Files
YG_FT/frontend/dist/assets/DataProcessCreateView-fflU6m3U.js

105 lines
588 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var Y0=Object.defineProperty;var Uv=u=>{throw TypeError(u)};var K0=(u,t,e)=>t in u?Y0(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var R=(u,t,e)=>K0(u,typeof t!="symbol"?t+"":t,e),hg=(u,t,e)=>t.has(u)||Uv("Cannot "+e);var n=(u,t,e)=>(hg(u,t,"read from private field"),e?e.call(u):t.get(u)),m=(u,t,e)=>t.has(u)?Uv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),p=(u,t,e,s)=>(hg(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),v=(u,t,e)=>(hg(u,t,"access private method"),e);var Jt=(u,t,e,s)=>({set _(i){p(u,t,i,e)},get _(){return n(u,t,s)}});import{E as Q0}from"./el-alert-B_M4eVTG.js";import{E as Ml}from"./index-9zpOHVFd.js";import{v as J0}from"./directive-CGqZKDhv.js";import{d as ni,o as O,c as $,q as x,s as V,n as re,aa as G,g as ct,j as st,G as Ey,H as Gp,x as at,w as tt,M as xt,ad as xe,y as it,e as Pt,f as Bt,A as lt,D as Is,aQ as Cy,al as ky,r as Z0,P as vh,t as Hv,aL as ug,z as ap,ac as tA,ag as eA,aR as sA,K as iA,aB as nA,v as rA}from"./index-Dd84m4NL.js";import{A as aA}from"./AppConfirmDialog-D8GYfvI4.js";import{E as Ty,a as Py}from"./el-form-item-BMccCMQS.js";import{E as jd}from"./index-CxrDRhwR.js";import{a as My,E as jp}from"./el-checkbox-DmCZOH3C.js";import{E as Wd}from"./el-input-number-CLGVcD2n.js";/* empty css */import{_ as ri}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{E as Xd,a as qd}from"./el-select-DinjeS4W.js";import{E as oA}from"./el-slider-zfFAQg0d.js";import{E as lA}from"./el-switch-DeGokrBx.js";import"./el-popper-CXiDZrHI.js";import"./el-tooltip-l0sNRNKZ.js";import"./el-scrollbar-CnqWU4CY.js";import{E as cA}from"./el-tag-DPsbND_Z.js";import{E as Iy}from"./el-pagination-CZfi7rql.js";import{E as rv}from"./el-progress-QxrdzpaU.js";import{E as hA}from"./el-upload-CT0Hhwbe.js";import{a as uA,b as Dy,c as dA,e as fA,f as zv,r as pA,h as gA,u as mA,i as Vv,j as Gv,s as vA,k as yA,l as av,m as dg,n as bA,o as op,p as wA,q as AA,t as SA,v as xA,w as _A,x as EA,y as CA,z as kA,A as TA,B as PA}from"./dataProcess-PWnIk5S8.js";import{u as MA}from"./models-DxMjE4y2.js";import"./vnode-CasYkit1.js";import"./castArray-Cc7cuNko.js";import"./_baseClone-C6YdWYHR.js";import"./raf-CGf5YZRu.js";import"./index-BkMrw1Qg.js";import"./index-DEuQ2B0Z.js";import"./omit-njl9pMBF.js";import"./index-CrQUvw33.js";import"./index-KnEmF0FL.js";import"./index-C5oiM9Uu.js";import"./scroll-CJw98M_S.js";import"./clamp-MxoDdpzk.js";import"./toNumber-Dzu6kJGs.js";import"./_baseIteratee-CfOSjoYo.js";import"./debounce-CqM0EiuE.js";import"./validator-BEv3fs9p.js";import"./model-SG-pVLXE.js";const _l={min:1,max:50};function ov(u,t=1){const e=Number(u),s=Number.isFinite(e)?Math.trunc(e):t;return Math.min(_l.max,Math.max(_l.min,s))}const IA={class:"generation-option-row dataset-split-row"},DA={class:"dataset-split-config"},LA={class:"dataset-split-grid"},RA={class:"dataset-split-field"},FA={class:"dataset-split-input"},OA={class:"dataset-split-field"},NA={class:"dataset-split-input"},BA={class:"dataset-split-field"},$A={class:"dataset-split-input"},UA={key:0,role:"alert"},HA=ni({__name:"DatasetSplitEditor",props:{modelValue:{},ariaLabelPrefix:{default:""}},emits:["update:modelValue"],setup(u,{emit:t}){const e=u,s=t,i=st(()=>{const{train:o,validation:l,test:c}=e.modelValue;return o+l+c});function r(o,l){s("update:modelValue",{...e.modelValue,[o]:Math.min(100,Math.max(0,Number(l)||0))})}function a(o){return`${e.ariaLabelPrefix}${o}比例`}return(o,l)=>{const c=Wd;return O(),$("div",IA,[l[9]||(l[9]=x("div",{class:"generation-option-copy"},[x("strong",null,"数据集划分"),x("small",null,"按比例将生成后的问答对随机划分为训练集、验证集和测试集")],-1)),x("div",DA,[x("div",LA,[x("label",RA,[l[4]||(l[4]=x("span",null,"训练集",-1)),x("span",FA,[V(c,{"model-value":u.modelValue.train,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("训练集"),"onUpdate:modelValue":l[0]||(l[0]=h=>r("train",h))},null,8,["model-value","aria-label"]),l[3]||(l[3]=x("span",null,"%",-1))])]),x("label",OA,[l[6]||(l[6]=x("span",null,"验证集",-1)),x("span",NA,[V(c,{"model-value":u.modelValue.validation,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("验证集"),"onUpdate:modelValue":l[1]||(l[1]=h=>r("validation",h))},null,8,["model-value","aria-label"]),l[5]||(l[5]=x("span",null,"%",-1))])]),x("label",BA,[l[8]||(l[8]=x("span",null,"测试集",-1)),x("span",$A,[V(c,{"model-value":u.modelValue.test,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("测试集"),"onUpdate:modelValue":l[2]||(l[2]=h=>r("test",h))},null,8,["model-value","aria-label"]),l[7]||(l[7]=x("span",null,"%",-1))])])]),x("div",{class:re(["dataset-split-summary",{"is-invalid":i.value!==100}])},[x("span",null,"总计 "+G(i.value)+"%",1),i.value!==100?(O(),$("span",UA," 训练集、验证集和测试集比例总和必须为 100% ")):ct("",!0)],2)])])}}}),Ly=ri(HA,[["__scopeId","data-v-f479d5fe"]]),zA="你是一名专业的数据生成助手。请根据输入内容生成准确、完整、可直接用于模型训练的问答数据。仅输出符合所选输出类型和目标格式的内容,答案应事实清晰、语言自然,不要添加无关说明。",VA="你是一名专业的数据生成助手。请严格依据输入内容生成准确、完整、可直接用于监督微调的问答数据。只生成问题和最终答案,不输出分析、推理过程或来源中不存在的信息;答案应事实清晰、语言自然。",GA="你是一名专业的推理数据生成助手。请严格依据输入内容生成问题、可核验的推理过程和最终答案。推理需要说明关键依据与必要步骤,不得引入来源中不存在的事实;最终答案应准确、完整且语言自然。",jA=`你是一名专业的数据生成助手。请根据下方来源内容生成可用于监督微调的问答数据。
来源内容:
{{ content }}
要求:严格依据来源生成问题和最终答案,不输出分析、中间思考过程或来源中不存在的信息;答案应准确、完整、语言自然。`,WA=`你是一名专业的推理数据生成助手。请根据下方来源内容生成可用于推理模型训练的问答数据。
来源内容:
{{ content }}
要求:每条数据必须包含问题、可核验的中间思考过程和最终答案。中间思考过程需说明关键依据、必要步骤和中间计算,不得跳过推理只给结论,也不得引入来源中不存在的事实。`,XA=`你是一名专业的数据生成专家。你的任务是根据下方的来源内容提取核心信息并生成高质量的问答数据用于大模型的监督微调SFT
来源内容:
{{ content }}
任务要求:
1. 问题构建:基于来源内容设计问题,问题应当具有实际意义,不仅限于表面的事实问答,可以包括对内容的主旨概括、具体细节的询问或应用场景的探讨。
2. 答案生成:严格依据来源内容生成最终答案,答案需准确无误、逻辑连贯、完整且表达自然流畅。
3. 忠于原文:不输出分析、中间思考过程或任何多余的解释,切勿引入来源内容中未提及的事实或主观臆造的信息。`,qA=`你是一名具有深厚专业知识的推理数据生成专家。你的任务是根据给定的来源内容,生成高质量、逻辑严密且可用于训练推理大语言模型(如 O1 或 DeepSeek-R1的问答数据。
来源内容:
{{ content }}
任务要求:
1. 多维度提问:从来源内容中提取核心概念或关键逻辑,构建具有挑战性的问题,避免简单的信息抽取,提问可以涉及因果分析、方案设计、逻辑推断或跨段落信息整合。
2. 深度思维链CoT
- 必须提供详尽的中间思考过程。
- 在思考过程中,需首先分析问题的核心需求,然后逐步拆解来源内容中的相关事实或数据。
- 对于涉及计算或多步推导的问题,必须一步步展示计算或推导过程,并说明每一步的理论依据或事实来源。
- 如果遇到矛盾或缺失的信息,需在思考过程中指出,并合理假设或推理,但最终答案不得编造来源中完全不相关的事实。
3. 最终答案:在充分推理后给出明确的最终结论。结论应当是对问题的直接回应,语言自然、结构清晰,并且结论必须能从前面的思考过程中自然得出。
数据格式要求:
请确保每条生成的数据清晰包含“问题”、“中间思考过程”和“最终答案”三个部分,且内容充实、专业。`,Wp=`你是一名专业的数据生成专家。请基于下方来源内容生成高质量、可直接用于大模型监督微调SFT的问答数据。
来源内容:
{{ content }}
任务要求:
1. 提问有价值:问题应聚焦来源内容的核心信息点,避免无意义的字面抄录或过于宽泛的提问;优先设计需要理解、归纳或推理才能回答的问题,例如主旨概括、细节追问、因果解释或场景应用。
2. 答案忠于来源:严格依据来源内容作答,不得引入来源中不存在的事实、观点或数据;若来源信息不足以完整回答该问题,请如实说明不足,不要编造或臆测。
3. 答案完整且自然:回答应直接回应问题,要点完整、逻辑清晰、语言流畅;涉及多项内容时建议分点陈述,但不必照搬原文措辞。`,Ry=`你是一名具有深厚专业知识的推理数据生成专家。请基于下方来源内容,生成包含完整思维链、可用于训练推理大语言模型(如 O1、DeepSeek-R1的问答数据。
来源内容:
{{ content }}
任务要求:
1. 提问有挑战性:从来源内容中提炼需要多步思考才能回答的问题,避免可直接定位答案的简单事实抽取;可涉及因果分析、逻辑推断或跨信息整合。
2. 推理可核验:逐步展开思考过程,每个关键结论都应标注其在来源中的依据或必要的中间推导;不得跳过关键步骤只给结论,也不得引入来源中完全不存在的事实。
3. 信息不足时如实处理:遇到来源信息缺失或相互矛盾时,需在推理中明确指出,并基于来源做出合理假设,但不得编造与来源无关的内容。
4. 最终答案须能从前面的推理过程中自然得出,语言简洁、结构清晰。`;function Sg(u){return u==="reasoning"?Ry:Wp}function Fy(u){const t=s=>s.replace(/\r\n/g,`
`).trim(),e=t(u);return[zA,VA,jA,XA,GA,WA,qA,Wp,Ry].map(t).includes(e)}function Oy(){return{preprocessOptions:["clean_invalid","detect_structure","deduplicate","normalize_format"],semanticEnrichment:!1,qaPairsPerRow:1,datasetSplit:{train:80,validation:10,test:10},generationModelId:"",generationPrompt:Wp,outputType:"standard",reasoningDetail:"normal",temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}function Ny(){return{preprocessOptions:["clean_invalid_content","detect_document_structure","merge_short_content","filter_low_quality","deduplicate_content","preserve_context"],chunkMethod:"layout_hybrid",chunkSize:800,chunkOverlap:100,minChunkSize:100,semanticBreakpointPercentile:95,preserveTables:!0,preserveCodeBlocks:!0,preserveLists:!0,semanticEnrichment:!1,qaPairsPerChunk:1,datasetSplit:{train:80,validation:10,test:10},generationModelId:"",generationPrompt:Wp,outputType:"standard",reasoningDetail:"normal",temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}function Xe(u,t,e){return Object.prototype.hasOwnProperty.call(u,t)?u[t]:e}function vr(u,t,e){const s=Number(Xe(u,t,e));return Number.isFinite(s)?s:e}function By(u,t){const e=u.dataset_split;if(!e||typeof e!="object")return{...t};const s=e,i=r=>{const a=Number(s[r]);return Number.isFinite(a)?a:t[r]};return{train:i("train"),validation:i("validation"),test:i("test")}}function $y(u,t){const e=Xe(u,"output_type",t.outputType)==="reasoning"?"reasoning":"standard",s=String(Xe(u,"generation_prompt",t.generationPrompt));return{generationModelId:Xe(u,"generation_model_id",t.generationModelId),generationPrompt:Fy(s)?Sg(e):s,outputType:e,reasoningDetail:Xe(u,"reasoning_detail",t.reasoningDetail)==="detailed"?"detailed":"normal",temperature:vr(u,"temperature",t.temperature),maxTokens:vr(u,"max_tokens",t.maxTokens),jsonMode:!!Xe(u,"json_mode",t.jsonMode),qualityFilterEnabled:!!Xe(u,"quality_filter_enabled",t.qualityFilterEnabled),filterLowQuality:!!Xe(u,"filter_low_quality",t.filterLowQuality),filterShortContent:!!Xe(u,"filter_short_content",t.filterShortContent),minOutputLength:vr(u,"min_output_length",t.minOutputLength)}}function YA(u){const t=Oy(),e=Xe(u,"preprocess_options",[]);return{...t,...$y(u,t),preprocessOptions:Array.isArray(e)?e.map(String):t.preprocessOptions,semanticEnrichment:!!Xe(u,"semantic_enrichment",t.semanticEnrichment),qaPairsPerRow:ov(vr(u,"qa_pairs_per_row",t.qaPairsPerRow),t.qaPairsPerRow),datasetSplit:By(u,t.datasetSplit)}}function KA(u){const t=Ny(),e=Xe(u,"preprocess_options",[]);return{...t,...$y(u,t),preprocessOptions:Array.isArray(e)?e.map(String):t.preprocessOptions,chunkMethod:Xe(u,"chunk_method",t.chunkMethod),chunkSize:vr(u,"chunk_size",t.chunkSize),chunkOverlap:vr(u,"chunk_overlap",t.chunkOverlap),minChunkSize:vr(u,"min_chunk_size",t.minChunkSize),semanticBreakpointPercentile:vr(u,"semantic_breakpoint_percentile",t.semanticBreakpointPercentile),preserveTables:!!Xe(u,"preserve_tables",t.preserveTables),preserveCodeBlocks:!!Xe(u,"preserve_code_blocks",t.preserveCodeBlocks),preserveLists:!!Xe(u,"preserve_lists",t.preserveLists),semanticEnrichment:!!Xe(u,"semantic_enrichment",t.semanticEnrichment),qaPairsPerChunk:ov(vr(u,"qa_pairs_per_chunk",t.qaPairsPerChunk),t.qaPairsPerChunk),datasetSplit:By(u,t.datasetSplit)}}function QA(u,t,e){if(u==="structured")return{preprocessOptions:t.preprocessOptions};if(u!=="unstructured")return null;const{preprocessOptions:s,chunkMethod:i,chunkSize:r,chunkOverlap:a,minChunkSize:o,semanticBreakpointPercentile:l,preserveTables:c,preserveCodeBlocks:h,preserveLists:d}=e;return{preprocessOptions:s,chunkMethod:i,chunkSize:r,chunkOverlap:a,minChunkSize:o,semanticBreakpointPercentile:l,preserveTables:c,preserveCodeBlocks:h,preserveLists:d}}function JA(u,t,e){const s=u==="unstructured"?e:t;if(u==="external")return null;const i={semanticEnrichment:s.semanticEnrichment,datasetSplit:s.datasetSplit,generationModelId:s.generationModelId,generationPrompt:s.generationPrompt,outputType:s.outputType,reasoningDetail:s.reasoningDetail,temperature:s.temperature,maxTokens:s.maxTokens,jsonMode:s.jsonMode,qualityFilterEnabled:s.qualityFilterEnabled,filterLowQuality:s.filterLowQuality,filterShortContent:s.filterShortContent,minOutputLength:s.minOutputLength};return u==="unstructured"?{...i,qaPairsPerChunk:e.qaPairsPerChunk}:{...i,qaPairsPerRow:t.qaPairsPerRow}}const ZA={key:0,class:"generation-config-group model-config-group"},t1={class:"model-field"},e1={class:"model-option"},s1={class:"model-field"},i1={class:"field-copy"},n1={class:"field-header",style:{display:"flex","justify-content":"space-between","align-items":"center",width:"100%"}},r1={key:0},a1={key:1},o1={class:"prompt-input-wrapper"},l1={key:0,class:"highlight-var"},c1={key:1},h1={class:"advanced-settings-grid"},u1={class:"config-field"},d1={class:"config-field"},f1={class:"unit-input"},p1={class:"json-mode-row"},g1={key:0,class:"generation-validation-message",role:"alert"},m1={key:1,class:"generation-config-group quality-config-group"},v1={class:"output-type-field"},y1={class:"output-type-row"},b1={key:0,class:"output-type-row"},w1={class:"output-type-hint"},A1={class:"quality-switch-row"},S1={key:0,class:"quality-rule-panel"},x1={key:0,class:"minimum-length-field"},_1={class:"minimum-length-input"},E1={key:1,class:"quality-rule-warning",role:"alert"},C1={key:1,class:"generation-validation-message",role:"alert"},k1=ni({__name:"GenerationOptionsPanel",props:{options:{},models:{},section:{},validationMessage:{}},emits:["update:options"],setup(u,{emit:t}){const e=u,s=t,i=it(null),r=it(null);function a(A){const y=(A||"").split("{{ content }}"),S=[];return y.forEach((_,C)=>{_&&S.push({text:_,isVar:!1}),C<y.length-1&&S.push({text:"{{ content }}",isVar:!0})}),S}function o(A){r.value&&(r.value.scrollTop=A.target.scrollTop)}Ey(()=>{var y;const A=(y=i.value)==null?void 0:y.textarea;A&&A.addEventListener("scroll",o)}),Gp(()=>{var y;const A=(y=i.value)==null?void 0:y.textarea;A&&A.removeEventListener("scroll",o)});function l(A,y){s("update:options",{...e.options,[A]:y})}function c(){l("generationPrompt",Sg(e.options.outputType))}function h(A){const y=A.filter(S=>typeof S=="string");s("update:options",{...e.options,filterLowQuality:y.includes("low_quality"),filterShortContent:y.includes("short_content")})}function d(A){const y=A==="reasoning"?"reasoning":"standard";s("update:options",{...e.options,outputType:y,generationPrompt:Fy(e.options.generationPrompt)?Sg(y):e.options.generationPrompt})}function f(A){l("reasoningDetail",A==="detailed"?"detailed":"normal")}const g=()=>[e.options.filterLowQuality?"low_quality":"",e.options.filterShortContent?"short_content":""].filter(Boolean);function b(){if(!e.validationMessage)return"";const A=e.validationMessage.includes("数据生成模型");return e.section==="model"?A?e.validationMessage:"":A?"":e.validationMessage}function w(A){const y=A.model_source==="api"||A.model_source==="online"?"在线模型":A.model_source==="local"?"本地模型":A.model_source||"模型管理";return A.type?`${y} · ${A.type}`:y}return(A,y)=>{const S=qd,_=Xd,C=Ml,E=jd,k=oA,D=Wd,M=lA,F=jp,B=My;return u.section==="model"?(O(),$("div",ZA,[x("div",t1,[y[8]||(y[8]=x("div",{class:"field-copy"},[x("strong",null,[at("数据生成模型 "),x("em",null,"*")]),x("small",null,"选择负责生成问答、指令或结构化内容的大模型")],-1)),V(_,{class:"model-select","model-value":u.options.generationModelId,filterable:"",placeholder:"请选择用于生成数据的模型","aria-label":"数据生成模型","onUpdate:modelValue":y[0]||(y[0]=I=>l("generationModelId",I))},{empty:tt(()=>[...y[7]||(y[7]=[x("div",{class:"model-empty"},"暂无模型,请先在模型管理中添加",-1)])]),default:tt(()=>[(O(!0),$(xt,null,xe(u.models||[],I=>(O(),Pt(S,{key:I.id,label:I.name,value:I.id},{default:tt(()=>[x("div",e1,[x("span",null,G(I.name),1),x("small",null,G(w(I)),1)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),x("div",s1,[x("div",i1,[x("div",n1,[y[10]||(y[10]=x("strong",null,"默认提示语",-1)),V(C,{link:"",type:"primary",onClick:c,style:{"font-size":"12px",padding:"0"}},{default:tt(()=>[...y[9]||(y[9]=[at("恢复默认",-1)])]),_:1})]),u.options.outputType==="reasoning"?(O(),$("small",r1," 当前使用思维链专用提示语;系统还会按所选详细程度约束推理结构 ")):(O(),$("small",a1,"当前使用标准回答提示语,只要求问题和最终答案"))]),x("div",o1,[x("div",{ref_key:"promptHighlightRef",ref:r,class:"prompt-highlight-layer","aria-hidden":"true"},[(O(!0),$(xt,null,xe(a(u.options.generationPrompt),(I,T)=>(O(),$(xt,{key:T},[I.isVar?(O(),$("span",l1,G(I.text),1)):(O(),$("span",c1,G(I.text),1))],64))),128))],512),V(E,{ref_key:"promptInputRef",ref:i,class:"prompt-input","model-value":u.options.generationPrompt,type:"textarea",rows:6,maxlength:"2000","show-word-limit":"",resize:"vertical",placeholder:"请输入模型生成内容时需要遵循的要求","aria-label":"模型默认提示语","onUpdate:modelValue":y[1]||(y[1]=I=>l("generationPrompt",I))},null,8,["model-value"])]),y[11]||(y[11]=x("div",{class:"prompt-variables-hint"},[at(" 默认提示语已包含 "),x("code",{textContent:"{{ content }}"}),at(",运行时会替换为当前数据内容; 可移动该占位符来调整内容在提示语中的位置。 ")],-1))]),x("div",h1,[x("label",u1,[y[12]||(y[12]=x("span",{class:"config-field-label"},"生成温度 (Temperature)",-1)),V(k,{"model-value":u.options.temperature,min:0,max:1,step:.1,"show-input":"","onUpdate:modelValue":y[2]||(y[2]=I=>l("temperature",Number(I)||0))},null,8,["model-value"]),y[13]||(y[13]=x("small",null,"较低值输出更确定、保守,较高值输出更多样、有创造性",-1))]),x("label",d1,[y[15]||(y[15]=x("span",{class:"config-field-label"},"最大输出长度 (Max Tokens)",-1)),x("span",f1,[V(D,{"model-value":u.options.maxTokens,min:100,max:8192,step:256,"controls-position":"right","onUpdate:modelValue":y[3]||(y[3]=I=>l("maxTokens",Number(I)||1024))},null,8,["model-value"]),y[14]||(y[14]=x("span",null,"Token",-1))]),y[16]||(y[16]=x("small",null,"限制单次生成的最大内容长度,防止过度发散",-1))])]),x("div",p1,[y[17]||(y[17]=x("div",{class:"field-copy"},[x("strong",null,"强制 JSON 格式输出"),x("small",null,"要求大模型返回纯 JSON 对象,有助于提高下游结构化提取的稳定性")],-1)),V(M,{"model-value":u.options.jsonMode,"inline-prompt":"","active-text":"开","inactive-text":"关","onUpdate:modelValue":y[4]||(y[4]=I=>l("jsonMode",!!I))},null,8,["model-value"])]),b()?(O(),$("p",g1,G(b()),1)):ct("",!0)])):(O(),$("div",m1,[x("div",v1,[x("div",y1,[y[18]||(y[18]=x("div",{class:"field-copy"},[x("strong",null,"输出类型"),x("small",null,"控制答案是否包含可用于推理模型训练的思维链内容")],-1)),V(_,{class:"output-type-select","model-value":u.options.outputType,"aria-label":"输出类型","onUpdate:modelValue":d},{default:tt(()=>[V(S,{label:"标准回答",value:"standard"}),V(S,{label:"思维链回答",value:"reasoning"})]),_:1},8,["model-value"])]),u.options.outputType==="reasoning"?(O(),$("div",b1,[y[19]||(y[19]=x("div",{class:"field-copy"},[x("strong",null,"推理详细程度"),x("small",null,"控制推理过程保留关键步骤,或完整展开依据与中间推导")],-1)),V(_,{class:"output-type-select","model-value":u.options.reasoningDetail,"aria-label":"推理详细程度","onUpdate:modelValue":f},{default:tt(()=>[V(S,{label:"普通推理(推荐)",value:"normal"}),V(S,{label:"详细推理",value:"detailed"})]),_:1},8,["model-value"])])):ct("",!0),x("p",w1,[u.options.outputType==="reasoning"?(O(),$(xt,{key:0},[u.options.reasoningDetail==="detailed"?(O(),$(xt,{key:0},[at(" 完整展开条件、来源依据、中间推导和结论核对, ")],64)):(O(),$(xt,{key:1},[at("保留关键依据与必要步骤,")],64)),y[20]||(y[20]=at(" 最终按 ",-1)),y[21]||(y[21]=x("code",null,"<think>推理过程</think>",-1)),y[22]||(y[22]=at(" 加最终答案保存。 ",-1))],64)):(O(),$(xt,{key:1},[at("仅保存最终答案,不包含推理过程。")],64))])]),x("div",A1,[y[23]||(y[23]=x("div",{class:"config-group-heading"},[x("div",null,[x("h4",null,"质量筛选"),x("p",null,"生成后自动过滤不符合要求的内容,不影响源数据预处理")])],-1)),V(M,{"model-value":u.options.qualityFilterEnabled,"inline-prompt":"","active-text":"开","inactive-text":"关","aria-label":"质量筛选","onUpdate:modelValue":y[5]||(y[5]=I=>l("qualityFilterEnabled",!!I))},null,8,["model-value"])]),u.options.qualityFilterEnabled?(O(),$("div",S1,[V(B,{"model-value":g(),class:"quality-rule-list","onUpdate:modelValue":h},{default:tt(()=>[V(F,{value:"low_quality"},{default:tt(()=>[...y[24]||(y[24]=[x("span",{class:"rule-copy"},[x("strong",null,"过滤低质量内容"),x("small",null,"按相关性、完整性和可读性过滤明显不合格的生成结果")],-1)])]),_:1}),V(F,{value:"short_content"},{default:tt(()=>[...y[25]||(y[25]=[x("span",{class:"rule-copy"},[x("strong",null,"过滤过短内容"),x("small",null,"过滤正文长度低于指定字数的生成结果")],-1)])]),_:1})]),_:1},8,["model-value"]),u.options.filterShortContent?(O(),$("label",x1,[y[27]||(y[27]=x("span",null,"最少字数",-1)),x("span",_1,[V(D,{"model-value":u.options.minOutputLength,min:1,max:1e3,step:5,precision:0,"controls-position":"right","aria-label":"生成内容最少字数","onUpdate:modelValue":y[6]||(y[6]=I=>l("minOutputLength",Number(I)||1))},null,8,["model-value"]),y[26]||(y[26]=x("span",null,"字",-1))]),y[28]||(y[28]=x("small",null,"少于该字数的生成结果将被过滤",-1))])):ct("",!0),!u.options.filterLowQuality&&!u.options.filterShortContent?(O(),$("p",E1," 请至少选择一项质量筛选规则 ")):ct("",!0)])):ct("",!0),b()?(O(),$("p",C1,G(b()),1)):ct("",!0)]))}}}),lv=ri(k1,[["__scopeId","data-v-fbeb84f2"]]),T1={class:"form-section structured-options-section"},P1={class:"preprocess-option-copy"},M1={class:"form-section generation-options-section"},I1={class:"generation-option-list"},D1={class:"generation-option-row"},L1=ni({__name:"StructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{}},emits:["update:options"],setup(u,{emit:t}){const e=u,s=t,i=[{value:"clean_invalid",label:"清理无效数据",description:"清理全空列,并剔除关键字段残缺的数据行"},{value:"detect_structure",label:"嵌套结构展平",description:"展平嵌套对象和可解析的 JSON 字段Excel 表头与合并单元格在上传时自动解析"},{value:"deduplicate",label:"重复记录去重",description:"按整行内容或 id、uuid、key、code、*_id 等身份字段去重,暂不支持自定义组合字段"},{value:"normalize_format",label:"数据格式标准化",description:"按所选规则统一编码、空白、字段名及 JSON 序列化格式"},{value:"filter_anomaly",label:"异常数据过滤",description:"使用 IQR 识别数值离群值,并过滤乱码等异常记录"},{value:"desensitize",label:"敏感信息脱敏",description:"识别并脱敏姓名、手机号、邮箱和身份证号"}];function r(c,h){s("update:options",{...e.options,[c]:h})}function a(c){s("update:options",{...e.options,...c})}function o(c){r("qaPairsPerRow",ov(c))}function l(c){const h=new Set(i.map(f=>f.value)),d=Array.from(new Set(c.filter(f=>typeof f=="string"&&h.has(f))));r("preprocessOptions",d)}return(c,h)=>{const d=jp,f=My,g=Wd;return O(),$(xt,null,[x("div",T1,[h[1]||(h[1]=x("div",{class:"section-title-row"},[x("div",null,[x("h3",null,"预处理选项"),x("p",null,"选择在生成问答对之前需要执行的数据处理方式")])],-1)),V(f,{"model-value":u.options.preprocessOptions,class:"preprocess-option-grid","onUpdate:modelValue":l},{default:tt(()=>[(O(),$(xt,null,xe(i,b=>V(d,{key:b.value,value:b.value,class:"preprocess-option"},{default:tt(()=>[x("span",P1,[x("strong",null,G(b.label),1),x("small",null,G(b.description),1)])]),_:2},1032,["value"])),64))]),_:1},8,["model-value"])]),x("div",M1,[h[3]||(h[3]=x("div",{class:"section-title-row"},[x("div",null,[x("h3",null,"生成选项"),x("p",null,"配置每条结构化记录生成问答对的方式和数量")])],-1)),x("div",I1,[V(lv,{options:u.options,section:"quality","validation-message":u.validationAttempted?u.qualityValidationMessage:"","onUpdate:options":a},null,8,["options","validation-message"]),x("div",D1,[h[2]||(h[2]=x("div",{class:"generation-option-copy"},[x("strong",null,"每行生成数量"),x("small",null,"支持 150 条;数量越大,处理耗时和 Token 消耗越高")],-1)),V(g,{"model-value":u.options.qaPairsPerRow,min:Bt(_l).min,max:Bt(_l).max,step:1,precision:0,"controls-position":"right","onUpdate:modelValue":o},null,8,["model-value","min","max"])]),V(Ly,{"model-value":u.options.datasetSplit,"onUpdate:modelValue":h[0]||(h[0]=b=>r("datasetSplit",b))},null,8,["model-value"])])])],64)}}}),R1=ri(L1,[["__scopeId","data-v-2cec45e9"]]),F1={class:"form-section unstructured-options-section"},O1={class:"preprocess-option-grid"},N1={class:"form-section chunk-options-section"},B1={class:"chunk-settings-grid is-basic"},$1={class:"config-field"},U1={key:0},H1={key:1},z1={key:2},V1={class:"config-field"},G1={class:"unit-input"},j1={class:"config-field"},W1={class:"unit-input"},X1={class:"config-field"},q1={class:"unit-input"},Y1={key:0,class:"config-field"},K1={class:"unit-input"},Q1={key:0,class:"option-validation-message",role:"alert"},J1={class:"form-section generation-options-section"},Z1={class:"generation-option-list"},tS={class:"generation-option-row"},eS=ni({__name:"UnstructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{},chunkValidationMessage:{}},emits:["update:options"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=["clean_invalid_content","detect_document_structure","merge_short_content","filter_low_quality","deduplicate_content","preserve_context"],a=[{value:"layout_hybrid",label:"版面结构混合切分"},{value:"semantic",label:"语义切分"},{value:"fixed",label:"固定 Token 切分"}],o={chunkSize:{min:200,max:2e3},chunkOverlap:{min:0,max:500},minChunkSize:{min:20,max:500},semanticBreakpointPercentile:{min:1,max:99},qaPairsPerChunk:_l},l=st(()=>r.every(S=>s.options.preprocessOptions.includes(S))),c=st(()=>s.options.preprocessOptions.includes("desensitize")),h=st(()=>s.options.preserveTables&&s.options.preserveCodeBlocks&&s.options.preserveLists);function d(S,_){i("update:options",{...s.options,[S]:_})}function f(S){i("update:options",{...s.options,...S})}function g(S){const _=!!S,C=Array.from(new Set(s.options.preprocessOptions.filter(E=>!r.includes(E))));d("preprocessOptions",_?[...r,...C]:C)}function b(S){const _=Array.from(new Set(s.options.preprocessOptions.filter(C=>C!=="desensitize")));S&&_.push("desensitize"),d("preprocessOptions",_)}function w(S){const _=!!S;i("update:options",{...s.options,preserveTables:_,preserveCodeBlocks:_,preserveLists:_})}function A(S,_){const C=o[S],E=Number(_),k=Number.isFinite(E)?E:C.min;d(S,Math.min(C.max,Math.max(C.min,k)))}function y(){}return t({revealValidation:y}),(S,_)=>{const C=jp,E=qd,k=Xd,D=Wd;return O(),$(xt,null,[x("div",F1,[_[10]||(_[10]=x("div",{class:"section-title-row"},[x("div",null,[x("h3",null,"预处理选项"),x("p",null,"默认启用结构感知的推荐策略,只需决定是否需要脱敏")])],-1)),x("div",O1,[x("label",{class:re(["preprocess-option",{"is-checked":l.value}])},[V(C,{"model-value":l.value,"onUpdate:modelValue":g},null,8,["model-value"]),_[7]||(_[7]=x("span",{class:"preprocess-option-copy"},[x("strong",null,"智能预处理"),x("small",null,"清理页眉页脚、页码、目录和无效内容,感知文档结构、合并短块、预过滤低质量内容、近重复去重,并通过重叠保护上下文")],-1))],2),x("label",{class:re(["preprocess-option",{"is-checked":c.value}])},[V(C,{"model-value":c.value,"onUpdate:modelValue":b},null,8,["model-value"]),_[8]||(_[8]=x("span",{class:"preprocess-option-copy"},[x("strong",null,"敏感信息脱敏"),x("small",null,"识别并脱敏姓名、手机号、邮箱和身份证号")],-1))],2),x("label",{class:re(["preprocess-option",{"is-checked":h.value}])},[V(C,{"model-value":h.value,"onUpdate:modelValue":w},null,8,["model-value"]),_[9]||(_[9]=x("span",{class:"preprocess-option-copy"},[x("strong",null,"保护表格、代码和列表"),x("small",null,"避免切分点破坏特殊内容块的完整性")],-1))],2)])]),x("div",N1,[_[24]||(_[24]=x("div",{class:"section-title-row"},[x("div",null,[x("h3",null,"切分选项"),x("p",null,"优先保留文档版面结构,也可按主题变化或固定 Token 切分")])],-1)),x("div",B1,[x("label",$1,[_[11]||(_[11]=x("span",{class:"config-field-label"},"切分方式",-1)),V(k,{"model-value":u.options.chunkMethod,"aria-label":"切分方式","onUpdate:modelValue":_[0]||(_[0]=M=>d("chunkMethod",M))},{default:tt(()=>[(O(),$(xt,null,xe(a,M=>V(E,{key:M.value,label:M.label,value:M.value},null,8,["label","value"])),64))]),_:1},8,["model-value"]),u.options.chunkMethod==="layout_hybrid"?(O(),$("small",U1,"默认推荐,按标题、段落、列表和表格结构切分,并合并过短内容块")):u.options.chunkMethod==="semantic"?(O(),$("small",H1,"根据相邻内容的语义变化寻找主题边界,适合长文章和知识材料")):(O(),$("small",z1,"按句子边界控制固定 Token 长度,速度快且结果稳定"))]),x("label",V1,[_[13]||(_[13]=x("span",{class:"config-field-label"},"切片长度",-1)),x("span",G1,[V(D,{"model-value":u.options.chunkSize,min:200,max:2e3,step:50,precision:0,"controls-position":"right","aria-label":"切片长度","onUpdate:modelValue":_[1]||(_[1]=M=>A("chunkSize",M))},null,8,["model-value"]),_[12]||(_[12]=x("span",null,"Token",-1))]),_[14]||(_[14]=x("small",null,"单个切片的目标上限,默认 800 Token",-1))]),x("label",j1,[_[16]||(_[16]=x("span",{class:"config-field-label"},"重叠长度",-1)),x("span",W1,[V(D,{"model-value":u.options.chunkOverlap,min:0,max:500,step:10,precision:0,"controls-position":"right","aria-label":"重叠长度","onUpdate:modelValue":_[2]||(_[2]=M=>A("chunkOverlap",M))},null,8,["model-value"]),_[15]||(_[15]=x("span",null,"Token",-1))]),_[17]||(_[17]=x("small",null,"在相邻切片中最多重复保留的上下文,默认 100 Token",-1))]),x("label",X1,[_[19]||(_[19]=x("span",{class:"config-field-label"},"最小切片长度",-1)),x("span",q1,[V(D,{"model-value":u.options.minChunkSize,min:20,max:500,step:10,precision:0,"controls-position":"right","aria-label":"最小切片长度","onUpdate:modelValue":_[3]||(_[3]=M=>A("minChunkSize",M))},null,8,["model-value"]),_[18]||(_[18]=x("span",null,"Token",-1))]),_[20]||(_[20]=x("small",null,"过短的尾部内容会尽量并入前一个切片",-1))]),u.options.chunkMethod==="semantic"?(O(),$("label",Y1,[_[22]||(_[22]=x("span",{class:"config-field-label"},"语义断点百分位",-1)),x("span",K1,[V(D,{"model-value":u.options.semanticBreakpointPercentile,min:1,max:99,step:1,precision:0,"controls-position":"right","aria-label":"语义断点百分位","onUpdate:modelValue":_[4]||(_[4]=M=>A("semanticBreakpointPercentile",M))},null,8,["model-value"]),_[21]||(_[21]=x("span",null,"%",-1))]),_[23]||(_[23]=x("small",null,"百分位越低切片越多,推荐保持 95%",-1))])):ct("",!0)]),_[25]||(_[25]=x("p",{class:"chunk-estimation-note"}," Token 数为轻量估算值,实际长度以训练使用的模型分词器为准。 ",-1)),u.chunkValidationMessage?(O(),$("p",Q1,G(u.chunkValidationMessage),1)):ct("",!0)]),x("div",J1,[_[27]||(_[27]=x("div",{class:"section-title-row"},[x("div",null,[x("h3",null,"生成选项"),x("p",null,"只保留会直接影响输出的核心设置")])],-1)),x("div",Z1,[V(lv,{options:u.options,section:"quality","validation-message":u.validationAttempted?u.qualityValidationMessage:"","onUpdate:options":f},null,8,["options","validation-message"]),x("div",tS,[_[26]||(_[26]=x("div",{class:"generation-option-copy"},[x("strong",null,"每个切片生成数量"),x("small",null,"支持 150 条;数量越大,处理耗时和 Token 消耗越高")],-1)),V(D,{"model-value":u.options.qaPairsPerChunk,min:Bt(_l).min,max:Bt(_l).max,step:1,precision:0,"controls-position":"right","aria-label":"每个切片生成数量","onUpdate:modelValue":_[5]||(_[5]=M=>A("qaPairsPerChunk",M))},null,8,["model-value","min","max"])]),V(Ly,{"model-value":u.options.datasetSplit,"aria-label-prefix":"非结构化","onUpdate:modelValue":_[6]||(_[6]=M=>d("datasetSplit",M))},null,8,["model-value"])])])],64)}}}),sS=ri(eS,[["__scopeId","data-v-4ca60714"]]),iS={class:"task-setup-step"},nS={class:"form-section"},rS={class:"basic-grid"},aS={class:"form-section"},oS={class:"section-title-row"},lS={key:0},cS={key:1},hS={class:"type-options"},uS=["disabled"],dS=["disabled"],fS=["disabled"],pS=ni({__name:"TaskSetupStep",props:{name:{},description:{},processType:{},structuredOptions:{},unstructuredOptions:{},processTypeLocked:{type:Boolean}},emits:["update:name","update:description","update:processType","update:structuredOptions","update:unstructuredOptions"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=it(),a=it(),o=it(!1),l=st(()=>({name:s.name,processType:s.processType})),c=st(()=>{const{train:A,validation:y,test:S}=s.structuredOptions.datasetSplit;return A+y+S}),h=st(()=>{const{train:A,validation:y,test:S}=s.unstructuredOptions.datasetSplit;return A+y+S}),d=st(()=>s.processType==="structured"?s.structuredOptions:s.processType==="unstructured"?s.unstructuredOptions:null),f=st(()=>{const A=d.value;return A?A.qualityFilterEnabled&&!A.filterLowQuality&&!A.filterShortContent?"开启质量筛选后,请至少选择一项筛选规则":A.qualityFilterEnabled&&A.filterShortContent&&A.minOutputLength<1?"最少字数必须大于 0":"":""}),g=st(()=>s.unstructuredOptions.chunkOverlap>=s.unstructuredOptions.chunkSize?"重叠长度必须小于切片长度":s.unstructuredOptions.minChunkSize>s.unstructuredOptions.chunkSize?"最小切片长度不能大于切片长度":s.unstructuredOptions.chunkOverlap+s.unstructuredOptions.minChunkSize>s.unstructuredOptions.chunkSize?"重叠长度与最小切片长度之和不能大于切片长度":""),b={name:[{required:!0,message:"请输入任务名称",trigger:"blur"},{max:50,message:"任务名称不能超过 50 个字符",trigger:"blur"}],processType:[{required:!0,message:"请选择数据处理类型",trigger:"change"}]};async function w(){var A;if(o.value=!0,!r.value)return!1;try{if(await r.value.validate(),s.processType==="structured"&&c.value!==100)return lt.error("结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(s.processType==="unstructured"){if(h.value!==100)return lt.error("非结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(g.value)return(A=a.value)==null||A.revealValidation(),lt.error(g.value),!1}return f.value?(lt.error(f.value),!1):!0}catch{return lt.error("请完善标红的必填项"),!1}}return t({validate:w}),(A,y)=>{const S=jd,_=Py,C=Ty;return O(),$("section",iS,[V(C,{ref_key:"formRef",ref:r,model:l.value,rules:b,"label-position":"top","scroll-to-error":""},{default:tt(()=>[x("div",nS,[y[7]||(y[7]=x("h3",null,"基本信息",-1)),x("div",rS,[V(_,{label:"任务名称",prop:"name",required:""},{default:tt(()=>[V(S,{"model-value":u.name,maxlength:"50","show-word-limit":"",placeholder:"例如:金融问答清洗任务","onUpdate:modelValue":y[0]||(y[0]=E=>i("update:name",E))},null,8,["model-value"])]),_:1}),V(_,{label:"任务描述(选填)"},{default:tt(()=>[V(S,{"model-value":u.description,type:"textarea",rows:3,maxlength:"200","show-word-limit":"",placeholder:"简要说明本次数据处理目标","onUpdate:modelValue":y[1]||(y[1]=E=>i("update:description",E))},null,8,["model-value"])]),_:1})])]),x("div",aS,[x("div",oS,[x("div",null,[y[8]||(y[8]=x("h3",null,"处理类型",-1)),u.processTypeLocked?(O(),$("p",lS,"重新生成沿用原任务处理类型,不可修改")):(O(),$("p",cS,"类型会影响下一步支持的数据源格式和后续预览方式"))])]),V(_,{prop:"processType",class:"type-form-item"},{default:tt(()=>[x("div",hS,[x("button",{type:"button",class:re(["type-option",{"is-active":u.processType==="structured"}]),disabled:u.processTypeLocked,onClick:y[2]||(y[2]=E=>i("update:processType","structured"))},[...y[9]||(y[9]=[x("span",{class:"type-icon"},[x("i",{class:"fa fa-table"})],-1),x("span",null,[x("strong",null,"结构化数据"),x("small",null,"适用于 CSV、Excel、JSONL 等固定字段数据")],-1),x("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],10,uS),x("button",{type:"button",class:re(["type-option",{"is-active":u.processType==="unstructured"}]),disabled:u.processTypeLocked,onClick:y[3]||(y[3]=E=>i("update:processType","unstructured"))},[...y[10]||(y[10]=[x("span",{class:"type-icon"},[x("i",{class:"fa fa-file-text-o"})],-1),x("span",null,[x("strong",null,"非结构化数据"),x("small",null,"适用于文档、文本、问答等需要切分的数据")],-1),x("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],10,dS),x("button",{type:"button",class:re(["type-option",{"is-active":u.processType==="external"}]),disabled:u.processTypeLocked,onClick:y[4]||(y[4]=E=>i("update:processType","external"))},[...y[11]||(y[11]=[x("span",{class:"type-icon"},[x("i",{class:"fa fa-cloud-download"})],-1),x("span",null,[x("strong",null,"外来数据源拉取"),x("small",null,"适用于数据库、API 接口等需远程拉取的外部数据")],-1),x("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],10,fS)])]),_:1})]),u.processType==="structured"?(O(),Pt(R1,{key:0,options:u.structuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"onUpdate:options":y[5]||(y[5]=E=>i("update:structuredOptions",E))},null,8,["options","validation-attempted","quality-validation-message"])):ct("",!0),u.processType==="unstructured"?(O(),Pt(sS,{key:1,ref_key:"unstructuredOptionsPanelRef",ref:a,options:u.unstructuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"chunk-validation-message":g.value,"onUpdate:options":y[6]||(y[6]=E=>i("update:unstructuredOptions",E))},null,8,["options","validation-attempted","quality-validation-message","chunk-validation-message"])):ct("",!0)]),_:1},8,["model"])])}}}),gS=ri(pS,[["__scopeId","data-v-d9b924a8"]]),mS={class:"model-selection-step","aria-labelledby":"model-selection-title"},vS={class:"form-section"},yS={class:"model-form-content"},bS=ni({__name:"ModelSelectionStep",props:{options:{},models:{}},emits:["update:options"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=it(!1),a=st(()=>s.options.generationModelId===""?"请选择数据生成模型":"");function o(){return r.value=!0,a.value?(lt.error(a.value),!1):!0}return t({validate:o}),(l,c)=>(O(),$("section",mS,[x("div",vS,[c[1]||(c[1]=x("div",{class:"section-title-row"},[x("div",null,[x("h3",{id:"model-selection-title"},"大模型选择"),x("p",null,"选择本次数据生成使用的模型,并设置统一的输出要求")])],-1)),x("div",yS,[V(lv,{options:u.options,models:u.models,section:"model","validation-message":r.value?a.value:"","onUpdate:options":c[0]||(c[0]=h=>i("update:options",h))},null,8,["options","models","validation-message"])])])]))}}),wS=ri(bS,[["__scopeId","data-v-77825278"]]),AS={class:"source-upload-step","aria-labelledby":"source-upload-title"},SS={key:0,class:"form-section external-section"},xS={class:"external-form"},_S={class:"external-actions"},ES={key:0,class:"external-status is-connected",role:"status"},CS={key:0,class:"uploaded-file-list","aria-label":"已拉取数据列表"},kS={class:"uploaded-file-list-header"},TS={class:"uploaded-file-items"},PS={class:"file-main"},MS=["title"],IS=["title"],DS={class:"file-status",role:"status","aria-live":"polite"},LS={class:"file-progress-value"},RS={key:0,class:"file-preview-error"},FS={key:1,class:"form-section upload-section"},OS={class:"section-title-row"},NS={class:"el-upload__tip"},BS={key:1,class:"uploaded-file-list","aria-label":"已上传文件列表"},$S={class:"uploaded-file-list-header"},US={key:0,class:"upload-queue-status"},HS={class:"continue-upload"},zS={class:"uploaded-file-items"},VS={class:"file-main"},GS=["title"],jS=["title"],WS={class:"file-status",role:"status","aria-live":"polite"},XS={class:"file-progress-value"},qS={key:0,class:"file-preview-error"},Fa=10,YS=ni({__name:"SourceUploadStep",props:{processType:{},uploadedFiles:{},externalSource:{},externalPulling:{type:Boolean},externalConnected:{type:Boolean},previewBuilding:{type:Boolean},sourceUploading:{type:Boolean}},emits:["update:externalSource","file-change","remove-file","use-sample","test-connection","pull-data"],setup(u,{emit:t}){const e=u,s=t,i=[{value:"postgresql",label:"PostgreSQL"}],r=[{value:"none",label:"免鉴权"},{value:"basic",label:"账号密码"}],a=it(1),o={queued:{label:"等待上传",icon:"fa-clock-o"},uploading:{label:"正在上传",icon:"fa-cloud-upload"},waiting:{label:"等待切分",icon:"fa-clock-o"},processing:{label:"正在切分",icon:"fa-spinner fa-spin"},success:{label:"切分完成",icon:"fa-check-circle"},"upload-failed":{label:"上传失败",icon:"fa-exclamation-circle"},"preview-failed":{label:"切分失败",icon:"fa-exclamation-circle"}},l=st(()=>e.processType==="external"),c=st(()=>e.processType==="unstructured"?".txt,.md,.markdown,.pdf,.docx,.pptx,.json,.jsonl,.ndjson":".json,.jsonl,.ndjson,.csv,.tsv,.xlsx"),h=st(()=>{const C=(a.value-1)*Fa;return e.uploadedFiles.slice(C,C+Fa)});Is(()=>e.uploadedFiles.length,(C,E)=>{const k=Math.max(1,Math.ceil(C/Fa));if(C>E){a.value=k;return}a.value=Math.min(a.value,k)}),Is(()=>e.processType,()=>{a.value=1});function d(C,E){s("update:externalSource",{...e.externalSource,[C]:E})}function f(C){return C?C>=1024*1024?`${(C/1024/1024).toFixed(1)} MB`:`${(C/1024).toFixed(1)} KB`:"0 KB"}function g(C){return C.status==="queued"||C.status==="uploading"?C.status:C.status==="failed"?"upload-failed":C.previewStatus==="processing"||C.previewStatus==="success"?C.previewStatus:C.previewStatus==="failed"?"preview-failed":"waiting"}function b(C){const E=g(C),k=E==="queued"||E==="uploading"||E==="upload-failed"?C.uploadProgress:E==="waiting"?100:C.previewProgress??0;return Math.min(100,Math.max(0,k))}function w(C){return g(C)==="processing"}function A(C){return w(C)?100:b(C)}function y(C){const E=g(C);if(E==="waiting"||E==="success")return"success";if(E==="upload-failed"||E==="preview-failed")return"exception"}function S(C){return w(C)?"处理中":g(C)==="waiting"?"已上传":`${b(C)}%`}function _(C){return C.uploadError||C.previewError}return(C,E)=>{const k=qd,D=Xd,M=Py,F=jd,B=Wd,I=Ty,T=Ml,N=rv,H=Iy,Z=hA;return O(),$("section",AS,[l.value?(O(),$("div",SS,[E[18]||(E[18]=x("div",{class:"section-title-row"},[x("div",null,[x("h3",{id:"source-upload-title"},"数据源配置"),x("p",null,"配置并验证外部数据源,拉取成功后可在下一步预览数据内容")])],-1)),x("div",xS,[V(I,{"label-position":"top",class:"external-grid"},{default:tt(()=>[V(M,{label:"数据源类型"},{default:tt(()=>[V(D,{"model-value":u.externalSource.type,placeholder:"请选择数据源类型","aria-label":"数据源类型","onUpdate:modelValue":E[0]||(E[0]=P=>d("type",P))},{default:tt(()=>[(O(),$(xt,null,xe(i,P=>V(k,{key:P.value,label:P.label,value:P.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),V(M,{label:"地址 / URL"},{default:tt(()=>[V(F,{"model-value":u.externalSource.url,placeholder:"例如postgresql://db.example.com:5432/my_database","aria-label":"数据源地址或 URL","onUpdate:modelValue":E[1]||(E[1]=P=>d("url",P))},null,8,["model-value"])]),_:1}),V(M,{label:"鉴权方式"},{default:tt(()=>[V(D,{"model-value":u.externalSource.authMode,"aria-label":"鉴权方式","onUpdate:modelValue":E[2]||(E[2]=P=>d("authMode",P))},{default:tt(()=>[(O(),$(xt,null,xe(r,P=>V(k,{key:P.value,label:P.label,value:P.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),u.externalSource.authMode==="basic"?(O(),Pt(M,{key:0,label:"账号"},{default:tt(()=>[V(F,{"model-value":u.externalSource.username,autocomplete:"username",placeholder:"请输入账号","aria-label":"数据源账号","onUpdate:modelValue":E[3]||(E[3]=P=>d("username",P))},null,8,["model-value"])]),_:1})):ct("",!0),u.externalSource.authMode==="basic"?(O(),Pt(M,{key:1,label:"密码"},{default:tt(()=>[V(F,{"model-value":u.externalSource.password,type:"password","show-password":"",autocomplete:"current-password",placeholder:"请输入密码","aria-label":"数据源密码","onUpdate:modelValue":E[4]||(E[4]=P=>d("password",P))},null,8,["model-value"])]),_:1})):ct("",!0),V(M,{label:"拉取条数"},{default:tt(()=>[V(B,{"model-value":u.externalSource.limit,min:1,max:1e5,step:100,"controls-position":"right","aria-label":"数据拉取条数","onUpdate:modelValue":E[5]||(E[5]=P=>d("limit",Number(P)||0))},null,8,["model-value"])]),_:1}),V(M,{label:"只读查询语句",class:"external-query-field"},{default:tt(()=>[V(F,{"model-value":u.externalSource.query,type:"textarea",rows:4,maxlength:"20000","show-word-limit":"",placeholder:"例如SELECT question, answer FROM qa_data ORDER BY id","aria-label":"外部数据源只读查询语句","onUpdate:modelValue":E[6]||(E[6]=P=>d("query",P))},null,8,["model-value"]),E[12]||(E[12]=x("small",null,"只允许单条 SELECT 或 WITH 查询后端会拒绝写入、DDL 和多语句。",-1))]),_:1})]),_:1}),x("div",_S,[V(T,{loading:u.externalPulling&&!u.externalConnected,disabled:u.externalPulling||u.previewBuilding,plain:"",onClick:E[7]||(E[7]=P=>s("test-connection"))},{default:tt(()=>[...E[13]||(E[13]=[at(" 测试连接 ",-1)])]),_:1},8,["loading","disabled"]),V(T,{type:"primary",loading:u.externalPulling,disabled:u.externalPulling||u.previewBuilding,onClick:E[8]||(E[8]=P=>s("pull-data"))},{default:tt(()=>[...E[14]||(E[14]=[at(" 拉取数据 ",-1)])]),_:1},8,["loading","disabled"]),u.externalConnected?(O(),$("span",ES,[...E[15]||(E[15]=[x("i",{class:"fa fa-check-circle","aria-hidden":"true"},null,-1),at(" 连接正常 ",-1)])])):ct("",!0)]),u.uploadedFiles.length?(O(),$("section",CS,[x("div",kS,[x("span",null,"已拉取 "+G(u.uploadedFiles.length)+" 个数据集",1)]),x("div",TS,[(O(!0),$(xt,null,xe(h.value,P=>(O(),$("div",{key:P.uid,class:"uploaded-file"},[E[17]||(E[17]=x("span",{class:"file-icon"},[x("i",{class:"fa fa-cloud-download","aria-hidden":"true"})],-1)),x("div",PS,[x("strong",{title:P.name},G(P.name),9,MS),x("span",null,[at(G(f(P.size))+" ",1),P.count?(O(),$(xt,{key:0},[at(" · "+G(P.count.toLocaleString())+" 条",1)],64)):ct("",!0)])]),x("div",{class:re(["file-preview-progress",`is-${g(P)}`]),title:_(P)},[x("div",DS,[x("span",null,[x("i",{class:re(["fa",o[g(P)].icon]),"aria-hidden":"true"},null,2),at(" "+G(o[g(P)].label),1)]),x("span",LS,G(S(P)),1)]),V(N,{percentage:A(P),indeterminate:w(P),duration:1.5,"stroke-width":5,"show-text":!1,status:y(P),"aria-valuenow":w(P)?void 0:b(P),"aria-valuetext":w(P)?"正在切分,进度未知":S(P)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),_(P)?(O(),$("small",RS,G(_(P)),1)):ct("",!0)],10,IS),V(T,{link:"",type:"danger",disabled:u.previewBuilding||P.status==="uploading","aria-label":`删除数据集 ${P.name}`,onClick:K=>s("remove-file",P.uid)},{default:tt(()=>[...E[16]||(E[16]=[at(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),u.uploadedFiles.length>Fa?(O(),Pt(H,{key:0,"current-page":a.value,"onUpdate:currentPage":E[9]||(E[9]=P=>a.value=P),"page-size":Fa,total:u.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已拉取数据分页"},null,8,["current-page","total"])):ct("",!0)])):ct("",!0)])])):(O(),$("div",FS,[x("div",OS,[E[20]||(E[20]=x("div",null,[x("h3",{id:"source-upload-title"},"源数据上传"),x("p",null,"上传后可在下一步检查内容和切分效果,支持同时添加多个文件")],-1)),u.uploadedFiles.length===0?(O(),Pt(T,{key:0,link:"",type:"primary",disabled:u.previewBuilding,onClick:E[10]||(E[10]=P=>s("use-sample"))},{default:tt(()=>[...E[19]||(E[19]=[at(" 使用示例数据 ",-1)])]),_:1},8,["disabled"])):ct("",!0)]),u.uploadedFiles.length===0?(O(),Pt(Z,{key:0,drag:"",multiple:"",accept:c.value,disabled:u.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":P=>s("file-change",P),"aria-label":"选择或拖拽源数据文件"},{tip:tt(()=>[x("div",NS,G(u.processType==="unstructured"?"支持 TXT、MD、MARKDOWN、PDF、DOCX、PPTX、JSON、JSONL、NDJSON旧版 DOC/PPT 请先转换,单文件不超过 200MB":"支持 JSON、JSONL、NDJSON、CSV、TSV、XLSX旧版 XLS 请先转换,单文件不超过 200MB"),1)]),default:tt(()=>[E[21]||(E[21]=x("i",{class:"fa fa-cloud-upload upload-icon","aria-hidden":"true"},null,-1)),E[22]||(E[22]=x("div",{class:"el-upload__text"},[at("拖拽文件到此处,或"),x("em",null,"点击选择文件")],-1))]),_:1},8,["accept","disabled","on-change"])):(O(),$("section",BS,[x("div",$S,[x("span",null,[at(" 已选择 "+G(u.uploadedFiles.length)+" 个文件 ",1),u.sourceUploading?(O(),$("small",US," · 正在逐个上传")):ct("",!0)]),x("div",HS,[V(Z,{multiple:"",accept:c.value,disabled:u.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":P=>s("file-change",P),"aria-label":"继续添加源数据文件"},{default:tt(()=>[V(T,{size:"small",type:"primary",disabled:u.previewBuilding},{default:tt(()=>[...E[23]||(E[23]=[at("继续上传",-1)])]),_:1},8,["disabled"])]),_:1},8,["accept","disabled","on-change"])])]),x("div",zS,[(O(!0),$(xt,null,xe(h.value,P=>(O(),$("div",{key:P.uid,class:"uploaded-file"},[E[25]||(E[25]=x("span",{class:"file-icon"},[x("i",{class:"fa fa-file-text-o","aria-hidden":"true"})],-1)),x("div",VS,[x("strong",{title:P.name},G(P.name),9,GS),x("span",null,[at(G(f(P.size))+" ",1),P.count?(O(),$(xt,{key:0},[at(" · "+G(P.count.toLocaleString())+" 条",1)],64)):ct("",!0)])]),x("div",{class:re(["file-preview-progress",`is-${g(P)}`]),title:_(P)},[x("div",WS,[x("span",null,[x("i",{class:re(["fa",o[g(P)].icon]),"aria-hidden":"true"},null,2),at(" "+G(o[g(P)].label),1)]),x("span",XS,G(S(P)),1)]),V(N,{percentage:A(P),indeterminate:w(P),duration:1.5,"stroke-width":5,"show-text":!1,status:y(P),"aria-valuenow":w(P)?void 0:b(P),"aria-valuetext":w(P)?"正在切分,进度未知":S(P)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),_(P)?(O(),$("small",qS,G(_(P)),1)):ct("",!0)],10,jS),V(T,{link:"",type:"danger",disabled:u.previewBuilding||P.status==="uploading","aria-label":`删除文件 ${P.name}`,onClick:K=>s("remove-file",P.uid)},{default:tt(()=>[...E[24]||(E[24]=[at(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),u.uploadedFiles.length>Fa?(O(),Pt(H,{key:0,"current-page":a.value,"onUpdate:currentPage":E[11]||(E[11]=P=>a.value=P),"page-size":Fa,total:u.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已上传文件分页"},null,8,["current-page","total"])):ct("",!0)]))]))])}}}),KS=ri(YS,[["__scopeId","data-v-77d607a9"]]),QS=["aria-label"],JS={class:"office-toolbar"},ZS={class:"sheet-selector"},tx={key:0},ex={key:2,class:"toolbar-loading",role:"status"},sx=["href"],ix={key:0,class:"office-state",role:"status"},nx={key:1,class:"office-state is-error",role:"alert"},rx={class:"docx-page"},ax={key:1,class:"docx-table-wrap"},ox={class:"docx-table"},lx=["data-source-start"],cx={key:0,class:"office-empty"},hx={key:0,class:"xlsx-grid"},ux=["title"],dx={class:"row-number-cell"},fx=["title"],px={key:1,class:"office-empty"},gx={class:"xlsx-pagination"},fg=100,mx=ni({__name:"OfficeSourceViewer",props:{taskId:{},sourceFileId:{},fileName:{},fileFormat:{},selectedItem:{}},setup(u){const t=u,e=it(null),s=Cy(null),i=it(!1),r=it(""),a=it(0),o=it(0);let l=0;const c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,h=st(()=>{var T,N;return((T=t.fileFormat)==null?void 0:T.toLowerCase().replace(/^\./,""))||((N=t.fileName.split(".").pop())==null?void 0:N.toLowerCase())||""}),d=st(()=>h.value==="docx"),f=st(()=>{var T;return((T=s.value)==null?void 0:T.format)==="docx"?s.value:null}),g=st(()=>{var T;return((T=s.value)==null?void 0:T.format)==="xlsx"?s.value:null}),b=st(()=>t.taskId!=null&&t.sourceFileId!=null?Dy(t.taskId,t.sourceFileId):""),w=st(()=>{var Z;const T=(Z=g.value)==null?void 0:Z.active_sheet;if(!T||!T.rows.length)return"当前工作表没有可预览记录";const N=T.offset+1,H=T.offset+T.rows.length;return`${N}${H} 条记录`});function A(T,N){const H=t.selectedItem;return!H||H.sourceStart==null||H.sourceEnd==null?!1:N>H.sourceStart&&T<H.sourceEnd}function y(T){return A(T.source_start,T.source_end)}function S(T){return Array.isArray(T)?T.map(S):T&&typeof T=="object"?Object.fromEntries(Object.entries(T).sort(([N],[H])=>N.localeCompare(H)).map(([N,H])=>[N,S(H)])):T}function _(T){try{return JSON.stringify(S(T))}catch{return""}}const C=st(()=>{var N;const T=(N=t.selectedItem)==null?void 0:N.originalContent;if(!T)return"";try{return _(JSON.parse(T))}catch{return""}});function E(T){return!!(C.value&&_(T.record)===C.value)}function k(T){return T==null||T===""?"—":typeof T=="object"?JSON.stringify(T):String(T)}async function D(){var N;await vh();const T=(N=e.value)==null?void 0:N.querySelector(".docx-block.is-highlighted, .docx-table-row.is-highlighted, .xlsx-row.is-highlighted");T==null||T.scrollIntoView({block:"center",inline:"nearest",behavior:c?"auto":"smooth"})}async function M(T={}){const N=++l;if(T.reset&&(a.value=0,o.value=0,s.value=null),r.value="",t.taskId==null||t.sourceFileId==null){r.value="缺少原文件标识,无法加载预览";return}i.value=!0;try{const H=await uA(t.taskId,t.sourceFileId,d.value?{}:{sheet_index:a.value,offset:o.value,limit:fg});if(N!==l)return;s.value=H,H.format==="xlsx"&&(a.value=H.active_sheet.index),await D()}catch(H){if(N!==l)return;r.value=H instanceof Error?H.message:"Office 原文件预览加载失败"}finally{N===l&&(i.value=!1)}}function F(T){a.value=Number(T),o.value=0,M()}function B(){o.value=Math.max(0,o.value-fg),M()}function I(){var T;(T=g.value)!=null&&T.active_sheet.has_more&&(o.value+=fg,M())}return Is(()=>[t.taskId,t.sourceFileId,h.value],()=>void M({reset:!0}),{immediate:!0}),Is(()=>{var T;return(T=t.selectedItem)==null?void 0:T.id},()=>void D()),(T,N)=>{var K;const H=qd,Z=Xd,P=Ml;return O(),$("div",{class:"office-source-viewer","aria-label":`${h.value.toUpperCase()} 预览:${u.fileName}`},[x("div",JS,[g.value?(O(),$(xt,{key:0},[x("div",ZS,[N[1]||(N[1]=x("span",null,"工作表",-1)),V(Z,{"model-value":a.value,size:"small","aria-label":"选择 Excel 工作表","onUpdate:modelValue":F},{default:tt(()=>[(O(!0),$(xt,null,xe(g.value.sheets,z=>(O(),Pt(H,{key:z.index,label:z.name,value:z.index},null,8,["label","value"]))),128))]),_:1},8,["model-value"])]),x("span",null,G(w.value),1)],64)):(O(),$(xt,{key:1},[N[2]||(N[2]=x("span",null,"Word 网页版式预览",-1)),(K=f.value)!=null&&K.truncated?(O(),$("span",tx,"文档较长,仅展示前 2,000 个内容块")):ct("",!0)],64)),i.value&&s.value?(O(),$("span",ex,[...N[3]||(N[3]=[x("i",{class:"fa fa-spinner fa-spin"},null,-1),at(" 正在更新预览 ",-1)])])):ct("",!0),b.value?(O(),$("a",{key:3,class:"source-file-link",href:b.value,target:"_blank",rel:"noopener noreferrer"},[...N[4]||(N[4]=[x("i",{class:"fa fa-external-link"},null,-1),at(" 打开原文件 ",-1)])],8,sx)):ct("",!0)]),i.value&&!s.value?(O(),$("div",ix,[N[5]||(N[5]=x("i",{class:"fa fa-spinner fa-spin"},null,-1)),N[6]||(N[6]=x("strong",null,"正在加载原文件预览",-1)),x("span",null,G(d.value?"正在还原 Word 文档结构":"正在读取 Excel 工作表"),1)])):r.value?(O(),$("div",nx,[N[9]||(N[9]=x("i",{class:"fa fa-exclamation-circle"},null,-1)),x("strong",null,G(d.value?"Word 预览失败":"Excel 预览失败"),1),x("span",null,G(r.value),1),x("div",null,[V(P,{type:"primary",size:"small",onClick:N[0]||(N[0]=z=>M())},{default:tt(()=>[...N[7]||(N[7]=[at("重试",-1)])]),_:1}),b.value?(O(),Pt(P,{key:0,tag:"a",href:b.value,target:"_blank",size:"small"},{default:tt(()=>[...N[8]||(N[8]=[at(" 打开原文件 ",-1)])]),_:1},8,["href"])):ct("",!0)])])):f.value?(O(),$("div",{key:2,ref_key:"scrollRef",ref:e,class:"docx-scroll"},[x("article",rx,[(O(!0),$(xt,null,xe(f.value.blocks,(z,Et)=>(O(),$(xt,{key:Et},[z.type==="paragraph"?(O(),Pt(Z0(z.heading_level?`h${z.heading_level}`:"p"),{key:0,class:re(["docx-block",{"is-highlighted":A(z.source_start,z.source_end),"is-list":z.is_list}]),style:ky({textAlign:z.alignment}),"data-source-start":z.source_start},{default:tt(()=>[at(G(z.text),1)]),_:2},1032,["class","style","data-source-start"])):(O(),$("div",ax,[x("table",ox,[x("tbody",null,[(O(!0),$(xt,null,xe(z.rows,(_t,Ut)=>(O(),$("tr",{key:Ut,class:re(["docx-table-row",{"is-highlighted":y(_t)}]),"data-source-start":_t.source_start},[(O(!0),$(xt,null,xe(_t.cells,(Ot,X)=>(O(),$("td",{key:X},G(Ot||" "),1))),128))],10,lx))),128))])])]))],64))),128)),f.value.blocks.length?ct("",!0):(O(),$("div",cx,"文档中没有可预览的正文"))])],512)):g.value?(O(),$(xt,{key:3},[x("div",{ref_key:"scrollRef",ref:e,class:"xlsx-scroll"},[g.value.active_sheet.columns.length?(O(),$("table",hx,[x("thead",null,[x("tr",null,[N[10]||(N[10]=x("th",{class:"row-number-cell"},"#",-1)),(O(!0),$(xt,null,xe(g.value.active_sheet.columns,z=>(O(),$("th",{key:z,title:z},G(z),9,ux))),128))])]),x("tbody",null,[(O(!0),$(xt,null,xe(g.value.active_sheet.rows,z=>(O(),$("tr",{key:z.row_number,class:re(["xlsx-row",{"is-highlighted":E(z)}])},[x("th",dx,G(z.row_number),1),(O(!0),$(xt,null,xe(z.values,(Et,_t)=>(O(),$("td",{key:_t,title:k(Et)},G(k(Et)),9,fx))),128))],2))),128))])])):(O(),$("div",px,"当前工作表没有可预览记录"))],512),x("div",gx,[V(P,{size:"small",disabled:o.value===0||i.value,"aria-label":"上一页工作表记录",onClick:B},{default:tt(()=>[...N[11]||(N[11]=[x("i",{class:"fa fa-angle-left"},null,-1),at(" 上一页 ",-1)])]),_:1},8,["disabled"]),x("span",null,G(w.value),1),V(P,{size:"small",disabled:!g.value.active_sheet.has_more||i.value,"aria-label":"下一页工作表记录",onClick:I},{default:tt(()=>[...N[12]||(N[12]=[at(" 下一页 ",-1),x("i",{class:"fa fa-angle-right"},null,-1)])]),_:1},8,["disabled"])])],64)):ct("",!0)],8,QS)}}}),vx=ri(mx,[["__scopeId","data-v-609c0bbb"]]),ti=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),br=[1/0,1/0,-1/0,-1/0],Wa=new Float32Array(br),xg=[.001,0,0,.001,0,0],pg=1.35,Fs="http://www.w3.org/2000/svg",Zs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Pr={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ul="pdfjs_internal_id_",tu="pdfjs_internal_editor_",pt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},vt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},yx={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ce={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},bf={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ue={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,RICHMEDIA:27},Fl={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Xp={ERRORS:0,WARNINGS:1,INFOS:5},Ki={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},_h={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},bx={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let qp=Xp.WARNINGS;function wx(u){Number.isInteger(u)&&(qp=u)}function Ax(){return qp}function Yp(u){qp>=Xp.INFOS&&console.info(`Info: ${u}`)}function mt(u){qp>=Xp.WARNINGS&&console.warn(`Warning: ${u}`)}function Mt(u){throw new Error(u)}function he(u,t){u||Mt(t)}function Sx(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Uy(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const i=u.match(/\./g);(i==null?void 0:i.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=Ex(u)}catch{}}const s=t?URL.parse(u,t):URL.parse(u);return Sx(s)?s:null}function Hy(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&Uy(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function _g(u){return u.substring(u.lastIndexOf("/")+1)}function ft(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Il=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Eg extends Il{constructor(t,e){super(t,"PasswordException"),this.code=e}}class gg extends Il{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Cg extends Il{constructor(t){super(t,"InvalidPDFException")}}class lp extends Il{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class xx extends Il{constructor(t){super(t,"FormatError")}}class Ma extends Il{constructor(t){super(t,"AbortException")}}function _x(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&Mt("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=u.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Kp(u){typeof u!="string"&&Mt("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}class Wt{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return ft(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return ft(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return ft(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return ft(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return ft(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return ft(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),ft(this,"isCanvasFilterSupported",(t==null?void 0:t.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return ft(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",ft(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return ft(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var wr,wf,kg;class j{static get hexNums(){return ft(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],c=e[5];for(let h=0;h<6;h+=2){const d=t[s+h],f=t[s+h+1];t[s+h]=d*i+f*a+l,t[s+h+1]=d*r+f*o+c}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],c=e[5],h=t[0],d=t[1],f=t[2],g=t[3];let b=i*h+l,w=b,A=i*f+l,y=A,S=o*d+c,_=S,C=o*g+c,E=C;if(r!==0||a!==0){const k=r*h,D=r*f,M=a*d,F=a*g;b+=M,y+=M,A+=F,w+=F,S+=k,E+=k,C+=D,_+=D}s[0]=Math.min(s[0],b,A,w,y),s[1]=Math.min(s[1],S,C,_,E),s[2]=Math.max(s[2],b,A,w,y),s[3]=Math.max(s[3],S,C,_,E)}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 s=t[0],i=t[1],r=t[2],a=t[3],o=s**2+i**2,l=s*r+i*a,c=r**2+a**2,h=(o+c)/2,d=Math.sqrt(h**2-(o*c-l**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||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 s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=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 r>a?null:[s,r,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static bezierBoundingBox(t,e,s,i,r,a,o,l,c){c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l),v(this,wr,kg).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),c),v(this,wr,kg).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),c)}}wr=new WeakSet,wf=function(t,e,s,i,r,a,o,l,c,h){if(c<=0||c>=1)return;const d=1-c,f=c*c,g=f*c,b=d*(d*(d*t+3*c*e)+3*f*s)+g*i,w=d*(d*(d*r+3*c*a)+3*f*o)+g*l;h[0]=Math.min(h[0],b),h[1]=Math.min(h[1],w),h[2]=Math.max(h[2],b),h[3]=Math.max(h[3],w)},kg=function(t,e,s,i,r,a,o,l,c,h,d,f){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&v(this,wr,wf).call(this,t,e,s,i,r,a,o,l,-d/h,f);return}const g=h**2-4*d*c;if(g<0)return;const b=Math.sqrt(g),w=2*c;v(this,wr,wf).call(this,t,e,s,i,r,a,o,l,(-h+b)/w,f),v(this,wr,wf).call(this,t,e,s,i,r,a,o,l,(-h-b)/w,f)},m(j,wr);function Ex(u){return decodeURIComponent(escape(u))}let mg=null,jv=null;function Cx(u){return mg||(mg=/([\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,jv=new Map([["ſt","ſt"]])),u.replaceAll(mg,(t,e,s)=>e?e.normalize("NFKC"):jv.get(s))}function zy(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),_x(u)}function kx(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!u(s)&&!Number.isInteger(s)||!t(i))return!1;const a=r.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}const Yd=()=>[],cv=()=>new Map,Tg=()=>Object.create(null);function ee(u,t,e){return Math.min(Math.max(u,t),e)}class Kd{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let h,d,f,g;switch(i%=360,i<0&&(i+=360),i){case 180:h=-1,d=0,f=0,g=1;break;case 90:h=0,d=1,f=1,g=0;break;case 270:h=0,d=-1,f=-1,g=0;break;case 0:h=1,d=0,f=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,g=-g);let b,w,A,y;h===0?(b=Math.abs(c-t[1])*s+r,w=Math.abs(l-t[0])*s+a,A=(t[3]-t[1])*s,y=(t[2]-t[0])*s):(b=Math.abs(l-t[0])*s+r,w=Math.abs(c-t[1])*s+a,A=(t[2]-t[0])*s,y=(t[3]-t[1])*s),this.transform=[h*s,d*s,f*s,g*s,b-h*s*l-f*s*c,w-d*s*l-g*s*c],this.width=A,this.height=y}get rawDims(){const t=this.viewBox;return ft(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:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new Kd({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return j.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return j.applyInverseTransform(s,this.transform),s}}class eu{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(eu.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const c of r.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class Vy{static setupStorage(t,e,s,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:Object.hasOwn(o.attributes,"selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,c]of Object.entries(a))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&eu.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const h=[[i,-1,a]];for(;h.length>0;){const[g,b,w]=h.at(-1);if(b+1===g.children.length){h.pop();continue}const A=g.children[++h.at(-1)[1]];if(A===null)continue;const{name:y}=A;if(y==="#text"){const _=document.createTextNode(A.value);c.push(_),w.append(_);continue}const S=(d=A==null?void 0:A.attributes)!=null&&d.xmlns?document.createElementNS(A.attributes.xmlns,y):document.createElement(y);if(w.append(S),A.attributes&&this.setAttributes({html:S,element:A,storage:e,intent:r,linkService:s}),((f=A.children)==null?void 0:f.length)>0)h.push([A,-1,S]);else if(A.value){const _=document.createTextNode(A.value);o&&eu.shouldBuildText(y)&&c.push(_),S.append(_)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:r}=t.attributes.style;return new Kd({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}const Va=class Va{};R(Va,"CSS",96),R(Va,"PDF",72),R(Va,"PDF_TO_CSS_UNITS",Va.CSS/Va.PDF);let Ia=Va;async function hv(u,t="text"){if(Kh(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class uv extends Il{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Qp(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function dv(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function Tx(u){return[u]=u.split(/[#?]/,1),_g(u)}function Px(u,t="document.pdf"){if(typeof u!="string")return t;if(Qp(u))return mt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(u);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=_g(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=_g(s.pathname);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=c=>[...c].findLast(h=>r.test(h)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return t}var Mr;class Wv{constructor(){m(this,Mr,new Map);R(this,"times",[])}time(t){n(this,Mr).has(t)&&mt(`Timer is already running for ${t}`),n(this,Mr).set(t,Date.now())}timeEnd(t){n(this,Mr).has(t)||mt(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,Mr).get(t),end:Date.now()}),n(this,Mr).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
`).join("")}}Mr=new WeakMap;function Kh(u,t){const e=t?URL.parse(u,t):URL.parse(u);return/https?:/.test((e==null?void 0:e.protocol)??"")}function Ei(u){u.preventDefault()}function ce(u){u.preventDefault(),u.stopPropagation()}var ru;class cp{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,ru)||p(this,ru,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,ru).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const c=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(a+=h,o+=d):c==="+"&&(a-=h,o-=d),new Date(Date.UTC(s,i,r,a,o,l))}}ru=new WeakMap,m(cp,ru);function Qd(u){if(u.startsWith("#")){const e=u.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(u.startsWith("rgb(")){const[e,s,i]=u.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,i,1]}if(u.startsWith("rgba(")){const e=u.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=u.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Jd(u){const t=Qd(u);return t?t.slice(0,3):(mt(`Not a valid color format: "${u}"`),[0,0,0])}function Mx(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,Jd(s))}t.remove()}function Kt(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform();return[t,e,s,i,r,a]}function Xi(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform().invertSelf();return[t,e,s,i,r,a]}function El(u,t,e=!1,s=!0){if(t instanceof Kd){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=u,o=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;!e||t.rotation%180===0?(a.width=o,a.height=l):(a.width=l,a.height=o)}s&&u.setAttribute("data-main-rotation",t.rotation)}class _n{constructor(){const{pixelRatio:t}=_n;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=_n.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/e);const c=Math.min(a,o,l);return this.sx>c||this.sy>c?(this.sx=c,this.sy=c,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const Pg=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Ix{static get isDarkMode(){var t;return ft(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class Dx{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),ft(this,"commentForegroundColor",Jd(s))}}function Lx(u,t){t=ee(t??1,0,1);const e=255*(1-t);return u.map(s=>Math.round(s*t+e))}function Xv(u,t){const e=u[0]/255,s=u[1]/255,i=u[2]/255,r=Math.max(e,s,i),a=Math.min(e,s,i),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-i)/l+(s<i?6:0))*60;break;case s:t[0]=((i-e)/l+2)*60;break;case i:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function Mg(u,t){const e=u[0],s=u[1],i=u[2],r=(1-Math.abs(2*i-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=i-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=r+o,t[2]=o;break;case 2:t[0]=o,t[1]=r+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=r+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=r+o;break;case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function qv(u){return u<=.03928?u/12.92:((u+.055)/1.055)**2.4}function Yv(u,t,e){Mg(u,e),e.map(qv);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Mg(t,e),e.map(qv);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const Kv=new Map;function Rx(u,t){const e=u[0]+u[1]*256+u[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=Kv.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);Xv(u,a);const o=i.subarray(6,9);Xv(t,o);const l=o[2]<.5,c=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Yv(a,o,r)<c){let h,d;l?(h=a[2],d=1):(h=0,d=a[2]);const f=.005;for(;d-h>f;){const g=a[2]=(h+d)/2;l===Yv(a,o,r)<c?h=g:d=g}a[2]=l?d:h}return Mg(a,r),s=j.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),Kv.set(e,s),s}function Gy({html:u,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof u=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=u.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){const c=a[o];r.append(document.createTextNode(c)),o<l-1&&r.append(document.createElement("br"))}i.append(r)}else Vy.render({xfaHtml:u,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function jy(u){const t=new Path2D;if(!u)return t;for(let e=0,s=u.length;e<s;)switch(u[e++]){case _h.moveTo:t.moveTo(u[e++],u[e++]);break;case _h.lineTo:t.lineTo(u[e++],u[e++]);break;case _h.curveTo:t.bezierCurveTo(u[e++],u[e++],u[e++],u[e++],u[e++],u[e++]);break;case _h.quadraticCurveTo:t.quadraticCurveTo(u[e++],u[e++],u[e++],u[e++]);break;case _h.closePath:t.closePath();break;default:mt(`Unrecognized drawing path operator: ${u[e-1]}`);break}return t}var Ir,Dr,ci,hi,au,Lr,Gl,jl,ou,yp,Wy,Ke,Xy,qy,Ol,Th;const Dn=class Dn{constructor(t){m(this,Ke);m(this,Ir,null);m(this,Dr,null);m(this,ci);m(this,hi,null);m(this,au,null);m(this,Lr,null);m(this,Gl,null);m(this,jl,null);p(this,ci,t),n(Dn,ou)||p(Dn,ou,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=p(this,Ir,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,ci)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Ei,{signal:e}),t.addEventListener("pointerdown",v(Dn,yp,Wy),{signal:e}));const s=p(this,hi,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,ci).toolbarPosition;if(i){const{style:r}=t,a=n(this,ci)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return n(this,Ir)}hide(){var t;n(this,Ir).classList.add("hidden"),(t=n(this,Dr))==null||t.hideDropdown()}show(){var t,e;n(this,Ir).classList.remove("hidden"),(t=n(this,au))==null||t.shown(),(e=n(this,Lr))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,ci),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(Dn,ou)[t]),v(this,Ke,Ol).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,hi).append(s)}async addAltText(t){const e=await t.render();v(this,Ke,Ol).call(this,e),n(this,hi).append(e,n(this,Ke,Th)),p(this,au,t)}addComment(t,e=null){if(n(this,Lr))return;const s=t.renderForToolbar();if(!s)return;v(this,Ke,Ol).call(this,s);const i=p(this,Gl,n(this,Ke,Th));e?(n(this,hi).insertBefore(s,e),n(this,hi).insertBefore(i,e)):n(this,hi).append(s,i),p(this,Lr,t),t.toolbar=this}addColorPicker(t){if(n(this,Dr))return;p(this,Dr,t);const e=t.renderButton();v(this,Ke,Ol).call(this,e),n(this,hi).append(e,n(this,Ke,Th))}async addEditSignatureButton(t){const e=p(this,jl,await t.renderEditButton(n(this,ci)));v(this,Ke,Ol).call(this,e),n(this,hi).append(e,n(this,Ke,Th))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Lr))==null||e.removeToolbarCommentButton(),p(this,Lr,null),(s=n(this,Gl))==null||s.remove(),p(this,Gl,null);break}}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const i=n(this,hi).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,jl)&&(n(this,jl).title=t)}remove(){var t;n(this,Ir).remove(),(t=n(this,Dr))==null||t.destroy(),p(this,Dr,null)}};Ir=new WeakMap,Dr=new WeakMap,ci=new WeakMap,hi=new WeakMap,au=new WeakMap,Lr=new WeakMap,Gl=new WeakMap,jl=new WeakMap,ou=new WeakMap,yp=new WeakSet,Wy=function(t){t.stopPropagation()},Ke=new WeakSet,Xy=function(t){n(this,ci)._focusEventsAllowed=!1,ce(t)},qy=function(t){n(this,ci)._focusEventsAllowed=!0,ce(t)},Ol=function(t){const e=n(this,ci)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",v(this,Ke,Xy).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",v(this,Ke,qy).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ei,{signal:e}),!0)},Th=function(){const t=document.createElement("div");return t.className="divider",t},m(Dn,yp),m(Dn,ou,null);let Ig=Dn;var lu,Xa,Rn,Sr,Yy,Ky,Dg;class Fx{constructor(t){m(this,Sr);m(this,lu,null);m(this,Xa,null);m(this,Rn);p(this,Rn,t)}show(t,e,s){const[i,r]=v(this,Sr,Ky).call(this,e,s),{style:a}=n(this,Xa)||p(this,Xa,v(this,Sr,Yy).call(this));t.append(n(this,Xa)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Xa).remove()}}lu=new WeakMap,Xa=new WeakMap,Rn=new WeakMap,Sr=new WeakSet,Yy=function(){const t=p(this,Xa,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=n(this,Rn)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Ei,{signal:e});const s=p(this,lu,document.createElement("div"));return s.className="buttons",t.append(s),n(this,Rn).hasCommentManager()&&v(this,Sr,Dg).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,Rn).commentSelection("floating_button")}),v(this,Sr,Dg).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,Rn).highlightSelection("floating_button")}),t},Ky=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},Dg=function(t,e,s,i){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=n(this,Rn)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",Ei,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,lu).append(r)};const Ox="068f09d6-5b37-4f77-a97a-f8ff4f253b68",vg=Object.freeze({internal:Ox});function Qy(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}var qa,Ya,Wl,Ka;const Ht=class Ht{static initializeAndAddPointerId(t){(n(Ht,Ya)||p(Ht,Ya,new Set)).add(t)}static setPointer(t,e){n(Ht,qa)||p(Ht,qa,e),n(Ht,Ka)??p(Ht,Ka,t)}static setTimeStamp(t){p(Ht,Wl,t)}static isSamePointerId(t){return n(Ht,qa)===t}static isSamePointerIdOrRemove(t){var e;return n(Ht,qa)===t?!0:((e=n(Ht,Ya))==null||e.delete(t),!1)}static isSamePointerType(t){return n(Ht,Ka)===t}static isInitializedAndDifferentPointerType(t){return n(Ht,Ka)!==null&&!Ht.isSamePointerType(t)}static isSameTimeStamp(t){return n(Ht,Wl)===t}static isUsingMultiplePointers(){var t;return((t=n(Ht,Ya))==null?void 0:t.size)>=1}static clearPointerType(){p(Ht,Ka,null)}static clearPointerIds(){p(Ht,qa,NaN),p(Ht,Ya,null)}static clearTimeStamp(){p(Ht,Wl,NaN)}};qa=new WeakMap,Ya=new WeakMap,Wl=new WeakMap,Ka=new WeakMap,m(Ht,qa,NaN),m(Ht,Ya,null),m(Ht,Wl,NaN),m(Ht,Ka,null);let Ze=Ht;var bp;class Nx{constructor(){m(this,bp,0)}get id(){return`${tu}${Jt(this,bp)._++}`}}bp=new WeakMap;var Xl,cu,ts,ql,Af;const wv=class wv{constructor(){m(this,ql);m(this,Xl,zy());m(this,cu,0);m(this,ts,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Fs}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return ft(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return v(this,ql,Af).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return v(this,ql,Af).call(this,t,t)}async getFromBlob(t,e){const s=await e;return v(this,ql,Af).call(this,t,s)}async getFromId(t){n(this,ts)||p(this,ts,new Map);const e=n(this,ts).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:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,ts)||p(this,ts,new Map);let s=n(this,ts).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,Xl)}_${Jt(this,cu)._++}`,refCounter:1,isSvg:!1},n(this,ts).set(t,s),n(this,ts).set(s.id,s),s}getSvgUrl(t){const e=n(this,ts).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,ts)||p(this,ts,new Map);const e=n(this,ts).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,Xl)}_`)}};Xl=new WeakMap,cu=new WeakMap,ts=new WeakMap,ql=new WeakSet,Af=async function(t,e){n(this,ts)||p(this,ts,new Map);let s=n(this,ts).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,Xl)}_${Jt(this,cu)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await hv(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=wv._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,h)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,c()},a.onload=async()=>{const d=s.svgUrl=a.result;o.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=h});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){mt(i),s=null}return n(this,ts).set(t,s),s&&n(this,ts).set(s.id,s),s};let Lg=wv;var ve,Rr,hu,oe;class Bx{constructor(t=128){m(this,ve,[]);m(this,Rr,!1);m(this,hu);m(this,oe,-1);p(this,hu,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Rr))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,oe)===-1){n(this,ve).length>0&&(n(this,ve).length=0),p(this,oe,0),n(this,ve).push(l);return}if(a&&n(this,ve)[n(this,oe)].type===r){o&&(l.undo=n(this,ve)[n(this,oe)].undo),n(this,ve)[n(this,oe)]=l;return}const c=n(this,oe)+1;c===n(this,hu)?n(this,ve).splice(0,1):(p(this,oe,c),c<n(this,ve).length&&n(this,ve).splice(c)),n(this,ve).push(l)}undo(){if(n(this,oe)===-1)return;p(this,Rr,!0);const{undo:t,post:e}=n(this,ve)[n(this,oe)];t(),e==null||e(),p(this,Rr,!1),p(this,oe,n(this,oe)-1)}redo(){if(n(this,oe)<n(this,ve).length-1){p(this,oe,n(this,oe)+1),p(this,Rr,!0);const{cmd:t,post:e}=n(this,ve)[n(this,oe)];t(),e==null||e(),p(this,Rr,!1)}}hasSomethingToUndo(){return n(this,oe)!==-1}hasSomethingToRedo(){return n(this,oe)<n(this,ve).length-1}cleanType(t){if(n(this,oe)!==-1){for(let e=n(this,oe);e>=0;e--)if(n(this,ve)[e].type!==t){n(this,ve).splice(e+1,n(this,oe)-e),p(this,oe,e);return}n(this,ve).length=0,p(this,oe,-1)}}destroy(){p(this,ve,null)}}ve=new WeakMap,Rr=new WeakMap,hu=new WeakMap,oe=new WeakMap;var bh,Jy,Zy;const Ss=class Ss{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=Wt.platform;for(const[i,r,a={}]of t){const o=i.some(l=>l.startsWith("mac+"));for(const l of i){let c=l;if(o){const f=l.startsWith("mac+");if(e!==f)continue;f&&(c=l.slice(4))}const[h,d]=v(s=Ss,bh,Jy).call(s,c);h!==null&&this.callbacks.getOrInsertComputed(h,Yd).push({callback:r,options:a,modifiers:d})}}}exec(t,e){var h;let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const d=v(h=Ss,bh,Zy).call(h,e.code);if(d===null||d===e.key||(s=this.callbacks.get(d),!s))return}const i=(e.altKey?Ss.ALT:0)|(e.ctrlKey?Ss.CTRL:0)|(e.metaKey?Ss.META:0)|(e.shiftKey?Ss.SHIFT:0),r=s.find(d=>d.modifiers===i);if(!r)return;const{callback:a,options:{bubbles:o=!1,args:l=[],checker:c=null}}=r;c&&!c(t,e)||(a.bind(t,...l,e)(),o||ce(e))}};bh=new WeakSet,Jy=function(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),a=Ss[r];if(a){s|=a;continue}if(e!==null){mt(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&mt(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},Zy=function(t){var s;const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?((s=e[1])==null?void 0:s.toLowerCase())??e[2]:null},m(Ss,bh),R(Ss,"ALT",1),R(Ss,"CTRL",2),R(Ss,"META",4),R(Ss,"SHIFT",8);let Cl=Ss;const wp=class wp{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Mx(t),ft(this,"_colors",t)}convert(t){const e=Jd(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return wp._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?j.makeHexColor(...e):t}};R(wp,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Rg=wp;var Yl,Os,Kl,fe,le,Ql,Jl,cs,Zl,ui,Ie,Fr,Or,Nr,Br,Qi,di,Qa,uu,du,tc,fu,Ji,$r,ec,Ur,Zi,Ap,Fn,sc,pu,Hr,Ja,ic,zr,gu,Se,zt,On,Vr,Gr,mu,nc,vu,jr,tn,Nn,yu,bu,fi,Y,Sf,Fg,tb,eb,sb,Ph,ib,nb,rb,Og,ab,ob,lb,cb,os,Mn,hb,ub,Ng,db,Mh,Bg;const Hl=class Hl{constructor(t,e,s,i,r,a,o,l,c,h,d,f,g,b,w,A){m(this,Y);m(this,Yl,new AbortController);m(this,Os,null);m(this,Kl,null);m(this,fe,new Map);m(this,le,new Map);m(this,Ql,null);m(this,Jl,null);m(this,cs,null);m(this,Zl,null);m(this,ui,new Bx);m(this,Ie,null);m(this,Fr,null);m(this,Or,null);m(this,Nr,0);m(this,Br,new Set);m(this,Qi,null);m(this,di,null);m(this,Qa,new Set);R(this,"_editorUndoBar",null);m(this,uu,!1);m(this,du,!1);m(this,tc,!1);m(this,fu,null);m(this,Ji,null);m(this,$r,null);m(this,ec,null);m(this,Ur,!1);m(this,Zi,null);m(this,Ap,new Nx);m(this,Fn,!1);m(this,sc,!1);m(this,pu,!1);m(this,Hr,null);m(this,Ja,null);m(this,ic,null);m(this,zr,null);m(this,gu,null);m(this,Se,pt.NONE);m(this,zt,new Set);m(this,On,null);m(this,Vr,null);m(this,Gr,null);m(this,mu,null);m(this,nc,null);m(this,vu,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});m(this,jr,[0,0]);m(this,tn,null);m(this,Nn,null);m(this,yu,null);m(this,bu,null);m(this,fi,null);const y=this._signal=n(this,Yl).signal;p(this,Nn,t),p(this,yu,e),p(this,bu,s),p(this,Jl,i),p(this,Ie,r),p(this,Vr,a),p(this,nc,l),this._eventBus=o;const S={signal:y,...vg};o.on("editingaction",this.onEditingAction.bind(this),S),o.on("pagechanging",this.onPageChanging.bind(this),S),o.on("scalechanging",this.onScaleChanging.bind(this),S),o.on("rotationchanging",this.onRotationChanging.bind(this),S),o.on("setpreference",this.onSetPreference.bind(this),S),o.on("switchannotationeditorparams",_=>this.updateParams(_.type,_.value),S),window.addEventListener("pointerdown",()=>{p(this,sc,!0)},{capture:!0,signal:y}),window.addEventListener("pointerup",()=>{p(this,sc,!1)},{capture:!0,signal:y}),window.addEventListener("beforeunload",v(this,Y,tb).bind(this),{capture:!0,signal:y}),v(this,Y,ib).call(this),v(this,Y,cb).call(this),v(this,Y,Og).call(this),p(this,cs,l.annotationStorage),p(this,fu,l.filterFactory),p(this,Gr,c),p(this,ec,h||null),p(this,uu,d),p(this,du,f),p(this,tc,g),p(this,gu,b||null),this.viewParameters={realScale:Ia.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=w||null,this._supportsPinchToZoom=A!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=Hl.prototype,e=a=>n(a,Nn).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return ft(this,"_keyboardManager",new Cl([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,Nn).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,Nn).contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,i,r,a,o,l,c;(t=n(this,fi))==null||t.resolve(),p(this,fi,null),(e=n(this,Yl))==null||e.abort(),p(this,Yl,null),this._signal=null;for(const h of n(this,le).values())h.destroy();n(this,le).clear(),n(this,fe).clear(),n(this,Qa).clear(),(s=n(this,zr))==null||s.clear(),p(this,Os,null),n(this,zt).clear(),n(this,ui).destroy(),(i=n(this,Jl))==null||i.destroy(),(r=n(this,Ie))==null||r.destroy(),(a=n(this,Vr))==null||a.destroy(),(o=n(this,Zi))==null||o.hide(),p(this,Zi,null),(l=n(this,ic))==null||l.destroy(),p(this,ic,null),p(this,Kl,null),n(this,Ji)&&(clearTimeout(n(this,Ji)),p(this,Ji,null)),n(this,tn)&&(clearTimeout(n(this,tn)),p(this,tn,null)),(c=this._editorUndoBar)==null||c.destroy(),p(this,nc,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,gu)}get useNewAltTextFlow(){return n(this,du)}get useNewAltTextWhenAddingImage(){return n(this,tc)}get hcmFilter(){return ft(this,"hcmFilter",n(this,Gr)?n(this,fu).addHCMFilter(n(this,Gr).foreground,n(this,Gr).background):"none")}get direction(){return ft(this,"direction",getComputedStyle(n(this,Nn)).direction)}get _highlightColors(){return ft(this,"_highlightColors",n(this,ec)?new Map(n(this,ec).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return ft(this,"highlightColors",null);const e=new Map,s=!!n(this,Gr);for(const[i,r]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),r);continue}!s&&!a&&e.set(i,r)}return ft(this,"highlightColors",e)}get highlightColorNames(){return ft(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Or,t)}setMainHighlightColorPicker(t){p(this,ic,t)}editAltText(t,e=!1){var s;(s=n(this,Jl))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,Ie)}editComment(t,e,s,i){var r;(r=n(this,Ie))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,le).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=n(this,Ie))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=n(this,Ie))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=n(this,Ie))==null||e.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{var r;(r=this._editorUndoBar)==null||r.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){var i;(i=n(this,Ie))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=n(this,Ie))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=n(this,Ie))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(n(this,le).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,vg),await s}getSignature(t){var e;(e=n(this,Vr))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,Vr)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...vg}),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}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,tc,e);break}}onPageChanging({pageNumber:t}){p(this,Nr,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();n(this,le).delete(t),n(this,Nr)===t&&p(this,Nr,0)}focusMainContainer(){n(this,Nn).focus()}findParent(t,e){for(const s of n(this,le).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){n(this,yu).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Qa).add(t)}removeShouldRescale(t){n(this,Qa).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Ia.PDF_TO_CSS_UNITS;for(const s of n(this,Qa))s.onScaleChanging();(e=n(this,Or))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),h=v(this,Y,Sf).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;s.empty();const f=v(this,Y,Fg).call(this,h),g=n(this,Se)===pt.NONE,b=()=>{const w=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),e&&(w==null||w.editComment())};if(g){this.switchToMode(pt.HIGHLIGHT,b);return}b()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!n(this,cs))return null;const e=`${tu}${t}`,s=n(this,cs).getRawValue(e);return s&&n(this,cs).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,cs)&&!n(this,cs).has(t.id)&&n(this,cs).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,bu);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,n(this,Ur)&&(p(this,Ur,!1),v(this,Y,Ph).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,zt))if(e.div.contains(t)){p(this,Ja,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Ja))return;const[t,e]=n(this,Ja);p(this,Ja,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){v(this,Y,Og).call(this),this.setEditingState(!0)}removeEditListeners(){v(this,Y,ab).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,di))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,di))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,Os))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,zt)){const r=i.serialize(!0);r&&e.push(r)}e.length!==0&&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 r of e.items)for(const a of n(this,di))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){mt(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;r.push(c)}const a=()=>{for(const l of r)v(this,Y,Ng).call(this,l);v(this,Y,Bg).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){mt(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Se)!==pt.NONE&&!this.isEditorHandlingKeyboard&&Hl._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Ur)&&(p(this,Ur,!1),v(this,Y,Ph).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(const i of this.getEditors(t))i.pageIndex=e;const s=n(this,Ql).get(t);s&&(s.pageIndex=e,n(this,le).set(e,s),n(this,Fn)?s.enable():s.disable())}startUpdatePages(){p(this,Ql,new Map(n(this,le))),n(this,le).clear()}endUpdatePages(){p(this,Ql,null)}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==pt.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,n(this,cs).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,r]of n(this,cs))r.pageIndex===s&&r.isClone&&(n(this,cs).remove(i),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(v(this,Y,nb).call(this),v(this,Y,ob).call(this),v(this,Y,os).call(this,{isEditing:n(this,Se)!==pt.NONE,isEmpty:v(this,Y,Mh).call(this),hasSomethingToUndo:n(this,ui).hasSomethingToUndo(),hasSomethingToRedo:n(this,ui).hasSomethingToRedo(),hasSelectedEditor:!1})):(v(this,Y,rb).call(this),v(this,Y,lb).call(this),v(this,Y,os).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,di)){p(this,di,t);for(const e of n(this,di))v(this,Y,Mn).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,Ap).id}get currentLayer(){return n(this,le).get(n(this,Nr))}getLayer(t){return n(this,le).get(t)}get currentPageIndex(){return n(this,Nr)}addLayer(t){n(this,le).set(t.pageIndex,t),n(this,Fn)?t.enable():t.disable()}removeLayer(t){n(this,le).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,a=!1){var o,l,c,h,d,f;if(n(this,Se)!==t&&!(n(this,fi)&&(await n(this,fi).promise,!n(this,fi)))){if(p(this,fi,Promise.withResolvers()),(o=n(this,Or))==null||o.commitOrRemove(),n(this,Se)===pt.POPUP&&((l=n(this,Ie))==null||l.hideSidebar()),(c=n(this,Ie))==null||c.destroyPopup(),p(this,Se,t),t===pt.NONE){this.setEditingState(!1),v(this,Y,ub).call(this);for(const g of n(this,fe).values())g.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),n(this,fi).resolve();return}for(const g of n(this,fe).values())g.addStandaloneCommentButton();t===pt.SIGNATURE&&await((d=n(this,Vr))==null?void 0:d.loadSignatures()),s&&Ze.clearPointerType(),this.setEditingState(!0),await v(this,Y,hb).call(this),this.unselectAll();for(const g of n(this,le).values())g.updateMode(t);if(t===pt.POPUP){n(this,Kl)||p(this,Kl,await n(this,nc).getAnnotationsByType(new Set(n(this,di).map(w=>w._editorType))));const g=new Set,b=[];for(const w of n(this,fe).values()){const{annotationElementId:A,hasComment:y,deleted:S}=w;A&&g.add(A),y&&!S&&b.push(w.getData())}for(const w of n(this,Kl)){const{id:A,popupRef:y,contentsObj:S}=w;y&&(S!=null&&S.str)&&!g.has(A)&&!n(this,Br).has(A)&&b.push(w)}(f=n(this,Ie))==null||f.showSidebar(b)}if(!e){i&&this.addNewEditorFromKeyboard(),n(this,fi).resolve();return}for(const g of n(this,fe).values())g.uid===e?(this.setSelected(g),a?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();n(this,fi).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,Se)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,di)){switch(t){case vt.CREATE:this.currentLayer.addNewEditor(e);return;case vt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,mu)||p(this,mu,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,zt))s.updateParams(t,e);else for(const s of n(this,di))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,fe).values())a.editorType===t&&a.show(e);(((r=n(this,mu))==null?void 0:r.get(vt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&v(this,Y,Mn).call(this,[[vt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,pu)!==t){p(this,pu,t);for(const e of n(this,le).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,fe).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,fe).get(t)}addEditor(t){n(this,fe).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,Ji)&&clearTimeout(n(this,Ji)),p(this,Ji,setTimeout(()=>{this.focusMainContainer(),p(this,Ji,null)},0))),n(this,fe).delete(t.id),t.annotationElementId&&((e=n(this,zr))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Br).has(t.annotationElementId))&&((s=n(this,cs))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Br).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Br).has(t)}removeDeletedAnnotationElement(t){n(this,Br).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,Os)!==t&&(p(this,Os,t),t&&v(this,Y,Mn).call(this,t.propertiesToUpdate))}updateUI(t){n(this,Y,db)===t&&v(this,Y,Mn).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){v(this,Y,Mn).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,zt).has(t)){n(this,zt).delete(t),t.unselect(),v(this,Y,os).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,zt).add(t),t.select(),v(this,Y,Mn).call(this,t.propertiesToUpdate),v(this,Y,os).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=n(this,Or))==null||e.commitOrRemove();for(const i of n(this,zt))i!==t&&i.unselect();(s=n(this,Ie))==null||s.destroyPopup(),n(this,zt).clear(),n(this,zt).add(t),t.select(),v(this,Y,Mn).call(this,t.propertiesToUpdate),v(this,Y,os).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,zt).values().next().value}unselect(t){t.unselect(),n(this,zt).delete(t),v(this,Y,os).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,zt).size!==0}get isEnterHandled(){return n(this,zt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,ui).undo(),v(this,Y,os).call(this,{hasSomethingToUndo:n(this,ui).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:v(this,Y,Mh).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,ui).redo(),v(this,Y,os).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,ui).hasSomethingToRedo(),isEmpty:v(this,Y,Mh).call(this)})}addCommands(t){n(this,ui).add(t),v(this,Y,os).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:v(this,Y,Mh).call(this)})}cleanUndoStack(t){n(this,ui).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...n(this,zt)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)v(this,Y,Ng).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,Os))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,Os)||this.hasSelection}selectAll(){for(const t of n(this,zt))t.commit();v(this,Y,Bg).call(this,n(this,fe).values())}unselectAll(){var t,e;if(!(n(this,Os)&&(n(this,Os).commitOrRemove(),n(this,Se)!==pt.NONE))&&!((t=n(this,Or))!=null&&t.commitOrRemove())&&((e=n(this,Ie))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of n(this,zt))s.unselect();n(this,zt).clear(),v(this,Y,os).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,jr)[0]+=t,n(this,jr)[1]+=e;const[i,r]=n(this,jr),a=[...n(this,zt)],o=1e3;n(this,tn)&&clearTimeout(n(this,tn)),p(this,tn,setTimeout(()=>{p(this,tn,null),n(this,jr)[0]=n(this,jr)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,fe).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,fe).has(l.id)&&(l.translateInPage(-i,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,Qi,new Map);for(const t of n(this,zt))n(this,Qi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,Qi))return!1;this.disableUserSelect(!1);const t=n(this,Qi);p(this,Qi,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,fe).has(i.id)){const l=n(this,le).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,Qi))for(const s of n(this,Qi).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){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(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||n(this,zt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,Os)===t}getActive(){return n(this,Os)}getMode(){return n(this,Se)}isEditingMode(){return n(this,Se)!==pt.NONE}get imageManager(){return ft(this,"imageManager",new Lg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,h=e.rangeCount;c<h;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(c,h,d,f)=>({x:(h-i)/a,y:1-(c+d-s)/r,width:f/a,height:d/r});break;case"180":o=(c,h,d,f)=>({x:1-(c+d-s)/r,y:1-(h+f-i)/a,width:d/r,height:f/a});break;case"270":o=(c,h,d,f)=>({x:1-(h+f-i)/a,y:(c-s)/r,width:f/a,height:d/r});break;default:o=(c,h,d,f)=>({x:(c-s)/r,y:(h-i)/a,width:d/r,height:f/a});break}const l=[];for(let c=0,h=e.rangeCount;c<h;c++){const d=e.getRangeAt(c);if(!d.collapsed)for(const{x:f,y:g,width:b,height:w}of d.getClientRects())b===0||w===0||l.push(o(f,g,b,w))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,Zl)||p(this,Zl,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,Zl))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,Zl))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,cs).getRawValue(e);s&&(n(this,Se)===pt.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,zr))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,zr).delete(t))}addMissingCanvas(t,e){(n(this,zr)||p(this,zr,new Map)).set(t,e)}};Yl=new WeakMap,Os=new WeakMap,Kl=new WeakMap,fe=new WeakMap,le=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,cs=new WeakMap,Zl=new WeakMap,ui=new WeakMap,Ie=new WeakMap,Fr=new WeakMap,Or=new WeakMap,Nr=new WeakMap,Br=new WeakMap,Qi=new WeakMap,di=new WeakMap,Qa=new WeakMap,uu=new WeakMap,du=new WeakMap,tc=new WeakMap,fu=new WeakMap,Ji=new WeakMap,$r=new WeakMap,ec=new WeakMap,Ur=new WeakMap,Zi=new WeakMap,Ap=new WeakMap,Fn=new WeakMap,sc=new WeakMap,pu=new WeakMap,Hr=new WeakMap,Ja=new WeakMap,ic=new WeakMap,zr=new WeakMap,gu=new WeakMap,Se=new WeakMap,zt=new WeakMap,On=new WeakMap,Vr=new WeakMap,Gr=new WeakMap,mu=new WeakMap,nc=new WeakMap,vu=new WeakMap,jr=new WeakMap,tn=new WeakMap,Nn=new WeakMap,yu=new WeakMap,bu=new WeakMap,fi=new WeakMap,Y=new WeakSet,Sf=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Fg=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,le).values())if(s.hasTextLayer(t))return s;return null},tb=function(t){var e;this.commitOrRemove(),(e=this.currentLayer)==null||e.endDrawingSession(!1)},eb=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=v(this,Y,Sf).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,Zi)||p(this,Zi,new Fx(this)),n(this,Zi).show(s,i,this.direction==="ltr"))},sb=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,On)&&((r=n(this,Zi))==null||r.hide(),p(this,On,null),v(this,Y,os).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,On))return;const i=v(this,Y,Sf).call(this,t).closest(".textLayer");if(!i){n(this,On)&&((a=n(this,Zi))==null||a.hide(),p(this,On,null),v(this,Y,os).call(this,{hasSelectedText:!1}));return}if((o=n(this,Zi))==null||o.hide(),p(this,On,e),v(this,Y,os).call(this,{hasSelectedText:!0}),!(n(this,Se)!==pt.HIGHLIGHT&&n(this,Se)!==pt.NONE)&&(n(this,Se)===pt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Ur,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,Se)===pt.HIGHLIGHT?v(this,Y,Fg).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,sc)){const c=new AbortController,h=this.combinedSignal(c),d=f=>{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&v(this,Y,Ph).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("blur",d,{signal:h})}else l==null||l.toggleDrawing(!0),v(this,Y,Ph).call(this,"main_toolbar")}},Ph=function(t=""){n(this,Se)===pt.HIGHLIGHT?this.highlightSelection(t):n(this,uu)&&v(this,Y,eb).call(this)},ib=function(){document.addEventListener("selectionchange",v(this,Y,sb).bind(this),{signal:this._signal})},nb=function(){if(n(this,$r))return;p(this,$r,new AbortController);const t=this.combinedSignal(n(this,$r));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},rb=function(){var t;(t=n(this,$r))==null||t.abort(),p(this,$r,null)},Og=function(){if(n(this,Hr))return;p(this,Hr,new AbortController);const t=this.combinedSignal(n(this,Hr));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},ab=function(){var t;(t=n(this,Hr))==null||t.abort(),p(this,Hr,null)},ob=function(){if(n(this,Fr))return;p(this,Fr,new AbortController);const t=this.combinedSignal(n(this,Fr));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})},lb=function(){var t;(t=n(this,Fr))==null||t.abort(),p(this,Fr,null)},cb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},os=function(t){Object.entries(t).some(([s,i])=>n(this,vu)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,vu),t)}),n(this,Se)===pt.HIGHLIGHT&&t.hasSelectedEditor===!1&&v(this,Y,Mn).call(this,[[vt.HIGHLIGHT_FREE,!0]]))},Mn=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},hb=async function(){if(!n(this,Fn)){p(this,Fn,!0);const t=[];for(const e of n(this,le).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,fe).values())e.enable()}},ub=function(){if(this.unselectAll(),n(this,Fn)){p(this,Fn,!1);for(const t of n(this,le).values())t.disable();for(const t of n(this,fe).values())t.disable()}},Ng=function(t){const e=n(this,le).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},db=function(){let t=null;for(t of n(this,zt));return t},Mh=function(){if(n(this,fe).size===0)return!0;if(n(this,fe).size===1)for(const t of n(this,fe).values())return t.isEmpty();return!1},Bg=function(t){for(const e of n(this,zt))e.unselect();n(this,zt).clear();for(const e of t)e.isEmpty()||(n(this,zt).add(e),e.select());v(this,Y,os).call(this,{hasSelectedEditor:this.hasSelection})},R(Hl,"TRANSLATE_SMALL",1),R(Hl,"TRANSLATE_BIG",10);let kl=Hl;var De,en,Pi,rc,sn,Ns,ac,nn,_s,Bn,Za,rn,Wr,Vi,Ih,xf;const ls=class ls{constructor(t){m(this,Vi);m(this,De,null);m(this,en,!1);m(this,Pi,null);m(this,rc,null);m(this,sn,null);m(this,Ns,null);m(this,ac,!1);m(this,nn,null);m(this,_s,null);m(this,Bn,null);m(this,Za,null);m(this,rn,!1);p(this,_s,t),p(this,rn,t._uiManager.useNewAltTextFlow),n(ls,Wr)||p(ls,Wr,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){ls._l10n??(ls._l10n=t)}async render(){const t=p(this,Pi,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,rc,document.createElement("span"));t.append(e),n(this,rn)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(ls,Wr).missing),e.setAttribute("data-l10n-id",n(ls,Wr)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,_s)._uiManager._signal;t.addEventListener("contextmenu",Ei,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,_s)._uiManager.editAltText(n(this,_s)),n(this,rn)&&n(this,_s)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,Vi,Ih)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,ac,!0),i(r))},{signal:s}),await v(this,Vi,xf).call(this),t}finish(){n(this,Pi)&&(n(this,Pi).focus({focusVisible:n(this,ac)}),p(this,ac,!1))}isEmpty(){return n(this,rn)?n(this,De)===null:!n(this,De)&&!n(this,en)}hasData(){return n(this,rn)?n(this,De)!==null||!!n(this,Bn):this.isEmpty()}get guessedText(){return n(this,Bn)}async setGuessedText(t){n(this,De)===null&&(p(this,Bn,t),p(this,Za,await ls._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),v(this,Vi,xf).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,rn)||n(this,De)){(e=n(this,nn))==null||e.remove(),p(this,nn,null);return}if(!n(this,nn)){const s=p(this,nn,document.createElement("div"));s.className="noAltTextBadge",n(this,_s).div.append(s)}n(this,nn).classList.toggle("hidden",!t)}serialize(t){let e=n(this,De);return!t&&n(this,Bn)===e&&(e=n(this,Za)),{altText:e,decorative:n(this,en),guessedText:n(this,Bn),textWithDisclaimer:n(this,Za)}}get data(){return{altText:n(this,De),decorative:n(this,en)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,Bn,s),p(this,Za,i)),!(n(this,De)===t&&n(this,en)===e)&&(r||(p(this,De,t),p(this,en,e)),v(this,Vi,xf).call(this))}toggle(t=!1){n(this,Pi)&&(!t&&n(this,Ns)&&(clearTimeout(n(this,Ns)),p(this,Ns,null)),n(this,Pi).disabled=!t)}shown(){n(this,_s)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,Vi,Ih)}})}destroy(){var t,e;(t=n(this,Pi))==null||t.remove(),p(this,Pi,null),p(this,rc,null),p(this,sn,null),(e=n(this,nn))==null||e.remove(),p(this,nn,null)}};De=new WeakMap,en=new WeakMap,Pi=new WeakMap,rc=new WeakMap,sn=new WeakMap,Ns=new WeakMap,ac=new WeakMap,nn=new WeakMap,_s=new WeakMap,Bn=new WeakMap,Za=new WeakMap,rn=new WeakMap,Wr=new WeakMap,Vi=new WeakSet,Ih=function(){return n(this,De)&&"added"||n(this,De)===null&&this.guessedText&&"review"||"missing"},xf=async function(){var i,r,a;const t=n(this,Pi);if(!t)return;if(n(this,rn)){if(t.classList.toggle("done",!!n(this,De)),t.setAttribute("data-l10n-id",n(ls,Wr)[n(this,Vi,Ih)]),(i=n(this,rc))==null||i.setAttribute("data-l10n-id",n(ls,Wr)[`${n(this,Vi,Ih)}-label`]),!n(this,De)){(r=n(this,sn))==null||r.remove();return}}else{if(!n(this,De)&&!n(this,en)){t.classList.remove("done"),(a=n(this,sn))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,sn);if(!e){p(this,sn,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,_s).id}`;const o=100,l=n(this,_s)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,Ns)),p(this,Ns,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Ns,setTimeout(()=>{p(this,Ns,null),n(this,sn).classList.add("show"),n(this,_s)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;n(this,Ns)&&(clearTimeout(n(this,Ns)),p(this,Ns,null)),(c=n(this,sn))==null||c.classList.remove("show")},{signal:l})}n(this,en)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,De)),e.parentNode||t.append(e);const s=n(this,_s).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},m(ls,Wr,null),R(ls,"_l10n",null);let hp=ls;var Ue,pi,to,Yt,wu,Xr,gi,qr,Yr,eo,Au,$g;class lf{constructor(t){m(this,Au);m(this,Ue,null);m(this,pi,null);m(this,to,!1);m(this,Yt,null);m(this,wu,null);m(this,Xr,null);m(this,gi,null);m(this,qr,null);m(this,Yr,!1);m(this,eo,null);p(this,Yt,t)}renderForToolbar(){const t=p(this,pi,document.createElement("button"));return t.className="comment",v(this,Au,$g).call(this,t,!1)}renderForStandalone(){const t=p(this,Ue,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,Yt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,Yt)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=n(this,Yt).commentButtonColor;i&&(s.backgroundColor=i)}return v(this,Au,$g).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,Ue)??n(this,pi))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,Ue))return;const t=n(this,Yt).commentButtonColor;t&&(n(this,Ue).style.backgroundColor=t),n(this,Yt)._uiManager.updatePopupColor(n(this,Yt))}get commentButtonWidth(){var t;return(((t=n(this,Ue))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,Yt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,eo))return n(this,eo);if(!n(this,Ue))return null;const{x:t,y:e,height:s}=n(this,Ue).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Yt).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){p(this,eo,t)}hasDefaultPopupPosition(){return n(this,eo)===null}removeStandaloneCommentButton(){var t;(t=n(this,Ue))==null||t.remove(),p(this,Ue,null)}removeToolbarCommentButton(){var t;(t=n(this,pi))==null||t.remove(),p(this,pi,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,Ue)&&(n(this,Ue).classList.toggle("selected",t),n(this,Ue).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,Yt).commentButtonPosition;const{width:h,height:d,x:f,y:g}=n(this,Yt);s=f+s*h,i=g+i*d}const r=n(this,Yt).parent.boundingClientRect,{x:a,y:o,width:l,height:c}=r;n(this,Yt)._uiManager.editComment(n(this,Yt),a+s*l,o+i*c,{...t,parentDimensions:r})}finish(){n(this,pi)&&(n(this,pi).focus({focusVisible:n(this,to)}),p(this,to,!1))}isDeleted(){return n(this,Yr)||n(this,gi)===""}isEmpty(){return n(this,gi)===null}hasBeenEdited(){return this.isDeleted()||n(this,gi)!==n(this,wu)}serialize(){return this.data}get data(){return{text:n(this,gi),richText:n(this,Xr),date:n(this,qr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,gi)&&p(this,Xr,null),t===null){p(this,gi,""),p(this,Yr,!0);return}p(this,gi,t),p(this,qr,new Date),p(this,Yr,!1)}restoreData({text:t,richText:e,date:s}){p(this,gi,t),p(this,Xr,e),p(this,qr,s),p(this,Yr,!1)}setInitialText(t,e=null){p(this,wu,t),this.data=t,p(this,qr,null),p(this,Xr,e)}shown(){}destroy(){var t,e;(t=n(this,pi))==null||t.remove(),p(this,pi,null),(e=n(this,Ue))==null||e.remove(),p(this,Ue,null),p(this,gi,""),p(this,Xr,null),p(this,qr,null),p(this,Yt,null),p(this,to,!1),p(this,Yr,!1)}}Ue=new WeakMap,pi=new WeakMap,to=new WeakMap,Yt=new WeakMap,wu=new WeakMap,Xr=new WeakMap,gi=new WeakMap,qr=new WeakMap,Yr=new WeakMap,eo=new WeakMap,Au=new WeakSet,$g=function(t,e){if(!n(this,Yt)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[n(this,Yt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=n(this,Yt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Ei,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,Yt)._focusEventsAllowed=!1,ce(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,Yt)._focusEventsAllowed=!0,ce(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,pi)?this.edit():n(this,Yt).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,to,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,Yt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,Yt).toggleComment(!1,!1)},{signal:s}),t};var oc,so,Su,xu,_u,Eu,Cu,$n,io,Un,no,Hn,Da,fb,pb,gb;const Av=class Av{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){m(this,Da);m(this,oc);m(this,so,!1);m(this,Su,null);m(this,xu);m(this,_u);m(this,Eu);m(this,Cu);m(this,$n,null);m(this,io);m(this,Un,null);m(this,no);m(this,Hn,null);p(this,oc,t),p(this,Su,s),p(this,xu,e),p(this,_u,i),p(this,Eu,r),p(this,Cu,a),p(this,no,new AbortController),p(this,io,AbortSignal.any([o,n(this,no).signal])),t.addEventListener("touchstart",v(this,Da,fb).bind(this),{passive:!1,signal:n(this,io)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/_n.pixelRatio}destroy(){var t,e;(t=n(this,no))==null||t.abort(),p(this,no,null),(e=n(this,$n))==null||e.abort(),p(this,$n,null)}};oc=new WeakMap,so=new WeakMap,Su=new WeakMap,xu=new WeakMap,_u=new WeakMap,Eu=new WeakMap,Cu=new WeakMap,$n=new WeakMap,io=new WeakMap,Un=new WeakMap,no=new WeakMap,Hn=new WeakMap,Da=new WeakSet,fb=function(t){var i,r,a;if((i=n(this,xu))!=null&&i.call(this))return;if(t.touches.length===1){if(n(this,$n))return;const o=p(this,$n,new AbortController),l=AbortSignal.any([n(this,io),o.signal]),c=n(this,oc),h={capture:!0,signal:l,passive:!1},d=f=>{var g;f.pointerType==="touch"&&((g=n(this,$n))==null||g.abort(),p(this,$n,null))};c.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(ce(f),d(f))},h),c.addEventListener("pointerup",d,h),c.addEventListener("pointercancel",d,h);return}if(!n(this,Hn)){p(this,Hn,new AbortController);const o=AbortSignal.any([n(this,io),n(this,Hn).signal]),l=n(this,oc),c={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",v(this,Da,pb).bind(this),c);const h=v(this,Da,gb).bind(this);l.addEventListener("touchend",h,c),l.addEventListener("touchcancel",h,c),c.capture=!0,l.addEventListener("pointerdown",ce,c),l.addEventListener("pointermove",ce,c),l.addEventListener("pointercancel",ce,c),l.addEventListener("pointerup",ce,c),(r=n(this,_u))==null||r.call(this)}if(ce(t),t.touches.length!==2||(a=n(this,Su))!=null&&a.call(this)){p(this,Un,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,Un,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},pb=function(t){var C;if(!n(this,Un)||t.touches.length!==2)return;ce(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:a,screenY:o}=s,l=n(this,Un),{touch0X:c,touch0Y:h,touch1X:d,touch1Y:f}=l,g=d-c,b=f-h,w=a-i,A=o-r,y=Math.hypot(w,A)||1,S=Math.hypot(g,b)||1;if(!n(this,so)&&Math.abs(S-y)<=Av.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,so)){p(this,so,!0);return}const _=[(i+a)/2,(r+o)/2];(C=n(this,Eu))==null||C.call(this,_,S,y)},gb=function(t){var e;t.touches.length>=2||(n(this,Hn)&&(n(this,Hn).abort(),p(this,Hn,null),(e=n(this,Cu))==null||e.call(this)),n(this,Un)&&(ce(t),p(this,Un,null),p(this,so,!1)))};let up=Av;var ro,Mi,ie,Nt,zn,lc,Kr,ku,He,ao,Vn,mi,Qr,Tu,oo,Bs,Pu,lo,Gn,an,cc,hc,vi,co,Mu,Sp,ht,Ug,Iu,Hg,_f,mb,vb,zg,Ef,Vg,yb,bb,wb,Gg,Ab,jg,Sb,xb,_b,Wg,Dh;const dt=class dt{constructor(t){m(this,ht);m(this,ro,null);m(this,Mi,null);m(this,ie,null);m(this,Nt,null);m(this,zn,null);m(this,lc,!1);m(this,Kr,null);m(this,ku,"");m(this,He,null);m(this,ao,null);m(this,Vn,null);m(this,mi,null);m(this,Qr,null);m(this,Tu,"");m(this,oo,!1);m(this,Bs,null);m(this,Pu,!1);m(this,lo,!1);m(this,Gn,!1);m(this,an,null);m(this,cc,0);m(this,hc,0);m(this,vi,null);m(this,co,null);R(this,"isSelected",!1);R(this,"_isCopy",!1);R(this,"_editToolbar",null);R(this,"_initialOptions",Object.create(null));R(this,"_initialData",null);R(this,"_isVisible",!0);R(this,"_uiManager",null);R(this,"_focusEventsAllowed",!0);m(this,Mu,!1);m(this,Sp,dt._zIndex++);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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=dt.prototype._resizeWithKeyboard,e=kl.TRANSLATE_SMALL,s=kl.TRANSLATE_BIG;return ft(this,"_resizerKeyboardManager",new Cl([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],dt.prototype._stopResizingWithKeyboard]]))}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return ft(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new $x({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(dt._l10n??(dt._l10n=t),dt._l10nAlert??(dt._l10nAlert=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"})),dt._l10nResizer??(dt._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"})),dt._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);dt._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Mt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,Mu)}set _isDraggable(t){var e;p(this,Mu,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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=n(this,Sp)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(v(this,ht,Dh).call(this),(e=n(this,mi))==null||e.remove(),p(this,mi,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,oo)?p(this,oo,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){v(this,ht,Ug).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,Bs)||p(this,Bs,[this.x,this.y,this.width,this.height]),v(this,ht,Ug).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,Bs)||p(this,Bs,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,c]=this.getBaseTranslation();a+=l,o+=c;const{style:h}=s;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,Bs)&&(n(this,Bs)[0]!==this.x||n(this,Bs)[1]!==this.y)}get _hasBeenResized(){return!!n(this,Bs)&&(n(this,Bs)[2]!==this.width||n(this,Bs)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=dt,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=ee(r,0,s-o),a=ee(a,0,i-l);break;case 90:r=ee(r,0,s-l),a=ee(a,o,i);break;case 180:r=ee(r,o,s),a=ee(a,l,i);break;case 270:r=ee(r,l,s),a=ee(a,0,i-o);break}this.x=r/=s,this.y=a/=i;const[c,h]=this.getBaseTranslation();r+=c,a+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return v(s=dt,Iu,Hg).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return v(s=dt,Iu,Hg).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=n(this,ie))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,lo))return this._editToolbar;this._editToolbar=new Ig(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=n(this,ie))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return n(this,ie)||(hp.initialize(dt._l10n),p(this,ie,new hp(this)),n(this,ro)&&(n(this,ie).data=n(this,ro),p(this,ro,null))),n(this,ie)}get altTextData(){var t;return(t=n(this,ie))==null?void 0:t.data}set altTextData(t){n(this,ie)&&(n(this,ie).data=t)}get guessedAltText(){var t;return(t=n(this,ie))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,ie))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,ie))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,ie)&&!n(this,ie).isEmpty()}hasAltTextData(){var t;return((t=n(this,ie))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,Nt))==null||t.focusButton()}addCommentButton(){return this.canAddComment?n(this,Nt)||p(this,Nt,new lf(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,zn)){this._uiManager.isEditingMode()&&n(this,zn).classList.remove("hidden");return}this.hasComment&&(p(this,zn,n(this,Nt).renderForStandalone()),this.div.append(n(this,zn)))}}removeStandaloneCommentButton(){n(this,Nt).removeStandaloneCommentButton(),p(this,zn,null)}hideStandaloneCommentButton(){var t;(t=n(this,zn))==null||t.classList.add("hidden")}get comment(){if(!n(this,Nt))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,Nt);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,Nt)||p(this,Nt,new lf(this)),typeof t=="object"&&t!==null?n(this,Nt).restoreData(t):n(this,Nt).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(n(this,Nt)||p(this,Nt,new lf(this)),n(this,Nt).setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var t;return(t=n(this,Nt))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,Nt))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,Nt)&&!n(this,Nt).isEmpty()&&!n(this,Nt).isDeleted()}async editComment(t){n(this,Nt)||p(this,Nt,new lf(this)),n(this,Nt).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,Nt).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,c=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,c,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){n(this,Nt).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;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=n(this,lc)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),v(this,ht,jg).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),Qy(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,co)||p(this,co,new up({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:v(this,ht,yb).bind(this),onPinching:v(this,ht,bb).bind(this),onPinchEnd:v(this,ht,wb).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,oo,!0),this._isDraggable){v(this,ht,Ab).call(this,t);return}v(this,ht,Gg).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,an)&&clearTimeout(n(this,an)),p(this,an,setTimeout(()=>{var t;p(this,an,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=t/i,h=e/i,d=this.x*r,f=this.y*a,g=this.width*r,b=this.height*a;switch(s){case 0:return[d+c+o,a-f-h-b+l,d+c+g+o,a-f-h+l];case 90:return[d+h+o,a-f+c+l,d+h+b+o,a-f+c+g+l];case 180:return[d-c-g+o,a-f+h+l,d-c+o,a-f+h+b+l];case 270:return[d-h-b+o,a-f-c-g+l,d-h+o,a-f-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,a]=t,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[r,e-i,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&dt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,Nt))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:c,modificationDate:h}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:c,modificationDate:s||h,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,lo,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,lo,!1),!0):!1}isInEditMode(){return n(this,lo)}shouldGetKeyboardEvents(){return n(this,Gn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&i>0&&t<r&&s>0}rebuild(){v(this,ht,jg).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,p(i,ro,t.accessibilityData),i._isCopy=t.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,c,h]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=c/r,i.height=h/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,s;if((t=n(this,Qr))==null||t.abort(),p(this,Qr,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,an)&&(clearTimeout(n(this,an)),p(this,an,null)),v(this,ht,Dh).call(this),this.removeEditToolbar(),n(this,vi)){for(const i of n(this,vi).values())clearTimeout(i);p(this,vi,null)}this.parent=null,(e=n(this,co))==null||e.destroy(),p(this,co,null),(s=n(this,mi))==null||s.remove(),p(this,mi,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(v(this,ht,mb).call(this),n(this,He).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,r,a]=this.getPDFRect();return[dt._round(s+(r-s)*t),dt._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,Nt).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,Nt).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,Nt).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,Nt).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=n(this,Nt))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,Vn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,He).children;if(!n(this,Mi)){p(this,Mi,Array.from(e));const a=v(this,ht,Sb).bind(this),o=v(this,ht,xb).bind(this),l=this._uiManager._signal;for(const c of n(this,Mi)){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",v(this,ht,_b).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",dt._l10nResizer[h])}}const s=n(this,Mi)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,Mi).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,He).append(n(this,He).firstElementChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,He).firstElementChild.before(n(this,He).lastElementChild);let a=0;for(const o of e){const c=n(this,Mi)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",dt._l10nResizer[c])}}v(this,ht,Wg).call(this,0),p(this,Gn,!0),n(this,He).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,Gn)&&v(this,ht,Vg).call(this,n(this,Tu),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){v(this,ht,Dh).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,ie))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,i,r;this.isSelected&&(this.isSelected=!1,(t=n(this,He))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=n(this,ie))==null||r.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,Pu)}set isEditing(t){p(this,Pu,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}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){n(this,vi)||p(this,vi,new Map);const{action:s}=t;let i=n(this,vi).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,vi).delete(s),n(this,vi).size===0&&p(this,vi,null)},dt._telemetryTimeout),n(this,vi).set(s,i);return}t.type||(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),p(this,lc,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,lc,!0)}updateFakeAnnotationElement(t){if(!n(this,mi)&&!this.deleted){p(this,mi,t.addFakeAnnotation(this));return}if(this.deleted){n(this,mi).remove(),p(this,mi,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,mi).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};ro=new WeakMap,Mi=new WeakMap,ie=new WeakMap,Nt=new WeakMap,zn=new WeakMap,lc=new WeakMap,Kr=new WeakMap,ku=new WeakMap,He=new WeakMap,ao=new WeakMap,Vn=new WeakMap,mi=new WeakMap,Qr=new WeakMap,Tu=new WeakMap,oo=new WeakMap,Bs=new WeakMap,Pu=new WeakMap,lo=new WeakMap,Gn=new WeakMap,an=new WeakMap,cc=new WeakMap,hc=new WeakMap,vi=new WeakMap,co=new WeakMap,Mu=new WeakMap,Sp=new WeakMap,ht=new WeakSet,Ug=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Iu=new WeakSet,Hg=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},_f=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},mb=function(){if(n(this,He))return;p(this,He,document.createElement("div")),n(this,He).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 s of t){const i=document.createElement("div");n(this,He).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",v(this,ht,vb).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ei,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,He))},vb=function(t,e){var h;e.preventDefault();const{isMac:s}=Wt.platform;if(e.button!==0||e.ctrlKey&&s)return;(h=n(this,ie))==null||h.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,ao,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",v(this,ht,Vg).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",ce,{passive:!1,signal:a}),window.addEventListener("contextmenu",Ei,{signal:a}),p(this,Vn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const c=()=>{var d;r.abort(),this.parent.togglePointerEvents(!0),(d=n(this,ie))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,v(this,ht,Ef).call(this)};window.addEventListener("pointerup",c,{signal:a}),window.addEventListener("blur",c,{signal:a})},zg=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Ef=function(){if(!n(this,Vn))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,Vn);p(this,Vn,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:v(this,ht,zg).bind(this,r,a,o,l),undo:v(this,ht,zg).bind(this,t,e,s,i),mustExec:!0})},Vg=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,c=dt.MIN_SIZE/s,h=dt.MIN_SIZE/i,d=v(this,ht,_f).call(this,this.rotation),f=(P,K)=>[d[0]*P+d[2]*K,d[1]*P+d[3]*K],g=v(this,ht,_f).call(this,360-this.rotation),b=(P,K)=>[g[0]*P+g[2]*K,g[1]*P+g[3]*K];let w,A,y=!1,S=!1;switch(t){case"topLeft":y=!0,w=(P,K)=>[0,0],A=(P,K)=>[P,K];break;case"topMiddle":w=(P,K)=>[P/2,0],A=(P,K)=>[P/2,K];break;case"topRight":y=!0,w=(P,K)=>[P,0],A=(P,K)=>[0,K];break;case"middleRight":S=!0,w=(P,K)=>[P,K/2],A=(P,K)=>[0,K/2];break;case"bottomRight":y=!0,w=(P,K)=>[P,K],A=(P,K)=>[0,0];break;case"bottomMiddle":w=(P,K)=>[P/2,K],A=(P,K)=>[P/2,0];break;case"bottomLeft":y=!0,w=(P,K)=>[0,K],A=(P,K)=>[P,0];break;case"middleLeft":S=!0,w=(P,K)=>[0,K/2],A=(P,K)=>[P,K/2];break}const _=w(o,l),C=A(o,l);let E=f(...C);const k=dt._round(r+E[0]),D=dt._round(a+E[1]);let M=1,F=1,B,I;if(e.fromKeyboard)({deltaX:B,deltaY:I}=e);else{const{screenX:P,screenY:K}=e,[z,Et]=n(this,ao);[B,I]=this.screenToPageTranslation(P-z,K-Et),n(this,ao)[0]=P,n(this,ao)[1]=K}if([B,I]=b(B/s,I/i),y){const P=Math.hypot(o,l);M=F=Math.max(Math.min(Math.hypot(C[0]-_[0]-B,C[1]-_[1]-I)/P,1/o,1/l),c/o,h/l)}else S?M=ee(Math.abs(C[0]-_[0]-B),c,1)/o:F=ee(Math.abs(C[1]-_[1]-I),h,1)/l;const T=dt._round(o*M),N=dt._round(l*F);E=f(...A(T,N));const H=k-E[0],Z=D-E[1];n(this,Bs)||p(this,Bs,[this.x,this.y,this.width,this.height]),this.width=T,this.height=N,this.x=H,this.y=Z,this.setDims(),this.fixAndSetPosition(),this._onResizing()},yb=function(){var t;p(this,Vn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,ie))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},bb=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=v(this,ht,_f).call(this,this.rotation),o=(k,D)=>[a[0]*k+a[2]*D,a[1]*k+a[3]*D],[l,c]=this.parentDimensions,h=this.x,d=this.y,f=this.width,g=this.height,b=dt.MIN_SIZE/l,w=dt.MIN_SIZE/c;r=Math.max(Math.min(r,1/f,1/g),b/f,w/g);const A=dt._round(f*r),y=dt._round(g*r);if(A===f&&y===g)return;n(this,Bs)||p(this,Bs,[h,d,f,g]);const S=o(f/2,g/2),_=dt._round(h+S[0]),C=dt._round(d+S[1]),E=o(A/2,y/2);this.x=_-E[0],this.y=C-E[1],this.width=A,this.height=y,this.setDims(),this.fixAndSetPosition(),this._onResizing()},wb=function(){var t;(t=n(this,ie))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),v(this,ht,Ef).call(this)},Gg=function(t){const{isMac:e}=Wt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Ab=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=c=>{i.abort(),p(this,Kr,null),p(this,oo,!1),this._uiManager.endDragSession()||v(this,ht,Gg).call(this,c),s&&this._onStopDragging()};e&&(p(this,cc,t.clientX),p(this,hc,t.clientY),p(this,Kr,t.pointerId),p(this,ku,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:h,clientY:d,pointerId:f}=c;if(f!==n(this,Kr)){ce(c);return}const[g,b]=this.screenToPageTranslation(h-n(this,cc),d-n(this,hc));p(this,cc,h),p(this,hc,d),this._uiManager.dragSelectedEditors(g,b)},a),window.addEventListener("touchmove",ce,a),window.addEventListener("pointerdown",c=>{c.pointerType===n(this,ku)&&(n(this,co)||c.isPrimary)&&o(c),ce(c)},a));const l=c=>{if(!n(this,Kr)||n(this,Kr)===c.pointerId){o(c);return}ce(c)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},jg=function(){if(n(this,Qr)||!this.div)return;p(this,Qr,new AbortController);const t=this._uiManager.combinedSignal(n(this,Qr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Sb=function(t){dt._resizerKeyboardManager.exec(this,t)},xb=function(t){var e;n(this,Gn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,He)&&v(this,ht,Dh).call(this)},_b=function(t){p(this,Tu,n(this,Gn)?t:"")},Wg=function(t){if(n(this,Mi))for(const e of n(this,Mi))e.tabIndex=t},Dh=function(){p(this,Gn,!1),v(this,ht,Wg).call(this,-1),v(this,ht,Ef).call(this)},m(dt,Iu),R(dt,"_l10n",null),R(dt,"_l10nAlert",null),R(dt,"_l10nResizer",null),R(dt,"_borderLineWidth",-1),R(dt,"_colorManager",new Rg),R(dt,"_zIndex",1),R(dt,"_telemetryTimeout",1e3);let Rt=dt;class $x extends Rt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Qv=3285377520,oi=4294901760,qi=65535;class Xg{constructor(t){this.h1=t?t&4294967295:Qv,this.h2=t?t&4294967295:Qv}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let w=0,A=t.length;w<A;w++){const y=t.charCodeAt(w);y<=255?e[s++]=y:(e[s++]=y>>>8,e[s++]=y&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,c=this.h1,h=this.h2;const d=3432918353,f=461845907,g=d&qi,b=f&qi;for(let w=0;w<i;w++)w&1?(o=a[w],o=o*d&oi|o*g&qi,o=o<<15|o>>>17,o=o*f&oi|o*b&qi,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[w],l=l*d&oi|l*g&qi,l=l<<15|l>>>17,l=l*f&oi|l*b&qi,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*d&oi|o*g&qi,o=o<<15|o>>>17,o=o*f&oi|o*b&qi,i&1?c^=o:h^=o}this.h1=c,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&oi|t*36045&qi,e=e*4283543511&oi|((e<<16|t>>>16)*2950163797&oi)>>>16,t^=e>>>1,t=t*444984403&oi|t*60499&qi,e=e*3301882366&oi|((e<<16|t>>>16)*3120437893&oi)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const su=Object.freeze({map:null,hash:"",transfer:void 0});var ho,uo,jn,ze,xp,Eb;class fv{constructor(){m(this,xp);m(this,ho,!1);m(this,uo,null);m(this,jn,null);m(this,ze,new Map);R(this,"onSetModified",null);R(this,"onResetModified",null);R(this,"onAnnotationEditor",null)}getValue(t,e){const s=n(this,ze).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,ze).get(t)}remove(t){var s;const e=n(this,ze).get(t);e!==void 0&&(e instanceof Rt&&n(this,jn).delete(e.annotationElementId),n(this,ze).delete(t),n(this,ze).size===0&&this.resetModified(),!n(this,ze).values().some(i=>i instanceof Rt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=n(this,ze).get(t);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(i=!0,s[a]=o);else i=!0,n(this,ze).set(t,e);i&&v(this,xp,Eb).call(this),e instanceof Rt&&((n(this,jn)||p(this,jn,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return n(this,ze).has(t)}get size(){return n(this,ze).size}resetModified(){var t;n(this,ho)&&(p(this,ho,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new Cb(this)}get serializable(){if(n(this,ze).size===0)return su;const t=new Map,e=new Xg,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,ze)){const l=o instanceof Rt?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:su}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,ze).values()){if(!(r instanceof Rt)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;e.getOrInsertComputed(o,()=>Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[c,h]of Object.entries(a)){if(c==="type")continue;const d=l.getOrInsertComputed(c,cv);d.set(h,(d.get(h)??0)+1)}}if((i>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){p(this,uo,null)}updateEditor(t,e){var i;const s=(i=n(this,jn))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,jn))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,uo))return n(this,uo);const t=[];if(n(this,jn))for(const s of n(this,jn).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Xg;s.update(t.join(",")),e=s.hexdigest()}return p(this,uo,{ids:new Set(t),hash:e})}[Symbol.iterator](){return n(this,ze).entries()}}ho=new WeakMap,uo=new WeakMap,jn=new WeakMap,ze=new WeakMap,xp=new WeakSet,Eb=function(){var t;n(this,ho)||(p(this,ho,!0),(t=this.onSetModified)==null||t.call(this))};var Du;class Cb extends fv{constructor(e){super();m(this,Du,su);const{serializable:s}=e;if(s===su)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);p(this,Du,{map:o,hash:r,transfer:[]})}get print(){Mt("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Du)}get modifiedIds(){return ft(this,"modifiedIds",{ids:new Set,hash:""})}}Du=new WeakMap;const Rl="__forcedDependency",{floor:Jv,ceil:Zv}=Math;function ty(u,t,e,s,i,r){u[t*4+0]=Math.min(u[t*4+0],e),u[t*4+1]=Math.min(u[t*4+1],s),u[t*4+2]=Math.max(u[t*4+2],i),u[t*4+3]=Math.max(u[t*4+3],r)}function Ux(u,t,e,s,i){let r;u?(u<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=u,i[2]*=u,t<0&&(r=i[1],i[1]=i[3],i[3]=r),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const qg=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var uc,Jr;class Hx{constructor(t,e){m(this,uc);m(this,Jr);p(this,uc,t),p(this,Jr,e)}get length(){return n(this,uc).length}isEmpty(t){return n(this,uc)[t]===qg}minX(t){return n(this,Jr)[t*4+0]/256}minY(t){return n(this,Jr)[t*4+1]/256}maxX(t){return(n(this,Jr)[t*4+2]+1)/256}maxY(t){return(n(this,Jr)[t*4+3]+1)/256}}uc=new WeakMap,Jr=new WeakMap;const ey=(u,t)=>u==null?void 0:u.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var Wn,Lt,te,fo,po,go,es,Lu,Yg;class zx{constructor(t,e){m(this,Lu);m(this,Wn,[[1,0,0,1,0,0]]);m(this,Lt,[-1/0,-1/0,1/0,1/0]);m(this,te,new Float64Array(br));R(this,"_pendingBBoxIdx",-1);m(this,fo);m(this,po);m(this,go);m(this,es);R(this,"_savesStack",[]);R(this,"_markedContentStack",[]);p(this,fo,t.width),p(this,po,t.height),v(this,Lu,Yg).call(this,e)}growOperationsCount(t){t>=n(this,es).length&&v(this,Lu,Yg).call(this,t,n(this,es))}get clipBox(){return n(this,Lt)}save(t){return p(this,Lt,{__proto__:n(this,Lt)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(n(this,Lt));if(s===null)return this;p(this,Lt,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),n(this,es)[t]=n(this,es)[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,es)[t]=n(this,es)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,es)[t]=n(this,es)[s]),this}pushBaseTransform(t){return n(this,Wn).push(j.multiplyByDOMMatrix(n(this,Wn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,Wn).length>1&&n(this,Wn).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,n(this,te).set(br,0)),this}recordClipBox(t,e,s,i,r,a){const o=j.multiplyByDOMMatrix(n(this,Wn).at(-1),e.getTransform()),l=br.slice();j.axialAlignedBoundingBox([s,r,i,a],o,l);const c=j.intersect(n(this,Lt),l);return c?(n(this,Lt)[0]=c[0],n(this,Lt)[1]=c[1],n(this,Lt)[2]=c[2],n(this,Lt)[3]=c[3]):(n(this,Lt)[0]=n(this,Lt)[1]=1/0,n(this,Lt)[2]=n(this,Lt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,Lt);if(o[0]===1/0)return this;const l=j.multiplyByDOMMatrix(n(this,Wn).at(-1),e.getTransform());if(o[0]===-1/0)return j.axialAlignedBoundingBox([s,r,i,a],l,n(this,te)),this;const c=br.slice();return j.axialAlignedBoundingBox([s,r,i,a],l,c),n(this,te)[0]=ee(c[0],o[0],n(this,te)[0]),n(this,te)[1]=ee(c[1],o[1],n(this,te)[1]),n(this,te)[2]=ee(c[2],n(this,te)[2],o[2]),n(this,te)[3]=ee(c[3],n(this,te)[3],o[3]),this}recordFullPageBBox(t){return n(this,te)[0]=Math.max(0,n(this,Lt)[0]),n(this,te)[1]=Math.max(0,n(this,Lt)[1]),n(this,te)[2]=Math.min(n(this,fo),n(this,Lt)[2]),n(this,te)[3]=Math.min(n(this,po),n(this,Lt)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=Jv(n(this,te)[0]*256/n(this,fo)),r=Jv(n(this,te)[1]*256/n(this,po)),a=Zv(n(this,te)[2]*256/n(this,fo)),o=Zv(n(this,te)[3]*256/n(this,po));if(ty(n(this,go),t,i,r,a,o),s)for(const l of s)for(const c of l)c!==t&&ty(n(this,go),c,i,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,n(this,Lt)[0]=Math.max(n(this,Lt)[0],n(this,te)[0]),n(this,Lt)[1]=Math.max(n(this,Lt)[1],n(this,te)[1]),n(this,Lt)[2]=Math.min(n(this,Lt)[2],n(this,te)[2]),n(this,Lt)[3]=Math.min(n(this,Lt)[3],n(this,te)[3])),this}take(){return new Hx(n(this,es),n(this,go))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}Wn=new WeakMap,Lt=new WeakMap,te=new WeakMap,fo=new WeakMap,po=new WeakMap,go=new WeakMap,es=new WeakMap,Lu=new WeakSet,Yg=function(t,e){const s=new ArrayBuffer(t*4);p(this,go,new Uint8ClampedArray(s)),p(this,es,new Uint32Array(s)),e&&e.length>0?(n(this,es).set(e),n(this,es).fill(qg,e.length)):n(this,es).fill(qg)};var Es,Cs,mo,Ii,dc,Zr,ta,Vt;class Vx{constructor(t,e=!1){m(this,Es,{__proto__:null});m(this,Cs,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Rl]:[]});m(this,mo,new Map);m(this,Ii,new Set);m(this,dc,new Map);m(this,Zr);m(this,ta);m(this,Vt);p(this,Vt,t),e&&(p(this,Zr,new Map),p(this,ta,(s,i)=>{ey(n(this,Zr),i).dependencies.add(s)}))}get clipBox(){return n(this,Vt).clipBox}growOperationsCount(t){n(this,Vt).growOperationsCount(t)}save(t){return p(this,Es,{__proto__:n(this,Es)}),p(this,Cs,{__proto__:n(this,Cs),transform:{__proto__:n(this,Cs).transform},moveText:{__proto__:n(this,Cs).moveText},sameLineText:{__proto__:n(this,Cs).sameLineText},[Rl]:{__proto__:n(this,Cs)[Rl]}}),n(this,Vt).save(t),this}restore(t){n(this,Vt).restore(t,n(this,ta));const e=Object.getPrototypeOf(n(this,Es));return e===null?this:(p(this,Es,e),p(this,Cs,Object.getPrototypeOf(n(this,Cs))),this)}recordOpenMarker(t){return n(this,Vt).recordOpenMarker(t,n(this,ta)),this}getOpenMarker(){return n(this,Vt).getOpenMarker()}recordCloseMarker(t){return n(this,Vt).recordCloseMarker(t,n(this,ta)),this}beginMarkedContent(t){return n(this,Vt).beginMarkedContent(t),this}endMarkedContent(t){return n(this,Vt).endMarkedContent(t,n(this,ta)),this}pushBaseTransform(t){return n(this,Vt).pushBaseTransform(t),this}popBaseTransform(){return n(this,Vt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Es)[t]=e,this}recordIncrementalData(t,e){return n(this,Cs)[t].push(e),this}resetIncrementalData(t,e){return n(this,Cs)[t].length=0,this}recordNamedData(t,e){return n(this,mo).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,Es)[t]=n(this,mo).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Rl,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,Es)&&this.recordFutureForcedDependency(e,n(this,Es)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,Ii))this.recordFutureForcedDependency(Rl,t);return this}resetBBox(t){return n(this,Vt).resetBBox(t),this}recordClipBox(t,e,s,i,r,a){return n(this,Vt).recordClipBox(t,e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Vt).recordBBox(t,e,s,i,r,a),this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){const l=s.bbox;let c,h;if(l&&(c=l[2]!==l[0]&&l[3]!==l[1]&&n(this,dc).get(s),c!==!1&&(h=[0,0,0,0],j.axialAlignedBoundingBox(l,s.fontMatrix,h),(i!==1||r!==0||a!==0)&&Ux(i,-i,r,a,h),c)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!o)return this.recordFullPageBBox(t);const d=o();return l&&h&&c===void 0&&(c=h[0]<=r-d.actualBoundingBoxLeft&&h[2]>=r+d.actualBoundingBoxRight&&h[1]<=a-d.actualBoundingBoxAscent&&h[3]>=a+d.actualBoundingBoxDescent,n(this,dc).set(s,c),c)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,Vt).recordFullPageBBox(t),this}getSimpleIndex(t){return n(this,Es)[t]}recordDependencies(t,e){const s=n(this,Ii),i=n(this,Es),r=n(this,Cs);for(const a of e)a in n(this,Es)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return n(this,mo).has(e)&&n(this,Ii).add(n(this,mo).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Rl]),n(this,Zr)){const i=ey(n(this,Zr),t),{dependencies:r}=i;n(this,Ii).forEach(r.add,r),n(this,Vt)._savesStack.forEach(r.add,r),n(this,Vt)._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===n(this,Vt)._pendingBBoxIdx;return n(this,Vt).recordOperation(t,e,[n(this,Ii),n(this,Vt)._savesStack,n(this,Vt)._markedContentStack]),s&&n(this,Ii).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,Ii));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===n(this,Vt)._pendingBBoxIdx;return n(this,Vt).bboxToClipBoxDropOperation(t),s&&n(this,Ii).clear(),this}take(){return n(this,dc).clear(),n(this,Vt).take()}takeDebugMetadata(){return n(this,Zr)}}Es=new WeakMap,Cs=new WeakMap,mo=new WeakMap,Ii=new WeakMap,dc=new WeakMap,Zr=new WeakMap,ta=new WeakMap,Vt=new WeakMap;var Gt,pe,Di,fc,pc;const Sv=class Sv{constructor(t,e,s){m(this,Gt);m(this,pe);m(this,Di);m(this,fc,0);m(this,pc,0);if(t instanceof Sv&&n(t,Di)===!!s)return t;p(this,Gt,t),p(this,pe,e),p(this,Di,!!s)}get clipBox(){return n(this,Gt).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return Jt(this,pc)._++,n(this,Gt).save(n(this,pe)),this}restore(t){return n(this,pc)>0&&(n(this,Gt).restore(n(this,pe)),Jt(this,pc)._--),this}recordOpenMarker(t){return Jt(this,fc)._++,this}getOpenMarker(){return n(this,fc)>0?n(this,pe):n(this,Gt).getOpenMarker()}recordCloseMarker(t){return Jt(this,fc)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,Gt).pushBaseTransform(t),this}popBaseTransform(){return n(this,Gt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Gt).recordSimpleData(t,n(this,pe)),this}recordIncrementalData(t,e){return n(this,Gt).recordIncrementalData(t,n(this,pe)),this}resetIncrementalData(t,e){return n(this,Gt).resetIncrementalData(t,n(this,pe)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,Gt).recordSimpleDataFromNamed(t,e,n(this,pe)),this}recordFutureForcedDependency(t,e){return n(this,Gt).recordFutureForcedDependency(t,n(this,pe)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,Gt).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,Gt).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Di)||n(this,Gt).resetBBox(n(this,pe)),this}recordClipBox(t,e,s,i,r,a){return n(this,Di)||n(this,Gt).recordClipBox(n(this,pe),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Di)||n(this,Gt).recordBBox(n(this,pe),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Di)||n(this,Gt).recordCharacterBBox(n(this,pe),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Di)||n(this,Gt).recordFullPageBBox(n(this,pe)),this}getSimpleIndex(t){return n(this,Gt).getSimpleIndex(t)}recordDependencies(t,e){return n(this,Gt).recordDependencies(n(this,pe),e),this}recordNamedDependency(t,e){return n(this,Gt).recordNamedDependency(n(this,pe),e),this}recordOperation(t){return n(this,Gt).recordOperation(n(this,pe),!0),this}recordShowTextOperation(t){return n(this,Gt).recordShowTextOperation(n(this,pe),!0),this}bboxToClipBoxDropOperation(t){return n(this,Di)||n(this,Gt).bboxToClipBoxDropOperation(n(this,pe),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};Gt=new WeakMap,pe=new WeakMap,Di=new WeakMap,fc=new WeakMap,pc=new WeakMap;let iu=Sv;const li={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};var vo,yo,bo,wo,Ao,Ru;const Jh=class Jh{constructor(t){m(this,vo);m(this,yo);m(this,bo,4);m(this,wo,0);m(this,Ao,new(n(Jh,Ru))(n(this,bo)*6));p(this,vo,t.width),p(this,yo,t.height)}record(t,e,s,i){if(n(this,wo)===n(this,bo)){p(this,bo,n(this,bo)*2);const o=new(n(Jh,Ru))(n(this,bo)*6);o.set(n(this,Ao)),p(this,Ao,o)}const r=Kt(t);let a;if(i[0]!==1/0){const o=br.slice();j.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=j.intersect(i,o);if(!l)return;const[c,h,d,f]=l;if(c!==o[0]||h!==o[1]||d!==o[2]||f!==o[3]){const g=Math.atan2(r[1],r[0]),b=Math.abs(Math.sin(g)),w=Math.abs(Math.cos(g));if(b<1e-6||w<1e-6||Math.abs(b-w)<1e-6)a=[c,h,c,f,d,h];else{const A=d-c,y=f-h,S=b*b,_=w*w,C=w*b,E=_-S,k=(y*_-A*C)/E,D=(y*C-A*S)/E;a=[c+D,h,c,h+k,d,f-k]}}}a||(a=[0,-s,0,0,e,-s],j.applyTransform(a,r,0),j.applyTransform(a,r,2),j.applyTransform(a,r,4)),a[0]/=n(this,vo),a[1]/=n(this,yo),a[2]/=n(this,vo),a[3]/=n(this,yo),a[4]/=n(this,vo),a[5]/=n(this,yo),n(this,Ao).set(a,n(this,wo)*6),Jt(this,wo)._++}take(){return n(this,Ao).subarray(0,n(this,wo)*6)}};vo=new WeakMap,yo=new WeakMap,bo=new WeakMap,wo=new WeakMap,Ao=new WeakMap,Ru=new WeakMap,m(Jh,Ru,Wt.isFloat16ArraySupported?Float16Array:Float32Array);let Kg=Jh;var gc,Li,_p,kb;class Gx{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){m(this,_p);m(this,gc,new Set);m(this,Li,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){const e=v(this,_p,kb).call(this);e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),n(this,gc).clear(),n(this,Li)){const{adoptedStyleSheets:t}=this._document;t!=null&&t.includes(n(this,Li))&&(this._document.adoptedStyleSheets=t.filter(e=>e!==n(this,Li))),p(this,Li,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,gc).has(t.loadedName))){if(he(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,gc).add(i),s==null||s(t)}catch{mt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}Mt("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw mt(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return ft(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return ft(this,"isSyncFontLoadingSupported",ti||Wt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(he(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return ft(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(E,k){return E.charCodeAt(k)<<24|E.charCodeAt(k+1)<<16|E.charCodeAt(k+2)<<8|E.charCodeAt(k+3)&255}function i(E){return String.fromCharCode(E>>24&255,E>>16&255,E>>8&255,E&255)}function r(E,k,D,M){const F=E.substring(0,k),B=E.substring(k+D);return F+M+B}let a,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const c=l.getContext("2d");let h=0;function d(E,k){if(++h>30){mt("Load test font never loaded."),k();return}if(c.font="30px "+E,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){k();return}setTimeout(d.bind(null,E,k))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=r(g,976,f.length,f);const w=16,A=1482184792;let y=s(g,w);for(a=0,o=f.length-3;a<o;a+=4)y=y-A+s(f,a)|0;a<f.length&&(y=y-A+s(f+"XXX",a)|0),g=r(g,w,4,i(y));const S=`url(data:font/opentype;base64,${btoa(g)});`,_=`@font-face {font-family:"${f}";src:${S}}`;this.insertRule(_);const C=this._document.createElement("div");C.style.visibility="hidden",C.style.width=C.style.height="10px",C.style.position="absolute",C.style.top=C.style.left="0px";for(const E of[t.loadedName,f]){const k=this._document.createElement("span");k.textContent="Hi",k.style.fontFamily=E,C.append(k)}this._document.body.append(C),d(f,()=>{C.remove(),e.complete()})}}gc=new WeakMap,Li=new WeakMap,_p=new WeakSet,kb=function(){var e;if(n(this,Li))return n(this,Li);const t=((e=this._document.defaultView)==null?void 0:e.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:s}=this._document;if(s){const i=new t;return s.push(i),p(this,Li,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),p(this,Li,this.styleElement.sheet)};var jt;class jx{constructor(t,e=null,s,i){R(this,"compiledGlyphs",Object.create(null));m(this,jt);p(this,jt,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{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}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){mt(`getPathGenerator - ignoring character: "${a}".`)}const r=jy(i==null?void 0:i.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,jt).black}get bold(){return n(this,jt).bold}get disableFontFace(){return n(this,jt).disableFontFace}set disableFontFace(t){ft(this,"disableFontFace",!!t)}get fontExtraProperties(){return n(this,jt).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,jt).isInvalidPDFjsFont}get isType3Font(){return n(this,jt).isType3Font}get italic(){return n(this,jt).italic}get missingFile(){return n(this,jt).missingFile}get remeasure(){return n(this,jt).remeasure}get vertical(){return n(this,jt).vertical}get ascent(){return n(this,jt).ascent}get defaultWidth(){return n(this,jt).defaultWidth}get descent(){return n(this,jt).descent}get bbox(){return n(this,jt).bbox}get fontMatrix(){return n(this,jt).fontMatrix}get fallbackName(){return n(this,jt).fallbackName}get loadedName(){return n(this,jt).loadedName}get mimetype(){return n(this,jt).mimetype}get name(){return n(this,jt).name}get data(){return n(this,jt).data}clearData(){n(this,jt).clearData()}get cssFontInfo(){return n(this,jt).cssFontInfo}get systemFontInfo(){return n(this,jt).systemFontInfo}get defaultVMetrics(){return n(this,jt).defaultVMetrics}}jt=new WeakMap;class Tb{}R(Tb,"strings",["fontFamily","fontWeight","italicAngle"]);class Pb{}R(Pb,"strings",["css","loadedName","baseFontName","src"]);const Je=class Je{};R(Je,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),R(Je,"numbers",["ascent","defaultWidth","descent"]),R(Je,"strings",["fallbackName","loadedName","mimetype","name"]),R(Je,"OFFSET_NUMBERS",Math.ceil(Je.bools.length*2/8)),R(Je,"OFFSET_BBOX",Je.OFFSET_NUMBERS+Je.numbers.length*8),R(Je,"OFFSET_FONT_MATRIX",Je.OFFSET_BBOX+1+8),R(Je,"OFFSET_DEFAULT_VMETRICS",Je.OFFSET_FONT_MATRIX+1+48),R(Je,"OFFSET_STRINGS",Je.OFFSET_DEFAULT_VMETRICS+1+6);let Ls=Je;class gs{}R(gs,"KIND",0),R(gs,"HAS_BBOX",1),R(gs,"HAS_BACKGROUND",2),R(gs,"SHADING_TYPE",3),R(gs,"N_COORD",4),R(gs,"N_COLOR",8),R(gs,"N_STOP",12),R(gs,"N_FIGURES",16);var Fu,Ep,mc,vc,Cf;class Wx{constructor(t){m(this,vc);m(this,Fu);m(this,Ep,new TextDecoder);m(this,mc);p(this,Fu,t),p(this,mc,new DataView(t))}get fontFamily(){return v(this,vc,Cf).call(this,0)}get fontWeight(){return v(this,vc,Cf).call(this,1)}get italicAngle(){return v(this,vc,Cf).call(this,2)}}Fu=new WeakMap,Ep=new WeakMap,mc=new WeakMap,vc=new WeakSet,Cf=function(t){he(t<Tb.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=n(this,mc).getUint32(e)+4;const s=n(this,mc).getUint32(e);return n(this,Ep).decode(new Uint8Array(n(this,Fu),e+4,s))};var So,yc,on,xo,Lh;class Xx{constructor(t){m(this,xo);m(this,So);m(this,yc,new TextDecoder);m(this,on);p(this,So,t),p(this,on,new DataView(t))}get guessFallback(){return n(this,on).getUint8(0)!==0}get css(){return v(this,xo,Lh).call(this,0)}get loadedName(){return v(this,xo,Lh).call(this,1)}get baseFontName(){return v(this,xo,Lh).call(this,2)}get src(){return v(this,xo,Lh).call(this,3)}get style(){let t=1;t+=4+n(this,on).getUint32(t);const e=n(this,on).getUint32(t),s=n(this,yc).decode(new Uint8Array(n(this,So),t+4,e));t+=4+e;const i=n(this,on).getUint32(t),r=n(this,yc).decode(new Uint8Array(n(this,So),t+4,i));return{style:s,weight:r}}}So=new WeakMap,yc=new WeakMap,on=new WeakMap,xo=new WeakSet,Lh=function(t){he(t<Pb.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=n(this,on).getUint32(e)+4;const s=n(this,on).getUint32(e);return n(this,yc).decode(new Uint8Array(n(this,So),e+4,s))};var Ri,Cp,ye,$t,ki,kf,Tf,Rh,Qg;class qx{constructor({buffer:t,extra:e}){m(this,$t);m(this,Ri);m(this,Cp,new TextDecoder);m(this,ye);p(this,Ri,t),p(this,ye,new DataView(t)),e&&Object.assign(this,e)}get black(){return v(this,$t,ki).call(this,0)}get bold(){return v(this,$t,ki).call(this,1)}get disableFontFace(){return v(this,$t,ki).call(this,2)}get fontExtraProperties(){return v(this,$t,ki).call(this,3)}get isInvalidPDFjsFont(){return v(this,$t,ki).call(this,4)}get isType3Font(){return v(this,$t,ki).call(this,5)}get italic(){return v(this,$t,ki).call(this,6)}get missingFile(){return v(this,$t,ki).call(this,7)}get remeasure(){return v(this,$t,ki).call(this,8)}get vertical(){return v(this,$t,ki).call(this,9)}get ascent(){return v(this,$t,kf).call(this,0)}get defaultWidth(){return v(this,$t,kf).call(this,1)}get descent(){return v(this,$t,kf).call(this,2)}get bbox(){return v(this,$t,Tf).call(this,Ls.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return v(this,$t,Tf).call(this,Ls.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return v(this,$t,Tf).call(this,Ls.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return v(this,$t,Rh).call(this,0)}get loadedName(){return v(this,$t,Rh).call(this,1)}get mimetype(){return v(this,$t,Rh).call(this,2)}get name(){return v(this,$t,Rh).call(this,3)}get data(){const{offset:t,length:e}=v(this,$t,Qg).call(this);return e===0?void 0:new Uint8Array(n(this,Ri),t+4,e)}clearData(){const{offset:t,length:e}=v(this,$t,Qg).call(this);e!==0&&(n(this,ye).setUint32(t,0),p(this,Ri,new Uint8Array(n(this,Ri),0,t+4).slice().buffer),p(this,ye,new DataView(n(this,Ri))))}get cssFontInfo(){let t=Ls.OFFSET_STRINGS;const e=n(this,ye).getUint32(t);t+=4+e;const s=n(this,ye).getUint32(t);t+=4+s;const i=n(this,ye).getUint32(t);if(i===0)return null;const r=new Uint8Array(i);return r.set(new Uint8Array(n(this,Ri),t+4,i)),new Wx(r.buffer)}get systemFontInfo(){let t=Ls.OFFSET_STRINGS;const e=n(this,ye).getUint32(t);t+=4+e;const s=n(this,ye).getUint32(t);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(n(this,Ri),t+4,s)),new Xx(i.buffer)}}Ri=new WeakMap,Cp=new WeakMap,ye=new WeakMap,$t=new WeakSet,ki=function(t){he(t<Ls.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=n(this,ye).getUint8(e)>>s&3;return i===0?void 0:i===2},kf=function(t){return he(t<Ls.numbers.length,"Invalid number index"),n(this,ye).getFloat64(Ls.OFFSET_NUMBERS+t*8)},Tf=function(t,e,s,i){const r=n(this,ye).getUint8(t);if(r===0)return;he(r===e,"Invalid array length."),t+=1;const a=new Array(r);for(let o=0;o<r;o++)a[o]=n(this,ye)[s](t,!0),t+=i;return a},Rh=function(t){he(t<Ls.strings.length,"Invalid string index");let e=Ls.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=n(this,ye).getUint32(e)+4;const s=n(this,ye).getUint32(e);return n(this,Cp).decode(new Uint8Array(n(this,Ri),e+4,s))},Qg=function(){let t=Ls.OFFSET_STRINGS;const e=n(this,ye).getUint32(t);t+=4+e;const s=n(this,ye).getUint32(t);t+=4+s;const i=n(this,ye).getUint32(t);t+=4+i;const r=n(this,ye).getUint32(t);return{offset:t,length:r}};class Yx{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[gs.KIND],s=!!this.data[gs.HAS_BBOX],i=!!this.data[gs.HAS_BACKGROUND],r=t.getUint32(gs.N_COORD,!0),a=t.getUint32(gs.N_COLOR,!0),o=t.getUint32(gs.N_STOP,!0);let l=20;const c=new Float32Array(this.buffer,l,r*2);l+=r*8;const h=new Uint8Array(this.buffer,l,a*4);l+=a*4;const d=[];for(let b=0;b<o;++b){const w=t.getFloat32(l,!0);l+=4;const A=t.getUint32(l,!0);l+=4,d.push([w,`#${A.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let b=0;b<4;++b)f.push(t.getFloat32(l,!0)),l+=4}let g=null;if(i&&(g=new Uint8Array(this.buffer,l,3),l+=3),e===1)return["RadialAxial","axial",f,d,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",f,d,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(e===3){const b=this.data[gs.SHADING_TYPE];let w=null;if(c.length>0){w=br.slice();for(let A=0,y=c.length;A<y;A+=2)j.pointBoundingBox(c[A],c[A+1],w)}return["Mesh",b,c,h,r,w,f,g]}throw new Error(`Unsupported pattern kind: ${e}`)}}var bc;class Kx{constructor(t){m(this,bc);p(this,bc,t)}get path(){return Wt.isFloat16ArraySupported?new Float16Array(n(this,bc)):new Float32Array(n(this,bc))}}bc=new WeakMap;function Qx(u){if(u instanceof URL)return u;if(typeof u=="string"){if(ti){if(/^[a-z][a-z0-9\-+.]+:/i.test(u))return new URL(u);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(u))}const t=URL.parse(u,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Jx(u){if(ti&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return Kp(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u==null?void 0:u.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function cf(u){if(typeof u!="string")return null;if(u.endsWith("/"))return u;throw new Error(`Invalid factory url: "${u}" must include trailing slash.`)}const Jg=u=>typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0,Zx=u=>typeof u=="object"&&typeof(u==null?void 0:u.name)=="string",t_=kx.bind(null,Jg,Zx);var Xn,kp;class e_{constructor(){m(this,Xn,new Map);m(this,kp,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,kp).then(()=>{for(const[i]of n(this,Xn))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){mt("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,Xn).set(e,i)}removeEventListener(t,e){const s=n(this,Xn).get(e);s==null||s(),n(this,Xn).delete(e)}terminate(){for(const[,t]of n(this,Xn))t==null||t();n(this,Xn).clear()}}Xn=new WeakMap,kp=new WeakMap;const hf={DATA:1,ERROR:2},Ae={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function sy(){}function As(u){if(u instanceof Ma||u instanceof Cg||u instanceof Eg||u instanceof lp||u instanceof gg)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||Mt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new Ma(u.message);case"InvalidPDFException":return new Cg(u.message);case"PasswordException":return new Eg(u.message,u.code);case"ResponseException":return new lp(u.message,u.status,u.missing);case"UnknownErrorException":return new gg(u.message,u.details)}return new gg(u.message,u.toString())}var wc,_i,Mb,Ib,Db,Pf;class Fh{constructor(t,e,s){m(this,_i);m(this,wc,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",v(this,_i,Mb).bind(this),{signal:n(this,wc).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[r]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[r].pullCall=h,l.postMessage({sourceName:a,targetName:o,stream:Ae.PULL,streamId:r,desiredSize:c.desiredSize}),h.promise},cancel:c=>{he(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[r].cancelCall=h,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Ae.CANCEL,streamId:r,reason:As(c)}),h.promise}},s)}destroy(){var t;(t=n(this,wc))==null||t.abort(),p(this,wc,null)}}wc=new WeakMap,_i=new WeakSet,Mb=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){v(this,_i,Db).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===hf.DATA)i.resolve(t.data);else if(t.callback===hf.ERROR)i.reject(As(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:hf.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:hf.ERROR,callbackId:t.callbackId,reason:As(a)})});return}if(t.streamId){v(this,_i,Ib).call(this,t);return}e(t.data)},Ib=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(c,h=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=h,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:Ae.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Ae.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){he(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Ae.ERROR,streamId:e,reason:As(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Ae.START_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:Ae.START_COMPLETE,streamId:e,reason:As(c)})})},Db=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Ae.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(As(t.reason));break;case Ae.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(As(t.reason));break;case Ae.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:Ae.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||sy).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Ae.PULL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:Ae.PULL_COMPLETE,streamId:e,reason:As(c)})});break;case Ae.ENQUEUE:if(he(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Ae.CLOSE:if(he(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),v(this,_i,Pf).call(this,a,e);break;case Ae.ERROR:he(a,"error should have stream controller"),a.controller.error(As(t.reason)),v(this,_i,Pf).call(this,a,e);break;case Ae.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(As(t.reason)),v(this,_i,Pf).call(this,a,e);break;case Ae.CANCEL:if(!o)break;const l=As(t.reason);Promise.try(o.onCancel||sy,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Ae.CANCEL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:Ae.CANCEL_COMPLETE,streamId:e,reason:As(c)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Pf=async function(t,e){var s,i,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var Tp;class Lb{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){m(this,Tp,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:Mt(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(r=>{throw new Error(`Unable to load ${n(this,Tp)[t]} data at: ${i}`)})}async _fetch(t,e){Mt("Abstract method `_fetch` called.")}}Tp=new WeakMap;class iy extends Lb{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await hv(t,s);return i instanceof Uint8Array?i:Kp(i)}}var Ou;class Rb{constructor({enableHWA:t=!1}){m(this,Ou,!1);p(this,Ou,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,Ou)})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Mt("Abstract method `_createCanvas` called.")}}Ou=new WeakMap;class s_ extends Rb{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Fb{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}var _o,Ac,qn,ln,Le,Eo,ea,q,Me,Oh,kr,Mf,Na,Ob,Zg,Ba,Nh,Bh,tm,$h,Nb,Bb;class i_ extends Fb{constructor({docId:e,ownerDocument:s=globalThis.document}){super();m(this,q);m(this,_o);m(this,Ac);m(this,qn);m(this,ln);m(this,Le);m(this,Eo);m(this,ea,0);p(this,ln,e),p(this,Le,s)}addFilter(e){if(!e)return"none";let s=n(this,q,Me).get(e);if(s)return s;const[i,r,a]=v(this,q,Mf).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,q,Me).get(o),s)return n(this,q,Me).set(e,s),s;const l=`g_${n(this,ln)}_transfer_map_${Jt(this,ea)._++}`,c=v(this,q,Na).call(this,l);n(this,q,Me).set(e,c),n(this,q,Me).set(o,c);const h=v(this,q,Ba).call(this,l);return v(this,q,Bh).call(this,i,r,a,h),c}addHCMFilter(e,s){var b;const i=`${e}-${s}`,r="base";let a=n(this,q,Oh).get(r);if((a==null?void 0:a.key)===i||(a?((b=a.filter)==null||b.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,q,Oh).set(r,a)),!e||!s))return a.url;const o=v(this,q,$h).call(this,e);e=j.makeHexColor(...o);const l=v(this,q,$h).call(this,s);if(s=j.makeHexColor(...l),n(this,q,kr).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let w=0;w<=255;w++){const A=w/255;c[w]=A<=.03928?A/12.92:((A+.055)/1.055)**2.4}const h=c.join(","),d=`g_${n(this,ln)}_hcm_filter`,f=a.filter=v(this,q,Ba).call(this,d);v(this,q,Bh).call(this,h,h,h,f),v(this,q,Zg).call(this,f);const g=(w,A)=>{const y=o[w]/255,S=l[w]/255,_=new Array(A+1);for(let C=0;C<=A;C++)_[C]=y+C/A*(S-y);return _.join(",")};return v(this,q,Bh).call(this,g(0,5),g(1,5),g(2,5),f),a.url=v(this,q,Na).call(this,d),a.url}addSelectionHCMFilter(e,s){return this.addHighlightHCMFilter("selection",e,s,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const s=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return s==="none"||!Wt.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=n(this,q,Me).get(e);if(s)return s;const[i]=v(this,q,Mf).call(this,[e]),r=`alpha_${i}`;if(s=n(this,q,Me).get(r),s)return n(this,q,Me).set(e,s),s;const a=`g_${n(this,ln)}_alpha_map_${Jt(this,ea)._++}`,o=v(this,q,Na).call(this,a);n(this,q,Me).set(e,o),n(this,q,Me).set(r,o);const l=v(this,q,Ba).call(this,a);return v(this,q,tm).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,q,Me).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=v(this,q,Mf).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,q,Me).get(r),s)return n(this,q,Me).set(e,s),s;const a=`g_${n(this,ln)}_luminosity_map_${Jt(this,ea)._++}`,o=v(this,q,Na).call(this,a);n(this,q,Me).set(e,o),n(this,q,Me).set(r,o);const l=v(this,q,Ba).call(this,a);return v(this,q,Ob).call(this,l),e&&v(this,q,tm).call(this,i,l),o}addKnockoutFilter(e=0){const s=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${s}`,r=n(this,q,Me).get(i);if(r)return r;const a=`g_${n(this,ln)}_knockout_filter_${Jt(this,ea)._++}`,o=v(this,q,Na).call(this,a);n(this,q,Me).set(i,o);const l=v(this,q,Ba).call(this,a),c=n(this,Le).createElementNS(Fs,"feComponentTransfer");l.append(c);const h=n(this,Le).createElementNS(Fs,"feFuncA");return h.setAttribute("type","linear"),h.setAttribute("slope",`${s}`),h.setAttribute("intercept","0"),c.append(h),o}addHighlightHCMFilter(e,s,i,r,a){var S;const o=`${s}-${i}-${r}-${a}`;let l=n(this,q,Oh).get(e);if((l==null?void 0:l.key)===o||(l?((S=l.filter)==null||S.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,q,Oh).set(e,l)),!s||!i))return l.url;const[c,h]=[s,i].map(v(this,q,$h).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[g,b]=[r,a].map(v(this,q,Bb).bind(this));f<d&&([d,f,g,b]=[f,d,b,g]),n(this,q,kr).style.color="";const w=(_,C,E)=>{const k=new Array(256),D=(f-d)/E,M=_/255,F=(C-_)/(255*E);let B=0;for(let I=0;I<=E;I++){const T=Math.round(d+I*D),N=M+I*F;for(let H=B;H<=T;H++)k[H]=N;B=T+1}for(let I=B;I<256;I++)k[I]=k[B-1];return k.join(",")},A=`g_${n(this,ln)}_hcm_${e}_filter`,y=l.filter=v(this,q,Ba).call(this,A);return v(this,q,Zg).call(this,y),v(this,q,Bh).call(this,w(g[0],b[0],5),w(g[1],b[1],5),w(g[2],b[2],5),y),l.url=v(this,q,Na).call(this,A),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,Eo))!=null&&s.size)||((i=n(this,qn))==null||i.parentNode.parentNode.remove(),p(this,qn,null),(r=n(this,Ac))==null||r.clear(),p(this,Ac,null),(a=n(this,Eo))==null||a.clear(),p(this,Eo,null),p(this,ea,0))}}_o=new WeakMap,Ac=new WeakMap,qn=new WeakMap,ln=new WeakMap,Le=new WeakMap,Eo=new WeakMap,ea=new WeakMap,q=new WeakSet,Me=function(){return n(this,Ac)||p(this,Ac,new Map)},Oh=function(){return n(this,Eo)||p(this,Eo,new Map)},kr=function(){if(!n(this,qn)){const e=n(this,Le).createElement("div"),{style:s}=e;s.colorScheme="only light",s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=n(this,Le).createElementNS(Fs,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,qn,n(this,Le).createElementNS(Fs,"defs")),e.append(i),i.append(n(this,qn)),n(this,Le).body.append(e)}return n(this,qn)},Mf=function(e){if(e.length===1){const c=e[0],h=new Array(256);for(let f=0;f<256;f++)h[f]=c[f]/255;const d=h.join(",");return[d,d,d]}const[s,i,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let c=0;c<256;c++)a[c]=s[c]/255,o[c]=i[c]/255,l[c]=r[c]/255;return[a.join(","),o.join(","),l.join(",")]},Na=function(e){if(n(this,_o)===void 0){p(this,_o,"");const s=n(this,Le).URL;s!==n(this,Le).baseURI&&(Qp(s)?mt('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,_o,Hy(s,"")))}return`url(${n(this,_o)}#${e})`},Ob=function(e){const s=n(this,Le).createElementNS(Fs,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},Zg=function(e){const s=n(this,Le).createElementNS(Fs,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},Ba=function(e){const s=n(this,Le).createElementNS(Fs,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,q,kr).append(s),s},Nh=function(e,s,i){const r=n(this,Le).createElementNS(Fs,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Bh=function(e,s,i,r){const a=n(this,Le).createElementNS(Fs,"feComponentTransfer");r.append(a),v(this,q,Nh).call(this,a,"feFuncR",e),v(this,q,Nh).call(this,a,"feFuncG",s),v(this,q,Nh).call(this,a,"feFuncB",i)},tm=function(e,s){const i=n(this,Le).createElementNS(Fs,"feComponentTransfer");s.append(i),v(this,q,Nh).call(this,i,"feFuncA",e)},$h=function(e){return n(this,q,kr).style.color=e,Jd(getComputedStyle(n(this,q,kr)).getPropertyValue("color"))},Nb=function(e){return n(this,q,kr).style.color=e,Qd(getComputedStyle(n(this,q,kr)).getPropertyValue("color"))},Bb=function(e){const[s,i,r,a]=v(this,q,Nb).call(this,e);if(a===1)return[s,i,r];const[o,l,c]=v(this,q,$h).call(this,"Canvas");return[yg(s,o,a),yg(i,l,a),yg(r,c,a)]};function yg(u,t,e){return Math.round(e*u+(1-e)*t)}ti&&mt("Please use the `legacy` build in Node.js environments.");async function n_(u){const e=await process.getBuiltinModule("fs/promises").readFile(u);return new Uint8Array(e)}class r_ extends Fb{}class a_ extends Rb{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class o_ extends Lb{async _fetch(t,e){return n_(t)}}function $b({src:u,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Wt.isLittleEndian?4278190080:255,[l,c]=a?[r,o]:[o,r],h=s>>3,d=s&7,f=l^c,g=u.length;e=new Uint32Array(e.buffer);let b=0;for(let w=0;w<i;++w){for(const y=t+h;t<y;++t,b+=8){const S=u[t];e[b]=l^-(S>>7&1)&f,e[b+1]=l^-(S>>6&1)&f,e[b+2]=l^-(S>>5&1)&f,e[b+3]=l^-(S>>4&1)&f,e[b+4]=l^-(S>>3&1)&f,e[b+5]=l^-(S>>2&1)&f,e[b+6]=l^-(S>>1&1)&f,e[b+7]=l^-(S&1)&f}if(d===0)continue;const A=t<g?u[t++]:255;for(let y=0;y<d;++y,++b)e[b]=l^-(A>>7-y&1)&f}return{srcPos:t,destPos:b}}function l_({src:u,srcPos:t=0,dest:e,destPos:s=0,width:i,height:r}){let a=0;const o=i*r*3,l=o>>2,c=new Uint32Array(u.buffer,t,l),h=Wt.isLittleEndian?4278190080:255;if(Wt.isLittleEndian){for(;a<l-2;a+=3,s+=4){const d=c[a],f=c[a+1],g=c[a+2];e[s]=d|h,e[s+1]=d>>>24|f<<8|h,e[s+2]=f>>>16|g<<16|h,e[s+3]=g>>>8|h}for(let d=a*4,f=t+o;d<f;d+=3)e[s++]=u[d]|u[d+1]<<8|u[d+2]<<16|h}else{for(;a<l-2;a+=3,s+=4){const d=c[a],f=c[a+1],g=c[a+2];e[s]=d|h,e[s+1]=d<<24|f>>>8|h,e[s+2]=f<<16|g>>>16|h,e[s+3]=g<<8|h}for(let d=a*4,f=t+o;d<f;d+=3)e[s++]=u[d]<<24|u[d+1]<<16|u[d+2]<<8|h}return{srcPos:t+o,destPos:s}}const c_=`
struct Uniforms {
offsetX : f32,
offsetY : f32,
scaleX : f32,
scaleY : f32,
paddedWidth : f32,
paddedHeight : f32,
borderSize : f32,
_pad : f32,
};
@group(0) @binding(0) var<uniform> u : Uniforms;
struct VertexInput {
@location(0) position : vec2<f32>,
@location(1) color : vec4<f32>,
};
struct VertexOutput {
@builtin(position) position : vec4<f32>,
@location(0) color : vec3<f32>,
};
@vertex
fn vs_main(in : VertexInput) -> VertexOutput {
var out : VertexOutput;
let cx = (in.position.x + u.offsetX) * u.scaleX;
let cy = (in.position.y + u.offsetY) * u.scaleY;
out.position = vec4<f32>(
((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
0.0,
1.0
);
out.color = in.color.rgb;
return out;
}
@fragment
fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(in.color, 1.0);
}
`;var Pp,Yn,Co,Sc,Mp,Ub;class h_{constructor(){m(this,Mp);m(this,Pp,null);m(this,Yn,null);m(this,Co,null);m(this,Sc,null)}init(){return n(this,Pp)||p(this,Pp,v(this,Mp,Ub).call(this))}get isReady(){return n(this,Yn)!==null}loadMeshShader(){if(!n(this,Yn)||n(this,Co))return;const t=n(this,Yn).createShaderModule({code:c_});p(this,Co,n(this,Yn).createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:n(this,Sc)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,i,r,a,o,l){this.loadMeshShader();const c=n(this,Yn),{offsetX:h,offsetY:d,scaleX:f,scaleY:g}=i,b=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&c.queue.writeBuffer(b,0,t);const w=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(w,0,e);const A=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(A,0,new Float32Array([h,d,f,g,a,o,l,0]));const y=c.createBindGroup({layout:n(this,Co).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:A}}]}),S=new OffscreenCanvas(a,o),_=S.getContext("webgpu");_.configure({device:c,format:n(this,Sc),alphaMode:r?"opaque":"premultiplied"});const C=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},E=c.createCommandEncoder(),k=E.beginRenderPass({colorAttachments:[{view:_.getCurrentTexture().createView(),clearValue:C,loadOp:"clear",storeOp:"store"}]});return s>0&&(k.setPipeline(n(this,Co)),k.setBindGroup(0,y),k.setVertexBuffer(0,b),k.setVertexBuffer(1,w),k.draw(s)),k.end(),c.queue.submit([E.finish()]),b.destroy(),w.destroy(),A.destroy(),S.transferToImageBitmap()}}Pp=new WeakMap,Yn=new WeakMap,Co=new WeakMap,Sc=new WeakMap,Mp=new WeakSet,Ub=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();return e?(p(this,Sc,navigator.gpu.getPreferredCanvasFormat()),p(this,Yn,await e.requestDevice()),!0):!1}catch{return!1}};const Jp=new h_;function u_(){return Jp.init()}function d_(){return Jp.isReady}function f_(){Jp.loadMeshShader()}function p_(u,t,e,s,i,r,a,o){return Jp.draw(u,t,e,s,i,r,a,o)}const qe={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function If(u,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),u.clip(i)}class pv{isModifyingCurrentTransform(){return!1}getPattern(){Mt("Abstract method `getPattern` called.")}}class g_ extends pv{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}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,r=this._p1;if(e&&(i=i.slice(),r=r.slice(),j.applyTransform(i,e),j.applyTransform(r,e)),this._type==="axial")s=t.createLinearGradient(i[0],i[1],r[0],r[1]);else if(this._type==="radial"){let a=this._r0,o=this._r1;if(e){const l=new Float32Array(2);j.singularValueDecompose2dScale(e,l),a*=l[0],o*=l[0]}s=t.createRadialGradient(i[0],i[1],a,r[0],r[1],o)}for(const a of this._colorStops)s.addColorStop(a[0],a[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;e&&(s=s.slice(),i=i.slice(),j.applyTransform(s,e),j.applyTransform(i,e));let r=this._r1,a=this._r0;if(e){const c=new Float32Array(2);j.singularValueDecompose2dScale(e,c),r*=c[0],a*=c[0]}const o=t.createRadialGradient(s[0],s[1],r,i[0],i[1],a),l=this._colorStops.map(([c,h])=>[1-c,h]).reverse();for(const[c,h]of l)o.addColorStop(c,h);return o}getPattern(t,e,s,i){let r;if(i===qe.STROKE||i===qe.FILL){if(this.isOriginBased()){let f=j.transform(s,e.baseTransform);this.matrix&&(f=j.transform(f,this.matrix));const g=.001,b=Math.hypot(f[0],f[1]),w=Math.hypot(f[2],f[3]),A=(f[0]*f[2]+f[1]*f[3])/(b*w);if(Math.abs(A)<g)if(this.isRadial()){if(Math.abs(b-w)<g)return this._createGradient(t,f)}else return this._createGradient(t,f)}const a=e.current.getClippedPathBoundingBox(i,Kt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,c=e.canvasFactory.create(o,l),h=c.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]),s=j.transform(s,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),If(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),r=t.createPattern(c.canvas,"no-repeat"),e.canvasFactory.destroy(c);const d=new DOMMatrix(s);r.setTransform(d)}else this.areConic()&&(t.save(),If(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),If(t,this._bbox),r=this._createGradient(t);return r}}function m_(u,t,e,s,i,r,a,o){const l=t.coords,c=t.colors,h=u.data,d=u.width*4;let f;l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f),l[s*2+1]>l[i*2+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f);const g=(l[e*2]+t.offsetX)*t.scaleX,b=(l[e*2+1]+t.offsetY)*t.scaleY,w=(l[s*2]+t.offsetX)*t.scaleX,A=(l[s*2+1]+t.offsetY)*t.scaleY,y=(l[i*2]+t.offsetX)*t.scaleX,S=(l[i*2+1]+t.offsetY)*t.scaleY;if(b>=S)return;const _=c[r*4],C=c[r*4+1],E=c[r*4+2],k=c[a*4],D=c[a*4+1],M=c[a*4+2],F=c[o*4],B=c[o*4+1],I=c[o*4+2],T=Math.round(b),N=Math.round(S);let H,Z,P,K,z,Et,_t,Ut;for(let Ot=T;Ot<=N;Ot++){if(Ot<A){const ut=Ot<b?0:(b-Ot)/(b-A);H=g-(g-w)*ut,Z=_-(_-k)*ut,P=C-(C-D)*ut,K=E-(E-M)*ut}else{let ut;Ot>S?ut=1:A===S?ut=0:ut=(A-Ot)/(A-S),H=w-(w-y)*ut,Z=k-(k-F)*ut,P=D-(D-B)*ut,K=M-(M-I)*ut}let X;Ot<b?X=0:Ot>S?X=1:X=(b-Ot)/(b-S),z=g-(g-y)*X,Et=_-(_-F)*X,_t=C-(C-B)*X,Ut=E-(E-I)*X;const W=Math.round(Math.min(H,z)),gt=Math.round(Math.max(H,z));let rt=d*Ot+W*4;for(let ut=W;ut<=gt;ut++)X=(H-ut)/(H-z),X<0?X=0:X>1&&(X=1),h[rt++]=Z-(Z-Et)*X|0,h[rt++]=P-(P-_t)*X|0,h[rt++]=K-(K-Ut)*X|0,h[rt++]=255}}class v_ extends pv{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,f_()}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,h=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3)||1,f=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3e3)||1,g=c?c/d:1,b=h?h/f:1,w={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/b},A=d+4,y=f+4,S=s.create(A,y);if(d_()&&this._vertexCount>48)S.context.drawImage(p_(this._posData,this._colData,this._vertexCount,w,e,A,y,2),0,0);else{const _=S.context.createImageData(d,f);if(e){const C=_.data;for(let E=0,k=C.length;E<k;E+=4)C[E]=e[0],C[E+1]=e[1],C[E+2]=e[2],C[E+3]=255}for(let C=0,E=this._vertexCount;C<E;C+=3)m_(_,w,C,C+1,C+2,C,C+1,C+2);S.context.putImageData(_,2,2)}return{canvas:S.canvas,offsetX:o-2*g,offsetY:l-2*b,scaleX:g,scaleY:b}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){If(t,this._bbox);const r=new Float32Array(2);if(i===qe.SHADING)j.singularValueDecompose2dScale(Kt(t),r);else if(this.matrix){j.singularValueDecompose2dScale(this.matrix,r);const[l,c]=r;j.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=l,r[1]*=c}else j.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,i===qe.SHADING?null:this._background,e.canvasFactory);i!==qe.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY);const o=t.createPattern(a.canvas,"no-repeat");return e.canvasFactory.destroy(a),o}}class y_ extends pv{getPattern(){return"hotpink"}}function b_(u){switch(u[0]){case"RadialAxial":return new g_(u);case"Mesh":return new v_(u);case"Dummy":return new y_}throw new Error(`Unknown IR type: ${u[0]}`)}const ny={COLORED:1,UNCOLORED:2},Ip=class Ip{constructor(t,e,s,i){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.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?j.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){const[r,a,o,l]=this.bbox,c=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>c+1e-6||e>h+1e-6)return null;const d=Math.floor((s-o)/c)+1,f=Math.ceil((s+t-r)/c)-1,g=Math.floor((i-l)/h)+1,b=Math.ceil((i+e-a)/h)-1;return f<=d&&b<=g?[d,g]:null}updatePatternDims(t,e){const s=j.inverseTransform(this.patternBaseMatrix),i=[t[0],t[1]],r=[t[2],t[3]];j.applyTransform(i,s),j.applyTransform(r,s),e[0]=Math.abs(r[0]-i[0]),e[1]=Math.abs(r[1]-i[1]),e[2]=Math.min(i[0],r[0]),e[3]=Math.min(i[1],r[1])}_renderTileCanvas(t,e,s,i){var f,g;const[r,a,o,l]=this.bbox,c=t.canvasFactory.create(s.size,i.size),h=c.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-s.scale*r,-i.scale*a),d.transform(0,s.scale,0,0,i.scale,0,0),h.save(),(f=d.dependencyTracker)==null||f.save(),this.clipBbox(d,r,a,o,l),d.baseTransform=Kt(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),(g=d.dependencyTracker)==null||g.restore(),h.restore(),c}_getCombinedScales(){const t=new Float32Array(2);j.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return j.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,r],a){const[o,l,c,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new iu(d,a)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,r*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const f=c-o,g=h-l,[b,w]=this._getCombinedScales(),A=this.getSizeAndScale(f,this.ctx.canvas.width,b),y=this.getSizeAndScale(g,this.ctx.canvas.height,w),S=this._renderTileCanvas(t,a,A,y);t.ctx.drawImage(S.canvas,o,l,f,g),t.canvasFactory.destroy(S)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,l,c,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=Kt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,i,r,a]=this.bbox,o=r-s,l=a-i;let{xstep:c,ystep:h}=this;c=Math.abs(c),h=Math.abs(h),Yp("TilingType: "+this.tilingType);const[d,f]=this._getCombinedScales();let g=o,b=l,w=!1,A=!1;Math.ceil(c*d)>=Math.ceil(o*d)?g=c:w=!0,Math.ceil(h*f)>=Math.ceil(l*f)?b=h:A=!0;const y=this.getSizeAndScale(g,this.ctx.canvas.width,d),S=this.getSizeAndScale(b,this.ctx.canvas.height,f),_=this._renderTileCanvas(t,e,y,S);if(w||A){const C=_.canvas;w&&(g=c),A&&(b=h);const E=this.getSizeAndScale(g,this.ctx.canvas.width,d),k=this.getSizeAndScale(b,this.ctx.canvas.height,f),D=E.size,M=k.size,F=t.canvasFactory.create(D,M),B=F.context,I=w?Math.floor(o/c):0,T=A?Math.floor(l/h):0;for(let N=0;N<=I;N++)for(let H=0;H<=T;H++)B.drawImage(C,D*N,M*H,D,M,0,0,D,M);return t.canvasFactory.destroy(_),{canvas:F.canvas,canvasEntry:F,scaleX:E.scale,scaleY:k.scale,offsetX:s,offsetY:i}}return{canvas:_.canvas,canvasEntry:_,scaleX:y.scale,scaleY:S.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(Ip.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s,l=new Path2D;l.rect(e,s,a,o),j.axialAlignedBoundingBox([e,s,i,r],Kt(t.ctx),t.current.minMax),t.ctx.clip(l),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case ny.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case ny.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new xx(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){const a=i!==qe.SHADING?j.transform(s,this.patternBaseMatrix):s,o=this.createPatternCanvas(e,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const c=t.createPattern(o.canvas,"repeat");return e.canvasFactory.destroy(o.canvasEntry),c.setTransform(l),c}};R(Ip,"MAX_PATTERN_SIZE",3e3);let Qh=Ip;const w_=16,A_=100,S_=15,ry=10,Ms=16,bg=new DOMMatrix,ei=new Float32Array(2);function ay(u,t){if(u._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const i=u[s];typeof i!="function"||typeof t[s]!="function"||(e.set(s,i),u[s]=function(...r){return t[s](...r),i.apply(this,r)})}u._removeMirroring=()=>{for(const[s,i]of e)u[s]=i;delete u._removeMirroring}}function uf(u,t,e,s,i,r,a,o,l,c){const[h,d,f,g,b,w]=Kt(u);if(d===0&&f===0){const S=a*h+b,_=Math.round(S),C=o*g+w,E=Math.round(C),k=(a+l)*h+b,D=Math.abs(Math.round(k)-_)||1,M=(o+c)*g+w,F=Math.abs(Math.round(M)-E)||1;return u.setTransform(Math.sign(h),0,0,Math.sign(g),_,E),u.drawImage(t,e,s,i,r,0,0,D,F),u.setTransform(h,d,f,g,b,w),[D,F]}if(h===0&&g===0){const S=o*f+b,_=Math.round(S),C=a*d+w,E=Math.round(C),k=(o+c)*f+b,D=Math.abs(Math.round(k)-_)||1,M=(a+l)*d+w,F=Math.abs(Math.round(M)-E)||1;return u.setTransform(0,Math.sign(d),Math.sign(f),0,_,E),u.drawImage(t,e,s,i,r,0,0,F,D),u.setTransform(h,d,f,g,b,w),[F,D]}u.drawImage(t,e,s,i,r,a,o,l,c);const A=Math.hypot(h,d),y=Math.hypot(f,g);return[A*l,y*c]}class oy{constructor(t,e){R(this,"alphaIsShape",!1);R(this,"fontSize",0);R(this,"fontSizeScale",1);R(this,"textMatrix",null);R(this,"textMatrixScale",1);R(this,"fontMatrix",xg);R(this,"leading",0);R(this,"x",0);R(this,"y",0);R(this,"lineX",0);R(this,"lineY",0);R(this,"charSpacing",0);R(this,"wordSpacing",0);R(this,"textHScale",1);R(this,"textRenderingMode",Ce.FILL);R(this,"textRise",0);R(this,"fillColor","#000000");R(this,"strokeColor","#000000");R(this,"tilingPatternDims",null);R(this,"patternFill",!1);R(this,"patternStroke",!1);R(this,"fillAlpha",1);R(this,"strokeAlpha",1);R(this,"lineWidth",1);R(this,"activeSMask",null);R(this,"transferMaps","none");R(this,"minMax",Wa.slice());this.clipBox=new Float32Array([0,0,t,e])}clone(){var e;const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(t=qe.FILL,e=null){const s=this.minMax.slice();if(t===qe.STROKE){e||Mt("Stroke bounding box must include transform."),j.singularValueDecompose2dScale(e,ei);const i=ei[0]*this.lineWidth/2,r=ei[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=j.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(Wa,0)}getClippedPathBoundingBox(t=qe.FILL,e=null){return j.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function ly(u,t){const{width:e,height:s,kind:i}=t,r=s%Ms,a=(s-r)/Ms,o=r===0?a:a+1,l=u.createImageData(e,Ms);let c=0;const h=t.data,d=l.data;let f;if(i===bf.GRAYSCALE_1BPP)for(f=0;f<o;f++)({srcPos:c}=$b({src:h,srcPos:c,dest:d,width:e,height:f<a?Ms:r})),u.putImageData(l,0,f*Ms);else if(i===bf.RGBA_32BPP){let g=0,b=e*Ms*4;for(f=0;f<a;f++)d.set(h.subarray(c,c+b)),c+=b,u.putImageData(l,0,g),g+=Ms;f<o&&(b=e*r*4,d.set(h.subarray(c,c+b)),u.putImageData(l,0,g))}else if(i===bf.RGB_24BPP)for(f=0;f<o;f++)({srcPos:c}=l_({src:h,srcPos:c,dest:new Uint32Array(d.buffer),width:e,height:f<a?Ms:r})),u.putImageData(l,0,f*Ms);else throw new Error(`bad image kind: ${i}`)}function cy(u,t){if(t.bitmap){u.drawImage(t.bitmap,0,0);return}const{width:e,height:s}=t,i=s%Ms,r=(s-i)/Ms,a=i===0?r:r+1,o=u.createImageData(e,Ms);let l=0;const c=t.data,h=o.data;for(let d=0;d<a;d++)({srcPos:l}=$b({src:c,srcPos:l,dest:h,width:e,height:d<r?Ms:i,nonBlackColor:0})),u.putImageData(o,0,d*Ms)}function Oa(u,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)u[s]!==void 0&&(t[s]=u[s]);u.setLineDash!==void 0&&(t.setLineDash(u.getLineDash()),t.lineDashOffset=u.lineDashOffset)}function df(u){u.strokeStyle=u.fillStyle="#000000",u.fillRule="nonzero",u.globalAlpha=1,u.lineWidth=1,u.lineCap="butt",u.lineJoin="miter",u.miterLimit=10,u.globalCompositeOperation="source-over",u.font="10px sans-serif",u.setLineDash!==void 0&&(u.setLineDash([]),u.lineDashOffset=0);const{filter:t}=u;t!=="none"&&t!==""&&(u.filter="none")}function hy(u,t){if(t)return!0;j.singularValueDecompose2dScale(u,ei);const e=Math.fround(_n.pixelRatio*Ia.PDF_TO_CSS_UNITS);return ei[0]<=e&&ei[1]<=e}const x_=["butt","round","square"],__=["miter","round","bevel"],E_={},uy={};var $s,sa,ko,To,Po,Mo,Io,Do,Lo,cn,nt,em,sm,im,nm,rm,ws,Qe,am,Hb,Df;const xv=class xv{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,c,h,d){m(this,nt);m(this,$s,0);m(this,sa,0);m(this,ko,null);m(this,To,null);m(this,Po,null);m(this,Mo,null);m(this,Io,1);m(this,Do);m(this,Lo,null);m(this,cn,[]);this.ctx=t,this.current=new oy(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,s=null){var i;return typeof e=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.transparentCanvasEntry=this.canvasFactory.create(r,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=l,this.ctx.save(),this.ctx.transform(...Kt(this.compositeCtx))}this.ctx.save(),df(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Kt(this.ctx)}executeOperatorList(t,e,s,i,r){var y;const a=t.argsArray,o=t.fnArray;let l=e||0;const c=a.length;if(c===l)return l;const h=c-l>ry&&typeof s=="function",d=h?Date.now()+S_:0;let f=0;const g=this.commonObjs,b=this.objs;let w,A;for(;;){if(i!==void 0){if(l===i.nextBreakPoint)return i.breakIt(l,s),l;if(i.shouldSkip(l)){if(++l===c)return l;continue}}if(!r||r(l))if(w=o[l],A=a[l]??null,w!==Ki.dependency)A===null?this[w](l):this[w](l,...A);else for(const S of A){(y=this.dependencyTracker)==null||y.recordNamedData(S,l);const _=S.startsWith("g_")?g:b;if(!_.has(S))return _.get(S,s),l}if(l++,l===c)return l;if(h&&++f>ry){if(Date.now()>d)return s(),l;f=0}}}endDrawing(){v(this,nt,em).call(this);for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of n(this,cn))v(this,nt,Df).call(this,t);n(this,cn).length=0,p(this,ko,null),p(this,To,null),p(this,Po,null),p(this,Mo,null),p(this,Io,1),p(this,Lo,null),p(this,sa,0),p(this,$s,0),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),v(this,nt,sm).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=[];let l=r,c=a,h=s,d=i;for(;l>2&&h>1||c>2&&d>1;){let y=h,S=d;l>2&&h>1&&(y=Math.ceil(h/2),l/=h/y),c>2&&d>1&&(S=Math.ceil(d/2),c/=d/S),o.push({newWidth:y,newHeight:S}),h=y,d=S}if(o.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(o.length===1){const{newWidth:y,newHeight:S}=o[0],_=this.canvasFactory.create(y,S);return _.context.drawImage(t,0,0,s,i,0,0,y,S),{img:_.canvas,paintWidth:y,paintHeight:S,tmpCanvas:_}}let f=this.canvasFactory.create(1,1),g=this.canvasFactory.create(1,1),b=s,w=i,A=t;for(const{newWidth:y,newHeight:S}of o)this.canvasFactory.reset(g,y,S),g.context.drawImage(A,0,0,b,w,0,0,y,S),[f,g]=[g,f],A=f.canvas,b=y,w=S;return this.canvasFactory.destroy(g),{img:f.canvas,paintWidth:b,paintHeight:w,tmpCanvas:f}}_createMaskCanvas(t,e){var I,T;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=Kt(s);let c,h,d,f;if((e.bitmap||e.data)&&e.count>1){const N=e.bitmap||e.data.buffer;h=JSON.stringify(o?l:[l.slice(0,4),a]),c=this._cachedBitmapsMap.getOrInsertComputed(N,cv);const H=c.get(h);if(H&&!o){const Z=Math.round(Math.min(l[0],l[2])+l[4]),P=Math.round(Math.min(l[1],l[3])+l[5]);return(I=this.dependencyTracker)==null||I.recordDependencies(t,li.transformAndFill),{canvas:H,offsetX:Z,offsetY:P}}d=H}d||(f=this.canvasFactory.create(i,r),cy(f.context,e));let g=j.transform(l,[1/i,0,0,-1/r,0,0]);g=j.transform(g,[1,0,0,1,0,-r]);const b=Wa.slice();j.axialAlignedBoundingBox([0,0,i,r],g,b);const[w,A,y,S]=b,_=Math.round(y-w)||1,C=Math.round(S-A)||1,E=this.canvasFactory.create(_,C),k=E.context,D=w,M=A;k.translate(-D,-M),k.transform(...g);let F=null;if(!d){const N=this._scaleImage(f.canvas,Xi(k));d=N.img,F=N.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),c&&o&&(c.set(h,d),F=null,f=null)}k.imageSmoothingEnabled=hy(Kt(k),e.interpolate),uf(k,d,0,0,d.width,d.height,0,0,i,r),F&&this.canvasFactory.destroy(F),f&&this.canvasFactory.destroy(f),k.globalCompositeOperation="source-in";const B=j.transform(Xi(k),[1,0,0,1,-D,-M]);return k.fillStyle=o?a.getPattern(s,this,B,qe.FILL,t):a,k.fillRect(0,0,i,r),c&&!o&&c.set(h,E.canvas),(T=this.dependencyTracker)==null||T.recordDependencies(t,li.transformAndFill),{canvas:E.canvas,canvasEntry:c&&!o?null:E,offsetX:Math.round(D),offsetY:Math.round(M)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=x_[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=__[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,i,r,a,o;for(const[l,c]of e)switch(l){case"LW":this.setLineWidth(t,c);break;case"LC":this.setLineCap(t,c);break;case"LJ":this.setLineJoin(t,c);break;case"ML":this.setMiterLimit(t,c);break;case"D":this.setDash(t,c[0],c[1]);break;case"RI":this.setRenderingIntent(t,c);break;case"FL":this.setFlatness(t,c);break;case"Font":this.setFont(t,c[0],c[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=c;break;case"ca":(i=this.dependencyTracker)==null||i.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=c;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=c;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=c?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(c);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){const{canvas:e,subtype:s,backdrop:i,transferMap:r}=t,a=s==="Luminosity"||s==="Alpha"&&r;if(!a&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let o;if(s==="Luminosity"&&i){const[S,_,C]=Qd(i),E=Math.round(.3*S+.59*_+.11*C);o=(r==null?void 0:r[E])??E}else o=(r==null?void 0:r[0])??0;const l=4,{width:c,height:h}=this.ctx.canvas,d=e.width*e.height,f=c*h<l*d,g=a?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(r):this.filterFactory.addLuminosityFilter(r),subtype:s,transferMap:r}:null,b=s==="Luminosity"?i:null;let w,A,y;f?(w=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,c,h,b,g),A=0,y=0):(w=this._bakeSMaskCanvas(e,0,0,e.width,e.height,b,g),A=t.offsetX,y=t.offsetY),this.smaskPreparedEntry=w,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=A,this.smaskPreparedOffsetY=y,this.smaskPreparedOOBAlpha=!f&&o!==0?o:null}_bakeSMaskCanvas(t,e,s,i,r,a,o){!a&&!o&&Mt("_bakeSMaskCanvas with neither backdrop nor filter");const l=this.canvasFactory.create(i,r),c=l.context;if(c.drawImage(t,e,s),a&&(c.globalCompositeOperation="destination-atop",c.fillStyle=a,c.fillRect(0,0,i,r)),!o)return l;const h=this.canvasFactory.create(i,r),d=h.context;d.filter=o.url;const f=Wt.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(l.canvas,0,0),Wt.isCanvasFilterSupported&&(d.filter="none"),!f){const g=d.getImageData(0,0,i,r),{data:b}=g,{transferMap:w}=o;if(o.subtype==="Luminosity")for(let A=0,y=b.length;A<y;A+=4){const S=.3*b[A]+.59*b[A+1]+.11*b[A+2]+.5|0;b[A]=b[A+1]=b[A+2]=0,b[A+3]=(w==null?void 0:w[S])??S}else for(let A=3,y=b.length;A<y;A+=4)b[A]=w[b[A]];d.putImageData(g,0,0)}return this.canvasFactory.destroy(l),h}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:s}=this.ctx.canvas,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;const r=this.ctx=i.context;r.setTransform(this.suspendedCtx.getTransform()),Oa(this.suspendedCtx,r),ay(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Oa(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx,i=n(this,sa)>0&&s===this.ctx;this.composeSMask(i?null:s,e,this.ctx,t),!i&&(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,s,i){const r=i[0],a=i[1],o=i[2]-r,l=i[3]-a;if(o===0||l===0)return;const c=this.smaskPreparedEntry;if(c){let h=r,d=a,f=o,g=l;const b=this.smaskPreparedOOBAlpha,w=b!==null;if(w){h=Math.max(r,e.offsetX),d=Math.max(a,e.offsetY);const A=Math.min(r+o,e.offsetX+e.canvas.width),y=Math.min(a+l,e.offsetY+e.canvas.height);f=A-h,g=y-d}if(f>0&&g>0){const A=h-this.smaskPreparedOffsetX,y=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const S=new Path2D;S.rect(h,d,f,g),s.clip(S),s.globalCompositeOperation="destination-in",s.drawImage(c.canvas,A,y,f,g,h,d,f,g),s.restore()}w&&b<255&&this._applySMaskOOBAlpha(s,r,a,o,l,h,d,h+f,d+g,b)}else this.genericComposeSMask(e,s,o,l,r,a);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,r,a,o,l,r,a,o,l),t.restore())}_applySMaskOOBAlpha(t,e,s,i,r,a,o,l,c,h){const d=a<l&&o<c;if(d&&a===e&&o===s&&l===e+i&&c===s+r)return;const f=new Path2D;f.rect(e,s,i,r),d&&f.rect(a,o,l-a,c-o),t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(f,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,i,r),t.restore()}genericComposeSMask(t,e,s,i,r,a){const{context:o,offsetX:l,offsetY:c}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const h=new Path2D;h.rect(r,a,s,i),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(o.canvas,r-l,a-c,s,i,r,a,s,i),e.restore()}save(t){var s;this.inSMaskMode&&Oa(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Oa(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[r]=s;if(!i){r||(r=s[0]=new Path2D),e!==Ki.stroke&&e!==Ki.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===Ki.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-o,i[2]+o,i[1]-o,i[3]+o).recordDependencies(t,["transform"])}r instanceof Path2D||(r=s[0]=jy(r)),j.axialAlignedBoundingBox(i,Kt(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==Ki.stroke&&e!==Ki.closeStroke&&this.current.fillColor instanceof Qh){const o=j.intersect(this.current.clipBox,this.current.minMax);o?this.current.fillColor.updatePatternDims(o,a):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var o;const i=s&&v(this,nt,ws).call(this,this.current.strokeAlpha),r=this.ctx,a=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof a=="object"&&(a!=null&&a.getPattern)){const l=a.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=a.getPattern(r,this,Xi(r),qe.STROKE,t),l){const c=new Path2D;c.addPath(e,r.getTransform().invertSelf().multiplySelf(l)),e=c}this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);(o=this.dependencyTracker)==null||o.recordDependencies(t,li.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(qe.STROKE,Kt(this.ctx))),r.globalAlpha=this.current.fillAlpha,v(this,nt,Qe).call(this,i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,d,f;const i=s&&v(this,nt,ws).call(this,this.current.fillAlpha),r=this.ctx,a=this.current.fillColor,o=this.current.patternFill;let l=!1;const c=this.current.getClippedPathBoundingBox();if((h=this.dependencyTracker)==null||h.recordDependencies(t,li.fill),o){const g=this.current.tilingPatternDims,b=g&&a.canSkipPatternCanvas(g);if(b){a.drawPattern(this,e,this.pendingEOFill,b,t),this.pendingEOFill=!1,s&&this.consumePath(t,e,c),this.current.tilingPatternDims=null,v(this,nt,Qe).call(this,i);return}const w=a.isModifyingCurrentTransform()?r.getTransform():null;if((d=this.dependencyTracker)==null||d.save(t),r.save(),r.fillStyle=a.getPattern(r,this,Xi(r),qe.FILL,t),w){const A=new Path2D;A.addPath(e,r.getTransform().invertSelf().multiplySelf(w)),e=A}l=!0}this.contentVisible&&c!==null&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),l&&(r.restore(),(f=this.dependencyTracker)==null||f.restore(t)),s&&this.consumePath(t,e,c),v(this,nt,Qe).call(this,i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=v(this,nt,ws).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),v(this,nt,Qe).call(this,s)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var i;const s=v(this,nt,ws).call(this,this.current.fillAlpha);this.ctx.fill(e),(i=this.dependencyTracker)==null||i.recordDependencies(t,li.rawFillPath).recordOperation(t),v(this,nt,Qe).call(this,s)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=E_}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=uy}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:c,path:h}of e)h&&i.addPath(h,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(c,-c));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var d,f;(d=this.dependencyTracker)==null||d.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||xg,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&mt("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((f=i.systemFontInfo)==null?void 0:f.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const c=i.italic?"italic":"normal",h=ee(s,w_,A_);this.current.fontSizeScale=s/h,this.ctx.font=`${c} ${l} ${h}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,s,i,r,a){var y,S,_,C;const o=this.ctx,l=this.current,c=l.font,h=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,f=h&Ce.FILL_STROKE_MASK,g=!!(h&Ce.ADD_TO_PATH_FLAG),b=l.patternFill&&!c.missingFile,w=l.patternStroke&&!c.missingFile;let A;if((c.disableFontFace||g||b||w)&&!c.missingFile&&(A=c.getPathGenerator(this.commonObjs,e)),A&&(c.disableFontFace||b||w)){o.save(),o.translate(s,i),o.scale(d,-d),(y=this.dependencyTracker)==null||y.recordCharacterBBox(t,o,c);let E;if(f===Ce.FILL||f===Ce.FILL_STROKE)if(r){E=o.getTransform(),o.setTransform(...r);const k=v(this,nt,am).call(this,A,E,r);o.fill(k)}else o.fill(A);if(f===Ce.STROKE||f===Ce.FILL_STROKE)if(a){E||(E=o.getTransform()),o.setTransform(...a);const{a:k,b:D,c:M,d:F}=E,B=j.inverseTransform(a),I=j.transform([k,D,M,F,0,0],B);j.singularValueDecompose2dScale(I,ei),o.lineWidth*=Math.max(ei[0],ei[1])/d,o.stroke(v(this,nt,am).call(this,A,E,a))}else o.lineWidth/=d,o.stroke(A);o.restore()}else(f===Ce.FILL||f===Ce.FILL_STROKE)&&(o.fillText(e,s,i),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,c,d,s,i,()=>o.measureText(e))),(f===Ce.STROKE||f===Ce.FILL_STROKE)&&(this.dependencyTracker&&((_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,c,d,s,i,()=>o.measureText(e)).recordDependencies(t,li.stroke)),o.strokeText(e,s,i));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Kt(o),x:s,y:i,fontSize:d,path:A}),(C=this.dependencyTracker)==null||C.recordCharacterBBox(t,o,c,d,s,i))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){i=!0;break}return ft(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var T,N,H,Z;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,li.showText).resetBBox(t),this.current.textRenderingMode&Ce.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const P=v(this,nt,ws).call(this,s.fillAlpha);this.showType3Text(t,e),(T=this.dependencyTracker)==null||T.recordShowTextOperation(t),v(this,nt,Qe).call(this,P);return}const r=s.fontSize;if(r===0){(N=this.dependencyTracker)==null||N.recordOperation(t);return}const a=v(this,nt,ws).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,c=s.charSpacing,h=s.wordSpacing,d=s.fontDirection,f=s.textHScale*d,g=e.length,b=i.vertical,w=b?1:-1,A=i.defaultVMetrics,y=r*s.fontMatrix[0],S=s.textRenderingMode===Ce.FILL&&!i.disableFontFace&&!s.patternFill;o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),d>0?o.scale(f,-1):o.scale(f,1);let _,C;const E=s.textRenderingMode&Ce.FILL_STROKE_MASK,k=E===Ce.FILL||E===Ce.FILL_STROKE,D=E===Ce.STROKE||E===Ce.FILL_STROKE;let M=s.lineWidth;const F=s.textMatrixScale;if(F===0||M===0?D&&(M=this.getSinglePixelWidth()):M/=F,l!==1&&(o.scale(l,l),M/=l),o.lineWidth=M,k&&s.patternFill){o.save();const P=s.fillColor.getPattern(o,this,Xi(o),qe.FILL,t);_=Kt(o),o.restore(),o.fillStyle=P}if(D&&s.patternStroke){o.save();const P=s.strokeColor.getPattern(o,this,Xi(o),qe.STROKE,t);C=Kt(o),o.restore(),o.strokeStyle=P}if(i.isInvalidPDFjsFont){const P=[];let K=0;for(const Et of e)P.push(Et.unicode),K+=Et.width;const z=P.join("");if(o.fillText(z,0,0),this.dependencyTracker!==null){const Et=o.measureText(z);this.dependencyTracker.recordBBox(t,this.ctx,-Et.actualBoundingBoxLeft,Et.actualBoundingBoxRight,-Et.actualBoundingBoxAscent,Et.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=K*y*f,o.restore(),this.compose(),v(this,nt,Qe).call(this,a);return}let B=0,I;for(I=0;I<g;++I){const P=e[I];if(typeof P=="number"){B+=w*P*r/1e3;continue}let K=!1;const z=(P.isSpace?h:0)+c,Et=P.fontChar,_t=P.accent;let Ut,Ot,X=P.width;if(b){const rt=P.vmetric||A,ut=-(P.vmetric?rt[1]:X*.5)*y,Qt=rt[2]*y;X=rt?-rt[0]:X,Ut=ut/l,Ot=(B+Qt)/l}else Ut=B/l,Ot=0;let W;if(i.remeasure&&X>0){W=o.measureText(Et);const rt=W.width*1e3/r*l;if(X<rt&&this.isFontSubpixelAAEnabled){const ut=X/rt;K=!0,o.save(),o.scale(ut,1),Ut/=ut}else X!==rt&&(Ut+=(X-rt)/2e3*r/l)}if(this.contentVisible&&(P.isInFont||i.missingFile)){if(S&&!_t)o.fillText(Et,Ut,Ot),(H=this.dependencyTracker)==null||H.recordCharacterBBox(t,o,W?{bbox:null}:i,r/l,Ut,Ot,()=>W??o.measureText(Et));else if(this.paintChar(t,Et,Ut,Ot,_,C),_t){const rt=Ut+r*_t.offset.x/l,ut=Ot-r*_t.offset.y/l;this.paintChar(t,_t.fontChar,rt,ut,_,C)}}const gt=b?X*y-z*d:X*y+z*d;B+=gt,K&&o.restore()}b?s.y-=B:s.x+=B*f,o.restore(),this.compose(),(Z=this.dependencyTracker)==null||Z.recordShowTextOperation(t),v(this,nt,Qe).call(this,a)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,c=i.charSpacing,h=i.wordSpacing,d=i.textHScale*o,f=i.fontMatrix||xg,g=e.length,b=i.textRenderingMode===Ce.INVISIBLE;let w,A,y,S;if(b||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,o);const _=this.dependencyTracker;for(this.dependencyTracker=_?new iu(_,t):null,w=0;w<g;++w){if(A=e[w],typeof A=="number"){S=l*A*a/1e3,this.ctx.translate(S,0),i.x+=S*d;continue}const C=(A.isSpace?h:0)+c,E=r.charProcOperatorList[A.operatorListId];E?this.contentVisible&&(this.save(),E.fnArray[0]===Ki.setCharWidth&&(i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1),s.scale(a,a),s.transform(...f),this.executeOperatorList(E),this.restore()):mt(`Type3 character "${A.operatorListId}" is not available.`);const k=[A.width,0];j.applyTransform(k,f),y=k[0]*a+C,s.translate(y,0),i.x+=y*d}s.restore(),_&&(this.dependencyTracker=_)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,a,o){var c;const l=new Path2D;l.rect(i,r,a-i,o-r),this.ctx.clip(l),(c=this.dependencyTracker)==null||c.recordBBox(t,this.ctx,i,a,r,o).recordClipBox(t,this.ctx,i,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||Kt(this.ctx),r={createCanvasGraphics:(a,o)=>new xv(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new iu(this.dependencyTracker,o,!0):null)};s=new Qh(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof Qh?[0,0,0,0]:null}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=b_(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){var o;if(!this.contentVisible)return;const s=v(this,nt,ws).call(this,this.current.fillAlpha),i=this.ctx;this.save(t);const r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,Xi(i),qe.SHADING,t);const a=Xi(i);if(a){const{width:l,height:c}=i.canvas,h=Wa.slice();j.axialAlignedBoundingBox([0,0,l,c],a,h);const[d,f,g,b]=h;this.ctx.fillRect(d,f,g-d,b-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,li.transform).recordDependencies(t,li.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),v(this,nt,Qe).call(this,s)}beginInlineImage(){Mt("Should not call beginInlineImage")}beginImageData(){Mt("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Kt(this.ctx),s)){j.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,c=new Path2D;c.rect(r,a,o-r,l-a),this.ctx.clip(c),(i=this.dependencyTracker)==null||i.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var S;if(!this.contentVisible)return;this.save(t);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&n(this,$s)===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let _=new Path2D;const[C,E,k,D]=e.bbox;if(_.rect(C,E,k-C,D-E),e.matrix){const M=new Path2D;M.addPath(_,new DOMMatrix(e.matrix)),_=M}i.clip(_)}this.groupStack.push(null),n(this,cn).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&n(this,$s)===0&&Yp("TODO: Fully support non-isolated non-knockout groups.");const r=Kt(i);e.matrix&&i.transform(...e.matrix);const a=[0,0,i.canvas.width,i.canvas.height];let o;e.bbox?(o=Wa.slice(),j.axialAlignedBoundingBox(e.bbox,Kt(i),o),o=j.intersect(o,a)||[0,0,0,0]):o=a;const l=Math.floor(o[0]),c=Math.floor(o[1]),h=Math.max(Math.ceil(o[2])-l,1),d=Math.max(Math.ceil(o[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,d]);const f=this.canvasFactory.create(h,d);e.smask&&this.smaskGroupCanvases.push(f);const g=f.context,b=e.knockout&&!e.isolated?i:null,w=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&n(this,$s)>0,A=e.knockout?this.canvasFactory.create(h,d):null,y=n(this,$s);if(e.knockout?Jt(this,$s)._++:p(this,$s,0),g.translate(-l,-c),g.transform(...r),!e.isolated&&!e.smask&&s&&e.needsIsolation&&(g.save(),g.setTransform(1,0,0,1,0,0),g.drawImage(i.canvas,-l,-c),g.restore()),e.bbox){let _=new Path2D;const[C,E,k,D]=e.bbox;if(_.rect(C,E,k-C,D-E),e.matrix){const M=new Path2D;M.addPath(_,new DOMMatrix(e.matrix)),_=M}g.clip(_)}e.smask&&this.smaskStack.push({canvas:f.canvas,context:g,offsetX:l,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(l,c),i.save()),Oa(i,g),this.ctx=g,(S=this.dependencyTracker)==null||S.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),n(this,cn).push({backdropCtx:b,savedKnockoutLevel:y,offsetX:l,offsetY:c,hasInnerBackdrop:w,knockoutMaskEntry:A,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){var a;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop(),r=n(this,cn).pop();if(r&&p(this,$s,r.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&v(this,nt,Hb).call(this,s),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(a=this.dependencyTracker)==null||a.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),v(this,nt,Df).call(this,r);else{this.ctx.restore();const o=Kt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=Wa.slice();j.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],o,l);const c=n(this,cn).at(-1);if(n(this,$s)>0)if(r.hasInnerBackdrop){const{width:h,height:d}=s.canvas,f=this.canvasFactory.create(h,d),g=f.context;g.drawImage(i.canvas,r.offsetX,r.offsetY,h,d,0,0,h,d),g.globalCompositeOperation="source-over",g.drawImage(s.canvas,0,0);const b=v(this,nt,im).call(this,s.canvas);g.globalCompositeOperation="destination-in",g.drawImage(b.canvas,0,0);const w=this.ctx.globalCompositeOperation,A=this.ctx.globalAlpha,y=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...o),this.ctx.globalAlpha=1,Wt.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(b.canvas,0,0),this.ctx.globalCompositeOperation=w,this.ctx.globalAlpha=A,Wt.isCanvasFilterSupported&&(this.ctx.filter=y??"none"),this.ctx.drawImage(f.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(b),this.canvasFactory.destroy(f)}else{const h=(c==null?void 0:c.backdropCtx)??null;v(this,nt,rm).call(this,this.ctx,s.canvas,{backdropCanvas:(h==null?void 0:h.canvas)??null,destTransform:o,backdropOffset:h?[c.offsetX+r.offsetX,c.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(s.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),v(this,nt,Df).call(this,r),this.compose(l)}}beginAnnotation(t,e,s,i,r,a,o){if(v(this,nt,em).call(this),df(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const l=s[2]-s[0],c=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=l,s[3]=c,j.singularValueDecompose2dScale(Kt(this.ctx),ei);const{viewportScale:h}=this,d=Math.ceil(l*this.outputScaleX*h),f=Math.ceil(c*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:g,context:b}=this.annotationCanvas;if(o){const w=this.annotationCanvasMap.getOrInsertComputed(e,Yd);g.setAttribute("data-canvas-name",o);const A=w.findIndex(y=>y.getAttribute("data-canvas-name")===o);A===-1?w.push(g):w[A]=g}else this.annotationCanvasMap.set(e,g);this.annotationCanvas.savedCtx=this.ctx,this.ctx=b,this.ctx.save(),this.ctx.setTransform(ei[0],0,0,-ei[1],0,c*ei[1]),df(this.ctx)}else{df(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],l,c),this.ctx.clip(h)}}this.current=new oy(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=Kt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),v(this,nt,sm).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){var l;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=v(this,nt,ws).call(this,this.current.fillAlpha),r=this.ctx,a=this._createMaskCanvas(t,e),o=a.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(o,a.offsetX,a.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(t).recordBBox(t,this.ctx,a.offsetX,a.offsetX+o.width,a.offsetY,a.offsetY+o.height).recordOperation(t),r.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),v(this,nt,Qe).call(this,i)}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var f,g,b;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=v(this,nt,ws).call(this,this.current.fillAlpha),c=this.ctx;c.save();const h=Kt(c);c.transform(s,i,r,a,0,0);const d=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),(f=this.dependencyTracker)==null||f.resetBBox(t);for(let w=0,A=o.length;w<A;w+=2){const y=j.transform(h,[s,i,r,a,o[w],o[w+1]]);c.drawImage(d.canvas,y[4],y[5]),(g=this.dependencyTracker)==null||g.recordBBox(t,this.ctx,y[4],y[4]+d.canvas.width,y[5],y[5]+d.canvas.height)}c.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),(b=this.dependencyTracker)==null||b.recordOperation(t),v(this,nt,Qe).call(this,l)}paintImageMaskXObjectGroup(t,e){var o,l,c;if(!this.contentVisible)return;const s=v(this,nt,ws).call(this,this.current.fillAlpha),i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(t).recordDependencies(t,li.transformAndFill);for(const h of e){const{data:d,width:f,height:g,transform:b}=h,w=this.canvasFactory.create(f,g),A=w.context;A.save();const y=this.getObject(t,d,h);cy(A,y),A.globalCompositeOperation="source-in",A.fillStyle=a?r.getPattern(A,this,Xi(i),qe.FILL,t):r,A.fillRect(0,0,f,g),A.restore(),i.save(),i.transform(...b),i.scale(1,-1),uf(i,w.canvas,0,0,f,g,0,-1,1,1),this.canvasFactory.destroy(w),(l=this.dependencyTracker)==null||l.recordBBox(t,i,0,f,0,g),i.restore()}this.compose(),(c=this.dependencyTracker)==null||c.recordOperation(t),v(this,nt,Qe).call(this,s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){mt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){mt("Dependent image isn't ready yet");return}const o=a.width,l=a.height,c=[];for(let h=0,d=r.length;h<d;h+=2)c.push({transform:[s,0,0,i,r[h],r[h+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,c)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:s,height:i}=t,r=this.canvasFactory.create(s,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(t,e){var d;if(!this.contentVisible)return;const s=e.width,i=e.height,r=v(this,nt,ws).call(this,this.current.fillAlpha),a=this.ctx;this.save(t);const{filter:o}=a;o!=="none"&&o!==""&&(a.filter="none"),a.scale(1/s,-1/i);let l,c=null;if(e.bitmap){const f=this.applyTransferMapsToBitmap(e);l=f.img,c=f.canvasEntry}else{const f=this.canvasFactory.create(s,i);ly(f.context,e),l=this.applyTransferMapsToCanvas(f.context),c=f}const h=this._scaleImage(l,Xi(a));a.imageSmoothingEnabled=hy(Kt(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-i,0).recordDependencies(t,li.imageXObject).recordOperation(t),(d=this.imagesTracker)==null||d.record(a,s,i,this.dependencyTracker.clipBox)),uf(a,h.img,0,0,h.paintWidth,h.paintHeight,0,-i,s,i),h.tmpCanvas&&this.canvasFactory.destroy(h.tmpCanvas),c&&this.canvasFactory.destroy(c),this.compose(),this.restore(t),v(this,nt,Qe).call(this,r)}paintInlineImageXObjectGroup(t,e,s){var l,c,h;if(!this.contentVisible)return;const i=v(this,nt,ws).call(this,this.current.fillAlpha),r=this.ctx;let a,o=null;if(e.bitmap)a=e.bitmap;else{const d=e.width,f=e.height,g=this.canvasFactory.create(d,f);ly(g.context,e),a=this.applyTransferMapsToCanvas(g.context),o=g}(l=this.dependencyTracker)==null||l.resetBBox(t);for(const d of s)r.save(),r.transform(...d.transform),r.scale(1,-1),uf(r,a,d.x,d.y,d.w,d.h,0,-1,1,1),(c=this.dependencyTracker)==null||c.recordBBox(t,r,0,1,-1,0),r.restore();o&&this.canvasFactory.destroy(o),(h=this.dependencyTracker)==null||h.recordOperation(t),this.compose(),v(this,nt,Qe).call(this,i)}paintSolidColorImageMask(t){var s;if(!this.contentVisible)return;const e=v(this,nt,ws).call(this,this.current.fillAlpha);(s=this.dependencyTracker)==null||s.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,li.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),v(this,nt,Qe).call(this,e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===uy?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Kt(this.ctx);if(t[1]===0&&t[2]===0)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]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),c=Math.abs(r);if(l===c)if(t===0)a=o=1/l;else{const h=l*t;a=o=h<1?1/h:1}else if(t===0)a=1/l,o=1/c;else{const h=l*t,d=c*t;a=h<1?1/h:1,o=d<1?1/d:1}}else{const l=Math.abs(e*r-s*i),c=Math.hypot(e,s),h=Math.hypot(i,r);if(t===0)a=h/l,o=c/l;else{const d=t*l;a=h>d?h/d:1,o=c>d?c/d:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),bg.a=1/r,bg.d=1/a;const l=new Path2D;if(l.addPath(t,bg),o.length>0){const c=Math.max(r,a);s.setLineDash(o.map(h=>h/c)),s.lineDashOffset/=c}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};$s=new WeakMap,sa=new WeakMap,ko=new WeakMap,To=new WeakMap,Po=new WeakMap,Mo=new WeakMap,Io=new WeakMap,Do=new WeakMap,Lo=new WeakMap,cn=new WeakMap,nt=new WeakSet,em=function(){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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)},sm=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},im=function(t,e=null,s=1){const{width:i,height:r}=t,a=e??this.canvasFactory.create(i,r),o=a.context;s=Math.round(s*255)/255;const l=s<1;l&&n(this,Do)===void 0&&p(this,Do,Wt.isCanvasFilterSupported?new Map:"none");let c="none";if(l&&n(this,Do)instanceof Map&&(c=n(this,Do).getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!l||c!=="none")return e&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,i,r),o.restore()),o.filter=c,o.drawImage(t,0,0),o.filter="none",a;const h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,r),d=o.createImageData(i,r),f=h.data,g=d.data,b=s>0?1/s:1e6;for(let w=3,A=f.length;w<A;w+=4)g[w]=Math.min(Math.round(f[w]*b),255);return o.putImageData(d,0,0),a},nm=function(t,e,s,i){let r=(t==null?void 0:t[e])??null;if(r&&(r.canvas.width!==s||r.canvas.height!==i)&&(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(s,i),t&&(t[e]=r),r;const a=r.context;return a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,i),a.restore(),r},rm=function(t,e,s={}){const{backdropCanvas:i=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:l=null,sourceAlpha:c=1,sourceFilter:h="none",knockoutAlpha:d=1}=s,{width:f,height:g}=e,b=v(this,nt,im).call(this,e,o,d),w=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,Wt.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(b.canvas,0,0),i){const[A,y]=a,S=v(this,nt,nm).call(this,l,"knockoutBackdropEntry",f,g),_=S.context;_.drawImage(i,A,y,f,g,0,0,f,g),_.globalCompositeOperation="destination-in",_.drawImage(b.canvas,0,0),_.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(S.canvas,0,0),l||this.canvasFactory.destroy(S)}t.globalCompositeOperation=w,t.globalAlpha=c,Wt.isCanvasFilterSupported&&(t.filter=h??"none"),t.drawImage(e,0,0),t.restore(),o||this.canvasFactory.destroy(b)},ws=function(t=1){if(n(this,$s)===0||n(this,sa)>0||!this.contentVisible)return!1;Jt(this,sa)._++,p(this,Io,t);const e=n(this,cn).at(-1),{canvas:s}=this.ctx,i=v(this,nt,nm).call(this,e,"knockoutTempEntry",s.width,s.height);p(this,ko,i);const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),Oa(this.ctx,r),p(this,Mo,r.globalCompositeOperation),r.globalCompositeOperation="source-over",ay(r,this.ctx),p(this,Lo,e),p(this,To,this.ctx),p(this,Po,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},Qe=function(t){var l;if(!t)return;const e=n(this,ko),s=n(this,To),i=n(this,Po),r=e.context;p(this,ko,null),p(this,To,null),p(this,Po,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=n(this,Mo),p(this,Mo,null),Oa(this.ctx,s),this.ctx=s;const a=n(this,Lo);p(this,Lo,null);const o=n(this,Io);p(this,Io,1);try{v(this,nt,rm).call(this,i??s,e.canvas,{backdropCanvas:((l=a==null?void 0:a.backdropCtx)==null?void 0:l.canvas)??null,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(a==null?void 0:a.knockoutMaskEntry)??null,poolMeta:a,knockoutAlpha:o})}finally{r.restore(),Jt(this,sa)._--,a||this.canvasFactory.destroy(e)}},am=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i},Hb=function(t){const{canvas:e}=t,{width:s,height:i}=e;if(Wt.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}const r=t.getImageData(0,0,s,i),{data:a}=r;for(let o=0,l=a.length;o<l;o+=4){const c=a[o]*.2126+a[o+1]*.7152+a[o+2]*.0722+.5|0;a[o]=a[o+1]=a[o+2]=c}t.putImageData(r,0,0)},Df=function(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))};let Vl=xv;for(const u in Ki)Vl.prototype[u]!==void 0&&(Vl.prototype[Ki[u]]=Vl.prototype[u]);var Nu,Bu;class Zp{constructor(t,e,s){m(this,Nu,null);m(this,Bu,null);R(this,"_fullReader",null);R(this,"_rangeReaders",new Set);R(this,"_source",null);this._source=t,p(this,Nu,e),p(this,Bu,s)}get _progressiveDataLength(){var t;return((t=this._fullReader)==null?void 0:t._loaded)??0}getFullReader(){return he(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(n(this,Nu))(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new(n(this,Bu))(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){var e;(e=this._fullReader)==null||e.cancel(t);for(const s of new Set(this._rangeReaders))s.cancel(t)}}Nu=new WeakMap,Bu=new WeakMap;class tg{constructor(t){R(this,"onProgress",null);R(this,"_contentLength",0);R(this,"_filename",null);R(this,"_headersCapability",Promise.withResolvers());R(this,"_isRangeSupported",!1);R(this,"_isStreamingSupported",!1);R(this,"_loaded",0);R(this,"_stream",null);this._stream=t}_callOnProgress(){var t;(t=this.onProgress)==null||t.call(this,{loaded:this._loaded,total:this._contentLength})}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(){Mt("Abstract method `read` called")}cancel(t){Mt("Abstract method `cancel` called")}}class eg{constructor(t,e,s){R(this,"_stream",null);this._stream=t}async read(){Mt("Abstract method `read` called")}cancel(t){Mt("Abstract method `cancel` called")}}function C_(u){let t=!0,e=s("filename\\*","i").exec(u);if(e){e=e[1];let h=o(e);return h=unescape(h),h=l(h),h=c(h),r(h)}if(e=a(u),e){const h=c(e);return r(h)}if(e=s("filename","i").exec(u),e){e=e[1];let h=o(e);return h=c(h),r(h)}function s(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(h,{fatal:!0}),g=Kp(d);d=f.decode(g),t=!1}catch{}}return d}function r(h){return t&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),t&&(h=i("iso-8859-1",h))),h}function a(h){const d=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(h))!==null;){let[,w,A,y]=f;if(w=parseInt(w,10),w in d){if(w===0)break;continue}d[w]=[A,y]}const b=[];for(let w=0;w<d.length&&w in d;++w){let[A,y]=d[w];y=o(y),A&&(y=unescape(y),w===0&&(y=l(y))),b.push(y)}return b.join("")}function o(h){if(h.startsWith('"')){const d=h.slice(1).split('\\"');for(let f=0;f<d.length;++f){const g=d[f].indexOf('"');g!==-1&&(d[f]=d[f].slice(0,g),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function l(h){const d=h.indexOf("'");if(d===-1)return h;const f=h.slice(0,d),b=h.slice(d+1).replace(/^[^']*'/,"");return i(f,b)}function c(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,f,g,b){if(g==="q"||g==="Q")return b=b.replaceAll("_"," "),b=b.replaceAll(/=([0-9a-f]{2})/gi,function(w,A){return String.fromCharCode(parseInt(A,16))}),i(f,b);try{b=atob(b)}catch{}return i(f,b)})}return""}function zb(u,t){const e=new Headers;if(!u||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function sg(u){var t;return((t=URL.parse(u))==null?void 0:t.origin)??null}function Vb({responseHeaders:u,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={contentLength:0,isRangeSupported:!1},r=parseInt(u.get("Content-Length"),10);return!Number.isInteger(r)||(i.contentLength=r,r<=2*e)||s||!t||u.get("Accept-Ranges")!=="bytes"||(u.get("Content-Encoding")||"identity")==="identity"&&(i.isRangeSupported=!0),i}function Gb(u){const t=u.get("Content-Disposition");if(t){let e=C_(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(dv(e))return e}return null}function ig(u,t){return new lp(`Unexpected server response (${u}) while retrieving PDF "${t.href}".`,u,u===404||u===0&&t.protocol==="file:")}function jb(u,t){if(u!==t)throw new Error(`Expected range response-origin "${u}" to match "${t}".`)}function Wb(u,t,e,s){return fetch(u,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function Xb(u,t){if(u!==200&&u!==206)throw ig(u,t)}function ng(u){if(u instanceof Uint8Array)return u.buffer;if(u instanceof ArrayBuffer)return u;throw new Error(`getArrayBuffer - unexpected data: ${u}`)}class k_ extends Zp{constructor(e){super(e,T_,P_);R(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;he(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=zb(!0,s)}}class T_ extends tg{constructor(e){super(e);R(this,"_abortController",new AbortController);R(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a,withCredentials:o}=e._source;this._isStreamingSupported=!i;const l=new Headers(e.headers);Wb(a,l,o,this._abortController).then(c=>{e._responseOrigin=sg(c.url),Xb(c.status,a),this._reader=c.body.getReader();const h=c.headers,{contentLength:d,isRangeSupported:f}=Vb({responseHeaders:h,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=d,this._isRangeSupported=f,this._filename=Gb(h),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ma("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:ng(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class P_ extends eg{constructor(e,s,i){super(e,s,i);R(this,"_abortController",new AbortController);R(this,"_readCapability",Promise.withResolvers());R(this,"_reader",null);const{url:r,withCredentials:a}=e._source,o=new Headers(e.headers);o.append("Range",`bytes=${s}-${i-1}`),Wb(r,o,a,this._abortController).then(l=>{const c=sg(l.url);jb(c,e._responseOrigin),Xb(l.status,r),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:ng(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function dy(u){return u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer}function rg(){for(const u of this._requests)u.resolve({value:void 0,done:!0});this._requests.length=0}var Dp,qb;class M_ extends Zp{constructor(e){super(e,I_,D_);m(this,Dp);R(this,"_progressiveDone",!1);R(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=e,{initialData:i,progressiveDone:r}=s;if((i==null?void 0:i.length)>0){const o=dy(i);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":v(this,Dp,qb).call(this,o.begin,o.chunk);break;case"progressiveDone":(l=this._fullReader)==null||l.progressiveDone(),this._progressiveDone=!0;break}};s.transportReady(a)}getFullReader(){const e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(e,s)),i}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}Dp=new WeakSet,qb=function(e,s){const i=dy(s);if(e===void 0)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const r=this._rangeReaders.keys().find(a=>a._begin===e);he(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(i)}};var $u;class I_ extends tg{constructor(e){super(e);m(this,$u,rg.bind(this));R(this,"_done",!1);R(this,"_queuedChunks",null);R(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:i,disableStream:r}=e._source,{length:a,contentDispositionFilename:o}=s;this._queuedChunks=e._queuedChunks||[];for(const c of this._queuedChunks)this._loaded+=c.byteLength;this._done=e._progressiveDone,this._contentLength=a,this._isStreamingSupported=!r,this._isRangeSupported=!i,dv(o)&&(this._filename=o),this._headersCapability.resolve();const l=this._loaded;Promise.resolve().then(()=>{l>0&&this._loaded===l&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,n(this,$u).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&n(this,$u).call(this)}}$u=new WeakMap;var Uu;class D_ extends eg{constructor(e,s,i){super(e,s,i);m(this,Uu,rg.bind(this));R(this,"onDone",null);R(this,"_begin",-1);R(this,"_done",!1);R(this,"_queuedChunk",null);R(this,"_requests",[]);this._begin=s}_enqueue(e){var s;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),n(this,Uu).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,n(this,Uu).call(this),(s=this.onDone)==null||s.call(this)}}Uu=new WeakMap;const wg=200,fy=206;function L_(u){return typeof u!="string"?u:Kp(u).buffer}var hn,wh,Yb,Kb;class R_ extends Zp{constructor(e){super(e,F_,O_);m(this,wh);m(this,hn,new WeakMap);R(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=zb(this.isHttp,s)}_request(e){const s=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};n(this,hn).set(s,i),s.open("GET",this.url),s.withCredentials=this._source.withCredentials;for(const[r,a]of this.headers)s.setRequestHeader(r,a);return this.isHttp&&"begin"in e&&"end"in e?(s.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.validateStatus=r=>r===fy||r===wg):i.validateStatus=r=>r===wg,s.responseType="arraybuffer",he(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=v(this,wh,Kb).bind(this,s),s.onprogress=v(this,wh,Yb).bind(this,s),s.send(null),s}_abortRequest(e){n(this,hn).has(e)&&(n(this,hn).delete(e),e.abort())}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}hn=new WeakMap,wh=new WeakSet,Yb=function(e,s){var r;const i=n(this,hn).get(e);(r=i==null?void 0:i.onProgress)==null||r.call(i,s)},Kb=function(e,s){const i=n(this,hn).get(e);if(!i||(e.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),e.readyState!==4)||!n(this,hn).has(e))return;if(n(this,hn).delete(e),e.status===0&&this.isHttp){i.onError(e.status);return}const r=e.status||wg;if(!i.validateStatus(r)){i.onError(e.status);return}const a=L_(e.response);if(r===fy){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(mt('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(e.status)};var Hu,En,Qb,Jb,Zb,tw;class F_ extends tg{constructor(e){super(e);m(this,En);m(this,Hu,rg.bind(this));R(this,"_cachedChunks",[]);R(this,"_done",!1);R(this,"_requests",[]);R(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:v(this,En,Qb).bind(this),onDone:v(this,En,Jb).bind(this),onError:v(this,En,Zb).bind(this),onProgress:v(this,En,tw).bind(this)})}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 e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e),n(this,Hu).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}Hu=new WeakMap,En=new WeakSet,Qb=function(){const e=this._stream,{disableRange:s,rangeChunkSize:i}=e._source,r=this._fullRequestXhr;e._responseOrigin=sg(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(h=>{const[d,...f]=h.split(": ");return[d,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:c}=Vb({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=c,this._filename=Gb(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},Jb=function(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&n(this,Hu).call(this)},Zb=function(e){this._storedError=ig(e,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},tw=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var zu,xr,ew,sw,om;class O_ extends eg{constructor(e,s,i){super(e,s,i);m(this,xr);m(this,zu,rg.bind(this));R(this,"onClosed",null);R(this,"_done",!1);R(this,"_queuedChunk",null);R(this,"_requests",[]);R(this,"_storedError",null);this._requestXhr=e._request({begin:s,end:i,onHeadersReceived:v(this,xr,ew).bind(this),onDone:v(this,xr,sw).bind(this),onError:v(this,xr,om).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,n(this,zu).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}zu=new WeakMap,xr=new WeakSet,ew=function(){var s;const e=sg((s=this._requestXhr)==null?void 0:s.responseURL);try{jb(e,this._stream._responseOrigin)}catch(i){this._storedError=i,v(this,xr,om).call(this,0)}},sw=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,n(this,zu).call(this),(s=this.onClosed)==null||s.call(this)},om=function(e){this._storedError??(this._storedError=ig(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function iw(u,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(u,t);return s.toWeb(i)}class N_ extends Zp{constructor(t){super(t,B_,$_);const{url:e}=t;he(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class B_ extends tg{constructor(e){super(e);R(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a}=e._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const c=iw(a);this._reader=c.getReader();const{size:h}=l;this._contentLength=h,this._isRangeSupported=!s&&h>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ma("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=ig(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:ng(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class $_ extends eg{constructor(e,s,i){super(e,s,i);R(this,"_readCapability",Promise.withResolvers());R(this,"_reader",null);const{url:r}=e._source;try{const a=iw(r,{start:s,end:i-1});this._reader=a.getReader(),this._readCapability.resolve()}catch(a){this._readCapability.reject(a)}}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:ng(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function U_(u){return Kh(u)?k_:ti?N_:R_}var Vu,Gu;class Sn{static get workerPort(){return n(this,Vu)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Vu,t)}static get workerSrc(){return n(this,Gu)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Gu,t)}}Vu=new WeakMap,Gu=new WeakMap,m(Sn,Vu,null),m(Sn,Gu,"");var xc,ju;class H_{constructor({parsedData:t,rawData:e}){m(this,xc);m(this,ju);p(this,xc,t),p(this,ju,e)}getRaw(){return n(this,ju)}get(t){return n(this,xc).get(t)??null}[Symbol.iterator](){return n(this,xc).entries()}}xc=new WeakMap,ju=new WeakMap;const $a=Symbol("INTERNAL");var Wu,Xu,_c,Ro;class z_{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){m(this,Wu,!1);m(this,Xu,!1);m(this,_c,!1);m(this,Ro,!0);p(this,Wu,!!(t&Zs.DISPLAY)),p(this,Xu,!!(t&Zs.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,_c))return n(this,Ro);if(!n(this,Ro))return!1;const{print:t,view:e}=this.usage;return n(this,Wu)?(e==null?void 0:e.viewState)!=="OFF":n(this,Xu)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==$a&&Mt("Internal method `_setVisible` called."),p(this,_c,s),p(this,Ro,e)}get serializable(){return{userSet:n(this,_c),visible:n(this,Ro)}}}Wu=new WeakMap,Xu=new WeakMap,_c=new WeakMap,Ro=new WeakMap;var ia,Dt,Ec,Cc,qu,Yu,cm;const _v=class _v{constructor(t,e=Zs.DISPLAY,s=null){m(this,Yu);m(this,ia,null);m(this,Dt,new Map);m(this,Ec,null);m(this,Cc,null);m(this,qu);R(this,"creator",null);R(this,"name",null);if(p(this,qu,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,p(this,Cc,t.order);for(const i of t.groups)n(this,Dt).set(i.id,new z_(e,i));if(s){s.size!==n(this,Dt).size&&Mt("Incorrect serialized groupState.");for(const[i,r]of s)n(this,Dt).get(i)._setVisible($a,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const i of n(this,Dt).values())i._setVisible($a,!1);for(const i of t.on)n(this,Dt).get(i)._setVisible($a,!0);for(const i of t.off)n(this,Dt).get(i)._setVisible($a,!1)}p(this,Ec,this.getHash())}}isVisible(t){if(n(this,Dt).size===0)return!0;if(!t)return Yp("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,Dt).has(t.id)?n(this,Dt).get(t.id).visible:(mt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return v(this,Yu,cm).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,Dt).has(e))return mt(`Optional content group not found: ${e}`),!0;if(n(this,Dt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,Dt).has(e))return mt(`Optional content group not found: ${e}`),!0;if(!n(this,Dt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,Dt).has(e))return mt(`Optional content group not found: ${e}`),!0;if(!n(this,Dt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,Dt).has(e))return mt(`Optional content group not found: ${e}`),!0;if(n(this,Dt).get(e).visible)return!1}return!0}return mt(`Unknown optional content policy ${t.policy}.`),!0}return mt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,Dt).get(t);if(!i){mt(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((r=n(this,Dt).get(o))==null||r._setVisible($a,!1,!0));i._setVisible($a,!!e,!0),p(this,ia,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,Dt).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}p(this,ia,null)}get hasInitialVisibility(){return n(this,Ec)===null||this.getHash()===n(this,Ec)}getOrder(){return n(this,Dt).size?n(this,Cc)?n(this,Cc).slice():[...n(this,Dt).keys()]:null}getGroup(t){return n(this,Dt).get(t)||null}getHash(){if(n(this,ia)!==null)return n(this,ia);const t=new Xg;for(const[e,s]of n(this,Dt))t.update(`${e}:${s.visible}`);return p(this,ia,t.hexdigest())}[Symbol.iterator](){return n(this,Dt).entries()}get serializable(){const t=new Map;for(const[e,s]of n(this,Dt))t.set(e,s.serializable);return{data:n(this,qu),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new _v(t,e,s)}};ia=new WeakMap,Dt=new WeakMap,Ec=new WeakMap,Cc=new WeakMap,qu=new WeakMap,Yu=new WeakSet,cm=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let a;if(Array.isArray(r))a=v(this,Yu,cm).call(this,r);else if(n(this,Dt).has(r))a=n(this,Dt).get(r).visible;else return mt(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};let lm=_v;var be,Fi,Ve,Fo,un,ns,Uh,Hh,Lf;class V_{constructor(){m(this,ns);m(this,be,null);m(this,Fi,null);m(this,Ve,0);m(this,Fo,null);m(this,un,null)}get pagesNumber(){return n(this,Ve)}set pagesNumber(t){n(this,Ve)!==t&&(p(this,Ve,t),p(this,be,null),p(this,Fi,null))}movePages(t,e,s){v(this,ns,Uh).call(this);const i=n(this,be),r=v(this,ns,Hh).call(this),a=e.length,o=new Uint32Array(a);let l=0;for(let f=0;f<a;f++){const g=e[f]-1;o[f]=i[g],g<s&&l++}const c=n(this,Ve),h=c-a,d=ee(s-l,0,h);for(let f=0,g=0;f<c;f++)t.has(f+1)||(i[g++]=i[f]);i.copyWithin(d+a,d,h),i.set(o,d),v(this,ns,Lf).call(this,r),i.every((f,g)=>f===g+1)&&p(this,be,null)}deletePages(t){v(this,ns,Uh).call(this);const e=n(this,be),s=v(this,ns,Hh).call(this);p(this,un,{pageNumberToId:e.slice(),pagesNumber:n(this,Ve),prevPageNumbers:n(this,Fi).slice()});const i=n(this,Ve)-t.length;p(this,Ve,i);const r=p(this,be,new Uint32Array(i));p(this,Fi,new Int32Array(i));let a=0,o=0;for(const l of t){const c=l-1;c!==a&&(r.set(e.subarray(a,c),o),o+=c-a),a=c+1}a<e.length&&r.set(e.subarray(a),o),v(this,ns,Lf).call(this,s,new Set(t))}cancelDelete(){n(this,un)&&(p(this,be,n(this,un).pageNumberToId),p(this,Ve,n(this,un).pagesNumber),p(this,Fi,n(this,un).prevPageNumbers),p(this,un,null))}cleanSavedData(){p(this,un,null)}copyPages(t){v(this,ns,Uh).call(this),p(this,Fo,{pageNumbers:t,pageIds:t.map(e=>n(this,be)[e-1])})}cancelCopy(){p(this,Fo,null)}pastePages(t){v(this,ns,Uh).call(this);const e=n(this,be),s=v(this,ns,Hh).call(this),{pageNumbers:i,pageIds:r}=n(this,Fo),a=n(this,Ve)+i.length;p(this,Ve,a);const o=p(this,be,new Uint32Array(a));p(this,Fi,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+i.length),v(this,ns,Lf).call(this,s,null,t,i),p(this,Fo,null)}hasBeenAltered(){return n(this,be)!==null}getPageMappingForSaving(t=null){t??(t=v(this,ns,Hh).call(this));let e=0;for(const i of t.values())e=Math.max(e,i.length);const s=new Array(e);for(let i=0;i<e;i++)s[i]={document:null,pageIndices:[],includePages:[]};for(const[i,r]of t)for(let a=0,o=r.length;a<o;a++)s[a].includePages.push([i-1,r[a]-1]);for(const{includePages:i,pageIndices:r}of s){i.sort((a,o)=>a[0]-o[0]);for(let a=0,o=i.length;a<o;a++)r.push(i[a][1]),i[a]=i[a][0]}return s}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);const e=new Map;for(let s=0,i=t.length;s<i;s++){const r=this.getPageId(t[s]);e.getOrInsertComputed(r,Yd).push(s+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){var e;return((e=n(this,Fi))==null?void 0:e[t-1])??0}getPageNumber(t){if(!n(this,be))return t;const e=n(this,be);for(let s=0,i=n(this,Ve);s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){var e;return((e=n(this,be))==null?void 0:e[t-1])??t}getMapping(){var t;return(t=n(this,be))==null?void 0:t.subarray(0,this.pagesNumber)}}be=new WeakMap,Fi=new WeakMap,Ve=new WeakMap,Fo=new WeakMap,un=new WeakMap,ns=new WeakSet,Uh=function(){if(n(this,be))return;const t=n(this,Ve),e=p(this,be,new Uint32Array(t));for(let s=0;s<t;s++)e[s]=s+1;p(this,Fi,new Int32Array(e))},Hh=function(){const t=new Map,e=n(this,be);for(let s=0,i=n(this,Ve);s<i;s++){const r=e[s],a=t.get(r);a?a.push(s+1):t.set(r,[s+1])}return t},Lf=function(t,e=null,s=-1,i=null){const r=n(this,Fi),a=n(this,be),o=s+((i==null?void 0:i.length)??0),l=new Map;for(let c=0,h=n(this,Ve);c<h;c++){if(c>=s&&c<o){r[c]=-i[c-s];continue}const d=a[c],f=t.get(d);let g=l.get(d)||0;if(e&&f)for(;g<f.length&&e.has(f[g]);)g++;r[c]=f==null?void 0:f[g],l.set(d,g+1)}};const Nl=Symbol("INITIAL_DATA"),py=()=>({...Promise.withResolvers(),data:Nl});var yi;class nw{constructor(){m(this,yi,new Map)}get(t,e=null){if(e){const i=n(this,yi).getOrInsertComputed(t,py);return i.promise.then(()=>e(i.data)),null}const s=n(this,yi).get(t);if(!s||s.data===Nl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,yi).get(t);return!!e&&e.data!==Nl}delete(t){const e=n(this,yi).get(t);return!e||e.data===Nl?!1:(n(this,yi).delete(t),!0)}resolve(t,e=null){const s=n(this,yi).getOrInsertComputed(t,py);if(s.data!==Nl)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}of n(this,yi).values())(t=e==null?void 0:e.bitmap)==null||t.close();n(this,yi).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of n(this,yi))e!==Nl&&(yield[t,e])}}yi=new WeakMap;const G_=1e5,gy=30;var _y,na,hs,Ku,Qu,kc,Oo,Kn,Ju,Zu,No,td,Tc,ra,Pc,ed,Mc,Bo,sd,id,Ic,$o,nd,Dc,Lc,_r,rw,aw,hm,ii,Rf,um,ow,lw;const $e=class $e{constructor({textContentSource:t,images:e,container:s,viewport:i}){m(this,_r);m(this,na,Promise.withResolvers());m(this,hs,null);m(this,Ku,!1);m(this,Qu,!!((_y=globalThis.FontInspector)!=null&&_y.enabled));m(this,kc,null);m(this,Oo,null);m(this,Kn,null);m(this,Ju,0);m(this,Zu,0);m(this,No,null);m(this,td,null);m(this,Tc,0);m(this,ra,0);m(this,Pc,Object.create(null));m(this,ed,[]);m(this,Mc,null);m(this,Bo,[]);m(this,sd,new WeakMap);m(this,id,null);var c;if(t instanceof ReadableStream)p(this,Mc,t);else if(typeof t=="object")p(this,Mc,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,hs,p(this,td,s)),p(this,kc,e),p(this,ra,i.scale*_n.pixelRatio),p(this,Tc,i.rotation),p(this,Kn,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=i.rawDims;p(this,id,[1,0,0,-1,-o,l+a]),p(this,Zu,r),p(this,Ju,a),v(c=$e,ii,ow).call(c),s.style.setProperty("--min-font-size",n($e,Dc)),El(s,i),n(this,na).promise.finally(()=>{n($e,Lc).delete(this),p(this,Kn,null),p(this,Pc,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Wt.platform;return ft(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){n(this,kc)&&n(this,hs).append(n(this,kc).render());const t=()=>{n(this,No).read().then(({value:e,done:s})=>{if(s){n(this,na).resolve();return}n(this,Oo)??p(this,Oo,e.lang),Object.assign(n(this,Pc),e.styles),v(this,_r,rw).call(this,e.items),t()},n(this,na).reject)};return p(this,No,n(this,Mc).getReader()),n($e,Lc).add(this),t(),n(this,na).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*_n.pixelRatio,i=t.rotation;if(i!==n(this,Tc)&&(e==null||e(),p(this,Tc,i),El(n(this,td),{rotation:i})),s!==n(this,ra)){e==null||e(),p(this,ra,s);const a={div:null,properties:null,ctx:v(r=$e,ii,Rf).call(r,n(this,Oo))};for(const o of n(this,Bo))a.properties=n(this,sd).get(o),a.div=o,v(this,_r,hm).call(this,a)}}cancel(){var e;const t=new Ma("TextLayer task cancelled.");(e=n(this,No))==null||e.cancel(t).catch(()=>{}),p(this,No,null),n(this,na).reject(t)}get textDivs(){return n(this,Bo)}get textContentItemsStr(){return n(this,ed)}static cleanup(){if(!(n(this,Lc).size>0)){n(this,Ic).clear();for(const{canvas:t}of n(this,$o).values())t.remove();n(this,$o).clear()}}};na=new WeakMap,hs=new WeakMap,Ku=new WeakMap,Qu=new WeakMap,kc=new WeakMap,Oo=new WeakMap,Kn=new WeakMap,Ju=new WeakMap,Zu=new WeakMap,No=new WeakMap,td=new WeakMap,Tc=new WeakMap,ra=new WeakMap,Pc=new WeakMap,ed=new WeakMap,Mc=new WeakMap,Bo=new WeakMap,sd=new WeakMap,id=new WeakMap,Ic=new WeakMap,$o=new WeakMap,nd=new WeakMap,Dc=new WeakMap,Lc=new WeakMap,_r=new WeakSet,rw=function(t){var i,r;if(n(this,Ku))return;(r=n(this,Kn)).ctx??(r.ctx=v(i=$e,ii,Rf).call(i,n(this,Oo)));const e=n(this,Bo),s=n(this,ed);for(const a of t){if(e.length>G_){mt("Ignoring additional textDivs for performance reasons."),p(this,Ku,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,hs);p(this,hs,document.createElement("span")),n(this,hs).classList.add("markedContent"),a.id&&n(this,hs).setAttribute("id",`${a.id}`),a.tag==="Artifact"&&(n(this,hs).ariaHidden=!0),o.append(n(this,hs))}else a.type==="endMarkedContent"&&p(this,hs,n(this,hs).parentNode);continue}s.push(a.str),v(this,_r,aw).call(this,a)}},aw=function(t){var b;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,Bo).push(e);const i=j.transform(n(this,id),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,Pc)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,Qu)&&a.fontSubstitution||a.fontFamily;o=$e.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),c=l*v(b=$e,ii,lw).call(b,o,a,n(this,Oo));let h,d;r===0?(h=i[4],d=i[5]-c):(h=i[4]+c*Math.sin(r),d=i[5]-c*Math.cos(r));const f=e.style;f.left=`${(100*h/n(this,Zu)).toFixed(2)}%`,f.top=`${(100*d/n(this,Ju)).toFixed(2)}%`,f.setProperty("--font-height",`${l.toFixed(2)}px`),f.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,Qu)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const w=Math.abs(t.transform[0]),A=Math.abs(t.transform[3]);w!==A&&Math.max(w,A)/Math.min(w,A)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,sd).set(e,s),n(this,Kn).div=e,n(this,Kn).properties=s,v(this,_r,hm).call(this,n(this,Kn)),s.hasText&&n(this,hs).append(e),s.hasEOL){const w=document.createElement("br");w.setAttribute("role","presentation"),n(this,hs).append(w)}},hm=function(t){var a;const{div:e,properties:s,ctx:i}=t,{style:r}=e;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:o}=r,{canvasWidth:l,fontSize:c}=s;v(a=$e,ii,um).call(a,i,c*n(this,ra),o);const{width:h}=i.measureText(e.textContent);h>0&&r.setProperty("--scale-x",l*n(this,ra)/h)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},ii=new WeakSet,Rf=function(t=null){let e=n(this,$o).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,$o).set(t,e),n(this,nd).set(e,{size:0,family:""})}return e},um=function(t,e,s){const i=n(this,nd).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},ow=function(){if(n(this,Dc)!==null)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),p(this,Dc,t.getBoundingClientRect().height),t.remove()},lw=function(t,e,s){const i=n(this,Ic).get(t);if(i)return i;const r=v(this,ii,Rf).call(this,s);r.canvas.width=r.canvas.height=gy,v(this,ii,um).call(this,r,gy,t);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let c=.8;return o?c=o/(o+l):(Wt.platform.isFirefox&&mt("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?c=e.ascent:e.descent&&(c=1+e.descent)),n(this,Ic).set(t,c),c},m($e,ii),m($e,Ic,new Map),m($e,$o,new Map),m($e,nd,new WeakMap),m($e,Dc,null),m($e,Lc,new Set);let yh=$e;const j_=100;function cw(u={}){const t=new dm,{docId:e}=t,s=u.url?Qx(u.url):null,i=u.data?Jx(u.data):null,r=u.httpHeaders||null,a=u.withCredentials===!0,o=u.password??null,l=u.range instanceof hw?u.range:null,c=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:2**16;let h=u.worker instanceof nu?u.worker:null;const d=u.verbosity,f=typeof u.docBaseUrl=="string"&&!Qp(u.docBaseUrl)?u.docBaseUrl:null,g=cf(u.cMapUrl),b=u.cMapPacked!==!1,w=cf(u.iccUrl),A=cf(u.standardFontDataUrl),y=cf(u.wasmUrl),S=u.stopAtErrors!==!0,_=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,C=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!ti,E=typeof u.isImageDecoderSupported=="boolean"?u.isImageDecoderSupported:!ti,k=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,D=typeof u.disableFontFace=="boolean"?u.disableFontFace:ti,M=u.fontExtraProperties===!0,F=u.enableXfa===!0,B=u.ownerDocument||globalThis.document,I=u.disableRange===!0,T=u.disableStream===!0,N=u.disableAutoFetch===!0,H=u.pdfBug===!0,Z=u.CanvasFactory||(ti?a_:s_),P=u.FilterFactory||(ti?r_:i_),K=u.BinaryDataFactory||(ti?o_:iy),z=u.enableHWA===!0,_t=u.enableWebGPU===!0?u_():Promise.resolve(!1),Ut=u.useWasm!==!1,Ot=u.pagesMapper||new V_,X=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!ti&&!D,W=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:!!(K===iy&&g&&b&&A&&y&&Kh(g,document.baseURI)&&Kh(A,document.baseURI)&&Kh(y,document.baseURI)),gt=null;wx(d);const rt={canvasFactory:new Z({ownerDocument:B,enableHWA:z}),filterFactory:new P({docId:e,ownerDocument:B}),binaryDataFactory:W?null:new K({cMapUrl:g,standardFontDataUrl:A,wasmUrl:y})};h||(h=nu.create({verbosity:d,port:Sn.workerPort}),t._worker=h);const ut={docId:e,apiVersion:"6.1.200",data:i,password:o,disableAutoFetch:N,rangeChunkSize:c,docBaseUrl:f,enableXfa:F,evaluatorOptions:{maxImageSize:_,disableFontFace:D,ignoreErrors:S,isOffscreenCanvasSupported:C,isImageDecoderSupported:E,canvasMaxAreaInBytes:k,fontExtraProperties:M,useSystemFonts:X,useWasm:Ut,useWorkerFetch:W,cMapUrl:g,cMapPacked:b,iccUrl:w,standardFontDataUrl:A,wasmUrl:y,hasGPU:!1}},Qt={ownerDocument:B,pdfBug:H,styleElement:gt,enableHWA:z,loadingParams:{disableAutoFetch:N,enableXfa:F}};return Promise.all([h.promise,_t]).then(function([,ys]){if(h.destroyed)throw new Error("Worker was destroyed");ut.evaluatorOptions.hasGPU=ys;const ai=h.messageHandler.sendWithPromise("GetDocRequest",ut,i?[i.buffer]:null);let ji;if(!i)if(l)ji=new M_({pdfDataRangeTransport:l,disableRange:I,disableStream:T});else if(s){const as=U_(s);ji=new as({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:c,disableRange:I,disableStream:T})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return ai.then(as=>{if(h.destroyed)throw new Error("Worker was destroyed");const kn=new Fh(e,as,h.port),La=new X_(kn,t,ji,Qt,rt,Ot);if(t._transport=La,t.destroyed)throw new Error("Loading aborted");kn.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var Lp;const Rp=class Rp{constructor(){R(this,"_capability",Promise.withResolvers());R(this,"_setupCapability",Promise.withResolvers());R(this,"_transport",null);R(this,"_worker",null);R(this,"docId",`d${Jt(Rp,Lp)._++}`);R(this,"destroyed",!1);R(this,"onPassword",null);R(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0,this._capability.promise.catch(()=>{});try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Lp=new WeakMap,m(Rp,Lp,0);let dm=Rp;var Rc,Uo;class hw{constructor(t,e,s=!1,i=null){m(this,Rc,Promise.withResolvers());m(this,Uo,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){n(this,Uo).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){n(this,Rc).promise.then(()=>{n(this,Uo).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){n(this,Rc).promise.then(()=>{n(this,Uo).call(this,{type:"progressiveDone"})})}transportReady(t){p(this,Uo,t),n(this,Rc).resolve()}requestDataRange(t,e){Mt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Rc=new WeakMap,Uo=new WeakMap;class W_{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}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 ft(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()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}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()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}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()}}var Qn,Ho,zo,zh;const Ev=class Ev{constructor(t,e,s,i,r=!1){m(this,zo);m(this,Qn,!1);m(this,Ho,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new Wv:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new nw,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,p(this,Ho,i),this.imageCoordinates=null}clone(t){const e=new Ev(t,this._pageInfo,this._transport,n(this,Ho),this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new Kd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}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 ft(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=Pr.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:c=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:f=!1,recordImages:g=!1,recordOperations:b=!1,operationsFilter:w=null}){var N,H,Z;(N=this._stats)==null||N.time("Overall");const A=this._transport.getRenderingIntent(i,r,d,f),{renderingIntent:y,cacheKey:S}=A;p(this,Qn,!1),l||(l=this._transport.getOptionalContentConfig(y));const _=this._intentStates.getOrInsertComputed(S,Tg);_.streamReaderCancelTimeout&&(clearTimeout(_.streamReaderCancelTimeout),_.streamReaderCancelTimeout=null);const C=!!(y&Zs.PRINT);_.displayReadyCapability||(_.displayReadyCapability=Promise.withResolvers(),_.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(H=this._stats)==null||H.time("Page Request"),this._pumpOperatorList(A));const E=!!(this._pdfBug&&((Z=globalThis.StepperManager)!=null&&Z.enabled)),k=!!e&&!this.recordedBBoxes&&(b||E),D=!!e&&!this.imageCoordinates&&g,M=P=>{var K,z,Et,_t;if(_.renderTasks.delete(I),k){const Ut=(K=I.gfx)==null?void 0:K.dependencyTracker.take();Ut&&((z=I.stepper)==null||z.setOperatorBBoxes(Ut,I.gfx.dependencyTracker.takeDebugMetadata()),b&&(this.recordedBBoxes=Ut))}D&&!P&&(this.imageCoordinates=(Et=I.gfx)==null?void 0:Et.imagesTracker.take()),C&&p(this,Qn,!0),v(this,zo,zh).call(this),P?(I.capability.reject(P),this._abortOperatorList({intentState:_,reason:P instanceof Error?P:new Error(P)})):I.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(_t=globalThis.Stats)!=null&&_t.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let F=null,B=null;(k||D)&&(B=new zx(e,_.operatorList.length)),k&&(F=new Vx(B,E));const I=new pm({callback:M,params:{canvas:e,canvasContext:t,dependencyTracker:F??B,imagesTracker:D?new Kg(e):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:_.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!C,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:w});(_.renderTasks||(_.renderTasks=new Set)).add(I);const T=I.task;return Promise.all([_.displayReadyCapability.promise,l]).then(([P,K])=>{var z;if(this.destroyed){M();return}if((z=this._stats)==null||z.time("Rendering"),!(K.renderingIntent&y))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:P,optionalContentConfig:K}),I.operatorListChanged()}).catch(M),T}getOperatorList({intent:t="display",annotationMode:e=Pr.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,Tg);let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:n(this,Ho).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>eu.textContent(i));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const i of e)s.lang??(s.lang=i.lang),Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}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 s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,Qn,!1),Promise.all(t)}cleanup(t=!1){p(this,Qn,!0);const e=v(this,zo,zh).call(this);return t&&e&&this._stats&&(this._stats=new Wv),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&v(this,zo,zh).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:n(this,Ho).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},void 0,a).getReader(),c=this._intentStates.get(e);c.streamReader=l;const h=()=>{l.read().then(({value:d,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),h())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();v(this,zo,zh).call(this)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof uv){let i=j_;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new Ma(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}};Qn=new WeakMap,Ho=new WeakMap,zo=new WeakSet,zh=function(){if(!n(this,Qn)||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(),p(this,Qn,!1),!0};let fm=Ev;var aa,Oi,Jn,Vo,Fp,Go,jo,ms,Ff,uw,dw,Vh,Fc,Of;const de=class de{constructor({name:t=null,port:e=null,verbosity:s=Ax()}={}){m(this,ms);m(this,aa,Promise.withResolvers());m(this,Oi,null);m(this,Jn,null);m(this,Vo,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(de,jo).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(de,jo).set(e,this),v(this,ms,uw).call(this,e)}else v(this,ms,dw).call(this)}get promise(){return n(this,aa).promise}get port(){return n(this,Jn)}get messageHandler(){return n(this,Oi)}destroy(){var t,e;this.destroyed=!0,(t=n(this,Vo))==null||t.terminate(),p(this,Vo,null),n(de,jo).delete(n(this,Jn)),p(this,Jn,null),(e=n(this,Oi))==null||e.destroy(),p(this,Oi,null)}static create(t){const e=n(this,jo).get(t==null?void 0: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 de(t)}static get workerSrc(){if(Sn.workerSrc)return Sn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ft(this,"_setupFakeWorkerGlobal",(async()=>n(this,Fc,Of)?n(this,Fc,Of):(await import(this.workerSrc)).WorkerMessageHandler)())}};aa=new WeakMap,Oi=new WeakMap,Jn=new WeakMap,Vo=new WeakMap,Fp=new WeakMap,Go=new WeakMap,jo=new WeakMap,ms=new WeakSet,Ff=function(){n(this,aa).resolve(),n(this,Oi).send("configure",{verbosity:this.verbosity})},uw=function(t){p(this,Jn,t),p(this,Oi,new Fh("main","worker",t)),n(this,Oi).on("ready",()=>{}),v(this,ms,Ff).call(this)},dw=function(){if(n(de,Go)||n(de,Fc,Of)){v(this,ms,Vh).call(this);return}let{workerSrc:t}=de;try{de._isSameOrigin(window.location,t)||(t=de._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Fh("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,aa).reject(new Error("Worker was destroyed")):v(this,ms,Vh).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,Vo)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}p(this,Oi,s),p(this,Jn,e),p(this,Vo,e),v(this,ms,Ff).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{v(this,ms,Vh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Yp("The worker has been disabled.")}v(this,ms,Vh).call(this)},Vh=function(){n(de,Go)||(mt("Setting up fake worker."),p(de,Go,!0)),de._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,aa).reject(new Error("Worker was destroyed"));return}const e=new e_;p(this,Jn,e);const s=`fake${Jt(de,Fp)._++}`,i=new Fh(s+"_worker",s,e);t.setup(i,e),p(this,Oi,new Fh(s,s+"_worker",e)),v(this,ms,Ff).call(this)}).catch(t=>{n(this,aa).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Fc=new WeakSet,Of=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},m(de,Fc),m(de,Fp,0),m(de,Go,!1),m(de,jo,new WeakMap),ti&&(p(de,Go,!0),Sn.workerSrc||(Sn.workerSrc="./pdf.worker.mjs")),de._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},de._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let nu=de;var Us,Wo,Zn,Ni,Xo,Oc,tr,Gi,Gh,Nf;class X_{constructor(t,e,s,i,r,a){m(this,Gi);R(this,"downloadInfoCapability",Promise.withResolvers());m(this,Us,null);m(this,Wo,new Map);m(this,Zn,null);m(this,Ni,new Map);m(this,Xo,new Map);m(this,Oc,new Map);m(this,tr,null);this.messageHandler=t,this.loadingTask=e,p(this,Zn,s),this.commonObjs=new nw,this.fontLoader=new Gx({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;n(this,Ni).set(e,t),n(this,Xo).set(e,Promise.resolve(t))}get annotationStorage(){return ft(this,"annotationStorage",new fv)}getRenderingIntent(t,e=Pr.ENABLE,s=null,i=!1,r=!1){let a=Zs.DISPLAY,o=su;switch(t){case"any":a=Zs.ANY;break;case"display":break;case"print":a=Zs.PRINT;break;default:mt(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Zs.PRINT&&s instanceof Cb?s:this.annotationStorage;switch(e){case Pr.DISABLE:a+=Zs.ANNOTATIONS_DISABLE;break;case Pr.ENABLE:break;case Pr.ENABLE_FORMS:a+=Zs.ANNOTATIONS_FORMS;break;case Pr.ENABLE_STORAGE:a+=Zs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:mt(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Zs.IS_EDITING),r&&(a+=Zs.OPLIST);const{ids:c,hash:h}=l.modifiedIds,d=[a,o.hash,h];return{renderingIntent:a,cacheKey:d.join("_"),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,tr))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,Ni).values())t.push(i._destroy());n(this,Ni).clear(),n(this,Xo).clear(),n(this,Oc).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,Wo).clear(),this.filterFactory.destroy(),yh.cleanup(),(i=n(this,Zn))==null||i.cancelAllRequests(new Ma("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{he(n(this,Zn),"GetReader - no `BasePDFStream` instance available."),p(this,Us,n(this,Zn).getFullReader()),n(this,Us).onProgress=r=>v(this,Gi,Nf).call(this,r),i.onPull=()=>{n(this,Us).read().then(function({value:r,done:a}){if(a){i.close();return}he(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n(this,Us).cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await n(this,Us).headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=n(this,Us);return i&&r&&(n(this,Us).onProgress=null),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{he(n(this,Zn),"GetRangeReader - no `BasePDFStream` instance available.");const r=n(this,Zn).getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}he(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new W_(s,this))}),t.on("DocException",s=>{e._capability.reject(As(s))}),t.on("PasswordRequest",s=>{p(this,tr,Promise.withResolvers());try{if(!e.onPassword)throw As(s);const i=r=>{r instanceof Error?n(this,tr).reject(r):n(this,tr).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,tr).reject(i)}return n(this,tr).promise}),t.on("DataLoaded",s=>{v(this,Gi,Nf).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,Ni).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const f=r.error;mt(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new qx(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,c=new jx(o,l,r.charProcOperatorList,r.extra);this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{c.fontExtraProperties||c.clearData(),this.commonObjs.resolve(s,c)});break;case"CopyLocalImage":const{imageRef:h}=r;he(h,"The imageRef must be defined.");for(const f of n(this,Ni).values())for(const[,g]of f.objs){if((g==null?void 0:g.ref)!==h)continue;if(!g.dataLen)return null;const b=structuredClone(g);return this.commonObjs.resolve(s,b),g.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new Kx(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const d=new Yx(r);this.commonObjs.resolve(s,d.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,Ni).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{this.destroyed||v(this,Gi,Nf).call(this,s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&mt("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:((s=n(this,Us))==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){var r;const e={pageInfos:t};let s;const i=globalThis.ImageBitmap;if(typeof i=="function"){const a=Array.isArray(t)?t:[t];for(const o of a)(o==null?void 0:o.image)instanceof i&&(s||(s=[])).push(o.image)}if(this.annotationStorage.size>0){const a=this.annotationStorage.serializable;let{map:o}=a;(r=a.transfer)!=null&&r.length&&(s?s.push(...a.transfer):s=a.transfer);const l=this.pagesMapper.getMapping();if(l){const c=new Map;for(const[h,d]of o){if((d==null?void 0:d.pageIndex)!==void 0&&d.pageIndex>=0&&d.pageIndex<l.length){const f=l[d.pageIndex]-1;if(f!==d.pageIndex){c.set(h,{...d,pageIndex:f});continue}}c.set(h,d)}o=c}e.annotationStorage=o}return this.messageHandler.sendWithPromise("ExtractPages",e,s).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,i=n(this,Xo).get(e);if(i)return i;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&n(this,Oc).set(a.refStr,s);const o=new fm(e,a,this,this.pagesMapper,this._params.pdfBug);return n(this,Ni).set(e,o),o});return n(this,Xo).set(e,r),r}async getPageIndex(t){if(!Jg(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return v(this,Gi,Gh).call(this,"GetFieldObjects")}hasJSActions(){return v(this,Gi,Gh).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?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)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return v(this,Gi,Gh).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return v(this,Gi,Gh).call(this,"GetOptionalContentConfig").then(e=>new lm(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return n(this,Wo).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,i;return{info:e[0],metadata:e[1]?new H_(e[1]):null,contentDispositionFilename:((s=n(this,Us))==null?void 0:s.filename)??null,contentLength:((i=n(this,Us))==null?void 0:i.contentLength)??null,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,Ni).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,Wo).clear(),this.filterFactory.destroy(!0),yh.cleanup()}}cachedPageNumber(t){if(!Jg(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=n(this,Oc).get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}Us=new WeakMap,Wo=new WeakMap,Zn=new WeakMap,Ni=new WeakMap,Xo=new WeakMap,Oc=new WeakMap,tr=new WeakMap,Gi=new WeakSet,Gh=function(t,e=null){return n(this,Wo).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},Nf=function({loaded:t,total:e}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:t,total:e,percent:e?ee(Math.round(t/e*100),0,100):NaN})};class q_{constructor(t){R(this,"_internalRenderTask",null);R(this,"onContinue",null);R(this,"onError",null);this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&(e==null?void 0:e.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var oa,qo;const Ga=class Ga{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:f=null,enableHWA:g=!1,operationsFilter:b=null}){m(this,oa,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new q_(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=g,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=b}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var c,h;if(this.cancelled)return;if(this._canvas){if(n(Ga,qo).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.");n(Ga,qo).add(this._canvas)}this._pdfBug&&((c=globalThis.StepperManager)!=null&&c.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Vl(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,oa)&&(window.cancelAnimationFrame(n(this,oa)),p(this,oa,null)),n(Ga,qo).delete(this._canvas),t||(t=new uv(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(i=this.task).onError)==null||r.call(i,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?p(this,oa,window.requestAnimationFrame(()=>{p(this,oa,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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n(Ga,qo).delete(this._canvas),this.callback())))}};oa=new WeakMap,qo=new WeakMap,m(Ga,qo,new WeakSet);let pm=Ga;const Y_="6.1.200",K_="6353acefe";var Hs,Yo,Nc,ke,rd,Bc,er,ad,la,Bi,od,Xt,gm,mm,vm,Ua,fw,Tr;const xs=class xs{constructor({editor:t=null,uiManager:e=null}){m(this,Xt);m(this,Hs,null);m(this,Yo,null);m(this,Nc);m(this,ke,null);m(this,rd,!1);m(this,Bc,!1);m(this,er,null);m(this,ad);m(this,la,null);m(this,Bi,null);var s,i;t?(p(this,Bc,!1),p(this,er,t)):p(this,Bc,!0),p(this,Bi,(t==null?void 0:t._uiManager)||e),p(this,ad,n(this,Bi)._eventBus),p(this,Nc,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,Bi))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n(xs,od)||p(xs,od,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"}))}static get _keyboardManager(){return ft(this,"_keyboardManager",new Cl([[["Escape"],xs.prototype._hideDropdownFromKeyboard],[["Space"],xs.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],xs.prototype._moveToNext],[["ArrowUp","ArrowLeft"],xs.prototype._moveToPrevious],[["Home"],xs.prototype._moveToBeginning],[["End"],xs.prototype._moveToEnd]]))}renderButton(){const t=p(this,Hs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,er)&&(t.ariaControls=`${n(this,er).id}_colorpicker_dropdown`);const e=n(this,Bi)._signal;t.addEventListener("click",v(this,Xt,Ua).bind(this),{signal:e}),t.addEventListener("keydown",v(this,Xt,vm).bind(this),{signal:e});const s=p(this,Yo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,Nc),t.append(s),t}renderMainDropdown(){const t=p(this,ke,v(this,Xt,gm).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,Hs)){v(this,Xt,Ua).call(this,t);return}const e=t.target.getAttribute("data-color");e&&v(this,Xt,mm).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,Xt,Tr)){v(this,Xt,Ua).call(this,t);return}if(t.target===n(this,Hs)){(e=n(this,ke).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,ke))==null?void 0:e.firstElementChild)||t.target===n(this,Hs)){n(this,Xt,Tr)&&this._hideDropdownFromKeyboard();return}n(this,Xt,Tr)||v(this,Xt,Ua).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,Xt,Tr)){v(this,Xt,Ua).call(this,t);return}(e=n(this,ke).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,Xt,Tr)){v(this,Xt,Ua).call(this,t);return}(e=n(this,ke).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,ke))==null||t.classList.add("hidden"),n(this,Hs).ariaExpanded="false",(e=n(this,la))==null||e.abort(),p(this,la,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,Bc)){if(!n(this,Xt,Tr)){(t=n(this,er))==null||t.unselect();return}this.hideDropdown(),n(this,Hs).focus({preventScroll:!0,focusVisible:n(this,rd)})}}updateColor(t){if(n(this,Yo)&&(n(this,Yo).style.backgroundColor=t),!n(this,ke))return;const e=n(this,Bi).highlightColors.values();for(const s of n(this,ke).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,Hs))==null||t.remove(),p(this,Hs,null),p(this,Yo,null),(e=n(this,ke))==null||e.remove(),p(this,ke,null)}};Hs=new WeakMap,Yo=new WeakMap,Nc=new WeakMap,ke=new WeakMap,rd=new WeakMap,Bc=new WeakMap,er=new WeakMap,ad=new WeakMap,la=new WeakMap,Bi=new WeakMap,od=new WeakMap,Xt=new WeakSet,gm=function(){const t=document.createElement("div"),e=n(this,Bi)._signal;t.addEventListener("contextmenu",Ei,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,er)&&(t.id=`${n(this,er).id}_colorpicker_dropdown`);for(const[s,i]of n(this,Bi).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n(xs,od)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,Nc),r.addEventListener("click",v(this,Xt,mm).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",v(this,Xt,vm).bind(this),{signal:e}),t},mm=function(t,e){e.stopPropagation(),n(this,ad).dispatch("switchannotationeditorparams",{source:this,type:vt.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},vm=function(t){xs._keyboardManager.exec(this,t)},Ua=function(t){if(n(this,Xt,Tr)){this.hideDropdown();return}if(p(this,rd,t.detail===0),n(this,la)||(p(this,la,new AbortController),window.addEventListener("pointerdown",v(this,Xt,fw).bind(this),{signal:n(this,Bi).combinedSignal(n(this,la))})),n(this,Hs).ariaExpanded="true",n(this,ke)){n(this,ke).classList.remove("hidden");return}const e=p(this,ke,v(this,Xt,gm).call(this));n(this,Hs).append(e)},fw=function(t){var e;(e=n(this,ke))!=null&&e.contains(t.target)||this.hideDropdown()},Tr=function(){return n(this,ke)&&!n(this,ke).classList.contains("hidden")},m(xs,od,null);let dp=xs;var zs,$c,Ko,sr,ld;const ja=class ja{constructor(t){m(this,zs,null);m(this,$c,!1);m(this,Ko,null);m(this,sr,null);p(this,Ko,t),p(this,sr,t._uiManager),n(ja,ld)||p(ja,ld,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,zs))return n(this,zs);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:a}=n(this,Ko),o=p(this,$c,Wt.isAlphaColorInputSupported&&i!==void 0),l=p(this,zs,document.createElement("input"));if(l.type="color",o){l.setAttribute("alpha","");const c=j.hexNums[Math.round((a??1)*255)];l.value=(r||"#000000")+c}else l.value=r||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",n(ja,ld)[t]),l.addEventListener("input",()=>{if(o){const c=Qd(l.value);if(!c)return;const[h,d,f,g]=c,b=j.makeHexColor(h,d,f);s!==void 0?n(this,sr).updateParams(s,{color:b,opacity:g}):(n(this,sr).updateParams(e,b),n(this,sr).updateParams(i,g))}else n(this,sr).updateParams(e,l.value)},{signal:n(this,sr)._signal}),l}update(t){if(n(this,zs))if(n(this,$c)){const e=j.hexNums[Math.round(n(this,Ko).opacity*255)];n(this,zs).value=t+e}else n(this,zs).value=t}updateOpacity(t){if(!n(this,zs)||!n(this,$c))return;const e=j.hexNums[Math.round(t*255)];n(this,zs).value=n(this,Ko).color+e}destroy(){var t;(t=n(this,zs))==null||t.remove(),p(this,zs,null)}hideDropdown(){}};zs=new WeakMap,$c=new WeakMap,Ko=new WeakMap,sr=new WeakMap,ld=new WeakMap,m(ja,ld,null);let fp=ja;function my(u){return Math.floor(ee(u,0,1)*255).toString(16).padStart(2,"0")}function Eh(u){return ee(u,0,1)*255}class vy{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Eh(t),[t,t,t]}static G_HTML([t]){const e=my(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Eh)}static RGB_HTML(t){return`#${t.map(my).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Eh(1-Math.min(1,t+i)),Eh(1-Math.min(1,s+i)),Eh(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class Q_{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Mt("Abstract method `_createSVG` called.")}}class pp extends Q_{_createSVG(t){return document.createElementNS(Fs,t)}}const J_=9,Tl=new WeakSet,Z_=new Date().getTimezoneOffset()*60*1e3;class Ag{static create(t){switch(t.data.annotationType){case ue.LINK:return new gv(t);case ue.TEXT:return new eE(t);case ue.WIDGET:switch(t.data.fieldType){case"Tx":return new sE(t);case"Btn":return t.data.radioButton?new rE(t):t.data.checkBox?new nE(t):new aE(t);case"Ch":return new oE(t);case"Sig":return new iE(t)}return new Dl(t);case ue.POPUP:return new bm(t);case ue.FREETEXT:return new ww(t);case ue.LINE:return new cE(t);case ue.SQUARE:return new hE(t);case ue.CIRCLE:return new uE(t);case ue.POLYLINE:return new Aw(t);case ue.CARET:return new fE(t);case ue.INK:return new mv(t);case ue.POLYGON:return new dE(t);case ue.HIGHLIGHT:return new Sw(t);case ue.UNDERLINE:return new pE(t);case ue.SQUIGGLY:return new gE(t);case ue.STRIKEOUT:return new mE(t);case ue.STAMP:return new xw(t);case ue.FILEATTACHMENT:return new vE(t);case ue.RICHMEDIA:case ue.SCREEN:return new _w(t);default:return new ae(t)}}}var Qo,Uc,bi,cd,ym;const Cv=class Cv{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){m(this,cd);m(this,Qo,null);m(this,Uc,!1);m(this,bi,null);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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Cv._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],r=e[l+2]):e[l+1]===a&&(r=Math.max(r,e[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let c=0,h=l.length;c<h;c+=2)l[c+1]>a?(a=l[c+1],r=l[c]):l[c+1]===a&&(r=Math.max(r,l[c]));if(r!==1/0)return[r,a]}return i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/i,t}get commentText(){var e,s,i;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${tu}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((i=t.contentsObj)==null?void 0:i.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${tu}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=n(this,bi))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,bi,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,Qo)||p(this,Qo,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&v(this,cd,ym).call(this,e);let i=((r=n(this,bi))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,bi).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,bi,null),this.popup=null))}resetEdited(){var t;n(this,Qo)&&(v(this,cd,ym).call(this,n(this,Qo).rect),(t=n(this,bi))==null||t.popup.resetEdited(),p(this,Qo,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Dl)&&!(this instanceof gv)&&!(this instanceof _w)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof bm){const{rotation:w}=e;return!e.hasOwnCanvas&&w!==0&&this.setRotation(w,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const w=e.borderStyle.horizontalCornerRadius,A=e.borderStyle.verticalCornerRadius;if(w>0||A>0){const S=`calc(${w}px * var(--total-scale-factor)) / calc(${A}px * var(--total-scale-factor))`;a.borderRadius=S}switch(e.borderStyle.style){case Fl.SOLID:a.borderStyle="solid";break;case Fl.DASHED:a.borderStyle="dashed";break;case Fl.BEVELED:mt("Unimplemented border style: beveled");break;case Fl.INSET:mt("Unimplemented border style: inset");break;case Fl.UNDERLINE:a.borderBottomStyle="solid";break}const y=e.borderColor||null;y?(p(this,Uc,!0),a.borderColor=j.makeHexColor(...y)):a.borderWidth=0}const c=j.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:d,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(c[0]-f)/h}%`,a.top=`${100*(c[1]-g)/d}%`;const{rotation:b}=e;return e.hasOwnCanvas||b===0?(a.width=`${100*o/h}%`,a.height=`${100*l/d}%`):this.setRotation(b,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=vy[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:vy[`${a}_rgb`](o)})};return ft(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const r=t[i]||s[i];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(w=>Math.fround(w));if(t.length===8){const[w,A,y,S]=t.subarray(2,6);if(i===w&&r===A&&e===y&&s===S)return}const{style:a}=this.container;let o;if(n(this,Uc)){const{borderColor:w,borderWidth:A}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Fs}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${w}" stroke-width="${A}">`],this.container.classList.add("hasBorder")}const l=i-e,c=r-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const f=h.createElement("defs");d.append(f);const g=h.createElement("clipPath"),b=`clippath_${this.data.id}`;g.setAttribute("id",b),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let w=2,A=t.length;w<A;w+=8){const y=t[w],S=t[w+1],_=t[w+2],C=t[w+3],E=h.createElement("rect"),k=(_-e)/l,D=(r-S)/c,M=(y-_)/l,F=(S-C)/c;E.setAttribute("x",k),E.setAttribute("y",D),E.setAttribute("width",M),E.setAttribute("height",F),g.append(E),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${k}" y="${D}" width="${M}" height="${F}"/>`)}n(this,Uc)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${b})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate),p(this,bi,new bm({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(n(this,bi)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,bi)}render(){Mt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,c=document.querySelector(`[data-element-id="${a}"]`);if(c&&!Tl.has(c)){mt(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&Tl.has(i)&&s.push({id:a,exportValue:r,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.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",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":j.makeHexColor(...e)}};Qo=new WeakMap,Uc=new WeakMap,bi=new WeakMap,cd=new WeakSet,ym=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let ae=Cv;class tE extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}var si,Ha,pw,gw;class gv extends ae{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});m(this,si);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),r=!0):e.attachment?(v(this,si,pw).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(v(this,si,gw).call(this,i,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=i,this.container.append(i)),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&v(this,si,Ha).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),v(this,si,Ha).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),v(this,si,Ha).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),v(this,si,Ha).call(this),!this._fieldObjects){mt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var d;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const g of r){const b=this._fieldObjects[g]||[];for(const{id:w}of b)f.add(w)}for(const g of Object.values(this._fieldObjects))for(const b of g)f.has(b.id)===o&&l.push(b)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const c=this.annotationStorage,h=[];for(const f of l){const{id:g}=f;switch(h.push(g),f.type){case"text":{const w=f.defaultValue||"";c.setValue(g,{value:w});break}case"checkbox":case"radiobutton":{const w=f.defaultValue===f.exportValues;c.setValue(g,{value:w});break}case"combobox":case"listbox":{const w=f.defaultValue||"";c.setValue(g,{value:w});break}default:continue}const b=document.querySelector(`[data-element-id="${g}"]`);if(b){if(!Tl.has(b)){mt(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;b.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}si=new WeakSet,Ha=function(){this.container.setAttribute("data-internal-link","")},pw=function(e,s,i,r="",a=null){e.href=this.linkService.getAnchorUrl(""),i.description?e.title=i.description:r&&(e.title=r);const o=async()=>{var c;const l=await this.linkService.getAttachmentContent(s);l&&((c=this.downloadManager)==null||c.openOrDownloadData(l,i.filename,a))};e.onclick=()=>(o(),!1),v(this,si,Ha).call(this)},gw=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),v(this,si,Ha).call(this)};class eE extends ae{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.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class Dl extends ae{render(){return this.container}_getKeyModifier(t){return Wt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a)}}))})}_setEventListeners(t,e,s,i){var r,a,o;for(const[l,c]of s)(c==="Action"||(r=this.data.actions)!=null&&r[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,c,i),c==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||J_,r=t.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),h=Math.round(c/(pg*i))||1,d=c/h;a=Math.min(i,l(d/pg))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/pg))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=j.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class sE extends Dl{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let c=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const h={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),Tl.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:d,datetimeType:f,timeStep:g}=this.data,b=!!f&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",A=>{t.setValue(e,{value:A.target.value}),this.setPropertyOnSiblings(s,"value",A.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",A=>{const y=this.data.defaultFieldValue??"";s.value=h.userValue=y,h.formattedValue=null});let w=A=>{const{formattedValue:y}=h;y!=null&&(A.target.value=y),A.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",y=>{var _;if(h.focused)return;const{target:S}=y;if(b&&(S.type=f,g&&(S.step=g)),h.userValue){const C=h.userValue;if(b)if(f==="time"){const E=new Date(C),k=[E.getHours(),E.getMinutes(),E.getSeconds()];S.value=k.map(D=>D.toString().padStart(2,"0")).join(":")}else S.value=new Date(C-Z_).toISOString().split(f==="date"?"T":".",1)[0];else S.value=C}h.lastCommittedValue=S.value,h.commitKey=1,(_=this.data.actions)!=null&&_.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",y=>{this.container.classList.add("sandboxModified");const S={value(_){h.userValue=_.detail.value??"",b||t.setValue(e,{value:h.userValue.toString()}),_.target.value=h.userValue},formattedValue(_){const{formattedValue:C}=_.detail;h.formattedValue=C,C!=null&&_.target!==document.activeElement&&(_.target.value=C);const E={formattedValue:C};b&&(E.value=C),t.setValue(e,E)},selRange(_){_.target.setSelectionRange(..._.detail.selRange)},charLimit:_=>{var D;const{charLimit:C}=_.detail,{target:E}=_;if(C===0){E.removeAttribute("maxLength");return}E.setAttribute("maxLength",C);let k=h.userValue;!k||k.length<=C||(k=k.slice(0,C),E.value=h.userValue=k,t.setValue(e,{value:k}),(D=this.linkService.eventBus)==null||D.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:k,willCommit:!0,commitKey:1,selStart:E.selectionStart,selEnd:E.selectionEnd}}))}};this._dispatchEventFromSandbox(S,y)}),s.addEventListener("keydown",y=>{var C;h.commitKey=1;let S=-1;if(y.key==="Escape"?S=0:y.key==="Enter"&&!this.data.multiLine?S=2:y.key==="Tab"&&(h.commitKey=3),S===-1)return;const{value:_}=y.target;h.lastCommittedValue!==_&&(h.lastCommittedValue=_,h.userValue=_,(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:S,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}))});const A=w;w=null,s.addEventListener("blur",y=>{var C,E;if(!h.focused||!y.relatedTarget)return;(C=this.data.actions)!=null&&C.Blur||(h.focused=!1);const{target:S}=y;let{value:_}=S;if(b){if(_&&f==="time"){const k=_.split(":").map(D=>parseInt(D,10));_=new Date(2e3,0,1,k[0],k[1],k[2]||0).valueOf(),S.step=""}else _.includes("T")||(_=`${_}T00:00`),_=new Date(_).valueOf();S.type="text"}h.userValue=_,h.lastCommittedValue!==_&&((E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:h.commitKey,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}})),A(y)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",y=>{var F;h.lastCommittedValue=null;const{data:S,target:_}=y,{value:C,selectionStart:E,selectionEnd:k}=_;let D=E,M=k;switch(y.inputType){case"deleteWordBackward":{const B=C.substring(0,E).match(/\w*\W*$/);B&&(D-=B[0].length);break}case"deleteWordForward":{const B=C.substring(E).match(/^\W*\w*/);B&&(M+=B[0].length);break}case"deleteContentBackward":E===k&&(D-=1);break;case"deleteContentForward":E===k&&(M+=1);break}y.preventDefault(),(F=this.linkService.eventBus)==null||F.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:C,change:S||"",willCommit:!1,selStart:D,selEnd:M}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],y=>y.target.value)}if(w&&s.addEventListener("blur",w),this.data.comb){const y=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${y}px * var(--total-scale-factor))`);const S=this.data.textAlignment;if(S===1||S===2){const _=()=>{const C=l-s.value.length;s.style.setProperty("--comb-offset",`${S===1?C>>1:C}`)};_();for(const C of["input","blur","resetform","updatefromsandbox"])s.addEventListener(C,_)}}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class iE extends Dl{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class nE extends Dl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return Tl.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s)){const h=l&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=h),t.setValue(c.id,{value:h})}t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class rE extends Dl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(Tl.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const h=a===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const f=h&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class aE extends gv{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",s=>{this._dispatchEventFromSandbox({},s)})),t}}class oE extends Dl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Tl.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===f});const a=(d,f)=>{const g=f.replaceAll(" "," ");d.textContent=g,g!==f&&d.setAttribute("display-value",f)};for(const d of this.data.options){const f=document.createElement("option");a(f,d.displayValue),f.value=d.exportValue,s.value.includes(d.exportValue)&&(f.setAttribute("selected",!0),r=!1),i.append(f)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),o=()=>{d.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const l=d=>{const f=d?"value":"textContent",{options:g,multiple:b}=i;return b?Array.prototype.filter.call(g,w=>w.selected).map(w=>w[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let c=l(!1);const h=d=>{const f=d.target.options;return Array.prototype.map.call(f,g=>({displayValue:g.getAttribute("display-value")||g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const f={value(g){o==null||o();const b=g.detail.value,w=new Set(Array.isArray(b)?b:[b]);for(const A of i.options)A.selected=w.has(A.value);t.setValue(e,{value:l(!0)}),c=l(!1)},multipleSelection(g){i.multiple=!0},remove(g){const b=i.options,w=g.detail.remove;b[w].selected=!1,i.remove(w),b.length>0&&Array.prototype.findIndex.call(b,y=>y.selected)===-1&&(b[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},clear(g){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),c=l(!1)},insert(g){const{index:b,displayValue:w,exportValue:A}=g.detail.insert,y=i.children[b],S=document.createElement("option");a(S,w),S.value=A,y?y.before(S):i.append(S),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},items(g){const{items:b}=g.detail;for(;i.length!==0;)i.remove(0);for(const w of b){const{displayValue:A,exportValue:y}=w,S=document.createElement("option");a(S,A),S.value=y,i.append(S)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},indices(g){const b=new Set(g.detail.indices);for(const w of g.target.options)w.selected=b.has(w.index);t.setValue(e,{value:l(!0)}),c=l(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,d)}),i.addEventListener("input",d=>{var b;const f=l(!0),g=l(!1);t.setValue(e,{value:f}),d.preventDefault(),(b=this.linkService.eventBus)==null||b.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:g,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}var hd,wm;class bm extends ae{constructor(e){const{data:s,elements:i,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&ae._hasPopupData(s)});m(this,hd);if(this.elements=i,a&&ae._hasPopupData(s)){const o=this.popup=v(this,hd,wm).call(this);for(const l of i)l.popup=o}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const s=this.popup=v(this,hd,wm).call(this),i=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",i.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(r=>`${Ul}${r}`).join(",")),this.container}}hd=new WeakSet,wm=function(){return new lE({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})};var Vs,ca,Op,Np,Hc,zc,ge,dn,ha,Jo,Vc,Gc,fn,Gs,ir,nr,me,rr,ua,ud,ar,jc,Zo,da,Re,fa,bt,Bf,Am,Sm,xm,$f,_m,mw,vw,yw,bw,Uf,Hf,Em;class lE{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:c,parentRect:h,open:d,commentManager:f=null}){m(this,bt);m(this,Vs,null);m(this,ca,v(this,bt,yw).bind(this));m(this,Op,v(this,bt,Em).bind(this));m(this,Np,v(this,bt,Hf).bind(this));m(this,Hc,v(this,bt,Uf).bind(this));m(this,zc,null);m(this,ge,null);m(this,dn,null);m(this,ha,null);m(this,Jo,null);m(this,Vc,null);m(this,Gc,null);m(this,fn,!1);m(this,Gs,null);m(this,ir,null);m(this,nr,null);m(this,me,null);m(this,rr,null);m(this,ua,null);m(this,ud,null);m(this,ar,null);m(this,jc,null);m(this,Zo,null);m(this,da,!1);m(this,Re,null);m(this,fa,null);p(this,ge,t),p(this,jc,i),p(this,dn,a),p(this,ar,o),p(this,Vc,l),p(this,zc,e),p(this,ud,c),p(this,Gc,h),p(this,Jo,s),p(this,Vs,f),p(this,Re,s[0]),p(this,ha,cp.toDateObject(r)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),f||(v(this,bt,Bf).call(this),n(this,ge).hidden=!0,d&&v(this,bt,Uf).call(this))}renderCommentButton(){if(n(this,me)){n(this,me).parentNode||n(this,Re).container.after(n(this,me));return}if(n(this,rr)||v(this,bt,Am).call(this),!n(this,rr))return;const{signal:t}=p(this,ir,new AbortController),e=n(this,Re).hasOwnCommentButton,s=()=>{n(this,Vs).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{n(this,Vs).toggleCommentPopup(this,!1,!0,!e)},r=()=>{n(this,Vs).toggleCommentPopup(this,!1,!1)};if(e){p(this,me,n(this,Re).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,ca),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=p(this,me,document.createElement("button"));a.className="annotationCommentButton";const o=n(this,Re).container;a.style.zIndex=parseInt(o.style.zIndex,10)+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),v(this,bt,xm).call(this),v(this,bt,Sm).call(this),a.addEventListener("keydown",n(this,ca),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=n(this,Re).commentData;return t?n(this,Vc)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=n(this,me))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=n(this,Re).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return n(this,me)}get comment(){return n(this,fa)||p(this,fa,n(this,Re).commentText),n(this,fa)}set comment(t){t!==this.comment&&(n(this,Re).commentText=p(this,fa,t))}focus(){var t;(t=n(this,Re).container)==null||t.focus()}get parentBoundingClientRect(){return n(this,Re).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){n(this,me)&&(n(this,me).classList.toggle("selected",t),n(this,me).ariaExpanded=e)}setSelectedCommentButton(t){n(this,me).classList.toggle("selected",t)}get commentPopupPosition(){if(n(this,ua))return n(this,ua);const{x:t,y:e,height:s}=n(this,me).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Re).layer.getBoundingClientRect();return[(t-i)/a,(e+s-r)/o]}set commentPopupPosition(t){p(this,ua,t)}hasDefaultPopupPosition(){return n(this,ua)===null}get commentButtonPosition(){return n(this,rr)}get commentButtonWidth(){return n(this,me).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=n(this,ua)||this.commentButtonPosition.map(c=>c/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;n(this,Vs).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(n(this,Gs))return;const t=p(this,Gs,document.createElement("div"));if(t.className="popup",n(this,zc)){const r=t.style.outlineColor=j.makeHexColor(...n(this,zc));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=n(this,jc))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,jc)}if(t.append(e),n(this,ha)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,ha).valueOf()})),r.dateTime=n(this,ha).toISOString(),e.append(r)}Gy({html:n(this,bt,$f)||n(this,dn).str,dir:(i=n(this,dn))==null?void 0:i.dir,className:"popupContent"},t),n(this,ge).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(n(this,Vs)){s?(this.remove(),p(this,fa,null)):e&&(e.deleted?this.remove():(v(this,bt,xm).call(this),p(this,fa,e.text))),t&&(p(this,rr,null),v(this,bt,Am).call(this),v(this,bt,Sm).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}v(this,bt,Bf).call(this),n(this,Zo)||p(this,Zo,{contentsObj:n(this,dn),richText:n(this,ar)}),t&&p(this,nr,null),e&&e.text&&(p(this,ar,v(this,bt,vw).call(this,e.text)),p(this,ha,cp.toDateObject(e.date)),p(this,dn,null)),(i=n(this,Gs))==null||i.remove(),p(this,Gs,null)}resetEdited(){var t;n(this,Zo)&&({contentsObj:Jt(this,dn)._,richText:Jt(this,ar)._}=n(this,Zo),p(this,Zo,null),(t=n(this,Gs))==null||t.remove(),p(this,Gs,null),p(this,nr,null))}remove(){var t,e,s;if((t=n(this,ir))==null||t.abort(),p(this,ir,null),(e=n(this,Gs))==null||e.remove(),p(this,Gs,null),p(this,da,!1),p(this,fn,!1),(s=n(this,me))==null||s.remove(),p(this,me,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){p(this,da,this.isVisible),n(this,da)&&(n(this,ge).hidden=!0)}maybeShow(){n(this,Vs)||(v(this,bt,Bf).call(this),n(this,da)&&(n(this,Gs)||v(this,bt,Hf).call(this),p(this,da,!1),n(this,ge).hidden=!1))}get isVisible(){return n(this,Vs)?!1:n(this,ge).hidden===!1}}Vs=new WeakMap,ca=new WeakMap,Op=new WeakMap,Np=new WeakMap,Hc=new WeakMap,zc=new WeakMap,ge=new WeakMap,dn=new WeakMap,ha=new WeakMap,Jo=new WeakMap,Vc=new WeakMap,Gc=new WeakMap,fn=new WeakMap,Gs=new WeakMap,ir=new WeakMap,nr=new WeakMap,me=new WeakMap,rr=new WeakMap,ua=new WeakMap,ud=new WeakMap,ar=new WeakMap,jc=new WeakMap,Zo=new WeakMap,da=new WeakMap,Re=new WeakMap,fa=new WeakMap,bt=new WeakSet,Bf=function(){var e;if(n(this,ir))return;p(this,ir,new AbortController);const{signal:t}=n(this,ir);for(const s of this.trigger)s.addEventListener("click",n(this,Hc),{signal:t}),s.addEventListener("pointerenter",n(this,Np),{signal:t}),s.addEventListener("pointerleave",n(this,Op),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,Jo))(e=s.container)==null||e.addEventListener("keydown",n(this,ca),{signal:t})},Am=function(){const t=n(this,Jo).find(e=>e.hasCommentButton);t&&p(this,rr,t._normalizePoint(t.commentButtonPosition))},Sm=function(){if(n(this,Re).extraPopupElement&&!n(this,Re).editor)return;n(this,me)||this.renderCommentButton();const[t,e]=n(this,rr),{style:s}=n(this,me);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},xm=function(){n(this,Re).extraPopupElement||(n(this,me)||this.renderCommentButton(),n(this,me).style.backgroundColor=this.commentButtonColor||"")},$f=function(){const t=n(this,ar),e=n(this,dn);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,ar).html||null},_m=function(){var t,e,s;return((s=(e=(t=n(this,bt,$f))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},mw=function(){var t,e,s;return((s=(e=(t=n(this,bt,$f))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},vw=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,bt,mw),fontSize:n(this,bt,_m)?`calc(${n(this,bt,_m)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
`))e.push({name:"span",value:r,attributes:i});return s},yw=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,fn))&&v(this,bt,Uf).call(this)},bw=function(){if(n(this,nr)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,Vc);let a=!!n(this,Gc),o=a?n(this,Gc):n(this,ud);for(const b of n(this,Jo))if(!o||j.intersect(b.data.rect,o)!==null){o=b.data.rect,a=!0;break}const l=j.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),h=a?o[2]-o[0]+5:0,d=l[0]+h,f=l[1];p(this,nr,[100*(d-i)/e,100*(f-r)/s]);const{style:g}=n(this,ge);g.left=`${n(this,nr)[0]}%`,g.top=`${n(this,nr)[1]}%`},Uf=function(){if(n(this,Vs)){n(this,Vs).toggleCommentPopup(this,!1);return}p(this,fn,!n(this,fn)),n(this,fn)?(v(this,bt,Hf).call(this),n(this,ge).addEventListener("click",n(this,Hc)),n(this,ge).addEventListener("keydown",n(this,ca))):(v(this,bt,Em).call(this),n(this,ge).removeEventListener("click",n(this,Hc)),n(this,ge).removeEventListener("keydown",n(this,ca)))},Hf=function(){n(this,Gs)||this.render(),this.isVisible?n(this,fn)&&n(this,ge).classList.add("focused"):(v(this,bt,bw).call(this),n(this,ge).hidden=!1,n(this,ge).style.zIndex=parseInt(n(this,ge).style.zIndex,10)+1e3)},Em=function(){n(this,ge).classList.remove("focused"),!(n(this,fn)||!this.isVisible)&&(n(this,ge).hidden=!0,n(this,ge).style.zIndex=parseInt(n(this,ge).style.zIndex,10)-1e3)};class ww extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=pt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var dd;class cE extends ae{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,dd,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=p(this,dd,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,dd)}addHighlightArea(){this.container.classList.add("highlightArea")}}dd=new WeakMap;var fd;class hE extends ae{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,fd,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,fd,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,fd)}addHighlightArea(){this.container.classList.add("highlightArea")}}fd=new WeakMap;var pd;class uE extends ae{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,pd,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,pd,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,pd)}addHighlightArea(){this.container.classList.add("highlightArea")}}pd=new WeakMap;var gd;class Aw extends ae{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,gd,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let c=[];for(let d=0,f=s.length;d<f;d+=2){const g=s[d]-e[0],b=e[3]-s[d+1];c.push(`${g},${b}`)}c=c.join(" ");const h=p(this,gd,this.svgFactory.createElement(this.svgElementName));return h.setAttribute("points",c),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),l.append(h),this.container.append(l),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,gd)}addHighlightArea(){this.container.classList.add("highlightArea")}}gd=new WeakMap;class dE extends Aw{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class fE extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}var md,tl,vd,Cm;class mv extends ae{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,vd);m(this,md,null);m(this,tl,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?pt.HIGHLIGHT:pt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:c}=v(this,vd,Cm).call(this,s,e),h=this.svgFactory.create(l,c,!0),d=p(this,md,this.svgFactory.createElement("svg:g"));h.append(d),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",o);for(let f=0,g=i.length;f<g;f++){const b=this.svgFactory.createElement(this.svgElementName);n(this,tl).push(b),b.setAttribute("points",i[f].join(",")),d.append(b)}return!a&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:r}=e,a=n(this,md);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,tl).length;o<l;o++)n(this,tl)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:c}=v(this,vd,Cm).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${c}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,tl)}addHighlightArea(){this.container.classList.add("highlightArea")}}md=new WeakMap,tl=new WeakMap,vd=new WeakSet,Cm=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class Sw extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=pt.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class pE extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class gE extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class mE extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class xw extends ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=pt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var yd,bd,km;class vE extends ae{constructor(e){var r;super(e,{isRenderable:!0});m(this,bd);m(this,yd,null);const{fileId:s,file:i}=this.data;this.filename=i.filename,this.content=i.content,this.fileId=s,(r=this.linkService.eventBus)==null||r.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",v(this,bd,km).bind(this)),p(this,yd,i);const{isMac:r}=Wt.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&v(this,bd,km).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,yd)}addHighlightArea(){this.container.classList.add("highlightArea")}}yd=new WeakMap,bd=new WeakSet,km=async function(){var a;const{fileId:e,filename:s,content:i}=this,r=await this.linkService.getAttachmentContent(e)||i;r&&((a=this.downloadManager)==null||a.openOrDownloadData(r,s))};var Wc,el,or,Pl,Ew,Tm;class _w extends ae{constructor(e){super(e,{isRenderable:!!e.data.richMedia});m(this,Pl);m(this,Wc,new AbortController);m(this,el,null);m(this,or,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,s=document.createElement("button");return s.className="mediaPlayButton",s.type="button",s.title=s.ariaLabel=e,s.addEventListener("click",()=>v(this,Pl,Ew).call(this,s),{signal:n(this,Wc).signal}),this.container.append(s),this.container}destroy(){n(this,Wc).abort(),n(this,or)&&(n(this,or).pause(),n(this,or).removeAttribute("src"),n(this,or).load(),p(this,or,null)),v(this,Pl,Tm).call(this)}}Wc=new WeakMap,el=new WeakMap,or=new WeakMap,Pl=new WeakSet,Ew=async function(e){const{fileId:s,filename:i,contentType:r}=this.data.richMedia;e.disabled=!0;let a;try{a=await this.linkService.getAttachmentContent(s)}catch{return}finally{e.disabled=!1}if(!a||!e.isConnected)return;const{signal:o}=n(this,Wc),l=URL.createObjectURL(new Blob([a],{type:r}));p(this,el,l);const c=r.startsWith("audio/"),h=document.createElement(c?"audio":"video");if(p(this,or,h),h.className="mediaContent",this._setBackgroundColor(h),h.src=l,h.title=i,h.controls=!0,h.autoplay=!0,h.tabIndex=0,c){let d=!1,f=!1;const g=()=>{h.controls=d||f};this.container.addEventListener("pointerenter",()=>{d=!0,g()},{signal:o}),this.container.addEventListener("pointerleave",()=>{d=!1,g()},{signal:o}),this.container.addEventListener("focusin",()=>{f=!0,g()},{signal:o}),this.container.addEventListener("focusout",()=>{f=!1,g()},{signal:o})}h.addEventListener("emptied",()=>v(this,Pl,Tm).call(this,l),{once:!0,signal:o}),e.replaceWith(h),h.play().catch(()=>{})},Tm=function(e=n(this,el)){e&&e===n(this,el)&&(URL.revokeObjectURL(e),p(this,el,null))};var pa,sl,Xc,lr,wd,il,ss,Ad,xn,zf,Vf;const kv=class kv{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o,commentManager:l,linkService:c,annotationStorage:h}){m(this,xn);m(this,pa,null);m(this,sl,null);m(this,Xc,null);m(this,lr,new Map);m(this,wd,null);m(this,il,null);m(this,ss,[]);m(this,Ad,!1);R(this,"zIndex",0);this.div=t,p(this,pa,e),p(this,sl,s),p(this,wd,o||null),p(this,il,c||null),p(this,Xc,h||new fv),this.page=r,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,lr).size>0}async render(t){var l;const{annotations:e,optionalContentConfig:s}=t,i=this.div;El(i,this.viewport);const r=new Map,a=[],o={data:null,layer:i,linkService:n(this,il),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new pp,annotationStorage:n(this,Xc),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const c of e){if(c.noHTML)continue;const h=c.annotationType===ue.POPUP;if(h){const g=r.get(c.id);if(!g)continue;if(!this._commentManager){a.push(c);continue}o.elements=g}else if(c.rect[2]===c.rect[0]||c.rect[3]===c.rect[1])continue;o.data=c;const d=Ag.create(o);if(!d.isRenderable)continue;h||(n(this,ss).push(d),c.popupRef&&r.getOrInsertComputed(c.popupRef,Yd).push(d));const f=d.render();c.hidden&&(f.style.visibility="hidden"),d.updateOC(s),d._isEditable&&(n(this,lr).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await v(this,xn,zf).call(this);for(const c of a){const h=o.elements=r.get(c.id);o.data=c;const d=Ag.create(o);if(!d.isRenderable)continue;const f=d.render();d.contentElement.id=`${Ul}${c.id}`,c.hidden&&(f.style.visibility="hidden"),h.at(-1).container.after(f)}v(this,xn,Vf).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:n(this,il),svgFactory:new pp,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=kv._defaultBorderStyle),e.data=s;const i=Ag.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${Ul}${s.id}`,n(this,ss).push(i))}await v(this,xn,zf).call(this)}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,El(s,{rotation:t.rotation});for(const i of n(this,ss))i.updateOC(e);v(this,xn,Vf).call(this),s.hidden=!1}destroy(){var t,e;for(const s of n(this,ss))(t=s.destroy)==null||t.call(s),(e=n(this,pa))==null||e.removePointerInTextLayer(s.contentElement);n(this,ss).length=0,n(this,lr).clear(),this.div.replaceChildren()}refreshCanvases(){v(this,xn,Vf).call(this)}getEditableAnnotations(){return n(this,lr).values()}getEditableAnnotation(t){return n(this,lr).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new tE({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:n(this,il),annotationStorage:n(this,Xc)});return r.render(),r.contentElement.id=`${Ul}${s}`,r.createOrUpdatePopup(),n(this,ss).push(r),r}removeAnnotation(t){var i;const e=n(this,ss).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=n(this,ss).splice(e,1);(i=n(this,pa))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);v(this,xn,zf).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return ft(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Fl.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};pa=new WeakMap,sl=new WeakMap,Xc=new WeakMap,lr=new WeakMap,wd=new WeakMap,il=new WeakMap,ss=new WeakMap,Ad=new WeakMap,xn=new WeakSet,zf=async function(){var s,i,r;if(n(this,ss).length===0)return;this.div.replaceChildren();const t=[];if(!n(this,Ad)){p(this,Ad,!0);for(const{contentElement:a,data:{id:o}}of n(this,ss)){const l=a.id=`${Ul}${o}`;t.push((s=n(this,wd))==null?void 0:s.getAriaAttributes(l).then(c=>{if(c)for(const[h,d]of c)a.setAttribute(h,d)}))}}n(this,ss).sort(({data:{rect:[a,o,l,c]}},{data:{rect:[h,d,f,g]}})=>{if(a===l&&o===c)return 1;if(h===f&&d===g)return-1;const b=c,w=o,A=(o+c)/2,y=g,S=d,_=(d+g)/2;if(A>=y&&_<=w)return-1;if(_>=b&&A<=S)return 1;const C=(a+l)/2,E=(h+f)/2;return C-E});const e=document.createDocumentFragment();for(const a of n(this,ss))e.append(a.container),this._commentManager?(r=((i=a.extraPopupElement)==null?void 0:i.popup)||a.popup)==null||r.renderCommentButton():a.extraPopupElement&&e.append(a.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),n(this,pa))for(const a of n(this,ss))n(this,pa).addPointerInTextLayer(a.contentElement,!1)},Vf=function(){var e;if(!n(this,sl))return;const t=this.div;for(const[s,i]of n(this,sl)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;if(Array.isArray(i))for(const h of i)h.className="annotationContent",h.ariaHidden=!0;else i.className="annotationContent",i.ariaHidden=!0;const a=[];for(const h of r.children)h.nodeName==="CANVAS"&&a.push(h);for(const h of a)h.remove();const o=Array.isArray(i)?i[0]:i,{firstChild:l}=r;if(l?l.classList.contains("annotationContent")?l.after(o):l.before(o):r.append(o),Array.isArray(i)){let h=o;for(let d=1,f=i.length;d<f;d++)h.after(i[d]),h=i[d]}n(this,sl).delete(s);const c=n(this,lr).get(s);c&&(c._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,i),c._hasNoCanvas=!1):c.canvas=i)}};let Pm=kv;const ff=/\r\n?|\n/g;var js,Sd,nl,Ws,_e,Cw,kw,Tw,Gf,Ar,jf,Wf,Pw,Im,Mw;const Zt=class Zt extends Rt{constructor(e){super({...e,name:"freeTextEditor"});m(this,_e);m(this,js,"");m(this,Sd,`${this.id}-editor`);m(this,nl,null);m(this,Ws);R(this,"_colorPicker",null);this.color=e.color||Zt._defaultColor||Rt._defaultLineColor,p(this,Ws,e.fontSize||Zt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(Rt._l10nAlert.freetext),this.canAddComment=!1}static get _keyboardManager(){const e=Zt.prototype,s=a=>a.isEmpty(),i=kl.TRANSLATE_SMALL,r=kl.TRANSLATE_BIG;return ft(this,"_keyboardManager",new Cl([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){Rt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case vt.FREETEXT_SIZE:Zt._defaultFontSize=s;break;case vt.FREETEXT_COLOR:Zt._defaultColor=s;break}}updateParams(e,s){switch(e){case vt.FREETEXT_SIZE:v(this,_e,Cw).call(this,s);break;case vt.FREETEXT_COLOR:v(this,_e,kw).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[vt.FREETEXT_SIZE,Zt._defaultFontSize],[vt.FREETEXT_COLOR,Zt._defaultColor||Rt._defaultLineColor]]}get propertiesToUpdate(){return[[vt.FREETEXT_SIZE,n(this,Ws)],[vt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new fp(this)),[["colorPicker",this._colorPicker]]}get colorType(){return vt.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-Zt._internalPadding*e,-(Zt._internalPadding+n(this,Ws))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(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"),p(this,nl,new AbortController);const e=this._uiManager.combinedSignal(n(this,nl));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,Sd)),this._isDraggable=!0,(e=n(this,nl))==null||e.abort(),p(this,nl,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.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()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=n(this,js),s=p(this,js,v(this,_e,Tw).call(this).trimEnd());if(e===s)return;const i=r=>{if(p(this,js,r),!r){this.remove();return}v(this,_e,Wf).call(this),this._uiManager.rebuild(this),v(this,_e,Gf).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),v(this,_e,Gf).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){Zt._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){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 e,s;(this._isCopy||this.annotationElementId)&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",n(this,Sd)),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(${n(this,Ws)}px * var(--total-scale-factor))`,i.color=this.color,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[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[h,d]=this.pageDimensions,[f,g]=this.pageTranslation;let b,w;switch(this.rotation){case 0:b=e+(o[0]-f)/h,w=s+this.height-(o[1]-g)/d;break;case 90:b=e+(o[0]-f)/h,w=s-(o[1]-g)/d,[l,c]=[c,-l];break;case 180:b=e-this.width+(o[0]-f)/h,w=s-(o[1]-g)/d,[l,c]=[-l,-c];break;case 270:b=e+(o[0]-f-this.height*d)/h,w=s+(o[1]-g-this.width*h)/d,[l,c]=[-c,l];break}this.setAt(b*r,w*a,l,c)}else this._moveAfterPaste(e,s);v(this,_e,Wf).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var b,w,A;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=v(b=Zt,Ar,Im).call(b,s.getData("text")||"").replaceAll(ff,`
`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:c}=o,h=[],d=[];if(l.nodeType===Node.TEXT_NODE){const y=l.parentElement;if(d.push(l.nodeValue.slice(c).replaceAll(ff,"")),y!==this.editorDiv){let S=h;for(const _ of this.editorDiv.childNodes){if(_===y){S=d;continue}S.push(v(w=Zt,Ar,jf).call(w,_))}}h.push(l.nodeValue.slice(0,c).replaceAll(ff,""))}else if(l===this.editorDiv){let y=h,S=0;for(const _ of this.editorDiv.childNodes)S++===c&&(y=d),y.push(v(A=Zt,Ar,jf).call(A,_))}p(this,js,`${h.join(`
`)}${r}${d.join(`
`)}`),v(this,_e,Wf).call(this);const f=new Range;let g=Math.sumPrecise(h.map(y=>y.length));for(const{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){const S=y.nodeValue.length;if(g<=S){f.setStart(y,g),f.setEnd(y,g);break}g-=S}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=Zt._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,i){var o;let r=null;if(e instanceof ww){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:d,id:f,popupRef:g,richText:b,contentsObj:w,creationDate:A,modificationDate:y},textContent:S,textPosition:_,parent:{page:{pageNumber:C}}}=e;if(!(S!=null&&S.length))return null;r=e={annotationType:pt.FREETEXT,color:Array.from(c),fontSize:l,value:S.join(`
`),position:_,pageIndex:C-1,rect:h.slice(0),rotation:d,annotationElementId:f,id:f,deleted:!1,popupRef:g,comment:(w==null?void 0:w.str)||null,richText:b,creationDate:A,modificationDate:y}}const a=await super.deserialize(e,s,i);return p(a,Ws,e.fontSize),a.color=j.makeHexColor(...e.color),p(a,js,v(o=Zt,Ar,Im).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Rt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,Ws),value:v(this,_e,Pw).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!v(this,_e,Mw).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,Ws)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,js).split(`
`)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:n(this,js)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};js=new WeakMap,Sd=new WeakMap,nl=new WeakMap,Ws=new WeakMap,_e=new WeakSet,Cw=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,Ws))*this.parentScale),p(this,Ws,r),v(this,_e,Gf).call(this)},i=n(this,Ws);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:vt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},kw=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:vt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Tw=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(v(i=Zt,Ar,jf).call(i,r)),s=r);return e.join(`
`)},Gf=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},Ar=new WeakSet,jf=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(ff,"")},Wf=function(){if(this.editorDiv.replaceChildren(),!!n(this,js))for(const e of n(this,js).split(`
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Pw=function(){return n(this,js).replaceAll(" "," ")},Im=function(e){return e.replaceAll(" "," ")},Mw=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},m(Zt,Ar),R(Zt,"_freeTextDefaultContent",""),R(Zt,"_internalPadding",0),R(Zt,"_defaultColor",null),R(Zt,"_defaultFontSize",10),R(Zt,"_type","freetext"),R(Zt,"_editorType",pt.FREETEXT);let Mm=Zt;class J{toSVGPath(){Mt("Abstract method `toSVGPath` must be implemented.")}get box(){Mt("Abstract getter `box` must be implemented.")}serialize(t,e){Mt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}R(J,"PRECISION",1e-4);var Xs,$i,qc,Yc,pn,wt,rl,al,xd,_d,Kc,Qc,ga,Ed,Bp,$p,Te,jh,Iw,Dw,Lw,Rw,Fw,Ow;const Ln=class Ln{constructor({x:t,y:e},s,i,r,a,o=0){m(this,Te);m(this,Xs);m(this,$i,[]);m(this,qc);m(this,Yc);m(this,pn,[]);m(this,wt,new Float32Array(18));m(this,rl);m(this,al);m(this,xd);m(this,_d);m(this,Kc);m(this,Qc);m(this,ga,[]);p(this,Xs,s),p(this,Qc,r*i),p(this,Yc,a),n(this,wt).set([NaN,NaN,NaN,NaN,t,e],6),p(this,qc,o),p(this,_d,n(Ln,Ed)*i),p(this,xd,n(Ln,$p)*i),p(this,Kc,i),n(this,ga).push(t,e)}isEmpty(){return isNaN(n(this,wt)[8])}add({x:t,y:e}){var F;p(this,rl,t),p(this,al,e);const[s,i,r,a]=n(this,Xs);let[o,l,c,h]=n(this,wt).subarray(8,12);const d=t-c,f=e-h,g=Math.hypot(d,f);if(g<n(this,xd))return!1;const b=g-n(this,_d),w=b/g,A=w*d,y=w*f;let S=o,_=l;o=c,l=h,c+=A,h+=y,(F=n(this,ga))==null||F.push(t,e);const C=-y/b,E=A/b,k=C*n(this,Qc),D=E*n(this,Qc);return n(this,wt).set(n(this,wt).subarray(2,8),0),n(this,wt).set([c+k,h+D],4),n(this,wt).set(n(this,wt).subarray(14,18),12),n(this,wt).set([c-k,h-D],16),isNaN(n(this,wt)[6])?(n(this,pn).length===0&&(n(this,wt).set([o+k,l+D],2),n(this,pn).push(NaN,NaN,NaN,NaN,(o+k-s)/r,(l+D-i)/a),n(this,wt).set([o-k,l-D],14),n(this,$i).push(NaN,NaN,NaN,NaN,(o-k-s)/r,(l-D-i)/a)),n(this,wt).set([S,_,o,l,c,h],6),!this.isEmpty()):(n(this,wt).set([S,_,o,l,c,h],6),Math.abs(Math.atan2(_-l,S-o)-Math.atan2(y,A))<Math.PI/2?([o,l,c,h]=n(this,wt).subarray(2,6),n(this,pn).push(NaN,NaN,NaN,NaN,((o+c)/2-s)/r,((l+h)/2-i)/a),[o,l,S,_]=n(this,wt).subarray(14,18),n(this,$i).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((_+l)/2-i)/a),!0):([S,_,o,l,c,h]=n(this,wt).subarray(0,6),n(this,pn).push(((S+5*o)/6-s)/r,((_+5*l)/6-i)/a,((5*o+c)/6-s)/r,((5*l+h)/6-i)/a,((o+c)/2-s)/r,((l+h)/2-i)/a),[c,h,o,l,S,_]=n(this,wt).subarray(12,18),n(this,$i).push(((S+5*o)/6-s)/r,((_+5*l)/6-i)/a,((5*o+c)/6-s)/r,((5*l+h)/6-i)/a,((o+c)/2-s)/r,((l+h)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,pn),e=n(this,$i);if(isNaN(n(this,wt)[6])&&!this.isEmpty())return v(this,Te,Iw).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);v(this,Te,Lw).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return v(this,Te,Dw).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new Nw(t,e,s,i,r,a)}getOutlines(){var d;const t=n(this,pn),e=n(this,$i),s=n(this,wt),[i,r,a,o]=n(this,Xs),l=new Float32Array((((d=n(this,ga))==null?void 0:d.length)??0)+2);for(let f=0,g=l.length-2;f<g;f+=2)l[f]=(n(this,ga)[f]-i)/a,l[f+1]=(n(this,ga)[f+1]-r)/o;if(l[l.length-2]=(n(this,rl)-i)/a,l[l.length-1]=(n(this,al)-r)/o,isNaN(s[6])&&!this.isEmpty())return v(this,Te,Rw).call(this,l);const c=new Float32Array(n(this,pn).length+24+n(this,$i).length);let h=t.length;for(let f=0;f<h;f+=2){if(isNaN(t[f])){c[f]=c[f+1]=NaN;continue}c[f]=t[f],c[f+1]=t[f+1]}h=v(this,Te,Ow).call(this,c,h);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=e[f+g],c[h+1]=e[f+g+1],h+=2}return v(this,Te,Fw).call(this,c,h),this.newFreeDrawOutline(c,l,n(this,Xs),n(this,Kc),n(this,qc),n(this,Yc))}};Xs=new WeakMap,$i=new WeakMap,qc=new WeakMap,Yc=new WeakMap,pn=new WeakMap,wt=new WeakMap,rl=new WeakMap,al=new WeakMap,xd=new WeakMap,_d=new WeakMap,Kc=new WeakMap,Qc=new WeakMap,ga=new WeakMap,Ed=new WeakMap,Bp=new WeakMap,$p=new WeakMap,Te=new WeakSet,jh=function(){const t=n(this,wt).subarray(4,6),e=n(this,wt).subarray(16,18),[s,i,r,a]=n(this,Xs);return[(n(this,rl)+(t[0]-e[0])/2-s)/r,(n(this,al)+(t[1]-e[1])/2-i)/a,(n(this,rl)+(e[0]-t[0])/2-s)/r,(n(this,al)+(e[1]-t[1])/2-i)/a]},Iw=function(){const[t,e,s,i]=n(this,Xs),[r,a,o,l]=v(this,Te,jh).call(this);return`M${(n(this,wt)[2]-t)/s} ${(n(this,wt)[3]-e)/i} L${(n(this,wt)[4]-t)/s} ${(n(this,wt)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,wt)[16]-t)/s} ${(n(this,wt)[17]-e)/i} L${(n(this,wt)[14]-t)/s} ${(n(this,wt)[15]-e)/i} Z`},Dw=function(t){const e=n(this,$i);t.push(`L${e[4]} ${e[5]} Z`)},Lw=function(t){const[e,s,i,r]=n(this,Xs),a=n(this,wt).subarray(4,6),o=n(this,wt).subarray(16,18),[l,c,h,d]=v(this,Te,jh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${c} L${h} ${d} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},Rw=function(t){const e=n(this,wt),[s,i,r,a]=n(this,Xs),[o,l,c,h]=v(this,Te,jh).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(d,t,n(this,Xs),n(this,Kc),n(this,qc),n(this,Yc))},Fw=function(t,e){const s=n(this,$i);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Ow=function(t,e){const s=n(this,wt).subarray(4,6),i=n(this,wt).subarray(16,18),[r,a,o,l]=n(this,Xs),[c,h,d,f]=v(this,Te,jh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},m(Ln,Ed,8),m(Ln,Bp,2),m(Ln,$p,n(Ln,Ed)+n(Ln,Bp));let gp=Ln;var Jc,ol,cr,Cd,qs,kd,we,Up,Bw;class Nw extends J{constructor(e,s,i,r,a,o){super();m(this,Up);m(this,Jc);m(this,ol,new Float32Array(4));m(this,cr);m(this,Cd);m(this,qs);m(this,kd);m(this,we);p(this,we,e),p(this,qs,s),p(this,Jc,i),p(this,kd,r),p(this,cr,a),p(this,Cd,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],v(this,Up,Bw).call(this,o);const[l,c,h,d]=n(this,ol);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-l)/h,e[f+1]=(e[f+1]-c)/d;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-l)/h,s[f+1]=(s[f+1]-c)/d}toSVGPath(){const e=[`M${n(this,we)[4]} ${n(this,we)[5]}`];for(let s=6,i=n(this,we).length;s<i;s+=6){if(isNaN(n(this,we)[s])){e.push(`L${n(this,we)[s+4]} ${n(this,we)[s+5]}`);continue}e.push(`C${n(this,we)[s]} ${n(this,we)[s+1]} ${n(this,we)[s+2]} ${n(this,we)[s+3]} ${n(this,we)[s+4]} ${n(this,we)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let c,h;switch(a){case 0:c=J._rescale(n(this,we),e,r,o,-l),h=J._rescale(n(this,qs),e,r,o,-l);break;case 90:c=J._rescaleAndSwap(n(this,we),e,s,o,l),h=J._rescaleAndSwap(n(this,qs),e,s,o,l);break;case 180:c=J._rescale(n(this,we),i,s,-o,l),h=J._rescale(n(this,qs),i,s,-o,l);break;case 270:c=J._rescaleAndSwap(n(this,we),i,r,-o,-l),h=J._rescaleAndSwap(n(this,qs),i,r,-o,-l);break}return{outline:Array.from(c),points:[Array.from(h)]}}get box(){return n(this,ol)}newOutliner(e,s,i,r,a,o=0){return new gp(e,s,i,r,a,o)}getNewOutline(e,s){const[i,r,a,o]=n(this,ol),[l,c,h,d]=n(this,Jc),f=a*h,g=o*d,b=i*h+l,w=r*d+c,A=this.newOutliner({x:n(this,qs)[0]*f+b,y:n(this,qs)[1]*g+w},n(this,Jc),n(this,kd),e,n(this,Cd),s??n(this,cr));for(let y=2;y<n(this,qs).length;y+=2)A.add({x:n(this,qs)[y]*f+b,y:n(this,qs)[y+1]*g+w});return A.getOutlines()}}Jc=new WeakMap,ol=new WeakMap,cr=new WeakMap,Cd=new WeakMap,qs=new WeakMap,kd=new WeakMap,we=new WeakMap,Up=new WeakSet,Bw=function(e){const s=n(this,we);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,c=i,h=r;const d=e?Math.max:Math.min,f=new Float32Array(4);for(let b=6,w=s.length;b<w;b+=6){const A=s[b+4],y=s[b+5];isNaN(s[b])?(j.pointBoundingBox(A,y,a),l>y?(o=A,l=y):l===y&&(o=d(o,A)),h<y?(c=A,h=y):h===y&&(c=d(c,A))):(f.set(br,0),j.bezierBoundingBox(i,r,...s.slice(b,b+6),f),j.rectBoundingBox(...f,a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=d(o,f[0])),h<f[3]?(c=f[2],h=f[3]):h===f[3]&&(c=d(c,f[2]))),i=A,r=y}const g=n(this,ol);g[0]=a[0]-n(this,cr),g[1]=a[1]-n(this,cr),g[2]=a[2]-a[0]+2*n(this,cr),g[3]=a[3]-a[1]+2*n(this,cr),this.firstPoint=[o,l],this.lastPoint=[c,h]};var Td,Pd,Md,ma,Ui,vs,$w,Xf,Uw,Hw,Lm;class Dm{constructor(t,e=0,s=0,i=!0){m(this,vs);m(this,Td);m(this,Pd);m(this,Md);m(this,ma,[]);m(this,Ui,[]);const r=br.slice(),a=10**-4;for(const{x:w,y:A,width:y,height:S}of t){const _=Math.floor((w-e)/a)*a,C=Math.ceil((w+y+e)/a)*a,E=Math.floor((A-e)/a)*a,k=Math.ceil((A+S+e)/a)*a,D=[_,E,k,!0],M=[C,E,k,!1];n(this,ma).push(D,M),j.rectBoundingBox(_,E,C,k,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,c=r[0]-s,h=r[1]-s;let d=i?-1/0:1/0,f=1/0;const g=n(this,ma).at(i?-1:-2),b=[g[0],g[2]];for(const w of n(this,ma)){const[A,y,S,_]=w;!_&&i?y<f?(f=y,d=A):y===f&&(d=Math.max(d,A)):_&&!i&&(y<f?(f=y,d=A):y===f&&(d=Math.min(d,A))),w[0]=(A-c)/o,w[1]=(y-h)/l,w[2]=(S-h)/l}p(this,Td,new Float32Array([c,h,o,l])),p(this,Pd,[d,f]),p(this,Md,b)}getOutlines(){n(this,ma).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,ma))e[3]?(t.push(...v(this,vs,Lm).call(this,e)),v(this,vs,Uw).call(this,e)):(v(this,vs,Hw).call(this,e),t.push(...v(this,vs,Lm).call(this,e)));return v(this,vs,$w).call(this,t)}}Td=new WeakMap,Pd=new WeakMap,Md=new WeakMap,ma=new WeakMap,Ui=new WeakMap,vs=new WeakSet,$w=function(t){const e=[],s=new Set;for(const a of t){const[o,l,c]=a;e.push([o,l,a],[o,c,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],c=e[a+1][2];l.push(c),c.push(l),s.add(l),s.add(c)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,c,h,d]=a;s.delete(a);let f=o,g=l;for(r=[o,c],i.push(r);;){let b;if(s.has(h))b=h;else if(s.has(d))b=d;else break;s.delete(b),[o,l,c,h,d]=b,f!==o&&(r.push(f,g,o,g===l?l:c),f=o),g=g===l?c:l}r.push(f,g)}return new yE(i,n(this,Td),n(this,Pd),n(this,Md))},Xf=function(t){const e=n(this,Ui);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},Uw=function([,t,e]){const s=v(this,vs,Xf).call(this,t);n(this,Ui).splice(s,0,[t,e])},Hw=function([,t,e]){const s=v(this,vs,Xf).call(this,t);for(let i=s;i<n(this,Ui).length;i++){const[r,a]=n(this,Ui)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ui).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,Ui)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ui).splice(i,1);return}}},Lm=function(t){const[e,s,i]=t,r=[[e,s,i]],a=v(this,vs,Xf).call(this,i);for(let o=0;o<a;o++){const[l,c]=n(this,Ui)[o];for(let h=0,d=r.length;h<d;h++){const[,f,g]=r[h];if(!(c<=f||g<=l)){if(f>=l){if(g>c)r[h][1]=c;else{if(d===1)return[];r.splice(h,1),h--,d--}continue}r[h][2]=l,g>c&&r.push([e,c,g])}}}return r};var Id,Zc;class yE extends J{constructor(e,s,i,r){super();m(this,Id);m(this,Zc);p(this,Zc,e),p(this,Id,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const e=[];for(const s of n(this,Zc)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,c=r-s;for(const h of n(this,Zc)){const d=new Array(h.length);for(let f=0;f<h.length;f+=2)d[f]=e+h[f]*l,d[f+1]=r-h[f+1]*c;o.push(d)}return o}get box(){return n(this,Id)}}Id=new WeakMap,Zc=new WeakMap;class Rm extends gp{newFreeDrawOutline(t,e,s,i,r,a){return new bE(t,e,s,i,r,a)}}class bE extends Nw{newOutliner(t,e,s,i,r,a=0){return new Rm(t,e,s,i,r,a)}}var th,Dd,hr,ll,Ld,ks,Rd,Fd,cl,Ys,Ks,Ge,eh,sh,is,ih,wi,Od,yt,Fm,qf,zw,Vw,Gw,Om,za,xi,Bl,jw,Yf,Kf,Ww,Xw,qw,Yw,Kw;const It=class It extends Rt{constructor(e){super({...e,name:"highlightEditor"});m(this,yt);m(this,th,null);m(this,Dd,0);m(this,hr);m(this,ll,null);m(this,Ld,null);m(this,ks,null);m(this,Rd,null);m(this,Fd,0);m(this,cl,null);m(this,Ys,null);m(this,Ks,null);m(this,Ge,!1);m(this,eh,null);m(this,sh,null);m(this,is,null);m(this,ih,"");m(this,wi);m(this,Od,"");this.color=e.color||It._defaultColor,p(this,wi,e.thickness||It._defaultThickness),this.opacity=e.opacity||It._defaultOpacity,p(this,hr,e.boxes||null),p(this,Od,e.methodOfCreation||""),p(this,ih,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(p(this,Ge,!0),v(this,yt,qf).call(this,e),v(this,yt,za).call(this)):n(this,hr)&&(p(this,th,e.anchorNode),p(this,Dd,e.anchorOffset),p(this,Rd,e.focusNode),p(this,Fd,e.focusOffset),v(this,yt,Fm).call(this),v(this,yt,za).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(Rt._l10nAlert.highlight)}static get _keyboardManager(){const e=It.prototype;return ft(this,"_keyboardManager",new Cl([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,Ge)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,wi),methodOfCreation:n(this,Od)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;Rt.initialize(e,s),It._defaultColor||(It._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case vt.HIGHLIGHT_COLOR:It._defaultColor=s;break;case vt.HIGHLIGHT_THICKNESS:It._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,sh)}get commentButtonPosition(){return n(this,eh)}updateParams(e,s){switch(e){case vt.HIGHLIGHT_COLOR:v(this,yt,zw).call(this,s);break;case vt.HIGHLIGHT_THICKNESS:v(this,yt,Vw).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[vt.HIGHLIGHT_COLOR,It._defaultColor],[vt.HIGHLIGHT_THICKNESS,It._defaultThickness]]}get propertiesToUpdate(){return[[vt.HIGHLIGHT_COLOR,this.color||It._defaultColor],[vt.HIGHLIGHT_THICKNESS,n(this,wi)||It._defaultThickness],[vt.HIGHLIGHT_FREE,n(this,Ge)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Ks),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,Ld))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",p(this,Ld,new dp({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(v(this,yt,Kf).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,v(this,yt,Kf).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){v(this,yt,Om).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,yt,za).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?v(this,yt,Om).call(this):e&&(v(this,yt,za).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,Ge)?(e=(e-this.rotation+360)%360,i=v(r=It,xi,Bl).call(r,n(this,Ys).box,e)):i=v(a=It,xi,Bl).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,Ks),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,is),{bbox:v(o=It,xi,Bl).call(o,n(this,ks).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,ih)&&(e.setAttribute("aria-label",n(this,ih)),e.setAttribute("role","mark")),n(this,Ge)?e.classList.add("free"):this.div.addEventListener("keydown",v(this,yt,jw).bind(this),{signal:this._uiManager._signal});const s=p(this,cl,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,ll),this.setDims(),Qy(this,n(this,cl),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:v(this,yt,Yf).call(this,!0);break;case 1:case 3:v(this,yt,Yf).call(this,!1);break}}select(){var e;super.select(),n(this,is)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,is)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{selected:!1}}),n(this,Ge)||v(this,yt,Yf).call(this,!1))}get _mustFixPosition(){return!n(this,Ge)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Ks),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,is),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:c,height:h}=i.getBoundingClientRect(),d=new AbortController,f=e.combinedSignal(d),g=b=>{d.abort(),v(this,xi,Yw).call(this,e,b)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",ce,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ei,{signal:f}),i.addEventListener("pointermove",v(this,xi,qw).bind(this,e),{signal:f}),this._freeHighlight=new Rm({x:r,y:a},[o,l,c,h],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.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 async deserialize(e,s,i){var A,y,S,_;let r=null;if(e instanceof Sw){const{data:{quadPoints:C,rect:E,rotation:k,id:D,color:M,opacity:F,popupRef:B,richText:I,contentsObj:T,creationDate:N,modificationDate:H},parent:{page:{pageNumber:Z}}}=e;r=e={annotationType:pt.HIGHLIGHT,color:Array.from(M),opacity:F,quadPoints:C,boxes:null,pageIndex:Z-1,rect:E.slice(0),rotation:k,annotationElementId:D,id:D,deleted:!1,popupRef:B,richText:I,comment:(T==null?void 0:T.str)||null,creationDate:N,modificationDate:H}}else if(e instanceof mv){const{data:{inkLists:C,rect:E,rotation:k,id:D,color:M,borderStyle:{rawWidth:F},popupRef:B,richText:I,contentsObj:T,creationDate:N,modificationDate:H},parent:{page:{pageNumber:Z}}}=e;r=e={annotationType:pt.HIGHLIGHT,color:Array.from(M),thickness:F,inkLists:C,boxes:null,pageIndex:Z-1,rect:E.slice(0),rotation:k,annotationElementId:D,id:D,deleted:!1,popupRef:B,richText:I,comment:(T==null?void 0:T.str)||null,creationDate:N,modificationDate:H}}const{color:a,quadPoints:o,inkLists:l,outlines:c,opacity:h}=e,d=await super.deserialize(e,s,i);d.color=j.makeHexColor(...a),d.opacity=h||1,l&&p(d,wi,e.thickness),d._initialData=r,e.comment&&d.setCommentData(e);const[f,g]=d.pageDimensions,[b,w]=d.pageTranslation;if(o){const C=p(d,hr,[]);for(let E=0;E<o.length;E+=8)C.push({x:(o[E]-b)/f,y:1-(o[E+1]-w)/g,width:(o[E+2]-o[E])/f,height:(o[E+1]-o[E+5])/g});v(A=d,yt,Fm).call(A),v(y=d,yt,za).call(y),d.rotate(d.rotation)}else if(l||c){p(d,Ge,!0);const C=(l||c.points)[0],E={x:C[0]-b,y:g-(C[1]-w)},k=new Rm(E,[0,0,f,g],1,n(d,wi)/2,!0,.001);for(let F=0,B=C.length;F<B;F+=2)E.x=C[F]-b,E.y=g-(C[F+1]-w),k.add(E);const{id:D,clipPathId:M}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:k.toSVGPath()}},!0,!0);v(S=d,yt,qf).call(S,{highlightOutlines:k.getOutlines(),highlightId:D,clipPathId:M}),v(_=d,yt,za).call(_),d.rotate(d.parentRotation)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=Rt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(e);return Object.assign(i,{color:s,opacity:this.opacity,thickness:n(this,wi),quadPoints:v(this,yt,Ww).call(this),outlines:v(this,yt,Xw).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!v(this,yt,Kw).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};th=new WeakMap,Dd=new WeakMap,hr=new WeakMap,ll=new WeakMap,Ld=new WeakMap,ks=new WeakMap,Rd=new WeakMap,Fd=new WeakMap,cl=new WeakMap,Ys=new WeakMap,Ks=new WeakMap,Ge=new WeakMap,eh=new WeakMap,sh=new WeakMap,is=new WeakMap,ih=new WeakMap,wi=new WeakMap,Od=new WeakMap,yt=new WeakSet,Fm=function(){const e=new Dm(n(this,hr),.001);p(this,Ys,e.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,Ys).box;const s=new Dm(n(this,hr),.0025,.001,this._uiManager.direction==="ltr");p(this,ks,s.getOutlines());const{firstPoint:i}=n(this,Ys);p(this,eh,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:r}=n(this,ks);p(this,sh,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},qf=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var f,g;if(p(this,Ys,e),p(this,ks,e.getNewOutline(n(this,wi)/2+1.5,.0025)),s>=0)p(this,Ks,s),p(this,ll,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,is,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,ks).box,path:{d:n(this,ks).toSVGPath()}},!0));else if(this.parent){const b=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Ks),{bbox:v(f=It,xi,Bl).call(f,n(this,Ys).box,(b-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,is),{bbox:v(g=It,xi,Bl).call(g,n(this,ks).box,b),path:{d:n(this,ks).toSVGPath()}})}const[a,o,l,c]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=c;break;case 90:{const[b,w]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*w/b,this.height=c*b/w;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[b,w]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*w/b,this.height=c*b/w;break}}const{firstPoint:h}=e;p(this,eh,[(h[0]-a)/l,(h[1]-o)/c]);const{lastPoint:d}=n(this,ks);p(this,sh,[(d[0]-a)/l,(d[1]-o)/c])},zw=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,It._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:vt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},Vw=function(e){const s=n(this,wi),i=r=>{p(this,wi,r),v(this,yt,Gw).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:vt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Gw=function(e){n(this,Ge)&&(v(this,yt,qf).call(this,{highlightOutlines:n(this,Ys).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},Om=function(){n(this,Ks)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Ks)),p(this,Ks,null),this.parent.drawLayer.remove(n(this,is)),p(this,is,null))},za=function(e=this.parent){n(this,Ks)===null&&({id:Jt(this,Ks)._,clipPathId:Jt(this,ll)._}=e.drawLayer.draw({bbox:n(this,Ys).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,Ge)},path:{d:n(this,Ys).toSVGPath()}},!1,!0),p(this,is,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Ge)},bbox:n(this,ks).box,path:{d:n(this,ks).toSVGPath()}},n(this,Ge))),n(this,cl)&&(n(this,cl).style.clipPath=n(this,ll)))},xi=new WeakSet,Bl=function([e,s,i,r],a){switch(a){case 90:return[1-s-r,e,r,i];case 180:return[1-e-i,1-s-r,i,r];case 270:return[s,1-e-i,r,i]}return[e,s,i,r]},jw=function(e){It._keyboardManager.exec(this,e)},Yf=function(e){if(!n(this,th))return;const s=window.getSelection();e?s.setPosition(n(this,th),n(this,Dd)):s.setPosition(n(this,Rd),n(this,Fd))},Kf=function(){return n(this,Ge)?this.rotation:0},Ww=function(){if(n(this,Ge))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,hr),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:h,width:d,height:f}of a){const g=c*e+i,b=(1-h)*s+r;o[l]=o[l+4]=g,o[l+1]=o[l+3]=b,o[l+2]=o[l+6]=g+d*e,o[l+5]=o[l+7]=b-f*s,l+=8}return o},Xw=function(e){return n(this,Ys).serialize(e,v(this,yt,Kf).call(this))},qw=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Yw=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Kw=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},m(It,xi),R(It,"_defaultColor",null),R(It,"_defaultOpacity",1),R(It,"_defaultThickness",12),R(It,"_type","highlight"),R(It,"_editorType",pt.HIGHLIGHT),R(It,"_freeHighlightId",-1),R(It,"_freeHighlight",null),R(It,"_freeHighlightClipId","");let mp=It;var hl;class Qw{constructor(){m(this,hl,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,hl)[t]=e}toSVGProperties(){const t=n(this,hl);return p(this,hl,Object.create(null)),{root:t}}reset(){p(this,hl,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Mt("Not implemented")}}hl=new WeakMap;var us,nh,Fe,ul,dl,kt,Nm,Bm,$m,Wh,Jw,Qf,Xh,$l;const St=class St extends Rt{constructor(e){super(e);m(this,kt);m(this,us,null);m(this,nh);R(this,"_colorPicker",null);R(this,"_drawId",null);p(this,nh,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(v(this,kt,Nm).call(this,e),v(this,kt,Wh).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){Mt("Not implemented")}static get typesMap(){Mt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(St,Fe).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var h;r.updateProperty(s,l);const c=n(this,us).updateProperty(s,l);c&&v(this,kt,Xh).call(this,c),(h=this.parent)==null||h.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s){const i=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[i],l=a[r],c=(h,d)=>{var f;a.updateProperty(i,h),a.updateProperty(r,d),n(this,us).updateProperty(i,h),n(this,us).updateProperty(r,d),(f=this.parent)==null||f.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:c.bind(this,e,s),undo:c.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:vt.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,St._mergeSVGProperties(n(this,us).getPathResizingSVGProperties(v(this,kt,Qf).call(this)),{bbox:v(this,kt,$l).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,St._mergeSVGProperties(n(this,us).getPathResizedSVGProperties(v(this,kt,Qf).call(this)),{bbox:v(this,kt,$l).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:v(this,kt,$l).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,St._mergeSVGProperties(n(this,us).getPathTranslatedSVGProperties(v(this,kt,Qf).call(this),this.parentDimensions),{bbox:v(this,kt,$l).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.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(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,nh)&&(p(this,nh,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){v(this,kt,$m).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,kt,Wh).call(this),v(this,kt,Xh).call(this,n(this,us).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),v(this,kt,$m).call(this)):e&&(this._uiManager.addShouldRescale(this),v(this,kt,Wh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,St._mergeSVGProperties({bbox:v(this,kt,$l).call(this)},n(this,us).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&v(this,kt,Xh).call(this,n(this,us).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,r,a){Mt("Not implemented")}static startDrawing(e,s,i,r){var A;const{target:a,offsetX:o,offsetY:l,pointerId:c,pointerType:h}=r;if(Ze.isInitializedAndDifferentPointerType(h))return;const{viewport:{rotation:d}}=e,{width:f,height:g}=a.getBoundingClientRect(),b=p(St,ul,new AbortController),w=e.combinedSignal(b);if(Ze.setPointer(h,c),window.addEventListener("pointerup",y=>{Ze.isSamePointerIdOrRemove(y.pointerId)&&this._endDraw(y)},{signal:w}),window.addEventListener("pointercancel",y=>{Ze.isSamePointerIdOrRemove(y.pointerId)&&this._currentParent.endDrawingSession()},{signal:w}),window.addEventListener("pointerdown",y=>{Ze.isSamePointerType(y.pointerType)&&(Ze.initializeAndAddPointerId(y.pointerId),n(St,Fe).isCancellable()&&(n(St,Fe).removeLastElement(),n(St,Fe).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:w}),window.addEventListener("contextmenu",Ei,{signal:w}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:w}),a.addEventListener("touchmove",y=>{Ze.isSameTimeStamp(y.timeStamp)&&ce(y)},{signal:w}),e.toggleDrawing(),(A=s._editorUndoBar)==null||A.hide(),n(St,Fe)){e.drawLayer.updateProperties(this._currentDrawId,n(St,Fe).startNew(o,l,f,g,d));return}s.updateUIForDefaultProperties(this),p(St,Fe,this.createDrawerInstance(o,l,f,g,d)),p(St,dl,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(St,dl).toSVGProperties(),n(St,Fe).defaultSVGProperties),!0,!1)}static _drawMove(e){if(Ze.isSameTimeStamp(e.timeStamp),!n(St,Fe))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(Ze.isSamePointerId(r)){if(Ze.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(St,Fe).add(s,i)),Ze.setTimeStamp(e.timeStamp),ce(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(St,Fe,null),p(St,dl,null),Ze.clearTimeStamp()),n(St,ul)&&(n(St,ul).abort(),p(St,ul,null),Ze.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(St,Fe).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(St,Fe),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:vt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(vt.DRAW_STEP),!n(St,Fe).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(St,Fe).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(St,dl),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){Mt("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,c=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),h=await super.deserialize(e,s,i);return h.createDrawingOptions(e),v(d=h,kt,Nm).call(d,{drawOutlines:c}),v(f=h,kt,Wh).call(f),h.onScaleChanging(),h.rotate(),h}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,us).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};us=new WeakMap,nh=new WeakMap,Fe=new WeakMap,ul=new WeakMap,dl=new WeakMap,kt=new WeakSet,Nm=function({drawOutlines:e,drawId:s,drawingOptions:i}){p(this,us,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(Rt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=v(this,kt,Bm).call(this,e,this.parent),v(this,kt,Xh).call(this,e.box)},Bm=function(e,s){const{id:i}=s.drawLayer.draw(St._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},$m=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Wh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=v(this,kt,Bm).call(this,n(this,us),e)}},Jw=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},Qf=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},Xh=function(e){[this.x,this.y,this.width,this.height]=v(this,kt,Jw).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},$l=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,c]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/c),r*(c/l),i*(l/c)];case 5:return[1-s,e,i*(l/c),r*(c/l)];case 6:return[1-e-r*(c/l),1-s,r*(c/l),i*(l/c)];case 7:return[s-i*(l/c),1-e-r*(c/l),i*(l/c),r*(c/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(c/l),s,r*(c/l),i*(l/c)];case 13:return[1-s-i*(l/c),e-r*(c/l),i*(l/c),r*(c/l)];case 14:return[1-e,1-s-i*(l/c),r*(c/l),i*(l/c)];case 15:return[s,1-e,i*(l/c),r*(c/l)];default:return[e,s,i,r]}},R(St,"_currentDrawId",-1),R(St,"_currentParent",null),m(St,Fe,null),m(St,ul,null),m(St,dl,null),R(St,"_INNER_MARGIN",3);let vp=St;var gn,Oe,je,fl,rh,ds,We,Ai,pl,gl,ml,ah,Jf;class wE{constructor(t,e,s,i,r,a){m(this,ah);m(this,gn,new Float64Array(6));m(this,Oe);m(this,je);m(this,fl);m(this,rh);m(this,ds);m(this,We,"");m(this,Ai,0);m(this,pl,new Zd);m(this,gl);m(this,ml);p(this,gl,s),p(this,ml,i),p(this,fl,r),p(this,rh,a),[t,e]=v(this,ah,Jf).call(this,t,e);const o=p(this,Oe,[NaN,NaN,NaN,NaN,t,e]);p(this,ds,[t,e]),p(this,je,[{line:o,points:n(this,ds)}]),n(this,gn).set(o,0)}updateProperty(t,e){t==="stroke-width"&&p(this,rh,e)}isEmpty(){var t;return!((t=n(this,je))!=null&&t.length)}isCancellable(){return n(this,ds).length<=10}add(t,e){[t,e]=v(this,ah,Jf).call(this,t,e);const[s,i,r,a]=n(this,gn).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,gl)*o,n(this,ml)*l)<=2?null:(n(this,ds).push(t,e),isNaN(s)?(n(this,gn).set([r,a,t,e],2),n(this,Oe).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,gn)[0])&&n(this,Oe).splice(6,6),n(this,gn).set([s,i,r,a,t,e],0),n(this,Oe).push(...J.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,ds).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){p(this,gl,s),p(this,ml,i),p(this,fl,r),[t,e]=v(this,ah,Jf).call(this,t,e);const a=p(this,Oe,[NaN,NaN,NaN,NaN,t,e]);p(this,ds,[t,e]);const o=n(this,je).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,je).push({line:a,points:n(this,ds)}),n(this,gn).set(a,0),p(this,Ai,0),this.toSVGPath(),null}getLastElement(){return n(this,je).at(-1)}setLastElement(t){return n(this,je)?(n(this,je).push(t),p(this,Oe,t.line),p(this,ds,t.points),p(this,Ai,0),{path:{d:this.toSVGPath()}}):n(this,pl).setLastElement(t)}removeLastElement(){if(!n(this,je))return n(this,pl).removeLastElement();n(this,je).pop(),p(this,We,"");for(let t=0,e=n(this,je).length;t<e;t++){const{line:s,points:i}=n(this,je)[t];p(this,Oe,s),p(this,ds,i),p(this,Ai,0),this.toSVGPath()}return{path:{d:n(this,We)}}}toSVGPath(){const t=J.svgRound(n(this,Oe)[4]),e=J.svgRound(n(this,Oe)[5]);if(n(this,ds).length===2)return p(this,We,`${n(this,We)} M ${t} ${e} Z`),n(this,We);if(n(this,ds).length<=6){const i=n(this,We).lastIndexOf("M");p(this,We,`${n(this,We).slice(0,i)} M ${t} ${e}`),p(this,Ai,6)}if(n(this,ds).length===4){const i=J.svgRound(n(this,Oe)[10]),r=J.svgRound(n(this,Oe)[11]);return p(this,We,`${n(this,We)} L ${i} ${r}`),p(this,Ai,12),n(this,We)}const s=[];n(this,Ai)===0&&(s.push(`M ${t} ${e}`),p(this,Ai,6));for(let i=n(this,Ai),r=n(this,Oe).length;i<r;i+=6){const[a,o,l,c,h,d]=n(this,Oe).slice(i,i+6).map(J.svgRound);s.push(`C${a} ${o} ${l} ${c} ${h} ${d}`)}return p(this,We,n(this,We)+s.join(" ")),p(this,Ai,n(this,Oe).length),n(this,We)}getOutlines(t,e,s,i){const r=n(this,je).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,pl).build(n(this,je),t,e,s,n(this,fl),n(this,rh),i),p(this,gn,null),p(this,Oe,null),p(this,je,null),p(this,We,null),n(this,pl)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}gn=new WeakMap,Oe=new WeakMap,je=new WeakMap,fl=new WeakMap,rh=new WeakMap,ds=new WeakMap,We=new WeakMap,Ai=new WeakMap,pl=new WeakMap,gl=new WeakMap,ml=new WeakMap,ah=new WeakSet,Jf=function(t,e){return J._normalizePoint(t,e,n(this,gl),n(this,ml),n(this,fl))};var fs,Nd,Bd,Qs,mn,vn,oh,lh,vl,Ye,In,Zw,t0,e0;class Zd extends J{constructor(){super(...arguments);m(this,Ye);m(this,fs);m(this,Nd,0);m(this,Bd);m(this,Qs);m(this,mn);m(this,vn);m(this,oh);m(this,lh);m(this,vl)}build(e,s,i,r,a,o,l){p(this,mn,s),p(this,vn,i),p(this,oh,r),p(this,lh,a),p(this,vl,o),p(this,Bd,l??0),p(this,Qs,e),v(this,Ye,t0).call(this)}get thickness(){return n(this,vl)}setLastElement(e){return n(this,Qs).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,Qs).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,Qs)){if(e.push(`M${J.svgRound(s[4])} ${J.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${J.svgRound(s[10])} ${J.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,c,h,d]=s.subarray(i,i+6).map(J.svgRound);e.push(`C${a} ${o} ${l} ${c} ${h} ${d}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[c,h,d,f]=v(this,Ye,Zw).call(this);let g,b,w,A,y,S,_,C,E;switch(n(this,lh)){case 0:E=J._rescale,g=e,b=s+r,w=i,A=-r,y=e+c*i,S=s+(1-h-f)*r,_=e+(c+d)*i,C=s+(1-h)*r;break;case 90:E=J._rescaleAndSwap,g=e,b=s,w=i,A=r,y=e+h*i,S=s+c*r,_=e+(h+f)*i,C=s+(c+d)*r;break;case 180:E=J._rescale,g=e+i,b=s,w=-i,A=r,y=e+(1-c-d)*i,S=s+h*r,_=e+(1-c)*i,C=s+(h+f)*r;break;case 270:E=J._rescaleAndSwap,g=e+i,b=s+r,w=-i,A=-r,y=e+(1-h-f)*i,S=s+(1-c-d)*r,_=e+(1-h)*i,C=s+(1-c)*r;break}for(const{line:k,points:D}of n(this,Qs))o.push(E(k,g,b,w,A,a?new Array(k.length):null)),l.push(E(D,g,b,w,A,a?new Array(D.length):null));return{lines:o,points:l,rect:[y,S,_,C]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:c,thickness:h}){const d=[];let f,g,b,w,A;switch(c){case 0:A=J._rescale,f=-e/i,g=s/r+1,b=1/i,w=-1/r;break;case 90:A=J._rescaleAndSwap,f=-s/r,g=-e/i,b=1/r,w=1/i;break;case 180:A=J._rescale,f=e/i+1,g=-s/r,b=-1/i,w=1/r;break;case 270:A=J._rescaleAndSwap,f=s/r+1,g=e/i+1,b=-1/r,w=-1/i;break}if(!o){o=[];for(const S of l){const _=S.length;if(_===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(_===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const C=new Float32Array(3*(_-2));o.push(C);let[E,k,D,M]=S.subarray(0,4);C.set([NaN,NaN,NaN,NaN,E,k],0);for(let F=4;F<_;F+=2){const B=S[F],I=S[F+1];C.set(J.createBezierPoints(E,k,D,M,B,I),(F-2)*3),[E,k,D,M]=[D,M,B,I]}}}for(let S=0,_=o.length;S<_;S++)d.push({line:A(o[S].map(C=>C??NaN),f,g,b,w),points:A(l[S].map(C=>C??NaN),f,g,b,w)});const y=new this.prototype.constructor;return y.build(d,i,r,1,c,h,a),y}get box(){return n(this,fs)}updateProperty(e,s){return e==="stroke-width"?v(this,Ye,e0).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=v(this,Ye,In).call(this);p(this,mn,e),p(this,vn,s),p(this,oh,i);const[o,l]=v(this,Ye,In).call(this),c=o-r,h=l-a,d=n(this,fs);return d[0]-=c,d[1]-=h,d[2]+=2*c,d[3]+=2*h,d}updateRotation(e){return p(this,Nd,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,fs).map(J.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,fs);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${J.svgRound(e)} ${J.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,fs);let i=0,r=0,a=0,o=0,l=0,c=0;switch(n(this,Nd)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,c=s;break;case 270:r=-s/e,a=e/s,c=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${J.svgRound(l)} ${J.svgRound(c)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=v(this,Ye,In).call(this),[l,c,h,d]=n(this,fs);if(Math.abs(h-a)<=J.PRECISION||Math.abs(d-o)<=J.PRECISION){const A=e+i/2-(l+h/2),y=s+r/2-(c+d/2);return{path:{"transform-origin":`${J.svgRound(e)} ${J.svgRound(s)}`,transform:`${this.rotationTransform} translate(${A} ${y})`}}}const f=(i-2*a)/(h-2*a),g=(r-2*o)/(d-2*o),b=h/i,w=d/r;return{path:{"transform-origin":`${J.svgRound(l)} ${J.svgRound(c)}`,transform:`${this.rotationTransform} scale(${b} ${w}) translate(${J.svgRound(a)} ${J.svgRound(o)}) scale(${f} ${g}) translate(${J.svgRound(-a)} ${J.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=v(this,Ye,In).call(this),l=n(this,fs),[c,h,d,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(d-a)<=J.PRECISION||Math.abs(f-o)<=J.PRECISION){const y=e+i/2-(c+d/2),S=s+r/2-(h+f/2);for(const{line:_,points:C}of n(this,Qs))J._translate(_,y,S,_),J._translate(C,y,S,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${J.svgRound(e)} ${J.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-2*a)/(d-2*a),b=(r-2*o)/(f-2*o),w=-g*(c+a)+e+a,A=-b*(h+o)+s+o;if(g!==1||b!==1||w!==0||A!==0)for(const{line:y,points:S}of n(this,Qs))J._rescale(y,w,A,g,b,y),J._rescale(S,w,A,g,b,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${J.svgRound(e)} ${J.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,fs),l=e-o[0],c=s-o[1];if(n(this,mn)===r&&n(this,vn)===a)for(const{line:h,points:d}of n(this,Qs))J._translate(h,l,c,h),J._translate(d,l,c,d);else{const h=n(this,mn)/r,d=n(this,vn)/a;p(this,mn,r),p(this,vn,a);for(const{line:f,points:g}of n(this,Qs))J._rescale(f,l,c,h,d,f),J._rescale(g,l,c,h,d,g);o[2]*=h,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${J.svgRound(e)} ${J.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,fs);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${J.svgRound(e[0])} ${J.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}fs=new WeakMap,Nd=new WeakMap,Bd=new WeakMap,Qs=new WeakMap,mn=new WeakMap,vn=new WeakMap,oh=new WeakMap,lh=new WeakMap,vl=new WeakMap,Ye=new WeakSet,In=function(e=n(this,vl)){const s=n(this,Bd)+e/2*n(this,oh);return n(this,lh)%180===0?[s/n(this,mn),s/n(this,vn)]:[s/n(this,vn),s/n(this,mn)]},Zw=function(){const[e,s,i,r]=n(this,fs),[a,o]=v(this,Ye,In).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},t0=function(){const e=p(this,fs,Wa.slice());for(const{line:r}of n(this,Qs)){if(r.length<=12){for(let l=4,c=r.length;l<c;l+=6)j.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,c=r.length;l<c;l+=6){const[h,d,f,g,b,w]=r.subarray(l,l+6);j.bezierBoundingBox(a,o,h,d,f,g,b,w,e),a=b,o=w}}const[s,i]=v(this,Ye,In).call(this);e[0]=ee(e[0]-s,0,1),e[1]=ee(e[1]-i,0,1),e[2]=ee(e[2]+s,0,1),e[3]=ee(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},e0=function(e){const[s,i]=v(this,Ye,In).call(this);p(this,vl,e);const[r,a]=v(this,Ye,In).call(this),[o,l]=[r-s,a-i],c=n(this,fs);return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c};class ag extends Qw{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:Rt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new ag(this._viewParameters);return t.updateAll(this),t}}var Hp,s0;const zl=class zl extends vp{constructor(e){super({...e,name:"inkEditor"});m(this,Hp);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){Rt.initialize(e,s),this._defaultDrawingOptions=new ag(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return ft(this,"typesMap",new Map([[vt.INK_THICKNESS,"stroke-width"],[vt.INK_COLOR,"stroke"],[vt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,r,a){return new wE(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return Zd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof mv){const{data:{inkLists:o,rect:l,rotation:c,id:h,color:d,opacity:f,borderStyle:{rawWidth:g},popupRef:b,richText:w,contentsObj:A,creationDate:y,modificationDate:S},parent:{page:{pageNumber:_}}}=e;r=e={annotationType:pt.INK,color:Array.from(d),thickness:g,opacity:f,paths:{points:o},boxes:null,pageIndex:_-1,rect:l.slice(0),rotation:c,annotationElementId:h,id:h,deleted:!1,popupRef:b,richText:w,comment:(A==null?void 0:A.str)||null,creationDate:y,modificationDate:S}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new fp(this)),[["colorPicker",this._colorPicker]]}get colorType(){return vt.INK_COLOR}get colorAndOpacityType(){return vt.INK_COLOR_AND_OPACITY}get opacityType(){return vt.INK_OPACITY}updateParams(e,s){if(e===vt.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===vt.INK_COLOR_AND_OPACITY){super.updateDefaultParams(vt.INK_COLOR,s.color),super.updateDefaultParams(vt.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=zl.getDefaultDrawingOptions({stroke:j.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:Rt._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!v(this,Hp,s0).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};Hp=new WeakSet,s0=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},R(zl,"_type","ink"),R(zl,"_editorType",pt.INK),R(zl,"_defaultDrawingOptions",null);let Um=zl;class Hm extends Zd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const pf=8,Ch=3;var yl,Ft,zm,Hi,i0,n0,Vm,Zf,r0,a0,o0,Gm,jm,l0;class yr{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let c=new OffscreenCanvas(1,1),h=c.getContext("2d",{alpha:!1});const d=200,f=h.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:b,actualBoundingBoxAscent:w,actualBoundingBoxDescent:A,fontBoundingBoxAscent:y,fontBoundingBoxDescent:S,width:_}=h.measureText(t),C=1.5,E=Math.ceil(Math.max(Math.abs(g)+Math.abs(b)||0,_)*C),k=Math.ceil(Math.max(Math.abs(w)+Math.abs(A)||d,Math.abs(y)+Math.abs(S)||d)*C);c=new OffscreenCanvas(E,k),h=c.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=f,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,E,k),h.fillStyle="black",h.fillText(t,E*(C-1)/2,k*(3-C)/2);const D=v(this,Ft,Gm).call(this,h.getImageData(0,0,E,k).data),M=v(this,Ft,o0).call(this,D),F=v(this,Ft,jm).call(this,M),B=v(this,Ft,Vm).call(this,D,E,k,F);return this.processDrawnLines({lines:{curves:B,width:E,height:k},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=v(this,Ft,l0).call(this,t),[c,h]=v(this,Ft,a0).call(this,a,o,l,Math.hypot(o,l)*n(this,yl).sigmaSFactor,n(this,yl).sigmaR,n(this,yl).kernelSize),d=v(this,Ft,jm).call(this,h),f=v(this,Ft,Vm).call(this,c,o,l,d);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:c,height:h}=t,d=t.thickness??0,f=[],g=Math.min(e/c,s/h),b=g/e,w=g/s,A=[];for(const{points:S}of l){const _=a?v(this,Ft,r0).call(this,S):S;if(!_)continue;A.push(_);const C=_.length,E=new Float32Array(C),k=new Float32Array(3*(C===2?2:C-2));if(f.push({line:k,points:E}),C===2){E[0]=_[0]*b,E[1]=_[1]*w,k.set([NaN,NaN,NaN,NaN,E[0],E[1]],0);continue}let[D,M,F,B]=_;D*=b,M*=w,F*=b,B*=w,E.set([D,M,F,B],0),k.set([NaN,NaN,NaN,NaN,D,M],0);for(let I=4;I<C;I+=2){const T=E[I]=_[I]*b,N=E[I+1]=_[I+1]*w;k.set(J.createBezierPoints(D,M,F,B,T,N),(I-2)*3),[D,M,F,B]=[F,B,T,N]}}if(f.length===0)return null;const y=o?new Hm:new Zd;return y.build(f,e,s,1,i,o?0:d,r),{outline:y,newCurves:A,areContours:o,thickness:d,width:c,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const S of t){l+=S.length;for(let _=2,C=S.length;_<C;_++){const E=S[_]-S[_-2];a=Math.min(a,E),o=Math.max(o,E)}}let c;a>=-128&&o<=127?c=Int8Array:a>=-32768&&o<=32767?c=Int16Array:c=Int32Array;const h=t.length,d=pf+Ch*h,f=new Uint32Array(d);let g=0;f[g++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*c.BYTES_PER_ELEMENT,f[g++]=0,f[g++]=i,f[g++]=r,f[g++]=e?0:1,f[g++]=Math.max(0,Math.floor(s??0)),f[g++]=h,f[g++]=c.BYTES_PER_ELEMENT;for(const S of t)f[g++]=S.length-2,f[g++]=S[0],f[g++]=S[1];const b=new CompressionStream("deflate-raw"),w=b.writable.getWriter();await w.ready,w.write(f);const A=c.prototype.constructor;for(const S of t){const _=new A(S.length-2);for(let C=2,E=S.length;C<E;C++)_[C-2]=S[C]-S[C-2];w.write(_)}return w.close(),(await new Response(b.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const _ of s)a||(a=new Uint8Array(new Uint32Array(_.buffer,0,4)[0])),a.set(_,o),o+=_.length;const l=new Uint32Array(a.buffer,0,a.length>>2),c=l[1];if(c!==0)throw new Error(`Invalid version: ${c}`);const h=l[2],d=l[3],f=l[4]===0,g=l[5],b=l[6],w=l[7],A=[],y=(pf+Ch*b)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(w){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,y);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,y);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,y);break}o=0;for(let _=0;_<b;_++){const C=l[Ch*_+pf],E=new Float32Array(C+2);A.push(E);for(let k=0;k<Ch-1;k++)E[k]=l[Ch*_+pf+k+1];for(let k=0;k<C;k++)E[k+2]=E[k]+S[o++]}return{areContours:f,thickness:g,outlines:A,width:h,height:d}}catch(e){return mt(`decompressSignature: ${e}`),null}}}yl=new WeakMap,Ft=new WeakSet,zm=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},Hi=new WeakMap,i0=function(t,e,s,i,r,a,o){const l=v(this,Ft,zm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(-c+l-o+16)%8,d=n(this,Hi)[2*h],f=n(this,Hi)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},n0=function(t,e,s,i,r,a,o){const l=v(this,Ft,zm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(c+l+o+16)%8,d=n(this,Hi)[2*h],f=n(this,Hi)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},Vm=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let h=0;h<r;h++)a[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)a[h*e]=a[h*e+e-1]=0;for(let h=0;h<e;h++)a[h]=a[e*s-1-h]=0;let o=1,l;const c=[];for(let h=1;h<s-1;h++){l=1;for(let d=1;d<e-1;d++){const f=h*e+d,g=a[f];if(g===0)continue;let b=h,w=d;if(g===1&&a[f-1]===0)o+=1,w-=1;else if(g>=1&&a[f+1]===0)o+=1,w+=1,g>1&&(l=g);else{g!==1&&(l=Math.abs(g));continue}const A=[d,h],y=w===d+1,S={isHole:y,points:A,id:o,parent:0};c.push(S);let _;for(const I of c)if(I.id===l){_=I;break}_?_.isHole?S.parent=y?_.parent:l:S.parent=y?l:_.parent:S.parent=y?l:0;const C=v(this,Ft,i0).call(this,a,e,h,d,b,w,0);if(C===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let E=n(this,Hi)[2*C],k=n(this,Hi)[2*C+1];const D=h+E,M=d+k;b=D,w=M;let F=h,B=d;for(;;){const I=v(this,Ft,n0).call(this,a,e,F,B,b,w,1);E=n(this,Hi)[2*I],k=n(this,Hi)[2*I+1];const T=F+E,N=B+k;A.push(N,T);const H=F*e+B;if(a[H+1]===0?a[H]=-o:a[H]===1&&(a[H]=o),T===h&&N===d&&F===D&&B===M){a[f]!==1&&(l=Math.abs(a[f]));break}else b=F,w=B,F=T,B=N}}}return c},Zf=function(t,e,s,i){if(s-e<=4){for(let D=e;D<s-2;D+=2)i.push(t[D],t[D+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,c=Math.hypot(o,l),h=o/c,d=l/c,f=h*a-d*r,g=l/o,b=1/c,w=Math.atan(g),A=Math.cos(w),y=Math.sin(w),S=b*(Math.abs(A)+Math.abs(y)),_=b*(1-S+S**2),C=Math.max(Math.atan(Math.abs(y+A)*_),Math.atan(Math.abs(y-A)*_));let E=0,k=e;for(let D=e+2;D<s-2;D+=2){const M=Math.abs(f-h*t[D+1]+d*t[D]);M>E&&(k=D,E=M)}E>(c*C)**2?(v(this,Ft,Zf).call(this,t,e,k+2,i),v(this,Ft,Zf).call(this,t,k,s,i)):i.push(r,a)},r0=function(t){const e=[],s=t.length;return v(this,Ft,Zf).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},a0=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,c=a>>1;for(let w=0;w<a;w++){const A=(w-c)**2;for(let y=0;y<a;y++)o[w*a+y]=Math.exp((A+(y-c)**2)/l)}const h=new Float32Array(256),d=-2*r**2;for(let w=0;w<256;w++)h[w]=Math.exp(w**2/d);const f=t.length,g=new Uint8Array(f),b=new Uint32Array(256);for(let w=0;w<s;w++)for(let A=0;A<e;A++){const y=w*e+A,S=t[y];let _=0,C=0;for(let k=0;k<a;k++){const D=w+k-c;if(!(D<0||D>=s))for(let M=0;M<a;M++){const F=A+M-c;if(F<0||F>=e)continue;const B=t[D*e+F],I=o[k*a+M]*h[Math.abs(B-S)];_+=B*I,C+=I}}const E=g[y]=Math.round(_/C);b[E]++}return[g,b]},o0=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Gm=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const c=s[o]=t[o<<2];i=Math.max(i,c),r=Math.min(r,c)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},jm=function(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},l0=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,yl);let a=s,o=i;if(s>r||i>r){let f=s,g=i,b=Math.log2(Math.max(s,i)/r);const w=Math.floor(b);b=b===w?w-1:w;for(let y=0;y<b;y++){a=Math.ceil(f/2),o=Math.ceil(g/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,f,g,0,0,a,o),f=a,g=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const A=Math.min(r/a,r/o);a=Math.round(a*A),o=Math.round(o*A)}const c=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});c.fillStyle="white",c.fillRect(0,0,a,o),c.filter="grayscale(1)",c.drawImage(t,0,0,t.width,t.height,0,0,a,o);const h=c.getImageData(0,0,a,o).data;return[v(this,Ft,Gm).call(this,h),a,o]},m(yr,Ft),m(yr,yl,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),m(yr,Hi,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class vv extends Qw{constructor(){super(),super.updateProperties({fill:Rt._defaultLineColor,"stroke-width":0})}clone(){const t=new vv;return t.updateAll(this),t}}class yv extends ag{constructor(t){super(t),super.updateProperties({stroke:Rt._defaultLineColor,"stroke-width":1})}clone(){const t=new yv(this._viewParameters);return t.updateAll(this),t}}var va,yn,ya,bl;const Rs=class Rs extends vp{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});m(this,va,!1);m(this,yn,null);m(this,ya,null);m(this,bl,null);this._willKeepAspectRatio=!0,p(this,ya,e.signatureData||null),p(this,yn,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){Rt.initialize(e,s),this._defaultDrawingOptions=new vv,this._defaultDrawnSignatureOptions=new yv(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return ft(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,yn)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,ya)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:c,heightInPage:h}=n(this,ya),{rawDims:{pageWidth:d,pageHeight:f},rotation:g}=this.parent.viewport,b=yr.processDrawnLines({lines:r,pageWidth:d,pageHeight:f,rotation:g,innerMargin:Rs._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(b,h,l,c)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:n(this,yn)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){p(this,bl,e),this.addEditToolbar()}getUuid(){return n(this,bl)}get description(){return n(this,yn)}set description(e){p(this,yn,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,ya),o=Math.max(r,a),l=yr.processDrawnLines({lines:{curves:e.map(c=>({points:c})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,r){const{x:a,y:o}=this,{outline:l}=p(this,ya,e);p(this,va,l instanceof Hm),this.description=i;let c;n(this,va)?c=Rs.getDefaultDrawingOptions():(c=Rs._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:c});const[,h]=this.pageDimensions;let d=s/h;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(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return yr.process(e,s,i,r,Rs._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return yr.extractContoursFromText(e,s,i,r,a,Rs._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return yr.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Rs._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Rs.getDefaultDrawingOptions():(this._drawingOptions=Rs._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:n(this,va),color:[0,0,0],thickness:n(this,va)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,bl),a.isCopy=!0):a.lines=s,n(this,yn)&&(a.accessibilityData={type:"Figure",alt:n(this,yn)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Hm.deserialize(e,s,i,r,a,o):Zd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return p(r,va,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",p(r,bl,e.uuid),r}};va=new WeakMap,yn=new WeakMap,ya=new WeakMap,bl=new WeakMap,R(Rs,"_type","signature"),R(Rs,"_editorType",pt.SIGNATURE),R(Rs,"_defaultDrawingOptions",null);let Wm=Rs;var ne,Ne,ba,ur,wa,ch,dr,wl,bn,Js,hh,Tt,qh,Yh,tp,ep,sp,qm,ip,c0;class Xm extends Rt{constructor(e){super({...e,name:"stampEditor"});m(this,Tt);m(this,ne,null);m(this,Ne,null);m(this,ba,null);m(this,ur,null);m(this,wa,null);m(this,ch,"");m(this,dr,null);m(this,wl,!1);m(this,bn,null);m(this,Js,!1);m(this,hh,!1);p(this,ur,e.bitmapUrl),p(this,wa,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){Rt.initialize(e,s)}static isHandlingMimeForPasting(e){return Pg.includes(e)}static paste(e,s){s.pasteEditor({mode:pt.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!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:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var e;n(this,Ne)&&(p(this,ne,null),this._uiManager.imageManager.deleteId(n(this,Ne)),(e=n(this,dr))==null||e.remove(),p(this,dr,null),n(this,bn)&&(clearTimeout(n(this,bn)),p(this,bn,null))),super.remove()}rebuild(){if(!this.parent){n(this,Ne)&&v(this,Tt,tp).call(this);return}super.rebuild(),this.div!==null&&(n(this,Ne)&&n(this,dr)===null&&v(this,Tt,tp).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,ba)||n(this,ne)||n(this,ur)||n(this,wa)||n(this,Ne)||n(this,wl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,wl)||(n(this,ne)?v(this,Tt,ep).call(this):v(this,Tt,tp).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(p(this,Ne,i),r&&p(this,ne,r),p(this,wl,!1),v(this,Tt,ep).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,bn)!==null&&clearTimeout(n(this,bn)),p(this,bn,setTimeout(()=>{p(this,bn,null),v(this,Tt,qm).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,ne),o=new _n;let l=n(this,ne),c=r,h=a,d=null;if(s){if(r>s||a>s){const D=Math.min(s/r,s/a);c=Math.floor(r*D),h=Math.floor(a*D)}d=document.createElement("canvas");const g=d.width=Math.ceil(c*o.sx),b=d.height=Math.ceil(h*o.sy);n(this,Js)||(l=v(this,Tt,sp).call(this,g,b));const w=d.getContext("2d");w.filter=this._uiManager.hcmFilter;let A="white",y="#cfcfd8";this._uiManager.hcmFilter!=="none"?y="black":Ix.isDarkMode&&(A="#8f8f9d",y="#42414d");const S=15,_=S*o.sx,C=S*o.sy,E=new OffscreenCanvas(_*2,C*2),k=E.getContext("2d");k.fillStyle=A,k.fillRect(0,0,_*2,C*2),k.fillStyle=y,k.fillRect(0,0,_,C),k.fillRect(_,C,_,C),w.fillStyle=w.createPattern(E,"repeat"),w.fillRect(0,0,g,b),w.drawImage(l,0,0,l.width,l.height,0,0,g,b)}let f=null;if(i){let g,b;if(o.symmetric&&l.width<e&&l.height<e)g=l.width,b=l.height;else if(l=n(this,ne),r>e||a>e){const y=Math.min(e/r,e/a);g=Math.floor(r*y),b=Math.floor(a*y),n(this,Js)||(l=v(this,Tt,sp).call(this,g,b))}const A=new OffscreenCanvas(g,b).getContext("2d",{willReadFrequently:!0});A.drawImage(l,0,0,l.width,l.height,0,0,g,b),f={width:g,height:b,data:A.getImageData(0,0,g,b).data}}return{canvas:d,width:c,height:h,imageData:f}}static async deserialize(e,s,i){var A;let r=null,a=!1;if(e instanceof xw){const{data:{rect:y,rotation:S,id:_,structParent:C,popupRef:E,richText:k,contentsObj:D,creationDate:M,modificationDate:F},container:B,parent:{page:{pageNumber:I}},canvas:T}=e;let N,H;T?(delete e.canvas,{id:N,bitmap:H}=i.imageManager.getFromCanvas(B.id,T),T.remove()):(a=!0,e._hasNoCanvas=!0);const Z=((A=await s._structTree.getAriaAttributes(`${Ul}${_}`))==null?void 0:A.get("aria-label"))||"";r=e={annotationType:pt.STAMP,bitmapId:N,bitmap:H,pageIndex:I-1,rect:y.slice(0),rotation:S,annotationElementId:_,id:_,deleted:!1,accessibilityData:{decorative:!1,altText:Z},isSvg:!1,structParent:C,popupRef:E,richText:k,comment:(D==null?void 0:D.str)||null,creationDate:M,modificationDate:F}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:c,bitmapUrl:h,bitmapId:d,isSvg:f,accessibilityData:g}=e;a?(i.addMissingCanvas(e.id,o),p(o,wl,!0)):d&&i.imageManager.isValidId(d)?(p(o,Ne,d),c&&p(o,ne,c)):p(o,ur,h),p(o,Js,f);const[b,w]=o.pageDimensions;return o.width=(l[2]-l[0])/b,o.height=(l[3]-l[1])/w,g&&(o.altTextData=g),o._initialData=r,e.comment&&o.setCommentData(e),p(o,hh,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:n(this,Ne),isSvg:n(this,Js)});if(this.addComment(i),e)return i.bitmapUrl=v(this,Tt,ip).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=v(this,Tt,c0).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,Js)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,Ne)))s.stamps.set(n(this,Ne),{area:o,serialized:i}),i.bitmap=v(this,Tt,ip).call(this,!1);else if(n(this,Js)){const l=s.stamps.get(n(this,Ne));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=v(this,Tt,ip).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}ne=new WeakMap,Ne=new WeakMap,ba=new WeakMap,ur=new WeakMap,wa=new WeakMap,ch=new WeakMap,dr=new WeakMap,wl=new WeakMap,bn=new WeakMap,Js=new WeakMap,hh=new WeakMap,Tt=new WeakSet,qh=function(e,s=!1){if(!e){this.remove();return}p(this,ne,e.bitmap),s||(p(this,Ne,e.id),p(this,Js,e.isSvg)),e.file&&p(this,ch,e.file.name),v(this,Tt,ep).call(this)},Yh=function(){if(p(this,ba,null),this._uiManager.enableWaiting(!1),!!n(this,dr)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,ne)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,ne)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},tp=function(){if(n(this,Ne)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Ne)).then(i=>v(this,Tt,qh).call(this,i,!0)).finally(()=>v(this,Tt,Yh).call(this));return}if(n(this,ur)){const i=n(this,ur);p(this,ur,null),this._uiManager.enableWaiting(!0),p(this,ba,this._uiManager.imageManager.getFromUrl(i).then(r=>v(this,Tt,qh).call(this,r)).finally(()=>v(this,Tt,Yh).call(this)));return}if(n(this,wa)){const i=n(this,wa);p(this,wa,null),this._uiManager.enableWaiting(!0),p(this,ba,this._uiManager.imageManager.getFromFile(i).then(r=>v(this,Tt,qh).call(this,r)).finally(()=>v(this,Tt,Yh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Pg.join(",");const s=this._uiManager._signal;p(this,ba,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),v(this,Tt,qh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>v(this,Tt,Yh).call(this))),e.click()},ep=function(){var c;const{div:e}=this;let{width:s,height:i}=n(this,ne);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const h=Math.min(o*r/s,o*a/i);s*=h,i*=h}this._uiManager.enableWaiting(!1);const l=p(this,dr,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/a,this.setDims(),(c=this._initialOptions)!=null&&c.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),v(this,Tt,qm).call(this),n(this,hh)||(this.parent.addUndoableEditor(this),p(this,hh,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,ch)&&this.div.setAttribute("aria-description",n(this,ch)),this.annotationElementId||this._uiManager.a11yAlert(Rt._l10nAlert.stamp)},sp=function(e,s){const{width:i,height:r}=n(this,ne);let a=i,o=r,l=n(this,ne);for(;a>2*e||o>2*s;){const c=a,h=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,c,h,0,0,a,o),l=d.transferToImageBitmap()}return l},qm=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new _n,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),c=n(this,dr);if(!c||c.width===o&&c.height===l)return;c.width=o,c.height=l;const h=n(this,Js)?n(this,ne):v(this,Tt,sp).call(this,o,l),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(h,0,0,h.width,h.height,0,0,o,l)},ip=function(e){if(e){if(n(this,Js)){const r=this._uiManager.imageManager.getSvgUrl(n(this,Ne));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,ne),s.getContext("2d").drawImage(n(this,ne),0,0),s.toDataURL()}if(n(this,Js)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Ia.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Ia.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,ne),0,0,n(this,ne).width,n(this,ne).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,ne))},c0=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},R(Xm,"_type","stamp"),R(Xm,"_editorType",pt.STAMP);var Al,uh,Aa,Sa,fr,Ts,xa,dh,fh,zi,pr,Be,gr,_a,ph,et,Ea,qt,Km,h0,Yi,Qm,Jm,np;const Ti=class Ti{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:h}){m(this,qt);m(this,Al);m(this,uh,!1);m(this,Aa,null);m(this,Sa,null);m(this,fr,null);m(this,Ts,new Map);m(this,xa,!1);m(this,dh,!1);m(this,fh,!1);m(this,zi,null);m(this,pr,null);m(this,Be,null);m(this,gr,null);m(this,_a,null);m(this,ph,-1);m(this,et);const d=[...n(Ti,Ea).values()];if(!Ti._initialized){Ti._initialized=!0;for(const f of d)f.initialize(h,t)}t.registerEditorTypes(d),p(this,et,t),this.pageIndex=e,this.div=s,p(this,Al,r),p(this,Aa,a),this.viewport=c,p(this,Be,l),this.drawLayer=o,this._structTree=i,n(this,et).addLayer(this)}get isEmpty(){return n(this,Ts).size===0}get isInvisible(){return this.isEmpty&&n(this,et).getMode()===pt.NONE}updateToolbar(t){n(this,et).updateToolbar(t)}updateMode(t=n(this,et).getMode()){switch(v(this,qt,np).call(this),t){case pt.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case pt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case pt.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;if(e.toggle("nonEditing",!1),t===pt.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Ti,Ea).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,Be))==null?void 0:e.div)}setEditingState(t){n(this,et).setEditingState(t)}addCommands(t){n(this,et).addCommands(t)}cleanUndoStack(t){n(this,et).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=n(this,Aa))==null||e.togglePointerEvents(t)}async enable(){var s;p(this,fh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,_a))==null||s.abort(),p(this,_a,null);const t=new Set;for(const i of n(this,qt,Km))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,et).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,Aa);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,et).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}p(this,fh,!1),n(this,et)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(p(this,dh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Be)&&!n(this,_a)){p(this,_a,new AbortController);const r=n(this,et).combinedSignal(n(this,_a));n(this,Be).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:c,timeStamp:h}=a,d=n(this,ph);if(h-d>500){p(this,ph,h);return}p(this,ph,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const g=document.elementsFromPoint(l,c);if(f.toggle("getElements",!1),!this.div.contains(g[0]))return;let b;const w=new RegExp(`^${tu}[0-9]+$`);for(const y of g)if(w.test(y.id)){b=y.id;break}if(!b)return;const A=n(this,Ts).get(b);(A==null?void 0:A.annotationElementId)===null&&(ce(a),A.dblclick(a))},{signal:r,capture:!0})}const t=n(this,Aa),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,qt,Km)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(this,et).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let c=a.get(l);if(c){c.resetAnnotationElement(o),c.show(!1),o.show();continue}c=r.get(l),c&&(n(this,et).addChangedExistingAnnotation(c),c.renderAnnotationElement(o)&&c.show(!1)),o.show()}}v(this,qt,np).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Ti,Ea).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),p(this,dh,!1)}getEditableAnnotation(t){var e;return((e=n(this,Aa))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,et).getActive()!==t&&n(this,et).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Be))!=null&&t.div&&!n(this,gr)){p(this,gr,new AbortController);const e=n(this,et).combinedSignal(n(this,gr));n(this,Be).div.addEventListener("pointerdown",v(this,qt,h0).bind(this),{signal:e}),n(this,Be).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,Be))!=null&&t.div&&n(this,gr)&&(n(this,gr).abort(),p(this,gr,null),n(this,Be).div.classList.remove("highlighting"))}enableClick(){if(n(this,Sa))return;p(this,Sa,new AbortController);const t=n(this,et).combinedSignal(n(this,Sa));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(){var t;(t=n(this,Sa))==null||t.abort(),p(this,Sa,null)}attach(t){n(this,Ts).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,et).isDeletedAnnotationElement(e)&&n(this,et).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,Ts).delete(t.id),(e=n(this,Al))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,dh)&&t.annotationElementId&&n(this,et).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,et).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,et).addDeletedAnnotationElement(t),Rt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.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),n(this,et).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,fh)),n(this,et).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,fr)&&(t._focusEventsAllowed=!1,p(this,fr,setTimeout(()=>{p(this,fr,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,et)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,Al))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of n(this,Ts).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,et).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,qt,Yi))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,et).updateMode(t.mode);const{offsetX:s,offsetY:i}=v(this,qt,Jm).call(this),r=n(this,et).getId(),a=v(this,qt,Qm).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,et),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Ti,Ea).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,et)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,et).getId(),r=v(this,qt,Qm).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,et),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(v(this,qt,Jm).call(this),!0,t)}setSelected(t){n(this,et).setSelected(t)}toggleSelected(t){n(this,et).toggleSelected(t)}unselect(t){n(this,et).unselect(t)}pointerup(t){var i;const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,xa)||(p(this,xa,!1),(i=n(this,qt,Yi))!=null&&i.isDrawer&&n(this,qt,Yi).supportMultipleDrawings))return;if(!n(this,uh)){p(this,uh,!0);return}const s=n(this,et).getMode();if(s===pt.STAMP||s===pt.POPUP||s===pt.SIGNATURE){n(this,et).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,et).getMode()===pt.HIGHLIGHT&&this.enableTextSelection(),n(this,xa)){p(this,xa,!1);return}const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,xa,!0),(i=n(this,qt,Yi))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,et).getActive();p(this,uh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,zi)){n(this,qt,Yi).startDrawing(this,n(this,et),!1,t);return}n(this,et).setCurrentDrawingSession(this),p(this,zi,new AbortController);const e=n(this,et).combinedSignal(n(this,zi));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,pr,null),this.commitOrRemove())},{signal:e}),n(this,qt,Yi).startDrawing(this,n(this,et),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,pr,e);return}n(this,pr)&&setTimeout(()=>{var e;(e=n(this,pr))==null||e.focus(),p(this,pr,null)},0)}endDrawingSession(t=!1){return n(this,zi)?(n(this,et).setCurrentDrawingSession(null),n(this,zi).abort(),p(this,zi,null),p(this,pr,null),n(this,qt,Yi).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,et).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,zi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,zi)&&n(this,qt,Yi).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,et).getActive())==null?void 0:t.parent)===this&&(n(this,et).commitOrRemove(),n(this,et).setActiveEditor(null)),n(this,fr)&&(clearTimeout(n(this,fr)),p(this,fr,null));for(const s of n(this,Ts).values())(e=n(this,Al))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,Ts).clear(),n(this,et).removeLayer(this)}async render({viewport:t}){this.viewport=t,El(this.div,t);for(const e of n(this,et).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,et).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,et).commitOrRemove(),v(this,qt,np).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,El(this.div,{rotation:s}),e!==s)for(const i of n(this,Ts).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,et).viewParameters.realScale}};Al=new WeakMap,uh=new WeakMap,Aa=new WeakMap,Sa=new WeakMap,fr=new WeakMap,Ts=new WeakMap,xa=new WeakMap,dh=new WeakMap,fh=new WeakMap,zi=new WeakMap,pr=new WeakMap,Be=new WeakMap,gr=new WeakMap,_a=new WeakMap,ph=new WeakMap,et=new WeakMap,Ea=new WeakMap,qt=new WeakSet,Km=function(){return n(this,Ts).size!==0?n(this,Ts).values():n(this,et).getEditors(this.pageIndex)},h0=function(t){n(this,et).unselectAll();const{target:e}=t;if(e===n(this,Be).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,Be).div.contains(e)){const{isMac:s}=Wt.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,et).showAllEditors("highlight",!0,!0),n(this,Be).div.classList.add("free"),this.toggleDrawing(),mp.startHighlighting(this,n(this,et).direction==="ltr",{target:n(this,Be).div,x:t.x,y:t.y}),n(this,Be).div.addEventListener("pointerup",()=>{n(this,Be).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,et)._signal}),t.preventDefault()}},Yi=function(){return n(Ti,Ea).get(n(this,et).getMode())},Qm=function(t){const e=n(this,qt,Yi);return e?new e.prototype.constructor(t):null},Jm=function(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),c=(r+o)/2-t,h=(a+l)/2-e,[d,f]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:d,offsetY:f}},np=function(){for(const t of n(this,Ts).values())t.isEmpty()&&t.remove()},R(Ti,"_initialized",!1),m(Ti,Ea,new Map([Mm,Um,Xm,mp,Wm].map(t=>[t._editorType,t])));let Ym=Ti;function AE(u,t){return u===t?0:u.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function gf(u){var t;return u?u.nodeType===Node.ELEMENT_NODE?u.closest(".textLayer"):((t=u.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function SE(u,t,e,s){if(u===e)return t<=s;const i=u.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function yy(u,t,e){if(u.nodeType!==Node.ELEMENT_NODE||!u.classList.contains("textLayer")||t!==u.childNodes.length)return{container:u,offset:t};let s=u.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var Ps,ps,Si,$d,Ud,Sl,xl,Hd,zp,Ca,ka,Ta,Pa,mr,rs,tv,ev,u0,rp,d0,Cn,sv,f0,iv;const ot=class ot{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){m(this,Cn);m(this,Ps,null);m(this,ps,new Map);m(this,Si,null);m(this,$d,null);m(this,Ud,null);m(this,Sl,null);m(this,xl,new Map);if(this.pageIndex=s,p(this,$d,t),p(this,Ud,e),i){const r=n(ot,mr).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n(ot,ka).delete(r.selectionDiv)),n(ot,mr).set(i,{drawLayer:this}),n(ot,Pa).add(i),p(this,Si,i),p(this,Sl,new MutationObserver(a=>{var o,l,c;if(!(!n(this,Ps)||!((o=n(this,Si))!=null&&o.isConnected)||!v(l=ot,rs,ev).call(l))){for(const{addedNodes:h}of a)for(const d of h)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){v(c=ot,rs,rp).call(c);return}}})),n(this,Sl).observe(i,{childList:!0}),n(ot,Ca)===null){p(ot,Ca,new AbortController);const{signal:a}=n(ot,Ca);document.addEventListener("selectionchange",v(ot,rs,rp).bind(ot),{signal:a}),document.addEventListener("pointerdown",()=>{p(ot,Ta,!0)},{signal:a}),document.addEventListener("pointerup",()=>{p(ot,Ta,!1)},{signal:a}),window.addEventListener("blur",()=>{p(ot,Ta,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,Ps)){p(this,Ps,t),(e=n(this,Si))!=null&&e.isConnected&&v(s=ot,rs,ev).call(s)&&v(i=ot,rs,rp).call(i);return}if(n(this,Ps)!==t){if(n(this,ps).size>0)for(const r of n(this,ps).values())r.remove(),t.append(r);p(this,Ps,t)}}static get _svgFactory(){return ft(this,"_svgFactory",new pp)}draw(t,e=!1,s=!1){const i=Jt(ot,Hd)._++,r=v(this,Cn,sv).call(this),a=ot._svgFactory.createElement("defs");r.append(a);const o=ot._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,xl).set(i,o);const c=s?v(this,Cn,f0).call(this,a,l):null,h=ot._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,ps).set(i,r),{id:i,clipPathId:`url(#${c})`}}drawOutline(t,e){const s=Jt(ot,Hd)._++,i=v(this,Cn,sv).call(this),r=ot._svgFactory.createElement("defs");i.append(r);const a=ot._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=ot._svgFactory.createElement("mask");r.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const f=ot._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=ot._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${o}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const c=ot._svgFactory.createElement("use");i.append(c),c.setAttribute("href",`#${o}`),l&&c.setAttribute("mask",`url(#${l})`);const h=c.cloneNode();return i.append(h),c.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,ps).set(s,i),s}finalizeDraw(t,e){n(this,xl).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,ps).get(t):t;if(o){if(s&&v(this,Cn,iv).call(this,o,s),i&&v(l=ot,rs,d0).call(l,o,i),r){const{classList:c}=o;for(const[h,d]of Object.entries(r))c.toggle(h,d)}if(a){const h=o.firstElementChild.firstElementChild;v(this,Cn,iv).call(this,h,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,ps).get(t);s&&(n(e,Ps).append(s),n(this,ps).delete(t),n(e,ps).set(t,s))}remove(t){n(this,xl).delete(t),n(this,Ps)!==null&&(n(this,ps).get(t).remove(),n(this,ps).delete(t))}destroy(){var t,e,s;p(this,Ps,null);for(const i of n(this,ps).values())i.remove();if(n(this,ps).clear(),n(this,xl).clear(),(t=n(this,Sl))==null||t.disconnect(),p(this,Sl,null),n(this,Si)){const i=n(ot,mr).get(n(this,Si));(i==null?void 0:i.drawLayer)===this&&(v(e=ot,rs,tv).call(e,n(this,Si)),n(ot,mr).delete(n(this,Si)),n(ot,Pa).delete(n(this,Si)),n(ot,Pa).size===0&&((s=n(ot,Ca))==null||s.abort(),p(ot,Ca,null),p(ot,Ta,!1))),p(this,Si,null)}}};Ps=new WeakMap,ps=new WeakMap,Si=new WeakMap,$d=new WeakMap,Ud=new WeakMap,Sl=new WeakMap,xl=new WeakMap,Hd=new WeakMap,zp=new WeakMap,Ca=new WeakMap,ka=new WeakMap,Ta=new WeakMap,Pa=new WeakMap,mr=new WeakMap,rs=new WeakSet,tv=function(t){const e=n(this,mr).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,ka).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},ev=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},u0=function(){return[...n(this,Pa)].filter(t=>t.isConnected).sort(AE)},rp=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,ka))o.remove();n(this,ka).clear();return}const e=new WeakMap,s=v(this,rs,u0).call(this),i=[];for(let o=0,l=t.rangeCount;o<l;o++){const c=t.getRangeAt(o);if(c.collapsed)continue;let{startContainer:h,startOffset:d,endContainer:f,endOffset:g}=c,b=gf(h),w=gf(f);const A=b===null,y=w===null;if(n(this,Ta)&&A!==y)return;if(t.rangeCount===1){const{anchorNode:C,anchorOffset:E,focusNode:k,focusOffset:D}=t,M=gf(C),F=gf(k),B=SE(C,E,k,D);M&&F&&B!==null&&(B?(h=C,d=E,b=M,f=k,g=D,w=F):(h=k,d=D,b=F,f=C,g=E,w=M))}const S=s.filter(C=>c.intersectsNode(C));if(S.length===0)continue;let _=!1;if(b||(b=S[0],h=b,d=0,_=!0),w||(w=S.at(-1),f=w,g=w.childNodes.length,_=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const C=f.previousSibling;if(!C)continue;f=C,g=C.nodeType===Node.TEXT_NODE?C.textContent.length:C.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===g){const C=yy(f,g,w);if(!C)continue;f=C.container,g=C.offset}}if(h.nodeType===Node.ELEMENT_NODE){const C=yy(h,d,b);if(!C)continue;h=C.container,d=C.offset}if(b===w&&!_&&S.includes(b)){i.push([c,b]);continue}for(const C of S){const E=C.firstChild;if(!E)continue;const k=document.createRange();if(C===b?k.setStart(h,d):k.setStartBefore(E),C===w)k.setEnd(f,g);else{const D=C.lastChild;if(!D)continue;if(D.nodeType===Node.ELEMENT_NODE&&D.classList.contains("endOfContent")){const M=D.previousSibling;if(!M)continue;k.setEndAfter(M)}else k.setEndAfter(D)}k.collapsed||i.push([k,C])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,Pa))r.has(o)||v(this,rs,tv).call(this,o);for(const[o,l]of i){const c=n(ot,mr).get(l);if(!c)continue;let h=e.get(l);if(!h){const w=l.getBoundingClientRect();h=(A,y,S,_)=>({x:(A-w.x)/w.width,y:(y-w.y)/w.height,width:S/w.width,height:_/w.height}),e.set(l,h)}const d=[];for(let{x:w,y:A,width:y,height:S}of o.getClientRects())y===0||S===0||({x:w,y:A,width:y,height:S}=h(w,A,y,S),!(y===1&&S===1)&&d.push(`M${w} ${A} h${y} v${S} h-${y} Z`));if(d.length===0)continue;const f=c.drawLayer;let g=c.selectionDiv,b=c.path;if(!g){const w=`clip_selection_${Jt(ot,zp)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${w})`;const A=(a=n(f,$d))==null?void 0:a.createSelectionStyle(n(f,Ud));if(A)for(const[_,C]of Object.entries(A))g.style.setProperty(_,C);const y=ot._svgFactory.create(1,1,!0);y.setAttribute("aria-hidden","true"),y.setAttribute("width","100%"),y.setAttribute("height","100%");const S=ot._svgFactory.createElement("clipPath");S.setAttribute("id",w),S.setAttribute("clipPathUnits","objectBoundingBox"),b=ot._svgFactory.createElement("path"),S.append(b),y.append(S),g.append(y),c.path=b,c.selectionDiv=g}!g.parentNode&&n(f,Ps)&&(n(f,Ps).append(g),n(this,ka).add(g)),b.setAttribute("d",d.join(" "))}},d0=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},Cn=new WeakSet,sv=function(){const t=ot._svgFactory.create(1,1,!0);return n(this,Ps).append(t),t.setAttribute("aria-hidden","true"),t},f0=function(t,e){const s=ot._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=ot._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},iv=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},m(ot,rs),m(ot,Hd,0),m(ot,zp,0),m(ot,Ca,null),m(ot,ka,new Set),m(ot,Ta,!1),m(ot,Pa,new Set),m(ot,mr,new WeakMap);let Zm=ot;function mf(u){return`${(u*100).toFixed(2)}%`}var gh,zd,Vd,mh,wn,An,Gd,Vp,p0;const Zh=class Zh{constructor(t,e,s,i){m(this,Vp);m(this,gh,[]);m(this,zd,new Map);m(this,Vd,null);m(this,mh,0);m(this,wn,0);m(this,An,0);p(this,mh,t),p(this,gh,e),p(this,wn,s.rawDims.pageWidth),p(this,An,s.rawDims.pageHeight),p(this,Vd,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,gh).length;e+=6){const s=v(this,Vp,p0).call(this,n(this,gh).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var y;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,zd).get(s);if(!i)return;const r=(y=n(Zh,Gd))==null?void 0:y.deref();if(r===s)return;r&&(r.width=0,r.height=0),p(Zh,Gd,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:c,height:h}=i,d=n(this,Vd).call(this),f=Math.ceil(o*d.width),g=Math.ceil(l*d.height),b=Math.floor((o+c/n(this,wn))*d.width),w=Math.floor((l+h/n(this,An))*d.height);s.width=b-f,s.height=w-g;const A=s.getContext("2d");A.setTransform(...a),A.translate(-f,-g),A.drawImage(d,0,0)}),t}};gh=new WeakMap,zd=new WeakMap,Vd=new WeakMap,mh=new WeakMap,wn=new WeakMap,An=new WeakMap,Gd=new WeakMap,Vp=new WeakSet,p0=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,wn),(a-e)*n(this,An)),l=Math.hypot((s-t)*n(this,wn),(i-e)*n(this,An));if(o<n(this,mh)||l<n(this,mh))return null;const c=[(r-t)*n(this,wn)/o,(a-e)*n(this,An)/o,(s-t)*n(this,wn)/l,(i-e)*n(this,An)/l,0,0],h=j.inverseTransform(c),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:mf(t),top:mf(e),width:mf(o/n(this,wn)),height:mf(l/n(this,An)),transformOrigin:"0% 0%",transform:`matrix(${c.join(",")})`}),n(this,zd).set(d,{inverseTransform:h,width:o,height:l,x1:t,y1:e}),d},m(Zh,Gd,null);let nv=Zh;globalThis._pdfjsTestingUtils={HighlightOutliner:Dm};globalThis.pdfjsLib={AbortException:Ma,AnnotationEditorLayer:Ym,AnnotationEditorParamsType:vt,AnnotationEditorType:pt,AnnotationEditorUIManager:kl,AnnotationLayer:Pm,AnnotationMode:Pr,AnnotationType:ue,applyOpacity:Lx,build:K_,ColorPicker:dp,createValidAbsoluteUrl:Uy,CSSConstants:Dx,DOMSVGFactory:pp,DrawLayer:Zm,FeatureTest:Wt,fetchData:hv,findContrastColor:Rx,getDocument:cw,getFilenameFromUrl:Tx,getPdfFilenameFromUrl:Px,getRGB:Jd,getRGBA:Qd,getUuid:zy,GlobalWorkerOptions:Sn,ImageKind:bf,InvalidPDFException:Cg,isDataScheme:Qp,isPdfFile:dv,isValidExplicitDest:t_,makeArr:Yd,makeMap:cv,makeObj:Tg,MathClamp:ee,noContextMenu:Ei,normalizeUnicode:Cx,OPS:Ki,OutputScale:_n,PasswordException:Eg,PasswordResponses:bx,PDFDataRangeTransport:hw,PDFDateString:cp,PDFWorker:nu,PermissionFlag:yx,PixelsPerInch:Ia,RenderingCancelledException:uv,renderRichText:Gy,ResponseException:lp,setLayerDimensions:El,shadow:ft,SignatureExtractor:yr,stopEvent:ce,SupportedImageMimeTypes:Pg,TextLayer:yh,TextLayerImages:nv,TouchManager:up,updateUrlHash:Hy,Util:j,VerbosityLevel:Xp,version:Y_,XfaLayer:Vy};const xE="/assets/pdf.worker.min-DEtVeC4l.mjs",_E={class:"pdf-source-viewer","aria-label":"PDF 原文件预览"},EE={key:0,class:"pdf-toolbar"},CE={class:"toolbar-group"},kE=["disabled"],TE={class:"page-indicator"},PE=["disabled"],ME={key:0,class:"fa fa-map-marker","aria-hidden":"true"},IE={class:"toolbar-group"},DE=["disabled"],LE={class:"zoom-indicator"},RE=["disabled"],FE=["aria-label"],OE=["data-page-number"],NE={key:0,class:"pdf-loading",role:"status"},BE={key:1,class:"pdf-error",role:"alert"},$E=["href"],UE={key:2,class:"pdf-unavailable",role:"status"},HE=ni({__name:"PdfSourceViewer",props:{taskId:{},sourceFileId:{},fileName:{},selectedItem:{}},setup(u){Sn.workerSrc=xE;const t=u,e=it(null),s=it(null),i=it(null),r=it(null),a=Cy(null),o=it([]),l=it(1),c=it(0),h=it(1),d=it(1),f=it(!1),g=it(!1),b=it(""),w=it("idle");let A=null,y=null,S=null,_=0,C=0,E=0,k=0;const D=st(()=>t.taskId!=null&&t.sourceFileId!=null?Dy(t.taskId,t.sourceFileId):""),M=st(()=>({"--total-scale-factor":String(d.value)})),F=st(()=>w.value==="highlighted"?`切片原文已在第 ${l.value} 页高亮`:w.value==="unmatched"?`已定位第 ${l.value} 页,未匹配到可高亮文字`:w.value==="manual"?"手动新增切片没有原文位置":c.value?`${l.value} / ${c.value}`:"正在读取 PDF");function B(X){var W;if(!X)return null;if(X.sourceStart==null||X.sourceEnd==null){const gt=(W=X.sourcePages)==null?void 0:W[0];return gt==null?null:o.value.find(rt=>rt.page_number===gt)??null}return o.value.find(gt=>X.sourceStart>=gt.source_start&&X.sourceStart<gt.source_end)??o.value.find(gt=>X.sourceStart<gt.source_end&&X.sourceEnd>gt.source_start)??null}function I(X){var ys;const W=t.selectedItem;if(!W)return"";if(W.sourceStart==null||W.sourceEnd==null)return(ys=W.sourcePages)!=null&&ys.includes(X.page_number)?W.originalContent:"";const gt=Math.max(W.sourceStart,X.source_start),rt=Math.min(W.sourceEnd,X.source_end);if(rt<=gt)return"";const ut=Math.max(0,gt-W.sourceStart),Qt=Math.max(ut,rt-W.sourceStart);return W.originalContent.slice(ut,Qt)}function T(X){return X.normalize("NFKC").replace(/[^\p{L}\p{N}]+/gu,"").toLocaleLowerCase()}function N(X,W,gt){let rt=-1,ut=Number.POSITIVE_INFINITY,Qt=X.indexOf(W);for(;Qt>=0;){const ys=Math.abs(Qt-gt);ys<ut&&(rt=Qt,ut=ys),Qt=X.indexOf(W,Qt+1)}return rt}function H(X,W,gt){var La;const rt=[];let ut="";for(const Ee of X){const Pe=ut.length;ut+=T(Ee),rt.push({start:Pe,end:ut.length})}const Qt=T(W);if(!ut||!Qt)return[];const ys=((La=t.selectedItem)==null?void 0:La.sourceStart)??gt.source_start,ai=Math.max(1,gt.source_end-gt.source_start),ji=Math.min(1,Math.max(0,(ys-gt.source_start)/ai)),as=Math.round(ut.length*ji),kn=[Qt.length,120,80,48,24,12,8].map(Ee=>Math.min(Ee,Qt.length)).filter((Ee,Pe,Ds)=>Ee>=4&&Ds.indexOf(Ee)===Pe);for(const Ee of kn){const Pe=Qt.slice(0,Ee),Ds=N(ut,Pe,as);if(Ds<0)continue;const Ah=Ds+Pe.length;return rt.reduce((Ci,Wi,Sh)=>(Wi.end>Ds&&Wi.start<Ah&&Ci.push(Sh),Ci),[])}return[]}function Z(X){var rt,ut;const W=t.selectedItem;for(const Qt of(S==null?void 0:S.textDivs)??[])Qt.classList.remove("is-slice-highlighted");if(!W||(W.sourceStart==null||W.sourceEnd==null)&&!((rt=W.sourcePages)!=null&&rt.length)){w.value=W?"manual":"idle";return}if(!X||X.page_number!==l.value||!S){w.value="idle";return}const gt=H(S.textContentItemsStr,I(X),X);for(const Qt of gt)(ut=S.textDivs[Qt])==null||ut.classList.add("is-slice-highlighted");w.value=gt.length?"highlighted":"unmatched"}async function P(X=!1){var ji;const W=a.value,gt=s.value,rt=i.value,ut=r.value,Qt=e.value;if(!W||!gt||!rt||!ut||!Qt)return;const ys=B(t.selectedItem);if(!X&&E===l.value&&S){Z(ys);return}const ai=++C;y==null||y.cancel(),S==null||S.cancel(),y=null,S=null,g.value=!0,b.value="";try{const as=await W.getPage(l.value);if(ai!==C)return;const kn=as.getViewport({scale:1}),Ee=Math.max(280,Qt.clientWidth-36)/kn.width*h.value,Pe=as.getViewport({scale:Ee}),Ds=Math.max(1,window.devicePixelRatio||1);if(!rt.getContext("2d"))throw new Error("浏览器无法创建 PDF 画布");d.value=Ee,gt.style.width=`${Pe.width}px`,gt.style.height=`${Pe.height}px`,rt.width=Math.floor(Pe.width*Ds),rt.height=Math.floor(Pe.height*Ds),rt.style.width=`${Pe.width}px`,rt.style.height=`${Pe.height}px`,ut.replaceChildren();const Ci=as.render({canvas:rt,viewport:Pe,transform:Ds===1?void 0:[Ds,0,0,Ds,0,0]});y=Ci;const Wi=Ci.promise.catch(xh=>{if(!(ai!==C||xh instanceof Error&&xh.name==="RenderingCancelledException"))throw xh}),Sh=as.streamTextContent();if(ai!==C)return;const tf=new yh({textContentSource:Sh,container:ut,viewport:Pe});if(S=tf,await Promise.all([Wi,tf.render()]),ai!==C)return;E=l.value,Z(ys),await vh(),(ji=gt.querySelector(".is-slice-highlighted"))==null||ji.scrollIntoView({block:"center",inline:"center",behavior:"smooth"})}catch(as){if(ai!==C)return;b.value=as instanceof Error?as.message:"PDF 页面渲染失败"}finally{ai===C&&(g.value=!1)}}async function K(){var gt;if(!a.value)return;const X=t.selectedItem;if(!X||(X.sourceStart==null||X.sourceEnd==null)&&!((gt=X.sourcePages)!=null&&gt.length)){Z(null);return}const W=B(X);if(!W){w.value="unmatched";return}if(l.value!==W.page_number){l.value=W.page_number,await P(!0);return}await P(!1)}async function z(){const X=++_;if(++C,E=0,y==null||y.cancel(),S==null||S.cancel(),await(A==null?void 0:A.destroy()),A=null,a.value=null,o.value=[],c.value=0,l.value=1,b.value="",w.value="idle",!(!D.value||t.taskId==null||t.sourceFileId==null)){f.value=!0;try{const W=cw({url:D.value});A=W;const[gt,rt]=await Promise.all([dA(t.taskId,t.sourceFileId),W.promise]);if(X!==_){await W.destroy();return}a.value=rt,o.value=gt.pages,c.value=rt.numPages,await vh(),await K(),t.selectedItem||await P(!0)}catch(W){if(X!==_)return;b.value=W instanceof Error?W.message:"PDF 原文件加载失败"}finally{X===_&&(f.value=!1)}}}async function Et(X){const W=Math.min(c.value,Math.max(1,l.value+X));W!==l.value&&(l.value=W,await P(!0))}async function _t(X){const W=Math.min(2,Math.max(.6,Number((h.value+X).toFixed(1))));W!==h.value&&(h.value=W,await P(!0))}function Ut(){window.cancelAnimationFrame(k),k=window.requestAnimationFrame(()=>{a.value&&P(!0)})}const Ot=new ResizeObserver(Ut);return Is(e,(X,W)=>{W&&Ot.unobserve(W),X&&Ot.observe(X)}),Is(D,()=>void z(),{immediate:!0}),Is(()=>{var X;return(X=t.selectedItem)==null?void 0:X.id},()=>void K()),Gp(()=>{++_,++C,window.cancelAnimationFrame(k),Ot.disconnect(),y==null||y.cancel(),S==null||S.cancel(),A==null||A.destroy()}),(X,W)=>(O(),$("div",_E,[D.value?(O(),$("div",EE,[x("div",CE,[x("button",{type:"button","aria-label":"上一页",disabled:l.value<=1||f.value,onClick:W[0]||(W[0]=gt=>Et(-1))},[...W[4]||(W[4]=[x("i",{class:"fa fa-chevron-left","aria-hidden":"true"},null,-1)])],8,kE),x("span",TE,G(l.value)+" / "+G(c.value||"—"),1),x("button",{type:"button","aria-label":"下一页",disabled:l.value>=c.value||f.value,onClick:W[1]||(W[1]=gt=>Et(1))},[...W[5]||(W[5]=[x("i",{class:"fa fa-chevron-right","aria-hidden":"true"},null,-1)])],8,PE)]),x("span",{class:re(["location-state",`is-${w.value}`]),role:"status"},[w.value==="highlighted"?(O(),$("i",ME)):ct("",!0),at(" "+G(F.value),1)],2),x("div",IE,[x("button",{type:"button","aria-label":"缩小",disabled:h.value<=.6||f.value,onClick:W[2]||(W[2]=gt=>_t(-.1))},"",8,DE),x("span",LE,G(Math.round(h.value*100))+"%",1),x("button",{type:"button","aria-label":"放大",disabled:h.value>=2||f.value,onClick:W[3]||(W[3]=gt=>_t(.1))},"+",8,RE)])])):ct("",!0),D.value?(O(),$("div",{key:1,ref_key:"scrollRef",ref:e,class:"pdf-scroll",tabindex:"0","aria-label":`PDF 预览:${u.fileName}`},[x("div",{ref_key:"pageRef",ref:s,class:"pdf-page",style:ky(M.value),"data-page-number":l.value},[x("canvas",{ref_key:"canvasRef",ref:i,class:"pdf-canvas"},null,512),x("div",{ref_key:"textLayerRef",ref:r,class:"pdf-text-layer"},null,512)],12,OE),f.value||g.value?(O(),$("div",NE,[W[6]||(W[6]=x("i",{class:"fa fa-spinner fa-spin","aria-hidden":"true"},null,-1)),at(" "+G(f.value?"正在加载 PDF…":"正在渲染页面…"),1)])):ct("",!0),b.value?(O(),$("div",BE,[W[7]||(W[7]=x("i",{class:"fa fa-exclamation-circle","aria-hidden":"true"},null,-1)),W[8]||(W[8]=x("strong",null,"PDF 预览失败",-1)),x("span",null,G(b.value),1),x("a",{href:D.value,target:"_blank",rel:"noopener noreferrer"},"在新窗口打开原件",8,$E)])):ct("",!0)],8,FE)):(O(),$("div",UE,[...W[9]||(W[9]=[x("i",{class:"fa fa-file-pdf-o","aria-hidden":"true"},null,-1),x("strong",null,"PDF 原文件暂不可预览",-1),x("span",null,"请重新上传该文件后再试。",-1)])]))]))}}),zE=ri(HE,[["__scopeId","data-v-b5c8430d"]]),VE=["问:如何看待当前的通货膨胀风险?","答:当前通胀水平总体可控,但仍需关注能源价格与供给扰动。","问:美联储下一次议息会议何时召开?","答:会议时间以美联储官方日历为准,市场会重点关注利率路径指引。","问:人民币汇率未来走势如何?","答:人民币汇率取决于中美利差、经济基本面与政策预期。","问:什么是复利?","答:复利是将上一期利息加入本金,再计算下一期利息。"].join(`
`);function GE(u){const t=u.split(`
`);let e=0;return t.map((s,i)=>{const r=e,a=r+s.length;return e=a+(i<t.length-1?1:0),{number:i+1,content:s,start:r,end:a}})}function by(u){var t;return((t=u.match(/[\u3400-\u4dbf\u4e00-\u9fff]|[A-Za-z0-9_]+|[^\s]/gu))==null?void 0:t.length)??0}const jE={class:"preview-step"},WE={class:"preview-file-switcher"},XE={class:"file-switcher-control"},qE={class:"file-option"},YE=["title"],KE={key:0},QE={class:"file-switcher-summary"},JE={class:"preview-workspace"},ZE={class:"source-pane"},tC={class:"pane-header"},eC=["data-source-start"],sC={class:"line-number"},iC={class:"line-content"},nC={class:"preview-pane"},rC={class:"pane-header"},aC={class:"pane-header-actions"},oC={class:"preview-toolbar"},lC={class:"preview-list","aria-label":"预览条目列表"},cC=["data-preview-id","aria-selected","onClick","onKeydown"],hC={class:"item-name"},uC={class:"item-source"},dC={class:"item-actions"},fC={key:0,class:"empty-result"},pC={key:1,class:"preview-editor"},gC={class:"editor-heading"},mC={class:"editor-actions"},kh=10,vC=ni({__name:"PreviewCompareStep",props:{sourceText:{},items:{},selectedId:{},processType:{},fileName:{},fileFormat:{},taskId:{},sourceFileId:{},files:{},selectedFileId:{}},emits:["update:selectedId","update:selectedFileId","update:item-content","restore:item","add:item","remove:item"],setup(u,{emit:t}){const e=u,s=t,i=it(null),r=it(""),a=it(1),o=it(null),l=it(""),c=st(()=>GE(e.sourceText)),h=st(()=>e.items.find(I=>I.id===e.selectedId)??e.items[0]),d=st(()=>e.items.find(I=>I.id===o.value)),f=st(()=>{var I,T;return((I=e.fileFormat)==null?void 0:I.toLowerCase().replace(/^\./,""))||((T=e.fileName.split(".").pop())==null?void 0:T.toLowerCase())||""}),g=st(()=>f.value==="pdf"),b=st(()=>["docx","xlsx"].includes(f.value)),w=st(()=>e.items.filter((I,T)=>!r.value.trim()||I.editedContent.toLowerCase().includes(r.value.trim().toLowerCase())||String(T+1).includes(r.value.trim()))),A=st(()=>{const I=(a.value-1)*kh;return w.value.slice(I,I+kh)});function y(I,T){const N=h.value;return!N||N.sourceStart==null||N.sourceEnd==null?!1:T>=N.sourceStart&&I<=N.sourceEnd}function S(I){s("update:selectedId",I)}function _(I){S(I.id),o.value=I.id,l.value=I.editedContent}function C(){o.value=null,l.value=""}function E(){d.value&&(s("update:item-content",d.value.id,l.value),C())}function k(){d.value&&(s("restore:item",d.value.id),C())}function D(I){S(I.id),s("remove:item",I.id)}function M(){C()}Is(r,()=>{a.value=1,C()}),Is(()=>e.selectedFileId,C),Is(h,async I=>{var H,Z;if(!I)return;const T=w.value.findIndex(P=>P.id===I.id);if(T>=0&&(a.value=Math.floor(T/kh)+1),g.value||b.value||I.sourceStart==null)return;await vh();const N=((H=i.value)==null?void 0:H.querySelector(`[data-source-start="${I.sourceStart}"]`))??((Z=i.value)==null?void 0:Z.querySelector(".source-line.is-highlighted"));N==null||N.scrollIntoView({block:"center",behavior:"smooth"})},{immediate:!0});function F(I){return e.items.findIndex(T=>T.id===I.id)+1}function B(I){var T;if((T=I.sourcePages)!=null&&T.length){const N=I.sourcePages[0],H=I.sourcePages[I.sourcePages.length-1];return N===H?`来源:第 ${N}`:`来源:第 ${N}${H}`}return I.sourceStartLine==null||I.sourceEndLine==null?"手动新增,无源文件定位":I.sourceStartLine===I.sourceEndLine?`来源:第 ${I.sourceStartLine}`:`来源:第 ${I.sourceStartLine}${I.sourceEndLine}`}return(I,T)=>{const N=qd,H=Xd,Z=Ml,P=jd,K=Iy;return O(),$("section",jE,[x("div",WE,[x("div",XE,[T[5]||(T[5]=x("span",null,"当前文件",-1)),V(H,{"model-value":u.selectedFileId,filterable:"",placeholder:"选择文件","aria-label":"选择当前预览文件","onUpdate:modelValue":T[0]||(T[0]=z=>s("update:selectedFileId",z))},{default:tt(()=>[(O(!0),$(xt,null,xe(u.files,z=>(O(),Pt(N,{key:z.id,label:z.name,value:z.id},{default:tt(()=>[x("div",qE,[x("strong",{title:z.name},G(z.name),9,YE),x("span",null,G(z.count.toLocaleString())+" "+G(u.processType==="unstructured"?"个切片":"条记录"),1),z.modifiedCount?(O(),$("em",KE,G(z.modifiedCount)+" 处已修改",1)):ct("",!0)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),x("span",QE,G(u.files.length)+" 个文件 · 当前文件 "+G(u.items.length.toLocaleString())+" "+G(u.processType==="unstructured"?"个切片":"条记录"),1)]),x("div",JE,[x("div",ZE,[x("div",tC,[x("div",null,[x("strong",null,"源文件 · "+G(u.fileName),1)])]),g.value?(O(),Pt(zE,{key:0,"task-id":u.taskId,"source-file-id":u.sourceFileId,"file-name":u.fileName,"selected-item":h.value??null},null,8,["task-id","source-file-id","file-name","selected-item"])):b.value?(O(),Pt(vx,{key:1,"task-id":u.taskId,"source-file-id":u.sourceFileId,"file-name":u.fileName,"file-format":f.value,"selected-item":h.value??null},null,8,["task-id","source-file-id","file-name","file-format","selected-item"])):(O(),$("div",{key:2,ref_key:"sourceViewerRef",ref:i,class:"source-viewer",tabindex:"0","aria-label":"源文件内容"},[(O(!0),$(xt,null,xe(c.value,z=>(O(),$("div",{key:z.number,class:re(["source-line",{"is-highlighted":y(z.start,z.end)}]),"data-source-start":z.start},[x("span",sC,G(z.number),1),x("span",iC,G(z.content||" "),1)],10,eC))),128))],512))]),x("div",nC,[x("div",rC,[x("strong",null,G(u.processType==="unstructured"?"切片内容":"记录内容"),1),x("div",aC,[x("span",null,"共 "+G(u.items.length.toLocaleString())+" 条",1),V(Z,{link:"",type:"primary",onClick:T[1]||(T[1]=z=>s("add:item"))},{default:tt(()=>[...T[6]||(T[6]=[x("i",{class:"fa fa-plus"},null,-1),at(" 手动新增 ",-1)])]),_:1})])]),d.value?(O(),$("div",pC,[x("div",gC,[x("div",null,[x("strong",null,G(u.processType==="unstructured"?"切片":"记录")+" #"+G(String(F(d.value)).padStart(3,"0"))+" 正文",1),x("small",null,G(B(d.value)),1)])]),V(P,{modelValue:l.value,"onUpdate:modelValue":T[4]||(T[4]=z=>l.value=z),type:"textarea",rows:7,resize:"none"},null,8,["modelValue"]),x("div",mC,[d.value.sourceStart!=null?(O(),Pt(Z,{key:0,link:"",onClick:k},{default:tt(()=>[...T[10]||(T[10]=[x("i",{class:"fa fa-undo"},null,-1),at(" 恢复原始内容 ",-1)])]),_:1})):ct("",!0),x("div",null,[V(Z,{onClick:C},{default:tt(()=>[...T[11]||(T[11]=[at("取消",-1)])]),_:1}),V(Z,{type:"primary",onClick:E},{default:tt(()=>[...T[12]||(T[12]=[at("保存修改",-1)])]),_:1})])])])):(O(),$(xt,{key:0},[x("div",oC,[V(P,{modelValue:r.value,"onUpdate:modelValue":T[2]||(T[2]=z=>r.value=z),clearable:"",placeholder:"搜索编号或内容",size:"small"},{prefix:tt(()=>[...T[7]||(T[7]=[x("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"])]),x("div",lC,[(O(!0),$(xt,null,xe(A.value,z=>{var Et,_t;return O(),$("div",{key:z.id,class:re(["preview-item",{"is-active":z.id===((Et=h.value)==null?void 0:Et.id)}]),"data-preview-id":z.id,"aria-selected":z.id===((_t=h.value)==null?void 0:_t.id),role:"button",tabindex:"0",onClick:Ut=>S(z.id),onKeydown:[Hv(Ut=>S(z.id),["enter"]),Hv(ug(Ut=>S(z.id),["prevent"]),["space"])]},[x("span",hC,G(u.processType==="unstructured"?"切片":"记录")+" #"+G(String(F(z)).padStart(3,"0")),1),x("span",uC,G(B(z)),1),x("span",dC,[V(Z,{link:"","aria-label":"编辑切片",title:"编辑",onClick:ug(Ut=>_(z),["stop"])},{default:tt(()=>[...T[8]||(T[8]=[x("i",{class:"fa fa-pencil"},null,-1)])]),_:1},8,["onClick"]),V(Z,{link:"",type:"danger","aria-label":"删除切片",title:"删除",onClick:ug(Ut=>D(z),["stop"])},{default:tt(()=>[...T[9]||(T[9]=[x("i",{class:"fa fa-trash-o"},null,-1)])]),_:1},8,["onClick"])])],42,cC)}),128)),w.value.length?ct("",!0):(O(),$("div",fC,"没有符合条件的内容"))]),w.value.length>kh?(O(),Pt(K,{key:0,"current-page":a.value,"onUpdate:currentPage":T[3]||(T[3]=z=>a.value=z),"page-size":kh,total:w.value.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"preview-pagination",onCurrentChange:M},null,8,["current-page","total"])):ct("",!0)],64))])])])}}}),yC=ri(vC,[["__scopeId","data-v-5f71c077"]]),bC={class:"generation-step"},wC={class:"generation-layout"},AC={class:"summary-panel"},SC={class:"run-icon"},xC={key:0,class:"fa fa-check"},_C={key:1,class:"fa fa-exclamation"},EC={key:2,class:"fa fa-cog fa-spin"},CC={key:3,class:"fa fa-play"},kC=ni({__name:"GenerationStep",props:{taskName:{},processType:{},fileName:{},previewCount:{},modifiedCount:{},generation:{}},emits:["retry"],setup(u,{emit:t}){const e=t;return(s,i)=>{const r=rv,a=Ml;return O(),$("section",bC,[x("div",wC,[x("div",AC,[i[6]||(i[6]=x("div",{class:"panel-heading"},[x("strong",null,"任务摘要"),x("span",null,"已完成预览确认")],-1)),x("dl",null,[x("div",null,[i[1]||(i[1]=x("dt",null,"任务名称",-1)),x("dd",null,G(u.taskName),1)]),x("div",null,[i[2]||(i[2]=x("dt",null,"数据类型",-1)),x("dd",null,G(u.processType==="unstructured"?"非结构化数据":u.processType==="external"?"外来数据源拉取":"结构化数据"),1)]),x("div",null,[i[3]||(i[3]=x("dt",null,"源文件",-1)),x("dd",null,G(u.fileName),1)]),x("div",null,[i[4]||(i[4]=x("dt",null,"预览条目",-1)),x("dd",null,G(u.previewCount.toLocaleString())+" 条",1)]),x("div",null,[i[5]||(i[5]=x("dt",null,"已修改",-1)),x("dd",null,G(u.modifiedCount.toLocaleString())+" 条",1)])])]),x("div",{class:re(["run-panel",`is-${u.generation.status}`])},[x("div",SC,[u.generation.status==="success"?(O(),$("i",xC)):u.generation.status==="failed"?(O(),$("i",_C)):u.generation.status==="running"?(O(),$("i",EC)):(O(),$("i",CC))]),x("h3",null,G(u.generation.status==="idle"?"准备开始处理":u.generation.status==="running"?"正在生成数据":u.generation.status==="success"?"数据生成完成":"生成失败"),1),x("p",null,G(u.generation.message),1),u.generation.status!=="idle"?(O(),Pt(r,{key:0,percentage:u.generation.progress,"stroke-width":10,status:u.generation.status==="success"?"success":void 0},null,8,["percentage","status"])):ct("",!0),i[8]||(i[8]=x("div",{class:"run-meta"},[x("span",null,"解析源数据"),x("span",null,"应用预览修改"),x("span",null,"生成标准结果")],-1)),u.generation.status==="failed"?(O(),Pt(a,{key:1,plain:"",type:"primary",onClick:i[0]||(i[0]=o=>e("retry"))},{default:tt(()=>[...i[7]||(i[7]=[at(" 重新生成 ",-1)])]),_:1})):ct("",!0)],2)])])}}}),TC=ri(kC,[["__scopeId","data-v-e77f8ccf"]]),PC={class:"result-step"},MC={class:"result-workspace"},IC={class:"pane-header result-list-header"},DC={class:"result-list-title"},LC={key:0,class:"fa fa-refresh",style:{"margin-right":"4px"}},RC={key:0,class:"bulk-regeneration-progress"},FC={class:"result-toolbar"},OC={class:"result-list"},NC=["onClick"],BC={class:"result-index"},$C={class:"result-copy"},UC={key:0,class:"css-spinner"},HC={key:0,class:"result-editor-pane"},zC={class:"pane-header"},VC={key:0,class:"modified-label"},GC={class:"result-header-actions"},jC={key:0,class:"fa fa-refresh",style:{"margin-right":"4px"}},WC={class:"source-reference","aria-labelledby":"source-reference-title"},XC={class:"source-reference-heading"},qC={key:0},YC={key:0},KC={key:1},QC={key:2},JC={class:"field-editor"},ZC={class:"field-editor"},tk={class:"field-editor"},ek={key:0,class:"validation-error"},sk={key:1,class:"validation-success"},ik={class:"editor-pagination"},nk=ni({__name:"ResultEditorStep",props:{items:{},previewItems:{},selectedId:{},regeneratingResultId:{},bulkRegeneration:{}},emits:["update:selectedId","update:field","regenerate:item","regenerate:all"],setup(u,{emit:t}){const e=u,s=t,i=it(""),r=it(!1),a=st(()=>e.items.find(C=>C.id===e.selectedId)??e.items[0]),o=st(()=>e.items.findIndex(C=>{var E;return C.id===((E=a.value)==null?void 0:E.id)})),l=st(()=>e.items.filter(C=>C.savedStatus==="invalid").length),c=st(()=>e.bulkRegeneration.status==="running"),h=st(()=>e.bulkRegeneration.status!=="idle"&&e.bulkRegeneration.total>0),d=st(()=>e.bulkRegeneration.total>0?Math.round(e.bulkRegeneration.completed/e.bulkRegeneration.total*100):0),f=C=>e.regeneratingResultId===C||e.bulkRegeneration.targetIds.includes(C),g=st(()=>a.value?f(a.value.id):!1),b=st(()=>{var E;const C=(E=a.value)==null?void 0:E.previewItemId;return C?e.previewItems.find(k=>k.id===C)??null:null}),w=st(()=>{var C,E;return((C=b.value)==null?void 0:C.editedContent.trim())||((E=b.value)==null?void 0:E.originalContent.trim())||""}),A=st(()=>!!(b.value&&b.value.editedContent.trim()&&b.value.editedContent!==b.value.originalContent)),y=st(()=>{const C=b.value;if(!C)return"";const E=[];return C.sourceStartLine!=null&&E.push(C.sourceEndLine!=null&&C.sourceEndLine!==C.sourceStartLine?`${C.sourceStartLine}${C.sourceEndLine}`:`${C.sourceStartLine}`),C.tokenCount>0&&E.push(`${C.tokenCount} Token`),E.join(" · ")}),S=st(()=>e.items.filter((C,E)=>{const k=i.value.trim().toLowerCase();return(!k||C.instruction.toLowerCase().includes(k)||C.output.toLowerCase().includes(k)||String(E+1).includes(k))&&(!r.value||C.status==="invalid")}));function _(C){if(!e.items.length)return;const E=Math.min(Math.max(o.value+C,0),e.items.length-1);s("update:selectedId",e.items[E].id)}return(C,E)=>{const k=Ml,D=rv,M=jd,F=jp,B=cA;return O(),$("section",PC,[x("div",MC,[x("aside",{class:re(["result-list-pane",{"has-bulk-progress":h.value}])},[x("div",IC,[x("div",DC,[E[9]||(E[9]=x("strong",null,"生成结果",-1)),x("span",null,"共 "+G(u.items.length)+" 条",1)]),l.value>0?(O(),Pt(k,{key:0,size:"small",plain:"",type:"primary",loading:c.value,disabled:!!u.regeneratingResultId||c.value,onClick:E[0]||(E[0]=I=>s("regenerate:all"))},{default:tt(()=>[c.value?ct("",!0):(O(),$("i",LC)),at(" "+G(c.value?"重新生成中":`全部重新生成(${l.value}`),1)]),_:1},8,["loading","disabled"])):ct("",!0)]),h.value?(O(),$("div",RC,[x("div",null,[x("span",null,"已处理 "+G(u.bulkRegeneration.completed)+" / "+G(u.bulkRegeneration.total),1),x("span",null,"成功 "+G(u.bulkRegeneration.succeeded)+" · 失败 "+G(u.bulkRegeneration.failed),1)]),V(D,{percentage:d.value,"show-text":!1,"stroke-width":5,color:u.bulkRegeneration.failed>0?"#d97706":"#5b50f2"},null,8,["percentage","color"])])):ct("",!0),x("div",FC,[V(M,{modelValue:i.value,"onUpdate:modelValue":E[1]||(E[1]=I=>i.value=I),clearable:"",size:"small",placeholder:"搜索结果"},{prefix:tt(()=>[...E[10]||(E[10]=[x("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"]),V(F,{modelValue:r.value,"onUpdate:modelValue":E[2]||(E[2]=I=>r.value=I)},{default:tt(()=>[...E[11]||(E[11]=[at("仅看错误",-1)])]),_:1},8,["modelValue"])]),x("div",OC,[(O(!0),$(xt,null,xe(S.value,I=>{var T;return O(),$("button",{key:I.id,type:"button",class:re(["result-item",{"is-active":I.id===((T=a.value)==null?void 0:T.id)}]),onClick:N=>s("update:selectedId",I.id)},[x("span",BC,"#"+G(String(u.items.findIndex(N=>N.id===I.id)+1).padStart(3,"0")),1),x("span",$C,[x("strong",null,G(I.instruction||"未填写指令"),1),x("small",null,G(I.output||"未填写输出"),1)]),f(I.id)?(O(),$("i",UC)):(O(),$("i",{key:1,class:re(["fa",I.status==="invalid"?"fa-exclamation-circle is-error":"fa-check-circle is-valid"])},null,2))],10,NC)}),128))])],2),a.value?(O(),$("div",HC,[x("div",zC,[x("div",null,[x("strong",null,"结果 #"+G(String(o.value+1).padStart(3,"0")),1),a.value.status==="modified"?(O(),$("span",VC,"已修改")):ct("",!0),a.value.split?(O(),Pt(B,{key:1,size:"small",effect:"plain"},{default:tt(()=>[at(G(a.value.split),1)]),_:1})):ct("",!0),a.value.qualityScore!=null?(O(),Pt(B,{key:2,size:"small",type:a.value.qualityScore>=80?"success":a.value.qualityScore>=60?"warning":"danger"},{default:tt(()=>[at("质量 "+G(a.value.qualityScore.toFixed(1)),1)]),_:1},8,["type"])):ct("",!0)]),x("div",GC,[a.value.savedStatus==="invalid"?(O(),Pt(k,{key:0,size:"small",plain:"",type:"primary",loading:g.value,disabled:c.value||!!u.regeneratingResultId&&!g.value,onClick:E[3]||(E[3]=I=>s("regenerate:item",a.value.id))},{default:tt(()=>[g.value?ct("",!0):(O(),$("i",jC)),E[12]||(E[12]=at(" 重新生成 ",-1))]),_:1},8,["loading","disabled"])):ct("",!0)])]),x("article",WC,[x("div",XC,[x("div",null,[E[13]||(E[13]=x("strong",{id:"source-reference-title"},"原文参照",-1)),y.value?(O(),$("span",qC,G(y.value),1)):ct("",!0)]),A.value?(O(),Pt(B,{key:0,size:"small",effect:"plain"},{default:tt(()=>[...E[14]||(E[14]=[at("已智能预处理",-1)])]),_:1})):ct("",!0)]),w.value?(O(),$("pre",YC,G(w.value),1)):(O(),$("p",KC,"当前结果没有关联到可用的原文切片。")),A.value?(O(),$("small",QC,"这里展示的是实际送入模型的预处理后原文,便于核对问题和答案是否有依据。")):ct("",!0)]),x("div",JC,[E[15]||(E[15]=x("label",null,[at("Instruction "),x("em",null,"必填")],-1)),V(M,{"model-value":a.value.instruction,disabled:g.value,type:"textarea",rows:3,"onUpdate:modelValue":E[4]||(E[4]=I=>s("update:field",a.value.id,"instruction",I))},null,8,["model-value","disabled"])]),x("div",ZC,[E[16]||(E[16]=x("label",null,[at("Input "),x("span",null,"选填")],-1)),V(M,{"model-value":a.value.input,disabled:g.value,type:"textarea",rows:2,"onUpdate:modelValue":E[5]||(E[5]=I=>s("update:field",a.value.id,"input",I))},null,8,["model-value","disabled"])]),x("div",tk,[E[17]||(E[17]=x("label",null,[at("Output "),x("em",null,"必填")],-1)),V(M,{"model-value":a.value.output,disabled:g.value,type:"textarea",rows:7,"onUpdate:modelValue":E[6]||(E[6]=I=>s("update:field",a.value.id,"output",I))},null,8,["model-value","disabled"])]),a.value.error?(O(),$("div",ek,[E[18]||(E[18]=x("i",{class:"fa fa-exclamation-circle"},null,-1)),at(" "+G(a.value.error),1)])):(O(),$("div",sk,[...E[19]||(E[19]=[x("i",{class:"fa fa-check-circle"},null,-1),at(" 字段校验通过 ",-1)])])),x("div",ik,[V(k,{disabled:o.value<=0,onClick:E[7]||(E[7]=I=>_(-1))},{default:tt(()=>[...E[20]||(E[20]=[at("上一条",-1)])]),_:1},8,["disabled"]),x("span",null,G(o.value+1)+" / "+G(u.items.length),1),V(k,{disabled:o.value>=u.items.length-1,onClick:E[8]||(E[8]=I=>_(1))},{default:tt(()=>[...E[21]||(E[21]=[at("下一条",-1)])]),_:1},8,["disabled"])])])):ct("",!0)])])}}}),rk=ri(nk,[["__scopeId","data-v-14f05d29"]]),wy=500,vf=1500,Ay=12;function yf(u){var t;return{id:String(u.id),previewItemId:u.preview_item_id==null?null:String(u.preview_item_id),instruction:u.instruction,input:u.input||"",output:u.output,originalInstruction:u.original_instruction??u.instruction,originalInput:u.original_input??u.input??"",originalOutput:u.original_output??u.output,savedInstruction:u.instruction,savedInput:u.input||"",savedOutput:u.output,savedStatus:u.status,status:u.status,error:u.error||void 0,split:u.split||void 0,qualityScore:(t=u.quality_score)==null?void 0:t.overall,updatedAt:u.updated_at}}function ak(u){const t=it([]),e=it(null),s=it(null),i=ap({status:"idle",total:0,completed:0,succeeded:0,failed:0,targetIds:[],failedIds:[]}),r=st(()=>!!s.value||i.status==="running"),a=ap({status:"idle",progress:0,message:"确认摘要后即可开始生成,过程中可查看实时进度。"});let o=null,l=0,c=0,h=!1;function d(){l+=1,o&&clearTimeout(o),o=null}function f(){d(),a.status="idle",a.progress=0,a.message="确认摘要后即可开始生成,过程中可查看实时进度。",t.value=[],e.value=null,s.value=null,Object.assign(i,{status:"idle",total:0,completed:0,succeeded:0,failed:0,targetIds:[],failedIds:[]})}function g(M){a.progress=Math.max(0,Math.min(100,Number(M.progress)||0)),a.message=M.message||(M.status==="running"?"后端正在生成标准化结果并进行质量评分。":M.status==="completed"?"数据处理已完成。":M.failure_reason||"任务已停止。")}async function b(M){var T;const F=await Vv(M,{page:1,page_size:wy}),B=[...F.items],I=Math.ceil(F.total/F.page_size);for(let N=2;N<=I;N+=1){const H=await Vv(M,{page:N,page_size:wy});B.push(...H.items)}t.value=B.map(yf),e.value=((T=t.value[0])==null?void 0:T.id)??null}async function w(M,F=!0){if(c=0,g(M),M.status==="completed"){const B=u.taskId.value;if(!B)return;await b(B),a.status="success",a.progress=100,a.message=`已完成 ${t.value.length.toLocaleString()} 条数据处理,可进入结果页检查。`,F&&lt.success("数据处理完成");return}(M.status==="failed"||M.status==="stopped")&&(a.status="failed",a.message=M.failure_reason||M.message||(M.status==="stopped"?"任务已停止,可以重新生成。":"数据处理失败,请检查配置后重试。"))}async function A(M){const F=u.taskId.value;if(!(!F||M!==l||a.status!=="running"))try{const B=await zv(F);if(M!==l)return;if(c=0,B.status==="running"||B.status==="pending"){g(B),o=setTimeout(()=>void A(M),vf);return}await w(B)}catch(B){if(M!==l)return;if(c+=1,c<=3){a.message=`进度查询暂时失败,正在重试(${c}/3`,o=setTimeout(()=>void A(M),vf);return}a.status="failed",a.message=B instanceof Error?B.message:"查询任务进度失败,请重试。"}}async function y(){var B;if(h||a.status==="running")return!1;const M=u.taskId.value;if(!M)return lt.error("任务尚未创建,请返回上一步重试"),!1;h=!0;let F=null;try{if(await((B=u.beforeGenerate)==null?void 0:B.call(u))===!1)return!1;d();const T=l;F=T,a.status="running",c=0,a.progress=0,a.message="正在同步预览修改并启动后端处理,请稍候。";const N=await fA(M);return T!==l?!1:N.status==="completed"||N.status==="failed"||N.status==="stopped"?(await w(N),!0):(g(N),o=setTimeout(()=>void A(T),vf),!0)}catch(I){return F!==null&&F!==l?void 0:(a.status="failed",a.message=I instanceof Error?I.message:"启动数据处理失败,请重试。",!1)}finally{h=!1}}async function S(){const M=u.taskId.value;if(!M)return;d();const F=l;c=0;try{const B=await zv(M);if(F!==l)return;if(B.status==="running"){a.status="running",g(B),o=setTimeout(()=>void A(F),vf);return}if(B.status==="completed"){await w(B,!1);return}if(B.status==="failed"||B.status==="stopped"){await w(B,!1);return}a.status="idle",g(B)}catch(B){a.status="failed",a.message=B instanceof Error?B.message:"查询任务进度失败,请重试。"}}function _(M,F,B){const I=t.value.find(H=>H.id===M);if(!I)return;I[F]=B;const T=I.instruction.trim()&&I.output.trim();I.error=T?void 0:"Instruction 和 Output 不能为空";const N=I.instruction!==I.originalInstruction||I.input!==I.originalInput||I.output!==I.originalOutput;I.status=I.error?"invalid":N?"modified":"valid",u.dirty.value=!0}async function C(M){const F=u.taskId.value,B=t.value.find(I=>I.id===M);if(!F||!B)return!1;if(r.value)return lt.warning("请等待当前失败结果重新生成完成"),!1;if(B.savedStatus!=="invalid")return lt.warning("只有生成失败的结果可以重新生成"),!1;if(!B.updatedAt)return lt.error("结果版本信息缺失,请刷新页面后重试"),!1;s.value=M;try{const I=await pA(F,M,{expected_updated_at:B.updatedAt}),T=t.value.findIndex(N=>N.id===M);return T>=0&&(t.value[T]=yf(I)),lt.success("当前结果已重新生成"),!0}catch{return!1}finally{s.value=null}}async function E(){const M=u.taskId.value;if(!M)return!1;if(r.value)return lt.warning("请等待当前失败结果重新生成完成"),!1;const F=t.value.filter(T=>T.savedStatus==="invalid");if(!F.length)return lt.info("当前没有需要重新生成的失败结果"),!1;const B=F.find(T=>T.instruction!==T.savedInstruction||T.input!==T.savedInput||T.output!==T.savedOutput);if(B)return e.value=B.id,lt.warning("失败结果存在未保存修改,请先保存或恢复后再全部重新生成"),!1;const I=F.find(T=>!T.updatedAt);if(I)return e.value=I.id,lt.error("失败结果版本信息缺失,请刷新页面后重试"),!1;Object.assign(i,{status:"running",total:F.length,completed:0,succeeded:0,failed:0,targetIds:F.map(T=>T.id),failedIds:[]});try{for(let N=0;N<F.length;N+=Ay){const H=F.slice(N,N+Ay);try{const Z=await gA(M,{items:H.map(P=>({result_id:P.id,expected_updated_at:P.updatedAt}))});for(const P of Z.items){const K=t.value.findIndex(z=>z.id===String(P.id));K>=0&&(t.value[K]=yf(P))}i.completed+=Z.total,i.succeeded+=Z.succeeded,i.failed+=Z.failed,i.failedIds.push(...Z.failures.map(P=>P.result_id))}catch{const Z=F.slice(N);i.completed=i.total,i.failed+=Z.length,i.failedIds.push(...Z.map(P=>P.id));break}}i.failed===0?(i.status="completed",lt.success(`已重新生成 ${i.succeeded} 条失败结果`)):i.succeeded>0?(i.status="partial",lt.warning(`重新生成完成:成功 ${i.succeeded} 条,仍失败 ${i.failed}`)):(i.status="failed",lt.error(`重新生成失败:${i.failed} 条结果仍需重试`));const T=i.failedIds.find(N=>{var H;return((H=t.value.find(Z=>Z.id===N))==null?void 0:H.savedStatus)==="invalid"});return T&&(e.value=T),i.failed===0}catch{const T=Math.max(0,i.total-i.completed),N=F.filter(H=>{var Z;return((Z=t.value.find(P=>P.id===H.id))==null?void 0:Z.savedStatus)==="invalid"}).map(H=>H.id);return i.completed=i.total,i.failed+=T,i.failedIds=[...new Set([...i.failedIds,...N])],i.status="failed",i.failedIds[0]&&(e.value=i.failedIds[0]),lt.error("批量重新生成意外中断,尚未成功的结果保持原状"),!1}finally{i.targetIds=[]}}async function k(){const M=u.taskId.value;if(!M)throw new Error("任务尚未创建");const F=t.value.filter(B=>B.instruction!==B.savedInstruction||B.input!==B.savedInput||B.output!==B.savedOutput);for(const B of F){const I=await mA(M,B.id,{instruction:B.instruction,input:B.input,output:B.output,expected_updated_at:B.updatedAt}),T=t.value.findIndex(N=>N.id===B.id);T>=0&&(t.value[T]=yf(I))}}function D(){let M=null;for(const F of t.value)(!F.instruction.trim()||!F.output.trim()||F.status==="invalid")&&(F.error||(F.error="结果未通过后端质量校验,请修改后重新保存"),F.status="invalid",M??(M=F.id));return M&&(e.value=M),M==null}return{bulkRegeneration:i,generation:a,regeneratingResultId:s,resultRegenerationBusy:r,results:t,selectedResultId:e,persistResultChanges:k,resetDownstream:f,regenerateAllResults:E,regenerateResult:C,resumeGeneration:S,startGeneration:y,stopGenerationTimer:d,updateResultField:_,validateResults:D}}const ok=1500,lk=3;function ck(u){return u.preview_status==="queued"||u.preview_status==="running"}function hk(){return new Promise(u=>setTimeout(u,ok))}function uk(){let u=0;function t(){u+=1}async function e(a,o,l,c){let h=o,d=0;if(l!==u)return h;for(c==null||c(h);ck(h)&&l===u&&(await hk(),l===u);)try{h=await Gv(a),d=0,c==null||c(h)}catch(f){if(d+=1,d>=lk)throw f}return h}async function s(a,o,l){t();const c=u,h=await vA(a,{replace_existing:!0,source_file_ids:o});return e(a,h,c,l)}async function i(a,o){t();const l=u,c=await Gv(a);return e(a,c,l,o)}async function r(a,o,l){const h=await s(a,o,d=>{for(const f of o)d.preview_status==="completed"?l({source_file_id:f,status:"success",progress:100}):d.preview_status==="failed"||d.preview_status==="cancelled"?l({source_file_id:f,status:"failed",progress:0,error:d.preview_failure_reason||"切分失败,请重试"}):l({source_file_id:f,status:"processing",progress:d.preview_progress})});return o.map(d=>h.preview_status==="completed"?{source_file_id:d,status:"success",progress:100}:{source_file_id:d,status:"failed",progress:0,error:h.preview_failure_reason||"切分失败,请重试"})}return Gp(t),{startPreviewBuild:s,resumePreviewBuild:i,buildPreviewsByFile:r,stopPreviewPolling:t}}const Sy=new Set(["xlsx","pdf","docx","pptx"]),dk=new Set(["json","jsonl","ndjson","csv","tsv","xlsx"]),fk=new Set(["txt","md","markdown","pdf","docx","pptx","json","jsonl","ndjson"]),pk=new Set(["doc","xls","ppt"]),gk=200*1024*1024,xy=20,mk=500*1024*1024;function vk(u,t,e){var a;if(u.size>gk)return{valid:!1,severity:"warning",message:"单文件不能超过 200MB"};const s=((a=u.name.split(".").pop())==null?void 0:a.toLowerCase())??"";return pk.has(s)?{valid:!1,severity:"error",message:"旧版 DOC、XLS、PPT 文件暂不支持,请分别转换为 DOCX、XLSX、PPTX 后上传"}:(t==="unstructured"?fk:dk).has(s)?e.some(o=>o.name===u.name&&o.size===u.size)?{valid:!1,severity:"warning",message:"同名且同大小的文件已经选择"}:e.length>=xy?{valid:!1,severity:"warning",message:`每个任务最多选择 ${xy} 个文件`}:e.reduce((o,l)=>o+l.size,0)+u.size>mk?{valid:!1,severity:"warning",message:"当前任务选择的文件总大小不能超过 500MB"}:{valid:!0,extension:s}:{valid:!1,severity:"error",message:t==="unstructured"?"非结构化数据支持 TXT、MD、MARKDOWN、PDF、DOCX、PPTX、JSON、JSONL、NDJSON":"结构化数据支持 JSON、JSONL、NDJSON、CSV、TSV、XLSX"}}function bv(u,t=""){return{uid:String(u.id),sourceFileId:String(u.id),name:u.name,size:u.size_bytes,count:u.record_count,content:t,fileFormat:u.file_format,checksumSha256:u.checksum_sha256,status:"ready",uploadProgress:100,previewStatus:"waiting",previewProgress:0}}function yk(u){var s;const t=(s=u==null?void 0:u.response)==null?void 0:s.data,e=t==null?void 0:t.detail;return typeof e=="string"?e:e!=null&&e.message?e.message:t!=null&&t.message?t.message:u instanceof Error&&u.message?u.message:"上传失败,请删除该文件后重新选择"}function bk(u){const t=it(!1),e=[];let s=null;async function i(o){const l=u.uploadedFiles.value.find(h=>String(h.uid)===o.uid);if(!l)return;const c=u.taskId.value;if(!c){l.status="failed",l.uploadError="任务尚未创建,请返回模型选择步骤后重试";return}l.status="uploading",l.uploadProgress=0,l.uploadError=void 0;try{let h="";if(!Sy.has(o.extension)){try{h=new TextDecoder("utf-8",{fatal:!0}).decode(await o.file.arrayBuffer())}catch{throw new Error("文本文件不是有效的 UTF-8 编码,请转换编码后重试")}if(!h.trim())throw new Error("不能上传空文件")}const f=(await yA(c,[o.file],g=>{l.uploadProgress=g})).files[0];if(!f)throw new Error("后端未返回源文件记录");if(Object.assign(l,bv(f),{rawFile:o.file,status:"uploading",uploadProgress:99}),Sy.has(o.extension))try{const g=await av(c,f.id,{start_line:1,line_count:1e4});l.content=g.content}catch{}else l.content=h;l.status="ready",l.uploadProgress=100,u.onUploaded(l)}catch(h){l.status="failed",l.uploadError=yk(h)}}async function r(){t.value=!0;try{for(;e.length;){const o=e.shift();o&&await i(o)}}finally{t.value=!1}}function a(o){e.push(o),!s&&(s=r().finally(()=>{s=null}))}return{enqueueSourceUpload:a,sourceUploading:t}}async function wk(u,t){const e=[];let s=1;for(;;){const i=await av(u,t,{start_line:s,line_count:1e4});if(e.push(i.content||""),!i.has_more)break;const r=Number(i.end_line||s)+1;if(r<=s)break;s=r}return e.join("")}async function Ak(u,t){const e=await op(u,{page:1,page_size:500}),s=[...e.items],i=Math.ceil(e.total/e.page_size);for(let r=2;r<=i;r+=1){const a=await op(u,{page:r,page_size:500});s.push(...a.items)}return s.map(t)}function Sk(u){const t=tA(),e=st(()=>t.name==="data-process-regenerate"),s=st(()=>t.name==="data-process-workflow"),i=st(()=>e.value||s.value?String(t.params.id||""):""),r=it(null),a=it(""),o=it(!1),l=it(""),c=it(""),h=it(!1),d=it("");async function f(y,S){var k,D;const _=String(y.id);u.uploadedFiles.value=await Promise.all((y.source_files||[]).map(async M=>bv(M,await wk(_,M.id)))),u.previewItems.value=S?await Ak(_,u.mapPreviewItem):[];const C=u.buildPreviewConfigSignature(),E=new Map;for(const M of u.previewItems.value)E.set(M.sourceFileId,(E.get(M.sourceFileId)||0)+1);for(const M of u.uploadedFiles.value){const F=E.get(String(M.sourceFileId))||0;M.previewCount=F,M.previewStatus=S&&F>0?"success":"waiting",M.previewProgress=S&&F>0?100:0,M.previewConfigSignature=S&&F>0?C:void 0}u.selectedPreviewFileId.value=String(((k=u.uploadedFiles.value[0])==null?void 0:k.uid)??"")||null,u.selectedPreviewId.value=u.selectedPreviewFileId.value?((D=u.previewItems.value.find(M=>M.sourceFileId===u.selectedPreviewFileId.value))==null?void 0:D.id)??null:null,u.selectedPreviewIdsByFile.value=u.selectedPreviewFileId.value&&u.selectedPreviewId.value?{[u.selectedPreviewFileId.value]:u.selectedPreviewId.value}:{},u.previewSignature.value=S&&u.previewItems.value.length?u.buildPreviewSignature():"",u.resetDownstream()}async function g(){if(i.value){h.value=!0,d.value="";try{const y=await dg(i.value),S=y.process_type;r.value=e.value?S:null,a.value=y.updated_at,u.task.name=y.name,u.task.description=y.description||"",u.processType.value=S;const _=y.config||{};return u.structuredOptions.value=YA(_),u.unstructuredOptions.value=KA(_),l.value=u.buildPreviewConfigSignature(),c.value="",await f(y,!0),await vh(),u.dirty.value=!1,y}catch(y){d.value=y instanceof Error?y.message:"原数据处理任务加载失败,请返回详情页后重试"}finally{h.value=!1}}}async function b(y){if(!e.value||!u.previewItems.value.length)return!0;const S=u.buildPreviewConfigSignature();if(!(S!==l.value)||S===c.value)return!0;const C=await y({title:"确认修改切分配置?",message:"修改预处理或切分配置后,将按新配置重新切分。在点击“开始生成”前,原生成结果和已发布数据会继续保留。",confirmText:"确认并继续",cancelText:"返回检查",tone:"warning"});return C&&(c.value=S),!!C}async function w(y){if(o.value){const _=await dg(i.value);a.value=_.updated_at||a.value}const S=await bA(i.value,{...y,expected_updated_at:a.value});a.value=S.task.updated_at||a.value,l.value=u.buildPreviewConfigSignature(),c.value="",o.value=!0,u.dirty.value=!0;try{const _=S.task.source_files?S.task:await dg(S.task.id);a.value=_.updated_at||a.value,h.value=!0;try{await f(_,!S.preview_invalidated)}finally{h.value=!1}}catch(_){throw d.value=_ instanceof Error?`重新生成配置已保存,但工作区恢复失败:${_.message}`:"重新生成配置已保存,但工作区恢复失败,请重试加载原任务",_}return S}async function A(y,S){return e.value&&!await y({title:"开始重新生成?",message:"点击开始后,当前生成结果将被替换。已发布数据集会继续保留,直到重新发布。",confirmText:"开始生成",cancelText:"继续检查",tone:"warning"})?!1:(await S(),!0)}return{sourceTaskId:i,isRegeneration:e,isWorkflowResume:s,originalProcessType:r,originalTaskUpdatedAt:a,regenerationPrepared:o,hydrating:h,initializationError:d,hydrateWorkspace:f,loadSource:g,confirmPreviewConfigChange:b,prepareRegeneration:w,confirmStartGeneration:A}}const xk={class:"create-wizard-layout"},_k={class:"wizard-main"},Ek={class:"wizard-main-inner"},Ck={class:"wizard-steps-container"},kk={class:"custom-wizard-steps"},Tk=["aria-current"],Pk={class:"step-node"},Mk={class:"step-icon"},Ik={key:0,class:"fa fa-check"},Dk={key:1},Lk={class:"step-text"},Rk={class:"step-title"},Fk={class:"wizard-content"},Ok={key:0,class:"initialization-error",role:"alert"},Nk={class:"wizard-footer"},Bk={class:"footer-left"},$k={class:"footer-right"},Uk="backend-pipeline-v4",Hk=ni({__name:"DataProcessCreateView",setup(u){const t=rA(),e=MA(),{list:s,loaded:i}=eA(e),r=st(()=>s.value),a=it(),o=it(),l=it(),c=[{id:"create",title:"创建任务",desc:"填写任务信息与处理配置"},{id:"model",title:"大模型选择",desc:"选择生成模型并设置输出要求"},{id:"upload",title:"上传文件",desc:"上传或接入待处理的源数据"},{id:"preview",title:"数据预览",desc:"核对源文件与预览内容"},{id:"generate",title:"开始生成",desc:"确认摘要并启动处理"},{id:"results",title:"结果编辑与保存",desc:"检查、修改并保存结果"}],h=it(0),d=st(()=>{var L;return((L=c[h.value])==null?void 0:L.id)??"create"}),f=ap({name:"",description:""}),g=it(null),b=it("structured"),w=it(Oy()),A=it(Ny()),y=st(()=>b.value==="unstructured"?A.value:w.value),S=it([]),_=it(!1),{resumePreviewBuild:C,startPreviewBuild:E,stopPreviewPolling:k}=uk(),D=ap({type:"postgresql",url:"",authMode:"none",username:"",password:"",limit:1e3,query:"",fileName:"external-data.jsonl"}),M=it(!1),F=it(!1),B=st(()=>S.value.map(L=>L.name).join(", ")),I=it(""),T=it([]),N=it(null),H=it(null),Z=it({}),P=it(!1),K=it(!1);let z=!1;const{bulkRegeneration:Et,generation:_t,regeneratingResultId:Ut,resultRegenerationBusy:Ot,results:X,selectedResultId:W,persistResultChanges:gt,resetDownstream:rt,regenerateAllResults:ut,regenerateResult:Qt,resumeGeneration:ys,startGeneration:ai,stopGenerationTimer:ji,updateResultField:as,validateResults:kn}=ak({taskId:g,dirty:P,beforeGenerate:E0}),{enqueueSourceUpload:La,sourceUploading:Ee}=bk({taskId:g,uploadedFiles:S,onUploaded(L){I.value="",rt(),P.value=!0,lt.success(`文件 ${L.name} 上传成功,等待切分`)}}),Pe=st(()=>S.value.some(L=>L.status!=="ready"||!L.sourceFileId)),Ds=st(()=>T.value.filter(L=>L.status!=="original").length),Ah=st(()=>{const L=new Map;for(const U of T.value){const Q=L.get(U.sourceFileId)||[];Q.push(U),L.set(U.sourceFileId,Q)}return L}),Ci=st(()=>S.value.find(L=>String(L.uid)===N.value)),Wi=st(()=>Ah.value.get(N.value||"")||[]),Sh=st(()=>{var L;return((L=Ci.value)==null?void 0:L.content)??""}),tf=st(()=>S.value.map(L=>{const U=Ah.value.get(String(L.uid))||[];return{id:String(L.uid),name:L.name,count:U.length,modifiedCount:U.filter(Q=>Q.status!=="original").length}})),xh=st(()=>d.value==="create"?"继续:选择大模型":d.value==="model"?"继续:上传文件":d.value==="upload"?Ee.value?"正在上传":_.value?"正在切分":"继续:数据预览":d.value==="preview"?"确认预览并继续":d.value==="results"?"保存任务":_t.status==="running"?"正在生成":_t.status==="success"?"查看生成结果":_t.status==="failed"?"重新生成":"开始生成"),g0=st(()=>d.value==="results"?"fa-check":d.value==="generate"&&_t.status!=="success"?"fa-play":"fa-arrow-right"),m0=st(()=>h.value>0?c[h.value-1].title:"");function Er(L){const U=c.findIndex(Q=>Q.id===L);U>=0&&(h.value=U)}function v0(L){if(b.value==="unstructured"){A.value={...A.value,...L};return}w.value={...w.value,...L}}function y0(){const L=b.value==="unstructured"?A.value:w.value,U={preprocess_options:[...L.preprocessOptions],semantic_enrichment:L.semanticEnrichment,dataset_split:{...L.datasetSplit},generation_model_id:L.generationModelId,generation_prompt:L.generationPrompt,output_type:L.outputType,reasoning_detail:L.reasoningDetail,temperature:L.temperature,max_tokens:L.maxTokens,json_mode:L.jsonMode,quality_filter_enabled:L.qualityFilterEnabled,filter_low_quality:L.filterLowQuality,filter_short_content:L.filterShortContent,min_output_length:L.minOutputLength};return b.value==="unstructured"?{...U,chunk_method:A.value.chunkMethod,chunk_size:A.value.chunkSize,chunk_overlap:A.value.chunkOverlap,min_chunk_size:A.value.minChunkSize,semantic_breakpoint_percentile:A.value.semanticBreakpointPercentile,preserve_tables:A.value.preserveTables,preserve_code_blocks:A.value.preserveCodeBlocks,preserve_lists:A.value.preserveLists,qa_pairs_per_chunk:A.value.qaPairsPerChunk}:{...U,qa_pairs_per_row:w.value.qaPairsPerRow}}function ef(){return{name:f.name.trim(),description:f.description.trim(),process_type:af.value||b.value,config:y0()}}async function Tn(L){g.value&&await wA(g.value,L)}async function sf(){if(Pn.value){const U=await Iv(ef());return g.value=String(U.task.id),P.value=!1,U.task}const L=g.value?await xA(g.value,ef()):await _A(ef());return g.value=String(L.id),P.value=!1,L}function Tv(){var L;return{type:"postgresql",url:D.url.trim(),auth_mode:D.authMode,username:D.username||void 0,password:D.password||void 0,limit:D.limit,query:((L=D.query)==null?void 0:L.trim())||void 0,file_name:D.fileName||"external-data.jsonl"}}function nf(L){var U;return{id:String(L.id),sourceFileId:String(L.source_file_id),originalContent:L.original_content,editedContent:L.edited_content,savedEditedContent:L.edited_content,sourceStart:L.source_start,sourceEnd:L.source_end,sourceStartLine:L.source_start_line,sourceEndLine:L.source_end_line,tokenCount:L.token_count,status:L.status,sourcePages:Array.isArray((U=L.quality_score)==null?void 0:U.source_pages)?L.quality_score.source_pages.filter(Q=>typeof Q=="number"):[],updatedAt:L.updated_at}}async function b0(){if(!g.value)return[];const L=await op(g.value,{page:1,page_size:500}),U=[...L.items],Q=Math.ceil(L.total/L.page_size);for(let At=2;At<=Q;At+=1){const se=await op(g.value,{page:At,page_size:500});U.push(...se.items)}return U.map(nf)}function w0(){return QA(b.value,w.value,A.value)}function A0(){return JA(b.value,w.value,A.value)}const S0=st(()=>JSON.stringify(A0()));function rf(){return`${Uk}:${b.value}:${JSON.stringify(w0())}`}function og(){const L=S.value.map(U=>`${U.uid}:${U.name}:${U.size}:${U.checksumSha256||U.count}`).join("|");return`${rf()}:${L}`}const{isRegeneration:Pn,isWorkflowResume:Pv,originalProcessType:af,hydrating:Ll,initializationError:lg,loadSource:Mv,confirmPreviewConfigChange:x0,prepareRegeneration:Iv,confirmStartGeneration:_0}=Sk({task:f,processType:b,structuredOptions:w,unstructuredOptions:A,uploadedFiles:S,previewItems:T,selectedPreviewFileId:N,selectedPreviewId:H,selectedPreviewIdsByFile:Z,previewSignature:I,dirty:P,buildPreviewConfigSignature:rf,buildPreviewSignature:og,mapPreviewItem:nf,resetDownstream:rt});async function E0(){return _0(L=>{var U;return((U=l.value)==null?void 0:U.open(L))??Promise.resolve(!1)},cg)}Is([()=>f.name,()=>f.description,b,w,A,D],()=>{Ll.value||(P.value=!0)},{deep:!0}),Is(b,(L,U)=>{if(!Ll.value){if(Pn.value&&af.value&&L!==af.value){b.value=af.value;return}L===U||S.value.length===0||(D0(),lt.info("处理类型已变更,请重新上传或拉取匹配的源数据"))}}),Is(S0,(L,U)=>{Ll.value||L!==U&&rt()});function C0(){var L;(L=document.querySelector(".layout-content"))==null||L.scrollTo({top:0,behavior:"smooth"})}Is(h,()=>vh(C0));function Dv(L){const U=L.raw;if(!U)return;if(!g.value){lt.error("任务尚未创建,请返回模型选择步骤后重试");return}const Q=vk(U,b.value,S.value);if(!Q.valid){lt[Q.severity](Q.message);return}const At=`local-${L.uid}-${Date.now()}-${S.value.length}`;S.value.push({uid:At,rawFile:U,name:U.name,size:U.size,count:0,content:"",fileFormat:Q.extension,status:"queued",uploadProgress:0,previewStatus:"waiting",previewProgress:0}),P.value=!0,La({uid:At,file:U,extension:Q.extension})}async function k0(){if(!g.value){lt.error("任务尚未创建,请返回模型选择步骤后重试");return}const L=new File([VE],"finance_qa.jsonl",{type:"application/x-ndjson"});Dv({raw:L,uid:Date.now(),name:L.name})}function T0(L){Object.assign(D,L),F.value=!1}async function P0(){if(!g.value){lt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!D.url.trim()){lt.warning("请先填写数据源地址");return}M.value=!0;try{const L=await EA(g.value,Tv());F.value=L.connected,L.connected?lt.success(L.message||"数据源连接测试成功"):lt.warning(L.message||"数据源连接失败")}catch{F.value=!1}finally{M.value=!1}}async function M0(){var L;if(!g.value){lt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!D.url.trim()){lt.warning("请先填写数据源地址");return}if(!((L=D.query)!=null&&L.trim())){lt.warning("请先填写只读 SELECT 查询语句");return}M.value=!0;try{const U=await CA(g.value,Tv()),Q=[];for(const At of U.files){const se=await av(g.value,At.id,{start_line:1,line_count:5e3});Q.push(bv(At,se.content))}S.value.push(...Q),F.value=!0,I.value="",rt(),P.value=!0,lt.success(`已成功登记 ${Q.length} 个外部源文件`)}catch{F.value=!1}finally{M.value=!1}}async function I0(L){const U=S.value.findIndex(At=>At.uid===L);if(U<0||!g.value)return;const Q=S.value[U];if(Q){if(Q.status==="uploading"){lt.warning("当前文件正在上传,请等待上传结束后再删除");return}if(Q.sourceFileId)try{await kA(g.value,Q.sourceFileId)}catch{return}S.value.splice(U,1),I.value="",T.value=[],H.value=null,rt(),P.value=!0}}function D0(){S.value=[],I.value="",T.value=[],N.value=null,H.value=null,Z.value={},F.value=!1,rt()}async function L0(){var Q;if(!(!await((Q=a.value)==null?void 0:Q.validate())||!await x0(At=>{var se;return((se=l.value)==null?void 0:se.open(At))??Promise.resolve(!1)}))){if(!Pn.value)try{await sf(),await Tn("model")}catch{return}Er("model")}}async function R0(){var L;if(!K.value){K.value=!0;try{if(await e.load(!0),!i.value){lt.error("模型列表加载失败,未提交任何修改,请稍后重试");return}const U=y.value.generationModelId,Q=r.value.some(se=>String(se.id)===String(U));if(U!==""&&!Q){lt.error(Pn.value?"原任务使用的模型已删除,请重新选择模型":"所选模型已删除,请重新选择");return}if(!await((L=o.value)==null?void 0:L.validate()))return;if(Pn.value){const se=await Iv(ef());g.value=String(se.task.id),P.value=!1,se.preview_invalidated?lt.info("切分配置已保存,后续将按新配置重新切分;点击“开始生成”前,原生成结果和已发布数据保持不变"):se.published_outputs_preserved&&lt.info("重新生成配置已保存;点击“开始生成”前,原生成结果和已发布数据保持不变")}else await sf();await Tn("upload"),P.value=!1,Er("upload")}catch{}finally{K.value=!1}}}function of(L){const U=L.preview_status==="queued"||L.preview_status==="running";_.value=U;for(const Q of S.value)!Q.sourceFileId||Q.previewStatus==="success"||(U?(Q.previewStatus="processing",Q.previewProgress=Math.max(0,Math.min(99,Number(L.preview_progress)||0)),Q.previewError=void 0):(L.preview_status==="failed"||L.preview_status==="cancelled")&&(Q.previewStatus="failed",Q.previewProgress=0,Q.previewError=L.preview_failure_reason||"切分失败,请重试"))}async function F0(){var At,se;T.value=await b0();const L=rf(),U=new Map;for(const Ct of T.value)U.set(Ct.sourceFileId,(U.get(Ct.sourceFileId)||0)+1);for(const Ct of S.value){const Cr=U.get(String(Ct.sourceFileId))||0;Ct.previewCount=Cr,Ct.previewStatus=Cr>0?"success":"failed",Ct.previewProgress=Cr>0?100:0,Ct.previewError=Cr>0?void 0:"该文件没有生成可用的预览条目",Ct.previewConfigSignature=Cr>0?L:void 0}const Q=S.value.filter(Ct=>Ct.previewStatus==="failed").length;return Q||!T.value.length?(lt.warning(`${Q||1} 个文件切分失败;修正问题后可重新切分`),!1):(N.value=String(((At=S.value[0])==null?void 0:At.uid)??"")||null,H.value=((se=Wi.value[0])==null?void 0:se.id)??null,Z.value=H.value&&N.value?{[N.value]:H.value}:{},I.value=og(),rt(),await Tn("preview"),P.value=!1,Er("preview"),!0)}async function Lv(L,U=!1){if(g.value){_.value=!0;try{const Q=U?await C(g.value,of):await E(g.value,L,of);of(Q),Q.preview_status==="completed"?await F0():Q.preview_status==="failed"&&lt.warning(Q.preview_failure_reason||"文件切分失败,请修正后重试")}catch{}finally{_.value=!1}}}async function O0(){if(_.value||Ee.value)return;if(!g.value){lt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(S.value.length===0){lt.warning(b.value==="external"?"请先拉取至少一个数据源":"请上传至少一个源数据文件");return}const L=S.value.filter(Ct=>Ct.status==="failed");if(L.length){lt.warning(`${L.length} 个文件上传失败,请删除后重新选择`);return}if(Pe.value){lt.warning("请等待所有文件上传完成后再开始切分");return}const U=og(),Q=rf(),At=()=>S.value.every(Ct=>Ct.previewStatus==="success"&&Ct.previewConfigSignature===Q);if(U===I.value&&T.value.length&&At()){Er("preview");return}for(const Ct of S.value)Ct.previewConfigSignature!==Q&&(Ct.previewStatus="waiting",Ct.previewProgress=0,Ct.previewError=void 0,Ct.previewCount=void 0);const se=S.value.filter(Ct=>Ct.previewStatus!=="success"||Ct.previewConfigSignature!==Q).map(Ct=>Ct.sourceFileId).filter(Ct=>!!Ct);await Tn("upload"),await Lv(se)}function N0(L){var U;N.value&&H.value&&(Z.value[N.value]=H.value),N.value=L,H.value=Z.value[L]||((U=Wi.value[0])==null?void 0:U.id)||null}function Rv(L){H.value=L,N.value&&(Z.value[N.value]=L)}function B0(L,U){const Q=T.value.find(At=>At.id===L);Q&&(Q.editedContent=U,Q.tokenCount=by(U),Q.status=U===Q.originalContent?"original":Q.sourceStart==null?"manual":"modified",rt(),P.value=!0)}async function cg(){if(!g.value)throw new Error("任务尚未创建");const L=T.value.filter(U=>U.editedContent!==U.savedEditedContent);for(const U of L){const Q=await AA(g.value,U.id,{edited_content:U.editedContent,expected_updated_at:U.updatedAt}),At=T.value.findIndex(se=>se.id===U.id);At>=0&&(T.value[At]=nf(Q))}}function $0(L){const U=T.value.find(Q=>Q.id===L);!U||U.sourceStart==null||(U.editedContent=U.originalContent,U.tokenCount=by(U.originalContent),U.status="original",rt(),P.value=!0)}async function U0(){if(!(!N.value||!g.value))try{const L=await TA(g.value,{source_file_id:N.value,edited_content:""}),U=nf(L);T.value.push(U),Rv(U.id),rt(),P.value=!0}catch{}}async function H0(L){var At,se;if(!await((At=l.value)==null?void 0:At.open({title:"删除预览内容?",message:"删除只影响本次处理,不会修改源文件。删除后可重新从源文件生成预览。",confirmText:"删除",cancelText:"取消",tone:"danger"})))return;const Q=T.value.findIndex(Ct=>Ct.id===L);if(!(Q<0)&&g.value){try{await PA(g.value,L)}catch{return}T.value.splice(Q,1),H.value=((se=Wi.value[Math.min(Q,Wi.value.length-1)])==null?void 0:se.id)??null,N.value&&H.value&&(Z.value[N.value]=H.value),rt(),P.value=!0}}async function z0(){if(d.value==="create"){await L0();return}if(d.value==="model"){await R0();return}if(d.value==="upload"){await O0();return}if(d.value==="preview"){if(!T.value.length){lt.warning("当前没有可生成的预览内容");return}try{await cg(),await Tn("generate")}catch{return}P.value=!1,Er("generate");return}if(d.value==="generate"){if(_t.status==="success"){try{await Tn("results")}catch{return}P.value=!1,Er("results")}else _t.status!=="running"&&await Fv();return}await G0()}async function Fv(){try{await Tn("generate")}catch{return}await ai()&&(P.value=!1)}async function Ov(L){var U;if(!(Pn.value&&!P.value)){if(d.value==="create"){if(!g.value&&!f.name.trim())return;if(!await((U=a.value)==null?void 0:U.validate()))throw new Error("请先完善任务信息");await sf()}else d.value==="model"&&P.value?await sf():d.value==="preview"?await cg():d.value==="results"&&await gt();g.value&&await Tn(L),P.value=!1}}async function Nv(){await Ov(d.value)}async function V0(){var L;if(Ee.value){lt.warning("请等待当前文件上传完成");return}if(_.value){lt.warning("请等待当前文件切分完成");return}if(d.value!=="generate"&&h.value>0){const U=(L=c[h.value-1])==null?void 0:L.id;if(!U)return;try{await Ov(U)}catch{return}h.value-=1}}async function G0(){if(!g.value){lt.error("任务尚未创建,请返回上一步重试");return}if(!kn()){lt.warning("请先修正校验失败的结果");return}try{await gt()}catch{return}if(!kn()){lt.warning("仍有结果未通过后端质量校验,请继续修正");return}try{await Tn("results"),await SA(g.value)}catch{return}P.value=!1,z=!0,lt.success("生成结果已确认"),await t.replace({name:"data-process-detail",params:{id:g.value}})}async function j0(){await W0()}async function W0(){await t.push({name:"data-process"})}sA(async L=>{if(z)return!0;if(L.name==="data-process"&&g.value)try{return await Nv(),z=!0,!0}catch{return lt.error("当前步骤自动保存失败,已停留在本页,请重试"),!1}try{return await Nv(),z=!0,!0}catch{return lt.error("当前步骤自动保存失败,已停留在本页,请重试"),!1}});function X0(L){return L.status==="running"||L.status==="failed"||L.status==="stopped"||L.status==="completed"&&L.results_confirmed===!1?"generate":Number(L.preview_count||T.value.length)>0?"preview":(L.source_files||[]).length>0?"upload":"model"}async function q0(){const L=await Mv();if(!L||(g.value=String(L.id),!Pv.value))return;if(L.status==="completed"&&L.results_confirmed!==!1){z=!0,await t.replace({name:"data-process-detail",params:{id:L.id}});return}if(L.preview_status==="queued"||L.preview_status==="running"){Er("upload"),of({task_id:L.id,preview_status:L.preview_status,preview_progress:Number(L.preview_progress)||0,preview_run_id:L.preview_run_id,preview_failure_reason:L.preview_failure_reason,preview_total_files:L.preview_total_files,preview_completed_files:L.preview_completed_files});const Q=S.value.map(At=>At.sourceFileId).filter(At=>!!At);Lv(Q,!0);return}let U=L.workflow_step||X0(L);L.preview_status==="failed"&&(U="upload"),L.status==="running"&&(U="generate"),U==="preview"&&!T.value.length&&(U="upload"),U==="results"&&L.status!=="completed"&&(U="generate"),Er(U),(U==="generate"||U==="results")&&await ys()}return Gp(()=>{k(),ji()}),Ey(()=>{localStorage.removeItem("yg-data-process-create-draft"),e.load(!0),(Pn.value||Pv.value)&&q0()}),(L,U)=>{var Ct,Cr,Bv,$v;const Q=Q0,At=Ml,se=J0;return O(),$(xt,null,[x("div",xk,[x("main",_k,[x("div",Ek,[x("div",Ck,[x("div",kk,[(O(),$(xt,null,xe(c,(bs,Ra)=>(O(),$(xt,{key:bs.id},[Ra!==0?(O(),$("div",{key:0,class:re(["step-connector",{"is-active":h.value>=Ra}])},null,2)):ct("",!0),x("div",{class:re(["step-item",{"is-active":h.value===Ra,"is-completed":h.value>Ra}]),"aria-current":h.value===Ra?"step":void 0},[x("div",Pk,[x("div",Mk,[h.value>Ra?(O(),$("i",Ik)):(O(),$("span",Dk,G(Ra+1),1))]),x("div",Lk,[x("div",Rk,G(bs.title),1)])])],10,Tk)],64))),64))])]),iA((O(),$("div",Fk,[Bt(lg)?(O(),$("div",Ok,[V(Q,{type:"error",closable:!1,title:Bt(lg),"show-icon":""},null,8,["title"]),V(At,{type:"primary",loading:Bt(Ll),onClick:Bt(Mv)},{default:tt(()=>[...U[6]||(U[6]=[at("重试加载原任务",-1)])]),_:1},8,["loading","onClick"])])):d.value==="create"?(O(),Pt(gS,{key:1,ref_key:"taskSetupRef",ref:a,name:f.name,"onUpdate:name":U[0]||(U[0]=bs=>f.name=bs),description:f.description,"onUpdate:description":U[1]||(U[1]=bs=>f.description=bs),"process-type":b.value,"onUpdate:processType":U[2]||(U[2]=bs=>b.value=bs),"structured-options":w.value,"onUpdate:structuredOptions":U[3]||(U[3]=bs=>w.value=bs),"unstructured-options":A.value,"onUpdate:unstructuredOptions":U[4]||(U[4]=bs=>A.value=bs),"process-type-locked":Bt(Pn)},null,8,["name","description","process-type","structured-options","unstructured-options","process-type-locked"])):d.value==="model"?(O(),Pt(wS,{key:2,ref_key:"modelSelectionRef",ref:o,options:y.value,models:r.value,"onUpdate:options":v0},null,8,["options","models"])):d.value==="upload"?(O(),Pt(KS,{key:3,"process-type":b.value,"uploaded-files":S.value,"external-source":D,"external-pulling":M.value,"external-connected":F.value,"preview-building":_.value,"source-uploading":Bt(Ee),"onUpdate:externalSource":T0,onFileChange:Dv,onRemoveFile:I0,onUseSample:k0,onTestConnection:P0,onPullData:M0},null,8,["process-type","uploaded-files","external-source","external-pulling","external-connected","preview-building","source-uploading"])):d.value==="preview"?(O(),Pt(yC,{key:4,"selected-id":H.value,"selected-file-id":N.value,"source-text":Sh.value,items:Wi.value,"process-type":b.value,"file-name":((Ct=Ci.value)==null?void 0:Ct.name)??"","file-format":(Cr=Ci.value)==null?void 0:Cr.fileFormat,"task-id":g.value,"source-file-id":((Bv=Ci.value)==null?void 0:Bv.sourceFileId)??(($v=Ci.value)==null?void 0:$v.uid)??null,files:tf.value,"onUpdate:selectedId":Rv,"onUpdate:selectedFileId":N0,"onUpdate:itemContent":B0,"onRestore:item":$0,"onAdd:item":U0,"onRemove:item":H0},null,8,["selected-id","selected-file-id","source-text","items","process-type","file-name","file-format","task-id","source-file-id","files"])):d.value==="generate"?(O(),Pt(TC,{key:5,"task-name":f.name,"process-type":b.value,"file-name":B.value,"preview-count":T.value.length,"modified-count":Ds.value,generation:Bt(_t),onRetry:Fv},null,8,["task-name","process-type","file-name","preview-count","modified-count","generation"])):d.value==="results"?(O(),Pt(rk,{key:6,"selected-id":Bt(W),"onUpdate:selectedId":U[5]||(U[5]=bs=>nA(W)?W.value=bs:null),items:Bt(X),"preview-items":T.value,"regenerating-result-id":Bt(Ut),"bulk-regeneration":Bt(Et),"onUpdate:field":Bt(as),"onRegenerate:all":Bt(ut),"onRegenerate:item":Bt(Qt)},null,8,["selected-id","items","preview-items","regenerating-result-id","bulk-regeneration","onUpdate:field","onRegenerate:all","onRegenerate:item"])):ct("",!0)])),[[se,Bt(Ll)]])])]),x("footer",Nk,[x("div",Bk,[h.value>0?(O(),Pt(At,{key:0,disabled:d.value==="generate"||_.value||Bt(Ee),onClick:V0},{default:tt(()=>[U[7]||(U[7]=x("i",{class:"fa fa-arrow-left",style:{"margin-right":"6px"}},null,-1)),at(" 返回:"+G(m0.value),1)]),_:1},8,["disabled"])):(O(),Pt(At,{key:1,onClick:j0},{default:tt(()=>[at(G(Bt(Pn)?"返回详情":"取消"),1)]),_:1}))]),U[8]||(U[8]=x("div",{class:"footer-center"},null,-1)),x("div",$k,[V(At,{class:"wizard-primary-action",type:"primary",loading:K.value||Bt(_t).status==="running"||Bt(Ot)||d.value==="upload"&&(Bt(Ee)||_.value),disabled:Bt(Ll)||K.value||!!Bt(lg)||Bt(Ot)||d.value==="generate"&&Bt(_t).status==="running"||_.value||Bt(Ee)||d.value==="upload"&&Pe.value,onClick:z0},{default:tt(()=>[at(G(xh.value)+" ",1),x("i",{class:re(["fa",g0.value]),style:{"margin-left":"6px"}},null,2)]),_:1},8,["loading","disabled"])])])]),V(aA,{ref_key:"confirmDialogRef",ref:l},null,512)],64)}}}),PT=ri(Hk,[["__scopeId","data-v-c986ad9a"]]);export{PT as default};