aldus-pdf 0.3.0

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.
@@ -0,0 +1,364 @@
1
+ var Lk=Object.defineProperty;var q1=a=>{throw TypeError(a)};var Ik=(a,t,e)=>t in a?Lk(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var It=(a,t,e)=>Ik(a,typeof t!="symbol"?t+"":t,e),ny=(a,t,e)=>t.has(a)||q1("Cannot "+e);var u=(a,t,e)=>(ny(a,t,"read from private field"),e?e.call(a):t.get(a)),P=(a,t,e)=>t.has(a)?q1("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,e),_=(a,t,e,n)=>(ny(a,t,"write to private field"),n?n.call(a,e):t.set(a,e),e),M=(a,t,e)=>(ny(a,t,"access private method"),e);var $n=(a,t,e,n)=>({set _(s){_(a,t,s,e)},get _(){return u(a,t,n)}});function Dk(a,t){for(var e=0;e<t.length;e++){const n=t[e];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in a)){const o=Object.getOwnPropertyDescriptor(n,s);o&&Object.defineProperty(a,s,o.get?o:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function e(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(s){if(s.ep)return;s.ep=!0;const o=e(s);fetch(s.href,o)}})();function Fk(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var iy={exports:{}},vh={},sy={exports:{}},qt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Y1;function Ok(){if(Y1)return qt;Y1=1;var a=Symbol.for("react.element"),t=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),m=Symbol.iterator;function y(I){return I===null||typeof I!="object"?null:(I=m&&I[m]||I["@@iterator"],typeof I=="function"?I:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,A={};function C(I,V,W){this.props=I,this.context=V,this.refs=A,this.updater=W||x}C.prototype.isReactComponent={},C.prototype.setState=function(I,V){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,V,"setState")},C.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=C.prototype;function N(I,V,W){this.props=I,this.context=V,this.refs=A,this.updater=W||x}var k=N.prototype=new E;k.constructor=N,b(k,C.prototype),k.isPureReactComponent=!0;var L=Array.isArray,R=Object.prototype.hasOwnProperty,j={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function H(I,V,W){var nt,rt={},dt=null,mt=null;if(V!=null)for(nt in V.ref!==void 0&&(mt=V.ref),V.key!==void 0&&(dt=""+V.key),V)R.call(V,nt)&&!O.hasOwnProperty(nt)&&(rt[nt]=V[nt]);var Mt=arguments.length-2;if(Mt===1)rt.children=W;else if(1<Mt){for(var Vt=Array(Mt),ye=0;ye<Mt;ye++)Vt[ye]=arguments[ye+2];rt.children=Vt}if(I&&I.defaultProps)for(nt in Mt=I.defaultProps,Mt)rt[nt]===void 0&&(rt[nt]=Mt[nt]);return{$$typeof:a,type:I,key:dt,ref:mt,props:rt,_owner:j.current}}function X(I,V){return{$$typeof:a,type:I.type,key:V,ref:I.ref,props:I.props,_owner:I._owner}}function q(I){return typeof I=="object"&&I!==null&&I.$$typeof===a}function K(I){var V={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(W){return V[W]})}var lt=/\/+/g;function pt(I,V){return typeof I=="object"&&I!==null&&I.key!=null?K(""+I.key):V.toString(36)}function ut(I,V,W,nt,rt){var dt=typeof I;(dt==="undefined"||dt==="boolean")&&(I=null);var mt=!1;if(I===null)mt=!0;else switch(dt){case"string":case"number":mt=!0;break;case"object":switch(I.$$typeof){case a:case t:mt=!0}}if(mt)return mt=I,rt=rt(mt),I=nt===""?"."+pt(mt,0):nt,L(rt)?(W="",I!=null&&(W=I.replace(lt,"$&/")+"/"),ut(rt,V,W,"",function(ye){return ye})):rt!=null&&(q(rt)&&(rt=X(rt,W+(!rt.key||mt&&mt.key===rt.key?"":(""+rt.key).replace(lt,"$&/")+"/")+I)),V.push(rt)),1;if(mt=0,nt=nt===""?".":nt+":",L(I))for(var Mt=0;Mt<I.length;Mt++){dt=I[Mt];var Vt=nt+pt(dt,Mt);mt+=ut(dt,V,W,Vt,rt)}else if(Vt=y(I),typeof Vt=="function")for(I=Vt.call(I),Mt=0;!(dt=I.next()).done;)dt=dt.value,Vt=nt+pt(dt,Mt++),mt+=ut(dt,V,W,Vt,rt);else if(dt==="object")throw V=String(I),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.");return mt}function St(I,V,W){if(I==null)return I;var nt=[],rt=0;return ut(I,nt,"","",function(dt){return V.call(W,dt,rt++)}),nt}function Q(I){if(I._status===-1){var V=I._result;V=V(),V.then(function(W){(I._status===0||I._status===-1)&&(I._status=1,I._result=W)},function(W){(I._status===0||I._status===-1)&&(I._status=2,I._result=W)}),I._status===-1&&(I._status=0,I._result=V)}if(I._status===1)return I._result.default;throw I._result}var tt={current:null},J={transition:null},at={ReactCurrentDispatcher:tt,ReactCurrentBatchConfig:J,ReactCurrentOwner:j};function st(){throw Error("act(...) is not supported in production builds of React.")}return qt.Children={map:St,forEach:function(I,V,W){St(I,function(){V.apply(this,arguments)},W)},count:function(I){var V=0;return St(I,function(){V++}),V},toArray:function(I){return St(I,function(V){return V})||[]},only:function(I){if(!q(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},qt.Component=C,qt.Fragment=e,qt.Profiler=s,qt.PureComponent=N,qt.StrictMode=n,qt.Suspense=d,qt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=at,qt.act=st,qt.cloneElement=function(I,V,W){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var nt=b({},I.props),rt=I.key,dt=I.ref,mt=I._owner;if(V!=null){if(V.ref!==void 0&&(dt=V.ref,mt=j.current),V.key!==void 0&&(rt=""+V.key),I.type&&I.type.defaultProps)var Mt=I.type.defaultProps;for(Vt in V)R.call(V,Vt)&&!O.hasOwnProperty(Vt)&&(nt[Vt]=V[Vt]===void 0&&Mt!==void 0?Mt[Vt]:V[Vt])}var Vt=arguments.length-2;if(Vt===1)nt.children=W;else if(1<Vt){Mt=Array(Vt);for(var ye=0;ye<Vt;ye++)Mt[ye]=arguments[ye+2];nt.children=Mt}return{$$typeof:a,type:I.type,key:rt,ref:dt,props:nt,_owner:mt}},qt.createContext=function(I){return I={$$typeof:l,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:o,_context:I},I.Consumer=I},qt.createElement=H,qt.createFactory=function(I){var V=H.bind(null,I);return V.type=I,V},qt.createRef=function(){return{current:null}},qt.forwardRef=function(I){return{$$typeof:c,render:I}},qt.isValidElement=q,qt.lazy=function(I){return{$$typeof:g,_payload:{_status:-1,_result:I},_init:Q}},qt.memo=function(I,V){return{$$typeof:f,type:I,compare:V===void 0?null:V}},qt.startTransition=function(I){var V=J.transition;J.transition={};try{I()}finally{J.transition=V}},qt.unstable_act=st,qt.useCallback=function(I,V){return tt.current.useCallback(I,V)},qt.useContext=function(I){return tt.current.useContext(I)},qt.useDebugValue=function(){},qt.useDeferredValue=function(I){return tt.current.useDeferredValue(I)},qt.useEffect=function(I,V){return tt.current.useEffect(I,V)},qt.useId=function(){return tt.current.useId()},qt.useImperativeHandle=function(I,V,W){return tt.current.useImperativeHandle(I,V,W)},qt.useInsertionEffect=function(I,V){return tt.current.useInsertionEffect(I,V)},qt.useLayoutEffect=function(I,V){return tt.current.useLayoutEffect(I,V)},qt.useMemo=function(I,V){return tt.current.useMemo(I,V)},qt.useReducer=function(I,V,W){return tt.current.useReducer(I,V,W)},qt.useRef=function(I){return tt.current.useRef(I)},qt.useState=function(I){return tt.current.useState(I)},qt.useSyncExternalStore=function(I,V,W){return tt.current.useSyncExternalStore(I,V,W)},qt.useTransition=function(){return tt.current.useTransition()},qt.version="18.3.1",qt}var K1;function Gv(){return K1||(K1=1,sy.exports=Ok()),sy.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Q1;function jk(){if(Q1)return vh;Q1=1;var a=Gv(),t=Symbol.for("react.element"),e=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(c,d,f){var g,m={},y=null,x=null;f!==void 0&&(y=""+f),d.key!==void 0&&(y=""+d.key),d.ref!==void 0&&(x=d.ref);for(g in d)n.call(d,g)&&!o.hasOwnProperty(g)&&(m[g]=d[g]);if(c&&c.defaultProps)for(g in d=c.defaultProps,d)m[g]===void 0&&(m[g]=d[g]);return{$$typeof:t,type:c,key:y,ref:x,props:m,_owner:s.current}}return vh.Fragment=e,vh.jsx=l,vh.jsxs=l,vh}var J1;function $k(){return J1||(J1=1,iy.exports=jk()),iy.exports}var S=$k(),F=Gv();const zk=Fk(F),Hk=Dk({__proto__:null,default:zk},[F]);var zp={},ry={exports:{}},Zn={},oy={exports:{}},ay={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Z1;function Bk(){return Z1||(Z1=1,(function(a){function t(J,at){var st=J.length;J.push(at);t:for(;0<st;){var I=st-1>>>1,V=J[I];if(0<s(V,at))J[I]=at,J[st]=V,st=I;else break t}}function e(J){return J.length===0?null:J[0]}function n(J){if(J.length===0)return null;var at=J[0],st=J.pop();if(st!==at){J[0]=st;t:for(var I=0,V=J.length,W=V>>>1;I<W;){var nt=2*(I+1)-1,rt=J[nt],dt=nt+1,mt=J[dt];if(0>s(rt,st))dt<V&&0>s(mt,rt)?(J[I]=mt,J[dt]=st,I=dt):(J[I]=rt,J[nt]=st,I=nt);else if(dt<V&&0>s(mt,st))J[I]=mt,J[dt]=st,I=dt;else break t}}return at}function s(J,at){var st=J.sortIndex-at.sortIndex;return st!==0?st:J.id-at.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;a.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();a.unstable_now=function(){return l.now()-c}}var d=[],f=[],g=1,m=null,y=3,x=!1,b=!1,A=!1,C=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(J){for(var at=e(f);at!==null;){if(at.callback===null)n(f);else if(at.startTime<=J)n(f),at.sortIndex=at.expirationTime,t(d,at);else break;at=e(f)}}function L(J){if(A=!1,k(J),!b)if(e(d)!==null)b=!0,Q(R);else{var at=e(f);at!==null&&tt(L,at.startTime-J)}}function R(J,at){b=!1,A&&(A=!1,E(H),H=-1),x=!0;var st=y;try{for(k(at),m=e(d);m!==null&&(!(m.expirationTime>at)||J&&!K());){var I=m.callback;if(typeof I=="function"){m.callback=null,y=m.priorityLevel;var V=I(m.expirationTime<=at);at=a.unstable_now(),typeof V=="function"?m.callback=V:m===e(d)&&n(d),k(at)}else n(d);m=e(d)}if(m!==null)var W=!0;else{var nt=e(f);nt!==null&&tt(L,nt.startTime-at),W=!1}return W}finally{m=null,y=st,x=!1}}var j=!1,O=null,H=-1,X=5,q=-1;function K(){return!(a.unstable_now()-q<X)}function lt(){if(O!==null){var J=a.unstable_now();q=J;var at=!0;try{at=O(!0,J)}finally{at?pt():(j=!1,O=null)}}else j=!1}var pt;if(typeof N=="function")pt=function(){N(lt)};else if(typeof MessageChannel<"u"){var ut=new MessageChannel,St=ut.port2;ut.port1.onmessage=lt,pt=function(){St.postMessage(null)}}else pt=function(){C(lt,0)};function Q(J){O=J,j||(j=!0,pt())}function tt(J,at){H=C(function(){J(a.unstable_now())},at)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(J){J.callback=null},a.unstable_continueExecution=function(){b||x||(b=!0,Q(R))},a.unstable_forceFrameRate=function(J){0>J||125<J?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<J?Math.floor(1e3/J):5},a.unstable_getCurrentPriorityLevel=function(){return y},a.unstable_getFirstCallbackNode=function(){return e(d)},a.unstable_next=function(J){switch(y){case 1:case 2:case 3:var at=3;break;default:at=y}var st=y;y=at;try{return J()}finally{y=st}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(J,at){switch(J){case 1:case 2:case 3:case 4:case 5:break;default:J=3}var st=y;y=J;try{return at()}finally{y=st}},a.unstable_scheduleCallback=function(J,at,st){var I=a.unstable_now();switch(typeof st=="object"&&st!==null?(st=st.delay,st=typeof st=="number"&&0<st?I+st:I):st=I,J){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=st+V,J={id:g++,callback:at,priorityLevel:J,startTime:st,expirationTime:V,sortIndex:-1},st>I?(J.sortIndex=st,t(f,J),e(d)===null&&J===e(f)&&(A?(E(H),H=-1):A=!0,tt(L,st-I))):(J.sortIndex=V,t(d,J),b||x||(b=!0,Q(R))),J},a.unstable_shouldYield=K,a.unstable_wrapCallback=function(J){var at=y;return function(){var st=y;y=at;try{return J.apply(this,arguments)}finally{y=st}}}})(ay)),ay}var tb;function Uk(){return tb||(tb=1,oy.exports=Bk()),oy.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var eb;function Vk(){if(eb)return Zn;eb=1;var a=Gv(),t=Uk();function e(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,h=1;h<arguments.length;h++)r+="&args[]="+encodeURIComponent(arguments[h]);return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var n=new Set,s={};function o(i,r){l(i,r),l(i+"Capture",r)}function l(i,r){for(s[i]=r,i=0;i<r.length;i++)n.add(r[i])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},m={};function y(i){return d.call(m,i)?!0:d.call(g,i)?!1:f.test(i)?m[i]=!0:(g[i]=!0,!1)}function x(i,r,h,p){if(h!==null&&h.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return p?!1:h!==null?!h.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function b(i,r,h,p){if(r===null||typeof r>"u"||x(i,r,h,p))return!0;if(p)return!1;if(h!==null)switch(h.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function A(i,r,h,p,v,w,T){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=p,this.attributeNamespace=v,this.mustUseProperty=h,this.propertyName=i,this.type=r,this.sanitizeURL=w,this.removeEmptyString=T}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new A(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];C[r]=new A(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new A(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new A(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){C[i]=new A(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new A(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new A(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new A(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new A(i,5,!1,i.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function N(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var r=i.replace(E,N);C[r]=new A(r,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var r=i.replace(E,N);C[r]=new A(r,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var r=i.replace(E,N);C[r]=new A(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new A(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new A(i,1,!1,i.toLowerCase(),null,!0,!0)});function k(i,r,h,p){var v=C.hasOwnProperty(r)?C[r]:null;(v!==null?v.type!==0:p||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(b(r,h,v,p)&&(h=null),p||v===null?y(r)&&(h===null?i.removeAttribute(r):i.setAttribute(r,""+h)):v.mustUseProperty?i[v.propertyName]=h===null?v.type===3?!1:"":h:(r=v.attributeName,p=v.attributeNamespace,h===null?i.removeAttribute(r):(v=v.type,h=v===3||v===4&&h===!0?"":""+h,p?i.setAttributeNS(p,r,h):i.setAttribute(r,h))))}var L=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),j=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),H=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),q=Symbol.for("react.provider"),K=Symbol.for("react.context"),lt=Symbol.for("react.forward_ref"),pt=Symbol.for("react.suspense"),ut=Symbol.for("react.suspense_list"),St=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),tt=Symbol.for("react.offscreen"),J=Symbol.iterator;function at(i){return i===null||typeof i!="object"?null:(i=J&&i[J]||i["@@iterator"],typeof i=="function"?i:null)}var st=Object.assign,I;function V(i){if(I===void 0)try{throw Error()}catch(h){var r=h.stack.trim().match(/\n( *(at )?)/);I=r&&r[1]||""}return`
34
+ `+I+i}var W=!1;function nt(i,r){if(!i||W)return"";W=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(Y){var p=Y}Reflect.construct(i,[],r)}else{try{r.call()}catch(Y){p=Y}i.call(r.prototype)}else{try{throw Error()}catch(Y){p=Y}i()}}catch(Y){if(Y&&p&&typeof Y.stack=="string"){for(var v=Y.stack.split(`
35
+ `),w=p.stack.split(`
36
+ `),T=v.length-1,D=w.length-1;1<=T&&0<=D&&v[T]!==w[D];)D--;for(;1<=T&&0<=D;T--,D--)if(v[T]!==w[D]){if(T!==1||D!==1)do if(T--,D--,0>D||v[T]!==w[D]){var $=`
37
+ `+v[T].replace(" at new "," at ");return i.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",i.displayName)),$}while(1<=T&&0<=D);break}}}finally{W=!1,Error.prepareStackTrace=h}return(i=i?i.displayName||i.name:"")?V(i):""}function rt(i){switch(i.tag){case 5:return V(i.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return i=nt(i.type,!1),i;case 11:return i=nt(i.type.render,!1),i;case 1:return i=nt(i.type,!0),i;default:return""}}function dt(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case O:return"Fragment";case j:return"Portal";case X:return"Profiler";case H:return"StrictMode";case pt:return"Suspense";case ut:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case K:return(i.displayName||"Context")+".Consumer";case q:return(i._context.displayName||"Context")+".Provider";case lt:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case St:return r=i.displayName||null,r!==null?r:dt(i.type)||"Memo";case Q:r=i._payload,i=i._init;try{return dt(i(r))}catch{}}return null}function mt(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return dt(r);case 8:return r===H?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function Mt(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Vt(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function ye(i){var r=Vt(i)?"checked":"value",h=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),p=""+i[r];if(!i.hasOwnProperty(r)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var v=h.get,w=h.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return v.call(this)},set:function(T){p=""+T,w.call(this,T)}}),Object.defineProperty(i,r,{enumerable:h.enumerable}),{getValue:function(){return p},setValue:function(T){p=""+T},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function ve(i){i._valueTracker||(i._valueTracker=ye(i))}function ue(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var h=r.getValue(),p="";return i&&(p=Vt(i)?i.checked?"true":"false":i.value),i=p,i!==h?(r.setValue(i),!0):!1}function te(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function Xt(i,r){var h=r.checked;return st({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:h??i._wrapperState.initialChecked})}function ai(i,r){var h=r.defaultValue==null?"":r.defaultValue,p=r.checked!=null?r.checked:r.defaultChecked;h=Mt(r.value!=null?r.value:h),i._wrapperState={initialChecked:p,initialValue:h,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Dn(i,r){r=r.checked,r!=null&&k(i,"checked",r,!1)}function Pi(i,r){Dn(i,r);var h=Mt(r.value),p=r.type;if(h!=null)p==="number"?(h===0&&i.value===""||i.value!=h)&&(i.value=""+h):i.value!==""+h&&(i.value=""+h);else if(p==="submit"||p==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?Mi(i,r.type,h):r.hasOwnProperty("defaultValue")&&Mi(i,r.type,Mt(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function Fn(i,r,h){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var p=r.type;if(!(p!=="submit"&&p!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,h||r===i.value||(i.value=r),i.defaultValue=r}h=i.name,h!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,h!==""&&(i.name=h)}function Mi(i,r,h){(r!=="number"||te(i.ownerDocument)!==i)&&(h==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+h&&(i.defaultValue=""+h))}var As=Array.isArray;function B(i,r,h,p){if(i=i.options,r){r={};for(var v=0;v<h.length;v++)r["$"+h[v]]=!0;for(h=0;h<i.length;h++)v=r.hasOwnProperty("$"+i[h].value),i[h].selected!==v&&(i[h].selected=v),v&&p&&(i[h].defaultSelected=!0)}else{for(h=""+Mt(h),r=null,v=0;v<i.length;v++){if(i[v].value===h){i[v].selected=!0,p&&(i[v].defaultSelected=!0);return}r!==null||i[v].disabled||(r=i[v])}r!==null&&(r.selected=!0)}}function Z(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(e(91));return st({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function yt(i,r){var h=r.value;if(h==null){if(h=r.children,r=r.defaultValue,h!=null){if(r!=null)throw Error(e(92));if(As(h)){if(1<h.length)throw Error(e(93));h=h[0]}r=h}r==null&&(r=""),h=r}i._wrapperState={initialValue:Mt(h)}}function Ft(i,r){var h=Mt(r.value),p=Mt(r.defaultValue);h!=null&&(h=""+h,h!==i.value&&(i.value=h),r.defaultValue==null&&i.defaultValue!==h&&(i.defaultValue=h)),p!=null&&(i.defaultValue=""+p)}function Qt(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function Lt(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ht(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?Lt(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var ie,Zt=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,h,p,v){MSApp.execUnsafeLocalFunction(function(){return i(r,h,p,v)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(ie=ie||document.createElement("div"),ie.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=ie.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function pe(i,r){if(r){var h=i.firstChild;if(h&&h===i.lastChild&&h.nodeType===3){h.nodeValue=r;return}}i.textContent=r}var Ge={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},$t=["Webkit","ms","Moz","O"];Object.keys(Ge).forEach(function(i){$t.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),Ge[r]=Ge[i]})});function tn(i,r,h){return r==null||typeof r=="boolean"||r===""?"":h||typeof r!="number"||r===0||Ge.hasOwnProperty(i)&&Ge[i]?(""+r).trim():r+"px"}function sa(i,r){i=i.style;for(var h in r)if(r.hasOwnProperty(h)){var p=h.indexOf("--")===0,v=tn(h,r[h],p);h==="float"&&(h="cssFloat"),p?i.setProperty(h,v):i[h]=v}}var wm=st({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $l(i,r){if(r){if(wm[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(e(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(e(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(e(61))}if(r.style!=null&&typeof r.style!="object")throw Error(e(62))}}function Iu(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Vr=null;function ra(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Du=null,Wr=null,Gr=null;function Pf(i){if(i=ih(i)){if(typeof Du!="function")throw Error(e(280));var r=i.stateNode;r&&(r=ep(r),Du(i.stateNode,i.type,r))}}function Mf(i){Wr?Gr?Gr.push(i):Gr=[i]:Wr=i}function Rf(){if(Wr){var i=Wr,r=Gr;if(Gr=Wr=null,Pf(i),r)for(i=0;i<r.length;i++)Pf(r[i])}}function Nf(i,r){return i(r)}function Fu(){}var ft=!1;function Ht(i,r,h){if(ft)return i(r,h);ft=!0;try{return Nf(i,r,h)}finally{ft=!1,(Wr!==null||Gr!==null)&&(Fu(),Rf())}}function xn(i,r){var h=i.stateNode;if(h===null)return null;var p=ep(h);if(p===null)return null;h=p[r];t:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(i=i.type,p=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!p;break t;default:i=!1}if(i)return null;if(h&&typeof h!="function")throw Error(e(231,r,typeof h));return h}var _s=!1;if(c)try{var Ou={};Object.defineProperty(Ou,"passive",{get:function(){_s=!0}}),window.addEventListener("test",Ou,Ou),window.removeEventListener("test",Ou,Ou)}catch{_s=!1}function $_(i,r,h,p,v,w,T,D,$){var Y=Array.prototype.slice.call(arguments,3);try{r.apply(h,Y)}catch(it){this.onError(it)}}var ju=!1,Lf=null,If=!1,bm=null,z_={onError:function(i){ju=!0,Lf=i}};function H_(i,r,h,p,v,w,T,D,$){ju=!1,Lf=null,$_.apply(z_,arguments)}function B_(i,r,h,p,v,w,T,D,$){if(H_.apply(this,arguments),ju){if(ju){var Y=Lf;ju=!1,Lf=null}else throw Error(e(198));If||(If=!0,bm=Y)}}function oa(i){var r=i,h=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(h=r.return),i=r.return;while(i)}return r.tag===3?h:null}function yx(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function vx(i){if(oa(i)!==i)throw Error(e(188))}function U_(i){var r=i.alternate;if(!r){if(r=oa(i),r===null)throw Error(e(188));return r!==i?null:i}for(var h=i,p=r;;){var v=h.return;if(v===null)break;var w=v.alternate;if(w===null){if(p=v.return,p!==null){h=p;continue}break}if(v.child===w.child){for(w=v.child;w;){if(w===h)return vx(v),i;if(w===p)return vx(v),r;w=w.sibling}throw Error(e(188))}if(h.return!==p.return)h=v,p=w;else{for(var T=!1,D=v.child;D;){if(D===h){T=!0,h=v,p=w;break}if(D===p){T=!0,p=v,h=w;break}D=D.sibling}if(!T){for(D=w.child;D;){if(D===h){T=!0,h=w,p=v;break}if(D===p){T=!0,p=w,h=v;break}D=D.sibling}if(!T)throw Error(e(189))}}if(h.alternate!==p)throw Error(e(190))}if(h.tag!==3)throw Error(e(188));return h.stateNode.current===h?i:r}function xx(i){return i=U_(i),i!==null?wx(i):null}function wx(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=wx(i);if(r!==null)return r;i=i.sibling}return null}var bx=t.unstable_scheduleCallback,Sx=t.unstable_cancelCallback,V_=t.unstable_shouldYield,W_=t.unstable_requestPaint,Ie=t.unstable_now,G_=t.unstable_getCurrentPriorityLevel,Sm=t.unstable_ImmediatePriority,Ax=t.unstable_UserBlockingPriority,Df=t.unstable_NormalPriority,X_=t.unstable_LowPriority,_x=t.unstable_IdlePriority,Ff=null,Es=null;function q_(i){if(Es&&typeof Es.onCommitFiberRoot=="function")try{Es.onCommitFiberRoot(Ff,i,void 0,(i.current.flags&128)===128)}catch{}}var Yi=Math.clz32?Math.clz32:Q_,Y_=Math.log,K_=Math.LN2;function Q_(i){return i>>>=0,i===0?32:31-(Y_(i)/K_|0)|0}var Of=64,jf=4194304;function $u(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function $f(i,r){var h=i.pendingLanes;if(h===0)return 0;var p=0,v=i.suspendedLanes,w=i.pingedLanes,T=h&268435455;if(T!==0){var D=T&~v;D!==0?p=$u(D):(w&=T,w!==0&&(p=$u(w)))}else T=h&~v,T!==0?p=$u(T):w!==0&&(p=$u(w));if(p===0)return 0;if(r!==0&&r!==p&&(r&v)===0&&(v=p&-p,w=r&-r,v>=w||v===16&&(w&4194240)!==0))return r;if((p&4)!==0&&(p|=h&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=p;0<r;)h=31-Yi(r),v=1<<h,p|=i[h],r&=~v;return p}function J_(i,r){switch(i){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Z_(i,r){for(var h=i.suspendedLanes,p=i.pingedLanes,v=i.expirationTimes,w=i.pendingLanes;0<w;){var T=31-Yi(w),D=1<<T,$=v[T];$===-1?((D&h)===0||(D&p)!==0)&&(v[T]=J_(D,r)):$<=r&&(i.expiredLanes|=D),w&=~D}}function Am(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Ex(){var i=Of;return Of<<=1,(Of&4194240)===0&&(Of=64),i}function _m(i){for(var r=[],h=0;31>h;h++)r.push(i);return r}function zu(i,r,h){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Yi(r),i[r]=h}function tE(i,r){var h=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var p=i.eventTimes;for(i=i.expirationTimes;0<h;){var v=31-Yi(h),w=1<<v;r[v]=0,p[v]=-1,i[v]=-1,h&=~w}}function Em(i,r){var h=i.entangledLanes|=r;for(i=i.entanglements;h;){var p=31-Yi(h),v=1<<p;v&r|i[p]&r&&(i[p]|=r),h&=~v}}var ae=0;function kx(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Cx,km,Tx,Px,Mx,Cm=!1,zf=[],Xr=null,qr=null,Yr=null,Hu=new Map,Bu=new Map,Kr=[],eE="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Rx(i,r){switch(i){case"focusin":case"focusout":Xr=null;break;case"dragenter":case"dragleave":qr=null;break;case"mouseover":case"mouseout":Yr=null;break;case"pointerover":case"pointerout":Hu.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bu.delete(r.pointerId)}}function Uu(i,r,h,p,v,w){return i===null||i.nativeEvent!==w?(i={blockedOn:r,domEventName:h,eventSystemFlags:p,nativeEvent:w,targetContainers:[v]},r!==null&&(r=ih(r),r!==null&&km(r)),i):(i.eventSystemFlags|=p,r=i.targetContainers,v!==null&&r.indexOf(v)===-1&&r.push(v),i)}function nE(i,r,h,p,v){switch(r){case"focusin":return Xr=Uu(Xr,i,r,h,p,v),!0;case"dragenter":return qr=Uu(qr,i,r,h,p,v),!0;case"mouseover":return Yr=Uu(Yr,i,r,h,p,v),!0;case"pointerover":var w=v.pointerId;return Hu.set(w,Uu(Hu.get(w)||null,i,r,h,p,v)),!0;case"gotpointercapture":return w=v.pointerId,Bu.set(w,Uu(Bu.get(w)||null,i,r,h,p,v)),!0}return!1}function Nx(i){var r=aa(i.target);if(r!==null){var h=oa(r);if(h!==null){if(r=h.tag,r===13){if(r=yx(h),r!==null){i.blockedOn=r,Mx(i.priority,function(){Tx(h)});return}}else if(r===3&&h.stateNode.current.memoizedState.isDehydrated){i.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Hf(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var h=Pm(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(h===null){h=i.nativeEvent;var p=new h.constructor(h.type,h);Vr=p,h.target.dispatchEvent(p),Vr=null}else return r=ih(h),r!==null&&km(r),i.blockedOn=h,!1;r.shift()}return!0}function Lx(i,r,h){Hf(i)&&h.delete(r)}function iE(){Cm=!1,Xr!==null&&Hf(Xr)&&(Xr=null),qr!==null&&Hf(qr)&&(qr=null),Yr!==null&&Hf(Yr)&&(Yr=null),Hu.forEach(Lx),Bu.forEach(Lx)}function Vu(i,r){i.blockedOn===r&&(i.blockedOn=null,Cm||(Cm=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,iE)))}function Wu(i){function r(v){return Vu(v,i)}if(0<zf.length){Vu(zf[0],i);for(var h=1;h<zf.length;h++){var p=zf[h];p.blockedOn===i&&(p.blockedOn=null)}}for(Xr!==null&&Vu(Xr,i),qr!==null&&Vu(qr,i),Yr!==null&&Vu(Yr,i),Hu.forEach(r),Bu.forEach(r),h=0;h<Kr.length;h++)p=Kr[h],p.blockedOn===i&&(p.blockedOn=null);for(;0<Kr.length&&(h=Kr[0],h.blockedOn===null);)Nx(h),h.blockedOn===null&&Kr.shift()}var zl=L.ReactCurrentBatchConfig,Bf=!0;function sE(i,r,h,p){var v=ae,w=zl.transition;zl.transition=null;try{ae=1,Tm(i,r,h,p)}finally{ae=v,zl.transition=w}}function rE(i,r,h,p){var v=ae,w=zl.transition;zl.transition=null;try{ae=4,Tm(i,r,h,p)}finally{ae=v,zl.transition=w}}function Tm(i,r,h,p){if(Bf){var v=Pm(i,r,h,p);if(v===null)Gm(i,r,p,Uf,h),Rx(i,p);else if(nE(v,i,r,h,p))p.stopPropagation();else if(Rx(i,p),r&4&&-1<eE.indexOf(i)){for(;v!==null;){var w=ih(v);if(w!==null&&Cx(w),w=Pm(i,r,h,p),w===null&&Gm(i,r,p,Uf,h),w===v)break;v=w}v!==null&&p.stopPropagation()}else Gm(i,r,p,null,h)}}var Uf=null;function Pm(i,r,h,p){if(Uf=null,i=ra(p),i=aa(i),i!==null)if(r=oa(i),r===null)i=null;else if(h=r.tag,h===13){if(i=yx(r),i!==null)return i;i=null}else if(h===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return Uf=i,null}function Ix(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(G_()){case Sm:return 1;case Ax:return 4;case Df:case X_:return 16;case _x:return 536870912;default:return 16}default:return 16}}var Qr=null,Mm=null,Vf=null;function Dx(){if(Vf)return Vf;var i,r=Mm,h=r.length,p,v="value"in Qr?Qr.value:Qr.textContent,w=v.length;for(i=0;i<h&&r[i]===v[i];i++);var T=h-i;for(p=1;p<=T&&r[h-p]===v[w-p];p++);return Vf=v.slice(i,1<p?1-p:void 0)}function Wf(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function Gf(){return!0}function Fx(){return!1}function li(i){function r(h,p,v,w,T){this._reactName=h,this._targetInst=v,this.type=p,this.nativeEvent=w,this.target=T,this.currentTarget=null;for(var D in i)i.hasOwnProperty(D)&&(h=i[D],this[D]=h?h(w):w[D]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?Gf:Fx,this.isPropagationStopped=Fx,this}return st(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=Gf)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=Gf)},persist:function(){},isPersistent:Gf}),r}var Hl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Rm=li(Hl),Gu=st({},Hl,{view:0,detail:0}),oE=li(Gu),Nm,Lm,Xu,Xf=st({},Gu,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Dm,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Xu&&(Xu&&i.type==="mousemove"?(Nm=i.screenX-Xu.screenX,Lm=i.screenY-Xu.screenY):Lm=Nm=0,Xu=i),Nm)},movementY:function(i){return"movementY"in i?i.movementY:Lm}}),Ox=li(Xf),aE=st({},Xf,{dataTransfer:0}),lE=li(aE),cE=st({},Gu,{relatedTarget:0}),Im=li(cE),uE=st({},Hl,{animationName:0,elapsedTime:0,pseudoElement:0}),hE=li(uE),dE=st({},Hl,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),fE=li(dE),pE=st({},Hl,{data:0}),jx=li(pE),gE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mE={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},yE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vE(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=yE[i])?!!r[i]:!1}function Dm(){return vE}var xE=st({},Gu,{key:function(i){if(i.key){var r=gE[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Wf(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?mE[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Dm,charCode:function(i){return i.type==="keypress"?Wf(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Wf(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),wE=li(xE),bE=st({},Xf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$x=li(bE),SE=st({},Gu,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Dm}),AE=li(SE),_E=st({},Hl,{propertyName:0,elapsedTime:0,pseudoElement:0}),EE=li(_E),kE=st({},Xf,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),CE=li(kE),TE=[9,13,27,32],Fm=c&&"CompositionEvent"in window,qu=null;c&&"documentMode"in document&&(qu=document.documentMode);var PE=c&&"TextEvent"in window&&!qu,zx=c&&(!Fm||qu&&8<qu&&11>=qu),Hx=" ",Bx=!1;function Ux(i,r){switch(i){case"keyup":return TE.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vx(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Bl=!1;function ME(i,r){switch(i){case"compositionend":return Vx(r);case"keypress":return r.which!==32?null:(Bx=!0,Hx);case"textInput":return i=r.data,i===Hx&&Bx?null:i;default:return null}}function RE(i,r){if(Bl)return i==="compositionend"||!Fm&&Ux(i,r)?(i=Dx(),Vf=Mm=Qr=null,Bl=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return zx&&r.locale!=="ko"?null:r.data;default:return null}}var NE={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wx(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!NE[i.type]:r==="textarea"}function Gx(i,r,h,p){Mf(p),r=Jf(r,"onChange"),0<r.length&&(h=new Rm("onChange","change",null,h,p),i.push({event:h,listeners:r}))}var Yu=null,Ku=null;function LE(i){uw(i,0)}function qf(i){var r=Xl(i);if(ue(r))return i}function IE(i,r){if(i==="change")return r}var Xx=!1;if(c){var Om;if(c){var jm="oninput"in document;if(!jm){var qx=document.createElement("div");qx.setAttribute("oninput","return;"),jm=typeof qx.oninput=="function"}Om=jm}else Om=!1;Xx=Om&&(!document.documentMode||9<document.documentMode)}function Yx(){Yu&&(Yu.detachEvent("onpropertychange",Kx),Ku=Yu=null)}function Kx(i){if(i.propertyName==="value"&&qf(Ku)){var r=[];Gx(r,Ku,i,ra(i)),Ht(LE,r)}}function DE(i,r,h){i==="focusin"?(Yx(),Yu=r,Ku=h,Yu.attachEvent("onpropertychange",Kx)):i==="focusout"&&Yx()}function FE(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return qf(Ku)}function OE(i,r){if(i==="click")return qf(r)}function jE(i,r){if(i==="input"||i==="change")return qf(r)}function $E(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var Ki=typeof Object.is=="function"?Object.is:$E;function Qu(i,r){if(Ki(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var h=Object.keys(i),p=Object.keys(r);if(h.length!==p.length)return!1;for(p=0;p<h.length;p++){var v=h[p];if(!d.call(r,v)||!Ki(i[v],r[v]))return!1}return!0}function Qx(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Jx(i,r){var h=Qx(i);i=0;for(var p;h;){if(h.nodeType===3){if(p=i+h.textContent.length,i<=r&&p>=r)return{node:h,offset:r-i};i=p}t:{for(;h;){if(h.nextSibling){h=h.nextSibling;break t}h=h.parentNode}h=void 0}h=Qx(h)}}function Zx(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Zx(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function tw(){for(var i=window,r=te();r instanceof i.HTMLIFrameElement;){try{var h=typeof r.contentWindow.location.href=="string"}catch{h=!1}if(h)i=r.contentWindow;else break;r=te(i.document)}return r}function $m(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function zE(i){var r=tw(),h=i.focusedElem,p=i.selectionRange;if(r!==h&&h&&h.ownerDocument&&Zx(h.ownerDocument.documentElement,h)){if(p!==null&&$m(h)){if(r=p.start,i=p.end,i===void 0&&(i=r),"selectionStart"in h)h.selectionStart=r,h.selectionEnd=Math.min(i,h.value.length);else if(i=(r=h.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var v=h.textContent.length,w=Math.min(p.start,v);p=p.end===void 0?w:Math.min(p.end,v),!i.extend&&w>p&&(v=p,p=w,w=v),v=Jx(h,w);var T=Jx(h,p);v&&T&&(i.rangeCount!==1||i.anchorNode!==v.node||i.anchorOffset!==v.offset||i.focusNode!==T.node||i.focusOffset!==T.offset)&&(r=r.createRange(),r.setStart(v.node,v.offset),i.removeAllRanges(),w>p?(i.addRange(r),i.extend(T.node,T.offset)):(r.setEnd(T.node,T.offset),i.addRange(r)))}}for(r=[],i=h;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<r.length;h++)i=r[h],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var HE=c&&"documentMode"in document&&11>=document.documentMode,Ul=null,zm=null,Ju=null,Hm=!1;function ew(i,r,h){var p=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Hm||Ul==null||Ul!==te(p)||(p=Ul,"selectionStart"in p&&$m(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Ju&&Qu(Ju,p)||(Ju=p,p=Jf(zm,"onSelect"),0<p.length&&(r=new Rm("onSelect","select",null,r,h),i.push({event:r,listeners:p}),r.target=Ul)))}function Yf(i,r){var h={};return h[i.toLowerCase()]=r.toLowerCase(),h["Webkit"+i]="webkit"+r,h["Moz"+i]="moz"+r,h}var Vl={animationend:Yf("Animation","AnimationEnd"),animationiteration:Yf("Animation","AnimationIteration"),animationstart:Yf("Animation","AnimationStart"),transitionend:Yf("Transition","TransitionEnd")},Bm={},nw={};c&&(nw=document.createElement("div").style,"AnimationEvent"in window||(delete Vl.animationend.animation,delete Vl.animationiteration.animation,delete Vl.animationstart.animation),"TransitionEvent"in window||delete Vl.transitionend.transition);function Kf(i){if(Bm[i])return Bm[i];if(!Vl[i])return i;var r=Vl[i],h;for(h in r)if(r.hasOwnProperty(h)&&h in nw)return Bm[i]=r[h];return i}var iw=Kf("animationend"),sw=Kf("animationiteration"),rw=Kf("animationstart"),ow=Kf("transitionend"),aw=new Map,lw="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Jr(i,r){aw.set(i,r),o(r,[i])}for(var Um=0;Um<lw.length;Um++){var Vm=lw[Um],BE=Vm.toLowerCase(),UE=Vm[0].toUpperCase()+Vm.slice(1);Jr(BE,"on"+UE)}Jr(iw,"onAnimationEnd"),Jr(sw,"onAnimationIteration"),Jr(rw,"onAnimationStart"),Jr("dblclick","onDoubleClick"),Jr("focusin","onFocus"),Jr("focusout","onBlur"),Jr(ow,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),VE=new Set("cancel close invalid load scroll toggle".split(" ").concat(Zu));function cw(i,r,h){var p=i.type||"unknown-event";i.currentTarget=h,B_(p,r,void 0,i),i.currentTarget=null}function uw(i,r){r=(r&4)!==0;for(var h=0;h<i.length;h++){var p=i[h],v=p.event;p=p.listeners;t:{var w=void 0;if(r)for(var T=p.length-1;0<=T;T--){var D=p[T],$=D.instance,Y=D.currentTarget;if(D=D.listener,$!==w&&v.isPropagationStopped())break t;cw(v,D,Y),w=$}else for(T=0;T<p.length;T++){if(D=p[T],$=D.instance,Y=D.currentTarget,D=D.listener,$!==w&&v.isPropagationStopped())break t;cw(v,D,Y),w=$}}}if(If)throw i=bm,If=!1,bm=null,i}function xe(i,r){var h=r[Jm];h===void 0&&(h=r[Jm]=new Set);var p=i+"__bubble";h.has(p)||(hw(r,i,2,!1),h.add(p))}function Wm(i,r,h){var p=0;r&&(p|=4),hw(h,i,p,r)}var Qf="_reactListening"+Math.random().toString(36).slice(2);function th(i){if(!i[Qf]){i[Qf]=!0,n.forEach(function(h){h!=="selectionchange"&&(VE.has(h)||Wm(h,!1,i),Wm(h,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Qf]||(r[Qf]=!0,Wm("selectionchange",!1,r))}}function hw(i,r,h,p){switch(Ix(r)){case 1:var v=sE;break;case 4:v=rE;break;default:v=Tm}h=v.bind(null,r,h,i),v=void 0,!_s||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(v=!0),p?v!==void 0?i.addEventListener(r,h,{capture:!0,passive:v}):i.addEventListener(r,h,!0):v!==void 0?i.addEventListener(r,h,{passive:v}):i.addEventListener(r,h,!1)}function Gm(i,r,h,p,v){var w=p;if((r&1)===0&&(r&2)===0&&p!==null)t:for(;;){if(p===null)return;var T=p.tag;if(T===3||T===4){var D=p.stateNode.containerInfo;if(D===v||D.nodeType===8&&D.parentNode===v)break;if(T===4)for(T=p.return;T!==null;){var $=T.tag;if(($===3||$===4)&&($=T.stateNode.containerInfo,$===v||$.nodeType===8&&$.parentNode===v))return;T=T.return}for(;D!==null;){if(T=aa(D),T===null)return;if($=T.tag,$===5||$===6){p=w=T;continue t}D=D.parentNode}}p=p.return}Ht(function(){var Y=w,it=ra(h),ot=[];t:{var et=aw.get(i);if(et!==void 0){var vt=Rm,Et=i;switch(i){case"keypress":if(Wf(h)===0)break t;case"keydown":case"keyup":vt=wE;break;case"focusin":Et="focus",vt=Im;break;case"focusout":Et="blur",vt=Im;break;case"beforeblur":case"afterblur":vt=Im;break;case"click":if(h.button===2)break t;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":vt=Ox;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":vt=lE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":vt=AE;break;case iw:case sw:case rw:vt=hE;break;case ow:vt=EE;break;case"scroll":vt=oE;break;case"wheel":vt=CE;break;case"copy":case"cut":case"paste":vt=fE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":vt=$x}var kt=(r&4)!==0,De=!kt&&i==="scroll",U=kt?et!==null?et+"Capture":null:et;kt=[];for(var z=Y,G;z!==null;){G=z;var ct=G.stateNode;if(G.tag===5&&ct!==null&&(G=ct,U!==null&&(ct=xn(z,U),ct!=null&&kt.push(eh(z,ct,G)))),De)break;z=z.return}0<kt.length&&(et=new vt(et,Et,null,h,it),ot.push({event:et,listeners:kt}))}}if((r&7)===0){t:{if(et=i==="mouseover"||i==="pointerover",vt=i==="mouseout"||i==="pointerout",et&&h!==Vr&&(Et=h.relatedTarget||h.fromElement)&&(aa(Et)||Et[Qs]))break t;if((vt||et)&&(et=it.window===it?it:(et=it.ownerDocument)?et.defaultView||et.parentWindow:window,vt?(Et=h.relatedTarget||h.toElement,vt=Y,Et=Et?aa(Et):null,Et!==null&&(De=oa(Et),Et!==De||Et.tag!==5&&Et.tag!==6)&&(Et=null)):(vt=null,Et=Y),vt!==Et)){if(kt=Ox,ct="onMouseLeave",U="onMouseEnter",z="mouse",(i==="pointerout"||i==="pointerover")&&(kt=$x,ct="onPointerLeave",U="onPointerEnter",z="pointer"),De=vt==null?et:Xl(vt),G=Et==null?et:Xl(Et),et=new kt(ct,z+"leave",vt,h,it),et.target=De,et.relatedTarget=G,ct=null,aa(it)===Y&&(kt=new kt(U,z+"enter",Et,h,it),kt.target=G,kt.relatedTarget=De,ct=kt),De=ct,vt&&Et)e:{for(kt=vt,U=Et,z=0,G=kt;G;G=Wl(G))z++;for(G=0,ct=U;ct;ct=Wl(ct))G++;for(;0<z-G;)kt=Wl(kt),z--;for(;0<G-z;)U=Wl(U),G--;for(;z--;){if(kt===U||U!==null&&kt===U.alternate)break e;kt=Wl(kt),U=Wl(U)}kt=null}else kt=null;vt!==null&&dw(ot,et,vt,kt,!1),Et!==null&&De!==null&&dw(ot,De,Et,kt,!0)}}t:{if(et=Y?Xl(Y):window,vt=et.nodeName&&et.nodeName.toLowerCase(),vt==="select"||vt==="input"&&et.type==="file")var Ct=IE;else if(Wx(et))if(Xx)Ct=jE;else{Ct=FE;var Rt=DE}else(vt=et.nodeName)&&vt.toLowerCase()==="input"&&(et.type==="checkbox"||et.type==="radio")&&(Ct=OE);if(Ct&&(Ct=Ct(i,Y))){Gx(ot,Ct,h,it);break t}Rt&&Rt(i,et,Y),i==="focusout"&&(Rt=et._wrapperState)&&Rt.controlled&&et.type==="number"&&Mi(et,"number",et.value)}switch(Rt=Y?Xl(Y):window,i){case"focusin":(Wx(Rt)||Rt.contentEditable==="true")&&(Ul=Rt,zm=Y,Ju=null);break;case"focusout":Ju=zm=Ul=null;break;case"mousedown":Hm=!0;break;case"contextmenu":case"mouseup":case"dragend":Hm=!1,ew(ot,h,it);break;case"selectionchange":if(HE)break;case"keydown":case"keyup":ew(ot,h,it)}var Nt;if(Fm)t:{switch(i){case"compositionstart":var Ot="onCompositionStart";break t;case"compositionend":Ot="onCompositionEnd";break t;case"compositionupdate":Ot="onCompositionUpdate";break t}Ot=void 0}else Bl?Ux(i,h)&&(Ot="onCompositionEnd"):i==="keydown"&&h.keyCode===229&&(Ot="onCompositionStart");Ot&&(zx&&h.locale!=="ko"&&(Bl||Ot!=="onCompositionStart"?Ot==="onCompositionEnd"&&Bl&&(Nt=Dx()):(Qr=it,Mm="value"in Qr?Qr.value:Qr.textContent,Bl=!0)),Rt=Jf(Y,Ot),0<Rt.length&&(Ot=new jx(Ot,i,null,h,it),ot.push({event:Ot,listeners:Rt}),Nt?Ot.data=Nt:(Nt=Vx(h),Nt!==null&&(Ot.data=Nt)))),(Nt=PE?ME(i,h):RE(i,h))&&(Y=Jf(Y,"onBeforeInput"),0<Y.length&&(it=new jx("onBeforeInput","beforeinput",null,h,it),ot.push({event:it,listeners:Y}),it.data=Nt))}uw(ot,r)})}function eh(i,r,h){return{instance:i,listener:r,currentTarget:h}}function Jf(i,r){for(var h=r+"Capture",p=[];i!==null;){var v=i,w=v.stateNode;v.tag===5&&w!==null&&(v=w,w=xn(i,h),w!=null&&p.unshift(eh(i,w,v)),w=xn(i,r),w!=null&&p.push(eh(i,w,v))),i=i.return}return p}function Wl(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function dw(i,r,h,p,v){for(var w=r._reactName,T=[];h!==null&&h!==p;){var D=h,$=D.alternate,Y=D.stateNode;if($!==null&&$===p)break;D.tag===5&&Y!==null&&(D=Y,v?($=xn(h,w),$!=null&&T.unshift(eh(h,$,D))):v||($=xn(h,w),$!=null&&T.push(eh(h,$,D)))),h=h.return}T.length!==0&&i.push({event:r,listeners:T})}var WE=/\r\n?/g,GE=/\u0000|\uFFFD/g;function fw(i){return(typeof i=="string"?i:""+i).replace(WE,`
38
+ `).replace(GE,"")}function Zf(i,r,h){if(r=fw(r),fw(i)!==r&&h)throw Error(e(425))}function tp(){}var Xm=null,qm=null;function Ym(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Km=typeof setTimeout=="function"?setTimeout:void 0,XE=typeof clearTimeout=="function"?clearTimeout:void 0,pw=typeof Promise=="function"?Promise:void 0,qE=typeof queueMicrotask=="function"?queueMicrotask:typeof pw<"u"?function(i){return pw.resolve(null).then(i).catch(YE)}:Km;function YE(i){setTimeout(function(){throw i})}function Qm(i,r){var h=r,p=0;do{var v=h.nextSibling;if(i.removeChild(h),v&&v.nodeType===8)if(h=v.data,h==="/$"){if(p===0){i.removeChild(v),Wu(r);return}p--}else h!=="$"&&h!=="$?"&&h!=="$!"||p++;h=v}while(h);Wu(r)}function Zr(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function gw(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var h=i.data;if(h==="$"||h==="$!"||h==="$?"){if(r===0)return i;r--}else h==="/$"&&r++}i=i.previousSibling}return null}var Gl=Math.random().toString(36).slice(2),ks="__reactFiber$"+Gl,nh="__reactProps$"+Gl,Qs="__reactContainer$"+Gl,Jm="__reactEvents$"+Gl,KE="__reactListeners$"+Gl,QE="__reactHandles$"+Gl;function aa(i){var r=i[ks];if(r)return r;for(var h=i.parentNode;h;){if(r=h[Qs]||h[ks]){if(h=r.alternate,r.child!==null||h!==null&&h.child!==null)for(i=gw(i);i!==null;){if(h=i[ks])return h;i=gw(i)}return r}i=h,h=i.parentNode}return null}function ih(i){return i=i[ks]||i[Qs],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Xl(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(e(33))}function ep(i){return i[nh]||null}var Zm=[],ql=-1;function to(i){return{current:i}}function we(i){0>ql||(i.current=Zm[ql],Zm[ql]=null,ql--)}function ge(i,r){ql++,Zm[ql]=i.current,i.current=r}var eo={},wn=to(eo),qn=to(!1),la=eo;function Yl(i,r){var h=i.type.contextTypes;if(!h)return eo;var p=i.stateNode;if(p&&p.__reactInternalMemoizedUnmaskedChildContext===r)return p.__reactInternalMemoizedMaskedChildContext;var v={},w;for(w in h)v[w]=r[w];return p&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=v),v}function Yn(i){return i=i.childContextTypes,i!=null}function np(){we(qn),we(wn)}function mw(i,r,h){if(wn.current!==eo)throw Error(e(168));ge(wn,r),ge(qn,h)}function yw(i,r,h){var p=i.stateNode;if(r=r.childContextTypes,typeof p.getChildContext!="function")return h;p=p.getChildContext();for(var v in p)if(!(v in r))throw Error(e(108,mt(i)||"Unknown",v));return st({},h,p)}function ip(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||eo,la=wn.current,ge(wn,i),ge(qn,qn.current),!0}function vw(i,r,h){var p=i.stateNode;if(!p)throw Error(e(169));h?(i=yw(i,r,la),p.__reactInternalMemoizedMergedChildContext=i,we(qn),we(wn),ge(wn,i)):we(qn),ge(qn,h)}var Js=null,sp=!1,t0=!1;function xw(i){Js===null?Js=[i]:Js.push(i)}function JE(i){sp=!0,xw(i)}function no(){if(!t0&&Js!==null){t0=!0;var i=0,r=ae;try{var h=Js;for(ae=1;i<h.length;i++){var p=h[i];do p=p(!0);while(p!==null)}Js=null,sp=!1}catch(v){throw Js!==null&&(Js=Js.slice(i+1)),bx(Sm,no),v}finally{ae=r,t0=!1}}return null}var Kl=[],Ql=0,rp=null,op=0,Ri=[],Ni=0,ca=null,Zs=1,tr="";function ua(i,r){Kl[Ql++]=op,Kl[Ql++]=rp,rp=i,op=r}function ww(i,r,h){Ri[Ni++]=Zs,Ri[Ni++]=tr,Ri[Ni++]=ca,ca=i;var p=Zs;i=tr;var v=32-Yi(p)-1;p&=~(1<<v),h+=1;var w=32-Yi(r)+v;if(30<w){var T=v-v%5;w=(p&(1<<T)-1).toString(32),p>>=T,v-=T,Zs=1<<32-Yi(r)+v|h<<v|p,tr=w+i}else Zs=1<<w|h<<v|p,tr=i}function e0(i){i.return!==null&&(ua(i,1),ww(i,1,0))}function n0(i){for(;i===rp;)rp=Kl[--Ql],Kl[Ql]=null,op=Kl[--Ql],Kl[Ql]=null;for(;i===ca;)ca=Ri[--Ni],Ri[Ni]=null,tr=Ri[--Ni],Ri[Ni]=null,Zs=Ri[--Ni],Ri[Ni]=null}var ci=null,ui=null,Se=!1,Qi=null;function bw(i,r){var h=Fi(5,null,null,0);h.elementType="DELETED",h.stateNode=r,h.return=i,r=i.deletions,r===null?(i.deletions=[h],i.flags|=16):r.push(h)}function Sw(i,r){switch(i.tag){case 5:var h=i.type;return r=r.nodeType!==1||h.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,ci=i,ui=Zr(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,ci=i,ui=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(h=ca!==null?{id:Zs,overflow:tr}:null,i.memoizedState={dehydrated:r,treeContext:h,retryLane:1073741824},h=Fi(18,null,null,0),h.stateNode=r,h.return=i,i.child=h,ci=i,ui=null,!0):!1;default:return!1}}function i0(i){return(i.mode&1)!==0&&(i.flags&128)===0}function s0(i){if(Se){var r=ui;if(r){var h=r;if(!Sw(i,r)){if(i0(i))throw Error(e(418));r=Zr(h.nextSibling);var p=ci;r&&Sw(i,r)?bw(p,h):(i.flags=i.flags&-4097|2,Se=!1,ci=i)}}else{if(i0(i))throw Error(e(418));i.flags=i.flags&-4097|2,Se=!1,ci=i}}}function Aw(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;ci=i}function ap(i){if(i!==ci)return!1;if(!Se)return Aw(i),Se=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Ym(i.type,i.memoizedProps)),r&&(r=ui)){if(i0(i))throw _w(),Error(e(418));for(;r;)bw(i,r),r=Zr(r.nextSibling)}if(Aw(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(e(317));t:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var h=i.data;if(h==="/$"){if(r===0){ui=Zr(i.nextSibling);break t}r--}else h!=="$"&&h!=="$!"&&h!=="$?"||r++}i=i.nextSibling}ui=null}}else ui=ci?Zr(i.stateNode.nextSibling):null;return!0}function _w(){for(var i=ui;i;)i=Zr(i.nextSibling)}function Jl(){ui=ci=null,Se=!1}function r0(i){Qi===null?Qi=[i]:Qi.push(i)}var ZE=L.ReactCurrentBatchConfig;function sh(i,r,h){if(i=h.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(h._owner){if(h=h._owner,h){if(h.tag!==1)throw Error(e(309));var p=h.stateNode}if(!p)throw Error(e(147,i));var v=p,w=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===w?r.ref:(r=function(T){var D=v.refs;T===null?delete D[w]:D[w]=T},r._stringRef=w,r)}if(typeof i!="string")throw Error(e(284));if(!h._owner)throw Error(e(290,i))}return i}function lp(i,r){throw i=Object.prototype.toString.call(r),Error(e(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function Ew(i){var r=i._init;return r(i._payload)}function kw(i){function r(U,z){if(i){var G=U.deletions;G===null?(U.deletions=[z],U.flags|=16):G.push(z)}}function h(U,z){if(!i)return null;for(;z!==null;)r(U,z),z=z.sibling;return null}function p(U,z){for(U=new Map;z!==null;)z.key!==null?U.set(z.key,z):U.set(z.index,z),z=z.sibling;return U}function v(U,z){return U=uo(U,z),U.index=0,U.sibling=null,U}function w(U,z,G){return U.index=G,i?(G=U.alternate,G!==null?(G=G.index,G<z?(U.flags|=2,z):G):(U.flags|=2,z)):(U.flags|=1048576,z)}function T(U){return i&&U.alternate===null&&(U.flags|=2),U}function D(U,z,G,ct){return z===null||z.tag!==6?(z=K0(G,U.mode,ct),z.return=U,z):(z=v(z,G),z.return=U,z)}function $(U,z,G,ct){var Ct=G.type;return Ct===O?it(U,z,G.props.children,ct,G.key):z!==null&&(z.elementType===Ct||typeof Ct=="object"&&Ct!==null&&Ct.$$typeof===Q&&Ew(Ct)===z.type)?(ct=v(z,G.props),ct.ref=sh(U,z,G),ct.return=U,ct):(ct=Np(G.type,G.key,G.props,null,U.mode,ct),ct.ref=sh(U,z,G),ct.return=U,ct)}function Y(U,z,G,ct){return z===null||z.tag!==4||z.stateNode.containerInfo!==G.containerInfo||z.stateNode.implementation!==G.implementation?(z=Q0(G,U.mode,ct),z.return=U,z):(z=v(z,G.children||[]),z.return=U,z)}function it(U,z,G,ct,Ct){return z===null||z.tag!==7?(z=va(G,U.mode,ct,Ct),z.return=U,z):(z=v(z,G),z.return=U,z)}function ot(U,z,G){if(typeof z=="string"&&z!==""||typeof z=="number")return z=K0(""+z,U.mode,G),z.return=U,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case R:return G=Np(z.type,z.key,z.props,null,U.mode,G),G.ref=sh(U,null,z),G.return=U,G;case j:return z=Q0(z,U.mode,G),z.return=U,z;case Q:var ct=z._init;return ot(U,ct(z._payload),G)}if(As(z)||at(z))return z=va(z,U.mode,G,null),z.return=U,z;lp(U,z)}return null}function et(U,z,G,ct){var Ct=z!==null?z.key:null;if(typeof G=="string"&&G!==""||typeof G=="number")return Ct!==null?null:D(U,z,""+G,ct);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case R:return G.key===Ct?$(U,z,G,ct):null;case j:return G.key===Ct?Y(U,z,G,ct):null;case Q:return Ct=G._init,et(U,z,Ct(G._payload),ct)}if(As(G)||at(G))return Ct!==null?null:it(U,z,G,ct,null);lp(U,G)}return null}function vt(U,z,G,ct,Ct){if(typeof ct=="string"&&ct!==""||typeof ct=="number")return U=U.get(G)||null,D(z,U,""+ct,Ct);if(typeof ct=="object"&&ct!==null){switch(ct.$$typeof){case R:return U=U.get(ct.key===null?G:ct.key)||null,$(z,U,ct,Ct);case j:return U=U.get(ct.key===null?G:ct.key)||null,Y(z,U,ct,Ct);case Q:var Rt=ct._init;return vt(U,z,G,Rt(ct._payload),Ct)}if(As(ct)||at(ct))return U=U.get(G)||null,it(z,U,ct,Ct,null);lp(z,ct)}return null}function Et(U,z,G,ct){for(var Ct=null,Rt=null,Nt=z,Ot=z=0,sn=null;Nt!==null&&Ot<G.length;Ot++){Nt.index>Ot?(sn=Nt,Nt=null):sn=Nt.sibling;var se=et(U,Nt,G[Ot],ct);if(se===null){Nt===null&&(Nt=sn);break}i&&Nt&&se.alternate===null&&r(U,Nt),z=w(se,z,Ot),Rt===null?Ct=se:Rt.sibling=se,Rt=se,Nt=sn}if(Ot===G.length)return h(U,Nt),Se&&ua(U,Ot),Ct;if(Nt===null){for(;Ot<G.length;Ot++)Nt=ot(U,G[Ot],ct),Nt!==null&&(z=w(Nt,z,Ot),Rt===null?Ct=Nt:Rt.sibling=Nt,Rt=Nt);return Se&&ua(U,Ot),Ct}for(Nt=p(U,Nt);Ot<G.length;Ot++)sn=vt(Nt,U,Ot,G[Ot],ct),sn!==null&&(i&&sn.alternate!==null&&Nt.delete(sn.key===null?Ot:sn.key),z=w(sn,z,Ot),Rt===null?Ct=sn:Rt.sibling=sn,Rt=sn);return i&&Nt.forEach(function(ho){return r(U,ho)}),Se&&ua(U,Ot),Ct}function kt(U,z,G,ct){var Ct=at(G);if(typeof Ct!="function")throw Error(e(150));if(G=Ct.call(G),G==null)throw Error(e(151));for(var Rt=Ct=null,Nt=z,Ot=z=0,sn=null,se=G.next();Nt!==null&&!se.done;Ot++,se=G.next()){Nt.index>Ot?(sn=Nt,Nt=null):sn=Nt.sibling;var ho=et(U,Nt,se.value,ct);if(ho===null){Nt===null&&(Nt=sn);break}i&&Nt&&ho.alternate===null&&r(U,Nt),z=w(ho,z,Ot),Rt===null?Ct=ho:Rt.sibling=ho,Rt=ho,Nt=sn}if(se.done)return h(U,Nt),Se&&ua(U,Ot),Ct;if(Nt===null){for(;!se.done;Ot++,se=G.next())se=ot(U,se.value,ct),se!==null&&(z=w(se,z,Ot),Rt===null?Ct=se:Rt.sibling=se,Rt=se);return Se&&ua(U,Ot),Ct}for(Nt=p(U,Nt);!se.done;Ot++,se=G.next())se=vt(Nt,U,Ot,se.value,ct),se!==null&&(i&&se.alternate!==null&&Nt.delete(se.key===null?Ot:se.key),z=w(se,z,Ot),Rt===null?Ct=se:Rt.sibling=se,Rt=se);return i&&Nt.forEach(function(Nk){return r(U,Nk)}),Se&&ua(U,Ot),Ct}function De(U,z,G,ct){if(typeof G=="object"&&G!==null&&G.type===O&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case R:t:{for(var Ct=G.key,Rt=z;Rt!==null;){if(Rt.key===Ct){if(Ct=G.type,Ct===O){if(Rt.tag===7){h(U,Rt.sibling),z=v(Rt,G.props.children),z.return=U,U=z;break t}}else if(Rt.elementType===Ct||typeof Ct=="object"&&Ct!==null&&Ct.$$typeof===Q&&Ew(Ct)===Rt.type){h(U,Rt.sibling),z=v(Rt,G.props),z.ref=sh(U,Rt,G),z.return=U,U=z;break t}h(U,Rt);break}else r(U,Rt);Rt=Rt.sibling}G.type===O?(z=va(G.props.children,U.mode,ct,G.key),z.return=U,U=z):(ct=Np(G.type,G.key,G.props,null,U.mode,ct),ct.ref=sh(U,z,G),ct.return=U,U=ct)}return T(U);case j:t:{for(Rt=G.key;z!==null;){if(z.key===Rt)if(z.tag===4&&z.stateNode.containerInfo===G.containerInfo&&z.stateNode.implementation===G.implementation){h(U,z.sibling),z=v(z,G.children||[]),z.return=U,U=z;break t}else{h(U,z);break}else r(U,z);z=z.sibling}z=Q0(G,U.mode,ct),z.return=U,U=z}return T(U);case Q:return Rt=G._init,De(U,z,Rt(G._payload),ct)}if(As(G))return Et(U,z,G,ct);if(at(G))return kt(U,z,G,ct);lp(U,G)}return typeof G=="string"&&G!==""||typeof G=="number"?(G=""+G,z!==null&&z.tag===6?(h(U,z.sibling),z=v(z,G),z.return=U,U=z):(h(U,z),z=K0(G,U.mode,ct),z.return=U,U=z),T(U)):h(U,z)}return De}var Zl=kw(!0),Cw=kw(!1),cp=to(null),up=null,tc=null,o0=null;function a0(){o0=tc=up=null}function l0(i){var r=cp.current;we(cp),i._currentValue=r}function c0(i,r,h){for(;i!==null;){var p=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,p!==null&&(p.childLanes|=r)):p!==null&&(p.childLanes&r)!==r&&(p.childLanes|=r),i===h)break;i=i.return}}function ec(i,r){up=i,o0=tc=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(Kn=!0),i.firstContext=null)}function Li(i){var r=i._currentValue;if(o0!==i)if(i={context:i,memoizedValue:r,next:null},tc===null){if(up===null)throw Error(e(308));tc=i,up.dependencies={lanes:0,firstContext:i}}else tc=tc.next=i;return r}var ha=null;function u0(i){ha===null?ha=[i]:ha.push(i)}function Tw(i,r,h,p){var v=r.interleaved;return v===null?(h.next=h,u0(r)):(h.next=v.next,v.next=h),r.interleaved=h,er(i,p)}function er(i,r){i.lanes|=r;var h=i.alternate;for(h!==null&&(h.lanes|=r),h=i,i=i.return;i!==null;)i.childLanes|=r,h=i.alternate,h!==null&&(h.childLanes|=r),h=i,i=i.return;return h.tag===3?h.stateNode:null}var io=!1;function h0(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pw(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function nr(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function so(i,r,h){var p=i.updateQueue;if(p===null)return null;if(p=p.shared,(ee&2)!==0){var v=p.pending;return v===null?r.next=r:(r.next=v.next,v.next=r),p.pending=r,er(i,h)}return v=p.interleaved,v===null?(r.next=r,u0(p)):(r.next=v.next,v.next=r),p.interleaved=r,er(i,h)}function hp(i,r,h){if(r=r.updateQueue,r!==null&&(r=r.shared,(h&4194240)!==0)){var p=r.lanes;p&=i.pendingLanes,h|=p,r.lanes=h,Em(i,h)}}function Mw(i,r){var h=i.updateQueue,p=i.alternate;if(p!==null&&(p=p.updateQueue,h===p)){var v=null,w=null;if(h=h.firstBaseUpdate,h!==null){do{var T={eventTime:h.eventTime,lane:h.lane,tag:h.tag,payload:h.payload,callback:h.callback,next:null};w===null?v=w=T:w=w.next=T,h=h.next}while(h!==null);w===null?v=w=r:w=w.next=r}else v=w=r;h={baseState:p.baseState,firstBaseUpdate:v,lastBaseUpdate:w,shared:p.shared,effects:p.effects},i.updateQueue=h;return}i=h.lastBaseUpdate,i===null?h.firstBaseUpdate=r:i.next=r,h.lastBaseUpdate=r}function dp(i,r,h,p){var v=i.updateQueue;io=!1;var w=v.firstBaseUpdate,T=v.lastBaseUpdate,D=v.shared.pending;if(D!==null){v.shared.pending=null;var $=D,Y=$.next;$.next=null,T===null?w=Y:T.next=Y,T=$;var it=i.alternate;it!==null&&(it=it.updateQueue,D=it.lastBaseUpdate,D!==T&&(D===null?it.firstBaseUpdate=Y:D.next=Y,it.lastBaseUpdate=$))}if(w!==null){var ot=v.baseState;T=0,it=Y=$=null,D=w;do{var et=D.lane,vt=D.eventTime;if((p&et)===et){it!==null&&(it=it.next={eventTime:vt,lane:0,tag:D.tag,payload:D.payload,callback:D.callback,next:null});t:{var Et=i,kt=D;switch(et=r,vt=h,kt.tag){case 1:if(Et=kt.payload,typeof Et=="function"){ot=Et.call(vt,ot,et);break t}ot=Et;break t;case 3:Et.flags=Et.flags&-65537|128;case 0:if(Et=kt.payload,et=typeof Et=="function"?Et.call(vt,ot,et):Et,et==null)break t;ot=st({},ot,et);break t;case 2:io=!0}}D.callback!==null&&D.lane!==0&&(i.flags|=64,et=v.effects,et===null?v.effects=[D]:et.push(D))}else vt={eventTime:vt,lane:et,tag:D.tag,payload:D.payload,callback:D.callback,next:null},it===null?(Y=it=vt,$=ot):it=it.next=vt,T|=et;if(D=D.next,D===null){if(D=v.shared.pending,D===null)break;et=D,D=et.next,et.next=null,v.lastBaseUpdate=et,v.shared.pending=null}}while(!0);if(it===null&&($=ot),v.baseState=$,v.firstBaseUpdate=Y,v.lastBaseUpdate=it,r=v.shared.interleaved,r!==null){v=r;do T|=v.lane,v=v.next;while(v!==r)}else w===null&&(v.shared.lanes=0);pa|=T,i.lanes=T,i.memoizedState=ot}}function Rw(i,r,h){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var p=i[r],v=p.callback;if(v!==null){if(p.callback=null,p=h,typeof v!="function")throw Error(e(191,v));v.call(p)}}}var rh={},Cs=to(rh),oh=to(rh),ah=to(rh);function da(i){if(i===rh)throw Error(e(174));return i}function d0(i,r){switch(ge(ah,r),ge(oh,i),ge(Cs,rh),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:ht(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=ht(r,i)}we(Cs),ge(Cs,r)}function nc(){we(Cs),we(oh),we(ah)}function Nw(i){da(ah.current);var r=da(Cs.current),h=ht(r,i.type);r!==h&&(ge(oh,i),ge(Cs,h))}function f0(i){oh.current===i&&(we(Cs),we(oh))}var Ce=to(0);function fp(i){for(var r=i;r!==null;){if(r.tag===13){var h=r.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||h.data==="$?"||h.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var p0=[];function g0(){for(var i=0;i<p0.length;i++)p0[i]._workInProgressVersionPrimary=null;p0.length=0}var pp=L.ReactCurrentDispatcher,m0=L.ReactCurrentBatchConfig,fa=0,Te=null,Xe=null,en=null,gp=!1,lh=!1,ch=0,tk=0;function bn(){throw Error(e(321))}function y0(i,r){if(r===null)return!1;for(var h=0;h<r.length&&h<i.length;h++)if(!Ki(i[h],r[h]))return!1;return!0}function v0(i,r,h,p,v,w){if(fa=w,Te=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,pp.current=i===null||i.memoizedState===null?sk:rk,i=h(p,v),lh){w=0;do{if(lh=!1,ch=0,25<=w)throw Error(e(301));w+=1,en=Xe=null,r.updateQueue=null,pp.current=ok,i=h(p,v)}while(lh)}if(pp.current=vp,r=Xe!==null&&Xe.next!==null,fa=0,en=Xe=Te=null,gp=!1,r)throw Error(e(300));return i}function x0(){var i=ch!==0;return ch=0,i}function Ts(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return en===null?Te.memoizedState=en=i:en=en.next=i,en}function Ii(){if(Xe===null){var i=Te.alternate;i=i!==null?i.memoizedState:null}else i=Xe.next;var r=en===null?Te.memoizedState:en.next;if(r!==null)en=r,Xe=i;else{if(i===null)throw Error(e(310));Xe=i,i={memoizedState:Xe.memoizedState,baseState:Xe.baseState,baseQueue:Xe.baseQueue,queue:Xe.queue,next:null},en===null?Te.memoizedState=en=i:en=en.next=i}return en}function uh(i,r){return typeof r=="function"?r(i):r}function w0(i){var r=Ii(),h=r.queue;if(h===null)throw Error(e(311));h.lastRenderedReducer=i;var p=Xe,v=p.baseQueue,w=h.pending;if(w!==null){if(v!==null){var T=v.next;v.next=w.next,w.next=T}p.baseQueue=v=w,h.pending=null}if(v!==null){w=v.next,p=p.baseState;var D=T=null,$=null,Y=w;do{var it=Y.lane;if((fa&it)===it)$!==null&&($=$.next={lane:0,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),p=Y.hasEagerState?Y.eagerState:i(p,Y.action);else{var ot={lane:it,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null};$===null?(D=$=ot,T=p):$=$.next=ot,Te.lanes|=it,pa|=it}Y=Y.next}while(Y!==null&&Y!==w);$===null?T=p:$.next=D,Ki(p,r.memoizedState)||(Kn=!0),r.memoizedState=p,r.baseState=T,r.baseQueue=$,h.lastRenderedState=p}if(i=h.interleaved,i!==null){v=i;do w=v.lane,Te.lanes|=w,pa|=w,v=v.next;while(v!==i)}else v===null&&(h.lanes=0);return[r.memoizedState,h.dispatch]}function b0(i){var r=Ii(),h=r.queue;if(h===null)throw Error(e(311));h.lastRenderedReducer=i;var p=h.dispatch,v=h.pending,w=r.memoizedState;if(v!==null){h.pending=null;var T=v=v.next;do w=i(w,T.action),T=T.next;while(T!==v);Ki(w,r.memoizedState)||(Kn=!0),r.memoizedState=w,r.baseQueue===null&&(r.baseState=w),h.lastRenderedState=w}return[w,p]}function Lw(){}function Iw(i,r){var h=Te,p=Ii(),v=r(),w=!Ki(p.memoizedState,v);if(w&&(p.memoizedState=v,Kn=!0),p=p.queue,S0(Ow.bind(null,h,p,i),[i]),p.getSnapshot!==r||w||en!==null&&en.memoizedState.tag&1){if(h.flags|=2048,hh(9,Fw.bind(null,h,p,v,r),void 0,null),nn===null)throw Error(e(349));(fa&30)!==0||Dw(h,r,v)}return v}function Dw(i,r,h){i.flags|=16384,i={getSnapshot:r,value:h},r=Te.updateQueue,r===null?(r={lastEffect:null,stores:null},Te.updateQueue=r,r.stores=[i]):(h=r.stores,h===null?r.stores=[i]:h.push(i))}function Fw(i,r,h,p){r.value=h,r.getSnapshot=p,jw(r)&&$w(i)}function Ow(i,r,h){return h(function(){jw(r)&&$w(i)})}function jw(i){var r=i.getSnapshot;i=i.value;try{var h=r();return!Ki(i,h)}catch{return!0}}function $w(i){var r=er(i,1);r!==null&&es(r,i,1,-1)}function zw(i){var r=Ts();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:uh,lastRenderedState:i},r.queue=i,i=i.dispatch=ik.bind(null,Te,i),[r.memoizedState,i]}function hh(i,r,h,p){return i={tag:i,create:r,destroy:h,deps:p,next:null},r=Te.updateQueue,r===null?(r={lastEffect:null,stores:null},Te.updateQueue=r,r.lastEffect=i.next=i):(h=r.lastEffect,h===null?r.lastEffect=i.next=i:(p=h.next,h.next=i,i.next=p,r.lastEffect=i)),i}function Hw(){return Ii().memoizedState}function mp(i,r,h,p){var v=Ts();Te.flags|=i,v.memoizedState=hh(1|r,h,void 0,p===void 0?null:p)}function yp(i,r,h,p){var v=Ii();p=p===void 0?null:p;var w=void 0;if(Xe!==null){var T=Xe.memoizedState;if(w=T.destroy,p!==null&&y0(p,T.deps)){v.memoizedState=hh(r,h,w,p);return}}Te.flags|=i,v.memoizedState=hh(1|r,h,w,p)}function Bw(i,r){return mp(8390656,8,i,r)}function S0(i,r){return yp(2048,8,i,r)}function Uw(i,r){return yp(4,2,i,r)}function Vw(i,r){return yp(4,4,i,r)}function Ww(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function Gw(i,r,h){return h=h!=null?h.concat([i]):null,yp(4,4,Ww.bind(null,r,i),h)}function A0(){}function Xw(i,r){var h=Ii();r=r===void 0?null:r;var p=h.memoizedState;return p!==null&&r!==null&&y0(r,p[1])?p[0]:(h.memoizedState=[i,r],i)}function qw(i,r){var h=Ii();r=r===void 0?null:r;var p=h.memoizedState;return p!==null&&r!==null&&y0(r,p[1])?p[0]:(i=i(),h.memoizedState=[i,r],i)}function Yw(i,r,h){return(fa&21)===0?(i.baseState&&(i.baseState=!1,Kn=!0),i.memoizedState=h):(Ki(h,r)||(h=Ex(),Te.lanes|=h,pa|=h,i.baseState=!0),r)}function ek(i,r){var h=ae;ae=h!==0&&4>h?h:4,i(!0);var p=m0.transition;m0.transition={};try{i(!1),r()}finally{ae=h,m0.transition=p}}function Kw(){return Ii().memoizedState}function nk(i,r,h){var p=lo(i);if(h={lane:p,action:h,hasEagerState:!1,eagerState:null,next:null},Qw(i))Jw(r,h);else if(h=Tw(i,r,h,p),h!==null){var v=jn();es(h,i,p,v),Zw(h,r,p)}}function ik(i,r,h){var p=lo(i),v={lane:p,action:h,hasEagerState:!1,eagerState:null,next:null};if(Qw(i))Jw(r,v);else{var w=i.alternate;if(i.lanes===0&&(w===null||w.lanes===0)&&(w=r.lastRenderedReducer,w!==null))try{var T=r.lastRenderedState,D=w(T,h);if(v.hasEagerState=!0,v.eagerState=D,Ki(D,T)){var $=r.interleaved;$===null?(v.next=v,u0(r)):(v.next=$.next,$.next=v),r.interleaved=v;return}}catch{}finally{}h=Tw(i,r,v,p),h!==null&&(v=jn(),es(h,i,p,v),Zw(h,r,p))}}function Qw(i){var r=i.alternate;return i===Te||r!==null&&r===Te}function Jw(i,r){lh=gp=!0;var h=i.pending;h===null?r.next=r:(r.next=h.next,h.next=r),i.pending=r}function Zw(i,r,h){if((h&4194240)!==0){var p=r.lanes;p&=i.pendingLanes,h|=p,r.lanes=h,Em(i,h)}}var vp={readContext:Li,useCallback:bn,useContext:bn,useEffect:bn,useImperativeHandle:bn,useInsertionEffect:bn,useLayoutEffect:bn,useMemo:bn,useReducer:bn,useRef:bn,useState:bn,useDebugValue:bn,useDeferredValue:bn,useTransition:bn,useMutableSource:bn,useSyncExternalStore:bn,useId:bn,unstable_isNewReconciler:!1},sk={readContext:Li,useCallback:function(i,r){return Ts().memoizedState=[i,r===void 0?null:r],i},useContext:Li,useEffect:Bw,useImperativeHandle:function(i,r,h){return h=h!=null?h.concat([i]):null,mp(4194308,4,Ww.bind(null,r,i),h)},useLayoutEffect:function(i,r){return mp(4194308,4,i,r)},useInsertionEffect:function(i,r){return mp(4,2,i,r)},useMemo:function(i,r){var h=Ts();return r=r===void 0?null:r,i=i(),h.memoizedState=[i,r],i},useReducer:function(i,r,h){var p=Ts();return r=h!==void 0?h(r):r,p.memoizedState=p.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},p.queue=i,i=i.dispatch=nk.bind(null,Te,i),[p.memoizedState,i]},useRef:function(i){var r=Ts();return i={current:i},r.memoizedState=i},useState:zw,useDebugValue:A0,useDeferredValue:function(i){return Ts().memoizedState=i},useTransition:function(){var i=zw(!1),r=i[0];return i=ek.bind(null,i[1]),Ts().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,h){var p=Te,v=Ts();if(Se){if(h===void 0)throw Error(e(407));h=h()}else{if(h=r(),nn===null)throw Error(e(349));(fa&30)!==0||Dw(p,r,h)}v.memoizedState=h;var w={value:h,getSnapshot:r};return v.queue=w,Bw(Ow.bind(null,p,w,i),[i]),p.flags|=2048,hh(9,Fw.bind(null,p,w,h,r),void 0,null),h},useId:function(){var i=Ts(),r=nn.identifierPrefix;if(Se){var h=tr,p=Zs;h=(p&~(1<<32-Yi(p)-1)).toString(32)+h,r=":"+r+"R"+h,h=ch++,0<h&&(r+="H"+h.toString(32)),r+=":"}else h=tk++,r=":"+r+"r"+h.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},rk={readContext:Li,useCallback:Xw,useContext:Li,useEffect:S0,useImperativeHandle:Gw,useInsertionEffect:Uw,useLayoutEffect:Vw,useMemo:qw,useReducer:w0,useRef:Hw,useState:function(){return w0(uh)},useDebugValue:A0,useDeferredValue:function(i){var r=Ii();return Yw(r,Xe.memoizedState,i)},useTransition:function(){var i=w0(uh)[0],r=Ii().memoizedState;return[i,r]},useMutableSource:Lw,useSyncExternalStore:Iw,useId:Kw,unstable_isNewReconciler:!1},ok={readContext:Li,useCallback:Xw,useContext:Li,useEffect:S0,useImperativeHandle:Gw,useInsertionEffect:Uw,useLayoutEffect:Vw,useMemo:qw,useReducer:b0,useRef:Hw,useState:function(){return b0(uh)},useDebugValue:A0,useDeferredValue:function(i){var r=Ii();return Xe===null?r.memoizedState=i:Yw(r,Xe.memoizedState,i)},useTransition:function(){var i=b0(uh)[0],r=Ii().memoizedState;return[i,r]},useMutableSource:Lw,useSyncExternalStore:Iw,useId:Kw,unstable_isNewReconciler:!1};function Ji(i,r){if(i&&i.defaultProps){r=st({},r),i=i.defaultProps;for(var h in i)r[h]===void 0&&(r[h]=i[h]);return r}return r}function _0(i,r,h,p){r=i.memoizedState,h=h(p,r),h=h==null?r:st({},r,h),i.memoizedState=h,i.lanes===0&&(i.updateQueue.baseState=h)}var xp={isMounted:function(i){return(i=i._reactInternals)?oa(i)===i:!1},enqueueSetState:function(i,r,h){i=i._reactInternals;var p=jn(),v=lo(i),w=nr(p,v);w.payload=r,h!=null&&(w.callback=h),r=so(i,w,v),r!==null&&(es(r,i,v,p),hp(r,i,v))},enqueueReplaceState:function(i,r,h){i=i._reactInternals;var p=jn(),v=lo(i),w=nr(p,v);w.tag=1,w.payload=r,h!=null&&(w.callback=h),r=so(i,w,v),r!==null&&(es(r,i,v,p),hp(r,i,v))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var h=jn(),p=lo(i),v=nr(h,p);v.tag=2,r!=null&&(v.callback=r),r=so(i,v,p),r!==null&&(es(r,i,p,h),hp(r,i,p))}};function t1(i,r,h,p,v,w,T){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(p,w,T):r.prototype&&r.prototype.isPureReactComponent?!Qu(h,p)||!Qu(v,w):!0}function e1(i,r,h){var p=!1,v=eo,w=r.contextType;return typeof w=="object"&&w!==null?w=Li(w):(v=Yn(r)?la:wn.current,p=r.contextTypes,w=(p=p!=null)?Yl(i,v):eo),r=new r(h,w),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=xp,i.stateNode=r,r._reactInternals=i,p&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=v,i.__reactInternalMemoizedMaskedChildContext=w),r}function n1(i,r,h,p){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(h,p),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(h,p),r.state!==i&&xp.enqueueReplaceState(r,r.state,null)}function E0(i,r,h,p){var v=i.stateNode;v.props=h,v.state=i.memoizedState,v.refs={},h0(i);var w=r.contextType;typeof w=="object"&&w!==null?v.context=Li(w):(w=Yn(r)?la:wn.current,v.context=Yl(i,w)),v.state=i.memoizedState,w=r.getDerivedStateFromProps,typeof w=="function"&&(_0(i,r,w,h),v.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(r=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),r!==v.state&&xp.enqueueReplaceState(v,v.state,null),dp(i,h,v,p),v.state=i.memoizedState),typeof v.componentDidMount=="function"&&(i.flags|=4194308)}function ic(i,r){try{var h="",p=r;do h+=rt(p),p=p.return;while(p);var v=h}catch(w){v=`
39
+ Error generating stack: `+w.message+`
40
+ `+w.stack}return{value:i,source:r,stack:v,digest:null}}function k0(i,r,h){return{value:i,source:null,stack:h??null,digest:r??null}}function C0(i,r){try{console.error(r.value)}catch(h){setTimeout(function(){throw h})}}var ak=typeof WeakMap=="function"?WeakMap:Map;function i1(i,r,h){h=nr(-1,h),h.tag=3,h.payload={element:null};var p=r.value;return h.callback=function(){kp||(kp=!0,B0=p),C0(i,r)},h}function s1(i,r,h){h=nr(-1,h),h.tag=3;var p=i.type.getDerivedStateFromError;if(typeof p=="function"){var v=r.value;h.payload=function(){return p(v)},h.callback=function(){C0(i,r)}}var w=i.stateNode;return w!==null&&typeof w.componentDidCatch=="function"&&(h.callback=function(){C0(i,r),typeof p!="function"&&(oo===null?oo=new Set([this]):oo.add(this));var T=r.stack;this.componentDidCatch(r.value,{componentStack:T!==null?T:""})}),h}function r1(i,r,h){var p=i.pingCache;if(p===null){p=i.pingCache=new ak;var v=new Set;p.set(r,v)}else v=p.get(r),v===void 0&&(v=new Set,p.set(r,v));v.has(h)||(v.add(h),i=bk.bind(null,i,r,h),r.then(i,i))}function o1(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function a1(i,r,h,p,v){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,h.flags|=131072,h.flags&=-52805,h.tag===1&&(h.alternate===null?h.tag=17:(r=nr(-1,1),r.tag=2,so(h,r,1))),h.lanes|=1),i):(i.flags|=65536,i.lanes=v,i)}var lk=L.ReactCurrentOwner,Kn=!1;function On(i,r,h,p){r.child=i===null?Cw(r,null,h,p):Zl(r,i.child,h,p)}function l1(i,r,h,p,v){h=h.render;var w=r.ref;return ec(r,v),p=v0(i,r,h,p,w,v),h=x0(),i!==null&&!Kn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~v,ir(i,r,v)):(Se&&h&&e0(r),r.flags|=1,On(i,r,p,v),r.child)}function c1(i,r,h,p,v){if(i===null){var w=h.type;return typeof w=="function"&&!Y0(w)&&w.defaultProps===void 0&&h.compare===null&&h.defaultProps===void 0?(r.tag=15,r.type=w,u1(i,r,w,p,v)):(i=Np(h.type,null,p,r,r.mode,v),i.ref=r.ref,i.return=r,r.child=i)}if(w=i.child,(i.lanes&v)===0){var T=w.memoizedProps;if(h=h.compare,h=h!==null?h:Qu,h(T,p)&&i.ref===r.ref)return ir(i,r,v)}return r.flags|=1,i=uo(w,p),i.ref=r.ref,i.return=r,r.child=i}function u1(i,r,h,p,v){if(i!==null){var w=i.memoizedProps;if(Qu(w,p)&&i.ref===r.ref)if(Kn=!1,r.pendingProps=p=w,(i.lanes&v)!==0)(i.flags&131072)!==0&&(Kn=!0);else return r.lanes=i.lanes,ir(i,r,v)}return T0(i,r,h,p,v)}function h1(i,r,h){var p=r.pendingProps,v=p.children,w=i!==null?i.memoizedState:null;if(p.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},ge(rc,hi),hi|=h;else{if((h&1073741824)===0)return i=w!==null?w.baseLanes|h:h,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,ge(rc,hi),hi|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},p=w!==null?w.baseLanes:h,ge(rc,hi),hi|=p}else w!==null?(p=w.baseLanes|h,r.memoizedState=null):p=h,ge(rc,hi),hi|=p;return On(i,r,v,h),r.child}function d1(i,r){var h=r.ref;(i===null&&h!==null||i!==null&&i.ref!==h)&&(r.flags|=512,r.flags|=2097152)}function T0(i,r,h,p,v){var w=Yn(h)?la:wn.current;return w=Yl(r,w),ec(r,v),h=v0(i,r,h,p,w,v),p=x0(),i!==null&&!Kn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~v,ir(i,r,v)):(Se&&p&&e0(r),r.flags|=1,On(i,r,h,v),r.child)}function f1(i,r,h,p,v){if(Yn(h)){var w=!0;ip(r)}else w=!1;if(ec(r,v),r.stateNode===null)bp(i,r),e1(r,h,p),E0(r,h,p,v),p=!0;else if(i===null){var T=r.stateNode,D=r.memoizedProps;T.props=D;var $=T.context,Y=h.contextType;typeof Y=="object"&&Y!==null?Y=Li(Y):(Y=Yn(h)?la:wn.current,Y=Yl(r,Y));var it=h.getDerivedStateFromProps,ot=typeof it=="function"||typeof T.getSnapshotBeforeUpdate=="function";ot||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(D!==p||$!==Y)&&n1(r,T,p,Y),io=!1;var et=r.memoizedState;T.state=et,dp(r,p,T,v),$=r.memoizedState,D!==p||et!==$||qn.current||io?(typeof it=="function"&&(_0(r,h,it,p),$=r.memoizedState),(D=io||t1(r,h,D,p,et,$,Y))?(ot||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(r.flags|=4194308)):(typeof T.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=p,r.memoizedState=$),T.props=p,T.state=$,T.context=Y,p=D):(typeof T.componentDidMount=="function"&&(r.flags|=4194308),p=!1)}else{T=r.stateNode,Pw(i,r),D=r.memoizedProps,Y=r.type===r.elementType?D:Ji(r.type,D),T.props=Y,ot=r.pendingProps,et=T.context,$=h.contextType,typeof $=="object"&&$!==null?$=Li($):($=Yn(h)?la:wn.current,$=Yl(r,$));var vt=h.getDerivedStateFromProps;(it=typeof vt=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(D!==ot||et!==$)&&n1(r,T,p,$),io=!1,et=r.memoizedState,T.state=et,dp(r,p,T,v);var Et=r.memoizedState;D!==ot||et!==Et||qn.current||io?(typeof vt=="function"&&(_0(r,h,vt,p),Et=r.memoizedState),(Y=io||t1(r,h,Y,p,et,Et,$)||!1)?(it||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(p,Et,$),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(p,Et,$)),typeof T.componentDidUpdate=="function"&&(r.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof T.componentDidUpdate!="function"||D===i.memoizedProps&&et===i.memoizedState||(r.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||D===i.memoizedProps&&et===i.memoizedState||(r.flags|=1024),r.memoizedProps=p,r.memoizedState=Et),T.props=p,T.state=Et,T.context=$,p=Y):(typeof T.componentDidUpdate!="function"||D===i.memoizedProps&&et===i.memoizedState||(r.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||D===i.memoizedProps&&et===i.memoizedState||(r.flags|=1024),p=!1)}return P0(i,r,h,p,w,v)}function P0(i,r,h,p,v,w){d1(i,r);var T=(r.flags&128)!==0;if(!p&&!T)return v&&vw(r,h,!1),ir(i,r,w);p=r.stateNode,lk.current=r;var D=T&&typeof h.getDerivedStateFromError!="function"?null:p.render();return r.flags|=1,i!==null&&T?(r.child=Zl(r,i.child,null,w),r.child=Zl(r,null,D,w)):On(i,r,D,w),r.memoizedState=p.state,v&&vw(r,h,!0),r.child}function p1(i){var r=i.stateNode;r.pendingContext?mw(i,r.pendingContext,r.pendingContext!==r.context):r.context&&mw(i,r.context,!1),d0(i,r.containerInfo)}function g1(i,r,h,p,v){return Jl(),r0(v),r.flags|=256,On(i,r,h,p),r.child}var M0={dehydrated:null,treeContext:null,retryLane:0};function R0(i){return{baseLanes:i,cachePool:null,transitions:null}}function m1(i,r,h){var p=r.pendingProps,v=Ce.current,w=!1,T=(r.flags&128)!==0,D;if((D=T)||(D=i!==null&&i.memoizedState===null?!1:(v&2)!==0),D?(w=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(v|=1),ge(Ce,v&1),i===null)return s0(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(T=p.children,i=p.fallback,w?(p=r.mode,w=r.child,T={mode:"hidden",children:T},(p&1)===0&&w!==null?(w.childLanes=0,w.pendingProps=T):w=Lp(T,p,0,null),i=va(i,p,h,null),w.return=r,i.return=r,w.sibling=i,r.child=w,r.child.memoizedState=R0(h),r.memoizedState=M0,i):N0(r,T));if(v=i.memoizedState,v!==null&&(D=v.dehydrated,D!==null))return ck(i,r,T,p,D,v,h);if(w){w=p.fallback,T=r.mode,v=i.child,D=v.sibling;var $={mode:"hidden",children:p.children};return(T&1)===0&&r.child!==v?(p=r.child,p.childLanes=0,p.pendingProps=$,r.deletions=null):(p=uo(v,$),p.subtreeFlags=v.subtreeFlags&14680064),D!==null?w=uo(D,w):(w=va(w,T,h,null),w.flags|=2),w.return=r,p.return=r,p.sibling=w,r.child=p,p=w,w=r.child,T=i.child.memoizedState,T=T===null?R0(h):{baseLanes:T.baseLanes|h,cachePool:null,transitions:T.transitions},w.memoizedState=T,w.childLanes=i.childLanes&~h,r.memoizedState=M0,p}return w=i.child,i=w.sibling,p=uo(w,{mode:"visible",children:p.children}),(r.mode&1)===0&&(p.lanes=h),p.return=r,p.sibling=null,i!==null&&(h=r.deletions,h===null?(r.deletions=[i],r.flags|=16):h.push(i)),r.child=p,r.memoizedState=null,p}function N0(i,r){return r=Lp({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function wp(i,r,h,p){return p!==null&&r0(p),Zl(r,i.child,null,h),i=N0(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function ck(i,r,h,p,v,w,T){if(h)return r.flags&256?(r.flags&=-257,p=k0(Error(e(422))),wp(i,r,T,p)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(w=p.fallback,v=r.mode,p=Lp({mode:"visible",children:p.children},v,0,null),w=va(w,v,T,null),w.flags|=2,p.return=r,w.return=r,p.sibling=w,r.child=p,(r.mode&1)!==0&&Zl(r,i.child,null,T),r.child.memoizedState=R0(T),r.memoizedState=M0,w);if((r.mode&1)===0)return wp(i,r,T,null);if(v.data==="$!"){if(p=v.nextSibling&&v.nextSibling.dataset,p)var D=p.dgst;return p=D,w=Error(e(419)),p=k0(w,p,void 0),wp(i,r,T,p)}if(D=(T&i.childLanes)!==0,Kn||D){if(p=nn,p!==null){switch(T&-T){case 4:v=2;break;case 16:v=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(p.suspendedLanes|T))!==0?0:v,v!==0&&v!==w.retryLane&&(w.retryLane=v,er(i,v),es(p,i,v,-1))}return q0(),p=k0(Error(e(421))),wp(i,r,T,p)}return v.data==="$?"?(r.flags|=128,r.child=i.child,r=Sk.bind(null,i),v._reactRetry=r,null):(i=w.treeContext,ui=Zr(v.nextSibling),ci=r,Se=!0,Qi=null,i!==null&&(Ri[Ni++]=Zs,Ri[Ni++]=tr,Ri[Ni++]=ca,Zs=i.id,tr=i.overflow,ca=r),r=N0(r,p.children),r.flags|=4096,r)}function y1(i,r,h){i.lanes|=r;var p=i.alternate;p!==null&&(p.lanes|=r),c0(i.return,r,h)}function L0(i,r,h,p,v){var w=i.memoizedState;w===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:p,tail:h,tailMode:v}:(w.isBackwards=r,w.rendering=null,w.renderingStartTime=0,w.last=p,w.tail=h,w.tailMode=v)}function v1(i,r,h){var p=r.pendingProps,v=p.revealOrder,w=p.tail;if(On(i,r,p.children,h),p=Ce.current,(p&2)!==0)p=p&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)t:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&y1(i,h,r);else if(i.tag===19)y1(i,h,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break t;for(;i.sibling===null;){if(i.return===null||i.return===r)break t;i=i.return}i.sibling.return=i.return,i=i.sibling}p&=1}if(ge(Ce,p),(r.mode&1)===0)r.memoizedState=null;else switch(v){case"forwards":for(h=r.child,v=null;h!==null;)i=h.alternate,i!==null&&fp(i)===null&&(v=h),h=h.sibling;h=v,h===null?(v=r.child,r.child=null):(v=h.sibling,h.sibling=null),L0(r,!1,v,h,w);break;case"backwards":for(h=null,v=r.child,r.child=null;v!==null;){if(i=v.alternate,i!==null&&fp(i)===null){r.child=v;break}i=v.sibling,v.sibling=h,h=v,v=i}L0(r,!0,h,null,w);break;case"together":L0(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function bp(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function ir(i,r,h){if(i!==null&&(r.dependencies=i.dependencies),pa|=r.lanes,(h&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(e(153));if(r.child!==null){for(i=r.child,h=uo(i,i.pendingProps),r.child=h,h.return=r;i.sibling!==null;)i=i.sibling,h=h.sibling=uo(i,i.pendingProps),h.return=r;h.sibling=null}return r.child}function uk(i,r,h){switch(r.tag){case 3:p1(r),Jl();break;case 5:Nw(r);break;case 1:Yn(r.type)&&ip(r);break;case 4:d0(r,r.stateNode.containerInfo);break;case 10:var p=r.type._context,v=r.memoizedProps.value;ge(cp,p._currentValue),p._currentValue=v;break;case 13:if(p=r.memoizedState,p!==null)return p.dehydrated!==null?(ge(Ce,Ce.current&1),r.flags|=128,null):(h&r.child.childLanes)!==0?m1(i,r,h):(ge(Ce,Ce.current&1),i=ir(i,r,h),i!==null?i.sibling:null);ge(Ce,Ce.current&1);break;case 19:if(p=(h&r.childLanes)!==0,(i.flags&128)!==0){if(p)return v1(i,r,h);r.flags|=128}if(v=r.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),ge(Ce,Ce.current),p)break;return null;case 22:case 23:return r.lanes=0,h1(i,r,h)}return ir(i,r,h)}var x1,I0,w1,b1;x1=function(i,r){for(var h=r.child;h!==null;){if(h.tag===5||h.tag===6)i.appendChild(h.stateNode);else if(h.tag!==4&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===r)break;for(;h.sibling===null;){if(h.return===null||h.return===r)return;h=h.return}h.sibling.return=h.return,h=h.sibling}},I0=function(){},w1=function(i,r,h,p){var v=i.memoizedProps;if(v!==p){i=r.stateNode,da(Cs.current);var w=null;switch(h){case"input":v=Xt(i,v),p=Xt(i,p),w=[];break;case"select":v=st({},v,{value:void 0}),p=st({},p,{value:void 0}),w=[];break;case"textarea":v=Z(i,v),p=Z(i,p),w=[];break;default:typeof v.onClick!="function"&&typeof p.onClick=="function"&&(i.onclick=tp)}$l(h,p);var T;h=null;for(Y in v)if(!p.hasOwnProperty(Y)&&v.hasOwnProperty(Y)&&v[Y]!=null)if(Y==="style"){var D=v[Y];for(T in D)D.hasOwnProperty(T)&&(h||(h={}),h[T]="")}else Y!=="dangerouslySetInnerHTML"&&Y!=="children"&&Y!=="suppressContentEditableWarning"&&Y!=="suppressHydrationWarning"&&Y!=="autoFocus"&&(s.hasOwnProperty(Y)?w||(w=[]):(w=w||[]).push(Y,null));for(Y in p){var $=p[Y];if(D=v!=null?v[Y]:void 0,p.hasOwnProperty(Y)&&$!==D&&($!=null||D!=null))if(Y==="style")if(D){for(T in D)!D.hasOwnProperty(T)||$&&$.hasOwnProperty(T)||(h||(h={}),h[T]="");for(T in $)$.hasOwnProperty(T)&&D[T]!==$[T]&&(h||(h={}),h[T]=$[T])}else h||(w||(w=[]),w.push(Y,h)),h=$;else Y==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,D=D?D.__html:void 0,$!=null&&D!==$&&(w=w||[]).push(Y,$)):Y==="children"?typeof $!="string"&&typeof $!="number"||(w=w||[]).push(Y,""+$):Y!=="suppressContentEditableWarning"&&Y!=="suppressHydrationWarning"&&(s.hasOwnProperty(Y)?($!=null&&Y==="onScroll"&&xe("scroll",i),w||D===$||(w=[])):(w=w||[]).push(Y,$))}h&&(w=w||[]).push("style",h);var Y=w;(r.updateQueue=Y)&&(r.flags|=4)}},b1=function(i,r,h,p){h!==p&&(r.flags|=4)};function dh(i,r){if(!Se)switch(i.tailMode){case"hidden":r=i.tail;for(var h=null;r!==null;)r.alternate!==null&&(h=r),r=r.sibling;h===null?i.tail=null:h.sibling=null;break;case"collapsed":h=i.tail;for(var p=null;h!==null;)h.alternate!==null&&(p=h),h=h.sibling;p===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:p.sibling=null}}function Sn(i){var r=i.alternate!==null&&i.alternate.child===i.child,h=0,p=0;if(r)for(var v=i.child;v!==null;)h|=v.lanes|v.childLanes,p|=v.subtreeFlags&14680064,p|=v.flags&14680064,v.return=i,v=v.sibling;else for(v=i.child;v!==null;)h|=v.lanes|v.childLanes,p|=v.subtreeFlags,p|=v.flags,v.return=i,v=v.sibling;return i.subtreeFlags|=p,i.childLanes=h,r}function hk(i,r,h){var p=r.pendingProps;switch(n0(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sn(r),null;case 1:return Yn(r.type)&&np(),Sn(r),null;case 3:return p=r.stateNode,nc(),we(qn),we(wn),g0(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(i===null||i.child===null)&&(ap(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Qi!==null&&(W0(Qi),Qi=null))),I0(i,r),Sn(r),null;case 5:f0(r);var v=da(ah.current);if(h=r.type,i!==null&&r.stateNode!=null)w1(i,r,h,p,v),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!p){if(r.stateNode===null)throw Error(e(166));return Sn(r),null}if(i=da(Cs.current),ap(r)){p=r.stateNode,h=r.type;var w=r.memoizedProps;switch(p[ks]=r,p[nh]=w,i=(r.mode&1)!==0,h){case"dialog":xe("cancel",p),xe("close",p);break;case"iframe":case"object":case"embed":xe("load",p);break;case"video":case"audio":for(v=0;v<Zu.length;v++)xe(Zu[v],p);break;case"source":xe("error",p);break;case"img":case"image":case"link":xe("error",p),xe("load",p);break;case"details":xe("toggle",p);break;case"input":ai(p,w),xe("invalid",p);break;case"select":p._wrapperState={wasMultiple:!!w.multiple},xe("invalid",p);break;case"textarea":yt(p,w),xe("invalid",p)}$l(h,w),v=null;for(var T in w)if(w.hasOwnProperty(T)){var D=w[T];T==="children"?typeof D=="string"?p.textContent!==D&&(w.suppressHydrationWarning!==!0&&Zf(p.textContent,D,i),v=["children",D]):typeof D=="number"&&p.textContent!==""+D&&(w.suppressHydrationWarning!==!0&&Zf(p.textContent,D,i),v=["children",""+D]):s.hasOwnProperty(T)&&D!=null&&T==="onScroll"&&xe("scroll",p)}switch(h){case"input":ve(p),Fn(p,w,!0);break;case"textarea":ve(p),Qt(p);break;case"select":case"option":break;default:typeof w.onClick=="function"&&(p.onclick=tp)}p=v,r.updateQueue=p,p!==null&&(r.flags|=4)}else{T=v.nodeType===9?v:v.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Lt(h)),i==="http://www.w3.org/1999/xhtml"?h==="script"?(i=T.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof p.is=="string"?i=T.createElement(h,{is:p.is}):(i=T.createElement(h),h==="select"&&(T=i,p.multiple?T.multiple=!0:p.size&&(T.size=p.size))):i=T.createElementNS(i,h),i[ks]=r,i[nh]=p,x1(i,r,!1,!1),r.stateNode=i;t:{switch(T=Iu(h,p),h){case"dialog":xe("cancel",i),xe("close",i),v=p;break;case"iframe":case"object":case"embed":xe("load",i),v=p;break;case"video":case"audio":for(v=0;v<Zu.length;v++)xe(Zu[v],i);v=p;break;case"source":xe("error",i),v=p;break;case"img":case"image":case"link":xe("error",i),xe("load",i),v=p;break;case"details":xe("toggle",i),v=p;break;case"input":ai(i,p),v=Xt(i,p),xe("invalid",i);break;case"option":v=p;break;case"select":i._wrapperState={wasMultiple:!!p.multiple},v=st({},p,{value:void 0}),xe("invalid",i);break;case"textarea":yt(i,p),v=Z(i,p),xe("invalid",i);break;default:v=p}$l(h,v),D=v;for(w in D)if(D.hasOwnProperty(w)){var $=D[w];w==="style"?sa(i,$):w==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&Zt(i,$)):w==="children"?typeof $=="string"?(h!=="textarea"||$!=="")&&pe(i,$):typeof $=="number"&&pe(i,""+$):w!=="suppressContentEditableWarning"&&w!=="suppressHydrationWarning"&&w!=="autoFocus"&&(s.hasOwnProperty(w)?$!=null&&w==="onScroll"&&xe("scroll",i):$!=null&&k(i,w,$,T))}switch(h){case"input":ve(i),Fn(i,p,!1);break;case"textarea":ve(i),Qt(i);break;case"option":p.value!=null&&i.setAttribute("value",""+Mt(p.value));break;case"select":i.multiple=!!p.multiple,w=p.value,w!=null?B(i,!!p.multiple,w,!1):p.defaultValue!=null&&B(i,!!p.multiple,p.defaultValue,!0);break;default:typeof v.onClick=="function"&&(i.onclick=tp)}switch(h){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break t;case"img":p=!0;break t;default:p=!1}}p&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Sn(r),null;case 6:if(i&&r.stateNode!=null)b1(i,r,i.memoizedProps,p);else{if(typeof p!="string"&&r.stateNode===null)throw Error(e(166));if(h=da(ah.current),da(Cs.current),ap(r)){if(p=r.stateNode,h=r.memoizedProps,p[ks]=r,(w=p.nodeValue!==h)&&(i=ci,i!==null))switch(i.tag){case 3:Zf(p.nodeValue,h,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Zf(p.nodeValue,h,(i.mode&1)!==0)}w&&(r.flags|=4)}else p=(h.nodeType===9?h:h.ownerDocument).createTextNode(p),p[ks]=r,r.stateNode=p}return Sn(r),null;case 13:if(we(Ce),p=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Se&&ui!==null&&(r.mode&1)!==0&&(r.flags&128)===0)_w(),Jl(),r.flags|=98560,w=!1;else if(w=ap(r),p!==null&&p.dehydrated!==null){if(i===null){if(!w)throw Error(e(318));if(w=r.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(e(317));w[ks]=r}else Jl(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Sn(r),w=!1}else Qi!==null&&(W0(Qi),Qi=null),w=!0;if(!w)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=h,r):(p=p!==null,p!==(i!==null&&i.memoizedState!==null)&&p&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(Ce.current&1)!==0?qe===0&&(qe=3):q0())),r.updateQueue!==null&&(r.flags|=4),Sn(r),null);case 4:return nc(),I0(i,r),i===null&&th(r.stateNode.containerInfo),Sn(r),null;case 10:return l0(r.type._context),Sn(r),null;case 17:return Yn(r.type)&&np(),Sn(r),null;case 19:if(we(Ce),w=r.memoizedState,w===null)return Sn(r),null;if(p=(r.flags&128)!==0,T=w.rendering,T===null)if(p)dh(w,!1);else{if(qe!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(T=fp(i),T!==null){for(r.flags|=128,dh(w,!1),p=T.updateQueue,p!==null&&(r.updateQueue=p,r.flags|=4),r.subtreeFlags=0,p=h,h=r.child;h!==null;)w=h,i=p,w.flags&=14680066,T=w.alternate,T===null?(w.childLanes=0,w.lanes=i,w.child=null,w.subtreeFlags=0,w.memoizedProps=null,w.memoizedState=null,w.updateQueue=null,w.dependencies=null,w.stateNode=null):(w.childLanes=T.childLanes,w.lanes=T.lanes,w.child=T.child,w.subtreeFlags=0,w.deletions=null,w.memoizedProps=T.memoizedProps,w.memoizedState=T.memoizedState,w.updateQueue=T.updateQueue,w.type=T.type,i=T.dependencies,w.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),h=h.sibling;return ge(Ce,Ce.current&1|2),r.child}i=i.sibling}w.tail!==null&&Ie()>oc&&(r.flags|=128,p=!0,dh(w,!1),r.lanes=4194304)}else{if(!p)if(i=fp(T),i!==null){if(r.flags|=128,p=!0,h=i.updateQueue,h!==null&&(r.updateQueue=h,r.flags|=4),dh(w,!0),w.tail===null&&w.tailMode==="hidden"&&!T.alternate&&!Se)return Sn(r),null}else 2*Ie()-w.renderingStartTime>oc&&h!==1073741824&&(r.flags|=128,p=!0,dh(w,!1),r.lanes=4194304);w.isBackwards?(T.sibling=r.child,r.child=T):(h=w.last,h!==null?h.sibling=T:r.child=T,w.last=T)}return w.tail!==null?(r=w.tail,w.rendering=r,w.tail=r.sibling,w.renderingStartTime=Ie(),r.sibling=null,h=Ce.current,ge(Ce,p?h&1|2:h&1),r):(Sn(r),null);case 22:case 23:return X0(),p=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==p&&(r.flags|=8192),p&&(r.mode&1)!==0?(hi&1073741824)!==0&&(Sn(r),r.subtreeFlags&6&&(r.flags|=8192)):Sn(r),null;case 24:return null;case 25:return null}throw Error(e(156,r.tag))}function dk(i,r){switch(n0(r),r.tag){case 1:return Yn(r.type)&&np(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return nc(),we(qn),we(wn),g0(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return f0(r),null;case 13:if(we(Ce),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(e(340));Jl()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return we(Ce),null;case 4:return nc(),null;case 10:return l0(r.type._context),null;case 22:case 23:return X0(),null;case 24:return null;default:return null}}var Sp=!1,An=!1,fk=typeof WeakSet=="function"?WeakSet:Set,wt=null;function sc(i,r){var h=i.ref;if(h!==null)if(typeof h=="function")try{h(null)}catch(p){Ne(i,r,p)}else h.current=null}function D0(i,r,h){try{h()}catch(p){Ne(i,r,p)}}var S1=!1;function pk(i,r){if(Xm=Bf,i=tw(),$m(i)){if("selectionStart"in i)var h={start:i.selectionStart,end:i.selectionEnd};else t:{h=(h=i.ownerDocument)&&h.defaultView||window;var p=h.getSelection&&h.getSelection();if(p&&p.rangeCount!==0){h=p.anchorNode;var v=p.anchorOffset,w=p.focusNode;p=p.focusOffset;try{h.nodeType,w.nodeType}catch{h=null;break t}var T=0,D=-1,$=-1,Y=0,it=0,ot=i,et=null;e:for(;;){for(var vt;ot!==h||v!==0&&ot.nodeType!==3||(D=T+v),ot!==w||p!==0&&ot.nodeType!==3||($=T+p),ot.nodeType===3&&(T+=ot.nodeValue.length),(vt=ot.firstChild)!==null;)et=ot,ot=vt;for(;;){if(ot===i)break e;if(et===h&&++Y===v&&(D=T),et===w&&++it===p&&($=T),(vt=ot.nextSibling)!==null)break;ot=et,et=ot.parentNode}ot=vt}h=D===-1||$===-1?null:{start:D,end:$}}else h=null}h=h||{start:0,end:0}}else h=null;for(qm={focusedElem:i,selectionRange:h},Bf=!1,wt=r;wt!==null;)if(r=wt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,wt=i;else for(;wt!==null;){r=wt;try{var Et=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Et!==null){var kt=Et.memoizedProps,De=Et.memoizedState,U=r.stateNode,z=U.getSnapshotBeforeUpdate(r.elementType===r.type?kt:Ji(r.type,kt),De);U.__reactInternalSnapshotBeforeUpdate=z}break;case 3:var G=r.stateNode.containerInfo;G.nodeType===1?G.textContent="":G.nodeType===9&&G.documentElement&&G.removeChild(G.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(e(163))}}catch(ct){Ne(r,r.return,ct)}if(i=r.sibling,i!==null){i.return=r.return,wt=i;break}wt=r.return}return Et=S1,S1=!1,Et}function fh(i,r,h){var p=r.updateQueue;if(p=p!==null?p.lastEffect:null,p!==null){var v=p=p.next;do{if((v.tag&i)===i){var w=v.destroy;v.destroy=void 0,w!==void 0&&D0(r,h,w)}v=v.next}while(v!==p)}}function Ap(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var h=r=r.next;do{if((h.tag&i)===i){var p=h.create;h.destroy=p()}h=h.next}while(h!==r)}}function F0(i){var r=i.ref;if(r!==null){var h=i.stateNode;switch(i.tag){case 5:i=h;break;default:i=h}typeof r=="function"?r(i):r.current=i}}function A1(i){var r=i.alternate;r!==null&&(i.alternate=null,A1(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[ks],delete r[nh],delete r[Jm],delete r[KE],delete r[QE])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function _1(i){return i.tag===5||i.tag===3||i.tag===4}function E1(i){t:for(;;){for(;i.sibling===null;){if(i.return===null||_1(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue t;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function O0(i,r,h){var p=i.tag;if(p===5||p===6)i=i.stateNode,r?h.nodeType===8?h.parentNode.insertBefore(i,r):h.insertBefore(i,r):(h.nodeType===8?(r=h.parentNode,r.insertBefore(i,h)):(r=h,r.appendChild(i)),h=h._reactRootContainer,h!=null||r.onclick!==null||(r.onclick=tp));else if(p!==4&&(i=i.child,i!==null))for(O0(i,r,h),i=i.sibling;i!==null;)O0(i,r,h),i=i.sibling}function j0(i,r,h){var p=i.tag;if(p===5||p===6)i=i.stateNode,r?h.insertBefore(i,r):h.appendChild(i);else if(p!==4&&(i=i.child,i!==null))for(j0(i,r,h),i=i.sibling;i!==null;)j0(i,r,h),i=i.sibling}var hn=null,Zi=!1;function ro(i,r,h){for(h=h.child;h!==null;)k1(i,r,h),h=h.sibling}function k1(i,r,h){if(Es&&typeof Es.onCommitFiberUnmount=="function")try{Es.onCommitFiberUnmount(Ff,h)}catch{}switch(h.tag){case 5:An||sc(h,r);case 6:var p=hn,v=Zi;hn=null,ro(i,r,h),hn=p,Zi=v,hn!==null&&(Zi?(i=hn,h=h.stateNode,i.nodeType===8?i.parentNode.removeChild(h):i.removeChild(h)):hn.removeChild(h.stateNode));break;case 18:hn!==null&&(Zi?(i=hn,h=h.stateNode,i.nodeType===8?Qm(i.parentNode,h):i.nodeType===1&&Qm(i,h),Wu(i)):Qm(hn,h.stateNode));break;case 4:p=hn,v=Zi,hn=h.stateNode.containerInfo,Zi=!0,ro(i,r,h),hn=p,Zi=v;break;case 0:case 11:case 14:case 15:if(!An&&(p=h.updateQueue,p!==null&&(p=p.lastEffect,p!==null))){v=p=p.next;do{var w=v,T=w.destroy;w=w.tag,T!==void 0&&((w&2)!==0||(w&4)!==0)&&D0(h,r,T),v=v.next}while(v!==p)}ro(i,r,h);break;case 1:if(!An&&(sc(h,r),p=h.stateNode,typeof p.componentWillUnmount=="function"))try{p.props=h.memoizedProps,p.state=h.memoizedState,p.componentWillUnmount()}catch(D){Ne(h,r,D)}ro(i,r,h);break;case 21:ro(i,r,h);break;case 22:h.mode&1?(An=(p=An)||h.memoizedState!==null,ro(i,r,h),An=p):ro(i,r,h);break;default:ro(i,r,h)}}function C1(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var h=i.stateNode;h===null&&(h=i.stateNode=new fk),r.forEach(function(p){var v=Ak.bind(null,i,p);h.has(p)||(h.add(p),p.then(v,v))})}}function ts(i,r){var h=r.deletions;if(h!==null)for(var p=0;p<h.length;p++){var v=h[p];try{var w=i,T=r,D=T;t:for(;D!==null;){switch(D.tag){case 5:hn=D.stateNode,Zi=!1;break t;case 3:hn=D.stateNode.containerInfo,Zi=!0;break t;case 4:hn=D.stateNode.containerInfo,Zi=!0;break t}D=D.return}if(hn===null)throw Error(e(160));k1(w,T,v),hn=null,Zi=!1;var $=v.alternate;$!==null&&($.return=null),v.return=null}catch(Y){Ne(v,r,Y)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)T1(r,i),r=r.sibling}function T1(i,r){var h=i.alternate,p=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(ts(r,i),Ps(i),p&4){try{fh(3,i,i.return),Ap(3,i)}catch(kt){Ne(i,i.return,kt)}try{fh(5,i,i.return)}catch(kt){Ne(i,i.return,kt)}}break;case 1:ts(r,i),Ps(i),p&512&&h!==null&&sc(h,h.return);break;case 5:if(ts(r,i),Ps(i),p&512&&h!==null&&sc(h,h.return),i.flags&32){var v=i.stateNode;try{pe(v,"")}catch(kt){Ne(i,i.return,kt)}}if(p&4&&(v=i.stateNode,v!=null)){var w=i.memoizedProps,T=h!==null?h.memoizedProps:w,D=i.type,$=i.updateQueue;if(i.updateQueue=null,$!==null)try{D==="input"&&w.type==="radio"&&w.name!=null&&Dn(v,w),Iu(D,T);var Y=Iu(D,w);for(T=0;T<$.length;T+=2){var it=$[T],ot=$[T+1];it==="style"?sa(v,ot):it==="dangerouslySetInnerHTML"?Zt(v,ot):it==="children"?pe(v,ot):k(v,it,ot,Y)}switch(D){case"input":Pi(v,w);break;case"textarea":Ft(v,w);break;case"select":var et=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!w.multiple;var vt=w.value;vt!=null?B(v,!!w.multiple,vt,!1):et!==!!w.multiple&&(w.defaultValue!=null?B(v,!!w.multiple,w.defaultValue,!0):B(v,!!w.multiple,w.multiple?[]:"",!1))}v[nh]=w}catch(kt){Ne(i,i.return,kt)}}break;case 6:if(ts(r,i),Ps(i),p&4){if(i.stateNode===null)throw Error(e(162));v=i.stateNode,w=i.memoizedProps;try{v.nodeValue=w}catch(kt){Ne(i,i.return,kt)}}break;case 3:if(ts(r,i),Ps(i),p&4&&h!==null&&h.memoizedState.isDehydrated)try{Wu(r.containerInfo)}catch(kt){Ne(i,i.return,kt)}break;case 4:ts(r,i),Ps(i);break;case 13:ts(r,i),Ps(i),v=i.child,v.flags&8192&&(w=v.memoizedState!==null,v.stateNode.isHidden=w,!w||v.alternate!==null&&v.alternate.memoizedState!==null||(H0=Ie())),p&4&&C1(i);break;case 22:if(it=h!==null&&h.memoizedState!==null,i.mode&1?(An=(Y=An)||it,ts(r,i),An=Y):ts(r,i),Ps(i),p&8192){if(Y=i.memoizedState!==null,(i.stateNode.isHidden=Y)&&!it&&(i.mode&1)!==0)for(wt=i,it=i.child;it!==null;){for(ot=wt=it;wt!==null;){switch(et=wt,vt=et.child,et.tag){case 0:case 11:case 14:case 15:fh(4,et,et.return);break;case 1:sc(et,et.return);var Et=et.stateNode;if(typeof Et.componentWillUnmount=="function"){p=et,h=et.return;try{r=p,Et.props=r.memoizedProps,Et.state=r.memoizedState,Et.componentWillUnmount()}catch(kt){Ne(p,h,kt)}}break;case 5:sc(et,et.return);break;case 22:if(et.memoizedState!==null){R1(ot);continue}}vt!==null?(vt.return=et,wt=vt):R1(ot)}it=it.sibling}t:for(it=null,ot=i;;){if(ot.tag===5){if(it===null){it=ot;try{v=ot.stateNode,Y?(w=v.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none"):(D=ot.stateNode,$=ot.memoizedProps.style,T=$!=null&&$.hasOwnProperty("display")?$.display:null,D.style.display=tn("display",T))}catch(kt){Ne(i,i.return,kt)}}}else if(ot.tag===6){if(it===null)try{ot.stateNode.nodeValue=Y?"":ot.memoizedProps}catch(kt){Ne(i,i.return,kt)}}else if((ot.tag!==22&&ot.tag!==23||ot.memoizedState===null||ot===i)&&ot.child!==null){ot.child.return=ot,ot=ot.child;continue}if(ot===i)break t;for(;ot.sibling===null;){if(ot.return===null||ot.return===i)break t;it===ot&&(it=null),ot=ot.return}it===ot&&(it=null),ot.sibling.return=ot.return,ot=ot.sibling}}break;case 19:ts(r,i),Ps(i),p&4&&C1(i);break;case 21:break;default:ts(r,i),Ps(i)}}function Ps(i){var r=i.flags;if(r&2){try{t:{for(var h=i.return;h!==null;){if(_1(h)){var p=h;break t}h=h.return}throw Error(e(160))}switch(p.tag){case 5:var v=p.stateNode;p.flags&32&&(pe(v,""),p.flags&=-33);var w=E1(i);j0(i,w,v);break;case 3:case 4:var T=p.stateNode.containerInfo,D=E1(i);O0(i,D,T);break;default:throw Error(e(161))}}catch($){Ne(i,i.return,$)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function gk(i,r,h){wt=i,P1(i)}function P1(i,r,h){for(var p=(i.mode&1)!==0;wt!==null;){var v=wt,w=v.child;if(v.tag===22&&p){var T=v.memoizedState!==null||Sp;if(!T){var D=v.alternate,$=D!==null&&D.memoizedState!==null||An;D=Sp;var Y=An;if(Sp=T,(An=$)&&!Y)for(wt=v;wt!==null;)T=wt,$=T.child,T.tag===22&&T.memoizedState!==null?N1(v):$!==null?($.return=T,wt=$):N1(v);for(;w!==null;)wt=w,P1(w),w=w.sibling;wt=v,Sp=D,An=Y}M1(i)}else(v.subtreeFlags&8772)!==0&&w!==null?(w.return=v,wt=w):M1(i)}}function M1(i){for(;wt!==null;){var r=wt;if((r.flags&8772)!==0){var h=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:An||Ap(5,r);break;case 1:var p=r.stateNode;if(r.flags&4&&!An)if(h===null)p.componentDidMount();else{var v=r.elementType===r.type?h.memoizedProps:Ji(r.type,h.memoizedProps);p.componentDidUpdate(v,h.memoizedState,p.__reactInternalSnapshotBeforeUpdate)}var w=r.updateQueue;w!==null&&Rw(r,w,p);break;case 3:var T=r.updateQueue;if(T!==null){if(h=null,r.child!==null)switch(r.child.tag){case 5:h=r.child.stateNode;break;case 1:h=r.child.stateNode}Rw(r,T,h)}break;case 5:var D=r.stateNode;if(h===null&&r.flags&4){h=D;var $=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&h.focus();break;case"img":$.src&&(h.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var Y=r.alternate;if(Y!==null){var it=Y.memoizedState;if(it!==null){var ot=it.dehydrated;ot!==null&&Wu(ot)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(e(163))}An||r.flags&512&&F0(r)}catch(et){Ne(r,r.return,et)}}if(r===i){wt=null;break}if(h=r.sibling,h!==null){h.return=r.return,wt=h;break}wt=r.return}}function R1(i){for(;wt!==null;){var r=wt;if(r===i){wt=null;break}var h=r.sibling;if(h!==null){h.return=r.return,wt=h;break}wt=r.return}}function N1(i){for(;wt!==null;){var r=wt;try{switch(r.tag){case 0:case 11:case 15:var h=r.return;try{Ap(4,r)}catch($){Ne(r,h,$)}break;case 1:var p=r.stateNode;if(typeof p.componentDidMount=="function"){var v=r.return;try{p.componentDidMount()}catch($){Ne(r,v,$)}}var w=r.return;try{F0(r)}catch($){Ne(r,w,$)}break;case 5:var T=r.return;try{F0(r)}catch($){Ne(r,T,$)}}}catch($){Ne(r,r.return,$)}if(r===i){wt=null;break}var D=r.sibling;if(D!==null){D.return=r.return,wt=D;break}wt=r.return}}var mk=Math.ceil,_p=L.ReactCurrentDispatcher,$0=L.ReactCurrentOwner,Di=L.ReactCurrentBatchConfig,ee=0,nn=null,$e=null,dn=0,hi=0,rc=to(0),qe=0,ph=null,pa=0,Ep=0,z0=0,gh=null,Qn=null,H0=0,oc=1/0,sr=null,kp=!1,B0=null,oo=null,Cp=!1,ao=null,Tp=0,mh=0,U0=null,Pp=-1,Mp=0;function jn(){return(ee&6)!==0?Ie():Pp!==-1?Pp:Pp=Ie()}function lo(i){return(i.mode&1)===0?1:(ee&2)!==0&&dn!==0?dn&-dn:ZE.transition!==null?(Mp===0&&(Mp=Ex()),Mp):(i=ae,i!==0||(i=window.event,i=i===void 0?16:Ix(i.type)),i)}function es(i,r,h,p){if(50<mh)throw mh=0,U0=null,Error(e(185));zu(i,h,p),((ee&2)===0||i!==nn)&&(i===nn&&((ee&2)===0&&(Ep|=h),qe===4&&co(i,dn)),Jn(i,p),h===1&&ee===0&&(r.mode&1)===0&&(oc=Ie()+500,sp&&no()))}function Jn(i,r){var h=i.callbackNode;Z_(i,r);var p=$f(i,i===nn?dn:0);if(p===0)h!==null&&Sx(h),i.callbackNode=null,i.callbackPriority=0;else if(r=p&-p,i.callbackPriority!==r){if(h!=null&&Sx(h),r===1)i.tag===0?JE(I1.bind(null,i)):xw(I1.bind(null,i)),qE(function(){(ee&6)===0&&no()}),h=null;else{switch(kx(p)){case 1:h=Sm;break;case 4:h=Ax;break;case 16:h=Df;break;case 536870912:h=_x;break;default:h=Df}h=B1(h,L1.bind(null,i))}i.callbackPriority=r,i.callbackNode=h}}function L1(i,r){if(Pp=-1,Mp=0,(ee&6)!==0)throw Error(e(327));var h=i.callbackNode;if(ac()&&i.callbackNode!==h)return null;var p=$f(i,i===nn?dn:0);if(p===0)return null;if((p&30)!==0||(p&i.expiredLanes)!==0||r)r=Rp(i,p);else{r=p;var v=ee;ee|=2;var w=F1();(nn!==i||dn!==r)&&(sr=null,oc=Ie()+500,ma(i,r));do try{xk();break}catch(D){D1(i,D)}while(!0);a0(),_p.current=w,ee=v,$e!==null?r=0:(nn=null,dn=0,r=qe)}if(r!==0){if(r===2&&(v=Am(i),v!==0&&(p=v,r=V0(i,v))),r===1)throw h=ph,ma(i,0),co(i,p),Jn(i,Ie()),h;if(r===6)co(i,p);else{if(v=i.current.alternate,(p&30)===0&&!yk(v)&&(r=Rp(i,p),r===2&&(w=Am(i),w!==0&&(p=w,r=V0(i,w))),r===1))throw h=ph,ma(i,0),co(i,p),Jn(i,Ie()),h;switch(i.finishedWork=v,i.finishedLanes=p,r){case 0:case 1:throw Error(e(345));case 2:ya(i,Qn,sr);break;case 3:if(co(i,p),(p&130023424)===p&&(r=H0+500-Ie(),10<r)){if($f(i,0)!==0)break;if(v=i.suspendedLanes,(v&p)!==p){jn(),i.pingedLanes|=i.suspendedLanes&v;break}i.timeoutHandle=Km(ya.bind(null,i,Qn,sr),r);break}ya(i,Qn,sr);break;case 4:if(co(i,p),(p&4194240)===p)break;for(r=i.eventTimes,v=-1;0<p;){var T=31-Yi(p);w=1<<T,T=r[T],T>v&&(v=T),p&=~w}if(p=v,p=Ie()-p,p=(120>p?120:480>p?480:1080>p?1080:1920>p?1920:3e3>p?3e3:4320>p?4320:1960*mk(p/1960))-p,10<p){i.timeoutHandle=Km(ya.bind(null,i,Qn,sr),p);break}ya(i,Qn,sr);break;case 5:ya(i,Qn,sr);break;default:throw Error(e(329))}}}return Jn(i,Ie()),i.callbackNode===h?L1.bind(null,i):null}function V0(i,r){var h=gh;return i.current.memoizedState.isDehydrated&&(ma(i,r).flags|=256),i=Rp(i,r),i!==2&&(r=Qn,Qn=h,r!==null&&W0(r)),i}function W0(i){Qn===null?Qn=i:Qn.push.apply(Qn,i)}function yk(i){for(var r=i;;){if(r.flags&16384){var h=r.updateQueue;if(h!==null&&(h=h.stores,h!==null))for(var p=0;p<h.length;p++){var v=h[p],w=v.getSnapshot;v=v.value;try{if(!Ki(w(),v))return!1}catch{return!1}}}if(h=r.child,r.subtreeFlags&16384&&h!==null)h.return=r,r=h;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function co(i,r){for(r&=~z0,r&=~Ep,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var h=31-Yi(r),p=1<<h;i[h]=-1,r&=~p}}function I1(i){if((ee&6)!==0)throw Error(e(327));ac();var r=$f(i,0);if((r&1)===0)return Jn(i,Ie()),null;var h=Rp(i,r);if(i.tag!==0&&h===2){var p=Am(i);p!==0&&(r=p,h=V0(i,p))}if(h===1)throw h=ph,ma(i,0),co(i,r),Jn(i,Ie()),h;if(h===6)throw Error(e(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,ya(i,Qn,sr),Jn(i,Ie()),null}function G0(i,r){var h=ee;ee|=1;try{return i(r)}finally{ee=h,ee===0&&(oc=Ie()+500,sp&&no())}}function ga(i){ao!==null&&ao.tag===0&&(ee&6)===0&&ac();var r=ee;ee|=1;var h=Di.transition,p=ae;try{if(Di.transition=null,ae=1,i)return i()}finally{ae=p,Di.transition=h,ee=r,(ee&6)===0&&no()}}function X0(){hi=rc.current,we(rc)}function ma(i,r){i.finishedWork=null,i.finishedLanes=0;var h=i.timeoutHandle;if(h!==-1&&(i.timeoutHandle=-1,XE(h)),$e!==null)for(h=$e.return;h!==null;){var p=h;switch(n0(p),p.tag){case 1:p=p.type.childContextTypes,p!=null&&np();break;case 3:nc(),we(qn),we(wn),g0();break;case 5:f0(p);break;case 4:nc();break;case 13:we(Ce);break;case 19:we(Ce);break;case 10:l0(p.type._context);break;case 22:case 23:X0()}h=h.return}if(nn=i,$e=i=uo(i.current,null),dn=hi=r,qe=0,ph=null,z0=Ep=pa=0,Qn=gh=null,ha!==null){for(r=0;r<ha.length;r++)if(h=ha[r],p=h.interleaved,p!==null){h.interleaved=null;var v=p.next,w=h.pending;if(w!==null){var T=w.next;w.next=v,p.next=T}h.pending=p}ha=null}return i}function D1(i,r){do{var h=$e;try{if(a0(),pp.current=vp,gp){for(var p=Te.memoizedState;p!==null;){var v=p.queue;v!==null&&(v.pending=null),p=p.next}gp=!1}if(fa=0,en=Xe=Te=null,lh=!1,ch=0,$0.current=null,h===null||h.return===null){qe=1,ph=r,$e=null;break}t:{var w=i,T=h.return,D=h,$=r;if(r=dn,D.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var Y=$,it=D,ot=it.tag;if((it.mode&1)===0&&(ot===0||ot===11||ot===15)){var et=it.alternate;et?(it.updateQueue=et.updateQueue,it.memoizedState=et.memoizedState,it.lanes=et.lanes):(it.updateQueue=null,it.memoizedState=null)}var vt=o1(T);if(vt!==null){vt.flags&=-257,a1(vt,T,D,w,r),vt.mode&1&&r1(w,Y,r),r=vt,$=Y;var Et=r.updateQueue;if(Et===null){var kt=new Set;kt.add($),r.updateQueue=kt}else Et.add($);break t}else{if((r&1)===0){r1(w,Y,r),q0();break t}$=Error(e(426))}}else if(Se&&D.mode&1){var De=o1(T);if(De!==null){(De.flags&65536)===0&&(De.flags|=256),a1(De,T,D,w,r),r0(ic($,D));break t}}w=$=ic($,D),qe!==4&&(qe=2),gh===null?gh=[w]:gh.push(w),w=T;do{switch(w.tag){case 3:w.flags|=65536,r&=-r,w.lanes|=r;var U=i1(w,$,r);Mw(w,U);break t;case 1:D=$;var z=w.type,G=w.stateNode;if((w.flags&128)===0&&(typeof z.getDerivedStateFromError=="function"||G!==null&&typeof G.componentDidCatch=="function"&&(oo===null||!oo.has(G)))){w.flags|=65536,r&=-r,w.lanes|=r;var ct=s1(w,D,r);Mw(w,ct);break t}}w=w.return}while(w!==null)}j1(h)}catch(Ct){r=Ct,$e===h&&h!==null&&($e=h=h.return);continue}break}while(!0)}function F1(){var i=_p.current;return _p.current=vp,i===null?vp:i}function q0(){(qe===0||qe===3||qe===2)&&(qe=4),nn===null||(pa&268435455)===0&&(Ep&268435455)===0||co(nn,dn)}function Rp(i,r){var h=ee;ee|=2;var p=F1();(nn!==i||dn!==r)&&(sr=null,ma(i,r));do try{vk();break}catch(v){D1(i,v)}while(!0);if(a0(),ee=h,_p.current=p,$e!==null)throw Error(e(261));return nn=null,dn=0,qe}function vk(){for(;$e!==null;)O1($e)}function xk(){for(;$e!==null&&!V_();)O1($e)}function O1(i){var r=H1(i.alternate,i,hi);i.memoizedProps=i.pendingProps,r===null?j1(i):$e=r,$0.current=null}function j1(i){var r=i;do{var h=r.alternate;if(i=r.return,(r.flags&32768)===0){if(h=hk(h,r,hi),h!==null){$e=h;return}}else{if(h=dk(h,r),h!==null){h.flags&=32767,$e=h;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{qe=6,$e=null;return}}if(r=r.sibling,r!==null){$e=r;return}$e=r=i}while(r!==null);qe===0&&(qe=5)}function ya(i,r,h){var p=ae,v=Di.transition;try{Di.transition=null,ae=1,wk(i,r,h,p)}finally{Di.transition=v,ae=p}return null}function wk(i,r,h,p){do ac();while(ao!==null);if((ee&6)!==0)throw Error(e(327));h=i.finishedWork;var v=i.finishedLanes;if(h===null)return null;if(i.finishedWork=null,i.finishedLanes=0,h===i.current)throw Error(e(177));i.callbackNode=null,i.callbackPriority=0;var w=h.lanes|h.childLanes;if(tE(i,w),i===nn&&($e=nn=null,dn=0),(h.subtreeFlags&2064)===0&&(h.flags&2064)===0||Cp||(Cp=!0,B1(Df,function(){return ac(),null})),w=(h.flags&15990)!==0,(h.subtreeFlags&15990)!==0||w){w=Di.transition,Di.transition=null;var T=ae;ae=1;var D=ee;ee|=4,$0.current=null,pk(i,h),T1(h,i),zE(qm),Bf=!!Xm,qm=Xm=null,i.current=h,gk(h),W_(),ee=D,ae=T,Di.transition=w}else i.current=h;if(Cp&&(Cp=!1,ao=i,Tp=v),w=i.pendingLanes,w===0&&(oo=null),q_(h.stateNode),Jn(i,Ie()),r!==null)for(p=i.onRecoverableError,h=0;h<r.length;h++)v=r[h],p(v.value,{componentStack:v.stack,digest:v.digest});if(kp)throw kp=!1,i=B0,B0=null,i;return(Tp&1)!==0&&i.tag!==0&&ac(),w=i.pendingLanes,(w&1)!==0?i===U0?mh++:(mh=0,U0=i):mh=0,no(),null}function ac(){if(ao!==null){var i=kx(Tp),r=Di.transition,h=ae;try{if(Di.transition=null,ae=16>i?16:i,ao===null)var p=!1;else{if(i=ao,ao=null,Tp=0,(ee&6)!==0)throw Error(e(331));var v=ee;for(ee|=4,wt=i.current;wt!==null;){var w=wt,T=w.child;if((wt.flags&16)!==0){var D=w.deletions;if(D!==null){for(var $=0;$<D.length;$++){var Y=D[$];for(wt=Y;wt!==null;){var it=wt;switch(it.tag){case 0:case 11:case 15:fh(8,it,w)}var ot=it.child;if(ot!==null)ot.return=it,wt=ot;else for(;wt!==null;){it=wt;var et=it.sibling,vt=it.return;if(A1(it),it===Y){wt=null;break}if(et!==null){et.return=vt,wt=et;break}wt=vt}}}var Et=w.alternate;if(Et!==null){var kt=Et.child;if(kt!==null){Et.child=null;do{var De=kt.sibling;kt.sibling=null,kt=De}while(kt!==null)}}wt=w}}if((w.subtreeFlags&2064)!==0&&T!==null)T.return=w,wt=T;else t:for(;wt!==null;){if(w=wt,(w.flags&2048)!==0)switch(w.tag){case 0:case 11:case 15:fh(9,w,w.return)}var U=w.sibling;if(U!==null){U.return=w.return,wt=U;break t}wt=w.return}}var z=i.current;for(wt=z;wt!==null;){T=wt;var G=T.child;if((T.subtreeFlags&2064)!==0&&G!==null)G.return=T,wt=G;else t:for(T=z;wt!==null;){if(D=wt,(D.flags&2048)!==0)try{switch(D.tag){case 0:case 11:case 15:Ap(9,D)}}catch(Ct){Ne(D,D.return,Ct)}if(D===T){wt=null;break t}var ct=D.sibling;if(ct!==null){ct.return=D.return,wt=ct;break t}wt=D.return}}if(ee=v,no(),Es&&typeof Es.onPostCommitFiberRoot=="function")try{Es.onPostCommitFiberRoot(Ff,i)}catch{}p=!0}return p}finally{ae=h,Di.transition=r}}return!1}function $1(i,r,h){r=ic(h,r),r=i1(i,r,1),i=so(i,r,1),r=jn(),i!==null&&(zu(i,1,r),Jn(i,r))}function Ne(i,r,h){if(i.tag===3)$1(i,i,h);else for(;r!==null;){if(r.tag===3){$1(r,i,h);break}else if(r.tag===1){var p=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(oo===null||!oo.has(p))){i=ic(h,i),i=s1(r,i,1),r=so(r,i,1),i=jn(),r!==null&&(zu(r,1,i),Jn(r,i));break}}r=r.return}}function bk(i,r,h){var p=i.pingCache;p!==null&&p.delete(r),r=jn(),i.pingedLanes|=i.suspendedLanes&h,nn===i&&(dn&h)===h&&(qe===4||qe===3&&(dn&130023424)===dn&&500>Ie()-H0?ma(i,0):z0|=h),Jn(i,r)}function z1(i,r){r===0&&((i.mode&1)===0?r=1:(r=jf,jf<<=1,(jf&130023424)===0&&(jf=4194304)));var h=jn();i=er(i,r),i!==null&&(zu(i,r,h),Jn(i,h))}function Sk(i){var r=i.memoizedState,h=0;r!==null&&(h=r.retryLane),z1(i,h)}function Ak(i,r){var h=0;switch(i.tag){case 13:var p=i.stateNode,v=i.memoizedState;v!==null&&(h=v.retryLane);break;case 19:p=i.stateNode;break;default:throw Error(e(314))}p!==null&&p.delete(r),z1(i,h)}var H1;H1=function(i,r,h){if(i!==null)if(i.memoizedProps!==r.pendingProps||qn.current)Kn=!0;else{if((i.lanes&h)===0&&(r.flags&128)===0)return Kn=!1,uk(i,r,h);Kn=(i.flags&131072)!==0}else Kn=!1,Se&&(r.flags&1048576)!==0&&ww(r,op,r.index);switch(r.lanes=0,r.tag){case 2:var p=r.type;bp(i,r),i=r.pendingProps;var v=Yl(r,wn.current);ec(r,h),v=v0(null,r,p,i,v,h);var w=x0();return r.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Yn(p)?(w=!0,ip(r)):w=!1,r.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,h0(r),v.updater=xp,r.stateNode=v,v._reactInternals=r,E0(r,p,i,h),r=P0(null,r,p,!0,w,h)):(r.tag=0,Se&&w&&e0(r),On(null,r,v,h),r=r.child),r;case 16:p=r.elementType;t:{switch(bp(i,r),i=r.pendingProps,v=p._init,p=v(p._payload),r.type=p,v=r.tag=Ek(p),i=Ji(p,i),v){case 0:r=T0(null,r,p,i,h);break t;case 1:r=f1(null,r,p,i,h);break t;case 11:r=l1(null,r,p,i,h);break t;case 14:r=c1(null,r,p,Ji(p.type,i),h);break t}throw Error(e(306,p,""))}return r;case 0:return p=r.type,v=r.pendingProps,v=r.elementType===p?v:Ji(p,v),T0(i,r,p,v,h);case 1:return p=r.type,v=r.pendingProps,v=r.elementType===p?v:Ji(p,v),f1(i,r,p,v,h);case 3:t:{if(p1(r),i===null)throw Error(e(387));p=r.pendingProps,w=r.memoizedState,v=w.element,Pw(i,r),dp(r,p,null,h);var T=r.memoizedState;if(p=T.element,w.isDehydrated)if(w={element:p,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},r.updateQueue.baseState=w,r.memoizedState=w,r.flags&256){v=ic(Error(e(423)),r),r=g1(i,r,p,h,v);break t}else if(p!==v){v=ic(Error(e(424)),r),r=g1(i,r,p,h,v);break t}else for(ui=Zr(r.stateNode.containerInfo.firstChild),ci=r,Se=!0,Qi=null,h=Cw(r,null,p,h),r.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(Jl(),p===v){r=ir(i,r,h);break t}On(i,r,p,h)}r=r.child}return r;case 5:return Nw(r),i===null&&s0(r),p=r.type,v=r.pendingProps,w=i!==null?i.memoizedProps:null,T=v.children,Ym(p,v)?T=null:w!==null&&Ym(p,w)&&(r.flags|=32),d1(i,r),On(i,r,T,h),r.child;case 6:return i===null&&s0(r),null;case 13:return m1(i,r,h);case 4:return d0(r,r.stateNode.containerInfo),p=r.pendingProps,i===null?r.child=Zl(r,null,p,h):On(i,r,p,h),r.child;case 11:return p=r.type,v=r.pendingProps,v=r.elementType===p?v:Ji(p,v),l1(i,r,p,v,h);case 7:return On(i,r,r.pendingProps,h),r.child;case 8:return On(i,r,r.pendingProps.children,h),r.child;case 12:return On(i,r,r.pendingProps.children,h),r.child;case 10:t:{if(p=r.type._context,v=r.pendingProps,w=r.memoizedProps,T=v.value,ge(cp,p._currentValue),p._currentValue=T,w!==null)if(Ki(w.value,T)){if(w.children===v.children&&!qn.current){r=ir(i,r,h);break t}}else for(w=r.child,w!==null&&(w.return=r);w!==null;){var D=w.dependencies;if(D!==null){T=w.child;for(var $=D.firstContext;$!==null;){if($.context===p){if(w.tag===1){$=nr(-1,h&-h),$.tag=2;var Y=w.updateQueue;if(Y!==null){Y=Y.shared;var it=Y.pending;it===null?$.next=$:($.next=it.next,it.next=$),Y.pending=$}}w.lanes|=h,$=w.alternate,$!==null&&($.lanes|=h),c0(w.return,h,r),D.lanes|=h;break}$=$.next}}else if(w.tag===10)T=w.type===r.type?null:w.child;else if(w.tag===18){if(T=w.return,T===null)throw Error(e(341));T.lanes|=h,D=T.alternate,D!==null&&(D.lanes|=h),c0(T,h,r),T=w.sibling}else T=w.child;if(T!==null)T.return=w;else for(T=w;T!==null;){if(T===r){T=null;break}if(w=T.sibling,w!==null){w.return=T.return,T=w;break}T=T.return}w=T}On(i,r,v.children,h),r=r.child}return r;case 9:return v=r.type,p=r.pendingProps.children,ec(r,h),v=Li(v),p=p(v),r.flags|=1,On(i,r,p,h),r.child;case 14:return p=r.type,v=Ji(p,r.pendingProps),v=Ji(p.type,v),c1(i,r,p,v,h);case 15:return u1(i,r,r.type,r.pendingProps,h);case 17:return p=r.type,v=r.pendingProps,v=r.elementType===p?v:Ji(p,v),bp(i,r),r.tag=1,Yn(p)?(i=!0,ip(r)):i=!1,ec(r,h),e1(r,p,v),E0(r,p,v,h),P0(null,r,p,!0,i,h);case 19:return v1(i,r,h);case 22:return h1(i,r,h)}throw Error(e(156,r.tag))};function B1(i,r){return bx(i,r)}function _k(i,r,h,p){this.tag=i,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fi(i,r,h,p){return new _k(i,r,h,p)}function Y0(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ek(i){if(typeof i=="function")return Y0(i)?1:0;if(i!=null){if(i=i.$$typeof,i===lt)return 11;if(i===St)return 14}return 2}function uo(i,r){var h=i.alternate;return h===null?(h=Fi(i.tag,r,i.key,i.mode),h.elementType=i.elementType,h.type=i.type,h.stateNode=i.stateNode,h.alternate=i,i.alternate=h):(h.pendingProps=r,h.type=i.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=i.flags&14680064,h.childLanes=i.childLanes,h.lanes=i.lanes,h.child=i.child,h.memoizedProps=i.memoizedProps,h.memoizedState=i.memoizedState,h.updateQueue=i.updateQueue,r=i.dependencies,h.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},h.sibling=i.sibling,h.index=i.index,h.ref=i.ref,h}function Np(i,r,h,p,v,w){var T=2;if(p=i,typeof i=="function")Y0(i)&&(T=1);else if(typeof i=="string")T=5;else t:switch(i){case O:return va(h.children,v,w,r);case H:T=8,v|=8;break;case X:return i=Fi(12,h,r,v|2),i.elementType=X,i.lanes=w,i;case pt:return i=Fi(13,h,r,v),i.elementType=pt,i.lanes=w,i;case ut:return i=Fi(19,h,r,v),i.elementType=ut,i.lanes=w,i;case tt:return Lp(h,v,w,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case q:T=10;break t;case K:T=9;break t;case lt:T=11;break t;case St:T=14;break t;case Q:T=16,p=null;break t}throw Error(e(130,i==null?i:typeof i,""))}return r=Fi(T,h,r,v),r.elementType=i,r.type=p,r.lanes=w,r}function va(i,r,h,p){return i=Fi(7,i,p,r),i.lanes=h,i}function Lp(i,r,h,p){return i=Fi(22,i,p,r),i.elementType=tt,i.lanes=h,i.stateNode={isHidden:!1},i}function K0(i,r,h){return i=Fi(6,i,null,r),i.lanes=h,i}function Q0(i,r,h){return r=Fi(4,i.children!==null?i.children:[],i.key,r),r.lanes=h,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function kk(i,r,h,p,v){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=_m(0),this.expirationTimes=_m(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_m(0),this.identifierPrefix=p,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function J0(i,r,h,p,v,w,T,D,$){return i=new kk(i,r,h,D,$),r===1?(r=1,w===!0&&(r|=8)):r=0,w=Fi(3,null,null,r),i.current=w,w.stateNode=i,w.memoizedState={element:p,isDehydrated:h,cache:null,transitions:null,pendingSuspenseBoundaries:null},h0(w),i}function Ck(i,r,h){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:j,key:p==null?null:""+p,children:i,containerInfo:r,implementation:h}}function U1(i){if(!i)return eo;i=i._reactInternals;t:{if(oa(i)!==i||i.tag!==1)throw Error(e(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break t;case 1:if(Yn(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break t}}r=r.return}while(r!==null);throw Error(e(171))}if(i.tag===1){var h=i.type;if(Yn(h))return yw(i,h,r)}return r}function V1(i,r,h,p,v,w,T,D,$){return i=J0(h,p,!0,i,v,w,T,D,$),i.context=U1(null),h=i.current,p=jn(),v=lo(h),w=nr(p,v),w.callback=r??null,so(h,w,v),i.current.lanes=v,zu(i,v,p),Jn(i,p),i}function Ip(i,r,h,p){var v=r.current,w=jn(),T=lo(v);return h=U1(h),r.context===null?r.context=h:r.pendingContext=h,r=nr(w,T),r.payload={element:i},p=p===void 0?null:p,p!==null&&(r.callback=p),i=so(v,r,T),i!==null&&(es(i,v,T,w),hp(i,v,T)),T}function Dp(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function W1(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var h=i.retryLane;i.retryLane=h!==0&&h<r?h:r}}function Z0(i,r){W1(i,r),(i=i.alternate)&&W1(i,r)}function Tk(){return null}var G1=typeof reportError=="function"?reportError:function(i){console.error(i)};function ty(i){this._internalRoot=i}Fp.prototype.render=ty.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(e(409));Ip(i,r,null,null)},Fp.prototype.unmount=ty.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;ga(function(){Ip(null,i,null,null)}),r[Qs]=null}};function Fp(i){this._internalRoot=i}Fp.prototype.unstable_scheduleHydration=function(i){if(i){var r=Px();i={blockedOn:null,target:i,priority:r};for(var h=0;h<Kr.length&&r!==0&&r<Kr[h].priority;h++);Kr.splice(h,0,i),h===0&&Nx(i)}};function ey(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function Op(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function X1(){}function Pk(i,r,h,p,v){if(v){if(typeof p=="function"){var w=p;p=function(){var Y=Dp(T);w.call(Y)}}var T=V1(r,p,i,0,null,!1,!1,"",X1);return i._reactRootContainer=T,i[Qs]=T.current,th(i.nodeType===8?i.parentNode:i),ga(),T}for(;v=i.lastChild;)i.removeChild(v);if(typeof p=="function"){var D=p;p=function(){var Y=Dp($);D.call(Y)}}var $=J0(i,0,!1,null,null,!1,!1,"",X1);return i._reactRootContainer=$,i[Qs]=$.current,th(i.nodeType===8?i.parentNode:i),ga(function(){Ip(r,$,h,p)}),$}function jp(i,r,h,p,v){var w=h._reactRootContainer;if(w){var T=w;if(typeof v=="function"){var D=v;v=function(){var $=Dp(T);D.call($)}}Ip(r,T,i,v)}else T=Pk(h,r,i,v,p);return Dp(T)}Cx=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var h=$u(r.pendingLanes);h!==0&&(Em(r,h|1),Jn(r,Ie()),(ee&6)===0&&(oc=Ie()+500,no()))}break;case 13:ga(function(){var p=er(i,1);if(p!==null){var v=jn();es(p,i,1,v)}}),Z0(i,1)}},km=function(i){if(i.tag===13){var r=er(i,134217728);if(r!==null){var h=jn();es(r,i,134217728,h)}Z0(i,134217728)}},Tx=function(i){if(i.tag===13){var r=lo(i),h=er(i,r);if(h!==null){var p=jn();es(h,i,r,p)}Z0(i,r)}},Px=function(){return ae},Mx=function(i,r){var h=ae;try{return ae=i,r()}finally{ae=h}},Du=function(i,r,h){switch(r){case"input":if(Pi(i,h),r=h.name,h.type==="radio"&&r!=null){for(h=i;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<h.length;r++){var p=h[r];if(p!==i&&p.form===i.form){var v=ep(p);if(!v)throw Error(e(90));ue(p),Pi(p,v)}}}break;case"textarea":Ft(i,h);break;case"select":r=h.value,r!=null&&B(i,!!h.multiple,r,!1)}},Nf=G0,Fu=ga;var Mk={usingClientEntryPoint:!1,Events:[ih,Xl,ep,Mf,Rf,G0]},yh={findFiberByHostInstance:aa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Rk={bundleType:yh.bundleType,version:yh.version,rendererPackageName:yh.rendererPackageName,rendererConfig:yh.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:L.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=xx(i),i===null?null:i.stateNode},findFiberByHostInstance:yh.findFiberByHostInstance||Tk,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var $p=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$p.isDisabled&&$p.supportsFiber)try{Ff=$p.inject(Rk),Es=$p}catch{}}return Zn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Mk,Zn.createPortal=function(i,r){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ey(r))throw Error(e(200));return Ck(i,r,null,h)},Zn.createRoot=function(i,r){if(!ey(i))throw Error(e(299));var h=!1,p="",v=G1;return r!=null&&(r.unstable_strictMode===!0&&(h=!0),r.identifierPrefix!==void 0&&(p=r.identifierPrefix),r.onRecoverableError!==void 0&&(v=r.onRecoverableError)),r=J0(i,1,!1,null,null,h,!1,p,v),i[Qs]=r.current,th(i.nodeType===8?i.parentNode:i),new ty(r)},Zn.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(e(188)):(i=Object.keys(i).join(","),Error(e(268,i)));return i=xx(r),i=i===null?null:i.stateNode,i},Zn.flushSync=function(i){return ga(i)},Zn.hydrate=function(i,r,h){if(!Op(r))throw Error(e(200));return jp(null,i,r,!0,h)},Zn.hydrateRoot=function(i,r,h){if(!ey(i))throw Error(e(405));var p=h!=null&&h.hydratedSources||null,v=!1,w="",T=G1;if(h!=null&&(h.unstable_strictMode===!0&&(v=!0),h.identifierPrefix!==void 0&&(w=h.identifierPrefix),h.onRecoverableError!==void 0&&(T=h.onRecoverableError)),r=V1(r,null,i,1,h??null,v,!1,w,T),i[Qs]=r.current,th(i),p)for(i=0;i<p.length;i++)h=p[i],v=h._getVersion,v=v(h._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[h,v]:r.mutableSourceEagerHydrationData.push(h,v);return new Fp(r)},Zn.render=function(i,r,h){if(!Op(r))throw Error(e(200));return jp(null,i,r,!1,h)},Zn.unmountComponentAtNode=function(i){if(!Op(i))throw Error(e(40));return i._reactRootContainer?(ga(function(){jp(null,null,i,!1,function(){i._reactRootContainer=null,i[Qs]=null})}),!0):!1},Zn.unstable_batchedUpdates=G0,Zn.unstable_renderSubtreeIntoContainer=function(i,r,h,p){if(!Op(h))throw Error(e(200));if(i==null||i._reactInternals===void 0)throw Error(e(38));return jp(i,r,h,!1,p)},Zn.version="18.3.1-next-f1338f8080-20240426",Zn}var nb;function Qb(){if(nb)return ry.exports;nb=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(t){console.error(t)}}return a(),ry.exports=Vk(),ry.exports}var ib;function Wk(){if(ib)return zp;ib=1;var a=Qb();return zp.createRoot=a.createRoot,zp.hydrateRoot=a.hydrateRoot,zp}var Gk=Wk();Qb();/**
41
+ * @remix-run/router v1.23.3
42
+ *
43
+ * Copyright (c) Remix Software Inc.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE.md file in the root directory of this source tree.
47
+ *
48
+ * @license MIT
49
+ */function Xh(){return Xh=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(a[n]=e[n])}return a},Xh.apply(null,arguments)}var qo;(function(a){a.Pop="POP",a.Push="PUSH",a.Replace="REPLACE"})(qo||(qo={}));const sb="popstate";function Xk(a){a===void 0&&(a={});function t(n,s){let{pathname:o,search:l,hash:c}=n.location;return Ay("",{pathname:o,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function e(n,s){return typeof s=="string"?s:Tg(s)}return Yk(t,e,null,a)}function Ve(a,t){if(a===!1||a===null||typeof a>"u")throw new Error(t)}function Xv(a,t){if(!a){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function qk(){return Math.random().toString(36).substr(2,8)}function rb(a,t){return{usr:a.state,key:a.key,idx:t}}function Ay(a,t,e,n){return e===void 0&&(e=null),Xh({pathname:typeof a=="string"?a:a.pathname,search:"",hash:""},typeof t=="string"?Nu(t):t,{state:e,key:t&&t.key||n||qk()})}function Tg(a){let{pathname:t="/",search:e="",hash:n=""}=a;return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Nu(a){let t={};if(a){let e=a.indexOf("#");e>=0&&(t.hash=a.substr(e),a=a.substr(0,e));let n=a.indexOf("?");n>=0&&(t.search=a.substr(n),a=a.substr(0,n)),a&&(t.pathname=a)}return t}function Yk(a,t,e,n){n===void 0&&(n={});let{window:s=document.defaultView,v5Compat:o=!1}=n,l=s.history,c=qo.Pop,d=null,f=g();f==null&&(f=0,l.replaceState(Xh({},l.state,{idx:f}),""));function g(){return(l.state||{idx:null}).idx}function m(){c=qo.Pop;let C=g(),E=C==null?null:C-f;f=C,d&&d({action:c,location:A.location,delta:E})}function y(C,E){c=qo.Push;let N=Ay(A.location,C,E);f=g()+1;let k=rb(N,f),L=A.createHref(N);try{l.pushState(k,"",L)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;s.location.assign(L)}o&&d&&d({action:c,location:A.location,delta:1})}function x(C,E){c=qo.Replace;let N=Ay(A.location,C,E);f=g();let k=rb(N,f),L=A.createHref(N);l.replaceState(k,"",L),o&&d&&d({action:c,location:A.location,delta:0})}function b(C){let E=s.location.origin!=="null"?s.location.origin:s.location.href,N=typeof C=="string"?C:Tg(C);return N=N.replace(/ $/,"%20"),Ve(E,"No window.location.(origin|href) available to create URL for href: "+N),new URL(N,E)}let A={get action(){return c},get location(){return a(s,l)},listen(C){if(d)throw new Error("A history only accepts one active listener");return s.addEventListener(sb,m),d=C,()=>{s.removeEventListener(sb,m),d=null}},createHref(C){return t(s,C)},createURL:b,encodeLocation(C){let E=b(C);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:y,replace:x,go(C){return l.go(C)}};return A}var ob;(function(a){a.data="data",a.deferred="deferred",a.redirect="redirect",a.error="error"})(ob||(ob={}));function Kk(a,t,e){return e===void 0&&(e="/"),Qk(a,t,e)}function Qk(a,t,e,n){let s=typeof t=="string"?Nu(t):t,o=qv(s.pathname||"/",e);if(o==null)return null;let l=Jb(a);Jk(l);let c=null,d=uC(o);for(let f=0;c==null&&f<l.length;++f)c=aC(l[f],d);return c}function Jb(a,t,e,n){t===void 0&&(t=[]),e===void 0&&(e=[]),n===void 0&&(n="");let s=(o,l,c)=>{let d={relativePath:c===void 0?o.path||"":c,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};d.relativePath.startsWith("/")&&(Ve(d.relativePath.startsWith(n),'Absolute route path "'+d.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),d.relativePath=d.relativePath.slice(n.length));let f=Yo([n,d.relativePath]),g=e.concat(d);o.children&&o.children.length>0&&(Ve(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+f+'".')),Jb(o.children,t,g,f)),!(o.path==null&&!o.index)&&t.push({path:f,score:rC(f,o.index),routesMeta:g})};return a.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))s(o,l);else for(let d of Zb(o.path))s(o,l,d)}),t}function Zb(a){let t=a.split("/");if(t.length===0)return[];let[e,...n]=t,s=e.endsWith("?"),o=e.replace(/\?$/,"");if(n.length===0)return s?[o,""]:[o];let l=Zb(n.join("/")),c=[];return c.push(...l.map(d=>d===""?o:[o,d].join("/"))),s&&c.push(...l),c.map(d=>a.startsWith("/")&&d===""?"/":d)}function Jk(a){a.sort((t,e)=>t.score!==e.score?e.score-t.score:oC(t.routesMeta.map(n=>n.childrenIndex),e.routesMeta.map(n=>n.childrenIndex)))}const Zk=/^:[\w-]+$/,tC=3,eC=2,nC=1,iC=10,sC=-2,ab=a=>a==="*";function rC(a,t){let e=a.split("/"),n=e.length;return e.some(ab)&&(n+=sC),t&&(n+=eC),e.filter(s=>!ab(s)).reduce((s,o)=>s+(Zk.test(o)?tC:o===""?nC:iC),n)}function oC(a,t){return a.length===t.length&&a.slice(0,-1).every((n,s)=>n===t[s])?a[a.length-1]-t[t.length-1]:0}function aC(a,t,e){let{routesMeta:n}=a,s={},o="/",l=[];for(let c=0;c<n.length;++c){let d=n[c],f=c===n.length-1,g=o==="/"?t:t.slice(o.length)||"/",m=lC({path:d.relativePath,caseSensitive:d.caseSensitive,end:f},g),y=d.route;if(!m)return null;Object.assign(s,m.params),l.push({params:s,pathname:Yo([o,m.pathname]),pathnameBase:gC(Yo([o,m.pathnameBase])),route:y}),m.pathnameBase!=="/"&&(o=Yo([o,m.pathnameBase]))}return l}function lC(a,t){typeof a=="string"&&(a={path:a,caseSensitive:!1,end:!0});let[e,n]=cC(a.path,a.caseSensitive,a.end),s=t.match(e);if(!s)return null;let o=s[0],l=o.replace(/(.)\/+$/,"$1"),c=s.slice(1);return{params:n.reduce((f,g,m)=>{let{paramName:y,isOptional:x}=g;if(y==="*"){let A=c[m]||"";l=o.slice(0,o.length-A.length).replace(/(.)\/+$/,"$1")}const b=c[m];return x&&!b?f[y]=void 0:f[y]=(b||"").replace(/%2F/g,"/"),f},{}),pathname:o,pathnameBase:l,pattern:a}}function cC(a,t,e){t===void 0&&(t=!1),e===void 0&&(e=!0),Xv(a==="*"||!a.endsWith("*")||a.endsWith("/*"),'Route path "'+a+'" will be treated as if it were '+('"'+a.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+a.replace(/\*$/,"/*")+'".'));let n=[],s="^"+a.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,d)=>(n.push({paramName:c,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return a.endsWith("*")?(n.push({paramName:"*"}),s+=a==="*"||a==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):e?s+="\\/*$":a!==""&&a!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),n]}function uC(a){try{return a.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Xv(!1,'The URL path "'+a+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),a}}function qv(a,t){if(t==="/")return a;if(!a.toLowerCase().startsWith(t.toLowerCase()))return null;let e=t.endsWith("/")?t.length-1:t.length,n=a.charAt(e);return n&&n!=="/"?null:a.slice(e)||"/"}const hC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,dC=a=>hC.test(a);function fC(a,t){t===void 0&&(t="/");let{pathname:e,search:n="",hash:s=""}=typeof a=="string"?Nu(a):a,o;if(e)if(dC(e))o=e;else{if(e.includes("//")){let l=e;e=nS(e),Xv(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+e))}e.startsWith("/")?o=lb(e.substring(1),"/"):o=lb(e,t)}else o=t;return{pathname:o,search:mC(n),hash:yC(s)}}function lb(a,t){let e=t.replace(/\/+$/,"").split("/");return a.split("/").forEach(s=>{s===".."?e.length>1&&e.pop():s!=="."&&e.push(s)}),e.length>1?e.join("/"):"/"}function ly(a,t,e,n){return"Cannot include a '"+a+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+e+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function pC(a){return a.filter((t,e)=>e===0||t.route.path&&t.route.path.length>0)}function tS(a,t){let e=pC(a);return t?e.map((n,s)=>s===e.length-1?n.pathname:n.pathnameBase):e.map(n=>n.pathnameBase)}function eS(a,t,e,n){n===void 0&&(n=!1);let s;typeof a=="string"?s=Nu(a):(s=Xh({},a),Ve(!s.pathname||!s.pathname.includes("?"),ly("?","pathname","search",s)),Ve(!s.pathname||!s.pathname.includes("#"),ly("#","pathname","hash",s)),Ve(!s.search||!s.search.includes("#"),ly("#","search","hash",s)));let o=a===""||s.pathname==="",l=o?"/":s.pathname,c;if(l==null)c=e;else{let m=t.length-1;if(!n&&l.startsWith("..")){let y=l.split("/");for(;y[0]==="..";)y.shift(),m-=1;s.pathname=y.join("/")}c=m>=0?t[m]:"/"}let d=fC(s,c),f=l&&l!=="/"&&l.endsWith("/"),g=(o||l===".")&&e.endsWith("/");return!d.pathname.endsWith("/")&&(f||g)&&(d.pathname+="/"),d}const nS=a=>a.replace(/\/\/+/g,"/"),Yo=a=>nS(a.join("/")),gC=a=>a.replace(/\/+$/,"").replace(/^\/*/,"/"),mC=a=>!a||a==="?"?"":a.startsWith("?")?a:"?"+a,yC=a=>!a||a==="#"?"":a.startsWith("#")?a:"#"+a;function vC(a){return a!=null&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.internal=="boolean"&&"data"in a}const iS=["post","put","patch","delete"];new Set(iS);const xC=["get",...iS];new Set(xC);/**
50
+ * React Router v6.30.4
51
+ *
52
+ * Copyright (c) Remix Software Inc.
53
+ *
54
+ * This source code is licensed under the MIT license found in the
55
+ * LICENSE.md file in the root directory of this source tree.
56
+ *
57
+ * @license MIT
58
+ */function qh(){return qh=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(a[n]=e[n])}return a},qh.apply(null,arguments)}const Yv=F.createContext(null),wC=F.createContext(null),Fl=F.createContext(null),lm=F.createContext(null),na=F.createContext({outlet:null,matches:[],isDataRoute:!1}),sS=F.createContext(null);function bC(a,t){let{relative:e}=t===void 0?{}:t;Ef()||Ve(!1);let{basename:n,navigator:s}=F.useContext(Fl),{hash:o,pathname:l,search:c}=aS(a,{relative:e}),d=l;return n!=="/"&&(d=l==="/"?n:Yo([n,l])),s.createHref({pathname:d,search:c,hash:o})}function Ef(){return F.useContext(lm)!=null}function cm(){return Ef()||Ve(!1),F.useContext(lm).location}function rS(a){F.useContext(Fl).static||F.useLayoutEffect(a)}function oS(){let{isDataRoute:a}=F.useContext(na);return a?DC():SC()}function SC(){Ef()||Ve(!1);let a=F.useContext(Yv),{basename:t,future:e,navigator:n}=F.useContext(Fl),{matches:s}=F.useContext(na),{pathname:o}=cm(),l=JSON.stringify(tS(s,e.v7_relativeSplatPath)),c=F.useRef(!1);return rS(()=>{c.current=!0}),F.useCallback(function(f,g){if(g===void 0&&(g={}),!c.current)return;if(typeof f=="number"){n.go(f);return}let m=eS(f,JSON.parse(l),o,g.relative==="path");a==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Yo([t,m.pathname])),(g.replace?n.replace:n.push)(m,g.state,g)},[t,n,l,o,a])}function AC(){let{matches:a}=F.useContext(na),t=a[a.length-1];return t?t.params:{}}function aS(a,t){let{relative:e}=t===void 0?{}:t,{future:n}=F.useContext(Fl),{matches:s}=F.useContext(na),{pathname:o}=cm(),l=JSON.stringify(tS(s,n.v7_relativeSplatPath));return F.useMemo(()=>eS(a,JSON.parse(l),o,e==="path"),[a,l,o,e])}function _C(a,t){return EC(a,t)}function EC(a,t,e,n){Ef()||Ve(!1);let{navigator:s}=F.useContext(Fl),{matches:o}=F.useContext(na),l=o[o.length-1],c=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let f=cm(),g;if(t){var m;let C=typeof t=="string"?Nu(t):t;d==="/"||(m=C.pathname)!=null&&m.startsWith(d)||Ve(!1),g=C}else g=f;let y=g.pathname||"/",x=y;if(d!=="/"){let C=d.replace(/^\//,"").split("/");x="/"+y.replace(/^\//,"").split("/").slice(C.length).join("/")}let b=Kk(a,{pathname:x}),A=MC(b&&b.map(C=>Object.assign({},C,{params:Object.assign({},c,C.params),pathname:Yo([d,s.encodeLocation?s.encodeLocation(C.pathname).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?d:Yo([d,s.encodeLocation?s.encodeLocation(C.pathnameBase).pathname:C.pathnameBase])})),o,e,n);return t&&A?F.createElement(lm.Provider,{value:{location:qh({pathname:"/",search:"",hash:"",state:null,key:"default"},g),navigationType:qo.Pop}},A):A}function kC(){let a=IC(),t=vC(a)?a.status+" "+a.statusText:a instanceof Error?a.message:JSON.stringify(a),e=a instanceof Error?a.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return F.createElement(F.Fragment,null,F.createElement("h2",null,"Unexpected Application Error!"),F.createElement("h3",{style:{fontStyle:"italic"}},t),e?F.createElement("pre",{style:s},e):null,null)}const CC=F.createElement(kC,null);class TC extends F.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){console.error("React Router caught the following error during render",t,e)}render(){return this.state.error!==void 0?F.createElement(na.Provider,{value:this.props.routeContext},F.createElement(sS.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function PC(a){let{routeContext:t,match:e,children:n}=a,s=F.useContext(Yv);return s&&s.static&&s.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=e.route.id),F.createElement(na.Provider,{value:t},n)}function MC(a,t,e,n){var s;if(t===void 0&&(t=[]),e===void 0&&(e=null),n===void 0&&(n=null),a==null){var o;if(!e)return null;if(e.errors)a=e.matches;else if((o=n)!=null&&o.v7_partialHydration&&t.length===0&&!e.initialized&&e.matches.length>0)a=e.matches;else return null}let l=a,c=(s=e)==null?void 0:s.errors;if(c!=null){let g=l.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);g>=0||Ve(!1),l=l.slice(0,Math.min(l.length,g+1))}let d=!1,f=-1;if(e&&n&&n.v7_partialHydration)for(let g=0;g<l.length;g++){let m=l[g];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(f=g),m.route.id){let{loaderData:y,errors:x}=e,b=m.route.loader&&y[m.route.id]===void 0&&(!x||x[m.route.id]===void 0);if(m.route.lazy||b){d=!0,f>=0?l=l.slice(0,f+1):l=[l[0]];break}}}return l.reduceRight((g,m,y)=>{let x,b=!1,A=null,C=null;e&&(x=c&&m.route.id?c[m.route.id]:void 0,A=m.route.errorElement||CC,d&&(f<0&&y===0?(FC("route-fallback"),b=!0,C=null):f===y&&(b=!0,C=m.route.hydrateFallbackElement||null)));let E=t.concat(l.slice(0,y+1)),N=()=>{let k;return x?k=A:b?k=C:m.route.Component?k=F.createElement(m.route.Component,null):m.route.element?k=m.route.element:k=g,F.createElement(PC,{match:m,routeContext:{outlet:g,matches:E,isDataRoute:e!=null},children:k})};return e&&(m.route.ErrorBoundary||m.route.errorElement||y===0)?F.createElement(TC,{location:e.location,revalidation:e.revalidation,component:A,error:x,children:N(),routeContext:{outlet:null,matches:E,isDataRoute:!0}}):N()},null)}var lS=(function(a){return a.UseBlocker="useBlocker",a.UseRevalidator="useRevalidator",a.UseNavigateStable="useNavigate",a})(lS||{}),cS=(function(a){return a.UseBlocker="useBlocker",a.UseLoaderData="useLoaderData",a.UseActionData="useActionData",a.UseRouteError="useRouteError",a.UseNavigation="useNavigation",a.UseRouteLoaderData="useRouteLoaderData",a.UseMatches="useMatches",a.UseRevalidator="useRevalidator",a.UseNavigateStable="useNavigate",a.UseRouteId="useRouteId",a})(cS||{});function RC(a){let t=F.useContext(Yv);return t||Ve(!1),t}function NC(a){let t=F.useContext(wC);return t||Ve(!1),t}function LC(a){let t=F.useContext(na);return t||Ve(!1),t}function uS(a){let t=LC(),e=t.matches[t.matches.length-1];return e.route.id||Ve(!1),e.route.id}function IC(){var a;let t=F.useContext(sS),e=NC(),n=uS();return t!==void 0?t:(a=e.errors)==null?void 0:a[n]}function DC(){let{router:a}=RC(lS.UseNavigateStable),t=uS(cS.UseNavigateStable),e=F.useRef(!1);return rS(()=>{e.current=!0}),F.useCallback(function(s,o){o===void 0&&(o={}),e.current&&(typeof s=="number"?a.navigate(s):a.navigate(s,qh({fromRouteId:t},o)))},[a,t])}const cb={};function FC(a,t,e){cb[a]||(cb[a]=!0)}function OC(a,t){a==null||a.v7_startTransition,a==null||a.v7_relativeSplatPath}function _y(a){Ve(!1)}function jC(a){let{basename:t="/",children:e=null,location:n,navigationType:s=qo.Pop,navigator:o,static:l=!1,future:c}=a;Ef()&&Ve(!1);let d=t.replace(/^\/*/,"/"),f=F.useMemo(()=>({basename:d,navigator:o,static:l,future:qh({v7_relativeSplatPath:!1},c)}),[d,c,o,l]);typeof n=="string"&&(n=Nu(n));let{pathname:g="/",search:m="",hash:y="",state:x=null,key:b="default"}=n,A=F.useMemo(()=>{let C=qv(g,d);return C==null?null:{location:{pathname:C,search:m,hash:y,state:x,key:b},navigationType:s}},[d,g,m,y,x,b,s]);return A==null?null:F.createElement(Fl.Provider,{value:f},F.createElement(lm.Provider,{children:e,value:A}))}function $C(a){let{children:t,location:e}=a;return _C(Ey(t),e)}new Promise(()=>{});function Ey(a,t){t===void 0&&(t=[]);let e=[];return F.Children.forEach(a,(n,s)=>{if(!F.isValidElement(n))return;let o=[...t,s];if(n.type===F.Fragment){e.push.apply(e,Ey(n.props.children,o));return}n.type!==_y&&Ve(!1),!n.props.index||!n.props.children||Ve(!1);let l={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(l.children=Ey(n.props.children,o)),e.push(l)}),e}/**
59
+ * React Router DOM v6.30.4
60
+ *
61
+ * Copyright (c) Remix Software Inc.
62
+ *
63
+ * This source code is licensed under the MIT license found in the
64
+ * LICENSE.md file in the root directory of this source tree.
65
+ *
66
+ * @license MIT
67
+ */function ky(){return ky=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(a[n]=e[n])}return a},ky.apply(null,arguments)}function zC(a,t){if(a==null)return{};var e={};for(var n in a)if({}.hasOwnProperty.call(a,n)){if(t.indexOf(n)!==-1)continue;e[n]=a[n]}return e}function HC(a){return!!(a.metaKey||a.altKey||a.ctrlKey||a.shiftKey)}function BC(a,t){return a.button===0&&(!t||t==="_self")&&!HC(a)}const UC=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],VC="6";try{window.__reactRouterVersion=VC}catch{}const WC="startTransition",ub=Hk[WC];function GC(a){let{basename:t,children:e,future:n,window:s}=a,o=F.useRef();o.current==null&&(o.current=Xk({window:s,v5Compat:!0}));let l=o.current,[c,d]=F.useState({action:l.action,location:l.location}),{v7_startTransition:f}=n||{},g=F.useCallback(m=>{f&&ub?ub(()=>d(m)):d(m)},[d,f]);return F.useLayoutEffect(()=>l.listen(g),[l,g]),F.useEffect(()=>OC(n),[n]),F.createElement(jC,{basename:t,children:e,location:c.location,navigationType:c.action,navigator:l,future:n})}const XC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",qC=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,hS=F.forwardRef(function(t,e){let{onClick:n,relative:s,reloadDocument:o,replace:l,state:c,target:d,to:f,preventScrollReset:g,viewTransition:m}=t,y=zC(t,UC),{basename:x}=F.useContext(Fl),b,A=!1;if(typeof f=="string"&&qC.test(f)&&(b=f,XC))try{let k=new URL(window.location.href),L=f.startsWith("//")?new URL(k.protocol+f):new URL(f),R=qv(L.pathname,x);L.origin===k.origin&&R!=null?f=R+L.search+L.hash:A=!0}catch{}let C=bC(f,{relative:s}),E=YC(f,{replace:l,state:c,target:d,preventScrollReset:g,relative:s,viewTransition:m});function N(k){n&&n(k),k.defaultPrevented||E(k)}return F.createElement("a",ky({},y,{href:b||C,onClick:A||o?n:N,ref:e,target:d}))});var hb;(function(a){a.UseScrollRestoration="useScrollRestoration",a.UseSubmit="useSubmit",a.UseSubmitFetcher="useSubmitFetcher",a.UseFetcher="useFetcher",a.useViewTransitionState="useViewTransitionState"})(hb||(hb={}));var db;(function(a){a.UseFetcher="useFetcher",a.UseFetchers="useFetchers",a.UseScrollRestoration="useScrollRestoration"})(db||(db={}));function YC(a,t){let{target:e,replace:n,state:s,preventScrollReset:o,relative:l,viewTransition:c}=t===void 0?{}:t,d=oS(),f=cm(),g=aS(a,{relative:l});return F.useCallback(m=>{if(BC(m,e)){m.preventDefault();let y=n!==void 0?n:Tg(f)===Tg(g);d(a,{replace:y,state:s,preventScrollReset:o,relative:l,viewTransition:c})}},[f,d,g,n,s,e,a,o,l,c])}var Bh={};Bh.d=(a,t)=>{for(var e in t)Bh.o(t,e)&&!Bh.o(a,e)&&Object.defineProperty(a,e,{enumerable:!0,get:t[e]})};Bh.o=(a,t)=>Object.prototype.hasOwnProperty.call(a,t);var jt=globalThis.pdfjsLib={};Bh.d(jt,{AbortException:()=>Zo,AnnotationEditorLayer:()=>Dv,AnnotationEditorParamsType:()=>Jt,AnnotationEditorType:()=>Bt,AnnotationEditorUIManager:()=>Ll,AnnotationLayer:()=>VP,AnnotationMode:()=>yo,ColorPicker:()=>Ig,DOMSVGFactory:()=>sx,DrawLayer:()=>jv,FeatureTest:()=>Wn,GlobalWorkerOptions:()=>Fr,ImageKind:()=>Kp,InvalidPDFException:()=>Ty,MissingPDFException:()=>Yh,OPS:()=>rs,OutputScale:()=>My,PDFDataRangeTransport:()=>fA,PDFDateString:()=>tx,PDFWorker:()=>Ac,PasswordResponses:()=>ZC,PermissionFlag:()=>JC,PixelsPerInch:()=>ta,RenderingCancelledException:()=>Jv,TextLayer:()=>Kh,TouchManager:()=>Ng,UnexpectedResponseException:()=>Pg,Util:()=>Pt,VerbosityLevel:()=>um,XfaLayer:()=>gA,build:()=>_P,createValidAbsoluteUrl:()=>iT,fetchData:()=>pm,getDocument:()=>gP,getFilenameFromUrl:()=>dT,getPdfFilenameFromUrl:()=>fT,getXfaPageViewport:()=>pT,isDataScheme:()=>gm,isPdfFile:()=>Zv,noContextMenu:()=>bs,normalizeUnicode:()=>cT,setLayerDimensions:()=>Nl,shadow:()=>Kt,stopEvent:()=>ki,version:()=>AP});const In=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),dS=[1,0,0,1,0,0],Cy=[.001,0,0,.001,0,0],KC=1e7,cy=1.35,_i={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},yo={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},QC="pdfjs_internal_editor_",Bt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Jt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},JC={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},_n={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Kp={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Ye={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,WIDGET:20},xh={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},um={ERRORS:0,WARNINGS:1,INFOS:5},rs={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},ZC={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let hm=um.WARNINGS;function tT(a){Number.isInteger(a)&&(hm=a)}function eT(){return hm}function dm(a){hm>=um.INFOS&&console.log(`Info: ${a}`)}function Ut(a){hm>=um.WARNINGS&&console.log(`Warning: ${a}`)}function fe(a){throw new Error(a)}function He(a,t){a||fe(t)}function nT(a){switch(a==null?void 0:a.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function iT(a,t=null,e=null){if(!a)return null;try{if(e&&typeof a=="string"){if(e.addDefaultProtocol&&a.startsWith("www.")){const s=a.match(/\./g);(s==null?void 0:s.length)>=2&&(a=`http://${a}`)}if(e.tryConvertEncoding)try{a=lT(a)}catch{}}const n=t?new URL(a,t):new URL(a);if(nT(n))return n}catch{}return null}function Kt(a,t,e,n=!1){return Object.defineProperty(a,t,{value:e,enumerable:!n,configurable:!0,writable:!1}),e}const ia=(function(){function t(e,n){this.message=e,this.name=n}return t.prototype=new Error,t.constructor=t,t})();class fb extends ia{constructor(t,e){super(t,"PasswordException"),this.code=e}}class uy extends ia{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ty extends ia{constructor(t){super(t,"InvalidPDFException")}}class Yh extends ia{constructor(t){super(t,"MissingPDFException")}}class Pg extends ia{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class sT extends ia{constructor(t){super(t,"FormatError")}}class Zo extends ia{constructor(t){super(t,"AbortException")}}function fS(a){(typeof a!="object"||(a==null?void 0:a.length)===void 0)&&fe("Invalid argument for bytesToString");const t=a.length,e=8192;if(t<e)return String.fromCharCode.apply(null,a);const n=[];for(let s=0;s<t;s+=e){const o=Math.min(s+e,t),l=a.subarray(s,o);n.push(String.fromCharCode.apply(null,l))}return n.join("")}function fm(a){typeof a!="string"&&fe("Invalid argument for stringToBytes");const t=a.length,e=new Uint8Array(t);for(let n=0;n<t;++n)e[n]=a.charCodeAt(n)&255;return e}function rT(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)}function Kv(a){const t=Object.create(null);for(const[e,n]of a)t[e]=n;return t}function oT(){const a=new Uint8Array(4);return a[0]=1,new Uint32Array(a.buffer,0,1)[0]===1}function aT(){try{return new Function(""),!0}catch{return!1}}class Wn{static get isLittleEndian(){return Kt(this,"isLittleEndian",oT())}static get isEvalSupported(){return Kt(this,"isEvalSupported",aT())}static get isOffscreenCanvasSupported(){return Kt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Kt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?Kt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):Kt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return Kt(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const hy=Array.from(Array(256).keys(),a=>a.toString(16).padStart(2,"0"));var jr,Qp,Py;class Pt{static makeHexColor(t,e,n){return`#${hy[t]}${hy[e]}${hy[n]}`}static scaleMinMax(t,e){let n;t[0]?(t[0]<0&&(n=e[0],e[0]=e[2],e[2]=n),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[3],e[3]*=t[3]):(n=e[0],e[0]=e[1],e[1]=n,n=e[2],e[2]=e[3],e[3]=n,t[1]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(n=e[0],e[0]=e[2],e[2]=n),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){const n=t[0]*e[0]+t[1]*e[2]+e[4],s=t[0]*e[1]+t[1]*e[3]+e[5];return[n,s]}static applyInverseTransform(t,e){const n=e[0]*e[3]-e[1]*e[2],s=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/n,o=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/n;return[s,o]}static getAxialAlignedBoundingBox(t,e){const n=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),o=this.applyTransform([t[0],t[3]],e),l=this.applyTransform([t[2],t[1]],e);return[Math.min(n[0],s[0],o[0],l[0]),Math.min(n[1],s[1],o[1],l[1]),Math.max(n[0],s[0],o[0],l[0]),Math.max(n[1],s[1],o[1],l[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],n=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],o=t[2]*e[0]+t[3]*e[2],l=t[2]*e[1]+t[3]*e[3],c=(n+l)/2,d=Math.sqrt((n+l)**2-4*(n*l-o*s))/2,f=c+d||1,g=c-d||1;return[Math.sqrt(f),Math.sqrt(g)]}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 n=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(n>s)return null;const o=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),l=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return o>l?null:[n,o,s,l]}static bezierBoundingBox(t,e,n,s,o,l,c,d,f){return f?(f[0]=Math.min(f[0],t,c),f[1]=Math.min(f[1],e,d),f[2]=Math.max(f[2],t,c),f[3]=Math.max(f[3],e,d)):f=[Math.min(t,c),Math.min(e,d),Math.max(t,c),Math.max(e,d)],M(this,jr,Py).call(this,t,n,o,c,e,s,l,d,3*(-t+3*(n-o)+c),6*(t-2*n+o),3*(n-t),f),M(this,jr,Py).call(this,t,n,o,c,e,s,l,d,3*(-e+3*(s-l)+d),6*(e-2*s+l),3*(s-e),f),f}}jr=new WeakSet,Qp=function(t,e,n,s,o,l,c,d,f,g){if(f<=0||f>=1)return;const m=1-f,y=f*f,x=y*f,b=m*(m*(m*t+3*f*e)+3*y*n)+x*s,A=m*(m*(m*o+3*f*l)+3*y*c)+x*d;g[0]=Math.min(g[0],b),g[1]=Math.min(g[1],A),g[2]=Math.max(g[2],b),g[3]=Math.max(g[3],A)},Py=function(t,e,n,s,o,l,c,d,f,g,m,y){if(Math.abs(f)<1e-12){Math.abs(g)>=1e-12&&M(this,jr,Qp).call(this,t,e,n,s,o,l,c,d,-m/g,y);return}const x=g**2-4*m*f;if(x<0)return;const b=Math.sqrt(x),A=2*f;M(this,jr,Qp).call(this,t,e,n,s,o,l,c,d,(-g+b)/A,y),M(this,jr,Qp).call(this,t,e,n,s,o,l,c,d,(-g-b)/A,y)},P(Pt,jr);function lT(a){return decodeURIComponent(escape(a))}let dy=null,pb=null;function cT(a){return dy||(dy=/([\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,pb=new Map([["ſt","ſt"]])),a.replaceAll(dy,(t,e,n)=>e?e.normalize("NFKC"):pb.get(n))}function uT(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const a=new Uint8Array(32);return crypto.getRandomValues(a),fS(a)}const Qv="pdfjs_internal_id_";function hT(a){return Uint8Array.prototype.toBase64?a.toBase64():btoa(fS(a))}typeof Promise.try!="function"&&(Promise.try=function(a,...t){return new Promise(e=>{e(a(...t))})});const or="http://www.w3.org/2000/svg",_a=class _a{};It(_a,"CSS",96),It(_a,"PDF",72),It(_a,"PDF_TO_CSS_UNITS",_a.CSS/_a.PDF);let ta=_a;async function pm(a,t="text"){if(Eh(a,document.baseURI)){const e=await fetch(a);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,n)=>{const s=new XMLHttpRequest;s.open("GET",a,!0),s.responseType=t,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE){if(s.status===200||s.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(s.response);return}e(s.responseText);return}n(new Error(s.statusText))}},s.send(null)})}class kf{constructor({viewBox:t,userUnit:e,scale:n,rotation:s,offsetX:o=0,offsetY:l=0,dontFlip:c=!1}){this.viewBox=t,this.userUnit=e,this.scale=n,this.rotation=s,this.offsetX=o,this.offsetY=l,n*=e;const d=(t[2]+t[0])/2,f=(t[3]+t[1])/2;let g,m,y,x;switch(s%=360,s<0&&(s+=360),s){case 180:g=-1,m=0,y=0,x=1;break;case 90:g=0,m=1,y=1,x=0;break;case 270:g=0,m=-1,y=-1,x=0;break;case 0:g=1,m=0,y=0,x=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}c&&(y=-y,x=-x);let b,A,C,E;g===0?(b=Math.abs(f-t[1])*n+o,A=Math.abs(d-t[0])*n+l,C=(t[3]-t[1])*n,E=(t[2]-t[0])*n):(b=Math.abs(d-t[0])*n+o,A=Math.abs(f-t[1])*n+l,C=(t[2]-t[0])*n,E=(t[3]-t[1])*n),this.transform=[g*n,m*n,y*n,x*n,b-g*n*d-y*n*f,A-m*n*d-x*n*f],this.width=C,this.height=E}get rawDims(){const{userUnit:t,viewBox:e}=this,n=e.map(s=>s*t);return Kt(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:n=this.offsetX,offsetY:s=this.offsetY,dontFlip:o=!1}={}){return new kf({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:s,dontFlip:o})}convertToViewportPoint(t,e){return Pt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=Pt.applyTransform([t[0],t[1]],this.transform),n=Pt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],n[0],n[1]]}convertToPdfPoint(t,e){return Pt.applyInverseTransform([t,e],this.transform)}}class Jv extends ia{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function gm(a){const t=a.length;let e=0;for(;e<t&&a[e].trim()==="";)e++;return a.substring(e,e+5).toLowerCase()==="data:"}function Zv(a){return typeof a=="string"&&/\.pdf$/i.test(a)}function dT(a){return[a]=a.split(/[#?]/,1),a.substring(a.lastIndexOf("/")+1)}function fT(a,t="document.pdf"){if(typeof a!="string")return t;if(gm(a))return Ut('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=e.exec(a);let o=n.exec(s[1])||n.exec(s[2])||n.exec(s[3]);if(o&&(o=o[0],o.includes("%")))try{o=n.exec(decodeURIComponent(o))[0]}catch{}return o||t}class gb{constructor(){It(this,"started",Object.create(null));It(this,"times",[])}time(t){t in this.started&&Ut(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Ut(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:n}of this.times)e=Math.max(n.length,e);for(const{name:n,start:s,end:o}of this.times)t.push(`${n.padEnd(e)} ${o-s}ms
68
+ `);return t.join("")}}function Eh(a,t){try{const{protocol:e}=t?new URL(a,t):new URL(a);return e==="http:"||e==="https:"}catch{return!1}}function bs(a){a.preventDefault()}function ki(a){a.preventDefault(),a.stopPropagation()}var Zh;class tx{static toDateObject(t){if(!t||typeof t!="string")return null;u(this,Zh)||_(this,Zh,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=u(this,Zh).exec(t);if(!e)return null;const n=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let o=parseInt(e[3],10);o=o>=1&&o<=31?o:1;let l=parseInt(e[4],10);l=l>=0&&l<=23?l:0;let c=parseInt(e[5],10);c=c>=0&&c<=59?c:0;let d=parseInt(e[6],10);d=d>=0&&d<=59?d:0;const f=e[7]||"Z";let g=parseInt(e[8],10);g=g>=0&&g<=23?g:0;let m=parseInt(e[9],10)||0;return m=m>=0&&m<=59?m:0,f==="-"?(l+=g,c+=m):f==="+"&&(l-=g,c-=m),new Date(Date.UTC(n,s,o,l,c,d))}}Zh=new WeakMap,P(tx,Zh);function pT(a,{scale:t=1,rotation:e=0}){const{width:n,height:s}=a.attributes.style,o=[0,0,parseInt(n),parseInt(s)];return new kf({viewBox:o,userUnit:1,scale:t,rotation:e})}function ex(a){if(a.startsWith("#")){const t=parseInt(a.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return a.startsWith("rgb(")?a.slice(4,-1).split(",").map(t=>parseInt(t)):a.startsWith("rgba(")?a.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Ut(`Not a valid color format: "${a}"`),[0,0,0])}function gT(a){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of a.keys()){t.style.color=e;const n=window.getComputedStyle(t).color;a.set(e,ex(n))}t.remove()}function _e(a){const{a:t,b:e,c:n,d:s,e:o,f:l}=a.getTransform();return[t,e,n,s,o,l]}function Ms(a){const{a:t,b:e,c:n,d:s,e:o,f:l}=a.getTransform().invertSelf();return[t,e,n,s,o,l]}function Nl(a,t,e=!1,n=!0){if(t instanceof kf){const{pageWidth:s,pageHeight:o}=t.rawDims,{style:l}=a,c=Wn.isCSSRoundSupported,d=`var(--scale-factor) * ${s}px`,f=`var(--scale-factor) * ${o}px`,g=c?`round(down, ${d}, var(--scale-round-x, 1px))`:`calc(${d})`,m=c?`round(down, ${f}, var(--scale-round-y, 1px))`:`calc(${f})`;!e||t.rotation%180===0?(l.width=g,l.height=m):(l.width=m,l.height=g)}n&&a.setAttribute("data-main-rotation",t.rotation)}class My{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}var vo,Ca,os,Ta,td,ed,Ug,pS,Gn,gS,mS,Jp,yS,Ny;const cr=class cr{constructor(t){P(this,Gn);P(this,vo,null);P(this,Ca,null);P(this,os);P(this,Ta,null);P(this,td,null);_(this,os,t),u(cr,ed)||_(cr,ed,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"}))}render(){const t=_(this,vo,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=u(this,os)._uiManager._signal;t.addEventListener("contextmenu",bs,{signal:e}),t.addEventListener("pointerdown",M(cr,Ug,pS),{signal:e});const n=_(this,Ta,document.createElement("div"));n.className="buttons",t.append(n);const s=u(this,os).toolbarPosition;if(s){const{style:o}=t,l=u(this,os)._uiManager.direction==="ltr"?1-s[0]:s[0];o.insetInlineEnd=`${100*l}%`,o.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return M(this,Gn,yS).call(this),t}get div(){return u(this,vo)}hide(){var t;u(this,vo).classList.add("hidden"),(t=u(this,Ca))==null||t.hideDropdown()}show(){var t;u(this,vo).classList.remove("hidden"),(t=u(this,td))==null||t.shown()}async addAltText(t){const e=await t.render();M(this,Gn,Jp).call(this,e),u(this,Ta).prepend(e,u(this,Gn,Ny)),_(this,td,t)}addColorPicker(t){_(this,Ca,t);const e=t.renderButton();M(this,Gn,Jp).call(this,e),u(this,Ta).prepend(e,u(this,Gn,Ny))}remove(){var t;u(this,vo).remove(),(t=u(this,Ca))==null||t.destroy(),_(this,Ca,null)}};vo=new WeakMap,Ca=new WeakMap,os=new WeakMap,Ta=new WeakMap,td=new WeakMap,ed=new WeakMap,Ug=new WeakSet,pS=function(t){t.stopPropagation()},Gn=new WeakSet,gS=function(t){u(this,os)._focusEventsAllowed=!1,ki(t)},mS=function(t){u(this,os)._focusEventsAllowed=!0,ki(t)},Jp=function(t){const e=u(this,os)._uiManager._signal;t.addEventListener("focusin",M(this,Gn,gS).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",M(this,Gn,mS).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",bs,{signal:e})},yS=function(){const{editorType:t,_uiManager:e}=u(this,os),n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",u(cr,ed)[t]),M(this,Gn,Jp).call(this,n),n.addEventListener("click",s=>{e.delete()},{signal:e._signal}),u(this,Ta).append(n)},Ny=function(){const t=document.createElement("div");return t.className="divider",t},P(cr,Ug),P(cr,ed,null);let Ry=cr;var nd,Pa,Ma,ea,vS,xS,wS;class mT{constructor(t){P(this,ea);P(this,nd,null);P(this,Pa,null);P(this,Ma);_(this,Ma,t)}show(t,e,n){const[s,o]=M(this,ea,xS).call(this,e,n),{style:l}=u(this,Pa)||_(this,Pa,M(this,ea,vS).call(this));t.append(u(this,Pa)),l.insetInlineEnd=`${100*s}%`,l.top=`calc(${100*o}% + var(--editor-toolbar-vert-offset))`}hide(){u(this,Pa).remove()}}nd=new WeakMap,Pa=new WeakMap,Ma=new WeakMap,ea=new WeakSet,vS=function(){const t=_(this,Pa,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",bs,{signal:u(this,Ma)._signal});const e=_(this,nd,document.createElement("div"));return e.className="buttons",t.append(e),M(this,ea,wS).call(this),t},xS=function(t,e){let n=0,s=0;for(const o of t){const l=o.y+o.height;if(l<n)continue;const c=o.x+(e?o.width:0);if(l>n){s=c,n=l;continue}e?c>s&&(s=c):c<s&&(s=c)}return[e?1-s:s,n]},wS=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=u(this,Ma)._signal;t.addEventListener("contextmenu",bs,{signal:n}),t.addEventListener("click",()=>{u(this,Ma).highlightSelection("floating_button")},{signal:n}),u(this,nd).append(t)};function Mg(a,t,e){for(const n of e)t.addEventListener(n,a[n].bind(a))}var Vg;class yT{constructor(){P(this,Vg,0)}get id(){return`${QC}${$n(this,Vg)._++}`}}Vg=new WeakMap;var _c,id,Cn,Ec,Zp;const hx=class hx{constructor(){P(this,Ec);P(this,_c,uT());P(this,id,0);P(this,Cn,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',n=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=t;const o=s.decode().then(()=>(n.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(n.getImageData(0,0,1,1).data.buffer)[0]===0));return Kt(this,"_isSVGFittingCanvas",o)}async getFromFile(t){const{lastModified:e,name:n,size:s,type:o}=t;return M(this,Ec,Zp).call(this,`${e}_${n}_${s}_${o}`,t)}async getFromUrl(t){return M(this,Ec,Zp).call(this,t,t)}async getFromBlob(t,e){const n=await e;return M(this,Ec,Zp).call(this,t,n)}async getFromId(t){u(this,Cn)||_(this,Cn,new Map);const e=u(this,Cn).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:n}=e;return delete e.blobPromise,this.getFromBlob(e.id,n)}return this.getFromUrl(e.url)}getFromCanvas(t,e){u(this,Cn)||_(this,Cn,new Map);let n=u(this,Cn).get(t);if(n!=null&&n.bitmap)return n.refCounter+=1,n;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),n={bitmap:s.transferToImageBitmap(),id:`image_${u(this,_c)}_${$n(this,id)._++}`,refCounter:1,isSvg:!1},u(this,Cn).set(t,n),u(this,Cn).set(n.id,n),n}getSvgUrl(t){const e=u(this,Cn).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var s;u(this,Cn)||_(this,Cn,new Map);const e=u(this,Cn).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:n}=e;if(!e.url&&!e.file){const o=new OffscreenCanvas(n.width,n.height);o.getContext("bitmaprenderer").transferFromImageBitmap(n),e.blobPromise=o.convertToBlob()}(s=n.close)==null||s.call(n),e.bitmap=null}isValidId(t){return t.startsWith(`image_${u(this,_c)}_`)}};_c=new WeakMap,id=new WeakMap,Cn=new WeakMap,Ec=new WeakSet,Zp=async function(t,e){u(this,Cn)||_(this,Cn,new Map);let n=u(this,Cn).get(t);if(n===null)return null;if(n!=null&&n.bitmap)return n.refCounter+=1,n;try{n||(n={bitmap:null,id:`image_${u(this,_c)}_${$n(this,id)._++}`,refCounter:0,isSvg:!1});let s;if(typeof e=="string"?(n.url=e,s=await pm(e,"blob")):e instanceof File?s=n.file=e:e instanceof Blob&&(s=e),s.type==="image/svg+xml"){const o=hx._isSVGFittingCanvas,l=new FileReader,c=new Image,d=new Promise((f,g)=>{c.onload=()=>{n.bitmap=c,n.isSvg=!0,f()},l.onload=async()=>{const m=n.svgUrl=l.result;c.src=await o?`${m}#svgView(preserveAspectRatio(none))`:m},c.onerror=l.onerror=g});l.readAsDataURL(s),await d}else n.bitmap=await createImageBitmap(s);n.refCounter=1}catch(s){Ut(s),n=null}return u(this,Cn).set(t,n),n&&u(this,Cn).set(n.id,n),n};let Ly=hx;var Fe,xo,sd,Pe;class vT{constructor(t=128){P(this,Fe,[]);P(this,xo,!1);P(this,sd);P(this,Pe,-1);_(this,sd,t)}add({cmd:t,undo:e,post:n,mustExec:s,type:o=NaN,overwriteIfSameType:l=!1,keepUndo:c=!1}){if(s&&t(),u(this,xo))return;const d={cmd:t,undo:e,post:n,type:o};if(u(this,Pe)===-1){u(this,Fe).length>0&&(u(this,Fe).length=0),_(this,Pe,0),u(this,Fe).push(d);return}if(l&&u(this,Fe)[u(this,Pe)].type===o){c&&(d.undo=u(this,Fe)[u(this,Pe)].undo),u(this,Fe)[u(this,Pe)]=d;return}const f=u(this,Pe)+1;f===u(this,sd)?u(this,Fe).splice(0,1):(_(this,Pe,f),f<u(this,Fe).length&&u(this,Fe).splice(f)),u(this,Fe).push(d)}undo(){if(u(this,Pe)===-1)return;_(this,xo,!0);const{undo:t,post:e}=u(this,Fe)[u(this,Pe)];t(),e==null||e(),_(this,xo,!1),_(this,Pe,u(this,Pe)-1)}redo(){if(u(this,Pe)<u(this,Fe).length-1){_(this,Pe,u(this,Pe)+1),_(this,xo,!0);const{cmd:t,post:e}=u(this,Fe)[u(this,Pe)];t(),e==null||e(),_(this,xo,!1)}}hasSomethingToUndo(){return u(this,Pe)!==-1}hasSomethingToRedo(){return u(this,Pe)<u(this,Fe).length-1}cleanType(t){if(u(this,Pe)!==-1){for(let e=u(this,Pe);e>=0;e--)if(u(this,Fe)[e].type!==t){u(this,Fe).splice(e+1,u(this,Pe)-e),_(this,Pe,e);return}u(this,Fe).length=0,_(this,Pe,-1)}}destroy(){_(this,Fe,null)}}Fe=new WeakMap,xo=new WeakMap,sd=new WeakMap,Pe=new WeakMap;var Wg,bS;class Cf{constructor(t){P(this,Wg);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Wn.platform;for(const[n,s,o={}]of t)for(const l of n){const c=l.startsWith("mac+");e&&c?(this.callbacks.set(l.slice(4),{callback:s,options:o}),this.allKeys.add(l.split("+").at(-1))):!e&&!c&&(this.callbacks.set(l,{callback:s,options:o}),this.allKeys.add(l.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const n=this.callbacks.get(M(this,Wg,bS).call(this,e));if(!n)return;const{callback:s,options:{bubbles:o=!1,args:l=[],checker:c=null}}=n;c&&!c(t,e)||(s.bind(t,...l,e)(),o||ki(e))}}Wg=new WeakSet,bS=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const Gg=class Gg{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return gT(t),Kt(this,"_colors",t)}convert(t){const e=ex(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[n,s]of this._colors)if(s.every((o,l)=>o===e[l]))return Gg._colorsMapping.get(n);return e}getHexCode(t){const e=this._colors.get(t);return e?Pt.makeHexColor(...e):t}};It(Gg,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Iy=Gg;var kc,di,Qe,fn,Cc,hr,Tc,$i,wo,Ra,Pc,Na,Ls,as,La,rd,od,Mc,ad,Is,bo,Rc,So,Ds,Xg,Ao,ld,_o,Ia,cd,ud,rn,le,dr,Da,hd,dd,Eo,Fs,fr,fd,zi,gt,tg,Dy,SS,AS,eg,_S,ES,kS,Fy,CS,Oy,jy,TS,zn,ar,PS,MS,$y,RS,kh,zy;const wc=class wc{constructor(t,e,n,s,o,l,c,d,f,g,m,y,x){P(this,gt);P(this,kc,new AbortController);P(this,di,null);P(this,Qe,new Map);P(this,fn,new Map);P(this,Cc,null);P(this,hr,null);P(this,Tc,null);P(this,$i,new vT);P(this,wo,null);P(this,Ra,null);P(this,Pc,0);P(this,Na,new Set);P(this,Ls,null);P(this,as,null);P(this,La,new Set);It(this,"_editorUndoBar",null);P(this,rd,!1);P(this,od,!1);P(this,Mc,!1);P(this,ad,null);P(this,Is,null);P(this,bo,null);P(this,Rc,null);P(this,So,!1);P(this,Ds,null);P(this,Xg,new yT);P(this,Ao,!1);P(this,ld,!1);P(this,_o,null);P(this,Ia,null);P(this,cd,null);P(this,ud,null);P(this,rn,Bt.NONE);P(this,le,new Set);P(this,dr,null);P(this,Da,null);P(this,hd,null);P(this,dd,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});P(this,Eo,[0,0]);P(this,Fs,null);P(this,fr,null);P(this,fd,null);P(this,zi,null);const b=this._signal=u(this,kc).signal;_(this,fr,t),_(this,fd,e),_(this,Cc,n),this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:b}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:b}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:b}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:b}),s._on("setpreference",this.onSetPreference.bind(this),{signal:b}),s._on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),{signal:b}),M(this,gt,_S).call(this),M(this,gt,TS).call(this),M(this,gt,Fy).call(this),_(this,hr,o.annotationStorage),_(this,ad,o.filterFactory),_(this,Da,l),_(this,Rc,c||null),_(this,rd,d),_(this,od,f),_(this,Mc,g),_(this,ud,m||null),this.viewParameters={realScale:ta.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=y||null,this._supportsPinchToZoom=x!==!1}static get _keyboardManager(){const t=wc.prototype,e=l=>u(l,fr).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&l.hasSomethingToControl(),n=(l,{target:c})=>{if(c instanceof HTMLInputElement){const{type:d}=c;return d!=="text"&&d!=="number"}return!0},s=this.TRANSLATE_SMALL,o=this.TRANSLATE_BIG;return Kt(this,"_keyboardManager",new Cf([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],t.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:n}],[["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:n}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(l,{target:c})=>!(c instanceof HTMLButtonElement)&&u(l,fr).contains(c)&&!l.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(l,{target:c})=>!(c instanceof HTMLButtonElement)&&u(l,fr).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-o,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[o,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-o],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,o],checker:e}]]))}destroy(){var t,e,n,s,o;(t=u(this,zi))==null||t.resolve(),_(this,zi,null),(e=u(this,kc))==null||e.abort(),_(this,kc,null),this._signal=null;for(const l of u(this,fn).values())l.destroy();u(this,fn).clear(),u(this,Qe).clear(),u(this,La).clear(),_(this,di,null),u(this,le).clear(),u(this,$i).destroy(),(n=u(this,Cc))==null||n.destroy(),(s=u(this,Ds))==null||s.hide(),_(this,Ds,null),u(this,Is)&&(clearTimeout(u(this,Is)),_(this,Is,null)),u(this,Fs)&&(clearTimeout(u(this,Fs)),_(this,Fs,null)),(o=this._editorUndoBar)==null||o.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return u(this,ud)}get useNewAltTextFlow(){return u(this,od)}get useNewAltTextWhenAddingImage(){return u(this,Mc)}get hcmFilter(){return Kt(this,"hcmFilter",u(this,Da)?u(this,ad).addHCMFilter(u(this,Da).foreground,u(this,Da).background):"none")}get direction(){return Kt(this,"direction",getComputedStyle(u(this,fr)).direction)}get highlightColors(){return Kt(this,"highlightColors",u(this,Rc)?new Map(u(this,Rc).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return Kt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),_(this,Ra,t)}setMainHighlightColorPicker(t){_(this,cd,t)}editAltText(t,e=!1){var n;(n=u(this,Cc))==null||n.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":_(this,Mc,e);break}}onPageChanging({pageNumber:t}){_(this,Pc,t-1)}focusMainContainer(){u(this,fr).focus()}findParent(t,e){for(const n of u(this,fn).values()){const{x:s,y:o,width:l,height:c}=n.div.getBoundingClientRect();if(t>=s&&t<=s+l&&e>=o&&e<=o+c)return n}return null}disableUserSelect(t=!1){u(this,fd).classList.toggle("noUserSelect",t)}addShouldRescale(t){u(this,La).add(t)}removeShouldRescale(t){u(this,La).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*ta.PDF_TO_CSS_UNITS;for(const n of u(this,La))n.onScaleChanging();(e=u(this,Ra))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l}=e,c=e.toString(),f=M(this,gt,tg).call(this,e).closest(".textLayer"),g=this.getSelectionBoxes(f);if(!g)return;e.empty();const m=M(this,gt,Dy).call(this,f),y=u(this,rn)===Bt.NONE,x=()=>{m==null||m.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:g,anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l,text:c}),y&&this.showAllEditors("highlight",!0,!0)};if(y){this.switchToMode(Bt.HIGHLIGHT,x);return}x()}addToAnnotationStorage(t){!t.isEmpty()&&u(this,hr)&&!u(this,hr).has(t.id)&&u(this,hr).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,u(this,So)&&(_(this,So,!1),M(this,gt,eg).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of u(this,le))if(e.div.contains(t)){_(this,Ia,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!u(this,Ia))return;const[t,e]=u(this,Ia);_(this,Ia,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){M(this,gt,Fy).call(this),M(this,gt,Oy).call(this)}removeEditListeners(){M(this,gt,CS).call(this),M(this,gt,jy).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const n of u(this,as))if(n.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const n of u(this,as))if(n.isHandlingMimeForPasting(e.type)){n.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var n;if(t.preventDefault(),(n=u(this,di))==null||n.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of u(this,le)){const o=s.serialize(!0);o&&e.push(o)}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 o of e.items)for(const l of u(this,as))if(l.isHandlingMimeForPasting(o.type)){l.paste(o,this.currentLayer);return}let n=e.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(o){Ut(`paste: "${o.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();const s=this.currentLayer;try{const o=[];for(const d of n){const f=await s.deserialize(d);if(!f)return;o.push(f)}const l=()=>{for(const d of o)M(this,gt,$y).call(this,d);M(this,gt,zy).call(this,o)},c=()=>{for(const d of o)d.remove()};this.addCommands({cmd:l,undo:c,mustExec:!0})}catch(o){Ut(`paste: "${o.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),u(this,rn)!==Bt.NONE&&!this.isEditorHandlingKeyboard&&wc._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,u(this,So)&&(_(this,So,!1),M(this,gt,eg).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(t){t?(M(this,gt,ES).call(this),M(this,gt,Oy).call(this),M(this,gt,zn).call(this,{isEditing:u(this,rn)!==Bt.NONE,isEmpty:M(this,gt,kh).call(this),hasSomethingToUndo:u(this,$i).hasSomethingToUndo(),hasSomethingToRedo:u(this,$i).hasSomethingToRedo(),hasSelectedEditor:!1})):(M(this,gt,kS).call(this),M(this,gt,jy).call(this),M(this,gt,zn).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!u(this,as)){_(this,as,t);for(const e of u(this,as))M(this,gt,ar).call(this,e.defaultPropertiesToUpdate)}}getId(){return u(this,Xg).id}get currentLayer(){return u(this,fn).get(u(this,Pc))}getLayer(t){return u(this,fn).get(t)}get currentPageIndex(){return u(this,Pc)}addLayer(t){u(this,fn).set(t.pageIndex,t),u(this,Ao)?t.enable():t.disable()}removeLayer(t){u(this,fn).delete(t.pageIndex)}async updateMode(t,e=null,n=!1){var s;if(u(this,rn)!==t&&!(u(this,zi)&&(await u(this,zi).promise,!u(this,zi)))){if(_(this,zi,Promise.withResolvers()),_(this,rn,t),t===Bt.NONE){this.setEditingState(!1),M(this,gt,MS).call(this),(s=this._editorUndoBar)==null||s.hide(),u(this,zi).resolve();return}this.setEditingState(!0),await M(this,gt,PS).call(this),this.unselectAll();for(const o of u(this,fn).values())o.updateMode(t);if(!e){n&&this.addNewEditorFromKeyboard(),u(this,zi).resolve();return}for(const o of u(this,Qe).values())o.annotationElementId===e?(this.setSelected(o),o.enterInEditMode()):o.unselect();u(this,zi).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==u(this,rn)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var n;if(u(this,as)){switch(t){case Jt.CREATE:this.currentLayer.addNewEditor();return;case Jt.HIGHLIGHT_DEFAULT_COLOR:(n=u(this,cd))==null||n.updateColor(e);break;case Jt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(u(this,hd)||_(this,hd,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const s of u(this,le))s.updateParams(t,e);for(const s of u(this,as))s.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){var o;for(const l of u(this,Qe).values())l.editorType===t&&l.show(e);(((o=u(this,hd))==null?void 0:o.get(Jt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&M(this,gt,ar).call(this,[[Jt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(u(this,ld)!==t){_(this,ld,t);for(const e of u(this,fn).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const n of u(this,Qe).values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return u(this,Qe).get(t)}addEditor(t){u(this,Qe).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(u(this,Is)&&clearTimeout(u(this,Is)),_(this,Is,setTimeout(()=>{this.focusMainContainer(),_(this,Is,null)},0))),u(this,Qe).delete(t.id),this.unselect(t),(!t.annotationElementId||!u(this,Na).has(t.annotationElementId))&&((e=u(this,hr))==null||e.remove(t.id))}addDeletedAnnotationElement(t){u(this,Na).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return u(this,Na).has(t)}removeDeletedAnnotationElement(t){u(this,Na).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){u(this,di)!==t&&(_(this,di,t),t&&M(this,gt,ar).call(this,t.propertiesToUpdate))}updateUI(t){u(this,gt,RS)===t&&M(this,gt,ar).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){M(this,gt,ar).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(u(this,le).has(t)){u(this,le).delete(t),t.unselect(),M(this,gt,zn).call(this,{hasSelectedEditor:this.hasSelection});return}u(this,le).add(t),t.select(),M(this,gt,ar).call(this,t.propertiesToUpdate),M(this,gt,zn).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;(e=u(this,Ra))==null||e.commitOrRemove();for(const n of u(this,le))n!==t&&n.unselect();u(this,le).clear(),u(this,le).add(t),t.select(),M(this,gt,ar).call(this,t.propertiesToUpdate),M(this,gt,zn).call(this,{hasSelectedEditor:!0})}isSelected(t){return u(this,le).has(t)}get firstSelectedEditor(){return u(this,le).values().next().value}unselect(t){t.unselect(),u(this,le).delete(t),M(this,gt,zn).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return u(this,le).size!==0}get isEnterHandled(){return u(this,le).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;u(this,$i).undo(),M(this,gt,zn).call(this,{hasSomethingToUndo:u(this,$i).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:M(this,gt,kh).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){u(this,$i).redo(),M(this,gt,zn).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:u(this,$i).hasSomethingToRedo(),isEmpty:M(this,gt,kh).call(this)})}addCommands(t){u(this,$i).add(t),M(this,gt,zn).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:M(this,gt,kh).call(this)})}cleanUndoStack(t){u(this,$i).cleanType(t)}delete(){var o;this.commitOrRemove();const t=(o=this.currentLayer)==null?void 0:o.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...u(this,le)],n=()=>{var l;(l=this._editorUndoBar)==null||l.show(s,e.length===1?e[0].editorType:e.length);for(const c of e)c.remove()},s=()=>{for(const l of e)M(this,gt,$y).call(this,l)};this.addCommands({cmd:n,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=u(this,di))==null||t.commitOrRemove()}hasSomethingToControl(){return u(this,di)||this.hasSelection}selectAll(){for(const t of u(this,le))t.commit();M(this,gt,zy).call(this,u(this,Qe).values())}unselectAll(){var t;if(!(u(this,di)&&(u(this,di).commitOrRemove(),u(this,rn)!==Bt.NONE))&&!((t=u(this,Ra))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of u(this,le))e.unselect();u(this,le).clear(),M(this,gt,zn).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;u(this,Eo)[0]+=t,u(this,Eo)[1]+=e;const[s,o]=u(this,Eo),l=[...u(this,le)],c=1e3;u(this,Fs)&&clearTimeout(u(this,Fs)),_(this,Fs,setTimeout(()=>{_(this,Fs,null),u(this,Eo)[0]=u(this,Eo)[1]=0,this.addCommands({cmd:()=>{for(const d of l)u(this,Qe).has(d.id)&&d.translateInPage(s,o)},undo:()=>{for(const d of l)u(this,Qe).has(d.id)&&d.translateInPage(-s,-o)},mustExec:!1})},c));for(const d of l)d.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),_(this,Ls,new Map);for(const t of u(this,le))u(this,Ls).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!u(this,Ls))return!1;this.disableUserSelect(!1);const t=u(this,Ls);_(this,Ls,null);let e=!1;for(const[{x:s,y:o,pageIndex:l},c]of t)c.newX=s,c.newY=o,c.newPageIndex=l,e||(e=s!==c.savedX||o!==c.savedY||l!==c.savedPageIndex);if(!e)return!1;const n=(s,o,l,c)=>{if(u(this,Qe).has(s.id)){const d=u(this,fn).get(c);d?s._setParentAndPosition(d,o,l):(s.pageIndex=c,s.x=o,s.y=l)}};return this.addCommands({cmd:()=>{for(const[s,{newX:o,newY:l,newPageIndex:c}]of t)n(s,o,l,c)},undo:()=>{for(const[s,{savedX:o,savedY:l,savedPageIndex:c}]of t)n(s,o,l,c)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(u(this,Ls))for(const n of u(this,Ls).keys())n.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||u(this,le).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return u(this,di)===t}getActive(){return u(this,di)}getMode(){return u(this,rn)}get imageManager(){return Kt(this,"imageManager",new Ly)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let f=0,g=e.rangeCount;f<g;f++)if(!t.contains(e.getRangeAt(f).commonAncestorContainer))return null;const{x:n,y:s,width:o,height:l}=t.getBoundingClientRect();let c;switch(t.getAttribute("data-main-rotation")){case"90":c=(f,g,m,y)=>({x:(g-s)/l,y:1-(f+m-n)/o,width:y/l,height:m/o});break;case"180":c=(f,g,m,y)=>({x:1-(f+m-n)/o,y:1-(g+y-s)/l,width:m/o,height:y/l});break;case"270":c=(f,g,m,y)=>({x:1-(g+y-s)/l,y:(f-n)/o,width:y/l,height:m/o});break;default:c=(f,g,m,y)=>({x:(f-n)/o,y:(g-s)/l,width:m/o,height:y/l});break}const d=[];for(let f=0,g=e.rangeCount;f<g;f++){const m=e.getRangeAt(f);if(!m.collapsed)for(const{x:y,y:x,width:b,height:A}of m.getClientRects())b===0||A===0||d.push(c(y,x,b,A))}return d.length===0?null:d}addChangedExistingAnnotation({annotationElementId:t,id:e}){(u(this,Tc)||_(this,Tc,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=u(this,Tc))==null||e.delete(t)}renderAnnotationElement(t){var s;const e=(s=u(this,Tc))==null?void 0:s.get(t.data.id);if(!e)return;const n=u(this,hr).getRawValue(e);n&&(u(this,rn)===Bt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(t))}};kc=new WeakMap,di=new WeakMap,Qe=new WeakMap,fn=new WeakMap,Cc=new WeakMap,hr=new WeakMap,Tc=new WeakMap,$i=new WeakMap,wo=new WeakMap,Ra=new WeakMap,Pc=new WeakMap,Na=new WeakMap,Ls=new WeakMap,as=new WeakMap,La=new WeakMap,rd=new WeakMap,od=new WeakMap,Mc=new WeakMap,ad=new WeakMap,Is=new WeakMap,bo=new WeakMap,Rc=new WeakMap,So=new WeakMap,Ds=new WeakMap,Xg=new WeakMap,Ao=new WeakMap,ld=new WeakMap,_o=new WeakMap,Ia=new WeakMap,cd=new WeakMap,ud=new WeakMap,rn=new WeakMap,le=new WeakMap,dr=new WeakMap,Da=new WeakMap,hd=new WeakMap,dd=new WeakMap,Eo=new WeakMap,Fs=new WeakMap,fr=new WeakMap,fd=new WeakMap,zi=new WeakMap,gt=new WeakSet,tg=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Dy=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const n of u(this,fn).values())if(n.hasTextLayer(t))return n;return null},SS=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const n=M(this,gt,tg).call(this,t).closest(".textLayer"),s=this.getSelectionBoxes(n);s&&(u(this,Ds)||_(this,Ds,new mT(this)),u(this,Ds).show(n,s,this.direction==="ltr"))},AS=function(){var o,l,c;const t=document.getSelection();if(!t||t.isCollapsed){u(this,dr)&&((o=u(this,Ds))==null||o.hide(),_(this,dr,null),M(this,gt,zn).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===u(this,dr))return;const s=M(this,gt,tg).call(this,t).closest(".textLayer");if(!s){u(this,dr)&&((l=u(this,Ds))==null||l.hide(),_(this,dr,null),M(this,gt,zn).call(this,{hasSelectedText:!1}));return}if((c=u(this,Ds))==null||c.hide(),_(this,dr,e),M(this,gt,zn).call(this,{hasSelectedText:!0}),!(u(this,rn)!==Bt.HIGHLIGHT&&u(this,rn)!==Bt.NONE)&&(u(this,rn)===Bt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),_(this,So,this.isShiftKeyDown),!this.isShiftKeyDown)){const d=u(this,rn)===Bt.HIGHLIGHT?M(this,gt,Dy).call(this,s):null;d==null||d.toggleDrawing();const f=new AbortController,g=this.combinedSignal(f),m=y=>{y.type==="pointerup"&&y.button!==0||(f.abort(),d==null||d.toggleDrawing(!0),y.type==="pointerup"&&M(this,gt,eg).call(this,"main_toolbar"))};window.addEventListener("pointerup",m,{signal:g}),window.addEventListener("blur",m,{signal:g})}},eg=function(t=""){u(this,rn)===Bt.HIGHLIGHT?this.highlightSelection(t):u(this,rd)&&M(this,gt,SS).call(this)},_S=function(){document.addEventListener("selectionchange",M(this,gt,AS).bind(this),{signal:this._signal})},ES=function(){if(u(this,bo))return;_(this,bo,new AbortController);const t=this.combinedSignal(u(this,bo));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},kS=function(){var t;(t=u(this,bo))==null||t.abort(),_(this,bo,null)},Fy=function(){if(u(this,_o))return;_(this,_o,new AbortController);const t=this.combinedSignal(u(this,_o));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},CS=function(){var t;(t=u(this,_o))==null||t.abort(),_(this,_o,null)},Oy=function(){if(u(this,wo))return;_(this,wo,new AbortController);const t=this.combinedSignal(u(this,wo));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})},jy=function(){var t;(t=u(this,wo))==null||t.abort(),_(this,wo,null)},TS=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},zn=function(t){Object.entries(t).some(([n,s])=>u(this,dd)[n]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(u(this,dd),t)}),u(this,rn)===Bt.HIGHLIGHT&&t.hasSelectedEditor===!1&&M(this,gt,ar).call(this,[[Jt.HIGHLIGHT_FREE,!0]]))},ar=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},PS=async function(){if(!u(this,Ao)){_(this,Ao,!0);const t=[];for(const e of u(this,fn).values())t.push(e.enable());await Promise.all(t);for(const e of u(this,Qe).values())e.enable()}},MS=function(){if(this.unselectAll(),u(this,Ao)){_(this,Ao,!1);for(const t of u(this,fn).values())t.disable();for(const t of u(this,Qe).values())t.disable()}},$y=function(t){const e=u(this,fn).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},RS=function(){let t=null;for(t of u(this,le));return t},kh=function(){if(u(this,Qe).size===0)return!0;if(u(this,Qe).size===1)for(const t of u(this,Qe).values())return t.isEmpty();return!1},zy=function(t){for(const e of u(this,le))e.unselect();u(this,le).clear();for(const e of t)e.isEmpty()||(u(this,le).add(e),e.select());M(this,gt,zn).call(this,{hasSelectedEditor:this.hasSelection})},It(wc,"TRANSLATE_SMALL",1),It(wc,"TRANSLATE_BIG",10);let Ll=wc;var on,Os,ls,Nc,js,fi,Lc,$s,ii,pr,Fa,zs,ko,xs,Ch,ng;const Hn=class Hn{constructor(t){P(this,xs);P(this,on,null);P(this,Os,!1);P(this,ls,null);P(this,Nc,null);P(this,js,null);P(this,fi,null);P(this,Lc,!1);P(this,$s,null);P(this,ii,null);P(this,pr,null);P(this,Fa,null);P(this,zs,!1);_(this,ii,t),_(this,zs,t._uiManager.useNewAltTextFlow),u(Hn,ko)||_(Hn,ko,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){Hn._l10n??(Hn._l10n=t)}async render(){const t=_(this,ls,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=_(this,Nc,document.createElement("span"));t.append(e),u(this,zs)?(t.classList.add("new"),t.setAttribute("data-l10n-id",u(Hn,ko).missing),e.setAttribute("data-l10n-id",u(Hn,ko)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const n=u(this,ii)._uiManager._signal;t.addEventListener("contextmenu",bs,{signal:n}),t.addEventListener("pointerdown",o=>o.stopPropagation(),{signal:n});const s=o=>{o.preventDefault(),u(this,ii)._uiManager.editAltText(u(this,ii)),u(this,zs)&&u(this,ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:u(this,xs,Ch)}})};return t.addEventListener("click",s,{capture:!0,signal:n}),t.addEventListener("keydown",o=>{o.target===t&&o.key==="Enter"&&(_(this,Lc,!0),s(o))},{signal:n}),await M(this,xs,ng).call(this),t}finish(){u(this,ls)&&(u(this,ls).focus({focusVisible:u(this,Lc)}),_(this,Lc,!1))}isEmpty(){return u(this,zs)?u(this,on)===null:!u(this,on)&&!u(this,Os)}hasData(){return u(this,zs)?u(this,on)!==null||!!u(this,pr):this.isEmpty()}get guessedText(){return u(this,pr)}async setGuessedText(t){u(this,on)===null&&(_(this,pr,t),_(this,Fa,await Hn._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),M(this,xs,ng).call(this))}toggleAltTextBadge(t=!1){var e;if(!u(this,zs)||u(this,on)){(e=u(this,$s))==null||e.remove(),_(this,$s,null);return}if(!u(this,$s)){const n=_(this,$s,document.createElement("div"));n.className="noAltTextBadge",u(this,ii).div.append(n)}u(this,$s).classList.toggle("hidden",!t)}serialize(t){let e=u(this,on);return!t&&u(this,pr)===e&&(e=u(this,Fa)),{altText:e,decorative:u(this,Os),guessedText:u(this,pr),textWithDisclaimer:u(this,Fa)}}get data(){return{altText:u(this,on),decorative:u(this,Os)}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:s,cancel:o=!1}){n&&(_(this,pr,n),_(this,Fa,s)),!(u(this,on)===t&&u(this,Os)===e)&&(o||(_(this,on,t),_(this,Os,e)),M(this,xs,ng).call(this))}toggle(t=!1){u(this,ls)&&(!t&&u(this,fi)&&(clearTimeout(u(this,fi)),_(this,fi,null)),u(this,ls).disabled=!t)}shown(){u(this,ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:u(this,xs,Ch)}})}destroy(){var t,e;(t=u(this,ls))==null||t.remove(),_(this,ls,null),_(this,Nc,null),_(this,js,null),(e=u(this,$s))==null||e.remove(),_(this,$s,null)}};on=new WeakMap,Os=new WeakMap,ls=new WeakMap,Nc=new WeakMap,js=new WeakMap,fi=new WeakMap,Lc=new WeakMap,$s=new WeakMap,ii=new WeakMap,pr=new WeakMap,Fa=new WeakMap,zs=new WeakMap,ko=new WeakMap,xs=new WeakSet,Ch=function(){return u(this,on)&&"added"||u(this,on)===null&&this.guessedText&&"review"||"missing"},ng=async function(){var s,o,l;const t=u(this,ls);if(!t)return;if(u(this,zs)){if(t.classList.toggle("done",!!u(this,on)),t.setAttribute("data-l10n-id",u(Hn,ko)[u(this,xs,Ch)]),(s=u(this,Nc))==null||s.setAttribute("data-l10n-id",u(Hn,ko)[`${u(this,xs,Ch)}-label`]),!u(this,on)){(o=u(this,js))==null||o.remove();return}}else{if(!u(this,on)&&!u(this,Os)){t.classList.remove("done"),(l=u(this,js))==null||l.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=u(this,js);if(!e){_(this,js,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${u(this,ii).id}`;const c=100,d=u(this,ii)._uiManager._signal;d.addEventListener("abort",()=>{clearTimeout(u(this,fi)),_(this,fi,null)},{once:!0}),t.addEventListener("mouseenter",()=>{_(this,fi,setTimeout(()=>{_(this,fi,null),u(this,js).classList.add("show"),u(this,ii)._reportTelemetry({action:"alt_text_tooltip"})},c))},{signal:d}),t.addEventListener("mouseleave",()=>{var f;u(this,fi)&&(clearTimeout(u(this,fi)),_(this,fi,null)),(f=u(this,js))==null||f.classList.remove("show")},{signal:d})}u(this,Os)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=u(this,on)),e.parentNode||t.append(e);const n=u(this,ii).getImageForAltText();n==null||n.setAttribute("aria-describedby",e.id)},P(Hn,ko,null),It(Hn,"_l10n",null);let Rg=Hn;var pd,Oa,gd,md,yd,vd,xd,Ic,gr,ja,Co,Hr,NS,LS,Hy;const dx=class dx{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:n=null,onPinchStart:s=null,onPinching:o=null,onPinchEnd:l=null,signal:c}){P(this,Hr);P(this,pd);P(this,Oa,!1);P(this,gd,null);P(this,md);P(this,yd);P(this,vd);P(this,xd);P(this,Ic);P(this,gr,null);P(this,ja);P(this,Co,null);_(this,pd,t),_(this,gd,n),_(this,md,e),_(this,yd,s),_(this,vd,o),_(this,xd,l),_(this,ja,new AbortController),_(this,Ic,AbortSignal.any([c,u(this,ja).signal])),t.addEventListener("touchstart",M(this,Hr,NS).bind(this),{passive:!1,signal:u(this,Ic)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Kt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;(t=u(this,ja))==null||t.abort(),_(this,ja,null)}};pd=new WeakMap,Oa=new WeakMap,gd=new WeakMap,md=new WeakMap,yd=new WeakMap,vd=new WeakMap,xd=new WeakMap,Ic=new WeakMap,gr=new WeakMap,ja=new WeakMap,Co=new WeakMap,Hr=new WeakSet,NS=function(t){var s,o,l;if((s=u(this,md))!=null&&s.call(this)||t.touches.length<2)return;if(!u(this,Co)){_(this,Co,new AbortController);const c=AbortSignal.any([u(this,Ic),u(this,Co).signal]),d=u(this,pd),f={signal:c,passive:!1};d.addEventListener("touchmove",M(this,Hr,LS).bind(this),f),d.addEventListener("touchend",M(this,Hr,Hy).bind(this),f),d.addEventListener("touchcancel",M(this,Hr,Hy).bind(this),f),(o=u(this,yd))==null||o.call(this)}if(ki(t),t.touches.length!==2||(l=u(this,gd))!=null&&l.call(this)){_(this,gr,null);return}let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]),_(this,gr,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:n.screenX,touch1Y:n.screenY})},LS=function(t){var L;if(!u(this,gr)||t.touches.length!==2)return;let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]);const{screenX:s,screenY:o}=e,{screenX:l,screenY:c}=n,d=u(this,gr),{touch0X:f,touch0Y:g,touch1X:m,touch1Y:y}=d,x=m-f,b=y-g,A=l-s,C=c-o,E=Math.hypot(A,C)||1,N=Math.hypot(x,b)||1;if(!u(this,Oa)&&Math.abs(N-E)<=dx.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(d.touch0X=s,d.touch0Y=o,d.touch1X=l,d.touch1Y=c,t.preventDefault(),!u(this,Oa)){_(this,Oa,!0);return}const k=[(s+l)/2,(o+c)/2];(L=u(this,vd))==null||L.call(this,k,N,E)},Hy=function(t){var e;u(this,Co).abort(),_(this,Co,null),(e=u(this,xd))==null||e.call(this),u(this,gr)&&(t.preventDefault(),_(this,gr,null),_(this,Oa,!1))};let Ng=dx;var $a,cs,be,Dc,To,wd,za,pn,Ha,mr,Po,bd,Ba,pi,Sd,Ua,yr,Hs,Fc,Oc,Hi,Va,Ad,qg,Dt,By,_d,Uy,ig,IS,DS,Vy,sg,Wy,FS,OS,jS,Gy,$S,Xy,zS,HS,BS,qy,Th;const Wt=class Wt{constructor(t){P(this,Dt);P(this,$a,null);P(this,cs,null);P(this,be,null);P(this,Dc,!1);P(this,To,null);P(this,wd,"");P(this,za,!1);P(this,pn,null);P(this,Ha,null);P(this,mr,null);P(this,Po,null);P(this,bd,"");P(this,Ba,!1);P(this,pi,null);P(this,Sd,!1);P(this,Ua,!1);P(this,yr,!1);P(this,Hs,null);P(this,Fc,0);P(this,Oc,0);P(this,Hi,null);P(this,Va,null);It(this,"_editToolbar",null);It(this,"_initialOptions",Object.create(null));It(this,"_initialData",null);It(this,"_isVisible",!0);It(this,"_uiManager",null);It(this,"_focusEventsAllowed",!0);P(this,Ad,!1);P(this,qg,Wt._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:n,pageHeight:s,pageX:o,pageY:l}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,s],this.pageTranslation=[o,l];const[c,d]=this.parentDimensions;this.x=t.x/c,this.y=t.y/d,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=Wt.prototype._resizeWithKeyboard,e=Ll.TRANSLATE_SMALL,n=Ll.TRANSLATE_BIG;return Kt(this,"_resizerKeyboardManager",new Cf([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,n]}],[["Escape","mac+Escape"],Wt.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Kt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new xT({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(Wt._l10n??(Wt._l10n=t),Wt._l10nResizer||(Wt._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"})),Wt._borderLineWidth!==-1)return;const n=getComputedStyle(document.documentElement);Wt._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){fe("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return u(this,Ad)}set _isDraggable(t){var e;_(this,Ad,t),(e=this.div)==null||e.classList.toggle("draggable",t)}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=u(this,qg)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):M(this,Dt,Th).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(u(this,Ba)?_(this,Ba,!1):this.parent.setSelected(this))}focusout(t){var n;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(n=this.parent)!=null&&n.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,n,s){const[o,l]=this.parentDimensions;[n,s]=this.screenToPageTranslation(n,s),this.x=(t+n)/o,this.y=(e+s)/l,this.fixAndSetPosition()}translate(t,e){M(this,Dt,By).call(this,this.parentDimensions,t,e)}translateInPage(t,e){u(this,pi)||_(this,pi,[this.x,this.y,this.width,this.height]),M(this,Dt,By).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){u(this,pi)||_(this,pi,[this.x,this.y,this.width,this.height]);const{div:n,parentDimensions:[s,o]}=this;if(this.x+=t/s,this.y+=e/o,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:m,y}=this.div.getBoundingClientRect();this.parent.findNewParent(this,m,y)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:l,y:c}=this;const[d,f]=this.getBaseTranslation();l+=d,c+=f;const{style:g}=n;g.left=`${(100*l).toFixed(2)}%`,g.top=`${(100*c).toFixed(2)}%`,this._onTranslating(l,c),n.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!u(this,pi)&&(u(this,pi)[0]!==this.x||u(this,pi)[1]!==this.y)}get _hasBeenResized(){return!!u(this,pi)&&(u(this,pi)[2]!==this.width||u(this,pi)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:n}=Wt,s=n/t,o=n/e;switch(this.rotation){case 90:return[-s,o];case 180:return[s,o];case 270:return[s,-o];default:return[-s,-o]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[n,s]}=this;let{x:o,y:l,width:c,height:d}=this;if(c*=n,d*=s,o*=n,l*=s,this._mustFixPosition)switch(t){case 0:o=Math.max(0,Math.min(n-c,o)),l=Math.max(0,Math.min(s-d,l));break;case 90:o=Math.max(0,Math.min(n-d,o)),l=Math.min(s,Math.max(c,l));break;case 180:o=Math.min(n,Math.max(c,o)),l=Math.min(s,Math.max(d,l));break;case 270:o=Math.min(n,Math.max(d,o)),l=Math.max(0,Math.min(s-c,l));break}this.x=o/=n,this.y=l/=s;const[f,g]=this.getBaseTranslation();o+=f,l+=g,e.left=`${(100*o).toFixed(2)}%`,e.top=`${(100*l).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var n;return M(n=Wt,_d,Uy).call(n,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var n;return M(n=Wt,_d,Uy).call(n,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,n]}=this;return[e*t,n*t]}setDims(t,e){const[n,s]=this.parentDimensions,{style:o}=this.div;o.width=`${(100*t/n).toFixed(2)}%`,u(this,za)||(o.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:n}=t,s=n.endsWith("%"),o=!u(this,za)&&e.endsWith("%");if(s&&o)return;const[l,c]=this.parentDimensions;s||(t.width=`${(100*parseFloat(n)/l).toFixed(2)}%`),!u(this,za)&&!o&&(t.height=`${(100*parseFloat(e)/c).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=u(this,be))==null||t.finish()}async addEditToolbar(){return this._editToolbar||u(this,Ua)?this._editToolbar:(this._editToolbar=new Ry(this),this.div.append(this._editToolbar.render()),u(this,be)&&await this._editToolbar.addAltText(u(this,be)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=u(this,be))==null||t.destroy())}addContainer(t){var n;const e=(n=this._editToolbar)==null?void 0:n.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){u(this,be)||(Rg.initialize(Wt._l10n),_(this,be,new Rg(this)),u(this,$a)&&(u(this,be).data=u(this,$a),_(this,$a,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=u(this,be))==null?void 0:t.data}set altTextData(t){u(this,be)&&(u(this,be).data=t)}get guessedAltText(){var t;return(t=u(this,be))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=u(this,be))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=u(this,be))==null?void 0:e.serialize(t)}hasAltText(){return!!u(this,be)&&!u(this,be).isEmpty()}hasAltTextData(){var t;return((t=u(this,be))==null?void 0:t.hasData())??!1}render(){var o;this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=u(this,Dc)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),M(this,Dt,Xy).call(this);const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[n,s]=this.getInitialTranslation();return this.translate(n,s),Mg(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(u(this,Va)||_(this,Va,new Ng({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:M(this,Dt,FS).bind(this),onPinching:M(this,Dt,OS).bind(this),onPinchEnd:M(this,Dt,jS).bind(this),signal:this._uiManager._signal}))),(o=this._uiManager._editorUndoBar)==null||o.hide(),this.div}pointerdown(t){const{isMac:e}=Wn.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(_(this,Ba,!0),this._isDraggable){M(this,Dt,$S).call(this,t);return}M(this,Dt,Gy).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){u(this,Hs)&&clearTimeout(u(this,Hs)),_(this,Hs,setTimeout(()=>{var t;_(this,Hs,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,n){t.changeParent(this),this.x=e,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,n=this.rotation){const s=this.parentScale,[o,l]=this.pageDimensions,[c,d]=this.pageTranslation,f=t/s,g=e/s,m=this.x*o,y=this.y*l,x=this.width*o,b=this.height*l;switch(n){case 0:return[m+f+c,l-y-g-b+d,m+f+x+c,l-y-g+d];case 90:return[m+g+c,l-y+f+d,m+g+b+c,l-y+f+x+d];case 180:return[m-f-x+c,l-y+g+d,m-f+c,l-y+g+b+d];case 270:return[m-g-b+c,l-y-f-x+d,m-g+c,l-y-f+d];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[n,s,o,l]=t,c=o-n,d=l-s;switch(this.rotation){case 0:return[n,e-l,c,d];case 90:return[n,e-s,d,c];case 180:return[o,e-s,c,d];case 270:return[o,e-l,d,c];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){_(this,Ua,!0)}disableEditMode(){_(this,Ua,!1)}isInEditMode(){return u(this,Ua)}shouldGetKeyboardEvents(){return u(this,yr)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:n,right:s}=this.getClientDimensions(),{innerHeight:o,innerWidth:l}=window;return e<l&&s>0&&t<o&&n>0}rebuild(){M(this,Dt,Xy).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){fe("An editor must be serializable")}static async deserialize(t,e,n){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:n});s.rotation=t.rotation,_(s,$a,t.accessibilityData);const[o,l]=s.pageDimensions,[c,d,f,g]=s.getRectInCurrentCoords(t.rect,l);return s.x=c/o,s.y=d/l,s.width=f/o,s.height=g/l,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=u(this,Po))==null||t.abort(),_(this,Po,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),u(this,Hs)&&(clearTimeout(u(this,Hs)),_(this,Hs,null)),M(this,Dt,Th).call(this),this.removeEditToolbar(),u(this,Hi)){for(const n of u(this,Hi).values())clearTimeout(n);_(this,Hi,null)}this.parent=null,(e=u(this,Va))==null||e.destroy(),_(this,Va,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(M(this,Dt,IS).call(this),u(this,pn).classList.remove("hidden"),Mg(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),_(this,mr,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=u(this,pn).children;if(!u(this,cs)){_(this,cs,Array.from(e));const l=M(this,Dt,zS).bind(this),c=M(this,Dt,HS).bind(this),d=this._uiManager._signal;for(const f of u(this,cs)){const g=f.getAttribute("data-resizer-name");f.setAttribute("role","spinbutton"),f.addEventListener("keydown",l,{signal:d}),f.addEventListener("blur",c,{signal:d}),f.addEventListener("focus",M(this,Dt,BS).bind(this,g),{signal:d}),f.setAttribute("data-l10n-id",Wt._l10nResizer[g])}}const n=u(this,cs)[0];let s=0;for(const l of e){if(l===n)break;s++}const o=(360-this.rotation+this.parentRotation)%360/90*(u(this,cs).length/4);if(o!==s){if(o<s)for(let c=0;c<s-o;c++)u(this,pn).append(u(this,pn).firstChild);else if(o>s)for(let c=0;c<o-s;c++)u(this,pn).firstChild.before(u(this,pn).lastChild);let l=0;for(const c of e){const f=u(this,cs)[l++].getAttribute("data-resizer-name");c.setAttribute("data-l10n-id",Wt._l10nResizer[f])}}M(this,Dt,qy).call(this,0),_(this,yr,!0),u(this,pn).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){u(this,yr)&&M(this,Dt,Wy).call(this,u(this,bd),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){M(this,Dt,Th).call(this),this.div.focus()}select(){var t,e,n;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var s,o;(s=this.div)!=null&&s.classList.contains("selectedEditor")&&((o=this._editToolbar)==null||o.show())});return}(e=this._editToolbar)==null||e.show(),(n=u(this,be))==null||n.toggleAltTextBadge(!1)}unselect(){var t,e,n,s,o;(t=u(this,pn))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(n=this.div)!=null&&n.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(s=this._editToolbar)==null||s.hide(),(o=u(this,be))==null||o.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return u(this,Sd)}set isEditing(t){_(this,Sd,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){_(this,za,!0);const n=t/e,{style:s}=this.div;s.aspectRatio=n,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){u(this,Hi)||_(this,Hi,new Map);const{action:n}=t;let s=u(this,Hi).get(n);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(t),u(this,Hi).delete(n),u(this,Hi).size===0&&_(this,Hi,null)},Wt._telemetryTimeout),u(this,Hi).set(n,s);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),_(this,Dc,!1)}disable(){this.div&&(this.div.tabIndex=-1),_(this,Dc,!0)}renderAnnotationElement(t){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 n=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),n.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};$a=new WeakMap,cs=new WeakMap,be=new WeakMap,Dc=new WeakMap,To=new WeakMap,wd=new WeakMap,za=new WeakMap,pn=new WeakMap,Ha=new WeakMap,mr=new WeakMap,Po=new WeakMap,bd=new WeakMap,Ba=new WeakMap,pi=new WeakMap,Sd=new WeakMap,Ua=new WeakMap,yr=new WeakMap,Hs=new WeakMap,Fc=new WeakMap,Oc=new WeakMap,Hi=new WeakMap,Va=new WeakMap,Ad=new WeakMap,qg=new WeakMap,Dt=new WeakSet,By=function([t,e],n,s){[n,s]=this.screenToPageTranslation(n,s),this.x+=n/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},_d=new WeakSet,Uy=function(t,e,n){switch(n){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},ig=function(t){switch(t){case 90:{const[e,n]=this.pageDimensions;return[0,-e/n,n/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,n]=this.pageDimensions;return[0,e/n,-n/e,0]}default:return[1,0,0,1]}},IS=function(){if(u(this,pn))return;_(this,pn,document.createElement("div")),u(this,pn).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 n of t){const s=document.createElement("div");u(this,pn).append(s),s.classList.add("resizer",n),s.setAttribute("data-resizer-name",n),s.addEventListener("pointerdown",M(this,Dt,DS).bind(this,n),{signal:e}),s.addEventListener("contextmenu",bs,{signal:e}),s.tabIndex=-1}this.div.prepend(u(this,pn))},DS=function(t,e){var g;e.preventDefault();const{isMac:n}=Wn.platform;if(e.button!==0||e.ctrlKey&&n)return;(g=u(this,be))==null||g.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,_(this,Ha,[e.screenX,e.screenY]);const o=new AbortController,l=this._uiManager.combinedSignal(o);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",M(this,Dt,Wy).bind(this,t),{passive:!0,capture:!0,signal:l}),window.addEventListener("touchmove",ki,{passive:!1,signal:l}),window.addEventListener("contextmenu",bs,{signal:l}),_(this,mr,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const c=this.parent.div.style.cursor,d=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const f=()=>{var m;o.abort(),this.parent.togglePointerEvents(!0),(m=u(this,be))==null||m.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=c,this.div.style.cursor=d,M(this,Dt,sg).call(this)};window.addEventListener("pointerup",f,{signal:l}),window.addEventListener("blur",f,{signal:l})},Vy=function(t,e,n,s){this.width=n,this.height=s,this.x=t,this.y=e;const[o,l]=this.parentDimensions;this.setDims(o*n,l*s),this.fixAndSetPosition(),this._onResized()},sg=function(){if(!u(this,mr))return;const{savedX:t,savedY:e,savedWidth:n,savedHeight:s}=u(this,mr);_(this,mr,null);const o=this.x,l=this.y,c=this.width,d=this.height;o===t&&l===e&&c===n&&d===s||this.addCommands({cmd:M(this,Dt,Vy).bind(this,o,l,c,d),undo:M(this,Dt,Vy).bind(this,t,e,n,s),mustExec:!0})},Wy=function(t,e){const[n,s]=this.parentDimensions,o=this.x,l=this.y,c=this.width,d=this.height,f=Wt.MIN_SIZE/n,g=Wt.MIN_SIZE/s,m=M(this,Dt,ig).call(this,this.rotation),y=(Q,tt)=>[m[0]*Q+m[2]*tt,m[1]*Q+m[3]*tt],x=M(this,Dt,ig).call(this,360-this.rotation),b=(Q,tt)=>[x[0]*Q+x[2]*tt,x[1]*Q+x[3]*tt];let A,C,E=!1,N=!1;switch(t){case"topLeft":E=!0,A=(Q,tt)=>[0,0],C=(Q,tt)=>[Q,tt];break;case"topMiddle":A=(Q,tt)=>[Q/2,0],C=(Q,tt)=>[Q/2,tt];break;case"topRight":E=!0,A=(Q,tt)=>[Q,0],C=(Q,tt)=>[0,tt];break;case"middleRight":N=!0,A=(Q,tt)=>[Q,tt/2],C=(Q,tt)=>[0,tt/2];break;case"bottomRight":E=!0,A=(Q,tt)=>[Q,tt],C=(Q,tt)=>[0,0];break;case"bottomMiddle":A=(Q,tt)=>[Q/2,tt],C=(Q,tt)=>[Q/2,0];break;case"bottomLeft":E=!0,A=(Q,tt)=>[0,tt],C=(Q,tt)=>[Q,0];break;case"middleLeft":N=!0,A=(Q,tt)=>[0,tt/2],C=(Q,tt)=>[Q,tt/2];break}const k=A(c,d),L=C(c,d);let R=y(...L);const j=Wt._round(o+R[0]),O=Wt._round(l+R[1]);let H=1,X=1,q,K;if(e.fromKeyboard)({deltaX:q,deltaY:K}=e);else{const{screenX:Q,screenY:tt}=e,[J,at]=u(this,Ha);[q,K]=this.screenToPageTranslation(Q-J,tt-at),u(this,Ha)[0]=Q,u(this,Ha)[1]=tt}if([q,K]=b(q/n,K/s),E){const Q=Math.hypot(c,d);H=X=Math.max(Math.min(Math.hypot(L[0]-k[0]-q,L[1]-k[1]-K)/Q,1/c,1/d),f/c,g/d)}else N?H=Math.max(f,Math.min(1,Math.abs(L[0]-k[0]-q)))/c:X=Math.max(g,Math.min(1,Math.abs(L[1]-k[1]-K)))/d;const lt=Wt._round(c*H),pt=Wt._round(d*X);R=y(...C(lt,pt));const ut=j-R[0],St=O-R[1];u(this,pi)||_(this,pi,[this.x,this.y,this.width,this.height]),this.width=lt,this.height=pt,this.x=ut,this.y=St,this.setDims(n*lt,s*pt),this.fixAndSetPosition(),this._onResizing()},FS=function(){var t;_(this,mr,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=u(this,be))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},OS=function(t,e,n){let o=.7*(n/e)+1-.7;if(o===1)return;const l=M(this,Dt,ig).call(this,this.rotation),c=(j,O)=>[l[0]*j+l[2]*O,l[1]*j+l[3]*O],[d,f]=this.parentDimensions,g=this.x,m=this.y,y=this.width,x=this.height,b=Wt.MIN_SIZE/d,A=Wt.MIN_SIZE/f;o=Math.max(Math.min(o,1/y,1/x),b/y,A/x);const C=Wt._round(y*o),E=Wt._round(x*o);if(C===y&&E===x)return;u(this,pi)||_(this,pi,[g,m,y,x]);const N=c(y/2,x/2),k=Wt._round(g+N[0]),L=Wt._round(m+N[1]),R=c(C/2,E/2);this.x=k-R[0],this.y=L-R[1],this.width=C,this.height=E,this.setDims(d*C,f*E),this.fixAndSetPosition(),this._onResizing()},jS=function(){var t;(t=u(this,be))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),M(this,Dt,sg).call(this)},Gy=function(t){const{isMac:e}=Wn.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},$S=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let n=!1;const s=new AbortController,o=this._uiManager.combinedSignal(s),l={capture:!0,passive:!1,signal:o},c=f=>{s.abort(),_(this,To,null),_(this,Ba,!1),this._uiManager.endDragSession()||M(this,Dt,Gy).call(this,f),n&&this._onStopDragging()};e&&(_(this,Fc,t.clientX),_(this,Oc,t.clientY),_(this,To,t.pointerId),_(this,wd,t.pointerType),window.addEventListener("pointermove",f=>{n||(n=!0,this._onStartDragging());const{clientX:g,clientY:m,pointerId:y}=f;if(y!==u(this,To)){ki(f);return}const[x,b]=this.screenToPageTranslation(g-u(this,Fc),m-u(this,Oc));_(this,Fc,g),_(this,Oc,m),this._uiManager.dragSelectedEditors(x,b)},l),window.addEventListener("touchmove",ki,l),window.addEventListener("pointerdown",f=>{f.pointerType===u(this,wd)&&(u(this,Va)||f.isPrimary)&&c(f),ki(f)},l));const d=f=>{if(!u(this,To)||u(this,To)===f.pointerId){c(f);return}ki(f)};window.addEventListener("pointerup",d,{signal:o}),window.addEventListener("blur",d,{signal:o})},Xy=function(){if(u(this,Po)||!this.div)return;_(this,Po,new AbortController);const t=this._uiManager.combinedSignal(u(this,Po));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},zS=function(t){Wt._resizerKeyboardManager.exec(this,t)},HS=function(t){var e;u(this,yr)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==u(this,pn)&&M(this,Dt,Th).call(this)},BS=function(t){_(this,bd,u(this,yr)?t:"")},qy=function(t){if(u(this,cs))for(const e of u(this,cs))e.tabIndex=t},Th=function(){_(this,yr,!1),M(this,Dt,qy).call(this,-1),M(this,Dt,sg).call(this)},P(Wt,_d),It(Wt,"_l10n",null),It(Wt,"_l10nResizer",null),It(Wt,"_borderLineWidth",-1),It(Wt,"_colorManager",new Iy),It(Wt,"_zIndex",1),It(Wt,"_telemetryTimeout",1e3);let Re=Wt;class xT extends Re{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const mb=3285377520,Oi=4294901760,Rs=65535;class US{constructor(t){this.h1=t?t&4294967295:mb,this.h2=t?t&4294967295:mb}update(t){let e,n;if(typeof t=="string"){e=new Uint8Array(t.length*2),n=0;for(let A=0,C=t.length;A<C;A++){const E=t.charCodeAt(A);E<=255?e[n++]=E:(e[n++]=E>>>8,e[n++]=E&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),n=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const s=n>>2,o=n-s*4,l=new Uint32Array(e.buffer,0,s);let c=0,d=0,f=this.h1,g=this.h2;const m=3432918353,y=461845907,x=m&Rs,b=y&Rs;for(let A=0;A<s;A++)A&1?(c=l[A],c=c*m&Oi|c*x&Rs,c=c<<15|c>>>17,c=c*y&Oi|c*b&Rs,f^=c,f=f<<13|f>>>19,f=f*5+3864292196):(d=l[A],d=d*m&Oi|d*x&Rs,d=d<<15|d>>>17,d=d*y&Oi|d*b&Rs,g^=d,g=g<<13|g>>>19,g=g*5+3864292196);switch(c=0,o){case 3:c^=e[s*4+2]<<16;case 2:c^=e[s*4+1]<<8;case 1:c^=e[s*4],c=c*m&Oi|c*x&Rs,c=c<<15|c>>>17,c=c*y&Oi|c*b&Rs,s&1?f^=c:g^=c}this.h1=f,this.h2=g}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Oi|t*36045&Rs,e=e*4283543511&Oi|((e<<16|t>>>16)*2950163797&Oi)>>>16,t^=e>>>1,t=t*444984403&Oi|t*60499&Rs,e=e*3301882366&Oi|((e<<16|t>>>16)*3120437893&Oi)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Yy=Object.freeze({map:null,hash:"",transfer:void 0});var Wa,Ga,an,Yg,VS;class nx{constructor(){P(this,Yg);P(this,Wa,!1);P(this,Ga,null);P(this,an,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const n=u(this,an).get(t);return n===void 0?e:Object.assign(e,n)}getRawValue(t){return u(this,an).get(t)}remove(t){if(u(this,an).delete(t),u(this,an).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of u(this,an).values())if(e instanceof Re)return;this.onAnnotationEditor(null)}}setValue(t,e){const n=u(this,an).get(t);let s=!1;if(n!==void 0)for(const[o,l]of Object.entries(e))n[o]!==l&&(s=!0,n[o]=l);else s=!0,u(this,an).set(t,e);s&&M(this,Yg,VS).call(this),e instanceof Re&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return u(this,an).has(t)}getAll(){return u(this,an).size>0?Kv(u(this,an)):null}setAll(t){for(const[e,n]of Object.entries(t))this.setValue(e,n)}get size(){return u(this,an).size}resetModified(){u(this,Wa)&&(_(this,Wa,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new WS(this)}get serializable(){if(u(this,an).size===0)return Yy;const t=new Map,e=new US,n=[],s=Object.create(null);let o=!1;for(const[l,c]of u(this,an)){const d=c instanceof Re?c.serialize(!1,s):c;d&&(t.set(l,d),e.update(`${l}:${JSON.stringify(d)}`),o||(o=!!d.bitmap))}if(o)for(const l of t.values())l.bitmap&&n.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:n}:Yy}get editorStats(){let t=null;const e=new Map;for(const n of u(this,an).values()){if(!(n instanceof Re))continue;const s=n.telemetryFinalData;if(!s)continue;const{type:o}=s;e.has(o)||e.set(o,Object.getPrototypeOf(n).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[c,d]of Object.entries(s)){if(c==="type")continue;let f=l.get(c);f||(f=new Map,l.set(c,f));const g=f.get(d)??0;f.set(d,g+1)}}for(const[n,s]of e)t[n]=s.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){_(this,Ga,null)}get modifiedIds(){if(u(this,Ga))return u(this,Ga);const t=[];for(const e of u(this,an).values())!(e instanceof Re)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return _(this,Ga,{ids:new Set(t),hash:t.join(",")})}}Wa=new WeakMap,Ga=new WeakMap,an=new WeakMap,Yg=new WeakSet,VS=function(){u(this,Wa)||(_(this,Wa,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Ed;class WS extends nx{constructor(e){super();P(this,Ed);const{map:n,hash:s,transfer:o}=e.serializable,l=structuredClone(n,o?{transfer:o}:null);_(this,Ed,{map:l,hash:s,transfer:o})}get print(){fe("Should not call PrintAnnotationStorage.print")}get serializable(){return u(this,Ed)}get modifiedIds(){return Kt(this,"modifiedIds",{ids:new Set,hash:""})}}Ed=new WeakMap;var jc;class wT{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){P(this,jc,new Set);this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),u(this,jc).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||u(this,jc).has(t.loadedName))){if(He(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:s,style:o}=t,l=new FontFace(n,s,o);this.addNativeFontFace(l);try{await l.load(),u(this,jc).add(n),e==null||e(t)}catch{Ut(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}fe("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 n=t.createNativeFontFace();if(n){this.addNativeFontFace(n);try{await n.loaded}catch(s){throw Ut(`Failed to load font '${n.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(n=>{const s=this._queueLoadingCallback(n);this._prepareFontLoadEvent(t,s)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return Kt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(In||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Kt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(He(!s.done,"completeRequest() cannot be called twice."),s.done=!0;n.length>0&&n[0].done;){const o=n.shift();setTimeout(o.callback,0)}}const{loadingRequests:n}=this,s={done:!1,complete:e,callback:t};return n.push(s),s}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Kt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function n(L,R){return L.charCodeAt(R)<<24|L.charCodeAt(R+1)<<16|L.charCodeAt(R+2)<<8|L.charCodeAt(R+3)&255}function s(L,R,j,O){const H=L.substring(0,R),X=L.substring(R+j);return H+O+X}let o,l;const c=this._document.createElement("canvas");c.width=1,c.height=1;const d=c.getContext("2d");let f=0;function g(L,R){if(++f>30){Ut("Load test font never loaded."),R();return}if(d.font="30px "+L,d.fillText(".",0,20),d.getImageData(0,0,1,1).data[3]>0){R();return}setTimeout(g.bind(null,L,R))}const m=`lt${Date.now()}${this.loadTestFontId++}`;let y=this._loadTestFont;y=s(y,976,m.length,m);const b=16,A=1482184792;let C=n(y,b);for(o=0,l=m.length-3;o<l;o+=4)C=C-A+n(m,o)|0;o<m.length&&(C=C-A+n(m+"XXX",o)|0),y=s(y,b,4,rT(C));const E=`url(data:font/opentype;base64,${btoa(y)});`,N=`@font-face {font-family:"${m}";src:${E}}`;this.insertRule(N);const k=this._document.createElement("div");k.style.visibility="hidden",k.style.width=k.style.height="10px",k.style.position="absolute",k.style.top=k.style.left="0px";for(const L of[t.loadedName,m]){const R=this._document.createElement("span");R.textContent="Hi",R.style.fontFamily=L,k.append(R)}this._document.body.append(k),g(m,()=>{k.remove(),e.complete()})}}jc=new WeakMap;class bT{constructor(t,{disableFontFace:e=!1,fontExtraProperties:n=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const o in t)this[o]=t[o];this.disableFontFace=e===!0,this.fontExtraProperties=n===!0,this._inspectFont=s}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const n={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(n.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,n)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var n;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${hT(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return(n=this._inspectFont)==null||n.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const n=this.loadedName+"_path_"+e;let s;try{s=t.get(n)}catch(l){Ut(`getPathGenerator - ignoring character: "${l}".`)}const o=new Path2D(s||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=o}}const Hp={DATA:1,ERROR:2},ze={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function yb(){}function ei(a){if(a instanceof Zo||a instanceof Ty||a instanceof Yh||a instanceof fb||a instanceof Pg||a instanceof uy)return a;switch(a instanceof Error||typeof a=="object"&&a!==null||fe('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),a.name){case"AbortException":return new Zo(a.message);case"InvalidPDFException":return new Ty(a.message);case"MissingPDFException":return new Yh(a.message);case"PasswordException":return new fb(a.message,a.code);case"UnexpectedResponseException":return new Pg(a.message,a.status);case"UnknownErrorException":return new uy(a.message,a.details)}return new uy(a.message,a.toString())}var $c,qi,GS,XS,qS,rg;class Ph{constructor(t,e,n){P(this,qi);P(this,$c,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener("message",M(this,qi,GS).bind(this),{signal:u(this,$c).signal})}on(t,e){const n=this.actionHandler;if(n[t])throw new Error(`There is already an actionName called "${t}"`);n[t]=e}send(t,e,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},n)}sendWithPromise(t,e,n){const s=this.callbackId++,o=Promise.withResolvers();this.callbackCapabilities[s]=o;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},n)}catch(l){o.reject(l)}return o.promise}sendWithStream(t,e,n,s){const o=this.streamId++,l=this.sourceName,c=this.targetName,d=this.comObj;return new ReadableStream({start:f=>{const g=Promise.withResolvers();return this.streamControllers[o]={controller:f,startCall:g,pullCall:null,cancelCall:null,isClosed:!1},d.postMessage({sourceName:l,targetName:c,action:t,streamId:o,data:e,desiredSize:f.desiredSize},s),g.promise},pull:f=>{const g=Promise.withResolvers();return this.streamControllers[o].pullCall=g,d.postMessage({sourceName:l,targetName:c,stream:ze.PULL,streamId:o,desiredSize:f.desiredSize}),g.promise},cancel:f=>{He(f instanceof Error,"cancel must have a valid reason");const g=Promise.withResolvers();return this.streamControllers[o].cancelCall=g,this.streamControllers[o].isClosed=!0,d.postMessage({sourceName:l,targetName:c,stream:ze.CANCEL,streamId:o,reason:ei(f)}),g.promise}},n)}destroy(){var t;(t=u(this,$c))==null||t.abort(),_(this,$c,null)}}$c=new WeakMap,qi=new WeakSet,GS=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){M(this,qi,qS).call(this,t);return}if(t.callback){const n=t.callbackId,s=this.callbackCapabilities[n];if(!s)throw new Error(`Cannot resolve callback ${n}`);if(delete this.callbackCapabilities[n],t.callback===Hp.DATA)s.resolve(t.data);else if(t.callback===Hp.ERROR)s.reject(ei(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const n=this.sourceName,s=t.sourceName,o=this.comObj;Promise.try(e,t.data).then(function(l){o.postMessage({sourceName:n,targetName:s,callback:Hp.DATA,callbackId:t.callbackId,data:l})},function(l){o.postMessage({sourceName:n,targetName:s,callback:Hp.ERROR,callbackId:t.callbackId,reason:ei(l)})});return}if(t.streamId){M(this,qi,XS).call(this,t);return}e(t.data)},XS=function(t){const e=t.streamId,n=this.sourceName,s=t.sourceName,o=this.comObj,l=this,c=this.actionHandler[t.action],d={enqueue(f,g=1,m){if(this.isCancelled)return;const y=this.desiredSize;this.desiredSize-=g,y>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),o.postMessage({sourceName:n,targetName:s,stream:ze.ENQUEUE,streamId:e,chunk:f},m)},close(){this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:n,targetName:s,stream:ze.CLOSE,streamId:e}),delete l.streamSinks[e])},error(f){He(f instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,o.postMessage({sourceName:n,targetName:s,stream:ze.ERROR,streamId:e,reason:ei(f)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};d.sinkCapability.resolve(),d.ready=d.sinkCapability.promise,this.streamSinks[e]=d,Promise.try(c,t.data,d).then(function(){o.postMessage({sourceName:n,targetName:s,stream:ze.START_COMPLETE,streamId:e,success:!0})},function(f){o.postMessage({sourceName:n,targetName:s,stream:ze.START_COMPLETE,streamId:e,reason:ei(f)})})},qS=function(t){const e=t.streamId,n=this.sourceName,s=t.sourceName,o=this.comObj,l=this.streamControllers[e],c=this.streamSinks[e];switch(t.stream){case ze.START_COMPLETE:t.success?l.startCall.resolve():l.startCall.reject(ei(t.reason));break;case ze.PULL_COMPLETE:t.success?l.pullCall.resolve():l.pullCall.reject(ei(t.reason));break;case ze.PULL:if(!c){o.postMessage({sourceName:n,targetName:s,stream:ze.PULL_COMPLETE,streamId:e,success:!0});break}c.desiredSize<=0&&t.desiredSize>0&&c.sinkCapability.resolve(),c.desiredSize=t.desiredSize,Promise.try(c.onPull||yb).then(function(){o.postMessage({sourceName:n,targetName:s,stream:ze.PULL_COMPLETE,streamId:e,success:!0})},function(f){o.postMessage({sourceName:n,targetName:s,stream:ze.PULL_COMPLETE,streamId:e,reason:ei(f)})});break;case ze.ENQUEUE:if(He(l,"enqueue should have stream controller"),l.isClosed)break;l.controller.enqueue(t.chunk);break;case ze.CLOSE:if(He(l,"close should have stream controller"),l.isClosed)break;l.isClosed=!0,l.controller.close(),M(this,qi,rg).call(this,l,e);break;case ze.ERROR:He(l,"error should have stream controller"),l.controller.error(ei(t.reason)),M(this,qi,rg).call(this,l,e);break;case ze.CANCEL_COMPLETE:t.success?l.cancelCall.resolve():l.cancelCall.reject(ei(t.reason)),M(this,qi,rg).call(this,l,e);break;case ze.CANCEL:if(!c)break;const d=ei(t.reason);Promise.try(c.onCancel||yb,d).then(function(){o.postMessage({sourceName:n,targetName:s,stream:ze.CANCEL_COMPLETE,streamId:e,success:!0})},function(f){o.postMessage({sourceName:n,targetName:s,stream:ze.CANCEL_COMPLETE,streamId:e,reason:ei(f)})}),c.sinkCapability.reject(d),c.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},rg=async function(t,e){var n,s,o;await Promise.allSettled([(n=t.startCall)==null?void 0:n.promise,(s=t.pullCall)==null?void 0:s.promise,(o=t.cancelCall)==null?void 0:o.promise]),delete this.streamControllers[e]};var kd;class YS{constructor({enableHWA:t=!1}){P(this,kd,!1);_(this,kd,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(t,e);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!u(this,kd)})}}reset(t,e,n){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||n<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=n}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){fe("Abstract method `_createCanvas` called.")}}kd=new WeakMap;class ST extends YS{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const n=this._document.createElement("canvas");return n.width=t,n.height=e,n}}class KS{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(n=>({cMapData:n,isCompressed:this.isCompressed})).catch(n=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){fe("Abstract method `_fetch` called.")}}class QS extends KS{async _fetch(t){const e=await pm(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):fm(e)}}class JS{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,n,s,o){return"none"}destroy(t=!1){}}var Xa,zc,vr,xr,Tn,qa,Ya,xt,En,Mh,uc,og,hc,ZS,Ky,dc,Rh,Nh,Qy,Lh;class AT extends JS{constructor({docId:e,ownerDocument:n=globalThis.document}){super();P(this,xt);P(this,Xa);P(this,zc);P(this,vr);P(this,xr);P(this,Tn);P(this,qa);P(this,Ya,0);_(this,xr,e),_(this,Tn,n)}addFilter(e){if(!e)return"none";let n=u(this,xt,En).get(e);if(n)return n;const[s,o,l]=M(this,xt,og).call(this,e),c=e.length===1?s:`${s}${o}${l}`;if(n=u(this,xt,En).get(c),n)return u(this,xt,En).set(e,n),n;const d=`g_${u(this,xr)}_transfer_map_${$n(this,Ya)._++}`,f=M(this,xt,hc).call(this,d);u(this,xt,En).set(e,f),u(this,xt,En).set(c,f);const g=M(this,xt,dc).call(this,d);return M(this,xt,Nh).call(this,s,o,l,g),f}addHCMFilter(e,n){var b;const s=`${e}-${n}`,o="base";let l=u(this,xt,Mh).get(o);if((l==null?void 0:l.key)===s||(l?((b=l.filter)==null||b.remove(),l.key=s,l.url="none",l.filter=null):(l={key:s,url:"none",filter:null},u(this,xt,Mh).set(o,l)),!e||!n))return l.url;const c=M(this,xt,Lh).call(this,e);e=Pt.makeHexColor(...c);const d=M(this,xt,Lh).call(this,n);if(n=Pt.makeHexColor(...d),u(this,xt,uc).style.color="",e==="#000000"&&n==="#ffffff"||e===n)return l.url;const f=new Array(256);for(let A=0;A<=255;A++){const C=A/255;f[A]=C<=.03928?C/12.92:((C+.055)/1.055)**2.4}const g=f.join(","),m=`g_${u(this,xr)}_hcm_filter`,y=l.filter=M(this,xt,dc).call(this,m);M(this,xt,Nh).call(this,g,g,g,y),M(this,xt,Ky).call(this,y);const x=(A,C)=>{const E=c[A]/255,N=d[A]/255,k=new Array(C+1);for(let L=0;L<=C;L++)k[L]=E+L/C*(N-E);return k.join(",")};return M(this,xt,Nh).call(this,x(0,5),x(1,5),x(2,5),y),l.url=M(this,xt,hc).call(this,m),l.url}addAlphaFilter(e){let n=u(this,xt,En).get(e);if(n)return n;const[s]=M(this,xt,og).call(this,[e]),o=`alpha_${s}`;if(n=u(this,xt,En).get(o),n)return u(this,xt,En).set(e,n),n;const l=`g_${u(this,xr)}_alpha_map_${$n(this,Ya)._++}`,c=M(this,xt,hc).call(this,l);u(this,xt,En).set(e,c),u(this,xt,En).set(o,c);const d=M(this,xt,dc).call(this,l);return M(this,xt,Qy).call(this,s,d),c}addLuminosityFilter(e){let n=u(this,xt,En).get(e||"luminosity");if(n)return n;let s,o;if(e?([s]=M(this,xt,og).call(this,[e]),o=`luminosity_${s}`):o="luminosity",n=u(this,xt,En).get(o),n)return u(this,xt,En).set(e,n),n;const l=`g_${u(this,xr)}_luminosity_map_${$n(this,Ya)._++}`,c=M(this,xt,hc).call(this,l);u(this,xt,En).set(e,c),u(this,xt,En).set(o,c);const d=M(this,xt,dc).call(this,l);return M(this,xt,ZS).call(this,d),e&&M(this,xt,Qy).call(this,s,d),c}addHighlightHCMFilter(e,n,s,o,l){var N;const c=`${n}-${s}-${o}-${l}`;let d=u(this,xt,Mh).get(e);if((d==null?void 0:d.key)===c||(d?((N=d.filter)==null||N.remove(),d.key=c,d.url="none",d.filter=null):(d={key:c,url:"none",filter:null},u(this,xt,Mh).set(e,d)),!n||!s))return d.url;const[f,g]=[n,s].map(M(this,xt,Lh).bind(this));let m=Math.round(.2126*f[0]+.7152*f[1]+.0722*f[2]),y=Math.round(.2126*g[0]+.7152*g[1]+.0722*g[2]),[x,b]=[o,l].map(M(this,xt,Lh).bind(this));y<m&&([m,y,x,b]=[y,m,b,x]),u(this,xt,uc).style.color="";const A=(k,L,R)=>{const j=new Array(256),O=(y-m)/R,H=k/255,X=(L-k)/(255*R);let q=0;for(let K=0;K<=R;K++){const lt=Math.round(m+K*O),pt=H+K*X;for(let ut=q;ut<=lt;ut++)j[ut]=pt;q=lt+1}for(let K=q;K<256;K++)j[K]=j[q-1];return j.join(",")},C=`g_${u(this,xr)}_hcm_${e}_filter`,E=d.filter=M(this,xt,dc).call(this,C);return M(this,xt,Ky).call(this,E),M(this,xt,Nh).call(this,A(x[0],b[0],5),A(x[1],b[1],5),A(x[2],b[2],5),E),d.url=M(this,xt,hc).call(this,C),d.url}destroy(e=!1){var n,s,o,l;e&&((n=u(this,qa))!=null&&n.size)||((s=u(this,vr))==null||s.parentNode.parentNode.remove(),_(this,vr,null),(o=u(this,zc))==null||o.clear(),_(this,zc,null),(l=u(this,qa))==null||l.clear(),_(this,qa,null),_(this,Ya,0))}}Xa=new WeakMap,zc=new WeakMap,vr=new WeakMap,xr=new WeakMap,Tn=new WeakMap,qa=new WeakMap,Ya=new WeakMap,xt=new WeakSet,En=function(){return u(this,zc)||_(this,zc,new Map)},Mh=function(){return u(this,qa)||_(this,qa,new Map)},uc=function(){if(!u(this,vr)){const e=u(this,Tn).createElement("div"),{style:n}=e;n.visibility="hidden",n.contain="strict",n.width=n.height=0,n.position="absolute",n.top=n.left=0,n.zIndex=-1;const s=u(this,Tn).createElementNS(or,"svg");s.setAttribute("width",0),s.setAttribute("height",0),_(this,vr,u(this,Tn).createElementNS(or,"defs")),e.append(s),s.append(u(this,vr)),u(this,Tn).body.append(e)}return u(this,vr)},og=function(e){if(e.length===1){const f=e[0],g=new Array(256);for(let y=0;y<256;y++)g[y]=f[y]/255;const m=g.join(",");return[m,m,m]}const[n,s,o]=e,l=new Array(256),c=new Array(256),d=new Array(256);for(let f=0;f<256;f++)l[f]=n[f]/255,c[f]=s[f]/255,d[f]=o[f]/255;return[l.join(","),c.join(","),d.join(",")]},hc=function(e){if(u(this,Xa)===void 0){_(this,Xa,"");const n=u(this,Tn).URL;n!==u(this,Tn).baseURI&&(gm(n)?Ut('#createUrl: ignore "data:"-URL for performance reasons.'):_(this,Xa,n.split("#",1)[0]))}return`url(${u(this,Xa)}#${e})`},ZS=function(e){const n=u(this,Tn).createElementNS(or,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(n)},Ky=function(e){const n=u(this,Tn).createElementNS(or,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(n)},dc=function(e){const n=u(this,Tn).createElementNS(or,"filter");return n.setAttribute("color-interpolation-filters","sRGB"),n.setAttribute("id",e),u(this,xt,uc).append(n),n},Rh=function(e,n,s){const o=u(this,Tn).createElementNS(or,n);o.setAttribute("type","discrete"),o.setAttribute("tableValues",s),e.append(o)},Nh=function(e,n,s,o){const l=u(this,Tn).createElementNS(or,"feComponentTransfer");o.append(l),M(this,xt,Rh).call(this,l,"feFuncR",e),M(this,xt,Rh).call(this,l,"feFuncG",n),M(this,xt,Rh).call(this,l,"feFuncB",s)},Qy=function(e,n){const s=u(this,Tn).createElementNS(or,"feComponentTransfer");n.append(s),M(this,xt,Rh).call(this,s,"feFuncA",e)},Lh=function(e){return u(this,xt,uc).style.color=e,ex(getComputedStyle(u(this,xt,uc)).getPropertyValue("color"))};class tA{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(n=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){fe("Abstract method `_fetch` called.")}}class eA extends tA{async _fetch(t){const e=await pm(t,"arraybuffer");return new Uint8Array(e)}}In&&Ut("Please use the `legacy` build in Node.js environments.");async function nA(a){const e=await process.getBuiltinModule("fs").promises.readFile(a);return new Uint8Array(e)}class _T extends JS{}class ET extends YS{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class kT extends KS{async _fetch(t){return nA(t)}}class CT extends tA{async _fetch(t){return nA(t)}}const Nn={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Jy(a,t){if(!t)return;const e=t[2]-t[0],n=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],e,n),a.clip(s)}class ix{getPattern(){fe("Abstract method `getPattern` called.")}}class TT extends ix{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const n of this._colorStops)e.addColorStop(n[0],n[1]);return e}getPattern(t,e,n,s){let o;if(s===Nn.STROKE||s===Nn.FILL){const l=e.current.getClippedPathBoundingBox(s,_e(t))||[0,0,0,0],c=Math.ceil(l[2]-l[0])||1,d=Math.ceil(l[3]-l[1])||1,f=e.cachedCanvases.getCanvas("pattern",c,d),g=f.context;g.clearRect(0,0,g.canvas.width,g.canvas.height),g.beginPath(),g.rect(0,0,g.canvas.width,g.canvas.height),g.translate(-l[0],-l[1]),n=Pt.transform(n,[1,0,0,1,l[0],l[1]]),g.transform(...e.baseTransform),this.matrix&&g.transform(...this.matrix),Jy(g,this._bbox),g.fillStyle=this._createGradient(g),g.fill(),o=t.createPattern(f.canvas,"no-repeat");const m=new DOMMatrix(n);o.setTransform(m)}else Jy(t,this._bbox),o=this._createGradient(t);return o}}function fy(a,t,e,n,s,o,l,c){const d=t.coords,f=t.colors,g=a.data,m=a.width*4;let y;d[e+1]>d[n+1]&&(y=e,e=n,n=y,y=o,o=l,l=y),d[n+1]>d[s+1]&&(y=n,n=s,s=y,y=l,l=c,c=y),d[e+1]>d[n+1]&&(y=e,e=n,n=y,y=o,o=l,l=y);const x=(d[e]+t.offsetX)*t.scaleX,b=(d[e+1]+t.offsetY)*t.scaleY,A=(d[n]+t.offsetX)*t.scaleX,C=(d[n+1]+t.offsetY)*t.scaleY,E=(d[s]+t.offsetX)*t.scaleX,N=(d[s+1]+t.offsetY)*t.scaleY;if(b>=N)return;const k=f[o],L=f[o+1],R=f[o+2],j=f[l],O=f[l+1],H=f[l+2],X=f[c],q=f[c+1],K=f[c+2],lt=Math.round(b),pt=Math.round(N);let ut,St,Q,tt,J,at,st,I;for(let V=lt;V<=pt;V++){if(V<C){const mt=V<b?0:(b-V)/(b-C);ut=x-(x-A)*mt,St=k-(k-j)*mt,Q=L-(L-O)*mt,tt=R-(R-H)*mt}else{let mt;V>N?mt=1:C===N?mt=0:mt=(C-V)/(C-N),ut=A-(A-E)*mt,St=j-(j-X)*mt,Q=O-(O-q)*mt,tt=H-(H-K)*mt}let W;V<b?W=0:V>N?W=1:W=(b-V)/(b-N),J=x-(x-E)*W,at=k-(k-X)*W,st=L-(L-q)*W,I=R-(R-K)*W;const nt=Math.round(Math.min(ut,J)),rt=Math.round(Math.max(ut,J));let dt=m*V+nt*4;for(let mt=nt;mt<=rt;mt++)W=(ut-mt)/(ut-J),W<0?W=0:W>1&&(W=1),g[dt++]=St-(St-at)*W|0,g[dt++]=Q-(Q-st)*W|0,g[dt++]=tt-(tt-I)*W|0,g[dt++]=255}}function PT(a,t,e){const n=t.coords,s=t.colors;let o,l;switch(t.type){case"lattice":const c=t.verticesPerRow,d=Math.floor(n.length/c)-1,f=c-1;for(o=0;o<d;o++){let g=o*c;for(let m=0;m<f;m++,g++)fy(a,e,n[g],n[g+1],n[g+c],s[g],s[g+1],s[g+c]),fy(a,e,n[g+c+1],n[g+1],n[g+c],s[g+c+1],s[g+1],s[g+c])}break;case"triangles":for(o=0,l=n.length;o<l;o+=3)fy(a,e,n[o],n[o+1],n[o+2],s[o],s[o+1],s[o+2]);break;default:throw new Error("illegal figure")}}class MT extends ix{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,n){const c=Math.floor(this._bounds[0]),d=Math.floor(this._bounds[1]),f=Math.ceil(this._bounds[2])-c,g=Math.ceil(this._bounds[3])-d,m=Math.min(Math.ceil(Math.abs(f*t[0]*1.1)),3e3),y=Math.min(Math.ceil(Math.abs(g*t[1]*1.1)),3e3),x=f/m,b=g/y,A={coords:this._coords,colors:this._colors,offsetX:-c,offsetY:-d,scaleX:1/x,scaleY:1/b},C=m+4,E=y+4,N=n.getCanvas("mesh",C,E),k=N.context,L=k.createImageData(m,y);if(e){const j=L.data;for(let O=0,H=j.length;O<H;O+=4)j[O]=e[0],j[O+1]=e[1],j[O+2]=e[2],j[O+3]=255}for(const j of this._figures)PT(L,j,A);return k.putImageData(L,2,2),{canvas:N.canvas,offsetX:c-2*x,offsetY:d-2*b,scaleX:x,scaleY:b}}getPattern(t,e,n,s){Jy(t,this._bbox);let o;if(s===Nn.SHADING)o=Pt.singularValueDecompose2dScale(_e(t));else if(o=Pt.singularValueDecompose2dScale(e.baseTransform),this.matrix){const c=Pt.singularValueDecompose2dScale(this.matrix);o=[o[0]*c[0],o[1]*c[1]]}const l=this._createMeshCanvas(o,s===Nn.SHADING?null:this._background,e.cachedCanvases);return s!==Nn.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(l.offsetX,l.offsetY),t.scale(l.scaleX,l.scaleY),t.createPattern(l.canvas,"no-repeat")}}class RT extends ix{getPattern(){return"hotpink"}}function NT(a){switch(a[0]){case"RadialAxial":return new TT(a);case"Mesh":return new MT(a);case"Dummy":return new RT}throw new Error(`Unknown IR type: ${a[0]}`)}const vb={COLORED:1,UNCOLORED:2},Kg=class Kg{constructor(t,e,n,s,o){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=n,this.canvasGraphicsFactory=s,this.baseTransform=o}createPatternCanvas(t){const{bbox:e,operatorList:n,paintType:s,tilingType:o,color:l,canvasGraphicsFactory:c}=this;let{xstep:d,ystep:f}=this;d=Math.abs(d),f=Math.abs(f),dm("TilingType: "+o);const g=e[0],m=e[1],y=e[2],x=e[3],b=y-g,A=x-m,C=Pt.singularValueDecompose2dScale(this.matrix),E=Pt.singularValueDecompose2dScale(this.baseTransform),N=C[0]*E[0],k=C[1]*E[1];let L=b,R=A,j=!1,O=!1;const H=Math.ceil(d*N),X=Math.ceil(f*k),q=Math.ceil(b*N),K=Math.ceil(A*k);H>=q?L=d:j=!0,X>=K?R=f:O=!0;const lt=this.getSizeAndScale(L,this.ctx.canvas.width,N),pt=this.getSizeAndScale(R,this.ctx.canvas.height,k),ut=t.cachedCanvases.getCanvas("pattern",lt.size,pt.size),St=ut.context,Q=c.createCanvasGraphics(St);if(Q.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(Q,s,l),St.translate(-lt.scale*g,-pt.scale*m),Q.transform(lt.scale,0,0,pt.scale,0,0),St.save(),this.clipBbox(Q,g,m,y,x),Q.baseTransform=_e(Q.ctx),Q.executeOperatorList(n),Q.endDrawing(),St.restore(),j||O){const tt=ut.canvas;j&&(L=d),O&&(R=f);const J=this.getSizeAndScale(L,this.ctx.canvas.width,N),at=this.getSizeAndScale(R,this.ctx.canvas.height,k),st=J.size,I=at.size,V=t.cachedCanvases.getCanvas("pattern-workaround",st,I),W=V.context,nt=j?Math.floor(b/d):0,rt=O?Math.floor(A/f):0;for(let dt=0;dt<=nt;dt++)for(let mt=0;mt<=rt;mt++)W.drawImage(tt,st*dt,I*mt,st,I,0,0,st,I);return{canvas:V.canvas,scaleX:J.scale,scaleY:at.scale,offsetX:g,offsetY:m}}return{canvas:ut.canvas,scaleX:lt.scale,scaleY:pt.scale,offsetX:g,offsetY:m}}getSizeAndScale(t,e,n){const s=Math.max(Kg.MAX_PATTERN_SIZE,e);let o=Math.ceil(t*n);return o>=s?o=s:n=o/t,{scale:n,size:o}}clipBbox(t,e,n,s,o){const l=s-e,c=o-n;t.ctx.rect(e,n,l,c),t.current.updateRectMinMax(_e(t.ctx),[e,n,s,o]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,n){const s=t.ctx,o=t.current;switch(e){case vb.COLORED:const l=this.ctx;s.fillStyle=l.fillStyle,s.strokeStyle=l.strokeStyle,o.fillColor=l.fillStyle,o.strokeColor=l.strokeStyle;break;case vb.UNCOLORED:const c=Pt.makeHexColor(n[0],n[1],n[2]);s.fillStyle=c,s.strokeStyle=c,o.fillColor=c,o.strokeColor=c;break;default:throw new sT(`Unsupported paint type: ${e}`)}}getPattern(t,e,n,s){let o=n;s!==Nn.SHADING&&(o=Pt.transform(o,e.baseTransform),this.matrix&&(o=Pt.transform(o,this.matrix)));const l=this.createPatternCanvas(e);let c=new DOMMatrix(o);c=c.translate(l.offsetX,l.offsetY),c=c.scale(1/l.scaleX,1/l.scaleY);const d=t.createPattern(l.canvas,"repeat");return d.setTransform(c),d}};It(Kg,"MAX_PATTERN_SIZE",3e3);let Zy=Kg;function LT({src:a,srcPos:t=0,dest:e,width:n,height:s,nonBlackColor:o=4294967295,inverseDecode:l=!1}){const c=Wn.isLittleEndian?4278190080:255,[d,f]=l?[o,c]:[c,o],g=n>>3,m=n&7,y=a.length;e=new Uint32Array(e.buffer);let x=0;for(let b=0;b<s;b++){for(const C=t+g;t<C;t++){const E=t<y?a[t]:255;e[x++]=E&128?f:d,e[x++]=E&64?f:d,e[x++]=E&32?f:d,e[x++]=E&16?f:d,e[x++]=E&8?f:d,e[x++]=E&4?f:d,e[x++]=E&2?f:d,e[x++]=E&1?f:d}if(m===0)continue;const A=t<y?a[t++]:255;for(let C=0;C<m;C++)e[x++]=A&1<<7-C?f:d}return{srcPos:t,destPos:x}}const xb=16,wb=100,IT=15,bb=10,Sb=1e3,oi=16;function DT(a,t){if(a._removeMirroring)throw new Error("Context is already forwarding operations.");a.__originalSave=a.save,a.__originalRestore=a.restore,a.__originalRotate=a.rotate,a.__originalScale=a.scale,a.__originalTranslate=a.translate,a.__originalTransform=a.transform,a.__originalSetTransform=a.setTransform,a.__originalResetTransform=a.resetTransform,a.__originalClip=a.clip,a.__originalMoveTo=a.moveTo,a.__originalLineTo=a.lineTo,a.__originalBezierCurveTo=a.bezierCurveTo,a.__originalRect=a.rect,a.__originalClosePath=a.closePath,a.__originalBeginPath=a.beginPath,a._removeMirroring=()=>{a.save=a.__originalSave,a.restore=a.__originalRestore,a.rotate=a.__originalRotate,a.scale=a.__originalScale,a.translate=a.__originalTranslate,a.transform=a.__originalTransform,a.setTransform=a.__originalSetTransform,a.resetTransform=a.__originalResetTransform,a.clip=a.__originalClip,a.moveTo=a.__originalMoveTo,a.lineTo=a.__originalLineTo,a.bezierCurveTo=a.__originalBezierCurveTo,a.rect=a.__originalRect,a.closePath=a.__originalClosePath,a.beginPath=a.__originalBeginPath,delete a._removeMirroring},a.save=function(){t.save(),this.__originalSave()},a.restore=function(){t.restore(),this.__originalRestore()},a.translate=function(n,s){t.translate(n,s),this.__originalTranslate(n,s)},a.scale=function(n,s){t.scale(n,s),this.__originalScale(n,s)},a.transform=function(n,s,o,l,c,d){t.transform(n,s,o,l,c,d),this.__originalTransform(n,s,o,l,c,d)},a.setTransform=function(n,s,o,l,c,d){t.setTransform(n,s,o,l,c,d),this.__originalSetTransform(n,s,o,l,c,d)},a.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},a.rotate=function(n){t.rotate(n),this.__originalRotate(n)},a.clip=function(n){t.clip(n),this.__originalClip(n)},a.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},a.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},a.bezierCurveTo=function(e,n,s,o,l,c){t.bezierCurveTo(e,n,s,o,l,c),this.__originalBezierCurveTo(e,n,s,o,l,c)},a.rect=function(e,n,s,o){t.rect(e,n,s,o),this.__originalRect(e,n,s,o)},a.closePath=function(){t.closePath(),this.__originalClosePath()},a.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class FT{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,n){let s;return this.cache[t]!==void 0?(s=this.cache[t],this.canvasFactory.reset(s,e,n)):(s=this.canvasFactory.create(e,n),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Bp(a,t,e,n,s,o,l,c,d,f){const[g,m,y,x,b,A]=_e(a);if(m===0&&y===0){const N=l*g+b,k=Math.round(N),L=c*x+A,R=Math.round(L),j=(l+d)*g+b,O=Math.abs(Math.round(j)-k)||1,H=(c+f)*x+A,X=Math.abs(Math.round(H)-R)||1;return a.setTransform(Math.sign(g),0,0,Math.sign(x),k,R),a.drawImage(t,e,n,s,o,0,0,O,X),a.setTransform(g,m,y,x,b,A),[O,X]}if(g===0&&x===0){const N=c*y+b,k=Math.round(N),L=l*m+A,R=Math.round(L),j=(c+f)*y+b,O=Math.abs(Math.round(j)-k)||1,H=(l+d)*m+A,X=Math.abs(Math.round(H)-R)||1;return a.setTransform(0,Math.sign(m),Math.sign(y),0,k,R),a.drawImage(t,e,n,s,o,0,0,X,O),a.setTransform(g,m,y,x,b,A),[X,O]}a.drawImage(t,e,n,s,o,l,c,d,f);const C=Math.hypot(g,m),E=Math.hypot(y,x);return[C*d,E*f]}function OT(a){const{width:t,height:e}=a;if(t>Sb||e>Sb)return null;const n=1e3,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=t+1;let l=new Uint8Array(o*(e+1)),c,d,f;const g=t+7&-8;let m=new Uint8Array(g*e),y=0;for(const E of a.data){let N=128;for(;N>0;)m[y++]=E&N?0:255,N>>=1}let x=0;for(y=0,m[y]!==0&&(l[0]=1,++x),d=1;d<t;d++)m[y]!==m[y+1]&&(l[d]=m[y]?2:1,++x),y++;for(m[y]!==0&&(l[d]=2,++x),c=1;c<e;c++){y=c*g,f=c*o,m[y-g]!==m[y]&&(l[f]=m[y]?1:8,++x);let E=(m[y]?4:0)+(m[y-g]?8:0);for(d=1;d<t;d++)E=(E>>2)+(m[y+1]?4:0)+(m[y-g+1]?8:0),s[E]&&(l[f+d]=s[E],++x),y++;if(m[y-g]!==m[y]&&(l[f+d]=m[y]?2:4,++x),x>n)return null}for(y=g*(e-1),f=c*o,m[y]!==0&&(l[f]=8,++x),d=1;d<t;d++)m[y]!==m[y+1]&&(l[f+d]=m[y]?4:8,++x),y++;if(m[y]!==0&&(l[f+d]=4,++x),x>n)return null;const b=new Int32Array([0,o,-1,0,-o,0,0,0,1]),A=new Path2D;for(c=0;x&&c<=e;c++){let E=c*o;const N=E+t;for(;E<N&&!l[E];)E++;if(E===N)continue;A.moveTo(E%o,c);const k=E;let L=l[E];do{const R=b[L];do E+=R;while(!l[E]);const j=l[E];j!==5&&j!==10?(L=j,l[E]=0):(L=j&51*L>>4,l[E]&=L>>2|L<<2),A.lineTo(E%o,E/o|0),l[E]||--x}while(k!==E);--c}return m=null,l=null,function(E){E.save(),E.scale(1/t,-1/e),E.translate(0,-e),E.fill(A),E.beginPath(),E.restore()}}class Ab{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=dS,this.textMatrixScale=1,this.fontMatrix=Cy,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=_n.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,n){[e,n]=Pt.applyTransform([e,n],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(t,e){const n=Pt.applyTransform(e,t),s=Pt.applyTransform(e.slice(2),t),o=Pt.applyTransform([e[0],e[3]],t),l=Pt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,n[0],s[0],o[0],l[0]),this.minY=Math.min(this.minY,n[1],s[1],o[1],l[1]),this.maxX=Math.max(this.maxX,n[0],s[0],o[0],l[0]),this.maxY=Math.max(this.maxY,n[1],s[1],o[1],l[1])}updateScalingPathMinMax(t,e){Pt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,n,s,o,l,c,d,f,g){const m=Pt.bezierBoundingBox(e,n,s,o,l,c,d,f,g);g||this.updateRectMinMax(t,m)}getPathBoundingBox(t=Nn.FILL,e=null){const n=[this.minX,this.minY,this.maxX,this.maxY];if(t===Nn.STROKE){e||fe("Stroke bounding box must include transform.");const s=Pt.singularValueDecompose2dScale(e),o=s[0]*this.lineWidth/2,l=s[1]*this.lineWidth/2;n[0]-=o,n[1]-=l,n[2]+=o,n[3]+=l}return n}updateClipFromPath(){const t=Pt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Nn.FILL,e=null){return Pt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function _b(a,t){if(t instanceof ImageData){a.putImageData(t,0,0);return}const e=t.height,n=t.width,s=e%oi,o=(e-s)/oi,l=s===0?o:o+1,c=a.createImageData(n,oi);let d=0,f;const g=t.data,m=c.data;let y,x,b,A;if(t.kind===Kp.GRAYSCALE_1BPP){const C=g.byteLength,E=new Uint32Array(m.buffer,0,m.byteLength>>2),N=E.length,k=n+7>>3,L=4294967295,R=Wn.isLittleEndian?4278190080:255;for(y=0;y<l;y++){for(b=y<o?oi:s,f=0,x=0;x<b;x++){const j=C-d;let O=0;const H=j>k?n:j*8-7,X=H&-8;let q=0,K=0;for(;O<X;O+=8)K=g[d++],E[f++]=K&128?L:R,E[f++]=K&64?L:R,E[f++]=K&32?L:R,E[f++]=K&16?L:R,E[f++]=K&8?L:R,E[f++]=K&4?L:R,E[f++]=K&2?L:R,E[f++]=K&1?L:R;for(;O<H;O++)q===0&&(K=g[d++],q=128),E[f++]=K&q?L:R,q>>=1}for(;f<N;)E[f++]=0;a.putImageData(c,0,y*oi)}}else if(t.kind===Kp.RGBA_32BPP){for(x=0,A=n*oi*4,y=0;y<o;y++)m.set(g.subarray(d,d+A)),d+=A,a.putImageData(c,0,x),x+=oi;y<l&&(A=n*s*4,m.set(g.subarray(d,d+A)),a.putImageData(c,0,x))}else if(t.kind===Kp.RGB_24BPP)for(b=oi,A=n*b,y=0;y<l;y++){for(y>=o&&(b=s,A=n*b),f=0,x=A;x--;)m[f++]=g[d++],m[f++]=g[d++],m[f++]=g[d++],m[f++]=255;a.putImageData(c,0,y*oi)}else throw new Error(`bad image kind: ${t.kind}`)}function Eb(a,t){if(t.bitmap){a.drawImage(t.bitmap,0,0);return}const e=t.height,n=t.width,s=e%oi,o=(e-s)/oi,l=s===0?o:o+1,c=a.createImageData(n,oi);let d=0;const f=t.data,g=c.data;for(let m=0;m<l;m++){const y=m<o?oi:s;({srcPos:d}=LT({src:f,srcPos:d,dest:g,width:n,height:y,nonBlackColor:0})),a.putImageData(c,0,m*oi)}}function wh(a,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of e)a[n]!==void 0&&(t[n]=a[n]);a.setLineDash!==void 0&&(t.setLineDash(a.getLineDash()),t.lineDashOffset=a.lineDashOffset)}function Up(a){if(a.strokeStyle=a.fillStyle="#000000",a.fillRule="nonzero",a.globalAlpha=1,a.lineWidth=1,a.lineCap="butt",a.lineJoin="miter",a.miterLimit=10,a.globalCompositeOperation="source-over",a.font="10px sans-serif",a.setLineDash!==void 0&&(a.setLineDash([]),a.lineDashOffset=0),!In){const{filter:t}=a;t!=="none"&&t!==""&&(a.filter="none")}}function kb(a,t){if(t)return!0;const e=Pt.singularValueDecompose2dScale(a);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const n=Math.fround((globalThis.devicePixelRatio||1)*ta.PDF_TO_CSS_UNITS);return e[0]<=n&&e[1]<=n}const jT=["butt","round","square"],$T=["miter","round","bevel"],zT={},Cb={};var Ss,tv,ev,nv;const fx=class fx{constructor(t,e,n,s,o,{optionalContentConfig:l,markedContentStack:c=null},d,f){P(this,Ss);this.ctx=t,this.current=new Ab(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=n,this.canvasFactory=s,this.filterFactory=o,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=c||[],this.optionalContentConfig=l,this.cachedCanvases=new FT(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=d,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=f,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:n=!1,background:s=null}){const o=this.ctx.canvas.width,l=this.ctx.canvas.height,c=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,o,l),this.ctx.fillStyle=c,n){const d=this.cachedCanvases.getCanvas("transparent",o,l);this.compositeCtx=this.ctx,this.transparentCanvas=d.canvas,this.ctx=d.context,this.ctx.save(),this.ctx.transform(..._e(this.compositeCtx))}this.ctx.save(),Up(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=_e(this.ctx)}executeOperatorList(t,e,n,s){const o=t.argsArray,l=t.fnArray;let c=e||0;const d=o.length;if(d===c)return c;const f=d-c>bb&&typeof n=="function",g=f?Date.now()+IT:0;let m=0;const y=this.commonObjs,x=this.objs;let b;for(;;){if(s!==void 0&&c===s.nextBreakPoint)return s.breakIt(c,n),c;if(b=l[c],b!==rs.dependency)this[b].apply(this,o[c]);else for(const A of o[c]){const C=A.startsWith("g_")?y:x;if(!C.has(A))return C.get(A,n),c}if(c++,c===d)return c;if(f&&++m>bb){if(Date.now()>g)return n(),c;m=0}}}endDrawing(){M(this,Ss,tv).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),M(this,Ss,ev).call(this)}_scaleImage(t,e){const n=t.width??t.displayWidth,s=t.height??t.displayHeight;let o=Math.max(Math.hypot(e[0],e[1]),1),l=Math.max(Math.hypot(e[2],e[3]),1),c=n,d=s,f="prescale1",g,m;for(;o>2&&c>1||l>2&&d>1;){let y=c,x=d;o>2&&c>1&&(y=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c/2),o/=c/y),l>2&&d>1&&(x=d>=16384?Math.floor(d/2)-1||1:Math.ceil(d)/2,l/=d/x),g=this.cachedCanvases.getCanvas(f,y,x),m=g.context,m.clearRect(0,0,y,x),m.drawImage(t,0,0,c,d,0,0,y,x),t=g.canvas,c=y,d=x,f=f==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:c,paintHeight:d}}_createMaskCanvas(t){const e=this.ctx,{width:n,height:s}=t,o=this.current.fillColor,l=this.current.patternFill,c=_e(e);let d,f,g,m;if((t.bitmap||t.data)&&t.count>1){const H=t.bitmap||t.data.buffer;f=JSON.stringify(l?c:[c.slice(0,4),o]),d=this._cachedBitmapsMap.get(H),d||(d=new Map,this._cachedBitmapsMap.set(H,d));const X=d.get(f);if(X&&!l){const q=Math.round(Math.min(c[0],c[2])+c[4]),K=Math.round(Math.min(c[1],c[3])+c[5]);return{canvas:X,offsetX:q,offsetY:K}}g=X}g||(m=this.cachedCanvases.getCanvas("maskCanvas",n,s),Eb(m.context,t));let y=Pt.transform(c,[1/n,0,0,-1/s,0,0]);y=Pt.transform(y,[1,0,0,1,0,-s]);const[x,b,A,C]=Pt.getAxialAlignedBoundingBox([0,0,n,s],y),E=Math.round(A-x)||1,N=Math.round(C-b)||1,k=this.cachedCanvases.getCanvas("fillCanvas",E,N),L=k.context,R=x,j=b;L.translate(-R,-j),L.transform(...y),g||(g=this._scaleImage(m.canvas,Ms(L)),g=g.img,d&&l&&d.set(f,g)),L.imageSmoothingEnabled=kb(_e(L),t.interpolate),Bp(L,g,0,0,g.width,g.height,0,0,n,s),L.globalCompositeOperation="source-in";const O=Pt.transform(Ms(L),[1,0,0,1,-R,-j]);return L.fillStyle=l?o.getPattern(e,this,O,Nn.FILL):o,L.fillRect(0,0,n,s),d&&!l&&(this.cachedCanvases.delete("fillCanvas"),d.set(f,k.canvas)),{canvas:k.canvas,offsetX:Math.round(R),offsetY:Math.round(j)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=jT[t]}setLineJoin(t){this.ctx.lineJoin=$T[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(t),n.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,n]of t)switch(e){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(n,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const o=this.ctx;o.setTransform(..._e(this.suspendedCtx)),wh(this.suspendedCtx,o),DT(o,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),wh(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,n,s){const o=s[0],l=s[1],c=s[2]-o,d=s[3]-l;c===0||d===0||(this.genericComposeSMask(e.context,n,c,d,e.subtype,e.backdrop,e.transferMap,o,l,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(n.canvas,0,0),t.restore())}genericComposeSMask(t,e,n,s,o,l,c,d,f,g,m){let y=t.canvas,x=d-g,b=f-m;if(l){const C=Pt.makeHexColor(...l);if(x<0||b<0||x+n>y.width||b+s>y.height){const E=this.cachedCanvases.getCanvas("maskExtension",n,s),N=E.context;N.drawImage(y,-x,-b),N.globalCompositeOperation="destination-atop",N.fillStyle=C,N.fillRect(0,0,n,s),N.globalCompositeOperation="source-over",y=E.canvas,x=b=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const E=new Path2D;E.rect(x,b,n,s),t.clip(E),t.globalCompositeOperation="destination-atop",t.fillStyle=C,t.fillRect(x,b,n,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),o==="Alpha"&&c?e.filter=this.filterFactory.addAlphaFilter(c):o==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(c));const A=new Path2D;A.rect(d,f,n,s),e.clip(A),e.globalCompositeOperation="destination-in",e.drawImage(y,x,b,n,s,d,f,n,s),e.restore()}save(){this.inSMaskMode?(wh(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),wh(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,n,s,o,l){this.ctx.transform(t,e,n,s,o,l),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,n){const s=this.ctx,o=this.current;let l=o.x,c=o.y,d,f;const g=_e(s),m=g[0]===0&&g[3]===0||g[1]===0&&g[2]===0,y=m?n.slice(0):null;for(let x=0,b=0,A=t.length;x<A;x++)switch(t[x]|0){case rs.rectangle:l=e[b++],c=e[b++];const C=e[b++],E=e[b++],N=l+C,k=c+E;s.moveTo(l,c),C===0||E===0?s.lineTo(N,k):(s.lineTo(N,c),s.lineTo(N,k),s.lineTo(l,k)),m||o.updateRectMinMax(g,[l,c,N,k]),s.closePath();break;case rs.moveTo:l=e[b++],c=e[b++],s.moveTo(l,c),m||o.updatePathMinMax(g,l,c);break;case rs.lineTo:l=e[b++],c=e[b++],s.lineTo(l,c),m||o.updatePathMinMax(g,l,c);break;case rs.curveTo:d=l,f=c,l=e[b+4],c=e[b+5],s.bezierCurveTo(e[b],e[b+1],e[b+2],e[b+3],l,c),o.updateCurvePathMinMax(g,d,f,e[b],e[b+1],e[b+2],e[b+3],l,c,y),b+=6;break;case rs.curveTo2:d=l,f=c,s.bezierCurveTo(l,c,e[b],e[b+1],e[b+2],e[b+3]),o.updateCurvePathMinMax(g,d,f,l,c,e[b],e[b+1],e[b+2],e[b+3],y),l=e[b+2],c=e[b+3],b+=4;break;case rs.curveTo3:d=l,f=c,l=e[b+2],c=e[b+3],s.bezierCurveTo(e[b],e[b+1],l,c,l,c),o.updateCurvePathMinMax(g,d,f,e[b],e[b+1],l,c,l,c,y),b+=4;break;case rs.closePath:s.closePath();break}m&&o.updateScalingPathMinMax(g,y),o.setCurrentPoint(l,c)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,n=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n=="object"&&(n!=null&&n.getPattern)?(e.save(),e.strokeStyle=n.getPattern(e,this,Ms(e),Nn.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,n=this.current.fillColor,s=this.current.patternFill;let o=!1;s&&(e.save(),e.fillStyle=n.getPattern(e,this,Ms(e),Nn.FILL),o=!0);const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),o&&e.restore(),t&&this.consumePath(l)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=zT}eoClip(){this.pendingClip=Cb}beginText(){this.current.textMatrix=dS,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}const n=new Path2D,s=e.getTransform().invertSelf();for(const{transform:o,x:l,y:c,fontSize:d,path:f}of t)n.addPath(f,new DOMMatrix(o).preMultiplySelf(s).translate(l,c).scale(d,-d));e.clip(n),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var g;const n=this.commonObjs.get(t),s=this.current;if(!n)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=n.fontMatrix||Cy,(s.fontMatrix[0]===0||s.fontMatrix[3]===0)&&Ut("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=n,this.current.fontSize=e,n.isType3Font)return;const o=n.loadedName||"sans-serif",l=((g=n.systemFontInfo)==null?void 0:g.css)||`"${o}", ${n.fallbackName}`;let c="normal";n.black?c="900":n.bold&&(c="bold");const d=n.italic?"italic":"normal";let f=e;e<xb?f=xb:e>wb&&(f=wb),this.current.fontSizeScale=e/f,this.ctx.font=`${d} ${c} ${f}px ${l}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,n,s,o,l){this.current.textMatrix=[t,e,n,s,o,l],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,n,s,o){const l=this.ctx,c=this.current,d=c.font,f=c.textRenderingMode,g=c.fontSize/c.fontSizeScale,m=f&_n.FILL_STROKE_MASK,y=!!(f&_n.ADD_TO_PATH_FLAG),x=c.patternFill&&!d.missingFile,b=c.patternStroke&&!d.missingFile;let A;if((d.disableFontFace||y||x||b)&&(A=d.getPathGenerator(this.commonObjs,t)),d.disableFontFace||x||b){if(l.save(),l.translate(e,n),l.scale(g,-g),m===_n.FILL||m===_n.FILL_STROKE)if(s){const C=l.getTransform();l.setTransform(...s),l.fill(M(this,Ss,nv).call(this,A,C,s))}else l.fill(A);if(m===_n.STROKE||m===_n.FILL_STROKE)if(o){const C=l.getTransform();l.setTransform(...o),l.stroke(M(this,Ss,nv).call(this,A,C,o))}else l.lineWidth/=g,l.stroke(A);l.restore()}else(m===_n.FILL||m===_n.FILL_STROKE)&&l.fillText(t,e,n),(m===_n.STROKE||m===_n.FILL_STROKE)&&l.strokeText(t,e,n);y&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:_e(l),x:e,y:n,fontSize:g,path:A})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let n=!1;for(let s=3;s<e.length;s+=4)if(e[s]>0&&e[s]<255){n=!0;break}return Kt(this,"isFontSubpixelAAEnabled",n)}showText(t){const e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(s===0)return;const o=this.ctx,l=e.fontSizeScale,c=e.charSpacing,d=e.wordSpacing,f=e.fontDirection,g=e.textHScale*f,m=t.length,y=n.vertical,x=y?1:-1,b=n.defaultVMetrics,A=s*e.fontMatrix[0],C=e.textRenderingMode===_n.FILL&&!n.disableFontFace&&!e.patternFill;o.save(),o.transform(...e.textMatrix),o.translate(e.x,e.y+e.textRise),f>0?o.scale(g,-1):o.scale(g,1);let E,N;if(e.patternFill){o.save();const O=e.fillColor.getPattern(o,this,Ms(o),Nn.FILL);E=_e(o),o.restore(),o.fillStyle=O}if(e.patternStroke){o.save();const O=e.strokeColor.getPattern(o,this,Ms(o),Nn.STROKE);N=_e(o),o.restore(),o.strokeStyle=O}let k=e.lineWidth;const L=e.textMatrixScale;if(L===0||k===0){const O=e.textRenderingMode&_n.FILL_STROKE_MASK;(O===_n.STROKE||O===_n.FILL_STROKE)&&(k=this.getSinglePixelWidth())}else k/=L;if(l!==1&&(o.scale(l,l),k/=l),o.lineWidth=k,n.isInvalidPDFjsFont){const O=[];let H=0;for(const X of t)O.push(X.unicode),H+=X.width;o.fillText(O.join(""),0,0),e.x+=H*A*g,o.restore(),this.compose();return}let R=0,j;for(j=0;j<m;++j){const O=t[j];if(typeof O=="number"){R+=x*O*s/1e3;continue}let H=!1;const X=(O.isSpace?d:0)+c,q=O.fontChar,K=O.accent;let lt,pt,ut=O.width;if(y){const Q=O.vmetric||b,tt=-(O.vmetric?Q[1]:ut*.5)*A,J=Q[2]*A;ut=Q?-Q[0]:ut,lt=tt/l,pt=(R+J)/l}else lt=R/l,pt=0;if(n.remeasure&&ut>0){const Q=o.measureText(q).width*1e3/s*l;if(ut<Q&&this.isFontSubpixelAAEnabled){const tt=ut/Q;H=!0,o.save(),o.scale(tt,1),lt/=tt}else ut!==Q&&(lt+=(ut-Q)/2e3*s/l)}if(this.contentVisible&&(O.isInFont||n.missingFile)){if(C&&!K)o.fillText(q,lt,pt);else if(this.paintChar(q,lt,pt,E,N),K){const Q=lt+s*K.offset.x/l,tt=pt-s*K.offset.y/l;this.paintChar(K.fontChar,Q,tt,E,N)}}const St=y?ut*A-X*f:ut*A+X*f;R+=St,H&&o.restore()}y?e.y-=R:e.x+=R*g,o.restore(),this.compose()}showType3Text(t){const e=this.ctx,n=this.current,s=n.font,o=n.fontSize,l=n.fontDirection,c=s.vertical?1:-1,d=n.charSpacing,f=n.wordSpacing,g=n.textHScale*l,m=n.fontMatrix||Cy,y=t.length,x=n.textRenderingMode===_n.INVISIBLE;let b,A,C,E;if(!(x||o===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...n.textMatrix),e.translate(n.x,n.y),e.scale(g,l),b=0;b<y;++b){if(A=t[b],typeof A=="number"){E=c*A*o/1e3,this.ctx.translate(E,0),n.x+=E*g;continue}const N=(A.isSpace?f:0)+d,k=s.charProcOperatorList[A.operatorListId];if(!k){Ut(`Type3 character "${A.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=A,this.save(),e.scale(o,o),e.transform(...m),this.executeOperatorList(k),this.restore()),C=Pt.applyTransform([A.width,0],m)[0]*o+N,e.translate(C,0),n.x+=C*g}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,n,s,o,l){this.ctx.rect(n,s,o-n,l-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const n=t[1],s=this.baseTransform||_e(this.ctx),o={createCanvasGraphics:l=>new fx(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Zy(t,n,this.ctx,o,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,n){this.ctx.strokeStyle=this.current.strokeColor=Pt.makeHexColor(t,e,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,n){this.ctx.fillStyle=this.current.fillColor=Pt.makeHexColor(t,e,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let n;return this.cachedPatterns.has(t)?n=this.cachedPatterns.get(t):(n=NT(this.getObject(t)),this.cachedPatterns.set(t,n)),e&&(n.matrix=e),n}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,Ms(e),Nn.SHADING);const s=Ms(e);if(s){const{width:o,height:l}=e.canvas,[c,d,f,g]=Pt.getAxialAlignedBoundingBox([0,0,o,l],s);this.ctx.fillRect(c,d,f-c,g-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){fe("Should not call beginInlineImage")}beginImageData(){fe("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=_e(this.ctx),e)){const n=e[2]-e[0],s=e[3]-e[1];this.ctx.rect(e[0],e[1],n,s),this.current.updateRectMinMax(_e(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||dm("TODO: Support non-isolated groups."),t.knockout&&Ut("Knockout groups not supported.");const n=_e(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=Pt.getAxialAlignedBoundingBox(t.bbox,_e(e));const o=[0,0,e.canvas.width,e.canvas.height];s=Pt.intersect(s,o)||[0,0,0,0];const l=Math.floor(s[0]),c=Math.floor(s[1]),d=Math.max(Math.ceil(s[2])-l,1),f=Math.max(Math.ceil(s[3])-c,1);this.current.startNewPathAndClipBox([0,0,d,f]);let g="groupAt"+this.groupLevel;t.smask&&(g+="_smask_"+this.smaskCounter++%2);const m=this.cachedCanvases.getCanvas(g,d,f),y=m.context;y.translate(-l,-c),y.transform(...n),t.smask?this.smaskStack.push({canvas:m.canvas,context:y,offsetX:l,offsetY:c,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(l,c),e.save()),wh(e,y),this.ctx=y,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const s=_e(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...s);const o=Pt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],s);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(t,e,n,s,o){if(M(this,Ss,tv).call(this),Up(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const l=e[2]-e[0],c=e[3]-e[1];if(o&&this.annotationCanvasMap){n=n.slice(),n[4]-=e[0],n[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=l,e[3]=c;const[d,f]=Pt.singularValueDecompose2dScale(_e(this.ctx)),{viewportScale:g}=this,m=Math.ceil(l*this.outputScaleX*g),y=Math.ceil(c*this.outputScaleY*g);this.annotationCanvas=this.canvasFactory.create(m,y);const{canvas:x,context:b}=this.annotationCanvas;this.annotationCanvasMap.set(t,x),this.annotationCanvas.savedCtx=this.ctx,this.ctx=b,this.ctx.save(),this.ctx.setTransform(d,0,0,-f,0,c*f),Up(this.ctx)}else Up(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],l,c),this.ctx.clip(),this.ctx.beginPath()}this.current=new Ab(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),M(this,Ss,ev).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const n=this.ctx,s=this.processingType3;if(s&&(s.compiled===void 0&&(s.compiled=OT(t)),s.compiled)){s.compiled(n);return}const o=this._createMaskCanvas(t),l=o.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(l,o.offsetX,o.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,n=0,s=0,o,l){if(!this.contentVisible)return;t=this.getObject(t.data,t);const c=this.ctx;c.save();const d=_e(c);c.transform(e,n,s,o,0,0);const f=this._createMaskCanvas(t);c.setTransform(1,0,0,1,f.offsetX-d[4],f.offsetY-d[5]);for(let g=0,m=l.length;g<m;g+=2){const y=Pt.transform(d,[e,n,s,o,l[g],l[g+1]]),[x,b]=Pt.applyTransform([0,0],y);c.drawImage(f.canvas,x,b)}c.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,n=this.current.fillColor,s=this.current.patternFill;for(const o of t){const{data:l,width:c,height:d,transform:f}=o,g=this.cachedCanvases.getCanvas("maskCanvas",c,d),m=g.context;m.save();const y=this.getObject(l,o);Eb(m,y),m.globalCompositeOperation="source-in",m.fillStyle=s?n.getPattern(m,this,Ms(e),Nn.FILL):n,m.fillRect(0,0,c,d),m.restore(),e.save(),e.transform(...f),e.scale(1,-1),Bp(e,g.canvas,0,0,c,d,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){Ut("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,n,s){if(!this.contentVisible)return;const o=this.getObject(t);if(!o){Ut("Dependent image isn't ready yet");return}const l=o.width,c=o.height,d=[];for(let f=0,g=s.length;f<g;f+=2)d.push({transform:[e,0,0,n,s[f],s[f+1]],x:0,y:0,w:l,h:c});this.paintInlineImageXObjectGroup(o,d)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:n,height:s}=t,o=this.cachedCanvases.getCanvas("inlineImage",n,s),l=o.context;return l.filter=this.current.transferMaps,l.drawImage(e,0,0),l.filter="none",o.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,n=t.height,s=this.ctx;if(this.save(),!In){const{filter:c}=s;c!=="none"&&c!==""&&(s.filter="none")}s.scale(1/e,-1/n);let o;if(t.bitmap)o=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)o=t;else{const d=this.cachedCanvases.getCanvas("inlineImage",e,n).context;_b(d,t),o=this.applyTransferMapsToCanvas(d)}const l=this._scaleImage(o,Ms(s));s.imageSmoothingEnabled=kb(_e(s),t.interpolate),Bp(s,l.img,0,0,l.paintWidth,l.paintHeight,0,-n,e,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const n=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const o=t.width,l=t.height,d=this.cachedCanvases.getCanvas("inlineImage",o,l).context;_b(d,t),s=this.applyTransferMapsToCanvas(d)}for(const o of e)n.save(),n.transform(...o.transform),n.scale(1,-1),Bp(n,s,o.x,o.y,o.w,o.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const n=this.ctx;this.pendingClip&&(e||(this.pendingClip===Cb?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=_e(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),n=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(n,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:n,c:s,d:o}=this.ctx.getTransform();let l,c;if(n===0&&s===0){const d=Math.abs(e),f=Math.abs(o);if(d===f)if(t===0)l=c=1/d;else{const g=d*t;l=c=g<1?1/g:1}else if(t===0)l=1/d,c=1/f;else{const g=d*t,m=f*t;l=g<1?1/g:1,c=m<1?1/m:1}}else{const d=Math.abs(e*o-n*s),f=Math.hypot(e,n),g=Math.hypot(s,o);if(t===0)l=g/d,c=f/d;else{const m=t*d;l=g>m?g/m:1,c=f>m?f/m:1}}this._cachedScaleForStroking[0]=l,this._cachedScaleForStroking[1]=c}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:n}=this.current,[s,o]=this.getScaleForStroking();if(e.lineWidth=n||1,s===1&&o===1){e.stroke();return}const l=e.getLineDash();if(t&&e.save(),e.scale(s,o),l.length>0){const c=Math.max(s,o);e.setLineDash(l.map(d=>d/c)),e.lineDashOffset/=c}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Ss=new WeakSet,tv=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},ev=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},nv=function(t,e,n){const s=new Path2D;return s.addPath(t,new DOMMatrix(n).invertSelf().multiplySelf(e)),s};let Sc=fx;for(const a in rs)Sc.prototype[a]!==void 0&&(Sc.prototype[rs[a]]=Sc.prototype[a]);var Cd,Td;class Fr{static get workerPort(){return u(this,Cd)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");_(this,Cd,t)}static get workerSrc(){return u(this,Td)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");_(this,Td,t)}}Cd=new WeakMap,Td=new WeakMap,P(Fr,Cd,null),P(Fr,Td,"");var Ka,Pd;class HT{constructor({parsedData:t,rawData:e}){P(this,Ka);P(this,Pd);_(this,Ka,t),_(this,Pd,e)}getRaw(){return u(this,Pd)}get(t){return u(this,Ka).get(t)??null}getAll(){return Kv(u(this,Ka))}has(t){return u(this,Ka).has(t)}}Ka=new WeakMap,Pd=new WeakMap;const fc=Symbol("INTERNAL");var Md,Rd,Nd,Hc;class BT{constructor(t,{name:e,intent:n,usage:s,rbGroups:o}){P(this,Md,!1);P(this,Rd,!1);P(this,Nd,!1);P(this,Hc,!0);_(this,Md,!!(t&_i.DISPLAY)),_(this,Rd,!!(t&_i.PRINT)),this.name=e,this.intent=n,this.usage=s,this.rbGroups=o}get visible(){if(u(this,Nd))return u(this,Hc);if(!u(this,Hc))return!1;const{print:t,view:e}=this.usage;return u(this,Md)?(e==null?void 0:e.viewState)!=="OFF":u(this,Rd)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,n=!1){t!==fc&&fe("Internal method `_setVisible` called."),_(this,Nd,n),_(this,Hc,e)}}Md=new WeakMap,Rd=new WeakMap,Nd=new WeakMap,Hc=new WeakMap;var Mo,ce,Bc,Uc,Ld,iv;class UT{constructor(t,e=_i.DISPLAY){P(this,Ld);P(this,Mo,null);P(this,ce,new Map);P(this,Bc,null);P(this,Uc,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,_(this,Uc,t.order);for(const n of t.groups)u(this,ce).set(n.id,new BT(e,n));if(t.baseState==="OFF")for(const n of u(this,ce).values())n._setVisible(fc,!1);for(const n of t.on)u(this,ce).get(n)._setVisible(fc,!0);for(const n of t.off)u(this,ce).get(n)._setVisible(fc,!1);_(this,Bc,this.getHash())}}isVisible(t){if(u(this,ce).size===0)return!0;if(!t)return dm("Optional content group not defined."),!0;if(t.type==="OCG")return u(this,ce).has(t.id)?u(this,ce).get(t.id).visible:(Ut(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return M(this,Ld,iv).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!u(this,ce).has(e))return Ut(`Optional content group not found: ${e}`),!0;if(u(this,ce).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!u(this,ce).has(e))return Ut(`Optional content group not found: ${e}`),!0;if(!u(this,ce).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!u(this,ce).has(e))return Ut(`Optional content group not found: ${e}`),!0;if(!u(this,ce).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!u(this,ce).has(e))return Ut(`Optional content group not found: ${e}`),!0;if(u(this,ce).get(e).visible)return!1}return!0}return Ut(`Unknown optional content policy ${t.policy}.`),!0}return Ut(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,n=!0){var o;const s=u(this,ce).get(t);if(!s){Ut(`Optional content group not found: ${t}`);return}if(n&&e&&s.rbGroups.length)for(const l of s.rbGroups)for(const c of l)c!==t&&((o=u(this,ce).get(c))==null||o._setVisible(fc,!1,!0));s._setVisible(fc,!!e,!0),_(this,Mo,null)}setOCGState({state:t,preserveRB:e}){let n;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":n=s;continue}const o=u(this,ce).get(s);if(o)switch(n){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!o.visible,e);break}}_(this,Mo,null)}get hasInitialVisibility(){return u(this,Bc)===null||this.getHash()===u(this,Bc)}getOrder(){return u(this,ce).size?u(this,Uc)?u(this,Uc).slice():[...u(this,ce).keys()]:null}getGroups(){return u(this,ce).size>0?Kv(u(this,ce)):null}getGroup(t){return u(this,ce).get(t)||null}getHash(){if(u(this,Mo)!==null)return u(this,Mo);const t=new US;for(const[e,n]of u(this,ce))t.update(`${e}:${n.visible}`);return _(this,Mo,t.hexdigest())}}Mo=new WeakMap,ce=new WeakMap,Bc=new WeakMap,Uc=new WeakMap,Ld=new WeakSet,iv=function(t){const e=t.length;if(e<2)return!0;const n=t[0];for(let s=1;s<e;s++){const o=t[s];let l;if(Array.isArray(o))l=M(this,Ld,iv).call(this,o);else if(u(this,ce).has(o))l=u(this,ce).get(o).visible;else return Ut(`Optional content group not found: ${o}`),!0;switch(n){case"And":if(!l)return!1;break;case"Or":if(l)return!0;break;case"Not":return!l;default:return!0}}return n==="And"};class VT{constructor(t,{disableRange:e=!1,disableStream:n=!1}){He(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:o,progressiveDone:l,contentDispositionFilename:c}=t;if(this._queuedChunks=[],this._progressiveDone=l,this._contentDispositionFilename=c,(o==null?void 0:o.length)>0){const d=o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer;this._queuedChunks.push(d)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((d,f)=>{this._onReceiveData({begin:d,chunk:f})}),t.addProgressListener((d,f)=>{this._onProgress({loaded:d,total:f})}),t.addProgressiveReadListener(d=>{this._onReceiveData({chunk:d})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const n=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{const s=this._rangeReaders.some(function(o){return o._begin!==t?!1:(o._enqueue(n),!0)});He(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,n,s,o;t.total===void 0?(n=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||n.call(e,{loaded:t.loaded}):(o=(s=this._fullRequestReader)==null?void 0:s.onProgress)==null||o.call(s,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){He(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new WT(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new GT(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(n),n}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const n of this._rangeReaders.slice(0))n.cancel(t);this._pdfDataRangeTransport.abort()}}class WT{constructor(t,e,n=!1,s=null){this._stream=t,this._done=n||!1,this._filename=Zv(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const o of this._queuedChunks)this._loaded+=o.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class GT{constructor(t,e,n){this._stream=t,this._begin=e,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function XT(a){let t=!0,e=n("filename\\*","i").exec(a);if(e){e=e[1];let g=c(e);return g=unescape(g),g=d(g),g=f(g),o(g)}if(e=l(a),e){const g=f(e);return o(g)}if(e=n("filename","i").exec(a),e){e=e[1];let g=c(e);return g=f(g),o(g)}function n(g,m){return new RegExp("(?:^|;)\\s*"+g+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',m)}function s(g,m){if(g){if(!/^[\x00-\xFF]+$/.test(m))return m;try{const y=new TextDecoder(g,{fatal:!0}),x=fm(m);m=y.decode(x),t=!1}catch{}}return m}function o(g){return t&&/[\x80-\xff]/.test(g)&&(g=s("utf-8",g),t&&(g=s("iso-8859-1",g))),g}function l(g){const m=[];let y;const x=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(y=x.exec(g))!==null;){let[,A,C,E]=y;if(A=parseInt(A,10),A in m){if(A===0)break;continue}m[A]=[C,E]}const b=[];for(let A=0;A<m.length&&A in m;++A){let[C,E]=m[A];E=c(E),C&&(E=unescape(E),A===0&&(E=d(E))),b.push(E)}return b.join("")}function c(g){if(g.startsWith('"')){const m=g.slice(1).split('\\"');for(let y=0;y<m.length;++y){const x=m[y].indexOf('"');x!==-1&&(m[y]=m[y].slice(0,x),m.length=y+1),m[y]=m[y].replaceAll(/\\(.)/g,"$1")}g=m.join('"')}return g}function d(g){const m=g.indexOf("'");if(m===-1)return g;const y=g.slice(0,m),b=g.slice(m+1).replace(/^[^']*'/,"");return s(y,b)}function f(g){return!g.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(g)?g:g.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(m,y,x,b){if(x==="q"||x==="Q")return b=b.replaceAll("_"," "),b=b.replaceAll(/=([0-9a-fA-F]{2})/g,function(A,C){return String.fromCharCode(parseInt(C,16))}),s(y,b);try{b=atob(b)}catch{}return s(y,b)})}return""}function iA(a,t){const e=new Headers;if(!a||!t||typeof t!="object")return e;for(const n in t){const s=t[n];s!==void 0&&e.append(n,s)}return e}function mm(a){try{return new URL(a).origin}catch{}return null}function sA({responseHeaders:a,isHttp:t,rangeChunkSize:e,disableRange:n}){const s={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(a.get("Content-Length"),10);return!Number.isInteger(o)||(s.suggestedLength=o,o<=2*e)||n||!t||a.get("Accept-Ranges")!=="bytes"||(a.get("Content-Encoding")||"identity")!=="identity"||(s.allowRangeRequests=!0),s}function rA(a){const t=a.get("Content-Disposition");if(t){let e=XT(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Zv(e))return e}return null}function ym(a,t){return a===404||a===0&&t.startsWith("file:")?new Yh('Missing PDF "'+t+'".'):new Pg(`Unexpected server response (${a}) while retrieving PDF "${t}".`,a)}function oA(a){return a===200||a===206}function aA(a,t,e){return{method:"GET",headers:a,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function lA(a){return a instanceof Uint8Array?a.buffer:a instanceof ArrayBuffer?a:(Ut(`getArrayBuffer - unexpected data format: ${a}`),new Uint8Array(a).buffer)}class Tb{constructor(t){It(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=iA(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return He(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new qT(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new YT(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class qT{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const n=new Headers(t.headers),s=e.url;fetch(s,aA(n,this._withCredentials,this._abortController)).then(o=>{if(t._responseOrigin=mm(o.url),!oA(o.status))throw ym(o.status,s);this._reader=o.body.getReader(),this._headersCapability.resolve();const l=o.headers,{allowRangeRequests:c,suggestedLength:d}=sA({responseHeaders:l,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=c,this._contentLength=d||this._contentLength,this._filename=rA(l),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Zo("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded,total:this._contentLength}),{value:lA(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class YT{constructor(t,e,n){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const o=new Headers(t.headers);o.append("Range",`bytes=${e}-${n-1}`);const l=s.url;fetch(l,aA(o,this._withCredentials,this._abortController)).then(c=>{const d=mm(c.url);if(d!==t._responseOrigin)throw new Error(`Expected range response-origin "${d}" to match "${t._responseOrigin}".`);if(!oA(c.status))throw ym(c.status,l);this._readCapability.resolve(),this._reader=c.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded}),{value:lA(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const py=200,gy=206;function KT(a){const t=a.response;return typeof t!="string"?t:fm(t).buffer}class QT{constructor({url:t,httpHeaders:e,withCredentials:n}){It(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=iA(this.isHttp,e),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,n=this.currXhrId++,s=this.pendingRequests[n]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[o,l]of this.headers)e.setRequestHeader(o,l);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=gy):s.expectedStatus=py,e.responseType="arraybuffer",He(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,n),e.onprogress=this.onProgress.bind(this,n),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),n}onProgress(t,e){var s;const n=this.pendingRequests[t];n&&((s=n.onProgress)==null||s.call(n,e))}onStateChange(t,e){const n=this.pendingRequests[t];if(!n)return;const s=n.xhr;if(s.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),s.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],s.status===0&&this.isHttp){n.onError(s.status);return}const o=s.status||py;if(!(o===py&&n.expectedStatus===gy)&&o!==n.expectedStatus){n.onError(s.status);return}const c=KT(s);if(o===gy){const d=s.getResponseHeader("Content-Range"),f=/bytes (\d+)-(\d+)\/(\d+)/.exec(d);f?n.onDone({begin:parseInt(f[1],10),chunk:c}):(Ut('Missing or invalid "Content-Range" header.'),n.onError(0))}else c?n.onDone({begin:0,chunk:c}):n.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class JT{constructor(t){this._source=t,this._manager=new QT(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return He(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new ZT(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const n=new tP(this._manager,t,e);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class ZT{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=mm(e.responseURL);const n=e.getAllResponseHeaders(),s=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(c=>{const[d,...f]=c.split(": ");return[d,f.join(": ")]}):[]),{allowRangeRequests:o,suggestedLength:l}=sA({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});o&&(this._isRangeSupported=!0),this._contentLength=l||this._contentLength,this._filename=rA(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=ym(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class tP{constructor(t,e,n){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var e;const t=mm((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=ym(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const eP=/^[a-z][a-z0-9\-+.]+:/i;function nP(a){if(eP.test(a))return new URL(a);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(a))}class iP{constructor(t){this.source=t,this.url=nP(t.url),He(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return He(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new sP(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new rP(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class sP{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=process.getBuiltinModule("fs");n.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new Yh(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Zo("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class rP{constructor(t,e,n){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const o=process.getBuiltinModule("fs");this._setReadableStream(o.createReadStream(this._url,{start:e,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const oP=1e5,ti=30,aP=.8;var Kb,Ro,si,Id,Dd,Qa,wr,Fd,Od,Ja,Vc,Wc,No,Gc,jd,Xc,Za,$d,zd,tl,el,Hd,Lo,qc,Br,cA,uA,sv,Ti,ag,rv,hA,dA;const Ke=class Ke{constructor({textContentSource:t,container:e,viewport:n}){P(this,Br);P(this,Ro,Promise.withResolvers());P(this,si,null);P(this,Id,!1);P(this,Dd,!!((Kb=globalThis.FontInspector)!=null&&Kb.enabled));P(this,Qa,null);P(this,wr,null);P(this,Fd,0);P(this,Od,0);P(this,Ja,null);P(this,Vc,null);P(this,Wc,0);P(this,No,0);P(this,Gc,Object.create(null));P(this,jd,[]);P(this,Xc,null);P(this,Za,[]);P(this,$d,new WeakMap);P(this,zd,null);var d;if(t instanceof ReadableStream)_(this,Xc,t);else if(typeof t=="object")_(this,Xc,new ReadableStream({start(f){f.enqueue(t),f.close()}}));else throw new Error('No "textContentSource" parameter specified.');_(this,si,_(this,Vc,e)),_(this,No,n.scale*(globalThis.devicePixelRatio||1)),_(this,Wc,n.rotation),_(this,wr,{div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:o,pageX:l,pageY:c}=n.rawDims;_(this,zd,[1,0,0,-1,-l,c+o]),_(this,Od,s),_(this,Fd,o),M(d=Ke,Ti,hA).call(d),Nl(e,n),u(this,Ro).promise.finally(()=>{u(Ke,qc).delete(this),_(this,wr,null),_(this,Gc,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Wn.platform;return Kt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{u(this,Ja).read().then(({value:e,done:n})=>{if(n){u(this,Ro).resolve();return}u(this,Qa)??_(this,Qa,e.lang),Object.assign(u(this,Gc),e.styles),M(this,Br,cA).call(this,e.items),t()},u(this,Ro).reject)};return _(this,Ja,u(this,Xc).getReader()),u(Ke,qc).add(this),t(),u(this,Ro).promise}update({viewport:t,onBefore:e=null}){var o;const n=t.scale*(globalThis.devicePixelRatio||1),s=t.rotation;if(s!==u(this,Wc)&&(e==null||e(),_(this,Wc,s),Nl(u(this,Vc),{rotation:s})),n!==u(this,No)){e==null||e(),_(this,No,n);const l={div:null,properties:null,ctx:M(o=Ke,Ti,ag).call(o,u(this,Qa))};for(const c of u(this,Za))l.properties=u(this,$d).get(c),l.div=c,M(this,Br,sv).call(this,l)}}cancel(){var e;const t=new Zo("TextLayer task cancelled.");(e=u(this,Ja))==null||e.cancel(t).catch(()=>{}),_(this,Ja,null),u(this,Ro).reject(t)}get textDivs(){return u(this,Za)}get textContentItemsStr(){return u(this,jd)}static cleanup(){if(!(u(this,qc).size>0)){u(this,tl).clear();for(const{canvas:t}of u(this,el).values())t.remove();u(this,el).clear()}}};Ro=new WeakMap,si=new WeakMap,Id=new WeakMap,Dd=new WeakMap,Qa=new WeakMap,wr=new WeakMap,Fd=new WeakMap,Od=new WeakMap,Ja=new WeakMap,Vc=new WeakMap,Wc=new WeakMap,No=new WeakMap,Gc=new WeakMap,jd=new WeakMap,Xc=new WeakMap,Za=new WeakMap,$d=new WeakMap,zd=new WeakMap,tl=new WeakMap,el=new WeakMap,Hd=new WeakMap,Lo=new WeakMap,qc=new WeakMap,Br=new WeakSet,cA=function(t){var s,o;if(u(this,Id))return;(o=u(this,wr)).ctx??(o.ctx=M(s=Ke,Ti,ag).call(s,u(this,Qa)));const e=u(this,Za),n=u(this,jd);for(const l of t){if(e.length>oP){Ut("Ignoring additional textDivs for performance reasons."),_(this,Id,!0);return}if(l.str===void 0){if(l.type==="beginMarkedContentProps"||l.type==="beginMarkedContent"){const c=u(this,si);_(this,si,document.createElement("span")),u(this,si).classList.add("markedContent"),l.id!==null&&u(this,si).setAttribute("id",`${l.id}`),c.append(u(this,si))}else l.type==="endMarkedContent"&&_(this,si,u(this,si).parentNode);continue}n.push(l.str),M(this,Br,uA).call(this,l)}},uA=function(t){var A;const e=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};u(this,Za).push(e);const s=Pt.transform(u(this,zd),t.transform);let o=Math.atan2(s[1],s[0]);const l=u(this,Gc)[t.fontName];l.vertical&&(o+=Math.PI/2);let c=u(this,Dd)&&l.fontSubstitution||l.fontFamily;c=Ke.fontFamilyMap.get(c)||c;const d=Math.hypot(s[2],s[3]),f=d*M(A=Ke,Ti,dA).call(A,c,u(this,Qa));let g,m;o===0?(g=s[4],m=s[5]-f):(g=s[4]+f*Math.sin(o),m=s[5]-f*Math.cos(o));const y="calc(var(--scale-factor)*",x=e.style;u(this,si)===u(this,Vc)?(x.left=`${(100*g/u(this,Od)).toFixed(2)}%`,x.top=`${(100*m/u(this,Fd)).toFixed(2)}%`):(x.left=`${y}${g.toFixed(2)}px)`,x.top=`${y}${m.toFixed(2)}px)`),x.fontSize=`${y}${(u(Ke,Lo)*d).toFixed(2)}px)`,x.fontFamily=c,n.fontSize=d,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,u(this,Dd)&&(e.dataset.fontName=l.fontSubstitutionLoadedName||t.fontName),o!==0&&(n.angle=o*(180/Math.PI));let b=!1;if(t.str.length>1)b=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const C=Math.abs(t.transform[0]),E=Math.abs(t.transform[3]);C!==E&&Math.max(C,E)/Math.min(C,E)>1.5&&(b=!0)}if(b&&(n.canvasWidth=l.vertical?t.height:t.width),u(this,$d).set(e,n),u(this,wr).div=e,u(this,wr).properties=n,M(this,Br,sv).call(this,u(this,wr)),n.hasText&&u(this,si).append(e),n.hasEOL){const C=document.createElement("br");C.setAttribute("role","presentation"),u(this,si).append(C)}},sv=function(t){var c;const{div:e,properties:n,ctx:s}=t,{style:o}=e;let l="";if(u(Ke,Lo)>1&&(l=`scale(${1/u(Ke,Lo)})`),n.canvasWidth!==0&&n.hasText){const{fontFamily:d}=o,{canvasWidth:f,fontSize:g}=n;M(c=Ke,Ti,rv).call(c,s,g*u(this,No),d);const{width:m}=s.measureText(e.textContent);m>0&&(l=`scaleX(${f*u(this,No)/m}) ${l}`)}n.angle!==0&&(l=`rotate(${n.angle}deg) ${l}`),l.length>0&&(o.transform=l)},Ti=new WeakSet,ag=function(t=null){let e=u(this,el).get(t||(t=""));if(!e){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),e=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),u(this,el).set(t,e),u(this,Hd).set(e,{size:0,family:""})}return e},rv=function(t,e,n){const s=u(this,Hd).get(t);e===s.size&&n===s.family||(t.font=`${e}px ${n}`,s.size=e,s.family=n)},hA=function(){if(u(this,Lo)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),_(this,Lo,t.getBoundingClientRect().height),t.remove()},dA=function(t,e){const n=u(this,tl).get(t);if(n)return n;const s=M(this,Ti,ag).call(this,e);s.canvas.width=s.canvas.height=ti,M(this,Ti,rv).call(this,s,ti,t);const o=s.measureText("");let l=o.fontBoundingBoxAscent,c=Math.abs(o.fontBoundingBoxDescent);if(l){const g=l/(l+c);return u(this,tl).set(t,g),s.canvas.width=s.canvas.height=0,g}s.strokeStyle="red",s.clearRect(0,0,ti,ti),s.strokeText("g",0,0);let d=s.getImageData(0,0,ti,ti).data;c=0;for(let g=d.length-1-3;g>=0;g-=4)if(d[g]>0){c=Math.ceil(g/4/ti);break}s.clearRect(0,0,ti,ti),s.strokeText("A",0,ti),d=s.getImageData(0,0,ti,ti).data,l=0;for(let g=0,m=d.length;g<m;g+=4)if(d[g]>0){l=ti-Math.floor(g/4/ti);break}s.canvas.width=s.canvas.height=0;const f=l?l/(l+c):aP;return u(this,tl).set(t,f),f},P(Ke,Ti),P(Ke,tl,new Map),P(Ke,el,new Map),P(Ke,Hd,new WeakMap),P(Ke,Lo,null),P(Ke,qc,new Set);let Kh=Ke;class Qh{static textContent(t){const e=[],n={items:e,styles:Object.create(null)};function s(o){var d;if(!o)return;let l=null;const c=o.name;if(c==="#text")l=o.value;else if(Qh.shouldBuildText(c))(d=o==null?void 0:o.attributes)!=null&&d.textContent?l=o.attributes.textContent:o.value&&(l=o.value);else return;if(l!==null&&e.push({str:l}),!!o.children)for(const f of o.children)s(f)}return s(t),n}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const lP=65536,cP=100,uP=5e3,hP=In?ET:ST,dP=In?kT:QS,fP=In?_T:AT,pP=In?CT:eA;function gP(a={}){typeof a=="string"||a instanceof URL?a={url:a}:(a instanceof ArrayBuffer||ArrayBuffer.isView(a))&&(a={data:a});const t=new ov,{docId:e}=t,n=a.url?mP(a.url):null,s=a.data?yP(a.data):null,o=a.httpHeaders||null,l=a.withCredentials===!0,c=a.password??null,d=a.range instanceof fA?a.range:null,f=Number.isInteger(a.rangeChunkSize)&&a.rangeChunkSize>0?a.rangeChunkSize:lP;let g=a.worker instanceof Ac?a.worker:null;const m=a.verbosity,y=typeof a.docBaseUrl=="string"&&!gm(a.docBaseUrl)?a.docBaseUrl:null,x=typeof a.cMapUrl=="string"?a.cMapUrl:null,b=a.cMapPacked!==!1,A=a.CMapReaderFactory||dP,C=typeof a.standardFontDataUrl=="string"?a.standardFontDataUrl:null,E=a.StandardFontDataFactory||pP,N=a.stopAtErrors!==!0,k=Number.isInteger(a.maxImageSize)&&a.maxImageSize>-1?a.maxImageSize:-1,L=a.isEvalSupported!==!1,R=typeof a.isOffscreenCanvasSupported=="boolean"?a.isOffscreenCanvasSupported:!In,j=typeof a.isImageDecoderSupported=="boolean"?a.isImageDecoderSupported:!In&&(Wn.platform.isFirefox||!globalThis.chrome),O=Number.isInteger(a.canvasMaxAreaInBytes)?a.canvasMaxAreaInBytes:-1,H=typeof a.disableFontFace=="boolean"?a.disableFontFace:In,X=a.fontExtraProperties===!0,q=a.enableXfa===!0,K=a.ownerDocument||globalThis.document,lt=a.disableRange===!0,pt=a.disableStream===!0,ut=a.disableAutoFetch===!0,St=a.pdfBug===!0,Q=a.CanvasFactory||hP,tt=a.FilterFactory||fP,J=a.enableHWA===!0,at=d?d.length:a.length??NaN,st=typeof a.useSystemFonts=="boolean"?a.useSystemFonts:!In&&!H,I=typeof a.useWorkerFetch=="boolean"?a.useWorkerFetch:A===QS&&E===eA&&x&&C&&Eh(x,document.baseURI)&&Eh(C,document.baseURI),V=null;tT(m);const W={canvasFactory:new Q({ownerDocument:K,enableHWA:J}),filterFactory:new tt({docId:e,ownerDocument:K}),cMapReaderFactory:I?null:new A({baseUrl:x,isCompressed:b}),standardFontDataFactory:I?null:new E({baseUrl:C})};if(!g){const dt={verbosity:m,port:Fr.workerPort};g=dt.port?Ac.fromPort(dt):new Ac(dt),t._worker=g}const nt={docId:e,apiVersion:"4.10.38",data:s,password:c,disableAutoFetch:ut,rangeChunkSize:f,length:at,docBaseUrl:y,enableXfa:q,evaluatorOptions:{maxImageSize:k,disableFontFace:H,ignoreErrors:N,isEvalSupported:L,isOffscreenCanvasSupported:R,isImageDecoderSupported:j,canvasMaxAreaInBytes:O,fontExtraProperties:X,useSystemFonts:st,cMapUrl:I?x:null,standardFontDataUrl:I?C:null}},rt={disableFontFace:H,fontExtraProperties:X,ownerDocument:K,pdfBug:St,styleElement:V,loadingParams:{disableAutoFetch:ut,enableXfa:q}};return g.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(g.destroyed)throw new Error("Worker was destroyed");const dt=g.messageHandler.sendWithPromise("GetDocRequest",nt,s?[s.buffer]:null);let mt;if(d)mt=new VT(d,{disableRange:lt,disableStream:pt});else if(!s){if(!n)throw new Error("getDocument - no `url` parameter provided.");let Mt;if(In)if(Eh(n)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Mt=Tb}else Mt=iP;else Mt=Eh(n)?Tb:JT;mt=new Mt({url:n,length:at,httpHeaders:o,withCredentials:l,rangeChunkSize:f,disableRange:lt,disableStream:pt})}return dt.then(Mt=>{if(t.destroyed)throw new Error("Loading aborted");if(g.destroyed)throw new Error("Worker was destroyed");const Vt=new Ph(e,Mt,g.port),ye=new bP(Vt,t,mt,rt,W);t._transport=ye,Vt.send("Ready",null)})}).catch(t._capability.reject),t}function mP(a){if(a instanceof URL)return a.href;try{return new URL(a,window.location).href}catch{if(In&&typeof a=="string")return a}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function yP(a){if(In&&typeof Buffer<"u"&&a instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength)return a;if(typeof a=="string")return fm(a);if(a instanceof ArrayBuffer||ArrayBuffer.isView(a)||typeof a=="object"&&!isNaN(a==null?void 0:a.length))return new Uint8Array(a);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Pb(a){return typeof a=="object"&&Number.isInteger(a==null?void 0:a.num)&&a.num>=0&&Number.isInteger(a==null?void 0:a.gen)&&a.gen>=0}var Qg;const Jg=class Jg{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${$n(Jg,Qg)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,e,n,s;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(o){throw(n=this._worker)!=null&&n.port&&delete this._worker._pendingDestroy,o}this._transport=null,(s=this._worker)==null||s.destroy(),this._worker=null}};Qg=new WeakMap,P(Jg,Qg,0);let ov=Jg;class fA{constructor(t,e,n=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=n,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const n of this._rangeListeners)n(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const n of this._progressListeners)n(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){fe("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class vP{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Kt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Io,br,Gi,pc,lg;class xP{constructor(t,e,n,s=!1){P(this,Gi);P(this,Io,null);P(this,br,!1);this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=s?new gb:null,this._pdfBug=s,this.commonObjs=n.commonObjs,this.objs=new pA,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:n=0,offsetY:s=0,dontFlip:o=!1}={}){return new kf({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:s,dontFlip:o})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Kt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:e,intent:n="display",annotationMode:s=yo.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:c=null,annotationCanvasMap:d=null,pageColors:f=null,printAnnotationStorage:g=null,isEditing:m=!1}){var L,R;(L=this._stats)==null||L.time("Overall");const y=this._transport.getRenderingIntent(n,s,g,m),{renderingIntent:x,cacheKey:b}=y;_(this,br,!1),M(this,Gi,lg).call(this),c||(c=this._transport.getOptionalContentConfig(x));let A=this._intentStates.get(b);A||(A=Object.create(null),this._intentStates.set(b,A)),A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const C=!!(x&_i.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(R=this._stats)==null||R.time("Page Request"),this._pumpOperatorList(y));const E=j=>{var O;A.renderTasks.delete(N),(this._maybeCleanupAfterRender||C)&&_(this,br,!0),M(this,Gi,pc).call(this,!C),j?(N.capability.reject(j),this._abortOperatorList({intentState:A,reason:j instanceof Error?j:new Error(j)})):N.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(O=globalThis.Stats)!=null&&O.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},N=new lv({callback:E,params:{canvasContext:t,viewport:e,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:d,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!C,pdfBug:this._pdfBug,pageColors:f});(A.renderTasks||(A.renderTasks=new Set)).add(N);const k=N.task;return Promise.all([A.displayReadyCapability.promise,c]).then(([j,O])=>{var H;if(this.destroyed){E();return}if((H=this._stats)==null||H.time("Rendering"),!(O.renderingIntent&x))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");N.initializeGraphics({transparency:j,optionalContentConfig:O}),N.operatorListChanged()}).catch(E),k}getOperatorList({intent:t="display",annotationMode:e=yo.ENABLE,printAnnotationStorage:n=null,isEditing:s=!1}={}){var f;function o(){c.operatorList.lastChunk&&(c.opListReadCapability.resolve(c.operatorList),c.renderTasks.delete(d))}const l=this._transport.getRenderingIntent(t,e,n,s,!0);let c=this._intentStates.get(l.cacheKey);c||(c=Object.create(null),this._intentStates.set(l.cacheKey,c));let d;return c.opListReadCapability||(d=Object.create(null),d.operatorListChanged=o,c.opListReadCapability=Promise.withResolvers(),(c.renderTasks||(c.renderTasks=new Set)).add(d),c.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(f=this._stats)==null||f.time("Page Request"),this._pumpOperatorList(l)),c.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(s){return s.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>Qh.textContent(n));const e=this.streamTextContent(t);return new Promise(function(n,s){function o(){l.read().then(function({value:d,done:f}){if(f){n(c);return}c.lang??(c.lang=d.lang),Object.assign(c.styles,d.styles),c.items.push(...d.items),o()},s)}const l=e.getReader(),c={items:[],styles:Object.create(null),lang:null};o()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const n of e.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),_(this,br,!1),M(this,Gi,lg).call(this),Promise.all(t)}cleanup(t=!1){_(this,br,!0);const e=M(this,Gi,pc).call(this,!1);return t&&e&&this._stats&&(this._stats=new gb),e}_startRenderPage(t,e){var s,o;const n=this._intentStates.get(e);n&&((s=this._stats)==null||s.timeEnd("Page Request"),(o=n.displayReadyCapability)==null||o.resolve(t))}_renderPageChunk(t,e){for(let n=0,s=t.length;n<s;n++)e.operatorList.fnArray.push(t.fnArray[n]),e.operatorList.argsArray.push(t.argsArray[n]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const n of e.renderTasks)n.operatorListChanged();t.lastChunk&&M(this,Gi,pc).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:n,modifiedIds:s}){const{map:o,transfer:l}=n,d=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:o,modifiedIds:s},l).getReader(),f=this._intentStates.get(e);f.streamReader=d;const g=()=>{d.read().then(({value:m,done:y})=>{if(y){f.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(m,f),g())},m=>{if(f.streamReader=null,!this._transport.destroyed){if(f.operatorList){f.operatorList.lastChunk=!0;for(const y of f.renderTasks)y.operatorListChanged();M(this,Gi,pc).call(this,!0)}if(f.displayReadyCapability)f.displayReadyCapability.reject(m);else if(f.opListReadCapability)f.opListReadCapability.reject(m);else throw m}})};g()}_abortOperatorList({intentState:t,reason:e,force:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(e instanceof Jv){let s=cP;e.extraDelay>0&&e.extraDelay<1e3&&(s+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},s);return}}if(t.streamReader.cancel(new Zo(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[s,o]of this._intentStates)if(o===t){this._intentStates.delete(s);break}this.cleanup()}}}get stats(){return this._stats}}Io=new WeakMap,br=new WeakMap,Gi=new WeakSet,pc=function(t=!1){if(M(this,Gi,lg).call(this),!u(this,br)||this.destroyed)return!1;if(t)return _(this,Io,setTimeout(()=>{_(this,Io,null),M(this,Gi,pc).call(this,!1)},uP)),!1;for(const{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),_(this,br,!1),!0},lg=function(){u(this,Io)&&(clearTimeout(u(this,Io)),_(this,Io,null))};var Sr,Zg;class wP{constructor(){P(this,Sr,new Map);P(this,Zg,Promise.resolve())}postMessage(t,e){const n={data:structuredClone(t,e?{transfer:e}:null)};u(this,Zg).then(()=>{for(const[s]of u(this,Sr))s.call(this,n)})}addEventListener(t,e,n=null){let s=null;if((n==null?void 0:n.signal)instanceof AbortSignal){const{signal:o}=n;if(o.aborted){Ut("LoopbackPort - cannot use an `aborted` signal.");return}const l=()=>this.removeEventListener(t,e);s=()=>o.removeEventListener("abort",l),o.addEventListener("abort",l)}u(this,Sr).set(e,s)}removeEventListener(t,e){const n=u(this,Sr).get(e);n==null||n(),u(this,Sr).delete(e)}terminate(){for(const[,t]of u(this,Sr))t==null||t();u(this,Sr).clear()}}Sr=new WeakMap,Zg=new WeakMap;var tm,nl,il,Yc,cg,Kc,ug;const Ae=class Ae{constructor({name:t=null,port:e=null,verbosity:n=eT()}={}){P(this,Yc);var s;if(this.name=t,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if((s=u(Ae,il))!=null&&s.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(u(Ae,il)||_(Ae,il,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Ph("main","worker",t),this._messageHandler.on("ready",function(){}),M(this,Yc,cg).call(this)}_initialize(){if(u(Ae,nl)||u(Ae,Kc,ug)){this._setupFakeWorker();return}let{workerSrc:t}=Ae;try{Ae._isSameOrigin(window.location.href,t)||(t=Ae._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),n=new Ph("main","worker",e),s=()=>{o.abort(),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},o=new AbortController;e.addEventListener("error",()=>{this._webWorker||s()},{signal:o.signal}),n.on("test",c=>{if(o.abort(),this.destroyed||!c){s();return}this._messageHandler=n,this._port=e,this._webWorker=e,M(this,Yc,cg).call(this)}),n.on("ready",c=>{if(o.abort(),this.destroyed){s();return}try{l()}catch{this._setupFakeWorker()}});const l=()=>{const c=new Uint8Array;n.send("test",c,[c.buffer])};l();return}catch{dm("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){u(Ae,nl)||(Ut("Setting up fake worker."),_(Ae,nl,!0)),Ae._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new wP;this._port=e;const n=`fake${$n(Ae,tm)._++}`,s=new Ph(n+"_worker",n,e);t.setup(s,e),this._messageHandler=new Ph(n,n+"_worker",e),M(this,Yc,cg).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t,e,n;this.destroyed=!0,(t=this._webWorker)==null||t.terminate(),this._webWorker=null,(e=u(Ae,il))==null||e.delete(this._port),this._port=null,(n=this._messageHandler)==null||n.destroy(),this._messageHandler=null}static fromPort(t){var n;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const e=(n=u(this,il))==null?void 0:n.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Ae(t)}static get workerSrc(){if(Fr.workerSrc)return Fr.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Kt(this,"_setupFakeWorkerGlobal",(async()=>u(this,Kc,ug)?u(this,Kc,ug):(await import(this.workerSrc)).WorkerMessageHandler)())}};tm=new WeakMap,nl=new WeakMap,il=new WeakMap,Yc=new WeakSet,cg=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Kc=new WeakSet,ug=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},P(Ae,Kc),P(Ae,tm,0),P(Ae,nl,!1),P(Ae,il),In&&(_(Ae,nl,!0),Fr.workerSrc||(Fr.workerSrc="./pdf.worker.mjs")),Ae._isSameOrigin=(t,e)=>{let n;try{if(n=new URL(t),!n.origin||n.origin==="null")return!1}catch{return!1}const s=new URL(e,n);return n.origin===s.origin},Ae._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Ac=Ae;var Ar,Bs,Qc,Jc,_r,sl,Ih;class bP{constructor(t,e,n,s,o){P(this,sl);P(this,Ar,new Map);P(this,Bs,new Map);P(this,Qc,new Map);P(this,Jc,new Map);P(this,_r,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new pA,this.fontLoader=new wT({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=o.canvasFactory,this.filterFactory=o.filterFactory,this.cMapReaderFactory=o.cMapReaderFactory,this.standardFontDataFactory=o.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Kt(this,"annotationStorage",new nx)}getRenderingIntent(t,e=yo.ENABLE,n=null,s=!1,o=!1){let l=_i.DISPLAY,c=Yy;switch(t){case"any":l=_i.ANY;break;case"display":break;case"print":l=_i.PRINT;break;default:Ut(`getRenderingIntent - invalid intent: ${t}`)}const d=l&_i.PRINT&&n instanceof WS?n:this.annotationStorage;switch(e){case yo.DISABLE:l+=_i.ANNOTATIONS_DISABLE;break;case yo.ENABLE:break;case yo.ENABLE_FORMS:l+=_i.ANNOTATIONS_FORMS;break;case yo.ENABLE_STORAGE:l+=_i.ANNOTATIONS_STORAGE,c=d.serializable;break;default:Ut(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(l+=_i.IS_EDITING),o&&(l+=_i.OPLIST);const{ids:f,hash:g}=d.modifiedIds,m=[l,c.hash,g];return{renderingIntent:l,cacheKey:m.join("_"),annotationStorageSerializable:c,modifiedIds:f}}destroy(){var n;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(n=u(this,_r))==null||n.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of u(this,Bs).values())t.push(s._destroy());u(this,Bs).clear(),u(this,Qc).clear(),u(this,Jc).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var s,o;this.commonObjs.clear(),this.fontLoader.clear(),u(this,Ar).clear(),this.filterFactory.destroy(),Kh.cleanup(),(s=this._networkStream)==null||s.cancelAllRequests(new Zo("Worker was terminated.")),(o=this.messageHandler)==null||o.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(n,s)=>{He(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=o=>{this._lastProgress={loaded:o.loaded,total:o.total}},s.onPull=()=>{this._fullReader.read().then(function({value:o,done:l}){if(l){s.close();return}He(o instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{s.error(o)})},s.onCancel=o=>{this._fullReader.cancel(o),s.ready.catch(l=>{if(!this.destroyed)throw l})}}),t.on("ReaderHeadersReady",async n=>{var c;await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:o,contentLength:l}=this._fullReader;return(!s||!o)&&(this._lastProgress&&((c=e.onProgress)==null||c.call(e,this._lastProgress)),this._fullReader.onProgress=d=>{var f;(f=e.onProgress)==null||f.call(e,{loaded:d.loaded,total:d.total})}),{isStreamingSupported:s,isRangeSupported:o,contentLength:l}}),t.on("GetRangeReader",(n,s)=>{He(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const o=this._networkStream.getRangeReader(n.begin,n.end);if(!o){s.close();return}s.onPull=()=>{o.read().then(function({value:l,done:c}){if(c){s.close();return}He(l instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(l),1,[l])}).catch(l=>{s.error(l)})},s.onCancel=l=>{o.cancel(l),s.ready.catch(c=>{if(!this.destroyed)throw c})}}),t.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,e._capability.resolve(new vP(n,this))}),t.on("DocException",n=>{e._capability.reject(ei(n))}),t.on("PasswordRequest",n=>{_(this,_r,Promise.withResolvers());try{if(!e.onPassword)throw ei(n);const s=o=>{o instanceof Error?u(this,_r).reject(o):u(this,_r).resolve({password:o})};e.onPassword(s,n.code)}catch(s){u(this,_r).reject(s)}return u(this,_r).promise}),t.on("DataLoaded",n=>{var s;(s=e.onProgress)==null||s.call(e,{loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),t.on("StartRenderPage",n=>{if(this.destroyed)return;u(this,Bs).get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),t.on("commonobj",([n,s,o])=>{var l;if(this.destroyed||this.commonObjs.has(n))return null;switch(s){case"Font":const{disableFontFace:c,fontExtraProperties:d,pdfBug:f}=this._params;if("error"in o){const x=o.error;Ut(`Error during font loading: ${x}`),this.commonObjs.resolve(n,x);break}const g=f&&((l=globalThis.FontInspector)!=null&&l.enabled)?(x,b)=>globalThis.FontInspector.fontAdded(x,b):null,m=new bT(o,{disableFontFace:c,fontExtraProperties:d,inspectFont:g});this.fontLoader.bind(m).catch(()=>t.sendWithPromise("FontFallback",{id:n})).finally(()=>{!d&&m.data&&(m.data=null),this.commonObjs.resolve(n,m)});break;case"CopyLocalImage":const{imageRef:y}=o;He(y,"The imageRef must be defined.");for(const x of u(this,Bs).values())for(const[,b]of x.objs)if((b==null?void 0:b.ref)===y)return b.dataLen?(this.commonObjs.resolve(n,structuredClone(b)),b.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,o);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),t.on("obj",([n,s,o,l])=>{var d;if(this.destroyed)return;const c=u(this,Bs).get(s);if(!c.objs.has(n)){if(c._intentStates.size===0){(d=l==null?void 0:l.bitmap)==null||d.close();return}switch(o){case"Image":c.objs.resolve(n,l),(l==null?void 0:l.dataLen)>KC&&(c._maybeCleanupAfterRender=!0);break;case"Pattern":c.objs.resolve(n,l);break;default:throw new Error(`Got unknown object type ${o}`)}}}),t.on("DocProgress",n=>{var s;this.destroyed||(s=e.onProgress)==null||s.call(e,{loaded:n.loaded,total:n.total})}),t.on("FetchBuiltInCMap",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(n)}),t.on("FetchStandardFontData",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(n)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var n;this.annotationStorage.size<=0&&Ut("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((n=this._fullReader)==null?void 0:n.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,n=u(this,Qc).get(e);if(n)return n;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(o=>{if(this.destroyed)throw new Error("Transport destroyed");o.refStr&&u(this,Jc).set(o.refStr,t);const l=new xP(e,o,this,this._params.pdfBug);return u(this,Bs).set(e,l),l});return u(this,Qc).set(e,s),s}getPageIndex(t){return Pb(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return M(this,sl,Ih).call(this,"GetFieldObjects")}hasJSActions(){return M(this,sl,Ih).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return M(this,sl,Ih).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return M(this,sl,Ih).call(this,"GetOptionalContentConfig").then(e=>new UT(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=u(this,Ar).get(t);if(e)return e;const n=this.messageHandler.sendWithPromise(t,null).then(s=>{var o,l;return{info:s[0],metadata:s[1]?new HT(s[1]):null,contentDispositionFilename:((o=this._fullReader)==null?void 0:o.filename)??null,contentLength:((l=this._fullReader)==null?void 0:l.contentLength)??null}});return u(this,Ar).set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of u(this,Bs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),u(this,Ar).clear(),this.filterFactory.destroy(!0),Kh.cleanup()}}cachedPageNumber(t){if(!Pb(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return u(this,Jc).get(e)??null}}Ar=new WeakMap,Bs=new WeakMap,Qc=new WeakMap,Jc=new WeakMap,_r=new WeakMap,sl=new WeakSet,Ih=function(t,e=null){const n=u(this,Ar).get(t);if(n)return n;const s=this.messageHandler.sendWithPromise(t,e);return u(this,Ar).set(t,s),s};const bh=Symbol("INITIAL_DATA");var gi,Bd,av;class pA{constructor(){P(this,Bd);P(this,gi,Object.create(null))}get(t,e=null){if(e){const s=M(this,Bd,av).call(this,t);return s.promise.then(()=>e(s.data)),null}const n=u(this,gi)[t];if(!n||n.data===bh)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){const e=u(this,gi)[t];return!!e&&e.data!==bh}delete(t){const e=u(this,gi)[t];return!e||e.data===bh?!1:(delete u(this,gi)[t],!0)}resolve(t,e=null){const n=M(this,Bd,av).call(this,t);n.data=e,n.resolve()}clear(){var t;for(const e in u(this,gi)){const{data:n}=u(this,gi)[e];(t=n==null?void 0:n.bitmap)==null||t.close()}_(this,gi,Object.create(null))}*[Symbol.iterator](){for(const t in u(this,gi)){const{data:e}=u(this,gi)[t];e!==bh&&(yield[t,e])}}}gi=new WeakMap,Bd=new WeakSet,av=function(t){var e;return(e=u(this,gi))[t]||(e[t]={...Promise.withResolvers(),data:bh})};var Do;class SP{constructor(t){P(this,Do,null);_(this,Do,t),this.onContinue=null}get promise(){return u(this,Do).capability.promise}cancel(t=0){u(this,Do).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=u(this,Do).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=u(this,Do);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}Do=new WeakMap;var Fo,rl;const Ea=class Ea{constructor({callback:t,params:e,objs:n,commonObjs:s,annotationCanvasMap:o,operatorList:l,pageIndex:c,canvasFactory:d,filterFactory:f,useRequestAnimationFrame:g=!1,pdfBug:m=!1,pageColors:y=null}){P(this,Fo,null);this.callback=t,this.params=e,this.objs=n,this.commonObjs=s,this.annotationCanvasMap=o,this.operatorListIdx=null,this.operatorList=l,this._pageIndex=c,this.canvasFactory=d,this.filterFactory=f,this._pdfBug=m,this.pageColors=y,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=g===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new SP(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var c,d;if(this.cancelled)return;if(this._canvas){if(u(Ea,rl).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");u(Ea,rl).add(this._canvas)}this._pdfBug&&((c=globalThis.StepperManager)!=null&&c.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:s,transform:o,background:l}=this.params;this.gfx=new Sc(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:s,transparency:t,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,(d=this.graphicsReadyCallback)==null||d.call(this)}cancel(t=null,e=0){var n;this.running=!1,this.cancelled=!0,(n=this.gfx)==null||n.endDrawing(),u(this,Fo)&&(window.cancelAnimationFrame(u(this,Fo)),_(this,Fo,null)),u(Ea,rl).delete(this._canvas),this.callback(t||new Jv(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?_(this,Fo,window.requestAnimationFrame(()=>{_(this,Fo,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),u(Ea,rl).delete(this._canvas),this.callback())))}};Fo=new WeakMap,rl=new WeakMap,P(Ea,rl,new WeakSet);let lv=Ea;const AP="4.10.38",_P="f9bea397f";function Mb(a){return Math.floor(Math.max(0,Math.min(1,a))*255).toString(16).padStart(2,"0")}function Sh(a){return Math.max(0,Math.min(255,255*a))}class Rb{static CMYK_G([t,e,n,s]){return["G",1-Math.min(1,.3*t+.59*n+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Sh(t),[t,t,t]}static G_HTML([t]){const e=Mb(t);return`#${e}${e}${e}`}static RGB_G([t,e,n]){return["G",.3*t+.59*e+.11*n]}static RGB_rgb(t){return t.map(Sh)}static RGB_HTML(t){return`#${t.map(Mb).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,n,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,n+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,n,s]){return[Sh(1-Math.min(1,t+s)),Sh(1-Math.min(1,n+s)),Sh(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,n]){const s=1-t,o=1-e,l=1-n,c=Math.min(s,o,l);return["CMYK",s,o,l,c]}}class EP{create(t,e,n=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),n||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){fe("Abstract method `_createSVG` called.")}}class sx extends EP{_createSVG(t){return document.createElementNS(or,t)}}class gA{static setupStorage(t,e,n,s,o){const l=s.getValue(e,{value:null});switch(n.name){case"textarea":if(l.value!==null&&(t.textContent=l.value),o==="print")break;t.addEventListener("input",c=>{s.setValue(e,{value:c.target.value})});break;case"input":if(n.attributes.type==="radio"||n.attributes.type==="checkbox"){if(l.value===n.attributes.xfaOn?t.setAttribute("checked",!0):l.value===n.attributes.xfaOff&&t.removeAttribute("checked"),o==="print")break;t.addEventListener("change",c=>{s.setValue(e,{value:c.target.checked?c.target.getAttribute("xfaOn"):c.target.getAttribute("xfaOff")})})}else{if(l.value!==null&&t.setAttribute("value",l.value),o==="print")break;t.addEventListener("input",c=>{s.setValue(e,{value:c.target.value})})}break;case"select":if(l.value!==null){t.setAttribute("value",l.value);for(const c of n.children)c.attributes.value===l.value?c.attributes.selected=!0:c.attributes.hasOwnProperty("selected")&&delete c.attributes.selected}t.addEventListener("input",c=>{const d=c.target.options,f=d.selectedIndex===-1?"":d[d.selectedIndex].value;s.setValue(e,{value:f})});break}}static setAttributes({html:t,element:e,storage:n=null,intent:s,linkService:o}){const{attributes:l}=e,c=t instanceof HTMLAnchorElement;l.type==="radio"&&(l.name=`${l.name}-${s}`);for(const[d,f]of Object.entries(l))if(f!=null)switch(d){case"class":f.length&&t.setAttribute(d,f.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",f);break;case"style":Object.assign(t.style,f);break;case"textContent":t.textContent=f;break;default:(!c||d!=="href"&&d!=="newWindow")&&t.setAttribute(d,f)}c&&o.addLinkAttributes(t,l.href,l.newWindow),n&&l.dataId&&this.setupStorage(t,l.dataId,e,n)}static render(t){var m,y;const e=t.annotationStorage,n=t.linkService,s=t.xfaHtml,o=t.intent||"display",l=document.createElement(s.name);s.attributes&&this.setAttributes({html:l,element:s,intent:o,linkService:n});const c=o!=="richText",d=t.div;if(d.append(l),t.viewport){const x=`matrix(${t.viewport.transform.join(",")})`;d.style.transform=x}c&&d.setAttribute("class","xfaLayer xfaFont");const f=[];if(s.children.length===0){if(s.value){const x=document.createTextNode(s.value);l.append(x),c&&Qh.shouldBuildText(s.name)&&f.push(x)}return{textDivs:f}}const g=[[s,-1,l]];for(;g.length>0;){const[x,b,A]=g.at(-1);if(b+1===x.children.length){g.pop();continue}const C=x.children[++g.at(-1)[1]];if(C===null)continue;const{name:E}=C;if(E==="#text"){const k=document.createTextNode(C.value);f.push(k),A.append(k);continue}const N=(m=C==null?void 0:C.attributes)!=null&&m.xmlns?document.createElementNS(C.attributes.xmlns,E):document.createElement(E);if(A.append(N),C.attributes&&this.setAttributes({html:N,element:C,storage:e,intent:o,linkService:n}),((y=C.children)==null?void 0:y.length)>0)g.push([C,-1,N]);else if(C.value){const k=document.createTextNode(C.value);c&&Qh.shouldBuildText(E)&&f.push(k),N.append(k)}}for(const x of d.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))x.setAttribute("readOnly",!0);return{textDivs:f}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Tf=1e3,kP=9,Il=new WeakSet;function Ko(a){return{width:a[2]-a[0],height:a[3]-a[1]}}class CP{static create(t){switch(t.data.annotationType){case Ye.LINK:return new mA(t);case Ye.TEXT:return new TP(t);case Ye.WIDGET:switch(t.data.fieldType){case"Tx":return new PP(t);case"Btn":return t.data.radioButton?new xA(t):t.data.checkBox?new RP(t):new NP(t);case"Ch":return new LP(t);case"Sig":return new MP(t)}return new Ol(t);case Ye.POPUP:return new uv(t);case Ye.FREETEXT:return new _A(t);case Ye.LINE:return new DP(t);case Ye.SQUARE:return new FP(t);case Ye.CIRCLE:return new OP(t);case Ye.POLYLINE:return new EA(t);case Ye.CARET:return new $P(t);case Ye.INK:return new rx(t);case Ye.POLYGON:return new jP(t);case Ye.HIGHLIGHT:return new kA(t);case Ye.UNDERLINE:return new zP(t);case Ye.SQUIGGLY:return new HP(t);case Ye.STRIKEOUT:return new BP(t);case Ye.STAMP:return new CA(t);case Ye.FILEATTACHMENT:return new UP(t);default:return new je(t)}}}var ol,Zc,tu,Ud,cv;const px=class px{constructor(t,{isRenderable:e=!1,ignoreBorder:n=!1,createQuadrilaterals:s=!1}={}){P(this,Ud);P(this,ol,null);P(this,Zc,!1);P(this,tu,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(n)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:n}){return!!(t!=null&&t.str||e!=null&&e.str||n!=null&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return px._hasPopupData(this.data)}updateEdited(t){var n;if(!this.container)return;u(this,ol)||_(this,ol,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&M(this,Ud,cv).call(this,e),(n=u(this,tu))==null||n.popup.updateEdited(t)}resetEdited(){var t;u(this,ol)&&(M(this,Ud,cv).call(this,u(this,ol).rect),(t=u(this,tu))==null||t.popup.resetEdited(),_(this,ol,null))}_createContainer(t){const{data:e,parent:{page:n,viewport:s}}=this,o=document.createElement("section");o.setAttribute("data-annotation-id",e.id),this instanceof Ol||(o.tabIndex=Tf);const{style:l}=o;if(l.zIndex=this.parent.zIndex++,e.alternativeText&&(o.title=e.alternativeText),e.noRotate&&o.classList.add("norotate"),!e.rect||this instanceof uv){const{rotation:A}=e;return!e.hasOwnCanvas&&A!==0&&this.setRotation(A,o),o}const{width:c,height:d}=Ko(e.rect);if(!t&&e.borderStyle.width>0){l.borderWidth=`${e.borderStyle.width}px`;const A=e.borderStyle.horizontalCornerRadius,C=e.borderStyle.verticalCornerRadius;if(A>0||C>0){const N=`calc(${A}px * var(--scale-factor)) / calc(${C}px * var(--scale-factor))`;l.borderRadius=N}else if(this instanceof xA){const N=`calc(${c}px * var(--scale-factor)) / calc(${d}px * var(--scale-factor))`;l.borderRadius=N}switch(e.borderStyle.style){case xh.SOLID:l.borderStyle="solid";break;case xh.DASHED:l.borderStyle="dashed";break;case xh.BEVELED:Ut("Unimplemented border style: beveled");break;case xh.INSET:Ut("Unimplemented border style: inset");break;case xh.UNDERLINE:l.borderBottomStyle="solid";break}const E=e.borderColor||null;E?(_(this,Zc,!0),l.borderColor=Pt.makeHexColor(E[0]|0,E[1]|0,E[2]|0)):l.borderWidth=0}const f=Pt.normalizeRect([e.rect[0],n.view[3]-e.rect[1]+n.view[1],e.rect[2],n.view[3]-e.rect[3]+n.view[1]]),{pageWidth:g,pageHeight:m,pageX:y,pageY:x}=s.rawDims;l.left=`${100*(f[0]-y)/g}%`,l.top=`${100*(f[1]-x)/m}%`;const{rotation:b}=e;return e.hasOwnCanvas||b===0?(l.width=`${100*c/g}%`,l.height=`${100*d/m}%`):this.setRotation(b,o),o}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:s}=this.parent.viewport.rawDims,{width:o,height:l}=Ko(this.data.rect);let c,d;t%180===0?(c=100*o/n,d=100*l/s):(c=100*l/n,d=100*o/s),e.style.width=`${c}%`,e.style.height=`${d}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,n,s)=>{const o=s.detail[e],l=o[0],c=o.slice(1);s.target.style[n]=Rb[`${l}_HTML`](c),this.annotationStorage.setValue(this.data.id,{[n]:Rb[`${l}_rgb`](c)})};return Kt(this,"_commonActions",{display:e=>{const{display:n}=e.detail,s=n%2===1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:n===1||n===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:n}=e.detail;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:n,noView:n})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const n=e.detail.rotation;this.setRotation(n),this.annotationStorage.setValue(this.data.id,{rotation:n})}})}_dispatchEventFromSandbox(t,e){const n=this._commonActions;for(const s of Object.keys(e.detail)){const o=t[s]||n[s];o==null||o(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const n=this._commonActions;for(const[s,o]of Object.entries(e)){const l=n[s];if(l){const c={detail:{[s]:o},target:t};l(c),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,n,s,o]=this.data.rect.map(A=>Math.fround(A));if(t.length===8){const[A,C,E,N]=t.subarray(2,6);if(s===A&&o===C&&e===E&&n===N)return}const{style:l}=this.container;let c;if(u(this,Zc)){const{borderColor:A,borderWidth:C}=l;l.borderWidth=0,c=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${A}" stroke-width="${C}">`],this.container.classList.add("hasBorder")}const d=s-e,f=o-n,{svgFactory:g}=this,m=g.createElement("svg");m.classList.add("quadrilateralsContainer"),m.setAttribute("width",0),m.setAttribute("height",0);const y=g.createElement("defs");m.append(y);const x=g.createElement("clipPath"),b=`clippath_${this.data.id}`;x.setAttribute("id",b),x.setAttribute("clipPathUnits","objectBoundingBox"),y.append(x);for(let A=2,C=t.length;A<C;A+=8){const E=t[A],N=t[A+1],k=t[A+2],L=t[A+3],R=g.createElement("rect"),j=(k-e)/d,O=(o-N)/f,H=(E-k)/d,X=(N-L)/f;R.setAttribute("x",j),R.setAttribute("y",O),R.setAttribute("width",H),R.setAttribute("height",X),x.append(R),c==null||c.push(`<rect vector-effect="non-scaling-stroke" x="${j}" y="${O}" width="${H}" height="${X}"/>`)}u(this,Zc)&&(c.push("</g></svg>')"),l.backgroundImage=c.join("")),this.container.append(m),this.container.style.clipPath=`url(#${b})`}_createPopup(){const{data:t}=this,e=_(this,tu,new uv({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){fe("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const n=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:o,id:l,exportValues:c}of s){if(o===-1||l===e)continue;const d=typeof c=="string"?c:null,f=document.querySelector(`[data-element-id="${l}"]`);if(f&&!Il.has(f)){Ut(`_getElementsByName - element not allowed: ${l}`);continue}n.push({id:l,exportValue:d,domElement:f})}return n}for(const s of document.getElementsByName(t)){const{exportValue:o}=s,l=s.getAttribute("data-element-id");l!==e&&Il.has(s)&&n.push({id:l,exportValue:o,domElement:s})}return n}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var n;(n=this.linkService.eventBus)==null||n.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}};ol=new WeakMap,Zc=new WeakMap,tu=new WeakMap,Ud=new WeakSet,cv=function(t){const{container:{style:e},data:{rect:n,rotation:s},parent:{viewport:{rawDims:{pageWidth:o,pageHeight:l,pageX:c,pageY:d}}}}=this;n==null||n.splice(0,4,...t);const{width:f,height:g}=Ko(t);e.left=`${100*(t[0]-c)/o}%`,e.top=`${100*(l-t[3]+d)/l}%`,s===0?(e.width=`${100*f/o}%`,e.height=`${100*g/l}%`):this.setRotation(s)};let je=px;var Ei,ba,yA,vA;class mA extends je{constructor(e,n=null){super(e,{isRenderable:!0,ignoreBorder:!!(n!=null&&n.ignoreBorder),createQuadrilaterals:!0});P(this,Ei);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:n}=this,s=document.createElement("a");s.setAttribute("data-element-id",e.id);let o=!1;return e.url?(n.addLinkAttributes(s,e.url,e.newWindow),o=!0):e.action?(this._bindNamedAction(s,e.action),o=!0):e.attachment?(M(this,Ei,yA).call(this,s,e.attachment,e.attachmentDest),o=!0):e.setOCGState?(M(this,Ei,vA).call(this,s,e.setOCGState),o=!0):e.dest?(this._bindLink(s,e.dest),o=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,e),o=!0),e.resetForm?(this._bindResetFormAction(s,e.resetForm),o=!0):this.isTooltipOnly&&!o&&(this._bindLink(s,""),o=!0)),this.container.classList.add("linkAnnotation"),o&&this.container.append(s),this.container}_bindLink(e,n){e.href=this.linkService.getDestinationHash(n),e.onclick=()=>(n&&this.linkService.goToDestination(n),!1),(n||n==="")&&M(this,Ei,ba).call(this)}_bindNamedAction(e,n){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(n),!1),M(this,Ei,ba).call(this)}_bindJSAction(e,n){e.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const o of Object.keys(n.actions)){const l=s.get(o);l&&(e[l]=()=>{var c;return(c=this.linkService.eventBus)==null||c.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n.id,name:o}}),!1})}e.onclick||(e.onclick=()=>!1),M(this,Ei,ba).call(this)}_bindResetFormAction(e,n){const s=e.onclick;if(s||(e.href=this.linkService.getAnchorUrl("")),M(this,Ei,ba).call(this),!this._fieldObjects){Ut('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(e.onclick=()=>!1);return}e.onclick=()=>{var m;s==null||s();const{fields:o,refs:l,include:c}=n,d=[];if(o.length!==0||l.length!==0){const y=new Set(l);for(const x of o){const b=this._fieldObjects[x]||[];for(const{id:A}of b)y.add(A)}for(const x of Object.values(this._fieldObjects))for(const b of x)y.has(b.id)===c&&d.push(b)}else for(const y of Object.values(this._fieldObjects))d.push(...y);const f=this.annotationStorage,g=[];for(const y of d){const{id:x}=y;switch(g.push(x),y.type){case"text":{const A=y.defaultValue||"";f.setValue(x,{value:A});break}case"checkbox":case"radiobutton":{const A=y.defaultValue===y.exportValues;f.setValue(x,{value:A});break}case"combobox":case"listbox":{const A=y.defaultValue||"";f.setValue(x,{value:A});break}default:continue}const b=document.querySelector(`[data-element-id="${x}"]`);if(b){if(!Il.has(b)){Ut(`_bindResetFormAction - element not allowed: ${x}`);continue}}else continue;b.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((m=this.linkService.eventBus)==null||m.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}})),!1}}}Ei=new WeakSet,ba=function(){this.container.setAttribute("data-internal-link","")},yA=function(e,n,s=null){e.href=this.linkService.getAnchorUrl(""),n.description&&(e.title=n.description),e.onclick=()=>{var o;return(o=this.downloadManager)==null||o.openOrDownloadData(n.content,n.filename,s),!1},M(this,Ei,ba).call(this)},vA=function(e,n){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(n),!1),M(this,Ei,ba).call(this)};class TP extends je{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ol extends je{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Wn.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,n,s,o){n.includes("mouse")?t.addEventListener(n,l=>{var c;(c=this.linkService.eventBus)==null||c.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:o(l),shift:l.shiftKey,modifier:this._getKeyModifier(l)}})}):t.addEventListener(n,l=>{var c;if(n==="blur"){if(!e.focused||!l.relatedTarget)return;e.focused=!1}else if(n==="focus"){if(e.focused)return;e.focused=!0}o&&((c=this.linkService.eventBus)==null||c.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:o(l)}}))})}_setEventListeners(t,e,n,s){var o,l,c;for(const[d,f]of n)(f==="Action"||(o=this.data.actions)!=null&&o[f])&&((f==="Focus"||f==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,d,f,s),f==="Focus"&&!((l=this.data.actions)!=null&&l.Blur)?this._setEventListener(t,e,"blur","Blur",null):f==="Blur"&&!((c=this.data.actions)!=null&&c.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":Pt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||kP,o=t.style;let l;const c=2,d=f=>Math.round(10*f)/10;if(this.data.multiLine){const f=Math.abs(this.data.rect[3]-this.data.rect[1]-c),g=Math.round(f/(cy*s))||1,m=f/g;l=Math.min(s,d(m/cy))}else{const f=Math.abs(this.data.rect[3]-this.data.rect[1]-c);l=Math.min(s,d(f/cy))}o.fontSize=`calc(${l}px * var(--scale-factor))`,o.color=Pt.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(o.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class PP extends Ol{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,n,s){const o=this.annotationStorage;for(const l of this._getElementsByName(t.name,t.id))l.domElement&&(l.domElement[e]=n),o.setValue(l.id,{[s]:n})}render(){var s,o;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const l=t.getValue(e,{value:this.data.fieldValue});let c=l.value||"";const d=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;d&&c.length>d&&(c=c.slice(0,d));let f=l.formattedValue||((s=this.data.textContent)==null?void 0:s.join(`
69
+ `))||null;f&&this.data.comb&&(f=f.replaceAll(/\s+/g,""));const g={userValue:c,formattedValue:f,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=f??c,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",f??c),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),Il.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=Tf,this._setRequired(n,this.data.required),d&&(n.maxLength=d),n.addEventListener("input",y=>{t.setValue(e,{value:y.target.value}),this.setPropertyOnSiblings(n,"value",y.target.value,"value"),g.formattedValue=null}),n.addEventListener("resetform",y=>{const x=this.data.defaultFieldValue??"";n.value=g.userValue=x,g.formattedValue=null});let m=y=>{const{formattedValue:x}=g;x!=null&&(y.target.value=x),y.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",x=>{var A;if(g.focused)return;const{target:b}=x;g.userValue&&(b.value=g.userValue),g.lastCommittedValue=b.value,g.commitKey=1,(A=this.data.actions)!=null&&A.Focus||(g.focused=!0)}),n.addEventListener("updatefromsandbox",x=>{this.showElementAndHideCanvas(x.target);const b={value(A){g.userValue=A.detail.value??"",t.setValue(e,{value:g.userValue.toString()}),A.target.value=g.userValue},formattedValue(A){const{formattedValue:C}=A.detail;g.formattedValue=C,C!=null&&A.target!==document.activeElement&&(A.target.value=C),t.setValue(e,{formattedValue:C})},selRange(A){A.target.setSelectionRange(...A.detail.selRange)},charLimit:A=>{var k;const{charLimit:C}=A.detail,{target:E}=A;if(C===0){E.removeAttribute("maxLength");return}E.setAttribute("maxLength",C);let N=g.userValue;!N||N.length<=C||(N=N.slice(0,C),E.value=g.userValue=N,t.setValue(e,{value:N}),(k=this.linkService.eventBus)==null||k.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:N,willCommit:!0,commitKey:1,selStart:E.selectionStart,selEnd:E.selectionEnd}}))}};this._dispatchEventFromSandbox(b,x)}),n.addEventListener("keydown",x=>{var C;g.commitKey=1;let b=-1;if(x.key==="Escape"?b=0:x.key==="Enter"&&!this.data.multiLine?b=2:x.key==="Tab"&&(g.commitKey=3),b===-1)return;const{value:A}=x.target;g.lastCommittedValue!==A&&(g.lastCommittedValue=A,g.userValue=A,(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:b,selStart:x.target.selectionStart,selEnd:x.target.selectionEnd}}))});const y=m;m=null,n.addEventListener("blur",x=>{var A,C;if(!g.focused||!x.relatedTarget)return;(A=this.data.actions)!=null&&A.Blur||(g.focused=!1);const{value:b}=x.target;g.userValue=b,g.lastCommittedValue!==b&&((C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:g.commitKey,selStart:x.target.selectionStart,selEnd:x.target.selectionEnd}})),y(x)}),(o=this.data.actions)!=null&&o.Keystroke&&n.addEventListener("beforeinput",x=>{var R;g.lastCommittedValue=null;const{data:b,target:A}=x,{value:C,selectionStart:E,selectionEnd:N}=A;let k=E,L=N;switch(x.inputType){case"deleteWordBackward":{const j=C.substring(0,E).match(/\w*[^\w]*$/);j&&(k-=j[0].length);break}case"deleteWordForward":{const j=C.substring(E).match(/^[^\w]*\w*/);j&&(L+=j[0].length);break}case"deleteContentBackward":E===N&&(k-=1);break;case"deleteContentForward":E===N&&(L+=1);break}x.preventDefault(),(R=this.linkService.eventBus)==null||R.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:C,change:b||"",willCommit:!1,selStart:k,selEnd:L}})}),this._setEventListeners(n,g,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],x=>x.target.value)}if(m&&n.addEventListener("blur",m),this.data.comb){const x=(this.data.rect[2]-this.data.rect[0])/d;n.classList.add("comb"),n.style.letterSpacing=`calc(${x}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class MP extends Ol{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class RP extends Ol{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,n=e.id;let s=t.getValue(n,{value:e.exportValue===e.fieldValue}).value;typeof s=="string"&&(s=s!=="Off",t.setValue(n,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const o=document.createElement("input");return Il.add(o),o.setAttribute("data-element-id",n),o.disabled=e.readOnly,this._setRequired(o,this.data.required),o.type="checkbox",o.name=e.fieldName,s&&o.setAttribute("checked",!0),o.setAttribute("exportValue",e.exportValue),o.tabIndex=Tf,o.addEventListener("change",l=>{const{name:c,checked:d}=l.target;for(const f of this._getElementsByName(c,n)){const g=d&&f.exportValue===e.exportValue;f.domElement&&(f.domElement.checked=g),t.setValue(f.id,{value:g})}t.setValue(n,{value:d})}),o.addEventListener("resetform",l=>{const c=e.defaultFieldValue||"Off";l.target.checked=c===e.exportValue}),this.enableScripting&&this.hasJSActions&&(o.addEventListener("updatefromsandbox",l=>{const c={value(d){d.target.checked=d.detail.value!=="Off",t.setValue(n,{value:d.target.checked})}};this._dispatchEventFromSandbox(c,l)}),this._setEventListeners(o,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],l=>l.target.checked)),this._setBackgroundColor(o),this._setDefaultPropertiesFromJS(o),this.container.append(o),this.container}}class xA extends Ol{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,n=e.id;let s=t.getValue(n,{value:e.fieldValue===e.buttonValue}).value;if(typeof s=="string"&&(s=s!==e.buttonValue,t.setValue(n,{value:s})),s)for(const l of this._getElementsByName(e.fieldName,n))t.setValue(l.id,{value:!1});const o=document.createElement("input");if(Il.add(o),o.setAttribute("data-element-id",n),o.disabled=e.readOnly,this._setRequired(o,this.data.required),o.type="radio",o.name=e.fieldName,s&&o.setAttribute("checked",!0),o.tabIndex=Tf,o.addEventListener("change",l=>{const{name:c,checked:d}=l.target;for(const f of this._getElementsByName(c,n))t.setValue(f.id,{value:!1});t.setValue(n,{value:d})}),o.addEventListener("resetform",l=>{const c=e.defaultFieldValue;l.target.checked=c!=null&&c===e.buttonValue}),this.enableScripting&&this.hasJSActions){const l=e.buttonValue;o.addEventListener("updatefromsandbox",c=>{const d={value:f=>{const g=l===f.detail.value;for(const m of this._getElementsByName(f.target.name)){const y=g&&m.id===n;m.domElement&&(m.domElement.checked=y),t.setValue(m.id,{value:y})}}};this._dispatchEventFromSandbox(d,c)}),this._setEventListeners(o,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],c=>c.target.checked)}return this._setBackgroundColor(o),this._setDefaultPropertiesFromJS(o),this.container.append(o),this.container}}class NP extends mA{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({},n)})),t}}class LP extends Ol{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,n=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Il.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Tf;let o=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",g=>{const m=this.data.defaultFieldValue;for(const y of s.options)y.selected=y.value===m});for(const g of this.data.options){const m=document.createElement("option");m.textContent=g.displayValue,m.value=g.exportValue,n.value.includes(g.exportValue)&&(m.setAttribute("selected",!0),o=!1),s.append(m)}let l=null;if(o){const g=document.createElement("option");g.value=" ",g.setAttribute("hidden",!0),g.setAttribute("selected",!0),s.prepend(g),l=()=>{g.remove(),s.removeEventListener("input",l),l=null},s.addEventListener("input",l)}const c=g=>{const m=g?"value":"textContent",{options:y,multiple:x}=s;return x?Array.prototype.filter.call(y,b=>b.selected).map(b=>b[m]):y.selectedIndex===-1?null:y[y.selectedIndex][m]};let d=c(!1);const f=g=>{const m=g.target.options;return Array.prototype.map.call(m,y=>({displayValue:y.textContent,exportValue:y.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",g=>{const m={value(y){l==null||l();const x=y.detail.value,b=new Set(Array.isArray(x)?x:[x]);for(const A of s.options)A.selected=b.has(A.value);t.setValue(e,{value:c(!0)}),d=c(!1)},multipleSelection(y){s.multiple=!0},remove(y){const x=s.options,b=y.detail.remove;x[b].selected=!1,s.remove(b),x.length>0&&Array.prototype.findIndex.call(x,C=>C.selected)===-1&&(x[0].selected=!0),t.setValue(e,{value:c(!0),items:f(y)}),d=c(!1)},clear(y){for(;s.length!==0;)s.remove(0);t.setValue(e,{value:null,items:[]}),d=c(!1)},insert(y){const{index:x,displayValue:b,exportValue:A}=y.detail.insert,C=s.children[x],E=document.createElement("option");E.textContent=b,E.value=A,C?C.before(E):s.append(E),t.setValue(e,{value:c(!0),items:f(y)}),d=c(!1)},items(y){const{items:x}=y.detail;for(;s.length!==0;)s.remove(0);for(const b of x){const{displayValue:A,exportValue:C}=b,E=document.createElement("option");E.textContent=A,E.value=C,s.append(E)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:c(!0),items:f(y)}),d=c(!1)},indices(y){const x=new Set(y.detail.indices);for(const b of y.target.options)b.selected=x.has(b.index);t.setValue(e,{value:c(!0)}),d=c(!1)},editable(y){y.target.disabled=!y.detail.editable}};this._dispatchEventFromSandbox(m,g)}),s.addEventListener("input",g=>{var x;const m=c(!0),y=c(!1);t.setValue(e,{value:m}),g.preventDefault(),(x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:d,change:y,changeEx:m,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],g=>g.target.value)):s.addEventListener("input",function(g){t.setValue(e,{value:c(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class uv extends je{constructor(t){const{data:e,elements:n}=t;super(t,{isRenderable:je._hasPopupData(e)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new IP({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const n of this.elements)n.popup=t,n.container.ariaHasPopup="dialog",e.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(n=>`${Qv}${n}`).join(",")),this.container}}var eu,em,nm,nu,al,Le,Er,iu,Vd,Wd,su,kr,us,Cr,Gd,Tr,Xd,ll,cl,de,hg,hv,wA,bA,SA,AA,dg,fg,dv;class IP{constructor({container:t,color:e,elements:n,titleObj:s,modificationDate:o,contentsObj:l,richText:c,parent:d,rect:f,parentRect:g,open:m}){P(this,de);P(this,eu,M(this,de,SA).bind(this));P(this,em,M(this,de,dv).bind(this));P(this,nm,M(this,de,fg).bind(this));P(this,nu,M(this,de,dg).bind(this));P(this,al,null);P(this,Le,null);P(this,Er,null);P(this,iu,null);P(this,Vd,null);P(this,Wd,null);P(this,su,null);P(this,kr,!1);P(this,us,null);P(this,Cr,null);P(this,Gd,null);P(this,Tr,null);P(this,Xd,null);P(this,ll,null);P(this,cl,!1);var y;_(this,Le,t),_(this,Xd,s),_(this,Er,l),_(this,Tr,c),_(this,Wd,d),_(this,al,e),_(this,Gd,f),_(this,su,g),_(this,Vd,n),_(this,iu,tx.toDateObject(o)),this.trigger=n.flatMap(x=>x.getElementsToTriggerPopup());for(const x of this.trigger)x.addEventListener("click",u(this,nu)),x.addEventListener("mouseenter",u(this,nm)),x.addEventListener("mouseleave",u(this,em)),x.classList.add("popupTriggerArea");for(const x of n)(y=x.container)==null||y.addEventListener("keydown",u(this,eu));u(this,Le).hidden=!0,m&&M(this,de,dg).call(this)}render(){if(u(this,us))return;const t=_(this,us,document.createElement("div"));if(t.className="popup",u(this,al)){const o=t.style.outlineColor=Pt.makeHexColor(...u(this,al));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${o} 30%, white)`:t.style.backgroundColor=Pt.makeHexColor(...u(this,al).map(c=>Math.floor(.7*(255-c)+c)))}const e=document.createElement("span");e.className="header";const n=document.createElement("h1");if(e.append(n),{dir:n.dir,str:n.textContent}=u(this,Xd),t.append(e),u(this,iu)){const o=document.createElement("span");o.classList.add("popupDate"),o.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),o.setAttribute("data-l10n-args",JSON.stringify({dateObj:u(this,iu).valueOf()})),e.append(o)}const s=u(this,de,hg);if(s)gA.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const o=this._formatContents(u(this,Er));t.append(o)}u(this,Le).append(t)}_formatContents({str:t,dir:e}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let o=0,l=s.length;o<l;++o){const c=s[o];n.append(document.createTextNode(c)),o<l-1&&n.append(document.createElement("br"))}return n}updateEdited({rect:t,popupContent:e}){var n;u(this,ll)||_(this,ll,{contentsObj:u(this,Er),richText:u(this,Tr)}),t&&_(this,Cr,null),e&&(_(this,Tr,M(this,de,bA).call(this,e)),_(this,Er,null)),(n=u(this,us))==null||n.remove(),_(this,us,null)}resetEdited(){var t;u(this,ll)&&({contentsObj:$n(this,Er)._,richText:$n(this,Tr)._}=u(this,ll),_(this,ll,null),(t=u(this,us))==null||t.remove(),_(this,us,null),_(this,Cr,null))}forceHide(){_(this,cl,this.isVisible),u(this,cl)&&(u(this,Le).hidden=!0)}maybeShow(){u(this,cl)&&(u(this,us)||M(this,de,fg).call(this),_(this,cl,!1),u(this,Le).hidden=!1)}get isVisible(){return u(this,Le).hidden===!1}}eu=new WeakMap,em=new WeakMap,nm=new WeakMap,nu=new WeakMap,al=new WeakMap,Le=new WeakMap,Er=new WeakMap,iu=new WeakMap,Vd=new WeakMap,Wd=new WeakMap,su=new WeakMap,kr=new WeakMap,us=new WeakMap,Cr=new WeakMap,Gd=new WeakMap,Tr=new WeakMap,Xd=new WeakMap,ll=new WeakMap,cl=new WeakMap,de=new WeakSet,hg=function(){const t=u(this,Tr),e=u(this,Er);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&u(this,Tr).html||null},hv=function(){var t,e,n;return((n=(e=(t=u(this,de,hg))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:n.fontSize)||0},wA=function(){var t,e,n;return((n=(e=(t=u(this,de,hg))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:n.color)||null},bA=function(t){const e=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:u(this,de,wA),fontSize:u(this,de,hv)?`calc(${u(this,de,hv)}px * var(--scale-factor))`:""}};for(const o of t.split(`
70
+ `))e.push({name:"span",value:o,attributes:s});return n},SA=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&u(this,kr))&&M(this,de,dg).call(this)},AA=function(){if(u(this,Cr)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:s,pageY:o}}}=u(this,Wd);let l=!!u(this,su),c=l?u(this,su):u(this,Gd);for(const b of u(this,Vd))if(!c||Pt.intersect(b.data.rect,c)!==null){c=b.data.rect,l=!0;break}const d=Pt.normalizeRect([c[0],t[3]-c[1]+t[1],c[2],t[3]-c[3]+t[1]]),g=l?c[2]-c[0]+5:0,m=d[0]+g,y=d[1];_(this,Cr,[100*(m-s)/e,100*(y-o)/n]);const{style:x}=u(this,Le);x.left=`${u(this,Cr)[0]}%`,x.top=`${u(this,Cr)[1]}%`},dg=function(){_(this,kr,!u(this,kr)),u(this,kr)?(M(this,de,fg).call(this),u(this,Le).addEventListener("click",u(this,nu)),u(this,Le).addEventListener("keydown",u(this,eu))):(M(this,de,dv).call(this),u(this,Le).removeEventListener("click",u(this,nu)),u(this,Le).removeEventListener("keydown",u(this,eu)))},fg=function(){u(this,us)||this.render(),this.isVisible?u(this,kr)&&u(this,Le).classList.add("focused"):(M(this,de,AA).call(this),u(this,Le).hidden=!1,u(this,Le).style.zIndex=parseInt(u(this,Le).style.zIndex)+1e3)},dv=function(){u(this,Le).classList.remove("focused"),!(u(this,kr)||!this.isVisible)&&(u(this,Le).hidden=!0,u(this,Le).style.zIndex=parseInt(u(this,Le).style.zIndex)-1e3)};class _A extends je{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Bt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const n=document.createElement("span");n.textContent=e,t.append(n)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var qd;class DP extends je{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});P(this,qd,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:n,height:s}=Ko(e.rect),o=this.svgFactory.create(n,s,!0),l=_(this,qd,this.svgFactory.createElement("svg:line"));return l.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),l.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),l.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),l.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),l.setAttribute("stroke-width",e.borderStyle.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),o.append(l),this.container.append(o),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return u(this,qd)}addHighlightArea(){this.container.classList.add("highlightArea")}}qd=new WeakMap;var Yd;class FP extends je{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});P(this,Yd,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:n,height:s}=Ko(e.rect),o=this.svgFactory.create(n,s,!0),l=e.borderStyle.width,c=_(this,Yd,this.svgFactory.createElement("svg:rect"));return c.setAttribute("x",l/2),c.setAttribute("y",l/2),c.setAttribute("width",n-l),c.setAttribute("height",s-l),c.setAttribute("stroke-width",l||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),o.append(c),this.container.append(o),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return u(this,Yd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Yd=new WeakMap;var Kd;class OP extends je{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});P(this,Kd,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:n,height:s}=Ko(e.rect),o=this.svgFactory.create(n,s,!0),l=e.borderStyle.width,c=_(this,Kd,this.svgFactory.createElement("svg:ellipse"));return c.setAttribute("cx",n/2),c.setAttribute("cy",s/2),c.setAttribute("rx",n/2-l/2),c.setAttribute("ry",s/2-l/2),c.setAttribute("stroke-width",l||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),o.append(c),this.container.append(o),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return u(this,Kd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Kd=new WeakMap;var Qd;class EA extends je{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});P(this,Qd,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:n,borderStyle:s,popupRef:o}}=this;if(!n)return this.container;const{width:l,height:c}=Ko(e),d=this.svgFactory.create(l,c,!0);let f=[];for(let m=0,y=n.length;m<y;m+=2){const x=n[m]-e[0],b=e[3]-n[m+1];f.push(`${x},${b}`)}f=f.join(" ");const g=_(this,Qd,this.svgFactory.createElement(this.svgElementName));return g.setAttribute("points",f),g.setAttribute("stroke-width",s.width||1),g.setAttribute("stroke","transparent"),g.setAttribute("fill","transparent"),d.append(g),this.container.append(d),!o&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return u(this,Qd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Qd=new WeakMap;class jP extends EA{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class $P extends je{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var Jd,ul,Zd,fv;class rx extends je{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});P(this,Zd);P(this,Jd,null);P(this,ul,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Bt.HIGHLIGHT:Bt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:n,inkLists:s,borderStyle:o,popupRef:l}}=this,{transform:c,width:d,height:f}=M(this,Zd,fv).call(this,n,e),g=this.svgFactory.create(d,f,!0),m=_(this,Jd,this.svgFactory.createElement("svg:g"));g.append(m),m.setAttribute("stroke-width",o.width||1),m.setAttribute("stroke-linecap","round"),m.setAttribute("stroke-linejoin","round"),m.setAttribute("stroke-miterlimit",10),m.setAttribute("stroke","transparent"),m.setAttribute("fill","transparent"),m.setAttribute("transform",c);for(let y=0,x=s.length;y<x;y++){const b=this.svgFactory.createElement(this.svgElementName);u(this,ul).push(b),b.setAttribute("points",s[y].join(",")),m.append(b)}return!l&&this.hasPopupData&&this._createPopup(),this.container.append(g),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:n,points:s,rect:o}=e,l=u(this,Jd);if(n>=0&&l.setAttribute("stroke-width",n||1),s)for(let c=0,d=u(this,ul).length;c<d;c++)u(this,ul)[c].setAttribute("points",s[c].join(","));if(o){const{transform:c,width:d,height:f}=M(this,Zd,fv).call(this,this.data.rotation,o);l.parentElement.setAttribute("viewBox",`0 0 ${d} ${f}`),l.setAttribute("transform",c)}}getElementsToTriggerPopup(){return u(this,ul)}addHighlightArea(){this.container.classList.add("highlightArea")}}Jd=new WeakMap,ul=new WeakMap,Zd=new WeakSet,fv=function(e,n){switch(e){case 90:return{transform:`rotate(90) translate(${-n[0]},${n[1]}) scale(1,-1)`,width:n[3]-n[1],height:n[2]-n[0]};case 180:return{transform:`rotate(180) translate(${-n[2]},${n[1]}) scale(1,-1)`,width:n[2]-n[0],height:n[3]-n[1]};case 270:return{transform:`rotate(270) translate(${-n[2]},${n[3]}) scale(1,-1)`,width:n[3]-n[1],height:n[2]-n[0]};default:return{transform:`translate(${-n[0]},${n[3]}) scale(1,-1)`,width:n[2]-n[0],height:n[3]-n[1]}}};class kA extends je{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Bt.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class zP extends je{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class HP extends je{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class BP extends je{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class CA extends je{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Bt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var tf,ef,pv;class UP extends je{constructor(e){var s;super(e,{isRenderable:!0});P(this,ef);P(this,tf,null);const{file:n}=this.data;this.filename=n.filename,this.content=n.content,(s=this.linkService.eventBus)==null||s.dispatch("fileattachmentannotation",{source:this,...n})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:n}=this;let s;n.hasAppearance||n.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(n.name)?"paperclip":"pushpin"}.svg`,n.fillAlpha&&n.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(n.fillAlpha*100)}%);`)),s.addEventListener("dblclick",M(this,ef,pv).bind(this)),_(this,tf,s);const{isMac:o}=Wn.platform;return e.addEventListener("keydown",l=>{l.key==="Enter"&&(o?l.metaKey:l.ctrlKey)&&M(this,ef,pv).call(this)}),!n.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),e.append(s),e}getElementsToTriggerPopup(){return u(this,tf)}addHighlightArea(){this.container.classList.add("highlightArea")}}tf=new WeakMap,ef=new WeakSet,pv=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var nf,hl,dl,sf,Dl,TA,gv;class VP{constructor({div:t,accessibilityManager:e,annotationCanvasMap:n,annotationEditorUIManager:s,page:o,viewport:l,structTreeLayer:c}){P(this,Dl);P(this,nf,null);P(this,hl,null);P(this,dl,new Map);P(this,sf,null);this.div=t,_(this,nf,e),_(this,hl,n),_(this,sf,c||null),this.page=o,this.viewport=l,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return u(this,dl).size>0}async render(t){var l;const{annotations:e}=t,n=this.div;Nl(n,this.viewport);const s=new Map,o={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new sx,annotationStorage:t.annotationStorage||new nx,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const c of e){if(c.noHTML)continue;const d=c.annotationType===Ye.POPUP;if(d){const m=s.get(c.id);if(!m)continue;o.elements=m}else{const{width:m,height:y}=Ko(c.rect);if(m<=0||y<=0)continue}o.data=c;const f=CP.create(o);if(!f.isRenderable)continue;if(!d&&c.popupRef){const m=s.get(c.popupRef);m?m.push(f):s.set(c.popupRef,[f])}const g=f.render();c.hidden&&(g.style.visibility="hidden"),await M(this,Dl,TA).call(this,g,c.id),f._isEditable&&(u(this,dl).set(f.data.id,f),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(f))}M(this,Dl,gv).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,Nl(e,{rotation:t.rotation}),M(this,Dl,gv).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(u(this,dl).values())}getEditableAnnotation(t){return u(this,dl).get(t)}}nf=new WeakMap,hl=new WeakMap,dl=new WeakMap,sf=new WeakMap,Dl=new WeakSet,TA=async function(t,e){var l,c;const n=t.firstChild||t,s=n.id=`${Qv}${e}`,o=await((l=u(this,sf))==null?void 0:l.getAriaAttributes(s));if(o)for(const[d,f]of o)n.setAttribute(d,f);this.div.append(t),(c=u(this,nf))==null||c.moveElementInDOM(this.div,t,n,!1)},gv=function(){if(!u(this,hl))return;const t=this.div;for(const[e,n]of u(this,hl)){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;n.className="annotationContent";const{firstChild:o}=s;o?o.nodeName==="CANVAS"?o.replaceWith(n):o.classList.contains("annotationContent")?o.after(n):o.before(n):s.append(n)}u(this,hl).clear()};const Vp=/\r\n?|\n/g;var hs,mi,rf,fl,yi,We,PA,MA,RA,pg,$r,gg,mg,NA,yv,LA;const me=class me extends Re{constructor(e){super({...e,name:"freeTextEditor"});P(this,We);P(this,hs);P(this,mi,"");P(this,rf,`${this.id}-editor`);P(this,fl,null);P(this,yi);_(this,hs,e.color||me._defaultColor||Re._defaultLineColor),_(this,yi,e.fontSize||me._defaultFontSize)}static get _keyboardManager(){const e=me.prototype,n=l=>l.isEmpty(),s=Ll.TRANSLATE_SMALL,o=Ll.TRANSLATE_BIG;return Kt(this,"_keyboardManager",new Cf([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-s,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-o,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[s,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[o,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-s],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-o],checker:n}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,s],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,o],checker:n}]]))}static initialize(e,n){Re.initialize(e,n);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,n){switch(e){case Jt.FREETEXT_SIZE:me._defaultFontSize=n;break;case Jt.FREETEXT_COLOR:me._defaultColor=n;break}}updateParams(e,n){switch(e){case Jt.FREETEXT_SIZE:M(this,We,PA).call(this,n);break;case Jt.FREETEXT_COLOR:M(this,We,MA).call(this,n);break}}static get defaultPropertiesToUpdate(){return[[Jt.FREETEXT_SIZE,me._defaultFontSize],[Jt.FREETEXT_COLOR,me._defaultColor||Re._defaultLineColor]]}get propertiesToUpdate(){return[[Jt.FREETEXT_SIZE,u(this,yi)],[Jt.FREETEXT_COLOR,u(this,hs)]]}_translateEmpty(e,n){this._uiManager.translateSelectedEditors(e,n,!0)}getInitialTranslation(){const e=this.parentScale;return[-me._internalPadding*e,-(me._internalPadding+u(this,yi))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Bt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),_(this,fl,new AbortController);const e=this._uiManager.combinedSignal(u(this,fl));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){var e;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",u(this,rf)),this._isDraggable=!0,(e=u(this,fl))==null||e.abort(),_(this,fl,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var n;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(n=this._initialOptions)!=null&&n.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=u(this,mi),n=_(this,mi,M(this,We,RA).call(this).trimEnd());if(e===n)return;const s=o=>{if(_(this,mi,o),!o){this.remove();return}M(this,We,mg).call(this),this._uiManager.rebuild(this),M(this,We,pg).call(this)};this.addCommands({cmd:()=>{s(n)},undo:()=>{s(e)},mustExec:!1}),M(this,We,pg).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){me._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,n;this.width&&(e=this.x,n=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",u(this,rf)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${u(this,yi)}px * var(--scale-factor))`,s.color=u(this,hs),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Mg(this,this.div,["dblclick","keydown"]),this.width){const[o,l]=this.parentDimensions;if(this.annotationElementId){const{position:c}=this._initialData;let[d,f]=this.getInitialTranslation();[d,f]=this.pageTranslationToScreen(d,f);const[g,m]=this.pageDimensions,[y,x]=this.pageTranslation;let b,A;switch(this.rotation){case 0:b=e+(c[0]-y)/g,A=n+this.height-(c[1]-x)/m;break;case 90:b=e+(c[0]-y)/g,A=n-(c[1]-x)/m,[d,f]=[f,-d];break;case 180:b=e-this.width+(c[0]-y)/g,A=n-(c[1]-x)/m,[d,f]=[-d,-f];break;case 270:b=e+(c[0]-y-this.height*m)/g,A=n+(c[1]-x-this.width*g)/m,[d,f]=[-f,d];break}this.setAt(b*o,A*l,d,f)}else this.setAt(e*o,n*l,this.width*o,this.height*l);M(this,We,mg).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var b,A,C;const n=e.clipboardData||window.clipboardData,{types:s}=n;if(s.length===1&&s[0]==="text/plain")return;e.preventDefault();const o=M(b=me,$r,yv).call(b,n.getData("text")||"").replaceAll(Vp,`
71
+ `);if(!o)return;const l=window.getSelection();if(!l.rangeCount)return;this.editorDiv.normalize(),l.deleteFromDocument();const c=l.getRangeAt(0);if(!o.includes(`
72
+ `)){c.insertNode(document.createTextNode(o)),this.editorDiv.normalize(),l.collapseToStart();return}const{startContainer:d,startOffset:f}=c,g=[],m=[];if(d.nodeType===Node.TEXT_NODE){const E=d.parentElement;if(m.push(d.nodeValue.slice(f).replaceAll(Vp,"")),E!==this.editorDiv){let N=g;for(const k of this.editorDiv.childNodes){if(k===E){N=m;continue}N.push(M(A=me,$r,gg).call(A,k))}}g.push(d.nodeValue.slice(0,f).replaceAll(Vp,""))}else if(d===this.editorDiv){let E=g,N=0;for(const k of this.editorDiv.childNodes)N++===f&&(E=m),E.push(M(C=me,$r,gg).call(C,k))}_(this,mi,`${g.join(`
73
+ `)}${o}${m.join(`
74
+ `)}`),M(this,We,mg).call(this);const y=new Range;let x=g.reduce((E,N)=>E+N.length,0);for(const{firstChild:E}of this.editorDiv.childNodes)if(E.nodeType===Node.TEXT_NODE){const N=E.nodeValue.length;if(x<=N){y.setStart(E,x),y.setEnd(E,x);break}x-=N}l.removeAllRanges(),l.addRange(y)}get contentDiv(){return this.editorDiv}static async deserialize(e,n,s){var c;let o=null;if(e instanceof _A){const{data:{defaultAppearanceData:{fontSize:d,fontColor:f},rect:g,rotation:m,id:y,popupRef:x},textContent:b,textPosition:A,parent:{page:{pageNumber:C}}}=e;if(!b||b.length===0)return null;o=e={annotationType:Bt.FREETEXT,color:Array.from(f),fontSize:d,value:b.join(`
75
+ `),position:A,pageIndex:C-1,rect:g.slice(0),rotation:m,id:y,deleted:!1,popupRef:x}}const l=await super.deserialize(e,n,s);return _(l,yi,e.fontSize),_(l,hs,Pt.makeHexColor(...e.color)),_(l,mi,M(c=me,$r,yv).call(c,e.value)),l.annotationElementId=e.id||null,l._initialData=o,l}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=me._internalPadding*this.parentScale,s=this.getRect(n,n),o=Re._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:u(this,hs)),l={annotationType:Bt.FREETEXT,color:o,fontSize:u(this,yi),value:M(this,We,NA).call(this),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?l:this.annotationElementId&&!M(this,We,LA).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){const n=super.renderAnnotationElement(e);if(this.deleted)return n;const{style:s}=n;s.fontSize=`calc(${u(this,yi)}px * var(--scale-factor))`,s.color=u(this,hs),n.replaceChildren();for(const l of u(this,mi).split(`
76
+ `)){const c=document.createElement("div");c.append(l?document.createTextNode(l):document.createElement("br")),n.append(c)}const o=me._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(o,o),popupContent:u(this,mi)}),n}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};hs=new WeakMap,mi=new WeakMap,rf=new WeakMap,fl=new WeakMap,yi=new WeakMap,We=new WeakSet,PA=function(e){const n=o=>{this.editorDiv.style.fontSize=`calc(${o}px * var(--scale-factor))`,this.translate(0,-(o-u(this,yi))*this.parentScale),_(this,yi,o),M(this,We,pg).call(this)},s=u(this,yi);this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Jt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},MA=function(e){const n=o=>{_(this,hs,this.editorDiv.style.color=o)},s=u(this,hs);this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Jt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},RA=function(){var s;const e=[];this.editorDiv.normalize();let n=null;for(const o of this.editorDiv.childNodes)(n==null?void 0:n.nodeType)===Node.TEXT_NODE&&o.nodeName==="BR"||(e.push(M(s=me,$r,gg).call(s,o)),n=o);return e.join(`
77
+ `)},pg=function(){const[e,n]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:o,div:l}=this,c=l.style.display,d=l.classList.contains("hidden");l.classList.remove("hidden"),l.style.display="hidden",o.div.append(this.div),s=l.getBoundingClientRect(),l.remove(),l.style.display=c,l.classList.toggle("hidden",d)}this.rotation%180===this.parentRotation%180?(this.width=s.width/e,this.height=s.height/n):(this.width=s.height/e,this.height=s.width/n),this.fixAndSetPosition()},$r=new WeakSet,gg=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Vp,"")},mg=function(){if(this.editorDiv.replaceChildren(),!!u(this,mi))for(const e of u(this,mi).split(`
78
+ `)){const n=document.createElement("div");n.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(n)}},NA=function(){return u(this,mi).replaceAll(" "," ")},yv=function(e){return e.replaceAll(" "," ")},LA=function(e){const{value:n,fontSize:s,color:o,pageIndex:l}=this._initialData;return this._hasBeenMoved||e.value!==n||e.fontSize!==s||e.color.some((c,d)=>c!==o[d])||e.pageIndex!==l},P(me,$r),It(me,"_freeTextDefaultContent",""),It(me,"_internalPadding",0),It(me,"_defaultColor",null),It(me,"_defaultFontSize",10),It(me,"_type","freetext"),It(me,"_editorType",Bt.FREETEXT);let mv=me;class bt{toSVGPath(){fe("Abstract method `toSVGPath` must be implemented.")}get box(){fe("Abstract getter `box` must be implemented.")}serialize(t,e){fe("Abstract method `serialize` must be implemented.")}static _rescale(t,e,n,s,o,l){l||(l=new Float32Array(t.length));for(let c=0,d=t.length;c<d;c+=2)l[c]=e+t[c]*s,l[c+1]=n+t[c+1]*o;return l}static _rescaleAndSwap(t,e,n,s,o,l){l||(l=new Float32Array(t.length));for(let c=0,d=t.length;c<d;c+=2)l[c]=e+t[c+1]*s,l[c+1]=n+t[c]*o;return l}static _translate(t,e,n,s){s||(s=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)s[o]=e+t[o],s[o+1]=n+t[o+1];return s}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,n,s,o){switch(o){case 90:return[1-e/n,t/s];case 180:return[1-t/n,1-e/s];case 270:return[e/n,1-t/s];default:return[t/n,e/s]}}static _normalizePagePoint(t,e,n){switch(n){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,n,s,o,l){return[(t+5*n)/6,(e+5*s)/6,(5*n+o)/6,(5*s+l)/6,(n+o)/2,(s+l)/2]}}It(bt,"PRECISION",1e-4);var vi,ds,ru,ou,Us,Yt,pl,gl,of,af,au,lu,Oo,lf,im,sm,Ze,Dh,IA,DA,FA,OA,jA,$A;const ur=class ur{constructor({x:t,y:e},n,s,o,l,c=0){P(this,Ze);P(this,vi);P(this,ds,[]);P(this,ru);P(this,ou);P(this,Us,[]);P(this,Yt,new Float32Array(18));P(this,pl);P(this,gl);P(this,of);P(this,af);P(this,au);P(this,lu);P(this,Oo,[]);_(this,vi,n),_(this,lu,o*s),_(this,ou,l),u(this,Yt).set([NaN,NaN,NaN,NaN,t,e],6),_(this,ru,c),_(this,af,u(ur,lf)*s),_(this,of,u(ur,sm)*s),_(this,au,s),u(this,Oo).push(t,e)}isEmpty(){return isNaN(u(this,Yt)[8])}add({x:t,y:e}){var X;_(this,pl,t),_(this,gl,e);const[n,s,o,l]=u(this,vi);let[c,d,f,g]=u(this,Yt).subarray(8,12);const m=t-f,y=e-g,x=Math.hypot(m,y);if(x<u(this,of))return!1;const b=x-u(this,af),A=b/x,C=A*m,E=A*y;let N=c,k=d;c=f,d=g,f+=C,g+=E,(X=u(this,Oo))==null||X.push(t,e);const L=-E/b,R=C/b,j=L*u(this,lu),O=R*u(this,lu);return u(this,Yt).set(u(this,Yt).subarray(2,8),0),u(this,Yt).set([f+j,g+O],4),u(this,Yt).set(u(this,Yt).subarray(14,18),12),u(this,Yt).set([f-j,g-O],16),isNaN(u(this,Yt)[6])?(u(this,Us).length===0&&(u(this,Yt).set([c+j,d+O],2),u(this,Us).push(NaN,NaN,NaN,NaN,(c+j-n)/o,(d+O-s)/l),u(this,Yt).set([c-j,d-O],14),u(this,ds).push(NaN,NaN,NaN,NaN,(c-j-n)/o,(d-O-s)/l)),u(this,Yt).set([N,k,c,d,f,g],6),!this.isEmpty()):(u(this,Yt).set([N,k,c,d,f,g],6),Math.abs(Math.atan2(k-d,N-c)-Math.atan2(E,C))<Math.PI/2?([c,d,f,g]=u(this,Yt).subarray(2,6),u(this,Us).push(NaN,NaN,NaN,NaN,((c+f)/2-n)/o,((d+g)/2-s)/l),[c,d,N,k]=u(this,Yt).subarray(14,18),u(this,ds).push(NaN,NaN,NaN,NaN,((N+c)/2-n)/o,((k+d)/2-s)/l),!0):([N,k,c,d,f,g]=u(this,Yt).subarray(0,6),u(this,Us).push(((N+5*c)/6-n)/o,((k+5*d)/6-s)/l,((5*c+f)/6-n)/o,((5*d+g)/6-s)/l,((c+f)/2-n)/o,((d+g)/2-s)/l),[f,g,c,d,N,k]=u(this,Yt).subarray(12,18),u(this,ds).push(((N+5*c)/6-n)/o,((k+5*d)/6-s)/l,((5*c+f)/6-n)/o,((5*d+g)/6-s)/l,((c+f)/2-n)/o,((d+g)/2-s)/l),!0))}toSVGPath(){if(this.isEmpty())return"";const t=u(this,Us),e=u(this,ds);if(isNaN(u(this,Yt)[6])&&!this.isEmpty())return M(this,Ze,IA).call(this);const n=[];n.push(`M${t[4]} ${t[5]}`);for(let s=6;s<t.length;s+=6)isNaN(t[s])?n.push(`L${t[s+4]} ${t[s+5]}`):n.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);M(this,Ze,FA).call(this,n);for(let s=e.length-6;s>=6;s-=6)isNaN(e[s])?n.push(`L${e[s+4]} ${e[s+5]}`):n.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);return M(this,Ze,DA).call(this,n),n.join(" ")}newFreeDrawOutline(t,e,n,s,o,l){return new zA(t,e,n,s,o,l)}getOutlines(){var m;const t=u(this,Us),e=u(this,ds),n=u(this,Yt),[s,o,l,c]=u(this,vi),d=new Float32Array((((m=u(this,Oo))==null?void 0:m.length)??0)+2);for(let y=0,x=d.length-2;y<x;y+=2)d[y]=(u(this,Oo)[y]-s)/l,d[y+1]=(u(this,Oo)[y+1]-o)/c;if(d[d.length-2]=(u(this,pl)-s)/l,d[d.length-1]=(u(this,gl)-o)/c,isNaN(n[6])&&!this.isEmpty())return M(this,Ze,OA).call(this,d);const f=new Float32Array(u(this,Us).length+24+u(this,ds).length);let g=t.length;for(let y=0;y<g;y+=2){if(isNaN(t[y])){f[y]=f[y+1]=NaN;continue}f[y]=t[y],f[y+1]=t[y+1]}g=M(this,Ze,$A).call(this,f,g);for(let y=e.length-6;y>=6;y-=6)for(let x=0;x<6;x+=2){if(isNaN(e[y+x])){f[g]=f[g+1]=NaN,g+=2;continue}f[g]=e[y+x],f[g+1]=e[y+x+1],g+=2}return M(this,Ze,jA).call(this,f,g),this.newFreeDrawOutline(f,d,u(this,vi),u(this,au),u(this,ru),u(this,ou))}};vi=new WeakMap,ds=new WeakMap,ru=new WeakMap,ou=new WeakMap,Us=new WeakMap,Yt=new WeakMap,pl=new WeakMap,gl=new WeakMap,of=new WeakMap,af=new WeakMap,au=new WeakMap,lu=new WeakMap,Oo=new WeakMap,lf=new WeakMap,im=new WeakMap,sm=new WeakMap,Ze=new WeakSet,Dh=function(){const t=u(this,Yt).subarray(4,6),e=u(this,Yt).subarray(16,18),[n,s,o,l]=u(this,vi);return[(u(this,pl)+(t[0]-e[0])/2-n)/o,(u(this,gl)+(t[1]-e[1])/2-s)/l,(u(this,pl)+(e[0]-t[0])/2-n)/o,(u(this,gl)+(e[1]-t[1])/2-s)/l]},IA=function(){const[t,e,n,s]=u(this,vi),[o,l,c,d]=M(this,Ze,Dh).call(this);return`M${(u(this,Yt)[2]-t)/n} ${(u(this,Yt)[3]-e)/s} L${(u(this,Yt)[4]-t)/n} ${(u(this,Yt)[5]-e)/s} L${o} ${l} L${c} ${d} L${(u(this,Yt)[16]-t)/n} ${(u(this,Yt)[17]-e)/s} L${(u(this,Yt)[14]-t)/n} ${(u(this,Yt)[15]-e)/s} Z`},DA=function(t){const e=u(this,ds);t.push(`L${e[4]} ${e[5]} Z`)},FA=function(t){const[e,n,s,o]=u(this,vi),l=u(this,Yt).subarray(4,6),c=u(this,Yt).subarray(16,18),[d,f,g,m]=M(this,Ze,Dh).call(this);t.push(`L${(l[0]-e)/s} ${(l[1]-n)/o} L${d} ${f} L${g} ${m} L${(c[0]-e)/s} ${(c[1]-n)/o}`)},OA=function(t){const e=u(this,Yt),[n,s,o,l]=u(this,vi),[c,d,f,g]=M(this,Ze,Dh).call(this),m=new Float32Array(36);return m.set([NaN,NaN,NaN,NaN,(e[2]-n)/o,(e[3]-s)/l,NaN,NaN,NaN,NaN,(e[4]-n)/o,(e[5]-s)/l,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,f,g,NaN,NaN,NaN,NaN,(e[16]-n)/o,(e[17]-s)/l,NaN,NaN,NaN,NaN,(e[14]-n)/o,(e[15]-s)/l],0),this.newFreeDrawOutline(m,t,u(this,vi),u(this,au),u(this,ru),u(this,ou))},jA=function(t,e){const n=u(this,ds);return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+=6},$A=function(t,e){const n=u(this,Yt).subarray(4,6),s=u(this,Yt).subarray(16,18),[o,l,c,d]=u(this,vi),[f,g,m,y]=M(this,Ze,Dh).call(this);return t.set([NaN,NaN,NaN,NaN,(n[0]-o)/c,(n[1]-l)/d,NaN,NaN,NaN,NaN,f,g,NaN,NaN,NaN,NaN,m,y,NaN,NaN,NaN,NaN,(s[0]-o)/c,(s[1]-l)/d],e),e+=24},P(ur,lf,8),P(ur,im,2),P(ur,sm,u(ur,lf)+u(ur,im));let Lg=ur;var cu,ml,Pr,cf,xi,uf,Oe,rm,HA;class zA extends bt{constructor(e,n,s,o,l,c){super();P(this,rm);P(this,cu);P(this,ml,new Float32Array(4));P(this,Pr);P(this,cf);P(this,xi);P(this,uf);P(this,Oe);_(this,Oe,e),_(this,xi,n),_(this,cu,s),_(this,uf,o),_(this,Pr,l),_(this,cf,c),this.lastPoint=[NaN,NaN],M(this,rm,HA).call(this,c);const[d,f,g,m]=u(this,ml);for(let y=0,x=e.length;y<x;y+=2)e[y]=(e[y]-d)/g,e[y+1]=(e[y+1]-f)/m;for(let y=0,x=n.length;y<x;y+=2)n[y]=(n[y]-d)/g,n[y+1]=(n[y+1]-f)/m}toSVGPath(){const e=[`M${u(this,Oe)[4]} ${u(this,Oe)[5]}`];for(let n=6,s=u(this,Oe).length;n<s;n+=6){if(isNaN(u(this,Oe)[n])){e.push(`L${u(this,Oe)[n+4]} ${u(this,Oe)[n+5]}`);continue}e.push(`C${u(this,Oe)[n]} ${u(this,Oe)[n+1]} ${u(this,Oe)[n+2]} ${u(this,Oe)[n+3]} ${u(this,Oe)[n+4]} ${u(this,Oe)[n+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,n,s,o],l){const c=s-e,d=o-n;let f,g;switch(l){case 0:f=bt._rescale(u(this,Oe),e,o,c,-d),g=bt._rescale(u(this,xi),e,o,c,-d);break;case 90:f=bt._rescaleAndSwap(u(this,Oe),e,n,c,d),g=bt._rescaleAndSwap(u(this,xi),e,n,c,d);break;case 180:f=bt._rescale(u(this,Oe),s,n,-c,d),g=bt._rescale(u(this,xi),s,n,-c,d);break;case 270:f=bt._rescaleAndSwap(u(this,Oe),s,o,-c,-d),g=bt._rescaleAndSwap(u(this,xi),s,o,-c,-d);break}return{outline:Array.from(f),points:[Array.from(g)]}}get box(){return u(this,ml)}newOutliner(e,n,s,o,l,c=0){return new Lg(e,n,s,o,l,c)}getNewOutline(e,n){const[s,o,l,c]=u(this,ml),[d,f,g,m]=u(this,cu),y=l*g,x=c*m,b=s*g+d,A=o*m+f,C=this.newOutliner({x:u(this,xi)[0]*y+b,y:u(this,xi)[1]*x+A},u(this,cu),u(this,uf),e,u(this,cf),n??u(this,Pr));for(let E=2;E<u(this,xi).length;E+=2)C.add({x:u(this,xi)[E]*y+b,y:u(this,xi)[E+1]*x+A});return C.getOutlines()}}cu=new WeakMap,ml=new WeakMap,Pr=new WeakMap,cf=new WeakMap,xi=new WeakMap,uf=new WeakMap,Oe=new WeakMap,rm=new WeakSet,HA=function(e){const n=u(this,Oe);let s=n[4],o=n[5],l=s,c=o,d=s,f=o,g=s,m=o;const y=e?Math.max:Math.min;for(let b=6,A=n.length;b<A;b+=6){if(isNaN(n[b]))l=Math.min(l,n[b+4]),c=Math.min(c,n[b+5]),d=Math.max(d,n[b+4]),f=Math.max(f,n[b+5]),m<n[b+5]?(g=n[b+4],m=n[b+5]):m===n[b+5]&&(g=y(g,n[b+4]));else{const C=Pt.bezierBoundingBox(s,o,...n.slice(b,b+6));l=Math.min(l,C[0]),c=Math.min(c,C[1]),d=Math.max(d,C[2]),f=Math.max(f,C[3]),m<C[3]?(g=C[2],m=C[3]):m===C[3]&&(g=y(g,C[2]))}s=n[b+4],o=n[b+5]}const x=u(this,ml);x[0]=l-u(this,Pr),x[1]=c-u(this,Pr),x[2]=d-l+2*u(this,Pr),x[3]=f-c+2*u(this,Pr),this.lastPoint=[g,m]};var hf,df,jo,fs,Xn,BA,yg,UA,VA,xv;class vv{constructor(t,e=0,n=0,s=!0){P(this,Xn);P(this,hf);P(this,df);P(this,jo,[]);P(this,fs,[]);let o=1/0,l=-1/0,c=1/0,d=-1/0;const f=10**-4;for(const{x:C,y:E,width:N,height:k}of t){const L=Math.floor((C-e)/f)*f,R=Math.ceil((C+N+e)/f)*f,j=Math.floor((E-e)/f)*f,O=Math.ceil((E+k+e)/f)*f,H=[L,j,O,!0],X=[R,j,O,!1];u(this,jo).push(H,X),o=Math.min(o,L),l=Math.max(l,R),c=Math.min(c,j),d=Math.max(d,O)}const g=l-o+2*n,m=d-c+2*n,y=o-n,x=c-n,b=u(this,jo).at(s?-1:-2),A=[b[0],b[2]];for(const C of u(this,jo)){const[E,N,k]=C;C[0]=(E-y)/g,C[1]=(N-x)/m,C[2]=(k-x)/m}_(this,hf,new Float32Array([y,x,g,m])),_(this,df,A)}getOutlines(){u(this,jo).sort((e,n)=>e[0]-n[0]||e[1]-n[1]||e[2]-n[2]);const t=[];for(const e of u(this,jo))e[3]?(t.push(...M(this,Xn,xv).call(this,e)),M(this,Xn,UA).call(this,e)):(M(this,Xn,VA).call(this,e),t.push(...M(this,Xn,xv).call(this,e)));return M(this,Xn,BA).call(this,t)}}hf=new WeakMap,df=new WeakMap,jo=new WeakMap,fs=new WeakMap,Xn=new WeakSet,BA=function(t){const e=[],n=new Set;for(const l of t){const[c,d,f]=l;e.push([c,d,l],[c,f,l])}e.sort((l,c)=>l[1]-c[1]||l[0]-c[0]);for(let l=0,c=e.length;l<c;l+=2){const d=e[l][2],f=e[l+1][2];d.push(f),f.push(d),n.add(d),n.add(f)}const s=[];let o;for(;n.size>0;){const l=n.values().next().value;let[c,d,f,g,m]=l;n.delete(l);let y=c,x=d;for(o=[c,f],s.push(o);;){let b;if(n.has(g))b=g;else if(n.has(m))b=m;else break;n.delete(b),[c,d,f,g,m]=b,y!==c&&(o.push(y,x,c,x===d?d:f),y=c),x=x===d?f:d}o.push(y,x)}return new WP(s,u(this,hf),u(this,df))},yg=function(t){const e=u(this,fs);let n=0,s=e.length-1;for(;n<=s;){const o=n+s>>1,l=e[o][0];if(l===t)return o;l<t?n=o+1:s=o-1}return s+1},UA=function([,t,e]){const n=M(this,Xn,yg).call(this,t);u(this,fs).splice(n,0,[t,e])},VA=function([,t,e]){const n=M(this,Xn,yg).call(this,t);for(let s=n;s<u(this,fs).length;s++){const[o,l]=u(this,fs)[s];if(o!==t)break;if(o===t&&l===e){u(this,fs).splice(s,1);return}}for(let s=n-1;s>=0;s--){const[o,l]=u(this,fs)[s];if(o!==t)break;if(o===t&&l===e){u(this,fs).splice(s,1);return}}},xv=function(t){const[e,n,s]=t,o=[[e,n,s]],l=M(this,Xn,yg).call(this,s);for(let c=0;c<l;c++){const[d,f]=u(this,fs)[c];for(let g=0,m=o.length;g<m;g++){const[,y,x]=o[g];if(!(f<=y||x<=d)){if(y>=d){if(x>f)o[g][1]=f;else{if(m===1)return[];o.splice(g,1),g--,m--}continue}o[g][2]=d,x>f&&o.push([e,f,x])}}}return o};var ff,uu;class WP extends bt{constructor(e,n,s){super();P(this,ff);P(this,uu);_(this,uu,e),_(this,ff,n),this.lastPoint=s}toSVGPath(){const e=[];for(const n of u(this,uu)){let[s,o]=n;e.push(`M${s} ${o}`);for(let l=2;l<n.length;l+=2){const c=n[l],d=n[l+1];c===s?(e.push(`V${d}`),o=d):d===o&&(e.push(`H${c}`),s=c)}e.push("Z")}return e.join(" ")}serialize([e,n,s,o],l){const c=[],d=s-e,f=o-n;for(const g of u(this,uu)){const m=new Array(g.length);for(let y=0;y<g.length;y+=2)m[y]=e+g[y]*d,m[y+1]=o-g[y+1]*f;c.push(m)}return c}get box(){return u(this,ff)}get classNamesForOutlining(){return["highlightOutline"]}}ff=new WeakMap,uu=new WeakMap;class wv extends Lg{newFreeDrawOutline(t,e,n,s,o,l){return new GP(t,e,n,s,o,l)}}class GP extends zA{newOutliner(t,e,n,s,o,l=0){return new wv(t,e,n,s,o,l)}}var ps,yl,hu,Je,pf,du,gf,mf,$o,gs,fu,yf,he,bv,Sv,Av,Sa,WA,fo;const ni=class ni{constructor({editor:t=null,uiManager:e=null}){P(this,he);P(this,ps,null);P(this,yl,null);P(this,hu);P(this,Je,null);P(this,pf,!1);P(this,du,!1);P(this,gf,null);P(this,mf);P(this,$o,null);P(this,gs,null);P(this,fu);var n;t?(_(this,du,!1),_(this,fu,Jt.HIGHLIGHT_COLOR),_(this,gf,t)):(_(this,du,!0),_(this,fu,Jt.HIGHLIGHT_DEFAULT_COLOR)),_(this,gs,(t==null?void 0:t._uiManager)||e),_(this,mf,u(this,gs)._eventBus),_(this,hu,(t==null?void 0:t.color)||((n=u(this,gs))==null?void 0:n.highlightColors.values().next().value)||"#FFFF98"),u(ni,yf)||_(ni,yf,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return Kt(this,"_keyboardManager",new Cf([[["Escape","mac+Escape"],ni.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ni.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ni.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ni.prototype._moveToPrevious],[["Home","mac+Home"],ni.prototype._moveToBeginning],[["End","mac+End"],ni.prototype._moveToEnd]]))}renderButton(){const t=_(this,ps,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=u(this,gs)._signal;t.addEventListener("click",M(this,he,Sa).bind(this),{signal:e}),t.addEventListener("keydown",M(this,he,Av).bind(this),{signal:e});const n=_(this,yl,document.createElement("span"));return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=u(this,hu),t.append(n),t}renderMainDropdown(){const t=_(this,Je,M(this,he,bv).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===u(this,ps)){M(this,he,Sa).call(this,t);return}const e=t.target.getAttribute("data-color");e&&M(this,he,Sv).call(this,e,t)}_moveToNext(t){var e,n;if(!u(this,he,fo)){M(this,he,Sa).call(this,t);return}if(t.target===u(this,ps)){(e=u(this,Je).firstChild)==null||e.focus();return}(n=t.target.nextSibling)==null||n.focus()}_moveToPrevious(t){var e,n;if(t.target===((e=u(this,Je))==null?void 0:e.firstChild)||t.target===u(this,ps)){u(this,he,fo)&&this._hideDropdownFromKeyboard();return}u(this,he,fo)||M(this,he,Sa).call(this,t),(n=t.target.previousSibling)==null||n.focus()}_moveToBeginning(t){var e;if(!u(this,he,fo)){M(this,he,Sa).call(this,t);return}(e=u(this,Je).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!u(this,he,fo)){M(this,he,Sa).call(this,t);return}(e=u(this,Je).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=u(this,Je))==null||t.classList.add("hidden"),(e=u(this,$o))==null||e.abort(),_(this,$o,null)}_hideDropdownFromKeyboard(){var t;if(!u(this,du)){if(!u(this,he,fo)){(t=u(this,gf))==null||t.unselect();return}this.hideDropdown(),u(this,ps).focus({preventScroll:!0,focusVisible:u(this,pf)})}}updateColor(t){if(u(this,yl)&&(u(this,yl).style.backgroundColor=t),!u(this,Je))return;const e=u(this,gs).highlightColors.values();for(const n of u(this,Je).children)n.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=u(this,ps))==null||t.remove(),_(this,ps,null),_(this,yl,null),(e=u(this,Je))==null||e.remove(),_(this,Je,null)}};ps=new WeakMap,yl=new WeakMap,hu=new WeakMap,Je=new WeakMap,pf=new WeakMap,du=new WeakMap,gf=new WeakMap,mf=new WeakMap,$o=new WeakMap,gs=new WeakMap,fu=new WeakMap,yf=new WeakMap,he=new WeakSet,bv=function(){const t=document.createElement("div"),e=u(this,gs)._signal;t.addEventListener("contextmenu",bs,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[n,s]of u(this,gs).highlightColors){const o=document.createElement("button");o.tabIndex="0",o.role="option",o.setAttribute("data-color",s),o.title=n,o.setAttribute("data-l10n-id",u(ni,yf)[n]);const l=document.createElement("span");o.append(l),l.className="swatch",l.style.backgroundColor=s,o.setAttribute("aria-selected",s===u(this,hu)),o.addEventListener("click",M(this,he,Sv).bind(this,s),{signal:e}),t.append(o)}return t.addEventListener("keydown",M(this,he,Av).bind(this),{signal:e}),t},Sv=function(t,e){e.stopPropagation(),u(this,mf).dispatch("switchannotationeditorparams",{source:this,type:u(this,fu),value:t})},Av=function(t){ni._keyboardManager.exec(this,t)},Sa=function(t){if(u(this,he,fo)){this.hideDropdown();return}if(_(this,pf,t.detail===0),u(this,$o)||(_(this,$o,new AbortController),window.addEventListener("pointerdown",M(this,he,WA).bind(this),{signal:u(this,gs).combinedSignal(u(this,$o))})),u(this,Je)){u(this,Je).classList.remove("hidden");return}const e=_(this,Je,M(this,he,bv).call(this));u(this,ps).append(e)},WA=function(t){var e;(e=u(this,Je))!=null&&e.contains(t.target)||this.hideDropdown()},fo=function(){return u(this,Je)&&!u(this,Je).classList.contains("hidden")},P(ni,yf,null);let Ig=ni;var pu,vf,Mr,vl,gu,ri,xf,wf,xl,Bi,wi,gn,mu,Rr,Pn,yu,Ui,bf,zt,_v,vg,GA,XA,qA,Ev,Aa,Xi,gc,YA,xg,Fh,KA,QA,JA,ZA,t_;const oe=class oe extends Re{constructor(e){super({...e,name:"highlightEditor"});P(this,zt);P(this,pu,null);P(this,vf,0);P(this,Mr);P(this,vl,null);P(this,gu,null);P(this,ri,null);P(this,xf,null);P(this,wf,0);P(this,xl,null);P(this,Bi,null);P(this,wi,null);P(this,gn,!1);P(this,mu,null);P(this,Rr);P(this,Pn,null);P(this,yu,"");P(this,Ui);P(this,bf,"");this.color=e.color||oe._defaultColor,_(this,Ui,e.thickness||oe._defaultThickness),_(this,Rr,e.opacity||oe._defaultOpacity),_(this,Mr,e.boxes||null),_(this,bf,e.methodOfCreation||""),_(this,yu,e.text||""),this._isDraggable=!1,e.highlightId>-1?(_(this,gn,!0),M(this,zt,vg).call(this,e),M(this,zt,Aa).call(this)):u(this,Mr)&&(_(this,pu,e.anchorNode),_(this,vf,e.anchorOffset),_(this,xf,e.focusNode),_(this,wf,e.focusOffset),M(this,zt,_v).call(this),M(this,zt,Aa).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=oe.prototype;return Kt(this,"_keyboardManager",new Cf([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:u(this,gn)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:u(this,Ui),methodOfCreation:u(this,bf)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,n){var s;Re.initialize(e,n),oe._defaultColor||(oe._defaultColor=((s=n.highlightColors)==null?void 0:s.values().next().value)||"#fff066")}static updateDefaultParams(e,n){switch(e){case Jt.HIGHLIGHT_DEFAULT_COLOR:oe._defaultColor=n;break;case Jt.HIGHLIGHT_THICKNESS:oe._defaultThickness=n;break}}translateInPage(e,n){}get toolbarPosition(){return u(this,mu)}updateParams(e,n){switch(e){case Jt.HIGHLIGHT_COLOR:M(this,zt,GA).call(this,n);break;case Jt.HIGHLIGHT_THICKNESS:M(this,zt,XA).call(this,n);break}}static get defaultPropertiesToUpdate(){return[[Jt.HIGHLIGHT_DEFAULT_COLOR,oe._defaultColor],[Jt.HIGHLIGHT_THICKNESS,oe._defaultThickness]]}get propertiesToUpdate(){return[[Jt.HIGHLIGHT_COLOR,this.color||oe._defaultColor],[Jt.HIGHLIGHT_THICKNESS,u(this,Ui)||oe._defaultThickness],[Jt.HIGHLIGHT_FREE,u(this,gn)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(_(this,gu,new Ig({editor:this})),e.addColorPicker(u(this,gu))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(M(this,zt,Fh).call(this))}getBaseTranslation(){return[0,0]}getRect(e,n){return super.getRect(e,n,M(this,zt,Fh).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){M(this,zt,Ev).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(M(this,zt,Aa).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var s;let n=!1;this.parent&&!e?M(this,zt,Ev).call(this):e&&(M(this,zt,Aa).call(this,e),n=!this.parent&&((s=this.div)==null?void 0:s.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),n&&this.select()}rotate(e){var o,l,c;const{drawLayer:n}=this.parent;let s;u(this,gn)?(e=(e-this.rotation+360)%360,s=M(o=oe,Xi,gc).call(o,u(this,Bi).box,e)):s=M(l=oe,Xi,gc).call(l,[this.x,this.y,this.width,this.height],e),n.updateProperties(u(this,wi),{bbox:s,root:{"data-main-rotation":e}}),n.updateProperties(u(this,Pn),{bbox:M(c=oe,Xi,gc).call(c,u(this,ri).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();u(this,yu)&&(e.setAttribute("aria-label",u(this,yu)),e.setAttribute("role","mark")),u(this,gn)?e.classList.add("free"):this.div.addEventListener("keydown",M(this,zt,YA).bind(this),{signal:this._uiManager._signal});const n=_(this,xl,document.createElement("div"));e.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",n.style.clipPath=u(this,vl);const[s,o]=this.parentDimensions;return this.setDims(this.width*s,this.height*o),Mg(this,u(this,xl),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(u(this,Pn),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(u(this,Pn),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:M(this,zt,xg).call(this,!0);break;case 1:case 3:M(this,zt,xg).call(this,!1);break}}select(){var e;super.select(),u(this,Pn)&&((e=this.parent)==null||e.drawLayer.updateProperties(u(this,Pn),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),u(this,Pn)&&((e=this.parent)==null||e.drawLayer.updateProperties(u(this,Pn),{rootClass:{selected:!1}}),u(this,gn)||M(this,zt,xg).call(this,!1))}get _mustFixPosition(){return!u(this,gn)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(u(this,wi),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(u(this,Pn),{rootClass:{hidden:!e}}))}static startHighlighting(e,n,{target:s,x:o,y:l}){const{x:c,y:d,width:f,height:g}=s.getBoundingClientRect(),m=new AbortController,y=e.combinedSignal(m),x=b=>{m.abort(),M(this,Xi,ZA).call(this,e,b)};window.addEventListener("blur",x,{signal:y}),window.addEventListener("pointerup",x,{signal:y}),window.addEventListener("pointerdown",ki,{capture:!0,passive:!1,signal:y}),window.addEventListener("contextmenu",bs,{signal:y}),s.addEventListener("pointermove",M(this,Xi,JA).bind(this,e),{signal:y}),this._freeHighlight=new wv({x:o,y:l},[c,d,f,g],e.scale,this._defaultThickness/2,n,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,n,s){var A,C,E,N;let o=null;if(e instanceof kA){const{data:{quadPoints:k,rect:L,rotation:R,id:j,color:O,opacity:H,popupRef:X},parent:{page:{pageNumber:q}}}=e;o=e={annotationType:Bt.HIGHLIGHT,color:Array.from(O),opacity:H,quadPoints:k,boxes:null,pageIndex:q-1,rect:L.slice(0),rotation:R,id:j,deleted:!1,popupRef:X}}else if(e instanceof rx){const{data:{inkLists:k,rect:L,rotation:R,id:j,color:O,borderStyle:{rawWidth:H},popupRef:X},parent:{page:{pageNumber:q}}}=e;o=e={annotationType:Bt.HIGHLIGHT,color:Array.from(O),thickness:H,inkLists:k,boxes:null,pageIndex:q-1,rect:L.slice(0),rotation:R,id:j,deleted:!1,popupRef:X}}const{color:l,quadPoints:c,inkLists:d,opacity:f}=e,g=await super.deserialize(e,n,s);g.color=Pt.makeHexColor(...l),_(g,Rr,f||1),d&&_(g,Ui,e.thickness),g.annotationElementId=e.id||null,g._initialData=o;const[m,y]=g.pageDimensions,[x,b]=g.pageTranslation;if(c){const k=_(g,Mr,[]);for(let L=0;L<c.length;L+=8)k.push({x:(c[L]-x)/m,y:1-(c[L+1]-b)/y,width:(c[L+2]-c[L])/m,height:(c[L+1]-c[L+5])/y});M(A=g,zt,_v).call(A),M(C=g,zt,Aa).call(C),g.rotate(g.rotation)}else if(d){_(g,gn,!0);const k=d[0],L={x:k[0]-x,y:y-(k[1]-b)},R=new wv(L,[0,0,m,y],1,u(g,Ui)/2,!0,.001);for(let H=0,X=k.length;H<X;H+=2)L.x=k[H]-x,L.y=y-(k[H+1]-b),R.add(L);const{id:j,clipPathId:O}=n.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:g.color,"fill-opacity":g._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:R.toSVGPath()}},!0,!0);M(E=g,zt,vg).call(E,{highlightOutlines:R.getOutlines(),highlightId:j,clipPathId:O}),M(N=g,zt,Aa).call(N)}return g}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const n=this.getRect(0,0),s=Re._colorManager.convert(this.color),o={annotationType:Bt.HIGHLIGHT,color:s,opacity:u(this,Rr),thickness:u(this,Ui),quadPoints:M(this,zt,KA).call(this),outlines:M(this,zt,QA).call(this,n),pageIndex:this.pageIndex,rect:n,rotation:M(this,zt,Fh).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!M(this,zt,t_).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};pu=new WeakMap,vf=new WeakMap,Mr=new WeakMap,vl=new WeakMap,gu=new WeakMap,ri=new WeakMap,xf=new WeakMap,wf=new WeakMap,xl=new WeakMap,Bi=new WeakMap,wi=new WeakMap,gn=new WeakMap,mu=new WeakMap,Rr=new WeakMap,Pn=new WeakMap,yu=new WeakMap,Ui=new WeakMap,bf=new WeakMap,zt=new WeakSet,_v=function(){const e=new vv(u(this,Mr),.001);_(this,Bi,e.getOutlines()),[this.x,this.y,this.width,this.height]=u(this,Bi).box;const n=new vv(u(this,Mr),.0025,.001,this._uiManager.direction==="ltr");_(this,ri,n.getOutlines());const{lastPoint:s}=u(this,ri);_(this,mu,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])},vg=function({highlightOutlines:e,highlightId:n,clipPathId:s}){var m,y;if(_(this,Bi,e),_(this,ri,e.getNewOutline(u(this,Ui)/2+1.5,.0025)),n>=0)_(this,wi,n),_(this,vl,s),this.parent.drawLayer.finalizeDraw(n,{bbox:e.box,path:{d:e.toSVGPath()}}),_(this,Pn,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:u(this,ri).box,path:{d:u(this,ri).toSVGPath()}},!0));else if(this.parent){const x=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(u(this,wi),{bbox:M(m=oe,Xi,gc).call(m,u(this,Bi).box,(x-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(u(this,Pn),{bbox:M(y=oe,Xi,gc).call(y,u(this,ri).box,x),path:{d:u(this,ri).toSVGPath()}})}const[l,c,d,f]=e.box;switch(this.rotation){case 0:this.x=l,this.y=c,this.width=d,this.height=f;break;case 90:{const[x,b]=this.parentDimensions;this.x=c,this.y=1-l,this.width=d*b/x,this.height=f*x/b;break}case 180:this.x=1-l,this.y=1-c,this.width=d,this.height=f;break;case 270:{const[x,b]=this.parentDimensions;this.x=1-c,this.y=l,this.width=d*b/x,this.height=f*x/b;break}}const{lastPoint:g}=u(this,ri);_(this,mu,[(g[0]-l)/d,(g[1]-c)/f])},GA=function(e){const n=(l,c)=>{var d,f;this.color=l,_(this,Rr,c),(d=this.parent)==null||d.drawLayer.updateProperties(u(this,wi),{root:{fill:l,"fill-opacity":c}}),(f=u(this,gu))==null||f.updateColor(l)},s=this.color,o=u(this,Rr);this.addCommands({cmd:n.bind(this,e,oe._defaultOpacity),undo:n.bind(this,s,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Jt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},XA=function(e){const n=u(this,Ui),s=o=>{_(this,Ui,o),M(this,zt,qA).call(this,o)};this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Jt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},qA=function(e){if(!u(this,gn))return;M(this,zt,vg).call(this,{highlightOutlines:u(this,Bi).getNewOutline(e/2)}),this.fixAndSetPosition();const[n,s]=this.parentDimensions;this.setDims(this.width*n,this.height*s)},Ev=function(){u(this,wi)===null||!this.parent||(this.parent.drawLayer.remove(u(this,wi)),_(this,wi,null),this.parent.drawLayer.remove(u(this,Pn)),_(this,Pn,null))},Aa=function(e=this.parent){u(this,wi)===null&&({id:$n(this,wi)._,clipPathId:$n(this,vl)._}=e.drawLayer.draw({bbox:u(this,Bi).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":u(this,Rr)},rootClass:{highlight:!0,free:u(this,gn)},path:{d:u(this,Bi).toSVGPath()}},!1,!0),_(this,Pn,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:u(this,gn)},bbox:u(this,ri).box,path:{d:u(this,ri).toSVGPath()}},u(this,gn))),u(this,xl)&&(u(this,xl).style.clipPath=u(this,vl)))},Xi=new WeakSet,gc=function([e,n,s,o],l){switch(l){case 90:return[1-n-o,e,o,s];case 180:return[1-e-s,1-n-o,s,o];case 270:return[n,1-e-s,o,s]}return[e,n,s,o]},YA=function(e){oe._keyboardManager.exec(this,e)},xg=function(e){if(!u(this,pu))return;const n=window.getSelection();e?n.setPosition(u(this,pu),u(this,vf)):n.setPosition(u(this,xf),u(this,wf))},Fh=function(){return u(this,gn)?this.rotation:0},KA=function(){if(u(this,gn))return null;const[e,n]=this.pageDimensions,[s,o]=this.pageTranslation,l=u(this,Mr),c=new Float32Array(l.length*8);let d=0;for(const{x:f,y:g,width:m,height:y}of l){const x=f*e+s,b=(1-g)*n+o;c[d]=c[d+4]=x,c[d+1]=c[d+3]=b,c[d+2]=c[d+6]=x+m*e,c[d+5]=c[d+7]=b-y*n,d+=8}return c},QA=function(e){return u(this,Bi).serialize(e,M(this,zt,Fh).call(this))},JA=function(e,n){this._freeHighlight.add(n)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},ZA=function(e,n){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(n,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},t_=function(e){const{color:n}=this._initialData;return e.color.some((s,o)=>s!==n[o])},P(oe,Xi),It(oe,"_defaultColor",null),It(oe,"_defaultOpacity",1),It(oe,"_defaultThickness",12),It(oe,"_type","highlight"),It(oe,"_editorType",Bt.HIGHLIGHT),It(oe,"_freeHighlightId",-1),It(oe,"_freeHighlight",null),It(oe,"_freeHighlightClipId","");let Dg=oe;var wl;class XP{constructor(){P(this,wl,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,n]of Object.entries(t))this.updateProperty(e,n)}updateSVGProperty(t,e){u(this,wl)[t]=e}toSVGProperties(){const t=u(this,wl);return _(this,wl,Object.create(null)),{root:t}}reset(){_(this,wl,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){fe("Not implemented")}}wl=new WeakMap;var bi,vu,ln,bl,Sl,zo,Ho,Bo,Al,ne,Cv,Tv,Pv,Oh,e_,wg,jh,mc;const At=class At extends Re{constructor(e){super(e);P(this,ne);P(this,bi,null);P(this,vu);It(this,"_drawId",null);_(this,vu,e.mustBeCommitted||!1),e.drawOutlines&&(M(this,ne,Cv).call(this,e),M(this,ne,Oh).call(this))}static _mergeSVGProperties(e,n){const s=new Set(Object.keys(e));for(const[o,l]of Object.entries(n))s.has(o)?Object.assign(e[o],l):e[o]=l;return e}static getDefaultDrawingOptions(e){fe("Not implemented")}static get typesMap(){fe("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,n){const s=this.typesMap.get(e);s&&this._defaultDrawingOptions.updateProperty(s,n),this._currentParent&&(u(At,ln).updateProperty(s,n),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,n){const s=this.constructor.typesMap.get(e);s&&this._updateProperty(e,s,n)}static get defaultPropertiesToUpdate(){const e=[],n=this._defaultDrawingOptions;for(const[s,o]of this.typesMap)e.push([s,n[o]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:n}=this;for(const[s,o]of this.constructor.typesMap)e.push([s,n[o]]);return e}_updateProperty(e,n,s){const o=this._drawingOptions,l=o[n],c=d=>{var g;o.updateProperty(n,d);const f=u(this,bi).updateProperty(n,d);f&&M(this,ne,jh).call(this,f),(g=this.parent)==null||g.drawLayer.updateProperties(this._drawId,o.toSVGProperties())};this.addCommands({cmd:c.bind(this,s),undo:c.bind(this,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,At._mergeSVGProperties(u(this,bi).getPathResizingSVGProperties(M(this,ne,wg).call(this)),{bbox:M(this,ne,mc).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,At._mergeSVGProperties(u(this,bi).getPathResizedSVGProperties(M(this,ne,wg).call(this)),{bbox:M(this,ne,mc).call(this)}))}_onTranslating(e,n){var s;(s=this.parent)==null||s.drawLayer.updateProperties(this._drawId,{bbox:M(this,ne,mc).call(this,e,n)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,At._mergeSVGProperties(u(this,bi).getPathTranslatedSVGProperties(M(this,ne,wg).call(this),this.parentDimensions),{bbox:M(this,ne,mc).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,u(this,vu)&&(_(this,vu,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){M(this,ne,Pv).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(M(this,ne,Oh).call(this),M(this,ne,jh).call(this,u(this,bi).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var s;let n=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),M(this,ne,Pv).call(this)):e&&(this._uiManager.addShouldRescale(this),M(this,ne,Oh).call(this,e),n=!this.parent&&((s=this.div)==null?void 0:s.classList.contains("selectedEditor"))),super.setParent(e),n&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,At._mergeSVGProperties({bbox:M(this,ne,mc).call(this)},u(this,bi).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&M(this,ne,jh).call(this,u(this,bi).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const n=document.createElement("div");e.append(n),n.setAttribute("aria-hidden","true"),n.className="internal";const[s,o]=this.parentDimensions;return this.setDims(this.width*s,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,n,s,o,l){fe("Not implemented")}static startDrawing(e,n,s,o){var C;const{target:l,offsetX:c,offsetY:d,pointerId:f,pointerType:g}=o;if(u(At,Ho)&&u(At,Ho)!==g)return;const{viewport:{rotation:m}}=e,{width:y,height:x}=l.getBoundingClientRect(),b=_(At,bl,new AbortController),A=e.combinedSignal(b);if(u(At,zo)||_(At,zo,f),u(At,Ho)??_(At,Ho,g),window.addEventListener("pointerup",E=>{var N;u(At,zo)===E.pointerId?this._endDraw(E):(N=u(At,Bo))==null||N.delete(E.pointerId)},{signal:A}),window.addEventListener("pointercancel",E=>{var N;u(At,zo)===E.pointerId?this._currentParent.endDrawingSession():(N=u(At,Bo))==null||N.delete(E.pointerId)},{signal:A}),window.addEventListener("pointerdown",E=>{u(At,Ho)===E.pointerType&&((u(At,Bo)||_(At,Bo,new Set)).add(E.pointerId),u(At,ln).isCancellable()&&(u(At,ln).removeLastElement(),u(At,ln).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",bs,{signal:A}),l.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),l.addEventListener("touchmove",E=>{E.timeStamp===u(At,Al)&&ki(E)},{signal:A}),e.toggleDrawing(),(C=n._editorUndoBar)==null||C.hide(),u(At,ln)){e.drawLayer.updateProperties(this._currentDrawId,u(At,ln).startNew(c,d,y,x,m));return}n.updateUIForDefaultProperties(this),_(At,ln,this.createDrawerInstance(c,d,y,x,m)),_(At,Sl,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(u(At,Sl).toSVGProperties(),u(At,ln).defaultSVGProperties),!0,!1)}static _drawMove(e){var l;if(_(At,Al,-1),!u(At,ln))return;const{offsetX:n,offsetY:s,pointerId:o}=e;if(u(At,zo)===o){if(((l=u(At,Bo))==null?void 0:l.size)>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,u(At,ln).add(n,s)),_(At,Al,e.timeStamp),ki(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,_(At,ln,null),_(At,Sl,null),_(At,Ho,null),_(At,Al,NaN)),u(At,bl)&&(u(At,bl).abort(),_(At,bl,null),_(At,zo,NaN),_(At,Bo,null))}static _endDraw(e){const n=this._currentParent;if(n){if(n.toggleDrawing(!0),this._cleanup(!1),e&&n.drawLayer.updateProperties(this._currentDrawId,u(At,ln).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const s=u(At,ln),o=this._currentDrawId,l=s.getLastElement();n.addCommands({cmd:()=>{n.drawLayer.updateProperties(o,s.setLastElement(l))},undo:()=>{n.drawLayer.updateProperties(o,s.removeLastElement())},mustExec:!1,type:Jt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const n=this._currentParent;if(!n)return null;if(n.toggleDrawing(!0),n.cleanUndoStack(Jt.DRAW_STEP),!u(At,ln).isEmpty()){const{pageDimensions:[s,o],scale:l}=n,c=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:u(At,ln).getOutlines(s*l,o*l,l,this._INNER_MARGIN),drawingOptions:u(At,Sl),mustBeCommitted:!e});return this._cleanup(!0),c}return n.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,n,s,o,l,c){fe("Not implemented")}static async deserialize(e,n,s){var m,y;const{rawDims:{pageWidth:o,pageHeight:l,pageX:c,pageY:d}}=n.viewport,f=this.deserializeDraw(c,d,o,l,this._INNER_MARGIN,e),g=await super.deserialize(e,n,s);return g.createDrawingOptions(e),M(m=g,ne,Cv).call(m,{drawOutlines:f}),M(y=g,ne,Oh).call(y),g.onScaleChanging(),g.rotate(),g}serializeDraw(e){const[n,s]=this.pageTranslation,[o,l]=this.pageDimensions;return u(this,bi).serialize([n,s,o,l],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};bi=new WeakMap,vu=new WeakMap,ln=new WeakMap,bl=new WeakMap,Sl=new WeakMap,zo=new WeakMap,Ho=new WeakMap,Bo=new WeakMap,Al=new WeakMap,ne=new WeakSet,Cv=function({drawOutlines:e,drawId:n,drawingOptions:s}){_(this,bi,e),this._drawingOptions||(this._drawingOptions=s),n>=0?(this._drawId=n,this.parent.drawLayer.finalizeDraw(n,e.defaultProperties)):this._drawId=M(this,ne,Tv).call(this,e,this.parent),M(this,ne,jh).call(this,e.box)},Tv=function(e,n){const{id:s}=n.drawLayer.draw(At._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return s},Pv=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Oh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=M(this,ne,Tv).call(this,u(this,bi),e)}},e_=function([e,n,s,o]){const{parentDimensions:[l,c],rotation:d}=this;switch(d){case 90:return[n,1-e,s*(c/l),o*(l/c)];case 180:return[1-e,1-n,s,o];case 270:return[1-n,e,s*(c/l),o*(l/c)];default:return[e,n,s,o]}},wg=function(){const{x:e,y:n,width:s,height:o,parentDimensions:[l,c],rotation:d}=this;switch(d){case 90:return[1-n,e,s*(l/c),o*(c/l)];case 180:return[1-e,1-n,s,o];case 270:return[n,1-e,s*(l/c),o*(c/l)];default:return[e,n,s,o]}},jh=function(e){if([this.x,this.y,this.width,this.height]=M(this,ne,e_).call(this,e),this.div){this.fixAndSetPosition();const[n,s]=this.parentDimensions;this.setDims(this.width*n,this.height*s)}this._onResized()},mc=function(){const{x:e,y:n,width:s,height:o,rotation:l,parentRotation:c,parentDimensions:[d,f]}=this;switch((l*4+c)/90){case 1:return[1-n-o,e,o,s];case 2:return[1-e-s,1-n-o,s,o];case 3:return[n,1-e-s,o,s];case 4:return[e,n-s*(d/f),o*(f/d),s*(d/f)];case 5:return[1-n,e,s*(d/f),o*(f/d)];case 6:return[1-e-o*(f/d),1-n,o*(f/d),s*(d/f)];case 7:return[n-s*(d/f),1-e-o*(f/d),s*(d/f),o*(f/d)];case 8:return[e-s,n-o,s,o];case 9:return[1-n,e-s,o,s];case 10:return[1-e,1-n,s,o];case 11:return[n-o,1-e,o,s];case 12:return[e-o*(f/d),n,o*(f/d),s*(d/f)];case 13:return[1-n-s*(d/f),e-o*(f/d),s*(d/f),o*(f/d)];case 14:return[1-e,1-n-s*(d/f),o*(f/d),s*(d/f)];case 15:return[n,1-e,s*(d/f),o*(f/d)];default:return[e,n,s,o]}},It(At,"_currentDrawId",-1),It(At,"_currentParent",null),P(At,ln,null),P(At,bl,null),P(At,Sl,null),P(At,zo,NaN),P(At,Ho,null),P(At,Bo,null),P(At,Al,NaN),It(At,"_INNER_MARGIN",3);let kv=At;var Vs,cn,un,_l,xu,Bn,mn,Vi,El,kl,Cl,wu,bg;class qP{constructor(t,e,n,s,o,l){P(this,wu);P(this,Vs,new Float64Array(6));P(this,cn);P(this,un);P(this,_l);P(this,xu);P(this,Bn);P(this,mn,"");P(this,Vi,0);P(this,El,new Fg);P(this,kl);P(this,Cl);_(this,kl,n),_(this,Cl,s),_(this,_l,o),_(this,xu,l),[t,e]=M(this,wu,bg).call(this,t,e);const c=_(this,cn,[NaN,NaN,NaN,NaN,t,e]);_(this,Bn,[t,e]),_(this,un,[{line:c,points:u(this,Bn)}]),u(this,Vs).set(c,0)}updateProperty(t,e){t==="stroke-width"&&_(this,xu,e)}isEmpty(){return!u(this,un)||u(this,un).length===0}isCancellable(){return u(this,Bn).length<=10}add(t,e){[t,e]=M(this,wu,bg).call(this,t,e);const[n,s,o,l]=u(this,Vs).subarray(2,6),c=t-o,d=e-l;return Math.hypot(u(this,kl)*c,u(this,Cl)*d)<=2?null:(u(this,Bn).push(t,e),isNaN(n)?(u(this,Vs).set([o,l,t,e],2),u(this,cn).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(u(this,Vs)[0])&&u(this,cn).splice(6,6),u(this,Vs).set([n,s,o,l,t,e],0),u(this,cn).push(...bt.createBezierPoints(n,s,o,l,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const n=this.add(t,e);return n||(u(this,Bn).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,s,o){_(this,kl,n),_(this,Cl,s),_(this,_l,o),[t,e]=M(this,wu,bg).call(this,t,e);const l=_(this,cn,[NaN,NaN,NaN,NaN,t,e]);_(this,Bn,[t,e]);const c=u(this,un).at(-1);return c&&(c.line=new Float32Array(c.line),c.points=new Float32Array(c.points)),u(this,un).push({line:l,points:u(this,Bn)}),u(this,Vs).set(l,0),_(this,Vi,0),this.toSVGPath(),null}getLastElement(){return u(this,un).at(-1)}setLastElement(t){return u(this,un)?(u(this,un).push(t),_(this,cn,t.line),_(this,Bn,t.points),_(this,Vi,0),{path:{d:this.toSVGPath()}}):u(this,El).setLastElement(t)}removeLastElement(){if(!u(this,un))return u(this,El).removeLastElement();u(this,un).pop(),_(this,mn,"");for(let t=0,e=u(this,un).length;t<e;t++){const{line:n,points:s}=u(this,un)[t];_(this,cn,n),_(this,Bn,s),_(this,Vi,0),this.toSVGPath()}return{path:{d:u(this,mn)}}}toSVGPath(){const t=bt.svgRound(u(this,cn)[4]),e=bt.svgRound(u(this,cn)[5]);if(u(this,Bn).length===2)return _(this,mn,`${u(this,mn)} M ${t} ${e} Z`),u(this,mn);if(u(this,Bn).length<=6){const s=u(this,mn).lastIndexOf("M");_(this,mn,`${u(this,mn).slice(0,s)} M ${t} ${e}`),_(this,Vi,6)}if(u(this,Bn).length===4){const s=bt.svgRound(u(this,cn)[10]),o=bt.svgRound(u(this,cn)[11]);return _(this,mn,`${u(this,mn)} L ${s} ${o}`),_(this,Vi,12),u(this,mn)}const n=[];u(this,Vi)===0&&(n.push(`M ${t} ${e}`),_(this,Vi,6));for(let s=u(this,Vi),o=u(this,cn).length;s<o;s+=6){const[l,c,d,f,g,m]=u(this,cn).slice(s,s+6).map(bt.svgRound);n.push(`C${l} ${c} ${d} ${f} ${g} ${m}`)}return _(this,mn,u(this,mn)+n.join(" ")),_(this,Vi,u(this,cn).length),u(this,mn)}getOutlines(t,e,n,s){const o=u(this,un).at(-1);return o.line=new Float32Array(o.line),o.points=new Float32Array(o.points),u(this,El).build(u(this,un),t,e,n,u(this,_l),u(this,xu),s),_(this,Vs,null),_(this,cn,null),_(this,un,null),_(this,mn,null),u(this,El)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Vs=new WeakMap,cn=new WeakMap,un=new WeakMap,_l=new WeakMap,xu=new WeakMap,Bn=new WeakMap,mn=new WeakMap,Vi=new WeakMap,El=new WeakMap,kl=new WeakMap,Cl=new WeakMap,wu=new WeakSet,bg=function(t,e){return bt._normalizePoint(t,e,u(this,kl),u(this,Cl),u(this,_l))};var Un,Sf,Af,Si,Ws,Gs,bu,Su,Au,vn,lr,n_,i_,s_;const gx=class gx extends bt{constructor(){super(...arguments);P(this,vn);P(this,Un);P(this,Sf,0);P(this,Af);P(this,Si);P(this,Ws);P(this,Gs);P(this,bu);P(this,Su);P(this,Au)}build(e,n,s,o,l,c,d){_(this,Ws,n),_(this,Gs,s),_(this,bu,o),_(this,Su,l),_(this,Au,c),_(this,Af,d??0),_(this,Si,e),M(this,vn,i_).call(this)}setLastElement(e){return u(this,Si).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return u(this,Si).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:n}of u(this,Si)){if(e.push(`M${bt.svgRound(n[4])} ${bt.svgRound(n[5])}`),n.length===6){e.push("Z");continue}if(n.length===12){e.push(`L${bt.svgRound(n[10])} ${bt.svgRound(n[11])}`);continue}for(let s=6,o=n.length;s<o;s+=6){const[l,c,d,f,g,m]=n.subarray(s,s+6).map(bt.svgRound);e.push(`C${l} ${c} ${d} ${f} ${g} ${m}`)}}return e.join("")}serialize([e,n,s,o],l){const c=[],d=[],[f,g,m,y]=M(this,vn,n_).call(this);let x,b,A,C,E,N,k,L,R;switch(u(this,Su)){case 0:R=bt._rescale,x=e,b=n+o,A=s,C=-o,E=e+f*s,N=n+(1-g-y)*o,k=e+(f+m)*s,L=n+(1-g)*o;break;case 90:R=bt._rescaleAndSwap,x=e,b=n,A=s,C=o,E=e+g*s,N=n+f*o,k=e+(g+y)*s,L=n+(f+m)*o;break;case 180:R=bt._rescale,x=e+s,b=n,A=-s,C=o,E=e+(1-f-m)*s,N=n+g*o,k=e+(1-f)*s,L=n+(g+y)*o;break;case 270:R=bt._rescaleAndSwap,x=e+s,b=n+o,A=-s,C=-o,E=e+(1-g-y)*s,N=n+(1-f-m)*o,k=e+(1-g)*s,L=n+(1-f)*o;break}for(const{line:j,points:O}of u(this,Si))c.push(R(j,x,b,A,C,l?new Array(j.length):null)),d.push(R(O,x,b,A,C,l?new Array(O.length):null));return{lines:c,points:d,rect:[E,N,k,L]}}static deserialize(e,n,s,o,l,{paths:{lines:c,points:d},rotation:f,thickness:g}){const m=[];let y,x,b,A,C;switch(f){case 0:C=bt._rescale,y=-e/s,x=n/o+1,b=1/s,A=-1/o;break;case 90:C=bt._rescaleAndSwap,y=-n/o,x=-e/s,b=1/o,A=1/s;break;case 180:C=bt._rescale,y=e/s+1,x=-n/o,b=-1/s,A=1/o;break;case 270:C=bt._rescaleAndSwap,y=n/o+1,x=e/s+1,b=-1/o,A=-1/s;break}if(!c){c=[];for(const N of d){const k=N.length;if(k===2){c.push(new Float32Array([NaN,NaN,NaN,NaN,N[0],N[1]]));continue}if(k===4){c.push(new Float32Array([NaN,NaN,NaN,NaN,N[0],N[1],NaN,NaN,NaN,NaN,N[2],N[3]]));continue}const L=new Float32Array(3*(k-2));c.push(L);let[R,j,O,H]=N.subarray(0,4);L.set([NaN,NaN,NaN,NaN,R,j],0);for(let X=4;X<k;X+=2){const q=N[X],K=N[X+1];L.set(bt.createBezierPoints(R,j,O,H,q,K),(X-2)*3),[R,j,O,H]=[O,H,q,K]}}}for(let N=0,k=c.length;N<k;N++)m.push({line:C(c[N].map(L=>L??NaN),y,x,b,A),points:C(d[N].map(L=>L??NaN),y,x,b,A)});const E=new gx;return E.build(m,s,o,1,f,g,l),E}get box(){return u(this,Un)}updateProperty(e,n){return e==="stroke-width"?M(this,vn,s_).call(this,n):null}updateParentDimensions([e,n],s){const[o,l]=M(this,vn,lr).call(this);_(this,Ws,e),_(this,Gs,n),_(this,bu,s);const[c,d]=M(this,vn,lr).call(this),f=c-o,g=d-l,m=u(this,Un);return m[0]-=f,m[1]-=g,m[2]+=2*f,m[3]+=2*g,m}updateRotation(e){return _(this,Sf,e),{path:{transform:this.rotationTransform}}}get viewBox(){return u(this,Un).map(bt.svgRound).join(" ")}get defaultProperties(){const[e,n]=u(this,Un);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bt.svgRound(e)} ${bt.svgRound(n)}`}}}get rotationTransform(){const[,,e,n]=u(this,Un);let s=0,o=0,l=0,c=0,d=0,f=0;switch(u(this,Sf)){case 90:o=n/e,l=-e/n,d=e;break;case 180:s=-1,c=-1,d=e,f=n;break;case 270:o=-n/e,l=e/n,f=n;break;default:return""}return`matrix(${s} ${o} ${l} ${c} ${bt.svgRound(d)} ${bt.svgRound(f)})`}getPathResizingSVGProperties([e,n,s,o]){const[l,c]=M(this,vn,lr).call(this),[d,f,g,m]=u(this,Un);if(Math.abs(g-l)<=bt.PRECISION||Math.abs(m-c)<=bt.PRECISION){const C=e+s/2-(d+g/2),E=n+o/2-(f+m/2);return{path:{"transform-origin":`${bt.svgRound(e)} ${bt.svgRound(n)}`,transform:`${this.rotationTransform} translate(${C} ${E})`}}}const y=(s-2*l)/(g-2*l),x=(o-2*c)/(m-2*c),b=g/s,A=m/o;return{path:{"transform-origin":`${bt.svgRound(d)} ${bt.svgRound(f)}`,transform:`${this.rotationTransform} scale(${b} ${A}) translate(${bt.svgRound(l)} ${bt.svgRound(c)}) scale(${y} ${x}) translate(${bt.svgRound(-l)} ${bt.svgRound(-c)})`}}}getPathResizedSVGProperties([e,n,s,o]){const[l,c]=M(this,vn,lr).call(this),d=u(this,Un),[f,g,m,y]=d;if(d[0]=e,d[1]=n,d[2]=s,d[3]=o,Math.abs(m-l)<=bt.PRECISION||Math.abs(y-c)<=bt.PRECISION){const E=e+s/2-(f+m/2),N=n+o/2-(g+y/2);for(const{line:k,points:L}of u(this,Si))bt._translate(k,E,N,k),bt._translate(L,E,N,L);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bt.svgRound(e)} ${bt.svgRound(n)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const x=(s-2*l)/(m-2*l),b=(o-2*c)/(y-2*c),A=-x*(f+l)+e+l,C=-b*(g+c)+n+c;if(x!==1||b!==1||A!==0||C!==0)for(const{line:E,points:N}of u(this,Si))bt._rescale(E,A,C,x,b,E),bt._rescale(N,A,C,x,b,N);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bt.svgRound(e)} ${bt.svgRound(n)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,n],s){const[o,l]=s,c=u(this,Un),d=e-c[0],f=n-c[1];if(u(this,Ws)===o&&u(this,Gs)===l)for(const{line:g,points:m}of u(this,Si))bt._translate(g,d,f,g),bt._translate(m,d,f,m);else{const g=u(this,Ws)/o,m=u(this,Gs)/l;_(this,Ws,o),_(this,Gs,l);for(const{line:y,points:x}of u(this,Si))bt._rescale(y,d,f,g,m,y),bt._rescale(x,d,f,g,m,x);c[2]*=g,c[3]*=m}return c[0]=e,c[1]=n,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${bt.svgRound(e)} ${bt.svgRound(n)}`}}}get defaultSVGProperties(){const e=u(this,Un);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${bt.svgRound(e[0])} ${bt.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}};Un=new WeakMap,Sf=new WeakMap,Af=new WeakMap,Si=new WeakMap,Ws=new WeakMap,Gs=new WeakMap,bu=new WeakMap,Su=new WeakMap,Au=new WeakMap,vn=new WeakSet,lr=function(e=u(this,Au)){const n=u(this,Af)+e/2*u(this,bu);return u(this,Su)%180===0?[n/u(this,Ws),n/u(this,Gs)]:[n/u(this,Gs),n/u(this,Ws)]},n_=function(){const[e,n,s,o]=u(this,Un),[l,c]=M(this,vn,lr).call(this,0);return[e+l,n+c,s-2*l,o-2*c]},i_=function(){const e=_(this,Un,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:o}of u(this,Si)){if(o.length<=12){for(let d=4,f=o.length;d<f;d+=6){const[g,m]=o.subarray(d,d+2);e[0]=Math.min(e[0],g),e[1]=Math.min(e[1],m),e[2]=Math.max(e[2],g),e[3]=Math.max(e[3],m)}continue}let l=o[4],c=o[5];for(let d=6,f=o.length;d<f;d+=6){const[g,m,y,x,b,A]=o.subarray(d,d+6);Pt.bezierBoundingBox(l,c,g,m,y,x,b,A,e),l=b,c=A}}const[n,s]=M(this,vn,lr).call(this);e[0]=Math.min(1,Math.max(0,e[0]-n)),e[1]=Math.min(1,Math.max(0,e[1]-s)),e[2]=Math.min(1,Math.max(0,e[2]+n)),e[3]=Math.min(1,Math.max(0,e[3]+s)),e[2]-=e[0],e[3]-=e[1]},s_=function(e){const[n,s]=M(this,vn,lr).call(this);_(this,Au,e);const[o,l]=M(this,vn,lr).call(this),[c,d]=[o-n,l-s],f=u(this,Un);return f[0]-=c,f[1]-=d,f[2]+=2*c,f[3]+=2*d,f};let Fg=gx;var _u;const mx=class mx extends XP{constructor(e){super();P(this,_u);_(this,_u,e),super.updateProperties({fill:"none",stroke:Re._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,n){e==="stroke-width"&&(n??(n=this["stroke-width"]),n*=u(this,_u).realScale),super.updateSVGProperty(e,n)}clone(){const e=new mx(u(this,_u));return e.updateAll(this),e}};_u=new WeakMap;let Mv=mx;var om,r_;const bc=class bc extends kv{constructor(e){super({...e,name:"inkEditor"});P(this,om);this._willKeepAspectRatio=!0}static initialize(e,n){Re.initialize(e,n),this._defaultDrawingOptions=new Mv(n.viewParameters)}static getDefaultDrawingOptions(e){const n=this._defaultDrawingOptions.clone();return n.updateProperties(e),n}static get supportMultipleDrawings(){return!0}static get typesMap(){return Kt(this,"typesMap",new Map([[Jt.INK_THICKNESS,"stroke-width"],[Jt.INK_COLOR,"stroke"],[Jt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,n,s,o,l){return new qP(e,n,s,o,l,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,n,s,o,l,c){return Fg.deserialize(e,n,s,o,l,c)}static async deserialize(e,n,s){let o=null;if(e instanceof rx){const{data:{inkLists:c,rect:d,rotation:f,id:g,color:m,opacity:y,borderStyle:{rawWidth:x},popupRef:b},parent:{page:{pageNumber:A}}}=e;o=e={annotationType:Bt.INK,color:Array.from(m),thickness:x,opacity:y,paths:{points:c},boxes:null,pageIndex:A-1,rect:d.slice(0),rotation:f,id:g,deleted:!1,popupRef:b}}const l=await super.deserialize(e,n,s);return l.annotationElementId=e.id||null,l._initialData=o,l}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:n,parent:s}=this;n.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(e,n.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:n,opacity:s}){this._drawingOptions=bc.getDefaultDrawingOptions({stroke:Pt.makeHexColor(...e),"stroke-width":n,"stroke-opacity":s})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:n,points:s,rect:o}=this.serializeDraw(e),{_drawingOptions:{stroke:l,"stroke-opacity":c,"stroke-width":d}}=this,f={annotationType:Bt.INK,color:Re._colorManager.convert(l),opacity:c,thickness:d,paths:{lines:n,points:s},pageIndex:this.pageIndex,rect:o,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?f:this.annotationElementId&&!M(this,om,r_).call(this,f)?null:(f.id=this.annotationElementId,f)}renderAnnotationElement(e){const{points:n,rect:s}=this.serializeDraw(!1);return e.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:n}),null}};om=new WeakSet,r_=function(e){const{color:n,thickness:s,opacity:o,pageIndex:l}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some((c,d)=>c!==n[d])||e.thickness!==s||e.opacity!==o||e.pageIndex!==l},It(bc,"_type","ink"),It(bc,"_editorType",Bt.INK),It(bc,"_defaultDrawingOptions",null);let Rv=bc;var Me,yn,Uo,Nr,Vo,Eu,Xs,qs,Ai,ku,re,$h,zh,Sg,Lv,Ag,Iv,_g,o_;const Gh=class Gh extends Re{constructor(e){super({...e,name:"stampEditor"});P(this,re);P(this,Me,null);P(this,yn,null);P(this,Uo,null);P(this,Nr,null);P(this,Vo,null);P(this,Eu,"");P(this,Xs,null);P(this,qs,null);P(this,Ai,!1);P(this,ku,!1);_(this,Nr,e.bitmapUrl),_(this,Vo,e.bitmapFile)}static initialize(e,n){Re.initialize(e,n)}static get supportedTypes(){return Kt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(n=>`image/${n}`))}static get supportedTypesStr(){return Kt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,n){n.pasteEditor(Bt.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const n=e.get("hasAltText");return{hasAltText:n.get(!0)??0,hasNoAltText:n.get(!1)??0}}async mlGuessAltText(e=null,n=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:o,width:l,height:c}=e||this.copyCanvas(null,null,!0).imageData,d=await s.guess({name:"altText",request:{data:o,width:l,height:c,channels:o.length/(l*c)}});if(!d)throw new Error("No response from the AI service.");if(d.error)throw new Error("Error from the AI service.");if(d.cancel)return null;if(!d.output)throw new Error("No valid response from the AI service.");const f=d.output;return await this.setGuessedAltText(f),n&&!this.hasAltTextData()&&(this.altTextData={alt:f,decorative:!1}),f}remove(){var e;u(this,yn)&&(_(this,Me,null),this._uiManager.imageManager.deleteId(u(this,yn)),(e=u(this,Xs))==null||e.remove(),_(this,Xs,null),u(this,qs)&&(clearTimeout(u(this,qs)),_(this,qs,null))),super.remove()}rebuild(){if(!this.parent){u(this,yn)&&M(this,re,Sg).call(this);return}super.rebuild(),this.div!==null&&(u(this,yn)&&u(this,Xs)===null&&M(this,re,Sg).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(u(this,Uo)||u(this,Me)||u(this,Nr)||u(this,Vo)||u(this,yn))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,n;if(this.width&&(e=this.x,n=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),u(this,Me)?M(this,re,Lv).call(this):M(this,re,Sg).call(this),this.width&&!this.annotationElementId){const[s,o]=this.parentDimensions;this.setAt(e*s,n*o,this.width*s,this.height*o)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;u(this,qs)!==null&&clearTimeout(u(this,qs)),_(this,qs,setTimeout(()=>{_(this,qs,null),M(this,re,Iv).call(this)},200))}copyCanvas(e,n,s=!1){var x;e||(e=224);const{width:o,height:l}=u(this,Me),c=new My;let d=u(this,Me),f=o,g=l,m=null;if(n){if(o>n||l>n){const H=Math.min(n/o,n/l);f=Math.floor(o*H),g=Math.floor(l*H)}m=document.createElement("canvas");const b=m.width=Math.ceil(f*c.sx),A=m.height=Math.ceil(g*c.sy);u(this,Ai)||(d=M(this,re,Ag).call(this,b,A));const C=m.getContext("2d");C.filter=this._uiManager.hcmFilter;let E="white",N="#cfcfd8";this._uiManager.hcmFilter!=="none"?N="black":(x=window.matchMedia)!=null&&x.call(window,"(prefers-color-scheme: dark)").matches&&(E="#8f8f9d",N="#42414d");const k=15,L=k*c.sx,R=k*c.sy,j=new OffscreenCanvas(L*2,R*2),O=j.getContext("2d");O.fillStyle=E,O.fillRect(0,0,L*2,R*2),O.fillStyle=N,O.fillRect(0,0,L,R),O.fillRect(L,R,L,R),C.fillStyle=C.createPattern(j,"repeat"),C.fillRect(0,0,b,A),C.drawImage(d,0,0,d.width,d.height,0,0,b,A)}let y=null;if(s){let b,A;if(c.symmetric&&d.width<e&&d.height<e)b=d.width,A=d.height;else if(d=u(this,Me),o>e||l>e){const N=Math.min(e/o,e/l);b=Math.floor(o*N),A=Math.floor(l*N),u(this,Ai)||(d=M(this,re,Ag).call(this,b,A))}const E=new OffscreenCanvas(b,A).getContext("2d",{willReadFrequently:!0});E.drawImage(d,0,0,d.width,d.height,0,0,b,A),y={width:b,height:A,data:E.getImageData(0,0,b,A).data}}return{canvas:m,width:f,height:g,imageData:y}}getImageForAltText(){return u(this,Xs)}static async deserialize(e,n,s){var A;let o=null;if(e instanceof CA){const{data:{rect:C,rotation:E,id:N,structParent:k,popupRef:L},container:R,parent:{page:{pageNumber:j}}}=e,O=R.querySelector("canvas"),H=s.imageManager.getFromCanvas(R.id,O);O.remove();const X=((A=await n._structTree.getAriaAttributes(`${Qv}${N}`))==null?void 0:A.get("aria-label"))||"";o=e={annotationType:Bt.STAMP,bitmapId:H.id,bitmap:H.bitmap,pageIndex:j-1,rect:C.slice(0),rotation:E,id:N,deleted:!1,accessibilityData:{decorative:!1,altText:X},isSvg:!1,structParent:k,popupRef:L}}const l=await super.deserialize(e,n,s),{rect:c,bitmap:d,bitmapUrl:f,bitmapId:g,isSvg:m,accessibilityData:y}=e;g&&s.imageManager.isValidId(g)?(_(l,yn,g),d&&_(l,Me,d)):_(l,Nr,f),_(l,Ai,m);const[x,b]=l.pageDimensions;return l.width=(c[2]-c[0])/x,l.height=(c[3]-c[1])/b,l.annotationElementId=e.id||null,y&&(l.altTextData=y),l._initialData=o,_(l,ku,!!o),l}serialize(e=!1,n=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s={annotationType:Bt.STAMP,bitmapId:u(this,yn),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:u(this,Ai),structTreeParentId:this._structTreeParentId};if(e)return s.bitmapUrl=M(this,re,_g).call(this,!0),s.accessibilityData=this.serializeAltText(!0),s;const{decorative:o,altText:l}=this.serializeAltText(!1);if(!o&&l&&(s.accessibilityData={type:"Figure",alt:l}),this.annotationElementId){const d=M(this,re,o_).call(this,s);if(d.isSame)return null;d.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,n===null)return s;n.stamps||(n.stamps=new Map);const c=u(this,Ai)?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!n.stamps.has(u(this,yn)))n.stamps.set(u(this,yn),{area:c,serialized:s}),s.bitmap=M(this,re,_g).call(this,!1);else if(u(this,Ai)){const d=n.stamps.get(u(this,yn));c>d.area&&(d.area=c,d.serialized.bitmap.close(),d.serialized.bitmap=M(this,re,_g).call(this,!1))}return s}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Me=new WeakMap,yn=new WeakMap,Uo=new WeakMap,Nr=new WeakMap,Vo=new WeakMap,Eu=new WeakMap,Xs=new WeakMap,qs=new WeakMap,Ai=new WeakMap,ku=new WeakMap,re=new WeakSet,$h=function(e,n=!1){if(!e){this.remove();return}_(this,Me,e.bitmap),n||(_(this,yn,e.id),_(this,Ai,e.isSvg)),e.file&&_(this,Eu,e.file.name),M(this,re,Lv).call(this)},zh=function(){if(_(this,Uo,null),this._uiManager.enableWaiting(!1),!!u(this,Xs)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&u(this,Me)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&u(this,Me)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Sg=function(){if(u(this,yn)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(u(this,yn)).then(s=>M(this,re,$h).call(this,s,!0)).finally(()=>M(this,re,zh).call(this));return}if(u(this,Nr)){const s=u(this,Nr);_(this,Nr,null),this._uiManager.enableWaiting(!0),_(this,Uo,this._uiManager.imageManager.getFromUrl(s).then(o=>M(this,re,$h).call(this,o)).finally(()=>M(this,re,zh).call(this)));return}if(u(this,Vo)){const s=u(this,Vo);_(this,Vo,null),this._uiManager.enableWaiting(!0),_(this,Uo,this._uiManager.imageManager.getFromFile(s).then(o=>M(this,re,$h).call(this,o)).finally(()=>M(this,re,zh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Gh.supportedTypesStr;const n=this._uiManager._signal;_(this,Uo,new Promise(s=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const o=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),M(this,re,$h).call(this,o)}s()},{signal:n}),e.addEventListener("cancel",()=>{this.remove(),s()},{signal:n})}).finally(()=>M(this,re,zh).call(this))),e.click()},Lv=function(){var m;const{div:e}=this;let{width:n,height:s}=u(this,Me);const[o,l]=this.pageDimensions,c=.75;if(this.width)n=this.width*o,s=this.height*l;else if(n>c*o||s>c*l){const y=Math.min(c*o/n,c*l/s);n*=y,s*=y}const[d,f]=this.parentDimensions;this.setDims(n*d/o,s*f/l),this._uiManager.enableWaiting(!1);const g=_(this,Xs,document.createElement("canvas"));g.setAttribute("role","img"),this.addContainer(g),this.width=n/o,this.height=s/l,(m=this._initialOptions)!=null&&m.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),M(this,re,Iv).call(this),u(this,ku)||(this.parent.addUndoableEditor(this),_(this,ku,!0)),this._reportTelemetry({action:"inserted_image"}),u(this,Eu)&&g.setAttribute("aria-label",u(this,Eu))},Ag=function(e,n){const{width:s,height:o}=u(this,Me);let l=s,c=o,d=u(this,Me);for(;l>2*e||c>2*n;){const f=l,g=c;l>2*e&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2)),c>2*n&&(c=c>=16384?Math.floor(c/2)-1:Math.ceil(c/2));const m=new OffscreenCanvas(l,c);m.getContext("2d").drawImage(d,0,0,f,g,0,0,l,c),d=m.transferToImageBitmap()}return d},Iv=function(){const[e,n]=this.parentDimensions,{width:s,height:o}=this,l=new My,c=Math.ceil(s*e*l.sx),d=Math.ceil(o*n*l.sy),f=u(this,Xs);if(!f||f.width===c&&f.height===d)return;f.width=c,f.height=d;const g=u(this,Ai)?u(this,Me):M(this,re,Ag).call(this,c,d),m=f.getContext("2d");m.filter=this._uiManager.hcmFilter,m.drawImage(g,0,0,g.width,g.height,0,0,c,d)},_g=function(e){if(e){if(u(this,Ai)){const o=this._uiManager.imageManager.getSvgUrl(u(this,yn));if(o)return o}const n=document.createElement("canvas");return{width:n.width,height:n.height}=u(this,Me),n.getContext("2d").drawImage(u(this,Me),0,0),n.toDataURL()}if(u(this,Ai)){const[n,s]=this.pageDimensions,o=Math.round(this.width*n*ta.PDF_TO_CSS_UNITS),l=Math.round(this.height*s*ta.PDF_TO_CSS_UNITS),c=new OffscreenCanvas(o,l);return c.getContext("2d").drawImage(u(this,Me),0,0,u(this,Me).width,u(this,Me).height,0,0,o,l),c.transferToImageBitmap()}return structuredClone(u(this,Me))},o_=function(e){var c;const{pageIndex:n,accessibilityData:{altText:s}}=this._initialData,o=e.pageIndex===n,l=(((c=e.accessibilityData)==null?void 0:c.alt)||"")===s;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&o&&l,isSameAltText:l}},It(Gh,"_type","stamp"),It(Gh,"_editorType",Bt.STAMP);let Nv=Gh;var Tl,Cu,Ys,Wo,Lr,Wi,Go,Tu,Pl,ms,Ir,Mn,Dr,Tt,Xo,Ee,a_,Ns,Fv,Ov,Eg;const ss=class ss{constructor({uiManager:t,pageIndex:e,div:n,structTreeLayer:s,accessibilityManager:o,annotationLayer:l,drawLayer:c,textLayer:d,viewport:f,l10n:g}){P(this,Ee);P(this,Tl);P(this,Cu,!1);P(this,Ys,null);P(this,Wo,null);P(this,Lr,null);P(this,Wi,new Map);P(this,Go,!1);P(this,Tu,!1);P(this,Pl,!1);P(this,ms,null);P(this,Ir,null);P(this,Mn,null);P(this,Dr,null);P(this,Tt);const m=[...u(ss,Xo).values()];if(!ss._initialized){ss._initialized=!0;for(const y of m)y.initialize(g,t)}t.registerEditorTypes(m),_(this,Tt,t),this.pageIndex=e,this.div=n,_(this,Tl,o),_(this,Ys,l),this.viewport=f,_(this,Mn,d),this.drawLayer=c,this._structTree=s,u(this,Tt).addLayer(this)}get isEmpty(){return u(this,Wi).size===0}get isInvisible(){return this.isEmpty&&u(this,Tt).getMode()===Bt.NONE}updateToolbar(t){u(this,Tt).updateToolbar(t)}updateMode(t=u(this,Tt).getMode()){switch(M(this,Ee,Eg).call(this),t){case Bt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Bt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Bt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const n of u(ss,Xo).values())e.toggle(`${n._type}Editing`,t===n._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=u(this,Mn))==null?void 0:e.div)}setEditingState(t){u(this,Tt).setEditingState(t)}addCommands(t){u(this,Tt).addCommands(t)}cleanUndoStack(t){u(this,Tt).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=u(this,Ys))==null||e.div.classList.toggle("disabled",!t)}async enable(){_(this,Pl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const n of u(this,Wi).values())n.enableEditing(),n.show(!0),n.annotationElementId&&(u(this,Tt).removeChangedExistingAnnotation(n),t.add(n.annotationElementId));if(!u(this,Ys)){_(this,Pl,!1);return}const e=u(this,Ys).getEditableAnnotations();for(const n of e){if(n.hide(),u(this,Tt).isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;const s=await this.deserialize(n);s&&(this.addOrRebuild(s),s.enableEditing())}_(this,Pl,!1)}disable(){var s;_(this,Tu,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const o of u(this,Wi).values())if(o.disableEditing(),!!o.annotationElementId){if(o.serialize()!==null){t.set(o.annotationElementId,o);continue}else e.set(o.annotationElementId,o);(s=this.getEditableAnnotation(o.annotationElementId))==null||s.show(),o.remove()}if(u(this,Ys)){const o=u(this,Ys).getEditableAnnotations();for(const l of o){const{id:c}=l.data;if(u(this,Tt).isDeletedAnnotationElement(c))continue;let d=e.get(c);if(d){d.resetAnnotationElement(l),d.show(!1),l.show();continue}d=t.get(c),d&&(u(this,Tt).addChangedExistingAnnotation(d),d.renderAnnotationElement(l)&&d.show(!1)),l.show()}}M(this,Ee,Eg).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const o of u(ss,Xo).values())n.remove(`${o._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),_(this,Tu,!1)}getEditableAnnotation(t){var e;return((e=u(this,Ys))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){u(this,Tt).getActive()!==t&&u(this,Tt).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=u(this,Mn))!=null&&t.div&&!u(this,Dr)){_(this,Dr,new AbortController);const e=u(this,Tt).combinedSignal(u(this,Dr));u(this,Mn).div.addEventListener("pointerdown",M(this,Ee,a_).bind(this),{signal:e}),u(this,Mn).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=u(this,Mn))!=null&&t.div&&u(this,Dr)&&(u(this,Dr).abort(),_(this,Dr,null),u(this,Mn).div.classList.remove("highlighting"))}enableClick(){if(u(this,Wo))return;_(this,Wo,new AbortController);const t=u(this,Tt).combinedSignal(u(this,Wo));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=u(this,Wo))==null||t.abort(),_(this,Wo,null)}attach(t){u(this,Wi).set(t.id,t);const{annotationElementId:e}=t;e&&u(this,Tt).isDeletedAnnotationElement(e)&&u(this,Tt).removeDeletedAnnotationElement(t)}detach(t){var e;u(this,Wi).delete(t.id),(e=u(this,Tl))==null||e.removePointerInTextLayer(t.contentDiv),!u(this,Tu)&&t.annotationElementId&&u(this,Tt).addDeletedAnnotationElement(t)}remove(t){this.detach(t),u(this,Tt).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(u(this,Tt).addDeletedAnnotationElement(t.annotationElementId),Re.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),u(this,Tt).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!u(this,Pl)),u(this,Tt).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var n;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!u(this,Lr)&&(t._focusEventsAllowed=!1,_(this,Lr,setTimeout(()=>{_(this,Lr,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:u(this,Tt)._signal}),e.focus())},0))),t._structTreeParentId=(n=u(this,Tl))==null?void 0:n.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),n=()=>{t.remove()};this.addCommands({cmd:e,undo:n,mustExec:!1})}getNextId(){return u(this,Tt).getId()}combinedSignal(t){return u(this,Tt).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=u(this,Ee,Ns))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){u(this,Tt).updateToolbar(t),u(this,Tt).updateMode(t);const{offsetX:n,offsetY:s}=M(this,Ee,Ov).call(this),o=this.getNextId(),l=M(this,Ee,Fv).call(this,{parent:this,id:o,x:n,y:s,uiManager:u(this,Tt),isCentered:!0,...e});l&&this.add(l)}async deserialize(t){var e;return await((e=u(ss,Xo).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,u(this,Tt)))||null}createAndAddNewEditor(t,e,n={}){const s=this.getNextId(),o=M(this,Ee,Fv).call(this,{parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:u(this,Tt),isCentered:e,...n});return o&&this.add(o),o}addNewEditor(){this.createAndAddNewEditor(M(this,Ee,Ov).call(this),!0)}setSelected(t){u(this,Tt).setSelected(t)}toggleSelected(t){u(this,Tt).toggleSelected(t)}unselect(t){u(this,Tt).unselect(t)}pointerup(t){var n;const{isMac:e}=Wn.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&u(this,Go)&&(_(this,Go,!1),!((n=u(this,Ee,Ns))!=null&&n.isDrawer&&u(this,Ee,Ns).supportMultipleDrawings))){if(!u(this,Cu)){_(this,Cu,!0);return}if(u(this,Tt).getMode()===Bt.STAMP){u(this,Tt).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){var s;if(u(this,Tt).getMode()===Bt.HIGHLIGHT&&this.enableTextSelection(),u(this,Go)){_(this,Go,!1);return}const{isMac:e}=Wn.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(_(this,Go,!0),(s=u(this,Ee,Ns))!=null&&s.isDrawer){this.startDrawingSession(t);return}const n=u(this,Tt).getActive();_(this,Cu,!n||n.isEmpty())}startDrawingSession(t){if(this.div.focus(),u(this,ms)){u(this,Ee,Ns).startDrawing(this,u(this,Tt),!1,t);return}u(this,Tt).setCurrentDrawingSession(this),_(this,ms,new AbortController);const e=u(this,Tt).combinedSignal(u(this,ms));this.div.addEventListener("blur",({relatedTarget:n})=>{n&&!this.div.contains(n)&&(_(this,Ir,null),this.commitOrRemove())},{signal:e}),u(this,Ee,Ns).startDrawing(this,u(this,Tt),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&_(this,Ir,e);return}u(this,Ir)&&setTimeout(()=>{var e;(e=u(this,Ir))==null||e.focus(),_(this,Ir,null)},0)}endDrawingSession(t=!1){return u(this,ms)?(u(this,Tt).setCurrentDrawingSession(null),u(this,ms).abort(),_(this,ms,null),_(this,Ir,null),u(this,Ee,Ns).endDrawing(t)):null}findNewParent(t,e,n){const s=u(this,Tt).findParent(e,n);return s===null||s===this?!1:(s.changeParent(t),!0)}commitOrRemove(){return u(this,ms)?(this.endDrawingSession(),!0):!1}onScaleChanging(){u(this,ms)&&u(this,Ee,Ns).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=u(this,Tt).getActive())==null?void 0:t.parent)===this&&(u(this,Tt).commitOrRemove(),u(this,Tt).setActiveEditor(null)),u(this,Lr)&&(clearTimeout(u(this,Lr)),_(this,Lr,null));for(const n of u(this,Wi).values())(e=u(this,Tl))==null||e.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,u(this,Wi).clear(),u(this,Tt).removeLayer(this)}render({viewport:t}){this.viewport=t,Nl(this.div,t);for(const e of u(this,Tt).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){u(this,Tt).commitOrRemove(),M(this,Ee,Eg).call(this);const e=this.viewport.rotation,n=t.rotation;if(this.viewport=t,Nl(this.div,{rotation:n}),e!==n)for(const s of u(this,Wi).values())s.rotate(n)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return u(this,Tt).viewParameters.realScale}};Tl=new WeakMap,Cu=new WeakMap,Ys=new WeakMap,Wo=new WeakMap,Lr=new WeakMap,Wi=new WeakMap,Go=new WeakMap,Tu=new WeakMap,Pl=new WeakMap,ms=new WeakMap,Ir=new WeakMap,Mn=new WeakMap,Dr=new WeakMap,Tt=new WeakMap,Xo=new WeakMap,Ee=new WeakSet,a_=function(t){u(this,Tt).unselectAll();const{target:e}=t;if(e===u(this,Mn).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&u(this,Mn).div.contains(e)){const{isMac:n}=Wn.platform;if(t.button!==0||t.ctrlKey&&n)return;u(this,Tt).showAllEditors("highlight",!0,!0),u(this,Mn).div.classList.add("free"),this.toggleDrawing(),Dg.startHighlighting(this,u(this,Tt).direction==="ltr",{target:u(this,Mn).div,x:t.x,y:t.y}),u(this,Mn).div.addEventListener("pointerup",()=>{u(this,Mn).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:u(this,Tt)._signal}),t.preventDefault()}},Ns=function(){return u(ss,Xo).get(u(this,Tt).getMode())},Fv=function(t){const e=u(this,Ee,Ns);return e?new e.prototype.constructor(t):null},Ov=function(){const{x:t,y:e,width:n,height:s}=this.div.getBoundingClientRect(),o=Math.max(0,t),l=Math.max(0,e),c=Math.min(window.innerWidth,t+n),d=Math.min(window.innerHeight,e+s),f=(o+c)/2-t,g=(l+d)/2-e,[m,y]=this.viewport.rotation%180===0?[f,g]:[g,f];return{offsetX:m,offsetY:y}},Eg=function(){for(const t of u(this,Wi).values())t.isEmpty()&&t.remove()},It(ss,"_initialized",!1),P(ss,Xo,new Map([mv,Rv,Nv,Dg].map(t=>[t._editorType,t])));let Dv=ss;var ys,_f,Vn,Ml,am,l_,Ks,$v,c_,zv;const kn=class kn{constructor({pageIndex:t}){P(this,Ks);P(this,ys,null);P(this,_f,0);P(this,Vn,new Map);P(this,Ml,new Map);this.pageIndex=t}setParent(t){if(!u(this,ys)){_(this,ys,t);return}if(u(this,ys)!==t){if(u(this,Vn).size>0)for(const e of u(this,Vn).values())e.remove(),t.append(e);_(this,ys,t)}}static get _svgFactory(){return Kt(this,"_svgFactory",new sx)}draw(t,e=!1,n=!1){const s=$n(this,_f)._++,o=M(this,Ks,$v).call(this),l=kn._svgFactory.createElement("defs");o.append(l);const c=kn._svgFactory.createElement("path");l.append(c);const d=`path_p${this.pageIndex}_${s}`;c.setAttribute("id",d),c.setAttribute("vector-effect","non-scaling-stroke"),e&&u(this,Ml).set(s,c);const f=n?M(this,Ks,c_).call(this,l,d):null,g=kn._svgFactory.createElement("use");return o.append(g),g.setAttribute("href",`#${d}`),this.updateProperties(o,t),u(this,Vn).set(s,o),{id:s,clipPathId:`url(#${f})`}}drawOutline(t,e){const n=$n(this,_f)._++,s=M(this,Ks,$v).call(this),o=kn._svgFactory.createElement("defs");s.append(o);const l=kn._svgFactory.createElement("path");o.append(l);const c=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",c),l.setAttribute("vector-effect","non-scaling-stroke");let d;if(e){const m=kn._svgFactory.createElement("mask");o.append(m),d=`mask_p${this.pageIndex}_${n}`,m.setAttribute("id",d),m.setAttribute("maskUnits","objectBoundingBox");const y=kn._svgFactory.createElement("rect");m.append(y),y.setAttribute("width","1"),y.setAttribute("height","1"),y.setAttribute("fill","white");const x=kn._svgFactory.createElement("use");m.append(x),x.setAttribute("href",`#${c}`),x.setAttribute("stroke","none"),x.setAttribute("fill","black"),x.setAttribute("fill-rule","nonzero"),x.classList.add("mask")}const f=kn._svgFactory.createElement("use");s.append(f),f.setAttribute("href",`#${c}`),d&&f.setAttribute("mask",`url(#${d})`);const g=f.cloneNode();return s.append(g),f.classList.add("mainOutline"),g.classList.add("secondaryOutline"),this.updateProperties(s,t),u(this,Vn).set(n,s),n}finalizeDraw(t,e){u(this,Ml).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var d;if(!e)return;const{root:n,bbox:s,rootClass:o,path:l}=e,c=typeof t=="number"?u(this,Vn).get(t):t;if(c){if(n&&M(this,Ks,zv).call(this,c,n),s&&M(d=kn,am,l_).call(d,c,s),o){const{classList:f}=c;for(const[g,m]of Object.entries(o))f.toggle(g,m)}if(l){const g=c.firstChild.firstChild;M(this,Ks,zv).call(this,g,l)}}}updateParent(t,e){if(e===this)return;const n=u(this,Vn).get(t);n&&(u(e,ys).append(n),u(this,Vn).delete(t),u(e,Vn).set(t,n))}remove(t){u(this,Ml).delete(t),u(this,ys)!==null&&(u(this,Vn).get(t).remove(),u(this,Vn).delete(t))}destroy(){_(this,ys,null);for(const t of u(this,Vn).values())t.remove();u(this,Vn).clear(),u(this,Ml).clear()}};ys=new WeakMap,_f=new WeakMap,Vn=new WeakMap,Ml=new WeakMap,am=new WeakSet,l_=function(t,[e,n,s,o]){const{style:l}=t;l.top=`${100*n}%`,l.left=`${100*e}%`,l.width=`${100*s}%`,l.height=`${100*o}%`},Ks=new WeakSet,$v=function(){const t=kn._svgFactory.create(1,1,!0);return u(this,ys).append(t),t.setAttribute("aria-hidden",!0),t},c_=function(t,e){const n=kn._svgFactory.createElement("clipPath");t.append(n);const s=`clip_${e}`;n.setAttribute("id",s),n.setAttribute("clipPathUnits","objectBoundingBox");const o=kn._svgFactory.createElement("use");return n.append(o),o.setAttribute("href",`#${e}`),o.classList.add("clip"),s},zv=function(t,e){for(const[n,s]of Object.entries(e))s===null?t.removeAttribute(n):t.setAttribute(n,s)},P(kn,am);let jv=kn;globalThis.pdfjsTestingUtils={HighlightOutliner:vv};jt.AbortException;jt.AnnotationEditorLayer;jt.AnnotationEditorParamsType;jt.AnnotationEditorType;jt.AnnotationEditorUIManager;jt.AnnotationLayer;jt.AnnotationMode;jt.ColorPicker;jt.DOMSVGFactory;jt.DrawLayer;jt.FeatureTest;var YP=jt.GlobalWorkerOptions;jt.ImageKind;jt.InvalidPDFException;jt.MissingPDFException;jt.OPS;jt.OutputScale;jt.PDFDataRangeTransport;jt.PDFDateString;jt.PDFWorker;jt.PasswordResponses;jt.PermissionFlag;jt.PixelsPerInch;jt.RenderingCancelledException;jt.TextLayer;jt.TouchManager;jt.UnexpectedResponseException;jt.Util;jt.VerbosityLevel;jt.XfaLayer;jt.build;jt.createValidAbsoluteUrl;jt.fetchData;var u_=jt.getDocument;jt.getFilenameFromUrl;jt.getPdfFilenameFromUrl;jt.getXfaPageViewport;jt.isDataScheme;jt.isPdfFile;jt.noContextMenu;jt.normalizeUnicode;jt.setLayerDimensions;jt.shadow;jt.stopEvent;jt.version;const KP="/assets/pdf.worker.min-yatZIOMy.mjs";/**
79
+ * @license lucide-react v1.23.0 - ISC
80
+ *
81
+ * This source code is licensed under the ISC license.
82
+ * See the LICENSE file in the root directory of this source tree.
83
+ */const h_=(...a)=>a.filter((t,e,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===e).join(" ").trim();/**
84
+ * @license lucide-react v1.23.0 - ISC
85
+ *
86
+ * This source code is licensed under the ISC license.
87
+ * See the LICENSE file in the root directory of this source tree.
88
+ */const QP=a=>a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
89
+ * @license lucide-react v1.23.0 - ISC
90
+ *
91
+ * This source code is licensed under the ISC license.
92
+ * See the LICENSE file in the root directory of this source tree.
93
+ */const JP=a=>a.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,e,n)=>n?n.toUpperCase():e.toLowerCase());/**
94
+ * @license lucide-react v1.23.0 - ISC
95
+ *
96
+ * This source code is licensed under the ISC license.
97
+ * See the LICENSE file in the root directory of this source tree.
98
+ */const Nb=a=>{const t=JP(a);return t.charAt(0).toUpperCase()+t.slice(1)};/**
99
+ * @license lucide-react v1.23.0 - ISC
100
+ *
101
+ * This source code is licensed under the ISC license.
102
+ * See the LICENSE file in the root directory of this source tree.
103
+ */var my={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
104
+ * @license lucide-react v1.23.0 - ISC
105
+ *
106
+ * This source code is licensed under the ISC license.
107
+ * See the LICENSE file in the root directory of this source tree.
108
+ */const ZP=a=>{for(const t in a)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},tM=F.createContext({}),eM=()=>F.useContext(tM),nM=F.forwardRef(({color:a,size:t,strokeWidth:e,absoluteStrokeWidth:n,className:s="",children:o,iconNode:l,...c},d)=>{const{size:f=24,strokeWidth:g=2,absoluteStrokeWidth:m=!1,color:y="currentColor",className:x=""}=eM()??{},b=n??m?Number(e??g)*24/Number(t??f):e??g;return F.createElement("svg",{ref:d,...my,width:t??f??my.width,height:t??f??my.height,stroke:a??y,strokeWidth:b,className:h_("lucide",x,s),...!o&&!ZP(c)&&{"aria-hidden":"true"},...c},[...l.map(([A,C])=>F.createElement(A,C)),...Array.isArray(o)?o:[o]])});/**
109
+ * @license lucide-react v1.23.0 - ISC
110
+ *
111
+ * This source code is licensed under the ISC license.
112
+ * See the LICENSE file in the root directory of this source tree.
113
+ */const Gt=(a,t)=>{const e=F.forwardRef(({className:n,...s},o)=>F.createElement(nM,{ref:o,iconNode:t,className:h_(`lucide-${QP(Nb(a))}`,`lucide-${a}`,n),...s}));return e.displayName=Nb(a),e};/**
114
+ * @license lucide-react v1.23.0 - ISC
115
+ *
116
+ * This source code is licensed under the ISC license.
117
+ * See the LICENSE file in the root directory of this source tree.
118
+ */const iM=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],sM=Gt("bold",iM);/**
119
+ * @license lucide-react v1.23.0 - ISC
120
+ *
121
+ * This source code is licensed under the ISC license.
122
+ * See the LICENSE file in the root directory of this source tree.
123
+ */const rM=[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2",key:"yj20xf"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2",key:"1ltk23"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2",key:"1q24h9"}]],d_=Gt("bring-to-front",rM);/**
124
+ * @license lucide-react v1.23.0 - ISC
125
+ *
126
+ * This source code is licensed under the ISC license.
127
+ * See the LICENSE file in the root directory of this source tree.
128
+ */const oM=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],aM=Gt("check",oM);/**
129
+ * @license lucide-react v1.23.0 - ISC
130
+ *
131
+ * This source code is licensed under the ISC license.
132
+ * See the LICENSE file in the root directory of this source tree.
133
+ */const lM=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],cM=Gt("chevron-left",lM);/**
134
+ * @license lucide-react v1.23.0 - ISC
135
+ *
136
+ * This source code is licensed under the ISC license.
137
+ * See the LICENSE file in the root directory of this source tree.
138
+ */const uM=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],f_=Gt("chevron-right",uM);/**
139
+ * @license lucide-react v1.23.0 - ISC
140
+ *
141
+ * This source code is licensed under the ISC license.
142
+ * See the LICENSE file in the root directory of this source tree.
143
+ */const hM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],dM=Gt("circle-dot",hM);/**
144
+ * @license lucide-react v1.23.0 - ISC
145
+ *
146
+ * This source code is licensed under the ISC license.
147
+ * See the LICENSE file in the root directory of this source tree.
148
+ */const fM=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],pM=Gt("cloud-upload",fM);/**
149
+ * @license lucide-react v1.23.0 - ISC
150
+ *
151
+ * This source code is licensed under the ISC license.
152
+ * See the LICENSE file in the root directory of this source tree.
153
+ */const gM=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],mM=Gt("droplets",gM);/**
154
+ * @license lucide-react v1.23.0 - ISC
155
+ *
156
+ * This source code is licensed under the ISC license.
157
+ * See the LICENSE file in the root directory of this source tree.
158
+ */const yM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],vM=Gt("file-text",yM);/**
159
+ * @license lucide-react v1.23.0 - ISC
160
+ *
161
+ * This source code is licensed under the ISC license.
162
+ * See the LICENSE file in the root directory of this source tree.
163
+ */const xM=[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]],ox=Gt("highlighter",xM);/**
164
+ * @license lucide-react v1.23.0 - ISC
165
+ *
166
+ * This source code is licensed under the ISC license.
167
+ * See the LICENSE file in the root directory of this source tree.
168
+ */const wM=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],bM=Gt("image-plus",wM);/**
169
+ * @license lucide-react v1.23.0 - ISC
170
+ *
171
+ * This source code is licensed under the ISC license.
172
+ * See the LICENSE file in the root directory of this source tree.
173
+ */const SM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],AM=Gt("image",SM);/**
174
+ * @license lucide-react v1.23.0 - ISC
175
+ *
176
+ * This source code is licensed under the ISC license.
177
+ * See the LICENSE file in the root directory of this source tree.
178
+ */const _M=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],EM=Gt("italic",_M);/**
179
+ * @license lucide-react v1.23.0 - ISC
180
+ *
181
+ * This source code is licensed under the ISC license.
182
+ * See the LICENSE file in the root directory of this source tree.
183
+ */const kM=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],p_=Gt("link-2",kM);/**
184
+ * @license lucide-react v1.23.0 - ISC
185
+ *
186
+ * This source code is licensed under the ISC license.
187
+ * See the LICENSE file in the root directory of this source tree.
188
+ */const CM=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],TM=Gt("link",CM);/**
189
+ * @license lucide-react v1.23.0 - ISC
190
+ *
191
+ * This source code is licensed under the ISC license.
192
+ * See the LICENSE file in the root directory of this source tree.
193
+ */const PM=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],MM=Gt("list",PM);/**
194
+ * @license lucide-react v1.23.0 - ISC
195
+ *
196
+ * This source code is licensed under the ISC license.
197
+ * See the LICENSE file in the root directory of this source tree.
198
+ */const RM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],g_=Gt("lock",RM);/**
199
+ * @license lucide-react v1.23.0 - ISC
200
+ *
201
+ * This source code is licensed under the ISC license.
202
+ * See the LICENSE file in the root directory of this source tree.
203
+ */const NM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],m_=Gt("lock-open",NM);/**
204
+ * @license lucide-react v1.23.0 - ISC
205
+ *
206
+ * This source code is licensed under the ISC license.
207
+ * See the LICENSE file in the root directory of this source tree.
208
+ */const LM=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],IM=Gt("mouse-pointer-2",LM);/**
209
+ * @license lucide-react v1.23.0 - ISC
210
+ *
211
+ * This source code is licensed under the ISC license.
212
+ * See the LICENSE file in the root directory of this source tree.
213
+ */const DM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],FM=Gt("panel-top",DM);/**
214
+ * @license lucide-react v1.23.0 - ISC
215
+ *
216
+ * This source code is licensed under the ISC license.
217
+ * See the LICENSE file in the root directory of this source tree.
218
+ */const OM=[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]],jM=Gt("pilcrow",OM);/**
219
+ * @license lucide-react v1.23.0 - ISC
220
+ *
221
+ * This source code is licensed under the ISC license.
222
+ * See the LICENSE file in the root directory of this source tree.
223
+ */const $M=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],zM=Gt("redo-2",$M);/**
224
+ * @license lucide-react v1.23.0 - ISC
225
+ *
226
+ * This source code is licensed under the ISC license.
227
+ * See the LICENSE file in the root directory of this source tree.
228
+ */const HM=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],zr=Gt("rotate-ccw",HM);/**
229
+ * @license lucide-react v1.23.0 - ISC
230
+ *
231
+ * This source code is licensed under the ISC license.
232
+ * See the LICENSE file in the root directory of this source tree.
233
+ */const BM=[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]],y_=Gt("send-to-back",BM);/**
234
+ * @license lucide-react v1.23.0 - ISC
235
+ *
236
+ * This source code is licensed under the ISC license.
237
+ * See the LICENSE file in the root directory of this source tree.
238
+ */const UM=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],VM=Gt("send",UM);/**
239
+ * @license lucide-react v1.23.0 - ISC
240
+ *
241
+ * This source code is licensed under the ISC license.
242
+ * See the LICENSE file in the root directory of this source tree.
243
+ */const WM=[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]],GM=Gt("signature",WM);/**
244
+ * @license lucide-react v1.23.0 - ISC
245
+ *
246
+ * This source code is licensed under the ISC license.
247
+ * See the LICENSE file in the root directory of this source tree.
248
+ */const XM=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Hv=Gt("sparkles",XM);/**
249
+ * @license lucide-react v1.23.0 - ISC
250
+ *
251
+ * This source code is licensed under the ISC license.
252
+ * See the LICENSE file in the root directory of this source tree.
253
+ */const qM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],YM=Gt("square-check",qM);/**
254
+ * @license lucide-react v1.23.0 - ISC
255
+ *
256
+ * This source code is licensed under the ISC license.
257
+ * See the LICENSE file in the root directory of this source tree.
258
+ */const KM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]],QM=Gt("square-chevron-down",KM);/**
259
+ * @license lucide-react v1.23.0 - ISC
260
+ *
261
+ * This source code is licensed under the ISC license.
262
+ * See the LICENSE file in the root directory of this source tree.
263
+ */const JM=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],v_=Gt("text-align-center",JM);/**
264
+ * @license lucide-react v1.23.0 - ISC
265
+ *
266
+ * This source code is licensed under the ISC license.
267
+ * See the LICENSE file in the root directory of this source tree.
268
+ */const ZM=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],x_=Gt("text-align-end",ZM);/**
269
+ * @license lucide-react v1.23.0 - ISC
270
+ *
271
+ * This source code is licensed under the ISC license.
272
+ * See the LICENSE file in the root directory of this source tree.
273
+ */const t2=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],w_=Gt("text-align-start",t2);/**
274
+ * @license lucide-react v1.23.0 - ISC
275
+ *
276
+ * This source code is licensed under the ISC license.
277
+ * See the LICENSE file in the root directory of this source tree.
278
+ */const e2=[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]],b_=Gt("text-cursor-input",e2);/**
279
+ * @license lucide-react v1.23.0 - ISC
280
+ *
281
+ * This source code is licensed under the ISC license.
282
+ * See the LICENSE file in the root directory of this source tree.
283
+ */const n2=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Ur=Gt("trash-2",n2);/**
284
+ * @license lucide-react v1.23.0 - ISC
285
+ *
286
+ * This source code is licensed under the ISC license.
287
+ * See the LICENSE file in the root directory of this source tree.
288
+ */const i2=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],s2=Gt("type",i2);/**
289
+ * @license lucide-react v1.23.0 - ISC
290
+ *
291
+ * This source code is licensed under the ISC license.
292
+ * See the LICENSE file in the root directory of this source tree.
293
+ */const r2=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],o2=Gt("underline",r2);/**
294
+ * @license lucide-react v1.23.0 - ISC
295
+ *
296
+ * This source code is licensed under the ISC license.
297
+ * See the LICENSE file in the root directory of this source tree.
298
+ */const a2=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],l2=Gt("undo-2",a2);/**
299
+ * @license lucide-react v1.23.0 - ISC
300
+ *
301
+ * This source code is licensed under the ISC license.
302
+ * See the LICENSE file in the root directory of this source tree.
303
+ */const c2=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ax=Gt("x",c2);/**
304
+ * @license lucide-react v1.23.0 - ISC
305
+ *
306
+ * This source code is licensed under the ISC license.
307
+ * See the LICENSE file in the root directory of this source tree.
308
+ */const u2=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],h2=Gt("zoom-in",u2);/**
309
+ * @license lucide-react v1.23.0 - ISC
310
+ *
311
+ * This source code is licensed under the ISC license.
312
+ * See the LICENSE file in the root directory of this source tree.
313
+ */const d2=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],f2=Gt("zoom-out",d2);async function p2(a,t){const e=a.getReader(),n=new TextDecoder;let s="";for(;;){const{done:o,value:l}=await e.read();if(o)break;s+=n.decode(l,{stream:!0});let c;for(;(c=s.indexOf(`
314
+ `))>=0;){const d=s.slice(0,c).trim();if(s=s.slice(c+1),!d)continue;let f;try{f=JSON.parse(d)}catch{continue}t(f)}}}const ns=`${"/".replace(/\/+$/,"")}/api`;async function rr(a){if(!a.ok){const t=await a.json().catch(()=>null);throw new Error((t==null?void 0:t.error)||`${a.status} ${a.statusText}`)}return a.json()}const vs={list:()=>fetch(`${ns}/documents`).then(a=>rr(a)),upload:a=>{const t=new FormData;return t.append("pdf",a),fetch(`${ns}/documents`,{method:"POST",body:t}).then(e=>rr(e))},pdfUrl:a=>`${ns}/documents/${a}/pdf`,revert:a=>fetch(`${ns}/documents/${a}/revert`,{method:"POST"}).then(t=>rr(t)),saveEdits:(a,t)=>fetch(`${ns}/documents/${a}/edits`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({edits:t})}).then(e=>rr(e)),loadEdits:a=>fetch(`${ns}/documents/${a}/edits`).then(t=>rr(t)),createField:(a,t)=>fetch(`${ns}/documents/${a}/fields`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}).then(e=>rr(e)),docOp:(a,t,e)=>fetch(`${ns}/documents/${a}/ops`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:t,...e})}).then(n=>rr(n)),insertImage:(a,t,e)=>{const n=new FormData;return n.append("image",t),n.append("page",String(e.page)),n.append("x",String(e.x)),n.append("y",String(e.y)),fetch(`${ns}/documents/${a}/images`,{method:"POST",body:n}).then(s=>rr(s))},agentStream:async(a,t,e=[],n=[],s,o,l)=>{const c=await fetch(`${ns}/documents/${a}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({prompt:t,edits:e,imageEdits:n,resume:s,page:l})});if(!c.ok||!c.body){const g=await c.json().catch(()=>null);throw new Error((g==null?void 0:g.error)||`${c.status} ${c.statusText}`)}let d,f;if(await p2(c.body,g=>{g.type==="done"?d={sessionId:g.sessionId,toolCalls:g.toolCalls??0,edits:g.edits??[],imageEdits:g.imageEdits??[],reloaded:g.reloaded}:g.type==="error"?f=new Error(g.error||"El agente falló."):o(g)}),f)throw f;if(!d)throw new Error("El agente no devolvió un resultado.");return d},bake:(a,t,e=[],n=[],s=[],o=[],l=[])=>fetch(`${ns}/documents/${a}/bake`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({edits:t,imageEdits:e,widgetEdits:n,highlights:s,highlightEdits:o,linkEdits:l})}).then(c=>rr(c))},g2=a=>a>1024*1024?`${(a/1024/1024).toFixed(1)} MB`:`${Math.round(a/1024)} KB`;function m2(){const[a,t]=F.useState([]),[e,n]=F.useState(""),[s,o]=F.useState(!1),[l,c]=F.useState(!1),d=F.useRef(null),f=oS();F.useEffect(()=>{vs.list().then(t).catch(m=>n(m.message))},[]);const g=F.useCallback(async m=>{o(!0),n("");try{const y=await vs.upload(m);f(`/doc/${y.id}`)}catch(y){n(y instanceof Error?y.message:"No se pudo subir"),o(!1)}},[f]);return S.jsxs("div",{className:"mx-auto max-w-2xl px-6 py-16",children:[S.jsxs("header",{className:"mb-8 flex items-center gap-3",children:[S.jsx("span",{className:"grid h-11 w-11 place-items-center bg-blue-600 text-lg font-bold text-white",style:{clipPath:"polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%)"},children:"A"}),S.jsxs("div",{children:[S.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-neutral-900",children:"Aldus"}),S.jsx("p",{className:"text-[13px] text-neutral-500",children:"Edición pixel-perfect del grafo de contenido de un PDF."}),S.jsx("p",{className:"text-[11px] italic text-neutral-400",children:"God's in his heaven. All's right with the PDF."})]})]}),S.jsxs("div",{onClick:()=>{var m;return(m=d.current)==null?void 0:m.click()},onDragOver:m=>{m.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:m=>{m.preventDefault(),c(!1);const y=m.dataTransfer.files[0];y&&g(y)},className:`flex cursor-pointer flex-col items-center gap-3 rounded-2xl border-2 border-dashed px-6 py-14 text-center transition-colors ${l?"border-blue-500 bg-blue-50":"border-neutral-200 bg-white hover:border-blue-300 hover:bg-neutral-50"}`,children:[S.jsx(pM,{size:32,strokeWidth:1.6,className:"text-neutral-400"}),S.jsx("span",{className:"text-[14px] font-medium text-neutral-600",children:s?"Subiendo…":"Arrastrá un PDF o hacé click para elegirlo"}),S.jsx("input",{ref:d,type:"file",accept:"application/pdf",hidden:!0,onChange:m=>{var x;const y=(x=m.target.files)==null?void 0:x[0];y&&g(y)}})]}),e&&S.jsx("p",{className:"mt-4 text-[13px] text-red-600",children:e}),a.length>0&&S.jsx("ul",{className:"mt-8 space-y-2",children:a.map(m=>S.jsx("li",{children:S.jsxs(hS,{to:`/doc/${m.id}`,className:"group flex items-center gap-3 rounded-xl border border-neutral-200 bg-white px-4 py-3 transition-colors hover:border-blue-300 hover:bg-neutral-50",children:[S.jsx(vM,{size:18,className:"shrink-0 text-neutral-400"}),S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsx("span",{className:"block truncate text-[14px] font-medium text-neutral-800",children:m.name}),S.jsxs("span",{className:"block text-[12px] text-neutral-400",children:[g2(m.size)," · ",new Date(m.uploadedAt).toLocaleString()]})]}),S.jsx(f_,{size:16,className:"shrink-0 text-neutral-300 group-hover:text-blue-500"})]})},m.id))})]})}const y2={text:{width:160,height:20},checkbox:{width:14,height:14},radio:{width:14,height:14},select:{width:140,height:20},list:{width:140,height:60},button:{width:90,height:24},signature:{width:200,height:50}};function Lb(a){const t=a.width/Math.max(1,a.text.length);return Math.max(t,a.fontSize*.2)}function Jh(a,t,e){if(a<=0)return"none";const n=(Lb(t)+Lb(e))/2;return a>2*n?"column":a>.5*n?"space":"none"}function v2(a){const t=[];let e=[];for(const n of a){if(e.length===0){e.push(n);continue}const s=e[e.length-1],o=n.x-(s.x+s.width);Jh(o,s,n)==="column"?(t.push(e),e=[n]):e.push(n)}return e.length&&t.push(e),t}function x2(a){let t="";for(let e=0;e<a.length;e++){const n=a[e];if(e>0){const s=a[e-1],o=n.x-(s.x+s.width);Jh(o,s,n)==="space"&&!t.endsWith(" ")&&!n.text.startsWith(" ")&&(t+=" ")}t+=n.text}return t}function w2(a){const t=[];let e=0;for(;e<a.length;){const n=a[e];if(n.segments.length!==1){t.push(...n.segments),e++;continue}const s=[n.segments[0]];let o=e+1;for(;o<a.length;){const l=s[s.length-1],c=a[o].segments.length===1?a[o].segments[0]:null;if(!c)break;const d=l.baseline-c.baseline,f=l.fontSize*1.2;if(!(Math.abs(c.x-l.x)<=.5&&Math.abs(c.fontSize-l.fontSize)<=.1&&Math.abs(d-f)<=l.fontSize*.06))break;s.push(c),o++}if(s.length===1)t.push(s[0]);else{const l=s[0],c=s[s.length-1];t.push({...l,text:s.map(d=>d.text).join(`
315
+ `),runs:s.flatMap(d=>d.runs),width:Math.max(...s.map(d=>d.width)),y:c.y,height:l.y+l.height-c.y})}e=o}return t}function b2(a,t,e,n){const s=[];for(const o of a){if((o==null?void 0:o.subtype)!=="Link"||!Array.isArray(o.rect))continue;const l=o.url??o.unsafeUrl;if(!l)continue;const[c,d,f,g]=o.rect;s.push({id:`p${t}-link${s.length}`,kind:"link",page:t,url:l,x:Math.min(c,f)-e,y:Math.min(d,g)-n,width:Math.abs(f-c),height:Math.abs(g-d)})}return s}function S2(a,t,e,n){const s=[],o=l=>Math.max(0,Math.min(255,Math.round(l<=1?l*255:l))).toString(16).padStart(2,"0");for(const l of a){if((l==null?void 0:l.subtype)!=="Highlight"||!Array.isArray(l.rect))continue;const[c,d,f,g]=l.rect,m=l.color&&l.color.length>=3?l.color:null;s.push({id:`p${t}-hl${s.length}`,kind:"highlight",page:t,x:Math.min(c,f)-e,y:Math.min(d,g)-n,width:Math.abs(f-c),height:Math.abs(g-d),color:m?`#${o(m[0])}${o(m[1])}${o(m[2])}`:"#ffd400"})}return s}function A2(a){return a.fieldType==="Tx"?"text":a.fieldType==="Sig"?"signature":a.fieldType==="Ch"?a.combo?"select":"list":a.fieldType==="Btn"?a.checkBox?"checkbox":a.radioButton?"radio":"button":"text"}function _2(a,t,e,n){const s=[];for(const o of a){if((o==null?void 0:o.subtype)!=="Widget"||!Array.isArray(o.rect)||o.hidden)continue;const[l,c,d,f]=o.rect,g=A2(o);s.push({id:`p${t}-w${s.length}`,kind:"widget",page:t,fieldName:o.fieldName??"",widgetType:g,readOnly:o.readOnly===!0,options:(g==="select"||g==="list")&&Array.isArray(o.options)?o.options.map(m=>m.displayValue||m.exportValue||"").filter(Boolean):void 0,value:(()=>{const m=o.fieldValue;if(Array.isArray(m))return m.length?m:void 0;if(typeof m=="string"&&m&&m!=="Off")return m})(),x:Math.min(l,d)-e,y:Math.min(c,f)-n,width:Math.abs(d-l),height:Math.abs(f-c)})}return s}const E2=10,k2=11,C2=12,S_=85,T2=86,P2=83,A_=88,M2=new Set([S_,T2,P2,A_]),R2=(a,t)=>[a[0]*t[0]+a[1]*t[2],a[0]*t[1]+a[1]*t[3],a[2]*t[0]+a[3]*t[2],a[2]*t[1]+a[3]*t[3],a[4]*t[0]+a[5]*t[2]+t[4],a[4]*t[1]+a[5]*t[3]+t[5]];function N2(a,t,e,n,s){const o=[];let l=[1,0,0,1,0,0];const c=[],d=new Map;for(let f=0;f<a.length;f++){const g=a[f];if(g===E2)c.push(l);else if(g===k2)l=c.pop()??[1,0,0,1,0,0];else if(g===C2){const m=t[f];l=R2([m[0],m[1],m[2],m[3],m[4],m[5]],l)}else if(M2.has(g)){const[m,y,x,b,A,C]=l,E=[A,m+A,x+A,m+x+A],N=[C,y+C,b+C,y+b+C],k=Math.min(...E),L=Math.min(...N),R=t[f][0],j=(g===S_||g===A_)&&typeof R=="string"?R:void 0;let O;if(j){const H=d.get(j)??0;d.set(j,H+1),O=H===0?`p${e}-${j}`:`p${e}-${j}#${H}`}else O=`p${e}-img${o.length}`;o.push({id:O,kind:"image",page:e,x:k-n,y:L-s,width:Math.max(...E)-k,height:Math.max(...N)-L,rotated:Math.abs(y)>.01||Math.abs(x)>.01,objId:j})}}return o}function L2(a){const t=a.toLowerCase(),e=/bold|black|heavy|semibold|demibold|extrabold|-bd\b|,bd\b/.test(t),n=/italic|oblique/.test(t),s=/(mono|courier|consol|menlo|typewriter|fixed)/.test(t)?"mono":/(times|georgia|garamond|serif|roman|minion|antiqua|palatino|cambria|bodoni)/.test(t)?"serif":"sans";return{bold:e,italic:n,bucket:s}}function I2(a,t,e){const n=e.get(t);if(n)return n;let s=null;try{s=a.commonObjs.get(t)}catch{s=null}const o=(s==null?void 0:s.name)||(s==null?void 0:s.fallbackName)||t,l=L2(o),c={loadedName:t,postScriptName:o,bold:(s==null?void 0:s.bold)??l.bold,italic:(s==null?void 0:s.italic)??l.italic,bucket:l.bucket,ascent:typeof(s==null?void 0:s.ascent)=="number"&&s.ascent>0?s.ascent:.8,descent:typeof(s==null?void 0:s.descent)=="number"&&s.descent<0?s.descent:-.2,embedded:s!=null&&s.missingFile!==!0};return e.set(t,c),c}async function D2(a){const t=await a.getOperatorList(),e=await a.getTextContent({disableNormalization:!0}),n=await a.getAnnotations().catch(()=>[]),[s,o,l,c]=a.view,d=new Map,f=[];let g=0;for(const y of e.items){if(typeof y.str!="string"||y.str.trim().length===0)continue;const[x,b,A,C,E,N]=y.transform;f.push({id:`p${a.pageNumber}-r${g++}`,kind:"text",page:a.pageNumber,text:y.str,x:E-s,baseline:N-o,width:y.width,fontSize:Math.hypot(A,C),angle:Math.atan2(b,x),font:I2(a,y.fontName,d)})}const m=F2(f,a.pageNumber);return{page:a.pageNumber,width:l-s,height:c-o,runs:f,lines:m,segments:w2(m),images:N2(t.fnArray,t.argsArray,a.pageNumber,s,o),widgets:_2(n,a.pageNumber,s,o),links:b2(n,a.pageNumber,s,o),highlights:S2(n,a.pageNumber,s,o)}}function F2(a,t){const e=a.filter(l=>Math.abs(l.angle)<.01),n=a.filter(l=>Math.abs(l.angle)>=.01),s=[...e].sort((l,c)=>c.baseline-l.baseline||l.x-c.x),o=[];for(const l of s){const c=o[o.length-1],d=Math.max(1,l.fontSize*.35);c&&Math.abs(c[0].baseline-l.baseline)<=d?c.push(l):o.push([l])}for(const l of n)o.push([l]);return o.map((l,c)=>O2(l,t))}function Ib(a){const t=a[0].x,e=Math.max(...a.map(c=>c.x+c.width)),n=a[0].baseline,s=Math.max(...a.map(c=>c.fontSize)),o=Math.max(...a.map(c=>c.font.ascent*c.fontSize)),l=Math.min(...a.map(c=>c.font.descent*c.fontSize));return{x:t,baseline:n,width:e-t,y:n+l,height:o-l,fontSize:s}}function O2(a,t,e){const n=[...a].sort((l,c)=>l.x-c.x),s=`p${t}-y${Math.round(n[0].baseline)}`,o=v2(n).map(l=>({id:`${s}-x${Math.round(l[0].x)}`,kind:"segment",page:t,text:x2(l),runs:l,...Ib(l)}));return{id:s,kind:"line",page:t,text:o.map(l=>l.text).join(" "),segments:o,...Ib(n)}}const Db=["fontSize","font","x","baseline","remove","charSpacing","hScale","color","align"];function Pu(a){var s;const t=new Map;for(const o of a.runs){const l=Math.round(o.baseline*10)/10;t.set(l,[...t.get(l)??[],o])}const e=[...t.keys()].sort((o,l)=>l-o),n=[];for(let o=0;o<e.length;o++){const l=[...t.get(e[o])??[]].sort((c,d)=>c.x-d.x);o>0&&n.length&&(n[n.length-1].text+=`
316
+ `);for(let c=0;c<l.length;c++){const d=l[c];let f="";if(c>0){const m=l[c-1],y=d.x-(m.x+m.width);Jh(y,m,d)==="space"&&!((s=n[n.length-1])!=null&&s.text.endsWith(" "))&&!d.text.startsWith(" ")&&(f=" ")}const g=n[n.length-1];g&&g.bold===d.font.bold&&g.italic===d.font.italic&&g.color===d.color?g.text+=f+d.text:(g&&f&&(g.text+=f),n.push({text:d.text,bold:d.font.bold,italic:d.font.italic,color:d.color,dx:d.x-a.x}))}}return n}function __(a,t){if(a.length!==t.length)return!1;for(let e=0;e<a.length;e++)if(a[e].text!==t[e].text||a[e].bold!==t[e].bold||a[e].italic!==t[e].italic||a[e].color!==t[e].color||!!a[e].underline!=!!t[e].underline)return!1;return!0}const Rl=a=>a.map(t=>t.text).join("");function yy(a,t){const e=Rl(a);if(e===t)return a;if(!a.length)return t?[{text:t,bold:!1,italic:!1,dx:0}]:a;let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let s=0;for(;s<e.length-n&&s<t.length-n&&e[e.length-1-s]===t[t.length-1-s];)s++;const o=t.slice(n,t.length-s);let l=a[a.length-1],c=0;for(const x of a){if(n<c+x.text.length||n===c+x.text.length&&x===a[a.length-1]){l=x;break}c+=x.text.length}const d=[];let f=0;const g=x=>{const b=d[d.length-1];b&&C_(b,x)?b.text+=x.text:d.push({...x})};for(const x of a){if(f>=n)break;const b=Math.min(x.text.length,n-f);b>0&&g({...x,text:x.text.slice(0,b)}),f+=x.text.length}const m=e.slice(n,e.length-s);if(o&&m&&m.length*o.length<=25e4){const x=[];for(const C of a)for(let E=0;E<C.text.length;E++)x.push(C);let b;if(m.length===o.length)b=[...o].map((C,E)=>m[E]===C?E:null);else{const C=m.length,E=o.length,N=Array.from({length:C+1},()=>new Uint32Array(E+1));for(let k=C-1;k>=0;k--)for(let L=E-1;L>=0;L--)N[k][L]=m[k]===o[L]?N[k+1][L+1]+1:Math.max(N[k+1][L],N[k][L+1]);b=new Array(E).fill(null);for(let k=0,L=0;k<C&&L<E;)m[k]===o[L]?(b[L]=k,k++,L++):N[k+1][L]>=N[k][L+1]?k++:L++}let A=l;for(let C=0;C<o.length;C++){const E=b[C],N=E!=null?x[n+E]??A:A;E!=null&&(A=N),g({...N,text:o[C]})}}else o&&g({...l,text:o});const y=e.length-s;f=0;for(const x of a){const b=f+x.text.length;if(b>y){const A=Math.max(0,y-f);g({...x,text:x.text.slice(A)})}f=b}return d.filter(x=>x.text.length>0)}const E_=/^(\s*)(?:[•·▪‣*-]|\d{1,3}[.)]|[a-zA-Z][.)])(\s+)/,Bv=" ",Hh=a=>E_.test(a),Fb=a=>/^\s*(?:[•·▪‣*-]|\d{1,3}[.)]|[a-zA-Z][.)])\s*$/.test(a);function j2(a){if(!a.length)return a;const t=E_.exec(Rl(a));if(!t)return a.map((s,o)=>o===0?{...s,text:`•${Bv}${s.text}`}:s);let e=t[0].length;const n=[];for(const s of a){if(e>=s.text.length){e-=s.text.length;continue}n.push(e>0?{...s,text:s.text.slice(e)}:s),e=0}return n.length?n:a}function $2(a){const t=/^(\s*)(?:([•·▪‣*-])|(\d{1,3})([.)])|([a-z])([.)])|([A-Z])([.)]))(\s+)/.exec(a);if(!t)return null;const[,e,n,s,o,l,c,d,f,g]=t;return n?`${e}${n}${g}`:s?`${e}${Number(s)+1}${o}${g}`:l?`${e}${l==="z"?"a":String.fromCharCode(l.charCodeAt(0)+1)}${c}${g}`:d?`${e}${d==="Z"?"A":String.fromCharCode(d.charCodeAt(0)+1)}${f}${g}`:null}function k_(a,t,e){const n=[];let s=0;for(const o of a){const l=new Set([0,o.text.length]);for(const d of[t-s,e-s])d>0&&d<o.text.length&&l.add(d);const c=[...l].sort((d,f)=>d-f);for(let d=0;d<c.length-1;d++)n.push({run:{...o,text:o.text.slice(c[d],c[d+1])},from:s+c[d]});s+=o.text.length}return n}const C_=(a,t)=>a.bold===t.bold&&a.italic===t.italic&&a.color===t.color&&!!a.underline==!!t.underline;function T_(a,t){const e=[];for(const n of a){const s=e[e.length-1];s&&C_(s,n)?s.text+=n.text:e.push({...n,dx:0})}return e.length&&(e[0].dx=t),e}function Ob(a,t,e,n){var d;if(e<=t)return a;const s=k_(a,t,e),o=f=>f.from>=t&&f.from<e,l=s.filter(o);if(!l.length)return a;const c=!l.every(f=>f.run[n]);return T_(s.map(f=>o(f)?{...f.run,[n]:c}:f.run),((d=a[0])==null?void 0:d.dx)??0)}function z2(a,t,e,n){var c;if(e<=t)return a;const s=k_(a,t,e),o=d=>d.from>=t&&d.from<e;if(!s.some(o))return a;const l=d=>{const f={...d};return n.bold!==void 0&&(f.bold=n.bold),n.italic!==void 0&&(f.italic=n.italic),n.color!==void 0&&(n.color===null?delete f.color:f.color=n.color),f};return T_(s.map(d=>o(d)?l(d.run):d.run),((c=a[0])==null?void 0:c.dx)??0)}function P_(a){const t=a.runs.reduce((n,s)=>s.width>n.width?s:n),e=[...new Set(a.runs.map(n=>Math.round(n.baseline*10)/10))].sort((n,s)=>s-n);return{text:a.text,x:a.x,baseline:a.baseline,width:a.width,fontSize:a.fontSize,bucket:t.font.bucket,bold:t.font.bold,italic:t.font.italic,runs:[...a.runs].sort((n,s)=>n.x-s.x).map(n=>({x:n.x,bold:n.font.bold,italic:n.font.italic})),...e.length>1?{baselines:e}:{}}}function ka(a,t,e){const n=t?{...t}:{segmentId:a.id,page:a.page,text:a.text,original:P_(a)};e.runs!==void 0&&(e.runs===null?delete n.runs:n.runs=e.runs),e.text!==void 0&&(n.text=e.text),n.runs&&(__(n.runs,Pu(a))?delete n.runs:n.text=Rl(n.runs));for(const o of Db){const l=e[o];l!==void 0&&(l===null?delete n[o]:n[o]=l)}return n.text===a.text&&n.runs===void 0&&Db.every(o=>n[o]===void 0)?null:n}const jb=["x","y","width","height","remove","zOrder"];function Uh(a,t,e){const n=t?{...t}:{imageId:a.id,page:a.page,original:{x:a.x,y:a.y,width:a.width,height:a.height}};for(const s of jb){const o=e[s];o!==void 0&&(o===null?delete n[s]:n[s]=o)}return jb.every(s=>n[s]===void 0)?null:n}function H2(a){return a.map(t=>!t.remove&&!t.zOrder&&(t.x!=null||t.y!=null||t.width!=null||t.height!=null)?{...t,zOrder:"front"}:t)}function Og(a,t){return{x:(t==null?void 0:t.x)??a.x,y:(t==null?void 0:t.y)??a.y,width:(t==null?void 0:t.width)??a.width,height:(t==null?void 0:t.height)??a.height,removed:(t==null?void 0:t.remove)===!0,moved:(t==null?void 0:t.x)!==void 0||(t==null?void 0:t.y)!==void 0||(t==null?void 0:t.width)!==void 0||(t==null?void 0:t.height)!==void 0}}const $b=["x","y","width","height","remove"];function kg(a,t,e){const n=t?{...t}:{widgetId:a.id,page:a.page,original:{fieldName:a.fieldName,x:a.x,y:a.y,width:a.width,height:a.height}};for(const s of $b){const o=e[s];o!==void 0&&(o===null?delete n[s]:n[s]=o)}return $b.every(s=>n[s]===void 0)?null:n}function jg(a,t){return{x:(t==null?void 0:t.x)??a.x,y:(t==null?void 0:t.y)??a.y,width:(t==null?void 0:t.width)??a.width,height:(t==null?void 0:t.height)??a.height,removed:(t==null?void 0:t.remove)===!0}}const zb=["x","y","width","height","color","remove"];function yc(a,t,e){const n=t?{...t}:{highlightId:a.id,page:a.page,original:{x:a.x,y:a.y,width:a.width,height:a.height,color:a.color}};for(const s of zb){const o=e[s];o!==void 0&&(o===null?delete n[s]:n[s]=o)}return zb.every(s=>n[s]===void 0)?null:n}function $g(a,t){return{x:(t==null?void 0:t.x)??a.x,y:(t==null?void 0:t.y)??a.y,width:(t==null?void 0:t.width)??a.width,height:(t==null?void 0:t.height)??a.height,color:(t==null?void 0:t.color)??a.color,removed:(t==null?void 0:t.remove)===!0,moved:(t==null?void 0:t.x)!==void 0||(t==null?void 0:t.y)!==void 0}}const Hb=["x","y","width","height","remove"];function Vh(a,t,e){const n=t?{...t}:{linkId:a.id,page:a.page,original:{url:a.url,x:a.x,y:a.y,width:a.width,height:a.height}};for(const s of Hb){const o=e[s];o!==void 0&&(o===null?delete n[s]:n[s]=o)}return Hb.every(s=>n[s]===void 0)?null:n}function zg(a,t){return{x:(t==null?void 0:t.x)??a.x,y:(t==null?void 0:t.y)??a.y,width:(t==null?void 0:t.width)??a.width,height:(t==null?void 0:t.height)??a.height,removed:(t==null?void 0:t.remove)===!0,moved:(t==null?void 0:t.x)!==void 0||(t==null?void 0:t.y)!==void 0}}function Qo(a,t){const e=(t==null?void 0:t.fontSize)??a.fontSize,n=e/a.fontSize,s=(t==null?void 0:t.x)??a.x,o=(t==null?void 0:t.baseline)??a.baseline;return{x:s,baseline:o,fontSize:e,y:o+(a.y-a.baseline)*n,height:a.height*n,width:a.width,moved:(t==null?void 0:t.x)!==void 0||(t==null?void 0:t.baseline)!==void 0}}function Ln(a,t,e){return{left:a.x*e,top:(t-a.y-a.height)*e,width:a.width*e,height:a.height*e}}function B2(a,t,e,n){return{x:a/n,y:e-t/n}}var vy={};const U2=()=>{try{if(typeof process<"u"&&(vy!=null&&vy.ALDUS_DEBUG))return!0}catch{}try{if(typeof localStorage<"u"&&localStorage.getItem("aldusDebug"))return!0}catch{}return!1},lx=a=>(...t)=>{U2()&&console.log(`[${a}]`,...t)},Wp=lx("aldus:fonts"),Bb=new Set,vm=a=>`aldus-${a.replace(/[^\w-]/g,"_")}`;function V2(a,t){if(!(typeof FontFace>"u"))for(const e of t.segments)for(const n of e.runs){const s=n.font;if(!s.embedded||!s.postScriptName)continue;const o=vm(s.postScriptName);if(!Bb.has(o)){Bb.add(o);try{const l=a.commonObjs.get(s.loadedName);if(!(l!=null&&l.data)){Wp("SIN BYTES para",s.loadedName,s.postScriptName,"— fantasma caerá al bucket",s.bucket);continue}const c=new FontFace(o,l.data.slice());document.fonts.add(c),c.load().then(()=>Wp("registrada",o,"←",s.loadedName)).catch(d=>{document.fonts.delete(c),Wp("load FALLÓ",o,d)})}catch(l){Wp("commonObjs sin",s.loadedName,"(",s.postScriptName,")",l)}}}}const M_=" ",W2=new RegExp(M_,"g"),R_=a=>a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ {2,}/g,t=>M_.repeat(t.length)),_t=a=>Math.round(a*10)/10;function xm(a){return a==="serif"?"Georgia, 'Times New Roman', serif":a==="mono"?"'Courier New', Courier, monospace":"Helvetica, Arial, sans-serif"}const jl=a=>{const t=a.font.postScriptName?`'${vm(a.font.postScriptName)}',`:"";return`'${a.font.loadedName}',${t}${xm(a.font.bucket)}`};let xa=null;function Jo(a,t){if(xa===!1)return 0;if(!xa){try{xa=document.createElement("canvas").getContext("2d")??!1}catch{xa=!1}if(!xa)return 0}return xa.font=t,xa.measureText(a).width}function G2(a,t,e){if(!t.length||a.font.embedded&&typeof document<"u"&&"fonts"in document&&!(document.fonts.check(`12px '${a.font.loadedName}'`)||(a.font.postScriptName?document.fonts.check(`12px '${vm(a.font.postScriptName)}'`):!1)))return 0;const n=!a.font.embedded&&a.font.italic?"italic ":"",s=!a.font.embedded&&a.font.bold?"700 ":"",o=Jo(t,`${n}${s}${(a.fontSize*e).toFixed(2)}px ${jl(a)}`);if(o<=0)return 0;const l=(a.width*e-o)/t.length;return Math.abs(l)>a.fontSize*e*.4?0:l}function Mu(a){return a.runs.reduce((t,e)=>e.width>t.width?e:t)}function N_(a,t,e){const n=a.runs.find(s=>s.font.bold===t&&s.font.italic===e);return{base:n??Mu(a),exact:!!n}}function X2(a,t,e,n){const{base:s,exact:o}=N_(a,t.bold,t.italic),l=o?jl(s):xm(s.font.bucket),c=t.bold&&(!o||!s.font.embedded),d=t.italic&&(!o||!s.font.embedded),f=o?c?"font-weight:700;":"":`font-weight:${t.bold?700:400};`,g=o?d?"font-style:italic;":"":`font-style:${t.italic?"italic":"normal"};`,m=t.color??s.color,y=m?`color:${m};`:"",x=t.underline?"text-decoration:underline;":"";return`font-family:${l};font-size:${(s.fontSize*e*n).toFixed(2)}px;${y}${f}${g}${x}`}function L_(a,t,e){const{base:n,exact:s}=N_(a,t.bold,t.italic),o=s?jl(n):xm(n.font.bucket),l=t.italic&&(!s||!n.font.embedded)?"italic ":"",c=t.bold&&(!s||!n.font.embedded)?"700 ":"";return`${l}${c}${(n.fontSize*e).toFixed(2)}px ${o}`}function I_(a,t,e,n,s){const o=(d,f)=>Jo(f,L_(t,d,e)),l=[[]];for(const d of a)d.text.split(`
317
+ `).forEach((g,m)=>{m>0&&l.push([]),l[l.length-1].push({...d,text:g})});const c=[];return l.forEach((d,f)=>{if(f>0){const x=c[c.length-1];x?x.text+=`
318
+ `:c.push({text:`
319
+ `,bold:!1,italic:!1,dx:0})}const g=d.reduce((x,b)=>x+o(b,b.text),0);let y=s==="center"?Math.max(0,(n-g)/2):s==="right"?Math.max(0,n-g):0;for(const x of d){const b=o(x,x.text);c.push({...x,dx:_t(y),w:_t(b)}),y+=b}}),c.length?c:a}function q2(a,t,e=0,n=1){const s=!a.font.embedded&&a.font.bold?"font-weight:bold;":"",o=!a.font.embedded&&a.font.italic?"font-style:italic;":"",l=e!==0?`letter-spacing:${e.toFixed(3)}px;`:"",c=a.color?`color:${a.color};`:"";return`font-family:${jl(a)};font-size:${(a.fontSize*n*t).toFixed(2)}px;${c}${s}${o}${l}`}function Y2(a,t,e,n){return t.map(s=>`<span data-b="${s.bold?1:0}" data-i="${s.italic?1:0}"${s.color?` data-c="${s.color}"`:""} style="${X2(a,s,e,n)}">${R_(s.text)}</span>`).join("")||"<br>"}function Uv(a,t,e){const n=new Map;for(const d of a.runs){const f=Math.round(d.baseline*10)/10;n.set(f,[...n.get(f)??[],d])}const s=[...n.keys()].sort((d,f)=>f-d);if(s.length>1)return s.map(d=>Uv({...a,runs:n.get(d)??[]},t,e)).join(`
320
+ `);const o=a.runs,l=o.map(d=>d.text);for(let d=1;d<o.length;d++){const f=o[d-1],g=o[d].x-(f.x+f.width);Jh(g,f,o[d])==="space"&&!l[d-1].endsWith(" ")&&!l[d].startsWith(" ")&&(l[d-1]+=" ")}let c="";for(let d=0;d<o.length;d++){const f=o[d];let g="";if(d>0){const m=o[d-1],y=f.x-(m.x+m.width),x=Jh(y,m,f);if(x==="none"&&y>.5)g=`margin-left:${(y*e*t).toFixed(2)}px;`;else if(x!=="none"){const b=Jo(" ",`${(m.fontSize*e*t).toFixed(2)}px ${jl(m)}`),A=y*e*t-b;Math.abs(A)>.5&&(g=`margin-left:${A.toFixed(2)}px;`)}}c+=`<span data-b="${f.font.bold?1:0}" data-i="${f.font.italic?1:0}"${f.color?` data-c="${f.color}"`:""} style="${g}${q2(f,t,G2(f,f.text,t)*e,e)}">${R_(l[d])}</span>`}return c||"<br>"}function K2(a,t,e){if(t){const n=(t.fontSize??a.fontSize)/a.fontSize;if(t.text===a.text&&!t.runs&&t.font===void 0&&t.color===void 0&&t.charSpacing===void 0&&t.hScale===void 0)return Uv(a,e,n);const o=Mu(a),l=t.runs??[{text:t.text,bold:o.font.bold,italic:o.font.italic,dx:0}];return Y2(a,l,n,e)}return Uv(a,e,1)}function Q2(a){if(/^#([0-9a-f]{6})$/i.exec(a.trim()))return a.trim().toLowerCase();const e=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(a.trim());if(!e)return;const n=s=>Math.min(255,parseInt(s,10)).toString(16).padStart(2,"0");return`#${n(e[1])}${n(e[2])}${n(e[3])}`}function J2(a,t,e,n){const s=[],o=(Mu(t).color??"#000000").toLowerCase(),l=(g,m,y,x)=>{if(!g)return;const b=s[s.length-1];b&&b.bold===m&&b.italic===y&&b.color===x?b.text+=g:s.push({text:g,bold:m,italic:y,color:x})},c=(g,m,y,x)=>{if(g.nodeType===Node.TEXT_NODE){l((g.textContent??"").replace(W2," ").replace(/\n+/g," "),m,y,x);return}if(!(g instanceof HTMLElement)||g.tagName==="BR")return;let b=m,A=y,C=x;(g.tagName==="B"||g.tagName==="STRONG")&&(b=!0),(g.tagName==="I"||g.tagName==="EM")&&(A=!0);const E=g.style.fontWeight;E&&(b=E==="bold"||E==="bolder"||parseInt(E)>=600);const N=g.style.fontStyle;if(N&&(A=N==="italic"||N==="oblique"),g.dataset.b!==void 0&&(b=g.dataset.b==="1"),g.dataset.i!==void 0&&(A=g.dataset.i==="1"),g.dataset.c!==void 0)C=g.dataset.c||void 0;else if(g.style.color){const k=Q2(g.style.color);k&&k.toLowerCase()!==o&&(C=k)}g.childNodes.forEach(k=>c(k,b,A,C))};for(c(a,!1,!1,void 0);s.length&&/^\s+$/.test(s[s.length-1].text);)s.pop();s.length&&(s[s.length-1].text=s[s.length-1].text.replace(/\s+$/,""));const d=[];let f=0;for(const g of s)d.push({...g,dx:_t(f)}),f+=Jo(g.text,L_(t,g,e));return d}function Ub(a,t,e){const n=document.createRange();n.selectNodeContents(a);try{n.setEnd(t,e)}catch{return 0}return n.toString().length}function Z2(a,t){const e=(a.textContent??"").length,n=a.contains(t.startContainer)?Ub(a,t.startContainer,t.startOffset):0,s=a.contains(t.endContainer)?Ub(a,t.endContainer,t.endOffset):e;return{start:Math.min(n,s,e),end:Math.min(s,e)}}function go(){const a=document.activeElement;return a instanceof HTMLTextAreaElement&&a.classList.contains("seg-text")||a instanceof HTMLElement&&a.classList.contains("seg-text")&&a.isContentEditable?a:null}function tR(a,t,e){const n=window.getSelection(),s=n&&n.rangeCount>0?n.getRangeAt(0):null;if(!s||!a.contains(s.commonAncestorContainer))return null;const o=((e==null?void 0:e.fontSize)??t.fontSize)/t.fontSize,l=J2(a,t,o);let{start:c,end:d}=Z2(a,s);d<=c&&(c=Math.max(0,c-1),d=c+1);let f=!0,g=!0,m=!1,y=0;for(const x of l){const b=y,A=y+x.text.length;A>c&&b<d&&(m=!0,f=f&&x.bold,g=g&&x.italic),y=A}return m?{bold:f,italic:g}:{bold:!1,italic:!1}}const vc="aldus:selection-style",Hg=lx("aldus:overlay");function xy(a,t,e,n){try{const s=t.runs.map(l=>{const c=document.fonts.check(`12px '${l.font.loadedName}'`),d=l.font.postScriptName?document.fonts.check(`12px '${vm(l.font.postScriptName)}'`):null;return` run "${l.text.slice(0,12)}" font=${l.font.loadedName}(${l.font.postScriptName??"?"}) emb=${l.font.embedded} b=${l.font.bold} i=${l.font.italic} size=${l.fontSize.toFixed(1)} color=${l.color??"-"} VIVO=${c} STABLE=${d}`}),o=e?`edit{x:${e.x??"-"} y:${e.baseline??"-"} size:${e.fontSize??"-"} font:${e.font??"-"} color:${e.color??"-"} runs:${e.runs?e.runs.map(l=>`${l.text.slice(0,8)}|b${+l.bold}i${+l.italic}c${l.color??"-"}`).join(","):"-"}}`:"edit:null";Hg(`[aldus:${a}] ${t.id} "${((e==null?void 0:e.text)??t.text).slice(0,40)}" ${o} ${n?JSON.stringify(n):""}
321
+ ${s.join(`
322
+ `)}`)}catch{}}function D_(a,t,e){const n=Mu(a),s=((t==null?void 0:t.fontSize)??a.fontSize)/a.fontSize;return{fontFamily:t!=null&&t.font?xm(t.font):jl(n),fontSize:`${(n.fontSize*s*e).toFixed(2)}px`,fontWeight:!n.font.embedded&&n.font.bold?700:400,fontStyle:!n.font.embedded&&n.font.italic?"italic":"normal",color:(t==null?void 0:t.color)??n.color??"#000"}}const F_=(a,t,e)=>{const n=Math.min(0,e-t),s=Math.max(0,e-t);return Math.min(Math.max(a,n),s)},Ru=(a,t,e)=>F_(a,t,e),Or=(a,t,e)=>F_(a,t,e);function Lu(a){const t=a.threshold??3,e=F.useRef(null),[n,s]=F.useState(null);return{delta:n,handlers:{onPointerDown:f=>{var g;f.button===0&&((g=a.onDown)==null?void 0:g.call(a,f))!==!1&&(f.preventDefault(),f.stopPropagation(),f.currentTarget.setPointerCapture(f.pointerId),e.current={px:f.clientX,py:f.clientY,moved:!1})},onPointerMove:f=>{var x,b;const g=e.current;if(!g)return;const m=f.clientX-g.px,y=f.clientY-g.py;!g.moved&&Math.abs(m)+Math.abs(y)>t&&(g.moved=!0,(x=a.onStart)==null||x.call(a,f)),g.moved&&(s({dx:m,dy:y}),(b=a.onMove)==null||b.call(a,f,{dx:m,dy:y}))},onPointerUp:f=>{var m;const g=e.current;e.current=null,s(null),g&&(g.moved?a.onDrop(f,{dx:f.clientX-g.px,dy:f.clientY-g.py}):(m=a.onClick)==null||m.call(a,f))},onPointerCancel:f=>{var m;const g=e.current;e.current=null,s(null),g!=null&&g.moved&&((m=a.onCancel)==null||m.call(a,f))}}}}function eR({bbox:a,count:t,onMove:e,onHighlight:n,onDelete:s,onClear:o}){const l=Lu({onDrop:(f,{dx:g,dy:m})=>e(g,m),onClick:()=>o()}),c=l.delta;if(!a)return null;const d=4;return S.jsx("div",{className:"group-box",style:{left:a.left-d,top:a.top-d,width:a.width+d*2,height:a.height+d*2,transform:c?`translate(${c.dx}px,${c.dy}px)`:void 0},onClick:f=>f.stopPropagation(),...l.handlers,children:S.jsxs("div",{className:"group-tag",onPointerDown:f=>f.stopPropagation(),children:[t," seleccionados",n&&S.jsx("button",{title:"Resaltar los textos del grupo (acumula, se escribe con Aplicar)",onPointerDown:f=>f.stopPropagation(),onClick:f=>{f.stopPropagation(),n()},children:S.jsx(ox,{size:12})}),S.jsx("button",{title:"Eliminar todos",onPointerDown:f=>f.stopPropagation(),onClick:f=>{f.stopPropagation(),s()},children:S.jsx(Ur,{size:12})})]})})}function nR({hl:a,pageHeight:t,scale:e,selected:n,edit:s,isLocked:o,groupMode:l,onSelect:c,onPatch:d}){const f=$g(a,s);if(f.removed)return null;const g=Ln({x:f.x,y:f.y,width:f.width,height:f.height},t,e),m=Lu({onDown:()=>{n||c()},onDrop:(x,{dx:b,dy:A})=>{Math.abs(b)<1&&Math.abs(A)<1||d({x:_t(f.x+b/e),y:_t(f.y-A/e)})}}),y=m.delta;return S.jsx("div",{className:`hl-box${n?" selected":""}${o?" locked":""}`,style:{left:g.left,top:g.top,width:g.width,height:g.height,background:a.color||"#ffd400",transform:y?`translate(${y.dx}px, ${y.dy}px)`:void 0},title:"Resaltado — arrastrá para mover, Supr para borrar",onClick:x=>{x.stopPropagation(),c()},...m.handlers,children:n&&!o&&!l&&S.jsx("button",{className:"hl-del",title:"Eliminar resaltado",onPointerDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),d({remove:!0})},children:S.jsx(Ur,{size:12})})})}function Rn({label:a,onClick:t,active:e,danger:n,children:s}){return S.jsx("button",{title:a,"aria-label":a,onMouseDown:o=>o.preventDefault(),onClick:o=>{o.stopPropagation(),t()},className:`fb-btn${e?" active":""}${n?" danger":""}`,children:s})}const Wh=()=>S.jsx("span",{className:"fb-sep"});function O_({rect:a,children:t}){return S.jsx("div",{className:"float-bar",style:{left:a.left,top:Math.max(2,a.top-36)},onClick:e=>e.stopPropagation(),children:t})}function j_({rect:a,pageWidth:t,width:e,onAlign:n,onZ:s,onDelete:o}){return S.jsxs(O_,{rect:a,children:[n&&S.jsxs(S.Fragment,{children:[S.jsx(Rn,{label:"Alinear a la izquierda de la página",onClick:()=>n(40),children:S.jsx(w_,{size:14})}),S.jsx(Rn,{label:"Centrar en la página",onClick:()=>n((t-e)/2),children:S.jsx(v_,{size:14})}),S.jsx(Rn,{label:"Alinear a la derecha de la página",onClick:()=>n(t-40-e),children:S.jsx(x_,{size:14})}),s&&S.jsx(Wh,{})]}),s&&S.jsxs(S.Fragment,{children:[S.jsx(Rn,{label:"Enviar al fondo",onClick:()=>s("back"),children:S.jsx(y_,{size:14})}),S.jsx(Rn,{label:"Traer al frente",onClick:()=>s("front"),children:S.jsx(d_,{size:14})})]}),(n||s)&&S.jsx(Wh,{}),S.jsx(Rn,{label:"Eliminar",onClick:o,danger:!0,children:S.jsx(Ur,{size:14})})]})}function cx(a){const t=F.useRef(null),[e,n]=F.useState(null);return{size:e,handlers:{onPointerDown:d=>{d.preventDefault(),d.stopPropagation(),d.currentTarget.setPointerCapture(d.pointerId),t.current={px:d.clientX,py:d.clientY}},onPointerMove:d=>{t.current&&(d.stopPropagation(),n(a.map(d.clientX-t.current.px,d.clientY-t.current.py)))},onPointerUp:d=>{d.stopPropagation();const f=t.current;t.current=null,n(null),f&&a.onCommit(d.clientX-f.px,d.clientY-f.py)},onClick:d=>d.stopPropagation()}}}function iR({img:a,pageWidth:t,pageHeight:e,scale:n,selected:s,edit:o,isLocked:l,snapshot:c,cleanPixels:d,groupMode:f,onSelect:g,onPatch:m,onDragging:y}){const x=Og(a,o),b=Ln({x:x.x,y:x.y,width:x.width,height:x.height},e,n),A=Ln({x:a.x,y:a.y,width:a.width,height:a.height},e,n),C=F.useRef(null),E=Lu({onDown:()=>{s||g(),c&&(C.current={snap:c,origLeft:A.left,origTop:A.top,origW:A.width,origH:A.height})},onStart:()=>{y(a.id,!0)},onDrop:(Q,{dx:tt,dy:J})=>{const at=_t(Ru(x.x+tt/n,x.width,t)),st=_t(Or(x.y-J/n,x.height,e));if(at===_t(x.x)&&st===_t(x.y)){y(a.id,!1,!1);return}m({x:at===_t(a.x)?null:at,y:st===_t(a.y)?null:st}),y(a.id,!1,!0)},onCancel:()=>{y(a.id,!1,!1)}}),N=E.delta,k=cx({map:(Q,tt)=>({dx:Q,dy:tt}),onCommit:(Q,tt)=>{const J=Math.max(4,_t(x.width+Q/n)),at=Math.max(4,_t(x.height+tt/n)),st=x.y+x.height,I=_t(st-at);m({width:J===_t(a.width)?null:J,height:at===_t(a.height)?null:at,y:I===_t(a.y)?null:I})}}),L=k.size;if(x.removed)return null;const R=!!o&&!o.remove&&(o.x!=null||o.y!=null||o.width!=null||o.height!=null),j=!!o&&!o.remove&&(o.x!=null&&Math.abs(o.x-a.x)>.7||o.y!=null&&Math.abs(o.y-a.y)>.7||o.width!=null&&Math.abs(o.width-a.width)>.7||o.height!=null&&Math.abs(o.height-a.height)>.7),O=N!=null||j,H=N!=null||R,X=C.current,q=(X==null?void 0:X.snap)??c,K=(X==null?void 0:X.origLeft)??A.left,lt=(X==null?void 0:X.origTop)??A.top,pt=(X==null?void 0:X.origW)??A.width,ut=(X==null?void 0:X.origH)??A.height,St=H?d?{backgroundImage:`url(${d})`,backgroundSize:"100% 100%"}:O&&q&&pt>0&&ut>0?{backgroundImage:`url(${q.url})`,backgroundSize:`${q.width*b.width/pt}px ${q.height*b.height/ut}px`,backgroundPosition:`${-K*b.width/pt}px ${-lt*b.height/ut}px`}:void 0:void 0;return S.jsxs(S.Fragment,{children:[s&&!l&&!f&&S.jsx(j_,{rect:b,pageWidth:t,width:x.width,onAlign:Q=>m({x:_t(Ru(Q,x.width,t))}),onZ:Q=>m({zOrder:Q}),onDelete:()=>m({remove:!0})}),S.jsx("div",{className:`img-box${s?" selected":""}${o?" edited":""}${H?" ghost":""}${O?" dragging":""}${l?" locked":""}`,style:{left:b.left,top:b.top,width:L?b.width+L.dx:b.width,height:L?b.height+L.dy:b.height,transform:N?`translate(${N.dx}px, ${N.dy}px)`:void 0,zIndex:H?36:void 0,...St},title:`Imagen · ${Math.round(x.width)}×${Math.round(x.height)} pt`,onClick:Q=>{Q.stopPropagation(),g()},...E.handlers,children:!l&&!f&&S.jsx("div",{className:"seg-grip",title:"Arrastrar para escalar la imagen",...k.handlers})})]})}function sR({link:a,pageHeight:t,scale:e,selected:n,edit:s,isLocked:o,groupMode:l,onSelect:c,onPatch:d}){const f=zg(a,s);if(f.removed)return null;const g=Ln({x:f.x,y:f.y,width:f.width,height:f.height},t,e),m=Lu({onDown:()=>{n||c()},onDrop:(x,{dx:b,dy:A})=>{Math.abs(b)<1&&Math.abs(A)<1||d({x:_t(f.x+b/e),y:_t(f.y-A/e)})}}),y=m.delta;return S.jsx("div",{className:`link-box${n?" selected":""}${o?" locked":""}`,style:{left:g.left,top:g.top,width:g.width,height:g.height,transform:y?`translate(${y.dx}px, ${y.dy}px)`:void 0},title:`Link → ${a.url} (arrastrá para mover, Supr para borrar)`,onClick:x=>{x.stopPropagation(),c()},...m.handlers,children:n&&!o&&!l&&S.jsxs("div",{className:"link-tag",onPointerDown:x=>x.stopPropagation(),children:[S.jsx(p_,{size:11}),S.jsx("span",{children:a.url.length>36?`${a.url.slice(0,34)}…`:a.url}),S.jsx("button",{title:"Eliminar link",onClick:x=>{x.stopPropagation(),d({remove:!0})},children:S.jsx(Ur,{size:11})})]})})}let xc=null;function Vb(a,t,e){e<=t&&(t=Math.max(0,t-1),e=t+1);let n=0,s=!1,o=!0,l=!0,c=!0;for(const d of a){const f=Math.max(t,n);Math.min(e,n+d.text.length)>f&&(s=!0,o=o&&d.bold,l=l&&d.italic,c=c&&!!d.underline),n+=d.text.length}return s?{bold:o,italic:l,underline:c}:null}function rR(a){let t=null;return a.split(`
323
+ `).map(e=>{const n=/^(\s*)(\d{1,3})([.)])(\s+)/.exec(e);return n?(t=t==null?parseInt(n[2],10):t+1,`${n[1]}${t}${n[3]}${n[4]}${e.slice(n[0].length)}`):(t=null,e)}).join(`
324
+ `)}function Wb(a,t){const e=o=>!!o&&/\S/.test(o);let n=t,s=t;for(!e(a[t])&&e(a[t-1])&&(n=t-1,s=t);n>0&&e(a[n-1]);)n--;for(;s<a.length&&e(a[s]);)s++;return n===s?[0,a.length]:[n,s]}const oR=a=>a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),aR=F.forwardRef(function({onClosed:t},e){const n=F.useRef(null),s=F.useRef(null),o=F.useRef(null),l=F.useRef(null),c=F.useCallback(()=>{const y=l.current,x=o.current;!y||!x||(xc=y.runs,x.innerHTML=y.runs.map(b=>{const A=[];return b.bold&&A.push("text-shadow:0.02em 0 0 currentColor,-0.02em 0 0 currentColor"),b.italic&&A.push("font-style:italic"),b.underline&&A.push("text-decoration:underline"),b.color&&A.push(`color:${b.color}`),`<span${A.length?` style="${A.join(";")}"`:""}>${oR(b.text)}</span>`}).join("")||"&#8203;")},[]),d=F.useCallback(()=>{n.current&&(n.current.style.display="none"),l.current=null,xc=null,t()},[t]),f=F.useCallback(()=>{const y=l.current,x=s.current;if(!y||!x)return;const b=x.value.split(`
325
+ `);let A=0;for(const k of b){const L=(k.match(/ /g)??[]).length;A=Math.max(A,Jo(k,y.fontCss)+L*y.ws+k.length*y.ls)}const C=`${Math.max(y.minW,Math.ceil(A)+8)}px`,E=b.length>1?y.lineHN:y.lineH1,N=`${Math.ceil(Math.max(b.length*E,y.minHeightCss))}px`;for(const k of[x,o.current,n.current])k&&(k.style.width=C,k.style.height=N,k!==n.current&&(k.style.lineHeight=`${E}px`))},[]),g=F.useCallback(()=>{c(),f()},[c,f]),m=F.useCallback(()=>{const y=l.current,x=s.current;if(!y||!x)return;const b=x.value.replace(/\s+$/,""),A=I_(yy(y.runs,b),y.seg,1,y.minW/y.scale,y.align),C=_t(Math.max(4,y.anchorX+y.xShiftPt));y.onPatch({text:b,runs:__(A,Pu(y.seg))?null:A,align:y.align==="left"?null:y.align,...y.xShiftPt!==0?{x:C===_t(y.seg.x)?null:C}:{}})},[]);return F.useImperativeHandle(e,()=>({open(y){var O,H,X;const x=n.current,b=s.current;if(!x||!b)return;const A=((O=y.edit)==null?void 0:O.runs)??Pu(y.seg),C=Rl(A),E=Fb(C)?`${C.replace(/\s+$/,"")}${Bv}`:C,N=Qo(y.seg,y.edit),k=Ln({x:N.x,y:N.y,width:N.width,height:N.height},y.pageHeight,y.scale),L=D_(y.seg,y.edit,y.scale),R={...y,seedText:C,seedRuns:A,runs:A,fontCss:`${L.fontStyle==="italic"?"italic ":""}${L.fontWeight===700?"700 ":""}${L.fontSize} ${L.fontFamily}`,minW:Math.max(k.width,y.minWidthCss),ws:0,ls:0,anchorX:N.x,xShiftPt:0,lineH1:k.height,lineHN:(((H=y.edit)==null?void 0:H.fontSize)??y.seg.fontSize)*1.2*y.scale,align:((X=y.edit)==null?void 0:X.align)??"left"};if(C===y.seg.text&&!C.includes(`
326
+ `)){const q=Jo(E,R.fontCss),K=(E.match(/ /g)??[]).length,lt=k.width-q;if(q>0&&Math.abs(lt)>.5&&E.length>1)if(lt>0&&K>0)R.ws=lt/K;else{const pt=lt/E.length,ut=parseFloat(L.fontSize)||12;Math.abs(pt)<=ut*.4&&(R.ls=pt)}}l.current=R,x.style.display="block",x.style.left=`${k.left}px`,x.style.top=`${k.top}px`,x.style.height=`${k.height}px`;const j=o.current;for(const q of[b,j])q&&(Object.assign(q.style,L),q.style.height=`${k.height}px`,q.style.lineHeight=`${k.height}px`,q.style.wordSpacing=R.ws?`${R.ws.toFixed(2)}px`:"",q.style.letterSpacing=R.ls?`${R.ls.toFixed(3)}px`:"",q.style.textAlign=R.align);b.style.color="transparent",b.style.caretColor=L.color??"#000",b.value=E,R.runs=yy(A,E),c(),f(),b.focus(),b.setSelectionRange(E.length,E.length),Hg("[aldus:edit-open]",y.seg.id,"layer(textarea):",JSON.stringify(E.slice(0,30)),"focus:",document.activeElement===b)},isOpen:()=>l.current!=null}),[f,c]),F.useEffect(()=>{const y=s.current;if(!y)return;const x=()=>{const E=l.current;if(E){if((E.ws!==0||E.ls!==0)&&y.value!==E.seedText){E.ws=0,E.ls=0;for(const N of[y,o.current])N&&(N.style.wordSpacing="",N.style.letterSpacing="")}E.runs=yy(E.runs,y.value),g()}},b=()=>{const E=l.current;E&&(Hg("[aldus:blur] layer comitea y cierra",E.seg.id),m(),d())},A=E=>{const N=l.current;if(N){if(E.key==="Enter"&&!E.shiftKey){E.preventDefault();const k=y.selectionStart,L=y.value.lastIndexOf(`
327
+ `,k-1)+1,R=y.value.slice(L,k);if(Fb(R)&&R.trim()!==""){y.setRangeText("",L,k,"start"),x(),y.blur();return}const j=$2(R),O=`
328
+ ${j??""}`;if(y.setRangeText(O,k,y.selectionEnd,"end"),j&&/\d/.test(j)){const H=y.selectionStart;y.value=rR(y.value),y.setSelectionRange(H,H)}x();return}if(E.key==="Escape"){y.value=N.seedText,N.runs=N.seedRuns,y.blur();return}if((E.metaKey||E.ctrlKey)&&(E.key==="b"||E.key==="i"||E.key==="u")){E.preventDefault();const{selectionStart:k,selectionEnd:L}=y,[R,j]=k===L?Wb(y.value,k):[k,L];N.runs=Ob(N.runs,R,j,E.key==="b"?"bold":E.key==="i"?"italic":"underline"),g()}}},C=E=>{const N=l.current;if(!N)return;const k=E.detail;if((k==null?void 0:k.key)==="align"&&k.align){N.align=k.align;for(const H of[y,o.current])H&&(H.style.textAlign=k.align);return}const L=y.selectionStart,R=y.selectionEnd,[j,O]=L===R?Wb(y.value,L):[L,R];if((k==null?void 0:k.key)==="bold"||(k==null?void 0:k.key)==="italic"||(k==null?void 0:k.key)==="underline")N.runs=Ob(N.runs,j,O,k.key),g();else if((k==null?void 0:k.key)==="color"&&k.color)N.runs=z2(N.runs,j,O,{color:k.color}),g();else if((k==null?void 0:k.key)==="list"){const H=n.current,X=y.selectionStart,q=`•${Bv}`,K=/^(\s*)(?:[•·▪‣*-]|\d{1,3}[.)]|[a-zA-Z][.)])(\s*)/,lt=y.selectionStart,pt=y.selectionEnd,ut=y.value.lastIndexOf(`
329
+ `,lt-1)+1;let St=y.value.indexOf(`
330
+ `,pt);St<0&&(St=y.value.length);const Q=y.value.slice(0,ut),tt=y.value.slice(St),J=y.value.slice(ut,St).split(`
331
+ `),at=dt=>dt.trim()!=="",st=J.filter(at).length>0&&J.filter(at).every(dt=>Hh(dt)),I=Hh(y.value.split(`
332
+ `)[0]??""),V=J.map(dt=>st?dt.replace(K,""):!at(dt)||Hh(dt)?dt:q+dt);y.value=Q+V.join(`
333
+ `)+tt;const W=st?-q.length:q.length,nt=Math.max(0,Math.min(y.value.length,X+W));y.setSelectionRange(nt,nt);const rt=Hh(y.value.split(`
334
+ `)[0]??"");if(I!==rt){const dt=Jo(q,N.fontCss)+(q.match(/ /g)??[]).length*N.ws+q.length*N.ls,mt=rt?-1:1;N.xShiftPt+=mt*dt/N.scale,H&&(H.style.left=`${parseFloat(H.style.left)+mt*dt}px`)}x()}};return y.addEventListener("blur",b),y.addEventListener("keydown",A),y.addEventListener("input",x),window.addEventListener(vc,C),()=>{y.removeEventListener("blur",b),y.removeEventListener("keydown",A),y.removeEventListener("input",x),window.removeEventListener(vc,C)}},[m,d,f,g]),S.jsxs("div",{ref:n,className:"seg-box editing masked",style:{display:"none",position:"absolute",zIndex:40},onClick:y=>y.stopPropagation(),onPointerDown:y=>y.stopPropagation(),onDoubleClick:y=>y.stopPropagation(),children:[S.jsx("div",{ref:o,className:"seg-text seg-backdrop","aria-hidden":!0}),S.jsx("textarea",{ref:s,className:"seg-text seg-textarea",rows:1,wrap:"off",spellCheck:!1,autoCorrect:"off",autoCapitalize:"off"})]})});function lR({seg:a,edit:t,rect:e,pageWidth:n,frameWpt:s,onPatch:o,onDocOp:l,onRequestLink:c,savedHighlights:d,hasPendingHighlight:f,onHighlightPatch:g,highlightColor:m,onHighlightColor:y}){const x=d??[],b=x[0]??null,A=!!b||f,C=I=>x.forEach(V=>g(V.id,I)),E=(t==null?void 0:t.runs)??Pu(a),[N,k]=F.useState(null);F.useEffect(()=>{const I=()=>{const V=go();if(V instanceof HTMLTextAreaElement&&xc){k(Vb(xc,V.selectionStart,V.selectionEnd));return}k(V?tR(V,a,t):null)};return I(),document.addEventListener("selectionchange",I),()=>document.removeEventListener("selectionchange",I)},[a,t]);const L=N?N.bold:E.length>0&&E.every(I=>I.bold),R=N?N.italic:E.length>0&&E.every(I=>I.italic),j=N?!!N.underline:E.length>0&&E.every(I=>!!I.underline),O=I=>{const V=go();if(V){window.dispatchEvent(new CustomEvent(vc,{detail:{key:I}})),V instanceof HTMLTextAreaElement&&xc&&k(Vb(xc,V.selectionStart,V.selectionEnd));return}const W=I==="bold"?!L:I==="italic"?!R:!j;o({runs:E.map(nt=>({...nt,[I]:W}))})},H=Qo(a,t),X=(t==null?void 0:t.align)??"left",q=I=>{if(go()){window.dispatchEvent(new CustomEvent(vc,{detail:{key:"align",align:I}}));return}const V=(t==null?void 0:t.runs)??Pu(a),W=I_(V,a,1,s,I);o({align:I==="left"?null:I,runs:I==="left"&&!(t!=null&&t.runs)?void 0:W})},K={page:a.page,segmentId:a.id,x:H.x,y:H.y,width:H.width,height:H.height},lt=Mu(a),pt=(t==null?void 0:t.color)??lt.color??"#000000",ut=(t==null?void 0:t.fontSize)??a.fontSize,St=I=>{if(go()){window.dispatchEvent(new CustomEvent(vc,{detail:{key:"color",color:I}}));return}o({color:I.toLowerCase()===(lt.color??"#000000").toLowerCase()?null:I})},[,Q]=F.useState(0),tt=go(),J=tt instanceof HTMLTextAreaElement?tt.value:tt==null?void 0:tt.textContent,at=Hh(J??Rl(E)),st=()=>{if(go()){window.dispatchEvent(new CustomEvent(vc,{detail:{key:"list"}})),Q(V=>V+1);return}const I=j2(E);if(I!==E){const V=Rl(E),W=Rl(I),nt=W.length>V.length,rt=nt?W.slice(0,W.length-V.length):V.slice(0,V.length-W.length),dt=Jo(rt,`${a.fontSize}px ${jl(Mu(a))}`),mt=_t(Math.max(4,H.x+(nt?-dt:dt)));o({runs:I,text:W,x:mt===_t(a.x)?null:mt})}};return S.jsxs(O_,{rect:e,children:[S.jsx(Rn,{label:"Negrita",onClick:()=>O("bold"),active:L,children:S.jsx(sM,{size:14})}),S.jsx(Rn,{label:"Itálica",onClick:()=>O("italic"),active:R,children:S.jsx(EM,{size:14})}),S.jsx(Rn,{label:"Subrayado",onClick:()=>O("underline"),active:j,children:S.jsx(o2,{size:14})}),S.jsx(Rn,{label:"Lista con viñeta (Enter en edición agrega el siguiente ítem)",onClick:st,active:at,children:S.jsx(MM,{size:14})}),S.jsxs("select",{className:"fb-input",style:{width:76},title:"Familia tipográfica",value:(t==null?void 0:t.font)??"original",onMouseDown:I=>I.stopPropagation(),onClick:I=>I.stopPropagation(),onChange:I=>o({font:I.target.value==="original"?null:I.target.value}),children:[S.jsx("option",{value:"original",children:"Original"}),S.jsx("option",{value:"sans",children:"Sans"}),S.jsx("option",{value:"serif",children:"Serif"}),S.jsx("option",{value:"mono",children:"Mono"})]}),S.jsx("input",{className:"fb-input",type:"number",step:.5,min:4,title:"Tamaño (pt)",defaultValue:_t(ut),onMouseDown:I=>I.stopPropagation(),onClick:I=>I.stopPropagation(),onBlur:I=>{const V=parseFloat(I.target.value);Number.isFinite(V)&&V>=4&&o({fontSize:_t(V)===_t(a.fontSize)?null:_t(V)})},onKeyDown:I=>{I.key==="Enter"&&I.target.blur()}},`${a.id}-${_t(ut)}`),S.jsx("button",{className:"fb-swatch",title:"Color del texto (a la selección si estás editando)",style:{background:pt},onMouseDown:I=>I.preventDefault(),onClick:I=>I.stopPropagation(),children:S.jsx("input",{type:"color",value:pt,onChange:I=>St(I.target.value)})}),S.jsx(Wh,{}),S.jsx(Rn,{label:"Texto a la izquierda del área",active:X==="left",onClick:()=>q("left"),children:S.jsx(w_,{size:14})}),S.jsx(Rn,{label:"Centrar el texto en el área (ensanchá con el grip)",active:X==="center",onClick:()=>q("center"),children:S.jsx(v_,{size:14})}),S.jsx(Rn,{label:"Texto a la derecha del área",active:X==="right",onClick:()=>q("right"),children:S.jsx(x_,{size:14})}),S.jsx(Wh,{}),S.jsx(Rn,{label:A?x.length>1?`Quitar el resaltado (${x.length} apilados)`:"Quitar el resaltado":"Resaltar (acumula, se escribe con Aplicar)",active:A,onClick:()=>{A?(C({remove:!0}),l("unhighlight",{segmentId:a.id})):l("highlight",{...K,color:m})},children:S.jsx(ox,{size:14})}),S.jsx("button",{className:"fb-swatch",title:b?"Color del resaltado (recolorea el existente)":"Color del resaltador",style:{background:(b==null?void 0:b.color)??m},onMouseDown:I=>I.preventDefault(),onClick:I=>I.stopPropagation(),children:S.jsx("input",{type:"color",value:(b==null?void 0:b.color)??m,onChange:I=>b?C({color:I.target.value}):y(I.target.value)})}),S.jsx(Rn,{label:"Link",onClick:()=>c(K),children:S.jsx(p_,{size:14})}),S.jsx(Wh,{}),S.jsx(Rn,{label:"Eliminar",onClick:()=>o({remove:!0}),danger:!0,children:S.jsx(Ur,{size:14})})]})}function cR({seg:a,pageWidth:t,pageHeight:e,scale:n,selected:s,editing:o,edit:l,onCanvas:c,isLocked:d,onDragging:f,area:g,onArea:m,groupMode:y,onSelect:x,onStartEdit:b,onPatch:A,onDocOp:C,onRequestLink:E,highlights:N,savedHighlights:k,onHighlightPatch:L,highlightColor:R,onHighlightColor:j}){const O=Qo(a,l),H=Ln({x:O.x,y:O.y,width:O.width,height:O.height},e,n),X=K2(a,l,n),q=((l==null?void 0:l.text)??a.text).split(`
335
+ `).length,K=O.fontSize*1.2*n,lt=q>1?q*K:H.height,pt=q>1?K:H.height,ut=Math.max(H.width,(g==null?void 0:g.w)!=null?g.w*n:0),St=Math.max(lt,(g==null?void 0:g.h)!=null?g.h*n:0),Q=Lu({onDown:()=>{if(o)return!1;s||x()},onStart:()=>{xy("drag-start",a,l),f(!0)},onDrop:(W,{dx:nt,dy:rt})=>{const dt=_t(Ru(O.x+nt/n,O.width,t)),mt=Or(O.y-rt/n,O.height,e),Mt=_t(O.baseline+(mt-O.y));if(l==null&&dt===_t(a.x)&&Mt===_t(a.baseline)){f(!1,!1);return}xy("drop",a,l,{drop:{nx:dt,nb:Mt}}),A({x:dt===_t(a.x)?null:dt,baseline:Mt===_t(a.baseline)?null:Mt}),f(!1,!0)},onCancel:()=>{f(!1,!1)}}),tt=Q.delta,J=cx({map:(W,nt)=>({w:Math.max(H.width,ut+W),h:Math.max(lt,St+nt)}),onCommit:(W,nt)=>{const rt=Math.max(H.width,ut+W),dt=Math.max(lt,St+nt),mt=_t(rt/n),Mt=_t(dt/n);m({w:mt<=_t(O.width)+1?void 0:mt,h:Mt<=_t(lt/n)+1?void 0:Mt})}}),at=J.size;if(F.useEffect(()=>{l&&xy("render-edited",a,l,{editing:o,drag:tt!=null})},[l,a]),l!=null&&l.remove)return null;const st=o||l!=null||tt!=null,I=(at==null?void 0:at.h)??St,V=!!l&&(l.x!=null||l.baseline!=null);return S.jsxs(S.Fragment,{children:[s&&!d&&!y&&S.jsx(lR,{seg:a,edit:l,rect:H,pageWidth:t,frameWpt:ut/n,onPatch:A,onDocOp:C,onRequestLink:E,savedHighlights:k??null,hasPendingHighlight:!!(N!=null&&N.length),onHighlightPatch:L,highlightColor:R,onHighlightColor:j}),S.jsxs("div",{className:`seg-box${s?" selected":""}${st?" masked":""}${l?" edited":""}${o?" editing":""}${d?" locked":""}${l&&c&&!V?" on-canvas":""}`,style:{left:H.left,top:H.top,minWidth:(at==null?void 0:at.w)??ut,...l!=null&&l.align?{width:(at==null?void 0:at.w)??ut}:{},height:I,lineHeight:`${pt}px`,transform:tt?`translate(${tt.dx}px, ${tt.dy}px)`:void 0,transformOrigin:"left bottom"},onClick:W=>{W.stopPropagation(),x()},onDoubleClick:W=>{W.stopPropagation(),b()},...Q.handlers,title:o?void 0:(l==null?void 0:l.text)??a.text,children:[N==null?void 0:N.map((W,nt)=>S.jsx("div",{className:"seg-hl",style:{width:H.width+2,height:H.height+2,background:W.color??"#ffd400"}},`hl-${nt}`)),k==null?void 0:k.map(W=>{const nt=Ln({x:a.x,y:a.y,width:a.width,height:a.height},e,n),rt=Ln({x:W.x,y:W.y,width:W.width,height:W.height},e,n);return S.jsx("div",{className:"seg-hl",style:{left:rt.left-nt.left,top:rt.top-nt.top,width:rt.width,height:rt.height,background:W.color||"#ffd400"}},W.id)}),st&&S.jsx("div",{className:"seg-text",style:{position:"relative",zIndex:1,...D_(a,l,n),...l!=null&&l.align?{width:"100%",textAlign:l.align}:{}},dangerouslySetInnerHTML:{__html:X}}),!o&&!d&&!y&&S.jsx("div",{className:"seg-grip",title:"Ampliar el área de texto (ancho y alto; la letra no cambia)",...J.handlers,onDoubleClick:W=>W.stopPropagation()})]})]})}const Gb={text:"texto",checkbox:"checkbox",radio:"radio",select:"select",list:"lista",button:"botón",signature:"firma"};function uR({widget:a,pageWidth:t,pageHeight:e,scale:n,selected:s,edit:o,isLocked:l,snapshot:c,groupMode:d,onSelect:f,onPatch:g}){const m=jg(a,o),y=Ln({x:m.x,y:m.y,width:m.width,height:m.height},e,n),x=Ln({x:a.x,y:a.y,width:a.width,height:a.height},e,n),b=Lu({onDown:()=>{s||f()},onDrop:(L,{dx:R,dy:j})=>{const O=_t(Ru(m.x+R/n,m.width,t)),H=_t(Or(m.y-j/n,m.height,e));g({x:O===_t(a.x)?null:O,y:H===_t(a.y)?null:H})}}),A=b.delta,C=cx({map:(L,R)=>({dx:L,dy:R}),onCommit:(L,R)=>{const j=Math.max(6,_t(m.width+L/n)),O=Math.max(6,_t(m.height+R/n)),H=m.y+m.height,X=_t(H-O);g({width:j===_t(a.width)?null:j,height:O===_t(a.height)?null:O,y:X===_t(a.y)?null:X})}}),E=C.size;if(m.removed)return null;const N=A!=null,k=N&&c&&x.width>0&&x.height>0?{backgroundImage:`url(${c.url})`,backgroundSize:`${c.width*y.width/x.width}px ${c.height*y.height/x.height}px`,backgroundPosition:`${-x.left*y.width/x.width}px ${-x.top*y.height/x.height}px`}:void 0;return S.jsxs(S.Fragment,{children:[N&&S.jsx("div",{className:"seg-mask",style:{left:x.left,top:x.top,width:x.width,height:x.height}}),s&&!l&&!d&&S.jsx(j_,{rect:y,pageWidth:t,width:m.width,onDelete:()=>g({remove:!0})}),S.jsxs("div",{className:`widget-box${s?" selected":""}${o?" edited":""}${l?" locked":""}`,style:{left:y.left,top:y.top,width:E?y.width+E.dx:y.width,height:E?y.height+E.dy:y.height,transform:A?`translate(${A.dx}px, ${A.dy}px)`:void 0,...k},title:`Campo ${Gb[a.widgetType]} · ${a.fieldName}`,onClick:L=>{L.stopPropagation(),f()},...b.handlers,children:[s&&S.jsxs("span",{className:"widget-label",children:[Gb[a.widgetType]," · ",a.fieldName]}),!l&&!d&&S.jsx("div",{className:"seg-grip",title:"Arrastrar para redimensionar el campo",...C.handlers})]})]})}function hR({graph:a,scale:t,selectedId:e,onSelect:n,edits:s,onEdit:o,imageEdits:l,onImageEdit:c,widgetEdits:d,onWidgetEdit:f,locked:g,placing:m,onPlace:y,snapshot:x,imagePixels:b,onDocOp:A,onRequestLink:C,onAddText:E,highlights:N,highlightEdits:k,onHighlightEdit:L,onSyncHighlightEdits:R,linkEdits:j,onLinkEdit:O,highlightColor:H,onHighlightColor:X,phantomSegments:q,onDragging:K,areaWidths:lt,onAreaWidth:pt,onEditingChange:ut}){var As;const[St,Q]=F.useState(null);F.useEffect(()=>{ut(St!=null)},[St,ut]),F.useEffect(()=>{var B;(B=go())==null||B.blur()},[a.page]);const tt=F.useRef(null),J=F.useRef(s);J.current=s;const at=F.useCallback(()=>Q(null),[]),st=B=>{var yt,Ft,Qt;const Z=J.current.get(B.id)??null;Q(B.id),(Qt=tt.current)==null||Qt.open({seg:B,edit:Z,scale:t,pageHeight:a.height,minWidthCss:(((yt=lt.get(B.id))==null?void 0:yt.w)??0)*t,minHeightCss:(((Ft=lt.get(B.id))==null?void 0:Ft.h)??0)*t,onPatch:Lt=>{const ht=ka(B,J.current.get(B.id)??null,Lt);o(ht??{segmentId:B.id,revert:!0})}})},[,I]=F.useState(0);F.useEffect(()=>{const B=()=>I(Z=>Z+1);return document.fonts.addEventListener("loadingdone",B),()=>document.fonts.removeEventListener("loadingdone",B)},[]);const V=new Set(a.segments.map(B=>B.id)),W=[...a.segments,...q.filter(B=>!V.has(B.id))],nt=new Set(W.map(B=>B.id)),rt=new Map,dt=[];for(const B of N)B.segmentId&&nt.has(B.segmentId)?rt.set(B.segmentId,[...rt.get(B.segmentId)??[],B]):dt.push(B);const mt=(B,Z)=>{const yt=Math.max(0,Math.min(B.x+B.width,Z.x+Z.width)-Math.max(B.x,Z.x)),Ft=Math.max(0,Math.min(B.y+B.height,Z.y+Z.height)-Math.max(B.y,Z.y));return yt*Ft},Mt=new Map,Vt=[];for(const B of a.highlights){if((As=k.get(B.id))!=null&&As.remove)continue;let Z=null,yt=0;for(const Ft of W)Z=mt(B,Ft)>yt?(yt=mt(B,Ft),Ft):Z;Z&&yt>B.width*B.height*.3?Mt.set(Z.id,[...Mt.get(Z.id)??[],B]):Vt.push(B)}const ye=new Set([...Mt.values()].flat().map(B=>B.id));F.useEffect(()=>{const B=[];for(const[Z,yt]of Mt){const Ft=W.find(ie=>ie.id===Z);if(!Ft)continue;const Qt=s.get(Z)??null,Lt=_t(((Qt==null?void 0:Qt.x)??Ft.x)-Ft.x),ht=_t(((Qt==null?void 0:Qt.baseline)??Ft.baseline)-Ft.baseline);if(!(Lt===0&&ht===0))for(const ie of yt){const Zt=k.get(ie.id)??null,pe=_t(ie.x+Lt),Ge=_t(ie.y+ht);if(_t((Zt==null?void 0:Zt.x)??ie.x)===pe&&_t((Zt==null?void 0:Zt.y)??ie.y)===Ge)continue;const $t=yc(ie,Zt,{x:pe===_t(ie.x)?null:pe,y:Ge===_t(ie.y)?null:Ge});B.push($t??{highlightId:ie.id,revert:!0})}}B.length&&R(B)},[s,k,a]);const ve=B=>{var Z;St&&St!==B&&(Hg("[aldus:forceblur] cierro editor de",St,"por selección de",B??"(nada)"),(Z=go())==null||Z.blur()),ue.size&&te(new Set),n(B)},[ue,te]=F.useState(new Set);F.useEffect(()=>te(new Set),[a.page]);const[Xt,ai]=F.useState(null),Dn=F.useRef(null),Pi=B=>{const Z=W.find(ht=>ht.id===B);if(Z){const ht=Qo(Z,s.get(Z.id)??null);return Ln({x:ht.x,y:ht.y,width:ht.width,height:ht.height},a.height,t)}const yt=a.images.find(ht=>ht.id===B);if(yt){const ht=Og(yt,l.get(yt.id)??null);return Ln({x:ht.x,y:ht.y,width:ht.width,height:ht.height},a.height,t)}const Ft=a.widgets.find(ht=>ht.id===B);if(Ft){const ht=jg(Ft,d.get(Ft.id)??null);return Ln({x:ht.x,y:ht.y,width:ht.width,height:ht.height},a.height,t)}const Qt=a.highlights.find(ht=>ht.id===B);if(Qt){const ht=$g(Qt,k.get(Qt.id)??null);return Ln({x:ht.x,y:ht.y,width:ht.width,height:ht.height},a.height,t)}const Lt=a.links.find(ht=>ht.id===B);if(Lt){const ht=zg(Lt,j.get(Lt.id)??null);return Ln({x:ht.x,y:ht.y,width:ht.width,height:ht.height},a.height,t)}return null},Fn=(B,Z)=>{const yt=_t(B/t),Ft=_t(-Z/t),Qt=(Lt,ht)=>_t(Ru(Lt+yt,ht,a.width));for(const Lt of ue){const ht=W.find($t=>$t.id===Lt);if(ht){const $t=Qo(ht,s.get(ht.id)??null),tn=Or($t.y+Ft,$t.height,a.height),sa=ka(ht,s.get(ht.id)??null,{x:Qt($t.x,$t.width),baseline:_t($t.baseline+(tn-$t.y))});o(sa??{segmentId:ht.id,revert:!0});continue}const ie=a.images.find($t=>$t.id===Lt);if(ie){const $t=Og(ie,l.get(ie.id)??null),tn=Uh(ie,l.get(ie.id)??null,{x:Qt($t.x,$t.width),y:_t(Or($t.y+Ft,$t.height,a.height))});c(tn??{imageId:ie.id,revert:!0});continue}const Zt=a.widgets.find($t=>$t.id===Lt);if(Zt){const $t=jg(Zt,d.get(Zt.id)??null),tn=kg(Zt,d.get(Zt.id)??null,{x:Qt($t.x,$t.width),y:_t(Or($t.y+Ft,$t.height,a.height))});f(tn??{widgetId:Zt.id,revert:!0});continue}const pe=a.highlights.find($t=>$t.id===Lt);if(pe){const $t=$g(pe,k.get(pe.id)??null),tn=yc(pe,k.get(pe.id)??null,{x:Qt($t.x,$t.width),y:_t(Or($t.y+Ft,$t.height,a.height))});L(tn??{highlightId:pe.id,revert:!0});continue}const Ge=a.links.find($t=>$t.id===Lt);if(Ge){const $t=zg(Ge,j.get(Ge.id)??null),tn=Vh(Ge,j.get(Ge.id)??null,{x:Qt($t.x,$t.width),y:_t(Or($t.y+Ft,$t.height,a.height))});O(tn??{linkId:Ge.id,revert:!0})}}},Mi=()=>{let B=1/0,Z=1/0,yt=-1/0,Ft=-1/0;for(const Qt of ue){const Lt=Pi(Qt);Lt&&(B=Math.min(B,Lt.left),Z=Math.min(Z,Lt.top),yt=Math.max(yt,Lt.left+Lt.width),Ft=Math.max(Ft,Lt.top+Lt.height))}return B===1/0?null:{left:B,top:Z,width:yt-B,height:Ft-Z}};return S.jsxs("div",{className:`node-overlay${m?" placing":""}`,onClick:B=>{if(m){const Z=B.currentTarget.getBoundingClientRect(),yt=B2(B.clientX-Z.left,B.clientY-Z.top,a.height,t);y(yt.x,yt.y)}},onPointerDown:B=>{if(m||B.button!==0||B.target!==B.currentTarget)return;const Z=B.currentTarget.getBoundingClientRect();Dn.current={x:B.clientX-Z.left,y:B.clientY-Z.top,hostL:Z.left,hostT:Z.top},B.currentTarget.setPointerCapture(B.pointerId)},onPointerMove:B=>{const Z=Dn.current;if(!Z)return;const yt=B.clientX-Z.hostL,Ft=B.clientY-Z.hostT;ai({l:Math.min(Z.x,yt),t:Math.min(Z.y,Ft),w:Math.abs(yt-Z.x),h:Math.abs(Ft-Z.y)})},onPointerUp:B=>{const Z=Dn.current;if(Dn.current=null,!Z)return;const yt=B.clientX-Z.hostL,Ft=B.clientY-Z.hostT,Qt=Math.abs(yt-Z.x)+Math.abs(Ft-Z.y)>4;if(ai(null),!Qt){ve(null);return}const Lt={l:Math.min(Z.x,yt),t:Math.min(Z.y,Ft),r:Math.max(Z.x,yt),b:Math.max(Z.y,Ft)},ht=new Set,ie=Zt=>{if(g.has(Zt))return;const pe=Pi(Zt);pe&&pe.left<Lt.r&&pe.left+pe.width>Lt.l&&pe.top<Lt.b&&pe.top+pe.height>Lt.t&&ht.add(Zt)};W.forEach(Zt=>ie(Zt.id)),a.images.forEach(Zt=>ie(Zt.id)),a.widgets.forEach(Zt=>ie(Zt.id)),a.highlights.forEach(Zt=>{ye.has(Zt.id)||ie(Zt.id)}),a.links.forEach(Zt=>ie(Zt.id)),te(ht),n(ht.size===1?[...ht][0]:null)},children:[a.images.map(B=>S.jsx(iR,{groupMode:ue.size>1,img:B,pageWidth:a.width,pageHeight:a.height,scale:t,selected:e===B.id||ue.has(B.id),edit:l.get(B.id)??null,isLocked:g.has(B.id),snapshot:x,cleanPixels:b.get(B.id)??null,onSelect:()=>ve(B.id),onPatch:Z=>{const yt=Uh(B,l.get(B.id)??null,Z);c(yt??{imageId:B.id,revert:!0})},onDragging:K},B.id)),W.map(B=>S.jsx(cR,{groupMode:ue.size>1,seg:B,pageWidth:a.width,pageHeight:a.height,scale:t,selected:e===B.id||ue.has(B.id),editing:St===B.id,edit:s.get(B.id)??null,onCanvas:V.has(B.id),isLocked:g.has(B.id),onDragging:(Z,yt)=>K(B.id,Z,yt),area:lt.get(B.id)??null,onArea:Z=>pt(B.id,Z),onSelect:()=>ve(B.id),onStartEdit:()=>{ve(B.id),st(B)},onPatch:Z=>{const yt=ka(B,s.get(B.id)??null,Z);o(yt??{segmentId:B.id,revert:!0})},onDocOp:A,onRequestLink:C,onAddText:E,highlights:rt.get(B.id)??null,savedHighlights:(Mt.get(B.id)??[]).flatMap(Z=>{const yt=k.get(Z.id)??null;return yt!=null&&yt.remove?[]:[{id:Z.id,x:Z.x,y:Z.y,width:Z.width,height:Z.height,color:(yt==null?void 0:yt.color)??Z.color}]}),onHighlightPatch:(Z,yt)=>{const Ft=a.highlights.find(Lt=>Lt.id===Z);if(!Ft)return;const Qt=yc(Ft,k.get(Z)??null,yt);L(Qt??{highlightId:Z,revert:!0})},highlightColor:H,onHighlightColor:X},B.id)),a.links.map(B=>S.jsx(sR,{link:B,pageHeight:a.height,scale:t,selected:e===B.id||ue.has(B.id),edit:j.get(B.id)??null,isLocked:g.has(B.id),groupMode:ue.size>1,onSelect:()=>ve(B.id),onPatch:Z=>{const yt=Vh(B,j.get(B.id)??null,Z);O(yt??{linkId:B.id,revert:!0})}},B.id)),Vt.map(B=>S.jsx(nR,{hl:B,pageHeight:a.height,scale:t,selected:e===B.id||ue.has(B.id),edit:k.get(B.id)??null,isLocked:g.has(B.id),groupMode:ue.size>1,onSelect:()=>ve(B.id),onPatch:Z=>{const yt=yc(B,k.get(B.id)??null,Z);L(yt??{highlightId:B.id,revert:!0})}},B.id)),dt.map((B,Z)=>{const yt=Ln({x:B.x,y:B.y,width:B.width,height:B.height},a.height,t);return S.jsx("div",{className:"seg-hl",style:{position:"absolute",left:yt.left,top:yt.top,width:yt.width,height:yt.height,background:B.color??"#ffd400"}},`hl-${Z}`)}),a.widgets.map(B=>S.jsx(uR,{groupMode:ue.size>1,widget:B,pageWidth:a.width,pageHeight:a.height,scale:t,selected:e===B.id||ue.has(B.id),edit:d.get(B.id)??null,isLocked:g.has(B.id),snapshot:x,onSelect:()=>ve(B.id),onPatch:Z=>{const yt=kg(B,d.get(B.id)??null,Z);f(yt??{widgetId:B.id,revert:!0})}},B.id)),Xt&&S.jsx("div",{className:"marquee",style:{left:Xt.l,top:Xt.t,width:Xt.w,height:Xt.h}}),ue.size>1&&S.jsx(eR,{bbox:Mi(),count:ue.size,onMove:Fn,onHighlight:(()=>{const B=[...ue].map(Z=>W.find(yt=>yt.id===Z)).filter(Z=>!!Z);if(B.length)return()=>A("highlight",{items:B.map(Z=>{const yt=Qo(Z,s.get(Z.id)??null);return{page:Z.page,segmentId:Z.id,x:yt.x,y:yt.y,width:yt.width,height:yt.height,color:H}})})})(),onDelete:()=>{for(const B of ue){const Z=W.find(ht=>ht.id===B);if(Z){const ht=ka(Z,s.get(Z.id)??null,{remove:!0});ht&&o(ht);continue}const yt=a.images.find(ht=>ht.id===B);if(yt){const ht=Uh(yt,l.get(yt.id)??null,{remove:!0});ht&&c(ht);continue}const Ft=a.widgets.find(ht=>ht.id===B);if(Ft){const ht=kg(Ft,d.get(Ft.id)??null,{remove:!0});ht&&f(ht);continue}const Qt=a.highlights.find(ht=>ht.id===B);if(Qt){const ht=yc(Qt,k.get(Qt.id)??null,{remove:!0});ht&&L(ht);continue}const Lt=a.links.find(ht=>ht.id===B);if(Lt){const ht=Vh(Lt,j.get(Lt.id)??null,{remove:!0});ht&&O(ht)}}te(new Set)},onClear:()=>{te(new Set),n(null)}}),S.jsx(aR,{ref:tt,onClosed:at})]})}const wy=a=>Math.max(0,Math.min(255,Math.round(a))).toString(16).padStart(2,"0"),po=new Map;function dR(){po.clear()}const fR=(a,t)=>`${a}|${Math.round(t.baseline*2)}|${Math.round(t.x*2)}|${t.text}`;function pR(a,t,e){const n=t.getContext("2d",{willReadFrequently:!0});if(!n)return;const s=t.width/(a.width*e),o=e*s,l=a.widgets.map(c=>({l:Math.floor(c.x*o)-1,t:Math.floor((a.height-c.y-c.height)*o)-1,r:Math.ceil((c.x+c.width)*o)+1,b:Math.ceil((a.height-c.y)*o)+1}));for(const c of a.runs){if(c.angle&&Math.abs(c.angle)>.01)continue;const d=fR(a.page,c),f=po.get(d);if(f!==void 0){f&&(c.color=f);continue}const g=Math.floor(c.x*e*s),m=Math.floor((a.height-c.baseline-c.fontSize*.25)*e*s),y=Math.max(1,Math.ceil(c.width*e*s)),x=Math.max(1,Math.ceil(c.fontSize*1.1*e*s));if(g<0||m<0||g+y>t.width||m+x>t.height||y*x>2e5)continue;let b;try{b=n.getImageData(g,m,y,x).data}catch{return}if(l.some(q=>q.l<g+y&&q.r>g&&q.t<m+x&&q.b>m)){po.set(d,"");continue}let A=0;for(let q=0;q<b.length;q+=4){if(b[q+3]<40)continue;const K=255-b[q]+(255-b[q+1])+(255-b[q+2]);K>A&&(A=K)}if(A<90){po.set(d,"");continue}const C=A*.8;let E=0,N=0,k=0,L=0;for(let q=0;q<b.length;q+=4)b[q+3]<40||255-b[q]+(255-b[q+1])+(255-b[q+2])<C||(E+=b[q],N+=b[q+1],k+=b[q+2],L++);if(!L){po.set(d,"");continue}const R=E/L,j=N/L,O=k/L;if(Math.max(R,j,O)-Math.min(R,j,O)<24){po.set(d,"");continue}const X=`#${wy(R)}${wy(j)}${wy(O)}`;X!=="#000000"?(c.color=X,po.set(d,X)):po.set(d,"")}}const Cg=new Map;function gR(){Cg.clear()}const mR=1,yR=2,vR=3;function xR(a){const{width:t,height:e}=a;if(!t||!e)return null;const n=document.createElement("canvas");n.width=t,n.height=e;const s=n.getContext("2d");if(!s)return null;if(a.bitmap)return s.drawImage(a.bitmap,0,0),n.toDataURL("image/png");if(!a.data)return null;const o=s.createImageData(t,e),l=o.data,c=a.data;if(a.kind===vR)l.set(c.subarray(0,l.length));else if(a.kind===yR)for(let d=0,f=0;d<c.length;d+=3,f+=4)l[f]=c[d],l[f+1]=c[d+1],l[f+2]=c[d+2],l[f+3]=255;else if(a.kind===mR){const d=t+7>>3;for(let f=0;f<e;f++)for(let g=0;g<t;g++){const y=c[f*d+(g>>3)]>>7-(g&7)&1?255:0,x=(f*t+g)*4;l[x]=y,l[x+1]=y,l[x+2]=y,l[x+3]=255}}else return null;return s.putImageData(o,0,0),n.toDataURL("image/png")}function wR(a,t){const e=new Map;for(const n of t){if(Cg.has(n.id)){const o=Cg.get(n.id);o&&e.set(n.id,o);continue}let s=null;try{n.objId&&a.objs.has(n.objId)&&(s=xR(a.objs.get(n.objId)))}catch{s=null}Cg.set(n.id,s),s&&e.set(n.id,s)}return e}async function Xb(a,t,e,n){var g;const s=await a.getPage(t),o=s.getViewport({scale:e}),l=window.devicePixelRatio||1,c=document.createElement("canvas");c.width=Math.floor(o.width*l),c.height=Math.floor(o.height*l);const d=c.getContext("2d",{willReadFrequently:!0});if(!d)return null;(g=n.current)==null||g.cancel();const f=s.render({canvasContext:d,viewport:o,transform:l!==1?[l,0,0,l,0,0]:void 0});n.current=f;try{await f.promise}catch{return null}return c}function bR({pdf:a,pageNum:t,scale:e,graph:n,onGraph:s,selectedId:o,onSelect:l,edits:c,onEdit:d,imageEdits:f,onImageEdit:g,widgetEdits:m,onWidgetEdit:y,locked:x,placing:b,onPlace:A,onDocOp:C,onRequestLink:E,onAddText:N,highlights:k,highlightEdits:L,onHighlightEdit:R,onSyncHighlightEdits:j,linkEdits:O,onLinkEdit:H,highlightColor:X,onHighlightColor:q,phantomSegments:K,onDragging:lt,lift:pt,draggingId:ut,areaWidths:St,onAreaWidth:Q,onEditingChange:tt}){const J=F.useRef(null),at=F.useRef(null),st=F.useRef(null),[I,V]=F.useState(null),[W,nt]=F.useState(null),[rt,dt]=F.useState(new Map),mt=F.useRef(null),Mt=F.useRef(null),Vt=F.useRef(!1),ye=F.useRef(null);ye.current=ut;const ve=F.useRef(!1),ue=te=>{var Dn;const Xt=J.current;if(!Xt)return;(Xt.width!==te.width||Xt.height!==te.height)&&(Xt.width=te.width,Xt.height=te.height);const ai=window.devicePixelRatio||1;Xt.style.width=`${Math.floor(te.width/ai)}px`,Xt.style.height=`${Math.floor(te.height/ai)}px`,(Dn=Xt.getContext("2d"))==null||Dn.drawImage(te,0,0)};return F.useEffect(()=>{let te=!1;return(async()=>{const Xt=await Xb(a,t,e,at);if(te||!Xt)return;const ai=window.devicePixelRatio||1,Dn=Math.floor(Xt.width/ai),Pi=Math.floor(Xt.height/ai);mt.current=Xt,ue(Xt),Vt.current=!1,ve.current=!1,V({w:Dn,h:Pi});const Fn=await a.getPage(t),Mi=await D2(Fn);if(!te){try{V2(Fn,Mi)}catch{}try{pR(Mi,Xt,e)}catch{}try{dt(wR(Fn,Mi.images))}catch{}s(Mi);try{nt({url:Xt.toDataURL("image/jpeg",.7),width:Dn,height:Pi})}catch{nt(null)}}})(),()=>{var Xt;te=!0,(Xt=at.current)==null||Xt.cancel()}},[a,t,e,s]),F.useEffect(()=>{if(!pt){Vt.current&&mt.current&&(ue(mt.current),Vt.current=!1),Mt.current=null;return}ye.current!==pt.segId&&(ve.current=!1);let te=!1;return(async()=>{const Xt=await Xb(pt.doc,t,e,st);te||!Xt||(Mt.current={segId:pt.segId,canvas:Xt},(ye.current===pt.segId||ve.current)&&(ue(Xt),Vt.current=!0))})().catch(()=>{}),()=>{var Xt;te=!0,(Xt=st.current)==null||Xt.cancel()}},[pt,t,e]),F.useEffect(()=>{if(!ut)return;ve.current=!0;const te=Mt.current;te&&te.segId===ut&&!Vt.current&&(ue(te.canvas),Vt.current=!0)},[ut]),S.jsxs("div",{className:"pdf-stage",style:I?{width:I.w,height:I.h}:void 0,children:[S.jsx("canvas",{ref:J}),n&&S.jsx(hR,{graph:n,scale:e,selectedId:o,onSelect:l,edits:c,onEdit:d,imageEdits:f,onImageEdit:g,widgetEdits:m,onWidgetEdit:y,locked:x,placing:b,onPlace:A,snapshot:W,imagePixels:rt,onDocOp:C,onRequestLink:E,onAddText:N,highlights:k,highlightEdits:L,onHighlightEdit:R,onSyncHighlightEdits:j,linkEdits:O,onLinkEdit:H,highlightColor:X,onHighlightColor:q,phantomSegments:K,onDragging:lt,areaWidths:St,onAreaWidth:Q,onEditingChange:tt})]})}const Ci=(...a)=>a.filter(Boolean).join(" ");function Ah({icon:a,label:t,active:e,onClick:n}){return S.jsx("button",{title:t,"aria-label":t,onClick:n,className:Ci("grid h-9 w-9 place-items-center rounded-lg transition-colors",e?"bg-blue-50 text-blue-600 ring-1 ring-blue-200":"text-neutral-500 hover:bg-neutral-100 hover:text-neutral-800"),children:S.jsx(a,{size:17,strokeWidth:1.9})})}function lc({icon:a,label:t,onClick:e,disabled:n,active:s}){return S.jsx("button",{title:t,"aria-label":t,onClick:e,disabled:n,className:Ci("grid h-8 w-8 place-items-center rounded-md transition-colors disabled:opacity-30 disabled:cursor-default",s?"bg-blue-50 text-blue-600":"text-neutral-600 hover:bg-neutral-100"),children:S.jsx(a,{size:16,strokeWidth:2})})}function Be({children:a,onClick:t,variant:e="default",disabled:n,className:s,...o}){const l={default:"border border-neutral-200 bg-white text-neutral-700 hover:bg-neutral-50",primary:"bg-blue-600 text-white hover:bg-blue-700 disabled:bg-blue-300",danger:"border border-red-200 bg-white text-red-600 hover:bg-red-50",ghost:"text-neutral-600 hover:bg-neutral-100"}[e];return S.jsx("button",{onClick:t,disabled:n,className:Ci("inline-flex h-8 items-center justify-center gap-1.5 rounded-md px-3 text-[13px] font-medium transition-colors disabled:opacity-50 disabled:cursor-default",l,s),...o,children:a})}function SR({value:a,defaultValue:t,onCommit:e,placeholder:n,className:s,prefix:o}){return S.jsxs("label",{className:Ci("flex h-8 items-center gap-1.5 rounded-md border border-neutral-200 bg-white px-2 focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-100",s),children:[o&&S.jsx("span",{className:"text-[11px] text-neutral-400",children:o}),S.jsx("input",{className:"min-w-0 flex-1 bg-transparent text-[13px] text-neutral-800 outline-none placeholder:text-neutral-300",value:a,defaultValue:t,placeholder:n,onChange:a!==void 0?l=>e(l.target.value):void 0,onBlur:a===void 0?l=>e(l.target.value):void 0,onKeyDown:l=>{l.key==="Enter"&&l.target.blur()}})]})}function Ue({label:a,defaultValue:t,onCommit:e,step:n=.5,min:s}){return S.jsxs("label",{className:"flex h-8 min-w-0 flex-1 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-100",children:[a&&S.jsx("span",{className:"shrink-0 text-[10.5px] font-medium text-neutral-400",children:a}),S.jsx("input",{type:"number",step:n,min:s,defaultValue:t,onBlur:o=>{const l=parseFloat(o.target.value);Number.isFinite(l)&&e(l)},onKeyDown:o=>{o.key==="Enter"&&o.target.blur()},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-neutral-800 outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"})]})}function AR({value:a,onChange:t,children:e}){return S.jsx("select",{value:a,onChange:n=>t(n.target.value),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-2 text-[13px] text-neutral-800 outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-100",children:e})}function ux({title:a,onClose:t,children:e,footer:n}){const s=F.useRef(null);return F.useEffect(()=>{var l,c;const o=d=>{d.key==="Escape"&&t()};return window.addEventListener("keydown",o),(c=(l=s.current)==null?void 0:l.querySelector("input, textarea, button"))==null||c.focus(),()=>window.removeEventListener("keydown",o)},[t]),S.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/30 p-4",onMouseDown:t,children:S.jsxs("div",{ref:s,className:"w-full max-w-sm overflow-hidden rounded-xl bg-white shadow-2xl ring-1 ring-black/5",onMouseDown:o=>o.stopPropagation(),children:[S.jsxs("div",{className:"flex items-center justify-between border-b border-neutral-100 px-4 py-3",children:[S.jsx("h2",{className:"text-sm font-semibold text-neutral-800",children:a}),S.jsx("button",{onClick:t,className:"grid h-7 w-7 place-items-center rounded-md text-neutral-400 hover:bg-neutral-100",children:S.jsx(ax,{size:16})})]}),S.jsx("div",{className:"space-y-3 px-4 py-4",children:e}),n&&S.jsx("div",{className:"flex justify-end gap-2 border-t border-neutral-100 bg-neutral-50 px-4 py-3",children:n})]})})}function Bg({children:a}){return S.jsx("div",{className:"mb-1 text-[12px] font-medium text-neutral-600",children:a})}function _R({message:a,tone:t="info"}){return a?S.jsx("div",{className:"pointer-events-none fixed bottom-5 left-1/2 z-40 -translate-x-1/2",children:S.jsx("div",{className:Ci("rounded-lg px-4 py-2 text-[13px] font-medium shadow-lg ring-1",t==="error"?"bg-red-600 text-white ring-red-700":"bg-neutral-900 text-white ring-black/10"),children:a})}):null}const Vv={text:"Texto",checkbox:"Checkbox",radio:"Radio",select:"Select",list:"Lista",button:"Botón",signature:"Firma"},ji=a=>(Math.round(a*10)/10).toString();function wa({children:a}){return S.jsx("aside",{className:"thin-scroll flex w-[300px] shrink-0 flex-col overflow-y-auto border-l border-neutral-200 bg-white",children:a})}function cc({title:a,subtitle:t,onClose:e}){return S.jsxs("div",{className:"flex items-center justify-between border-b border-neutral-100 px-3 py-2.5",children:[S.jsxs("div",{className:"min-w-0",children:[S.jsx("div",{className:"truncate text-[13px] font-semibold text-neutral-800",children:a}),t&&S.jsx("div",{className:"truncate text-[11px] text-neutral-400",children:t})]}),e&&S.jsx("button",{onClick:e,className:"grid h-6 w-6 shrink-0 place-items-center rounded text-neutral-400 hover:bg-neutral-100",children:S.jsx(ax,{size:15})})]})}function ke({title:a,children:t}){return S.jsxs("div",{className:"border-b border-neutral-100 px-3 py-3",children:[S.jsx("div",{className:"mb-2 text-[10.5px] font-semibold uppercase tracking-[0.08em] text-neutral-400",children:a}),S.jsx("div",{className:"space-y-2",children:t})]})}function ws({children:a}){return S.jsx("div",{className:"flex items-center gap-2",children:a})}function ER({seg:a,edit:t}){const e=(t==null?void 0:t.runs)??Pu(a);return!(t!=null&&t.runs)&&t?S.jsx("span",{children:t.text}):S.jsx("span",{children:e.map((n,s)=>S.jsx("span",{style:{fontWeight:n.bold?700:400,fontStyle:n.italic?"italic":"normal"},children:n.text},s))})}function _h({icon:a,label:t,meta:e,active:n,edited:s,onClick:o,right:l,lockable:c}){return S.jsxs("div",{role:"button",tabIndex:0,onClick:o,onKeyDown:d=>{d.key==="Enter"&&(o==null||o())},className:Ci("group flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",n?"bg-blue-50":"hover:bg-neutral-50"),children:[S.jsx("span",{className:Ci("shrink-0",s?"text-amber-600":"text-neutral-400"),children:a}),S.jsxs("span",{className:"min-w-0 flex-1",children:[S.jsx("span",{className:Ci("block truncate text-[12.5px]",s?"text-amber-700":"text-neutral-700"),children:t}),e&&S.jsx("span",{className:"block truncate text-[10.5px] tabular-nums text-neutral-400",children:e})]}),c&&S.jsx("button",{title:c.locked?"Desbloquear":"Bloquear","aria-label":c.locked?"Desbloquear":"Bloquear",onClick:d=>{d.stopPropagation(),c.onToggle()},className:Ci("grid h-6 w-6 shrink-0 place-items-center rounded transition-opacity hover:bg-neutral-200/60",c.locked?"text-blue-600 opacity-100":"text-neutral-400 opacity-0 group-hover:opacity-100"),children:c.locked?S.jsx(g_,{size:13}):S.jsx(m_,{size:13})}),l]})}function kR(a){const{graph:t,selectedId:e,onSelect:n,edits:s,imageEdits:o,widgetEdits:l,highlightEdits:c,linkEdits:d,locked:f,onToggleLock:g}=a;if(!t)return S.jsx(wa,{});const m=t.segments.find(R=>R.id===e)??null,y=t.images.find(R=>R.id===e)??null,x=t.widgets.find(R=>R.id===e)??null,b=t.highlights.find(R=>R.id===e)??null,A=t.links.find(R=>R.id===e)??null,C=R=>S.jsx(ke,{title:"Estado",children:S.jsx(Be,{variant:f.has(R)?"primary":"default",className:"w-full",onClick:()=>g(R),children:f.has(R)?S.jsxs(S.Fragment,{children:[S.jsx(m_,{size:14})," Desbloquear"]}):S.jsxs(S.Fragment,{children:[S.jsx(g_,{size:14})," Bloquear"]})})}),E=(R,j)=>[...R].sort((O,H)=>{const X=q=>j(q)===e?0:f.has(j(q))?1:2;return X(O)-X(H)}),N=t.lines.flatMap(R=>R.segments),k=[];t.links.length>0&&k.push({key:"links",count:t.links.length,node:S.jsx(ke,{title:`Links (${t.links.length})`,children:E(t.links,R=>R.id).map(R=>{var j;return S.jsx(_h,{icon:S.jsx(TM,{size:14}),onClick:()=>n(R.id),active:e===R.id,edited:d.has(R.id),lockable:{locked:f.has(R.id),onToggle:()=>g(R.id)},label:`${R.url}${(j=d.get(R.id))!=null&&j.remove?" · eliminado":""}`,meta:`x ${ji(R.x)} · y ${ji(R.y)}`,right:S.jsx("button",{title:"Borrar link (se escribe con Aplicar)",onClick:O=>{O.stopPropagation();const H=Vh(R,d.get(R.id)??null,{remove:!0});H&&a.onLinkEdit(H)},className:"grid h-6 w-6 shrink-0 place-items-center rounded text-neutral-400 hover:bg-red-50 hover:text-red-600",children:S.jsx(Ur,{size:13})})},R.id)})})}),t.highlights.length>0&&k.push({key:"highlights",count:t.highlights.length,node:S.jsx(ke,{title:`Resaltados (${t.highlights.length})`,children:E(t.highlights,R=>R.id).map(R=>{var j;return S.jsx(_h,{onClick:()=>n(R.id),active:e===R.id,edited:c.has(R.id),lockable:{locked:f.has(R.id),onToggle:()=>g(R.id)},icon:S.jsx("span",{className:"grid place-items-center",children:S.jsx("span",{className:"h-3.5 w-3.5 rounded-[3px]",style:{background:R.color}})}),label:`${Math.round(R.width)}×${Math.round(R.height)} pt${(j=c.get(R.id))!=null&&j.remove?" · eliminado":""}`,meta:`x ${ji(R.x)} · y ${ji(R.y)}`},R.id)})})}),t.images.length>0&&k.push({key:"images",count:t.images.length,node:S.jsx(ke,{title:`Imágenes (${t.images.length})`,children:E(t.images,R=>R.id).map(R=>{var j;return S.jsx(_h,{icon:S.jsx(AM,{size:14}),onClick:()=>n(R.id),active:e===R.id,edited:o.has(R.id),lockable:{locked:f.has(R.id),onToggle:()=>g(R.id)},label:`${Math.round(R.width)}×${Math.round(R.height)} pt${(j=o.get(R.id))!=null&&j.remove?" · eliminada":""}`,meta:`x ${ji(R.x)} · y ${ji(R.y)}${R.rotated?" · rotada":""}`},R.id)})})}),t.widgets.length>0&&k.push({key:"widgets",count:t.widgets.length,node:S.jsx(ke,{title:`Campos (${t.widgets.length})`,children:E(t.widgets,R=>R.id).map(R=>S.jsx(_h,{icon:S.jsx(b_,{size:14}),onClick:()=>n(R.id),active:e===R.id,edited:l.has(R.id),lockable:{locked:f.has(R.id),onToggle:()=>g(R.id)},label:R.fieldName||"(sin nombre)",meta:`${Vv[R.widgetType]} · x ${ji(R.x)} · y ${ji(R.y)}`},R.id))})}),t.segments.length>0&&k.push({key:"text",count:t.segments.length,node:S.jsx(ke,{title:`Texto (${t.segments.length})`,children:E(N,R=>R.id).map(R=>S.jsx(_h,{icon:S.jsx(s2,{size:14}),onClick:()=>n(R.id),edited:s.has(R.id),active:e===R.id,lockable:{locked:f.has(R.id),onToggle:()=>g(R.id)},label:S.jsx(ER,{seg:R,edit:s.get(R.id)??null}),meta:`x ${ji(R.x)} · y ${ji(R.baseline)} · ${ji(R.fontSize)} pt`},R.id))})}),k.sort((R,j)=>R.count-j.count);const L=S.jsx(S.Fragment,{children:k.map(R=>S.jsx(F.Fragment,{children:R.node},R.key))});return x?S.jsxs(wa,{children:[S.jsx(cc,{title:x.fieldName||"Campo",subtitle:Vv[x.widgetType],onClose:()=>n(null)}),S.jsx(RR,{widget:x,edit:l.get(x.id)??null,onWidgetEdit:a.onWidgetEdit,onDocOp:a.onDocOp}),C(x.id),L]}):y?S.jsxs(wa,{children:[S.jsx(cc,{title:"Imagen",subtitle:`${Math.round(y.width)}×${Math.round(y.height)} pt`,onClose:()=>n(null)}),S.jsx(TR,{img:y,edit:o.get(y.id)??null,onImageEdit:a.onImageEdit}),C(y.id),L]}):m?S.jsxs(wa,{children:[S.jsx(cc,{title:"Texto",subtitle:`${ji(m.fontSize)} pt`,onClose:()=>n(null)}),S.jsx(CR,{seg:m,edit:s.get(m.id)??null,onEdit:a.onEdit}),C(m.id),L]}):b?S.jsxs(wa,{children:[S.jsx(cc,{title:"Resaltado",subtitle:b.color,onClose:()=>n(null)}),S.jsx(PR,{hl:b,edit:c.get(b.id)??null,onHighlightEdit:a.onHighlightEdit}),C(b.id),L]}):A?S.jsxs(wa,{children:[S.jsx(cc,{title:"Link",subtitle:A.url,onClose:()=>n(null)}),S.jsx(MR,{link:A,edit:d.get(A.id)??null,onLinkEdit:a.onLinkEdit}),C(A.id),L]}):S.jsxs(wa,{children:[S.jsx(cc,{title:`Página ${t.page}`,subtitle:`${t.width.toFixed(0)}×${t.height.toFixed(0)} pt`}),L]})}function CR({seg:a,edit:t,onEdit:e}){const n=d=>{const f=ka(a,t,d);e(f??{segmentId:a.id,revert:!0})},s=a.runs.reduce((d,f)=>f.width>d.width?f:d),o=(t==null?void 0:t.font)??"original",l=(d,f)=>g=>{const m=Math.round(g*10)/10;n({[d]:m===Math.round(f*10)/10?null:m})},c=(t==null?void 0:t.remove)===!0;return S.jsxs(S.Fragment,{children:[S.jsx(ke,{title:"Contenido",children:S.jsx(SR,{defaultValue:(t==null?void 0:t.text)??a.text,onCommit:d=>n({text:d})})}),S.jsxs(ke,{title:"Avanzado",children:[S.jsxs(AR,{value:o,onChange:d=>n({font:d==="original"?null:d}),children:[S.jsxs("option",{value:"original",children:[s.font.postScriptName," (original)"]}),S.jsx("option",{value:"sans",children:"Sans"}),S.jsx("option",{value:"serif",children:"Serif"}),S.jsx("option",{value:"mono",children:"Mono"})]}),S.jsxs(ws,{children:[S.jsx(Ue,{label:"AV",step:.1,defaultValue:(t==null?void 0:t.charSpacing)??0,onCommit:d=>n({charSpacing:d===0?null:d})}),S.jsx(Ue,{label:"↔ %",step:1,min:10,defaultValue:(t==null?void 0:t.hScale)??100,onCommit:d=>n({hScale:d<=0||d===100?null:d})})]})]}),S.jsx(ke,{title:"Posición (pt)",children:S.jsxs(ws,{children:[S.jsx(Ue,{label:"X",defaultValue:(t==null?void 0:t.x)??a.x,onCommit:l("x",a.x)}),S.jsx(Ue,{label:"Y",defaultValue:(t==null?void 0:t.baseline)??a.baseline,onCommit:l("baseline",a.baseline)})]})}),S.jsxs(ke,{title:"Acciones",children:[c&&S.jsxs(Be,{variant:"danger",className:"w-full",onClick:()=>n({remove:null}),children:[S.jsx(zr,{size:14})," Restaurar"]}),t&&S.jsxs(Be,{variant:"ghost",className:"w-full",onClick:()=>e({segmentId:a.id,revert:!0}),children:[S.jsx(zr,{size:14})," Revertir cambios"]}),!t&&S.jsx("div",{className:"text-[11px] text-neutral-400",children:"Formato y acciones: en la barra sobre el objeto."})]})]})}function TR({img:a,edit:t,onImageEdit:e}){const n=l=>{const c=Uh(a,t,l);e(c??{imageId:a.id,revert:!0})},s=Og(a,t),o=(l,c)=>d=>{const f=Math.round(d*10)/10;n({[l]:f===Math.round(c*10)/10?null:f})};return S.jsxs(S.Fragment,{children:[a.rotated&&S.jsx("div",{className:"border-b border-neutral-100 bg-amber-50 px-3 py-2 text-[11px] text-amber-700",children:"Imagen con rotación: mover/escalar no soportado aún."}),S.jsxs(ke,{title:"Geometría (pt)",children:[S.jsxs(ws,{children:[S.jsx(Ue,{label:"X",defaultValue:s.x,onCommit:o("x",a.x)}),S.jsx(Ue,{label:"Y",defaultValue:s.y,onCommit:o("y",a.y)})]}),S.jsxs(ws,{children:[S.jsx(Ue,{label:"W",defaultValue:s.width,onCommit:o("width",a.width)}),S.jsx(Ue,{label:"H",defaultValue:s.height,onCommit:o("height",a.height)})]})]}),S.jsx(ke,{title:"Orden",children:S.jsxs(ws,{children:[S.jsxs(Be,{className:"flex-1",onClick:()=>n({zOrder:"back"}),children:[S.jsx(y_,{size:14})," Al fondo"]}),S.jsxs(Be,{className:"flex-1",onClick:()=>n({zOrder:"front"}),children:[S.jsx(d_,{size:14})," Al frente"]})]})}),S.jsxs(ke,{title:"Acciones",children:[S.jsx(Be,{variant:"danger",className:"w-full",onClick:()=>n({remove:s.removed?null:!0}),children:s.removed?S.jsxs(S.Fragment,{children:[S.jsx(zr,{size:14})," Restaurar imagen"]}):S.jsxs(S.Fragment,{children:[S.jsx(Ur,{size:14})," Eliminar imagen"]})}),t&&S.jsxs(Be,{variant:"ghost",className:"w-full",onClick:()=>e({imageId:a.id,revert:!0}),children:[S.jsx(zr,{size:14})," Revertir"]})]})]})}function PR({hl:a,edit:t,onHighlightEdit:e}){const n=l=>{const c=yc(a,t,l);e(c??{highlightId:a.id,revert:!0})},s=$g(a,t),o=(l,c)=>d=>{const f=Math.round(d*10)/10;n({[l]:f===Math.round(c*10)/10?null:f})};return S.jsxs(S.Fragment,{children:[S.jsxs(ke,{title:"Anotación",children:[S.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[S.jsx("span",{className:"text-neutral-400",children:"Color"}),S.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-neutral-700",title:"Cambiar el color del resaltado",children:[S.jsx("span",{className:"h-3.5 w-3.5 rounded-[3px] ring-1 ring-black/10",style:{background:s.color}}),s.color,S.jsx("input",{type:"color",className:"sr-only",value:s.color,onChange:l=>n({color:l.target.value.toLowerCase()===a.color.toLowerCase()?null:l.target.value})})]})]}),S.jsx("div",{className:"text-[11px] text-neutral-400",children:"Capa /Annots: se mueve, recolorea y borra sin tocar el contenido — incluso después de Aplicar."})]}),S.jsxs(ke,{title:"Geometría (pt)",children:[S.jsxs(ws,{children:[S.jsx(Ue,{label:"X",defaultValue:s.x,onCommit:o("x",a.x)}),S.jsx(Ue,{label:"Y",defaultValue:s.y,onCommit:o("y",a.y)})]}),S.jsxs(ws,{children:[S.jsx(Ue,{label:"W",defaultValue:s.width,onCommit:o("width",a.width)}),S.jsx(Ue,{label:"H",defaultValue:s.height,onCommit:o("height",a.height)})]})]}),S.jsxs(ke,{title:"Acciones",children:[S.jsx(Be,{variant:"danger",className:"w-full",onClick:()=>n({remove:s.removed?null:!0}),children:s.removed?S.jsxs(S.Fragment,{children:[S.jsx(zr,{size:14})," Restaurar resaltado"]}):S.jsxs(S.Fragment,{children:[S.jsx(ox,{size:14})," Eliminar resaltado"]})}),t&&S.jsxs(Be,{variant:"ghost",className:"w-full",onClick:()=>e({highlightId:a.id,revert:!0}),children:[S.jsx(zr,{size:14})," Revertir"]})]})]})}function MR({link:a,edit:t,onLinkEdit:e}){const n=l=>{const c=Vh(a,t,l);e(c??{linkId:a.id,revert:!0})},s=zg(a,t),o=(l,c)=>d=>{const f=Math.round(d*10)/10;n({[l]:f===Math.round(c*10)/10?null:f})};return S.jsxs(S.Fragment,{children:[S.jsx(ke,{title:"Destino",children:S.jsx("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"block truncate text-[12.5px] text-blue-600 hover:underline",children:a.url})}),S.jsxs(ke,{title:"Geometría (pt)",children:[S.jsxs(ws,{children:[S.jsx(Ue,{label:"X",defaultValue:s.x,onCommit:o("x",a.x)}),S.jsx(Ue,{label:"Y",defaultValue:s.y,onCommit:o("y",a.y)})]}),S.jsxs(ws,{children:[S.jsx(Ue,{label:"W",defaultValue:s.width,onCommit:o("width",a.width)}),S.jsx(Ue,{label:"H",defaultValue:s.height,onCommit:o("height",a.height)})]})]}),S.jsxs(ke,{title:"Acciones",children:[S.jsx(Be,{variant:"danger",className:"w-full",onClick:()=>n({remove:s.removed?null:!0}),children:s.removed?S.jsxs(S.Fragment,{children:[S.jsx(zr,{size:14})," Restaurar link"]}):S.jsxs(S.Fragment,{children:[S.jsx(Ur,{size:14})," Eliminar link"]})}),t&&S.jsxs(Be,{variant:"ghost",className:"w-full",onClick:()=>e({linkId:a.id,revert:!0}),children:[S.jsx(zr,{size:14})," Revertir"]})]})]})}function RR({widget:a,edit:t,onWidgetEdit:e,onDocOp:n}){const s=c=>{const d=kg(a,t,c);e(d??{widgetId:a.id,revert:!0})},o=jg(a,t),l=(c,d)=>f=>{const g=Math.round(f*10)/10;s({[c]:g===Math.round(d*10)/10?null:g})};return S.jsxs(S.Fragment,{children:[S.jsxs(ke,{title:"Campo",children:[S.jsxs("div",{className:"flex justify-between text-[12px]",children:[S.jsx("span",{className:"text-neutral-400",children:"Tipo"}),S.jsx("span",{className:"text-neutral-700",children:Vv[a.widgetType]})]}),S.jsxs("div",{className:"flex justify-between text-[12px]",children:[S.jsx("span",{className:"text-neutral-400",children:"Nombre"}),S.jsx("span",{className:"truncate pl-2 text-neutral-700",children:a.fieldName||"(sin nombre)"})]}),a.readOnly&&S.jsxs("div",{className:"flex justify-between text-[12px]",children:[S.jsx("span",{className:"text-neutral-400",children:"Flags"}),S.jsx("span",{className:"text-neutral-700",children:"read-only"})]})]}),S.jsxs(ke,{title:"Geometría (pt)",children:[S.jsxs(ws,{children:[S.jsx(Ue,{label:"X",defaultValue:o.x,onCommit:l("x",a.x)}),S.jsx(Ue,{label:"Y",defaultValue:o.y,onCommit:l("y",a.y)})]}),S.jsxs(ws,{children:[S.jsx(Ue,{label:"W",defaultValue:o.width,onCommit:l("width",a.width)}),S.jsx(Ue,{label:"H",defaultValue:o.height,onCommit:l("height",a.height)})]})]}),(a.widgetType==="select"||a.widgetType==="list")&&S.jsxs(ke,{title:"Opciones (una por línea)",children:[S.jsx("textarea",{defaultValue:(a.options??[]).join(`
336
+ `),rows:4,className:"w-full resize-y rounded-md border border-neutral-200 px-2 py-1.5 text-[13px] outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-100",onBlur:c=>{const d=c.target.value.split(`
337
+ `).map(f=>f.trim()).filter(Boolean);d.length&&d.join(`
338
+ `)!==(a.options??[]).join(`
339
+ `)&&n("setFieldOptions",{fieldName:a.fieldName,options:d})}}),S.jsx("div",{className:"text-[11px] text-neutral-400",children:"Se guardan al salir del campo."})]}),a.widgetType==="radio"&&S.jsxs(ke,{title:"Grupo de radios",children:[S.jsxs("div",{className:"text-[11px] text-neutral-400",children:['Las opciones del mismo grupo comparten el nombre "',a.fieldName,'" — se selecciona una sola a la vez.']}),S.jsx(Be,{className:"w-full",onClick:()=>n("addRadioOption",{fieldName:a.fieldName,page:a.page,x:a.x,y:a.y-a.height-8}),children:"Agregar opción al grupo"})]}),S.jsx(ke,{title:"Acciones",children:S.jsx(Be,{variant:"danger",className:"w-full",onClick:()=>s({remove:t!=null&&t.remove?null:!0}),children:t!=null&&t.remove?S.jsxs(S.Fragment,{children:[S.jsx(zr,{size:14})," Restaurar campo"]}):S.jsxs(S.Fragment,{children:[S.jsx(Ur,{size:14})," ",a.widgetType==="radio"?"Eliminar grupo completo":"Eliminar campo"]})})})]})}function mo(a,t){const e=[],n=/(`[^`]+`)|(\*\*[^*]+\*\*)|(__[^_]+__)|(\*[^*\n]+\*)|(_[^_\n]+_)|(\[[^\]]+\]\([^)]+\))/g;let s=0,o,l=0;for(;(o=n.exec(a))!==null;){o.index>s&&e.push(a.slice(s,o.index));const c=o[0],d=`${t}-${l++}`;if(c.startsWith("`"))e.push(S.jsx("code",{className:"ai-code",children:c.slice(1,-1)},d));else if(c.startsWith("**")||c.startsWith("__"))e.push(S.jsx("strong",{children:mo(c.slice(2,-2),d)},d));else if(c.startsWith("*")||c.startsWith("_"))e.push(S.jsx("em",{children:mo(c.slice(1,-1),d)},d));else{const f=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c);f?e.push(S.jsx("a",{href:f[2],target:"_blank",rel:"noreferrer",children:f[1]},d)):e.push(c)}s=o.index+c.length}return s<a.length&&e.push(a.slice(s)),e}const by=/^```/,qb=/^(#{1,6})\s+(.*)$/,Gp=/^\s*[-*+]\s+/,Xp=/^\s*\d+\.\s+/,NR=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;function Wv(a){return a.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}function LR(a){return Wv(a).map(t=>{const e=t.startsWith(":"),n=t.endsWith(":");return e&&n?"center":n?"right":"left"})}function IR({text:a,caret:t}){const e=a.split(`
340
+ `),n=[];let s=0,o=0;for(;s<e.length;){const l=e[s];if(by.test(l.trim())){const g=[];for(s++;s<e.length&&!by.test(e[s].trim());)g.push(e[s]),s++;s++,n.push(S.jsx("pre",{className:"ai-pre",children:S.jsx("code",{children:g.join(`
341
+ `)})},o++));continue}const c=qb.exec(l);if(c){const g=`h${Math.min(c[1].length+2,6)}`;n.push(S.jsx(g,{className:"ai-h",children:mo(c[2],`h${o++}`)},o)),s++;continue}if(Gp.test(l)){const g=[];for(;s<e.length&&Gp.test(e[s]);){const m=e[s].replace(Gp,"");g.push(S.jsx("li",{children:mo(m,`ul${o}-${g.length}`)},g.length)),s++}n.push(S.jsx("ul",{className:"ai-list",children:g},o++));continue}if(Xp.test(l)){const g=[];for(;s<e.length&&Xp.test(e[s]);){const m=e[s].replace(Xp,"");g.push(S.jsx("li",{children:mo(m,`ol${o}-${g.length}`)},g.length)),s++}n.push(S.jsx("ol",{className:"ai-list",children:g},o++));continue}if(l.includes("|")&&s+1<e.length&&NR.test(e[s+1])){const g=Wv(l),m=LR(e[s+1]);s+=2;const y=[];for(;s<e.length&&e[s].includes("|")&&e[s].trim()!=="";)y.push(Wv(e[s])),s++;const x=o++;n.push(S.jsx("div",{className:"ai-table-wrap",children:S.jsxs("table",{className:"ai-table",children:[S.jsx("thead",{children:S.jsx("tr",{children:g.map((b,A)=>S.jsx("th",{style:{textAlign:m[A]??"left"},children:mo(b,`th${x}-${A}`)},A))})}),S.jsx("tbody",{children:y.map((b,A)=>S.jsx("tr",{children:g.map((C,E)=>S.jsx("td",{style:{textAlign:m[E]??"left"},children:mo(b[E]??"",`td${x}-${A}-${E}`)},E))},A))})]})},x));continue}if(l.trim()===""){s++;continue}const d=[];for(;s<e.length&&e[s].trim()!==""&&!by.test(e[s].trim())&&!qb.test(e[s])&&!Gp.test(e[s])&&!Xp.test(e[s]);)d.push(e[s]),s++;const f=o++;n.push(S.jsx("p",{className:"ai-p",children:d.map((g,m)=>S.jsxs(F.Fragment,{children:[m>0&&S.jsx("br",{}),mo(g,`p${f}-${m}`)]},m))},f))}if(t){const l=S.jsx("span",{className:"ai-cursor"},"caret"),c=n.length-1,d=n[c];if(F.isValidElement(d)){const f=d.props.children,g=[...Array.isArray(f)?f:f!=null?[f]:[],l];n[c]=F.cloneElement(d,void 0,...g)}else n.push(l)}return S.jsx("div",{className:"ai-md",children:n})}const DR=`
342
+ .ai-md > :first-child { margin-top: 0; }
343
+ .ai-md > :last-child { margin-bottom: 0; }
344
+ .ai-p, .ai-list { margin: 0 0 7px; }
345
+ .ai-list { padding-left: 18px; }
346
+ .ai-md li { margin: 2px 0; }
347
+ .ai-h { margin: 6px 0 4px; font-size: 13px; font-weight: 650; line-height: 1.4; }
348
+ .ai-md a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
349
+ .ai-code { background: color-mix(in srgb, var(--ink) 7%, transparent); padding: 1px 5px; border-radius: 5px;
350
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
351
+ .ai-pre { background: color-mix(in srgb, var(--ink) 5%, transparent); border: 1px solid var(--line);
352
+ border-radius: 8px; padding: 8px 10px; margin: 0 0 7px; overflow-x: auto; }
353
+ .ai-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: pre; }
354
+ .ai-cursor { display: inline-block; width: 6px; height: 13px; margin-left: 1px;
355
+ background: var(--muted); vertical-align: -1px; border-radius: 1px;
356
+ animation: aiBlink 1.05s steps(1) infinite; }
357
+ @keyframes aiBlink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
358
+ .ai-table-wrap { overflow-x: auto; margin: 0 0 8px; }
359
+ .ai-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
360
+ .ai-table th, .ai-table td { border: 1px solid var(--line); padding: 5px 9px; line-height: 1.4; vertical-align: top; }
361
+ .ai-table th { background: color-mix(in srgb, var(--ink) 5%, transparent); font-weight: 600; color: var(--ink); }
362
+ .ai-table tr:nth-child(even) td { background: color-mix(in srgb, var(--ink) 2.5%, transparent); }
363
+ `,FR=.28,OR=24,jR=340;function $R({text:a,active:t}){const[e,n]=F.useState(t?0:a.length),s=F.useRef(t?0:a.length),o=F.useRef(),l=F.useRef(a.length);a.length<l.current&&(s.current=0),l.current=a.length,F.useEffect(()=>{if(!t){s.current=a.length,n(a.length);return}let d=0;const f=g=>{const m=a.length,y=d?Math.min((g-d)/1e3,.05):0;d=g;const x=m-s.current;if(x>0){const b=Math.max(OR,Math.min(jR,x/FR));s.current=Math.min(m,s.current+b*y),n(Math.floor(s.current))}o.current=requestAnimationFrame(f)};return o.current=requestAnimationFrame(f),()=>{o.current&&cancelAnimationFrame(o.current)}},[a,t]);const c=t?a.slice(0,e):a;return S.jsx(IR,{text:c,caret:t})}const Sy=lx("aldus:panel"),zR={edit_document:"delegando al editor",verify_layout:"verificando layout",edit_text:"editando texto",move_text:"moviendo texto",set_text_color:"coloreando texto",set_text_size:"cambiando tamaño",delete_text:"eliminando texto",move_image:"moviendo imagen",delete_image:"eliminando imagen",highlight_text:"resaltando",set_highlight_color:"recoloreando resaltado",delete_highlight:"quitando resaltado",add_link:"creando link",delete_link:"quitando link",add_text:"agregando texto",insert_image:"insertando imagen",add_watermark:"poniendo watermark",add_header_footer:"encabezado/pie",add_form_field:"creando campo",placeholders_to_fields:"convirtiendo a inputs",fill_field:"completando campo",fill_fields:"completando campos",move_field:"moviendo campo",delete_field:"eliminando campo"},HR=a=>zR[a.replace("mcp__aldus__","")]??a;function BR(a,t,e){const n=[...a],s=n[n.length-1];return s&&s.kind==="text"&&s.agent===e?n[n.length-1]={...s,text:s.text+t}:n.push({kind:"text",text:t,agent:e}),n}function UR(a){const t=[];for(const e of a){let n=t[t.length-1];(!n||n.agent!==e.agent)&&(n={agent:e.agent,rows:[]},t.push(n));const s=n.rows[n.rows.length-1];e.kind==="tool"?s&&s.kind==="tools"?s.names.push(e.name):n.rows.push({kind:"tools",names:[e.name]}):n.rows.push({kind:"text",text:e.text})}return t}const VR=["Resumí de qué trata el documento","Poné el título en mayúsculas","Corregí las faltas de ortografía del título"];function WR({docId:a,page:t,edits:e,imageEdits:n,onApply:s,onReload:o,onClose:l}){const[c,d]=F.useState([]),[f,g]=F.useState(""),[m,y]=F.useState(!1),[x,b]=F.useState(0),A=F.useRef(void 0),C=F.useRef(0),E=F.useRef(null);F.useEffect(()=>{var k;(k=E.current)==null||k.scrollTo({top:E.current.scrollHeight,behavior:"smooth"})},[c]),F.useEffect(()=>{if(!m)return;const k=setInterval(()=>b(L=>L+1),500);return()=>clearInterval(k)},[m]);async function N(k){const L=k.trim();if(!L||m)return;const R=C.current===0;C.current++,d(O=>[...O,{role:"user",text:L},{role:"assistant",parts:[],streaming:!0,startedAt:Date.now(),firstTurn:R}]),g(""),y(!0);const j=O=>d(H=>{const X=[...H];return X[X.length-1]=O(X[X.length-1]),X});try{const O=await vs.agentStream(a,L,[...e.values()],[...n.values()],A.current,H=>{const X=H.agent??"chat";H.type==="text"?j(q=>({...q,parts:BR(q.parts??[],H.delta,X)})):H.type==="tool"&&(Sy("tool [%s]: %s",X,H.name),j(q=>({...q,parts:[...q.parts??[],{kind:"tool",name:H.name,agent:X}]})))},t);A.current=O.sessionId??A.current,Sy("done: toolCalls=%d edits=%d reloaded=%s",O.toolCalls,O.edits.length+O.imageEdits.length,!!O.reloaded),O.reloaded?o():s(O.edits,O.imageEdits),j(H=>({...H,streaming:!1,parts:H.parts&&H.parts.length?H.parts:[{kind:"text",text:"(listo)",agent:"chat"}],edits:O.reloaded?0:O.edits.length+O.imageEdits.length,saved:O.reloaded}))}catch(O){const H=O instanceof Error?O.message:"Falló el agente.";Sy("error: %s",H),j(X=>({...X,streaming:!1,error:!0,parts:[...X.parts??[],{kind:"text",text:`⚠️ ${H}`,agent:"chat"}]}))}finally{y(!1)}}return S.jsxs("aside",{className:"flex w-[340px] shrink-0 flex-col border-l border-neutral-200 bg-white",children:[S.jsxs("style",{children:[DR,`@keyframes casper-dots{0%,20%{content:''}40%{content:'.'}60%{content:'..'}80%,100%{content:'...'}}
364
+ .casper-dots::after{content:'';animation:casper-dots 1.4s steps(1,end) infinite}`]}),S.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-neutral-200 px-3",children:[S.jsx(Hv,{size:16,className:"text-blue-600"}),S.jsx("span",{className:"text-[13px] font-semibold tracking-wide text-neutral-900",children:"CASPER"}),S.jsx("span",{className:"text-[11px] text-neutral-400",children:"· MAGI-3 · preguntá o pedí cambios"}),S.jsx("div",{className:"flex-1"}),S.jsx("button",{onClick:l,title:"Cerrar",className:"grid h-7 w-7 place-items-center rounded-md text-neutral-500 hover:bg-neutral-100",children:S.jsx(ax,{size:15})})]}),S.jsxs("div",{ref:E,className:"thin-scroll flex-1 space-y-3 overflow-y-auto p-3",children:[c.length===0&&S.jsxs("div",{className:"mt-2 space-y-2",children:[S.jsx("p",{className:"text-[12px] leading-relaxed text-neutral-500",children:"Tengo el documento entero cargado. Preguntame sobre su contenido o pedime cambios (editar texto, mover imágenes…). Los cambios aparecen en el editor para revisar y guardar."}),S.jsx("div",{className:"flex flex-col gap-1.5 pt-1",children:VR.map(k=>S.jsx("button",{onClick:()=>void N(k),className:"rounded-lg border border-neutral-200 px-2.5 py-1.5 text-left text-[12px] text-neutral-600 hover:border-blue-300 hover:bg-blue-50",children:k},k))})]}),c.map((k,L)=>{if(k.role==="user")return S.jsx("div",{className:"flex flex-col items-end gap-1.5",children:S.jsx("div",{className:"max-w-[85%] whitespace-pre-wrap rounded-2xl bg-blue-600 px-3 py-2 text-[12.5px] leading-relaxed text-white",children:k.text})},L);const R=UR(k.parts??[]),j=k.parts??[],O=j[j.length-1],H=!!k.streaming&&(!O||O.kind==="tool"),X=k.startedAt?(Date.now()-k.startedAt)/1e3:0,q=H&&k.firstTurn&&X>=5,K=(lt,pt,ut)=>lt.map((St,Q)=>St.kind==="text"?St.text.trim()?S.jsx("div",{style:ut?{backgroundColor:"rgba(255,255,255,0.06)",color:"#e6edf3"}:void 0,className:Ci("rounded-2xl px-3 py-2 text-[12.5px] leading-relaxed",k.error?"bg-red-50 text-red-700":ut?"":"bg-neutral-100 text-neutral-800",ut?"max-w-full":"max-w-[85%]"),children:S.jsx($R,{text:St.text,active:pt&&Q===lt.length-1})},Q):null:S.jsx("div",{className:"flex flex-wrap gap-1 px-0.5",children:St.names.map((tt,J)=>S.jsxs("span",{style:ut?{border:"1px solid rgba(255,255,255,0.18)",backgroundColor:"rgba(255,255,255,0.10)",color:"#cfe6f5"}:void 0,className:Ci("rounded-full px-2 py-0.5 text-[10.5px] font-medium",ut?"":"border border-blue-200 bg-blue-100 text-blue-700"),children:["✎ ",HR(tt)]},J))},Q));return S.jsxs("div",{className:"flex flex-col items-start gap-2",children:[R.map((lt,pt)=>{const ut=!!k.streaming&&pt===R.length-1;return lt.agent==="editor"?S.jsxs("div",{style:{backgroundColor:"#172c3a",color:"#e6edf3"},className:"flex w-[92%] flex-col gap-1.5 rounded-lg px-2.5 py-2",children:[S.jsxs("div",{style:{color:"#7cc4e8"},className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider",children:[S.jsx(Hv,{size:11})," editor"]}),K(lt.rows,ut,!0)]},pt):S.jsx("div",{className:"flex w-full flex-col items-start gap-2",children:K(lt.rows,ut,!1)},pt)}),H&&S.jsxs("div",{className:"flex flex-col gap-1 px-1",children:[S.jsxs("span",{style:{color:"#8a8a93"},className:"text-[12px]",children:["Pensando",S.jsx("span",{className:"casper-dots"})]}),q&&S.jsx("span",{style:{color:"#8a8a93"},className:"text-[11px] leading-relaxed",children:"La primera respuesta puede tardar unos segundos."})]}),!k.streaming&&!k.error&&typeof k.edits=="number"&&k.edits>0&&S.jsxs("div",{className:"px-1 text-[11px] font-medium text-blue-600",children:["✎ ",k.edits," edición(es) activa(s) — revisá y guardá"]}),!k.streaming&&!k.error&&k.saved&&S.jsx("div",{className:"px-1 text-[11px] font-medium text-emerald-600",children:"✓ Aplicado y guardado en el documento"})]},L)})]}),S.jsx("div",{className:"shrink-0 border-t border-neutral-200 p-2.5",children:S.jsxs("div",{className:"flex items-end gap-2",children:[S.jsx("textarea",{value:f,onChange:k=>g(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),N(f))},placeholder:"Escribí una pregunta o un cambio…",rows:2,disabled:m,className:"thin-scroll min-h-[38px] flex-1 resize-none rounded-lg border border-neutral-200 px-2.5 py-1.5 text-[12.5px] outline-none focus:border-blue-500 disabled:bg-neutral-50"}),S.jsx("button",{onClick:()=>void N(f),disabled:m||!f.trim(),title:"Enviar (Enter)",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-blue-600 text-white hover:bg-blue-700 disabled:bg-neutral-200 disabled:text-neutral-400",children:S.jsx(VM,{size:16})})]})})]})}function GR({onClose:a,onApply:t}){const[e,n]=F.useState("BORRADOR"),s=()=>{e.trim()&&t(e.trim()),a()};return S.jsx(ux,{title:"Marca de agua",onClose:a,footer:S.jsxs(S.Fragment,{children:[S.jsx(Be,{onClick:a,children:"Cancelar"}),S.jsx(Be,{variant:"primary",onClick:s,children:"Aplicar"})]}),children:S.jsxs("div",{children:[S.jsx(Bg,{children:"Texto (diagonal, en todas las páginas)"}),S.jsx("input",{autoFocus:!0,value:e,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s()},className:"h-9 w-full rounded-md border border-neutral-200 px-3 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-100"})]})})}function XR({onClose:a,onApply:t}){const[e,n]=F.useState(""),[s,o]=F.useState(""),[l,c]=F.useState(!0),d=()=>{(e.trim()||s.trim()||l)&&t({header:e.trim()||void 0,footer:s.trim()||void 0,pageNumbers:l}),a()},f="h-9 w-full rounded-md border border-neutral-200 px-3 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-100";return S.jsxs(ux,{title:"Encabezado y pie de página",onClose:a,footer:S.jsxs(S.Fragment,{children:[S.jsx(Be,{onClick:a,children:"Cancelar"}),S.jsx(Be,{variant:"primary",onClick:d,children:"Aplicar"})]}),children:[S.jsxs("div",{children:[S.jsx(Bg,{children:"Encabezado"}),S.jsx("input",{autoFocus:!0,value:e,onChange:g=>n(g.target.value),placeholder:"(opcional)",className:f})]}),S.jsxs("div",{children:[S.jsx(Bg,{children:"Pie de página"}),S.jsx("input",{value:s,onChange:g=>o(g.target.value),placeholder:"(opcional)",className:f})]}),S.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-neutral-700",children:[S.jsx("input",{type:"checkbox",checked:l,onChange:g=>c(g.target.checked),className:"h-4 w-4 rounded border-neutral-300 accent-blue-600"}),"Numerar páginas ",S.jsx("span",{className:"text-neutral-400",children:"(Página N de M, abajo a la derecha)"})]})]})}function qR({onClose:a,onApply:t}){const[e,n]=F.useState("https://"),s=/^https?:\/\/.+\..+/.test(e.trim()),o=()=>{s&&(t(e.trim()),a())};return S.jsx(ux,{title:"Convertir en link",onClose:a,footer:S.jsxs(S.Fragment,{children:[S.jsx(Be,{onClick:a,children:"Cancelar"}),S.jsx(Be,{variant:"primary",disabled:!s,onClick:o,children:"Crear link"})]}),children:S.jsxs("div",{children:[S.jsx(Bg,{children:"URL de destino"}),S.jsx("input",{autoFocus:!0,value:e,onChange:l=>n(l.target.value),onKeyDown:l=>{l.key==="Enter"&&o()},className:"h-9 w-full rounded-md border border-neutral-200 px-3 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-100"})]})})}function YR(a,t,e=100){const n=F.useRef([]),s=F.useRef([]),[,o]=F.useState(0),l=F.useCallback(y=>{n.current.push(y),n.current.length>e&&n.current.shift(),s.current=[],o(x=>x+1)},[e]),c=F.useCallback(()=>{l({kind:"snap",snap:a()})},[l,a]),d=F.useCallback(y=>{l({kind:"command",...y})},[l]),f=F.useCallback(()=>{const y=n.current.pop();y&&(y.kind==="snap"?(s.current.push({kind:"snap",snap:a()}),t(y.snap)):(s.current.push(y),y.undo()),o(x=>x+1))},[a,t]),g=F.useCallback(()=>{const y=s.current.pop();y&&(y.kind==="snap"?(n.current.push({kind:"snap",snap:a()}),t(y.snap)):(n.current.push(y),y.redo()),o(x=>x+1))},[a,t]),m=F.useCallback(()=>{n.current=[],s.current=[],o(y=>y+1)},[]);return{pushHistory:c,pushCommand:d,undo:f,redo:g,clear:m,get canUndo(){return n.current.length>0},get canRedo(){return s.current.length>0}}}function KR(a,t){const[e,n]=F.useState(new Map),[s,o]=F.useState(new Map),[l,c]=F.useState(new Map),[d,f]=F.useState([]),[g,m]=F.useState(new Map),[y,x]=F.useState(new Map),b=F.useRef(e),A=F.useRef(s),C=F.useRef(l),E=F.useRef(d),N=F.useRef(g),k=F.useRef(y);b.current=e,A.current=s,C.current=l,E.current=d,N.current=g,k.current=y;const L=F.useRef(t);L.current=t;const R=F.useRef(new Map),j=F.useCallback(()=>({e:b.current,i:A.current,w:C.current,h:E.current,hl:N.current,l:k.current}),[]),O=F.useCallback(W=>{var nt;n(W.e),o(W.i),c(W.w),f(W.h),m(W.hl),x(W.l),(nt=L.current)==null||nt.call(L)},[]),H=YR(j,O),{pushHistory:X,clear:q}=H,K=F.useCallback(W=>{var nt;if(!R.current.has(W)){const rt=(nt=a.current)==null?void 0:nt.segments.find(dt=>dt.id===W);rt&&R.current.set(W,rt)}},[a]),lt=F.useCallback(W=>{X(),"revert"in W||K(W.segmentId),n(nt=>{const rt=new Map(nt);return"revert"in W?rt.delete(W.segmentId):rt.set(W.segmentId,W),rt})},[X,K]),pt=F.useCallback(W=>{X(),o(nt=>{const rt=new Map(nt);return"revert"in W?rt.delete(W.imageId):rt.set(W.imageId,W),rt})},[X]),ut=F.useCallback(W=>{X(),c(nt=>{const rt=new Map(nt);return"revert"in W?rt.delete(W.widgetId):rt.set(W.widgetId,W),rt})},[X]),St=F.useCallback(W=>{X(),m(nt=>{const rt=new Map(nt);return"revert"in W?rt.delete(W.highlightId):rt.set(W.highlightId,W),rt})},[X]),Q=F.useCallback(W=>{W.length&&m(nt=>{const rt=new Map(nt);for(const dt of W)"revert"in dt?rt.delete(dt.highlightId):rt.set(dt.highlightId,dt);return rt})},[]),tt=F.useCallback(W=>{X(),x(nt=>{const rt=new Map(nt);return"revert"in W?rt.delete(W.linkId):rt.set(W.linkId,W),rt})},[X]),J=F.useCallback((W,nt)=>{X();for(const rt of W)K(rt.segmentId);n(new Map(W.map(rt=>[rt.segmentId,rt]))),o(new Map(nt.map(rt=>[rt.imageId,rt])))},[X,K]),at=F.useCallback(W=>{W.length&&(X(),f(nt=>[...nt,...W]))},[X]),st=F.useCallback(W=>{E.current.some(nt=>nt.segmentId===W)&&(X(),f(nt=>nt.filter(rt=>rt.segmentId!==W)))},[X]),I=F.useCallback(W=>{var nt;return((nt=a.current)==null?void 0:nt.segments.find(rt=>rt.id===W))??R.current.get(W)??null},[a]),V=F.useCallback(()=>{n(new Map),o(new Map),c(new Map),f([]),m(new Map),x(new Map),R.current.clear(),q()},[q]);return{edits:e,imageEdits:s,widgetEdits:l,pendingHighlights:d,highlightEdits:g,linkEdits:y,editsRef:b,imageEditsRef:A,widgetEditsRef:C,highlightsRef:E,segCache:R,onEdit:lt,onImageEdit:pt,onWidgetEdit:ut,onHighlightEdit:St,onLinkEdit:tt,syncHighlightEdits:Q,applyAgentEdits:J,addHighlights:at,removePendingHighlightsFor:st,findSeg:I,clearAll:V,history:H}}const QR="modulepreload",JR=function(a){return"/"+a},Yb={},qp=function(t,e,n){let s=Promise.resolve();if(e&&e.length>0){let l=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=l(e.map(f=>{if(f=JR(f),f in Yb)return;Yb[f]=!0;const g=f.endsWith(".css"),m=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const y=document.createElement("link");if(y.rel=g?"stylesheet":QR,g||(y.as="script"),y.crossOrigin="",y.href=f,d&&y.setAttribute("nonce",d),document.head.appendChild(y),g)return new Promise((x,b)=>{y.addEventListener("load",x),y.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})};function ZR(a){const{id:t,docVersion:e,edits:n,imageEdits:s,widgetEdits:o,pendingHighlights:l,editsRef:c,highlightsRef:d,graphRef:f,segCache:g}=a,m=F.useRef(a.onError);m.current=a.onError;const[y,x]=F.useState(null),[b,A]=F.useState(null);F.useEffect(()=>{qp(()=>import("./index-L30_R8mi.js"),[])},[]),F.useEffect(()=>{let k=!1;return fetch(`${vs.pdfUrl(t)}?v=${e}`).then(L=>L.ok?L.arrayBuffer():Promise.reject(new Error(String(L.status)))).then(L=>{k||A(new Uint8Array(L))}).catch(L=>{k||m.current(L instanceof Error?L.message:"No se pudo abrir el PDF")}),()=>{k=!0}},[t,e]);const C=F.useCallback(()=>{const k=f.current;return d.current.map(L=>{if(!L.segmentId)return L;const R=(k&&k.page===L.page?k.segments.find(O=>O.id===L.segmentId):void 0)??g.current.get(L.segmentId);if(!R)return L;const j=Qo(R,c.current.get(R.id)??null);return{...L,x:j.x,y:j.y,width:j.width,height:j.height}})},[]),E=F.useCallback(async(k,L)=>{if(!b)throw new Error("documento no cargado");const{bakeSegmentEdits:R}=await qp(async()=>{const{bakeSegmentEdits:q}=await import("./index-L30_R8mi.js");return{bakeSegmentEdits:q}},[]),j=[...n.values()].map(q=>({segmentId:q.segmentId,page:q.page,text:q.original.text,remove:!0,original:q.original}));k&&!n.has(k.id)&&j.push({segmentId:k.id,page:k.page,text:k.text,remove:!0,original:P_(k)});let O=[...s.values()];if(L){const q=Uh(L,null,{remove:!0});q&&(O=[...O.filter(K=>K.imageId!==L.id),q])}const H=await R(b.slice(),j,O,[...o.values()]);for(const[q,K]of Object.entries(H.colors)){const lt=g.current.get(q);lt&&lt.runs.forEach(pt=>{pt.color=K})}const{hideHighlightAnnotations:X}=await qp(async()=>{const{hideHighlightAnnotations:q}=await import("./index-L30_R8mi.js");return{hideHighlightAnnotations:q}},[]);return X(H.pdf)},[b,n,s,o]),N=n.size||s.size||o.size||l.length;return F.useEffect(()=>{if(!b)return;let k=!1;return(async()=>{const L=N?await E():await(await qp(async()=>{const{hideHighlightAnnotations:j}=await import("./index-L30_R8mi.js");return{hideHighlightAnnotations:j}},[])).hideHighlightAnnotations(b);if(k)return;const R=await u_({data:L.slice(),fontExtraProperties:!0}).promise;if(k){R.destroy();return}x(j=>(j==null||j.destroy(),R))})().catch(L=>{k||m.current(L instanceof Error?L.message:"No se pudo generar el preview")}),()=>{k=!0}},[b,E,N,n,s,o,l]),{pdf:y,baseBytes:b,bakePending:E,resolveHighlights:C}}function tN(a){const{selectedId:t,editingActive:e,baseBytes:n,bakePending:s,edits:o,imageEdits:l,pendingHighlights:c,graphRef:d,segCache:f}=a,[g,m]=F.useState(null),[y,x]=F.useState(null),b=F.useRef(!1);F.useEffect(()=>{var j,O;if(e)return;const E=t,N=E&&!o.has(E)?(j=d.current)==null?void 0:j.segments.find(H=>H.id===E):null,k=E&&!N&&!l.has(E)?(O=d.current)==null?void 0:O.images.find(H=>H.id===E):null;if(!N&&!k||!n){b.current||m(H=>(H==null||H.doc.destroy(),null));return}const L=N?N.id:k.id;let R=!1;return(async()=>{const H=N?await s(N):await s(void 0,k);if(R)return;const X=await u_({data:H.slice(),fontExtraProperties:!0}).promise;if(R){X.destroy();return}m(q=>(q==null||q.doc.destroy(),{segId:L,doc:X}))})().catch(()=>{}),()=>{R=!0}},[t,n,s,o,l,c,e]);const A=F.useCallback((E,N,k=!1)=>{var L;if(N){if(!f.current.has(E)){const R=(L=d.current)==null?void 0:L.segments.find(j=>j.id===E);R&&f.current.set(E,R)}x(E);return}x(null),k?b.current=!0:m(R=>(R==null?void 0:R.segId)===E?(R.doc.destroy(),null):R)},[]),C=F.useCallback(()=>{b.current&&(b.current=!1,m(E=>(E==null||E.doc.destroy(),null)))},[]);return{lift:g,draggingId:y,onDragging:A,onPreviewLanded:C}}function eN(a,t){const[e,n]=F.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem(`aldus-locks-${a}`)||"[]"))}catch{return new Set}}),s=F.useCallback(o=>{n(l=>{const c=new Set(l);return c.has(o)?c.delete(o):c.add(o),localStorage.setItem(`aldus-locks-${a}`,JSON.stringify([...c])),c})},[a]);return F.useEffect(()=>{if(!(t!=null&&t.images.length))return;let o;try{o=new Set(JSON.parse(localStorage.getItem(`aldus-autolock-${a}`)||"[]"))}catch{o=new Set}const l=[];let c=!1;for(const d of t.images){if(o.has(d.id))continue;o.add(d.id),c=!0,d.width*d.height/(t.width*t.height)>=.8&&l.push(d.id)}c&&localStorage.setItem(`aldus-autolock-${a}`,JSON.stringify([...o])),l.length&&n(d=>{const f=new Set(d);for(const g of l)f.add(g);return localStorage.setItem(`aldus-locks-${a}`,JSON.stringify([...f])),f})},[t,a]),{locked:e,toggleLock:s}}function nN(a){const[t,e]=F.useState(()=>{try{return new Map(Object.entries(JSON.parse(localStorage.getItem(`aldus-areas-${a}`)||"{}")))}catch{return new Map}}),n=F.useCallback((s,o)=>{e(l=>{const c=new Map(l);return o==null||o.w==null&&o.h==null?c.delete(s):c.set(s,o),localStorage.setItem(`aldus-areas-${a}`,JSON.stringify(Object.fromEntries(c))),c})},[a]);return{areaWidths:t,onAreaWidth:n}}const is=a=>Math.round(a*10)/10;function iN(a){const{id:t,pageNum:e,graph:n}=a,s=F.useRef(a);s.current=a;const[o,l]=F.useState(null),c=F.useRef(null),d=F.useRef(null),f=F.useMemo(()=>{var E,N;if(!(n!=null&&n.segments.length))return{size:11,bucket:"sans"};const x=n.segments.map(k=>k.fontSize).sort((k,L)=>k-L),b=is(x[Math.floor(x.length/2)]),A=new Map;for(const k of n.segments){const L=((E=k.runs[0])==null?void 0:E.font.bucket)??"sans";A.set(L,(A.get(L)??0)+1)}const C=((N=[...A.entries()].sort((k,L)=>L[1]-k[1])[0])==null?void 0:N[0])??"sans";return{size:b,bucket:C}},[n]),g=F.useCallback((x,b)=>{if(!o)return;const A=o;l(null),s.current.onError("");const C=A.kind==="text"?12:f.size;A.kind==="text"&&(d.current={x:is(x),y:is(b),area:{w:240,h:Math.round(C*1.2*2)}});const E=()=>A.kind==="field"?vs.createField(t,{type:A.type,page:e,x:is(x),y:is(b-y2[A.type].height)}):A.kind==="image"?vs.insertImage(t,A.file,{page:e,x:is(x),y:is(b)}):vs.docOp(t,"addText",{page:e,x:is(x),y:is(b),text:"Texto nuevo",size:C,bucket:f.bucket});E().then(()=>{s.current.onBumpDoc(),s.current.onNotice("Creado — doble click para editar"),s.current.onServerOp(E)}).catch(N=>{d.current=null,s.current.onError(N instanceof Error?N.message:"No se pudo crear")})},[o,t,e,f]),m=F.useCallback(x=>{const b=()=>vs.docOp(t,"addText",{page:x.page,x:is(x.x),y:is(x.baseline+x.size),text:x.text,size:x.size,bucket:x.bucket});b().then(()=>{s.current.onBumpDoc(),s.current.onServerOp(b)}).catch(A=>s.current.onError(A instanceof Error?A.message:"No se pudo agregar"))},[t]),y=F.useCallback(x=>{const b=d.current;if(!b)return;const A=x.segments.find(C=>Math.abs(C.x-b.x)<12&&Math.abs(C.baseline-b.y)<20&&C.text==="Texto nuevo");A&&(d.current=null,s.current.onAreaWidth(A.id,b.area),s.current.onSelect(A.id))},[]);return{placing:o,setPlacing:l,imageFileRef:c,pageTextStyle:f,onPlace:g,onAddText:m,matchInsertedText:y}}const Yp=a=>Math.round(a*10)/10;function sN(a){const{pdf:t,pageNum:e,setPageNum:n,selectedId:s,setSelectedId:o,graph:l,edits:c,highlightEdits:d,onEdit:f,onImageEdit:g,onWidgetEdit:m,onHighlightEdit:y,onLinkEdit:x,undo:b,redo:A,findSeg:C,cancelPlacing:E}=a;F.useEffect(()=>{const N=k=>{const L=k.target;if(L&&(L.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(L.tagName)))return;if(k.key==="Escape"){E();return}if((k.metaKey||k.ctrlKey)&&(k.key==="z"||k.key==="Z")){k.preventDefault(),k.shiftKey?A():b();return}if((k.metaKey||k.ctrlKey)&&(k.key==="y"||k.key==="Y")){k.preventDefault(),A();return}if((k.key==="Delete"||k.key==="Backspace")&&s&&l){const O=C(s);if(O){k.preventDefault();const lt=ka(O,c.get(O.id)??null,{remove:!0});lt&&f(lt);return}const H=l.images.find(lt=>lt.id===s);if(H){k.preventDefault(),g({imageId:H.id,page:H.page,remove:!0,original:{x:H.x,y:H.y,width:H.width,height:H.height}});return}const X=l.widgets.find(lt=>lt.id===s);if(X){k.preventDefault(),m({widgetId:X.id,page:X.page,remove:!0,original:{fieldName:X.fieldName,x:X.x,y:X.y,width:X.width,height:X.height}});return}const q=l.highlights.find(lt=>lt.id===s);if(q){k.preventDefault(),y({highlightId:q.id,page:q.page,remove:!0,original:{x:q.x,y:q.y,width:q.width,height:q.height,color:q.color}});return}const K=l.links.find(lt=>lt.id===s);if(K){k.preventDefault(),x({linkId:K.id,page:K.page,remove:!0,original:{url:K.url,x:K.x,y:K.y,width:K.width,height:K.height}});return}}const R=s?C(s):null;if(R&&l&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(k.key)){k.preventDefault();const O=k.shiftKey?5:.5,H=k.key==="ArrowLeft"?-O:k.key==="ArrowRight"?O:0,X=k.key==="ArrowUp"?O:k.key==="ArrowDown"?-O:0,q=c.get(R.id)??null,K=Qo(R,q),lt=Yp(Ru(K.x+H,K.width,l.width)),pt=Or(K.y+X,K.height,l.height),ut=Yp(K.baseline+(pt-K.y)),St=ka(R,q,{x:lt===Yp(R.x)?null:lt,baseline:ut===Yp(R.baseline)?null:ut});f(St??{segmentId:R.id,revert:!0});return}const j=(t==null?void 0:t.numPages)??0;(k.key==="ArrowRight"||k.key==="PageDown")&&e<j?(k.preventDefault(),n(O=>O+1),o(null)):(k.key==="ArrowLeft"||k.key==="PageUp")&&e>1&&(k.preventDefault(),n(O=>O-1),o(null))};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t,e,n,s,o,l,c,d,f,g,m,y,x,b,A,C,E])}const rN=[{label:"Texto",tools:[{id:"text",icon:jM,label:"Texto (la viñeta se activa desde la barra del objeto; Enter continúa listas)",placing:{kind:"text"}}]},{label:"Forms",tools:[{id:"field-text",icon:b_,label:"Campo de texto",placing:{kind:"field",type:"text"}},{id:"field-checkbox",icon:YM,label:"Checkbox",placing:{kind:"field",type:"checkbox"}},{id:"field-radio",icon:dM,label:"Grupo de radios (agregá opciones desde el panel)",placing:{kind:"field",type:"radio"}},{id:"field-select",icon:QM,label:"Select (editá las opciones desde el panel)",placing:{kind:"field",type:"select"}},{id:"field-signature",icon:GM,label:"Campo de firma",placing:{kind:"field",type:"signature"}}]}];function oN(){const{id:a=""}=AC();F.useEffect(()=>{dR(),gR()},[a]);const[t,e]=F.useState(0),[n,s]=F.useState(1),[o,l]=F.useState(()=>{const ft=parseFloat(localStorage.getItem("aldus-zoom")||"");return Number.isFinite(ft)&&ft>=.5&&ft<=3?ft:1.5}),[c,d]=F.useState(null),f=F.useRef(c);f.current=c;const[g,m]=F.useState(null),[y,x]=F.useState(!0),[b,A]=F.useState(!1),[C,E]=F.useState(!1),[N,k]=F.useState(""),[L,R]=F.useState(""),[j,O]=F.useState(null),[H,X]=F.useState(()=>localStorage.getItem("aldus-hl")||"#ffd400"),q=F.useCallback(ft=>{X(ft),localStorage.setItem("aldus-hl",ft)},[]);F.useEffect(()=>{if(!N&&!L)return;const ft=setTimeout(()=>{k(""),R("")},3200);return()=>clearTimeout(ft)},[N,L]);const{edits:K,imageEdits:lt,widgetEdits:pt,pendingHighlights:ut,highlightEdits:St,linkEdits:Q,editsRef:tt,highlightsRef:J,segCache:at,onEdit:st,onImageEdit:I,onWidgetEdit:V,onHighlightEdit:W,onLinkEdit:nt,syncHighlightEdits:rt,applyAgentEdits:dt,addHighlights:mt,removePendingHighlightsFor:Mt,findSeg:Vt,clearAll:ye,history:ve}=KR(f,()=>m(null)),{pushCommand:ue}=ve,te=F.useCallback(ft=>{ue({undo:()=>vs.revert(a).then(()=>e(Ht=>Ht+1)).catch(Ht=>R(Ht instanceof Error?Ht.message:"No se pudo deshacer")),redo:()=>ft().then(()=>e(Ht=>Ht+1)).catch(Ht=>R(Ht instanceof Error?Ht.message:"No se pudo rehacer"))})},[ue,a]),{locked:Xt,toggleLock:ai}=eN(a,c),{areaWidths:Dn,onAreaWidth:Pi}=nN(a),{pdf:Fn,baseBytes:Mi,bakePending:As,resolveHighlights:B}=ZR({id:a,docVersion:t,edits:K,imageEdits:lt,widgetEdits:pt,pendingHighlights:ut,editsRef:tt,highlightsRef:J,graphRef:f,segCache:at,onError:R}),{lift:Z,draggingId:yt,onDragging:Ft,onPreviewLanded:Qt}=tN({selectedId:g,editingActive:b,baseBytes:Mi,bakePending:As,edits:K,imageEdits:lt,pendingHighlights:ut,graphRef:f,segCache:at}),{placing:Lt,setPlacing:ht,imageFileRef:ie,onPlace:Zt,onAddText:pe,matchInsertedText:Ge}=iN({id:a,pageNum:n,graph:c,onBumpDoc:()=>e(ft=>ft+1),onNotice:k,onError:R,onAreaWidth:Pi,onSelect:m,onServerOp:te}),$t=F.useCallback(ft=>{d(ft),Qt(),Ge(ft)},[Qt,Ge]),tn=F.useCallback((ft,Ht)=>{if(ft==="highlight"){const _s=Array.isArray(Ht.items)?Ht.items:[Ht];mt(_s);return}if(ft==="unhighlight"){Mt(Ht.segmentId);return}R("");const xn=()=>vs.docOp(a,ft,Ht);xn().then(()=>{e(_s=>_s+1),k("Aplicado"),te(xn)}).catch(_s=>R(_s instanceof Error?_s.message:"No se pudo aplicar"))},[a,mt,Mt,te]),sa=F.useCallback(ft=>{O({kind:"link",target:ft})},[]),wm=F.useCallback(()=>ht(null),[ht]);sN({pdf:Fn,pageNum:n,setPageNum:s,selectedId:g,setSelectedId:m,graph:c,edits:K,highlightEdits:St,onEdit:st,onImageEdit:I,onWidgetEdit:V,onHighlightEdit:W,onLinkEdit:nt,undo:ve.undo,redo:ve.redo,findSeg:Vt,cancelPlacing:wm});const $l=F.useCallback(ft=>{const Ht=Math.min(3,Math.max(.5,Math.round(ft*100)/100));l(Ht),localStorage.setItem("aldus-zoom",String(Ht))},[]),Iu=F.useCallback(async()=>{E(!0),R("");try{const ft=H2([...lt.values()]),Ht=await vs.bake(a,[...K.values()],ft,[...pt.values()],B(),[...St.values()],[...Q.values()]);ye(),m(null),e(xn=>xn+1),k(Ht.warnings.length?`Aplicado con avisos: ${Ht.warnings.join(" · ")}`:`Aplicado (${Ht.applied.length})`)}catch(ft){R(ft instanceof Error?ft.message:"No se pudo aplicar")}finally{E(!1)}},[a,K,lt,pt,St,Q,B,ye]),Vr=(Fn==null?void 0:Fn.numPages)??0,ra=K.size+lt.size+pt.size+ut.length+St.size+Q.size,Du=F.useMemo(()=>new Map([...K].filter(([,ft])=>ft.page===n)),[K,n]),Wr=F.useMemo(()=>new Map([...lt].filter(([,ft])=>ft.page===n)),[lt,n]),Gr=F.useMemo(()=>new Map([...pt].filter(([,ft])=>ft.page===n)),[pt,n]),Pf=F.useMemo(()=>ut.filter(ft=>ft.page===n),[ut,n]),Mf=F.useMemo(()=>new Map([...St].filter(([,ft])=>ft.page===n)),[St,n]),Rf=F.useMemo(()=>new Map([...Q].filter(([,ft])=>ft.page===n)),[Q,n]),Nf=F.useMemo(()=>{const ft=[];for(const Ht of K.values()){if(Ht.page!==n)continue;const xn=at.current.get(Ht.segmentId);xn&&ft.push(xn)}return ft},[K,n]),Fu=ft=>!!Lt&&!!ft&&Lt.kind===ft.kind&&(ft.kind!=="field"||Lt.kind==="field"&&Lt.type===ft.type);return S.jsxs("div",{className:"flex h-full flex-col bg-neutral-50 text-neutral-800",children:[S.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-neutral-200 bg-white px-3",children:[S.jsxs(hS,{to:"/",className:"flex items-center gap-1.5 text-[15px] font-semibold tracking-tight text-neutral-900",children:[S.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-md bg-blue-600 text-white text-[13px] font-bold",children:"A"}),"Aldus"]}),S.jsx("div",{className:"mx-1 h-6 w-px bg-neutral-200"}),S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx(lc,{icon:cM,label:"Página anterior",disabled:n<=1,onClick:()=>{s(ft=>ft-1),m(null)}}),S.jsx("input",{className:"h-8 w-12 rounded-md border border-neutral-200 text-center text-[13px] outline-none focus:border-blue-500",type:"number",min:1,max:Vr||1,value:n,onChange:ft=>{const Ht=Number(ft.target.value);Number.isFinite(Ht)&&(s(Math.min(Math.max(1,Math.round(Ht)),Vr||1)),m(null))}}),S.jsxs("span",{className:"text-[13px] text-neutral-400",children:["/ ",Vr||"…"]}),S.jsx(lc,{icon:f_,label:"Página siguiente",disabled:n>=Vr,onClick:()=>{s(ft=>ft+1),m(null)}})]}),S.jsx("div",{className:"mx-1 h-6 w-px bg-neutral-200"}),S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx(lc,{icon:f2,label:"Alejar",onClick:()=>$l(o-.15)}),S.jsxs("span",{className:"w-11 text-center text-[13px] tabular-nums text-neutral-500",children:[Math.round(o*100),"%"]}),S.jsx(lc,{icon:h2,label:"Acercar",onClick:()=>$l(o+.15)})]}),S.jsx("div",{className:"mx-1 h-6 w-px bg-neutral-200"}),S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx(lc,{icon:l2,label:"Deshacer (Ctrl+Z)",disabled:!ve.canUndo,onClick:ve.undo}),S.jsx(lc,{icon:zM,label:"Rehacer (Ctrl+Shift+Z)",disabled:!ve.canRedo,onClick:ve.redo})]}),S.jsx("div",{className:"flex-1"}),Lt&&S.jsx("span",{className:"text-[12px] text-blue-600",children:"Click en la página · Esc cancela"}),c&&!Lt&&S.jsxs("span",{className:"hidden text-[12px] text-neutral-400 md:inline",children:[c.segments.length," segmentos · ",c.images.length," img · ",c.widgets.length," campos"]}),S.jsxs("button",{onClick:()=>x(ft=>!ft),title:"Aldus AI — preguntá o pedí cambios",className:Ci("flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[13px] font-medium transition-colors",y?"border-blue-600 bg-blue-50 text-blue-700":"border-neutral-200 text-neutral-600 hover:bg-neutral-50"),children:[S.jsx(Hv,{size:15})," AI"]}),S.jsxs(Be,{variant:"primary",disabled:C||ra===0,onClick:()=>void Iu(),children:[S.jsx(aM,{size:15,strokeWidth:2.5}),C?"Aplicando…":`Aplicar${ra?` (${ra})`:""}`]})]}),S.jsxs("div",{className:"flex min-h-0 flex-1",children:[S.jsxs("nav",{className:"thin-scroll flex shrink-0 flex-col items-center gap-0.5 overflow-y-auto border-r border-neutral-200 bg-white py-2",style:{width:56},children:[S.jsx(Ah,{icon:IM,label:"Seleccionar (Esc)",active:!Lt,onClick:()=>ht(null)}),rN.map(ft=>S.jsxs("div",{className:"flex w-full flex-col items-center gap-0.5",children:[S.jsx("div",{className:"mt-2 mb-0.5 w-full text-center text-[8.5px] font-semibold uppercase tracking-[0.1em] text-neutral-300 select-none",children:ft.label}),ft.tools.map(Ht=>S.jsx(Ah,{icon:Ht.icon,label:Ht.label,active:Fu(Ht.placing),onClick:()=>ht(()=>Fu(Ht.placing)?null:Ht.placing)},Ht.id))]},ft.label)),S.jsx("div",{className:"mt-2 mb-0.5 w-full text-center text-[8.5px] font-semibold uppercase tracking-[0.1em] text-neutral-300 select-none",children:"Objetos"}),S.jsx(Ah,{icon:bM,label:"Insertar imagen (PNG/JPEG)",active:(Lt==null?void 0:Lt.kind)==="image",onClick:()=>{var ft;return(ft=ie.current)==null?void 0:ft.click()}}),S.jsx("input",{ref:ie,type:"file",accept:"image/png,image/jpeg",hidden:!0,onChange:ft=>{var xn;const Ht=(xn=ft.target.files)==null?void 0:xn[0];Ht&&ht({kind:"image",file:Ht}),ft.target.value=""}}),S.jsx("div",{className:"mt-2 mb-0.5 w-full text-center text-[8.5px] font-semibold uppercase tracking-[0.1em] text-neutral-300 select-none",children:"Doc"}),S.jsx(Ah,{icon:mM,label:"Marca de agua (todas las páginas)",onClick:()=>O({kind:"watermark"})}),S.jsx(Ah,{icon:FM,label:"Encabezado y pie de página",onClick:()=>O({kind:"headerFooter"})})]}),S.jsx("main",{className:Ci("thin-scroll flex flex-1 justify-center overflow-auto p-8",Lt&&"cursor-crosshair"),children:Fn?S.jsx("div",{className:"h-max",children:S.jsx(bR,{pdf:Fn,pageNum:n,scale:o,onGraph:$t,graph:(c==null?void 0:c.page)===n?c:null,selectedId:g,onSelect:m,edits:Du,onEdit:st,imageEdits:Wr,onImageEdit:I,widgetEdits:Gr,onWidgetEdit:V,locked:Xt,placing:Lt!=null,onPlace:Zt,onDocOp:tn,onRequestLink:sa,onAddText:pe,highlights:Pf,highlightEdits:Mf,onHighlightEdit:W,onSyncHighlightEdits:rt,linkEdits:Rf,onLinkEdit:nt,highlightColor:H,onHighlightColor:q,phantomSegments:Nf,onDragging:Ft,lift:Z,draggingId:yt,areaWidths:Dn,onAreaWidth:Pi,onEditingChange:A})}):S.jsx("p",{className:"mt-24 text-[13px] text-neutral-400",children:L||"Abriendo el PDF…"})}),S.jsx(kR,{graph:(c==null?void 0:c.page)===n?c:null,selectedId:g,onSelect:m,edits:K,onEdit:st,imageEdits:lt,onImageEdit:I,widgetEdits:pt,onWidgetEdit:V,highlightEdits:St,onHighlightEdit:W,linkEdits:Q,onLinkEdit:nt,locked:Xt,onToggleLock:ai,onDocOp:tn,onRequestLink:sa}),y&&S.jsx(WR,{docId:a,page:n,edits:K,imageEdits:lt,onApply:dt,onReload:()=>{ye(),m(null),e(ft=>ft+1)},onClose:()=>x(!1)})]}),(j==null?void 0:j.kind)==="watermark"&&S.jsx(GR,{onClose:()=>O(null),onApply:ft=>tn("watermark",{text:ft})}),(j==null?void 0:j.kind)==="headerFooter"&&S.jsx(XR,{onClose:()=>O(null),onApply:ft=>tn("headerFooter",ft)}),(j==null?void 0:j.kind)==="link"&&S.jsx(qR,{onClose:()=>O(null),onApply:ft=>tn("addLink",{...j.target,url:ft})}),S.jsx(_R,{message:L||N,tone:L?"error":"info"})]})}YP.workerSrc=KP;const aN="/".replace(/\/+$/,"");Gk.createRoot(document.getElementById("root")).render(S.jsx(F.StrictMode,{children:S.jsx(GC,{basename:aN,children:S.jsxs($C,{children:[S.jsx(_y,{path:"/",element:S.jsx(m2,{})}),S.jsx(_y,{path:"/doc/:id",element:S.jsx(oN,{})})]})})}));export{y2 as F,Fk as g};