@verdocs/web-sdk 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{VerdocsEndpoint-5e6dd8ef.js → VerdocsEndpoint-2c7ecda8.js} +7 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/verdocs-auth.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-dropdown_12.cjs.entry.js +3 -7
- package/dist/cjs/verdocs-quick-functions.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-search-activity_2.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-search.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-sign.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +1 -1
- package/dist/collection/components/embeds/verdocs-view/verdocs-view.js +2 -24
- package/dist/components/VerdocsEndpoint.js +7 -0
- package/dist/components/verdocs-sign.js +1 -1
- package/dist/components/verdocs-view2.js +2 -7
- package/dist/docs.json +1 -18
- package/dist/esm/{VerdocsEndpoint-30e1b6ec.js → VerdocsEndpoint-1dbbd8e2.js} +7 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/verdocs-auth.entry.js +1 -1
- package/dist/esm/verdocs-dropdown_12.entry.js +3 -7
- package/dist/esm/verdocs-quick-functions.entry.js +1 -1
- package/dist/esm/verdocs-search-activity_2.entry.js +1 -1
- package/dist/esm/verdocs-search.entry.js +1 -1
- package/dist/esm/verdocs-sign.entry.js +2 -2
- package/dist/esm/verdocs-web-sdk.js +1 -1
- package/dist/esm-es5/{VerdocsEndpoint-30e1b6ec.js → VerdocsEndpoint-1dbbd8e2.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/verdocs-auth.entry.js +1 -1
- package/dist/esm-es5/verdocs-dropdown_12.entry.js +2 -2
- package/dist/esm-es5/verdocs-quick-functions.entry.js +1 -1
- package/dist/esm-es5/verdocs-search-activity_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-search.entry.js +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js +1 -1
- package/dist/esm-es5/verdocs-web-sdk.js +1 -1
- package/dist/types/components/embeds/verdocs-view/verdocs-view.d.ts +0 -5
- package/dist/types/components.d.ts +0 -8
- package/dist/verdocs-web-sdk/{p-d522de7d.entry.js → p-4cfc0f04.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-f6a53928.system.entry.js → p-4e98796c.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-1b4e04b7.system.entry.js → p-5bd83ddc.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-c29c2cf8.entry.js → p-6b8bc6f4.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-4d80d044.system.js → p-6fd6ae35.system.js} +1 -1
- package/dist/verdocs-web-sdk/{p-16d62a51.system.entry.js → p-7adcb52c.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-88a300c5.system.js +1 -1
- package/dist/verdocs-web-sdk/{p-8276345a.entry.js → p-9e3a842c.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-aa9fc574.entry.js → p-a55ed8ce.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-06f38046.js → p-c34360d3.js} +1 -1
- package/dist/verdocs-web-sdk/{p-9139a76d.system.entry.js → p-cc12ccaa.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-30cc8818.entry.js → p-e3229752.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-1ea3b9d3.entry.js → p-f74862f7.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-c4d03ff9.system.entry.js → p-f76721d3.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-a87069d5.system.entry.js → p-fdf34ca6.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +2 -2
- package/dist/custom-elements.json +0 -830
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./p-2bc58746.js";import{c as createPopper}from"./p-4c66f794.js";import{d as getAugmentedNamespace,e as createCommonjsModule,f as getDefaultExportFromCjs,h as commonjsGlobal,B as Buffer,i as commonjsRequire,p as process_1,V as VerdocsEndpoint}from"./p-06f38046.js";const SortDown='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#50BE80"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M7 10l5 5 5-5H7z"/></svg>\n',verdocsDropdownCss='verdocs-dropdown{font-family:"Barlow", sans-serif;display:block}verdocs-dropdown .arrow{width:32px;height:26px;background:#fff;cursor:pointer;border-radius:4px;-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;border:1px solid #cccccc;-ms-flex-pack:center;justify-content:center}verdocs-dropdown .arrow svg{fill:#55bc81;-webkit-transition:0.3s;transition:0.3s}verdocs-dropdown .items{width:200px;display:none;z-index:10000;border-radius:5px;background:#33354c;border:1px solid #654dcb}verdocs-dropdown .items[data-show]{display:block}verdocs-dropdown .option{width:100%;color:#fff;border:none;display:block;text-align:left;background:none;padding:10px 20px}verdocs-dropdown .option:hover{cursor:pointer;background:#55bc81}verdocs-dropdown .option[disabled]{color:#aaaaaa}verdocs-dropdown .option[disabled]:hover{color:#aaaaaa;cursor:inherit;background:transparent}verdocs-dropdown.open .items{display:block}verdocs-dropdown.open .arrow{background:#4c56cb;border:1px solid #707ae5}verdocs-dropdown.open .arrow svg{-webkit-transform:scaleY(-1);transform:scaleY(-1);fill:#fff}',VerdocsDropdown=class{constructor(t){registerInstance(this,t),this.optionSelected=createEvent(this,"optionSelected",7),this.options=[]}componentWillLoad(){this.isOpen=!!this.open}componentDidLoad(){this.popper=createPopper(this.dropdownButton,this.dropdownMenu,{placement:"bottom-start",modifiers:[{name:"offset",options:{offset:[0,6]}}]})}handleSelectOption(t){this.isOpen=!1,this.optionSelected.emit(t),this.hide()}showDropdown(){var t,e;this.isOpen=!0,this.dropdownMenu.setAttribute("data-show",""),this.dropdownMenu.removeAttribute("aria-hidden"),null===(t=this.popper)||void 0===t||t.setOptions((t=>({...t,modifiers:[...t.modifiers,{name:"eventListeners",enabled:!0}]}))),null===(e=this.popper)||void 0===e||e.update()}handleHideDropdown(t){var e,s;"button"===(null===(e=null==t?void 0:t.target)||void 0===e?void 0:e.localName)&&"arrow"===(null===(s=null==t?void 0:t.target)||void 0===s?void 0:s.className)||this.hide()}toggleDropdown(){this.isOpen?this.hide():this.showDropdown()}hide(){var t;this.isOpen=!1,this.dropdownMenu.removeAttribute("data-show"),this.dropdownMenu.setAttribute("aria-hidden","true"),null===(t=this.popper)||void 0===t||t.setOptions((t=>({...t,modifiers:[...t.modifiers,{name:"eventListeners",enabled:!1}]})))}render(){var t;return h(Host,{class:{storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV),open:!!this.isOpen}},h("button",{class:"arrow",innerHTML:SortDown,"aria-label":"Open Menu",onClick:()=>this.toggleDropdown(),onBlur:t=>this.handleHideDropdown(t),ref:t=>this.dropdownButton=t}),h("div",{class:"items","aria-hidden":!this.open,ref:t=>this.dropdownMenu=t},null===(t=this.options)||void 0===t?void 0:t.map((t=>h("button",{onClick:()=>this.handleSelectOption(t),class:"option",disabled:t.disabled},t.label)))))}};VerdocsDropdown.style=verdocsDropdownCss;const Paperclip='<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">\n <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />\n</svg>\n',verdocsFieldAttachmentCss='verdocs-field-attachment{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:24px;height:24px;display:block;font-size:11px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-attachment span{width:20px;cursor:pointer}verdocs-field-attachment.required span{border:1px solid #cc0000}verdocs-field-attachment.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldAttachment=class{constructor(t){registerInstance(this,t),this.fieldChange=createEvent(this,"fieldChange",7),this.order=1,this.value="",this.required=!1,this.disabled=!1}async focusField(){this.handleShow()}handleShow(){this.dialog=document.createElement("verdocs-upload-dialog"),this.dialog.open=!0,this.dialog.addEventListener("cancel",(()=>{var t;console.log("cancel"),null===(t=this.dialog)||void 0===t||t.remove()})),document.addEventListener("done",(t=>{var e;console.log("done",t),null===(e=this.dialog)||void 0===e||e.remove()})),document.body.append(this.dialog)}render(){return h(Host,{class:{required:this.required}},h("span",{innerHTML:Paperclip,onClick:()=>this.handleShow()}))}};VerdocsFieldAttachment.style=verdocsFieldAttachmentCss;const verdocsFieldCheckboxCss='@charset "UTF-8";verdocs-field-checkbox{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;font-size:11px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-checkbox label>input[type=checkbox]{display:none}verdocs-field-checkbox label>input[type=checkbox]+*::before{content:"";display:block;vertical-align:bottom;width:14px;height:14px;border-radius:2px;border:1px solid rgba(0, 0, 0, 0.2);-ms-flex-negative:0;flex-shrink:0}verdocs-field-checkbox label>input[type=checkbox]:checked+*{color:var(--verdocs-primary-color)}verdocs-field-checkbox label>input[type=checkbox]:checked+*::before{content:"✓";color:white;text-align:center;background:var(--verdocs-primary-color);border-color:var(--verdocs-primary-color)}verdocs-field-checkbox.required label>input[type=checkbox]+*::before{border:1px solid var(--verdocs-required-color)}verdocs-field-checkbox.hide{display:none}verdocs-field-checkbox.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldCheckbox=class{constructor(t){registerInstance(this,t),this.fieldChange=createEvent(this,"fieldChange",7),this.order=1,this.value=!1,this.required=!1,this.disabled=!1}handleChange(t){this.fieldChange.emit(t.target.checked)}render(){return h(Host,{class:{required:this.required}},h("label",null,h("input",{type:"checkbox",tabIndex:this.order,checked:this.value,disabled:this.disabled,required:this.required,onChange:t=>this.handleChange(t)}),h("span",null)))}};function hasProperty(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function lastItemOf(t){return t[t.length-1]}function pushUnique(t,...e){return e.forEach((e=>{t.includes(e)||t.push(e)})),t}function stringToArray(t,e){return t?t.split(e):[]}function isInRange(t,e,s){return(void 0===e||t>=e)&&(void 0===s||t<=s)}function limitToRange(t,e,s){return t<e?e:t>s?s:t}function createTagRepeat(t,e,s={},i=0,n=""){n+=`<${Object.keys(s).reduce(((t,e)=>{let n=s[e];return"function"==typeof n&&(n=n(i)),`${t} ${e}="${n}"`}),t)}></${t}>`;const r=i+1;return r<e?createTagRepeat(t,e,s,r,n):n}function optimizeTemplateHTML(t){return t.replace(/>\s+/g,">").replace(/\s+</,"<")}function stripTime(t){return new Date(t).setHours(0,0,0,0)}function today(){return(new Date).setHours(0,0,0,0)}function dateValue(...t){switch(t.length){case 0:return today();case 1:return stripTime(t[0])}const e=new Date(0);return e.setFullYear(...t),e.setHours(0,0,0,0)}function addDays(t,e){const s=new Date(t);return s.setDate(s.getDate()+e)}function addWeeks(t,e){return addDays(t,7*e)}function addMonths(t,e){const s=new Date(t),i=s.getMonth()+e;let n=i%12;n<0&&(n+=12);const r=s.setMonth(i);return s.getMonth()!==n?s.setDate(0):r}function addYears(t,e){const s=new Date(t),i=s.getMonth(),n=s.setFullYear(s.getFullYear()+e);return 1===i&&2===s.getMonth()?s.setDate(0):n}function dayDiff(t,e){return(t-e+7)%7}function dayOfTheWeekOf(t,e,s=0){const i=new Date(t).getDay();return addDays(t,dayDiff(e,s)-dayDiff(i,s))}function getWeek(t){const e=dayOfTheWeekOf(t,4,1),s=dayOfTheWeekOf(new Date(e).setMonth(0,4),4,1);return Math.round((e-s)/6048e5)+1}function startOfYearPeriod(t,e){const s=new Date(t).getFullYear();return Math.floor(s/e)*e}function regularizeDate(t,e,s){if(1!==e&&2!==e)return t;const i=new Date(t);return 1===e?s?i.setMonth(i.getMonth()+1,0):i.setDate(1):s?i.setFullYear(i.getFullYear()+1,0,0):i.setMonth(0,1),i.setHours(0,0,0,0)}VerdocsFieldCheckbox.style=verdocsFieldCheckboxCss;const reFormatTokens=/dd?|DD?|mm?|MM?|yy?(?:yy)?/,reNonDateParts=/[\s!-/:-@[-`{-~年月日]+/;let knownFormats={};const parseFns={y:(t,e)=>new Date(t).setFullYear(parseInt(e,10)),m(t,e,s){const i=new Date(t);let n=parseInt(e,10)-1;if(isNaN(n)){if(!e)return NaN;const t=e.toLowerCase(),i=e=>e.toLowerCase().startsWith(t);if(n=s.monthsShort.findIndex(i),n<0&&(n=s.months.findIndex(i)),n<0)return NaN}return i.setMonth(n),i.getMonth()!==normalizeMonth(n)?i.setDate(0):i.getTime()},d:(t,e)=>new Date(t).setDate(parseInt(e,10))},formatFns={d:t=>t.getDate(),dd:t=>padZero(t.getDate(),2),D:(t,e)=>e.daysShort[t.getDay()],DD:(t,e)=>e.days[t.getDay()],m:t=>t.getMonth()+1,mm:t=>padZero(t.getMonth()+1,2),M:(t,e)=>e.monthsShort[t.getMonth()],MM:(t,e)=>e.months[t.getMonth()],y:t=>t.getFullYear(),yy:t=>padZero(t.getFullYear(),2).slice(-2),yyyy:t=>padZero(t.getFullYear(),4)};function normalizeMonth(t){return t>-1?t%12:normalizeMonth(t+12)}function padZero(t,e){return t.toString().padStart(e,"0")}function parseFormatString(t){if("string"!=typeof t)throw new Error("Invalid date format.");if(t in knownFormats)return knownFormats[t];const e=t.split(reFormatTokens),s=t.match(new RegExp(reFormatTokens,"g"));if(0===e.length||!s)throw new Error("Invalid date format.");const i=s.map((t=>formatFns[t])),n=Object.keys(parseFns).reduce(((t,e)=>(s.find((t=>"D"!==t[0]&&t[0].toLowerCase()===e))&&t.push(e),t)),[]);return knownFormats[t]={parser(t,e){const i=t.split(reNonDateParts).reduce(((t,e,i)=>{if(e.length>0&&s[i]){const n=s[i][0];"M"===n?t.m=e:"D"!==n&&(t[n]=e)}return t}),{});return n.reduce(((t,s)=>{const n=parseFns[s](t,i[s],e);return isNaN(n)?t:n}),today())},formatter:(t,s)=>i.reduce(((i,n,r)=>i+`${e[r]}${n(t,s)}`),"")+lastItemOf(e)}}function parseDate(t,e,s){if(t instanceof Date||"number"==typeof t){const e=stripTime(t);return isNaN(e)?void 0:e}if(t){if("today"===t)return today();if(e&&e.toValue){const i=e.toValue(t,e,s);return isNaN(i)?void 0:stripTime(i)}return parseFormatString(e).parser(t,s)}}function formatDate(t,e,s){if(isNaN(t)||!t&&0!==t)return"";const i="number"==typeof t?new Date(t):t;return e.toDisplay?e.toDisplay(i,e,s):parseFormatString(e).formatter(i,s)}const range=document.createRange();function parseHTML(t){return range.createContextualFragment(t)}function getParent(t){return t.parentElement||(t.parentNode instanceof ShadowRoot?t.parentNode.host:void 0)}function isActiveElement(t){return t.getRootNode().activeElement===t}function hideElement(t){"none"!==t.style.display&&(t.style.display&&(t.dataset.styleDisplay=t.style.display),t.style.display="none")}function showElement(t){"none"===t.style.display&&(t.dataset.styleDisplay?(t.style.display=t.dataset.styleDisplay,delete t.dataset.styleDisplay):t.style.display="")}function emptyChildNodes(t){t.firstChild&&(t.removeChild(t.firstChild),emptyChildNodes(t))}function replaceChildNodes(t,e){emptyChildNodes(t),e instanceof DocumentFragment?t.appendChild(e):"string"==typeof e?t.appendChild(parseHTML(e)):"function"==typeof e.forEach&&e.forEach((e=>{t.appendChild(e)}))}const listenerRegistry=new WeakMap,{addEventListener,removeEventListener}=EventTarget.prototype;function registerListeners(t,e){let s=listenerRegistry.get(t);s||(s=[],listenerRegistry.set(t,s)),e.forEach((t=>{addEventListener.call(...t),s.push(t)}))}function unregisterListeners(t){let e=listenerRegistry.get(t);e&&(e.forEach((t=>{removeEventListener.call(...t)})),listenerRegistry.delete(t))}if(!Event.prototype.composedPath){const t=(e,s=[])=>{let i;return s.push(e),e.parentNode?i=e.parentNode:e.host?i=e.host:e.defaultView&&(i=e.defaultView),i?t(i,s):s};Event.prototype.composedPath=function(){return t(this.target)}}function findFromPath(t,e,s){const[i,...n]=t;return e(i)?i:i!==s&&"HTML"!==i.tagName&&0!==n.length?findFromPath(n,e,s):void 0}function findElementInEventPath(t,e){const s="function"==typeof e?e:t=>t instanceof Element&&t.matches(e);return findFromPath(t.composedPath(),s,t.currentTarget)}const locales={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",titleFormat:"MM y"}},defaultOptions={autohide:!1,beforeShowDay:null,beforeShowDecade:null,beforeShowMonth:null,beforeShowYear:null,calendarWeeks:!1,clearBtn:!1,dateDelimiter:",",datesDisabled:[],daysOfWeekDisabled:[],daysOfWeekHighlighted:[],defaultViewDate:void 0,disableTouchKeyboard:!1,format:"mm/dd/yyyy",language:"en",maxDate:null,maxNumberOfDates:1,maxView:3,minDate:null,nextArrow:"»",orientation:"auto",pickLevel:0,prevArrow:"«",showDaysOfWeek:!0,showOnClick:!0,showOnFocus:!0,startView:0,title:"",todayBtn:!1,todayBtnMode:0,todayHighlight:!1,updateOnBlur:!0,weekStart:0},{language:defaultLang,format:defaultFormat,weekStart:defaultWeekStart}=defaultOptions;function sanitizeDOW(t,e){return t.length<6&&e>=0&&e<7?pushUnique(t,e):t}function calcEndOfWeek(t){return(t+6)%7}function validateDate(t,e,s,i){const n=parseDate(t,e,s);return void 0!==n?n:i}function validateViewId(t,e,s=3){const i=parseInt(t,10);return i>=0&&i<=s?i:e}function processOptions(t,e){const s=Object.assign({},t),i={},n=e.constructor.locales,r=e.rangeSideIndex;let{format:o,language:a,locale:h,maxDate:c,maxView:l,minDate:d,pickLevel:u,startView:f,weekStart:p}=e.config||{};if(s.language){let t;if(s.language!==a&&(n[s.language]?t=s.language:(t=s.language.split("-")[0],void 0===n[t]&&(t=!1))),delete s.language,t){a=i.language=t;const e=h||n[defaultLang];h=Object.assign({format:defaultFormat,weekStart:defaultWeekStart},n[defaultLang]),a!==defaultLang&&Object.assign(h,n[a]),i.locale=h,o===e.format&&(o=i.format=h.format),p===e.weekStart&&(p=i.weekStart=h.weekStart,i.weekEnd=calcEndOfWeek(h.weekStart))}}if(s.format){const t="function"==typeof s.format.toDisplay,e="function"==typeof s.format.toValue,n=reFormatTokens.test(s.format);(t&&e||n)&&(o=i.format=s.format),delete s.format}let g=u;void 0!==s.pickLevel&&(g=validateViewId(s.pickLevel,2),delete s.pickLevel),g!==u&&(g>u&&(void 0===s.minDate&&(s.minDate=d),void 0===s.maxDate&&(s.maxDate=c)),s.datesDisabled||(s.datesDisabled=[]),u=i.pickLevel=g);let b=d,A=c;if(void 0!==s.minDate){const t=dateValue(0,0,1);b=null===s.minDate?t:validateDate(s.minDate,o,h,b),b!==t&&(b=regularizeDate(b,u,!1)),delete s.minDate}if(void 0!==s.maxDate&&(A=null===s.maxDate?void 0:validateDate(s.maxDate,o,h,A),void 0!==A&&(A=regularizeDate(A,u,!0)),delete s.maxDate),A<b?(d=i.minDate=A,c=i.maxDate=b):(d!==b&&(d=i.minDate=b),c!==A&&(c=i.maxDate=A)),s.datesDisabled&&(i.datesDisabled=s.datesDisabled.reduce(((t,e)=>{const s=parseDate(e,o,h);return void 0!==s?pushUnique(t,regularizeDate(s,u,r)):t}),[]),delete s.datesDisabled),void 0!==s.defaultViewDate){const t=parseDate(s.defaultViewDate,o,h);void 0!==t&&(i.defaultViewDate=t),delete s.defaultViewDate}if(void 0!==s.weekStart){const t=Number(s.weekStart)%7;isNaN(t)||(p=i.weekStart=t,i.weekEnd=calcEndOfWeek(t)),delete s.weekStart}if(s.daysOfWeekDisabled&&(i.daysOfWeekDisabled=s.daysOfWeekDisabled.reduce(sanitizeDOW,[]),delete s.daysOfWeekDisabled),s.daysOfWeekHighlighted&&(i.daysOfWeekHighlighted=s.daysOfWeekHighlighted.reduce(sanitizeDOW,[]),delete s.daysOfWeekHighlighted),void 0!==s.maxNumberOfDates){const t=parseInt(s.maxNumberOfDates,10);t>=0&&(i.maxNumberOfDates=t,i.multidate=1!==t),delete s.maxNumberOfDates}s.dateDelimiter&&(i.dateDelimiter=String(s.dateDelimiter),delete s.dateDelimiter);let m=l;void 0!==s.maxView&&(m=validateViewId(s.maxView,l),delete s.maxView),m=u>m?u:m,m!==l&&(l=i.maxView=m);let w=f;if(void 0!==s.startView&&(w=validateViewId(s.startView,w),delete s.startView),w<u?w=u:w>l&&(w=l),w!==f&&(i.startView=w),s.prevArrow){const t=parseHTML(s.prevArrow);t.childNodes.length>0&&(i.prevArrow=t.childNodes),delete s.prevArrow}if(s.nextArrow){const t=parseHTML(s.nextArrow);t.childNodes.length>0&&(i.nextArrow=t.childNodes),delete s.nextArrow}if(void 0!==s.disableTouchKeyboard&&(i.disableTouchKeyboard="ontouchstart"in document&&!!s.disableTouchKeyboard,delete s.disableTouchKeyboard),s.orientation){const t=s.orientation.toLowerCase().split(/\s+/g);i.orientation={x:t.find((t=>"left"===t||"right"===t))||"auto",y:t.find((t=>"top"===t||"bottom"===t))||"auto"},delete s.orientation}if(void 0!==s.todayBtnMode){switch(s.todayBtnMode){case 0:case 1:i.todayBtnMode=s.todayBtnMode}delete s.todayBtnMode}return Object.keys(s).forEach((t=>{void 0!==s[t]&&hasProperty(defaultOptions,t)&&(i[t]=s[t])})),i}const pickerTemplate=optimizeTemplateHTML('<div class="datepicker">\n <div class="datepicker-picker">\n <div class="datepicker-header">\n <div class="datepicker-title"></div>\n <div class="datepicker-controls">\n <button type="button" class="%buttonClass% prev-btn"></button>\n <button type="button" class="%buttonClass% view-switch"></button>\n <button type="button" class="%buttonClass% next-btn"></button>\n </div>\n </div>\n <div class="datepicker-main"></div>\n <div class="datepicker-footer">\n <div class="datepicker-controls">\n <button type="button" class="%buttonClass% today-btn"></button>\n <button type="button" class="%buttonClass% clear-btn"></button>\n </div>\n </div>\n </div>\n</div>'),daysTemplate=optimizeTemplateHTML(`<div class="days">\n <div class="days-of-week">${createTagRepeat("span",7,{class:"dow"})}</div>\n <div class="datepicker-grid">${createTagRepeat("span",42)}</div>\n</div>`),calendarWeeksTemplate=optimizeTemplateHTML(`<div class="calendar-weeks">\n <div class="days-of-week"><span class="dow"></span></div>\n <div class="weeks">${createTagRepeat("span",6,{class:"week"})}</div>\n</div>`);class View{constructor(t,e){Object.assign(this,e,{picker:t,element:parseHTML('<div class="datepicker-view"></div>').firstChild,selected:[]}),this.init(this.picker.datepicker.config)}init(t){void 0!==t.pickLevel&&(this.isMinView=this.id===t.pickLevel),this.setOptions(t),this.updateFocus(),this.updateSelection()}performBeforeHook(t,e,s){let i=this.beforeShow(new Date(s));switch(typeof i){case"boolean":i={enabled:i};break;case"string":i={classes:i}}if(i){if(!1===i.enabled&&(t.classList.add("disabled"),pushUnique(this.disabled,e)),i.classes){const s=i.classes.split(/\s+/);t.classList.add(...s),s.includes("disabled")&&pushUnique(this.disabled,e)}i.content&&replaceChildNodes(t,i.content)}}}class DaysView extends View{constructor(t){super(t,{id:0,name:"days",cellClass:"day"})}init(t,e=!0){if(e){const t=parseHTML(daysTemplate).firstChild;this.dow=t.firstChild,this.grid=t.lastChild,this.element.appendChild(t)}super.init(t)}setOptions(t){let e;if(hasProperty(t,"minDate")&&(this.minDate=t.minDate),hasProperty(t,"maxDate")&&(this.maxDate=t.maxDate),t.datesDisabled&&(this.datesDisabled=t.datesDisabled),t.daysOfWeekDisabled&&(this.daysOfWeekDisabled=t.daysOfWeekDisabled,e=!0),t.daysOfWeekHighlighted&&(this.daysOfWeekHighlighted=t.daysOfWeekHighlighted),void 0!==t.todayHighlight&&(this.todayHighlight=t.todayHighlight),void 0!==t.weekStart&&(this.weekStart=t.weekStart,this.weekEnd=t.weekEnd,e=!0),t.locale){const s=this.locale=t.locale;this.dayNames=s.daysMin,this.switchLabelFormat=s.titleFormat,e=!0}if(void 0!==t.beforeShowDay&&(this.beforeShow="function"==typeof t.beforeShowDay?t.beforeShowDay:void 0),void 0!==t.calendarWeeks)if(t.calendarWeeks&&!this.calendarWeeks){const t=parseHTML(calendarWeeksTemplate).firstChild;this.calendarWeeks={element:t,dow:t.firstChild,weeks:t.lastChild},this.element.insertBefore(t,this.element.firstChild)}else this.calendarWeeks&&!t.calendarWeeks&&(this.element.removeChild(this.calendarWeeks.element),this.calendarWeeks=null);void 0!==t.showDaysOfWeek&&(t.showDaysOfWeek?(showElement(this.dow),this.calendarWeeks&&showElement(this.calendarWeeks.dow)):(hideElement(this.dow),this.calendarWeeks&&hideElement(this.calendarWeeks.dow))),e&&Array.from(this.dow.children).forEach(((t,e)=>{const s=(this.weekStart+e)%7;t.textContent=this.dayNames[s],t.className=this.daysOfWeekDisabled.includes(s)?"dow disabled":"dow"}))}updateFocus(){const t=new Date(this.picker.viewDate),e=t.getFullYear(),s=t.getMonth(),i=dateValue(e,s,1),n=dayOfTheWeekOf(i,this.weekStart,this.weekStart);this.first=i,this.last=dateValue(e,s+1,0),this.start=n,this.focused=this.picker.viewDate}updateSelection(){const{dates:t,rangepicker:e}=this.picker.datepicker;this.selected=t,e&&(this.range=e.dates)}render(){this.today=this.todayHighlight?today():void 0,this.disabled=[...this.datesDisabled];const t=formatDate(this.focused,this.switchLabelFormat,this.locale);if(this.picker.setViewSwitchLabel(t),this.picker.setPrevBtnDisabled(this.first<=this.minDate),this.picker.setNextBtnDisabled(this.last>=this.maxDate),this.calendarWeeks){const t=dayOfTheWeekOf(this.first,1,1);Array.from(this.calendarWeeks.weeks.children).forEach(((e,s)=>{e.textContent=getWeek(addWeeks(t,s))}))}Array.from(this.grid.children).forEach(((t,e)=>{const s=t.classList,i=addDays(this.start,e),n=new Date(i),r=n.getDay();if(t.className=`datepicker-cell ${this.cellClass}`,t.dataset.date=i,t.textContent=n.getDate(),i<this.first?s.add("prev"):i>this.last&&s.add("next"),this.today===i&&s.add("today"),(i<this.minDate||i>this.maxDate||this.disabled.includes(i))&&s.add("disabled"),this.daysOfWeekDisabled.includes(r)&&(s.add("disabled"),pushUnique(this.disabled,i)),this.daysOfWeekHighlighted.includes(r)&&s.add("highlighted"),this.range){const[t,e]=this.range;i>t&&i<e&&s.add("range"),i===t&&s.add("range-start"),i===e&&s.add("range-end")}this.selected.includes(i)&&s.add("selected"),i===this.focused&&s.add("focused"),this.beforeShow&&this.performBeforeHook(t,i,i)}))}refresh(){const[t,e]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach((t=>{t.classList.remove("range","range-start","range-end","selected","focused")})),Array.from(this.grid.children).forEach((s=>{const i=Number(s.dataset.date),n=s.classList;i>t&&i<e&&n.add("range"),i===t&&n.add("range-start"),i===e&&n.add("range-end"),this.selected.includes(i)&&n.add("selected"),i===this.focused&&n.add("focused")}))}refreshFocus(){const t=Math.round((this.focused-this.start)/864e5);this.grid.querySelectorAll(".focused").forEach((t=>{t.classList.remove("focused")})),this.grid.children[t].classList.add("focused")}}function computeMonthRange(t,e){if(!t||!t[0]||!t[1])return;const[[s,i],[n,r]]=t;return s>e||n<e?void 0:[s===e?i:-1,n===e?r:12]}class MonthsView extends View{constructor(t){super(t,{id:1,name:"months",cellClass:"month"})}init(t,e=!0){e&&(this.grid=this.element,this.element.classList.add("months","datepicker-grid"),this.grid.appendChild(parseHTML(createTagRepeat("span",12,{"data-month":t=>t})))),super.init(t)}setOptions(t){if(t.locale&&(this.monthNames=t.locale.monthsShort),hasProperty(t,"minDate"))if(void 0===t.minDate)this.minYear=this.minMonth=this.minDate=void 0;else{const e=new Date(t.minDate);this.minYear=e.getFullYear(),this.minMonth=e.getMonth(),this.minDate=e.setDate(1)}if(hasProperty(t,"maxDate"))if(void 0===t.maxDate)this.maxYear=this.maxMonth=this.maxDate=void 0;else{const e=new Date(t.maxDate);this.maxYear=e.getFullYear(),this.maxMonth=e.getMonth(),this.maxDate=dateValue(this.maxYear,this.maxMonth+1,0)}this.isMinView?t.datesDisabled&&(this.datesDisabled=t.datesDisabled):this.datesDisabled=[],void 0!==t.beforeShowMonth&&(this.beforeShow="function"==typeof t.beforeShowMonth?t.beforeShowMonth:void 0)}updateFocus(){const t=new Date(this.picker.viewDate);this.year=t.getFullYear(),this.focused=t.getMonth()}updateSelection(){const{dates:t,rangepicker:e}=this.picker.datepicker;this.selected=t.reduce(((t,e)=>{const s=new Date(e),i=s.getFullYear(),n=s.getMonth();return void 0===t[i]?t[i]=[n]:pushUnique(t[i],n),t}),{}),e&&e.dates&&(this.range=e.dates.map((t=>{const e=new Date(t);return isNaN(e)?void 0:[e.getFullYear(),e.getMonth()]})))}render(){this.disabled=this.datesDisabled.reduce(((t,e)=>{const s=new Date(e);return this.year===s.getFullYear()&&t.push(s.getMonth()),t}),[]),this.picker.setViewSwitchLabel(this.year),this.picker.setPrevBtnDisabled(this.year<=this.minYear),this.picker.setNextBtnDisabled(this.year>=this.maxYear);const t=this.selected[this.year]||[],e=this.year<this.minYear||this.year>this.maxYear,s=this.year===this.minYear,i=this.year===this.maxYear,n=computeMonthRange(this.range,this.year);Array.from(this.grid.children).forEach(((r,o)=>{const a=r.classList,h=dateValue(this.year,o,1);if(r.className=`datepicker-cell ${this.cellClass}`,this.isMinView&&(r.dataset.date=h),r.textContent=this.monthNames[o],(e||s&&o<this.minMonth||i&&o>this.maxMonth||this.disabled.includes(o))&&a.add("disabled"),n){const[t,e]=n;o>t&&o<e&&a.add("range"),o===t&&a.add("range-start"),o===e&&a.add("range-end")}t.includes(o)&&a.add("selected"),o===this.focused&&a.add("focused"),this.beforeShow&&this.performBeforeHook(r,o,h)}))}refresh(){const t=this.selected[this.year]||[],[e,s]=computeMonthRange(this.range,this.year)||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach((t=>{t.classList.remove("range","range-start","range-end","selected","focused")})),Array.from(this.grid.children).forEach(((i,n)=>{const r=i.classList;n>e&&n<s&&r.add("range"),n===e&&r.add("range-start"),n===s&&r.add("range-end"),t.includes(n)&&r.add("selected"),n===this.focused&&r.add("focused")}))}refreshFocus(){this.grid.querySelectorAll(".focused").forEach((t=>{t.classList.remove("focused")})),this.grid.children[this.focused].classList.add("focused")}}function toTitleCase(t){return[...t].reduce(((t,e,s)=>t+(s?e:e.toUpperCase())),"")}class YearsView extends View{constructor(t,e){super(t,e)}init(t,e=!0){e&&(this.navStep=10*this.step,this.beforeShowOption=`beforeShow${toTitleCase(this.cellClass)}`,this.grid=this.element,this.element.classList.add(this.name,"datepicker-grid"),this.grid.appendChild(parseHTML(createTagRepeat("span",12)))),super.init(t)}setOptions(t){if(hasProperty(t,"minDate")&&(void 0===t.minDate?this.minYear=this.minDate=void 0:(this.minYear=startOfYearPeriod(t.minDate,this.step),this.minDate=dateValue(this.minYear,0,1))),hasProperty(t,"maxDate")&&(void 0===t.maxDate?this.maxYear=this.maxDate=void 0:(this.maxYear=startOfYearPeriod(t.maxDate,this.step),this.maxDate=dateValue(this.maxYear,11,31))),this.isMinView?t.datesDisabled&&(this.datesDisabled=t.datesDisabled):this.datesDisabled=[],void 0!==t[this.beforeShowOption]){const e=t[this.beforeShowOption];this.beforeShow="function"==typeof e?e:void 0}}updateFocus(){const t=new Date(this.picker.viewDate),e=startOfYearPeriod(t,this.navStep),s=e+9*this.step;this.first=e,this.last=s,this.start=e-this.step,this.focused=startOfYearPeriod(t,this.step)}updateSelection(){const{dates:t,rangepicker:e}=this.picker.datepicker;this.selected=t.reduce(((t,e)=>pushUnique(t,startOfYearPeriod(e,this.step))),[]),e&&e.dates&&(this.range=e.dates.map((t=>{if(void 0!==t)return startOfYearPeriod(t,this.step)})))}render(){this.disabled=this.datesDisabled.map((t=>new Date(t).getFullYear())),this.picker.setViewSwitchLabel(`${this.first}-${this.last}`),this.picker.setPrevBtnDisabled(this.first<=this.minYear),this.picker.setNextBtnDisabled(this.last>=this.maxYear),Array.from(this.grid.children).forEach(((t,e)=>{const s=t.classList,i=this.start+e*this.step,n=dateValue(i,0,1);if(t.className=`datepicker-cell ${this.cellClass}`,this.isMinView&&(t.dataset.date=n),t.textContent=t.dataset.year=i,0===e?s.add("prev"):11===e&&s.add("next"),(i<this.minYear||i>this.maxYear||this.disabled.includes(i))&&s.add("disabled"),this.range){const[t,e]=this.range;i>t&&i<e&&s.add("range"),i===t&&s.add("range-start"),i===e&&s.add("range-end")}this.selected.includes(i)&&s.add("selected"),i===this.focused&&s.add("focused"),this.beforeShow&&this.performBeforeHook(t,i,n)}))}refresh(){const[t,e]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach((t=>{t.classList.remove("range","range-start","range-end","selected","focused")})),Array.from(this.grid.children).forEach((s=>{const i=Number(s.textContent),n=s.classList;i>t&&i<e&&n.add("range"),i===t&&n.add("range-start"),i===e&&n.add("range-end"),this.selected.includes(i)&&n.add("selected"),i===this.focused&&n.add("focused")}))}refreshFocus(){const t=Math.round((this.focused-this.start)/this.step);this.grid.querySelectorAll(".focused").forEach((t=>{t.classList.remove("focused")})),this.grid.children[t].classList.add("focused")}}function triggerDatepickerEvent(t,e){const s={date:t.getDate(),viewDate:new Date(t.picker.viewDate),viewId:t.picker.currentView.id,datepicker:t};t.element.dispatchEvent(new CustomEvent(e,{detail:s}))}function goToPrevOrNext(t,e){const{minDate:s,maxDate:i}=t.config,{currentView:n,viewDate:r}=t.picker;let o;switch(n.id){case 0:o=addMonths(r,e);break;case 1:o=addYears(r,e);break;default:o=addYears(r,e*n.navStep)}o=limitToRange(o,s,i),t.picker.changeFocus(o).render()}function switchView(t){const e=t.picker.currentView.id;e!==t.config.maxView&&t.picker.changeView(e+1).render()}function unfocus(t){t.config.updateOnBlur?t.update({revert:!0}):t.refresh("input"),t.hide()}function goToSelectedMonthOrYear(t,e){const s=t.picker,i=new Date(s.viewDate),n=s.currentView.id,r=1===n?addMonths(i,e-i.getMonth()):addYears(i,e-i.getFullYear());s.changeFocus(r).changeView(n-1).render()}function onClickTodayBtn(t){const e=t.picker,s=today();if(1===t.config.todayBtnMode){if(t.config.autohide)return void t.setDate(s);t.setDate(s,{render:!1}),e.update()}e.viewDate!==s&&e.changeFocus(s),e.changeView(0).render()}function onClickClearBtn(t){t.setDate({clear:!0})}function onClickViewSwitch(t){switchView(t)}function onClickPrevBtn(t){goToPrevOrNext(t,-1)}function onClickNextBtn(t){goToPrevOrNext(t,1)}function onClickView(t,e){const s=findElementInEventPath(e,".datepicker-cell");if(!s||s.classList.contains("disabled"))return;const{id:i,isMinView:n}=t.picker.currentView;n?t.setDate(Number(s.dataset.date)):goToSelectedMonthOrYear(t,Number(1===i?s.dataset.month:s.dataset.year))}function onMousedownPicker(t){t.preventDefault()}const orientClasses=["left","top","right","bottom"].reduce(((t,e)=>(t[e]=`datepicker-orient-${e}`,t)),{}),toPx=t=>t?`${t}px`:t;function processPickerOptions(t,e){if(void 0!==e.title&&(e.title?(t.controls.title.textContent=e.title,showElement(t.controls.title)):(t.controls.title.textContent="",hideElement(t.controls.title))),e.prevArrow){const s=t.controls.prevBtn;emptyChildNodes(s),e.prevArrow.forEach((t=>{s.appendChild(t.cloneNode(!0))}))}if(e.nextArrow){const s=t.controls.nextBtn;emptyChildNodes(s),e.nextArrow.forEach((t=>{s.appendChild(t.cloneNode(!0))}))}if(e.locale&&(t.controls.todayBtn.textContent=e.locale.today,t.controls.clearBtn.textContent=e.locale.clear),void 0!==e.todayBtn&&(e.todayBtn?showElement(t.controls.todayBtn):hideElement(t.controls.todayBtn)),hasProperty(e,"minDate")||hasProperty(e,"maxDate")){const{minDate:e,maxDate:s}=t.datepicker.config;t.controls.todayBtn.disabled=!isInRange(today(),e,s)}void 0!==e.clearBtn&&(e.clearBtn?showElement(t.controls.clearBtn):hideElement(t.controls.clearBtn))}function computeResetViewDate(t){const{dates:e,config:s}=t;return limitToRange(e.length>0?lastItemOf(e):s.defaultViewDate,s.minDate,s.maxDate)}function setViewDate(t,e){const s=new Date(t.viewDate),i=new Date(e),{id:n,year:r,first:o,last:a}=t.currentView,h=i.getFullYear();switch(t.viewDate=e,h!==s.getFullYear()&&triggerDatepickerEvent(t.datepicker,"changeYear"),i.getMonth()!==s.getMonth()&&triggerDatepickerEvent(t.datepicker,"changeMonth"),n){case 0:return e<o||e>a;case 1:return h!==r;default:return h<o||h>a}}function getTextDirection(t){return window.getComputedStyle(t).direction}function findScrollParents(t){const e=getParent(t);if(e!==document.body&&e)return"visible"!==window.getComputedStyle(e).overflow?e:findScrollParents(e)}class Picker{constructor(t){const{config:e}=this.datepicker=t,s=pickerTemplate.replace(/%buttonClass%/g,e.buttonClass),i=this.element=parseHTML(s).firstChild,[n,r,o]=i.firstChild.children,a=n.firstElementChild,[h,c,l]=n.lastElementChild.children,[d,u]=o.firstChild.children,f={title:a,prevBtn:h,viewSwitch:c,nextBtn:l,todayBtn:d,clearBtn:u};this.main=r,this.controls=f,i.classList.add("datepicker-"+(t.inline?"inline":"dropdown")),processPickerOptions(this,e),this.viewDate=computeResetViewDate(t),registerListeners(t,[[i,"mousedown",onMousedownPicker],[r,"click",onClickView.bind(null,t)],[f.viewSwitch,"click",onClickViewSwitch.bind(null,t)],[f.prevBtn,"click",onClickPrevBtn.bind(null,t)],[f.nextBtn,"click",onClickNextBtn.bind(null,t)],[f.todayBtn,"click",onClickTodayBtn.bind(null,t)],[f.clearBtn,"click",onClickClearBtn.bind(null,t)]]),this.views=[new DaysView(this),new MonthsView(this),new YearsView(this,{id:2,name:"years",cellClass:"year",step:1}),new YearsView(this,{id:3,name:"decades",cellClass:"decade",step:10})],this.currentView=this.views[e.startView],this.currentView.render(),this.main.appendChild(this.currentView.element),e.container?e.container.appendChild(this.element):t.inputField.after(this.element)}setOptions(t){processPickerOptions(this,t),this.views.forEach((e=>{e.init(t,!1)})),this.currentView.render()}detach(){this.element.remove()}show(){if(this.active)return;const{datepicker:t,element:e}=this;if(t.inline)e.classList.add("active");else{const s=getTextDirection(t.inputField);s!==getTextDirection(getParent(e))?e.dir=s:e.dir&&e.removeAttribute("dir"),e.style.visiblity="hidden",e.classList.add("active"),this.place(),e.style.visiblity="",t.config.disableTouchKeyboard&&t.inputField.blur()}this.active=!0,triggerDatepickerEvent(t,"show")}hide(){this.active&&(this.datepicker.exitEditMode(),this.element.classList.remove("active"),this.active=!1,triggerDatepickerEvent(this.datepicker,"hide"))}place(){const{classList:t,offsetParent:e,style:s}=this.element,{config:i,inputField:n}=this.datepicker,{width:r,height:o}=this.element.getBoundingClientRect(),{left:a,top:h,right:c,bottom:l,width:d,height:u}=n.getBoundingClientRect();let{x:f,y:p}=i.orientation,g=a,b=h;if(e!==document.body&&e){const t=e.getBoundingClientRect();g-=t.left-e.scrollLeft,b-=t.top-e.scrollTop}else g+=window.scrollX,b+=window.scrollY;const A=findScrollParents(n);let m=0,w=0,{clientWidth:v,clientHeight:k}=document.documentElement;if(A){const t=A.getBoundingClientRect();t.top>0&&(w=t.top),t.left>0&&(m=t.left),t.right<v&&(v=t.right),t.bottom<k&&(k=t.bottom)}let x=0;"auto"===f&&(a<m?(f="left",x=m-a):a+r>v?(f="right",v<c&&(x=v-c)):f="rtl"===getTextDirection(n)?c-r<m?"left":"right":"left"),"right"===f&&(g+=d-r),g+=x,"auto"===p&&(p=h-o>w&&l+o>k?"top":"bottom"),"top"===p?b-=o:b+=u,t.remove(...Object.values(orientClasses)),t.add(orientClasses[f],orientClasses[p]),s.left=toPx(g),s.top=toPx(b)}setViewSwitchLabel(t){this.controls.viewSwitch.textContent=t}setPrevBtnDisabled(t){this.controls.prevBtn.disabled=t}setNextBtnDisabled(t){this.controls.nextBtn.disabled=t}changeView(t){const e=this.currentView,s=this.views[t];return s.id!==e.id&&(this.currentView=s,this._renderMethod="render",triggerDatepickerEvent(this.datepicker,"changeView"),this.main.replaceChild(s.element,e.element)),this}changeFocus(t){return this._renderMethod=setViewDate(this,t)?"render":"refreshFocus",this.views.forEach((t=>{t.updateFocus()})),this}update(){const t=computeResetViewDate(this.datepicker);return this._renderMethod=setViewDate(this,t)?"render":"refresh",this.views.forEach((t=>{t.updateFocus(),t.updateSelection()})),this}render(t=!0){const e=t&&this._renderMethod||"render";delete this._renderMethod,this.currentView[e]()}}function findNextAvailableOne(t,e,s,i,n,r){if(isInRange(t,n,r))return i(t)?findNextAvailableOne(e(t,s),e,s,i,n,r):t}function moveByArrowKey(t,e,s,i){const n=t.picker,r=n.currentView,o=r.step||1;let a,h,c=n.viewDate;switch(r.id){case 0:c=i?addDays(c,7*s):e.ctrlKey||e.metaKey?addYears(c,s):addDays(c,s),a=addDays,h=t=>r.disabled.includes(t);break;case 1:c=addMonths(c,i?4*s:s),a=addMonths,h=t=>{const e=new Date(t),{year:s,disabled:i}=r;return e.getFullYear()===s&&i.includes(e.getMonth())};break;default:c=addYears(c,s*(i?4:1)*o),a=addYears,h=t=>r.disabled.includes(startOfYearPeriod(t,o))}c=findNextAvailableOne(c,a,s<0?-o:o,h,r.minDate,r.maxDate),void 0!==c&&n.changeFocus(c).render()}function onKeydown(t,e){const s=e.key;if("Tab"===s)return void unfocus(t);const i=t.picker,{id:n,isMinView:r}=i.currentView;if(i.active){if(t.editMode)return void("Enter"===s?t.exitEditMode({update:!0,autohide:t.config.autohide}):"Escape"===s&&i.hide());if("ArrowLeft"===s)if(e.ctrlKey||e.metaKey)goToPrevOrNext(t,-1);else{if(e.shiftKey)return void t.enterEditMode();moveByArrowKey(t,e,-1,!1)}else if("ArrowRight"===s)if(e.ctrlKey||e.metaKey)goToPrevOrNext(t,1);else{if(e.shiftKey)return void t.enterEditMode();moveByArrowKey(t,e,1,!1)}else if("ArrowUp"===s)if(e.ctrlKey||e.metaKey)switchView(t);else{if(e.shiftKey)return void t.enterEditMode();moveByArrowKey(t,e,-1,!0)}else if("ArrowDown"===s){if(e.shiftKey&&!e.ctrlKey&&!e.metaKey)return void t.enterEditMode();moveByArrowKey(t,e,1,!0)}else{if("Enter"!==s)return void("Escape"===s?i.hide():"Backspace"!==s&&"Delete"!==s&&(1!==s.length||e.ctrlKey||e.metaKey)||t.enterEditMode());if(r)return void t.setDate(i.viewDate);i.changeView(n-1).render()}}else{if("ArrowDown"!==s)return void("Enter"===s?t.update():"Escape"===s&&i.show());i.show()}e.preventDefault()}function onFocus(t){t.config.showOnFocus&&!t._showing&&t.show()}function onMousedown(t,e){const s=e.target;(t.picker.active||t.config.showOnClick)&&(s._active=isActiveElement(s),s._clicking=setTimeout((()=>{delete s._active,delete s._clicking}),2e3))}function onClickInput(t,e){const s=e.target;s._clicking&&(clearTimeout(s._clicking),delete s._clicking,s._active&&t.enterEditMode(),delete s._active,t.config.showOnClick&&t.show())}function onPaste(t,e){e.clipboardData.types.includes("text/plain")&&t.enterEditMode()}function onClickOutside(t,e){const{element:s,picker:i}=t;if(!i.active&&!isActiveElement(s))return;const n=i.element;findElementInEventPath(e,(t=>t===s||t===n))||unfocus(t)}function stringifyDates(t,e){return t.map((t=>formatDate(t,e.format,e.locale))).join(e.dateDelimiter)}function processInputDates(t,e,s=!1){const{config:i,dates:n,rangeSideIndex:r}=t;if(0===e.length)return s?[]:void 0;let o=e.reduce(((t,e)=>{let s=parseDate(e,i.format,i.locale);return void 0===s||(s=regularizeDate(s,i.pickLevel,r),!isInRange(s,i.minDate,i.maxDate)||t.includes(s)||i.datesDisabled.includes(s)||!(i.pickLevel>0)&&i.daysOfWeekDisabled.includes(new Date(s).getDay())||t.push(s)),t}),[]);return 0!==o.length?(i.multidate&&!s&&(o=o.reduce(((t,e)=>(n.includes(e)||t.push(e),t)),n.filter((t=>!o.includes(t))))),i.maxNumberOfDates&&o.length>i.maxNumberOfDates?o.slice(-1*i.maxNumberOfDates):o):void 0}function refreshUI(t,e=3,s=!0){const{config:i,picker:n,inputField:r}=t;if(2&e){const t=n.active?i.pickLevel:i.startView;n.update().changeView(t).render(s)}1&e&&r&&(r.value=stringifyDates(t.dates,i))}function setDate(t,e,s){let{clear:i,render:n,autohide:r,revert:o}=s;void 0===n&&(n=!0),n?void 0===r&&(r=t.config.autohide):r=!1;const a=processInputDates(t,e,i);(a||o)&&(a&&a.toString()!==t.dates.toString()?(t.dates=a,refreshUI(t,n?3:1),triggerDatepickerEvent(t,"changeDate")):refreshUI(t,1),r&&t.hide())}class Datepicker{constructor(t,e={},s){t.datepicker=this,this.element=t;const i=this.config=Object.assign({buttonClass:e.buttonClass&&String(e.buttonClass)||"button",container:null,defaultViewDate:today(),maxDate:void 0,minDate:void 0},processOptions(defaultOptions,this)),n=this.inline="INPUT"!==t.tagName;let r,o;if(n?i.container=t:(e.container&&(i.container=e.container instanceof HTMLElement?e.container:document.querySelector(e.container)),r=this.inputField=t,r.classList.add("datepicker-input")),s){const t=s.inputs.indexOf(r),e=s.datepickers;if(t<0||t>1||!Array.isArray(e))throw Error("Invalid rangepicker object.");e[t]=this,Object.defineProperty(this,"rangepicker",{get:()=>s}),Object.defineProperty(this,"rangeSideIndex",{get:()=>t})}this._options=e,Object.assign(i,processOptions(e,this)),n?(o=stringToArray(t.dataset.date,i.dateDelimiter),delete t.dataset.date):o=stringToArray(r.value,i.dateDelimiter),this.dates=[];const a=processInputDates(this,o);a&&a.length>0&&(this.dates=a),r&&(r.value=stringifyDates(this.dates,i));const h=this.picker=new Picker(this);if(n)this.show();else{const t=onClickOutside.bind(null,this);registerListeners(this,[[r,"keydown",onKeydown.bind(null,this)],[r,"focus",onFocus.bind(null,this)],[r,"mousedown",onMousedown.bind(null,this)],[r,"click",onClickInput.bind(null,this)],[r,"paste",onPaste.bind(null,this)],[document,"mousedown",t],[document,"touchstart",t],[window,"resize",h.place.bind(h)]])}}static formatDate(t,e,s){return formatDate(t,e,s&&locales[s]||locales.en)}static parseDate(t,e,s){return parseDate(t,e,s&&locales[s]||locales.en)}static get locales(){return locales}get active(){return!(!this.picker||!this.picker.active)}get pickerElement(){return this.picker?this.picker.element:void 0}setOptions(t){const e=this.picker,s=processOptions(t,this);Object.assign(this._options,t),Object.assign(this.config,s),e.setOptions(s),refreshUI(this,3)}show(){if(this.inputField){if(this.inputField.disabled)return;isActiveElement(this.inputField)||this.config.disableTouchKeyboard||(this._showing=!0,this.inputField.focus(),delete this._showing)}this.picker.show()}hide(){this.inline||(this.picker.hide(),this.picker.update().changeView(this.config.startView).render())}destroy(){return this.hide(),unregisterListeners(this),this.picker.detach(),this.inline||this.inputField.classList.remove("datepicker-input"),delete this.element.datepicker,this}getDate(t){const e=t?e=>formatDate(e,t,this.config.locale):t=>new Date(t);return this.config.multidate?this.dates.map(e):this.dates.length>0?e(this.dates[0]):void 0}setDate(...t){const e=[...t],s={},i=lastItemOf(t);"object"!=typeof i||Array.isArray(i)||i instanceof Date||!i||Object.assign(s,e.pop()),setDate(this,Array.isArray(e[0])?e[0]:e,s)}update(t){if(this.inline)return;const e=Object.assign(t||{},{clear:!0,render:!0});setDate(this,stringToArray(this.inputField.value,this.config.dateDelimiter),e)}refresh(t,e=!1){let s;t&&"string"!=typeof t&&(e=t,t=void 0),s="picker"===t?2:"input"===t?1:3,refreshUI(this,s,!e)}enterEditMode(){this.inline||!this.picker.active||this.editMode||(this.editMode=!0,this.inputField.classList.add("in-edit"))}exitEditMode(t){if(this.inline||!this.editMode)return;const e=Object.assign({update:!1},t);delete this.editMode,this.inputField.classList.remove("in-edit"),e.update&&this.update(e)}}const verdocsFieldDateCss='.datepicker{display:none}.datepicker.active{display:block}.datepicker-dropdown{position:absolute;top:0;left:0;z-index:20;padding-top:4px}.datepicker-dropdown.datepicker-orient-top{padding-top:0;padding-bottom:4px}.datepicker-picker{display:inline-block;border-radius:4px;background-color:white}.datepicker-dropdown .datepicker-picker{-webkit-box-shadow:0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);box-shadow:0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1)}.datepicker-picker span{display:block;-ms-flex:1;flex:1;border:0;border-radius:4px;cursor:default;text-align:center;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.datepicker-main{padding:2px}.datepicker-footer{-webkit-box-shadow:inset 0 1px 1px rgba(10, 10, 10, 0.1);box-shadow:inset 0 1px 1px rgba(10, 10, 10, 0.1);background-color:whitesmoke}.datepicker-grid,.datepicker-view .days-of-week,.datepicker-view,.datepicker-controls{display:-ms-flexbox;display:flex}.datepicker-grid{-ms-flex-wrap:wrap;flex-wrap:wrap}.datepicker-view .days .datepicker-cell,.datepicker-view .dow{-ms-flex-preferred-size:14.2857142857%;flex-basis:14.2857142857%}.datepicker-view.datepicker-grid .datepicker-cell{-ms-flex-preferred-size:25%;flex-basis:25%}.datepicker-cell,.datepicker-view .week{height:2.25rem;line-height:2.25rem}.datepicker-title{-webkit-box-shadow:inset 0 -1px 1px rgba(10, 10, 10, 0.1);box-shadow:inset 0 -1px 1px rgba(10, 10, 10, 0.1);background-color:whitesmoke;padding:0.375rem 0.75rem;text-align:center;font-weight:700}.datepicker-header .datepicker-controls{padding:2px 2px 0}.datepicker-controls .button{display:-ms-inline-flexbox;display:inline-flex;position:relative;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;margin:0;border:1px solid #dbdbdb;border-radius:4px;-webkit-box-shadow:none;box-shadow:none;background-color:white;cursor:pointer;padding:calc(0.375em - 1px) 0.75em;height:2.25em;vertical-align:top;text-align:center;line-height:1.5;white-space:nowrap;color:#363636;font-size:1rem}.datepicker-controls .button:focus,.datepicker-controls .button:active{outline:none}.datepicker-controls .button:hover{border-color:#b5b5b5;color:#363636}.datepicker-controls .button:focus{border-color:#3273dc;color:#363636}.datepicker-controls .button:focus:not(:active){-webkit-box-shadow:0 0 0 0.125em rgba(50, 115, 220, 0.25);box-shadow:0 0 0 0.125em rgba(50, 115, 220, 0.25)}.datepicker-controls .button:active{border-color:#4a4a4a;color:#363636}.datepicker-controls .button[disabled]{cursor:not-allowed}.datepicker-header .datepicker-controls .button{border-color:transparent;font-weight:bold}.datepicker-header .datepicker-controls .button:hover{background-color:#f9f9f9}.datepicker-header .datepicker-controls .button:focus:not(:active){-webkit-box-shadow:0 0 0 0.125em rgba(255, 255, 255, 0.25);box-shadow:0 0 0 0.125em rgba(255, 255, 255, 0.25)}.datepicker-header .datepicker-controls .button:active{background-color:#f2f2f2}.datepicker-header .datepicker-controls .button[disabled]{-webkit-box-shadow:none;box-shadow:none}.datepicker-footer .datepicker-controls .button{margin:calc(0.375rem - 1px) 0.375rem;border-radius:2px;width:100%;font-size:0.75rem}.datepicker-controls .view-switch{-ms-flex:auto;flex:auto}.datepicker-controls .prev-btn,.datepicker-controls .next-btn{padding-right:0.375rem;padding-left:0.375rem;width:2.25rem}.datepicker-controls .prev-btn.disabled,.datepicker-controls .next-btn.disabled{visibility:hidden}.datepicker-view .dow{height:1.5rem;line-height:1.5rem;font-size:0.875rem;font-weight:700}.datepicker-view .week{width:2.25rem;color:#b5b5b5;font-size:0.75rem}@media (max-width: 22.5rem){.datepicker-view .week{width:1.96875rem}}.datepicker-grid{width:15.75rem}@media (max-width: 22.5rem){.calendar-weeks+.days .datepicker-grid{width:13.78125rem}}.datepicker-cell:not(.disabled):hover{background-color:#f9f9f9;cursor:pointer}.datepicker-cell.focused:not(.selected){background-color:#e8e8e8}.datepicker-cell.selected,.datepicker-cell.selected:hover{background-color:#3273dc;color:#fff;font-weight:600}.datepicker-cell.disabled{color:#dbdbdb}.datepicker-cell.prev:not(.disabled),.datepicker-cell.next:not(.disabled){color:#7a7a7a}.datepicker-cell.prev.selected,.datepicker-cell.next.selected{color:#e6e6e6}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today){border-radius:0;background-color:whitesmoke}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today):not(.disabled):hover{background-color:#eeeeee}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today).focused{background-color:#e8e8e8}.datepicker-cell.today:not(.selected){background-color:#00d1b2}.datepicker-cell.today:not(.selected):not(.disabled){color:#fff}.datepicker-cell.today.focused:not(.selected){background-color:#00c4a7}.datepicker-cell.range-end:not(.selected),.datepicker-cell.range-start:not(.selected){background-color:#b5b5b5;color:#fff}.datepicker-cell.range-end.focused:not(.selected),.datepicker-cell.range-start.focused:not(.selected){background-color:#afafaf}.datepicker-cell.range-start{border-radius:4px 0 0 4px}.datepicker-cell.range-end{border-radius:0 4px 4px 0}.datepicker-cell.range{border-radius:0;background-color:#dbdbdb}.datepicker-cell.range:not(.disabled):not(.focused):not(.today):hover{background-color:#d5d5d5}.datepicker-cell.range.disabled{color:#c2c2c2}.datepicker-cell.range.focused{background-color:#cfcfcf}.datepicker-view.datepicker-grid .datepicker-cell{height:4.5rem;line-height:4.5rem}.datepicker-input.in-edit{border-color:#2366d1}.datepicker-input.in-edit:focus,.datepicker-input.in-edit:active{-webkit-box-shadow:0 0 0.25em 0.25em rgba(35, 102, 209, 0.2);box-shadow:0 0 0.25em 0.25em rgba(35, 102, 209, 0.2)}verdocs-field-date{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:64px;height:15px;display:block;font-size:11px;position:relative;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-date input{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid #ccc;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-date input.hide{display:none}verdocs-field-date.required input{border:1px solid var(--verdocs-required-color)}verdocs-field-date.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldDate=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.fieldInput=createEvent(this,"fieldInput",7),this.placeholder="Select Date",this.order=1,this.value="",this.required=!1,this.disabled=!1,this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}componentDidLoad(){new Datepicker(this.el,{autohide:!0,todayHighlight:!0}),this.el.addEventListener("changeDate",(t=>{console.log("changeDate",t.detail.date.toISOString())}))}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}handleInput(t){this.fieldInput.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("input",{type:"text",value:"",placeholder:this.placeholder,required:this.required,ref:t=>this.el=t,onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus(),onChange:t=>this.handleChange(t),onInput:t=>this.handleInput(t)}))}};VerdocsFieldDate.style=verdocsFieldDateCss;const verdocsFieldDropdownCss='verdocs-field-dropdown{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:85px;height:20px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-dropdown select{position:absolute;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-dropdown select:focus{outline:none}verdocs-field-dropdown select.hide{display:none}verdocs-field-dropdown.required select{border:1px solid var(--verdocs-required-color)}verdocs-field-dropdown.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldDropdown=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.options=[],this.required=!1,this.order=1,this.disabled=!1,this.value="",this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required}},h("select",{tabIndex:this.order,disabled:this.disabled,ref:t=>this.el=t,onChange:t=>this.handleChange(t),onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus()},h("option",{value:""},"Select..."),this.options.map((t=>h("option",{value:t.id,selected:t.value===this.value},t.value)))))}};VerdocsFieldDropdown.style=verdocsFieldDropdownCss;const verdocsFieldInitialCss='verdocs-field-initial{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:83px;height:36px;display:block;font-size:11px;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-initial img{display:block;max-width:100%;max-height:100%}verdocs-field-initial button{-webkit-box-sizing:border-box;box-sizing:border-box;border:none;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-initial button.hide{display:none}verdocs-field-initial.required{border:1px solid var(--verdocs-required-color)}verdocs-field-initial.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldInitial=class{constructor(t){registerInstance(this,t),this.adopt=createEvent(this,"adopt",7),this.cancel=createEvent(this,"cancel",7),this.required=!1,this.fullName="",this.value=""}async focusField(){this.handleShow()}handleShow(){this.dialog=document.createElement("verdocs-initial-dialog"),this.dialog.open=!0,this.dialog.fullName=this.fullName,this.dialog.addEventListener("cancel",(()=>{var t;console.log("cancel"),null===(t=this.dialog)||void 0===t||t.remove()})),document.addEventListener("adopt",(t=>{var e;console.log("adopt",t),null===(e=this.dialog)||void 0===e||e.remove()})),document.body.append(this.dialog)}render(){return h(Host,{class:{required:this.required}},""!==this.value?h("img",{src:this.value,alt:"Initials"}):h("button",{class:{},onClick:()=>this.handleShow()},"Initial"))}};VerdocsFieldInitial.style=verdocsFieldInitialCss;const verdocsFieldPaymentCss='verdocs-field-payment{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:24px;height:24px;display:block;font-size:11px;position:relative;border:1px solid #cfa;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-payment button,verdocs-field-payment div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-field-payment button{color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-payment button.hide{display:none}verdocs-field-payment input{float:left;font-family:Arial, sans-serif}verdocs-field-payment select{position:absolute;font-family:Arial, sans-serif;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-payment .frame{width:100%;height:100%;background-size:contain;text-align:left}verdocs-field-payment .frame img{position:absolute;height:auto;width:100%}verdocs-field-payment.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldPayment=class{constructor(t){registerInstance(this,t),this.signatureComplete=createEvent(this,"signatureComplete",7),this.initialComplete=createEvent(this,"initialComplete",7),this.focused=!1,this.signed=!1,this.signatureUrl="",this._fields=[],this.signatureFile=null,this.initialFile=null,this.focusOrderNumber=-1,this.focusFieldName="",this.activeElement=null,this.showError={pageNum:-1,fieldIndex:-1,type:null},this.dialogOpened=!1,this.closeAllErrors=!1,this.fieldsMap={},this.fieldsForCurrentSigner=[],this.fontSize=11,this.averageFontWidth=5,this.requiredFields=[]}componentWillLoad(){if(console.log("sign field",this.field),this.recipients&&this.recipients.length>0){const t=this.recipients.find((t=>"preparer"===t.type));console.log("Found preparer",t),t&&(this.preparedMessage=`Prepared by ${t.full_name}`)}}render(){return h(Host,{class:{focused:this.focused,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("button",{class:{hide:this.signed}},"Payment"),h("div",this.signed?{class:"frame"}:{style:{display:"none"}}),h("img",{width:"100%",height:"100%",src:this.signatureUrl}))}};VerdocsFieldPayment.style=verdocsFieldPaymentCss;const verdocsFieldRadioButtonCss='verdocs-field-radio-button{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:14px;height:14px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border-radius:100%}verdocs-field-radio-button input[type=radio]{position:absolute;opacity:0}verdocs-field-radio-button input[type=radio]+label:before{content:"";background:#f4f4f4;border-radius:100%;border:1px solid rgba(0, 0, 0, 0.2);display:inline-block;width:13px;height:13px;position:relative;top:2px;margin-right:2px;vertical-align:top;cursor:pointer;text-align:center;-webkit-transition:all 250ms ease;transition:all 250ms ease}verdocs-field-radio-button input[type=radio]:checked+label:before{background-color:#55bc81;-webkit-box-shadow:inset 0 0 0 2px #f4f4f4;box-shadow:inset 0 0 0 2px #f4f4f4}verdocs-field-radio-button input[type=radio]:focus+label:before{outline:none;border-color:#55bc81}verdocs-field-radio-button input[type=radio]:disabled+label:before{-webkit-box-shadow:inset 0 0 0 4px #f4f4f4;box-shadow:inset 0 0 0 4px #f4f4f4;border-color:#b4b4b4;background:#b4b4b4}verdocs-field-radio-button input[type=radio]+label:empty:before{margin-right:0}verdocs-field-radio-button.required input[type=radio]+label:before{border:1px solid var(--verdocs-required-color)}verdocs-field-radio-button.hide{display:none}verdocs-field-radio-button.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldRadioButton=class{constructor(t){registerInstance(this,t),this.fieldChange=createEvent(this,"fieldChange",7),this.order=1,this.checked=!1,this.value="",this.name="",this.required=!1,this.disabled=!1}handleChange(t){console.log("changed",t),this.fieldChange.emit(t.target.checked)}render(){return h(Host,{class:{required:this.required,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("input",{type:"radio",tabIndex:this.order,value:this.value,name:this.name,id:`${this.name}=${this.value}`,checked:this.checked,disabled:this.disabled,required:this.required,onChange:t=>this.handleChange(t)}),h("label",{htmlFor:`${this.name}=${this.value}`}))}};VerdocsFieldRadioButton.style=verdocsFieldRadioButtonCss;const verdocsFieldSignatureCss='verdocs-field-signature{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:83px;height:36px;display:block;font-size:11px;position:relative;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-signature img{display:block;max-width:100%;max-height:100%}verdocs-field-signature button{-webkit-box-sizing:border-box;box-sizing:border-box;border:none;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-signature button.hide{display:none}verdocs-field-signature.required{border:1px solid var(--verdocs-required-color)}verdocs-field-signature.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldSignature=class{constructor(t){registerInstance(this,t),this.adopt=createEvent(this,"adopt",7),this.cancel=createEvent(this,"cancel",7),this.required=!1,this.fullName="",this.value=""}async focusField(){this.handleShow()}handleShow(){this.dialog=document.createElement("verdocs-signature-dialog"),this.dialog.open=!0,this.dialog.fullName=this.fullName,this.dialog.addEventListener("cancel",(()=>{var t;console.log("cancel"),null===(t=this.dialog)||void 0===t||t.remove()})),document.addEventListener("adopt",(t=>{var e;console.log("adopt",t),null===(e=this.dialog)||void 0===e||e.remove()})),document.body.append(this.dialog)}render(){return h(Host,{class:{required:this.required}},""!==this.value?h("img",{src:this.value,alt:"Signature"}):h("button",{class:{},onClick:()=>this.handleShow()},"Signature"))}};VerdocsFieldSignature.style=verdocsFieldSignatureCss;const verdocsFieldTextareaCss='verdocs-field-textarea{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:150px;height:15px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-textarea textarea{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-textarea textarea.hide{display:none}verdocs-field-textarea.required{border:1px solid var(--verdocs-required-color)}verdocs-field-textarea.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldTextarea=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.fieldInput=createEvent(this,"fieldInput",7),this.placeholder="",this.order=1,this.value="",this.required=!1,this.disabled=!1,this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}handleInput(t){this.fieldInput.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("textarea",{placeholder:this.placeholder||"",tabIndex:this.order,value:this.value,disabled:this.disabled,required:this.required,ref:t=>this.el=t,onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus(),onChange:t=>this.handleChange(t),onInput:t=>this.handleInput(t)}))}};VerdocsFieldTextarea.style=verdocsFieldTextareaCss;const verdocsFieldTextboxCss='verdocs-field-textbox{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:150px;height:15px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-textbox input{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-textbox input.hide{display:none}verdocs-field-textbox.required{border:1px solid var(--verdocs-required-color)}verdocs-field-textbox.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldTextbox=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.fieldInput=createEvent(this,"fieldInput",7),this.placeholder="",this.order=1,this.value="",this.required=!1,this.disabled=!1,this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}handleInput(t){this.fieldInput.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required}},h("input",{type:"text",placeholder:this.placeholder||"",tabIndex:this.order,value:this.value,disabled:this.disabled,required:this.required,ref:t=>this.el=t,onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus(),onChange:t=>this.handleChange(t),onInput:t=>this.handleInput(t)}))}};VerdocsFieldTextbox.style=verdocsFieldTextboxCss;const _nodeResolve_empty={},_nodeResolve_empty$1=Object.freeze({__proto__:null,default:_nodeResolve_empty}),require$$5=getAugmentedNamespace(_nodeResolve_empty$1);var pdf=createCommonjsModule((function(module,exports){
|
|
1
|
+
import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./p-2bc58746.js";import{c as createPopper}from"./p-4c66f794.js";import{d as getAugmentedNamespace,e as createCommonjsModule,f as getDefaultExportFromCjs,h as commonjsGlobal,B as Buffer,i as commonjsRequire,p as process_1,V as VerdocsEndpoint}from"./p-c34360d3.js";const SortDown='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#50BE80"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M7 10l5 5 5-5H7z"/></svg>\n',verdocsDropdownCss='verdocs-dropdown{font-family:"Barlow", sans-serif;display:block}verdocs-dropdown .arrow{width:32px;height:26px;background:#fff;cursor:pointer;border-radius:4px;-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;border:1px solid #cccccc;-ms-flex-pack:center;justify-content:center}verdocs-dropdown .arrow svg{fill:#55bc81;-webkit-transition:0.3s;transition:0.3s}verdocs-dropdown .items{width:200px;display:none;z-index:10000;border-radius:5px;background:#33354c;border:1px solid #654dcb}verdocs-dropdown .items[data-show]{display:block}verdocs-dropdown .option{width:100%;color:#fff;border:none;display:block;text-align:left;background:none;padding:10px 20px}verdocs-dropdown .option:hover{cursor:pointer;background:#55bc81}verdocs-dropdown .option[disabled]{color:#aaaaaa}verdocs-dropdown .option[disabled]:hover{color:#aaaaaa;cursor:inherit;background:transparent}verdocs-dropdown.open .items{display:block}verdocs-dropdown.open .arrow{background:#4c56cb;border:1px solid #707ae5}verdocs-dropdown.open .arrow svg{-webkit-transform:scaleY(-1);transform:scaleY(-1);fill:#fff}',VerdocsDropdown=class{constructor(t){registerInstance(this,t),this.optionSelected=createEvent(this,"optionSelected",7),this.options=[]}componentWillLoad(){this.isOpen=!!this.open}componentDidLoad(){this.popper=createPopper(this.dropdownButton,this.dropdownMenu,{placement:"bottom-start",modifiers:[{name:"offset",options:{offset:[0,6]}}]})}handleSelectOption(t){this.isOpen=!1,this.optionSelected.emit(t),this.hide()}showDropdown(){var t,e;this.isOpen=!0,this.dropdownMenu.setAttribute("data-show",""),this.dropdownMenu.removeAttribute("aria-hidden"),null===(t=this.popper)||void 0===t||t.setOptions((t=>({...t,modifiers:[...t.modifiers,{name:"eventListeners",enabled:!0}]}))),null===(e=this.popper)||void 0===e||e.update()}handleHideDropdown(t){var e,s;"button"===(null===(e=null==t?void 0:t.target)||void 0===e?void 0:e.localName)&&"arrow"===(null===(s=null==t?void 0:t.target)||void 0===s?void 0:s.className)||this.hide()}toggleDropdown(){this.isOpen?this.hide():this.showDropdown()}hide(){var t;this.isOpen=!1,this.dropdownMenu.removeAttribute("data-show"),this.dropdownMenu.setAttribute("aria-hidden","true"),null===(t=this.popper)||void 0===t||t.setOptions((t=>({...t,modifiers:[...t.modifiers,{name:"eventListeners",enabled:!1}]})))}render(){var t;return h(Host,{class:{storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV),open:!!this.isOpen}},h("button",{class:"arrow",innerHTML:SortDown,"aria-label":"Open Menu",onClick:()=>this.toggleDropdown(),onBlur:t=>this.handleHideDropdown(t),ref:t=>this.dropdownButton=t}),h("div",{class:"items","aria-hidden":!this.open,ref:t=>this.dropdownMenu=t},null===(t=this.options)||void 0===t?void 0:t.map((t=>h("button",{onClick:()=>this.handleSelectOption(t),class:"option",disabled:t.disabled},t.label)))))}};VerdocsDropdown.style=verdocsDropdownCss;const Paperclip='<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">\n <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />\n</svg>\n',verdocsFieldAttachmentCss='verdocs-field-attachment{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:24px;height:24px;display:block;font-size:11px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-attachment span{width:20px;cursor:pointer}verdocs-field-attachment.required span{border:1px solid #cc0000}verdocs-field-attachment.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldAttachment=class{constructor(t){registerInstance(this,t),this.fieldChange=createEvent(this,"fieldChange",7),this.order=1,this.value="",this.required=!1,this.disabled=!1}async focusField(){this.handleShow()}handleShow(){this.dialog=document.createElement("verdocs-upload-dialog"),this.dialog.open=!0,this.dialog.addEventListener("cancel",(()=>{var t;console.log("cancel"),null===(t=this.dialog)||void 0===t||t.remove()})),document.addEventListener("done",(t=>{var e;console.log("done",t),null===(e=this.dialog)||void 0===e||e.remove()})),document.body.append(this.dialog)}render(){return h(Host,{class:{required:this.required}},h("span",{innerHTML:Paperclip,onClick:()=>this.handleShow()}))}};VerdocsFieldAttachment.style=verdocsFieldAttachmentCss;const verdocsFieldCheckboxCss='@charset "UTF-8";verdocs-field-checkbox{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;font-size:11px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-checkbox label>input[type=checkbox]{display:none}verdocs-field-checkbox label>input[type=checkbox]+*::before{content:"";display:block;vertical-align:bottom;width:14px;height:14px;border-radius:2px;border:1px solid rgba(0, 0, 0, 0.2);-ms-flex-negative:0;flex-shrink:0}verdocs-field-checkbox label>input[type=checkbox]:checked+*{color:var(--verdocs-primary-color)}verdocs-field-checkbox label>input[type=checkbox]:checked+*::before{content:"✓";color:white;text-align:center;background:var(--verdocs-primary-color);border-color:var(--verdocs-primary-color)}verdocs-field-checkbox.required label>input[type=checkbox]+*::before{border:1px solid var(--verdocs-required-color)}verdocs-field-checkbox.hide{display:none}verdocs-field-checkbox.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldCheckbox=class{constructor(t){registerInstance(this,t),this.fieldChange=createEvent(this,"fieldChange",7),this.order=1,this.value=!1,this.required=!1,this.disabled=!1}handleChange(t){this.fieldChange.emit(t.target.checked)}render(){return h(Host,{class:{required:this.required}},h("label",null,h("input",{type:"checkbox",tabIndex:this.order,checked:this.value,disabled:this.disabled,required:this.required,onChange:t=>this.handleChange(t)}),h("span",null)))}};function hasProperty(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function lastItemOf(t){return t[t.length-1]}function pushUnique(t,...e){return e.forEach((e=>{t.includes(e)||t.push(e)})),t}function stringToArray(t,e){return t?t.split(e):[]}function isInRange(t,e,s){return(void 0===e||t>=e)&&(void 0===s||t<=s)}function limitToRange(t,e,s){return t<e?e:t>s?s:t}function createTagRepeat(t,e,s={},i=0,n=""){n+=`<${Object.keys(s).reduce(((t,e)=>{let n=s[e];return"function"==typeof n&&(n=n(i)),`${t} ${e}="${n}"`}),t)}></${t}>`;const r=i+1;return r<e?createTagRepeat(t,e,s,r,n):n}function optimizeTemplateHTML(t){return t.replace(/>\s+/g,">").replace(/\s+</,"<")}function stripTime(t){return new Date(t).setHours(0,0,0,0)}function today(){return(new Date).setHours(0,0,0,0)}function dateValue(...t){switch(t.length){case 0:return today();case 1:return stripTime(t[0])}const e=new Date(0);return e.setFullYear(...t),e.setHours(0,0,0,0)}function addDays(t,e){const s=new Date(t);return s.setDate(s.getDate()+e)}function addWeeks(t,e){return addDays(t,7*e)}function addMonths(t,e){const s=new Date(t),i=s.getMonth()+e;let n=i%12;n<0&&(n+=12);const r=s.setMonth(i);return s.getMonth()!==n?s.setDate(0):r}function addYears(t,e){const s=new Date(t),i=s.getMonth(),n=s.setFullYear(s.getFullYear()+e);return 1===i&&2===s.getMonth()?s.setDate(0):n}function dayDiff(t,e){return(t-e+7)%7}function dayOfTheWeekOf(t,e,s=0){const i=new Date(t).getDay();return addDays(t,dayDiff(e,s)-dayDiff(i,s))}function getWeek(t){const e=dayOfTheWeekOf(t,4,1),s=dayOfTheWeekOf(new Date(e).setMonth(0,4),4,1);return Math.round((e-s)/6048e5)+1}function startOfYearPeriod(t,e){const s=new Date(t).getFullYear();return Math.floor(s/e)*e}function regularizeDate(t,e,s){if(1!==e&&2!==e)return t;const i=new Date(t);return 1===e?s?i.setMonth(i.getMonth()+1,0):i.setDate(1):s?i.setFullYear(i.getFullYear()+1,0,0):i.setMonth(0,1),i.setHours(0,0,0,0)}VerdocsFieldCheckbox.style=verdocsFieldCheckboxCss;const reFormatTokens=/dd?|DD?|mm?|MM?|yy?(?:yy)?/,reNonDateParts=/[\s!-/:-@[-`{-~年月日]+/;let knownFormats={};const parseFns={y:(t,e)=>new Date(t).setFullYear(parseInt(e,10)),m(t,e,s){const i=new Date(t);let n=parseInt(e,10)-1;if(isNaN(n)){if(!e)return NaN;const t=e.toLowerCase(),i=e=>e.toLowerCase().startsWith(t);if(n=s.monthsShort.findIndex(i),n<0&&(n=s.months.findIndex(i)),n<0)return NaN}return i.setMonth(n),i.getMonth()!==normalizeMonth(n)?i.setDate(0):i.getTime()},d:(t,e)=>new Date(t).setDate(parseInt(e,10))},formatFns={d:t=>t.getDate(),dd:t=>padZero(t.getDate(),2),D:(t,e)=>e.daysShort[t.getDay()],DD:(t,e)=>e.days[t.getDay()],m:t=>t.getMonth()+1,mm:t=>padZero(t.getMonth()+1,2),M:(t,e)=>e.monthsShort[t.getMonth()],MM:(t,e)=>e.months[t.getMonth()],y:t=>t.getFullYear(),yy:t=>padZero(t.getFullYear(),2).slice(-2),yyyy:t=>padZero(t.getFullYear(),4)};function normalizeMonth(t){return t>-1?t%12:normalizeMonth(t+12)}function padZero(t,e){return t.toString().padStart(e,"0")}function parseFormatString(t){if("string"!=typeof t)throw new Error("Invalid date format.");if(t in knownFormats)return knownFormats[t];const e=t.split(reFormatTokens),s=t.match(new RegExp(reFormatTokens,"g"));if(0===e.length||!s)throw new Error("Invalid date format.");const i=s.map((t=>formatFns[t])),n=Object.keys(parseFns).reduce(((t,e)=>(s.find((t=>"D"!==t[0]&&t[0].toLowerCase()===e))&&t.push(e),t)),[]);return knownFormats[t]={parser(t,e){const i=t.split(reNonDateParts).reduce(((t,e,i)=>{if(e.length>0&&s[i]){const n=s[i][0];"M"===n?t.m=e:"D"!==n&&(t[n]=e)}return t}),{});return n.reduce(((t,s)=>{const n=parseFns[s](t,i[s],e);return isNaN(n)?t:n}),today())},formatter:(t,s)=>i.reduce(((i,n,r)=>i+`${e[r]}${n(t,s)}`),"")+lastItemOf(e)}}function parseDate(t,e,s){if(t instanceof Date||"number"==typeof t){const e=stripTime(t);return isNaN(e)?void 0:e}if(t){if("today"===t)return today();if(e&&e.toValue){const i=e.toValue(t,e,s);return isNaN(i)?void 0:stripTime(i)}return parseFormatString(e).parser(t,s)}}function formatDate(t,e,s){if(isNaN(t)||!t&&0!==t)return"";const i="number"==typeof t?new Date(t):t;return e.toDisplay?e.toDisplay(i,e,s):parseFormatString(e).formatter(i,s)}const range=document.createRange();function parseHTML(t){return range.createContextualFragment(t)}function getParent(t){return t.parentElement||(t.parentNode instanceof ShadowRoot?t.parentNode.host:void 0)}function isActiveElement(t){return t.getRootNode().activeElement===t}function hideElement(t){"none"!==t.style.display&&(t.style.display&&(t.dataset.styleDisplay=t.style.display),t.style.display="none")}function showElement(t){"none"===t.style.display&&(t.dataset.styleDisplay?(t.style.display=t.dataset.styleDisplay,delete t.dataset.styleDisplay):t.style.display="")}function emptyChildNodes(t){t.firstChild&&(t.removeChild(t.firstChild),emptyChildNodes(t))}function replaceChildNodes(t,e){emptyChildNodes(t),e instanceof DocumentFragment?t.appendChild(e):"string"==typeof e?t.appendChild(parseHTML(e)):"function"==typeof e.forEach&&e.forEach((e=>{t.appendChild(e)}))}const listenerRegistry=new WeakMap,{addEventListener,removeEventListener}=EventTarget.prototype;function registerListeners(t,e){let s=listenerRegistry.get(t);s||(s=[],listenerRegistry.set(t,s)),e.forEach((t=>{addEventListener.call(...t),s.push(t)}))}function unregisterListeners(t){let e=listenerRegistry.get(t);e&&(e.forEach((t=>{removeEventListener.call(...t)})),listenerRegistry.delete(t))}if(!Event.prototype.composedPath){const t=(e,s=[])=>{let i;return s.push(e),e.parentNode?i=e.parentNode:e.host?i=e.host:e.defaultView&&(i=e.defaultView),i?t(i,s):s};Event.prototype.composedPath=function(){return t(this.target)}}function findFromPath(t,e,s){const[i,...n]=t;return e(i)?i:i!==s&&"HTML"!==i.tagName&&0!==n.length?findFromPath(n,e,s):void 0}function findElementInEventPath(t,e){const s="function"==typeof e?e:t=>t instanceof Element&&t.matches(e);return findFromPath(t.composedPath(),s,t.currentTarget)}const locales={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",titleFormat:"MM y"}},defaultOptions={autohide:!1,beforeShowDay:null,beforeShowDecade:null,beforeShowMonth:null,beforeShowYear:null,calendarWeeks:!1,clearBtn:!1,dateDelimiter:",",datesDisabled:[],daysOfWeekDisabled:[],daysOfWeekHighlighted:[],defaultViewDate:void 0,disableTouchKeyboard:!1,format:"mm/dd/yyyy",language:"en",maxDate:null,maxNumberOfDates:1,maxView:3,minDate:null,nextArrow:"»",orientation:"auto",pickLevel:0,prevArrow:"«",showDaysOfWeek:!0,showOnClick:!0,showOnFocus:!0,startView:0,title:"",todayBtn:!1,todayBtnMode:0,todayHighlight:!1,updateOnBlur:!0,weekStart:0},{language:defaultLang,format:defaultFormat,weekStart:defaultWeekStart}=defaultOptions;function sanitizeDOW(t,e){return t.length<6&&e>=0&&e<7?pushUnique(t,e):t}function calcEndOfWeek(t){return(t+6)%7}function validateDate(t,e,s,i){const n=parseDate(t,e,s);return void 0!==n?n:i}function validateViewId(t,e,s=3){const i=parseInt(t,10);return i>=0&&i<=s?i:e}function processOptions(t,e){const s=Object.assign({},t),i={},n=e.constructor.locales,r=e.rangeSideIndex;let{format:o,language:a,locale:h,maxDate:c,maxView:l,minDate:d,pickLevel:u,startView:f,weekStart:p}=e.config||{};if(s.language){let t;if(s.language!==a&&(n[s.language]?t=s.language:(t=s.language.split("-")[0],void 0===n[t]&&(t=!1))),delete s.language,t){a=i.language=t;const e=h||n[defaultLang];h=Object.assign({format:defaultFormat,weekStart:defaultWeekStart},n[defaultLang]),a!==defaultLang&&Object.assign(h,n[a]),i.locale=h,o===e.format&&(o=i.format=h.format),p===e.weekStart&&(p=i.weekStart=h.weekStart,i.weekEnd=calcEndOfWeek(h.weekStart))}}if(s.format){const t="function"==typeof s.format.toDisplay,e="function"==typeof s.format.toValue,n=reFormatTokens.test(s.format);(t&&e||n)&&(o=i.format=s.format),delete s.format}let g=u;void 0!==s.pickLevel&&(g=validateViewId(s.pickLevel,2),delete s.pickLevel),g!==u&&(g>u&&(void 0===s.minDate&&(s.minDate=d),void 0===s.maxDate&&(s.maxDate=c)),s.datesDisabled||(s.datesDisabled=[]),u=i.pickLevel=g);let b=d,A=c;if(void 0!==s.minDate){const t=dateValue(0,0,1);b=null===s.minDate?t:validateDate(s.minDate,o,h,b),b!==t&&(b=regularizeDate(b,u,!1)),delete s.minDate}if(void 0!==s.maxDate&&(A=null===s.maxDate?void 0:validateDate(s.maxDate,o,h,A),void 0!==A&&(A=regularizeDate(A,u,!0)),delete s.maxDate),A<b?(d=i.minDate=A,c=i.maxDate=b):(d!==b&&(d=i.minDate=b),c!==A&&(c=i.maxDate=A)),s.datesDisabled&&(i.datesDisabled=s.datesDisabled.reduce(((t,e)=>{const s=parseDate(e,o,h);return void 0!==s?pushUnique(t,regularizeDate(s,u,r)):t}),[]),delete s.datesDisabled),void 0!==s.defaultViewDate){const t=parseDate(s.defaultViewDate,o,h);void 0!==t&&(i.defaultViewDate=t),delete s.defaultViewDate}if(void 0!==s.weekStart){const t=Number(s.weekStart)%7;isNaN(t)||(p=i.weekStart=t,i.weekEnd=calcEndOfWeek(t)),delete s.weekStart}if(s.daysOfWeekDisabled&&(i.daysOfWeekDisabled=s.daysOfWeekDisabled.reduce(sanitizeDOW,[]),delete s.daysOfWeekDisabled),s.daysOfWeekHighlighted&&(i.daysOfWeekHighlighted=s.daysOfWeekHighlighted.reduce(sanitizeDOW,[]),delete s.daysOfWeekHighlighted),void 0!==s.maxNumberOfDates){const t=parseInt(s.maxNumberOfDates,10);t>=0&&(i.maxNumberOfDates=t,i.multidate=1!==t),delete s.maxNumberOfDates}s.dateDelimiter&&(i.dateDelimiter=String(s.dateDelimiter),delete s.dateDelimiter);let m=l;void 0!==s.maxView&&(m=validateViewId(s.maxView,l),delete s.maxView),m=u>m?u:m,m!==l&&(l=i.maxView=m);let w=f;if(void 0!==s.startView&&(w=validateViewId(s.startView,w),delete s.startView),w<u?w=u:w>l&&(w=l),w!==f&&(i.startView=w),s.prevArrow){const t=parseHTML(s.prevArrow);t.childNodes.length>0&&(i.prevArrow=t.childNodes),delete s.prevArrow}if(s.nextArrow){const t=parseHTML(s.nextArrow);t.childNodes.length>0&&(i.nextArrow=t.childNodes),delete s.nextArrow}if(void 0!==s.disableTouchKeyboard&&(i.disableTouchKeyboard="ontouchstart"in document&&!!s.disableTouchKeyboard,delete s.disableTouchKeyboard),s.orientation){const t=s.orientation.toLowerCase().split(/\s+/g);i.orientation={x:t.find((t=>"left"===t||"right"===t))||"auto",y:t.find((t=>"top"===t||"bottom"===t))||"auto"},delete s.orientation}if(void 0!==s.todayBtnMode){switch(s.todayBtnMode){case 0:case 1:i.todayBtnMode=s.todayBtnMode}delete s.todayBtnMode}return Object.keys(s).forEach((t=>{void 0!==s[t]&&hasProperty(defaultOptions,t)&&(i[t]=s[t])})),i}const pickerTemplate=optimizeTemplateHTML('<div class="datepicker">\n <div class="datepicker-picker">\n <div class="datepicker-header">\n <div class="datepicker-title"></div>\n <div class="datepicker-controls">\n <button type="button" class="%buttonClass% prev-btn"></button>\n <button type="button" class="%buttonClass% view-switch"></button>\n <button type="button" class="%buttonClass% next-btn"></button>\n </div>\n </div>\n <div class="datepicker-main"></div>\n <div class="datepicker-footer">\n <div class="datepicker-controls">\n <button type="button" class="%buttonClass% today-btn"></button>\n <button type="button" class="%buttonClass% clear-btn"></button>\n </div>\n </div>\n </div>\n</div>'),daysTemplate=optimizeTemplateHTML(`<div class="days">\n <div class="days-of-week">${createTagRepeat("span",7,{class:"dow"})}</div>\n <div class="datepicker-grid">${createTagRepeat("span",42)}</div>\n</div>`),calendarWeeksTemplate=optimizeTemplateHTML(`<div class="calendar-weeks">\n <div class="days-of-week"><span class="dow"></span></div>\n <div class="weeks">${createTagRepeat("span",6,{class:"week"})}</div>\n</div>`);class View{constructor(t,e){Object.assign(this,e,{picker:t,element:parseHTML('<div class="datepicker-view"></div>').firstChild,selected:[]}),this.init(this.picker.datepicker.config)}init(t){void 0!==t.pickLevel&&(this.isMinView=this.id===t.pickLevel),this.setOptions(t),this.updateFocus(),this.updateSelection()}performBeforeHook(t,e,s){let i=this.beforeShow(new Date(s));switch(typeof i){case"boolean":i={enabled:i};break;case"string":i={classes:i}}if(i){if(!1===i.enabled&&(t.classList.add("disabled"),pushUnique(this.disabled,e)),i.classes){const s=i.classes.split(/\s+/);t.classList.add(...s),s.includes("disabled")&&pushUnique(this.disabled,e)}i.content&&replaceChildNodes(t,i.content)}}}class DaysView extends View{constructor(t){super(t,{id:0,name:"days",cellClass:"day"})}init(t,e=!0){if(e){const t=parseHTML(daysTemplate).firstChild;this.dow=t.firstChild,this.grid=t.lastChild,this.element.appendChild(t)}super.init(t)}setOptions(t){let e;if(hasProperty(t,"minDate")&&(this.minDate=t.minDate),hasProperty(t,"maxDate")&&(this.maxDate=t.maxDate),t.datesDisabled&&(this.datesDisabled=t.datesDisabled),t.daysOfWeekDisabled&&(this.daysOfWeekDisabled=t.daysOfWeekDisabled,e=!0),t.daysOfWeekHighlighted&&(this.daysOfWeekHighlighted=t.daysOfWeekHighlighted),void 0!==t.todayHighlight&&(this.todayHighlight=t.todayHighlight),void 0!==t.weekStart&&(this.weekStart=t.weekStart,this.weekEnd=t.weekEnd,e=!0),t.locale){const s=this.locale=t.locale;this.dayNames=s.daysMin,this.switchLabelFormat=s.titleFormat,e=!0}if(void 0!==t.beforeShowDay&&(this.beforeShow="function"==typeof t.beforeShowDay?t.beforeShowDay:void 0),void 0!==t.calendarWeeks)if(t.calendarWeeks&&!this.calendarWeeks){const t=parseHTML(calendarWeeksTemplate).firstChild;this.calendarWeeks={element:t,dow:t.firstChild,weeks:t.lastChild},this.element.insertBefore(t,this.element.firstChild)}else this.calendarWeeks&&!t.calendarWeeks&&(this.element.removeChild(this.calendarWeeks.element),this.calendarWeeks=null);void 0!==t.showDaysOfWeek&&(t.showDaysOfWeek?(showElement(this.dow),this.calendarWeeks&&showElement(this.calendarWeeks.dow)):(hideElement(this.dow),this.calendarWeeks&&hideElement(this.calendarWeeks.dow))),e&&Array.from(this.dow.children).forEach(((t,e)=>{const s=(this.weekStart+e)%7;t.textContent=this.dayNames[s],t.className=this.daysOfWeekDisabled.includes(s)?"dow disabled":"dow"}))}updateFocus(){const t=new Date(this.picker.viewDate),e=t.getFullYear(),s=t.getMonth(),i=dateValue(e,s,1),n=dayOfTheWeekOf(i,this.weekStart,this.weekStart);this.first=i,this.last=dateValue(e,s+1,0),this.start=n,this.focused=this.picker.viewDate}updateSelection(){const{dates:t,rangepicker:e}=this.picker.datepicker;this.selected=t,e&&(this.range=e.dates)}render(){this.today=this.todayHighlight?today():void 0,this.disabled=[...this.datesDisabled];const t=formatDate(this.focused,this.switchLabelFormat,this.locale);if(this.picker.setViewSwitchLabel(t),this.picker.setPrevBtnDisabled(this.first<=this.minDate),this.picker.setNextBtnDisabled(this.last>=this.maxDate),this.calendarWeeks){const t=dayOfTheWeekOf(this.first,1,1);Array.from(this.calendarWeeks.weeks.children).forEach(((e,s)=>{e.textContent=getWeek(addWeeks(t,s))}))}Array.from(this.grid.children).forEach(((t,e)=>{const s=t.classList,i=addDays(this.start,e),n=new Date(i),r=n.getDay();if(t.className=`datepicker-cell ${this.cellClass}`,t.dataset.date=i,t.textContent=n.getDate(),i<this.first?s.add("prev"):i>this.last&&s.add("next"),this.today===i&&s.add("today"),(i<this.minDate||i>this.maxDate||this.disabled.includes(i))&&s.add("disabled"),this.daysOfWeekDisabled.includes(r)&&(s.add("disabled"),pushUnique(this.disabled,i)),this.daysOfWeekHighlighted.includes(r)&&s.add("highlighted"),this.range){const[t,e]=this.range;i>t&&i<e&&s.add("range"),i===t&&s.add("range-start"),i===e&&s.add("range-end")}this.selected.includes(i)&&s.add("selected"),i===this.focused&&s.add("focused"),this.beforeShow&&this.performBeforeHook(t,i,i)}))}refresh(){const[t,e]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach((t=>{t.classList.remove("range","range-start","range-end","selected","focused")})),Array.from(this.grid.children).forEach((s=>{const i=Number(s.dataset.date),n=s.classList;i>t&&i<e&&n.add("range"),i===t&&n.add("range-start"),i===e&&n.add("range-end"),this.selected.includes(i)&&n.add("selected"),i===this.focused&&n.add("focused")}))}refreshFocus(){const t=Math.round((this.focused-this.start)/864e5);this.grid.querySelectorAll(".focused").forEach((t=>{t.classList.remove("focused")})),this.grid.children[t].classList.add("focused")}}function computeMonthRange(t,e){if(!t||!t[0]||!t[1])return;const[[s,i],[n,r]]=t;return s>e||n<e?void 0:[s===e?i:-1,n===e?r:12]}class MonthsView extends View{constructor(t){super(t,{id:1,name:"months",cellClass:"month"})}init(t,e=!0){e&&(this.grid=this.element,this.element.classList.add("months","datepicker-grid"),this.grid.appendChild(parseHTML(createTagRepeat("span",12,{"data-month":t=>t})))),super.init(t)}setOptions(t){if(t.locale&&(this.monthNames=t.locale.monthsShort),hasProperty(t,"minDate"))if(void 0===t.minDate)this.minYear=this.minMonth=this.minDate=void 0;else{const e=new Date(t.minDate);this.minYear=e.getFullYear(),this.minMonth=e.getMonth(),this.minDate=e.setDate(1)}if(hasProperty(t,"maxDate"))if(void 0===t.maxDate)this.maxYear=this.maxMonth=this.maxDate=void 0;else{const e=new Date(t.maxDate);this.maxYear=e.getFullYear(),this.maxMonth=e.getMonth(),this.maxDate=dateValue(this.maxYear,this.maxMonth+1,0)}this.isMinView?t.datesDisabled&&(this.datesDisabled=t.datesDisabled):this.datesDisabled=[],void 0!==t.beforeShowMonth&&(this.beforeShow="function"==typeof t.beforeShowMonth?t.beforeShowMonth:void 0)}updateFocus(){const t=new Date(this.picker.viewDate);this.year=t.getFullYear(),this.focused=t.getMonth()}updateSelection(){const{dates:t,rangepicker:e}=this.picker.datepicker;this.selected=t.reduce(((t,e)=>{const s=new Date(e),i=s.getFullYear(),n=s.getMonth();return void 0===t[i]?t[i]=[n]:pushUnique(t[i],n),t}),{}),e&&e.dates&&(this.range=e.dates.map((t=>{const e=new Date(t);return isNaN(e)?void 0:[e.getFullYear(),e.getMonth()]})))}render(){this.disabled=this.datesDisabled.reduce(((t,e)=>{const s=new Date(e);return this.year===s.getFullYear()&&t.push(s.getMonth()),t}),[]),this.picker.setViewSwitchLabel(this.year),this.picker.setPrevBtnDisabled(this.year<=this.minYear),this.picker.setNextBtnDisabled(this.year>=this.maxYear);const t=this.selected[this.year]||[],e=this.year<this.minYear||this.year>this.maxYear,s=this.year===this.minYear,i=this.year===this.maxYear,n=computeMonthRange(this.range,this.year);Array.from(this.grid.children).forEach(((r,o)=>{const a=r.classList,h=dateValue(this.year,o,1);if(r.className=`datepicker-cell ${this.cellClass}`,this.isMinView&&(r.dataset.date=h),r.textContent=this.monthNames[o],(e||s&&o<this.minMonth||i&&o>this.maxMonth||this.disabled.includes(o))&&a.add("disabled"),n){const[t,e]=n;o>t&&o<e&&a.add("range"),o===t&&a.add("range-start"),o===e&&a.add("range-end")}t.includes(o)&&a.add("selected"),o===this.focused&&a.add("focused"),this.beforeShow&&this.performBeforeHook(r,o,h)}))}refresh(){const t=this.selected[this.year]||[],[e,s]=computeMonthRange(this.range,this.year)||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach((t=>{t.classList.remove("range","range-start","range-end","selected","focused")})),Array.from(this.grid.children).forEach(((i,n)=>{const r=i.classList;n>e&&n<s&&r.add("range"),n===e&&r.add("range-start"),n===s&&r.add("range-end"),t.includes(n)&&r.add("selected"),n===this.focused&&r.add("focused")}))}refreshFocus(){this.grid.querySelectorAll(".focused").forEach((t=>{t.classList.remove("focused")})),this.grid.children[this.focused].classList.add("focused")}}function toTitleCase(t){return[...t].reduce(((t,e,s)=>t+(s?e:e.toUpperCase())),"")}class YearsView extends View{constructor(t,e){super(t,e)}init(t,e=!0){e&&(this.navStep=10*this.step,this.beforeShowOption=`beforeShow${toTitleCase(this.cellClass)}`,this.grid=this.element,this.element.classList.add(this.name,"datepicker-grid"),this.grid.appendChild(parseHTML(createTagRepeat("span",12)))),super.init(t)}setOptions(t){if(hasProperty(t,"minDate")&&(void 0===t.minDate?this.minYear=this.minDate=void 0:(this.minYear=startOfYearPeriod(t.minDate,this.step),this.minDate=dateValue(this.minYear,0,1))),hasProperty(t,"maxDate")&&(void 0===t.maxDate?this.maxYear=this.maxDate=void 0:(this.maxYear=startOfYearPeriod(t.maxDate,this.step),this.maxDate=dateValue(this.maxYear,11,31))),this.isMinView?t.datesDisabled&&(this.datesDisabled=t.datesDisabled):this.datesDisabled=[],void 0!==t[this.beforeShowOption]){const e=t[this.beforeShowOption];this.beforeShow="function"==typeof e?e:void 0}}updateFocus(){const t=new Date(this.picker.viewDate),e=startOfYearPeriod(t,this.navStep),s=e+9*this.step;this.first=e,this.last=s,this.start=e-this.step,this.focused=startOfYearPeriod(t,this.step)}updateSelection(){const{dates:t,rangepicker:e}=this.picker.datepicker;this.selected=t.reduce(((t,e)=>pushUnique(t,startOfYearPeriod(e,this.step))),[]),e&&e.dates&&(this.range=e.dates.map((t=>{if(void 0!==t)return startOfYearPeriod(t,this.step)})))}render(){this.disabled=this.datesDisabled.map((t=>new Date(t).getFullYear())),this.picker.setViewSwitchLabel(`${this.first}-${this.last}`),this.picker.setPrevBtnDisabled(this.first<=this.minYear),this.picker.setNextBtnDisabled(this.last>=this.maxYear),Array.from(this.grid.children).forEach(((t,e)=>{const s=t.classList,i=this.start+e*this.step,n=dateValue(i,0,1);if(t.className=`datepicker-cell ${this.cellClass}`,this.isMinView&&(t.dataset.date=n),t.textContent=t.dataset.year=i,0===e?s.add("prev"):11===e&&s.add("next"),(i<this.minYear||i>this.maxYear||this.disabled.includes(i))&&s.add("disabled"),this.range){const[t,e]=this.range;i>t&&i<e&&s.add("range"),i===t&&s.add("range-start"),i===e&&s.add("range-end")}this.selected.includes(i)&&s.add("selected"),i===this.focused&&s.add("focused"),this.beforeShow&&this.performBeforeHook(t,i,n)}))}refresh(){const[t,e]=this.range||[];this.grid.querySelectorAll(".range, .range-start, .range-end, .selected, .focused").forEach((t=>{t.classList.remove("range","range-start","range-end","selected","focused")})),Array.from(this.grid.children).forEach((s=>{const i=Number(s.textContent),n=s.classList;i>t&&i<e&&n.add("range"),i===t&&n.add("range-start"),i===e&&n.add("range-end"),this.selected.includes(i)&&n.add("selected"),i===this.focused&&n.add("focused")}))}refreshFocus(){const t=Math.round((this.focused-this.start)/this.step);this.grid.querySelectorAll(".focused").forEach((t=>{t.classList.remove("focused")})),this.grid.children[t].classList.add("focused")}}function triggerDatepickerEvent(t,e){const s={date:t.getDate(),viewDate:new Date(t.picker.viewDate),viewId:t.picker.currentView.id,datepicker:t};t.element.dispatchEvent(new CustomEvent(e,{detail:s}))}function goToPrevOrNext(t,e){const{minDate:s,maxDate:i}=t.config,{currentView:n,viewDate:r}=t.picker;let o;switch(n.id){case 0:o=addMonths(r,e);break;case 1:o=addYears(r,e);break;default:o=addYears(r,e*n.navStep)}o=limitToRange(o,s,i),t.picker.changeFocus(o).render()}function switchView(t){const e=t.picker.currentView.id;e!==t.config.maxView&&t.picker.changeView(e+1).render()}function unfocus(t){t.config.updateOnBlur?t.update({revert:!0}):t.refresh("input"),t.hide()}function goToSelectedMonthOrYear(t,e){const s=t.picker,i=new Date(s.viewDate),n=s.currentView.id,r=1===n?addMonths(i,e-i.getMonth()):addYears(i,e-i.getFullYear());s.changeFocus(r).changeView(n-1).render()}function onClickTodayBtn(t){const e=t.picker,s=today();if(1===t.config.todayBtnMode){if(t.config.autohide)return void t.setDate(s);t.setDate(s,{render:!1}),e.update()}e.viewDate!==s&&e.changeFocus(s),e.changeView(0).render()}function onClickClearBtn(t){t.setDate({clear:!0})}function onClickViewSwitch(t){switchView(t)}function onClickPrevBtn(t){goToPrevOrNext(t,-1)}function onClickNextBtn(t){goToPrevOrNext(t,1)}function onClickView(t,e){const s=findElementInEventPath(e,".datepicker-cell");if(!s||s.classList.contains("disabled"))return;const{id:i,isMinView:n}=t.picker.currentView;n?t.setDate(Number(s.dataset.date)):goToSelectedMonthOrYear(t,Number(1===i?s.dataset.month:s.dataset.year))}function onMousedownPicker(t){t.preventDefault()}const orientClasses=["left","top","right","bottom"].reduce(((t,e)=>(t[e]=`datepicker-orient-${e}`,t)),{}),toPx=t=>t?`${t}px`:t;function processPickerOptions(t,e){if(void 0!==e.title&&(e.title?(t.controls.title.textContent=e.title,showElement(t.controls.title)):(t.controls.title.textContent="",hideElement(t.controls.title))),e.prevArrow){const s=t.controls.prevBtn;emptyChildNodes(s),e.prevArrow.forEach((t=>{s.appendChild(t.cloneNode(!0))}))}if(e.nextArrow){const s=t.controls.nextBtn;emptyChildNodes(s),e.nextArrow.forEach((t=>{s.appendChild(t.cloneNode(!0))}))}if(e.locale&&(t.controls.todayBtn.textContent=e.locale.today,t.controls.clearBtn.textContent=e.locale.clear),void 0!==e.todayBtn&&(e.todayBtn?showElement(t.controls.todayBtn):hideElement(t.controls.todayBtn)),hasProperty(e,"minDate")||hasProperty(e,"maxDate")){const{minDate:e,maxDate:s}=t.datepicker.config;t.controls.todayBtn.disabled=!isInRange(today(),e,s)}void 0!==e.clearBtn&&(e.clearBtn?showElement(t.controls.clearBtn):hideElement(t.controls.clearBtn))}function computeResetViewDate(t){const{dates:e,config:s}=t;return limitToRange(e.length>0?lastItemOf(e):s.defaultViewDate,s.minDate,s.maxDate)}function setViewDate(t,e){const s=new Date(t.viewDate),i=new Date(e),{id:n,year:r,first:o,last:a}=t.currentView,h=i.getFullYear();switch(t.viewDate=e,h!==s.getFullYear()&&triggerDatepickerEvent(t.datepicker,"changeYear"),i.getMonth()!==s.getMonth()&&triggerDatepickerEvent(t.datepicker,"changeMonth"),n){case 0:return e<o||e>a;case 1:return h!==r;default:return h<o||h>a}}function getTextDirection(t){return window.getComputedStyle(t).direction}function findScrollParents(t){const e=getParent(t);if(e!==document.body&&e)return"visible"!==window.getComputedStyle(e).overflow?e:findScrollParents(e)}class Picker{constructor(t){const{config:e}=this.datepicker=t,s=pickerTemplate.replace(/%buttonClass%/g,e.buttonClass),i=this.element=parseHTML(s).firstChild,[n,r,o]=i.firstChild.children,a=n.firstElementChild,[h,c,l]=n.lastElementChild.children,[d,u]=o.firstChild.children,f={title:a,prevBtn:h,viewSwitch:c,nextBtn:l,todayBtn:d,clearBtn:u};this.main=r,this.controls=f,i.classList.add("datepicker-"+(t.inline?"inline":"dropdown")),processPickerOptions(this,e),this.viewDate=computeResetViewDate(t),registerListeners(t,[[i,"mousedown",onMousedownPicker],[r,"click",onClickView.bind(null,t)],[f.viewSwitch,"click",onClickViewSwitch.bind(null,t)],[f.prevBtn,"click",onClickPrevBtn.bind(null,t)],[f.nextBtn,"click",onClickNextBtn.bind(null,t)],[f.todayBtn,"click",onClickTodayBtn.bind(null,t)],[f.clearBtn,"click",onClickClearBtn.bind(null,t)]]),this.views=[new DaysView(this),new MonthsView(this),new YearsView(this,{id:2,name:"years",cellClass:"year",step:1}),new YearsView(this,{id:3,name:"decades",cellClass:"decade",step:10})],this.currentView=this.views[e.startView],this.currentView.render(),this.main.appendChild(this.currentView.element),e.container?e.container.appendChild(this.element):t.inputField.after(this.element)}setOptions(t){processPickerOptions(this,t),this.views.forEach((e=>{e.init(t,!1)})),this.currentView.render()}detach(){this.element.remove()}show(){if(this.active)return;const{datepicker:t,element:e}=this;if(t.inline)e.classList.add("active");else{const s=getTextDirection(t.inputField);s!==getTextDirection(getParent(e))?e.dir=s:e.dir&&e.removeAttribute("dir"),e.style.visiblity="hidden",e.classList.add("active"),this.place(),e.style.visiblity="",t.config.disableTouchKeyboard&&t.inputField.blur()}this.active=!0,triggerDatepickerEvent(t,"show")}hide(){this.active&&(this.datepicker.exitEditMode(),this.element.classList.remove("active"),this.active=!1,triggerDatepickerEvent(this.datepicker,"hide"))}place(){const{classList:t,offsetParent:e,style:s}=this.element,{config:i,inputField:n}=this.datepicker,{width:r,height:o}=this.element.getBoundingClientRect(),{left:a,top:h,right:c,bottom:l,width:d,height:u}=n.getBoundingClientRect();let{x:f,y:p}=i.orientation,g=a,b=h;if(e!==document.body&&e){const t=e.getBoundingClientRect();g-=t.left-e.scrollLeft,b-=t.top-e.scrollTop}else g+=window.scrollX,b+=window.scrollY;const A=findScrollParents(n);let m=0,w=0,{clientWidth:v,clientHeight:k}=document.documentElement;if(A){const t=A.getBoundingClientRect();t.top>0&&(w=t.top),t.left>0&&(m=t.left),t.right<v&&(v=t.right),t.bottom<k&&(k=t.bottom)}let x=0;"auto"===f&&(a<m?(f="left",x=m-a):a+r>v?(f="right",v<c&&(x=v-c)):f="rtl"===getTextDirection(n)?c-r<m?"left":"right":"left"),"right"===f&&(g+=d-r),g+=x,"auto"===p&&(p=h-o>w&&l+o>k?"top":"bottom"),"top"===p?b-=o:b+=u,t.remove(...Object.values(orientClasses)),t.add(orientClasses[f],orientClasses[p]),s.left=toPx(g),s.top=toPx(b)}setViewSwitchLabel(t){this.controls.viewSwitch.textContent=t}setPrevBtnDisabled(t){this.controls.prevBtn.disabled=t}setNextBtnDisabled(t){this.controls.nextBtn.disabled=t}changeView(t){const e=this.currentView,s=this.views[t];return s.id!==e.id&&(this.currentView=s,this._renderMethod="render",triggerDatepickerEvent(this.datepicker,"changeView"),this.main.replaceChild(s.element,e.element)),this}changeFocus(t){return this._renderMethod=setViewDate(this,t)?"render":"refreshFocus",this.views.forEach((t=>{t.updateFocus()})),this}update(){const t=computeResetViewDate(this.datepicker);return this._renderMethod=setViewDate(this,t)?"render":"refresh",this.views.forEach((t=>{t.updateFocus(),t.updateSelection()})),this}render(t=!0){const e=t&&this._renderMethod||"render";delete this._renderMethod,this.currentView[e]()}}function findNextAvailableOne(t,e,s,i,n,r){if(isInRange(t,n,r))return i(t)?findNextAvailableOne(e(t,s),e,s,i,n,r):t}function moveByArrowKey(t,e,s,i){const n=t.picker,r=n.currentView,o=r.step||1;let a,h,c=n.viewDate;switch(r.id){case 0:c=i?addDays(c,7*s):e.ctrlKey||e.metaKey?addYears(c,s):addDays(c,s),a=addDays,h=t=>r.disabled.includes(t);break;case 1:c=addMonths(c,i?4*s:s),a=addMonths,h=t=>{const e=new Date(t),{year:s,disabled:i}=r;return e.getFullYear()===s&&i.includes(e.getMonth())};break;default:c=addYears(c,s*(i?4:1)*o),a=addYears,h=t=>r.disabled.includes(startOfYearPeriod(t,o))}c=findNextAvailableOne(c,a,s<0?-o:o,h,r.minDate,r.maxDate),void 0!==c&&n.changeFocus(c).render()}function onKeydown(t,e){const s=e.key;if("Tab"===s)return void unfocus(t);const i=t.picker,{id:n,isMinView:r}=i.currentView;if(i.active){if(t.editMode)return void("Enter"===s?t.exitEditMode({update:!0,autohide:t.config.autohide}):"Escape"===s&&i.hide());if("ArrowLeft"===s)if(e.ctrlKey||e.metaKey)goToPrevOrNext(t,-1);else{if(e.shiftKey)return void t.enterEditMode();moveByArrowKey(t,e,-1,!1)}else if("ArrowRight"===s)if(e.ctrlKey||e.metaKey)goToPrevOrNext(t,1);else{if(e.shiftKey)return void t.enterEditMode();moveByArrowKey(t,e,1,!1)}else if("ArrowUp"===s)if(e.ctrlKey||e.metaKey)switchView(t);else{if(e.shiftKey)return void t.enterEditMode();moveByArrowKey(t,e,-1,!0)}else if("ArrowDown"===s){if(e.shiftKey&&!e.ctrlKey&&!e.metaKey)return void t.enterEditMode();moveByArrowKey(t,e,1,!0)}else{if("Enter"!==s)return void("Escape"===s?i.hide():"Backspace"!==s&&"Delete"!==s&&(1!==s.length||e.ctrlKey||e.metaKey)||t.enterEditMode());if(r)return void t.setDate(i.viewDate);i.changeView(n-1).render()}}else{if("ArrowDown"!==s)return void("Enter"===s?t.update():"Escape"===s&&i.show());i.show()}e.preventDefault()}function onFocus(t){t.config.showOnFocus&&!t._showing&&t.show()}function onMousedown(t,e){const s=e.target;(t.picker.active||t.config.showOnClick)&&(s._active=isActiveElement(s),s._clicking=setTimeout((()=>{delete s._active,delete s._clicking}),2e3))}function onClickInput(t,e){const s=e.target;s._clicking&&(clearTimeout(s._clicking),delete s._clicking,s._active&&t.enterEditMode(),delete s._active,t.config.showOnClick&&t.show())}function onPaste(t,e){e.clipboardData.types.includes("text/plain")&&t.enterEditMode()}function onClickOutside(t,e){const{element:s,picker:i}=t;if(!i.active&&!isActiveElement(s))return;const n=i.element;findElementInEventPath(e,(t=>t===s||t===n))||unfocus(t)}function stringifyDates(t,e){return t.map((t=>formatDate(t,e.format,e.locale))).join(e.dateDelimiter)}function processInputDates(t,e,s=!1){const{config:i,dates:n,rangeSideIndex:r}=t;if(0===e.length)return s?[]:void 0;let o=e.reduce(((t,e)=>{let s=parseDate(e,i.format,i.locale);return void 0===s||(s=regularizeDate(s,i.pickLevel,r),!isInRange(s,i.minDate,i.maxDate)||t.includes(s)||i.datesDisabled.includes(s)||!(i.pickLevel>0)&&i.daysOfWeekDisabled.includes(new Date(s).getDay())||t.push(s)),t}),[]);return 0!==o.length?(i.multidate&&!s&&(o=o.reduce(((t,e)=>(n.includes(e)||t.push(e),t)),n.filter((t=>!o.includes(t))))),i.maxNumberOfDates&&o.length>i.maxNumberOfDates?o.slice(-1*i.maxNumberOfDates):o):void 0}function refreshUI(t,e=3,s=!0){const{config:i,picker:n,inputField:r}=t;if(2&e){const t=n.active?i.pickLevel:i.startView;n.update().changeView(t).render(s)}1&e&&r&&(r.value=stringifyDates(t.dates,i))}function setDate(t,e,s){let{clear:i,render:n,autohide:r,revert:o}=s;void 0===n&&(n=!0),n?void 0===r&&(r=t.config.autohide):r=!1;const a=processInputDates(t,e,i);(a||o)&&(a&&a.toString()!==t.dates.toString()?(t.dates=a,refreshUI(t,n?3:1),triggerDatepickerEvent(t,"changeDate")):refreshUI(t,1),r&&t.hide())}class Datepicker{constructor(t,e={},s){t.datepicker=this,this.element=t;const i=this.config=Object.assign({buttonClass:e.buttonClass&&String(e.buttonClass)||"button",container:null,defaultViewDate:today(),maxDate:void 0,minDate:void 0},processOptions(defaultOptions,this)),n=this.inline="INPUT"!==t.tagName;let r,o;if(n?i.container=t:(e.container&&(i.container=e.container instanceof HTMLElement?e.container:document.querySelector(e.container)),r=this.inputField=t,r.classList.add("datepicker-input")),s){const t=s.inputs.indexOf(r),e=s.datepickers;if(t<0||t>1||!Array.isArray(e))throw Error("Invalid rangepicker object.");e[t]=this,Object.defineProperty(this,"rangepicker",{get:()=>s}),Object.defineProperty(this,"rangeSideIndex",{get:()=>t})}this._options=e,Object.assign(i,processOptions(e,this)),n?(o=stringToArray(t.dataset.date,i.dateDelimiter),delete t.dataset.date):o=stringToArray(r.value,i.dateDelimiter),this.dates=[];const a=processInputDates(this,o);a&&a.length>0&&(this.dates=a),r&&(r.value=stringifyDates(this.dates,i));const h=this.picker=new Picker(this);if(n)this.show();else{const t=onClickOutside.bind(null,this);registerListeners(this,[[r,"keydown",onKeydown.bind(null,this)],[r,"focus",onFocus.bind(null,this)],[r,"mousedown",onMousedown.bind(null,this)],[r,"click",onClickInput.bind(null,this)],[r,"paste",onPaste.bind(null,this)],[document,"mousedown",t],[document,"touchstart",t],[window,"resize",h.place.bind(h)]])}}static formatDate(t,e,s){return formatDate(t,e,s&&locales[s]||locales.en)}static parseDate(t,e,s){return parseDate(t,e,s&&locales[s]||locales.en)}static get locales(){return locales}get active(){return!(!this.picker||!this.picker.active)}get pickerElement(){return this.picker?this.picker.element:void 0}setOptions(t){const e=this.picker,s=processOptions(t,this);Object.assign(this._options,t),Object.assign(this.config,s),e.setOptions(s),refreshUI(this,3)}show(){if(this.inputField){if(this.inputField.disabled)return;isActiveElement(this.inputField)||this.config.disableTouchKeyboard||(this._showing=!0,this.inputField.focus(),delete this._showing)}this.picker.show()}hide(){this.inline||(this.picker.hide(),this.picker.update().changeView(this.config.startView).render())}destroy(){return this.hide(),unregisterListeners(this),this.picker.detach(),this.inline||this.inputField.classList.remove("datepicker-input"),delete this.element.datepicker,this}getDate(t){const e=t?e=>formatDate(e,t,this.config.locale):t=>new Date(t);return this.config.multidate?this.dates.map(e):this.dates.length>0?e(this.dates[0]):void 0}setDate(...t){const e=[...t],s={},i=lastItemOf(t);"object"!=typeof i||Array.isArray(i)||i instanceof Date||!i||Object.assign(s,e.pop()),setDate(this,Array.isArray(e[0])?e[0]:e,s)}update(t){if(this.inline)return;const e=Object.assign(t||{},{clear:!0,render:!0});setDate(this,stringToArray(this.inputField.value,this.config.dateDelimiter),e)}refresh(t,e=!1){let s;t&&"string"!=typeof t&&(e=t,t=void 0),s="picker"===t?2:"input"===t?1:3,refreshUI(this,s,!e)}enterEditMode(){this.inline||!this.picker.active||this.editMode||(this.editMode=!0,this.inputField.classList.add("in-edit"))}exitEditMode(t){if(this.inline||!this.editMode)return;const e=Object.assign({update:!1},t);delete this.editMode,this.inputField.classList.remove("in-edit"),e.update&&this.update(e)}}const verdocsFieldDateCss='.datepicker{display:none}.datepicker.active{display:block}.datepicker-dropdown{position:absolute;top:0;left:0;z-index:20;padding-top:4px}.datepicker-dropdown.datepicker-orient-top{padding-top:0;padding-bottom:4px}.datepicker-picker{display:inline-block;border-radius:4px;background-color:white}.datepicker-dropdown .datepicker-picker{-webkit-box-shadow:0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);box-shadow:0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1)}.datepicker-picker span{display:block;-ms-flex:1;flex:1;border:0;border-radius:4px;cursor:default;text-align:center;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.datepicker-main{padding:2px}.datepicker-footer{-webkit-box-shadow:inset 0 1px 1px rgba(10, 10, 10, 0.1);box-shadow:inset 0 1px 1px rgba(10, 10, 10, 0.1);background-color:whitesmoke}.datepicker-grid,.datepicker-view .days-of-week,.datepicker-view,.datepicker-controls{display:-ms-flexbox;display:flex}.datepicker-grid{-ms-flex-wrap:wrap;flex-wrap:wrap}.datepicker-view .days .datepicker-cell,.datepicker-view .dow{-ms-flex-preferred-size:14.2857142857%;flex-basis:14.2857142857%}.datepicker-view.datepicker-grid .datepicker-cell{-ms-flex-preferred-size:25%;flex-basis:25%}.datepicker-cell,.datepicker-view .week{height:2.25rem;line-height:2.25rem}.datepicker-title{-webkit-box-shadow:inset 0 -1px 1px rgba(10, 10, 10, 0.1);box-shadow:inset 0 -1px 1px rgba(10, 10, 10, 0.1);background-color:whitesmoke;padding:0.375rem 0.75rem;text-align:center;font-weight:700}.datepicker-header .datepicker-controls{padding:2px 2px 0}.datepicker-controls .button{display:-ms-inline-flexbox;display:inline-flex;position:relative;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;margin:0;border:1px solid #dbdbdb;border-radius:4px;-webkit-box-shadow:none;box-shadow:none;background-color:white;cursor:pointer;padding:calc(0.375em - 1px) 0.75em;height:2.25em;vertical-align:top;text-align:center;line-height:1.5;white-space:nowrap;color:#363636;font-size:1rem}.datepicker-controls .button:focus,.datepicker-controls .button:active{outline:none}.datepicker-controls .button:hover{border-color:#b5b5b5;color:#363636}.datepicker-controls .button:focus{border-color:#3273dc;color:#363636}.datepicker-controls .button:focus:not(:active){-webkit-box-shadow:0 0 0 0.125em rgba(50, 115, 220, 0.25);box-shadow:0 0 0 0.125em rgba(50, 115, 220, 0.25)}.datepicker-controls .button:active{border-color:#4a4a4a;color:#363636}.datepicker-controls .button[disabled]{cursor:not-allowed}.datepicker-header .datepicker-controls .button{border-color:transparent;font-weight:bold}.datepicker-header .datepicker-controls .button:hover{background-color:#f9f9f9}.datepicker-header .datepicker-controls .button:focus:not(:active){-webkit-box-shadow:0 0 0 0.125em rgba(255, 255, 255, 0.25);box-shadow:0 0 0 0.125em rgba(255, 255, 255, 0.25)}.datepicker-header .datepicker-controls .button:active{background-color:#f2f2f2}.datepicker-header .datepicker-controls .button[disabled]{-webkit-box-shadow:none;box-shadow:none}.datepicker-footer .datepicker-controls .button{margin:calc(0.375rem - 1px) 0.375rem;border-radius:2px;width:100%;font-size:0.75rem}.datepicker-controls .view-switch{-ms-flex:auto;flex:auto}.datepicker-controls .prev-btn,.datepicker-controls .next-btn{padding-right:0.375rem;padding-left:0.375rem;width:2.25rem}.datepicker-controls .prev-btn.disabled,.datepicker-controls .next-btn.disabled{visibility:hidden}.datepicker-view .dow{height:1.5rem;line-height:1.5rem;font-size:0.875rem;font-weight:700}.datepicker-view .week{width:2.25rem;color:#b5b5b5;font-size:0.75rem}@media (max-width: 22.5rem){.datepicker-view .week{width:1.96875rem}}.datepicker-grid{width:15.75rem}@media (max-width: 22.5rem){.calendar-weeks+.days .datepicker-grid{width:13.78125rem}}.datepicker-cell:not(.disabled):hover{background-color:#f9f9f9;cursor:pointer}.datepicker-cell.focused:not(.selected){background-color:#e8e8e8}.datepicker-cell.selected,.datepicker-cell.selected:hover{background-color:#3273dc;color:#fff;font-weight:600}.datepicker-cell.disabled{color:#dbdbdb}.datepicker-cell.prev:not(.disabled),.datepicker-cell.next:not(.disabled){color:#7a7a7a}.datepicker-cell.prev.selected,.datepicker-cell.next.selected{color:#e6e6e6}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today){border-radius:0;background-color:whitesmoke}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today):not(.disabled):hover{background-color:#eeeeee}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today).focused{background-color:#e8e8e8}.datepicker-cell.today:not(.selected){background-color:#00d1b2}.datepicker-cell.today:not(.selected):not(.disabled){color:#fff}.datepicker-cell.today.focused:not(.selected){background-color:#00c4a7}.datepicker-cell.range-end:not(.selected),.datepicker-cell.range-start:not(.selected){background-color:#b5b5b5;color:#fff}.datepicker-cell.range-end.focused:not(.selected),.datepicker-cell.range-start.focused:not(.selected){background-color:#afafaf}.datepicker-cell.range-start{border-radius:4px 0 0 4px}.datepicker-cell.range-end{border-radius:0 4px 4px 0}.datepicker-cell.range{border-radius:0;background-color:#dbdbdb}.datepicker-cell.range:not(.disabled):not(.focused):not(.today):hover{background-color:#d5d5d5}.datepicker-cell.range.disabled{color:#c2c2c2}.datepicker-cell.range.focused{background-color:#cfcfcf}.datepicker-view.datepicker-grid .datepicker-cell{height:4.5rem;line-height:4.5rem}.datepicker-input.in-edit{border-color:#2366d1}.datepicker-input.in-edit:focus,.datepicker-input.in-edit:active{-webkit-box-shadow:0 0 0.25em 0.25em rgba(35, 102, 209, 0.2);box-shadow:0 0 0.25em 0.25em rgba(35, 102, 209, 0.2)}verdocs-field-date{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:64px;height:15px;display:block;font-size:11px;position:relative;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-date input{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid #ccc;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-date input.hide{display:none}verdocs-field-date.required input{border:1px solid var(--verdocs-required-color)}verdocs-field-date.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldDate=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.fieldInput=createEvent(this,"fieldInput",7),this.placeholder="Select Date",this.order=1,this.value="",this.required=!1,this.disabled=!1,this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}componentDidLoad(){new Datepicker(this.el,{autohide:!0,todayHighlight:!0}),this.el.addEventListener("changeDate",(t=>{console.log("changeDate",t.detail.date.toISOString())}))}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}handleInput(t){this.fieldInput.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("input",{type:"text",value:"",placeholder:this.placeholder,required:this.required,ref:t=>this.el=t,onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus(),onChange:t=>this.handleChange(t),onInput:t=>this.handleInput(t)}))}};VerdocsFieldDate.style=verdocsFieldDateCss;const verdocsFieldDropdownCss='verdocs-field-dropdown{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:85px;height:20px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-dropdown select{position:absolute;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-dropdown select:focus{outline:none}verdocs-field-dropdown select.hide{display:none}verdocs-field-dropdown.required select{border:1px solid var(--verdocs-required-color)}verdocs-field-dropdown.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldDropdown=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.options=[],this.required=!1,this.order=1,this.disabled=!1,this.value="",this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required}},h("select",{tabIndex:this.order,disabled:this.disabled,ref:t=>this.el=t,onChange:t=>this.handleChange(t),onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus()},h("option",{value:""},"Select..."),this.options.map((t=>h("option",{value:t.id,selected:t.value===this.value},t.value)))))}};VerdocsFieldDropdown.style=verdocsFieldDropdownCss;const verdocsFieldInitialCss='verdocs-field-initial{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:83px;height:36px;display:block;font-size:11px;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-initial img{display:block;max-width:100%;max-height:100%}verdocs-field-initial button{-webkit-box-sizing:border-box;box-sizing:border-box;border:none;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-initial button.hide{display:none}verdocs-field-initial.required{border:1px solid var(--verdocs-required-color)}verdocs-field-initial.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldInitial=class{constructor(t){registerInstance(this,t),this.adopt=createEvent(this,"adopt",7),this.cancel=createEvent(this,"cancel",7),this.required=!1,this.fullName="",this.value=""}async focusField(){this.handleShow()}handleShow(){this.dialog=document.createElement("verdocs-initial-dialog"),this.dialog.open=!0,this.dialog.fullName=this.fullName,this.dialog.addEventListener("cancel",(()=>{var t;console.log("cancel"),null===(t=this.dialog)||void 0===t||t.remove()})),document.addEventListener("adopt",(t=>{var e;console.log("adopt",t),null===(e=this.dialog)||void 0===e||e.remove()})),document.body.append(this.dialog)}render(){return h(Host,{class:{required:this.required}},""!==this.value?h("img",{src:this.value,alt:"Initials"}):h("button",{class:{},onClick:()=>this.handleShow()},"Initial"))}};VerdocsFieldInitial.style=verdocsFieldInitialCss;const verdocsFieldPaymentCss='verdocs-field-payment{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:24px;height:24px;display:block;font-size:11px;position:relative;border:1px solid #cfa;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-payment button,verdocs-field-payment div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-field-payment button{color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-payment button.hide{display:none}verdocs-field-payment input{float:left;font-family:Arial, sans-serif}verdocs-field-payment select{position:absolute;font-family:Arial, sans-serif;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-payment .frame{width:100%;height:100%;background-size:contain;text-align:left}verdocs-field-payment .frame img{position:absolute;height:auto;width:100%}verdocs-field-payment.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldPayment=class{constructor(t){registerInstance(this,t),this.signatureComplete=createEvent(this,"signatureComplete",7),this.initialComplete=createEvent(this,"initialComplete",7),this.focused=!1,this.signed=!1,this.signatureUrl="",this._fields=[],this.signatureFile=null,this.initialFile=null,this.focusOrderNumber=-1,this.focusFieldName="",this.activeElement=null,this.showError={pageNum:-1,fieldIndex:-1,type:null},this.dialogOpened=!1,this.closeAllErrors=!1,this.fieldsMap={},this.fieldsForCurrentSigner=[],this.fontSize=11,this.averageFontWidth=5,this.requiredFields=[]}componentWillLoad(){if(console.log("sign field",this.field),this.recipients&&this.recipients.length>0){const t=this.recipients.find((t=>"preparer"===t.type));console.log("Found preparer",t),t&&(this.preparedMessage=`Prepared by ${t.full_name}`)}}render(){return h(Host,{class:{focused:this.focused,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("button",{class:{hide:this.signed}},"Payment"),h("div",this.signed?{class:"frame"}:{style:{display:"none"}}),h("img",{width:"100%",height:"100%",src:this.signatureUrl}))}};VerdocsFieldPayment.style=verdocsFieldPaymentCss;const verdocsFieldRadioButtonCss='verdocs-field-radio-button{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:14px;height:14px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border-radius:100%}verdocs-field-radio-button input[type=radio]{position:absolute;opacity:0}verdocs-field-radio-button input[type=radio]+label:before{content:"";background:#f4f4f4;border-radius:100%;border:1px solid rgba(0, 0, 0, 0.2);display:inline-block;width:13px;height:13px;position:relative;top:2px;margin-right:2px;vertical-align:top;cursor:pointer;text-align:center;-webkit-transition:all 250ms ease;transition:all 250ms ease}verdocs-field-radio-button input[type=radio]:checked+label:before{background-color:#55bc81;-webkit-box-shadow:inset 0 0 0 2px #f4f4f4;box-shadow:inset 0 0 0 2px #f4f4f4}verdocs-field-radio-button input[type=radio]:focus+label:before{outline:none;border-color:#55bc81}verdocs-field-radio-button input[type=radio]:disabled+label:before{-webkit-box-shadow:inset 0 0 0 4px #f4f4f4;box-shadow:inset 0 0 0 4px #f4f4f4;border-color:#b4b4b4;background:#b4b4b4}verdocs-field-radio-button input[type=radio]+label:empty:before{margin-right:0}verdocs-field-radio-button.required input[type=radio]+label:before{border:1px solid var(--verdocs-required-color)}verdocs-field-radio-button.hide{display:none}verdocs-field-radio-button.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldRadioButton=class{constructor(t){registerInstance(this,t),this.fieldChange=createEvent(this,"fieldChange",7),this.order=1,this.checked=!1,this.value="",this.name="",this.required=!1,this.disabled=!1}handleChange(t){console.log("changed",t),this.fieldChange.emit(t.target.checked)}render(){return h(Host,{class:{required:this.required,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("input",{type:"radio",tabIndex:this.order,value:this.value,name:this.name,id:`${this.name}=${this.value}`,checked:this.checked,disabled:this.disabled,required:this.required,onChange:t=>this.handleChange(t)}),h("label",{htmlFor:`${this.name}=${this.value}`}))}};VerdocsFieldRadioButton.style=verdocsFieldRadioButtonCss;const verdocsFieldSignatureCss='verdocs-field-signature{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:83px;height:36px;display:block;font-size:11px;position:relative;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-signature img{display:block;max-width:100%;max-height:100%}verdocs-field-signature button{-webkit-box-sizing:border-box;box-sizing:border-box;border:none;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-signature button.hide{display:none}verdocs-field-signature.required{border:1px solid var(--verdocs-required-color)}verdocs-field-signature.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldSignature=class{constructor(t){registerInstance(this,t),this.adopt=createEvent(this,"adopt",7),this.cancel=createEvent(this,"cancel",7),this.required=!1,this.fullName="",this.value=""}async focusField(){this.handleShow()}handleShow(){this.dialog=document.createElement("verdocs-signature-dialog"),this.dialog.open=!0,this.dialog.fullName=this.fullName,this.dialog.addEventListener("cancel",(()=>{var t;console.log("cancel"),null===(t=this.dialog)||void 0===t||t.remove()})),document.addEventListener("adopt",(t=>{var e;console.log("adopt",t),null===(e=this.dialog)||void 0===e||e.remove()})),document.body.append(this.dialog)}render(){return h(Host,{class:{required:this.required}},""!==this.value?h("img",{src:this.value,alt:"Signature"}):h("button",{class:{},onClick:()=>this.handleShow()},"Signature"))}};VerdocsFieldSignature.style=verdocsFieldSignatureCss;const verdocsFieldTextareaCss='verdocs-field-textarea{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:150px;height:15px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-textarea textarea{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-textarea textarea.hide{display:none}verdocs-field-textarea.required{border:1px solid var(--verdocs-required-color)}verdocs-field-textarea.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldTextarea=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.fieldInput=createEvent(this,"fieldInput",7),this.placeholder="",this.order=1,this.value="",this.required=!1,this.disabled=!1,this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}handleInput(t){this.fieldInput.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required,storybook:!!(null===window||void 0===window?void 0:window.STORYBOOK_ENV)}},h("textarea",{placeholder:this.placeholder||"",tabIndex:this.order,value:this.value,disabled:this.disabled,required:this.required,ref:t=>this.el=t,onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus(),onChange:t=>this.handleChange(t),onInput:t=>this.handleInput(t)}))}};VerdocsFieldTextarea.style=verdocsFieldTextareaCss;const verdocsFieldTextboxCss='verdocs-field-textbox{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:150px;height:15px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-textbox input{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-textbox input.hide{display:none}verdocs-field-textbox.required{border:1px solid var(--verdocs-required-color)}verdocs-field-textbox.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}',VerdocsFieldTextbox=class{constructor(t){registerInstance(this,t),this.fieldFocus=createEvent(this,"fieldFocus",7),this.fieldBlur=createEvent(this,"fieldBlur",7),this.fieldChange=createEvent(this,"fieldChange",7),this.fieldInput=createEvent(this,"fieldInput",7),this.placeholder="",this.order=1,this.value="",this.required=!1,this.disabled=!1,this.focused=!1}async focusField(){this.focused=!0,this.el.focus(),this.fieldFocus.emit(!0)}handleBlur(){this.focused=!1,this.fieldBlur.emit(!0)}handleFocus(){this.focused=!0,this.fieldFocus.emit(!0)}handleChange(t){this.fieldChange.emit(t.target.value)}handleInput(t){this.fieldInput.emit(t.target.value)}render(){return h(Host,{class:{focused:this.focused,required:this.required}},h("input",{type:"text",placeholder:this.placeholder||"",tabIndex:this.order,value:this.value,disabled:this.disabled,required:this.required,ref:t=>this.el=t,onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus(),onChange:t=>this.handleChange(t),onInput:t=>this.handleInput(t)}))}};VerdocsFieldTextbox.style=verdocsFieldTextboxCss;const _nodeResolve_empty={},_nodeResolve_empty$1=Object.freeze({__proto__:null,default:_nodeResolve_empty}),require$$5=getAugmentedNamespace(_nodeResolve_empty$1);var pdf=createCommonjsModule((function(module,exports){
|
|
2
2
|
/**
|
|
3
3
|
* @licstart The following is the entire license notice for the
|
|
4
4
|
* Javascript code in this page
|
|
@@ -20,4 +20,4 @@ import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from".
|
|
|
20
20
|
* @licend The above is the entire license notice for the
|
|
21
21
|
* Javascript code in this page
|
|
22
22
|
*/
|
|
23
|
-
var factory;factory=function(){return(()=>{var __webpack_modules__=[,(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatTimer=e.RenderingCancelledException=e.PixelsPerInch=e.PageViewport=e.PDFDateString=e.LinkTarget=e.DOMStandardFontDataFactory=e.DOMSVGFactory=e.DOMCanvasFactory=e.DOMCMapReaderFactory=void 0,e.addLinkAttributes=function(t,{url:e,target:s,rel:n,enabled:r=!0}={}){(0,i.assert)(e&&"string"==typeof e,'addLinkAttributes: A valid "url" parameter must provided.');const o=(0,i.removeNullCharacters)(e);r?t.href=t.title=o:(t.href="",t.title=`Disabled: ${o}`,t.onclick=()=>!1);let h="";switch(s){case a.NONE:break;case a.SELF:h="_self";break;case a.BLANK:h="_blank";break;case a.PARENT:h="_parent";break;case a.TOP:h="_top"}t.target=h,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"},e.deprecated=function(t){console.log("Deprecated API usage: "+t)},e.getFilenameFromUrl=function(t){const e=t.indexOf("#"),s=t.indexOf("?"),i=Math.min(e>0?e:t.length,s>0?s:t.length);return t.substring(t.lastIndexOf("/",i)+1,i)},e.getPdfFilenameFromUrl=function(t,e="document.pdf"){if("string"!=typeof t)return e;if(h(t))return(0,i.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let r=s.exec(n[1])||s.exec(n[2])||s.exec(n[3]);if(r&&(r=r[0],r.includes("%")))try{r=s.exec(decodeURIComponent(r))[0]}catch(t){}return r||e},e.getXfaPageViewport=function(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style,r=[0,0,parseInt(i),parseInt(n)];return new o({viewBox:r,scale:e,rotation:s})},e.isDataScheme=h,e.isPdfFile=function(t){return"string"==typeof t&&/\.pdf$/i.test(t)},e.isValidFetchUrl=c,e.loadScript=function(t,e=!1){return new Promise(((s,i)=>{const n=document.createElement("script");n.src=t,n.onload=function(t){e&&n.remove(),s(t)},n.onerror=function(){i(new Error(`Cannot load script at: ${n.src}`))},(document.head||document.documentElement).appendChild(n)}))};var i=s(2),n=s(5);async function r(t,e=!1){if(c(t,document.baseURI)){const s=await fetch(t);if(!s.ok)throw new Error(s.statusText);return e?new Uint8Array(await s.arrayBuffer()):(0,i.stringToBytes)(await s.text())}return new Promise(((s,n)=>{const r=new XMLHttpRequest;r.open("GET",t,!0),e&&(r.responseType="arraybuffer"),r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){let t;if(e&&r.response?t=new Uint8Array(r.response):!e&&r.responseText&&(t=(0,i.stringToBytes)(r.responseText)),t)return void s(t)}n(new Error(r.statusText))}},r.send(null)}))}e.PixelsPerInch={CSS:96,PDF:72,get PDF_TO_CSS_UNITS(){return(0,i.shadow)(this,"PDF_TO_CSS_UNITS",this.CSS/this.PDF)}},e.DOMCanvasFactory=class extends n.BaseCanvasFactory{constructor({ownerDocument:t=globalThis.document}={}){super(),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},e.DOMCMapReaderFactory=class extends n.BaseCMapReaderFactory{_fetchData(t,e){return r(t,this.isCompressed).then((t=>({cMapData:t,compressionType:e})))}},e.DOMStandardFontDataFactory=class extends n.BaseStandardFontDataFactory{_fetchData(t){return r(t,!0)}},e.DOMSVGFactory=class extends n.BaseSVGFactory{_createSVG(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}};class o{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const o=(t[2]+t[0])/2,a=(t[3]+t[1])/2;let h,c,l,d,u,f,p,g;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,l=0,d=1;break;case 90:h=0,c=1,l=1,d=0;break;case 270:h=0,c=-1,l=-1,d=0;break;case 0:h=1,c=0,l=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(l=-l,d=-d),0===h?(u=Math.abs(a-t[1])*e+i,f=Math.abs(o-t[0])*e+n,p=Math.abs(t[3]-t[1])*e,g=Math.abs(t[2]-t[0])*e):(u=Math.abs(o-t[0])*e+i,f=Math.abs(a-t[1])*e+n,p=Math.abs(t[2]-t[0])*e,g=Math.abs(t[3]-t[1])*e),this.transform=[h*e,c*e,l*e,d*e,u-h*e*o-l*e*a,f-c*e*o-d*e*a],this.width=p,this.height=g}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new o({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return i.Util.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=i.Util.applyTransform([t[0],t[1]],this.transform),s=i.Util.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return i.Util.applyInverseTransform([t,e],this.transform)}}e.PageViewport=o,e.RenderingCancelledException=class extends i.BaseException{constructor(t,e){super(t,"RenderingCancelledException"),this.type=e}};const a={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};function h(t){const e=t.length;let s=0;for(;s<e&&""===t[s].trim();)s++;return"data:"===t.substring(s,s+5).toLowerCase()}function c(t,e){try{const{protocol:s}=e?new URL(t,e):new URL(t);return"http:"===s||"https:"===s}catch(t){return!1}}let l;e.LinkTarget=a,e.StatTimer=class{constructor(){this.started=Object.create(null),this.times=[]}time(t){t in this.started&&(0,i.warn)(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||(0,i.warn)(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const t of this.times){const s=t.name;s.length>e&&(e=s.length)}for(const s of this.times){const i=s.end-s.start;t.push(`${s.name.padEnd(e)} ${i}ms\n`)}return t.join("")}},e.PDFDateString=class{static toDateObject(t){if(!t||!(0,i.isString)(t))return null;l||(l=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=l.exec(t);if(!e)return null;const s=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(e[4],10);o=o>=0&&o<=23?o:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const c=e[7]||"Z";let d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,"-"===c?(o+=d,a+=u):"+"===c&&(o-=d,a-=u),new Date(Date.UTC(s,n,r,o,a,h))}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VerbosityLevel=e.Util=e.UnknownErrorException=e.UnexpectedResponseException=e.UNSUPPORTED_FEATURES=e.TextRenderingMode=e.StreamType=e.RenderingIntentFlag=e.PermissionFlag=e.PasswordResponses=e.PasswordException=e.PageActionEventType=e.OPS=e.MissingPDFException=e.IsLittleEndianCached=e.IsEvalSupportedCached=e.InvalidPDFException=e.ImageKind=e.IDENTITY_MATRIX=e.FormatError=e.FontType=e.FONT_IDENTITY_MATRIX=e.DocumentActionEventType=e.CMapCompressionType=e.BaseException=e.AnnotationType=e.AnnotationStateModelType=e.AnnotationReviewState=e.AnnotationReplyType=e.AnnotationMode=e.AnnotationMarkedState=e.AnnotationFlag=e.AnnotationFieldFlag=e.AnnotationBorderStyleType=e.AnnotationActionEventType=e.AbortException=void 0,e.arrayByteLength=f,e.arraysToBytes=function(t){const e=t.length;if(1===e&&t[0]instanceof Uint8Array)return t[0];let s=0;for(let i=0;i<e;i++)s+=f(t[i]);let i=0;const n=new Uint8Array(s);for(let s=0;s<e;s++){let e=t[s];e instanceof Uint8Array||(e="string"==typeof e?u(e):new Uint8Array(e));const r=e.byteLength;n.set(e,i),i+=r}return n},e.assert=a,e.bytesToString=function(t){a(null!==t&&"object"==typeof t&&void 0!==t.length,"Invalid argument for bytesToString");const e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);const i=[];for(let n=0;n<e;n+=s){const r=Math.min(n+s,e),o=t.subarray(n,r);i.push(String.fromCharCode.apply(null,o))}return i.join("")},e.createObjectURL=function(t,e="",s=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!s)return URL.createObjectURL(new Blob([t],{type:e}));const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let n=`data:${e};base64,`;for(let e=0,s=t.length;e<s;e+=3){const r=255&t[e],o=255&t[e+1],a=255&t[e+2];n+=i[r>>2]+i[(3&r)<<4|o>>4]+i[e+1<s?(15&o)<<2|a>>6:64]+i[e+2<s?63&a:64]}return n},e.createPromiseCapability=function(){const t=Object.create(null);let e=!1;return Object.defineProperty(t,"settled",{get:()=>e}),t.promise=new Promise((function(s,i){t.resolve=function(t){e=!0,s(t)},t.reject=function(t){e=!0,i(t)}})),t},e.createValidAbsoluteUrl=function(t,e=null,s=null){if(!t)return null;try{if(s&&"string"==typeof t){if(s.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e&&e.length>=2&&(t=`http://${t}`)}if(s.tryConvertEncoding)try{t=A(t)}catch(t){}}const i=e?new URL(t,e):new URL(t);if(function(t){if(!t)return!1;switch(t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(t){}return null},e.escapeString=function(t){return t.replace(/([()\\\n\r])/g,(t=>"\n"===t?"\\n":"\r"===t?"\\r":`\\${t}`))},e.getModificationDate=function(t=new Date){return[t.getUTCFullYear().toString(),(t.getUTCMonth()+1).toString().padStart(2,"0"),t.getUTCDate().toString().padStart(2,"0"),t.getUTCHours().toString().padStart(2,"0"),t.getUTCMinutes().toString().padStart(2,"0"),t.getUTCSeconds().toString().padStart(2,"0")].join("")},e.getVerbosityLevel=function(){return n},e.info=function(t){n>=i.INFOS&&console.log(`Info: ${t}`)},e.isArrayBuffer=function(t){return"object"==typeof t&&null!==t&&void 0!==t.byteLength},e.isArrayEqual=function(t,e){if(t.length!==e.length)return!1;for(let s=0,i=t.length;s<i;s++)if(t[s]!==e[s])return!1;return!0},e.isAscii=function(t){return/^[\x00-\x7F]*$/.test(t)},e.isBool=function(t){return"boolean"==typeof t},e.isNum=function(t){return"number"==typeof t},e.isSameOrigin=function(t,e){let s;try{if(s=new URL(t),!s.origin||"null"===s.origin)return!1}catch(t){return!1}const i=new URL(e,s);return s.origin===i.origin},e.isString=function(t){return"string"==typeof t},e.objectFromMap=function(t){const e=Object.create(null);for(const[s,i]of t)e[s]=i;return e},e.objectSize=function(t){return Object.keys(t).length},e.removeNullCharacters=function(t,e=!1){return"string"!=typeof t?(r("The argument for removeNullCharacters must be a string."),t):(e&&(t=t.replace(d," ")),t.replace(l,""))},e.setVerbosityLevel=function(t){Number.isInteger(t)&&(n=t)},e.shadow=h,e.string32=function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)},e.stringToBytes=u,e.stringToPDFString=function(t){const e=t.length,s=[];if("þ"===t[0]&&"ÿ"===t[1])for(let i=2;i<e;i+=2)s.push(String.fromCharCode(t.charCodeAt(i)<<8|t.charCodeAt(i+1)));else if("ÿ"===t[0]&&"þ"===t[1])for(let i=2;i<e;i+=2)s.push(String.fromCharCode(t.charCodeAt(i+1)<<8|t.charCodeAt(i)));else for(let i=0;i<e;++i){const e=b[t.charCodeAt(i)];s.push(e?String.fromCharCode(e):t.charAt(i))}return s.join("")},e.stringToUTF16BEString=function(t){const e=["þÿ"];for(let s=0,i=t.length;s<i;s++){const i=t.charCodeAt(s);e.push(String.fromCharCode(i>>8&255),String.fromCharCode(255&i))}return e.join("")},e.stringToUTF8String=A,e.unreachable=o,e.utf8StringToString=function(t){return unescape(encodeURIComponent(t))},e.warn=r,s(3),e.IDENTITY_MATRIX=[1,0,0,1,0,0],e.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0],e.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},e.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},e.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},e.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},e.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},e.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},e.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"},e.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"},e.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"},e.AnnotationReplyType={GROUP:"Group",REPLY:"R"},e.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512},e.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864},e.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},e.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"},e.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},e.PageActionEventType={O:"PageOpen",C:"PageClose"},e.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"},e.FontType={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1STANDARD:"TYPE1STANDARD",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const i={ERRORS:0,WARNINGS:1,INFOS:5};e.VerbosityLevel=i,e.CMapCompressionType={NONE:0,BINARY:1,STREAM:2},e.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},e.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",signatures:"signatures",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"},e.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let n=i.WARNINGS;function r(t){n>=i.WARNINGS&&console.log(`Warning: ${t}`)}function o(t){throw new Error(t)}function a(t,e){t||o(e)}function h(t,e,s){return Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!1}),s}const c=function(){function t(e,s){this.constructor===t&&o("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();e.BaseException=c,e.PasswordException=class extends c{constructor(t,e){super(t,"PasswordException"),this.code=e}},e.UnknownErrorException=class extends c{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},e.InvalidPDFException=class extends c{constructor(t){super(t,"InvalidPDFException")}},e.MissingPDFException=class extends c{constructor(t){super(t,"MissingPDFException")}},e.UnexpectedResponseException=class extends c{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},e.FormatError=class extends c{constructor(t){super(t,"FormatError")}},e.AbortException=class extends c{constructor(t){super(t,"AbortException")}};const l=/\x00+/g,d=/[\x01-\x1F]/g;function u(t){a("string"==typeof t,"Invalid argument for stringToBytes");const e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=255&t.charCodeAt(i);return s}function f(t){return void 0!==t.length?t.length:(a(void 0!==t.byteLength,"arrayByteLength - invalid argument."),t.byteLength)}e.IsLittleEndianCached={get value(){return h(this,"value",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}},e.IsEvalSupportedCached={get value(){return h(this,"value",function(){try{return new Function(""),!0}catch(t){return!1}}())}};const p=[...Array(256).keys()].map((t=>t.toString(16).padStart(2,"0")));class g{static makeHexColor(t,e,s){return`#${p[t]}${p[e]}${p[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}static getAxialAlignedBoundingBox(t,e){const s=g.applyTransform(t,e),i=g.applyTransform(t.slice(2,4),e),n=g.applyTransform([t[0],t[3]],e),r=g.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static apply3dTransform(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[3]*e[0]+t[4]*e[1]+t[5]*e[2],t[6]*e[0]+t[7]*e[1]+t[8]*e[2]]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[2]*e[1]+t[3]*e[3],n=(s+i)/2,r=Math.sqrt((s+i)**2-4*(s*i-(t[2]*e[0]+t[3]*e[2])*(t[0]*e[1]+t[1]*e[3])))/2,o=n-r||1;return[Math.sqrt(n+r||1),Math.sqrt(o)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){function s(t,e){return t-e}const i=[t[0],t[2],e[0],e[2]].sort(s),n=[t[1],t[3],e[1],e[3]].sort(s),r=[];return t=g.normalizeRect(t),e=g.normalizeRect(e),i[0]===t[0]&&i[1]===e[0]||i[0]===e[0]&&i[1]===t[0]?(r[0]=i[1],r[2]=i[2],n[0]===t[1]&&n[1]===e[1]||n[0]===e[1]&&n[1]===t[1]?(r[1]=n[1],r[3]=n[2],r):null):null}static bezierBoundingBox(t,e,s,i,n,r,o,a){const h=[],c=[[],[]];let l,d,u,f,p,g,b,A;for(let c=0;c<2;++c)if(0===c?(d=6*t-12*s+6*n,l=-3*t+9*s-9*n+3*o,u=3*s-3*t):(d=6*e-12*i+6*r,l=-3*e+9*i-9*r+3*a,u=3*i-3*e),Math.abs(l)<1e-12){if(Math.abs(d)<1e-12)continue;f=-u/d,0<f&&f<1&&h.push(f)}else b=d*d-4*u*l,A=Math.sqrt(b),b<0||(p=(-d+A)/(2*l),0<p&&p<1&&h.push(p),g=(-d-A)/(2*l),0<g&&g<1&&h.push(g));let m,w=h.length;const v=w;for(;w--;)f=h[w],m=1-f,c[0][w]=m*m*m*t+3*m*m*f*s+3*m*f*f*n+f*f*f*o,c[1][w]=m*m*m*e+3*m*m*f*i+3*m*f*f*r+f*f*f*a;return c[0][v]=t,c[1][v]=e,c[0][v+1]=o,c[1][v+1]=a,c[0].length=c[1].length=v+2,[Math.min(...c[0]),Math.min(...c[1]),Math.max(...c[0]),Math.max(...c[1])]}}e.Util=g;const b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function A(t){return decodeURIComponent(escape(t))}},(t,e,s)=>{s(4)},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNodeJS=void 0,e.isNodeJS=!("object"!=typeof process_1||process_1+""!="[object process]"||process_1.versions.nw||process_1.versions.electron&&process_1.type&&"browser"!==process_1.type)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseStandardFontDataFactory=e.BaseSVGFactory=e.BaseCanvasFactory=e.BaseCMapReaderFactory=void 0;var i=s(2);class n{constructor(){this.constructor===n&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d")}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}e.BaseCanvasFactory=n;class r{constructor({baseUrl:t=null,isCompressed:e=!1}){this.constructor===r&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetchData(e,this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE).catch((()=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(t,e){(0,i.unreachable)("Abstract method `_fetchData` called.")}}e.BaseCMapReaderFactory=r;class o{constructor({baseUrl:t=null}){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch((()=>{throw new Error(`Unable to load font data at: ${e}`)}))}_fetchData(t){(0,i.unreachable)("Abstract method `_fetchData` called.")}}e.BaseStandardFontDataFactory=o;class a{constructor(){this.constructor===a&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(t,e){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){(0,i.unreachable)("Abstract method `_createSVG` called.")}}e.BaseSVGFactory=a},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=exports.RenderTask=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,exports.getDocument=getDocument,exports.setPDFNetworkStreamFactory=setPDFNetworkStreamFactory,exports.version=void 0;var _util=__w_pdfjs_require__(2),_display_utils=__w_pdfjs_require__(1),_font_loader=__w_pdfjs_require__(7),_node_utils=__w_pdfjs_require__(8),_annotation_storage=__w_pdfjs_require__(9),_canvas=__w_pdfjs_require__(10),_worker_options=__w_pdfjs_require__(12),_is_node=__w_pdfjs_require__(4),_message_handler=__w_pdfjs_require__(13),_metadata=__w_pdfjs_require__(14),_optional_content_config=__w_pdfjs_require__(15),_transport_stream=__w_pdfjs_require__(16),_xfa_text=__w_pdfjs_require__(17);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DefaultCanvasFactory=_is_node.isNodeJS?_node_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_is_node.isNodeJS?_node_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultStandardFontDataFactory=_is_node.isNodeJS?_node_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;let createPDFNetworkStream;function setPDFNetworkStreamFactory(t){createPDFNetworkStream=t}function getDocument(t){const e=new PDFDocumentLoadingTask;let s;if("string"==typeof t||t instanceof URL)s={url:t};else if((0,_util.isArrayBuffer)(t))s={data:t};else if(t instanceof PDFDataRangeTransport)s={range:t};else{if("object"!=typeof t)throw new Error("Invalid parameter in getDocument, need either string, URL, Uint8Array, or parameter object.");if(!t.url&&!t.data&&!t.range)throw new Error("Invalid parameter object: need either .data, .range or .url");s=t}const i=Object.create(null);let n=null,r=null;for(const t in s){const e=s[t];switch(t){case"url":if("undefined"!=typeof window)try{i[t]=new URL(e,window.location).href;continue}catch(t){(0,_util.warn)(`Cannot create valid URL: "${t}".`)}else if("string"==typeof e||e instanceof URL){i[t]=e.toString();continue}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.");case"range":n=e;continue;case"worker":r=e;continue;case"data":if(_is_node.isNodeJS&&void 0!==Buffer&&e instanceof Buffer)i[t]=new Uint8Array(e);else{if(e instanceof Uint8Array)break;if("string"==typeof e)i[t]=(0,_util.stringToBytes)(e);else if("object"!=typeof e||null===e||isNaN(e.length)){if(!(0,_util.isArrayBuffer)(e))throw new Error("Invalid PDF binary data: either typed array, string, or array-like object is expected in the data property.");i[t]=new Uint8Array(e)}else i[t]=new Uint8Array(e)}continue}i[t]=e}if(i.rangeChunkSize=i.rangeChunkSize||DEFAULT_RANGE_CHUNK_SIZE,i.CMapReaderFactory=i.CMapReaderFactory||DefaultCMapReaderFactory,i.StandardFontDataFactory=i.StandardFontDataFactory||DefaultStandardFontDataFactory,i.ignoreErrors=!0!==i.stopAtErrors,i.fontExtraProperties=!0===i.fontExtraProperties,i.pdfBug=!0===i.pdfBug,i.enableXfa=!0===i.enableXfa,("string"!=typeof i.docBaseUrl||(0,_display_utils.isDataScheme)(i.docBaseUrl))&&(i.docBaseUrl=null),Number.isInteger(i.maxImageSize)||(i.maxImageSize=-1),"boolean"!=typeof i.useWorkerFetch&&(i.useWorkerFetch=i.CMapReaderFactory===_display_utils.DOMCMapReaderFactory&&i.StandardFontDataFactory===_display_utils.DOMStandardFontDataFactory),"boolean"!=typeof i.isEvalSupported&&(i.isEvalSupported=!0),"boolean"!=typeof i.disableFontFace&&(i.disableFontFace=_is_node.isNodeJS),"boolean"!=typeof i.useSystemFonts&&(i.useSystemFonts=!_is_node.isNodeJS&&!i.disableFontFace),void 0===i.ownerDocument&&(i.ownerDocument=globalThis.document),"boolean"!=typeof i.disableRange&&(i.disableRange=!1),"boolean"!=typeof i.disableStream&&(i.disableStream=!1),"boolean"!=typeof i.disableAutoFetch&&(i.disableAutoFetch=!1),(0,_util.setVerbosityLevel)(i.verbosity),!r){const t={verbosity:i.verbosity,port:_worker_options.GlobalWorkerOptions.workerPort};r=t.port?PDFWorker.fromPort(t):new PDFWorker(t),e._worker=r}const o=e.docId;return r.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");const t=_fetchDocument(r,i,n,o),s=new Promise((function(t){let e;n?e=new _transport_stream.PDFDataTransportStream({length:i.length,initialData:i.initialData,progressiveDone:i.progressiveDone,contentDispositionFilename:i.contentDispositionFilename,disableRange:i.disableRange,disableStream:i.disableStream},n):i.data||(e=createPDFNetworkStream({url:i.url,length:i.length,httpHeaders:i.httpHeaders,withCredentials:i.withCredentials,rangeChunkSize:i.rangeChunkSize,disableRange:i.disableRange,disableStream:i.disableStream})),t(e)}));return Promise.all([t,s]).then((function([t,s]){if(e.destroyed)throw new Error("Loading aborted");const n=new _message_handler.MessageHandler(o,t,r.port),a=new WorkerTransport(n,e,s,i);e._transport=a,n.send("Ready",null)}))})).catch(e._capability.reject),e}async function _fetchDocument(t,e,s,i){if(t.destroyed)throw new Error("Worker was destroyed");s&&(e.length=s.length,e.initialData=s.initialData,e.progressiveDone=s.progressiveDone,e.contentDispositionFilename=s.contentDispositionFilename);const n=await t.messageHandler.sendWithPromise("GetDocRequest",{docId:i,apiVersion:"2.12.313",source:{data:e.data,url:e.url,password:e.password,disableAutoFetch:e.disableAutoFetch,rangeChunkSize:e.rangeChunkSize,length:e.length},maxImageSize:e.maxImageSize,disableFontFace:e.disableFontFace,docBaseUrl:e.docBaseUrl,ignoreErrors:e.ignoreErrors,isEvalSupported:e.isEvalSupported,fontExtraProperties:e.fontExtraProperties,enableXfa:e.enableXfa,useSystemFonts:e.useSystemFonts,cMapUrl:e.useWorkerFetch?e.cMapUrl:null,standardFontDataUrl:e.useWorkerFetch?e.standardFontDataUrl:null});if(t.destroyed)throw new Error("Worker was destroyed");return n}exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;class PDFDocumentLoadingTask{static get idCounters(){return(0,_util.shadow)(this,"idCounters",{doc:0})}constructor(){this._capability=(0,_util.createPromiseCapability)(),this._transport=null,this._worker=null,this.docId="d"+PDFDocumentLoadingTask.idCounters.doc++,this.destroyed=!1,this.onPassword=null,this.onProgress=null,this.onUnsupportedFeature=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,await(this._transport?.destroy()),this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const s of this._progressListeners)s(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(t,e){this._pdfInfo=t,this._transport=e,Object.defineProperty(this,"fingerprint",{get(){return(0,_display_utils.deprecated)("`PDFDocumentProxy.fingerprint`, please use `PDFDocumentProxy.fingerprints` instead."),this.fingerprints[0]}}),Object.defineProperty(this,"getStats",{value:async()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getStats`, please use the `PDFDocumentProxy.stats`-getter instead."),this.stats||{streamTypes:{},fontTypes:{}})})}get annotationStorage(){return this._transport.annotationStorage}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get stats(){return this._transport.stats}get isPureXfa(){return!!this._transport._htmlForXfa}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}saveDocument(){return this._transport.annotationStorage.size<=0&&(0,_display_utils.deprecated)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead."),this._transport.saveDocument()}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(t,e,s,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._ownerDocument=i,this._transport=s,this._stats=n?new _display_utils.StatTimer:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new PDFObjects,this.cleanupAfterRender=!1,this.pendingCleanup=!1,this._intentStates=new Map,this._annotationPromises=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const e=this._transport.getRenderingIntent(t);let s=this._annotationPromises.get(e.cacheKey);return s||(s=this._transport.getAnnotations(this._pageIndex,e.renderingIntent),this._annotationPromises.set(e.cacheKey,s),s=s.then((t=>{for(const e of t)void 0!==e.titleObj&&Object.defineProperty(e,"title",{get:()=>((0,_display_utils.deprecated)("`title`-property on annotation, please use `titleObj` instead."),e.titleObj.str)}),void 0!==e.contentsObj&&Object.defineProperty(e,"contents",{get:()=>((0,_display_utils.deprecated)("`contents`-property on annotation, please use `contentsObj` instead."),e.contentsObj.str)});return t}))),s}getJSActions(){return this._jsActionsPromise||=this._transport.getPageJSActions(this._pageIndex)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=_util.AnnotationMode.ENABLE,transform:n=null,imageLayer:r=null,canvasFactory:o=null,background:a=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null}){void 0!==arguments[0]?.renderInteractiveForms&&((0,_display_utils.deprecated)("render no longer accepts the `renderInteractiveForms`-option, please use the `annotationMode`-option instead."),!0===arguments[0].renderInteractiveForms&&i===_util.AnnotationMode.ENABLE&&(i=_util.AnnotationMode.ENABLE_FORMS)),void 0!==arguments[0]?.includeAnnotationStorage&&((0,_display_utils.deprecated)("render no longer accepts the `includeAnnotationStorage`-option, please use the `annotationMode`-option instead."),!0===arguments[0].includeAnnotationStorage&&i===_util.AnnotationMode.ENABLE&&(i=_util.AnnotationMode.ENABLE_STORAGE)),this._stats&&this._stats.time("Overall");const l=this._transport.getRenderingIntent(s,i);this.pendingCleanup=!1,h||(h=this._transport.getOptionalContentConfig());let d=this._intentStates.get(l.cacheKey);d||(d=Object.create(null),this._intentStates.set(l.cacheKey,d)),d.streamReaderCancelTimeout&&(clearTimeout(d.streamReaderCancelTimeout),d.streamReaderCancelTimeout=null);const u=o||new DefaultCanvasFactory({ownerDocument:this._ownerDocument}),f=!!(l.renderingIntent&_util.RenderingIntentFlag.PRINT);d.displayReadyCapability||(d.displayReadyCapability=(0,_util.createPromiseCapability)(),d.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(l));const p=t=>{d.renderTasks.delete(g),(this.cleanupAfterRender||f)&&(this.pendingCleanup=!0),this._tryCleanup(),t?(g.capability.reject(t),this._abortOperatorList({intentState:d,reason:t instanceof Error?t:new Error(t)})):g.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"))},g=new InternalRenderTask({callback:p,params:{canvasContext:t,viewport:e,transform:n,imageLayer:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:d.operatorList,pageIndex:this._pageIndex,canvasFactory:u,useRequestAnimationFrame:!f,pdfBug:this._pdfBug});(d.renderTasks||=new Set).add(g);const b=g.task;return Promise.all([d.displayReadyCapability.promise,h]).then((([t,e])=>{this.pendingCleanup?p():(this._stats&&this._stats.time("Rendering"),g.initializeGraphics({transparency:t,optionalContentConfig:e}),g.operatorListChanged())})).catch(p),b}getOperatorList({intent:t="display",annotationMode:e=_util.AnnotationMode.ENABLE}={}){const s=this._transport.getRenderingIntent(t,e,!0);let i,n=this._intentStates.get(s.cacheKey);return n||(n=Object.create(null),this._intentStates.set(s.cacheKey,n)),n.opListReadCapability||(i=Object.create(null),i.operatorListChanged=function(){n.operatorList.lastChunk&&(n.opListReadCapability.resolve(n.operatorList),n.renderTasks.delete(i))},n.opListReadCapability=(0,_util.createPromiseCapability)(),(n.renderTasks||=new Set).add(i),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(s)),n.opListReadCapability.promise}streamTextContent({normalizeWhitespace:t=!1,disableCombineTextItems:e=!1,includeMarkedContent:s=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,normalizeWhitespace:!0===t,combineTextItems:!0!==e,includeMarkedContent:!0===s},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>_xfa_text.XfaText.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,s){const i=e.getReader(),n={items:[],styles:Object.create(null)};!function e(){i.read().then((function({value:s,done:i}){i?t(n):(Object.assign(n.styles,s.styles),n.items.push(...s.items),e())}),s)}()}))}getStructTree(){return this._structTreePromise||=this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,this.pendingCleanup=!1,Promise.all(t)}cleanup(t=!1){return this.pendingCleanup=!0,this._tryCleanup(t)}_tryCleanup(t=!1){if(!this.pendingCleanup)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,t&&this._stats&&(this._stats=new _display_utils.StatTimer),this.pendingCleanup=!1,!0}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats&&this._stats.timeEnd("Page Request"),s.displayReadyCapability&&s.displayReadyCapability.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this._tryCleanup()}_pumpOperatorList({renderingIntent:t,cacheKey:e}){const s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:t&_util.RenderingIntentFlag.ANNOTATIONS_STORAGE?this._transport.annotationStorage.serializable:null}).getReader(),i=this._intentStates.get(e);i.streamReader=s;const n=()=>{s.read().then((({value:t,done:e})=>{e?i.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,i),n())}),(t=>{if(i.streamReader=null,!this._transport.destroyed){if(i.operatorList){i.operatorList.lastChunk=!0;for(const t of i.renderTasks)t.operatorListChanged();this._tryCleanup()}if(i.displayReadyCapability)i.displayReadyCapability.reject(t);else{if(!i.opListReadCapability)throw t;i.opListReadCapability.reject(t)}}}))};n()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(!s){if(t.renderTasks.size>0)return;if(e instanceof _display_utils.RenderingCancelledException)return void(t.streamReaderCancelTimeout=setTimeout((()=>{this._abortOperatorList({intentState:t,reason:e,force:!0}),t.streamReaderCancelTimeout=null}),RENDERING_CANCELLED_TIMEOUT))}if(t.streamReader.cancel(new _util.AbortException(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,s]of this._intentStates)if(s===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){this._listeners=[],this._deferred=Promise.resolve()}postMessage(t,e){const s={data:function(t){if(globalThis.structuredClone)return globalThis.structuredClone(t,e);const s=new WeakMap;return function t(i){if("function"==typeof i||"symbol"==typeof i||i instanceof URL)throw new Error(`LoopbackPort.postMessage - cannot clone: ${i?.toString()}`);if("object"!=typeof i||null===i)return i;if(s.has(i))return s.get(i);let n,r;if((n=i.buffer)&&(0,_util.isArrayBuffer)(n))return r=e?.includes(n)?new i.constructor(n,i.byteOffset,i.byteLength):new i.constructor(i),s.set(i,r),r;if(i instanceof Map){r=new Map,s.set(i,r);for(const[e,s]of i)r.set(e,t(s));return r}if(i instanceof Set){r=new Set,s.set(i,r);for(const e of i)r.add(t(e));return r}r=Array.isArray(i)?[]:Object.create(null),s.set(i,r);for(const e in i){let s,n=i;for(;!(s=Object.getOwnPropertyDescriptor(n,e));)n=Object.getPrototypeOf(n);void 0!==s.value&&("function"!=typeof s.value||i.hasOwnProperty?.(e))&&(r[e]=t(s.value))}return r}(t)}(t)};this._deferred.then((()=>{for(const t of this._listeners)t.call(this,s)}))}addEventListener(t,e){this._listeners.push(e)}removeEventListener(t,e){const s=this._listeners.indexOf(e);this._listeners.splice(s,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};if(_is_node.isNodeJS&&"function"==typeof commonjsRequire)PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if("object"==typeof document){const t=document?.currentScript?.src;t&&(PDFWorkerUtil.fallbackWorkerSrc=t.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.createCDNWrapper=function(t){return URL.createObjectURL(new Blob([`importScripts("${t}");`]))};class PDFWorker{static get _workerPorts(){return(0,_util.shadow)(this,"_workerPorts",new WeakMap)}constructor({name:t=null,port:e=null,verbosity:s=(0,_util.getVerbosityLevel)()}={}){if(e&&PDFWorker._workerPorts.has(e))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=(0,_util.createPromiseCapability)(),this._port=null,this._webWorker=null,this._messageHandler=null,e)return PDFWorker._workerPorts.set(e,this),void this._initializeFromPort(e);this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new _message_handler.MessageHandler("main","worker",t),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve()}_initialize(){if("undefined"!=typeof Worker&&!PDFWorkerUtil.isWorkerDisabled&&!PDFWorker._mainThreadWorkerMessageHandler){let t=PDFWorker.workerSrc;try{(0,_util.isSameOrigin)(window.location.href,t)||(t=PDFWorkerUtil.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t),s=new _message_handler.MessageHandler("main","worker",e),i=()=>{e.removeEventListener("error",n),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=()=>{this._webWorker||i()};e.addEventListener("error",n),s.on("test",(t=>{e.removeEventListener("error",n),this.destroyed?i():t?(this._messageHandler=s,this._port=e,this._webWorker=e,this._readyCapability.resolve(),s.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),s.destroy(),e.terminate())})),s.on("ready",(()=>{if(e.removeEventListener("error",n),this.destroyed)i();else try{r()}catch(t){this._setupFakeWorker()}}));const r=()=>{const t=new Uint8Array([255]);try{s.send("test",t,[t.buffer])}catch(e){(0,_util.warn)("Cannot use postMessage transfers."),t[0]=0,s.send("test",t)}};return void r()}catch(t){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),PDFWorker._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new LoopbackPort;this._port=e;const s="fake"+PDFWorkerUtil.fakeWorkerId++,i=new _message_handler.MessageHandler(s+"_worker",s,e);t.setup(i,e);const n=new _message_handler.MessageHandler(s,s+"_worker",e);this._messageHandler=n,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),PDFWorker._workerPorts.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this._workerPorts.has(t.port)?this._workerPorts.get(t.port):new PDFWorker(t)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(null!==PDFWorkerUtil.fallbackWorkerSrc)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch(t){return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof commonjsRequire){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}}exports.PDFWorker=PDFWorker,PDFWorker.getWorkerSrc=function(){return(0,_display_utils.deprecated)("`PDFWorker.getWorkerSrc()`, please use `PDFWorker.workerSrc` instead."),this.workerSrc};class WorkerTransport{#t=null;#e=new Map;#s=new Map;#i=null;constructor(t,e,s,i){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({docId:e.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this._params=i,i.useWorkerFetch||(this.CMapReaderFactory=new i.CMapReaderFactory({baseUrl:i.cMapUrl,isCompressed:i.cMapPacked}),this.StandardFontDataFactory=new i.StandardFontDataFactory({baseUrl:i.standardFontDataUrl})),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=(0,_util.createPromiseCapability)(),this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}get stats(){return this.#t}getRenderingIntent(t,e=_util.AnnotationMode.ENABLE,s=!1){let i=_util.RenderingIntentFlag.DISPLAY,n="";switch(t){case"any":i=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":i=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case _util.AnnotationMode.DISABLE:i+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:i+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:i+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,n=this.annotationStorage.lastModified;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${e}`)}return s&&(i+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:i,cacheKey:`${i}_${n}`}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=(0,_util.createPromiseCapability)(),this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#e.values())t.push(e._destroy());this.#e.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#i=null,this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null,this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:s}){s?e.close():((0,_util.assert)((0,_util.isArrayBuffer)(t),"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(()=>{const t=(0,_util.createPromiseCapability)(),s=this._fullReader;return s.headersReady.then((()=>{s.isStreamingSupported&&s.isRangeSupported||(this._lastProgress&&e.onProgress?.(this._lastProgress),s.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),t.resolve({isStreamingSupported:s.isStreamingSupported,isRangeSupported:s.isRangeSupported,contentLength:s.contentLength})}),t.reject),t.promise})),t.on("GetRangeReader",((t,e)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const s=this._networkStream.getRangeReader(t.begin,t.end);s?(e.onPull=()=>{s.read().then((function({value:t,done:s}){s?e.close():((0,_util.assert)((0,_util.isArrayBuffer)(t),"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{s.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new PDFDocumentProxy(t,this))})),t.on("DocException",(function(t){let s;switch(t.name){case"PasswordException":s=new _util.PasswordException(t.message,t.code);break;case"InvalidPDFException":s=new _util.InvalidPDFException(t.message);break;case"MissingPDFException":s=new _util.MissingPDFException(t.message);break;case"UnexpectedResponseException":s=new _util.UnexpectedResponseException(t.message,t.status);break;case"UnknownErrorException":s=new _util.UnknownErrorException(t.message,t.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}e._capability.reject(s)})),t.on("PasswordRequest",(t=>{if(this._passwordCapability=(0,_util.createPromiseCapability)(),e.onPassword){const s=t=>{this._passwordCapability.resolve({password:t})};try{e.onPassword(s,t.code)}catch(t){this._passwordCapability.reject(t)}}else this._passwordCapability.reject(new _util.PasswordException(t.message,t.code));return this._passwordCapability.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#e.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,s,i])=>{if(!this.destroyed&&!this.commonObjs.has(e))switch(s){case"Font":const n=this._params;if("error"in i){const t=i.error;(0,_util.warn)(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let r=null;n.pdfBug&&globalThis.FontInspector?.enabled&&(r={registerFont(t,e){globalThis.FontInspector.fontAdded(t,e)}});const o=new _font_loader.FontFaceObject(i,{isEvalSupported:n.isEvalSupported,disableFontFace:n.disableFontFace,ignoreErrors:n.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:r});this.fontLoader.bind(o).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!n.fontExtraProperties&&o.data&&(o.data=null),this.commonObjs.resolve(e,o)}));break;case"FontPath":case"Image":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${s}`)}})),t.on("obj",(([t,e,s,i])=>{if(this.destroyed)return;const n=this.#e.get(e);if(!n.objs.has(t))switch(s){case"Image":n.objs.resolve(t,i),i?.data?.length>8e6&&(n.cleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,i);break;default:throw new Error(`Got unknown object type ${s}`)}})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("DocStats",(t=>{this.destroyed||(this.#t=Object.freeze({streamTypes:Object.freeze(t.streamTypes),fontTypes:Object.freeze(t.fontTypes)}))})),t.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this)),t.on("FetchBuiltInCMap",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.CMapReaderFactory?this.CMapReaderFactory.fetch(t):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),t.on("FetchStandardFontData",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.StandardFontDataFactory?this.StandardFontDataFactory.fetch(t):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}_onUnsupportedFeature({featureId:t}){this.destroyed||this.loadingTask.onUnsupportedFeature?.(t)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request"));const e=t-1,s=this.#s.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((t=>{if(this.destroyed)throw new Error("Transport destroyed");const s=new PDFPageProxy(e,t,this,this._params.ownerDocument,this._params.pdfBug);return this.#e.set(e,s),s}));return this.#s.set(e,i),i}getPageIndex(t){return this.messageHandler.sendWithPromise("GetPageIndex",{ref:t})}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}saveDocument(){return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:this.annotationStorage.serializable,filename:this._fullReader?.filename??null}).finally((()=>{this.annotationStorage.resetModified()}))}getFieldObjects(){return this._getFieldObjectsPromise||=this.messageHandler.sendWithPromise("GetFieldObjects",null)}hasJSActions(){return this._hasJSActionsPromise||=this.messageHandler.sendWithPromise("HasJSActions",null)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then((t=>new _optional_content_config.OptionalContentConfig(t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.#i||=this.messageHandler.sendWithPromise("GetMetadata",null).then((t=>({info:t[0],metadata:t[1]?new _metadata.Metadata(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(await this.messageHandler.sendWithPromise("Cleanup",null),!this.destroyed){for(const t of this.#e.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#i=null,this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null}}get loadingParams(){const t=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:t.disableAutoFetch,enableXfa:t.enableXfa})}}class PDFObjects{constructor(){this._objs=Object.create(null)}_ensureObj(t){return this._objs[t]?this._objs[t]:this._objs[t]={capability:(0,_util.createPromiseCapability)(),data:null,resolved:!1}}get(t,e=null){if(e)return this._ensureObj(t).capability.promise.then(e),null;const s=this._objs[t];if(!s||!s.resolved)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){return this._objs[t]?.resolved||!1}resolve(t,e){const s=this._ensureObj(t);s.resolved=!0,s.data=e,s.capability.resolve(e)}clear(){this._objs=Object.create(null)}}class RenderTask{constructor(t){this._internalRenderTask=t,this.onContinue=null}get promise(){return this._internalRenderTask.capability.promise}cancel(){this._internalRenderTask.cancel()}}exports.RenderTask=RenderTask;class InternalRenderTask{static get canvasInUse(){return(0,_util.shadow)(this,"canvasInUse",new WeakSet)}constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:o,canvasFactory:a,useRequestAnimationFrame:h=!1,pdfBug:c=!1}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=o,this.canvasFactory=a,this._pdfBug=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=(0,_util.createPromiseCapability)(),this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(InternalRenderTask.canvasInUse.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");InternalRenderTask.canvasInUse.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,imageLayer:r,background:o}=this.params;this.gfx=new _canvas.CanvasGraphics(s,this.commonObjs,this.objs,this.canvasFactory,r,e,this.annotationCanvasMap),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback&&this.graphicsReadyCallback()}cancel(t=null){this.running=!1,this.cancelled=!0,this.gfx&&this.gfx.endDrawing(),this._canvas&&InternalRenderTask.canvasInUse.delete(this._canvas),this.callback(t||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,"canvas"))}operatorListChanged(){this.graphicsReady?(this.stepper&&this.stepper.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),this._canvas&&InternalRenderTask.canvasInUse.delete(this._canvas),this.callback())))}}const version="2.12.313";exports.version=version;const build="a2ae56f39";exports.build=build},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FontLoader=e.FontFaceObject=void 0;var i=s(2);class n{constructor({docId:t,onUnsupportedFeature:e,ownerDocument:s=globalThis.document,styleElement:r=null}){this.constructor===n&&(0,i.unreachable)("Cannot initialize BaseFontLoader."),this.docId=t,this._onUnsupportedFeature=e,this._document=s,this.nativeFontFaces=[],this.styleElement=null}addNativeFontFace(t){this.nativeFontFaces.push(t),this._document.fonts.add(t)}insertRule(t){let e=this.styleElement;e||(e=this.styleElement=this._document.createElement("style"),e.id=`PDFJS_FONT_STYLE_TAG_${this.docId}`,this._document.documentElement.getElementsByTagName("head")[0].appendChild(e));const s=e.sheet;s.insertRule(t,s.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.length=0,this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async bind(t){if(t.attached||t.missingFile)return;if(t.attached=!0,this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){throw this._onUnsupportedFeature({featureId:i.UNSUPPORTED_FEATURES.errorFontLoadNative}),(0,i.warn)(`Failed to load font '${e.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent([e],[t],i)}))}}_queueLoadingCallback(t){(0,i.unreachable)("Abstract method `_queueLoadingCallback`.")}get isFontLoadingAPISupported(){return(0,i.shadow)(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){(0,i.unreachable)("Abstract method `isSyncFontLoadingSupported`.")}get _loadTestFont(){(0,i.unreachable)("Abstract method `_loadTestFont`.")}_prepareFontLoadEvent(t,e,s){(0,i.unreachable)("Abstract method `_prepareFontLoadEvent`.")}}let r;e.FontLoader=r,e.FontLoader=r=class extends n{constructor(t){super(t),this.loadingContext={requests:[],nextRequestId:0},this.loadTestFontId=0}get isSyncFontLoadingSupported(){let t=!1;return("undefined"==typeof navigator||/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent)?.[1]>=14)&&(t=!0),(0,i.shadow)(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const e=this.loadingContext,s={id:"pdfjs-font-loading-"+e.nextRequestId++,done:!1,complete:function(){for((0,i.assert)(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.requests.length>0&&e.requests[0].done;){const t=e.requests.shift();setTimeout(t.callback,0)}},callback:t};return e.requests.push(s),s}get _loadTestFont(){return(0,i.shadow)(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e,s){function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function r(t,e,s,i){return t.substring(0,e)+i+t.substring(e+s)}let o,a;const h=this._document.createElement("canvas");h.width=1,h.height=1;const c=h.getContext("2d");let l=0;const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=r(u,976,d.length,d);const f=1482184792;let p=n(u,16);for(o=0,a=d.length-3;o<a;o+=4)p=p-f+n(d,o)|0;o<d.length&&(p=p-f+n(d+"XXX",o)|0),u=r(u,16,4,(0,i.string32)(p));const g=`url(data:font/opentype;base64,${btoa(u)});`;this.insertRule(`@font-face {font-family:"${d}";src:${g}}`);const b=[];for(const t of e)b.push(t.loadedName);b.push(d);const A=this._document.createElement("div");A.style.visibility="hidden",A.style.width=A.style.height="10px",A.style.position="absolute",A.style.top=A.style.left="0px";for(const t of b){const e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,A.appendChild(e)}this._document.body.appendChild(A),function t(e,s){if(l++,l>30)return(0,i.warn)("Load test font never loaded."),void s();c.font="30px "+e,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0?s():setTimeout(t.bind(null,e,s))}(d,(()=>{A.remove(),s.complete()}))}},e.FontFaceObject=class{constructor(t,{isEvalSupported:e=!0,disableFontFace:s=!1,ignoreErrors:i=!1,onUnsupportedFeature:n,fontRegistry:r=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.isEvalSupported=!1!==e,this.disableFontFace=!0===s,this.ignoreErrors=!0===i,this._onUnsupportedFeature=n,this.fontRegistry=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this.fontRegistry&&this.fontRegistry.registerFont(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=(0,i.bytesToString)(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this.fontRegistry&&this.fontRegistry.registerFont(this,e),s}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(t){if(!this.ignoreErrors)throw t;return this._onUnsupportedFeature({featureId:i.UNSUPPORTED_FEATURES.errorFontGetPath}),(0,i.warn)(`getPathGenerator - ignoring character: "${t}".`),this.compiledGlyphs[e]=function(){}}if(this.isEvalSupported&&i.IsEvalSupportedCached.value){const t=[];for(const e of s){const s=void 0!==e.args?e.args.join(","):"";t.push("c.",e.cmd,"(",s,");\n")}return this.compiledGlyphs[e]=new Function("c","size",t.join(""))}return this.compiledGlyphs[e]=function(t,e){for(const i of s)"scale"===i.cmd&&(i.args=[e,-e]),t[i.cmd].apply(t,i.args)}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NodeStandardFontDataFactory=e.NodeCanvasFactory=e.NodeCMapReaderFactory=void 0;var i=s(5),n=s(4),r=s(2);let o=class{constructor(){(0,r.unreachable)("Not implemented: NodeCanvasFactory")}};e.NodeCanvasFactory=o;let a=class{constructor(){(0,r.unreachable)("Not implemented: NodeCMapReaderFactory")}};e.NodeCMapReaderFactory=a;let h=class{constructor(){(0,r.unreachable)("Not implemented: NodeStandardFontDataFactory")}};if(e.NodeStandardFontDataFactory=h,n.isNodeJS){const t=function(t){return new Promise(((e,s)=>{require$$5.readFile(t,((t,i)=>{!t&&i?e(new Uint8Array(i)):s(new Error(t))}))}))};e.NodeCanvasFactory=o=class extends i.BaseCanvasFactory{_createCanvas(t,e){return require$$5.createCanvas(t,e)}},e.NodeCMapReaderFactory=a=class extends i.BaseCMapReaderFactory{_fetchData(e,s){return t(e).then((t=>({cMapData:t,compressionType:s})))}},e.NodeStandardFontDataFactory=h=class extends i.BaseStandardFontDataFactory{_fetchData(e){return t(e)}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AnnotationStorage=void 0;var i=s(2);e.AnnotationStorage=class{constructor(){this._storage=new Map,this._timeStamp=Date.now(),this._modified=!1,this.onSetModified=null,this.onResetModified=null}getValue(t,e){const s=this._storage.get(t);return void 0===s?e:Object.assign(e,s)}setValue(t,e){const s=this._storage.get(t);let i=!1;if(void 0!==s)for(const[t,n]of Object.entries(e))s[t]!==n&&(i=!0,s[t]=n);else i=!0,this._storage.set(t,e);i&&(this._timeStamp=Date.now(),this._setModified())}getAll(){return this._storage.size>0?(0,i.objectFromMap)(this._storage):null}get size(){return this._storage.size}_setModified(){this._modified||(this._modified=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this._modified&&(this._modified=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get serializable(){return this._storage.size>0?this._storage:null}get lastModified(){return this._timeStamp.toString()}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CanvasGraphics=void 0;var i=s(2),n=s(11),r=s(1);const o=4096,a=16;function h(t){if(!t.mozCurrentTransform){t._originalSave=t.save,t._originalRestore=t.restore,t._originalRotate=t.rotate,t._originalScale=t.scale,t._originalTranslate=t.translate,t._originalTransform=t.transform,t._originalSetTransform=t.setTransform,t._originalResetTransform=t.resetTransform,t._transformMatrix=t._transformMatrix||[1,0,0,1,0,0],t._transformStack=[];try{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"lineWidth");t._setLineWidth=e.set,t._getLineWidth=e.get,Object.defineProperty(t,"lineWidth",{set:function(t){this._setLineWidth(1.000001*t)},get:function(){return this._getLineWidth()}})}catch(t){}Object.defineProperty(t,"mozCurrentTransform",{get:function(){return this._transformMatrix}}),Object.defineProperty(t,"mozCurrentTransformInverse",{get:function(){const[t,e,s,i,n,r]=this._transformMatrix,o=t*i-e*s,a=e*s-t*i;return[i/o,e/a,s/a,t/o,(i*n-s*r)/a,(e*n-t*r)/o]}}),t.save=function(){const t=this._transformMatrix;this._transformStack.push(t),this._transformMatrix=t.slice(0,6),this._originalSave()},t.restore=function(){const t=this._transformStack.pop();t&&(this._transformMatrix=t,this._originalRestore())},t.translate=function(t,e){const s=this._transformMatrix;s[4]=s[0]*t+s[2]*e+s[4],s[5]=s[1]*t+s[3]*e+s[5],this._originalTranslate(t,e)},t.scale=function(t,e){const s=this._transformMatrix;s[0]*=t,s[1]*=t,s[2]*=e,s[3]*=e,this._originalScale(t,e)},t.transform=function(e,s,i,n,r,o){const a=this._transformMatrix;this._transformMatrix=[a[0]*e+a[2]*s,a[1]*e+a[3]*s,a[0]*i+a[2]*n,a[1]*i+a[3]*n,a[0]*r+a[2]*o+a[4],a[1]*r+a[3]*o+a[5]],t._originalTransform(e,s,i,n,r,o)},t.setTransform=function(e,s,i,n,r,o){this._transformMatrix=[e,s,i,n,r,o],t._originalSetTransform(e,s,i,n,r,o)},t.resetTransform=function(){this._transformMatrix=[1,0,0,1,0,0],t._originalResetTransform()},t.rotate=function(t){const e=Math.cos(t),s=Math.sin(t),i=this._transformMatrix;this._transformMatrix=[i[0]*e+i[2]*s,i[1]*e+i[3]*s,i[0]*-s+i[2]*e,i[1]*-s+i[3]*e,i[4],i[5]],this._originalRotate(t)}}}class c{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s,i){let n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,s),n.context.setTransform(1,0,0,1,0,0)):(n=this.canvasFactory.create(e,s),this.cache[t]=n),i&&h(n.context),n}clear(){for(const t in this.cache)this.canvasFactory.destroy(this.cache[t]),delete this.cache[t]}}class l{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=i.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=i.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=i.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps=null,this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=i.Util.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateCurvePathMinMax(t,e,s,n,r,o,a,h,c){const l=i.Util.bezierBoundingBox(e,s,n,r,o,a,h,c);this.updatePathMinMax(t,l[0],l[1]),this.updatePathMinMax(t,l[2],l[3])}getPathBoundingBox(t=n.PathType.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===n.PathType.STROKE){e||(0,i.unreachable)("Stroke bounding box must include transform.");const t=i.Util.singularValueDecompose2dScale(e),n=t[0]*this.lineWidth/2,r=t[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=i.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=n.PathType.FILL,e=null){return i.Util.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function d(t,e,s=null){if("undefined"!=typeof ImageData&&e instanceof ImageData)return void t.putImageData(e,0,0);const n=e.height,r=e.width,o=n%a,h=(n-o)/a,c=0===o?h:h+1,l=t.createImageData(r,a);let d,u=0;const f=e.data,p=l.data;let g,b,A,m,w,v,k,x;if(s)switch(s.length){case 1:w=s[0],v=s[0],k=s[0],x=s[0];break;case 4:w=s[0],v=s[1],k=s[2],x=s[3]}if(e.kind===i.ImageKind.GRAYSCALE_1BPP){const e=f.byteLength,s=new Uint32Array(p.buffer,0,p.byteLength>>2),n=s.length,m=r+7>>3;let w=4294967295,v=i.IsLittleEndianCached.value?4278190080:255;for(x&&255===x[0]&&0===x[255]&&([w,v]=[v,w]),g=0;g<c;g++){for(A=g<h?a:o,d=0,b=0;b<A;b++){const t=e-u;let i=0;const n=t>m?r:8*t-7,o=-8&n;let a=0,h=0;for(;i<o;i+=8)h=f[u++],s[d++]=128&h?w:v,s[d++]=64&h?w:v,s[d++]=32&h?w:v,s[d++]=16&h?w:v,s[d++]=8&h?w:v,s[d++]=4&h?w:v,s[d++]=2&h?w:v,s[d++]=1&h?w:v;for(;i<n;i++)0===a&&(h=f[u++],a=128),s[d++]=h&a?w:v,a>>=1}for(;d<n;)s[d++]=0;t.putImageData(l,0,g*a)}}else if(e.kind===i.ImageKind.RGBA_32BPP){const e=!!(w||v||k);for(b=0,m=r*a*4,g=0;g<h;g++){if(p.set(f.subarray(u,u+m)),u+=m,e)for(let t=0;t<m;t+=4)w&&(p[t+0]=w[p[t+0]]),v&&(p[t+1]=v[p[t+1]]),k&&(p[t+2]=k[p[t+2]]);t.putImageData(l,0,b),b+=a}if(g<c){if(m=r*o*4,p.set(f.subarray(u,u+m)),e)for(let t=0;t<m;t+=4)w&&(p[t+0]=w[p[t+0]]),v&&(p[t+1]=v[p[t+1]]),k&&(p[t+2]=k[p[t+2]]);t.putImageData(l,0,b)}}else{if(e.kind!==i.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);{const e=!!(w||v||k);for(A=a,m=r*A,g=0;g<c;g++){for(g>=h&&(A=o,m=r*A),d=0,b=m;b--;)p[d++]=f[u++],p[d++]=f[u++],p[d++]=f[u++],p[d++]=255;if(e)for(let t=0;t<d;t+=4)w&&(p[t+0]=w[p[t+0]]),v&&(p[t+1]=v[p[t+1]]),k&&(p[t+2]=k[p[t+2]]);t.putImageData(l,0,g*a)}}}}function u(t,e){const s=e.height,i=e.width,n=s%a,r=(s-n)/a,o=0===n?r:r+1,h=t.createImageData(i,a);let c=0;const l=e.data,d=h.data;for(let e=0;e<o;e++){const s=e<r?a:n;let o=3;for(let t=0;t<s;t++){let t,e=0;for(let s=0;s<i;s++)e||(t=l[c++],e=128),d[o]=t&e?0:255,o+=4,e>>=1}t.putImageData(h,0,e*a)}}function f(t,e){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"];for(let i=0,n=s.length;i<n;i++){const n=s[i];void 0!==t[n]&&(e[n]=t[n])}void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function p(t){t.strokeStyle="#000000",t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0)}function g(t,e,s,i){const n=t.length;for(let r=3;r<n;r+=4){const n=t[r];if(0===n)t[r-3]=e,t[r-2]=s,t[r-1]=i;else if(n<255){const o=255-n;t[r-3]=t[r-3]*n+e*o>>8,t[r-2]=t[r-2]*n+s*o>>8,t[r-1]=t[r-1]*n+i*o>>8}}}function b(t,e,s){const i=t.length;for(let n=3;n<i;n+=4)e[n]=e[n]*(s?s[t[n]]:t[n])*.00392156862745098|0}function A(t,e,s){const i=t.length;for(let n=3;n<i;n+=4){const i=77*t[n-3]+152*t[n-2]+28*t[n-1];e[n]=s?e[n]*s[i>>8]>>8:e[n]*i>>16}}function m(t,e){const s=i.Util.singularValueDecompose2dScale(t);s[0]=Math.fround(s[0]),s[1]=Math.fround(s[1]);const n=Math.fround((globalThis.devicePixelRatio||1)*r.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==e?e:s[0]<=n||s[1]<=n}const w=["butt","round","square"],v=["miter","round","bevel"],k={},x={};class y{constructor(t,e,s,i,n,r,o){this.ctx=t,this.current=new l(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.imageLayer=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=[],this.optionalContentConfig=r,this.cachedCanvases=new c(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,t&&h(t),this._cachedGetSinglePixelWidth=null}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height;if(this.ctx.save(),this.ctx.fillStyle=i||"rgb(255, 255, 255)",this.ctx.fillRect(0,0,n,r),this.ctx.restore(),s){const t=this.cachedCanvases.getCanvas("transparent",n,r,!0);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform.apply(this.ctx,this.compositeCtx.mozCurrentTransform)}this.ctx.save(),p(this.ctx),t&&(this.ctx.transform.apply(this.ctx,t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform.apply(this.ctx,e.transform),this.viewportScale=e.scale,this.baseTransform=this.ctx.mozCurrentTransform.slice(),this._combinedScaleFactor=Math.hypot(this.baseTransform[0],this.baseTransform[2]),this.imageLayer&&this.imageLayer.beginLayout()}executeOperatorList(t,e,s,n){const r=t.argsArray,o=t.fnArray;let a=e||0;const h=r.length;if(h===a)return a;const c=h-a>10&&"function"==typeof s,l=c?Date.now()+15:0;let d=0;const u=this.commonObjs,f=this.objs;let p;for(;;){if(void 0!==n&&a===n.nextBreakPoint)return n.breakIt(a,s),a;if(p=o[a],p!==i.OPS.dependency)this[p].apply(this,r[a]);else for(const t of r[a]){const e=t.startsWith("g_")?u:f;if(!e.has(t))return e.get(t,s),a}if(a++,a===h)return a;if(c&&++d>10){if(Date.now()>l)return s(),a;d=0}}}endDrawing(){for(;this.stateStack.length||null!==this.current.activeSMask;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this.imageLayer&&this.imageLayer.endLayout()}_scaleImage(t,e){const s=t.width,i=t.height;let n,r,o=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),h=s,c=i,l="prescale1";for(;o>2&&h>1||a>2&&c>1;){let e=h,s=c;o>2&&h>1&&(e=Math.ceil(h/2),o/=h/e),a>2&&c>1&&(s=Math.ceil(c/2),a/=c/s),n=this.cachedCanvases.getCanvas(l,e,s),r=n.context,r.clearRect(0,0,e,s),r.drawImage(t,0,0,h,c,0,0,e,s),t=n.canvas,h=e,c=s,l="prescale1"===l?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,s=t.width,r=t.height,o=this.current.fillColor,a=this.current.patternFill,h=this.cachedCanvases.getCanvas("maskCanvas",s,r);u(h.context,t);let c=i.Util.transform(e.mozCurrentTransform,[1/s,0,0,-1/r,0,0]);c=i.Util.transform(c,[1,0,0,1,0,-r]);const l=i.Util.applyTransform([0,0],c),d=i.Util.applyTransform([s,r],c),f=i.Util.normalizeRect([l[0],l[1],d[0],d[1]]),p=Math.ceil(f[2]-f[0]),g=Math.ceil(f[3]-f[1]),b=this.cachedCanvases.getCanvas("fillCanvas",p,g,!0),A=b.context,w=Math.min(l[0],d[0]),v=Math.min(l[1],d[1]);A.translate(-w,-v),A.transform.apply(A,c);const k=this._scaleImage(h.canvas,A.mozCurrentTransformInverse);A.imageSmoothingEnabled=m(A.mozCurrentTransform,t.interpolate),A.drawImage(k.img,0,0,k.img.width,k.img.height,0,0,s,r),A.globalCompositeOperation="source-in";const x=i.Util.transform(A.mozCurrentTransformInverse,[1,0,0,1,-w,-v]);return A.fillStyle=a?o.getPattern(e,this,x,n.PathType.FILL):o,A.fillRect(0,0,s,r),{canvas:b.canvas,offsetX:Math.round(w),offsetY:Math.round(v)}}setLineWidth(t){this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=w[t]}setLineJoin(t){this.ctx.lineJoin=v[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],i=s[1];switch(s[0]){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=s[1];break;case"ca":this.current.fillAlpha=s[1],this.ctx.globalAlpha=s[1];break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.current.transferMaps=i}}}checkSMaskState(){const t=!!this.suspendedCtx;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.suspendedCtx)throw new Error("beginSMaskMode called while already in smask mode");const t=this.cachedCanvases.getCanvas("smaskGroupAt"+this.groupLevel,this.ctx.canvas.width,this.ctx.canvas.height,!0);this.suspendedCtx=this.ctx,this.ctx=t.context;const e=this.ctx;e.setTransform.apply(e,this.suspendedCtx.mozCurrentTransform),f(this.suspendedCtx,e),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,s){e.translate(t,s),this.__originalTranslate(t,s)},t.scale=function(t,s){e.scale(t,s),this.__originalScale(t,s)},t.transform=function(t,s,i,n,r,o){e.transform(t,s,i,n,r,o),this.__originalTransform(t,s,i,n,r,o)},t.setTransform=function(t,s,i,n,r,o){e.setTransform(t,s,i,n,r,o),this.__originalSetTransform(t,s,i,n,r,o)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},t.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},t.bezierCurveTo=function(t,s,i,n,r,o){e.bezierCurveTo(t,s,i,n,r,o),this.__originalBezierCurveTo(t,s,i,n,r,o)},t.rect=function(t,s,i,n){e.rect(t,s,i,n),this.__originalRect(t,s,i,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(e,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.suspendedCtx)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),f(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.current.activeSMask=null,this.suspendedCtx=null}compose(t){this.current.activeSMask&&(t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height],function(t,e,s,i){const n=i[0],r=i[1],o=i[2]-n,a=i[3]-r;0!==o&&0!==a&&(function(t,e,s,i,n,r,o,a,h,c,l){const d=!!r,u=d?r[0]:0,f=d?r[1]:0,p=d?r[2]:0;let m;m="Luminosity"===n?A:b;const w=Math.min(i,Math.ceil(1048576/s));for(let n=0;n<i;n+=w){const r=Math.min(w,i-n),b=t.getImageData(a-c,n+(h-l),s,r),A=e.getImageData(a,n+h,s,r);d&&g(b.data,u,f,p),m(b.data,A.data,o),e.putImageData(A,a,n+h)}}(e.context,s,o,a,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}(this.suspendedCtx,this.current.activeSMask,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}save(){this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.current.activeSMask&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedGetSinglePixelWidth=null}constructPath(t,e){const s=this.ctx,n=this.current;let r,o,a=n.x,h=n.y;for(let c=0,l=0,d=t.length;c<d;c++)switch(0|t[c]){case i.OPS.rectangle:a=e[l++],h=e[l++];const t=e[l++],c=e[l++],d=a+t,u=h+c;s.moveTo(a,h),0===t||0===c?s.lineTo(d,u):(s.lineTo(d,h),s.lineTo(d,u),s.lineTo(a,u)),n.updatePathMinMax(s.mozCurrentTransform,a,h),n.updatePathMinMax(s.mozCurrentTransform,d,u),s.closePath();break;case i.OPS.moveTo:a=e[l++],h=e[l++],s.moveTo(a,h),n.updatePathMinMax(s.mozCurrentTransform,a,h);break;case i.OPS.lineTo:a=e[l++],h=e[l++],s.lineTo(a,h),n.updatePathMinMax(s.mozCurrentTransform,a,h);break;case i.OPS.curveTo:r=a,o=h,a=e[l+4],h=e[l+5],s.bezierCurveTo(e[l],e[l+1],e[l+2],e[l+3],a,h),n.updateCurvePathMinMax(s.mozCurrentTransform,r,o,e[l],e[l+1],e[l+2],e[l+3],a,h),l+=6;break;case i.OPS.curveTo2:r=a,o=h,s.bezierCurveTo(a,h,e[l],e[l+1],e[l+2],e[l+3]),n.updateCurvePathMinMax(s.mozCurrentTransform,r,o,a,h,e[l],e[l+1],e[l+2],e[l+3]),a=e[l+2],h=e[l+3],l+=4;break;case i.OPS.curveTo3:r=a,o=h,a=e[l+2],h=e[l+3],s.bezierCurveTo(e[l],e[l+1],a,h,a,h),n.updateCurvePathMinMax(s.mozCurrentTransform,r,o,e[l],e[l+1],a,h,a,h),l+=4;break;case i.OPS.closePath:s.closePath()}n.setCurrentPoint(a,h)}closePath(){this.ctx.closePath()}stroke(t){t=void 0===t||t;const e=this.ctx,s=this.current.strokeColor;if(e.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const t=this.getSinglePixelWidth();e.save(),e.strokeStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,n.PathType.STROKE),e.lineWidth=Math.max(t,this.current.lineWidth),e.stroke(),e.restore()}else{const t=this.getSinglePixelWidth();t<0&&-t>=this.current.lineWidth?(e.save(),e.resetTransform(),e.lineWidth=Math.round(this._combinedScaleFactor),e.stroke(),e.restore()):(e.lineWidth=Math.max(t,this.current.lineWidth),e.stroke())}t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t){t=void 0===t||t;const e=this.ctx,s=this.current.fillColor;let i=!1;this.current.patternFill&&(e.save(),e.fillStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,n.PathType.FILL),i=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),i&&e.restore(),t&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=k}eoClip(){this.pendingClip=x}beginText(){this.current.textMatrix=i.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){e.save(),e.beginPath();for(let s=0;s<t.length;s++){const i=t[s];e.setTransform.apply(e,i.transform),e.translate(i.x,i.y),i.addToPath(e,i.fontSize)}e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const s=this.commonObjs.get(t),n=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(n.fontMatrix=s.fontMatrix||i.FONT_IDENTITY_MATRIX,0!==n.fontMatrix[0]&&0!==n.fontMatrix[3]||(0,i.warn)("Invalid font matrix for font "+t),e<0?(e=-e,n.fontDirection=-1):n.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;let r="normal";s.black?r="900":s.bold&&(r="bold");const o=s.italic?"italic":"normal",a=`"${s.loadedName||"sans-serif"}", ${s.fallbackName}`;let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${r} ${h}px ${a}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,n,r){const o=this.ctx,a=this.current,h=a.font,c=a.textRenderingMode,l=a.fontSize/a.fontSizeScale,d=c&i.TextRenderingMode.FILL_STROKE_MASK,u=!!(c&i.TextRenderingMode.ADD_TO_PATH_FLAG),f=a.patternFill&&!h.missingFile;let p;(h.disableFontFace||u||f)&&(p=h.getPathGenerator(this.commonObjs,t)),h.disableFontFace||f?(o.save(),o.translate(e,s),o.beginPath(),p(o,l),n&&o.setTransform.apply(o,n),d!==i.TextRenderingMode.FILL&&d!==i.TextRenderingMode.FILL_STROKE||o.fill(),d!==i.TextRenderingMode.STROKE&&d!==i.TextRenderingMode.FILL_STROKE||(r&&(o.resetTransform(),o.lineWidth=Math.round(this._combinedScaleFactor)),o.stroke()),o.restore()):(d!==i.TextRenderingMode.FILL&&d!==i.TextRenderingMode.FILL_STROKE||o.fillText(t,e,s),d!==i.TextRenderingMode.STROKE&&d!==i.TextRenderingMode.FILL_STROKE||(r?(o.save(),o.moveTo(e,s),o.resetTransform(),o.lineWidth=Math.round(this._combinedScaleFactor),o.strokeText(t,0,0),o.restore()):o.strokeText(t,e,s))),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:o.mozCurrentTransform,x:e,y:s,fontSize:l,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){s=!0;break}return(0,i.shadow)(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const r=e.fontSize;if(0===r)return;const o=this.ctx,a=e.fontSizeScale,h=e.charSpacing,c=e.wordSpacing,l=e.fontDirection,d=e.textHScale*l,u=t.length,f=s.vertical,p=f?1:-1,g=s.defaultVMetrics,b=r*e.fontMatrix[0],A=e.textRenderingMode===i.TextRenderingMode.FILL&&!s.disableFontFace&&!e.patternFill;let m;if(o.save(),o.transform.apply(o,e.textMatrix),o.translate(e.x,e.y+e.textRise),o.scale(d,l>0?-1:1),e.patternFill){o.save();const t=e.fillColor.getPattern(o,this,o.mozCurrentTransformInverse,n.PathType.FILL);m=o.mozCurrentTransform,o.restore(),o.fillStyle=t}let w=e.lineWidth,v=!1;const k=e.textMatrixScale;if(0===k||0===w){const t=e.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;t!==i.TextRenderingMode.STROKE&&t!==i.TextRenderingMode.FILL_STROKE||(this._cachedGetSinglePixelWidth=null,w=this.getSinglePixelWidth(),v=w<0)}else w/=k;1!==a&&(o.scale(a,a),w/=a),o.lineWidth=w;let x,y=0;for(x=0;x<u;++x){const e=t[x];if((0,i.isNum)(e)){y+=p*e*r/1e3;continue}let n=!1;const d=(e.isSpace?c:0)+h,u=e.fontChar,w=e.accent;let k,_,D,M=e.width;if(f){const t=e.vmetric||g,s=-(e.vmetric?t[1]:.5*M)*b;M=t?-t[0]:M,k=s/a,_=(y+t[2]*b)/a}else k=y/a,_=0;if(s.remeasure&&M>0){const t=1e3*o.measureText(u).width/r*a;if(M<t&&this.isFontSubpixelAAEnabled){const e=M/t;n=!0,o.save(),o.scale(e,1),k/=e}else M!==t&&(k+=(M-t)/2e3*r/a)}this.contentVisible&&(e.isInFont||s.missingFile)&&(A&&!w?o.fillText(u,k,_):(this.paintChar(u,k,_,m,v),w&&this.paintChar(w.fontChar,k+r*w.offset.x/a,_-r*w.offset.y/a,m,v))),D=f?M*b-d*l:M*b+d*l,y+=D,n&&o.restore()}f?e.y-=y:e.x+=y*d,o.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,n=s.font,r=s.fontSize,o=s.fontDirection,a=n.vertical?1:-1,h=s.charSpacing,c=s.wordSpacing,l=s.textHScale*o,d=s.fontMatrix||i.FONT_IDENTITY_MATRIX,u=t.length;let f,p,g,b;if(s.textRenderingMode!==i.TextRenderingMode.INVISIBLE&&0!==r){for(this._cachedGetSinglePixelWidth=null,e.save(),e.transform.apply(e,s.textMatrix),e.translate(s.x,s.y),e.scale(l,o),f=0;f<u;++f){if(p=t[f],(0,i.isNum)(p)){b=a*p*r/1e3,this.ctx.translate(b,0),s.x+=b*l;continue}const o=(p.isSpace?c:0)+h,u=n.charProcOperatorList[p.operatorListId];u?(this.contentVisible&&(this.processingType3=p,this.save(),e.scale(r,r),e.transform.apply(e,d),this.executeOperatorList(u),this.restore()),g=i.Util.applyTransform([p.width,0],d)[0]*r+o,e.translate(g,0),s.x+=g*l):(0,i.warn)(`Type3 character "${p.operatorListId}" is not available.`)}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const s=t[1],i=this.baseTransform||this.ctx.mozCurrentTransform.slice();e=new n.TilingPattern(t,s,this.ctx,{createCanvasGraphics:t=>new y(t,this.commonObjs,this.objs,this.canvasFactory)},i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const n=i.Util.makeHexColor(t,e,s);this.ctx.strokeStyle=n,this.current.strokeColor=n}setFillRGBColor(t,e,s){const n=i.Util.makeHexColor(t,e,s);this.ctx.fillStyle=n,this.current.fillColor=n,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=(0,n.getShadingPattern)(this.objs.get(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,n.PathType.SHADING);const r=e.mozCurrentTransformInverse;if(r){const t=e.canvas,s=t.width,n=t.height,o=i.Util.applyTransform([0,0],r),a=i.Util.applyTransform([0,n],r),h=i.Util.applyTransform([s,0],r),c=i.Util.applyTransform([s,n],r),l=Math.min(o[0],a[0],h[0],c[0]),d=Math.min(o[1],a[1],h[1],c[1]),u=Math.max(o[0],a[0],h[0],c[0]),f=Math.max(o[1],a[1],h[1],c[1]);this.ctx.fillRect(l,d,u-l,f-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,i.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,i.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(t,e){this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(t)&&6===t.length&&this.transform.apply(this,t),this.baseTransform=this.ctx.mozCurrentTransform,e)&&(this.ctx.rect(e[0],e[1],e[2]-e[0],e[3]-e[1]),this.current.updatePathMinMax(this.ctx.mozCurrentTransform,e[0],e[1]),this.current.updatePathMinMax(this.ctx.mozCurrentTransform,e[2],e[3]),this.clip(),this.endPath())}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save();const e=this.suspendedCtx;this.current.activeSMask&&(this.suspendedCtx=null,this.current.activeSMask=null);const s=this.ctx;t.isolated||(0,i.info)("TODO: Support non-isolated groups."),t.knockout&&(0,i.warn)("Knockout groups not supported.");const n=s.mozCurrentTransform;if(t.matrix&&s.transform.apply(s,t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=i.Util.getAxialAlignedBoundingBox(t.bbox,s.mozCurrentTransform);r=i.Util.intersect(r,[0,0,s.canvas.width,s.canvas.height])||[0,0,0,0];const a=Math.floor(r[0]),h=Math.floor(r[1]);let c=Math.max(Math.ceil(r[2])-a,1),l=Math.max(Math.ceil(r[3])-h,1),d=1,u=1;c>o&&(d=c/o,c=o),l>o&&(u=l/o,l=o),this.current.startNewPathAndClipBox([0,0,c,l]);let p="groupAt"+this.groupLevel;t.smask&&(p+="_smask_"+this.smaskCounter++%2);const g=this.cachedCanvases.getCanvas(p,c,l,!0),b=g.context;b.scale(1/d,1/u),b.translate(-a,-h),b.transform.apply(b,n),t.smask?this.smaskStack.push({canvas:g.canvas,context:b,offsetX:a,offsetY:h,scaleX:d,scaleY:u,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(s.setTransform(1,0,0,1,0,0),s.translate(a,h),s.scale(d,u),s.save()),f(s,b),this.ctx=b,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push({ctx:s,suspendedCtx:e}),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,{ctx:s,suspendedCtx:n}=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,n&&(this.suspendedCtx=n),t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=this.ctx.mozCurrentTransform;this.restore(),this.ctx.save(),this.ctx.setTransform.apply(this.ctx,t);const s=i.Util.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotations(){this.save(),this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)}endAnnotations(){this.restore()}beginAnnotation(t,e,s,n,r){if(this.save(),Array.isArray(e)&&4===e.length){const n=e[2]-e[0],o=e[3]-e[1];if(r&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=n,e[3]=o;const[r,a]=i.Util.singularValueDecompose2dScale(this.ctx.mozCurrentTransform),{viewportScale:c}=this,l=Math.ceil(n*this.outputScaleX*c),d=Math.ceil(o*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(l,d);const{canvas:u,context:f}=this.annotationCanvas;u.style.width=`calc(${n}px * var(--viewport-scale-factor))`,u.style.height=`calc(${o}px * var(--viewport-scale-factor))`,this.annotationCanvasMap.set(t,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.setTransform(r,0,0,-a,0,o*a),h(this.ctx),p(this.ctx)}else p(this.ctx),this.ctx.rect(e[0],e[1],n,o),this.clip(),this.endPath()}this.current=new l(this.ctx.canvas.width,this.ctx.canvas.height),this.transform.apply(this,s),this.transform.apply(this,n)}endAnnotation(){this.annotationCanvas&&(this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.restore()}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=this.ctx,s=t.width,i=t.height,n=this.processingType3;if(n&&void 0===n.compiled&&(n.compiled=s<=1e3&&i<=1e3?function(t){const e=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),s=t.width,i=t.height,n=s+1;let r,o,a,h;const c=new Uint8Array(n*(i+1)),l=s+7&-8,d=t.data,u=new Uint8Array(l*i);let f=0;for(r=0,o=d.length;r<o;r++){const t=d[r];let e=128;for(;e>0;)u[f++]=t&e?0:255,e>>=1}let p=0;for(f=0,0!==u[f]&&(c[0]=1,++p),a=1;a<s;a++)u[f]!==u[f+1]&&(c[a]=u[f]?2:1,++p),f++;for(0!==u[f]&&(c[a]=2,++p),r=1;r<i;r++){f=r*l,h=r*n,u[f-l]!==u[f]&&(c[h]=u[f]?1:8,++p);let t=(u[f]?4:0)+(u[f-l]?8:0);for(a=1;a<s;a++)t=(t>>2)+(u[f+1]?4:0)+(u[f-l+1]?8:0),e[t]&&(c[h+a]=e[t],++p),f++;if(u[f-l]!==u[f]&&(c[h+a]=u[f]?2:4,++p),p>1e3)return null}for(f=l*(i-1),h=r*n,0!==u[f]&&(c[h]=8,++p),a=1;a<s;a++)u[f]!==u[f+1]&&(c[h+a]=u[f]?4:8,++p),f++;if(0!==u[f]&&(c[h+a]=4,++p),p>1e3)return null;const g=new Int32Array([0,n,-1,0,-n,0,0,0,1]),b=[];for(r=0;p&&r<=i;r++){let t=r*n;const e=t+s;for(;t<e&&!c[t];)t++;if(t===e)continue;const i=[t%n,r],o=t;let a=c[t];do{const e=g[a];do{t+=e}while(!c[t]);const s=c[t];5!==s&&10!==s?(a=s,c[t]=0):(a=s&51*a>>4,c[t]&=a>>2|a<<2),i.push(t%n,t/n|0),c[t]||--p}while(o!==t);b.push(i),--r}return function(t){t.save(),t.scale(1/s,-1/i),t.translate(0,-i),t.beginPath();for(let e=0,s=b.length;e<s;e++){const s=b[e];t.moveTo(s[0],s[1]);for(let e=2,i=s.length;e<i;e+=2)t.lineTo(s[e],s[e+1])}t.fill(),t.beginPath(),t.restore()}}({data:t.data,width:s,height:i}):null),n?.compiled)return void n.compiled(e);const r=this._createMaskCanvas(t),o=r.canvas;e.save(),e.setTransform(1,0,0,1,0,0),e.drawImage(o,r.offsetX,r.offsetY),e.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,n=0,r,o){if(!this.contentVisible)return;const a=this.ctx;a.save();const h=a.mozCurrentTransform;a.transform(e,s,n,r,0,0);const c=this._createMaskCanvas(t);a.setTransform(1,0,0,1,0,0);for(let t=0,l=o.length;t<l;t+=2){const l=i.Util.transform(h,[e,s,n,r,o[t],o[t+1]]),[d,u]=i.Util.applyTransform([0,0],l);a.drawImage(c.canvas,d,u)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(let r=0,o=t.length;r<o;r++){const o=t[r],a=o.width,h=o.height,c=this.cachedCanvases.getCanvas("maskCanvas",a,h),l=c.context;l.save(),u(l,o),l.globalCompositeOperation="source-in",l.fillStyle=i?s.getPattern(l,this,e.mozCurrentTransformInverse,n.PathType.FILL):s,l.fillRect(0,0,a,h),l.restore(),e.save(),e.transform.apply(e,o.transform),e.scale(1,-1),e.drawImage(c.canvas,0,0,a,h,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);e?this.paintInlineImageXObject(e):(0,i.warn)("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,n){if(!this.contentVisible)return;const r=t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);if(!r)return void(0,i.warn)("Dependent image isn't ready yet");const o=r.width,a=r.height,h=[];for(let t=0,i=n.length;t<i;t+=2)h.push({transform:[e,0,0,s,n[t],n[t+1]],x:0,y:0,w:o,h:a});this.paintInlineImageXObjectGroup(r,h)}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;let n;if(this.save(),i.scale(1/e,-1/s),"function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const i=this.cachedCanvases.getCanvas("inlineImage",e,s);d(i.context,t,this.current.transferMaps),n=i.canvas}const r=this._scaleImage(n,i.mozCurrentTransformInverse);if(i.imageSmoothingEnabled=m(i.mozCurrentTransform,t.interpolate),i.drawImage(r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.imageLayer){const n=this.getCanvasPosition(0,-s);this.imageLayer.appendImage({imgData:t,left:n[0],top:n[1],width:e/i.mozCurrentTransformInverse[0],height:s/i.mozCurrentTransformInverse[3]})}this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx,i=t.width,n=t.height,r=this.cachedCanvases.getCanvas("inlineImage",i,n);d(r.context,t,this.current.transferMaps);for(let o=0,a=e.length;o<a;o++){const a=e[o];if(s.save(),s.transform.apply(s,a.transform),s.scale(1,-1),s.drawImage(r.canvas,a.x,a.y,a.w,a.h,0,-1,1,1),this.imageLayer){const e=this.getCanvasPosition(a.x,a.y);this.imageLayer.appendImage({imgData:t,left:e[0],top:e[1],width:i,height:n})}s.restore()}this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){this.markedContentStack.push("OC"===t?{visible:this.optionalContentConfig.isVisible(e)}:{visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const e=this.ctx;this.pendingClip&&(this.pendingClip===x?e.clip("evenodd"):e.clip(),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),e.beginPath()}getSinglePixelWidth(){if(null===this._cachedGetSinglePixelWidth){const t=this.ctx.mozCurrentTransform,e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=t[0]**2+t[2]**2,i=t[1]**2+t[3]**2,n=Math.sqrt(Math.max(s,i))/e;this._cachedGetSinglePixelWidth=s!==i&&this._combinedScaleFactor*n>1?-this._combinedScaleFactor*n:e>Number.EPSILON?n:1}return this._cachedGetSinglePixelWidth}getCanvasPosition(t,e){const s=this.ctx.mozCurrentTransform;return[s[0]*t+s[2]*e+s[4],s[1]*t+s[3]*e+s[5]]}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}e.CanvasGraphics=y;for(const t in i.OPS)void 0!==y.prototype[t]&&(y.prototype[i.OPS[t]]=y.prototype[t])},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TilingPattern=e.PathType=void 0,e.getShadingPattern=function(t){switch(t[0]){case"RadialAxial":return new a(t);case"Mesh":return new l(t);case"Dummy":return new d}throw new Error(`Unknown IR type: ${t[0]}`)};var i=s(2);const n={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function r(t,e){if(!e||"undefined"==typeof Path2D)return;const s=e[2]-e[0],i=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],s,i),t.clip(n)}e.PathType=n;class o{constructor(){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class a extends o{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,s,o){let a;if(o===n.STROKE||o===n.FILL){const n=e.current.getClippedPathBoundingBox(o,t.mozCurrentTransform)||[0,0,0,0],h=Math.ceil(n[2]-n[0])||1,c=Math.ceil(n[3]-n[1])||1,l=e.cachedCanvases.getCanvas("pattern",h,c,!0),d=l.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-n[0],-n[1]),s=i.Util.transform(s,[1,0,0,1,n[0],n[1]]),d.transform.apply(d,e.baseTransform),this.matrix&&d.transform.apply(d,this.matrix),r(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),a=t.createPattern(l.canvas,"no-repeat");const u=new DOMMatrix(s);try{a.setTransform(u)}catch(t){(0,i.warn)(`RadialAxialShadingPattern.getPattern: "${t?.message}".`)}}else r(t,this._bbox),a=this._createGradient(t);return a}}function h(t,e,s,i,n,r,o,a){const h=e.coords,c=e.colors,l=t.data,d=4*t.width;let u;h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=r,r=o,o=u),h[i+1]>h[n+1]&&(u=i,i=n,n=u,u=o,o=a,a=u),h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=r,r=o,o=u);const f=(h[s]+e.offsetX)*e.scaleX,p=(h[s+1]+e.offsetY)*e.scaleY,g=(h[i]+e.offsetX)*e.scaleX,b=(h[i+1]+e.offsetY)*e.scaleY,A=(h[n]+e.offsetX)*e.scaleX,m=(h[n+1]+e.offsetY)*e.scaleY;if(p>=m)return;const w=c[r],v=c[r+1],k=c[r+2],x=c[o],y=c[o+1],_=c[o+2],D=c[a],M=c[a+1],E=c[a+2],F=Math.round(p),C=Math.round(m);let P,S,O,T,R,I,L,N;for(let t=F;t<=C;t++){if(t<b){let e;e=t<p?0:(p-t)/(p-b),P=f-(f-g)*e,S=w-(w-x)*e,O=v-(v-y)*e,T=k-(k-_)*e}else{let e;e=t>m?1:b===m?0:(b-t)/(b-m),P=g-(g-A)*e,S=x-(x-D)*e,O=y-(y-M)*e,T=_-(_-E)*e}let e;e=t<p?0:t>m?1:(p-t)/(p-m),R=f-(f-A)*e,I=w-(w-D)*e,L=v-(v-M)*e,N=k-(k-E)*e;const s=Math.round(Math.min(P,R)),i=Math.round(Math.max(P,R));let n=d*t+4*s;for(let t=s;t<=i;t++)e=(P-t)/(P-R),e<0?e=0:e>1&&(e=1),l[n++]=S-(S-I)*e|0,l[n++]=O-(O-L)*e|0,l[n++]=T-(T-N)*e|0,l[n++]=255}}function c(t,e,s){const i=e.coords,n=e.colors;let r,o;switch(e.type){case"lattice":const a=e.verticesPerRow,c=Math.floor(i.length/a)-1,l=a-1;for(r=0;r<c;r++){let e=r*a;for(let r=0;r<l;r++,e++)h(t,s,i[e],i[e+1],i[e+a],n[e],n[e+1],n[e+a]),h(t,s,i[e+a+1],i[e+1],i[e+a],n[e+a+1],n[e+1],n[e+a])}break;case"triangles":for(r=0,o=i.length;r<o;r+=3)h(t,s,i[r],i[r+1],i[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class l extends o{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-i,o=Math.ceil(this._bounds[3])-n,a=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),h=Math.min(Math.ceil(Math.abs(o*t[1]*1.1)),3e3),l=r/a,d=o/h,u={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-n,scaleX:1/l,scaleY:1/d},f=s.getCanvas("mesh",a+4,h+4,!1),p=f.context,g=p.createImageData(a,h);if(e){const t=g.data;for(let s=0,i=t.length;s<i;s+=4)t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=255}for(const t of this._figures)c(g,t,u);return p.putImageData(g,2,2),{canvas:f.canvas,offsetX:i-2*l,offsetY:n-2*d,scaleX:l,scaleY:d}}getPattern(t,e,s,o){let a;if(r(t,this._bbox),o===n.SHADING)a=i.Util.singularValueDecompose2dScale(t.mozCurrentTransform);else if(a=i.Util.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=i.Util.singularValueDecompose2dScale(this.matrix);a=[a[0]*t[0],a[1]*t[1]]}const h=this._createMeshCanvas(a,o===n.SHADING?null:this._background,e.cachedCanvases);return o!==n.SHADING&&(t.setTransform.apply(t,e.baseTransform),this.matrix&&t.transform.apply(t,this.matrix)),t.translate(h.offsetX,h.offsetY),t.scale(h.scaleX,h.scaleY),t.createPattern(h.canvas,"no-repeat")}}class d extends o{getPattern(){return"hotpink"}}class u{static get MAX_PATTERN_SIZE(){return(0,i.shadow)(this,"MAX_PATTERN_SIZE",3e3)}constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3]||[1,0,0,1,0,0],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,n=this.xstep,r=this.ystep,o=this.paintType,a=this.color,h=this.canvasGraphicsFactory;(0,i.info)("TilingType: "+this.tilingType);const c=s[0],l=s[1],d=s[2],u=s[3],f=i.Util.singularValueDecompose2dScale(this.matrix),p=i.Util.singularValueDecompose2dScale(this.baseTransform),g=[f[0]*p[0],f[1]*p[1]],b=this.getSizeAndScale(n,this.ctx.canvas.width,g[0]),A=this.getSizeAndScale(r,this.ctx.canvas.height,g[1]),m=t.cachedCanvases.getCanvas("pattern",b.size,A.size,!0),w=m.context,v=h.createCanvasGraphics(w);v.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(v,o,a);let k=c,x=l,y=d,_=u;return c<0&&(k=0,y+=Math.abs(c)),l<0&&(x=0,_+=Math.abs(l)),w.translate(-b.scale*k,-A.scale*x),v.transform(b.scale,0,0,A.scale,0,0),this.clipBbox(v,k,x,y,_),v.baseTransform=v.ctx.mozCurrentTransform.slice(),v.executeOperatorList(e),v.endDrawing(),{canvas:m.canvas,scaleX:b.scale,scaleY:A.scale,offsetX:k,offsetY:x}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(u.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){t.ctx.rect(e,s,i-e,n-s),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,r=t.current;switch(e){case 1:const t=this.ctx;n.fillStyle=t.fillStyle,n.strokeStyle=t.strokeStyle,r.fillColor=t.fillStyle,r.strokeColor=t.strokeStyle;break;case 2:const o=i.Util.makeHexColor(s[0],s[1],s[2]);n.fillStyle=o,n.strokeStyle=o,r.fillColor=o,r.strokeColor=o;break;default:throw new i.FormatError(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,r){let o=s;r!==n.SHADING&&(o=i.Util.transform(o,e.baseTransform),this.matrix&&(o=i.Util.transform(o,this.matrix)));const a=this.createPatternCanvas(e);let h=new DOMMatrix(o);h=h.translate(a.offsetX,a.offsetY),h=h.scale(1/a.scaleX,1/a.scaleY);const c=t.createPattern(a.canvas,"repeat");try{c.setTransform(h)}catch(t){(0,i.warn)(`TilingPattern.getPattern: "${t?.message}".`)}return c}}e.TilingPattern=u},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalWorkerOptions=void 0;const s=Object.create(null);e.GlobalWorkerOptions=s,s.workerPort=void 0===s.workerPort?null:s.workerPort,s.workerSrc=void 0===s.workerSrc?"":s.workerSrc},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageHandler=void 0;var i=s(2);function n(t){if(!(t instanceof Error||"object"==typeof t&&null!==t))return(0,i.warn)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t;switch(t.name){case"AbortException":return new i.AbortException(t.message);case"MissingPDFException":return new i.MissingPDFException(t.message);case"PasswordException":return new i.PasswordException(t.message,t.code);case"UnexpectedResponseException":return new i.UnexpectedResponseException(t.message,t.status);case"UnknownErrorException":return new i.UnknownErrorException(t.message,t.details);default:return new i.UnknownErrorException(t.message,t.toString())}}e.MessageHandler=class{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=t=>{const e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream)return void this._processStreamMessage(e);if(e.callback){const t=e.callbackId,s=this.callbackCapabilities[t];if(!s)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)s.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");s.reject(n(e.reason))}return}const i=this.actionHandler[e.action];if(!i)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,r=e.sourceName;new Promise((function(t){t(i(e.data))})).then((function(i){s.postMessage({sourceName:t,targetName:r,callback:1,callbackId:e.callbackId,data:i})}),(function(i){s.postMessage({sourceName:t,targetName:r,callback:2,callbackId:e.callbackId,reason:n(i)})}))}else e.streamId?this._createStreamSink(e):i(e.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const n=this.callbackId++,r=(0,i.createPromiseCapability)();this.callbackCapabilities[n]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},s)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,s,r){const o=this.streamId++,a=this.sourceName,h=this.targetName,c=this.comObj;return new ReadableStream({start:s=>{const n=(0,i.createPromiseCapability)();return this.streamControllers[o]={controller:s,startCall:n,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:a,targetName:h,action:t,streamId:o,data:e,desiredSize:s.desiredSize},r),n.promise},pull:t=>{const e=(0,i.createPromiseCapability)();return this.streamControllers[o].pullCall=e,c.postMessage({sourceName:a,targetName:h,stream:6,streamId:o,desiredSize:t.desiredSize}),e.promise},cancel:t=>{(0,i.assert)(t instanceof Error,"cancel must have a valid reason");const e=(0,i.createPromiseCapability)();return this.streamControllers[o].cancelCall=e,this.streamControllers[o].isClosed=!0,c.postMessage({sourceName:a,targetName:h,stream:1,streamId:o,reason:n(t)}),e.promise}},s)}_createStreamSink(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,o=this.comObj,a=this,h=this.actionHandler[t.action],c={enqueue(t,n=1,a){if(this.isCancelled)return;const h=this.desiredSize;this.desiredSize-=n,h>0&&this.desiredSize<=0&&(this.sinkCapability=(0,i.createPromiseCapability)(),this.ready=this.sinkCapability.promise),o.postMessage({sourceName:s,targetName:r,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:s,targetName:r,stream:3,streamId:e}),delete a.streamSinks[e])},error(t){(0,i.assert)(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:s,targetName:r,stream:5,streamId:e,reason:n(t)}))},sinkCapability:(0,i.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[e]=c,new Promise((function(e){e(h(t.data,c))})).then((function(){o.postMessage({sourceName:s,targetName:r,stream:8,streamId:e,success:!0})}),(function(t){o.postMessage({sourceName:s,targetName:r,stream:8,streamId:e,reason:n(t)})}))}_processStreamMessage(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,o=this.comObj,a=this.streamControllers[e],h=this.streamSinks[e];switch(t.stream){case 8:t.success?a.startCall.resolve():a.startCall.reject(n(t.reason));break;case 7:t.success?a.pullCall.resolve():a.pullCall.reject(n(t.reason));break;case 6:if(!h){o.postMessage({sourceName:s,targetName:r,stream:7,streamId:e,success:!0});break}h.desiredSize<=0&&t.desiredSize>0&&h.sinkCapability.resolve(),h.desiredSize=t.desiredSize,new Promise((function(t){t(h.onPull&&h.onPull())})).then((function(){o.postMessage({sourceName:s,targetName:r,stream:7,streamId:e,success:!0})}),(function(t){o.postMessage({sourceName:s,targetName:r,stream:7,streamId:e,reason:n(t)})}));break;case 4:if((0,i.assert)(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case 3:if((0,i.assert)(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this._deleteStreamController(a,e);break;case 5:(0,i.assert)(a,"error should have stream controller"),a.controller.error(n(t.reason)),this._deleteStreamController(a,e);break;case 2:t.success?a.cancelCall.resolve():a.cancelCall.reject(n(t.reason)),this._deleteStreamController(a,e);break;case 1:if(!h)break;new Promise((function(e){e(h.onCancel&&h.onCancel(n(t.reason)))})).then((function(){o.postMessage({sourceName:s,targetName:r,stream:2,streamId:e,success:!0})}),(function(t){o.postMessage({sourceName:s,targetName:r,stream:2,streamId:e,reason:n(t)})})),h.sinkCapability.reject(n(t.reason)),h.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(t,e){await Promise.allSettled([t.startCall&&t.startCall.promise,t.pullCall&&t.pullCall.promise,t.cancelCall&&t.cancelCall.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Metadata=void 0;var i=s(2);e.Metadata=class{#n;#r;constructor({parsedData:t,rawData:e}){this.#n=t,this.#r=e}getRaw(){return this.#r}get(t){return this.#n.get(t)??null}getAll(){return(0,i.objectFromMap)(this.#n)}has(t){return this.#n.has(t)}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OptionalContentConfig=void 0;var i=s(2);class n{constructor(t,e){this.visible=!0,this.name=t,this.intent=e}}e.OptionalContentConfig=class{constructor(t){if(this.name=null,this.creator=null,this._order=null,this._groups=new Map,null!==t){this.name=t.name,this.creator=t.creator,this._order=t.order;for(const e of t.groups)this._groups.set(e.id,new n(e.name,e.intent));if("OFF"===t.baseState)for(const t of this._groups)t.visible=!1;for(const e of t.on)this._groups.get(e).visible=!0;for(const e of t.off)this._groups.get(e).visible=!1}}_evaluateVisibilityExpression(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let n=1;n<e;n++){const e=t[n];let r;if(Array.isArray(e))r=this._evaluateVisibilityExpression(e);else{if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;r=this._groups.get(e).visible}switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return"And"===s}isVisible(t){if(0===this._groups.size)return!0;if(!t)return(0,i.warn)("Optional content group not defined."),!0;if("OCG"===t.type)return this._groups.has(t.id)?this._groups.get(t.id).visible:((0,i.warn)(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this._evaluateVisibilityExpression(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(this._groups.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(!this._groups.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(!this._groups.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(this._groups.get(e).visible)return!1}return!0}return(0,i.warn)(`Unknown optional content policy ${t.policy}.`),!0}return(0,i.warn)(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){this._groups.has(t)?this._groups.get(t).visible=!!e:(0,i.warn)(`Optional content group not found: ${t}`)}getOrder(){return this._groups.size?this._order?this._order.slice():Array.from(this._groups.keys()):null}getGroups(){return this._groups.size>0?(0,i.objectFromMap)(this._groups):null}getGroup(t){return this._groups.get(t)||null}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFDataTransportStream=void 0;var i=s(2),n=s(1);e.PDFDataTransportStream=class{constructor(t,e){(0,i.assert)(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=t.progressiveDone||!1,this._contentDispositionFilename=t.contentDispositionFilename||null;const s=t.initialData;if(s?.length>0){const t=new Uint8Array(s).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._contentLength=t.length,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),this._pdfDataRangeTransport.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),this._pdfDataRangeTransport.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),this._pdfDataRangeTransport.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),this._pdfDataRangeTransport.transportReady()}_onReceiveData(t){const e=new Uint8Array(t.chunk).buffer;if(void 0===t.begin)this._fullRequestReader?this._fullRequestReader._enqueue(e):this._queuedChunks.push(e);else{const s=this._rangeReaders.some((function(s){return s._begin===t.begin&&(s._enqueue(e),!0)}));(0,i.assert)(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){if(void 0===t.total){const e=this._rangeReaders[0];e?.onProgress&&e.onProgress({loaded:t.loaded})}else{const e=this._fullRequestReader;e?.onProgress&&e.onProgress({loaded:t.loaded,total:t.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new r(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new o(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}};class r{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=(0,n.isPdfFile)(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class o{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.XfaText=void 0;class s{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let n=null;const r=i.name;if("#text"===r)n=i.value;else{if(!s.shouldBuildText(r))return;i?.attributes?.textContent?n=i.attributes.textContent:i.value&&(n=i.value)}if(null!==n&&e.push({str:n}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}e.XfaText=s},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AnnotationLayer=void 0;var i=s(2),n=s(1),r=s(9),o=s(19),a=s(20);const h=1e3,c=new WeakSet;class l{static create(t){switch(t.data.annotationType){case i.AnnotationType.LINK:return new u(t);case i.AnnotationType.TEXT:return new f(t);case i.AnnotationType.WIDGET:switch(t.data.fieldType){case"Tx":return new g(t);case"Btn":return t.data.radioButton?new A(t):t.data.checkBox?new b(t):new m(t);case"Ch":return new w(t)}return new p(t);case i.AnnotationType.POPUP:return new v(t);case i.AnnotationType.FREETEXT:return new x(t);case i.AnnotationType.LINE:return new y(t);case i.AnnotationType.SQUARE:return new _(t);case i.AnnotationType.CIRCLE:return new D(t);case i.AnnotationType.POLYLINE:return new M(t);case i.AnnotationType.CARET:return new F(t);case i.AnnotationType.INK:return new C(t);case i.AnnotationType.POLYGON:return new E(t);case i.AnnotationType.HIGHLIGHT:return new P(t);case i.AnnotationType.UNDERLINE:return new S(t);case i.AnnotationType.SQUIGGLY:return new O(t);case i.AnnotationType.STRIKEOUT:return new T(t);case i.AnnotationType.STAMP:return new R(t);case i.AnnotationType.FILEATTACHMENT:return new I(t);default:return new d(t)}}}class d{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.page=t.page,this.viewport=t.viewport,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this._mouseState=t.mouseState,e&&(this.container=this._createContainer(s)),i&&(this.quadrilaterals=this._createQuadrilaterals(s))}_createContainer(t=!1){const e=this.data,s=this.page,n=this.viewport,r=document.createElement("section");let o=e.rect[2]-e.rect[0],a=e.rect[3]-e.rect[1];r.setAttribute("data-annotation-id",e.id);const h=i.Util.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]);if(e.hasOwnCanvas){const t=n.transform.slice(),[e,s]=i.Util.singularValueDecompose2dScale(t);o=Math.ceil(o*e),a=Math.ceil(a*s),h[0]*=e,h[1]*=s;for(let e=0;e<4;e++)t[e]=Math.sign(t[e]);r.style.transform=`matrix(${t.join(",")})`}else r.style.transform=`matrix(${n.transform.join(",")})`;if(r.style.transformOrigin=`${-h[0]}px ${-h[1]}px`,!t&&e.borderStyle.width>0){r.style.borderWidth=`${e.borderStyle.width}px`,e.borderStyle.style!==i.AnnotationBorderStyleType.UNDERLINE&&(o-=2*e.borderStyle.width,a-=2*e.borderStyle.width);const t=e.borderStyle.horizontalCornerRadius,s=e.borderStyle.verticalCornerRadius;switch((t>0||s>0)&&(r.style.borderRadius=`${t}px / ${s}px`),e.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:r.style.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:r.style.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:r.style.borderBottomStyle="solid"}e.borderColor||e.color?r.style.borderColor=i.Util.makeHexColor(0|e.color[0],0|e.color[1],0|e.color[2]):r.style.borderWidth=0}return r.style.left=`${h[0]}px`,r.style.top=`${h[1]}px`,e.hasOwnCanvas?r.style.width=r.style.height="auto":(r.style.width=`${o}px`,r.style.height=`${a}px`),r}_createQuadrilaterals(t=!1){if(!this.data.quadPoints)return null;const e=[],s=this.data.rect;for(const s of this.data.quadPoints)this.data.rect=[s[2].x,s[2].y,s[1].x,s[1].y],e.push(this._createContainer(t));return this.data.rect=s,e}_createPopup(t,e){let s=this.container;this.quadrilaterals&&(t=t||this.quadrilaterals,s=this.quadrilaterals[0]),t||((t=document.createElement("div")).style.height=s.style.height,t.style.width=s.style.width,s.appendChild(t));const i=new k({container:s,trigger:t,color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,hideWrapper:!0}).render();i.style.left=s.style.width,s.appendChild(i)}_renderQuadrilaterals(t){for(const e of this.quadrilaterals)e.className=t;return this.quadrilaterals}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:t,id:r,exportValues:o}of n){if(-1===t)continue;if(r===e)continue;const n="string"==typeof o?o:null,a=document.getElementById(r);!a||c.has(a)?s.push({id:r,exportValue:n,domElement:a}):(0,i.warn)(`_getElementsByName - element not allowed: ${r}`)}return s}for(const i of document.getElementsByName(t)){const{id:t,exportValue:n}=i;t!==e&&c.has(i)&&s.push({id:t,exportValue:n,domElement:i})}return s}static get platform(){const t="undefined"!=typeof navigator?navigator.platform:"";return(0,i.shadow)(this,"platform",{isWin:t.includes("Win"),isMac:t.includes("Mac")})}}class u extends d{constructor(t,e=null){super(t,{isRenderable:!!(t.data.url||t.data.dest||t.data.action||t.data.isTooltipOnly||t.data.resetForm||t.data.actions&&(t.data.actions.Action||t.data.actions["Mouse Up"]||t.data.actions["Mouse Down"])),ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0})}render(){const{data:t,linkService:e}=this,s=document.createElement("a");if(t.url)e.addLinkAttributes||(0,i.warn)("LinkAnnotationElement.render - missing `addLinkAttributes`-method on the `linkService`-instance."),e.addLinkAttributes?.(s,t.url,t.newWindow);else if(t.action)this._bindNamedAction(s,t.action);else if(t.dest)this._bindLink(s,t.dest);else{let e=!1;t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(e=!0,this._bindJSAction(s,t)),t.resetForm?this._bindResetFormAction(s,t.resetForm):e||this._bindLink(s,"")}return this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map(((t,e)=>{const i=0===e?s:s.cloneNode();return t.appendChild(i),t})):(this.container.className="linkAnnotation",this.container.appendChild(s),this.container)}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&(t.className="internalLink")}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),t.className="internalLink"}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),t.className="internalLink"}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),t.className="internalLink",!this._fieldObjects)return(0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(s||(t.onclick=()=>!1));t.onclick=()=>{s&&s();const{fields:t,refs:i,include:n}=e,r=[];if(0!==t.length||0!==i.length){const e=new Set(i);for(const s of t){const t=this._fieldObjects[s]||[];for(const{id:s}of t)e.add(s)}for(const t of Object.values(this._fieldObjects))for(const s of t)e.has(s.id)===n&&r.push(s)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const o=this.annotationStorage,a=[];for(const t of r){const{id:e}=t;switch(a.push(e),t.type){case"text":{const s=t.defaultValue||"";o.setValue(e,{value:s,valueAsString:s});break}case"checkbox":case"radiobutton":o.setValue(e,{value:t.defaultValue===t.exportValues});break;case"combobox":case"listbox":o.setValue(e,{value:t.defaultValue||""});break;default:continue}const s=document.getElementById(e);s&&c.has(s)&&s.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:a,name:"ResetForm"}}),!1}}}class f extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str)})}render(){this.container.className="textAnnotation";const t=document.createElement("img");return t.style.height=this.container.style.height,t.style.width=this.container.style.width,t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.alt="[{{type}} Annotation]",t.dataset.l10nId="text_annotation_type",t.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.hasPopup||this._createPopup(t,this.data),this.container.appendChild(t),this.container}}class p extends d{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}_getKeyModifier(t){const{isWin:e,isMac:s}=d.platform;return e&&t.ctrlKey||s&&t.metaKey}_setEventListener(t,e,s,i){e.includes("mouse")?t.addEventListener(e,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(e,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:t.target.checked}})}))}_setEventListeners(t,e,s){for(const[i,n]of e)("Action"===n||this.data.actions?.[n])&&this._setEventListener(t,i,n,s)}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":i.Util.makeHexColor(e[0],e[1],e[2])}_dispatchEventFromSandbox(t,e){const s=(t,e,s)=>{const i=s.detail[t];s.target.style[e]=o.ColorConverters[`${i[0]}_HTML`](i.slice(1))},i={display:t=>{const e=t.detail.display%2==1;t.target.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:e,print:0===t.detail.display||3===t.detail.display})},print:t=>{this.annotationStorage.setValue(this.data.id,{print:t.detail.print})},hidden:t=>{t.target.style.visibility=t.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:t.detail.hidden})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.detail.readonly?t.target.setAttribute("readonly",""):t.target.removeAttribute("readonly")},required:t=>{t.detail.required?t.target.setAttribute("required",""):t.target.removeAttribute("required")},bgColor:t=>{s("bgColor","backgroundColor",t)},fillColor:t=>{s("fillColor","backgroundColor",t)},fgColor:t=>{s("fgColor","color",t)},textColor:t=>{s("textColor","color",t)},borderColor:t=>{s("borderColor","borderColor",t)},strokeColor:t=>{s("strokeColor","borderColor",t)}};for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n&&n(e)}}}class g extends p{constructor(t){super(t,{isRenderable:t.renderForms||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.className="textWidgetAnnotation";let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue,valueAsString:this.data.fieldValue}),n=i.valueAsString||i.value||"",r={userValue:null,formattedValue:null,beforeInputSelectionRange:null,beforeInputValue:null};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=n):(s=document.createElement("input"),s.type="text",s.setAttribute("value",n)),c.add(s),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=h,r.userValue=n,s.setAttribute("id",e),s.addEventListener("input",(i=>{t.setValue(e,{value:i.target.value}),this.setPropertyOnSiblings(s,"value",i.target.value,"value")})),s.addEventListener("resetform",(()=>{s.value=r.userValue=this.data.defaultFieldValue||"",delete r.formattedValue}));let o=t=>{r.formattedValue&&(t.target.value=r.formattedValue),t.target.scrollLeft=0,r.beforeInputSelectionRange=null};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(t=>{r.userValue&&(t.target.value=r.userValue)})),s.addEventListener("updatefromsandbox",(s=>{this._dispatchEventFromSandbox({value(s){r.userValue=s.detail.value||"",t.setValue(e,{value:r.userValue.toString()}),r.formattedValue||(s.target.value=r.userValue)},valueAsString(s){r.formattedValue=s.detail.valueAsString||"",s.target!==document.activeElement&&(s.target.value=r.formattedValue),t.setValue(e,{formattedValue:r.formattedValue})},selRange(t){const[e,s]=t.detail.selRange;e>=0&&s<t.target.value.length&&t.target.setSelectionRange(e,s)}},s)})),s.addEventListener("keydown",(t=>{r.beforeInputValue=t.target.value;let s=-1;"Escape"===t.key?s=0:"Enter"===t.key?s=2:"Tab"===t.key&&(s=3),-1!==s&&(r.userValue=t.target.value,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:t.target.value,willCommit:!0,commitKey:s,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const i=o;o=null,s.addEventListener("blur",(t=>{this._mouseState.isDown&&(r.userValue=t.target.value,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:t.target.value,willCommit:!0,commitKey:1,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})),i(t)})),s.addEventListener("mousedown",(t=>{r.beforeInputValue=t.target.value,r.beforeInputSelectionRange=null})),s.addEventListener("keyup",(t=>{t.target.selectionStart===t.target.selectionEnd&&(r.beforeInputSelectionRange=null)})),s.addEventListener("select",(t=>{r.beforeInputSelectionRange=[t.target.selectionStart,t.target.selectionEnd]})),this.data.actions?.Keystroke&&s.addEventListener("input",(t=>{let s=-1,i=-1;r.beforeInputSelectionRange&&([s,i]=r.beforeInputSelectionRange),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r.beforeInputValue,change:t.data,willCommit:!1,selStart:s,selEnd:i}})})),this._setEventListeners(s,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(o&&s.addEventListener("blur",o),null!==this.data.maxLen&&(s.maxLength=this.data.maxLen),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/this.data.maxLen;s.classList.add("comb"),s.style.letterSpacing=`calc(${t}px - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell";return this._setTextStyle(s),this._setBackgroundColor(s),this.container.appendChild(s),this.container}_setTextStyle(t){const{fontSize:e,fontColor:s}=this.data.defaultAppearanceData,n=t.style;e&&(n.fontSize=`${e}px`),n.color=i.Util.makeHexColor(s[0],s[1],s[2]),null!==this.data.textAlignment&&(n.textAlign=["left","center","right"][this.data.textAlignment])}}class b extends p{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,t.setValue(s,{value:i})),this.container.className="buttonWidgetAnnotation checkBox";const n=document.createElement("input");return c.add(n),n.disabled=e.readOnly,n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("id",s),n.setAttribute("exportValue",e.exportValue),n.tabIndex=h,n.addEventListener("change",(i=>{const{name:n,checked:r}=i.target;for(const i of this._getElementsByName(n,s)){const s=r&&i.exportValue===e.exportValue;i.domElement&&(i.domElement.checked=s),t.setValue(i.id,{value:s})}t.setValue(s,{value:r})})),n.addEventListener("resetform",(t=>{t.target.checked=(e.defaultFieldValue||"Off")===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(s,{value:e.target.checked})}},e)})),this._setEventListeners(n,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this.container.appendChild(n),this.container}}class A extends p{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.className="buttonWidgetAnnotation radioButton";const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;"string"==typeof i&&(i=i!==e.buttonValue,t.setValue(s,{value:i}));const n=document.createElement("input");if(c.add(n),n.disabled=e.readOnly,n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("id",s),n.tabIndex=h,n.addEventListener("change",(e=>{const{name:i,checked:n}=e.target;for(const e of this._getElementsByName(i,s))t.setValue(e.id,{value:!1});t.setValue(s,{value:n})})),n.addEventListener("resetform",(t=>{const s=e.defaultFieldValue;t.target.checked=null!=s&&s===e.buttonValue})),this.enableScripting&&this.hasJSActions){const i=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value:e=>{const n=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=n&&i.id===s;i.domElement&&(i.domElement.checked=e),t.setValue(i.id,{value:e})}}},e)})),this._setEventListeners(n,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this.container.appendChild(n),this.container}}class m extends u{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();return t.className="buttonWidgetAnnotation pushButton",this.data.alternativeText&&(t.title=this.data.alternativeText),t}}class w extends p{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.className="choiceWidgetAnnotation";const t=this.annotationStorage,e=this.data.id;t.getValue(e,{value:this.data.fieldValue.length>0?this.data.fieldValue[0]:void 0});let{fontSize:s}=this.data.defaultAppearanceData;s||(s=9);const i=`calc(${s}px * var(--zoom-factor))`,n=document.createElement("select");c.add(n),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.setAttribute("id",e),n.tabIndex=h,n.style.fontSize=`${s}px`,this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(()=>{const t=this.data.defaultFieldValue;for(const e of n.options)e.selected=e.value===t}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,this.data.combo&&(e.style.fontSize=i),this.data.fieldValue.includes(t.exportValue)&&e.setAttribute("selected",!0),n.appendChild(e)}const r=(t,e)=>{const s=e?"value":"textContent",i=t.target.options;return t.target.multiple?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[s])):-1===i.selectedIndex?null:i[i.selectedIndex][s]},o=t=>Array.prototype.map.call(t.target.options,(t=>({displayValue:t.textContent,exportValue:t.value})));return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(s=>{this._dispatchEventFromSandbox({value(s){const i=s.detail.value,o=new Set(Array.isArray(i)?i:[i]);for(const t of n.options)t.selected=o.has(t.value);t.setValue(e,{value:r(s,!0)})},multipleSelection(t){n.multiple=!0},remove(s){const i=n.options,a=s.detail.remove;i[a].selected=!1,n.remove(a),i.length>0&&-1===Array.prototype.findIndex.call(i,(t=>t.selected))&&(i[0].selected=!0),t.setValue(e,{value:r(s,!0),items:o(s)})},clear(s){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]})},insert(s){const{index:i,displayValue:a,exportValue:h}=s.detail.insert,c=document.createElement("option");c.textContent=a,c.value=h,n.insertBefore(c,n.children[i]),t.setValue(e,{value:r(s,!0),items:o(s)})},items(s){const{items:i}=s.detail;for(;0!==n.length;)n.remove(0);for(const t of i){const{displayValue:e,exportValue:s}=t,i=document.createElement("option");i.textContent=e,i.value=s,n.appendChild(i)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:r(s,!0),items:o(s)})},indices(s){const i=new Set(s.detail.indices);for(const t of s.target.options)t.selected=i.has(t.index);t.setValue(e,{value:r(s,!0)})},editable(t){t.target.disabled=!t.detail.editable}},s)})),n.addEventListener("input",(s=>{const i=r(s,!0),n=r(s,!1);t.setValue(e,{value:i}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,changeEx:i,willCommit:!0,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"]],(t=>t.target.checked))):n.addEventListener("input",(function(s){t.setValue(e,{value:r(s)})})),this._setBackgroundColor(n),this.container.appendChild(n),this.container}}class v extends d{constructor(t){super(t,{isRenderable:!!(t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str)})}render(){if(this.container.className="popupAnnotation",["Line","Square","Circle","PolyLine","Polygon","Ink"].includes(this.data.parentType))return this.container;const t=this.layer.querySelectorAll(`[data-annotation-id="${this.data.parentId}"]`);if(0===t.length)return this.container;const e=new k({container:this.container,trigger:Array.from(t),color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText}),s=this.page,n=i.Util.normalizeRect([this.data.parentRect[0],s.view[3]-this.data.parentRect[1]+s.view[1],this.data.parentRect[2],s.view[3]-this.data.parentRect[3]+s.view[1]]),r=n[0]+this.data.parentRect[2]-this.data.parentRect[0],o=n[1];return this.container.style.transformOrigin=`${-r}px ${-o}px`,this.container.style.left=`${r}px`,this.container.style.top=`${o}px`,this.container.appendChild(e.render()),this.container}}class k{constructor(t){this.container=t.container,this.trigger=t.trigger,this.color=t.color,this.titleObj=t.titleObj,this.modificationDate=t.modificationDate,this.contentsObj=t.contentsObj,this.richText=t.richText,this.hideWrapper=t.hideWrapper||!1,this.pinned=!1}render(){const t=document.createElement("div");t.className="popupWrapper",this.hideElement=this.hideWrapper?t:this.container,this.hideElement.hidden=!0;const e=document.createElement("div");e.className="popup";const s=this.color;s&&(e.style.backgroundColor=i.Util.makeHexColor(0|.7*(255-s[0])+s[0],0|.7*(255-s[1])+s[1],0|.7*(255-s[2])+s[2]));const r=document.createElement("h1");r.dir=this.titleObj.dir,r.textContent=this.titleObj.str,e.appendChild(r);const o=n.PDFDateString.toDateObject(this.modificationDate);if(o){const t=document.createElement("span");t.className="popupDate",t.textContent="{{date}}, {{time}}",t.dataset.l10nId="annotation_date_string",t.dataset.l10nArgs=JSON.stringify({date:o.toLocaleDateString(),time:o.toLocaleTimeString()}),e.appendChild(t)}if(!this.richText?.str||this.contentsObj?.str&&this.contentsObj.str!==this.richText.str){const t=this._formatContents(this.contentsObj);e.appendChild(t)}else a.XfaLayer.render({xfaHtml:this.richText.html,intent:"richText",div:e}),e.lastChild.className="richText popupContent";Array.isArray(this.trigger)||(this.trigger=[this.trigger]);for(const t of this.trigger)t.addEventListener("click",this._toggle.bind(this)),t.addEventListener("mouseover",this._show.bind(this,!1)),t.addEventListener("mouseout",this._hide.bind(this,!1));return e.addEventListener("click",this._hide.bind(this,!0)),t.appendChild(e),t}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.className="popupContent",s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let t=0,e=i.length;t<e;++t)s.appendChild(document.createTextNode(i[t])),t<e-1&&s.appendChild(document.createElement("br"));return s}_toggle(){this.pinned?this._hide(!0):this._show(!0)}_show(t=!1){t&&(this.pinned=!0),this.hideElement.hidden&&(this.hideElement.hidden=!1,this.container.style.zIndex+=1)}_hide(t=!0){t&&(this.pinned=!1),this.hideElement.hidden||this.pinned||(this.hideElement.hidden=!0,this.container.style.zIndex-=1)}}class x extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){return this.container.className="freeTextAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class y extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="lineAnnotation";const t=this.data,e=this.svgFactory.create(t.rect[2]-t.rect[0],t.rect[3]-t.rect[1]),s=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),s.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),s.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),s.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),s.setAttribute("stroke-width",t.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),e.appendChild(s),this.container.append(e),this._createPopup(s,t),this.container}}class _ extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="squareAnnotation";const t=this.data,e=t.rect[2]-t.rect[0],s=t.rect[3]-t.rect[1],i=this.svgFactory.create(e,s),n=t.borderStyle.width,r=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.appendChild(r),this.container.append(i),this._createPopup(r,t),this.container}}class D extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="circleAnnotation";const t=this.data,e=t.rect[2]-t.rect[0],s=t.rect[3]-t.rect[1],i=this.svgFactory.create(e,s),n=t.borderStyle.width,r=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.appendChild(r),this.container.append(i),this._createPopup(r,t),this.container}}class M extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const t=this.data,e=this.svgFactory.create(t.rect[2]-t.rect[0],t.rect[3]-t.rect[1]);let s=[];for(const e of t.vertices)s.push(e.x-t.rect[0]+","+(t.rect[3]-e.y));s=s.join(" ");const i=this.svgFactory.createElement(this.svgElementName);return i.setAttribute("points",s),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),e.appendChild(i),this.container.append(e),this._createPopup(i,t),this.container}}class E extends M{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class F extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){return this.container.className="caretAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class C extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const t=this.data,e=this.svgFactory.create(t.rect[2]-t.rect[0],t.rect[3]-t.rect[1]);for(const s of t.inkLists){let i=[];for(const e of s)i.push(`${e.x-t.rect[0]},${t.rect[3]-e.y}`);i=i.join(" ");const n=this.svgFactory.createElement(this.svgElementName);n.setAttribute("points",i),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),this._createPopup(n,t),e.appendChild(n)}return this.container.append(e),this.container}}class P extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("highlightAnnotation"):(this.container.className="highlightAnnotation",this.container)}}class S extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("underlineAnnotation"):(this.container.className="underlineAnnotation",this.container)}}class O extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("squigglyAnnotation"):(this.container.className="squigglyAnnotation",this.container)}}class T extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("strikeoutAnnotation"):(this.container.className="strikeoutAnnotation",this.container)}}class R extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){return this.container.className="stampAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class I extends d{constructor(t){super(t,{isRenderable:!0});const{filename:e,content:s}=this.data.file;this.filename=(0,n.getFilenameFromUrl)(e),this.content=s,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,id:(0,i.stringToPDFString)(e),filename:e,content:s})}render(){this.container.className="fileAttachmentAnnotation";const t=document.createElement("div");return t.style.height=this.container.style.height,t.style.width=this.container.style.width,t.addEventListener("dblclick",this._download.bind(this)),!this.data.hasPopup&&(this.data.titleObj?.str||this.data.contentsObj?.str||this.data.richText)&&this._createPopup(t,this.data),this.container.appendChild(t),this.container}_download(){this.downloadManager?.openOrDownloadData(this.container,this.content,this.filename)}}e.AnnotationLayer=class{static render(t){const e=[],s=[];for(const n of t.annotations)n&&(n.annotationType!==i.AnnotationType.POPUP?e.push(n):s.push(n));s.length&&e.push(...s);const o=t.div;for(const s of e){const e=l.create({data:s,layer:o,page:t.page,viewport:t.viewport,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new n.DOMSVGFactory,annotationStorage:t.annotationStorage||new r.AnnotationStorage,enableScripting:t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,mouseState:t.mouseState||{isDown:!1}});if(e.isRenderable){const t=e.render();if(s.hidden&&(t.style.visibility="hidden"),Array.isArray(t))for(const e of t)o.appendChild(e);else e instanceof v?o.prepend(t):o.appendChild(t)}}this.#o(o,t.annotationCanvasMap)}static update(t){const{page:e,viewport:s,annotations:n,annotationCanvasMap:r,div:o}=t,a=s.transform,h=`matrix(${a.join(",")})`;let c,l;for(const t of n){const s=o.querySelectorAll(`[data-annotation-id="${t.id}"]`);if(s)for(const n of s)if(t.hasOwnCanvas){const s=i.Util.normalizeRect([t.rect[0],e.view[3]-t.rect[1]+e.view[1],t.rect[2],e.view[3]-t.rect[3]+e.view[1]]);if(!l){c=Math.abs(a[0]||a[1]);const t=a.slice();for(let e=0;e<4;e++)t[e]=Math.sign(t[e]);l=`matrix(${t.join(",")})`}const r=s[0]*c,o=s[1]*c;n.style.left=`${r}px`,n.style.top=`${o}px`,n.style.transformOrigin=`${-r}px ${-o}px`,n.style.transform=l}else n.style.transform=h}this.#o(o,r),o.hidden=!1}static#o(t,e){if(e){for(const[s,i]of e){const e=t.querySelector(`[data-annotation-id="${s}"]`);if(!e)continue;const{firstChild:n}=e;"CANVAS"===n.nodeName?e.replaceChild(i,n):e.insertBefore(i,n)}e.clear()}}}},(t,e)=>{function s(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}Object.defineProperty(e,"__esModule",{value:!0}),e.ColorConverters=void 0,e.ColorConverters=class{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_HTML([t]){const e=s(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_HTML([t,e,i]){return`#${s(t)}${s(e)}${s(i)}`}static T_HTML(){return"#00000000"}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_HTML(t){return this.RGB_HTML(this.CMYK_RGB(t))}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s;return["CMYK",i,n,r,Math.min(i,n,r)]}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.XfaLayer=void 0;var i=s(2),n=s(17);e.XfaLayer=class{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===s.attributes.type||"checkbox"===s.attributes.type){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{i.setValue(e,{value:t.target.getAttribute(t.target.checked?"xfaOn":"xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value)for(const t of s.children)t.attributes.value===r.value&&(t.attributes.selected=!0);t.addEventListener("input",(t=>{const s=t.target.options;i.setValue(e,{value:-1===s.selectedIndex?"":s[s.selectedIndex].value})}))}}static setAttributes({html:t,element:e,storage:s=null,intent:n,linkService:r}){const{attributes:o}=e,a=t instanceof HTMLAnchorElement;"radio"===o.type&&(o.name=`${o.name}-${n}`);for(const[e,s]of Object.entries(o))if(null!=s&&"dataId"!==e)if("style"!==e)if("textContent"===e)t.textContent=s;else if("class"===e)s.length&&t.setAttribute(e,s.join(" "));else{if(a&&("href"===e||"newWindow"===e))continue;t.setAttribute(e,s)}else Object.assign(t.style,s);a&&(r.addLinkAttributes||(0,i.warn)("XfaLayer.setAttribute - missing `addLinkAttributes`-method on the `linkService`-instance."),r.addLinkAttributes?.(t,o.href,o.newWindow)),s&&o.dataId&&this.setupStorage(t,o.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:r,linkService:s});const a=[[i,-1,o]],h=t.div;if(h.appendChild(o),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=e}"richText"!==r&&h.setAttribute("class","xfaLayer xfaFont");const c=[];for(;a.length>0;){const[t,i,o]=a[a.length-1];if(i+1===t.children.length){a.pop();continue}const h=t.children[++a[a.length-1][1]];if(null===h)continue;const{name:l}=h;if("#text"===l){const t=document.createTextNode(h.value);c.push(t),o.appendChild(t);continue}let d;if(d=h?.attributes?.xmlns?document.createElementNS(h.attributes.xmlns,l):document.createElement(l),o.appendChild(d),h.attributes&&this.setAttributes({html:d,element:h,storage:e,intent:r,linkService:s}),h.children&&h.children.length>0)a.push([h,-1,d]);else if(h.value){const t=document.createTextNode(h.value);n.XfaText.shouldBuildText(l)&&c.push(t),d.appendChild(t)}}for(const t of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.renderTextLayer=function(t){const e=new d({textContent:t.textContent,textContentStream:t.textContentStream,container:t.container,viewport:t.viewport,textDivs:t.textDivs,textContentItemsStr:t.textContentItemsStr,enhanceTextSelection:t.enhanceTextSelection});return e._render(t.timeout),e};var i=s(2);const n=30,r=new Map,o=/^\s+$/g;function a(t,e,s,a){const h=document.createElement("span"),c=t._enhanceTextSelection?{angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,originalTransform:null,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,scale:1}:{angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL};t._textDivs.push(h);const l=i.Util.transform(t._viewport.transform,e.transform);let d=Math.atan2(l[1],l[0]);const u=s[e.fontName];u.vertical&&(d+=Math.PI/2);const f=Math.hypot(l[2],l[3]),p=f*function(t,e){const s=r.get(t);if(s)return s;e.save(),e.font=`30px ${t}`;const i=e.measureText("");let o=i.fontBoundingBoxAscent,a=Math.abs(i.fontBoundingBoxDescent);if(o){e.restore();const s=o/(o+a);return r.set(t,s),s}e.strokeStyle="red",e.clearRect(0,0,n,n),e.strokeText("g",0,0);let h=e.getImageData(0,0,n,n).data;a=0;for(let t=h.length-1-3;t>=0;t-=4)if(h[t]>0){a=Math.ceil(t/4/n);break}e.clearRect(0,0,n,n),e.strokeText("A",0,n),h=e.getImageData(0,0,n,n).data,o=0;for(let t=0,e=h.length;t<e;t+=4)if(h[t]>0){o=n-Math.floor(t/4/n);break}if(e.restore(),o){const e=o/(o+a);return r.set(t,e),e}return r.set(t,.8),.8}(u.fontFamily,a);let g,b;0===d?(g=l[4],b=l[5]-p):(g=l[4]+p*Math.sin(d),b=l[5]-p*Math.cos(d)),h.style.left=`${g}px`,h.style.top=`${b}px`,h.style.fontSize=`${f}px`,h.style.fontFamily=u.fontFamily,h.setAttribute("role","presentation"),h.textContent=e.str,h.dir=e.dir,t._fontInspectorEnabled&&(h.dataset.fontName=e.fontName),0!==d&&(c.angle=d*(180/Math.PI));let A=!1;if(e.str.length>1||t._enhanceTextSelection&&o.test(e.str))A=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),s=Math.abs(e.transform[3]);t!==s&&Math.max(t,s)/Math.min(t,s)>1.5&&(A=!0)}if(A&&(c.canvasWidth=u.vertical?e.height*t._viewport.scale:e.width*t._viewport.scale),t._textDivProperties.set(h,c),t._textContentStream&&t._layoutText(h),t._enhanceTextSelection&&c.hasText){let s=1,n=0;0!==d&&(s=Math.cos(d),n=Math.sin(d));const r=(u.vertical?e.height:e.width)*t._viewport.scale,o=f;let a,c;0!==d?(a=[s,n,-n,s,g,b],c=i.Util.getAxialAlignedBoundingBox([0,0,r,o],a)):c=[g,b,g+r,b+o],t._bounds.push({left:c[0],top:c[1],right:c[2],bottom:c[3],div:h,size:[r,o],m:a})}}function h(t){if(t._canceled)return;const e=t._textDivs,s=t._capability,i=e.length;if(i>1e5)return t._renderingDone=!0,void s.resolve();if(!t._textContentStream)for(let s=0;s<i;s++)t._layoutText(e[s]);t._renderingDone=!0,s.resolve()}function c(t,e,s){let i=0;for(let n=0;n<s;n++){const s=t[e++];s>0&&(i=i?Math.min(s,i):s)}return i}function l(t,e){e.sort((function(t,e){return t.x1-e.x1||t.index-e.index}));const s=[{start:-1/0,end:1/0,boundary:{x1:-1/0,y1:-1/0,x2:0,y2:1/0,index:-1,x1New:0,x2New:0}}];for(const t of e){let e=0;for(;e<s.length&&s[e].end<=t.y1;)e++;let i,n,r=s.length-1;for(;r>=0&&s[r].start>=t.y2;)r--;let o,a,h=-1/0;for(o=e;o<=r;o++){let e;i=s[o],n=i.boundary,e=n.x2>t.x1?n.index>t.index?n.x1New:t.x1:void 0===n.x2New?(n.x2+t.x1)/2:n.x2New,e>h&&(h=e)}for(t.x1New=h,o=e;o<=r;o++)i=s[o],n=i.boundary,void 0===n.x2New?n.x2>t.x1?n.index>t.index&&(n.x2New=n.x2):n.x2New=h:n.x2New>h&&(n.x2New=Math.max(h,n.x2));const c=[];let l=null;for(o=e;o<=r;o++){i=s[o],n=i.boundary;const e=n.x2>t.x2?n:t;l===e?c[c.length-1].end=i.end:(c.push({start:i.start,end:i.end,boundary:e}),l=e)}for(s[e].start<t.y1&&(c[0].start=t.y1,c.unshift({start:s[e].start,end:t.y1,boundary:s[e].boundary})),t.y2<s[r].end&&(c[c.length-1].end=t.y2,c.push({start:t.y2,end:s[r].end,boundary:s[r].boundary})),o=e;o<=r;o++){if(i=s[o],n=i.boundary,void 0!==n.x2New)continue;let t=!1;for(a=e-1;!t&&a>=0&&s[a].start>=n.y1;a--)t=s[a].boundary===n;for(a=r+1;!t&&a<s.length&&s[a].end<=n.y2;a++)t=s[a].boundary===n;for(a=0;!t&&a<c.length;a++)t=c[a].boundary===n;t||(n.x2New=h)}Array.prototype.splice.apply(s,[e,r-e+1].concat(c))}for(const e of s){const s=e.boundary;void 0===s.x2New&&(s.x2New=Math.max(t,s.x2))}}class d{constructor({textContent:t,textContentStream:e,container:s,viewport:n,textDivs:r,textContentItemsStr:o,enhanceTextSelection:a}){this._textContent=t,this._textContentStream=e,this._container=s,this._document=s.ownerDocument,this._viewport=n,this._textDivs=r||[],this._textContentItemsStr=o||[],this._enhanceTextSelection=!!a,this._fontInspectorEnabled=!!globalThis.FontInspector?.enabled,this._reader=null,this._layoutTextLastFontSize=null,this._layoutTextLastFontFamily=null,this._layoutTextCtx=null,this._textDivProperties=new WeakMap,this._renderingDone=!1,this._canceled=!1,this._capability=(0,i.createPromiseCapability)(),this._renderTimer=null,this._bounds=[],this._capability.promise.finally((()=>{this._enhanceTextSelection||(this._textDivProperties=null),this._layoutTextCtx&&(this._layoutTextCtx.canvas.width=0,this._layoutTextCtx.canvas.height=0,this._layoutTextCtx=null)})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch((()=>{})),this._reader=null),null!==this._renderTimer&&(clearTimeout(this._renderTimer),this._renderTimer=null),this._capability.reject(new Error("TextLayer task cancelled."))}_processItems(t,e){for(let s=0,i=t.length;s<i;s++)if(void 0!==t[s].str)this._textContentItemsStr.push(t[s].str),a(this,t[s],e,this._layoutTextCtx);else if("beginMarkedContentProps"===t[s].type||"beginMarkedContent"===t[s].type){const e=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),null!==t[s].id&&this._container.setAttribute("id",`${t[s].id}`),e.appendChild(this._container)}else"endMarkedContent"===t[s].type&&(this._container=this._container.parentNode)}_layoutText(t){const e=this._textDivProperties.get(t);let s="";if(0!==e.canvasWidth&&e.hasText){const{fontSize:i,fontFamily:n}=t.style;i===this._layoutTextLastFontSize&&n===this._layoutTextLastFontFamily||(this._layoutTextCtx.font=`${i} ${n}`,this._layoutTextLastFontSize=i,this._layoutTextLastFontFamily=n);const{width:r}=this._layoutTextCtx.measureText(t.textContent);if(r>0){const t=e.canvasWidth/r;this._enhanceTextSelection&&(e.scale=t),s=`scaleX(${t})`}}if(0!==e.angle&&(s=`rotate(${e.angle}deg) ${s}`),s.length>0&&(this._enhanceTextSelection&&(e.originalTransform=s),t.style.transform=s),e.hasText&&this._container.appendChild(t),e.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this._container.appendChild(t)}}_render(t=0){const e=(0,i.createPromiseCapability)();let s=Object.create(null);const r=this._document.createElement("canvas");if(r.height=r.width=n,r.mozOpaque=!0,this._layoutTextCtx=r.getContext("2d",{alpha:!1}),this._textContent)this._processItems(this._textContent.items,this._textContent.styles),e.resolve();else{if(!this._textContentStream)throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');{const t=()=>{this._reader.read().then((({value:i,done:n})=>{n?e.resolve():(Object.assign(s,i.styles),this._processItems(i.items,s),t())}),e.reject)};this._reader=this._textContentStream.getReader(),t()}}e.promise.then((()=>{s=null,t?this._renderTimer=setTimeout((()=>{h(this),this._renderTimer=null}),t):h(this)}),this._capability.reject)}expandTextDivs(t=!1){if(!this._enhanceTextSelection||!this._renderingDone)return;null!==this._bounds&&(function(t){const e=t._bounds,s=t._viewport,n=function(t,e,s){const i=s.map((function(t,e){return{x1:t.left,y1:t.top,x2:t.right,y2:t.bottom,index:e,x1New:void 0,x2New:void 0}}));l(t,i);const n=new Array(s.length);for(const t of i)n[t.index]={left:t.x1New,top:0,right:t.x2New,bottom:0};s.map((function(e,s){const r=n[s],o=i[s];o.x1=e.top,o.y1=t-r.right,o.x2=e.bottom,o.y2=t-r.left,o.index=s,o.x1New=void 0,o.x2New=void 0})),l(e,i);for(const t of i){const e=t.index;n[e].top=t.x1New,n[e].bottom=t.x2New}return n}(s.width,s.height,e);for(let s=0;s<n.length;s++){const r=e[s].div,o=t._textDivProperties.get(r);if(0===o.angle){o.paddingLeft=e[s].left-n[s].left,o.paddingTop=e[s].top-n[s].top,o.paddingRight=n[s].right-e[s].right,o.paddingBottom=n[s].bottom-e[s].bottom,t._textDivProperties.set(r,o);continue}const a=n[s],h=e[s],l=h.m,d=l[0],u=l[1],f=[[0,0],[0,h.size[1]],[h.size[0],0],h.size],p=new Float64Array(64);for(let t=0,e=f.length;t<e;t++){const e=i.Util.applyTransform(f[t],l);p[t+0]=d&&(a.left-e[0])/d,p[t+4]=u&&(a.top-e[1])/u,p[t+8]=d&&(a.right-e[0])/d,p[t+12]=u&&(a.bottom-e[1])/u,p[t+16]=u&&(a.left-e[0])/-u,p[t+20]=d&&(a.top-e[1])/d,p[t+24]=u&&(a.right-e[0])/-u,p[t+28]=d&&(a.bottom-e[1])/d,p[t+32]=d&&(a.left-e[0])/-d,p[t+36]=u&&(a.top-e[1])/-u,p[t+40]=d&&(a.right-e[0])/-d,p[t+44]=u&&(a.bottom-e[1])/-u,p[t+48]=u&&(a.left-e[0])/u,p[t+52]=d&&(a.top-e[1])/-d,p[t+56]=u&&(a.right-e[0])/u,p[t+60]=d&&(a.bottom-e[1])/-d}const g=1+Math.min(Math.abs(d),Math.abs(u));o.paddingLeft=c(p,32,16)/g,o.paddingTop=c(p,48,16)/g,o.paddingRight=c(p,0,16)/g,o.paddingBottom=c(p,16,16)/g,t._textDivProperties.set(r,o)}}(this),this._bounds=null);const e=[],s=[];for(let i=0,n=this._textDivs.length;i<n;i++){const n=this._textDivs[i],r=this._textDivProperties.get(n);r.hasText&&(t?(e.length=0,s.length=0,r.originalTransform&&e.push(r.originalTransform),r.paddingTop>0?(s.push(`${r.paddingTop}px`),e.push(`translateY(${-r.paddingTop}px)`)):s.push(0),s.push(r.paddingRight>0?r.paddingRight/r.scale+"px":0),s.push(r.paddingBottom>0?`${r.paddingBottom}px`:0),r.paddingLeft>0?(s.push(r.paddingLeft/r.scale+"px"),e.push(`translateX(${-r.paddingLeft/r.scale}px)`)):s.push(0),n.style.padding=s.join(" "),e.length&&(n.style.transform=e.join(" "))):(n.style.padding=null,n.style.transform=r.originalTransform))}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SVGGraphics=void 0;var i=s(2),n=s(1),r=s(4);let o=class{constructor(){(0,i.unreachable)("Not implemented: SVGGraphics")}};e.SVGGraphics=o;{const t={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},s="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/1999/xlink",l=["butt","round","square"],d=["miter","round","bevel"],u=function(){const t=new Uint8Array([137,80,78,71,13,10,26,10]),e=new Int32Array(256);for(let t=0;t<256;t++){let s=t;for(let t=0;t<8;t++)s=1&s?3988292384^s>>1&2147483647:s>>1&2147483647;e[t]=s}function s(t,s,i,n){let r=n;const o=s.length;i[r]=o>>24&255,i[r+1]=o>>16&255,i[r+2]=o>>8&255,i[r+3]=255&o,r+=4,i[r]=255&t.charCodeAt(0),i[r+1]=255&t.charCodeAt(1),i[r+2]=255&t.charCodeAt(2),i[r+3]=255&t.charCodeAt(3),r+=4,i.set(s,r),r+=s.length;const a=function(t,s,i){let n=-1;for(let r=s;r<i;r++)n=n>>>8^e[255&(n^t[r])];return-1^n}(i,n+4,r);i[r]=a>>24&255,i[r+1]=a>>16&255,i[r+2]=a>>8&255,i[r+3]=255&a}function n(t){let e=t.length;const s=65535,i=Math.ceil(e/s),n=new Uint8Array(2+e+5*i+4);let r=0;n[r++]=120,n[r++]=156;let o=0;for(;e>s;)n[r++]=0,n[r++]=255,n[r++]=255,n[r++]=0,n[r++]=0,n.set(t.subarray(o,o+s),r),r+=s,o+=s,e-=s;n[r++]=1,n[r++]=255&e,n[r++]=e>>8&255,n[r++]=255&~e,n[r++]=(65535&~e)>>8&255,n.set(t.subarray(o),r),r+=t.length-o;const a=function(t,e,s){let i=1,n=0;for(let e=0;e<s;++e)i=(i+(255&t[e]))%65521,n=(n+i)%65521;return n<<16|i}(t,0,t.length);return n[r++]=a>>24&255,n[r++]=a>>16&255,n[r++]=a>>8&255,n[r++]=255&a,n}return function(e,o,a){return function(e,o,a,h){const c=e.width,l=e.height;let d,u,f;const p=e.data;switch(o){case i.ImageKind.GRAYSCALE_1BPP:u=0,d=1,f=c+7>>3;break;case i.ImageKind.RGB_24BPP:u=2,d=8,f=3*c;break;case i.ImageKind.RGBA_32BPP:u=6,d=8,f=4*c;break;default:throw new Error("invalid format")}const g=new Uint8Array((1+f)*l);let b=0,A=0;for(let t=0;t<l;++t)g[b++]=0,g.set(p.subarray(A,A+f),b),A+=f,b+=f;if(o===i.ImageKind.GRAYSCALE_1BPP&&h){b=0;for(let t=0;t<l;t++){b++;for(let t=0;t<f;t++)g[b++]^=255}}const m=new Uint8Array([c>>24&255,c>>16&255,c>>8&255,255&c,l>>24&255,l>>16&255,l>>8&255,255&l,d,u,0,0,0]),w=function(t){if(!r.isNodeJS)return n(t);try{let e;e=parseInt(process_1.versions.node)>=8?t:Buffer.from(t);const s=require$$5.deflateSync(e,{level:9});return s instanceof Uint8Array?s:new Uint8Array(s)}catch(t){(0,i.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+t)}return n(t)}(g),v=new Uint8Array(t.length+36+m.length+w.length);let k=0;return v.set(t,k),k+=t.length,s("IHDR",m,v,k),k+=12+m.length,s("IDATA",w,v,k),k+=12+w.length,s("IEND",new Uint8Array(0),v,k),(0,i.createObjectURL)(v,"image/png",a)}(e,void 0===e.kind?i.ImageKind.GRAYSCALE_1BPP:e.kind,o,a)}}();class f{constructor(){this.fontSizeScale=1,this.fontWeight=t.fontWeight,this.fontSize=0,this.textMatrix=i.IDENTITY_MATRIX,this.fontMatrix=i.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=i.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=t.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(t,e){this.x=t,this.y=e}}function a(t){if(Number.isInteger(t))return t.toString();const e=t.toFixed(10);let s=e.length-1;if("0"!==e[s])return e;do{s--}while("0"===e[s]);return e.substring(0,"."===e[s]?s:s+1)}function h(t){if(0===t[4]&&0===t[5]){if(0===t[1]&&0===t[2])return 1===t[0]&&1===t[3]?"":`scale(${a(t[0])} ${a(t[3])})`;if(t[0]===t[3]&&t[1]===-t[2])return`rotate(${a(180*Math.acos(t[0])/Math.PI)})`}else if(1===t[0]&&0===t[1]&&0===t[2]&&1===t[3])return`translate(${a(t[4])} ${a(t[5])})`;return`matrix(${a(t[0])} ${a(t[1])} ${a(t[2])} ${a(t[3])} ${a(t[4])} ${a(t[5])})`}let p=0,g=0,b=0;e.SVGGraphics=o=class{constructor(t,e,s=!1){this.svgFactory=new n.DOMSVGFactory,this.current=new f,this.transformMatrix=i.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=t,this.objs=e,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!s,this._operatorIdMapping=[];for(const t in i.OPS)this._operatorIdMapping[i.OPS[t]]=t}save(){this.transformStack.push(this.transformMatrix);const t=this.current;this.extraStack.push(t),this.current=t.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(t){this.save(),this.executeOpTree(t),this.restore()}loadDependencies(t){const e=t.fnArray,s=t.argsArray;for(let t=0,n=e.length;t<n;t++)if(e[t]===i.OPS.dependency)for(const e of s[t]){const t=e.startsWith("g_")?this.commonObjs:this.objs,s=new Promise((s=>{t.get(e,s)}));this.current.dependencies.push(s)}return Promise.all(this.current.dependencies)}transform(t,e,s,n,r,o){this.transformMatrix=i.Util.transform(this.transformMatrix,[t,e,s,n,r,o]),this.tgrp=null}getSVG(t,e){this.viewport=e;const s=this._initialize(e);return this.loadDependencies(t).then((()=>(this.transformMatrix=i.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(t)),s)))}convertOpList(t){const e=this._operatorIdMapping,s=t.argsArray,i=t.fnArray,n=[];for(let t=0,r=i.length;t<r;t++){const r=i[t];n.push({fnId:r,fn:e[r],args:s[t]})}return function(t){let e=[];const s=[];for(const i of t)"save"!==i.fn?"restore"===i.fn?e=s.pop():e.push(i):(e.push({fnId:92,fn:"group",items:[]}),s.push(e),e=e[e.length-1].items);return e}(n)}executeOpTree(t){for(const e of t){const t=e.fn,s=e.args;switch(0|e.fnId){case i.OPS.beginText:this.beginText();break;case i.OPS.dependency:break;case i.OPS.setLeading:this.setLeading(s);break;case i.OPS.setLeadingMoveText:this.setLeadingMoveText(s[0],s[1]);break;case i.OPS.setFont:this.setFont(s);break;case i.OPS.showText:case i.OPS.showSpacedText:this.showText(s[0]);break;case i.OPS.endText:this.endText();break;case i.OPS.moveText:this.moveText(s[0],s[1]);break;case i.OPS.setCharSpacing:this.setCharSpacing(s[0]);break;case i.OPS.setWordSpacing:this.setWordSpacing(s[0]);break;case i.OPS.setHScale:this.setHScale(s[0]);break;case i.OPS.setTextMatrix:this.setTextMatrix(s[0],s[1],s[2],s[3],s[4],s[5]);break;case i.OPS.setTextRise:this.setTextRise(s[0]);break;case i.OPS.setTextRenderingMode:this.setTextRenderingMode(s[0]);break;case i.OPS.setLineWidth:this.setLineWidth(s[0]);break;case i.OPS.setLineJoin:this.setLineJoin(s[0]);break;case i.OPS.setLineCap:this.setLineCap(s[0]);break;case i.OPS.setMiterLimit:this.setMiterLimit(s[0]);break;case i.OPS.setFillRGBColor:this.setFillRGBColor(s[0],s[1],s[2]);break;case i.OPS.setStrokeRGBColor:this.setStrokeRGBColor(s[0],s[1],s[2]);break;case i.OPS.setStrokeColorN:this.setStrokeColorN(s);break;case i.OPS.setFillColorN:this.setFillColorN(s);break;case i.OPS.shadingFill:this.shadingFill(s[0]);break;case i.OPS.setDash:this.setDash(s[0],s[1]);break;case i.OPS.setRenderingIntent:this.setRenderingIntent(s[0]);break;case i.OPS.setFlatness:this.setFlatness(s[0]);break;case i.OPS.setGState:this.setGState(s[0]);break;case i.OPS.fill:this.fill();break;case i.OPS.eoFill:this.eoFill();break;case i.OPS.stroke:this.stroke();break;case i.OPS.fillStroke:this.fillStroke();break;case i.OPS.eoFillStroke:this.eoFillStroke();break;case i.OPS.clip:this.clip("nonzero");break;case i.OPS.eoClip:this.clip("evenodd");break;case i.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case i.OPS.paintImageXObject:this.paintImageXObject(s[0]);break;case i.OPS.paintInlineImageXObject:this.paintInlineImageXObject(s[0]);break;case i.OPS.paintImageMaskXObject:this.paintImageMaskXObject(s[0]);break;case i.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(s[0],s[1]);break;case i.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case i.OPS.closePath:this.closePath();break;case i.OPS.closeStroke:this.closeStroke();break;case i.OPS.closeFillStroke:this.closeFillStroke();break;case i.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case i.OPS.nextLine:this.nextLine();break;case i.OPS.transform:this.transform(s[0],s[1],s[2],s[3],s[4],s[5]);break;case i.OPS.constructPath:this.constructPath(s[0],s[1]);break;case i.OPS.endPath:this.endPath();break;case 92:this.group(e.items);break;default:(0,i.warn)(`Unimplemented operator ${t}`)}}}setWordSpacing(t){this.current.wordSpacing=t}setCharSpacing(t){this.current.charSpacing=t}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(t,e,s,i,n,r){const o=this.current;o.textMatrix=o.lineMatrix=[t,e,s,i,n,r],o.textMatrixScale=Math.hypot(t,e),o.x=o.lineX=0,o.y=o.lineY=0,o.xcoords=[],o.ycoords=[],o.tspan=this.svgFactory.createElement("svg:tspan"),o.tspan.setAttributeNS(null,"font-family",o.fontFamily),o.tspan.setAttributeNS(null,"font-size",`${a(o.fontSize)}px`),o.tspan.setAttributeNS(null,"y",a(-o.y)),o.txtElement=this.svgFactory.createElement("svg:text"),o.txtElement.appendChild(o.tspan)}beginText(){const t=this.current;t.x=t.lineX=0,t.y=t.lineY=0,t.textMatrix=i.IDENTITY_MATRIX,t.lineMatrix=i.IDENTITY_MATRIX,t.textMatrixScale=1,t.tspan=this.svgFactory.createElement("svg:tspan"),t.txtElement=this.svgFactory.createElement("svg:text"),t.txtgrp=this.svgFactory.createElement("svg:g"),t.xcoords=[],t.ycoords=[]}moveText(t,e){const s=this.current;s.x=s.lineX+=t,s.y=s.lineY+=e,s.xcoords=[],s.ycoords=[],s.tspan=this.svgFactory.createElement("svg:tspan"),s.tspan.setAttributeNS(null,"font-family",s.fontFamily),s.tspan.setAttributeNS(null,"font-size",`${a(s.fontSize)}px`),s.tspan.setAttributeNS(null,"y",a(-s.y))}showText(e){const n=this.current,r=n.font,o=n.fontSize;if(0===o)return;const c=n.fontSizeScale,l=n.charSpacing,d=n.wordSpacing,u=n.fontDirection,f=n.textHScale*u,p=r.vertical,g=p?1:-1,b=r.defaultVMetrics,A=o*n.fontMatrix[0];let m=0;for(const t of e){if(null===t){m+=u*d;continue}if((0,i.isNum)(t)){m+=g*t*o/1e3;continue}const e=(t.isSpace?d:0)+l,s=t.fontChar;let a,h,f,w=t.width;if(p){let e;const s=t.vmetric||b;e=t.vmetric?s[1]:.5*w,e=-e*A,w=s?-s[0]:w,a=e/c,h=(m+s[2]*A)/c}else a=m/c,h=0;(t.isInFont||r.missingFile)&&(n.xcoords.push(n.x+a),p&&n.ycoords.push(-n.y+h),n.tspan.textContent+=s),f=p?w*A-e*u:w*A+e*u,m+=f}n.tspan.setAttributeNS(null,"x",n.xcoords.map(a).join(" ")),n.tspan.setAttributeNS(null,"y",p?n.ycoords.map(a).join(" "):a(-n.y)),p?n.y-=m:n.x+=m*f,n.tspan.setAttributeNS(null,"font-family",n.fontFamily),n.tspan.setAttributeNS(null,"font-size",`${a(n.fontSize)}px`),n.fontStyle!==t.fontStyle&&n.tspan.setAttributeNS(null,"font-style",n.fontStyle),n.fontWeight!==t.fontWeight&&n.tspan.setAttributeNS(null,"font-weight",n.fontWeight);const w=n.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;w===i.TextRenderingMode.FILL||w===i.TextRenderingMode.FILL_STROKE?(n.fillColor!==t.fillColor&&n.tspan.setAttributeNS(null,"fill",n.fillColor),n.fillAlpha<1&&n.tspan.setAttributeNS(null,"fill-opacity",n.fillAlpha)):n.tspan.setAttributeNS(null,"fill",n.textRenderingMode===i.TextRenderingMode.ADD_TO_PATH?"transparent":"none"),(w===i.TextRenderingMode.STROKE||w===i.TextRenderingMode.FILL_STROKE)&&this._setStrokeAttributes(n.tspan,1/(n.textMatrixScale||1));let v=n.textMatrix;0!==n.textRise&&(v=v.slice(),v[5]+=n.textRise),n.txtElement.setAttributeNS(null,"transform",`${h(v)} scale(${a(f)}, -1)`),n.txtElement.setAttributeNS(s,"xml:space","preserve"),n.txtElement.appendChild(n.tspan),n.txtgrp.appendChild(n.txtElement),this._ensureTransformGroup().appendChild(n.txtElement)}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}addFontStyle(t){if(!t.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.appendChild(this.cssStyle));const e=(0,i.createObjectURL)(t.data,t.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${t.loadedName}"; src: url(${e}); }\n`}setFont(t){const e=this.current,s=this.commonObjs.get(t[0]);let n=t[1];e.font=s,!this.embedFonts||s.missingFile||this.embeddedFonts[s.loadedName]||(this.addFontStyle(s),this.embeddedFonts[s.loadedName]=s),e.fontMatrix=s.fontMatrix||i.FONT_IDENTITY_MATRIX;let r="normal";s.black?r="900":s.bold&&(r="bold");const o=s.italic?"italic":"normal";n<0?(n=-n,e.fontDirection=-1):e.fontDirection=1,e.fontSize=n,e.fontFamily=s.loadedName,e.fontWeight=r,e.fontStyle=o,e.tspan=this.svgFactory.createElement("svg:tspan"),e.tspan.setAttributeNS(null,"y",a(-e.y)),e.xcoords=[],e.ycoords=[]}endText(){const t=this.current;t.textRenderingMode&i.TextRenderingMode.ADD_TO_PATH_FLAG&&t.txtElement?.hasChildNodes()&&(t.element=t.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(t){t>0&&(this.current.lineWidth=t)}setLineCap(t){this.current.lineCap=l[t]}setLineJoin(t){this.current.lineJoin=d[t]}setMiterLimit(t){this.current.miterLimit=t}setStrokeAlpha(t){this.current.strokeAlpha=t}setStrokeRGBColor(t,e,s){this.current.strokeColor=i.Util.makeHexColor(t,e,s)}setFillAlpha(t){this.current.fillAlpha=t}setFillRGBColor(t,e,s){this.current.fillColor=i.Util.makeHexColor(t,e,s),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(t){this.current.strokeColor=this._makeColorN_Pattern(t)}setFillColorN(t){this.current.fillColor=this._makeColorN_Pattern(t)}shadingFill(t){const e=this.viewport.width,s=this.viewport.height,n=i.Util.inverseTransform(this.transformMatrix),r=i.Util.applyTransform([0,0],n),o=i.Util.applyTransform([0,s],n),a=i.Util.applyTransform([e,0],n),h=i.Util.applyTransform([e,s],n),c=Math.min(r[0],o[0],a[0],h[0]),l=Math.min(r[1],o[1],a[1],h[1]),d=Math.max(r[0],o[0],a[0],h[0]),u=Math.max(r[1],o[1],a[1],h[1]),f=this.svgFactory.createElement("svg:rect");f.setAttributeNS(null,"x",c),f.setAttributeNS(null,"y",l),f.setAttributeNS(null,"width",d-c),f.setAttributeNS(null,"height",u-l),f.setAttributeNS(null,"fill",this._makeShadingPattern(t)),this.current.fillAlpha<1&&f.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().appendChild(f)}_makeColorN_Pattern(t){return"TilingPattern"===t[0]?this._makeTilingPattern(t):this._makeShadingPattern(t)}_makeTilingPattern(t){const e=t[1],s=t[2],n=t[3]||i.IDENTITY_MATRIX,[r,o,a,h]=t[4],c=t[5],l=t[6],d=t[7],u="shading"+b++,[f,p,g,A]=i.Util.normalizeRect([...i.Util.applyTransform([r,o],n),...i.Util.applyTransform([a,h],n)]),[m,w]=i.Util.singularValueDecompose2dScale(n),v=c*m,k=l*w,x=this.svgFactory.createElement("svg:pattern");x.setAttributeNS(null,"id",u),x.setAttributeNS(null,"patternUnits","userSpaceOnUse"),x.setAttributeNS(null,"width",v),x.setAttributeNS(null,"height",k),x.setAttributeNS(null,"x",`${f}`),x.setAttributeNS(null,"y",`${p}`);const y=this.svg,_=this.transformMatrix,D=this.current.fillColor,M=this.current.strokeColor,E=this.svgFactory.create(g-f,A-p);if(this.svg=E,this.transformMatrix=n,2===d){const t=i.Util.makeHexColor(...e);this.current.fillColor=t,this.current.strokeColor=t}return this.executeOpTree(this.convertOpList(s)),this.svg=y,this.transformMatrix=_,this.current.fillColor=D,this.current.strokeColor=M,x.appendChild(E.childNodes[0]),this.defs.appendChild(x),`url(#${u})`}_makeShadingPattern(t){switch("string"==typeof t&&(t=this.objs.get(t)),t[0]){case"RadialAxial":const e="shading"+b++,s=t[3];let n;switch(t[1]){case"axial":const s=t[4],i=t[5];n=this.svgFactory.createElement("svg:linearGradient"),n.setAttributeNS(null,"id",e),n.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),n.setAttributeNS(null,"x1",s[0]),n.setAttributeNS(null,"y1",s[1]),n.setAttributeNS(null,"x2",i[0]),n.setAttributeNS(null,"y2",i[1]);break;case"radial":const r=t[4],o=t[5],a=t[6],h=t[7];n=this.svgFactory.createElement("svg:radialGradient"),n.setAttributeNS(null,"id",e),n.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),n.setAttributeNS(null,"cx",o[0]),n.setAttributeNS(null,"cy",o[1]),n.setAttributeNS(null,"r",h),n.setAttributeNS(null,"fx",r[0]),n.setAttributeNS(null,"fy",r[1]),n.setAttributeNS(null,"fr",a);break;default:throw new Error(`Unknown RadialAxial type: ${t[1]}`)}for(const t of s){const e=this.svgFactory.createElement("svg:stop");e.setAttributeNS(null,"offset",t[0]),e.setAttributeNS(null,"stop-color",t[1]),n.appendChild(e)}return this.defs.appendChild(n),`url(#${e})`;case"Mesh":return(0,i.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${t[0]}`)}}setDash(t,e){this.current.dashArray=t,this.current.dashPhase=e}constructPath(t,e){const s=this.current;let n=s.x,r=s.y,o=[],h=0;for(const s of t)switch(0|s){case i.OPS.rectangle:n=e[h++],r=e[h++];const t=n+e[h++],s=r+e[h++];o.push("M",a(n),a(r),"L",a(t),a(r),"L",a(t),a(s),"L",a(n),a(s),"Z");break;case i.OPS.moveTo:n=e[h++],r=e[h++],o.push("M",a(n),a(r));break;case i.OPS.lineTo:n=e[h++],r=e[h++],o.push("L",a(n),a(r));break;case i.OPS.curveTo:n=e[h+4],r=e[h+5],o.push("C",a(e[h]),a(e[h+1]),a(e[h+2]),a(e[h+3]),a(n),a(r)),h+=6;break;case i.OPS.curveTo2:o.push("C",a(n),a(r),a(e[h]),a(e[h+1]),a(e[h+2]),a(e[h+3])),n=e[h+2],r=e[h+3],h+=4;break;case i.OPS.curveTo3:n=e[h+2],r=e[h+3],o.push("C",a(e[h]),a(e[h+1]),a(n),a(r),a(n),a(r)),h+=4;break;case i.OPS.closePath:o.push("Z")}o=o.join(" "),s.path&&t.length>0&&t[0]!==i.OPS.rectangle&&t[0]!==i.OPS.moveTo?o=s.path.getAttributeNS(null,"d")+o:(s.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().appendChild(s.path)),s.path.setAttributeNS(null,"d",o),s.path.setAttributeNS(null,"fill","none"),s.element=s.path,s.setCurrentPoint(n,r)}endPath(){const t=this.current;if(t.path=null,!this.pendingClip)return;if(!t.element)return void(this.pendingClip=null);const e="clippath"+p++,s=this.svgFactory.createElement("svg:clipPath");s.setAttributeNS(null,"id",e),s.setAttributeNS(null,"transform",h(this.transformMatrix));const i=t.element.cloneNode(!0);if(i.setAttributeNS(null,"clip-rule","evenodd"===this.pendingClip?"evenodd":"nonzero"),this.pendingClip=null,s.appendChild(i),this.defs.appendChild(s),t.activeClipUrl){t.clipGroup=null;for(const t of this.extraStack)t.clipGroup=null;s.setAttributeNS(null,"clip-path",t.activeClipUrl)}t.activeClipUrl=`url(#${e})`,this.tgrp=null}clip(t){this.pendingClip=t}closePath(){const t=this.current;if(t.path){const e=`${t.path.getAttributeNS(null,"d")}Z`;t.path.setAttributeNS(null,"d",e)}}setLeading(t){this.current.leading=-t}setTextRise(t){this.current.textRise=t}setTextRenderingMode(t){this.current.textRenderingMode=t}setHScale(t){this.current.textHScale=t/100}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s);break;case"CA":this.setStrokeAlpha(s);break;case"ca":this.setFillAlpha(s);break;default:(0,i.warn)(`Unimplemented graphic state operator ${e}`)}}fill(){const t=this.current;t.element&&(t.element.setAttributeNS(null,"fill",t.fillColor),t.element.setAttributeNS(null,"fill-opacity",t.fillAlpha),this.endPath())}stroke(){const t=this.current;t.element&&(this._setStrokeAttributes(t.element),t.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(t,e=1){const s=this.current;let i=s.dashArray;1!==e&&i.length>0&&(i=i.map((function(t){return e*t}))),t.setAttributeNS(null,"stroke",s.strokeColor),t.setAttributeNS(null,"stroke-opacity",s.strokeAlpha),t.setAttributeNS(null,"stroke-miterlimit",a(s.miterLimit)),t.setAttributeNS(null,"stroke-linecap",s.lineCap),t.setAttributeNS(null,"stroke-linejoin",s.lineJoin),t.setAttributeNS(null,"stroke-width",a(e*s.lineWidth)+"px"),t.setAttributeNS(null,"stroke-dasharray",i.map(a).join(" ")),t.setAttributeNS(null,"stroke-dashoffset",a(e*s.dashPhase)+"px")}eoFill(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){const t=this.svgFactory.createElement("svg:rect");t.setAttributeNS(null,"x","0"),t.setAttributeNS(null,"y","0"),t.setAttributeNS(null,"width","1px"),t.setAttributeNS(null,"height","1px"),t.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().appendChild(t)}paintImageXObject(t){const e=t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);e?this.paintInlineImageXObject(e):(0,i.warn)(`Dependent image with object ID ${t} is not ready yet`)}paintInlineImageXObject(t,e){const s=t.width,i=t.height,n=u(t,this.forceDataSchema,!!e),r=this.svgFactory.createElement("svg:rect");r.setAttributeNS(null,"x","0"),r.setAttributeNS(null,"y","0"),r.setAttributeNS(null,"width",a(s)),r.setAttributeNS(null,"height",a(i)),this.current.element=r,this.clip("nonzero");const o=this.svgFactory.createElement("svg:image");o.setAttributeNS(c,"xlink:href",n),o.setAttributeNS(null,"x","0"),o.setAttributeNS(null,"y",a(-i)),o.setAttributeNS(null,"width",a(s)+"px"),o.setAttributeNS(null,"height",a(i)+"px"),o.setAttributeNS(null,"transform",`scale(${a(1/s)} ${a(-1/i)})`),e?e.appendChild(o):this._ensureTransformGroup().appendChild(o)}paintImageMaskXObject(t){const e=this.current,s=t.width,i=t.height,n=e.fillColor;e.maskId="mask"+g++;const r=this.svgFactory.createElement("svg:mask");r.setAttributeNS(null,"id",e.maskId);const o=this.svgFactory.createElement("svg:rect");o.setAttributeNS(null,"x","0"),o.setAttributeNS(null,"y","0"),o.setAttributeNS(null,"width",a(s)),o.setAttributeNS(null,"height",a(i)),o.setAttributeNS(null,"fill",n),o.setAttributeNS(null,"mask",`url(#${e.maskId})`),this.defs.appendChild(r),this._ensureTransformGroup().appendChild(o),this.paintInlineImageXObject(t,r)}paintFormXObjectBegin(t,e){if(Array.isArray(t)&&6===t.length&&this.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e){const t=e[2]-e[0],s=e[3]-e[1],i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x",e[0]),i.setAttributeNS(null,"y",e[1]),i.setAttributeNS(null,"width",a(t)),i.setAttributeNS(null,"height",a(s)),this.current.element=i,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(t){const e=this.svgFactory.create(t.width,t.height),s=this.svgFactory.createElement("svg:defs");e.appendChild(s),this.defs=s;const i=this.svgFactory.createElement("svg:g");return i.setAttributeNS(null,"transform",h(t.transform)),e.appendChild(i),this.svg=i,e}_ensureClipGroup(){if(!this.current.clipGroup){const t=this.svgFactory.createElement("svg:g");t.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.appendChild(t),this.current.clipGroup=t}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",h(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().appendChild(this.tgrp):this.svg.appendChild(this.tgrp)),this.tgrp}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFNodeStream=void 0;var i=s(2),n=s(24);const r=require$$5,o=require$$5,a=require$$5,h=require$$5,c=/^file:\/\/\/[a-zA-Z]:\//;e.PDFNodeStream=class{constructor(t){this.source=t,this.url=function(t){const e=h.parse(t);return"file:"===e.protocol||e.host?e:/^[a-z]:[/\\]/i.test(t)?h.parse(`file:///${t}`):(e.host||(e.protocol="file:"),e)}(t.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new g(this):new f(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new b(this,t,e):new p(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class l{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=(0,i.createPromiseCapability)(),this._headersCapability=(0,i.createPromiseCapability)()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=t.length,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class d{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=(0,i.createPromiseCapability)(),this._isStreamingSupported=!t.source.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=t.length,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}function u(t,e){return{protocol:t.protocol,auth:t.auth,host:t.hostname,port:t.port,path:t.path,method:"GET",headers:e}}class f extends l{constructor(t){super(t);const e=e=>{if(404===e.statusCode){const t=new i.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=t,void this._headersCapability.reject(t)}this._headersCapability.resolve(),this._setReadableStream(e);const s=t=>this._readableStream.headers[t.toLowerCase()],{allowRangeRequests:r,suggestedLength:o}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:s,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=o||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(s)};this._request=null,this._request="http:"===this._url.protocol?o.request(u(this._url,t.httpHeaders),e):a.request(u(this._url,t.httpHeaders),e),this._request.on("error",(t=>{this._storedError=t,this._headersCapability.reject(t)})),this._request.end()}}class p extends d{constructor(t,e,s){super(t),this._httpHeaders={};for(const e in t.httpHeaders){const s=t.httpHeaders[e];void 0!==s&&(this._httpHeaders[e]=s)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const n=t=>{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=t}};this._request=null,this._request="http:"===this._url.protocol?o.request(u(this._url,this._httpHeaders),n):a.request(u(this._url,this._httpHeaders),n),this._request.on("error",(t=>{this._storedError=t})),this._request.end()}}class g extends l{constructor(t){super(t);let e=decodeURIComponent(this._url.path);c.test(this._url.href)&&(e=e.replace(/^\//,"")),r.lstat(e,((t,s)=>{if(t)return"ENOENT"===t.code&&(t=new i.MissingPDFException(`Missing PDF "${e}".`)),this._storedError=t,void this._headersCapability.reject(t);this._contentLength=s.size,this._setReadableStream(r.createReadStream(e)),this._headersCapability.resolve()}))}}class b extends d{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);c.test(this._url.href)&&(i=i.replace(/^\//,"")),this._setReadableStream(r.createReadStream(i,{start:e,end:s-1}))}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createResponseStatusError=function(t,e){return 404===t||0===t&&e.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+e+'".'):new i.UnexpectedResponseException(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)},e.extractFilenameFromHeader=function(t){const e=t("Content-Disposition");if(e){let t=(0,n.getFilenameFromContentDispositionHeader)(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch(t){}if((0,r.isPdfFile)(t))return t}return null},e.validateRangeRequestCapabilities=function({getResponseHeader:t,isHttp:e,rangeChunkSize:s,disableRange:n}){(0,i.assert)(s>0,"Range chunk size must be larger than zero");const r={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(t("Content-Length"),10);return Number.isInteger(o)?(r.suggestedLength=o,o<=2*s||n||!e||"bytes"!==t("Accept-Ranges")||"identity"!==(t("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r):r},e.validateResponseStatus=function(t){return 200===t||206===t};var i=s(2),n=s(25),r=s(1)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getFilenameFromContentDispositionHeader=function(t){let e=!0,s=n("filename\\*","i").exec(t);if(s){s=s[1];let t=a(s);return t=unescape(t),t=h(t),t=c(t),o(t)}if(s=function(t){const e=[];let s;const i=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(s=i.exec(t));){let[,t,i,n]=s;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[i,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[s,i]=e[t];i=a(i),s&&(i=unescape(i),0===t&&(i=h(i))),r.push(i)}return r.join("")}(t),s)return o(c(s));if(s=n("filename","i").exec(t),s){s=s[1];let t=a(s);return t=c(t),o(t)}function n(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function r(t,s){if(t){if(!/^[\x00-\xFF]+$/.test(s))return s;try{const n=new TextDecoder(t,{fatal:!0}),r=(0,i.stringToBytes)(s);s=n.decode(r),e=!1}catch(i){if(/^utf-?8$/i.test(t))try{s=decodeURIComponent(escape(s)),e=!1}catch(t){}}}return s}function o(t){return e&&/[\x80-\xff]/.test(t)&&(t=r("utf-8",t),e&&(t=r("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const s=e[t].indexOf('"');-1!==s&&(e[t]=e[t].slice(0,s),e.length=t+1),e[t]=e[t].replace(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){const e=t.indexOf("'");return-1===e?t:r(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function c(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,s,i){if("q"===s||"Q"===s)return r(e,i=(i=i.replace(/_/g," ")).replace(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{i=atob(i)}catch(t){}return r(e,i)}))}return""};var i=s(2)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFNetworkStream=void 0;var i=s(2),n=s(24);class r{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.getXhr=e.getXhr||function(){return new XMLHttpRequest},this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const t in s)i[t]=s[t];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=this.getXhr(),s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const t in this.httpHeaders){const s=this.httpHeaders[t];void 0!==s&&e.setRequestHeader(t,s)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const n=s.xhr;if(n.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==n.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===n.status&&this.isHttp)return void s.onError?.(n.status);const r=n.status||200;if((200!==r||206!==s.expectedStatus)&&r!==s.expectedStatus)return void s.onError?.(n.status);const o=function(t){const e=t.response;return"string"!=typeof e?e:(0,i.stringToBytes)(e).buffer}(n);if(206===r){const t=n.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);s.onDone({begin:parseInt(e[1],10),chunk:o})}else o?s.onDone({begin:0,chunk:o}):s.onError?.(n.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}e.PDFNetworkStream=class{constructor(t){this._source=t,this._manager=new r(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new o(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new a(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class o{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=(0,i.createPromiseCapability)(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=t=>e.getResponseHeader(t),{allowRangeRequests:i,suggestedLength:r}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=(0,n.createResponseStatusError)(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class a{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=(0,n.createResponseStatusError)(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFFetchStream=void 0;var i=s(2),n=s(24);function r(t,e,s){return{method:"GET",headers:t,signal:s?.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function o(t){const e=new Headers;for(const s in t){const i=t[s];void 0!==i&&e.append(s,i)}return e}e.PDFFetchStream=class{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new a(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new h(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class a{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=(0,i.createPromiseCapability)(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),"undefined"!=typeof AbortController&&(this._abortController=new AbortController),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._headers=o(this._stream.httpHeaders);const s=e.url;fetch(s,r(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,n.validateResponseStatus)(t.status))throw(0,n.createResponseStatusError)(t.status,s);this._reader=t.body.getReader(),this._headersCapability.resolve();const e=e=>t.headers.get(e),{allowRangeRequests:r,suggestedLength:o}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=o||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._reader&&this._reader.cancel(t),this._abortController&&this._abortController.abort()}}class h{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const a=t.source;this._withCredentials=a.withCredentials||!1,this._readCapability=(0,i.createPromiseCapability)(),this._isStreamingSupported=!a.disableStream,"undefined"!=typeof AbortController&&(this._abortController=new AbortController),this._headers=o(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const h=a.url;fetch(h,r(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,n.validateResponseStatus)(t.status))throw(0,n.createResponseStatusError)(t.status,h);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._reader&&this._reader.cancel(t),this._abortController&&this._abortController.abort()}}}],__webpack_module_cache__={};function __w_pdfjs_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var s=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](s,s.exports,__w_pdfjs_require__),s.exports}var __webpack_exports__={};return(()=>{var t=__webpack_exports__;Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"AnnotationLayer",{enumerable:!0,get:function(){return n.AnnotationLayer}}),Object.defineProperty(t,"AnnotationMode",{enumerable:!0,get:function(){return s.AnnotationMode}}),Object.defineProperty(t,"CMapCompressionType",{enumerable:!0,get:function(){return s.CMapCompressionType}}),Object.defineProperty(t,"GlobalWorkerOptions",{enumerable:!0,get:function(){return r.GlobalWorkerOptions}}),Object.defineProperty(t,"InvalidPDFException",{enumerable:!0,get:function(){return s.InvalidPDFException}}),Object.defineProperty(t,"LinkTarget",{enumerable:!0,get:function(){return e.LinkTarget}}),Object.defineProperty(t,"LoopbackPort",{enumerable:!0,get:function(){return i.LoopbackPort}}),Object.defineProperty(t,"MissingPDFException",{enumerable:!0,get:function(){return s.MissingPDFException}}),Object.defineProperty(t,"OPS",{enumerable:!0,get:function(){return s.OPS}}),Object.defineProperty(t,"PDFDataRangeTransport",{enumerable:!0,get:function(){return i.PDFDataRangeTransport}}),Object.defineProperty(t,"PDFDateString",{enumerable:!0,get:function(){return e.PDFDateString}}),Object.defineProperty(t,"PDFWorker",{enumerable:!0,get:function(){return i.PDFWorker}}),Object.defineProperty(t,"PasswordResponses",{enumerable:!0,get:function(){return s.PasswordResponses}}),Object.defineProperty(t,"PermissionFlag",{enumerable:!0,get:function(){return s.PermissionFlag}}),Object.defineProperty(t,"PixelsPerInch",{enumerable:!0,get:function(){return e.PixelsPerInch}}),Object.defineProperty(t,"RenderingCancelledException",{enumerable:!0,get:function(){return e.RenderingCancelledException}}),Object.defineProperty(t,"SVGGraphics",{enumerable:!0,get:function(){return h.SVGGraphics}}),Object.defineProperty(t,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return s.UNSUPPORTED_FEATURES}}),Object.defineProperty(t,"UnexpectedResponseException",{enumerable:!0,get:function(){return s.UnexpectedResponseException}}),Object.defineProperty(t,"Util",{enumerable:!0,get:function(){return s.Util}}),Object.defineProperty(t,"VerbosityLevel",{enumerable:!0,get:function(){return s.VerbosityLevel}}),Object.defineProperty(t,"XfaLayer",{enumerable:!0,get:function(){return c.XfaLayer}}),Object.defineProperty(t,"addLinkAttributes",{enumerable:!0,get:function(){return e.addLinkAttributes}}),Object.defineProperty(t,"build",{enumerable:!0,get:function(){return i.build}}),Object.defineProperty(t,"createObjectURL",{enumerable:!0,get:function(){return s.createObjectURL}}),Object.defineProperty(t,"createPromiseCapability",{enumerable:!0,get:function(){return s.createPromiseCapability}}),Object.defineProperty(t,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return s.createValidAbsoluteUrl}}),Object.defineProperty(t,"getDocument",{enumerable:!0,get:function(){return i.getDocument}}),Object.defineProperty(t,"getFilenameFromUrl",{enumerable:!0,get:function(){return e.getFilenameFromUrl}}),Object.defineProperty(t,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return e.getPdfFilenameFromUrl}}),Object.defineProperty(t,"getXfaPageViewport",{enumerable:!0,get:function(){return e.getXfaPageViewport}}),Object.defineProperty(t,"isPdfFile",{enumerable:!0,get:function(){return e.isPdfFile}}),Object.defineProperty(t,"loadScript",{enumerable:!0,get:function(){return e.loadScript}}),Object.defineProperty(t,"removeNullCharacters",{enumerable:!0,get:function(){return s.removeNullCharacters}}),Object.defineProperty(t,"renderTextLayer",{enumerable:!0,get:function(){return a.renderTextLayer}}),Object.defineProperty(t,"shadow",{enumerable:!0,get:function(){return s.shadow}}),Object.defineProperty(t,"version",{enumerable:!0,get:function(){return i.version}});var e=__w_pdfjs_require__(1),s=__w_pdfjs_require__(2),i=__w_pdfjs_require__(6),n=__w_pdfjs_require__(18),r=__w_pdfjs_require__(12),o=__w_pdfjs_require__(4),a=__w_pdfjs_require__(21),h=__w_pdfjs_require__(22),c=__w_pdfjs_require__(20);if(o.isNodeJS){const{PDFNodeStream:t}=__w_pdfjs_require__(23);(0,i.setPDFNetworkStreamFactory)((e=>new t(e)))}else{const{PDFNetworkStream:t}=__w_pdfjs_require__(26),{PDFFetchStream:s}=__w_pdfjs_require__(27);(0,i.setPDFNetworkStreamFactory)((i=>(0,e.isValidFetchUrl)(i.url)?new s(i):new t(i)))}})(),__webpack_exports__})()},module.exports=factory()}));const pdf$1=getDefaultExportFromCjs(pdf),integerSequence=(t,e)=>Array(e).fill(1).map(((e,s)=>s+t)),verdocsViewCss='verdocs-view{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:-ms-flexbox;display:flex;background:#ccc;min-height:600px;position:relative;padding:0 0 20px 0;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-view div,verdocs-view canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-view .container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column}verdocs-view button.test{color:#fff;cursor:pointer;padding:5px 10px;border-radius:4px;background:#5a5767;border:1px solid #ccc}verdocs-view .load-progress{position:absolute;top:0;left:0;right:0;height:6px;z-index:2000;background:#000}verdocs-view .load-progress .bar{height:6px;background:#50be80}#verdocs-pdf-viewer-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column}#verdocs-pdf-viewer-container canvas{background:white;max-width:100%;margin:15px 0 0 0}',CANVAS_MARGIN=15,PDF_WORKER_URL=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdf.version}/pdf.worker.min.js`,CMAPS_URL=`https://unpkg.com/pdfjs-dist@${pdf.version}/cmaps/`;console.log("[VIEW] Loading PDF-JS",{PDF_WORKER_URL,CMAPS_URL}),pdf$1.GlobalWorkerOptions.workerSrc=PDF_WORKER_URL;const VerdocsView=class{constructor(t){registerInstance(this,t),this.pageRendered=createEvent(this,"pageRendered",7),this.pageLoaded=createEvent(this,"pageLoaded",7),this.pageChange=createEvent(this,"pageChange",7),this.pageInit=createEvent(this,"pageInit",7),this.scaleChange=createEvent(this,"scaleChange",7),this.documentRendered=createEvent(this,"documentRendered",7),this.numPages=1,this.fingerprint=null,this.endpoint=VerdocsEndpoint.getDefault(),this.rotation=0,this.token=null,this.loadProgress=0,this.pagesRendered=[]}doSrc(t,e){t!==e&&this.loadAndRender(t)}isRotated(t){return 0!==t&&t%180!=0}async renderPages(){const t=integerSequence(1,this.numPages);for await(let e of t){const t=e-1;console.log("[VIEW] Rendering page",e);const s=await this.pdfDocument.getPage(e),[i,n,r,o]=s.view,a=s.rotate,h=s.getViewport({scale:1/.75}),c=document.createElement("canvas"),l=c.getContext("2d");c.height=h.height,c.width=h.width,await s.render({canvasContext:l,viewport:h}),this.pdfContainer.appendChild(c);const d=c.width,u=c.height,f=r-i,p=o-n;this.pagesRendered.sort(((t,e)=>t.pageNumber-e.pageNumber));const g=this.pagesRendered.filter((t=>t.pageNumber<e)).pop(),b=((null==g?void 0:g.canvasBottom)||0)+CANVAS_MARGIN,A={pageNumber:e,width:d,height:u,originalWidth:this.isRotated(a)?p:f,originalHeight:this.isRotated(a)?f:p,xRatio:d/f,yRatio:u/p,canvasTop:b,canvasLeft:CANVAS_MARGIN,canvasRight:CANVAS_MARGIN+d,canvasBottom:b+u};this.pagesRendered[t]?this.pagesRendered[t]=A:this.pagesRendered.push(A);const m={pages:this.pagesRendered,numPages:this.numPages,numRendered:this.pagesRendered.length,canvasContainer:this.pdfContainer};this.pageRendered.emit(m),e>=this.numPages&&(console.log("[VIEW] Done rendering"),this.pagesRendered.sort(((t,e)=>t.pageNumber-e.pageNumber)),this.documentRendered.emit(m))}}componentDidLoad(){this.pdfContainer=document.getElementById("verdocs-pdf-viewer-container"),this.source&&this.loadAndRender(this.source)}onProgress(t){this.loadProgress=Math.floor(100*t.loaded/t.total)}loadAndRender(t){console.log("[VIEW] Loading",t);const e=pdf$1.getDocument({url:t,withCredentials:!0,cMapUrl:CMAPS_URL,cMapPacked:!0,verbosity:pdf.VerbosityLevel.WARNINGS,httpHeaders:this.token?{Authorization:`Bearer ${this.token}`}:{}},null,null,this.onProgress);e.onProgress=this.onProgress,e.promise.then((t=>{this.loadProgress=100,this.numPages=t.numPages,this.fingerprint=t.fingerprints[0],console.log(`[VIEW] Got PDF document fingerprint "${this.fingerprint}, ${this.numPages} pages`,t),this.pdfDocument=t,this.renderPages().catch((t=>console.log("Rendering error",t)))}))}render(){return h("div",{class:"container"},this.loadProgress<100?h("verdocs-loader",null):h("div",{style:{display:"none"}}),h("div",{id:"verdocs-pdf-viewer-container"}))}get component(){return getElement(this)}static get watchers(){return{source:["doSrc"]}}};VerdocsView.style=verdocsViewCss;export{VerdocsDropdown as verdocs_dropdown,VerdocsFieldAttachment as verdocs_field_attachment,VerdocsFieldCheckbox as verdocs_field_checkbox,VerdocsFieldDate as verdocs_field_date,VerdocsFieldDropdown as verdocs_field_dropdown,VerdocsFieldInitial as verdocs_field_initial,VerdocsFieldPayment as verdocs_field_payment,VerdocsFieldRadioButton as verdocs_field_radio_button,VerdocsFieldSignature as verdocs_field_signature,VerdocsFieldTextarea as verdocs_field_textarea,VerdocsFieldTextbox as verdocs_field_textbox,VerdocsView as verdocs_view}
|
|
23
|
+
var factory;factory=function(){return(()=>{var __webpack_modules__=[,(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StatTimer=e.RenderingCancelledException=e.PixelsPerInch=e.PageViewport=e.PDFDateString=e.LinkTarget=e.DOMStandardFontDataFactory=e.DOMSVGFactory=e.DOMCanvasFactory=e.DOMCMapReaderFactory=void 0,e.addLinkAttributes=function(t,{url:e,target:s,rel:n,enabled:r=!0}={}){(0,i.assert)(e&&"string"==typeof e,'addLinkAttributes: A valid "url" parameter must provided.');const o=(0,i.removeNullCharacters)(e);r?t.href=t.title=o:(t.href="",t.title=`Disabled: ${o}`,t.onclick=()=>!1);let h="";switch(s){case a.NONE:break;case a.SELF:h="_self";break;case a.BLANK:h="_blank";break;case a.PARENT:h="_parent";break;case a.TOP:h="_top"}t.target=h,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"},e.deprecated=function(t){console.log("Deprecated API usage: "+t)},e.getFilenameFromUrl=function(t){const e=t.indexOf("#"),s=t.indexOf("?"),i=Math.min(e>0?e:t.length,s>0?s:t.length);return t.substring(t.lastIndexOf("/",i)+1,i)},e.getPdfFilenameFromUrl=function(t,e="document.pdf"){if("string"!=typeof t)return e;if(h(t))return(0,i.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let r=s.exec(n[1])||s.exec(n[2])||s.exec(n[3]);if(r&&(r=r[0],r.includes("%")))try{r=s.exec(decodeURIComponent(r))[0]}catch(t){}return r||e},e.getXfaPageViewport=function(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style,r=[0,0,parseInt(i),parseInt(n)];return new o({viewBox:r,scale:e,rotation:s})},e.isDataScheme=h,e.isPdfFile=function(t){return"string"==typeof t&&/\.pdf$/i.test(t)},e.isValidFetchUrl=c,e.loadScript=function(t,e=!1){return new Promise(((s,i)=>{const n=document.createElement("script");n.src=t,n.onload=function(t){e&&n.remove(),s(t)},n.onerror=function(){i(new Error(`Cannot load script at: ${n.src}`))},(document.head||document.documentElement).appendChild(n)}))};var i=s(2),n=s(5);async function r(t,e=!1){if(c(t,document.baseURI)){const s=await fetch(t);if(!s.ok)throw new Error(s.statusText);return e?new Uint8Array(await s.arrayBuffer()):(0,i.stringToBytes)(await s.text())}return new Promise(((s,n)=>{const r=new XMLHttpRequest;r.open("GET",t,!0),e&&(r.responseType="arraybuffer"),r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){let t;if(e&&r.response?t=new Uint8Array(r.response):!e&&r.responseText&&(t=(0,i.stringToBytes)(r.responseText)),t)return void s(t)}n(new Error(r.statusText))}},r.send(null)}))}e.PixelsPerInch={CSS:96,PDF:72,get PDF_TO_CSS_UNITS(){return(0,i.shadow)(this,"PDF_TO_CSS_UNITS",this.CSS/this.PDF)}},e.DOMCanvasFactory=class extends n.BaseCanvasFactory{constructor({ownerDocument:t=globalThis.document}={}){super(),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},e.DOMCMapReaderFactory=class extends n.BaseCMapReaderFactory{_fetchData(t,e){return r(t,this.isCompressed).then((t=>({cMapData:t,compressionType:e})))}},e.DOMStandardFontDataFactory=class extends n.BaseStandardFontDataFactory{_fetchData(t){return r(t,!0)}},e.DOMSVGFactory=class extends n.BaseSVGFactory{_createSVG(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}};class o{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const o=(t[2]+t[0])/2,a=(t[3]+t[1])/2;let h,c,l,d,u,f,p,g;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,l=0,d=1;break;case 90:h=0,c=1,l=1,d=0;break;case 270:h=0,c=-1,l=-1,d=0;break;case 0:h=1,c=0,l=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(l=-l,d=-d),0===h?(u=Math.abs(a-t[1])*e+i,f=Math.abs(o-t[0])*e+n,p=Math.abs(t[3]-t[1])*e,g=Math.abs(t[2]-t[0])*e):(u=Math.abs(o-t[0])*e+i,f=Math.abs(a-t[1])*e+n,p=Math.abs(t[2]-t[0])*e,g=Math.abs(t[3]-t[1])*e),this.transform=[h*e,c*e,l*e,d*e,u-h*e*o-l*e*a,f-c*e*o-d*e*a],this.width=p,this.height=g}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new o({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return i.Util.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=i.Util.applyTransform([t[0],t[1]],this.transform),s=i.Util.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return i.Util.applyInverseTransform([t,e],this.transform)}}e.PageViewport=o,e.RenderingCancelledException=class extends i.BaseException{constructor(t,e){super(t,"RenderingCancelledException"),this.type=e}};const a={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};function h(t){const e=t.length;let s=0;for(;s<e&&""===t[s].trim();)s++;return"data:"===t.substring(s,s+5).toLowerCase()}function c(t,e){try{const{protocol:s}=e?new URL(t,e):new URL(t);return"http:"===s||"https:"===s}catch(t){return!1}}let l;e.LinkTarget=a,e.StatTimer=class{constructor(){this.started=Object.create(null),this.times=[]}time(t){t in this.started&&(0,i.warn)(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||(0,i.warn)(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const t of this.times){const s=t.name;s.length>e&&(e=s.length)}for(const s of this.times){const i=s.end-s.start;t.push(`${s.name.padEnd(e)} ${i}ms\n`)}return t.join("")}},e.PDFDateString=class{static toDateObject(t){if(!t||!(0,i.isString)(t))return null;l||(l=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=l.exec(t);if(!e)return null;const s=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(e[4],10);o=o>=0&&o<=23?o:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const c=e[7]||"Z";let d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,"-"===c?(o+=d,a+=u):"+"===c&&(o-=d,a-=u),new Date(Date.UTC(s,n,r,o,a,h))}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VerbosityLevel=e.Util=e.UnknownErrorException=e.UnexpectedResponseException=e.UNSUPPORTED_FEATURES=e.TextRenderingMode=e.StreamType=e.RenderingIntentFlag=e.PermissionFlag=e.PasswordResponses=e.PasswordException=e.PageActionEventType=e.OPS=e.MissingPDFException=e.IsLittleEndianCached=e.IsEvalSupportedCached=e.InvalidPDFException=e.ImageKind=e.IDENTITY_MATRIX=e.FormatError=e.FontType=e.FONT_IDENTITY_MATRIX=e.DocumentActionEventType=e.CMapCompressionType=e.BaseException=e.AnnotationType=e.AnnotationStateModelType=e.AnnotationReviewState=e.AnnotationReplyType=e.AnnotationMode=e.AnnotationMarkedState=e.AnnotationFlag=e.AnnotationFieldFlag=e.AnnotationBorderStyleType=e.AnnotationActionEventType=e.AbortException=void 0,e.arrayByteLength=f,e.arraysToBytes=function(t){const e=t.length;if(1===e&&t[0]instanceof Uint8Array)return t[0];let s=0;for(let i=0;i<e;i++)s+=f(t[i]);let i=0;const n=new Uint8Array(s);for(let s=0;s<e;s++){let e=t[s];e instanceof Uint8Array||(e="string"==typeof e?u(e):new Uint8Array(e));const r=e.byteLength;n.set(e,i),i+=r}return n},e.assert=a,e.bytesToString=function(t){a(null!==t&&"object"==typeof t&&void 0!==t.length,"Invalid argument for bytesToString");const e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);const i=[];for(let n=0;n<e;n+=s){const r=Math.min(n+s,e),o=t.subarray(n,r);i.push(String.fromCharCode.apply(null,o))}return i.join("")},e.createObjectURL=function(t,e="",s=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!s)return URL.createObjectURL(new Blob([t],{type:e}));const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let n=`data:${e};base64,`;for(let e=0,s=t.length;e<s;e+=3){const r=255&t[e],o=255&t[e+1],a=255&t[e+2];n+=i[r>>2]+i[(3&r)<<4|o>>4]+i[e+1<s?(15&o)<<2|a>>6:64]+i[e+2<s?63&a:64]}return n},e.createPromiseCapability=function(){const t=Object.create(null);let e=!1;return Object.defineProperty(t,"settled",{get:()=>e}),t.promise=new Promise((function(s,i){t.resolve=function(t){e=!0,s(t)},t.reject=function(t){e=!0,i(t)}})),t},e.createValidAbsoluteUrl=function(t,e=null,s=null){if(!t)return null;try{if(s&&"string"==typeof t){if(s.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e&&e.length>=2&&(t=`http://${t}`)}if(s.tryConvertEncoding)try{t=A(t)}catch(t){}}const i=e?new URL(t,e):new URL(t);if(function(t){if(!t)return!1;switch(t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(t){}return null},e.escapeString=function(t){return t.replace(/([()\\\n\r])/g,(t=>"\n"===t?"\\n":"\r"===t?"\\r":`\\${t}`))},e.getModificationDate=function(t=new Date){return[t.getUTCFullYear().toString(),(t.getUTCMonth()+1).toString().padStart(2,"0"),t.getUTCDate().toString().padStart(2,"0"),t.getUTCHours().toString().padStart(2,"0"),t.getUTCMinutes().toString().padStart(2,"0"),t.getUTCSeconds().toString().padStart(2,"0")].join("")},e.getVerbosityLevel=function(){return n},e.info=function(t){n>=i.INFOS&&console.log(`Info: ${t}`)},e.isArrayBuffer=function(t){return"object"==typeof t&&null!==t&&void 0!==t.byteLength},e.isArrayEqual=function(t,e){if(t.length!==e.length)return!1;for(let s=0,i=t.length;s<i;s++)if(t[s]!==e[s])return!1;return!0},e.isAscii=function(t){return/^[\x00-\x7F]*$/.test(t)},e.isBool=function(t){return"boolean"==typeof t},e.isNum=function(t){return"number"==typeof t},e.isSameOrigin=function(t,e){let s;try{if(s=new URL(t),!s.origin||"null"===s.origin)return!1}catch(t){return!1}const i=new URL(e,s);return s.origin===i.origin},e.isString=function(t){return"string"==typeof t},e.objectFromMap=function(t){const e=Object.create(null);for(const[s,i]of t)e[s]=i;return e},e.objectSize=function(t){return Object.keys(t).length},e.removeNullCharacters=function(t,e=!1){return"string"!=typeof t?(r("The argument for removeNullCharacters must be a string."),t):(e&&(t=t.replace(d," ")),t.replace(l,""))},e.setVerbosityLevel=function(t){Number.isInteger(t)&&(n=t)},e.shadow=h,e.string32=function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)},e.stringToBytes=u,e.stringToPDFString=function(t){const e=t.length,s=[];if("þ"===t[0]&&"ÿ"===t[1])for(let i=2;i<e;i+=2)s.push(String.fromCharCode(t.charCodeAt(i)<<8|t.charCodeAt(i+1)));else if("ÿ"===t[0]&&"þ"===t[1])for(let i=2;i<e;i+=2)s.push(String.fromCharCode(t.charCodeAt(i+1)<<8|t.charCodeAt(i)));else for(let i=0;i<e;++i){const e=b[t.charCodeAt(i)];s.push(e?String.fromCharCode(e):t.charAt(i))}return s.join("")},e.stringToUTF16BEString=function(t){const e=["þÿ"];for(let s=0,i=t.length;s<i;s++){const i=t.charCodeAt(s);e.push(String.fromCharCode(i>>8&255),String.fromCharCode(255&i))}return e.join("")},e.stringToUTF8String=A,e.unreachable=o,e.utf8StringToString=function(t){return unescape(encodeURIComponent(t))},e.warn=r,s(3),e.IDENTITY_MATRIX=[1,0,0,1,0,0],e.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0],e.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},e.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},e.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},e.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},e.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},e.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},e.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"},e.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"},e.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"},e.AnnotationReplyType={GROUP:"Group",REPLY:"R"},e.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512},e.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864},e.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},e.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"},e.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},e.PageActionEventType={O:"PageOpen",C:"PageClose"},e.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"},e.FontType={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1STANDARD:"TYPE1STANDARD",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const i={ERRORS:0,WARNINGS:1,INFOS:5};e.VerbosityLevel=i,e.CMapCompressionType={NONE:0,BINARY:1,STREAM:2},e.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},e.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",signatures:"signatures",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"},e.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let n=i.WARNINGS;function r(t){n>=i.WARNINGS&&console.log(`Warning: ${t}`)}function o(t){throw new Error(t)}function a(t,e){t||o(e)}function h(t,e,s){return Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!1}),s}const c=function(){function t(e,s){this.constructor===t&&o("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();e.BaseException=c,e.PasswordException=class extends c{constructor(t,e){super(t,"PasswordException"),this.code=e}},e.UnknownErrorException=class extends c{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},e.InvalidPDFException=class extends c{constructor(t){super(t,"InvalidPDFException")}},e.MissingPDFException=class extends c{constructor(t){super(t,"MissingPDFException")}},e.UnexpectedResponseException=class extends c{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},e.FormatError=class extends c{constructor(t){super(t,"FormatError")}},e.AbortException=class extends c{constructor(t){super(t,"AbortException")}};const l=/\x00+/g,d=/[\x01-\x1F]/g;function u(t){a("string"==typeof t,"Invalid argument for stringToBytes");const e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=255&t.charCodeAt(i);return s}function f(t){return void 0!==t.length?t.length:(a(void 0!==t.byteLength,"arrayByteLength - invalid argument."),t.byteLength)}e.IsLittleEndianCached={get value(){return h(this,"value",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}},e.IsEvalSupportedCached={get value(){return h(this,"value",function(){try{return new Function(""),!0}catch(t){return!1}}())}};const p=[...Array(256).keys()].map((t=>t.toString(16).padStart(2,"0")));class g{static makeHexColor(t,e,s){return`#${p[t]}${p[e]}${p[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}static getAxialAlignedBoundingBox(t,e){const s=g.applyTransform(t,e),i=g.applyTransform(t.slice(2,4),e),n=g.applyTransform([t[0],t[3]],e),r=g.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static apply3dTransform(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[3]*e[0]+t[4]*e[1]+t[5]*e[2],t[6]*e[0]+t[7]*e[1]+t[8]*e[2]]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[2]*e[1]+t[3]*e[3],n=(s+i)/2,r=Math.sqrt((s+i)**2-4*(s*i-(t[2]*e[0]+t[3]*e[2])*(t[0]*e[1]+t[1]*e[3])))/2,o=n-r||1;return[Math.sqrt(n+r||1),Math.sqrt(o)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){function s(t,e){return t-e}const i=[t[0],t[2],e[0],e[2]].sort(s),n=[t[1],t[3],e[1],e[3]].sort(s),r=[];return t=g.normalizeRect(t),e=g.normalizeRect(e),i[0]===t[0]&&i[1]===e[0]||i[0]===e[0]&&i[1]===t[0]?(r[0]=i[1],r[2]=i[2],n[0]===t[1]&&n[1]===e[1]||n[0]===e[1]&&n[1]===t[1]?(r[1]=n[1],r[3]=n[2],r):null):null}static bezierBoundingBox(t,e,s,i,n,r,o,a){const h=[],c=[[],[]];let l,d,u,f,p,g,b,A;for(let c=0;c<2;++c)if(0===c?(d=6*t-12*s+6*n,l=-3*t+9*s-9*n+3*o,u=3*s-3*t):(d=6*e-12*i+6*r,l=-3*e+9*i-9*r+3*a,u=3*i-3*e),Math.abs(l)<1e-12){if(Math.abs(d)<1e-12)continue;f=-u/d,0<f&&f<1&&h.push(f)}else b=d*d-4*u*l,A=Math.sqrt(b),b<0||(p=(-d+A)/(2*l),0<p&&p<1&&h.push(p),g=(-d-A)/(2*l),0<g&&g<1&&h.push(g));let m,w=h.length;const v=w;for(;w--;)f=h[w],m=1-f,c[0][w]=m*m*m*t+3*m*m*f*s+3*m*f*f*n+f*f*f*o,c[1][w]=m*m*m*e+3*m*m*f*i+3*m*f*f*r+f*f*f*a;return c[0][v]=t,c[1][v]=e,c[0][v+1]=o,c[1][v+1]=a,c[0].length=c[1].length=v+2,[Math.min(...c[0]),Math.min(...c[1]),Math.max(...c[0]),Math.max(...c[1])]}}e.Util=g;const b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function A(t){return decodeURIComponent(escape(t))}},(t,e,s)=>{s(4)},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNodeJS=void 0,e.isNodeJS=!("object"!=typeof process_1||process_1+""!="[object process]"||process_1.versions.nw||process_1.versions.electron&&process_1.type&&"browser"!==process_1.type)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseStandardFontDataFactory=e.BaseSVGFactory=e.BaseCanvasFactory=e.BaseCMapReaderFactory=void 0;var i=s(2);class n{constructor(){this.constructor===n&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d")}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}e.BaseCanvasFactory=n;class r{constructor({baseUrl:t=null,isCompressed:e=!1}){this.constructor===r&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetchData(e,this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE).catch((()=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(t,e){(0,i.unreachable)("Abstract method `_fetchData` called.")}}e.BaseCMapReaderFactory=r;class o{constructor({baseUrl:t=null}){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch((()=>{throw new Error(`Unable to load font data at: ${e}`)}))}_fetchData(t){(0,i.unreachable)("Abstract method `_fetchData` called.")}}e.BaseStandardFontDataFactory=o;class a{constructor(){this.constructor===a&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(t,e){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){(0,i.unreachable)("Abstract method `_createSVG` called.")}}e.BaseSVGFactory=a},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=exports.RenderTask=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,exports.getDocument=getDocument,exports.setPDFNetworkStreamFactory=setPDFNetworkStreamFactory,exports.version=void 0;var _util=__w_pdfjs_require__(2),_display_utils=__w_pdfjs_require__(1),_font_loader=__w_pdfjs_require__(7),_node_utils=__w_pdfjs_require__(8),_annotation_storage=__w_pdfjs_require__(9),_canvas=__w_pdfjs_require__(10),_worker_options=__w_pdfjs_require__(12),_is_node=__w_pdfjs_require__(4),_message_handler=__w_pdfjs_require__(13),_metadata=__w_pdfjs_require__(14),_optional_content_config=__w_pdfjs_require__(15),_transport_stream=__w_pdfjs_require__(16),_xfa_text=__w_pdfjs_require__(17);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DefaultCanvasFactory=_is_node.isNodeJS?_node_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_is_node.isNodeJS?_node_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultStandardFontDataFactory=_is_node.isNodeJS?_node_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;let createPDFNetworkStream;function setPDFNetworkStreamFactory(t){createPDFNetworkStream=t}function getDocument(t){const e=new PDFDocumentLoadingTask;let s;if("string"==typeof t||t instanceof URL)s={url:t};else if((0,_util.isArrayBuffer)(t))s={data:t};else if(t instanceof PDFDataRangeTransport)s={range:t};else{if("object"!=typeof t)throw new Error("Invalid parameter in getDocument, need either string, URL, Uint8Array, or parameter object.");if(!t.url&&!t.data&&!t.range)throw new Error("Invalid parameter object: need either .data, .range or .url");s=t}const i=Object.create(null);let n=null,r=null;for(const t in s){const e=s[t];switch(t){case"url":if("undefined"!=typeof window)try{i[t]=new URL(e,window.location).href;continue}catch(t){(0,_util.warn)(`Cannot create valid URL: "${t}".`)}else if("string"==typeof e||e instanceof URL){i[t]=e.toString();continue}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.");case"range":n=e;continue;case"worker":r=e;continue;case"data":if(_is_node.isNodeJS&&void 0!==Buffer&&e instanceof Buffer)i[t]=new Uint8Array(e);else{if(e instanceof Uint8Array)break;if("string"==typeof e)i[t]=(0,_util.stringToBytes)(e);else if("object"!=typeof e||null===e||isNaN(e.length)){if(!(0,_util.isArrayBuffer)(e))throw new Error("Invalid PDF binary data: either typed array, string, or array-like object is expected in the data property.");i[t]=new Uint8Array(e)}else i[t]=new Uint8Array(e)}continue}i[t]=e}if(i.rangeChunkSize=i.rangeChunkSize||DEFAULT_RANGE_CHUNK_SIZE,i.CMapReaderFactory=i.CMapReaderFactory||DefaultCMapReaderFactory,i.StandardFontDataFactory=i.StandardFontDataFactory||DefaultStandardFontDataFactory,i.ignoreErrors=!0!==i.stopAtErrors,i.fontExtraProperties=!0===i.fontExtraProperties,i.pdfBug=!0===i.pdfBug,i.enableXfa=!0===i.enableXfa,("string"!=typeof i.docBaseUrl||(0,_display_utils.isDataScheme)(i.docBaseUrl))&&(i.docBaseUrl=null),Number.isInteger(i.maxImageSize)||(i.maxImageSize=-1),"boolean"!=typeof i.useWorkerFetch&&(i.useWorkerFetch=i.CMapReaderFactory===_display_utils.DOMCMapReaderFactory&&i.StandardFontDataFactory===_display_utils.DOMStandardFontDataFactory),"boolean"!=typeof i.isEvalSupported&&(i.isEvalSupported=!0),"boolean"!=typeof i.disableFontFace&&(i.disableFontFace=_is_node.isNodeJS),"boolean"!=typeof i.useSystemFonts&&(i.useSystemFonts=!_is_node.isNodeJS&&!i.disableFontFace),void 0===i.ownerDocument&&(i.ownerDocument=globalThis.document),"boolean"!=typeof i.disableRange&&(i.disableRange=!1),"boolean"!=typeof i.disableStream&&(i.disableStream=!1),"boolean"!=typeof i.disableAutoFetch&&(i.disableAutoFetch=!1),(0,_util.setVerbosityLevel)(i.verbosity),!r){const t={verbosity:i.verbosity,port:_worker_options.GlobalWorkerOptions.workerPort};r=t.port?PDFWorker.fromPort(t):new PDFWorker(t),e._worker=r}const o=e.docId;return r.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");const t=_fetchDocument(r,i,n,o),s=new Promise((function(t){let e;n?e=new _transport_stream.PDFDataTransportStream({length:i.length,initialData:i.initialData,progressiveDone:i.progressiveDone,contentDispositionFilename:i.contentDispositionFilename,disableRange:i.disableRange,disableStream:i.disableStream},n):i.data||(e=createPDFNetworkStream({url:i.url,length:i.length,httpHeaders:i.httpHeaders,withCredentials:i.withCredentials,rangeChunkSize:i.rangeChunkSize,disableRange:i.disableRange,disableStream:i.disableStream})),t(e)}));return Promise.all([t,s]).then((function([t,s]){if(e.destroyed)throw new Error("Loading aborted");const n=new _message_handler.MessageHandler(o,t,r.port),a=new WorkerTransport(n,e,s,i);e._transport=a,n.send("Ready",null)}))})).catch(e._capability.reject),e}async function _fetchDocument(t,e,s,i){if(t.destroyed)throw new Error("Worker was destroyed");s&&(e.length=s.length,e.initialData=s.initialData,e.progressiveDone=s.progressiveDone,e.contentDispositionFilename=s.contentDispositionFilename);const n=await t.messageHandler.sendWithPromise("GetDocRequest",{docId:i,apiVersion:"2.12.313",source:{data:e.data,url:e.url,password:e.password,disableAutoFetch:e.disableAutoFetch,rangeChunkSize:e.rangeChunkSize,length:e.length},maxImageSize:e.maxImageSize,disableFontFace:e.disableFontFace,docBaseUrl:e.docBaseUrl,ignoreErrors:e.ignoreErrors,isEvalSupported:e.isEvalSupported,fontExtraProperties:e.fontExtraProperties,enableXfa:e.enableXfa,useSystemFonts:e.useSystemFonts,cMapUrl:e.useWorkerFetch?e.cMapUrl:null,standardFontDataUrl:e.useWorkerFetch?e.standardFontDataUrl:null});if(t.destroyed)throw new Error("Worker was destroyed");return n}exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;class PDFDocumentLoadingTask{static get idCounters(){return(0,_util.shadow)(this,"idCounters",{doc:0})}constructor(){this._capability=(0,_util.createPromiseCapability)(),this._transport=null,this._worker=null,this.docId="d"+PDFDocumentLoadingTask.idCounters.doc++,this.destroyed=!1,this.onPassword=null,this.onProgress=null,this.onUnsupportedFeature=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,await(this._transport?.destroy()),this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const s of this._progressListeners)s(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(t,e){this._pdfInfo=t,this._transport=e,Object.defineProperty(this,"fingerprint",{get(){return(0,_display_utils.deprecated)("`PDFDocumentProxy.fingerprint`, please use `PDFDocumentProxy.fingerprints` instead."),this.fingerprints[0]}}),Object.defineProperty(this,"getStats",{value:async()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getStats`, please use the `PDFDocumentProxy.stats`-getter instead."),this.stats||{streamTypes:{},fontTypes:{}})})}get annotationStorage(){return this._transport.annotationStorage}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get stats(){return this._transport.stats}get isPureXfa(){return!!this._transport._htmlForXfa}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}saveDocument(){return this._transport.annotationStorage.size<=0&&(0,_display_utils.deprecated)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead."),this._transport.saveDocument()}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(t,e,s,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._ownerDocument=i,this._transport=s,this._stats=n?new _display_utils.StatTimer:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new PDFObjects,this.cleanupAfterRender=!1,this.pendingCleanup=!1,this._intentStates=new Map,this._annotationPromises=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const e=this._transport.getRenderingIntent(t);let s=this._annotationPromises.get(e.cacheKey);return s||(s=this._transport.getAnnotations(this._pageIndex,e.renderingIntent),this._annotationPromises.set(e.cacheKey,s),s=s.then((t=>{for(const e of t)void 0!==e.titleObj&&Object.defineProperty(e,"title",{get:()=>((0,_display_utils.deprecated)("`title`-property on annotation, please use `titleObj` instead."),e.titleObj.str)}),void 0!==e.contentsObj&&Object.defineProperty(e,"contents",{get:()=>((0,_display_utils.deprecated)("`contents`-property on annotation, please use `contentsObj` instead."),e.contentsObj.str)});return t}))),s}getJSActions(){return this._jsActionsPromise||=this._transport.getPageJSActions(this._pageIndex)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=_util.AnnotationMode.ENABLE,transform:n=null,imageLayer:r=null,canvasFactory:o=null,background:a=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null}){void 0!==arguments[0]?.renderInteractiveForms&&((0,_display_utils.deprecated)("render no longer accepts the `renderInteractiveForms`-option, please use the `annotationMode`-option instead."),!0===arguments[0].renderInteractiveForms&&i===_util.AnnotationMode.ENABLE&&(i=_util.AnnotationMode.ENABLE_FORMS)),void 0!==arguments[0]?.includeAnnotationStorage&&((0,_display_utils.deprecated)("render no longer accepts the `includeAnnotationStorage`-option, please use the `annotationMode`-option instead."),!0===arguments[0].includeAnnotationStorage&&i===_util.AnnotationMode.ENABLE&&(i=_util.AnnotationMode.ENABLE_STORAGE)),this._stats&&this._stats.time("Overall");const l=this._transport.getRenderingIntent(s,i);this.pendingCleanup=!1,h||(h=this._transport.getOptionalContentConfig());let d=this._intentStates.get(l.cacheKey);d||(d=Object.create(null),this._intentStates.set(l.cacheKey,d)),d.streamReaderCancelTimeout&&(clearTimeout(d.streamReaderCancelTimeout),d.streamReaderCancelTimeout=null);const u=o||new DefaultCanvasFactory({ownerDocument:this._ownerDocument}),f=!!(l.renderingIntent&_util.RenderingIntentFlag.PRINT);d.displayReadyCapability||(d.displayReadyCapability=(0,_util.createPromiseCapability)(),d.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(l));const p=t=>{d.renderTasks.delete(g),(this.cleanupAfterRender||f)&&(this.pendingCleanup=!0),this._tryCleanup(),t?(g.capability.reject(t),this._abortOperatorList({intentState:d,reason:t instanceof Error?t:new Error(t)})):g.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"))},g=new InternalRenderTask({callback:p,params:{canvasContext:t,viewport:e,transform:n,imageLayer:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:d.operatorList,pageIndex:this._pageIndex,canvasFactory:u,useRequestAnimationFrame:!f,pdfBug:this._pdfBug});(d.renderTasks||=new Set).add(g);const b=g.task;return Promise.all([d.displayReadyCapability.promise,h]).then((([t,e])=>{this.pendingCleanup?p():(this._stats&&this._stats.time("Rendering"),g.initializeGraphics({transparency:t,optionalContentConfig:e}),g.operatorListChanged())})).catch(p),b}getOperatorList({intent:t="display",annotationMode:e=_util.AnnotationMode.ENABLE}={}){const s=this._transport.getRenderingIntent(t,e,!0);let i,n=this._intentStates.get(s.cacheKey);return n||(n=Object.create(null),this._intentStates.set(s.cacheKey,n)),n.opListReadCapability||(i=Object.create(null),i.operatorListChanged=function(){n.operatorList.lastChunk&&(n.opListReadCapability.resolve(n.operatorList),n.renderTasks.delete(i))},n.opListReadCapability=(0,_util.createPromiseCapability)(),(n.renderTasks||=new Set).add(i),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(s)),n.opListReadCapability.promise}streamTextContent({normalizeWhitespace:t=!1,disableCombineTextItems:e=!1,includeMarkedContent:s=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,normalizeWhitespace:!0===t,combineTextItems:!0!==e,includeMarkedContent:!0===s},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>_xfa_text.XfaText.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,s){const i=e.getReader(),n={items:[],styles:Object.create(null)};!function e(){i.read().then((function({value:s,done:i}){i?t(n):(Object.assign(n.styles,s.styles),n.items.push(...s.items),e())}),s)}()}))}getStructTree(){return this._structTreePromise||=this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,this.pendingCleanup=!1,Promise.all(t)}cleanup(t=!1){return this.pendingCleanup=!0,this._tryCleanup(t)}_tryCleanup(t=!1){if(!this.pendingCleanup)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,t&&this._stats&&(this._stats=new _display_utils.StatTimer),this.pendingCleanup=!1,!0}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats&&this._stats.timeEnd("Page Request"),s.displayReadyCapability&&s.displayReadyCapability.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this._tryCleanup()}_pumpOperatorList({renderingIntent:t,cacheKey:e}){const s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:t&_util.RenderingIntentFlag.ANNOTATIONS_STORAGE?this._transport.annotationStorage.serializable:null}).getReader(),i=this._intentStates.get(e);i.streamReader=s;const n=()=>{s.read().then((({value:t,done:e})=>{e?i.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,i),n())}),(t=>{if(i.streamReader=null,!this._transport.destroyed){if(i.operatorList){i.operatorList.lastChunk=!0;for(const t of i.renderTasks)t.operatorListChanged();this._tryCleanup()}if(i.displayReadyCapability)i.displayReadyCapability.reject(t);else{if(!i.opListReadCapability)throw t;i.opListReadCapability.reject(t)}}}))};n()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(!s){if(t.renderTasks.size>0)return;if(e instanceof _display_utils.RenderingCancelledException)return void(t.streamReaderCancelTimeout=setTimeout((()=>{this._abortOperatorList({intentState:t,reason:e,force:!0}),t.streamReaderCancelTimeout=null}),RENDERING_CANCELLED_TIMEOUT))}if(t.streamReader.cancel(new _util.AbortException(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,s]of this._intentStates)if(s===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){this._listeners=[],this._deferred=Promise.resolve()}postMessage(t,e){const s={data:function(t){if(globalThis.structuredClone)return globalThis.structuredClone(t,e);const s=new WeakMap;return function t(i){if("function"==typeof i||"symbol"==typeof i||i instanceof URL)throw new Error(`LoopbackPort.postMessage - cannot clone: ${i?.toString()}`);if("object"!=typeof i||null===i)return i;if(s.has(i))return s.get(i);let n,r;if((n=i.buffer)&&(0,_util.isArrayBuffer)(n))return r=e?.includes(n)?new i.constructor(n,i.byteOffset,i.byteLength):new i.constructor(i),s.set(i,r),r;if(i instanceof Map){r=new Map,s.set(i,r);for(const[e,s]of i)r.set(e,t(s));return r}if(i instanceof Set){r=new Set,s.set(i,r);for(const e of i)r.add(t(e));return r}r=Array.isArray(i)?[]:Object.create(null),s.set(i,r);for(const e in i){let s,n=i;for(;!(s=Object.getOwnPropertyDescriptor(n,e));)n=Object.getPrototypeOf(n);void 0!==s.value&&("function"!=typeof s.value||i.hasOwnProperty?.(e))&&(r[e]=t(s.value))}return r}(t)}(t)};this._deferred.then((()=>{for(const t of this._listeners)t.call(this,s)}))}addEventListener(t,e){this._listeners.push(e)}removeEventListener(t,e){const s=this._listeners.indexOf(e);this._listeners.splice(s,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};if(_is_node.isNodeJS&&"function"==typeof commonjsRequire)PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if("object"==typeof document){const t=document?.currentScript?.src;t&&(PDFWorkerUtil.fallbackWorkerSrc=t.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.createCDNWrapper=function(t){return URL.createObjectURL(new Blob([`importScripts("${t}");`]))};class PDFWorker{static get _workerPorts(){return(0,_util.shadow)(this,"_workerPorts",new WeakMap)}constructor({name:t=null,port:e=null,verbosity:s=(0,_util.getVerbosityLevel)()}={}){if(e&&PDFWorker._workerPorts.has(e))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=(0,_util.createPromiseCapability)(),this._port=null,this._webWorker=null,this._messageHandler=null,e)return PDFWorker._workerPorts.set(e,this),void this._initializeFromPort(e);this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new _message_handler.MessageHandler("main","worker",t),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve()}_initialize(){if("undefined"!=typeof Worker&&!PDFWorkerUtil.isWorkerDisabled&&!PDFWorker._mainThreadWorkerMessageHandler){let t=PDFWorker.workerSrc;try{(0,_util.isSameOrigin)(window.location.href,t)||(t=PDFWorkerUtil.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t),s=new _message_handler.MessageHandler("main","worker",e),i=()=>{e.removeEventListener("error",n),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=()=>{this._webWorker||i()};e.addEventListener("error",n),s.on("test",(t=>{e.removeEventListener("error",n),this.destroyed?i():t?(this._messageHandler=s,this._port=e,this._webWorker=e,this._readyCapability.resolve(),s.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),s.destroy(),e.terminate())})),s.on("ready",(()=>{if(e.removeEventListener("error",n),this.destroyed)i();else try{r()}catch(t){this._setupFakeWorker()}}));const r=()=>{const t=new Uint8Array([255]);try{s.send("test",t,[t.buffer])}catch(e){(0,_util.warn)("Cannot use postMessage transfers."),t[0]=0,s.send("test",t)}};return void r()}catch(t){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),PDFWorker._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new LoopbackPort;this._port=e;const s="fake"+PDFWorkerUtil.fakeWorkerId++,i=new _message_handler.MessageHandler(s+"_worker",s,e);t.setup(i,e);const n=new _message_handler.MessageHandler(s,s+"_worker",e);this._messageHandler=n,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),PDFWorker._workerPorts.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this._workerPorts.has(t.port)?this._workerPorts.get(t.port):new PDFWorker(t)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(null!==PDFWorkerUtil.fallbackWorkerSrc)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch(t){return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof commonjsRequire){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}}exports.PDFWorker=PDFWorker,PDFWorker.getWorkerSrc=function(){return(0,_display_utils.deprecated)("`PDFWorker.getWorkerSrc()`, please use `PDFWorker.workerSrc` instead."),this.workerSrc};class WorkerTransport{#t=null;#e=new Map;#s=new Map;#i=null;constructor(t,e,s,i){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({docId:e.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this._params=i,i.useWorkerFetch||(this.CMapReaderFactory=new i.CMapReaderFactory({baseUrl:i.cMapUrl,isCompressed:i.cMapPacked}),this.StandardFontDataFactory=new i.StandardFontDataFactory({baseUrl:i.standardFontDataUrl})),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=(0,_util.createPromiseCapability)(),this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}get stats(){return this.#t}getRenderingIntent(t,e=_util.AnnotationMode.ENABLE,s=!1){let i=_util.RenderingIntentFlag.DISPLAY,n="";switch(t){case"any":i=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":i=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case _util.AnnotationMode.DISABLE:i+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:i+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:i+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,n=this.annotationStorage.lastModified;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${e}`)}return s&&(i+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:i,cacheKey:`${i}_${n}`}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=(0,_util.createPromiseCapability)(),this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#e.values())t.push(e._destroy());this.#e.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#i=null,this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null,this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:s}){s?e.close():((0,_util.assert)((0,_util.isArrayBuffer)(t),"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(()=>{const t=(0,_util.createPromiseCapability)(),s=this._fullReader;return s.headersReady.then((()=>{s.isStreamingSupported&&s.isRangeSupported||(this._lastProgress&&e.onProgress?.(this._lastProgress),s.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),t.resolve({isStreamingSupported:s.isStreamingSupported,isRangeSupported:s.isRangeSupported,contentLength:s.contentLength})}),t.reject),t.promise})),t.on("GetRangeReader",((t,e)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const s=this._networkStream.getRangeReader(t.begin,t.end);s?(e.onPull=()=>{s.read().then((function({value:t,done:s}){s?e.close():((0,_util.assert)((0,_util.isArrayBuffer)(t),"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{s.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new PDFDocumentProxy(t,this))})),t.on("DocException",(function(t){let s;switch(t.name){case"PasswordException":s=new _util.PasswordException(t.message,t.code);break;case"InvalidPDFException":s=new _util.InvalidPDFException(t.message);break;case"MissingPDFException":s=new _util.MissingPDFException(t.message);break;case"UnexpectedResponseException":s=new _util.UnexpectedResponseException(t.message,t.status);break;case"UnknownErrorException":s=new _util.UnknownErrorException(t.message,t.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}e._capability.reject(s)})),t.on("PasswordRequest",(t=>{if(this._passwordCapability=(0,_util.createPromiseCapability)(),e.onPassword){const s=t=>{this._passwordCapability.resolve({password:t})};try{e.onPassword(s,t.code)}catch(t){this._passwordCapability.reject(t)}}else this._passwordCapability.reject(new _util.PasswordException(t.message,t.code));return this._passwordCapability.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#e.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,s,i])=>{if(!this.destroyed&&!this.commonObjs.has(e))switch(s){case"Font":const n=this._params;if("error"in i){const t=i.error;(0,_util.warn)(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let r=null;n.pdfBug&&globalThis.FontInspector?.enabled&&(r={registerFont(t,e){globalThis.FontInspector.fontAdded(t,e)}});const o=new _font_loader.FontFaceObject(i,{isEvalSupported:n.isEvalSupported,disableFontFace:n.disableFontFace,ignoreErrors:n.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:r});this.fontLoader.bind(o).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!n.fontExtraProperties&&o.data&&(o.data=null),this.commonObjs.resolve(e,o)}));break;case"FontPath":case"Image":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${s}`)}})),t.on("obj",(([t,e,s,i])=>{if(this.destroyed)return;const n=this.#e.get(e);if(!n.objs.has(t))switch(s){case"Image":n.objs.resolve(t,i),i?.data?.length>8e6&&(n.cleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,i);break;default:throw new Error(`Got unknown object type ${s}`)}})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("DocStats",(t=>{this.destroyed||(this.#t=Object.freeze({streamTypes:Object.freeze(t.streamTypes),fontTypes:Object.freeze(t.fontTypes)}))})),t.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this)),t.on("FetchBuiltInCMap",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.CMapReaderFactory?this.CMapReaderFactory.fetch(t):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),t.on("FetchStandardFontData",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.StandardFontDataFactory?this.StandardFontDataFactory.fetch(t):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}_onUnsupportedFeature({featureId:t}){this.destroyed||this.loadingTask.onUnsupportedFeature?.(t)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request"));const e=t-1,s=this.#s.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((t=>{if(this.destroyed)throw new Error("Transport destroyed");const s=new PDFPageProxy(e,t,this,this._params.ownerDocument,this._params.pdfBug);return this.#e.set(e,s),s}));return this.#s.set(e,i),i}getPageIndex(t){return this.messageHandler.sendWithPromise("GetPageIndex",{ref:t})}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}saveDocument(){return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:this.annotationStorage.serializable,filename:this._fullReader?.filename??null}).finally((()=>{this.annotationStorage.resetModified()}))}getFieldObjects(){return this._getFieldObjectsPromise||=this.messageHandler.sendWithPromise("GetFieldObjects",null)}hasJSActions(){return this._hasJSActionsPromise||=this.messageHandler.sendWithPromise("HasJSActions",null)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then((t=>new _optional_content_config.OptionalContentConfig(t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.#i||=this.messageHandler.sendWithPromise("GetMetadata",null).then((t=>({info:t[0],metadata:t[1]?new _metadata.Metadata(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(await this.messageHandler.sendWithPromise("Cleanup",null),!this.destroyed){for(const t of this.#e.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#i=null,this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null}}get loadingParams(){const t=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:t.disableAutoFetch,enableXfa:t.enableXfa})}}class PDFObjects{constructor(){this._objs=Object.create(null)}_ensureObj(t){return this._objs[t]?this._objs[t]:this._objs[t]={capability:(0,_util.createPromiseCapability)(),data:null,resolved:!1}}get(t,e=null){if(e)return this._ensureObj(t).capability.promise.then(e),null;const s=this._objs[t];if(!s||!s.resolved)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){return this._objs[t]?.resolved||!1}resolve(t,e){const s=this._ensureObj(t);s.resolved=!0,s.data=e,s.capability.resolve(e)}clear(){this._objs=Object.create(null)}}class RenderTask{constructor(t){this._internalRenderTask=t,this.onContinue=null}get promise(){return this._internalRenderTask.capability.promise}cancel(){this._internalRenderTask.cancel()}}exports.RenderTask=RenderTask;class InternalRenderTask{static get canvasInUse(){return(0,_util.shadow)(this,"canvasInUse",new WeakSet)}constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:o,canvasFactory:a,useRequestAnimationFrame:h=!1,pdfBug:c=!1}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=o,this.canvasFactory=a,this._pdfBug=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=(0,_util.createPromiseCapability)(),this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(InternalRenderTask.canvasInUse.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");InternalRenderTask.canvasInUse.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,imageLayer:r,background:o}=this.params;this.gfx=new _canvas.CanvasGraphics(s,this.commonObjs,this.objs,this.canvasFactory,r,e,this.annotationCanvasMap),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback&&this.graphicsReadyCallback()}cancel(t=null){this.running=!1,this.cancelled=!0,this.gfx&&this.gfx.endDrawing(),this._canvas&&InternalRenderTask.canvasInUse.delete(this._canvas),this.callback(t||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,"canvas"))}operatorListChanged(){this.graphicsReady?(this.stepper&&this.stepper.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),this._canvas&&InternalRenderTask.canvasInUse.delete(this._canvas),this.callback())))}}const version="2.12.313";exports.version=version;const build="a2ae56f39";exports.build=build},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FontLoader=e.FontFaceObject=void 0;var i=s(2);class n{constructor({docId:t,onUnsupportedFeature:e,ownerDocument:s=globalThis.document,styleElement:r=null}){this.constructor===n&&(0,i.unreachable)("Cannot initialize BaseFontLoader."),this.docId=t,this._onUnsupportedFeature=e,this._document=s,this.nativeFontFaces=[],this.styleElement=null}addNativeFontFace(t){this.nativeFontFaces.push(t),this._document.fonts.add(t)}insertRule(t){let e=this.styleElement;e||(e=this.styleElement=this._document.createElement("style"),e.id=`PDFJS_FONT_STYLE_TAG_${this.docId}`,this._document.documentElement.getElementsByTagName("head")[0].appendChild(e));const s=e.sheet;s.insertRule(t,s.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.length=0,this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async bind(t){if(t.attached||t.missingFile)return;if(t.attached=!0,this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){throw this._onUnsupportedFeature({featureId:i.UNSUPPORTED_FEATURES.errorFontLoadNative}),(0,i.warn)(`Failed to load font '${e.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent([e],[t],i)}))}}_queueLoadingCallback(t){(0,i.unreachable)("Abstract method `_queueLoadingCallback`.")}get isFontLoadingAPISupported(){return(0,i.shadow)(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){(0,i.unreachable)("Abstract method `isSyncFontLoadingSupported`.")}get _loadTestFont(){(0,i.unreachable)("Abstract method `_loadTestFont`.")}_prepareFontLoadEvent(t,e,s){(0,i.unreachable)("Abstract method `_prepareFontLoadEvent`.")}}let r;e.FontLoader=r,e.FontLoader=r=class extends n{constructor(t){super(t),this.loadingContext={requests:[],nextRequestId:0},this.loadTestFontId=0}get isSyncFontLoadingSupported(){let t=!1;return("undefined"==typeof navigator||/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent)?.[1]>=14)&&(t=!0),(0,i.shadow)(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const e=this.loadingContext,s={id:"pdfjs-font-loading-"+e.nextRequestId++,done:!1,complete:function(){for((0,i.assert)(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.requests.length>0&&e.requests[0].done;){const t=e.requests.shift();setTimeout(t.callback,0)}},callback:t};return e.requests.push(s),s}get _loadTestFont(){return(0,i.shadow)(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e,s){function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function r(t,e,s,i){return t.substring(0,e)+i+t.substring(e+s)}let o,a;const h=this._document.createElement("canvas");h.width=1,h.height=1;const c=h.getContext("2d");let l=0;const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=r(u,976,d.length,d);const f=1482184792;let p=n(u,16);for(o=0,a=d.length-3;o<a;o+=4)p=p-f+n(d,o)|0;o<d.length&&(p=p-f+n(d+"XXX",o)|0),u=r(u,16,4,(0,i.string32)(p));const g=`url(data:font/opentype;base64,${btoa(u)});`;this.insertRule(`@font-face {font-family:"${d}";src:${g}}`);const b=[];for(const t of e)b.push(t.loadedName);b.push(d);const A=this._document.createElement("div");A.style.visibility="hidden",A.style.width=A.style.height="10px",A.style.position="absolute",A.style.top=A.style.left="0px";for(const t of b){const e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,A.appendChild(e)}this._document.body.appendChild(A),function t(e,s){if(l++,l>30)return(0,i.warn)("Load test font never loaded."),void s();c.font="30px "+e,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0?s():setTimeout(t.bind(null,e,s))}(d,(()=>{A.remove(),s.complete()}))}},e.FontFaceObject=class{constructor(t,{isEvalSupported:e=!0,disableFontFace:s=!1,ignoreErrors:i=!1,onUnsupportedFeature:n,fontRegistry:r=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.isEvalSupported=!1!==e,this.disableFontFace=!0===s,this.ignoreErrors=!0===i,this._onUnsupportedFeature=n,this.fontRegistry=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this.fontRegistry&&this.fontRegistry.registerFont(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=(0,i.bytesToString)(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this.fontRegistry&&this.fontRegistry.registerFont(this,e),s}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(t){if(!this.ignoreErrors)throw t;return this._onUnsupportedFeature({featureId:i.UNSUPPORTED_FEATURES.errorFontGetPath}),(0,i.warn)(`getPathGenerator - ignoring character: "${t}".`),this.compiledGlyphs[e]=function(){}}if(this.isEvalSupported&&i.IsEvalSupportedCached.value){const t=[];for(const e of s){const s=void 0!==e.args?e.args.join(","):"";t.push("c.",e.cmd,"(",s,");\n")}return this.compiledGlyphs[e]=new Function("c","size",t.join(""))}return this.compiledGlyphs[e]=function(t,e){for(const i of s)"scale"===i.cmd&&(i.args=[e,-e]),t[i.cmd].apply(t,i.args)}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NodeStandardFontDataFactory=e.NodeCanvasFactory=e.NodeCMapReaderFactory=void 0;var i=s(5),n=s(4),r=s(2);let o=class{constructor(){(0,r.unreachable)("Not implemented: NodeCanvasFactory")}};e.NodeCanvasFactory=o;let a=class{constructor(){(0,r.unreachable)("Not implemented: NodeCMapReaderFactory")}};e.NodeCMapReaderFactory=a;let h=class{constructor(){(0,r.unreachable)("Not implemented: NodeStandardFontDataFactory")}};if(e.NodeStandardFontDataFactory=h,n.isNodeJS){const t=function(t){return new Promise(((e,s)=>{require$$5.readFile(t,((t,i)=>{!t&&i?e(new Uint8Array(i)):s(new Error(t))}))}))};e.NodeCanvasFactory=o=class extends i.BaseCanvasFactory{_createCanvas(t,e){return require$$5.createCanvas(t,e)}},e.NodeCMapReaderFactory=a=class extends i.BaseCMapReaderFactory{_fetchData(e,s){return t(e).then((t=>({cMapData:t,compressionType:s})))}},e.NodeStandardFontDataFactory=h=class extends i.BaseStandardFontDataFactory{_fetchData(e){return t(e)}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AnnotationStorage=void 0;var i=s(2);e.AnnotationStorage=class{constructor(){this._storage=new Map,this._timeStamp=Date.now(),this._modified=!1,this.onSetModified=null,this.onResetModified=null}getValue(t,e){const s=this._storage.get(t);return void 0===s?e:Object.assign(e,s)}setValue(t,e){const s=this._storage.get(t);let i=!1;if(void 0!==s)for(const[t,n]of Object.entries(e))s[t]!==n&&(i=!0,s[t]=n);else i=!0,this._storage.set(t,e);i&&(this._timeStamp=Date.now(),this._setModified())}getAll(){return this._storage.size>0?(0,i.objectFromMap)(this._storage):null}get size(){return this._storage.size}_setModified(){this._modified||(this._modified=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this._modified&&(this._modified=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get serializable(){return this._storage.size>0?this._storage:null}get lastModified(){return this._timeStamp.toString()}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CanvasGraphics=void 0;var i=s(2),n=s(11),r=s(1);const o=4096,a=16;function h(t){if(!t.mozCurrentTransform){t._originalSave=t.save,t._originalRestore=t.restore,t._originalRotate=t.rotate,t._originalScale=t.scale,t._originalTranslate=t.translate,t._originalTransform=t.transform,t._originalSetTransform=t.setTransform,t._originalResetTransform=t.resetTransform,t._transformMatrix=t._transformMatrix||[1,0,0,1,0,0],t._transformStack=[];try{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"lineWidth");t._setLineWidth=e.set,t._getLineWidth=e.get,Object.defineProperty(t,"lineWidth",{set:function(t){this._setLineWidth(1.000001*t)},get:function(){return this._getLineWidth()}})}catch(t){}Object.defineProperty(t,"mozCurrentTransform",{get:function(){return this._transformMatrix}}),Object.defineProperty(t,"mozCurrentTransformInverse",{get:function(){const[t,e,s,i,n,r]=this._transformMatrix,o=t*i-e*s,a=e*s-t*i;return[i/o,e/a,s/a,t/o,(i*n-s*r)/a,(e*n-t*r)/o]}}),t.save=function(){const t=this._transformMatrix;this._transformStack.push(t),this._transformMatrix=t.slice(0,6),this._originalSave()},t.restore=function(){const t=this._transformStack.pop();t&&(this._transformMatrix=t,this._originalRestore())},t.translate=function(t,e){const s=this._transformMatrix;s[4]=s[0]*t+s[2]*e+s[4],s[5]=s[1]*t+s[3]*e+s[5],this._originalTranslate(t,e)},t.scale=function(t,e){const s=this._transformMatrix;s[0]*=t,s[1]*=t,s[2]*=e,s[3]*=e,this._originalScale(t,e)},t.transform=function(e,s,i,n,r,o){const a=this._transformMatrix;this._transformMatrix=[a[0]*e+a[2]*s,a[1]*e+a[3]*s,a[0]*i+a[2]*n,a[1]*i+a[3]*n,a[0]*r+a[2]*o+a[4],a[1]*r+a[3]*o+a[5]],t._originalTransform(e,s,i,n,r,o)},t.setTransform=function(e,s,i,n,r,o){this._transformMatrix=[e,s,i,n,r,o],t._originalSetTransform(e,s,i,n,r,o)},t.resetTransform=function(){this._transformMatrix=[1,0,0,1,0,0],t._originalResetTransform()},t.rotate=function(t){const e=Math.cos(t),s=Math.sin(t),i=this._transformMatrix;this._transformMatrix=[i[0]*e+i[2]*s,i[1]*e+i[3]*s,i[0]*-s+i[2]*e,i[1]*-s+i[3]*e,i[4],i[5]],this._originalRotate(t)}}}class c{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s,i){let n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,s),n.context.setTransform(1,0,0,1,0,0)):(n=this.canvasFactory.create(e,s),this.cache[t]=n),i&&h(n.context),n}clear(){for(const t in this.cache)this.canvasFactory.destroy(this.cache[t]),delete this.cache[t]}}class l{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=i.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=i.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=i.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps=null,this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=i.Util.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateCurvePathMinMax(t,e,s,n,r,o,a,h,c){const l=i.Util.bezierBoundingBox(e,s,n,r,o,a,h,c);this.updatePathMinMax(t,l[0],l[1]),this.updatePathMinMax(t,l[2],l[3])}getPathBoundingBox(t=n.PathType.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===n.PathType.STROKE){e||(0,i.unreachable)("Stroke bounding box must include transform.");const t=i.Util.singularValueDecompose2dScale(e),n=t[0]*this.lineWidth/2,r=t[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=i.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=n.PathType.FILL,e=null){return i.Util.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function d(t,e,s=null){if("undefined"!=typeof ImageData&&e instanceof ImageData)return void t.putImageData(e,0,0);const n=e.height,r=e.width,o=n%a,h=(n-o)/a,c=0===o?h:h+1,l=t.createImageData(r,a);let d,u=0;const f=e.data,p=l.data;let g,b,A,m,w,v,k,x;if(s)switch(s.length){case 1:w=s[0],v=s[0],k=s[0],x=s[0];break;case 4:w=s[0],v=s[1],k=s[2],x=s[3]}if(e.kind===i.ImageKind.GRAYSCALE_1BPP){const e=f.byteLength,s=new Uint32Array(p.buffer,0,p.byteLength>>2),n=s.length,m=r+7>>3;let w=4294967295,v=i.IsLittleEndianCached.value?4278190080:255;for(x&&255===x[0]&&0===x[255]&&([w,v]=[v,w]),g=0;g<c;g++){for(A=g<h?a:o,d=0,b=0;b<A;b++){const t=e-u;let i=0;const n=t>m?r:8*t-7,o=-8&n;let a=0,h=0;for(;i<o;i+=8)h=f[u++],s[d++]=128&h?w:v,s[d++]=64&h?w:v,s[d++]=32&h?w:v,s[d++]=16&h?w:v,s[d++]=8&h?w:v,s[d++]=4&h?w:v,s[d++]=2&h?w:v,s[d++]=1&h?w:v;for(;i<n;i++)0===a&&(h=f[u++],a=128),s[d++]=h&a?w:v,a>>=1}for(;d<n;)s[d++]=0;t.putImageData(l,0,g*a)}}else if(e.kind===i.ImageKind.RGBA_32BPP){const e=!!(w||v||k);for(b=0,m=r*a*4,g=0;g<h;g++){if(p.set(f.subarray(u,u+m)),u+=m,e)for(let t=0;t<m;t+=4)w&&(p[t+0]=w[p[t+0]]),v&&(p[t+1]=v[p[t+1]]),k&&(p[t+2]=k[p[t+2]]);t.putImageData(l,0,b),b+=a}if(g<c){if(m=r*o*4,p.set(f.subarray(u,u+m)),e)for(let t=0;t<m;t+=4)w&&(p[t+0]=w[p[t+0]]),v&&(p[t+1]=v[p[t+1]]),k&&(p[t+2]=k[p[t+2]]);t.putImageData(l,0,b)}}else{if(e.kind!==i.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);{const e=!!(w||v||k);for(A=a,m=r*A,g=0;g<c;g++){for(g>=h&&(A=o,m=r*A),d=0,b=m;b--;)p[d++]=f[u++],p[d++]=f[u++],p[d++]=f[u++],p[d++]=255;if(e)for(let t=0;t<d;t+=4)w&&(p[t+0]=w[p[t+0]]),v&&(p[t+1]=v[p[t+1]]),k&&(p[t+2]=k[p[t+2]]);t.putImageData(l,0,g*a)}}}}function u(t,e){const s=e.height,i=e.width,n=s%a,r=(s-n)/a,o=0===n?r:r+1,h=t.createImageData(i,a);let c=0;const l=e.data,d=h.data;for(let e=0;e<o;e++){const s=e<r?a:n;let o=3;for(let t=0;t<s;t++){let t,e=0;for(let s=0;s<i;s++)e||(t=l[c++],e=128),d[o]=t&e?0:255,o+=4,e>>=1}t.putImageData(h,0,e*a)}}function f(t,e){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"];for(let i=0,n=s.length;i<n;i++){const n=s[i];void 0!==t[n]&&(e[n]=t[n])}void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function p(t){t.strokeStyle="#000000",t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0)}function g(t,e,s,i){const n=t.length;for(let r=3;r<n;r+=4){const n=t[r];if(0===n)t[r-3]=e,t[r-2]=s,t[r-1]=i;else if(n<255){const o=255-n;t[r-3]=t[r-3]*n+e*o>>8,t[r-2]=t[r-2]*n+s*o>>8,t[r-1]=t[r-1]*n+i*o>>8}}}function b(t,e,s){const i=t.length;for(let n=3;n<i;n+=4)e[n]=e[n]*(s?s[t[n]]:t[n])*.00392156862745098|0}function A(t,e,s){const i=t.length;for(let n=3;n<i;n+=4){const i=77*t[n-3]+152*t[n-2]+28*t[n-1];e[n]=s?e[n]*s[i>>8]>>8:e[n]*i>>16}}function m(t,e){const s=i.Util.singularValueDecompose2dScale(t);s[0]=Math.fround(s[0]),s[1]=Math.fround(s[1]);const n=Math.fround((globalThis.devicePixelRatio||1)*r.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==e?e:s[0]<=n||s[1]<=n}const w=["butt","round","square"],v=["miter","round","bevel"],k={},x={};class y{constructor(t,e,s,i,n,r,o){this.ctx=t,this.current=new l(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.imageLayer=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=[],this.optionalContentConfig=r,this.cachedCanvases=new c(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,t&&h(t),this._cachedGetSinglePixelWidth=null}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height;if(this.ctx.save(),this.ctx.fillStyle=i||"rgb(255, 255, 255)",this.ctx.fillRect(0,0,n,r),this.ctx.restore(),s){const t=this.cachedCanvases.getCanvas("transparent",n,r,!0);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform.apply(this.ctx,this.compositeCtx.mozCurrentTransform)}this.ctx.save(),p(this.ctx),t&&(this.ctx.transform.apply(this.ctx,t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform.apply(this.ctx,e.transform),this.viewportScale=e.scale,this.baseTransform=this.ctx.mozCurrentTransform.slice(),this._combinedScaleFactor=Math.hypot(this.baseTransform[0],this.baseTransform[2]),this.imageLayer&&this.imageLayer.beginLayout()}executeOperatorList(t,e,s,n){const r=t.argsArray,o=t.fnArray;let a=e||0;const h=r.length;if(h===a)return a;const c=h-a>10&&"function"==typeof s,l=c?Date.now()+15:0;let d=0;const u=this.commonObjs,f=this.objs;let p;for(;;){if(void 0!==n&&a===n.nextBreakPoint)return n.breakIt(a,s),a;if(p=o[a],p!==i.OPS.dependency)this[p].apply(this,r[a]);else for(const t of r[a]){const e=t.startsWith("g_")?u:f;if(!e.has(t))return e.get(t,s),a}if(a++,a===h)return a;if(c&&++d>10){if(Date.now()>l)return s(),a;d=0}}}endDrawing(){for(;this.stateStack.length||null!==this.current.activeSMask;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this.imageLayer&&this.imageLayer.endLayout()}_scaleImage(t,e){const s=t.width,i=t.height;let n,r,o=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),h=s,c=i,l="prescale1";for(;o>2&&h>1||a>2&&c>1;){let e=h,s=c;o>2&&h>1&&(e=Math.ceil(h/2),o/=h/e),a>2&&c>1&&(s=Math.ceil(c/2),a/=c/s),n=this.cachedCanvases.getCanvas(l,e,s),r=n.context,r.clearRect(0,0,e,s),r.drawImage(t,0,0,h,c,0,0,e,s),t=n.canvas,h=e,c=s,l="prescale1"===l?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,s=t.width,r=t.height,o=this.current.fillColor,a=this.current.patternFill,h=this.cachedCanvases.getCanvas("maskCanvas",s,r);u(h.context,t);let c=i.Util.transform(e.mozCurrentTransform,[1/s,0,0,-1/r,0,0]);c=i.Util.transform(c,[1,0,0,1,0,-r]);const l=i.Util.applyTransform([0,0],c),d=i.Util.applyTransform([s,r],c),f=i.Util.normalizeRect([l[0],l[1],d[0],d[1]]),p=Math.ceil(f[2]-f[0]),g=Math.ceil(f[3]-f[1]),b=this.cachedCanvases.getCanvas("fillCanvas",p,g,!0),A=b.context,w=Math.min(l[0],d[0]),v=Math.min(l[1],d[1]);A.translate(-w,-v),A.transform.apply(A,c);const k=this._scaleImage(h.canvas,A.mozCurrentTransformInverse);A.imageSmoothingEnabled=m(A.mozCurrentTransform,t.interpolate),A.drawImage(k.img,0,0,k.img.width,k.img.height,0,0,s,r),A.globalCompositeOperation="source-in";const x=i.Util.transform(A.mozCurrentTransformInverse,[1,0,0,1,-w,-v]);return A.fillStyle=a?o.getPattern(e,this,x,n.PathType.FILL):o,A.fillRect(0,0,s,r),{canvas:b.canvas,offsetX:Math.round(w),offsetY:Math.round(v)}}setLineWidth(t){this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=w[t]}setLineJoin(t){this.ctx.lineJoin=v[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],i=s[1];switch(s[0]){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=s[1];break;case"ca":this.current.fillAlpha=s[1],this.ctx.globalAlpha=s[1];break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.current.transferMaps=i}}}checkSMaskState(){const t=!!this.suspendedCtx;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.suspendedCtx)throw new Error("beginSMaskMode called while already in smask mode");const t=this.cachedCanvases.getCanvas("smaskGroupAt"+this.groupLevel,this.ctx.canvas.width,this.ctx.canvas.height,!0);this.suspendedCtx=this.ctx,this.ctx=t.context;const e=this.ctx;e.setTransform.apply(e,this.suspendedCtx.mozCurrentTransform),f(this.suspendedCtx,e),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,s){e.translate(t,s),this.__originalTranslate(t,s)},t.scale=function(t,s){e.scale(t,s),this.__originalScale(t,s)},t.transform=function(t,s,i,n,r,o){e.transform(t,s,i,n,r,o),this.__originalTransform(t,s,i,n,r,o)},t.setTransform=function(t,s,i,n,r,o){e.setTransform(t,s,i,n,r,o),this.__originalSetTransform(t,s,i,n,r,o)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},t.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},t.bezierCurveTo=function(t,s,i,n,r,o){e.bezierCurveTo(t,s,i,n,r,o),this.__originalBezierCurveTo(t,s,i,n,r,o)},t.rect=function(t,s,i,n){e.rect(t,s,i,n),this.__originalRect(t,s,i,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(e,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.suspendedCtx)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),f(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.current.activeSMask=null,this.suspendedCtx=null}compose(t){this.current.activeSMask&&(t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height],function(t,e,s,i){const n=i[0],r=i[1],o=i[2]-n,a=i[3]-r;0!==o&&0!==a&&(function(t,e,s,i,n,r,o,a,h,c,l){const d=!!r,u=d?r[0]:0,f=d?r[1]:0,p=d?r[2]:0;let m;m="Luminosity"===n?A:b;const w=Math.min(i,Math.ceil(1048576/s));for(let n=0;n<i;n+=w){const r=Math.min(w,i-n),b=t.getImageData(a-c,n+(h-l),s,r),A=e.getImageData(a,n+h,s,r);d&&g(b.data,u,f,p),m(b.data,A.data,o),e.putImageData(A,a,n+h)}}(e.context,s,o,a,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}(this.suspendedCtx,this.current.activeSMask,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}save(){this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.current.activeSMask&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedGetSinglePixelWidth=null}constructPath(t,e){const s=this.ctx,n=this.current;let r,o,a=n.x,h=n.y;for(let c=0,l=0,d=t.length;c<d;c++)switch(0|t[c]){case i.OPS.rectangle:a=e[l++],h=e[l++];const t=e[l++],c=e[l++],d=a+t,u=h+c;s.moveTo(a,h),0===t||0===c?s.lineTo(d,u):(s.lineTo(d,h),s.lineTo(d,u),s.lineTo(a,u)),n.updatePathMinMax(s.mozCurrentTransform,a,h),n.updatePathMinMax(s.mozCurrentTransform,d,u),s.closePath();break;case i.OPS.moveTo:a=e[l++],h=e[l++],s.moveTo(a,h),n.updatePathMinMax(s.mozCurrentTransform,a,h);break;case i.OPS.lineTo:a=e[l++],h=e[l++],s.lineTo(a,h),n.updatePathMinMax(s.mozCurrentTransform,a,h);break;case i.OPS.curveTo:r=a,o=h,a=e[l+4],h=e[l+5],s.bezierCurveTo(e[l],e[l+1],e[l+2],e[l+3],a,h),n.updateCurvePathMinMax(s.mozCurrentTransform,r,o,e[l],e[l+1],e[l+2],e[l+3],a,h),l+=6;break;case i.OPS.curveTo2:r=a,o=h,s.bezierCurveTo(a,h,e[l],e[l+1],e[l+2],e[l+3]),n.updateCurvePathMinMax(s.mozCurrentTransform,r,o,a,h,e[l],e[l+1],e[l+2],e[l+3]),a=e[l+2],h=e[l+3],l+=4;break;case i.OPS.curveTo3:r=a,o=h,a=e[l+2],h=e[l+3],s.bezierCurveTo(e[l],e[l+1],a,h,a,h),n.updateCurvePathMinMax(s.mozCurrentTransform,r,o,e[l],e[l+1],a,h,a,h),l+=4;break;case i.OPS.closePath:s.closePath()}n.setCurrentPoint(a,h)}closePath(){this.ctx.closePath()}stroke(t){t=void 0===t||t;const e=this.ctx,s=this.current.strokeColor;if(e.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const t=this.getSinglePixelWidth();e.save(),e.strokeStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,n.PathType.STROKE),e.lineWidth=Math.max(t,this.current.lineWidth),e.stroke(),e.restore()}else{const t=this.getSinglePixelWidth();t<0&&-t>=this.current.lineWidth?(e.save(),e.resetTransform(),e.lineWidth=Math.round(this._combinedScaleFactor),e.stroke(),e.restore()):(e.lineWidth=Math.max(t,this.current.lineWidth),e.stroke())}t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t){t=void 0===t||t;const e=this.ctx,s=this.current.fillColor;let i=!1;this.current.patternFill&&(e.save(),e.fillStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,n.PathType.FILL),i=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),i&&e.restore(),t&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=k}eoClip(){this.pendingClip=x}beginText(){this.current.textMatrix=i.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){e.save(),e.beginPath();for(let s=0;s<t.length;s++){const i=t[s];e.setTransform.apply(e,i.transform),e.translate(i.x,i.y),i.addToPath(e,i.fontSize)}e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const s=this.commonObjs.get(t),n=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(n.fontMatrix=s.fontMatrix||i.FONT_IDENTITY_MATRIX,0!==n.fontMatrix[0]&&0!==n.fontMatrix[3]||(0,i.warn)("Invalid font matrix for font "+t),e<0?(e=-e,n.fontDirection=-1):n.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;let r="normal";s.black?r="900":s.bold&&(r="bold");const o=s.italic?"italic":"normal",a=`"${s.loadedName||"sans-serif"}", ${s.fallbackName}`;let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${r} ${h}px ${a}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,n,r){const o=this.ctx,a=this.current,h=a.font,c=a.textRenderingMode,l=a.fontSize/a.fontSizeScale,d=c&i.TextRenderingMode.FILL_STROKE_MASK,u=!!(c&i.TextRenderingMode.ADD_TO_PATH_FLAG),f=a.patternFill&&!h.missingFile;let p;(h.disableFontFace||u||f)&&(p=h.getPathGenerator(this.commonObjs,t)),h.disableFontFace||f?(o.save(),o.translate(e,s),o.beginPath(),p(o,l),n&&o.setTransform.apply(o,n),d!==i.TextRenderingMode.FILL&&d!==i.TextRenderingMode.FILL_STROKE||o.fill(),d!==i.TextRenderingMode.STROKE&&d!==i.TextRenderingMode.FILL_STROKE||(r&&(o.resetTransform(),o.lineWidth=Math.round(this._combinedScaleFactor)),o.stroke()),o.restore()):(d!==i.TextRenderingMode.FILL&&d!==i.TextRenderingMode.FILL_STROKE||o.fillText(t,e,s),d!==i.TextRenderingMode.STROKE&&d!==i.TextRenderingMode.FILL_STROKE||(r?(o.save(),o.moveTo(e,s),o.resetTransform(),o.lineWidth=Math.round(this._combinedScaleFactor),o.strokeText(t,0,0),o.restore()):o.strokeText(t,e,s))),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:o.mozCurrentTransform,x:e,y:s,fontSize:l,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){s=!0;break}return(0,i.shadow)(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const r=e.fontSize;if(0===r)return;const o=this.ctx,a=e.fontSizeScale,h=e.charSpacing,c=e.wordSpacing,l=e.fontDirection,d=e.textHScale*l,u=t.length,f=s.vertical,p=f?1:-1,g=s.defaultVMetrics,b=r*e.fontMatrix[0],A=e.textRenderingMode===i.TextRenderingMode.FILL&&!s.disableFontFace&&!e.patternFill;let m;if(o.save(),o.transform.apply(o,e.textMatrix),o.translate(e.x,e.y+e.textRise),o.scale(d,l>0?-1:1),e.patternFill){o.save();const t=e.fillColor.getPattern(o,this,o.mozCurrentTransformInverse,n.PathType.FILL);m=o.mozCurrentTransform,o.restore(),o.fillStyle=t}let w=e.lineWidth,v=!1;const k=e.textMatrixScale;if(0===k||0===w){const t=e.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;t!==i.TextRenderingMode.STROKE&&t!==i.TextRenderingMode.FILL_STROKE||(this._cachedGetSinglePixelWidth=null,w=this.getSinglePixelWidth(),v=w<0)}else w/=k;1!==a&&(o.scale(a,a),w/=a),o.lineWidth=w;let x,y=0;for(x=0;x<u;++x){const e=t[x];if((0,i.isNum)(e)){y+=p*e*r/1e3;continue}let n=!1;const d=(e.isSpace?c:0)+h,u=e.fontChar,w=e.accent;let k,_,D,M=e.width;if(f){const t=e.vmetric||g,s=-(e.vmetric?t[1]:.5*M)*b;M=t?-t[0]:M,k=s/a,_=(y+t[2]*b)/a}else k=y/a,_=0;if(s.remeasure&&M>0){const t=1e3*o.measureText(u).width/r*a;if(M<t&&this.isFontSubpixelAAEnabled){const e=M/t;n=!0,o.save(),o.scale(e,1),k/=e}else M!==t&&(k+=(M-t)/2e3*r/a)}this.contentVisible&&(e.isInFont||s.missingFile)&&(A&&!w?o.fillText(u,k,_):(this.paintChar(u,k,_,m,v),w&&this.paintChar(w.fontChar,k+r*w.offset.x/a,_-r*w.offset.y/a,m,v))),D=f?M*b-d*l:M*b+d*l,y+=D,n&&o.restore()}f?e.y-=y:e.x+=y*d,o.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,n=s.font,r=s.fontSize,o=s.fontDirection,a=n.vertical?1:-1,h=s.charSpacing,c=s.wordSpacing,l=s.textHScale*o,d=s.fontMatrix||i.FONT_IDENTITY_MATRIX,u=t.length;let f,p,g,b;if(s.textRenderingMode!==i.TextRenderingMode.INVISIBLE&&0!==r){for(this._cachedGetSinglePixelWidth=null,e.save(),e.transform.apply(e,s.textMatrix),e.translate(s.x,s.y),e.scale(l,o),f=0;f<u;++f){if(p=t[f],(0,i.isNum)(p)){b=a*p*r/1e3,this.ctx.translate(b,0),s.x+=b*l;continue}const o=(p.isSpace?c:0)+h,u=n.charProcOperatorList[p.operatorListId];u?(this.contentVisible&&(this.processingType3=p,this.save(),e.scale(r,r),e.transform.apply(e,d),this.executeOperatorList(u),this.restore()),g=i.Util.applyTransform([p.width,0],d)[0]*r+o,e.translate(g,0),s.x+=g*l):(0,i.warn)(`Type3 character "${p.operatorListId}" is not available.`)}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const s=t[1],i=this.baseTransform||this.ctx.mozCurrentTransform.slice();e=new n.TilingPattern(t,s,this.ctx,{createCanvasGraphics:t=>new y(t,this.commonObjs,this.objs,this.canvasFactory)},i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const n=i.Util.makeHexColor(t,e,s);this.ctx.strokeStyle=n,this.current.strokeColor=n}setFillRGBColor(t,e,s){const n=i.Util.makeHexColor(t,e,s);this.ctx.fillStyle=n,this.current.fillColor=n,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=(0,n.getShadingPattern)(this.objs.get(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,n.PathType.SHADING);const r=e.mozCurrentTransformInverse;if(r){const t=e.canvas,s=t.width,n=t.height,o=i.Util.applyTransform([0,0],r),a=i.Util.applyTransform([0,n],r),h=i.Util.applyTransform([s,0],r),c=i.Util.applyTransform([s,n],r),l=Math.min(o[0],a[0],h[0],c[0]),d=Math.min(o[1],a[1],h[1],c[1]),u=Math.max(o[0],a[0],h[0],c[0]),f=Math.max(o[1],a[1],h[1],c[1]);this.ctx.fillRect(l,d,u-l,f-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,i.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,i.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(t,e){this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(t)&&6===t.length&&this.transform.apply(this,t),this.baseTransform=this.ctx.mozCurrentTransform,e)&&(this.ctx.rect(e[0],e[1],e[2]-e[0],e[3]-e[1]),this.current.updatePathMinMax(this.ctx.mozCurrentTransform,e[0],e[1]),this.current.updatePathMinMax(this.ctx.mozCurrentTransform,e[2],e[3]),this.clip(),this.endPath())}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save();const e=this.suspendedCtx;this.current.activeSMask&&(this.suspendedCtx=null,this.current.activeSMask=null);const s=this.ctx;t.isolated||(0,i.info)("TODO: Support non-isolated groups."),t.knockout&&(0,i.warn)("Knockout groups not supported.");const n=s.mozCurrentTransform;if(t.matrix&&s.transform.apply(s,t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=i.Util.getAxialAlignedBoundingBox(t.bbox,s.mozCurrentTransform);r=i.Util.intersect(r,[0,0,s.canvas.width,s.canvas.height])||[0,0,0,0];const a=Math.floor(r[0]),h=Math.floor(r[1]);let c=Math.max(Math.ceil(r[2])-a,1),l=Math.max(Math.ceil(r[3])-h,1),d=1,u=1;c>o&&(d=c/o,c=o),l>o&&(u=l/o,l=o),this.current.startNewPathAndClipBox([0,0,c,l]);let p="groupAt"+this.groupLevel;t.smask&&(p+="_smask_"+this.smaskCounter++%2);const g=this.cachedCanvases.getCanvas(p,c,l,!0),b=g.context;b.scale(1/d,1/u),b.translate(-a,-h),b.transform.apply(b,n),t.smask?this.smaskStack.push({canvas:g.canvas,context:b,offsetX:a,offsetY:h,scaleX:d,scaleY:u,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(s.setTransform(1,0,0,1,0,0),s.translate(a,h),s.scale(d,u),s.save()),f(s,b),this.ctx=b,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push({ctx:s,suspendedCtx:e}),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,{ctx:s,suspendedCtx:n}=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,n&&(this.suspendedCtx=n),t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=this.ctx.mozCurrentTransform;this.restore(),this.ctx.save(),this.ctx.setTransform.apply(this.ctx,t);const s=i.Util.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotations(){this.save(),this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)}endAnnotations(){this.restore()}beginAnnotation(t,e,s,n,r){if(this.save(),Array.isArray(e)&&4===e.length){const n=e[2]-e[0],o=e[3]-e[1];if(r&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=n,e[3]=o;const[r,a]=i.Util.singularValueDecompose2dScale(this.ctx.mozCurrentTransform),{viewportScale:c}=this,l=Math.ceil(n*this.outputScaleX*c),d=Math.ceil(o*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(l,d);const{canvas:u,context:f}=this.annotationCanvas;u.style.width=`calc(${n}px * var(--viewport-scale-factor))`,u.style.height=`calc(${o}px * var(--viewport-scale-factor))`,this.annotationCanvasMap.set(t,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.setTransform(r,0,0,-a,0,o*a),h(this.ctx),p(this.ctx)}else p(this.ctx),this.ctx.rect(e[0],e[1],n,o),this.clip(),this.endPath()}this.current=new l(this.ctx.canvas.width,this.ctx.canvas.height),this.transform.apply(this,s),this.transform.apply(this,n)}endAnnotation(){this.annotationCanvas&&(this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.restore()}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=this.ctx,s=t.width,i=t.height,n=this.processingType3;if(n&&void 0===n.compiled&&(n.compiled=s<=1e3&&i<=1e3?function(t){const e=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),s=t.width,i=t.height,n=s+1;let r,o,a,h;const c=new Uint8Array(n*(i+1)),l=s+7&-8,d=t.data,u=new Uint8Array(l*i);let f=0;for(r=0,o=d.length;r<o;r++){const t=d[r];let e=128;for(;e>0;)u[f++]=t&e?0:255,e>>=1}let p=0;for(f=0,0!==u[f]&&(c[0]=1,++p),a=1;a<s;a++)u[f]!==u[f+1]&&(c[a]=u[f]?2:1,++p),f++;for(0!==u[f]&&(c[a]=2,++p),r=1;r<i;r++){f=r*l,h=r*n,u[f-l]!==u[f]&&(c[h]=u[f]?1:8,++p);let t=(u[f]?4:0)+(u[f-l]?8:0);for(a=1;a<s;a++)t=(t>>2)+(u[f+1]?4:0)+(u[f-l+1]?8:0),e[t]&&(c[h+a]=e[t],++p),f++;if(u[f-l]!==u[f]&&(c[h+a]=u[f]?2:4,++p),p>1e3)return null}for(f=l*(i-1),h=r*n,0!==u[f]&&(c[h]=8,++p),a=1;a<s;a++)u[f]!==u[f+1]&&(c[h+a]=u[f]?4:8,++p),f++;if(0!==u[f]&&(c[h+a]=4,++p),p>1e3)return null;const g=new Int32Array([0,n,-1,0,-n,0,0,0,1]),b=[];for(r=0;p&&r<=i;r++){let t=r*n;const e=t+s;for(;t<e&&!c[t];)t++;if(t===e)continue;const i=[t%n,r],o=t;let a=c[t];do{const e=g[a];do{t+=e}while(!c[t]);const s=c[t];5!==s&&10!==s?(a=s,c[t]=0):(a=s&51*a>>4,c[t]&=a>>2|a<<2),i.push(t%n,t/n|0),c[t]||--p}while(o!==t);b.push(i),--r}return function(t){t.save(),t.scale(1/s,-1/i),t.translate(0,-i),t.beginPath();for(let e=0,s=b.length;e<s;e++){const s=b[e];t.moveTo(s[0],s[1]);for(let e=2,i=s.length;e<i;e+=2)t.lineTo(s[e],s[e+1])}t.fill(),t.beginPath(),t.restore()}}({data:t.data,width:s,height:i}):null),n?.compiled)return void n.compiled(e);const r=this._createMaskCanvas(t),o=r.canvas;e.save(),e.setTransform(1,0,0,1,0,0),e.drawImage(o,r.offsetX,r.offsetY),e.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,n=0,r,o){if(!this.contentVisible)return;const a=this.ctx;a.save();const h=a.mozCurrentTransform;a.transform(e,s,n,r,0,0);const c=this._createMaskCanvas(t);a.setTransform(1,0,0,1,0,0);for(let t=0,l=o.length;t<l;t+=2){const l=i.Util.transform(h,[e,s,n,r,o[t],o[t+1]]),[d,u]=i.Util.applyTransform([0,0],l);a.drawImage(c.canvas,d,u)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(let r=0,o=t.length;r<o;r++){const o=t[r],a=o.width,h=o.height,c=this.cachedCanvases.getCanvas("maskCanvas",a,h),l=c.context;l.save(),u(l,o),l.globalCompositeOperation="source-in",l.fillStyle=i?s.getPattern(l,this,e.mozCurrentTransformInverse,n.PathType.FILL):s,l.fillRect(0,0,a,h),l.restore(),e.save(),e.transform.apply(e,o.transform),e.scale(1,-1),e.drawImage(c.canvas,0,0,a,h,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);e?this.paintInlineImageXObject(e):(0,i.warn)("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,n){if(!this.contentVisible)return;const r=t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);if(!r)return void(0,i.warn)("Dependent image isn't ready yet");const o=r.width,a=r.height,h=[];for(let t=0,i=n.length;t<i;t+=2)h.push({transform:[e,0,0,s,n[t],n[t+1]],x:0,y:0,w:o,h:a});this.paintInlineImageXObjectGroup(r,h)}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;let n;if(this.save(),i.scale(1/e,-1/s),"function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const i=this.cachedCanvases.getCanvas("inlineImage",e,s);d(i.context,t,this.current.transferMaps),n=i.canvas}const r=this._scaleImage(n,i.mozCurrentTransformInverse);if(i.imageSmoothingEnabled=m(i.mozCurrentTransform,t.interpolate),i.drawImage(r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.imageLayer){const n=this.getCanvasPosition(0,-s);this.imageLayer.appendImage({imgData:t,left:n[0],top:n[1],width:e/i.mozCurrentTransformInverse[0],height:s/i.mozCurrentTransformInverse[3]})}this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx,i=t.width,n=t.height,r=this.cachedCanvases.getCanvas("inlineImage",i,n);d(r.context,t,this.current.transferMaps);for(let o=0,a=e.length;o<a;o++){const a=e[o];if(s.save(),s.transform.apply(s,a.transform),s.scale(1,-1),s.drawImage(r.canvas,a.x,a.y,a.w,a.h,0,-1,1,1),this.imageLayer){const e=this.getCanvasPosition(a.x,a.y);this.imageLayer.appendImage({imgData:t,left:e[0],top:e[1],width:i,height:n})}s.restore()}this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){this.markedContentStack.push("OC"===t?{visible:this.optionalContentConfig.isVisible(e)}:{visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const e=this.ctx;this.pendingClip&&(this.pendingClip===x?e.clip("evenodd"):e.clip(),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),e.beginPath()}getSinglePixelWidth(){if(null===this._cachedGetSinglePixelWidth){const t=this.ctx.mozCurrentTransform,e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=t[0]**2+t[2]**2,i=t[1]**2+t[3]**2,n=Math.sqrt(Math.max(s,i))/e;this._cachedGetSinglePixelWidth=s!==i&&this._combinedScaleFactor*n>1?-this._combinedScaleFactor*n:e>Number.EPSILON?n:1}return this._cachedGetSinglePixelWidth}getCanvasPosition(t,e){const s=this.ctx.mozCurrentTransform;return[s[0]*t+s[2]*e+s[4],s[1]*t+s[3]*e+s[5]]}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}e.CanvasGraphics=y;for(const t in i.OPS)void 0!==y.prototype[t]&&(y.prototype[i.OPS[t]]=y.prototype[t])},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TilingPattern=e.PathType=void 0,e.getShadingPattern=function(t){switch(t[0]){case"RadialAxial":return new a(t);case"Mesh":return new l(t);case"Dummy":return new d}throw new Error(`Unknown IR type: ${t[0]}`)};var i=s(2);const n={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function r(t,e){if(!e||"undefined"==typeof Path2D)return;const s=e[2]-e[0],i=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],s,i),t.clip(n)}e.PathType=n;class o{constructor(){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class a extends o{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,s,o){let a;if(o===n.STROKE||o===n.FILL){const n=e.current.getClippedPathBoundingBox(o,t.mozCurrentTransform)||[0,0,0,0],h=Math.ceil(n[2]-n[0])||1,c=Math.ceil(n[3]-n[1])||1,l=e.cachedCanvases.getCanvas("pattern",h,c,!0),d=l.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-n[0],-n[1]),s=i.Util.transform(s,[1,0,0,1,n[0],n[1]]),d.transform.apply(d,e.baseTransform),this.matrix&&d.transform.apply(d,this.matrix),r(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),a=t.createPattern(l.canvas,"no-repeat");const u=new DOMMatrix(s);try{a.setTransform(u)}catch(t){(0,i.warn)(`RadialAxialShadingPattern.getPattern: "${t?.message}".`)}}else r(t,this._bbox),a=this._createGradient(t);return a}}function h(t,e,s,i,n,r,o,a){const h=e.coords,c=e.colors,l=t.data,d=4*t.width;let u;h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=r,r=o,o=u),h[i+1]>h[n+1]&&(u=i,i=n,n=u,u=o,o=a,a=u),h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=r,r=o,o=u);const f=(h[s]+e.offsetX)*e.scaleX,p=(h[s+1]+e.offsetY)*e.scaleY,g=(h[i]+e.offsetX)*e.scaleX,b=(h[i+1]+e.offsetY)*e.scaleY,A=(h[n]+e.offsetX)*e.scaleX,m=(h[n+1]+e.offsetY)*e.scaleY;if(p>=m)return;const w=c[r],v=c[r+1],k=c[r+2],x=c[o],y=c[o+1],_=c[o+2],D=c[a],M=c[a+1],E=c[a+2],F=Math.round(p),C=Math.round(m);let P,S,O,T,R,I,L,N;for(let t=F;t<=C;t++){if(t<b){let e;e=t<p?0:(p-t)/(p-b),P=f-(f-g)*e,S=w-(w-x)*e,O=v-(v-y)*e,T=k-(k-_)*e}else{let e;e=t>m?1:b===m?0:(b-t)/(b-m),P=g-(g-A)*e,S=x-(x-D)*e,O=y-(y-M)*e,T=_-(_-E)*e}let e;e=t<p?0:t>m?1:(p-t)/(p-m),R=f-(f-A)*e,I=w-(w-D)*e,L=v-(v-M)*e,N=k-(k-E)*e;const s=Math.round(Math.min(P,R)),i=Math.round(Math.max(P,R));let n=d*t+4*s;for(let t=s;t<=i;t++)e=(P-t)/(P-R),e<0?e=0:e>1&&(e=1),l[n++]=S-(S-I)*e|0,l[n++]=O-(O-L)*e|0,l[n++]=T-(T-N)*e|0,l[n++]=255}}function c(t,e,s){const i=e.coords,n=e.colors;let r,o;switch(e.type){case"lattice":const a=e.verticesPerRow,c=Math.floor(i.length/a)-1,l=a-1;for(r=0;r<c;r++){let e=r*a;for(let r=0;r<l;r++,e++)h(t,s,i[e],i[e+1],i[e+a],n[e],n[e+1],n[e+a]),h(t,s,i[e+a+1],i[e+1],i[e+a],n[e+a+1],n[e+1],n[e+a])}break;case"triangles":for(r=0,o=i.length;r<o;r+=3)h(t,s,i[r],i[r+1],i[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class l extends o{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-i,o=Math.ceil(this._bounds[3])-n,a=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),h=Math.min(Math.ceil(Math.abs(o*t[1]*1.1)),3e3),l=r/a,d=o/h,u={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-n,scaleX:1/l,scaleY:1/d},f=s.getCanvas("mesh",a+4,h+4,!1),p=f.context,g=p.createImageData(a,h);if(e){const t=g.data;for(let s=0,i=t.length;s<i;s+=4)t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=255}for(const t of this._figures)c(g,t,u);return p.putImageData(g,2,2),{canvas:f.canvas,offsetX:i-2*l,offsetY:n-2*d,scaleX:l,scaleY:d}}getPattern(t,e,s,o){let a;if(r(t,this._bbox),o===n.SHADING)a=i.Util.singularValueDecompose2dScale(t.mozCurrentTransform);else if(a=i.Util.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=i.Util.singularValueDecompose2dScale(this.matrix);a=[a[0]*t[0],a[1]*t[1]]}const h=this._createMeshCanvas(a,o===n.SHADING?null:this._background,e.cachedCanvases);return o!==n.SHADING&&(t.setTransform.apply(t,e.baseTransform),this.matrix&&t.transform.apply(t,this.matrix)),t.translate(h.offsetX,h.offsetY),t.scale(h.scaleX,h.scaleY),t.createPattern(h.canvas,"no-repeat")}}class d extends o{getPattern(){return"hotpink"}}class u{static get MAX_PATTERN_SIZE(){return(0,i.shadow)(this,"MAX_PATTERN_SIZE",3e3)}constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3]||[1,0,0,1,0,0],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,n=this.xstep,r=this.ystep,o=this.paintType,a=this.color,h=this.canvasGraphicsFactory;(0,i.info)("TilingType: "+this.tilingType);const c=s[0],l=s[1],d=s[2],u=s[3],f=i.Util.singularValueDecompose2dScale(this.matrix),p=i.Util.singularValueDecompose2dScale(this.baseTransform),g=[f[0]*p[0],f[1]*p[1]],b=this.getSizeAndScale(n,this.ctx.canvas.width,g[0]),A=this.getSizeAndScale(r,this.ctx.canvas.height,g[1]),m=t.cachedCanvases.getCanvas("pattern",b.size,A.size,!0),w=m.context,v=h.createCanvasGraphics(w);v.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(v,o,a);let k=c,x=l,y=d,_=u;return c<0&&(k=0,y+=Math.abs(c)),l<0&&(x=0,_+=Math.abs(l)),w.translate(-b.scale*k,-A.scale*x),v.transform(b.scale,0,0,A.scale,0,0),this.clipBbox(v,k,x,y,_),v.baseTransform=v.ctx.mozCurrentTransform.slice(),v.executeOperatorList(e),v.endDrawing(),{canvas:m.canvas,scaleX:b.scale,scaleY:A.scale,offsetX:k,offsetY:x}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max(u.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){t.ctx.rect(e,s,i-e,n-s),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,r=t.current;switch(e){case 1:const t=this.ctx;n.fillStyle=t.fillStyle,n.strokeStyle=t.strokeStyle,r.fillColor=t.fillStyle,r.strokeColor=t.strokeStyle;break;case 2:const o=i.Util.makeHexColor(s[0],s[1],s[2]);n.fillStyle=o,n.strokeStyle=o,r.fillColor=o,r.strokeColor=o;break;default:throw new i.FormatError(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,r){let o=s;r!==n.SHADING&&(o=i.Util.transform(o,e.baseTransform),this.matrix&&(o=i.Util.transform(o,this.matrix)));const a=this.createPatternCanvas(e);let h=new DOMMatrix(o);h=h.translate(a.offsetX,a.offsetY),h=h.scale(1/a.scaleX,1/a.scaleY);const c=t.createPattern(a.canvas,"repeat");try{c.setTransform(h)}catch(t){(0,i.warn)(`TilingPattern.getPattern: "${t?.message}".`)}return c}}e.TilingPattern=u},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalWorkerOptions=void 0;const s=Object.create(null);e.GlobalWorkerOptions=s,s.workerPort=void 0===s.workerPort?null:s.workerPort,s.workerSrc=void 0===s.workerSrc?"":s.workerSrc},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageHandler=void 0;var i=s(2);function n(t){if(!(t instanceof Error||"object"==typeof t&&null!==t))return(0,i.warn)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t;switch(t.name){case"AbortException":return new i.AbortException(t.message);case"MissingPDFException":return new i.MissingPDFException(t.message);case"PasswordException":return new i.PasswordException(t.message,t.code);case"UnexpectedResponseException":return new i.UnexpectedResponseException(t.message,t.status);case"UnknownErrorException":return new i.UnknownErrorException(t.message,t.details);default:return new i.UnknownErrorException(t.message,t.toString())}}e.MessageHandler=class{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=t=>{const e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream)return void this._processStreamMessage(e);if(e.callback){const t=e.callbackId,s=this.callbackCapabilities[t];if(!s)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)s.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");s.reject(n(e.reason))}return}const i=this.actionHandler[e.action];if(!i)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,r=e.sourceName;new Promise((function(t){t(i(e.data))})).then((function(i){s.postMessage({sourceName:t,targetName:r,callback:1,callbackId:e.callbackId,data:i})}),(function(i){s.postMessage({sourceName:t,targetName:r,callback:2,callbackId:e.callbackId,reason:n(i)})}))}else e.streamId?this._createStreamSink(e):i(e.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const n=this.callbackId++,r=(0,i.createPromiseCapability)();this.callbackCapabilities[n]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},s)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,s,r){const o=this.streamId++,a=this.sourceName,h=this.targetName,c=this.comObj;return new ReadableStream({start:s=>{const n=(0,i.createPromiseCapability)();return this.streamControllers[o]={controller:s,startCall:n,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:a,targetName:h,action:t,streamId:o,data:e,desiredSize:s.desiredSize},r),n.promise},pull:t=>{const e=(0,i.createPromiseCapability)();return this.streamControllers[o].pullCall=e,c.postMessage({sourceName:a,targetName:h,stream:6,streamId:o,desiredSize:t.desiredSize}),e.promise},cancel:t=>{(0,i.assert)(t instanceof Error,"cancel must have a valid reason");const e=(0,i.createPromiseCapability)();return this.streamControllers[o].cancelCall=e,this.streamControllers[o].isClosed=!0,c.postMessage({sourceName:a,targetName:h,stream:1,streamId:o,reason:n(t)}),e.promise}},s)}_createStreamSink(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,o=this.comObj,a=this,h=this.actionHandler[t.action],c={enqueue(t,n=1,a){if(this.isCancelled)return;const h=this.desiredSize;this.desiredSize-=n,h>0&&this.desiredSize<=0&&(this.sinkCapability=(0,i.createPromiseCapability)(),this.ready=this.sinkCapability.promise),o.postMessage({sourceName:s,targetName:r,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:s,targetName:r,stream:3,streamId:e}),delete a.streamSinks[e])},error(t){(0,i.assert)(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:s,targetName:r,stream:5,streamId:e,reason:n(t)}))},sinkCapability:(0,i.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[e]=c,new Promise((function(e){e(h(t.data,c))})).then((function(){o.postMessage({sourceName:s,targetName:r,stream:8,streamId:e,success:!0})}),(function(t){o.postMessage({sourceName:s,targetName:r,stream:8,streamId:e,reason:n(t)})}))}_processStreamMessage(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,o=this.comObj,a=this.streamControllers[e],h=this.streamSinks[e];switch(t.stream){case 8:t.success?a.startCall.resolve():a.startCall.reject(n(t.reason));break;case 7:t.success?a.pullCall.resolve():a.pullCall.reject(n(t.reason));break;case 6:if(!h){o.postMessage({sourceName:s,targetName:r,stream:7,streamId:e,success:!0});break}h.desiredSize<=0&&t.desiredSize>0&&h.sinkCapability.resolve(),h.desiredSize=t.desiredSize,new Promise((function(t){t(h.onPull&&h.onPull())})).then((function(){o.postMessage({sourceName:s,targetName:r,stream:7,streamId:e,success:!0})}),(function(t){o.postMessage({sourceName:s,targetName:r,stream:7,streamId:e,reason:n(t)})}));break;case 4:if((0,i.assert)(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case 3:if((0,i.assert)(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this._deleteStreamController(a,e);break;case 5:(0,i.assert)(a,"error should have stream controller"),a.controller.error(n(t.reason)),this._deleteStreamController(a,e);break;case 2:t.success?a.cancelCall.resolve():a.cancelCall.reject(n(t.reason)),this._deleteStreamController(a,e);break;case 1:if(!h)break;new Promise((function(e){e(h.onCancel&&h.onCancel(n(t.reason)))})).then((function(){o.postMessage({sourceName:s,targetName:r,stream:2,streamId:e,success:!0})}),(function(t){o.postMessage({sourceName:s,targetName:r,stream:2,streamId:e,reason:n(t)})})),h.sinkCapability.reject(n(t.reason)),h.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(t,e){await Promise.allSettled([t.startCall&&t.startCall.promise,t.pullCall&&t.pullCall.promise,t.cancelCall&&t.cancelCall.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Metadata=void 0;var i=s(2);e.Metadata=class{#n;#r;constructor({parsedData:t,rawData:e}){this.#n=t,this.#r=e}getRaw(){return this.#r}get(t){return this.#n.get(t)??null}getAll(){return(0,i.objectFromMap)(this.#n)}has(t){return this.#n.has(t)}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OptionalContentConfig=void 0;var i=s(2);class n{constructor(t,e){this.visible=!0,this.name=t,this.intent=e}}e.OptionalContentConfig=class{constructor(t){if(this.name=null,this.creator=null,this._order=null,this._groups=new Map,null!==t){this.name=t.name,this.creator=t.creator,this._order=t.order;for(const e of t.groups)this._groups.set(e.id,new n(e.name,e.intent));if("OFF"===t.baseState)for(const t of this._groups)t.visible=!1;for(const e of t.on)this._groups.get(e).visible=!0;for(const e of t.off)this._groups.get(e).visible=!1}}_evaluateVisibilityExpression(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let n=1;n<e;n++){const e=t[n];let r;if(Array.isArray(e))r=this._evaluateVisibilityExpression(e);else{if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;r=this._groups.get(e).visible}switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return"And"===s}isVisible(t){if(0===this._groups.size)return!0;if(!t)return(0,i.warn)("Optional content group not defined."),!0;if("OCG"===t.type)return this._groups.has(t.id)?this._groups.get(t.id).visible:((0,i.warn)(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this._evaluateVisibilityExpression(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(this._groups.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(!this._groups.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(!this._groups.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this._groups.has(e))return(0,i.warn)(`Optional content group not found: ${e}`),!0;if(this._groups.get(e).visible)return!1}return!0}return(0,i.warn)(`Unknown optional content policy ${t.policy}.`),!0}return(0,i.warn)(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){this._groups.has(t)?this._groups.get(t).visible=!!e:(0,i.warn)(`Optional content group not found: ${t}`)}getOrder(){return this._groups.size?this._order?this._order.slice():Array.from(this._groups.keys()):null}getGroups(){return this._groups.size>0?(0,i.objectFromMap)(this._groups):null}getGroup(t){return this._groups.get(t)||null}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFDataTransportStream=void 0;var i=s(2),n=s(1);e.PDFDataTransportStream=class{constructor(t,e){(0,i.assert)(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=t.progressiveDone||!1,this._contentDispositionFilename=t.contentDispositionFilename||null;const s=t.initialData;if(s?.length>0){const t=new Uint8Array(s).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._contentLength=t.length,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),this._pdfDataRangeTransport.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),this._pdfDataRangeTransport.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),this._pdfDataRangeTransport.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),this._pdfDataRangeTransport.transportReady()}_onReceiveData(t){const e=new Uint8Array(t.chunk).buffer;if(void 0===t.begin)this._fullRequestReader?this._fullRequestReader._enqueue(e):this._queuedChunks.push(e);else{const s=this._rangeReaders.some((function(s){return s._begin===t.begin&&(s._enqueue(e),!0)}));(0,i.assert)(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){if(void 0===t.total){const e=this._rangeReaders[0];e?.onProgress&&e.onProgress({loaded:t.loaded})}else{const e=this._fullRequestReader;e?.onProgress&&e.onProgress({loaded:t.loaded,total:t.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new r(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new o(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}};class r{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=(0,n.isPdfFile)(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class o{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.XfaText=void 0;class s{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let n=null;const r=i.name;if("#text"===r)n=i.value;else{if(!s.shouldBuildText(r))return;i?.attributes?.textContent?n=i.attributes.textContent:i.value&&(n=i.value)}if(null!==n&&e.push({str:n}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}e.XfaText=s},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AnnotationLayer=void 0;var i=s(2),n=s(1),r=s(9),o=s(19),a=s(20);const h=1e3,c=new WeakSet;class l{static create(t){switch(t.data.annotationType){case i.AnnotationType.LINK:return new u(t);case i.AnnotationType.TEXT:return new f(t);case i.AnnotationType.WIDGET:switch(t.data.fieldType){case"Tx":return new g(t);case"Btn":return t.data.radioButton?new A(t):t.data.checkBox?new b(t):new m(t);case"Ch":return new w(t)}return new p(t);case i.AnnotationType.POPUP:return new v(t);case i.AnnotationType.FREETEXT:return new x(t);case i.AnnotationType.LINE:return new y(t);case i.AnnotationType.SQUARE:return new _(t);case i.AnnotationType.CIRCLE:return new D(t);case i.AnnotationType.POLYLINE:return new M(t);case i.AnnotationType.CARET:return new F(t);case i.AnnotationType.INK:return new C(t);case i.AnnotationType.POLYGON:return new E(t);case i.AnnotationType.HIGHLIGHT:return new P(t);case i.AnnotationType.UNDERLINE:return new S(t);case i.AnnotationType.SQUIGGLY:return new O(t);case i.AnnotationType.STRIKEOUT:return new T(t);case i.AnnotationType.STAMP:return new R(t);case i.AnnotationType.FILEATTACHMENT:return new I(t);default:return new d(t)}}}class d{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.page=t.page,this.viewport=t.viewport,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this._mouseState=t.mouseState,e&&(this.container=this._createContainer(s)),i&&(this.quadrilaterals=this._createQuadrilaterals(s))}_createContainer(t=!1){const e=this.data,s=this.page,n=this.viewport,r=document.createElement("section");let o=e.rect[2]-e.rect[0],a=e.rect[3]-e.rect[1];r.setAttribute("data-annotation-id",e.id);const h=i.Util.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]);if(e.hasOwnCanvas){const t=n.transform.slice(),[e,s]=i.Util.singularValueDecompose2dScale(t);o=Math.ceil(o*e),a=Math.ceil(a*s),h[0]*=e,h[1]*=s;for(let e=0;e<4;e++)t[e]=Math.sign(t[e]);r.style.transform=`matrix(${t.join(",")})`}else r.style.transform=`matrix(${n.transform.join(",")})`;if(r.style.transformOrigin=`${-h[0]}px ${-h[1]}px`,!t&&e.borderStyle.width>0){r.style.borderWidth=`${e.borderStyle.width}px`,e.borderStyle.style!==i.AnnotationBorderStyleType.UNDERLINE&&(o-=2*e.borderStyle.width,a-=2*e.borderStyle.width);const t=e.borderStyle.horizontalCornerRadius,s=e.borderStyle.verticalCornerRadius;switch((t>0||s>0)&&(r.style.borderRadius=`${t}px / ${s}px`),e.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:r.style.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:r.style.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:r.style.borderBottomStyle="solid"}e.borderColor||e.color?r.style.borderColor=i.Util.makeHexColor(0|e.color[0],0|e.color[1],0|e.color[2]):r.style.borderWidth=0}return r.style.left=`${h[0]}px`,r.style.top=`${h[1]}px`,e.hasOwnCanvas?r.style.width=r.style.height="auto":(r.style.width=`${o}px`,r.style.height=`${a}px`),r}_createQuadrilaterals(t=!1){if(!this.data.quadPoints)return null;const e=[],s=this.data.rect;for(const s of this.data.quadPoints)this.data.rect=[s[2].x,s[2].y,s[1].x,s[1].y],e.push(this._createContainer(t));return this.data.rect=s,e}_createPopup(t,e){let s=this.container;this.quadrilaterals&&(t=t||this.quadrilaterals,s=this.quadrilaterals[0]),t||((t=document.createElement("div")).style.height=s.style.height,t.style.width=s.style.width,s.appendChild(t));const i=new k({container:s,trigger:t,color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,hideWrapper:!0}).render();i.style.left=s.style.width,s.appendChild(i)}_renderQuadrilaterals(t){for(const e of this.quadrilaterals)e.className=t;return this.quadrilaterals}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:t,id:r,exportValues:o}of n){if(-1===t)continue;if(r===e)continue;const n="string"==typeof o?o:null,a=document.getElementById(r);!a||c.has(a)?s.push({id:r,exportValue:n,domElement:a}):(0,i.warn)(`_getElementsByName - element not allowed: ${r}`)}return s}for(const i of document.getElementsByName(t)){const{id:t,exportValue:n}=i;t!==e&&c.has(i)&&s.push({id:t,exportValue:n,domElement:i})}return s}static get platform(){const t="undefined"!=typeof navigator?navigator.platform:"";return(0,i.shadow)(this,"platform",{isWin:t.includes("Win"),isMac:t.includes("Mac")})}}class u extends d{constructor(t,e=null){super(t,{isRenderable:!!(t.data.url||t.data.dest||t.data.action||t.data.isTooltipOnly||t.data.resetForm||t.data.actions&&(t.data.actions.Action||t.data.actions["Mouse Up"]||t.data.actions["Mouse Down"])),ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0})}render(){const{data:t,linkService:e}=this,s=document.createElement("a");if(t.url)e.addLinkAttributes||(0,i.warn)("LinkAnnotationElement.render - missing `addLinkAttributes`-method on the `linkService`-instance."),e.addLinkAttributes?.(s,t.url,t.newWindow);else if(t.action)this._bindNamedAction(s,t.action);else if(t.dest)this._bindLink(s,t.dest);else{let e=!1;t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(e=!0,this._bindJSAction(s,t)),t.resetForm?this._bindResetFormAction(s,t.resetForm):e||this._bindLink(s,"")}return this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map(((t,e)=>{const i=0===e?s:s.cloneNode();return t.appendChild(i),t})):(this.container.className="linkAnnotation",this.container.appendChild(s),this.container)}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&(t.className="internalLink")}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),t.className="internalLink"}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),t.className="internalLink"}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),t.className="internalLink",!this._fieldObjects)return(0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(s||(t.onclick=()=>!1));t.onclick=()=>{s&&s();const{fields:t,refs:i,include:n}=e,r=[];if(0!==t.length||0!==i.length){const e=new Set(i);for(const s of t){const t=this._fieldObjects[s]||[];for(const{id:s}of t)e.add(s)}for(const t of Object.values(this._fieldObjects))for(const s of t)e.has(s.id)===n&&r.push(s)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const o=this.annotationStorage,a=[];for(const t of r){const{id:e}=t;switch(a.push(e),t.type){case"text":{const s=t.defaultValue||"";o.setValue(e,{value:s,valueAsString:s});break}case"checkbox":case"radiobutton":o.setValue(e,{value:t.defaultValue===t.exportValues});break;case"combobox":case"listbox":o.setValue(e,{value:t.defaultValue||""});break;default:continue}const s=document.getElementById(e);s&&c.has(s)&&s.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:a,name:"ResetForm"}}),!1}}}class f extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str)})}render(){this.container.className="textAnnotation";const t=document.createElement("img");return t.style.height=this.container.style.height,t.style.width=this.container.style.width,t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.alt="[{{type}} Annotation]",t.dataset.l10nId="text_annotation_type",t.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.hasPopup||this._createPopup(t,this.data),this.container.appendChild(t),this.container}}class p extends d{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}_getKeyModifier(t){const{isWin:e,isMac:s}=d.platform;return e&&t.ctrlKey||s&&t.metaKey}_setEventListener(t,e,s,i){e.includes("mouse")?t.addEventListener(e,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(e,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:t.target.checked}})}))}_setEventListeners(t,e,s){for(const[i,n]of e)("Action"===n||this.data.actions?.[n])&&this._setEventListener(t,i,n,s)}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":i.Util.makeHexColor(e[0],e[1],e[2])}_dispatchEventFromSandbox(t,e){const s=(t,e,s)=>{const i=s.detail[t];s.target.style[e]=o.ColorConverters[`${i[0]}_HTML`](i.slice(1))},i={display:t=>{const e=t.detail.display%2==1;t.target.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:e,print:0===t.detail.display||3===t.detail.display})},print:t=>{this.annotationStorage.setValue(this.data.id,{print:t.detail.print})},hidden:t=>{t.target.style.visibility=t.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:t.detail.hidden})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.detail.readonly?t.target.setAttribute("readonly",""):t.target.removeAttribute("readonly")},required:t=>{t.detail.required?t.target.setAttribute("required",""):t.target.removeAttribute("required")},bgColor:t=>{s("bgColor","backgroundColor",t)},fillColor:t=>{s("fillColor","backgroundColor",t)},fgColor:t=>{s("fgColor","color",t)},textColor:t=>{s("textColor","color",t)},borderColor:t=>{s("borderColor","borderColor",t)},strokeColor:t=>{s("strokeColor","borderColor",t)}};for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n&&n(e)}}}class g extends p{constructor(t){super(t,{isRenderable:t.renderForms||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.className="textWidgetAnnotation";let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue,valueAsString:this.data.fieldValue}),n=i.valueAsString||i.value||"",r={userValue:null,formattedValue:null,beforeInputSelectionRange:null,beforeInputValue:null};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=n):(s=document.createElement("input"),s.type="text",s.setAttribute("value",n)),c.add(s),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=h,r.userValue=n,s.setAttribute("id",e),s.addEventListener("input",(i=>{t.setValue(e,{value:i.target.value}),this.setPropertyOnSiblings(s,"value",i.target.value,"value")})),s.addEventListener("resetform",(()=>{s.value=r.userValue=this.data.defaultFieldValue||"",delete r.formattedValue}));let o=t=>{r.formattedValue&&(t.target.value=r.formattedValue),t.target.scrollLeft=0,r.beforeInputSelectionRange=null};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(t=>{r.userValue&&(t.target.value=r.userValue)})),s.addEventListener("updatefromsandbox",(s=>{this._dispatchEventFromSandbox({value(s){r.userValue=s.detail.value||"",t.setValue(e,{value:r.userValue.toString()}),r.formattedValue||(s.target.value=r.userValue)},valueAsString(s){r.formattedValue=s.detail.valueAsString||"",s.target!==document.activeElement&&(s.target.value=r.formattedValue),t.setValue(e,{formattedValue:r.formattedValue})},selRange(t){const[e,s]=t.detail.selRange;e>=0&&s<t.target.value.length&&t.target.setSelectionRange(e,s)}},s)})),s.addEventListener("keydown",(t=>{r.beforeInputValue=t.target.value;let s=-1;"Escape"===t.key?s=0:"Enter"===t.key?s=2:"Tab"===t.key&&(s=3),-1!==s&&(r.userValue=t.target.value,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:t.target.value,willCommit:!0,commitKey:s,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const i=o;o=null,s.addEventListener("blur",(t=>{this._mouseState.isDown&&(r.userValue=t.target.value,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:t.target.value,willCommit:!0,commitKey:1,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})),i(t)})),s.addEventListener("mousedown",(t=>{r.beforeInputValue=t.target.value,r.beforeInputSelectionRange=null})),s.addEventListener("keyup",(t=>{t.target.selectionStart===t.target.selectionEnd&&(r.beforeInputSelectionRange=null)})),s.addEventListener("select",(t=>{r.beforeInputSelectionRange=[t.target.selectionStart,t.target.selectionEnd]})),this.data.actions?.Keystroke&&s.addEventListener("input",(t=>{let s=-1,i=-1;r.beforeInputSelectionRange&&([s,i]=r.beforeInputSelectionRange),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r.beforeInputValue,change:t.data,willCommit:!1,selStart:s,selEnd:i}})})),this._setEventListeners(s,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(o&&s.addEventListener("blur",o),null!==this.data.maxLen&&(s.maxLength=this.data.maxLen),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/this.data.maxLen;s.classList.add("comb"),s.style.letterSpacing=`calc(${t}px - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell";return this._setTextStyle(s),this._setBackgroundColor(s),this.container.appendChild(s),this.container}_setTextStyle(t){const{fontSize:e,fontColor:s}=this.data.defaultAppearanceData,n=t.style;e&&(n.fontSize=`${e}px`),n.color=i.Util.makeHexColor(s[0],s[1],s[2]),null!==this.data.textAlignment&&(n.textAlign=["left","center","right"][this.data.textAlignment])}}class b extends p{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,t.setValue(s,{value:i})),this.container.className="buttonWidgetAnnotation checkBox";const n=document.createElement("input");return c.add(n),n.disabled=e.readOnly,n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("id",s),n.setAttribute("exportValue",e.exportValue),n.tabIndex=h,n.addEventListener("change",(i=>{const{name:n,checked:r}=i.target;for(const i of this._getElementsByName(n,s)){const s=r&&i.exportValue===e.exportValue;i.domElement&&(i.domElement.checked=s),t.setValue(i.id,{value:s})}t.setValue(s,{value:r})})),n.addEventListener("resetform",(t=>{t.target.checked=(e.defaultFieldValue||"Off")===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(s,{value:e.target.checked})}},e)})),this._setEventListeners(n,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this.container.appendChild(n),this.container}}class A extends p{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.className="buttonWidgetAnnotation radioButton";const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;"string"==typeof i&&(i=i!==e.buttonValue,t.setValue(s,{value:i}));const n=document.createElement("input");if(c.add(n),n.disabled=e.readOnly,n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("id",s),n.tabIndex=h,n.addEventListener("change",(e=>{const{name:i,checked:n}=e.target;for(const e of this._getElementsByName(i,s))t.setValue(e.id,{value:!1});t.setValue(s,{value:n})})),n.addEventListener("resetform",(t=>{const s=e.defaultFieldValue;t.target.checked=null!=s&&s===e.buttonValue})),this.enableScripting&&this.hasJSActions){const i=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value:e=>{const n=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=n&&i.id===s;i.domElement&&(i.domElement.checked=e),t.setValue(i.id,{value:e})}}},e)})),this._setEventListeners(n,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this.container.appendChild(n),this.container}}class m extends u{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();return t.className="buttonWidgetAnnotation pushButton",this.data.alternativeText&&(t.title=this.data.alternativeText),t}}class w extends p{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.className="choiceWidgetAnnotation";const t=this.annotationStorage,e=this.data.id;t.getValue(e,{value:this.data.fieldValue.length>0?this.data.fieldValue[0]:void 0});let{fontSize:s}=this.data.defaultAppearanceData;s||(s=9);const i=`calc(${s}px * var(--zoom-factor))`,n=document.createElement("select");c.add(n),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.setAttribute("id",e),n.tabIndex=h,n.style.fontSize=`${s}px`,this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(()=>{const t=this.data.defaultFieldValue;for(const e of n.options)e.selected=e.value===t}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,this.data.combo&&(e.style.fontSize=i),this.data.fieldValue.includes(t.exportValue)&&e.setAttribute("selected",!0),n.appendChild(e)}const r=(t,e)=>{const s=e?"value":"textContent",i=t.target.options;return t.target.multiple?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[s])):-1===i.selectedIndex?null:i[i.selectedIndex][s]},o=t=>Array.prototype.map.call(t.target.options,(t=>({displayValue:t.textContent,exportValue:t.value})));return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(s=>{this._dispatchEventFromSandbox({value(s){const i=s.detail.value,o=new Set(Array.isArray(i)?i:[i]);for(const t of n.options)t.selected=o.has(t.value);t.setValue(e,{value:r(s,!0)})},multipleSelection(t){n.multiple=!0},remove(s){const i=n.options,a=s.detail.remove;i[a].selected=!1,n.remove(a),i.length>0&&-1===Array.prototype.findIndex.call(i,(t=>t.selected))&&(i[0].selected=!0),t.setValue(e,{value:r(s,!0),items:o(s)})},clear(s){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]})},insert(s){const{index:i,displayValue:a,exportValue:h}=s.detail.insert,c=document.createElement("option");c.textContent=a,c.value=h,n.insertBefore(c,n.children[i]),t.setValue(e,{value:r(s,!0),items:o(s)})},items(s){const{items:i}=s.detail;for(;0!==n.length;)n.remove(0);for(const t of i){const{displayValue:e,exportValue:s}=t,i=document.createElement("option");i.textContent=e,i.value=s,n.appendChild(i)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:r(s,!0),items:o(s)})},indices(s){const i=new Set(s.detail.indices);for(const t of s.target.options)t.selected=i.has(t.index);t.setValue(e,{value:r(s,!0)})},editable(t){t.target.disabled=!t.detail.editable}},s)})),n.addEventListener("input",(s=>{const i=r(s,!0),n=r(s,!1);t.setValue(e,{value:i}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,changeEx:i,willCommit:!0,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"]],(t=>t.target.checked))):n.addEventListener("input",(function(s){t.setValue(e,{value:r(s)})})),this._setBackgroundColor(n),this.container.appendChild(n),this.container}}class v extends d{constructor(t){super(t,{isRenderable:!!(t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str)})}render(){if(this.container.className="popupAnnotation",["Line","Square","Circle","PolyLine","Polygon","Ink"].includes(this.data.parentType))return this.container;const t=this.layer.querySelectorAll(`[data-annotation-id="${this.data.parentId}"]`);if(0===t.length)return this.container;const e=new k({container:this.container,trigger:Array.from(t),color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText}),s=this.page,n=i.Util.normalizeRect([this.data.parentRect[0],s.view[3]-this.data.parentRect[1]+s.view[1],this.data.parentRect[2],s.view[3]-this.data.parentRect[3]+s.view[1]]),r=n[0]+this.data.parentRect[2]-this.data.parentRect[0],o=n[1];return this.container.style.transformOrigin=`${-r}px ${-o}px`,this.container.style.left=`${r}px`,this.container.style.top=`${o}px`,this.container.appendChild(e.render()),this.container}}class k{constructor(t){this.container=t.container,this.trigger=t.trigger,this.color=t.color,this.titleObj=t.titleObj,this.modificationDate=t.modificationDate,this.contentsObj=t.contentsObj,this.richText=t.richText,this.hideWrapper=t.hideWrapper||!1,this.pinned=!1}render(){const t=document.createElement("div");t.className="popupWrapper",this.hideElement=this.hideWrapper?t:this.container,this.hideElement.hidden=!0;const e=document.createElement("div");e.className="popup";const s=this.color;s&&(e.style.backgroundColor=i.Util.makeHexColor(0|.7*(255-s[0])+s[0],0|.7*(255-s[1])+s[1],0|.7*(255-s[2])+s[2]));const r=document.createElement("h1");r.dir=this.titleObj.dir,r.textContent=this.titleObj.str,e.appendChild(r);const o=n.PDFDateString.toDateObject(this.modificationDate);if(o){const t=document.createElement("span");t.className="popupDate",t.textContent="{{date}}, {{time}}",t.dataset.l10nId="annotation_date_string",t.dataset.l10nArgs=JSON.stringify({date:o.toLocaleDateString(),time:o.toLocaleTimeString()}),e.appendChild(t)}if(!this.richText?.str||this.contentsObj?.str&&this.contentsObj.str!==this.richText.str){const t=this._formatContents(this.contentsObj);e.appendChild(t)}else a.XfaLayer.render({xfaHtml:this.richText.html,intent:"richText",div:e}),e.lastChild.className="richText popupContent";Array.isArray(this.trigger)||(this.trigger=[this.trigger]);for(const t of this.trigger)t.addEventListener("click",this._toggle.bind(this)),t.addEventListener("mouseover",this._show.bind(this,!1)),t.addEventListener("mouseout",this._hide.bind(this,!1));return e.addEventListener("click",this._hide.bind(this,!0)),t.appendChild(e),t}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.className="popupContent",s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let t=0,e=i.length;t<e;++t)s.appendChild(document.createTextNode(i[t])),t<e-1&&s.appendChild(document.createElement("br"));return s}_toggle(){this.pinned?this._hide(!0):this._show(!0)}_show(t=!1){t&&(this.pinned=!0),this.hideElement.hidden&&(this.hideElement.hidden=!1,this.container.style.zIndex+=1)}_hide(t=!0){t&&(this.pinned=!1),this.hideElement.hidden||this.pinned||(this.hideElement.hidden=!0,this.container.style.zIndex-=1)}}class x extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){return this.container.className="freeTextAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class y extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="lineAnnotation";const t=this.data,e=this.svgFactory.create(t.rect[2]-t.rect[0],t.rect[3]-t.rect[1]),s=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),s.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),s.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),s.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),s.setAttribute("stroke-width",t.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),e.appendChild(s),this.container.append(e),this._createPopup(s,t),this.container}}class _ extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="squareAnnotation";const t=this.data,e=t.rect[2]-t.rect[0],s=t.rect[3]-t.rect[1],i=this.svgFactory.create(e,s),n=t.borderStyle.width,r=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.appendChild(r),this.container.append(i),this._createPopup(r,t),this.container}}class D extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="circleAnnotation";const t=this.data,e=t.rect[2]-t.rect[0],s=t.rect[3]-t.rect[1],i=this.svgFactory.create(e,s),n=t.borderStyle.width,r=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.appendChild(r),this.container.append(i),this._createPopup(r,t),this.container}}class M extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const t=this.data,e=this.svgFactory.create(t.rect[2]-t.rect[0],t.rect[3]-t.rect[1]);let s=[];for(const e of t.vertices)s.push(e.x-t.rect[0]+","+(t.rect[3]-e.y));s=s.join(" ");const i=this.svgFactory.createElement(this.svgElementName);return i.setAttribute("points",s),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),e.appendChild(i),this.container.append(e),this._createPopup(i,t),this.container}}class E extends M{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class F extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){return this.container.className="caretAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class C extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const t=this.data,e=this.svgFactory.create(t.rect[2]-t.rect[0],t.rect[3]-t.rect[1]);for(const s of t.inkLists){let i=[];for(const e of s)i.push(`${e.x-t.rect[0]},${t.rect[3]-e.y}`);i=i.join(" ");const n=this.svgFactory.createElement(this.svgElementName);n.setAttribute("points",i),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),this._createPopup(n,t),e.appendChild(n)}return this.container.append(e),this.container}}class P extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("highlightAnnotation"):(this.container.className="highlightAnnotation",this.container)}}class S extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("underlineAnnotation"):(this.container.className="underlineAnnotation",this.container)}}class O extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("squigglyAnnotation"):(this.container.className="squigglyAnnotation",this.container)}}class T extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("strikeoutAnnotation"):(this.container.className="strikeoutAnnotation",this.container)}}class R extends d{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){return this.container.className="stampAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class I extends d{constructor(t){super(t,{isRenderable:!0});const{filename:e,content:s}=this.data.file;this.filename=(0,n.getFilenameFromUrl)(e),this.content=s,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,id:(0,i.stringToPDFString)(e),filename:e,content:s})}render(){this.container.className="fileAttachmentAnnotation";const t=document.createElement("div");return t.style.height=this.container.style.height,t.style.width=this.container.style.width,t.addEventListener("dblclick",this._download.bind(this)),!this.data.hasPopup&&(this.data.titleObj?.str||this.data.contentsObj?.str||this.data.richText)&&this._createPopup(t,this.data),this.container.appendChild(t),this.container}_download(){this.downloadManager?.openOrDownloadData(this.container,this.content,this.filename)}}e.AnnotationLayer=class{static render(t){const e=[],s=[];for(const n of t.annotations)n&&(n.annotationType!==i.AnnotationType.POPUP?e.push(n):s.push(n));s.length&&e.push(...s);const o=t.div;for(const s of e){const e=l.create({data:s,layer:o,page:t.page,viewport:t.viewport,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new n.DOMSVGFactory,annotationStorage:t.annotationStorage||new r.AnnotationStorage,enableScripting:t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,mouseState:t.mouseState||{isDown:!1}});if(e.isRenderable){const t=e.render();if(s.hidden&&(t.style.visibility="hidden"),Array.isArray(t))for(const e of t)o.appendChild(e);else e instanceof v?o.prepend(t):o.appendChild(t)}}this.#o(o,t.annotationCanvasMap)}static update(t){const{page:e,viewport:s,annotations:n,annotationCanvasMap:r,div:o}=t,a=s.transform,h=`matrix(${a.join(",")})`;let c,l;for(const t of n){const s=o.querySelectorAll(`[data-annotation-id="${t.id}"]`);if(s)for(const n of s)if(t.hasOwnCanvas){const s=i.Util.normalizeRect([t.rect[0],e.view[3]-t.rect[1]+e.view[1],t.rect[2],e.view[3]-t.rect[3]+e.view[1]]);if(!l){c=Math.abs(a[0]||a[1]);const t=a.slice();for(let e=0;e<4;e++)t[e]=Math.sign(t[e]);l=`matrix(${t.join(",")})`}const r=s[0]*c,o=s[1]*c;n.style.left=`${r}px`,n.style.top=`${o}px`,n.style.transformOrigin=`${-r}px ${-o}px`,n.style.transform=l}else n.style.transform=h}this.#o(o,r),o.hidden=!1}static#o(t,e){if(e){for(const[s,i]of e){const e=t.querySelector(`[data-annotation-id="${s}"]`);if(!e)continue;const{firstChild:n}=e;"CANVAS"===n.nodeName?e.replaceChild(i,n):e.insertBefore(i,n)}e.clear()}}}},(t,e)=>{function s(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}Object.defineProperty(e,"__esModule",{value:!0}),e.ColorConverters=void 0,e.ColorConverters=class{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_HTML([t]){const e=s(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_HTML([t,e,i]){return`#${s(t)}${s(e)}${s(i)}`}static T_HTML(){return"#00000000"}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_HTML(t){return this.RGB_HTML(this.CMYK_RGB(t))}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s;return["CMYK",i,n,r,Math.min(i,n,r)]}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.XfaLayer=void 0;var i=s(2),n=s(17);e.XfaLayer=class{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===s.attributes.type||"checkbox"===s.attributes.type){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{i.setValue(e,{value:t.target.getAttribute(t.target.checked?"xfaOn":"xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value)for(const t of s.children)t.attributes.value===r.value&&(t.attributes.selected=!0);t.addEventListener("input",(t=>{const s=t.target.options;i.setValue(e,{value:-1===s.selectedIndex?"":s[s.selectedIndex].value})}))}}static setAttributes({html:t,element:e,storage:s=null,intent:n,linkService:r}){const{attributes:o}=e,a=t instanceof HTMLAnchorElement;"radio"===o.type&&(o.name=`${o.name}-${n}`);for(const[e,s]of Object.entries(o))if(null!=s&&"dataId"!==e)if("style"!==e)if("textContent"===e)t.textContent=s;else if("class"===e)s.length&&t.setAttribute(e,s.join(" "));else{if(a&&("href"===e||"newWindow"===e))continue;t.setAttribute(e,s)}else Object.assign(t.style,s);a&&(r.addLinkAttributes||(0,i.warn)("XfaLayer.setAttribute - missing `addLinkAttributes`-method on the `linkService`-instance."),r.addLinkAttributes?.(t,o.href,o.newWindow)),s&&o.dataId&&this.setupStorage(t,o.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:r,linkService:s});const a=[[i,-1,o]],h=t.div;if(h.appendChild(o),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=e}"richText"!==r&&h.setAttribute("class","xfaLayer xfaFont");const c=[];for(;a.length>0;){const[t,i,o]=a[a.length-1];if(i+1===t.children.length){a.pop();continue}const h=t.children[++a[a.length-1][1]];if(null===h)continue;const{name:l}=h;if("#text"===l){const t=document.createTextNode(h.value);c.push(t),o.appendChild(t);continue}let d;if(d=h?.attributes?.xmlns?document.createElementNS(h.attributes.xmlns,l):document.createElement(l),o.appendChild(d),h.attributes&&this.setAttributes({html:d,element:h,storage:e,intent:r,linkService:s}),h.children&&h.children.length>0)a.push([h,-1,d]);else if(h.value){const t=document.createTextNode(h.value);n.XfaText.shouldBuildText(l)&&c.push(t),d.appendChild(t)}}for(const t of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.renderTextLayer=function(t){const e=new d({textContent:t.textContent,textContentStream:t.textContentStream,container:t.container,viewport:t.viewport,textDivs:t.textDivs,textContentItemsStr:t.textContentItemsStr,enhanceTextSelection:t.enhanceTextSelection});return e._render(t.timeout),e};var i=s(2);const n=30,r=new Map,o=/^\s+$/g;function a(t,e,s,a){const h=document.createElement("span"),c=t._enhanceTextSelection?{angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,originalTransform:null,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,scale:1}:{angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL};t._textDivs.push(h);const l=i.Util.transform(t._viewport.transform,e.transform);let d=Math.atan2(l[1],l[0]);const u=s[e.fontName];u.vertical&&(d+=Math.PI/2);const f=Math.hypot(l[2],l[3]),p=f*function(t,e){const s=r.get(t);if(s)return s;e.save(),e.font=`30px ${t}`;const i=e.measureText("");let o=i.fontBoundingBoxAscent,a=Math.abs(i.fontBoundingBoxDescent);if(o){e.restore();const s=o/(o+a);return r.set(t,s),s}e.strokeStyle="red",e.clearRect(0,0,n,n),e.strokeText("g",0,0);let h=e.getImageData(0,0,n,n).data;a=0;for(let t=h.length-1-3;t>=0;t-=4)if(h[t]>0){a=Math.ceil(t/4/n);break}e.clearRect(0,0,n,n),e.strokeText("A",0,n),h=e.getImageData(0,0,n,n).data,o=0;for(let t=0,e=h.length;t<e;t+=4)if(h[t]>0){o=n-Math.floor(t/4/n);break}if(e.restore(),o){const e=o/(o+a);return r.set(t,e),e}return r.set(t,.8),.8}(u.fontFamily,a);let g,b;0===d?(g=l[4],b=l[5]-p):(g=l[4]+p*Math.sin(d),b=l[5]-p*Math.cos(d)),h.style.left=`${g}px`,h.style.top=`${b}px`,h.style.fontSize=`${f}px`,h.style.fontFamily=u.fontFamily,h.setAttribute("role","presentation"),h.textContent=e.str,h.dir=e.dir,t._fontInspectorEnabled&&(h.dataset.fontName=e.fontName),0!==d&&(c.angle=d*(180/Math.PI));let A=!1;if(e.str.length>1||t._enhanceTextSelection&&o.test(e.str))A=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),s=Math.abs(e.transform[3]);t!==s&&Math.max(t,s)/Math.min(t,s)>1.5&&(A=!0)}if(A&&(c.canvasWidth=u.vertical?e.height*t._viewport.scale:e.width*t._viewport.scale),t._textDivProperties.set(h,c),t._textContentStream&&t._layoutText(h),t._enhanceTextSelection&&c.hasText){let s=1,n=0;0!==d&&(s=Math.cos(d),n=Math.sin(d));const r=(u.vertical?e.height:e.width)*t._viewport.scale,o=f;let a,c;0!==d?(a=[s,n,-n,s,g,b],c=i.Util.getAxialAlignedBoundingBox([0,0,r,o],a)):c=[g,b,g+r,b+o],t._bounds.push({left:c[0],top:c[1],right:c[2],bottom:c[3],div:h,size:[r,o],m:a})}}function h(t){if(t._canceled)return;const e=t._textDivs,s=t._capability,i=e.length;if(i>1e5)return t._renderingDone=!0,void s.resolve();if(!t._textContentStream)for(let s=0;s<i;s++)t._layoutText(e[s]);t._renderingDone=!0,s.resolve()}function c(t,e,s){let i=0;for(let n=0;n<s;n++){const s=t[e++];s>0&&(i=i?Math.min(s,i):s)}return i}function l(t,e){e.sort((function(t,e){return t.x1-e.x1||t.index-e.index}));const s=[{start:-1/0,end:1/0,boundary:{x1:-1/0,y1:-1/0,x2:0,y2:1/0,index:-1,x1New:0,x2New:0}}];for(const t of e){let e=0;for(;e<s.length&&s[e].end<=t.y1;)e++;let i,n,r=s.length-1;for(;r>=0&&s[r].start>=t.y2;)r--;let o,a,h=-1/0;for(o=e;o<=r;o++){let e;i=s[o],n=i.boundary,e=n.x2>t.x1?n.index>t.index?n.x1New:t.x1:void 0===n.x2New?(n.x2+t.x1)/2:n.x2New,e>h&&(h=e)}for(t.x1New=h,o=e;o<=r;o++)i=s[o],n=i.boundary,void 0===n.x2New?n.x2>t.x1?n.index>t.index&&(n.x2New=n.x2):n.x2New=h:n.x2New>h&&(n.x2New=Math.max(h,n.x2));const c=[];let l=null;for(o=e;o<=r;o++){i=s[o],n=i.boundary;const e=n.x2>t.x2?n:t;l===e?c[c.length-1].end=i.end:(c.push({start:i.start,end:i.end,boundary:e}),l=e)}for(s[e].start<t.y1&&(c[0].start=t.y1,c.unshift({start:s[e].start,end:t.y1,boundary:s[e].boundary})),t.y2<s[r].end&&(c[c.length-1].end=t.y2,c.push({start:t.y2,end:s[r].end,boundary:s[r].boundary})),o=e;o<=r;o++){if(i=s[o],n=i.boundary,void 0!==n.x2New)continue;let t=!1;for(a=e-1;!t&&a>=0&&s[a].start>=n.y1;a--)t=s[a].boundary===n;for(a=r+1;!t&&a<s.length&&s[a].end<=n.y2;a++)t=s[a].boundary===n;for(a=0;!t&&a<c.length;a++)t=c[a].boundary===n;t||(n.x2New=h)}Array.prototype.splice.apply(s,[e,r-e+1].concat(c))}for(const e of s){const s=e.boundary;void 0===s.x2New&&(s.x2New=Math.max(t,s.x2))}}class d{constructor({textContent:t,textContentStream:e,container:s,viewport:n,textDivs:r,textContentItemsStr:o,enhanceTextSelection:a}){this._textContent=t,this._textContentStream=e,this._container=s,this._document=s.ownerDocument,this._viewport=n,this._textDivs=r||[],this._textContentItemsStr=o||[],this._enhanceTextSelection=!!a,this._fontInspectorEnabled=!!globalThis.FontInspector?.enabled,this._reader=null,this._layoutTextLastFontSize=null,this._layoutTextLastFontFamily=null,this._layoutTextCtx=null,this._textDivProperties=new WeakMap,this._renderingDone=!1,this._canceled=!1,this._capability=(0,i.createPromiseCapability)(),this._renderTimer=null,this._bounds=[],this._capability.promise.finally((()=>{this._enhanceTextSelection||(this._textDivProperties=null),this._layoutTextCtx&&(this._layoutTextCtx.canvas.width=0,this._layoutTextCtx.canvas.height=0,this._layoutTextCtx=null)})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch((()=>{})),this._reader=null),null!==this._renderTimer&&(clearTimeout(this._renderTimer),this._renderTimer=null),this._capability.reject(new Error("TextLayer task cancelled."))}_processItems(t,e){for(let s=0,i=t.length;s<i;s++)if(void 0!==t[s].str)this._textContentItemsStr.push(t[s].str),a(this,t[s],e,this._layoutTextCtx);else if("beginMarkedContentProps"===t[s].type||"beginMarkedContent"===t[s].type){const e=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),null!==t[s].id&&this._container.setAttribute("id",`${t[s].id}`),e.appendChild(this._container)}else"endMarkedContent"===t[s].type&&(this._container=this._container.parentNode)}_layoutText(t){const e=this._textDivProperties.get(t);let s="";if(0!==e.canvasWidth&&e.hasText){const{fontSize:i,fontFamily:n}=t.style;i===this._layoutTextLastFontSize&&n===this._layoutTextLastFontFamily||(this._layoutTextCtx.font=`${i} ${n}`,this._layoutTextLastFontSize=i,this._layoutTextLastFontFamily=n);const{width:r}=this._layoutTextCtx.measureText(t.textContent);if(r>0){const t=e.canvasWidth/r;this._enhanceTextSelection&&(e.scale=t),s=`scaleX(${t})`}}if(0!==e.angle&&(s=`rotate(${e.angle}deg) ${s}`),s.length>0&&(this._enhanceTextSelection&&(e.originalTransform=s),t.style.transform=s),e.hasText&&this._container.appendChild(t),e.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this._container.appendChild(t)}}_render(t=0){const e=(0,i.createPromiseCapability)();let s=Object.create(null);const r=this._document.createElement("canvas");if(r.height=r.width=n,r.mozOpaque=!0,this._layoutTextCtx=r.getContext("2d",{alpha:!1}),this._textContent)this._processItems(this._textContent.items,this._textContent.styles),e.resolve();else{if(!this._textContentStream)throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');{const t=()=>{this._reader.read().then((({value:i,done:n})=>{n?e.resolve():(Object.assign(s,i.styles),this._processItems(i.items,s),t())}),e.reject)};this._reader=this._textContentStream.getReader(),t()}}e.promise.then((()=>{s=null,t?this._renderTimer=setTimeout((()=>{h(this),this._renderTimer=null}),t):h(this)}),this._capability.reject)}expandTextDivs(t=!1){if(!this._enhanceTextSelection||!this._renderingDone)return;null!==this._bounds&&(function(t){const e=t._bounds,s=t._viewport,n=function(t,e,s){const i=s.map((function(t,e){return{x1:t.left,y1:t.top,x2:t.right,y2:t.bottom,index:e,x1New:void 0,x2New:void 0}}));l(t,i);const n=new Array(s.length);for(const t of i)n[t.index]={left:t.x1New,top:0,right:t.x2New,bottom:0};s.map((function(e,s){const r=n[s],o=i[s];o.x1=e.top,o.y1=t-r.right,o.x2=e.bottom,o.y2=t-r.left,o.index=s,o.x1New=void 0,o.x2New=void 0})),l(e,i);for(const t of i){const e=t.index;n[e].top=t.x1New,n[e].bottom=t.x2New}return n}(s.width,s.height,e);for(let s=0;s<n.length;s++){const r=e[s].div,o=t._textDivProperties.get(r);if(0===o.angle){o.paddingLeft=e[s].left-n[s].left,o.paddingTop=e[s].top-n[s].top,o.paddingRight=n[s].right-e[s].right,o.paddingBottom=n[s].bottom-e[s].bottom,t._textDivProperties.set(r,o);continue}const a=n[s],h=e[s],l=h.m,d=l[0],u=l[1],f=[[0,0],[0,h.size[1]],[h.size[0],0],h.size],p=new Float64Array(64);for(let t=0,e=f.length;t<e;t++){const e=i.Util.applyTransform(f[t],l);p[t+0]=d&&(a.left-e[0])/d,p[t+4]=u&&(a.top-e[1])/u,p[t+8]=d&&(a.right-e[0])/d,p[t+12]=u&&(a.bottom-e[1])/u,p[t+16]=u&&(a.left-e[0])/-u,p[t+20]=d&&(a.top-e[1])/d,p[t+24]=u&&(a.right-e[0])/-u,p[t+28]=d&&(a.bottom-e[1])/d,p[t+32]=d&&(a.left-e[0])/-d,p[t+36]=u&&(a.top-e[1])/-u,p[t+40]=d&&(a.right-e[0])/-d,p[t+44]=u&&(a.bottom-e[1])/-u,p[t+48]=u&&(a.left-e[0])/u,p[t+52]=d&&(a.top-e[1])/-d,p[t+56]=u&&(a.right-e[0])/u,p[t+60]=d&&(a.bottom-e[1])/-d}const g=1+Math.min(Math.abs(d),Math.abs(u));o.paddingLeft=c(p,32,16)/g,o.paddingTop=c(p,48,16)/g,o.paddingRight=c(p,0,16)/g,o.paddingBottom=c(p,16,16)/g,t._textDivProperties.set(r,o)}}(this),this._bounds=null);const e=[],s=[];for(let i=0,n=this._textDivs.length;i<n;i++){const n=this._textDivs[i],r=this._textDivProperties.get(n);r.hasText&&(t?(e.length=0,s.length=0,r.originalTransform&&e.push(r.originalTransform),r.paddingTop>0?(s.push(`${r.paddingTop}px`),e.push(`translateY(${-r.paddingTop}px)`)):s.push(0),s.push(r.paddingRight>0?r.paddingRight/r.scale+"px":0),s.push(r.paddingBottom>0?`${r.paddingBottom}px`:0),r.paddingLeft>0?(s.push(r.paddingLeft/r.scale+"px"),e.push(`translateX(${-r.paddingLeft/r.scale}px)`)):s.push(0),n.style.padding=s.join(" "),e.length&&(n.style.transform=e.join(" "))):(n.style.padding=null,n.style.transform=r.originalTransform))}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SVGGraphics=void 0;var i=s(2),n=s(1),r=s(4);let o=class{constructor(){(0,i.unreachable)("Not implemented: SVGGraphics")}};e.SVGGraphics=o;{const t={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},s="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/1999/xlink",l=["butt","round","square"],d=["miter","round","bevel"],u=function(){const t=new Uint8Array([137,80,78,71,13,10,26,10]),e=new Int32Array(256);for(let t=0;t<256;t++){let s=t;for(let t=0;t<8;t++)s=1&s?3988292384^s>>1&2147483647:s>>1&2147483647;e[t]=s}function s(t,s,i,n){let r=n;const o=s.length;i[r]=o>>24&255,i[r+1]=o>>16&255,i[r+2]=o>>8&255,i[r+3]=255&o,r+=4,i[r]=255&t.charCodeAt(0),i[r+1]=255&t.charCodeAt(1),i[r+2]=255&t.charCodeAt(2),i[r+3]=255&t.charCodeAt(3),r+=4,i.set(s,r),r+=s.length;const a=function(t,s,i){let n=-1;for(let r=s;r<i;r++)n=n>>>8^e[255&(n^t[r])];return-1^n}(i,n+4,r);i[r]=a>>24&255,i[r+1]=a>>16&255,i[r+2]=a>>8&255,i[r+3]=255&a}function n(t){let e=t.length;const s=65535,i=Math.ceil(e/s),n=new Uint8Array(2+e+5*i+4);let r=0;n[r++]=120,n[r++]=156;let o=0;for(;e>s;)n[r++]=0,n[r++]=255,n[r++]=255,n[r++]=0,n[r++]=0,n.set(t.subarray(o,o+s),r),r+=s,o+=s,e-=s;n[r++]=1,n[r++]=255&e,n[r++]=e>>8&255,n[r++]=255&~e,n[r++]=(65535&~e)>>8&255,n.set(t.subarray(o),r),r+=t.length-o;const a=function(t,e,s){let i=1,n=0;for(let e=0;e<s;++e)i=(i+(255&t[e]))%65521,n=(n+i)%65521;return n<<16|i}(t,0,t.length);return n[r++]=a>>24&255,n[r++]=a>>16&255,n[r++]=a>>8&255,n[r++]=255&a,n}return function(e,o,a){return function(e,o,a,h){const c=e.width,l=e.height;let d,u,f;const p=e.data;switch(o){case i.ImageKind.GRAYSCALE_1BPP:u=0,d=1,f=c+7>>3;break;case i.ImageKind.RGB_24BPP:u=2,d=8,f=3*c;break;case i.ImageKind.RGBA_32BPP:u=6,d=8,f=4*c;break;default:throw new Error("invalid format")}const g=new Uint8Array((1+f)*l);let b=0,A=0;for(let t=0;t<l;++t)g[b++]=0,g.set(p.subarray(A,A+f),b),A+=f,b+=f;if(o===i.ImageKind.GRAYSCALE_1BPP&&h){b=0;for(let t=0;t<l;t++){b++;for(let t=0;t<f;t++)g[b++]^=255}}const m=new Uint8Array([c>>24&255,c>>16&255,c>>8&255,255&c,l>>24&255,l>>16&255,l>>8&255,255&l,d,u,0,0,0]),w=function(t){if(!r.isNodeJS)return n(t);try{let e;e=parseInt(process_1.versions.node)>=8?t:Buffer.from(t);const s=require$$5.deflateSync(e,{level:9});return s instanceof Uint8Array?s:new Uint8Array(s)}catch(t){(0,i.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+t)}return n(t)}(g),v=new Uint8Array(t.length+36+m.length+w.length);let k=0;return v.set(t,k),k+=t.length,s("IHDR",m,v,k),k+=12+m.length,s("IDATA",w,v,k),k+=12+w.length,s("IEND",new Uint8Array(0),v,k),(0,i.createObjectURL)(v,"image/png",a)}(e,void 0===e.kind?i.ImageKind.GRAYSCALE_1BPP:e.kind,o,a)}}();class f{constructor(){this.fontSizeScale=1,this.fontWeight=t.fontWeight,this.fontSize=0,this.textMatrix=i.IDENTITY_MATRIX,this.fontMatrix=i.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=i.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=t.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(t,e){this.x=t,this.y=e}}function a(t){if(Number.isInteger(t))return t.toString();const e=t.toFixed(10);let s=e.length-1;if("0"!==e[s])return e;do{s--}while("0"===e[s]);return e.substring(0,"."===e[s]?s:s+1)}function h(t){if(0===t[4]&&0===t[5]){if(0===t[1]&&0===t[2])return 1===t[0]&&1===t[3]?"":`scale(${a(t[0])} ${a(t[3])})`;if(t[0]===t[3]&&t[1]===-t[2])return`rotate(${a(180*Math.acos(t[0])/Math.PI)})`}else if(1===t[0]&&0===t[1]&&0===t[2]&&1===t[3])return`translate(${a(t[4])} ${a(t[5])})`;return`matrix(${a(t[0])} ${a(t[1])} ${a(t[2])} ${a(t[3])} ${a(t[4])} ${a(t[5])})`}let p=0,g=0,b=0;e.SVGGraphics=o=class{constructor(t,e,s=!1){this.svgFactory=new n.DOMSVGFactory,this.current=new f,this.transformMatrix=i.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=t,this.objs=e,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!s,this._operatorIdMapping=[];for(const t in i.OPS)this._operatorIdMapping[i.OPS[t]]=t}save(){this.transformStack.push(this.transformMatrix);const t=this.current;this.extraStack.push(t),this.current=t.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(t){this.save(),this.executeOpTree(t),this.restore()}loadDependencies(t){const e=t.fnArray,s=t.argsArray;for(let t=0,n=e.length;t<n;t++)if(e[t]===i.OPS.dependency)for(const e of s[t]){const t=e.startsWith("g_")?this.commonObjs:this.objs,s=new Promise((s=>{t.get(e,s)}));this.current.dependencies.push(s)}return Promise.all(this.current.dependencies)}transform(t,e,s,n,r,o){this.transformMatrix=i.Util.transform(this.transformMatrix,[t,e,s,n,r,o]),this.tgrp=null}getSVG(t,e){this.viewport=e;const s=this._initialize(e);return this.loadDependencies(t).then((()=>(this.transformMatrix=i.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(t)),s)))}convertOpList(t){const e=this._operatorIdMapping,s=t.argsArray,i=t.fnArray,n=[];for(let t=0,r=i.length;t<r;t++){const r=i[t];n.push({fnId:r,fn:e[r],args:s[t]})}return function(t){let e=[];const s=[];for(const i of t)"save"!==i.fn?"restore"===i.fn?e=s.pop():e.push(i):(e.push({fnId:92,fn:"group",items:[]}),s.push(e),e=e[e.length-1].items);return e}(n)}executeOpTree(t){for(const e of t){const t=e.fn,s=e.args;switch(0|e.fnId){case i.OPS.beginText:this.beginText();break;case i.OPS.dependency:break;case i.OPS.setLeading:this.setLeading(s);break;case i.OPS.setLeadingMoveText:this.setLeadingMoveText(s[0],s[1]);break;case i.OPS.setFont:this.setFont(s);break;case i.OPS.showText:case i.OPS.showSpacedText:this.showText(s[0]);break;case i.OPS.endText:this.endText();break;case i.OPS.moveText:this.moveText(s[0],s[1]);break;case i.OPS.setCharSpacing:this.setCharSpacing(s[0]);break;case i.OPS.setWordSpacing:this.setWordSpacing(s[0]);break;case i.OPS.setHScale:this.setHScale(s[0]);break;case i.OPS.setTextMatrix:this.setTextMatrix(s[0],s[1],s[2],s[3],s[4],s[5]);break;case i.OPS.setTextRise:this.setTextRise(s[0]);break;case i.OPS.setTextRenderingMode:this.setTextRenderingMode(s[0]);break;case i.OPS.setLineWidth:this.setLineWidth(s[0]);break;case i.OPS.setLineJoin:this.setLineJoin(s[0]);break;case i.OPS.setLineCap:this.setLineCap(s[0]);break;case i.OPS.setMiterLimit:this.setMiterLimit(s[0]);break;case i.OPS.setFillRGBColor:this.setFillRGBColor(s[0],s[1],s[2]);break;case i.OPS.setStrokeRGBColor:this.setStrokeRGBColor(s[0],s[1],s[2]);break;case i.OPS.setStrokeColorN:this.setStrokeColorN(s);break;case i.OPS.setFillColorN:this.setFillColorN(s);break;case i.OPS.shadingFill:this.shadingFill(s[0]);break;case i.OPS.setDash:this.setDash(s[0],s[1]);break;case i.OPS.setRenderingIntent:this.setRenderingIntent(s[0]);break;case i.OPS.setFlatness:this.setFlatness(s[0]);break;case i.OPS.setGState:this.setGState(s[0]);break;case i.OPS.fill:this.fill();break;case i.OPS.eoFill:this.eoFill();break;case i.OPS.stroke:this.stroke();break;case i.OPS.fillStroke:this.fillStroke();break;case i.OPS.eoFillStroke:this.eoFillStroke();break;case i.OPS.clip:this.clip("nonzero");break;case i.OPS.eoClip:this.clip("evenodd");break;case i.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case i.OPS.paintImageXObject:this.paintImageXObject(s[0]);break;case i.OPS.paintInlineImageXObject:this.paintInlineImageXObject(s[0]);break;case i.OPS.paintImageMaskXObject:this.paintImageMaskXObject(s[0]);break;case i.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(s[0],s[1]);break;case i.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case i.OPS.closePath:this.closePath();break;case i.OPS.closeStroke:this.closeStroke();break;case i.OPS.closeFillStroke:this.closeFillStroke();break;case i.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case i.OPS.nextLine:this.nextLine();break;case i.OPS.transform:this.transform(s[0],s[1],s[2],s[3],s[4],s[5]);break;case i.OPS.constructPath:this.constructPath(s[0],s[1]);break;case i.OPS.endPath:this.endPath();break;case 92:this.group(e.items);break;default:(0,i.warn)(`Unimplemented operator ${t}`)}}}setWordSpacing(t){this.current.wordSpacing=t}setCharSpacing(t){this.current.charSpacing=t}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(t,e,s,i,n,r){const o=this.current;o.textMatrix=o.lineMatrix=[t,e,s,i,n,r],o.textMatrixScale=Math.hypot(t,e),o.x=o.lineX=0,o.y=o.lineY=0,o.xcoords=[],o.ycoords=[],o.tspan=this.svgFactory.createElement("svg:tspan"),o.tspan.setAttributeNS(null,"font-family",o.fontFamily),o.tspan.setAttributeNS(null,"font-size",`${a(o.fontSize)}px`),o.tspan.setAttributeNS(null,"y",a(-o.y)),o.txtElement=this.svgFactory.createElement("svg:text"),o.txtElement.appendChild(o.tspan)}beginText(){const t=this.current;t.x=t.lineX=0,t.y=t.lineY=0,t.textMatrix=i.IDENTITY_MATRIX,t.lineMatrix=i.IDENTITY_MATRIX,t.textMatrixScale=1,t.tspan=this.svgFactory.createElement("svg:tspan"),t.txtElement=this.svgFactory.createElement("svg:text"),t.txtgrp=this.svgFactory.createElement("svg:g"),t.xcoords=[],t.ycoords=[]}moveText(t,e){const s=this.current;s.x=s.lineX+=t,s.y=s.lineY+=e,s.xcoords=[],s.ycoords=[],s.tspan=this.svgFactory.createElement("svg:tspan"),s.tspan.setAttributeNS(null,"font-family",s.fontFamily),s.tspan.setAttributeNS(null,"font-size",`${a(s.fontSize)}px`),s.tspan.setAttributeNS(null,"y",a(-s.y))}showText(e){const n=this.current,r=n.font,o=n.fontSize;if(0===o)return;const c=n.fontSizeScale,l=n.charSpacing,d=n.wordSpacing,u=n.fontDirection,f=n.textHScale*u,p=r.vertical,g=p?1:-1,b=r.defaultVMetrics,A=o*n.fontMatrix[0];let m=0;for(const t of e){if(null===t){m+=u*d;continue}if((0,i.isNum)(t)){m+=g*t*o/1e3;continue}const e=(t.isSpace?d:0)+l,s=t.fontChar;let a,h,f,w=t.width;if(p){let e;const s=t.vmetric||b;e=t.vmetric?s[1]:.5*w,e=-e*A,w=s?-s[0]:w,a=e/c,h=(m+s[2]*A)/c}else a=m/c,h=0;(t.isInFont||r.missingFile)&&(n.xcoords.push(n.x+a),p&&n.ycoords.push(-n.y+h),n.tspan.textContent+=s),f=p?w*A-e*u:w*A+e*u,m+=f}n.tspan.setAttributeNS(null,"x",n.xcoords.map(a).join(" ")),n.tspan.setAttributeNS(null,"y",p?n.ycoords.map(a).join(" "):a(-n.y)),p?n.y-=m:n.x+=m*f,n.tspan.setAttributeNS(null,"font-family",n.fontFamily),n.tspan.setAttributeNS(null,"font-size",`${a(n.fontSize)}px`),n.fontStyle!==t.fontStyle&&n.tspan.setAttributeNS(null,"font-style",n.fontStyle),n.fontWeight!==t.fontWeight&&n.tspan.setAttributeNS(null,"font-weight",n.fontWeight);const w=n.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;w===i.TextRenderingMode.FILL||w===i.TextRenderingMode.FILL_STROKE?(n.fillColor!==t.fillColor&&n.tspan.setAttributeNS(null,"fill",n.fillColor),n.fillAlpha<1&&n.tspan.setAttributeNS(null,"fill-opacity",n.fillAlpha)):n.tspan.setAttributeNS(null,"fill",n.textRenderingMode===i.TextRenderingMode.ADD_TO_PATH?"transparent":"none"),(w===i.TextRenderingMode.STROKE||w===i.TextRenderingMode.FILL_STROKE)&&this._setStrokeAttributes(n.tspan,1/(n.textMatrixScale||1));let v=n.textMatrix;0!==n.textRise&&(v=v.slice(),v[5]+=n.textRise),n.txtElement.setAttributeNS(null,"transform",`${h(v)} scale(${a(f)}, -1)`),n.txtElement.setAttributeNS(s,"xml:space","preserve"),n.txtElement.appendChild(n.tspan),n.txtgrp.appendChild(n.txtElement),this._ensureTransformGroup().appendChild(n.txtElement)}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}addFontStyle(t){if(!t.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.appendChild(this.cssStyle));const e=(0,i.createObjectURL)(t.data,t.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${t.loadedName}"; src: url(${e}); }\n`}setFont(t){const e=this.current,s=this.commonObjs.get(t[0]);let n=t[1];e.font=s,!this.embedFonts||s.missingFile||this.embeddedFonts[s.loadedName]||(this.addFontStyle(s),this.embeddedFonts[s.loadedName]=s),e.fontMatrix=s.fontMatrix||i.FONT_IDENTITY_MATRIX;let r="normal";s.black?r="900":s.bold&&(r="bold");const o=s.italic?"italic":"normal";n<0?(n=-n,e.fontDirection=-1):e.fontDirection=1,e.fontSize=n,e.fontFamily=s.loadedName,e.fontWeight=r,e.fontStyle=o,e.tspan=this.svgFactory.createElement("svg:tspan"),e.tspan.setAttributeNS(null,"y",a(-e.y)),e.xcoords=[],e.ycoords=[]}endText(){const t=this.current;t.textRenderingMode&i.TextRenderingMode.ADD_TO_PATH_FLAG&&t.txtElement?.hasChildNodes()&&(t.element=t.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(t){t>0&&(this.current.lineWidth=t)}setLineCap(t){this.current.lineCap=l[t]}setLineJoin(t){this.current.lineJoin=d[t]}setMiterLimit(t){this.current.miterLimit=t}setStrokeAlpha(t){this.current.strokeAlpha=t}setStrokeRGBColor(t,e,s){this.current.strokeColor=i.Util.makeHexColor(t,e,s)}setFillAlpha(t){this.current.fillAlpha=t}setFillRGBColor(t,e,s){this.current.fillColor=i.Util.makeHexColor(t,e,s),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(t){this.current.strokeColor=this._makeColorN_Pattern(t)}setFillColorN(t){this.current.fillColor=this._makeColorN_Pattern(t)}shadingFill(t){const e=this.viewport.width,s=this.viewport.height,n=i.Util.inverseTransform(this.transformMatrix),r=i.Util.applyTransform([0,0],n),o=i.Util.applyTransform([0,s],n),a=i.Util.applyTransform([e,0],n),h=i.Util.applyTransform([e,s],n),c=Math.min(r[0],o[0],a[0],h[0]),l=Math.min(r[1],o[1],a[1],h[1]),d=Math.max(r[0],o[0],a[0],h[0]),u=Math.max(r[1],o[1],a[1],h[1]),f=this.svgFactory.createElement("svg:rect");f.setAttributeNS(null,"x",c),f.setAttributeNS(null,"y",l),f.setAttributeNS(null,"width",d-c),f.setAttributeNS(null,"height",u-l),f.setAttributeNS(null,"fill",this._makeShadingPattern(t)),this.current.fillAlpha<1&&f.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().appendChild(f)}_makeColorN_Pattern(t){return"TilingPattern"===t[0]?this._makeTilingPattern(t):this._makeShadingPattern(t)}_makeTilingPattern(t){const e=t[1],s=t[2],n=t[3]||i.IDENTITY_MATRIX,[r,o,a,h]=t[4],c=t[5],l=t[6],d=t[7],u="shading"+b++,[f,p,g,A]=i.Util.normalizeRect([...i.Util.applyTransform([r,o],n),...i.Util.applyTransform([a,h],n)]),[m,w]=i.Util.singularValueDecompose2dScale(n),v=c*m,k=l*w,x=this.svgFactory.createElement("svg:pattern");x.setAttributeNS(null,"id",u),x.setAttributeNS(null,"patternUnits","userSpaceOnUse"),x.setAttributeNS(null,"width",v),x.setAttributeNS(null,"height",k),x.setAttributeNS(null,"x",`${f}`),x.setAttributeNS(null,"y",`${p}`);const y=this.svg,_=this.transformMatrix,D=this.current.fillColor,M=this.current.strokeColor,E=this.svgFactory.create(g-f,A-p);if(this.svg=E,this.transformMatrix=n,2===d){const t=i.Util.makeHexColor(...e);this.current.fillColor=t,this.current.strokeColor=t}return this.executeOpTree(this.convertOpList(s)),this.svg=y,this.transformMatrix=_,this.current.fillColor=D,this.current.strokeColor=M,x.appendChild(E.childNodes[0]),this.defs.appendChild(x),`url(#${u})`}_makeShadingPattern(t){switch("string"==typeof t&&(t=this.objs.get(t)),t[0]){case"RadialAxial":const e="shading"+b++,s=t[3];let n;switch(t[1]){case"axial":const s=t[4],i=t[5];n=this.svgFactory.createElement("svg:linearGradient"),n.setAttributeNS(null,"id",e),n.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),n.setAttributeNS(null,"x1",s[0]),n.setAttributeNS(null,"y1",s[1]),n.setAttributeNS(null,"x2",i[0]),n.setAttributeNS(null,"y2",i[1]);break;case"radial":const r=t[4],o=t[5],a=t[6],h=t[7];n=this.svgFactory.createElement("svg:radialGradient"),n.setAttributeNS(null,"id",e),n.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),n.setAttributeNS(null,"cx",o[0]),n.setAttributeNS(null,"cy",o[1]),n.setAttributeNS(null,"r",h),n.setAttributeNS(null,"fx",r[0]),n.setAttributeNS(null,"fy",r[1]),n.setAttributeNS(null,"fr",a);break;default:throw new Error(`Unknown RadialAxial type: ${t[1]}`)}for(const t of s){const e=this.svgFactory.createElement("svg:stop");e.setAttributeNS(null,"offset",t[0]),e.setAttributeNS(null,"stop-color",t[1]),n.appendChild(e)}return this.defs.appendChild(n),`url(#${e})`;case"Mesh":return(0,i.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${t[0]}`)}}setDash(t,e){this.current.dashArray=t,this.current.dashPhase=e}constructPath(t,e){const s=this.current;let n=s.x,r=s.y,o=[],h=0;for(const s of t)switch(0|s){case i.OPS.rectangle:n=e[h++],r=e[h++];const t=n+e[h++],s=r+e[h++];o.push("M",a(n),a(r),"L",a(t),a(r),"L",a(t),a(s),"L",a(n),a(s),"Z");break;case i.OPS.moveTo:n=e[h++],r=e[h++],o.push("M",a(n),a(r));break;case i.OPS.lineTo:n=e[h++],r=e[h++],o.push("L",a(n),a(r));break;case i.OPS.curveTo:n=e[h+4],r=e[h+5],o.push("C",a(e[h]),a(e[h+1]),a(e[h+2]),a(e[h+3]),a(n),a(r)),h+=6;break;case i.OPS.curveTo2:o.push("C",a(n),a(r),a(e[h]),a(e[h+1]),a(e[h+2]),a(e[h+3])),n=e[h+2],r=e[h+3],h+=4;break;case i.OPS.curveTo3:n=e[h+2],r=e[h+3],o.push("C",a(e[h]),a(e[h+1]),a(n),a(r),a(n),a(r)),h+=4;break;case i.OPS.closePath:o.push("Z")}o=o.join(" "),s.path&&t.length>0&&t[0]!==i.OPS.rectangle&&t[0]!==i.OPS.moveTo?o=s.path.getAttributeNS(null,"d")+o:(s.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().appendChild(s.path)),s.path.setAttributeNS(null,"d",o),s.path.setAttributeNS(null,"fill","none"),s.element=s.path,s.setCurrentPoint(n,r)}endPath(){const t=this.current;if(t.path=null,!this.pendingClip)return;if(!t.element)return void(this.pendingClip=null);const e="clippath"+p++,s=this.svgFactory.createElement("svg:clipPath");s.setAttributeNS(null,"id",e),s.setAttributeNS(null,"transform",h(this.transformMatrix));const i=t.element.cloneNode(!0);if(i.setAttributeNS(null,"clip-rule","evenodd"===this.pendingClip?"evenodd":"nonzero"),this.pendingClip=null,s.appendChild(i),this.defs.appendChild(s),t.activeClipUrl){t.clipGroup=null;for(const t of this.extraStack)t.clipGroup=null;s.setAttributeNS(null,"clip-path",t.activeClipUrl)}t.activeClipUrl=`url(#${e})`,this.tgrp=null}clip(t){this.pendingClip=t}closePath(){const t=this.current;if(t.path){const e=`${t.path.getAttributeNS(null,"d")}Z`;t.path.setAttributeNS(null,"d",e)}}setLeading(t){this.current.leading=-t}setTextRise(t){this.current.textRise=t}setTextRenderingMode(t){this.current.textRenderingMode=t}setHScale(t){this.current.textHScale=t/100}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s);break;case"CA":this.setStrokeAlpha(s);break;case"ca":this.setFillAlpha(s);break;default:(0,i.warn)(`Unimplemented graphic state operator ${e}`)}}fill(){const t=this.current;t.element&&(t.element.setAttributeNS(null,"fill",t.fillColor),t.element.setAttributeNS(null,"fill-opacity",t.fillAlpha),this.endPath())}stroke(){const t=this.current;t.element&&(this._setStrokeAttributes(t.element),t.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(t,e=1){const s=this.current;let i=s.dashArray;1!==e&&i.length>0&&(i=i.map((function(t){return e*t}))),t.setAttributeNS(null,"stroke",s.strokeColor),t.setAttributeNS(null,"stroke-opacity",s.strokeAlpha),t.setAttributeNS(null,"stroke-miterlimit",a(s.miterLimit)),t.setAttributeNS(null,"stroke-linecap",s.lineCap),t.setAttributeNS(null,"stroke-linejoin",s.lineJoin),t.setAttributeNS(null,"stroke-width",a(e*s.lineWidth)+"px"),t.setAttributeNS(null,"stroke-dasharray",i.map(a).join(" ")),t.setAttributeNS(null,"stroke-dashoffset",a(e*s.dashPhase)+"px")}eoFill(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){const t=this.svgFactory.createElement("svg:rect");t.setAttributeNS(null,"x","0"),t.setAttributeNS(null,"y","0"),t.setAttributeNS(null,"width","1px"),t.setAttributeNS(null,"height","1px"),t.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().appendChild(t)}paintImageXObject(t){const e=t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);e?this.paintInlineImageXObject(e):(0,i.warn)(`Dependent image with object ID ${t} is not ready yet`)}paintInlineImageXObject(t,e){const s=t.width,i=t.height,n=u(t,this.forceDataSchema,!!e),r=this.svgFactory.createElement("svg:rect");r.setAttributeNS(null,"x","0"),r.setAttributeNS(null,"y","0"),r.setAttributeNS(null,"width",a(s)),r.setAttributeNS(null,"height",a(i)),this.current.element=r,this.clip("nonzero");const o=this.svgFactory.createElement("svg:image");o.setAttributeNS(c,"xlink:href",n),o.setAttributeNS(null,"x","0"),o.setAttributeNS(null,"y",a(-i)),o.setAttributeNS(null,"width",a(s)+"px"),o.setAttributeNS(null,"height",a(i)+"px"),o.setAttributeNS(null,"transform",`scale(${a(1/s)} ${a(-1/i)})`),e?e.appendChild(o):this._ensureTransformGroup().appendChild(o)}paintImageMaskXObject(t){const e=this.current,s=t.width,i=t.height,n=e.fillColor;e.maskId="mask"+g++;const r=this.svgFactory.createElement("svg:mask");r.setAttributeNS(null,"id",e.maskId);const o=this.svgFactory.createElement("svg:rect");o.setAttributeNS(null,"x","0"),o.setAttributeNS(null,"y","0"),o.setAttributeNS(null,"width",a(s)),o.setAttributeNS(null,"height",a(i)),o.setAttributeNS(null,"fill",n),o.setAttributeNS(null,"mask",`url(#${e.maskId})`),this.defs.appendChild(r),this._ensureTransformGroup().appendChild(o),this.paintInlineImageXObject(t,r)}paintFormXObjectBegin(t,e){if(Array.isArray(t)&&6===t.length&&this.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e){const t=e[2]-e[0],s=e[3]-e[1],i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x",e[0]),i.setAttributeNS(null,"y",e[1]),i.setAttributeNS(null,"width",a(t)),i.setAttributeNS(null,"height",a(s)),this.current.element=i,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(t){const e=this.svgFactory.create(t.width,t.height),s=this.svgFactory.createElement("svg:defs");e.appendChild(s),this.defs=s;const i=this.svgFactory.createElement("svg:g");return i.setAttributeNS(null,"transform",h(t.transform)),e.appendChild(i),this.svg=i,e}_ensureClipGroup(){if(!this.current.clipGroup){const t=this.svgFactory.createElement("svg:g");t.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.appendChild(t),this.current.clipGroup=t}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",h(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().appendChild(this.tgrp):this.svg.appendChild(this.tgrp)),this.tgrp}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFNodeStream=void 0;var i=s(2),n=s(24);const r=require$$5,o=require$$5,a=require$$5,h=require$$5,c=/^file:\/\/\/[a-zA-Z]:\//;e.PDFNodeStream=class{constructor(t){this.source=t,this.url=function(t){const e=h.parse(t);return"file:"===e.protocol||e.host?e:/^[a-z]:[/\\]/i.test(t)?h.parse(`file:///${t}`):(e.host||(e.protocol="file:"),e)}(t.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new g(this):new f(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new b(this,t,e):new p(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class l{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=(0,i.createPromiseCapability)(),this._headersCapability=(0,i.createPromiseCapability)()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=t.length,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class d{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=(0,i.createPromiseCapability)(),this._isStreamingSupported=!t.source.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=t.length,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}function u(t,e){return{protocol:t.protocol,auth:t.auth,host:t.hostname,port:t.port,path:t.path,method:"GET",headers:e}}class f extends l{constructor(t){super(t);const e=e=>{if(404===e.statusCode){const t=new i.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=t,void this._headersCapability.reject(t)}this._headersCapability.resolve(),this._setReadableStream(e);const s=t=>this._readableStream.headers[t.toLowerCase()],{allowRangeRequests:r,suggestedLength:o}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:s,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=o||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(s)};this._request=null,this._request="http:"===this._url.protocol?o.request(u(this._url,t.httpHeaders),e):a.request(u(this._url,t.httpHeaders),e),this._request.on("error",(t=>{this._storedError=t,this._headersCapability.reject(t)})),this._request.end()}}class p extends d{constructor(t,e,s){super(t),this._httpHeaders={};for(const e in t.httpHeaders){const s=t.httpHeaders[e];void 0!==s&&(this._httpHeaders[e]=s)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const n=t=>{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=t}};this._request=null,this._request="http:"===this._url.protocol?o.request(u(this._url,this._httpHeaders),n):a.request(u(this._url,this._httpHeaders),n),this._request.on("error",(t=>{this._storedError=t})),this._request.end()}}class g extends l{constructor(t){super(t);let e=decodeURIComponent(this._url.path);c.test(this._url.href)&&(e=e.replace(/^\//,"")),r.lstat(e,((t,s)=>{if(t)return"ENOENT"===t.code&&(t=new i.MissingPDFException(`Missing PDF "${e}".`)),this._storedError=t,void this._headersCapability.reject(t);this._contentLength=s.size,this._setReadableStream(r.createReadStream(e)),this._headersCapability.resolve()}))}}class b extends d{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);c.test(this._url.href)&&(i=i.replace(/^\//,"")),this._setReadableStream(r.createReadStream(i,{start:e,end:s-1}))}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createResponseStatusError=function(t,e){return 404===t||0===t&&e.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+e+'".'):new i.UnexpectedResponseException(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)},e.extractFilenameFromHeader=function(t){const e=t("Content-Disposition");if(e){let t=(0,n.getFilenameFromContentDispositionHeader)(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch(t){}if((0,r.isPdfFile)(t))return t}return null},e.validateRangeRequestCapabilities=function({getResponseHeader:t,isHttp:e,rangeChunkSize:s,disableRange:n}){(0,i.assert)(s>0,"Range chunk size must be larger than zero");const r={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(t("Content-Length"),10);return Number.isInteger(o)?(r.suggestedLength=o,o<=2*s||n||!e||"bytes"!==t("Accept-Ranges")||"identity"!==(t("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r):r},e.validateResponseStatus=function(t){return 200===t||206===t};var i=s(2),n=s(25),r=s(1)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getFilenameFromContentDispositionHeader=function(t){let e=!0,s=n("filename\\*","i").exec(t);if(s){s=s[1];let t=a(s);return t=unescape(t),t=h(t),t=c(t),o(t)}if(s=function(t){const e=[];let s;const i=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(s=i.exec(t));){let[,t,i,n]=s;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[i,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[s,i]=e[t];i=a(i),s&&(i=unescape(i),0===t&&(i=h(i))),r.push(i)}return r.join("")}(t),s)return o(c(s));if(s=n("filename","i").exec(t),s){s=s[1];let t=a(s);return t=c(t),o(t)}function n(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function r(t,s){if(t){if(!/^[\x00-\xFF]+$/.test(s))return s;try{const n=new TextDecoder(t,{fatal:!0}),r=(0,i.stringToBytes)(s);s=n.decode(r),e=!1}catch(i){if(/^utf-?8$/i.test(t))try{s=decodeURIComponent(escape(s)),e=!1}catch(t){}}}return s}function o(t){return e&&/[\x80-\xff]/.test(t)&&(t=r("utf-8",t),e&&(t=r("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const s=e[t].indexOf('"');-1!==s&&(e[t]=e[t].slice(0,s),e.length=t+1),e[t]=e[t].replace(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){const e=t.indexOf("'");return-1===e?t:r(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function c(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,s,i){if("q"===s||"Q"===s)return r(e,i=(i=i.replace(/_/g," ")).replace(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{i=atob(i)}catch(t){}return r(e,i)}))}return""};var i=s(2)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFNetworkStream=void 0;var i=s(2),n=s(24);class r{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.getXhr=e.getXhr||function(){return new XMLHttpRequest},this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const t in s)i[t]=s[t];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=this.getXhr(),s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const t in this.httpHeaders){const s=this.httpHeaders[t];void 0!==s&&e.setRequestHeader(t,s)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const n=s.xhr;if(n.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==n.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===n.status&&this.isHttp)return void s.onError?.(n.status);const r=n.status||200;if((200!==r||206!==s.expectedStatus)&&r!==s.expectedStatus)return void s.onError?.(n.status);const o=function(t){const e=t.response;return"string"!=typeof e?e:(0,i.stringToBytes)(e).buffer}(n);if(206===r){const t=n.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);s.onDone({begin:parseInt(e[1],10),chunk:o})}else o?s.onDone({begin:0,chunk:o}):s.onError?.(n.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}e.PDFNetworkStream=class{constructor(t){this._source=t,this._manager=new r(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new o(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new a(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class o{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=(0,i.createPromiseCapability)(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=t=>e.getResponseHeader(t),{allowRangeRequests:i,suggestedLength:r}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=(0,n.createResponseStatusError)(t,this._url),this._headersReceivedCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class a{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=(0,n.createResponseStatusError)(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,i.createPromiseCapability)();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFFetchStream=void 0;var i=s(2),n=s(24);function r(t,e,s){return{method:"GET",headers:t,signal:s?.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function o(t){const e=new Headers;for(const s in t){const i=t[s];void 0!==i&&e.append(s,i)}return e}e.PDFFetchStream=class{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new a(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new h(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class a{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=(0,i.createPromiseCapability)(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),"undefined"!=typeof AbortController&&(this._abortController=new AbortController),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._headers=o(this._stream.httpHeaders);const s=e.url;fetch(s,r(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,n.validateResponseStatus)(t.status))throw(0,n.createResponseStatusError)(t.status,s);this._reader=t.body.getReader(),this._headersCapability.resolve();const e=e=>t.headers.get(e),{allowRangeRequests:r,suggestedLength:o}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=o||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._reader&&this._reader.cancel(t),this._abortController&&this._abortController.abort()}}class h{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const a=t.source;this._withCredentials=a.withCredentials||!1,this._readCapability=(0,i.createPromiseCapability)(),this._isStreamingSupported=!a.disableStream,"undefined"!=typeof AbortController&&(this._abortController=new AbortController),this._headers=o(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const h=a.url;fetch(h,r(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,n.validateResponseStatus)(t.status))throw(0,n.createResponseStatusError)(t.status,h);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._reader&&this._reader.cancel(t),this._abortController&&this._abortController.abort()}}}],__webpack_module_cache__={};function __w_pdfjs_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var s=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](s,s.exports,__w_pdfjs_require__),s.exports}var __webpack_exports__={};return(()=>{var t=__webpack_exports__;Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"AnnotationLayer",{enumerable:!0,get:function(){return n.AnnotationLayer}}),Object.defineProperty(t,"AnnotationMode",{enumerable:!0,get:function(){return s.AnnotationMode}}),Object.defineProperty(t,"CMapCompressionType",{enumerable:!0,get:function(){return s.CMapCompressionType}}),Object.defineProperty(t,"GlobalWorkerOptions",{enumerable:!0,get:function(){return r.GlobalWorkerOptions}}),Object.defineProperty(t,"InvalidPDFException",{enumerable:!0,get:function(){return s.InvalidPDFException}}),Object.defineProperty(t,"LinkTarget",{enumerable:!0,get:function(){return e.LinkTarget}}),Object.defineProperty(t,"LoopbackPort",{enumerable:!0,get:function(){return i.LoopbackPort}}),Object.defineProperty(t,"MissingPDFException",{enumerable:!0,get:function(){return s.MissingPDFException}}),Object.defineProperty(t,"OPS",{enumerable:!0,get:function(){return s.OPS}}),Object.defineProperty(t,"PDFDataRangeTransport",{enumerable:!0,get:function(){return i.PDFDataRangeTransport}}),Object.defineProperty(t,"PDFDateString",{enumerable:!0,get:function(){return e.PDFDateString}}),Object.defineProperty(t,"PDFWorker",{enumerable:!0,get:function(){return i.PDFWorker}}),Object.defineProperty(t,"PasswordResponses",{enumerable:!0,get:function(){return s.PasswordResponses}}),Object.defineProperty(t,"PermissionFlag",{enumerable:!0,get:function(){return s.PermissionFlag}}),Object.defineProperty(t,"PixelsPerInch",{enumerable:!0,get:function(){return e.PixelsPerInch}}),Object.defineProperty(t,"RenderingCancelledException",{enumerable:!0,get:function(){return e.RenderingCancelledException}}),Object.defineProperty(t,"SVGGraphics",{enumerable:!0,get:function(){return h.SVGGraphics}}),Object.defineProperty(t,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return s.UNSUPPORTED_FEATURES}}),Object.defineProperty(t,"UnexpectedResponseException",{enumerable:!0,get:function(){return s.UnexpectedResponseException}}),Object.defineProperty(t,"Util",{enumerable:!0,get:function(){return s.Util}}),Object.defineProperty(t,"VerbosityLevel",{enumerable:!0,get:function(){return s.VerbosityLevel}}),Object.defineProperty(t,"XfaLayer",{enumerable:!0,get:function(){return c.XfaLayer}}),Object.defineProperty(t,"addLinkAttributes",{enumerable:!0,get:function(){return e.addLinkAttributes}}),Object.defineProperty(t,"build",{enumerable:!0,get:function(){return i.build}}),Object.defineProperty(t,"createObjectURL",{enumerable:!0,get:function(){return s.createObjectURL}}),Object.defineProperty(t,"createPromiseCapability",{enumerable:!0,get:function(){return s.createPromiseCapability}}),Object.defineProperty(t,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return s.createValidAbsoluteUrl}}),Object.defineProperty(t,"getDocument",{enumerable:!0,get:function(){return i.getDocument}}),Object.defineProperty(t,"getFilenameFromUrl",{enumerable:!0,get:function(){return e.getFilenameFromUrl}}),Object.defineProperty(t,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return e.getPdfFilenameFromUrl}}),Object.defineProperty(t,"getXfaPageViewport",{enumerable:!0,get:function(){return e.getXfaPageViewport}}),Object.defineProperty(t,"isPdfFile",{enumerable:!0,get:function(){return e.isPdfFile}}),Object.defineProperty(t,"loadScript",{enumerable:!0,get:function(){return e.loadScript}}),Object.defineProperty(t,"removeNullCharacters",{enumerable:!0,get:function(){return s.removeNullCharacters}}),Object.defineProperty(t,"renderTextLayer",{enumerable:!0,get:function(){return a.renderTextLayer}}),Object.defineProperty(t,"shadow",{enumerable:!0,get:function(){return s.shadow}}),Object.defineProperty(t,"version",{enumerable:!0,get:function(){return i.version}});var e=__w_pdfjs_require__(1),s=__w_pdfjs_require__(2),i=__w_pdfjs_require__(6),n=__w_pdfjs_require__(18),r=__w_pdfjs_require__(12),o=__w_pdfjs_require__(4),a=__w_pdfjs_require__(21),h=__w_pdfjs_require__(22),c=__w_pdfjs_require__(20);if(o.isNodeJS){const{PDFNodeStream:t}=__w_pdfjs_require__(23);(0,i.setPDFNetworkStreamFactory)((e=>new t(e)))}else{const{PDFNetworkStream:t}=__w_pdfjs_require__(26),{PDFFetchStream:s}=__w_pdfjs_require__(27);(0,i.setPDFNetworkStreamFactory)((i=>(0,e.isValidFetchUrl)(i.url)?new s(i):new t(i)))}})(),__webpack_exports__})()},module.exports=factory()}));const pdf$1=getDefaultExportFromCjs(pdf),integerSequence=(t,e)=>Array(e).fill(1).map(((e,s)=>s+t)),verdocsViewCss='verdocs-view{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:-ms-flexbox;display:flex;background:#ccc;min-height:600px;position:relative;padding:0 0 20px 0;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-view div,verdocs-view canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-view .container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column}verdocs-view button.test{color:#fff;cursor:pointer;padding:5px 10px;border-radius:4px;background:#5a5767;border:1px solid #ccc}verdocs-view .load-progress{position:absolute;top:0;left:0;right:0;height:6px;z-index:2000;background:#000}verdocs-view .load-progress .bar{height:6px;background:#50be80}#verdocs-pdf-viewer-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column}#verdocs-pdf-viewer-container canvas{background:white;max-width:100%;margin:15px 0 0 0}',CANVAS_MARGIN=15,PDF_WORKER_URL=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdf.version}/pdf.worker.min.js`,CMAPS_URL=`https://unpkg.com/pdfjs-dist@${pdf.version}/cmaps/`;console.log("[VIEW] Loading PDF-JS",{PDF_WORKER_URL,CMAPS_URL}),pdf$1.GlobalWorkerOptions.workerSrc=PDF_WORKER_URL;const VerdocsView=class{constructor(t){registerInstance(this,t),this.pageRendered=createEvent(this,"pageRendered",7),this.pageLoaded=createEvent(this,"pageLoaded",7),this.pageChange=createEvent(this,"pageChange",7),this.pageInit=createEvent(this,"pageInit",7),this.scaleChange=createEvent(this,"scaleChange",7),this.documentRendered=createEvent(this,"documentRendered",7),this.numPages=1,this.fingerprint=null,this.endpoint=VerdocsEndpoint.getDefault(),this.rotation=0,this.loadProgress=0,this.pagesRendered=[]}doSrc(t,e){t!==e&&this.loadAndRender(t)}isRotated(t){return 0!==t&&t%180!=0}async renderPages(){const t=integerSequence(1,this.numPages);for await(let e of t){const t=e-1;console.log("[VIEW] Rendering page",e);const s=await this.pdfDocument.getPage(e),[i,n,r,o]=s.view,a=s.rotate,h=s.getViewport({scale:1/.75}),c=document.createElement("canvas"),l=c.getContext("2d");c.height=h.height,c.width=h.width,await s.render({canvasContext:l,viewport:h}),this.pdfContainer.appendChild(c);const d=c.width,u=c.height,f=r-i,p=o-n;this.pagesRendered.sort(((t,e)=>t.pageNumber-e.pageNumber));const g=this.pagesRendered.filter((t=>t.pageNumber<e)).pop(),b=((null==g?void 0:g.canvasBottom)||0)+CANVAS_MARGIN,A={pageNumber:e,width:d,height:u,originalWidth:this.isRotated(a)?p:f,originalHeight:this.isRotated(a)?f:p,xRatio:d/f,yRatio:u/p,canvasTop:b,canvasLeft:CANVAS_MARGIN,canvasRight:CANVAS_MARGIN+d,canvasBottom:b+u};this.pagesRendered[t]?this.pagesRendered[t]=A:this.pagesRendered.push(A);const m={pages:this.pagesRendered,numPages:this.numPages,numRendered:this.pagesRendered.length,canvasContainer:this.pdfContainer};this.pageRendered.emit(m),e>=this.numPages&&(console.log("[VIEW] Done rendering"),this.pagesRendered.sort(((t,e)=>t.pageNumber-e.pageNumber)),this.documentRendered.emit(m))}}componentDidLoad(){this.pdfContainer=document.getElementById("verdocs-pdf-viewer-container"),this.source&&this.loadAndRender(this.source)}onProgress(t){this.loadProgress=Math.floor(100*t.loaded/t.total)}loadAndRender(t){console.log("[VIEW] Loading",t);const e=this.endpoint.getToken(),s=pdf$1.getDocument({url:t,withCredentials:!0,cMapUrl:CMAPS_URL,cMapPacked:!0,verbosity:pdf.VerbosityLevel.WARNINGS,httpHeaders:e?{Authorization:`Bearer ${e}`}:{}},null,null,this.onProgress);s.onProgress=this.onProgress,s.promise.then((t=>{this.loadProgress=100,this.numPages=t.numPages,this.fingerprint=t.fingerprints[0],console.log(`[VIEW] Got PDF document fingerprint "${this.fingerprint}, ${this.numPages} pages`,t),this.pdfDocument=t,this.renderPages().catch((t=>console.log("Rendering error",t)))}))}render(){return h("div",{class:"container"},this.loadProgress<100?h("verdocs-loader",null):h("div",{style:{display:"none"}}),h("div",{id:"verdocs-pdf-viewer-container"}))}get component(){return getElement(this)}static get watchers(){return{source:["doSrc"]}}};VerdocsView.style=verdocsViewCss;export{VerdocsDropdown as verdocs_dropdown,VerdocsFieldAttachment as verdocs_field_attachment,VerdocsFieldCheckbox as verdocs_field_checkbox,VerdocsFieldDate as verdocs_field_date,VerdocsFieldDropdown as verdocs_field_dropdown,VerdocsFieldInitial as verdocs_field_initial,VerdocsFieldPayment as verdocs_field_payment,VerdocsFieldRadioButton as verdocs_field_radio_button,VerdocsFieldSignature as verdocs_field_signature,VerdocsFieldTextarea as verdocs_field_textarea,VerdocsFieldTextbox as verdocs_field_textbox,VerdocsView as verdocs_view}
|