directus-extension-texttoanything 1.7.2 → 1.7.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/app.js +2 -2
- package/package.json +125 -125
package/dist/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{defineOperationApp as t,useStores as e,useApi as i,defineModule as s,defineInterface as n}from"@directus/extensions-sdk";import*as a from"vue";import{resolveComponent as r,openBlock as o,createBlock as l,withCtx as h,createVNode as c,createCommentVNode as d,ref as u,createElementBlock as p,createTextVNode as g,pushScopeId as f,popScopeId as m,createElementVNode as v,defineComponent as b,computed as y,watch as w,nextTick as x,onMounted as A,toDisplayString as _,normalizeStyle as S,unref as T,Fragment as k,resolveDynamicComponent as C,withModifiers as E,createSlots as M,resolveDirective as P,renderList as D,normalizeClass as I,withDirectives as R,inject as L,onBeforeUnmount as F,reactive as N,onUnmounted as O,Teleport as B,renderSlot as z}from"vue";var j=t({id:"ttabarcode",name:"TTA generate barcode",icon:"barcode",description:"Generate a barcode trough Text to anything!",overview:({barcodeContent:t})=>[{label:"barcode content",text:t}],options:[{field:"barcodeContent",name:"content",type:"string",meta:{width:"full",interface:"input"}},{field:"barcodeType",name:"type",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:["auspost","azteccode","azteccodecompact","aztecrune","bc412","channelcode","codablockf","code11","code128","code16k","code2of5","code32","code39","code39ext","code49","code93","code93ext","codeone","coop2of5","daft","databarexpanded","databarexpandedcomposite","databarexpandedstacked","databarexpandedstackedcomposite","databarlimited","databarlimitedcomposite","databaromni","databaromnicomposite","databarstacked","databarstackedcomposite","databarstackedomni","databarstackedomnicomposite","databartruncated","databartruncatedcomposite","datalogic2of5","datamatrix","datamatrixrectangular","datamatrixrectangularextension","dotcode","ean13","ean13composite","ean14","ean2","ean5","ean8","ean8composite","flattermarken","gs1-128","gs1-128composite","gs1-cc","gs1datamatrix","gs1datamatrixrectangular","gs1dldatamatrix","gs1dlqrcode","gs1dotcode","gs1northamericancoupon","gs1qrcode","hanxin","hibcazteccode","hibccodablockf","hibccode128","hibccode39","hibcdatamatrix","hibcdatamatrixrectangular","hibcmicropdf417","hibcpdf417","hibcqrcode","iata2of5","identcode","industrial2of5","interleaved2of5","isbn","ismn","issn","itf14","japanpost","kix","leitcode","mailmark","mands","matrix2of5","maxicode","micropdf417","microqrcode","msi","onecode","pdf417","pdf417compact","pharmacode","pharmacode2","planet","plessey","posicode","postnet","pzn","qrcode","rationalizedCodabar","raw","rectangularmicroqrcode","royalmail","sscc18","swissqrcode","symbol","telepen","telepennumeric","ultracode","upca","upcacomposite","upce","upcecomposite"].map((t=>({text:t,value:t})))}}},{field:"scale",name:"scale",type:"number",meta:{width:"full",interface:"input"}},{field:"height",name:"height",type:"number",meta:{width:"full",interface:"input"}},{field:"includetext",name:"include text",type:"boolean",meta:{width:"full",interface:"boolean"}}]}),V=t({id:"ttapdf",name:"TTA generate PDF",icon:"picture_as_pdf",description:"Generate a PDF trough Text to anything!",overview:({filename:t})=>[{label:"File name",text:t}],options:[{field:"filename",name:"File name",type:"string",meta:{width:"full",interface:"input"}},{field:"pdfoptions",name:"Options",type:"json",meta:{width:"full",interface:"input-code",options:{language:"json",placeholder:JSON.stringify({html:"<h1>Hello world!</h1>",format:"A4",landscape:!1,margin:10,marginRight:5,marginLeft:5},null,2),template:JSON.stringify({html:"<h1>Hello world!</h1>",format:"A4",landscape:!1,margin:10,marginRight:5,marginLeft:5},null,2)}}}]}),H=t({id:"ttapdftemplate",name:"TTA generate PDF from template",icon:"picture_as_pdf",description:"Generate a PDF based on a template trough Text to anything!",overview:({filename:t})=>[{label:"File name",text:t}],options:t=>[{field:"filename",name:"File name",type:"string",meta:{width:"full",interface:"input"}},{field:"mode",name:"Mode",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:[{value:"online",text:"Online"},{value:"offline",text:"Offline"}]}}},{field:"template",name:"Template",type:"string",meta:{interface:"online"==t.mode?"TTA-pdf-online-template-selector":"TTA-pdf-template-selector",options:{},note:"When selecting the online mode, you will be able to select a template from the TextToAnything dashboard. (https://app.texttoanything.nl)"}},{field:"templatevariables",name:"Template variables",type:"json",meta:{width:"full",interface:"input-code",options:{language:"json"}}}]}),$=t({id:"ttaqrcode",name:"TTA generate QRcode",icon:"qr_code",description:"Generate a QRcode trough Text to anything!",overview:({content:t})=>[{label:"QRCode content",text:t}],options:[{field:"content",name:"QRCode content",type:"string",meta:{width:"full",interface:"input"}},{field:"lightColor",name:"Light color",type:"string",meta:{width:"full",interface:"select-color"}},{field:"darkColor",name:"Dark color",type:"string",meta:{width:"full",interface:"select-color"}},{field:"margin",name:"Margin",type:"integer",meta:{width:"half",interface:"input"}},{field:"width",name:"Width",type:"integer",meta:{width:"half",interface:"input"}}]});const U=String.raw`[A-Za-z][^/\s>]*`,G=String.raw`\B"(?:\\[^<>\n]|[^\\"<>\n])*"(?!\w)`,q=String.raw`\B'(?:\\[^<>\n]|[^\\'<>\n])*'(?!\w)`,W=String.raw`${G}|${q}`,K=String.raw`"(?<quotedAttrValue>[^"]*)"`,X=String.raw`'(?<singleQuotedAttrValue>[^']*)'`,Y=String.raw`(?<unquotedAttrValue>[^\s"'\`=<>]+)`,Q=String.raw`[^=\s>/"']+(?=[=>\s]|$)`,J=String.raw`${K}|${X}|${Y}`,Z=String.raw`(?<attrName>${Q})(?:\s*=\s*(?:${J}))?`,tt=String.raw`${W}|[^\s>]*[^\s>/]|[^\s>]*/(?!\s*>)`,et=String.raw`(?<attrSpace>\s*)(?:${Z}|(?<attrText>${tt}))`,it={comment:String.raw`<!--.*?-->`,dtd:String.raw`<![^>]+>`,startTag:String.raw`<(?<startTagName>${U})(?<attrs>(?:${et})*)\s*(?<closingSlash>/?)\s*>`,endTag:String.raw`</(?<endTagName>${U})\s*>`,space:String.raw`\s+`,text:String.raw`[^<\s"']+|${W}|['"]`,wildcard:String.raw`.`},st=Object.entries(it).map((([t,e])=>`(?<${t}>${e})`)).join("|");const nt=new Set(["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"]);function at(t,e=" ",i=80){const s=new RegExp(st,"gys"),n=new RegExp(et,"gy"),a=[];let r=null,o=0,l=0,h="",c=0,d="";const u=()=>{if(d&&"\n"!=d){const t=h.indexOf("\n"),e=-1==t?h.length:t;l+d.length+e>i&&(d="\n")}const t="\n"==d&&h?e.repeat(c):"",s=`${d}${t}${h}`;if(s){const t=s.lastIndexOf("\n");-1==t?l+=s.length:l=s.length-t-1,a.push(s)}h=d=""},p=(...t)=>{for(const e of t)!r&&/^\s+$/.test(e)?(u(),d=e):(h||(c=o),h+=e)};for(const e of function*(t,e){let i,{lastIndex:s}=t;for(;i=t.exec(e);)yield i,({lastIndex:s}=t);if(s!=e.length)throw new Error("Failed to parse string")}(s,t)){if(at.__strict&&e.groups.wildcard)throw new Error("Unexpected wildcard");if(e.groups.endTag){const t=e.groups.endTagName.toLowerCase();t==r&&(r=null),r||(--o,p(`</${t}>`))}if(r)p(e[0]);else if(e.groups.space)p(...e[0].match(/\n/g)?.slice(0,2)??[" "]);else if(e.groups.comment||e.groups.dtd||e.groups.text||e.groups.wildcard)p(e[0]);else if(e.groups.startTag){const t=e.groups.startTagName.toLowerCase();if(p(`<${t}`),++o,e.groups.attrs){let t,i,{lastIndex:s}=n;for(;t=n.exec(e.groups.attrs);){if(({lastIndex:s}=n),at.__strict&&t.groups.attrText)throw new Error("Unexpected attr text");t.groups.attrText?(t.groups.attrSpace&&p(/\n/.test(t.groups.attrSpace)?"\n":" "),p(t.groups.attrText)):(!t.groups.attrSpace&&i?.groups.attrText||p(/\n/.test(t.groups.attrSpace)?"\n":" "),p(`${t.groups.attrName}${t.groups.quotedAttrValue?`="${t.groups.quotedAttrValue}"`:t.groups.singleQuotedAttrValue?`='${t.groups.singleQuotedAttrValue}'`:t.groups.unquotedAttrValue?`=${t.groups.unquotedAttrValue}`:""}`)),i=t}if(s!=e.groups.attrs.length)throw new Error("Failed to parse attributes")}const i=Boolean(e.groups.closingSlash);p(i?" />":">"),i||nt.has(t)?--o:["pre","textarea","script","style"].includes(t)&&(r=t)}}u();let g=!1;for(;/^\s+$/.test(a[a.length-1]);){const t=a.pop();/\n/.test(t)&&(g=!0)}return g&&a.push("\n"),a.join("")}at.default=at;var rt=at;class ot{constructor(t,e,i,s,n){this.kind=t,this.input=e,this.begin=i,this.end=s,this.file=n}getText(){return this.input.slice(this.begin,this.end)}getPosition(){let[t,e]=[1,1];for(let i=0;i<this.begin;i++)"\n"===this.input[i]?(t++,e=1):e++;return[t,e]}size(){return this.end-this.begin}}class lt{liquidMethodMissing(t){}}const ht=Object.prototype.toString,ct=String.prototype.toLowerCase,dt=Object.hasOwnProperty;function ut(t){return"string"==typeof t}function pt(t){return"function"==typeof t}function gt(t){return t&&pt(t.then)}function ft(t){return t&&pt(t.next)&&pt(t.throw)&&pt(t.return)}function mt(t){return ut(t=yt(t))?t:_t(t)?"":St(t)?t.map((t=>mt(t))).join(""):String(t)}function vt(t){return St(t=yt(t))?t:ut(t)&&t.length>0?[t]:Et(e=t)&&Symbol.iterator in e?Array.from(t):Et(t)?Object.keys(t).map((e=>[e,t[e]])):[];var e}function bt(t){return _t(t=yt(t))?[]:St(t)?t:[t]}function yt(t){return t instanceof lt&&pt(t.valueOf)?t.valueOf():t}function wt(t){return t=Number(t),isNaN(t)?0:t}function xt(t){return"number"==typeof t}function At(t){return t&&pt(t.toLiquid)?At(t.toLiquid()):t}function _t(t){return null==t}function St(t){return"[object Array]"===ht.call(t)}function Tt(t){return t&&xt(t.length)}function kt(t,e){t=t||{};for(const i in t)if(dt.call(t,i)&&!1===e(t[i],i,t))break;return t}function Ct(t){return t[t.length-1]}function Et(t){const e=typeof t;return null!==t&&("object"===e||"function"===e)}function Mt(t,e,i=1){const s=[];for(let n=t;n<e;n+=i)s.push(n);return s}function Pt(t,e,i=" "){return Dt(t,e,i,((t,e)=>e+t))}function Dt(t,e,i,s){let n=e-(t=String(t)).length;for(;n-- >0;)t=s(t,i);return t}function It(t){return t}function Rt(t,e){return null==t&&null==e?0:null==t?1:null==e||(t=ct.call(t))<(e=ct.call(e))?-1:t>e?1:0}function Lt(t){return function(...e){return t.call(this,...e.map(yt))}}function Ft(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function*Nt(t){const e=new Set;for(const i of t){const t=JSON.stringify(i);e.has(t)||(e.add(t),yield i)}}const Ot="__liquidClass__";class Bt extends Error{constructor(t,e){super("string"==typeof t?t:t.message),this.context="","string"!=typeof t&&Object.defineProperty(this,"originalError",{value:t,enumerable:!1}),Object.defineProperty(this,"token",{value:e,enumerable:!1}),Object.defineProperty(this,Ot,{value:"LiquidError",enumerable:!1})}update(){Object.defineProperty(this,"context",{value:qt(this.token),enumerable:!1}),this.message=function(t,e){e.file&&(t+=`, file:${e.file}`);const[i,s]=e.getPosition();return t+=`, line:${i}, col:${s}`}(this.message,this.token),this.stack=this.message+"\n"+this.context+"\n"+this.stack,this.originalError&&(this.stack+="\nFrom "+this.originalError.stack)}static is(t){return"LiquidError"===(null==t?void 0:t[Ot])}}class zt extends Bt{constructor(t,e){super(t,e),this.name="TokenizationError",super.update()}}class jt extends Bt{constructor(t,e){super(t,e),this.name="ParseError",this.message=t.message,super.update()}}class Vt extends Bt{constructor(t,e){super(t,e.token),this.name="RenderError",this.message=t.message,super.update()}static is(t){return"RenderError"===t.name}}class Ht extends Bt{constructor(t){super(t[0],t[0].token),this.errors=t,this.name="LiquidErrors";const e=t.length>1?"s":"";this.message=`${t.length} error${e} found`,super.update()}static is(t){return"LiquidErrors"===t.name}}class $t extends Bt{constructor(t,e){super(t,e),this.name="UndefinedVariableError",this.message=t.message,super.update()}}class Ut extends Error{constructor(t){super(`undefined variable: ${t}`),this.name="InternalUndefinedVariableError",this.variableName=t}}class Gt extends Error{constructor(t){super(t),this.name="AssertionError",this.message=t+""}}function qt(t){const[e,i]=t.getPosition(),s=t.input.split("\n"),n=Math.max(e-2,1),a=Math.min(e+3,s.length);return Mt(n,a+1).map((t=>{let n=`${t===e?">> ":" "}${Pt(String(t),String(a).length)}| `;const r=t===e?"\n"+Pt("^",i+n.length):"";return n+=s[t-1],n+=r,n})).join("\n")}const Wt=[0,0,0,0,0,0,0,0,0,20,4,4,4,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,2,8,0,0,0,0,8,0,0,0,64,0,65,0,0,33,33,33,33,33,33,33,33,33,33,0,0,2,2,2,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0];function Kt(t){const e=t.charCodeAt(0);return e>=128?!Wt[e]:!!(1&Wt[e])}function Xt(t,e){if(!t){const i="function"==typeof e?e():e||`expect ${t} to be true`;throw new Gt(i)}}function Yt(t,e=`unexpected ${JSON.stringify(t)}`){Xt(!t,e)}Wt[160]=Wt[5760]=Wt[6158]=Wt[8192]=Wt[8193]=Wt[8194]=Wt[8195]=Wt[8196]=Wt[8197]=Wt[8198]=Wt[8199]=Wt[8200]=Wt[8201]=Wt[8202]=Wt[8232]=Wt[8233]=Wt[8239]=Wt[8287]=Wt[12288]=4,Wt[8220]=Wt[8221]=128;class Qt extends lt{equals(t){return!(t instanceof Qt)&&(ut(t=yt(t))||St(t)?0===t.length:!!Et(t)&&0===Object.keys(t).length)}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return""}static is(t){return t instanceof Qt}}class Jt extends Qt{equals(t){return!1===t||(!!_t(yt(t))||(ut(t)?/^\s*$/.test(t):super.equals(t)))}static is(t){return t instanceof Jt}}class Zt extends lt{constructor(t,e,i){super(),this.i=0,this.length=t,this.name=`${i}-${e}`}next(){this.i++}index0(){return this.i}index(){return this.i+1}first(){return 0===this.i}last(){return this.i===this.length-1}rindex(){return this.length-this.i}rindex0(){return this.length-this.i-1}valueOf(){return JSON.stringify(this)}}class te{constructor(){this.buffer=""}write(t){this.buffer+=mt(t)}}class ee{constructor(){throw this.buffer="",this.stream=null,new Error("streaming not supported in browser")}}class ie{constructor(){this.buffer=""}write(t){"string"!=typeof(t=yt(t))&&""===this.buffer?this.buffer=t:this.buffer=mt(this.buffer)+mt(t)}}class se extends lt{constructor(t=()=>""){super(),this.superBlockRender=t}*super(){const t=new te;return yield this.superBlockRender(t),t.buffer}}function ne(t){return t&&pt(t.equals)&&pt(t.gt)&&pt(t.geq)&&pt(t.lt)&&pt(t.leq)}const ae=new class extends lt{equals(t){return _t(yt(t))}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return null}},re={true:!0,false:!1,nil:ae,null:ae,empty:new Qt,blank:new Jt};function oe(t){const e={};for(const[i,s]of Object.entries(t)){let t=e;for(let e=0;e<i.length;e++){const s=i[e];t[s]=t[s]||{},e===i.length-1&&Kt(i[e])&&(t[s].needBoundary=!0),t=t[s]}t.data=s,t.end=!0}return e}var le=function(){return le=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},le.apply(this,arguments)};function he(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((s=s.apply(t,e||[])).next())}))}function ce(t){return he(this,void 0,void 0,(function*(){if(!ft(t))return t;let e,i=!1,s="next";do{const n=t[s](e);i=n.done,e=n.value,s="next";try{ft(e)&&(e=ce(e)),gt(e)&&(e=yield e)}catch(t){s="throw",e=t}}while(!i);return e}))}function de(t){if(!ft(t))return t;let e,i=!1,s="next";do{const n=t[s](e);if(i=n.done,e=n.value,s="next",ft(e))try{e=de(e)}catch(t){s="throw",e=t}}while(!i);return e}const ue=/%([-_0^#:]+)?(\d+)?([EO])?(.)/;function pe(t){const e=function(t){const e=t.getFullYear();return!(3&e||!(e%100||e%400==0&&e))}(t)?29:28;return[31,e,31,30,31,30,31,31,30,31,30,31]}function ge(t){let e=0;for(let i=0;i<t.getMonth();++i)e+=pe(t)[i];return e+t.getDate()}function fe(t,e){const i=ge(t)+(e-t.getDay()),s=7-new Date(t.getFullYear(),0,1).getDay()+e;return String(Math.floor((i-s)/7)+1)}const me={d:2,e:2,H:2,I:2,j:3,k:2,l:2,L:3,m:2,M:2,S:2,U:2,W:2},ve=new Set("aAbBceklpP");function be(t,e){const i=Math.abs(t.getTimezoneOffset()),s=Math.floor(i/60),n=i%60;return(t.getTimezoneOffset()>0?"-":"+")+Pt(s,2,"0")+(e.flags[":"]?":":"")+Pt(n,2,"0")}const ye={a:t=>t.getShortWeekdayName(),A:t=>t.getLongWeekdayName(),b:t=>t.getShortMonthName(),B:t=>t.getLongMonthName(),c:t=>t.toLocaleString(),C:t=>function(t){return parseInt(t.getFullYear().toString().substring(0,2),10)}(t),d:t=>t.getDate(),e:t=>t.getDate(),H:t=>t.getHours(),I:t=>String(t.getHours()%12||12),j:t=>ge(t),k:t=>t.getHours(),l:t=>String(t.getHours()%12||12),L:t=>t.getMilliseconds(),m:t=>t.getMonth()+1,M:t=>t.getMinutes(),N:(t,e)=>{const i=Number(e.width)||9;return function(t,e,i=" "){return Dt(t,e,i,((t,e)=>t+e))}(String(t.getMilliseconds()).slice(0,i),i,"0")},p:t=>t.getHours()<12?"AM":"PM",P:t=>t.getHours()<12?"am":"pm",q:t=>function(t){const e=t.getDate();if([11,12,13].includes(e))return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}(t),s:t=>Math.round(t.getTime()/1e3),S:t=>t.getSeconds(),u:t=>t.getDay()||7,U:t=>fe(t,0),w:t=>t.getDay(),W:t=>fe(t,1),x:t=>t.toLocaleDateString(),X:t=>t.toLocaleTimeString(),y:t=>t.getFullYear().toString().slice(2,4),Y:t=>t.getFullYear(),z:be,Z:(t,e)=>t.getTimeZoneName()||be(t,e),t:()=>"\t",n:()=>"\n","%":()=>"%"};function we(t,e){let i,s="",n=e;for(;i=ue.exec(n);)s+=n.slice(0,i.index),n=n.slice(i.index+i[0].length),s+=xe(t,i);return s+n}function xe(t,e){const[i,s="",n,a,r]=e,o=ye[r];if(!o)return i;const l={};for(const t of s)l[t]=!0;let h=String(o(t,{flags:l,width:n,modifier:a})),c=ve.has(r)?" ":"0",d=n||me[r]||0;var u;return l["^"]?h=h.toUpperCase():l["#"]&&(u=h,h=[...u].some((t=>t>="a"&&t<="z"))?u.toUpperCase():u.toLowerCase()),l._?c=" ":l[0]&&(c="0"),l["-"]&&(d=0),Pt(h,d,c)}function Ae(){return"undefined"!=typeof Intl?Intl.DateTimeFormat:void 0}ye.h=ye.b;const _e=/([zZ]|([+-])(\d{2}):?(\d{2}))$/,Se=["January","February","March","April","May","June","July","August","September","October","November","December"],Te=Se.map((t=>t.slice(0,3))),ke=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ce=ke.map((t=>t.slice(0,3)));class Ee{constructor(t,e,i){this.locale=e,this.DateTimeFormat=Ae(),this.date=new Date(t),this.timezoneFixed=void 0!==i,void 0===i&&(i=this.date.getTimezoneOffset()),this.timezoneOffset=ut(i)?Ee.getTimezoneOffset(i,this.date):i,this.timezoneName=ut(i)?i:"";const s=6e4*(this.date.getTimezoneOffset()-this.timezoneOffset),n=this.date.getTime()+s;this.displayDate=new Date(n)}getTime(){return this.displayDate.getTime()}getMilliseconds(){return this.displayDate.getMilliseconds()}getSeconds(){return this.displayDate.getSeconds()}getMinutes(){return this.displayDate.getMinutes()}getHours(){return this.displayDate.getHours()}getDay(){return this.displayDate.getDay()}getDate(){return this.displayDate.getDate()}getMonth(){return this.displayDate.getMonth()}getFullYear(){return this.displayDate.getFullYear()}toLocaleString(t,e){return(null==e?void 0:e.timeZone)?this.date.toLocaleString(t,e):this.displayDate.toLocaleString(t,e)}toLocaleTimeString(t){return this.displayDate.toLocaleTimeString(t)}toLocaleDateString(t){return this.displayDate.toLocaleDateString(t)}getTimezoneOffset(){return this.timezoneOffset}getTimeZoneName(){return this.timezoneFixed?this.timezoneName:this.DateTimeFormat?this.DateTimeFormat().resolvedOptions().timeZone:void 0}getLongMonthName(){var t;return null!==(t=this.format({month:"long"}))&&void 0!==t?t:Se[this.getMonth()]}getShortMonthName(){var t;return null!==(t=this.format({month:"short"}))&&void 0!==t?t:Te[this.getMonth()]}getLongWeekdayName(){var t;return null!==(t=this.format({weekday:"long"}))&&void 0!==t?t:ke[this.displayDate.getDay()]}getShortWeekdayName(){var t;return null!==(t=this.format({weekday:"short"}))&&void 0!==t?t:Ce[this.displayDate.getDay()]}valid(){return!isNaN(this.getTime())}format(t){return this.DateTimeFormat&&this.DateTimeFormat(this.locale,t).format(this.displayDate)}static createDateFixedToTimezone(t,e){const i=t.match(_e);if(i&&"Z"===i[1])return new Ee(+new Date(t),e,0);if(i&&i[2]&&i[3]&&i[4]){const[,,s,n,a]=i,r=("+"===s?-1:1)*(60*parseInt(n,10)+parseInt(a,10));return new Ee(+new Date(t),e,r)}return new Ee(t,e)}static getTimezoneOffset(t,e){const i=e.toLocaleString("en-US",{timeZone:t}),s=e.toLocaleString("en-US",{timeZone:"UTC"}),n=new Date(i);return(+new Date(s)-+n)/6e4}}class Me{constructor(t,e){this.base=0,this.message=`${t} limit exceeded`,this.limit=e}use(t){t=wt(t),Xt(this.base+t<=this.limit,this.message),this.base+=t}check(t){Xt((t=wt(t))<=this.limit,this.message)}}class Pe extends ot{constructor(t,[e,i],s,n,a,r,o,l){super(t,s,n,a,l),this.trimLeft=!1,this.trimRight=!1;const h="-"===s[e],c="-"===s[i-1];let d=h?e+1:e,u=c?i-1:i;for(;d<u&&4&Wt[s.charCodeAt(d)];)d++;for(;u>d&&4&Wt[s.charCodeAt(u-1)];)u--;this.contentRange=[d,u],this.trimLeft=h||r,this.trimRight=c||o}get content(){return this.input.slice(this.contentRange[0],this.contentRange[1])}}class De extends Pe{constructor(t,e,i,s,n){const{trimTagLeft:a,trimTagRight:r,tagDelimiterLeft:o,tagDelimiterRight:l}=s,[h,c]=[e+o.length,i-l.length];super(Wi.Tag,[h,c],t,e,i,a,r,n),this.tokenizer=new Si(t,s.operators,n,this.contentRange),this.name=this.tokenizer.readTagName(),this.tokenizer.assert(this.name,"illegal tag syntax, tag name expected"),this.tokenizer.skipBlank(),this.args=this.tokenizer.input.slice(this.tokenizer.p,this.contentRange[1])}}class Ie extends Pe{constructor(t,e,i,s,n){const{trimOutputLeft:a,trimOutputRight:r,outputDelimiterLeft:o,outputDelimiterRight:l}=s,h=[e+o.length,i-l.length];super(Wi.Output,h,t,e,i,a,r,n)}}class Re extends ot{constructor(t,e,i,s){super(Wi.HTML,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.trimLeft=0,this.trimRight=0}getContent(){return this.input.slice(this.begin+this.trimLeft,this.end-this.trimRight)}}class Le extends ot{constructor(t,e,i,s){super(Wi.Number,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.content=Number(this.getText())}}class Fe extends ot{constructor(t,e,i,s){super(Wi.Word,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.content=this.getText()}}class Ne extends ot{constructor(t,e,i,s){super(Wi.Literal,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.literal=this.getText(),this.content=re[this.literal]}}const Oe={"==":2,"!=":2,">":2,"<":2,">=":2,"<=":2,contains:2,not:1,and:0,or:0},Be={"==":0,"!=":0,">":0,"<":0,">=":0,"<=":0,contains:0,not:1,and:0,or:0};class ze extends ot{constructor(t,e,i,s){super(Wi.Operator,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.operator=this.getText()}getPrecedence(){const t=this.getText();return t in Oe?Oe[t]:1}}class je extends ot{constructor(t,e,i,s,n,a){super(Wi.PropertyAccess,i,s,n,a),this.variable=t,this.props=e}}class Ve extends ot{constructor(t,e,i,s,n,a){super(Wi.Filter,i,s,n,a),this.name=t,this.args=e}}class He extends ot{constructor(t,e,i,s,n,a){super(Wi.Hash,t,e,i,a),this.input=t,this.begin=e,this.end=i,this.name=s,this.value=n,this.file=a}}const $e=/[\da-fA-F]/,Ue=/[0-7]/,Ge={b:"\b",f:"\f",n:"\n",r:"\r",t:"\t",v:"\v"};function qe(t){const e=t.charCodeAt(0);return e>=97?e-87:e>=65?e-55:e-48}class We extends ot{constructor(t,e,i,s){super(Wi.Quoted,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.content=function(t){let e="";for(let i=1;i<t.length-1;i++)if("\\"===t[i])if(void 0!==Ge[t[i+1]])e+=Ge[t[++i]];else if("u"===t[i+1]){let s=0,n=i+2;for(;n<=i+5&&$e.test(t[n]);)s=16*s+qe(t[n++]);i=n-1,e+=String.fromCharCode(s)}else if(Ue.test(t[i+1])){let s=i+1,n=0;for(;s<=i+3&&Ue.test(t[s]);)n=8*n+qe(t[s++]);i=s-1,e+=String.fromCharCode(n)}else e+=t[++i];else e+=t[i];return e}(this.getText())}}class Ke extends ot{constructor(t,e,i,s,n,a){super(Wi.Range,t,e,i,a),this.input=t,this.begin=e,this.end=i,this.lhs=s,this.rhs=n,this.file=a}}class Xe extends Pe{constructor(t,e,i,s,n){super(Wi.Tag,[e,i],t,e,i,!1,!1,n),this.tokenizer=new Si(t,s.operators,n,this.contentRange),this.name=this.tokenizer.readTagName(),this.tokenizer.assert(this.name,"illegal liquid tag syntax"),this.tokenizer.skipBlank()}get args(){return this.tokenizer.input.slice(this.tokenizer.p,this.contentRange[1])}}class Ye extends ot{constructor(t,e,i,s,n,a){super(Wi.FilteredValue,i,s,n,a),this.initial=t,this.filters=e,this.input=i,this.begin=s,this.end=n,this.file=a}}const Qe={now:()=>Date.now()};function Je(){return"object"==typeof global&&global.performance||"object"==typeof window&&window.performance||Qe}class Ze{renderTemplatesToNodeStream(t,e){const i=new ee;return Promise.resolve().then((()=>ce(this.renderTemplates(t,e,i)))).then((()=>i.end()),(t=>i.error(t))),i.stream}*renderTemplates(t,e,i){i||(i=e.opts.keepOutputType?new ie:new te);const s=[];for(const n of t){e.renderLimit.check(Je().now());try{const t=yield n.render(e,i);if(t&&i.write(t),e.breakCalled||e.continueCalled)break}catch(t){const i=Bt.is(t)?t:new Vt(t,n);if(!e.opts.catchAllErrors)throw i;s.push(i)}}if(s.length)throw new Ht(s);return i.buffer}}class ti{constructor(t){this.postfix=[...ii(t)]}*evaluate(t,e){Xt(t,"unable to evaluate: context not defined");const i=[];for(const s of this.postfix)if(Qi(s)){const e=i.pop();let n;if(1===Be[s.operator])n=yield t.opts.operators[s.operator](e,t);else{const a=i.pop();n=yield t.opts.operators[s.operator](a,e,t)}i.push(n)}else i.push(yield ei(s,t,e));return i[0]}valid(){return!!this.postfix.length}}function*ei(t,e,i=!1){if(t)return"content"in t?t.content:is(t)?yield function*(t,e,i){const s=[];for(const i of t.props)s.push(yield ei(i,e,!1));try{if(t.variable){const n=yield ei(t.variable,e,i);return yield e._getFromScope(n,s)}return yield e._get(s)}catch(e){if(i&&"InternalUndefinedVariableError"===e.name)return null;throw new $t(e,t)}}(t,e,i):ns(t)?yield function*(t,e){const i=yield ei(t.lhs,e),s=yield ei(t.rhs,e);return e.memoryLimit.use(s-i+1),Mt(+i,+s+1)}(t,e):void 0}function*ii(t){const e=[];for(const i of t)if(Qi(i)){for(;e.length&&e[e.length-1].getPrecedence()>i.getPrecedence();)yield e.pop();e.push(i)}else yield i;for(;e.length;)yield e.pop()}function si(t,e){return!ni(t,e)}function ni(t,e){return t=yt(t),e.opts.jsTruthy?!t:!1===t||null==t}const ai={"==":ri,"!=":(t,e)=>!ri(t,e),">":(t,e)=>ne(t)?t.gt(e):ne(e)?e.lt(t):yt(t)>yt(e),"<":(t,e)=>ne(t)?t.lt(e):ne(e)?e.gt(t):yt(t)<yt(e),">=":(t,e)=>ne(t)?t.geq(e):ne(e)?e.leq(t):yt(t)>=yt(e),"<=":(t,e)=>ne(t)?t.leq(e):ne(e)?e.geq(t):yt(t)<=yt(e),contains:(t,e)=>St(t=yt(t))?t.some((t=>ri(t,e))):!!pt(null==t?void 0:t.indexOf)&&t.indexOf(yt(e))>-1,not:(t,e)=>ni(yt(t),e),and:(t,e,i)=>si(yt(t),i)&&si(yt(e),i),or:(t,e,i)=>si(yt(t),i)||si(yt(e),i)};function ri(t,e){return ne(t)?t.equals(e):ne(e)?e.equals(t):(t=yt(t),e=yt(e),St(t)?St(e)&&function(t,e){return t.length===e.length&&!t.some(((t,i)=>!ri(t,e[i])))}(t,e):t===e)}let oi=class{constructor(t,e,i,s){this.key=t,this.value=e,this.next=i,this.prev=s}};class li{constructor(t,e=0){this.limit=t,this.size=e,this.cache={},this.head=new oi("HEAD",null,null,null),this.tail=new oi("TAIL",null,null,null),this.head.next=this.tail,this.tail.prev=this.head}write(t,e){if(this.cache[t])this.cache[t].value=e;else{const i=new oi(t,e,this.head.next,this.head);this.head.next.prev=i,this.head.next=i,this.cache[t]=i,this.size++,this.ensureLimit()}}read(t){if(!this.cache[t])return;const{value:e}=this.cache[t];return this.remove(t),this.write(t,e),e}remove(t){const e=this.cache[t];e.prev.next=e.next,e.next.prev=e.prev,delete this.cache[t],this.size--}clear(){this.head.next=this.tail,this.tail.prev=this.head,this.size=0,this.cache={}}ensureLimit(){this.size>this.limit&&this.remove(this.tail.prev.key)}}function hi(t,e){const i=document.createElement("base");i.href=t;const s=document.getElementsByTagName("head")[0];s.insertBefore(i,s.firstChild);const n=document.createElement("a");n.href=e;const a=n.href;return s.removeChild(i),a}var ci=Object.freeze({__proto__:null,resolve:function(t,e,i){return t.length&&"/"!==Ct(t)&&(t+="/"),hi(t,e).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,((t,e,s)=>{const n=s.split("/").pop();return/\.\w+$/.test(n)?t:e+s+i}))},readFile:function(t){return he(this,void 0,void 0,(function*(){return new Promise(((e,i)=>{const s=new XMLHttpRequest;s.onload=()=>{s.status>=200&&s.status<300?e(s.responseText):i(new Error(s.statusText))},s.onerror=()=>{i(new Error("An error occurred whilst receiving the response."))},s.open("GET",t),s.send()}))}))},readFileSync:function(t){const e=new XMLHttpRequest;if(e.open("GET",t,!1),e.send(),e.status<200||e.status>=300)throw new Error(e.statusText);return e.responseText},exists:function(t){return he(this,void 0,void 0,(function*(){return!0}))},existsSync:function(t){return!0},dirname:function(t){return hi(t,".")},sep:"/"});function di(t,e=0){return JSON.stringify(t,null,e)}var ui={default:function(t,e,...i){return St(t=yt(t))||ut(t)?t.length?t:e:(!1!==t||!new Map(i).get("allow_false"))&&(ni(t,this.context)?e:t)},raw:{raw:!0,handler:It},jsonify:di,to_integer:function(t){return Number(t)},json:di,inspect:function(t,e=0){const i=[];return JSON.stringify(t,(function(t,e){if("object"!=typeof e||null===e)return e;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(e)?"[Circular]":(i.push(e),e)}),e)}};const pi={"&":"&","<":"<",">":">",'"':""","'":"'"},gi={"&":"&","<":"<",">":">",""":'"',"'":"'"};function fi(t){return t=mt(t),this.context.memoryLimit.use(t.length),t.replace(/&|<|>|"|'/g,(t=>pi[t]))}function mi(t){return t=mt(t),this.context.memoryLimit.use(t.length),t.replace(/&(amp|lt|gt|#34|#39);/g,(t=>gi[t]))}var vi=Object.freeze({__proto__:null,escape:fi,xml_escape:function(t){return fi.call(this,t)},escape_once:function(t){return fi.call(this,mi.call(this,t))},newline_to_br:function(t){const e=mt(t);return this.context.memoryLimit.use(e.length),e.replace(/\r?\n/gm,"<br />\n")},strip_html:function(t){const e=mt(t);return this.context.memoryLimit.use(e.length),e.replace(/<script[\s\S]*?<\/script>|<style[\s\S]*?<\/style>|<.*?>|<!--[\s\S]*?-->/g,"")}});class bi{constructor(t){this.mapping=t,this.sep="/"}exists(t){return he(this,void 0,void 0,(function*(){return this.existsSync(t)}))}existsSync(t){return!_t(this.mapping[t])}readFile(t){return he(this,void 0,void 0,(function*(){return this.readFileSync(t)}))}readFileSync(t){const e=this.mapping[t];if(_t(e))throw new Error(`ENOENT: ${t}`);return e}dirname(t){const e=t.split(this.sep);return e.pop(),e.join(this.sep)}resolve(t,e,i){if(e+=i,"."===t)return e;const s=t.split(/\/+/);for(const t of e.split(this.sep))"."!==t&&""!==t&&(".."===t?(s.length>1||""!==s[0])&&s.pop():s.push(t));return s.join(this.sep)}}const yi={root:["."],layouts:["."],partials:["."],relativeReference:!0,jekyllInclude:!1,keyValueSeparator:":",cache:void 0,extname:"",fs:ci,dynamicPartials:!0,jsTruthy:!1,dateFormat:"%A, %B %-e, %Y at %-l:%M %P %z",locale:"",trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",preserveTimezones:!1,strictFilters:!1,strictVariables:!1,ownPropertyOnly:!0,lenientIf:!1,globals:{},keepOutputType:!1,operators:ai,memoryLimit:1/0,parseLimit:1/0,renderLimit:1/0};function wi(t){var e,i,s;if(t.hasOwnProperty("root")&&(t.hasOwnProperty("partials")||(t.partials=t.root),t.hasOwnProperty("layouts")||(t.layouts=t.root)),t.hasOwnProperty("cache")){let e;e="number"==typeof t.cache?t.cache>0?new li(t.cache):void 0:"object"==typeof t.cache?t.cache:t.cache?new li(1024):void 0,t.cache=e}return(t=Object.assign(Object.assign(Object.assign({},yi),t.jekyllInclude?{dynamicPartials:!1}:{}),t)).fs.dirname&&t.fs.sep||!t.relativeReference||(console.warn("[LiquidJS] `fs.dirname` and `fs.sep` are required for relativeReference, set relativeReference to `false` to suppress this warning"),t.relativeReference=!1),t.root=xi(t.root),t.partials=xi(t.partials),t.layouts=xi(t.layouts),t.outputEscape=t.outputEscape&&("escape"===(s=t.outputEscape)?fi:"json"===s?ui.json:(Xt(pt(s),"`outputEscape` need to be of type string or function"),s)),t.locale||(t.locale=null!==(i=null===(e=Ae())||void 0===e?void 0:e().resolvedOptions().locale)&&void 0!==i?i:"en-US"),t.templates&&(t.fs=new bi(t.templates),t.relativeReference=!0,t.root=t.partials=t.layouts="."),t}function xi(t){let e=[];return St(t)&&(e=t),ut(t)&&(e=[t]),e}function Ai(t,e){if(!t||!Ji(t))return;const i=e?4:16;for(;Wt[t.input.charCodeAt(t.end-1-t.trimRight)]&i;)t.trimRight++}function _i(t,e){if(!t||!Ji(t))return;const i=e?4:16;for(;Wt[t.input.charCodeAt(t.begin+t.trimLeft)]&i;)t.trimLeft++;"\n"===t.input.charAt(t.begin+t.trimLeft)&&t.trimLeft++}class Si{constructor(t,e=yi.operators,i,s){this.input=t,this.file=i,this.rawBeginAt=-1,this.p=s?s[0]:0,this.N=s?s[1]:t.length,this.opTrie=oe(e),this.literalTrie=oe(re)}readExpression(){return new ti(this.readExpressionTokens())}*readExpressionTokens(){for(;this.p<this.N;){const t=this.readOperator();if(t){yield t;continue}const e=this.readValue();if(!e)return;yield e}}readOperator(){this.skipBlank();const t=this.matchTrie(this.opTrie);if(-1!==t)return new ze(this.input,this.p,this.p=t,this.file)}matchTrie(t){let e,i=t,s=this.p;for(;i[this.input[s]]&&s<this.N;)i=i[this.input[s++]],i.end&&(e=i);return e?e.needBoundary&&Kt(this.peek(s-this.p))?-1:s:-1}readFilteredValue(){const t=this.p,e=this.readExpression();this.assert(e.valid(),`invalid value expression: ${this.snapshot()}`);const i=this.readFilters();return new Ye(e,i,this.input,t,this.p,this.file)}readFilters(){const t=[];for(;;){const e=this.readFilter();if(!e)return t;t.push(e)}}readFilter(){if(this.skipBlank(),this.end())return null;this.assert("|"===this.read(),'expected "|" before filter');const t=this.readIdentifier();if(!t.size())return this.assert(this.end(),"expected filter name"),null;const e=[];if(this.skipBlank(),":"===this.peek())do{++this.p;const t=this.readFilterArg();t&&e.push(t),this.skipBlank(),this.assert(this.end()||","===this.peek()||"|"===this.peek(),(()=>`unexpected character ${this.snapshot()}`))}while(","===this.peek());else if("|"!==this.peek()&&!this.end())throw this.error('expected ":" after filter name');return new Ve(t.getText(),e,this.input,t.begin,this.p,this.file)}readFilterArg(){const t=this.readValue();if(!t)return;if(this.skipBlank(),":"!==this.peek())return t;++this.p;const e=this.readValue();return[t.getText(),e]}readTopLevelTokens(t=yi){const e=[];for(;this.p<this.N;){const i=this.readTopLevelToken(t);e.push(i)}return function(t,e){let i=!1;for(let s=0;s<t.length;s++){const n=t[s];rs(n)&Wi.Delimited&&(!i&&n.trimLeft&&Ai(t[s-1],e.greedy),Zi(n)&&("raw"===n.name?i=!0:"endraw"===n.name&&(i=!1)),!i&&n.trimRight&&_i(t[s+1],e.greedy))}}(e,t),e}readTopLevelToken(t){const{tagDelimiterLeft:e,outputDelimiterLeft:i}=t;return this.rawBeginAt>-1?this.readEndrawOrRawContent(t):this.match(e)?this.readTagToken(t):this.match(i)?this.readOutputToken(t):this.readHTMLToken([e,i])}readHTMLToken(t){const e=this.p;for(;this.p<this.N&&!t.some((t=>this.match(t)));)++this.p;return new Re(this.input,e,this.p,this.file)}readTagToken(t){const{file:e,input:i}=this,s=this.p;if(-1===this.readToDelimiter(t.tagDelimiterRight))throw this.error(`tag ${this.snapshot(s)} not closed`,s);const n=new De(i,s,this.p,t,e);return"raw"===n.name&&(this.rawBeginAt=s),n}readToDelimiter(t,e=!1){for(this.skipBlank();this.p<this.N;)if(e&&8&this.peekType())this.readQuoted();else if(++this.p,this.rmatch(t))return this.p;return-1}readOutputToken(t=yi){const{file:e,input:i}=this,{outputDelimiterRight:s}=t,n=this.p;if(-1===this.readToDelimiter(s,!0))throw this.error(`output ${this.snapshot(n)} not closed`,n);return new Ie(i,n,this.p,t,e)}readEndrawOrRawContent(t){const{tagDelimiterLeft:e,tagDelimiterRight:i}=t,s=this.p;let n=this.readTo(e)-e.length;for(;this.p<this.N;)if("endraw"===this.readIdentifier().getText())for(;this.p<=this.N;){if(this.rmatch(i)){const e=this.p;return s===n?(this.rawBeginAt=-1,new De(this.input,s,e,t,this.file)):(this.p=n,new Re(this.input,s,n,this.file))}if(this.rmatch(e))break;this.p++}else n=this.readTo(e)-e.length;throw this.error(`raw ${this.snapshot(this.rawBeginAt)} not closed`,s)}readLiquidTagTokens(t=yi){const e=[];for(;this.p<this.N;){const i=this.readLiquidTagToken(t);i&&e.push(i)}return e}readLiquidTagToken(t){if(this.skipBlank(),this.end())return;const e=this.p;this.readToDelimiter("\n");const i=this.p;return new Xe(this.input,e,i,t,this.file)}error(t,e=this.p){return new zt(t,new Fe(this.input,e,this.N,this.file))}assert(t,e,i){if(!t)throw this.error("function"==typeof e?e():e,i)}snapshot(t=this.p){return JSON.stringify(function(t,e){return t.length>e?t.slice(0,e-3)+"...":t}(this.input.slice(t,this.N),32))}readWord(){return this.readIdentifier()}readIdentifier(){this.skipBlank();const t=this.p;for(;!this.end()&&Kt(this.peek());)++this.p;return new Fe(this.input,t,this.p,this.file)}readNonEmptyIdentifier(){const t=this.readIdentifier();return t.size()?t:void 0}readTagName(){return this.skipBlank(),"#"===this.input[this.p]?this.input.slice(this.p,++this.p):this.readIdentifier().getText()}readHashes(t){const e=[];for(;;){const i=this.readHash(t);if(!i)return e;e.push(i)}}readHash(t){this.skipBlank(),","===this.peek()&&++this.p;const e=this.p,i=this.readNonEmptyIdentifier();if(!i)return;let s;this.skipBlank();const n=ut(t)?t:t?"=":":";return this.peek()===n&&(++this.p,s=this.readValue()),new He(this.input,e,this.p,i,s,this.file)}remaining(){return this.input.slice(this.p,this.N)}advance(t=1){this.p+=t}end(){return this.p>=this.N}read(){return this.input[this.p++]}readTo(t){for(;this.p<this.N;)if(++this.p,this.rmatch(t))return this.p;return-1}readValue(){this.skipBlank();const t=this.p,e=this.readLiteral()||this.readQuoted()||this.readRange()||this.readNumber(),i=this.readProperties(!e);return i.length?new je(e,i,this.input,t,this.p):e}readScopeValue(){this.skipBlank();const t=this.p,e=this.readProperties();if(e.length)return new je(void 0,e,this.input,t,this.p)}readProperties(t=!0){const e=[];for(;;)if("["!==this.peek()){if(t&&!e.length){const t=this.readNonEmptyIdentifier();if(t){e.push(t);continue}}if("."!==this.peek()||"."===this.peek(1))break;{this.p++;const t=this.readNonEmptyIdentifier();if(!t)break;e.push(t)}}else{this.p++;const t=this.readValue()||new Fe(this.input,this.p,this.p,this.file);this.assert(-1!==this.readTo("]"),"[ not closed"),e.push(t)}return e}readNumber(){this.skipBlank();let t=!1,e=!1,i=0;for(64&this.peekType()&&i++;this.p+i<=this.N;)if(32&this.peekType(i))e=!0,i++;else{if("."!==this.peek(i)||"."===this.peek(i+1))break;if(t||!e)return;t=!0,i++}if(e&&!Kt(this.peek(i))){const t=new Le(this.input,this.p,this.p+i,this.file);return this.advance(i),t}}readLiteral(){this.skipBlank();const t=this.matchTrie(this.literalTrie);if(-1===t)return;const e=new Ne(this.input,this.p,t,this.file);return this.p=t,e}readRange(){this.skipBlank();const t=this.p;if("("!==this.peek())return;++this.p;const e=this.readValueOrThrow();this.skipBlank(),this.assert("."===this.read()&&"."===this.read(),"invalid range syntax");const i=this.readValueOrThrow();return this.skipBlank(),this.assert(")"===this.read(),"invalid range syntax"),new Ke(this.input,t,this.p,e,i,this.file)}readValueOrThrow(){const t=this.readValue();return this.assert(t,(()=>`unexpected token ${this.snapshot()}, value expected`)),t}readQuoted(){this.skipBlank();const t=this.p;if(!(8&this.peekType()))return;++this.p;let e=!1;for(;this.p<this.N&&(++this.p,this.input[this.p-1]!==this.input[t]||e);)e?e=!1:"\\"===this.input[this.p-1]&&(e=!0);return new We(this.input,t,this.p,this.file)}*readFileNameTemplate(t){const{outputDelimiterLeft:e}=t,i=[","," ",e],s=new Set(i);for(;this.p<this.N&&!s.has(this.peek());)yield this.match(e)?this.readOutputToken(t):this.readHTMLToken(i)}match(t){for(let e=0;e<t.length;e++)if(t[e]!==this.input[this.p+e])return!1;return!0}rmatch(t){for(let e=0;e<t.length;e++)if(t[t.length-1-e]!==this.input[this.p-1-e])return!1;return!0}peekType(t=0){return this.p+t>=this.N?0:Wt[this.input.charCodeAt(this.p+t)]}peek(t=0){return this.p+t>=this.N?"":this.input[this.p+t]}skipBlank(){for(;4&this.peekType();)++this.p}}class Ti{constructor(t,e){this.handlers={},this.stopRequested=!1,this.tokens=t,this.parseToken=e}on(t,e){return this.handlers[t]=e,this}trigger(t,e){const i=this.handlers[t];return!!i&&(i.call(this,e),!0)}start(){let t;for(this.trigger("start");!this.stopRequested&&(t=this.tokens.shift());){if(this.trigger("token",t))continue;if(Zi(t)&&this.trigger(`tag:${t.name}`,t))continue;const e=this.parseToken(t,this.tokens);this.trigger("template",e)}return this.stopRequested||this.trigger("end"),this}stop(){return this.stopRequested=!0,this}}class ki{constructor(t){this.token=t}}class Ci extends ki{constructor(t,e,i){super(t),this.name=t.name,this.liquid=i,this.tokenizer=t.tokenizer}}class Ei{constructor(t,e){this.hash={};const i=t instanceof Si?t:new Si(t,{});for(const t of i.readHashes(e))this.hash[t.name.content]=t.value}*render(t){const e={};for(const i of Object.keys(this.hash))e[i]=void 0===this.hash[i]||(yield ei(this.hash[i],t));return e}}function Mi(t){return St(t)}class Pi{constructor(t,e,i){this.token=t,this.name=t.name,this.handler=pt(e)?e:pt(null==e?void 0:e.handler)?e.handler:It,this.raw=!pt(e)&&!!(null==e?void 0:e.raw),this.args=t.args,this.liquid=i}*render(t,e){const i=[];for(const t of this.args)Mi(t)?i.push([t[0],yield ei(t[1],e)]):i.push(yield ei(t,e));return yield this.handler.apply({context:e,token:this.token,liquid:this.liquid},[t,...i])}}class Di{constructor(t,e){this.filters=[];const i="string"==typeof t?new Si(t,e.options.operators).readFilteredValue():t;this.initial=i.initial,this.filters=i.filters.map((t=>new Pi(t,this.getFilter(e,t.name),e)))}*value(t,e){e=e||t.opts.lenientIf&&this.filters.length>0&&"default"===this.filters[0].name;let i=yield this.initial.evaluate(t,e);for(const e of this.filters)i=yield e.render(i,t);return i}getFilter(t,e){const i=t.filters[e];return Xt(i||!t.options.strictFilters,(()=>`undefined filter: ${e}`)),i}}class Ii extends ki{constructor(t,e){var i;super(t);const s=new Si(t.input,e.options.operators,t.file,t.contentRange);this.value=new Di(s.readFilteredValue(),e);const n=this.value.filters,a=e.options.outputEscape;if(!(null===(i=n[n.length-1])||void 0===i?void 0:i.raw)&&a){const t=new Ve(toString.call(a),[],"",0,0);n.push(new Pi(t,a,e))}}*render(t,e){const i=yield this.value.value(t,!1);e.write(i)}*arguments(){yield this.value}}class Ri extends ki{constructor(t){super(t),this.str=t.getContent()}*render(t,e){e.write(this.str)}}class Li{constructor(t,e){this.segments=t,this.location=e}toString(){return Gi(this.segments,!0)}toArray(){return Array.from(function*t(...e){for(const i of e)i instanceof Li?yield Array.from(t(...i.segments)):yield i}(...this.segments))}}class Fi{constructor(){this.map=new Map}get(t){const e=Gi([t.segments[0]]);return this.map.has(e)||this.map.set(e,[]),this.map.get(e)}has(t){return this.map.has(Gi([t.segments[0]]))}push(t){this.get(t).push(t)}asObject(){return Object.fromEntries(this.map)}}const Ni={partials:!0};function*Oi(t,e,i){const s=new Fi,n=new Fi,a=new Fi,r=new ji(new Set),o=new Set;function l(t,e){s.push(t);const i=e.alias(t);if(void 0!==i){const t=i.segments[0];ut(t)&&!r.has(t)&&n.push(i)}else{const i=t.segments[0];ut(i)&&!e.has(i)&&n.push(t)}for(const i of t.segments)i instanceof Li&&l(i,e)}function*h(t,s){if(t.arguments)for(const e of t.arguments())for(const t of Vi(e))l(t,s);if(t.localScope)for(const e of t.localScope()){s.add(e.content),s.deleteAlias(e.content);const[t,i]=e.getPosition();a.push(new Li([e.content],{row:t,col:i,file:e.file}))}if(t.children)if(t.partialScope){const n=t.partialScope();if(void 0===n){for(const n of yield t.children(e,i))yield h(n,s);return}if(o.has(n.name))return;const a=new Set,r=n.isolated?new ji(a):s.push(a);for(const t of n.scope)if(ut(t))a.add(t);else{const[e,i]=t;a.add(e);const s=Array.from(Vi(i));s.length&&r.setAlias(e,s[0].segments)}for(const s of yield t.children(e,i))yield h(s,r),o.add(n.name);r.pop()}else{t.blockScope&&s.push(new Set(t.blockScope()));for(const n of yield t.children(e,i))yield h(n,s);t.blockScope&&s.pop()}}for(const e of t)yield h(e,r);return{variables:s.asObject(),globals:n.asObject(),locals:a.asObject()}}function Bi(t,e={}){return ce(Oi(t,Object.assign(Object.assign({},Ni),e).partials,!1))}function zi(t,e={}){return de(Oi(t,Object.assign(Object.assign({},Ni),e).partials,!0))}class ji{constructor(t){this.stack=[{names:t,aliases:new Map}]}has(t){for(const e of this.stack)if(e.names.has(t))return!0;return!1}push(t){return this.stack.push({names:t,aliases:new Map}),this}pop(){var t;return null===(t=this.stack.pop())||void 0===t?void 0:t.names}add(t){this.stack[0].names.add(t)}alias(t){const e=t.segments[0];if(!ut(e))return;const i=this.getAlias(e);return void 0!==i?new Li([...i,...t.segments.slice(1)],t.location):void 0}setAlias(t,e){this.stack[this.stack.length-1].aliases.set(t,e)}deleteAlias(t){this.stack[this.stack.length-1].aliases.delete(t)}getAlias(t){for(const e of this.stack){if(e.aliases.has(t))return e.aliases.get(t);if(e.names.has(t))return}}}function*Vi(t){as(t)?yield*Hi(t):t instanceof Di&&(yield*function*(t){for(const e of t.initial.postfix)as(e)&&(yield*Hi(e));for(const e of t.filters)for(const t of e.args)Mi(t)&&t[1]?yield*Hi(t[1]):as(t)&&(yield*Hi(t))}(t))}function*Hi(t){ns(t)?(yield*Hi(t.lhs),yield*Hi(t.rhs)):is(t)&&(yield $i(t))}function $i(t){const e=[];let i=t.file;const s=t.props[0];i=i||s.file,ts(s)||es(s)||ss(s)?e.push(s.content):is(s)&&e.push(...$i(s).segments);for(const s of t.props.slice(1))i=i||s.file,ts(s)||es(s)||ss(s)?e.push(s.content):is(s)&&e.push($i(s));const[n,a]=t.getPosition();return new Li(e,{row:n,col:a,file:i})}const Ui=/^[\u0080-\uFFFFa-zA-Z_][\u0080-\uFFFFa-zA-Z0-9_-]*$/;function Gi(t,e=!1){const i=[],s=t[0];ut(s)&&(!e||s.match(Ui)?i.push(`${s}`):i.push(`['${s}']`));for(const e of t.slice(1))e instanceof Li?i.push(`[${Gi(e.segments)}]`):ut(e)?e.match(Ui)?i.push(`.${e}`):i.push(`['${e}']`):i.push(`[${e}]`);return i.join("")}var qi,Wi,Ki;!function(t){t.Partials="partials",t.Layouts="layouts",t.Root="root"}(qi||(qi={}));class Xi{constructor(t){if(this.options=t,t.relativeReference){const e=t.fs.sep;Xt(e,"`fs.sep` is required for relative reference");const i=new RegExp(["."+e,".."+e,"./","../"].map((t=>t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))).join("|"));this.shouldLoadRelative=t=>i.test(t)}else this.shouldLoadRelative=t=>!1;this.contains=this.options.fs.contains||(()=>!0)}*lookup(t,e,i,s){const{fs:n}=this.options,a=this.options[e];for(const r of this.candidates(t,a,s,e!==qi.Root))if(i?n.existsSync(r):yield n.exists(r))return r;throw this.lookupError(t,a)}*candidates(t,e,i,s){const{fs:n,extname:a}=this.options;if(this.shouldLoadRelative(t)&&i){const r=n.resolve(this.dirname(i),t,a);for(const t of e)if(!s||this.contains(t,r)){yield r;break}}for(const i of e){const e=n.resolve(i,t,a);s&&!this.contains(i,e)||(yield e)}if(void 0!==n.fallback){const e=n.fallback(t);void 0!==e&&(yield e)}}dirname(t){const e=this.options.fs;return Xt(e.dirname,"`fs.dirname` is required for relative reference"),e.dirname(t)}lookupError(t,e){const i=new Error("ENOENT");return i.message=`ENOENT: Failed to lookup "${t}" in "${e}"`,i.code="ENOENT",i}}class Yi{constructor(t){this.liquid=t,this.cache=this.liquid.options.cache,this.fs=this.liquid.options.fs,this.parseFile=this.cache?this._parseFileCached:this._parseFile,this.loader=new Xi(this.liquid.options),this.parseLimit=new Me("parse length",t.options.parseLimit)}parse(t,e){t=String(t),this.parseLimit.use(t.length);const i=new Si(t,this.liquid.options.operators,e).readTopLevelTokens(this.liquid.options);return this.parseTokens(i)}parseTokens(t){let e;const i=[],s=[];for(;e=t.shift();)try{i.push(this.parseToken(e,t))}catch(t){if(!this.liquid.options.catchAllErrors)throw t;s.push(t)}if(s.length)throw new Ht(s);return i}parseToken(t,e){try{if(Zi(t)){const i=this.liquid.tags[t.name];return Xt(i,`tag "${t.name}" not found`),new i(t,e,this.liquid,this)}return rs(t)===Wi.Output?new Ii(t,this.liquid):new Ri(t)}catch(e){if(Bt.is(e))throw e;throw new jt(e,t)}}parseStream(t){return new Ti(t,((t,e)=>this.parseToken(t,e)))}*_parseFileCached(t,e,i=qi.Root,s){const n=this.cache,a=this.loader.shouldLoadRelative(t)?s+","+t:i+":"+t,r=yield n.read(a);if(r)return r;const o=this._parseFile(t,e,i,s),l=e?yield o:ce(o);n.write(a,l);try{return yield l}catch(t){throw n.remove(a),t}}*_parseFile(t,e,i=qi.Root,s){const n=yield this.loader.lookup(t,i,e,s);return this.parse(e?this.fs.readFileSync(n):yield this.fs.readFile(n),n)}}function Qi(t){return rs(t)===Wi.Operator}function Ji(t){return rs(t)===Wi.HTML}function Zi(t){return rs(t)===Wi.Tag}function ts(t){return rs(t)===Wi.Quoted}function es(t){return rs(t)===Wi.Number}function is(t){return rs(t)===Wi.PropertyAccess}function ss(t){return rs(t)===Wi.Word}function ns(t){return rs(t)===Wi.Range}function as(t){return(1667&rs(t))>0}function rs(t){return t?t.kind:-1}!function(t){t[t.Number=1]="Number",t[t.Literal=2]="Literal",t[t.Tag=4]="Tag",t[t.Output=8]="Output",t[t.HTML=16]="HTML",t[t.Filter=32]="Filter",t[t.Hash=64]="Hash",t[t.PropertyAccess=128]="PropertyAccess",t[t.Word=256]="Word",t[t.Range=512]="Range",t[t.Quoted=1024]="Quoted",t[t.Operator=2048]="Operator",t[t.FilteredValue=4096]="FilteredValue",t[t.Delimited=12]="Delimited"}(Wi||(Wi={}));class os{constructor(t={},e=yi,i={},{memoryLimit:s,renderLimit:n}={}){var a,r,o,l,h;this.scopes=[{}],this.registers={},this.breakCalled=!1,this.continueCalled=!1,this.sync=!!i.sync,this.opts=e,this.globals=null!==(a=i.globals)&&void 0!==a?a:e.globals,this.environments=Et(t)?t:Object(t),this.strictVariables=null!==(r=i.strictVariables)&&void 0!==r?r:this.opts.strictVariables,this.ownPropertyOnly=null!==(o=i.ownPropertyOnly)&&void 0!==o?o:e.ownPropertyOnly,this.memoryLimit=null!=s?s:new Me("memory alloc",null!==(l=i.memoryLimit)&&void 0!==l?l:e.memoryLimit),this.renderLimit=null!=n?n:new Me("template render",Je().now()+(null!==(h=i.renderLimit)&&void 0!==h?h:e.renderLimit))}getRegister(t){return this.registers[t]=this.registers[t]||{}}setRegister(t,e){return this.registers[t]=e}saveRegister(...t){return t.map((t=>[t,this.getRegister(t)]))}restoreRegister(t){return t.forEach((([t,e])=>this.setRegister(t,e)))}getAll(){return[this.globals,this.environments,...this.scopes].reduce(((t,e)=>le(t,e)),{})}get(t){return this.getSync(t)}getSync(t){return de(this._get(t))}*_get(t){const e=this.findScope(t[0]);return yield this._getFromScope(e,t)}getFromScope(t,e){return de(this._getFromScope(t,e))}*_getFromScope(t,e,i=this.strictVariables){ut(e)&&(e=e.split("."));for(let s=0;s<e.length;s++)if(t=yield ls(t,e[s],this.ownPropertyOnly),i&&void 0===t)throw new Ut(e.slice(0,s+1).join("."));return t}push(t){return this.scopes.push(t)}pop(){return this.scopes.pop()}bottom(){return this.scopes[0]}spawn(t={}){return new os(t,this.opts,{sync:this.sync,globals:this.globals,strictVariables:this.strictVariables},{renderLimit:this.renderLimit,memoryLimit:this.memoryLimit})}findScope(t){for(let e=this.scopes.length-1;e>=0;e--){const i=this.scopes[e];if(t in i)return i}return t in this.environments?this.environments:this.globals}}function ls(t,e,i){if(t=At(t),e=yt(e),_t(t))return t;if(St(t)&&e<0)return t[t.length+ +e];const s=function(t,e,i){return!i||dt.call(t,e)||t instanceof lt?t[e]:void 0}(t,e,i);return void 0===s&&t instanceof lt?t.liquidMethodMissing(e):pt(s)?s.call(t):"size"===e?function(t){if(dt.call(t,"size")||void 0!==t.size)return t.size;if(St(t)||ut(t))return t.length;if("object"==typeof t)return Object.keys(t).length}(t):"first"===e?function(t){return St(t)?t[0]:t.first}(t):"last"===e?function(t){return St(t)?t[t.length-1]:t.last}(t):s}!function(t){t[t.OUTPUT=0]="OUTPUT",t[t.STORE=1]="STORE"}(Ki||(Ki={}));const hs=Lt(Math.abs),cs=Lt(Math.max),ds=Lt(Math.min),us=Lt(Math.ceil),ps=Lt(((t,e,i=!1)=>i?Math.floor(t/e):t/e)),gs=Lt(Math.floor),fs=Lt(((t,e)=>t-e)),ms=Lt(((t,e)=>t%e)),vs=Lt(((t,e)=>t*e));var bs=Object.freeze({__proto__:null,abs:hs,at_least:cs,at_most:ds,ceil:us,divided_by:ps,floor:gs,minus:fs,modulo:ms,times:vs,round:function(t,e=0){t=yt(t),e=yt(e);const i=Math.pow(10,e);return Math.round(t*i)/i},plus:function(t,e){return t=yt(t),e=yt(e),Number(t)+Number(e)}});const ys=/[^\p{M}\p{L}\p{Nd}]+/gu,ws={raw:/\s+/g,default:ys,pretty:/[^\p{M}\p{L}\p{Nd}._~!$&'()+,;=@]+/gu,ascii:/[^A-Za-z0-9]+/g,latin:ys,none:null};var xs=Object.freeze({__proto__:null,url_decode:t=>decodeURIComponent(mt(t)).replace(/\+/g," "),url_encode:t=>encodeURIComponent(mt(t)).replace(/%20/g,"+"),cgi_escape:t=>encodeURIComponent(mt(t)).replace(/%20/g,"+").replace(/[!'()*]/g,(t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())),uri_escape:t=>encodeURI(mt(t)).replace(/%5B/g,"[").replace(/%5D/g,"]"),slugify:function(t,e="default",i=!1){t=mt(t);const s=ws[e];return s&&("latin"===e&&(t=function(t){return t.replace(/[àáâãäå]/g,"a").replace(/[æ]/g,"ae").replace(/[ç]/g,"c").replace(/[èéêë]/g,"e").replace(/[ìíîï]/g,"i").replace(/[ð]/g,"d").replace(/[ñ]/g,"n").replace(/[òóôõöø]/g,"o").replace(/[ùúûü]/g,"u").replace(/[ýÿ]/g,"y").replace(/[ß]/g,"ss").replace(/[œ]/g,"oe").replace(/[þ]/g,"th").replace(/[ẞ]/g,"SS").replace(/[Œ]/g,"OE").replace(/[Þ]/g,"TH")}(t)),t=t.replace(s,"-").replace(/^-|-$/g,"")),i?t:t.toLowerCase()}});const As=Lt((function(t,e){const i=bt(t),s=_t(e)?" ":mt(e),n=i.length*(1+s.length);return this.context.memoryLimit.use(n),i.join(s)})),_s=Lt((t=>Tt(t)?Ct(t):"")),Ss=Lt((t=>Tt(t)?t[0]:"")),Ts=Lt((function(t){const e=bt(t);return this.context.memoryLimit.use(e.length),[...e].reverse()}));function ks(t,e=[]){const i=bt(t),s=bt(e);return this.context.memoryLimit.use(i.length+s.length),i.concat(s)}function Cs(t){return this.context.opts.jekyllWhere?e=>{return Qt.is(t)?ri(e,t):St(e)?(i=t,e.some((t=>ri(t,i)))):ri(e,t);var i}:void 0===t?t=>si(t,this.context):e=>ri(e,t)}function*Es(t,e,i,s){const n=[];e=bt(e),this.context.memoryLimit.use(e.length);const a=new Si(mt(i)).readScopeValue();for(const t of e)n.push(yield ei(a,this.context.spawn(t)));const r=Cs.call(this,s);return e.filter(((e,i)=>r(n[i])===t))}function*Ms(t,e,i,s){const n=[],a=new Di(mt(s),this.liquid),r=bt(e);this.context.memoryLimit.use(r.length);for(const e of r){this.context.push({[i]:e});const s=yield a.value(this.context);this.context.pop(),s===t&&n.push(e)}return n}function*Ps(t,e,i){const s=new Si(mt(e)).readScopeValue(),n=bt(t),a=Cs.call(this,i);for(let t=0;t<n.length;t++){if(a(yield ei(s,this.context.spawn(n[t]))))return[t,n[t]]}}function*Ds(t,e,i){const s=new Di(mt(i),this.liquid),n=bt(t);for(let t=0;t<n.length;t++){this.context.push({[e]:n[t]});const i=yield s.value(this.context);if(this.context.pop(),i)return[t,n[t]]}}var Is=Object.freeze({__proto__:null,join:As,last:_s,first:Ss,reverse:Ts,sort:function*(t,e){const i=[],s=bt(t);this.context.memoryLimit.use(s.length);for(const t of s)i.push([t,e?yield this.context._getFromScope(t,mt(e).split("."),!1):t]);return i.sort(((t,e)=>{const i=t[1],s=e[1];return i<s?-1:i>s?1:0})).map((t=>t[0]))},sort_natural:function(t,e){const i=mt(e),s=void 0===e?Rt:(t,e)=>Rt(t[i],e[i]),n=bt(t);return this.context.memoryLimit.use(n.length),[...n].sort(s)},size:t=>t&&t.length||0,map:function*(t,e){const i=[],s=bt(t);this.context.memoryLimit.use(s.length);for(const t of s)i.push(yield this.context._getFromScope(t,mt(e),!1));return i},sum:function*(t,e){let i=0;const s=bt(t);for(const t of s){const s=Number(e?yield this.context._getFromScope(t,mt(e),!1):t);i+=Number.isNaN(s)?0:s}return i},compact:function(t){const e=bt(t);return this.context.memoryLimit.use(e.length),e.filter((t=>!_t(yt(t))))},concat:ks,push:function(t,e){return ks.call(this,t,[e])},unshift:function(t,e){const i=bt(t);this.context.memoryLimit.use(i.length);const s=[...i];return s.unshift(e),s},pop:function(t){const e=[...bt(t)];return e.pop(),e},shift:function(t){const e=bt(t);this.context.memoryLimit.use(e.length);const i=[...e];return i.shift(),i},slice:function(t,e,i=1){return _t(t=yt(t))?[]:(St(t)||(t=mt(t)),e=e<0?t.length+e:e,this.context.memoryLimit.use(i),t.slice(e,e+i))},where:function*(t,e,i){return yield*Es.call(this,!0,t,e,i)},reject:function*(t,e,i){return yield*Es.call(this,!1,t,e,i)},where_exp:function*(t,e,i){return yield*Ms.call(this,!0,t,e,i)},reject_exp:function*(t,e,i){return yield*Ms.call(this,!1,t,e,i)},group_by:function*(t,e){const i=new Map;t=vt(t);const s=new Si(mt(e)).readScopeValue();this.context.memoryLimit.use(t.length);for(const e of t){const t=yield ei(s,this.context.spawn(e));i.has(t)||i.set(t,[]),i.get(t).push(e)}return[...i.entries()].map((([t,e])=>({name:t,items:e})))},group_by_exp:function*(t,e,i){const s=new Map,n=new Di(mt(i),this.liquid);t=vt(t),this.context.memoryLimit.use(t.length);for(const i of t){this.context.push({[e]:i});const t=yield n.value(this.context);this.context.pop(),s.has(t)||s.set(t,[]),s.get(t).push(i)}return[...s.entries()].map((([t,e])=>({name:t,items:e})))},has:function*(t,e,i){return!!(yield*Ps.call(this,t,e,i))},has_exp:function*(t,e,i){return!!(yield*Ds.call(this,t,e,i))},find_index:function*(t,e,i){const s=yield*Ps.call(this,t,e,i);return s?s[0]:void 0},find_index_exp:function*(t,e,i){const s=yield*Ds.call(this,t,e,i);return s?s[0]:void 0},find:function*(t,e,i){const s=yield*Ps.call(this,t,e,i);return s?s[1]:void 0},find_exp:function*(t,e,i){const s=yield*Ds.call(this,t,e,i);return s?s[1]:void 0},uniq:function(t){return t=bt(t),this.context.memoryLimit.use(t.length),[...new Set(t)]},sample:function(t,e=1){if(_t(t=yt(t)))return[];St(t)||(t=mt(t)),this.context.memoryLimit.use(e);const i=[...t].sort((()=>Math.random()-.5));return 1===e?i[0]:i.slice(0,e)}});function Rs(t,e,i){var s,n,a;const r=(null!==(s=null==t?void 0:t.length)&&void 0!==s?s:0)+(null!==(n=null==e?void 0:e.length)&&void 0!==n?n:0)+(null!==(a=null==i?void 0:i.length)&&void 0!==a?a:0);this.context.memoryLimit.use(r);const o=Fs(t,this.context.opts,i);return o?we(o,e=_t(e=yt(e))?this.context.opts.dateFormat:mt(e)):t}function Ls(t,e,i,s){const n=Fs(t,this.context.opts);if(!n)return t;if("ordinal"===i){const t=n.getDate();return we(n,"US"===s?`${e} ${t}%q, %Y`:`${t}%q ${e} %Y`)}return we(n,`%d ${e} %Y`)}function Fs(t,e,i){let s;const n=null!=i?i:e.timezoneOffset,a=e.locale;return s="now"===(t=yt(t))||"today"===t?new Ee(Date.now(),a,n):xt(t)?new Ee(1e3*t,a,n):ut(t)?/^\d+$/.test(t)?new Ee(1e3*+t,a,n):e.preserveTimezones&&void 0===i?Ee.createDateFixedToTimezone(t,a):new Ee(t,a,n):new Ee(t,a,n),s.valid()?s:void 0}var Ns=Object.freeze({__proto__:null,date:Rs,date_to_xmlschema:function(t){return Rs.call(this,t,"%Y-%m-%dT%H:%M:%S%:z")},date_to_rfc822:function(t){return Rs.call(this,t,"%a, %d %b %Y %H:%M:%S %z")},date_to_string:function(t,e,i){return Ls.call(this,t,"%b",e,i)},date_to_long_string:function(t,e,i){return Ls.call(this,t,"%B",e,i)}});const Os=/[\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/gu,Bs=/[^\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF\s]+/gu;var zs=Object.freeze({__proto__:null,append:function(t,e){Xt(2===arguments.length,"append expect 2 arguments");const i=mt(t),s=mt(e);return this.context.memoryLimit.use(i.length+s.length),i+s},prepend:function(t,e){Xt(2===arguments.length,"prepend expect 2 arguments");const i=mt(t),s=mt(e);return this.context.memoryLimit.use(i.length+s.length),s+i},lstrip:function(t,e){const i=mt(t);return this.context.memoryLimit.use(i.length),e?(e=Ft(mt(e)),i.replace(new RegExp(`^[${e}]+`,"g"),"")):i.replace(/^\s+/,"")},downcase:function(t){const e=mt(t);return this.context.memoryLimit.use(e.length),e.toLowerCase()},upcase:function(t){const e=mt(t);return this.context.memoryLimit.use(e.length),mt(e).toUpperCase()},remove:function(t,e){const i=mt(t);return this.context.memoryLimit.use(i.length),i.split(mt(e)).join("")},remove_first:function(t,e){const i=mt(t);return this.context.memoryLimit.use(i.length),i.replace(mt(e),"")},remove_last:function(t,e){const i=mt(t);this.context.memoryLimit.use(i.length);const s=mt(e),n=i.lastIndexOf(s);return-1===n?i:i.substring(0,n)+i.substring(n+s.length)},rstrip:function(t,e){return t=mt(t),this.context.memoryLimit.use(t.length),e?(e=Ft(mt(e)),t.replace(new RegExp(`[${e}]+$`,"g"),"")):t.replace(/\s+$/,"")},split:function(t,e){const i=mt(t);this.context.memoryLimit.use(i.length);const s=i.split(mt(e));for(;s.length&&""===s[s.length-1];)s.pop();return s},strip:function(t,e){const i=mt(t);return this.context.memoryLimit.use(i.length),e?(e=Ft(mt(e)),i.replace(new RegExp(`^[${e}]+`,"g"),"").replace(new RegExp(`[${e}]+$`,"g"),"")):i.trim()},strip_newlines:function(t){const e=mt(t);return this.context.memoryLimit.use(e.length),e.replace(/\r?\n/gm,"")},capitalize:function(t){return t=mt(t),this.context.memoryLimit.use(t.length),t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()},replace:function(t,e,i){const s=mt(t);return this.context.memoryLimit.use(s.length),s.split(mt(e)).join(i)},replace_first:function(t,e,i){const s=mt(t);return this.context.memoryLimit.use(s.length),s.replace(mt(e),i)},replace_last:function(t,e,i){const s=mt(t);this.context.memoryLimit.use(s.length);const n=mt(e),a=s.lastIndexOf(n);if(-1===a)return s;const r=mt(i);return s.substring(0,a)+r+s.substring(a+n.length)},truncate:function(t,e=50,i="..."){const s=mt(t);return this.context.memoryLimit.use(s.length),s.length<=e?t:s.substring(0,e-i.length)+i},truncatewords:function(t,e=15,i="..."){const s=mt(t);this.context.memoryLimit.use(s.length);const n=s.split(/\s+/);e<=0&&(e=1);let a=n.slice(0,e).join(" ");return n.length>=e&&(a+=i),a},normalize_whitespace:function(t){const e=mt(t);return this.context.memoryLimit.use(e.length),e.replace(/\s+/g," ")},number_of_words:function(t,e){const i=mt(t);if(this.context.memoryLimit.use(i.length),!(t=i.trim()))return 0;switch(e){case"cjk":return(t.match(Os)||[]).length+(t.match(Bs)||[]).length;case"auto":return Os.test(t)?t.match(Os).length+(t.match(Bs)||[]).length:t.split(/\s+/).length;default:return t.split(/\s+/).length}},array_to_sentence_string:function(t,e="and"){switch(this.context.memoryLimit.use(t.length),t.length){case 0:return"";case 1:return t[0];case 2:return`${t[0]} ${e} ${t[1]}`;default:return`${t.slice(0,-1).join(", ")}, ${e} ${t[t.length-1]}`}}});const js=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},vi),bs),xs),Is),Ns),zs),ui);const Vs=["offset","limit","reversed"];function Hs(t,e,i){if(e.options.dynamicPartials){const e=t.readValue();if(t.assert(e,"illegal file path"),"none"===e.getText())return;if(ts(e)){return $s(i.parse(e.content))}return e}const s=[...t.readFileNameTemplate(e.options)],n=$s(i.parseTokens(s));return"none"===n?void 0:n}function $s(t){return 1===t.length&&Ji(t[0].token)?t[0].token.getContent():t}function*Us(t,e,i){return"string"==typeof t?t:Array.isArray(t)?i.renderer.renderTemplates(t,e):yield ei(t,e)}class Gs extends Zt{constructor(t,e,i,s){super(t,i,s),this.length=t,this.cols=e}row(){return Math.floor(this.i/this.cols)+1}col0(){return this.i%this.cols}col(){return this.col0()+1}col_first(){return 0===this.col0()}col_last(){return this.col()===this.cols}}const qs={assign:class extends Ci{constructor(t,e,i){super(t,e,i),this.identifier=this.tokenizer.readIdentifier(),this.key=this.identifier.content,this.tokenizer.assert(this.key,"expected variable name"),this.tokenizer.skipBlank(),this.tokenizer.assert("="===this.tokenizer.peek(),'expected "="'),this.tokenizer.advance(),this.value=new Di(this.tokenizer.readFilteredValue(),this.liquid)}*render(t){t.bottom()[this.key]=yield this.value.value(t,this.liquid.options.lenientIf)}*arguments(){yield this.value}*localScope(){yield this.identifier}},for:class extends Ci{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer.readIdentifier(),a=this.tokenizer.readIdentifier(),r=this.tokenizer.readValue();if(!n.size()||"in"!==a.content||!r)throw new Error(`illegal tag: ${t.getText()}`);let o;this.variable=n.content,this.collection=r,this.hash=new Ei(this.tokenizer,i.options.keyValueSeparator),this.templates=[],this.elseTemplates=[];const l=s.parseStream(e).on("start",(()=>o=this.templates)).on("tag:else",(t=>{Yt(t.args),o=this.elseTemplates})).on("tag:endfor",(t=>{Yt(t.args),l.stop()})).on("template",(t=>o.push(t))).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)}));l.start()}*render(t,e){const i=this.liquid.renderer;let s=vt(yield ei(this.collection,t));if(!s.length)return void(yield i.renderTemplates(this.elseTemplates,t,e));const n="continue-"+this.variable+"-"+this.collection.getText();t.push({continue:t.getRegister(n)});const a=yield this.hash.render(t);t.pop();s=(this.liquid.options.orderedFilterParameters?Object.keys(a).filter((t=>Vs.includes(t))):Vs.filter((t=>void 0!==a[t]))).reduce(((t,e)=>{return"offset"===e?(i=t,s=a.offset,i.slice(s)):"limit"===e?function(t,e){return t.slice(0,e)}(t,a.limit):function(t){return[...t].reverse()}(t);var i,s}),s),t.setRegister(n,(a.offset||0)+s.length);const r={forloop:new Zt(s.length,this.collection.getText(),this.variable)};t.push(r);for(const n of s){if(r[this.variable]=n,t.continueCalled=t.breakCalled=!1,yield i.renderTemplates(this.templates,t,e),t.breakCalled)break;r.forloop.next()}t.continueCalled=t.breakCalled=!1,t.pop()}*children(){const t=this.templates.slice();return this.elseTemplates&&t.push(...this.elseTemplates),t}*arguments(){yield this.collection;for(const t of Object.values(this.hash.hash))as(t)&&(yield t)}blockScope(){return[this.variable,"forloop"]}},capture:class extends Ci{constructor(t,e,i,s){for(super(t,e,i),this.templates=[],this.identifier=this.readVariable(),this.variable=this.identifier.content;e.length;){const t=e.shift();if(Zi(t)&&"endcapture"===t.name)return;this.templates.push(s.parseToken(t,e))}throw new Error(`tag ${t.getText()} not closed`)}readVariable(){let t=this.tokenizer.readIdentifier();if(t.content)return t;if(t=this.tokenizer.readQuoted(),t)return t;throw this.tokenizer.error("invalid capture name")}*render(t){const e=this.liquid.renderer,i=yield e.renderTemplates(this.templates,t);t.bottom()[this.variable]=i}*children(){return this.templates}*localScope(){yield this.identifier}},case:class extends Ci{constructor(t,e,i,s){super(t,e,i),this.branches=[],this.elseTemplates=[],this.value=new Di(this.tokenizer.readFilteredValue(),this.liquid),this.elseTemplates=[];let n=[],a=0;const r=s.parseStream(e).on("tag:when",(t=>{if(a>0)return;n=[];const e=[];for(;!t.tokenizer.end();)e.push(t.tokenizer.readValueOrThrow()),t.tokenizer.skipBlank(),","===t.tokenizer.peek()?t.tokenizer.readTo(","):t.tokenizer.readTo("or");this.branches.push({values:e,templates:n})})).on("tag:else",(()=>{a++,n=this.elseTemplates})).on("tag:endcase",(()=>r.stop())).on("template",(t=>{n===this.elseTemplates&&1!==a||n.push(t)})).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)}));r.start()}*render(t,e){const i=this.liquid.renderer,s=yt(yield this.value.value(t,t.opts.lenientIf));let n=!1;for(const a of this.branches)for(const r of a.values){if(ri(s,yield ei(r,t,t.opts.lenientIf))){yield i.renderTemplates(a.templates,t,e),n=!0;break}}n||(yield i.renderTemplates(this.elseTemplates,t,e))}*arguments(){yield this.value,yield*this.branches.flatMap((t=>t.values))}*children(){const t=this.branches.flatMap((t=>t.templates));return this.elseTemplates&&t.push(...this.elseTemplates),t}},comment:class extends Ci{constructor(t,e,i){for(super(t,e,i);e.length;){const t=e.shift();if(Zi(t)&&"endcomment"===t.name)return}throw new Error(`tag ${t.getText()} not closed`)}render(){}},include:class extends Ci{constructor(t,e,i,s){super(t,e,i);const{tokenizer:n}=t;this.file=Hs(n,this.liquid,s),this.currentFile=t.file;const a=n.p;"with"===n.readIdentifier().content?(n.skipBlank(),":"!==n.peek()?this.withVar=n.readValue():n.p=a):n.p=a,this.hash=new Ei(n,i.options.jekyllInclude||i.options.keyValueSeparator)}*render(t,e){const{liquid:i,hash:s,withVar:n}=this,{renderer:a}=i,r=yield Us(this.file,t,i);Xt(r,(()=>`illegal file path "${r}"`));const o=t.saveRegister("blocks","blockMode");t.setRegister("blocks",{}),t.setRegister("blockMode",Ki.OUTPUT);const l=yield s.render(t);n&&(l[r]=yield ei(n,t));const h=yield i._parsePartialFile(r,t.sync,this.currentFile);t.push(t.opts.jekyllInclude?{include:l}:l),yield a.renderTemplates(h,t,e),t.pop(),t.restoreRegister(o)}*children(t,e){return t&&ut(this.file)?yield this.liquid._parsePartialFile(this.file,e,this.currentFile):[]}partialScope(){if(ut(this.file)){let t;return this.liquid.options.jekyllInclude?t=["include"]:(t=Object.keys(this.hash.hash),this.withVar&&t.push([this.file,this.withVar])),{name:this.file,isolated:!1,scope:t}}}*arguments(){yield*Object.values(this.hash.hash).filter(as),as(this.file)&&(yield this.file),as(this.withVar)&&(yield this.withVar)}},render:class extends Ci{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer;for(this.file=Hs(n,this.liquid,s),this.currentFile=t.file;!n.end();){n.skipBlank();const t=n.p,e=n.readIdentifier();if(("with"===e.content||"for"===e.content)&&(n.skipBlank(),":"!==n.peek())){const t=n.readValue();if(t){const i=n.p;let s;"as"===n.readIdentifier().content?s=n.readIdentifier():n.p=i,this[e.content]={value:t,alias:s&&s.content},n.skipBlank(),","===n.peek()&&n.advance();continue}}n.p=t;break}this.hash=new Ei(n,i.options.keyValueSeparator)}*render(t,e){const{liquid:i,hash:s}=this,n=yield Us(this.file,t,i);Xt(n,(()=>`illegal file path "${n}"`));const a=t.spawn(),r=a.bottom();if(le(r,yield s.render(t)),this.with){const{value:e,alias:i}=this.with;r[i||n]=yield ei(e,t)}if(this.for){const{value:s,alias:o}=this.for,l=vt(yield ei(s,t));r.forloop=new Zt(l.length,s.getText(),o);for(const t of l){r[o]=t;const s=yield i._parsePartialFile(n,a.sync,this.currentFile);yield i.renderer.renderTemplates(s,a,e),r.forloop.next()}}else{const t=yield i._parsePartialFile(n,a.sync,this.currentFile);yield i.renderer.renderTemplates(t,a,e)}}*children(t,e){return t&&ut(this.file)?yield this.liquid._parsePartialFile(this.file,e,this.currentFile):[]}partialScope(){if(ut(this.file)){const t=Object.keys(this.hash.hash);if(this.with){const{value:e,alias:i}=this.with;ut(i)?t.push([i,e]):ut(this.file)&&t.push([this.file,e])}if(this.for){const{value:e,alias:i}=this.for;ut(i)?t.push([i,e]):ut(this.file)&&t.push([this.file,e])}return{name:this.file,isolated:!0,scope:t}}}*arguments(){for(const t of Object.values(this.hash.hash))as(t)&&(yield t);if(this.with){const{value:t}=this.with;as(t)&&(yield t)}if(this.for){const{value:t}=this.for;as(t)&&(yield t)}}},decrement:class extends Ci{constructor(t,e,i){super(t,e,i),this.identifier=this.tokenizer.readIdentifier(),this.variable=this.identifier.content}render(t,e){const i=t.environments;xt(i[this.variable])||(i[this.variable]=0),e.write(mt(--i[this.variable]))}*localScope(){yield this.identifier}},increment:class extends Ci{constructor(t,e,i){super(t,e,i),this.identifier=this.tokenizer.readIdentifier(),this.variable=this.identifier.content}render(t,e){const i=t.environments;xt(i[this.variable])||(i[this.variable]=0);const s=i[this.variable];i[this.variable]++,e.write(mt(s))}*localScope(){yield this.identifier}},cycle:class extends Ci{constructor(t,e,i){super(t,e,i),this.candidates=[];const s=this.tokenizer.readValue();for(this.tokenizer.skipBlank(),s&&(":"===this.tokenizer.peek()?(this.group=s,this.tokenizer.advance()):this.candidates.push(s));!this.tokenizer.end();){const t=this.tokenizer.readValue();t&&this.candidates.push(t),this.tokenizer.readTo(",")}this.tokenizer.assert(this.candidates.length,(()=>`empty candidates: "${t.getText()}"`))}*render(t,e){const i=`cycle:${yield ei(this.group,t)}:`+this.candidates.join(","),s=t.getRegister("cycle");let n=s[i];void 0===n&&(n=s[i]=0);const a=this.candidates[n];return n=(n+1)%this.candidates.length,s[i]=n,yield ei(a,t)}*arguments(){yield*this.candidates,this.group&&(yield this.group)}},if:class extends Ci{constructor(t,e,i,s){super(t,e,i),this.branches=[];let n=[];s.parseStream(e).on("start",(()=>this.branches.push({value:new Di(t.tokenizer.readFilteredValue(),this.liquid),templates:n=[]}))).on("tag:elsif",(t=>{Xt(!this.elseTemplates,"unexpected elsif after else"),this.branches.push({value:new Di(t.tokenizer.readFilteredValue(),this.liquid),templates:n=[]})})).on("tag:else",(t=>{Yt(t.args),Xt(!this.elseTemplates,"duplicated else"),n=this.elseTemplates=[]})).on("tag:endif",(function(t){Yt(t.args),this.stop()})).on("template",(t=>n.push(t))).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)})).start()}*render(t,e){const i=this.liquid.renderer;for(const{value:s,templates:n}of this.branches){if(si(yield s.value(t,t.opts.lenientIf),t))return void(yield i.renderTemplates(n,t,e))}yield i.renderTemplates(this.elseTemplates||[],t,e)}*children(){const t=this.branches.flatMap((t=>t.templates));return this.elseTemplates&&t.push(...this.elseTemplates),t}arguments(){return this.branches.map((t=>t.value))}},layout:class extends Ci{constructor(t,e,i,s){super(t,e,i),this.file=Hs(this.tokenizer,this.liquid,s),this.currentFile=t.file,this.args=new Ei(this.tokenizer,i.options.keyValueSeparator),this.templates=s.parseTokens(e)}*render(t,e){const{liquid:i,args:s,file:n}=this,{renderer:a}=i;if(void 0===n)return t.setRegister("blockMode",Ki.OUTPUT),void(yield a.renderTemplates(this.templates,t,e));const r=yield Us(this.file,t,i);Xt(r,(()=>`illegal file path "${r}"`));const o=yield i._parseLayoutFile(r,t.sync,this.currentFile);t.setRegister("blockMode",Ki.STORE);const l=yield a.renderTemplates(this.templates,t),h=t.getRegister("blocks");void 0===h[""]&&(h[""]=(t,e)=>e.write(l)),t.setRegister("blockMode",Ki.OUTPUT),t.push(yield s.render(t)),yield a.renderTemplates(o,t,e),t.pop()}*children(t){const e=this.templates.slice();return t&&ut(this.file)&&e.push(...yield this.liquid._parsePartialFile(this.file,!0,this.currentFile)),e}*arguments(){for(const t of Object.values(this.args.hash))as(t)&&(yield t);as(this.file)&&(yield this.file)}partialScope(){if(ut(this.file))return{name:this.file,isolated:!1,scope:Object.keys(this.args.hash)}}},block:class extends Ci{constructor(t,e,i,s){super(t,e,i),this.templates=[];const n=/\w+/.exec(t.args);for(this.block=n?n[0]:"";e.length;){const t=e.shift();if(Zi(t)&&"endblock"===t.name)return;const i=s.parseToken(t,e);this.templates.push(i)}throw new Error(`tag ${t.getText()} not closed`)}*render(t,e){const i=this.getBlockRender(t);t.getRegister("blockMode")===Ki.STORE?t.getRegister("blocks")[this.block]=i:yield i(new se,e)}getBlockRender(t){const{liquid:e,templates:i}=this,s=t.getRegister("blocks")[this.block],n=function*(s,n){t.push({block:s}),yield e.renderer.renderTemplates(i,t,n),t.pop()};return s?(t,e)=>s(new se((e=>n(t,e))),e):n}*children(){return this.templates}blockScope(){return["block"]}},raw:class extends Ci{constructor(t,e,i){for(super(t,e,i),this.tokens=[];e.length;){const t=e.shift();if(Zi(t)&&"endraw"===t.name)return;this.tokens.push(t)}throw new Error(`tag ${t.getText()} not closed`)}render(){return this.tokens.map((t=>t.getText())).join("")}},tablerow:class extends Ci{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer.readIdentifier();this.tokenizer.skipBlank();const a=this.tokenizer.readIdentifier(),r=this.tokenizer.readValue();if("in"!==a.content||!r)throw new Error(`illegal tag: ${t.getText()}`);let o;this.variable=n.content,this.collection=r,this.args=new Ei(this.tokenizer,i.options.keyValueSeparator),this.templates=[];const l=s.parseStream(e).on("start",(()=>o=this.templates)).on("tag:endtablerow",(()=>l.stop())).on("template",(t=>o.push(t))).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)}));l.start()}*render(t,e){let i=vt(yield ei(this.collection,t));const s=yield this.args.render(t),n=s.offset||0,a=void 0===s.limit?i.length:s.limit;i=i.slice(n,n+a);const r=s.cols||i.length,o=this.liquid.renderer,l=new Gs(i.length,r,this.collection.getText(),this.variable),h={tablerowloop:l};t.push(h);for(let s=0;s<i.length;s++,l.next())h[this.variable]=i[s],0===l.col0()&&(1!==l.row()&&e.write("</tr>"),e.write(`<tr class="row${l.row()}">`)),e.write(`<td class="col${l.col()}">`),yield o.renderTemplates(this.templates,t,e),e.write("</td>");i.length&&e.write("</tr>"),t.pop()}*children(){return this.templates}*arguments(){yield this.collection;for(const t of Object.values(this.args.hash))as(t)&&(yield t)}blockScope(){return[this.variable,"tablerowloop"]}},unless:class extends Ci{constructor(t,e,i,s){super(t,e,i),this.branches=[],this.elseTemplates=[];let n=[],a=0;s.parseStream(e).on("start",(()=>this.branches.push({value:new Di(t.tokenizer.readFilteredValue(),this.liquid),test:ni,templates:n=[]}))).on("tag:elsif",(t=>{a>0?n=[]:this.branches.push({value:new Di(t.tokenizer.readFilteredValue(),this.liquid),test:si,templates:n=[]})})).on("tag:else",(()=>{a++,n=this.elseTemplates})).on("tag:endunless",(function(){this.stop()})).on("template",(t=>{n===this.elseTemplates&&1!==a||n.push(t)})).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)})).start()}*render(t,e){const i=this.liquid.renderer;for(const{value:s,test:n,templates:a}of this.branches){if(n(yield s.value(t,t.opts.lenientIf),t))return void(yield i.renderTemplates(a,t,e))}yield i.renderTemplates(this.elseTemplates,t,e)}*children(){const t=this.branches.flatMap((t=>t.templates));return this.elseTemplates&&t.push(...this.elseTemplates),t}arguments(){return this.branches.map((t=>t.value))}},break:class extends Ci{render(t,e){t.breakCalled=!0}},continue:class extends Ci{render(t,e){t.continueCalled=!0}},echo:class extends Ci{constructor(t,e,i){super(t,e,i),this.tokenizer.skipBlank(),this.tokenizer.end()||(this.value=new Di(this.tokenizer.readFilteredValue(),this.liquid))}*render(t,e){if(!this.value)return;const i=yield this.value.value(t,!1);e.write(i)}*arguments(){this.value&&(yield this.value)}},liquid:class extends Ci{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer.readLiquidTagTokens(this.liquid.options);this.templates=s.parseTokens(n)}*render(t,e){yield this.liquid.renderer.renderTemplates(this.templates,t,e)}*children(){return this.templates}},"#":class extends Ci{constructor(t,e,i){if(super(t,e,i),-1!==t.args.search(/\n\s*[^#\s]/g))throw new Error("every line of an inline comment must start with a '#' character")}render(){}}};class Ws{constructor(t={}){this.renderer=new Ze,this.filters={},this.tags={},this.options=wi(t),this.parser=new Yi(this),kt(qs,((t,e)=>this.registerTag(e,t))),kt(js,((t,e)=>this.registerFilter(e,t)))}parse(t,e){return new Yi(this).parse(t,e)}_render(t,e,i){const s=e instanceof os?e:new os(e,this.options,i);return this.renderer.renderTemplates(t,s)}render(t,e,i){return he(this,void 0,void 0,(function*(){return ce(this._render(t,e,Object.assign(Object.assign({},i),{sync:!1})))}))}renderSync(t,e,i){return de(this._render(t,e,Object.assign(Object.assign({},i),{sync:!0})))}renderToNodeStream(t,e,i={}){const s=new os(e,this.options,i);return this.renderer.renderTemplatesToNodeStream(t,s)}_parseAndRender(t,e,i){const s=this.parse(t);return this._render(s,e,i)}parseAndRender(t,e,i){return he(this,void 0,void 0,(function*(){return ce(this._parseAndRender(t,e,Object.assign(Object.assign({},i),{sync:!1})))}))}parseAndRenderSync(t,e,i){return de(this._parseAndRender(t,e,Object.assign(Object.assign({},i),{sync:!0})))}_parsePartialFile(t,e,i){return new Yi(this).parseFile(t,e,qi.Partials,i)}_parseLayoutFile(t,e,i){return new Yi(this).parseFile(t,e,qi.Layouts,i)}_parseFile(t,e,i,s){return new Yi(this).parseFile(t,e,i,s)}parseFile(t,e){return he(this,void 0,void 0,(function*(){return ce(new Yi(this).parseFile(t,!1,e))}))}parseFileSync(t,e){return de(new Yi(this).parseFile(t,!0,e))}*_renderFile(t,e,i){const s=yield this._parseFile(t,i.sync,i.lookupType);return yield this._render(s,e,i)}renderFile(t,e,i){return he(this,void 0,void 0,(function*(){return ce(this._renderFile(t,e,Object.assign(Object.assign({},i),{sync:!1})))}))}renderFileSync(t,e,i){return de(this._renderFile(t,e,Object.assign(Object.assign({},i),{sync:!0})))}renderFileToNodeStream(t,e,i){return he(this,void 0,void 0,(function*(){const s=yield this.parseFile(t);return this.renderToNodeStream(s,e,i)}))}_evalValue(t,e){const i=new Di(t,this),s=e instanceof os?e:new os(e,this.options);return i.value(s)}evalValue(t,e){return he(this,void 0,void 0,(function*(){return ce(this._evalValue(t,e))}))}evalValueSync(t,e){return de(this._evalValue(t,e))}registerFilter(t,e){this.filters[t]=e}registerTag(t,e){var i;this.tags[t]=pt(e)?e:(i=e,class extends Ci{constructor(t,e,s){super(t,e,s),pt(i.parse)&&i.parse.call(this,t,e)}*render(t,e){const s=yield new Ei(this.token.args,t.opts.keyValueSeparator).render(t);return yield i.render.call(this,t,e,s)}})}plugin(t){return t.call(this,Ws)}express(){const t=this;let e=!0;return function(i,s,n){if(e){e=!1;const i=xi(this.root);t.options.root.unshift(...i),t.options.layouts.unshift(...i),t.options.partials.unshift(...i)}t.renderFile(i,s).then((t=>n(null,t)),n)}}analyze(t,e={}){return he(this,void 0,void 0,(function*(){return Bi(t,e)}))}analyzeSync(t,e={}){return zi(t,e)}parseAndAnalyze(t,e,i={}){return he(this,void 0,void 0,(function*(){return Bi(this.parse(t,e),i)}))}parseAndAnalyzeSync(t,e,i={}){return zi(this.parse(t,e),i)}variables(t,e={}){return he(this,void 0,void 0,(function*(){const i=yield Bi(ut(t)?this.parse(t):t,e);return Object.keys(i.variables)}))}variablesSync(t,e={}){const i=zi(ut(t)?this.parse(t):t,e);return Object.keys(i.variables)}fullVariables(t,e={}){return he(this,void 0,void 0,(function*(){const i=yield Bi(ut(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.variables).flatMap((t=>t.map((t=>String(t)))))))}))}fullVariablesSync(t,e={}){const i=zi(ut(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.variables).flatMap((t=>t.map((t=>String(t)))))))}variableSegments(t,e={}){return he(this,void 0,void 0,(function*(){const i=yield Bi(ut(t)?this.parse(t):t,e);return Array.from(Nt(Object.values(i.variables).flatMap((t=>t.map((t=>t.toArray()))))))}))}variableSegmentsSync(t,e={}){const i=zi(ut(t)?this.parse(t):t,e);return Array.from(Nt(Object.values(i.variables).flatMap((t=>t.map((t=>t.toArray()))))))}globalVariables(t,e={}){return he(this,void 0,void 0,(function*(){const i=yield Bi(ut(t)?this.parse(t):t,e);return Object.keys(i.globals)}))}globalVariablesSync(t,e={}){const i=zi(ut(t)?this.parse(t):t,e);return Object.keys(i.globals)}globalFullVariables(t,e={}){return he(this,void 0,void 0,(function*(){const i=yield Bi(ut(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.globals).flatMap((t=>t.map((t=>String(t)))))))}))}globalFullVariablesSync(t,e={}){const i=zi(ut(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.globals).flatMap((t=>t.map((t=>String(t)))))))}globalVariableSegments(t,e={}){return he(this,void 0,void 0,(function*(){const i=yield Bi(ut(t)?this.parse(t):t,e);return Array.from(Nt(Object.values(i.globals).flatMap((t=>t.map((t=>t.toArray()))))))}))}globalVariableSegmentsSync(t,e={}){const i=zi(ut(t)?this.parse(t):t,e);return Array.from(Nt(Object.values(i.globals).flatMap((t=>t.map((t=>t.toArray()))))))}}const Ks={render:function(t,e){const i=r("v-icon"),s=r("v-list-item-icon"),n=r("v-text-overflow"),a=r("v-list-item-content"),u=r("v-list-item"),p=r("v-list");return o(),l(p,{nav:""},{default:h((()=>[c(u,{href:"https://app.texttoanything.nl/"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"open_in_new"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Text to anything dashboard"})])),_:1})])),_:1}),c(u,{to:"/tta_settings/templates"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"code"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Templates"})])),_:1})])),_:1}),c(u,{to:"/tta_settings/flowsLogExplorer"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"short_text"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Flows log explorer"})])),_:1})])),_:1}),c(u,{to:"/tta_settings/settings"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"settings"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Settings"})])),_:1})])),_:1}),d(' <v-list-item to="/tta_settings/usage">\n <v-list-item-icon><v-icon name="bar_chart" /></v-list-item-icon>\n <v-list-item-content>\n <v-text-overflow text="Usage" />\n </v-list-item-content>\n </v-list-item> ')])),_:1})},__file:"settingsmodule/src/TTAnav.vue"},Xs=t=>(f("data-v-4a16637c"),t=t(),m(),t),Ys={key:0,class:"popover"},Qs=Xs((()=>v("br",null,null,-1))),Js=Xs((()=>v("ul",null,[v("li",null,"HTML - preview as webpage"),v("li",null,"PDF (Preview) - watermarked, free"),v("li",null,"PDF - final version, without watermark"),v("li",null,"Code - preview without test input")],-1)));var Zs={__name:"explainPreviewMode",props:{text:{type:String,required:!0}},setup(t){const e=u(!1);return(t,i)=>{const s=r("v-icon");return o(),p("div",{class:"info-popover",onMouseenter:i[0]||(i[0]=t=>e.value=!0),onMouseleave:i[1]||(i[1]=t=>e.value=!1)},[c(s,{name:"question_mark",class:"info-icon"}),e.value?(o(),p("div",Ys,[g(" The preview mode has 4 modes: "),Qs,Js])):d("v-if",!0)],32)}}},tn=[],en=[];function sn(t,e){if(t&&"undefined"!=typeof document){var i,s=!0===e.prepend?"prepend":"append",n=!0===e.singleTag,a="string"==typeof e.container?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(n){var r=tn.indexOf(a);-1===r&&(r=tn.push(a)-1,en[r]={}),i=en[r]&&en[r][s]?en[r][s]:en[r][s]=o()}else i=o();65279===t.charCodeAt(0)&&(t=t.substring(1)),i.styleSheet?i.styleSheet.cssText+=t:i.appendChild(document.createTextNode(t))}function o(){var t=document.createElement("style");if(t.setAttribute("type","text/css"),e.attributes)for(var i=Object.keys(e.attributes),n=0;n<i.length;n++)t.setAttribute(i[n],e.attributes[i[n]]);var r="prepend"===s?"afterbegin":"beforeend";return a.insertAdjacentElement(r,t),t}}sn("\n.info-popover[data-v-4a16637c] {\n position: relative;\n display: flex;\n color: var(--theme--foreground-subdued);\n}\n.info-icon[data-v-4a16637c] {\n margin: auto;\n}\n.popover[data-v-4a16637c] {\n position: absolute;\n top: 175%;\n left: 50%;\n transform: translateX(-50%);\n background-color: var(--theme--background);\n color: var(--theme--foreground);\n border: 1px solid var(--theme--border);\n padding: 0.5rem;\n border-radius: 4px;\n white-space: nowrap;\n z-index: 1000;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n}\n",{}),Zs.__scopeId="data-v-4a16637c",Zs.__file="settingsmodule/src/pages/templates/explainPreviewMode.vue";const nn=v("div",{class:"field half"},[v("div",{class:"type-label"},"Template name")],-1),an=v("div",{class:"field half"},[v("div",{class:"type-label"},"Description")],-1),rn=v("div",{class:"field half"},[v("div",{class:"type-label"},"Format")],-1),on=v("div",{class:"field half"},[v("div",{class:"type-label"},"Orientation")],-1),ln={key:0,class:"TTA-popup"},hn={class:"TTA-toolbar"},cn={class:"right-side"},dn={class:"setwidth"},un={class:"TTA-action"},pn={class:"TTA-wapper"},gn={class:"devFields"},fn={id:"partSelect"},mn=["src","srcDoc"],vn={class:"tta-notice"},bn=v("a",{href:"https://app.texttoanything.nl",target:"_blank"},"TTA app",-1);var yn=b({__name:"templates",setup(t){const{useCollectionsStore:s,useFlowsStore:n,useNotificationsStore:a}=e(),f=n(),m=a(),b=y((()=>f.flows.filter((t=>"webhook"===t.trigger&&"POST"==t.options.method)).map((t=>({text:t.name,value:t.id}))))),M=u([]),P=u(!1),D=u(!1),I=u("Development"),R=u("html"),L=u(""),F=u(!1),N=u(),O=u(50),B=y((()=>100-O.value)),z=y((()=>100-B.value)),j=u("");function V(t){"Header"==I.value?G.value.header=t:"Body"==I.value?G.value.template=t:G.value.footer=t}function H(t){"Fixed"==G.value.input_type?G.value.input_fixed=t:G.value.input_flow_body=t}w((()=>I.value),(t=>{"Development"==t&&(j.value=""),"Header"==t&&(j.value=G.value.header),"Body"==t&&(j.value=G.value.template),"Footer"==t&&(j.value=G.value.footer)}),{immediate:!0});const $=i(),U={template:"<h1>Hello {{name}}!</h1>",id:-1,name:"",description:"",collection:"",format:"A4",orientation:"portrait",header:"\x3c!-- Any content/styling here is seperated from the body on render--\x3e\n<style> \n #header, #footer { \n margin: 0 !important; \n padding: 0 !important; \n font-size: 9px; \n -webkit-print-color-adjust: exact;\n }\n</style>\n<div style='width:100%'>\n <span class='date'></span>\n <span class='title' style='float:right'></span>\n</div>",footer:"\x3c!-- Any content/styling here is seperated from the body on render--\x3e\n<style> \n #header, #footer { \n margin: 0 !important; \n padding: 0 !important; \n font-size: 9px; -webkit-print-color-adjust: exact;\n }\n</style>\n<div\n style=‘width:100%’>\n <div style=‘float:right’><span\n class='pageNumber'></span> / <span class='totalPages'></span>\n </div>\n</div>",input_type:"Fixed",input_fixed:'{"name": "World!"}',input_flow:"",input_flow_body:"{}"},G=u(structuredClone(U)),q=new Ws;async function W(t){if("Flow"==G.value.input_type&&!G.value.input_flow)return;L.value="rendering";let e={};try{if("Flow"==G.value.input_type){const t=await $.post("/flows/trigger/"+G.value.input_flow,JSON.parse(G.value.input_flow_body));if("object"!=typeof t.data)throw new Error("Output of flow should be an object, not an "+typeof t.data);if("name"in t.data&&"code"in t.data&&"status"in t.data)throw new Error(JSON.stringify(t.data));e=t.data}else null==G.value.input_fixed&&(G.value.input_fixed="{}"),e=JSON.parse(G.value.input_fixed);if("html"==t||"code"==t){const i=(G.value.header||"")+(G.value.template||"")+(G.value.footer||""),s=new Blob(['<style>\n .date:before{content: "Date here";font-style: italic; }\n .title:before{content: "Title here";font-style: italic; }\n .pageNumber:before{content: "Pagenumber";font-style: italic; }\n .totalPages:before{content: "Total pages";font-style: italic; }\n </style>'+("code"==t?i:await q.render(q.parse(i),e))],{type:"text/html"});L.value=URL.createObjectURL(s)}else{const t=q.parse(G.value.header||""),i=q.parse(G.value.template),s=q.parse(G.value.footer||""),n=await q.render(t,e),a=await q.render(i,e),r=await q.render(s,e),o=await fetch("/tta/pdf?preview="+("pdf-preview"==R.value?"preview":""),{body:JSON.stringify({...G.value,input_fixed:void 0,input_flow:void 0,input_flow_body:void 0,input_type:void 0,id:void 0,header:n,html:a,footer:r,landscape:"portrait"!=G.value.orientation}),method:"POST",headers:{"Content-Type":"application/json"}}).then((t=>t.blob())).then((t=>URL.createObjectURL(t)));L.value=o}}catch(t){console.error(t),m.add({title:"Error while generating PDF",text:"Please check your console/terminal for the error.",type:"error",dialog:!0}),L.value=URL.createObjectURL(new Blob(["Error occurred: "+((null==t?void 0:t.message)||t)],{type:"text/html"}))}}async function K(){const t=await $.get("/items/TTA_htmltemplates",{params:{limit:-1}});M.value=t.data.data}async function X(){-1==G.value.id?await $.post("/items/TTA_htmltemplates",{...G.value,id:void 0}):await $.patch("/items/TTA_htmltemplates/"+G.value.id,{...G.value,id:void 0}),P.value=!1,K()}async function Y(){await $.delete("/items/TTA_htmltemplates/"+N.value),M.value=M.value.filter((t=>t.id!=N.value)),F.value=!1}function Q({item:t}){G.value=t,D.value=!0}function J(){G.value=structuredClone(U),D.value=!1}function Z(){G.value.template=rt(G.value.template),G.value.footer=rt(G.value.footer),G.value.header=rt(G.value.header)}return w((()=>G.value.id),((t,e)=>{t!=e&&(I.value="",x((()=>{I.value="Body"})))})),w((()=>[G.value.header,G.value.template,G.value.footer,G.value.input_type,G.value.input_flow,G.value.input_fixed,R.value]),(()=>{["html","code"].includes(R.value)&&W(R.value)}),{deep:!0,immediate:!0}),A((async()=>{O.value=parseInt(localStorage.getItem("TTA-widthPartition")||"50"),K()})),w((()=>O.value),(t=>localStorage.setItem("TTA-widthPartition",t+""))),(t,e)=>{const i=r("v-icon"),s=r("v-button"),n=r("v-card-title"),a=r("v-input"),u=r("v-list-item-content"),f=r("v-list-item"),m=r("v-select"),y=r("v-list"),w=r("v-card-text"),x=r("v-card-actions"),A=r("v-card"),$=r("v-dialog"),U=r("VSelect"),q=r("v-slider"),K=r("VButton"),tt=r("VIcon"),et=r("v-table"),it=r("VNotice"),st=r("private-view");return o(),l(st,{title:"Offline templates"},{navigation:h((()=>[c(Ks)])),actions:h((()=>[c(s,{rounded:"",icon:"",onClick:e[0]||(e[0]=t=>P.value=!0)},{default:h((()=>[c(i,{name:"add"})])),_:1}),c($,{modelValue:P.value,"onUpdate:modelValue":e[6]||(e[6]=t=>P.value=t),persistent:!0},{default:h((()=>[c(A,null,{default:h((()=>[c(n,null,{default:h((()=>[g("Create a new HTML template")])),_:1}),c(w,null,{default:h((()=>[c(y,null,{default:h((()=>[c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[nn,c(a,{modelValue:G.value.name,"onUpdate:modelValue":e[1]||(e[1]=t=>G.value.name=t),placeholder:"Template name"},null,8,["modelValue"])])),_:1})])),_:1}),c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[an,c(a,{modelValue:G.value.description,"onUpdate:modelValue":e[2]||(e[2]=t=>G.value.description=t),placeholder:"Description"},null,8,["modelValue"])])),_:1})])),_:1}),c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[rn,c(m,{modelValue:G.value.format,"onUpdate:modelValue":e[3]||(e[3]=t=>G.value.format=t),placeholder:"Size",items:["A1","A2","A3","A4","A5","A6","Letter","Legal","Tabloid","Ledger"].map((t=>({text:t,value:t})))},null,8,["modelValue","items"])])),_:1})])),_:1}),c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[on,c(m,{modelValue:G.value.orientation,"onUpdate:modelValue":e[4]||(e[4]=t=>G.value.orientation=t),placeholder:"Orientation",items:["portrait","landscape"].map((t=>({text:t,value:t})))},null,8,["modelValue","items"])])),_:1})])),_:1})])),_:1})])),_:1}),c(x,null,{default:h((()=>[c(s,{secondary:"",onClick:e[5]||(e[5]=t=>P.value=!1)},{default:h((()=>[g(" Cancel ")])),_:1}),c(s,{disabled:!G.value.collection||!G.value.name||!G.value.format,onClick:X},{default:h((()=>[g(" Save ")])),_:1},8,["disabled"])])),_:1})])),_:1})])),_:1},8,["modelValue"])])),default:h((()=>[D.value?(o(),p("div",ln,[v("div",hn,[v("div",{onClick:e[7]||(e[7]=t=>P.value=!0),class:"TTA-template-title"},[g(_(G.value.name)+" ",1),c(i,{name:"edit"})]),v("div",cn,[c(U,{modelValue:R.value,"onUpdate:modelValue":e[8]||(e[8]=t=>R.value=t),items:[{text:"HTML",value:"html"},{text:"PDF (Preview)",value:"pdf-preview"},{text:"PDF",value:"pdf"},{text:"Code",value:"code"}],style:{width:"170px"}},null,8,["modelValue","items"]),c(Zs,{text:"This is helpful info."}),v("div",{class:"TTA-action",onClick:Z},[c(i,{name:"vertical_align_center"})]),v("div",{class:"TTA-action",onClick:X},[c(i,{name:"save"})]),v("div",dn,[c(q,{modelValue:O.value,"onUpdate:modelValue":e[9]||(e[9]=t=>O.value=t),min:10,max:90,class:"TTA-slider"},null,8,["modelValue"])]),v("div",un,[c(i,{name:"close",onClick:J})])])]),v("div",pn,[v("div",{style:S("width: "+T(z)+"%"),class:"TTA-editor-wrapper"},["Development"==I.value?(o(),p(k,{key:0},[v("div",gn,[c(m,{modelValue:G.value.input_type,"onUpdate:modelValue":e[10]||(e[10]=t=>G.value.input_type=t),class:"max-w-input",items:[{value:"Flow",text:"Flow"},{value:"Fixed",text:"Fixed"}]},null,8,["modelValue"]),"Flow"==G.value.input_type?(o(),l(m,{key:0,modelValue:G.value.input_flow,"onUpdate:modelValue":e[11]||(e[11]=t=>G.value.input_flow=t),class:"max-w-input",items:T(b)},null,8,["modelValue","items"])):d("v-if",!0)]),"Fixed"==G.value.input_type?(o(),l(C("interface-input-code"),{key:0,class:"TTA-editor",value:G.value.input_fixed,language:"json",onInput:H},null,40,["value"])):d("v-if",!0),"Flow"==G.value.input_type?(o(),l(C("interface-input-code"),{key:1,class:"TTA-editor",value:G.value.input_flow_body,language:"json",onInput:H},null,40,["value"])):d("v-if",!0)],64)):d("v-if",!0),"Development"!=I.value?(o(),l(C("interface-input-code"),{key:1,class:"TTA-editor",value:j.value,language:"htmlmixed",onInput:V},null,40,["value"])):d("v-if",!0),v("div",fn,[c(m,{modelValue:I.value,"onUpdate:modelValue":e[12]||(e[12]=t=>I.value=t),items:[{value:"Header",text:"Header"},{value:"Body",text:"Body"},{value:"Footer",text:"Footer"},{value:"Development",text:"Test input"}]},null,8,["modelValue"])])],4),v("iframe",{class:"TTA-preview",src:"rendering"==L.value?void 0:L.value,srcDoc:"rendering"==L.value?T('\n <html>\n <head>\n <style>\n body {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100vh;\n margin: 0;\n font-family: sans-serif;\n background: #f9f9f9;\n }\n .spinner {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n .loader {\n border: 6px solid #f3f3f3;\n border-top: 6px solid #3498db;\n border-radius: 50%;\n width: 40px;\n height: 40px;\n animation: spin 1s linear infinite;\n margin-bottom: 10px;\n }\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n </style>\n </head>\n <body>\n <div class="spinner">\n <div class="loader"></div>\n <div>Loading...</div>\n </div>\n </body>\n </html>'):void 0,style:S("width: "+T(B)+"%")},null,12,mn),R.value.startsWith("pdf")?(o(),l(K,{key:0,onClick:e[13]||(e[13]=t=>{W("pdf")}),icon:!0,outlined:!1,id:"generatePDF"},{default:h((()=>[c(i,{name:"refresh"})])),_:1})):d("v-if",!0)])])):d("v-if",!0),c(et,{headers:[{text:"Name",value:"name",sortable:!1},{text:"Description",value:"description",width:600,sortable:!1},{text:"Format",value:"format",sortable:!1},{text:"",value:"del",width:60,sortable:!1}],"onClick:row":Q,items:M.value},{"item.del":h((({item:t})=>[c(K,{onClick:E((e=>{return i=t.id,N.value=i,void(F.value=!0);var i}),["stop"]),outlined:!0,icon:!0,rounded:!0},{default:h((()=>[c(tt,{name:"delete"})])),_:2},1032,["onClick"])])),_:1},8,["items"]),v("div",vn,[c(it,null,{default:h((()=>[g(" You can create online templates in the "),bn,g(" for a better editor experience. ")])),_:1})]),c($,{modelValue:F.value,"onUpdate:modelValue":e[15]||(e[15]=t=>F.value=t),persistent:!0},{default:h((()=>[c(A,null,{default:h((()=>[c(n,null,{default:h((()=>[g(" Are you sure you want to delete this item? This action can not be undone. ")])),_:1}),c(x,null,{default:h((()=>[c(s,{secondary:"",onClick:e[14]||(e[14]=t=>F.value=!1)},{default:h((()=>[g(" Cancel ")])),_:1}),c(s,{kind:"danger",onClick:Y},{default:h((()=>[g(" Proceed ")])),_:1})])),_:1})])),_:1})])),_:1},8,["modelValue"])])),_:1})}}});sn("\n.TTA-popup {\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n z-index: 100;\n display: flex;\n flex-direction: column;\n background-color: var(--theme--form--field--input--background-subdued);\n}\n.TTA-toolbar {\n background-color: var(--theme--form--field--input--background-subdued);\n display: flex;\n justify-content: space-between;\n}\n.TTA-toolbar .right-side {\n display: flex;\n align-items: center;\n gap: 5px;\n}\n.TTA-toolbar .TTA-slider {\n padding-top: 5px;\n}\n.TTA-toolbar .TTA-action {\n padding: 5px;\n cursor: pointer;\n}\n.TTA-toolbar .setwidth {\n display: flex;\n gap: 10px;\n padding-top: 6px;\n}\n.TTA-toolbar .TTA-template-title {\n margin: auto 0;\n font-size: 18px;\n cursor: pointer;\n padding-right: 5px;\n padding-left: 20px;\n border-bottom: 1px solid var(--v-list-item-border-color);\n}\n.TTA-toolbar .TTA-template-title i {\n padding-left: 5px;\n}\n.TTA-wapper {\n display: flex;\n flex-grow: 1;\n overflow: hidden;\n position: relative;\n}\n.TTA-preview {\n flex-grow: 1;\n background-color: white;\n border: 0;\n}\n.TTA-editor {\n flex-grow: 1;\n height: 100%;\n width: 100%;\n max-height: calc(100vh - 130px);\n}\n.TTA-wapper .TTA-editor-wrapper {\n position: relative;\n}\n.TTA-editor > div {\n height: 100% !important;\n border-radius: 0 !important;\n}\n.TTA-editor .CodeMirror {\n height: 100%;\n}\n.TTA-wapper #partSelect {\n position: absolute;\n right: 0;\n top: 0;\n width: 200px;\n}\n.devFields {\n border-top: var(--theme--border-width) solid\n var(--theme--form--field--input--border-color);\n margin-left: 25px;\n margin-bottom: 10px;\n}\n.max-w-input {\n max-width: 250px;\n padding: 10px 0;\n}\n.max-w-input .v-input {\n max-width: 250px;\n margin-bottom: 5px;\n}\n#generatePDF {\n position: fixed;\n top: 69px;\n right: 10px;\n}\n.tta-notice {\n padding: 10px;\n}\n",{}),yn.__file="settingsmodule/src/pages/templates.vue";var wn=b({__name:"virusscanDialog",setup(t){const e=i(),s=u([]),n=u(!1);A((async()=>{const t=await e.get("/folders");s.value=t.data.data.map((t=>({name:t.name,id:t.id,scanning:1==t.TTA_VIRUSSCAN_ENABLED})))}));const a=y((()=>s.value.filter((t=>1==t.scanning)).length));return(t,i)=>{const l=r("VNotice"),d=r("v-button"),u=r("v-table"),f=r("v-drawer"),m=r("v-icon");return o(),p(k,null,[c(f,{modelValue:n.value,"onUpdate:modelValue":i[0]||(i[0]=t=>n.value=t),persistent:!0,placement:"right",title:"Manage folders that are scanned for virusses",onCancel:i[1]||(i[1]=t=>n.value=!1),icon:"settings"},{default:h((()=>[c(l,null,{default:h((()=>[g(" Any uploads to the enabled folders will be scanned. ")])),_:1}),c(u,{headers:[{text:"",value:"enabled"},{text:"Name",value:"name"}],items:s.value},{"item.enabled":h((({item:t})=>[c(d,{onClick:i=>async function(t){t.scanning=!t.scanning,await e.patch("/folders/"+t.id,{TTA_VIRUSSCAN_ENABLED:t.scanning})}(t),small:"",danger:!t.scanning},{default:h((()=>[g(_(t.scanning?"Enabled":"Disabled"),1)])),_:2},1032,["onClick","danger"])])),_:1},8,["items"])])),_:1},8,["modelValue"]),c(d,{align:"left",fullWidth:"",small:"",onClick:i[2]||(i[2]=t=>n.value=!0)},{default:h((()=>[c(m,{name:"edit"}),T(a)==s.value.length?(o(),p(k,{key:0},[g(" All ")],64)):(o(),p(k,{key:1},[g(_(T(a))+"/"+_(s.value.length),1)],64)),g(" folders are being scanned ")])),_:1})],64)}}});wn.__file="settingsmodule/src/pages/settings/virusscanDialog.vue";const xn=t=>(f("data-v-7f9dbb3b"),t=t(),m(),t),An={class:"cards-wrapper"},_n=xn((()=>v("span",{class:"field-name"},"RapidAPI token",-1))),Sn=xn((()=>v("span",{class:"field-name"},"RapidAPI virusscanner token",-1))),Tn={class:"field-name info-parent"},kn=xn((()=>v("div",null,[g(" What should happen when a virus is detected? "),v("ul",null,[v("li",null," Delete threads, threads will be deleted immediately "),v("li",null," Trigger flow, the selected flow will be triggered with upload payload ")]),v("div",null," The trigger flow option is ideal for when you want to send a notification or add extra logic. The trigger flow option will not automaticly delete the file. ")],-1))),Cn={key:0},En={class:"field-name info-parent"};var Mn=b({__name:"settings",setup(t){const s=u(""),n=u(""),a=u(!1),f=u(""),m=u(""),b=u(""),w=i(),{useFlowsStore:x}=e(),_=x(),S=y((()=>_.flows.map((t=>({text:t.name,value:t.id})))));async function C(){M({TTA_KEY:s.value,TTA_KEY_VIRUS:n.value},"apikeys")}async function E(){M({TTA_VIRUSSCANNER_ENABLED:a.value,TTA_VIRUSSCANNER_MODE:f.value,TTA_VIRUSSCANNER_FLOW_ID:m.value},"virus")}async function M(t,e){b.value=e,await w.patch("/settings",t),setTimeout((()=>{b.value=""}),500)}return A((async()=>{const t=await w.get("/settings");s.value=t.data.data.TTA_KEY,n.value=t.data.data.TTA_KEY_VIRUS,m.value=t.data.data.TTA_VIRUSSCANNER_FLOW_ID,a.value=1==t.data.data.TTA_VIRUSSCANNER_ENABLED||!1,f.value=t.data.data.TTA_VIRUSSCANNER_MODE||"workflow"})),(t,e)=>{const i=r("v-card-title"),u=r("v-input"),y=r("v-card-text"),w=r("v-icon"),x=r("v-button"),A=r("v-progress-circular"),_=r("v-card-actions"),M=r("v-card"),P=r("VCheckbox"),D=r("VIcon"),I=r("VNotice"),R=r("v-hover"),L=r("v-select"),F=r("private-view");return o(),l(F,{title:"Settings"},{navigation:h((()=>[c(Ks)])),default:h((()=>[v("div",An,[c(M,{class:"w-full"},{default:h((()=>[c(i,null,{default:h((()=>[g("API settings")])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[v("div",null,[_n,c(u,{modelValue:s.value,"onUpdate:modelValue":e[0]||(e[0]=t=>s.value=t)},null,8,["modelValue"])])])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[c(x,{href:"https://rapidapi.com/Attacler/api/text-to-anything",target:"_blank",align:"left",fullWidth:"",small:""},{default:h((()=>[c(w,{name:"open_in_new"}),g(" Get RapidAPI token ")])),_:1})])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[v("div",null,[Sn,c(u,{modelValue:n.value,"onUpdate:modelValue":e[1]||(e[1]=t=>n.value=t)},null,8,["modelValue"])])])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[c(x,{href:"https://rapidapi.com/Attacler/api/virusscan-texttoanything/",target:"_blank",align:"left",fullWidth:"",small:""},{default:h((()=>[c(w,{name:"open_in_new"}),g(" Get RapidAPI virusscanner token ")])),_:1})])),_:1}),c(_,{class:"action-buttons"},{default:h((()=>[c(x,{onClick:C,disabled:"apikeys"==b.value,id:"save-button"},{default:h((()=>["apikeys"!=b.value?(o(),p(k,{key:0},[g(" Save ")],64)):(o(),l(A,{key:1,small:!0,indeterminate:""}))])),_:1},8,["disabled"])])),_:1})])),_:1}),c(M,{class:"w-full"},{default:h((()=>[c(i,null,{default:h((()=>[g("Virusscanner settings")])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[v("div",null,[c(P,{modelValue:a.value,"onUpdate:modelValue":e[2]||(e[2]=t=>a.value=t),value:!1},{default:h((()=>[g(" Automatic scanning ")])),_:1},8,["modelValue"])])])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[v("div",null,[v("div",Tn,[g(" Mode "),c(R,null,{default:h((({hover:t})=>[c(D,{name:"info"}),t?(o(),l(I,{key:0,class:"info-popup"},{default:h((()=>[kn])),_:1})):d("v-if",!0)])),_:1})]),c(L,{modelValue:f.value,"onUpdate:modelValue":e[3]||(e[3]=t=>f.value=t),items:[{text:"Delete threats",value:"delete"},{text:"Trigger flow",value:"flow"}]},null,8,["modelValue"])]),"flow"==f.value?(o(),p("div",Cn,[v("div",En,[g(" Flow "),c(R,null,{default:h((({hover:t})=>[c(D,{name:"info"}),t?(o(),l(I,{key:0,class:"info-popup"},{default:h((()=>[g(" This flow will be triggered once a virus has been detected. ")])),_:1})):d("v-if",!0)])),_:1})]),c(L,{items:T(S),showDeselect:"",modelValue:m.value,"onUpdate:modelValue":e[4]||(e[4]=t=>m.value=t)},null,8,["items","modelValue"])])):d("v-if",!0)])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[c(wn)])),_:1}),c(y,{class:"fields-spacing"},{default:h((()=>[c(x,{href:"https://texttoanything.nl/docs/directus/virusscanner",target:"_blank",align:"left",fullWidth:"",small:""},{default:h((()=>[c(w,{name:"open_in_new"}),g(" Virusscanner documentation ")])),_:1})])),_:1}),c(_,{class:"action-buttons"},{default:h((()=>[c(x,{onClick:E,disabled:"virus"==b.value,id:"save-button"},{default:h((()=>["virus"!=b.value?(o(),p(k,{key:0},[g(" Save ")],64)):(o(),l(A,{key:1,small:!0,indeterminate:""}))])),_:1},8,["disabled"])])),_:1})])),_:1})])])),_:1})}}});sn("\n.w-full[data-v-7f9dbb3b] {\n width: 100%;\n}\n.cards-wrapper[data-v-7f9dbb3b] {\n padding: 0 2.5rem;\n display: flex;\n flex-wrap: wrap;\n gap: 2.5rem;\n}\n.fields-spacing[data-v-7f9dbb3b] {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n#save-button[data-v-7f9dbb3b] {\n margin-left: auto;\n}\n.info-parent[data-v-7f9dbb3b] {\n position: relative;\n display: flex;\n gap: 5px;\n}\n.info-parent .info-popup[data-v-7f9dbb3b] {\n position: absolute;\n top: 25px;\n left: 0;\n z-index: 10;\n}\n",{}),Mn.__scopeId="data-v-7f9dbb3b",Mn.__file="settingsmodule/src/pages/settings.vue";var Pn=b({__name:"dateTimePicker",props:{value:{type:[String,null],required:!0}},setup(t,{emit:e}){const i=t,s=u(),n=u(i.value);const a=y((()=>function(t){const e=new Date(t||-1);return e instanceof Date&&!isNaN(e.getTime())&&1970!=e.getFullYear()}(null==n?void 0:n.value)));return w((()=>n.value),(()=>{a.value&&(console.log(" Updating with",n.value),e("update:modelValue",n.value))})),(t,e)=>{const i=r("v-input"),l=r("v-date-picker"),d=r("v-menu");return o(),p("div",null,[c(d,{ref_key:"dateTimeMenu",ref:s,"close-on-content-click":!1,attached:"","full-height":"",seamless:""},{activator:h((({toggle:t,active:e})=>[c(i,{active:e,clickable:"",readonly:"",placeholder:T(a)?void 0:n.value,onClick:t},M({_:2},[T(a)?{name:"prepend",fn:h((()=>[g(_(n.value),1)])),key:"0"}:void 0]),1032,["active","placeholder","onClick"])])),default:h((()=>{var t;return[c(l,{type:"date","use-24":!0,"include-seconds":!1,"model-value":n.value,"onUpdate:modelValue":e[0]||(e[0]=t=>n.value=t),onClose:null==(t=s.value)?void 0:t.deactivate},null,8,["model-value","onClose"])]})),_:1},512)])}}});sn("\n.v-icon.today-icon[data-v-42405105]:hover,\n.v-icon.today-icon.active[data-v-42405105] {\n --v-icon-color: var(--theme--primary);\n}\n.v-icon.clear-icon[data-v-42405105]:hover,\n.v-icon.clear-icon.active[data-v-42405105] {\n --v-icon-color: var(--theme--danger);\n}\n",{}),Pn.__scopeId="data-v-42405105",Pn.__file="settingsmodule/src/components/dateTimePicker.vue";var Dn={d:(t,e)=>{for(var i in e)Dn.o(e,i)&&!Dn.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},In={};function Rn(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,s=new Array(e);i<e;i++)s[i]=t[i];return s}function Ln(t,e){if(t){if("string"==typeof t)return Rn(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Rn(t,e):void 0}}function Fn(t){return function(t){if(Array.isArray(t))return Rn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ln(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nn(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Dn.d(In,{Z:()=>ta});const On=(Vn={computed:()=>a.computed,createTextVNode:()=>a.createTextVNode,createVNode:()=>a.createVNode,defineComponent:()=>a.defineComponent,reactive:()=>a.reactive,ref:()=>a.ref,watch:()=>a.watch,watchEffect:()=>a.watchEffect},Hn={},Dn.d(Hn,Vn),Hn),Bn=(0,On.defineComponent)({props:{data:{required:!0,type:String},onClick:Function},render:function(){var t=this.data,e=this.onClick;return(0,On.createVNode)("span",{class:"vjs-tree-brackets",onClick:e},[t])}}),zn=(0,On.defineComponent)({emits:["change","update:modelValue"],props:{checked:{type:Boolean,default:!1},isMultiple:Boolean,onChange:Function},setup:function(t,e){var i=e.emit;return{uiType:(0,On.computed)((function(){return t.isMultiple?"checkbox":"radio"})),model:(0,On.computed)({get:function(){return t.checked},set:function(t){return i("update:modelValue",t)}})}},render:function(){var t=this.uiType,e=this.model,i=this.$emit;return(0,On.createVNode)("label",{class:["vjs-check-controller",e?"is-checked":""],onClick:function(t){return t.stopPropagation()}},[(0,On.createVNode)("span",{class:"vjs-check-controller-inner is-".concat(t)},null),(0,On.createVNode)("input",{checked:e,class:"vjs-check-controller-original is-".concat(t),type:t,onChange:function(){return i("change",e)}},null)])}}),jn=(0,On.defineComponent)({props:{nodeType:{required:!0,type:String},onClick:Function},render:function(){var t=this.nodeType,e=this.onClick,i="objectStart"===t||"arrayStart"===t;return i||"objectCollapsed"===t||"arrayCollapsed"===t?(0,On.createVNode)("span",{class:"vjs-carets vjs-carets-".concat(i?"open":"close"),onClick:e},[(0,On.createVNode)("svg",{viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true"},[(0,On.createVNode)("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"},null)])]):null}});var Vn,Hn;function $n(t){return $n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$n(t)}function Un(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function Gn(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"root",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=(arguments.length>3?arguments[3]:void 0)||{},n=s.key,a=s.index,r=s.type,o=void 0===r?"content":r,l=s.showComma,h=void 0!==l&&l,c=s.length,d=void 0===c?1:c,u=Un(t);if("array"===u){var p=qn(t.map((function(t,s,n){return Gn(t,"".concat(e,"[").concat(s,"]"),i+1,{index:s,showComma:s!==n.length-1,length:d,type:o})})));return[Gn("[",e,i,{showComma:!1,key:n,length:t.length,type:"arrayStart"})[0]].concat(p,Gn("]",e,i,{showComma:h,length:t.length,type:"arrayEnd"})[0])}if("object"===u){var g=Object.keys(t),f=qn(g.map((function(s,n,a){return Gn(t[s],/^[a-zA-Z_]\w*$/.test(s)?"".concat(e,".").concat(s):"".concat(e,'["').concat(s,'"]'),i+1,{key:s,showComma:n!==a.length-1,length:d,type:o})})));return[Gn("{",e,i,{showComma:!1,key:n,index:a,length:g.length,type:"objectStart"})[0]].concat(f,Gn("}",e,i,{showComma:h,length:g.length,type:"objectEnd"})[0])}return[{content:t,level:i,key:n,index:a,path:e,showComma:h,length:d,type:o}]}function qn(t){if("function"==typeof Array.prototype.flat)return t.flat();for(var e=Fn(t),i=[];e.length;){var s=e.shift();Array.isArray(s)?e.unshift.apply(e,Fn(s)):i.push(s)}return i}function Wn(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if(null==t)return t;if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if("object"!==$n(t))return t;if(e.get(t))return e.get(t);if(Array.isArray(t)){var i=t.map((function(t){return Wn(t,e)}));return e.set(t,i),i}var s={};for(var n in t)s[n]=Wn(t[n],e);return e.set(t,s),s}function Kn(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function Xn(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Kn(Object(i),!0).forEach((function(e){Nn(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Kn(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}var Yn={showLength:{type:Boolean,default:!1},showDoubleQuotes:{type:Boolean,default:!0},renderNodeKey:Function,renderNodeValue:Function,selectableType:String,showSelectController:{type:Boolean,default:!1},showLine:{type:Boolean,default:!0},showLineNumber:{type:Boolean,default:!1},selectOnClickNode:{type:Boolean,default:!0},nodeSelectable:{type:Function,default:function(){return!0}},highlightSelectedNode:{type:Boolean,default:!0},showIcon:{type:Boolean,default:!1},theme:{type:String,default:"light"},showKeyValueSpace:{type:Boolean,default:!0},editable:{type:Boolean,default:!1},editableTrigger:{type:String,default:"click"},onNodeClick:{type:Function},onBracketsClick:{type:Function},onIconClick:{type:Function},onValueChange:{type:Function}};const Qn=(0,On.defineComponent)({name:"TreeNode",props:Xn(Xn({},Yn),{},{node:{type:Object,required:!0},collapsed:Boolean,checked:Boolean,style:Object,onSelectedChange:{type:Function}}),emits:["nodeClick","bracketsClick","iconClick","selectedChange","valueChange"],setup:function(t,e){var i=e.emit,s=(0,On.computed)((function(){return Un(t.node.content)})),n=(0,On.computed)((function(){return"vjs-value vjs-value-".concat(s.value)})),a=(0,On.computed)((function(){return t.showDoubleQuotes?'"'.concat(t.node.key,'"'):t.node.key})),r=(0,On.computed)((function(){return"multiple"===t.selectableType})),o=(0,On.computed)((function(){return"single"===t.selectableType})),l=(0,On.computed)((function(){return t.nodeSelectable(t.node)&&(r.value||o.value)})),h=(0,On.reactive)({editing:!1}),c=function(e){var s,n,a="null"===(n=null===(s=e.target)||void 0===s?void 0:s.value)?null:"undefined"===n?void 0:"true"===n||"false"!==n&&(n[0]+n[n.length-1]==='""'||n[0]+n[n.length-1]==="''"?n.slice(1,-1):"number"==typeof Number(n)&&!isNaN(Number(n))||"NaN"===n?Number(n):n);i("valueChange",a,t.node.path)},d=(0,On.computed)((function(){var e,i=null===(e=t.node)||void 0===e?void 0:e.content;return null===i?i="null":void 0===i&&(i="undefined"),"string"===s.value?'"'.concat(i,'"'):i+""})),u=function(){var e=t.renderNodeValue;return e?e({node:t.node,defaultValue:d.value}):d.value},p=function(){i("bracketsClick",!t.collapsed,t.node)},g=function(){i("iconClick",!t.collapsed,t.node)},f=function(){i("selectedChange",t.node)},m=function(){i("nodeClick",t.node),l.value&&t.selectOnClickNode&&i("selectedChange",t.node)},v=function(e){if(t.editable&&!h.editing){h.editing=!0;var i=function t(i){var s;i.target!==e.target&&(null===(s=i.target)||void 0===s?void 0:s.parentElement)!==e.target&&(h.editing=!1,document.removeEventListener("click",t))};document.removeEventListener("click",i),document.addEventListener("click",i)}};return function(){var e,i=t.node;return(0,On.createVNode)("div",{class:{"vjs-tree-node":!0,"has-selector":t.showSelectController,"has-carets":t.showIcon,"is-highlight":t.highlightSelectedNode&&t.checked,dark:"dark"===t.theme},onClick:m,style:t.style},[t.showLineNumber&&(0,On.createVNode)("span",{class:"vjs-node-index"},[i.id+1]),t.showSelectController&&l.value&&"objectEnd"!==i.type&&"arrayEnd"!==i.type&&(0,On.createVNode)(zn,{isMultiple:r.value,checked:t.checked,onChange:f},null),(0,On.createVNode)("div",{class:"vjs-indent"},[Array.from(Array(i.level)).map((function(e,i){return(0,On.createVNode)("div",{key:i,class:{"vjs-indent-unit":!0,"has-line":t.showLine}},null)})),t.showIcon&&(0,On.createVNode)(jn,{nodeType:i.type,onClick:g},null)]),i.key&&(0,On.createVNode)("span",{class:"vjs-key"},[(e=t.renderNodeKey,e?e({node:t.node,defaultKey:a.value||""}):a.value),(0,On.createVNode)("span",{class:"vjs-colon"},[":".concat(t.showKeyValueSpace?" ":"")])]),(0,On.createVNode)("span",null,["content"!==i.type&&i.content?(0,On.createVNode)(Bn,{data:i.content.toString(),onClick:p},null):(0,On.createVNode)("span",{class:n.value,onClick:!t.editable||t.editableTrigger&&"click"!==t.editableTrigger?void 0:v,onDblclick:t.editable&&"dblclick"===t.editableTrigger?v:void 0},[t.editable&&h.editing?(0,On.createVNode)("input",{value:d.value,onChange:c,style:{padding:"3px 8px",border:"1px solid #eee",boxShadow:"none",boxSizing:"border-box",borderRadius:5,fontFamily:"inherit"}},null):u()]),i.showComma&&(0,On.createVNode)("span",null,[","]),t.showLength&&t.collapsed&&(0,On.createVNode)("span",{class:"vjs-comment"},[(0,On.createTextVNode)(" // "),i.length,(0,On.createTextVNode)(" items ")])])])}}});function Jn(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function Zn(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Jn(Object(i),!0).forEach((function(e){Nn(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Jn(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}const ta=(0,On.defineComponent)({name:"Tree",props:Zn(Zn({},Yn),{},{data:{type:[String,Number,Boolean,Array,Object],default:null},collapsedNodeLength:{type:Number,default:1/0},deep:{type:Number,default:1/0},pathCollapsible:{type:Function,default:function(){return!1}},rootPath:{type:String,default:"root"},virtual:{type:Boolean,default:!1},height:{type:Number,default:400},itemHeight:{type:Number,default:20},selectedValue:{type:[String,Array],default:function(){return""}},collapsedOnClickBrackets:{type:Boolean,default:!0},style:Object,onSelectedChange:{type:Function},theme:{type:String,default:"light"}}),slots:["renderNodeKey","renderNodeValue"],emits:["nodeClick","bracketsClick","iconClick","selectedChange","update:selectedValue","update:data"],setup:function(t,e){var i=e.emit,s=e.slots,n=(0,On.ref)(),a=(0,On.computed)((function(){return Gn(t.data,t.rootPath)})),r=function(e,i){return a.value.reduce((function(s,n){var a,r=n.level>=e||n.length>=i,o=null===(a=t.pathCollapsible)||void 0===a?void 0:a.call(t,n);return"objectStart"!==n.type&&"arrayStart"!==n.type||!r&&!o?s:Zn(Zn({},s),{},Nn({},n.path,1))}),{})},o=(0,On.reactive)({translateY:0,visibleData:null,hiddenPaths:r(t.deep,t.collapsedNodeLength)}),l=(0,On.computed)((function(){for(var t=null,e=[],i=a.value.length,s=0;s<i;s++){var n=Zn(Zn({},a.value[s]),{},{id:s}),r=o.hiddenPaths[n.path];if(t&&t.path===n.path){var l="objectStart"===t.type,h=Zn(Zn(Zn({},n),t),{},{showComma:n.showComma,content:l?"{...}":"[...]",type:l?"objectCollapsed":"arrayCollapsed"});t=null,e.push(h)}else{if(r&&!t){t=n;continue}if(t)continue;e.push(n)}}return e})),h=(0,On.computed)((function(){var e=t.selectedValue;return e&&"multiple"===t.selectableType&&Array.isArray(e)?e:[e]})),c=(0,On.computed)((function(){return!t.selectableType||t.selectOnClickNode||t.showSelectController?"":"When selectableType is not null, selectOnClickNode and showSelectController cannot be false at the same time, because this will cause the selection to fail."})),d=function(){var e=l.value;if(t.virtual){var i,s=t.height/t.itemHeight,a=(null===(i=n.value)||void 0===i?void 0:i.scrollTop)||0,r=Math.floor(a/t.itemHeight),h=r<0?0:r+s>e.length?e.length-s:r;h<0&&(h=0);var c=h+s;o.translateY=h*t.itemHeight,o.visibleData=e.filter((function(t,e){return e>=h&&e<c}))}else o.visibleData=e},u=function(){d()},p=function(e){var s,n=e.path,a=t.selectableType;if("multiple"===a){var r=h.value.findIndex((function(t){return t===n})),o=Fn(h.value);-1!==r?o.splice(r,1):o.push(n),i("update:selectedValue",o),i("selectedChange",o,Fn(h.value))}else if("single"===a&&h.value[0]!==n){var l=(s=h.value,function(t){if(Array.isArray(t))return t}(s)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var i,s,n=[],a=!0,r=!1;try{for(e=e.call(t);!(a=(i=e.next()).done)&&(n.push(i.value),1!==n.length);a=!0);}catch(t){r=!0,s=t}finally{try{a||null==e.return||e.return()}finally{if(r)throw s}}return n}}(s)||Ln(s,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],c=n;i("update:selectedValue",c),i("selectedChange",c,l)}},g=function(t){i("nodeClick",t)},f=function(t,e){if(t)o.hiddenPaths=Zn(Zn({},o.hiddenPaths),{},Nn({},e,1));else{var i=Zn({},o.hiddenPaths);delete i[e],o.hiddenPaths=i}},m=function(e,s){t.collapsedOnClickBrackets&&f(e,s.path),i("bracketsClick",e,s)},v=function(t,e){f(t,e.path),i("iconClick",t,e)},b=function(e,s){var n=Wn(t.data),a=t.rootPath;new Function("data","val","data".concat(s.slice(a.length),"=val"))(n,e),i("update:data",n)};return(0,On.watchEffect)((function(){c.value&&function(t){throw new Error("[VueJSONPretty] ".concat(t))}(c.value)})),(0,On.watchEffect)((function(){l.value&&d()})),(0,On.watch)((function(){return t.deep}),(function(e){e&&(o.hiddenPaths=r(e,t.collapsedNodeLength))})),(0,On.watch)((function(){return t.collapsedNodeLength}),(function(e){e&&(o.hiddenPaths=r(t.deep,e))})),function(){var e,i,r=null!==(e=t.renderNodeKey)&&void 0!==e?e:s.renderNodeKey,c=null!==(i=t.renderNodeValue)&&void 0!==i?i:s.renderNodeValue,d=o.visibleData&&o.visibleData.map((function(e){return(0,On.createVNode)(Qn,{key:e.id,node:e,collapsed:!!o.hiddenPaths[e.path],theme:t.theme,showDoubleQuotes:t.showDoubleQuotes,showLength:t.showLength,checked:h.value.includes(e.path),selectableType:t.selectableType,showLine:t.showLine,showLineNumber:t.showLineNumber,showSelectController:t.showSelectController,selectOnClickNode:t.selectOnClickNode,nodeSelectable:t.nodeSelectable,highlightSelectedNode:t.highlightSelectedNode,editable:t.editable,editableTrigger:t.editableTrigger,showIcon:t.showIcon,showKeyValueSpace:t.showKeyValueSpace,renderNodeKey:r,renderNodeValue:c,onNodeClick:g,onBracketsClick:m,onIconClick:v,onSelectedChange:p,onValueChange:b,style:t.itemHeight&&20!==t.itemHeight?{lineHeight:"".concat(t.itemHeight,"px")}:{}},null)}));return(0,On.createVNode)("div",{ref:n,class:{"vjs-tree":!0,"is-virtual":t.virtual,dark:"dark"===t.theme},onScroll:t.virtual?u:void 0,style:t.showLineNumber?Zn({paddingLeft:"".concat(12*Number(a.value.length.toString().length),"px")},t.style):t.style},[t.virtual?(0,On.createVNode)("div",{class:"vjs-tree-list",style:{height:"".concat(t.height,"px")}},[(0,On.createVNode)("div",{class:"vjs-tree-list-holder",style:{height:"".concat(l.value.length*t.itemHeight,"px")}},[(0,On.createVNode)("div",{class:"vjs-tree-list-holder-inner",style:{transform:"translateY(".concat(o.translateY,"px)")}},[d])])]):d])}}});var ea=In.Z;sn('.vjs-tree-brackets{cursor:pointer}.vjs-tree-brackets:hover{color:#1890ff}.vjs-check-controller{position:absolute;left:0}.vjs-check-controller.is-checked .vjs-check-controller-inner{background-color:#1890ff;border-color:#0076e4}.vjs-check-controller.is-checked .vjs-check-controller-inner.is-checkbox:after{transform:rotate(45deg) scaleY(1)}.vjs-check-controller.is-checked .vjs-check-controller-inner.is-radio:after{transform:translate(-50%,-50%) scale(1)}.vjs-check-controller .vjs-check-controller-inner{display:inline-block;position:relative;border:1px solid #bfcbd9;border-radius:2px;vertical-align:middle;box-sizing:border-box;width:16px;height:16px;background-color:#fff;z-index:1;cursor:pointer;transition:border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46)}.vjs-check-controller .vjs-check-controller-inner:after{box-sizing:content-box;content:"";border:2px solid #fff;border-left:0;border-top:0;height:8px;left:4px;position:absolute;top:1px;transform:rotate(45deg) scaleY(0);width:4px;transition:transform .15s cubic-bezier(.71,-.46,.88,.6) .05s;transform-origin:center}.vjs-check-controller .vjs-check-controller-inner.is-radio{border-radius:100%}.vjs-check-controller .vjs-check-controller-inner.is-radio:after{border-radius:100%;height:4px;background-color:#fff;left:50%;top:50%}.vjs-check-controller .vjs-check-controller-original{opacity:0;outline:none;position:absolute;z-index:-1;top:0;left:0;right:0;bottom:0;margin:0}.vjs-carets{position:absolute;right:0;cursor:pointer}.vjs-carets svg{transition:transform .3s}.vjs-carets:hover{color:#1890ff}.vjs-carets-close{transform:rotate(-90deg)}.vjs-tree-node{display:flex;position:relative;line-height:20px}.vjs-tree-node.has-carets{padding-left:15px}.vjs-tree-node.has-carets.has-selector,.vjs-tree-node.has-selector{padding-left:30px}.vjs-tree-node.is-highlight,.vjs-tree-node:hover{background-color:#e6f7ff}.vjs-tree-node .vjs-indent{display:flex;position:relative}.vjs-tree-node .vjs-indent-unit{width:1em}.vjs-tree-node .vjs-indent-unit.has-line{border-left:1px dashed #bfcbd9}.vjs-tree-node.dark.is-highlight,.vjs-tree-node.dark:hover{background-color:#2e4558}.vjs-node-index{position:absolute;right:100%;margin-right:4px;user-select:none}.vjs-colon{white-space:pre}.vjs-comment{color:#bfcbd9}.vjs-value{word-break:break-word}.vjs-value-null,.vjs-value-undefined{color:#d55fde}.vjs-value-boolean,.vjs-value-number{color:#1d8ce0}.vjs-value-string{color:#13ce66}.vjs-tree{font-family:Monaco,Menlo,Consolas,Bitstream Vera Sans Mono,monospace;font-size:14px;text-align:left}.vjs-tree.is-virtual{overflow:auto}.vjs-tree.is-virtual .vjs-tree-node{white-space:nowrap}',{});const ia=t=>(f("data-v-2ded8f93"),t=t(),m(),t),sa={class:"content"},na=ia((()=>v("div",{class:"header"},[v("span",{class:"dot success"}),v("span",{class:"type-label"}," Trigger ")],-1))),aa={class:"inset"},ra={class:"steps"},oa={class:"header"},la={class:"type-label"},ha={class:"subdued"},ca={class:"inset"};var da=b({__name:"displayFlowLogs",props:{currentLog:{type:null,required:!0}},setup(t,{emit:e}){const{currentLog:i}=t,s=u(""),n=y((()=>{const{data:t}=i;if(!t)return[];return((null==t?void 0:t.steps)||[]).map((e=>({...e,status:"resolve"===e.status?"success":"error",operationType:e.operationType||"",options:e.options?e.options:null,data:t.data[e.key]?t.data[e.key]:null})))}));function a(t,e){console.log(i),s.value=t+e.path.substring(4)}function f(){navigator.clipboard.writeText(s.value)}return(i,u)=>{const m=r("v-icon"),b=r("v-button"),y=r("v-detail"),w=r("v-drawer"),x=P("tooltip");return o(),l(w,{modelValue:!0,title:"Flow log",icon:"fact_check",onEsc:u[1]||(u[1]=t=>e("close")),onCancel:u[2]||(u[2]=t=>e("close"))},{actions:h((()=>[s.value?(o(),l(b,{key:0,class:"ml-auto",onClick:f},{default:h((()=>[g(_(s.value)+" ",1),c(m,{name:"copy_all"})])),_:1})):d("v-if",!0)])),default:h((()=>[v("div",sa,[na,v("div",aa,[c(y,{label:"Payload",class:"payload"},{default:h((()=>[c(T(ea),{data:t.currentLog.data.data.$trigger,virtual:"",onNodeClick:u[0]||(u[0]=t=>a("$trigger",t)),selectableType:"single"},null,8,["data"])])),_:1})]),v("div",ra,[(o(!0),p(k,null,D(T(n),(t=>(o(),p("div",{key:t.id,class:"step"},[v("div",oa,[v("span",{class:I(["dot",t.status])},null,2),R((o(),p("span",la,[g(_(t.key)+" ",1),v("span",ha," "+_(t.operationType),1)])),[[x,t.key]])]),v("div",ca,[t.options?(o(),l(y,{key:0,label:"Options"},{default:h((()=>[c(T(ea),{data:t.options,virtual:""},null,8,["data"])])),_:2},1024)):d("v-if",!0),null!==t.data?(o(),l(y,{key:1,label:"Payload",class:"payload"},{default:h((()=>[c(T(ea),{data:t.data,virtual:"",onNodeClick:e=>a(t.key,e),selectableType:"single"},null,8,["data","onNodeClick"])])),_:2},1024)):d("v-if",!0)])])))),128))])])])),_:1})}}});sn("\n.content[data-v-2ded8f93] {\n padding: 1rem;\n}\n.header[data-v-2ded8f93] {\n font-size: 1.2rem;\n font-weight: bold;\n}\n.dot[data-v-2ded8f93] {\n width: 0.75rem;\n height: 0.75rem;\n border-radius: 50%;\n margin-right: 0.5rem;\n display: inline-block;\n}\n.dot.success[data-v-2ded8f93] {\n background-color: var(--primary);\n}\n.dot.error[data-v-2ded8f93] {\n background-color: var(--red);\n}\n.step[data-v-2ded8f93] {\n margin: 0.5rem 0;\n position: relative;\n}\n.inset[data-v-2ded8f93] {\n border-left: var(--theme--border-width) solid\n var(--theme--border-color-subdued);\n margin-left: 0.35rem;\n padding-top: 5px;\n padding-left: 1rem;\n margin-top: -5px;\n}\n",{});sn("\n.payload .vjs-value,\n.payload .vjs-key {\n cursor: pointer;\n}\n",{}),da.__scopeId="data-v-2ded8f93",da.__file="settingsmodule/src/components/displayFlowLogs.vue";const ua=t=>(f("data-v-231dc418"),t=t(),m(),t),pa={class:"px-5 w-full"},ga=["title"],fa=["title"],ma={class:"filters"},va=ua((()=>v("h2",null,"Filter",-1))),ba=ua((()=>v("div",{class:"field-name"},"Flow",-1))),ya=ua((()=>v("div",{class:"field-name"},"From date",-1))),wa=ua((()=>v("div",{class:"field-name"},"To date",-1))),xa=ua((()=>v("div",{class:"field-name"},"Sorting order",-1)));var Aa=b({__name:"flowLogsExplorer",setup(t){const{useFlowsStore:s}=e(),n=i(),a=s(),p=u(),f=u([]),m=u(),b=u(),w=u(""),x=u("all"),S=u(),k=u("Descending");async function C(){const t=await n.get("/revisions",{params:{"filter[_and][0][collection][_eq]":"directus_flows","filter[_and][1][item][_eq]":p.value||void 0,"filter[_and][2][version][_null]":!0,"filter[_and][3][activity][action][_eq]":"run","filter[_and][4][activity][timestamp][_gte]":m.value?m.value:void 0,"filter[_and][4][activity][timestamp][_lte]":b.value?b.value+"T23:59:59":void 0,"fields[0]":"*","fields[1]":"activity.*",limit:2e3,sort:"Descending"==k.value?["-activity.timestamp"]:["activity.timestamp"]}});f.value=t.data.data}A((()=>{const t=new Date;t.setDate(t.getDate()-7),m.value=t.toISOString().split("T")[0],b.value=(new Date).toISOString().split("T")[0]}));const E=y((()=>{if(!w.value&&"all"==x.value)return f.value;let t=f.value;return"all"!=x.value&&(t=t.filter((t=>t.data.steps[t.data.steps.length-1].status==("error"==x.value?"reject":"resolve")))),w.value&&(t=f.value.filter((t=>{const e=t.data.data.$trigger;return JSON.stringify(e).toLowerCase().includes(w.value.toLowerCase())}))),t})),M=y((()=>a.flows.map((t=>({text:t.name,value:t.id})))));function P(t){var e;if(0==t.data.steps.length)return"";const i=null==(e=t.data.steps[t.data.steps.length-1])?void 0:e.key;return i?t.data.data[i]:""}function D(t){S.value=t.item}function R(t){if(0==t.data.steps.length)return!1;return"resolve"!=t.data.steps[t.data.steps.length-1].status}return(t,e)=>{const i=r("v-icon"),s=r("v-table"),n=r("v-select"),a=r("v-button"),u=r("v-input"),f=r("VSelect"),y=r("private-view");return o(),l(y,{title:"Flow logs explorer"},{navigation:h((()=>[c(Ks)])),sidebar:h((()=>[v("div",ma,[va,v("div",null,[ba,c(n,{items:T(M),showDeselect:"",modelValue:p.value,"onUpdate:modelValue":e[0]||(e[0]=t=>p.value=t)},null,8,["items","modelValue"])]),v("div",null,[ya,m.value?(o(),l(Pn,{key:0,modelValue:m.value,"onUpdate:modelValue":e[1]||(e[1]=t=>m.value=t),value:m.value},null,8,["modelValue","value"])):d("v-if",!0)]),v("div",null,[wa,b.value?(o(),l(Pn,{key:0,modelValue:b.value,"onUpdate:modelValue":e[2]||(e[2]=t=>b.value=t),value:b.value},null,8,["modelValue","value"])):d("v-if",!0)]),v("div",null,[xa,c(n,{modelValue:k.value,"onUpdate:modelValue":e[3]||(e[3]=t=>k.value=t),items:["Descending","Ascending"]},null,8,["modelValue"])]),c(a,{onClick:C,fullWidth:!0},{default:h((()=>[g("Search")])),_:1}),v("div",null,[g(" Input filter "),c(u,{modelValue:w.value,"onUpdate:modelValue":e[4]||(e[4]=t=>w.value=t),placeholder:"Input filter",class:"w-full"},null,8,["modelValue"])]),v("div",null,[g(" Status "),c(f,{modelValue:x.value,"onUpdate:modelValue":e[5]||(e[5]=t=>x.value=t),items:[{text:"All",value:"all"},{text:"Error",value:"error"},{text:"Success",value:"success"}]},null,8,["modelValue"])])]),S.value?(o(),l(da,{key:0,onClose:e[6]||(e[6]=t=>S.value=null),currentLog:S.value},null,8,["currentLog"])):d("v-if",!0)])),default:h((()=>[v("div",pa,[c(s,{headers:[{text:"Status",value:"status",sortable:!1,width:100},{text:"Timestamp",value:"timestamp",sortable:!1,width:100},{text:"Input",value:"input",sortable:!1,width:1e3},{text:"Output",value:"output",sortable:!1,width:1e3}],items:T(E),"onClick:row":D},{"item.status":h((({item:t})=>[c(i,{name:R(t)?"error":"check_circle",class:I(["flowLogStatus",{error:R(t),success:!R(t)}])},null,8,["name","class"])])),"item.timestamp":h((({item:t})=>[g(_(new Date(t.activity.timestamp).toLocaleDateString()),1)])),"item.input":h((({item:t})=>[v("div",{title:JSON.stringify(t.data.data.$trigger,null,2)},_(t.data.data.$trigger),9,ga)])),"item.output":h((({item:t})=>[v("div",{title:JSON.stringify(P(t),null,2)},_(P(t)),9,fa)])),_:1},8,["items"])])])),_:1})}}});sn("\n.w-full[data-v-231dc418] {\n width: 100%;\n}\n.px-5[data-v-231dc418] {\n padding: 0 2.5rem;\n}\n.date-input[data-v-231dc418] {\n min-width: 300px;\n}\n.filters[data-v-231dc418] {\n padding: 10px 5px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.filters h2[data-v-231dc418] {\n font-size: 1.5rem;\n font-weight: bold;\n}\n.grow[data-v-231dc418],\n.grow button[data-v-231dc418] {\n flex-grow: 1;\n}\n.flowLogStatus.success[data-v-231dc418] {\n color: var(--primary);\n}\n.flowLogStatus.error[data-v-231dc418] {\n color: var(--red);\n}\n",{}),Aa.__scopeId="data-v-231dc418",Aa.__file="settingsmodule/src/pages/flowLogsExplorer.vue";var _a=s({id:"tta_settings",name:"Text to anything settings",icon:"text_fields",routes:[{path:"",redirect:"/tta_settings/templates"},{path:"templates",component:yn},{path:"settings",component:Mn},{path:"flowsLogExplorer",component:Aa}]}),Sa=b({__name:"interface",props:["value"],emits:["input"],setup(t,{emit:e}){const i=t,s=L("api"),n=u(0),a=u([]);return A((async()=>{w((()=>n.value),((t,i)=>{t!=i&&e("input",t)}));const t=await s.get("/tta/pdf/onlineTemplates");a.value=t.data.map((t=>({text:t.name,value:t.id}))),t.data.find((t=>t.id==i.value))?n.value=parseInt(i.value):n.value=null})),(t,e)=>{const i=r("v-select");return o(),l(i,{modelValue:n.value,"onUpdate:modelValue":e[0]||(e[0]=t=>n.value=t),items:a.value},null,8,["modelValue","items"])}}});Sa.__file="pdf/PDFOnlineTemplateSelector/src/interface.vue";var Ta=n({id:"TTA-pdf-online-template-selector",name:"PDF online template selector",icon:"picture_as_pdf",description:"Selector for an online PDF template for Text To Anything",component:Sa,options:null,types:["string"]}),ka=b({__name:"interface",props:["value"],emits:["input"],setup(t,{emit:e}){const i=t,s=L("api"),n=u(""),a=u([]);return A((async()=>{w((()=>n.value),((t,i)=>{t!=i&&e("input",t)}));const t=await s.get("/items/TTA_htmltemplates");a.value=t.data.data.map((t=>({text:t.name,value:t.id}))),n.value=i.value})),(t,e)=>{const i=r("v-select");return o(),l(i,{modelValue:n.value,"onUpdate:modelValue":e[0]||(e[0]=t=>n.value=t),items:a.value},null,8,["modelValue","items"])}}});ka.__file="pdf/PDFTemplateSelector/src/interface.vue";var Ca=n({id:"TTA-pdf-template-selector",name:"PDF template selector",icon:"picture_as_pdf",description:"Selector for a PDF template for Text To Anything",component:ka,options:null,types:["string"]}),Ea=b({__name:"interface",props:{label:{type:String,required:!0},flow:{type:null,required:!0},primaryKey:{type:null,required:!0}},setup(t){const e=t,s=i(),n=u(!1);async function a(){n.value=!0;try{const t=await s.post("/flows/trigger/"+e.flow,{id:e.primaryKey});window.open("/assets/"+t.data,"_blank")}catch(t){}n.value=!1}return(t,i)=>{const s=r("v-button");return o(),l(s,{onClick:a,loading:n.value,disabled:n.value},{default:h((()=>[g(_(e.label),1)])),_:1},8,["loading","disabled"])}}});Ea.__file="pdf/GeneratePDFFromTemplateInterface/src/interface.vue";var Ma=n({id:"tta-download-interface",name:"Download interface",icon:"sim_card_download",description:"Download files based on a flow. (Text to anything)",hideLabel:!0,hideLoader:!0,component:Ea,options:()=>{const{useFlowsStore:t}=e(),i=t();return[{field:"label",type:"string",name:"$t:label",meta:{width:"full",interface:"system-input-translated-string",options:{placeholder:"$t:label"}}},{field:"flow",name:"$t:operations.trigger.flow",type:"string",meta:{width:"full",interface:"select-dropdown",options:{choices:y((()=>i.flows.filter((t=>"webhook"===t.trigger&&"POST"==t.options.method)).map((t=>({text:t.name,value:t.id}))))),iconRight:"bolt",placeholder:"$t:a_flow_uuid"}}}]},types:["string"]});
|
|
1
|
+
import{defineOperationApp as t,useStores as e,useApi as i,defineModule as s,defineInterface as n}from"@directus/extensions-sdk";import*as a from"vue";import{resolveComponent as r,openBlock as o,createBlock as l,withCtx as h,createVNode as c,createCommentVNode as d,ref as u,createElementBlock as p,createTextVNode as g,pushScopeId as f,popScopeId as _,createElementVNode as m,defineComponent as v,computed as b,watch as y,nextTick as w,onMounted as x,toDisplayString as A,normalizeStyle as k,unref as T,Fragment as S,resolveDynamicComponent as E,withModifiers as C,createSlots as R,resolveDirective as M,renderList as P,normalizeClass as L,withDirectives as D,inject as I,onBeforeUnmount as O,reactive as N,onUnmounted as F,Teleport as B,renderSlot as j}from"vue";var z,V=t({id:"ttabarcode",name:"TTA generate barcode",icon:"barcode",description:"Generate a barcode trough Text to anything!",overview:({barcodeContent:t})=>[{label:"barcode content",text:t}],options:[{field:"barcodeContent",name:"content",type:"string",meta:{width:"full",interface:"input"}},{field:"barcodeType",name:"type",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:["auspost","azteccode","azteccodecompact","aztecrune","bc412","channelcode","codablockf","code11","code128","code16k","code2of5","code32","code39","code39ext","code49","code93","code93ext","codeone","coop2of5","daft","databarexpanded","databarexpandedcomposite","databarexpandedstacked","databarexpandedstackedcomposite","databarlimited","databarlimitedcomposite","databaromni","databaromnicomposite","databarstacked","databarstackedcomposite","databarstackedomni","databarstackedomnicomposite","databartruncated","databartruncatedcomposite","datalogic2of5","datamatrix","datamatrixrectangular","datamatrixrectangularextension","dotcode","ean13","ean13composite","ean14","ean2","ean5","ean8","ean8composite","flattermarken","gs1-128","gs1-128composite","gs1-cc","gs1datamatrix","gs1datamatrixrectangular","gs1dldatamatrix","gs1dlqrcode","gs1dotcode","gs1northamericancoupon","gs1qrcode","hanxin","hibcazteccode","hibccodablockf","hibccode128","hibccode39","hibcdatamatrix","hibcdatamatrixrectangular","hibcmicropdf417","hibcpdf417","hibcqrcode","iata2of5","identcode","industrial2of5","interleaved2of5","isbn","ismn","issn","itf14","japanpost","kix","leitcode","mailmark","mands","matrix2of5","maxicode","micropdf417","microqrcode","msi","onecode","pdf417","pdf417compact","pharmacode","pharmacode2","planet","plessey","posicode","postnet","pzn","qrcode","rationalizedCodabar","raw","rectangularmicroqrcode","royalmail","sscc18","swissqrcode","symbol","telepen","telepennumeric","ultracode","upca","upcacomposite","upce","upcecomposite"].map((t=>({text:t,value:t})))}}},{field:"scale",name:"scale",type:"number",meta:{width:"full",interface:"input"}},{field:"height",name:"height",type:"number",meta:{width:"full",interface:"input"}},{field:"includetext",name:"include text",type:"boolean",meta:{width:"full",interface:"boolean"}}]}),U=t({id:"ttapdf",name:"TTA generate PDF",icon:"picture_as_pdf",description:"Generate a PDF trough Text to anything!",overview:({filename:t})=>[{label:"File name",text:t}],options:[{field:"filename",name:"File name",type:"string",meta:{width:"full",interface:"input"}},{field:"pdfoptions",name:"Options",type:"json",meta:{width:"full",interface:"input-code",options:{language:"json",placeholder:JSON.stringify({html:"<h1>Hello world!</h1>",format:"A4",landscape:!1,margin:10,marginRight:5,marginLeft:5},null,2),template:JSON.stringify({html:"<h1>Hello world!</h1>",format:"A4",landscape:!1,margin:10,marginRight:5,marginLeft:5},null,2)}}}]}),H=t({id:"ttapdftemplate",name:"TTA generate PDF from template",icon:"picture_as_pdf",description:"Generate a PDF based on a template trough Text to anything!",overview:({filename:t})=>[{label:"File name",text:t}],options:t=>[{field:"filename",name:"File name",type:"string",meta:{width:"full",interface:"input"}},{field:"mode",name:"Template source",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:[{value:"online",text:"TTA Dashboard"},{value:"offline",text:"Directus"}]},note:"When selecting 'TTA Dashboard', you will be able to select a template from the TextToAnything dashboard. (https://app.texttoanything.nl)"}},{field:"template",name:"Template",type:"string",meta:{interface:"online"==t.mode?"TTA-pdf-online-template-selector":"TTA-pdf-template-selector",options:{}}},{field:"templatevariables",name:"Template variables",type:"json",meta:{width:"full",interface:"input-code",options:{language:"json"}}}]}),$=t({id:"ttaqrcode",name:"TTA generate QRcode",icon:"qr_code",description:"Generate a QRcode trough Text to anything!",overview:({content:t})=>[{label:"QRCode content",text:t}],options:[{field:"content",name:"QRCode content",type:"string",meta:{width:"full",interface:"input"}},{field:"lightColor",name:"Light color",type:"string",meta:{width:"full",interface:"select-color"}},{field:"darkColor",name:"Dark color",type:"string",meta:{width:"full",interface:"select-color"}},{field:"margin",name:"Margin",type:"integer",meta:{width:"half",interface:"input"}},{field:"width",name:"Width",type:"integer",meta:{width:"half",interface:"input"}}]}),W={exports:{}},G={},q={exports:{}},K={},X={};function Y(){if(z)return X;function t(t){this.__parent=t,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}function e(t,e){this.__cache=[""],this.__indent_size=t.indent_size,this.__indent_string=t.indent_char,t.indent_with_tabs||(this.__indent_string=new Array(t.indent_size+1).join(t.indent_char)),e=e||"",t.indent_level>0&&(e=new Array(t.indent_level+1).join(this.__indent_string)),this.__base_string=e,this.__base_string_length=e.length}function i(i,s){this.__indent_cache=new e(i,s),this.raw=!1,this._end_with_newline=i.end_with_newline,this.indent_size=i.indent_size,this.wrap_line_length=i.wrap_line_length,this.indent_empty_lines=i.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new t(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}return z=1,t.prototype.clone_empty=function(){var e=new t(this.__parent);return e.set_indent(this.__indent_count,this.__alignment_count),e},t.prototype.item=function(t){return t<0?this.__items[this.__items.length+t]:this.__items[t]},t.prototype.has_match=function(t){for(var e=this.__items.length-1;e>=0;e--)if(this.__items[e].match(t))return!0;return!1},t.prototype.set_indent=function(t,e){this.is_empty()&&(this.__indent_count=t||0,this.__alignment_count=e||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},t.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},t.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},t.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var t=this.__parent.current_line;return t.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),t.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),t.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===t.__items[0]&&(t.__items.splice(0,1),t.__character_count-=1),!0}return!1},t.prototype.is_empty=function(){return 0===this.__items.length},t.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},t.prototype.push=function(t){this.__items.push(t);var e=t.lastIndexOf("\n");-1!==e?this.__character_count=t.length-e:this.__character_count+=t.length},t.prototype.pop=function(){var t=null;return this.is_empty()||(t=this.__items.pop(),this.__character_count-=t.length),t},t.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},t.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},t.prototype.trim=function(){for(;" "===this.last();)this.__items.pop(),this.__character_count-=1},t.prototype.toString=function(){var t="";return this.is_empty()?this.__parent.indent_empty_lines&&(t=this.__parent.get_indent_string(this.__indent_count)):(t=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),t+=this.__items.join("")),t},e.prototype.get_indent_size=function(t,e){var i=this.__base_string_length;return e=e||0,t<0&&(i=0),i+=t*this.__indent_size,i+=e},e.prototype.get_indent_string=function(t,e){var i=this.__base_string;return e=e||0,t<0&&(t=0,i=""),e+=t*this.__indent_size,this.__ensure_cache(e),i+=this.__cache[e]},e.prototype.__ensure_cache=function(t){for(;t>=this.__cache.length;)this.__add_column()},e.prototype.__add_column=function(){var t=this.__cache.length,e=0,i="";this.__indent_size&&t>=this.__indent_size&&(t-=(e=Math.floor(t/this.__indent_size))*this.__indent_size,i=new Array(e+1).join(this.__indent_string)),t&&(i+=new Array(t+1).join(" ")),this.__cache.push(i)},i.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},i.prototype.get_line_number=function(){return this.__lines.length},i.prototype.get_indent_string=function(t,e){return this.__indent_cache.get_indent_string(t,e)},i.prototype.get_indent_size=function(t,e){return this.__indent_cache.get_indent_size(t,e)},i.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},i.prototype.add_new_line=function(t){return!(this.is_empty()||!t&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},i.prototype.get_code=function(t){this.trim(!0);var e=this.current_line.pop();e&&("\n"===e[e.length-1]&&(e=e.replace(/\n+$/g,"")),this.current_line.push(e)),this._end_with_newline&&this.__add_outputline();var i=this.__lines.join("\n");return"\n"!==t&&(i=i.replace(/[\n]/g,t)),i},i.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},i.prototype.set_indent=function(t,e){return t=t||0,e=e||0,this.next_line.set_indent(t,e),this.__lines.length>1?(this.current_line.set_indent(t,e),!0):(this.current_line.set_indent(),!1)},i.prototype.add_raw_token=function(t){for(var e=0;e<t.newlines;e++)this.__add_outputline();this.current_line.set_indent(-1),this.current_line.push(t.whitespace_before),this.current_line.push(t.text),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1},i.prototype.add_token=function(t){this.__add_space_before_token(),this.current_line.push(t),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=this.current_line._allow_wrap()},i.prototype.__add_space_before_token=function(){this.space_before_token&&!this.just_added_newline()&&(this.non_breaking_space||this.set_wrap_point(),this.current_line.push(" "))},i.prototype.remove_indent=function(t){for(var e=this.__lines.length;t<e;)this.__lines[t]._remove_indent(),t++;this.current_line._remove_wrap_indent()},i.prototype.trim=function(t){for(t=void 0!==t&&t,this.current_line.trim();t&&this.__lines.length>1&&this.current_line.is_empty();)this.__lines.pop(),this.current_line=this.__lines[this.__lines.length-1],this.current_line.trim();this.previous_line=this.__lines.length>1?this.__lines[this.__lines.length-2]:null},i.prototype.just_added_newline=function(){return this.current_line.is_empty()},i.prototype.just_added_blankline=function(){return this.is_empty()||this.current_line.is_empty()&&this.previous_line.is_empty()},i.prototype.ensure_empty_line_above=function(e,i){for(var s=this.__lines.length-2;s>=0;){var n=this.__lines[s];if(n.is_empty())break;if(0!==n.item(0).indexOf(e)&&n.item(-1)!==i){this.__lines.splice(s+1,0,new t(this)),this.previous_line=this.__lines[this.__lines.length-2];break}s--}},X.Output=i,X}var Q,J={};function Z(){if(Q)return J;return Q=1,J.Token=function(t,e,i,s){this.type=t,this.text=e,this.comments_before=null,this.newlines=i||0,this.whitespace_before=s||"",this.parent=null,this.next=null,this.previous=null,this.opened=null,this.closed=null,this.directives=null},J}var tt,et={};function it(){return tt||(tt=1,a="(?:"+(n="\\\\u[0-9a-fA-F]{4}|\\\\u\\{[0-9a-fA-F]+\\}")+"|[\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a"+(i="\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc")+"])",r="(?:"+n+"|["+(e="\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a")+i+(s="\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f")+"])*",(t=et).identifier=new RegExp(a+r,"g"),t.identifierStart=new RegExp(a),t.identifierMatch=new RegExp("(?:"+n+"|["+e+i+s+"])+"),t.newline=/[\n\r\u2028\u2029]/,t.lineBreak=new RegExp("\r\n|"+t.newline.source),t.allLineBreaks=new RegExp(t.lineBreak.source,"g")),et;var t,e,i,s,n,a,r}var st,nt,at={},rt={};function ot(){if(st)return rt;function t(t,i){this.raw_options=e(t,i),this.disabled=this._get_boolean("disabled"),this.eol=this._get_characters("eol","auto"),this.end_with_newline=this._get_boolean("end_with_newline"),this.indent_size=this._get_number("indent_size",4),this.indent_char=this._get_characters("indent_char"," "),this.indent_level=this._get_number("indent_level"),this.preserve_newlines=this._get_boolean("preserve_newlines",!0),this.max_preserve_newlines=this._get_number("max_preserve_newlines",32786),this.preserve_newlines||(this.max_preserve_newlines=0),this.indent_with_tabs=this._get_boolean("indent_with_tabs","\t"===this.indent_char),this.indent_with_tabs&&(this.indent_char="\t",1===this.indent_size&&(this.indent_size=4)),this.wrap_line_length=this._get_number("wrap_line_length",this._get_number("max_char")),this.indent_empty_lines=this._get_boolean("indent_empty_lines"),this.templating=this._get_selection_list("templating",["auto","none","angular","django","erb","handlebars","php","smarty"],["auto"])}function e(t,e){var s,n={};for(s in t=i(t))s!==e&&(n[s]=t[s]);if(e&&t[e])for(s in t[e])n[s]=t[e][s];return n}function i(t){var e,i={};for(e in t){i[e.replace(/-/g,"_")]=t[e]}return i}return st=1,t.prototype._get_array=function(t,e){var i=this.raw_options[t],s=e||[];return"object"==typeof i?null!==i&&"function"==typeof i.concat&&(s=i.concat()):"string"==typeof i&&(s=i.split(/[^a-zA-Z0-9_\/\-]+/)),s},t.prototype._get_boolean=function(t,e){var i=this.raw_options[t];return void 0===i?!!e:!!i},t.prototype._get_characters=function(t,e){var i=this.raw_options[t],s=e||"";return"string"==typeof i&&(s=i.replace(/\\r/,"\r").replace(/\\n/,"\n").replace(/\\t/,"\t")),s},t.prototype._get_number=function(t,e){var i=this.raw_options[t];e=parseInt(e,10),isNaN(e)&&(e=0);var s=parseInt(i,10);return isNaN(s)&&(s=e),s},t.prototype._get_selection=function(t,e,i){var s=this._get_selection_list(t,e,i);if(1!==s.length)throw new Error("Invalid Option Value: The option '"+t+"' can only be one of the following values:\n"+e+"\nYou passed in: '"+this.raw_options[t]+"'");return s[0]},t.prototype._get_selection_list=function(t,e,i){if(!e||0===e.length)throw new Error("Selection list cannot be empty.");if(i=i||[e[0]],!this._is_valid_selection(i,e))throw new Error("Invalid Default Value!");var s=this._get_array(t,i);if(!this._is_valid_selection(s,e))throw new Error("Invalid Option Value: The option '"+t+"' can contain only the following values:\n"+e+"\nYou passed in: '"+this.raw_options[t]+"'");return s},t.prototype._is_valid_selection=function(t,e){return t.length&&e.length&&!t.some((function(t){return-1===e.indexOf(t)}))},rt.Options=t,rt.normalizeOpts=i,rt.mergeOpts=e,rt}function lt(){if(nt)return at;nt=1;var t=ot().Options,e=["before-newline","after-newline","preserve-newline"];function i(i){t.call(this,i,"js");var s=this.raw_options.brace_style||null;"expand-strict"===s?this.raw_options.brace_style="expand":"collapse-preserve-inline"===s?this.raw_options.brace_style="collapse,preserve-inline":void 0!==this.raw_options.braces_on_own_line&&(this.raw_options.brace_style=this.raw_options.braces_on_own_line?"expand":"collapse");var n=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_preserve_inline=!1,this.brace_style="collapse";for(var a=0;a<n.length;a++)"preserve-inline"===n[a]?this.brace_preserve_inline=!0:this.brace_style=n[a];this.unindent_chained_methods=this._get_boolean("unindent_chained_methods"),this.break_chained_methods=this._get_boolean("break_chained_methods"),this.space_in_paren=this._get_boolean("space_in_paren"),this.space_in_empty_paren=this._get_boolean("space_in_empty_paren"),this.jslint_happy=this._get_boolean("jslint_happy"),this.space_after_anon_function=this._get_boolean("space_after_anon_function"),this.space_after_named_function=this._get_boolean("space_after_named_function"),this.keep_array_indentation=this._get_boolean("keep_array_indentation"),this.space_before_conditional=this._get_boolean("space_before_conditional",!0),this.unescape_strings=this._get_boolean("unescape_strings"),this.e4x=this._get_boolean("e4x"),this.comma_first=this._get_boolean("comma_first"),this.operator_position=this._get_selection("operator_position",e),this.test_output_raw=this._get_boolean("test_output_raw"),this.jslint_happy&&(this.space_after_anon_function=!0)}return i.prototype=new t,at.Options=i,at}var ht,ct={},dt={};function ut(){if(ht)return dt;ht=1;var t=RegExp.prototype.hasOwnProperty("sticky");function e(t){this.__input=t||"",this.__input_length=this.__input.length,this.__position=0}return e.prototype.restart=function(){this.__position=0},e.prototype.back=function(){this.__position>0&&(this.__position-=1)},e.prototype.hasNext=function(){return this.__position<this.__input_length},e.prototype.next=function(){var t=null;return this.hasNext()&&(t=this.__input.charAt(this.__position),this.__position+=1),t},e.prototype.peek=function(t){var e=null;return t=t||0,(t+=this.__position)>=0&&t<this.__input_length&&(e=this.__input.charAt(t)),e},e.prototype.__match=function(e,i){e.lastIndex=i;var s=e.exec(this.__input);return!s||t&&e.sticky||s.index!==i&&(s=null),s},e.prototype.test=function(t,e){return e=e||0,(e+=this.__position)>=0&&e<this.__input_length&&!!this.__match(t,e)},e.prototype.testChar=function(t,e){var i=this.peek(e);return t.lastIndex=0,null!==i&&t.test(i)},e.prototype.match=function(t){var e=this.__match(t,this.__position);return e?this.__position+=e[0].length:e=null,e},e.prototype.read=function(t,e,i){var s,n="";return t&&(s=this.match(t))&&(n+=s[0]),!e||!s&&t||(n+=this.readUntil(e,i)),n},e.prototype.readUntil=function(t,e){var i,s=this.__position;t.lastIndex=this.__position;var n=t.exec(this.__input);return n?(s=n.index,e&&(s+=n[0].length)):s=this.__input_length,i=this.__input.substring(this.__position,s),this.__position=s,i},e.prototype.readUntilAfter=function(t){return this.readUntil(t,!0)},e.prototype.get_regexp=function(e,i){var s=null,n="g";return i&&t&&(n="y"),"string"==typeof e&&""!==e?s=new RegExp(e,n):e&&(s=new RegExp(e.source,n)),s},e.prototype.get_literal_regexp=function(t){return RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"))},e.prototype.peekUntilAfter=function(t){var e=this.__position,i=this.readUntilAfter(t);return this.__position=e,i},e.prototype.lookBack=function(t){var e=this.__position-1;return e>=t.length&&this.__input.substring(e-t.length,e).toLowerCase()===t},dt.InputScanner=e,dt}var pt,gt={},ft={};var _t,mt,vt,bt={},yt={};function wt(){if(_t)return yt;function t(t,e){this._input=t,this._starting_pattern=null,this._match_pattern=null,this._until_pattern=null,this._until_after=!1,e&&(this._starting_pattern=this._input.get_regexp(e._starting_pattern,!0),this._match_pattern=this._input.get_regexp(e._match_pattern,!0),this._until_pattern=this._input.get_regexp(e._until_pattern),this._until_after=e._until_after)}return _t=1,t.prototype.read=function(){var t=this._input.read(this._starting_pattern);return this._starting_pattern&&!t||(t+=this._input.read(this._match_pattern,this._until_pattern,this._until_after)),t},t.prototype.read_match=function(){return this._input.match(this._match_pattern)},t.prototype.until_after=function(t){var e=this._create();return e._until_after=!0,e._until_pattern=this._input.get_regexp(t),e._update(),e},t.prototype.until=function(t){var e=this._create();return e._until_after=!1,e._until_pattern=this._input.get_regexp(t),e._update(),e},t.prototype.starting_with=function(t){var e=this._create();return e._starting_pattern=this._input.get_regexp(t,!0),e._update(),e},t.prototype.matching=function(t){var e=this._create();return e._match_pattern=this._input.get_regexp(t,!0),e._update(),e},t.prototype._create=function(){return new t(this._input,this)},t.prototype._update=function(){},yt.Pattern=t,yt}function xt(){if(vt)return gt;vt=1;var t=ut().InputScanner,e=Z().Token,i=function(){if(pt)return ft;function t(t){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=t}return pt=1,t.prototype.restart=function(){this.__position=0},t.prototype.isEmpty=function(){return 0===this.__tokens_length},t.prototype.hasNext=function(){return this.__position<this.__tokens_length},t.prototype.next=function(){var t=null;return this.hasNext()&&(t=this.__tokens[this.__position],this.__position+=1),t},t.prototype.peek=function(t){var e=null;return t=t||0,(t+=this.__position)>=0&&t<this.__tokens_length&&(e=this.__tokens[t]),e},t.prototype.add=function(t){this.__parent_token&&(t.parent=this.__parent_token),this.__tokens.push(t),this.__tokens_length+=1},ft.TokenStream=t,ft}().TokenStream,s=function(){if(mt)return bt;mt=1;var t=wt().Pattern;function e(e,i){t.call(this,e,i),i?this._line_regexp=this._input.get_regexp(i._line_regexp):this.__set_whitespace_patterns("",""),this.newline_count=0,this.whitespace_before_token=""}return e.prototype=new t,e.prototype.__set_whitespace_patterns=function(t,e){t+="\\t ",e+="\\n\\r",this._match_pattern=this._input.get_regexp("["+t+e+"]+",!0),this._newline_regexp=this._input.get_regexp("\\r\\n|["+e+"]")},e.prototype.read=function(){this.newline_count=0,this.whitespace_before_token="";var t=this._input.read(this._match_pattern);if(" "===t)this.whitespace_before_token=" ";else if(t){var e=this.__split(this._newline_regexp,t);this.newline_count=e.length-1,this.whitespace_before_token=e[this.newline_count]}return t},e.prototype.matching=function(t,e){var i=this._create();return i.__set_whitespace_patterns(t,e),i._update(),i},e.prototype._create=function(){return new e(this._input,this)},e.prototype.__split=function(t,e){t.lastIndex=0;for(var i=0,s=[],n=t.exec(e);n;)s.push(e.substring(i,n.index)),i=n.index+n[0].length,n=t.exec(e);return i<e.length?s.push(e.substring(i,e.length)):s.push(""),s},bt.WhitespacePattern=e,bt}().WhitespacePattern,n={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},a=function(e,i){this._input=new t(e),this._options=i||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new s(this._input)};return a.prototype.tokenize=function(){var t;this._input.restart(),this.__tokens=new i,this._reset();for(var s=new e(n.START,""),a=null,r=[],o=new i;s.type!==n.EOF;){for(t=this._get_next_token(s,a);this._is_comment(t);)o.add(t),t=this._get_next_token(s,a);o.isEmpty()||(t.comments_before=o,o=new i),t.parent=a,this._is_opening(t)?(r.push(a),a=t):a&&this._is_closing(t,a)&&(t.opened=a,a.closed=t,a=r.pop(),t.parent=a),t.previous=s,s.next=t,this.__tokens.add(t),s=t}return this.__tokens},a.prototype._is_first_token=function(){return this.__tokens.isEmpty()},a.prototype._reset=function(){},a.prototype._get_next_token=function(t,e){this._readWhitespace();var i=this._input.read(/.+/g);return i?this._create_token(n.RAW,i):this._create_token(n.EOF,"")},a.prototype._is_comment=function(t){return!1},a.prototype._is_opening=function(t){return!1},a.prototype._is_closing=function(t,e){return!1},a.prototype._create_token=function(t,i){return new e(t,i,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token)},a.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},gt.Tokenizer=a,gt.TOKEN=n,gt}var At,kt={};function Tt(){if(At)return kt;function t(t,e){t="string"==typeof t?t:t.source,e="string"==typeof e?e:e.source,this.__directives_block_pattern=new RegExp(t+/ beautify( \w+[:]\w+)+ /.source+e,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(t+/\sbeautify\signore:end\s/.source+e,"g")}return At=1,t.prototype.get_directives=function(t){if(!t.match(this.__directives_block_pattern))return null;var e={};this.__directive_pattern.lastIndex=0;for(var i=this.__directive_pattern.exec(t);i;)e[i[1]]=i[2],i=this.__directive_pattern.exec(t);return e},t.prototype.readIgnored=function(t){return t.readUntilAfter(this.__directives_end_ignore_pattern)},kt.Directives=t,kt}var St,Et,Ct,Rt,Mt={};function Pt(){if(St)return Mt;St=1;var t=wt().Pattern,e={django:!1,erb:!1,handlebars:!1,php:!1,smarty:!1,angular:!1};function i(i,s){t.call(this,i,s),this.__template_pattern=null,this._disabled=Object.assign({},e),this._excluded=Object.assign({},e),s&&(this.__template_pattern=this._input.get_regexp(s.__template_pattern),this._excluded=Object.assign(this._excluded,s._excluded),this._disabled=Object.assign(this._disabled,s._disabled));var n=new t(i);this.__patterns={handlebars_comment:n.starting_with(/{{!--/).until_after(/--}}/),handlebars_unescaped:n.starting_with(/{{{/).until_after(/}}}/),handlebars:n.starting_with(/{{/).until_after(/}}/),php:n.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),erb:n.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:n.starting_with(/{%/).until_after(/%}/),django_value:n.starting_with(/{{/).until_after(/}}/),django_comment:n.starting_with(/{#/).until_after(/#}/),smarty:n.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:n.starting_with(/{\*/).until_after(/\*}/),smarty_literal:n.starting_with(/{literal}/).until_after(/{\/literal}/)}}return i.prototype=new t,i.prototype._create=function(){return new i(this._input,this)},i.prototype._update=function(){this.__set_templated_pattern()},i.prototype.disable=function(t){var e=this._create();return e._disabled[t]=!0,e._update(),e},i.prototype.read_options=function(t){var i=this._create();for(var s in e)i._disabled[s]=-1===t.templating.indexOf(s);return i._update(),i},i.prototype.exclude=function(t){var e=this._create();return e._excluded[t]=!0,e._update(),e},i.prototype.read=function(){var t="";t=this._match_pattern?this._input.read(this._starting_pattern):this._input.read(this._starting_pattern,this.__template_pattern);for(var e=this._read_template();e;)this._match_pattern?e+=this._input.read(this._match_pattern):e+=this._input.readUntil(this.__template_pattern),t+=e,e=this._read_template();return this._until_after&&(t+=this._input.readUntilAfter(this._until_pattern)),t},i.prototype.__set_templated_pattern=function(){var t=[];this._disabled.php||t.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||t.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.angular||t.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||t.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(t.push(this.__patterns.django._starting_pattern.source),t.push(this.__patterns.django_value._starting_pattern.source),t.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||t.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&t.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+t.join("|")+")")},i.prototype._read_template=function(){var t="",e=this._input.peek();if("<"===e){var i=this._input.peek(1);this._disabled.php||this._excluded.php||"?"!==i||(t=t||this.__patterns.php.read()),this._disabled.erb||this._excluded.erb||"%"!==i||(t=t||this.__patterns.erb.read())}else"{"===e&&(this._disabled.handlebars||this._excluded.handlebars||(t=(t=(t=t||this.__patterns.handlebars_comment.read())||this.__patterns.handlebars_unescaped.read())||this.__patterns.handlebars.read()),this._disabled.django||(this._excluded.django||this._excluded.handlebars||(t=t||this.__patterns.django_value.read()),this._excluded.django||(t=(t=t||this.__patterns.django_comment.read())||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(t=(t=(t=t||this.__patterns.smarty_comment.read())||this.__patterns.smarty_literal.read())||this.__patterns.smarty.read()));return t},Mt.TemplatablePattern=i,Mt}function Lt(){if(Et)return ct;Et=1;var t=ut().InputScanner,e=xt().Tokenizer,i=xt().TOKEN,s=Tt().Directives,n=it(),a=wt().Pattern,r=Pt().TemplatablePattern;function o(t,e){return-1!==e.indexOf(t)}var l={START_EXPR:"TK_START_EXPR",END_EXPR:"TK_END_EXPR",START_BLOCK:"TK_START_BLOCK",END_BLOCK:"TK_END_BLOCK",WORD:"TK_WORD",RESERVED:"TK_RESERVED",SEMICOLON:"TK_SEMICOLON",STRING:"TK_STRING",EQUALS:"TK_EQUALS",OPERATOR:"TK_OPERATOR",COMMA:"TK_COMMA",BLOCK_COMMENT:"TK_BLOCK_COMMENT",COMMENT:"TK_COMMENT",DOT:"TK_DOT",UNKNOWN:"TK_UNKNOWN",START:i.START,RAW:i.RAW,EOF:i.EOF},h=new s(/\/\*/,/\*\//),c=/0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/,d=/[0-9]/,u=/[^\d\.]/,p=">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" "),g=">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";g=(g="\\?\\.(?!\\d) "+(g=g.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"))).replace(/ /g,"|");var f,_=new RegExp(g),m="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(","),v=m.concat(["do","in","of","else","get","set","new","catch","finally","typeof","yield","async","await","from","as","class","extends"]),b=new RegExp("^(?:"+v.join("|")+")$"),y=function(t,i){e.call(this,t,i),this._patterns.whitespace=this._patterns.whitespace.matching(/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,/\u2028\u2029/.source);var s=new a(this._input),o=new r(this._input).read_options(this._options);this.__patterns={template:o,identifier:o.starting_with(n.identifier).matching(n.identifierMatch),number:s.matching(c),punct:s.matching(_),comment:s.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),block_comment:s.starting_with(/\/\*/).until_after(/\*\//),html_comment_start:s.matching(/<!--/),html_comment_end:s.matching(/-->/),include:s.starting_with(/#include/).until_after(n.lineBreak),shebang:s.starting_with(/#!/).until_after(n.lineBreak),xml:s.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/),single_quote:o.until(/['\\\n\r\u2028\u2029]/),double_quote:o.until(/["\\\n\r\u2028\u2029]/),template_text:o.until(/[`\\$]/),template_expression:o.until(/[`}\\]/)}};return(y.prototype=new e)._is_comment=function(t){return t.type===l.COMMENT||t.type===l.BLOCK_COMMENT||t.type===l.UNKNOWN},y.prototype._is_opening=function(t){return t.type===l.START_BLOCK||t.type===l.START_EXPR},y.prototype._is_closing=function(t,e){return(t.type===l.END_BLOCK||t.type===l.END_EXPR)&&e&&("]"===t.text&&"["===e.text||")"===t.text&&"("===e.text||"}"===t.text&&"{"===e.text)},y.prototype._reset=function(){f=!1},y.prototype._get_next_token=function(t,e){var i=null;this._readWhitespace();var s=this._input.peek();return null===s?this._create_token(l.EOF,""):i=(i=(i=(i=(i=(i=(i=(i=(i=(i=i||this._read_non_javascript(s))||this._read_string(s))||this._read_pair(s,this._input.peek(1)))||this._read_word(t))||this._read_singles(s))||this._read_comment(s))||this._read_regexp(s,t))||this._read_xml(s,t))||this._read_punctuation())||this._create_token(l.UNKNOWN,this._input.next())},y.prototype._read_word=function(t){var e;return""!==(e=this.__patterns.identifier.read())?(e=e.replace(n.allLineBreaks,"\n"),t.type!==l.DOT&&(t.type!==l.RESERVED||"set"!==t.text&&"get"!==t.text)&&b.test(e)?"in"!==e&&"of"!==e||t.type!==l.WORD&&t.type!==l.STRING?this._create_token(l.RESERVED,e):this._create_token(l.OPERATOR,e):this._create_token(l.WORD,e)):""!==(e=this.__patterns.number.read())?this._create_token(l.WORD,e):void 0},y.prototype._read_singles=function(t){var e=null;return"("===t||"["===t?e=this._create_token(l.START_EXPR,t):")"===t||"]"===t?e=this._create_token(l.END_EXPR,t):"{"===t?e=this._create_token(l.START_BLOCK,t):"}"===t?e=this._create_token(l.END_BLOCK,t):";"===t?e=this._create_token(l.SEMICOLON,t):"."===t&&u.test(this._input.peek(1))?e=this._create_token(l.DOT,t):","===t&&(e=this._create_token(l.COMMA,t)),e&&this._input.next(),e},y.prototype._read_pair=function(t,e){var i=null;return"#"===t&&"{"===e&&(i=this._create_token(l.START_BLOCK,t+e)),i&&(this._input.next(),this._input.next()),i},y.prototype._read_punctuation=function(){var t=this.__patterns.punct.read();if(""!==t)return"="===t?this._create_token(l.EQUALS,t):"?."===t?this._create_token(l.DOT,t):this._create_token(l.OPERATOR,t)},y.prototype._read_non_javascript=function(t){var e="";if("#"===t){if(this._is_first_token()&&(e=this.__patterns.shebang.read()))return this._create_token(l.UNKNOWN,e.trim()+"\n");if(e=this.__patterns.include.read())return this._create_token(l.UNKNOWN,e.trim()+"\n");t=this._input.next();var i="#";if(this._input.hasNext()&&this._input.testChar(d)){do{i+=t=this._input.next()}while(this._input.hasNext()&&"#"!==t&&"="!==t);return"#"===t||("["===this._input.peek()&&"]"===this._input.peek(1)?(i+="[]",this._input.next(),this._input.next()):"{"===this._input.peek()&&"}"===this._input.peek(1)&&(i+="{}",this._input.next(),this._input.next())),this._create_token(l.WORD,i)}this._input.back()}else if("<"===t&&this._is_first_token()){if(e=this.__patterns.html_comment_start.read()){for(;this._input.hasNext()&&!this._input.testChar(n.newline);)e+=this._input.next();return f=!0,this._create_token(l.COMMENT,e)}}else if(f&&"-"===t&&(e=this.__patterns.html_comment_end.read()))return f=!1,this._create_token(l.COMMENT,e);return null},y.prototype._read_comment=function(t){var e=null;if("/"===t){var i="";if("*"===this._input.peek(1)){i=this.__patterns.block_comment.read();var s=h.get_directives(i);s&&"start"===s.ignore&&(i+=h.readIgnored(this._input)),i=i.replace(n.allLineBreaks,"\n"),(e=this._create_token(l.BLOCK_COMMENT,i)).directives=s}else"/"===this._input.peek(1)&&(i=this.__patterns.comment.read(),e=this._create_token(l.COMMENT,i))}return e},y.prototype._read_string=function(e){if("`"===e||"'"===e||'"'===e){var i=this._input.next();return this.has_char_escapes=!1,i+="`"===e?this._read_string_recursive("`",!0,"${"):this._read_string_recursive(e),this.has_char_escapes&&this._options.unescape_strings&&(i=function(e){var i="",s=0,n=new t(e),a=null;for(;n.hasNext();)if((a=n.match(/([\s]|[^\\]|\\\\)+/g))&&(i+=a[0]),"\\"===n.peek()){if(n.next(),"x"===n.peek())a=n.match(/x([0-9A-Fa-f]{2})/g);else{if("u"!==n.peek()){i+="\\",n.hasNext()&&(i+=n.next());continue}(a=n.match(/u([0-9A-Fa-f]{4})/g))||(a=n.match(/u\{([0-9A-Fa-f]+)\}/g))}if(!a)return e;if((s=parseInt(a[1],16))>126&&s<=255&&0===a[0].indexOf("x"))return e;i+=s>=0&&s<32||s>1114111?"\\"+a[0]:34===s||39===s||92===s?"\\"+String.fromCharCode(s):String.fromCharCode(s)}return i}(i)),this._input.peek()===e&&(i+=this._input.next()),i=i.replace(n.allLineBreaks,"\n"),this._create_token(l.STRING,i)}return null},y.prototype._allow_regexp_or_xml=function(t){return t.type===l.RESERVED&&o(t.text,["return","case","throw","else","do","typeof","yield"])||t.type===l.END_EXPR&&")"===t.text&&t.opened.previous.type===l.RESERVED&&o(t.opened.previous.text,["if","while","for"])||o(t.type,[l.COMMENT,l.START_EXPR,l.START_BLOCK,l.START,l.END_BLOCK,l.OPERATOR,l.EQUALS,l.EOF,l.SEMICOLON,l.COMMA])},y.prototype._read_regexp=function(t,e){if("/"===t&&this._allow_regexp_or_xml(e)){for(var i=this._input.next(),s=!1,a=!1;this._input.hasNext()&&(s||a||this._input.peek()!==t)&&!this._input.testChar(n.newline);)i+=this._input.peek(),s?s=!1:(s="\\"===this._input.peek(),"["===this._input.peek()?a=!0:"]"===this._input.peek()&&(a=!1)),this._input.next();return this._input.peek()===t&&(i+=this._input.next(),i+=this._input.read(n.identifier)),this._create_token(l.STRING,i)}return null},y.prototype._read_xml=function(t,e){if(this._options.e4x&&"<"===t&&this._allow_regexp_or_xml(e)){var i="",s=this.__patterns.xml.read_match();if(s){for(var a=s[2].replace(/^{\s+/,"{").replace(/\s+}$/,"}"),r=0===a.indexOf("{"),o=0;s;){var h=!!s[1],c=s[2];if(!(!!s[s.length-1]||"![CDATA["===c.slice(0,8))&&(c===a||r&&c.replace(/^{\s+/,"{").replace(/\s+}$/,"}"))&&(h?--o:++o),i+=s[0],o<=0)break;s=this.__patterns.xml.read_match()}return s||(i+=this._input.match(/[\s\S]*/g)[0]),i=i.replace(n.allLineBreaks,"\n"),this._create_token(l.STRING,i)}}return null},y.prototype._read_string_recursive=function(t,e,i){var s,a;"'"===t?a=this.__patterns.single_quote:'"'===t?a=this.__patterns.double_quote:"`"===t?a=this.__patterns.template_text:"}"===t&&(a=this.__patterns.template_expression);for(var r=a.read(),o="";this._input.hasNext();){if((o=this._input.next())===t||!e&&n.newline.test(o)){this._input.back();break}"\\"===o&&this._input.hasNext()?("x"===(s=this._input.peek())||"u"===s?this.has_char_escapes=!0:"\r"===s&&"\n"===this._input.peek(1)&&this._input.next(),o+=this._input.next()):i&&("${"===i&&"$"===o&&"{"===this._input.peek()&&(o+=this._input.next()),i===o&&(o+="`"===t?this._read_string_recursive("}",e,"`"):this._read_string_recursive("`",e,"${"),this._input.hasNext()&&(o+=this._input.next()))),r+=o+=a.read()}return r},ct.Tokenizer=y,ct.TOKEN=l,ct.positionable_operators=p.slice(),ct.line_starters=m.slice(),ct}function Dt(){if(Ct)return K;Ct=1;var t=Y().Output,e=Z().Token,i=it(),s=lt().Options,n=Lt().Tokenizer,a=Lt().line_starters,r=Lt().positionable_operators,o=Lt().TOKEN;function l(t,e){return-1!==e.indexOf(t)}function h(t){return t.replace(/^\s+/g,"")}function c(t,e){return t&&t.type===o.RESERVED&&t.text===e}function d(t,e){return t&&t.type===o.RESERVED&&l(t.text,e)}var u=["case","return","do","if","throw","else","await","break","continue","async"],p=function(t){for(var e={},i=0;i<t.length;i++)e[t[i].replace(/-/g,"_")]=t[i];return e}(["before-newline","after-newline","preserve-newline"]),g=[p.before_newline,p.preserve_newline],f="BlockStatement",_="Statement",m="ObjectLiteral",v="ArrayLiteral",b="ForInitializer",y="Conditional",w="Expression";function x(t,e){e.multiline_frame||e.mode===b||e.mode===y||t.remove_indent(e.start_line_index)}function A(t){return t===v}function k(t){return l(t,[w,b,y])}function T(t,e){e=e||{},this._source_text=t||"",this._output=null,this._tokens=null,this._last_last_text=null,this._flags=null,this._previous_flags=null,this._flag_store=null,this._options=new s(e)}T.prototype.create_flags=function(t,i){var s=0;return t&&(s=t.indentation_level,!this._output.just_added_newline()&&t.line_indent_level>s&&(s=t.line_indent_level)),{mode:i,parent:t,last_token:t?t.last_token:new e(o.START_BLOCK,""),last_word:t?t.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,inline_frame:!1,if_block:!1,else_block:!1,class_start_block:!1,do_block:!1,do_while:!1,import_block:!1,in_case_statement:!1,in_case:!1,case_body:!1,case_block:!1,indentation_level:s,alignment:0,line_indent_level:t?t.line_indent_level:s,start_line_index:this._output.get_line_number(),ternary_depth:0}},T.prototype._reset=function(e){var i=e.match(/^[\t ]*/)[0];this._last_last_text="",this._output=new t(this._options,i),this._output.raw=this._options.test_output_raw,this._flag_store=[],this.set_mode(f);var s=new n(e,this._options);return this._tokens=s.tokenize(),e},T.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var t=this._reset(this._source_text),e=this._options.eol;"auto"===this._options.eol&&(e="\n",t&&i.lineBreak.test(t||"")&&(e=t.match(i.lineBreak)[0]));for(var s=this._tokens.next();s;)this.handle_token(s),this._last_last_text=this._flags.last_token.text,this._flags.last_token=s,s=this._tokens.next();return this._output.get_code(e)},T.prototype.handle_token=function(t,e){t.type===o.START_EXPR?this.handle_start_expr(t):t.type===o.END_EXPR?this.handle_end_expr(t):t.type===o.START_BLOCK?this.handle_start_block(t):t.type===o.END_BLOCK?this.handle_end_block(t):t.type===o.WORD||t.type===o.RESERVED?this.handle_word(t):t.type===o.SEMICOLON?this.handle_semicolon(t):t.type===o.STRING?this.handle_string(t):t.type===o.EQUALS?this.handle_equals(t):t.type===o.OPERATOR?this.handle_operator(t):t.type===o.COMMA?this.handle_comma(t):t.type===o.BLOCK_COMMENT?this.handle_block_comment(t,e):t.type===o.COMMENT?this.handle_comment(t,e):t.type===o.DOT?this.handle_dot(t):t.type===o.EOF?this.handle_eof(t):(t.type,o.UNKNOWN,this.handle_unknown(t,e))},T.prototype.handle_whitespace_and_comments=function(t,e){var i=t.newlines,s=this._options.keep_array_indentation&&A(this._flags.mode);if(t.comments_before)for(var n=t.comments_before.next();n;)this.handle_whitespace_and_comments(n,e),this.handle_token(n,e),n=t.comments_before.next();if(s)for(var a=0;a<i;a+=1)this.print_newline(a>0,e);else if(this._options.max_preserve_newlines&&i>this._options.max_preserve_newlines&&(i=this._options.max_preserve_newlines),this._options.preserve_newlines&&i>1){this.print_newline(!1,e);for(var r=1;r<i;r+=1)this.print_newline(!0,e)}};var S=["async","break","continue","return","throw","yield"];return T.prototype.allow_wrap_or_preserved_newline=function(t,e){if(e=void 0!==e&&e,!this._output.just_added_newline()){var i=this._options.preserve_newlines&&t.newlines||e;if(l(this._flags.last_token.text,r)||l(t.text,r)){var s=l(this._flags.last_token.text,r)&&l(this._options.operator_position,g)||l(t.text,r);i=i&&s}if(i)this.print_newline(!1,!0);else if(this._options.wrap_line_length){if(d(this._flags.last_token,S))return;this._output.set_wrap_point()}}},T.prototype.print_newline=function(t,e){if(!e&&";"!==this._flags.last_token.text&&","!==this._flags.last_token.text&&"="!==this._flags.last_token.text&&(this._flags.last_token.type!==o.OPERATOR||"--"===this._flags.last_token.text||"++"===this._flags.last_token.text))for(var i=this._tokens.peek();!(this._flags.mode!==_||this._flags.if_block&&c(i,"else")||this._flags.do_block);)this.restore_mode();this._output.add_new_line(t)&&(this._flags.multiline_frame=!0)},T.prototype.print_token_line_indentation=function(t){this._output.just_added_newline()&&(this._options.keep_array_indentation&&t.newlines&&("["===t.text||A(this._flags.mode))?(this._output.current_line.set_indent(-1),this._output.current_line.push(t.whitespace_before),this._output.space_before_token=!1):this._output.set_indent(this._flags.indentation_level,this._flags.alignment)&&(this._flags.line_indent_level=this._flags.indentation_level))},T.prototype.print_token=function(t){if(this._output.raw)this._output.add_raw_token(t);else{if(this._options.comma_first&&t.previous&&t.previous.type===o.COMMA&&this._output.just_added_newline()&&","===this._output.previous_line.last()){var e=this._output.previous_line.pop();this._output.previous_line.is_empty()&&(this._output.previous_line.push(e),this._output.trim(!0),this._output.current_line.pop(),this._output.trim()),this.print_token_line_indentation(t),this._output.add_token(","),this._output.space_before_token=!0}this.print_token_line_indentation(t),this._output.non_breaking_space=!0,this._output.add_token(t.text),this._output.previous_token_wrapped&&(this._flags.multiline_frame=!0)}},T.prototype.indent=function(){this._flags.indentation_level+=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},T.prototype.deindent=function(){this._flags.indentation_level>0&&(!this._flags.parent||this._flags.indentation_level>this._flags.parent.indentation_level)&&(this._flags.indentation_level-=1,this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},T.prototype.set_mode=function(t){this._flags?(this._flag_store.push(this._flags),this._previous_flags=this._flags):this._previous_flags=this.create_flags(null,t),this._flags=this.create_flags(this._previous_flags,t),this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},T.prototype.restore_mode=function(){this._flag_store.length>0&&(this._previous_flags=this._flags,this._flags=this._flag_store.pop(),this._previous_flags.mode===_&&x(this._output,this._previous_flags),this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},T.prototype.start_of_object_property=function(){return this._flags.parent.mode===m&&this._flags.mode===_&&(":"===this._flags.last_token.text&&0===this._flags.ternary_depth||d(this._flags.last_token,["get","set"]))},T.prototype.start_of_statement=function(t){var e=!1;return!!(e=(e=(e=(e=(e=(e=(e=e||d(this._flags.last_token,["var","let","const"])&&t.type===o.WORD)||c(this._flags.last_token,"do"))||!(this._flags.parent.mode===m&&this._flags.mode===_)&&d(this._flags.last_token,S)&&!t.newlines)||c(this._flags.last_token,"else")&&!(c(t,"if")&&!t.comments_before))||this._flags.last_token.type===o.END_EXPR&&(this._previous_flags.mode===b||this._previous_flags.mode===y))||this._flags.last_token.type===o.WORD&&this._flags.mode===f&&!this._flags.in_case&&!("--"===t.text||"++"===t.text)&&"function"!==this._last_last_text&&t.type!==o.WORD&&t.type!==o.RESERVED)||this._flags.mode===m&&(":"===this._flags.last_token.text&&0===this._flags.ternary_depth||d(this._flags.last_token,["get","set"])))&&(this.set_mode(_),this.indent(),this.handle_whitespace_and_comments(t,!0),this.start_of_object_property()||this.allow_wrap_or_preserved_newline(t,d(t,["do","for","if","while"])),!0)},T.prototype.handle_start_expr=function(t){this.start_of_statement(t)||this.handle_whitespace_and_comments(t);var e=w;if("["===t.text){if(this._flags.last_token.type===o.WORD||")"===this._flags.last_token.text)return d(this._flags.last_token,a)&&(this._output.space_before_token=!0),this.print_token(t),this.set_mode(e),this.indent(),void(this._options.space_in_paren&&(this._output.space_before_token=!0));e=v,A(this._flags.mode)&&("["!==this._flags.last_token.text&&(","!==this._flags.last_token.text||"]"!==this._last_last_text&&"}"!==this._last_last_text)||this._options.keep_array_indentation||this.print_newline()),l(this._flags.last_token.type,[o.START_EXPR,o.END_EXPR,o.WORD,o.OPERATOR,o.DOT])||(this._output.space_before_token=!0)}else{if(this._flags.last_token.type===o.RESERVED)"for"===this._flags.last_token.text?(this._output.space_before_token=this._options.space_before_conditional,e=b):l(this._flags.last_token.text,["if","while","switch"])?(this._output.space_before_token=this._options.space_before_conditional,e=y):l(this._flags.last_word,["await","async"])?this._output.space_before_token=!0:"import"===this._flags.last_token.text&&""===t.whitespace_before?this._output.space_before_token=!1:(l(this._flags.last_token.text,a)||"catch"===this._flags.last_token.text)&&(this._output.space_before_token=!0);else if(this._flags.last_token.type===o.EQUALS||this._flags.last_token.type===o.OPERATOR)this.start_of_object_property()||this.allow_wrap_or_preserved_newline(t);else if(this._flags.last_token.type===o.WORD){this._output.space_before_token=!1;var i=this._tokens.peek(-3);if(this._options.space_after_named_function&&i){var s=this._tokens.peek(-4);d(i,["async","function"])||"*"===i.text&&d(s,["async","function"])?this._output.space_before_token=!0:this._flags.mode===m?"{"!==i.text&&","!==i.text&&("*"!==i.text||"{"!==s.text&&","!==s.text)||(this._output.space_before_token=!0):this._flags.parent&&this._flags.parent.class_start_block&&(this._output.space_before_token=!0)}}else this.allow_wrap_or_preserved_newline(t);(this._flags.last_token.type===o.RESERVED&&("function"===this._flags.last_word||"typeof"===this._flags.last_word)||"*"===this._flags.last_token.text&&(l(this._last_last_text,["function","yield"])||this._flags.mode===m&&l(this._last_last_text,["{",","])))&&(this._output.space_before_token=this._options.space_after_anon_function)}";"===this._flags.last_token.text||this._flags.last_token.type===o.START_BLOCK?this.print_newline():this._flags.last_token.type!==o.END_EXPR&&this._flags.last_token.type!==o.START_EXPR&&this._flags.last_token.type!==o.END_BLOCK&&"."!==this._flags.last_token.text&&this._flags.last_token.type!==o.COMMA||this.allow_wrap_or_preserved_newline(t,t.newlines),this.print_token(t),this.set_mode(e),this._options.space_in_paren&&(this._output.space_before_token=!0),this.indent()},T.prototype.handle_end_expr=function(t){for(;this._flags.mode===_;)this.restore_mode();this.handle_whitespace_and_comments(t),this._flags.multiline_frame&&this.allow_wrap_or_preserved_newline(t,"]"===t.text&&A(this._flags.mode)&&!this._options.keep_array_indentation),this._options.space_in_paren&&(this._flags.last_token.type!==o.START_EXPR||this._options.space_in_empty_paren?this._output.space_before_token=!0:(this._output.trim(),this._output.space_before_token=!1)),this.deindent(),this.print_token(t),this.restore_mode(),x(this._output,this._previous_flags),this._flags.do_while&&this._previous_flags.mode===y&&(this._previous_flags.mode=w,this._flags.do_block=!1,this._flags.do_while=!1)},T.prototype.handle_start_block=function(t){this.handle_whitespace_and_comments(t);var e=this._tokens.peek(),i=this._tokens.peek(1);"switch"===this._flags.last_word&&this._flags.last_token.type===o.END_EXPR?(this.set_mode(f),this._flags.in_case_statement=!0):this._flags.case_body?this.set_mode(f):i&&(l(i.text,[":",","])&&l(e.type,[o.STRING,o.WORD,o.RESERVED])||l(e.text,["get","set","..."])&&l(i.type,[o.WORD,o.RESERVED]))?l(this._last_last_text,["class","interface"])&&!l(i.text,[":",","])?this.set_mode(f):this.set_mode(m):this._flags.last_token.type===o.OPERATOR&&"=>"===this._flags.last_token.text?this.set_mode(f):l(this._flags.last_token.type,[o.EQUALS,o.START_EXPR,o.COMMA,o.OPERATOR])||d(this._flags.last_token,["return","throw","import","default"])?this.set_mode(m):this.set_mode(f),this._flags.last_token&&d(this._flags.last_token.previous,["class","extends"])&&(this._flags.class_start_block=!0);var s=!e.comments_before&&"}"===e.text,n=s&&"function"===this._flags.last_word&&this._flags.last_token.type===o.END_EXPR;if(this._options.brace_preserve_inline){var a=0,r=null;this._flags.inline_frame=!0;do{if(a+=1,(r=this._tokens.peek(a-1)).newlines){this._flags.inline_frame=!1;break}}while(r.type!==o.EOF&&(r.type!==o.END_BLOCK||r.opened!==t))}("expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines)&&!this._flags.inline_frame?this._flags.last_token.type!==o.OPERATOR&&(n||this._flags.last_token.type===o.EQUALS||d(this._flags.last_token,u)&&"else"!==this._flags.last_token.text)?this._output.space_before_token=!0:this.print_newline(!1,!0):(!A(this._previous_flags.mode)||this._flags.last_token.type!==o.START_EXPR&&this._flags.last_token.type!==o.COMMA||((this._flags.last_token.type===o.COMMA||this._options.space_in_paren)&&(this._output.space_before_token=!0),(this._flags.last_token.type===o.COMMA||this._flags.last_token.type===o.START_EXPR&&this._flags.inline_frame)&&(this.allow_wrap_or_preserved_newline(t),this._previous_flags.multiline_frame=this._previous_flags.multiline_frame||this._flags.multiline_frame,this._flags.multiline_frame=!1)),this._flags.last_token.type!==o.OPERATOR&&this._flags.last_token.type!==o.START_EXPR&&(l(this._flags.last_token.type,[o.START_BLOCK,o.SEMICOLON])&&!this._flags.inline_frame?this.print_newline():this._output.space_before_token=!0)),this.print_token(t),this.indent(),s||this._options.brace_preserve_inline&&this._flags.inline_frame||this.print_newline()},T.prototype.handle_end_block=function(t){for(this.handle_whitespace_and_comments(t);this._flags.mode===_;)this.restore_mode();var e=this._flags.last_token.type===o.START_BLOCK;this._flags.inline_frame&&!e?this._output.space_before_token=!0:"expand"===this._options.brace_style?e||this.print_newline():e||(A(this._flags.mode)&&this._options.keep_array_indentation?(this._options.keep_array_indentation=!1,this.print_newline(),this._options.keep_array_indentation=!0):this.print_newline()),this.restore_mode(),this.print_token(t)},T.prototype.handle_word=function(t){if(t.type===o.RESERVED)if(l(t.text,["set","get"])&&this._flags.mode!==m)t.type=o.WORD;else if("import"===t.text&&l(this._tokens.peek().text,["(","."]))t.type=o.WORD;else if(l(t.text,["as","from"])&&!this._flags.import_block)t.type=o.WORD;else if(this._flags.mode===m){":"===this._tokens.peek().text&&(t.type=o.WORD)}if(this.start_of_statement(t)?d(this._flags.last_token,["var","let","const"])&&t.type===o.WORD&&(this._flags.declaration_statement=!0):!t.newlines||k(this._flags.mode)||this._flags.last_token.type===o.OPERATOR&&"--"!==this._flags.last_token.text&&"++"!==this._flags.last_token.text||this._flags.last_token.type===o.EQUALS||!this._options.preserve_newlines&&d(this._flags.last_token,["var","let","const","set","get"])?this.handle_whitespace_and_comments(t):(this.handle_whitespace_and_comments(t),this.print_newline()),this._flags.do_block&&!this._flags.do_while){if(c(t,"while"))return this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0,void(this._flags.do_while=!0);this.print_newline(),this._flags.do_block=!1}if(this._flags.if_block)if(!this._flags.else_block&&c(t,"else"))this._flags.else_block=!0;else{for(;this._flags.mode===_;)this.restore_mode();this._flags.if_block=!1,this._flags.else_block=!1}if(this._flags.in_case_statement&&d(t,["case","default"]))return this.print_newline(),this._flags.case_block||!this._flags.case_body&&!this._options.jslint_happy||this.deindent(),this._flags.case_body=!1,this.print_token(t),void(this._flags.in_case=!0);if(this._flags.last_token.type!==o.COMMA&&this._flags.last_token.type!==o.START_EXPR&&this._flags.last_token.type!==o.EQUALS&&this._flags.last_token.type!==o.OPERATOR||this.start_of_object_property()||l(this._flags.last_token.text,["+","-"])&&":"===this._last_last_text&&this._flags.parent.mode===m||this.allow_wrap_or_preserved_newline(t),c(t,"function"))return(l(this._flags.last_token.text,["}",";"])||this._output.just_added_newline()&&!l(this._flags.last_token.text,["(","[","{",":","=",","])&&this._flags.last_token.type!==o.OPERATOR)&&(this._output.just_added_blankline()||t.comments_before||(this.print_newline(),this.print_newline(!0))),this._flags.last_token.type===o.RESERVED||this._flags.last_token.type===o.WORD?d(this._flags.last_token,["get","set","new","export"])||d(this._flags.last_token,S)||c(this._flags.last_token,"default")&&"export"===this._last_last_text||"declare"===this._flags.last_token.text?this._output.space_before_token=!0:this.print_newline():this._flags.last_token.type===o.OPERATOR||"="===this._flags.last_token.text?this._output.space_before_token=!0:(this._flags.multiline_frame||!k(this._flags.mode)&&!A(this._flags.mode))&&this.print_newline(),this.print_token(t),void(this._flags.last_word=t.text);var e="NONE";(this._flags.last_token.type===o.END_BLOCK?this._previous_flags.inline_frame?e="SPACE":d(t,["else","catch","finally","from"])?"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines?e="NEWLINE":(e="SPACE",this._output.space_before_token=!0):e="NEWLINE":this._flags.last_token.type===o.SEMICOLON&&this._flags.mode===f?e="NEWLINE":this._flags.last_token.type===o.SEMICOLON&&k(this._flags.mode)?e="SPACE":this._flags.last_token.type===o.STRING?e="NEWLINE":this._flags.last_token.type===o.RESERVED||this._flags.last_token.type===o.WORD||"*"===this._flags.last_token.text&&(l(this._last_last_text,["function","yield"])||this._flags.mode===m&&l(this._last_last_text,["{",","]))?e="SPACE":this._flags.last_token.type===o.START_BLOCK?e=this._flags.inline_frame?"SPACE":"NEWLINE":this._flags.last_token.type===o.END_EXPR&&(this._output.space_before_token=!0,e="NEWLINE"),d(t,a)&&")"!==this._flags.last_token.text&&(e=this._flags.inline_frame||"else"===this._flags.last_token.text||"export"===this._flags.last_token.text?"SPACE":"NEWLINE"),d(t,["else","catch","finally"]))?(this._flags.last_token.type!==o.END_BLOCK||this._previous_flags.mode!==f||"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines)&&!this._flags.inline_frame?this.print_newline():(this._output.trim(!0),"}"!==this._output.current_line.last()&&this.print_newline(),this._output.space_before_token=!0):"NEWLINE"===e?d(this._flags.last_token,u)||"declare"===this._flags.last_token.text&&d(t,["var","let","const"])?this._output.space_before_token=!0:this._flags.last_token.type!==o.END_EXPR?this._flags.last_token.type===o.START_EXPR&&d(t,["var","let","const"])||":"===this._flags.last_token.text||(c(t,"if")&&c(t.previous,"else")?this._output.space_before_token=!0:this.print_newline()):d(t,a)&&")"!==this._flags.last_token.text&&this.print_newline():this._flags.multiline_frame&&A(this._flags.mode)&&","===this._flags.last_token.text&&"}"===this._last_last_text?this.print_newline():"SPACE"===e&&(this._output.space_before_token=!0);!t.previous||t.previous.type!==o.WORD&&t.previous.type!==o.RESERVED||(this._output.space_before_token=!0),this.print_token(t),this._flags.last_word=t.text,t.type===o.RESERVED&&("do"===t.text?this._flags.do_block=!0:"if"===t.text?this._flags.if_block=!0:"import"===t.text?this._flags.import_block=!0:this._flags.import_block&&c(t,"from")&&(this._flags.import_block=!1))},T.prototype.handle_semicolon=function(t){this.start_of_statement(t)?this._output.space_before_token=!1:this.handle_whitespace_and_comments(t);for(var e=this._tokens.peek();!(this._flags.mode!==_||this._flags.if_block&&c(e,"else")||this._flags.do_block);)this.restore_mode();this._flags.import_block&&(this._flags.import_block=!1),this.print_token(t)},T.prototype.handle_string=function(t){(!t.text.startsWith("`")||0!==t.newlines||""!==t.whitespace_before||")"!==t.previous.text&&this._flags.last_token.type!==o.WORD)&&(this.start_of_statement(t)?this._output.space_before_token=!0:(this.handle_whitespace_and_comments(t),this._flags.last_token.type===o.RESERVED||this._flags.last_token.type===o.WORD||this._flags.inline_frame?this._output.space_before_token=!0:this._flags.last_token.type===o.COMMA||this._flags.last_token.type===o.START_EXPR||this._flags.last_token.type===o.EQUALS||this._flags.last_token.type===o.OPERATOR?this.start_of_object_property()||this.allow_wrap_or_preserved_newline(t):!t.text.startsWith("`")||this._flags.last_token.type!==o.END_EXPR||"]"!==t.previous.text&&")"!==t.previous.text||0!==t.newlines?this.print_newline():this._output.space_before_token=!0)),this.print_token(t)},T.prototype.handle_equals=function(t){this.start_of_statement(t)||this.handle_whitespace_and_comments(t),this._flags.declaration_statement&&(this._flags.declaration_assignment=!0),this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0},T.prototype.handle_comma=function(t){this.handle_whitespace_and_comments(t,!0),this.print_token(t),this._output.space_before_token=!0,this._flags.declaration_statement?(k(this._flags.parent.mode)&&(this._flags.declaration_assignment=!1),this._flags.declaration_assignment?(this._flags.declaration_assignment=!1,this.print_newline(!1,!0)):this._options.comma_first&&this.allow_wrap_or_preserved_newline(t)):this._flags.mode===m||this._flags.mode===_&&this._flags.parent.mode===m?(this._flags.mode===_&&this.restore_mode(),this._flags.inline_frame||this.print_newline()):this._options.comma_first&&this.allow_wrap_or_preserved_newline(t)},T.prototype.handle_operator=function(t){var e="*"===t.text&&(d(this._flags.last_token,["function","yield"])||l(this._flags.last_token.type,[o.START_BLOCK,o.COMMA,o.END_BLOCK,o.SEMICOLON])),i=l(t.text,["-","+"])&&(l(this._flags.last_token.type,[o.START_BLOCK,o.START_EXPR,o.EQUALS,o.OPERATOR])||l(this._flags.last_token.text,a)||","===this._flags.last_token.text);if(this.start_of_statement(t));else{var s=!e;this.handle_whitespace_and_comments(t,s)}if("*"!==t.text||this._flags.last_token.type!==o.DOT)if("::"!==t.text)if(l(t.text,["-","+"])&&this.start_of_object_property())this.print_token(t);else{if(this._flags.last_token.type===o.OPERATOR&&l(this._options.operator_position,g)&&this.allow_wrap_or_preserved_newline(t),":"===t.text&&this._flags.in_case)return this.print_token(t),this._flags.in_case=!1,this._flags.case_body=!0,void(this._tokens.peek().type!==o.START_BLOCK?(this.indent(),this.print_newline(),this._flags.case_block=!1):(this._flags.case_block=!0,this._output.space_before_token=!0));var n=!0,h=!0,c=!1;if(":"===t.text?0===this._flags.ternary_depth?n=!1:(this._flags.ternary_depth-=1,c=!0):"?"===t.text&&(this._flags.ternary_depth+=1),!i&&!e&&this._options.preserve_newlines&&l(t.text,r)){var m=":"===t.text,v=m&&c,b=m&&!c;switch(this._options.operator_position){case p.before_newline:return this._output.space_before_token=!b,this.print_token(t),m&&!v||this.allow_wrap_or_preserved_newline(t),void(this._output.space_before_token=!0);case p.after_newline:return this._output.space_before_token=!0,!m||v?this._tokens.peek().newlines?this.print_newline(!1,!0):this.allow_wrap_or_preserved_newline(t):this._output.space_before_token=!1,this.print_token(t),void(this._output.space_before_token=!0);case p.preserve_newline:return b||this.allow_wrap_or_preserved_newline(t),n=!(this._output.just_added_newline()||b),this._output.space_before_token=n,this.print_token(t),void(this._output.space_before_token=!0)}}if(e){this.allow_wrap_or_preserved_newline(t),n=!1;var y=this._tokens.peek();h=y&&l(y.type,[o.WORD,o.RESERVED])}else if("..."===t.text)this.allow_wrap_or_preserved_newline(t),n=this._flags.last_token.type===o.START_BLOCK,h=!1;else if(l(t.text,["--","++","!","~"])||i){if(this._flags.last_token.type!==o.COMMA&&this._flags.last_token.type!==o.START_EXPR||this.allow_wrap_or_preserved_newline(t),n=!1,h=!1,t.newlines&&("--"===t.text||"++"===t.text||"~"===t.text)){var w=d(this._flags.last_token,u)&&t.newlines;w&&(this._previous_flags.if_block||this._previous_flags.else_block)&&this.restore_mode(),this.print_newline(w,!0)}";"===this._flags.last_token.text&&k(this._flags.mode)&&(n=!0),this._flags.last_token.type===o.RESERVED?n=!0:this._flags.last_token.type===o.END_EXPR?n=!("]"===this._flags.last_token.text&&("--"===t.text||"++"===t.text)):this._flags.last_token.type===o.OPERATOR&&(n=l(t.text,["--","-","++","+"])&&l(this._flags.last_token.text,["--","-","++","+"]),l(t.text,["+","-"])&&l(this._flags.last_token.text,["--","++"])&&(h=!0)),(this._flags.mode!==f||this._flags.inline_frame)&&this._flags.mode!==_||"{"!==this._flags.last_token.text&&";"!==this._flags.last_token.text||this.print_newline()}this._output.space_before_token=this._output.space_before_token||n,this.print_token(t),this._output.space_before_token=h}else this.print_token(t);else this.print_token(t)},T.prototype.handle_block_comment=function(t,e){return this._output.raw?(this._output.add_raw_token(t),void(t.directives&&"end"===t.directives.preserve&&(this._output.raw=this._options.test_output_raw))):t.directives?(this.print_newline(!1,e),this.print_token(t),"start"===t.directives.preserve&&(this._output.raw=!0),void this.print_newline(!1,!0)):i.newline.test(t.text)||t.newlines?void this.print_block_commment(t,e):(this._output.space_before_token=!0,this.print_token(t),void(this._output.space_before_token=!0))},T.prototype.print_block_commment=function(t,e){var s,n=function(t){for(var e=[],s=(t=t.replace(i.allLineBreaks,"\n")).indexOf("\n");-1!==s;)e.push(t.substring(0,s)),s=(t=t.substring(s+1)).indexOf("\n");return t.length&&e.push(t),e}(t.text),a=!1,r=!1,o=t.whitespace_before,l=o.length;if(this.print_newline(!1,e),this.print_token_line_indentation(t),this._output.add_token(n[0]),this.print_newline(!1,e),n.length>1){for(a=function(t,e){for(var i=0;i<t.length;i++)if(t[i].trim().charAt(0)!==e)return!1;return!0}(n=n.slice(1),"*"),r=function(t,e){for(var i,s=0,n=t.length;s<n;s++)if((i=t[s])&&0!==i.indexOf(e))return!1;return!0}(n,o),a&&(this._flags.alignment=1),s=0;s<n.length;s++)a?(this.print_token_line_indentation(t),this._output.add_token(h(n[s]))):r&&n[s]?(this.print_token_line_indentation(t),this._output.add_token(n[s].substring(l))):(this._output.current_line.set_indent(-1),this._output.add_token(n[s])),this.print_newline(!1,e);this._flags.alignment=0}},T.prototype.handle_comment=function(t,e){t.newlines?this.print_newline(!1,e):this._output.trim(!0),this._output.space_before_token=!0,this.print_token(t),this.print_newline(!1,e)},T.prototype.handle_dot=function(t){this.start_of_statement(t)||this.handle_whitespace_and_comments(t,!0),this._flags.last_token.text.match("^[0-9]+$")&&(this._output.space_before_token=!0),d(this._flags.last_token,u)?this._output.space_before_token=!1:this.allow_wrap_or_preserved_newline(t,")"===this._flags.last_token.text&&this._options.break_chained_methods),this._options.unindent_chained_methods&&this._output.just_added_newline()&&this.deindent(),this.print_token(t)},T.prototype.handle_unknown=function(t,e){this.print_token(t),"\n"===t.text[t.text.length-1]&&this.print_newline(!1,e)},T.prototype.handle_eof=function(t){for(;this._flags.mode===_;)this.restore_mode();this.handle_whitespace_and_comments(t)},K.Beautifier=T,K}var It,Ot,Nt,Ft={exports:{}},Bt={},jt={};function zt(){if(It)return jt;It=1;var t=ot().Options;function e(e){t.call(this,e,"css"),this.selector_separator_newline=this._get_boolean("selector_separator_newline",!0),this.newline_between_rules=this._get_boolean("newline_between_rules",!0);var i=this._get_boolean("space_around_selector_separator");this.space_around_combinator=this._get_boolean("space_around_combinator")||i;var s=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]);this.brace_style="collapse";for(var n=0;n<s.length;n++)"expand"!==s[n]?this.brace_style="collapse":this.brace_style=s[n]}return e.prototype=new t,jt.Options=e,jt}function Vt(){if(Nt)return Ft.exports;Nt=1;var t=function(){if(Ot)return Bt;Ot=1;var t=zt().Options,e=Y().Output,i=ut().InputScanner,s=new(0,Tt().Directives)(/\/\*/,/\*\//),n=/\r\n|[\r\n]/,a=/\r\n|[\r\n]/g,r=/\s/,o=/(?:\s|\n)+/g,l=/\/\*(?:[\s\S]*?)((?:\*\/)|$)/g,h=/\/\/(?:[^\n\r\u2028\u2029]*)/g;function c(e,i){this._source_text=e||"",this._options=new t(i),this._ch=null,this._input=null,this.NESTED_AT_RULE={page:!0,"font-face":!0,keyframes:!0,media:!0,supports:!0,document:!0},this.CONDITIONAL_GROUP_RULE={media:!0,supports:!0,document:!0},this.NON_SEMICOLON_NEWLINE_PROPERTY=["grid-template-areas","grid-template"]}return c.prototype.eatString=function(t){var e="";for(this._ch=this._input.next();this._ch;){if(e+=this._ch,"\\"===this._ch)e+=this._input.next();else if(-1!==t.indexOf(this._ch)||"\n"===this._ch)break;this._ch=this._input.next()}return e},c.prototype.eatWhitespace=function(t){for(var e=r.test(this._input.peek()),i=0;r.test(this._input.peek());)this._ch=this._input.next(),t&&"\n"===this._ch&&(0===i||i<this._options.max_preserve_newlines)&&(i++,this._output.add_new_line(!0));return e},c.prototype.foundNestedPseudoClass=function(){for(var t=0,e=1,i=this._input.peek(e);i;){if("{"===i)return!0;if("("===i)t+=1;else if(")"===i){if(0===t)return!1;t-=1}else if(";"===i||"}"===i)return!1;e++,i=this._input.peek(e)}return!1},c.prototype.print_string=function(t){this._output.set_indent(this._indentLevel),this._output.non_breaking_space=!0,this._output.add_token(t)},c.prototype.preserveSingleSpace=function(t){t&&(this._output.space_before_token=!0)},c.prototype.indent=function(){this._indentLevel++},c.prototype.outdent=function(){this._indentLevel>0&&this._indentLevel--},c.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var t=this._source_text,c=this._options.eol;"auto"===c&&(c="\n",t&&n.test(t||"")&&(c=t.match(n)[0]));var d=(t=t.replace(a,"\n")).match(/^[\t ]*/)[0];this._output=new e(this._options,d),this._input=new i(t),this._indentLevel=0,this._nestedLevel=0,this._ch=null;for(var u,p,g=0,f=!1,_=!1,m=!1,v=!1,b=!1,y=this._ch,w=!1;u=""!==this._input.read(o),p=y,this._ch=this._input.next(),"\\"===this._ch&&this._input.hasNext()&&(this._ch+=this._input.next()),y=this._ch,this._ch;)if("/"===this._ch&&"*"===this._input.peek()){this._output.add_new_line(),this._input.back();var x=this._input.read(l),A=s.get_directives(x);A&&"start"===A.ignore&&(x+=s.readIgnored(this._input)),this.print_string(x),this.eatWhitespace(!0),this._output.add_new_line()}else if("/"===this._ch&&"/"===this._input.peek())this._output.space_before_token=!0,this._input.back(),this.print_string(this._input.read(h)),this.eatWhitespace(!0);else if("$"===this._ch){this.preserveSingleSpace(u),this.print_string(this._ch);var k=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);k.match(/[ :]$/)&&(k=this.eatString(": ").replace(/\s+$/,""),this.print_string(k),this._output.space_before_token=!0),0===g&&-1!==k.indexOf(":")&&(_=!0,this.indent())}else if("@"===this._ch)if(this.preserveSingleSpace(u),"{"===this._input.peek())this.print_string(this._ch+this.eatString("}"));else{this.print_string(this._ch);var T=this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);T.match(/[ :]$/)&&(T=this.eatString(": ").replace(/\s+$/,""),this.print_string(T),this._output.space_before_token=!0),0===g&&-1!==T.indexOf(":")?(_=!0,this.indent()):T in this.NESTED_AT_RULE?(this._nestedLevel+=1,T in this.CONDITIONAL_GROUP_RULE&&(m=!0)):0!==g||_||(v=!0)}else if("#"===this._ch&&"{"===this._input.peek())this.preserveSingleSpace(u),this.print_string(this._ch+this.eatString("}"));else if("{"===this._ch)_&&(_=!1,this.outdent()),v=!1,m?(m=!1,f=this._indentLevel>=this._nestedLevel):f=this._indentLevel>=this._nestedLevel-1,this._options.newline_between_rules&&f&&this._output.previous_line&&"{"!==this._output.previous_line.item(-1)&&this._output.ensure_empty_line_above("/",","),this._output.space_before_token=!0,"expand"===this._options.brace_style?(this._output.add_new_line(),this.print_string(this._ch),this.indent(),this._output.set_indent(this._indentLevel)):("("===p?this._output.space_before_token=!1:","!==p&&this.indent(),this.print_string(this._ch)),this.eatWhitespace(!0),this._output.add_new_line();else if("}"===this._ch)this.outdent(),this._output.add_new_line(),"{"===p&&this._output.trim(!0),_&&(this.outdent(),_=!1),this.print_string(this._ch),f=!1,this._nestedLevel&&this._nestedLevel--,this.eatWhitespace(!0),this._output.add_new_line(),this._options.newline_between_rules&&!this._output.just_added_blankline()&&"}"!==this._input.peek()&&this._output.add_new_line(!0),")"===this._input.peek()&&(this._output.trim(!0),"expand"===this._options.brace_style&&this._output.add_new_line(!0));else if(":"===this._ch){for(var S=0;S<this.NON_SEMICOLON_NEWLINE_PROPERTY.length;S++)if(this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[S])){w=!0;break}!f&&!m||this._input.lookBack("&")||this.foundNestedPseudoClass()||this._input.lookBack("(")||v||0!==g?(this._input.lookBack(" ")&&(this._output.space_before_token=!0),":"===this._input.peek()?(this._ch=this._input.next(),this.print_string("::")):this.print_string(":")):(this.print_string(":"),_||(_=!0,this._output.space_before_token=!0,this.eatWhitespace(!0),this.indent()))}else if('"'===this._ch||"'"===this._ch){var E='"'===p||"'"===p;this.preserveSingleSpace(E||u),this.print_string(this._ch+this.eatString(this._ch)),this.eatWhitespace(!0)}else if(";"===this._ch)w=!1,0===g?(_&&(this.outdent(),_=!1),v=!1,this.print_string(this._ch),this.eatWhitespace(!0),"/"!==this._input.peek()&&this._output.add_new_line()):(this.print_string(this._ch),this.eatWhitespace(!0),this._output.space_before_token=!0);else if("("===this._ch)if(this._input.lookBack("url"))this.print_string(this._ch),this.eatWhitespace(),g++,this.indent(),this._ch=this._input.next(),")"===this._ch||'"'===this._ch||"'"===this._ch?this._input.back():this._ch&&(this.print_string(this._ch+this.eatString(")")),g&&(g--,this.outdent()));else{var C=!1;this._input.lookBack("with")&&(C=!0),this.preserveSingleSpace(u||C),this.print_string(this._ch),_&&"$"===p&&this._options.selector_separator_newline?(this._output.add_new_line(),b=!0):(this.eatWhitespace(),g++,this.indent())}else if(")"===this._ch)g&&(g--,this.outdent()),b&&";"===this._input.peek()&&this._options.selector_separator_newline&&(b=!1,this.outdent(),this._output.add_new_line()),this.print_string(this._ch);else if(","===this._ch)this.print_string(this._ch),this.eatWhitespace(!0),!this._options.selector_separator_newline||_&&!b||0!==g||v?this._output.space_before_token=!0:this._output.add_new_line();else if(">"!==this._ch&&"+"!==this._ch&&"~"!==this._ch||_||0!==g)if("]"===this._ch)this.print_string(this._ch);else if("["===this._ch)this.preserveSingleSpace(u),this.print_string(this._ch);else if("="===this._ch)this.eatWhitespace(),this.print_string("="),r.test(this._ch)&&(this._ch="");else if("!"!==this._ch||this._input.lookBack("\\")){var R='"'===p||"'"===p;this.preserveSingleSpace(R||u),this.print_string(this._ch),!this._output.just_added_newline()&&"\n"===this._input.peek()&&w&&this._output.add_new_line()}else this._output.space_before_token=!0,this.print_string(this._ch);else this._options.space_around_combinator?(this._output.space_before_token=!0,this.print_string(this._ch),this._output.space_before_token=!0):(this.print_string(this._ch),this.eatWhitespace(),this._ch&&r.test(this._ch)&&(this._ch=""));return this._output.get_code(c)},Bt.Beautifier=c,Bt}().Beautifier,e=zt().Options;return Ft.exports=function(e,i){return new t(e,i).beautify()},Ft.exports.defaultOptions=function(){return new e},Ft.exports}var Ut,Ht={exports:{}},$t={},Wt={};function Gt(){if(Ut)return Wt;Ut=1;var t=ot().Options;function e(e){t.call(this,e,"html"),1===this.templating.length&&"auto"===this.templating[0]&&(this.templating=["django","erb","handlebars","php"]),this.indent_inner_html=this._get_boolean("indent_inner_html"),this.indent_body_inner_html=this._get_boolean("indent_body_inner_html",!0),this.indent_head_inner_html=this._get_boolean("indent_head_inner_html",!0),this.indent_handlebars=this._get_boolean("indent_handlebars",!0),this.wrap_attributes=this._get_selection("wrap_attributes",["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"]),this.wrap_attributes_min_attrs=this._get_number("wrap_attributes_min_attrs",2),this.wrap_attributes_indent_size=this._get_number("wrap_attributes_indent_size",this.indent_size),this.extra_liners=this._get_array("extra_liners",["head","body","/html"]),this.inline=this._get_array("inline",["a","abbr","area","audio","b","bdi","bdo","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","s","samp","select","small","span","strong","sub","sup","svg","template","textarea","time","u","var","video","wbr","text","acronym","big","strike","tt"]),this.inline_custom_elements=this._get_boolean("inline_custom_elements",!0),this.void_elements=this._get_array("void_elements",["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr","!doctype","?xml","basefont","isindex"]),this.unformatted=this._get_array("unformatted",[]),this.content_unformatted=this._get_array("content_unformatted",["pre","textarea"]),this.unformatted_content_delimiter=this._get_characters("unformatted_content_delimiter"),this.indent_scripts=this._get_selection("indent_scripts",["normal","keep","separate"])}return e.prototype=new t,Wt.Options=e,Wt}var qt,Kt,Xt,Yt,Qt={};function Jt(){if(qt)return Qt;qt=1;var t=xt().Tokenizer,e=xt().TOKEN,i=Tt().Directives,s=Pt().TemplatablePattern,n=wt().Pattern,a={TAG_OPEN:"TK_TAG_OPEN",TAG_CLOSE:"TK_TAG_CLOSE",CONTROL_FLOW_OPEN:"TK_CONTROL_FLOW_OPEN",CONTROL_FLOW_CLOSE:"TK_CONTROL_FLOW_CLOSE",ATTRIBUTE:"TK_ATTRIBUTE",EQUALS:"TK_EQUALS",VALUE:"TK_VALUE",COMMENT:"TK_COMMENT",TEXT:"TK_TEXT",UNKNOWN:"TK_UNKNOWN",START:e.START,RAW:e.RAW,EOF:e.EOF},r=new i(/<\!--/,/-->/),o=function(e,i){t.call(this,e,i),this._current_tag_name="";var a=new s(this._input).read_options(this._options),r=new n(this._input);if(this.__patterns={word:a.until(/[\n\r\t <]/),word_control_flow_close_excluded:a.until(/[\n\r\t <}]/),single_quote:a.until_after(/'/),double_quote:a.until_after(/"/),attribute:a.until(/[\n\r\t =>]|\/>/),element_name:a.until(/[\n\r\t >\/]/),angular_control_flow_start:r.matching(/\@[a-zA-Z]+[^({]*[({]/),handlebars_comment:r.starting_with(/{{!--/).until_after(/--}}/),handlebars:r.starting_with(/{{/).until_after(/}}/),handlebars_open:r.until(/[\n\r\t }]/),handlebars_raw_close:r.until(/}}/),comment:r.starting_with(/<!--/).until_after(/-->/),cdata:r.starting_with(/<!\[CDATA\[/).until_after(/]]>/),conditional_comment:r.starting_with(/<!\[/).until_after(/]>/),processing:r.starting_with(/<\?/).until_after(/\?>/)},this._options.indent_handlebars&&(this.__patterns.word=this.__patterns.word.exclude("handlebars"),this.__patterns.word_control_flow_close_excluded=this.__patterns.word_control_flow_close_excluded.exclude("handlebars")),this._unformatted_content_delimiter=null,this._options.unformatted_content_delimiter){var o=this._input.get_literal_regexp(this._options.unformatted_content_delimiter);this.__patterns.unformatted_content_delimiter=r.matching(o).until_after(o)}};return(o.prototype=new t)._is_comment=function(t){return!1},o.prototype._is_opening=function(t){return t.type===a.TAG_OPEN||t.type===a.CONTROL_FLOW_OPEN},o.prototype._is_closing=function(t,e){return t.type===a.TAG_CLOSE&&e&&((">"===t.text||"/>"===t.text)&&"<"===e.text[0]||"}}"===t.text&&"{"===e.text[0]&&"{"===e.text[1])||t.type===a.CONTROL_FLOW_CLOSE&&"}"===t.text&&e.text.endsWith("{")},o.prototype._reset=function(){this._current_tag_name=""},o.prototype._get_next_token=function(t,e){var i=null;this._readWhitespace();var s=this._input.peek();return null===s?this._create_token(a.EOF,""):i=(i=(i=(i=(i=(i=(i=(i=(i=(i=(i=i||this._read_open_handlebars(s,e))||this._read_attribute(s,t,e))||this._read_close(s,e))||this._read_script_and_style(s,t))||this._read_control_flows(s,e))||this._read_raw_content(s,t,e))||this._read_content_word(s,e))||this._read_comment_or_cdata(s))||this._read_processing(s))||this._read_open(s,e))||this._create_token(a.UNKNOWN,this._input.next())},o.prototype._read_comment_or_cdata=function(t){var e=null,i=null,s=null;"<"===t&&("!"===this._input.peek(1)&&((i=this.__patterns.comment.read())?(s=r.get_directives(i))&&"start"===s.ignore&&(i+=r.readIgnored(this._input)):i=this.__patterns.cdata.read()),i&&((e=this._create_token(a.COMMENT,i)).directives=s));return e},o.prototype._read_processing=function(t){var e=null,i=null;if("<"===t){var s=this._input.peek(1);"!"!==s&&"?"!==s||(i=(i=this.__patterns.conditional_comment.read())||this.__patterns.processing.read()),i&&((e=this._create_token(a.COMMENT,i)).directives=null)}return e},o.prototype._read_open=function(t,e){var i=null,s=null;return e&&e.type!==a.CONTROL_FLOW_OPEN||"<"===t&&(i=this._input.next(),"/"===this._input.peek()&&(i+=this._input.next()),i+=this.__patterns.element_name.read(),s=this._create_token(a.TAG_OPEN,i)),s},o.prototype._read_open_handlebars=function(t,e){var i=null,s=null;return e&&e.type!==a.CONTROL_FLOW_OPEN||(this._options.templating.includes("angular")||this._options.indent_handlebars)&&"{"===t&&"{"===this._input.peek(1)&&(this._options.indent_handlebars&&"!"===this._input.peek(2)?(i=(i=this.__patterns.handlebars_comment.read())||this.__patterns.handlebars.read(),s=this._create_token(a.COMMENT,i)):(i=this.__patterns.handlebars_open.read(),s=this._create_token(a.TAG_OPEN,i))),s},o.prototype._read_control_flows=function(t,e){var i="",s=null;if(!this._options.templating.includes("angular"))return s;if("@"===t){if(""===(i=this.__patterns.angular_control_flow_start.read()))return s;for(var n=i.endsWith("(")?1:0,r=0;!i.endsWith("{")||n!==r;){var o=this._input.next();if(null===o)break;"("===o?n++:")"===o&&r++,i+=o}s=this._create_token(a.CONTROL_FLOW_OPEN,i)}else"}"===t&&e&&e.type===a.CONTROL_FLOW_OPEN&&(i=this._input.next(),s=this._create_token(a.CONTROL_FLOW_CLOSE,i));return s},o.prototype._read_close=function(t,e){var i=null,s=null;return e&&e.type===a.TAG_OPEN&&("<"===e.text[0]&&(">"===t||"/"===t&&">"===this._input.peek(1))?(i=this._input.next(),"/"===t&&(i+=this._input.next()),s=this._create_token(a.TAG_CLOSE,i)):"{"===e.text[0]&&"}"===t&&"}"===this._input.peek(1)&&(this._input.next(),this._input.next(),s=this._create_token(a.TAG_CLOSE,"}}"))),s},o.prototype._read_attribute=function(t,e,i){var s=null,n="";if(i&&"<"===i.text[0])if("="===t)s=this._create_token(a.EQUALS,this._input.next());else if('"'===t||"'"===t){var r=this._input.next();r+='"'===t?this.__patterns.double_quote.read():this.__patterns.single_quote.read(),s=this._create_token(a.VALUE,r)}else(n=this.__patterns.attribute.read())&&(s=e.type===a.EQUALS?this._create_token(a.VALUE,n):this._create_token(a.ATTRIBUTE,n));return s},o.prototype._is_content_unformatted=function(t){return-1===this._options.void_elements.indexOf(t)&&(-1!==this._options.content_unformatted.indexOf(t)||-1!==this._options.unformatted.indexOf(t))},o.prototype._read_raw_content=function(t,e,i){var s="";if(i&&"{"===i.text[0])s=this.__patterns.handlebars_raw_close.read();else if(e.type===a.TAG_CLOSE&&"<"===e.opened.text[0]&&"/"!==e.text[0]){var n=e.opened.text.substr(1).toLowerCase();this._is_content_unformatted(n)&&(s=this._input.readUntil(new RegExp("</"+n+"[\\n\\r\\t ]*?>","ig")))}return s?this._create_token(a.TEXT,s):null},o.prototype._read_script_and_style=function(t,e){if(e.type===a.TAG_CLOSE&&"<"===e.opened.text[0]&&"/"!==e.text[0]){var i=e.opened.text.substr(1).toLowerCase();if("script"===i||"style"===i){var s=this._read_comment_or_cdata(t);if(s)return s.type=a.TEXT,s;var n=this._input.readUntil(new RegExp("</"+i+"[\\n\\r\\t ]*?>","ig"));if(n)return this._create_token(a.TEXT,n)}}return null},o.prototype._read_content_word=function(t,e){var i="";return this._options.unformatted_content_delimiter&&t===this._options.unformatted_content_delimiter[0]&&(i=this.__patterns.unformatted_content_delimiter.read()),i||(i=e&&e.type===a.CONTROL_FLOW_OPEN?this.__patterns.word_control_flow_close_excluded.read():this.__patterns.word.read()),i?this._create_token(a.TEXT,i):null},Qt.Tokenizer=o,Qt.TOKEN=a,Qt}function Zt(){if(Kt)return $t;Kt=1;var t=Gt().Options,e=Y().Output,i=Jt().Tokenizer,s=Jt().TOKEN,n=/\r\n|[\r\n]/,a=/\r\n|[\r\n]/g,r=function(t,i){this.indent_level=0,this.alignment_size=0,this.max_preserve_newlines=t.max_preserve_newlines,this.preserve_newlines=t.preserve_newlines,this._output=new e(t,i)};r.prototype.current_line_has_match=function(t){return this._output.current_line.has_match(t)},r.prototype.set_space_before_token=function(t,e){this._output.space_before_token=t,this._output.non_breaking_space=e},r.prototype.set_wrap_point=function(){this._output.set_indent(this.indent_level,this.alignment_size),this._output.set_wrap_point()},r.prototype.add_raw_token=function(t){this._output.add_raw_token(t)},r.prototype.print_preserved_newlines=function(t){var e=0;t.type!==s.TEXT&&t.previous.type!==s.TEXT&&(e=t.newlines?1:0),this.preserve_newlines&&(e=t.newlines<this.max_preserve_newlines+1?t.newlines:this.max_preserve_newlines+1);for(var i=0;i<e;i++)this.print_newline(i>0);return 0!==e},r.prototype.traverse_whitespace=function(t){return!(!t.whitespace_before&&!t.newlines)&&(this.print_preserved_newlines(t)||(this._output.space_before_token=!0),!0)},r.prototype.previous_token_wrapped=function(){return this._output.previous_token_wrapped},r.prototype.print_newline=function(t){this._output.add_new_line(t)},r.prototype.print_token=function(t){t.text&&(this._output.set_indent(this.indent_level,this.alignment_size),this._output.add_token(t.text))},r.prototype.indent=function(){this.indent_level++},r.prototype.deindent=function(){this.indent_level>0&&(this.indent_level--,this._output.set_indent(this.indent_level,this.alignment_size))},r.prototype.get_full_indent=function(t){return(t=this.indent_level+(t||0))<1?"":this._output.get_indent_string(t)};var o=function(t,e){var i=null,n=null;return e.closed?("script"===t?i="text/javascript":"style"===t&&(i="text/css"),i=function(t){for(var e=null,i=t.next;i.type!==s.EOF&&t.closed!==i;){if(i.type===s.ATTRIBUTE&&"type"===i.text){i.next&&i.next.type===s.EQUALS&&i.next.next&&i.next.next.type===s.VALUE&&(e=i.next.next.text);break}i=i.next}return e}(e)||i,i.search("text/css")>-1?n="css":i.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/)>-1?n="javascript":i.search(/(text|application|dojo)\/(x-)?(html)/)>-1?n="html":i.search(/test\/null/)>-1&&(n="null"),n):null};function l(t,e){return-1!==e.indexOf(t)}function h(t,e,i){this.parent=t||null,this.tag=e?e.tag_name:"",this.indent_level=i||0,this.parser_token=e||null}function c(t){this._printer=t,this._current_frame=null}function d(e,i,s,n){this._source_text=e||"",i=i||{},this._js_beautify=s,this._css_beautify=n,this._tag_stack=null;var a=new t(i,"html");this._options=a,this._is_wrap_attributes_force="force"===this._options.wrap_attributes.substr(0,5),this._is_wrap_attributes_force_expand_multiline="force-expand-multiline"===this._options.wrap_attributes,this._is_wrap_attributes_force_aligned="force-aligned"===this._options.wrap_attributes,this._is_wrap_attributes_aligned_multiple="aligned-multiple"===this._options.wrap_attributes,this._is_wrap_attributes_preserve="preserve"===this._options.wrap_attributes.substr(0,8),this._is_wrap_attributes_preserve_aligned="preserve-aligned"===this._options.wrap_attributes}c.prototype.get_parser_token=function(){return this._current_frame?this._current_frame.parser_token:null},c.prototype.record_tag=function(t){var e=new h(this._current_frame,t,this._printer.indent_level);this._current_frame=e},c.prototype._try_pop_frame=function(t){var e=null;return t&&(e=t.parser_token,this._printer.indent_level=t.indent_level,this._current_frame=t.parent),e},c.prototype._get_frame=function(t,e){for(var i=this._current_frame;i&&-1===t.indexOf(i.tag);){if(e&&-1!==e.indexOf(i.tag)){i=null;break}i=i.parent}return i},c.prototype.try_pop=function(t,e){var i=this._get_frame([t],e);return this._try_pop_frame(i)},c.prototype.indent_to_tag=function(t){var e=this._get_frame(t);e&&(this._printer.indent_level=e.indent_level)},d.prototype.beautify=function(){if(this._options.disabled)return this._source_text;var t=this._source_text,e=this._options.eol;"auto"===this._options.eol&&(e="\n",t&&n.test(t)&&(e=t.match(n)[0]));var o=(t=t.replace(a,"\n")).match(/^[\t ]*/)[0],l={text:"",type:""},h=new u(this._options),d=new r(this._options,o),p=new i(t,this._options).tokenize();this._tag_stack=new c(d);for(var g=null,f=p.next();f.type!==s.EOF;)f.type===s.TAG_OPEN||f.type===s.COMMENT?h=g=this._handle_tag_open(d,f,h,l,p):f.type===s.ATTRIBUTE||f.type===s.EQUALS||f.type===s.VALUE||f.type===s.TEXT&&!h.tag_complete?g=this._handle_inside_tag(d,f,h,l):f.type===s.TAG_CLOSE?g=this._handle_tag_close(d,f,h):f.type===s.TEXT?g=this._handle_text(d,f,h):f.type===s.CONTROL_FLOW_OPEN?g=this._handle_control_flow_open(d,f):f.type===s.CONTROL_FLOW_CLOSE?g=this._handle_control_flow_close(d,f):d.add_raw_token(f),l=g,f=p.next();return d._output.get_code(e)},d.prototype._handle_control_flow_open=function(t,e){var i={text:e.text,type:e.type};return t.set_space_before_token(e.newlines||""!==e.whitespace_before,!0),e.newlines?t.print_preserved_newlines(e):t.set_space_before_token(e.newlines||""!==e.whitespace_before,!0),t.print_token(e),t.indent(),i},d.prototype._handle_control_flow_close=function(t,e){var i={text:e.text,type:e.type};return t.deindent(),e.newlines?t.print_preserved_newlines(e):t.set_space_before_token(e.newlines||""!==e.whitespace_before,!0),t.print_token(e),i},d.prototype._handle_tag_close=function(t,e,i){var s={text:e.text,type:e.type};return t.alignment_size=0,i.tag_complete=!0,t.set_space_before_token(e.newlines||""!==e.whitespace_before,!0),i.is_unformatted?t.add_raw_token(e):("<"===i.tag_start_char&&(t.set_space_before_token("/"===e.text[0],!0),this._is_wrap_attributes_force_expand_multiline&&i.has_wrapped_attrs&&t.print_newline(!1)),t.print_token(e)),!i.indent_content||i.is_unformatted||i.is_content_unformatted||(t.indent(),i.indent_content=!1),i.is_inline_element||i.is_unformatted||i.is_content_unformatted||t.set_wrap_point(),s},d.prototype._handle_inside_tag=function(t,e,i,n){var a=i.has_wrapped_attrs,r={text:e.text,type:e.type};return t.set_space_before_token(e.newlines||""!==e.whitespace_before,!0),i.is_unformatted?t.add_raw_token(e):"{"===i.tag_start_char&&e.type===s.TEXT?t.print_preserved_newlines(e)?(e.newlines=0,t.add_raw_token(e)):t.print_token(e):(e.type===s.ATTRIBUTE?t.set_space_before_token(!0):(e.type===s.EQUALS||e.type===s.VALUE&&e.previous.type===s.EQUALS)&&t.set_space_before_token(!1),e.type===s.ATTRIBUTE&&"<"===i.tag_start_char&&((this._is_wrap_attributes_preserve||this._is_wrap_attributes_preserve_aligned)&&(t.traverse_whitespace(e),a=a||0!==e.newlines),this._is_wrap_attributes_force&&i.attr_count>=this._options.wrap_attributes_min_attrs&&(n.type!==s.TAG_OPEN||this._is_wrap_attributes_force_expand_multiline)&&(t.print_newline(!1),a=!0)),t.print_token(e),a=a||t.previous_token_wrapped(),i.has_wrapped_attrs=a),r},d.prototype._handle_text=function(t,e,i){var s={text:e.text,type:"TK_CONTENT"};return i.custom_beautifier_name?this._print_custom_beatifier_text(t,e,i):i.is_unformatted||i.is_content_unformatted?t.add_raw_token(e):(t.traverse_whitespace(e),t.print_token(e)),s},d.prototype._print_custom_beatifier_text=function(t,e,i){var s=this;if(""!==e.text){var n,a=e.text,r=1,o="",l="";"javascript"===i.custom_beautifier_name&&"function"==typeof this._js_beautify?n=this._js_beautify:"css"===i.custom_beautifier_name&&"function"==typeof this._css_beautify?n=this._css_beautify:"html"===i.custom_beautifier_name&&(n=function(t,e){return new d(t,e,s._js_beautify,s._css_beautify).beautify()}),"keep"===this._options.indent_scripts?r=0:"separate"===this._options.indent_scripts&&(r=-t.indent_level);var h=t.get_full_indent(r);if(a=a.replace(/\n[ \t]*$/,""),"html"!==i.custom_beautifier_name&&"<"===a[0]&&a.match(/^(<!--|<!\[CDATA\[)/)){var c=/^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(a);if(!c)return void t.add_raw_token(e);o=h+c[1]+"\n",a=c[4],c[5]&&(l=h+c[5]),a=a.replace(/\n[ \t]*$/,""),(c[2]||-1!==c[3].indexOf("\n"))&&(c=c[3].match(/[ \t]+$/))&&(e.whitespace_before=c[0])}if(a)if(n){var u=function(){this.eol="\n"};u.prototype=this._options.raw_options,a=n(h+a,new u)}else{var p=e.whitespace_before;p&&(a=a.replace(new RegExp("\n("+p+")?","g"),"\n")),a=h+a.replace(/\n/g,"\n"+h)}o&&(a=a?o+a+"\n"+l:o+l),t.print_newline(!1),a&&(e.text=a,e.whitespace_before="",e.newlines=0,t.add_raw_token(e),t.print_newline(!0))}},d.prototype._handle_tag_open=function(t,e,i,n,a){var r=this._get_tag_open_token(e);if(!i.is_unformatted&&!i.is_content_unformatted||i.is_empty_element||e.type!==s.TAG_OPEN||r.is_start_tag?(t.traverse_whitespace(e),this._set_tag_position(t,e,r,i,n),r.is_inline_element||t.set_wrap_point(),t.print_token(e)):(t.add_raw_token(e),r.start_tag_token=this._tag_stack.try_pop(r.tag_name)),r.is_start_tag&&this._is_wrap_attributes_force){var o,l=0;do{(o=a.peek(l)).type===s.ATTRIBUTE&&(r.attr_count+=1),l+=1}while(o.type!==s.EOF&&o.type!==s.TAG_CLOSE)}return(this._is_wrap_attributes_force_aligned||this._is_wrap_attributes_aligned_multiple||this._is_wrap_attributes_preserve_aligned)&&(r.alignment_size=e.text.length+1),r.tag_complete||r.is_unformatted||(t.alignment_size=r.alignment_size),r};var u=function(t,e,i){if(this.parent=e||null,this.text="",this.type="TK_TAG_OPEN",this.tag_name="",this.is_inline_element=!1,this.is_unformatted=!1,this.is_content_unformatted=!1,this.is_empty_element=!1,this.is_start_tag=!1,this.is_end_tag=!1,this.indent_content=!1,this.multiline_content=!1,this.custom_beautifier_name=null,this.start_tag_token=null,this.attr_count=0,this.has_wrapped_attrs=!1,this.alignment_size=0,this.tag_complete=!1,this.tag_start_char="",this.tag_check="",i){var n;this.tag_start_char=i.text[0],this.text=i.text,"<"===this.tag_start_char?(n=i.text.match(/^<([^\s>]*)/),this.tag_check=n?n[1]:""):(n=i.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=n?n[1]:"",(i.text.startsWith("{{#>")||i.text.startsWith("{{~#>"))&&">"===this.tag_check[0]&&(">"===this.tag_check&&null!==i.next?this.tag_check=i.next.text.split(" ")[0]:this.tag_check=i.text.split(">")[1])),this.tag_check=this.tag_check.toLowerCase(),i.type===s.COMMENT&&(this.tag_complete=!0),this.is_start_tag="/"!==this.tag_check.charAt(0),this.tag_name=this.is_start_tag?this.tag_check:this.tag_check.substr(1),this.is_end_tag=!this.is_start_tag||i.closed&&"/>"===i.closed.text;var a=2;"{"===this.tag_start_char&&this.text.length>=3&&"~"===this.text.charAt(2)&&(a=3),this.is_end_tag=this.is_end_tag||"{"===this.tag_start_char&&(!t.indent_handlebars||this.text.length<3||/[^#\^]/.test(this.text.charAt(a)))}else this.tag_complete=!0};d.prototype._get_tag_open_token=function(t){var e=new u(this._options,this._tag_stack.get_parser_token(),t);return e.alignment_size=this._options.wrap_attributes_indent_size,e.is_end_tag=e.is_end_tag||l(e.tag_check,this._options.void_elements),e.is_empty_element=e.tag_complete||e.is_start_tag&&e.is_end_tag,e.is_unformatted=!e.tag_complete&&l(e.tag_check,this._options.unformatted),e.is_content_unformatted=!e.is_empty_element&&l(e.tag_check,this._options.content_unformatted),e.is_inline_element=l(e.tag_name,this._options.inline)||this._options.inline_custom_elements&&e.tag_name.includes("-")||"{"===e.tag_start_char,e},d.prototype._set_tag_position=function(t,e,i,n,a){if(i.is_empty_element||(i.is_end_tag?i.start_tag_token=this._tag_stack.try_pop(i.tag_name):(this._do_optional_end_element(i)&&(i.is_inline_element||t.print_newline(!1)),this._tag_stack.record_tag(i),"script"!==i.tag_name&&"style"!==i.tag_name||i.is_unformatted||i.is_content_unformatted||(i.custom_beautifier_name=o(i.tag_check,e)))),l(i.tag_check,this._options.extra_liners)&&(t.print_newline(!1),t._output.just_added_blankline()||t.print_newline(!0)),i.is_empty_element){if("{"===i.tag_start_char&&"else"===i.tag_check)this._tag_stack.indent_to_tag(["if","unless","each"]),i.indent_content=!0,t.current_line_has_match(/{{#if/)||t.print_newline(!1);"!--"===i.tag_name&&a.type===s.TAG_CLOSE&&n.is_end_tag&&-1===i.text.indexOf("\n")||(i.is_inline_element||i.is_unformatted||t.print_newline(!1),this._calcluate_parent_multiline(t,i))}else if(i.is_end_tag){var r=!1;r=(r=i.start_tag_token&&i.start_tag_token.multiline_content)||!i.is_inline_element&&!(n.is_inline_element||n.is_unformatted)&&!(a.type===s.TAG_CLOSE&&i.start_tag_token===n)&&"TK_CONTENT"!==a.type,(i.is_content_unformatted||i.is_unformatted)&&(r=!1),r&&t.print_newline(!1)}else i.indent_content=!i.custom_beautifier_name,"<"===i.tag_start_char&&("html"===i.tag_name?i.indent_content=this._options.indent_inner_html:"head"===i.tag_name?i.indent_content=this._options.indent_head_inner_html:"body"===i.tag_name&&(i.indent_content=this._options.indent_body_inner_html)),i.is_inline_element||i.is_unformatted||"TK_CONTENT"===a.type&&!i.is_content_unformatted||t.print_newline(!1),this._calcluate_parent_multiline(t,i)},d.prototype._calcluate_parent_multiline=function(t,e){!e.parent||!t._output.just_added_newline()||(e.is_inline_element||e.is_unformatted)&&e.parent.is_inline_element||(e.parent.multiline_content=!0)};var p=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","menu","nav","ol","p","pre","section","table","ul"],g=["a","audio","del","ins","map","noscript","video"];return d.prototype._do_optional_end_element=function(t){var e=null;if(!t.is_empty_element&&t.is_start_tag&&t.parent){if("body"===t.tag_name)e=e||this._tag_stack.try_pop("head");else if("li"===t.tag_name)e=e||this._tag_stack.try_pop("li",["ol","ul","menu"]);else if("dd"===t.tag_name||"dt"===t.tag_name)e=(e=e||this._tag_stack.try_pop("dt",["dl"]))||this._tag_stack.try_pop("dd",["dl"]);else if("p"===t.parent.tag_name&&-1!==p.indexOf(t.tag_name)){var i=t.parent.parent;i&&-1!==g.indexOf(i.tag_name)||(e=e||this._tag_stack.try_pop("p"))}else"rp"===t.tag_name||"rt"===t.tag_name?e=(e=e||this._tag_stack.try_pop("rt",["ruby","rtc"]))||this._tag_stack.try_pop("rp",["ruby","rtc"]):"optgroup"===t.tag_name?e=e||this._tag_stack.try_pop("optgroup",["select"]):"option"===t.tag_name?e=e||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):"colgroup"===t.tag_name?e=e||this._tag_stack.try_pop("caption",["table"]):"thead"===t.tag_name?e=(e=e||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]):"tbody"===t.tag_name||"tfoot"===t.tag_name?e=(e=(e=(e=e||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("thead",["table"]))||this._tag_stack.try_pop("tbody",["table"]):"tr"===t.tag_name?e=(e=(e=e||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"]):"th"!==t.tag_name&&"td"!==t.tag_name||(e=(e=e||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]))||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"]));return t.parent=this._tag_stack.get_parser_token(),e}},$t.Beautifier=d,$t}function te(){if(Yt)return G;Yt=1;var t=function(){if(Rt)return q.exports;Rt=1;var t=Dt().Beautifier,e=lt().Options;return q.exports=function(e,i){return new t(e,i).beautify()},q.exports.defaultOptions=function(){return new e},q.exports}(),e=Vt(),i=function(){if(Xt)return Ht.exports;Xt=1;var t=Zt().Beautifier,e=Gt().Options;return Ht.exports=function(e,i,s,n){return new t(e,i,s,n).beautify()},Ht.exports.defaultOptions=function(){return new e},Ht.exports}();function s(s,n,a,r){return i(s,n,a=a||t,r=r||e)}return s.defaultOptions=i.defaultOptions,G.js=t,G.css=e,G.html=s,G}!function(t){var e,i,s,n,a=te();a.js_beautify=a.js,a.css_beautify=a.css,a.html_beautify=a.html,t.exports=(e=a,i=a,s=a,n=function(t,i){return e.js_beautify(t,i)},n.js=e.js_beautify,n.css=i.css_beautify,n.html=s.html_beautify,n.js_beautify=e.js_beautify,n.css_beautify=i.css_beautify,n.html_beautify=s.html_beautify,n)}(W);class ee{constructor(t,e,i,s,n){this.kind=t,this.input=e,this.begin=i,this.end=s,this.file=n}getText(){return this.input.slice(this.begin,this.end)}getPosition(){let[t,e]=[1,1];for(let i=0;i<this.begin;i++)"\n"===this.input[i]?(t++,e=1):e++;return[t,e]}size(){return this.end-this.begin}}class ie{liquidMethodMissing(t){}}const se=Object.prototype.toString,ne=String.prototype.toLowerCase,ae=Object.hasOwnProperty;function re(t){return"string"==typeof t}function oe(t){return"function"==typeof t}function le(t){return t&&oe(t.then)}function he(t){return t&&oe(t.next)&&oe(t.throw)&&oe(t.return)}function ce(t){return re(t=pe(t))?t:me(t)?"":ve(t)?t.map((t=>ce(t))).join(""):String(t)}function de(t){return ve(t=pe(t))?t:re(t)&&t.length>0?[t]:xe(e=t)&&Symbol.iterator in e?Array.from(t):xe(t)?Object.keys(t).map((e=>[e,t[e]])):[];var e}function ue(t){return me(t=pe(t))?[]:ve(t)?t:[t]}function pe(t){return t instanceof ie&&oe(t.valueOf)?t.valueOf():t}function ge(t){return t=Number(t),isNaN(t)?0:t}function fe(t){return"number"==typeof t}function _e(t){return t&&oe(t.toLiquid)?_e(t.toLiquid()):t}function me(t){return null==t}function ve(t){return"[object Array]"===se.call(t)}function be(t){return t&&fe(t.length)}function ye(t,e){t=t||{};for(const i in t)if(ae.call(t,i)&&!1===e(t[i],i,t))break;return t}function we(t){return t[t.length-1]}function xe(t){const e=typeof t;return null!==t&&("object"===e||"function"===e)}function Ae(t,e,i=1){const s=[];for(let n=t;n<e;n+=i)s.push(n);return s}function ke(t,e,i=" "){return Te(t,e,i,((t,e)=>e+t))}function Te(t,e,i,s){let n=e-(t=String(t)).length;for(;n-- >0;)t=s(t,i);return t}function Se(t){return t}function Ee(t,e){return null==t&&null==e?0:null==t?1:null==e||(t=ne.call(t))<(e=ne.call(e))?-1:t>e?1:0}function Ce(t){return function(...e){return t.call(this,...e.map(pe))}}function Re(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function*Me(t){const e=new Set;for(const i of t){const t=JSON.stringify(i);e.has(t)||(e.add(t),yield i)}}const Pe="__liquidClass__";class Le extends Error{constructor(t,e){super("string"==typeof t?t:t.message),this.context="","string"!=typeof t&&Object.defineProperty(this,"originalError",{value:t,enumerable:!1}),Object.defineProperty(this,"token",{value:e,enumerable:!1}),Object.defineProperty(this,Pe,{value:"LiquidError",enumerable:!1})}update(){Object.defineProperty(this,"context",{value:ze(this.token),enumerable:!1}),this.message=function(t,e){e.file&&(t+=`, file:${e.file}`);const[i,s]=e.getPosition();return t+=`, line:${i}, col:${s}`}(this.message,this.token),this.stack=this.message+"\n"+this.context+"\n"+this.stack,this.originalError&&(this.stack+="\nFrom "+this.originalError.stack)}static is(t){return"LiquidError"===(null==t?void 0:t[Pe])}}class De extends Le{constructor(t,e){super(t,e),this.name="TokenizationError",super.update()}}class Ie extends Le{constructor(t,e){super(t,e),this.name="ParseError",this.message=t.message,super.update()}}class Oe extends Le{constructor(t,e){super(t,e.token),this.name="RenderError",this.message=t.message,super.update()}static is(t){return"RenderError"===t.name}}class Ne extends Le{constructor(t){super(t[0],t[0].token),this.errors=t,this.name="LiquidErrors";const e=t.length>1?"s":"";this.message=`${t.length} error${e} found`,super.update()}static is(t){return"LiquidErrors"===t.name}}class Fe extends Le{constructor(t,e){super(t,e),this.name="UndefinedVariableError",this.message=t.message,super.update()}}class Be extends Error{constructor(t){super(`undefined variable: ${t}`),this.name="InternalUndefinedVariableError",this.variableName=t}}class je extends Error{constructor(t){super(t),this.name="AssertionError",this.message=t+""}}function ze(t){const[e,i]=t.getPosition(),s=t.input.split("\n"),n=Math.max(e-2,1),a=Math.min(e+3,s.length);return Ae(n,a+1).map((t=>{let n=`${t===e?">> ":" "}${ke(String(t),String(a).length)}| `;const r=t===e?"\n"+ke("^",i+n.length):"";return n+=s[t-1],n+=r,n})).join("\n")}const Ve=[0,0,0,0,0,0,0,0,0,20,4,4,4,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,2,8,0,0,0,0,8,0,0,0,64,0,65,0,0,33,33,33,33,33,33,33,33,33,33,0,0,2,2,2,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0];function Ue(t){const e=t.charCodeAt(0);return e>=128?!Ve[e]:!!(1&Ve[e])}function He(t,e){if(!t){const i="function"==typeof e?e():e||`expect ${t} to be true`;throw new je(i)}}function $e(t,e=`unexpected ${JSON.stringify(t)}`){He(!t,e)}Ve[160]=Ve[5760]=Ve[6158]=Ve[8192]=Ve[8193]=Ve[8194]=Ve[8195]=Ve[8196]=Ve[8197]=Ve[8198]=Ve[8199]=Ve[8200]=Ve[8201]=Ve[8202]=Ve[8232]=Ve[8233]=Ve[8239]=Ve[8287]=Ve[12288]=4,Ve[8220]=Ve[8221]=128;class We extends ie{equals(t){return!(t instanceof We)&&(re(t=pe(t))||ve(t)?0===t.length:!!xe(t)&&0===Object.keys(t).length)}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return""}static is(t){return t instanceof We}}class Ge extends We{equals(t){return!1===t||(!!me(pe(t))||(re(t)?/^\s*$/.test(t):super.equals(t)))}static is(t){return t instanceof Ge}}class qe extends ie{constructor(t,e,i){super(),this.i=0,this.length=t,this.name=`${i}-${e}`}next(){this.i++}index0(){return this.i}index(){return this.i+1}first(){return 0===this.i}last(){return this.i===this.length-1}rindex(){return this.length-this.i}rindex0(){return this.length-this.i-1}valueOf(){return JSON.stringify(this)}}class Ke{constructor(){this.buffer=""}write(t){this.buffer+=ce(t)}}class Xe{constructor(){throw this.buffer="",this.stream=null,new Error("streaming not supported in browser")}}class Ye{constructor(){this.buffer=""}write(t){"string"!=typeof(t=pe(t))&&""===this.buffer?this.buffer=t:this.buffer=ce(this.buffer)+ce(t)}}class Qe extends ie{constructor(t=()=>""){super(),this.superBlockRender=t}*super(){const t=new Ke;return yield this.superBlockRender(t),t.buffer}}function Je(t){return t&&oe(t.equals)&&oe(t.gt)&&oe(t.geq)&&oe(t.lt)&&oe(t.leq)}const Ze=new class extends ie{equals(t){return me(pe(t))}gt(){return!1}geq(){return!1}lt(){return!1}leq(){return!1}valueOf(){return null}},ti={true:!0,false:!1,nil:Ze,null:Ze,empty:new We,blank:new Ge};function ei(t){const e={};for(const[i,s]of Object.entries(t)){let t=e;for(let e=0;e<i.length;e++){const s=i[e];t[s]=t[s]||{},e===i.length-1&&Ue(i[e])&&(t[s].needBoundary=!0),t=t[s]}t.data=s,t.end=!0}return e}var ii=function(){return ii=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},ii.apply(this,arguments)};function si(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((s=s.apply(t,e||[])).next())}))}function ni(t){return si(this,void 0,void 0,(function*(){if(!he(t))return t;let e,i=!1,s="next";do{const n=t[s](e);i=n.done,e=n.value,s="next";try{he(e)&&(e=ni(e)),le(e)&&(e=yield e)}catch(t){s="throw",e=t}}while(!i);return e}))}function ai(t){if(!he(t))return t;let e,i=!1,s="next";do{const n=t[s](e);if(i=n.done,e=n.value,s="next",he(e))try{e=ai(e)}catch(t){s="throw",e=t}}while(!i);return e}const ri=/%([-_0^#:]+)?(\d+)?([EO])?(.)/;function oi(t){const e=function(t){const e=t.getFullYear();return!(3&e||!(e%100||e%400==0&&e))}(t)?29:28;return[31,e,31,30,31,30,31,31,30,31,30,31]}function li(t){let e=0;for(let i=0;i<t.getMonth();++i)e+=oi(t)[i];return e+t.getDate()}function hi(t,e){const i=li(t)+(e-t.getDay()),s=7-new Date(t.getFullYear(),0,1).getDay()+e;return String(Math.floor((i-s)/7)+1)}const ci={d:2,e:2,H:2,I:2,j:3,k:2,l:2,L:3,m:2,M:2,S:2,U:2,W:2},di=new Set("aAbBceklpP");function ui(t,e){const i=Math.abs(t.getTimezoneOffset()),s=Math.floor(i/60),n=i%60;return(t.getTimezoneOffset()>0?"-":"+")+ke(s,2,"0")+(e.flags[":"]?":":"")+ke(n,2,"0")}const pi={a:t=>t.getShortWeekdayName(),A:t=>t.getLongWeekdayName(),b:t=>t.getShortMonthName(),B:t=>t.getLongMonthName(),c:t=>t.toLocaleString(),C:t=>function(t){return parseInt(t.getFullYear().toString().substring(0,2),10)}(t),d:t=>t.getDate(),e:t=>t.getDate(),H:t=>t.getHours(),I:t=>String(t.getHours()%12||12),j:t=>li(t),k:t=>t.getHours(),l:t=>String(t.getHours()%12||12),L:t=>t.getMilliseconds(),m:t=>t.getMonth()+1,M:t=>t.getMinutes(),N:(t,e)=>{const i=Number(e.width)||9;return function(t,e,i=" "){return Te(t,e,i,((t,e)=>t+e))}(String(t.getMilliseconds()).slice(0,i),i,"0")},p:t=>t.getHours()<12?"AM":"PM",P:t=>t.getHours()<12?"am":"pm",q:t=>function(t){const e=t.getDate();if([11,12,13].includes(e))return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}(t),s:t=>Math.round(t.getTime()/1e3),S:t=>t.getSeconds(),u:t=>t.getDay()||7,U:t=>hi(t,0),w:t=>t.getDay(),W:t=>hi(t,1),x:t=>t.toLocaleDateString(),X:t=>t.toLocaleTimeString(),y:t=>t.getFullYear().toString().slice(2,4),Y:t=>t.getFullYear(),z:ui,Z:(t,e)=>t.getTimeZoneName()||ui(t,e),t:()=>"\t",n:()=>"\n","%":()=>"%"};function gi(t,e){let i,s="",n=e;for(;i=ri.exec(n);)s+=n.slice(0,i.index),n=n.slice(i.index+i[0].length),s+=fi(t,i);return s+n}function fi(t,e){const[i,s="",n,a,r]=e,o=pi[r];if(!o)return i;const l={};for(const t of s)l[t]=!0;let h=String(o(t,{flags:l,width:n,modifier:a})),c=di.has(r)?" ":"0",d=n||ci[r]||0;var u;return l["^"]?h=h.toUpperCase():l["#"]&&(u=h,h=[...u].some((t=>t>="a"&&t<="z"))?u.toUpperCase():u.toLowerCase()),l._?c=" ":l[0]&&(c="0"),l["-"]&&(d=0),ke(h,d,c)}function _i(){return"undefined"!=typeof Intl?Intl.DateTimeFormat:void 0}pi.h=pi.b;const mi=/([zZ]|([+-])(\d{2}):?(\d{2}))$/,vi=["January","February","March","April","May","June","July","August","September","October","November","December"],bi=vi.map((t=>t.slice(0,3))),yi=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],wi=yi.map((t=>t.slice(0,3)));class xi{constructor(t,e,i){this.locale=e,this.DateTimeFormat=_i(),this.date=new Date(t),this.timezoneFixed=void 0!==i,void 0===i&&(i=this.date.getTimezoneOffset()),this.timezoneOffset=re(i)?xi.getTimezoneOffset(i,this.date):i,this.timezoneName=re(i)?i:"";const s=6e4*(this.date.getTimezoneOffset()-this.timezoneOffset),n=this.date.getTime()+s;this.displayDate=new Date(n)}getTime(){return this.displayDate.getTime()}getMilliseconds(){return this.displayDate.getMilliseconds()}getSeconds(){return this.displayDate.getSeconds()}getMinutes(){return this.displayDate.getMinutes()}getHours(){return this.displayDate.getHours()}getDay(){return this.displayDate.getDay()}getDate(){return this.displayDate.getDate()}getMonth(){return this.displayDate.getMonth()}getFullYear(){return this.displayDate.getFullYear()}toLocaleString(t,e){return(null==e?void 0:e.timeZone)?this.date.toLocaleString(t,e):this.displayDate.toLocaleString(t,e)}toLocaleTimeString(t){return this.displayDate.toLocaleTimeString(t)}toLocaleDateString(t){return this.displayDate.toLocaleDateString(t)}getTimezoneOffset(){return this.timezoneOffset}getTimeZoneName(){return this.timezoneFixed?this.timezoneName:this.DateTimeFormat?this.DateTimeFormat().resolvedOptions().timeZone:void 0}getLongMonthName(){var t;return null!==(t=this.format({month:"long"}))&&void 0!==t?t:vi[this.getMonth()]}getShortMonthName(){var t;return null!==(t=this.format({month:"short"}))&&void 0!==t?t:bi[this.getMonth()]}getLongWeekdayName(){var t;return null!==(t=this.format({weekday:"long"}))&&void 0!==t?t:yi[this.displayDate.getDay()]}getShortWeekdayName(){var t;return null!==(t=this.format({weekday:"short"}))&&void 0!==t?t:wi[this.displayDate.getDay()]}valid(){return!isNaN(this.getTime())}format(t){return this.DateTimeFormat&&this.DateTimeFormat(this.locale,t).format(this.displayDate)}static createDateFixedToTimezone(t,e){const i=t.match(mi);if(i&&"Z"===i[1])return new xi(+new Date(t),e,0);if(i&&i[2]&&i[3]&&i[4]){const[,,s,n,a]=i,r=("+"===s?-1:1)*(60*parseInt(n,10)+parseInt(a,10));return new xi(+new Date(t),e,r)}return new xi(t,e)}static getTimezoneOffset(t,e){const i=e.toLocaleString("en-US",{timeZone:t}),s=e.toLocaleString("en-US",{timeZone:"UTC"}),n=new Date(i);return(+new Date(s)-+n)/6e4}}class Ai{constructor(t,e){this.base=0,this.message=`${t} limit exceeded`,this.limit=e}use(t){t=ge(t),He(this.base+t<=this.limit,this.message),this.base+=t}check(t){He((t=ge(t))<=this.limit,this.message)}}class ki extends ee{constructor(t,[e,i],s,n,a,r,o,l){super(t,s,n,a,l),this.trimLeft=!1,this.trimRight=!1;const h="-"===s[e],c="-"===s[i-1];let d=h?e+1:e,u=c?i-1:i;for(;d<u&&4&Ve[s.charCodeAt(d)];)d++;for(;u>d&&4&Ve[s.charCodeAt(u-1)];)u--;this.contentRange=[d,u],this.trimLeft=h||r,this.trimRight=c||o}get content(){return this.input.slice(this.contentRange[0],this.contentRange[1])}}class Ti extends ki{constructor(t,e,i,s,n){const{trimTagLeft:a,trimTagRight:r,tagDelimiterLeft:o,tagDelimiterRight:l}=s,[h,c]=[e+o.length,i-l.length];super(Vs.Tag,[h,c],t,e,i,a,r,n),this.tokenizer=new vs(t,s.operators,n,this.contentRange),this.name=this.tokenizer.readTagName(),this.tokenizer.assert(this.name,"illegal tag syntax, tag name expected"),this.tokenizer.skipBlank(),this.args=this.tokenizer.input.slice(this.tokenizer.p,this.contentRange[1])}}class Si extends ki{constructor(t,e,i,s,n){const{trimOutputLeft:a,trimOutputRight:r,outputDelimiterLeft:o,outputDelimiterRight:l}=s,h=[e+o.length,i-l.length];super(Vs.Output,h,t,e,i,a,r,n)}}class Ei extends ee{constructor(t,e,i,s){super(Vs.HTML,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.trimLeft=0,this.trimRight=0}getContent(){return this.input.slice(this.begin+this.trimLeft,this.end-this.trimRight)}}class Ci extends ee{constructor(t,e,i,s){super(Vs.Number,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.content=Number(this.getText())}}class Ri extends ee{constructor(t,e,i,s){super(Vs.Word,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.content=this.getText()}}class Mi extends ee{constructor(t,e,i,s){super(Vs.Literal,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.literal=this.getText(),this.content=ti[this.literal]}}const Pi={"==":2,"!=":2,">":2,"<":2,">=":2,"<=":2,contains:2,not:1,and:0,or:0},Li={"==":0,"!=":0,">":0,"<":0,">=":0,"<=":0,contains:0,not:1,and:0,or:0};class Di extends ee{constructor(t,e,i,s){super(Vs.Operator,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.operator=this.getText()}getPrecedence(){const t=this.getText();return t in Pi?Pi[t]:1}}class Ii extends ee{constructor(t,e,i,s,n,a){super(Vs.PropertyAccess,i,s,n,a),this.variable=t,this.props=e}}class Oi extends ee{constructor(t,e,i,s,n,a){super(Vs.Filter,i,s,n,a),this.name=t,this.args=e}}class Ni extends ee{constructor(t,e,i,s,n,a){super(Vs.Hash,t,e,i,a),this.input=t,this.begin=e,this.end=i,this.name=s,this.value=n,this.file=a}}const Fi=/[\da-fA-F]/,Bi=/[0-7]/,ji={b:"\b",f:"\f",n:"\n",r:"\r",t:"\t",v:"\v"};function zi(t){const e=t.charCodeAt(0);return e>=97?e-87:e>=65?e-55:e-48}class Vi extends ee{constructor(t,e,i,s){super(Vs.Quoted,t,e,i,s),this.input=t,this.begin=e,this.end=i,this.file=s,this.content=function(t){let e="";for(let i=1;i<t.length-1;i++)if("\\"===t[i])if(void 0!==ji[t[i+1]])e+=ji[t[++i]];else if("u"===t[i+1]){let s=0,n=i+2;for(;n<=i+5&&Fi.test(t[n]);)s=16*s+zi(t[n++]);i=n-1,e+=String.fromCharCode(s)}else if(Bi.test(t[i+1])){let s=i+1,n=0;for(;s<=i+3&&Bi.test(t[s]);)n=8*n+zi(t[s++]);i=s-1,e+=String.fromCharCode(n)}else e+=t[++i];else e+=t[i];return e}(this.getText())}}class Ui extends ee{constructor(t,e,i,s,n,a){super(Vs.Range,t,e,i,a),this.input=t,this.begin=e,this.end=i,this.lhs=s,this.rhs=n,this.file=a}}class Hi extends ki{constructor(t,e,i,s,n){super(Vs.Tag,[e,i],t,e,i,!1,!1,n),this.tokenizer=new vs(t,s.operators,n,this.contentRange),this.name=this.tokenizer.readTagName(),this.tokenizer.assert(this.name,"illegal liquid tag syntax"),this.tokenizer.skipBlank()}get args(){return this.tokenizer.input.slice(this.tokenizer.p,this.contentRange[1])}}class $i extends ee{constructor(t,e,i,s,n,a){super(Vs.FilteredValue,i,s,n,a),this.initial=t,this.filters=e,this.input=i,this.begin=s,this.end=n,this.file=a}}const Wi={now:()=>Date.now()};function Gi(){return"object"==typeof global&&global.performance||"object"==typeof window&&window.performance||Wi}class qi{renderTemplatesToNodeStream(t,e){const i=new Xe;return Promise.resolve().then((()=>ni(this.renderTemplates(t,e,i)))).then((()=>i.end()),(t=>i.error(t))),i.stream}*renderTemplates(t,e,i){i||(i=e.opts.keepOutputType?new Ye:new Ke);const s=[];for(const n of t){e.renderLimit.check(Gi().now());try{const t=yield n.render(e,i);if(t&&i.write(t),e.breakCalled||e.continueCalled)break}catch(t){const i=Le.is(t)?t:new Oe(t,n);if(!e.opts.catchAllErrors)throw i;s.push(i)}}if(s.length)throw new Ne(s);return i.buffer}}class Ki{constructor(t){this.postfix=[...Yi(t)]}*evaluate(t,e){He(t,"unable to evaluate: context not defined");const i=[];for(const s of this.postfix)if(Ws(s)){const e=i.pop();let n;if(1===Li[s.operator])n=yield t.opts.operators[s.operator](e,t);else{const a=i.pop();n=yield t.opts.operators[s.operator](a,e,t)}i.push(n)}else i.push(yield Xi(s,t,e));return i[0]}valid(){return!!this.postfix.length}}function*Xi(t,e,i=!1){if(t)return"content"in t?t.content:Ys(t)?yield function*(t,e,i){const s=[];for(const i of t.props)s.push(yield Xi(i,e,!1));try{if(t.variable){const n=yield Xi(t.variable,e,i);return yield e._getFromScope(n,s)}return yield e._get(s)}catch(e){if(i&&"InternalUndefinedVariableError"===e.name)return null;throw new Fe(e,t)}}(t,e,i):Js(t)?yield function*(t,e){const i=yield Xi(t.lhs,e),s=yield Xi(t.rhs,e);return e.memoryLimit.use(s-i+1),Ae(+i,+s+1)}(t,e):void 0}function*Yi(t){const e=[];for(const i of t)if(Ws(i)){for(;e.length&&e[e.length-1].getPrecedence()>i.getPrecedence();)yield e.pop();e.push(i)}else yield i;for(;e.length;)yield e.pop()}function Qi(t,e){return!Ji(t,e)}function Ji(t,e){return t=pe(t),e.opts.jsTruthy?!t:!1===t||null==t}const Zi={"==":ts,"!=":(t,e)=>!ts(t,e),">":(t,e)=>Je(t)?t.gt(e):Je(e)?e.lt(t):pe(t)>pe(e),"<":(t,e)=>Je(t)?t.lt(e):Je(e)?e.gt(t):pe(t)<pe(e),">=":(t,e)=>Je(t)?t.geq(e):Je(e)?e.leq(t):pe(t)>=pe(e),"<=":(t,e)=>Je(t)?t.leq(e):Je(e)?e.geq(t):pe(t)<=pe(e),contains:(t,e)=>ve(t=pe(t))?t.some((t=>ts(t,e))):!!oe(null==t?void 0:t.indexOf)&&t.indexOf(pe(e))>-1,not:(t,e)=>Ji(pe(t),e),and:(t,e,i)=>Qi(pe(t),i)&&Qi(pe(e),i),or:(t,e,i)=>Qi(pe(t),i)||Qi(pe(e),i)};function ts(t,e){return Je(t)?t.equals(e):Je(e)?e.equals(t):(t=pe(t),e=pe(e),ve(t)?ve(e)&&function(t,e){return t.length===e.length&&!t.some(((t,i)=>!ts(t,e[i])))}(t,e):t===e)}let es=class{constructor(t,e,i,s){this.key=t,this.value=e,this.next=i,this.prev=s}};class is{constructor(t,e=0){this.limit=t,this.size=e,this.cache={},this.head=new es("HEAD",null,null,null),this.tail=new es("TAIL",null,null,null),this.head.next=this.tail,this.tail.prev=this.head}write(t,e){if(this.cache[t])this.cache[t].value=e;else{const i=new es(t,e,this.head.next,this.head);this.head.next.prev=i,this.head.next=i,this.cache[t]=i,this.size++,this.ensureLimit()}}read(t){if(!this.cache[t])return;const{value:e}=this.cache[t];return this.remove(t),this.write(t,e),e}remove(t){const e=this.cache[t];e.prev.next=e.next,e.next.prev=e.prev,delete this.cache[t],this.size--}clear(){this.head.next=this.tail,this.tail.prev=this.head,this.size=0,this.cache={}}ensureLimit(){this.size>this.limit&&this.remove(this.tail.prev.key)}}function ss(t,e){const i=document.createElement("base");i.href=t;const s=document.getElementsByTagName("head")[0];s.insertBefore(i,s.firstChild);const n=document.createElement("a");n.href=e;const a=n.href;return s.removeChild(i),a}var ns=Object.freeze({__proto__:null,resolve:function(t,e,i){return t.length&&"/"!==we(t)&&(t+="/"),ss(t,e).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,((t,e,s)=>{const n=s.split("/").pop();return/\.\w+$/.test(n)?t:e+s+i}))},readFile:function(t){return si(this,void 0,void 0,(function*(){return new Promise(((e,i)=>{const s=new XMLHttpRequest;s.onload=()=>{s.status>=200&&s.status<300?e(s.responseText):i(new Error(s.statusText))},s.onerror=()=>{i(new Error("An error occurred whilst receiving the response."))},s.open("GET",t),s.send()}))}))},readFileSync:function(t){const e=new XMLHttpRequest;if(e.open("GET",t,!1),e.send(),e.status<200||e.status>=300)throw new Error(e.statusText);return e.responseText},exists:function(t){return si(this,void 0,void 0,(function*(){return!0}))},existsSync:function(t){return!0},dirname:function(t){return ss(t,".")},sep:"/"});function as(t,e=0){return JSON.stringify(t,null,e)}var rs={default:function(t,e,...i){return ve(t=pe(t))||re(t)?t.length?t:e:(!1!==t||!new Map(i).get("allow_false"))&&(Ji(t,this.context)?e:t)},raw:{raw:!0,handler:Se},jsonify:as,to_integer:function(t){return Number(t)},json:as,inspect:function(t,e=0){const i=[];return JSON.stringify(t,(function(t,e){if("object"!=typeof e||null===e)return e;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(e)?"[Circular]":(i.push(e),e)}),e)}};const os={"&":"&","<":"<",">":">",'"':""","'":"'"},ls={"&":"&","<":"<",">":">",""":'"',"'":"'"};function hs(t){return t=ce(t),this.context.memoryLimit.use(t.length),t.replace(/&|<|>|"|'/g,(t=>os[t]))}function cs(t){return t=ce(t),this.context.memoryLimit.use(t.length),t.replace(/&(amp|lt|gt|#34|#39);/g,(t=>ls[t]))}var ds=Object.freeze({__proto__:null,escape:hs,xml_escape:function(t){return hs.call(this,t)},escape_once:function(t){return hs.call(this,cs.call(this,t))},newline_to_br:function(t){const e=ce(t);return this.context.memoryLimit.use(e.length),e.replace(/\r?\n/gm,"<br />\n")},strip_html:function(t){const e=ce(t);return this.context.memoryLimit.use(e.length),e.replace(/<script[\s\S]*?<\/script>|<style[\s\S]*?<\/style>|<.*?>|<!--[\s\S]*?-->/g,"")}});class us{constructor(t){this.mapping=t,this.sep="/"}exists(t){return si(this,void 0,void 0,(function*(){return this.existsSync(t)}))}existsSync(t){return!me(this.mapping[t])}readFile(t){return si(this,void 0,void 0,(function*(){return this.readFileSync(t)}))}readFileSync(t){const e=this.mapping[t];if(me(e))throw new Error(`ENOENT: ${t}`);return e}dirname(t){const e=t.split(this.sep);return e.pop(),e.join(this.sep)}resolve(t,e,i){if(e+=i,"."===t)return e;const s=t.split(/\/+/);for(const t of e.split(this.sep))"."!==t&&""!==t&&(".."===t?(s.length>1||""!==s[0])&&s.pop():s.push(t));return s.join(this.sep)}}const ps={root:["."],layouts:["."],partials:["."],relativeReference:!0,jekyllInclude:!1,keyValueSeparator:":",cache:void 0,extname:"",fs:ns,dynamicPartials:!0,jsTruthy:!1,dateFormat:"%A, %B %-e, %Y at %-l:%M %P %z",locale:"",trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",preserveTimezones:!1,strictFilters:!1,strictVariables:!1,ownPropertyOnly:!0,lenientIf:!1,globals:{},keepOutputType:!1,operators:Zi,memoryLimit:1/0,parseLimit:1/0,renderLimit:1/0};function gs(t){var e,i,s;if(t.hasOwnProperty("root")&&(t.hasOwnProperty("partials")||(t.partials=t.root),t.hasOwnProperty("layouts")||(t.layouts=t.root)),t.hasOwnProperty("cache")){let e;e="number"==typeof t.cache?t.cache>0?new is(t.cache):void 0:"object"==typeof t.cache?t.cache:t.cache?new is(1024):void 0,t.cache=e}return(t=Object.assign(Object.assign(Object.assign({},ps),t.jekyllInclude?{dynamicPartials:!1}:{}),t)).fs.dirname&&t.fs.sep||!t.relativeReference||(console.warn("[LiquidJS] `fs.dirname` and `fs.sep` are required for relativeReference, set relativeReference to `false` to suppress this warning"),t.relativeReference=!1),t.root=fs(t.root),t.partials=fs(t.partials),t.layouts=fs(t.layouts),t.outputEscape=t.outputEscape&&("escape"===(s=t.outputEscape)?hs:"json"===s?rs.json:(He(oe(s),"`outputEscape` need to be of type string or function"),s)),t.locale||(t.locale=null!==(i=null===(e=_i())||void 0===e?void 0:e().resolvedOptions().locale)&&void 0!==i?i:"en-US"),t.templates&&(t.fs=new us(t.templates),t.relativeReference=!0,t.root=t.partials=t.layouts="."),t}function fs(t){let e=[];return ve(t)&&(e=t),re(t)&&(e=[t]),e}function _s(t,e){if(!t||!Gs(t))return;const i=e?4:16;for(;Ve[t.input.charCodeAt(t.end-1-t.trimRight)]&i;)t.trimRight++}function ms(t,e){if(!t||!Gs(t))return;const i=e?4:16;for(;Ve[t.input.charCodeAt(t.begin+t.trimLeft)]&i;)t.trimLeft++;"\n"===t.input.charAt(t.begin+t.trimLeft)&&t.trimLeft++}class vs{constructor(t,e=ps.operators,i,s){this.input=t,this.file=i,this.rawBeginAt=-1,this.p=s?s[0]:0,this.N=s?s[1]:t.length,this.opTrie=ei(e),this.literalTrie=ei(ti)}readExpression(){return new Ki(this.readExpressionTokens())}*readExpressionTokens(){for(;this.p<this.N;){const t=this.readOperator();if(t){yield t;continue}const e=this.readValue();if(!e)return;yield e}}readOperator(){this.skipBlank();const t=this.matchTrie(this.opTrie);if(-1!==t)return new Di(this.input,this.p,this.p=t,this.file)}matchTrie(t){let e,i=t,s=this.p;for(;i[this.input[s]]&&s<this.N;)i=i[this.input[s++]],i.end&&(e=i);return e?e.needBoundary&&Ue(this.peek(s-this.p))?-1:s:-1}readFilteredValue(){const t=this.p,e=this.readExpression();this.assert(e.valid(),`invalid value expression: ${this.snapshot()}`);const i=this.readFilters();return new $i(e,i,this.input,t,this.p,this.file)}readFilters(){const t=[];for(;;){const e=this.readFilter();if(!e)return t;t.push(e)}}readFilter(){if(this.skipBlank(),this.end())return null;this.assert("|"===this.read(),'expected "|" before filter');const t=this.readIdentifier();if(!t.size())return this.assert(this.end(),"expected filter name"),null;const e=[];if(this.skipBlank(),":"===this.peek())do{++this.p;const t=this.readFilterArg();t&&e.push(t),this.skipBlank(),this.assert(this.end()||","===this.peek()||"|"===this.peek(),(()=>`unexpected character ${this.snapshot()}`))}while(","===this.peek());else if("|"!==this.peek()&&!this.end())throw this.error('expected ":" after filter name');return new Oi(t.getText(),e,this.input,t.begin,this.p,this.file)}readFilterArg(){const t=this.readValue();if(!t)return;if(this.skipBlank(),":"!==this.peek())return t;++this.p;const e=this.readValue();return[t.getText(),e]}readTopLevelTokens(t=ps){const e=[];for(;this.p<this.N;){const i=this.readTopLevelToken(t);e.push(i)}return function(t,e){let i=!1;for(let s=0;s<t.length;s++){const n=t[s];tn(n)&Vs.Delimited&&(!i&&n.trimLeft&&_s(t[s-1],e.greedy),qs(n)&&("raw"===n.name?i=!0:"endraw"===n.name&&(i=!1)),!i&&n.trimRight&&ms(t[s+1],e.greedy))}}(e,t),e}readTopLevelToken(t){const{tagDelimiterLeft:e,outputDelimiterLeft:i}=t;return this.rawBeginAt>-1?this.readEndrawOrRawContent(t):this.match(e)?this.readTagToken(t):this.match(i)?this.readOutputToken(t):this.readHTMLToken([e,i])}readHTMLToken(t){const e=this.p;for(;this.p<this.N&&!t.some((t=>this.match(t)));)++this.p;return new Ei(this.input,e,this.p,this.file)}readTagToken(t){const{file:e,input:i}=this,s=this.p;if(-1===this.readToDelimiter(t.tagDelimiterRight))throw this.error(`tag ${this.snapshot(s)} not closed`,s);const n=new Ti(i,s,this.p,t,e);return"raw"===n.name&&(this.rawBeginAt=s),n}readToDelimiter(t,e=!1){for(this.skipBlank();this.p<this.N;)if(e&&8&this.peekType())this.readQuoted();else if(++this.p,this.rmatch(t))return this.p;return-1}readOutputToken(t=ps){const{file:e,input:i}=this,{outputDelimiterRight:s}=t,n=this.p;if(-1===this.readToDelimiter(s,!0))throw this.error(`output ${this.snapshot(n)} not closed`,n);return new Si(i,n,this.p,t,e)}readEndrawOrRawContent(t){const{tagDelimiterLeft:e,tagDelimiterRight:i}=t,s=this.p;let n=this.readTo(e)-e.length;for(;this.p<this.N;)if("endraw"===this.readIdentifier().getText())for(;this.p<=this.N;){if(this.rmatch(i)){const e=this.p;return s===n?(this.rawBeginAt=-1,new Ti(this.input,s,e,t,this.file)):(this.p=n,new Ei(this.input,s,n,this.file))}if(this.rmatch(e))break;this.p++}else n=this.readTo(e)-e.length;throw this.error(`raw ${this.snapshot(this.rawBeginAt)} not closed`,s)}readLiquidTagTokens(t=ps){const e=[];for(;this.p<this.N;){const i=this.readLiquidTagToken(t);i&&e.push(i)}return e}readLiquidTagToken(t){if(this.skipBlank(),this.end())return;const e=this.p;this.readToDelimiter("\n");const i=this.p;return new Hi(this.input,e,i,t,this.file)}error(t,e=this.p){return new De(t,new Ri(this.input,e,this.N,this.file))}assert(t,e,i){if(!t)throw this.error("function"==typeof e?e():e,i)}snapshot(t=this.p){return JSON.stringify(function(t,e){return t.length>e?t.slice(0,e-3)+"...":t}(this.input.slice(t,this.N),32))}readWord(){return this.readIdentifier()}readIdentifier(){this.skipBlank();const t=this.p;for(;!this.end()&&Ue(this.peek());)++this.p;return new Ri(this.input,t,this.p,this.file)}readNonEmptyIdentifier(){const t=this.readIdentifier();return t.size()?t:void 0}readTagName(){return this.skipBlank(),"#"===this.input[this.p]?this.input.slice(this.p,++this.p):this.readIdentifier().getText()}readHashes(t){const e=[];for(;;){const i=this.readHash(t);if(!i)return e;e.push(i)}}readHash(t){this.skipBlank(),","===this.peek()&&++this.p;const e=this.p,i=this.readNonEmptyIdentifier();if(!i)return;let s;this.skipBlank();const n=re(t)?t:t?"=":":";return this.peek()===n&&(++this.p,s=this.readValue()),new Ni(this.input,e,this.p,i,s,this.file)}remaining(){return this.input.slice(this.p,this.N)}advance(t=1){this.p+=t}end(){return this.p>=this.N}read(){return this.input[this.p++]}readTo(t){for(;this.p<this.N;)if(++this.p,this.rmatch(t))return this.p;return-1}readValue(){this.skipBlank();const t=this.p,e=this.readLiteral()||this.readQuoted()||this.readRange()||this.readNumber(),i=this.readProperties(!e);return i.length?new Ii(e,i,this.input,t,this.p):e}readScopeValue(){this.skipBlank();const t=this.p,e=this.readProperties();if(e.length)return new Ii(void 0,e,this.input,t,this.p)}readProperties(t=!0){const e=[];for(;;)if("["!==this.peek()){if(t&&!e.length){const t=this.readNonEmptyIdentifier();if(t){e.push(t);continue}}if("."!==this.peek()||"."===this.peek(1))break;{this.p++;const t=this.readNonEmptyIdentifier();if(!t)break;e.push(t)}}else{this.p++;const t=this.readValue()||new Ri(this.input,this.p,this.p,this.file);this.assert(-1!==this.readTo("]"),"[ not closed"),e.push(t)}return e}readNumber(){this.skipBlank();let t=!1,e=!1,i=0;for(64&this.peekType()&&i++;this.p+i<=this.N;)if(32&this.peekType(i))e=!0,i++;else{if("."!==this.peek(i)||"."===this.peek(i+1))break;if(t||!e)return;t=!0,i++}if(e&&!Ue(this.peek(i))){const t=new Ci(this.input,this.p,this.p+i,this.file);return this.advance(i),t}}readLiteral(){this.skipBlank();const t=this.matchTrie(this.literalTrie);if(-1===t)return;const e=new Mi(this.input,this.p,t,this.file);return this.p=t,e}readRange(){this.skipBlank();const t=this.p;if("("!==this.peek())return;++this.p;const e=this.readValueOrThrow();this.skipBlank(),this.assert("."===this.read()&&"."===this.read(),"invalid range syntax");const i=this.readValueOrThrow();return this.skipBlank(),this.assert(")"===this.read(),"invalid range syntax"),new Ui(this.input,t,this.p,e,i,this.file)}readValueOrThrow(){const t=this.readValue();return this.assert(t,(()=>`unexpected token ${this.snapshot()}, value expected`)),t}readQuoted(){this.skipBlank();const t=this.p;if(!(8&this.peekType()))return;++this.p;let e=!1;for(;this.p<this.N&&(++this.p,this.input[this.p-1]!==this.input[t]||e);)e?e=!1:"\\"===this.input[this.p-1]&&(e=!0);return new Vi(this.input,t,this.p,this.file)}*readFileNameTemplate(t){const{outputDelimiterLeft:e}=t,i=[","," ",e],s=new Set(i);for(;this.p<this.N&&!s.has(this.peek());)yield this.match(e)?this.readOutputToken(t):this.readHTMLToken(i)}match(t){for(let e=0;e<t.length;e++)if(t[e]!==this.input[this.p+e])return!1;return!0}rmatch(t){for(let e=0;e<t.length;e++)if(t[t.length-1-e]!==this.input[this.p-1-e])return!1;return!0}peekType(t=0){return this.p+t>=this.N?0:Ve[this.input.charCodeAt(this.p+t)]}peek(t=0){return this.p+t>=this.N?"":this.input[this.p+t]}skipBlank(){for(;4&this.peekType();)++this.p}}class bs{constructor(t,e){this.handlers={},this.stopRequested=!1,this.tokens=t,this.parseToken=e}on(t,e){return this.handlers[t]=e,this}trigger(t,e){const i=this.handlers[t];return!!i&&(i.call(this,e),!0)}start(){let t;for(this.trigger("start");!this.stopRequested&&(t=this.tokens.shift());){if(this.trigger("token",t))continue;if(qs(t)&&this.trigger(`tag:${t.name}`,t))continue;const e=this.parseToken(t,this.tokens);this.trigger("template",e)}return this.stopRequested||this.trigger("end"),this}stop(){return this.stopRequested=!0,this}}class ys{constructor(t){this.token=t}}class ws extends ys{constructor(t,e,i){super(t),this.name=t.name,this.liquid=i,this.tokenizer=t.tokenizer}}class xs{constructor(t,e){this.hash={};const i=t instanceof vs?t:new vs(t,{});for(const t of i.readHashes(e))this.hash[t.name.content]=t.value}*render(t){const e={};for(const i of Object.keys(this.hash))e[i]=void 0===this.hash[i]||(yield Xi(this.hash[i],t));return e}}function As(t){return ve(t)}class ks{constructor(t,e,i){this.token=t,this.name=t.name,this.handler=oe(e)?e:oe(null==e?void 0:e.handler)?e.handler:Se,this.raw=!oe(e)&&!!(null==e?void 0:e.raw),this.args=t.args,this.liquid=i}*render(t,e){const i=[];for(const t of this.args)As(t)?i.push([t[0],yield Xi(t[1],e)]):i.push(yield Xi(t,e));return yield this.handler.apply({context:e,token:this.token,liquid:this.liquid},[t,...i])}}class Ts{constructor(t,e){this.filters=[];const i="string"==typeof t?new vs(t,e.options.operators).readFilteredValue():t;this.initial=i.initial,this.filters=i.filters.map((t=>new ks(t,this.getFilter(e,t.name),e)))}*value(t,e){e=e||t.opts.lenientIf&&this.filters.length>0&&"default"===this.filters[0].name;let i=yield this.initial.evaluate(t,e);for(const e of this.filters)i=yield e.render(i,t);return i}getFilter(t,e){const i=t.filters[e];return He(i||!t.options.strictFilters,(()=>`undefined filter: ${e}`)),i}}class Ss extends ys{constructor(t,e){var i;super(t);const s=new vs(t.input,e.options.operators,t.file,t.contentRange);this.value=new Ts(s.readFilteredValue(),e);const n=this.value.filters,a=e.options.outputEscape;if(!(null===(i=n[n.length-1])||void 0===i?void 0:i.raw)&&a){const t=new Oi(toString.call(a),[],"",0,0);n.push(new ks(t,a,e))}}*render(t,e){const i=yield this.value.value(t,!1);e.write(i)}*arguments(){yield this.value}}class Es extends ys{constructor(t){super(t),this.str=t.getContent()}*render(t,e){e.write(this.str)}}class Cs{constructor(t,e){this.segments=t,this.location=e}toString(){return js(this.segments,!0)}toArray(){return Array.from(function*t(...e){for(const i of e)i instanceof Cs?yield Array.from(t(...i.segments)):yield i}(...this.segments))}}class Rs{constructor(){this.map=new Map}get(t){const e=js([t.segments[0]]);return this.map.has(e)||this.map.set(e,[]),this.map.get(e)}has(t){return this.map.has(js([t.segments[0]]))}push(t){this.get(t).push(t)}asObject(){return Object.fromEntries(this.map)}}const Ms={partials:!0};function*Ps(t,e,i){const s=new Rs,n=new Rs,a=new Rs,r=new Is(new Set),o=new Set;function l(t,e){s.push(t);const i=e.alias(t);if(void 0!==i){const t=i.segments[0];re(t)&&!r.has(t)&&n.push(i)}else{const i=t.segments[0];re(i)&&!e.has(i)&&n.push(t)}for(const i of t.segments)i instanceof Cs&&l(i,e)}function*h(t,s){if(t.arguments)for(const e of t.arguments())for(const t of Os(e))l(t,s);if(t.localScope)for(const e of t.localScope()){s.add(e.content),s.deleteAlias(e.content);const[t,i]=e.getPosition();a.push(new Cs([e.content],{row:t,col:i,file:e.file}))}if(t.children)if(t.partialScope){const n=t.partialScope();if(void 0===n){for(const n of yield t.children(e,i))yield h(n,s);return}if(o.has(n.name))return;const a=new Set,r=n.isolated?new Is(a):s.push(a);for(const t of n.scope)if(re(t))a.add(t);else{const[e,i]=t;a.add(e);const s=Array.from(Os(i));s.length&&r.setAlias(e,s[0].segments)}for(const s of yield t.children(e,i))yield h(s,r),o.add(n.name);r.pop()}else{t.blockScope&&s.push(new Set(t.blockScope()));for(const n of yield t.children(e,i))yield h(n,s);t.blockScope&&s.pop()}}for(const e of t)yield h(e,r);return{variables:s.asObject(),globals:n.asObject(),locals:a.asObject()}}function Ls(t,e={}){return ni(Ps(t,Object.assign(Object.assign({},Ms),e).partials,!1))}function Ds(t,e={}){return ai(Ps(t,Object.assign(Object.assign({},Ms),e).partials,!0))}class Is{constructor(t){this.stack=[{names:t,aliases:new Map}]}has(t){for(const e of this.stack)if(e.names.has(t))return!0;return!1}push(t){return this.stack.push({names:t,aliases:new Map}),this}pop(){var t;return null===(t=this.stack.pop())||void 0===t?void 0:t.names}add(t){this.stack[0].names.add(t)}alias(t){const e=t.segments[0];if(!re(e))return;const i=this.getAlias(e);return void 0!==i?new Cs([...i,...t.segments.slice(1)],t.location):void 0}setAlias(t,e){this.stack[this.stack.length-1].aliases.set(t,e)}deleteAlias(t){this.stack[this.stack.length-1].aliases.delete(t)}getAlias(t){for(const e of this.stack){if(e.aliases.has(t))return e.aliases.get(t);if(e.names.has(t))return}}}function*Os(t){Zs(t)?yield*Ns(t):t instanceof Ts&&(yield*function*(t){for(const e of t.initial.postfix)Zs(e)&&(yield*Ns(e));for(const e of t.filters)for(const t of e.args)As(t)&&t[1]?yield*Ns(t[1]):Zs(t)&&(yield*Ns(t))}(t))}function*Ns(t){Js(t)?(yield*Ns(t.lhs),yield*Ns(t.rhs)):Ys(t)&&(yield Fs(t))}function Fs(t){const e=[];let i=t.file;const s=t.props[0];i=i||s.file,Ks(s)||Xs(s)||Qs(s)?e.push(s.content):Ys(s)&&e.push(...Fs(s).segments);for(const s of t.props.slice(1))i=i||s.file,Ks(s)||Xs(s)||Qs(s)?e.push(s.content):Ys(s)&&e.push(Fs(s));const[n,a]=t.getPosition();return new Cs(e,{row:n,col:a,file:i})}const Bs=/^[\u0080-\uFFFFa-zA-Z_][\u0080-\uFFFFa-zA-Z0-9_-]*$/;function js(t,e=!1){const i=[],s=t[0];re(s)&&(!e||s.match(Bs)?i.push(`${s}`):i.push(`['${s}']`));for(const e of t.slice(1))e instanceof Cs?i.push(`[${js(e.segments)}]`):re(e)?e.match(Bs)?i.push(`.${e}`):i.push(`['${e}']`):i.push(`[${e}]`);return i.join("")}var zs,Vs,Us;!function(t){t.Partials="partials",t.Layouts="layouts",t.Root="root"}(zs||(zs={}));class Hs{constructor(t){if(this.options=t,t.relativeReference){const e=t.fs.sep;He(e,"`fs.sep` is required for relative reference");const i=new RegExp(["."+e,".."+e,"./","../"].map((t=>t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))).join("|"));this.shouldLoadRelative=t=>i.test(t)}else this.shouldLoadRelative=t=>!1;this.contains=this.options.fs.contains||(()=>!0)}*lookup(t,e,i,s){const{fs:n}=this.options,a=this.options[e];for(const r of this.candidates(t,a,s,e!==zs.Root))if(i?n.existsSync(r):yield n.exists(r))return r;throw this.lookupError(t,a)}*candidates(t,e,i,s){const{fs:n,extname:a}=this.options;if(this.shouldLoadRelative(t)&&i){const r=n.resolve(this.dirname(i),t,a);for(const t of e)if(!s||this.contains(t,r)){yield r;break}}for(const i of e){const e=n.resolve(i,t,a);s&&!this.contains(i,e)||(yield e)}if(void 0!==n.fallback){const e=n.fallback(t);void 0!==e&&(yield e)}}dirname(t){const e=this.options.fs;return He(e.dirname,"`fs.dirname` is required for relative reference"),e.dirname(t)}lookupError(t,e){const i=new Error("ENOENT");return i.message=`ENOENT: Failed to lookup "${t}" in "${e}"`,i.code="ENOENT",i}}class $s{constructor(t){this.liquid=t,this.cache=this.liquid.options.cache,this.fs=this.liquid.options.fs,this.parseFile=this.cache?this._parseFileCached:this._parseFile,this.loader=new Hs(this.liquid.options),this.parseLimit=new Ai("parse length",t.options.parseLimit)}parse(t,e){t=String(t),this.parseLimit.use(t.length);const i=new vs(t,this.liquid.options.operators,e).readTopLevelTokens(this.liquid.options);return this.parseTokens(i)}parseTokens(t){let e;const i=[],s=[];for(;e=t.shift();)try{i.push(this.parseToken(e,t))}catch(t){if(!this.liquid.options.catchAllErrors)throw t;s.push(t)}if(s.length)throw new Ne(s);return i}parseToken(t,e){try{if(qs(t)){const i=this.liquid.tags[t.name];return He(i,`tag "${t.name}" not found`),new i(t,e,this.liquid,this)}return tn(t)===Vs.Output?new Ss(t,this.liquid):new Es(t)}catch(e){if(Le.is(e))throw e;throw new Ie(e,t)}}parseStream(t){return new bs(t,((t,e)=>this.parseToken(t,e)))}*_parseFileCached(t,e,i=zs.Root,s){const n=this.cache,a=this.loader.shouldLoadRelative(t)?s+","+t:i+":"+t,r=yield n.read(a);if(r)return r;const o=this._parseFile(t,e,i,s),l=e?yield o:ni(o);n.write(a,l);try{return yield l}catch(t){throw n.remove(a),t}}*_parseFile(t,e,i=zs.Root,s){const n=yield this.loader.lookup(t,i,e,s);return this.parse(e?this.fs.readFileSync(n):yield this.fs.readFile(n),n)}}function Ws(t){return tn(t)===Vs.Operator}function Gs(t){return tn(t)===Vs.HTML}function qs(t){return tn(t)===Vs.Tag}function Ks(t){return tn(t)===Vs.Quoted}function Xs(t){return tn(t)===Vs.Number}function Ys(t){return tn(t)===Vs.PropertyAccess}function Qs(t){return tn(t)===Vs.Word}function Js(t){return tn(t)===Vs.Range}function Zs(t){return(1667&tn(t))>0}function tn(t){return t?t.kind:-1}!function(t){t[t.Number=1]="Number",t[t.Literal=2]="Literal",t[t.Tag=4]="Tag",t[t.Output=8]="Output",t[t.HTML=16]="HTML",t[t.Filter=32]="Filter",t[t.Hash=64]="Hash",t[t.PropertyAccess=128]="PropertyAccess",t[t.Word=256]="Word",t[t.Range=512]="Range",t[t.Quoted=1024]="Quoted",t[t.Operator=2048]="Operator",t[t.FilteredValue=4096]="FilteredValue",t[t.Delimited=12]="Delimited"}(Vs||(Vs={}));class en{constructor(t={},e=ps,i={},{memoryLimit:s,renderLimit:n}={}){var a,r,o,l,h;this.scopes=[{}],this.registers={},this.breakCalled=!1,this.continueCalled=!1,this.sync=!!i.sync,this.opts=e,this.globals=null!==(a=i.globals)&&void 0!==a?a:e.globals,this.environments=xe(t)?t:Object(t),this.strictVariables=null!==(r=i.strictVariables)&&void 0!==r?r:this.opts.strictVariables,this.ownPropertyOnly=null!==(o=i.ownPropertyOnly)&&void 0!==o?o:e.ownPropertyOnly,this.memoryLimit=null!=s?s:new Ai("memory alloc",null!==(l=i.memoryLimit)&&void 0!==l?l:e.memoryLimit),this.renderLimit=null!=n?n:new Ai("template render",Gi().now()+(null!==(h=i.renderLimit)&&void 0!==h?h:e.renderLimit))}getRegister(t){return this.registers[t]=this.registers[t]||{}}setRegister(t,e){return this.registers[t]=e}saveRegister(...t){return t.map((t=>[t,this.getRegister(t)]))}restoreRegister(t){return t.forEach((([t,e])=>this.setRegister(t,e)))}getAll(){return[this.globals,this.environments,...this.scopes].reduce(((t,e)=>ii(t,e)),{})}get(t){return this.getSync(t)}getSync(t){return ai(this._get(t))}*_get(t){const e=this.findScope(t[0]);return yield this._getFromScope(e,t)}getFromScope(t,e){return ai(this._getFromScope(t,e))}*_getFromScope(t,e,i=this.strictVariables){re(e)&&(e=e.split("."));for(let s=0;s<e.length;s++)if(t=yield sn(t,e[s],this.ownPropertyOnly),i&&void 0===t)throw new Be(e.slice(0,s+1).join("."));return t}push(t){return this.scopes.push(t)}pop(){return this.scopes.pop()}bottom(){return this.scopes[0]}spawn(t={}){return new en(t,this.opts,{sync:this.sync,globals:this.globals,strictVariables:this.strictVariables},{renderLimit:this.renderLimit,memoryLimit:this.memoryLimit})}findScope(t){for(let e=this.scopes.length-1;e>=0;e--){const i=this.scopes[e];if(t in i)return i}return t in this.environments?this.environments:this.globals}}function sn(t,e,i){if(t=_e(t),e=pe(e),me(t))return t;if(ve(t)&&e<0)return t[t.length+ +e];const s=function(t,e,i){return!i||ae.call(t,e)||t instanceof ie?t[e]:void 0}(t,e,i);return void 0===s&&t instanceof ie?t.liquidMethodMissing(e):oe(s)?s.call(t):"size"===e?function(t){if(ae.call(t,"size")||void 0!==t.size)return t.size;if(ve(t)||re(t))return t.length;if("object"==typeof t)return Object.keys(t).length}(t):"first"===e?function(t){return ve(t)?t[0]:t.first}(t):"last"===e?function(t){return ve(t)?t[t.length-1]:t.last}(t):s}!function(t){t[t.OUTPUT=0]="OUTPUT",t[t.STORE=1]="STORE"}(Us||(Us={}));const nn=Ce(Math.abs),an=Ce(Math.max),rn=Ce(Math.min),on=Ce(Math.ceil),ln=Ce(((t,e,i=!1)=>i?Math.floor(t/e):t/e)),hn=Ce(Math.floor),cn=Ce(((t,e)=>t-e)),dn=Ce(((t,e)=>t%e)),un=Ce(((t,e)=>t*e));var pn=Object.freeze({__proto__:null,abs:nn,at_least:an,at_most:rn,ceil:on,divided_by:ln,floor:hn,minus:cn,modulo:dn,times:un,round:function(t,e=0){t=pe(t),e=pe(e);const i=Math.pow(10,e);return Math.round(t*i)/i},plus:function(t,e){return t=pe(t),e=pe(e),Number(t)+Number(e)}});const gn=/[^\p{M}\p{L}\p{Nd}]+/gu,fn={raw:/\s+/g,default:gn,pretty:/[^\p{M}\p{L}\p{Nd}._~!$&'()+,;=@]+/gu,ascii:/[^A-Za-z0-9]+/g,latin:gn,none:null};var _n=Object.freeze({__proto__:null,url_decode:t=>decodeURIComponent(ce(t)).replace(/\+/g," "),url_encode:t=>encodeURIComponent(ce(t)).replace(/%20/g,"+"),cgi_escape:t=>encodeURIComponent(ce(t)).replace(/%20/g,"+").replace(/[!'()*]/g,(t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())),uri_escape:t=>encodeURI(ce(t)).replace(/%5B/g,"[").replace(/%5D/g,"]"),slugify:function(t,e="default",i=!1){t=ce(t);const s=fn[e];return s&&("latin"===e&&(t=function(t){return t.replace(/[àáâãäå]/g,"a").replace(/[æ]/g,"ae").replace(/[ç]/g,"c").replace(/[èéêë]/g,"e").replace(/[ìíîï]/g,"i").replace(/[ð]/g,"d").replace(/[ñ]/g,"n").replace(/[òóôõöø]/g,"o").replace(/[ùúûü]/g,"u").replace(/[ýÿ]/g,"y").replace(/[ß]/g,"ss").replace(/[œ]/g,"oe").replace(/[þ]/g,"th").replace(/[ẞ]/g,"SS").replace(/[Œ]/g,"OE").replace(/[Þ]/g,"TH")}(t)),t=t.replace(s,"-").replace(/^-|-$/g,"")),i?t:t.toLowerCase()}});const mn=Ce((function(t,e){const i=ue(t),s=me(e)?" ":ce(e),n=i.length*(1+s.length);return this.context.memoryLimit.use(n),i.join(s)})),vn=Ce((t=>be(t)?we(t):"")),bn=Ce((t=>be(t)?t[0]:"")),yn=Ce((function(t){const e=ue(t);return this.context.memoryLimit.use(e.length),[...e].reverse()}));function wn(t,e=[]){const i=ue(t),s=ue(e);return this.context.memoryLimit.use(i.length+s.length),i.concat(s)}function xn(t){return this.context.opts.jekyllWhere?e=>{return We.is(t)?ts(e,t):ve(e)?(i=t,e.some((t=>ts(t,i)))):ts(e,t);var i}:void 0===t?t=>Qi(t,this.context):e=>ts(e,t)}function*An(t,e,i,s){const n=[];e=ue(e),this.context.memoryLimit.use(e.length);const a=new vs(ce(i)).readScopeValue();for(const t of e)n.push(yield Xi(a,this.context.spawn(t)));const r=xn.call(this,s);return e.filter(((e,i)=>r(n[i])===t))}function*kn(t,e,i,s){const n=[],a=new Ts(ce(s),this.liquid),r=ue(e);this.context.memoryLimit.use(r.length);for(const e of r){this.context.push({[i]:e});const s=yield a.value(this.context);this.context.pop(),s===t&&n.push(e)}return n}function*Tn(t,e,i){const s=new vs(ce(e)).readScopeValue(),n=ue(t),a=xn.call(this,i);for(let t=0;t<n.length;t++){if(a(yield Xi(s,this.context.spawn(n[t]))))return[t,n[t]]}}function*Sn(t,e,i){const s=new Ts(ce(i),this.liquid),n=ue(t);for(let t=0;t<n.length;t++){this.context.push({[e]:n[t]});const i=yield s.value(this.context);if(this.context.pop(),i)return[t,n[t]]}}var En=Object.freeze({__proto__:null,join:mn,last:vn,first:bn,reverse:yn,sort:function*(t,e){const i=[],s=ue(t);this.context.memoryLimit.use(s.length);for(const t of s)i.push([t,e?yield this.context._getFromScope(t,ce(e).split("."),!1):t]);return i.sort(((t,e)=>{const i=t[1],s=e[1];return i<s?-1:i>s?1:0})).map((t=>t[0]))},sort_natural:function(t,e){const i=ce(e),s=void 0===e?Ee:(t,e)=>Ee(t[i],e[i]),n=ue(t);return this.context.memoryLimit.use(n.length),[...n].sort(s)},size:t=>t&&t.length||0,map:function*(t,e){const i=[],s=ue(t);this.context.memoryLimit.use(s.length);for(const t of s)i.push(yield this.context._getFromScope(t,ce(e),!1));return i},sum:function*(t,e){let i=0;const s=ue(t);for(const t of s){const s=Number(e?yield this.context._getFromScope(t,ce(e),!1):t);i+=Number.isNaN(s)?0:s}return i},compact:function(t){const e=ue(t);return this.context.memoryLimit.use(e.length),e.filter((t=>!me(pe(t))))},concat:wn,push:function(t,e){return wn.call(this,t,[e])},unshift:function(t,e){const i=ue(t);this.context.memoryLimit.use(i.length);const s=[...i];return s.unshift(e),s},pop:function(t){const e=[...ue(t)];return e.pop(),e},shift:function(t){const e=ue(t);this.context.memoryLimit.use(e.length);const i=[...e];return i.shift(),i},slice:function(t,e,i=1){return me(t=pe(t))?[]:(ve(t)||(t=ce(t)),e=e<0?t.length+e:e,this.context.memoryLimit.use(i),t.slice(e,e+i))},where:function*(t,e,i){return yield*An.call(this,!0,t,e,i)},reject:function*(t,e,i){return yield*An.call(this,!1,t,e,i)},where_exp:function*(t,e,i){return yield*kn.call(this,!0,t,e,i)},reject_exp:function*(t,e,i){return yield*kn.call(this,!1,t,e,i)},group_by:function*(t,e){const i=new Map;t=de(t);const s=new vs(ce(e)).readScopeValue();this.context.memoryLimit.use(t.length);for(const e of t){const t=yield Xi(s,this.context.spawn(e));i.has(t)||i.set(t,[]),i.get(t).push(e)}return[...i.entries()].map((([t,e])=>({name:t,items:e})))},group_by_exp:function*(t,e,i){const s=new Map,n=new Ts(ce(i),this.liquid);t=de(t),this.context.memoryLimit.use(t.length);for(const i of t){this.context.push({[e]:i});const t=yield n.value(this.context);this.context.pop(),s.has(t)||s.set(t,[]),s.get(t).push(i)}return[...s.entries()].map((([t,e])=>({name:t,items:e})))},has:function*(t,e,i){return!!(yield*Tn.call(this,t,e,i))},has_exp:function*(t,e,i){return!!(yield*Sn.call(this,t,e,i))},find_index:function*(t,e,i){const s=yield*Tn.call(this,t,e,i);return s?s[0]:void 0},find_index_exp:function*(t,e,i){const s=yield*Sn.call(this,t,e,i);return s?s[0]:void 0},find:function*(t,e,i){const s=yield*Tn.call(this,t,e,i);return s?s[1]:void 0},find_exp:function*(t,e,i){const s=yield*Sn.call(this,t,e,i);return s?s[1]:void 0},uniq:function(t){return t=ue(t),this.context.memoryLimit.use(t.length),[...new Set(t)]},sample:function(t,e=1){if(me(t=pe(t)))return[];ve(t)||(t=ce(t)),this.context.memoryLimit.use(e);const i=[...t].sort((()=>Math.random()-.5));return 1===e?i[0]:i.slice(0,e)}});function Cn(t,e,i){var s,n,a;const r=(null!==(s=null==t?void 0:t.length)&&void 0!==s?s:0)+(null!==(n=null==e?void 0:e.length)&&void 0!==n?n:0)+(null!==(a=null==i?void 0:i.length)&&void 0!==a?a:0);this.context.memoryLimit.use(r);const o=Mn(t,this.context.opts,i);return o?gi(o,e=me(e=pe(e))?this.context.opts.dateFormat:ce(e)):t}function Rn(t,e,i,s){const n=Mn(t,this.context.opts);if(!n)return t;if("ordinal"===i){const t=n.getDate();return gi(n,"US"===s?`${e} ${t}%q, %Y`:`${t}%q ${e} %Y`)}return gi(n,`%d ${e} %Y`)}function Mn(t,e,i){let s;const n=null!=i?i:e.timezoneOffset,a=e.locale;return s="now"===(t=pe(t))||"today"===t?new xi(Date.now(),a,n):fe(t)?new xi(1e3*t,a,n):re(t)?/^\d+$/.test(t)?new xi(1e3*+t,a,n):e.preserveTimezones&&void 0===i?xi.createDateFixedToTimezone(t,a):new xi(t,a,n):new xi(t,a,n),s.valid()?s:void 0}var Pn=Object.freeze({__proto__:null,date:Cn,date_to_xmlschema:function(t){return Cn.call(this,t,"%Y-%m-%dT%H:%M:%S%:z")},date_to_rfc822:function(t){return Cn.call(this,t,"%a, %d %b %Y %H:%M:%S %z")},date_to_string:function(t,e,i){return Rn.call(this,t,"%b",e,i)},date_to_long_string:function(t,e,i){return Rn.call(this,t,"%B",e,i)}});const Ln=/[\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/gu,Dn=/[^\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF\s]+/gu;var In=Object.freeze({__proto__:null,append:function(t,e){He(2===arguments.length,"append expect 2 arguments");const i=ce(t),s=ce(e);return this.context.memoryLimit.use(i.length+s.length),i+s},prepend:function(t,e){He(2===arguments.length,"prepend expect 2 arguments");const i=ce(t),s=ce(e);return this.context.memoryLimit.use(i.length+s.length),s+i},lstrip:function(t,e){const i=ce(t);return this.context.memoryLimit.use(i.length),e?(e=Re(ce(e)),i.replace(new RegExp(`^[${e}]+`,"g"),"")):i.replace(/^\s+/,"")},downcase:function(t){const e=ce(t);return this.context.memoryLimit.use(e.length),e.toLowerCase()},upcase:function(t){const e=ce(t);return this.context.memoryLimit.use(e.length),ce(e).toUpperCase()},remove:function(t,e){const i=ce(t);return this.context.memoryLimit.use(i.length),i.split(ce(e)).join("")},remove_first:function(t,e){const i=ce(t);return this.context.memoryLimit.use(i.length),i.replace(ce(e),"")},remove_last:function(t,e){const i=ce(t);this.context.memoryLimit.use(i.length);const s=ce(e),n=i.lastIndexOf(s);return-1===n?i:i.substring(0,n)+i.substring(n+s.length)},rstrip:function(t,e){return t=ce(t),this.context.memoryLimit.use(t.length),e?(e=Re(ce(e)),t.replace(new RegExp(`[${e}]+$`,"g"),"")):t.replace(/\s+$/,"")},split:function(t,e){const i=ce(t);this.context.memoryLimit.use(i.length);const s=i.split(ce(e));for(;s.length&&""===s[s.length-1];)s.pop();return s},strip:function(t,e){const i=ce(t);return this.context.memoryLimit.use(i.length),e?(e=Re(ce(e)),i.replace(new RegExp(`^[${e}]+`,"g"),"").replace(new RegExp(`[${e}]+$`,"g"),"")):i.trim()},strip_newlines:function(t){const e=ce(t);return this.context.memoryLimit.use(e.length),e.replace(/\r?\n/gm,"")},capitalize:function(t){return t=ce(t),this.context.memoryLimit.use(t.length),t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()},replace:function(t,e,i){const s=ce(t);return this.context.memoryLimit.use(s.length),s.split(ce(e)).join(i)},replace_first:function(t,e,i){const s=ce(t);return this.context.memoryLimit.use(s.length),s.replace(ce(e),i)},replace_last:function(t,e,i){const s=ce(t);this.context.memoryLimit.use(s.length);const n=ce(e),a=s.lastIndexOf(n);if(-1===a)return s;const r=ce(i);return s.substring(0,a)+r+s.substring(a+n.length)},truncate:function(t,e=50,i="..."){const s=ce(t);return this.context.memoryLimit.use(s.length),s.length<=e?t:s.substring(0,e-i.length)+i},truncatewords:function(t,e=15,i="..."){const s=ce(t);this.context.memoryLimit.use(s.length);const n=s.split(/\s+/);e<=0&&(e=1);let a=n.slice(0,e).join(" ");return n.length>=e&&(a+=i),a},normalize_whitespace:function(t){const e=ce(t);return this.context.memoryLimit.use(e.length),e.replace(/\s+/g," ")},number_of_words:function(t,e){const i=ce(t);if(this.context.memoryLimit.use(i.length),!(t=i.trim()))return 0;switch(e){case"cjk":return(t.match(Ln)||[]).length+(t.match(Dn)||[]).length;case"auto":return Ln.test(t)?t.match(Ln).length+(t.match(Dn)||[]).length:t.split(/\s+/).length;default:return t.split(/\s+/).length}},array_to_sentence_string:function(t,e="and"){switch(this.context.memoryLimit.use(t.length),t.length){case 0:return"";case 1:return t[0];case 2:return`${t[0]} ${e} ${t[1]}`;default:return`${t.slice(0,-1).join(", ")}, ${e} ${t[t.length-1]}`}}});const On=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ds),pn),_n),En),Pn),In),rs);const Nn=["offset","limit","reversed"];function Fn(t,e,i){if(e.options.dynamicPartials){const e=t.readValue();if(t.assert(e,"illegal file path"),"none"===e.getText())return;if(Ks(e)){const t=i.parse(function(t){return t.content}(e));return Bn(t)}return e}const s=[...t.readFileNameTemplate(e.options)],n=Bn(i.parseTokens(s));return"none"===n?void 0:n}function Bn(t){return 1===t.length&&Gs(t[0].token)?t[0].token.getContent():t}function*jn(t,e,i){return"string"==typeof t?t:Array.isArray(t)?i.renderer.renderTemplates(t,e):yield Xi(t,e)}class zn extends qe{constructor(t,e,i,s){super(t,i,s),this.length=t,this.cols=e}row(){return Math.floor(this.i/this.cols)+1}col0(){return this.i%this.cols}col(){return this.col0()+1}col_first(){return 0===this.col0()}col_last(){return this.col()===this.cols}}const Vn={assign:class extends ws{constructor(t,e,i){super(t,e,i),this.identifier=this.tokenizer.readIdentifier(),this.key=this.identifier.content,this.tokenizer.assert(this.key,"expected variable name"),this.tokenizer.skipBlank(),this.tokenizer.assert("="===this.tokenizer.peek(),'expected "="'),this.tokenizer.advance(),this.value=new Ts(this.tokenizer.readFilteredValue(),this.liquid)}*render(t){t.bottom()[this.key]=yield this.value.value(t,this.liquid.options.lenientIf)}*arguments(){yield this.value}*localScope(){yield this.identifier}},for:class extends ws{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer.readIdentifier(),a=this.tokenizer.readIdentifier(),r=this.tokenizer.readValue();if(!n.size()||"in"!==a.content||!r)throw new Error(`illegal tag: ${t.getText()}`);let o;this.variable=n.content,this.collection=r,this.hash=new xs(this.tokenizer,i.options.keyValueSeparator),this.templates=[],this.elseTemplates=[];const l=s.parseStream(e).on("start",(()=>o=this.templates)).on("tag:else",(t=>{$e(t.args),o=this.elseTemplates})).on("tag:endfor",(t=>{$e(t.args),l.stop()})).on("template",(t=>o.push(t))).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)}));l.start()}*render(t,e){const i=this.liquid.renderer;let s=de(yield Xi(this.collection,t));if(!s.length)return void(yield i.renderTemplates(this.elseTemplates,t,e));const n="continue-"+this.variable+"-"+this.collection.getText();t.push({continue:t.getRegister(n)});const a=yield this.hash.render(t);t.pop();s=(this.liquid.options.orderedFilterParameters?Object.keys(a).filter((t=>Nn.includes(t))):Nn.filter((t=>void 0!==a[t]))).reduce(((t,e)=>{return"offset"===e?(i=t,s=a.offset,i.slice(s)):"limit"===e?function(t,e){return t.slice(0,e)}(t,a.limit):function(t){return[...t].reverse()}(t);var i,s}),s),t.setRegister(n,(a.offset||0)+s.length);const r={forloop:new qe(s.length,this.collection.getText(),this.variable)};t.push(r);for(const n of s){if(r[this.variable]=n,t.continueCalled=t.breakCalled=!1,yield i.renderTemplates(this.templates,t,e),t.breakCalled)break;r.forloop.next()}t.continueCalled=t.breakCalled=!1,t.pop()}*children(){const t=this.templates.slice();return this.elseTemplates&&t.push(...this.elseTemplates),t}*arguments(){yield this.collection;for(const t of Object.values(this.hash.hash))Zs(t)&&(yield t)}blockScope(){return[this.variable,"forloop"]}},capture:class extends ws{constructor(t,e,i,s){for(super(t,e,i),this.templates=[],this.identifier=this.readVariable(),this.variable=this.identifier.content;e.length;){const t=e.shift();if(qs(t)&&"endcapture"===t.name)return;this.templates.push(s.parseToken(t,e))}throw new Error(`tag ${t.getText()} not closed`)}readVariable(){let t=this.tokenizer.readIdentifier();if(t.content)return t;if(t=this.tokenizer.readQuoted(),t)return t;throw this.tokenizer.error("invalid capture name")}*render(t){const e=this.liquid.renderer,i=yield e.renderTemplates(this.templates,t);t.bottom()[this.variable]=i}*children(){return this.templates}*localScope(){yield this.identifier}},case:class extends ws{constructor(t,e,i,s){super(t,e,i),this.branches=[],this.elseTemplates=[],this.value=new Ts(this.tokenizer.readFilteredValue(),this.liquid),this.elseTemplates=[];let n=[],a=0;const r=s.parseStream(e).on("tag:when",(t=>{if(a>0)return;n=[];const e=[];for(;!t.tokenizer.end();)e.push(t.tokenizer.readValueOrThrow()),t.tokenizer.skipBlank(),","===t.tokenizer.peek()?t.tokenizer.readTo(","):t.tokenizer.readTo("or");this.branches.push({values:e,templates:n})})).on("tag:else",(()=>{a++,n=this.elseTemplates})).on("tag:endcase",(()=>r.stop())).on("template",(t=>{n===this.elseTemplates&&1!==a||n.push(t)})).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)}));r.start()}*render(t,e){const i=this.liquid.renderer,s=pe(yield this.value.value(t,t.opts.lenientIf));let n=!1;for(const a of this.branches)for(const r of a.values){if(ts(s,yield Xi(r,t,t.opts.lenientIf))){yield i.renderTemplates(a.templates,t,e),n=!0;break}}n||(yield i.renderTemplates(this.elseTemplates,t,e))}*arguments(){yield this.value,yield*this.branches.flatMap((t=>t.values))}*children(){const t=this.branches.flatMap((t=>t.templates));return this.elseTemplates&&t.push(...this.elseTemplates),t}},comment:class extends ws{constructor(t,e,i){for(super(t,e,i);e.length;){const t=e.shift();if(qs(t)&&"endcomment"===t.name)return}throw new Error(`tag ${t.getText()} not closed`)}render(){}},include:class extends ws{constructor(t,e,i,s){super(t,e,i);const{tokenizer:n}=t;this.file=Fn(n,this.liquid,s),this.currentFile=t.file;const a=n.p;"with"===n.readIdentifier().content?(n.skipBlank(),":"!==n.peek()?this.withVar=n.readValue():n.p=a):n.p=a,this.hash=new xs(n,i.options.jekyllInclude||i.options.keyValueSeparator)}*render(t,e){const{liquid:i,hash:s,withVar:n}=this,{renderer:a}=i,r=yield jn(this.file,t,i);He(r,(()=>`illegal file path "${r}"`));const o=t.saveRegister("blocks","blockMode");t.setRegister("blocks",{}),t.setRegister("blockMode",Us.OUTPUT);const l=yield s.render(t);n&&(l[r]=yield Xi(n,t));const h=yield i._parsePartialFile(r,t.sync,this.currentFile);t.push(t.opts.jekyllInclude?{include:l}:l),yield a.renderTemplates(h,t,e),t.pop(),t.restoreRegister(o)}*children(t,e){return t&&re(this.file)?yield this.liquid._parsePartialFile(this.file,e,this.currentFile):[]}partialScope(){if(re(this.file)){let t;return this.liquid.options.jekyllInclude?t=["include"]:(t=Object.keys(this.hash.hash),this.withVar&&t.push([this.file,this.withVar])),{name:this.file,isolated:!1,scope:t}}}*arguments(){yield*Object.values(this.hash.hash).filter(Zs),Zs(this.file)&&(yield this.file),Zs(this.withVar)&&(yield this.withVar)}},render:class extends ws{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer;for(this.file=Fn(n,this.liquid,s),this.currentFile=t.file;!n.end();){n.skipBlank();const t=n.p,e=n.readIdentifier();if(("with"===e.content||"for"===e.content)&&(n.skipBlank(),":"!==n.peek())){const t=n.readValue();if(t){const i=n.p;let s;"as"===n.readIdentifier().content?s=n.readIdentifier():n.p=i,this[e.content]={value:t,alias:s&&s.content},n.skipBlank(),","===n.peek()&&n.advance();continue}}n.p=t;break}this.hash=new xs(n,i.options.keyValueSeparator)}*render(t,e){const{liquid:i,hash:s}=this,n=yield jn(this.file,t,i);He(n,(()=>`illegal file path "${n}"`));const a=t.spawn(),r=a.bottom();if(ii(r,yield s.render(t)),this.with){const{value:e,alias:i}=this.with;r[i||n]=yield Xi(e,t)}if(this.for){const{value:s,alias:o}=this.for,l=de(yield Xi(s,t));r.forloop=new qe(l.length,s.getText(),o);for(const t of l){r[o]=t;const s=yield i._parsePartialFile(n,a.sync,this.currentFile);yield i.renderer.renderTemplates(s,a,e),r.forloop.next()}}else{const t=yield i._parsePartialFile(n,a.sync,this.currentFile);yield i.renderer.renderTemplates(t,a,e)}}*children(t,e){return t&&re(this.file)?yield this.liquid._parsePartialFile(this.file,e,this.currentFile):[]}partialScope(){if(re(this.file)){const t=Object.keys(this.hash.hash);if(this.with){const{value:e,alias:i}=this.with;re(i)?t.push([i,e]):re(this.file)&&t.push([this.file,e])}if(this.for){const{value:e,alias:i}=this.for;re(i)?t.push([i,e]):re(this.file)&&t.push([this.file,e])}return{name:this.file,isolated:!0,scope:t}}}*arguments(){for(const t of Object.values(this.hash.hash))Zs(t)&&(yield t);if(this.with){const{value:t}=this.with;Zs(t)&&(yield t)}if(this.for){const{value:t}=this.for;Zs(t)&&(yield t)}}},decrement:class extends ws{constructor(t,e,i){super(t,e,i),this.identifier=this.tokenizer.readIdentifier(),this.variable=this.identifier.content}render(t,e){const i=t.environments;fe(i[this.variable])||(i[this.variable]=0),e.write(ce(--i[this.variable]))}*localScope(){yield this.identifier}},increment:class extends ws{constructor(t,e,i){super(t,e,i),this.identifier=this.tokenizer.readIdentifier(),this.variable=this.identifier.content}render(t,e){const i=t.environments;fe(i[this.variable])||(i[this.variable]=0);const s=i[this.variable];i[this.variable]++,e.write(ce(s))}*localScope(){yield this.identifier}},cycle:class extends ws{constructor(t,e,i){super(t,e,i),this.candidates=[];const s=this.tokenizer.readValue();for(this.tokenizer.skipBlank(),s&&(":"===this.tokenizer.peek()?(this.group=s,this.tokenizer.advance()):this.candidates.push(s));!this.tokenizer.end();){const t=this.tokenizer.readValue();t&&this.candidates.push(t),this.tokenizer.readTo(",")}this.tokenizer.assert(this.candidates.length,(()=>`empty candidates: "${t.getText()}"`))}*render(t,e){const i=`cycle:${yield Xi(this.group,t)}:`+this.candidates.join(","),s=t.getRegister("cycle");let n=s[i];void 0===n&&(n=s[i]=0);const a=this.candidates[n];return n=(n+1)%this.candidates.length,s[i]=n,yield Xi(a,t)}*arguments(){yield*this.candidates,this.group&&(yield this.group)}},if:class extends ws{constructor(t,e,i,s){super(t,e,i),this.branches=[];let n=[];s.parseStream(e).on("start",(()=>this.branches.push({value:new Ts(t.tokenizer.readFilteredValue(),this.liquid),templates:n=[]}))).on("tag:elsif",(t=>{He(!this.elseTemplates,"unexpected elsif after else"),this.branches.push({value:new Ts(t.tokenizer.readFilteredValue(),this.liquid),templates:n=[]})})).on("tag:else",(t=>{$e(t.args),He(!this.elseTemplates,"duplicated else"),n=this.elseTemplates=[]})).on("tag:endif",(function(t){$e(t.args),this.stop()})).on("template",(t=>n.push(t))).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)})).start()}*render(t,e){const i=this.liquid.renderer;for(const{value:s,templates:n}of this.branches){if(Qi(yield s.value(t,t.opts.lenientIf),t))return void(yield i.renderTemplates(n,t,e))}yield i.renderTemplates(this.elseTemplates||[],t,e)}*children(){const t=this.branches.flatMap((t=>t.templates));return this.elseTemplates&&t.push(...this.elseTemplates),t}arguments(){return this.branches.map((t=>t.value))}},layout:class extends ws{constructor(t,e,i,s){super(t,e,i),this.file=Fn(this.tokenizer,this.liquid,s),this.currentFile=t.file,this.args=new xs(this.tokenizer,i.options.keyValueSeparator),this.templates=s.parseTokens(e)}*render(t,e){const{liquid:i,args:s,file:n}=this,{renderer:a}=i;if(void 0===n)return t.setRegister("blockMode",Us.OUTPUT),void(yield a.renderTemplates(this.templates,t,e));const r=yield jn(this.file,t,i);He(r,(()=>`illegal file path "${r}"`));const o=yield i._parseLayoutFile(r,t.sync,this.currentFile);t.setRegister("blockMode",Us.STORE);const l=yield a.renderTemplates(this.templates,t),h=t.getRegister("blocks");void 0===h[""]&&(h[""]=(t,e)=>e.write(l)),t.setRegister("blockMode",Us.OUTPUT),t.push(yield s.render(t)),yield a.renderTemplates(o,t,e),t.pop()}*children(t){const e=this.templates.slice();return t&&re(this.file)&&e.push(...yield this.liquid._parsePartialFile(this.file,!0,this.currentFile)),e}*arguments(){for(const t of Object.values(this.args.hash))Zs(t)&&(yield t);Zs(this.file)&&(yield this.file)}partialScope(){if(re(this.file))return{name:this.file,isolated:!1,scope:Object.keys(this.args.hash)}}},block:class extends ws{constructor(t,e,i,s){super(t,e,i),this.templates=[];const n=/\w+/.exec(t.args);for(this.block=n?n[0]:"";e.length;){const t=e.shift();if(qs(t)&&"endblock"===t.name)return;const i=s.parseToken(t,e);this.templates.push(i)}throw new Error(`tag ${t.getText()} not closed`)}*render(t,e){const i=this.getBlockRender(t);t.getRegister("blockMode")===Us.STORE?t.getRegister("blocks")[this.block]=i:yield i(new Qe,e)}getBlockRender(t){const{liquid:e,templates:i}=this,s=t.getRegister("blocks")[this.block],n=function*(s,n){t.push({block:s}),yield e.renderer.renderTemplates(i,t,n),t.pop()};return s?(t,e)=>s(new Qe((e=>n(t,e))),e):n}*children(){return this.templates}blockScope(){return["block"]}},raw:class extends ws{constructor(t,e,i){for(super(t,e,i),this.tokens=[];e.length;){const t=e.shift();if(qs(t)&&"endraw"===t.name)return;this.tokens.push(t)}throw new Error(`tag ${t.getText()} not closed`)}render(){return this.tokens.map((t=>t.getText())).join("")}},tablerow:class extends ws{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer.readIdentifier();this.tokenizer.skipBlank();const a=this.tokenizer.readIdentifier(),r=this.tokenizer.readValue();if("in"!==a.content||!r)throw new Error(`illegal tag: ${t.getText()}`);let o;this.variable=n.content,this.collection=r,this.args=new xs(this.tokenizer,i.options.keyValueSeparator),this.templates=[];const l=s.parseStream(e).on("start",(()=>o=this.templates)).on("tag:endtablerow",(()=>l.stop())).on("template",(t=>o.push(t))).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)}));l.start()}*render(t,e){let i=de(yield Xi(this.collection,t));const s=yield this.args.render(t),n=s.offset||0,a=void 0===s.limit?i.length:s.limit;i=i.slice(n,n+a);const r=s.cols||i.length,o=this.liquid.renderer,l=new zn(i.length,r,this.collection.getText(),this.variable),h={tablerowloop:l};t.push(h);for(let s=0;s<i.length;s++,l.next())h[this.variable]=i[s],0===l.col0()&&(1!==l.row()&&e.write("</tr>"),e.write(`<tr class="row${l.row()}">`)),e.write(`<td class="col${l.col()}">`),yield o.renderTemplates(this.templates,t,e),e.write("</td>");i.length&&e.write("</tr>"),t.pop()}*children(){return this.templates}*arguments(){yield this.collection;for(const t of Object.values(this.args.hash))Zs(t)&&(yield t)}blockScope(){return[this.variable,"tablerowloop"]}},unless:class extends ws{constructor(t,e,i,s){super(t,e,i),this.branches=[],this.elseTemplates=[];let n=[],a=0;s.parseStream(e).on("start",(()=>this.branches.push({value:new Ts(t.tokenizer.readFilteredValue(),this.liquid),test:Ji,templates:n=[]}))).on("tag:elsif",(t=>{a>0?n=[]:this.branches.push({value:new Ts(t.tokenizer.readFilteredValue(),this.liquid),test:Qi,templates:n=[]})})).on("tag:else",(()=>{a++,n=this.elseTemplates})).on("tag:endunless",(function(){this.stop()})).on("template",(t=>{n===this.elseTemplates&&1!==a||n.push(t)})).on("end",(()=>{throw new Error(`tag ${t.getText()} not closed`)})).start()}*render(t,e){const i=this.liquid.renderer;for(const{value:s,test:n,templates:a}of this.branches){if(n(yield s.value(t,t.opts.lenientIf),t))return void(yield i.renderTemplates(a,t,e))}yield i.renderTemplates(this.elseTemplates,t,e)}*children(){const t=this.branches.flatMap((t=>t.templates));return this.elseTemplates&&t.push(...this.elseTemplates),t}arguments(){return this.branches.map((t=>t.value))}},break:class extends ws{render(t,e){t.breakCalled=!0}},continue:class extends ws{render(t,e){t.continueCalled=!0}},echo:class extends ws{constructor(t,e,i){super(t,e,i),this.tokenizer.skipBlank(),this.tokenizer.end()||(this.value=new Ts(this.tokenizer.readFilteredValue(),this.liquid))}*render(t,e){if(!this.value)return;const i=yield this.value.value(t,!1);e.write(i)}*arguments(){this.value&&(yield this.value)}},liquid:class extends ws{constructor(t,e,i,s){super(t,e,i);const n=this.tokenizer.readLiquidTagTokens(this.liquid.options);this.templates=s.parseTokens(n)}*render(t,e){yield this.liquid.renderer.renderTemplates(this.templates,t,e)}*children(){return this.templates}},"#":class extends ws{constructor(t,e,i){if(super(t,e,i),-1!==t.args.search(/\n\s*[^#\s]/g))throw new Error("every line of an inline comment must start with a '#' character")}render(){}}};class Un{constructor(t={}){this.renderer=new qi,this.filters={},this.tags={},this.options=gs(t),this.parser=new $s(this),ye(Vn,((t,e)=>this.registerTag(e,t))),ye(On,((t,e)=>this.registerFilter(e,t)))}parse(t,e){return new $s(this).parse(t,e)}_render(t,e,i){const s=e instanceof en?e:new en(e,this.options,i);return this.renderer.renderTemplates(t,s)}render(t,e,i){return si(this,void 0,void 0,(function*(){return ni(this._render(t,e,Object.assign(Object.assign({},i),{sync:!1})))}))}renderSync(t,e,i){return ai(this._render(t,e,Object.assign(Object.assign({},i),{sync:!0})))}renderToNodeStream(t,e,i={}){const s=new en(e,this.options,i);return this.renderer.renderTemplatesToNodeStream(t,s)}_parseAndRender(t,e,i){const s=this.parse(t);return this._render(s,e,i)}parseAndRender(t,e,i){return si(this,void 0,void 0,(function*(){return ni(this._parseAndRender(t,e,Object.assign(Object.assign({},i),{sync:!1})))}))}parseAndRenderSync(t,e,i){return ai(this._parseAndRender(t,e,Object.assign(Object.assign({},i),{sync:!0})))}_parsePartialFile(t,e,i){return new $s(this).parseFile(t,e,zs.Partials,i)}_parseLayoutFile(t,e,i){return new $s(this).parseFile(t,e,zs.Layouts,i)}_parseFile(t,e,i,s){return new $s(this).parseFile(t,e,i,s)}parseFile(t,e){return si(this,void 0,void 0,(function*(){return ni(new $s(this).parseFile(t,!1,e))}))}parseFileSync(t,e){return ai(new $s(this).parseFile(t,!0,e))}*_renderFile(t,e,i){const s=yield this._parseFile(t,i.sync,i.lookupType);return yield this._render(s,e,i)}renderFile(t,e,i){return si(this,void 0,void 0,(function*(){return ni(this._renderFile(t,e,Object.assign(Object.assign({},i),{sync:!1})))}))}renderFileSync(t,e,i){return ai(this._renderFile(t,e,Object.assign(Object.assign({},i),{sync:!0})))}renderFileToNodeStream(t,e,i){return si(this,void 0,void 0,(function*(){const s=yield this.parseFile(t);return this.renderToNodeStream(s,e,i)}))}_evalValue(t,e){const i=new Ts(t,this),s=e instanceof en?e:new en(e,this.options);return i.value(s)}evalValue(t,e){return si(this,void 0,void 0,(function*(){return ni(this._evalValue(t,e))}))}evalValueSync(t,e){return ai(this._evalValue(t,e))}registerFilter(t,e){this.filters[t]=e}registerTag(t,e){this.tags[t]=oe(e)?e:function(t){return class extends ws{constructor(e,i,s){super(e,i,s),oe(t.parse)&&t.parse.call(this,e,i)}*render(e,i){const s=yield new xs(this.token.args,e.opts.keyValueSeparator).render(e);return yield t.render.call(this,e,i,s)}}}(e)}plugin(t){return t.call(this,Un)}express(){const t=this;let e=!0;return function(i,s,n){if(e){e=!1;const i=fs(this.root);t.options.root.unshift(...i),t.options.layouts.unshift(...i),t.options.partials.unshift(...i)}t.renderFile(i,s).then((t=>n(null,t)),n)}}analyze(t,e={}){return si(this,void 0,void 0,(function*(){return Ls(t,e)}))}analyzeSync(t,e={}){return Ds(t,e)}parseAndAnalyze(t,e,i={}){return si(this,void 0,void 0,(function*(){return Ls(this.parse(t,e),i)}))}parseAndAnalyzeSync(t,e,i={}){return Ds(this.parse(t,e),i)}variables(t,e={}){return si(this,void 0,void 0,(function*(){const i=yield Ls(re(t)?this.parse(t):t,e);return Object.keys(i.variables)}))}variablesSync(t,e={}){const i=Ds(re(t)?this.parse(t):t,e);return Object.keys(i.variables)}fullVariables(t,e={}){return si(this,void 0,void 0,(function*(){const i=yield Ls(re(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.variables).flatMap((t=>t.map((t=>String(t)))))))}))}fullVariablesSync(t,e={}){const i=Ds(re(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.variables).flatMap((t=>t.map((t=>String(t)))))))}variableSegments(t,e={}){return si(this,void 0,void 0,(function*(){const i=yield Ls(re(t)?this.parse(t):t,e);return Array.from(Me(Object.values(i.variables).flatMap((t=>t.map((t=>t.toArray()))))))}))}variableSegmentsSync(t,e={}){const i=Ds(re(t)?this.parse(t):t,e);return Array.from(Me(Object.values(i.variables).flatMap((t=>t.map((t=>t.toArray()))))))}globalVariables(t,e={}){return si(this,void 0,void 0,(function*(){const i=yield Ls(re(t)?this.parse(t):t,e);return Object.keys(i.globals)}))}globalVariablesSync(t,e={}){const i=Ds(re(t)?this.parse(t):t,e);return Object.keys(i.globals)}globalFullVariables(t,e={}){return si(this,void 0,void 0,(function*(){const i=yield Ls(re(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.globals).flatMap((t=>t.map((t=>String(t)))))))}))}globalFullVariablesSync(t,e={}){const i=Ds(re(t)?this.parse(t):t,e);return Array.from(new Set(Object.values(i.globals).flatMap((t=>t.map((t=>String(t)))))))}globalVariableSegments(t,e={}){return si(this,void 0,void 0,(function*(){const i=yield Ls(re(t)?this.parse(t):t,e);return Array.from(Me(Object.values(i.globals).flatMap((t=>t.map((t=>t.toArray()))))))}))}globalVariableSegmentsSync(t,e={}){const i=Ds(re(t)?this.parse(t):t,e);return Array.from(Me(Object.values(i.globals).flatMap((t=>t.map((t=>t.toArray()))))))}}const Hn={render:function(t,e){const i=r("v-icon"),s=r("v-list-item-icon"),n=r("v-text-overflow"),a=r("v-list-item-content"),u=r("v-list-item"),p=r("v-list");return o(),l(p,{nav:""},{default:h((()=>[c(u,{href:"https://app.texttoanything.nl/"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"open_in_new"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Text to anything dashboard"})])),_:1})])),_:1}),c(u,{to:"/tta_settings/templates"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"code"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Templates"})])),_:1})])),_:1}),c(u,{to:"/tta_settings/flowsLogExplorer"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"short_text"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Flows log explorer"})])),_:1})])),_:1}),c(u,{to:"/tta_settings/settings"},{default:h((()=>[c(s,null,{default:h((()=>[c(i,{name:"settings"})])),_:1}),c(a,null,{default:h((()=>[c(n,{text:"Settings"})])),_:1})])),_:1}),d(' <v-list-item to="/tta_settings/usage">\n <v-list-item-icon><v-icon name="bar_chart" /></v-list-item-icon>\n <v-list-item-content>\n <v-text-overflow text="Usage" />\n </v-list-item-content>\n </v-list-item> ')])),_:1})},__file:"settingsmodule/src/TTAnav.vue"},$n=t=>(f("data-v-4a16637c"),t=t(),_(),t),Wn={key:0,class:"popover"},Gn=$n((()=>m("br",null,null,-1))),qn=$n((()=>m("ul",null,[m("li",null,"HTML - preview as webpage"),m("li",null,"PDF (Preview) - watermarked, free"),m("li",null,"PDF - final version, without watermark"),m("li",null,"Code - preview without test input")],-1)));var Kn={__name:"explainPreviewMode",props:{text:{type:String,required:!0}},setup(t){const e=u(!1);return(t,i)=>{const s=r("v-icon");return o(),p("div",{class:"info-popover",onMouseenter:i[0]||(i[0]=t=>e.value=!0),onMouseleave:i[1]||(i[1]=t=>e.value=!1)},[c(s,{name:"question_mark",class:"info-icon"}),e.value?(o(),p("div",Wn,[g(" The preview mode has 4 modes: "),Gn,qn])):d("v-if",!0)],32)}}},Xn=[],Yn=[];function Qn(t,e){if(t&&"undefined"!=typeof document){var i,s=!0===e.prepend?"prepend":"append",n=!0===e.singleTag,a="string"==typeof e.container?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(n){var r=Xn.indexOf(a);-1===r&&(r=Xn.push(a)-1,Yn[r]={}),i=Yn[r]&&Yn[r][s]?Yn[r][s]:Yn[r][s]=o()}else i=o();65279===t.charCodeAt(0)&&(t=t.substring(1)),i.styleSheet?i.styleSheet.cssText+=t:i.appendChild(document.createTextNode(t))}function o(){var t=document.createElement("style");if(t.setAttribute("type","text/css"),e.attributes)for(var i=Object.keys(e.attributes),n=0;n<i.length;n++)t.setAttribute(i[n],e.attributes[i[n]]);var r="prepend"===s?"afterbegin":"beforeend";return a.insertAdjacentElement(r,t),t}}Qn("\n.info-popover[data-v-4a16637c] {\n position: relative;\n display: flex;\n color: var(--theme--foreground-subdued);\n}\n.info-icon[data-v-4a16637c] {\n margin: auto;\n}\n.popover[data-v-4a16637c] {\n position: absolute;\n top: 175%;\n left: 50%;\n transform: translateX(-50%);\n background-color: var(--theme--background);\n color: var(--theme--foreground);\n border: 1px solid var(--theme--border);\n padding: 0.5rem;\n border-radius: 4px;\n white-space: nowrap;\n z-index: 1000;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n}\n",{}),Kn.__scopeId="data-v-4a16637c",Kn.__file="settingsmodule/src/pages/templates/explainPreviewMode.vue";const Jn=m("div",{class:"field half"},[m("div",{class:"type-label"}," Template name ")],-1),Zn=m("div",{class:"field half"},[m("div",{class:"type-label"}," Description ")],-1),ta=m("div",{class:"field half"},[m("div",{class:"type-label"},"Format")],-1),ea=m("div",{class:"field half"},[m("div",{class:"type-label"}," Orientation ")],-1),ia={key:0,class:"TTA-popup"},sa={class:"TTA-toolbar"},na={class:"right-side"},aa={class:"setwidth"},ra={class:"TTA-action"},oa={class:"TTA-wapper"},la={class:"devFields"},ha={id:"partSelect"},ca=["src","srcDoc"],da={class:"tta-notice"},ua=m("a",{href:"https://app.texttoanything.nl",target:"_blank"},"TTA app",-1);var pa=v({__name:"templates",setup(t){const{useFlowsStore:s,useNotificationsStore:n}=e(),a=s(),f=n(),_=b((()=>a.flows.filter((t=>"webhook"===t.trigger&&"POST"==t.options.method)).map((t=>({text:t.name,value:t.id}))))),v=u([]),R=u(!1),M=u(!1),P=u("Development"),L=u("html"),D=u(""),I=u(!1),O=u(),N=u(50),F=b((()=>100-N.value)),B=b((()=>100-F.value)),j=u("");function z(){"Development"==P.value&&(j.value=""),"Header"==P.value&&(j.value=G.value.header),"Body"==P.value&&(j.value=G.value.template),"Footer"==P.value&&(j.value=G.value.footer)}function V(t){"Header"==P.value?G.value.header=t:"Body"==P.value?G.value.template=t:G.value.footer=t}function U(t){"Fixed"==G.value.input_type?G.value.input_fixed=t:G.value.input_flow_body=t}y((()=>P.value),(()=>{z()}),{immediate:!0});const H=i(),$={template:"<h1>Hello {{name}}!</h1>",id:-1,name:"",description:"",collection:"",format:"A4",orientation:"portrait",header:"\x3c!-- Any content/styling here is seperated from the body on render--\x3e\n<style> \n #header, #footer { \n margin: 0 !important; \n padding: 0 !important; \n font-size: 9px; \n -webkit-print-color-adjust: exact;\n }\n</style>\n<div style='width:100%'>\n <span class='date'></span>\n <span class='title' style='float:right'></span>\n</div>",footer:"\x3c!-- Any content/styling here is seperated from the body on render--\x3e\n<style> \n #header, #footer { \n margin: 0 !important; \n padding: 0 !important; \n font-size: 9px; -webkit-print-color-adjust: exact;\n }\n</style>\n<div\n style=‘width:100%’>\n <div style=‘float:right’><span\n class='pageNumber'></span> / <span class='totalPages'></span>\n </div>\n</div>",input_type:"Fixed",input_fixed:'{"name": "World!"}',input_flow:"",input_flow_body:"{}"},G=u(structuredClone($)),q=new Un;async function K(t){if("Flow"==G.value.input_type&&!G.value.input_flow)return;D.value="rendering";let e={};try{if("Flow"==G.value.input_type){const t=await H.post("/flows/trigger/"+G.value.input_flow,JSON.parse(G.value.input_flow_body));if("object"!=typeof t.data)throw new Error("Output of flow should be an object, not an "+typeof t.data);if("name"in t.data&&"code"in t.data&&"status"in t.data)throw new Error(JSON.stringify(t.data));e=t.data}else null==G.value.input_fixed&&(G.value.input_fixed="{}"),e=JSON.parse(G.value.input_fixed);if("html"==t||"code"==t){const i=(G.value.header||"")+(G.value.template||"")+(G.value.footer||""),s=new Blob(['<style>\n .date:before{content: "Date here";font-style: italic; }\n .title:before{content: "Title here";font-style: italic; }\n .pageNumber:before{content: "Pagenumber";font-style: italic; }\n .totalPages:before{content: "Total pages";font-style: italic; }\n </style>'+("code"==t?i:await q.render(q.parse(i),e))],{type:"text/html"});D.value=URL.createObjectURL(s)}else{const t=q.parse(G.value.header||""),i=q.parse(G.value.template),s=q.parse(G.value.footer||""),n=await q.render(t,e),a=await q.render(i,e),r=await q.render(s,e),o=await fetch("/tta/pdf?preview="+("pdf-preview"==L.value?"preview":""),{body:JSON.stringify({...G.value,input_fixed:void 0,input_flow:void 0,input_flow_body:void 0,input_type:void 0,id:void 0,header:n,html:a,footer:r,landscape:"portrait"!=G.value.orientation}),method:"POST",headers:{"Content-Type":"application/json"}}).then((t=>t.blob())).then((t=>URL.createObjectURL(t)));D.value=o}}catch(t){console.error(t),f.add({title:"Error while generating PDF",text:"Please check your console/terminal for the error.",type:"error",dialog:!0}),D.value=URL.createObjectURL(new Blob(["Error occurred: "+((null==t?void 0:t.message)||t)],{type:"text/html"}))}}async function X(){const t=await H.get("/items/TTA_htmltemplates",{params:{limit:-1}});v.value=t.data.data}async function Y(){-1==G.value.id?await H.post("/items/TTA_htmltemplates",{...G.value,id:void 0}):await H.patch("/items/TTA_htmltemplates/"+G.value.id,{...G.value,id:void 0}),R.value=!1,X()}async function Q(){await H.delete("/items/TTA_htmltemplates/"+O.value),v.value=v.value.filter((t=>t.id!=O.value)),I.value=!1}function J({item:t}){G.value=t,M.value=!0}function Z(){G.value=structuredClone($),M.value=!1}function tt(){const t={wrap_line_length:0,indent_inner_html:!0};G.value.template=W.exports.html(G.value.template,t),G.value.footer=W.exports.html(G.value.footer,t),G.value.header=W.exports.html(G.value.header,t),z()}return y((()=>G.value.id),((t,e)=>{t!=e&&(P.value="",w((()=>{P.value="Body"})))})),y((()=>[G.value.header,G.value.template,G.value.footer,G.value.input_type,G.value.input_flow,G.value.input_fixed,L.value]),(()=>{["html","code"].includes(L.value)&&K(L.value)}),{deep:!0,immediate:!0}),x((async()=>{N.value=parseInt(localStorage.getItem("TTA-widthPartition")||"50"),X()})),y((()=>N.value),(t=>localStorage.setItem("TTA-widthPartition",t+""))),(t,e)=>{const i=r("v-icon"),s=r("v-button"),n=r("v-card-title"),a=r("v-input"),u=r("v-list-item-content"),f=r("v-list-item"),b=r("v-select"),y=r("v-list"),w=r("v-card-text"),x=r("v-card-actions"),z=r("v-card"),H=r("v-dialog"),$=r("VSelect"),W=r("v-slider"),q=r("VButton"),X=r("VIcon"),et=r("v-table"),it=r("VNotice"),st=r("private-view");return o(),l(st,{title:"Offline templates"},{navigation:h((()=>[c(Hn)])),actions:h((()=>[c(s,{rounded:"",icon:"",onClick:e[0]||(e[0]=t=>R.value=!0)},{default:h((()=>[c(i,{name:"add"})])),_:1}),c(H,{modelValue:R.value,"onUpdate:modelValue":e[6]||(e[6]=t=>R.value=t),persistent:!0},{default:h((()=>[c(z,null,{default:h((()=>[c(n,null,{default:h((()=>[g("Create a new HTML template")])),_:1}),c(w,null,{default:h((()=>[c(y,null,{default:h((()=>[c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[Jn,c(a,{modelValue:G.value.name,"onUpdate:modelValue":e[1]||(e[1]=t=>G.value.name=t),placeholder:"Template name"},null,8,["modelValue"])])),_:1})])),_:1}),c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[Zn,c(a,{modelValue:G.value.description,"onUpdate:modelValue":e[2]||(e[2]=t=>G.value.description=t),placeholder:"Description"},null,8,["modelValue"])])),_:1})])),_:1}),c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[ta,c(b,{modelValue:G.value.format,"onUpdate:modelValue":e[3]||(e[3]=t=>G.value.format=t),placeholder:"Size",items:["A1","A2","A3","A4","A5","A6","Letter","Legal","Tabloid","Ledger"].map((t=>({text:t,value:t})))},null,8,["modelValue","items"])])),_:1})])),_:1}),c(f,null,{default:h((()=>[c(u,null,{default:h((()=>[ea,c(b,{modelValue:G.value.orientation,"onUpdate:modelValue":e[4]||(e[4]=t=>G.value.orientation=t),placeholder:"Orientation",items:["portrait","landscape"].map((t=>({text:t,value:t})))},null,8,["modelValue","items"])])),_:1})])),_:1})])),_:1})])),_:1}),c(x,null,{default:h((()=>[c(s,{secondary:"",onClick:e[5]||(e[5]=t=>R.value=!1)},{default:h((()=>[g(" Cancel ")])),_:1}),c(s,{disabled:!G.value.name||!G.value.format,onClick:Y},{default:h((()=>[g(" Save ")])),_:1},8,["disabled"])])),_:1})])),_:1})])),_:1},8,["modelValue"])])),default:h((()=>[M.value?(o(),p("div",ia,[m("div",sa,[m("div",{onClick:e[7]||(e[7]=t=>R.value=!0),class:"TTA-template-title"},[g(A(G.value.name)+" ",1),c(i,{name:"edit"})]),m("div",na,[c($,{modelValue:L.value,"onUpdate:modelValue":e[8]||(e[8]=t=>L.value=t),items:[{text:"HTML",value:"html"},{text:"PDF (Preview)",value:"pdf-preview"},{text:"PDF",value:"pdf"},{text:"Code",value:"code"}],style:{width:"170px"}},null,8,["modelValue","items"]),c(Kn,{text:"This is helpful info."}),m("div",{class:"TTA-action",onClick:tt},[c(i,{name:"vertical_align_center"})]),m("div",{class:"TTA-action",onClick:Y},[c(i,{name:"save"})]),m("div",aa,[c(W,{modelValue:N.value,"onUpdate:modelValue":e[9]||(e[9]=t=>N.value=t),min:10,max:90,class:"TTA-slider"},null,8,["modelValue"])]),m("div",ra,[c(i,{name:"close",onClick:Z})])])]),m("div",oa,[m("div",{style:k("width: "+T(B)+"%"),class:"TTA-editor-wrapper"},["Development"==P.value?(o(),p(S,{key:0},[m("div",la,[c(b,{modelValue:G.value.input_type,"onUpdate:modelValue":e[10]||(e[10]=t=>G.value.input_type=t),class:"max-w-input",items:[{value:"Flow",text:"Flow"},{value:"Fixed",text:"Fixed"}]},null,8,["modelValue"]),"Flow"==G.value.input_type?(o(),l(b,{key:0,modelValue:G.value.input_flow,"onUpdate:modelValue":e[11]||(e[11]=t=>G.value.input_flow=t),class:"max-w-input",items:T(_)},null,8,["modelValue","items"])):d("v-if",!0)]),"Fixed"==G.value.input_type?(o(),l(E("interface-input-code"),{key:0,class:"TTA-editor",value:G.value.input_fixed,language:"json",onInput:U},null,40,["value"])):d("v-if",!0),"Flow"==G.value.input_type?(o(),l(E("interface-input-code"),{key:1,class:"TTA-editor",value:G.value.input_flow_body,language:"json",onInput:U},null,40,["value"])):d("v-if",!0)],64)):d("v-if",!0),"Development"!=P.value?(o(),l(E("interface-input-code"),{key:1,class:"TTA-editor",value:j.value,language:"htmlmixed",onInput:V},null,40,["value"])):d("v-if",!0),m("div",ha,[c(b,{modelValue:P.value,"onUpdate:modelValue":e[12]||(e[12]=t=>P.value=t),items:[{value:"Header",text:"Header"},{value:"Body",text:"Body"},{value:"Footer",text:"Footer"},{value:"Development",text:"Test input"}]},null,8,["modelValue"])])],4),m("iframe",{class:"TTA-preview",src:"rendering"==D.value?void 0:D.value,srcDoc:"rendering"==D.value?T('\n <html>\n <head>\n <style>\n body {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100vh;\n margin: 0;\n font-family: sans-serif;\n background: #f9f9f9;\n }\n .spinner {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n .loader {\n border: 6px solid #f3f3f3;\n border-top: 6px solid #3498db;\n border-radius: 50%;\n width: 40px;\n height: 40px;\n animation: spin 1s linear infinite;\n margin-bottom: 10px;\n }\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n </style>\n </head>\n <body>\n <div class="spinner">\n <div class="loader"></div>\n <div>Loading...</div>\n </div>\n </body>\n </html>'):void 0,style:k("width: "+T(F)+"%")},null,12,ca),L.value.startsWith("pdf")?(o(),l(q,{key:0,onClick:e[13]||(e[13]=t=>{K("pdf")}),icon:!0,outlined:!1,id:"generatePDF"},{default:h((()=>[c(i,{name:"refresh"})])),_:1})):d("v-if",!0)])])):d("v-if",!0),c(et,{headers:[{text:"Name",value:"name",sortable:!1},{text:"Description",value:"description",width:600,sortable:!1},{text:"Format",value:"format",sortable:!1},{text:"",value:"del",width:60,sortable:!1}],"onClick:row":J,items:v.value},{"item.del":h((({item:t})=>[c(q,{onClick:C((e=>{return i=t.id,O.value=i,void(I.value=!0);var i}),["stop"]),outlined:!0,icon:!0,rounded:!0},{default:h((()=>[c(X,{name:"delete"})])),_:2},1032,["onClick"])])),_:1},8,["items"]),m("div",da,[c(it,null,{default:h((()=>[g(" You can create online templates in the "),ua,g(" for a better editor experience. ")])),_:1})]),c(H,{modelValue:I.value,"onUpdate:modelValue":e[15]||(e[15]=t=>I.value=t),persistent:!0},{default:h((()=>[c(z,null,{default:h((()=>[c(n,null,{default:h((()=>[g(" Are you sure you want to delete this item? This action can not be undone. ")])),_:1}),c(x,null,{default:h((()=>[c(s,{secondary:"",onClick:e[14]||(e[14]=t=>I.value=!1)},{default:h((()=>[g(" Cancel ")])),_:1}),c(s,{kind:"danger",onClick:Q},{default:h((()=>[g(" Proceed ")])),_:1})])),_:1})])),_:1})])),_:1},8,["modelValue"])])),_:1})}}});Qn("\n.TTA-popup {\n position: fixed;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n z-index: 100;\n display: flex;\n flex-direction: column;\n background-color: var(--theme--form--field--input--background-subdued);\n}\n.TTA-toolbar {\n background-color: var(--theme--form--field--input--background-subdued);\n display: flex;\n justify-content: space-between;\n}\n.TTA-toolbar .right-side {\n display: flex;\n align-items: center;\n gap: 5px;\n}\n.TTA-toolbar .TTA-slider {\n padding-top: 5px;\n}\n.TTA-toolbar .TTA-action {\n padding: 5px;\n cursor: pointer;\n}\n.TTA-toolbar .setwidth {\n display: flex;\n gap: 10px;\n padding-top: 6px;\n}\n.TTA-toolbar .TTA-template-title {\n margin: auto 0;\n font-size: 18px;\n cursor: pointer;\n padding-right: 5px;\n padding-left: 20px;\n border-bottom: 1px solid var(--v-list-item-border-color);\n}\n.TTA-toolbar .TTA-template-title i {\n padding-left: 5px;\n}\n.TTA-wapper {\n display: flex;\n flex-grow: 1;\n overflow: hidden;\n position: relative;\n}\n.TTA-preview {\n flex-grow: 1;\n background-color: white;\n border: 0;\n}\n.TTA-editor {\n flex-grow: 1;\n height: 100%;\n width: 100%;\n max-height: calc(100vh - 130px);\n}\n.TTA-wapper .TTA-editor-wrapper {\n position: relative;\n}\n.TTA-editor > div {\n height: 100% !important;\n border-radius: 0 !important;\n}\n.TTA-editor .CodeMirror {\n height: 100%;\n}\n.TTA-wapper #partSelect {\n position: absolute;\n right: 0;\n top: 0;\n width: 200px;\n}\n.devFields {\n border-top: var(--theme--border-width) solid\n var(--theme--form--field--input--border-color);\n margin-left: 25px;\n margin-bottom: 10px;\n}\n.max-w-input {\n max-width: 250px;\n padding: 10px 0;\n}\n.max-w-input .v-input {\n max-width: 250px;\n margin-bottom: 5px;\n}\n#generatePDF {\n position: fixed;\n top: 69px;\n right: 10px;\n}\n.tta-notice {\n padding: 10px;\n}\n",{}),pa.__file="settingsmodule/src/pages/templates.vue";var ga=v({__name:"virusscanDialog",setup(t){const e=i(),s=u([]),n=u(!1);x((async()=>{const t=await e.get("/folders");s.value=t.data.data.map((t=>({name:t.name,id:t.id,scanning:1==t.TTA_VIRUSSCAN_ENABLED})))}));const a=b((()=>s.value.filter((t=>1==t.scanning)).length));return(t,i)=>{const l=r("VNotice"),d=r("v-button"),u=r("v-table"),f=r("v-drawer"),_=r("v-icon");return o(),p(S,null,[c(f,{modelValue:n.value,"onUpdate:modelValue":i[0]||(i[0]=t=>n.value=t),persistent:!0,placement:"right",title:"Manage folders that are scanned for virusses",onCancel:i[1]||(i[1]=t=>n.value=!1),icon:"settings"},{default:h((()=>[c(l,null,{default:h((()=>[g(" Any uploads to the enabled folders will be scanned. ")])),_:1}),c(u,{headers:[{text:"",value:"enabled"},{text:"Name",value:"name"}],items:s.value},{"item.enabled":h((({item:t})=>[c(d,{onClick:i=>async function(t){t.scanning=!t.scanning,await e.patch("/folders/"+t.id,{TTA_VIRUSSCAN_ENABLED:t.scanning})}(t),small:"",danger:!t.scanning},{default:h((()=>[g(A(t.scanning?"Enabled":"Disabled"),1)])),_:2},1032,["onClick","danger"])])),_:1},8,["items"])])),_:1},8,["modelValue"]),c(d,{align:"left",fullWidth:"",small:"",onClick:i[2]||(i[2]=t=>n.value=!0)},{default:h((()=>[c(_,{name:"edit"}),T(a)==s.value.length?(o(),p(S,{key:0},[g(" All ")],64)):(o(),p(S,{key:1},[g(A(T(a))+"/"+A(s.value.length),1)],64)),g(" folders are being scanned ")])),_:1})],64)}}});ga.__file="settingsmodule/src/pages/settings/virusscanDialog.vue";const fa=t=>(f("data-v-7f9dbb3b"),t=t(),_(),t),_a={class:"cards-wrapper"},ma=fa((()=>m("span",{class:"field-name"},"RapidAPI token",-1))),va=fa((()=>m("span",{class:"field-name"},"RapidAPI virusscanner token",-1))),ba={class:"field-name info-parent"},ya=fa((()=>m("div",null,[g(" What should happen when a virus is detected? "),m("ul",null,[m("li",null," Delete threads, threads will be deleted immediately "),m("li",null," Trigger flow, the selected flow will be triggered with upload payload ")]),m("div",null," The trigger flow option is ideal for when you want to send a notification or add extra logic. The trigger flow option will not automaticly delete the file. ")],-1))),wa={key:0},xa={class:"field-name info-parent"};var Aa=v({__name:"settings",setup(t){const s=u(""),n=u(""),a=u(!1),f=u(""),_=u(""),v=u(""),y=i(),{useFlowsStore:w}=e(),A=w(),k=b((()=>A.flows.map((t=>({text:t.name,value:t.id})))));async function E(){R({TTA_KEY:s.value,TTA_KEY_VIRUS:n.value},"apikeys")}async function C(){R({TTA_VIRUSSCANNER_ENABLED:a.value,TTA_VIRUSSCANNER_MODE:f.value,TTA_VIRUSSCANNER_FLOW_ID:_.value},"virus")}async function R(t,e){v.value=e,await y.patch("/settings",t),setTimeout((()=>{v.value=""}),500)}return x((async()=>{const t=await y.get("/settings");s.value=t.data.data.TTA_KEY,n.value=t.data.data.TTA_KEY_VIRUS,_.value=t.data.data.TTA_VIRUSSCANNER_FLOW_ID,a.value=1==t.data.data.TTA_VIRUSSCANNER_ENABLED||!1,f.value=t.data.data.TTA_VIRUSSCANNER_MODE||"workflow"})),(t,e)=>{const i=r("v-card-title"),u=r("v-input"),b=r("v-card-text"),y=r("v-icon"),w=r("v-button"),x=r("v-progress-circular"),A=r("v-card-actions"),R=r("v-card"),M=r("VCheckbox"),P=r("VIcon"),L=r("VNotice"),D=r("v-hover"),I=r("v-select"),O=r("private-view");return o(),l(O,{title:"Settings"},{navigation:h((()=>[c(Hn)])),default:h((()=>[m("div",_a,[c(R,{class:"w-full"},{default:h((()=>[c(i,null,{default:h((()=>[g("API settings")])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[m("div",null,[ma,c(u,{modelValue:s.value,"onUpdate:modelValue":e[0]||(e[0]=t=>s.value=t)},null,8,["modelValue"])])])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[c(w,{href:"https://rapidapi.com/Attacler/api/text-to-anything",target:"_blank",align:"left",fullWidth:"",small:""},{default:h((()=>[c(y,{name:"open_in_new"}),g(" Get RapidAPI token ")])),_:1})])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[m("div",null,[va,c(u,{modelValue:n.value,"onUpdate:modelValue":e[1]||(e[1]=t=>n.value=t)},null,8,["modelValue"])])])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[c(w,{href:"https://rapidapi.com/Attacler/api/virusscan-texttoanything/",target:"_blank",align:"left",fullWidth:"",small:""},{default:h((()=>[c(y,{name:"open_in_new"}),g(" Get RapidAPI virusscanner token ")])),_:1})])),_:1}),c(A,{class:"action-buttons"},{default:h((()=>[c(w,{onClick:E,disabled:"apikeys"==v.value,id:"save-button"},{default:h((()=>["apikeys"!=v.value?(o(),p(S,{key:0},[g(" Save ")],64)):(o(),l(x,{key:1,small:!0,indeterminate:""}))])),_:1},8,["disabled"])])),_:1})])),_:1}),c(R,{class:"w-full"},{default:h((()=>[c(i,null,{default:h((()=>[g("Virusscanner settings")])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[m("div",null,[c(M,{modelValue:a.value,"onUpdate:modelValue":e[2]||(e[2]=t=>a.value=t),value:!1},{default:h((()=>[g(" Automatic scanning ")])),_:1},8,["modelValue"])])])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[m("div",null,[m("div",ba,[g(" Mode "),c(D,null,{default:h((({hover:t})=>[c(P,{name:"info"}),t?(o(),l(L,{key:0,class:"info-popup"},{default:h((()=>[ya])),_:1})):d("v-if",!0)])),_:1})]),c(I,{modelValue:f.value,"onUpdate:modelValue":e[3]||(e[3]=t=>f.value=t),items:[{text:"Delete threats",value:"delete"},{text:"Trigger flow",value:"flow"}]},null,8,["modelValue"])]),"flow"==f.value?(o(),p("div",wa,[m("div",xa,[g(" Flow "),c(D,null,{default:h((({hover:t})=>[c(P,{name:"info"}),t?(o(),l(L,{key:0,class:"info-popup"},{default:h((()=>[g(" This flow will be triggered once a virus has been detected. ")])),_:1})):d("v-if",!0)])),_:1})]),c(I,{items:T(k),showDeselect:"",modelValue:_.value,"onUpdate:modelValue":e[4]||(e[4]=t=>_.value=t)},null,8,["items","modelValue"])])):d("v-if",!0)])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[c(ga)])),_:1}),c(b,{class:"fields-spacing"},{default:h((()=>[c(w,{href:"https://texttoanything.nl/docs/directus/virusscanner",target:"_blank",align:"left",fullWidth:"",small:""},{default:h((()=>[c(y,{name:"open_in_new"}),g(" Virusscanner documentation ")])),_:1})])),_:1}),c(A,{class:"action-buttons"},{default:h((()=>[c(w,{onClick:C,disabled:"virus"==v.value,id:"save-button"},{default:h((()=>["virus"!=v.value?(o(),p(S,{key:0},[g(" Save ")],64)):(o(),l(x,{key:1,small:!0,indeterminate:""}))])),_:1},8,["disabled"])])),_:1})])),_:1})])])),_:1})}}});Qn("\n.w-full[data-v-7f9dbb3b] {\n width: 100%;\n}\n.cards-wrapper[data-v-7f9dbb3b] {\n padding: 0 2.5rem;\n display: flex;\n flex-wrap: wrap;\n gap: 2.5rem;\n}\n.fields-spacing[data-v-7f9dbb3b] {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n#save-button[data-v-7f9dbb3b] {\n margin-left: auto;\n}\n.info-parent[data-v-7f9dbb3b] {\n position: relative;\n display: flex;\n gap: 5px;\n}\n.info-parent .info-popup[data-v-7f9dbb3b] {\n position: absolute;\n top: 25px;\n left: 0;\n z-index: 10;\n}\n",{}),Aa.__scopeId="data-v-7f9dbb3b",Aa.__file="settingsmodule/src/pages/settings.vue";var ka=v({__name:"dateTimePicker",props:{value:{type:[String,null],required:!0}},setup(t,{emit:e}){const i=t,s=u(),n=u(i.value);const a=b((()=>function(t){const e=new Date(t||-1);return e instanceof Date&&!isNaN(e.getTime())&&1970!=e.getFullYear()}(null==n?void 0:n.value)));return y((()=>n.value),(()=>{a.value&&(console.log(" Updating with",n.value),e("update:modelValue",n.value))})),(t,e)=>{const i=r("v-input"),l=r("v-date-picker"),d=r("v-menu");return o(),p("div",null,[c(d,{ref_key:"dateTimeMenu",ref:s,"close-on-content-click":!1,attached:"","full-height":"",seamless:""},{activator:h((({toggle:t,active:e})=>[c(i,{active:e,clickable:"",readonly:"",placeholder:T(a)?void 0:n.value,onClick:t},R({_:2},[T(a)?{name:"prepend",fn:h((()=>[g(A(n.value),1)])),key:"0"}:void 0]),1032,["active","placeholder","onClick"])])),default:h((()=>{var t;return[c(l,{type:"date","use-24":!0,"include-seconds":!1,"model-value":n.value,"onUpdate:modelValue":e[0]||(e[0]=t=>n.value=t),onClose:null==(t=s.value)?void 0:t.deactivate},null,8,["model-value","onClose"])]})),_:1},512)])}}});Qn("\n.v-icon.today-icon[data-v-42405105]:hover,\n.v-icon.today-icon.active[data-v-42405105] {\n --v-icon-color: var(--theme--primary);\n}\n.v-icon.clear-icon[data-v-42405105]:hover,\n.v-icon.clear-icon.active[data-v-42405105] {\n --v-icon-color: var(--theme--danger);\n}\n",{}),ka.__scopeId="data-v-42405105",ka.__file="settingsmodule/src/components/dateTimePicker.vue";var Ta={d:(t,e)=>{for(var i in e)Ta.o(e,i)&&!Ta.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Sa={};function Ea(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,s=new Array(e);i<e;i++)s[i]=t[i];return s}function Ca(t,e){if(t){if("string"==typeof t)return Ea(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Ea(t,e):void 0}}function Ra(t){return function(t){if(Array.isArray(t))return Ea(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ca(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ma(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Ta.d(Sa,{Z:()=>Ka});const Pa=(Oa={computed:()=>a.computed,createTextVNode:()=>a.createTextVNode,createVNode:()=>a.createVNode,defineComponent:()=>a.defineComponent,reactive:()=>a.reactive,ref:()=>a.ref,watch:()=>a.watch,watchEffect:()=>a.watchEffect},Na={},Ta.d(Na,Oa),Na),La=(0,Pa.defineComponent)({props:{data:{required:!0,type:String},onClick:Function},render:function(){var t=this.data,e=this.onClick;return(0,Pa.createVNode)("span",{class:"vjs-tree-brackets",onClick:e},[t])}}),Da=(0,Pa.defineComponent)({emits:["change","update:modelValue"],props:{checked:{type:Boolean,default:!1},isMultiple:Boolean,onChange:Function},setup:function(t,e){var i=e.emit;return{uiType:(0,Pa.computed)((function(){return t.isMultiple?"checkbox":"radio"})),model:(0,Pa.computed)({get:function(){return t.checked},set:function(t){return i("update:modelValue",t)}})}},render:function(){var t=this.uiType,e=this.model,i=this.$emit;return(0,Pa.createVNode)("label",{class:["vjs-check-controller",e?"is-checked":""],onClick:function(t){return t.stopPropagation()}},[(0,Pa.createVNode)("span",{class:"vjs-check-controller-inner is-".concat(t)},null),(0,Pa.createVNode)("input",{checked:e,class:"vjs-check-controller-original is-".concat(t),type:t,onChange:function(){return i("change",e)}},null)])}}),Ia=(0,Pa.defineComponent)({props:{nodeType:{required:!0,type:String},onClick:Function},render:function(){var t=this.nodeType,e=this.onClick,i="objectStart"===t||"arrayStart"===t;return i||"objectCollapsed"===t||"arrayCollapsed"===t?(0,Pa.createVNode)("span",{class:"vjs-carets vjs-carets-".concat(i?"open":"close"),onClick:e},[(0,Pa.createVNode)("svg",{viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true"},[(0,Pa.createVNode)("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"},null)])]):null}});var Oa,Na;function Fa(t){return Fa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fa(t)}function Ba(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function ja(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"root",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=(arguments.length>3?arguments[3]:void 0)||{},n=s.key,a=s.index,r=s.type,o=void 0===r?"content":r,l=s.showComma,h=void 0!==l&&l,c=s.length,d=void 0===c?1:c,u=Ba(t);if("array"===u){var p=za(t.map((function(t,s,n){return ja(t,"".concat(e,"[").concat(s,"]"),i+1,{index:s,showComma:s!==n.length-1,length:d,type:o})})));return[ja("[",e,i,{showComma:!1,key:n,length:t.length,type:"arrayStart"})[0]].concat(p,ja("]",e,i,{showComma:h,length:t.length,type:"arrayEnd"})[0])}if("object"===u){var g=Object.keys(t),f=za(g.map((function(s,n,a){return ja(t[s],/^[a-zA-Z_]\w*$/.test(s)?"".concat(e,".").concat(s):"".concat(e,'["').concat(s,'"]'),i+1,{key:s,showComma:n!==a.length-1,length:d,type:o})})));return[ja("{",e,i,{showComma:!1,key:n,index:a,length:g.length,type:"objectStart"})[0]].concat(f,ja("}",e,i,{showComma:h,length:g.length,type:"objectEnd"})[0])}return[{content:t,level:i,key:n,index:a,path:e,showComma:h,length:d,type:o}]}function za(t){if("function"==typeof Array.prototype.flat)return t.flat();for(var e=Ra(t),i=[];e.length;){var s=e.shift();Array.isArray(s)?e.unshift.apply(e,Ra(s)):i.push(s)}return i}function Va(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if(null==t)return t;if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if("object"!==Fa(t))return t;if(e.get(t))return e.get(t);if(Array.isArray(t)){var i=t.map((function(t){return Va(t,e)}));return e.set(t,i),i}var s={};for(var n in t)s[n]=Va(t[n],e);return e.set(t,s),s}function Ua(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function Ha(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Ua(Object(i),!0).forEach((function(e){Ma(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Ua(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}var $a={showLength:{type:Boolean,default:!1},showDoubleQuotes:{type:Boolean,default:!0},renderNodeKey:Function,renderNodeValue:Function,selectableType:String,showSelectController:{type:Boolean,default:!1},showLine:{type:Boolean,default:!0},showLineNumber:{type:Boolean,default:!1},selectOnClickNode:{type:Boolean,default:!0},nodeSelectable:{type:Function,default:function(){return!0}},highlightSelectedNode:{type:Boolean,default:!0},showIcon:{type:Boolean,default:!1},theme:{type:String,default:"light"},showKeyValueSpace:{type:Boolean,default:!0},editable:{type:Boolean,default:!1},editableTrigger:{type:String,default:"click"},onNodeClick:{type:Function},onBracketsClick:{type:Function},onIconClick:{type:Function},onValueChange:{type:Function}};const Wa=(0,Pa.defineComponent)({name:"TreeNode",props:Ha(Ha({},$a),{},{node:{type:Object,required:!0},collapsed:Boolean,checked:Boolean,style:Object,onSelectedChange:{type:Function}}),emits:["nodeClick","bracketsClick","iconClick","selectedChange","valueChange"],setup:function(t,e){var i=e.emit,s=(0,Pa.computed)((function(){return Ba(t.node.content)})),n=(0,Pa.computed)((function(){return"vjs-value vjs-value-".concat(s.value)})),a=(0,Pa.computed)((function(){return t.showDoubleQuotes?'"'.concat(t.node.key,'"'):t.node.key})),r=(0,Pa.computed)((function(){return"multiple"===t.selectableType})),o=(0,Pa.computed)((function(){return"single"===t.selectableType})),l=(0,Pa.computed)((function(){return t.nodeSelectable(t.node)&&(r.value||o.value)})),h=(0,Pa.reactive)({editing:!1}),c=function(e){var s,n,a="null"===(n=null===(s=e.target)||void 0===s?void 0:s.value)?null:"undefined"===n?void 0:"true"===n||"false"!==n&&(n[0]+n[n.length-1]==='""'||n[0]+n[n.length-1]==="''"?n.slice(1,-1):"number"==typeof Number(n)&&!isNaN(Number(n))||"NaN"===n?Number(n):n);i("valueChange",a,t.node.path)},d=(0,Pa.computed)((function(){var e,i=null===(e=t.node)||void 0===e?void 0:e.content;return null===i?i="null":void 0===i&&(i="undefined"),"string"===s.value?'"'.concat(i,'"'):i+""})),u=function(){var e=t.renderNodeValue;return e?e({node:t.node,defaultValue:d.value}):d.value},p=function(){i("bracketsClick",!t.collapsed,t.node)},g=function(){i("iconClick",!t.collapsed,t.node)},f=function(){i("selectedChange",t.node)},_=function(){i("nodeClick",t.node),l.value&&t.selectOnClickNode&&i("selectedChange",t.node)},m=function(e){if(t.editable&&!h.editing){h.editing=!0;var i=function t(i){var s;i.target!==e.target&&(null===(s=i.target)||void 0===s?void 0:s.parentElement)!==e.target&&(h.editing=!1,document.removeEventListener("click",t))};document.removeEventListener("click",i),document.addEventListener("click",i)}};return function(){var e,i=t.node;return(0,Pa.createVNode)("div",{class:{"vjs-tree-node":!0,"has-selector":t.showSelectController,"has-carets":t.showIcon,"is-highlight":t.highlightSelectedNode&&t.checked,dark:"dark"===t.theme},onClick:_,style:t.style},[t.showLineNumber&&(0,Pa.createVNode)("span",{class:"vjs-node-index"},[i.id+1]),t.showSelectController&&l.value&&"objectEnd"!==i.type&&"arrayEnd"!==i.type&&(0,Pa.createVNode)(Da,{isMultiple:r.value,checked:t.checked,onChange:f},null),(0,Pa.createVNode)("div",{class:"vjs-indent"},[Array.from(Array(i.level)).map((function(e,i){return(0,Pa.createVNode)("div",{key:i,class:{"vjs-indent-unit":!0,"has-line":t.showLine}},null)})),t.showIcon&&(0,Pa.createVNode)(Ia,{nodeType:i.type,onClick:g},null)]),i.key&&(0,Pa.createVNode)("span",{class:"vjs-key"},[(e=t.renderNodeKey,e?e({node:t.node,defaultKey:a.value||""}):a.value),(0,Pa.createVNode)("span",{class:"vjs-colon"},[":".concat(t.showKeyValueSpace?" ":"")])]),(0,Pa.createVNode)("span",null,["content"!==i.type&&i.content?(0,Pa.createVNode)(La,{data:i.content.toString(),onClick:p},null):(0,Pa.createVNode)("span",{class:n.value,onClick:!t.editable||t.editableTrigger&&"click"!==t.editableTrigger?void 0:m,onDblclick:t.editable&&"dblclick"===t.editableTrigger?m:void 0},[t.editable&&h.editing?(0,Pa.createVNode)("input",{value:d.value,onChange:c,style:{padding:"3px 8px",border:"1px solid #eee",boxShadow:"none",boxSizing:"border-box",borderRadius:5,fontFamily:"inherit"}},null):u()]),i.showComma&&(0,Pa.createVNode)("span",null,[","]),t.showLength&&t.collapsed&&(0,Pa.createVNode)("span",{class:"vjs-comment"},[(0,Pa.createTextVNode)(" // "),i.length,(0,Pa.createTextVNode)(" items ")])])])}}});function Ga(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,s)}return i}function qa(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Ga(Object(i),!0).forEach((function(e){Ma(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Ga(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}const Ka=(0,Pa.defineComponent)({name:"Tree",props:qa(qa({},$a),{},{data:{type:[String,Number,Boolean,Array,Object],default:null},collapsedNodeLength:{type:Number,default:1/0},deep:{type:Number,default:1/0},pathCollapsible:{type:Function,default:function(){return!1}},rootPath:{type:String,default:"root"},virtual:{type:Boolean,default:!1},height:{type:Number,default:400},itemHeight:{type:Number,default:20},selectedValue:{type:[String,Array],default:function(){return""}},collapsedOnClickBrackets:{type:Boolean,default:!0},style:Object,onSelectedChange:{type:Function},theme:{type:String,default:"light"}}),slots:["renderNodeKey","renderNodeValue"],emits:["nodeClick","bracketsClick","iconClick","selectedChange","update:selectedValue","update:data"],setup:function(t,e){var i=e.emit,s=e.slots,n=(0,Pa.ref)(),a=(0,Pa.computed)((function(){return ja(t.data,t.rootPath)})),r=function(e,i){return a.value.reduce((function(s,n){var a,r=n.level>=e||n.length>=i,o=null===(a=t.pathCollapsible)||void 0===a?void 0:a.call(t,n);return"objectStart"!==n.type&&"arrayStart"!==n.type||!r&&!o?s:qa(qa({},s),{},Ma({},n.path,1))}),{})},o=(0,Pa.reactive)({translateY:0,visibleData:null,hiddenPaths:r(t.deep,t.collapsedNodeLength)}),l=(0,Pa.computed)((function(){for(var t=null,e=[],i=a.value.length,s=0;s<i;s++){var n=qa(qa({},a.value[s]),{},{id:s}),r=o.hiddenPaths[n.path];if(t&&t.path===n.path){var l="objectStart"===t.type,h=qa(qa(qa({},n),t),{},{showComma:n.showComma,content:l?"{...}":"[...]",type:l?"objectCollapsed":"arrayCollapsed"});t=null,e.push(h)}else{if(r&&!t){t=n;continue}if(t)continue;e.push(n)}}return e})),h=(0,Pa.computed)((function(){var e=t.selectedValue;return e&&"multiple"===t.selectableType&&Array.isArray(e)?e:[e]})),c=(0,Pa.computed)((function(){return!t.selectableType||t.selectOnClickNode||t.showSelectController?"":"When selectableType is not null, selectOnClickNode and showSelectController cannot be false at the same time, because this will cause the selection to fail."})),d=function(){var e=l.value;if(t.virtual){var i,s=t.height/t.itemHeight,a=(null===(i=n.value)||void 0===i?void 0:i.scrollTop)||0,r=Math.floor(a/t.itemHeight),h=r<0?0:r+s>e.length?e.length-s:r;h<0&&(h=0);var c=h+s;o.translateY=h*t.itemHeight,o.visibleData=e.filter((function(t,e){return e>=h&&e<c}))}else o.visibleData=e},u=function(){d()},p=function(e){var s,n=e.path,a=t.selectableType;if("multiple"===a){var r=h.value.findIndex((function(t){return t===n})),o=Ra(h.value);-1!==r?o.splice(r,1):o.push(n),i("update:selectedValue",o),i("selectedChange",o,Ra(h.value))}else if("single"===a&&h.value[0]!==n){var l=(s=h.value,function(t){if(Array.isArray(t))return t}(s)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var i,s,n=[],a=!0,r=!1;try{for(e=e.call(t);!(a=(i=e.next()).done)&&(n.push(i.value),1!==n.length);a=!0);}catch(t){r=!0,s=t}finally{try{a||null==e.return||e.return()}finally{if(r)throw s}}return n}}(s)||Ca(s,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],c=n;i("update:selectedValue",c),i("selectedChange",c,l)}},g=function(t){i("nodeClick",t)},f=function(t,e){if(t)o.hiddenPaths=qa(qa({},o.hiddenPaths),{},Ma({},e,1));else{var i=qa({},o.hiddenPaths);delete i[e],o.hiddenPaths=i}},_=function(e,s){t.collapsedOnClickBrackets&&f(e,s.path),i("bracketsClick",e,s)},m=function(t,e){f(t,e.path),i("iconClick",t,e)},v=function(e,s){var n=Va(t.data),a=t.rootPath;new Function("data","val","data".concat(s.slice(a.length),"=val"))(n,e),i("update:data",n)};return(0,Pa.watchEffect)((function(){c.value&&function(t){throw new Error("[VueJSONPretty] ".concat(t))}(c.value)})),(0,Pa.watchEffect)((function(){l.value&&d()})),(0,Pa.watch)((function(){return t.deep}),(function(e){e&&(o.hiddenPaths=r(e,t.collapsedNodeLength))})),(0,Pa.watch)((function(){return t.collapsedNodeLength}),(function(e){e&&(o.hiddenPaths=r(t.deep,e))})),function(){var e,i,r=null!==(e=t.renderNodeKey)&&void 0!==e?e:s.renderNodeKey,c=null!==(i=t.renderNodeValue)&&void 0!==i?i:s.renderNodeValue,d=o.visibleData&&o.visibleData.map((function(e){return(0,Pa.createVNode)(Wa,{key:e.id,node:e,collapsed:!!o.hiddenPaths[e.path],theme:t.theme,showDoubleQuotes:t.showDoubleQuotes,showLength:t.showLength,checked:h.value.includes(e.path),selectableType:t.selectableType,showLine:t.showLine,showLineNumber:t.showLineNumber,showSelectController:t.showSelectController,selectOnClickNode:t.selectOnClickNode,nodeSelectable:t.nodeSelectable,highlightSelectedNode:t.highlightSelectedNode,editable:t.editable,editableTrigger:t.editableTrigger,showIcon:t.showIcon,showKeyValueSpace:t.showKeyValueSpace,renderNodeKey:r,renderNodeValue:c,onNodeClick:g,onBracketsClick:_,onIconClick:m,onSelectedChange:p,onValueChange:v,style:t.itemHeight&&20!==t.itemHeight?{lineHeight:"".concat(t.itemHeight,"px")}:{}},null)}));return(0,Pa.createVNode)("div",{ref:n,class:{"vjs-tree":!0,"is-virtual":t.virtual,dark:"dark"===t.theme},onScroll:t.virtual?u:void 0,style:t.showLineNumber?qa({paddingLeft:"".concat(12*Number(a.value.length.toString().length),"px")},t.style):t.style},[t.virtual?(0,Pa.createVNode)("div",{class:"vjs-tree-list",style:{height:"".concat(t.height,"px")}},[(0,Pa.createVNode)("div",{class:"vjs-tree-list-holder",style:{height:"".concat(l.value.length*t.itemHeight,"px")}},[(0,Pa.createVNode)("div",{class:"vjs-tree-list-holder-inner",style:{transform:"translateY(".concat(o.translateY,"px)")}},[d])])]):d])}}});var Xa=Sa.Z;Qn('.vjs-tree-brackets{cursor:pointer}.vjs-tree-brackets:hover{color:#1890ff}.vjs-check-controller{position:absolute;left:0}.vjs-check-controller.is-checked .vjs-check-controller-inner{background-color:#1890ff;border-color:#0076e4}.vjs-check-controller.is-checked .vjs-check-controller-inner.is-checkbox:after{transform:rotate(45deg) scaleY(1)}.vjs-check-controller.is-checked .vjs-check-controller-inner.is-radio:after{transform:translate(-50%,-50%) scale(1)}.vjs-check-controller .vjs-check-controller-inner{display:inline-block;position:relative;border:1px solid #bfcbd9;border-radius:2px;vertical-align:middle;box-sizing:border-box;width:16px;height:16px;background-color:#fff;z-index:1;cursor:pointer;transition:border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46)}.vjs-check-controller .vjs-check-controller-inner:after{box-sizing:content-box;content:"";border:2px solid #fff;border-left:0;border-top:0;height:8px;left:4px;position:absolute;top:1px;transform:rotate(45deg) scaleY(0);width:4px;transition:transform .15s cubic-bezier(.71,-.46,.88,.6) .05s;transform-origin:center}.vjs-check-controller .vjs-check-controller-inner.is-radio{border-radius:100%}.vjs-check-controller .vjs-check-controller-inner.is-radio:after{border-radius:100%;height:4px;background-color:#fff;left:50%;top:50%}.vjs-check-controller .vjs-check-controller-original{opacity:0;outline:none;position:absolute;z-index:-1;top:0;left:0;right:0;bottom:0;margin:0}.vjs-carets{position:absolute;right:0;cursor:pointer}.vjs-carets svg{transition:transform .3s}.vjs-carets:hover{color:#1890ff}.vjs-carets-close{transform:rotate(-90deg)}.vjs-tree-node{display:flex;position:relative;line-height:20px}.vjs-tree-node.has-carets{padding-left:15px}.vjs-tree-node.has-carets.has-selector,.vjs-tree-node.has-selector{padding-left:30px}.vjs-tree-node.is-highlight,.vjs-tree-node:hover{background-color:#e6f7ff}.vjs-tree-node .vjs-indent{display:flex;position:relative}.vjs-tree-node .vjs-indent-unit{width:1em}.vjs-tree-node .vjs-indent-unit.has-line{border-left:1px dashed #bfcbd9}.vjs-tree-node.dark.is-highlight,.vjs-tree-node.dark:hover{background-color:#2e4558}.vjs-node-index{position:absolute;right:100%;margin-right:4px;user-select:none}.vjs-colon{white-space:pre}.vjs-comment{color:#bfcbd9}.vjs-value{word-break:break-word}.vjs-value-null,.vjs-value-undefined{color:#d55fde}.vjs-value-boolean,.vjs-value-number{color:#1d8ce0}.vjs-value-string{color:#13ce66}.vjs-tree{font-family:Monaco,Menlo,Consolas,Bitstream Vera Sans Mono,monospace;font-size:14px;text-align:left}.vjs-tree.is-virtual{overflow:auto}.vjs-tree.is-virtual .vjs-tree-node{white-space:nowrap}',{});const Ya=t=>(f("data-v-2ded8f93"),t=t(),_(),t),Qa={class:"content"},Ja=Ya((()=>m("div",{class:"header"},[m("span",{class:"dot success"}),m("span",{class:"type-label"}," Trigger ")],-1))),Za={class:"inset"},tr={class:"steps"},er={class:"header"},ir={class:"type-label"},sr={class:"subdued"},nr={class:"inset"};var ar=v({__name:"displayFlowLogs",props:{currentLog:{type:null,required:!0}},setup(t,{emit:e}){const{currentLog:i}=t,s=u(""),n=b((()=>{const{data:t}=i;if(!t)return[];return((null==t?void 0:t.steps)||[]).map((e=>({...e,status:"resolve"===e.status?"success":"error",operationType:e.operationType||"",options:e.options?e.options:null,data:t.data[e.key]?t.data[e.key]:null})))}));function a(t,e){console.log(i),s.value=t+e.path.substring(4)}function f(){navigator.clipboard.writeText(s.value)}return(i,u)=>{const _=r("v-icon"),v=r("v-button"),b=r("v-detail"),y=r("v-drawer"),w=M("tooltip");return o(),l(y,{modelValue:!0,title:"Flow log",icon:"fact_check",onEsc:u[1]||(u[1]=t=>e("close")),onCancel:u[2]||(u[2]=t=>e("close"))},{actions:h((()=>[s.value?(o(),l(v,{key:0,class:"ml-auto",onClick:f},{default:h((()=>[g(A(s.value)+" ",1),c(_,{name:"copy_all"})])),_:1})):d("v-if",!0)])),default:h((()=>[m("div",Qa,[Ja,m("div",Za,[c(b,{label:"Payload",class:"payload"},{default:h((()=>[c(T(Xa),{data:t.currentLog.data.data.$trigger,virtual:"",onNodeClick:u[0]||(u[0]=t=>a("$trigger",t)),selectableType:"single"},null,8,["data"])])),_:1})]),m("div",tr,[(o(!0),p(S,null,P(T(n),(t=>(o(),p("div",{key:t.id,class:"step"},[m("div",er,[m("span",{class:L(["dot",t.status])},null,2),D((o(),p("span",ir,[g(A(t.key)+" ",1),m("span",sr," "+A(t.operationType),1)])),[[w,t.key]])]),m("div",nr,[t.options?(o(),l(b,{key:0,label:"Options"},{default:h((()=>[c(T(Xa),{data:t.options,virtual:""},null,8,["data"])])),_:2},1024)):d("v-if",!0),null!==t.data?(o(),l(b,{key:1,label:"Payload",class:"payload"},{default:h((()=>[c(T(Xa),{data:t.data,virtual:"",onNodeClick:e=>a(t.key,e),selectableType:"single"},null,8,["data","onNodeClick"])])),_:2},1024)):d("v-if",!0)])])))),128))])])])),_:1})}}});Qn("\n.content[data-v-2ded8f93] {\n padding: 1rem;\n}\n.header[data-v-2ded8f93] {\n font-size: 1.2rem;\n font-weight: bold;\n}\n.dot[data-v-2ded8f93] {\n width: 0.75rem;\n height: 0.75rem;\n border-radius: 50%;\n margin-right: 0.5rem;\n display: inline-block;\n}\n.dot.success[data-v-2ded8f93] {\n background-color: var(--primary);\n}\n.dot.error[data-v-2ded8f93] {\n background-color: var(--red);\n}\n.step[data-v-2ded8f93] {\n margin: 0.5rem 0;\n position: relative;\n}\n.inset[data-v-2ded8f93] {\n border-left: var(--theme--border-width) solid\n var(--theme--border-color-subdued);\n margin-left: 0.35rem;\n padding-top: 5px;\n padding-left: 1rem;\n margin-top: -5px;\n}\n",{});Qn("\n.payload .vjs-value,\n.payload .vjs-key {\n cursor: pointer;\n}\n",{}),ar.__scopeId="data-v-2ded8f93",ar.__file="settingsmodule/src/components/displayFlowLogs.vue";const rr=t=>(f("data-v-231dc418"),t=t(),_(),t),or={class:"px-5 w-full"},lr=["title"],hr=["title"],cr={class:"filters"},dr=rr((()=>m("h2",null,"Filter",-1))),ur=rr((()=>m("div",{class:"field-name"},"Flow",-1))),pr=rr((()=>m("div",{class:"field-name"},"From date",-1))),gr=rr((()=>m("div",{class:"field-name"},"To date",-1))),fr=rr((()=>m("div",{class:"field-name"},"Sorting order",-1)));var _r=v({__name:"flowLogsExplorer",setup(t){const{useFlowsStore:s}=e(),n=i(),a=s(),p=u(),f=u([]),_=u(),v=u(),y=u(""),w=u("all"),k=u(),S=u("Descending");async function E(){const t=await n.get("/revisions",{params:{"filter[_and][0][collection][_eq]":"directus_flows","filter[_and][1][item][_eq]":p.value||void 0,"filter[_and][2][version][_null]":!0,"filter[_and][3][activity][action][_eq]":"run","filter[_and][4][activity][timestamp][_gte]":_.value?_.value:void 0,"filter[_and][4][activity][timestamp][_lte]":v.value?v.value+"T23:59:59":void 0,"fields[0]":"*","fields[1]":"activity.*",limit:2e3,sort:"Descending"==S.value?["-activity.timestamp"]:["activity.timestamp"]}});f.value=t.data.data}x((()=>{const t=new Date;t.setDate(t.getDate()-7),_.value=t.toISOString().split("T")[0],v.value=(new Date).toISOString().split("T")[0]}));const C=b((()=>{if(!y.value&&"all"==w.value)return f.value;let t=f.value;return"all"!=w.value&&(t=t.filter((t=>t.data.steps[t.data.steps.length-1].status==("error"==w.value?"reject":"resolve")))),y.value&&(t=f.value.filter((t=>{const e=t.data.data.$trigger;return JSON.stringify(e).toLowerCase().includes(y.value.toLowerCase())}))),t})),R=b((()=>a.flows.map((t=>({text:t.name,value:t.id})))));function M(t){var e;if(0==t.data.steps.length)return"";const i=null==(e=t.data.steps[t.data.steps.length-1])?void 0:e.key;return i?t.data.data[i]:""}function P(t){k.value=t.item}function D(t){if(0==t.data.steps.length)return!1;return"resolve"!=t.data.steps[t.data.steps.length-1].status}return(t,e)=>{const i=r("v-icon"),s=r("v-table"),n=r("v-select"),a=r("v-button"),u=r("v-input"),f=r("VSelect"),b=r("private-view");return o(),l(b,{title:"Flow logs explorer"},{navigation:h((()=>[c(Hn)])),sidebar:h((()=>[m("div",cr,[dr,m("div",null,[ur,c(n,{items:T(R),showDeselect:"",modelValue:p.value,"onUpdate:modelValue":e[0]||(e[0]=t=>p.value=t)},null,8,["items","modelValue"])]),m("div",null,[pr,_.value?(o(),l(ka,{key:0,modelValue:_.value,"onUpdate:modelValue":e[1]||(e[1]=t=>_.value=t),value:_.value},null,8,["modelValue","value"])):d("v-if",!0)]),m("div",null,[gr,v.value?(o(),l(ka,{key:0,modelValue:v.value,"onUpdate:modelValue":e[2]||(e[2]=t=>v.value=t),value:v.value},null,8,["modelValue","value"])):d("v-if",!0)]),m("div",null,[fr,c(n,{modelValue:S.value,"onUpdate:modelValue":e[3]||(e[3]=t=>S.value=t),items:["Descending","Ascending"]},null,8,["modelValue"])]),c(a,{onClick:E,fullWidth:!0},{default:h((()=>[g("Search")])),_:1}),m("div",null,[g(" Input filter "),c(u,{modelValue:y.value,"onUpdate:modelValue":e[4]||(e[4]=t=>y.value=t),placeholder:"Input filter",class:"w-full"},null,8,["modelValue"])]),m("div",null,[g(" Status "),c(f,{modelValue:w.value,"onUpdate:modelValue":e[5]||(e[5]=t=>w.value=t),items:[{text:"All",value:"all"},{text:"Error",value:"error"},{text:"Success",value:"success"}]},null,8,["modelValue"])])]),k.value?(o(),l(ar,{key:0,onClose:e[6]||(e[6]=t=>k.value=null),currentLog:k.value},null,8,["currentLog"])):d("v-if",!0)])),default:h((()=>[m("div",or,[c(s,{headers:[{text:"Status",value:"status",sortable:!1,width:100},{text:"Timestamp",value:"timestamp",sortable:!1,width:100},{text:"Input",value:"input",sortable:!1,width:1e3},{text:"Output",value:"output",sortable:!1,width:1e3}],items:T(C),"onClick:row":P},{"item.status":h((({item:t})=>[c(i,{name:D(t)?"error":"check_circle",class:L(["flowLogStatus",{error:D(t),success:!D(t)}])},null,8,["name","class"])])),"item.timestamp":h((({item:t})=>[g(A(new Date(t.activity.timestamp).toLocaleDateString()),1)])),"item.input":h((({item:t})=>[m("div",{title:JSON.stringify(t.data.data.$trigger,null,2)},A(t.data.data.$trigger),9,lr)])),"item.output":h((({item:t})=>[m("div",{title:JSON.stringify(M(t),null,2)},A(M(t)),9,hr)])),_:1},8,["items"])])])),_:1})}}});Qn("\n.w-full[data-v-231dc418] {\n width: 100%;\n}\n.px-5[data-v-231dc418] {\n padding: 0 2.5rem;\n}\n.date-input[data-v-231dc418] {\n min-width: 300px;\n}\n.filters[data-v-231dc418] {\n padding: 10px 5px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.filters h2[data-v-231dc418] {\n font-size: 1.5rem;\n font-weight: bold;\n}\n.grow[data-v-231dc418],\n.grow button[data-v-231dc418] {\n flex-grow: 1;\n}\n.flowLogStatus.success[data-v-231dc418] {\n color: var(--primary);\n}\n.flowLogStatus.error[data-v-231dc418] {\n color: var(--red);\n}\n",{}),_r.__scopeId="data-v-231dc418",_r.__file="settingsmodule/src/pages/flowLogsExplorer.vue";var mr=s({id:"tta_settings",name:"Text to anything settings",icon:"text_fields",routes:[{path:"",redirect:"/tta_settings/templates"},{path:"templates",component:pa},{path:"settings",component:Aa},{path:"flowsLogExplorer",component:_r}]}),vr=v({__name:"interface",props:["value"],emits:["input"],setup(t,{emit:e}){const i=t,s=I("api"),n=u(0),a=u([]);return x((async()=>{y((()=>n.value),((t,i)=>{t!=i&&e("input",t)}));const t=await s.get("/tta/pdf/onlineTemplates");a.value=t.data.map((t=>({text:t.name,value:t.id}))),t.data.find((t=>t.id==i.value))?n.value=parseInt(i.value):n.value=null})),(t,e)=>{const i=r("v-select");return o(),l(i,{modelValue:n.value,"onUpdate:modelValue":e[0]||(e[0]=t=>n.value=t),items:a.value},null,8,["modelValue","items"])}}});vr.__file="pdf/PDFOnlineTemplateSelector/src/interface.vue";var br=n({id:"TTA-pdf-online-template-selector",name:"PDF online template selector",icon:"picture_as_pdf",description:"Selector for an online PDF template for Text To Anything",component:vr,options:null,types:["string"]}),yr=v({__name:"interface",props:["value"],emits:["input"],setup(t,{emit:e}){const i=t,s=I("api"),n=u(""),a=u([]);return x((async()=>{y((()=>n.value),((t,i)=>{t!=i&&e("input",t)}));const t=await s.get("/items/TTA_htmltemplates");a.value=t.data.data.map((t=>({text:t.name,value:t.id}))),n.value=i.value})),(t,e)=>{const i=r("v-select");return o(),l(i,{modelValue:n.value,"onUpdate:modelValue":e[0]||(e[0]=t=>n.value=t),items:a.value},null,8,["modelValue","items"])}}});yr.__file="pdf/PDFTemplateSelector/src/interface.vue";var wr=n({id:"TTA-pdf-template-selector",name:"PDF template selector",icon:"picture_as_pdf",description:"Selector for a PDF template for Text To Anything",component:yr,options:null,types:["string"]});const xr={style:{display:"none"}};var Ar=v({__name:"interface",props:{label:{type:String,required:!0},flow:{type:null,required:!0},primaryKey:{type:null,required:!0}},setup(t){const e=t,s=i(),n=u(!1);async function a(){n.value=!0;try{const t=await s.post("/flows/trigger/"+e.flow,{id:e.primaryKey});window.open("/assets/"+t.data,"_blank")}catch(t){}n.value=!1}return(t,i)=>{const s=r("VButton");return o(),p(S,null,[c(s,{onClick:a,loading:n.value,disabled:n.value},{default:h((()=>[g(A(e.label),1)])),_:1},8,["loading","disabled"]),m("div",xr,[c(s,{loading:!0,disabled:!0})])],64)}}});Ar.__file="pdf/GeneratePDFFromTemplateInterface/src/interface.vue";var kr=n({id:"tta-download-interface",name:"Download interface",icon:"sim_card_download",description:"Download files based on a flow. (Text to anything)",hideLabel:!0,hideLoader:!0,component:Ar,options:()=>{const{useFlowsStore:t}=e(),i=t();return[{field:"label",type:"string",name:"$t:label",meta:{width:"full",interface:"system-input-translated-string",options:{placeholder:"$t:label"}}},{field:"flow",name:"$t:operations.trigger.flow",type:"string",meta:{width:"full",interface:"select-dropdown",options:{choices:b((()=>i.flows.filter((t=>"webhook"===t.trigger&&"POST"==t.options.method)).map((t=>({text:t.name,value:t.id}))))),iconRight:"bolt",placeholder:"$t:a_flow_uuid"}}}]},types:["string"]});
|
|
2
2
|
/**
|
|
3
3
|
* @licstart The following is the entire license notice for the
|
|
4
4
|
* JavaScript code in this page
|
|
@@ -19,4 +19,4 @@ import{defineOperationApp as t,useStores as e,useApi as i,defineModule as s,defi
|
|
|
19
19
|
*
|
|
20
20
|
* @licend The above is the entire license notice for the
|
|
21
21
|
* JavaScript code in this page
|
|
22
|
-
*/const Pa=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Da=[.001,0,0,.001,0,0],Ia=1.35,Ra=1,La=2,Fa=4,Na=16,Oa=32,Ba=64,za=128,ja=256,Va={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ha={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101},$a={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Ua=0,Ga=1,qa=2,Wa=3,Ka=3,Xa=4,Ya={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Qa={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},Ja=1,Za=2,tr=3,er=4,ir=5,sr={ERRORS:0,WARNINGS:1,INFOS:5},nr={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,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},ar=0,rr=1,or=2,lr=3;let hr=sr.WARNINGS;function cr(t){Number.isInteger(t)&&(hr=t)}function dr(){return hr}function ur(t){hr>=sr.INFOS&&console.log(`Info: ${t}`)}function pr(t){hr>=sr.WARNINGS&&console.log(`Warning: ${t}`)}function gr(t){throw new Error(t)}function fr(t,e){t||gr(e)}function mr(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function vr(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&mr(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function br(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const yr=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class wr extends yr{constructor(t,e){super(t,"PasswordException"),this.code=e}}class xr extends yr{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ar extends yr{constructor(t){super(t,"InvalidPDFException")}}class _r extends yr{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class Sr extends yr{constructor(t){super(t,"FormatError")}}class Tr extends yr{constructor(t){super(t,"AbortException")}}function kr(t){"object"==typeof t&&void 0!==t?.length||gr("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const a=Math.min(n+i,e),r=t.subarray(n,a);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function Cr(t){"string"!=typeof t&&gr("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class Er{static get isLittleEndian(){return br(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return br(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return br(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return br(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return br(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return br(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Mr=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class Pr{static makeHexColor(t,e,i){return`#${Mr[t]}${Mr[e]}${Mr[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}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,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){const h=t[i+e],c=t[i+e+1];t[i+e]=h*s+c*a+o,t[i+e+1]=h*n+c*r+l}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3];let p=s*h+o,g=p,f=s*d+o,m=f,v=r*c+l,b=v,y=r*u+l,w=y;if(0!==n||0!==a){const t=n*h,e=n*d,i=a*c,s=a*u;p+=i,m+=i,f+=s,g+=s,v+=t,w+=t,y+=e,b+=e}i[0]=Math.min(i[0],p,f,g,m),i[1]=Math.min(i[1],v,y,b,w),i[2]=Math.max(i[2],p,f,g,m),i[3]=Math.max(i[3],v,y,b,w)}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 singularValueDecompose2dScale(t,e){const i=t[0],s=t[1],n=t[2],a=t[3],r=i**2+s**2,o=i*n+s*a,l=n**2+a**2,h=(r+l)/2,c=Math.sqrt(h**2-(r*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}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){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[i,n,s,a]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static#t(t,e,i,s,n,a,r,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*i)+u*s,g=c*(c*(c*n+3*l*a)+3*d*r)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,a,r,o,l,h,c,d){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,a,r,o,-c/h,d));const u=h**2-4*c*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,a,r,o,(-h+p)/g,d),this.#t(t,e,i,s,n,a,r,o,(-h-p)/g,d)}static bezierBoundingBox(t,e,i,s,n,a,r,o,l){l[0]=Math.min(l[0],t,r),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,r),l[3]=Math.max(l[3],e,o),this.#e(t,i,n,r,e,s,a,o,3*(3*(i-n)-t+r),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,r,e,s,a,o,3*(3*(s-a)-e+o),6*(e-2*s+a),3*(s-e),l)}}let Dr=null,Ir=null;function Rr(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),kr(t)}const Lr="pdfjs_internal_id_";function Fr(t,e,i){return Math.min(Math.max(t,e),i)}function Nr(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(kr(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce(((t,e)=>t+e),0)});const Or="http://www.w3.org/2000/svg";class Br{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function zr(t,e="text"){if(Gr(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class jr{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=a,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,d,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+a,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+a,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,c*i,d*i,u*i,p-h*i*o-d*i*l,g-c*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const t=this.viewBox;return br(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new jr({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return Pr.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];Pr.applyTransform(e,this.transform);const i=[t[2],t[3]];return Pr.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return Pr.applyInverseTransform(i,this.transform),i}}class Vr extends yr{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Hr(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function $r(t){return"string"==typeof t&&/\.pdf$/i.test(t)}class Ur{started=Object.create(null);times=[];time(t){t in this.started&&pr(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||pr(`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{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function Gr(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===i?.protocol||"https:"===i?.protocol}function qr(t){t.preventDefault()}function Wr(t){t.preventDefault(),t.stopPropagation()}class Kr{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,r+=c):"+"===l&&(a-=h,r-=c),new Date(Date.UTC(i,s,n,a,r,o))}}function Xr(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(pr(`Not a valid color format: "${t}"`),[0,0,0])}function Yr(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform();return[e,i,s,n,a,r]}function Qr(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,i,s,n,a,r]}function Jr(t,e,i=!1,s=!0){if(e instanceof jr){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:a}=t,r=Er.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${n}px`,h=r?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,c=r?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(a.width=c,a.height=h):(a.width=h,a.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}class Zr{constructor(){const{pixelRatio:t}=Zr;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let a=1/0,r=1/0,o=1/0;(i=Zr.capPixels(i,n))>0&&(a=Math.sqrt(i/(t*e))),-1!==s&&(r=s/t,o=s/e);const l=Math.min(a,r,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const to=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class eo{#s=null;#n=null;#a;#r=null;#o=null;#l=null;static#h=null;constructor(t){this.#a=t,eo.#h||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#a._uiManager._signal;t.addEventListener("contextmenu",qr,{signal:e}),t.addEventListener("pointerdown",eo.#c,{signal:e});const i=this.#r=document.createElement("div");i.className="buttons",t.append(i);const s=this.#a.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#a._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static#c(t){t.stopPropagation()}#u(t){this.#a._focusEventsAllowed=!1,Wr(t)}#p(t){this.#a._focusEventsAllowed=!0,Wr(t)}#g(t){const e=this.#a._uiManager._signal;t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#p.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",qr,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#a,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",eo.#h[t]),this.#g(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#r.append(i)}get#f(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#g(e),this.#r.prepend(e,this.#f),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#g(e),this.#r.prepend(e,this.#f)}async addEditSignatureButton(t){const e=this.#l=await t.renderEditButton(this.#a);this.#g(e),this.#r.prepend(e,this.#f)}updateEditSignatureButton(t){this.#l&&(this.#l.title=t)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class io{#r=null;#s=null;#m;constructor(t){this.#m=t}#v(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",qr,{signal:this.#m._signal});const e=this.#r=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#y(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const a=n.x+(e?n.width:0);t>i?(s=a,i=t):e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#y(e,i),{style:a}=this.#s||=this.#v();t.append(this.#s),a.insetInlineEnd=100*s+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#m._signal;t.addEventListener("contextmenu",qr,{signal:i}),t.addEventListener("click",(()=>{this.#m.highlightSelection("floating_button")}),{signal:i}),this.#r.append(t)}}function so(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class no{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class ao{#x=Rr();#w=0;#A=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return br(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#_(t,e){this.#A||=new Map;let i=this.#A.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#x}_${this.#w++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await zr(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=ao._isSVGFittingCanvas,s=new FileReader,n=new Image,a=new Promise(((t,a)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=a}));s.readAsDataURL(t),await a}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){pr(t),i=null}return this.#A.set(t,i),i&&this.#A.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#_(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){const i=await e;return this.#_(t,i)}async getFromId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#A||=new Map;let i=this.#A.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#x}_${this.#w++}`,refCounter:1,isSvg:!1},this.#A.set(t,i),this.#A.set(i.id,i),i}getSvgUrl(t){const e=this.#A.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#x}_`)}}class ro{#S=[];#T=!1;#k;#C=-1;constructor(t=128){this.#k=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){if(s&&t(),this.#T)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#C)return this.#S.length>0&&(this.#S.length=0),this.#C=0,void this.#S.push(o);if(a&&this.#S[this.#C].type===n)return r&&(o.undo=this.#S[this.#C].undo),void(this.#S[this.#C]=o);const l=this.#C+1;l===this.#k?this.#S.splice(0,1):(this.#C=l,l<this.#S.length&&this.#S.splice(l)),this.#S.push(o)}undo(){if(-1===this.#C)return;this.#T=!0;const{undo:t,post:e}=this.#S[this.#C];t(),e?.(),this.#T=!1,this.#C-=1}redo(){if(this.#C<this.#S.length-1){this.#C+=1,this.#T=!0;const{cmd:t,post:e}=this.#S[this.#C];t(),e?.(),this.#T=!1}}hasSomethingToUndo(){return-1!==this.#C}hasSomethingToRedo(){return this.#C<this.#S.length-1}cleanType(t){if(-1!==this.#C){for(let e=this.#C;e>=0;e--)if(this.#S[e].type!==t)return this.#S.splice(e+1,this.#C-e),void(this.#C=e);this.#S.length=0,this.#C=-1}}destroy(){this.#S=null}}class oo{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Er.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#E(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#E(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:a=[],checker:r=null}}=i;r&&!r(t,e)||(s.bind(t,...a,e)(),n||Wr(e))}}class lo{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,Xr(s))}e.remove()}(t),br(this,"_colors",t)}convert(t){const e=Xr(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return lo._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?Pr.makeHexColor(...e):t}}class ho{#M=new AbortController;#P=null;#D=new Map;#I=new Map;#R=null;#L=null;#F=null;#N=new ro;#O=null;#B=null;#z=0;#j=new Set;#V=null;#H=null;#$=new Set;_editorUndoBar=null;#U=!1;#G=!1;#q=!1;#W=null;#K=null;#X=null;#Y=null;#Q=!1;#J=null;#Z=new no;#tt=!1;#et=!1;#it=null;#st=null;#nt=null;#at=null;#rt=null;#ot=Ha.NONE;#lt=new Set;#ht=null;#ct=null;#dt=null;#ut=null;#pt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#gt=[0,0];#ft=null;#mt=null;#vt=null;#bt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=ho.prototype,e=t=>t.#mt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return br(this,"_keyboardManager",new oo([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,a,r,o,l,h,c,d,u,p){const g=this._signal=this.#M.signal;this.#mt=t,this.#vt=e,this.#R=i,this.#ct=s,this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:g}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),n._on("setpreference",this.onSetPreference.bind(this),{signal:g}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:g}),this.#yt(),this.#wt(),this.#xt(),this.#L=a.annotationStorage,this.#W=a.filterFactory,this.#dt=r,this.#Y=o||null,this.#U=l,this.#G=h,this.#q=c,this.#rt=d||null,this.viewParameters={realScale:Br.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==p}destroy(){this.#bt?.resolve(),this.#bt=null,this.#M?.abort(),this.#M=null,this._signal=null;for(const t of this.#I.values())t.destroy();this.#I.clear(),this.#D.clear(),this.#$.clear(),this.#at?.clear(),this.#P=null,this.#lt.clear(),this.#N.destroy(),this.#R?.destroy(),this.#ct?.destroy(),this.#J?.hide(),this.#J=null,this.#nt?.destroy(),this.#nt=null,this.#K&&(clearTimeout(this.#K),this.#K=null),this.#ft&&(clearTimeout(this.#ft),this.#ft=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#rt}get useNewAltTextFlow(){return this.#G}get useNewAltTextWhenAddingImage(){return this.#q}get hcmFilter(){return br(this,"hcmFilter",this.#dt?this.#W.addHCMFilter(this.#dt.foreground,this.#dt.background):"none")}get direction(){return br(this,"direction",getComputedStyle(this.#mt).direction)}get highlightColors(){return br(this,"highlightColors",this.#Y?new Map(this.#Y.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return br(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#B=t}setMainHighlightColorPicker(t){this.#nt=t}editAltText(t,e=!1){this.#R?.editAltText(this,t,e)}getSignature(t){this.#ct?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#ct}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#q=e}onPageChanging({pageNumber:t}){this.#z=t-1}focusMainContainer(){this.#mt.focus()}findParent(t,e){for(const i of this.#I.values()){const{x:s,y:n,width:a,height:r}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&e>=n&&e<=n+r)return i}return null}disableUserSelect(t=!1){this.#vt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#$.add(t)}removeShouldRescale(t){this.#$.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Br.PDF_TO_CSS_UNITS;for(const t of this.#$)t.onScaleChanging();this.#B?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#At({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#_t(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#I.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a}=e,r=e.toString(),o=this.#At(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#_t(o),c=this.#ot===Ha.NONE,d=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a,text:r}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(Ha.HIGHLIGHT,d):d()}#St(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#At(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#J||=new io(this),this.#J.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#L||this.#L.has(t.id)||this.#L.setValue(t.id,t)}#Tt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ht&&(this.#J?.hide(),this.#ht=null,this.#kt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ht)return;const i=this.#At(t).closest(".textLayer");if(i){if(this.#J?.hide(),this.#ht=e,this.#kt({hasSelectedText:!0}),(this.#ot===Ha.HIGHLIGHT||this.#ot===Ha.NONE)&&(this.#ot===Ha.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Q=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#ot===Ha.HIGHLIGHT?this.#_t(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#Ct("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ht&&(this.#J?.hide(),this.#ht=null,this.#kt({hasSelectedText:!1}))}#Ct(t=""){this.#ot===Ha.HIGHLIGHT?this.highlightSelection(t):this.#U&&this.#St()}#yt(){document.addEventListener("selectionchange",this.#Tt.bind(this),{signal:this._signal})}#Et(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Mt(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Q&&(this.#Q=!1,this.#Ct("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#lt)if(e.div.contains(t)){this.#st=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#st)return;const[t,e]=this.#st;this.#st=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#xt(){if(this.#it)return;this.#it=new AbortController;const t=this.combinedSignal(this.#it);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Pt(){this.#it?.abort(),this.#it=null}#Dt(){if(this.#O)return;this.#O=new AbortController;const t=this.combinedSignal(this.#O);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#It(){this.#O?.abort(),this.#O=null}#wt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#xt(),this.#Dt()}removeEditListeners(){this.#Pt(),this.#It()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#P?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#lt){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#H)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void pr(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#Rt(e);this.#Lt(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){pr(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#ot===Ha.NONE||this.isEditorHandlingKeyboard||ho._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Q&&(this.#Q=!1,this.#Ct("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#kt(t){Object.entries(t).some((([t,e])=>this.#pt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#pt,t)}),this.#ot===Ha.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Ft([[$a.HIGHLIGHT_FREE,!0]]))}#Ft(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Et(),this.#Dt(),this.#kt({isEditing:this.#ot!==Ha.NONE,isEmpty:this.#Nt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Mt(),this.#It(),this.#kt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#H){this.#H=t;for(const t of this.#H)this.#Ft(t.defaultPropertiesToUpdate)}}getId(){return this.#Z.id}get currentLayer(){return this.#I.get(this.#z)}getLayer(t){return this.#I.get(t)}get currentPageIndex(){return this.#z}addLayer(t){this.#I.set(t.pageIndex,t),this.#tt?t.enable():t.disable()}removeLayer(t){this.#I.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#ot!==t&&(!this.#bt||(await this.#bt.promise,this.#bt))){if(this.#bt=Promise.withResolvers(),this.#B?.commitOrRemove(),this.#ot=t,t===Ha.NONE)return this.setEditingState(!1),this.#Ot(),this._editorUndoBar?.hide(),void this.#bt.resolve();t===Ha.SIGNATURE&&await(this.#ct?.loadSignatures()),this.setEditingState(!0),await this.#Bt(),this.unselectAll();for(const e of this.#I.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#bt.resolve();for(const t of this.#D.values())t.annotationElementId===e||t.id===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#bt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#ot&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#H){switch(t){case $a.CREATE:return void this.currentLayer.addNewEditor(e);case $a.HIGHLIGHT_DEFAULT_COLOR:this.#nt?.updateColor(e);break;case $a.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ut||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#lt)i.updateParams(t,e);for(const i of this.#H)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#D.values())i.editorType===t&&i.show(e);(this.#ut?.get($a.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Ft([[$a.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#et!==t){this.#et=t;for(const e of this.#I.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Bt(){if(!this.#tt){this.#tt=!0;const t=[];for(const e of this.#I.values())t.push(e.enable());await Promise.all(t);for(const t of this.#D.values())t.enable()}}#Ot(){if(this.unselectAll(),this.#tt){this.#tt=!1;for(const t of this.#I.values())t.disable();for(const t of this.#D.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#D.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#D.get(t)}addEditor(t){this.#D.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#K&&clearTimeout(this.#K),this.#K=setTimeout((()=>{this.focusMainContainer(),this.#K=null}),0)),this.#D.delete(t.id),t.annotationElementId&&this.#at?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#j.has(t.annotationElementId)||this.#L?.remove(t.id)}addDeletedAnnotationElement(t){this.#j.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#j.has(t)}removeDeletedAnnotationElement(t){this.#j.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Rt(t){const e=this.#I.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#P!==t&&(this.#P=t,t&&this.#Ft(t.propertiesToUpdate))}get#zt(){let t=null;for(t of this.#lt);return t}updateUI(t){this.#zt===t&&this.#Ft(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Ft(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#lt.has(t))return this.#lt.delete(t),t.unselect(),void this.#kt({hasSelectedEditor:this.hasSelection});this.#lt.add(t),t.select(),this.#Ft(t.propertiesToUpdate),this.#kt({hasSelectedEditor:!0})}setSelected(t){this.#B?.commitOrRemove();for(const e of this.#lt)e!==t&&e.unselect();this.#lt.clear(),this.#lt.add(t),t.select(),this.#Ft(t.propertiesToUpdate),this.#kt({hasSelectedEditor:!0})}isSelected(t){return this.#lt.has(t)}get firstSelectedEditor(){return this.#lt.values().next().value}unselect(t){t.unselect(),this.#lt.delete(t),this.#kt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#lt.size}get isEnterHandled(){return 1===this.#lt.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#kt({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Nt()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#kt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Nt()})}addCommands(t){this.#N.add(t),this.#kt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Nt()})}cleanUndoStack(t){this.#N.cleanType(t)}#Nt(){if(0===this.#D.size)return!0;if(1===this.#D.size)for(const t of this.#D.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#lt],i=()=>{for(const t of e)this.#Rt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#P?.commitOrRemove()}hasSomethingToControl(){return this.#P||this.hasSelection}#Lt(t){for(const t of this.#lt)t.unselect();this.#lt.clear();for(const e of t)e.isEmpty()||(this.#lt.add(e),e.select());this.#kt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#lt)t.commit();this.#Lt(this.#D.values())}unselectAll(){if((!this.#P||(this.#P.commitOrRemove(),this.#ot===Ha.NONE))&&!this.#B?.commitOrRemove()&&this.hasSelection){for(const t of this.#lt)t.unselect();this.#lt.clear(),this.#kt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#gt[0]+=t,this.#gt[1]+=e;const[s,n]=this.#gt,a=[...this.#lt];this.#ft&&clearTimeout(this.#ft),this.#ft=setTimeout((()=>{this.#ft=null,this.#gt[0]=this.#gt[1]=0,this.addCommands({cmd:()=>{for(const t of a)this.#D.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of a)this.#D.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})}),1e3);for(const i of a)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#V=new Map;for(const t of this.#lt)this.#V.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#V)return!1;this.disableUserSelect(!1);const t=this.#V;this.#V=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},a]of t)a.newX=i,a.newY=s,a.newPageIndex=n,e||=i!==a.savedX||s!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#D.has(t.id)){const n=this.#I.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:a}]of t)i(e,s,n,a)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:a}]of t)i(e,s,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#V)for(const i of this.#V.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#lt.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#P===t}getActive(){return this.#P}getMode(){return this.#ot}get imageManager(){return br(this,"imageManager",new ao)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-s)/a,y:1-(t+r-i)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-i)/n,y:1-(e+o-s)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-s)/a,y:(t-i)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-i)/n,y:(e-s)/a,width:r/n,height:o/a})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&o.push(r(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#F||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#F?.delete(t)}renderAnnotationElement(t){const e=this.#F?.get(t.data.id);if(!e)return;const i=this.#L.getRawValue(e);i&&(this.#ot!==Ha.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const s=this.#at?.get(t);s&&(s.setCanvas(e,i),this.#at.delete(t))}addMissingCanvas(t,e){(this.#at||=new Map).set(t,e)}}class co{#o=null;#jt=!1;#Vt=null;#Ht=null;#$t=null;#Ut=null;#Gt=!1;#qt=null;#a=null;#Wt=null;#Kt=null;#Xt=!1;static#Yt=null;static _l10n=null;constructor(t){this.#a=t,this.#Xt=t._uiManager.useNewAltTextFlow,co.#Yt||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){co._l10n??=t}async render(){const t=this.#Vt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#Ht=document.createElement("span");t.append(e),this.#Xt?(t.classList.add("new"),t.setAttribute("data-l10n-id",co.#Yt.missing),e.setAttribute("data-l10n-id",co.#Yt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#a._uiManager._signal;t.addEventListener("contextmenu",qr,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a),this.#Xt&&this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Qt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#Gt=!0,s(e))}),{signal:i}),await this.#Jt(),t}get#Qt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Vt&&(this.#Vt.focus({focusVisible:this.#Gt}),this.#Gt=!1)}isEmpty(){return this.#Xt?null===this.#o:!this.#o&&!this.#jt}hasData(){return this.#Xt?null!==this.#o||!!this.#Wt:this.isEmpty()}get guessedText(){return this.#Wt}async setGuessedText(t){null===this.#o&&(this.#Wt=t,this.#Kt=await co._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Jt())}toggleAltTextBadge(t=!1){if(!this.#Xt||this.#o)return this.#qt?.remove(),void(this.#qt=null);if(!this.#qt){const t=this.#qt=document.createElement("div");t.className="noAltTextBadge",this.#a.div.append(t)}this.#qt.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#Wt!==e||(e=this.#Kt),{altText:e,decorative:this.#jt,guessedText:this.#Wt,textWithDisclaimer:this.#Kt}}get data(){return{altText:this.#o,decorative:this.#jt}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#Wt=i,this.#Kt=s),this.#o===t&&this.#jt===e||(n||(this.#o=t,this.#jt=e),this.#Jt())}toggle(t=!1){this.#Vt&&(!t&&this.#Ut&&(clearTimeout(this.#Ut),this.#Ut=null),this.#Vt.disabled=!t)}shown(){this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Qt}})}destroy(){this.#Vt?.remove(),this.#Vt=null,this.#Ht=null,this.#$t=null,this.#qt?.remove(),this.#qt=null}async#Jt(){const t=this.#Vt;if(!t)return;if(this.#Xt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",co.#Yt[this.#Qt]),this.#Ht?.setAttribute("data-l10n-id",co.#Yt[`${this.#Qt}-label`]),!this.#o)return void this.#$t?.remove()}else{if(!this.#o&&!this.#jt)return t.classList.remove("done"),void this.#$t?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#$t;if(!e){this.#$t=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#a.id}`;const i=100,s=this.#a._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Ut),this.#Ut=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Ut=setTimeout((()=>{this.#Ut=null,this.#$t.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Ut&&(clearTimeout(this.#Ut),this.#Ut=null),this.#$t?.classList.remove("show")}),{signal:s})}this.#jt?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#a.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class uo{#mt;#Zt=!1;#te=null;#ee;#ie;#se;#ne;#ae=null;#re;#oe=null;#le;#he=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:a=null,signal:r}){this.#mt=t,this.#te=i,this.#ee=e,this.#ie=s,this.#se=n,this.#ne=a,this.#le=new AbortController,this.#re=AbortSignal.any([r,this.#le.signal]),t.addEventListener("touchstart",this.#ce.bind(this),{passive:!1,signal:this.#re})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Zr.pixelRatio}#ce(t){if(this.#ee?.())return;if(1===t.touches.length){if(this.#ae)return;const t=this.#ae=new AbortController,e=AbortSignal.any([this.#re,t.signal]),i=this.#mt,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#ae?.abort(),this.#ae=null)};return i.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(Wr(t),n(t))}),s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!this.#he){this.#he=new AbortController;const t=AbortSignal.any([this.#re,this.#he.signal]),e=this.#mt,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#de.bind(this),i);const s=this.#ue.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",Wr,i),e.addEventListener("pointermove",Wr,i),e.addEventListener("pointercancel",Wr,i),e.addEventListener("pointerup",Wr,i),this.#ie?.()}if(Wr(t),2!==t.touches.length||this.#te?.())return void(this.#oe=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#oe={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#de(t){if(!this.#oe||2!==t.touches.length)return;Wr(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:s,screenY:n}=e,{screenX:a,screenY:r}=i,o=this.#oe,{touch0X:l,touch0Y:h,touch1X:c,touch1Y:d}=o,u=c-l,p=d-h,g=a-s,f=r-n,m=Math.hypot(g,f)||1,v=Math.hypot(u,p)||1;if(!this.#Zt&&Math.abs(v-m)<=uo.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=n,o.touch1X=a,o.touch1Y=r,!this.#Zt)return void(this.#Zt=!0);const b=[(s+a)/2,(n+r)/2];this.#se?.(b,v,m)}#ue(t){t.touches.length>=2||(this.#he&&(this.#he.abort(),this.#he=null,this.#ne?.()),this.#oe&&(Wr(t),this.#oe=null,this.#Zt=!1))}destroy(){this.#le?.abort(),this.#le=null,this.#ae?.abort(),this.#ae=null}}class po{#pe=null;#ge=null;#o=null;#fe=!1;#me=null;#ve="";#be=!1;#ye=null;#we=null;#xe=null;#Ae=null;#_e="";#Se=!1;#Te=null;#ke=!1;#Ce=!1;#Ee=!1;#Me=null;#Pe=0;#De=0;#Ie=null;#Re=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#Le=!1;#Fe=po._zIndex++;static _borderLineWidth=-1;static _colorManager=new lo;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=po.prototype._resizeWithKeyboard,e=ho.TRANSLATE_SMALL,i=ho.TRANSLATE_BIG;return br(this,"_resizerKeyboardManager",new oo([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],po.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,a];const[r,o]=this.parentDimensions;this.x=t.x/r,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return br(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new go({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(po._l10n??=t,po._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==po._borderLineWidth)return;const i=getComputedStyle(document.documentElement);po._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){gr("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Le}set _isDraggable(t){this.#Le=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Fe}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Ne(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Se?this.#Se=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#Oe([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#Oe(this.parentDimensions,t,e)}translateInPage(t,e){this.#Te||=[this.x,this.y,this.width,this.height],this.#Oe(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#Te||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:r}=this;const[o,l]=this.getBaseTranslation();a+=o,r+=l;const{style:h}=i;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this._onTranslating(a,r),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Te&&(this.#Te[0]!==this.x||this.#Te[1]!==this.y)}get _hasBeenResized(){return!!this.#Te&&(this.#Te[2]!==this.width||this.#Te[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=po,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:a,width:r,height:o}=this;if(r*=i,o*=s,n*=i,a*=s,this._mustFixPosition)switch(t){case 0:n=Fr(n,0,i-r),a=Fr(a,0,s-o);break;case 90:n=Fr(n,0,i-o),a=Fr(a,r,s);break;case 180:n=Fr(n,r,i),a=Fr(a,o,s);break;case 270:n=Fr(n,o,i),a=Fr(a,0,s-r)}this.x=n/=i,this.y=a/=s;const[l,h]=this.getBaseTranslation();n+=l,a+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#Be(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return po.#Be(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return po.#Be(t,e,360-this.parentRotation)}#ze(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#be||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#be&&e.endsWith("%");if(s&&n)return;const[a,r]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/a).toFixed(2)}%`),this.#be||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#je(){if(this.#ye)return;this.#ye=document.createElement("div"),this.#ye.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#ye.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Ve.bind(this,i),{signal:e}),t.addEventListener("contextmenu",qr,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#ye)}#Ve(t,e){e.preventDefault();const{isMac:i}=Er.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#we=[e.screenX,e.screenY];const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#He.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Wr,{passive:!1,signal:a}),window.addEventListener("contextmenu",qr,{signal:a}),this.#xe={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const r=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=r,this.div.style.cursor=o,this.#$e()};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}#Ue(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*i,a*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#$e(){if(!this.#xe)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#xe;this.#xe=null;const n=this.x,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===i&&o===s||this.addCommands({cmd:this.#Ue.bind(this,n,a,r,o),undo:this.#Ue.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#He(t,e){const[i,s]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,l=po.MIN_SIZE/i,h=po.MIN_SIZE/s,c=this.#ze(this.rotation),d=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=this.#ze(360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const v=p(r,o),b=g(r,o);let y=d(...b);const w=po._round(n+y[0]),x=po._round(a+y[1]);let A,_,S=1,T=1;if(e.fromKeyboard)({deltaX:A,deltaY:_}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#we;[A,_]=this.screenToPageTranslation(t-s,i-n),this.#we[0]=t,this.#we[1]=i}if([A,_]=((t,e)=>[u[0]*t+u[2]*e,u[1]*t+u[3]*e])(A/i,_/s),f){const t=Math.hypot(r,o);S=T=Math.max(Math.min(Math.hypot(b[0]-v[0]-A,b[1]-v[1]-_)/t,1/r,1/o),l/r,h/o)}else m?S=Fr(Math.abs(b[0]-v[0]-A),l,1)/r:T=Fr(Math.abs(b[1]-v[1]-_),h,1)/o;const k=po._round(r*S),C=po._round(o*T);y=d(...g(k,C));const E=w-y[0],M=x-y[1];this.#Te||=[this.x,this.y,this.width,this.height],this.width=k,this.height=C,this.x=E,this.y=M,this.setDims(i*k,s*C),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ce||(this._editToolbar=new eo(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(co.initialize(po._l10n),this.#o=new co(this),this.#pe&&(this.#o.data=this.#pe,this.#pe=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#fe?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#Ge();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[s,n]=this.getInitialTranslation();return this.translate(s,n),so(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Re||=new uo({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#qe.bind(this),onPinching:this.#We.bind(this),onPinchEnd:this.#Ke.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),t}#qe(){this.#xe={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#We(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#ze(this.rotation),a=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[r,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,d=this.height,u=po.MIN_SIZE/r,p=po.MIN_SIZE/o;s=Math.max(Math.min(s,1/c,1/d),u/c,p/d);const g=po._round(c*s),f=po._round(d*s);if(g===c&&f===d)return;this.#Te||=[l,h,c,d];const m=a(c/2,d/2),v=po._round(l+m[0]),b=po._round(h+m[1]),y=a(g/2,f/2);this.x=v-y[0],this.y=b-y[1],this.width=g,this.height=f,this.setDims(r*g,o*f),this.fixAndSetPosition(),this._onResizing()}#Ke(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#$e()}pointerdown(t){const{isMac:e}=Er.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#Se=!0,this._isDraggable?this.#Xe(t):this.#Ye(t))}#Ye(t){const{isMac:e}=Er.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#Xe(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),a={capture:!0,passive:!1,signal:n},r=t=>{s.abort(),this.#me=null,this.#Se=!1,this._uiManager.endDragSession()||this.#Ye(t),i&&this._onStopDragging()};e&&(this.#Pe=t.clientX,this.#De=t.clientY,this.#me=t.pointerId,this.#ve=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#me)return void Wr(t);const[a,r]=this.screenToPageTranslation(e-this.#Pe,s-this.#De);this.#Pe=e,this.#De=s,this._uiManager.dragSelectedEditors(a,r)}),a),window.addEventListener("touchmove",Wr,a),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#ve&&(this.#Re||t.isPrimary)&&r(t),Wr(t)}),a));const o=t=>{this.#me&&this.#me!==t.pointerId?Wr(t):r(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Me&&clearTimeout(this.#Me),this.#Me=setTimeout((()=>{this.#Me=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/s,h=e/s,c=this.x*n,d=this.y*a,u=this.width*n,p=this.height*a;switch(i){case 0:return[c+l+r,a-d-h-p+o,c+l+u+r,a-d-h+o];case 90:return[c+h+r,a-d+l+o,c+h+p+r,a-d+l+u+o];case 180:return[c-l-u+r,a-d+h+o,c-l+r,a-d+h+p+o];case 270:return[c-h-p+r,a-d-l-u+o,c-h+r,a-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,a]=t,r=n-i,o=a-s;switch(this.rotation){case 0:return[i,e-a,r,o];case 90:return[i,e-s,o,r];case 180:return[n,e-s,r,o];case 270:return[n,e-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#Ce=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#Ce=!1,!0)}isInEditMode(){return this.#Ce}shouldGetKeyboardEvents(){return this.#Ee}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:a}=window;return e<a&&s>0&&t<n&&i>0}#Ge(){if(this.#Ae||!this.div)return;this.#Ae=new AbortController;const t=this._uiManager.combinedSignal(this.#Ae);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#Ge()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){gr("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#pe=t.accessibilityData,s._isCopy=t.isCopy||!1;const[n,a]=s.pageDimensions,[r,o,l,h]=s.getRectInCurrentCoords(t.rect,a);return s.x=r/n,s.y=o/a,s.width=l/n,s.height=h/a,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#Ae?.abort(),this.#Ae=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Me&&(clearTimeout(this.#Me),this.#Me=null),this.#Ne(),this.removeEditToolbar(),this.#Ie){for(const t of this.#Ie.values())clearTimeout(t);this.#Ie=null}this.parent=null,this.#Re?.destroy(),this.#Re=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#je(),this.#ye.classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#xe={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#ye.children;if(!this.#ge){this.#ge=Array.from(e);const t=this.#Qe.bind(this),i=this.#Je.bind(this),s=this._uiManager._signal;for(const e of this.#ge){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ze.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",po._l10nResizer[n])}}const i=this.#ge[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#ge.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#ye.append(this.#ye.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#ye.firstChild.before(this.#ye.lastChild);let t=0;for(const i of e){const e=this.#ge[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",po._l10nResizer[e])}}this.#ti(0),this.#Ee=!0,this.#ye.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#Qe(t){po._resizerKeyboardManager.exec(this,t)}#Je(t){this.#Ee&&t.relatedTarget?.parentNode!==this.#ye&&this.#Ne()}#Ze(t){this.#_e=this.#Ee?t:""}#ti(t){if(this.#ge)for(const e of this.#ge)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Ee&&this.#He(this.#_e,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Ne(){this.#Ee=!1,this.#ti(-1),this.#$e()}_stopResizingWithKeyboard(){this.#Ne(),this.div.focus()}select(){this.isSelected&&this._editToolbar||(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})))}unselect(){this.isSelected&&(this.isSelected=!1,this.#ye?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#ke}set isEditing(t){this.#ke=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#be=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#Ie||=new Map;const{action:e}=t;let i=this.#Ie.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Ie.delete(e),0===this.#Ie.size&&(this.#Ie=null)}),po._telemetryTimeout),void this.#Ie.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#fe=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#fe=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class go extends po{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const fo=3285377520,mo=4294901760,vo=65535;class bo{constructor(t){this.h1=t?4294967295&t:fo,this.h2=t?4294967295&t:fo}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,a=new Uint32Array(e.buffer,0,s);let r=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(r=a[t],r=r*c&mo|r*u&vo,r=r<<15|r>>>17,r=r*d&mo|r*p&vo,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[t],o=o*c&mo|o*u&vo,o=o<<15|o>>>17,o=o*d&mo|o*p&vo,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(r=0,n){case 3:r^=e[4*s+2]<<16;case 2:r^=e[4*s+1]<<8;case 1:r^=e[4*s],r=r*c&mo|r*u&vo,r=r<<15|r>>>17,r=r*d&mo|r*p&vo,1&s?l^=r:h^=r}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&mo|36045*t&vo,e=4283543511*e&mo|(2950163797*(e<<16|t>>>16)&mo)>>>16,t^=e>>>1,t=444984403*t&mo|60499*t&vo,e=3301882366*e&mo|(3120437893*(e<<16|t>>>16)&mo)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const yo=Object.freeze({map:null,hash:"",transfer:void 0});class wo{#ei=!1;#ii=null;#si=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#si.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#si.get(t)}remove(t){if(this.#si.delete(t),0===this.#si.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#si.values())if(t instanceof po)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#si.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#si.set(t,e);s&&this.#ni(),e instanceof po&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#si.has(t)}get size(){return this.#si.size}#ni(){this.#ei||(this.#ei=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#ei&&(this.#ei=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new xo(this)}get serializable(){if(0===this.#si.size)return yo;const t=new Map,e=new bo,i=[],s=Object.create(null);let n=!1;for(const[i,a]of this.#si){const r=a instanceof po?a.serialize(!1,s):a;r&&(t.set(i,r),e.update(`${i}:${JSON.stringify(r)}`),n||=!!r.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:yo}get editorStats(){let t=null;const e=new Map;for(const i of this.#si.values()){if(!(i instanceof po))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const a=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=a.get(t);i||(i=new Map,a.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#ii=null}get modifiedIds(){if(this.#ii)return this.#ii;const t=[];for(const e of this.#si.values())e instanceof po&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#ii={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#si.entries()}}class xo extends wo{#ai;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ai={map:n,hash:i,transfer:s}}get print(){gr("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ai}get modifiedIds(){return br(this,"modifiedIds",{ids:new Set,hash:""})}}class Ao{#ri=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ri.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#ri.has(t.loadedName))if(fr(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:s,style:n}=t,a=new FontFace(e,s,n);this.addNativeFontFace(a);try{await a.load(),this.#ri.add(e),i?.(t)}catch{pr(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else gr("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw pr(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return br(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return br(this,"isSyncFontLoadingSupported",Pa||Er.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(fr(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return br(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=s(c,976,h.length,h);const d=1482184792;let u=i(c,16);for(n=0,a=h.length-3;n<a;n+=4)u=u-d+i(h,n)|0;var p;n<h.length&&(u=u-d+i(h+"XXX",n)|0),c=s(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return pr("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{f.remove(),e.complete()}))}}class _o{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this._inspectFont=e}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._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Nr(this.data)});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){pr(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}function So(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const To=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,ko=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[s,n,...a]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(n))return!1;const r=a.length;let o=!0;switch(n.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return 0===r;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(4!==r)return!1;o=!1;break;default:return!1}for(const t of a)if(!("number"==typeof t||o&&null===t))return!1;return!0}.bind(null,To,(t=>"object"==typeof t&&"string"==typeof t?.name));class Co{#oi=new Map;#li=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#li.then((()=>{for(const[t]of this.#oi)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void pr("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}this.#oi.set(e,s)}removeEventListener(t,e){const i=this.#oi.get(e);i?.(),this.#oi.delete(e)}terminate(){for(const[,t]of this.#oi)t?.();this.#oi.clear()}}const Eo=1,Mo=2,Po=1,Do=2,Io=3,Ro=4,Lo=5,Fo=6,No=7,Oo=8;function Bo(){}function zo(t){if(t instanceof Tr||t instanceof Ar||t instanceof wr||t instanceof _r||t instanceof xr)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||gr('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Tr(t.message);case"InvalidPDFException":return new Ar(t.message);case"PasswordException":return new wr(t.message,t.code);case"ResponseException":return new _r(t.message,t.status,t.missing);case"UnknownErrorException":return new xr(t.message,t.details)}return new xr(t.message,t.toString())}class jo{#hi=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#ci.bind(this),{signal:this.#hi.signal})}#ci({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#di(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Eo)i.resolve(t.data);else{if(t.callback!==Mo)throw new Error("Unexpected callback case");i.reject(zo(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:Eo,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:Mo,callbackId:t.callbackId,reason:zo(e)})}))}else t.streamId?this.#ui(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,a=this.sourceName,r=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:r,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:a,targetName:r,stream:Fo,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{fr(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:a,targetName:r,stream:Po,streamId:n,reason:zo(t)}),e.promise}},i)}#ui(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t,a=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Ro,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Io,streamId:e}),delete a.streamSinks[e])},error(t){fr(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Lo,streamId:e,reason:zo(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(r,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Oo,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Oo,streamId:e,reason:zo(t)})}))}#di(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case Oo:t.success?a.startCall.resolve():a.startCall.reject(zo(t.reason));break;case No:t.success?a.pullCall.resolve():a.pullCall.reject(zo(t.reason));break;case Fo:if(!r){n.postMessage({sourceName:i,targetName:s,stream:No,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||Bo).then((function(){n.postMessage({sourceName:i,targetName:s,stream:No,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:No,streamId:e,reason:zo(t)})}));break;case Ro:if(fr(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Io:if(fr(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#pi(a,e);break;case Lo:fr(a,"error should have stream controller"),a.controller.error(zo(t.reason)),this.#pi(a,e);break;case Do:t.success?a.cancelCall.resolve():a.cancelCall.reject(zo(t.reason)),this.#pi(a,e);break;case Po:if(!r)break;const o=zo(t.reason);Promise.try(r.onCancel||Bo,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Do,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Do,streamId:e,reason:zo(t)})})),r.sinkCapability.reject(o),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#pi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#hi?.abort(),this.#hi=null}}class Vo{#gi=!1;constructor({enableHWA:t=!1}){this.#gi=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#gi})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}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){gr("Abstract method `_createCanvas` called.")}}class Ho extends Vo{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class $o{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("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._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){gr("Abstract method `_fetch` called.")}}class Uo extends $o{async _fetch(t){const e=await zr(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Cr(e)}}class Go{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class qo extends Go{#fi;#mi;#vi;#bi;#yi;#wi;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#bi=t,this.#yi=e}get#A(){return this.#mi||=new Map}get#xi(){return this.#wi||=new Map}get#Ai(){if(!this.#vi){const t=this.#yi.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#yi.createElementNS(Or,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#vi=this.#yi.createElementNS(Or,"defs"),t.append(i),i.append(this.#vi),this.#yi.body.append(t)}return this.#vi}#_i(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),a=new Array(256),r=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,a[t]=i[t]/255,r[t]=s[t]/255;return[n.join(","),a.join(","),r.join(",")]}#Si(t){if(void 0===this.#fi){this.#fi="";const t=this.#yi.URL;t!==this.#yi.baseURI&&(Hr(t)?pr('#createUrl: ignore "data:"-URL for performance reasons.'):this.#fi=vr(t,""))}return`url(${this.#fi}#${t})`}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[i,s,n]=this.#_i(t),a=1===t.length?i:`${i}${s}${n}`;if(e=this.#A.get(a),e)return this.#A.set(t,e),e;const r=`g_${this.#bi}_transfer_map_${this.#w++}`,o=this.#Si(r);this.#A.set(t,o),this.#A.set(a,o);const l=this.#Ti(r);return this.#ki(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#xi.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#xi.set(s,n)),!t||!e)return n.url;const a=this.#Ci(t);t=Pr.makeHexColor(...a);const r=this.#Ci(e);if(e=Pr.makeHexColor(...r),this.#Ai.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#bi}_hcm_filter`,c=n.filter=this.#Ti(h);this.#ki(l,l,l,c),this.#Ei(c);const d=(t,e)=>{const i=a[t]/255,s=r[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#ki(d(0,5),d(1,5),d(2,5),c),n.url=this.#Si(h),n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[i]=this.#_i([t]),s=`alpha_${i}`;if(e=this.#A.get(s),e)return this.#A.set(t,e),e;const n=`g_${this.#bi}_alpha_map_${this.#w++}`,a=this.#Si(n);this.#A.set(t,a),this.#A.set(s,a);const r=this.#Ti(n);return this.#Mi(i,r),a}addLuminosityFilter(t){let e,i,s=this.#A.get(t||"luminosity");if(s)return s;if(t?([e]=this.#_i([t]),i=`luminosity_${e}`):i="luminosity",s=this.#A.get(i),s)return this.#A.set(t,s),s;const n=`g_${this.#bi}_luminosity_map_${this.#w++}`,a=this.#Si(n);this.#A.set(t,a),this.#A.set(i,a);const r=this.#Ti(n);return this.#Pi(r),t&&this.#Mi(e,r),a}addHighlightHCMFilter(t,e,i,s,n){const a=`${e}-${i}-${s}-${n}`;let r=this.#xi.get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},this.#xi.set(t,r)),!e||!i)return r.url;const[o,l]=[e,i].map(this.#Ci.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,u]=[s,n].map(this.#Ci.bind(this));c<h&&([h,c,d,u]=[c,h,u,d]),this.#Ai.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(c-h)/i,a=t/255,r=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=a+t*r;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#bi}_hcm_${t}_filter`,f=r.filter=this.#Ti(g);return this.#Ei(f),this.#ki(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),f),r.url=this.#Si(g),r.url}destroy(t=!1){t&&this.#wi?.size||(this.#vi?.parentNode.parentNode.remove(),this.#vi=null,this.#mi?.clear(),this.#mi=null,this.#wi?.clear(),this.#wi=null,this.#w=0)}#Pi(t){const e=this.#yi.createElementNS(Or,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#Ei(t){const e=this.#yi.createElementNS(Or,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#Ti(t){const e=this.#yi.createElementNS(Or,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#Ai.append(e),e}#Di(t,e,i){const s=this.#yi.createElementNS(Or,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#ki(t,e,i,s){const n=this.#yi.createElementNS(Or,"feComponentTransfer");s.append(n),this.#Di(n,"feFuncR",t),this.#Di(n,"feFuncG",e),this.#Di(n,"feFuncB",i)}#Mi(t,e){const i=this.#yi.createElementNS(Or,"feComponentTransfer");e.append(i),this.#Di(i,"feFuncA",t)}#Ci(t){return this.#Ai.style.color=t,Xr(getComputedStyle(this.#Ai).getPropertyValue("color"))}}class Wo{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("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._fetch(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){gr("Abstract method `_fetch` called.")}}class Ko extends Wo{async _fetch(t){const e=await zr(t,"arraybuffer");return new Uint8Array(e)}}class Xo{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load wasm data at: ${e}`)}))}async _fetch(t){gr("Abstract method `_fetch` called.")}}class Yo extends Xo{async _fetch(t){const e=await zr(t,"arraybuffer");return new Uint8Array(e)}}async function Qo(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}Pa&&pr("Please use the `legacy` build in Node.js environments.");class Jo extends Go{}class Zo extends Vo{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class tl extends $o{async _fetch(t){return Qo(t)}}class el extends Wo{async _fetch(t){return Qo(t)}}class il extends Xo{async _fetch(t){return Qo(t)}}const sl="Fill",nl="Stroke",al="Shading";function rl(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class ol{isModifyingCurrentTransform(){return!1}getPattern(){gr("Abstract method `getPattern` called.")}}class ll extends ol{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,i,s){let n;if(s===nl||s===sl){const a=e.current.getClippedPathBoundingBox(s,Yr(t))||[0,0,0,0],r=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",r,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),i=Pr.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),rl(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(i);n.setTransform(c)}else rl(t,this._bbox),n=this._createGradient(t);return n}}function hl(t,e,i,s,n,a,r,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=r,r=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,v=(l[n]+e.offsetX)*e.scaleX,b=(l[n+1]+e.offsetY)*e.scaleY;if(g>=b)return;const y=h[a],w=h[a+1],x=h[a+2],A=h[r],_=h[r+1],S=h[r+2],T=h[o],k=h[o+1],C=h[o+2],E=Math.round(g),M=Math.round(b);let P,D,I,R,L,F,N,O;for(let t=E;t<=M;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);P=p-(p-f)*e,D=y-(y-A)*e,I=w-(w-_)*e,R=x-(x-S)*e}else{let e;e=t>b?1:m===b?0:(m-t)/(m-b),P=f-(f-v)*e,D=A-(A-T)*e,I=_-(_-k)*e,R=S-(S-C)*e}let e;e=t<g?0:t>b?1:(g-t)/(g-b),L=p-(p-v)*e,F=y-(y-T)*e,N=w-(w-k)*e,O=x-(x-C)*e;const i=Math.round(Math.min(P,L)),s=Math.round(Math.max(P,L));let n=d*t+4*i;for(let t=i;t<=s;t++)e=(P-t)/(P-L),e<0?e=0:e>1&&(e=1),c[n++]=D-(D-F)*e|0,c[n++]=I-(I-N)*e|0,c[n++]=R-(R-O)*e|0,c[n++]=255}}function cl(t,e,i){const s=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(a=0;a<l;a++){let e=a*o;for(let a=0;a<h;a++,e++)hl(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),hl(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(a=0,r=s.length;a<r;a+=3)hl(t,i,s[a],s[a+1],s[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class dl extends ol{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-s,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),h=a/o,c=r/l,d={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)cl(m,t,d);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*c,scaleX:h,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){rl(t,this._bbox);const n=new Float32Array(2);if(s===al)Pr.singularValueDecompose2dScale(Yr(t),n);else if(this.matrix){Pr.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;Pr.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else Pr.singularValueDecompose2dScale(e.baseTransform,n);const a=this._createMeshCanvas(n,s===al?null:this._background,e.cachedCanvases);return s!==al&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class ul extends ol{getPattern(){return"hotpink"}}const pl=1,gl=2;class fl{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),ur("TilingType: "+n);const h=e[0],c=e[1],d=e[2],u=e[3],p=d-h,g=u-c,f=new Float32Array(2);Pr.singularValueDecompose2dScale(this.matrix,f);const[m,v]=f;Pr.singularValueDecompose2dScale(this.baseTransform,f);const b=m*f[0],y=v*f[1];let w=p,x=g,A=!1,_=!1;const S=Math.ceil(o*b),T=Math.ceil(l*y);S>=Math.ceil(p*b)?w=o:A=!0,T>=Math.ceil(g*y)?x=l:_=!0;const k=this.getSizeAndScale(w,this.ctx.canvas.width,b),C=this.getSizeAndScale(x,this.ctx.canvas.height,y),E=t.cachedCanvases.getCanvas("pattern",k.size,C.size),M=E.context,P=r.createCanvasGraphics(M);if(P.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(P,s,a),M.translate(-k.scale*h,-C.scale*c),P.transform(k.scale,0,0,C.scale,0,0),M.save(),this.clipBbox(P,h,c,d,u),P.baseTransform=Yr(P.ctx),P.executeOperatorList(i),P.endDrawing(),M.restore(),A||_){const e=E.canvas;A&&(w=o),_&&(x=l);const i=this.getSizeAndScale(w,this.ctx.canvas.width,b),s=this.getSizeAndScale(x,this.ctx.canvas.height,y),n=i.size,a=s.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),d=r.context,u=A?Math.floor(p/o):0,f=_?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)d.drawImage(e,n*t,a*i,n,a,0,0,n,a);return{canvas:r.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:c}}return{canvas:E.canvas,scaleX:k.scale,scaleY:C.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,i){const s=Math.max(fl.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const a=s-e,r=n-i;t.ctx.rect(e,i,a,r),Pr.axialAlignedBoundingBox([e,i,s,n],Yr(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case pl:const{fillStyle:t,strokeStyle:a}=this.ctx;s.fillStyle=n.fillColor=t,s.strokeStyle=n.strokeColor=a;break;case gl:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new Sr(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s){let n=i;s!==al&&(n=Pr.transform(n,e.baseTransform),this.matrix&&(n=Pr.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}}function ml({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=Er.isLittleEndian?4278190080:255,[l,h]=r?[a,o]:[o,a],c=s>>3,d=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(const s=e+c;e<s;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===d)continue;const s=e<u?t[e++]:255;for(let t=0;t<d;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const vl=16,bl=new DOMMatrix,yl=new Float32Array(2),wl=new Float32Array([1/0,1/0,-1/0,-1/0]);class xl{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Al(t,e,i,s,n,a,r,o,l,h){const[c,d,u,p,g,f]=Yr(t);if(0===d&&0===u){const m=r*c+g,v=Math.round(m),b=o*p+f,y=Math.round(b),w=(r+l)*c+g,x=Math.abs(Math.round(w)-v)||1,A=(o+h)*p+f,_=Math.abs(Math.round(A)-y)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),v,y),t.drawImage(e,i,s,n,a,0,0,x,_),t.setTransform(c,d,u,p,g,f),[x,_]}if(0===c&&0===p){const m=o*u+g,v=Math.round(m),b=r*d+f,y=Math.round(b),w=(o+h)*u+g,x=Math.abs(Math.round(w)-v)||1,A=(r+l)*d+f,_=Math.abs(Math.round(A)-y)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,v,y),t.drawImage(e,i,s,n,a,0,0,_,x),t.setTransform(c,d,u,p,g,f),[_,x]}t.drawImage(e,i,s,n,a,r,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class _l{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Da;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=Ua;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e){this.clipBox=new Float32Array([0,0,t,e]),this.minMax=wl.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=sl,e=null){const i=this.minMax.slice();if(t===nl){e||gr("Stroke bounding box must include transform."),Pr.singularValueDecompose2dScale(e,yl);const t=yl[0]*this.lineWidth/2,s=yl[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=Pr.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(wl,0)}getClippedPathBoundingBox(t=sl,e=null){return Pr.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Sl(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%vl,a=(i-n)/vl,r=0===n?a:a+1,o=t.createImageData(s,vl);let l,h=0;const c=e.data,d=o.data;let u,p,g,f;if(e.kind===Ya.GRAYSCALE_1BPP){const e=c.byteLength,i=new Uint32Array(d.buffer,0,d.byteLength>>2),f=i.length,m=s+7>>3,v=4294967295,b=Er.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<a?vl:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const a=t>m?s:8*t-7,r=-8&a;let o=0,d=0;for(;n<r;n+=8)d=c[h++],i[l++]=128&d?v:b,i[l++]=64&d?v:b,i[l++]=32&d?v:b,i[l++]=16&d?v:b,i[l++]=8&d?v:b,i[l++]=4&d?v:b,i[l++]=2&d?v:b,i[l++]=1&d?v:b;for(;n<a;n++)0===o&&(d=c[h++],o=128),i[l++]=d&o?v:b,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*vl)}}else if(e.kind===Ya.RGBA_32BPP){for(p=0,f=s*vl*4,u=0;u<a;u++)d.set(c.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=vl;u<r&&(f=s*n*4,d.set(c.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==Ya.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=vl,f=s*g,u=0;u<r;u++){for(u>=a&&(g=n,f=s*g),l=0,p=f;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*vl)}}}function Tl(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%vl,a=(i-n)/vl,r=0===n?a:a+1,o=t.createImageData(s,vl);let l=0;const h=e.data,c=o.data;for(let e=0;e<r;e++){const i=e<a?vl:n;({srcPos:l}=ml({src:h,srcPos:l,dest:c,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*vl)}}function kl(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Cl(t){t.strokeStyle=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);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function El(t,e){if(e)return!0;Pr.singularValueDecompose2dScale(t,yl);const i=Math.fround(Zr.pixelRatio*Br.PDF_TO_CSS_UNITS);return yl[0]<=i&&yl[1]<=i}const Ml=["butt","round","square"],Pl=["miter","round","bevel"],Dl={},Il={};class Rl{constructor(t,e,i,s,n,{optionalContentConfig:a,markedContentStack:r=null},o,l){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=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=r||[],this.optionalContentConfig=a,this.cachedCanvases=new xl(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,a=this.ctx.canvas.height,r=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=r,i){const t=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Yr(this.compositeCtx))}this.ctx.save(),Cl(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Yr(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const l=o-r>10&&"function"==typeof i,h=l?Date.now()+15:0;let c=0;const d=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&r===s.nextBreakPoint)return s.breakIt(r,i),r;if(p=a[r],p!==nr.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?d:u;if(!e.has(t))return e.get(t,i),r}if(r++,r===o)return r;if(l&&++c>10){if(Date.now()>h)return i(),r;c=0}}}#Ii(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,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)}endDrawing(){this.#Ii(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#Ri()}#Ri(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,a,r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,c="prescale1";for(;r>2&&l>1||o>2&&h>1;){let e=l,i=h;r>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(c,e,i),a=n.context,a.clearRect(0,0,e,i),a.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,a=this.current.patternFill,r=Yr(e);let o,l,h,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(a?r:[r.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!a){return{canvas:i,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])}}h=i}h||(c=this.cachedCanvases.getCanvas("maskCanvas",i,s),Tl(c.context,t));let d=Pr.transform(r,[1/i,0,0,-1/s,0,0]);d=Pr.transform(d,[1,0,0,1,0,-s]);const u=wl.slice();Pr.axialAlignedBoundingBox([0,0,i,s],d,u);const[p,g,f,m]=u,v=Math.round(f-p)||1,b=Math.round(m-g)||1,y=this.cachedCanvases.getCanvas("fillCanvas",v,b),w=y.context,x=p,A=g;w.translate(-x,-A),w.transform(...d),h||(h=this._scaleImage(c.canvas,Qr(w)),h=h.img,o&&a&&o.set(l,h)),w.imageSmoothingEnabled=El(Yr(w),t.interpolate),Al(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=Pr.transform(Qr(w),[1,0,0,1,-x,-A]);return w.fillStyle=a?n.getPattern(e,this,_,sl):n,w.fillRect(0,0,i,s),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,y.canvas)),{canvas:y.canvas,offsetX:Math.round(x),offsetY:Math.round(A)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ml[t]}setLineJoin(t){this.ctx.lineJoin=Pl[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){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=i;break;case"ca":this.ctx.globalAlpha=this.current.fillAlpha=i;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.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx;const n=this.ctx=s.context;n.setTransform(this.suspendedCtx.getTransform()),kl(this.suspendedCtx,n),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,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,a,r){e.transform(t,i,s,n,a,r),this.__originalTransform(t,i,s,n,a,r)},t.setTransform=function(t,i,s,n,a,r){e.setTransform(t,i,s,n,a,r),this.__originalSetTransform(t,i,s,n,a,r)},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,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,a,r){e.bezierCurveTo(t,i,s,n,a,r),this.__originalBezierCurveTo(t,i,s,n,a,r)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),kl(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;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];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,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()}composeSMask(t,e,i,s){const n=s[0],a=s[1],r=s[2]-n,o=s[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,i,r,o,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,a,r,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(a)if(u<0||p<0||u+i>d.width||p+s>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(d,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=a,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(u,p,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode&&kl(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&kl(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,a){this.ctx.transform(t,e,i,s,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let[s]=e;if(!i)return s||=e[0]=new Path2D,void this[t](s);if(!(s instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,i=s.length;e<i;)switch(s[e++]){case ar:t.moveTo(s[e++],s[e++]);break;case rr:t.lineTo(s[e++],s[e++]);break;case or:t.bezierCurveTo(s[e++],s[e++],s[e++],s[e++],s[e++],s[e++]);break;case lr:t.closePath();break;default:pr(`Unrecognized drawing path operator: ${s[e-1]}`)}s=t}Pr.axialAlignedBoundingBox(i,Yr(this.ctx),this.current.minMax),this[t](s)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const i=this.ctx,s=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=s.getPattern(i,this,Qr(i),nl),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}this.rescaleAndStroke(t,!1),i.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(nl,Yr(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const i=this.ctx,s=this.current.fillColor;let n=!1;if(this.current.patternFill){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.fillStyle=s.getPattern(i,this,Qr(i),sl),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}n=!0}const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(i.fill(t,"evenodd"),this.pendingEOFill=!1):i.fill(t)),n&&i.restore(),e&&this.consumePath(t,a)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=Dl}eoClip(){this.pendingClip=Il}beginText(){this.current.textMatrix=null,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)return;const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:a,fontSize:r,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,a).scale(r,-r));e.clip(i),delete this.pendingTextPaths}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 i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||Da,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||pr("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let r="normal";i.black?r="900":i.bold&&(r="bold");const o=i.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${r} ${l}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){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#Li(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const a=this.ctx,r=this.current,o=r.font,l=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,c=l&Ka,d=!!(l&Xa),u=r.patternFill&&!o.missingFile,p=r.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||d||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){let t;if(a.save(),a.translate(e,i),a.scale(h,-h),c!==Ua&&c!==qa||(s?(t=a.getTransform(),a.setTransform(...s),a.fill(this.#Li(g,t,s))):a.fill(g)),c===Ga||c===qa)if(n){t||=a.getTransform(),a.setTransform(...n);const{a:e,b:i,c:s,d:r}=t,o=Pr.inverseTransform(n),l=Pr.transform([e,i,s,r,0,0],o);Pr.singularValueDecompose2dScale(l,yl),a.lineWidth*=Math.max(yl[0],yl[1])/h,a.stroke(this.#Li(g,t,n))}else a.lineWidth/=h,a.stroke(g);a.restore()}else c!==Ua&&c!==qa||a.fillText(t,e,i),c!==Ga&&c!==qa||a.strokeText(t,e,i);if(d){(this.pendingTextPaths||=[]).push({transform:Yr(a),x:e,y:i,fontSize:h,path:g})}}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 i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return br(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,a=e.fontSizeScale,r=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,c=t.length,d=i.vertical,u=d?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],f=e.textRenderingMode===Ua&&!i.disableFontFace&&!e.patternFill;let m,v;if(n.save(),e.textMatrix&&n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,Qr(n),sl);m=Yr(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,Qr(n),nl);v=Yr(n),n.restore(),n.strokeStyle=t}let b=e.lineWidth;const y=e.textMatrixScale;if(0===y||0===b){const t=e.textRenderingMode&Ka;t!==Ga&&t!==qa||(b=this.getSinglePixelWidth())}else b/=y;if(1!==a&&(n.scale(a,a),b/=a),n.lineWidth=b,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let w,x=0;for(w=0;w<c;++w){const e=t[w];if("number"==typeof e){x+=u*e*s/1e3;continue}let h=!1;const c=(e.isSpace?o:0)+r,b=e.fontChar,y=e.accent;let A,_,S=e.width;if(d){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*S)*g,s=t[2]*g;S=t?-t[0]:S,A=i/a,_=(x+s)/a}else A=x/a,_=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(b).width/s*a;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;h=!0,n.save(),n.scale(e,1),A/=e}else S!==t&&(A+=(S-t)/2e3*s/a)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(f&&!y)n.fillText(b,A,_);else if(this.paintChar(b,A,_,m,v),y){const t=A+s*y.offset.x/a,e=_-s*y.offset.y/a;this.paintChar(y.fontChar,t,e,m,v)}x+=d?S*g-c*l:S*g+c*l,h&&n.restore()}d?e.y-=x:e.x+=x*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,a=i.fontDirection,r=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,h=i.textHScale*a,c=i.fontMatrix||Da,d=t.length;let u,p,g,f;if(!(i.textRenderingMode===Wa)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),i.textMatrix&&e.transform(...i.textMatrix),e.translate(i.x,i.y+i.textRise),e.scale(h,a),u=0;u<d;++u){if(p=t[u],"number"==typeof p){f=r*p*n/1e3,this.ctx.translate(f,0),i.x+=f*h;continue}const a=(p.isSpace?l:0)+o,d=s.charProcOperatorList[p.operatorListId];d?this.contentVisible&&(this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(d),this.restore()):pr(`Type3 character "${p.operatorListId}" is not available.`);const m=[p.width,0];Pr.applyTransform(m,c),g=m[0]*n+a,e.translate(g,0),i.x+=g*h}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,a){const r=new Path2D;r.rect(i,s,n-i,a-s),this.ctx.clip(r),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=this.baseTransform||Yr(this.ctx),s={createCanvasGraphics:t=>new Rl(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new fl(t,this.ctx,s,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new ll(t);case"Mesh":return new dl(t);case"Dummy":return new ul}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,Qr(e),al);const s=Qr(e);if(s){const{width:t,height:i}=e.canvas,n=wl.slice();Pr.axialAlignedBoundingBox([0,0,t,i],s,n);const[a,r,o,l]=n;this.ctx.fillRect(a,r,o-a,l-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){gr("Should not call beginInlineImage")}beginImageData(){gr("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Yr(this.ctx),e)){Pr.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,i,s,n]=e,a=new Path2D;a.rect(t,i,s-t,n-i),this.ctx.clip(a),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||ur("TODO: Support non-isolated groups."),t.knockout&&pr("Knockout groups not supported.");const i=Yr(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=wl.slice();Pr.axialAlignedBoundingBox(t.bbox,Yr(e),s);const n=[0,0,e.canvas.width,e.canvas.height];s=Pr.intersect(s,n)||[0,0,0,0];const a=Math.floor(s[0]),r=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-a,1),l=Math.max(Math.ceil(s[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(h,o,l),d=c.context;d.translate(-a,-r),d.transform(...i);let u=new Path2D;const[p,g,f,m]=t.bbox;if(u.rect(p,g,f-p,m-g),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}d.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:d,offsetX:a,offsetY:r,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,r),e.save()),kl(e,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=Yr(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=wl.slice();Pr.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,i),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#Ii(),Cl(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=a,Pr.singularValueDecompose2dScale(Yr(this.ctx),yl);const{viewportScale:n}=this,r=Math.ceil(s*this.outputScaleX*n),o=Math.ceil(a*this.outputScaleY*n);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(t,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(yl[0],0,0,-yl[1],0,a*yl[1]),Cl(this.ctx)}else{Cl(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],s,a),this.ctx.clip(t)}}this.current=new _l(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Ri(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this._createMaskCanvas(t),n=s.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(n,s.offsetX,s.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const r=this.ctx;r.save();const o=Yr(r);r.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);r.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=a.length;t<h;t+=2){const h=Pr.transform(o,[e,i,s,n,a[t],a[t+1]]);r.drawImage(l.canvas,h[4],h[5])}r.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:a,height:r,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",a,r),h=l.context;h.save();Tl(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,Qr(e),sl):i,h.fillRect(0,0,a,r),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),Al(e,l.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):pr("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void pr("Dependent image isn't ready yet");const a=n.width,r=n.height,o=[];for(let t=0,n=s.length;t<n;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:a,h:r});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;this.save();const{filter:n}=s;let a;if("none"!==n&&""!==n&&(s.filter="none"),s.scale(1/e,-1/i),t.bitmap)a=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)a=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Sl(s,t),a=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(a,Qr(s));s.imageSmoothingEnabled=El(Yr(s),t.interpolate),Al(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=t.width,i=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Sl(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),Al(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.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){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t,e){const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const s=this.ctx;this.pendingClip&&(i||(this.pendingClip===Il?s.clip(t,"evenodd"):s.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Yr(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let a,r;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)a=r=1/i;else{const e=i*t;a=r=e<1?1/e:1}else if(0===t)a=1/i,r=1/s;else{const e=i*t,n=s*t;a=e<1?1/e:1,r=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)a=h/o,r=l/o;else{const e=t*o;a=h>e?h/e:1,r=l>e?l/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,a]=this.getScaleForStroking();if(n===a)return i.lineWidth=(s||1)*n,void i.stroke(t);const r=i.getLineDash();e&&i.save(),i.scale(n,a),bl.a=1/n,bl.d=1/a;const o=new Path2D;if(o.addPath(t,bl),r.length>0){const t=Math.max(n,a);i.setLineDash(r.map((e=>e/t))),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in nr)void 0!==Rl.prototype[t]&&(Rl.prototype[nr[t]]=Rl.prototype[t]);class Ll{static#Fi=null;static#Ni="";static get workerPort(){return this.#Fi}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Fi=t}static get workerSrc(){return this.#Ni}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Ni=t}}class Fl{#Oi;#Bi;constructor({parsedData:t,rawData:e}){this.#Oi=t,this.#Bi=e}getRaw(){return this.#Bi}get(t){return this.#Oi.get(t)??null}[Symbol.iterator](){return this.#Oi.entries()}}const Nl=Symbol("INTERNAL");class Ol{#zi=!1;#ji=!1;#Vi=!1;#Hi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#zi=!!(t&La),this.#ji=!!(t&Fa),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#Vi)return this.#Hi;if(!this.#Hi)return!1;const{print:t,view:e}=this.usage;return this.#zi?"OFF"!==e?.viewState:!this.#ji||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Nl&&gr("Internal method `_setVisible` called."),this.#Vi=i,this.#Hi=e}}class Bl{#$i=null;#Ui=new Map;#Gi=null;#qi=null;constructor(t,e=La){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#qi=t.order;for(const i of t.groups)this.#Ui.set(i.id,new Ol(e,i));if("OFF"===t.baseState)for(const t of this.#Ui.values())t._setVisible(Nl,!1);for(const e of t.on)this.#Ui.get(e)._setVisible(Nl,!0);for(const e of t.off)this.#Ui.get(e)._setVisible(Nl,!1);this.#Gi=this.getHash()}}#Wi(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Wi(e);else{if(!this.#Ui.has(e))return pr(`Optional content group not found: ${e}`),!0;n=this.#Ui.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Ui.size)return!0;if(!t)return ur("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ui.has(t.id)?this.#Ui.get(t.id).visible:(pr(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Wi(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return pr(`Optional content group not found: ${e}`),!0;if(this.#Ui.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return pr(`Optional content group not found: ${e}`),!0;if(!this.#Ui.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return pr(`Optional content group not found: ${e}`),!0;if(!this.#Ui.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Ui.has(e))return pr(`Optional content group not found: ${e}`),!0;if(this.#Ui.get(e).visible)return!1}return!0}return pr(`Unknown optional content policy ${t.policy}.`),!0}return pr(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Ui.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Ui.get(i)?._setVisible(Nl,!1,!0);s._setVisible(Nl,!!e,!0),this.#$i=null}else pr(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#Ui.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#$i=null}get hasInitialVisibility(){return null===this.#Gi||this.getHash()===this.#Gi}getOrder(){return this.#Ui.size?this.#qi?this.#qi.slice():[...this.#Ui.keys()]:null}getGroup(t){return this.#Ui.get(t)||null}getHash(){if(null!==this.#$i)return this.#$i;const t=new bo;for(const[e,i]of this.#Ui)t.update(`${e}:${i.visible}`);return this.#$i=t.hexdigest()}[Symbol.iterator](){return this.#Ui.entries()}}class zl{constructor(t,{disableRange:e=!1,disableStream:i=!1}){fr(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:a,contentDispositionFilename:r}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=r,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{fr(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){fr(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new jl(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Vl(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class jl{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=$r(s)?s: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){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else 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=Promise.withResolvers();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 Vl{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,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=Promise.withResolvers();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)}}function Hl(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function $l(t){return URL.parse(t)?.origin??null}function Ul({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(a))return n;if(n.suggestedLength=a,a<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function Gl(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=r(i);return t=unescape(t),t=o(t),t=l(t),a(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const a=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=r(s),i&&(s=unescape(s),0===t&&(s=o(s))),a.push(s)}return a.join("")}(t),i)return a(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=r(i);return t=l(t),a(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=Cr(i);i=s.decode(n),e=!1}catch{}}return i}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if($r(t))return t}return null}function ql(t,e){return new _r(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function Wl(t){return 200===t||206===t}function Kl(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Xl(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(pr(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Yl{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Hl(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return fr(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ql(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Jl(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ql{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=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,Kl(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=$l(e.url),!Wl(e.status))throw ql(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:a}=Ul({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=Gl(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Tr("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?.({loaded:this._loaded,total:this._contentLength}),{value:Xl(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Jl{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const a=s.url;fetch(a,Kl(n,this._withCredentials,this._abortController)).then((e=>{const i=$l(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Wl(e.status))throw ql(e.status,a);this._readCapability.resolve(),this._reader=e.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?.({loaded:this._loaded}),{value:Xl(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Zl{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Hl(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",fr(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const a=function(t){const e=t.response;return"string"!=typeof e?e:Cr(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:a}):(pr('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone({begin:0,chunk:a}):i.onError(s.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()}}class th{constructor(t){this._source=t,this._manager=new Zl(t),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 fr(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new eh(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new ih(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class eh{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),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);this._manager._responseOrigin=$l(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:a}=Ul({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=Gl(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(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=ql(t,this._url),this._headersCapability.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._headersCapability.promise}async read(){if(await this._headersCapability.promise,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=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.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 ih{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=$l(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else 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??=ql(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=Promise.withResolvers();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()}}const sh=/^[a-z][a-z0-9\-+.]+:/i;class nh{constructor(t){this.source=t,this.url=function(t){if(sh.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),fr("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return fr(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new ah(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new rh(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class ah{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=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=ql(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)}))}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();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{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 Tr("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class rh{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}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();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{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)}}const oh=Symbol("INITIAL_DATA");class lh{#Ki=Object.create(null);#Xi(t){return this.#Ki[t]||={...Promise.withResolvers(),data:oh}}get(t,e=null){if(e){const i=this.#Xi(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Ki[t];if(!i||i.data===oh)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Ki[t];return!!e&&e.data!==oh}delete(t){const e=this.#Ki[t];return!(!e||e.data===oh)&&(delete this.#Ki[t],!0)}resolve(t,e=null){const i=this.#Xi(t);i.data=e,i.resolve()}clear(){for(const t in this.#Ki){const{data:e}=this.#Ki[t];e?.bitmap?.close()}this.#Ki=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Ki){const{data:e}=this.#Ki[t];e!==oh&&(yield[t,e])}}}class hh{#Yi=Promise.withResolvers();#mt=null;#Qi=!1;#Ji=!!globalThis.FontInspector?.enabled;#Zi=null;#ts=null;#es=0;#is=0;#ss=null;#ns=null;#as=0;#rs=0;#os=Object.create(null);#ls=[];#hs=null;#cs=[];#ds=new WeakMap;#us=null;static#ps=new Map;static#gs=new Map;static#fs=new WeakMap;static#ms=null;static#vs=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#hs=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#hs=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#mt=this.#ns=e,this.#rs=i.scale*Zr.pixelRatio,this.#as=i.rotation,this.#ts={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:a,pageY:r}=i.rawDims;this.#us=[1,0,0,-1,-a,r+n],this.#is=s,this.#es=n,hh.#bs(),Jr(e,i),this.#Yi.promise.finally((()=>{hh.#vs.delete(this),this.#ts=null,this.#os=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Er.platform;return br(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#ss.read().then((({value:e,done:i})=>{i?this.#Yi.resolve():(this.#Zi??=e.lang,Object.assign(this.#os,e.styles),this.#ys(e.items),t())}),this.#Yi.reject)};return this.#ss=this.#hs.getReader(),hh.#vs.add(this),t(),this.#Yi.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*Zr.pixelRatio,s=t.rotation;if(s!==this.#as&&(e?.(),this.#as=s,Jr(this.#ns,{rotation:s})),i!==this.#rs){e?.(),this.#rs=i;const t={div:null,properties:null,ctx:hh.#ws(this.#Zi)};for(const e of this.#cs)t.properties=this.#ds.get(e),t.div=e,this.#xs(t)}}cancel(){const t=new Tr("TextLayer task cancelled.");this.#ss?.cancel(t).catch((()=>{})),this.#ss=null,this.#Yi.reject(t)}get textDivs(){return this.#cs}get textContentItemsStr(){return this.#ls}#ys(t){if(this.#Qi)return;this.#ts.ctx??=hh.#ws(this.#Zi);const e=this.#cs,i=this.#ls;for(const s of t){if(e.length>1e5)return pr("Ignoring additional textDivs for performance reasons."),void(this.#Qi=!0);if(void 0!==s.str)i.push(s.str),this.#As(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#mt;this.#mt=document.createElement("span"),this.#mt.classList.add("markedContent"),null!==s.id&&this.#mt.setAttribute("id",`${s.id}`),t.append(this.#mt)}else"endMarkedContent"===s.type&&(this.#mt=this.#mt.parentNode)}}#As(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#cs.push(e);const s=Pr.transform(this.#us,t.transform);let n=Math.atan2(s[1],s[0]);const a=this.#os[t.fontName];a.vertical&&(n+=Math.PI/2);let r=this.#Ji&&a.fontSubstitution||a.fontFamily;r=hh.fontFamilyMap.get(r)||r;const o=Math.hypot(s[2],s[3]),l=o*hh.#_s(r,a,this.#Zi);let h,c;0===n?(h=s[4],c=s[5]-l):(h=s[4]+l*Math.sin(n),c=s[5]-l*Math.cos(n));const d="calc(var(--total-scale-factor) *",u=e.style;this.#mt===this.#ns?(u.left=`${(100*h/this.#is).toFixed(2)}%`,u.top=`${(100*c/this.#es).toFixed(2)}%`):(u.left=`${d}${h.toFixed(2)}px)`,u.top=`${d}${c.toFixed(2)}px)`),u.fontSize=`${d}${(hh.#ms*o).toFixed(2)}px)`,u.fontFamily=r,i.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Ji&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==n&&(i.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(i.canvasWidth=a.vertical?t.height:t.width),this.#ds.set(e,i),this.#ts.div=e,this.#ts.properties=i,this.#xs(this.#ts),i.hasText&&this.#mt.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#mt.append(t)}}#xs(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;let a="";if(hh.#ms>1&&(a=`scale(${1/hh.#ms})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:r,fontSize:o}=i;hh.#Ss(s,o*this.#rs,t);const{width:l}=s.measureText(e.textContent);l>0&&(a=`scaleX(${r*this.#rs/l}) ${a}`)}0!==i.angle&&(a=`rotate(${i.angle}deg) ${a}`),a.length>0&&(n.transform=a)}static cleanup(){if(!(this.#vs.size>0)){this.#ps.clear();for(const{canvas:t}of this.#gs.values())t.remove();this.#gs.clear()}}static#ws(t=null){let e=this.#gs.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#gs.set(t,e),this.#fs.set(e,{size:0,family:""})}return e}static#Ss(t,e,i){const s=this.#fs.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#bs(){if(null!==this.#ms)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#ms=t.getBoundingClientRect().height,t.remove()}static#_s(t,e,i){const s=this.#ps.get(t);if(s)return s;const n=this.#ws(i);n.canvas.width=n.canvas.height=30,this.#Ss(n,30,t);const a=n.measureText(""),r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return r?l=r/(r+o):(Er.platform.isFirefox&&pr("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#ps.set(t,l),l}}class ch{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!ch.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}function dh(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new uh,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(Pa)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(Pa&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Cr(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,r=!0===t.withCredentials,o=t.password??null,l=t.range instanceof ph?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let c=t.worker instanceof mh?t.worker:null;const d=t.verbosity,u="string"!=typeof t.docBaseUrl||Hr(t.docBaseUrl)?null:t.docBaseUrl,p=So(t.cMapUrl),g=!1!==t.cMapPacked,f=t.CMapReaderFactory||(Pa?tl:Uo),m=So(t.iccUrl),v=So(t.standardFontDataUrl),b=t.StandardFontDataFactory||(Pa?el:Ko),y=So(t.wasmUrl),w=t.WasmFactory||(Pa?il:Yo),x=!0!==t.stopAtErrors,A=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,_=!1!==t.isEvalSupported,S="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!Pa,T="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!Pa&&(Er.platform.isFirefox||!globalThis.chrome),k=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:Pa,E=!0===t.fontExtraProperties,M=!0===t.enableXfa,P=t.ownerDocument||globalThis.document,D=!0===t.disableRange,I=!0===t.disableStream,R=!0===t.disableAutoFetch,L=!0===t.pdfBug,F=t.CanvasFactory||(Pa?Zo:Ho),N=t.FilterFactory||(Pa?Jo:qo),O=!0===t.enableHWA,B=!1!==t.useWasm,z=l?l.length:t.length??NaN,j="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!Pa&&!C,V="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===Uo&&b===Ko&&w===Yo&&p&&v&&y&&Gr(p,document.baseURI)&&Gr(v,document.baseURI)&&Gr(y,document.baseURI));cr(d);const H={canvasFactory:new F({ownerDocument:P,enableHWA:O}),filterFactory:new N({docId:i,ownerDocument:P}),cMapReaderFactory:V?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:V?null:new b({baseUrl:v}),wasmFactory:V?null:new w({baseUrl:y})};c||(c=mh.create({verbosity:d,port:Ll.workerPort}),e._worker=c);const $={docId:i,apiVersion:"5.3.31",data:n,password:o,disableAutoFetch:R,rangeChunkSize:h,length:z,docBaseUrl:u,enableXfa:M,evaluatorOptions:{maxImageSize:A,disableFontFace:C,ignoreErrors:x,isEvalSupported:_,isOffscreenCanvasSupported:S,isImageDecoderSupported:T,canvasMaxAreaInBytes:k,fontExtraProperties:E,useSystemFonts:j,useWasm:B,useWorkerFetch:V,cMapUrl:p,iccUrl:m,standardFontDataUrl:v,wasmUrl:y}},U={ownerDocument:P,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:M}};return c.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",$,n?[n.buffer]:null);let o;if(l)o=new zl(l,{disableRange:D,disableStream:I});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const t=Gr(s)?Yl:Pa?nh:th;o=new t({url:s,length:z,httpHeaders:a,withCredentials:r,rangeChunkSize:h,disableRange:D,disableStream:I})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new jo(i,t,c.port),n=new vh(s,e,o,U,H);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}class uh{static#bi=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+uh.#bi++;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class ph{#Yi=Promise.withResolvers();#Ts=[];#ks=[];#Cs=[];#Es=[];constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){this.#Es.push(t)}addProgressListener(t){this.#Cs.push(t)}addProgressiveReadListener(t){this.#ks.push(t)}addProgressiveDoneListener(t){this.#Ts.push(t)}onDataRange(t,e){for(const i of this.#Es)i(t,e)}onDataProgress(t,e){this.#Yi.promise.then((()=>{for(const i of this.#Cs)i(t,e)}))}onDataProgressiveRead(t){this.#Yi.promise.then((()=>{for(const e of this.#ks)e(t)}))}onDataProgressiveDone(){this.#Yi.promise.then((()=>{for(const t of this.#Ts)t()}))}transportReady(){this.#Yi.resolve()}requestDataRange(t,e){gr("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class gh{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return br(this,"isPureXfa",!!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()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class fh{#Ms=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Ur:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new lh,this._intentStates=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:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new jr({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return br(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=Va.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:r=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:c=!1}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(i,s,h,c),{renderingIntent:u,cacheKey:p}=d;this.#Ms=!1,r||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&Fa);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const m=t=>{g.renderTasks.delete(v),f&&(this.#Ms=!0),this.#Ps(),t?(v.capability.reject(t),this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})):v.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},v=new yh({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||=new Set).add(v);const b=v.task;return Promise.all([g.displayReadyCapability.promise,r]).then((([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");v.initializeGraphics({transparency:t,optionalContentConfig:e}),v.operatorListChanged()}})).catch(m),b}getOperatorList({intent:t="display",annotationMode:e=Va.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let a,r=this._intentStates.get(n.cacheKey);return r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r)),r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>ch.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return 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 i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#Ms=!1,Promise.all(t)}cleanup(t=!1){this.#Ms=!0;const e=this.#Ps();return t&&e&&(this._stats&&=new Ur),e}#Ps(){if(!this.#Ms||this.destroyed)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.#Ms=!1,!0}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#Ps()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:a}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},a).getReader(),o=this._intentStates.get(e);o.streamReader=r;const l=()=>{r.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#Ps()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Vr){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new Tr(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class mh{#Yi=Promise.withResolvers();#Ds=null;#Fi=null;#Is=null;static#Rs=0;static#Ls=!1;static#Fs=new WeakMap;static{Pa&&(this.#Ls=!0,Ll.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{var e;if(e="`PDFWorker.fromPort` - please use `PDFWorker.create` instead.",console.log("Deprecated API usage: "+e),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=dr()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(mh.#Fs.has(e))throw new Error("Cannot use more than one PDFWorker per port.");mh.#Fs.set(e,this),this.#Ns(e)}else this.#Os()}get promise(){return this.#Yi.promise}#Bs(){this.#Yi.resolve(),this.#Ds.send("configure",{verbosity:this.verbosity})}get port(){return this.#Fi}get messageHandler(){return this.#Ds}#Ns(t){this.#Fi=t,this.#Ds=new jo("main","worker",t),this.#Ds.on("ready",(()=>{})),this.#Bs()}#Os(){if(mh.#Ls||mh.#zs)return void this.#js();let{workerSrc:t}=mh;try{mh._isSameOrigin(window.location,t)||(t=mh._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new jo("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#Yi.reject(new Error("Worker was destroyed")):this.#js()},n=new AbortController;e.addEventListener("error",(()=>{this.#Is||s()}),{signal:n.signal}),i.on("test",(t=>{n.abort(),!this.destroyed&&t?(this.#Ds=i,this.#Fi=e,this.#Is=e,this.#Bs()):s()})),i.on("ready",(t=>{if(n.abort(),this.destroyed)s();else try{a()}catch{this.#js()}}));const a=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void a()}catch{ur("The worker has been disabled.")}this.#js()}#js(){mh.#Ls||(pr("Setting up fake worker."),mh.#Ls=!0),mh._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this.#Yi.reject(new Error("Worker was destroyed"));const e=new Co;this.#Fi=e;const i="fake"+mh.#Rs++,s=new jo(i+"_worker",i,e);t.setup(s,e),this.#Ds=new jo(i,i+"_worker",e),this.#Bs()})).catch((t=>{this.#Yi.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this.#Is?.terminate(),this.#Is=null,mh.#Fs.delete(this.#Fi),this.#Fi=null,this.#Ds?.destroy(),this.#Ds=null}static create(t){const e=this.#Fs.get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new mh(t)}static get workerSrc(){if(Ll.workerSrc)return Ll.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#zs(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return br(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#zs)return this.#zs;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class vh{#Vs=new Map;#Hs=new Map;#$s=new Map;#Us=new Map;#Gs=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new lh,this.fontLoader=new Ao({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#qs(t,e=null){const i=this.#Vs.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Vs.set(t,s),s}get annotationStorage(){return br(this,"annotationStorage",new wo)}getRenderingIntent(t,e=Va.ENABLE,i=null,s=!1,n=!1){let a=La,r=yo;switch(t){case"any":a=Ra;break;case"display":break;case"print":a=Fa;break;default:pr(`getRenderingIntent - invalid intent: ${t}`)}const o=a&Fa&&i instanceof xo?i:this.annotationStorage;switch(e){case Va.DISABLE:a+=Ba;break;case Va.ENABLE:break;case Va.ENABLE_FORMS:a+=Na;break;case Va.ENABLE_STORAGE:a+=Oa,r=o.serializable;break;default:pr(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(a+=za),n&&(a+=ja);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,h].join("_"),annotationStorageSerializable:r,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Gs?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Hs.values())t.push(e._destroy());this.#Hs.clear(),this.#$s.clear(),this.#Us.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.#Vs.clear(),this.filterFactory.destroy(),hh.cleanup(),this._networkStream?.cancelAllRequests(new Tr("Worker was terminated.")),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)=>{fr(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:i}){i?e.close():(fr(t instanceof ArrayBuffer,"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",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{fr(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(fr(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.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 gh(t,this))})),t.on("DocException",(t=>{e._capability.reject(zo(t))})),t.on("PasswordRequest",(t=>{this.#Gs=Promise.withResolvers();try{if(!e.onPassword)throw zo(t);const i=t=>{t instanceof Error?this.#Gs.reject(t):this.#Gs.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Gs.reject(t)}return this.#Gs.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#Hs.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){const t=s.error;pr(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const n=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new _o(s,n);this.fontLoader.bind(a).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a.fontExtraProperties&&a.data&&(a.data=null),this.commonObjs.resolve(e,a)}));break;case"CopyLocalImage":const{imageRef:r}=s;fr(r,"The imageRef must be defined.");for(const t of this.#Hs.values())for(const[,i]of t.objs)if(i?.ref===r)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#Hs.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&pr("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#$s.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#Us.set(i.refStr,t);const s=new fh(e,i,this,this._params.pdfBug);return this.#Hs.set(e,s),s}));return this.#$s.set(e,s),s}getPageIndex(t){return To(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#qs("GetFieldObjects")}hasJSActions(){return this.#qs("HasJSActions")}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)}getDocJSActions(){return this.#qs("GetDocJSActions")}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(t){return this.#qs("GetOptionalContentConfig").then((e=>new Bl(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Vs.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Fl(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Vs.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Hs.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Vs.clear(),this.filterFactory.destroy(!0),hh.cleanup()}}cachedPageNumber(t){if(!To(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Us.get(e)??null}}class bh{#Ws=null;onContinue=null;onError=null;constructor(t){this.#Ws=t}get promise(){return this.#Ws.capability.promise}cancel(t=0){this.#Ws.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Ws.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Ws;return t.form||t.canvas&&e?.size>0}}class yh{#Ks=null;static#Xs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:a,pageIndex:r,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=r,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new bh(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(yh.#Xs.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.");yh.#Xs.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:i,viewport:s,transform:n,background:a}=this.params;this.gfx=new Rl(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Ks&&(window.cancelAnimationFrame(this.#Ks),this.#Ks=null),yh.#Xs.delete(this._canvas),t||=new Vr(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Ks=window.requestAnimationFrame((()=>{this.#Ks=null,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(),yh.#Xs.delete(this._canvas),this.callback())))}}function wh(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function xh(t){return Math.max(0,Math.min(255,255*t))}class Ah{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=xh(t),t,t]}static G_HTML([t]){const e=wh(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(xh)}static RGB_HTML(t){return`#${t.map(wh).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[xh(1-Math.min(1,t+s)),xh(1-Math.min(1,i+s)),xh(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,a=1-i;return["CMYK",s,n,a,Math.min(s,n,a)]}}class _h{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(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){gr("Abstract method `_createSVG` called.")}}class Sh extends _h{_createSVG(t){return document.createElementNS(Or,t)}}class Th{static setupStorage(t,e,i,s,n){const a=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of i.children)t.attributes.value===a.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${s}`);for(const[e,i]of Object.entries(a))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!r||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}r&&n.addLinkAttributes(t,a.href,a.newWindow),i&&a.dataId&&this.setupStorage(t,a.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:n,linkService:i});const r="richText"!==n,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);a.append(t),r&&ch.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,a]];for(;h.length>0;){const[t,s,a]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const t=document.createTextNode(o.value);l.push(t),a.append(t);continue}const d=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,c):document.createElement(c);if(a.append(d),o.attributes&&this.setAttributes({html:d,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,d]);else if(o.value){const t=document.createTextNode(o.value);r&&ch.shouldBuildText(c)&&l.push(t),d.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const kh=1e3,Ch=new WeakSet;class Eh{static create(t){switch(t.data.annotationType){case Qa.LINK:return new Ph(t);case Qa.TEXT:return new Dh(t);case Qa.WIDGET:switch(t.data.fieldType){case"Tx":return new Rh(t);case"Btn":return t.data.radioButton?new Nh(t):t.data.checkBox?new Fh(t):new Oh(t);case"Ch":return new Bh(t);case"Sig":return new Lh(t)}return new Ih(t);case Qa.POPUP:return new zh(t);case Qa.FREETEXT:return new Vh(t);case Qa.LINE:return new Hh(t);case Qa.SQUARE:return new $h(t);case Qa.CIRCLE:return new Uh(t);case Qa.POLYLINE:return new Gh(t);case Qa.CARET:return new Wh(t);case Qa.INK:return new Kh(t);case Qa.POLYGON:return new qh(t);case Qa.HIGHLIGHT:return new Xh(t);case Qa.UNDERLINE:return new Yh(t);case Qa.SQUIGGLY:return new Qh(t);case Qa.STRIKEOUT:return new Jh(t);case Qa.STAMP:return new Zh(t);case Qa.FILEATTACHMENT:return new tc(t);default:return new Mh(t)}}}class Mh{#Ys=null;#Qs=!1;#Js=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,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.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Mh._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#Ys||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#Zs(e),this.#Js?.popup.updateEdited(t)}resetEdited(){this.#Ys&&(this.#Zs(this.#Ys.rect),this.#Js?.popup.resetEdited(),this.#Ys=null)}#Zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===s?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/a+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Ih||(n.tabIndex=kh);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof zh){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;a.borderRadius=e}else if(this instanceof Nh){const t=`calc(${r}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case Ja:a.borderStyle="solid";break;case Za:a.borderStyle="dashed";break;case tr:pr("Unimplemented border style: beveled");break;case er:pr("Unimplemented border style: inset");break;case ir:a.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Qs=!0,a.borderColor=Pr.makeHexColor(0|s[0],0|s[1],0|s[2])):a.borderWidth=0}const l=Pr.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=s.rawDims;a.left=100*(l[0]-d)/h+"%",a.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/h+"%",a.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:a}=this;t%180!=0&&([n,a]=[a,n]),e.style.width=100*n/i+"%",e.style.height=100*a/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],a=s.slice(1);i.target.style[e]=Ah[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:Ah[`${n}_rgb`](a)})};return br(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const a=i[s];if(a){a({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[a,r,o,l]=t.subarray(2,6);if(s===a&&n===r&&e===o&&i===l)return}const{style:a}=this.container;let r;if(this.#Qs){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],a=t[i+1],c=t[i+2],d=t[i+3],p=h.createElement("rect"),g=(c-e)/o,f=(n-a)/l,m=(s-c)/o,v=(a-d)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",v),u.append(p),r?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${v}"/>`)}this.#Qs&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#Js=new zh({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){gr("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:a}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||Ch.has(r)?i.push({id:n,exportValue:s,domElement:r}):pr(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(Ch.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class Ph extends Mh{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#tn(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#en(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#in(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#in()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#in()}#tn(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#in()}#en(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#in()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#in()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#in(),!this._fieldObjects)return pr('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,a=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&a.push(i)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const r=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;r.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(Ch.has(i)?i.dispatchEvent(new Event("resetform")):pr(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class Dh extends Mh{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ih extends Mh{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Er.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,a]of i)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,n,a,s),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Pr.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let a;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(Ia*s))||1);a=Math.min(s,r(e/Ia))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(s,r(t/Ia))}n.fontSize=`calc(${a}px * var(--total-scale-factor))`,n.color=Pr.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Rh extends Ih{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),n.setValue(a.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&n.length>a&&(n=n.slice(0,a));let r=s.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=r??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",r??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Ch.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=kh,this._setRequired(i,this.data.required),a&&(i.maxLength=a),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let a=o.userValue;!a||a.length<=s||(a=a.slice(0,s),n.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)})),i.addEventListener("keydown",(t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=l;l=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:a,selectionEnd:r}=s;let l=a,h=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":a===r&&(l-=1);break;case"deleteContentForward":a===r&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Lh extends Ih{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Fh extends Ih{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ch.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=kh,n.addEventListener("change",(s=>{const{name:n,checked:a}=s.target;for(const s of this._getElementsByName(n,i)){const i=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:a})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["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._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Nh extends Ih{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Ch.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=kh,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["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._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Oh extends Ph{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Bh extends Ih{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Ch.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=kh;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of s.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),a=()=>{t.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const r=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=r(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){a?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:r(!0)}),o=r(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,a=i.detail.remove;if(n[a].selected=!1,s.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(i){const{index:n,displayValue:a,exportValue:h}=i.detail.insert,c=s.children[n],d=document.createElement("option");d.textContent=a,d.value=h,c?c.before(d):s.append(d),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=r(!0),n=r(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(i){t.setValue(e,{value:r(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class zh extends Mh{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:Mh._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new jh({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${Lr}${t}`)).join(",")),this.container}}class jh{#sn=this.#nn.bind(this);#an=this.#rn.bind(this);#on=this.#ln.bind(this);#hn=this.#cn.bind(this);#dn=null;#mt=null;#un=null;#pn=null;#gn=null;#fn=null;#mn=null;#vn=!1;#bn=null;#C=null;#yn=null;#wn=null;#xn=null;#Ys=null;#An=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:a,richText:r,parent:o,rect:l,parentRect:h,open:c}){this.#mt=t,this.#xn=s,this.#un=a,this.#wn=r,this.#fn=o,this.#dn=e,this.#yn=l,this.#mn=h,this.#gn=i,this.#pn=Kr.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#hn),t.addEventListener("mouseenter",this.#on),t.addEventListener("mouseleave",this.#an),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#sn);this.#mt.hidden=!0,c&&this.#cn()}render(){if(this.#bn)return;const t=this.#bn=document.createElement("div");if(t.className="popup",this.#dn){const e=t.style.outlineColor=Pr.makeHexColor(...this.#dn);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#xn),t.append(e),this.#pn){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#pn.valueOf()})),e.append(t)}const s=this.#_n;if(s)Th.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#un);t.append(e)}this.#mt.append(t)}get#_n(){const t=this.#wn,e=this.#un;return!t?.str||e?.str&&e.str!==t.str?null:this.#wn.html||null}get#Sn(){return this.#_n?.attributes?.style?.fontSize||0}get#Tn(){return this.#_n?.attributes?.style?.color||null}#kn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#Tn,fontSize:this.#Sn?`calc(${this.#Sn}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#nn(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#vn)&&this.#cn()}updateEdited({rect:t,popupContent:e}){this.#Ys||={contentsObj:this.#un,richText:this.#wn},t&&(this.#C=null),e&&(this.#wn=this.#kn(e),this.#un=null),this.#bn?.remove(),this.#bn=null}resetEdited(){this.#Ys&&(({contentsObj:this.#un,richText:this.#wn}=this.#Ys),this.#Ys=null,this.#bn?.remove(),this.#bn=null,this.#C=null)}#Cn(){if(null!==this.#C)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#fn;let a=!!this.#mn,r=a?this.#mn:this.#yn;for(const t of this.#gn)if(!r||null!==Pr.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=Pr.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=a?r[2]-r[0]+5:0,h=o[0]+l,c=o[1];this.#C=[100*(h-s)/e,100*(c-n)/i];const{style:d}=this.#mt;d.left=`${this.#C[0]}%`,d.top=`${this.#C[1]}%`}#cn(){this.#vn=!this.#vn,this.#vn?(this.#ln(),this.#mt.addEventListener("click",this.#hn),this.#mt.addEventListener("keydown",this.#sn)):(this.#rn(),this.#mt.removeEventListener("click",this.#hn),this.#mt.removeEventListener("keydown",this.#sn))}#ln(){this.#bn||this.render(),this.isVisible?this.#vn&&this.#mt.classList.add("focused"):(this.#Cn(),this.#mt.hidden=!1,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)+1e3)}#rn(){this.#mt.classList.remove("focused"),!this.#vn&&this.isVisible&&(this.#mt.hidden=!0,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)-1e3)}forceHide(){this.#An=this.isVisible,this.#An&&(this.#mt.hidden=!0)}maybeShow(){this.#An&&(this.#bn||this.#ln(),this.#An=!1,this.#mt.hidden=!1)}get isVisible(){return!1===this.#mt.hidden}}class Vh extends Mh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Ha.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Hh extends Mh{#En=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#En=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#En}addHighlightArea(){this.container.classList.add("highlightArea")}}class $h extends Mh{#Mn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#Mn=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",i-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Mn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Uh extends Mh{#Pn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#Pn=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",i/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",i/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Pn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gh extends Mh{#Dn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:n,height:a}=this;if(!e)return this.container;const r=this.svgFactory.create(n,a,!0);let o=[];for(let i=0,s=e.length;i<s;i+=2){const s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");const l=this.#Dn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Dn}addHighlightArea(){this.container.classList.add("highlightArea")}}class qh extends Gh{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Wh extends Mh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Kh extends Mh{#In=null;#Rn=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Ha.HIGHLIGHT:Ha.INK}#Ln(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:a,width:r,height:o}=this.#Ln(e,t),l=this.svgFactory.create(r,o,!0),h=this.#In=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#Rn.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#In;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#Rn.length;t<e;t++)this.#Rn[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#Ln(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#Rn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Xh extends Mh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Ha.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Yh extends Mh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Qh extends Mh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Jh extends Mh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Zh extends Mh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Ha.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class tc extends Mh{#Fn=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Nn.bind(this)),this.#Fn=i;const{isMac:s}=Er.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Nn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Fn}addHighlightArea(){this.container.classList.add("highlightArea")}#Nn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ec{#On=null;#Bn=null;#zn=new Map;#jn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:a,structTreeLayer:r}){this.div=t,this.#On=e,this.#Bn=i,this.#jn=r||null,this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#zn.size>0}async#Vn(t,e){const i=t.firstChild||t,s=i.id=`${Lr}${e}`,n=await(this.#jn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#On?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;Jr(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Sh,annotationStorage:t.annotationStorage||new wo,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===Qa.POPUP;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;n.data=t;const i=Eh.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const a=i.render();t.hidden&&(a.style.visibility="hidden"),await this.#Vn(a,t.id),i._isEditable&&(this.#zn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#Hn()}async addLinkAnnotations(t,e){const i={data:null,layer:this.div,linkService:e,svgFactory:new Sh,parent:this};for(const e of t){e.borderStyle||=ec._defaultBorderStyle,i.data=e;const t=Eh.create(i);if(!t.isRenderable)continue;const s=t.render();await this.#Vn(s,e.id)}}update({viewport:t}){const e=this.div;this.viewport=t,Jr(e,{rotation:t.rotation}),this.#Hn(),e.hidden=!1}#Hn(){if(!this.#Bn)return;const t=this.div;for(const[e,i]of this.#Bn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i);const a=this.#zn.get(e);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),a._hasNoCanvas=!1):a.canvas=i)}this.#Bn.clear()}getEditableAnnotations(){return Array.from(this.#zn.values())}getEditableAnnotation(t){return this.#zn.get(t)}static get _defaultBorderStyle(){return br(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ja,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const ic=/\r\n?|\n/g;class sc extends po{#dn;#$n="";#Un=`${this.id}-editor`;#Gn=null;#Sn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=sc.prototype,e=t=>t.isEmpty(),i=ho.TRANSLATE_SMALL,s=ho.TRANSLATE_BIG;return br(this,"_keyboardManager",new oo([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=Ha.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#dn=t.color||sc._defaultColor||po._defaultLineColor,this.#Sn=t.fontSize||sc._defaultFontSize}static initialize(t,e){po.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case $a.FREETEXT_SIZE:sc._defaultFontSize=e;break;case $a.FREETEXT_COLOR:sc._defaultColor=e}}updateParams(t,e){switch(t){case $a.FREETEXT_SIZE:this.#qn(e);break;case $a.FREETEXT_COLOR:this.#Wn(e)}}static get defaultPropertiesToUpdate(){return[[$a.FREETEXT_SIZE,sc._defaultFontSize],[$a.FREETEXT_COLOR,sc._defaultColor||po._defaultLineColor]]}get propertiesToUpdate(){return[[$a.FREETEXT_SIZE,this.#Sn],[$a.FREETEXT_COLOR,this.#dn]]}#qn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#Sn)*this.parentScale),this.#Sn=t,this.#Kn()},i=this.#Sn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$a.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Wn(t){const e=t=>{this.#dn=this.editorDiv.style.color=t},i=this.#dn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$a.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-sc._internalPadding*t,-(sc._internalPadding+this.#Sn)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Gn=new AbortController;const t=this._uiManager.combinedSignal(this.#Gn);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Un),this._isDraggable=!0,this.#Gn?.abort(),this.#Gn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Xn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(sc.#Yn(i)),e=i);return t.join("\n")}#Kn(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#$n,e=this.#$n=this.#Xn().trimEnd();if(t===e)return;const i=t=>{this.#$n=t,t?(this.#Qn(),this._uiManager.rebuild(this),this.#Kn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#Kn()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){sc._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Un),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#Sn}px * var(--total-scale-factor))`,i.color=this.#dn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-h)/o,u=e+this.height-(n[1]-c)/l;break;case 90:d=t+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[r,-a];break;case 180:d=t-this.width+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[-a,-r];break;case 270:d=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-c-this.width*o)/l,[a,r]=[-r,a]}this.setAt(d*i,u*s,a,r)}else this._moveAfterPaste(t,e);this.#Qn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Yn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(ic,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=sc.#Jn(e.getData("text")||"").replaceAll(ic,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!s.includes("\n"))return a.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:r,startOffset:o}=a,l=[],h=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(h.push(r.nodeValue.slice(o).replaceAll(ic,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(sc.#Yn(i)):e=h}l.push(r.nodeValue.slice(0,o).replaceAll(ic,""))}else if(r===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(sc.#Yn(i))}this.#$n=`${l.join("\n")}${s}${h.join("\n")}`,this.#Qn();const c=new Range;let d=Math.sumPrecise(l.map((t=>t.length)));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(d<=e){c.setStart(t,d),c.setEnd(t,d);break}d-=e}n.removeAllRanges(),n.addRange(c)}#Qn(){if(this.editorDiv.replaceChildren(),this.#$n)for(const t of this.#$n.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Zn(){return this.#$n.replaceAll(" "," ")}static#Jn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof Vh){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:a,id:r,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:c}}}=t;if(!l||0===l.length)return null;s=t={annotationType:Ha.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:c-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#Sn=t.fontSize,n.#dn=Pr.makeHexColor(...t.color),n.#$n=sc.#Jn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=sc._internalPadding*this.parentScale,i=this.getRect(e,e),s=po._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#dn),n={annotationType:Ha.FREETEXT,color:s,fontSize:this.#Sn,value:this.#Zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(n.isCopy=!0,n):this.annotationElementId&&!this.#ta(n)?null:(n.id=this.annotationElementId,n)}#ta(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#Sn}px * var(--total-scale-factor))`,i.color=this.#dn,e.replaceChildren();for(const t of this.#$n.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=sc._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#$n}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class nc{static PRECISION=1e-4;toSVGPath(){gr("Abstract method `toSVGPath` must be implemented.")}get box(){gr("Abstract getter `box` must be implemented.")}serialize(t,e){gr("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*s,a[r+1]=i+t[r+1]*n;return a}static _rescaleAndSwap(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*s,a[r+1]=i+t[r]*n;return a}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,a=t.length;n<a;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,a){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+a)/6,(i+n)/2,(s+a)/2]}}class ac{#ea;#ia=[];#sa;#na;#aa=[];#ra=new Float32Array(18);#oa;#la;#ha;#ca;#da;#ua;#pa=[];static#ga=8;static#fa=2;static#ma=ac.#ga+ac.#fa;constructor({x:t,y:e},i,s,n,a,r=0){this.#ea=i,this.#ua=n*s,this.#na=a,this.#ra.set([NaN,NaN,NaN,NaN,t,e],6),this.#sa=r,this.#ca=ac.#ga*s,this.#ha=ac.#ma*s,this.#da=s,this.#pa.push(t,e)}isEmpty(){return isNaN(this.#ra[8])}#va(){const t=this.#ra.subarray(4,6),e=this.#ra.subarray(16,18),[i,s,n,a]=this.#ea;return[(this.#oa+(t[0]-e[0])/2-i)/n,(this.#la+(t[1]-e[1])/2-s)/a,(this.#oa+(e[0]-t[0])/2-i)/n,(this.#la+(e[1]-t[1])/2-s)/a]}add({x:t,y:e}){this.#oa=t,this.#la=e;const[i,s,n,a]=this.#ea;let[r,o,l,h]=this.#ra.subarray(8,12);const c=t-l,d=e-h,u=Math.hypot(c,d);if(u<this.#ha)return!1;const p=u-this.#ca,g=p/u,f=g*c,m=g*d;let v=r,b=o;r=l,o=h,l+=f,h+=m,this.#pa?.push(t,e);const y=f/p,w=-m/p*this.#ua,x=y*this.#ua;if(this.#ra.set(this.#ra.subarray(2,8),0),this.#ra.set([l+w,h+x],4),this.#ra.set(this.#ra.subarray(14,18),12),this.#ra.set([l-w,h-x],16),isNaN(this.#ra[6]))return 0===this.#aa.length&&(this.#ra.set([r+w,o+x],2),this.#aa.push(NaN,NaN,NaN,NaN,(r+w-i)/n,(o+x-s)/a),this.#ra.set([r-w,o-x],14),this.#ia.push(NaN,NaN,NaN,NaN,(r-w-i)/n,(o-x-s)/a)),this.#ra.set([v,b,r,o,l,h],6),!this.isEmpty();this.#ra.set([v,b,r,o,l,h],6);return Math.abs(Math.atan2(b-o,v-r)-Math.atan2(m,f))<Math.PI/2?([r,o,l,h]=this.#ra.subarray(2,6),this.#aa.push(NaN,NaN,NaN,NaN,((r+l)/2-i)/n,((o+h)/2-s)/a),[r,o,v,b]=this.#ra.subarray(14,18),this.#ia.push(NaN,NaN,NaN,NaN,((v+r)/2-i)/n,((b+o)/2-s)/a),!0):([v,b,r,o,l,h]=this.#ra.subarray(0,6),this.#aa.push(((v+5*r)/6-i)/n,((b+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),[l,h,r,o,v,b]=this.#ra.subarray(12,18),this.#ia.push(((v+5*r)/6-i)/n,((b+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#aa,e=this.#ia;if(isNaN(this.#ra[6])&&!this.isEmpty())return this.#ba();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#ya(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#wa(i),i.join(" ")}#ba(){const[t,e,i,s]=this.#ea,[n,a,r,o]=this.#va();return`M${(this.#ra[2]-t)/i} ${(this.#ra[3]-e)/s} L${(this.#ra[4]-t)/i} ${(this.#ra[5]-e)/s} L${n} ${a} L${r} ${o} L${(this.#ra[16]-t)/i} ${(this.#ra[17]-e)/s} L${(this.#ra[14]-t)/i} ${(this.#ra[15]-e)/s} Z`}#wa(t){const e=this.#ia;t.push(`L${e[4]} ${e[5]} Z`)}#ya(t){const[e,i,s,n]=this.#ea,a=this.#ra.subarray(4,6),r=this.#ra.subarray(16,18),[o,l,h,c]=this.#va();t.push(`L${(a[0]-e)/s} ${(a[1]-i)/n} L${o} ${l} L${h} ${c} L${(r[0]-e)/s} ${(r[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,a){return new rc(t,e,i,s,n,a)}getOutlines(){const t=this.#aa,e=this.#ia,i=this.#ra,[s,n,a,r]=this.#ea,o=new Float32Array((this.#pa?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#pa[t]-s)/a,o[t+1]=(this.#pa[t+1]-n)/r;if(o[o.length-2]=(this.#oa-s)/a,o[o.length-1]=(this.#la-n)/r,isNaN(i[6])&&!this.isEmpty())return this.#xa(o);const l=new Float32Array(this.#aa.length+24+this.#ia.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#Aa(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#_a(l,h),this.newFreeDrawOutline(l,o,this.#ea,this.#da,this.#sa,this.#na)}#xa(t){const e=this.#ra,[i,s,n,a]=this.#ea,[r,o,l,h]=this.#va(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/a,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/a,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/a,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/a],0),this.newFreeDrawOutline(c,t,this.#ea,this.#da,this.#sa,this.#na)}#_a(t,e){const i=this.#ia;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#Aa(t,e){const i=this.#ra.subarray(4,6),s=this.#ra.subarray(16,18),[n,a,r,o]=this.#ea,[l,h,c,d]=this.#va();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/r,(i[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(s[0]-n)/r,(s[1]-a)/o],e),e+24}}class rc extends nc{#ea;#Sa=new Float32Array(4);#sa;#na;#pa;#da;#Ta;constructor(t,e,i,s,n,a){super(),this.#Ta=t,this.#pa=e,this.#ea=i,this.#da=s,this.#sa=n,this.#na=a,this.lastPoint=[NaN,NaN],this.#ka(a);const[r,o,l,h]=this.#Sa;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-r)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-r)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#Ta[4]} ${this.#Ta[5]}`];for(let e=6,i=this.#Ta.length;e<i;e+=6)isNaN(this.#Ta[e])?t.push(`L${this.#Ta[e+4]} ${this.#Ta[e+5]}`):t.push(`C${this.#Ta[e]} ${this.#Ta[e+1]} ${this.#Ta[e+2]} ${this.#Ta[e+3]} ${this.#Ta[e+4]} ${this.#Ta[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const a=i-t,r=s-e;let o,l;switch(n){case 0:o=nc._rescale(this.#Ta,t,s,a,-r),l=nc._rescale(this.#pa,t,s,a,-r);break;case 90:o=nc._rescaleAndSwap(this.#Ta,t,e,a,r),l=nc._rescaleAndSwap(this.#pa,t,e,a,r);break;case 180:o=nc._rescale(this.#Ta,i,e,-a,r),l=nc._rescale(this.#pa,i,e,-a,r);break;case 270:o=nc._rescaleAndSwap(this.#Ta,i,s,-a,-r),l=nc._rescaleAndSwap(this.#pa,i,s,-a,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}#ka(t){const e=this.#Ta;let i=e[4],s=e[5];const n=[i,s,i,s];let a=i,r=s;const o=t?Math.max:Math.min;for(let t=6,l=e.length;t<l;t+=6){const l=e[t+4],h=e[t+5];if(isNaN(e[t]))Pr.pointBoundingBox(l,h,n),r<h?(a=l,r=h):r===h&&(a=o(a,l));else{const l=[1/0,1/0,-1/0,-1/0];Pr.bezierBoundingBox(i,s,...e.slice(t,t+6),l),Pr.rectBoundingBox(...l,n),r<l[3]?(a=l[2],r=l[3]):r===l[3]&&(a=o(a,l[2]))}i=l,s=h}const l=this.#Sa;l[0]=n[0]-this.#sa,l[1]=n[1]-this.#sa,l[2]=n[2]-n[0]+2*this.#sa,l[3]=n[3]-n[1]+2*this.#sa,this.lastPoint=[a,r]}get box(){return this.#Sa}newOutliner(t,e,i,s,n,a=0){return new ac(t,e,i,s,n,a)}getNewOutline(t,e){const[i,s,n,a]=this.#Sa,[r,o,l,h]=this.#ea,c=n*l,d=a*h,u=i*l+r,p=s*h+o,g=this.newOutliner({x:this.#pa[0]*c+u,y:this.#pa[1]*d+p},this.#ea,this.#da,t,this.#na,e??this.#sa);for(let t=2;t<this.#pa.length;t+=2)g.add({x:this.#pa[t]*c+u,y:this.#pa[t+1]*d+p});return g.getOutlines()}}class oc{#ea;#Ca;#Ea=[];#Ma=[];constructor(t,e=0,i=0,s=!0){const n=[1/0,1/0,-1/0,-1/0],a=1e-4;for(const{x:i,y:s,width:r,height:o}of t){const t=Math.floor((i-e)/a)*a,l=Math.ceil((i+r+e)/a)*a,h=Math.floor((s-e)/a)*a,c=Math.ceil((s+o+e)/a)*a,d=[t,h,c,!0],u=[l,h,c,!1];this.#Ea.push(d,u),Pr.rectBoundingBox(t,h,l,c,n)}const r=n[2]-n[0]+2*i,o=n[3]-n[1]+2*i,l=n[0]-i,h=n[1]-i,c=this.#Ea.at(s?-1:-2),d=[c[0],c[2]];for(const t of this.#Ea){const[e,i,s]=t;t[0]=(e-l)/r,t[1]=(i-h)/o,t[2]=(s-h)/o}this.#ea=new Float32Array([l,h,r,o]),this.#Ca=d}getOutlines(){this.#Ea.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Ea)e[3]?(t.push(...this.#Pa(e)),this.#Da(e)):(this.#Ia(e),t.push(...this.#Pa(e)));return this.#Ra(t)}#Ra(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,a,r,o,l]=t;i.delete(t);let h=e,c=a;for(n=[e,r],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,a,r,o,l]=t,h!==e&&(n.push(h,c,e,c===a?a:r),h=e),c=c===a?r:a}n.push(h,c)}return new lc(s,this.#ea,this.#Ca)}#La(t){const e=this.#Ma;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,a=e[n][0];if(a===t)return n;a<t?i=n+1:s=n-1}return s+1}#Da([,t,e]){const i=this.#La(t);this.#Ma.splice(i,0,[t,e])}#Ia([,t,e]){const i=this.#La(t);for(let s=i;s<this.#Ma.length;s++){const[i,n]=this.#Ma[s];if(i!==t)break;if(i===t&&n===e)return void this.#Ma.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#Ma[s];if(i!==t)break;if(i===t&&n===e)return void this.#Ma.splice(s,1)}}#Pa(t){const[e,i,s]=t,n=[[e,i,s]],a=this.#La(s);for(let t=0;t<a;t++){const[i,s]=this.#Ma[t];for(let t=0,a=n.length;t<a;t++){const[,r,o]=n[t];if(!(s<=r||o<=i))if(r>=i)if(o>s)n[t][1]=s;else{if(1===a)return[];n.splice(t,1),t--,a--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class lc extends nc{#ea;#Fa;constructor(t,e,i){super(),this.#Fa=t,this.#ea=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Fa){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===i?(t.push(`V${r}`),s=r):r===s&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const a=[],r=i-t,o=s-e;for(const e of this.#Fa){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*r,i[n+1]=s-e[n+1]*o;a.push(i)}return a}get box(){return this.#ea}get classNamesForOutlining(){return["highlightOutline"]}}class hc extends ac{newFreeDrawOutline(t,e,i,s,n,a){return new cc(t,e,i,s,n,a)}}class cc extends rc{newOutliner(t,e,i,s,n,a=0){return new hc(t,e,i,s,n,a)}}class dc{#Na=null;#Oa=null;#Ba;#za=null;#ja=!1;#Va=!1;#a=null;#Ha;#$a=null;#m=null;#Ua;static#Ga=null;static get _keyboardManager(){return br(this,"_keyboardManager",new oo([[["Escape","mac+Escape"],dc.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],dc.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],dc.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],dc.prototype._moveToPrevious],[["Home","mac+Home"],dc.prototype._moveToBeginning],[["End","mac+End"],dc.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#Va=!1,this.#Ua=$a.HIGHLIGHT_COLOR,this.#a=t):(this.#Va=!0,this.#Ua=$a.HIGHLIGHT_DEFAULT_COLOR),this.#m=t?._uiManager||e,this.#Ha=this.#m._eventBus,this.#Ba=t?.color||this.#m?.highlightColors.values().next().value||"#FFFF98",dc.#Ga||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#Na=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#m._signal;t.addEventListener("click",this.#qa.bind(this),{signal:e}),t.addEventListener("keydown",this.#nn.bind(this),{signal:e});const i=this.#Oa=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Ba,t.append(i),t}renderMainDropdown(){const t=this.#za=this.#Wa();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Wa(){const t=document.createElement("div"),e=this.#m._signal;t.addEventListener("contextmenu",qr,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,s]of this.#m.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",dc.#Ga[i]);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#Ba),n.addEventListener("click",this.#Ka.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#nn.bind(this),{signal:e}),t}#Ka(t,e){e.stopPropagation(),this.#Ha.dispatch("switchannotationeditorparams",{source:this,type:this.#Ua,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Na)return void this.#qa(t);const e=t.target.getAttribute("data-color");e&&this.#Ka(e,t)}_moveToNext(t){this.#Xa?t.target!==this.#Na?t.target.nextSibling?.focus():this.#za.firstChild?.focus():this.#qa(t)}_moveToPrevious(t){t.target!==this.#za?.firstChild&&t.target!==this.#Na?(this.#Xa||this.#qa(t),t.target.previousSibling?.focus()):this.#Xa&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Xa?this.#za.firstChild?.focus():this.#qa(t)}_moveToEnd(t){this.#Xa?this.#za.lastChild?.focus():this.#qa(t)}#nn(t){dc._keyboardManager.exec(this,t)}#qa(t){if(this.#Xa)return void this.hideDropdown();if(this.#ja=0===t.detail,this.#$a||(this.#$a=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#m.combinedSignal(this.#$a)})),this.#za)return void this.#za.classList.remove("hidden");const e=this.#za=this.#Wa();this.#Na.append(e)}#c(t){this.#za?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#za?.classList.add("hidden"),this.#$a?.abort(),this.#$a=null}get#Xa(){return this.#za&&!this.#za.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Va||(this.#Xa?(this.hideDropdown(),this.#Na.focus({preventScroll:!0,focusVisible:this.#ja})):this.#a?.unselect())}updateColor(t){if(this.#Oa&&(this.#Oa.style.backgroundColor=t),!this.#za)return;const e=this.#m.highlightColors.values();for(const i of this.#za.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Na?.remove(),this.#Na=null,this.#Oa=null,this.#za?.remove(),this.#za=null}}class uc extends po{#Ya=null;#Qa=0;#Ja;#Za=null;#n=null;#tr=null;#er=null;#ir=0;#sr=null;#nr=null;#w=null;#ar=!1;#Ca=null;#rr;#or=null;#lr="";#ua;#hr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Ha.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=uc.prototype;return br(this,"_keyboardManager",new oo([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||uc._defaultColor,this.#ua=t.thickness||uc._defaultThickness,this.#rr=t.opacity||uc._defaultOpacity,this.#Ja=t.boxes||null,this.#hr=t.methodOfCreation||"",this.#lr=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#ar=!0,this.#cr(t),this.#dr()):this.#Ja&&(this.#Ya=t.anchorNode,this.#Qa=t.anchorOffset,this.#er=t.focusNode,this.#ir=t.focusOffset,this.#ur(),this.#dr(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#ar?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#ua,methodOfCreation:this.#hr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ur(){const t=new oc(this.#Ja,.001);this.#nr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#nr.box;const e=new oc(this.#Ja,.0025,.001,"ltr"===this._uiManager.direction);this.#tr=e.getOutlines();const{lastPoint:i}=this.#tr;this.#Ca=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#cr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#nr=t;if(this.#tr=t.getNewOutline(this.#ua/2+1.5,.0025),e>=0)this.#w=e,this.#Za=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#or=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#tr.box,path:{d:this.#tr.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:uc.#pr(this.#nr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#or,{bbox:uc.#pr(this.#tr.box,e),path:{d:this.#tr.toSVGPath()}})}const[s,n,a,r]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=a,this.height=r;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=a*e/t,this.height=r*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=a,this.height=r;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=a*e/t,this.height=r*t/e;break}}const{lastPoint:o}=this.#tr;this.#Ca=[(o[0]-s)/a,(o[1]-n)/r]}static initialize(t,e){po.initialize(t,e),uc._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case $a.HIGHLIGHT_DEFAULT_COLOR:uc._defaultColor=e;break;case $a.HIGHLIGHT_THICKNESS:uc._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Ca}updateParams(t,e){switch(t){case $a.HIGHLIGHT_COLOR:this.#Wn(e);break;case $a.HIGHLIGHT_THICKNESS:this.#gr(e)}}static get defaultPropertiesToUpdate(){return[[$a.HIGHLIGHT_DEFAULT_COLOR,uc._defaultColor],[$a.HIGHLIGHT_THICKNESS,uc._defaultThickness]]}get propertiesToUpdate(){return[[$a.HIGHLIGHT_COLOR,this.color||uc._defaultColor],[$a.HIGHLIGHT_THICKNESS,this.#ua||uc._defaultThickness],[$a.HIGHLIGHT_FREE,this.#ar]]}#Wn(t){const e=(t,e)=>{this.color=t,this.#rr=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#rr;this.addCommands({cmd:e.bind(this,t,uc._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$a.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#gr(t){const e=this.#ua,i=t=>{this.#ua=t,this.#fr(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$a.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new dc({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#mr())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#mr())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#vr(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#dr(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#vr():t&&(this.#dr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#fr(t){if(!this.#ar)return;this.#cr({highlightOutlines:this.#nr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#vr(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#or),this.#or=null)}#dr(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#Za}=t.drawLayer.draw({bbox:this.#nr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#rr},rootClass:{highlight:!0,free:this.#ar},path:{d:this.#nr.toSVGPath()}},!1,!0)),this.#or=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#ar},bbox:this.#tr.box,path:{d:this.#tr.toSVGPath()}},this.#ar),this.#sr&&(this.#sr.style.clipPath=this.#Za))}static#pr([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#ar?(t=(t-this.rotation+360)%360,i=uc.#pr(this.#nr.box,t)):i=uc.#pr([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#or,{bbox:uc.#pr(this.#tr.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#lr&&(t.setAttribute("aria-label",this.#lr),t.setAttribute("role","mark")),this.#ar?t.classList.add("free"):this.div.addEventListener("keydown",this.#br.bind(this),{signal:this._uiManager._signal});const e=this.#sr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Za;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),so(this,this.#sr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{hovered:!1}})}#br(t){uc._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#yr(!0);break;case 1:case 3:this.#yr(!1)}}#yr(t){if(!this.#Ya)return;const e=window.getSelection();t?e.setPosition(this.#Ya,this.#Qa):e.setPosition(this.#er,this.#ir)}select(){super.select(),this.#or&&this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#or&&(this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{selected:!1}}),this.#ar||this.#yr(!1))}get _mustFixPosition(){return!this.#ar}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#or,{rootClass:{hidden:!t}}))}#mr(){return this.#ar?this.rotation:0}#wr(){if(this.#ar)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Ja,a=new Float32Array(8*n.length);let r=0;for(const{x:o,y:l,width:h,height:c}of n){const n=o*t+i,d=(1-l)*e+s;a[r]=a[r+4]=n,a[r+1]=a[r+3]=d,a[r+2]=a[r+6]=n+h*t,a[r+5]=a[r+7]=d-c*e,r+=8}return a}#xr(t){return this.#nr.serialize(t,this.#mr())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:a,y:r,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=e=>{h.abort(),this.#Ar(t,e)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Wr,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",qr,{signal:c}),i.addEventListener("pointermove",this.#_r.bind(this,t),{signal:c}),this._freeHighlight=new hc({x:s,y:n},[a,r,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#_r(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#Ar(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof Xh){const{data:{quadPoints:e,rect:i,rotation:n,id:a,color:r,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:Ha.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}else if(t instanceof Kh){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:Ha.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}const{color:n,quadPoints:a,inkLists:r,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=Pr.makeHexColor(...n),l.#rr=o||1,r&&(l.#ua=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,c]=l.pageDimensions,[d,u]=l.pageTranslation;if(a){const t=l.#Ja=[];for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-d)/h,y:1-(a[e+1]-u)/c,width:(a[e+2]-a[e])/h,height:(a[e+1]-a[e+5])/c});l.#ur(),l.#dr(),l.rotate(l.rotation)}else if(r){l.#ar=!0;const t=r[0],i={x:t[0]-d,y:c-(t[1]-u)},s=new hc(i,[0,0,h,c],1,l.#ua/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-d,i.y=c-(t[e+1]-u),s.add(i);const{id:n,clipPathId:a}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#cr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:a}),l.#dr(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=po._colorManager.convert(this.color),s={annotationType:Ha.HIGHLIGHT,color:i,opacity:this.#rr,thickness:this.#ua,quadPoints:this.#wr(),outlines:this.#xr(e),pageIndex:this.pageIndex,rect:e,rotation:this.#mr(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#ta(s)?null:(s.id=this.annotationElementId,s)}#ta(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class pc{#Sr=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#Sr[t]=e}toSVGProperties(){const t=this.#Sr;return this.#Sr=Object.create(null),{root:t}}reset(){this.#Sr=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){gr("Not implemented")}}class gc extends po{#Tr=null;#kr;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#Cr=null;static#Er=null;static#Mr=null;static#Pr=NaN;static#Dr=null;static#Ir=null;static#Rr=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#kr=t.mustBeCommitted||!1,this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(this.#Lr(t),this.#dr())}#Lr({drawOutlines:t,drawId:e,drawingOptions:i}){this.#Tr=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Fr(t,this.parent),this.#Nr(t.box)}#Fr(t,e){const{id:i}=e.drawLayer.draw(gc._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){gr("Not implemented")}static get typesMap(){gr("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(gc.#Cr.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],a=t=>{s.updateProperty(e,t);const i=this.#Tr.updateProperty(e,t);i&&this.#Nr(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,gc._mergeSVGProperties(this.#Tr.getPathResizingSVGProperties(this.#Or()),{bbox:this.#Br()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,gc._mergeSVGProperties(this.#Tr.getPathResizedSVGProperties(this.#Or()),{bbox:this.#Br()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Br()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,gc._mergeSVGProperties(this.#Tr.getPathTranslatedSVGProperties(this.#Or(),this.parentDimensions),{bbox:this.#Br()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#kr&&(this.#kr=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#vr(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#dr(),this.#Nr(this.#Tr.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#vr()):t&&(this._uiManager.addShouldRescale(this),this.#dr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#vr(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#dr(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Fr(this.#Tr,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#zr([t,e,i,s]){const{parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[e,1-t,i*(a/n),s*(n/a)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(a/n),s*(n/a)];default:return[t,e,i,s]}}#Or(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[1-e,t,i*(n/a),s*(a/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/a),s*(a/n)];default:return[t,e,i,s]}}#Nr(t){if([this.x,this.y,this.width,this.height]=this.#zr(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Br(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:a,parentDimensions:[r,o]}=this;switch((4*n+a)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(r/o),s*(o/r),i*(r/o)];case 5:return[1-e,t,i*(r/o),s*(o/r)];case 6:return[1-t-s*(o/r),1-e,s*(o/r),i*(r/o)];case 7:return[e-i*(r/o),1-t-s*(o/r),i*(r/o),s*(o/r)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/r),e,s*(o/r),i*(r/o)];case 13:return[1-e-i*(r/o),t-s*(o/r),i*(r/o),s*(o/r)];case 14:return[1-t,1-e-i*(r/o),s*(o/r),i*(r/o)];case 15:return[e,1-t,i*(r/o),s*(o/r)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,gc._mergeSVGProperties({bbox:this.#Br()},this.#Tr.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Nr(this.#Tr.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const s=document.createElement("div");i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){gr("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:a,offsetY:r,pointerId:o,pointerType:l}=s;if(gc.#Dr&&gc.#Dr!==l)return;const{viewport:{rotation:h}}=t,{width:c,height:d}=n.getBoundingClientRect(),u=gc.#Er=new AbortController,p=t.combinedSignal(u);gc.#Pr||=o,gc.#Dr??=l,window.addEventListener("pointerup",(t=>{gc.#Pr===t.pointerId?this._endDraw(t):gc.#Ir?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{gc.#Pr===t.pointerId?this._currentParent.endDrawingSession():gc.#Ir?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{gc.#Dr===t.pointerType&&((gc.#Ir||=new Set).add(t.pointerId),gc.#Cr.isCancellable()&&(gc.#Cr.removeLastElement(),gc.#Cr.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",qr,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===gc.#Rr&&Wr(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),gc.#Cr?t.drawLayer.updateProperties(this._currentDrawId,gc.#Cr.startNew(a,r,c,d,h)):(e.updateUIForDefaultProperties(this),gc.#Cr=this.createDrawerInstance(a,r,c,d,h),gc.#Mr=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(gc.#Mr.toSVGProperties(),gc.#Cr.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(gc.#Rr=-1,!gc.#Cr)return;const{offsetX:e,offsetY:i,pointerId:s}=t;gc.#Pr===s&&(gc.#Ir?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,gc.#Cr.add(e,i)),gc.#Rr=t.timeStamp,Wr(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,gc.#Cr=null,gc.#Mr=null,gc.#Dr=null,gc.#Rr=NaN),gc.#Er&&(gc.#Er.abort(),gc.#Er=null,gc.#Pr=NaN,gc.#Ir=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,gc.#Cr.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=gc.#Cr,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:$a.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack($a.DRAW_STEP),!gc.#Cr.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:gc.#Cr.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:gc.#Mr,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,a){gr("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:a,pageY:r}}=e.viewport,o=this.deserializeDraw(a,r,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#Lr({drawOutlines:o}),l.#dr(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#Tr.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class fc{#ra=new Float64Array(6);#En;#jr;#as;#ua;#pa;#Vr="";#Hr=0;#Fa=new mc;#$r;#Ur;constructor(t,e,i,s,n,a){this.#$r=i,this.#Ur=s,this.#as=n,this.#ua=a,[t,e]=this.#Gr(t,e);const r=this.#En=[NaN,NaN,NaN,NaN,t,e];this.#pa=[t,e],this.#jr=[{line:r,points:this.#pa}],this.#ra.set(r,0)}updateProperty(t,e){"stroke-width"===t&&(this.#ua=e)}#Gr(t,e){return nc._normalizePoint(t,e,this.#$r,this.#Ur,this.#as)}isEmpty(){return!this.#jr||0===this.#jr.length}isCancellable(){return this.#pa.length<=10}add(t,e){[t,e]=this.#Gr(t,e);const[i,s,n,a]=this.#ra.subarray(2,6),r=t-n,o=e-a;return Math.hypot(this.#$r*r,this.#Ur*o)<=2?null:(this.#pa.push(t,e),isNaN(i)?(this.#ra.set([n,a,t,e],2),this.#En.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#ra[0])&&this.#En.splice(6,6),this.#ra.set([i,s,n,a,t,e],0),this.#En.push(...nc.createBezierPoints(i,s,n,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#pa.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#$r=i,this.#Ur=s,this.#as=n,[t,e]=this.#Gr(t,e);const a=this.#En=[NaN,NaN,NaN,NaN,t,e];this.#pa=[t,e];const r=this.#jr.at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),this.#jr.push({line:a,points:this.#pa}),this.#ra.set(a,0),this.#Hr=0,this.toSVGPath(),null}getLastElement(){return this.#jr.at(-1)}setLastElement(t){return this.#jr?(this.#jr.push(t),this.#En=t.line,this.#pa=t.points,this.#Hr=0,{path:{d:this.toSVGPath()}}):this.#Fa.setLastElement(t)}removeLastElement(){if(!this.#jr)return this.#Fa.removeLastElement();this.#jr.pop(),this.#Vr="";for(let t=0,e=this.#jr.length;t<e;t++){const{line:e,points:i}=this.#jr[t];this.#En=e,this.#pa=i,this.#Hr=0,this.toSVGPath()}return{path:{d:this.#Vr}}}toSVGPath(){const t=nc.svgRound(this.#En[4]),e=nc.svgRound(this.#En[5]);if(2===this.#pa.length)return this.#Vr=`${this.#Vr} M ${t} ${e} Z`,this.#Vr;if(this.#pa.length<=6){const i=this.#Vr.lastIndexOf("M");this.#Vr=`${this.#Vr.slice(0,i)} M ${t} ${e}`,this.#Hr=6}if(4===this.#pa.length){const t=nc.svgRound(this.#En[10]),e=nc.svgRound(this.#En[11]);return this.#Vr=`${this.#Vr} L ${t} ${e}`,this.#Hr=12,this.#Vr}const i=[];0===this.#Hr&&(i.push(`M ${t} ${e}`),this.#Hr=6);for(let t=this.#Hr,e=this.#En.length;t<e;t+=6){const[e,s,n,a,r,o]=this.#En.slice(t,t+6).map(nc.svgRound);i.push(`C${e} ${s} ${n} ${a} ${r} ${o}`)}return this.#Vr+=i.join(" "),this.#Hr=this.#En.length,this.#Vr}getOutlines(t,e,i,s){const n=this.#jr.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Fa.build(this.#jr,t,e,i,this.#as,this.#ua,s),this.#ra=null,this.#En=null,this.#jr=null,this.#Vr=null,this.#Fa}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class mc extends nc{#Sa;#qr=0;#sa;#jr;#$r;#Ur;#Wr;#as;#ua;build(t,e,i,s,n,a,r){this.#$r=e,this.#Ur=i,this.#Wr=s,this.#as=n,this.#ua=a,this.#sa=r??0,this.#jr=t,this.#Kr()}get thickness(){return this.#ua}setLastElement(t){return this.#jr.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#jr.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#jr)if(t.push(`M${nc.svgRound(e[4])} ${nc.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${nc.svgRound(e[10])} ${nc.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){const[s,n,a,r,o,l]=e.subarray(i,i+6).map(nc.svgRound);t.push(`C${s} ${n} ${a} ${r} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const a=[],r=[],[o,l,h,c]=this.#Xr();let d,u,p,g,f,m,v,b,y;switch(this.#as){case 0:y=nc._rescale,d=t,u=e+s,p=i,g=-s,f=t+o*i,m=e+(1-l-c)*s,v=t+(o+h)*i,b=e+(1-l)*s;break;case 90:y=nc._rescaleAndSwap,d=t,u=e,p=i,g=s,f=t+l*i,m=e+o*s,v=t+(l+c)*i,b=e+(o+h)*s;break;case 180:y=nc._rescale,d=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,m=e+l*s,v=t+(1-o)*i,b=e+(l+c)*s;break;case 270:y=nc._rescaleAndSwap,d=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-c)*i,m=e+(1-o-h)*s,v=t+(1-l)*i,b=e+(1-o)*s}for(const{line:t,points:e}of this.#jr)a.push(y(t,d,u,p,g,n?new Array(t.length):null)),r.push(y(e,d,u,p,g,n?new Array(e.length):null));return{lines:a,points:r,rect:[f,m,v,b]}}static deserialize(t,e,i,s,n,{paths:{lines:a,points:r},rotation:o,thickness:l}){const h=[];let c,d,u,p,g;switch(o){case 0:g=nc._rescale,c=-t/i,d=e/s+1,u=1/i,p=-1/s;break;case 90:g=nc._rescaleAndSwap,c=-e/s,d=-t/i,u=1/s,p=1/i;break;case 180:g=nc._rescale,c=t/i+1,d=-e/s,u=-1/i,p=1/s;break;case 270:g=nc._rescaleAndSwap,c=e/s+1,d=t/i+1,u=-1/s,p=-1/i}if(!a){a=[];for(const t of r){const e=t.length;if(2===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));a.push(i);let[s,n,r,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let a=4;a<e;a+=2){const e=t[a],l=t[a+1];i.set(nc.createBezierPoints(s,n,r,o,e,l),3*(a-2)),[s,n,r,o]=[r,o,e,l]}}}for(let t=0,e=a.length;t<e;t++)h.push({line:g(a[t].map((t=>t??NaN)),c,d,u,p),points:g(r[t].map((t=>t??NaN)),c,d,u,p)});const f=new this.prototype.constructor;return f.build(h,i,s,1,o,l,n),f}#Yr(t=this.#ua){const e=this.#sa+t/2*this.#Wr;return this.#as%180==0?[e/this.#$r,e/this.#Ur]:[e/this.#Ur,e/this.#$r]}#Xr(){const[t,e,i,s]=this.#Sa,[n,a]=this.#Yr(0);return[t+n,e+a,i-2*n,s-2*a]}#Kr(){const t=this.#Sa=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#jr){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)Pr.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let n=6,a=e.length;n<a;n+=6){const[a,r,o,l,h,c]=e.subarray(n,n+6);Pr.bezierBoundingBox(i,s,a,r,o,l,h,c,t),i=h,s=c}}const[e,i]=this.#Yr();t[0]=Fr(t[0]-e,0,1),t[1]=Fr(t[1]-i,0,1),t[2]=Fr(t[2]+e,0,1),t[3]=Fr(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#Sa}updateProperty(t,e){return"stroke-width"===t?this.#gr(e):null}#gr(t){const[e,i]=this.#Yr();this.#ua=t;const[s,n]=this.#Yr(),[a,r]=[s-e,n-i],o=this.#Sa;return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o}updateParentDimensions([t,e],i){const[s,n]=this.#Yr();this.#$r=t,this.#Ur=e,this.#Wr=i;const[a,r]=this.#Yr(),o=a-s,l=r-n,h=this.#Sa;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#qr=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#Sa.map(nc.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Sa;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${nc.svgRound(t)} ${nc.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#Sa;let i=0,s=0,n=0,a=0,r=0,o=0;switch(this.#qr){case 90:s=e/t,n=-t/e,r=t;break;case 180:i=-1,a=-1,r=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${a} ${nc.svgRound(r)} ${nc.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,a]=this.#Yr(),[r,o,l,h]=this.#Sa;if(Math.abs(l-n)<=nc.PRECISION||Math.abs(h-a)<=nc.PRECISION){const n=t+i/2-(r+l/2),a=e+s/2-(o+h/2);return{path:{"transform-origin":`${nc.svgRound(t)} ${nc.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${a})`}}}const c=(i-2*n)/(l-2*n),d=(s-2*a)/(h-2*a),u=l/i,p=h/s;return{path:{"transform-origin":`${nc.svgRound(r)} ${nc.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${nc.svgRound(n)} ${nc.svgRound(a)}) scale(${c} ${d}) translate(${nc.svgRound(-n)} ${nc.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,a]=this.#Yr(),r=this.#Sa,[o,l,h,c]=r;if(r[0]=t,r[1]=e,r[2]=i,r[3]=s,Math.abs(h-n)<=nc.PRECISION||Math.abs(c-a)<=nc.PRECISION){const n=t+i/2-(o+h/2),a=e+s/2-(l+c/2);for(const{line:t,points:e}of this.#jr)nc._translate(t,n,a,t),nc._translate(e,n,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${nc.svgRound(t)} ${nc.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(i-2*n)/(h-2*n),u=(s-2*a)/(c-2*a),p=-d*(o+n)+t+n,g=-u*(l+a)+e+a;if(1!==d||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#jr)nc._rescale(t,p,g,d,u,t),nc._rescale(e,p,g,d,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${nc.svgRound(t)} ${nc.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,a=this.#Sa,r=t-a[0],o=e-a[1];if(this.#$r===s&&this.#Ur===n)for(const{line:t,points:e}of this.#jr)nc._translate(t,r,o,t),nc._translate(e,r,o,e);else{const t=this.#$r/s,e=this.#Ur/n;this.#$r=s,this.#Ur=n;for(const{line:i,points:s}of this.#jr)nc._rescale(i,r,o,t,e,i),nc._rescale(s,r,o,t,e,s);a[2]*=t,a[3]*=e}return a[0]=t,a[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${nc.svgRound(t)} ${nc.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Sa;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${nc.svgRound(t[0])} ${nc.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class vc extends pc{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:po._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new vc(this._viewParameters);return t.updateAll(this),t}}class bc extends gc{static _type="ink";static _editorType=Ha.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){po.initialize(t,e),this._defaultDrawingOptions=new vc(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return br(this,"typesMap",new Map([[$a.INK_THICKNESS,"stroke-width"],[$a.INK_COLOR,"stroke"],[$a.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new fc(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,a){return mc.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){let s=null;if(t instanceof Kh){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:c}}}=t;s=t={annotationType:Ha.INK,color:Array.from(r),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:c-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=bc.getDefaultDrawingOptions({stroke:Pr.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":a,"stroke-width":r}}=this,o={annotationType:Ha.INK,color:po._colorManager.convert(n),opacity:a,thickness:r,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(o.isCopy=!0,o):this.annotationElementId&&!this.#ta(o)?null:(o.id=this.annotationElementId,o)}#ta(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class yc extends mc{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class wc{static#Qr={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Jr(t,e,i,s){return s-=e,0===(i-=t)?s>0?0:4:1===i?s+6:2-s}static#Zr=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#to(t,e,i,s,n,a,r){const o=this.#Jr(i,s,n,a);for(let n=0;n<8;n++){const a=(-n+o-r+16)%8;if(0!==t[(i+this.#Zr[2*a])*e+(s+this.#Zr[2*a+1])])return a}return-1}static#eo(t,e,i,s,n,a,r){const o=this.#Jr(i,s,n,a);for(let n=0;n<8;n++){const a=(n+o+r+16)%8;if(0!==t[(i+this.#Zr[2*a])*e+(s+this.#Zr[2*a+1])])return a}return-1}static#io(t,e,i,s){const n=t.length,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=t[e]<=s?1:0;for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let r,o=1;const l=[];for(let t=1;t<i-1;t++){r=1;for(let i=1;i<e-1;i++){const s=t*e+i,n=a[s];if(0===n)continue;let h=t,c=i;if(1===n&&0===a[s-1])o+=1,c-=1;else{if(!(n>=1&&0===a[s+1])){1!==n&&(r=Math.abs(n));continue}o+=1,c+=1,n>1&&(r=n)}const d=[i,t],u=c===i+1,p={isHole:u,points:d,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===r){g=t;break}g?g.isHole?p.parent=u?g.parent:r:p.parent=u?r:g.parent:p.parent=u?r:0;const f=this.#to(a,e,t,i,h,c,0);if(-1===f){a[s]=-o,1!==a[s]&&(r=Math.abs(a[s]));continue}let m=this.#Zr[2*f],v=this.#Zr[2*f+1];const b=t+m,y=i+v;h=b,c=y;let w=t,x=i;for(;;){const n=this.#eo(a,e,w,x,h,c,1);m=this.#Zr[2*n],v=this.#Zr[2*n+1];const l=w+m,u=x+v;d.push(u,l);const p=w*e+x;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&u===i&&w===b&&x===y){1!==a[s]&&(r=Math.abs(a[s]));break}h=w,c=x,w=l,x=u}}}return l}static#so(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[e],a=t[e+1],r=t[i-4]-n,o=t[i-3]-a,l=Math.hypot(r,o),h=r/l,c=o/l,d=h*a-c*n,u=o/r,p=1/l,g=Math.atan(u),f=Math.cos(g),m=Math.sin(g),v=p*(Math.abs(f)+Math.abs(m)),b=p*(1-v+v**2),y=Math.max(Math.atan(Math.abs(m+f)*b),Math.atan(Math.abs(m-f)*b));let w=0,x=e;for(let s=e+2;s<i-2;s+=2){const e=Math.abs(d-h*t[s+1]+c*t[s]);e>w&&(x=s,w=e)}w>(l*y)**2?(this.#so(t,e,x+2,s),this.#so(t,x,i,s)):s.push(n,a)}static#no(t){const e=[],i=t.length;return this.#so(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#ao(t,e,i,s,n,a){const r=new Float32Array(a**2),o=-2*s**2,l=a>>1;for(let t=0;t<a;t++){const e=(t-l)**2;for(let i=0;i<a;i++)r[t*a+i]=Math.exp((e+(i-l)**2)/o)}const h=new Float32Array(256),c=-2*n**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/c);const d=t.length,u=new Uint8Array(d),p=new Uint32Array(256);for(let s=0;s<i;s++)for(let n=0;n<e;n++){const o=s*e+n,c=t[o];let d=0,g=0;for(let o=0;o<a;o++){const u=s+o-l;if(!(u<0||u>=i))for(let i=0;i<a;i++){const s=n+i-l;if(s<0||s>=e)continue;const p=t[u*e+s],f=r[o*a+i]*h[Math.abs(p-c)];d+=p*f,g+=f}}p[u[o]=Math.round(d/g)]++}return[u,p]}static#ro(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#oo(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let e=0,a=i.length;e<a;e++){if(0===t[3+(e<<2)]){s=i[e]=255;continue}const a=i[e]=t[e<<2];a>s&&(s=a),a<n&&(n=a)}const a=255/(s-n);for(let t=0;t<e;t++)i[t]=(i[t]-n)*a;return i}static#lo(t){let e,i=-1/0,s=-1/0;const n=t.findIndex((t=>0!==t));let a=n,r=n;for(e=n;e<256;e++){const n=t[e];n>i&&(e-a>s&&(s=e-a,r=e-1),i=n,a=e)}for(e=r-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#ho(t){const e=t,{width:i,height:s}=t,{maxDim:n}=this.#Qr;let a=i,r=s;if(i>n||s>n){let o=i,l=s,h=Math.log2(Math.max(i,s)/n);const c=Math.floor(h);h=h===c?c-1:c;for(let i=0;i<h;i++){a=Math.ceil(o/2),r=Math.ceil(l/2);const i=new OffscreenCanvas(a,r);i.getContext("2d").drawImage(t,0,0,o,l,0,0,a,r),o=a,l=r,t!==e&&t.close(),t=i.transferToImageBitmap()}const d=Math.min(n/a,n/r);a=Math.round(a*d),r=Math.round(r*d)}const o=new OffscreenCanvas(a,r).getContext("2d",{willReadFrequently:!0});o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,a,r);const l=o.getImageData(0,0,a,r).data;return[this.#oo(l),a,r]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,a,r,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m,width:v}=h.measureText(t),b=1.5,y=Math.ceil(Math.max(Math.abs(d)+Math.abs(u)||0,v)*b),w=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(m)||200)*b);l=new OffscreenCanvas(y,w),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=c,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,y,w),h.fillStyle="black",h.fillText(t,.5*y/2,1.5*w/2);const x=this.#oo(h.getImageData(0,0,y,w).data),A=this.#ro(x),_=this.#lo(A),S=this.#io(x,y,w,_);return this.processDrawnLines({lines:{curves:S,width:y,height:w},pageWidth:n,pageHeight:a,rotation:r,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[a,r,o]=this.#ho(t),[l,h]=this.#ao(a,r,o,Math.hypot(r,o)*this.#Qr.sigmaSFactor,this.#Qr.sigmaR,this.#Qr.kernelSize),c=this.#lo(h),d=this.#io(l,r,o,c);return this.processDrawnLines({lines:{curves:d,width:r,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:a,areContours:r}){s%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,f=[];for(const{points:t}of o){const e=a?this.#no(t):t;if(!e)continue;f.push(e);const i=e.length,s=new Float32Array(i),n=new Float32Array(3*(2===i?2:i-2));if(d.push({line:n,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[r,o,l,h]=e;r*=p,o*=g,l*=p,h*=g,s.set([r,o,l,h],0),n.set([NaN,NaN,NaN,NaN,r,o],0);for(let t=4;t<i;t+=2){const i=s[t]=e[t]*p,a=s[t+1]=e[t+1]*g;n.set(nc.createBezierPoints(r,o,l,h,i,a),3*(t-2)),[r,o,l,h]=[l,h,i,a]}}if(0===d.length)return null;const m=r?new yc:new mc;return m.build(d,e,i,1,s,r?0:c,n),{outline:m,newCurves:f,areContours:r,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let a,r=1/0,o=-1/0,l=0;for(const e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];r=Math.min(r,i),o=Math.max(o,i)}}a=r>=-128&&o<=127?Int8Array:r>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,c=8+3*h,d=new Uint32Array(c);let u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*a.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=s,d[u++]=n,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(i??0)),d[u++]=h,d[u++]=a.BYTES_PER_ELEMENT;for(const e of t)d[u++]=e.length-2,d[u++]=e[0],d[u++]=e[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const f=a.prototype.constructor;for(const e of t){const t=new f(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}g.close();const m=await new Response(p.readable).arrayBuffer();return Nr(new Uint8Array(m))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):Cr(atob(e))),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),a=n.getWriter();await a.ready,a.write(i).then((async()=>{await a.ready,await a.close()})).catch((()=>{}));let r=null,o=0;for await(const t of s)r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),r.set(t,o),o+=t.length;const l=new Uint32Array(r.buffer,0,r.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],u=0===l[4],p=l[5],g=l[6],f=l[7],m=[],v=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let b;switch(f){case Int8Array.BYTES_PER_ELEMENT:b=new Int8Array(r.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:b=new Int16Array(r.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:b=new Int32Array(r.buffer,v)}o=0;for(let t=0;t<g;t++){const e=l[3*t+8],i=new Float32Array(e+2);m.push(i);for(let e=0;e<2;e++)i[e]=l[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+b[o++]}return{areContours:u,thickness:p,outlines:m,width:c,height:d}}catch(t){return pr(`decompressSignature: ${t}`),null}var e}}class xc extends pc{constructor(){super(),super.updateProperties({fill:po._defaultLineColor,"stroke-width":0})}clone(){const t=new xc;return t.updateAll(this),t}}class Ac extends vc{constructor(t){super(t),super.updateProperties({stroke:po._defaultLineColor,"stroke-width":1})}clone(){const t=new Ac(this._viewParameters);return t.updateAll(this),t}}class _c extends gc{#co=!1;#do=null;#uo=null;#po=null;static _type="signature";static _editorType=Ha.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#uo=t.signatureData||null,this.#do=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){po.initialize(t,e),this._defaultDrawingOptions=new xc,this._defaultDrawnSignatureOptions=new Ac(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return br(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#do}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#uo){const{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:a}=this.#uo,{rawDims:{pageWidth:r,pageHeight:o},rotation:l}=this.parent.viewport,h=wc.processDrawnLines({lines:t,pageWidth:r,pageHeight:o,rotation:l,innerMargin:_c._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,a,s,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#po=t,this.addEditToolbar()}getUuid(){return this.#po}get description(){return this.#do}set description(t){this.#do=t,super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#uo,a=Math.max(s,n);return{areContours:e,outline:wc.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:i,width:s,height:n},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.signatureManager&&null!==this.#do&&(await t.addEditSignatureButton(this._uiManager.signatureManager,this.#po,this.#do),t.show()),t):null}addSignature(t,e,i,s){const{x:n,y:a}=this,{outline:r}=this.#uo=t;let o;this.#co=r instanceof yc,this.#do=i,this.div.setAttribute("data-l10n-args",JSON.stringify({description:i})),this.#co?o=_c.getDefaultDrawingOptions():(o=_c._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":r.thickness})),this._addOutlines({drawOutlines:r,drawingOptions:o});const[l,h]=this.parentDimensions,[,c]=this.pageDimensions;let d=e/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(l*this.width,h*this.height),this.x=n,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return wc.process(t,e,i,s,_c._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return wc.extractContoursFromText(t,e,i,s,n,_c._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return wc.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:_c._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=_c.getDefaultDrawingOptions():(this._drawingOptions=_c._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,a={annotationType:Ha.SIGNATURE,isSignature:!0,areContours:this.#co,color:[0,0,0],thickness:this.#co?0:n,pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(a.paths={lines:e,points:i},a.uuid=this.#po,a.isCopy=!0):a.lines=e,this.#do&&(a.accessibilityData={type:"Figure",alt:this.#do}),a}static deserializeDraw(t,e,i,s,n,a){return a.areContours?yc.deserialize(t,e,i,s,n,a):mc.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);return s.#co=t.areContours,s.#do=t.accessibilityData?.alt||"",s.#po=t.uuid,s}}class Sc extends po{#go=null;#fo=null;#mo=null;#vo=null;#bo=null;#yo="";#wo=null;#xo=!1;#Ao=null;#_o=!1;#So=!1;static _type="stamp";static _editorType=Ha.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#vo=t.bitmapUrl,this.#bo=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){po.initialize(t,e)}static isHandlingMimeForPasting(t){return to.includes(t)}static paste(t,e){e.pasteEditor({mode:Ha.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#To(t,e=!1){t?(this.#go=t.bitmap,e||(this.#fo=t.id,this.#_o=t.isSvg),t.file&&(this.#yo=t.file.name),this.#ko()):this.remove()}#Co(){if(this.#mo=null,this._uiManager.enableWaiting(!1),this.#wo){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#go)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#go){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:a}=t||this.copyCanvas(null,null,!0).imageData,r=await i.guess({name:"altText",request:{data:s,width:n,height:a,channels:s.length/(n*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#Eo(){if(this.#fo)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#fo).then((t=>this.#To(t,!0))).finally((()=>this.#Co()));if(this.#vo){const t=this.#vo;return this.#vo=null,this._uiManager.enableWaiting(!0),void(this.#mo=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#To(t))).finally((()=>this.#Co())))}if(this.#bo){const t=this.#bo;return this.#bo=null,this._uiManager.enableWaiting(!0),void(this.#mo=this._uiManager.imageManager.getFromFile(t).then((t=>this.#To(t))).finally((()=>this.#Co())))}const t=document.createElement("input");t.type="file",t.accept=to.join(",");const e=this._uiManager._signal;this.#mo=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#To(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Co())),t.click()}remove(){this.#fo&&(this.#go=null,this._uiManager.imageManager.deleteId(this.#fo),this.#wo?.remove(),this.#wo=null,this.#Ao&&(clearTimeout(this.#Ao),this.#Ao=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#fo&&null===this.#wo&&this.#Eo(),this.isAttachedToDOM||this.parent.add(this))):this.#fo&&this.#Eo()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#mo||this.#go||this.#vo||this.#bo||this.#fo||this.#xo)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#xo||(this.#go?this.#ko():this.#Eo()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#fo=i,s&&(this.#go=s),this.#xo=!1,this.#ko())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Ao&&clearTimeout(this.#Ao);this.#Ao=setTimeout((()=>{this.#Ao=null,this.#Mo()}),200)}#ko(){const{div:t}=this;let{width:e,height:i}=this.#go;const[s,n]=this.pageDimensions,a=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>a*s||i>a*n){const t=Math.min(a*s/e,a*n/i);e*=t,i*=t}const[r,o]=this.parentDimensions;this.setDims(e*r/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#wo=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#Mo(),this.#So||(this.parent.addUndoableEditor(this),this.#So=!0),this._reportTelemetry({action:"inserted_image"}),this.#yo&&this.div.setAttribute("aria-description",this.#yo)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#go,a=new Zr;let r=this.#go,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*a.sx),i=h.height=Math.ceil(l*a.sy);this.#_o||(r=this.#Po(t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const p=15,g=p*a.sx,f=p*a.sy,m=new OffscreenCanvas(2*g,2*f),v=m.getContext("2d");v.fillStyle=d,v.fillRect(0,0,2*g,2*f),v.fillStyle=u,v.fillRect(0,0,g,f),v.fillRect(g,f,g,f),c.fillStyle=c.createPattern(m,"repeat"),c.fillRect(0,0,t,i),c.drawImage(r,0,0,r.width,r.height,0,0,t,i)}let c=null;if(i){let e,i;if(a.symmetric&&r.width<t&&r.height<t)e=r.width,i=r.height;else if(r=this.#go,s>t||n>t){const a=Math.min(t/s,t/n);e=Math.floor(s*a),i=Math.floor(n*a),this.#_o||(r=this.#Po(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.height,0,0,e,i),c={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:c}}#Po(t,e){const{width:i,height:s}=this.#go;let n=i,a=s,r=this.#go;for(;n>2*t||a>2*e;){const i=n,s=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,i,s,0,0,n,a),r=o.transferToImageBitmap()}return r}#Mo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Zr,a=Math.ceil(i*t*n.sx),r=Math.ceil(s*e*n.sy),o=this.#wo;if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const l=this.#_o?this.#go:this.#Po(a,r),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,r)}#Do(t){if(t){if(this.#_o){const t=this._uiManager.imageManager.getSvgUrl(this.#fo);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#go);return t.getContext("2d").drawImage(this.#go,0,0),t.toDataURL()}if(this.#_o){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Br.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Br.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#go,0,0,this.#go.width,this.#go.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#go)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof Zh){const{data:{rect:a,rotation:r,id:o,structParent:l,popupRef:h},container:c,parent:{page:{pageNumber:d}},canvas:u}=t;let p,g;u?(delete t.canvas,({id:p,bitmap:g}=i.imageManager.getFromCanvas(c.id,u)),u.remove()):(n=!0,t._hasNoCanvas=!0);const f=(await e._structTree.getAriaAttributes(`${Lr}${o}`))?.get("aria-label")||"";s=t={annotationType:Ha.STAMP,bitmapId:p,bitmap:g,pageIndex:d-1,rect:a.slice(0),rotation:r,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:f},isSvg:!1,structParent:l,popupRef:h}}const a=await super.deserialize(t,e,i),{rect:r,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:d}=t;n?(i.addMissingCanvas(t.id,a),a.#xo=!0):h&&i.imageManager.isValidId(h)?(a.#fo=h,o&&(a.#go=o)):a.#vo=l,a.#_o=c;const[u,p]=a.pageDimensions;return a.width=(r[2]-r[0])/u,a.height=(r[3]-r[1])/p,a.annotationElementId=t.id||null,d&&(a.altTextData=d),a._initialData=s,a.#So=!!s,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:Ha.STAMP,bitmapId:this.#fo,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#_o,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#Do(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#ta(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const a=this.#_o?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#fo)){if(this.#_o){const t=e.stamps.get(this.#fo);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Do(!1))}}else e.stamps.set(this.#fo,{area:a,serialized:i}),i.bitmap=this.#Do(!1);return i}#ta(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class Tc{#On;#Io=!1;#Ro=null;#Lo=null;#Fo=null;#No=new Map;#Oo=!1;#Bo=!1;#zo=!1;#jo=null;#Vo=null;#Ho=null;#$o=null;#m;static _initialized=!1;static#H=new Map([sc,bc,Sc,uc,_c].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:a,drawLayer:r,textLayer:o,viewport:l,l10n:h}){const c=[...Tc.#H.values()];if(!Tc._initialized){Tc._initialized=!0;for(const e of c)e.initialize(h,t)}t.registerEditorTypes(c),this.#m=t,this.pageIndex=e,this.div=i,this.#On=n,this.#Ro=a,this.viewport=l,this.#Ho=o,this.drawLayer=r,this._structTree=s,this.#m.addLayer(this)}get isEmpty(){return 0===this.#No.size}get isInvisible(){return this.isEmpty&&this.#m.getMode()===Ha.NONE}updateToolbar(t){this.#m.updateToolbar(t)}updateMode(t=this.#m.getMode()){switch(this.#Uo(),t){case Ha.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Ha.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Ha.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const i of Tc.#H.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#Ho?.div}setEditingState(t){this.#m.setEditingState(t)}addCommands(t){this.#m.addCommands(t)}cleanUndoStack(t){this.#m.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Ro?.div.classList.toggle("disabled",!t)}async enable(){this.#zo=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#No.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#m.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#Ro)return void(this.#zo=!1);const e=this.#Ro.getEditableAnnotations();for(const i of e){if(i.hide(),this.#m.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#zo=!1}disable(){this.#Bo=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#No.values())i.disableEditing(),i.annotationElementId&&(null===i.serialize()?(e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()):t.set(i.annotationElementId,i));if(this.#Ro){const i=this.#Ro.getEditableAnnotations();for(const s of i){const{id:i}=s.data;if(this.#m.isDeletedAnnotationElement(i))continue;let n=e.get(i);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=t.get(i),n&&(this.#m.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#Uo(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of Tc.#H.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#Bo=!1}getEditableAnnotation(t){return this.#Ro?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#m.getActive()!==t&&this.#m.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#Ho?.div&&!this.#$o){this.#$o=new AbortController;const t=this.#m.combinedSignal(this.#$o);this.#Ho.div.addEventListener("pointerdown",this.#Go.bind(this),{signal:t}),this.#Ho.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#Ho?.div&&this.#$o&&(this.#$o.abort(),this.#$o=null,this.#Ho.div.classList.remove("highlighting"))}#Go(t){this.#m.unselectAll();const{target:e}=t;if(e===this.#Ho.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#Ho.div.contains(e)){const{isMac:e}=Er.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#m.showAllEditors("highlight",!0,!0),this.#Ho.div.classList.add("free"),this.toggleDrawing(),uc.startHighlighting(this,"ltr"===this.#m.direction,{target:this.#Ho.div,x:t.x,y:t.y}),this.#Ho.div.addEventListener("pointerup",(()=>{this.#Ho.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#m._signal}),t.preventDefault()}}enableClick(){if(this.#Lo)return;this.#Lo=new AbortController;const t=this.#m.combinedSignal(this.#Lo);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#Lo?.abort(),this.#Lo=null}attach(t){this.#No.set(t.id,t);const{annotationElementId:e}=t;e&&this.#m.isDeletedAnnotationElement(e)&&this.#m.removeDeletedAnnotationElement(t)}detach(t){this.#No.delete(t.id),this.#On?.removePointerInTextLayer(t.contentDiv),!this.#Bo&&t.annotationElementId&&this.#m.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#m.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#m.addDeletedAnnotationElement(t.annotationElementId),po.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#m.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#zo),this.#m.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Fo&&(t._focusEventsAllowed=!1,this.#Fo=setTimeout((()=>{this.#Fo=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#m._signal}),e.focus())}),0)),t._structTreeParentId=this.#On?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#m.getId()}get#qo(){return Tc.#H.get(this.#m.getMode())}combinedSignal(t){return this.#m.combinedSignal(t)}#Wo(t){const e=this.#qo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#qo?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#m.updateMode(t.mode);const{offsetX:i,offsetY:s}=this.#Ko(),n=this.getNextId(),a=this.#Wo({parent:this,id:n,x:i,y:s,uiManager:this.#m,isCentered:!0,...e});a&&this.add(a)}async deserialize(t){return await(Tc.#H.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#m))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#Wo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#m,isCentered:e,...i});return n&&this.add(n),n}#Ko(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+i))/2-t,o=(a+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:l,offsetY:h}}addNewEditor(t={}){this.createAndAddNewEditor(this.#Ko(),!0,t)}setSelected(t){this.#m.setSelected(t)}toggleSelected(t){this.#m.toggleSelected(t)}unselect(t){this.#m.unselect(t)}pointerup(t){const{isMac:e}=Er.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#Oo)return;if(this.#Oo=!1,this.#qo?.isDrawer&&this.#qo.supportMultipleDrawings)return;if(!this.#Io)return void(this.#Io=!0);const i=this.#m.getMode();i!==Ha.STAMP&&i!==Ha.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#m.unselectAll()}pointerdown(t){if(this.#m.getMode()===Ha.HIGHLIGHT&&this.enableTextSelection(),this.#Oo)return void(this.#Oo=!1);const{isMac:e}=Er.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#Oo=!0,this.#qo?.isDrawer)return void this.startDrawingSession(t);const i=this.#m.getActive();this.#Io=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#jo)return void this.#qo.startDrawing(this,this.#m,!1,t);this.#m.setCurrentDrawingSession(this),this.#jo=new AbortController;const e=this.#m.combinedSignal(this.#jo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#Vo=null,this.commitOrRemove())}),{signal:e}),this.#qo.startDrawing(this,this.#m,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#Vo=t)}else this.#Vo&&setTimeout((()=>{this.#Vo?.focus(),this.#Vo=null}),0)}endDrawingSession(t=!1){return this.#jo?(this.#m.setCurrentDrawingSession(null),this.#jo.abort(),this.#jo=null,this.#Vo=null,this.#qo.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#m.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#jo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#jo&&this.#qo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#m.getActive()?.parent===this&&(this.#m.commitOrRemove(),this.#m.setActiveEditor(null)),this.#Fo&&(clearTimeout(this.#Fo),this.#Fo=null);for(const t of this.#No.values())this.#On?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#No.clear(),this.#m.removeLayer(this)}#Uo(){for(const t of this.#No.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Jr(this.div,t);for(const t of this.#m.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#m.commitOrRemove(),this.#Uo();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Jr(this.div,{rotation:i}),e!==i)for(const t of this.#No.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#m.viewParameters.realScale}}class kc{#fn=null;#Xo=new Map;#Yo=new Map;static#w=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#fn){if(this.#fn!==t){if(this.#Xo.size>0)for(const e of this.#Xo.values())e.remove(),t.append(e);this.#fn=t}}else this.#fn=t}static get _svgFactory(){return br(this,"_svgFactory",new Sh)}static#Qo(t,[e,i,s,n]){const{style:a}=t;a.top=100*i+"%",a.left=100*e+"%",a.width=100*s+"%",a.height=100*n+"%"}#Jo(){const t=kc._svgFactory.create(1,1,!0);return this.#fn.append(t),t.setAttribute("aria-hidden",!0),t}#Zo(t,e){const i=kc._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=kc._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#tl(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){const s=kc.#w++,n=this.#Jo(),a=kc._svgFactory.createElement("defs");n.append(a);const r=kc._svgFactory.createElement("path");a.append(r);const o=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#Yo.set(s,r);const l=i?this.#Zo(a,o):null,h=kc._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#Xo.set(s,n),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){const i=kc.#w++,s=this.#Jo(),n=kc._svgFactory.createElement("defs");s.append(n);const a=kc._svgFactory.createElement("path");n.append(a);const r=`path_p${this.pageIndex}_${i}`;let o;if(a.setAttribute("id",r),a.setAttribute("vector-effect","non-scaling-stroke"),e){const t=kc._svgFactory.createElement("mask");n.append(t),o=`mask_p${this.pageIndex}_${i}`,t.setAttribute("id",o),t.setAttribute("maskUnits","objectBoundingBox");const e=kc._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=kc._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${r}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const l=kc._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${r}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return s.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#Xo.set(i,s),i}finalizeDraw(t,e){this.#Yo.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:s,rootClass:n,path:a}=e,r="number"==typeof t?this.#Xo.get(t):t;if(r){if(i&&this.#tl(r,i),s&&kc.#Qo(r,s),n){const{classList:t}=r;for(const[e,i]of Object.entries(n))t.toggle(e,i)}if(a){const t=r.firstChild.firstChild;this.#tl(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#Xo.get(t);i&&(e.#fn.append(i),this.#Xo.delete(t),e.#Xo.set(t,i))}remove(t){this.#Yo.delete(t),null!==this.#fn&&(this.#Xo.get(t).remove(),this.#Xo.delete(t))}destroy(){this.#fn=null;for(const t of this.#Xo.values())t.remove();this.#Xo.clear(),this.#Yo.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:oc},globalThis.pdfjsLib={AbortException:Tr,AnnotationEditorLayer:Tc,AnnotationEditorParamsType:$a,AnnotationEditorType:Ha,AnnotationEditorUIManager:ho,AnnotationLayer:ec,AnnotationMode:Va,AnnotationType:Qa,build:"47ad820d9",ColorPicker:dc,createValidAbsoluteUrl:mr,DOMSVGFactory:Sh,DrawLayer:kc,FeatureTest:Er,fetchData:zr,getDocument:dh,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)},getPdfFilenameFromUrl:function(t,e="document.pdf"){if("string"!=typeof t)return e;if(Hr(t))return pr('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e},getUuid:Rr,getXfaPageViewport:function(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,a=[0,0,parseInt(s),parseInt(n)];return new jr({viewBox:a,userUnit:1,scale:e,rotation:i})},GlobalWorkerOptions:Ll,ImageKind:Ya,InvalidPDFException:Ar,isDataScheme:Hr,isPdfFile:$r,isValidExplicitDest:ko,MathClamp:Fr,noContextMenu:qr,normalizeUnicode:function(t){return Dr||(Dr=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Ir=new Map([["ſt","ſt"]])),t.replaceAll(Dr,((t,e,i)=>e?e.normalize("NFKC"):Ir.get(i)))},OPS:nr,OutputScale:Zr,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:ph,PDFDateString:Kr,PDFWorker:mh,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},PixelsPerInch:Br,RenderingCancelledException:Vr,ResponseException:_r,setLayerDimensions:Jr,shadow:br,SignatureExtractor:wc,stopEvent:Wr,SupportedImageMimeTypes:to,TextLayer:hh,TouchManager:uo,updateUrlHash:vr,Util:Pr,VerbosityLevel:sr,version:"5.3.31",XfaLayer:Th};const Cc={key:0,class:"loading-screen"},Ec={key:1,class:"image-display-area"},Mc={class:"ocr-container",ref:"containerRef"},Pc=["src"],Dc=["onClick","onMouseover"];var Ic=b({__name:"renderOCRResponse",props:{image:{type:null,required:!0},language:{type:String,required:!0}},emits:["close","loadingUpdate"],setup(t,{emit:i}){const s=t;Ll.workerSrc="/tta/pdf.worker.mjs";const{useNotificationsStore:n}=e(),a=n(),h=u(null),g=u([]),f=u(),m=u(),b=u([]),x=u(""),_=u(!1),C=u([]),M=u(1),P=y((()=>b.value.sort().map((t=>{var e;return null==(e=g.value[t])?void 0:e.text})).join(" ")));async function I(t,e,n){if(m.value=t,n)return x.value=n,R(),n;console.log(e),document.addEventListener("click",L),_.value=!0,i("loadingUpdate",!0);const r=new FormData;let o;r.append("image",e);try{const t=await fetch("/tta/ocr?language="+s.language,{method:"POST",body:r});if(!t.ok)throw new Error(`Server error: ${t.status}`);o=await t.text(),x.value=o,R()}catch(t){a.add({title:"Error while using OCR",text:"Please check your console/terminal for the error.",type:"error",dialog:!0}),console.error(t)}return _.value=!1,i("loadingUpdate",!1),o}function R(){const t=f.value,e=t.naturalWidth,i=t.naturalHeight,s=t.clientWidth,n=t.clientHeight,a=[];(new DOMParser).parseFromString(x.value,"text/html").querySelectorAll(".ocrx_word").forEach((t=>{const r=t.getAttribute("title");if(r){const o=r.match(/bbox (\d+) (\d+) (\d+) (\d+)/);if(o){const[r,l,h,c,d]=o.map(Number),u=l/e*s,p=h/i*n,g={x0:u,y0:p,x1:u+(c-l)/e*s,y1:p+(d-h)/i*n};a.push({text:t.textContent.trim(),bbox:g})}else console.warn("Malformed bbox data for span:",t)}else console.warn("Missing title attribute for span:",t)})),g.value=a}function L(){const t=document.activeElement;if(("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&!t.readOnly&&!t.disabled&&P.value){const e=t.selectionStart,i=t.selectionEnd,s=t.value;t.value=s.slice(0,e)+P.value+s.slice(i),t.selectionStart=t.selectionEnd=e+P.length,b.value=[],t.dispatchEvent(new Event("input",{bubbles:!0}))}}return A((async()=>{const t=await new Promise((t=>{const e=new FileReader;e.onload=e=>{t(e.target.result)},"application/pdf"==s.image.type?e.readAsArrayBuffer(s.image):e.readAsDataURL(s.image)}));if(s.image.type.startsWith("image/"))I(t,s.image);else if("application/pdf"==s.image.type){const e=new Uint8Array(t),i=await dh(e).promise;console.log(i.numPages);for(let t=1;t<=i.numPages;t++){const e=await i.getPage(t),s=e.getViewport({scale:1}),n=document.createElement("canvas"),a=n.getContext("2d");n.width=s.width,n.height=s.height,await e.render({canvasContext:a,viewport:s}).promise;const r=await new Promise((t=>n.toBlob((e=>t(e)),"image/png")));C.value.push({string:n.toDataURL("image/png"),file:new File([r],"page"+t+".png",{type:"image/png"})}),n.remove(),console.log({i:t})}const[s]=C.value;s&&I(s.string,s.file).then((t=>s.response=t))}else i("close"),a.add({title:"Error while using OCR",text:`File type '${s.image.type}' not supported.`,type:"error",dialog:!0})})),w((()=>M.value),(t=>{const e=C.value[t-1];e&&I(e.string,e.file,e.response).then((t=>e.response=t))})),F((()=>{document.removeEventListener("click",L)})),(t,e)=>{const i=r("v-progress-circular"),s=r("VPagination"),n=r("v-input");return o(),p(k,null,[_.value?(o(),p("div",Cc,[c(i,{indeterminate:"",class:"c"})])):d("v-if",!0),m.value?(o(),p("div",Ec,[v("div",Mc,[v("img",{src:m.value,onLoad:R,style:{width:"100%","object-fit":"contain"},ref_key:"imageRef",ref:f,onMousedown:e[0]||(e[0]=E((()=>{}),["stop"]))},null,40,Pc),(o(!0),p(k,null,D(g.value,((t,i)=>(o(),p("div",{key:i,class:"text-overlay",style:S({padding:"2px",position:"absolute",left:`${t.bbox.x0}px`,top:`${t.bbox.y0}px`,width:t.bbox.x1-t.bbox.x0+"px",height:t.bbox.y1-t.bbox.y0+"px",border:b.value.includes(i)?"2px solid green":h.value===i?"2px solid blue":"1px solid transparent",cursor:"pointer",backgroundColor:"rgba(255, 255, 0, 0.3)"}),onClick:t=>function(t){const e=b.value.indexOf(t);-1==e?b.value.push(t):b.value.splice(e,1)}(i),onMouseover:t=>h.value=i,onMouseleave:e[1]||(e[1]=t=>h.value=null)},null,44,Dc)))),128))],512),C.value.length>1?(o(),l(s,{key:0,modelValue:M.value,"onUpdate:modelValue":e[2]||(e[2]=t=>M.value=t),length:C.value.length,totalVisible:4,class:"pagination-center"},null,8,["modelValue","length"])):d("v-if",!0),c(n,{modelValue:T(P)},null,8,["modelValue"])])):d("v-if",!0)],64)}}});sn("\n.image-display-area[data-v-0d65f7ea] {\n position: relative;\n background: white;\n border: 1px solid white;\n color: black;\n border-radius: 8px;\n overflow: hidden;\n margin: auto;\n width: 100%;\n display: flex;\n flex-direction: column;\n}\n.pagination-center[data-v-0d65f7ea] {\n margin: 5px auto;\n}\n.ocr-container[data-v-0d65f7ea] {\n position: relative;\n height: 100%;\n}\n.text-overlay[data-v-0d65f7ea] {\n position: absolute;\n}\n.loading-screen[data-v-0d65f7ea] {\n position: absolute;\n width: 100%;\n height: 100%;\n background-color: rgba(255, 255, 255, 0.4);\n display: flex;\n left: 0;\n top: 0;\n z-index: 1000;\n}\n.loading-screen .c[data-v-0d65f7ea] {\n margin: auto;\n}\n",{}),Ic.__scopeId="data-v-0d65f7ea",Ic.__file="ocr/OCR-interface/src/renderOCRResponse.vue";var Rc=b({__name:"ocredrag",props:{initialX:{type:Number,required:!0},initialY:{type:Number,required:!0}},emits:["close"],setup(t,{emit:e}){const i=t,s=u(null),n=u(!1),a=N({x:i.initialX||50,y:i.initialY||50}),d=N({x:0,y:0}),p=t=>{n.value=!0,d.x=t.clientX-a.x,d.y=t.clientY-a.y,document.addEventListener("mousemove",g),document.addEventListener("mouseup",f)},g=t=>{n.value&&(a.x=t.clientX-d.x,a.y=t.clientY-d.y)},f=()=>{n.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)};return O((()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)})),(t,i)=>{const d=r("v-icon"),u=r("VButton");return o(),l(B,{to:"body"},[v("div",{ref_key:"draggableElement",ref:s,style:S({position:"absolute",left:a.x+"px",top:a.y+"px",cursor:n.value?"grabbing":"grab",width:"500px","max-width":"80vw",height:"auto",padding:"20px",backgroundColor:"var(--theme--background)",color:"var(--theme--form--field--label--foreground)",border:"var(--theme--border-color) 2px solid",borderRadius:"4px",userSelect:"none","z-index":100}),onMousedown:p},[z(t.$slots,"default"),c(u,{onClick:i[0]||(i[0]=t=>e("close")),outlined:!1,icon:!0,rounded:!0,class:"close-btn"},{default:h((()=>[c(d,{name:"close"})])),_:1})],36)])}}});sn("\n.close-btn[data-v-6008a42c] {\n position: absolute;\n right: -10px;\n top: -10px;\n z-index: 1001;\n}\n",{}),Rc.__scopeId="data-v-6008a42c",Rc.__file="ocr/OCR-interface/src/ocredrag.vue";const Lc={class:"ocr-container"};var Fc=b({__name:"interface",props:{language:{type:String,required:!0},collection:{type:String,required:!0}},setup(t){const i=t,{useFieldsStore:s}=e(),n=s(),a=u(!1),f=u(),m=u(!1),b=u(),y=u([]);function w(){f.value.click()}async function _(t){const e=t.target.files[0];e&&(b.value=e)}async function S(t,e){const i=e||T(t.target.parentElement);if(i){const t=await fetch(i).then((t=>t.blob())),e=new File([t],"image.png",{type:t.type}),s=f.value,n=new DataTransfer;n.items.add(e),s.files=n.files,s.dispatchEvent(new Event("change",{bubbles:!0}))}}function T(t){let e=0,i="";for(;e<10;){const s=(t=t.parentElement).querySelector("img");if(s){i=s.src;break}e++}return i.split("?")[0]}function C(){b.value=null,f.value.value=""}return A((()=>{const t=n.getFieldsForCollection(i.collection).filter((t=>{var e;return"file-image"==(null==(e=t.meta)?void 0:e.interface)}));x((()=>{setTimeout((()=>{for(const e of t){const t="[data-collection="+i.collection+"][data-field="+e.field+"]",s=document.querySelector(t);s&&s.addEventListener("mouseover",(e=>{const i=s.querySelector(".image-preview img");if(i){!s.querySelector(".ocr_button")&&T(i)&&y.value.push(t+" .actions")}}))}}),500);const e=n.getFieldsForCollection(i.collection).filter((t=>{var e;return"file"==(null==(e=t.meta)?void 0:e.interface)}));x((()=>{setTimeout((()=>{for(const t of e){const e="[data-collection="+i.collection+"][data-field="+t.field+"]",s=document.querySelector(e);if(s){const t=s.querySelector("input");null==t||t.addEventListener("change",(()=>{var t;null==(t=document.getElementById("_SCAN_OCR"))||t.remove()})),s.addEventListener("click",(()=>{setTimeout((()=>{var t;const e=document.querySelector("a[download]");if(e){const i=e.cloneNode(!0);i.href="#",i.querySelector("i").setAttribute("data-icon","camera_video"),i.id="_SCAN_OCR",i.classList.add("hide-by-default"),i.children[1].innerText="Scan with OCR",i.addEventListener("click",(t=>{t.preventDefault(),S(void 0,e.getAttribute("href"))})),null==(t=e.parentNode)||t.insertBefore(i,e)}}),100)}))}}}))})),a.value=!0}))})),(e,i)=>{const s=r("v-icon"),n=r("VButton"),u=r("v-button");return o(),p(k,null,[(o(!0),p(k,null,D(y.value,(t=>(o(),l(B,{to:t},[c(n,{onClick:S,outlined:!1,icon:!0,rounded:!0,class:"ocr_button"},{default:h((()=>[c(s,{name:"camera_video"})])),_:1})],8,["to"])))),256)),a.value?(o(),l(B,{key:0,to:"#sidebar .v-item-group"},[v("div",Lc,[c(u,{class:"ocr-btn",onClick:w,loading:m.value},{default:h((()=>[g(" Import data with OCR ")])),_:1},8,["loading"]),v("input",{type:"file",onChange:_,class:"ocr-input",ref_key:"inputRef",ref:f,accept:"image/*,application/pdf"},null,544),null!=b.value?(o(),l(Rc,{key:0,onClose:C},{default:h((()=>[c(Ic,{image:b.value,onClose:i[0]||(i[0]=()=>C()),language:t.language,onLoadingUpdate:i[1]||(i[1]=t=>m.value=t)},null,8,["image","language"])])),_:1})):d("v-if",!0)])])):d("v-if",!0)],64)}}});sn("\n.ocr-container {\n display: flex;\n}\n.ocr-container .ocr-btn {\n margin: 10px auto;\n}\n.ocr-container .ocr-input {\n display: none;\n}\n.hide-by-default {\n display: none;\n}\na ~ #_SCAN_OCR {\n display: block;\n}\n",{}),Fc.__file="ocr/OCR-interface/src/interface.vue";const Nc=[Ta,Ca,Ma,n({id:"tta-ocr-interface",name:"OCR interface",icon:"camera_video",description:"Use OCR to fill fields. (Text to anything)",hideLabel:!0,hideLoader:!0,component:Fc,types:["alias"],localTypes:["presentation"],options:[{field:"language",name:"Language",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:[{value:"eng",text:"English"},{value:"por",text:"Portuguese"},{value:"fra",text:"French"},{value:"osd",text:"Orientation and Script Detection"},{value:"chi_sim",text:"Chinese (Simplified)"},{value:"spa",text:"Spanish"},{value:"deu",text:"German"},{value:"chi_tra",text:"Chinese (Traditional)"},{value:"heb",text:"Hebrew"},{value:"kor",text:"Korean"},{value:"jpn",text:"Japanese"},{value:"rus",text:"Russian"},{value:"nld",text:"Dutch"},{value:"hin",text:"Hindi"},{value:"ita",text:"Italian"},{value:"jpn_vert",text:"Japanese (Vertical)"},{value:"pol",text:"Polish"},{value:"ron",text:"Romanian"},{value:"mar",text:"Marathi"},{value:"ukr",text:"Ukrainian"},{value:"mal",text:"Malayalam"},{value:"tam",text:"Tamil"},{value:"guj",text:"Gujarati"},{value:"tha",text:"Thai"},{value:"kan",text:"Kannada"},{value:"vie",text:"Vietnamese"},{value:"tel",text:"Telugu"},{value:"swe",text:"Swedish"},{value:"tur",text:"Turkish"},{value:"nor",text:"Norwegian"},{value:"ces",text:"Czech"},{value:"ben",text:"Bengali"},{value:"pan",text:"Punjabi"},{value:"equ",text:"Math / Equation Detection"},{value:"ell",text:"Greek"},{value:"bul",text:"Bulgarian"},{value:"lat",text:"Latin"},{value:"kur",text:"Kurdish"},{value:"ori",text:"Odia"},{value:"kat",text:"Georgian"},{value:"amh",text:"Amharic"},{value:"kaz",text:"Kazakh"},{value:"cat",text:"Catalan"},{value:"nep",text:"Nepali"},{value:"urd",text:"Urdu"},{value:"khm",text:"Khmer"},{value:"dan",text:"Danish"},{value:"chi_sim_vert",text:"Chinese (Simplified, Vertical)"},{value:"uzb",text:"Uzbek (Latin)"},{value:"slv",text:"Slovenian"},{value:"mkd",text:"Macedonian"},{value:"tgl",text:"Tagalog"},{value:"srp",text:"Serbian (Cyrillic)"},{value:"hrv",text:"Croatian"},{value:"tir",text:"Tigrinya"},{value:"syr",text:"Syriac"},{value:"lao",text:"Lao"},{value:"fin",text:"Finnish"},{value:"est",text:"Estonian"},{value:"bos",text:"Bosnian"},{value:"uig",text:"Uyghur"},{value:"sin",text:"Sinhala"},{value:"hye",text:"Armenian"},{value:"eus",text:"Basque"},{value:"sqi",text:"Albanian"},{value:"isl",text:"Icelandic"},{value:"bel",text:"Belarusian"},{value:"aze",text:"Azerbaijani (Latin)"},{value:"pus",text:"Pashto"},{value:"oci",text:"Occitan"},{value:"lit",text:"Lithuanian"},{value:"jav",text:"Javanese"},{value:"hun",text:"Hungarian"},{value:"grc",text:"Ancient Greek"},{value:"gle",text:"Irish"},{value:"frm",text:"Middle French"},{value:"afr",text:"Afrikaans"},{value:"uzb_cyrl",text:"Uzbek (Cyrillic)"},{value:"spa_old",text:"Old Spanish"},{value:"snd",text:"Sindhi"},{value:"mya",text:"Burmese"},{value:"iku",text:"Inuktitut"},{value:"fil",text:"Filipino"},{value:"fas",text:"Persian"},{value:"fao",text:"Faroese"},{value:"dzo",text:"Dzongkha"},{value:"cym",text:"Welsh"},{value:"aze_cyrl",text:"Azerbaijani (Cyrillic)"},{value:"ind",text:"Indonesian"},{value:"ara",text:"Arabic"},{value:"yid",text:"Yiddish"},{value:"ton",text:"Tongan"},{value:"tgk",text:"Tajik"},{value:"srp_latn",text:"Serbian (Latin)"},{value:"slk_frak",text:"Slovak (Fraktur)"},{value:"slk",text:"Slovak"},{value:"san",text:"Sanskrit"},{value:"msa",text:"Malay"},{value:"mri",text:"Maori"},{value:"mlt",text:"Maltese"},{value:"lav",text:"Latvian"},{value:"kur_ara",text:"Kurdish (Arabic)"},{value:"kor_vert",text:"Korean (Vertical)"},{value:"kmr",text:"Kurmanji"},{value:"kir",text:"Kyrgyz"},{value:"hat",text:"Haitian Creole"},{value:"glg",text:"Galician"},{value:"fry",text:"Frisian"},{value:"epo",text:"Esperanto"},{value:"div",text:"Divehi"},{value:"chr",text:"Cherokee"},{value:"bod",text:"Tibetan"},{value:"asm",text:"Assamese"},{value:"yor",text:"Yoruba"},{value:"tat",text:"Tatar"},{value:"sun",text:"Sundanese"},{value:"occ",text:"Occitan (alternative)"},{value:"mon",text:"Mongolian"},{value:"ita_old",text:"Old Italian"},{value:"gla",text:"Scottish Gaelic"},{value:"frk",text:"Frankish"},{value:"enm",text:"Middle English"},{value:"deu_frak",text:"German (Fraktur)"},{value:"dan_frak",text:"Danish (Fraktur)"},{value:"chi_tra_vert",text:"Chinese (Traditional, Vertical)"},{value:"ceb",text:"Cebuano"},{value:"bre",text:"Breton"},{value:"swa",text:"Swahili"},{value:"que",text:"Quechua"},{value:"ltz",text:"Luxembourgish"},{value:"kat_old",text:"Old Georgian"},{value:"cos",text:"Corsican"}]}}}]})],Oc=[],Bc=[],zc=[_a],jc=[],Vc=[j,V,H,$,t({id:"ttaocr",name:"TTA OCR",icon:"camera_video",description:"TTA scan image with OCR",overview:({fileID:t,mode:e,language:i})=>[{label:"Mode",text:e},{label:"Language",text:i},{label:"File ID",text:t}],options:[{field:"fileID",name:"File ID",type:"string",meta:{width:"full",interface:"input"}},{field:"mode",name:"Mode",type:"string",meta:{interface:"select-dropdown",options:{choices:[{text:"Text",value:"text"},{text:"Horc",value:"horc"}]}}},{field:"language",name:"Language",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:[{value:"eng",text:"English"},{value:"por",text:"Portuguese"},{value:"fra",text:"French"},{value:"osd",text:"Orientation and Script Detection"},{value:"chi_sim",text:"Chinese (Simplified)"},{value:"spa",text:"Spanish"},{value:"deu",text:"German"},{value:"chi_tra",text:"Chinese (Traditional)"},{value:"heb",text:"Hebrew"},{value:"kor",text:"Korean"},{value:"jpn",text:"Japanese"},{value:"rus",text:"Russian"},{value:"nld",text:"Dutch"},{value:"hin",text:"Hindi"},{value:"ita",text:"Italian"},{value:"jpn_vert",text:"Japanese (Vertical)"},{value:"pol",text:"Polish"},{value:"ron",text:"Romanian"},{value:"mar",text:"Marathi"},{value:"ukr",text:"Ukrainian"},{value:"mal",text:"Malayalam"},{value:"tam",text:"Tamil"},{value:"guj",text:"Gujarati"},{value:"tha",text:"Thai"},{value:"kan",text:"Kannada"},{value:"vie",text:"Vietnamese"},{value:"tel",text:"Telugu"},{value:"swe",text:"Swedish"},{value:"tur",text:"Turkish"},{value:"nor",text:"Norwegian"},{value:"ces",text:"Czech"},{value:"ben",text:"Bengali"},{value:"pan",text:"Punjabi"},{value:"equ",text:"Math / Equation Detection"},{value:"ell",text:"Greek"},{value:"bul",text:"Bulgarian"},{value:"lat",text:"Latin"},{value:"kur",text:"Kurdish"},{value:"ori",text:"Odia"},{value:"kat",text:"Georgian"},{value:"amh",text:"Amharic"},{value:"kaz",text:"Kazakh"},{value:"cat",text:"Catalan"},{value:"nep",text:"Nepali"},{value:"urd",text:"Urdu"},{value:"khm",text:"Khmer"},{value:"dan",text:"Danish"},{value:"chi_sim_vert",text:"Chinese (Simplified, Vertical)"},{value:"uzb",text:"Uzbek (Latin)"},{value:"slv",text:"Slovenian"},{value:"mkd",text:"Macedonian"},{value:"tgl",text:"Tagalog"},{value:"srp",text:"Serbian (Cyrillic)"},{value:"hrv",text:"Croatian"},{value:"tir",text:"Tigrinya"},{value:"syr",text:"Syriac"},{value:"lao",text:"Lao"},{value:"fin",text:"Finnish"},{value:"est",text:"Estonian"},{value:"bos",text:"Bosnian"},{value:"uig",text:"Uyghur"},{value:"sin",text:"Sinhala"},{value:"hye",text:"Armenian"},{value:"eus",text:"Basque"},{value:"sqi",text:"Albanian"},{value:"isl",text:"Icelandic"},{value:"bel",text:"Belarusian"},{value:"aze",text:"Azerbaijani (Latin)"},{value:"pus",text:"Pashto"},{value:"oci",text:"Occitan"},{value:"lit",text:"Lithuanian"},{value:"jav",text:"Javanese"},{value:"hun",text:"Hungarian"},{value:"grc",text:"Ancient Greek"},{value:"gle",text:"Irish"},{value:"frm",text:"Middle French"},{value:"afr",text:"Afrikaans"},{value:"uzb_cyrl",text:"Uzbek (Cyrillic)"},{value:"spa_old",text:"Old Spanish"},{value:"snd",text:"Sindhi"},{value:"mya",text:"Burmese"},{value:"iku",text:"Inuktitut"},{value:"fil",text:"Filipino"},{value:"fas",text:"Persian"},{value:"fao",text:"Faroese"},{value:"dzo",text:"Dzongkha"},{value:"cym",text:"Welsh"},{value:"aze_cyrl",text:"Azerbaijani (Cyrillic)"},{value:"ind",text:"Indonesian"},{value:"ara",text:"Arabic"},{value:"yid",text:"Yiddish"},{value:"ton",text:"Tongan"},{value:"tgk",text:"Tajik"},{value:"srp_latn",text:"Serbian (Latin)"},{value:"slk_frak",text:"Slovak (Fraktur)"},{value:"slk",text:"Slovak"},{value:"san",text:"Sanskrit"},{value:"msa",text:"Malay"},{value:"mri",text:"Maori"},{value:"mlt",text:"Maltese"},{value:"lav",text:"Latvian"},{value:"kur_ara",text:"Kurdish (Arabic)"},{value:"kor_vert",text:"Korean (Vertical)"},{value:"kmr",text:"Kurmanji"},{value:"kir",text:"Kyrgyz"},{value:"hat",text:"Haitian Creole"},{value:"glg",text:"Galician"},{value:"fry",text:"Frisian"},{value:"epo",text:"Esperanto"},{value:"div",text:"Divehi"},{value:"chr",text:"Cherokee"},{value:"bod",text:"Tibetan"},{value:"asm",text:"Assamese"},{value:"yor",text:"Yoruba"},{value:"tat",text:"Tatar"},{value:"sun",text:"Sundanese"},{value:"occ",text:"Occitan (alternative)"},{value:"mon",text:"Mongolian"},{value:"ita_old",text:"Old Italian"},{value:"gla",text:"Scottish Gaelic"},{value:"frk",text:"Frankish"},{value:"enm",text:"Middle English"},{value:"deu_frak",text:"German (Fraktur)"},{value:"dan_frak",text:"Danish (Fraktur)"},{value:"chi_tra_vert",text:"Chinese (Traditional, Vertical)"},{value:"ceb",text:"Cebuano"},{value:"bre",text:"Breton"},{value:"swa",text:"Swahili"},{value:"que",text:"Quechua"},{value:"ltz",text:"Luxembourgish"},{value:"kat_old",text:"Old Georgian"},{value:"cos",text:"Corsican"}]}}}]})];export{Oc as displays,Nc as interfaces,Bc as layouts,zc as modules,Vc as operations,jc as panels};
|
|
22
|
+
*/const Tr=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Sr=[.001,0,0,.001,0,0],Er=1.35,Cr=1,Rr=2,Mr=4,Pr=16,Lr=32,Dr=64,Ir=128,Or=256,Nr={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Fr={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101},Br={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},jr=0,zr=1,Vr=2,Ur=3,Hr=3,$r=4,Wr={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Gr={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},qr=1,Kr=2,Xr=3,Yr=4,Qr=5,Jr={ERRORS:0,WARNINGS:1,INFOS:5},Zr={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,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},to=0,eo=1,io=2,so=3;let no=Jr.WARNINGS;function ao(t){Number.isInteger(t)&&(no=t)}function ro(){return no}function oo(t){no>=Jr.INFOS&&console.log(`Info: ${t}`)}function lo(t){no>=Jr.WARNINGS&&console.log(`Warning: ${t}`)}function ho(t){throw new Error(t)}function co(t,e){t||ho(e)}function uo(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function po(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&uo(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function go(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const fo=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class _o extends fo{constructor(t,e){super(t,"PasswordException"),this.code=e}}class mo extends fo{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class vo extends fo{constructor(t){super(t,"InvalidPDFException")}}class bo extends fo{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class yo extends fo{constructor(t){super(t,"FormatError")}}class wo extends fo{constructor(t){super(t,"AbortException")}}function xo(t){"object"==typeof t&&void 0!==t?.length||ho("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const a=Math.min(n+i,e),r=t.subarray(n,a);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function Ao(t){"string"!=typeof t&&ho("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class ko{static get isLittleEndian(){return go(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return go(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return go(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return go(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return go(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return go(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const To=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class So{static makeHexColor(t,e,i){return`#${To[t]}${To[e]}${To[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}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,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){const h=t[i+e],c=t[i+e+1];t[i+e]=h*s+c*a+o,t[i+e+1]=h*n+c*r+l}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3];let p=s*h+o,g=p,f=s*d+o,_=f,m=r*c+l,v=m,b=r*u+l,y=b;if(0!==n||0!==a){const t=n*h,e=n*d,i=a*c,s=a*u;p+=i,_+=i,f+=s,g+=s,m+=t,y+=t,b+=e,v+=e}i[0]=Math.min(i[0],p,f,g,_),i[1]=Math.min(i[1],m,b,v,y),i[2]=Math.max(i[2],p,f,g,_),i[3]=Math.max(i[3],m,b,v,y)}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 singularValueDecompose2dScale(t,e){const i=t[0],s=t[1],n=t[2],a=t[3],r=i**2+s**2,o=i*n+s*a,l=n**2+a**2,h=(r+l)/2,c=Math.sqrt(h**2-(r*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}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){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[i,n,s,a]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static#t(t,e,i,s,n,a,r,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*i)+u*s,g=c*(c*(c*n+3*l*a)+3*d*r)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,a,r,o,l,h,c,d){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,a,r,o,-c/h,d));const u=h**2-4*c*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,a,r,o,(-h+p)/g,d),this.#t(t,e,i,s,n,a,r,o,(-h-p)/g,d)}static bezierBoundingBox(t,e,i,s,n,a,r,o,l){l[0]=Math.min(l[0],t,r),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,r),l[3]=Math.max(l[3],e,o),this.#e(t,i,n,r,e,s,a,o,3*(3*(i-n)-t+r),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,r,e,s,a,o,3*(3*(s-a)-e+o),6*(e-2*s+a),3*(s-e),l)}}let Eo=null,Co=null;function Ro(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),xo(t)}const Mo="pdfjs_internal_id_";function Po(t,e,i){return Math.min(Math.max(t,e),i)}function Lo(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(xo(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce(((t,e)=>t+e),0)});const Do="http://www.w3.org/2000/svg";class Io{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Oo(t,e="text"){if(Vo(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class No{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=a,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,d,u,p,g,f,_;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+a,f=(t[3]-t[1])*i,_=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+a,f=(t[2]-t[0])*i,_=(t[3]-t[1])*i),this.transform=[h*i,c*i,d*i,u*i,p-h*i*o-d*i*l,g-c*i*o-u*i*l],this.width=f,this.height=_}get rawDims(){const t=this.viewBox;return go(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new No({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return So.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];So.applyTransform(e,this.transform);const i=[t[2],t[3]];return So.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return So.applyInverseTransform(i,this.transform),i}}class Fo extends fo{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Bo(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function jo(t){return"string"==typeof t&&/\.pdf$/i.test(t)}class zo{started=Object.create(null);times=[];time(t){t in this.started&&lo(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||lo(`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{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function Vo(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===i?.protocol||"https:"===i?.protocol}function Uo(t){t.preventDefault()}function Ho(t){t.preventDefault(),t.stopPropagation()}class $o{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,r+=c):"+"===l&&(a-=h,r-=c),new Date(Date.UTC(i,s,n,a,r,o))}}function Wo(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(lo(`Not a valid color format: "${t}"`),[0,0,0])}function Go(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform();return[e,i,s,n,a,r]}function qo(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,i,s,n,a,r]}function Ko(t,e,i=!1,s=!0){if(e instanceof No){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:a}=t,r=ko.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${n}px`,h=r?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,c=r?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(a.width=c,a.height=h):(a.width=h,a.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}class Xo{constructor(){const{pixelRatio:t}=Xo;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let a=1/0,r=1/0,o=1/0;(i=Xo.capPixels(i,n))>0&&(a=Math.sqrt(i/(t*e))),-1!==s&&(r=s/t,o=s/e);const l=Math.min(a,r,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const Yo=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Qo{#s=null;#n=null;#a;#r=null;#o=null;#l=null;static#h=null;constructor(t){this.#a=t,Qo.#h||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#a._uiManager._signal;t.addEventListener("contextmenu",Uo,{signal:e}),t.addEventListener("pointerdown",Qo.#c,{signal:e});const i=this.#r=document.createElement("div");i.className="buttons",t.append(i);const s=this.#a.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#a._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static#c(t){t.stopPropagation()}#u(t){this.#a._focusEventsAllowed=!1,Ho(t)}#p(t){this.#a._focusEventsAllowed=!0,Ho(t)}#g(t){const e=this.#a._uiManager._signal;t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#p.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Uo,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#a,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",Qo.#h[t]),this.#g(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#r.append(i)}get#f(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#g(e),this.#r.prepend(e,this.#f),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#g(e),this.#r.prepend(e,this.#f)}async addEditSignatureButton(t){const e=this.#l=await t.renderEditButton(this.#a);this.#g(e),this.#r.prepend(e,this.#f)}updateEditSignatureButton(t){this.#l&&(this.#l.title=t)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class Jo{#r=null;#s=null;#_;constructor(t){this.#_=t}#m(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Uo,{signal:this.#_._signal});const e=this.#r=document.createElement("div");return e.className="buttons",t.append(e),this.#v(),t}#b(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const a=n.x+(e?n.width:0);t>i?(s=a,i=t):e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#b(e,i),{style:a}=this.#s||=this.#m();t.append(this.#s),a.insetInlineEnd=100*s+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#v(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#_._signal;t.addEventListener("contextmenu",Uo,{signal:i}),t.addEventListener("click",(()=>{this.#_.highlightSelection("floating_button")}),{signal:i}),this.#r.append(t)}}function Zo(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class tl{#y=0;get id(){return"pdfjs_internal_editor_"+this.#y++}}class el{#w=Ro();#y=0;#x=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return go(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#A(t,e){this.#x||=new Map;let i=this.#x.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#w}_${this.#y++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Oo(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=el._isSVGFittingCanvas,s=new FileReader,n=new Image,a=new Promise(((t,a)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=a}));s.readAsDataURL(t),await a}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){lo(t),i=null}return this.#x.set(t,i),i&&this.#x.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#A(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#A(t,t)}async getFromBlob(t,e){const i=await e;return this.#A(t,i)}async getFromId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#x||=new Map;let i=this.#x.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#w}_${this.#y++}`,refCounter:1,isSvg:!1},this.#x.set(t,i),this.#x.set(i.id,i),i}getSvgUrl(t){const e=this.#x.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#w}_`)}}class il{#k=[];#T=!1;#S;#E=-1;constructor(t=128){this.#S=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){if(s&&t(),this.#T)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#E)return this.#k.length>0&&(this.#k.length=0),this.#E=0,void this.#k.push(o);if(a&&this.#k[this.#E].type===n)return r&&(o.undo=this.#k[this.#E].undo),void(this.#k[this.#E]=o);const l=this.#E+1;l===this.#S?this.#k.splice(0,1):(this.#E=l,l<this.#k.length&&this.#k.splice(l)),this.#k.push(o)}undo(){if(-1===this.#E)return;this.#T=!0;const{undo:t,post:e}=this.#k[this.#E];t(),e?.(),this.#T=!1,this.#E-=1}redo(){if(this.#E<this.#k.length-1){this.#E+=1,this.#T=!0;const{cmd:t,post:e}=this.#k[this.#E];t(),e?.(),this.#T=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#k.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#k[e].type!==t)return this.#k.splice(e+1,this.#E-e),void(this.#E=e);this.#k.length=0,this.#E=-1}}destroy(){this.#k=null}}class sl{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ko.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#C(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#C(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:a=[],checker:r=null}}=i;r&&!r(t,e)||(s.bind(t,...a,e)(),n||Ho(e))}}class nl{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,Wo(s))}e.remove()}(t),go(this,"_colors",t)}convert(t){const e=Wo(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return nl._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?So.makeHexColor(...e):t}}class al{#R=new AbortController;#M=null;#P=new Map;#L=new Map;#D=null;#I=null;#O=null;#N=new il;#F=null;#B=null;#j=0;#z=new Set;#V=null;#U=null;#H=new Set;_editorUndoBar=null;#$=!1;#W=!1;#G=!1;#q=null;#K=null;#X=null;#Y=null;#Q=!1;#J=null;#Z=new tl;#tt=!1;#et=!1;#it=null;#st=null;#nt=null;#at=null;#rt=null;#ot=Fr.NONE;#lt=new Set;#ht=null;#ct=null;#dt=null;#ut=null;#pt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#gt=[0,0];#ft=null;#_t=null;#mt=null;#vt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=al.prototype,e=t=>t.#_t.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return go(this,"_keyboardManager",new sl([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#_t.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#_t.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,a,r,o,l,h,c,d,u,p){const g=this._signal=this.#R.signal;this.#_t=t,this.#mt=e,this.#D=i,this.#ct=s,this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:g}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),n._on("setpreference",this.onSetPreference.bind(this),{signal:g}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:g}),this.#bt(),this.#yt(),this.#wt(),this.#I=a.annotationStorage,this.#q=a.filterFactory,this.#dt=r,this.#Y=o||null,this.#$=l,this.#W=h,this.#G=c,this.#rt=d||null,this.viewParameters={realScale:Io.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==p}destroy(){this.#vt?.resolve(),this.#vt=null,this.#R?.abort(),this.#R=null,this._signal=null;for(const t of this.#L.values())t.destroy();this.#L.clear(),this.#P.clear(),this.#H.clear(),this.#at?.clear(),this.#M=null,this.#lt.clear(),this.#N.destroy(),this.#D?.destroy(),this.#ct?.destroy(),this.#J?.hide(),this.#J=null,this.#nt?.destroy(),this.#nt=null,this.#K&&(clearTimeout(this.#K),this.#K=null),this.#ft&&(clearTimeout(this.#ft),this.#ft=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#rt}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#G}get hcmFilter(){return go(this,"hcmFilter",this.#dt?this.#q.addHCMFilter(this.#dt.foreground,this.#dt.background):"none")}get direction(){return go(this,"direction",getComputedStyle(this.#_t).direction)}get highlightColors(){return go(this,"highlightColors",this.#Y?new Map(this.#Y.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return go(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#B=t}setMainHighlightColorPicker(t){this.#nt=t}editAltText(t,e=!1){this.#D?.editAltText(this,t,e)}getSignature(t){this.#ct?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#ct}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#G=e}onPageChanging({pageNumber:t}){this.#j=t-1}focusMainContainer(){this.#_t.focus()}findParent(t,e){for(const i of this.#L.values()){const{x:s,y:n,width:a,height:r}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&e>=n&&e<=n+r)return i}return null}disableUserSelect(t=!1){this.#mt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#H.add(t)}removeShouldRescale(t){this.#H.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Io.PDF_TO_CSS_UNITS;for(const t of this.#H)t.onScaleChanging();this.#B?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#xt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#At(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#L.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a}=e,r=e.toString(),o=this.#xt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#At(o),c=this.#ot===Fr.NONE,d=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a,text:r}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(Fr.HIGHLIGHT,d):d()}#kt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#xt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#J||=new Jo(this),this.#J.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#I||this.#I.has(t.id)||this.#I.setValue(t.id,t)}#Tt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ht&&(this.#J?.hide(),this.#ht=null,this.#St({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ht)return;const i=this.#xt(t).closest(".textLayer");if(i){if(this.#J?.hide(),this.#ht=e,this.#St({hasSelectedText:!0}),(this.#ot===Fr.HIGHLIGHT||this.#ot===Fr.NONE)&&(this.#ot===Fr.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Q=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#ot===Fr.HIGHLIGHT?this.#At(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#Et("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ht&&(this.#J?.hide(),this.#ht=null,this.#St({hasSelectedText:!1}))}#Et(t=""){this.#ot===Fr.HIGHLIGHT?this.highlightSelection(t):this.#$&&this.#kt()}#bt(){document.addEventListener("selectionchange",this.#Tt.bind(this),{signal:this._signal})}#Ct(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Rt(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Q&&(this.#Q=!1,this.#Et("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#lt)if(e.div.contains(t)){this.#st=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#st)return;const[t,e]=this.#st;this.#st=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#wt(){if(this.#it)return;this.#it=new AbortController;const t=this.combinedSignal(this.#it);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Mt(){this.#it?.abort(),this.#it=null}#Pt(){if(this.#F)return;this.#F=new AbortController;const t=this.combinedSignal(this.#F);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Lt(){this.#F?.abort(),this.#F=null}#yt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#wt(),this.#Pt()}removeEditListeners(){this.#Mt(),this.#Lt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#U)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#U)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#M?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#lt){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#U)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void lo(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#Dt(e);this.#It(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){lo(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#ot===Fr.NONE||this.isEditorHandlingKeyboard||al._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Q&&(this.#Q=!1,this.#Et("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#St(t){Object.entries(t).some((([t,e])=>this.#pt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#pt,t)}),this.#ot===Fr.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Ot([[Br.HIGHLIGHT_FREE,!0]]))}#Ot(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Pt(),this.#St({isEditing:this.#ot!==Fr.NONE,isEmpty:this.#Nt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Rt(),this.#Lt(),this.#St({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#U){this.#U=t;for(const t of this.#U)this.#Ot(t.defaultPropertiesToUpdate)}}getId(){return this.#Z.id}get currentLayer(){return this.#L.get(this.#j)}getLayer(t){return this.#L.get(t)}get currentPageIndex(){return this.#j}addLayer(t){this.#L.set(t.pageIndex,t),this.#tt?t.enable():t.disable()}removeLayer(t){this.#L.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#ot!==t&&(!this.#vt||(await this.#vt.promise,this.#vt))){if(this.#vt=Promise.withResolvers(),this.#B?.commitOrRemove(),this.#ot=t,t===Fr.NONE)return this.setEditingState(!1),this.#Ft(),this._editorUndoBar?.hide(),void this.#vt.resolve();t===Fr.SIGNATURE&&await(this.#ct?.loadSignatures()),this.setEditingState(!0),await this.#Bt(),this.unselectAll();for(const e of this.#L.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#vt.resolve();for(const t of this.#P.values())t.annotationElementId===e||t.id===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#vt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#ot&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#U){switch(t){case Br.CREATE:return void this.currentLayer.addNewEditor(e);case Br.HIGHLIGHT_DEFAULT_COLOR:this.#nt?.updateColor(e);break;case Br.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ut||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#lt)i.updateParams(t,e);for(const i of this.#U)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#P.values())i.editorType===t&&i.show(e);(this.#ut?.get(Br.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Ot([[Br.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#et!==t){this.#et=t;for(const e of this.#L.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Bt(){if(!this.#tt){this.#tt=!0;const t=[];for(const e of this.#L.values())t.push(e.enable());await Promise.all(t);for(const t of this.#P.values())t.enable()}}#Ft(){if(this.unselectAll(),this.#tt){this.#tt=!1;for(const t of this.#L.values())t.disable();for(const t of this.#P.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#P.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#P.get(t)}addEditor(t){this.#P.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#K&&clearTimeout(this.#K),this.#K=setTimeout((()=>{this.focusMainContainer(),this.#K=null}),0)),this.#P.delete(t.id),t.annotationElementId&&this.#at?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#z.has(t.annotationElementId)||this.#I?.remove(t.id)}addDeletedAnnotationElement(t){this.#z.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#z.has(t)}removeDeletedAnnotationElement(t){this.#z.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Dt(t){const e=this.#L.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#M!==t&&(this.#M=t,t&&this.#Ot(t.propertiesToUpdate))}get#jt(){let t=null;for(t of this.#lt);return t}updateUI(t){this.#jt===t&&this.#Ot(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Ot(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#lt.has(t))return this.#lt.delete(t),t.unselect(),void this.#St({hasSelectedEditor:this.hasSelection});this.#lt.add(t),t.select(),this.#Ot(t.propertiesToUpdate),this.#St({hasSelectedEditor:!0})}setSelected(t){this.#B?.commitOrRemove();for(const e of this.#lt)e!==t&&e.unselect();this.#lt.clear(),this.#lt.add(t),t.select(),this.#Ot(t.propertiesToUpdate),this.#St({hasSelectedEditor:!0})}isSelected(t){return this.#lt.has(t)}get firstSelectedEditor(){return this.#lt.values().next().value}unselect(t){t.unselect(),this.#lt.delete(t),this.#St({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#lt.size}get isEnterHandled(){return 1===this.#lt.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#St({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Nt()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#St({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Nt()})}addCommands(t){this.#N.add(t),this.#St({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Nt()})}cleanUndoStack(t){this.#N.cleanType(t)}#Nt(){if(0===this.#P.size)return!0;if(1===this.#P.size)for(const t of this.#P.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#lt],i=()=>{for(const t of e)this.#Dt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#M?.commitOrRemove()}hasSomethingToControl(){return this.#M||this.hasSelection}#It(t){for(const t of this.#lt)t.unselect();this.#lt.clear();for(const e of t)e.isEmpty()||(this.#lt.add(e),e.select());this.#St({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#lt)t.commit();this.#It(this.#P.values())}unselectAll(){if((!this.#M||(this.#M.commitOrRemove(),this.#ot===Fr.NONE))&&!this.#B?.commitOrRemove()&&this.hasSelection){for(const t of this.#lt)t.unselect();this.#lt.clear(),this.#St({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#gt[0]+=t,this.#gt[1]+=e;const[s,n]=this.#gt,a=[...this.#lt];this.#ft&&clearTimeout(this.#ft),this.#ft=setTimeout((()=>{this.#ft=null,this.#gt[0]=this.#gt[1]=0,this.addCommands({cmd:()=>{for(const t of a)this.#P.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of a)this.#P.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})}),1e3);for(const i of a)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#V=new Map;for(const t of this.#lt)this.#V.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#V)return!1;this.disableUserSelect(!1);const t=this.#V;this.#V=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},a]of t)a.newX=i,a.newY=s,a.newPageIndex=n,e||=i!==a.savedX||s!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#P.has(t.id)){const n=this.#L.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:a}]of t)i(e,s,n,a)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:a}]of t)i(e,s,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#V)for(const i of this.#V.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#lt.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#M===t}getActive(){return this.#M}getMode(){return this.#ot}get imageManager(){return go(this,"imageManager",new el)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-s)/a,y:1-(t+r-i)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-i)/n,y:1-(e+o-s)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-s)/a,y:(t-i)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-i)/n,y:(e-s)/a,width:r/n,height:o/a})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&o.push(r(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#O||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#O?.delete(t)}renderAnnotationElement(t){const e=this.#O?.get(t.data.id);if(!e)return;const i=this.#I.getRawValue(e);i&&(this.#ot!==Fr.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const s=this.#at?.get(t);s&&(s.setCanvas(e,i),this.#at.delete(t))}addMissingCanvas(t,e){(this.#at||=new Map).set(t,e)}}class rl{#o=null;#zt=!1;#Vt=null;#Ut=null;#Ht=null;#$t=null;#Wt=!1;#Gt=null;#a=null;#qt=null;#Kt=null;#Xt=!1;static#Yt=null;static _l10n=null;constructor(t){this.#a=t,this.#Xt=t._uiManager.useNewAltTextFlow,rl.#Yt||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){rl._l10n??=t}async render(){const t=this.#Vt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#Ut=document.createElement("span");t.append(e),this.#Xt?(t.classList.add("new"),t.setAttribute("data-l10n-id",rl.#Yt.missing),e.setAttribute("data-l10n-id",rl.#Yt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#a._uiManager._signal;t.addEventListener("contextmenu",Uo,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a),this.#Xt&&this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Qt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#Wt=!0,s(e))}),{signal:i}),await this.#Jt(),t}get#Qt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Vt&&(this.#Vt.focus({focusVisible:this.#Wt}),this.#Wt=!1)}isEmpty(){return this.#Xt?null===this.#o:!this.#o&&!this.#zt}hasData(){return this.#Xt?null!==this.#o||!!this.#qt:this.isEmpty()}get guessedText(){return this.#qt}async setGuessedText(t){null===this.#o&&(this.#qt=t,this.#Kt=await rl._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Jt())}toggleAltTextBadge(t=!1){if(!this.#Xt||this.#o)return this.#Gt?.remove(),void(this.#Gt=null);if(!this.#Gt){const t=this.#Gt=document.createElement("div");t.className="noAltTextBadge",this.#a.div.append(t)}this.#Gt.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#qt!==e||(e=this.#Kt),{altText:e,decorative:this.#zt,guessedText:this.#qt,textWithDisclaimer:this.#Kt}}get data(){return{altText:this.#o,decorative:this.#zt}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#qt=i,this.#Kt=s),this.#o===t&&this.#zt===e||(n||(this.#o=t,this.#zt=e),this.#Jt())}toggle(t=!1){this.#Vt&&(!t&&this.#$t&&(clearTimeout(this.#$t),this.#$t=null),this.#Vt.disabled=!t)}shown(){this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Qt}})}destroy(){this.#Vt?.remove(),this.#Vt=null,this.#Ut=null,this.#Ht=null,this.#Gt?.remove(),this.#Gt=null}async#Jt(){const t=this.#Vt;if(!t)return;if(this.#Xt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",rl.#Yt[this.#Qt]),this.#Ut?.setAttribute("data-l10n-id",rl.#Yt[`${this.#Qt}-label`]),!this.#o)return void this.#Ht?.remove()}else{if(!this.#o&&!this.#zt)return t.classList.remove("done"),void this.#Ht?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Ht;if(!e){this.#Ht=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#a.id}`;const i=100,s=this.#a._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#$t),this.#$t=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#$t=setTimeout((()=>{this.#$t=null,this.#Ht.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#$t&&(clearTimeout(this.#$t),this.#$t=null),this.#Ht?.classList.remove("show")}),{signal:s})}this.#zt?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#a.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class ol{#_t;#Zt=!1;#te=null;#ee;#ie;#se;#ne;#ae=null;#re;#oe=null;#le;#he=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:a=null,signal:r}){this.#_t=t,this.#te=i,this.#ee=e,this.#ie=s,this.#se=n,this.#ne=a,this.#le=new AbortController,this.#re=AbortSignal.any([r,this.#le.signal]),t.addEventListener("touchstart",this.#ce.bind(this),{passive:!1,signal:this.#re})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Xo.pixelRatio}#ce(t){if(this.#ee?.())return;if(1===t.touches.length){if(this.#ae)return;const t=this.#ae=new AbortController,e=AbortSignal.any([this.#re,t.signal]),i=this.#_t,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#ae?.abort(),this.#ae=null)};return i.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(Ho(t),n(t))}),s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!this.#he){this.#he=new AbortController;const t=AbortSignal.any([this.#re,this.#he.signal]),e=this.#_t,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#de.bind(this),i);const s=this.#ue.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",Ho,i),e.addEventListener("pointermove",Ho,i),e.addEventListener("pointercancel",Ho,i),e.addEventListener("pointerup",Ho,i),this.#ie?.()}if(Ho(t),2!==t.touches.length||this.#te?.())return void(this.#oe=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#oe={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#de(t){if(!this.#oe||2!==t.touches.length)return;Ho(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:s,screenY:n}=e,{screenX:a,screenY:r}=i,o=this.#oe,{touch0X:l,touch0Y:h,touch1X:c,touch1Y:d}=o,u=c-l,p=d-h,g=a-s,f=r-n,_=Math.hypot(g,f)||1,m=Math.hypot(u,p)||1;if(!this.#Zt&&Math.abs(m-_)<=ol.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=n,o.touch1X=a,o.touch1Y=r,!this.#Zt)return void(this.#Zt=!0);const v=[(s+a)/2,(n+r)/2];this.#se?.(v,m,_)}#ue(t){t.touches.length>=2||(this.#he&&(this.#he.abort(),this.#he=null,this.#ne?.()),this.#oe&&(Ho(t),this.#oe=null,this.#Zt=!1))}destroy(){this.#le?.abort(),this.#le=null,this.#ae?.abort(),this.#ae=null}}class ll{#pe=null;#ge=null;#o=null;#fe=!1;#_e=null;#me="";#ve=!1;#be=null;#ye=null;#we=null;#xe=null;#Ae="";#ke=!1;#Te=null;#Se=!1;#Ee=!1;#Ce=!1;#Re=null;#Me=0;#Pe=0;#Le=null;#De=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#Ie=!1;#Oe=ll._zIndex++;static _borderLineWidth=-1;static _colorManager=new nl;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ll.prototype._resizeWithKeyboard,e=al.TRANSLATE_SMALL,i=al.TRANSLATE_BIG;return go(this,"_resizerKeyboardManager",new sl([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],ll.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,a];const[r,o]=this.parentDimensions;this.x=t.x/r,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return go(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new hl({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(ll._l10n??=t,ll._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==ll._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ll._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ho("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Ie}set _isDraggable(t){this.#Ie=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Oe}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Ne(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ke?this.#ke=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#Fe([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#Fe(this.parentDimensions,t,e)}translateInPage(t,e){this.#Te||=[this.x,this.y,this.width,this.height],this.#Fe(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#Te||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:r}=this;const[o,l]=this.getBaseTranslation();a+=o,r+=l;const{style:h}=i;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this._onTranslating(a,r),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Te&&(this.#Te[0]!==this.x||this.#Te[1]!==this.y)}get _hasBeenResized(){return!!this.#Te&&(this.#Te[2]!==this.width||this.#Te[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ll,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:a,width:r,height:o}=this;if(r*=i,o*=s,n*=i,a*=s,this._mustFixPosition)switch(t){case 0:n=Po(n,0,i-r),a=Po(a,0,s-o);break;case 90:n=Po(n,0,i-o),a=Po(a,r,s);break;case 180:n=Po(n,r,i),a=Po(a,o,s);break;case 270:n=Po(n,o,i),a=Po(a,0,s-r)}this.x=n/=i,this.y=a/=s;const[l,h]=this.getBaseTranslation();n+=l,a+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#Be(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return ll.#Be(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ll.#Be(t,e,360-this.parentRotation)}#je(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#ve||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ve&&e.endsWith("%");if(s&&n)return;const[a,r]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/a).toFixed(2)}%`),this.#ve||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#ze(){if(this.#be)return;this.#be=document.createElement("div"),this.#be.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#be.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Ve.bind(this,i),{signal:e}),t.addEventListener("contextmenu",Uo,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#be)}#Ve(t,e){e.preventDefault();const{isMac:i}=ko.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#ye=[e.screenX,e.screenY];const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Ue.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Ho,{passive:!1,signal:a}),window.addEventListener("contextmenu",Uo,{signal:a}),this.#we={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const r=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=r,this.div.style.cursor=o,this.#He()};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}#$e(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*i,a*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#He(){if(!this.#we)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#we;this.#we=null;const n=this.x,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===i&&o===s||this.addCommands({cmd:this.#$e.bind(this,n,a,r,o),undo:this.#$e.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Ue(t,e){const[i,s]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,l=ll.MIN_SIZE/i,h=ll.MIN_SIZE/s,c=this.#je(this.rotation),d=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=this.#je(360-this.rotation);let p,g,f=!1,_=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":_=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":_=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const m=p(r,o),v=g(r,o);let b=d(...v);const y=ll._round(n+b[0]),w=ll._round(a+b[1]);let x,A,k=1,T=1;if(e.fromKeyboard)({deltaX:x,deltaY:A}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#ye;[x,A]=this.screenToPageTranslation(t-s,i-n),this.#ye[0]=t,this.#ye[1]=i}if([x,A]=((t,e)=>[u[0]*t+u[2]*e,u[1]*t+u[3]*e])(x/i,A/s),f){const t=Math.hypot(r,o);k=T=Math.max(Math.min(Math.hypot(v[0]-m[0]-x,v[1]-m[1]-A)/t,1/r,1/o),l/r,h/o)}else _?k=Po(Math.abs(v[0]-m[0]-x),l,1)/r:T=Po(Math.abs(v[1]-m[1]-A),h,1)/o;const S=ll._round(r*k),E=ll._round(o*T);b=d(...g(S,E));const C=y-b[0],R=w-b[1];this.#Te||=[this.x,this.y,this.width,this.height],this.width=S,this.height=E,this.x=C,this.y=R,this.setDims(i*S,s*E),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ee||(this._editToolbar=new Qo(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(rl.initialize(ll._l10n),this.#o=new rl(this),this.#pe&&(this.#o.data=this.#pe,this.#pe=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#fe?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#We();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[s,n]=this.getInitialTranslation();return this.translate(s,n),Zo(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#De||=new ol({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Ge.bind(this),onPinching:this.#qe.bind(this),onPinchEnd:this.#Ke.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),t}#Ge(){this.#we={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#qe(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#je(this.rotation),a=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[r,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,d=this.height,u=ll.MIN_SIZE/r,p=ll.MIN_SIZE/o;s=Math.max(Math.min(s,1/c,1/d),u/c,p/d);const g=ll._round(c*s),f=ll._round(d*s);if(g===c&&f===d)return;this.#Te||=[l,h,c,d];const _=a(c/2,d/2),m=ll._round(l+_[0]),v=ll._round(h+_[1]),b=a(g/2,f/2);this.x=m-b[0],this.y=v-b[1],this.width=g,this.height=f,this.setDims(r*g,o*f),this.fixAndSetPosition(),this._onResizing()}#Ke(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#He()}pointerdown(t){const{isMac:e}=ko.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ke=!0,this._isDraggable?this.#Xe(t):this.#Ye(t))}#Ye(t){const{isMac:e}=ko.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#Xe(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),a={capture:!0,passive:!1,signal:n},r=t=>{s.abort(),this.#_e=null,this.#ke=!1,this._uiManager.endDragSession()||this.#Ye(t),i&&this._onStopDragging()};e&&(this.#Me=t.clientX,this.#Pe=t.clientY,this.#_e=t.pointerId,this.#me=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#_e)return void Ho(t);const[a,r]=this.screenToPageTranslation(e-this.#Me,s-this.#Pe);this.#Me=e,this.#Pe=s,this._uiManager.dragSelectedEditors(a,r)}),a),window.addEventListener("touchmove",Ho,a),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#me&&(this.#De||t.isPrimary)&&r(t),Ho(t)}),a));const o=t=>{this.#_e&&this.#_e!==t.pointerId?Ho(t):r(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Re&&clearTimeout(this.#Re),this.#Re=setTimeout((()=>{this.#Re=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/s,h=e/s,c=this.x*n,d=this.y*a,u=this.width*n,p=this.height*a;switch(i){case 0:return[c+l+r,a-d-h-p+o,c+l+u+r,a-d-h+o];case 90:return[c+h+r,a-d+l+o,c+h+p+r,a-d+l+u+o];case 180:return[c-l-u+r,a-d+h+o,c-l+r,a-d+h+p+o];case 270:return[c-h-p+r,a-d-l-u+o,c-h+r,a-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,a]=t,r=n-i,o=a-s;switch(this.rotation){case 0:return[i,e-a,r,o];case 90:return[i,e-s,o,r];case 180:return[n,e-s,r,o];case 270:return[n,e-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#Ee=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#Ee=!1,!0)}isInEditMode(){return this.#Ee}shouldGetKeyboardEvents(){return this.#Ce}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:a}=window;return e<a&&s>0&&t<n&&i>0}#We(){if(this.#xe||!this.div)return;this.#xe=new AbortController;const t=this._uiManager.combinedSignal(this.#xe);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#We()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){ho("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#pe=t.accessibilityData,s._isCopy=t.isCopy||!1;const[n,a]=s.pageDimensions,[r,o,l,h]=s.getRectInCurrentCoords(t.rect,a);return s.x=r/n,s.y=o/a,s.width=l/n,s.height=h/a,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#xe?.abort(),this.#xe=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Re&&(clearTimeout(this.#Re),this.#Re=null),this.#Ne(),this.removeEditToolbar(),this.#Le){for(const t of this.#Le.values())clearTimeout(t);this.#Le=null}this.parent=null,this.#De?.destroy(),this.#De=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#ze(),this.#be.classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#we={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#be.children;if(!this.#ge){this.#ge=Array.from(e);const t=this.#Qe.bind(this),i=this.#Je.bind(this),s=this._uiManager._signal;for(const e of this.#ge){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ze.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",ll._l10nResizer[n])}}const i=this.#ge[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#ge.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#be.append(this.#be.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#be.firstChild.before(this.#be.lastChild);let t=0;for(const i of e){const e=this.#ge[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ll._l10nResizer[e])}}this.#ti(0),this.#Ce=!0,this.#be.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#Qe(t){ll._resizerKeyboardManager.exec(this,t)}#Je(t){this.#Ce&&t.relatedTarget?.parentNode!==this.#be&&this.#Ne()}#Ze(t){this.#Ae=this.#Ce?t:""}#ti(t){if(this.#ge)for(const e of this.#ge)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Ce&&this.#Ue(this.#Ae,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Ne(){this.#Ce=!1,this.#ti(-1),this.#He()}_stopResizingWithKeyboard(){this.#Ne(),this.div.focus()}select(){this.isSelected&&this._editToolbar||(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})))}unselect(){this.isSelected&&(this.isSelected=!1,this.#be?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#Se}set isEditing(t){this.#Se=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ve=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#Le||=new Map;const{action:e}=t;let i=this.#Le.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Le.delete(e),0===this.#Le.size&&(this.#Le=null)}),ll._telemetryTimeout),void this.#Le.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#fe=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#fe=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class hl extends ll{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const cl=3285377520,dl=4294901760,ul=65535;class pl{constructor(t){this.h1=t?4294967295&t:cl,this.h2=t?4294967295&t:cl}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,a=new Uint32Array(e.buffer,0,s);let r=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(r=a[t],r=r*c&dl|r*u&ul,r=r<<15|r>>>17,r=r*d&dl|r*p&ul,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[t],o=o*c&dl|o*u&ul,o=o<<15|o>>>17,o=o*d&dl|o*p&ul,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(r=0,n){case 3:r^=e[4*s+2]<<16;case 2:r^=e[4*s+1]<<8;case 1:r^=e[4*s],r=r*c&dl|r*u&ul,r=r<<15|r>>>17,r=r*d&dl|r*p&ul,1&s?l^=r:h^=r}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&dl|36045*t&ul,e=4283543511*e&dl|(2950163797*(e<<16|t>>>16)&dl)>>>16,t^=e>>>1,t=444984403*t&dl|60499*t&ul,e=3301882366*e&dl|(3120437893*(e<<16|t>>>16)&dl)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const gl=Object.freeze({map:null,hash:"",transfer:void 0});class fl{#ei=!1;#ii=null;#si=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#si.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#si.get(t)}remove(t){if(this.#si.delete(t),0===this.#si.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#si.values())if(t instanceof ll)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#si.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#si.set(t,e);s&&this.#ni(),e instanceof ll&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#si.has(t)}get size(){return this.#si.size}#ni(){this.#ei||(this.#ei=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#ei&&(this.#ei=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new _l(this)}get serializable(){if(0===this.#si.size)return gl;const t=new Map,e=new pl,i=[],s=Object.create(null);let n=!1;for(const[i,a]of this.#si){const r=a instanceof ll?a.serialize(!1,s):a;r&&(t.set(i,r),e.update(`${i}:${JSON.stringify(r)}`),n||=!!r.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:gl}get editorStats(){let t=null;const e=new Map;for(const i of this.#si.values()){if(!(i instanceof ll))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const a=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=a.get(t);i||(i=new Map,a.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#ii=null}get modifiedIds(){if(this.#ii)return this.#ii;const t=[];for(const e of this.#si.values())e instanceof ll&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#ii={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#si.entries()}}class _l extends fl{#ai;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ai={map:n,hash:i,transfer:s}}get print(){ho("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ai}get modifiedIds(){return go(this,"modifiedIds",{ids:new Set,hash:""})}}class ml{#ri=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ri.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#ri.has(t.loadedName))if(co(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:s,style:n}=t,a=new FontFace(e,s,n);this.addNativeFontFace(a);try{await a.load(),this.#ri.add(e),i?.(t)}catch{lo(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else ho("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw lo(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return go(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return go(this,"isSyncFontLoadingSupported",Tr||ko.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(co(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return go(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=s(c,976,h.length,h);const d=1482184792;let u=i(c,16);for(n=0,a=h.length-3;n<a;n+=4)u=u-d+i(h,n)|0;var p;n<h.length&&(u=u-d+i(h+"XXX",n)|0),c=s(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return lo("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{f.remove(),e.complete()}))}}class vl{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this._inspectFont=e}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._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Lo(this.data)});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){lo(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}function bl(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const yl=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,wl=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[s,n,...a]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(n))return!1;const r=a.length;let o=!0;switch(n.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return 0===r;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(4!==r)return!1;o=!1;break;default:return!1}for(const t of a)if(!("number"==typeof t||o&&null===t))return!1;return!0}.bind(null,yl,(t=>"object"==typeof t&&"string"==typeof t?.name));class xl{#oi=new Map;#li=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#li.then((()=>{for(const[t]of this.#oi)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void lo("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}this.#oi.set(e,s)}removeEventListener(t,e){const i=this.#oi.get(e);i?.(),this.#oi.delete(e)}terminate(){for(const[,t]of this.#oi)t?.();this.#oi.clear()}}const Al=1,kl=2,Tl=1,Sl=2,El=3,Cl=4,Rl=5,Ml=6,Pl=7,Ll=8;function Dl(){}function Il(t){if(t instanceof wo||t instanceof vo||t instanceof _o||t instanceof bo||t instanceof mo)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||ho('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new wo(t.message);case"InvalidPDFException":return new vo(t.message);case"PasswordException":return new _o(t.message,t.code);case"ResponseException":return new bo(t.message,t.status,t.missing);case"UnknownErrorException":return new mo(t.message,t.details)}return new mo(t.message,t.toString())}class Ol{#hi=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#ci.bind(this),{signal:this.#hi.signal})}#ci({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#di(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Al)i.resolve(t.data);else{if(t.callback!==kl)throw new Error("Unexpected callback case");i.reject(Il(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:Al,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:kl,callbackId:t.callbackId,reason:Il(e)})}))}else t.streamId?this.#ui(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,a=this.sourceName,r=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:r,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:a,targetName:r,stream:Ml,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{co(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:a,targetName:r,stream:Tl,streamId:n,reason:Il(t)}),e.promise}},i)}#ui(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t,a=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Cl,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:El,streamId:e}),delete a.streamSinks[e])},error(t){co(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Rl,streamId:e,reason:Il(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(r,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ll,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ll,streamId:e,reason:Il(t)})}))}#di(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case Ll:t.success?a.startCall.resolve():a.startCall.reject(Il(t.reason));break;case Pl:t.success?a.pullCall.resolve():a.pullCall.reject(Il(t.reason));break;case Ml:if(!r){n.postMessage({sourceName:i,targetName:s,stream:Pl,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||Dl).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Pl,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Pl,streamId:e,reason:Il(t)})}));break;case Cl:if(co(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case El:if(co(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#pi(a,e);break;case Rl:co(a,"error should have stream controller"),a.controller.error(Il(t.reason)),this.#pi(a,e);break;case Sl:t.success?a.cancelCall.resolve():a.cancelCall.reject(Il(t.reason)),this.#pi(a,e);break;case Tl:if(!r)break;const o=Il(t.reason);Promise.try(r.onCancel||Dl,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Sl,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Sl,streamId:e,reason:Il(t)})})),r.sinkCapability.reject(o),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#pi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#hi?.abort(),this.#hi=null}}class Nl{#gi=!1;constructor({enableHWA:t=!1}){this.#gi=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#gi})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}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){ho("Abstract method `_createCanvas` called.")}}class Fl extends Nl{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class Bl{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("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._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){ho("Abstract method `_fetch` called.")}}class jl extends Bl{async _fetch(t){const e=await Oo(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Ao(e)}}class zl{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class Vl extends zl{#fi;#_i;#mi;#vi;#bi;#yi;#y=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#vi=t,this.#bi=e}get#x(){return this.#_i||=new Map}get#wi(){return this.#yi||=new Map}get#xi(){if(!this.#mi){const t=this.#bi.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#bi.createElementNS(Do,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#mi=this.#bi.createElementNS(Do,"defs"),t.append(i),i.append(this.#mi),this.#bi.body.append(t)}return this.#mi}#Ai(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),a=new Array(256),r=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,a[t]=i[t]/255,r[t]=s[t]/255;return[n.join(","),a.join(","),r.join(",")]}#ki(t){if(void 0===this.#fi){this.#fi="";const t=this.#bi.URL;t!==this.#bi.baseURI&&(Bo(t)?lo('#createUrl: ignore "data:"-URL for performance reasons.'):this.#fi=po(t,""))}return`url(${this.#fi}#${t})`}addFilter(t){if(!t)return"none";let e=this.#x.get(t);if(e)return e;const[i,s,n]=this.#Ai(t),a=1===t.length?i:`${i}${s}${n}`;if(e=this.#x.get(a),e)return this.#x.set(t,e),e;const r=`g_${this.#vi}_transfer_map_${this.#y++}`,o=this.#ki(r);this.#x.set(t,o),this.#x.set(a,o);const l=this.#Ti(r);return this.#Si(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#wi.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#wi.set(s,n)),!t||!e)return n.url;const a=this.#Ei(t);t=So.makeHexColor(...a);const r=this.#Ei(e);if(e=So.makeHexColor(...r),this.#xi.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#vi}_hcm_filter`,c=n.filter=this.#Ti(h);this.#Si(l,l,l,c),this.#Ci(c);const d=(t,e)=>{const i=a[t]/255,s=r[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#Si(d(0,5),d(1,5),d(2,5),c),n.url=this.#ki(h),n.url}addAlphaFilter(t){let e=this.#x.get(t);if(e)return e;const[i]=this.#Ai([t]),s=`alpha_${i}`;if(e=this.#x.get(s),e)return this.#x.set(t,e),e;const n=`g_${this.#vi}_alpha_map_${this.#y++}`,a=this.#ki(n);this.#x.set(t,a),this.#x.set(s,a);const r=this.#Ti(n);return this.#Ri(i,r),a}addLuminosityFilter(t){let e,i,s=this.#x.get(t||"luminosity");if(s)return s;if(t?([e]=this.#Ai([t]),i=`luminosity_${e}`):i="luminosity",s=this.#x.get(i),s)return this.#x.set(t,s),s;const n=`g_${this.#vi}_luminosity_map_${this.#y++}`,a=this.#ki(n);this.#x.set(t,a),this.#x.set(i,a);const r=this.#Ti(n);return this.#Mi(r),t&&this.#Ri(e,r),a}addHighlightHCMFilter(t,e,i,s,n){const a=`${e}-${i}-${s}-${n}`;let r=this.#wi.get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},this.#wi.set(t,r)),!e||!i)return r.url;const[o,l]=[e,i].map(this.#Ei.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,u]=[s,n].map(this.#Ei.bind(this));c<h&&([h,c,d,u]=[c,h,u,d]),this.#xi.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(c-h)/i,a=t/255,r=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=a+t*r;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#vi}_hcm_${t}_filter`,f=r.filter=this.#Ti(g);return this.#Ci(f),this.#Si(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),f),r.url=this.#ki(g),r.url}destroy(t=!1){t&&this.#yi?.size||(this.#mi?.parentNode.parentNode.remove(),this.#mi=null,this.#_i?.clear(),this.#_i=null,this.#yi?.clear(),this.#yi=null,this.#y=0)}#Mi(t){const e=this.#bi.createElementNS(Do,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#Ci(t){const e=this.#bi.createElementNS(Do,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#Ti(t){const e=this.#bi.createElementNS(Do,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#xi.append(e),e}#Pi(t,e,i){const s=this.#bi.createElementNS(Do,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#Si(t,e,i,s){const n=this.#bi.createElementNS(Do,"feComponentTransfer");s.append(n),this.#Pi(n,"feFuncR",t),this.#Pi(n,"feFuncG",e),this.#Pi(n,"feFuncB",i)}#Ri(t,e){const i=this.#bi.createElementNS(Do,"feComponentTransfer");e.append(i),this.#Pi(i,"feFuncA",t)}#Ei(t){return this.#xi.style.color=t,Wo(getComputedStyle(this.#xi).getPropertyValue("color"))}}class Ul{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("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._fetch(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){ho("Abstract method `_fetch` called.")}}class Hl extends Ul{async _fetch(t){const e=await Oo(t,"arraybuffer");return new Uint8Array(e)}}class $l{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load wasm data at: ${e}`)}))}async _fetch(t){ho("Abstract method `_fetch` called.")}}class Wl extends $l{async _fetch(t){const e=await Oo(t,"arraybuffer");return new Uint8Array(e)}}async function Gl(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}Tr&&lo("Please use the `legacy` build in Node.js environments.");class ql extends zl{}class Kl extends Nl{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Xl extends Bl{async _fetch(t){return Gl(t)}}class Yl extends Ul{async _fetch(t){return Gl(t)}}class Ql extends $l{async _fetch(t){return Gl(t)}}const Jl="Fill",Zl="Stroke",th="Shading";function eh(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class ih{isModifyingCurrentTransform(){return!1}getPattern(){ho("Abstract method `getPattern` called.")}}class sh extends ih{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,i,s){let n;if(s===Zl||s===Jl){const a=e.current.getClippedPathBoundingBox(s,Go(t))||[0,0,0,0],r=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",r,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),i=So.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),eh(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(i);n.setTransform(c)}else eh(t,this._bbox),n=this._createGradient(t);return n}}function nh(t,e,i,s,n,a,r,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=r,r=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,_=(l[s+1]+e.offsetY)*e.scaleY,m=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY;if(g>=v)return;const b=h[a],y=h[a+1],w=h[a+2],x=h[r],A=h[r+1],k=h[r+2],T=h[o],S=h[o+1],E=h[o+2],C=Math.round(g),R=Math.round(v);let M,P,L,D,I,O,N,F;for(let t=C;t<=R;t++){if(t<_){const e=t<g?0:(g-t)/(g-_);M=p-(p-f)*e,P=b-(b-x)*e,L=y-(y-A)*e,D=w-(w-k)*e}else{let e;e=t>v?1:_===v?0:(_-t)/(_-v),M=f-(f-m)*e,P=x-(x-T)*e,L=A-(A-S)*e,D=k-(k-E)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),I=p-(p-m)*e,O=b-(b-T)*e,N=y-(y-S)*e,F=w-(w-E)*e;const i=Math.round(Math.min(M,I)),s=Math.round(Math.max(M,I));let n=d*t+4*i;for(let t=i;t<=s;t++)e=(M-t)/(M-I),e<0?e=0:e>1&&(e=1),c[n++]=P-(P-O)*e|0,c[n++]=L-(L-N)*e|0,c[n++]=D-(D-F)*e|0,c[n++]=255}}function ah(t,e,i){const s=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(a=0;a<l;a++){let e=a*o;for(let a=0;a<h;a++,e++)nh(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),nh(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(a=0,r=s.length;a<r;a+=3)nh(t,i,s[a],s[a+1],s[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class rh extends ih{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-s,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),h=a/o,c=r/l,d={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,_=f.createImageData(o,l);if(e){const t=_.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)ah(_,t,d);f.putImageData(_,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*c,scaleX:h,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){eh(t,this._bbox);const n=new Float32Array(2);if(s===th)So.singularValueDecompose2dScale(Go(t),n);else if(this.matrix){So.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;So.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else So.singularValueDecompose2dScale(e.baseTransform,n);const a=this._createMeshCanvas(n,s===th?null:this._background,e.cachedCanvases);return s!==th&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class oh extends ih{getPattern(){return"hotpink"}}const lh=1,hh=2;class ch{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),oo("TilingType: "+n);const h=e[0],c=e[1],d=e[2],u=e[3],p=d-h,g=u-c,f=new Float32Array(2);So.singularValueDecompose2dScale(this.matrix,f);const[_,m]=f;So.singularValueDecompose2dScale(this.baseTransform,f);const v=_*f[0],b=m*f[1];let y=p,w=g,x=!1,A=!1;const k=Math.ceil(o*v),T=Math.ceil(l*b);k>=Math.ceil(p*v)?y=o:x=!0,T>=Math.ceil(g*b)?w=l:A=!0;const S=this.getSizeAndScale(y,this.ctx.canvas.width,v),E=this.getSizeAndScale(w,this.ctx.canvas.height,b),C=t.cachedCanvases.getCanvas("pattern",S.size,E.size),R=C.context,M=r.createCanvasGraphics(R);if(M.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(M,s,a),R.translate(-S.scale*h,-E.scale*c),M.transform(S.scale,0,0,E.scale,0,0),R.save(),this.clipBbox(M,h,c,d,u),M.baseTransform=Go(M.ctx),M.executeOperatorList(i),M.endDrawing(),R.restore(),x||A){const e=C.canvas;x&&(y=o),A&&(w=l);const i=this.getSizeAndScale(y,this.ctx.canvas.width,v),s=this.getSizeAndScale(w,this.ctx.canvas.height,b),n=i.size,a=s.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),d=r.context,u=x?Math.floor(p/o):0,f=A?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)d.drawImage(e,n*t,a*i,n,a,0,0,n,a);return{canvas:r.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:c}}return{canvas:C.canvas,scaleX:S.scale,scaleY:E.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,i){const s=Math.max(ch.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const a=s-e,r=n-i;t.ctx.rect(e,i,a,r),So.axialAlignedBoundingBox([e,i,s,n],Go(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case lh:const{fillStyle:t,strokeStyle:a}=this.ctx;s.fillStyle=n.fillColor=t,s.strokeStyle=n.strokeColor=a;break;case hh:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new yo(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s){let n=i;s!==th&&(n=So.transform(n,e.baseTransform),this.matrix&&(n=So.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}}function dh({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=ko.isLittleEndian?4278190080:255,[l,h]=r?[a,o]:[o,a],c=s>>3,d=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(const s=e+c;e<s;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===d)continue;const s=e<u?t[e++]:255;for(let t=0;t<d;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const uh=16,ph=new DOMMatrix,gh=new Float32Array(2),fh=new Float32Array([1/0,1/0,-1/0,-1/0]);class _h{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function mh(t,e,i,s,n,a,r,o,l,h){const[c,d,u,p,g,f]=Go(t);if(0===d&&0===u){const _=r*c+g,m=Math.round(_),v=o*p+f,b=Math.round(v),y=(r+l)*c+g,w=Math.abs(Math.round(y)-m)||1,x=(o+h)*p+f,A=Math.abs(Math.round(x)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),m,b),t.drawImage(e,i,s,n,a,0,0,w,A),t.setTransform(c,d,u,p,g,f),[w,A]}if(0===c&&0===p){const _=o*u+g,m=Math.round(_),v=r*d+f,b=Math.round(v),y=(o+h)*u+g,w=Math.abs(Math.round(y)-m)||1,x=(r+l)*d+f,A=Math.abs(Math.round(x)-b)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,m,b),t.drawImage(e,i,s,n,a,0,0,A,w),t.setTransform(c,d,u,p,g,f),[A,w]}t.drawImage(e,i,s,n,a,r,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class vh{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Sr;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=jr;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e){this.clipBox=new Float32Array([0,0,t,e]),this.minMax=fh.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=Jl,e=null){const i=this.minMax.slice();if(t===Zl){e||ho("Stroke bounding box must include transform."),So.singularValueDecompose2dScale(e,gh);const t=gh[0]*this.lineWidth/2,s=gh[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=So.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(fh,0)}getClippedPathBoundingBox(t=Jl,e=null){return So.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function bh(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%uh,a=(i-n)/uh,r=0===n?a:a+1,o=t.createImageData(s,uh);let l,h=0;const c=e.data,d=o.data;let u,p,g,f;if(e.kind===Wr.GRAYSCALE_1BPP){const e=c.byteLength,i=new Uint32Array(d.buffer,0,d.byteLength>>2),f=i.length,_=s+7>>3,m=4294967295,v=ko.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<a?uh:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const a=t>_?s:8*t-7,r=-8&a;let o=0,d=0;for(;n<r;n+=8)d=c[h++],i[l++]=128&d?m:v,i[l++]=64&d?m:v,i[l++]=32&d?m:v,i[l++]=16&d?m:v,i[l++]=8&d?m:v,i[l++]=4&d?m:v,i[l++]=2&d?m:v,i[l++]=1&d?m:v;for(;n<a;n++)0===o&&(d=c[h++],o=128),i[l++]=d&o?m:v,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*uh)}}else if(e.kind===Wr.RGBA_32BPP){for(p=0,f=s*uh*4,u=0;u<a;u++)d.set(c.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=uh;u<r&&(f=s*n*4,d.set(c.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==Wr.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=uh,f=s*g,u=0;u<r;u++){for(u>=a&&(g=n,f=s*g),l=0,p=f;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*uh)}}}function yh(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%uh,a=(i-n)/uh,r=0===n?a:a+1,o=t.createImageData(s,uh);let l=0;const h=e.data,c=o.data;for(let e=0;e<r;e++){const i=e<a?uh:n;({srcPos:l}=dh({src:h,srcPos:l,dest:c,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*uh)}}function wh(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function xh(t){t.strokeStyle=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);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function Ah(t,e){if(e)return!0;So.singularValueDecompose2dScale(t,gh);const i=Math.fround(Xo.pixelRatio*Io.PDF_TO_CSS_UNITS);return gh[0]<=i&&gh[1]<=i}const kh=["butt","round","square"],Th=["miter","round","bevel"],Sh={},Eh={};class Ch{constructor(t,e,i,s,n,{optionalContentConfig:a,markedContentStack:r=null},o,l){this.ctx=t,this.current=new vh(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=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=r||[],this.optionalContentConfig=a,this.cachedCanvases=new _h(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,a=this.ctx.canvas.height,r=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=r,i){const t=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Go(this.compositeCtx))}this.ctx.save(),xh(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Go(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const l=o-r>10&&"function"==typeof i,h=l?Date.now()+15:0;let c=0;const d=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&r===s.nextBreakPoint)return s.breakIt(r,i),r;if(p=a[r],p!==Zr.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?d:u;if(!e.has(t))return e.get(t,i),r}if(r++,r===o)return r;if(l&&++c>10){if(Date.now()>h)return i(),r;c=0}}}#Li(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,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)}endDrawing(){this.#Li(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#Di()}#Di(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,a,r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,c="prescale1";for(;r>2&&l>1||o>2&&h>1;){let e=l,i=h;r>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(c,e,i),a=n.context,a.clearRect(0,0,e,i),a.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,a=this.current.patternFill,r=Go(e);let o,l,h,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(a?r:[r.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!a){return{canvas:i,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])}}h=i}h||(c=this.cachedCanvases.getCanvas("maskCanvas",i,s),yh(c.context,t));let d=So.transform(r,[1/i,0,0,-1/s,0,0]);d=So.transform(d,[1,0,0,1,0,-s]);const u=fh.slice();So.axialAlignedBoundingBox([0,0,i,s],d,u);const[p,g,f,_]=u,m=Math.round(f-p)||1,v=Math.round(_-g)||1,b=this.cachedCanvases.getCanvas("fillCanvas",m,v),y=b.context,w=p,x=g;y.translate(-w,-x),y.transform(...d),h||(h=this._scaleImage(c.canvas,qo(y)),h=h.img,o&&a&&o.set(l,h)),y.imageSmoothingEnabled=Ah(Go(y),t.interpolate),mh(y,h,0,0,h.width,h.height,0,0,i,s),y.globalCompositeOperation="source-in";const A=So.transform(qo(y),[1,0,0,1,-w,-x]);return y.fillStyle=a?n.getPattern(e,this,A,Jl):n,y.fillRect(0,0,i,s),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,b.canvas)),{canvas:b.canvas,offsetX:Math.round(w),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=kh[t]}setLineJoin(t){this.ctx.lineJoin=Th[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){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=i;break;case"ca":this.ctx.globalAlpha=this.current.fillAlpha=i;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.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx;const n=this.ctx=s.context;n.setTransform(this.suspendedCtx.getTransform()),wh(this.suspendedCtx,n),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,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,a,r){e.transform(t,i,s,n,a,r),this.__originalTransform(t,i,s,n,a,r)},t.setTransform=function(t,i,s,n,a,r){e.setTransform(t,i,s,n,a,r),this.__originalSetTransform(t,i,s,n,a,r)},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,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,a,r){e.bezierCurveTo(t,i,s,n,a,r),this.__originalBezierCurveTo(t,i,s,n,a,r)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),wh(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;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];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,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()}composeSMask(t,e,i,s){const n=s[0],a=s[1],r=s[2]-n,o=s[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,i,r,o,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,a,r,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(a)if(u<0||p<0||u+i>d.width||p+s>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(d,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=a,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(u,p,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode&&wh(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&wh(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,a){this.ctx.transform(t,e,i,s,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let[s]=e;if(!i)return s||=e[0]=new Path2D,void this[t](s);if(!(s instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,i=s.length;e<i;)switch(s[e++]){case to:t.moveTo(s[e++],s[e++]);break;case eo:t.lineTo(s[e++],s[e++]);break;case io:t.bezierCurveTo(s[e++],s[e++],s[e++],s[e++],s[e++],s[e++]);break;case so:t.closePath();break;default:lo(`Unrecognized drawing path operator: ${s[e-1]}`)}s=t}So.axialAlignedBoundingBox(i,Go(this.ctx),this.current.minMax),this[t](s)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const i=this.ctx,s=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=s.getPattern(i,this,qo(i),Zl),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}this.rescaleAndStroke(t,!1),i.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(Zl,Go(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const i=this.ctx,s=this.current.fillColor;let n=!1;if(this.current.patternFill){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.fillStyle=s.getPattern(i,this,qo(i),Jl),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}n=!0}const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(i.fill(t,"evenodd"),this.pendingEOFill=!1):i.fill(t)),n&&i.restore(),e&&this.consumePath(t,a)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=Sh}eoClip(){this.pendingClip=Eh}beginText(){this.current.textMatrix=null,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)return;const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:a,fontSize:r,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,a).scale(r,-r));e.clip(i),delete this.pendingTextPaths}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 i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||Sr,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||lo("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let r="normal";i.black?r="900":i.bold&&(r="bold");const o=i.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${r} ${l}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){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#Ii(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const a=this.ctx,r=this.current,o=r.font,l=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,c=l&Hr,d=!!(l&$r),u=r.patternFill&&!o.missingFile,p=r.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||d||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){let t;if(a.save(),a.translate(e,i),a.scale(h,-h),c!==jr&&c!==Vr||(s?(t=a.getTransform(),a.setTransform(...s),a.fill(this.#Ii(g,t,s))):a.fill(g)),c===zr||c===Vr)if(n){t||=a.getTransform(),a.setTransform(...n);const{a:e,b:i,c:s,d:r}=t,o=So.inverseTransform(n),l=So.transform([e,i,s,r,0,0],o);So.singularValueDecompose2dScale(l,gh),a.lineWidth*=Math.max(gh[0],gh[1])/h,a.stroke(this.#Ii(g,t,n))}else a.lineWidth/=h,a.stroke(g);a.restore()}else c!==jr&&c!==Vr||a.fillText(t,e,i),c!==zr&&c!==Vr||a.strokeText(t,e,i);if(d){(this.pendingTextPaths||=[]).push({transform:Go(a),x:e,y:i,fontSize:h,path:g})}}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 i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return go(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,a=e.fontSizeScale,r=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,c=t.length,d=i.vertical,u=d?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],f=e.textRenderingMode===jr&&!i.disableFontFace&&!e.patternFill;let _,m;if(n.save(),e.textMatrix&&n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,qo(n),Jl);_=Go(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,qo(n),Zl);m=Go(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const b=e.textMatrixScale;if(0===b||0===v){const t=e.textRenderingMode&Hr;t!==zr&&t!==Vr||(v=this.getSinglePixelWidth())}else v/=b;if(1!==a&&(n.scale(a,a),v/=a),n.lineWidth=v,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let y,w=0;for(y=0;y<c;++y){const e=t[y];if("number"==typeof e){w+=u*e*s/1e3;continue}let h=!1;const c=(e.isSpace?o:0)+r,v=e.fontChar,b=e.accent;let x,A,k=e.width;if(d){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*k)*g,s=t[2]*g;k=t?-t[0]:k,x=i/a,A=(w+s)/a}else x=w/a,A=0;if(i.remeasure&&k>0){const t=1e3*n.measureText(v).width/s*a;if(k<t&&this.isFontSubpixelAAEnabled){const e=k/t;h=!0,n.save(),n.scale(e,1),x/=e}else k!==t&&(x+=(k-t)/2e3*s/a)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(f&&!b)n.fillText(v,x,A);else if(this.paintChar(v,x,A,_,m),b){const t=x+s*b.offset.x/a,e=A-s*b.offset.y/a;this.paintChar(b.fontChar,t,e,_,m)}w+=d?k*g-c*l:k*g+c*l,h&&n.restore()}d?e.y-=w:e.x+=w*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,a=i.fontDirection,r=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,h=i.textHScale*a,c=i.fontMatrix||Sr,d=t.length;let u,p,g,f;if(!(i.textRenderingMode===Ur)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),i.textMatrix&&e.transform(...i.textMatrix),e.translate(i.x,i.y+i.textRise),e.scale(h,a),u=0;u<d;++u){if(p=t[u],"number"==typeof p){f=r*p*n/1e3,this.ctx.translate(f,0),i.x+=f*h;continue}const a=(p.isSpace?l:0)+o,d=s.charProcOperatorList[p.operatorListId];d?this.contentVisible&&(this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(d),this.restore()):lo(`Type3 character "${p.operatorListId}" is not available.`);const _=[p.width,0];So.applyTransform(_,c),g=_[0]*n+a,e.translate(g,0),i.x+=g*h}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,a){const r=new Path2D;r.rect(i,s,n-i,a-s),this.ctx.clip(r),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=this.baseTransform||Go(this.ctx),s={createCanvasGraphics:t=>new Ch(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new ch(t,this.ctx,s,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new sh(t);case"Mesh":return new rh(t);case"Dummy":return new oh}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,qo(e),th);const s=qo(e);if(s){const{width:t,height:i}=e.canvas,n=fh.slice();So.axialAlignedBoundingBox([0,0,t,i],s,n);const[a,r,o,l]=n;this.ctx.fillRect(a,r,o-a,l-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){ho("Should not call beginInlineImage")}beginImageData(){ho("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Go(this.ctx),e)){So.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,i,s,n]=e,a=new Path2D;a.rect(t,i,s-t,n-i),this.ctx.clip(a),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||oo("TODO: Support non-isolated groups."),t.knockout&&lo("Knockout groups not supported.");const i=Go(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=fh.slice();So.axialAlignedBoundingBox(t.bbox,Go(e),s);const n=[0,0,e.canvas.width,e.canvas.height];s=So.intersect(s,n)||[0,0,0,0];const a=Math.floor(s[0]),r=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-a,1),l=Math.max(Math.ceil(s[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(h,o,l),d=c.context;d.translate(-a,-r),d.transform(...i);let u=new Path2D;const[p,g,f,_]=t.bbox;if(u.rect(p,g,f-p,_-g),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}d.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:d,offsetX:a,offsetY:r,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,r),e.save()),wh(e,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=Go(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=fh.slice();So.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,i),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#Li(),xh(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=a,So.singularValueDecompose2dScale(Go(this.ctx),gh);const{viewportScale:n}=this,r=Math.ceil(s*this.outputScaleX*n),o=Math.ceil(a*this.outputScaleY*n);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(t,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(gh[0],0,0,-gh[1],0,a*gh[1]),xh(this.ctx)}else{xh(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],s,a),this.ctx.clip(t)}}this.current=new vh(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Di(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this._createMaskCanvas(t),n=s.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(n,s.offsetX,s.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const r=this.ctx;r.save();const o=Go(r);r.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);r.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=a.length;t<h;t+=2){const h=So.transform(o,[e,i,s,n,a[t],a[t+1]]);r.drawImage(l.canvas,h[4],h[5])}r.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:a,height:r,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",a,r),h=l.context;h.save();yh(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,qo(e),Jl):i,h.fillRect(0,0,a,r),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),mh(e,l.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):lo("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void lo("Dependent image isn't ready yet");const a=n.width,r=n.height,o=[];for(let t=0,n=s.length;t<n;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:a,h:r});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;this.save();const{filter:n}=s;let a;if("none"!==n&&""!==n&&(s.filter="none"),s.scale(1/e,-1/i),t.bitmap)a=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)a=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;bh(s,t),a=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(a,qo(s));s.imageSmoothingEnabled=Ah(Go(s),t.interpolate),mh(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=t.width,i=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,i).context;bh(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),mh(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.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){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t,e){const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const s=this.ctx;this.pendingClip&&(i||(this.pendingClip===Eh?s.clip(t,"evenodd"):s.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Go(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let a,r;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)a=r=1/i;else{const e=i*t;a=r=e<1?1/e:1}else if(0===t)a=1/i,r=1/s;else{const e=i*t,n=s*t;a=e<1?1/e:1,r=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)a=h/o,r=l/o;else{const e=t*o;a=h>e?h/e:1,r=l>e?l/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,a]=this.getScaleForStroking();if(n===a)return i.lineWidth=(s||1)*n,void i.stroke(t);const r=i.getLineDash();e&&i.save(),i.scale(n,a),ph.a=1/n,ph.d=1/a;const o=new Path2D;if(o.addPath(t,ph),r.length>0){const t=Math.max(n,a);i.setLineDash(r.map((e=>e/t))),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in Zr)void 0!==Ch.prototype[t]&&(Ch.prototype[Zr[t]]=Ch.prototype[t]);class Rh{static#Oi=null;static#Ni="";static get workerPort(){return this.#Oi}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Oi=t}static get workerSrc(){return this.#Ni}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Ni=t}}class Mh{#Fi;#Bi;constructor({parsedData:t,rawData:e}){this.#Fi=t,this.#Bi=e}getRaw(){return this.#Bi}get(t){return this.#Fi.get(t)??null}[Symbol.iterator](){return this.#Fi.entries()}}const Ph=Symbol("INTERNAL");class Lh{#ji=!1;#zi=!1;#Vi=!1;#Ui=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#ji=!!(t&Rr),this.#zi=!!(t&Mr),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#Vi)return this.#Ui;if(!this.#Ui)return!1;const{print:t,view:e}=this.usage;return this.#ji?"OFF"!==e?.viewState:!this.#zi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Ph&&ho("Internal method `_setVisible` called."),this.#Vi=i,this.#Ui=e}}class Dh{#Hi=null;#$i=new Map;#Wi=null;#Gi=null;constructor(t,e=Rr){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#Gi=t.order;for(const i of t.groups)this.#$i.set(i.id,new Lh(e,i));if("OFF"===t.baseState)for(const t of this.#$i.values())t._setVisible(Ph,!1);for(const e of t.on)this.#$i.get(e)._setVisible(Ph,!0);for(const e of t.off)this.#$i.get(e)._setVisible(Ph,!1);this.#Wi=this.getHash()}}#qi(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#qi(e);else{if(!this.#$i.has(e))return lo(`Optional content group not found: ${e}`),!0;n=this.#$i.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#$i.size)return!0;if(!t)return oo("Optional content group not defined."),!0;if("OCG"===t.type)return this.#$i.has(t.id)?this.#$i.get(t.id).visible:(lo(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#qi(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#$i.has(e))return lo(`Optional content group not found: ${e}`),!0;if(this.#$i.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#$i.has(e))return lo(`Optional content group not found: ${e}`),!0;if(!this.#$i.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#$i.has(e))return lo(`Optional content group not found: ${e}`),!0;if(!this.#$i.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#$i.has(e))return lo(`Optional content group not found: ${e}`),!0;if(this.#$i.get(e).visible)return!1}return!0}return lo(`Unknown optional content policy ${t.policy}.`),!0}return lo(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#$i.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#$i.get(i)?._setVisible(Ph,!1,!0);s._setVisible(Ph,!!e,!0),this.#Hi=null}else lo(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#$i.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#Hi=null}get hasInitialVisibility(){return null===this.#Wi||this.getHash()===this.#Wi}getOrder(){return this.#$i.size?this.#Gi?this.#Gi.slice():[...this.#$i.keys()]:null}getGroup(t){return this.#$i.get(t)||null}getHash(){if(null!==this.#Hi)return this.#Hi;const t=new pl;for(const[e,i]of this.#$i)t.update(`${e}:${i.visible}`);return this.#Hi=t.hexdigest()}[Symbol.iterator](){return this.#$i.entries()}}class Ih{constructor(t,{disableRange:e=!1,disableStream:i=!1}){co(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:a,contentDispositionFilename:r}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=r,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{co(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){co(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Oh(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Nh(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Oh{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=jo(s)?s: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){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else 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=Promise.withResolvers();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 Nh{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,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=Promise.withResolvers();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)}}function Fh(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function Bh(t){return URL.parse(t)?.origin??null}function jh({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(a))return n;if(n.suggestedLength=a,a<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function zh(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=r(i);return t=unescape(t),t=o(t),t=l(t),a(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const a=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=r(s),i&&(s=unescape(s),0===t&&(s=o(s))),a.push(s)}return a.join("")}(t),i)return a(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=r(i);return t=l(t),a(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=Ao(i);i=s.decode(n),e=!1}catch{}}return i}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(jo(t))return t}return null}function Vh(t,e){return new bo(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function Uh(t){return 200===t||206===t}function Hh(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function $h(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(lo(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Wh{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Fh(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return co(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Gh(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new qh(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Gh{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=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,Hh(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=Bh(e.url),!Uh(e.status))throw Vh(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:a}=jh({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=zh(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new wo("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?.({loaded:this._loaded,total:this._contentLength}),{value:$h(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class qh{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const a=s.url;fetch(a,Hh(n,this._withCredentials,this._abortController)).then((e=>{const i=Bh(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Uh(e.status))throw Vh(e.status,a);this._readCapability.resolve(),this._reader=e.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?.({loaded:this._loaded}),{value:$h(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Kh{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Fh(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",co(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const a=function(t){const e=t.response;return"string"!=typeof e?e:Ao(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:a}):(lo('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone({begin:0,chunk:a}):i.onError(s.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()}}class Xh{constructor(t){this._source=t,this._manager=new Kh(t),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 co(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Yh(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Qh(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Yh{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),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);this._manager._responseOrigin=Bh(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:a}=jh({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=zh(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(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=Vh(t,this._url),this._headersCapability.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._headersCapability.promise}async read(){if(await this._headersCapability.promise,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=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.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 Qh{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Bh(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else 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??=Vh(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=Promise.withResolvers();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()}}const Jh=/^[a-z][a-z0-9\-+.]+:/i;class Zh{constructor(t){this.source=t,this.url=function(t){if(Jh.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),co("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return co(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new tc(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ec(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class tc{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=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=Vh(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)}))}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();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{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 wo("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class ec{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}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();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{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)}}const ic=Symbol("INITIAL_DATA");class sc{#Ki=Object.create(null);#Xi(t){return this.#Ki[t]||={...Promise.withResolvers(),data:ic}}get(t,e=null){if(e){const i=this.#Xi(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Ki[t];if(!i||i.data===ic)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Ki[t];return!!e&&e.data!==ic}delete(t){const e=this.#Ki[t];return!(!e||e.data===ic)&&(delete this.#Ki[t],!0)}resolve(t,e=null){const i=this.#Xi(t);i.data=e,i.resolve()}clear(){for(const t in this.#Ki){const{data:e}=this.#Ki[t];e?.bitmap?.close()}this.#Ki=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Ki){const{data:e}=this.#Ki[t];e!==ic&&(yield[t,e])}}}class nc{#Yi=Promise.withResolvers();#_t=null;#Qi=!1;#Ji=!!globalThis.FontInspector?.enabled;#Zi=null;#ts=null;#es=0;#is=0;#ss=null;#ns=null;#as=0;#rs=0;#os=Object.create(null);#ls=[];#hs=null;#cs=[];#ds=new WeakMap;#us=null;static#ps=new Map;static#gs=new Map;static#fs=new WeakMap;static#_s=null;static#ms=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#hs=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#hs=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#_t=this.#ns=e,this.#rs=i.scale*Xo.pixelRatio,this.#as=i.rotation,this.#ts={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:a,pageY:r}=i.rawDims;this.#us=[1,0,0,-1,-a,r+n],this.#is=s,this.#es=n,nc.#vs(),Ko(e,i),this.#Yi.promise.finally((()=>{nc.#ms.delete(this),this.#ts=null,this.#os=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ko.platform;return go(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#ss.read().then((({value:e,done:i})=>{i?this.#Yi.resolve():(this.#Zi??=e.lang,Object.assign(this.#os,e.styles),this.#bs(e.items),t())}),this.#Yi.reject)};return this.#ss=this.#hs.getReader(),nc.#ms.add(this),t(),this.#Yi.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*Xo.pixelRatio,s=t.rotation;if(s!==this.#as&&(e?.(),this.#as=s,Ko(this.#ns,{rotation:s})),i!==this.#rs){e?.(),this.#rs=i;const t={div:null,properties:null,ctx:nc.#ys(this.#Zi)};for(const e of this.#cs)t.properties=this.#ds.get(e),t.div=e,this.#ws(t)}}cancel(){const t=new wo("TextLayer task cancelled.");this.#ss?.cancel(t).catch((()=>{})),this.#ss=null,this.#Yi.reject(t)}get textDivs(){return this.#cs}get textContentItemsStr(){return this.#ls}#bs(t){if(this.#Qi)return;this.#ts.ctx??=nc.#ys(this.#Zi);const e=this.#cs,i=this.#ls;for(const s of t){if(e.length>1e5)return lo("Ignoring additional textDivs for performance reasons."),void(this.#Qi=!0);if(void 0!==s.str)i.push(s.str),this.#xs(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#_t;this.#_t=document.createElement("span"),this.#_t.classList.add("markedContent"),null!==s.id&&this.#_t.setAttribute("id",`${s.id}`),t.append(this.#_t)}else"endMarkedContent"===s.type&&(this.#_t=this.#_t.parentNode)}}#xs(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#cs.push(e);const s=So.transform(this.#us,t.transform);let n=Math.atan2(s[1],s[0]);const a=this.#os[t.fontName];a.vertical&&(n+=Math.PI/2);let r=this.#Ji&&a.fontSubstitution||a.fontFamily;r=nc.fontFamilyMap.get(r)||r;const o=Math.hypot(s[2],s[3]),l=o*nc.#As(r,a,this.#Zi);let h,c;0===n?(h=s[4],c=s[5]-l):(h=s[4]+l*Math.sin(n),c=s[5]-l*Math.cos(n));const d="calc(var(--total-scale-factor) *",u=e.style;this.#_t===this.#ns?(u.left=`${(100*h/this.#is).toFixed(2)}%`,u.top=`${(100*c/this.#es).toFixed(2)}%`):(u.left=`${d}${h.toFixed(2)}px)`,u.top=`${d}${c.toFixed(2)}px)`),u.fontSize=`${d}${(nc.#_s*o).toFixed(2)}px)`,u.fontFamily=r,i.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Ji&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==n&&(i.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(i.canvasWidth=a.vertical?t.height:t.width),this.#ds.set(e,i),this.#ts.div=e,this.#ts.properties=i,this.#ws(this.#ts),i.hasText&&this.#_t.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#_t.append(t)}}#ws(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;let a="";if(nc.#_s>1&&(a=`scale(${1/nc.#_s})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:r,fontSize:o}=i;nc.#ks(s,o*this.#rs,t);const{width:l}=s.measureText(e.textContent);l>0&&(a=`scaleX(${r*this.#rs/l}) ${a}`)}0!==i.angle&&(a=`rotate(${i.angle}deg) ${a}`),a.length>0&&(n.transform=a)}static cleanup(){if(!(this.#ms.size>0)){this.#ps.clear();for(const{canvas:t}of this.#gs.values())t.remove();this.#gs.clear()}}static#ys(t=null){let e=this.#gs.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#gs.set(t,e),this.#fs.set(e,{size:0,family:""})}return e}static#ks(t,e,i){const s=this.#fs.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#vs(){if(null!==this.#_s)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#_s=t.getBoundingClientRect().height,t.remove()}static#As(t,e,i){const s=this.#ps.get(t);if(s)return s;const n=this.#ys(i);n.canvas.width=n.canvas.height=30,this.#ks(n,30,t);const a=n.measureText(""),r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return r?l=r/(r+o):(ko.platform.isFirefox&&lo("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#ps.set(t,l),l}}class ac{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!ac.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}function rc(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new oc,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(Tr)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(Tr&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Ao(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,r=!0===t.withCredentials,o=t.password??null,l=t.range instanceof lc?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let c=t.worker instanceof dc?t.worker:null;const d=t.verbosity,u="string"!=typeof t.docBaseUrl||Bo(t.docBaseUrl)?null:t.docBaseUrl,p=bl(t.cMapUrl),g=!1!==t.cMapPacked,f=t.CMapReaderFactory||(Tr?Xl:jl),_=bl(t.iccUrl),m=bl(t.standardFontDataUrl),v=t.StandardFontDataFactory||(Tr?Yl:Hl),b=bl(t.wasmUrl),y=t.WasmFactory||(Tr?Ql:Wl),w=!0!==t.stopAtErrors,x=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,A=!1!==t.isEvalSupported,k="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!Tr,T="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!Tr&&(ko.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,E="boolean"==typeof t.disableFontFace?t.disableFontFace:Tr,C=!0===t.fontExtraProperties,R=!0===t.enableXfa,M=t.ownerDocument||globalThis.document,P=!0===t.disableRange,L=!0===t.disableStream,D=!0===t.disableAutoFetch,I=!0===t.pdfBug,O=t.CanvasFactory||(Tr?Kl:Fl),N=t.FilterFactory||(Tr?ql:Vl),F=!0===t.enableHWA,B=!1!==t.useWasm,j=l?l.length:t.length??NaN,z="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!Tr&&!E,V="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===jl&&v===Hl&&y===Wl&&p&&m&&b&&Vo(p,document.baseURI)&&Vo(m,document.baseURI)&&Vo(b,document.baseURI));ao(d);const U={canvasFactory:new O({ownerDocument:M,enableHWA:F}),filterFactory:new N({docId:i,ownerDocument:M}),cMapReaderFactory:V?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:V?null:new v({baseUrl:m}),wasmFactory:V?null:new y({baseUrl:b})};c||(c=dc.create({verbosity:d,port:Rh.workerPort}),e._worker=c);const H={docId:i,apiVersion:"5.3.31",data:n,password:o,disableAutoFetch:D,rangeChunkSize:h,length:j,docBaseUrl:u,enableXfa:R,evaluatorOptions:{maxImageSize:x,disableFontFace:E,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:k,isImageDecoderSupported:T,canvasMaxAreaInBytes:S,fontExtraProperties:C,useSystemFonts:z,useWasm:B,useWorkerFetch:V,cMapUrl:p,iccUrl:_,standardFontDataUrl:m,wasmUrl:b}},$={ownerDocument:M,pdfBug:I,styleElement:null,loadingParams:{disableAutoFetch:D,enableXfa:R}};return c.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",H,n?[n.buffer]:null);let o;if(l)o=new Ih(l,{disableRange:P,disableStream:L});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const t=Vo(s)?Wh:Tr?Zh:Xh;o=new t({url:s,length:j,httpHeaders:a,withCredentials:r,rangeChunkSize:h,disableRange:P,disableStream:L})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new Ol(i,t,c.port),n=new uc(s,e,o,$,U);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}class oc{static#vi=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+oc.#vi++;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class lc{#Yi=Promise.withResolvers();#Ts=[];#Ss=[];#Es=[];#Cs=[];constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){this.#Cs.push(t)}addProgressListener(t){this.#Es.push(t)}addProgressiveReadListener(t){this.#Ss.push(t)}addProgressiveDoneListener(t){this.#Ts.push(t)}onDataRange(t,e){for(const i of this.#Cs)i(t,e)}onDataProgress(t,e){this.#Yi.promise.then((()=>{for(const i of this.#Es)i(t,e)}))}onDataProgressiveRead(t){this.#Yi.promise.then((()=>{for(const e of this.#Ss)e(t)}))}onDataProgressiveDone(){this.#Yi.promise.then((()=>{for(const t of this.#Ts)t()}))}transportReady(){this.#Yi.resolve()}requestDataRange(t,e){ho("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class hc{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return go(this,"isPureXfa",!!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()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class cc{#Rs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new zo:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new sc,this._intentStates=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:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new No({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return go(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=Nr.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:r=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:c=!1}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(i,s,h,c),{renderingIntent:u,cacheKey:p}=d;this.#Rs=!1,r||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&Mr);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const _=t=>{g.renderTasks.delete(m),f&&(this.#Rs=!0),this.#Ms(),t?(m.capability.reject(t),this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})):m.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},m=new gc({callback:_,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||=new Set).add(m);const v=m.task;return Promise.all([g.displayReadyCapability.promise,r]).then((([t,e])=>{if(this.destroyed)_();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");m.initializeGraphics({transparency:t,optionalContentConfig:e}),m.operatorListChanged()}})).catch(_),v}getOperatorList({intent:t="display",annotationMode:e=Nr.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let a,r=this._intentStates.get(n.cacheKey);return r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r)),r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>ac.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return 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 i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#Rs=!1,Promise.all(t)}cleanup(t=!1){this.#Rs=!0;const e=this.#Ms();return t&&e&&(this._stats&&=new zo),e}#Ms(){if(!this.#Rs||this.destroyed)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.#Rs=!1,!0}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#Ms()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:a}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},a).getReader(),o=this._intentStates.get(e);o.streamReader=r;const l=()=>{r.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#Ms()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Fo){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new wo(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class dc{#Yi=Promise.withResolvers();#Ps=null;#Oi=null;#Ls=null;static#Ds=0;static#Is=!1;static#Os=new WeakMap;static{Tr&&(this.#Is=!0,Rh.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{var e;if(e="`PDFWorker.fromPort` - please use `PDFWorker.create` instead.",console.log("Deprecated API usage: "+e),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=ro()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(dc.#Os.has(e))throw new Error("Cannot use more than one PDFWorker per port.");dc.#Os.set(e,this),this.#Ns(e)}else this.#Fs()}get promise(){return this.#Yi.promise}#Bs(){this.#Yi.resolve(),this.#Ps.send("configure",{verbosity:this.verbosity})}get port(){return this.#Oi}get messageHandler(){return this.#Ps}#Ns(t){this.#Oi=t,this.#Ps=new Ol("main","worker",t),this.#Ps.on("ready",(()=>{})),this.#Bs()}#Fs(){if(dc.#Is||dc.#js)return void this.#zs();let{workerSrc:t}=dc;try{dc._isSameOrigin(window.location,t)||(t=dc._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Ol("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#Yi.reject(new Error("Worker was destroyed")):this.#zs()},n=new AbortController;e.addEventListener("error",(()=>{this.#Ls||s()}),{signal:n.signal}),i.on("test",(t=>{n.abort(),!this.destroyed&&t?(this.#Ps=i,this.#Oi=e,this.#Ls=e,this.#Bs()):s()})),i.on("ready",(t=>{if(n.abort(),this.destroyed)s();else try{a()}catch{this.#zs()}}));const a=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void a()}catch{oo("The worker has been disabled.")}this.#zs()}#zs(){dc.#Is||(lo("Setting up fake worker."),dc.#Is=!0),dc._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this.#Yi.reject(new Error("Worker was destroyed"));const e=new xl;this.#Oi=e;const i="fake"+dc.#Ds++,s=new Ol(i+"_worker",i,e);t.setup(s,e),this.#Ps=new Ol(i,i+"_worker",e),this.#Bs()})).catch((t=>{this.#Yi.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this.#Ls?.terminate(),this.#Ls=null,dc.#Os.delete(this.#Oi),this.#Oi=null,this.#Ps?.destroy(),this.#Ps=null}static create(t){const e=this.#Os.get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new dc(t)}static get workerSrc(){if(Rh.workerSrc)return Rh.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#js(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return go(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#js)return this.#js;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class uc{#Vs=new Map;#Us=new Map;#Hs=new Map;#$s=new Map;#Ws=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new sc,this.fontLoader=new ml({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Gs(t,e=null){const i=this.#Vs.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Vs.set(t,s),s}get annotationStorage(){return go(this,"annotationStorage",new fl)}getRenderingIntent(t,e=Nr.ENABLE,i=null,s=!1,n=!1){let a=Rr,r=gl;switch(t){case"any":a=Cr;break;case"display":break;case"print":a=Mr;break;default:lo(`getRenderingIntent - invalid intent: ${t}`)}const o=a&Mr&&i instanceof _l?i:this.annotationStorage;switch(e){case Nr.DISABLE:a+=Dr;break;case Nr.ENABLE:break;case Nr.ENABLE_FORMS:a+=Pr;break;case Nr.ENABLE_STORAGE:a+=Lr,r=o.serializable;break;default:lo(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(a+=Ir),n&&(a+=Or);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,h].join("_"),annotationStorageSerializable:r,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Ws?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Us.values())t.push(e._destroy());this.#Us.clear(),this.#Hs.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.#Vs.clear(),this.filterFactory.destroy(),nc.cleanup(),this._networkStream?.cancelAllRequests(new wo("Worker was terminated.")),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)=>{co(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:i}){i?e.close():(co(t instanceof ArrayBuffer,"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",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{co(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(co(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.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 hc(t,this))})),t.on("DocException",(t=>{e._capability.reject(Il(t))})),t.on("PasswordRequest",(t=>{this.#Ws=Promise.withResolvers();try{if(!e.onPassword)throw Il(t);const i=t=>{t instanceof Error?this.#Ws.reject(t):this.#Ws.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Ws.reject(t)}return this.#Ws.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#Us.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){const t=s.error;lo(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const n=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new vl(s,n);this.fontLoader.bind(a).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a.fontExtraProperties&&a.data&&(a.data=null),this.commonObjs.resolve(e,a)}));break;case"CopyLocalImage":const{imageRef:r}=s;co(r,"The imageRef must be defined.");for(const t of this.#Us.values())for(const[,i]of t.objs)if(i?.ref===r)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#Us.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&lo("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#Hs.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#$s.set(i.refStr,t);const s=new cc(e,i,this,this._params.pdfBug);return this.#Us.set(e,s),s}));return this.#Hs.set(e,s),s}getPageIndex(t){return yl(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#Gs("GetFieldObjects")}hasJSActions(){return this.#Gs("HasJSActions")}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)}getDocJSActions(){return this.#Gs("GetDocJSActions")}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(t){return this.#Gs("GetOptionalContentConfig").then((e=>new Dh(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Vs.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Mh(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Vs.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Us.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Vs.clear(),this.filterFactory.destroy(!0),nc.cleanup()}}cachedPageNumber(t){if(!yl(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#$s.get(e)??null}}class pc{#qs=null;onContinue=null;onError=null;constructor(t){this.#qs=t}get promise(){return this.#qs.capability.promise}cancel(t=0){this.#qs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#qs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#qs;return t.form||t.canvas&&e?.size>0}}class gc{#Ks=null;static#Xs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:a,pageIndex:r,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=r,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new pc(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(gc.#Xs.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.");gc.#Xs.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:i,viewport:s,transform:n,background:a}=this.params;this.gfx=new Ch(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Ks&&(window.cancelAnimationFrame(this.#Ks),this.#Ks=null),gc.#Xs.delete(this._canvas),t||=new Fo(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Ks=window.requestAnimationFrame((()=>{this.#Ks=null,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(),gc.#Xs.delete(this._canvas),this.callback())))}}function fc(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function _c(t){return Math.max(0,Math.min(255,255*t))}class mc{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=_c(t),t,t]}static G_HTML([t]){const e=fc(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(_c)}static RGB_HTML(t){return`#${t.map(fc).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[_c(1-Math.min(1,t+s)),_c(1-Math.min(1,i+s)),_c(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,a=1-i;return["CMYK",s,n,a,Math.min(s,n,a)]}}class vc{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(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){ho("Abstract method `_createSVG` called.")}}class bc extends vc{_createSVG(t){return document.createElementNS(Do,t)}}class yc{static setupStorage(t,e,i,s,n){const a=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of i.children)t.attributes.value===a.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${s}`);for(const[e,i]of Object.entries(a))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!r||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}r&&n.addLinkAttributes(t,a.href,a.newWindow),i&&a.dataId&&this.setupStorage(t,a.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:n,linkService:i});const r="richText"!==n,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);a.append(t),r&&ac.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,a]];for(;h.length>0;){const[t,s,a]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const t=document.createTextNode(o.value);l.push(t),a.append(t);continue}const d=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,c):document.createElement(c);if(a.append(d),o.attributes&&this.setAttributes({html:d,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,d]);else if(o.value){const t=document.createTextNode(o.value);r&&ac.shouldBuildText(c)&&l.push(t),d.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const wc=1e3,xc=new WeakSet;class Ac{static create(t){switch(t.data.annotationType){case Gr.LINK:return new Tc(t);case Gr.TEXT:return new Sc(t);case Gr.WIDGET:switch(t.data.fieldType){case"Tx":return new Cc(t);case"Btn":return t.data.radioButton?new Pc(t):t.data.checkBox?new Mc(t):new Lc(t);case"Ch":return new Dc(t);case"Sig":return new Rc(t)}return new Ec(t);case Gr.POPUP:return new Ic(t);case Gr.FREETEXT:return new Nc(t);case Gr.LINE:return new Fc(t);case Gr.SQUARE:return new Bc(t);case Gr.CIRCLE:return new jc(t);case Gr.POLYLINE:return new zc(t);case Gr.CARET:return new Uc(t);case Gr.INK:return new Hc(t);case Gr.POLYGON:return new Vc(t);case Gr.HIGHLIGHT:return new $c(t);case Gr.UNDERLINE:return new Wc(t);case Gr.SQUIGGLY:return new Gc(t);case Gr.STRIKEOUT:return new qc(t);case Gr.STAMP:return new Kc(t);case Gr.FILEATTACHMENT:return new Xc(t);default:return new kc(t)}}}class kc{#Ys=null;#Qs=!1;#Js=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,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.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return kc._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#Ys||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#Zs(e),this.#Js?.popup.updateEdited(t)}resetEdited(){this.#Ys&&(this.#Zs(this.#Ys.rect),this.#Js?.popup.resetEdited(),this.#Ys=null)}#Zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===s?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/a+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Ec||(n.tabIndex=wc);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Ic){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;a.borderRadius=e}else if(this instanceof Pc){const t=`calc(${r}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case qr:a.borderStyle="solid";break;case Kr:a.borderStyle="dashed";break;case Xr:lo("Unimplemented border style: beveled");break;case Yr:lo("Unimplemented border style: inset");break;case Qr:a.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Qs=!0,a.borderColor=So.makeHexColor(0|s[0],0|s[1],0|s[2])):a.borderWidth=0}const l=So.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=s.rawDims;a.left=100*(l[0]-d)/h+"%",a.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/h+"%",a.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:a}=this;t%180!=0&&([n,a]=[a,n]),e.style.width=100*n/i+"%",e.style.height=100*a/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],a=s.slice(1);i.target.style[e]=mc[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:mc[`${n}_rgb`](a)})};return go(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const a=i[s];if(a){a({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[a,r,o,l]=t.subarray(2,6);if(s===a&&n===r&&e===o&&i===l)return}const{style:a}=this.container;let r;if(this.#Qs){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],a=t[i+1],c=t[i+2],d=t[i+3],p=h.createElement("rect"),g=(c-e)/o,f=(n-a)/l,_=(s-c)/o,m=(a-d)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",_),p.setAttribute("height",m),u.append(p),r?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${_}" height="${m}"/>`)}this.#Qs&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#Js=new Ic({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){ho("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:a}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||xc.has(r)?i.push({id:n,exportValue:s,domElement:r}):lo(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(xc.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class Tc extends kc{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#tn(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#en(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#in(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#in()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#in()}#tn(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#in()}#en(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#in()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#in()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#in(),!this._fieldObjects)return lo('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,a=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&a.push(i)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const r=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;r.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(xc.has(i)?i.dispatchEvent(new Event("resetform")):lo(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class Sc extends kc{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ec extends kc{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ko.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,a]of i)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,n,a,s),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":So.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let a;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(Er*s))||1);a=Math.min(s,r(e/Er))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(s,r(t/Er))}n.fontSize=`calc(${a}px * var(--total-scale-factor))`,n.color=So.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Cc extends Ec{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),n.setValue(a.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&n.length>a&&(n=n.slice(0,a));let r=s.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=r??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",r??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),xc.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=wc,this._setRequired(i,this.data.required),a&&(i.maxLength=a),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let a=o.userValue;!a||a.length<=s||(a=a.slice(0,s),n.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)})),i.addEventListener("keydown",(t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=l;l=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:a,selectionEnd:r}=s;let l=a,h=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":a===r&&(l-=1);break;case"deleteContentForward":a===r&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Rc extends Ec{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Mc extends Ec{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return xc.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=wc,n.addEventListener("change",(s=>{const{name:n,checked:a}=s.target;for(const s of this._getElementsByName(n,i)){const i=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:a})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["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._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Pc extends Ec{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(xc.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=wc,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["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._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Lc extends Tc{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Dc extends Ec{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");xc.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=wc;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of s.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),a=()=>{t.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const r=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=r(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){a?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:r(!0)}),o=r(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,a=i.detail.remove;if(n[a].selected=!1,s.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(i){const{index:n,displayValue:a,exportValue:h}=i.detail.insert,c=s.children[n],d=document.createElement("option");d.textContent=a,d.value=h,c?c.before(d):s.append(d),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=r(!0),n=r(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(i){t.setValue(e,{value:r(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ic extends kc{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:kc._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Oc({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${Mo}${t}`)).join(",")),this.container}}class Oc{#sn=this.#nn.bind(this);#an=this.#rn.bind(this);#on=this.#ln.bind(this);#hn=this.#cn.bind(this);#dn=null;#_t=null;#un=null;#pn=null;#gn=null;#fn=null;#_n=null;#mn=!1;#vn=null;#E=null;#bn=null;#yn=null;#wn=null;#Ys=null;#xn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:a,richText:r,parent:o,rect:l,parentRect:h,open:c}){this.#_t=t,this.#wn=s,this.#un=a,this.#yn=r,this.#fn=o,this.#dn=e,this.#bn=l,this.#_n=h,this.#gn=i,this.#pn=$o.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#hn),t.addEventListener("mouseenter",this.#on),t.addEventListener("mouseleave",this.#an),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#sn);this.#_t.hidden=!0,c&&this.#cn()}render(){if(this.#vn)return;const t=this.#vn=document.createElement("div");if(t.className="popup",this.#dn){const e=t.style.outlineColor=So.makeHexColor(...this.#dn);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#wn),t.append(e),this.#pn){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#pn.valueOf()})),e.append(t)}const s=this.#An;if(s)yc.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#un);t.append(e)}this.#_t.append(t)}get#An(){const t=this.#yn,e=this.#un;return!t?.str||e?.str&&e.str!==t.str?null:this.#yn.html||null}get#kn(){return this.#An?.attributes?.style?.fontSize||0}get#Tn(){return this.#An?.attributes?.style?.color||null}#Sn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#Tn,fontSize:this.#kn?`calc(${this.#kn}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#nn(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#mn)&&this.#cn()}updateEdited({rect:t,popupContent:e}){this.#Ys||={contentsObj:this.#un,richText:this.#yn},t&&(this.#E=null),e&&(this.#yn=this.#Sn(e),this.#un=null),this.#vn?.remove(),this.#vn=null}resetEdited(){this.#Ys&&(({contentsObj:this.#un,richText:this.#yn}=this.#Ys),this.#Ys=null,this.#vn?.remove(),this.#vn=null,this.#E=null)}#En(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#fn;let a=!!this.#_n,r=a?this.#_n:this.#bn;for(const t of this.#gn)if(!r||null!==So.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=So.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=a?r[2]-r[0]+5:0,h=o[0]+l,c=o[1];this.#E=[100*(h-s)/e,100*(c-n)/i];const{style:d}=this.#_t;d.left=`${this.#E[0]}%`,d.top=`${this.#E[1]}%`}#cn(){this.#mn=!this.#mn,this.#mn?(this.#ln(),this.#_t.addEventListener("click",this.#hn),this.#_t.addEventListener("keydown",this.#sn)):(this.#rn(),this.#_t.removeEventListener("click",this.#hn),this.#_t.removeEventListener("keydown",this.#sn))}#ln(){this.#vn||this.render(),this.isVisible?this.#mn&&this.#_t.classList.add("focused"):(this.#En(),this.#_t.hidden=!1,this.#_t.style.zIndex=parseInt(this.#_t.style.zIndex)+1e3)}#rn(){this.#_t.classList.remove("focused"),!this.#mn&&this.isVisible&&(this.#_t.hidden=!0,this.#_t.style.zIndex=parseInt(this.#_t.style.zIndex)-1e3)}forceHide(){this.#xn=this.isVisible,this.#xn&&(this.#_t.hidden=!0)}maybeShow(){this.#xn&&(this.#vn||this.#ln(),this.#xn=!1,this.#_t.hidden=!1)}get isVisible(){return!1===this.#_t.hidden}}class Nc extends kc{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Fr.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Fc extends kc{#Cn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#Cn=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Cn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Bc extends kc{#Rn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#Rn=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",i-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Rn}addHighlightArea(){this.container.classList.add("highlightArea")}}class jc extends kc{#Mn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#Mn=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",i/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",i/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Mn}addHighlightArea(){this.container.classList.add("highlightArea")}}class zc extends kc{#Pn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:n,height:a}=this;if(!e)return this.container;const r=this.svgFactory.create(n,a,!0);let o=[];for(let i=0,s=e.length;i<s;i+=2){const s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");const l=this.#Pn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Pn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vc extends zc{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Uc extends kc{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Hc extends kc{#Ln=null;#Dn=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Fr.HIGHLIGHT:Fr.INK}#In(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:a,width:r,height:o}=this.#In(e,t),l=this.svgFactory.create(r,o,!0),h=this.#Ln=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#Dn.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#Ln;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#Dn.length;t<e;t++)this.#Dn[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#In(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#Dn}addHighlightArea(){this.container.classList.add("highlightArea")}}class $c extends kc{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Fr.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Wc extends kc{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Gc extends kc{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class qc extends kc{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Kc extends kc{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Fr.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Xc extends kc{#On=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Nn.bind(this)),this.#On=i;const{isMac:s}=ko.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Nn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#On}addHighlightArea(){this.container.classList.add("highlightArea")}#Nn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class Yc{#Fn=null;#Bn=null;#jn=new Map;#zn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:a,structTreeLayer:r}){this.div=t,this.#Fn=e,this.#Bn=i,this.#zn=r||null,this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#jn.size>0}async#Vn(t,e){const i=t.firstChild||t,s=i.id=`${Mo}${e}`,n=await(this.#zn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#Fn?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;Ko(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new bc,annotationStorage:t.annotationStorage||new fl,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===Gr.POPUP;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;n.data=t;const i=Ac.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const a=i.render();t.hidden&&(a.style.visibility="hidden"),await this.#Vn(a,t.id),i._isEditable&&(this.#jn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#Un()}async addLinkAnnotations(t,e){const i={data:null,layer:this.div,linkService:e,svgFactory:new bc,parent:this};for(const e of t){e.borderStyle||=Yc._defaultBorderStyle,i.data=e;const t=Ac.create(i);if(!t.isRenderable)continue;const s=t.render();await this.#Vn(s,e.id)}}update({viewport:t}){const e=this.div;this.viewport=t,Ko(e,{rotation:t.rotation}),this.#Un(),e.hidden=!1}#Un(){if(!this.#Bn)return;const t=this.div;for(const[e,i]of this.#Bn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i);const a=this.#jn.get(e);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),a._hasNoCanvas=!1):a.canvas=i)}this.#Bn.clear()}getEditableAnnotations(){return Array.from(this.#jn.values())}getEditableAnnotation(t){return this.#jn.get(t)}static get _defaultBorderStyle(){return go(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:qr,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const Qc=/\r\n?|\n/g;class Jc extends ll{#dn;#Hn="";#$n=`${this.id}-editor`;#Wn=null;#kn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Jc.prototype,e=t=>t.isEmpty(),i=al.TRANSLATE_SMALL,s=al.TRANSLATE_BIG;return go(this,"_keyboardManager",new sl([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=Fr.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#dn=t.color||Jc._defaultColor||ll._defaultLineColor,this.#kn=t.fontSize||Jc._defaultFontSize}static initialize(t,e){ll.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Br.FREETEXT_SIZE:Jc._defaultFontSize=e;break;case Br.FREETEXT_COLOR:Jc._defaultColor=e}}updateParams(t,e){switch(t){case Br.FREETEXT_SIZE:this.#Gn(e);break;case Br.FREETEXT_COLOR:this.#qn(e)}}static get defaultPropertiesToUpdate(){return[[Br.FREETEXT_SIZE,Jc._defaultFontSize],[Br.FREETEXT_COLOR,Jc._defaultColor||ll._defaultLineColor]]}get propertiesToUpdate(){return[[Br.FREETEXT_SIZE,this.#kn],[Br.FREETEXT_COLOR,this.#dn]]}#Gn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#kn)*this.parentScale),this.#kn=t,this.#Kn()},i=this.#kn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Br.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#qn(t){const e=t=>{this.#dn=this.editorDiv.style.color=t},i=this.#dn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Br.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Jc._internalPadding*t,-(Jc._internalPadding+this.#kn)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Wn=new AbortController;const t=this._uiManager.combinedSignal(this.#Wn);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#$n),this._isDraggable=!0,this.#Wn?.abort(),this.#Wn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Xn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(Jc.#Yn(i)),e=i);return t.join("\n")}#Kn(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Hn,e=this.#Hn=this.#Xn().trimEnd();if(t===e)return;const i=t=>{this.#Hn=t,t?(this.#Qn(),this._uiManager.rebuild(this),this.#Kn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#Kn()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Jc._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#$n),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#kn}px * var(--total-scale-factor))`,i.color=this.#dn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-h)/o,u=e+this.height-(n[1]-c)/l;break;case 90:d=t+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[r,-a];break;case 180:d=t-this.width+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[-a,-r];break;case 270:d=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-c-this.width*o)/l,[a,r]=[-r,a]}this.setAt(d*i,u*s,a,r)}else this._moveAfterPaste(t,e);this.#Qn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Yn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Qc,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=Jc.#Jn(e.getData("text")||"").replaceAll(Qc,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!s.includes("\n"))return a.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:r,startOffset:o}=a,l=[],h=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(h.push(r.nodeValue.slice(o).replaceAll(Qc,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(Jc.#Yn(i)):e=h}l.push(r.nodeValue.slice(0,o).replaceAll(Qc,""))}else if(r===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(Jc.#Yn(i))}this.#Hn=`${l.join("\n")}${s}${h.join("\n")}`,this.#Qn();const c=new Range;let d=Math.sumPrecise(l.map((t=>t.length)));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(d<=e){c.setStart(t,d),c.setEnd(t,d);break}d-=e}n.removeAllRanges(),n.addRange(c)}#Qn(){if(this.editorDiv.replaceChildren(),this.#Hn)for(const t of this.#Hn.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Zn(){return this.#Hn.replaceAll(" "," ")}static#Jn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof Nc){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:a,id:r,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:c}}}=t;if(!l||0===l.length)return null;s=t={annotationType:Fr.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:c-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#kn=t.fontSize,n.#dn=So.makeHexColor(...t.color),n.#Hn=Jc.#Jn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Jc._internalPadding*this.parentScale,i=this.getRect(e,e),s=ll._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#dn),n={annotationType:Fr.FREETEXT,color:s,fontSize:this.#kn,value:this.#Zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(n.isCopy=!0,n):this.annotationElementId&&!this.#ta(n)?null:(n.id=this.annotationElementId,n)}#ta(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#kn}px * var(--total-scale-factor))`,i.color=this.#dn,e.replaceChildren();for(const t of this.#Hn.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=Jc._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Hn}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Zc{static PRECISION=1e-4;toSVGPath(){ho("Abstract method `toSVGPath` must be implemented.")}get box(){ho("Abstract getter `box` must be implemented.")}serialize(t,e){ho("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*s,a[r+1]=i+t[r+1]*n;return a}static _rescaleAndSwap(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*s,a[r+1]=i+t[r]*n;return a}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,a=t.length;n<a;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,a){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+a)/6,(i+n)/2,(s+a)/2]}}class td{#ea;#ia=[];#sa;#na;#aa=[];#ra=new Float32Array(18);#oa;#la;#ha;#ca;#da;#ua;#pa=[];static#ga=8;static#fa=2;static#_a=td.#ga+td.#fa;constructor({x:t,y:e},i,s,n,a,r=0){this.#ea=i,this.#ua=n*s,this.#na=a,this.#ra.set([NaN,NaN,NaN,NaN,t,e],6),this.#sa=r,this.#ca=td.#ga*s,this.#ha=td.#_a*s,this.#da=s,this.#pa.push(t,e)}isEmpty(){return isNaN(this.#ra[8])}#ma(){const t=this.#ra.subarray(4,6),e=this.#ra.subarray(16,18),[i,s,n,a]=this.#ea;return[(this.#oa+(t[0]-e[0])/2-i)/n,(this.#la+(t[1]-e[1])/2-s)/a,(this.#oa+(e[0]-t[0])/2-i)/n,(this.#la+(e[1]-t[1])/2-s)/a]}add({x:t,y:e}){this.#oa=t,this.#la=e;const[i,s,n,a]=this.#ea;let[r,o,l,h]=this.#ra.subarray(8,12);const c=t-l,d=e-h,u=Math.hypot(c,d);if(u<this.#ha)return!1;const p=u-this.#ca,g=p/u,f=g*c,_=g*d;let m=r,v=o;r=l,o=h,l+=f,h+=_,this.#pa?.push(t,e);const b=f/p,y=-_/p*this.#ua,w=b*this.#ua;if(this.#ra.set(this.#ra.subarray(2,8),0),this.#ra.set([l+y,h+w],4),this.#ra.set(this.#ra.subarray(14,18),12),this.#ra.set([l-y,h-w],16),isNaN(this.#ra[6]))return 0===this.#aa.length&&(this.#ra.set([r+y,o+w],2),this.#aa.push(NaN,NaN,NaN,NaN,(r+y-i)/n,(o+w-s)/a),this.#ra.set([r-y,o-w],14),this.#ia.push(NaN,NaN,NaN,NaN,(r-y-i)/n,(o-w-s)/a)),this.#ra.set([m,v,r,o,l,h],6),!this.isEmpty();this.#ra.set([m,v,r,o,l,h],6);return Math.abs(Math.atan2(v-o,m-r)-Math.atan2(_,f))<Math.PI/2?([r,o,l,h]=this.#ra.subarray(2,6),this.#aa.push(NaN,NaN,NaN,NaN,((r+l)/2-i)/n,((o+h)/2-s)/a),[r,o,m,v]=this.#ra.subarray(14,18),this.#ia.push(NaN,NaN,NaN,NaN,((m+r)/2-i)/n,((v+o)/2-s)/a),!0):([m,v,r,o,l,h]=this.#ra.subarray(0,6),this.#aa.push(((m+5*r)/6-i)/n,((v+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),[l,h,r,o,m,v]=this.#ra.subarray(12,18),this.#ia.push(((m+5*r)/6-i)/n,((v+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#aa,e=this.#ia;if(isNaN(this.#ra[6])&&!this.isEmpty())return this.#va();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#ba(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#ya(i),i.join(" ")}#va(){const[t,e,i,s]=this.#ea,[n,a,r,o]=this.#ma();return`M${(this.#ra[2]-t)/i} ${(this.#ra[3]-e)/s} L${(this.#ra[4]-t)/i} ${(this.#ra[5]-e)/s} L${n} ${a} L${r} ${o} L${(this.#ra[16]-t)/i} ${(this.#ra[17]-e)/s} L${(this.#ra[14]-t)/i} ${(this.#ra[15]-e)/s} Z`}#ya(t){const e=this.#ia;t.push(`L${e[4]} ${e[5]} Z`)}#ba(t){const[e,i,s,n]=this.#ea,a=this.#ra.subarray(4,6),r=this.#ra.subarray(16,18),[o,l,h,c]=this.#ma();t.push(`L${(a[0]-e)/s} ${(a[1]-i)/n} L${o} ${l} L${h} ${c} L${(r[0]-e)/s} ${(r[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,a){return new ed(t,e,i,s,n,a)}getOutlines(){const t=this.#aa,e=this.#ia,i=this.#ra,[s,n,a,r]=this.#ea,o=new Float32Array((this.#pa?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#pa[t]-s)/a,o[t+1]=(this.#pa[t+1]-n)/r;if(o[o.length-2]=(this.#oa-s)/a,o[o.length-1]=(this.#la-n)/r,isNaN(i[6])&&!this.isEmpty())return this.#wa(o);const l=new Float32Array(this.#aa.length+24+this.#ia.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#xa(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#Aa(l,h),this.newFreeDrawOutline(l,o,this.#ea,this.#da,this.#sa,this.#na)}#wa(t){const e=this.#ra,[i,s,n,a]=this.#ea,[r,o,l,h]=this.#ma(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/a,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/a,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/a,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/a],0),this.newFreeDrawOutline(c,t,this.#ea,this.#da,this.#sa,this.#na)}#Aa(t,e){const i=this.#ia;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#xa(t,e){const i=this.#ra.subarray(4,6),s=this.#ra.subarray(16,18),[n,a,r,o]=this.#ea,[l,h,c,d]=this.#ma();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/r,(i[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(s[0]-n)/r,(s[1]-a)/o],e),e+24}}class ed extends Zc{#ea;#ka=new Float32Array(4);#sa;#na;#pa;#da;#Ta;constructor(t,e,i,s,n,a){super(),this.#Ta=t,this.#pa=e,this.#ea=i,this.#da=s,this.#sa=n,this.#na=a,this.lastPoint=[NaN,NaN],this.#Sa(a);const[r,o,l,h]=this.#ka;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-r)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-r)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#Ta[4]} ${this.#Ta[5]}`];for(let e=6,i=this.#Ta.length;e<i;e+=6)isNaN(this.#Ta[e])?t.push(`L${this.#Ta[e+4]} ${this.#Ta[e+5]}`):t.push(`C${this.#Ta[e]} ${this.#Ta[e+1]} ${this.#Ta[e+2]} ${this.#Ta[e+3]} ${this.#Ta[e+4]} ${this.#Ta[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const a=i-t,r=s-e;let o,l;switch(n){case 0:o=Zc._rescale(this.#Ta,t,s,a,-r),l=Zc._rescale(this.#pa,t,s,a,-r);break;case 90:o=Zc._rescaleAndSwap(this.#Ta,t,e,a,r),l=Zc._rescaleAndSwap(this.#pa,t,e,a,r);break;case 180:o=Zc._rescale(this.#Ta,i,e,-a,r),l=Zc._rescale(this.#pa,i,e,-a,r);break;case 270:o=Zc._rescaleAndSwap(this.#Ta,i,s,-a,-r),l=Zc._rescaleAndSwap(this.#pa,i,s,-a,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}#Sa(t){const e=this.#Ta;let i=e[4],s=e[5];const n=[i,s,i,s];let a=i,r=s;const o=t?Math.max:Math.min;for(let t=6,l=e.length;t<l;t+=6){const l=e[t+4],h=e[t+5];if(isNaN(e[t]))So.pointBoundingBox(l,h,n),r<h?(a=l,r=h):r===h&&(a=o(a,l));else{const l=[1/0,1/0,-1/0,-1/0];So.bezierBoundingBox(i,s,...e.slice(t,t+6),l),So.rectBoundingBox(...l,n),r<l[3]?(a=l[2],r=l[3]):r===l[3]&&(a=o(a,l[2]))}i=l,s=h}const l=this.#ka;l[0]=n[0]-this.#sa,l[1]=n[1]-this.#sa,l[2]=n[2]-n[0]+2*this.#sa,l[3]=n[3]-n[1]+2*this.#sa,this.lastPoint=[a,r]}get box(){return this.#ka}newOutliner(t,e,i,s,n,a=0){return new td(t,e,i,s,n,a)}getNewOutline(t,e){const[i,s,n,a]=this.#ka,[r,o,l,h]=this.#ea,c=n*l,d=a*h,u=i*l+r,p=s*h+o,g=this.newOutliner({x:this.#pa[0]*c+u,y:this.#pa[1]*d+p},this.#ea,this.#da,t,this.#na,e??this.#sa);for(let t=2;t<this.#pa.length;t+=2)g.add({x:this.#pa[t]*c+u,y:this.#pa[t+1]*d+p});return g.getOutlines()}}class id{#ea;#Ea;#Ca=[];#Ra=[];constructor(t,e=0,i=0,s=!0){const n=[1/0,1/0,-1/0,-1/0],a=1e-4;for(const{x:i,y:s,width:r,height:o}of t){const t=Math.floor((i-e)/a)*a,l=Math.ceil((i+r+e)/a)*a,h=Math.floor((s-e)/a)*a,c=Math.ceil((s+o+e)/a)*a,d=[t,h,c,!0],u=[l,h,c,!1];this.#Ca.push(d,u),So.rectBoundingBox(t,h,l,c,n)}const r=n[2]-n[0]+2*i,o=n[3]-n[1]+2*i,l=n[0]-i,h=n[1]-i,c=this.#Ca.at(s?-1:-2),d=[c[0],c[2]];for(const t of this.#Ca){const[e,i,s]=t;t[0]=(e-l)/r,t[1]=(i-h)/o,t[2]=(s-h)/o}this.#ea=new Float32Array([l,h,r,o]),this.#Ea=d}getOutlines(){this.#Ca.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Ca)e[3]?(t.push(...this.#Ma(e)),this.#Pa(e)):(this.#La(e),t.push(...this.#Ma(e)));return this.#Da(t)}#Da(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,a,r,o,l]=t;i.delete(t);let h=e,c=a;for(n=[e,r],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,a,r,o,l]=t,h!==e&&(n.push(h,c,e,c===a?a:r),h=e),c=c===a?r:a}n.push(h,c)}return new sd(s,this.#ea,this.#Ea)}#Ia(t){const e=this.#Ra;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,a=e[n][0];if(a===t)return n;a<t?i=n+1:s=n-1}return s+1}#Pa([,t,e]){const i=this.#Ia(t);this.#Ra.splice(i,0,[t,e])}#La([,t,e]){const i=this.#Ia(t);for(let s=i;s<this.#Ra.length;s++){const[i,n]=this.#Ra[s];if(i!==t)break;if(i===t&&n===e)return void this.#Ra.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#Ra[s];if(i!==t)break;if(i===t&&n===e)return void this.#Ra.splice(s,1)}}#Ma(t){const[e,i,s]=t,n=[[e,i,s]],a=this.#Ia(s);for(let t=0;t<a;t++){const[i,s]=this.#Ra[t];for(let t=0,a=n.length;t<a;t++){const[,r,o]=n[t];if(!(s<=r||o<=i))if(r>=i)if(o>s)n[t][1]=s;else{if(1===a)return[];n.splice(t,1),t--,a--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class sd extends Zc{#ea;#Oa;constructor(t,e,i){super(),this.#Oa=t,this.#ea=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Oa){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===i?(t.push(`V${r}`),s=r):r===s&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const a=[],r=i-t,o=s-e;for(const e of this.#Oa){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*r,i[n+1]=s-e[n+1]*o;a.push(i)}return a}get box(){return this.#ea}get classNamesForOutlining(){return["highlightOutline"]}}class nd extends td{newFreeDrawOutline(t,e,i,s,n,a){return new ad(t,e,i,s,n,a)}}class ad extends ed{newOutliner(t,e,i,s,n,a=0){return new nd(t,e,i,s,n,a)}}class rd{#Na=null;#Fa=null;#Ba;#ja=null;#za=!1;#Va=!1;#a=null;#Ua;#Ha=null;#_=null;#$a;static#Wa=null;static get _keyboardManager(){return go(this,"_keyboardManager",new sl([[["Escape","mac+Escape"],rd.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],rd.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],rd.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],rd.prototype._moveToPrevious],[["Home","mac+Home"],rd.prototype._moveToBeginning],[["End","mac+End"],rd.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#Va=!1,this.#$a=Br.HIGHLIGHT_COLOR,this.#a=t):(this.#Va=!0,this.#$a=Br.HIGHLIGHT_DEFAULT_COLOR),this.#_=t?._uiManager||e,this.#Ua=this.#_._eventBus,this.#Ba=t?.color||this.#_?.highlightColors.values().next().value||"#FFFF98",rd.#Wa||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#Na=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#_._signal;t.addEventListener("click",this.#Ga.bind(this),{signal:e}),t.addEventListener("keydown",this.#nn.bind(this),{signal:e});const i=this.#Fa=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Ba,t.append(i),t}renderMainDropdown(){const t=this.#ja=this.#qa();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#qa(){const t=document.createElement("div"),e=this.#_._signal;t.addEventListener("contextmenu",Uo,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,s]of this.#_.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",rd.#Wa[i]);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#Ba),n.addEventListener("click",this.#Ka.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#nn.bind(this),{signal:e}),t}#Ka(t,e){e.stopPropagation(),this.#Ua.dispatch("switchannotationeditorparams",{source:this,type:this.#$a,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Na)return void this.#Ga(t);const e=t.target.getAttribute("data-color");e&&this.#Ka(e,t)}_moveToNext(t){this.#Xa?t.target!==this.#Na?t.target.nextSibling?.focus():this.#ja.firstChild?.focus():this.#Ga(t)}_moveToPrevious(t){t.target!==this.#ja?.firstChild&&t.target!==this.#Na?(this.#Xa||this.#Ga(t),t.target.previousSibling?.focus()):this.#Xa&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Xa?this.#ja.firstChild?.focus():this.#Ga(t)}_moveToEnd(t){this.#Xa?this.#ja.lastChild?.focus():this.#Ga(t)}#nn(t){rd._keyboardManager.exec(this,t)}#Ga(t){if(this.#Xa)return void this.hideDropdown();if(this.#za=0===t.detail,this.#Ha||(this.#Ha=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#_.combinedSignal(this.#Ha)})),this.#ja)return void this.#ja.classList.remove("hidden");const e=this.#ja=this.#qa();this.#Na.append(e)}#c(t){this.#ja?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#ja?.classList.add("hidden"),this.#Ha?.abort(),this.#Ha=null}get#Xa(){return this.#ja&&!this.#ja.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Va||(this.#Xa?(this.hideDropdown(),this.#Na.focus({preventScroll:!0,focusVisible:this.#za})):this.#a?.unselect())}updateColor(t){if(this.#Fa&&(this.#Fa.style.backgroundColor=t),!this.#ja)return;const e=this.#_.highlightColors.values();for(const i of this.#ja.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Na?.remove(),this.#Na=null,this.#Fa=null,this.#ja?.remove(),this.#ja=null}}class od extends ll{#Ya=null;#Qa=0;#Ja;#Za=null;#n=null;#tr=null;#er=null;#ir=0;#sr=null;#nr=null;#y=null;#ar=!1;#Ea=null;#rr;#or=null;#lr="";#ua;#hr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Fr.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=od.prototype;return go(this,"_keyboardManager",new sl([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||od._defaultColor,this.#ua=t.thickness||od._defaultThickness,this.#rr=t.opacity||od._defaultOpacity,this.#Ja=t.boxes||null,this.#hr=t.methodOfCreation||"",this.#lr=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#ar=!0,this.#cr(t),this.#dr()):this.#Ja&&(this.#Ya=t.anchorNode,this.#Qa=t.anchorOffset,this.#er=t.focusNode,this.#ir=t.focusOffset,this.#ur(),this.#dr(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#ar?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#ua,methodOfCreation:this.#hr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ur(){const t=new id(this.#Ja,.001);this.#nr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#nr.box;const e=new id(this.#Ja,.0025,.001,"ltr"===this._uiManager.direction);this.#tr=e.getOutlines();const{lastPoint:i}=this.#tr;this.#Ea=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#cr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#nr=t;if(this.#tr=t.getNewOutline(this.#ua/2+1.5,.0025),e>=0)this.#y=e,this.#Za=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#or=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#tr.box,path:{d:this.#tr.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#y,{bbox:od.#pr(this.#nr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#or,{bbox:od.#pr(this.#tr.box,e),path:{d:this.#tr.toSVGPath()}})}const[s,n,a,r]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=a,this.height=r;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=a*e/t,this.height=r*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=a,this.height=r;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=a*e/t,this.height=r*t/e;break}}const{lastPoint:o}=this.#tr;this.#Ea=[(o[0]-s)/a,(o[1]-n)/r]}static initialize(t,e){ll.initialize(t,e),od._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Br.HIGHLIGHT_DEFAULT_COLOR:od._defaultColor=e;break;case Br.HIGHLIGHT_THICKNESS:od._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Ea}updateParams(t,e){switch(t){case Br.HIGHLIGHT_COLOR:this.#qn(e);break;case Br.HIGHLIGHT_THICKNESS:this.#gr(e)}}static get defaultPropertiesToUpdate(){return[[Br.HIGHLIGHT_DEFAULT_COLOR,od._defaultColor],[Br.HIGHLIGHT_THICKNESS,od._defaultThickness]]}get propertiesToUpdate(){return[[Br.HIGHLIGHT_COLOR,this.color||od._defaultColor],[Br.HIGHLIGHT_THICKNESS,this.#ua||od._defaultThickness],[Br.HIGHLIGHT_FREE,this.#ar]]}#qn(t){const e=(t,e)=>{this.color=t,this.#rr=e,this.parent?.drawLayer.updateProperties(this.#y,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#rr;this.addCommands({cmd:e.bind(this,t,od._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Br.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#gr(t){const e=this.#ua,i=t=>{this.#ua=t,this.#fr(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Br.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new rd({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#_r())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#_r())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#mr(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#dr(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#mr():t&&(this.#dr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#fr(t){if(!this.#ar)return;this.#cr({highlightOutlines:this.#nr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#mr(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#or),this.#or=null)}#dr(t=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#Za}=t.drawLayer.draw({bbox:this.#nr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#rr},rootClass:{highlight:!0,free:this.#ar},path:{d:this.#nr.toSVGPath()}},!1,!0)),this.#or=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#ar},bbox:this.#tr.box,path:{d:this.#tr.toSVGPath()}},this.#ar),this.#sr&&(this.#sr.style.clipPath=this.#Za))}static#pr([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#ar?(t=(t-this.rotation+360)%360,i=od.#pr(this.#nr.box,t)):i=od.#pr([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#y,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#or,{bbox:od.#pr(this.#tr.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#lr&&(t.setAttribute("aria-label",this.#lr),t.setAttribute("role","mark")),this.#ar?t.classList.add("free"):this.div.addEventListener("keydown",this.#vr.bind(this),{signal:this._uiManager._signal});const e=this.#sr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Za;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Zo(this,this.#sr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{hovered:!1}})}#vr(t){od._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#br(!0);break;case 1:case 3:this.#br(!1)}}#br(t){if(!this.#Ya)return;const e=window.getSelection();t?e.setPosition(this.#Ya,this.#Qa):e.setPosition(this.#er,this.#ir)}select(){super.select(),this.#or&&this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#or&&(this.parent?.drawLayer.updateProperties(this.#or,{rootClass:{selected:!1}}),this.#ar||this.#br(!1))}get _mustFixPosition(){return!this.#ar}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#y,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#or,{rootClass:{hidden:!t}}))}#_r(){return this.#ar?this.rotation:0}#yr(){if(this.#ar)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Ja,a=new Float32Array(8*n.length);let r=0;for(const{x:o,y:l,width:h,height:c}of n){const n=o*t+i,d=(1-l)*e+s;a[r]=a[r+4]=n,a[r+1]=a[r+3]=d,a[r+2]=a[r+6]=n+h*t,a[r+5]=a[r+7]=d-c*e,r+=8}return a}#wr(t){return this.#nr.serialize(t,this.#_r())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:a,y:r,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=e=>{h.abort(),this.#xr(t,e)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Ho,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",Uo,{signal:c}),i.addEventListener("pointermove",this.#Ar.bind(this,t),{signal:c}),this._freeHighlight=new nd({x:s,y:n},[a,r,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#Ar(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#xr(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof $c){const{data:{quadPoints:e,rect:i,rotation:n,id:a,color:r,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:Fr.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}else if(t instanceof Hc){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:Fr.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}const{color:n,quadPoints:a,inkLists:r,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=So.makeHexColor(...n),l.#rr=o||1,r&&(l.#ua=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,c]=l.pageDimensions,[d,u]=l.pageTranslation;if(a){const t=l.#Ja=[];for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-d)/h,y:1-(a[e+1]-u)/c,width:(a[e+2]-a[e])/h,height:(a[e+1]-a[e+5])/c});l.#ur(),l.#dr(),l.rotate(l.rotation)}else if(r){l.#ar=!0;const t=r[0],i={x:t[0]-d,y:c-(t[1]-u)},s=new nd(i,[0,0,h,c],1,l.#ua/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-d,i.y=c-(t[e+1]-u),s.add(i);const{id:n,clipPathId:a}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#cr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:a}),l.#dr(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=ll._colorManager.convert(this.color),s={annotationType:Fr.HIGHLIGHT,color:i,opacity:this.#rr,thickness:this.#ua,quadPoints:this.#yr(),outlines:this.#wr(e),pageIndex:this.pageIndex,rect:e,rotation:this.#_r(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#ta(s)?null:(s.id=this.annotationElementId,s)}#ta(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class ld{#kr=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#kr[t]=e}toSVGProperties(){const t=this.#kr;return this.#kr=Object.create(null),{root:t}}reset(){this.#kr=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){ho("Not implemented")}}class hd extends ll{#Tr=null;#Sr;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#Er=null;static#Cr=null;static#Rr=null;static#Mr=NaN;static#Pr=null;static#Lr=null;static#Dr=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#Sr=t.mustBeCommitted||!1,this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(this.#Ir(t),this.#dr())}#Ir({drawOutlines:t,drawId:e,drawingOptions:i}){this.#Tr=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Or(t,this.parent),this.#Nr(t.box)}#Or(t,e){const{id:i}=e.drawLayer.draw(hd._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){ho("Not implemented")}static get typesMap(){ho("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(hd.#Er.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],a=t=>{s.updateProperty(e,t);const i=this.#Tr.updateProperty(e,t);i&&this.#Nr(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,hd._mergeSVGProperties(this.#Tr.getPathResizingSVGProperties(this.#Fr()),{bbox:this.#Br()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,hd._mergeSVGProperties(this.#Tr.getPathResizedSVGProperties(this.#Fr()),{bbox:this.#Br()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Br()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,hd._mergeSVGProperties(this.#Tr.getPathTranslatedSVGProperties(this.#Fr(),this.parentDimensions),{bbox:this.#Br()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#Sr&&(this.#Sr=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#mr(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#dr(),this.#Nr(this.#Tr.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#mr()):t&&(this._uiManager.addShouldRescale(this),this.#dr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#mr(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#dr(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Or(this.#Tr,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#jr([t,e,i,s]){const{parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[e,1-t,i*(a/n),s*(n/a)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(a/n),s*(n/a)];default:return[t,e,i,s]}}#Fr(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[1-e,t,i*(n/a),s*(a/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/a),s*(a/n)];default:return[t,e,i,s]}}#Nr(t){if([this.x,this.y,this.width,this.height]=this.#jr(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Br(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:a,parentDimensions:[r,o]}=this;switch((4*n+a)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(r/o),s*(o/r),i*(r/o)];case 5:return[1-e,t,i*(r/o),s*(o/r)];case 6:return[1-t-s*(o/r),1-e,s*(o/r),i*(r/o)];case 7:return[e-i*(r/o),1-t-s*(o/r),i*(r/o),s*(o/r)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/r),e,s*(o/r),i*(r/o)];case 13:return[1-e-i*(r/o),t-s*(o/r),i*(r/o),s*(o/r)];case 14:return[1-t,1-e-i*(r/o),s*(o/r),i*(r/o)];case 15:return[e,1-t,i*(r/o),s*(o/r)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,hd._mergeSVGProperties({bbox:this.#Br()},this.#Tr.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Nr(this.#Tr.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const s=document.createElement("div");i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){ho("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:a,offsetY:r,pointerId:o,pointerType:l}=s;if(hd.#Pr&&hd.#Pr!==l)return;const{viewport:{rotation:h}}=t,{width:c,height:d}=n.getBoundingClientRect(),u=hd.#Cr=new AbortController,p=t.combinedSignal(u);hd.#Mr||=o,hd.#Pr??=l,window.addEventListener("pointerup",(t=>{hd.#Mr===t.pointerId?this._endDraw(t):hd.#Lr?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{hd.#Mr===t.pointerId?this._currentParent.endDrawingSession():hd.#Lr?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{hd.#Pr===t.pointerType&&((hd.#Lr||=new Set).add(t.pointerId),hd.#Er.isCancellable()&&(hd.#Er.removeLastElement(),hd.#Er.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Uo,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===hd.#Dr&&Ho(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),hd.#Er?t.drawLayer.updateProperties(this._currentDrawId,hd.#Er.startNew(a,r,c,d,h)):(e.updateUIForDefaultProperties(this),hd.#Er=this.createDrawerInstance(a,r,c,d,h),hd.#Rr=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(hd.#Rr.toSVGProperties(),hd.#Er.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(hd.#Dr=-1,!hd.#Er)return;const{offsetX:e,offsetY:i,pointerId:s}=t;hd.#Mr===s&&(hd.#Lr?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,hd.#Er.add(e,i)),hd.#Dr=t.timeStamp,Ho(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,hd.#Er=null,hd.#Rr=null,hd.#Pr=null,hd.#Dr=NaN),hd.#Cr&&(hd.#Cr.abort(),hd.#Cr=null,hd.#Mr=NaN,hd.#Lr=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,hd.#Er.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=hd.#Er,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:Br.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Br.DRAW_STEP),!hd.#Er.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:hd.#Er.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:hd.#Rr,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,a){ho("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:a,pageY:r}}=e.viewport,o=this.deserializeDraw(a,r,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#Ir({drawOutlines:o}),l.#dr(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#Tr.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class cd{#ra=new Float64Array(6);#Cn;#zr;#as;#ua;#pa;#Vr="";#Ur=0;#Oa=new dd;#Hr;#$r;constructor(t,e,i,s,n,a){this.#Hr=i,this.#$r=s,this.#as=n,this.#ua=a,[t,e]=this.#Wr(t,e);const r=this.#Cn=[NaN,NaN,NaN,NaN,t,e];this.#pa=[t,e],this.#zr=[{line:r,points:this.#pa}],this.#ra.set(r,0)}updateProperty(t,e){"stroke-width"===t&&(this.#ua=e)}#Wr(t,e){return Zc._normalizePoint(t,e,this.#Hr,this.#$r,this.#as)}isEmpty(){return!this.#zr||0===this.#zr.length}isCancellable(){return this.#pa.length<=10}add(t,e){[t,e]=this.#Wr(t,e);const[i,s,n,a]=this.#ra.subarray(2,6),r=t-n,o=e-a;return Math.hypot(this.#Hr*r,this.#$r*o)<=2?null:(this.#pa.push(t,e),isNaN(i)?(this.#ra.set([n,a,t,e],2),this.#Cn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#ra[0])&&this.#Cn.splice(6,6),this.#ra.set([i,s,n,a,t,e],0),this.#Cn.push(...Zc.createBezierPoints(i,s,n,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#pa.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#Hr=i,this.#$r=s,this.#as=n,[t,e]=this.#Wr(t,e);const a=this.#Cn=[NaN,NaN,NaN,NaN,t,e];this.#pa=[t,e];const r=this.#zr.at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),this.#zr.push({line:a,points:this.#pa}),this.#ra.set(a,0),this.#Ur=0,this.toSVGPath(),null}getLastElement(){return this.#zr.at(-1)}setLastElement(t){return this.#zr?(this.#zr.push(t),this.#Cn=t.line,this.#pa=t.points,this.#Ur=0,{path:{d:this.toSVGPath()}}):this.#Oa.setLastElement(t)}removeLastElement(){if(!this.#zr)return this.#Oa.removeLastElement();this.#zr.pop(),this.#Vr="";for(let t=0,e=this.#zr.length;t<e;t++){const{line:e,points:i}=this.#zr[t];this.#Cn=e,this.#pa=i,this.#Ur=0,this.toSVGPath()}return{path:{d:this.#Vr}}}toSVGPath(){const t=Zc.svgRound(this.#Cn[4]),e=Zc.svgRound(this.#Cn[5]);if(2===this.#pa.length)return this.#Vr=`${this.#Vr} M ${t} ${e} Z`,this.#Vr;if(this.#pa.length<=6){const i=this.#Vr.lastIndexOf("M");this.#Vr=`${this.#Vr.slice(0,i)} M ${t} ${e}`,this.#Ur=6}if(4===this.#pa.length){const t=Zc.svgRound(this.#Cn[10]),e=Zc.svgRound(this.#Cn[11]);return this.#Vr=`${this.#Vr} L ${t} ${e}`,this.#Ur=12,this.#Vr}const i=[];0===this.#Ur&&(i.push(`M ${t} ${e}`),this.#Ur=6);for(let t=this.#Ur,e=this.#Cn.length;t<e;t+=6){const[e,s,n,a,r,o]=this.#Cn.slice(t,t+6).map(Zc.svgRound);i.push(`C${e} ${s} ${n} ${a} ${r} ${o}`)}return this.#Vr+=i.join(" "),this.#Ur=this.#Cn.length,this.#Vr}getOutlines(t,e,i,s){const n=this.#zr.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Oa.build(this.#zr,t,e,i,this.#as,this.#ua,s),this.#ra=null,this.#Cn=null,this.#zr=null,this.#Vr=null,this.#Oa}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class dd extends Zc{#ka;#Gr=0;#sa;#zr;#Hr;#$r;#qr;#as;#ua;build(t,e,i,s,n,a,r){this.#Hr=e,this.#$r=i,this.#qr=s,this.#as=n,this.#ua=a,this.#sa=r??0,this.#zr=t,this.#Kr()}get thickness(){return this.#ua}setLastElement(t){return this.#zr.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#zr.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#zr)if(t.push(`M${Zc.svgRound(e[4])} ${Zc.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Zc.svgRound(e[10])} ${Zc.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){const[s,n,a,r,o,l]=e.subarray(i,i+6).map(Zc.svgRound);t.push(`C${s} ${n} ${a} ${r} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const a=[],r=[],[o,l,h,c]=this.#Xr();let d,u,p,g,f,_,m,v,b;switch(this.#as){case 0:b=Zc._rescale,d=t,u=e+s,p=i,g=-s,f=t+o*i,_=e+(1-l-c)*s,m=t+(o+h)*i,v=e+(1-l)*s;break;case 90:b=Zc._rescaleAndSwap,d=t,u=e,p=i,g=s,f=t+l*i,_=e+o*s,m=t+(l+c)*i,v=e+(o+h)*s;break;case 180:b=Zc._rescale,d=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,_=e+l*s,m=t+(1-o)*i,v=e+(l+c)*s;break;case 270:b=Zc._rescaleAndSwap,d=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-c)*i,_=e+(1-o-h)*s,m=t+(1-l)*i,v=e+(1-o)*s}for(const{line:t,points:e}of this.#zr)a.push(b(t,d,u,p,g,n?new Array(t.length):null)),r.push(b(e,d,u,p,g,n?new Array(e.length):null));return{lines:a,points:r,rect:[f,_,m,v]}}static deserialize(t,e,i,s,n,{paths:{lines:a,points:r},rotation:o,thickness:l}){const h=[];let c,d,u,p,g;switch(o){case 0:g=Zc._rescale,c=-t/i,d=e/s+1,u=1/i,p=-1/s;break;case 90:g=Zc._rescaleAndSwap,c=-e/s,d=-t/i,u=1/s,p=1/i;break;case 180:g=Zc._rescale,c=t/i+1,d=-e/s,u=-1/i,p=1/s;break;case 270:g=Zc._rescaleAndSwap,c=e/s+1,d=t/i+1,u=-1/s,p=-1/i}if(!a){a=[];for(const t of r){const e=t.length;if(2===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));a.push(i);let[s,n,r,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let a=4;a<e;a+=2){const e=t[a],l=t[a+1];i.set(Zc.createBezierPoints(s,n,r,o,e,l),3*(a-2)),[s,n,r,o]=[r,o,e,l]}}}for(let t=0,e=a.length;t<e;t++)h.push({line:g(a[t].map((t=>t??NaN)),c,d,u,p),points:g(r[t].map((t=>t??NaN)),c,d,u,p)});const f=new this.prototype.constructor;return f.build(h,i,s,1,o,l,n),f}#Yr(t=this.#ua){const e=this.#sa+t/2*this.#qr;return this.#as%180==0?[e/this.#Hr,e/this.#$r]:[e/this.#$r,e/this.#Hr]}#Xr(){const[t,e,i,s]=this.#ka,[n,a]=this.#Yr(0);return[t+n,e+a,i-2*n,s-2*a]}#Kr(){const t=this.#ka=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#zr){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)So.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let n=6,a=e.length;n<a;n+=6){const[a,r,o,l,h,c]=e.subarray(n,n+6);So.bezierBoundingBox(i,s,a,r,o,l,h,c,t),i=h,s=c}}const[e,i]=this.#Yr();t[0]=Po(t[0]-e,0,1),t[1]=Po(t[1]-i,0,1),t[2]=Po(t[2]+e,0,1),t[3]=Po(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#ka}updateProperty(t,e){return"stroke-width"===t?this.#gr(e):null}#gr(t){const[e,i]=this.#Yr();this.#ua=t;const[s,n]=this.#Yr(),[a,r]=[s-e,n-i],o=this.#ka;return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o}updateParentDimensions([t,e],i){const[s,n]=this.#Yr();this.#Hr=t,this.#$r=e,this.#qr=i;const[a,r]=this.#Yr(),o=a-s,l=r-n,h=this.#ka;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Gr=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#ka.map(Zc.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#ka;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zc.svgRound(t)} ${Zc.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#ka;let i=0,s=0,n=0,a=0,r=0,o=0;switch(this.#Gr){case 90:s=e/t,n=-t/e,r=t;break;case 180:i=-1,a=-1,r=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${a} ${Zc.svgRound(r)} ${Zc.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,a]=this.#Yr(),[r,o,l,h]=this.#ka;if(Math.abs(l-n)<=Zc.PRECISION||Math.abs(h-a)<=Zc.PRECISION){const n=t+i/2-(r+l/2),a=e+s/2-(o+h/2);return{path:{"transform-origin":`${Zc.svgRound(t)} ${Zc.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${a})`}}}const c=(i-2*n)/(l-2*n),d=(s-2*a)/(h-2*a),u=l/i,p=h/s;return{path:{"transform-origin":`${Zc.svgRound(r)} ${Zc.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Zc.svgRound(n)} ${Zc.svgRound(a)}) scale(${c} ${d}) translate(${Zc.svgRound(-n)} ${Zc.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,a]=this.#Yr(),r=this.#ka,[o,l,h,c]=r;if(r[0]=t,r[1]=e,r[2]=i,r[3]=s,Math.abs(h-n)<=Zc.PRECISION||Math.abs(c-a)<=Zc.PRECISION){const n=t+i/2-(o+h/2),a=e+s/2-(l+c/2);for(const{line:t,points:e}of this.#zr)Zc._translate(t,n,a,t),Zc._translate(e,n,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zc.svgRound(t)} ${Zc.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(i-2*n)/(h-2*n),u=(s-2*a)/(c-2*a),p=-d*(o+n)+t+n,g=-u*(l+a)+e+a;if(1!==d||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#zr)Zc._rescale(t,p,g,d,u,t),Zc._rescale(e,p,g,d,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Zc.svgRound(t)} ${Zc.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,a=this.#ka,r=t-a[0],o=e-a[1];if(this.#Hr===s&&this.#$r===n)for(const{line:t,points:e}of this.#zr)Zc._translate(t,r,o,t),Zc._translate(e,r,o,e);else{const t=this.#Hr/s,e=this.#$r/n;this.#Hr=s,this.#$r=n;for(const{line:i,points:s}of this.#zr)Zc._rescale(i,r,o,t,e,i),Zc._rescale(s,r,o,t,e,s);a[2]*=t,a[3]*=e}return a[0]=t,a[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Zc.svgRound(t)} ${Zc.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#ka;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Zc.svgRound(t[0])} ${Zc.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class ud extends ld{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:ll._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new ud(this._viewParameters);return t.updateAll(this),t}}class pd extends hd{static _type="ink";static _editorType=Fr.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){ll.initialize(t,e),this._defaultDrawingOptions=new ud(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return go(this,"typesMap",new Map([[Br.INK_THICKNESS,"stroke-width"],[Br.INK_COLOR,"stroke"],[Br.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new cd(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,a){return dd.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){let s=null;if(t instanceof Hc){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:c}}}=t;s=t={annotationType:Fr.INK,color:Array.from(r),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:c-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=pd.getDefaultDrawingOptions({stroke:So.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":a,"stroke-width":r}}=this,o={annotationType:Fr.INK,color:ll._colorManager.convert(n),opacity:a,thickness:r,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(o.isCopy=!0,o):this.annotationElementId&&!this.#ta(o)?null:(o.id=this.annotationElementId,o)}#ta(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class gd extends dd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class fd{static#Qr={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Jr(t,e,i,s){return s-=e,0===(i-=t)?s>0?0:4:1===i?s+6:2-s}static#Zr=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#to(t,e,i,s,n,a,r){const o=this.#Jr(i,s,n,a);for(let n=0;n<8;n++){const a=(-n+o-r+16)%8;if(0!==t[(i+this.#Zr[2*a])*e+(s+this.#Zr[2*a+1])])return a}return-1}static#eo(t,e,i,s,n,a,r){const o=this.#Jr(i,s,n,a);for(let n=0;n<8;n++){const a=(n+o+r+16)%8;if(0!==t[(i+this.#Zr[2*a])*e+(s+this.#Zr[2*a+1])])return a}return-1}static#io(t,e,i,s){const n=t.length,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=t[e]<=s?1:0;for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let r,o=1;const l=[];for(let t=1;t<i-1;t++){r=1;for(let i=1;i<e-1;i++){const s=t*e+i,n=a[s];if(0===n)continue;let h=t,c=i;if(1===n&&0===a[s-1])o+=1,c-=1;else{if(!(n>=1&&0===a[s+1])){1!==n&&(r=Math.abs(n));continue}o+=1,c+=1,n>1&&(r=n)}const d=[i,t],u=c===i+1,p={isHole:u,points:d,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===r){g=t;break}g?g.isHole?p.parent=u?g.parent:r:p.parent=u?r:g.parent:p.parent=u?r:0;const f=this.#to(a,e,t,i,h,c,0);if(-1===f){a[s]=-o,1!==a[s]&&(r=Math.abs(a[s]));continue}let _=this.#Zr[2*f],m=this.#Zr[2*f+1];const v=t+_,b=i+m;h=v,c=b;let y=t,w=i;for(;;){const n=this.#eo(a,e,y,w,h,c,1);_=this.#Zr[2*n],m=this.#Zr[2*n+1];const l=y+_,u=w+m;d.push(u,l);const p=y*e+w;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&u===i&&y===v&&w===b){1!==a[s]&&(r=Math.abs(a[s]));break}h=y,c=w,y=l,w=u}}}return l}static#so(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[e],a=t[e+1],r=t[i-4]-n,o=t[i-3]-a,l=Math.hypot(r,o),h=r/l,c=o/l,d=h*a-c*n,u=o/r,p=1/l,g=Math.atan(u),f=Math.cos(g),_=Math.sin(g),m=p*(Math.abs(f)+Math.abs(_)),v=p*(1-m+m**2),b=Math.max(Math.atan(Math.abs(_+f)*v),Math.atan(Math.abs(_-f)*v));let y=0,w=e;for(let s=e+2;s<i-2;s+=2){const e=Math.abs(d-h*t[s+1]+c*t[s]);e>y&&(w=s,y=e)}y>(l*b)**2?(this.#so(t,e,w+2,s),this.#so(t,w,i,s)):s.push(n,a)}static#no(t){const e=[],i=t.length;return this.#so(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#ao(t,e,i,s,n,a){const r=new Float32Array(a**2),o=-2*s**2,l=a>>1;for(let t=0;t<a;t++){const e=(t-l)**2;for(let i=0;i<a;i++)r[t*a+i]=Math.exp((e+(i-l)**2)/o)}const h=new Float32Array(256),c=-2*n**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/c);const d=t.length,u=new Uint8Array(d),p=new Uint32Array(256);for(let s=0;s<i;s++)for(let n=0;n<e;n++){const o=s*e+n,c=t[o];let d=0,g=0;for(let o=0;o<a;o++){const u=s+o-l;if(!(u<0||u>=i))for(let i=0;i<a;i++){const s=n+i-l;if(s<0||s>=e)continue;const p=t[u*e+s],f=r[o*a+i]*h[Math.abs(p-c)];d+=p*f,g+=f}}p[u[o]=Math.round(d/g)]++}return[u,p]}static#ro(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#oo(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let e=0,a=i.length;e<a;e++){if(0===t[3+(e<<2)]){s=i[e]=255;continue}const a=i[e]=t[e<<2];a>s&&(s=a),a<n&&(n=a)}const a=255/(s-n);for(let t=0;t<e;t++)i[t]=(i[t]-n)*a;return i}static#lo(t){let e,i=-1/0,s=-1/0;const n=t.findIndex((t=>0!==t));let a=n,r=n;for(e=n;e<256;e++){const n=t[e];n>i&&(e-a>s&&(s=e-a,r=e-1),i=n,a=e)}for(e=r-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#ho(t){const e=t,{width:i,height:s}=t,{maxDim:n}=this.#Qr;let a=i,r=s;if(i>n||s>n){let o=i,l=s,h=Math.log2(Math.max(i,s)/n);const c=Math.floor(h);h=h===c?c-1:c;for(let i=0;i<h;i++){a=Math.ceil(o/2),r=Math.ceil(l/2);const i=new OffscreenCanvas(a,r);i.getContext("2d").drawImage(t,0,0,o,l,0,0,a,r),o=a,l=r,t!==e&&t.close(),t=i.transferToImageBitmap()}const d=Math.min(n/a,n/r);a=Math.round(a*d),r=Math.round(r*d)}const o=new OffscreenCanvas(a,r).getContext("2d",{willReadFrequently:!0});o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,a,r);const l=o.getImageData(0,0,a,r).data;return[this.#oo(l),a,r]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,a,r,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:_,width:m}=h.measureText(t),v=1.5,b=Math.ceil(Math.max(Math.abs(d)+Math.abs(u)||0,m)*v),y=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(_)||200)*v);l=new OffscreenCanvas(b,y),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=c,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,b,y),h.fillStyle="black",h.fillText(t,.5*b/2,1.5*y/2);const w=this.#oo(h.getImageData(0,0,b,y).data),x=this.#ro(w),A=this.#lo(x),k=this.#io(w,b,y,A);return this.processDrawnLines({lines:{curves:k,width:b,height:y},pageWidth:n,pageHeight:a,rotation:r,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[a,r,o]=this.#ho(t),[l,h]=this.#ao(a,r,o,Math.hypot(r,o)*this.#Qr.sigmaSFactor,this.#Qr.sigmaR,this.#Qr.kernelSize),c=this.#lo(h),d=this.#io(l,r,o,c);return this.processDrawnLines({lines:{curves:d,width:r,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:a,areContours:r}){s%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,f=[];for(const{points:t}of o){const e=a?this.#no(t):t;if(!e)continue;f.push(e);const i=e.length,s=new Float32Array(i),n=new Float32Array(3*(2===i?2:i-2));if(d.push({line:n,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[r,o,l,h]=e;r*=p,o*=g,l*=p,h*=g,s.set([r,o,l,h],0),n.set([NaN,NaN,NaN,NaN,r,o],0);for(let t=4;t<i;t+=2){const i=s[t]=e[t]*p,a=s[t+1]=e[t+1]*g;n.set(Zc.createBezierPoints(r,o,l,h,i,a),3*(t-2)),[r,o,l,h]=[l,h,i,a]}}if(0===d.length)return null;const _=r?new gd:new dd;return _.build(d,e,i,1,s,r?0:c,n),{outline:_,newCurves:f,areContours:r,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let a,r=1/0,o=-1/0,l=0;for(const e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];r=Math.min(r,i),o=Math.max(o,i)}}a=r>=-128&&o<=127?Int8Array:r>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,c=8+3*h,d=new Uint32Array(c);let u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*a.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=s,d[u++]=n,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(i??0)),d[u++]=h,d[u++]=a.BYTES_PER_ELEMENT;for(const e of t)d[u++]=e.length-2,d[u++]=e[0],d[u++]=e[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const f=a.prototype.constructor;for(const e of t){const t=new f(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}g.close();const _=await new Response(p.readable).arrayBuffer();return Lo(new Uint8Array(_))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):Ao(atob(e))),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),a=n.getWriter();await a.ready,a.write(i).then((async()=>{await a.ready,await a.close()})).catch((()=>{}));let r=null,o=0;for await(const t of s)r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),r.set(t,o),o+=t.length;const l=new Uint32Array(r.buffer,0,r.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],u=0===l[4],p=l[5],g=l[6],f=l[7],_=[],m=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let v;switch(f){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(r.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(r.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(r.buffer,m)}o=0;for(let t=0;t<g;t++){const e=l[3*t+8],i=new Float32Array(e+2);_.push(i);for(let e=0;e<2;e++)i[e]=l[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+v[o++]}return{areContours:u,thickness:p,outlines:_,width:c,height:d}}catch(t){return lo(`decompressSignature: ${t}`),null}var e}}class _d extends ld{constructor(){super(),super.updateProperties({fill:ll._defaultLineColor,"stroke-width":0})}clone(){const t=new _d;return t.updateAll(this),t}}class md extends ud{constructor(t){super(t),super.updateProperties({stroke:ll._defaultLineColor,"stroke-width":1})}clone(){const t=new md(this._viewParameters);return t.updateAll(this),t}}class vd extends hd{#co=!1;#do=null;#uo=null;#po=null;static _type="signature";static _editorType=Fr.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#uo=t.signatureData||null,this.#do=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){ll.initialize(t,e),this._defaultDrawingOptions=new _d,this._defaultDrawnSignatureOptions=new md(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return go(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#do}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#uo){const{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:a}=this.#uo,{rawDims:{pageWidth:r,pageHeight:o},rotation:l}=this.parent.viewport,h=fd.processDrawnLines({lines:t,pageWidth:r,pageHeight:o,rotation:l,innerMargin:vd._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,a,s,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#po=t,this.addEditToolbar()}getUuid(){return this.#po}get description(){return this.#do}set description(t){this.#do=t,super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#uo,a=Math.max(s,n);return{areContours:e,outline:fd.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:i,width:s,height:n},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.signatureManager&&null!==this.#do&&(await t.addEditSignatureButton(this._uiManager.signatureManager,this.#po,this.#do),t.show()),t):null}addSignature(t,e,i,s){const{x:n,y:a}=this,{outline:r}=this.#uo=t;let o;this.#co=r instanceof gd,this.#do=i,this.div.setAttribute("data-l10n-args",JSON.stringify({description:i})),this.#co?o=vd.getDefaultDrawingOptions():(o=vd._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":r.thickness})),this._addOutlines({drawOutlines:r,drawingOptions:o});const[l,h]=this.parentDimensions,[,c]=this.pageDimensions;let d=e/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(l*this.width,h*this.height),this.x=n,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return fd.process(t,e,i,s,vd._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return fd.extractContoursFromText(t,e,i,s,n,vd._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return fd.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:vd._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=vd.getDefaultDrawingOptions():(this._drawingOptions=vd._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,a={annotationType:Fr.SIGNATURE,isSignature:!0,areContours:this.#co,color:[0,0,0],thickness:this.#co?0:n,pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(a.paths={lines:e,points:i},a.uuid=this.#po,a.isCopy=!0):a.lines=e,this.#do&&(a.accessibilityData={type:"Figure",alt:this.#do}),a}static deserializeDraw(t,e,i,s,n,a){return a.areContours?gd.deserialize(t,e,i,s,n,a):dd.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);return s.#co=t.areContours,s.#do=t.accessibilityData?.alt||"",s.#po=t.uuid,s}}class bd extends ll{#go=null;#fo=null;#_o=null;#mo=null;#vo=null;#bo="";#yo=null;#wo=!1;#xo=null;#Ao=!1;#ko=!1;static _type="stamp";static _editorType=Fr.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#mo=t.bitmapUrl,this.#vo=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){ll.initialize(t,e)}static isHandlingMimeForPasting(t){return Yo.includes(t)}static paste(t,e){e.pasteEditor({mode:Fr.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#To(t,e=!1){t?(this.#go=t.bitmap,e||(this.#fo=t.id,this.#Ao=t.isSvg),t.file&&(this.#bo=t.file.name),this.#So()):this.remove()}#Eo(){if(this.#_o=null,this._uiManager.enableWaiting(!1),this.#yo){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#go)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#go){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:a}=t||this.copyCanvas(null,null,!0).imageData,r=await i.guess({name:"altText",request:{data:s,width:n,height:a,channels:s.length/(n*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#Co(){if(this.#fo)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#fo).then((t=>this.#To(t,!0))).finally((()=>this.#Eo()));if(this.#mo){const t=this.#mo;return this.#mo=null,this._uiManager.enableWaiting(!0),void(this.#_o=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#To(t))).finally((()=>this.#Eo())))}if(this.#vo){const t=this.#vo;return this.#vo=null,this._uiManager.enableWaiting(!0),void(this.#_o=this._uiManager.imageManager.getFromFile(t).then((t=>this.#To(t))).finally((()=>this.#Eo())))}const t=document.createElement("input");t.type="file",t.accept=Yo.join(",");const e=this._uiManager._signal;this.#_o=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#To(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Eo())),t.click()}remove(){this.#fo&&(this.#go=null,this._uiManager.imageManager.deleteId(this.#fo),this.#yo?.remove(),this.#yo=null,this.#xo&&(clearTimeout(this.#xo),this.#xo=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#fo&&null===this.#yo&&this.#Co(),this.isAttachedToDOM||this.parent.add(this))):this.#fo&&this.#Co()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#_o||this.#go||this.#mo||this.#vo||this.#fo||this.#wo)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#wo||(this.#go?this.#So():this.#Co()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#fo=i,s&&(this.#go=s),this.#wo=!1,this.#So())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#xo&&clearTimeout(this.#xo);this.#xo=setTimeout((()=>{this.#xo=null,this.#Ro()}),200)}#So(){const{div:t}=this;let{width:e,height:i}=this.#go;const[s,n]=this.pageDimensions,a=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>a*s||i>a*n){const t=Math.min(a*s/e,a*n/i);e*=t,i*=t}const[r,o]=this.parentDimensions;this.setDims(e*r/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#yo=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#Ro(),this.#ko||(this.parent.addUndoableEditor(this),this.#ko=!0),this._reportTelemetry({action:"inserted_image"}),this.#bo&&this.div.setAttribute("aria-description",this.#bo)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#go,a=new Xo;let r=this.#go,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*a.sx),i=h.height=Math.ceil(l*a.sy);this.#Ao||(r=this.#Mo(t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const p=15,g=p*a.sx,f=p*a.sy,_=new OffscreenCanvas(2*g,2*f),m=_.getContext("2d");m.fillStyle=d,m.fillRect(0,0,2*g,2*f),m.fillStyle=u,m.fillRect(0,0,g,f),m.fillRect(g,f,g,f),c.fillStyle=c.createPattern(_,"repeat"),c.fillRect(0,0,t,i),c.drawImage(r,0,0,r.width,r.height,0,0,t,i)}let c=null;if(i){let e,i;if(a.symmetric&&r.width<t&&r.height<t)e=r.width,i=r.height;else if(r=this.#go,s>t||n>t){const a=Math.min(t/s,t/n);e=Math.floor(s*a),i=Math.floor(n*a),this.#Ao||(r=this.#Mo(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.height,0,0,e,i),c={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:c}}#Mo(t,e){const{width:i,height:s}=this.#go;let n=i,a=s,r=this.#go;for(;n>2*t||a>2*e;){const i=n,s=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,i,s,0,0,n,a),r=o.transferToImageBitmap()}return r}#Ro(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Xo,a=Math.ceil(i*t*n.sx),r=Math.ceil(s*e*n.sy),o=this.#yo;if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const l=this.#Ao?this.#go:this.#Mo(a,r),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,r)}#Po(t){if(t){if(this.#Ao){const t=this._uiManager.imageManager.getSvgUrl(this.#fo);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#go);return t.getContext("2d").drawImage(this.#go,0,0),t.toDataURL()}if(this.#Ao){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Io.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Io.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#go,0,0,this.#go.width,this.#go.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#go)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof Kc){const{data:{rect:a,rotation:r,id:o,structParent:l,popupRef:h},container:c,parent:{page:{pageNumber:d}},canvas:u}=t;let p,g;u?(delete t.canvas,({id:p,bitmap:g}=i.imageManager.getFromCanvas(c.id,u)),u.remove()):(n=!0,t._hasNoCanvas=!0);const f=(await e._structTree.getAriaAttributes(`${Mo}${o}`))?.get("aria-label")||"";s=t={annotationType:Fr.STAMP,bitmapId:p,bitmap:g,pageIndex:d-1,rect:a.slice(0),rotation:r,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:f},isSvg:!1,structParent:l,popupRef:h}}const a=await super.deserialize(t,e,i),{rect:r,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:d}=t;n?(i.addMissingCanvas(t.id,a),a.#wo=!0):h&&i.imageManager.isValidId(h)?(a.#fo=h,o&&(a.#go=o)):a.#mo=l,a.#Ao=c;const[u,p]=a.pageDimensions;return a.width=(r[2]-r[0])/u,a.height=(r[3]-r[1])/p,a.annotationElementId=t.id||null,d&&(a.altTextData=d),a._initialData=s,a.#ko=!!s,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:Fr.STAMP,bitmapId:this.#fo,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Ao,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#Po(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#ta(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const a=this.#Ao?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#fo)){if(this.#Ao){const t=e.stamps.get(this.#fo);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Po(!1))}}else e.stamps.set(this.#fo,{area:a,serialized:i}),i.bitmap=this.#Po(!1);return i}#ta(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class yd{#Fn;#Lo=!1;#Do=null;#Io=null;#Oo=null;#No=new Map;#Fo=!1;#Bo=!1;#jo=!1;#zo=null;#Vo=null;#Uo=null;#Ho=null;#_;static _initialized=!1;static#U=new Map([Jc,pd,bd,od,vd].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:a,drawLayer:r,textLayer:o,viewport:l,l10n:h}){const c=[...yd.#U.values()];if(!yd._initialized){yd._initialized=!0;for(const e of c)e.initialize(h,t)}t.registerEditorTypes(c),this.#_=t,this.pageIndex=e,this.div=i,this.#Fn=n,this.#Do=a,this.viewport=l,this.#Uo=o,this.drawLayer=r,this._structTree=s,this.#_.addLayer(this)}get isEmpty(){return 0===this.#No.size}get isInvisible(){return this.isEmpty&&this.#_.getMode()===Fr.NONE}updateToolbar(t){this.#_.updateToolbar(t)}updateMode(t=this.#_.getMode()){switch(this.#$o(),t){case Fr.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Fr.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Fr.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const i of yd.#U.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#Uo?.div}setEditingState(t){this.#_.setEditingState(t)}addCommands(t){this.#_.addCommands(t)}cleanUndoStack(t){this.#_.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Do?.div.classList.toggle("disabled",!t)}async enable(){this.#jo=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#No.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#_.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#Do)return void(this.#jo=!1);const e=this.#Do.getEditableAnnotations();for(const i of e){if(i.hide(),this.#_.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#jo=!1}disable(){this.#Bo=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#No.values())i.disableEditing(),i.annotationElementId&&(null===i.serialize()?(e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()):t.set(i.annotationElementId,i));if(this.#Do){const i=this.#Do.getEditableAnnotations();for(const s of i){const{id:i}=s.data;if(this.#_.isDeletedAnnotationElement(i))continue;let n=e.get(i);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=t.get(i),n&&(this.#_.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#$o(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of yd.#U.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#Bo=!1}getEditableAnnotation(t){return this.#Do?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#_.getActive()!==t&&this.#_.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#Uo?.div&&!this.#Ho){this.#Ho=new AbortController;const t=this.#_.combinedSignal(this.#Ho);this.#Uo.div.addEventListener("pointerdown",this.#Wo.bind(this),{signal:t}),this.#Uo.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#Uo?.div&&this.#Ho&&(this.#Ho.abort(),this.#Ho=null,this.#Uo.div.classList.remove("highlighting"))}#Wo(t){this.#_.unselectAll();const{target:e}=t;if(e===this.#Uo.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#Uo.div.contains(e)){const{isMac:e}=ko.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#_.showAllEditors("highlight",!0,!0),this.#Uo.div.classList.add("free"),this.toggleDrawing(),od.startHighlighting(this,"ltr"===this.#_.direction,{target:this.#Uo.div,x:t.x,y:t.y}),this.#Uo.div.addEventListener("pointerup",(()=>{this.#Uo.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#_._signal}),t.preventDefault()}}enableClick(){if(this.#Io)return;this.#Io=new AbortController;const t=this.#_.combinedSignal(this.#Io);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#Io?.abort(),this.#Io=null}attach(t){this.#No.set(t.id,t);const{annotationElementId:e}=t;e&&this.#_.isDeletedAnnotationElement(e)&&this.#_.removeDeletedAnnotationElement(t)}detach(t){this.#No.delete(t.id),this.#Fn?.removePointerInTextLayer(t.contentDiv),!this.#Bo&&t.annotationElementId&&this.#_.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#_.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#_.addDeletedAnnotationElement(t.annotationElementId),ll.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#_.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#jo),this.#_.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Oo&&(t._focusEventsAllowed=!1,this.#Oo=setTimeout((()=>{this.#Oo=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#_._signal}),e.focus())}),0)),t._structTreeParentId=this.#Fn?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#_.getId()}get#Go(){return yd.#U.get(this.#_.getMode())}combinedSignal(t){return this.#_.combinedSignal(t)}#qo(t){const e=this.#Go;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Go?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#_.updateMode(t.mode);const{offsetX:i,offsetY:s}=this.#Ko(),n=this.getNextId(),a=this.#qo({parent:this,id:n,x:i,y:s,uiManager:this.#_,isCentered:!0,...e});a&&this.add(a)}async deserialize(t){return await(yd.#U.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#_))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#qo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#_,isCentered:e,...i});return n&&this.add(n),n}#Ko(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+i))/2-t,o=(a+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:l,offsetY:h}}addNewEditor(t={}){this.createAndAddNewEditor(this.#Ko(),!0,t)}setSelected(t){this.#_.setSelected(t)}toggleSelected(t){this.#_.toggleSelected(t)}unselect(t){this.#_.unselect(t)}pointerup(t){const{isMac:e}=ko.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#Fo)return;if(this.#Fo=!1,this.#Go?.isDrawer&&this.#Go.supportMultipleDrawings)return;if(!this.#Lo)return void(this.#Lo=!0);const i=this.#_.getMode();i!==Fr.STAMP&&i!==Fr.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#_.unselectAll()}pointerdown(t){if(this.#_.getMode()===Fr.HIGHLIGHT&&this.enableTextSelection(),this.#Fo)return void(this.#Fo=!1);const{isMac:e}=ko.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#Fo=!0,this.#Go?.isDrawer)return void this.startDrawingSession(t);const i=this.#_.getActive();this.#Lo=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#zo)return void this.#Go.startDrawing(this,this.#_,!1,t);this.#_.setCurrentDrawingSession(this),this.#zo=new AbortController;const e=this.#_.combinedSignal(this.#zo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#Vo=null,this.commitOrRemove())}),{signal:e}),this.#Go.startDrawing(this,this.#_,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#Vo=t)}else this.#Vo&&setTimeout((()=>{this.#Vo?.focus(),this.#Vo=null}),0)}endDrawingSession(t=!1){return this.#zo?(this.#_.setCurrentDrawingSession(null),this.#zo.abort(),this.#zo=null,this.#Vo=null,this.#Go.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#_.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#zo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#zo&&this.#Go.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#_.getActive()?.parent===this&&(this.#_.commitOrRemove(),this.#_.setActiveEditor(null)),this.#Oo&&(clearTimeout(this.#Oo),this.#Oo=null);for(const t of this.#No.values())this.#Fn?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#No.clear(),this.#_.removeLayer(this)}#$o(){for(const t of this.#No.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Ko(this.div,t);for(const t of this.#_.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#_.commitOrRemove(),this.#$o();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Ko(this.div,{rotation:i}),e!==i)for(const t of this.#No.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#_.viewParameters.realScale}}class wd{#fn=null;#Xo=new Map;#Yo=new Map;static#y=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#fn){if(this.#fn!==t){if(this.#Xo.size>0)for(const e of this.#Xo.values())e.remove(),t.append(e);this.#fn=t}}else this.#fn=t}static get _svgFactory(){return go(this,"_svgFactory",new bc)}static#Qo(t,[e,i,s,n]){const{style:a}=t;a.top=100*i+"%",a.left=100*e+"%",a.width=100*s+"%",a.height=100*n+"%"}#Jo(){const t=wd._svgFactory.create(1,1,!0);return this.#fn.append(t),t.setAttribute("aria-hidden",!0),t}#Zo(t,e){const i=wd._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=wd._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#tl(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){const s=wd.#y++,n=this.#Jo(),a=wd._svgFactory.createElement("defs");n.append(a);const r=wd._svgFactory.createElement("path");a.append(r);const o=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#Yo.set(s,r);const l=i?this.#Zo(a,o):null,h=wd._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#Xo.set(s,n),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){const i=wd.#y++,s=this.#Jo(),n=wd._svgFactory.createElement("defs");s.append(n);const a=wd._svgFactory.createElement("path");n.append(a);const r=`path_p${this.pageIndex}_${i}`;let o;if(a.setAttribute("id",r),a.setAttribute("vector-effect","non-scaling-stroke"),e){const t=wd._svgFactory.createElement("mask");n.append(t),o=`mask_p${this.pageIndex}_${i}`,t.setAttribute("id",o),t.setAttribute("maskUnits","objectBoundingBox");const e=wd._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=wd._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${r}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const l=wd._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${r}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return s.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#Xo.set(i,s),i}finalizeDraw(t,e){this.#Yo.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:s,rootClass:n,path:a}=e,r="number"==typeof t?this.#Xo.get(t):t;if(r){if(i&&this.#tl(r,i),s&&wd.#Qo(r,s),n){const{classList:t}=r;for(const[e,i]of Object.entries(n))t.toggle(e,i)}if(a){const t=r.firstChild.firstChild;this.#tl(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#Xo.get(t);i&&(e.#fn.append(i),this.#Xo.delete(t),e.#Xo.set(t,i))}remove(t){this.#Yo.delete(t),null!==this.#fn&&(this.#Xo.get(t).remove(),this.#Xo.delete(t))}destroy(){this.#fn=null;for(const t of this.#Xo.values())t.remove();this.#Xo.clear(),this.#Yo.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:id},globalThis.pdfjsLib={AbortException:wo,AnnotationEditorLayer:yd,AnnotationEditorParamsType:Br,AnnotationEditorType:Fr,AnnotationEditorUIManager:al,AnnotationLayer:Yc,AnnotationMode:Nr,AnnotationType:Gr,build:"47ad820d9",ColorPicker:rd,createValidAbsoluteUrl:uo,DOMSVGFactory:bc,DrawLayer:wd,FeatureTest:ko,fetchData:Oo,getDocument:rc,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)},getPdfFilenameFromUrl:function(t,e="document.pdf"){if("string"!=typeof t)return e;if(Bo(t))return lo('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e},getUuid:Ro,getXfaPageViewport:function(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,a=[0,0,parseInt(s),parseInt(n)];return new No({viewBox:a,userUnit:1,scale:e,rotation:i})},GlobalWorkerOptions:Rh,ImageKind:Wr,InvalidPDFException:vo,isDataScheme:Bo,isPdfFile:jo,isValidExplicitDest:wl,MathClamp:Po,noContextMenu:Uo,normalizeUnicode:function(t){return Eo||(Eo=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Co=new Map([["ſt","ſt"]])),t.replaceAll(Eo,((t,e,i)=>e?e.normalize("NFKC"):Co.get(i)))},OPS:Zr,OutputScale:Xo,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:lc,PDFDateString:$o,PDFWorker:dc,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},PixelsPerInch:Io,RenderingCancelledException:Fo,ResponseException:bo,setLayerDimensions:Ko,shadow:go,SignatureExtractor:fd,stopEvent:Ho,SupportedImageMimeTypes:Yo,TextLayer:nc,TouchManager:ol,updateUrlHash:po,Util:So,VerbosityLevel:Jr,version:"5.3.31",XfaLayer:yc};const xd={key:0,class:"loading-screen"},Ad={key:1,class:"image-display-area"},kd={class:"ocr-container",ref:"containerRef"},Td=["src"],Sd=["onClick","onMouseover"];var Ed=v({__name:"renderOCRResponse",props:{image:{type:null,required:!0},language:{type:String,required:!0}},emits:["close","loadingUpdate"],setup(t,{emit:i}){const s=t;Rh.workerSrc="/tta/pdf.worker.mjs";const{useNotificationsStore:n}=e(),a=n(),h=u(null),g=u([]),f=u(),_=u(),v=u([]),w=u(""),A=u(!1),E=u([]),R=u(1),M=b((()=>v.value.sort().map((t=>{var e;return null==(e=g.value[t])?void 0:e.text})).join(" ")));async function L(t,e,n){if(_.value=t,n)return w.value=n,D(),n;console.log(e),document.addEventListener("click",I),A.value=!0,i("loadingUpdate",!0);const r=new FormData;let o;r.append("image",e);try{const t=await fetch("/tta/ocr?language="+s.language,{method:"POST",body:r});if(!t.ok)throw new Error(`Server error: ${t.status}`);o=await t.text(),w.value=o,D()}catch(t){a.add({title:"Error while using OCR",text:"Please check your console/terminal for the error.",type:"error",dialog:!0}),console.error(t)}return A.value=!1,i("loadingUpdate",!1),o}function D(){const t=f.value,e=t.naturalWidth,i=t.naturalHeight,s=t.clientWidth,n=t.clientHeight,a=[];(new DOMParser).parseFromString(w.value,"text/html").querySelectorAll(".ocrx_word").forEach((t=>{const r=t.getAttribute("title");if(r){const o=r.match(/bbox (\d+) (\d+) (\d+) (\d+)/);if(o){const[r,l,h,c,d]=o.map(Number),u=l/e*s,p=h/i*n,g={x0:u,y0:p,x1:u+(c-l)/e*s,y1:p+(d-h)/i*n};a.push({text:t.textContent.trim(),bbox:g})}else console.warn("Malformed bbox data for span:",t)}else console.warn("Missing title attribute for span:",t)})),g.value=a}function I(){const t=document.activeElement;if(("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&!t.readOnly&&!t.disabled&&M.value){const e=t.selectionStart,i=t.selectionEnd,s=t.value;t.value=s.slice(0,e)+M.value+s.slice(i),t.selectionStart=t.selectionEnd=e+M.length,v.value=[],t.dispatchEvent(new Event("input",{bubbles:!0}))}}return x((async()=>{const t=await new Promise((t=>{const e=new FileReader;e.onload=e=>{t(e.target.result)},"application/pdf"==s.image.type?e.readAsArrayBuffer(s.image):e.readAsDataURL(s.image)}));if(s.image.type.startsWith("image/"))L(t,s.image);else if("application/pdf"==s.image.type){const e=new Uint8Array(t),i=await rc(e).promise;console.log(i.numPages);for(let t=1;t<=i.numPages;t++){const e=await i.getPage(t),s=e.getViewport({scale:1}),n=document.createElement("canvas"),a=n.getContext("2d");n.width=s.width,n.height=s.height,await e.render({canvasContext:a,viewport:s}).promise;const r=await new Promise((t=>n.toBlob((e=>t(e)),"image/png")));E.value.push({string:n.toDataURL("image/png"),file:new File([r],"page"+t+".png",{type:"image/png"})}),n.remove(),console.log({i:t})}const[s]=E.value;s&&L(s.string,s.file).then((t=>s.response=t))}else i("close"),a.add({title:"Error while using OCR",text:`File type '${s.image.type}' not supported.`,type:"error",dialog:!0})})),y((()=>R.value),(t=>{const e=E.value[t-1];e&&L(e.string,e.file,e.response).then((t=>e.response=t))})),O((()=>{document.removeEventListener("click",I)})),(t,e)=>{const i=r("v-progress-circular"),s=r("VPagination"),n=r("v-input");return o(),p(S,null,[A.value?(o(),p("div",xd,[c(i,{indeterminate:"",class:"c"})])):d("v-if",!0),_.value?(o(),p("div",Ad,[m("div",kd,[m("img",{src:_.value,onLoad:D,style:{width:"100%","object-fit":"contain"},ref_key:"imageRef",ref:f,onMousedown:e[0]||(e[0]=C((()=>{}),["stop"]))},null,40,Td),(o(!0),p(S,null,P(g.value,((t,i)=>(o(),p("div",{key:i,class:"text-overlay",style:k({padding:"2px",position:"absolute",left:`${t.bbox.x0}px`,top:`${t.bbox.y0}px`,width:t.bbox.x1-t.bbox.x0+"px",height:t.bbox.y1-t.bbox.y0+"px",border:v.value.includes(i)?"2px solid green":h.value===i?"2px solid blue":"1px solid transparent",cursor:"pointer",backgroundColor:"rgba(255, 255, 0, 0.3)"}),onClick:t=>function(t){const e=v.value.indexOf(t);-1==e?v.value.push(t):v.value.splice(e,1)}(i),onMouseover:t=>h.value=i,onMouseleave:e[1]||(e[1]=t=>h.value=null)},null,44,Sd)))),128))],512),E.value.length>1?(o(),l(s,{key:0,modelValue:R.value,"onUpdate:modelValue":e[2]||(e[2]=t=>R.value=t),length:E.value.length,totalVisible:4,class:"pagination-center"},null,8,["modelValue","length"])):d("v-if",!0),c(n,{modelValue:T(M)},null,8,["modelValue"])])):d("v-if",!0)],64)}}});Qn("\n.image-display-area[data-v-0d65f7ea] {\n position: relative;\n background: white;\n border: 1px solid white;\n color: black;\n border-radius: 8px;\n overflow: hidden;\n margin: auto;\n width: 100%;\n display: flex;\n flex-direction: column;\n}\n.pagination-center[data-v-0d65f7ea] {\n margin: 5px auto;\n}\n.ocr-container[data-v-0d65f7ea] {\n position: relative;\n height: 100%;\n}\n.text-overlay[data-v-0d65f7ea] {\n position: absolute;\n}\n.loading-screen[data-v-0d65f7ea] {\n position: absolute;\n width: 100%;\n height: 100%;\n background-color: rgba(255, 255, 255, 0.4);\n display: flex;\n left: 0;\n top: 0;\n z-index: 1000;\n}\n.loading-screen .c[data-v-0d65f7ea] {\n margin: auto;\n}\n",{}),Ed.__scopeId="data-v-0d65f7ea",Ed.__file="ocr/OCR-interface/src/renderOCRResponse.vue";var Cd=v({__name:"ocredrag",props:{initialX:{type:Number,required:!0},initialY:{type:Number,required:!0}},emits:["close"],setup(t,{emit:e}){const i=t,s=u(null),n=u(!1),a=N({x:i.initialX||50,y:i.initialY||50}),d=N({x:0,y:0}),p=t=>{n.value=!0,d.x=t.clientX-a.x,d.y=t.clientY-a.y,document.addEventListener("mousemove",g),document.addEventListener("mouseup",f)},g=t=>{n.value&&(a.x=t.clientX-d.x,a.y=t.clientY-d.y)},f=()=>{n.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)};return F((()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f)})),(t,i)=>{const d=r("v-icon"),u=r("VButton");return o(),l(B,{to:"body"},[m("div",{ref_key:"draggableElement",ref:s,style:k({position:"absolute",left:a.x+"px",top:a.y+"px",cursor:n.value?"grabbing":"grab",width:"500px","max-width":"80vw",height:"auto",padding:"20px",backgroundColor:"var(--theme--background)",color:"var(--theme--form--field--label--foreground)",border:"var(--theme--border-color) 2px solid",borderRadius:"4px",userSelect:"none","z-index":100}),onMousedown:p},[j(t.$slots,"default"),c(u,{onClick:i[0]||(i[0]=t=>e("close")),outlined:!1,icon:!0,rounded:!0,class:"close-btn"},{default:h((()=>[c(d,{name:"close"})])),_:1})],36)])}}});Qn("\n.close-btn[data-v-6008a42c] {\n position: absolute;\n right: -10px;\n top: -10px;\n z-index: 1001;\n}\n",{}),Cd.__scopeId="data-v-6008a42c",Cd.__file="ocr/OCR-interface/src/ocredrag.vue";const Rd={class:"ocr-container"};var Md=v({__name:"interface",props:{language:{type:String,required:!0},collection:{type:String,required:!0}},setup(t){const i=t,{useFieldsStore:s}=e(),n=s(),a=u(!1),f=u(),_=u(!1),v=u(),b=u([]);function y(){f.value.click()}async function A(t){const e=t.target.files[0];e&&(v.value=e)}async function k(t,e){const i=e||T(t.target.parentElement);if(i){const t=await fetch(i).then((t=>t.blob())),e=new File([t],"image.png",{type:t.type}),s=f.value,n=new DataTransfer;n.items.add(e),s.files=n.files,s.dispatchEvent(new Event("change",{bubbles:!0}))}}function T(t){let e=0,i="";for(;e<10;){const s=(t=t.parentElement).querySelector("img");if(s){i=s.src;break}e++}return i.split("?")[0]}function E(){v.value=null,f.value.value=""}return x((()=>{const t=n.getFieldsForCollection(i.collection).filter((t=>{var e;return"file-image"==(null==(e=t.meta)?void 0:e.interface)}));w((()=>{setTimeout((()=>{for(const e of t){const t="[data-collection="+i.collection+"][data-field="+e.field+"]",s=document.querySelector(t);s&&s.addEventListener("mouseover",(e=>{const i=s.querySelector(".image-preview img");if(i){!s.querySelector(".ocr_button")&&T(i)&&b.value.push(t+" .actions")}}))}}),500);const e=n.getFieldsForCollection(i.collection).filter((t=>{var e;return"file"==(null==(e=t.meta)?void 0:e.interface)}));w((()=>{setTimeout((()=>{for(const t of e){const e="[data-collection="+i.collection+"][data-field="+t.field+"]",s=document.querySelector(e);if(s){const t=s.querySelector("input");null==t||t.addEventListener("change",(()=>{var t;null==(t=document.getElementById("_SCAN_OCR"))||t.remove()})),s.addEventListener("click",(()=>{setTimeout((()=>{var t;const e=document.querySelector("a[download]");if(e){const i=e.cloneNode(!0);i.href="#",i.querySelector("i").setAttribute("data-icon","camera_video"),i.id="_SCAN_OCR",i.classList.add("hide-by-default"),i.children[1].innerText="Scan with OCR",i.addEventListener("click",(t=>{t.preventDefault(),k(void 0,e.getAttribute("href"))})),null==(t=e.parentNode)||t.insertBefore(i,e)}}),100)}))}}}))})),a.value=!0}))})),(e,i)=>{const s=r("v-icon"),n=r("VButton"),u=r("v-button");return o(),p(S,null,[(o(!0),p(S,null,P(b.value,(t=>(o(),l(B,{to:t},[c(n,{onClick:k,outlined:!1,icon:!0,rounded:!0,class:"ocr_button"},{default:h((()=>[c(s,{name:"camera_video"})])),_:1})],8,["to"])))),256)),a.value?(o(),l(B,{key:0,to:"#sidebar .v-item-group"},[m("div",Rd,[c(u,{class:"ocr-btn",onClick:y,loading:_.value},{default:h((()=>[g(" Import data with OCR ")])),_:1},8,["loading"]),m("input",{type:"file",onChange:A,class:"ocr-input",ref_key:"inputRef",ref:f,accept:"image/*,application/pdf"},null,544),null!=v.value?(o(),l(Cd,{key:0,onClose:E},{default:h((()=>[c(Ed,{image:v.value,onClose:i[0]||(i[0]=()=>E()),language:t.language,onLoadingUpdate:i[1]||(i[1]=t=>_.value=t)},null,8,["image","language"])])),_:1})):d("v-if",!0)])])):d("v-if",!0)],64)}}});Qn("\n.ocr-container {\n display: flex;\n}\n.ocr-container .ocr-btn {\n margin: 10px auto;\n}\n.ocr-container .ocr-input {\n display: none;\n}\n.hide-by-default {\n display: none;\n}\na ~ #_SCAN_OCR {\n display: block;\n}\n",{}),Md.__file="ocr/OCR-interface/src/interface.vue";const Pd=[br,wr,kr,n({id:"tta-ocr-interface",name:"OCR interface",icon:"camera_video",description:"Use OCR to fill fields. (Text to anything)",hideLabel:!0,hideLoader:!0,component:Md,types:["alias"],localTypes:["presentation"],options:[{field:"language",name:"Language",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:[{value:"eng",text:"English"},{value:"por",text:"Portuguese"},{value:"fra",text:"French"},{value:"osd",text:"Orientation and Script Detection"},{value:"chi_sim",text:"Chinese (Simplified)"},{value:"spa",text:"Spanish"},{value:"deu",text:"German"},{value:"chi_tra",text:"Chinese (Traditional)"},{value:"heb",text:"Hebrew"},{value:"kor",text:"Korean"},{value:"jpn",text:"Japanese"},{value:"rus",text:"Russian"},{value:"nld",text:"Dutch"},{value:"hin",text:"Hindi"},{value:"ita",text:"Italian"},{value:"jpn_vert",text:"Japanese (Vertical)"},{value:"pol",text:"Polish"},{value:"ron",text:"Romanian"},{value:"mar",text:"Marathi"},{value:"ukr",text:"Ukrainian"},{value:"mal",text:"Malayalam"},{value:"tam",text:"Tamil"},{value:"guj",text:"Gujarati"},{value:"tha",text:"Thai"},{value:"kan",text:"Kannada"},{value:"vie",text:"Vietnamese"},{value:"tel",text:"Telugu"},{value:"swe",text:"Swedish"},{value:"tur",text:"Turkish"},{value:"nor",text:"Norwegian"},{value:"ces",text:"Czech"},{value:"ben",text:"Bengali"},{value:"pan",text:"Punjabi"},{value:"equ",text:"Math / Equation Detection"},{value:"ell",text:"Greek"},{value:"bul",text:"Bulgarian"},{value:"lat",text:"Latin"},{value:"kur",text:"Kurdish"},{value:"ori",text:"Odia"},{value:"kat",text:"Georgian"},{value:"amh",text:"Amharic"},{value:"kaz",text:"Kazakh"},{value:"cat",text:"Catalan"},{value:"nep",text:"Nepali"},{value:"urd",text:"Urdu"},{value:"khm",text:"Khmer"},{value:"dan",text:"Danish"},{value:"chi_sim_vert",text:"Chinese (Simplified, Vertical)"},{value:"uzb",text:"Uzbek (Latin)"},{value:"slv",text:"Slovenian"},{value:"mkd",text:"Macedonian"},{value:"tgl",text:"Tagalog"},{value:"srp",text:"Serbian (Cyrillic)"},{value:"hrv",text:"Croatian"},{value:"tir",text:"Tigrinya"},{value:"syr",text:"Syriac"},{value:"lao",text:"Lao"},{value:"fin",text:"Finnish"},{value:"est",text:"Estonian"},{value:"bos",text:"Bosnian"},{value:"uig",text:"Uyghur"},{value:"sin",text:"Sinhala"},{value:"hye",text:"Armenian"},{value:"eus",text:"Basque"},{value:"sqi",text:"Albanian"},{value:"isl",text:"Icelandic"},{value:"bel",text:"Belarusian"},{value:"aze",text:"Azerbaijani (Latin)"},{value:"pus",text:"Pashto"},{value:"oci",text:"Occitan"},{value:"lit",text:"Lithuanian"},{value:"jav",text:"Javanese"},{value:"hun",text:"Hungarian"},{value:"grc",text:"Ancient Greek"},{value:"gle",text:"Irish"},{value:"frm",text:"Middle French"},{value:"afr",text:"Afrikaans"},{value:"uzb_cyrl",text:"Uzbek (Cyrillic)"},{value:"spa_old",text:"Old Spanish"},{value:"snd",text:"Sindhi"},{value:"mya",text:"Burmese"},{value:"iku",text:"Inuktitut"},{value:"fil",text:"Filipino"},{value:"fas",text:"Persian"},{value:"fao",text:"Faroese"},{value:"dzo",text:"Dzongkha"},{value:"cym",text:"Welsh"},{value:"aze_cyrl",text:"Azerbaijani (Cyrillic)"},{value:"ind",text:"Indonesian"},{value:"ara",text:"Arabic"},{value:"yid",text:"Yiddish"},{value:"ton",text:"Tongan"},{value:"tgk",text:"Tajik"},{value:"srp_latn",text:"Serbian (Latin)"},{value:"slk_frak",text:"Slovak (Fraktur)"},{value:"slk",text:"Slovak"},{value:"san",text:"Sanskrit"},{value:"msa",text:"Malay"},{value:"mri",text:"Maori"},{value:"mlt",text:"Maltese"},{value:"lav",text:"Latvian"},{value:"kur_ara",text:"Kurdish (Arabic)"},{value:"kor_vert",text:"Korean (Vertical)"},{value:"kmr",text:"Kurmanji"},{value:"kir",text:"Kyrgyz"},{value:"hat",text:"Haitian Creole"},{value:"glg",text:"Galician"},{value:"fry",text:"Frisian"},{value:"epo",text:"Esperanto"},{value:"div",text:"Divehi"},{value:"chr",text:"Cherokee"},{value:"bod",text:"Tibetan"},{value:"asm",text:"Assamese"},{value:"yor",text:"Yoruba"},{value:"tat",text:"Tatar"},{value:"sun",text:"Sundanese"},{value:"occ",text:"Occitan (alternative)"},{value:"mon",text:"Mongolian"},{value:"ita_old",text:"Old Italian"},{value:"gla",text:"Scottish Gaelic"},{value:"frk",text:"Frankish"},{value:"enm",text:"Middle English"},{value:"deu_frak",text:"German (Fraktur)"},{value:"dan_frak",text:"Danish (Fraktur)"},{value:"chi_tra_vert",text:"Chinese (Traditional, Vertical)"},{value:"ceb",text:"Cebuano"},{value:"bre",text:"Breton"},{value:"swa",text:"Swahili"},{value:"que",text:"Quechua"},{value:"ltz",text:"Luxembourgish"},{value:"kat_old",text:"Old Georgian"},{value:"cos",text:"Corsican"}]}}}]})],Ld=[],Dd=[],Id=[mr],Od=[],Nd=[V,U,H,$,t({id:"ttaocr",name:"TTA OCR",icon:"camera_video",description:"TTA scan image with OCR",overview:({fileID:t,mode:e,language:i})=>[{label:"Mode",text:e},{label:"Language",text:i},{label:"File ID",text:t}],options:[{field:"fileID",name:"File ID",type:"string",meta:{width:"full",interface:"input"}},{field:"mode",name:"Mode",type:"string",meta:{interface:"select-dropdown",options:{choices:[{text:"Text",value:"text"},{text:"Horc",value:"horc"}]}}},{field:"language",name:"Language",type:"dropdown",meta:{interface:"select-dropdown",options:{choices:[{value:"eng",text:"English"},{value:"por",text:"Portuguese"},{value:"fra",text:"French"},{value:"osd",text:"Orientation and Script Detection"},{value:"chi_sim",text:"Chinese (Simplified)"},{value:"spa",text:"Spanish"},{value:"deu",text:"German"},{value:"chi_tra",text:"Chinese (Traditional)"},{value:"heb",text:"Hebrew"},{value:"kor",text:"Korean"},{value:"jpn",text:"Japanese"},{value:"rus",text:"Russian"},{value:"nld",text:"Dutch"},{value:"hin",text:"Hindi"},{value:"ita",text:"Italian"},{value:"jpn_vert",text:"Japanese (Vertical)"},{value:"pol",text:"Polish"},{value:"ron",text:"Romanian"},{value:"mar",text:"Marathi"},{value:"ukr",text:"Ukrainian"},{value:"mal",text:"Malayalam"},{value:"tam",text:"Tamil"},{value:"guj",text:"Gujarati"},{value:"tha",text:"Thai"},{value:"kan",text:"Kannada"},{value:"vie",text:"Vietnamese"},{value:"tel",text:"Telugu"},{value:"swe",text:"Swedish"},{value:"tur",text:"Turkish"},{value:"nor",text:"Norwegian"},{value:"ces",text:"Czech"},{value:"ben",text:"Bengali"},{value:"pan",text:"Punjabi"},{value:"equ",text:"Math / Equation Detection"},{value:"ell",text:"Greek"},{value:"bul",text:"Bulgarian"},{value:"lat",text:"Latin"},{value:"kur",text:"Kurdish"},{value:"ori",text:"Odia"},{value:"kat",text:"Georgian"},{value:"amh",text:"Amharic"},{value:"kaz",text:"Kazakh"},{value:"cat",text:"Catalan"},{value:"nep",text:"Nepali"},{value:"urd",text:"Urdu"},{value:"khm",text:"Khmer"},{value:"dan",text:"Danish"},{value:"chi_sim_vert",text:"Chinese (Simplified, Vertical)"},{value:"uzb",text:"Uzbek (Latin)"},{value:"slv",text:"Slovenian"},{value:"mkd",text:"Macedonian"},{value:"tgl",text:"Tagalog"},{value:"srp",text:"Serbian (Cyrillic)"},{value:"hrv",text:"Croatian"},{value:"tir",text:"Tigrinya"},{value:"syr",text:"Syriac"},{value:"lao",text:"Lao"},{value:"fin",text:"Finnish"},{value:"est",text:"Estonian"},{value:"bos",text:"Bosnian"},{value:"uig",text:"Uyghur"},{value:"sin",text:"Sinhala"},{value:"hye",text:"Armenian"},{value:"eus",text:"Basque"},{value:"sqi",text:"Albanian"},{value:"isl",text:"Icelandic"},{value:"bel",text:"Belarusian"},{value:"aze",text:"Azerbaijani (Latin)"},{value:"pus",text:"Pashto"},{value:"oci",text:"Occitan"},{value:"lit",text:"Lithuanian"},{value:"jav",text:"Javanese"},{value:"hun",text:"Hungarian"},{value:"grc",text:"Ancient Greek"},{value:"gle",text:"Irish"},{value:"frm",text:"Middle French"},{value:"afr",text:"Afrikaans"},{value:"uzb_cyrl",text:"Uzbek (Cyrillic)"},{value:"spa_old",text:"Old Spanish"},{value:"snd",text:"Sindhi"},{value:"mya",text:"Burmese"},{value:"iku",text:"Inuktitut"},{value:"fil",text:"Filipino"},{value:"fas",text:"Persian"},{value:"fao",text:"Faroese"},{value:"dzo",text:"Dzongkha"},{value:"cym",text:"Welsh"},{value:"aze_cyrl",text:"Azerbaijani (Cyrillic)"},{value:"ind",text:"Indonesian"},{value:"ara",text:"Arabic"},{value:"yid",text:"Yiddish"},{value:"ton",text:"Tongan"},{value:"tgk",text:"Tajik"},{value:"srp_latn",text:"Serbian (Latin)"},{value:"slk_frak",text:"Slovak (Fraktur)"},{value:"slk",text:"Slovak"},{value:"san",text:"Sanskrit"},{value:"msa",text:"Malay"},{value:"mri",text:"Maori"},{value:"mlt",text:"Maltese"},{value:"lav",text:"Latvian"},{value:"kur_ara",text:"Kurdish (Arabic)"},{value:"kor_vert",text:"Korean (Vertical)"},{value:"kmr",text:"Kurmanji"},{value:"kir",text:"Kyrgyz"},{value:"hat",text:"Haitian Creole"},{value:"glg",text:"Galician"},{value:"fry",text:"Frisian"},{value:"epo",text:"Esperanto"},{value:"div",text:"Divehi"},{value:"chr",text:"Cherokee"},{value:"bod",text:"Tibetan"},{value:"asm",text:"Assamese"},{value:"yor",text:"Yoruba"},{value:"tat",text:"Tatar"},{value:"sun",text:"Sundanese"},{value:"occ",text:"Occitan (alternative)"},{value:"mon",text:"Mongolian"},{value:"ita_old",text:"Old Italian"},{value:"gla",text:"Scottish Gaelic"},{value:"frk",text:"Frankish"},{value:"enm",text:"Middle English"},{value:"deu_frak",text:"German (Fraktur)"},{value:"dan_frak",text:"Danish (Fraktur)"},{value:"chi_tra_vert",text:"Chinese (Traditional, Vertical)"},{value:"ceb",text:"Cebuano"},{value:"bre",text:"Breton"},{value:"swa",text:"Swahili"},{value:"que",text:"Quechua"},{value:"ltz",text:"Luxembourgish"},{value:"kat_old",text:"Old Georgian"},{value:"cos",text:"Corsican"}]}}}]})];export{Ld as displays,Pd as interfaces,Dd as layouts,Id as modules,Nd as operations,Od as panels};
|