@zhanguym/chatroom 1.2.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/application.d.ts +5 -0
- package/dist/app/application.js +55 -4
- package/dist/app/lifecycle.js +12 -0
- package/dist/app/workspace-access.d.ts +17 -4
- package/dist/core/operations/types.d.ts +1 -1
- package/dist/core/operations/types.js +1 -1
- package/dist/infrastructure/database/agent-mcp-settings-repository.d.ts +12 -0
- package/dist/infrastructure/database/agent-mcp-settings-repository.js +55 -0
- package/dist/infrastructure/database/app-database.js +3 -3
- package/dist/infrastructure/database/migrate.d.ts +2 -0
- package/dist/infrastructure/database/migrate.js +68 -0
- package/dist/infrastructure/database/schema.d.ts +3 -1
- package/dist/infrastructure/database/schema.js +35 -6
- package/dist/infrastructure/database/workspace-repository.d.ts +28 -0
- package/dist/infrastructure/database/workspace-repository.js +126 -0
- package/dist/mcp/custom/manager.d.ts +3 -1
- package/dist/mcp/custom/manager.js +37 -2
- package/dist/mcp/server/plugin-mcp-registrar.d.ts +4 -1
- package/dist/mcp/server/plugin-mcp-registrar.js +7 -2
- package/dist/mcp/server/tool-control.d.ts +6 -1
- package/dist/mcp/server/tool-control.js +11 -2
- package/dist/native/macos/ChatRoomComputerHelper.app/Contents/MacOS/chatroom-computer-helper +0 -0
- package/dist/native/windows/chatroom-computer-helper.exe +0 -0
- package/dist/plugins/agent/custom-mcp-store.d.ts +17 -0
- package/dist/plugins/agent/custom-mcp-store.js +38 -0
- package/dist/plugins/agent/mcp-gateway.d.ts +16 -0
- package/dist/plugins/agent/mcp-gateway.js +110 -0
- package/dist/plugins/agent/mcp.js +3 -2
- package/dist/plugins/agent/plugin.js +1 -1
- package/dist/plugins/agent/provider.d.ts +1 -0
- package/dist/plugins/agent/providers/codex/launch.d.ts +17 -0
- package/dist/plugins/agent/providers/codex/launch.js +24 -0
- package/dist/plugins/agent/providers/codex/provider.d.ts +3 -1
- package/dist/plugins/agent/providers/codex/provider.js +8 -2
- package/dist/plugins/agent/providers/codex/rpc.d.ts +7 -1
- package/dist/plugins/agent/providers/codex/rpc.js +28 -3
- package/dist/plugins/agent/providers/index.d.ts +2 -1
- package/dist/plugins/agent/providers/index.js +5 -2
- package/dist/plugins/agent/repository.js +10 -7
- package/dist/plugins/agent/runtime-files.d.ts +4 -4
- package/dist/plugins/agent/runtime-files.js +18 -14
- package/dist/plugins/agent/runtime.d.ts +2 -0
- package/dist/plugins/agent/runtime.js +52 -13
- package/dist/plugins/agent/types.d.ts +3 -2
- package/dist/plugins/cloud/v2/tunnel-client.js +1 -7
- package/dist/plugins/plugin-manager.d.ts +6 -1
- package/dist/plugins/plugin-manager.js +9 -2
- package/dist/plugins/types.d.ts +4 -0
- package/dist/plugins/web/http/agent-api-router.js +15 -1
- package/dist/plugins/web/http/git-api-router.js +13 -13
- package/dist/plugins/web/http/rtc-api-router.js +3 -0
- package/dist/plugins/web/http/runtime-api-router.js +22 -0
- package/dist/plugins/web/http/workspace-api-router.js +63 -12
- package/dist/plugins/web/plugin.js +1 -1
- package/dist/plugins/web/runtime.d.ts +3 -1
- package/dist/plugins/web/runtime.js +5 -1
- package/dist/plugins/workspace/mcp.js +20 -15
- package/dist/plugins/workspace/plugin.js +1 -1
- package/dist/plugins/workspace/workspace-root-policy.d.ts +0 -1
- package/dist/plugins/workspace/workspace-root-policy.js +25 -19
- package/dist/plugins/workspace/workspace-service.d.ts +20 -8
- package/dist/plugins/workspace/workspace-service.js +270 -64
- package/dist/web/assets/{AgentView-CMxIn3KB.css → AgentView-BqAfmgc4.css} +1 -1
- package/dist/web/assets/AgentView-tr6COjRg.js +4 -0
- package/dist/web/assets/{CloudView-CXuTK7Of.js → CloudView-D-fYLw_O.js} +1 -1
- package/dist/web/assets/{CodeViewer.vue_vue_type_script_setup_true_lang-DK6xGH2G.js → CodeViewer.vue_vue_type_script_setup_true_lang-BtA5aWrS.js} +1 -1
- package/dist/web/assets/ComputerView-B25C_C_h.js +1 -0
- package/dist/web/assets/ComputerView-vSSsexBY.css +1 -0
- package/dist/web/assets/{MarkdownContent-D4KYOn-f.js → MarkdownContent-BuDRrZ6c.js} +1 -1
- package/dist/web/assets/McpToolsView-D0G_HACK.css +1 -0
- package/dist/web/assets/McpToolsView-s0-Qvg2g.js +2 -0
- package/dist/web/assets/OperationsView-B_0SN40Y.js +4 -0
- package/dist/web/assets/{ProcessesView-NUAplTg4.js → ProcessesView-B2i-O0AL.js} +3 -3
- package/dist/web/assets/StateChip.vue_vue_type_script_setup_true_lang-DwnqcvSQ.js +1 -0
- package/dist/web/assets/{SystemLogsView-DGW_4nS0.js → SystemLogsView-BR4FZoAh.js} +1 -1
- package/dist/web/assets/{TerminalView-DCqHCfb5.js → TerminalView-2Z1blITD.js} +1 -1
- package/dist/web/assets/VSelect-CHI_FOMl.js +1 -0
- package/dist/web/assets/VSheet-CKEhsY-7.js +1 -0
- package/dist/web/assets/VSpacer-FbdDPUGx.js +1 -0
- package/dist/web/assets/{VSwitch-o-WPjZs0.js → VSwitch-o9DuRTKF.js} +1 -1
- package/dist/web/assets/{VTabs-D2y6M66D.js → VTabs-BSfSKBtT.js} +1 -1
- package/dist/web/assets/{VTextarea-DFSNyIwH.js → VTextarea-D_kPhUVU.js} +1 -1
- package/dist/web/assets/WorkspaceDownloadPreview-BoALqL1M.js +1 -0
- package/dist/web/assets/WorkspaceDownloadPreview-dFslZB0W.css +1 -0
- package/dist/web/assets/{WorkspaceMediaPreview-tkpcPK82.js → WorkspaceMediaPreview-qjt04eze.js} +3 -3
- package/dist/web/assets/{WorkspacePdfPreview-PqIFAx2J.js → WorkspacePdfPreview-BrUJpmNs.js} +1 -1
- package/dist/web/assets/WorkspacesView-CHXmDTlX.js +2 -0
- package/dist/web/assets/WorkspacesView-Dt24eGQ4.css +1 -0
- package/dist/web/assets/index-9DLDvF8M.js +19 -0
- package/dist/web/assets/{useMasterDetailFocus-DgNjKho5.js → useMasterDetailFocus-Chh0cM6g.js} +1 -1
- package/dist/web/assets/useOperationLabels-DF67nIF0.js +1 -0
- package/dist/web/index.html +1 -1
- package/dist/web/transport-sw.js +43 -15
- package/package.json +1 -1
- package/dist/web/assets/AgentView-XEf1AUcH.js +0 -4
- package/dist/web/assets/ComputerView-Bz2Wsz2X.css +0 -1
- package/dist/web/assets/ComputerView-Cxn7zhrw.js +0 -1
- package/dist/web/assets/McpToolsView-DdYOoY9_.css +0 -1
- package/dist/web/assets/McpToolsView-XLtFPY_M.js +0 -2
- package/dist/web/assets/OperationsView-DRx2Qq8W.js +0 -4
- package/dist/web/assets/StateChip.vue_vue_type_script_setup_true_lang-BYoHRX9h.js +0 -1
- package/dist/web/assets/VSelect-Dla-KtWu.js +0 -1
- package/dist/web/assets/VSheet-B9d-Gdzq.js +0 -1
- package/dist/web/assets/VSpacer--LXbKJE2.js +0 -1
- package/dist/web/assets/WorkspaceDownloadPreview-DJKSNaZ_.css +0 -1
- package/dist/web/assets/WorkspaceDownloadPreview-DaFQwUIa.js +0 -1
- package/dist/web/assets/WorkspacesView-ClA6xcjn.css +0 -1
- package/dist/web/assets/WorkspacesView-DkGvIFCb.js +0 -2
- package/dist/web/assets/index-CacDJSDn.js +0 -19
- package/dist/web/assets/useOperationLabels-BNiE-bRq.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var pi=d=>{throw TypeError(d)};var vs=(d,t,e)=>t.has(d)||pi("Cannot "+e);var X=(d,t,e)=>(vs(d,t,"read from private field"),e?e.call(d):t.get(d)),Tt=(d,t,e)=>t.has(d)?pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(d):t.set(d,e),ct=(d,t,e,s)=>(vs(d,t,"write to private field"),s?s.call(d,e):t.set(d,e),e),Ot=(d,t,e)=>(vs(d,t,"access private method"),e);var gi=(d,t,e,s)=>({set _(i){ct(d,t,i,e)},get _(){return X(d,t,s)}});import{d as Wi,o as Rn,b as Ln,c as Vt,e as ks,f as ze,aa as Nn,aS as Bn,aT as Hn,l as je,E as Xi,p as Yi,q as Ki,t as Ve,h as Ps,s as Nt,_ as qi,w as Un,D as Gn,F as $n,j as zn}from"./index-CacDJSDn.js";const mt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Ft=[1/0,1/0,-1/0,-1/0],Wt=new Float32Array(Ft),Ms=[.001,0,0,.001,0,0],ht="http://www.w3.org/2000/svg",gt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Bt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},he="pdfjs_internal_id_",fe="pdfjs_internal_editor_",L={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},G={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},jn={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},it={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},We={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},q={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},ae={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},is={ERRORS:0,WARNINGS:1,INFOS:5},Dt={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},ye={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},Vn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let ns=is.WARNINGS;function Wn(d){Number.isInteger(d)&&(ns=d)}function Xn(){return ns}function rs(d){ns>=is.INFOS&&console.info(`Info: ${d}`)}function B(d){ns>=is.WARNINGS&&console.warn(`Warning: ${d}`)}function $(d){throw new Error(d)}function J(d,t){d||$(t)}function Yn(d){switch(d?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Qi(d,t=null,e=null){if(!d)return null;if(e&&typeof d=="string"&&(e.addDefaultProtocol&&d.startsWith("www.")&&d.match(/\./g)?.length>=2&&(d=`http://${d}`),e.tryConvertEncoding))try{d=Qn(d)}catch{}const s=t?URL.parse(d,t):URL.parse(d);return Yn(s)?s:null}function Ji(d,t,e=!1){const s=URL.parse(d);return s?(s.hash=t,s.href):e&&Qi(d,"http://example.com")?d.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Ds(d){return d.substring(d.lastIndexOf("/")+1)}function T(d,t,e,s=!1){return Object.defineProperty(d,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const te=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Is extends te{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ws extends te{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Fs extends te{constructor(t){super(t,"InvalidPDFException")}}class Qe extends te{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class Kn extends te{constructor(t){super(t,"FormatError")}}class Ut extends te{constructor(t){super(t,"AbortException")}}function qn(d){(typeof d!="object"||d?.length===void 0)&&$("Invalid argument for bytesToString");const t=d.length,e=8192;if(t<e)return String.fromCharCode.apply(null,d);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=d.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function as(d){typeof d!="string"&&$("Invalid argument for stringToBytes");const t=d.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=d.charCodeAt(s)&255;return e}class j{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return T(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return T(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return T(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return T(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return T(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return T(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")),T(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return T(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",T(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return T(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class C{static get hexNums(){return T(this,"hexNums",Array.from({length:256},(t,e)=>e.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],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let h=0;h<6;h+=2){const c=t[s+h],u=t[s+h+1];t[s+h]=c*i+u*r+o,t[s+h+1]=c*n+u*a+l}}static applyInverseTransform(t,e){const s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],c=t[1],u=t[2],f=t[3];let p=i*h+o,g=p,m=i*u+o,b=m,y=a*c+l,A=y,S=a*f+l,v=S;if(n!==0||r!==0){const w=n*h,_=n*u,x=r*c,E=r*f;p+=x,b+=x,m+=E,g+=E,y+=w,v+=w,S+=_,A+=_}s[0]=Math.min(s[0],p,m,g,b),s[1]=Math.min(s[1],y,S,A,v),s[2]=Math.max(s[2],p,m,g,b),s[3]=Math.max(s[3],y,S,A,v)}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],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,h=(a+l)/2,c=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const 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 n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}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,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,h){if(l<=0||l>=1)return;const c=1-l,u=l*l,f=u*l,p=c*(c*(c*t+3*l*e)+3*u*s)+f*i,g=c*(c*(c*n+3*l*r)+3*u*a)+f*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,s,i,n,r,a,o,l,h,c,u){if(Math.abs(l)<1e-12){Math.abs(h)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-c/h,u);return}const f=h**2-4*c*l;if(f<0)return;const p=Math.sqrt(f),g=2*l;this.#t(t,e,s,i,n,r,a,o,(-h+p)/g,u),this.#t(t,e,s,i,n,r,a,o,(-h-p)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}}function Qn(d){return decodeURIComponent(escape(d))}let Ss=null,mi=null;function Jn(d){return Ss||(Ss=/([\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,mi=new Map([["ſt","ſt"]])),d.replaceAll(Ss,(t,e,s)=>e?e.normalize("NFKC"):mi.get(s))}function Zi(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),qn(d)}function Zn(d,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...n]=e;if(!d(s)&&!Number.isInteger(s)||!t(i))return!1;const r=n.length;let a=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(const o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}const ge=()=>[],Ws=()=>new Map,Os=()=>Object.create(null),tr=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(d){return[...this].join(d)});function W(d,t,e){return Math.min(Math.max(d,t),e)}class De{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,u,f;switch(i%=360,i<0&&(i+=360),i){case 180:h=-1,c=0,u=0,f=1;break;case 90:h=0,c=1,u=1,f=0;break;case 270:h=0,c=-1,u=-1,f=0;break;case 0:h=1,c=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,b;h===0?(p=Math.abs(l-t[1])*s+n,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(l-t[1])*s+r,m=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[h*s,c*s,u*s,f*s,p-h*s*o-u*s*l,g-c*s*o-f*s*l],this.width=m,this.height=b}get rawDims(){const t=this.viewBox;return T(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:n=!1}={}){return new De({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){const s=[t,e];return C.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return C.applyInverseTransform(s,this.transform),s}}class Ce{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(Ce.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const er=/url\(|image-set\(/i,sr=/^on/i;class tn{static get _allowedHtmlElements(){return T(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return T(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return T(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return T(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return T(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,l]of Object.entries(r))if(!(l==null||sr.test(o))&&!(i==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){const h=this._allowedRichTextStyles;for(const[c,u]of Object.entries(l))h.has(c)&&!er.test(u)&&(t.style[c]=u)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n?.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===ht&&this._allowedSvgElements.has(t)?document.createElementNS(ht,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const c=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=c}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const c=document.createTextNode(i.value);r.append(c),a&&Ce.shouldBuildText(i.name)&&l.push(c)}return{textDivs:l}}const h=[[i,-1,r]];for(;h.length>0;){const[c,u,f]=h.at(-1);if(u+1===c.children.length){h.pop();continue}const p=c.children[++h.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const b=document.createTextNode(p.value);l.push(b),f.append(b);continue}const m=this.#t(g,p.attributes?.xmlns,n);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)h.push([p,-1,m]);else if(p.value){const b=document.createTextNode(p.value);a&&Ce.shouldBuildText(g)&&l.push(b),m.append(b)}}}for(const c of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))c.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style;return new De({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}}class pe{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Xs(d,t="text"){if(Se(d,document.baseURI)){const e=await fetch(d);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",d,!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 Ys extends te{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function os(d){const t=d.length;let e=0;for(;e<t&&d[e].trim()==="";)e++;return d.substring(e,e+5).toLowerCase()==="data:"}function Ks(d){return typeof d=="string"&&/\.pdf$/i.test(d)}function ir(d){return[d]=d.split(/[#?]/,1),Ds(d)}function nr(d,t="document.pdf"){if(typeof d!="string")return t;if(os(d))return B('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(d);if(!s)return t;const i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Ds(o),o.length===4&&n.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=Ds(s.pathname);if(n.test(r))return i(r);if(s.searchParams.size>0){const a=l=>[...l].findLast(h=>n.test(h)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){const{hash:a}=s;let o=-1;for(const{index:l}of a.matchAll(/\.pdf\b/gi))o=l;if(o>0){let l=o;for(;l>0&&!"/?#=".includes(a[l-1]);)l--;if(l<o)return i(a.slice(l,o+4))}}return t}class bi{#t=new Map;times=[];time(t){this.#t.has(t)&&B(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||B(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.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
|
|
1
|
+
var pi=d=>{throw TypeError(d)};var vs=(d,t,e)=>t.has(d)||pi("Cannot "+e);var X=(d,t,e)=>(vs(d,t,"read from private field"),e?e.call(d):t.get(d)),Tt=(d,t,e)=>t.has(d)?pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(d):t.set(d,e),ct=(d,t,e,s)=>(vs(d,t,"write to private field"),s?s.call(d,e):t.set(d,e),e),Ot=(d,t,e)=>(vs(d,t,"access private method"),e);var gi=(d,t,e,s)=>({set _(i){ct(d,t,i,e)},get _(){return X(d,t,s)}});import{d as Wi,o as Rn,b as Ln,c as Vt,e as ks,f as ze,aa as Nn,aS as Bn,aT as Hn,l as je,E as Xi,p as Yi,q as Ki,t as Ve,h as Ps,s as Nt,_ as qi,w as Un,D as Gn,F as $n,j as zn}from"./index-9DLDvF8M.js";const mt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Ft=[1/0,1/0,-1/0,-1/0],Wt=new Float32Array(Ft),Ms=[.001,0,0,.001,0,0],ht="http://www.w3.org/2000/svg",gt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Bt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},he="pdfjs_internal_id_",fe="pdfjs_internal_editor_",L={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},G={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},jn={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},it={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},We={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},q={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},ae={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},is={ERRORS:0,WARNINGS:1,INFOS:5},Dt={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},ye={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},Vn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let ns=is.WARNINGS;function Wn(d){Number.isInteger(d)&&(ns=d)}function Xn(){return ns}function rs(d){ns>=is.INFOS&&console.info(`Info: ${d}`)}function B(d){ns>=is.WARNINGS&&console.warn(`Warning: ${d}`)}function $(d){throw new Error(d)}function J(d,t){d||$(t)}function Yn(d){switch(d?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Qi(d,t=null,e=null){if(!d)return null;if(e&&typeof d=="string"&&(e.addDefaultProtocol&&d.startsWith("www.")&&d.match(/\./g)?.length>=2&&(d=`http://${d}`),e.tryConvertEncoding))try{d=Qn(d)}catch{}const s=t?URL.parse(d,t):URL.parse(d);return Yn(s)?s:null}function Ji(d,t,e=!1){const s=URL.parse(d);return s?(s.hash=t,s.href):e&&Qi(d,"http://example.com")?d.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Ds(d){return d.substring(d.lastIndexOf("/")+1)}function T(d,t,e,s=!1){return Object.defineProperty(d,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const te=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Is extends te{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ws extends te{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Fs extends te{constructor(t){super(t,"InvalidPDFException")}}class Qe extends te{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class Kn extends te{constructor(t){super(t,"FormatError")}}class Ut extends te{constructor(t){super(t,"AbortException")}}function qn(d){(typeof d!="object"||d?.length===void 0)&&$("Invalid argument for bytesToString");const t=d.length,e=8192;if(t<e)return String.fromCharCode.apply(null,d);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=d.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function as(d){typeof d!="string"&&$("Invalid argument for stringToBytes");const t=d.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=d.charCodeAt(s)&255;return e}class j{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return T(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return T(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return T(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return T(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return T(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return T(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")),T(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return T(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",T(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return T(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class C{static get hexNums(){return T(this,"hexNums",Array.from({length:256},(t,e)=>e.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],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let h=0;h<6;h+=2){const c=t[s+h],u=t[s+h+1];t[s+h]=c*i+u*r+o,t[s+h+1]=c*n+u*a+l}}static applyInverseTransform(t,e){const s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){const i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],c=t[1],u=t[2],f=t[3];let p=i*h+o,g=p,m=i*u+o,b=m,y=a*c+l,A=y,S=a*f+l,v=S;if(n!==0||r!==0){const w=n*h,_=n*u,x=r*c,E=r*f;p+=x,b+=x,m+=E,g+=E,y+=w,v+=w,S+=_,A+=_}s[0]=Math.min(s[0],p,m,g,b),s[1]=Math.min(s[1],y,S,A,v),s[2]=Math.max(s[2],p,m,g,b),s[3]=Math.max(s[3],y,S,A,v)}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],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,h=(a+l)/2,c=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const 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 n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}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,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,h){if(l<=0||l>=1)return;const c=1-l,u=l*l,f=u*l,p=c*(c*(c*t+3*l*e)+3*u*s)+f*i,g=c*(c*(c*n+3*l*r)+3*u*a)+f*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,s,i,n,r,a,o,l,h,c,u){if(Math.abs(l)<1e-12){Math.abs(h)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-c/h,u);return}const f=h**2-4*c*l;if(f<0)return;const p=Math.sqrt(f),g=2*l;this.#t(t,e,s,i,n,r,a,o,(-h+p)/g,u),this.#t(t,e,s,i,n,r,a,o,(-h-p)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}}function Qn(d){return decodeURIComponent(escape(d))}let Ss=null,mi=null;function Jn(d){return Ss||(Ss=/([\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,mi=new Map([["ſt","ſt"]])),d.replaceAll(Ss,(t,e,s)=>e?e.normalize("NFKC"):mi.get(s))}function Zi(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),qn(d)}function Zn(d,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...n]=e;if(!d(s)&&!Number.isInteger(s)||!t(i))return!1;const r=n.length;let a=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(const o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}const ge=()=>[],Ws=()=>new Map,Os=()=>Object.create(null),tr=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(d){return[...this].join(d)});function W(d,t,e){return Math.min(Math.max(d,t),e)}class De{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,u,f;switch(i%=360,i<0&&(i+=360),i){case 180:h=-1,c=0,u=0,f=1;break;case 90:h=0,c=1,u=1,f=0;break;case 270:h=0,c=-1,u=-1,f=0;break;case 0:h=1,c=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,b;h===0?(p=Math.abs(l-t[1])*s+n,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(l-t[1])*s+r,m=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[h*s,c*s,u*s,f*s,p-h*s*o-u*s*l,g-c*s*o-f*s*l],this.width=m,this.height=b}get rawDims(){const t=this.viewBox;return T(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:n=!1}={}){return new De({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){const s=[t,e];return C.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return C.applyInverseTransform(s,this.transform),s}}class Ce{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(Ce.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const er=/url\(|image-set\(/i,sr=/^on/i;class tn{static get _allowedHtmlElements(){return T(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return T(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return T(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return T(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return T(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,l]of Object.entries(r))if(!(l==null||sr.test(o))&&!(i==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){const h=this._allowedRichTextStyles;for(const[c,u]of Object.entries(l))h.has(c)&&!er.test(u)&&(t.style[c]=u)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n?.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===ht&&this._allowedSvgElements.has(t)?document.createElementNS(ht,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const c=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=c}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const c=document.createTextNode(i.value);r.append(c),a&&Ce.shouldBuildText(i.name)&&l.push(c)}return{textDivs:l}}const h=[[i,-1,r]];for(;h.length>0;){const[c,u,f]=h.at(-1);if(u+1===c.children.length){h.pop();continue}const p=c.children[++h.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const b=document.createTextNode(p.value);l.push(b),f.append(b);continue}const m=this.#t(g,p.attributes?.xmlns,n);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)h.push([p,-1,m]);else if(p.value){const b=document.createTextNode(p.value);a&&Ce.shouldBuildText(g)&&l.push(b),m.append(b)}}}for(const c of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))c.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style;return new De({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}}class pe{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Xs(d,t="text"){if(Se(d,document.baseURI)){const e=await fetch(d);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",d,!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 Ys extends te{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function os(d){const t=d.length;let e=0;for(;e<t&&d[e].trim()==="";)e++;return d.substring(e,e+5).toLowerCase()==="data:"}function Ks(d){return typeof d=="string"&&/\.pdf$/i.test(d)}function ir(d){return[d]=d.split(/[#?]/,1),Ds(d)}function nr(d,t="document.pdf"){if(typeof d!="string")return t;if(os(d))return B('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(d);if(!s)return t;const i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Ds(o),o.length===4&&n.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=Ds(s.pathname);if(n.test(r))return i(r);if(s.searchParams.size>0){const a=l=>[...l].findLast(h=>n.test(h)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){const{hash:a}=s;let o=-1;for(const{index:l}of a.matchAll(/\.pdf\b/gi))o=l;if(o>0){let l=o;for(;l>0&&!"/?#=".includes(a[l-1]);)l--;if(l<o)return i(a.slice(l,o+4))}}return t}class bi{#t=new Map;times=[];time(t){this.#t.has(t)&&B(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||B(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.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
|
|
2
2
|
`).join("")}}function Se(d,t){const e=t?URL.parse(d,t):URL.parse(d);return/https?:/.test(e?.protocol??"")}function xt(d){d.preventDefault()}function nt(d){d.preventDefault(),d.stopPropagation()}class Rs{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.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 n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,l==="-"?(r+=h,a+=c):l==="+"&&(r-=h,a-=c),new Date(Date.UTC(s,i,n,r,a,o))}}function me(d){if(d.startsWith("#")){const e=d.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(d.startsWith("rgb(")){const[e,s,i]=d.slice(4,-1).split(",").map(n=>parseInt(n,10));return[e,s,i,1]}if(d.startsWith("rgba(")){const e=d.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=d.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 Ie(d){const t=me(d);return t?t.slice(0,3):(B(`Not a valid color format: "${d}"`),[0,0,0])}function rr(d){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of d.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;d.set(e,Ie(s))}t.remove()}function V(d){const{a:t,b:e,c:s,d:i,e:n,f:r}=d.getTransform();return[t,e,s,i,n,r]}function kt(d){const{a:t,b:e,c:s,d:i,e:n,f:r}=d.getTransform().invertSelf();return[t,e,s,i,n,r]}function Jt(d,t,e=!1,s=!0){if(t instanceof De){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=d,a=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-y))`;!e||t.rotation%180===0?(r.width=a,r.height=o):(r.width=o,r.height=a)}s&&d.setAttribute("data-main-rotation",t.rotation)}class St{constructor(){const{pixelRatio:t}=St;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,n=-1){let r=1/0,a=1/0,o=1/0;s=St.capPixels(s,n),s>0&&(r=Math.sqrt(s/(t*e))),i!==-1&&(a=i/t,o=i/e);const l=Math.min(r,a,o);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!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 Ls=new Set(["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"]);class ar{static get isDarkMode(){return T(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class or{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(),T(this,"commentForegroundColor",Ie(s))}}function lr(d,t){t=W(t??1,0,1);const e=255*(1-t);return d.map(s=>Math.round(s*t+e))}function yi(d,t){const e=d[0]/255,s=d[1]/255,i=d[2]/255,n=Math.max(e,s,i),r=Math.min(e,s,i),a=(n+r)/2;if(n===r)t[0]=t[1]=0;else{const o=n-r;switch(t[1]=a<.5?o/(n+r):o/(2-n-r),n){case e:t[0]=((s-i)/o+(s<i?6:0))*60;break;case s:t[0]=((i-e)/o+2)*60;break;case i:t[0]=((e-s)/o+4)*60;break}}t[2]=a}function Ns(d,t){const e=d[0],s=d[1],i=d[2],n=(1-Math.abs(2*i-1))*s,r=n*(1-Math.abs(e/60%2-1)),a=i-n/2;switch(Math.floor(e/60)){case 0:t[0]=n+a,t[1]=r+a,t[2]=a;break;case 1:t[0]=r+a,t[1]=n+a,t[2]=a;break;case 2:t[0]=a,t[1]=n+a,t[2]=r+a;break;case 3:t[0]=a,t[1]=r+a,t[2]=n+a;break;case 4:t[0]=r+a,t[1]=a,t[2]=n+a;break;case 5:case 6:t[0]=n+a,t[1]=a,t[2]=r+a;break}}function Bs(d){return d<=.03928?d/12.92:((d+.055)/1.055)**2.4}function Ai(d,t,e){Ns(d,e),e.map(Bs);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Ns(t,e),e.map(Bs);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const vi=new Map;function hr(d,t){const e=d[0]+d[1]*256+d[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=vi.get(e);if(s)return s;const i=new Float32Array(9),n=i.subarray(0,3),r=i.subarray(3,6);yi(d,r);const a=i.subarray(6,9);yi(t,a);const o=a[2]<.5,l=o?12:4.5;if(r[2]=o?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),Ai(r,a,n)<l){let h,c;o?(h=r[2],c=1):(h=0,c=r[2]);const u=.005;for(;c-h>u;){const f=r[2]=(h+c)/2;o===Ai(r,a,n)<l?h=f:c=f}r[2]=o?c:h}return Ns(r,n),s=C.makeHexColor(Math.round(n[0]*255),Math.round(n[1]*255),Math.round(n[2]*255)),vi.set(e,s),s}function en({html:d,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof d=="string"){const n=document.createElement("p");n.dir=t||"auto";const r=d.split(/\r\n?|\n/);for(let a=0,o=r.length;a<o;++a){const l=r[a];n.append(document.createTextNode(l)),a<o-1&&n.append(document.createElement("br"))}i.append(n)}else tn.render({xfaHtml:d,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function sn(d){const t=new Path2D;if(!d)return t;for(let e=0,s=d.length;e<s;)switch(d[e++]){case ye.moveTo:t.moveTo(d[e++],d[e++]);break;case ye.lineTo:t.lineTo(d[e++],d[e++]);break;case ye.curveTo:t.bezierCurveTo(d[e++],d[e++],d[e++],d[e++],d[e++],d[e++]);break;case ye.quadraticCurveTo:t.quadraticCurveTo(d[e++],d[e++],d[e++],d[e++]);break;case ye.closePath:t.closePath();break;default:B(`Unrecognized drawing path operator: ${d[e-1]}`);break}return t}class _e{#t=null;#e=null;#s;#i=null;#n=null;#a=null;#r=null;#o=null;static#l=null;constructor(t){this.#s=t,_e.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",xt,{signal:e}),t.addEventListener("pointerdown",_e.#h,{signal:e}));const s=this.#i=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#h(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,nt(t)}#d(t){this.#s._focusEventsAllowed=!0,nt(t)}#f(t){const e=this.#s._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",xt,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#n?.shown(),this.#a?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",_e.#l[t]),this.#f(s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),this.#i.append(s)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#f(e),this.#i.append(e,this.#g),this.#n=t}addComment(t,e=null){if(this.#a)return;const s=t.renderForToolbar();if(!s)return;this.#f(s);const i=this.#r=this.#g;e?(this.#i.insertBefore(s,e),this.#i.insertBefore(i,e)):this.#i.append(s,i),this.#a=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;const e=t.renderButton();this.#f(e),this.#i.append(e,this.#g)}async addEditSignatureButton(t){const e=this.#o=await t.renderEditButton(this.#s);e&&(this.#f(e),this.#i.append(e,this.#g))}removeButton(t){t==="comment"&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=null)}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=this.#i.querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class cr{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#s.direction;const e=this.#s._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",xt,{signal:e});const s=this.#t=document.createElement("div");return s.className="buttons",t.append(s),this.#s.hasCommentManager()&&this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")}),this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#n(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#n(e,s),{style:r}=this.#e||=this.#i();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#a(t,e,s,i){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);const r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);const a=this.#s._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",xt,{signal:a}),n.addEventListener("click",i,{signal:a})),this.#t.append(n)}}const dr="2837668c-d334-48d1-ba74-aa7deba483da",_s=Object.freeze({internal:dr});function nn(d,t,e){for(const s of e)t.addEventListener(s,d[s].bind(d))}class z{static#t=NaN;static#e=null;static#s=NaN;static#i=null;static initializeAndAddPointerId(t){(z.#e||=new Set).add(t)}static setPointer(t,e){z.#t||=e,z.#i??=t}static setTimeStamp(t){z.#s=t}static isSamePointerId(t){return z.#t===t}static isSamePointerIdOrRemove(t){return z.#t===t?!0:(z.#e?.delete(t),!1)}static isSamePointerType(t){return z.#i===t}static isInitializedAndDifferentPointerType(t){return z.#i!==null&&!z.isSamePointerType(t)}static isSameTimeStamp(t){return z.#s===t}static isUsingMultiplePointers(){return z.#e?.size>=1}static clearPointerType(){z.#i=null}static clearPointerIds(){z.#t=NaN,z.#e=null}static clearTimeStamp(){z.#s=NaN}}class ur{#t=0;get id(){return`${fe}${this.#t++}`}}class qs{#t=Zi();#e=0;#s=null;static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${ht}"><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 n=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 T(this,"_isSVGFittingCanvas",n)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await Xs(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=qs._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,h)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{const c=s.svgUrl=r.result;a.src=await n?`${c}#svgView(preserveAspectRatio(none))`:c},a.onerror=r.onerror=h});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){B(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#i(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){const s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;const e=this.#s.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){this.#s||=new Map;let s=this.#s.get(t);if(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_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class fr{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#i===-1){this.#t.length>0&&(this.#t.length=0),this.#i=0,this.#t.push(o);return}if(r&&this.#t[this.#i].type===n){a&&(o.undo=this.#t[this.#i].undo),this.#t[this.#i]=o;return}const l=this.#i+1;l===this.#s?this.#t.splice(0,1):(this.#i=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i!==-1){for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}}destroy(){this.#t=null}}class bt{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;const{isMac:e}=j.platform;for(const[s,i,n={}]of t){const r=s.some(a=>a.startsWith("mac+"));for(const a of s){let o=a;if(r){const c=a.startsWith("mac+");if(e!==c)continue;c&&(o=a.slice(4))}const[l,h]=bt.#t(o);l!==null&&this.callbacks.getOrInsertComputed(l,ge).push({callback:i,options:n,modifiers:h})}}}static#t(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const n=i.toUpperCase(),r=bt[n];if(r){s|=r;continue}if(e!==null){B(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=n==="SPACE"?" ":i}return e===null&&B(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]}static#e(t){const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?e[1]?.toLowerCase()??e[2]:null}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const h=bt.#e(e.code);if(h===null||h===e.key||(s=this.callbacks.get(h),!s))return}const i=(e.altKey?bt.ALT:0)|(e.ctrlKey?bt.CTRL:0)|(e.metaKey?bt.META:0)|(e.shiftKey?bt.SHIFT:0),n=s.find(h=>h.modifiers===i);if(!n)return;const{callback:r,options:{bubbles:a=!1,args:o=[],checker:l=null}}=n;l&&!l(t,e)||(r.bind(t,...o,e)(),a||nt(e))}}class Qs{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return rr(t),T(this,"_colors",t)}convert(t){const e=Ie(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return Qs._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?C.makeHexColor(...e):t}}class Gt{#t=new AbortController;#e=null;#s=null;#i=new Map;#n=new Map;#a=null;#r=null;#o=null;#l=null;#h=null;#u=new fr;#d=null;#f=null;#g=null;#m=0;#c=new Set;#p=null;#b=null;#y=new Set;_editorUndoBar=null;#A=!1;#v=!1;#w=!1;#_=null;#x=null;#E=null;#M=null;#k=!1;#T=null;#F=new ur;#D=!1;#O=!1;#R=!1;#I=null;#N=null;#j=null;#B=null;#G=null;#C=L.NONE;#S=new Set;#H=null;#$=null;#V=null;#q=null;#Y=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#L=[0,0];#W=null;#X=null;#tt=null;#et=null;#U=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Gt.prototype,e=r=>r.#X.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return T(this,"_keyboardManager",new bt([[["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:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(a)&&!r.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,l,h,c,u,f,p,g,m){const b=this._signal=this.#t.signal;this.#X=t,this.#tt=e,this.#et=s,this.#o=i,this.#d=n,this.#$=r,this.#Y=o,this._eventBus=a;const y={signal:b,..._s};a.on("editingaction",this.onEditingAction.bind(this),y),a.on("pagechanging",this.onPageChanging.bind(this),y),a.on("scalechanging",this.onScaleChanging.bind(this),y),a.on("rotationchanging",this.onRotationChanging.bind(this),y),a.on("setpreference",this.onSetPreference.bind(this),y),a.on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),y),window.addEventListener("pointerdown",()=>{this.#O=!0},{capture:!0,signal:b}),window.addEventListener("pointerup",()=>{this.#O=!1},{capture:!0,signal:b}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:b}),this.#lt(),this.#pt(),this.#it(),this.#l=o.annotationStorage,this.#_=o.filterFactory,this.#V=l,this.#M=h||null,this.#A=c,this.#v=u,this.#w=f,this.#G=p||null,this.viewParameters={realScale:pe.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=m!==!1,n?.setSidebarUiManager(this)}destroy(){this.#U?.resolve(),this.#U=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#i.clear(),this.#y.clear(),this.#B?.clear(),this.#e=null,this.#S.clear(),this.#u.destroy(),this.#o?.destroy(),this.#d?.destroy(),this.#$?.destroy(),this.#T?.hide(),this.#T=null,this.#j?.destroy(),this.#j=null,this.#s=null,this.#x&&(clearTimeout(this.#x),this.#x=null),this.#W&&(clearTimeout(this.#W),this.#W=null),this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#G}get useNewAltTextFlow(){return this.#v}get useNewAltTextWhenAddingImage(){return this.#w}get hcmFilter(){return T(this,"hcmFilter",this.#V?this.#_.addHCMFilter(this.#V.foreground,this.#V.background):"none")}get direction(){return T(this,"direction",getComputedStyle(this.#X).direction)}get _highlightColors(){return T(this,"_highlightColors",this.#M?new Map(this.#M.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 T(this,"highlightColors",null);const e=new Map,s=!!this.#V;for(const[i,n]of t){const r=i.endsWith("_HCM");if(s&&r){e.set(i.replace("_HCM",""),n);continue}!s&&!r&&e.set(i,n)}return T(this,"highlightColors",e)}get highlightColorNames(){return T(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),this.#g=t}setMainHighlightColorPicker(t){this.#j=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#d}editComment(t,e,s,i){this.#d?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#n.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#d?.updateComment(t.getData())}updatePopupColor(t){this.#d?.updatePopupColor(t)}removeComment(t){this.#d?.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#d?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#d?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(t){if(this.#n.has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=n=>{n.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,_s),await s}getSignature(t){this.#$?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#$}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,..._s}),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}){t==="enableNewAltTextWhenAddingImage"&&(this.#w=e)}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#n.delete(t),this.#m===t&&(this.#m=0)}focusMainContainer(){this.#X.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*pe.PDF_TO_CSS_UNITS;for(const e of this.#y)e.onScaleChanging();this.#g?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Z({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#st(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of this.#n.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a}=s,o=s.toString(),h=this.#Z(s).closest(".textLayer"),c=this.getSelectionBoxes(h);if(!c)return;s.empty();const u=this.#st(h),f=this.#C===L.NONE,p=()=>{const g=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a,text:o});f&&this.showAllEditors("highlight",!0,!0),e&&g?.editComment()};if(f){this.switchToMode(L.HIGHLIGHT,p);return}p()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#at(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#Z(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#T||=new cr(this),this.#T.show(s,i,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;const e=`${fe}${t}`,s=this.#l.getRawValue(e);return s&&this.#l.remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&this.#l&&!this.#l.has(t.id)&&this.#l.setValue(t.id,t)}a11yAlert(t,e=null){const s=this.#et;s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}#ot(){const t=document.getSelection();if(!t||t.isCollapsed){this.#H&&(this.#T?.hide(),this.#H=null,this.#P({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#H)return;const i=this.#Z(t).closest(".textLayer");if(!i){this.#H&&(this.#T?.hide(),this.#H=null,this.#P({hasSelectedText:!1}));return}if(this.#T?.hide(),this.#H=e,this.#P({hasSelectedText:!0}),!(this.#C!==L.HIGHLIGHT&&this.#C!==L.NONE)&&(this.#C===L.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#k=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this.#C===L.HIGHLIGHT?this.#st(i):null;if(n?.toggleDrawing(),this.#O){const r=new AbortController,a=this.combinedSignal(r),o=l=>{l.type==="pointerup"&&l.button!==0||(r.abort(),n?.toggleDrawing(!0),l.type==="pointerup"&&this.#Q("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else n?.toggleDrawing(!0),this.#Q("main_toolbar")}}#Q(t=""){this.#C===L.HIGHLIGHT?this.highlightSelection(t):this.#A&&this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ht(){if(this.#E)return;this.#E=new AbortController;const t=this.combinedSignal(this.#E);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ct(){this.#E?.abort(),this.#E=null}blur(){if(this.isShiftKeyDown=!1,this.#k&&(this.#k=!1,this.#Q("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#S)if(e.div.contains(t)){this.#N=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#N)return;const[t,e]=this.#N;this.#N=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#it(){if(this.#I)return;this.#I=new AbortController;const t=this.combinedSignal(this.#I);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#I?.abort(),this.#I=null}#ut(){if(this.#f)return;this.#f=new AbortController;const t=this.combinedSignal(this.#f);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#ft(){this.#f?.abort(),this.#f=null}#pt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#it(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#b)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#b)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#S){const i=s.serialize(!0);i&&e.push(i)}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 n of e.items)for(const r of this.#b)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){B(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const l=await i.deserialize(o);if(!l)return;n.push(l)}const r=()=>{for(const o of n)this.#nt(o);this.#rt(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){B(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==L.NONE&&!this.isEditorHandlingKeyboard&&Gt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#k&&(this.#k=!1,this.#Q("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.#r.get(t)||[])i.pageIndex=e;const s=this.#a.get(t);s&&(s.pageIndex=e,this.#n.set(e,s),this.#D?s.enable():s.disable())}startUpdatePages(){this.#a=new Map(this.#n),this.#n.clear();const t=this.#r=new Map,e=s=>{t.getOrInsertComputed(s.pageIndex,ge).push(s)};for(const s of this.#i.values())e(s);for(const[s,i]of this.#l)s.startsWith(fe)&&!this.#i.has(s)&&Number.isInteger(i?.pageIndex)&&e(i)}endUpdatePages(){this.#a=null,this.#r=null}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==L.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#l.setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,n]of this.#l)n.pageIndex===s&&n.isClone&&(this.#l.remove(i),e.push(t.deserialize(n).then(r=>{r&&(r.isClone=!0,t.addOrRebuild(r))})));return Promise.all(e)}#P(t){Object.entries(t).some(([s,i])=>this.#K[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#C===L.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#z([[G.HIGHLIGHT_FREE,!0]]))}#z(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#ht(),this.#ut(),this.#P({isEditing:this.#C!==L.NONE,isEmpty:this.#J(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ct(),this.#ft(),this.#P({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#b){this.#b=t;for(const e of this.#b)this.#z(e.defaultPropertiesToUpdate)}}getId(){return this.#F.id}get currentLayer(){return this.#n.get(this.#m)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#m}addLayer(t){this.#n.set(t.pageIndex,t),this.#D?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,n=!1,r=!1){if(this.#C!==t&&!(this.#U&&(await this.#U.promise,!this.#U))){if(this.#U=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===L.POPUP&&this.#d?.hideSidebar(),this.#d?.destroyPopup(),this.#C=t,t===L.NONE){this.setEditingState(!1),this.#mt();for(const a of this.#i.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#U.resolve();return}for(const a of this.#i.values())a.addStandaloneCommentButton();t===L.SIGNATURE&&await this.#$?.loadSignatures(),s&&z.clearPointerType(),this.setEditingState(!0),await this.#gt(),this.unselectAll();for(const a of this.#n.values())a.updateMode(t);if(t===L.POPUP){this.#s||=await this.#Y.getAnnotationsByType(new Set(this.#b.map(l=>l._editorType)));const a=new Set,o=[];for(const l of this.#i.values()){const{annotationElementId:h,hasComment:c,deleted:u}=l;h&&a.add(h),c&&!u&&o.push(l.getData())}for(const l of this.#s){const{id:h,popupRef:c,contentsObj:u}=l;c&&u?.str&&!a.has(h)&&!this.#c.has(h)&&o.push(l)}this.#d?.showSidebar(o)}if(!e){i&&this.addNewEditorFromKeyboard(),this.#U.resolve();return}for(const a of this.#i.values())a.uid===e?(this.setSelected(a),r?a.editComment():n?a.enterInEditMode():a.focus()):a.unselect();this.#U.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#b){switch(t){case G.CREATE:this.currentLayer.addNewEditor(e);return;case G.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#q||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of this.#S)s.updateParams(t,e);else for(const s of this.#b)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const n of this.#i.values())n.editorType===t&&n.show(e);(this.#q?.get(G.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#z([[G.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#R!==t){this.#R=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#D){this.#D=!0;const t=[];for(const e of this.#n.values())t.push(e.enable());await Promise.all(t);for(const e of this.#i.values())e.enable()}}#mt(){if(this.unselectAll(),this.#D){this.#D=!1;for(const t of this.#n.values())t.disable();for(const t of this.#i.values())t.disable()}}*getEditors(t){for(const e of this.#i.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#x&&clearTimeout(this.#x),this.#x=setTimeout(()=>{this.focusMainContainer(),this.#x=null},0)),this.#i.delete(t.id),t.annotationElementId&&this.#B?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#c.has(t.annotationElementId))&&this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#c.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#c.has(t)}removeDeletedAnnotationElement(t){this.#c.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#nt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#z(t.propertiesToUpdate))}get#bt(){let t=null;for(t of this.#S);return t}updateUI(t){this.#bt===t&&this.#z(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#z(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#S.has(t)){this.#S.delete(t),t.unselect(),this.#P({hasSelectedEditor:this.hasSelection});return}this.#S.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#g?.commitOrRemove();for(const e of this.#S)e!==t&&e.unselect();this.#d?.destroyPopup(),this.#S.clear(),this.#S.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#S.values().next().value}unselect(t){t.unselect(),this.#S.delete(t),this.#P({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#S.size!==0}get isEnterHandled(){return this.#S.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#P({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#J()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#J()})}addCommands(t){this.#u.add(t),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#J()})}cleanUndoStack(t){this.#u.cleanType(t)}#J(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(const t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#S],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(const n of e)n.remove()},i=()=>{for(const n of e)this.#nt(n)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#rt(t){for(const e of this.#S)e.unselect();this.#S.clear();for(const e of t)e.isEmpty()||(this.#S.add(e),e.select());this.#P({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#S)t.commit();this.#rt(this.#i.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==L.NONE))&&!this.#g?.commitOrRemove()&&(this.#d?.destroyPopup(),!!this.hasSelection)){for(const t of this.#S)t.unselect();this.#S.clear(),this.#P({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#L[0]+=t,this.#L[1]+=e;const[i,n]=this.#L,r=[...this.#S],a=1e3;this.#W&&clearTimeout(this.#W),this.#W=setTimeout(()=>{this.#W=null,this.#L[0]=this.#L[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#i.has(o.id)&&(o.translateInPage(i,n),o.translationDone())},undo:()=>{for(const o of r)this.#i.has(o.id)&&(o.translateInPage(-i,-n),o.translationDone())},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#p=new Map;for(const t of this.#S)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);const t=this.#p;this.#p=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#i.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#p)for(const s of this.#p.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(){return this.getActive()?.shouldGetKeyboardEvents()||this.#S.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}isEditingMode(){return this.#C!==L.NONE}get imageManager(){return T(this,"imageManager",new qs)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,h,c,u)=>({x:(h-i)/r,y:1-(l+c-s)/n,width:u/r,height:c/n});break;case"180":a=(l,h,c,u)=>({x:1-(l+c-s)/n,y:1-(h+u-i)/r,width:c/n,height:u/r});break;case"270":a=(l,h,c,u)=>({x:1-(h+u-i)/r,y:(l-s)/n,width:u/r,height:c/n});break;default:a=(l,h,c,u)=>({x:(l-s)/n,y:(h-i)/r,width:c/n,height:u/r});break}const o=[];for(let l=0,h=e.rangeCount;l<h;l++){const c=e.getRangeAt(l);if(!c.collapsed)for(const{x:u,y:f,width:p,height:g}of c.getClientRects())p===0||g===0||o.push(a(u,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#h||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#h?.delete(t)}renderAnnotationElement(t){const e=this.#h?.get(t.data.id);if(!e)return;const s=this.#l.getRawValue(e);s&&(this.#C===L.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){const i=this.#B?.get(t);i&&(i.setCanvas(e,s),this.#B.delete(t))}addMissingCanvas(t,e){(this.#B||=new Map).set(t,e)}}class It{#t=null;#e=!1;#s=null;#i=null;#n=null;#a=null;#r=!1;#o=null;#l=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#d=t._uiManager.useNewAltTextFlow,It.#f||=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){It._l10n??=t}async render(){const t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#i=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",It.#f.missing),e.setAttribute("data-l10n-id",It.#f["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=this.#l._uiManager._signal;t.addEventListener("contextmenu",xt,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#d&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#r=!0,i(n))},{signal:s}),await this.#m(),t}get#g(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#s&&(this.#s.focus({focusVisible:this.#r}),this.#r=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){this.#t===null&&(this.#h=t,this.#u=await It._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){const e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#h===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(this.#h=s,this.#u=i),!(this.#t===t&&this.#e===e)&&(n||(this.#t=t,this.#e=e),this.#m())}toggle(t=!1){this.#s&&(!t&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#s.disabled=!t)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#n=null,this.#o?.remove(),this.#o=null}async#m(){const t=this.#s;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",It.#f[this.#g]),this.#i?.setAttribute("data-l10n-id",It.#f[`${this.#g}-label`]),!this.#t){this.#n?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;const i=100,n=this.#l._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#n.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n?.classList.remove("show")},{signal:n})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class Oe{#t=null;#e=null;#s=!1;#i=null;#n=null;#a=null;#r=null;#o=null;#l=!1;#h=null;constructor(t){this.#i=t}renderForToolbar(){const t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){const t=this.#t=document.createElement("button");t.className="annotationCommentButton";const e=this.#i.commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#i._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=this.#i.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;const t=this.#i.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#i._uiManager.updatePopupColor(this.#i)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#i.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#h)return this.#h;if(!this.#t)return null;const{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#i.parent.boundingClientRect;return[(t-i)/r,(e+s-n)/a]}set commentPopupPositionInLayer(t){this.#h=t}hasDefaultPopupPosition(){return this.#h===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#i._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=[this.#i._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=this.#i._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",xt,{signal:s}),e&&(t.addEventListener("focusin",n=>{this.#i._focusEventsAllowed=!1,nt(n)},{capture:!0,signal:s}),t.addEventListener("focusout",n=>{this.#i._focusEventsAllowed=!0,nt(n)},{capture:!0,signal:s})),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),t===this.#e?this.edit():this.#i.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#s=!0,i(n))},{signal:s}),t.addEventListener("pointerenter",()=>{this.#i.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#i.toggleComment(!1,!1)},{signal:s}),t}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=this.#i.commentButtonPosition;const{width:h,height:c,x:u,y:f}=this.#i;s=u+s*h,i=f+i*c}const n=this.#i.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#i._uiManager.editComment(this.#i,r+s*o,a+i*l,{...t,parentDimensions:n})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#s}),this.#s=!1)}isDeleted(){return this.#l||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#n}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#r&&(this.#a=null),t===null){this.#r="",this.#l=!0;return}this.#r=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:s}){this.#r=t,this.#a=e,this.#o=s,this.#l=!1}setInitialText(t,e=null){this.#n=t,this.data=t,this.#o=null,this.#a=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#r="",this.#a=null,this.#o=null,this.#i=null,this.#s=!1,this.#l=!1}}function wi(d){d.preventDefault()}const Si=1e-4;function Es(d){return d.cancelable?(nt(d),!0):(d.stopPropagation(),!1)}class rn{#t;#e=!1;#s=null;#i;#n;#a;#r;#o;#l=!1;#h=null;#u;#d=new Set;#f=null;#g;#m=null;#c=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,onPanning:a=null,signal:o}){this.#t=t,this.#s=s,this.#i=e,this.#n=i,this.#a=n,this.#r=r,this.#o=a,this.#g=new AbortController,this.#u=AbortSignal.any([o,this.#g.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/St.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/St.pixelRatio}#p(t){if(this.#i?.())return;this.#y(t);const e=this.#d;for(const{identifier:s}of t.changedTouches)e.add(s);if(e.size===1){this.#b();return}if(!this.#m){this.#m=new AbortController;const s=AbortSignal.any([this.#u,this.#m.signal]),i=this.#t,n={signal:s,capture:!1,passive:!1};i.addEventListener("touchmove",this.#w.bind(this),n);const r=this.#_.bind(this);i.addEventListener("touchend",r,n),i.addEventListener("touchcancel",r,n),n.capture=!0,i.addEventListener("pointerdown",nt,n),i.addEventListener("pointermove",nt,n),i.addEventListener("pointercancel",wi,n),i.addEventListener("pointerup",wi,n),this.#n?.()}this.#l=Es(t),this.#v(t)}#b(){if(this.#h)return;const t=this.#h=new AbortController,e=AbortSignal.any([this.#u,t.signal]),s=this.#t,i={capture:!0,signal:e,passive:!1},n=r=>{r.pointerType==="touch"&&(this.#h?.abort(),this.#h=null)};s.addEventListener("pointerdown",r=>{r.pointerType==="touch"&&(nt(r),n(r))},i),s.addEventListener("pointerup",n,i),s.addEventListener("pointercancel",n,i)}#y(t){const e=this.#d;if(e.size===0)return;const s=this.#d=new Set;for(const{identifier:i}of t.touches)e.has(i)&&s.add(i)}#A(t){const e=this.#d,s=[];for(const i of t.touches)e.has(i.identifier)&&s.push(i);return s}#v(t){const e=this.#A(t);if(e.length!==2||this.#s?.()){this.#f=null;return}const[s,i]=e;this.#f={touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2}}#w(t){if(!this.#f)return;const e=this.#A(t);if(e.length!==2)return;const s=this.#l;if(this.#l=Es(t),!this.#l)return;if(!s){this.#v(t);return}const[i,n]=e,{screenX:r,screenY:a}=i,{screenX:o,screenY:l}=n,h=this.#f,{touch0X:c,touch0Y:u,touch1X:f,touch1Y:p,panX:g,panY:m}=h,b=f-c,y=p-u,A=o-r,S=l-a,v=(i.clientX+n.clientX)/2,w=(i.clientY+n.clientY)/2;h.panX=v,h.panY=w;const _=v-g,x=w-m,E=(r+o)/2,P=(a+l)/2,k=Math.hypot(E-h.screenPanX,P-h.screenPanY);h.screenPanX=E,h.screenPanY=P;const H=Math.hypot(A,S),N=Math.hypot(b,y),O=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*k;if(H<Si||N<Si||Math.abs(N-H)<=O){(_||x)&&this.#o?.(_,x);return}h.touch0X=r,h.touch0Y=a,h.touch1X=o,h.touch1Y=l;const K=Math.sign(H-N);if(!this.#e){this.#e=!0,this.#c=K,(_||x)&&this.#o?.(_,x);return}if(this.#c){const D=this.#c;if(this.#c=0,K!==D&&Math.abs(H-N)<=2*k){this.#e=!1,(_||x)&&this.#o?.(_,x);return}}this.#a?.([g,m],N,H,_,x)}#_(t){if(this.#y(t),this.#d.size>=2){this.#v(t);return}const e=!!this.#f;this.#x(),this.#d.size===1&&this.#b(),e&&Es(t)}#x(){this.#f=null,this.#e=!1,this.#c=0,this.#l=!1,this.#m&&(this.#m.abort(),this.#m=null,this.#r?.())}destroy(){this.#x(),this.#d.clear(),this.#g?.abort(),this.#g=null,this.#h?.abort(),this.#h=null}}class I{#t=null;#e=null;#s=null;#i=null;#n=null;#a=!1;#r=null;#o="";#l=null;#h=null;#u=null;#d=null;#f=null;#g="";#m=!1;#c=null;#p=!1;#b=!1;#y=!1;#A=null;#v=0;#w=0;#_=null;#x=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#E=!1;#M=I._zIndex++;static _borderLineWidth=-1;static _colorManager=new Qs;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=I.prototype._resizeWithKeyboard,e=Gt.TRANSLATE_SMALL,s=Gt.TRANSLATE_BIG;return T(this,"_resizerKeyboardManager",new bt([[["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"],I.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,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:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}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 T(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new pr({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(I._l10n??=t,I._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"}),I._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"}),I._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);I._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){$("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=t,this.div?.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=this.#M}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#L(),this.#d?.remove(),this.#d=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.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[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,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()}#k([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()}translate(t,e){this.#k(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#k(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=s;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=I,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=s,o*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=W(n,0,s-a),r=W(r,0,i-o);break;case 90:n=W(n,0,s-o),r=W(r,a,i);break;case 180:n=W(n,a,s),r=W(r,o,i);break;case 270:n=W(n,o,s),r=W(r,0,i-a);break}this.x=n/=s,this.y=r/=i;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#T(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return I.#T(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return I.#T(t,e,360-this.parentRotation)}#F(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]}}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]}#D(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.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");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#O.bind(this,s),{signal:e}),i.addEventListener("contextmenu",xt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#l)}#O(t,e){e.preventDefault();const{isMac:s}=j.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,this.#h=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#N.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",nt,{passive:!1,signal:r}),window.addEventListener("contextmenu",xt,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#I()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#R(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#I(){if(!this.#u)return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:this.#R.bind(this,n,r,a,o),undo:this.#R.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#N(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=I.MIN_SIZE/s,h=I.MIN_SIZE/i,c=this.#F(this.rotation),u=(D,F)=>[c[0]*D+c[2]*F,c[1]*D+c[3]*F],f=this.#F(360-this.rotation),p=(D,F)=>[f[0]*D+f[2]*F,f[1]*D+f[3]*F];let g,m,b=!1,y=!1;switch(t){case"topLeft":b=!0,g=(D,F)=>[0,0],m=(D,F)=>[D,F];break;case"topMiddle":g=(D,F)=>[D/2,0],m=(D,F)=>[D/2,F];break;case"topRight":b=!0,g=(D,F)=>[D,0],m=(D,F)=>[0,F];break;case"middleRight":y=!0,g=(D,F)=>[D,F/2],m=(D,F)=>[0,F/2];break;case"bottomRight":b=!0,g=(D,F)=>[D,F],m=(D,F)=>[0,0];break;case"bottomMiddle":g=(D,F)=>[D/2,F],m=(D,F)=>[D/2,0];break;case"bottomLeft":b=!0,g=(D,F)=>[0,F],m=(D,F)=>[D,0];break;case"middleLeft":y=!0,g=(D,F)=>[0,F/2],m=(D,F)=>[D,F/2];break}const A=g(a,o),S=m(a,o);let v=u(...S);const w=I._round(n+v[0]),_=I._round(r+v[1]);let x=1,E=1,P,k;if(e.fromKeyboard)({deltaX:P,deltaY:k}=e);else{const{screenX:D,screenY:F}=e,[rt,Ct]=this.#h;[P,k]=this.screenToPageTranslation(D-rt,F-Ct),this.#h[0]=D,this.#h[1]=F}if([P,k]=p(P/s,k/i),b){const D=Math.hypot(a,o);x=E=Math.max(Math.min(Math.hypot(S[0]-A[0]-P,S[1]-A[1]-k)/D,1/a,1/o),l/a,h/o)}else y?x=W(Math.abs(S[0]-A[0]-P),l,1)/a:E=W(Math.abs(S[1]-A[1]-k),h,1)/o;const H=I._round(a*x),N=I._round(o*E);v=u(...m(H,N));const O=w-v[0],K=_-v[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=H,this.height=N,this.x=O,this.y=K,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#b)return this._editToolbar;this._editToolbar=new _e(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(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#s?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#s||(It.initialize(I._l10n),this.#s=new It(this),this.#t&&(this.#s.data=this.#t,this.#t=null)),this.#s}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#i?.focusButton()}addCommentButton(){return this.canAddComment?this.#i||=new Oe(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#n){this._uiManager.isEditingMode()&&this.#n.classList.remove("hidden");return}this.hasComment&&(this.#n=this.#i.renderForStandalone(),this.div.append(this.#n))}}removeStandaloneCommentButton(){this.#i.removeStandaloneCommentButton(),this.#n=null}hideStandaloneCommentButton(){this.#n?.classList.add("hidden")}get comment(){if(!this.#i)return null;const{data:{richText:t,text:e,date:s,deleted:i}}=this.#i;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#i||=new Oe(this),typeof t=="object"&&t!==null?this.#i.restoreData(t):this.#i.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||(this.#i||=new Oe(this),this.#i.setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#i?.hasBeenEdited()}get hasDeletedComment(){return this.#i?.isDeleted()}get hasComment(){return!!this.#i&&!this.#i.isEmpty()&&!this.#i.isDeleted()}async editComment(t){this.#i||=new Oe(this),this.#i.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#i.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=i-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#i.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#a?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#H();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,n]=this.getInitialTranslation();return this.translate(i,n),nn(this,t,["keydown","pointerdown","dblclick"]),this.#$(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#j(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#B(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;const r=this.#F(this.rotation),a=(w,_)=>[r[0]*w+r[2]*_,r[1]*w+r[3]*_],[o,l]=this.parentDimensions,h=this.x,c=this.y,u=this.width,f=this.height,p=I.MIN_SIZE/o,g=I.MIN_SIZE/l;n=Math.max(Math.min(n,1/u,1/f),p/u,g/f);const m=I._round(u*n),b=I._round(f*n);if(m===u&&b===f)return;this.#c||=[h,c,u,f];const y=a(u/2,f/2),A=I._round(h+y[0]),S=I._round(c+y[1]),v=a(m/2,b/2);this.x=A-v[0],this.y=S-v[1],this.width=m,this.height=b,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#G(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#I()}pointerdown(t){const{isMac:e}=j.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#S(t);return}this.#C(t)}#C(t){const{isMac:e}=j.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#S(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=l=>{i.abort(),this.#r=null,this.#m=!1,this._uiManager.endDragSession()||this.#C(l),s&&this._onStopDragging()};e&&(this.#v=t.clientX,this.#w=t.clientY,this.#r=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",l=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:h,clientY:c,pointerId:u}=l;if(u!==this.#r){nt(l);return}const[f,p]=this.screenToPageTranslation(h-this.#v,c-this.#w);this.#v=h,this.#w=c,this._uiManager.dragSelectedEditors(f,p),this.div.scrollIntoView({block:"nearest"})},r),window.addEventListener("touchmove",nt,r),window.addEventListener("pointerdown",l=>{l.pointerType===this.#o&&(this.#x||l.isPrimary)&&a(l),nt(l)},r));const o=l=>{if(!this.#r||this.#r===l.pointerId){a(l);return}nt(l)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#A&&clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#A=null,this.parent?.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,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,h=e/i,c=this.x*n,u=this.y*r,f=this.width*n,p=this.height*r;switch(s){case 0:return[c+l+a,r-u-h-p+o,c+l+f+a,r-u-h+o];case 90:return[c+h+a,r-u+l+o,c+h+p+a,r-u+l+f+o];case 180:return[c-l-f+a,r-u+h+o,c-l+a,r-u+h+p+o];case 270:return[c-h-p+a,r-u-l-f+o,c-h+a,r-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&I._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#i?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:s||h,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#b=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#b=!1,!0):!1}isInEditMode(){return this.#b}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#H(){if(this.#f||!this.div)return;this.#f=new AbortController;const t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#$(){this.#x||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||(this.#x=new rn({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#j.bind(this),onPinching:this.#B.bind(this),onPinchEnd:this.#G.bind(this),signal:this._uiManager._signal}))}rebuild(){this.#H(),this.#$()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.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,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;const[n,r]=i.pageDimensions,[a,o,l,h]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=l/n,i.height=h/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.#x?.destroy(),this.#x=null,this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#A&&(clearTimeout(this.#A),this.#A=null),this.#L(),this.removeEditToolbar(),this.#_){for(const t of this.#_.values())clearTimeout(t);this.#_=null}this.parent=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#D(),this.#l.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,n,r]=this.getPDFRect();return[I._round(s+(n-s)*t),I._round(i+(r-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#i.commentPopupPositionInLayer}set commentPopupPosition(t){this.#i.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#i.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#i.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#i?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#l.children;if(!this.#e){this.#e=Array.from(e);const r=this.#V.bind(this),a=this.#q.bind(this),o=this._uiManager._signal;for(const l of this.#e){const h=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#Y.bind(this,h),{signal:o}),l.setAttribute("data-l10n-id",I._l10nResizer[h])}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#l.append(this.#l.firstElementChild);else if(n>i)for(let a=0;a<n-i;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(const a of e){const l=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",I._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#V(t){I._resizerKeyboardManager.exec(this,t)}#q(t){this.#y&&t.relatedTarget?.parentNode!==this.#l&&this.#L()}#Y(t){this.#g=this.#y?t:""}#K(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#y&&this.#N(this.#g,{deltaX:t,deltaY:e,fromKeyboard:!0})}#L(){this.#y=!1,this.#K(-1),this.#I()}_stopResizingWithKeyboard(){this.#L(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#s?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#s?.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 this.#p}set isEditing(t){this.#p=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){this.#_||=new Map;const{action:s}=t;let i=this.#_.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#_.delete(s),this.#_.size===0&&(this.#_=null)},I._telemetryTimeout),this.#_.set(s,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.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?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class pr extends I{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const _i=3285377520,At=4294901760,Pt=65535;class Hs{constructor(t){this.h1=t?t&4294967295:_i,this.h2=t?t&4294967295:_i}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,m=t.length;g<m;g++){const b=t.charCodeAt(g);b<=255?e[s++]=b:(e[s++]=b>>>8,e[s++]=b&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,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,l=this.h1,h=this.h2;const c=3432918353,u=461845907,f=c&Pt,p=u&Pt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*c&At|a*f&Pt,a=a<<15|a>>>17,a=a*u&At|a*p&Pt,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(o=r[g],o=o*c&At|o*f&Pt,o=o<<15|o>>>17,o=o*u&At|o*p&Pt,h^=o,h=h<<13|h>>>19,h=h*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*c&At|a*f&Pt,a=a<<15|a>>>17,a=a*u&At|a*p&Pt,i&1?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&At|t*36045&Pt,e=e*4283543511&At|((e<<16|t>>>16)*2950163797&At)>>>16,t^=e>>>1,t=t*444984403&At|t*60499&Pt,e=e*3301882366&At|((e<<16|t>>>16)*3120437893&At)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Te=Object.freeze({map:null,hash:"",transfer:void 0});class Js{#t=!1;#e=null;#s=null;#i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const s=this.#i.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#i.get(t)}remove(t){const e=this.#i.get(t);e!==void 0&&(e instanceof I&&this.#s.delete(e.annotationElementId),this.#i.delete(t),this.#i.size===0&&this.resetModified(),!this.#i.values().some(s=>s instanceof I)&&this.onAnnotationEditor?.(null))}setValue(t,e){const s=this.#i.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#i.set(t,e);i&&this.#n(),e instanceof I&&((this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#i.has(t)}get size(){return this.#i.size}#n(){this.#t||(this.#t=!0,this.onSetModified?.())}resetModified(){this.#t&&(this.#t=!1,this.onResetModified?.())}get print(){return new an(this)}get serializable(){if(this.#i.size===0)return Te;const t=new Map,e=new Hs,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#i){const o=a instanceof I?a.serialize(!1,i):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Te}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const n of this.#i.values()){if(!(n instanceof I)){n.popup&&(n.popup.deleted?i+=1:s+=1);continue}n.isCommentDeleted?i+=1:n.hasEditedComment&&(s+=1);const r=n.telemetryFinalData;if(!r)continue;const{type:a}=r;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(n).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[l,h]of Object.entries(r)){if(l==="type")continue;const c=o.getOrInsertComputed(l,Ws);c.set(h,(c.get(h)??0)+1)}}if((i>0||s>0)&&(t||=Object.create(null),t.comments={deleted:i,edited:s}),!t)return null;for(const[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){const s=this.#s?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;const t=[];if(this.#s)for(const s of this.#s.values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Hs;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#i.entries()}}class an extends Js{#t=Te;constructor(t){super();const{serializable:e}=t;if(e===Te)return;const{map:s,hash:i,transfer:n}=e,r=structuredClone(s,n?{transfer:n}:null);this.#t={map:r,hash:i,transfer:[]}}get print(){$("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return T(this,"modifiedIds",{ids:new Set,hash:""})}}const ne="__forcedDependency",{floor:Ei,ceil:xi}=Math;function Ci(d,t,e,s,i,n){d[t*4+0]=Math.min(d[t*4+0],e),d[t*4+1]=Math.min(d[t*4+1],s),d[t*4+2]=Math.max(d[t*4+2],i),d[t*4+3]=Math.max(d[t*4+3],n)}function gr(d,t,e,s,i){let n;d?(d<0&&(n=i[0],i[0]=i[2],i[2]=n),i[0]*=d,i[2]*=d,t<0&&(n=i[1],i[1]=i[3],i[3]=n),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const Us=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class mr{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===Us}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}const Ti=(d,t)=>d?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));class br{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(Ft);_pendingBBoxIdx=-1;#i;#n;#a;#r;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#i=t.width,this.#n=t.height,this.#o(e)}growOperationsCount(t){t>=this.#r.length&&this.#o(t,this.#r)}#o(t,e){const s=new ArrayBuffer(t*4);this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),e&&e.length>0?(this.#r.set(e),this.#r.fill(Us,e.length)):this.#r.fill(Us)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;const i=this._savesStack.pop();return i!==void 0&&(e?.(i,t),this.#r[t]=this.#r[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?.(s,t),this.#r[t]=this.#r[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e?.(s,t),this.#r[t]=this.#r[s]),this}pushBaseTransform(t){return this.#t.push(C.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){return this.#t.length>1&&this.#t.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#s.set(Ft,0)),this}recordClipBox(t,e,s,i,n,r){const a=C.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=Ft.slice();C.axialAlignedBoundingBox([s,n,i,r],a,o);const l=C.intersect(this.#e,o);return l?(this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3]):(this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0),this}recordBBox(t,e,s,i,n,r){const a=this.#e;if(a[0]===1/0)return this;const o=C.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return C.axialAlignedBoundingBox([s,n,i,r],o,this.#s),this;const l=Ft.slice();return C.axialAlignedBoundingBox([s,n,i,r],o,l),this.#s[0]=W(l[0],a[0],this.#s[0]),this.#s[1]=W(l[1],a[1],this.#s[1]),this.#s[2]=W(l[2],this.#s[2],a[2]),this.#s[3]=W(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#i,this.#e[2]),this.#s[3]=Math.min(this.#n,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=Ei(this.#s[0]*256/this.#i),n=Ei(this.#s[1]*256/this.#n),r=xi(this.#s[2]*256/this.#i),a=xi(this.#s[3]*256/this.#n);if(Ci(this.#a,t,i,n,r,a),s)for(const o of s)for(const l of o)l!==t&&Ci(this.#a,l,i,n,r,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3])),this}take(){return new mr(this.#r,this.#a)}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,n=0,r=0,a){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class yr{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[ne]:[]};#s=new Map;#i=new Set;#n=new Map;#a;#r;#o;constructor(t,e=!1){this.#o=t,e&&(this.#a=new Map,this.#r=(s,i)=>{Ti(this.#a,i).dependencies.add(s)})}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[ne]:{__proto__:this.#e[ne]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#r);const e=Object.getPrototypeOf(this.#t);return e===null?this:(this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this)}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#r),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#r),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ne,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#i)this.recordFutureForcedDependency(ne,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,i,n,r){return this.#o.recordClipBox(t,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#o.recordBBox(t,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){const o=s.bbox;let l,h;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#n.get(s),l!==!1&&(h=[0,0,0,0],C.axialAlignedBoundingBox(o,s.fontMatrix,h),(i!==1||n!==0||r!==0)&&gr(i,-i,n,r,h),l)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!a)return this.recordFullPageBBox(t);const c=a();return o&&h&&l===void 0&&(l=h[0]<=n-c.actualBoundingBoxLeft&&h[2]>=n+c.actualBoundingBoxRight&&h[1]<=r-c.actualBoundingBoxAscent&&h[3]>=r+c.actualBoundingBoxDescent,this.#n.set(s,l),l)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,n-c.actualBoundingBoxLeft,n+c.actualBoundingBoxRight,r-c.actualBoundingBoxAscent,r+c.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){const s=this.#i,i=this.#t,n=this.#e;for(const r of e)r in this.#t?s.add(i[r]):r in n&&n[r].forEach(s.add,s);return this}recordNamedDependency(t,e){return this.#s.has(e)&&this.#i.add(this.#s.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ne]),this.#a){const i=Ti(this.#a,t),{dependencies:n}=i;this.#i.forEach(n.add,n),this.#o._savesStack.forEach(n.add,n),this.#o._markedContentStack.forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}const s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.recordOperation(t,e,[this.#i,this.#o._savesStack,this.#o._markedContentStack]),s&&this.#i.clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(this.#i);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===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(t),s&&this.#i.clear(),this}take(){return this.#n.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}}class ke{#t;#e;#s;#i=0;#n=0;constructor(t,e,s){if(t instanceof ke&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#n++,this.#t.save(this.#e),this}restore(t){return this.#n>0&&(this.#t.restore(this.#e),this.#n--),this}recordOpenMarker(t){return this.#i++,this}getOpenMarker(){return this.#i>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#i--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#s||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,s,i,n,r){return this.#s||this.#t.recordClipBox(this.#e,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#s||this.#t.recordBBox(this.#e,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i,n,r,a){return this.#s||this.#t.recordCharacterBBox(this.#e,e,s,i,n,r,a),this}recordFullPageBBox(t){return this.#s||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#s||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const vt={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","filter","fillColor"]};class Je{#t;#e;#s=4;#i=0;#n=new Je.#a(this.#s*6);static#a=j.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,i){if(this.#i===this.#s){this.#s*=2;const a=new Je.#a(this.#s*6);a.set(this.#n),this.#n=a}const n=V(t);let r;if(i[0]!==1/0){const a=Ft.slice();C.axialAlignedBoundingBox([0,-s,e,0],n,a);const o=C.intersect(i,a);if(!o)return;const[l,h,c,u]=o;if(l!==a[0]||h!==a[1]||c!==a[2]||u!==a[3]){const f=Math.atan2(n[1],n[0]),p=Math.abs(Math.sin(f)),g=Math.abs(Math.cos(f));if(p<1e-6||g<1e-6||Math.abs(p-g)<1e-6)r=[l,h,l,u,c,h];else{const m=c-l,b=u-h,y=p*p,A=g*g,S=g*p,v=A-y,w=(b*A-m*S)/v,_=(b*S-m*y)/v;r=[l+_,h,l,h+w,c,u-w]}}}r||(r=[0,-s,0,0,e,-s],C.applyTransform(r,n,0),C.applyTransform(r,n,2),C.applyTransform(r,n,4)),r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#n.set(r,this.#i*6),this.#i++}take(){return this.#n.subarray(0,this.#i*6)}}const ki=new RegExp("\\p{Cc}","u");function Ar(d){const t=d[0];if(d.length<2||t!=='"'&&t!=="'"||d.at(-1)!==t)return!1;const e=d.length-1;for(let s=1;s<e;s++){const i=d[s];if(i===t||ki.test(i)||i==="\\"&&(++s>=e||ki.test(d[s])))return!1}return!0}function Pi(d){return Ar(d)?d:`"${d.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}class vr{#t=new Set;#e=new Set;#s=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.#t.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.#t.delete(t),this._document.fonts.delete(t)}insertRule(t){const e=this.#i();e.insertRule(t,e.cssRules.length)}#i(){if(this.#s)return this.#s;const t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:e}=this._document;if(e){const s=new t;return e.push(s),this.#s=s}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),this.#s=this.styleElement.sheet}clear(){for(const t of this.#t)this._document.fonts.delete(t);if(this.#t.clear(),this.#e.clear(),this.#s){const{adoptedStyleSheets:t}=this._document;t?.includes(this.#s)&&(this._document.adoptedStyleSheets=t.filter(e=>e!==this.#s)),this.#s=null}this.styleElement?.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||this.#e.has(t.loadedName))){if(J(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:n,style:r}=t,a=new FontFace(i,n,r);this.addNativeFontFace(a);try{await a.load(),this.#e.add(i),s?.(t)}catch{B(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}$("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 B(`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 this.#n(t)}}get isFontLoadingAPISupported(){return T(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return T(this,"isSyncFontLoadingSupported",mt||j.platform.isFirefox)}#n(t){function e(){for(J(!r.done,"completeRequest() cannot be called twice."),r.done=!0;s.length>0&&s[0].done;){const E=s.shift();setTimeout(E.resolve,0)}}const{loadingRequests:s}=this,{promise:i,resolve:n}=Promise.withResolvers(),r={done:!1,resolve:n};s.push(r),this._loadTestFont??=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");function a(E,P){return E.charCodeAt(P)<<24|E.charCodeAt(P+1)<<16|E.charCodeAt(P+2)<<8|E.charCodeAt(P+3)&255}function o(E){return String.fromCharCode(E>>24&255,E>>16&255,E>>8&255,E&255)}function l(E,P,k,H){const N=E.substring(0,P),O=E.substring(P+k);return N+H+O}let h,c;const u=this._document.createElement("canvas");u.width=1,u.height=1;const f=u.getContext("2d");let p=0;function g(E,P){if(++p>30){B("Load test font never loaded."),P();return}if(f.font="30px "+E,f.fillText(".",0,20),f.getImageData(0,0,1,1).data[3]>0){P();return}setTimeout(g.bind(null,E,P))}const m=`lt${Date.now()}${this.loadTestFontId++}`;let b=this._loadTestFont;b=l(b,976,m.length,m);const A=16,S=1482184792;let v=a(b,A);for(h=0,c=m.length-3;h<c;h+=4)v=v-S+a(m,h)|0;h<m.length&&(v=v-S+a(m+"XXX",h)|0),b=l(b,A,4,o(v));const w=`url(data:font/opentype;base64,${btoa(b)});`,_=`@font-face {font-family:"${m}";src:${w}}`;this.insertRule(_);const x=this._document.createElement("div");x.style.visibility="hidden",x.style.width=x.style.height="10px",x.style.position="absolute",x.style.top=x.style.left="0px";for(const E of[t.loadedName,m]){const P=this._document.createElement("span");P.textContent="Hi",P.style.fontFamily=E,x.append(P)}return this._document.body.append(x),g(m,()=>{x.remove(),e()}),i}}class wr{#t=new Map;#e;constructor(t,e=null,s,i){this.#e=t,this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){const{data:t}=this;if(!t||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,t,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(Pi(this.cssFontInfo.fontFamily),t,s)}return this._inspectFont?.(this),e}createFontFaceRule(){const{data:t}=this;if(!t||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t.toBase64()});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:${Pi(this.cssFontInfo.fontFamily)};${i}src:${e}}`}return this._inspectFont?.(this,e),s}getPathGenerator(t,e){let s=this.#t.get(e);if(s)return s;const i=`${this.loadedName}_path_${e}`;let n;try{n=t.get(i)}catch(r){B(`getPathGenerator - ignoring character: "${r}".`)}return s=sn(n?.path),this.fontExtraProperties||t.delete(i),this.#t.set(e,s),s}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(t){T(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.missingFile?null:"font/opentype"}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}}class Sr{static strings=["fontFamily","fontWeight","italicAngle"]}class _r{static strings=["css","loadedName","baseFontName","src"]}class re{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static strings=["fallbackName","loadedName"];static OFFSET_BBOX=Math.ceil(this.bools.length*2/8);static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_STRINGS=this.OFFSET_FONT_MATRIX+1+48}class $t{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class Er{static get decoder(){return T(this,"decoder",new TextDecoder)}static get encoder(){return T(this,"encoder",new TextEncoder)}}function Ee(d,t,e,s=0){const{decoder:i}=Er;for(let r=0;r<e;r++)s+=t.getUint32(s)+4;const n=t.getUint32(s);return i.decode(new Uint8Array(d,s+4,n))}class xr{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){return J(t<Sr.strings.length,"Invalid string index"),Ee(this.#t,this.#e,t)}get fontFamily(){return T(this,"fontFamily",this.#s(0))}get fontWeight(){return T(this,"fontWeight",this.#s(1))}get italicAngle(){return T(this,"italicAngle",this.#s(2))}}class Cr{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){return J(t<_r.strings.length,"Invalid string index"),Ee(this.#t,this.#e,t,4)}get css(){return T(this,"css",this.#s(0))}get loadedName(){return T(this,"loadedName",this.#s(1))}get baseFontName(){return T(this,"baseFontName",this.#s(2))}get src(){return T(this,"src",this.#s(3))}get style(){let t=0;t+=4+this.#e.getUint32(t);const e=Ee(this.#t,this.#e,0,t),s=Ee(this.#t,this.#e,1,t);return T(this,"style",{style:e,weight:s})}}class Tr{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){J(t<re.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=this.#e.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return T(this,"black",this.#s(0))}get bold(){return T(this,"bold",this.#s(1))}get disableFontFace(){return T(this,"disableFontFace",this.#s(2))}get fontExtraProperties(){return T(this,"fontExtraProperties",this.#s(3))}get isInvalidPDFjsFont(){return T(this,"isInvalidPDFjsFont",this.#s(4))}get isType3Font(){return T(this,"isType3Font",this.#s(5))}get italic(){return T(this,"italic",this.#s(6))}get missingFile(){return T(this,"missingFile",this.#s(7))}get remeasure(){return T(this,"remeasure",this.#s(8))}get vertical(){return T(this,"vertical",this.#s(9))}#i(t,e,s,i){const n=this.#e.getUint8(t++);if(n===0)return;J(n===e,"Invalid array length.");const r=new Array(n);for(let a=0;a<n;a++)r[a]=this.#e[s](t,!0),t+=i;return r}get bbox(){return T(this,"bbox",this.#i(re.OFFSET_BBOX,4,"getInt16",2))}get fontMatrix(){return T(this,"fontMatrix",this.#i(re.OFFSET_FONT_MATRIX,6,"getFloat64",8))}#n(t){return J(t<re.strings.length,"Invalid string index"),Ee(this.#t,this.#e,t,re.OFFSET_STRINGS+4)}get fallbackName(){return T(this,"fallbackName",this.#n(0))}get loadedName(){return T(this,"loadedName",this.#n(1))}#a(t){let e=re.OFFSET_STRINGS;for(let i=0;i<=t;i++)e+=4+this.#e.getUint32(e);const s=this.#e.getUint32(e);return{offset:e,length:s}}get data(){const{offset:t,length:e}=this.#a(2);return e?new Uint8Array(this.#t,t+4,e):void 0}clearData(){const{offset:t,length:e}=this.#a(2);e&&(this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t))}get cssFontInfo(){const{offset:t,length:e}=this.#a(1);let s=null;if(e){const i=new Uint8Array(this.#t,t+4,e).slice();s=new xr(i.buffer)}return T(this,"cssFontInfo",s)}get systemFontInfo(){const{offset:t,length:e}=this.#a(0);let s=null;if(e){const i=new Uint8Array(this.#t,t+4,e).slice();s=new Cr(i.buffer)}return T(this,"systemFontInfo",s)}}class kr{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[$t.KIND],s=!!this.data[$t.HAS_BBOX],i=!!this.data[$t.HAS_BACKGROUND],n=t.getUint32($t.N_COORD,!0),r=t.getUint32($t.N_COLOR,!0),a=t.getUint32($t.N_STOP,!0);let o=20;const l=new Float32Array(this.buffer,o,n*2);o+=n*8;const h=new Uint8Array(this.buffer,o,r*4);o+=r*4;const c=[];for(let p=0;p<a;++p){const g=t.getFloat32(o,!0);o+=4;const m=t.getUint32(o,!0);o+=4,c.push([g,`#${m.toString(16).padStart(6,"0")}`])}let u=null;if(s){u=[];for(let p=0;p<4;++p)u.push(t.getFloat32(o,!0)),o+=4}let f=null;if(i&&(f=new Uint8Array(this.buffer,o,3),o+=3),e===1)return["RadialAxial","axial",u,c,[l[0],l[1]],[l[2],l[3]],null,null];if(e===2)return["RadialAxial","radial",u,c,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){const p=this.data[$t.SHADING_TYPE];let g=null;if(l.length>0){g=Ft.slice();for(let m=0,b=l.length;m<b;m+=2)C.pointBoundingBox(l[m],l[m+1],g)}return["Mesh",p,l,h,n,g,u,f]}throw new Error(`Unsupported pattern kind: ${e}`)}}class Pr{#t;constructor(t){this.#t=t}get path(){return j.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}}function Mr(d){if(d instanceof URL)return d;if(typeof d=="string"){if(mt){if(/^[a-z][a-z0-9\-+.]+:/i.test(d))return new URL(d);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(d))}const t=URL.parse(d,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 Dr(d){if(mt&&typeof Buffer<"u"&&d instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength)return d;if(typeof d=="string")return as(d);if(d instanceof ArrayBuffer||ArrayBuffer.isView(d)||typeof d=="object"&&!isNaN(d?.length))return new Uint8Array(d);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Re(d){if(typeof d!="string")return null;if(d.endsWith("/"))return d;throw new Error(`Invalid factory url: "${d}" must include trailing slash.`)}const Gs=d=>typeof d=="object"&&Number.isInteger(d?.num)&&d.num>=0&&Number.isInteger(d?.gen)&&d.gen>=0,Ir=d=>typeof d=="object"&&typeof d?.name=="string",Fr=Zn.bind(null,Gs,Ir);class Or{#t=new Map;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:n}=s;if(n.aborted){B("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}const Le={DATA:1,ERROR:2},tt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Mi(){}function dt(d){if(d instanceof Ut||d instanceof Fs||d instanceof Is||d instanceof Qe||d instanceof ws)return d;switch(d instanceof Error||typeof d=="object"&&d!==null||$('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),d.name){case"AbortException":return new Ut(d.message);case"InvalidPDFException":return new Fs(d.message);case"PasswordException":return new Is(d.message,d.code);case"ResponseException":return new Qe(d.message,d.status,d.missing);case"UnknownErrorException":return new ws(d.message,d.details)}return new ws(d.message,d.toString())}class we{#t=new Map;#e=new Map;#s=1;#i;#n=new AbortController;#a;#r=new Map;#o=1;#l=new Map;#h;constructor(t,e,s){this.#a=t,this.#h=e,this.#i=s,s.addEventListener("message",this.#u.bind(this),{signal:this.#n.signal})}#u({data:t}){if(t.targetName!==this.#a)return;if(t.stream){this.#f(t);return}if(t.callback){const{callbackId:s,callback:i}=t,n=this.#e.get(s);if(!n)throw new Error(`Cannot resolve callback ${s}`);if(this.#e.delete(s),i===Le.DATA)n.resolve(t.data);else if(i===Le.ERROR)n.reject(dt(t.reason));else throw new Error("Unexpected callback case");return}const e=this.#t.get(t.action);if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.#a,i=t.sourceName,n=this.#i;Promise.try(e,t.data).then(r=>{n.postMessage({sourceName:s,targetName:i,callback:Le.DATA,callbackId:t.callbackId,data:r})},r=>{n.postMessage({sourceName:s,targetName:i,callback:Le.ERROR,callbackId:t.callbackId,reason:dt(r)})});return}if(t.streamId){this.#d(t);return}e(t.data)}on(t,e){const s=this.#t;if(s.has(t))throw new Error(`There is already a "${t}" handler.`);s.set(t,e)}send(t,e,s){this.#i.postMessage({sourceName:this.#a,targetName:this.#h,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.#s++,n=Promise.withResolvers();this.#e.set(i,n);try{this.#i.postMessage({sourceName:this.#a,targetName:this.#h,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.#o++,r=this.#a,a=this.#h,o=this.#i;return new ReadableStream({start:l=>{const h=Promise.withResolvers();return this.#r.set(n,{controller:l,startCall:h,pullCall:null,cancelCall:null,isClosed:!1}),o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:l.desiredSize},i),h.promise},pull:l=>{const h=Promise.withResolvers();return this.#r.get(n).pullCall=h,o.postMessage({sourceName:r,targetName:a,stream:tt.PULL,streamId:n,desiredSize:l.desiredSize}),h.promise},cancel:l=>{J(l instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.#r.get(n).cancelCall=h,this.#r.get(n).isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:tt.CANCEL,streamId:n,reason:dt(l)}),h.promise}},s)}#d(t){const e=t.streamId,s=this.#a,i=t.sourceName,n=this.#i,r=this.#l,a=this.#t.get(t.action),o={enqueue(l,h=1,c){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=h,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:tt.ENQUEUE,streamId:e,chunk:l},c)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:tt.CLOSE,streamId:e}),r.delete(e))},error(l){J(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:tt.ERROR,streamId:e,reason:dt(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,r.set(e,o),Promise.try(a,t.data,o).then(()=>{n.postMessage({sourceName:s,targetName:i,stream:tt.START_COMPLETE,streamId:e,success:!0})},l=>{n.postMessage({sourceName:s,targetName:i,stream:tt.START_COMPLETE,streamId:e,reason:dt(l)})})}#f(t){const e=t.streamId,s=this.#a,i=t.sourceName,n=this.#i,r=this.#r.get(e),a=this.#l.get(e);switch(t.stream){case tt.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(dt(t.reason));break;case tt.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(dt(t.reason));break;case tt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Mi).then(()=>{n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,success:!0})},l=>{n.postMessage({sourceName:s,targetName:i,stream:tt.PULL_COMPLETE,streamId:e,reason:dt(l)})});break;case tt.ENQUEUE:if(J(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case tt.CLOSE:if(J(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#g(r,e);break;case tt.ERROR:J(r,"error should have stream controller"),r.controller.error(dt(t.reason)),this.#g(r,e);break;case tt.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(dt(t.reason)),this.#g(r,e);break;case tt.CANCEL:if(!a)break;const o=dt(t.reason);Promise.try(a.onCancel||Mi,o).then(()=>{n.postMessage({sourceName:s,targetName:i,stream:tt.CANCEL_COMPLETE,streamId:e,success:!0})},l=>{n.postMessage({sourceName:s,targetName:i,stream:tt.CANCEL_COMPLETE,streamId:e,reason:dt(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,this.#l.delete(e);break;default:throw new Error("Unexpected stream case")}}async#g(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),this.#r.delete(e)}destroy(){this.#n?.abort(),this.#n=null}}class on{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){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:$(`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(n=>{throw new Error(`Unable to load ${this.#t[t]} data at: ${i}`)})}async _fetch(t,e){$("Abstract method `_fetch` called.")}}class Di extends on{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await Xs(t,s);return i instanceof Uint8Array?i:as(i)}}class ln{#t=!1;constructor({enableHWA:t=!1}){this.#t=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:!this.#t})}}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){$("Abstract method `_createCanvas` called.")}}class Rr extends ln{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 hn{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,n){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class Lr extends hn{#t;#e;#s;#i;#n;#a;#r=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i=t,this.#n=e}get#o(){return this.#e||=new Map}get#l(){return this.#a||=new Map}get#h(){if(!this.#s){const t=this.#n.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#n.createElementNS(ht,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#n.createElementNS(ht,"defs"),t.append(s),s.append(this.#s),this.#n.body.append(t)}return this.#s}#u(t){const e=r=>r&&Array.from(r,a=>a/255).join(",");if(t.length===1){const r=e(t[0]);return[r,r,r]}const[s,i,n]=t;return[e(s),e(i),e(n)]}#d(t){if(this.#t===void 0){this.#t="";const e=this.#n.URL;e!==this.#n.baseURI&&(os(e)?B('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=Ji(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;const[s,i,n]=this.#u(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;const a=`g_${this.#i}_transfer_map_${this.#r++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);const l=this.#m(a);return this.#p(s,i,n,l),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=this.#l.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#l.set(i,n)),!t||!e))return n.url;const r=this.#y(t);t=C.makeHexColor(...r);const a=this.#y(e);if(e=C.makeHexColor(...a),this.#v(),t==="#000000"&&e==="#ffffff"||t===e)return n.url;const l=Array.from({length:256},(f,p)=>Bs(p/255)).join(","),h=`g_${this.#i}_hcm_filter`,c=n.filter=this.#m(h);this.#p(l,l,l,c),this.#g(c);const u=(f,p)=>{const g=r[f]/255,m=a[f]/255,b=new Array(p+1);for(let y=0;y<=p;y++)b[y]=g+y/p*(m-g);return b.join(",")};return this.#p(u(0,5),u(1,5),u(2,5),c),n.url=this.#d(h),n.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){const e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return e==="none"||!j.platform.isFirefox?null:{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;const[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;const n=`g_${this.#i}_alpha_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);const a=this.#m(n);return this.#b(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#u([t]),i=`luminosity_${s}`):i="luminosity",e=this.#o.get(i),e)return this.#o.set(t,e),e;const n=`g_${this.#i}_luminosity_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);const a=this.#m(n);return this.#f(a),t&&this.#b(s,a),r}addKnockoutFilter(t=0){const e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,i=this.#o.get(s);if(i)return i;const n=`g_${this.#i}_knockout_filter_${this.#r++}`,r=this.#d(n);this.#o.set(s,r);const a=this.#m(n),o=this.#n.createElementNS(ht,"feComponentTransfer");a.append(o);const l=this.#n.createElementNS(ht,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),r}addHighlightHCMFilter(t,e,s,i,n){const r=`${e}-${s}-${i}-${n}`;let a=this.#l.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#l.set(t,a)),!e||!s))return a.url;const[o,l]=[e,s].map(this.#y.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,f]=[i,n].map(this.#w.bind(this));c<h&&([h,c,u,f]=[c,h,f,u]),this.#v();const p=(b,y,A)=>{const S=new Array(256),v=(c-h)/A,w=b/255,_=(y-b)/(255*A);let x=0;for(let E=0;E<=A;E++){const P=Math.round(h+E*v),k=w+E*_;for(let H=x;H<=P;H++)S[H]=k;x=P+1}for(let E=x;E<256;E++)S[E]=S[x-1];return S.join(",")},g=`g_${this.#i}_hcm_${t}_filter`,m=a.filter=this.#m(g);return this.#g(m),this.#p(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),m),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#a?.size||(this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#a?.clear(),this.#a=null,this.#r=0)}#f(t){const e=this.#n.createElementNS(ht,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#g(t){const e=this.#n.createElementNS(ht,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#m(t){const e=this.#n.createElementNS(ht,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#c(t,e,s){if(!s)return;const i=this.#n.createElementNS(ht,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#p(t,e,s,i){const n=this.#n.createElementNS(ht,"feComponentTransfer");i.append(n),this.#c(n,"feFuncR",t),this.#c(n,"feFuncG",e),this.#c(n,"feFuncB",s)}#b(t,e){const s=this.#n.createElementNS(ht,"feComponentTransfer");e.append(s),this.#c(s,"feFuncA",t)}#y(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Ie(getComputedStyle(this.#h).getPropertyValue("background-color"))}#A(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,me(getComputedStyle(this.#h).getPropertyValue("background-color"))}#v(){this.#h.style.color="",this.#h.style.backgroundColor=""}#w(t){const[e,s,i,n]=this.#A(t);if(n===1)return[e,s,i];const[r,a,o]=this.#y("Canvas");return[xs(e,r,n),xs(s,a,n),xs(i,o,n)]}}function xs(d,t,e){return Math.round(e*d+(1-e)*t)}mt&&B("Please use the `legacy` build in Node.js environments.");async function Nr(d){const e=await process.getBuiltinModule("fs/promises").readFile(d);return new Uint8Array(e)}class Br extends hn{}class Hr extends ln{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Ur extends on{async _fetch(t,e){return Nr(t)}}function cn({src:d,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=j.isLittleEndian?4278190080:255,[o,l]=r?[n,a]:[a,n],h=s>>3,c=s&7,u=o^l,f=d.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;++g){for(const b=t+h;t<b;++t,p+=8){const y=d[t];e[p]=o^-(y>>7&1)&u,e[p+1]=o^-(y>>6&1)&u,e[p+2]=o^-(y>>5&1)&u,e[p+3]=o^-(y>>4&1)&u,e[p+4]=o^-(y>>3&1)&u,e[p+5]=o^-(y>>2&1)&u,e[p+6]=o^-(y>>1&1)&u,e[p+7]=o^-(y&1)&u}if(c===0)continue;const m=t<f?d[t++]:255;for(let b=0;b<c;++b,++p)e[p]=o^-(m>>7-b&1)&u}return{srcPos:t,destPos:p}}function Gr({src:d,srcPos:t=0,dest:e,destPos:s=0,width:i,height:n}){let r=0;const a=i*n*3,o=a>>2,l=new Uint32Array(d.buffer,t,o),h=j.isLittleEndian?4278190080:255;if(j.isLittleEndian){for(;r<o-2;r+=3,s+=4){const c=l[r],u=l[r+1],f=l[r+2];e[s]=c|h,e[s+1]=c>>>24|u<<8|h,e[s+2]=u>>>16|f<<16|h,e[s+3]=f>>>8|h}for(let c=t+r*4,u=t+a;c<u;c+=3)e[s++]=d[c]|d[c+1]<<8|d[c+2]<<16|h}else{for(;r<o-2;r+=3,s+=4){const c=l[r],u=l[r+1],f=l[r+2];e[s]=c|h,e[s+1]=c<<24|u>>>8|h,e[s+2]=u<<16|f>>>16|h,e[s+3]=f<<8|h}for(let c=t+r*4,u=t+a;c<u;c+=3)e[s++]=d[c]<<24|d[c+1]<<16|d[c+2]<<8|h}return{srcPos:t+a,destPos:s}}const $r=`
|
|
3
3
|
struct Uniforms {
|
|
4
4
|
offsetX : f32,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as se,x as Ee,u as ne,w as Y,c as i,l as k,p as a,k as t,z as ve,O as pe,P as he,q as v,t as l,g as e,m as x,Q as ke,R as me,S as re,e as O,f as r,h as R,E as Z,T as ye,I as ge,J as Re,s as y,v as Q,_ as Oe,i as H,y as J,C as ze,D as ce,F as K,j as ie,U as xe,H as ae,W as qe,X as be,G as je,Y as He,M as Ge,L as Le,N as Ke,n as Ne,Z as Ce,$ as Je,a0 as ue,a1 as Qe,a2 as Pe,a3 as Ie,a4 as Xe,V as Ye,o as Ze}from"./index-9DLDvF8M.js";import{V as Ae}from"./VSelect-CHI_FOMl.js";import{_ as Ue}from"./CodeViewer.vue_vue_type_script_setup_true_lang-BtA5aWrS.js";import{W as et,a as tt}from"./WorkspaceMediaPreview-qjt04eze.js";import{M as at}from"./MarkdownContent-BuDRrZ6c.js";import{V as We}from"./VSheet-CKEhsY-7.js";import{V as Se}from"./VSpacer-FbdDPUGx.js";import{V as Be}from"./VTextarea-D_kPhUVU.js";import{V as lt,a as $e,b as ot,c as _e}from"./VTabs-BSfSKBtT.js";import"./syntax-highlight-C_fuMcwC.js";const it={key:1,class:"workspace-create-location"},st={key:2,class:"workspace-create-location"},nt=se({__name:"WorkspaceCreateDialog",props:Re({roots:{},busy:{type:Boolean},error:{}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:Re(["create"],["update:modelValue"]),setup(B,{emit:I}){const o=B,g=I,s=Ee(B,"modelValue"),_=y(""),w=y(""),S=ne();Y(()=>[s.value,o.roots],()=>{s.value&&(o.roots.includes(w.value)||(w.value=o.roots[0]??""))},{immediate:!0,deep:!0}),Y(s,f=>{f&&(_.value="")});const c=Q(()=>{const f=w.value.replace(/[\\/]+$/,""),n=f.includes("\\")&&!f.includes("/")?"\\":"/";return _.value.trim()?`${f}${n}${_.value.trim()}`:f});function b(){!w.value||!_.value.trim()||g("create",w.value,_.value.trim())}return(f,n)=>(i(),k(ge,{modelValue:s.value,"onUpdate:modelValue":n[4]||(n[4]=u=>s.value=u),width:"auto"},{default:a(()=>[t(ve,null,{default:a(()=>[t(pe,{"prepend-icon":"$mdiFolderOutline"},{append:a(()=>[t(x,{icon:"$mdiClose",variant:"text",size:"small","aria-label":e(S).t("$vuetify.chatroom.common.close"),onClick:n[0]||(n[0]=u=>s.value=!1)},null,8,["aria-label"])]),default:a(()=>[t(he,null,{default:a(()=>[v(l(e(S).t("$vuetify.chatroom.workspaces.createTitle")),1)]),_:1})]),_:1}),t(ke,{class:"workspace-create-form"},{default:a(()=>[t(me,{modelValue:_.value,"onUpdate:modelValue":n[1]||(n[1]=u=>_.value=u),label:e(S).t("$vuetify.chatroom.workspaces.projectName"),autofocus:"","hide-details":"auto",onKeyup:re(b,["enter"])},null,8,["modelValue","label"]),B.roots.length>1?(i(),k(Ae,{key:0,modelValue:w.value,"onUpdate:modelValue":n[2]||(n[2]=u=>w.value=u),items:B.roots,label:e(S).t("$vuetify.chatroom.workspaces.createLocation"),"hide-details":"auto"},null,8,["modelValue","items","label"])):w.value?(i(),O("div",it,[r("span",null,l(e(S).t("$vuetify.chatroom.workspaces.createLocation")),1),r("code",null,l(w.value),1)])):R("",!0),w.value?(i(),O("div",st,[r("span",null,l(e(S).t("$vuetify.chatroom.workspaces.projectPath")),1),r("code",null,l(c.value),1)])):R("",!0),B.error?(i(),k(Z,{key:3,type:"error",variant:"tonal",density:"compact"},{default:a(()=>[v(l(B.error),1)]),_:1})):R("",!0)]),_:1}),t(ye,{class:"justify-end"},{default:a(()=>[t(x,{variant:"text",onClick:n[3]||(n[3]=u=>s.value=!1)},{default:a(()=>[v(l(e(S).t("$vuetify.chatroom.workspaces.cancel")),1)]),_:1}),t(x,{color:"primary",variant:"flat",loading:B.busy,disabled:!w.value||!_.value.trim(),onClick:b},{default:a(()=>[v(l(e(S).t("$vuetify.chatroom.workspaces.create")),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),rt=Oe(nt,[["__scopeId","data-v-f24d3eec"]]),ut={class:"workspace-register-form"},ct={class:"text-subtitle-2"},dt={class:"text-body-2 text-medium-emphasis"},vt={class:"d-flex justify-end"},mt={class:"workspace-manage-list-heading"},ft={class:"text-subtitle-2"},pt={key:3,class:"workspace-manage-list"},ht={class:"workspace-manage-item-main"},kt={key:1,class:"workspace-manage-item-title"},yt={class:"workspace-manage-item-path"},gt={class:"workspace-manage-item-tags"},wt={class:"workspace-manage-item-actions"},$t=se({__name:"WorkspaceManageDialog",props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:Re(["updated"],["update:modelValue"]),setup(B,{emit:I}){const o=Ee(B,"modelValue"),g=I,s=ne(),_=y([]),w=y(""),S=y(""),c=y(null),b=y(""),f=y(!1),n=y(!1),u=y(""),V=y("");Y(o,p=>{p&&(w.value="",S.value="",c.value=null,u.value="",V.value="",P())});async function P(){f.value=!0,u.value="";try{_.value=await H("/workspaces/manage")}catch(p){u.value=J(p)}finally{f.value=!1}}async function m(){if(!(!w.value.trim()||n.value)){n.value=!0,u.value="",V.value="";try{await H("/workspaces/register",{method:"POST",body:JSON.stringify({path:w.value.trim(),name:S.value.trim()||null})}),w.value="",S.value="",V.value=s.t("$vuetify.chatroom.workspaces.registered"),g("updated"),await P()}catch(p){u.value=J(p)}finally{n.value=!1}}}function W(p){c.value=p.id,b.value=p.name,u.value="",V.value=""}function z(){c.value=null,b.value=""}async function $(p){const T=b.value.trim();if(!(!T||n.value)){n.value=!0,u.value="";try{await H("/workspaces/"+encodeURIComponent(p.id),{method:"PATCH",body:JSON.stringify({name:T})}),z(),g("updated"),await P()}catch(d){u.value=J(d)}finally{n.value=!1}}}async function D(p){if(!n.value&&window.confirm(s.t("$vuetify.chatroom.workspaces.removeConfirm"))){n.value=!0,u.value="";try{await H("/workspaces/"+encodeURIComponent(p.id),{method:"DELETE"}),g("updated"),await P()}catch(T){u.value=J(T)}finally{n.value=!1}}}async function M(p){if(!n.value&&window.confirm(s.t("$vuetify.chatroom.workspaces.cleanupConfirm"))){n.value=!0,u.value="",V.value="";try{await H("/workspaces/"+encodeURIComponent(p.id)+"/cleanup",{method:"DELETE"}),g("updated"),await P()}catch(T){u.value=J(T)}finally{n.value=!1}}}async function F(p){if(!n.value){n.value=!0,u.value="";try{await H("/workspaces/"+encodeURIComponent(p.id)+"/restore",{method:"POST",body:JSON.stringify({})}),g("updated"),await P()}catch(T){u.value=J(T)}finally{n.value=!1}}}function L(p){return p==="available"?s.t("$vuetify.chatroom.workspaces.available"):p==="restore_pending"?s.t("$vuetify.chatroom.workspaces.restorePending"):p==="unregistered"?s.t("$vuetify.chatroom.workspaces.unregistered"):s.t("$vuetify.chatroom.workspaces.missing")}function j(p){return s.t("$vuetify.chatroom.workspaces."+p.source)}return(p,T)=>(i(),k(ge,{modelValue:o.value,"onUpdate:modelValue":T[5]||(T[5]=d=>o.value=d),width:"min(760px, 96vw)",scrollable:""},{default:a(()=>[t(ve,{class:"workspace-manage-dialog"},{default:a(()=>[t(pe,{"prepend-icon":"$mdiFolderCogOutline"},{append:a(()=>[t(x,{icon:"$mdiClose",variant:"text",size:"small","aria-label":e(s).t("$vuetify.chatroom.common.close"),onClick:T[0]||(T[0]=d=>o.value=!1)},null,8,["aria-label"])]),default:a(()=>[t(he,null,{default:a(()=>[v(l(e(s).t("$vuetify.chatroom.workspaces.manage")),1)]),_:1})]),_:1}),t(ke,{class:"workspace-manage-content"},{default:a(()=>[r("section",ut,[r("div",ct,l(e(s).t("$vuetify.chatroom.workspaces.addExisting")),1),r("div",dt,l(e(s).t("$vuetify.chatroom.workspaces.pathHelp")),1),t(me,{modelValue:w.value,"onUpdate:modelValue":T[1]||(T[1]=d=>w.value=d),label:e(s).t("$vuetify.chatroom.workspaces.projectPathInput"),placeholder:"/mnt/data/my-project","hide-details":"auto",density:"comfortable",onKeyup:re(m,["enter"])},null,8,["modelValue","label"]),t(me,{modelValue:S.value,"onUpdate:modelValue":T[2]||(T[2]=d=>S.value=d),label:e(s).t("$vuetify.chatroom.workspaces.displayNameOptional"),"hide-details":"auto",density:"comfortable",onKeyup:re(m,["enter"])},null,8,["modelValue","label"]),r("div",vt,[t(x,{color:"primary",variant:"flat","prepend-icon":"$mdiPlus",loading:n.value,disabled:!w.value.trim(),onClick:m},{default:a(()=>[v(l(e(s).t("$vuetify.chatroom.workspaces.register")),1)]),_:1},8,["loading","disabled"])])]),t(ze),r("div",mt,[r("span",ft,l(e(s).t("$vuetify.chatroom.workspaces.workspace")),1),t(x,{icon:"$mdiRefresh",variant:"text",size:"small",loading:f.value,"aria-label":e(s).t("$vuetify.chatroom.workspaces.refresh"),onClick:P},null,8,["loading","aria-label"])]),f.value?(i(),k(ce,{key:0,indeterminate:""})):R("",!0),u.value?(i(),k(Z,{key:1,type:"error",variant:"tonal",density:"compact"},{default:a(()=>[v(l(u.value),1)]),_:1})):V.value?(i(),k(Z,{key:2,type:"success",variant:"tonal",density:"compact"},{default:a(()=>[v(l(V.value),1)]),_:1})):R("",!0),_.value.length?(i(),O("div",pt,[(i(!0),O(K,null,ie(_.value,d=>(i(),O("div",{key:d.id,class:"workspace-manage-item"},[r("div",ht,[c.value===d.id?(i(),k(me,{key:0,modelValue:b.value,"onUpdate:modelValue":T[3]||(T[3]=A=>b.value=A),autofocus:"",density:"compact","hide-details":"",disabled:n.value,onKeyup:[re(A=>$(d),["enter"]),re(z,["esc"])]},null,8,["modelValue","disabled","onKeyup"])):(i(),O("div",kt,l(d.name),1)),r("div",yt,l(d.path),1),r("div",gt,[t(xe,{size:"x-small",variant:"tonal",color:d.status==="available"?"success":"warning"},{default:a(()=>[v(l(L(d.status)),1)]),_:2},1032,["color"]),t(xe,{size:"x-small",variant:"tonal"},{default:a(()=>[v(l(j(d)),1)]),_:2},1024)])]),r("div",wt,[c.value===d.id?(i(),O(K,{key:0},[t(x,{icon:"$mdiCheck",size:"small",variant:"text",loading:n.value,"aria-label":e(s).t("$vuetify.chatroom.workspaces.save"),onClick:A=>$(d)},null,8,["loading","aria-label","onClick"]),t(x,{icon:"$mdiClose",size:"small",variant:"text",disabled:n.value,"aria-label":e(s).t("$vuetify.chatroom.workspaces.cancel"),onClick:z},null,8,["disabled","aria-label"])],64)):(i(),O(K,{key:1},[t(x,{icon:"$mdiPencil",size:"small",variant:"text",disabled:n.value,"aria-label":e(s).t("$vuetify.chatroom.workspaces.rename"),onClick:A=>W(d)},null,8,["disabled","aria-label","onClick"]),d.status==="restore_pending"?(i(),k(x,{key:0,icon:"$mdiFolderSync",size:"small",variant:"text",loading:n.value,"aria-label":e(s).t("$vuetify.chatroom.workspaces.restore"),onClick:A=>F(d)},null,8,["loading","aria-label","onClick"])):R("",!0),d.status!=="available"?(i(),k(x,{key:1,icon:"$mdiDeleteForeverOutline",size:"small",variant:"text",color:"error",disabled:n.value,"aria-label":e(s).t("$vuetify.chatroom.workspaces.cleanup"),onClick:A=>M(d)},null,8,["disabled","aria-label","onClick"])):R("",!0),d.manuallyRegistered&&!d.discovered?(i(),k(x,{key:2,icon:"$mdiFolderRemoveOutline",size:"small",variant:"text",color:"error",disabled:n.value,"aria-label":e(s).t("$vuetify.chatroom.workspaces.remove"),onClick:A=>D(d)},null,8,["disabled","aria-label","onClick"])):R("",!0)],64))])]))),128))])):f.value?R("",!0):(i(),k(ae,{key:4,icon:"$mdiFolderOutline",title:e(s).t("$vuetify.chatroom.workspaces.empty")},null,8,["title"]))]),_:1}),t(ye,{class:"justify-end"},{default:a(()=>[t(x,{variant:"text",onClick:T[4]||(T[4]=d=>o.value=!1)},{default:a(()=>[v(l(e(s).t("$vuetify.chatroom.common.close")),1)]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),_t=Oe($t,[["__scopeId","data-v-55f78db7"]]),bt={class:"workspace-files-pane"},Ct={class:"workspace-files-layout"},xt={class:"workspace-file-browser"},Vt={class:"workspace-file-breadcrumbs"},Pt={class:"workspace-breadcrumb-items"},It={key:0,class:"workspace-breadcrumb-separator"},St=["onClick"],Rt={key:0,class:"workspace-file-load-more"},Ot=["aria-busy"],zt={key:0,class:"workspace-preview-toolbar"},Tt=["title"],Lt={class:"workspace-preview-content"},Ut={class:"workspace-markdown-header"},Wt={key:0,class:"workspace-markdown-body"},Bt={key:1,class:"workspace-markdown-source"},Dt={class:"workspace-image-stage"},Mt=["src","alt"],Ft=se({__name:"WorkspaceFilesPane",props:{workspaceId:{}},setup(B){const I=B,o=ne(),g=y("preview"),s=y(!1),_=y(!1),w=qe(()=>I.workspaceId),{entries:S,file:c,selectedPath:b,previewLoading:f,breadcrumbs:n,parentPath:u,nextOffset:V,loading:P,loadingMore:m,error:W,loadDirectory:z,loadMore:$,navigate:D,openEntry:M}=w;Y(()=>c.value?.path??null,()=>{g.value="preview"}),Y(()=>c.value?.kind==="image"?c.value.url:null,p=>{s.value=!!p,_.value=!1});const F=Q(()=>S.value.find(p=>p.path===b.value&&p.type==="file"));function L(){if(!F.value)return;const p=F.value.path;Ge(Ke(I.workspaceId,p),Le(p)).catch(()=>{})}function j(p){return p==="file"?o.t("$vuetify.chatroom.files.file"):p==="directory"?o.t("$vuetify.chatroom.files.directory"):p==="symlink"?o.t("$vuetify.chatroom.files.symlink"):p}return(p,T)=>(i(),O("div",bt,[e(W)?(i(),k(Z,{key:0,type:"error",variant:"tonal",density:"compact"},{default:a(()=>[v(l(e(W)),1)]),_:1})):R("",!0),r("div",Ct,[r("div",xt,[r("div",Vt,[t(x,{icon:"$mdiArrowUp",size:"x-small",variant:"text",disabled:e(u)===null,"aria-label":e(o).t("$vuetify.chatroom.files.parentDirectory"),onClick:T[0]||(T[0]=d=>e(u)&&e(D)(e(u)))},null,8,["disabled","aria-label"]),r("div",Pt,[(i(!0),O(K,null,ie(e(n),(d,A)=>(i(),O(K,{key:d.path},[A?(i(),O("span",It,"/")):R("",!0),r("button",{type:"button",class:Ne(["workspace-breadcrumb",{active:A===e(n).length-1}]),onClick:we=>e(D)(d.path)},l(d.title),11,St)],64))),128))]),t(x,{icon:"$mdiRefresh",size:"x-small",variant:"text",loading:e(P),"aria-label":e(o).t("$vuetify.chatroom.files.refresh"),onClick:T[1]||(T[1]=d=>e(z)())},null,8,["loading","aria-label"])]),t(be,{density:"compact",border:"",rounded:"lg",class:"workspace-file-list"},{default:a(()=>[(i(!0),O(K,null,ie(e(S),d=>(i(),k(Ce,{key:d.path,active:e(b)===d.path,title:e(Le)(d.path),subtitle:d.type==="file"?`${j(d.type)} · ${e(Je)(d.size)}`:j(d.type),"prepend-icon":d.type==="directory"?"$mdiFolderOutline":d.type==="symlink"?"$mdiLinkVariant":"$mdiFileOutline","append-icon":d.type==="directory"?"$mdiChevronRight":void 0,onClick:A=>e(M)(d)},null,8,["active","title","subtitle","prepend-icon","append-icon","onClick"]))),128))]),_:1}),e(V)!==null?(i(),O("div",Rt,[t(x,{size:"small",variant:"text",loading:e(m),disabled:e(P),onClick:e($)},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.files.loadMore")),1)]),_:1},8,["loading","disabled","onClick"])])):R("",!0)]),r("div",{class:"workspace-file-preview","aria-busy":e(f)||s.value},[F.value?(i(),O("div",zt,[r("span",{class:"workspace-preview-filename mono",title:F.value.path},l(F.value.path),9,Tt),t(x,{size:"small",variant:"tonal","prepend-icon":"$mdiDownloadOutline",onClick:L},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.files.download")),1)]),_:1})])):R("",!0),r("div",Lt,[e(f)?(i(),k(ce,{key:0,indeterminate:""})):R("",!0),e(c)?.kind==="text"&&e(c).truncated?(i(),k(Z,{key:1,type:"warning",variant:"tonal",density:"compact",class:"workspace-preview-truncated"},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.files.previewTruncated")),1)]),_:1})):R("",!0),e(c)&&(e(c).kind==="pdf"||e(c).kind==="video"||e(c).kind==="audio")?(i(),k(et,{key:e(c).url,kind:e(c).kind,path:e(c).path,url:e(c).url},null,8,["kind","path","url"])):e(c)?.kind==="text"&&/\.(csv|tsv)$/i.test(e(c).path)?(i(),k(tt,{key:3,content:e(c).content,path:e(c).path,truncated:e(c).truncated},null,8,["content","path","truncated"])):e(c)?.kind==="text"&&e(je)(e(c).path)?(i(),k(We,{key:4,border:"",rounded:"lg",class:"workspace-markdown-preview"},{default:a(()=>[r("div",Ut,[t(He,{modelValue:g.value,"onUpdate:modelValue":T[2]||(T[2]=d=>g.value=d),mandatory:"",density:"compact",variant:"text",divided:"",class:"workspace-markdown-mode"},{default:a(()=>[t(x,{value:"preview",size:"small"},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.files.preview")),1)]),_:1}),t(x,{value:"source",size:"small"},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.files.source")),1)]),_:1})]),_:1},8,["modelValue"])]),t(ze),g.value==="preview"?(i(),O("div",Wt,[t(at,{text:e(c).content},null,8,["text"])])):(i(),O("div",Bt,[t(Ue,{text:e(c).content,filename:e(c).path,toolbar:!1},null,8,["text","filename"])]))]),_:1})):e(c)?.kind==="text"?(i(),k(Ue,{key:5,text:e(c).content,filename:e(c).path,"show-download":!1},null,8,["text","filename"])):e(c)?.kind==="image"?(i(),k(We,{key:6,border:"",rounded:"lg",class:"workspace-image-preview"},{default:a(()=>[r("div",Dt,[s.value?(i(),k(ce,{key:0,indeterminate:""})):R("",!0),_.value?(i(),k(ae,{key:1,icon:"$mdiAlertCircleOutline",title:e(o).t("$vuetify.chatroom.common.imageLoadFailed")},null,8,["title"])):(i(),O("img",{key:e(c).url,src:e(c).url,alt:e(c).path,decoding:"async",onLoad:T[3]||(T[3]=d=>s.value=!1),onError:T[4]||(T[4]=d=>{s.value=!1,_.value=!0})},null,40,Mt))])]),_:1})):e(c)?.kind==="unsupported"?(i(),k(ae,{key:7,icon:"$mdiFileQuestionOutline",title:e(o).t("$vuetify.chatroom.files.previewUnavailable"),text:e(c).path},null,8,["title","text"])):e(f)?R("",!0):(i(),k(ae,{key:8,icon:"$mdiFileEyeOutline",title:e(o).t("$vuetify.chatroom.files.select"),text:e(o).t("$vuetify.chatroom.files.readOnly")},null,8,["title","text"]))])],8,Ot)])]))}});function Et(B){const I=y(null),o=y([]),g=y([]),s=y(null),_=y(null),w=y(!1),S=y(!1),c=y(null),b=y("");let f=0;const n=ue(),u=ue(),V=ue();let P=!1;Qe(()=>{P=!0,f+=1,n.invalidate(),u.invalidate(),V.invalidate()});const m=()=>typeof B=="function"?B():String(B.value??""),W=Q(()=>I.value?.changes??[]),z=Q(()=>W.value.find(h=>h.path===s.value)??null),$=Q(()=>W.value.filter(De).map(h=>h.path)),D=Q(()=>W.value.filter(Me).map(h=>h.path));Y(B,()=>{f+=1,n.invalidate(),u.invalidate(),V.invalidate(),c.value=null,I.value=null,o.value=[],g.value=[],s.value=null,_.value=null,M()},{immediate:!0});async function M(){if(P||c.value)return;const h=++f,q=n.begin(),N=m();w.value=!0,b.value="";try{const G=await H(`/git/status?workspaceId=${encodeURIComponent(N)}`,{signal:q.signal});if(h!==f||!n.isCurrent(q)||m()!==N)return;if(I.value=G,!G){o.value=[],g.value=[],s.value=null,_.value=null;return}if(await F(h,N,q.signal),h!==f||!n.isCurrent(q)||m()!==N)return;X(),await j()}catch(G){h===f&&n.isCurrent(q)&&m()===N&&(b.value=J(G))}finally{h===f&&n.isCurrent(q)&&m()===N&&(w.value=!1)}}async function F(h,q,N){const G=encodeURIComponent(q),de=N?{signal:N}:{},[ee,E]=await Promise.all([H(`/git/branches?workspaceId=${G}`,de),H(`/git/log?workspaceId=${G}&limit=20`,de)]);h!==f||m()!==q||(o.value=ee,g.value=E)}function L(h){s.value!==h&&(s.value=h,_.value=null,j())}async function j(){const h=s.value,q=m();if(!h||!I.value?.head){u.invalidate(),S.value=!1,_.value=null;return}const N=u.begin();S.value=!0;try{const G=await H(`/git/diff?workspaceId=${encodeURIComponent(q)}&path=${encodeURIComponent(h)}`,{signal:N.signal});u.isCurrent(N)&&m()===q&&s.value===h&&(_.value=G)}catch(G){u.isCurrent(N)&&m()===q&&(_.value=null,b.value=J(G))}finally{u.isCurrent(N)&&m()===q&&(S.value=!1)}}async function p(h,q,N,G,de=6e4){if(P||c.value)return!1;const ee=m(),E=++f,U=V.begin();n.invalidate(),u.invalidate(),w.value=!1,S.value=!1,c.value=h,b.value="";try{const C=await H(q,{method:N,body:JSON.stringify({workspaceId:ee,...G}),timeoutMs:de,signal:U.signal});return P||E!==f||!V.isCurrent(U)||m()!==ee||(I.value=C,X(),await F(E,ee,U.signal),P||E!==f||!V.isCurrent(U)||m()!==ee)?!1:(await j(),!0)}catch(C){return!P&&E===f&&V.isCurrent(U)&&m()===ee&&(b.value=J(C)),!1}finally{!P&&E===f&&V.isCurrent(U)&&m()===ee&&(c.value=null)}}async function T(h){return h.length?p("stage","/git/stage","POST",{paths:h}):!1}async function d(h){return h.length?p("unstage","/git/unstage","POST",{paths:h}):!1}function A(h){return p("restore","/git/restore","POST",{path:h})}function we(h){return p("commit","/git/commit","POST",{message:h})}function Ve(h){return p("branch","/git/branches","POST",{name:h})}function le(h){return p("branch","/git/switch","POST",{name:h})}function te(h){return p("branch","/git/branches","DELETE",{name:h})}function oe(h){return p(h,`/git/${h}`,"POST",{},5*6e4)}function X(){W.value.some(h=>h.path===s.value)||(s.value=W.value[0]?.path??null)}return{status:I,branches:o,commits:g,selectedPath:s,selectPath:L,diff:_,loading:w,diffLoading:S,busy:c,error:b,changes:W,selectedChange:z,stagedPaths:$,unstagedPaths:D,load:M,stage:T,unstage:d,restore:A,commit:we,createBranch:Ve,switchBranch:le,deleteBranch:te,remote:oe,isStaged:De,isUnstaged:Me,statusCode:Nt}}function De(B){return B.indexStatus!==" "&&B.indexStatus!=="?"}function Me(B){return B.indexStatus==="?"||B.workingTreeStatus!==" "&&B.workingTreeStatus!=="?"}function Nt(B){return`${B.indexStatus}${B.workingTreeStatus}`.replaceAll(" ","·")}const At={class:"git-diff-viewer"},qt={class:"git-diff-content"},jt={class:"git-diff-line-number"},Ht={class:"git-diff-line-number"},Gt={class:"git-diff-line"},Kt={key:0,class:"git-diff-expand"},Jt={key:1},Fe=500,Qt=500,fe=2500,Xt=se({__name:"GitDiffViewer",props:{text:{}},setup(B){const I=B,o=ne(),g=y(Fe);Y(()=>I.text,()=>{g.value=Fe});const s=Q(()=>n(I.text)),_=Q(()=>f(I.text,Math.min(g.value,fe))),w=Q(()=>Math.max(0,s.value-_.value.length)),S=Q(()=>_.value.length<Math.min(s.value,fe)),c=Q(()=>s.value>fe&&_.value.length>=fe);function b(){g.value=Math.min(fe,g.value+Qt)}function f(V,P){const m=[],W=new Map;let z=0,$=0,D=!1,M="header";const F=(L,j,p,T)=>{const d=M+":"+j+":"+(p??"-")+":"+(T??"-")+":"+u(L),A=W.get(d)??0;W.set(d,A+1),m.push({key:d+":"+A,text:L,kind:j,oldLine:p,newLine:T})};for(const L of V.split(`
|
|
2
|
+
`,P)){const j=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(L);if(j){z=Number(j[1]),$=Number(j[2]),D=!0,M=L,F(L,"hunk",null,null);continue}if(!D||L.startsWith("diff --git ")||L.startsWith("index ")||L.startsWith("--- ")||L.startsWith("+++ ")||L.startsWith("new file mode ")||L.startsWith("deleted file mode ")||L.startsWith("Binary files ")||L.startsWith("GIT binary patch")||L.startsWith("\\ No newline")){L.startsWith("diff --git ")&&(M=L),F(L,"meta",null,null);continue}L.startsWith("+")?(F(L,"add",null,$),$+=1):L.startsWith("-")?(F(L,"delete",z,null),z+=1):(F(L,"context",z,$),z+=1,$+=1)}return m}function n(V){if(!V)return 1;let P=1;for(let m=0;m<V.length;m+=1)V.charCodeAt(m)===10&&(P+=1);return P}function u(V){let P=2166136261;for(let m=0;m<V.length;m+=1)P^=V.charCodeAt(m),P=Math.imul(P,16777619);return(P>>>0).toString(36)}return(V,P)=>(i(),O("div",At,[r("div",qt,[(i(!0),O(K,null,ie(_.value,m=>(i(),O("div",{key:m.key,class:Ne(["git-diff-row",`git-diff-row-${m.kind}`])},[r("span",jt,l(m.oldLine??""),1),r("span",Ht,l(m.newLine??""),1),r("code",Gt,l(m.text),1)],2))),128))]),w.value?(i(),O("div",Kt,[r("span",null,l(e(o).t("$vuetify.chatroom.git.diffRowsHidden",String(w.value))),1),S.value?(i(),k(x,{key:0,size:"small",variant:"text",onClick:b},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.showMoreDiff")),1)]),_:1})):c.value?(i(),O("span",Jt,l(e(o).t("$vuetify.chatroom.git.diffRenderLimit")),1)):R("",!0)])):R("",!0)]))}}),Yt={class:"workspace-git-pane"},Zt={class:"git-toolbar"},ea={class:"git-facts"},ta={class:"mono"},aa={class:"mono"},la={class:"mono"},oa={key:0},ia={class:"git-toolbar-actions"},sa={class:"git-section-header"},na={class:"git-section-actions"},ra={key:0,class:"git-workbench"},ua={class:"git-change-code mono"},ca={class:"git-diff-pane"},da={class:"git-file-toolbar"},va={class:"mono git-selected-path"},ma={class:"git-file-actions"},fa={class:"git-commit-bar"},pa={class:"git-history"},ha={class:"git-section-header"},ka={class:"git-commit-hash mono"},ya={class:"git-new-branch"},ga={class:"mono mt-2 text-break"},wa={class:"mono mt-2 text-break"},$a=se({__name:"WorkspaceGitPane",props:{workspaceId:{}},setup(B){const I=B,o=ne(),g=Et(()=>I.workspaceId),{status:s,branches:_,commits:w,selectedPath:S,selectPath:c,diff:b,loading:f,diffLoading:n,busy:u,error:V,changes:P,selectedChange:m,stagedPaths:W,unstagedPaths:z,load:$,stage:D,unstage:M,restore:F,commit:L,createBranch:j,switchBranch:p,deleteBranch:T,remote:d,isStaged:A,isUnstaged:we,statusCode:Ve}=g,le=y(""),te=y(!1),oe=y(""),X=y(null),h=y(null);Y(()=>I.workspaceId,()=>{le.value="",te.value=!1,oe.value="",X.value=null,h.value=null});async function q(){const E=X.value;E&&await F(E.path)&&(X.value=null)}async function N(){const E=le.value.trim();E&&await L(E)&&(le.value="")}async function G(){const E=oe.value.trim();E&&await j(E)&&(oe.value="",te.value=!1)}async function de(E){E.current||await p(E.name)&&(te.value=!1)}async function ee(){const E=h.value;E&&await T(E.name)&&(h.value=null)}return(E,U)=>(i(),O("div",Yt,[e(f)?(i(),k(ce,{key:0,indeterminate:""})):R("",!0),e(V)?(i(),k(Z,{key:1,type:"error",variant:"tonal",density:"compact"},{default:a(()=>[v(l(e(V)),1)]),_:1})):R("",!0),!e(f)&&!e(s)?(i(),k(ae,{key:2,icon:"$mdiSourceBranch",title:e(o).t("$vuetify.chatroom.git.notRepository")},null,8,["title"])):e(s)?(i(),O(K,{key:3},[r("div",Zt,[r("div",ea,[r("div",null,[r("span",null,l(e(o).t("$vuetify.chatroom.git.branch")),1),r("strong",ta,l(e(s).branch??"—"),1)]),r("div",null,[r("span",null,l(e(o).t("$vuetify.chatroom.git.head")),1),r("strong",aa,l(e(s).head?.slice(0,12)??"—"),1)]),r("div",null,[r("span",null,l(e(o).t("$vuetify.chatroom.git.upstream")),1),r("strong",la,l(e(s).upstream??"—"),1)]),e(s).upstream?(i(),O("div",oa,[r("span",null,l(e(o).t("$vuetify.chatroom.git.sync")),1),r("strong",null,"↑ "+l(e(s).ahead)+" · ↓ "+l(e(s).behind),1)])):R("",!0)]),r("div",ia,[t(x,{icon:"$mdiRefresh",size:"small",variant:"text",loading:e(f),disabled:e(u)!==null,"aria-label":e(o).t("$vuetify.chatroom.git.refresh"),onClick:e($)},null,8,["loading","disabled","aria-label","onClick"]),t(x,{"prepend-icon":"$mdiSourceBranch",size:"small",variant:"tonal",onClick:U[0]||(U[0]=C=>te.value=!0)},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.branches")),1)]),_:1}),t(x,{size:"small",variant:"text",loading:e(u)==="fetch",onClick:U[1]||(U[1]=C=>e(d)("fetch"))},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.fetch")),1)]),_:1},8,["loading"]),t(x,{size:"small",variant:"text",disabled:!e(s).upstream,loading:e(u)==="pull",onClick:U[2]||(U[2]=C=>e(d)("pull"))},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.pull")),1)]),_:1},8,["disabled","loading"]),t(x,{size:"small",variant:"text",loading:e(u)==="push",onClick:U[3]||(U[3]=C=>e(d)("push"))},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.push")),1)]),_:1},8,["loading"])])]),r("div",sa,[r("div",null,[r("strong",null,l(e(o).t("$vuetify.chatroom.git.changes")),1),r("span",null,l(e(P).length),1)]),r("div",na,[t(x,{size:"small",variant:"text",disabled:!e(z).length,loading:e(u)==="stage",onClick:U[4]||(U[4]=C=>e(D)(e(z)))},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.stageAll")),1)]),_:1},8,["disabled","loading"]),t(x,{size:"small",variant:"text",disabled:!e(W).length,loading:e(u)==="unstage",onClick:U[5]||(U[5]=C=>e(M)(e(W)))},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.unstageAll")),1)]),_:1},8,["disabled","loading"])])]),e(P).length?(i(),O("div",ra,[t(be,{density:"compact",class:"git-change-list"},{default:a(()=>[(i(!0),O(K,null,ie(e(P),C=>(i(),k(Ce,{key:C.path,active:e(S)===C.path,onClick:Te=>e(c)(C.path)},{prepend:a(()=>[r("span",ua,l(e(Ve)(C)),1)]),default:a(()=>[t(Pe,{class:"mono"},{default:a(()=>[v(l(C.path),1)]),_:2},1024),C.originalPath?(i(),k(Ie,{key:0,class:"mono"},{default:a(()=>[v(l(C.originalPath)+" → "+l(C.path),1)]),_:2},1024)):R("",!0)]),_:2},1032,["active","onClick"]))),128))]),_:1}),r("div",ca,[e(m)?(i(),O(K,{key:0},[r("div",da,[r("div",va,l(e(m).path),1),r("div",ma,[e(we)(e(m))?(i(),k(x,{key:0,size:"small",variant:"text",loading:e(u)==="stage",onClick:U[6]||(U[6]=C=>e(D)([e(m).path]))},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.stage")),1)]),_:1},8,["loading"])):R("",!0),e(A)(e(m))?(i(),k(x,{key:1,size:"small",variant:"text",loading:e(u)==="unstage",onClick:U[7]||(U[7]=C=>e(M)([e(m).path]))},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.unstage")),1)]),_:1},8,["loading"])):R("",!0),t(x,{color:"error",size:"small",variant:"text",disabled:!e(s).head&&e(m).kind!=="untracked",onClick:U[8]||(U[8]=C=>X.value=e(m))},{default:a(()=>[v(l(e(m).kind==="untracked"?e(o).t("$vuetify.chatroom.git.deleteFile"):e(o).t("$vuetify.chatroom.git.restore")),1)]),_:1},8,["disabled"])])]),e(n)?(i(),k(ce,{key:0,indeterminate:""})):R("",!0),e(b)?.truncated?(i(),k(Z,{key:1,type:"info",variant:"tonal",density:"compact"},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.diffTruncated")),1)]),_:1})):R("",!0),e(b)?.diff?(i(),k(Xt,{key:2,text:e(b).diff},null,8,["text"])):e(n)?R("",!0):(i(),k(ae,{key:3,icon:"$mdiFileCompare",title:e(s).head?e(o).t("$vuetify.chatroom.git.noDiff"):e(o).t("$vuetify.chatroom.git.noHead")},null,8,["title"]))],64)):R("",!0)])])):(i(),k(ae,{key:1,icon:"$mdiCheckCircleOutline",title:e(o).t("$vuetify.chatroom.git.clean")},null,8,["title"])),r("div",fa,[t(me,{modelValue:le.value,"onUpdate:modelValue":U[9]||(U[9]=C=>le.value=C),label:e(o).t("$vuetify.chatroom.git.commitMessage"),density:"compact",variant:"outlined","hide-details":"",disabled:!e(W).length,onKeyup:re(N,["enter"])},null,8,["modelValue","label","disabled"]),t(x,{color:"primary",variant:"flat",disabled:!e(W).length||!le.value.trim(),loading:e(u)==="commit",onClick:N},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.commit")),1)]),_:1},8,["disabled","loading"])]),r("div",pa,[r("div",ha,[r("strong",null,l(e(o).t("$vuetify.chatroom.git.recentCommits")),1)]),e(w).length?(i(),k(be,{key:0,density:"compact"},{default:a(()=>[(i(!0),O(K,null,ie(e(w),C=>(i(),k(Ce,{key:C.hash},{prepend:a(()=>[r("span",ka,l(C.shortHash),1)]),default:a(()=>[t(Pe,null,{default:a(()=>[v(l(C.subject),1)]),_:2},1024),t(Ie,null,{default:a(()=>[v(l(C.author)+" · "+l(new Date(C.date).toLocaleString(e(Xe)(e(o).current.value))),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})):R("",!0)])],64)):R("",!0),t(ge,{modelValue:te.value,"onUpdate:modelValue":U[12]||(U[12]=C=>te.value=C),width:"auto","max-width":"42rem"},{default:a(()=>[t(ve,null,{default:a(()=>[t(pe,{"prepend-icon":"$mdiSourceBranch"},{default:a(()=>[t(he,null,{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.branches")),1)]),_:1})]),_:1}),t(ke,null,{default:a(()=>[r("div",ya,[t(me,{modelValue:oe.value,"onUpdate:modelValue":U[10]||(U[10]=C=>oe.value=C),label:e(o).t("$vuetify.chatroom.git.newBranch"),density:"compact",variant:"outlined","hide-details":"",onKeyup:re(G,["enter"])},null,8,["modelValue","label"]),t(x,{color:"primary",variant:"flat",disabled:!oe.value.trim(),loading:e(u)==="branch",onClick:G},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.create")),1)]),_:1},8,["disabled","loading"])]),t(be,{class:"mt-3",density:"compact",border:"",rounded:"lg"},{default:a(()=>[(i(!0),O(K,null,ie(e(_),C=>(i(),k(Ce,{key:C.name},{append:a(()=>[C.current?(i(),k(xe,{key:0,size:"x-small",variant:"tonal"},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.current")),1)]),_:1})):(i(),O(K,{key:1},[t(x,{size:"x-small",variant:"text",onClick:Te=>de(C)},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.switch")),1)]),_:1},8,["onClick"]),t(x,{icon:"$mdiDeleteOutline",size:"x-small",color:"error",variant:"text","aria-label":e(o).t("$vuetify.chatroom.git.deleteBranch"),onClick:Te=>h.value=C},null,8,["aria-label","onClick"])],64))]),default:a(()=>[t(Pe,{class:"mono"},{default:a(()=>[v(l(C.name),1)]),_:2},1024),C.upstream?(i(),k(Ie,{key:0,class:"mono"},{default:a(()=>[v(l(C.upstream),1)]),_:2},1024)):R("",!0)]),_:2},1024))),128))]),_:1})]),_:1}),t(ye,null,{default:a(()=>[t(Se),t(x,{variant:"text",onClick:U[11]||(U[11]=C=>te.value=!1)},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.common.close")),1)]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),t(ge,{"model-value":X.value!==null,width:"auto","max-width":"32rem"},{default:a(()=>[t(ve,null,{default:a(()=>[t(pe,{"prepend-icon":"$mdiAlertCircleOutline",class:"text-error"},{default:a(()=>[t(he,null,{default:a(()=>[v(l(X.value?.kind==="untracked"?e(o).t("$vuetify.chatroom.git.deleteTitle"):e(o).t("$vuetify.chatroom.git.restoreTitle")),1)]),_:1})]),_:1}),t(ke,null,{default:a(()=>[v(l(X.value?.kind==="untracked"?e(o).t("$vuetify.chatroom.git.deleteDescription"):e(o).t("$vuetify.chatroom.git.restoreDescription"))+" ",1),r("div",ga,l(X.value?.path),1)]),_:1}),t(ye,null,{default:a(()=>[t(Se),t(x,{variant:"text",onClick:U[13]||(U[13]=C=>X.value=null)},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.common.cancel")),1)]),_:1}),t(x,{color:"error",variant:"flat",loading:e(u)==="restore",onClick:q},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.confirm")),1)]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["model-value"]),t(ge,{"model-value":h.value!==null,width:"auto","max-width":"32rem"},{default:a(()=>[t(ve,null,{default:a(()=>[t(pe,{"prepend-icon":"$mdiAlertCircleOutline",class:"text-error"},{default:a(()=>[t(he,null,{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.deleteBranchTitle")),1)]),_:1})]),_:1}),t(ke,null,{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.deleteBranchDescription"))+" ",1),r("div",wa,l(h.value?.name),1)]),_:1}),t(ye,null,{default:a(()=>[t(Se),t(x,{variant:"text",onClick:U[14]||(U[14]=C=>h.value=null)},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.common.cancel")),1)]),_:1}),t(x,{color:"error",variant:"flat",loading:e(u)==="branch",onClick:ee},{default:a(()=>[v(l(e(o).t("$vuetify.chatroom.git.confirm")),1)]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["model-value"])]))}}),_a={class:"workspace-prompt-pane"},ba={class:"workspace-prompt-form"},Ca={class:"workspace-prompt-actions"},xa=".chatroom/summary.md",Va=".chatroom/prompt.md",Pa=se({__name:"WorkspacePromptPane",props:{workspaceId:{}},setup(B){const I=B,o=y(""),g=y(""),s=y(""),_=y(""),w=y(!1),S=y(!1),c=y(!1),b=y(""),f=y(null),n=ne(),u=ue(),V=ue(),P=Q(()=>f.value===I.workspaceId&&(o.value!==s.value||g.value!==_.value));Y(()=>I.workspaceId,()=>{u.invalidate(),V.invalidate(),o.value="",g.value="",s.value="",_.value="",f.value=null,S.value=!1,c.value=!1,b.value="",m()},{immediate:!0});async function m(){const $=u.begin(),D=I.workspaceId;w.value=!0,b.value="",c.value=!1;try{const M=await H(`/workspace?workspaceId=${encodeURIComponent(D)}`,{signal:$.signal});if(!u.isCurrent($)||I.workspaceId!==D)return;o.value=M.summary??"",g.value=M.presetPrompt??"",s.value=o.value,_.value=g.value,f.value=D}catch(M){u.isCurrent($)&&(b.value=J(M))}finally{u.isCurrent($)&&(w.value=!1)}}async function W($,D,M,F){await H("/workspace/file",{method:"PUT",body:JSON.stringify({workspaceId:$,path:D,content:M}),signal:F})}async function z(){if(!P.value||S.value||f.value!==I.workspaceId)return;const $=V.begin(),D=I.workspaceId,M=o.value,F=g.value;S.value=!0,b.value="",c.value=!1;try{const L=[];if(M!==s.value&&L.push(W(D,xa,M,$.signal)),F!==_.value&&L.push(W(D,Va,F,$.signal)),await Promise.all(L),!V.isCurrent($)||I.workspaceId!==D)return;s.value=M,_.value=F,c.value=!0}catch(L){V.isCurrent($)&&I.workspaceId===D&&(b.value=J(L))}finally{V.isCurrent($)&&I.workspaceId===D&&(S.value=!1)}}return($,D)=>(i(),O("div",_a,[w.value?(i(),k(ce,{key:0,indeterminate:""})):R("",!0),r("div",ba,[t(Be,{modelValue:o.value,"onUpdate:modelValue":D[0]||(D[0]=M=>o.value=M),label:e(n).t("$vuetify.chatroom.workspaces.summary"),rows:"3","auto-grow":"",maxlength:"2048",counter:"",disabled:w.value},null,8,["modelValue","label","disabled"]),t(Be,{modelValue:g.value,"onUpdate:modelValue":D[1]||(D[1]=M=>g.value=M),label:e(n).t("$vuetify.chatroom.workspaces.presetPrompt"),rows:"10","auto-grow":"",maxlength:"16384",counter:"",disabled:w.value},null,8,["modelValue","label","disabled"]),b.value?(i(),k(Z,{key:0,type:"error",variant:"tonal",density:"compact"},{default:a(()=>[v(l(b.value),1)]),_:1})):c.value?(i(),k(Z,{key:1,type:"success",variant:"tonal",density:"compact"},{default:a(()=>[v(l(e(n).t("$vuetify.chatroom.workspaces.saved")),1)]),_:1})):R("",!0),r("div",Ca,[t(x,{color:"primary",variant:"flat",loading:S.value,disabled:w.value||!P.value,onClick:z},{default:a(()=>[v(l(e(n).t("$vuetify.chatroom.workspaces.save")),1)]),_:1},8,["loading","disabled"])])])]))}}),Ia=Oe(Pa,[["__scopeId","data-v-bbd264b7"]]),Sa={class:"workspace-skills-pane"},Ra={key:2,class:"workspace-skill-grid"},Oa={class:"workspace-skill-header"},za={class:"workspace-skill-title"},Ta={class:"workspace-skill-description"},La={class:"workspace-skill-path"},Ua=se({__name:"WorkspaceSkillsPane",props:{workspaceId:{}},setup(B){const I=B,o=y(null),g=y(!1),s=y(""),_=ne(),w=ue();Y(()=>I.workspaceId,()=>{o.value=null,S()},{immediate:!0});async function S(){const b=w.begin(),f=I.workspaceId;g.value=!0,s.value="";try{const n=await H(`/workspace?workspaceId=${encodeURIComponent(f)}`,{signal:b.signal});if(!w.isCurrent(b)||I.workspaceId!==f)return;o.value=n}catch(n){w.isCurrent(b)&&(s.value=J(n))}finally{w.isCurrent(b)&&(g.value=!1)}}function c(b){return b.path.startsWith(".claude/skills/")?_.t("$vuetify.chatroom.skills.sources.claude"):b.path.startsWith(".chatroom/skills/")?_.t("$vuetify.chatroom.skills.sources.chatRoom"):_.t("$vuetify.chatroom.skills.sources.agent")}return(b,f)=>(i(),O("div",Sa,[g.value?(i(),k(ce,{key:0,indeterminate:""})):R("",!0),s.value?(i(),k(Z,{key:1,type:"error",variant:"tonal",density:"compact"},{default:a(()=>[v(l(s.value),1)]),_:1})):R("",!0),o.value?.skills.length?(i(),O("div",Ra,[(i(!0),O(K,null,ie(o.value.skills,n=>(i(),O("div",{key:n.path,class:"workspace-skill-card"},[r("div",Oa,[r("div",za,[t(Ye,{icon:"$mdiPuzzleOutline",size:"18"}),r("strong",null,l(n.name),1)]),t(xe,{size:"x-small",variant:"tonal"},{default:a(()=>[v(l(c(n)),1)]),_:2},1024)]),r("div",Ta,l(n.description||e(_).t("$vuetify.chatroom.skills.noDescription")),1),r("div",La,l(n.path),1)]))),128))])):!g.value&&!s.value?(i(),k(ae,{key:3,icon:"$mdiPuzzleOutline",title:e(_).t("$vuetify.chatroom.skills.empty")},null,8,["title"])):R("",!0)]))}}),Wa={class:"workspace-layout"},Ba={class:"workspace-header"},Da={class:"workspace-identity min-w-0"},Ma={class:"workspace-meta-row"},Fa=["title"],Ea={class:"workspace-actions"},Ya=se({__name:"WorkspacesView",setup(B){const I=y([]),o=y([]),g=y(window.localStorage.getItem("chatroom.workspace.id")),s=Q(()=>I.value.find(W=>W.id===g.value)??null),_=y("git"),w=y(!1),S=y(""),c=y(!1),b=y(!1),f=y(!1),n=y(""),u=ne(),V=ue();Ze(()=>{P()}),Y(g,W=>{W?window.localStorage.setItem("chatroom.workspace.id",W):window.localStorage.removeItem("chatroom.workspace.id")});async function P(){const W=V.begin();w.value=!0,S.value="";try{const[z,$]=await Promise.all([H("/workspaces",{signal:W.signal}),H("/workspace/roots",{signal:W.signal})]);if(!V.isCurrent(W))return;I.value=z,o.value=$,I.value.some(D=>D.id===g.value)||(g.value=I.value[0]?.id??null)}catch(z){V.isCurrent(W)&&(S.value=J(z))}finally{V.isCurrent(W)&&(w.value=!1)}}async function m(W,z){if(!f.value){f.value=!0,n.value="";try{const $=await H("/workspaces",{method:"POST",body:JSON.stringify({parent:W,name:z})});await P(),g.value=$.id,c.value=!1}catch($){n.value=J($)}finally{f.value=!1}}}return(W,z)=>(i(),O("div",Wa,[t(ve,{class:"workspace-detail panel-card"},{default:a(()=>[r("div",Ba,[r("div",Da,[t(Ae,{modelValue:g.value,"onUpdate:modelValue":z[0]||(z[0]=$=>g.value=$),items:I.value.map($=>({title:$.name,value:$.id,subtitle:$.path})),loading:w.value,"aria-label":e(u).t("$vuetify.chatroom.workspaces.workspace"),density:"compact",variant:"outlined","hide-details":"","prepend-inner-icon":"$mdiFolderOutline",class:"workspace-switcher"},null,8,["modelValue","items","loading","aria-label"]),r("div",Ma,[s.value?(i(),O("div",{key:0,class:"workspace-path",title:s.value.path},l(s.value.path),9,Fa)):R("",!0),r("div",Ea,[t(x,{icon:"$mdiFolderCogOutline",size:"small",variant:"text","aria-label":e(u).t("$vuetify.chatroom.workspaces.manage"),onClick:z[1]||(z[1]=$=>b.value=!0)},null,8,["aria-label"]),t(x,{icon:"$mdiPlus",size:"small",variant:"text","aria-label":e(u).t("$vuetify.chatroom.workspaces.createTitle"),onClick:z[2]||(z[2]=$=>{n.value="",c.value=!0})},null,8,["aria-label"]),t(x,{icon:"$mdiRefresh",size:"small",variant:"text",loading:w.value,"aria-label":e(u).t("$vuetify.chatroom.workspaces.refresh"),onClick:P},null,8,["loading","aria-label"])])])])]),S.value?(i(),k(Z,{key:0,type:"error",variant:"tonal",density:"compact"},{default:a(()=>[v(l(S.value),1)]),_:1})):R("",!0),g.value?(i(),O(K,{key:1},[t(lt,{modelValue:_.value,"onUpdate:modelValue":z[3]||(z[3]=$=>_.value=$),density:"compact",class:"workspace-tabs"},{default:a(()=>[t($e,{value:"git"},{default:a(()=>[v(l(e(u).t("$vuetify.chatroom.workspaces.git")),1)]),_:1}),t($e,{value:"prompt"},{default:a(()=>[v(l(e(u).t("$vuetify.chatroom.workspaces.prompt")),1)]),_:1}),t($e,{value:"files"},{default:a(()=>[v(l(e(u).t("$vuetify.chatroom.workspaces.files")),1)]),_:1}),t($e,{value:"skills"},{default:a(()=>[v(l(e(u).t("$vuetify.chatroom.workspaces.skills")),1)]),_:1})]),_:1},8,["modelValue"]),t(ze),t(ot,{modelValue:_.value,"onUpdate:modelValue":z[4]||(z[4]=$=>_.value=$),touch:!1},{default:a(()=>[t(_e,{value:"git"},{default:a(()=>[t($a,{"workspace-id":g.value},null,8,["workspace-id"])]),_:1}),t(_e,{value:"prompt"},{default:a(()=>[t(Ia,{"workspace-id":g.value},null,8,["workspace-id"])]),_:1}),t(_e,{value:"files"},{default:a(()=>[t(Ft,{"workspace-id":g.value},null,8,["workspace-id"])]),_:1}),t(_e,{value:"skills"},{default:a(()=>[t(Ua,{"workspace-id":g.value},null,8,["workspace-id"])]),_:1})]),_:1},8,["modelValue"])],64)):w.value?R("",!0):(i(),k(ae,{key:2,icon:"$mdiFolderOutline",title:e(u).t("$vuetify.chatroom.workspaces.empty")},null,8,["title"]))]),_:1}),t(rt,{modelValue:c.value,"onUpdate:modelValue":z[5]||(z[5]=$=>c.value=$),roots:o.value,busy:f.value,error:n.value,onCreate:m},null,8,["modelValue","roots","busy","error"]),t(_t,{modelValue:b.value,"onUpdate:modelValue":z[6]||(z[6]=$=>b.value=$),onUpdated:P},null,8,["modelValue"])]))}});export{Ya as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.workspace-create-form[data-v-f24d3eec]{display:grid;gap:18px}.workspace-create-location[data-v-f24d3eec]{display:grid;gap:4px}.workspace-create-location span[data-v-f24d3eec]{color:rgb(var(--v-theme-on-surface),.55);font-size:12px}.workspace-create-location code[data-v-f24d3eec]{overflow-wrap:anywhere;font-size:12px}.workspace-manage-dialog[data-v-55f78db7]{max-height:min(88vh,900px)}.workspace-manage-content[data-v-55f78db7]{display:grid;gap:18px}.workspace-register-form[data-v-55f78db7]{display:grid;gap:10px}.workspace-manage-list-heading[data-v-55f78db7]{display:flex;align-items:center;justify-content:space-between}.workspace-manage-list[data-v-55f78db7]{display:grid;gap:0}.workspace-manage-item[data-v-55f78db7]{display:flex;align-items:flex-start;gap:12px;padding:12px 0;border-bottom:1px solid rgba(var(--v-border-color),var(--v-border-opacity))}.workspace-manage-item-main[data-v-55f78db7]{flex:1;min-width:0;display:grid;gap:5px}.workspace-manage-item-title[data-v-55f78db7]{font-weight:600}.workspace-manage-item-path[data-v-55f78db7]{color:rgba(var(--v-theme-on-surface),.62);font-size:12px;overflow-wrap:anywhere}.workspace-manage-item-tags[data-v-55f78db7],.workspace-manage-item-actions[data-v-55f78db7]{display:flex;align-items:center;flex-wrap:wrap;gap:4px}.workspace-manage-item-actions[data-v-55f78db7]{flex-shrink:0}.workspace-prompt-pane[data-v-bbd264b7]{min-width:0}.workspace-prompt-form[data-v-bbd264b7]{display:grid;gap:18px;padding:18px}.workspace-prompt-actions[data-v-bbd264b7]{display:flex;justify-content:flex-end}
|