jit-pdf 0.1.1 → 0.1.3

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.
@@ -2,27 +2,27 @@
2
2
  * @vue/shared v3.5.31
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
- **/function po(t){const e=Object.create(null);for(const n of t.split(","))e[n]=1;return n=>n in e}const ot={},To=[],dn=()=>{},cl=()=>!1,Wr=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),Hr=t=>t.startsWith("onUpdate:"),bt=Object.assign,pi=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},bf=Object.prototype.hasOwnProperty,Qe=(t,e)=>bf.call(t,e),Ce=Array.isArray,Mo=t=>nr(t)==="[object Map]",Vr=t=>nr(t)==="[object Set]",ul=t=>nr(t)==="[object Date]",Me=t=>typeof t=="function",ut=t=>typeof t=="string",Bt=t=>typeof t=="symbol",Je=t=>t!==null&&typeof t=="object",dl=t=>(Je(t)||Me(t))&&Me(t.then)&&Me(t.catch),pl=Object.prototype.toString,nr=t=>pl.call(t),_f=t=>nr(t).slice(8,-1),hl=t=>nr(t)==="[object Object]",Yr=t=>ut(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,or=po(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),qr=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},yf=/-\w/g,wt=qr(t=>t.replace(yf,e=>e.slice(1).toUpperCase())),vf=/\B([A-Z])/g,Yn=qr(t=>t.replace(vf,"-$1").toLowerCase()),Kr=qr(t=>t.charAt(0).toUpperCase()+t.slice(1)),hi=qr(t=>t?`on${Kr(t)}`:""),pn=(t,e)=>!Object.is(t,e),Xr=(t,...e)=>{for(let n=0;n<t.length;n++)t[n](...e)},gl=(t,e,n,o=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:o,value:n})},Zr=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let fl;const Qr=()=>fl||(fl=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Z(t){if(Ce(t)){const e={};for(let n=0;n<t.length;n++){const o=t[n],r=ut(o)?Af(o):Z(o);if(r)for(const a in r)e[a]=r[a]}return e}else if(ut(t)||Je(t))return t}const Df=/;(?![^(]*\))/g,Sf=/:([^]+)/,Ef=/\/\*[^]*?\*\//g;function Af(t){const e={};return t.replace(Ef,"").split(Df).forEach(n=>{if(n){const o=n.split(Sf);o.length>1&&(e[o[0].trim()]=o[1].trim())}}),e}function St(t){let e="";if(ut(t))e=t;else if(Ce(t))for(let n=0;n<t.length;n++){const o=St(t[n]);o&&(e+=o+" ")}else if(Je(t))for(const n in t)t[n]&&(e+=n+" ");return e.trim()}function zt(t){if(!t)return null;let{class:e,style:n}=t;return e&&!ut(e)&&(t.class=St(e)),n&&(t.style=Z(n)),t}const xf=po("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function ml(t){return!!t||t===""}function Cf(t,e){if(t.length!==e.length)return!1;let n=!0;for(let o=0;n&&o<t.length;o++)n=rr(t[o],e[o]);return n}function rr(t,e){if(t===e)return!0;let n=ul(t),o=ul(e);if(n||o)return n&&o?t.getTime()===e.getTime():!1;if(n=Bt(t),o=Bt(e),n||o)return t===e;if(n=Ce(t),o=Ce(e),n||o)return n&&o?Cf(t,e):!1;if(n=Je(t),o=Je(e),n||o){if(!n||!o)return!1;const r=Object.keys(t).length,a=Object.keys(e).length;if(r!==a)return!1;for(const i in t){const s=t.hasOwnProperty(i),l=e.hasOwnProperty(i);if(s&&!l||!s&&l||!rr(t[i],e[i]))return!1}}return String(t)===String(e)}function Tf(t,e){return t.findIndex(n=>rr(n,e))}const Pl=t=>!!(t&&t.__v_isRef===!0),fe=t=>ut(t)?t:t==null?"":Ce(t)||Je(t)&&(t.toString===pl||!Me(t.toString))?Pl(t)?fe(t.value):JSON.stringify(t,Fl,2):String(t),Fl=(t,e)=>Pl(e)?Fl(t,e.value):Mo(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[o,r],a)=>(n[gi(o,a)+" =>"]=r,n),{})}:Vr(e)?{[`Set(${e.size})`]:[...e.values()].map(n=>gi(n))}:Bt(e)?gi(e):Je(e)&&!Ce(e)&&!hl(e)?String(e):e,gi=(t,e="")=>{var n;return Bt(t)?`Symbol(${(n=t.description)!=null?n:e})`:t};/**
5
+ **/function po(t){const e=Object.create(null);for(const n of t.split(","))e[n]=1;return n=>n in e}const ot={},To=[],dn=()=>{},ul=()=>!1,Hr=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),Vr=t=>t.startsWith("onUpdate:"),bt=Object.assign,hi=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},vf=Object.prototype.hasOwnProperty,Qe=(t,e)=>vf.call(t,e),Ce=Array.isArray,Mo=t=>nr(t)==="[object Map]",Yr=t=>nr(t)==="[object Set]",dl=t=>nr(t)==="[object Date]",Me=t=>typeof t=="function",ut=t=>typeof t=="string",Bt=t=>typeof t=="symbol",Je=t=>t!==null&&typeof t=="object",pl=t=>(Je(t)||Me(t))&&Me(t.then)&&Me(t.catch),hl=Object.prototype.toString,nr=t=>hl.call(t),Df=t=>nr(t).slice(8,-1),gl=t=>nr(t)==="[object Object]",qr=t=>ut(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,or=po(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Kr=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},Sf=/-\w/g,wt=Kr(t=>t.replace(Sf,e=>e.slice(1).toUpperCase())),Ef=/\B([A-Z])/g,Yn=Kr(t=>t.replace(Ef,"-$1").toLowerCase()),Xr=Kr(t=>t.charAt(0).toUpperCase()+t.slice(1)),gi=Kr(t=>t?`on${Xr(t)}`:""),pn=(t,e)=>!Object.is(t,e),Zr=(t,...e)=>{for(let n=0;n<t.length;n++)t[n](...e)},fl=(t,e,n,o=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:o,value:n})},Qr=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let ml;const Jr=()=>ml||(ml=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Z(t){if(Ce(t)){const e={};for(let n=0;n<t.length;n++){const o=t[n],r=ut(o)?Tf(o):Z(o);if(r)for(const a in r)e[a]=r[a]}return e}else if(ut(t)||Je(t))return t}const Af=/;(?![^(]*\))/g,xf=/:([^]+)/,Cf=/\/\*[^]*?\*\//g;function Tf(t){const e={};return t.replace(Cf,"").split(Af).forEach(n=>{if(n){const o=n.split(xf);o.length>1&&(e[o[0].trim()]=o[1].trim())}}),e}function St(t){let e="";if(ut(t))e=t;else if(Ce(t))for(let n=0;n<t.length;n++){const o=St(t[n]);o&&(e+=o+" ")}else if(Je(t))for(const n in t)t[n]&&(e+=n+" ");return e.trim()}function zt(t){if(!t)return null;let{class:e,style:n}=t;return e&&!ut(e)&&(t.class=St(e)),n&&(t.style=Z(n)),t}const Mf=po("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Pl(t){return!!t||t===""}function Rf(t,e){if(t.length!==e.length)return!1;let n=!0;for(let o=0;n&&o<t.length;o++)n=rr(t[o],e[o]);return n}function rr(t,e){if(t===e)return!0;let n=dl(t),o=dl(e);if(n||o)return n&&o?t.getTime()===e.getTime():!1;if(n=Bt(t),o=Bt(e),n||o)return t===e;if(n=Ce(t),o=Ce(e),n||o)return n&&o?Rf(t,e):!1;if(n=Je(t),o=Je(e),n||o){if(!n||!o)return!1;const r=Object.keys(t).length,a=Object.keys(e).length;if(r!==a)return!1;for(const i in t){const s=t.hasOwnProperty(i),l=e.hasOwnProperty(i);if(s&&!l||!s&&l||!rr(t[i],e[i]))return!1}}return String(t)===String(e)}function wf(t,e){return t.findIndex(n=>rr(n,e))}const Fl=t=>!!(t&&t.__v_isRef===!0),fe=t=>ut(t)?t:t==null?"":Ce(t)||Je(t)&&(t.toString===hl||!Me(t.toString))?Fl(t)?fe(t.value):JSON.stringify(t,bl,2):String(t),bl=(t,e)=>Fl(e)?bl(t,e.value):Mo(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[o,r],a)=>(n[fi(o,a)+" =>"]=r,n),{})}:Yr(e)?{[`Set(${e.size})`]:[...e.values()].map(n=>fi(n))}:Bt(e)?fi(e):Je(e)&&!Ce(e)&&!gl(e)?String(e):e,fi=(t,e="")=>{var n;return Bt(t)?`Symbol(${(n=t.description)!=null?n:e})`:t};/**
6
6
  * @vue/reactivity v3.5.31
7
7
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
8
8
  * @license MIT
9
- **/let Lt;class Mf{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.__v_skip=!0,this.parent=Lt,!e&&Lt&&(this.index=(Lt.scopes||(Lt.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,n;if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].pause();for(e=0,n=this.effects.length;e<n;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,n;if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].resume();for(e=0,n=this.effects.length;e<n;e++)this.effects[e].resume()}}run(e){if(this._active){const n=Lt;try{return Lt=this,e()}finally{Lt=n}}}on(){++this._on===1&&(this.prevScope=Lt,Lt=this)}off(){this._on>0&&--this._on===0&&(Lt=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let n,o;for(n=0,o=this.effects.length;n<o;n++)this.effects[n].stop();for(this.effects.length=0,n=0,o=this.cleanups.length;n<o;n++)this.cleanups[n]();if(this.cleanups.length=0,this.scopes){for(n=0,o=this.scopes.length;n<o;n++)this.scopes[n].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}}function Rf(){return Lt}let at;const fi=new WeakSet;class bl{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Lt&&Lt.active&&Lt.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,fi.has(this)&&(fi.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||yl(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Al(this),vl(this);const e=at,n=an;at=this,an=!0;try{return this.fn()}finally{Dl(this),at=e,an=n,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)bi(e);this.deps=this.depsTail=void 0,Al(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?fi.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Fi(this)&&this.run()}get dirty(){return Fi(this)}}let _l=0,ar,ir;function yl(t,e=!1){if(t.flags|=8,e){t.next=ir,ir=t;return}t.next=ar,ar=t}function mi(){_l++}function Pi(){if(--_l>0)return;if(ir){let e=ir;for(ir=void 0;e;){const n=e.next;e.next=void 0,e.flags&=-9,e=n}}let t;for(;ar;){let e=ar;for(ar=void 0;e;){const n=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(o){t||(t=o)}e=n}}if(t)throw t}function vl(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Dl(t){let e,n=t.depsTail,o=n;for(;o;){const r=o.prevDep;o.version===-1?(o===n&&(n=r),bi(o),wf(o)):e=o,o.dep.activeLink=o.prevActiveLink,o.prevActiveLink=void 0,o=r}t.deps=e,t.depsTail=n}function Fi(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Sl(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Sl(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===sr)||(t.globalVersion=sr,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Fi(t))))return;t.flags|=2;const e=t.dep,n=at,o=an;at=t,an=!0;try{vl(t);const r=t.fn(t._value);(e.version===0||pn(r,t._value))&&(t.flags|=128,t._value=r,e.version++)}catch(r){throw e.version++,r}finally{at=n,an=o,Dl(t),t.flags&=-3}}function bi(t,e=!1){const{dep:n,prevSub:o,nextSub:r}=t;if(o&&(o.nextSub=r,t.prevSub=void 0),r&&(r.prevSub=o,t.nextSub=void 0),n.subs===t&&(n.subs=o,!o&&n.computed)){n.computed.flags&=-5;for(let a=n.computed.deps;a;a=a.nextDep)bi(a,!0)}!e&&!--n.sc&&n.map&&n.map.delete(n.key)}function wf(t){const{prevDep:e,nextDep:n}=t;e&&(e.nextDep=n,t.prevDep=void 0),n&&(n.prevDep=e,t.nextDep=void 0)}let an=!0;const El=[];function hn(){El.push(an),an=!1}function gn(){const t=El.pop();an=t===void 0?!0:t}function Al(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const n=at;at=void 0;try{e()}finally{at=n}}}let sr=0;class Of{constructor(e,n){this.sub=e,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class _i{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!at||!an||at===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==at)n=this.activeLink=new Of(at,this),at.deps?(n.prevDep=at.depsTail,at.depsTail.nextDep=n,at.depsTail=n):at.deps=at.depsTail=n,xl(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const o=n.nextDep;o.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=o),n.prevDep=at.depsTail,n.nextDep=void 0,at.depsTail.nextDep=n,at.depsTail=n,at.deps===n&&(at.deps=o)}return n}trigger(e){this.version++,sr++,this.notify(e)}notify(e){mi();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{Pi()}}}function xl(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let o=e.deps;o;o=o.nextDep)xl(o)}const n=t.dep.subs;n!==t&&(t.prevSub=n,n&&(n.nextSub=t)),t.dep.subs=t}}const Jr=new WeakMap,ho=Symbol(""),yi=Symbol(""),lr=Symbol("");function Et(t,e,n){if(an&&at){let o=Jr.get(t);o||Jr.set(t,o=new Map);let r=o.get(n);r||(o.set(n,r=new _i),r.map=o,r.key=n),r.track()}}function Tn(t,e,n,o,r,a){const i=Jr.get(t);if(!i){sr++;return}const s=l=>{l&&l.trigger()};if(mi(),e==="clear")i.forEach(s);else{const l=Ce(t),c=l&&Yr(n);if(l&&n==="length"){const u=Number(o);i.forEach((d,p)=>{(p==="length"||p===lr||!Bt(p)&&p>=u)&&s(d)})}else switch((n!==void 0||i.has(void 0))&&s(i.get(n)),c&&s(i.get(lr)),e){case"add":l?c&&s(i.get("length")):(s(i.get(ho)),Mo(t)&&s(i.get(yi)));break;case"delete":l||(s(i.get(ho)),Mo(t)&&s(i.get(yi)));break;case"set":Mo(t)&&s(i.get(ho));break}}Pi()}function kf(t,e){const n=Jr.get(t);return n&&n.get(e)}function Ro(t){const e=ke(t);return e===t?e:(Et(e,"iterate",lr),Wt(t)?e:e.map(sn))}function ea(t){return Et(t=ke(t),"iterate",lr),t}function fn(t,e){return Rn(t)?wo(qn(t)?sn(e):e):sn(e)}const If={__proto__:null,[Symbol.iterator](){return vi(this,Symbol.iterator,t=>fn(this,t))},concat(...t){return Ro(this).concat(...t.map(e=>Ce(e)?Ro(e):e))},entries(){return vi(this,"entries",t=>(t[1]=fn(this,t[1]),t))},every(t,e){return Mn(this,"every",t,e,void 0,arguments)},filter(t,e){return Mn(this,"filter",t,e,n=>n.map(o=>fn(this,o)),arguments)},find(t,e){return Mn(this,"find",t,e,n=>fn(this,n),arguments)},findIndex(t,e){return Mn(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Mn(this,"findLast",t,e,n=>fn(this,n),arguments)},findLastIndex(t,e){return Mn(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Mn(this,"forEach",t,e,void 0,arguments)},includes(...t){return Di(this,"includes",t)},indexOf(...t){return Di(this,"indexOf",t)},join(t){return Ro(this).join(t)},lastIndexOf(...t){return Di(this,"lastIndexOf",t)},map(t,e){return Mn(this,"map",t,e,void 0,arguments)},pop(){return cr(this,"pop")},push(...t){return cr(this,"push",t)},reduce(t,...e){return Cl(this,"reduce",t,e)},reduceRight(t,...e){return Cl(this,"reduceRight",t,e)},shift(){return cr(this,"shift")},some(t,e){return Mn(this,"some",t,e,void 0,arguments)},splice(...t){return cr(this,"splice",t)},toReversed(){return Ro(this).toReversed()},toSorted(t){return Ro(this).toSorted(t)},toSpliced(...t){return Ro(this).toSpliced(...t)},unshift(...t){return cr(this,"unshift",t)},values(){return vi(this,"values",t=>fn(this,t))}};function vi(t,e,n){const o=ea(t),r=o[e]();return o!==t&&!Wt(t)&&(r._next=r.next,r.next=()=>{const a=r._next();return a.done||(a.value=n(a.value)),a}),r}const Gf=Array.prototype;function Mn(t,e,n,o,r,a){const i=ea(t),s=i!==t&&!Wt(t),l=i[e];if(l!==Gf[e]){const d=l.apply(t,a);return s?sn(d):d}let c=n;i!==t&&(s?c=function(d,p){return n.call(this,fn(t,d),p,t)}:n.length>2&&(c=function(d,p){return n.call(this,d,p,t)}));const u=l.call(i,c,o);return s&&r?r(u):u}function Cl(t,e,n,o){const r=ea(t),a=r!==t&&!Wt(t);let i=n,s=!1;r!==t&&(a?(s=o.length===0,i=function(c,u,d){return s&&(s=!1,c=fn(t,c)),n.call(this,c,fn(t,u),d,t)}):n.length>3&&(i=function(c,u,d){return n.call(this,c,u,d,t)}));const l=r[e](i,...o);return s?fn(t,l):l}function Di(t,e,n){const o=ke(t);Et(o,"iterate",lr);const r=o[e](...n);return(r===-1||r===!1)&&ur(n[0])?(n[0]=ke(n[0]),o[e](...n)):r}function cr(t,e,n=[]){hn(),mi();const o=ke(t)[e].apply(t,n);return Pi(),gn(),o}const Lf=po("__proto__,__v_isRef,__isVue"),Tl=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Bt));function $f(t){Bt(t)||(t=String(t));const e=ke(this);return Et(e,"has",t),e.hasOwnProperty(t)}class Ml{constructor(e=!1,n=!1){this._isReadonly=e,this._isShallow=n}get(e,n,o){if(n==="__v_skip")return e.__v_skip;const r=this._isReadonly,a=this._isShallow;if(n==="__v_isReactive")return!r;if(n==="__v_isReadonly")return r;if(n==="__v_isShallow")return a;if(n==="__v_raw")return o===(r?a?Gl:Il:a?kl:Ol).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(o)?e:void 0;const i=Ce(e);if(!r){let l;if(i&&(l=If[n]))return l;if(n==="hasOwnProperty")return $f}const s=Reflect.get(e,n,ht(e)?e:o);if((Bt(n)?Tl.has(n):Lf(n))||(r||Et(e,"get",n),a))return s;if(ht(s)){const l=i&&Yr(n)?s:s.value;return r&&Je(l)?Ai(l):l}return Je(s)?r?Ai(s):Ei(s):s}}class Rl extends Ml{constructor(e=!1){super(!1,e)}set(e,n,o,r){let a=e[n];const i=Ce(e)&&Yr(n);if(!this._isShallow){const c=Rn(a);if(!Wt(o)&&!Rn(o)&&(a=ke(a),o=ke(o)),!i&&ht(a)&&!ht(o))return c||(a.value=o),!0}const s=i?Number(n)<e.length:Qe(e,n),l=Reflect.set(e,n,o,ht(e)?e:r);return e===ke(r)&&(s?pn(o,a)&&Tn(e,"set",n,o):Tn(e,"add",n,o)),l}deleteProperty(e,n){const o=Qe(e,n);e[n];const r=Reflect.deleteProperty(e,n);return r&&o&&Tn(e,"delete",n,void 0),r}has(e,n){const o=Reflect.has(e,n);return(!Bt(n)||!Tl.has(n))&&Et(e,"has",n),o}ownKeys(e){return Et(e,"iterate",Ce(e)?"length":ho),Reflect.ownKeys(e)}}class wl extends Ml{constructor(e=!1){super(!0,e)}set(e,n){return!0}deleteProperty(e,n){return!0}}const Nf=new Rl,jf=new wl,Uf=new Rl(!0),Bf=new wl(!0),Si=t=>t,ta=t=>Reflect.getPrototypeOf(t);function zf(t,e,n){return function(...o){const r=this.__v_raw,a=ke(r),i=Mo(a),s=t==="entries"||t===Symbol.iterator&&i,l=t==="keys"&&i,c=r[t](...o),u=n?Si:e?wo:sn;return!e&&Et(a,"iterate",l?yi:ho),bt(Object.create(c),{next(){const{value:d,done:p}=c.next();return p?{value:d,done:p}:{value:s?[u(d[0]),u(d[1])]:u(d),done:p}}})}}function na(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Wf(t,e){const n={get(r){const a=this.__v_raw,i=ke(a),s=ke(r);t||(pn(r,s)&&Et(i,"get",r),Et(i,"get",s));const{has:l}=ta(i),c=e?Si:t?wo:sn;if(l.call(i,r))return c(a.get(r));if(l.call(i,s))return c(a.get(s));a!==i&&a.get(r)},get size(){const r=this.__v_raw;return!t&&Et(ke(r),"iterate",ho),r.size},has(r){const a=this.__v_raw,i=ke(a),s=ke(r);return t||(pn(r,s)&&Et(i,"has",r),Et(i,"has",s)),r===s?a.has(r):a.has(r)||a.has(s)},forEach(r,a){const i=this,s=i.__v_raw,l=ke(s),c=e?Si:t?wo:sn;return!t&&Et(l,"iterate",ho),s.forEach((u,d)=>r.call(a,c(u),c(d),i))}};return bt(n,t?{add:na("add"),set:na("set"),delete:na("delete"),clear:na("clear")}:{add(r){const a=ke(this),i=ta(a),s=ke(r),l=!e&&!Wt(r)&&!Rn(r)?s:r;return i.has.call(a,l)||pn(r,l)&&i.has.call(a,r)||pn(s,l)&&i.has.call(a,s)||(a.add(l),Tn(a,"add",l,l)),this},set(r,a){!e&&!Wt(a)&&!Rn(a)&&(a=ke(a));const i=ke(this),{has:s,get:l}=ta(i);let c=s.call(i,r);c||(r=ke(r),c=s.call(i,r));const u=l.call(i,r);return i.set(r,a),c?pn(a,u)&&Tn(i,"set",r,a):Tn(i,"add",r,a),this},delete(r){const a=ke(this),{has:i,get:s}=ta(a);let l=i.call(a,r);l||(r=ke(r),l=i.call(a,r)),s&&s.call(a,r);const c=a.delete(r);return l&&Tn(a,"delete",r,void 0),c},clear(){const r=ke(this),a=r.size!==0,i=r.clear();return a&&Tn(r,"clear",void 0,void 0),i}}),["keys","values","entries",Symbol.iterator].forEach(r=>{n[r]=zf(r,t,e)}),n}function oa(t,e){const n=Wf(t,e);return(o,r,a)=>r==="__v_isReactive"?!t:r==="__v_isReadonly"?t:r==="__v_raw"?o:Reflect.get(Qe(n,r)&&r in o?n:o,r,a)}const Hf={get:oa(!1,!1)},Vf={get:oa(!1,!0)},Yf={get:oa(!0,!1)},qf={get:oa(!0,!0)},Ol=new WeakMap,kl=new WeakMap,Il=new WeakMap,Gl=new WeakMap;function Kf(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Xf(t){return t.__v_skip||!Object.isExtensible(t)?0:Kf(_f(t))}function Ei(t){return Rn(t)?t:ra(t,!1,Nf,Hf,Ol)}function Zf(t){return ra(t,!1,Uf,Vf,kl)}function Ai(t){return ra(t,!0,jf,Yf,Il)}function lT(t){return ra(t,!0,Bf,qf,Gl)}function ra(t,e,n,o,r){if(!Je(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const a=Xf(t);if(a===0)return t;const i=r.get(t);if(i)return i;const s=new Proxy(t,a===2?o:n);return r.set(t,s),s}function qn(t){return Rn(t)?qn(t.__v_raw):!!(t&&t.__v_isReactive)}function Rn(t){return!!(t&&t.__v_isReadonly)}function Wt(t){return!!(t&&t.__v_isShallow)}function ur(t){return t?!!t.__v_raw:!1}function ke(t){const e=t&&t.__v_raw;return e?ke(e):t}function dr(t){return!Qe(t,"__v_skip")&&Object.isExtensible(t)&&gl(t,"__v_skip",!0),t}const sn=t=>Je(t)?Ei(t):t,wo=t=>Je(t)?Ai(t):t;function ht(t){return t?t.__v_isRef===!0:!1}function Q(t){return Ll(t,!1)}function ln(t){return Ll(t,!0)}function Ll(t,e){return ht(t)?t:new Qf(t,e)}class Qf{constructor(e,n){this.dep=new _i,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?e:ke(e),this._value=n?e:sn(e),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(e){const n=this._rawValue,o=this.__v_isShallow||Wt(e)||Rn(e);e=o?e:ke(e),pn(e,n)&&(this._rawValue=e,this._value=o?e:sn(e),this.dep.trigger())}}function I(t){return ht(t)?t.value:t}function $t(t){return Me(t)?t():I(t)}const Jf={get:(t,e,n)=>e==="__v_raw"?t:I(Reflect.get(t,e,n)),set:(t,e,n,o)=>{const r=t[e];return ht(r)&&!ht(n)?(r.value=n,!0):Reflect.set(t,e,n,o)}};function $l(t){return qn(t)?t:new Proxy(t,Jf)}class em{constructor(e,n,o){this._object=e,this._defaultValue=o,this.__v_isRef=!0,this._value=void 0,this._key=Bt(n)?n:String(n),this._raw=ke(e);let r=!0,a=e;if(!Ce(e)||Bt(this._key)||!Yr(this._key))do r=!ur(a)||Wt(a);while(r&&(a=a.__v_raw));this._shallow=r}get value(){let e=this._object[this._key];return this._shallow&&(e=I(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&ht(this._raw[this._key])){const n=this._object[this._key];if(ht(n)){n.value=e;return}}this._object[this._key]=e}get dep(){return kf(this._raw,this._key)}}class tm{constructor(e){this._getter=e,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function Nl(t,e,n){return ht(t)?t:Me(t)?new tm(t):Je(t)&&arguments.length>1?nm(t,e,n):Q(t)}function nm(t,e,n){return new em(t,e,n)}class om{constructor(e,n,o){this.fn=e,this.setter=n,this._value=void 0,this.dep=new _i(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=sr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=o}notify(){if(this.flags|=16,!(this.flags&8)&&at!==this)return yl(this,!0),!0}get value(){const e=this.dep.track();return Sl(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function rm(t,e,n=!1){let o,r;return Me(t)?o=t:(o=t.get,r=t.set),new om(o,r,n)}const aa={},ia=new WeakMap;let go;function am(t,e=!1,n=go){if(n){let o=ia.get(n);o||ia.set(n,o=[]),o.push(t)}}function im(t,e,n=ot){const{immediate:o,deep:r,once:a,scheduler:i,augmentJob:s,call:l}=n,c=A=>r?A:Wt(A)||r===!1||r===0?wn(A,1):wn(A);let u,d,p,h,g=!1,f=!1;if(ht(t)?(d=()=>t.value,g=Wt(t)):qn(t)?(d=()=>c(t),g=!0):Ce(t)?(f=!0,g=t.some(A=>qn(A)||Wt(A)),d=()=>t.map(A=>{if(ht(A))return A.value;if(qn(A))return c(A);if(Me(A))return l?l(A,2):A()})):Me(t)?e?d=l?()=>l(t,2):t:d=()=>{if(p){hn();try{p()}finally{gn()}}const A=go;go=u;try{return l?l(t,3,[h]):t(h)}finally{go=A}}:d=dn,e&&r){const A=d,T=r===!0?1/0:r;d=()=>wn(A(),T)}const F=Rf(),_=()=>{u.stop(),F&&F.active&&pi(F.effects,u)};if(a&&e){const A=e;e=(...T)=>{A(...T),_()}}let y=f?new Array(t.length).fill(aa):aa;const E=A=>{if(!(!(u.flags&1)||!u.dirty&&!A))if(e){const T=u.run();if(r||g||(f?T.some((q,w)=>pn(q,y[w])):pn(T,y))){p&&p();const q=go;go=u;try{const w=[T,y===aa?void 0:f&&y[0]===aa?[]:y,h];y=T,l?l(e,3,w):e(...w)}finally{go=q}}}else u.run()};return s&&s(E),u=new bl(d),u.scheduler=i?()=>i(E,!1):E,h=A=>am(A,!1,u),p=u.onStop=()=>{const A=ia.get(u);if(A){if(l)l(A,4);else for(const T of A)T();ia.delete(u)}},e?o?E(!0):y=u.run():i?i(E.bind(null,!0),!0):u.run(),_.pause=u.pause.bind(u),_.resume=u.resume.bind(u),_.stop=_,_}function wn(t,e=1/0,n){if(e<=0||!Je(t)||t.__v_skip||(n=n||new Map,(n.get(t)||0)>=e))return t;if(n.set(t,e),e--,ht(t))wn(t.value,e,n);else if(Ce(t))for(let o=0;o<t.length;o++)wn(t[o],e,n);else if(Vr(t)||Mo(t))t.forEach(o=>{wn(o,e,n)});else if(hl(t)){for(const o in t)wn(t[o],e,n);for(const o of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,o)&&wn(t[o],e,n)}return t}/**
9
+ **/let Lt;class Of{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.__v_skip=!0,this.parent=Lt,!e&&Lt&&(this.index=(Lt.scopes||(Lt.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,n;if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].pause();for(e=0,n=this.effects.length;e<n;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,n;if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].resume();for(e=0,n=this.effects.length;e<n;e++)this.effects[e].resume()}}run(e){if(this._active){const n=Lt;try{return Lt=this,e()}finally{Lt=n}}}on(){++this._on===1&&(this.prevScope=Lt,Lt=this)}off(){this._on>0&&--this._on===0&&(Lt=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let n,o;for(n=0,o=this.effects.length;n<o;n++)this.effects[n].stop();for(this.effects.length=0,n=0,o=this.cleanups.length;n<o;n++)this.cleanups[n]();if(this.cleanups.length=0,this.scopes){for(n=0,o=this.scopes.length;n<o;n++)this.scopes[n].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}}function kf(){return Lt}let at;const mi=new WeakSet;class yl{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Lt&&Lt.active&&Lt.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,mi.has(this)&&(mi.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||vl(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,xl(this),Dl(this);const e=at,n=an;at=this,an=!0;try{return this.fn()}finally{Sl(this),at=e,an=n,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)yi(e);this.deps=this.depsTail=void 0,xl(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?mi.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){bi(this)&&this.run()}get dirty(){return bi(this)}}let _l=0,ar,ir;function vl(t,e=!1){if(t.flags|=8,e){t.next=ir,ir=t;return}t.next=ar,ar=t}function Pi(){_l++}function Fi(){if(--_l>0)return;if(ir){let e=ir;for(ir=void 0;e;){const n=e.next;e.next=void 0,e.flags&=-9,e=n}}let t;for(;ar;){let e=ar;for(ar=void 0;e;){const n=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(o){t||(t=o)}e=n}}if(t)throw t}function Dl(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Sl(t){let e,n=t.depsTail,o=n;for(;o;){const r=o.prevDep;o.version===-1?(o===n&&(n=r),yi(o),If(o)):e=o,o.dep.activeLink=o.prevActiveLink,o.prevActiveLink=void 0,o=r}t.deps=e,t.depsTail=n}function bi(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(El(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function El(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===sr)||(t.globalVersion=sr,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!bi(t))))return;t.flags|=2;const e=t.dep,n=at,o=an;at=t,an=!0;try{Dl(t);const r=t.fn(t._value);(e.version===0||pn(r,t._value))&&(t.flags|=128,t._value=r,e.version++)}catch(r){throw e.version++,r}finally{at=n,an=o,Sl(t),t.flags&=-3}}function yi(t,e=!1){const{dep:n,prevSub:o,nextSub:r}=t;if(o&&(o.nextSub=r,t.prevSub=void 0),r&&(r.prevSub=o,t.nextSub=void 0),n.subs===t&&(n.subs=o,!o&&n.computed)){n.computed.flags&=-5;for(let a=n.computed.deps;a;a=a.nextDep)yi(a,!0)}!e&&!--n.sc&&n.map&&n.map.delete(n.key)}function If(t){const{prevDep:e,nextDep:n}=t;e&&(e.nextDep=n,t.prevDep=void 0),n&&(n.prevDep=e,t.nextDep=void 0)}let an=!0;const Al=[];function hn(){Al.push(an),an=!1}function gn(){const t=Al.pop();an=t===void 0?!0:t}function xl(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const n=at;at=void 0;try{e()}finally{at=n}}}let sr=0;class Gf{constructor(e,n){this.sub=e,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class _i{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!at||!an||at===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==at)n=this.activeLink=new Gf(at,this),at.deps?(n.prevDep=at.depsTail,at.depsTail.nextDep=n,at.depsTail=n):at.deps=at.depsTail=n,Cl(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const o=n.nextDep;o.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=o),n.prevDep=at.depsTail,n.nextDep=void 0,at.depsTail.nextDep=n,at.depsTail=n,at.deps===n&&(at.deps=o)}return n}trigger(e){this.version++,sr++,this.notify(e)}notify(e){Pi();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{Fi()}}}function Cl(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let o=e.deps;o;o=o.nextDep)Cl(o)}const n=t.dep.subs;n!==t&&(t.prevSub=n,n&&(n.nextSub=t)),t.dep.subs=t}}const ea=new WeakMap,ho=Symbol(""),vi=Symbol(""),lr=Symbol("");function Et(t,e,n){if(an&&at){let o=ea.get(t);o||ea.set(t,o=new Map);let r=o.get(n);r||(o.set(n,r=new _i),r.map=o,r.key=n),r.track()}}function Tn(t,e,n,o,r,a){const i=ea.get(t);if(!i){sr++;return}const s=l=>{l&&l.trigger()};if(Pi(),e==="clear")i.forEach(s);else{const l=Ce(t),c=l&&qr(n);if(l&&n==="length"){const u=Number(o);i.forEach((d,p)=>{(p==="length"||p===lr||!Bt(p)&&p>=u)&&s(d)})}else switch((n!==void 0||i.has(void 0))&&s(i.get(n)),c&&s(i.get(lr)),e){case"add":l?c&&s(i.get("length")):(s(i.get(ho)),Mo(t)&&s(i.get(vi)));break;case"delete":l||(s(i.get(ho)),Mo(t)&&s(i.get(vi)));break;case"set":Mo(t)&&s(i.get(ho));break}}Fi()}function Lf(t,e){const n=ea.get(t);return n&&n.get(e)}function Ro(t){const e=ke(t);return e===t?e:(Et(e,"iterate",lr),Wt(t)?e:e.map(sn))}function ta(t){return Et(t=ke(t),"iterate",lr),t}function fn(t,e){return Rn(t)?wo(qn(t)?sn(e):e):sn(e)}const $f={__proto__:null,[Symbol.iterator](){return Di(this,Symbol.iterator,t=>fn(this,t))},concat(...t){return Ro(this).concat(...t.map(e=>Ce(e)?Ro(e):e))},entries(){return Di(this,"entries",t=>(t[1]=fn(this,t[1]),t))},every(t,e){return Mn(this,"every",t,e,void 0,arguments)},filter(t,e){return Mn(this,"filter",t,e,n=>n.map(o=>fn(this,o)),arguments)},find(t,e){return Mn(this,"find",t,e,n=>fn(this,n),arguments)},findIndex(t,e){return Mn(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Mn(this,"findLast",t,e,n=>fn(this,n),arguments)},findLastIndex(t,e){return Mn(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Mn(this,"forEach",t,e,void 0,arguments)},includes(...t){return Si(this,"includes",t)},indexOf(...t){return Si(this,"indexOf",t)},join(t){return Ro(this).join(t)},lastIndexOf(...t){return Si(this,"lastIndexOf",t)},map(t,e){return Mn(this,"map",t,e,void 0,arguments)},pop(){return cr(this,"pop")},push(...t){return cr(this,"push",t)},reduce(t,...e){return Tl(this,"reduce",t,e)},reduceRight(t,...e){return Tl(this,"reduceRight",t,e)},shift(){return cr(this,"shift")},some(t,e){return Mn(this,"some",t,e,void 0,arguments)},splice(...t){return cr(this,"splice",t)},toReversed(){return Ro(this).toReversed()},toSorted(t){return Ro(this).toSorted(t)},toSpliced(...t){return Ro(this).toSpliced(...t)},unshift(...t){return cr(this,"unshift",t)},values(){return Di(this,"values",t=>fn(this,t))}};function Di(t,e,n){const o=ta(t),r=o[e]();return o!==t&&!Wt(t)&&(r._next=r.next,r.next=()=>{const a=r._next();return a.done||(a.value=n(a.value)),a}),r}const Nf=Array.prototype;function Mn(t,e,n,o,r,a){const i=ta(t),s=i!==t&&!Wt(t),l=i[e];if(l!==Nf[e]){const d=l.apply(t,a);return s?sn(d):d}let c=n;i!==t&&(s?c=function(d,p){return n.call(this,fn(t,d),p,t)}:n.length>2&&(c=function(d,p){return n.call(this,d,p,t)}));const u=l.call(i,c,o);return s&&r?r(u):u}function Tl(t,e,n,o){const r=ta(t),a=r!==t&&!Wt(t);let i=n,s=!1;r!==t&&(a?(s=o.length===0,i=function(c,u,d){return s&&(s=!1,c=fn(t,c)),n.call(this,c,fn(t,u),d,t)}):n.length>3&&(i=function(c,u,d){return n.call(this,c,u,d,t)}));const l=r[e](i,...o);return s?fn(t,l):l}function Si(t,e,n){const o=ke(t);Et(o,"iterate",lr);const r=o[e](...n);return(r===-1||r===!1)&&ur(n[0])?(n[0]=ke(n[0]),o[e](...n)):r}function cr(t,e,n=[]){hn(),Pi();const o=ke(t)[e].apply(t,n);return Fi(),gn(),o}const jf=po("__proto__,__v_isRef,__isVue"),Ml=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Bt));function Uf(t){Bt(t)||(t=String(t));const e=ke(this);return Et(e,"has",t),e.hasOwnProperty(t)}class Rl{constructor(e=!1,n=!1){this._isReadonly=e,this._isShallow=n}get(e,n,o){if(n==="__v_skip")return e.__v_skip;const r=this._isReadonly,a=this._isShallow;if(n==="__v_isReactive")return!r;if(n==="__v_isReadonly")return r;if(n==="__v_isShallow")return a;if(n==="__v_raw")return o===(r?a?Ll:Gl:a?Il:kl).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(o)?e:void 0;const i=Ce(e);if(!r){let l;if(i&&(l=$f[n]))return l;if(n==="hasOwnProperty")return Uf}const s=Reflect.get(e,n,ht(e)?e:o);if((Bt(n)?Ml.has(n):jf(n))||(r||Et(e,"get",n),a))return s;if(ht(s)){const l=i&&qr(n)?s:s.value;return r&&Je(l)?xi(l):l}return Je(s)?r?xi(s):Ai(s):s}}class wl extends Rl{constructor(e=!1){super(!1,e)}set(e,n,o,r){let a=e[n];const i=Ce(e)&&qr(n);if(!this._isShallow){const c=Rn(a);if(!Wt(o)&&!Rn(o)&&(a=ke(a),o=ke(o)),!i&&ht(a)&&!ht(o))return c||(a.value=o),!0}const s=i?Number(n)<e.length:Qe(e,n),l=Reflect.set(e,n,o,ht(e)?e:r);return e===ke(r)&&(s?pn(o,a)&&Tn(e,"set",n,o):Tn(e,"add",n,o)),l}deleteProperty(e,n){const o=Qe(e,n);e[n];const r=Reflect.deleteProperty(e,n);return r&&o&&Tn(e,"delete",n,void 0),r}has(e,n){const o=Reflect.has(e,n);return(!Bt(n)||!Ml.has(n))&&Et(e,"has",n),o}ownKeys(e){return Et(e,"iterate",Ce(e)?"length":ho),Reflect.ownKeys(e)}}class Ol extends Rl{constructor(e=!1){super(!0,e)}set(e,n){return!0}deleteProperty(e,n){return!0}}const Bf=new wl,zf=new Ol,Wf=new wl(!0),Hf=new Ol(!0),Ei=t=>t,na=t=>Reflect.getPrototypeOf(t);function Vf(t,e,n){return function(...o){const r=this.__v_raw,a=ke(r),i=Mo(a),s=t==="entries"||t===Symbol.iterator&&i,l=t==="keys"&&i,c=r[t](...o),u=n?Ei:e?wo:sn;return!e&&Et(a,"iterate",l?vi:ho),bt(Object.create(c),{next(){const{value:d,done:p}=c.next();return p?{value:d,done:p}:{value:s?[u(d[0]),u(d[1])]:u(d),done:p}}})}}function oa(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Yf(t,e){const n={get(r){const a=this.__v_raw,i=ke(a),s=ke(r);t||(pn(r,s)&&Et(i,"get",r),Et(i,"get",s));const{has:l}=na(i),c=e?Ei:t?wo:sn;if(l.call(i,r))return c(a.get(r));if(l.call(i,s))return c(a.get(s));a!==i&&a.get(r)},get size(){const r=this.__v_raw;return!t&&Et(ke(r),"iterate",ho),r.size},has(r){const a=this.__v_raw,i=ke(a),s=ke(r);return t||(pn(r,s)&&Et(i,"has",r),Et(i,"has",s)),r===s?a.has(r):a.has(r)||a.has(s)},forEach(r,a){const i=this,s=i.__v_raw,l=ke(s),c=e?Ei:t?wo:sn;return!t&&Et(l,"iterate",ho),s.forEach((u,d)=>r.call(a,c(u),c(d),i))}};return bt(n,t?{add:oa("add"),set:oa("set"),delete:oa("delete"),clear:oa("clear")}:{add(r){const a=ke(this),i=na(a),s=ke(r),l=!e&&!Wt(r)&&!Rn(r)?s:r;return i.has.call(a,l)||pn(r,l)&&i.has.call(a,r)||pn(s,l)&&i.has.call(a,s)||(a.add(l),Tn(a,"add",l,l)),this},set(r,a){!e&&!Wt(a)&&!Rn(a)&&(a=ke(a));const i=ke(this),{has:s,get:l}=na(i);let c=s.call(i,r);c||(r=ke(r),c=s.call(i,r));const u=l.call(i,r);return i.set(r,a),c?pn(a,u)&&Tn(i,"set",r,a):Tn(i,"add",r,a),this},delete(r){const a=ke(this),{has:i,get:s}=na(a);let l=i.call(a,r);l||(r=ke(r),l=i.call(a,r)),s&&s.call(a,r);const c=a.delete(r);return l&&Tn(a,"delete",r,void 0),c},clear(){const r=ke(this),a=r.size!==0,i=r.clear();return a&&Tn(r,"clear",void 0,void 0),i}}),["keys","values","entries",Symbol.iterator].forEach(r=>{n[r]=Vf(r,t,e)}),n}function ra(t,e){const n=Yf(t,e);return(o,r,a)=>r==="__v_isReactive"?!t:r==="__v_isReadonly"?t:r==="__v_raw"?o:Reflect.get(Qe(n,r)&&r in o?n:o,r,a)}const qf={get:ra(!1,!1)},Kf={get:ra(!1,!0)},Xf={get:ra(!0,!1)},Zf={get:ra(!0,!0)},kl=new WeakMap,Il=new WeakMap,Gl=new WeakMap,Ll=new WeakMap;function Qf(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Jf(t){return t.__v_skip||!Object.isExtensible(t)?0:Qf(Df(t))}function Ai(t){return Rn(t)?t:aa(t,!1,Bf,qf,kl)}function em(t){return aa(t,!1,Wf,Kf,Il)}function xi(t){return aa(t,!0,zf,Xf,Gl)}function yT(t){return aa(t,!0,Hf,Zf,Ll)}function aa(t,e,n,o,r){if(!Je(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const a=Jf(t);if(a===0)return t;const i=r.get(t);if(i)return i;const s=new Proxy(t,a===2?o:n);return r.set(t,s),s}function qn(t){return Rn(t)?qn(t.__v_raw):!!(t&&t.__v_isReactive)}function Rn(t){return!!(t&&t.__v_isReadonly)}function Wt(t){return!!(t&&t.__v_isShallow)}function ur(t){return t?!!t.__v_raw:!1}function ke(t){const e=t&&t.__v_raw;return e?ke(e):t}function dr(t){return!Qe(t,"__v_skip")&&Object.isExtensible(t)&&fl(t,"__v_skip",!0),t}const sn=t=>Je(t)?Ai(t):t,wo=t=>Je(t)?xi(t):t;function ht(t){return t?t.__v_isRef===!0:!1}function Q(t){return $l(t,!1)}function ln(t){return $l(t,!0)}function $l(t,e){return ht(t)?t:new tm(t,e)}class tm{constructor(e,n){this.dep=new _i,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?e:ke(e),this._value=n?e:sn(e),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(e){const n=this._rawValue,o=this.__v_isShallow||Wt(e)||Rn(e);e=o?e:ke(e),pn(e,n)&&(this._rawValue=e,this._value=o?e:sn(e),this.dep.trigger())}}function I(t){return ht(t)?t.value:t}function $t(t){return Me(t)?t():I(t)}const nm={get:(t,e,n)=>e==="__v_raw"?t:I(Reflect.get(t,e,n)),set:(t,e,n,o)=>{const r=t[e];return ht(r)&&!ht(n)?(r.value=n,!0):Reflect.set(t,e,n,o)}};function Nl(t){return qn(t)?t:new Proxy(t,nm)}class om{constructor(e,n,o){this._object=e,this._defaultValue=o,this.__v_isRef=!0,this._value=void 0,this._key=Bt(n)?n:String(n),this._raw=ke(e);let r=!0,a=e;if(!Ce(e)||Bt(this._key)||!qr(this._key))do r=!ur(a)||Wt(a);while(r&&(a=a.__v_raw));this._shallow=r}get value(){let e=this._object[this._key];return this._shallow&&(e=I(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&ht(this._raw[this._key])){const n=this._object[this._key];if(ht(n)){n.value=e;return}}this._object[this._key]=e}get dep(){return Lf(this._raw,this._key)}}class rm{constructor(e){this._getter=e,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function jl(t,e,n){return ht(t)?t:Me(t)?new rm(t):Je(t)&&arguments.length>1?am(t,e,n):Q(t)}function am(t,e,n){return new om(t,e,n)}class im{constructor(e,n,o){this.fn=e,this.setter=n,this._value=void 0,this.dep=new _i(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=sr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=o}notify(){if(this.flags|=16,!(this.flags&8)&&at!==this)return vl(this,!0),!0}get value(){const e=this.dep.track();return El(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function sm(t,e,n=!1){let o,r;return Me(t)?o=t:(o=t.get,r=t.set),new im(o,r,n)}const ia={},sa=new WeakMap;let go;function lm(t,e=!1,n=go){if(n){let o=sa.get(n);o||sa.set(n,o=[]),o.push(t)}}function cm(t,e,n=ot){const{immediate:o,deep:r,once:a,scheduler:i,augmentJob:s,call:l}=n,c=A=>r?A:Wt(A)||r===!1||r===0?wn(A,1):wn(A);let u,d,p,h,g=!1,f=!1;if(ht(t)?(d=()=>t.value,g=Wt(t)):qn(t)?(d=()=>c(t),g=!0):Ce(t)?(f=!0,g=t.some(A=>qn(A)||Wt(A)),d=()=>t.map(A=>{if(ht(A))return A.value;if(qn(A))return c(A);if(Me(A))return l?l(A,2):A()})):Me(t)?e?d=l?()=>l(t,2):t:d=()=>{if(p){hn();try{p()}finally{gn()}}const A=go;go=u;try{return l?l(t,3,[h]):t(h)}finally{go=A}}:d=dn,e&&r){const A=d,T=r===!0?1/0:r;d=()=>wn(A(),T)}const F=kf(),y=()=>{u.stop(),F&&F.active&&hi(F.effects,u)};if(a&&e){const A=e;e=(...T)=>{A(...T),y()}}let _=f?new Array(t.length).fill(ia):ia;const E=A=>{if(!(!(u.flags&1)||!u.dirty&&!A))if(e){const T=u.run();if(r||g||(f?T.some((q,w)=>pn(q,_[w])):pn(T,_))){p&&p();const q=go;go=u;try{const w=[T,_===ia?void 0:f&&_[0]===ia?[]:_,h];_=T,l?l(e,3,w):e(...w)}finally{go=q}}}else u.run()};return s&&s(E),u=new yl(d),u.scheduler=i?()=>i(E,!1):E,h=A=>lm(A,!1,u),p=u.onStop=()=>{const A=sa.get(u);if(A){if(l)l(A,4);else for(const T of A)T();sa.delete(u)}},e?o?E(!0):_=u.run():i?i(E.bind(null,!0),!0):u.run(),y.pause=u.pause.bind(u),y.resume=u.resume.bind(u),y.stop=y,y}function wn(t,e=1/0,n){if(e<=0||!Je(t)||t.__v_skip||(n=n||new Map,(n.get(t)||0)>=e))return t;if(n.set(t,e),e--,ht(t))wn(t.value,e,n);else if(Ce(t))for(let o=0;o<t.length;o++)wn(t[o],e,n);else if(Yr(t)||Mo(t))t.forEach(o=>{wn(o,e,n)});else if(gl(t)){for(const o in t)wn(t[o],e,n);for(const o of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,o)&&wn(t[o],e,n)}return t}/**
10
10
  * @vue/runtime-core v3.5.31
11
11
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
12
12
  * @license MIT
13
- **/const pr=[];let xi=!1;function cT(t,...e){if(xi)return;xi=!0,hn();const n=pr.length?pr[pr.length-1].component:null,o=n&&n.appContext.config.warnHandler,r=sm();if(o)Oo(o,n,11,[t+e.map(a=>{var i,s;return(s=(i=a.toString)==null?void 0:i.call(a))!=null?s:JSON.stringify(a)}).join(""),n&&n.proxy,r.map(({vnode:a})=>`at <${zc(n,a.type)}>`).join(`
13
+ **/const pr=[];let Ci=!1;function _T(t,...e){if(Ci)return;Ci=!0,hn();const n=pr.length?pr[pr.length-1].component:null,o=n&&n.appContext.config.warnHandler,r=um();if(o)Oo(o,n,11,[t+e.map(a=>{var i,s;return(s=(i=a.toString)==null?void 0:i.call(a))!=null?s:JSON.stringify(a)}).join(""),n&&n.proxy,r.map(({vnode:a})=>`at <${Wc(n,a.type)}>`).join(`
14
14
  `),r]);else{const a=[`[Vue warn]: ${t}`,...e];r.length&&a.push(`
15
- `,...lm(r)),console.warn(...a)}gn(),xi=!1}function sm(){let t=pr[pr.length-1];if(!t)return[];const e=[];for(;t;){const n=e[0];n&&n.vnode===t?n.recurseCount++:e.push({vnode:t,recurseCount:0});const o=t.component&&t.component.parent;t=o&&o.vnode}return e}function lm(t){const e=[];return t.forEach((n,o)=>{e.push(...o===0?[]:[`
16
- `],...cm(n))}),e}function cm({vnode:t,recurseCount:e}){const n=e>0?`... (${e} recursive calls)`:"",o=t.component?t.component.parent==null:!1,r=` at <${zc(t.component,t.type,o)}`,a=">"+n;return t.props?[r,...um(t.props),a]:[r+a]}function um(t){const e=[],n=Object.keys(t);return n.slice(0,3).forEach(o=>{e.push(...jl(o,t[o]))}),n.length>3&&e.push(" ..."),e}function jl(t,e,n){return ut(e)?(e=JSON.stringify(e),n?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?n?e:[`${t}=${e}`]:ht(e)?(e=jl(t,ke(e.value),!0),n?e:[`${t}=Ref<`,e,">"]):Me(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=ke(e),n?e:[`${t}=`,e])}function Oo(t,e,n,o){try{return o?t(...o):t()}catch(r){sa(r,e,n)}}function mn(t,e,n,o){if(Me(t)){const r=Oo(t,e,n,o);return r&&dl(r)&&r.catch(a=>{sa(a,e,n)}),r}if(Ce(t)){const r=[];for(let a=0;a<t.length;a++)r.push(mn(t[a],e,n,o));return r}}function sa(t,e,n,o=!0){const r=e?e.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:i}=e&&e.appContext.config||ot;if(e){let s=e.parent;const l=e.proxy,c=`https://vuejs.org/error-reference/#runtime-${n}`;for(;s;){const u=s.ec;if(u){for(let d=0;d<u.length;d++)if(u[d](t,l,c)===!1)return}s=s.parent}if(a){hn(),Oo(a,null,10,[t,l,c]),gn();return}}dm(t,n,r,o,i)}function dm(t,e,n,o=!0,r=!1){if(r)throw t;console.error(t)}const Ot=[];let Pn=-1;const ko=[];let Kn=null,Io=0;const Ul=Promise.resolve();let la=null;function ca(t){const e=la||Ul;return t?e.then(this?t.bind(this):t):e}function pm(t){let e=Pn+1,n=Ot.length;for(;e<n;){const o=e+n>>>1,r=Ot[o],a=hr(r);a<t||a===t&&r.flags&2?e=o+1:n=o}return e}function Ci(t){if(!(t.flags&1)){const e=hr(t),n=Ot[Ot.length-1];!n||!(t.flags&2)&&e>=hr(n)?Ot.push(t):Ot.splice(pm(e),0,t),t.flags|=1,Bl()}}function Bl(){la||(la=Ul.then(Hl))}function hm(t){Ce(t)?ko.push(...t):Kn&&t.id===-1?Kn.splice(Io+1,0,t):t.flags&1||(ko.push(t),t.flags|=1),Bl()}function zl(t,e,n=Pn+1){for(;n<Ot.length;n++){const o=Ot[n];if(o&&o.flags&2){if(t&&o.id!==t.uid)continue;Ot.splice(n,1),n--,o.flags&4&&(o.flags&=-2),o(),o.flags&4||(o.flags&=-2)}}}function Wl(t){if(ko.length){const e=[...new Set(ko)].sort((n,o)=>hr(n)-hr(o));if(ko.length=0,Kn){Kn.push(...e);return}for(Kn=e,Io=0;Io<Kn.length;Io++){const n=Kn[Io];n.flags&4&&(n.flags&=-2),n.flags&8||n(),n.flags&=-2}Kn=null,Io=0}}const hr=t=>t.id==null?t.flags&2?-1:1/0:t.id;function Hl(t){try{for(Pn=0;Pn<Ot.length;Pn++){const e=Ot[Pn];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Oo(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Pn<Ot.length;Pn++){const e=Ot[Pn];e&&(e.flags&=-2)}Pn=-1,Ot.length=0,Wl(),la=null,(Ot.length||ko.length)&&Hl()}}let _t=null,Vl=null;function ua(t){const e=_t;return _t=t,Vl=t&&t.type.__scopeId||null,e}function We(t,e=_t,n){if(!e||t._n)return t;const o=(...r)=>{o._d&&ya(-1);const a=ua(e);let i;try{i=t(...r)}finally{ua(a),o._d&&ya(1)}return i};return o._n=!0,o._c=!0,o._d=!0,o}function fo(t,e){if(_t===null)return t;const n=Sa(_t),o=t.dirs||(t.dirs=[]);for(let r=0;r<e.length;r++){let[a,i,s,l=ot]=e[r];a&&(Me(a)&&(a={mounted:a,updated:a}),a.deep&&wn(i),o.push({dir:a,instance:n,value:i,oldValue:void 0,arg:s,modifiers:l}))}return t}function mo(t,e,n,o){const r=t.dirs,a=e&&e.dirs;for(let i=0;i<r.length;i++){const s=r[i];a&&(s.oldValue=a[i].value);let l=s.dir[o];l&&(hn(),mn(l,n,8,[t.el,s,t,e]),gn())}}function da(t,e){if(xt){let n=xt.provides;const o=xt.parent&&xt.parent.provides;o===n&&(n=xt.provides=Object.create(o)),n[t]=e}}function Po(t,e,n=!1){const o=Gc();if(o||No){let r=No?No._context.provides:o?o.parent==null||o.ce?o.vnode.appContext&&o.vnode.appContext.provides:o.parent.provides:void 0;if(r&&t in r)return r[t];if(arguments.length>1)return n&&Me(e)?e.call(o&&o.proxy):e}}const gm=Symbol.for("v-scx"),fm=()=>Po(gm);function Xn(t,e){return Ti(t,null,e)}function Se(t,e,n){return Ti(t,e,n)}function Ti(t,e,n=ot){const{immediate:o,deep:r,flush:a,once:i}=n,s=bt({},n),l=e&&o||!e&&a!=="post";let c;if(Sr){if(a==="sync"){const h=fm();c=h.__watcherHandles||(h.__watcherHandles=[])}else if(!l){const h=()=>{};return h.stop=dn,h.resume=dn,h.pause=dn,h}}const u=xt;s.call=(h,g,f)=>mn(h,u,g,f);let d=!1;a==="post"?s.scheduler=h=>{At(h,u&&u.suspense)}:a!=="sync"&&(d=!0,s.scheduler=(h,g)=>{g?h():Ci(h)}),s.augmentJob=h=>{e&&(h.flags|=4),d&&(h.flags|=2,u&&(h.id=u.uid,h.i=u))};const p=im(t,e,s);return Sr&&(c?c.push(p):l&&p()),p}function mm(t,e,n){const o=this.proxy,r=ut(t)?t.includes(".")?Yl(o,t):()=>o[t]:t.bind(o,o);let a;Me(e)?a=e:(a=e.handler,n=e);const i=Dr(this),s=Ti(r,a.bind(o),n);return i(),s}function Yl(t,e){const n=e.split(".");return()=>{let o=t;for(let r=0;r<n.length&&o;r++)o=o[n[r]];return o}}const ql=Symbol("_vte"),Pm=t=>t.__isTeleport,gr=t=>t&&(t.disabled||t.disabled===""),Fm=t=>t&&(t.defer||t.defer===""),Kl=t=>typeof SVGElement<"u"&&t instanceof SVGElement,Xl=t=>typeof MathMLElement=="function"&&t instanceof MathMLElement,Mi=(t,e)=>{const n=t&&t.to;return ut(n)?e?e(n):null:n},Zl={name:"Teleport",__isTeleport:!0,process(t,e,n,o,r,a,i,s,l,c){const{mc:u,pc:d,pbc:p,o:{insert:h,querySelector:g,createText:f,createComment:F}}=c,_=gr(e.props);let{shapeFlag:y,children:E,dynamicChildren:A}=e;if(t==null){const T=e.el=f(""),q=e.anchor=f("");h(T,n,o),h(q,n,o);const w=(W,J)=>{y&16&&u(E,W,J,r,a,i,s,l)},G=()=>{const W=e.target=Mi(e.props,g),J=Ri(W,e,f,h);W&&(i!=="svg"&&Kl(W)?i="svg":i!=="mathml"&&Xl(W)&&(i="mathml"),r&&r.isCE&&(r.ce._teleportTargets||(r.ce._teleportTargets=new Set)).add(W),_||(w(W,J),ha(e,!1)))};_&&(w(n,q),ha(e,!0)),Fm(e.props)||a&&a.pendingBranch?(e.el.__isMounted=!1,At(()=>{e.el.__isMounted===!1&&(G(),delete e.el.__isMounted)},a)):G()}else{e.el=t.el,e.targetStart=t.targetStart;const T=e.anchor=t.anchor,q=e.target=t.target,w=e.targetAnchor=t.targetAnchor;if(t.el.__isMounted===!1){At(()=>{Zl.process(t,e,n,o,r,a,i,s,l,c)},a);return}const G=gr(t.props),W=G?n:q,J=G?T:w;if(i==="svg"||Kl(q)?i="svg":(i==="mathml"||Xl(q))&&(i="mathml"),A?(p(t.dynamicChildren,A,W,r,a,i,s),Ui(t,e,!0)):l||d(t,e,W,J,r,a,i,s,!1),_)G?e.props&&t.props&&e.props.to!==t.props.to&&(e.props.to=t.props.to):pa(e,n,T,c,1);else if((e.props&&e.props.to)!==(t.props&&t.props.to)){const ue=e.target=Mi(e.props,g);ue&&pa(e,ue,null,c,0)}else G&&pa(e,q,w,c,1);ha(e,_)}},remove(t,e,n,{um:o,o:{remove:r}},a){const{shapeFlag:i,children:s,anchor:l,targetStart:c,targetAnchor:u,target:d,props:p}=t;if(d&&(r(c),r(u)),a&&r(l),i&16){const h=a||!gr(p);for(let g=0;g<s.length;g++){const f=s[g];o(f,e,n,h,!!f.dynamicChildren)}}},move:pa,hydrate:bm};function pa(t,e,n,{o:{insert:o},m:r},a=2){a===0&&o(t.targetAnchor,e,n);const{el:i,anchor:s,shapeFlag:l,children:c,props:u}=t,d=a===2;if(d&&o(i,e,n),(!d||gr(u))&&l&16)for(let p=0;p<c.length;p++)r(c[p],e,n,2);d&&o(s,e,n)}function bm(t,e,n,o,r,a,{o:{nextSibling:i,parentNode:s,querySelector:l,insert:c,createText:u}},d){function p(F,_){let y=_;for(;y;){if(y&&y.nodeType===8){if(y.data==="teleport start anchor")e.targetStart=y;else if(y.data==="teleport anchor"){e.targetAnchor=y,F._lpa=e.targetAnchor&&i(e.targetAnchor);break}}y=i(y)}}function h(F,_){_.anchor=d(i(F),_,s(F),n,o,r,a)}const g=e.target=Mi(e.props,l),f=gr(e.props);if(g){const F=g._lpa||g.firstChild;e.shapeFlag&16&&(f?(h(t,e),p(g,F),e.targetAnchor||Ri(g,e,u,c,s(t)===g?t:null)):(e.anchor=i(t),p(g,F),e.targetAnchor||Ri(g,e,u,c),d(F&&i(F),e,g,n,o,r,a))),ha(e,f)}else f&&e.shapeFlag&16&&(h(t,e),e.targetStart=t,e.targetAnchor=i(t));return e.anchor&&i(e.anchor)}const Ql=Zl;function ha(t,e){const n=t.ctx;if(n&&n.ut){let o,r;for(e?(o=t.el,r=t.anchor):(o=t.targetStart,r=t.targetAnchor);o&&o!==r;)o.nodeType===1&&o.setAttribute("data-v-owner",n.uid),o=o.nextSibling;n.ut()}}function Ri(t,e,n,o,r=null){const a=e.targetStart=n(""),i=e.targetAnchor=n("");return a[ql]=i,t&&(o(a,t,r),o(i,t,r)),i}const _m=Symbol("_leaveCb");function wi(t,e){t.shapeFlag&6&&t.component?(t.transition=e,wi(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function ie(t,e){return Me(t)?bt({name:t.name},e,{setup:t}):t}function Jl(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function ec(t,e){let n;return!!((n=Object.getOwnPropertyDescriptor(t,e))&&!n.configurable)}const ga=new WeakMap;function fr(t,e,n,o,r=!1){if(Ce(t)){t.forEach((f,F)=>fr(f,e&&(Ce(e)?e[F]:e),n,o,r));return}if(Go(o)&&!r){o.shapeFlag&512&&o.type.__asyncResolved&&o.component.subTree.component&&fr(t,e,n,o.component.subTree);return}const a=o.shapeFlag&4?Sa(o.component):o.el,i=r?null:a,{i:s,r:l}=t,c=e&&e.r,u=s.refs===ot?s.refs={}:s.refs,d=s.setupState,p=ke(d),h=d===ot?cl:f=>ec(u,f)?!1:Qe(p,f),g=(f,F)=>!(F&&ec(u,F));if(c!=null&&c!==l){if(tc(e),ut(c))u[c]=null,h(c)&&(d[c]=null);else if(ht(c)){const f=e;g(c,f.k)&&(c.value=null),f.k&&(u[f.k]=null)}}if(Me(l))Oo(l,s,12,[i,u]);else{const f=ut(l),F=ht(l);if(f||F){const _=()=>{if(t.f){const y=f?h(l)?d[l]:u[l]:g()||!t.k?l.value:u[t.k];if(r)Ce(y)&&pi(y,a);else if(Ce(y))y.includes(a)||y.push(a);else if(f)u[l]=[a],h(l)&&(d[l]=u[l]);else{const E=[a];g(l,t.k)&&(l.value=E),t.k&&(u[t.k]=E)}}else f?(u[l]=i,h(l)&&(d[l]=i)):F&&(g(l,t.k)&&(l.value=i),t.k&&(u[t.k]=i))};if(i){const y=()=>{_(),ga.delete(t)};y.id=-1,ga.set(t,y),At(y,n)}else tc(t),_()}}}function tc(t){const e=ga.get(t);e&&(e.flags|=8,ga.delete(t))}Qr().requestIdleCallback,Qr().cancelIdleCallback;const Go=t=>!!t.type.__asyncLoader,nc=t=>t.type.__isKeepAlive;function ym(t,e){oc(t,"a",e)}function vm(t,e){oc(t,"da",e)}function oc(t,e,n=xt){const o=t.__wdc||(t.__wdc=()=>{let r=n;for(;r;){if(r.isDeactivated)return;r=r.parent}return t()});if(fa(e,o,n),n){let r=n.parent;for(;r&&r.parent;)nc(r.parent.vnode)&&Dm(o,e,n,r),r=r.parent}}function Dm(t,e,n,o){const r=fa(e,t,o,!0);$o(()=>{pi(o[e],r)},n)}function fa(t,e,n=xt,o=!1){if(n){const r=n[t]||(n[t]=[]),a=e.__weh||(e.__weh=(...i)=>{hn();const s=Dr(n),l=mn(e,n,t,i);return s(),gn(),l});return o?r.unshift(a):r.push(a),a}}const On=t=>(e,n=xt)=>{(!Sr||t==="sp")&&fa(t,(...o)=>e(...o),n)},Sm=On("bm"),Lo=On("m"),Em=On("bu"),Am=On("u"),mr=On("bum"),$o=On("um"),xm=On("sp"),Cm=On("rtg"),Tm=On("rtc");function Mm(t,e=xt){fa("ec",t,e)}const rc="components";function Rm(t,e){return ic(rc,t,!0,e)||t}const ac=Symbol.for("v-ndc");function Fn(t){return ut(t)?ic(rc,t,!1)||t:t||ac}function ic(t,e,n=!0,o=!1){const r=_t||xt;if(r){const a=r.type;{const s=Bc(a,!1);if(s&&(s===e||s===wt(e)||s===Kr(wt(e))))return a}const i=sc(r[t]||a[t],e)||sc(r.appContext[t],e);return!i&&o?a:i}}function sc(t,e){return t&&(t[e]||t[wt(e)]||t[Kr(wt(e))])}function tt(t,e,n,o){let r;const a=n,i=Ce(t);if(i||ut(t)){const s=i&&qn(t);let l=!1,c=!1;s&&(l=!Wt(t),c=Rn(t),t=ea(t)),r=new Array(t.length);for(let u=0,d=t.length;u<d;u++)r[u]=e(l?c?wo(sn(t[u])):sn(t[u]):t[u],u,void 0,a)}else if(typeof t=="number"){r=new Array(t);for(let s=0;s<t;s++)r[s]=e(s+1,s,void 0,a)}else if(Je(t))if(t[Symbol.iterator])r=Array.from(t,(s,l)=>e(s,l,void 0,a));else{const s=Object.keys(t);r=new Array(s.length);for(let l=0,c=s.length;l<c;l++){const u=s[l];r[l]=e(t[u],u,l,a)}}else r=[];return r}function wm(t,e){for(let n=0;n<e.length;n++){const o=e[n];if(Ce(o))for(let r=0;r<o.length;r++)t[o[r].name]=o[r].fn;else o&&(t[o.name]=o.key?(...r)=>{const a=o.fn(...r);return a&&(a.key=o.key),a}:o.fn)}return t}function $e(t,e,n={},o,r){if(_t.ce||_t.parent&&Go(_t.parent)&&_t.parent.ce){const c=Object.keys(n).length>0;return e!=="default"&&(n.name=e),v(),he(pe,null,[je("slot",n,o&&o())],c?-2:64)}let a=t[e];a&&a._c&&(a._d=!1),v();const i=a&&lc(a(n)),s=n.key||i&&i.key,l=he(pe,{key:(s&&!Bt(s)?s:`_${e}`)+(!i&&o?"_fb":"")},i||(o?o():[]),i&&t._===1?64:-2);return l.scopeId&&(l.slotScopeIds=[l.scopeId+"-s"]),a&&a._c&&(a._d=!0),l}function lc(t){return t.some(e=>yr(e)?!(e.type===kn||e.type===pe&&!lc(e.children)):!0)?t:null}const Oi=t=>t?$c(t)?Sa(t):Oi(t.parent):null,Pr=bt(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>Oi(t.parent),$root:t=>Oi(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>hc(t),$forceUpdate:t=>t.f||(t.f=()=>{Ci(t.update)}),$nextTick:t=>t.n||(t.n=ca.bind(t.proxy)),$watch:t=>mm.bind(t)}),ki=(t,e)=>t!==ot&&!t.__isScriptSetup&&Qe(t,e),Om={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:n,setupState:o,data:r,props:a,accessCache:i,type:s,appContext:l}=t;if(e[0]!=="$"){const p=i[e];if(p!==void 0)switch(p){case 1:return o[e];case 2:return r[e];case 4:return n[e];case 3:return a[e]}else{if(ki(o,e))return i[e]=1,o[e];if(r!==ot&&Qe(r,e))return i[e]=2,r[e];if(Qe(a,e))return i[e]=3,a[e];if(n!==ot&&Qe(n,e))return i[e]=4,n[e];Ii&&(i[e]=0)}}const c=Pr[e];let u,d;if(c)return e==="$attrs"&&Et(t.attrs,"get",""),c(t);if((u=s.__cssModules)&&(u=u[e]))return u;if(n!==ot&&Qe(n,e))return i[e]=4,n[e];if(d=l.config.globalProperties,Qe(d,e))return d[e]},set({_:t},e,n){const{data:o,setupState:r,ctx:a}=t;return ki(r,e)?(r[e]=n,!0):o!==ot&&Qe(o,e)?(o[e]=n,!0):Qe(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(a[e]=n,!0)},has({_:{data:t,setupState:e,accessCache:n,ctx:o,appContext:r,props:a,type:i}},s){let l;return!!(n[s]||t!==ot&&s[0]!=="$"&&Qe(t,s)||ki(e,s)||Qe(a,s)||Qe(o,s)||Qe(Pr,s)||Qe(r.config.globalProperties,s)||(l=i.__cssModules)&&l[s])},defineProperty(t,e,n){return n.get!=null?t._.accessCache[e]=0:Qe(n,"value")&&this.set(t,e,n.value,null),Reflect.defineProperty(t,e,n)}};function ma(){return cc().slots}function km(){return cc().attrs}function cc(t){const e=Gc();return e.setupContext||(e.setupContext=Uc(e))}function uc(t){return Ce(t)?t.reduce((e,n)=>(e[n]=null,e),{}):t}let Ii=!0;function Im(t){const e=hc(t),n=t.proxy,o=t.ctx;Ii=!1,e.beforeCreate&&dc(e.beforeCreate,t,"bc");const{data:r,computed:a,methods:i,watch:s,provide:l,inject:c,created:u,beforeMount:d,mounted:p,beforeUpdate:h,updated:g,activated:f,deactivated:F,beforeDestroy:_,beforeUnmount:y,destroyed:E,unmounted:A,render:T,renderTracked:q,renderTriggered:w,errorCaptured:G,serverPrefetch:W,expose:J,inheritAttrs:ue,components:ce,directives:ee,filters:ge}=e;if(c&&Gm(c,o,null),i)for(const Te in i){const oe=i[Te];Me(oe)&&(o[Te]=oe.bind(n))}if(r){const Te=r.call(n,n);Je(Te)&&(t.data=Ei(Te))}if(Ii=!0,a)for(const Te in a){const oe=a[Te],He=Me(oe)?oe.bind(n,n):Me(oe.get)?oe.get.bind(n,n):dn,ft=!Me(oe)&&Me(oe.set)?oe.set.bind(n):dn,Ve=P({get:He,set:ft});Object.defineProperty(o,Te,{enumerable:!0,configurable:!0,get:()=>Ve.value,set:O=>Ve.value=O})}if(s)for(const Te in s)pc(s[Te],o,n,Te);if(l){const Te=Me(l)?l.call(n):l;Reflect.ownKeys(Te).forEach(oe=>{da(oe,Te[oe])})}u&&dc(u,t,"c");function Ee(Te,oe){Ce(oe)?oe.forEach(He=>Te(He.bind(n))):oe&&Te(oe.bind(n))}if(Ee(Sm,d),Ee(Lo,p),Ee(Em,h),Ee(Am,g),Ee(ym,f),Ee(vm,F),Ee(Mm,G),Ee(Tm,q),Ee(Cm,w),Ee(mr,y),Ee($o,A),Ee(xm,W),Ce(J))if(J.length){const Te=t.exposed||(t.exposed={});J.forEach(oe=>{Object.defineProperty(Te,oe,{get:()=>n[oe],set:He=>n[oe]=He,enumerable:!0})})}else t.exposed||(t.exposed={});T&&t.render===dn&&(t.render=T),ue!=null&&(t.inheritAttrs=ue),ce&&(t.components=ce),ee&&(t.directives=ee),W&&Jl(t)}function Gm(t,e,n=dn){Ce(t)&&(t=Gi(t));for(const o in t){const r=t[o];let a;Je(r)?"default"in r?a=Po(r.from||o,r.default,!0):a=Po(r.from||o):a=Po(r),ht(a)?Object.defineProperty(e,o,{enumerable:!0,configurable:!0,get:()=>a.value,set:i=>a.value=i}):e[o]=a}}function dc(t,e,n){mn(Ce(t)?t.map(o=>o.bind(e.proxy)):t.bind(e.proxy),e,n)}function pc(t,e,n,o){let r=o.includes(".")?Yl(n,o):()=>n[o];if(ut(t)){const a=e[t];Me(a)&&Se(r,a)}else if(Me(t))Se(r,t.bind(n));else if(Je(t))if(Ce(t))t.forEach(a=>pc(a,e,n,o));else{const a=Me(t.handler)?t.handler.bind(n):e[t.handler];Me(a)&&Se(r,a,t)}}function hc(t){const e=t.type,{mixins:n,extends:o}=e,{mixins:r,optionsCache:a,config:{optionMergeStrategies:i}}=t.appContext,s=a.get(e);let l;return s?l=s:!r.length&&!n&&!o?l=e:(l={},r.length&&r.forEach(c=>Pa(l,c,i,!0)),Pa(l,e,i)),Je(e)&&a.set(e,l),l}function Pa(t,e,n,o=!1){const{mixins:r,extends:a}=e;a&&Pa(t,a,n,!0),r&&r.forEach(i=>Pa(t,i,n,!0));for(const i in e)if(!(o&&i==="expose")){const s=Lm[i]||n&&n[i];t[i]=s?s(t[i],e[i]):e[i]}return t}const Lm={data:gc,props:fc,emits:fc,methods:Fr,computed:Fr,beforeCreate:kt,created:kt,beforeMount:kt,mounted:kt,beforeUpdate:kt,updated:kt,beforeDestroy:kt,beforeUnmount:kt,destroyed:kt,unmounted:kt,activated:kt,deactivated:kt,errorCaptured:kt,serverPrefetch:kt,components:Fr,directives:Fr,watch:Nm,provide:gc,inject:$m};function gc(t,e){return e?t?function(){return bt(Me(t)?t.call(this,this):t,Me(e)?e.call(this,this):e)}:e:t}function $m(t,e){return Fr(Gi(t),Gi(e))}function Gi(t){if(Ce(t)){const e={};for(let n=0;n<t.length;n++)e[t[n]]=t[n];return e}return t}function kt(t,e){return t?[...new Set([].concat(t,e))]:e}function Fr(t,e){return t?bt(Object.create(null),t,e):e}function fc(t,e){return t?Ce(t)&&Ce(e)?[...new Set([...t,...e])]:bt(Object.create(null),uc(t),uc(e??{})):e}function Nm(t,e){if(!t)return e;if(!e)return t;const n=bt(Object.create(null),t);for(const o in e)n[o]=kt(t[o],e[o]);return n}function mc(){return{app:null,config:{isNativeTag:cl,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let jm=0;function Um(t,e){return function(o,r=null){Me(o)||(o=bt({},o)),r!=null&&!Je(r)&&(r=null);const a=mc(),i=new WeakSet,s=[];let l=!1;const c=a.app={_uid:jm++,_component:o,_props:r,_container:null,_context:a,_instance:null,version:bP,get config(){return a.config},set config(u){},use(u,...d){return i.has(u)||(u&&Me(u.install)?(i.add(u),u.install(c,...d)):Me(u)&&(i.add(u),u(c,...d))),c},mixin(u){return a.mixins.includes(u)||a.mixins.push(u),c},component(u,d){return d?(a.components[u]=d,c):a.components[u]},directive(u,d){return d?(a.directives[u]=d,c):a.directives[u]},mount(u,d,p){if(!l){const h=c._ceVNode||je(o,r);return h.appContext=a,p===!0?p="svg":p===!1&&(p=void 0),t(h,u,p),l=!0,c._container=u,u.__vue_app__=c,Sa(h.component)}},onUnmount(u){s.push(u)},unmount(){l&&(mn(s,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,d){return a.provides[u]=d,c},runWithContext(u){const d=No;No=c;try{return u()}finally{No=d}}};return c}}let No=null;const Bm=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${wt(e)}Modifiers`]||t[`${Yn(e)}Modifiers`];function zm(t,e,...n){if(t.isUnmounted)return;const o=t.vnode.props||ot;let r=n;const a=e.startsWith("update:"),i=a&&Bm(o,e.slice(7));i&&(i.trim&&(r=n.map(u=>ut(u)?u.trim():u)),i.number&&(r=n.map(Zr)));let s,l=o[s=hi(e)]||o[s=hi(wt(e))];!l&&a&&(l=o[s=hi(Yn(e))]),l&&mn(l,t,6,r);const c=o[s+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[s])return;t.emitted[s]=!0,mn(c,t,6,r)}}const Wm=new WeakMap;function Pc(t,e,n=!1){const o=n?Wm:e.emitsCache,r=o.get(t);if(r!==void 0)return r;const a=t.emits;let i={},s=!1;if(!Me(t)){const l=c=>{const u=Pc(c,e,!0);u&&(s=!0,bt(i,u))};!n&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!a&&!s?(Je(t)&&o.set(t,null),null):(Ce(a)?a.forEach(l=>i[l]=null):bt(i,a),Je(t)&&o.set(t,i),i)}function Fa(t,e){return!t||!Wr(e)?!1:(e=e.slice(2).replace(/Once$/,""),Qe(t,e[0].toLowerCase()+e.slice(1))||Qe(t,Yn(e))||Qe(t,e))}function uT(){}function Fc(t){const{type:e,vnode:n,proxy:o,withProxy:r,propsOptions:[a],slots:i,attrs:s,emit:l,render:c,renderCache:u,props:d,data:p,setupState:h,ctx:g,inheritAttrs:f}=t,F=ua(t);let _,y;try{if(n.shapeFlag&4){const A=r||o,T=A;_=bn(c.call(T,A,u,d,h,p,g)),y=s}else{const A=e;_=bn(A.length>1?A(d,{attrs:s,slots:i,emit:l}):A(d,null)),y=e.props?s:Hm(s)}}catch(A){br.length=0,sa(A,t,1),_=je(kn)}let E=_;if(y&&f!==!1){const A=Object.keys(y),{shapeFlag:T}=E;A.length&&T&7&&(a&&A.some(Hr)&&(y=Vm(y,a)),E=jo(E,y,!1,!0))}return n.dirs&&(E=jo(E,null,!1,!0),E.dirs=E.dirs?E.dirs.concat(n.dirs):n.dirs),n.transition&&wi(E,n.transition),_=E,ua(F),_}const Hm=t=>{let e;for(const n in t)(n==="class"||n==="style"||Wr(n))&&((e||(e={}))[n]=t[n]);return e},Vm=(t,e)=>{const n={};for(const o in t)(!Hr(o)||!(o.slice(9)in e))&&(n[o]=t[o]);return n};function Ym(t,e,n){const{props:o,children:r,component:a}=t,{props:i,children:s,patchFlag:l}=e,c=a.emitsOptions;if(e.dirs||e.transition)return!0;if(n&&l>=0){if(l&1024)return!0;if(l&16)return o?bc(o,i,c):!!i;if(l&8){const u=e.dynamicProps;for(let d=0;d<u.length;d++){const p=u[d];if(_c(i,o,p)&&!Fa(c,p))return!0}}}else return(r||s)&&(!s||!s.$stable)?!0:o===i?!1:o?i?bc(o,i,c):!0:!!i;return!1}function bc(t,e,n){const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!0;for(let r=0;r<o.length;r++){const a=o[r];if(_c(e,t,a)&&!Fa(n,a))return!0}return!1}function _c(t,e,n){const o=t[n],r=e[n];return n==="style"&&Je(o)&&Je(r)?!rr(o,r):o!==r}function qm({vnode:t,parent:e,suspense:n},o){for(;e;){const r=e.subTree;if(r.suspense&&r.suspense.activeBranch===t&&(r.suspense.vnode.el=r.el=o,t=r),r===t)(t=e.vnode).el=o,e=e.parent;else break}n&&n.activeBranch===t&&(n.vnode.el=o)}const yc={},vc=()=>Object.create(yc),Dc=t=>Object.getPrototypeOf(t)===yc;function Km(t,e,n,o=!1){const r={},a=vc();t.propsDefaults=Object.create(null),Sc(t,e,r,a);for(const i in t.propsOptions[0])i in r||(r[i]=void 0);n?t.props=o?r:Zf(r):t.type.props?t.props=r:t.props=a,t.attrs=a}function Xm(t,e,n,o){const{props:r,attrs:a,vnode:{patchFlag:i}}=t,s=ke(r),[l]=t.propsOptions;let c=!1;if((o||i>0)&&!(i&16)){if(i&8){const u=t.vnode.dynamicProps;for(let d=0;d<u.length;d++){let p=u[d];if(Fa(t.emitsOptions,p))continue;const h=e[p];if(l)if(Qe(a,p))h!==a[p]&&(a[p]=h,c=!0);else{const g=wt(p);r[g]=Li(l,s,g,h,t,!1)}else h!==a[p]&&(a[p]=h,c=!0)}}}else{Sc(t,e,r,a)&&(c=!0);let u;for(const d in s)(!e||!Qe(e,d)&&((u=Yn(d))===d||!Qe(e,u)))&&(l?n&&(n[d]!==void 0||n[u]!==void 0)&&(r[d]=Li(l,s,d,void 0,t,!0)):delete r[d]);if(a!==s)for(const d in a)(!e||!Qe(e,d))&&(delete a[d],c=!0)}c&&Tn(t.attrs,"set","")}function Sc(t,e,n,o){const[r,a]=t.propsOptions;let i=!1,s;if(e)for(let l in e){if(or(l))continue;const c=e[l];let u;r&&Qe(r,u=wt(l))?!a||!a.includes(u)?n[u]=c:(s||(s={}))[u]=c:Fa(t.emitsOptions,l)||(!(l in o)||c!==o[l])&&(o[l]=c,i=!0)}if(a){const l=ke(n),c=s||ot;for(let u=0;u<a.length;u++){const d=a[u];n[d]=Li(r,l,d,c[d],t,!Qe(c,d))}}return i}function Li(t,e,n,o,r,a){const i=t[n];if(i!=null){const s=Qe(i,"default");if(s&&o===void 0){const l=i.default;if(i.type!==Function&&!i.skipFactory&&Me(l)){const{propsDefaults:c}=r;if(n in c)o=c[n];else{const u=Dr(r);o=c[n]=l.call(null,e),u()}}else o=l;r.ce&&r.ce._setProp(n,o)}i[0]&&(a&&!s?o=!1:i[1]&&(o===""||o===Yn(n))&&(o=!0))}return o}const Zm=new WeakMap;function Ec(t,e,n=!1){const o=n?Zm:e.propsCache,r=o.get(t);if(r)return r;const a=t.props,i={},s=[];let l=!1;if(!Me(t)){const u=d=>{l=!0;const[p,h]=Ec(d,e,!0);bt(i,p),h&&s.push(...h)};!n&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!a&&!l)return Je(t)&&o.set(t,To),To;if(Ce(a))for(let u=0;u<a.length;u++){const d=wt(a[u]);Ac(d)&&(i[d]=ot)}else if(a)for(const u in a){const d=wt(u);if(Ac(d)){const p=a[u],h=i[d]=Ce(p)||Me(p)?{type:p}:bt({},p),g=h.type;let f=!1,F=!0;if(Ce(g))for(let _=0;_<g.length;++_){const y=g[_],E=Me(y)&&y.name;if(E==="Boolean"){f=!0;break}else E==="String"&&(F=!1)}else f=Me(g)&&g.name==="Boolean";h[0]=f,h[1]=F,(f||Qe(h,"default"))&&s.push(d)}}const c=[i,s];return Je(t)&&o.set(t,c),c}function Ac(t){return t[0]!=="$"&&!or(t)}const $i=t=>t==="_"||t==="_ctx"||t==="$stable",Ni=t=>Ce(t)?t.map(bn):[bn(t)],Qm=(t,e,n)=>{if(e._n)return e;const o=We((...r)=>Ni(e(...r)),n);return o._c=!1,o},xc=(t,e,n)=>{const o=t._ctx;for(const r in t){if($i(r))continue;const a=t[r];if(Me(a))e[r]=Qm(r,a,o);else if(a!=null){const i=Ni(a);e[r]=()=>i}}},Cc=(t,e)=>{const n=Ni(e);t.slots.default=()=>n},Tc=(t,e,n)=>{for(const o in e)(n||!$i(o))&&(t[o]=e[o])},Jm=(t,e,n)=>{const o=t.slots=vc();if(t.vnode.shapeFlag&32){const r=e._;r?(Tc(o,e,n),n&&gl(o,"_",r,!0)):xc(e,o)}else e&&Cc(t,e)},eP=(t,e,n)=>{const{vnode:o,slots:r}=t;let a=!0,i=ot;if(o.shapeFlag&32){const s=e._;s?n&&s===1?a=!1:Tc(r,e,n):(a=!e.$stable,xc(e,r)),i=e}else e&&(Cc(t,e),i={default:1});if(a)for(const s in r)!$i(s)&&i[s]==null&&delete r[s]},At=aP;function tP(t){return nP(t)}function nP(t,e){const n=Qr();n.__VUE__=!0;const{insert:o,remove:r,patchProp:a,createElement:i,createText:s,createComment:l,setText:c,setElementText:u,parentNode:d,nextSibling:p,setScopeId:h=dn,insertStaticContent:g}=t,f=(D,S,R,N=null,$=null,j=null,ne=void 0,K=null,Y=!!S.dynamicChildren)=>{if(D===S)return;D&&!vr(D,S)&&(N=de(D),O(D,$,j,!0),D=null),S.patchFlag===-2&&(Y=!1,S.dynamicChildren=null);const{type:B,ref:be,shapeFlag:re}=S;switch(B){case ba:F(D,S,R,N);break;case kn:_(D,S,R,N);break;case _a:D==null&&y(S,R,N,ne);break;case pe:ce(D,S,R,N,$,j,ne,K,Y);break;default:re&1?T(D,S,R,N,$,j,ne,K,Y):re&6?ee(D,S,R,N,$,j,ne,K,Y):(re&64||re&128)&&B.process(D,S,R,N,$,j,ne,K,Y,vt)}be!=null&&$?fr(be,D&&D.ref,j,S||D,!S):be==null&&D&&D.ref!=null&&fr(D.ref,null,j,D,!0)},F=(D,S,R,N)=>{if(D==null)o(S.el=s(S.children),R,N);else{const $=S.el=D.el;S.children!==D.children&&c($,S.children)}},_=(D,S,R,N)=>{D==null?o(S.el=l(S.children||""),R,N):S.el=D.el},y=(D,S,R,N)=>{[D.el,D.anchor]=g(D.children,S,R,N,D.el,D.anchor)},E=({el:D,anchor:S},R,N)=>{let $;for(;D&&D!==S;)$=p(D),o(D,R,N),D=$;o(S,R,N)},A=({el:D,anchor:S})=>{let R;for(;D&&D!==S;)R=p(D),r(D),D=R;r(S)},T=(D,S,R,N,$,j,ne,K,Y)=>{if(S.type==="svg"?ne="svg":S.type==="math"&&(ne="mathml"),D==null)q(S,R,N,$,j,ne,K,Y);else{const B=D.el&&D.el._isVueCE?D.el:null;try{B&&B._beginPatch(),W(D,S,$,j,ne,K,Y)}finally{B&&B._endPatch()}}},q=(D,S,R,N,$,j,ne,K)=>{let Y,B;const{props:be,shapeFlag:re,transition:Fe,dirs:De}=D;if(Y=D.el=i(D.type,j,be&&be.is,be),re&8?u(Y,D.children):re&16&&G(D.children,Y,null,N,$,ji(D,j),ne,K),De&&mo(D,null,N,"created"),w(Y,D,D.scopeId,ne,N),be){for(const Ge in be)Ge!=="value"&&!or(Ge)&&a(Y,Ge,null,be[Ge],j,N);"value"in be&&a(Y,"value",null,be.value,j),(B=be.onVnodeBeforeMount)&&_n(B,N,D)}De&&mo(D,null,N,"beforeMount");const we=oP($,Fe);we&&Fe.beforeEnter(Y),o(Y,S,R),((B=be&&be.onVnodeMounted)||we||De)&&At(()=>{try{B&&_n(B,N,D),we&&Fe.enter(Y),De&&mo(D,null,N,"mounted")}finally{}},$)},w=(D,S,R,N,$)=>{if(R&&h(D,R),N)for(let j=0;j<N.length;j++)h(D,N[j]);if($){let j=$.subTree;if(S===j||Oc(j.type)&&(j.ssContent===S||j.ssFallback===S)){const ne=$.vnode;w(D,ne,ne.scopeId,ne.slotScopeIds,$.parent)}}},G=(D,S,R,N,$,j,ne,K,Y=0)=>{for(let B=Y;B<D.length;B++){const be=D[B]=K?In(D[B]):bn(D[B]);f(null,be,S,R,N,$,j,ne,K)}},W=(D,S,R,N,$,j,ne)=>{const K=S.el=D.el;let{patchFlag:Y,dynamicChildren:B,dirs:be}=S;Y|=D.patchFlag&16;const re=D.props||ot,Fe=S.props||ot;let De;if(R&&Fo(R,!1),(De=Fe.onVnodeBeforeUpdate)&&_n(De,R,S,D),be&&mo(S,D,R,"beforeUpdate"),R&&Fo(R,!0),(re.innerHTML&&Fe.innerHTML==null||re.textContent&&Fe.textContent==null)&&u(K,""),B?J(D.dynamicChildren,B,K,R,N,ji(S,$),j):ne||oe(D,S,K,null,R,N,ji(S,$),j,!1),Y>0){if(Y&16)ue(K,re,Fe,R,$);else if(Y&2&&re.class!==Fe.class&&a(K,"class",null,Fe.class,$),Y&4&&a(K,"style",re.style,Fe.style,$),Y&8){const we=S.dynamicProps;for(let Ge=0;Ge<we.length;Ge++){const Oe=we[Ge],k=re[Oe],ye=Fe[Oe];(ye!==k||Oe==="value")&&a(K,Oe,k,ye,$,R)}}Y&1&&D.children!==S.children&&u(K,S.children)}else!ne&&B==null&&ue(K,re,Fe,R,$);((De=Fe.onVnodeUpdated)||be)&&At(()=>{De&&_n(De,R,S,D),be&&mo(S,D,R,"updated")},N)},J=(D,S,R,N,$,j,ne)=>{for(let K=0;K<S.length;K++){const Y=D[K],B=S[K],be=Y.el&&(Y.type===pe||!vr(Y,B)||Y.shapeFlag&198)?d(Y.el):R;f(Y,B,be,null,N,$,j,ne,!0)}},ue=(D,S,R,N,$)=>{if(S!==R){if(S!==ot)for(const j in S)!or(j)&&!(j in R)&&a(D,j,S[j],null,$,N);for(const j in R){if(or(j))continue;const ne=R[j],K=S[j];ne!==K&&j!=="value"&&a(D,j,K,ne,$,N)}"value"in R&&a(D,"value",S.value,R.value,$)}},ce=(D,S,R,N,$,j,ne,K,Y)=>{const B=S.el=D?D.el:s(""),be=S.anchor=D?D.anchor:s("");let{patchFlag:re,dynamicChildren:Fe,slotScopeIds:De}=S;De&&(K=K?K.concat(De):De),D==null?(o(B,R,N),o(be,R,N),G(S.children||[],R,be,$,j,ne,K,Y)):re>0&&re&64&&Fe&&D.dynamicChildren&&D.dynamicChildren.length===Fe.length?(J(D.dynamicChildren,Fe,R,$,j,ne,K),(S.key!=null||$&&S===$.subTree)&&Ui(D,S,!0)):oe(D,S,R,be,$,j,ne,K,Y)},ee=(D,S,R,N,$,j,ne,K,Y)=>{S.slotScopeIds=K,D==null?S.shapeFlag&512?$.ctx.activate(S,R,N,ne,Y):ge(S,R,N,$,j,ne,Y):_e(D,S,Y)},ge=(D,S,R,N,$,j,ne)=>{const K=D.component=dP(D,N,$);if(nc(D)&&(K.ctx.renderer=vt),pP(K,!1,ne),K.asyncDep){if($&&$.registerDep(K,Ee,ne),!D.el){const Y=K.subTree=je(kn);_(null,Y,S,R),D.placeholder=Y.el}}else Ee(K,D,S,R,$,j,ne)},_e=(D,S,R)=>{const N=S.component=D.component;if(Ym(D,S,R))if(N.asyncDep&&!N.asyncResolved){Te(N,S,R);return}else N.next=S,N.update();else S.el=D.el,N.vnode=S},Ee=(D,S,R,N,$,j,ne)=>{const K=()=>{if(D.isMounted){let{next:re,bu:Fe,u:De,parent:we,vnode:Ge}=D;{const Ke=Mc(D);if(Ke){re&&(re.el=Ge.el,Te(D,re,ne)),Ke.asyncDep.then(()=>{At(()=>{D.isUnmounted||B()},$)});return}}let Oe=re,k;Fo(D,!1),re?(re.el=Ge.el,Te(D,re,ne)):re=Ge,Fe&&Xr(Fe),(k=re.props&&re.props.onVnodeBeforeUpdate)&&_n(k,we,re,Ge),Fo(D,!0);const ye=Fc(D),Le=D.subTree;D.subTree=ye,f(Le,ye,d(Le.el),de(Le),D,$,j),re.el=ye.el,Oe===null&&qm(D,ye.el),De&&At(De,$),(k=re.props&&re.props.onVnodeUpdated)&&At(()=>_n(k,we,re,Ge),$)}else{let re;const{el:Fe,props:De}=S,{bm:we,m:Ge,parent:Oe,root:k,type:ye}=D,Le=Go(S);Fo(D,!1),we&&Xr(we),!Le&&(re=De&&De.onVnodeBeforeMount)&&_n(re,Oe,S),Fo(D,!0);{k.ce&&k.ce._hasShadowRoot()&&k.ce._injectChildStyle(ye,D.parent?D.parent.type:void 0);const Ke=D.subTree=Fc(D);f(null,Ke,R,N,D,$,j),S.el=Ke.el}if(Ge&&At(Ge,$),!Le&&(re=De&&De.onVnodeMounted)){const Ke=S;At(()=>_n(re,Oe,Ke),$)}(S.shapeFlag&256||Oe&&Go(Oe.vnode)&&Oe.vnode.shapeFlag&256)&&D.a&&At(D.a,$),D.isMounted=!0,S=R=N=null}};D.scope.on();const Y=D.effect=new bl(K);D.scope.off();const B=D.update=Y.run.bind(Y),be=D.job=Y.runIfDirty.bind(Y);be.i=D,be.id=D.uid,Y.scheduler=()=>Ci(be),Fo(D,!0),B()},Te=(D,S,R)=>{S.component=D;const N=D.vnode.props;D.vnode=S,D.next=null,Xm(D,S.props,N,R),eP(D,S.children,R),hn(),zl(D),gn()},oe=(D,S,R,N,$,j,ne,K,Y=!1)=>{const B=D&&D.children,be=D?D.shapeFlag:0,re=S.children,{patchFlag:Fe,shapeFlag:De}=S;if(Fe>0){if(Fe&128){ft(B,re,R,N,$,j,ne,K,Y);return}else if(Fe&256){He(B,re,R,N,$,j,ne,K,Y);return}}De&8?(be&16&&L(B,$,j),re!==B&&u(R,re)):be&16?De&16?ft(B,re,R,N,$,j,ne,K,Y):L(B,$,j,!0):(be&8&&u(R,""),De&16&&G(re,R,N,$,j,ne,K,Y))},He=(D,S,R,N,$,j,ne,K,Y)=>{D=D||To,S=S||To;const B=D.length,be=S.length,re=Math.min(B,be);let Fe;for(Fe=0;Fe<re;Fe++){const De=S[Fe]=Y?In(S[Fe]):bn(S[Fe]);f(D[Fe],De,R,null,$,j,ne,K,Y)}B>be?L(D,$,j,!0,!1,re):G(S,R,N,$,j,ne,K,Y,re)},ft=(D,S,R,N,$,j,ne,K,Y)=>{let B=0;const be=S.length;let re=D.length-1,Fe=be-1;for(;B<=re&&B<=Fe;){const De=D[B],we=S[B]=Y?In(S[B]):bn(S[B]);if(vr(De,we))f(De,we,R,null,$,j,ne,K,Y);else break;B++}for(;B<=re&&B<=Fe;){const De=D[re],we=S[Fe]=Y?In(S[Fe]):bn(S[Fe]);if(vr(De,we))f(De,we,R,null,$,j,ne,K,Y);else break;re--,Fe--}if(B>re){if(B<=Fe){const De=Fe+1,we=De<be?S[De].el:N;for(;B<=Fe;)f(null,S[B]=Y?In(S[B]):bn(S[B]),R,we,$,j,ne,K,Y),B++}}else if(B>Fe)for(;B<=re;)O(D[B],$,j,!0),B++;else{const De=B,we=B,Ge=new Map;for(B=we;B<=Fe;B++){const dt=S[B]=Y?In(S[B]):bn(S[B]);dt.key!=null&&Ge.set(dt.key,B)}let Oe,k=0;const ye=Fe-we+1;let Le=!1,Ke=0;const Xe=new Array(ye);for(B=0;B<ye;B++)Xe[B]=0;for(B=De;B<=re;B++){const dt=D[B];if(k>=ye){O(dt,$,j,!0);continue}let Ze;if(dt.key!=null)Ze=Ge.get(dt.key);else for(Oe=we;Oe<=Fe;Oe++)if(Xe[Oe-we]===0&&vr(dt,S[Oe])){Ze=Oe;break}Ze===void 0?O(dt,$,j,!0):(Xe[Ze-we]=B+1,Ze>=Ke?Ke=Ze:Le=!0,f(dt,S[Ze],R,null,$,j,ne,K,Y),k++)}const Kt=Le?rP(Xe):To;for(Oe=Kt.length-1,B=ye-1;B>=0;B--){const dt=we+B,Ze=S[dt],Dt=S[dt+1],Ft=dt+1<be?Dt.el||wc(Dt):N;Xe[B]===0?f(null,Ze,R,Ft,$,j,ne,K,Y):Le&&(Oe<0||B!==Kt[Oe]?Ve(Ze,R,Ft,2):Oe--)}}},Ve=(D,S,R,N,$=null)=>{const{el:j,type:ne,transition:K,children:Y,shapeFlag:B}=D;if(B&6){Ve(D.component.subTree,S,R,N);return}if(B&128){D.suspense.move(S,R,N);return}if(B&64){ne.move(D,S,R,vt);return}if(ne===pe){o(j,S,R);for(let re=0;re<Y.length;re++)Ve(Y[re],S,R,N);o(D.anchor,S,R);return}if(ne===_a){E(D,S,R);return}if(N!==2&&B&1&&K)if(N===0)K.beforeEnter(j),o(j,S,R),At(()=>K.enter(j),$);else{const{leave:re,delayLeave:Fe,afterLeave:De}=K,we=()=>{D.ctx.isUnmounted?r(j):o(j,S,R)},Ge=()=>{j._isLeaving&&j[_m](!0),re(j,()=>{we(),De&&De()})};Fe?Fe(j,we,Ge):Ge()}else o(j,S,R)},O=(D,S,R,N=!1,$=!1)=>{const{type:j,props:ne,ref:K,children:Y,dynamicChildren:B,shapeFlag:be,patchFlag:re,dirs:Fe,cacheIndex:De,memo:we}=D;if(re===-2&&($=!1),K!=null&&(hn(),fr(K,null,R,D,!0),gn()),De!=null&&(S.renderCache[De]=void 0),be&256){S.ctx.deactivate(D);return}const Ge=be&1&&Fe,Oe=!Go(D);let k;if(Oe&&(k=ne&&ne.onVnodeBeforeUnmount)&&_n(k,S,D),be&6)se(D.component,R,N);else{if(be&128){D.suspense.unmount(R,N);return}Ge&&mo(D,null,S,"beforeUnmount"),be&64?D.type.remove(D,S,R,vt,N):B&&!B.hasOnce&&(j!==pe||re>0&&re&64)?L(B,S,R,!1,!0):(j===pe&&re&384||!$&&be&16)&&L(Y,S,R),N&&H(D)}const ye=we!=null&&De==null;(Oe&&(k=ne&&ne.onVnodeUnmounted)||Ge||ye)&&At(()=>{k&&_n(k,S,D),Ge&&mo(D,null,S,"unmounted"),ye&&(D.el=null)},R)},H=D=>{const{type:S,el:R,anchor:N,transition:$}=D;if(S===pe){V(R,N);return}if(S===_a){A(D);return}const j=()=>{r(R),$&&!$.persisted&&$.afterLeave&&$.afterLeave()};if(D.shapeFlag&1&&$&&!$.persisted){const{leave:ne,delayLeave:K}=$,Y=()=>ne(R,j);K?K(D.el,j,Y):Y()}else j()},V=(D,S)=>{let R;for(;D!==S;)R=p(D),r(D),D=R;r(S)},se=(D,S,R)=>{const{bum:N,scope:$,job:j,subTree:ne,um:K,m:Y,a:B}=D;Rc(Y),Rc(B),N&&Xr(N),$.stop(),j&&(j.flags|=8,O(ne,D,S,R)),K&&At(K,S),At(()=>{D.isUnmounted=!0},S)},L=(D,S,R,N=!1,$=!1,j=0)=>{for(let ne=j;ne<D.length;ne++)O(D[ne],S,R,N,$)},de=D=>{if(D.shapeFlag&6)return de(D.component.subTree);if(D.shapeFlag&128)return D.suspense.next();const S=p(D.anchor||D.el),R=S&&S[ql];return R?p(R):S};let Pe=!1;const Re=(D,S,R)=>{let N;D==null?S._vnode&&(O(S._vnode,null,null,!0),N=S._vnode.component):f(S._vnode||null,D,S,null,null,null,R),S._vnode=D,Pe||(Pe=!0,zl(N),Wl(),Pe=!1)},vt={p:f,um:O,m:Ve,r:H,mt:ge,mc:G,pc:oe,pbc:J,n:de,o:t};return{render:Re,hydrate:void 0,createApp:Um(Re)}}function ji({type:t,props:e},n){return n==="svg"&&t==="foreignObject"||n==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:n}function Fo({effect:t,job:e},n){n?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function oP(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Ui(t,e,n=!1){const o=t.children,r=e.children;if(Ce(o)&&Ce(r))for(let a=0;a<o.length;a++){const i=o[a];let s=r[a];s.shapeFlag&1&&!s.dynamicChildren&&((s.patchFlag<=0||s.patchFlag===32)&&(s=r[a]=In(r[a]),s.el=i.el),!n&&s.patchFlag!==-2&&Ui(i,s)),s.type===ba&&(s.patchFlag===-1&&(s=r[a]=In(s)),s.el=i.el),s.type===kn&&!s.el&&(s.el=i.el)}}function rP(t){const e=t.slice(),n=[0];let o,r,a,i,s;const l=t.length;for(o=0;o<l;o++){const c=t[o];if(c!==0){if(r=n[n.length-1],t[r]<c){e[o]=r,n.push(o);continue}for(a=0,i=n.length-1;a<i;)s=a+i>>1,t[n[s]]<c?a=s+1:i=s;c<t[n[a]]&&(a>0&&(e[o]=n[a-1]),n[a]=o)}}for(a=n.length,i=n[a-1];a-- >0;)n[a]=i,i=e[i];return n}function Mc(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Mc(e)}function Rc(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function wc(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?wc(e.subTree):null}const Oc=t=>t.__isSuspense;function aP(t,e){e&&e.pendingBranch?Ce(t)?e.effects.push(...t):e.effects.push(t):hm(t)}const pe=Symbol.for("v-fgt"),ba=Symbol.for("v-txt"),kn=Symbol.for("v-cmt"),_a=Symbol.for("v-stc"),br=[];let Ht=null;function v(t=!1){br.push(Ht=t?null:[])}function iP(){br.pop(),Ht=br[br.length-1]||null}let _r=1;function ya(t,e=!1){_r+=t,t<0&&Ht&&e&&(Ht.hasOnce=!0)}function kc(t){return t.dynamicChildren=_r>0?Ht||To:null,iP(),_r>0&&Ht&&Ht.push(t),t}function C(t,e,n,o,r,a){return kc(m(t,e,n,o,r,a,!0))}function he(t,e,n,o,r){return kc(je(t,e,n,o,r,!0))}function yr(t){return t?t.__v_isVNode===!0:!1}function vr(t,e){return t.type===e.type&&t.key===e.key}const Ic=({key:t})=>t??null,va=({ref:t,ref_key:e,ref_for:n})=>(typeof t=="number"&&(t=""+t),t!=null?ut(t)||ht(t)||Me(t)?{i:_t,r:t,k:e,f:!!n}:t:null);function m(t,e=null,n=null,o=0,r=null,a=t===pe?0:1,i=!1,s=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Ic(e),ref:e&&va(e),scopeId:Vl,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:a,patchFlag:o,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:_t};return s?(Bi(l,n),a&128&&t.normalize(l)):n&&(l.shapeFlag|=ut(n)?8:16),_r>0&&!i&&Ht&&(l.patchFlag>0||a&6)&&l.patchFlag!==32&&Ht.push(l),l}const je=sP;function sP(t,e=null,n=null,o=0,r=null,a=!1){if((!t||t===ac)&&(t=kn),yr(t)){const s=jo(t,e,!0);return n&&Bi(s,n),_r>0&&!a&&Ht&&(s.shapeFlag&6?Ht[Ht.indexOf(t)]=s:Ht.push(s)),s.patchFlag=-2,s}if(PP(t)&&(t=t.__vccOpts),e){e=Qt(e);let{class:s,style:l}=e;s&&!ut(s)&&(e.class=St(s)),Je(l)&&(ur(l)&&!Ce(l)&&(l=bt({},l)),e.style=Z(l))}const i=ut(t)?1:Oc(t)?128:Pm(t)?64:Je(t)?4:Me(t)?2:0;return m(t,e,n,o,r,i,a,!0)}function Qt(t){return t?ur(t)||Dc(t)?bt({},t):t:null}function jo(t,e,n=!1,o=!1){const{props:r,ref:a,patchFlag:i,children:s,transition:l}=t,c=e?xe(r||{},e):r,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Ic(c),ref:e&&e.ref?n&&a?Ce(a)?a.concat(va(e)):[a,va(e)]:va(e):a,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:s,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==pe?i===-1?16:i|16:i,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&jo(t.ssContent),ssFallback:t.ssFallback&&jo(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&o&&wi(u,l.clone(u)),u}function lP(t=" ",e=0){return je(ba,null,t,e)}function Zn(t,e){const n=je(_a,null,t);return n.staticCount=e,n}function ae(t="",e=!1){return e?(v(),he(kn,null,t)):je(kn,null,t)}function bn(t){return t==null||typeof t=="boolean"?je(kn):Ce(t)?je(pe,null,t.slice()):yr(t)?In(t):je(ba,null,String(t))}function In(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:jo(t)}function Bi(t,e){let n=0;const{shapeFlag:o}=t;if(e==null)e=null;else if(Ce(e))n=16;else if(typeof e=="object")if(o&65){const r=e.default;r&&(r._c&&(r._d=!1),Bi(t,r()),r._c&&(r._d=!0));return}else{n=32;const r=e._;!r&&!Dc(e)?e._ctx=_t:r===3&&_t&&(_t.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Me(e)?(e={default:e,_ctx:_t},n=32):(e=String(e),o&64?(n=16,e=[lP(e)]):n=8);t.children=e,t.shapeFlag|=n}function xe(...t){const e={};for(let n=0;n<t.length;n++){const o=t[n];for(const r in o)if(r==="class")e.class!==o.class&&(e.class=St([e.class,o.class]));else if(r==="style")e.style=Z([e.style,o.style]);else if(Wr(r)){const a=e[r],i=o[r];i&&a!==i&&!(Ce(a)&&a.includes(i))?e[r]=a?[].concat(a,i):i:i==null&&a==null&&!Hr(r)&&(e[r]=i)}else r!==""&&(e[r]=o[r])}return e}function _n(t,e,n,o=null){mn(t,e,7,[n,o])}const cP=mc();let uP=0;function dP(t,e,n){const o=t.type,r=(e?e.appContext:t.appContext)||cP,a={uid:uP++,vnode:t,type:o,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Mf(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(r.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Ec(o,r),emitsOptions:Pc(o,r),emit:null,emitted:null,propsDefaults:ot,inheritAttrs:o.inheritAttrs,ctx:ot,data:ot,props:ot,attrs:ot,slots:ot,refs:ot,setupState:ot,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return a.ctx={_:a},a.root=e?e.root:a,a.emit=zm.bind(null,a),t.ce&&t.ce(a),a}let xt=null;const Gc=()=>xt||_t;let Da,zi;{const t=Qr(),e=(n,o)=>{let r;return(r=t[n])||(r=t[n]=[]),r.push(o),a=>{r.length>1?r.forEach(i=>i(a)):r[0](a)}};Da=e("__VUE_INSTANCE_SETTERS__",n=>xt=n),zi=e("__VUE_SSR_SETTERS__",n=>Sr=n)}const Dr=t=>{const e=xt;return Da(t),t.scope.on(),()=>{t.scope.off(),Da(e)}},Lc=()=>{xt&&xt.scope.off(),Da(null)};function $c(t){return t.vnode.shapeFlag&4}let Sr=!1;function pP(t,e=!1,n=!1){e&&zi(e);const{props:o,children:r}=t.vnode,a=$c(t);Km(t,o,a,e),Jm(t,r,n||e);const i=a?hP(t,e):void 0;return e&&zi(!1),i}function hP(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,Om);const{setup:o}=n;if(o){hn();const r=t.setupContext=o.length>1?Uc(t):null,a=Dr(t),i=Oo(o,t,0,[t.props,r]),s=dl(i);if(gn(),a(),(s||t.sp)&&!Go(t)&&Jl(t),s){if(i.then(Lc,Lc),e)return i.then(l=>{Nc(t,l)}).catch(l=>{sa(l,t,0)});t.asyncDep=i}else Nc(t,i)}else jc(t)}function Nc(t,e,n){Me(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:Je(e)&&(t.setupState=$l(e)),jc(t)}function jc(t,e,n){const o=t.type;t.render||(t.render=o.render||dn);{const r=Dr(t);hn();try{Im(t)}finally{gn(),r()}}}const gP={get(t,e){return Et(t,"get",""),t[e]}};function Uc(t){const e=n=>{t.exposed=n||{}};return{attrs:new Proxy(t.attrs,gP),slots:t.slots,emit:t.emit,expose:e}}function Sa(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy($l(dr(t.exposed)),{get(e,n){if(n in e)return e[n];if(n in Pr)return Pr[n](t)},has(e,n){return n in e||n in Pr}})):t.proxy}const fP=/(?:^|[-_])\w/g,mP=t=>t.replace(fP,e=>e.toUpperCase()).replace(/[-_]/g,"");function Bc(t,e=!0){return Me(t)?t.displayName||t.name:t.name||e&&t.__name}function zc(t,e,n=!1){let o=Bc(e);if(!o&&e.__file){const r=e.__file.match(/([^/\\]+)\.\w+$/);r&&(o=r[1])}if(!o&&t){const r=a=>{for(const i in a)if(a[i]===e)return i};o=r(t.components)||t.parent&&r(t.parent.type.components)||r(t.appContext.components)}return o?mP(o):n?"App":"Anonymous"}function PP(t){return Me(t)&&"__vccOpts"in t}const P=(t,e)=>rm(t,e,Sr);function FP(t,e,n){try{ya(-1);const o=arguments.length;return o===2?Je(e)&&!Ce(e)?yr(e)?je(t,null,[e]):je(t,e):je(t,null,e):(o>3?n=Array.prototype.slice.call(arguments,2):o===3&&yr(n)&&(n=[n]),je(t,e,n))}finally{ya(1)}}const bP="3.5.31";/**
15
+ `,...dm(r)),console.warn(...a)}gn(),Ci=!1}function um(){let t=pr[pr.length-1];if(!t)return[];const e=[];for(;t;){const n=e[0];n&&n.vnode===t?n.recurseCount++:e.push({vnode:t,recurseCount:0});const o=t.component&&t.component.parent;t=o&&o.vnode}return e}function dm(t){const e=[];return t.forEach((n,o)=>{e.push(...o===0?[]:[`
16
+ `],...pm(n))}),e}function pm({vnode:t,recurseCount:e}){const n=e>0?`... (${e} recursive calls)`:"",o=t.component?t.component.parent==null:!1,r=` at <${Wc(t.component,t.type,o)}`,a=">"+n;return t.props?[r,...hm(t.props),a]:[r+a]}function hm(t){const e=[],n=Object.keys(t);return n.slice(0,3).forEach(o=>{e.push(...Ul(o,t[o]))}),n.length>3&&e.push(" ..."),e}function Ul(t,e,n){return ut(e)?(e=JSON.stringify(e),n?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?n?e:[`${t}=${e}`]:ht(e)?(e=Ul(t,ke(e.value),!0),n?e:[`${t}=Ref<`,e,">"]):Me(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=ke(e),n?e:[`${t}=`,e])}function Oo(t,e,n,o){try{return o?t(...o):t()}catch(r){la(r,e,n)}}function mn(t,e,n,o){if(Me(t)){const r=Oo(t,e,n,o);return r&&pl(r)&&r.catch(a=>{la(a,e,n)}),r}if(Ce(t)){const r=[];for(let a=0;a<t.length;a++)r.push(mn(t[a],e,n,o));return r}}function la(t,e,n,o=!0){const r=e?e.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:i}=e&&e.appContext.config||ot;if(e){let s=e.parent;const l=e.proxy,c=`https://vuejs.org/error-reference/#runtime-${n}`;for(;s;){const u=s.ec;if(u){for(let d=0;d<u.length;d++)if(u[d](t,l,c)===!1)return}s=s.parent}if(a){hn(),Oo(a,null,10,[t,l,c]),gn();return}}gm(t,n,r,o,i)}function gm(t,e,n,o=!0,r=!1){if(r)throw t;console.error(t)}const Ot=[];let Pn=-1;const ko=[];let Kn=null,Io=0;const Bl=Promise.resolve();let ca=null;function ua(t){const e=ca||Bl;return t?e.then(this?t.bind(this):t):e}function fm(t){let e=Pn+1,n=Ot.length;for(;e<n;){const o=e+n>>>1,r=Ot[o],a=hr(r);a<t||a===t&&r.flags&2?e=o+1:n=o}return e}function Ti(t){if(!(t.flags&1)){const e=hr(t),n=Ot[Ot.length-1];!n||!(t.flags&2)&&e>=hr(n)?Ot.push(t):Ot.splice(fm(e),0,t),t.flags|=1,zl()}}function zl(){ca||(ca=Bl.then(Vl))}function mm(t){Ce(t)?ko.push(...t):Kn&&t.id===-1?Kn.splice(Io+1,0,t):t.flags&1||(ko.push(t),t.flags|=1),zl()}function Wl(t,e,n=Pn+1){for(;n<Ot.length;n++){const o=Ot[n];if(o&&o.flags&2){if(t&&o.id!==t.uid)continue;Ot.splice(n,1),n--,o.flags&4&&(o.flags&=-2),o(),o.flags&4||(o.flags&=-2)}}}function Hl(t){if(ko.length){const e=[...new Set(ko)].sort((n,o)=>hr(n)-hr(o));if(ko.length=0,Kn){Kn.push(...e);return}for(Kn=e,Io=0;Io<Kn.length;Io++){const n=Kn[Io];n.flags&4&&(n.flags&=-2),n.flags&8||n(),n.flags&=-2}Kn=null,Io=0}}const hr=t=>t.id==null?t.flags&2?-1:1/0:t.id;function Vl(t){try{for(Pn=0;Pn<Ot.length;Pn++){const e=Ot[Pn];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Oo(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Pn<Ot.length;Pn++){const e=Ot[Pn];e&&(e.flags&=-2)}Pn=-1,Ot.length=0,Hl(),ca=null,(Ot.length||ko.length)&&Vl()}}let yt=null,Yl=null;function da(t){const e=yt;return yt=t,Yl=t&&t.type.__scopeId||null,e}function We(t,e=yt,n){if(!e||t._n)return t;const o=(...r)=>{o._d&&va(-1);const a=da(e);let i;try{i=t(...r)}finally{da(a),o._d&&va(1)}return i};return o._n=!0,o._c=!0,o._d=!0,o}function fo(t,e){if(yt===null)return t;const n=Ea(yt),o=t.dirs||(t.dirs=[]);for(let r=0;r<e.length;r++){let[a,i,s,l=ot]=e[r];a&&(Me(a)&&(a={mounted:a,updated:a}),a.deep&&wn(i),o.push({dir:a,instance:n,value:i,oldValue:void 0,arg:s,modifiers:l}))}return t}function mo(t,e,n,o){const r=t.dirs,a=e&&e.dirs;for(let i=0;i<r.length;i++){const s=r[i];a&&(s.oldValue=a[i].value);let l=s.dir[o];l&&(hn(),mn(l,n,8,[t.el,s,t,e]),gn())}}function pa(t,e){if(xt){let n=xt.provides;const o=xt.parent&&xt.parent.provides;o===n&&(n=xt.provides=Object.create(o)),n[t]=e}}function Po(t,e,n=!1){const o=Lc();if(o||No){let r=No?No._context.provides:o?o.parent==null||o.ce?o.vnode.appContext&&o.vnode.appContext.provides:o.parent.provides:void 0;if(r&&t in r)return r[t];if(arguments.length>1)return n&&Me(e)?e.call(o&&o.proxy):e}}const Pm=Symbol.for("v-scx"),Fm=()=>Po(Pm);function Xn(t,e){return Mi(t,null,e)}function Se(t,e,n){return Mi(t,e,n)}function Mi(t,e,n=ot){const{immediate:o,deep:r,flush:a,once:i}=n,s=bt({},n),l=e&&o||!e&&a!=="post";let c;if(Sr){if(a==="sync"){const h=Fm();c=h.__watcherHandles||(h.__watcherHandles=[])}else if(!l){const h=()=>{};return h.stop=dn,h.resume=dn,h.pause=dn,h}}const u=xt;s.call=(h,g,f)=>mn(h,u,g,f);let d=!1;a==="post"?s.scheduler=h=>{At(h,u&&u.suspense)}:a!=="sync"&&(d=!0,s.scheduler=(h,g)=>{g?h():Ti(h)}),s.augmentJob=h=>{e&&(h.flags|=4),d&&(h.flags|=2,u&&(h.id=u.uid,h.i=u))};const p=cm(t,e,s);return Sr&&(c?c.push(p):l&&p()),p}function bm(t,e,n){const o=this.proxy,r=ut(t)?t.includes(".")?ql(o,t):()=>o[t]:t.bind(o,o);let a;Me(e)?a=e:(a=e.handler,n=e);const i=Dr(this),s=Mi(r,a.bind(o),n);return i(),s}function ql(t,e){const n=e.split(".");return()=>{let o=t;for(let r=0;r<n.length&&o;r++)o=o[n[r]];return o}}const Kl=Symbol("_vte"),ym=t=>t.__isTeleport,gr=t=>t&&(t.disabled||t.disabled===""),_m=t=>t&&(t.defer||t.defer===""),Xl=t=>typeof SVGElement<"u"&&t instanceof SVGElement,Zl=t=>typeof MathMLElement=="function"&&t instanceof MathMLElement,Ri=(t,e)=>{const n=t&&t.to;return ut(n)?e?e(n):null:n},Ql={name:"Teleport",__isTeleport:!0,process(t,e,n,o,r,a,i,s,l,c){const{mc:u,pc:d,pbc:p,o:{insert:h,querySelector:g,createText:f,createComment:F}}=c,y=gr(e.props);let{shapeFlag:_,children:E,dynamicChildren:A}=e;if(t==null){const T=e.el=f(""),q=e.anchor=f("");h(T,n,o),h(q,n,o);const w=(W,J)=>{_&16&&u(E,W,J,r,a,i,s,l)},G=()=>{const W=e.target=Ri(e.props,g),J=wi(W,e,f,h);W&&(i!=="svg"&&Xl(W)?i="svg":i!=="mathml"&&Zl(W)&&(i="mathml"),r&&r.isCE&&(r.ce._teleportTargets||(r.ce._teleportTargets=new Set)).add(W),y||(w(W,J),ga(e,!1)))};y&&(w(n,q),ga(e,!0)),_m(e.props)||a&&a.pendingBranch?(e.el.__isMounted=!1,At(()=>{e.el.__isMounted===!1&&(G(),delete e.el.__isMounted)},a)):G()}else{e.el=t.el,e.targetStart=t.targetStart;const T=e.anchor=t.anchor,q=e.target=t.target,w=e.targetAnchor=t.targetAnchor;if(t.el.__isMounted===!1){At(()=>{Ql.process(t,e,n,o,r,a,i,s,l,c)},a);return}const G=gr(t.props),W=G?n:q,J=G?T:w;if(i==="svg"||Xl(q)?i="svg":(i==="mathml"||Zl(q))&&(i="mathml"),A?(p(t.dynamicChildren,A,W,r,a,i,s),Bi(t,e,!0)):l||d(t,e,W,J,r,a,i,s,!1),y)G?e.props&&t.props&&e.props.to!==t.props.to&&(e.props.to=t.props.to):ha(e,n,T,c,1);else if((e.props&&e.props.to)!==(t.props&&t.props.to)){const ue=e.target=Ri(e.props,g);ue&&ha(e,ue,null,c,0)}else G&&ha(e,q,w,c,1);ga(e,y)}},remove(t,e,n,{um:o,o:{remove:r}},a){const{shapeFlag:i,children:s,anchor:l,targetStart:c,targetAnchor:u,target:d,props:p}=t;if(d&&(r(c),r(u)),a&&r(l),i&16){const h=a||!gr(p);for(let g=0;g<s.length;g++){const f=s[g];o(f,e,n,h,!!f.dynamicChildren)}}},move:ha,hydrate:vm};function ha(t,e,n,{o:{insert:o},m:r},a=2){a===0&&o(t.targetAnchor,e,n);const{el:i,anchor:s,shapeFlag:l,children:c,props:u}=t,d=a===2;if(d&&o(i,e,n),(!d||gr(u))&&l&16)for(let p=0;p<c.length;p++)r(c[p],e,n,2);d&&o(s,e,n)}function vm(t,e,n,o,r,a,{o:{nextSibling:i,parentNode:s,querySelector:l,insert:c,createText:u}},d){function p(F,y){let _=y;for(;_;){if(_&&_.nodeType===8){if(_.data==="teleport start anchor")e.targetStart=_;else if(_.data==="teleport anchor"){e.targetAnchor=_,F._lpa=e.targetAnchor&&i(e.targetAnchor);break}}_=i(_)}}function h(F,y){y.anchor=d(i(F),y,s(F),n,o,r,a)}const g=e.target=Ri(e.props,l),f=gr(e.props);if(g){const F=g._lpa||g.firstChild;e.shapeFlag&16&&(f?(h(t,e),p(g,F),e.targetAnchor||wi(g,e,u,c,s(t)===g?t:null)):(e.anchor=i(t),p(g,F),e.targetAnchor||wi(g,e,u,c),d(F&&i(F),e,g,n,o,r,a))),ga(e,f)}else f&&e.shapeFlag&16&&(h(t,e),e.targetStart=t,e.targetAnchor=i(t));return e.anchor&&i(e.anchor)}const Jl=Ql;function ga(t,e){const n=t.ctx;if(n&&n.ut){let o,r;for(e?(o=t.el,r=t.anchor):(o=t.targetStart,r=t.targetAnchor);o&&o!==r;)o.nodeType===1&&o.setAttribute("data-v-owner",n.uid),o=o.nextSibling;n.ut()}}function wi(t,e,n,o,r=null){const a=e.targetStart=n(""),i=e.targetAnchor=n("");return a[Kl]=i,t&&(o(a,t,r),o(i,t,r)),i}const Dm=Symbol("_leaveCb");function Oi(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Oi(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function ie(t,e){return Me(t)?bt({name:t.name},e,{setup:t}):t}function ec(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function tc(t,e){let n;return!!((n=Object.getOwnPropertyDescriptor(t,e))&&!n.configurable)}const fa=new WeakMap;function fr(t,e,n,o,r=!1){if(Ce(t)){t.forEach((f,F)=>fr(f,e&&(Ce(e)?e[F]:e),n,o,r));return}if(Go(o)&&!r){o.shapeFlag&512&&o.type.__asyncResolved&&o.component.subTree.component&&fr(t,e,n,o.component.subTree);return}const a=o.shapeFlag&4?Ea(o.component):o.el,i=r?null:a,{i:s,r:l}=t,c=e&&e.r,u=s.refs===ot?s.refs={}:s.refs,d=s.setupState,p=ke(d),h=d===ot?ul:f=>tc(u,f)?!1:Qe(p,f),g=(f,F)=>!(F&&tc(u,F));if(c!=null&&c!==l){if(nc(e),ut(c))u[c]=null,h(c)&&(d[c]=null);else if(ht(c)){const f=e;g(c,f.k)&&(c.value=null),f.k&&(u[f.k]=null)}}if(Me(l))Oo(l,s,12,[i,u]);else{const f=ut(l),F=ht(l);if(f||F){const y=()=>{if(t.f){const _=f?h(l)?d[l]:u[l]:g()||!t.k?l.value:u[t.k];if(r)Ce(_)&&hi(_,a);else if(Ce(_))_.includes(a)||_.push(a);else if(f)u[l]=[a],h(l)&&(d[l]=u[l]);else{const E=[a];g(l,t.k)&&(l.value=E),t.k&&(u[t.k]=E)}}else f?(u[l]=i,h(l)&&(d[l]=i)):F&&(g(l,t.k)&&(l.value=i),t.k&&(u[t.k]=i))};if(i){const _=()=>{y(),fa.delete(t)};_.id=-1,fa.set(t,_),At(_,n)}else nc(t),y()}}}function nc(t){const e=fa.get(t);e&&(e.flags|=8,fa.delete(t))}Jr().requestIdleCallback,Jr().cancelIdleCallback;const Go=t=>!!t.type.__asyncLoader,oc=t=>t.type.__isKeepAlive;function Sm(t,e){rc(t,"a",e)}function Em(t,e){rc(t,"da",e)}function rc(t,e,n=xt){const o=t.__wdc||(t.__wdc=()=>{let r=n;for(;r;){if(r.isDeactivated)return;r=r.parent}return t()});if(ma(e,o,n),n){let r=n.parent;for(;r&&r.parent;)oc(r.parent.vnode)&&Am(o,e,n,r),r=r.parent}}function Am(t,e,n,o){const r=ma(e,t,o,!0);$o(()=>{hi(o[e],r)},n)}function ma(t,e,n=xt,o=!1){if(n){const r=n[t]||(n[t]=[]),a=e.__weh||(e.__weh=(...i)=>{hn();const s=Dr(n),l=mn(e,n,t,i);return s(),gn(),l});return o?r.unshift(a):r.push(a),a}}const On=t=>(e,n=xt)=>{(!Sr||t==="sp")&&ma(t,(...o)=>e(...o),n)},xm=On("bm"),Lo=On("m"),Cm=On("bu"),Tm=On("u"),mr=On("bum"),$o=On("um"),Mm=On("sp"),Rm=On("rtg"),wm=On("rtc");function Om(t,e=xt){ma("ec",t,e)}const ac="components";function km(t,e){return sc(ac,t,!0,e)||t}const ic=Symbol.for("v-ndc");function Fn(t){return ut(t)?sc(ac,t,!1)||t:t||ic}function sc(t,e,n=!0,o=!1){const r=yt||xt;if(r){const a=r.type;{const s=zc(a,!1);if(s&&(s===e||s===wt(e)||s===Xr(wt(e))))return a}const i=lc(r[t]||a[t],e)||lc(r.appContext[t],e);return!i&&o?a:i}}function lc(t,e){return t&&(t[e]||t[wt(e)]||t[Xr(wt(e))])}function tt(t,e,n,o){let r;const a=n,i=Ce(t);if(i||ut(t)){const s=i&&qn(t);let l=!1,c=!1;s&&(l=!Wt(t),c=Rn(t),t=ta(t)),r=new Array(t.length);for(let u=0,d=t.length;u<d;u++)r[u]=e(l?c?wo(sn(t[u])):sn(t[u]):t[u],u,void 0,a)}else if(typeof t=="number"){r=new Array(t);for(let s=0;s<t;s++)r[s]=e(s+1,s,void 0,a)}else if(Je(t))if(t[Symbol.iterator])r=Array.from(t,(s,l)=>e(s,l,void 0,a));else{const s=Object.keys(t);r=new Array(s.length);for(let l=0,c=s.length;l<c;l++){const u=s[l];r[l]=e(t[u],u,l,a)}}else r=[];return r}function Im(t,e){for(let n=0;n<e.length;n++){const o=e[n];if(Ce(o))for(let r=0;r<o.length;r++)t[o[r].name]=o[r].fn;else o&&(t[o.name]=o.key?(...r)=>{const a=o.fn(...r);return a&&(a.key=o.key),a}:o.fn)}return t}function $e(t,e,n={},o,r){if(yt.ce||yt.parent&&Go(yt.parent)&&yt.parent.ce){const c=Object.keys(n).length>0;return e!=="default"&&(n.name=e),v(),he(pe,null,[je("slot",n,o&&o())],c?-2:64)}let a=t[e];a&&a._c&&(a._d=!1),v();const i=a&&cc(a(n)),s=n.key||i&&i.key,l=he(pe,{key:(s&&!Bt(s)?s:`_${e}`)+(!i&&o?"_fb":"")},i||(o?o():[]),i&&t._===1?64:-2);return l.scopeId&&(l.slotScopeIds=[l.scopeId+"-s"]),a&&a._c&&(a._d=!0),l}function cc(t){return t.some(e=>_r(e)?!(e.type===kn||e.type===pe&&!cc(e.children)):!0)?t:null}const ki=t=>t?Nc(t)?Ea(t):ki(t.parent):null,Pr=bt(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>ki(t.parent),$root:t=>ki(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>gc(t),$forceUpdate:t=>t.f||(t.f=()=>{Ti(t.update)}),$nextTick:t=>t.n||(t.n=ua.bind(t.proxy)),$watch:t=>bm.bind(t)}),Ii=(t,e)=>t!==ot&&!t.__isScriptSetup&&Qe(t,e),Gm={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:n,setupState:o,data:r,props:a,accessCache:i,type:s,appContext:l}=t;if(e[0]!=="$"){const p=i[e];if(p!==void 0)switch(p){case 1:return o[e];case 2:return r[e];case 4:return n[e];case 3:return a[e]}else{if(Ii(o,e))return i[e]=1,o[e];if(r!==ot&&Qe(r,e))return i[e]=2,r[e];if(Qe(a,e))return i[e]=3,a[e];if(n!==ot&&Qe(n,e))return i[e]=4,n[e];Gi&&(i[e]=0)}}const c=Pr[e];let u,d;if(c)return e==="$attrs"&&Et(t.attrs,"get",""),c(t);if((u=s.__cssModules)&&(u=u[e]))return u;if(n!==ot&&Qe(n,e))return i[e]=4,n[e];if(d=l.config.globalProperties,Qe(d,e))return d[e]},set({_:t},e,n){const{data:o,setupState:r,ctx:a}=t;return Ii(r,e)?(r[e]=n,!0):o!==ot&&Qe(o,e)?(o[e]=n,!0):Qe(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(a[e]=n,!0)},has({_:{data:t,setupState:e,accessCache:n,ctx:o,appContext:r,props:a,type:i}},s){let l;return!!(n[s]||t!==ot&&s[0]!=="$"&&Qe(t,s)||Ii(e,s)||Qe(a,s)||Qe(o,s)||Qe(Pr,s)||Qe(r.config.globalProperties,s)||(l=i.__cssModules)&&l[s])},defineProperty(t,e,n){return n.get!=null?t._.accessCache[e]=0:Qe(n,"value")&&this.set(t,e,n.value,null),Reflect.defineProperty(t,e,n)}};function Pa(){return uc().slots}function Lm(){return uc().attrs}function uc(t){const e=Lc();return e.setupContext||(e.setupContext=Bc(e))}function dc(t){return Ce(t)?t.reduce((e,n)=>(e[n]=null,e),{}):t}let Gi=!0;function $m(t){const e=gc(t),n=t.proxy,o=t.ctx;Gi=!1,e.beforeCreate&&pc(e.beforeCreate,t,"bc");const{data:r,computed:a,methods:i,watch:s,provide:l,inject:c,created:u,beforeMount:d,mounted:p,beforeUpdate:h,updated:g,activated:f,deactivated:F,beforeDestroy:y,beforeUnmount:_,destroyed:E,unmounted:A,render:T,renderTracked:q,renderTriggered:w,errorCaptured:G,serverPrefetch:W,expose:J,inheritAttrs:ue,components:ce,directives:ee,filters:ge}=e;if(c&&Nm(c,o,null),i)for(const Te in i){const oe=i[Te];Me(oe)&&(o[Te]=oe.bind(n))}if(r){const Te=r.call(n,n);Je(Te)&&(t.data=Ai(Te))}if(Gi=!0,a)for(const Te in a){const oe=a[Te],He=Me(oe)?oe.bind(n,n):Me(oe.get)?oe.get.bind(n,n):dn,ft=!Me(oe)&&Me(oe.set)?oe.set.bind(n):dn,Ve=P({get:He,set:ft});Object.defineProperty(o,Te,{enumerable:!0,configurable:!0,get:()=>Ve.value,set:O=>Ve.value=O})}if(s)for(const Te in s)hc(s[Te],o,n,Te);if(l){const Te=Me(l)?l.call(n):l;Reflect.ownKeys(Te).forEach(oe=>{pa(oe,Te[oe])})}u&&pc(u,t,"c");function Ee(Te,oe){Ce(oe)?oe.forEach(He=>Te(He.bind(n))):oe&&Te(oe.bind(n))}if(Ee(xm,d),Ee(Lo,p),Ee(Cm,h),Ee(Tm,g),Ee(Sm,f),Ee(Em,F),Ee(Om,G),Ee(wm,q),Ee(Rm,w),Ee(mr,_),Ee($o,A),Ee(Mm,W),Ce(J))if(J.length){const Te=t.exposed||(t.exposed={});J.forEach(oe=>{Object.defineProperty(Te,oe,{get:()=>n[oe],set:He=>n[oe]=He,enumerable:!0})})}else t.exposed||(t.exposed={});T&&t.render===dn&&(t.render=T),ue!=null&&(t.inheritAttrs=ue),ce&&(t.components=ce),ee&&(t.directives=ee),W&&ec(t)}function Nm(t,e,n=dn){Ce(t)&&(t=Li(t));for(const o in t){const r=t[o];let a;Je(r)?"default"in r?a=Po(r.from||o,r.default,!0):a=Po(r.from||o):a=Po(r),ht(a)?Object.defineProperty(e,o,{enumerable:!0,configurable:!0,get:()=>a.value,set:i=>a.value=i}):e[o]=a}}function pc(t,e,n){mn(Ce(t)?t.map(o=>o.bind(e.proxy)):t.bind(e.proxy),e,n)}function hc(t,e,n,o){let r=o.includes(".")?ql(n,o):()=>n[o];if(ut(t)){const a=e[t];Me(a)&&Se(r,a)}else if(Me(t))Se(r,t.bind(n));else if(Je(t))if(Ce(t))t.forEach(a=>hc(a,e,n,o));else{const a=Me(t.handler)?t.handler.bind(n):e[t.handler];Me(a)&&Se(r,a,t)}}function gc(t){const e=t.type,{mixins:n,extends:o}=e,{mixins:r,optionsCache:a,config:{optionMergeStrategies:i}}=t.appContext,s=a.get(e);let l;return s?l=s:!r.length&&!n&&!o?l=e:(l={},r.length&&r.forEach(c=>Fa(l,c,i,!0)),Fa(l,e,i)),Je(e)&&a.set(e,l),l}function Fa(t,e,n,o=!1){const{mixins:r,extends:a}=e;a&&Fa(t,a,n,!0),r&&r.forEach(i=>Fa(t,i,n,!0));for(const i in e)if(!(o&&i==="expose")){const s=jm[i]||n&&n[i];t[i]=s?s(t[i],e[i]):e[i]}return t}const jm={data:fc,props:mc,emits:mc,methods:Fr,computed:Fr,beforeCreate:kt,created:kt,beforeMount:kt,mounted:kt,beforeUpdate:kt,updated:kt,beforeDestroy:kt,beforeUnmount:kt,destroyed:kt,unmounted:kt,activated:kt,deactivated:kt,errorCaptured:kt,serverPrefetch:kt,components:Fr,directives:Fr,watch:Bm,provide:fc,inject:Um};function fc(t,e){return e?t?function(){return bt(Me(t)?t.call(this,this):t,Me(e)?e.call(this,this):e)}:e:t}function Um(t,e){return Fr(Li(t),Li(e))}function Li(t){if(Ce(t)){const e={};for(let n=0;n<t.length;n++)e[t[n]]=t[n];return e}return t}function kt(t,e){return t?[...new Set([].concat(t,e))]:e}function Fr(t,e){return t?bt(Object.create(null),t,e):e}function mc(t,e){return t?Ce(t)&&Ce(e)?[...new Set([...t,...e])]:bt(Object.create(null),dc(t),dc(e??{})):e}function Bm(t,e){if(!t)return e;if(!e)return t;const n=bt(Object.create(null),t);for(const o in e)n[o]=kt(t[o],e[o]);return n}function Pc(){return{app:null,config:{isNativeTag:ul,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let zm=0;function Wm(t,e){return function(o,r=null){Me(o)||(o=bt({},o)),r!=null&&!Je(r)&&(r=null);const a=Pc(),i=new WeakSet,s=[];let l=!1;const c=a.app={_uid:zm++,_component:o,_props:r,_container:null,_context:a,_instance:null,version:vP,get config(){return a.config},set config(u){},use(u,...d){return i.has(u)||(u&&Me(u.install)?(i.add(u),u.install(c,...d)):Me(u)&&(i.add(u),u(c,...d))),c},mixin(u){return a.mixins.includes(u)||a.mixins.push(u),c},component(u,d){return d?(a.components[u]=d,c):a.components[u]},directive(u,d){return d?(a.directives[u]=d,c):a.directives[u]},mount(u,d,p){if(!l){const h=c._ceVNode||je(o,r);return h.appContext=a,p===!0?p="svg":p===!1&&(p=void 0),t(h,u,p),l=!0,c._container=u,u.__vue_app__=c,Ea(h.component)}},onUnmount(u){s.push(u)},unmount(){l&&(mn(s,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,d){return a.provides[u]=d,c},runWithContext(u){const d=No;No=c;try{return u()}finally{No=d}}};return c}}let No=null;const Hm=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${wt(e)}Modifiers`]||t[`${Yn(e)}Modifiers`];function Vm(t,e,...n){if(t.isUnmounted)return;const o=t.vnode.props||ot;let r=n;const a=e.startsWith("update:"),i=a&&Hm(o,e.slice(7));i&&(i.trim&&(r=n.map(u=>ut(u)?u.trim():u)),i.number&&(r=n.map(Qr)));let s,l=o[s=gi(e)]||o[s=gi(wt(e))];!l&&a&&(l=o[s=gi(Yn(e))]),l&&mn(l,t,6,r);const c=o[s+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[s])return;t.emitted[s]=!0,mn(c,t,6,r)}}const Ym=new WeakMap;function Fc(t,e,n=!1){const o=n?Ym:e.emitsCache,r=o.get(t);if(r!==void 0)return r;const a=t.emits;let i={},s=!1;if(!Me(t)){const l=c=>{const u=Fc(c,e,!0);u&&(s=!0,bt(i,u))};!n&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!a&&!s?(Je(t)&&o.set(t,null),null):(Ce(a)?a.forEach(l=>i[l]=null):bt(i,a),Je(t)&&o.set(t,i),i)}function ba(t,e){return!t||!Hr(e)?!1:(e=e.slice(2).replace(/Once$/,""),Qe(t,e[0].toLowerCase()+e.slice(1))||Qe(t,Yn(e))||Qe(t,e))}function vT(){}function bc(t){const{type:e,vnode:n,proxy:o,withProxy:r,propsOptions:[a],slots:i,attrs:s,emit:l,render:c,renderCache:u,props:d,data:p,setupState:h,ctx:g,inheritAttrs:f}=t,F=da(t);let y,_;try{if(n.shapeFlag&4){const A=r||o,T=A;y=bn(c.call(T,A,u,d,h,p,g)),_=s}else{const A=e;y=bn(A.length>1?A(d,{attrs:s,slots:i,emit:l}):A(d,null)),_=e.props?s:qm(s)}}catch(A){br.length=0,la(A,t,1),y=je(kn)}let E=y;if(_&&f!==!1){const A=Object.keys(_),{shapeFlag:T}=E;A.length&&T&7&&(a&&A.some(Vr)&&(_=Km(_,a)),E=jo(E,_,!1,!0))}return n.dirs&&(E=jo(E,null,!1,!0),E.dirs=E.dirs?E.dirs.concat(n.dirs):n.dirs),n.transition&&Oi(E,n.transition),y=E,da(F),y}const qm=t=>{let e;for(const n in t)(n==="class"||n==="style"||Hr(n))&&((e||(e={}))[n]=t[n]);return e},Km=(t,e)=>{const n={};for(const o in t)(!Vr(o)||!(o.slice(9)in e))&&(n[o]=t[o]);return n};function Xm(t,e,n){const{props:o,children:r,component:a}=t,{props:i,children:s,patchFlag:l}=e,c=a.emitsOptions;if(e.dirs||e.transition)return!0;if(n&&l>=0){if(l&1024)return!0;if(l&16)return o?yc(o,i,c):!!i;if(l&8){const u=e.dynamicProps;for(let d=0;d<u.length;d++){const p=u[d];if(_c(i,o,p)&&!ba(c,p))return!0}}}else return(r||s)&&(!s||!s.$stable)?!0:o===i?!1:o?i?yc(o,i,c):!0:!!i;return!1}function yc(t,e,n){const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!0;for(let r=0;r<o.length;r++){const a=o[r];if(_c(e,t,a)&&!ba(n,a))return!0}return!1}function _c(t,e,n){const o=t[n],r=e[n];return n==="style"&&Je(o)&&Je(r)?!rr(o,r):o!==r}function Zm({vnode:t,parent:e,suspense:n},o){for(;e;){const r=e.subTree;if(r.suspense&&r.suspense.activeBranch===t&&(r.suspense.vnode.el=r.el=o,t=r),r===t)(t=e.vnode).el=o,e=e.parent;else break}n&&n.activeBranch===t&&(n.vnode.el=o)}const vc={},Dc=()=>Object.create(vc),Sc=t=>Object.getPrototypeOf(t)===vc;function Qm(t,e,n,o=!1){const r={},a=Dc();t.propsDefaults=Object.create(null),Ec(t,e,r,a);for(const i in t.propsOptions[0])i in r||(r[i]=void 0);n?t.props=o?r:em(r):t.type.props?t.props=r:t.props=a,t.attrs=a}function Jm(t,e,n,o){const{props:r,attrs:a,vnode:{patchFlag:i}}=t,s=ke(r),[l]=t.propsOptions;let c=!1;if((o||i>0)&&!(i&16)){if(i&8){const u=t.vnode.dynamicProps;for(let d=0;d<u.length;d++){let p=u[d];if(ba(t.emitsOptions,p))continue;const h=e[p];if(l)if(Qe(a,p))h!==a[p]&&(a[p]=h,c=!0);else{const g=wt(p);r[g]=$i(l,s,g,h,t,!1)}else h!==a[p]&&(a[p]=h,c=!0)}}}else{Ec(t,e,r,a)&&(c=!0);let u;for(const d in s)(!e||!Qe(e,d)&&((u=Yn(d))===d||!Qe(e,u)))&&(l?n&&(n[d]!==void 0||n[u]!==void 0)&&(r[d]=$i(l,s,d,void 0,t,!0)):delete r[d]);if(a!==s)for(const d in a)(!e||!Qe(e,d))&&(delete a[d],c=!0)}c&&Tn(t.attrs,"set","")}function Ec(t,e,n,o){const[r,a]=t.propsOptions;let i=!1,s;if(e)for(let l in e){if(or(l))continue;const c=e[l];let u;r&&Qe(r,u=wt(l))?!a||!a.includes(u)?n[u]=c:(s||(s={}))[u]=c:ba(t.emitsOptions,l)||(!(l in o)||c!==o[l])&&(o[l]=c,i=!0)}if(a){const l=ke(n),c=s||ot;for(let u=0;u<a.length;u++){const d=a[u];n[d]=$i(r,l,d,c[d],t,!Qe(c,d))}}return i}function $i(t,e,n,o,r,a){const i=t[n];if(i!=null){const s=Qe(i,"default");if(s&&o===void 0){const l=i.default;if(i.type!==Function&&!i.skipFactory&&Me(l)){const{propsDefaults:c}=r;if(n in c)o=c[n];else{const u=Dr(r);o=c[n]=l.call(null,e),u()}}else o=l;r.ce&&r.ce._setProp(n,o)}i[0]&&(a&&!s?o=!1:i[1]&&(o===""||o===Yn(n))&&(o=!0))}return o}const eP=new WeakMap;function Ac(t,e,n=!1){const o=n?eP:e.propsCache,r=o.get(t);if(r)return r;const a=t.props,i={},s=[];let l=!1;if(!Me(t)){const u=d=>{l=!0;const[p,h]=Ac(d,e,!0);bt(i,p),h&&s.push(...h)};!n&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!a&&!l)return Je(t)&&o.set(t,To),To;if(Ce(a))for(let u=0;u<a.length;u++){const d=wt(a[u]);xc(d)&&(i[d]=ot)}else if(a)for(const u in a){const d=wt(u);if(xc(d)){const p=a[u],h=i[d]=Ce(p)||Me(p)?{type:p}:bt({},p),g=h.type;let f=!1,F=!0;if(Ce(g))for(let y=0;y<g.length;++y){const _=g[y],E=Me(_)&&_.name;if(E==="Boolean"){f=!0;break}else E==="String"&&(F=!1)}else f=Me(g)&&g.name==="Boolean";h[0]=f,h[1]=F,(f||Qe(h,"default"))&&s.push(d)}}const c=[i,s];return Je(t)&&o.set(t,c),c}function xc(t){return t[0]!=="$"&&!or(t)}const Ni=t=>t==="_"||t==="_ctx"||t==="$stable",ji=t=>Ce(t)?t.map(bn):[bn(t)],tP=(t,e,n)=>{if(e._n)return e;const o=We((...r)=>ji(e(...r)),n);return o._c=!1,o},Cc=(t,e,n)=>{const o=t._ctx;for(const r in t){if(Ni(r))continue;const a=t[r];if(Me(a))e[r]=tP(r,a,o);else if(a!=null){const i=ji(a);e[r]=()=>i}}},Tc=(t,e)=>{const n=ji(e);t.slots.default=()=>n},Mc=(t,e,n)=>{for(const o in e)(n||!Ni(o))&&(t[o]=e[o])},nP=(t,e,n)=>{const o=t.slots=Dc();if(t.vnode.shapeFlag&32){const r=e._;r?(Mc(o,e,n),n&&fl(o,"_",r,!0)):Cc(e,o)}else e&&Tc(t,e)},oP=(t,e,n)=>{const{vnode:o,slots:r}=t;let a=!0,i=ot;if(o.shapeFlag&32){const s=e._;s?n&&s===1?a=!1:Mc(r,e,n):(a=!e.$stable,Cc(e,r)),i=e}else e&&(Tc(t,e),i={default:1});if(a)for(const s in r)!Ni(s)&&i[s]==null&&delete r[s]},At=lP;function rP(t){return aP(t)}function aP(t,e){const n=Jr();n.__VUE__=!0;const{insert:o,remove:r,patchProp:a,createElement:i,createText:s,createComment:l,setText:c,setElementText:u,parentNode:d,nextSibling:p,setScopeId:h=dn,insertStaticContent:g}=t,f=(D,S,R,N=null,$=null,j=null,ne=void 0,K=null,Y=!!S.dynamicChildren)=>{if(D===S)return;D&&!vr(D,S)&&(N=de(D),O(D,$,j,!0),D=null),S.patchFlag===-2&&(Y=!1,S.dynamicChildren=null);const{type:B,ref:be,shapeFlag:re}=S;switch(B){case ya:F(D,S,R,N);break;case kn:y(D,S,R,N);break;case _a:D==null&&_(S,R,N,ne);break;case pe:ce(D,S,R,N,$,j,ne,K,Y);break;default:re&1?T(D,S,R,N,$,j,ne,K,Y):re&6?ee(D,S,R,N,$,j,ne,K,Y):(re&64||re&128)&&B.process(D,S,R,N,$,j,ne,K,Y,vt)}be!=null&&$?fr(be,D&&D.ref,j,S||D,!S):be==null&&D&&D.ref!=null&&fr(D.ref,null,j,D,!0)},F=(D,S,R,N)=>{if(D==null)o(S.el=s(S.children),R,N);else{const $=S.el=D.el;S.children!==D.children&&c($,S.children)}},y=(D,S,R,N)=>{D==null?o(S.el=l(S.children||""),R,N):S.el=D.el},_=(D,S,R,N)=>{[D.el,D.anchor]=g(D.children,S,R,N,D.el,D.anchor)},E=({el:D,anchor:S},R,N)=>{let $;for(;D&&D!==S;)$=p(D),o(D,R,N),D=$;o(S,R,N)},A=({el:D,anchor:S})=>{let R;for(;D&&D!==S;)R=p(D),r(D),D=R;r(S)},T=(D,S,R,N,$,j,ne,K,Y)=>{if(S.type==="svg"?ne="svg":S.type==="math"&&(ne="mathml"),D==null)q(S,R,N,$,j,ne,K,Y);else{const B=D.el&&D.el._isVueCE?D.el:null;try{B&&B._beginPatch(),W(D,S,$,j,ne,K,Y)}finally{B&&B._endPatch()}}},q=(D,S,R,N,$,j,ne,K)=>{let Y,B;const{props:be,shapeFlag:re,transition:Fe,dirs:De}=D;if(Y=D.el=i(D.type,j,be&&be.is,be),re&8?u(Y,D.children):re&16&&G(D.children,Y,null,N,$,Ui(D,j),ne,K),De&&mo(D,null,N,"created"),w(Y,D,D.scopeId,ne,N),be){for(const Ge in be)Ge!=="value"&&!or(Ge)&&a(Y,Ge,null,be[Ge],j,N);"value"in be&&a(Y,"value",null,be.value,j),(B=be.onVnodeBeforeMount)&&yn(B,N,D)}De&&mo(D,null,N,"beforeMount");const we=iP($,Fe);we&&Fe.beforeEnter(Y),o(Y,S,R),((B=be&&be.onVnodeMounted)||we||De)&&At(()=>{try{B&&yn(B,N,D),we&&Fe.enter(Y),De&&mo(D,null,N,"mounted")}finally{}},$)},w=(D,S,R,N,$)=>{if(R&&h(D,R),N)for(let j=0;j<N.length;j++)h(D,N[j]);if($){let j=$.subTree;if(S===j||kc(j.type)&&(j.ssContent===S||j.ssFallback===S)){const ne=$.vnode;w(D,ne,ne.scopeId,ne.slotScopeIds,$.parent)}}},G=(D,S,R,N,$,j,ne,K,Y=0)=>{for(let B=Y;B<D.length;B++){const be=D[B]=K?In(D[B]):bn(D[B]);f(null,be,S,R,N,$,j,ne,K)}},W=(D,S,R,N,$,j,ne)=>{const K=S.el=D.el;let{patchFlag:Y,dynamicChildren:B,dirs:be}=S;Y|=D.patchFlag&16;const re=D.props||ot,Fe=S.props||ot;let De;if(R&&Fo(R,!1),(De=Fe.onVnodeBeforeUpdate)&&yn(De,R,S,D),be&&mo(S,D,R,"beforeUpdate"),R&&Fo(R,!0),(re.innerHTML&&Fe.innerHTML==null||re.textContent&&Fe.textContent==null)&&u(K,""),B?J(D.dynamicChildren,B,K,R,N,Ui(S,$),j):ne||oe(D,S,K,null,R,N,Ui(S,$),j,!1),Y>0){if(Y&16)ue(K,re,Fe,R,$);else if(Y&2&&re.class!==Fe.class&&a(K,"class",null,Fe.class,$),Y&4&&a(K,"style",re.style,Fe.style,$),Y&8){const we=S.dynamicProps;for(let Ge=0;Ge<we.length;Ge++){const Oe=we[Ge],k=re[Oe],_e=Fe[Oe];(_e!==k||Oe==="value")&&a(K,Oe,k,_e,$,R)}}Y&1&&D.children!==S.children&&u(K,S.children)}else!ne&&B==null&&ue(K,re,Fe,R,$);((De=Fe.onVnodeUpdated)||be)&&At(()=>{De&&yn(De,R,S,D),be&&mo(S,D,R,"updated")},N)},J=(D,S,R,N,$,j,ne)=>{for(let K=0;K<S.length;K++){const Y=D[K],B=S[K],be=Y.el&&(Y.type===pe||!vr(Y,B)||Y.shapeFlag&198)?d(Y.el):R;f(Y,B,be,null,N,$,j,ne,!0)}},ue=(D,S,R,N,$)=>{if(S!==R){if(S!==ot)for(const j in S)!or(j)&&!(j in R)&&a(D,j,S[j],null,$,N);for(const j in R){if(or(j))continue;const ne=R[j],K=S[j];ne!==K&&j!=="value"&&a(D,j,K,ne,$,N)}"value"in R&&a(D,"value",S.value,R.value,$)}},ce=(D,S,R,N,$,j,ne,K,Y)=>{const B=S.el=D?D.el:s(""),be=S.anchor=D?D.anchor:s("");let{patchFlag:re,dynamicChildren:Fe,slotScopeIds:De}=S;De&&(K=K?K.concat(De):De),D==null?(o(B,R,N),o(be,R,N),G(S.children||[],R,be,$,j,ne,K,Y)):re>0&&re&64&&Fe&&D.dynamicChildren&&D.dynamicChildren.length===Fe.length?(J(D.dynamicChildren,Fe,R,$,j,ne,K),(S.key!=null||$&&S===$.subTree)&&Bi(D,S,!0)):oe(D,S,R,be,$,j,ne,K,Y)},ee=(D,S,R,N,$,j,ne,K,Y)=>{S.slotScopeIds=K,D==null?S.shapeFlag&512?$.ctx.activate(S,R,N,ne,Y):ge(S,R,N,$,j,ne,Y):ye(D,S,Y)},ge=(D,S,R,N,$,j,ne)=>{const K=D.component=gP(D,N,$);if(oc(D)&&(K.ctx.renderer=vt),fP(K,!1,ne),K.asyncDep){if($&&$.registerDep(K,Ee,ne),!D.el){const Y=K.subTree=je(kn);y(null,Y,S,R),D.placeholder=Y.el}}else Ee(K,D,S,R,$,j,ne)},ye=(D,S,R)=>{const N=S.component=D.component;if(Xm(D,S,R))if(N.asyncDep&&!N.asyncResolved){Te(N,S,R);return}else N.next=S,N.update();else S.el=D.el,N.vnode=S},Ee=(D,S,R,N,$,j,ne)=>{const K=()=>{if(D.isMounted){let{next:re,bu:Fe,u:De,parent:we,vnode:Ge}=D;{const Ke=Rc(D);if(Ke){re&&(re.el=Ge.el,Te(D,re,ne)),Ke.asyncDep.then(()=>{At(()=>{D.isUnmounted||B()},$)});return}}let Oe=re,k;Fo(D,!1),re?(re.el=Ge.el,Te(D,re,ne)):re=Ge,Fe&&Zr(Fe),(k=re.props&&re.props.onVnodeBeforeUpdate)&&yn(k,we,re,Ge),Fo(D,!0);const _e=bc(D),Le=D.subTree;D.subTree=_e,f(Le,_e,d(Le.el),de(Le),D,$,j),re.el=_e.el,Oe===null&&Zm(D,_e.el),De&&At(De,$),(k=re.props&&re.props.onVnodeUpdated)&&At(()=>yn(k,we,re,Ge),$)}else{let re;const{el:Fe,props:De}=S,{bm:we,m:Ge,parent:Oe,root:k,type:_e}=D,Le=Go(S);Fo(D,!1),we&&Zr(we),!Le&&(re=De&&De.onVnodeBeforeMount)&&yn(re,Oe,S),Fo(D,!0);{k.ce&&k.ce._hasShadowRoot()&&k.ce._injectChildStyle(_e,D.parent?D.parent.type:void 0);const Ke=D.subTree=bc(D);f(null,Ke,R,N,D,$,j),S.el=Ke.el}if(Ge&&At(Ge,$),!Le&&(re=De&&De.onVnodeMounted)){const Ke=S;At(()=>yn(re,Oe,Ke),$)}(S.shapeFlag&256||Oe&&Go(Oe.vnode)&&Oe.vnode.shapeFlag&256)&&D.a&&At(D.a,$),D.isMounted=!0,S=R=N=null}};D.scope.on();const Y=D.effect=new yl(K);D.scope.off();const B=D.update=Y.run.bind(Y),be=D.job=Y.runIfDirty.bind(Y);be.i=D,be.id=D.uid,Y.scheduler=()=>Ti(be),Fo(D,!0),B()},Te=(D,S,R)=>{S.component=D;const N=D.vnode.props;D.vnode=S,D.next=null,Jm(D,S.props,N,R),oP(D,S.children,R),hn(),Wl(D),gn()},oe=(D,S,R,N,$,j,ne,K,Y=!1)=>{const B=D&&D.children,be=D?D.shapeFlag:0,re=S.children,{patchFlag:Fe,shapeFlag:De}=S;if(Fe>0){if(Fe&128){ft(B,re,R,N,$,j,ne,K,Y);return}else if(Fe&256){He(B,re,R,N,$,j,ne,K,Y);return}}De&8?(be&16&&L(B,$,j),re!==B&&u(R,re)):be&16?De&16?ft(B,re,R,N,$,j,ne,K,Y):L(B,$,j,!0):(be&8&&u(R,""),De&16&&G(re,R,N,$,j,ne,K,Y))},He=(D,S,R,N,$,j,ne,K,Y)=>{D=D||To,S=S||To;const B=D.length,be=S.length,re=Math.min(B,be);let Fe;for(Fe=0;Fe<re;Fe++){const De=S[Fe]=Y?In(S[Fe]):bn(S[Fe]);f(D[Fe],De,R,null,$,j,ne,K,Y)}B>be?L(D,$,j,!0,!1,re):G(S,R,N,$,j,ne,K,Y,re)},ft=(D,S,R,N,$,j,ne,K,Y)=>{let B=0;const be=S.length;let re=D.length-1,Fe=be-1;for(;B<=re&&B<=Fe;){const De=D[B],we=S[B]=Y?In(S[B]):bn(S[B]);if(vr(De,we))f(De,we,R,null,$,j,ne,K,Y);else break;B++}for(;B<=re&&B<=Fe;){const De=D[re],we=S[Fe]=Y?In(S[Fe]):bn(S[Fe]);if(vr(De,we))f(De,we,R,null,$,j,ne,K,Y);else break;re--,Fe--}if(B>re){if(B<=Fe){const De=Fe+1,we=De<be?S[De].el:N;for(;B<=Fe;)f(null,S[B]=Y?In(S[B]):bn(S[B]),R,we,$,j,ne,K,Y),B++}}else if(B>Fe)for(;B<=re;)O(D[B],$,j,!0),B++;else{const De=B,we=B,Ge=new Map;for(B=we;B<=Fe;B++){const dt=S[B]=Y?In(S[B]):bn(S[B]);dt.key!=null&&Ge.set(dt.key,B)}let Oe,k=0;const _e=Fe-we+1;let Le=!1,Ke=0;const Xe=new Array(_e);for(B=0;B<_e;B++)Xe[B]=0;for(B=De;B<=re;B++){const dt=D[B];if(k>=_e){O(dt,$,j,!0);continue}let Ze;if(dt.key!=null)Ze=Ge.get(dt.key);else for(Oe=we;Oe<=Fe;Oe++)if(Xe[Oe-we]===0&&vr(dt,S[Oe])){Ze=Oe;break}Ze===void 0?O(dt,$,j,!0):(Xe[Ze-we]=B+1,Ze>=Ke?Ke=Ze:Le=!0,f(dt,S[Ze],R,null,$,j,ne,K,Y),k++)}const Kt=Le?sP(Xe):To;for(Oe=Kt.length-1,B=_e-1;B>=0;B--){const dt=we+B,Ze=S[dt],Dt=S[dt+1],Ft=dt+1<be?Dt.el||Oc(Dt):N;Xe[B]===0?f(null,Ze,R,Ft,$,j,ne,K,Y):Le&&(Oe<0||B!==Kt[Oe]?Ve(Ze,R,Ft,2):Oe--)}}},Ve=(D,S,R,N,$=null)=>{const{el:j,type:ne,transition:K,children:Y,shapeFlag:B}=D;if(B&6){Ve(D.component.subTree,S,R,N);return}if(B&128){D.suspense.move(S,R,N);return}if(B&64){ne.move(D,S,R,vt);return}if(ne===pe){o(j,S,R);for(let re=0;re<Y.length;re++)Ve(Y[re],S,R,N);o(D.anchor,S,R);return}if(ne===_a){E(D,S,R);return}if(N!==2&&B&1&&K)if(N===0)K.beforeEnter(j),o(j,S,R),At(()=>K.enter(j),$);else{const{leave:re,delayLeave:Fe,afterLeave:De}=K,we=()=>{D.ctx.isUnmounted?r(j):o(j,S,R)},Ge=()=>{j._isLeaving&&j[Dm](!0),re(j,()=>{we(),De&&De()})};Fe?Fe(j,we,Ge):Ge()}else o(j,S,R)},O=(D,S,R,N=!1,$=!1)=>{const{type:j,props:ne,ref:K,children:Y,dynamicChildren:B,shapeFlag:be,patchFlag:re,dirs:Fe,cacheIndex:De,memo:we}=D;if(re===-2&&($=!1),K!=null&&(hn(),fr(K,null,R,D,!0),gn()),De!=null&&(S.renderCache[De]=void 0),be&256){S.ctx.deactivate(D);return}const Ge=be&1&&Fe,Oe=!Go(D);let k;if(Oe&&(k=ne&&ne.onVnodeBeforeUnmount)&&yn(k,S,D),be&6)se(D.component,R,N);else{if(be&128){D.suspense.unmount(R,N);return}Ge&&mo(D,null,S,"beforeUnmount"),be&64?D.type.remove(D,S,R,vt,N):B&&!B.hasOnce&&(j!==pe||re>0&&re&64)?L(B,S,R,!1,!0):(j===pe&&re&384||!$&&be&16)&&L(Y,S,R),N&&H(D)}const _e=we!=null&&De==null;(Oe&&(k=ne&&ne.onVnodeUnmounted)||Ge||_e)&&At(()=>{k&&yn(k,S,D),Ge&&mo(D,null,S,"unmounted"),_e&&(D.el=null)},R)},H=D=>{const{type:S,el:R,anchor:N,transition:$}=D;if(S===pe){V(R,N);return}if(S===_a){A(D);return}const j=()=>{r(R),$&&!$.persisted&&$.afterLeave&&$.afterLeave()};if(D.shapeFlag&1&&$&&!$.persisted){const{leave:ne,delayLeave:K}=$,Y=()=>ne(R,j);K?K(D.el,j,Y):Y()}else j()},V=(D,S)=>{let R;for(;D!==S;)R=p(D),r(D),D=R;r(S)},se=(D,S,R)=>{const{bum:N,scope:$,job:j,subTree:ne,um:K,m:Y,a:B}=D;wc(Y),wc(B),N&&Zr(N),$.stop(),j&&(j.flags|=8,O(ne,D,S,R)),K&&At(K,S),At(()=>{D.isUnmounted=!0},S)},L=(D,S,R,N=!1,$=!1,j=0)=>{for(let ne=j;ne<D.length;ne++)O(D[ne],S,R,N,$)},de=D=>{if(D.shapeFlag&6)return de(D.component.subTree);if(D.shapeFlag&128)return D.suspense.next();const S=p(D.anchor||D.el),R=S&&S[Kl];return R?p(R):S};let Pe=!1;const Re=(D,S,R)=>{let N;D==null?S._vnode&&(O(S._vnode,null,null,!0),N=S._vnode.component):f(S._vnode||null,D,S,null,null,null,R),S._vnode=D,Pe||(Pe=!0,Wl(N),Hl(),Pe=!1)},vt={p:f,um:O,m:Ve,r:H,mt:ge,mc:G,pc:oe,pbc:J,n:de,o:t};return{render:Re,hydrate:void 0,createApp:Wm(Re)}}function Ui({type:t,props:e},n){return n==="svg"&&t==="foreignObject"||n==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:n}function Fo({effect:t,job:e},n){n?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function iP(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Bi(t,e,n=!1){const o=t.children,r=e.children;if(Ce(o)&&Ce(r))for(let a=0;a<o.length;a++){const i=o[a];let s=r[a];s.shapeFlag&1&&!s.dynamicChildren&&((s.patchFlag<=0||s.patchFlag===32)&&(s=r[a]=In(r[a]),s.el=i.el),!n&&s.patchFlag!==-2&&Bi(i,s)),s.type===ya&&(s.patchFlag===-1&&(s=r[a]=In(s)),s.el=i.el),s.type===kn&&!s.el&&(s.el=i.el)}}function sP(t){const e=t.slice(),n=[0];let o,r,a,i,s;const l=t.length;for(o=0;o<l;o++){const c=t[o];if(c!==0){if(r=n[n.length-1],t[r]<c){e[o]=r,n.push(o);continue}for(a=0,i=n.length-1;a<i;)s=a+i>>1,t[n[s]]<c?a=s+1:i=s;c<t[n[a]]&&(a>0&&(e[o]=n[a-1]),n[a]=o)}}for(a=n.length,i=n[a-1];a-- >0;)n[a]=i,i=e[i];return n}function Rc(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Rc(e)}function wc(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function Oc(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?Oc(e.subTree):null}const kc=t=>t.__isSuspense;function lP(t,e){e&&e.pendingBranch?Ce(t)?e.effects.push(...t):e.effects.push(t):mm(t)}const pe=Symbol.for("v-fgt"),ya=Symbol.for("v-txt"),kn=Symbol.for("v-cmt"),_a=Symbol.for("v-stc"),br=[];let Ht=null;function v(t=!1){br.push(Ht=t?null:[])}function cP(){br.pop(),Ht=br[br.length-1]||null}let yr=1;function va(t,e=!1){yr+=t,t<0&&Ht&&e&&(Ht.hasOnce=!0)}function Ic(t){return t.dynamicChildren=yr>0?Ht||To:null,cP(),yr>0&&Ht&&Ht.push(t),t}function C(t,e,n,o,r,a){return Ic(m(t,e,n,o,r,a,!0))}function he(t,e,n,o,r){return Ic(je(t,e,n,o,r,!0))}function _r(t){return t?t.__v_isVNode===!0:!1}function vr(t,e){return t.type===e.type&&t.key===e.key}const Gc=({key:t})=>t??null,Da=({ref:t,ref_key:e,ref_for:n})=>(typeof t=="number"&&(t=""+t),t!=null?ut(t)||ht(t)||Me(t)?{i:yt,r:t,k:e,f:!!n}:t:null);function m(t,e=null,n=null,o=0,r=null,a=t===pe?0:1,i=!1,s=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Gc(e),ref:e&&Da(e),scopeId:Yl,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:a,patchFlag:o,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:yt};return s?(zi(l,n),a&128&&t.normalize(l)):n&&(l.shapeFlag|=ut(n)?8:16),yr>0&&!i&&Ht&&(l.patchFlag>0||a&6)&&l.patchFlag!==32&&Ht.push(l),l}const je=uP;function uP(t,e=null,n=null,o=0,r=null,a=!1){if((!t||t===ic)&&(t=kn),_r(t)){const s=jo(t,e,!0);return n&&zi(s,n),yr>0&&!a&&Ht&&(s.shapeFlag&6?Ht[Ht.indexOf(t)]=s:Ht.push(s)),s.patchFlag=-2,s}if(yP(t)&&(t=t.__vccOpts),e){e=Qt(e);let{class:s,style:l}=e;s&&!ut(s)&&(e.class=St(s)),Je(l)&&(ur(l)&&!Ce(l)&&(l=bt({},l)),e.style=Z(l))}const i=ut(t)?1:kc(t)?128:ym(t)?64:Je(t)?4:Me(t)?2:0;return m(t,e,n,o,r,i,a,!0)}function Qt(t){return t?ur(t)||Sc(t)?bt({},t):t:null}function jo(t,e,n=!1,o=!1){const{props:r,ref:a,patchFlag:i,children:s,transition:l}=t,c=e?xe(r||{},e):r,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Gc(c),ref:e&&e.ref?n&&a?Ce(a)?a.concat(Da(e)):[a,Da(e)]:Da(e):a,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:s,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==pe?i===-1?16:i|16:i,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&jo(t.ssContent),ssFallback:t.ssFallback&&jo(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&o&&Oi(u,l.clone(u)),u}function dP(t=" ",e=0){return je(ya,null,t,e)}function Zn(t,e){const n=je(_a,null,t);return n.staticCount=e,n}function ae(t="",e=!1){return e?(v(),he(kn,null,t)):je(kn,null,t)}function bn(t){return t==null||typeof t=="boolean"?je(kn):Ce(t)?je(pe,null,t.slice()):_r(t)?In(t):je(ya,null,String(t))}function In(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:jo(t)}function zi(t,e){let n=0;const{shapeFlag:o}=t;if(e==null)e=null;else if(Ce(e))n=16;else if(typeof e=="object")if(o&65){const r=e.default;r&&(r._c&&(r._d=!1),zi(t,r()),r._c&&(r._d=!0));return}else{n=32;const r=e._;!r&&!Sc(e)?e._ctx=yt:r===3&&yt&&(yt.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Me(e)?(e={default:e,_ctx:yt},n=32):(e=String(e),o&64?(n=16,e=[dP(e)]):n=8);t.children=e,t.shapeFlag|=n}function xe(...t){const e={};for(let n=0;n<t.length;n++){const o=t[n];for(const r in o)if(r==="class")e.class!==o.class&&(e.class=St([e.class,o.class]));else if(r==="style")e.style=Z([e.style,o.style]);else if(Hr(r)){const a=e[r],i=o[r];i&&a!==i&&!(Ce(a)&&a.includes(i))?e[r]=a?[].concat(a,i):i:i==null&&a==null&&!Vr(r)&&(e[r]=i)}else r!==""&&(e[r]=o[r])}return e}function yn(t,e,n,o=null){mn(t,e,7,[n,o])}const pP=Pc();let hP=0;function gP(t,e,n){const o=t.type,r=(e?e.appContext:t.appContext)||pP,a={uid:hP++,vnode:t,type:o,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Of(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(r.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Ac(o,r),emitsOptions:Fc(o,r),emit:null,emitted:null,propsDefaults:ot,inheritAttrs:o.inheritAttrs,ctx:ot,data:ot,props:ot,attrs:ot,slots:ot,refs:ot,setupState:ot,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return a.ctx={_:a},a.root=e?e.root:a,a.emit=Vm.bind(null,a),t.ce&&t.ce(a),a}let xt=null;const Lc=()=>xt||yt;let Sa,Wi;{const t=Jr(),e=(n,o)=>{let r;return(r=t[n])||(r=t[n]=[]),r.push(o),a=>{r.length>1?r.forEach(i=>i(a)):r[0](a)}};Sa=e("__VUE_INSTANCE_SETTERS__",n=>xt=n),Wi=e("__VUE_SSR_SETTERS__",n=>Sr=n)}const Dr=t=>{const e=xt;return Sa(t),t.scope.on(),()=>{t.scope.off(),Sa(e)}},$c=()=>{xt&&xt.scope.off(),Sa(null)};function Nc(t){return t.vnode.shapeFlag&4}let Sr=!1;function fP(t,e=!1,n=!1){e&&Wi(e);const{props:o,children:r}=t.vnode,a=Nc(t);Qm(t,o,a,e),nP(t,r,n||e);const i=a?mP(t,e):void 0;return e&&Wi(!1),i}function mP(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,Gm);const{setup:o}=n;if(o){hn();const r=t.setupContext=o.length>1?Bc(t):null,a=Dr(t),i=Oo(o,t,0,[t.props,r]),s=pl(i);if(gn(),a(),(s||t.sp)&&!Go(t)&&ec(t),s){if(i.then($c,$c),e)return i.then(l=>{jc(t,l)}).catch(l=>{la(l,t,0)});t.asyncDep=i}else jc(t,i)}else Uc(t)}function jc(t,e,n){Me(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:Je(e)&&(t.setupState=Nl(e)),Uc(t)}function Uc(t,e,n){const o=t.type;t.render||(t.render=o.render||dn);{const r=Dr(t);hn();try{$m(t)}finally{gn(),r()}}}const PP={get(t,e){return Et(t,"get",""),t[e]}};function Bc(t){const e=n=>{t.exposed=n||{}};return{attrs:new Proxy(t.attrs,PP),slots:t.slots,emit:t.emit,expose:e}}function Ea(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Nl(dr(t.exposed)),{get(e,n){if(n in e)return e[n];if(n in Pr)return Pr[n](t)},has(e,n){return n in e||n in Pr}})):t.proxy}const FP=/(?:^|[-_])\w/g,bP=t=>t.replace(FP,e=>e.toUpperCase()).replace(/[-_]/g,"");function zc(t,e=!0){return Me(t)?t.displayName||t.name:t.name||e&&t.__name}function Wc(t,e,n=!1){let o=zc(e);if(!o&&e.__file){const r=e.__file.match(/([^/\\]+)\.\w+$/);r&&(o=r[1])}if(!o&&t){const r=a=>{for(const i in a)if(a[i]===e)return i};o=r(t.components)||t.parent&&r(t.parent.type.components)||r(t.appContext.components)}return o?bP(o):n?"App":"Anonymous"}function yP(t){return Me(t)&&"__vccOpts"in t}const P=(t,e)=>sm(t,e,Sr);function _P(t,e,n){try{va(-1);const o=arguments.length;return o===2?Je(e)&&!Ce(e)?_r(e)?je(t,null,[e]):je(t,e):je(t,null,e):(o>3?n=Array.prototype.slice.call(arguments,2):o===3&&_r(n)&&(n=[n]),je(t,e,n))}finally{va(1)}}const vP="3.5.31";/**
17
17
  * @vue/runtime-dom v3.5.31
18
18
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
19
19
  * @license MIT
20
- **/let Wi;const Wc=typeof window<"u"&&window.trustedTypes;if(Wc)try{Wi=Wc.createPolicy("vue",{createHTML:t=>t})}catch{}const Hc=Wi?t=>Wi.createHTML(t):t=>t,_P="http://www.w3.org/2000/svg",yP="http://www.w3.org/1998/Math/MathML",Gn=typeof document<"u"?document:null,Vc=Gn&&Gn.createElement("template"),vP={insert:(t,e,n)=>{e.insertBefore(t,n||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,n,o)=>{const r=e==="svg"?Gn.createElementNS(_P,t):e==="mathml"?Gn.createElementNS(yP,t):n?Gn.createElement(t,{is:n}):Gn.createElement(t);return t==="select"&&o&&o.multiple!=null&&r.setAttribute("multiple",o.multiple),r},createText:t=>Gn.createTextNode(t),createComment:t=>Gn.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Gn.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,n,o,r,a){const i=n?n.previousSibling:e.lastChild;if(r&&(r===a||r.nextSibling))for(;e.insertBefore(r.cloneNode(!0),n),!(r===a||!(r=r.nextSibling)););else{Vc.innerHTML=Hc(o==="svg"?`<svg>${t}</svg>`:o==="mathml"?`<math>${t}</math>`:t);const s=Vc.content;if(o==="svg"||o==="mathml"){const l=s.firstChild;for(;l.firstChild;)s.appendChild(l.firstChild);s.removeChild(l)}e.insertBefore(s,n)}return[i?i.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}},DP=Symbol("_vtc");function SP(t,e,n){const o=t[DP];o&&(e=(e?[e,...o]:[...o]).join(" ")),e==null?t.removeAttribute("class"):n?t.setAttribute("class",e):t.className=e}const Yc=Symbol("_vod"),EP=Symbol("_vsh"),AP=Symbol(""),xP=/(?:^|;)\s*display\s*:/;function CP(t,e,n){const o=t.style,r=ut(n);let a=!1;if(n&&!r){if(e)if(ut(e))for(const i of e.split(";")){const s=i.slice(0,i.indexOf(":")).trim();n[s]==null&&Ea(o,s,"")}else for(const i in e)n[i]==null&&Ea(o,i,"");for(const i in n)i==="display"&&(a=!0),Ea(o,i,n[i])}else if(r){if(e!==n){const i=o[AP];i&&(n+=";"+i),o.cssText=n,a=xP.test(n)}}else e&&t.removeAttribute("style");Yc in t&&(t[Yc]=a?o.display:"",t[EP]&&(o.display="none"))}const qc=/\s*!important$/;function Ea(t,e,n){if(Ce(n))n.forEach(o=>Ea(t,e,o));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const o=TP(t,e);qc.test(n)?t.setProperty(Yn(o),n.replace(qc,""),"important"):t[o]=n}}const Kc=["Webkit","Moz","ms"],Hi={};function TP(t,e){const n=Hi[e];if(n)return n;let o=wt(e);if(o!=="filter"&&o in t)return Hi[e]=o;o=Kr(o);for(let r=0;r<Kc.length;r++){const a=Kc[r]+o;if(a in t)return Hi[e]=a}return e}const Xc="http://www.w3.org/1999/xlink";function Zc(t,e,n,o,r,a=xf(e)){o&&e.startsWith("xlink:")?n==null?t.removeAttributeNS(Xc,e.slice(6,e.length)):t.setAttributeNS(Xc,e,n):n==null||a&&!ml(n)?t.removeAttribute(e):t.setAttribute(e,a?"":Bt(n)?String(n):n)}function Qc(t,e,n,o,r){if(e==="innerHTML"||e==="textContent"){n!=null&&(t[e]=e==="innerHTML"?Hc(n):n);return}const a=t.tagName;if(e==="value"&&a!=="PROGRESS"&&!a.includes("-")){const s=a==="OPTION"?t.getAttribute("value")||"":t.value,l=n==null?t.type==="checkbox"?"on":"":String(n);(s!==l||!("_value"in t))&&(t.value=l),n==null&&t.removeAttribute(e),t._value=n;return}let i=!1;if(n===""||n==null){const s=typeof t[e];s==="boolean"?n=ml(n):n==null&&s==="string"?(n="",i=!0):s==="number"&&(n=0,i=!0)}try{t[e]=n}catch{}i&&t.removeAttribute(r||e)}function bo(t,e,n,o){t.addEventListener(e,n,o)}function MP(t,e,n,o){t.removeEventListener(e,n,o)}const Jc=Symbol("_vei");function RP(t,e,n,o,r=null){const a=t[Jc]||(t[Jc]={}),i=a[e];if(o&&i)i.value=o;else{const[s,l]=wP(e);if(o){const c=a[e]=IP(o,r);bo(t,s,c,l)}else i&&(MP(t,s,i,l),a[e]=void 0)}}const eu=/(?:Once|Passive|Capture)$/;function wP(t){let e;if(eu.test(t)){e={};let o;for(;o=t.match(eu);)t=t.slice(0,t.length-o[0].length),e[o[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Yn(t.slice(2)),e]}let Vi=0;const OP=Promise.resolve(),kP=()=>Vi||(OP.then(()=>Vi=0),Vi=Date.now());function IP(t,e){const n=o=>{if(!o._vts)o._vts=Date.now();else if(o._vts<=n.attached)return;mn(GP(o,n.value),e,5,[o])};return n.value=t,n.attached=kP(),n}function GP(t,e){if(Ce(e)){const n=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{n.call(t),t._stopped=!0},e.map(o=>r=>!r._stopped&&o&&o(r))}else return e}const tu=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,LP=(t,e,n,o,r,a)=>{const i=r==="svg";e==="class"?SP(t,o,i):e==="style"?CP(t,n,o):Wr(e)?Hr(e)||RP(t,e,n,o,a):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):$P(t,e,o,i))?(Qc(t,e,o),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&Zc(t,e,o,i,a,e!=="value")):t._isVueCE&&(NP(t,e)||t._def.__asyncLoader&&(/[A-Z]/.test(e)||!ut(o)))?Qc(t,wt(e),o,a,e):(e==="true-value"?t._trueValue=o:e==="false-value"&&(t._falseValue=o),Zc(t,e,o,i))};function $P(t,e,n,o){if(o)return!!(e==="innerHTML"||e==="textContent"||e in t&&tu(e)&&Me(n));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const r=t.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return tu(e)&&ut(n)?!1:e in t}function NP(t,e){const n=t._def.props;if(!n)return!1;const o=wt(e);return Array.isArray(n)?n.some(r=>wt(r)===o):Object.keys(n).some(r=>wt(r)===o)}const Aa=t=>{const e=t.props["onUpdate:modelValue"]||!1;return Ce(e)?n=>Xr(e,n):e};function jP(t){t.target.composing=!0}function nu(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Uo=Symbol("_assign");function ou(t,e,n){return e&&(t=t.trim()),n&&(t=Zr(t)),t}const Bo={created(t,{modifiers:{lazy:e,trim:n,number:o}},r){t[Uo]=Aa(r);const a=o||r.props&&r.props.type==="number";bo(t,e?"change":"input",i=>{i.target.composing||t[Uo](ou(t.value,n,a))}),(n||a)&&bo(t,"change",()=>{t.value=ou(t.value,n,a)}),e||(bo(t,"compositionstart",jP),bo(t,"compositionend",nu),bo(t,"change",nu))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:n,modifiers:{lazy:o,trim:r,number:a}},i){if(t[Uo]=Aa(i),t.composing)return;const s=(a||t.type==="number")&&!/^0\d/.test(t.value)?Zr(t.value):t.value,l=e??"";if(s===l)return;const c=t.getRootNode();(c instanceof Document||c instanceof ShadowRoot)&&c.activeElement===t&&t.type!=="range"&&(o&&e===n||r&&t.value.trim()===l)||(t.value=l)}},UP={deep:!0,created(t,{value:e,modifiers:{number:n}},o){const r=Vr(e);bo(t,"change",()=>{const a=Array.prototype.filter.call(t.options,i=>i.selected).map(i=>n?Zr(xa(i)):xa(i));t[Uo](t.multiple?r?new Set(a):a:a[0]),t._assigning=!0,ca(()=>{t._assigning=!1})}),t[Uo]=Aa(o)},mounted(t,{value:e}){ru(t,e)},beforeUpdate(t,e,n){t[Uo]=Aa(n)},updated(t,{value:e}){t._assigning||ru(t,e)}};function ru(t,e){const n=t.multiple,o=Ce(e);if(!(n&&!o&&!Vr(e))){for(let r=0,a=t.options.length;r<a;r++){const i=t.options[r],s=xa(i);if(n)if(o){const l=typeof s;l==="string"||l==="number"?i.selected=e.some(c=>String(c)===String(s)):i.selected=Tf(e,s)>-1}else i.selected=e.has(s);else if(rr(xa(i),e)){t.selectedIndex!==r&&(t.selectedIndex=r);return}}!n&&t.selectedIndex!==-1&&(t.selectedIndex=-1)}}function xa(t){return"_value"in t?t._value:t.value}const BP=["ctrl","shift","alt","meta"],zP={stop:t=>t.stopPropagation(),prevent:t=>t.preventDefault(),self:t=>t.target!==t.currentTarget,ctrl:t=>!t.ctrlKey,shift:t=>!t.shiftKey,alt:t=>!t.altKey,meta:t=>!t.metaKey,left:t=>"button"in t&&t.button!==0,middle:t=>"button"in t&&t.button!==1,right:t=>"button"in t&&t.button!==2,exact:(t,e)=>BP.some(n=>t[`${n}Key`]&&!e.includes(n))},Yi=(t,e)=>{if(!t)return t;const n=t._withMods||(t._withMods={}),o=e.join(".");return n[o]||(n[o]=(r,...a)=>{for(let i=0;i<e.length;i++){const s=zP[e[i]];if(s&&s(r,e))return}return t(r,...a)})},WP={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},HP=(t,e)=>{const n=t._withKeys||(t._withKeys={}),o=e.join(".");return n[o]||(n[o]=r=>{if(!("key"in r))return;const a=Yn(r.key);if(e.some(i=>i===a||WP[i]===a))return t(r)})},VP=bt({patchProp:LP},vP);let au;function YP(){return au||(au=tP(VP))}const qP=(...t)=>{const e=YP().createApp(...t),{mount:n}=e;return e.mount=o=>{const r=XP(o);if(!r)return;const a=e._component;!Me(a)&&!a.render&&!a.template&&(a.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const i=n(r,!1,KP(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),i},e};function KP(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function XP(t){return ut(t)?document.querySelector(t):t}var Er=(t=>(t[t.Degree0=0]="Degree0",t[t.Degree90=1]="Degree90",t[t.Degree180=2]="Degree180",t[t.Degree270=3]="Degree270",t))(Er||{});function qi(t){const{width:e,height:n}=t;return{width:n,height:e}}function Ca(t,e,n){return t=e%2===0?t:qi(t),{width:t.width*n,height:t.height*n}}function iu(t,e,n){let o=e.x,r=e.y;switch(n){case 0:o=e.x,r=e.y;break;case 1:o=t.height-e.y,r=e.x;break;case 2:o=t.width-e.x,r=t.height-e.y;break;case 3:o=e.y,r=t.width-e.x;break}return{x:o,y:r}}function Ta(t,e){return{x:t.x*e,y:t.y*e}}function ZP(t,e,n,o){return Ta(iu(t,e,n),o)}function QP(t,e,n,o){return Ta(iu(t,e,(4-n)%4),1/o)}function cn(t){if(t.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};const e=t.map(a=>a.x),n=t.map(a=>a.y),o=Math.min(...e),r=Math.min(...n);return{origin:{x:o,y:r},size:{width:Math.max(...e)-o,height:Math.max(...n)-r}}}function JP(t,e,n){const o=Math.cos(e),r=Math.sin(e),a=t.x*o-t.y*r,i=t.x*r+t.y*o;return{x:a+n.x,y:i+n.y}}function yn(t,e){return{origin:{x:t.origin.x-e,y:t.origin.y-e},size:{width:t.size.width+e*2,height:t.size.height+e*2}}}function Ki(t,e,n){let o=e.origin.x,r=e.origin.y,a=e.size;switch(n){case 0:break;case 1:o=t.height-e.origin.y-e.size.height,r=e.origin.x,a=qi(e.size);break;case 2:o=t.width-e.origin.x-e.size.width,r=t.height-e.origin.y-e.size.height;break;case 3:o=e.origin.y,r=t.width-e.origin.x-e.size.width,a=qi(e.size);break}return{origin:{x:o,y:r},size:{width:a.width,height:a.height}}}function su(t,e){return{origin:{x:t.origin.x*e,y:t.origin.y*e},size:{width:t.size.width*e,height:t.size.height*e}}}function eF(t,e,n,o){return su(Ki(t,e,n),o)}function tF(t,e,n,o){return su(Ki(t,e,(4-n)%4),1/o)}const nF={origin:{x:0,y:0},size:{width:0,height:0}};function Xi(t){if(t.length===0)return null;let e=t[0].origin.x,n=t[0].origin.y,o=t[0].origin.x+t[0].size.width,r=t[0].origin.y+t[0].size.height;for(const a of t)e=Math.min(e,a.origin.x),n=Math.min(n,a.origin.y),o=Math.max(o,a.origin.x+a.size.width),r=Math.max(r,a.origin.y+a.size.height);return{origin:{x:e,y:n},size:{width:o-e,height:r-n}}}function oF(t){return Xi(t)??nF}function Ma(t){const e=t%360;return e<0?e+360:e}function _o(t){return{x:t.origin.x+t.size.width/2,y:t.origin.y+t.size.height/2}}function yo(t,e,n){const o=n*Math.PI/180,r=Math.cos(o),a=Math.sin(o),i=t.x-e.x,s=t.y-e.y;return{x:e.x+i*r-s*a,y:e.y+i*a+s*r}}function lu(t,e,n){return t.map(o=>yo(o,e,n))}function Qn(t,e,n){const o=[{x:t.origin.x,y:t.origin.y},{x:t.origin.x+t.size.width,y:t.origin.y},{x:t.origin.x+t.size.width,y:t.origin.y+t.size.height},{x:t.origin.x,y:t.origin.y+t.size.height}],r=lu(o,n,e);return cn(r)}function Zi(t,e){return Qn(t,e,_o(t))}function cu(t,e,n){const o=n*Math.PI/180,r=Math.cos(o),a=Math.sin(o),i=1-r,s=a,l=-a,c=1-r,u=i*c-s*l,d=_o(t);if(Math.abs(u)<1e-10)return d;const p=_o(e),h=p.x-(r*d.x-a*d.y),g=p.y-(a*d.x+r*d.y);return{x:(c*h-s*g)/u,y:(-l*h+i*g)/u}}class zo{isEnabled(){return!1}debug(){}info(){}warn(){}error(){}perf(){}}class rF{isEnabled(){return!0}debug(e,n,...o){console.debug(`${e}.${n}`,...o)}info(e,n,...o){console.info(`${e}.${n}`,...o)}warn(e,n,...o){console.warn(`${e}.${n}`,...o)}error(e,n,...o){console.error(`${e}.${n}`,...o)}perf(e,n,o,r,...a){console.info(`${e}.${n}.${o}.${r}`,...a)}}class aF{constructor(e,n){this.logger=e,this.level=n}isEnabled(e){const n={debug:0,info:1,warn:2,error:3};return this.level<=n[e]}debug(e,n,...o){this.level<=0&&this.logger.debug(e,n,...o)}info(e,n,...o){this.level<=1&&this.logger.info(e,n,...o)}warn(e,n,...o){this.level<=2&&this.logger.warn(e,n,...o)}error(e,n,...o){this.level<=3&&this.logger.error(e,n,...o)}perf(e,n,o,r,...a){this.logger.perf(e,n,o,r,...a)}}class iF{constructor(){this.marks=new Map}isEnabled(){return!1}debug(e,n,...o){}info(e,n,...o){}warn(e,n,...o){}error(e,n,...o){}perf(e,n,o,r,a,...i){const s=`${e}.${n}.${o}.${r}.${a}`;switch(r){case"Begin":globalThis.performance.mark(s,{detail:i}),this.marks.set(`${e}.${n}.${o}.${a}`,Date.now());break;case"End":globalThis.performance.mark(s,{detail:i});const l=`${e}.${n}.${o}.Measure.${a}`,c=`${e}.${n}.${o}.Begin.${a}`;globalThis.performance.measure(l,c,s);const u=this.marks.get(`${e}.${n}.${o}.${a}`);if(u){const d=Date.now()-u;console.info(`⏱️ ${e}.${n}.${o}.${a}: ${d}ms`),this.marks.delete(`${e}.${n}.${o}.${a}`)}break}}}class sF{constructor(e){this.loggers=e}isEnabled(e){return this.loggers.some(n=>n.isEnabled(e))}debug(e,n,...o){for(const r of this.loggers)r.debug(e,n,...o)}info(e,n,...o){for(const r of this.loggers)r.info(e,n,...o)}warn(e,n,...o){for(const r of this.loggers)r.warn(e,n,...o)}error(e,n,...o){for(const r of this.loggers)r.error(e,n,...o)}perf(e,n,o,r,...a){for(const i of this.loggers)i.perf(e,n,o,r,...a)}}var Wo=(t=>(t[t.Pending=0]="Pending",t[t.Resolved=1]="Resolved",t[t.Rejected=2]="Rejected",t[t.Aborted=3]="Aborted",t))(Wo||{});class lF extends Error{constructor(e){super(`Task aborted: ${JSON.stringify(e)}`),this.name="TaskAbortedError",this.reason=e}}class cF extends Error{constructor(e){super(`Task rejected: ${JSON.stringify(e)}`),this.name="TaskRejectedError",this.reason=e}}class Ie{constructor(){this.state={stage:0},this.resolvedCallbacks=[],this.rejectedCallbacks=[],this._promise=null,this.progressCbs=[]}toPromise(){return this._promise||(this._promise=new Promise((e,n)=>{this.wait(o=>e(o),o=>{o.type==="abort"?n(new lF(o.reason)):n(new cF(o.reason))})})),this._promise}wait(e,n){switch(this.state.stage){case 0:this.resolvedCallbacks.push(e),this.rejectedCallbacks.push(n);break;case 1:e(this.state.result);break;case 2:n({type:"reject",reason:this.state.reason});break;case 3:n({type:"abort",reason:this.state.reason});break}}resolve(e){if(this.state.stage===0){this.state={stage:1,result:e};for(const n of this.resolvedCallbacks)try{n(e)}catch{}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}reject(e){if(this.state.stage===0){this.state={stage:2,reason:e};for(const n of this.rejectedCallbacks)try{n({type:"reject",reason:e})}catch{}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}abort(e){if(this.state.stage===0){this.state={stage:3,reason:e};for(const n of this.rejectedCallbacks)try{n({type:"abort",reason:e})}catch{}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}fail(e){e.type==="abort"?this.abort(e.reason):this.reject(e.reason)}onProgress(e){this.progressCbs.push(e)}progress(e){for(const n of this.progressCbs)n(e)}static all(e){const n=new Ie;if(e.length===0)return n.resolve([]),n;const o=new Array(e.length);let r=0,a=!1;return e.forEach((i,s)=>{i.wait(l=>{a||(o[s]=l,r++,r===e.length&&(a=!0,n.resolve(o)))},l=>{a||(a=!0,l.type==="abort"?n.abort(l.reason):n.reject(l.reason))})}),n}static allSettled(e){const n=new Ie;if(e.length===0)return n.resolve([]),n;const o=new Array(e.length);let r=0;return e.forEach((a,i)=>{a.wait(s=>{o[i]={status:"resolved",value:s},r++,r===e.length&&n.resolve(o)},s=>{o[i]={status:s.type==="abort"?"aborted":"rejected",reason:s.reason},r++,r===e.length&&n.resolve(o)})}),n}static race(e){const n=new Ie;if(e.length===0)return n.reject("No tasks provided"),n;let o=!1;return e.forEach(r=>{r.wait(a=>{o||(o=!0,n.resolve(a))},a=>{o||(o=!0,a.type==="abort"?n.abort(a.reason):n.reject(a.reason))})}),n}static withProgress(e,n){const o=Ie.all(e);if(n){let r=0;e.forEach(a=>{a.wait(()=>{r++,n(r,e.length)},()=>{r++,n(r,e.length)})})}return o}}const uF=Object.freeze(["­","​","⁠","\uFEFF","￾","￿"]);new RegExp(`[${uF.join("")}]`,"g");var uu=(t=>(t[t.Unknown=0]="Unknown",t[t.XYZ=1]="XYZ",t[t.FitPage=2]="FitPage",t[t.FitHorizontal=3]="FitHorizontal",t[t.FitVertical=4]="FitVertical",t[t.FitRectangle=5]="FitRectangle",t[t.FitBoundingBox=6]="FitBoundingBox",t[t.FitBoundingBoxHorizontal=7]="FitBoundingBoxHorizontal",t[t.FitBoundingBoxVertical=8]="FitBoundingBoxVertical",t))(uu||{}),mt=(t=>(t[t.Unknown=-1]="Unknown",t[t.Courier=0]="Courier",t[t.Courier_Bold=1]="Courier_Bold",t[t.Courier_BoldOblique=2]="Courier_BoldOblique",t[t.Courier_Oblique=3]="Courier_Oblique",t[t.Helvetica=4]="Helvetica",t[t.Helvetica_Bold=5]="Helvetica_Bold",t[t.Helvetica_BoldOblique=6]="Helvetica_BoldOblique",t[t.Helvetica_Oblique=7]="Helvetica_Oblique",t[t.Times_Roman=8]="Times_Roman",t[t.Times_Bold=9]="Times_Bold",t[t.Times_BoldItalic=10]="Times_BoldItalic",t[t.Times_Italic=11]="Times_Italic",t[t.Symbol=12]="Symbol",t[t.ZapfDingbats=13]="ZapfDingbats",t))(mt||{}),Vt=(t=>(t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t))(Vt||{}),Ar=(t=>(t[t.Top=0]="Top",t[t.Middle=1]="Middle",t[t.Bottom=2]="Bottom",t))(Ar||{}),it=(t=>(t[t.Normal=0]="Normal",t[t.Multiply=1]="Multiply",t[t.Screen=2]="Screen",t[t.Overlay=3]="Overlay",t[t.Darken=4]="Darken",t[t.Lighten=5]="Lighten",t[t.ColorDodge=6]="ColorDodge",t[t.ColorBurn=7]="ColorBurn",t[t.HardLight=8]="HardLight",t[t.SoftLight=9]="SoftLight",t[t.Difference=10]="Difference",t[t.Exclusion=11]="Exclusion",t[t.Hue=12]="Hue",t[t.Saturation=13]="Saturation",t[t.Color=14]="Color",t[t.Luminosity=15]="Luminosity",t))(it||{}),Ra=(t=>(t[t.Unsupported=0]="Unsupported",t[t.Goto=1]="Goto",t[t.RemoteGoto=2]="RemoteGoto",t[t.URI=3]="URI",t[t.LaunchAppOrOpenFile=4]="LaunchAppOrOpenFile",t))(Ra||{}),M=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.TEXT=1]="TEXT",t[t.LINK=2]="LINK",t[t.FREETEXT=3]="FREETEXT",t[t.LINE=4]="LINE",t[t.SQUARE=5]="SQUARE",t[t.CIRCLE=6]="CIRCLE",t[t.POLYGON=7]="POLYGON",t[t.POLYLINE=8]="POLYLINE",t[t.HIGHLIGHT=9]="HIGHLIGHT",t[t.UNDERLINE=10]="UNDERLINE",t[t.SQUIGGLY=11]="SQUIGGLY",t[t.STRIKEOUT=12]="STRIKEOUT",t[t.STAMP=13]="STAMP",t[t.CARET=14]="CARET",t[t.INK=15]="INK",t[t.POPUP=16]="POPUP",t[t.FILEATTACHMENT=17]="FILEATTACHMENT",t[t.SOUND=18]="SOUND",t[t.MOVIE=19]="MOVIE",t[t.WIDGET=20]="WIDGET",t[t.SCREEN=21]="SCREEN",t[t.PRINTERMARK=22]="PRINTERMARK",t[t.TRAPNET=23]="TRAPNET",t[t.WATERMARK=24]="WATERMARK",t[t.THREED=25]="THREED",t[t.RICHMEDIA=26]="RICHMEDIA",t[t.XFAWIDGET=27]="XFAWIDGET",t[t.REDACT=28]="REDACT",t))(M||{}),Qi=(t=>(t[t.Unknown=-1]="Unknown",t[t.Comment=0]="Comment",t[t.Key=1]="Key",t[t.Note=2]="Note",t[t.Help=3]="Help",t[t.NewParagraph=4]="NewParagraph",t[t.Paragraph=5]="Paragraph",t[t.Insert=6]="Insert",t[t.Graph=7]="Graph",t[t.PushPin=8]="PushPin",t[t.Paperclip=9]="Paperclip",t[t.Tag=10]="Tag",t[t.Speaker=11]="Speaker",t[t.Mic=12]="Mic",t[t.Approved=13]="Approved",t[t.Experimental=14]="Experimental",t[t.NotApproved=15]="NotApproved",t[t.AsIs=16]="AsIs",t[t.Expired=17]="Expired",t[t.NotForPublicRelease=18]="NotForPublicRelease",t[t.Confidential=19]="Confidential",t[t.Final=20]="Final",t[t.Sold=21]="Sold",t[t.Departmental=22]="Departmental",t[t.ForComment=23]="ForComment",t[t.TopSecret=24]="TopSecret",t[t.Draft=25]="Draft",t[t.ForPublicRelease=26]="ForPublicRelease",t))(Qi||{}),Ct=(t=>(t[t.None=0]="None",t[t.Square=1]="Square",t[t.Circle=2]="Circle",t[t.Diamond=3]="Diamond",t[t.OpenArrow=4]="OpenArrow",t[t.ClosedArrow=5]="ClosedArrow",t[t.Butt=6]="Butt",t[t.ROpenArrow=7]="ROpenArrow",t[t.RClosedArrow=8]="RClosedArrow",t[t.Slash=9]="Slash",t[t.Unknown=10]="Unknown",t))(Ct||{}),Ln=(t=>(t[t.Unknown=0]="Unknown",t[t.Reply=1]="Reply",t[t.Group=2]="Group",t))(Ln||{}),rt=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.SOLID=1]="SOLID",t[t.DASHED=2]="DASHED",t[t.BEVELED=3]="BEVELED",t[t.INSET=4]="INSET",t[t.UNDERLINE=5]="UNDERLINE",t[t.CLOUDY=6]="CLOUDY",t))(rt||{});const dF=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"});Object.entries(dF).reduce((t,[e,n])=>(t[n]=Number(e),t),{});var vn=(t=>(t[t.ANSI=0]="ANSI",t[t.DEFAULT=1]="DEFAULT",t[t.SYMBOL=2]="SYMBOL",t[t.SHIFTJIS=128]="SHIFTJIS",t[t.HANGEUL=129]="HANGEUL",t[t.GB2312=134]="GB2312",t[t.CHINESEBIG5=136]="CHINESEBIG5",t[t.GREEK=161]="GREEK",t[t.VIETNAMESE=163]="VIETNAMESE",t[t.HEBREW=177]="HEBREW",t[t.ARABIC=178]="ARABIC",t[t.CYRILLIC=204]="CYRILLIC",t[t.THAI=222]="THAI",t[t.EASTERNEUROPEAN=238]="EASTERNEUROPEAN",t))(vn||{}),xr=(t=>(t[t.Create=0]="Create",t[t.Read=1]="Read",t[t.Update=2]="Update",t[t.Delete=3]="Delete",t))(xr||{}),te=(t=>(t[t.Print=4]="Print",t[t.ModifyContents=8]="ModifyContents",t[t.CopyContents=16]="CopyContents",t[t.ModifyAnnotations=32]="ModifyAnnotations",t[t.FillForms=256]="FillForms",t[t.ExtractForAccessibility=512]="ExtractForAccessibility",t[t.AssembleDocument=1024]="AssembleDocument",t[t.PrintHighQuality=2048]="PrintHighQuality",t[t.AllowAll=3900]="AllowAll",t))(te||{});class pF extends Error{constructor(e,n){const o=e.map(r=>te[r]).join(", ");super(`Permission denied. Required: ${o}`),this.requiredFlags=e,this.currentPermissions=n,this.name="PermissionDeniedError"}}var ve=(t=>(t[t.Ok=0]="Ok",t[t.Unknown=1]="Unknown",t[t.NotFound=2]="NotFound",t[t.WrongFormat=3]="WrongFormat",t[t.Password=4]="Password",t[t.Security=5]="Security",t[t.PageError=6]="PageError",t[t.XFALoad=7]="XFALoad",t[t.XFALayout=8]="XFALayout",t[t.Cancelled=9]="Cancelled",t[t.Initialization=10]="Initialization",t[t.NotReady=11]="NotReady",t[t.NotSupport=12]="NotSupport",t[t.LoadDoc=13]="LoadDoc",t[t.DocNotOpen=14]="DocNotOpen",t[t.CantCloseDoc=15]="CantCloseDoc",t[t.CantCreateNewDoc=16]="CantCreateNewDoc",t[t.CantImportPages=17]="CantImportPages",t[t.CantCreateAnnot=18]="CantCreateAnnot",t[t.CantSetAnnotRect=19]="CantSetAnnotRect",t[t.CantSetAnnotContent=20]="CantSetAnnotContent",t[t.CantRemoveInkList=21]="CantRemoveInkList",t[t.CantAddInkStoke=22]="CantAddInkStoke",t[t.CantReadAttachmentSize=23]="CantReadAttachmentSize",t[t.CantReadAttachmentContent=24]="CantReadAttachmentContent",t[t.CantFocusAnnot=25]="CantFocusAnnot",t[t.CantSelectText=26]="CantSelectText",t[t.CantSelectOption=27]="CantSelectOption",t[t.CantCheckField=28]="CantCheckField",t[t.CantSetAnnotString=29]="CantSetAnnotString",t))(ve||{});class Ue{static create(){return new Ie}static resolve(e){const n=new Ie;return n.resolve(e),n}static reject(e){const n=new Ie;return n.reject(e),n}static abort(e){const n=new Ie;return n.reject(e),n}}function hF(t){/^#?[0-9a-f]{3}$/i.test(t)&&(t=t.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"#$1$1$2$2$3$3").toLowerCase());const[,e,n,o]=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t)??(()=>{throw new Error(`Invalid hex colour: "${t}"`)})();return{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(o,16)}}function gF(t){try{const{red:e,green:n,blue:o}=hF(t);return(.299*e+.587*n+.114*o)/255<.45?"#fff":"#000"}catch{return"#000"}}const Ji=Object.freeze([{id:Vt.Left,label:"Left",css:"left"},{id:Vt.Center,label:"Center",css:"center"},{id:Vt.Right,label:"Right",css:"right"}]),du=Ji.reduce((t,e)=>(t[e.id]=e,t),{});Ji.reduce((t,e)=>(t[e.css]=e.id,t),{});function fF(t){return du[t]??du[Vt.Left]}function es(t){return fF(t).css}Ji.map(t=>({value:t.id,label:t.label}));var pu=(t=>(t.Courier="Courier",t.Helvetica="Helvetica",t.Times="Times",t.Symbol="Symbol",t.ZapfDingbats="ZapfDingbats",t.Unknown="Unknown",t))(pu||{});mt.Helvetica;const hu={id:mt.Helvetica,family:"Helvetica",bold:!1,italic:!1,label:"Helvetica",css:"Helvetica, Arial, sans-serif"},ts=Object.freeze([{id:mt.Courier,family:"Courier",bold:!1,italic:!1,label:"Courier",css:"Courier, monospace"},{id:mt.Courier_Bold,family:"Courier",bold:!0,italic:!1,label:"Courier Bold",css:"Courier, monospace"},{id:mt.Courier_BoldOblique,family:"Courier",bold:!0,italic:!0,label:"Courier Bold Oblique",css:"Courier, monospace"},{id:mt.Courier_Oblique,family:"Courier",bold:!1,italic:!0,label:"Courier Oblique",css:"Courier, monospace"},hu,{id:mt.Helvetica_Bold,family:"Helvetica",bold:!0,italic:!1,label:"Helvetica Bold",css:"Helvetica, Arial, sans-serif"},{id:mt.Helvetica_BoldOblique,family:"Helvetica",bold:!0,italic:!0,label:"Helvetica Bold Oblique",css:"Helvetica, Arial, sans-serif"},{id:mt.Helvetica_Oblique,family:"Helvetica",bold:!1,italic:!0,label:"Helvetica Oblique",css:"Helvetica, Arial, sans-serif"},{id:mt.Times_Roman,family:"Times",bold:!1,italic:!1,label:"Times Roman",css:'"Times New Roman", Times, serif'},{id:mt.Times_Bold,family:"Times",bold:!0,italic:!1,label:"Times Bold",css:'"Times New Roman", Times, serif'},{id:mt.Times_BoldItalic,family:"Times",bold:!0,italic:!0,label:"Times Bold Italic",css:'"Times New Roman", Times, serif'},{id:mt.Times_Italic,family:"Times",bold:!1,italic:!0,label:"Times Italic",css:'"Times New Roman", Times, serif'},{id:mt.Symbol,family:"Symbol",bold:!1,italic:!1,label:"Symbol",css:"Symbol, serif"},{id:mt.ZapfDingbats,family:"ZapfDingbats",bold:!1,italic:!1,label:"Zapf Dingbats",css:"ZapfDingbats, serif"}]),mF=ts.reduce((t,e)=>(t[e.id]=e,t),{}),PF=new Map;for(const t of ts)PF.set(`${t.family}_${t.bold}_${t.italic}`,t.id);function FF(){return hu}function bF(t){return mF[t]??FF()}function ns(t){const e=bF(t);return{fontFamily:e.css,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal"}}Object.values(pu).filter(t=>t!=="Unknown").map(t=>({value:t,label:t})),[...new Set(ts.map(t=>t.family))];const wa=Object.freeze([{id:it.Normal,label:"Normal",css:"normal"},{id:it.Multiply,label:"Multiply",css:"multiply"},{id:it.Screen,label:"Screen",css:"screen"},{id:it.Overlay,label:"Overlay",css:"overlay"},{id:it.Darken,label:"Darken",css:"darken"},{id:it.Lighten,label:"Lighten",css:"lighten"},{id:it.ColorDodge,label:"Color Dodge",css:"color-dodge"},{id:it.ColorBurn,label:"Color Burn",css:"color-burn"},{id:it.HardLight,label:"Hard Light",css:"hard-light"},{id:it.SoftLight,label:"Soft Light",css:"soft-light"},{id:it.Difference,label:"Difference",css:"difference"},{id:it.Exclusion,label:"Exclusion",css:"exclusion"},{id:it.Hue,label:"Hue",css:"hue"},{id:it.Saturation,label:"Saturation",css:"saturation"},{id:it.Color,label:"Color",css:"color"},{id:it.Luminosity,label:"Luminosity",css:"luminosity"}]),gu=wa.reduce((t,e)=>(t[e.id]=e,t),{});wa.reduce((t,e)=>(t[e.css]=e.id,t),{});function _F(t){return gu[t]??gu[it.Normal]}function Oa(t){return _F(t).css}wa.map(t=>({value:t.id,label:t.label})),wa.map(t=>t.id);function os(t){if(t instanceof zo)return{type:"noop"};if(t instanceof rF)return{type:"console"};if(t instanceof iF)return{type:"perf"};if(t instanceof aF){const e=t;return{type:"level",config:{level:e.level,logger:os(e.logger)}}}return t instanceof sF?{type:"all",config:{loggers:t.loggers.map(os)}}:{type:"noop"}}function yF(t){var e;if(typeof((e=globalThis.crypto)==null?void 0:e.getRandomValues)=="function")return globalThis.crypto.getRandomValues(new Uint8Array(t));if(typeof require=="function")try{const{randomBytes:o}=require("crypto");return o(t)}catch{}const n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=Math.floor(Math.random()*256);return n}function pt(){var t;if(typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function")return globalThis.crypto.randomUUID();const e=yF(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=Array.from(e,o=>o.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}class vo extends Ie{constructor(e={}){super(),this.children=new Map,this.childResults=[],this.completedCount=0,this.expectedCount=0,this.isFinalized=!1,this.config={aggregate:e.aggregate??(n=>n),onChildComplete:e.onChildComplete??(()=>{}),failFast:e.failFast??!0}}addChild(e,n){if(this.state.stage!==Wo.Pending)return this.state.stage===Wo.Aborted&&e.abort(this.state.reason),this;const o=n??this.expectedCount;return this.expectedCount=Math.max(this.expectedCount,o+1),this.children.set(e,o),e.wait(r=>this.handleChildSuccess(e,r,o),r=>this.handleChildError(e,r,o)),this}finalize(){return this.isFinalized?this:(this.isFinalized=!0,this.expectedCount===0&&this.resolve(this.config.aggregate([])),this)}handleChildSuccess(e,n,o){if(this.state.stage!==Wo.Pending)return;this.childResults[o]=n,this.completedCount++,this.children.delete(e);const r=this.config.onChildComplete(this.completedCount,this.expectedCount,n,o);if(r!==void 0&&this.progress(r),this.completedCount===this.expectedCount){const a=this.config.aggregate(this.childResults);this.resolve(a)}}handleChildError(e,n,o){if(this.state.stage===Wo.Pending){if(this.children.delete(e),this.config.failFast){for(const[r]of this.children)r.abort("Sibling task failed");this.children.clear(),this.fail(n)}else if(this.childResults[o]=void 0,this.completedCount++,this.completedCount===this.expectedCount){const r=this.config.aggregate(this.childResults);this.resolve(r)}}}abort(e){for(const[n]of this.children)n.abort(e);this.children.clear(),super.abort(e)}reject(e){for(const[n]of this.children)n.abort(e);this.children.clear(),super.reject(e)}getPendingCount(){return this.children.size}getCompletedCount(){return this.completedCount}static gather(e){const n=new vo({aggregate:o=>o,onChildComplete:(o,r)=>({completed:o,total:r})});return e.forEach((o,r)=>n.addChild(o,r)),n.finalize(),n}static gatherIndexed(e){const n=new vo({aggregate:o=>{const r={};return o.forEach((a,i)=>{r[i]=a}),r},onChildComplete:(o,r,a,i)=>({page:i,result:a})});return e.forEach((o,r)=>n.addChild(o,r)),n.finalize(),n}static gatherFrom(e,n){const o=new vo(n);return e.forEach((r,a)=>o.addChild(r,a)),o.finalize(),o}static first(e){let n=!1;const o=new vo({aggregate:r=>r[0],failFast:!1});return o.handleChildSuccess=(r,a)=>{if(!n){n=!0;for(const[i]of o.children)i!==r&&i.abort("Race won by sibling");o.resolve(a)}},e.forEach((r,a)=>o.addChild(r,a)),o.finalize(),o}}function Yt(){}class fu{constructor(){this.dependencyGraph=new Map}addNode(e,n=[]){this.dependencyGraph.set(e,new Set(n))}hasCircularDependencies(){const e=new Set,n=new Set,o=r=>{e.add(r),n.add(r);const a=this.dependencyGraph.get(r)||new Set;for(const i of a)if(e.has(i)){if(n.has(i))return!0}else if(o(i))return!0;return n.delete(r),!1};for(const r of this.dependencyGraph.keys())if(!e.has(r)&&o(r))return!0;return!1}resolveLoadOrder(){if(this.hasCircularDependencies())throw new Error("Circular dependencies detected");const e=[],n=new Set,o=new Set,r=a=>{if(o.has(a))throw new Error("Circular dependency");if(n.has(a))return;o.add(a);const i=this.dependencyGraph.get(a)||new Set;for(const s of i)r(s);o.delete(a),n.add(a),e.push(a)};for(const a of this.dependencyGraph.keys())n.has(a)||r(a);return e}}class Nt extends Error{constructor(e){super(e),this.name="PluginRegistrationError"}}class Ho extends Error{constructor(e){super(e),this.name="PluginNotFoundError"}}class vF extends Error{constructor(e){super(e),this.name="CircularDependencyError"}}class DF extends Error{constructor(e){super(e),this.name="PluginConfigurationError"}}class SF{constructor(e,n){this.store=e,this.pluginId=n}getState(){return this.store.getState().plugins[this.pluginId]}dispatch(e){return this.store.dispatchToPlugin(this.pluginId,e)}subscribeToState(e){return this.store.subscribeToPlugin(this.pluginId,(n,o,r)=>{e(n,o,r)})}onAction(e,n){return this.store.onAction(e,(o,r,a)=>{n(o,r.plugins[this.pluginId],a.plugins[this.pluginId])})}}const ka="START_LOADING_DOCUMENT",mu="UPDATE_DOCUMENT_LOADING_PROGRESS",Ia="SET_DOCUMENT_LOADED",rs="SET_DOCUMENT_ERROR",as="RETRY_LOADING_DOCUMENT",Ga="CLOSE_DOCUMENT",is="SET_ACTIVE_DOCUMENT",ss="REORDER_DOCUMENTS",ls="MOVE_DOCUMENT",cs="UPDATE_DOCUMENT_SECURITY",EF="REFRESH_DOCUMENT",Vo="REFRESH_PAGES",AF="SET_PAGES",La="SET_SCALE",us="SET_ROTATION",xF=[ka,mu,Ia,Ga,is,rs,as,EF,Vo,AF,La,us,"SET_DEFAULT_SCALE","SET_DEFAULT_ROTATION",ss,ls,cs],Pu=(t,e,n,o,r,a,i)=>({type:ka,payload:{documentId:t,name:e,scale:n,rotation:o,passwordProvided:r,autoActivate:a,permissions:i}}),CF=(t,e)=>({type:Ia,payload:{documentId:t,document:e}}),TF=(t,e,n,o)=>({type:rs,payload:{documentId:t,error:e,errorCode:n,errorDetails:o}}),MF=(t,e)=>({type:as,payload:{documentId:t,passwordProvided:e}}),Fu=(t,e)=>({type:Ga,payload:{documentId:t,nextActiveDocumentId:e}}),RF=t=>({type:is,payload:t}),$a=(t,e)=>({type:Vo,payload:{documentId:t,pageIndexes:e}}),wF=(t,e)=>({type:La,payload:{scale:t,documentId:e}}),OF=t=>({type:ss,payload:t}),kF=(t,e)=>({type:ls,payload:{documentId:t,toIndex:e}}),IF=(t,e,n)=>({type:cs,payload:{documentId:t,permissions:e,isOwnerUnlocked:n}});class GF{constructor(e,n){this.initialCoreState=n,this.pluginReducers={},this.listeners=[],this.pluginListeners={},this.isDispatching=!1,this.state={core:n,plugins:{}},this.coreReducer=e}addPluginReducer(e,n,o){this.state.plugins[e]=o,this.pluginReducers[e]=n}dispatchToCore(e){if(!this.coreReducer)return this.getState();if(this.isDispatching)throw new Error("Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.");const n=this.getState();try{this.isDispatching=!0,this.state.core=this.coreReducer(this.state.core,e)}finally{this.isDispatching=!1}return this.listeners.forEach(o=>{const r=this.getState();o(e,r,n)}),this.getState()}dispatchToPlugin(e,n,o=!0){if(this.isDispatching)throw new Error("Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.");const r=this.getState(),a=this.pluginReducers[e];if(!a)return r.plugins[e];const i=r.plugins[e];try{this.isDispatching=!0;const s=a(i,n);this.state.plugins[e]=s}finally{this.isDispatching=!1}return o&&this.listeners.forEach(s=>{const l=this.getState();s(n,l,r)}),this.pluginListeners[e]&&this.pluginListeners[e].forEach(s=>{const l=this.getState().plugins[e];s(n,l,i)}),this.getState().plugins[e]}dispatch(e){if(this.isDispatching)throw new Error("Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.");const n=this.getState();try{this.isDispatching=!0,this.isCoreAction(e)&&(this.state.core=this.coreReducer(this.state.core,e));for(const o in this.pluginReducers){const r=this.pluginReducers[o],a=n.plugins[o];r&&(this.state.plugins[o]=r(a,e))}}finally{this.isDispatching=!1}return this.listeners.forEach(o=>{const r=this.getState();o(e,r,n)}),this.getState()}getState(){if(this.isDispatching)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return{core:{...this.state.core},plugins:{...this.state.plugins}}}subscribe(e){if(this.isDispatching)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state.");return this.listeners.push(e),()=>{if(this.isDispatching)throw new Error("You may not unsubscribe from a store listener while the reducer is executing.");this.listeners=this.listeners.filter(n=>n!==e)}}subscribeToPlugin(e,n){if(!(e in this.state.plugins))throw new Error(`Plugin state not found for plugin "${e}". Did you forget to call addPluginReducer?`);if(this.isDispatching)throw new Error("You may not call store.subscribeToPlugin() while the reducer is executing.");return this.pluginListeners[e]||(this.pluginListeners[e]=[]),this.pluginListeners[e].push(n),()=>{if(this.isDispatching)throw new Error("You may not unsubscribe from a store listener while the reducer is executing.");this.pluginListeners[e]=this.pluginListeners[e].filter(o=>o!==n),this.pluginListeners[e].length===0&&delete this.pluginListeners[e]}}onAction(e,n){return this.subscribe((o,r,a)=>{o.type===e&&n(o,r,a)})}getPluginStore(e){if(!(e in this.state.plugins))throw new Error(`Plugin state not found for plugin "${e}". Did you forget to call addPluginReducer?`);return new SF(this,e)}isCoreAction(e){return xF.includes(e.type)}destroy(){var e,n;this.listeners.length=0;for(const o in this.pluginListeners)(n=(e=this.pluginListeners[o])==null?void 0:e.splice)==null||n.call(e,0);this.pluginListeners={},this.pluginReducers={},this.state.plugins={},this.state.core={...this.initialCoreState}}}const LF=t=>({documents:{},documentOrder:[],activeDocumentId:null,defaultScale:(t==null?void 0:t.defaultScale)??1,defaultRotation:(t==null?void 0:t.defaultRotation)??Er.Degree0,globalPermissions:t==null?void 0:t.permissions});te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality;const $F=[te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality],NF={[te.Print]:"print",[te.ModifyContents]:"modifyContents",[te.CopyContents]:"copyContents",[te.ModifyAnnotations]:"modifyAnnotations",[te.FillForms]:"fillForms",[te.ExtractForAccessibility]:"extractForAccessibility",[te.AssembleDocument]:"assembleDocument",[te.PrintHighQuality]:"printHighQuality"};function bu(t,e){if(!t)return;if(e in t)return t[e];const n=NF[e];if(n&&n in t)return t[n]}function ds(t,e,n){var o;const r=t.documents[e],a=r==null?void 0:r.permissions,i=t.globalPermissions,s=((o=r==null?void 0:r.document)==null?void 0:o.permissions)??te.AllowAll,l=bu(a==null?void 0:a.overrides,n);if(l!==void 0)return l;const c=bu(i==null?void 0:i.overrides,n);return c!==void 0?c:(a==null?void 0:a.enforceDocumentPermissions)??(i==null?void 0:i.enforceDocumentPermissions)??!0?(s&n)!==0:!0}function _u(t,e){return $F.reduce((n,o)=>ds(t,e,o)?n|o:n,0)}function jF(t,e,n){const o=t.activeDocumentId;if(o!==e)return o;if(n!==void 0)return n&&t.documents[n]?n:null;const r=t.documentOrder.indexOf(e);return r===-1?null:r>0?t.documentOrder[r-1]:r<t.documentOrder.length-1?t.documentOrder[r+1]:null}function UF(t,e,n){const o=t.indexOf(e);if(o===-1||n<0||n>=t.length||o===n)return null;const r=[...t];return r.splice(o,1),r.splice(n,0,e),r}const BF=(t,e)=>{switch(e.type){case ka:{const{documentId:n,name:o,scale:r,rotation:a,passwordProvided:i,autoActivate:s=!0,permissions:l}=e.payload,c={id:n,name:o,status:"loading",loadingProgress:0,error:null,document:null,scale:r??t.defaultScale,rotation:a??t.defaultRotation,passwordProvided:i??!1,pageRefreshVersions:{},permissions:l,loadStartedAt:Date.now()};return{...t,documents:{...t.documents,[n]:c},documentOrder:[...t.documentOrder,n],activeDocumentId:s||!t.activeDocumentId?n:t.activeDocumentId}}case mu:{const{documentId:n,progress:o}=e.payload,r=t.documents[n];return!r||r.status!=="loading"?t:{...t,documents:{...t.documents,[n]:{...r,loadingProgress:o}}}}case Ia:{const{documentId:n,document:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,status:"loaded",document:o,error:null,errorCode:void 0,errorDetails:void 0,passwordProvided:void 0,loadedAt:Date.now()}}}:t}case rs:{const{documentId:n,error:o,errorCode:r,errorDetails:a}=e.payload,i=t.documents[n];return i?{...t,documents:{...t.documents,[n]:{...i,status:"error",error:o,errorCode:r,errorDetails:a}}}:t}case as:{const{documentId:n,passwordProvided:o}=e.payload,r=t.documents[n];return!r||r.status!=="error"?t:{...t,documents:{...t.documents,[n]:{...r,status:"loading",loadingProgress:0,error:null,errorCode:void 0,errorDetails:void 0,passwordProvided:o??!1,loadStartedAt:Date.now()}}}}case Ga:{const{documentId:n,nextActiveDocumentId:o}=e.payload,{[n]:r,...a}=t.documents;return{...t,documents:a,documentOrder:t.documentOrder.filter(i=>i!==n),activeDocumentId:jF(t,n,o)}}case ls:{const{documentId:n,toIndex:o}=e.payload,r=UF(t.documentOrder,n,o);return r?{...t,documentOrder:r}:t}case ss:return{...t,documentOrder:e.payload};case is:return{...t,activeDocumentId:e.payload};case La:{const{scale:n,documentId:o}=e.payload,r=o??t.activeDocumentId;if(!r)return t;const a=t.documents[r];return a?{...t,documents:{...t.documents,[r]:{...a,scale:n}}}:t}case us:{const{rotation:n,documentId:o}=e.payload,r=o??t.activeDocumentId;if(!r)return t;const a=t.documents[r];return a?{...t,documents:{...t.documents,[r]:{...a,rotation:n}}}:t}case Vo:{const{documentId:n,pageIndexes:o}=e.payload,r=t.documents[n];if(!r)return t;const a={...r.pageRefreshVersions};for(const i of o)a[i]=(a[i]||0)+1;return{...t,documents:{...t.documents,[n]:{...r,pageRefreshVersions:a}}}}case cs:{const{documentId:n,permissions:o,isOwnerUnlocked:r}=e.payload,a=t.documents[n];return a!=null&&a.document?{...t,documents:{...t.documents,[n]:{...a,document:{...a.document,permissions:o,isOwnerUnlocked:r}}}}:t}default:return t}};class zF{constructor(e,n){this.plugins=new Map,this.manifests=new Map,this.capabilities=new Map,this.status=new Map,this.configurations=new Map,this.initPromise=null,this.pendingRegistrations=[],this.processingRegistrations=[],this.initialized=!1,this.isInitializing=!1,this.pluginsReadyPromise=null,this.destroyed=!1,this.resolver=new fu,this.engine=e,this.initialCoreState=LF(n),this.store=new GF(BF,this.initialCoreState),this.logger=(n==null?void 0:n.logger)??new zo}getLogger(){return this.logger}registerPlugin(e,n){if(this.initialized&&!this.isInitializing)throw new Nt("Cannot register plugins after initialization");this.validateManifest(e.manifest),this.store.addPluginReducer(e.manifest.id,e.reducer,typeof e.initialState=="function"?e.initialState(this.initialCoreState,{...e.manifest.defaultConfig,...n}):e.initialState),this.pendingRegistrations.push({package:e,config:n})}getStore(){return this.store}getEngine(){return this.engine}pluginsReady(){return this.pluginsReadyPromise?this.pluginsReadyPromise:(this.pluginsReadyPromise=(async()=>{this.initialized||await this.initialize();const e=Array.from(this.plugins.values()).map(n=>typeof n.ready=="function"?n.ready():Promise.resolve());await Promise.all(e)})(),this.pluginsReadyPromise)}async initialize(){if(this.destroyed)throw new Nt("Registry has been destroyed");return this.initPromise?this.initPromise:(this.initPromise=(async()=>{if(this.initialized)throw new Nt("Registry is already initialized");this.isInitializing=!0;try{if(this.destroyed)return;for(;this.pendingRegistrations.length>0;){if(this.destroyed)return;this.processingRegistrations=[...this.pendingRegistrations],this.pendingRegistrations=[];for(const n of this.processingRegistrations){const o=new Set,r=[...n.package.manifest.requires,...n.package.manifest.optional];for(const a of r){const i=this.processingRegistrations.find(s=>s.package.manifest.provides.includes(a));i&&o.add(i.package.manifest.id)}this.resolver.addNode(n.package.manifest.id,[...o])}const e=this.resolver.resolveLoadOrder();for(const n of e){const o=this.processingRegistrations.find(r=>r.package.manifest.id===n);this.instantiatePlugin(o.package.manifest,o.package.create,o.config)}for(const n of e)await this.runPluginInitialization(n);this.processingRegistrations=[],this.resolver=new fu}this.initialized=!0}catch(e){throw e instanceof Error?new vF(`Failed to resolve plugin dependencies: ${e.message}`):e}finally{this.isInitializing=!1}})(),this.initPromise)}instantiatePlugin(e,n,o){const r={...e.defaultConfig,...o};this.validateConfig(e.id,r,e.defaultConfig);const a=n(this,r);this.validatePlugin(a);for(const i of e.provides){if(this.capabilities.has(i))throw new Nt(`Capability ${i} is already provided by plugin ${this.capabilities.get(i)}`);this.capabilities.set(i,e.id)}this.plugins.set(e.id,a),this.manifests.set(e.id,e),this.status.set(e.id,"registered"),this.configurations.set(e.id,r)}async runPluginInitialization(e){const n=this.plugins.get(e);if(!n)return;const o=this.manifests.get(e),r=this.configurations.get(e);for(const a of o.requires)if(!this.capabilities.has(a))throw new Nt(`Missing required capability: ${a} for plugin ${e}`);this.logger.debug("PluginRegistry","InitializePlugin",`Initializing plugin ${e}`);try{n.initialize&&await n.initialize(r),this.status.set(e,"active"),this.logger.info("PluginRegistry","PluginInitialized",`Plugin ${e} initialized successfully`)}catch(a){throw this.status.set(e,"error"),this.logger.error("PluginRegistry","InitializationFailed",`Plugin ${e} initialization failed`,{error:a}),a}}getPluginConfig(e){const n=this.configurations.get(e);if(!n)throw new Ho(`Configuration for plugin ${e} not found`);return n}validateConfig(e,n,o){const a=Object.keys(o).filter(i=>!n.hasOwnProperty(i));if(a.length>0)throw new DF(`Missing required configuration keys for plugin ${e}: ${a.join(", ")}`)}async updatePluginConfig(e,n){const o=this.getPlugin(e);if(!o)throw new Ho(`Plugin ${e} not found`);const r=this.manifests.get(e),a=this.configurations.get(e);if(!r||!a)throw new Ho(`Plugin ${e} not found`);const i={...a,...n};this.validateConfig(e,i,r.defaultConfig),this.configurations.set(e,i),o.initialize&&await o.initialize(i)}registerPluginBatch(e){for(const n of e)this.registerPlugin(n.package,n.config)}async unregisterPlugin(e){const n=this.plugins.get(e);if(!n)throw new Ho(`Plugin ${e} is not registered`);const o=this.manifests.get(e);if(!o)throw new Ho(`Manifest for plugin ${e} not found`);for(const[r,a]of this.manifests.entries()){if(r===e)continue;if([...a.requires,...a.optional].some(s=>o.provides.includes(s)))throw new Nt(`Cannot unregister plugin ${e}: plugin ${r} depends on it`)}try{n.destroy&&await n.destroy();for(const r of o.provides)this.capabilities.delete(r);this.plugins.delete(e),this.manifests.delete(e),this.status.delete(e)}catch(r){throw r instanceof Error?new Error(`Failed to unregister plugin ${e}: ${r.message}`):r}}getPlugin(e){const n=this.plugins.get(e);return n||null}getCapabilityProvider(e){const n=this.capabilities.get(e);return n?this.getPlugin(n):null}hasCapability(e){return this.capabilities.has(e)}getAllPlugins(){return Array.from(this.plugins.values())}getPluginStatus(e){const n=this.status.get(e);if(!n)throw new Ho(`Plugin ${e} not found`);return n}validatePlugin(e){if(!e.id)throw new Nt("Plugin must have an id")}validateManifest(e){if(!e.id)throw new Nt("Manifest must have an id");if(!e.name)throw new Nt("Manifest must have a name");if(!e.version)throw new Nt("Manifest must have a version");if(!Array.isArray(e.provides))throw new Nt("Manifest must have a provides array");if(!Array.isArray(e.requires))throw new Nt("Manifest must have a requires array");if(!Array.isArray(e.optional))throw new Nt("Manifest must have an optional array")}isDestroyed(){return this.destroyed}async destroy(){var e;if(this.destroyed)throw new Nt("Registry has already been destroyed");this.destroyed=!0;try{await this.initPromise}catch{}for(const n of Array.from(this.plugins.values()).reverse())await((e=n.destroy)==null?void 0:e.call(n));this.store.destroy(),this.plugins.clear(),this.manifests.clear(),this.capabilities.clear(),this.status.clear(),this.pendingRegistrations.length=0,this.processingRegistrations.length=0}}function WF(t){return"autoMountElements"in t&&typeof t.autoMountElements=="function"}class jt{constructor(e,n){if(this.id=e,this.registry=n,this.cooldownActions={},this.debouncedTimeouts={},this.unsubscribeFromState=null,this.unsubscribeFromCoreStore=null,this.unsubscribeFromStartLoadingDocument=null,this.unsubscribeFromSetDocumentLoaded=null,this.unsubscribeFromCloseDocument=null,this.unsubscribeFromSetScale=null,this.unsubscribeFromSetRotation=null,e!==this.constructor.id)throw new Error(`Plugin ID mismatch: ${e} !== ${this.constructor.id}`);this.engine=this.registry.getEngine(),this.logger=this.registry.getLogger(),this.coreStore=this.registry.getStore(),this.pluginStore=this.coreStore.getPluginStore(this.id),this.unsubscribeFromState=this.pluginStore.subscribeToState((o,r,a)=>{this.onStoreUpdated(a,r)}),this.unsubscribeFromCoreStore=this.coreStore.subscribe((o,r,a)=>{this.onCoreStoreUpdated(a,r),r.core.activeDocumentId!==a.core.activeDocumentId&&this.onActiveDocumentChanged(a.core.activeDocumentId,r.core.activeDocumentId)}),this.unsubscribeFromStartLoadingDocument=this.coreStore.onAction(ka,o=>{this.onDocumentLoadingStarted(o.payload.documentId)}),this.unsubscribeFromSetDocumentLoaded=this.coreStore.onAction(Ia,o=>{this.onDocumentLoaded(o.payload.documentId)}),this.unsubscribeFromCloseDocument=this.coreStore.onAction(Ga,o=>{this.onDocumentClosed(o.payload.documentId)}),this.unsubscribeFromSetScale=this.coreStore.onAction(La,(o,r)=>{const a=o.payload.documentId??r.core.activeDocumentId;a&&this.onScaleChanged(a,o.payload.scale)}),this.unsubscribeFromSetRotation=this.coreStore.onAction(us,(o,r)=>{const a=o.payload.documentId??r.core.activeDocumentId;a&&this.onRotationChanged(a,o.payload.rotation)}),this.readyPromise=new Promise(o=>{this.readyResolve=o}),this.readyResolve()}provides(){if(!this._capability){const e=this.buildCapability();this._capability=Object.freeze(e)}return this._capability}get state(){return this.pluginStore.getState()}get coreState(){return this.coreStore.getState()}getState(){return this.pluginStore.getState()}getCoreState(){return this.coreStore.getState()}dispatchCoreAction(e){return this.coreStore.dispatchToCore(e)}dispatchToAllPlugins(e){return this.coreStore.dispatch(e)}dispatch(e){return this.pluginStore.dispatch(e)}cooldownDispatch(e,n=100){const o=Date.now(),r=this.cooldownActions[e.type]||0;return o-r>=n?(this.cooldownActions[e.type]=o,this.dispatch(e),!0):!1}debouncedDispatch(e,n=100){const o=e.type;this.debouncedTimeouts[o]&&clearTimeout(this.debouncedTimeouts[o]),this.debouncedTimeouts[o]=setTimeout(()=>{this.dispatch(e),delete this.debouncedTimeouts[o]},n)}cancelDebouncedDispatch(e){this.debouncedTimeouts[e]&&(clearTimeout(this.debouncedTimeouts[e]),delete this.debouncedTimeouts[e])}subscribe(e){return this.pluginStore.subscribeToState(e)}subscribeToCoreStore(e){return this.coreStore.subscribe(e)}onStoreUpdated(e,n){}onCoreStoreUpdated(e,n){}onDocumentLoadingStarted(e){}onDocumentLoaded(e){}onDocumentClosed(e){}onActiveDocumentChanged(e,n){}onScaleChanged(e,n){}onRotationChanged(e,n){}destroy(){Object.values(this.debouncedTimeouts).forEach(e=>{clearTimeout(e)}),this.debouncedTimeouts={},this.unsubscribeFromState&&(this.unsubscribeFromState(),this.unsubscribeFromState=null),this.unsubscribeFromCoreStore&&(this.unsubscribeFromCoreStore(),this.unsubscribeFromCoreStore=null),this.unsubscribeFromStartLoadingDocument&&(this.unsubscribeFromStartLoadingDocument(),this.unsubscribeFromStartLoadingDocument=null),this.unsubscribeFromSetDocumentLoaded&&(this.unsubscribeFromSetDocumentLoaded(),this.unsubscribeFromSetDocumentLoaded=null),this.unsubscribeFromCloseDocument&&(this.unsubscribeFromCloseDocument(),this.unsubscribeFromCloseDocument=null),this.unsubscribeFromSetScale&&(this.unsubscribeFromSetScale(),this.unsubscribeFromSetScale=null),this.unsubscribeFromSetRotation&&(this.unsubscribeFromSetRotation(),this.unsubscribeFromSetRotation=null)}ready(){return this.readyPromise}markReady(){this.readyResolve()}resetReady(){this.readyPromise=new Promise(e=>{this.readyResolve=e})}getActiveDocumentId(){const e=this.coreState.core.activeDocumentId;if(!e)throw new Error("No active document");return e}getActiveDocumentIdOrNull(){return this.coreState.core.activeDocumentId}getCoreDocument(e){const n=e??this.getActiveDocumentIdOrNull();return n?this.coreState.core.documents[n]??null:null}getCoreDocumentOrThrow(e){const n=this.getCoreDocument(e);if(!n)throw new Error(`Document not found: ${e??"active"}`);return n}getDocumentPermissions(e){const n=e??this.coreState.core.activeDocumentId;return n?_u(this.coreState.core,n):te.AllowAll}checkPermission(e,...n){const o=e??this.coreState.core.activeDocumentId;return o?n.every(r=>ds(this.coreState.core,o,r)):!0}requirePermission(e,...n){const o=e??this.coreState.core.activeDocumentId;if(!o)return;const r=[];for(const a of n)ds(this.coreState.core,o,a)||r.push(a);if(r.length>0){const a=_u(this.coreState.core,o);throw new pF(r,a)}}}class Na{constructor(e,n){this.handler=e,this.options=n,this.lastRun=0,this.handle=o=>{this.options.mode==="debounce"?this.debounce(o):this.throttle(o)}}debounce(e){this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.handler(e),this.timeoutId=void 0},this.options.wait)}throttle(e){if(this.options.mode==="debounce")return;const n=Date.now(),o=this.options.throttleMode||"leading-trailing";n-this.lastRun>=this.options.wait&&(o==="leading-trailing"&&this.handler(e),this.lastRun=n),this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.handler(e),this.lastRun=Date.now(),this.timeoutId=void 0},this.options.wait-(n-this.lastRun))}destroy(){this.timeoutId&&window.clearTimeout(this.timeoutId)}}class ps{constructor(e,n){this.handler=e,this.options=n,this.controls=new Map,this.handle=o=>{const r=String(this.options.keyExtractor(o));let a=this.controls.get(r);a||(a=new Na(this.handler,this.baseOptions),this.controls.set(r,a)),a.handle(o)},this.baseOptions={mode:n.mode,wait:n.wait,...n.mode==="throttle"&&"throttleMode"in n?{throttleMode:n.throttleMode}:{}}}destroy(){for(const e of this.controls.values())e.destroy();this.controls.clear()}}function hs(t){return"keyExtractor"in t}function et(t,e,n){return t<e?e:t>n?n:t}function Cr(t,e,n){if(t===e)return!0;if(t==null||e==null)return t===e;const o=typeof t;if(o!==typeof e)return!1;if(o==="object"){n||(n=new Set);const a=HF(t,e);if(n.has(a))return!0;n.add(a);const i=Array.isArray(t),s=Array.isArray(e);return i&&s?YF(t,e,n):!i&&!s?qF(t,e,n):!1}return!1}function HF(t,e){return`${yu(t)}__${yu(e)}`}let VF=0;const gs=new WeakMap;function yu(t){return gs.has(t)||gs.set(t,++VF),gs.get(t)}function YF(t,e,n){if(t.length!==e.length)return!1;const o=new Array(e.length).fill(!1);e:for(let r=0;r<t.length;r++){const a=t[r];for(let i=0;i<e.length;i++)if(!o[i]&&Cr(a,e[i],n)){o[i]=!0;continue e}return!1}return!0}function qF(t,e,n){const o=Object.keys(t).sort(),r=Object.keys(e).sort();if(o.length!==r.length)return!1;for(let a=0;a<o.length;a++)if(o[a]!==r[a])return!1;for(const a of o){const i=t[a],s=e[a];if(!Cr(i,s,n))return!1}return!0}function $n(){const t=new Set;return{emit:(n=void 0)=>t.forEach(o=>o(n)),on:n=>(t.add(n),()=>t.delete(n)),off:n=>t.delete(n),clear:()=>t.clear()}}function Be(t,e=Cr){const n=new Set,o=new Map;let r=t;const a=s=>n.forEach(l=>l(s)),i=(s,l)=>{let c=s,u=()=>{};if(l){if(hs(l)){const d=new ps(s,l);c=d.handle,u=()=>d.destroy()}else{const d=new Na(s,l);c=d.handle,u=()=>d.destroy()}o.set(s,{wrapped:c,destroy:u})}return r!==void 0&&c(r),n.add(c),()=>{n.delete(c),u(),o.delete(s)}};return{get value(){return r},emit(s=void 0){(r===void 0||!e(r,s))&&(r=s,a(s))},on:i,off(s){const l=o.get(s);l?(n.delete(l.wrapped),l.destroy(),o.delete(s)):n.delete(s)},clear(){n.clear(),o.forEach(s=>s.destroy()),o.clear()},select(s,l=Cr){return(c,u)=>{let d;if(r!==void 0){const p=s(r);d=p,c(p)}return i(p=>{const h=s(p);(d===void 0||!l(d,h))&&(d=h,c(h))},u)}}}}function Tt(t,e){const n=(e==null?void 0:e.cache)??!0,o=(e==null?void 0:e.equality)??Cr,r=new Map,a=new Map,i=new Map,s=new Set,l=new Map,c=h=>String(h),u=h=>{let g=a.get(h);return g||(g=new Set,a.set(h,g)),g},d=h=>{let g=i.get(h);return g||(g=new Map,i.set(h,g)),g};return{emit(h,g){const f=c(h);if(n){const y=r.get(f);if(y!==void 0&&o(y,g))return;r.set(f,g)}const F=a.get(f);F&&F.forEach(y=>y(g));const _=t(h,g);s.forEach(y=>y(_))},forScope(h){const g=c(h);return(f,F)=>{const _=u(g),y=d(g);let E=f,A=()=>{};if(F){if(hs(F)){const T=new ps(f,F);E=T.handle,A=()=>T.destroy()}else{const T=new Na(f,F);E=T.handle,A=()=>T.destroy()}y.set(f,{wrapped:E,destroy:A})}if(n){const T=r.get(g);T!==void 0&&E(T)}return _.add(E),()=>{_.delete(E),A(),y.delete(f),_.size===0&&a.delete(g),y.size===0&&i.delete(g)}}},onGlobal:(h,g)=>{let f=h,F=()=>{};if(g){if(hs(g)){const _=new ps(h,g);f=_.handle,F=()=>_.destroy()}else{const _=new Na(h,g);f=_.handle,F=()=>_.destroy()}l.set(h,{wrapped:f,destroy:F})}return s.add(f),()=>{s.delete(f),F(),l.delete(h)}},getValue(h){return n?r.get(c(h)):void 0},getScopes(){return n?Array.from(r.keys()):Array.from(a.keys())},clearScope(h){const g=c(h);n&&r.delete(g);const f=a.get(g);f&&(f.clear(),a.delete(g));const F=i.get(g);F&&(F.forEach(_=>_.destroy()),F.clear(),i.delete(g))},clear(){n&&r.clear(),a.forEach(h=>h.clear()),a.clear(),i.forEach(h=>{h.forEach(g=>g.destroy()),h.clear()}),i.clear(),s.clear(),l.forEach(h=>h.destroy()),l.clear()}}}class KF{constructor(e){this.autoMountElements=[],this.package=e}addUtility(e){return this.autoMountElements.push({component:e,type:"utility"}),this}addWrapper(e){return this.autoMountElements.push({component:e,type:"wrapper"}),this}build(){return{...this.package,autoMountElements:()=>this.autoMountElements}}}function Tr(t){return new KF(t)}const vu=Symbol("pdfKey");function Du(){const t=Po(vu);if(!t)throw new Error("useRegistry must be used inside <EmbedPDF>");return t}function Su(){const{coreState:t}=Du();return t}function Dn(t){const e=Su();return P(()=>{const o=e.value,r=$t(t);return!o||!r?null:o.documents[r]??null})}te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality;const XF=[te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality],ZF={[te.Print]:"print",[te.ModifyContents]:"modifyContents",[te.CopyContents]:"copyContents",[te.ModifyAnnotations]:"modifyAnnotations",[te.FillForms]:"fillForms",[te.ExtractForAccessibility]:"extractForAccessibility",[te.AssembleDocument]:"assembleDocument",[te.PrintHighQuality]:"printHighQuality"};function Eu(t,e){if(!t)return;if(e in t)return t[e];const n=ZF[e];if(n&&n in t)return t[n]}function fs(t,e,n){var o;const r=t.documents[e],a=r==null?void 0:r.permissions,i=t.globalPermissions,s=((o=r==null?void 0:r.document)==null?void 0:o.permissions)??te.AllowAll,l=Eu(a==null?void 0:a.overrides,n);if(l!==void 0)return l;const c=Eu(i==null?void 0:i.overrides,n);return c!==void 0?c:(a==null?void 0:a.enforceDocumentPermissions)??(i==null?void 0:i.enforceDocumentPermissions)??!0?(s&n)!==0:!0}function QF(t,e){return XF.reduce((n,o)=>fs(t,e,o)?n|o:n,0)}function ms(t){const e=Su();return P(()=>{var n,o;const r=$t(t),a=e.value;if(!a)return{permissions:te.AllowAll,pdfPermissions:te.AllowAll,hasPermission:()=>!0,hasAllPermissions:()=>!0,canPrint:!0,canModifyContents:!0,canCopyContents:!0,canModifyAnnotations:!0,canFillForms:!0,canExtractForAccessibility:!0,canAssembleDocument:!0,canPrintHighQuality:!0};const i=QF(a,r),s=((o=(n=a.documents[r])==null?void 0:n.document)==null?void 0:o.permissions)??te.AllowAll,l=u=>fs(a,r,u);return{permissions:i,pdfPermissions:s,hasPermission:l,hasAllPermissions:(...u)=>u.every(d=>fs(a,r,d)),canPrint:l(te.Print),canModifyContents:l(te.ModifyContents),canCopyContents:l(te.CopyContents),canModifyAnnotations:l(te.ModifyAnnotations),canFillForms:l(te.FillForms),canExtractForAccessibility:l(te.ExtractForAccessibility),canAssembleDocument:l(te.AssembleDocument),canPrintHighQuality:l(te.PrintHighQuality)}})}function Nn(t){const{registry:e}=Du(),n=ln(null),o=Q(!0),r=Q(new Promise(()=>{})),a=()=>{var i;if(!e.value)return;const s=e.value.getPlugin(t);if(!s)throw new Error(`Plugin ${t} not found`);n.value=s,o.value=!1,r.value=((i=s.ready)==null?void 0:i.call(s))??Promise.resolve()};return Lo(a),Se(e,a),{plugin:n,isLoading:o,ready:r}}function It(t){const{plugin:e,isLoading:n,ready:o}=Nn(t);return{provides:P(()=>{if(!e.value)return null;if(!e.value.provides)throw new Error(`Plugin ${t} does not implement provides()`);return e.value.provides()}),isLoading:n,ready:o}}const JF=ie({__name:"nested-wrapper",props:{wrappers:{},utilities:{}},setup(t){return(e,n)=>{const o=Rm("NestedWrapper",!0);return v(),he(Fn(t.wrappers[0]),null,{default:We(()=>[t.wrappers.length>1?(v(),he(o,{key:0,wrappers:t.wrappers.slice(1),utilities:t.utilities},{default:We(()=>[$e(e.$slots,"default")]),_:3},8,["wrappers","utilities"])):(v(),C(pe,{key:1},[$e(e.$slots,"default"),(v(!0),C(pe,null,tt(t.utilities,(r,a)=>(v(),he(Fn(r),{key:`utility-${a}`}))),128))],64))]),_:3})}}}),eb=ie({__name:"auto-mount",props:{plugins:{}},setup(t){const e=t,n=P(()=>{const o=[],r=[];for(const a of e.plugins){const i=a.package;if(WF(i)){const s=i.autoMountElements()||[];for(const l of s)l.type==="utility"?o.push(l.component):l.type==="wrapper"&&r.push(l.component)}}return{utilities:o,wrappers:r}});return(o,r)=>n.value.wrappers.length>0?(v(),he(JF,{key:0,wrappers:n.value.wrappers,utilities:n.value.utilities},{default:We(()=>[$e(o.$slots,"default")]),_:3},8,["wrappers","utilities"])):(v(),C(pe,{key:1},[$e(o.$slots,"default"),(v(!0),C(pe,null,tt(n.value.utilities,(a,i)=>(v(),he(Fn(a),{key:`utility-${i}`}))),128))],64))}}),tb=ie({__name:"embed-pdf",props:{engine:{},config:{},logger:{},plugins:{},onInitialized:{},autoMountDomElements:{type:Boolean,default:!0}},setup(t){const e=t,n=ln(null),o=Q(null),r=Q(!0),a=Q(!1),i=P(()=>{var d;return((d=o.value)==null?void 0:d.activeDocumentId)??null}),s=P(()=>{var d;return((d=o.value)==null?void 0:d.documents)??{}}),l=P(()=>{var d;return((d=o.value)==null?void 0:d.documentOrder)??[]}),c=P(()=>{const d=i.value,p=s.value;return d&&p[d]?p[d]:null}),u=P(()=>{const d=s.value;return l.value.map(h=>d[h]).filter(h=>h!=null)});return da(vu,{registry:n,coreState:o,isInitializing:r,pluginsReady:a,activeDocumentId:i,activeDocument:c,documents:s,documentStates:u}),Lo(async()=>{var d,p;const h={...e.config,logger:((d=e.config)==null?void 0:d.logger)??e.logger},g=new zF(e.engine,h);if(g.registerPluginBatch(e.plugins),await g.initialize(),g.isDestroyed())return;const f=g.getStore();o.value=f.getState().core;const F=f.subscribe((_,y,E)=>{f.isCoreAction(_)&&y.core!==E.core&&(o.value=y.core)});if(await((p=e.onInitialized)==null?void 0:p.call(e,g)),g.isDestroyed()){F();return}n.value=g,r.value=!1,g.pluginsReady().then(()=>{g.isDestroyed()||(a.value=!0)}),mr(()=>{var _;F(),(_=n.value)==null||_.destroy()})}),(d,p)=>a.value&&t.autoMountDomElements?(v(),he(eb,{key:0,plugins:t.plugins},{default:We(()=>[$e(d.$slots,"default",{registry:n.value,coreState:o.value,isInitializing:r.value,pluginsReady:a.value,activeDocumentId:i.value,activeDocument:c.value,documents:s.value,documentStates:u.value})]),_:3},8,["plugins"])):$e(d.$slots,"default",{key:1,registry:n.value,coreState:o.value,isInitializing:r.value,pluginsReady:a.value,activeDocumentId:i.value,activeDocument:c.value,documents:s.value,documentStates:u.value})}}),Au="annotation",nb={id:Au,name:"Annotation Plugin",version:"1.0.0",provides:["annotation"],requires:["interaction-manager","selection"],optional:["history","scroll"],defaultConfig:{autoCommit:!0,annotationAuthor:"Guest",deactivateToolAfterCreate:!1,selectAfterCreate:!0,autoOpenLinks:!0}},xu="ANNOTATION/INIT_STATE",Cu="ANNOTATION/CLEANUP_STATE",ob="ANNOTATION/SET_ACTIVE_DOCUMENT",Tu="ANNOTATION/SET_ANNOTATIONS",Mu="ANNOTATION/SELECT_ANNOTATION",Ru="ANNOTATION/DESELECT_ANNOTATION",wu="ANNOTATION/ADD_TO_SELECTION",Ou="ANNOTATION/REMOVE_FROM_SELECTION",ku="ANNOTATION/SET_SELECTION",Iu="ANNOTATION/SET_ACTIVE_TOOL_ID",Gu="ANNOTATION/CREATE_ANNOTATION",Lu="ANNOTATION/PATCH_ANNOTATION",$u="ANNOTATION/MOVE_ANNOTATION",Nu="ANNOTATION/DELETE_ANNOTATION",ju="ANNOTATION/COMMIT",Uu="ANNOTATION/PURGE_ANNOTATION",Bu="ANNOTATION/SET_LOCKED",zu="ANNOTATION/SYNC_OBJECT",Wu="ANNOTATION/ADD_COLOR_PRESET",Hu="ANNOTATION/SET_TOOL_DEFAULTS",Vu="ANNOTATION/ADD_TOOL";function rb(t,e){return{type:xu,payload:{documentId:t,state:e}}}function ab(t){return{type:Cu,payload:t}}const ib=(t,e)=>({type:Tu,payload:{documentId:t,annotations:e}}),sb=(t,e,n)=>({type:Mu,payload:{documentId:t,pageIndex:e,id:n}}),Ps=t=>({type:Ru,payload:{documentId:t}}),Fs=(t,e,n)=>({type:wu,payload:{documentId:t,pageIndex:e,id:n}}),Yu=(t,e)=>({type:Ou,payload:{documentId:t,id:e}}),bs=(t,e)=>({type:ku,payload:{documentId:t,ids:e}}),qu=(t,e)=>({type:Iu,payload:{documentId:t,toolId:e}}),ja=(t,e,n)=>({type:Gu,payload:{documentId:t,pageIndex:e,annotation:n}}),Ua=(t,e,n,o)=>({type:Lu,payload:{documentId:t,pageIndex:e,id:n,patch:o}}),Ku=(t,e,n,o)=>({type:$u,payload:{documentId:t,pageIndex:e,id:n,patch:o}}),_s=(t,e,n)=>({type:Nu,payload:{documentId:t,pageIndex:e,id:n}}),lb=(t,e)=>({type:ju,payload:{documentId:t,committedUids:e}}),ys=(t,e,n)=>({type:Uu,payload:{documentId:t,pageIndex:e,uid:n}}),cb=(t,e)=>({type:Bu,payload:{documentId:t,mode:e}}),ub=(t,e,n)=>({type:zu,payload:{documentId:t,id:e,patch:n}}),db=t=>({type:Wu,payload:t}),pb=(t,e)=>({type:Hu,payload:{toolId:t,patch:e}}),hb=t=>({type:Vu,payload:t});var jn=(t=>(t.None="none",t.All="all",t.Include="include",t.Exclude="exclude",t))(jn||{});function gb(t,e){return!(t.origin.x+t.size.width<e.origin.x||e.origin.x+e.size.width<t.origin.x||t.origin.y+t.size.height<e.origin.y||e.origin.y+e.size.height<t.origin.y)}function fb(t){return t.object.type===M.INK}function mb(t){return t.object.type===M.CIRCLE}function Pb(t){return t.object.type===M.POLYGON}function Fb(t){return t.object.type===M.SQUARE}function bb(t){return t.object.type===M.LINE}function _b(t){return t.object.type===M.POLYLINE}function yb(t){return t.object.type===M.HIGHLIGHT}function vb(t){return t.object.type===M.UNDERLINE}function Db(t){return t.object.type===M.STRIKEOUT}function Sb(t){return t.object.type===M.SQUIGGLY}function Eb(t){return yb(t)||vb(t)||Db(t)||Sb(t)}function Ab(t){return t.object.type===M.FREETEXT}function xb(t){return t.object.type===M.STAMP}function Xu(t){return t.object.type===M.TEXT}function Cb(t){return t.object.type===M.REDACT}function Tb(t){return t.object.type===M.CARET}function Mb(t){return t.object.type===M.WIDGET}function vs(t){return Xu(t)&&!t.object.inReplyToId||Eb(t)||fb(t)||Fb(t)||mb(t)||Pb(t)||bb(t)||_b(t)||Ab(t)||xb(t)||Cb(t)||Tb(t)}function Rb(t){return vs(t)||Mb(t)}function Ds(t){return(t==null?void 0:t.categories)??[]}function Ba(t,e){switch(e.type){case jn.None:return!1;case jn.All:return!0;case jn.Include:return t.length===0?!1:t.some(n=>e.categories.includes(n));case jn.Exclude:return t.length===0?!0:!t.some(n=>e.categories.includes(n))}}function Zu(t){var e;return((e=t.flags)==null?void 0:e.includes("locked"))??!1}const wb=(t,e)=>(t.pages[e]??[]).map(n=>t.byUid[n]),Ob=t=>t.selectedUids.length>0?t.byUid[t.selectedUids[0]]??null:null,Qu=t=>t.selectedUids.map(e=>t.byUid[e]).filter(e=>e!==void 0),Ju=t=>t.selectedUids,kb=(t,e)=>t.byUid[e]??null,Ib=t=>{const e={};for(const a of Object.values(t.pages))for(const i of a){const s=t.byUid[i];if(s&&Xu(s)){const l=s.object.inReplyToId;l&&(e[l]||(e[l]=[])).push(s)}}const n={},o=new Set;for(const a of Object.values(t.pages))for(const i of a){const s=t.byUid[i];if(s&&s.object.inReplyToId&&s.object.replyType===Ln.Group&&s.object.type!==M.LINK&&vs(s)){const l=s.object.inReplyToId;(n[l]||(n[l]=[])).push(s),o.add(s.object.id)}}const r={};for(const[a,i]of Object.entries(t.pages)){const s=Number(a),l=[];for(const c of i){const u=t.byUid[c];if(!u||!vs(u)||o.has(u.object.id))continue;const d=n[u.object.id];l.push({page:s,annotation:u,replies:e[u.object.id]??[],...d&&d.length>0?{groupMembers:d}:{}})}l.length>0&&(r[s]=l)}return r},Gb=t=>{const e=Ib(t),n=[],o=Object.keys(e).map(Number).sort((r,a)=>r-a);for(const r of o)n.push(...e[r]);return n},Lb=(t,e)=>{const n=[];for(const o of Object.values(t.pages))for(const r of o){const a=t.byUid[r];a&&"inReplyToId"in a.object&&a.object.inReplyToId===e&&n.push({id:a.object.id,pageIndex:a.object.pageIndex})}return n},$b=(t,e,n)=>{const o=[];for(const r of Object.values(t.pages))for(const a of r){const i=t.byUid[a];i&&"inReplyToId"in i.object&&i.object.inReplyToId===e&&n.includes(i.object.type)&&o.push(i)}return o},Nb=(t,e)=>$b(t,e,[M.LINK]),jb=(t,e)=>{const n=t.byUid[e];if(n)return n.object.inReplyToId&&n.object.replyType===Ln.Group?n.object.inReplyToId:e},ed=(t,e)=>{const n=jb(t,e);if(!n)return[];const o=[],r=t.byUid[n];r&&r.object.type!==M.LINK&&o.push(r);for(const a of Object.values(t.pages))for(const i of a){const s=t.byUid[i];s&&s.object.inReplyToId===n&&s.object.replyType===Ln.Group&&s.object.type!==M.LINK&&o.push(s)}return o},td=(t,e)=>{const n=t.byUid[e];if(!n||n.object.type===M.LINK)return!1;if(n.object.inReplyToId&&n.object.replyType===Ln.Group)return!0;for(const o of Object.values(t.pages))for(const r of o){const a=t.byUid[r];if(a&&a.object.inReplyToId===e&&a.object.replyType===Ln.Group&&a.object.type!==M.LINK)return!0}return!1},Ub=t=>{const e=Qu(t);if(e.length===0)return"disabled";const n=e[0].object.id;if(td(t,n)){const o=ed(t,n),r=new Set(o.map(a=>a.object.id));if(e.every(a=>r.has(a.object.id)))return"ungroup"}return e.length>=2?"group":"disabled"};function qt(t){let e=t;return[()=>e,r=>{e=r}]}function Bb(t,e){if(t.length<3)return!0;const n=t[0],o=t[t.length-1],r=Math.hypot(o.x-n.x,o.y-n.y);return r<5?!1:t.reduce((i,s)=>{const l=Math.abs((o.x-n.x)*(n.y-s.y)-(n.x-s.x)*(o.y-n.y))/r;return Math.max(i,l)},0)/r<e}const Ss={annotationType:M.INK,create(t){const{onCommit:e,onPreview:n,getTool:o,pageSize:r}=t,[a,i]=qt([]),[s,l]=qt(!1),c={current:null},u=h=>({x:et(h.x,0,r.width),y:et(h.y,0,r.height)}),d=()=>{const h=o();return h?{...h.defaults,strokeWidth:h.defaults.strokeWidth??1,strokeColor:h.defaults.strokeColor??h.defaults.color??"#000000",opacity:h.defaults.opacity??1,flags:h.defaults.flags??["print"]}:null},p=()=>{const h=a();if(h.length===0||h[0].points.length===0)return null;const g=d();if(!g)return null;const f=h.flatMap(_=>_.points),F=yn(cn(f),g.strokeWidth/2);return{type:M.INK,bounds:F,data:{...g,rect:F,inkList:h,blendMode:g.blendMode}}};return{onPointerDown:(h,g)=>{var f;const F=u(h);l(!0),c.current&&clearTimeout(c.current);const _=[...a(),{points:[F]}];i(_),n(p()),(f=g.setPointerCapture)==null||f.call(g)},onPointerMove:h=>{if(!s())return;const g=a();if(g.length===0)return;const f=u(h);g[g.length-1].points.push(f),i(g),n(p())},onPointerUp:(h,g)=>{var f;l(!1),(f=g.releasePointerCapture)==null||f.call(g);const F=o(),_=F==null?void 0:F.behavior;if(_!=null&&_.smartLineRecognition){const E=_.smartLineThreshold??.15,A=a(),T=A[A.length-1];if(T&&T.points.length>1&&Bb(T.points,E)){const q=T.points[0],w=T.points[T.points.length-1],G=w.x-q.x,W=w.y-q.y,J=Math.atan2(Math.abs(W),Math.abs(G))*(180/Math.PI),ue=_.snapAngleDeg??15;if(J<=ue){const ce=T.points.reduce((ee,ge)=>ee+ge.y,0)/T.points.length;T.points=[{x:q.x,y:ce},{x:w.x,y:ce}]}else if(J>=90-ue){const ce=T.points.reduce((ee,ge)=>ee+ge.x,0)/T.points.length;T.points=[{x:ce,y:q.y},{x:ce,y:w.y}]}i([...A]),n(p())}}const y=(_==null?void 0:_.commitDelay)??800;c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{const E=a();if(E.length>0&&E[0].points.length>1){const A=d();if(!A)return;const T=E.flatMap(w=>w.points),q=yn(cn(T),A.strokeWidth/2);e({...A,inkList:E,rect:q,type:M.INK,pageIndex:t.pageIndex,id:pt(),created:new Date})}i([]),n(null)},y)},onPointerCancel:(h,g)=>{var f;i([]),l(!1),n(null),c.current&&clearTimeout(c.current),(f=g.releasePointerCapture)==null||f.call(g)}}}};function nd(t){const e=n=>{const o=n*9,r=Math.PI/6;return{x:-o*Math.cos(r),y:o*Math.sin(r)}};return{getSvgPath:n=>{const{x:o,y:r}=e(n);return t?`M 0 0 L ${o} ${r} L ${o} ${-r} Z`:`M ${o} ${r} L 0 0 L ${o} ${-r}`},getLocalPoints:n=>{const{x:o,y:r}=e(n);return[{x:0,y:0},{x:o,y:r},{x:o,y:-r}]},getRotation:n=>n,filled:t}}function od(t,e){const n=o=>o*t/2;return{getSvgPath:o=>{const r=n(o);return`M ${-r} 0 L ${r} 0`},getLocalPoints:o=>{const r=n(o);return[{x:-r,y:0},{x:r,y:0}]},getRotation:e,filled:!1}}const rd=nd(!1),ad=nd(!0),Es={[Ct.OpenArrow]:rd,[Ct.ClosedArrow]:ad,[Ct.ROpenArrow]:{...rd,getRotation:t=>t+Math.PI},[Ct.RClosedArrow]:{...ad,getRotation:t=>t+Math.PI},[Ct.Circle]:{getSvgPath:t=>{const e=t*5/2;return`M ${e} 0 A ${e} ${e} 0 1 1 ${-e} 0 A ${e} ${e} 0 1 1 ${e} 0`},getLocalPoints:t=>{const e=t*5/2;return[{x:-e,y:-e},{x:e,y:e}]},getRotation:()=>0,filled:!0},[Ct.Square]:{getSvgPath:t=>{const e=t*6/2;return`M ${-e} ${-e} L ${e} ${-e} L ${e} ${e} L ${-e} ${e} Z`},getLocalPoints:t=>{const e=t*6/2;return[{x:-e,y:-e},{x:e,y:-e},{x:e,y:e},{x:-e,y:e}]},getRotation:t=>t,filled:!0},[Ct.Diamond]:{getSvgPath:t=>{const e=t*6/2;return`M 0 ${-e} L ${e} 0 L 0 ${e} L ${-e} 0 Z`},getLocalPoints:t=>{const e=t*6/2;return[{x:0,y:-e},{x:e,y:0},{x:0,y:e},{x:-e,y:0}]},getRotation:t=>t,filled:!0},[Ct.Butt]:od(6,t=>t+Math.PI/2),[Ct.Slash]:od(18,t=>t+Math.PI/1.5)},zb=1.2;function Wb(t,e=0){if(t.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};const n=cn(t);return e>0?yn(n,e):n}function Jt(t,e,n){if(!t||t.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};const o=[...t],r=(l,c)=>Math.atan2(c.y-l.y,c.x-l.x),a=(l,c,u)=>{if(!l)return;const d=Es[l];if(!d)return;const p=d.getLocalPoints(e),h=d.getRotation(u),g=p.map(f=>JP(f,h,c));o.push(...g)};if(t.length>=2){const l=r(t[1],t[0]);a(n==null?void 0:n.start,t[0],l);const c=t.length-1,u=r(t[c-1],t[c]);a(n==null?void 0:n.end,t[c],u)}if(o.length<=1){const l=t[0]||{x:0,y:0},c=e;return{origin:{x:l.x-c,y:l.y-c},size:{width:c*2,height:c*2}}}const i=cn(o),s=e/2+zb*e;return yn(i,s)}function za(t,e){if(!t.unrotatedRect)return{rect:e};const n=_o(e);return{rect:Qn(e,t.rotation??0,n),unrotatedRect:e}}function Jn(t){return t.unrotatedRect?cu(t.unrotatedRect,t.rect,t.rotation??0):_o(t.rect)}function As(t,e,n){const o=Jn(t),r=t.unrotatedRect??t.rect,a={x:e.origin.x-r.origin.x,y:e.origin.y-r.origin.y},i={x:o.x+a.x,y:o.y+a.y};return{rect:Qn(e,n,i),unrotatedRect:e}}function Wa(t,e,n){if(!t.unrotatedRect)return e;const o=t.rotation??0;if(Math.abs(o%360)<1e-8)return e;const r=Jn(t),a=_o(n),i=o*Math.PI/180,s=Math.cos(i),l=Math.sin(i),c=r.x-a.x,u=r.y-a.y,d=(1-s)*c+l*u,p=-l*c+(1-s)*u;return Math.abs(d)<1e-8&&Math.abs(p)<1e-8?e:e.map(h=>({x:h.x+d,y:h.y+p}))}function Hb(t,e,n,o,r){if(!t)return null;const a=Es[t];if(!a)return null;const i=l=>l*180/Math.PI,s=a.getRotation(n);return{d:a.getSvgPath(e),transform:`translate(${o} ${r}) rotate(${i(s)})`,filled:a.filled}}class id{constructor(){this.patches=new Map}register(e,n){this.patches.set(e,n)}transform(e,n){const o=this.patches.get(e.type);return o?o(e,n):n.changes}}const Vb=new id;function eo(t,e){var n;if(((n=e.metadata)==null?void 0:n.rotationAngle)===void 0)return null;const o=e.metadata.rotationAngle,r=e.changes.unrotatedRect??t.unrotatedRect??t.rect,a={origin:{...r.origin},size:{...r.size}};return{...As(t,a,o),rotation:o}}function Mr(t,e){const n=t.unrotatedRect??t.rect;return{rotation:e,...As(t,n,e)}}function to(t,e){const n=e.origin.x-t.rect.origin.x,o=e.origin.y-t.rect.origin.y,r={rect:e};return t.unrotatedRect&&(r.unrotatedRect={origin:{x:t.unrotatedRect.origin.x+n,y:t.unrotatedRect.origin.y+o},size:{...t.unrotatedRect.size}}),{dx:n,dy:o,rects:r}}function no(t,e,n){const o=t.unrotatedRect??t.rect;let r=e.size.width/o.size.width,a=e.size.height/o.size.height;const i=10;if((e.size.width<i||e.size.height<i)&&(r=Math.max(r,i/o.size.width),a=Math.max(a,i/o.size.height),e={origin:e.origin,size:{width:o.size.width*r,height:o.size.height*a}}),n!=null&&n.maintainAspectRatio){const l=Math.min(r,a);r=l,a=l,e={origin:e.origin,size:{width:o.size.width*l,height:o.size.height*l}}}const s=t.unrotatedRect?{unrotatedRect:e,rect:Zi(e,t.rotation??0)}:{rect:e};return{scaleX:r,scaleY:a,oldRect:o,resolvedRect:e,rects:s}}function Ha(t,e){const n=t.unrotatedRect??t.rect,o=e.unrotatedRect??n;return{dx:o.origin.x-n.origin.x,dy:o.origin.y-n.origin.y}}function Va(t,e,n){if(e===0||t.rotation!==void 0)return t;const o=(4-e)%4*90;let r=t;if(n&&(e===1||e===3)){const l=t.rect,c=l.origin.x+l.size.width/2,u=l.origin.y+l.size.height/2;r={...t,rect:{origin:{x:c-l.size.height/2,y:u-l.size.width/2},size:{width:l.size.height,height:l.size.width}}}}const{rotation:a,rect:i,unrotatedRect:s}=Mr(r,o);return{...r,rotation:a,rect:i,unrotatedRect:s}}function Ya(t,e){const n=et(t.rect.origin.x,0,e.width-t.rect.size.width),o=et(t.rect.origin.y,0,e.height-t.rect.size.height),r=n-t.rect.origin.x,a=o-t.rect.origin.y;return r===0&&a===0?t:{...t,rect:{origin:{x:n,y:o},size:t.rect.size},...t.unrotatedRect?{unrotatedRect:{origin:{x:t.unrotatedRect.origin.x+r,y:t.unrotatedRect.origin.y+a},size:t.unrotatedRect.size}}:{}}}const qa=Object.freeze(Object.defineProperty({__proto__:null,LINE_ENDING_HANDLERS:Es,PatchRegistry:id,applyInsertUpright:Va,calculateAABBFromVertices:Wb,calculateRotatedRectAABB:Zi,calculateRotatedRectAABBAroundPoint:Qn,clampAnnotationToPage:Ya,compensateRotatedVertexEdit:Wa,createEnding:Hb,getRectCenter:_o,lineRectWithEndings:Jt,patchRegistry:Vb,resolveAnnotationRotationCenter:Jn,resolveRotateRects:As,resolveVertexEditRects:za,rotatePointAroundCenter:yo,rotateVertices:lu},Symbol.toStringTag,{value:"Module"})),Ka=24,sd={annotationType:M.TEXT,create(t){const{onCommit:e,getTool:n,pageSize:o}=t;return{onPointerDown:r=>{const a=n();if(!a)return;const i={origin:{x:r.x-Ka/2,y:r.y-Ka/2},size:{width:Ka,height:Ka}};let s={...a.defaults,rect:i,type:M.TEXT,icon:a.defaults.icon??Qi.Comment,contents:a.defaults.contents??"",flags:a.defaults.flags??["print","noRotate","noZoom"],pageIndex:t.pageIndex,id:pt(),created:new Date};s=Ya(s,o),e(s)}}}};function Rr({threshold:t=5,getTool:e,onClickDetected:n}){const[o,r]=qt(null),[a,i]=qt(!1);return{onStart:s=>{r(s),i(!1)},onMove:s=>{const l=o();if(!l||a())return;Math.sqrt(Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2))>t&&i(!0)},onEnd:s=>{var l;if(o()&&!a()){const u=e();u&&"clickBehavior"in u&&((l=u.clickBehavior)!=null&&l.enabled)&&n(s,u)}r(null),i(!1)},hasMoved:a,reset:()=>{r(null),i(!1)}}}const ld={annotationType:M.FREETEXT,create(t){const{onCommit:e,onPreview:n,getTool:o,pageSize:r,pageIndex:a,pageRotation:i}=t,[s,l]=qt(null),c=h=>({x:et(h.x,0,r.width),y:et(h.y,0,r.height)}),u=()=>{const h=o();return h?{...h.defaults,fontColor:h.defaults.fontColor??"#000000",opacity:h.defaults.opacity??1,fontSize:h.defaults.fontSize??12,fontFamily:h.defaults.fontFamily??mt.Helvetica,color:h.defaults.color??h.defaults.backgroundColor??"transparent",textAlign:h.defaults.textAlign??Vt.Left,verticalAlign:h.defaults.verticalAlign??Ar.Top,contents:h.defaults.contents??"Insert text here",flags:h.defaults.flags??["print"]}:null},d=Rr({threshold:5,getTool:o,onClickDetected:(h,g)=>{var f;const F=u();if(!F)return;const _=g.clickBehavior;if(!(_!=null&&_.enabled))return;const{width:y,height:E}=_.defaultSize,A={origin:{x:h.x-y/2,y:h.y-E/2},size:{width:y,height:E}},T=_.defaultContent??F.contents;let q={...F,contents:T,type:M.FREETEXT,rect:A,pageIndex:a,id:pt(),created:new Date};(f=g.behavior)!=null&&f.insertUpright&&(q=Va(q,i,!1)),q=Ya(q,r),e(q)}}),p=h=>{const g=s();if(!g)return null;const f=u();if(!f)return null;const F=Math.min(g.x,h.x),_=Math.min(g.y,h.y),y=Math.abs(g.x-h.x),E=Math.abs(g.y-h.y),A={origin:{x:F,y:_},size:{width:y,height:E}};return{type:M.FREETEXT,bounds:A,data:{...f,rect:A}}};return{onPointerDown:(h,g)=>{var f;const F=c(h);l(F),d.onStart(F),n(p(F)),(f=g.setPointerCapture)==null||f.call(g)},onPointerMove:h=>{const g=c(h);d.onMove(g),s()&&d.hasMoved()&&n(p(g))},onPointerUp:(h,g)=>{var f,F;const _=s();if(!_)return;const y=u();if(!y)return;const E=c(h);if(!d.hasMoved())d.onEnd(E);else{const A=Math.min(_.x,E.x),T=Math.min(_.y,E.y),q=Math.abs(_.x-E.x),w=Math.abs(_.y-E.y),G={origin:{x:A,y:T},size:{width:q,height:w}},W=o();let J={...y,type:M.FREETEXT,rect:G,pageIndex:t.pageIndex,id:pt(),created:new Date};(f=W==null?void 0:W.behavior)!=null&&f.insertUpright&&(J=Va(J,i,!0)),e(J)}l(null),n(null),d.reset(),(F=g.releasePointerCapture)==null||F.call(g)},onPointerLeave:(h,g)=>{var f;l(null),n(null),d.reset(),(f=g.releasePointerCapture)==null||f.call(g)},onPointerCancel:(h,g)=>{var f;l(null),n(null),d.reset(),(f=g.releasePointerCapture)==null||f.call(g)}}}},xs={annotationType:M.LINE,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,strokeWidth:p.defaults.strokeWidth??1,lineEndings:p.defaults.lineEndings??{start:Ct.None,end:Ct.None},color:p.defaults.color??"#000000",opacity:p.defaults.opacity??1,strokeStyle:p.defaults.strokeStyle??rt.SOLID,strokeDashArray:p.defaults.strokeDashArray??[],strokeColor:p.defaults.strokeColor??"#000000",flags:p.defaults.flags??["print"]}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const F=f.defaultAngle??0,y=f.defaultLength/2,E=p.x-y*Math.cos(F),A=p.y-y*Math.sin(F),T=p.x+y*Math.cos(F),q=p.y+y*Math.sin(F),w=l({x:E,y:A}),G=l({x:T,y:q}),W=Jt([w,G],g.strokeWidth,g.lineEndings);n({...g,rect:W,linePoints:{start:w,end:G},pageIndex:e,id:pt(),created:new Date,type:M.LINE})}}),d=p=>{const h=i();if(!h)return null;const g=c();if(!g)return null;const f=Jt([h,p],g.strokeWidth,g.lineEndings);return{type:M.LINE,bounds:f,data:{...g,rect:f,linePoints:{start:h,end:p}}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;const f=i();if(!f)return;const F=l(p);if(!u.hasMoved())u.onEnd(F);else{const _=c();if(!_)return;if(Math.abs(F.x-f.x)>2||Math.abs(F.y-f.y)>2){const y=Jt([f,F],_.strokeWidth,_.lineEndings);n({..._,rect:y,linePoints:{start:f,end:F},pageIndex:e,id:pt(),flags:["print"],created:new Date,type:M.LINE})}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},cd={annotationType:M.POLYLINE,create(t){const{onCommit:e,onPreview:n,getTool:o,pageSize:r}=t,[a,i]=qt([]),[s,l]=qt(null),c=h=>({x:et(h.x,0,r.width),y:et(h.y,0,r.height)}),u=()=>{const h=o();return h?{...h.defaults,strokeWidth:h.defaults.strokeWidth??1,lineEndings:h.defaults.lineEndings??{start:Ct.None,end:Ct.None},color:h.defaults.color??"#000000",opacity:h.defaults.opacity??1,strokeColor:h.defaults.strokeColor??"#000000",strokeStyle:h.defaults.strokeStyle??rt.SOLID,strokeDashArray:h.defaults.strokeDashArray??[],flags:h.defaults.flags??["print"]}:null},d=()=>{const h=a();if(h.length<2)return;const g=u();if(!g)return;const f=Jt(h,g.strokeWidth,g.lineEndings),F={...g,vertices:h,rect:f,type:M.POLYLINE,pageIndex:t.pageIndex,id:pt(),created:new Date};e(F),i([]),l(null),n(null)},p=()=>{const h=a(),g=s();if(h.length===0||!g)return null;const f=u();if(!f)return null;const F=[...h,g],_=Jt(F,f.strokeWidth,f.lineEndings);return{type:M.POLYLINE,bounds:_,data:{...f,rect:_,vertices:F,currentVertex:g}}};return{onClick:(h,g)=>{if(g.metaKey||g.ctrlKey)return;const f=c(h),F=a(),_=F[F.length-1];_&&Math.abs(_.x-f.x)<1&&Math.abs(_.y-f.y)<1||(i([...F,f]),l(f),n(p()))},onDoubleClick:()=>{d()},onPointerMove:h=>{if(a().length>0){const g=c(h);l(g),n(p())}},onPointerCancel:()=>{i([]),l(null),n(null)}}}};function ud(t,e,n,o){const r=o*Math.PI/180,a=Math.abs(Math.cos(r)),i=Math.abs(Math.sin(r)),s=a*a-i*i,l=t.size.width,c=t.size.height;let u,d;if(Math.abs(s)>1e-6)u=(a*l-i*c)/s,d=(a*c-i*l)/s,u=Math.max(u,1),d=Math.max(d,1);else{const g=e.size.width*e.size.height,f=l*c,F=g>0?Math.sqrt(f/g):1;u=n.size.width*F,d=n.size.height*F}const p=t.origin.x+l/2,h=t.origin.y+c/2;return{origin:{x:p-u/2,y:h-d/2},size:{width:u,height:d}}}const Yo=Math.PI,wr=Math.PI/2,Un=34*Math.PI/180,dd=30*Math.PI/180,Cs=12*Math.PI/180;class Ts{constructor(){this.parts=[],this.bbox={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},this.started=!1}moveTo(e,n){const o=-n;this.updateBBox(e,o),this.parts.push(`M ${oo(e)} ${oo(o)}`),this.started=!0}curveTo(e,n,o,r,a,i){const s=-n,l=-r,c=-i;this.updateBBox(e,s),this.updateBBox(o,l),this.updateBBox(a,c),this.parts.push(`C ${oo(e)} ${oo(s)}, ${oo(o)} ${oo(l)}, ${oo(a)} ${oo(c)}`)}close(){this.started&&this.parts.push("Z")}build(e){const n=e>0?e/2:0;return{path:this.parts.join(" "),bbox:{minX:this.bbox.minX-n,minY:this.bbox.minY-n,maxX:this.bbox.maxX+n,maxY:this.bbox.maxY+n}}}updateBBox(e,n){e<this.bbox.minX&&(this.bbox.minX=e),n<this.bbox.minY&&(this.bbox.minY=n),e>this.bbox.maxX&&(this.bbox.maxX=e),n>this.bbox.maxY&&(this.bbox.maxY=n)}}function oo(t){return Number(t.toFixed(4)).toString()}function Or(t,e){const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}function pd(t,e){return e===0?0:t/e}function hd(t,e){return e===0?0:t/e}function Yb(t){let e=0;const n=t.length;for(let o=0;o<n;o++){const r=(o+1)%n;e+=t[o].x*t[r].y-t[o].y*t[r].x}return e}function qb(t){Yb(t)<0&&t.reverse()}function Kb(t){if(t.length<=2)return t;const e=.5,n=[t[0]];for(let o=1;o<t.length;o++){const r=n[n.length-1],a=t[o];(Math.abs(a.x-r.x)>=e||Math.abs(a.y-r.y)>=e)&&n.push(a)}return n}function qo(t,e,n,o,r,a,i,s){const l=Math.cos(t),c=Math.sin(t),u=Math.cos(e),d=Math.sin(e),p=Math.sin((e-t)/2);if(p===0){s&&i.moveTo(n+r*l,o+a*c);return}const h=4/3*(1-Math.cos((e-t)/2))/p,g=n+r*(l-h*c),f=o+a*(c+h*l),F=n+r*(u+h*d),_=o+a*(d-h*u),y=n+r*u,E=o+a*d;s&&i.moveTo(n+r*l,o+a*c),i.curveTo(g,f,F,_,y,E)}function Ms(t,e,n,o,r,a){const i=Math.cos(t),s=Math.sin(t),l=Math.cos(e),c=Math.sin(e),u=Math.sin((e-t)/2);if(u===0)return[];const d=4/3*(1-Math.cos((e-t)/2))/u;return[{x:n+r*(i-d*s),y:o+a*(s+d*i)},{x:n+r*(l+d*c),y:o+a*(c-d*l)},{x:n+r*l,y:o+a*c}]}function kr(t,e,n,o,r,a,i,s){const l=wr;let c=e-t;for(;c<0;)c+=2*Math.PI;const u=c;let d=0;for(s&&i.moveTo(r+n*Math.cos(t),a+o*Math.sin(t));c>l;)qo(t+d,t+d+l,r,a,n,o,i,!1),d+=l,c-=l;c>0&&qo(t+d,t+u,r,a,n,o,i,!1)}function gd(t,e,n,o,r,a,i,s,l){let c=t+Yo+i;const u=t+Yo+i-22*Math.PI/180;qo(c,u,o,r,n,n,s,l),c=u;const d=e-a;kr(c,d,n,n,o,r,s,!1)}function Xb(t,e,n,o,r,a){const i=t+Yo;qo(i+n,i+n-dd,o,r,e,e,a,!1),qo(i+n-dd,i+wr,o,r,e,e,a,!1),qo(i+wr,i+Yo-Un,o,r,e,e,a,!1)}function Zb(t,e){const n=[],o=t+Yo;return n.push(...Ms(o+Un,o+Cs,0,0,e,e)),n.push(...Ms(o+Cs,o+wr,0,0,e,e)),n.push(...Ms(o+wr,o+Yo-Un,0,0,e,e)),n}function Qb(t,e,n,o){for(let r=0;r+2<t.length;r+=3){const a=t[r],i=t[r+1],s=t[r+2];o.curveTo(a.x+e,a.y+n,i.x+e,i.y+n,s.x+e,s.y+n)}}function Jb(t,e,n){if(n===0)return{n:-1,adjustedRadius:t};const o=2*e*t,r=n-o;if(r<=0)return{n:0,adjustedRadius:t};const a=2*e*t,i=Math.max(1,Math.ceil(r/a)),s=r/(i*2*e);return{n:i,adjustedRadius:s}}function Rs(t,e,n,o,r){let a=Kb(t);qb(a);const i=a.length;if(i<2)return;if(n<=0){r.moveTo(a[0].x,a[0].y);for(let p=1;p<i;p++)r.curveTo(a[p].x,a[p].y,a[p].x,a[p].y,a[p].x,a[p].y);return}let s=e?ws(n,o):fd(n,o);s<.5&&(s=.5);const l=Math.cos(Un),c=[];for(let p=0;p+1<i;p++){const h=Or(a[p],a[p+1]);h<=0||h>=2*l*s?c.push(Un):c.push(Math.acos(Math.min(1,h/(2*s))))}let u=0,d=!1;for(let p=0;p+1<i;p++){const h=a[p],g=a[p+1],f=Or(h,g);if(f===0)continue;const F=Jb(s,l,f);if(F.n<0){d||(r.moveTo(h.x,h.y),d=!0);continue}const _=Math.max(.5,F.adjustedRadius),y=2*l*_,E=l*s+l*_;let A=Math.atan2(g.y-h.y,g.x-h.x);if(p===0){const ce=a[i-2];u=Math.atan2(h.y-ce.y,h.x-ce.x)}const T=pd(g.x-h.x,f),q=hd(g.y-h.y,f);let w=h.x,G=h.y;const W=c[p],J=p===0?i-2:p-1,ue=c[J]??Un;if(gd(u,A,s,h.x,h.y,W,ue,r,!d),d=!0,F.n===0)w+=f*T,G+=f*q;else{w+=E*T,G+=E*q;let ce=F.n;F.n>=1&&(Xb(A,_,Un,w,G,r),w+=y*T,G+=y*q,ce=F.n-1);const ee=Zb(A,_);for(let ge=0;ge<ce;ge++)Qb(ee,w,G,r),w+=y*T,G+=y*q}u=A}}function e_(t,e,n,o){const r=(t+n)/2,a=(e+o)/2,i=(n-t)/2,s=(o-e)/2;if(i<=0||s<=0)return[];const l=Math.max(32,Math.ceil(Math.max(i,s)*2)),c=[];for(let u=0;u<=l;u++){const d=2*Math.PI*u/l;c.push({x:r+i*Math.cos(d),y:a+s*Math.sin(d)})}return c}function ws(t,e){return 4.75*t+.5*e}function fd(t,e){return 4*t+.5*e}function t_(t,e,n,o,r,a,i){if(r<=0){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,_e=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,_e,Ee,i,!0);return}const s=n-t,l=o-e;let c=ws(r,a);const u=.5*c;if(s<u&&l<u){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,_e=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,_e,Ee,i,!0);return}const d=5;if(s<d&&l>20||s>20&&l<d){Rs([{x:t,y:e},{x:n,y:e},{x:n,y:o},{x:t,y:o},{x:t,y:e}],!0,r,a,i);return}const p=Math.sin(Cs)*c-1.5;let h=t,g=n,f=e,F=o;if(s>2*p)h+=p,g-=p;else{const ee=(t+n)/2;h=ee-.1,g=ee+.1}if(l>2*p)f+=p,F-=p;else{const ee=(o+e)/2;F=ee+.1,f=ee-.1}const _=e_(h,f,g,F),y=_.length;if(y<2)return;let E=0;for(let ee=1;ee<y;ee++)E+=Or(_[ee-1],_[ee]);const A=Math.cos(Un);let T=2*A*c,q=Math.ceil(E/T);if(q<2){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,_e=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,_e,Ee,i,!0);return}if(T=E/q,c=T/(2*A),c<.5)c=.5,T=2*A*c;else if(c<3){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,_e=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,_e,Ee,i,!0);return}const w=[];let G=0;const W=a*.1;for(let ee=0;ee+1<y;ee++){const ge=_[ee],_e=_[ee+1],Ee=_e.x-ge.x,Te=_e.y-ge.y,oe=Or(ge,_e);if(oe===0)continue;let He=oe+G;if(He>=T-W||ee===y-2){const ft=pd(Ee,oe),Ve=hd(Te,oe);let O=T-G;for(;He>=T-W;)w.push({x:ge.x+O*ft,y:ge.y+O*Ve}),He-=T,O+=T;G=Math.max(0,He)}else G+=oe}const J=w.length;let ue=0,ce=0;for(let ee=0;ee<J;ee++){const ge=(ee+1)%J,_e=w[ee],Ee=w[ge];if(ee===0){const He=w[J-1];ue=Math.atan2(_e.y-He.y,_e.x-He.x),ce=md(He,_e,c,T)}const Te=Math.atan2(Ee.y-_e.y,Ee.x-_e.x),oe=md(_e,Ee,c,T);gd(ue,Te,c,_e.x,_e.y,oe,ce,i,ee===0),ue=Te,ce=oe}}function md(t,e,n,o){const r=Or(t,e);if(r===0)return Un;const a=r-o,i=(o/2+a/2)/n;return i<-1||i>1?0:Math.acos(i)}function en(t,e,n){return(n?ws(t,e):fd(t,e))+e/2}function n_(t,e,n,o){const r=new Ts;let a=0,i=0,s=t.width,l=t.height;e?(a+=e.left,i+=e.top,s-=e.right,l-=e.bottom):(a+=o/2,i+=o/2,s-=o/2,l-=o/2);const c=[{x:a,y:-i},{x:s,y:-i},{x:s,y:-l},{x:a,y:-l},{x:a,y:-i}];return Rs(c,!1,n,o,r),r.close(),r.build(o)}function o_(t,e,n,o){const r=new Ts;let a=0,i=0,s=t.width,l=t.height;return e&&(a+=e.left,i+=e.top,s-=e.right,l-=e.bottom),t_(a,-l,s,-i,n,o,r),r.close(),r.build(o)}function r_(t,e,n,o){const r=new Ts;if(t.length<3)return r.build(o);const a=t.map(l=>({x:l.x-e.x,y:-(l.y-e.y)})),i=a[0],s=a[a.length-1];return(i.x!==s.x||i.y!==s.y)&&a.push({x:i.x,y:i.y}),Rs(a,!1,n,o,r),r.close(),r.build(o)}const a_=14,Pd={annotationType:M.POLYGON,create(t){const{onCommit:e,onPreview:n,getTool:o,scale:r,pageSize:a}=t,[i,s]=qt([]),[l,c]=qt(null),u=f=>({x:et(f.x,0,a.width),y:et(f.y,0,a.height)}),d=f=>{const F=i();if(F.length<2)return!1;const y=a_/r/2,E=F[0];return f.x>=E.x-y&&f.x<=E.x+y&&f.y>=E.y-y&&f.y<=E.y+y},p=()=>{const f=o();return f?{...f.defaults,color:f.defaults.color??"#000000",opacity:f.defaults.opacity??1,strokeWidth:f.defaults.strokeWidth??1,strokeColor:f.defaults.strokeColor??"#000000",strokeStyle:f.defaults.strokeStyle??rt.SOLID,strokeDashArray:f.defaults.strokeDashArray??[],flags:f.defaults.flags??["print"]}:null},h=()=>{const f=i();if(f.length<3)return;const F=p();if(!F)return;const _=F.cloudyBorderIntensity??0,y=_>0?en(_,F.strokeWidth,!1):F.strokeWidth/2,E=yn(cn(f),y),A={...F,vertices:f,rect:E,type:M.POLYGON,pageIndex:t.pageIndex,id:pt(),created:new Date,..._>0&&{rectangleDifferences:{left:y,top:y,right:y,bottom:y}}};e(A),s([]),c(null),n(null)},g=()=>{const f=i(),F=l();if(f.length===0||!F)return null;const _=p();if(!_)return null;const y=_.cloudyBorderIntensity??0,E=y>0?en(y,_.strokeWidth,!1):_.strokeWidth/2,A=[...f,F],T=yn(cn(A),E);return{type:M.POLYGON,bounds:T,data:{..._,rect:T,vertices:f,currentVertex:F}}};return{onClick:(f,F)=>{if(F.metaKey||F.ctrlKey)return;const _=u(f);if(d(_)&&i().length>=3){h();return}const y=i(),E=y[y.length-1];E&&Math.abs(E.x-_.x)<1&&Math.abs(E.y-_.y)<1||(s([...y,_]),c(_),n(g()))},onDoubleClick:f=>{h()},onPointerMove:f=>{if(i().length>0){const F=u(f);c(F),n(g())}},onPointerCancel:f=>{s([]),c(null),n(null)}}}},Fd={annotationType:M.SQUARE,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,flags:p.defaults.flags??["print"],strokeWidth:p.defaults.strokeWidth??2,strokeColor:p.defaults.strokeColor??"#000000",strokeStyle:p.defaults.strokeStyle??rt.SOLID,strokeDashArray:p.defaults.strokeDashArray??[],color:p.defaults.color??"#000000",opacity:p.defaults.opacity??1}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const{width:F,height:_}=f.defaultSize,y=F/2,E=_/2,A=et(p.x-y,0,a.width-F),T=et(p.y-E,0,a.height-_),q=g.strokeWidth,w=g.cloudyBorderIntensity??0,G=w>0?en(w,q,!1):q/2,W={origin:{x:A-G,y:T-G},size:{width:F+2*G,height:_+2*G}},J={...g,type:M.SQUARE,created:new Date,id:pt(),pageIndex:e,rect:W,...w>0&&{rectangleDifferences:{left:G,top:G,right:G,bottom:G}}};n(J)}}),d=p=>{const h=i();if(!h)return null;const g=Math.min(h.x,p.x),f=Math.min(h.y,p.y),F=Math.abs(h.x-p.x),_=Math.abs(h.y-p.y),y=c();if(!y)return null;const E=y.strokeWidth,A=y.cloudyBorderIntensity??0,T=A>0?en(A,E,!1):E/2,q={origin:{x:g-T,y:f-T},size:{width:F+2*T,height:_+2*T}};return{type:M.SQUARE,bounds:q,data:{rect:q,...y,...A>0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;if(!i()||!c())return;const _=l(p);if(!u.hasMoved())u.onEnd(_);else{const y=c();if(!y)return;const E=d(_);if(E){const A=y.cloudyBorderIntensity??0,T=A>0?en(A,y.strokeWidth,!1):void 0,q={...y,type:M.SQUARE,created:new Date,id:pt(),pageIndex:e,rect:E.data.rect,...T!==void 0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}};n(q)}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},bd={annotationType:M.STAMP,create(t){const{services:e,onCommit:n,getTool:o,pageSize:r,pageRotation:a}=t;return{onPointerDown:i=>{const s=o();if(!s)return;const{imageSrc:l,imageSize:c}=s.defaults,u=(d,p,h)=>{var g;const f={origin:{x:i.x-p/2,y:i.y-h/2},size:{width:p,height:h}};let F={...s.defaults,rect:f,type:M.STAMP,icon:s.defaults.icon??Qi.Draft,subject:s.defaults.subject??"Stamp",flags:s.defaults.flags??["print"],pageIndex:t.pageIndex,id:pt(),created:new Date};(g=s.behavior)!=null&&g.insertUpright&&(F=Va(F,a,!1)),F=Ya(F,r),n(F,{imageData:d})};l?e.processImage({source:l,maxWidth:r.width,maxHeight:r.height,onComplete:d=>u(d.imageData,(c==null?void 0:c.width)??d.width,(c==null?void 0:c.height)??d.height)}):e.requestFile({accept:"image/png,image/jpeg",onFile:d=>{e.processImage({source:d,maxWidth:r.width,maxHeight:r.height,onComplete:p=>u(p.imageData,p.width,p.height)})}})}}}},_d={annotationType:M.CIRCLE,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,strokeWidth:p.defaults.strokeWidth??2,strokeColor:p.defaults.strokeColor??"#000000",strokeStyle:p.defaults.strokeStyle??rt.SOLID,strokeDashArray:p.defaults.strokeDashArray??[],color:p.defaults.color??"#000000",opacity:p.defaults.opacity??1,flags:p.defaults.flags??["print"]}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const{width:F,height:_}=f.defaultSize,y=F/2,E=_/2,A=et(p.x-y,0,a.width-F),T=et(p.y-E,0,a.height-_),q=g.strokeWidth,w=g.cloudyBorderIntensity??0,G=w>0?en(w,q,!0):q/2,W={origin:{x:A-G,y:T-G},size:{width:F+2*G,height:_+2*G}},J={...g,type:M.CIRCLE,created:new Date,id:pt(),pageIndex:e,rect:W,...w>0&&{rectangleDifferences:{left:G,top:G,right:G,bottom:G}}};n(J)}}),d=p=>{const h=i();if(!h)return null;const g=Math.min(h.x,p.x),f=Math.min(h.y,p.y),F=Math.abs(h.x-p.x),_=Math.abs(h.y-p.y),y=c();if(!y)return null;const E=y.strokeWidth,A=y.cloudyBorderIntensity??0,T=A>0?en(A,E,!0):E/2,q={origin:{x:g-T,y:f-T},size:{width:F+2*T,height:_+2*T}};return{type:M.CIRCLE,bounds:q,data:{rect:q,...y,...A>0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;if(!i()||!c())return;const _=l(p);if(!u.hasMoved())u.onEnd(_);else{const y=c();if(!y)return;const E=d(_);if(E){const A=y.cloudyBorderIntensity??0,T=A>0?en(A,y.strokeWidth,!0):void 0,q={...y,type:M.CIRCLE,flags:["print"],created:new Date,id:pt(),pageIndex:e,rect:E.data.rect,...T!==void 0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}};n(q)}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},yd={annotationType:M.LINK,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,flags:p.defaults.flags??["print"],strokeWidth:p.defaults.strokeWidth??2,strokeColor:p.defaults.strokeColor??"#0000FF",strokeStyle:p.defaults.strokeStyle??rt.UNDERLINE,strokeDashArray:p.defaults.strokeDashArray??[]}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const{width:F,height:_}=f.defaultSize,y=F/2,E=_/2,A=et(p.x-y,0,a.width-F),T=et(p.y-E,0,a.height-_),q={origin:{x:A,y:T},size:{width:F,height:_}},w={...g,type:M.LINK,target:void 0,created:new Date,id:pt(),pageIndex:e,rect:q};n(w)}}),d=p=>{const h=i();if(!h)return null;const g=Math.min(h.x,p.x),f=Math.min(h.y,p.y),F=Math.abs(h.x-p.x),_=Math.abs(h.y-p.y),y=c();if(!y)return null;const E={origin:{x:g,y:f},size:{width:F,height:_}};return{type:M.LINK,bounds:E,data:{rect:E,strokeColor:y.strokeColor,strokeWidth:y.strokeWidth,strokeStyle:y.strokeStyle,strokeDashArray:y.strokeDashArray}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;if(!i())return;const F=c();if(!F)return;const _=l(p);if(!u.hasMoved())u.onEnd(_);else{const y=d(_);if(y){const E={...F,type:M.LINK,target:void 0,created:new Date,id:pt(),pageIndex:e,rect:y.data.rect};n(E)}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},i_={toolId:"__textMarkup__",handle(t,e,n){const o=t.getTool();if(o)for(const r of e){const a=pt();n().then(i=>{var s;t.createAnnotation(r.pageIndex,{...o.defaults,rect:r.rect,segmentRects:r.segmentRects,pageIndex:r.pageIndex,created:new Date,id:a,...i!=null&&{custom:{text:i}}}),(s=o.behavior)!=null&&s.selectAfterCreate&&t.selectAnnotation(r.pageIndex,a)})}}};function vd(t){const e=t.size.height,n=e/2,o=n;return{origin:{x:t.origin.x+t.size.width-o/2,y:t.origin.y+e/2},size:{width:o,height:n}}}const s_={toolId:"insertText",handle(t,e,n){const o=t.getTool();if(!o)return;const r=()=>({strokeColor:o.defaults.strokeColor??"#E44234",opacity:o.defaults.opacity??1,flags:o.defaults.flags??["print"]});for(const a of e){const i=a.segmentRects[a.segmentRects.length-1];if(!i)continue;const s=vd(i),l=pt(),c=r();n().then(u=>{var d;t.createAnnotation(a.pageIndex,{type:M.CARET,id:l,pageIndex:a.pageIndex,rect:s,strokeColor:c.strokeColor,opacity:c.opacity,intent:"Insert",rectangleDifferences:{left:.5,top:.5,right:.5,bottom:.5},created:new Date,flags:c.flags,...u!=null&&{custom:{text:u}}}),(d=o.behavior)!=null&&d.selectAfterCreate&&t.selectAnnotation(a.pageIndex,l)})}}},l_={toolId:"replaceText",handle(t,e,n){const o=t.getTool();if(!o)return;const r=()=>({strokeColor:o.defaults.strokeColor??"#E44234",opacity:o.defaults.opacity??1,flags:o.defaults.flags??["print"]});for(const a of e){const i=a.segmentRects[a.segmentRects.length-1];if(!i)continue;const s=vd(i),l=pt(),c=pt(),u=r();n().then(d=>{var p;t.createAnnotation(a.pageIndex,{type:M.CARET,id:l,pageIndex:a.pageIndex,rect:s,strokeColor:u.strokeColor,opacity:u.opacity,intent:"Replace",rectangleDifferences:{left:.5,top:.5,right:.5,bottom:.5},created:new Date,flags:u.flags}),t.createAnnotation(a.pageIndex,{type:M.STRIKEOUT,id:c,pageIndex:a.pageIndex,rect:a.rect,segmentRects:a.segmentRects,strokeColor:u.strokeColor,opacity:u.opacity,intent:"StrikeOutTextEdit",inReplyToId:l,replyType:Ln.Group,created:new Date,flags:u.flags,...d!=null&&{custom:{text:d}}}),(p=o.behavior)!=null&&p.selectAfterCreate&&t.selectAnnotation(a.pageIndex,l)})}}},Dd=(t,e)=>{switch(e.type){case"vertex-edit":return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,inkList:t.inkList.map(a=>({points:a.points.map(i=>({x:i.x+n,y:i.y+o}))}))}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata),s=(A,T)=>({origin:{x:A.origin.x+T,y:A.origin.y+T},size:{width:Math.max(1,A.size.width-T*2),height:Math.max(1,A.size.height-T*2)}}),l=.001,c=Math.abs(n-1)>l,u=Math.abs(o-1)>l,d=c&&!u?n:!c&&u?o:Math.min(n,o),p=Math.max(1,t.strokeWidth*d),h=Math.max(1,Math.min(a.size.width,a.size.height)),g=Math.min(p,h),f=Number(g.toFixed(1)),F=s(r,t.strokeWidth/2),_=s(a,f/2),y=_.size.width/Math.max(F.size.width,1e-6),E=_.size.height/Math.max(F.size.height,1e-6);return{...i,inkList:t.inkList.map(A=>({points:A.points.map(T=>({x:_.origin.x+(T.x-F.origin.x)*y,y:_.origin.y+(T.y-F.origin.y)*E}))})),strokeWidth:f}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Ha(t,n);return{...n,inkList:t.inkList.map(a=>({points:a.points.map(i=>({x:i.x+o,y:i.y+r}))}))}}case"property-update":{if(!(e.changes.strokeWidth!==void 0||e.changes.rotation!==void 0))return e.changes;const o={...t,...e.changes},r=o.inkList.flatMap(s=>s.points),a=yn(cn(r),o.strokeWidth/2),i=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...e.changes,unrotatedRect:a,rect:Qn(a,i,Jn(t))}:{...e.changes,rect:a}}default:return e.changes}},Sd=(t,e)=>{switch(e.type){case"vertex-edit":if(e.changes.linePoints){const{start:n,end:o}=e.changes.linePoints,r=[n,o],a=Jt(r,t.strokeWidth,t.lineEndings),i=Wa(t,r,a),s=Jt(i,t.strokeWidth,t.lineEndings);return{...za(t,s),linePoints:{start:i[0],end:i[1]}}}return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,linePoints:{start:{x:t.linePoints.start.x+n,y:t.linePoints.start.y+o},end:{x:t.linePoints.end.x+n,y:t.linePoints.end.y+o}}}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata);return{...i,linePoints:{start:{x:a.origin.x+(t.linePoints.start.x-r.origin.x)*n,y:a.origin.y+(t.linePoints.start.y-r.origin.y)*o},end:{x:a.origin.x+(t.linePoints.end.x-r.origin.x)*n,y:a.origin.y+(t.linePoints.end.y-r.origin.y)*o}}}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Ha(t,n);return{...n,linePoints:{start:{x:t.linePoints.start.x+o,y:t.linePoints.start.y+r},end:{x:t.linePoints.end.x+o,y:t.linePoints.end.y+r}}}}case"property-update":{if(!(e.changes.strokeWidth!==void 0||e.changes.lineEndings!==void 0||e.changes.rotation!==void 0))return e.changes;const o={...t,...e.changes},r=Jt([o.linePoints.start,o.linePoints.end],o.strokeWidth,o.lineEndings),a=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...e.changes,unrotatedRect:r,rect:Qn(r,a,Jn(t))}:{...e.changes,rect:r}}default:return e.changes}},c_=(t,e)=>{switch(e.type){case"vertex-edit":if(e.changes.vertices&&e.changes.vertices.length){const n=e.changes.vertices,o=Jt(n,t.strokeWidth,t.lineEndings),r=Wa(t,n,o),a=Jt(r,t.strokeWidth,t.lineEndings);return{...za(t,a),vertices:r}}return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,vertices:t.vertices.map(a=>({x:a.x+n,y:a.y+o}))}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata);return{...i,vertices:t.vertices.map(s=>({x:a.origin.x+(s.x-r.origin.x)*n,y:a.origin.y+(s.y-r.origin.y)*o}))}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Ha(t,n);return{...n,vertices:t.vertices.map(a=>({x:a.x+o,y:a.y+r}))}}case"property-update":{if(!(e.changes.strokeWidth!==void 0||e.changes.lineEndings!==void 0||e.changes.rotation!==void 0))return e.changes;const o={...t,...e.changes},r=Jt(o.vertices,o.strokeWidth,o.lineEndings),a=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...e.changes,unrotatedRect:r,rect:Qn(r,a,Jn(t))}:{...e.changes,rect:r}}default:return e.changes}};function Ed(t,e){return(t??0)>0?en(t,e,!1):e/2}const u_=(t,e)=>{switch(e.type){case"vertex-edit":if(e.changes.vertices&&e.changes.vertices.length){const n=Ed(t.cloudyBorderIntensity,t.strokeWidth),o=e.changes.vertices,r=yn(cn(o),n),a=Wa(t,o,r),i=yn(cn(a),n);return{...za(t,i),vertices:a}}return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,vertices:t.vertices.map(a=>({x:a.x+n,y:a.y+o}))}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata);return{...i,vertices:t.vertices.map(s=>({x:a.origin.x+(s.x-r.origin.x)*n,y:a.origin.y+(s.y-r.origin.y)*o}))}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Ha(t,n);return{...n,vertices:t.vertices.map(a=>({x:a.x+o,y:a.y+r}))}}case"property-update":{const n=e.changes.cloudyBorderIntensity!==void 0;if(!(e.changes.strokeWidth!==void 0||e.changes.rotation!==void 0||n))return e.changes;const r={...t,...e.changes},a=Ed(r.cloudyBorderIntensity,r.strokeWidth),i=yn(cn(r.vertices),a);let s=e.changes;const l=(t.cloudyBorderIntensity??0)>0;if(n||e.changes.strokeWidth!==void 0&&l){const u=r.cloudyBorderIntensity??0;if(u>0){const d=en(u,r.strokeWidth,!1);s={...s,rectangleDifferences:{left:d,top:d,right:d,bottom:d}}}else s={...s,rectangleDifferences:void 0}}const c=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...s,unrotatedRect:i,rect:Qn(i,c,Jn(t))}:{...s,rect:i}}default:return e.changes}},d_=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":{let n=e.changes;const o=e.changes.cloudyBorderIntensity!==void 0,r=e.changes.strokeWidth!==void 0,a=(t.cloudyBorderIntensity??0)>0;if(o||r&&a){const i={...t,...e.changes},s=i.cloudyBorderIntensity??0;if(s>0){const l=en(s,i.strokeWidth,!0);n={...n,rectangleDifferences:{left:l,top:l,right:l,bottom:l}}}else n={...n,rectangleDifferences:void 0}}return e.changes.rotation!==void 0&&(n={...n,...Mr(t,e.changes.rotation)}),n}default:return e.changes}},p_=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":{let n=e.changes;const o=e.changes.cloudyBorderIntensity!==void 0,r=e.changes.strokeWidth!==void 0,a=(t.cloudyBorderIntensity??0)>0;if(o||r&&a){const i={...t,...e.changes},s=i.cloudyBorderIntensity??0;if(s>0){const l=en(s,i.strokeWidth,!1);n={...n,rectangleDifferences:{left:l,top:l,right:l,bottom:l}}}else n={...n,rectangleDifferences:void 0}}return e.changes.rotation!==void 0&&(n={...n,...Mr(t,e.changes.rotation)}),n}default:return e.changes}},h_=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":return e.changes.rotation!==void 0?{...e.changes,...Mr(t,e.changes.rotation)}:e.changes;default:return e.changes}},g_=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":return e.changes.rotation!==void 0?{...e.changes,...Mr(t,e.changes.rotation)}:e.changes;default:return e.changes}},f_=[{id:"highlight",name:"Highlight",labelKey:"annotation.highlight",categories:["annotation","markup"],matchScore:t=>t.type===M.HIGHLIGHT?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.HIGHLIGHT,strokeColor:"#FFCD45",color:"#FFCD45",opacity:1,blendMode:it.Multiply}},{id:"underline",name:"Underline",labelKey:"annotation.underline",categories:["annotation","markup"],matchScore:t=>t.type===M.UNDERLINE?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.UNDERLINE,strokeColor:"#E44234",color:"#E44234",opacity:1}},{id:"strikeout",name:"Strikeout",labelKey:"annotation.strikeout",categories:["annotation","markup"],matchScore:t=>t.type===M.STRIKEOUT?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.STRIKEOUT,strokeColor:"#E44234",color:"#E44234",opacity:1}},{id:"squiggly",name:"Squiggly",labelKey:"annotation.squiggly",categories:["annotation","markup"],matchScore:t=>t.type===M.SQUIGGLY?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.SQUIGGLY,strokeColor:"#E44234",color:"#E44234",opacity:1}}],m_=[{id:"insertText",name:"Insert Text",labelKey:"annotation.insertText",categories:["annotation","markup"],matchScore:t=>{var e;return t.type!==M.CARET?0:(e=t.intent)!=null&&e.includes("Insert")?2:1},interaction:{exclusive:!1,textSelection:!0,showSelectionRects:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.CARET,strokeColor:"#E44234",opacity:1,intent:"Insert"},selectionHandler:s_}],P_=[{id:"replaceText",name:"Replace Text",labelKey:"annotation.replaceText",categories:["annotation","markup"],matchScore:t=>{var e,n;return t.type===M.STRIKEOUT&&((e=t.intent)!=null&&e.includes("StrikeOutTextEdit"))||t.type===M.CARET&&((n=t.intent)!=null&&n.includes("Replace"))?2:0},interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.STRIKEOUT,strokeColor:"#E44234",opacity:1,intent:"StrikeOutTextEdit"},selectionHandler:l_}],F_=[{id:"ink",name:"Pen",labelKey:"annotation.ink",categories:["annotation","markup"],matchScore:t=>t.type===M.INK&&t.intent!=="InkHighlight"?5:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1},defaults:{type:M.INK,strokeColor:"#E44234",color:"#E44234",opacity:1,strokeWidth:6},behavior:{commitDelay:800},transform:Dd,pointerHandler:Ss},{id:"inkHighlighter",name:"Ink Highlighter",labelKey:"annotation.inkHighlighter",categories:["annotation","markup"],matchScore:t=>t.type===M.INK&&t.intent==="InkHighlight"?10:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.INK,intent:"InkHighlight",strokeColor:"#FFCD45",color:"#FFCD45",opacity:1,strokeWidth:14,blendMode:it.Multiply},behavior:{commitDelay:800,smartLineRecognition:!0,smartLineThreshold:.15},transform:Dd,pointerHandler:Ss}],b_=[{id:"circle",name:"Circle",labelKey:"annotation.circle",categories:["annotation","shape"],matchScore:t=>t.type===M.CIRCLE?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.CIRCLE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234",strokeStyle:rt.SOLID},clickBehavior:{enabled:!0,defaultSize:{width:100,height:100}},transform:d_,pointerHandler:_d}],__=[{id:"square",name:"Square",labelKey:"annotation.square",categories:["annotation","shape"],matchScore:t=>t.type===M.SQUARE?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.SQUARE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234",strokeStyle:rt.SOLID},clickBehavior:{enabled:!0,defaultSize:{width:100,height:100}},transform:p_,pointerHandler:Fd}],y_=[{id:"line",name:"Line",labelKey:"annotation.line",categories:["annotation","shape"],matchScore:t=>t.type===M.LINE&&t.intent!=="LineArrow"?5:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.LINE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234"},clickBehavior:{enabled:!0,defaultLength:100,defaultAngle:0},transform:Sd,pointerHandler:xs},{id:"lineArrow",name:"Arrow",labelKey:"annotation.arrow",categories:["annotation","shape"],matchScore:t=>t.type===M.LINE&&t.intent==="LineArrow"?10:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.LINE,intent:"LineArrow",color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234",lineEndings:{start:Ct.None,end:Ct.OpenArrow}},clickBehavior:{enabled:!0,defaultLength:100,defaultAngle:0},transform:Sd,pointerHandler:xs}],v_=[{id:"polyline",name:"Polyline",labelKey:"annotation.polyline",categories:["annotation","shape"],matchScore:t=>t.type===M.POLYLINE?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.POLYLINE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234"},transform:c_,pointerHandler:cd}],D_=[{id:"polygon",name:"Polygon",labelKey:"annotation.polygon",categories:["annotation","shape"],matchScore:t=>t.type===M.POLYGON?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.POLYGON,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234"},transform:u_,pointerHandler:Pd}],S_=[{id:"textComment",name:"Comment",labelKey:"annotation.text",categories:["annotation","markup"],matchScore:t=>t.type===M.TEXT&&!t.inReplyToId?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,isRotatable:!1},defaults:{type:M.TEXT,strokeColor:"#FFCD45",opacity:1},behavior:{selectAfterCreate:!0},pointerHandler:sd}],E_=[{id:"freeText",name:"Free Text",labelKey:"annotation.freeText",categories:["annotation","markup"],matchScore:t=>t.type===M.FREETEXT?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.FREETEXT,contents:"Insert text",fontSize:14,fontColor:"#E44234",fontFamily:mt.Helvetica,textAlign:Vt.Left,verticalAlign:Ar.Top,color:"transparent",backgroundColor:"transparent",opacity:1},clickBehavior:{enabled:!0,defaultSize:{width:100,height:20},defaultContent:"Insert text"},behavior:{insertUpright:!0,editAfterCreate:!0,selectAfterCreate:!0},transform:h_,pointerHandler:ld}],A_=[{id:"stamp",name:"Image",labelKey:"annotation.stamp",categories:["annotation","markup"],matchScore:t=>t.type===M.STAMP?1:0,interaction:{exclusive:!1,cursor:"copy",isDraggable:!0,isResizable:!0,lockAspectRatio:!0,lockGroupAspectRatio:!0},defaults:{type:M.STAMP},behavior:{insertUpright:!0,useAppearanceStream:!1},transform:g_,pointerHandler:bd}],x_=[{id:"link",name:"Link",labelKey:"annotation.link",categories:["annotation","markup"],matchScore:t=>t.type===M.LINK?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,isRotatable:!1},defaults:{type:M.LINK,strokeColor:"#0000FF",strokeWidth:2,strokeStyle:rt.UNDERLINE},clickBehavior:{enabled:!0,defaultSize:{width:100,height:20}},pointerHandler:yd}],C_=[...f_,...m_,...P_,...F_,...b_,...__,...y_,...v_,...D_,...S_,...E_,...A_,...x_],T_=["#E44234","#FF8D00","#FFCD45","#5CC96E","#25D2D1","#597CE2","#C544CE","#7D2E25","#000000","#FFFFFF"],Os=t=>t.length===1?t[0]:null,Xa=t=>({pages:{},byUid:{},selectedUids:[],selectedUid:null,activeToolId:null,hasPendingChanges:!1,locked:(t==null?void 0:t.locked)??{type:jn.None}}),M_=(t,e,n)=>{const o=t.byUid[e];return o?{...t,byUid:{...t.byUid,[e]:{...o,commitState:o.commitState==="synced"||o.commitState==="moved"?"dirty":o.commitState,object:{...o.object,...n},dictMode:!0}},hasPendingChanges:!0}:t},R_=(t,e,n)=>{const o=t.byUid[e];return o?{...t,byUid:{...t.byUid,[e]:{...o,commitState:o.commitState==="synced"?"moved":o.commitState,object:{...o.object,...n}}},hasPendingChanges:!0}:t},w_=t=>{const e=new Map;C_.forEach(r=>e.set(r.id,r));const n=new Map(e);(t.tools||[]).forEach(r=>{const a=e.get(r.id);a?n.set(r.id,{...a,...r,defaults:{...a.defaults,...r.defaults},interaction:{...a.interaction,...r.interaction},behavior:{...a.behavior,...r.behavior},...a.clickBehavior||r.clickBehavior?{clickBehavior:{...a.clickBehavior,...r.clickBehavior}}:{}}):n.set(r.id,r)});const o=Array.from(n.values()).map(r=>{var a,i,s;return{...r,behavior:{...r.behavior,deactivateToolAfterCreate:((a=r.behavior)==null?void 0:a.deactivateToolAfterCreate)??t.deactivateToolAfterCreate??!1,selectAfterCreate:((i=r.behavior)==null?void 0:i.selectAfterCreate)??t.selectAfterCreate??!0,editAfterCreate:((s=r.behavior)==null?void 0:s.editAfterCreate)??t.editAfterCreate??!1}}});return{documents:{},activeDocumentId:null,tools:o,colorPresets:t.colorPresets??T_}},O_=(t,e)=>{switch(e.type){case xu:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case Cu:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case ob:return{...t,activeDocumentId:e.payload};case Tu:{const{documentId:n,annotations:o}=e.payload,r=t.documents[n];if(!r)return t;const a={},i={};for(const[s,l]of Object.entries(o)){const c=Number(s),u=r.pages[c]||[];for(const p of u)delete i[p];const d=l.map(p=>{const h=p.id;return i[h]={commitState:"synced",object:p},h});a[c]=d}return{...t,documents:{...t.documents,[n]:{...r,pages:a,byUid:i}}}}case Mu:{const{documentId:n,id:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,selectedUids:[o],selectedUid:o}}}:t}case Ru:{const{documentId:n}=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,selectedUids:[],selectedUid:null}}}:t}case wu:{const{documentId:n,id:o}=e.payload,r=t.documents[n];if(!r||r.selectedUids.includes(o))return t;const a=[...r.selectedUids,o];return{...t,documents:{...t.documents,[n]:{...r,selectedUids:a,selectedUid:Os(a)}}}}case Ou:{const{documentId:n,id:o}=e.payload,r=t.documents[n];if(!r)return t;const a=r.selectedUids.filter(i=>i!==o);return{...t,documents:{...t.documents,[n]:{...r,selectedUids:a,selectedUid:Os(a)}}}}case ku:{const{documentId:n,ids:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,selectedUids:o,selectedUid:Os(o)}}}:t}case Iu:{const{documentId:n,toolId:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,activeToolId:o}}}:t}case Gu:{const{documentId:n,pageIndex:o,annotation:r}=e.payload,a=t.documents[n];if(!a)return t;const i=r.id;return{...t,documents:{...t.documents,[n]:{...a,pages:{...a.pages,[o]:[...a.pages[o]??[],i]},byUid:{...a.byUid,[i]:{commitState:"new",object:r,dictMode:!0}},hasPendingChanges:!0}}}}case Nu:{const{documentId:n,pageIndex:o,id:r}=e.payload,a=t.documents[n];return!a||!a.byUid[r]?t:{...t,documents:{...t.documents,[n]:{...a,pages:{...a.pages,[o]:(a.pages[o]??[]).filter(i=>i!==r)},byUid:{...a.byUid,[r]:{...a.byUid[r],commitState:"deleted"}},hasPendingChanges:!0}}}}case Lu:{const{documentId:n,id:o,patch:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:M_(a,o,r)}}:t}case $u:{const{documentId:n,id:o,patch:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:R_(a,o,r)}}:t}case ju:{const{documentId:n,committedUids:o}=e.payload,r=t.documents[n];if(!r)return t;const a=new Set(o),i={};let s=!1;for(const[l,c]of Object.entries(r.byUid))a.has(l)?i[l]={...c,commitState:c.commitState==="dirty"||c.commitState==="new"||c.commitState==="moved"?"synced":c.commitState}:(i[l]=c,(c.commitState==="new"||c.commitState==="dirty"||c.commitState==="moved"||c.commitState==="deleted")&&(s=!0));return{...t,documents:{...t.documents,[n]:{...r,byUid:i,hasPendingChanges:s}}}}case Uu:{const{documentId:n,pageIndex:o,uid:r}=e.payload,a=t.documents[n];if(!a||!a.byUid[r])return t;const{[r]:i,...s}=a.byUid;return{...t,documents:{...t.documents,[n]:{...a,pages:{...a.pages,[o]:(a.pages[o]??[]).filter(l=>l!==r)},byUid:s}}}}case Bu:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,locked:o}}}:t}case zu:{const{documentId:n,id:o,patch:r}=e.payload,a=t.documents[n];if(!a)return t;const i=a.byUid[o];return i?{...t,documents:{...t.documents,[n]:{...a,byUid:{...a.byUid,[o]:{...i,object:{...i.object,...r}}}}}}:t}case Vu:{const n=new Map(t.tools.map(o=>[o.id,o]));return n.set(e.payload.id,e.payload),{...t,tools:Array.from(n.values())}}case Hu:{const{toolId:n,patch:o}=e.payload;return{...t,tools:t.tools.map(r=>r.id===n?{...r,defaults:{...r.defaults,...o}}:r)}}case Wu:return t.colorPresets.includes(e.payload)?t:{...t,colorPresets:[...t.colorPresets,e.payload]};default:return t}},ks=class Ff extends jt{constructor(e,n,o){var r,a,i,s;super(e,n),this.ANNOTATION_HISTORY_TOPIC="annotations",this.state$=Tt((l,c)=>({documentId:l,state:c})),this.pendingContexts=new Map,this.isInitialLoadComplete=new Map,this.importQueue=new Map,this.commitInProgress=new Map,this.activeTool$=Tt((l,c)=>({documentId:l,tool:c})),this.events$=Tt((l,c)=>c,{cache:!1}),this.toolsChange$=Be(),this.appearanceCache=new Map,this.unifiedDragStates=new Map,this.unifiedDrag$=Be(),this.unifiedResizeStates=new Map,this.unifiedResize$=Be(),this.unifiedRotateStates=new Map,this.unifiedRotate$=Be(),this.navigate$=Tt((l,c)=>c,{cache:!1}),this.config=o,this.selection=((r=n.getPlugin("selection"))==null?void 0:r.provides())??null,this.history=((a=n.getPlugin("history"))==null?void 0:a.provides())??null,this.scroll=((i=n.getPlugin("scroll"))==null?void 0:i.provides())??null,this.interactionManager=((s=n.getPlugin("interaction-manager"))==null?void 0:s.provides())??null}onDocumentLoadingStarted(e){this.dispatch(rb(e,Xa(this.config))),this.pendingContexts.set(e,new Map),this.isInitialLoadComplete.set(e,!1),this.importQueue.set(e,[]),this.logger.debug("AnnotationPlugin","DocumentOpened",`Initialized annotation state for document: ${e}`)}onDocumentLoaded(e){const n=this.getCoreDocument(e);if(n!=null&&n.document&&this.getAllAnnotations(e,n.document),this.selection)for(const o of this.state.tools)o.interaction.textSelection&&this.selection.enableForMode(o.interaction.mode??o.id,{showSelectionRects:o.interaction.showSelectionRects??!1,enableSelection:!0,enableMarquee:!1})}onDocumentClosed(e){this.dispatch(ab(e)),this.pendingContexts.delete(e),this.isInitialLoadComplete.delete(e),this.importQueue.delete(e),this.appearanceCache.delete(e),this.state$.clearScope(e),this.activeTool$.clearScope(e),this.events$.clearScope(e),this.navigate$.clearScope(e),this.logger.debug("AnnotationPlugin","DocumentClosed",`Cleaned up annotation state for document: ${e}`)}async initialize(){var e,n,o;this.state.tools.forEach(r=>this.registerInteractionForTool(r)),this.history&&this.history.onHistoryChange(r=>{r.topic===this.ANNOTATION_HISTORY_TOPIC&&this.config.autoCommit!==!1&&this.commit(r.documentId)}),(e=this.interactionManager)==null||e.onModeChange(r=>{var a,i;const s=((a=this.state.tools.find(c=>(c.interaction.mode??c.id)===r.activeMode))==null?void 0:a.id)??null,l=((i=this.state.documents[r.documentId])==null?void 0:i.activeToolId)??null;s!==l&&r.documentId&&this.dispatch(qu(r.documentId,s))}),(n=this.selection)==null||n.onMarqueeEnd(({documentId:r,pageIndex:a,rect:i,modeId:s})=>{if(s!=="pointerMode")return;const l=this.state.documents[r];if(!l)return;const u=(l.pages[a]??[]).map(d=>l.byUid[d]).filter(d=>d!==void 0).filter(d=>Rb(d)).filter(d=>gb(i,d.object.rect)).filter(d=>!this.isAnnotationLocked(d.object,r)).map(d=>d.object.id);if(u.length>0){const d=new Set;for(const p of u)if(this.isInGroupMethod(p,r)){const h=this.getGroupMembersMethod(p,r);for(const g of h)d.add(g.object.id)}else d.add(p);this.setSelectionMethod([...d],r)}}),(o=this.selection)==null||o.onEndSelection(({documentId:r})=>{var a,i,s,l;if(!this.checkPermission(r,te.ModifyAnnotations))return;const c=this.getActiveTool(r);if(!c||!c.interaction.textSelection)return;const u=(a=this.selection)==null?void 0:a.getFormattedSelection(),d=(i=this.selection)==null?void 0:i.getSelectedText();if(!u||!d)return;const p=()=>new Promise(f=>{d.wait(F=>f(F.join(`
21
- `)),()=>f(void 0))}),h={toolId:c.id,documentId:r,getTool:()=>this.getActiveTool(r)??null,createAnnotation:(f,F)=>this.createAnnotation(f,F,void 0,r),selectAnnotation:(f,F)=>this.selectAnnotation(f,F,r)};(c.selectionHandler??i_).handle(h,u,p),(s=c.behavior)!=null&&s.deactivateToolAfterCreate&&this.setActiveTool(null,r),(l=this.selection)==null||l.clear()})}registerInteractionForTool(e){var n;(n=this.interactionManager)==null||n.registerMode({id:e.interaction.mode??e.id,scope:"page",exclusive:e.interaction.exclusive,cursor:e.interaction.cursor})}buildCapability(){return{getActiveTool:()=>this.getActiveTool(),setActiveTool:e=>this.setActiveTool(e),getState:()=>this.getDocumentState(),getPageAnnotations:e=>this.getPageAnnotations(e),getSelectedAnnotation:()=>this.getSelectedAnnotation(),getSelectedAnnotations:()=>this.getSelectedAnnotationsMethod(),getSelectedAnnotationIds:()=>this.getSelectedAnnotationIdsMethod(),getAnnotationById:e=>this.getAnnotationById(e),selectAnnotation:(e,n)=>this.selectAnnotation(e,n),toggleSelection:(e,n)=>this.toggleSelectionMethod(e,n),addToSelection:(e,n)=>this.addToSelectionMethod(e,n),removeFromSelection:e=>this.removeFromSelectionMethod(e),setSelection:e=>this.setSelectionMethod(e),deselectAnnotation:()=>this.deselectAnnotation(),importAnnotations:e=>this.importAnnotations(e),createAnnotation:(e,n,o)=>this.createAnnotation(e,n,o),updateAnnotation:(e,n,o)=>this.updateAnnotation(e,n,o),updateAnnotations:e=>this.updateAnnotationsMethod(e),moveAnnotation:(e,n,o,r,a)=>this.moveAnnotationMethod(e,n,o,r,a),deleteAnnotation:(e,n)=>this.deleteAnnotation(e,n),deleteAnnotations:(e,n)=>this.deleteAnnotationsMethod(e,n),purgeAnnotation:(e,n,o)=>this.purgeAnnotationMethod(e,n,o),renderAnnotation:e=>this.renderAnnotation(e),getPageAppearances:(e,n,o)=>this.getPageAppearances(e,n,o),invalidatePageAppearances:(e,n)=>this.invalidatePageAppearances(e,n),commit:()=>this.commit(),getAttachedLinks:(e,n)=>this.getAttachedLinksMethod(e,n),hasAttachedLinks:(e,n)=>this.hasAttachedLinksMethod(e,n),deleteAttachedLinks:(e,n)=>this.deleteAttachedLinksMethod(e,n),groupAnnotations:e=>this.groupAnnotationsMethod(e),ungroupAnnotations:(e,n)=>this.ungroupAnnotationsMethod(e,n),getGroupMembers:(e,n)=>this.getGroupMembersMethod(e,n),isInGroup:(e,n)=>this.isInGroupMethod(e,n),setLocked:(e,n)=>this.setLocked(e,n),getLocked:e=>this.getLocked(e),isAnnotationLocked:(e,n)=>this.isAnnotationLocked(e,n),isCategoryLocked:(e,n)=>this.isCategoryLockedMethod(e,n),isToolLocked:(e,n)=>this.isToolLockedMethod(e,n),syncAnnotationObject:(e,n,o)=>this.syncAnnotationObject(e,n,o),navigateTarget:(e,n)=>this.navigateTargetMethod(e,n),forDocument:e=>this.createAnnotationScope(e),getTools:()=>this.state.tools,getTool:e=>this.getTool(e),addTool:e=>{this.dispatch(hb(e)),this.registerInteractionForTool(e)},findToolForAnnotation:e=>this.findToolForAnnotation(e),setToolDefaults:(e,n)=>this.dispatch(pb(e,n)),getColorPresets:()=>[...this.state.colorPresets],addColorPreset:e=>this.dispatch(db(e)),transformAnnotation:(e,n)=>this.transformAnnotation(e,n),onStateChange:this.state$.onGlobal,onActiveToolChange:this.activeTool$.onGlobal,onAnnotationEvent:this.events$.onGlobal,onToolsChange:this.toolsChange$.on,onNavigate:this.navigate$.onGlobal}}createAnnotationScope(e){return{getState:()=>this.getDocumentState(e),getPageAnnotations:n=>this.getPageAnnotations(n,e),getSelectedAnnotation:()=>this.getSelectedAnnotation(e),getSelectedAnnotations:()=>this.getSelectedAnnotationsMethod(e),getSelectedAnnotationIds:()=>this.getSelectedAnnotationIdsMethod(e),getAnnotationById:n=>this.getAnnotationById(n,e),selectAnnotation:(n,o)=>this.selectAnnotation(n,o,e),toggleSelection:(n,o)=>this.toggleSelectionMethod(n,o,e),addToSelection:(n,o)=>this.addToSelectionMethod(n,o,e),removeFromSelection:n=>this.removeFromSelectionMethod(n,e),setSelection:n=>this.setSelectionMethod(n,e),deselectAnnotation:()=>this.deselectAnnotation(e),getActiveTool:()=>this.getActiveTool(e),setActiveTool:n=>this.setActiveTool(n,e),findToolForAnnotation:n=>this.findToolForAnnotation(n),importAnnotations:n=>this.importAnnotations(n,e),createAnnotation:(n,o,r)=>this.createAnnotation(n,o,r,e),updateAnnotation:(n,o,r)=>this.updateAnnotation(n,o,r,e),updateAnnotations:n=>this.updateAnnotationsMethod(n,e),moveAnnotation:(n,o,r,a)=>this.moveAnnotationMethod(n,o,r,a,e),deleteAnnotation:(n,o)=>this.deleteAnnotation(n,o,e),deleteAnnotations:n=>this.deleteAnnotationsMethod(n,e),purgeAnnotation:(n,o)=>this.purgeAnnotationMethod(n,o,e),renderAnnotation:n=>this.renderAnnotation(n,e),getPageAppearances:(n,o)=>this.getPageAppearances(n,o,e),invalidatePageAppearances:n=>this.invalidatePageAppearances(n,e),commit:()=>this.commit(e),getAttachedLinks:n=>this.getAttachedLinksMethod(n,e),hasAttachedLinks:n=>this.hasAttachedLinksMethod(n,e),deleteAttachedLinks:n=>this.deleteAttachedLinksMethod(n,e),groupAnnotations:()=>this.groupAnnotationsMethod(e),ungroupAnnotations:n=>this.ungroupAnnotationsMethod(n,e),getGroupMembers:n=>this.getGroupMembersMethod(n,e),isInGroup:n=>this.isInGroupMethod(n,e),getGroupingAction:()=>this.getGroupingActionMethod(e),setLocked:n=>this.setLocked(n,e),getLocked:()=>this.getLocked(e),isAnnotationLocked:n=>this.isAnnotationLocked(n,e),isCategoryLocked:n=>this.isCategoryLockedMethod(n,e),isToolLocked:n=>this.isToolLockedMethod(n,e),syncAnnotationObject:(n,o)=>this.syncAnnotationObject(n,o,e),navigateTarget:n=>this.navigateTargetMethod(n,e),onStateChange:this.state$.forScope(e),onAnnotationEvent:this.events$.forScope(e),onActiveToolChange:this.activeTool$.forScope(e),onNavigate:this.navigate$.forScope(e)}}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&(this.state$.emit(o,a),r&&r.activeToolId!==a.activeToolId&&this.activeTool$.emit(o,this.getActiveTool(o)),(r==null?void 0:r.selectedUids)!==a.selectedUids&&this.updateAnnotationSelectionActivity(o,a))}if(e.tools!==n.tools){for(const o in n.documents)this.activeTool$.emit(o,this.getActiveTool(o));this.toolsChange$.emit({tools:n.tools})}}transformAnnotation(e,n){const o={type:n.type,changes:n.changes,metadata:n.metadata},r=this.findToolForAnnotation(e);return r!=null&&r.transform?r.transform(e,o):o.changes}registerPageHandlers(e,n,o,r){var a,i;const s=this.getCoreDocument(e),l=(a=s==null?void 0:s.document)==null?void 0:a.pages[n];if(!l)return()=>{};if(!this.interactionManager)return()=>{};const c=[],u=((l.rotation??0)+((s==null?void 0:s.rotation)??0))%4;for(const d of this.state.tools){const p=d.pointerHandler??((i=d.defaults)!=null&&i.type?Ff.defaultHandlerFactories.get(d.defaults.type):void 0);if(!p)continue;const h={pageIndex:n,pageSize:l.size,pageRotation:u,scale:o,services:r.services,onPreview:f=>r.onPreview(d.id,f),onCommit:(f,F)=>{var _,y,E;const A=((_=d.behavior)==null?void 0:_.editAfterCreate)??!1;this.createAnnotation(n,f,F,e,{editAfterCreate:A}),(y=d.behavior)!=null&&y.deactivateToolAfterCreate&&this.setActiveTool(null,e),((E=d.behavior)!=null&&E.selectAfterCreate||A)&&this.selectAnnotation(n,f.id,e)},getTool:()=>this.state.tools.find(f=>f.id===d.id)},g=this.interactionManager.registerHandlers({documentId:e,modeId:d.interaction.mode??d.id,handlers:p.create(h),pageIndex:n});c.push(g)}return()=>c.forEach(d=>d())}getDocumentState(e){const n=e??this.getActiveDocumentId(),o=this.state.documents[n];if(!o)throw new Error(`Annotation state not found for document: ${n}`);return o}getAllAnnotations(e,n){this.engine.getAllAnnotations(n).wait(r=>{this.dispatch(ib(e,r)),this.isInitialLoadComplete.set(e,!0);const a=this.importQueue.get(e);a&&a.length>0&&this.processImportQueue(e),this.events$.emit(e,{type:"loaded",documentId:e,total:Object.values(r).reduce((i,s)=>i+s.length,0)})},Yt)}getPageAnnotations(e,n){const{pageIndex:o}=e,r=n??this.getActiveDocumentId(),a=this.getCoreDocument(r),i=a==null?void 0:a.document;if(!i)return Ue.reject({code:ve.NotFound,message:"Document not found"});const s=i.pages.find(l=>l.index===o);return s?this.engine.getPageAnnotations(i,s):Ue.reject({code:ve.NotFound,message:"Page not found"})}getSelectedAnnotation(e){return Ob(this.getDocumentState(e))}getAnnotationById(e,n){const o=this.getDocumentState(n);return kb(o,e)}renderAnnotation({pageIndex:e,annotation:n,options:o},r){const a=r??this.getActiveDocumentId(),i=this.getCoreDocument(a),s=i==null?void 0:i.document;if(!s)return Ue.reject({code:ve.NotFound,message:"Document not found"});const l=s.pages.find(c=>c.index===e);return l?this.engine.renderPageAnnotation(s,l,n,o):Ue.reject({code:ve.NotFound,message:"Page not found"})}getPageAppearances(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getCoreDocument(r),i=a==null?void 0:a.document;if(!i)return Ue.reject({code:ve.NotFound,message:"Document not found"});const s=i.pages.find(p=>p.index===e);if(!s)return Ue.reject({code:ve.NotFound,message:"Page not found"});let l=this.appearanceCache.get(r);l||(l=new Map,this.appearanceCache.set(r,l));const c=l.get(e);if(c&&!n){const p=new Ie;return p.resolve(c),p}const u=this.engine.renderPageAnnotations(i,s,n),d=new Ie;return u.wait(p=>{l.set(e,p),d.resolve(p)},p=>{d.fail(p)}),d}invalidatePageAppearances(e,n){const o=n??this.getActiveDocumentId(),r=this.appearanceCache.get(o);r&&r.delete(e)}invalidateAnnotationAppearance(e,n,o){const r=o??this.getActiveDocumentId(),a=this.appearanceCache.get(r);if(!a)return;const i=a.get(n);i&&delete i[e]}importAnnotations(e,n){const o=n??this.getActiveDocumentId();if(!this.isInitialLoadComplete.get(o)){const r=this.importQueue.get(o)||[];r.push(...e),this.importQueue.set(o,r);return}this.processImportItems(o,e)}processImportQueue(e){const n=this.importQueue.get(e);if(!n||n.length===0)return;const o=[...n];this.importQueue.set(e,[]),this.processImportItems(e,o)}processImportItems(e,n){const o=this.pendingContexts.get(e);if(o){for(const r of n){const{annotation:a,ctx:i}=r,s=a.pageIndex,l=a.id;this.dispatch(ja(e,s,a)),i&&o.set(l,i)}this.config.autoCommit!==!1&&this.commit(e)}}createAnnotation(e,n,o,r,a){const i=r??this.getActiveDocumentId();if(!this.checkPermission(i,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","CreateAnnotation",`Cannot create annotation: document ${i} lacks ModifyAnnotations permission`);return}const s=n.id,l=this.pendingContexts.get(i);if(!l)return;const c={...n,author:n.author??this.config.annotationAuthor},u=a==null?void 0:a.editAfterCreate,d=()=>{this.dispatch(ja(i,e,c)),o&&l.set(s,o),this.events$.emit(i,{type:"create",documentId:i,annotation:c,pageIndex:e,ctx:o,committed:!1,editAfterCreate:u})};if(!this.history){d(),this.config.autoCommit&&this.commit(i);return}const p={execute:d,undo:()=>{l.delete(s),this.dispatch(Ps(i)),this.dispatch(_s(i,e,s)),this.events$.emit(i,{type:"delete",documentId:i,annotation:c,pageIndex:e,committed:!1})},metadata:{annotationIds:[s]}};this.history.forDocument(i).register(p,this.ANNOTATION_HISTORY_TOPIC)}buildPatch(e,n){return"rect"in n?n:this.transformAnnotation(e,{type:"property-update",changes:n})}updateAnnotation(e,n,o,r){const a=r??this.getActiveDocumentId();if(!this.checkPermission(a,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","UpdateAnnotation",`Cannot update annotation: document ${a} lacks ModifyAnnotations permission`);return}const s=this.getDocumentState(a).byUid[n].object,l=this.buildPatch(s,{...o,author:o.author??this.config.annotationAuthor}),c=()=>{this.dispatch(Ua(a,e,n,l)),this.events$.emit(a,{type:"update",documentId:a,annotation:s,pageIndex:e,patch:l,committed:!1})};if(!this.history){c(),this.config.autoCommit!==!1&&this.commit(a);return}const u=Object.fromEntries(Object.keys(o).map(h=>[h,s[h]])),d={execute:c,undo:()=>{this.dispatch(Ua(a,e,n,u)),this.events$.emit(a,{type:"update",documentId:a,annotation:s,pageIndex:e,patch:u,committed:!1})},metadata:{annotationIds:[n]}};this.history.forDocument(a).register(d,this.ANNOTATION_HISTORY_TOPIC)}deleteAnnotation(e,n,o){var r;const a=o??this.getActiveDocumentId();if(!this.checkPermission(a,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","DeleteAnnotation",`Cannot delete annotation: document ${a} lacks ModifyAnnotations permission`);return}const i=this.getDocumentState(a),s=(r=i.byUid[n])==null?void 0:r.object;if(!s)return;const l=Lb(i,n),c=l.map(h=>{var g;return(g=i.byUid[h.id])==null?void 0:g.object}).filter(h=>h!==void 0),u=()=>{var h;for(const g of l){const f=(h=i.byUid[g.id])==null?void 0:h.object;f&&(this.dispatch(_s(a,g.pageIndex,g.id)),this.events$.emit(a,{type:"delete",documentId:a,annotation:f,pageIndex:g.pageIndex,committed:!1}))}this.dispatch(Ps(a)),this.dispatch(_s(a,e,n)),this.events$.emit(a,{type:"delete",documentId:a,annotation:s,pageIndex:e,committed:!1})};if(!this.history){u(),this.config.autoCommit!==!1&&this.commit(a);return}const d={execute:u,undo:()=>{this.dispatch(ja(a,e,s)),this.events$.emit(a,{type:"create",documentId:a,annotation:s,pageIndex:e,committed:!1});for(const h of c)this.dispatch(ja(a,h.pageIndex,h)),this.events$.emit(a,{type:"create",documentId:a,annotation:h,pageIndex:h.pageIndex,committed:!1})},metadata:{annotationIds:[n,...l.map(h=>h.id)]}};this.history.forDocument(a).register(d,this.ANNOTATION_HISTORY_TOPIC)}deleteAnnotationsMethod(e,n){for(const{pageIndex:o,id:r}of e)this.deleteAnnotation(o,r,n)}purgeAnnotationMethod(e,n,o){const r=o??this.getActiveDocumentId();this.dispatch(ys(r,e,n))}selectAnnotation(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getAnnotationById(n,r);if(!(a&&this.isAnnotationLocked(a.object,r)))if(this.isInGroupMethod(n,r)){const s=this.getGroupMembersMethod(n,r).map(l=>l.object.id);this.dispatch(bs(r,s))}else this.dispatch(sb(r,e,n))}deselectAnnotation(e){const n=e??this.getActiveDocumentId();this.dispatch(Ps(n))}updateAnnotationSelectionActivity(e,n){var o,r;if(n.selectedUids.length===0){(o=this.interactionManager)==null||o.releasePageActivity(e,"annotation-selection");return}const a=n.selectedUids[0],i=n.byUid[a];i&&((r=this.interactionManager)==null||r.claimPageActivity(e,"annotation-selection",i.object.pageIndex))}getSelectedAnnotationsMethod(e){return Qu(this.getDocumentState(e))}getSelectedAnnotationIdsMethod(e){return Ju(this.getDocumentState(e))}toggleSelectionMethod(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getAnnotationById(n,r);if(a&&this.isAnnotationLocked(a.object,r))return;const i=this.getDocumentState(r);if(i.selectedUids.includes(n))this.dispatch(Yu(r,n));else if(this.isInGroupMethod(n,r)){const s=this.getGroupMembersMethod(n,r);for(const l of s)i.selectedUids.includes(l.object.id)||this.dispatch(Fs(r,l.object.pageIndex,l.object.id))}else this.dispatch(Fs(r,e,n))}addToSelectionMethod(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getAnnotationById(n,r);a&&this.isAnnotationLocked(a.object,r)||this.dispatch(Fs(r,e,n))}removeFromSelectionMethod(e,n){const o=n??this.getActiveDocumentId();this.dispatch(Yu(o,e))}setSelectionMethod(e,n){const o=n??this.getActiveDocumentId(),r=this.getDocumentState(o),a=e.filter(i=>{const s=r.byUid[i];return!s||!this.isAnnotationLocked(s.object,o)});this.dispatch(bs(o,a))}getAttachedLinksMethod(e,n){return Nb(this.getDocumentState(n),e)}hasAttachedLinksMethod(e,n){return this.getAttachedLinksMethod(e,n).length>0}deleteAttachedLinksMethod(e,n){const o=this.getAttachedLinksMethod(e,n);for(const r of o)this.deleteAnnotation(r.object.pageIndex,r.object.id,n)}groupAnnotationsMethod(e){const n=e??this.getActiveDocumentId();if(!this.checkPermission(n,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","GroupAnnotations",`Cannot group annotations: document ${n} lacks ModifyAnnotations permission`);return}const o=this.getSelectedAnnotationsMethod(n);if(o.length<2){this.logger.debug("AnnotationPlugin","GroupAnnotations","Need at least 2 annotations to group");return}const r=o[0],i=o.slice(1).map(s=>({pageIndex:s.object.pageIndex,id:s.object.id,patch:{inReplyToId:r.object.id,replyType:Ln.Group}}));this.updateAnnotationsMethod(i,n)}ungroupAnnotationsMethod(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","UngroupAnnotations",`Cannot ungroup annotations: document ${o} lacks ModifyAnnotations permission`);return}const a=this.getGroupMembersMethod(e,o).filter(i=>i.object.inReplyToId&&i.object.replyType===Ln.Group).map(i=>({pageIndex:i.object.pageIndex,id:i.object.id,patch:{inReplyToId:void 0,replyType:void 0}}));a.length>0&&this.updateAnnotationsMethod(a,o)}getGroupMembersMethod(e,n){return ed(this.getDocumentState(n),e)}isInGroupMethod(e,n){return td(this.getDocumentState(n),e)}getGroupingActionMethod(e){return Ub(this.getDocumentState(e))}computeCombinedConstraints(e){let n=1/0,o=1/0,r=1/0,a=1/0;for(const i of e){const s=i.rect.origin.y,l=i.pageSize.height-(i.rect.origin.y+i.rect.size.height),c=i.rect.origin.x,u=i.pageSize.width-(i.rect.origin.x+i.rect.size.width);n=Math.min(n,s),o=Math.min(o,l),r=Math.min(r,c),a=Math.min(a,u)}return isFinite(n)||(n=0),isFinite(o)||(o=0),isFinite(r)||(r=0),isFinite(a)||(a=0),{maxUp:n,maxDown:o,maxLeft:r,maxRight:a}}clampDelta(e,n){return{x:Math.max(-n.maxLeft,Math.min(n.maxRight,e.x)),y:Math.max(-n.maxUp,Math.min(n.maxDown,e.y))}}startDrag(e,n){const{annotationIds:o,pageSize:r}=n,a=[];for(const d of o){const p=this.getAttachedLinksMethod(d,e);for(const h of p)a.includes(h.object.id)||a.push(h.object.id)}const i=[...o,...a],s=new Map,l=[];for(const d of i){const p=this.getAnnotationById(d,e);p&&(s.set(d,{...p.object.rect}),l.push({id:d,rect:p.object.rect,pageIndex:p.object.pageIndex,pageSize:r}))}const c=this.computeCombinedConstraints(l),u={documentId:e,isDragging:!0,primaryIds:o,attachedLinkIds:a,allParticipantIds:i,originalRects:s,delta:{x:0,y:0},combinedConstraints:c};this.unifiedDragStates.set(e,u),this.unifiedDrag$.emit({documentId:e,type:"start",state:u,previewPatches:{}})}computeDragPreviewPatches(e,n){const o={};for(const r of e.allParticipantIds){const a=this.getAnnotationById(r,n);if(!a)continue;const i=e.originalRects.get(r);if(!i)continue;const s={...i,origin:{x:i.origin.x+e.delta.x,y:i.origin.y+e.delta.y}};o[r]=this.transformAnnotation(a.object,{type:"move",changes:{rect:s}})}return o}updateDrag(e,n){const o=this.unifiedDragStates.get(e);if(!(o!=null&&o.isDragging))return{x:0,y:0};const r=this.clampDelta(n,o.combinedConstraints),a={...o,delta:r};this.unifiedDragStates.set(e,a);const i=this.computeDragPreviewPatches(a,e);return this.unifiedDrag$.emit({documentId:e,type:"update",state:a,previewPatches:i}),r}commitDrag(e){const n=this.unifiedDragStates.get(e);if(!n)return;const o=n.delta;if(o.x!==0||o.y!==0){const a=[];for(const i of n.allParticipantIds){const s=this.getAnnotationById(i,e);if(!s)continue;const l=n.originalRects.get(i)??s.object.rect,c={...l,origin:{x:l.origin.x+o.x,y:l.origin.y+o.y}},u=this.transformAnnotation(s.object,{type:"move",changes:{rect:c}});a.push({pageIndex:s.object.pageIndex,id:i,patch:u})}a.length>0&&this.moveAnnotationsMethod(a,e)}const r=this.computeDragPreviewPatches(n,e);this.unifiedDrag$.emit({documentId:e,type:"end",state:{...n,isDragging:!1},previewPatches:r}),this.unifiedDragStates.delete(e)}cancelDrag(e){const n=this.unifiedDragStates.get(e);n&&(this.unifiedDrag$.emit({documentId:e,type:"cancel",state:{...n,isDragging:!1,delta:{x:0,y:0}},previewPatches:{}}),this.unifiedDragStates.delete(e))}getDragState(e){return this.unifiedDragStates.get(e)??null}get onDragChange(){return this.unifiedDrag$.on}computeUnifiedGroupBoundingBox(e){if(e.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};let n=1/0,o=1/0,r=-1/0,a=-1/0;for(const i of e)n=Math.min(n,i.origin.x),o=Math.min(o,i.origin.y),r=Math.max(r,i.origin.x+i.size.width),a=Math.max(a,i.origin.y+i.size.height);return{origin:{x:n,y:o},size:{width:r-n,height:a-o}}}computeUnifiedRelativePositions(e,n){return e.map(o=>({id:o.id,originalRect:o.rect,originalUnrotatedRect:o.unrotatedRect,pageIndex:o.pageIndex,isAttachedLink:o.isAttachedLink,parentId:o.parentId,relativeX:n.size.width>0?(o.rect.origin.x-n.origin.x)/n.size.width:0,relativeY:n.size.height>0?(o.rect.origin.y-n.origin.y)/n.size.height:0,relativeWidth:n.size.width>0?o.rect.size.width/n.size.width:1,relativeHeight:n.size.height>0?o.rect.size.height/n.size.height:1}))}computeUnifiedResizedRects(e,n,o=10){const r=new Map;for(const a of e){const i=Math.max(o,a.relativeWidth*n.size.width),s=Math.max(o,a.relativeHeight*n.size.height);r.set(a.id,{origin:{x:n.origin.x+a.relativeX*n.size.width,y:n.origin.y+a.relativeY*n.size.height},size:{width:i,height:s}})}return r}computeResizePreviewPatches(e,n){const o={},r=this.unifiedResizeStates.get(n),a=r?new Map(r.participatingAnnotations.map(i=>[i.id,i])):void 0;for(const[i,s]of e){const l=this.getAnnotationById(i,n);if(!l)continue;let c=s;const u=a==null?void 0:a.get(i);r!=null&&r.isGroupResize&&(u!=null&&u.originalUnrotatedRect)&&(c=ud(s,u.originalRect,u.originalUnrotatedRect,l.object.rotation??0)),o[i]=this.transformAnnotation(l.object,{type:"resize",changes:{rect:c}})}return o}startResize(e,n){const{annotationIds:o,pageSize:r,resizeHandle:a}=n,i=[],s=[];for(const f of o){const F=this.getAnnotationById(f,e);if(F){s.push({id:f,rect:F.object.rect,unrotatedRect:F.object.unrotatedRect?this.cloneRect(F.object.unrotatedRect):void 0,pageIndex:F.object.pageIndex,isAttachedLink:!1});const _=this.getAttachedLinksMethod(f,e);for(const y of _)i.includes(y.object.id)||(i.push(y.object.id),s.push({id:y.object.id,rect:y.object.rect,unrotatedRect:y.object.unrotatedRect?this.cloneRect(y.object.unrotatedRect):void 0,pageIndex:y.object.pageIndex,isAttachedLink:!0,parentId:f}))}}const l=[...o,...i],c=s.map(f=>f.rect),u=this.computeUnifiedGroupBoundingBox(c),d=this.computeUnifiedRelativePositions(s,u),p=this.computeUnifiedResizedRects(d,u),h={documentId:e,isResizing:!0,isGroupResize:o.length>1,primaryIds:o,attachedLinkIds:i,allParticipantIds:l,originalGroupBox:u,currentGroupBox:u,participatingAnnotations:d,resizeHandle:a,computedRects:p};this.unifiedResizeStates.set(e,h);const g=this.computeResizePreviewPatches(p,e);this.unifiedResize$.emit({documentId:e,type:"start",state:h,computedRects:Object.fromEntries(p),previewPatches:g})}updateResize(e,n){const o=this.unifiedResizeStates.get(e);if(!(o!=null&&o.isResizing))return{};const r=this.computeUnifiedResizedRects(o.participatingAnnotations,n),a={...o,currentGroupBox:n,computedRects:r};this.unifiedResizeStates.set(e,a);const i=Object.fromEntries(r),s=this.computeResizePreviewPatches(r,e);return this.unifiedResize$.emit({documentId:e,type:"update",state:a,computedRects:i,previewPatches:s}),i}commitResize(e){const n=this.unifiedResizeStates.get(e);if(!n)return;const o=this.computeUnifiedResizedRects(n.participatingAnnotations,n.currentGroupBox),r=[],a=new Map(n.participatingAnnotations.map(s=>[s.id,s]));for(const[s,l]of o){const c=this.getAnnotationById(s,e);if(!c)continue;let u=l;const d=a.get(s);n.isGroupResize&&(d!=null&&d.originalUnrotatedRect)&&(u=ud(l,d.originalRect,d.originalUnrotatedRect,c.object.rotation??0));const p=this.transformAnnotation(c.object,{type:"resize",changes:{rect:u}});r.push({pageIndex:c.object.pageIndex,id:s,patch:p})}r.length>0&&this.updateAnnotationsMethod(r,e);const i=this.computeResizePreviewPatches(o,e);this.unifiedResize$.emit({documentId:e,type:"end",state:{...n,isResizing:!1},computedRects:Object.fromEntries(o),previewPatches:i}),this.unifiedResizeStates.delete(e)}cancelResize(e){const n=this.unifiedResizeStates.get(e);if(!n)return;const o=this.computeUnifiedResizedRects(n.participatingAnnotations,n.originalGroupBox);this.unifiedResize$.emit({documentId:e,type:"cancel",state:{...n,isResizing:!1,currentGroupBox:n.originalGroupBox},computedRects:Object.fromEntries(o),previewPatches:{}}),this.unifiedResizeStates.delete(e)}getResizeState(e){return this.unifiedResizeStates.get(e)??null}get onResizeChange(){return this.unifiedResize$.on}cloneRect(e){return{origin:{x:e.origin.x,y:e.origin.y},size:{width:e.size.width,height:e.size.height}}}translateRect(e,n){return{origin:{x:e.origin.x+n.x,y:e.origin.y+n.y},size:{...e.size}}}normalizeAngle(e){const n=e%360;return n<0?n+360:n}normalizeDelta(e){return(e+540)%360-180}buildRotationParticipants(e,n){const o=[],r=[];for(const a of e){const i=this.getAnnotationById(a,n);if(!i)continue;o.push({id:a,rect:this.cloneRect(i.object.rect),pageIndex:i.object.pageIndex,rotation:i.object.rotation??0,unrotatedRect:i.object.unrotatedRect?this.cloneRect(i.object.unrotatedRect):void 0,isAttachedLink:!1});const s=this.getAttachedLinksMethod(a,n);for(const l of s)r.includes(l.object.id)||(r.push(l.object.id),o.push({id:l.object.id,rect:this.cloneRect(l.object.rect),pageIndex:l.object.pageIndex,rotation:l.object.rotation??0,unrotatedRect:l.object.unrotatedRect?this.cloneRect(l.object.unrotatedRect):void 0,isAttachedLink:!0,parentId:a}))}return{participants:o,attachedLinkIds:r}}computeRotatePreviewPatches(e,n){const o={};for(const r of e.participants){const a=this.getAnnotationById(r.id,n);if(!a)continue;const i=Jn({rect:r.rect,unrotatedRect:r.unrotatedRect,rotation:r.rotation}),s=yo(i,e.rotationCenter,e.delta),l={x:s.x-i.x,y:s.y-i.y},c=this.normalizeAngle(r.rotation+e.delta),u=this.transformAnnotation(a.object,{type:"rotate",changes:{rotation:c,unrotatedRect:this.translateRect(r.unrotatedRect??r.rect,l)},metadata:{rotationAngle:c,rotationDelta:e.delta,rotationCenter:e.rotationCenter}});!u.rect&&(l.x!==0||l.y!==0)&&(u.rect={origin:{x:a.object.rect.origin.x+l.x,y:a.object.rect.origin.y+l.y},size:{...a.object.rect.size}}),o[r.id]=u}return o}startRotation(e,n){const{annotationIds:o,cursorAngle:r,rotationCenter:a}=n,{participants:i,attachedLinkIds:s}=this.buildRotationParticipants(o,e);if(i.length===0)return;const l=i.map(h=>h.rect),c=this.computeUnifiedGroupBoundingBox(l),u=a??{x:c.origin.x+c.size.width/2,y:c.origin.y+c.size.height/2},d={documentId:e,isRotating:!0,primaryIds:o,attachedLinkIds:s,allParticipantIds:i.map(h=>h.id),rotationCenter:u,cursorStartAngle:r,currentAngle:r,delta:0,participants:i};this.unifiedRotateStates.set(e,d);const p=this.computeRotatePreviewPatches(d,e);this.unifiedRotate$.emit({documentId:e,type:"start",state:d,previewPatches:p})}updateRotation(e,n,o){const r=this.unifiedRotateStates.get(e);if(!(r!=null&&r.isRotating))return;const a=o!==void 0?o:this.normalizeDelta(n-r.cursorStartAngle),i={...r,currentAngle:n,delta:a};this.unifiedRotateStates.set(e,i);const s=this.computeRotatePreviewPatches(i,e);this.unifiedRotate$.emit({documentId:e,type:"update",state:i,previewPatches:s})}commitRotation(e){const n=this.unifiedRotateStates.get(e);if(!n)return;const o=this.computeRotatePreviewPatches(n,e),r=[];for(const[a,i]of Object.entries(o)){const s=this.getAnnotationById(a,e);s&&r.push({pageIndex:s.object.pageIndex,id:a,patch:i})}r.length>0&&this.updateAnnotationsMethod(r,e),this.unifiedRotate$.emit({documentId:e,type:"end",state:{...n,isRotating:!1},previewPatches:o}),this.unifiedRotateStates.delete(e)}cancelRotation(e){const n=this.unifiedRotateStates.get(e);n&&(this.unifiedRotate$.emit({documentId:e,type:"cancel",state:{...n,isRotating:!1,delta:0,currentAngle:n.cursorStartAngle},previewPatches:{}}),this.unifiedRotateStates.delete(e))}getRotateState(e){return this.unifiedRotateStates.get(e)??null}get onRotateChange(){return this.unifiedRotate$.on}updateAnnotationsMethod(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","UpdateAnnotations",`Cannot update annotations: document ${o} lacks ModifyAnnotations permission`);return}const r=this.getDocumentState(o),a=e.map(({pageIndex:u,id:d,patch:p})=>{var h;const g=(h=r.byUid[d])==null?void 0:h.object;if(!g)return null;const f=this.buildPatch(g,{...p,author:p.author??this.config.annotationAuthor});return{pageIndex:u,id:d,patch:f,originalObject:g}}).filter(u=>u!==null);if(a.length===0)return;const i=()=>{for(const{pageIndex:u,id:d,patch:p,originalObject:h}of a)this.dispatch(Ua(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})};if(!this.history){i(),this.config.autoCommit!==!1&&this.commit(o);return}const s=a.map(({pageIndex:u,id:d,patch:p,originalObject:h})=>({pageIndex:u,id:d,originalPatch:Object.fromEntries(Object.keys(p).map(g=>[g,h[g]])),originalObject:h})),l={execute:i,undo:()=>{for(const{pageIndex:u,id:d,originalPatch:p,originalObject:h}of s)this.dispatch(Ua(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})},metadata:{annotationIds:a.map(u=>u.id)}};this.history.forDocument(o).register(l,this.ANNOTATION_HISTORY_TOPIC)}moveAnnotationsMethod(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","MoveAnnotations",`Cannot move annotations: document ${o} lacks ModifyAnnotations permission`);return}const r=this.getDocumentState(o),a=e.map(({pageIndex:u,id:d,patch:p})=>{var h;const g=(h=r.byUid[d])==null?void 0:h.object;return g?{pageIndex:u,id:d,patch:p,originalObject:g}:null}).filter(u=>u!==null);if(a.length===0)return;const i=()=>{for(const{pageIndex:u,id:d,patch:p,originalObject:h}of a)this.dispatch(Ku(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})};if(!this.history){i(),this.config.autoCommit!==!1&&this.commit(o);return}const s=a.map(({pageIndex:u,id:d,patch:p,originalObject:h})=>({pageIndex:u,id:d,originalPatch:Object.fromEntries(Object.keys(p).map(g=>[g,h[g]])),originalObject:h})),l={execute:i,undo:()=>{for(const{pageIndex:u,id:d,originalPatch:p,originalObject:h}of s)this.dispatch(Ku(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})},metadata:{annotationIds:a.map(u=>u.id)}};this.history.forDocument(o).register(l,this.ANNOTATION_HISTORY_TOPIC)}moveAnnotationMethod(e,n,o,r="delta",a){const i=a??this.getActiveDocumentId(),s=this.getAnnotationById(n,i);if(!s)return;const l=s.object.rect,c={...l,origin:r==="absolute"?{x:o.x,y:o.y}:{x:l.origin.x+o.x,y:l.origin.y+o.y}},u=this.transformAnnotation(s.object,{type:"move",changes:{rect:c}});this.moveAnnotationsMethod([{pageIndex:e,id:n,patch:u}],i)}getActiveTool(e){const n=this.getDocumentState(e);return n.activeToolId?this.state.tools.find(o=>o.id===n.activeToolId)??null:null}setActiveTool(e,n){var o,r;const a=n??this.getActiveDocumentId();if(e!==null&&!this.checkPermission(a,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","SetActiveTool",`Cannot activate tool: document ${a} lacks ModifyAnnotations permission`);return}const i=this.getDocumentState(a);if(e===i.activeToolId)return;this.dispatch(qu(a,e));const s=this.state.tools.find(l=>l.id===e);s?(o=this.interactionManager)==null||o.forDocument(a).activate(s.interaction.mode??s.id):(r=this.interactionManager)==null||r.forDocument(a).activateDefaultMode()}getTool(e){return this.state.tools.find(n=>n.id===e)}findToolForAnnotation(e){let n=null,o=0;for(const r of this.state.tools){const a=r.matchScore(e);a>o&&(o=a,n=r)}return n}setLocked(e,n){const o=n??this.getActiveDocumentId();this.dispatch(cb(o,e));const r=this.getDocumentState(o),a=r.selectedUids.filter(i=>{const s=r.byUid[i];return s?this.isAnnotationLocked(s.object,o):!1});if(a.length>0){const i=r.selectedUids.filter(s=>!a.includes(s));this.dispatch(bs(o,i))}}getLocked(e){return this.getDocumentState(e).locked}isAnnotationLocked(e,n){if(Zu(e))return!0;const o=this.findToolForAnnotation(e),r=Ds(o);return Ba(r,this.getLocked(n))}isCategoryLockedMethod(e,n){return Ba([e],this.getLocked(n))}isToolLockedMethod(e,n){const o=this.getTool(e);if(!o)return!1;const r=Ds(o);return Ba(r,this.getLocked(n))}syncAnnotationObject(e,n,o){const r=o??this.getActiveDocumentId();this.dispatch(ub(r,e,n))}navigateTargetMethod(e,n){var o;const r=n??this.getActiveDocumentId(),a=l=>(this.navigate$.emit(r,{documentId:r,result:l,target:e}),Ue.resolve(l));let i;if(e.type==="destination")i=e.destination;else if(e.type==="action"){const l=e.action;if(l.type===Ra.Goto||l.type===Ra.RemoteGoto)i=l.destination;else return l.type===Ra.URI?a({outcome:"uri",uri:l.uri}):a({outcome:"unsupported"})}if(!i)return a({outcome:"unsupported"});if(!this.scroll)return a({outcome:"destination",destination:i});const s=this.scroll.forDocument(r);if(i.zoom.mode===uu.XYZ){const l=this.getCoreDocument(r),c=(o=l==null?void 0:l.document)==null?void 0:o.pages.find(u=>u.index===i.pageIndex);s.scrollToPage({pageNumber:i.pageIndex+1,pageCoordinates:c&&i.zoom.params?{x:i.zoom.params.x,y:c.size.height-i.zoom.params.y}:void 0,behavior:"smooth"})}else s.scrollToPage({pageNumber:i.pageIndex+1,behavior:"smooth"});return a({outcome:"navigated"})}collectPendingChanges(e,n){const o=this.getDocumentState(e),r=this.pendingContexts.get(e),a={creations:[],updates:[],deletions:[],committedUids:[],isEmpty:!0};for(const[i,s]of Object.entries(o.byUid))if(!(s.commitState==="synced"||!n.pages.find(c=>c.index===s.object.pageIndex)))switch(a.committedUids.push(i),a.isEmpty=!1,s.commitState){case"new":a.creations.push({uid:i,ta:s,ctx:r==null?void 0:r.get(s.object.id)});break;case"moved":a.updates.push({uid:i,ta:s,moved:!0});break;case"dirty":a.updates.push({uid:i,ta:s});break;case"deleted":a.deletions.push({uid:i,ta:s});break}return a}executeCommitBatch(e,n,o){const r=new Ie,a=this.pendingContexts.get(e),i=[];for(const{uid:l,ta:c,ctx:u}of o.creations){const d=n.pages.find(h=>h.index===c.object.pageIndex);if(!d)continue;const p=this.engine.createPageAnnotation(n,d,c.object,u);i.push({type:"create",task:p,ta:c,uid:l,ctx:u})}for(const{uid:l,ta:c,moved:u}of o.updates){const d=n.pages.find(h=>h.index===c.object.pageIndex);if(!d)continue;const p=u?this.engine.updatePageAnnotation(n,d,c.object,{regenerateAppearance:!1}):this.engine.updatePageAnnotation(n,d,c.object);i.push({type:"update",task:p,ta:c,uid:l,moved:u})}for(const{uid:l,ta:c}of o.deletions){const u=n.pages.find(d=>d.index===c.object.pageIndex);if(u)if(c.object.id){const d=new Ie;this.engine.removePageAnnotation(n,u,c.object).wait(()=>d.resolve(!0),d.fail),i.push({type:"delete",task:d,ta:c,uid:l})}else this.dispatch(ys(e,c.object.pageIndex,l))}const s=i.map(l=>l.task);return Ie.allSettled(s).wait(()=>{this.emitCommitEvents(e,i,a);for(const l of i)l.type==="update"&&l.moved||(l.type==="create"||l.type==="update"||l.type==="delete")&&this.invalidateAnnotationAppearance(l.ta.object.id,l.ta.object.pageIndex,e);this.dispatch(lb(e,o.committedUids)),r.resolve(!0)},l=>r.fail(l)),r}emitCommitEvents(e,n,o){for(const r of n)if(r.task.state.stage===Wo.Resolved)switch(r.type){case"create":this.events$.emit(e,{type:"create",documentId:e,annotation:r.ta.object,pageIndex:r.ta.object.pageIndex,ctx:r.ctx,committed:!0}),o==null||o.delete(r.ta.object.id);break;case"update":this.events$.emit(e,{type:"update",documentId:e,annotation:r.ta.object,pageIndex:r.ta.object.pageIndex,patch:r.ta.object,committed:!0});break;case"delete":this.dispatch(ys(e,r.ta.object.pageIndex,r.uid)),this.events$.emit(e,{type:"delete",documentId:e,annotation:r.ta.object,pageIndex:r.ta.object.pageIndex,committed:!0});break}}acquireCommitLock(e){return this.commitInProgress.get(e)?!1:(this.commitInProgress.set(e,!0),!0)}releaseCommitLock(e){this.commitInProgress.set(e,!1)}commit(e){const n=e??this.getActiveDocumentId();if(!this.getDocumentState(n).hasPendingChanges||!this.acquireCommitLock(n))return Ue.resolve(!0);const r=this.getCoreDocument(n),a=r==null?void 0:r.document;if(!a)return this.releaseCommitLock(n),Ue.reject({code:ve.NotFound,message:"Document not found"});const i=this.collectPendingChanges(n,a);if(i.isEmpty)return this.releaseCommitLock(n),Ue.resolve(!0);const s=new Ie;return this.executeCommitBatch(n,a,i).wait(()=>{this.releaseCommitLock(n),this.getDocumentState(n).hasPendingChanges?this.commit(n).wait(c=>s.resolve(c),c=>s.fail(c)):s.resolve(!0)},l=>{this.releaseCommitLock(n),s.fail(l)}),s}};ks.id="annotation",ks.defaultHandlerFactories=new Map([[M.CIRCLE,_d],[M.SQUARE,Fd],[M.STAMP,bd],[M.POLYGON,Pd],[M.POLYLINE,cd],[M.LINE,xs],[M.INK,Ss],[M.FREETEXT,ld],[M.TEXT,sd],[M.LINK,yd]]);let Is=ks;function tn(t,e,n){return t===void 0?n:typeof t=="function"?t(e):t}const k_=t=>t,I_={manifest:nb,create:(t,e)=>new Is(Au,t,e),reducer:O_,initialState:(t,e)=>w_(e)};function Ad(t,e){const{width:n,height:o}=t.size;switch(e%4){case 1:return{matrix:`matrix(0, -1, 1, 0, 0, ${o})`,width:o,height:n};case 2:return{matrix:`matrix(-1, 0, 0, -1, ${n}, ${o})`,width:n,height:o};case 3:return{matrix:`matrix(0, 1, -1, 0, ${n}, 0)`,width:o,height:n};default:return{matrix:"matrix(1, 0, 0, 1, 0, 0)",width:n,height:o}}}const Ir=ie({__name:"counter-rotate-container",props:{rect:{},rotation:{}},setup(t){const e=t,n=P(()=>Ad(e.rect,e.rotation)),o=P(()=>({style:{position:"absolute",left:`${e.rect.origin.x}px`,top:`${e.rect.origin.y}px`,transform:n.value.matrix,transformOrigin:"0 0",width:`${n.value.width}px`,height:`${n.value.height}px`,pointerEvents:"none",zIndex:3},onPointerdown:a=>{a.stopPropagation(),a.preventDefault()},onTouchstart:a=>{a.stopPropagation(),a.preventDefault()}})),r=P(()=>({origin:{x:e.rect.origin.x,y:e.rect.origin.y},size:{width:n.value.width,height:n.value.height}}));return(a,i)=>$e(a.$slots,"default",{menuWrapperProps:o.value,matrix:n.value.matrix,rect:r.value})}});function G_(t){return{x:t.includes("e")?"left":t.includes("w")?"right":"center",y:t.includes("s")?"top":t.includes("n")?"bottom":"center"}}function L_(t,e){const n=e.x==="left"?t.origin.x:e.x==="right"?t.origin.x+t.size.width:t.origin.x+t.size.width/2,o=e.y==="top"?t.origin.y:e.y==="bottom"?t.origin.y+t.size.height:t.origin.y+t.size.height/2;return{x:n,y:o}}function $_(t,e,n){let o=t.origin.x,r=t.origin.y,a=t.size.width,i=t.size.height;return n.x==="left"?a+=e.x:n.x==="right"&&(o+=e.x,a-=e.x),n.y==="top"?i+=e.y:n.y==="bottom"&&(r+=e.y,i-=e.y),{origin:{x:o,y:r},size:{width:a,height:i}}}function N_(t,e,n,o){let{x:r,y:a}=t.origin,{width:i,height:s}=t.size;if(n.x==="center"||n.y==="center")n.y==="center"?(s=i/o,a=e.origin.y+(e.size.height-s)/2):(i=s*o,r=e.origin.x+(e.size.width-i)/2);else{const c=Math.abs(i-e.size.width),u=Math.abs(s-e.size.height),d=c+u;if(d===0)i=e.size.width,s=e.size.height;else{const p=c/d,h=u/d,g=i,f=i/o,F=s*o,_=s;i=p*g+h*F,s=p*f+h*_}}return n.x==="right"&&(r=e.origin.x+e.size.width-i),n.y==="bottom"&&(a=e.origin.y+e.size.height-s),{origin:{x:r,y:a},size:{width:i,height:s}}}function j_(t,e,n,o,r){if(!o)return t;let{x:a,y:i}=t.origin,{width:s,height:l}=t.size;s=Math.max(1,s),l=Math.max(1,l);const c=n.x==="left"?e.origin.x:e.origin.x+e.size.width,u=n.y==="top"?e.origin.y:e.origin.y+e.size.height,d=n.x==="left"?o.width-c:n.x==="right"?c:Math.min(e.origin.x,o.width-e.origin.x-e.size.width)*2+e.size.width,p=n.y==="top"?o.height-u:n.y==="bottom"?u:Math.min(e.origin.y,o.height-e.origin.y-e.size.height)*2+e.size.height;if(r){const h=s>d?d/s:1,g=l>p?p/l:1,f=Math.min(h,g);f<1&&(s*=f,l*=f)}else s=Math.min(s,d),l=Math.min(l,p);return n.x==="left"?a=c:n.x==="right"?a=c-s:a=e.origin.x+(e.size.width-s)/2,n.y==="top"?i=u:n.y==="bottom"?i=u-l:i=e.origin.y+(e.size.height-l)/2,a=Math.max(0,Math.min(a,o.width-s)),i=Math.max(0,Math.min(i,o.height-l)),{origin:{x:a,y:i},size:{width:s,height:l}}}function U_(t,e,n){let o,r;return n.x==="left"?o=e.origin.x:n.x==="right"?o=e.origin.x+e.size.width-t.size.width:o=e.origin.x+(e.size.width-t.size.width)/2,n.y==="top"?r=e.origin.y:n.y==="bottom"?r=e.origin.y+e.size.height-t.size.height:r=e.origin.y+(e.size.height-t.size.height)/2,{origin:{x:o,y:r},size:t.size}}function xd(t,e,n,o=!1){if(!e)return t;let{origin:{x:r,y:a},size:{width:i,height:s}}=t;const l=e.minWidth??1,c=e.minHeight??1,u=e.maxWidth,d=e.maxHeight;if(n&&i>0&&s>0){const p=i/s;i<l&&(i=l,s=i/p),s<c&&(s=c,i=s*p),u!==void 0&&i>u&&(i=u,s=i/p),d!==void 0&&s>d&&(s=d,i=s*p)}else i=Math.max(l,i),s=Math.max(c,s),u!==void 0&&(i=Math.min(u,i)),d!==void 0&&(s=Math.min(d,s));return e.boundingBox&&!o&&(r=Math.max(0,Math.min(r,e.boundingBox.width-i)),a=Math.max(0,Math.min(a,e.boundingBox.height-s))),{origin:{x:r,y:a},size:{width:i,height:s}}}function Cd(t,e,n){const r=Zi(t,e);return r.origin.x>=-1e-6&&r.origin.y>=-1e-6&&r.origin.x+r.size.width<=n.width+1e-6&&r.origin.y+r.size.height<=n.height+1e-6}function Za(t,e,n,o,r){const{startRect:a,maintainAspectRatio:i=!1,annotationRotation:s=0,constraints:l}=n,c=G_(e),u=a.size.width/a.size.height||1;let d=$_(a,t,c);if(i&&(d=N_(d,a,c,u)),o&&(d=j_(d,a,c,l==null?void 0:l.boundingBox,i)),d=xd(d,l,i,r),r&&(d=U_(d,a,c)),s!==0){const p=L_(a,c),h={x:a.origin.x+a.size.width/2,y:a.origin.y+a.size.height/2},g={x:d.origin.x+d.size.width/2,y:d.origin.y+d.size.height/2},f=yo(p,h,s),F=yo(p,g,s);d={origin:{x:d.origin.x+(f.x-F.x),y:d.origin.y+(f.y-F.y)},size:d.size}}return d}function B_(t,e,n){const{annotationRotation:o=0,constraints:r}=n,a=r==null?void 0:r.boundingBox;if(o!==0&&a){const i=Za(t,e,n,!1,!0);if(Cd(i,o,a))return i;let s=Za({x:0,y:0},e,n,!1,!0),l=0,c=1;for(let u=0;u<20;u+=1){const d=(l+c)/2,p=Za({x:t.x*d,y:t.y*d},e,n,!1,!0);Cd(p,o,a)?(s=p,l=d):c=d}return s}return Za(t,e,n,!0,!1)}const Td=35,z_={n:0,ne:45,e:90,se:135,s:180,sw:225,w:270,nw:315},W_=["ns-resize","nesw-resize","ew-resize","nwse-resize","ns-resize","nesw-resize","ew-resize","nwse-resize"];function H_(t,e,n=0){const o=e*90,a=((z_[t]+o+n)%360+360)%360,i=Math.round(a/45)%8;return W_[i]}function V_(t,e,n){const o=-t/2;return n==="center"?o:n==="outside"?o-e:o+e}function Y_(t,e={}){const{handleSize:n=8,spacing:o=1,offsetMode:r="outside",includeSides:a=!1,zIndex:i=3,rotationAwareCursor:s=!0}=e,l=(t.pageRotation??0)%4,c=t.annotationRotation??0,u=g=>({[g]:V_(n,o,r)+"px"}),d=[["nw",{...u("top"),...u("left")}],["ne",{...u("top"),...u("right")}],["sw",{...u("bottom"),...u("left")}],["se",{...u("bottom"),...u("right")}]],p=a?[["n",{...u("top"),left:`calc(50% - ${n/2}px)`}],["s",{...u("bottom"),left:`calc(50% - ${n/2}px)`}],["w",{...u("left"),top:`calc(50% - ${n/2}px)`}],["e",{...u("right"),top:`calc(50% - ${n/2}px)`}]]:[];return[...d,...p].map(([g,f])=>({handle:g,style:{position:"absolute",width:n+"px",height:n+"px",borderRadius:"50%",zIndex:i,cursor:s?H_(g,l,c):"default",pointerEvents:"auto",touchAction:"none",...f},attrs:{"data-epdf-handle":g}}))}function q_(t,e={},n){const{vertexSize:o=12,zIndex:r=4}=e,a=t.element,i=t.scale??1;return(n??t.vertices??[]).map((l,c)=>{const u=(l.x-a.origin.x)*i-o/2,d=(l.y-a.origin.y)*i-o/2;return{handle:"nw",style:{position:"absolute",left:u+"px",top:d+"px",width:o+"px",height:o+"px",borderRadius:"50%",cursor:"pointer",zIndex:r,pointerEvents:"auto",touchAction:"none"},attrs:{"data-epdf-vertex":c}}})}function K_(t,e={},n=0){const{handleSize:o=16,zIndex:r=5,showConnector:a=!0,connectorWidth:i=1}=e,s=t.scale??1,l=t.element,c=t.rotationElement??l,u=t.rotationCenter??{x:l.origin.x+l.size.width/2,y:l.origin.y+l.size.height/2};c.size.width*s,c.size.height*s;const d=(u.x-c.origin.x)*s,p=(u.y-c.origin.y)*s,h=n*Math.PI/180,g=e.margin??Td,f=l.size.height*s/2+g,F=d+f*Math.sin(h),_=p-f*Math.cos(h),y=F-o/2,E=_-o/2;return{handleStyle:{position:"absolute",left:y+"px",top:E+"px",width:o+"px",height:o+"px",borderRadius:"50%",cursor:"grab",zIndex:r,pointerEvents:"auto",touchAction:"none"},connectorStyle:a?{position:"absolute",left:d-i/2+"px",top:p-f+"px",width:i+"px",height:f+"px",transformOrigin:"center bottom",transform:`rotate(${n}deg)`,zIndex:r-1,pointerEvents:"none"}:{},radius:f,attrs:{"data-epdf-rotation-handle":!0}}}class X_{constructor(e,n){this.config=e,this.onUpdate=n,this.state="idle",this.startPoint=null,this.startElement=null,this.startRotationElement=null,this.gestureRotationCenter=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.currentVertices=[],this.rotationCenter=null,this.centerScreen=null,this.initialRotation=0,this.lastComputedRotation=0,this.rotationDelta=0,this.rotationSnappedAngle=null,this.currentVertices=e.vertices||[]}updateConfig(e){this.config={...this.config,...e},this.state!=="vertex-editing"&&(this.currentVertices=e.vertices||[])}startDrag(e,n){this.state="dragging",this.startPoint={x:e,y:n},this.startElement={...this.config.element},this.startRotationElement=this.config.rotationElement?{...this.config.rotationElement}:null,this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"move",changes:{rect:this.startElement}}})}startResize(e,n,o){this.state="resizing",this.activeHandle=e,this.startPoint={x:n,y:o},this.startElement={...this.config.element},this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"resize",changes:{rect:this.startElement},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio}}})}startVertexEdit(e,n,o){this.currentVertices=[...this.config.vertices??this.currentVertices],!(e<0||e>=this.currentVertices.length)&&(this.state="vertex-editing",this.activeVertexIndex=e,this.startPoint={x:n,y:o},this.startVertices=[...this.currentVertices],this.gestureRotationCenter=this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2},this.onUpdate({state:"start",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:e}}}))}startRotation(e,n,o=0,r){this.state="rotating",this.startPoint={x:e,y:n},this.startElement={...this.config.element},this.rotationCenter=this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2};const{scale:a=1}=this.config,i=this.config.rotationElement??this.config.element,s=i.size.width*a,l=i.size.height*a,c=r??Math.max(s,l)/2+Td,u=(this.config.pageRotation??0)*90,d=(o+u)*Math.PI/180;this.centerScreen={x:e-c*Math.sin(d),y:n+c*Math.cos(d)},this.initialRotation=o,this.lastComputedRotation=o,this.rotationDelta=0,this.rotationSnappedAngle=null,this.onUpdate({state:"start",transformData:{type:"rotate",changes:{rotation:o},metadata:{rotationAngle:o,rotationDelta:0,rotationCenter:this.rotationCenter,isSnapped:!1}}})}move(e,n,o,r){if(!(this.state==="idle"||!this.startPoint)){if(o!==void 0&&o===0){this.end();return}if(this.state==="dragging"&&this.startElement){const a=this.calculateDelta(e,n),i=this.calculateDragPosition(a);this.currentPosition=i,this.onUpdate({state:"move",transformData:{type:"move",changes:{rect:i}}})}else if(this.state==="resizing"&&this.activeHandle&&this.startElement){const a=this.calculateLocalDelta(e,n),i=B_(a,this.activeHandle,{startRect:this.startElement,maintainAspectRatio:this.config.maintainAspectRatio||!!r,annotationRotation:this.config.annotationRotation,constraints:this.config.constraints});this.currentPosition=i,this.onUpdate({state:"move",transformData:{type:"resize",changes:{rect:i},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio||!!r}}})}else if(this.state==="vertex-editing"&&this.activeVertexIndex!==null){const a=this.calculateVertexPosition(e,n);this.currentVertices=a,this.onUpdate({state:"move",transformData:{type:"vertex-edit",changes:{vertices:a},metadata:{vertexIndex:this.activeVertexIndex}}})}else if(this.state==="rotating"&&this.rotationCenter){const a=this.calculateAngleFromMouse(e,n),i=this.applyRotationSnapping(a),s=Ma(i.angle),l=this.lastComputedRotation,c=s-l,u=c>180?c-360:c<-180?c+360:c;this.rotationDelta+=u,this.lastComputedRotation=s,this.rotationSnappedAngle=i.isSnapped?s:null,this.onUpdate({state:"move",transformData:{type:"rotate",changes:{rotation:s},metadata:{rotationAngle:s,rotationDelta:this.rotationDelta,rotationCenter:this.rotationCenter,isSnapped:i.isSnapped,snappedAngle:this.rotationSnappedAngle??void 0,cursorPosition:{clientX:e,clientY:n}}}})}}}end(){if(this.state==="idle")return;const e=this.state,n=this.activeHandle,o=this.activeVertexIndex;if(e==="vertex-editing")this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.currentVertices},metadata:{vertexIndex:o||void 0}}});else if(e==="rotating")this.onUpdate({state:"end",transformData:{type:"rotate",changes:{rotation:this.lastComputedRotation},metadata:{rotationAngle:this.lastComputedRotation,rotationDelta:this.rotationDelta,rotationCenter:this.rotationCenter||void 0,isSnapped:this.rotationSnappedAngle!==null,snappedAngle:this.rotationSnappedAngle??void 0}}});else{const r=this.currentPosition||this.config.element;this.onUpdate({state:"end",transformData:{type:e==="dragging"?"move":"resize",changes:{rect:r},metadata:e==="dragging"?void 0:{handle:n||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}})}this.reset()}cancel(){this.state!=="idle"&&(this.state==="vertex-editing"?this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:this.activeVertexIndex||void 0}}}):this.state==="rotating"?this.onUpdate({state:"end",transformData:{type:"rotate",changes:{rotation:this.initialRotation},metadata:{rotationAngle:this.initialRotation,rotationDelta:0,rotationCenter:this.rotationCenter||void 0,isSnapped:!1}}}):this.startElement&&this.onUpdate({state:"end",transformData:{type:this.state==="dragging"?"move":"resize",changes:{rect:this.startElement},metadata:this.state==="dragging"?void 0:{handle:this.activeHandle||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}}),this.reset())}reset(){this.state="idle",this.startPoint=null,this.startElement=null,this.startRotationElement=null,this.gestureRotationCenter=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.rotationCenter=null,this.centerScreen=null,this.initialRotation=0,this.lastComputedRotation=0,this.rotationDelta=0,this.rotationSnappedAngle=null}calculateDelta(e,n){if(!this.startPoint)return{x:0,y:0};const o={x:e-this.startPoint.x,y:n-this.startPoint.y};return this.transformDelta(o)}transformDelta(e){const{pageRotation:n=0,scale:o=1}=this.config,r=n*Math.PI/2,a=Math.cos(r),i=Math.sin(r),s=e.x/o,l=e.y/o;return{x:a*s+i*l,y:-i*s+a*l}}calculateLocalDelta(e,n){const o=this.calculateDelta(e,n),{annotationRotation:r=0}=this.config;if(r===0)return o;const a=r*Math.PI/180,i=Math.cos(a),s=Math.sin(a);return{x:i*o.x+s*o.y,y:-s*o.x+i*o.y}}clampPoint(e){var n;const o=(n=this.config.constraints)==null?void 0:n.boundingBox;if(!o)return e;const{annotationRotation:r=0}=this.config;if(r===0)return{x:Math.max(0,Math.min(e.x,o.width)),y:Math.max(0,Math.min(e.y,o.height))};const a=this.gestureRotationCenter??this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2},i=yo(e,a,r),s=Math.max(0,Math.min(i.x,o.width)),l=Math.max(0,Math.min(i.y,o.height));return s===i.x&&l===i.y?e:yo({x:s,y:l},a,-r)}calculateVertexPosition(e,n){if(this.activeVertexIndex===null)return this.startVertices;const o=this.calculateLocalDelta(e,n),r=[...this.startVertices],a=r[this.activeVertexIndex],i={x:a.x+o.x,y:a.y+o.y};return r[this.activeVertexIndex]=this.clampPoint(i),r}calculateDragPosition(e){if(!this.startElement)return this.config.element;const n={origin:{x:this.startElement.origin.x+e.x,y:this.startElement.origin.y+e.y},size:{width:this.startElement.size.width,height:this.startElement.size.height}},{annotationRotation:o=0,constraints:r}=this.config,a=r==null?void 0:r.boundingBox;if(o!==0&&a){let i,s,l,c;if(this.startRotationElement)i=this.startRotationElement.size.width,s=this.startRotationElement.size.height,l=this.startRotationElement.origin.x-this.startElement.origin.x,c=this.startRotationElement.origin.y-this.startElement.origin.y;else{const p=Math.abs(o*Math.PI/180),h=Math.abs(Math.cos(p)),g=Math.abs(Math.sin(p)),f=n.size.width,F=n.size.height;i=f*h+F*g,s=f*g+F*h,l=(f-i)/2,c=(F-s)/2}let{x:u,y:d}=n.origin;return u=Math.max(-l,Math.min(u,a.width-i-l)),d=Math.max(-c,Math.min(d,a.height-s-c)),{origin:{x:u,y:d},size:n.size}}return xd(n,r,this.config.maintainAspectRatio??!1)}calculateAngleFromMouse(e,n){if(!this.centerScreen)return this.initialRotation;const o=e-this.centerScreen.x,r=n-this.centerScreen.y;if(Math.sqrt(o*o+r*r)<10)return this.lastComputedRotation;const i=(this.config.pageRotation??0)*90,s=Math.atan2(r,o)*(180/Math.PI)+90-i;return Ma(Math.round(s))}applyRotationSnapping(e){const n=this.config.rotationSnapAngles??[0,90,180,270],o=this.config.rotationSnapThreshold??4,r=Ma(e);for(const a of n){const i=Ma(a),s=Math.abs(r-i);if(Math.min(s,360-s)<=o)return{angle:i,isSnapped:!0,snapTarget:i}}return{angle:r,isSnapped:!1}}}const nt=t=>ke(ht(t)?I(t):t),Do=(t,e=0)=>{const n=Number(t);return Number.isFinite(n)?n:e},Ko=t=>{var e,n,o,r;return{origin:{x:Do((e=t==null?void 0:t.origin)==null?void 0:e.x),y:Do((n=t==null?void 0:t.origin)==null?void 0:n.y)},size:{width:Do((o=t==null?void 0:t.size)==null?void 0:o.width),height:Do((r=t==null?void 0:t.size)==null?void 0:r.height)}}},Gs=(t=[])=>t.map(e=>({x:Do(e==null?void 0:e.x),y:Do(e==null?void 0:e.y)})),Md=t=>t===void 0?void 0:!!t,Xo=t=>t===void 0?void 0:Do(t),Rd=t=>t?nt(t):void 0;function Z_(t){const e=Q(null),{onUpdate:n,element:o,rotationCenter:r,rotationElement:a,vertices:i,constraints:s,maintainAspectRatio:l,pageRotation:c,annotationRotation:u,scale:d,enabled:p}=t,h={element:Ko(nt(o)),rotationCenter:r?nt(r):void 0,rotationElement:a?Ko(nt(a)):void 0,vertices:i?Gs(nt(i)):void 0,constraints:Rd(s),maintainAspectRatio:Md(p===void 0?void 0:nt(l)),pageRotation:Xo(c===void 0?void 0:nt(c)),annotationRotation:Xo(u===void 0?void 0:nt(u)),scale:Xo(d===void 0?void 0:nt(d))};e.value||(e.value=dr(new X_(h,w=>n==null?void 0:n(w)))),Se(()=>({element:o,rotationCenter:r,rotationElement:a,vertices:i,constraints:s,maintainAspectRatio:l,pageRotation:c,annotationRotation:u,scale:d}),w=>{var G;(G=e.value)==null||G.updateConfig({element:Ko(nt(w.element)),rotationCenter:w.rotationCenter?nt(w.rotationCenter):void 0,rotationElement:w.rotationElement?Ko(nt(w.rotationElement)):void 0,vertices:w.vertices?Gs(nt(w.vertices)):void 0,constraints:Rd(w.constraints),maintainAspectRatio:Md(w.maintainAspectRatio===void 0?void 0:nt(w.maintainAspectRatio)),pageRotation:Xo(w.pageRotation===void 0?void 0:nt(w.pageRotation)),annotationRotation:Xo(w.annotationRotation===void 0?void 0:nt(w.annotationRotation)),scale:Xo(w.scale===void 0?void 0:nt(w.scale))})},{deep:!0}),$o(()=>{e.value=null});const g=()=>!!(p===void 0||nt(p)),f=w=>{var G,W,J;g()&&(w.preventDefault(),w.stopPropagation(),(G=e.value)==null||G.startDrag(w.clientX,w.clientY),(J=(W=w.currentTarget).setPointerCapture)==null||J.call(W,w.pointerId))},F=w=>{var G;return(G=e.value)==null?void 0:G.move(w.clientX,w.clientY,w.buttons,w.shiftKey)},_=w=>{var G,W,J;(G=e.value)==null||G.end(),(J=(W=w.currentTarget).releasePointerCapture)==null||J.call(W,w.pointerId)},y=w=>{var G,W,J;(G=e.value)==null||G.cancel(),(J=(W=w.currentTarget).releasePointerCapture)==null||J.call(W,w.pointerId)},E=w=>({onPointerdown:G=>{var W,J,ue;g()&&(G.preventDefault(),G.stopPropagation(),(W=e.value)==null||W.startResize(w,G.clientX,G.clientY),(ue=(J=G.currentTarget).setPointerCapture)==null||ue.call(J,G.pointerId))},onPointermove:F,onPointerup:_,onPointercancel:y}),A=w=>({onPointerdown:G=>{var W,J,ue;g()&&(G.preventDefault(),G.stopPropagation(),(W=e.value)==null||W.startVertexEdit(w,G.clientX,G.clientY),(ue=(J=G.currentTarget).setPointerCapture)==null||ue.call(J,G.pointerId))},onPointermove:F,onPointerup:_,onPointercancel:y}),T=(w=0,G)=>({onPointerdown:W=>{var J,ue,ce;if(!g())return;W.preventDefault(),W.stopPropagation();const ee=W.currentTarget.getBoundingClientRect(),ge=ee.left+ee.width/2,_e=ee.top+ee.height/2;(J=e.value)==null||J.startRotation(ge,_e,w,G),(ce=(ue=W.currentTarget).setPointerCapture)==null||ce.call(ue,W.pointerId)},onPointermove:F,onPointerup:_,onPointercancel:y});return{dragProps:P(()=>g()?{onPointerdown:f,onPointermove:F,onPointerup:_,onPointercancel:y}:{}),createResizeProps:E,createVertexProps:A,createRotationProps:T}}function Q_(t,{delay:e=300,tolerancePx:n=18}={}){const o=Q({t:0,x:0,y:0});return t?{onDblclick:i=>{t==null||t(i)},onPointerupCapture:i=>{if(!t||i.pointerType==="mouse"||i.isPrimary===!1)return;const s=performance.now(),l=i.clientX,c=i.clientY,u=s-o.value.t<=e,d=l-o.value.x,p=c-o.value.y,h=d*d+p*p<=n*n;u&&h&&(t==null||t(i)),o.value={t:s,x:l,y:c}}}:{}}function wd(t){const{controller:e,resizeUI:n,vertexUI:o,rotationUI:r,includeVertices:a=!1,includeRotation:i=!1,currentRotation:s=0,handleAttrs:l,vertexAttrs:c,rotationAttrs:u}=t,{dragProps:d,createResizeProps:p,createVertexProps:h,createRotationProps:g}=Z_(e),f=P(()=>Ko(nt(e.element))),F=P(()=>e.vertices?Gs(nt(e.vertices)):void 0),_=P(()=>Number(nt(e.scale??1))),y=P(()=>Number(nt(e.pageRotation??0))),E=P(()=>e.annotationRotation!==void 0?Number(nt(e.annotationRotation)):void 0),A=P(()=>e.maintainAspectRatio===void 0?void 0:!!nt(e.maintainAspectRatio)),T=P(()=>nt(e.constraints??void 0)),q=P(()=>e.rotationCenter?nt(e.rotationCenter):void 0),w=P(()=>e.rotationElement?Ko(nt(e.rotationElement)):void 0),G=P(()=>Y_({element:f.value,scale:_.value,pageRotation:y.value,annotationRotation:E.value,maintainAspectRatio:A.value,constraints:T.value},n).map(ce=>{var ee;return{key:((ee=ce.attrs)==null?void 0:ee["data-epdf-handle"])??ce.handle,style:ce.style,...p(ce.handle),...ce.attrs??{},...(l==null?void 0:l(ce.handle))??{}}})),W=P(()=>{if(!a)return[];const ue=F.value??[];return q_({element:f.value,scale:_.value,vertices:ue},o,ue).map((ee,ge)=>({key:ge,style:ee.style,...h(ge),...ee.attrs??{},...(c==null?void 0:c(ge))??{}}))}),J=P(()=>{if(!!!nt(i??!1))return null;const ce=Number(nt(s??0)),ee=K_({element:f.value,rotationCenter:q.value,rotationElement:w.value,scale:_.value},r,ce);return{handle:{style:ee.handleStyle,...g(ce,ee.radius),...ee.attrs??{},...(u==null?void 0:u())??{}},connector:{style:ee.connectorStyle,"data-epdf-rotation-connector":!0}}});return{dragProps:d,resize:G,vertices:W,rotation:J}}function J_(t){const e=n=>Array.isArray(n)?n.map(o=>e(o)):ht(n)||qn(n)||ur(n)?e(ke(n)):n&&typeof n=="object"?Object.keys(n).reduce((o,r)=>(o[r]=e(n[r]),o),{}):n;return e(t)}const Od="INTERACTION/INIT_STATE",kd="INTERACTION/CLEANUP_STATE",Id="INTERACTION/ACTIVATE_MODE",Gd="INTERACTION/PAUSE",Ld="INTERACTION/RESUME",$d="INTERACTION/SET_CURSOR",ey="INTERACTION/SET_ACTIVE_DOCUMENT",Nd="INTERACTION/SET_DEFAULT_MODE",jd="INTERACTION/SET_EXCLUSION_RULES",Ud="INTERACTION/ADD_EXCLUSION_CLASS",Bd="INTERACTION/REMOVE_EXCLUSION_CLASS",zd="INTERACTION/ADD_EXCLUSION_ATTRIBUTE",Wd="INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE";function ty(t,e){return{type:Od,payload:{documentId:t,state:e}}}function ny(t){return{type:kd,payload:t}}function oy(t,e){return{type:Id,payload:{documentId:t,mode:e}}}function ry(t){return{type:Gd,payload:t}}function ay(t){return{type:Ld,payload:t}}function iy(t,e){return{type:$d,payload:{documentId:t,cursor:e}}}function Hd(t){return{type:Nd,payload:{mode:t}}}function Vd(t){return{type:jd,payload:{rules:t}}}function sy(t){return{type:Ud,payload:{className:t}}}function ly(t){return{type:Bd,payload:{className:t}}}function cy(t){return{type:zd,payload:{attribute:t}}}function uy(t){return{type:Wd,payload:{attribute:t}}}function dy(t){const e=["onPointerDown","onPointerUp","onPointerMove","onPointerEnter","onPointerLeave","onPointerCancel","onMouseDown","onMouseUp","onMouseMove","onMouseEnter","onMouseLeave","onMouseCancel","onClick","onDoubleClick"],n={};for(const o of e)n[o]=(r,a,i)=>{var s;for(const l of t){if(a.isImmediatePropagationStopped())break;(s=l[o])==null||s.call(l,r,a,i)}};return n}const Yd="pointerMode",qd=class extends jt{constructor(e,n,o){super(e,n),this.modes=new Map,this.cursorClaims=new Map,this.buckets=new Map,this.alwaysGlobal=new Map,this.alwaysPage=new Map,this.pageActivities=new Map,this.onModeChange$=$n(),this.onHandlerChange$=$n(),this.onCursorChange$=$n(),this.onStateChange$=Be(),this.onPageActivityChange$=$n(),this.registerMode({id:Yd,scope:"page",exclusive:!1,cursor:"auto"}),this.dispatch(Hd(Yd)),o.exclusionRules&&this.dispatch(Vd(o.exclusionRules))}onDocumentLoadingStarted(e){const n={activeMode:this.state.defaultMode,cursor:"auto",paused:!1};this.dispatch(ty(e,n)),this.cursorClaims.set(e,new Map),this.buckets.set(e,new Map),this.alwaysGlobal.set(e,new Set),this.alwaysPage.set(e,new Map),this.pageActivities.set(e,new Map);const o=this.buckets.get(e);for(const r of this.modes.keys())o.set(r,{global:new Set,page:new Map});this.logger.debug("InteractionManagerPlugin","DocumentOpened",`Initialized interaction state for document: ${e}`)}onDocumentClosed(e){const n=this.pageActivities.get(e);if(n){const o=new Set(n.values());n.clear();for(const r of o)this.onPageActivityChange$.emit({documentId:e,pageIndex:r,hasActivity:!1})}this.cursorClaims.delete(e),this.buckets.delete(e),this.alwaysGlobal.delete(e),this.alwaysPage.delete(e),this.pageActivities.delete(e),this.dispatch(ny(e)),this.logger.debug("InteractionManagerPlugin","DocumentClosed",`Cleaned up interaction state for document: ${e}`)}buildCapability(){return{getActiveMode:()=>this.getActiveMode(),getActiveInteractionMode:()=>this.getActiveInteractionMode(),activate:e=>this.activate(e),activateDefaultMode:()=>this.activateDefaultMode(),setCursor:(e,n,o)=>this.setCursor(e,n,o),getCurrentCursor:()=>this.getCurrentCursor(),removeCursor:e=>this.removeCursor(e),getHandlersForScope:e=>this.getHandlersForScope(e),activeModeIsExclusive:()=>this.activeModeIsExclusive(),pause:()=>this.pause(),resume:()=>this.resume(),isPaused:()=>this.registry.isDestroyed()||this.isPaused(),getState:()=>this.getDocumentStateOrThrow(),forDocument:e=>this.createInteractionScope(e),registerMode:e=>this.registerMode(e),registerHandlers:e=>this.registerHandlers(e),registerAlways:e=>this.registerAlways(e),setDefaultMode:e=>this.setDefaultMode(e),getDefaultMode:()=>this.state.defaultMode,getExclusionRules:()=>this.state.exclusionRules,setExclusionRules:e=>this.dispatch(Vd(e)),addExclusionClass:e=>this.dispatch(sy(e)),removeExclusionClass:e=>this.dispatch(ly(e)),addExclusionAttribute:e=>this.dispatch(cy(e)),removeExclusionAttribute:e=>this.dispatch(uy(e)),claimPageActivity:(e,n,o)=>this.claimPageActivity(e,n,o),releasePageActivity:(e,n)=>this.releasePageActivity(e,n),hasPageActivity:(e,n)=>this.hasPageActivity(e,n),onModeChange:this.onModeChange$.on,onCursorChange:this.onCursorChange$.on,onHandlerChange:this.onHandlerChange$.on,onStateChange:this.onStateChange$.on,onPageActivityChange:this.onPageActivityChange$.on}}createInteractionScope(e){return{getActiveMode:()=>this.getActiveMode(e),getActiveInteractionMode:()=>this.getActiveInteractionMode(e),activate:n=>this.activate(n,e),activateDefaultMode:()=>this.activateDefaultMode(e),setCursor:(n,o,r)=>this.setCursor(n,o,r,e),getCurrentCursor:()=>this.getCurrentCursor(e),removeCursor:n=>this.removeCursor(n,e),getHandlersForScope:n=>this.getHandlersForScope(n),activeModeIsExclusive:()=>this.activeModeIsExclusive(e),pause:()=>this.pause(e),resume:()=>this.resume(e),isPaused:()=>this.isPaused(e),getState:()=>this.getDocumentStateOrThrow(e),claimPageActivity:(n,o)=>this.claimPageActivity(e,n,o),releasePageActivity:n=>this.releasePageActivity(e,n),hasPageActivity:n=>this.hasPageActivity(e,n),onModeChange:n=>this.onModeChange$.on(o=>{o.documentId===e&&n(o.activeMode)}),onCursorChange:n=>this.onCursorChange$.on(o=>{o.documentId===e&&n(o.cursor)}),onStateChange:n=>this.onStateChange$.on(o=>{o.documentId===e&&n(o.state)}),onPageActivityChange:n=>this.onPageActivityChange$.on(o=>{o.documentId===e&&n({pageIndex:o.pageIndex,hasActivity:o.hasActivity})})}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Interaction state not found for document: ${e??"active"}`);return n}activate(e,n){var o;const r=n??this.getActiveDocumentId(),a=this.getDocumentStateOrThrow(r);if(!this.modes.has(e))throw new Error(`[interaction] unknown mode '${e}'`);if(e===a.activeMode)return;const i=a.activeMode;(o=this.cursorClaims.get(r))==null||o.clear(),this.notifyHandlersInactive(r,i),this.dispatch(oy(r,e)),this.emitCursor(r),this.notifyHandlersActive(r,e),this.onModeChange$.emit({documentId:r,activeMode:e,previousMode:i})}activateDefaultMode(e){const n=e??this.getActiveDocumentIdOrNull();n&&this.activate(this.state.defaultMode,n)}setDefaultMode(e){if(!this.modes.has(e))throw new Error(`[interaction] cannot set unknown mode '${e}' as default`);this.dispatch(Hd(e))}getActiveMode(e){return this.getDocumentStateOrThrow(e).activeMode}getActiveInteractionMode(e){const n=this.getDocumentState(e);return n?this.modes.get(n.activeMode)??null:null}activeModeIsExclusive(e){const n=this.getActiveInteractionMode(e);return!!(n!=null&&n.exclusive)}pause(e){const n=e??this.getActiveDocumentId();this.dispatch(ry(n))}resume(e){const n=e??this.getActiveDocumentId();this.dispatch(ay(n))}isPaused(e){return this.getDocumentStateOrThrow(e).paused}registerMode(e){this.modes.set(e.id,e);for(const n of this.buckets.keys()){const o=this.buckets.get(n);o.has(e.id)||o.set(e.id,{global:new Set,page:new Map})}}registerHandlers({documentId:e,modeId:n,handlers:o,pageIndex:r}){const a=Array.isArray(n)?n:[n],i=[],s=this.buckets.get(e);if(!s)throw new Error(`No buckets found for document: ${e}`);for(const l of a){const c=s.get(l);if(!c)throw new Error(`unknown mode '${l}'`);if(r==null)c.global.add(o);else{const u=c.page.get(r)??new Set;u.add(o),c.page.set(r,u)}i.push(()=>{if(r==null)c.global.delete(o);else{const u=c.page.get(r);u&&(u.delete(o),u.size===0&&c.page.delete(r))}})}return this.onHandlerChange$.emit({...this.state}),()=>{i.forEach(l=>l()),this.onHandlerChange$.emit({...this.state})}}registerAlways({scope:e,handlers:n}){if(e.type==="global"){const a=this.alwaysGlobal.get(e.documentId)??new Set;return a.add(n),this.alwaysGlobal.set(e.documentId,a),this.onHandlerChange$.emit({...this.state}),()=>{a.delete(n),this.onHandlerChange$.emit({...this.state})}}const o=this.alwaysPage.get(e.documentId)??new Map,r=o.get(e.pageIndex)??new Set;return r.add(n),o.set(e.pageIndex,r),this.alwaysPage.set(e.documentId,o),this.onHandlerChange$.emit({...this.state}),()=>{r.delete(n),this.onHandlerChange$.emit({...this.state})}}getHandlersForScope(e){var n;const o=this.getDocumentState(e.documentId);if(!o)return null;const r=this.modes.get(o.activeMode);if(!r)return null;const a=this.buckets.get(e.documentId);if(!a)return null;const i=a.get(r.id);if(!i)return null;const s=(u,d)=>u.size||d.size?dy([...u,...d]):null;if(e.type==="global"){const u=this.alwaysGlobal.get(e.documentId)??new Set,d=r.scope==="global"?i.global:new Set;return s(u,d)}const l=((n=this.alwaysPage.get(e.documentId))==null?void 0:n.get(e.pageIndex))??new Set,c=r.scope==="page"?i.page.get(e.pageIndex)??new Set:new Set;return s(l,c)}setCursor(e,n,o=0,r){const a=r??this.getActiveDocumentId(),i=this.cursorClaims.get(a);i&&(i.set(e,{cursor:n,priority:o}),this.emitCursor(a))}removeCursor(e,n){const o=n??this.getActiveDocumentId(),r=this.cursorClaims.get(o);r&&(r.delete(e),this.emitCursor(o))}getCurrentCursor(e){return this.getDocumentStateOrThrow(e).cursor}emitCursor(e){var n;const o=this.cursorClaims.get(e);if(!o)return;const r=this.getDocumentState(e);if(!r)return;const a=[...o.values()].sort((i,s)=>s.priority-i.priority)[0]??{cursor:((n=this.modes.get(r.activeMode))==null?void 0:n.cursor)??"auto"};a.cursor!==r.cursor&&(this.dispatch(iy(e,a.cursor)),this.onCursorChange$.emit({documentId:e,cursor:a.cursor}))}claimPageActivity(e,n,o){let r=this.pageActivities.get(e);r||(r=new Map,this.pageActivities.set(e,r));const a=r.get(n);a!==o&&(r.set(n,o),a!==void 0&&!this.pageHasAnyTopic(e,a)&&this.onPageActivityChange$.emit({documentId:e,pageIndex:a,hasActivity:!1}),this.countTopicsOnPage(e,o)===1&&this.onPageActivityChange$.emit({documentId:e,pageIndex:o,hasActivity:!0}))}releasePageActivity(e,n){const o=this.pageActivities.get(e);if(!o)return;const r=o.get(n);r!==void 0&&(o.delete(n),this.pageHasAnyTopic(e,r)||this.onPageActivityChange$.emit({documentId:e,pageIndex:r,hasActivity:!1}))}hasPageActivity(e,n){return this.pageHasAnyTopic(e,n)}pageHasAnyTopic(e,n){const o=this.pageActivities.get(e);if(!o)return!1;for(const r of o.values())if(r===n)return!0;return!1}countTopicsOnPage(e,n){const o=this.pageActivities.get(e);if(!o)return 0;let r=0;for(const a of o.values())a===n&&r++;return r}notifyHandlersActive(e,n){var o,r;(o=this.alwaysGlobal.get(e))==null||o.forEach(l=>{var c;(c=l.onHandlerActiveStart)==null||c.call(l,n)}),(r=this.alwaysPage.get(e))==null||r.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveStart)==null||u.call(c,n)})});const a=this.modes.get(n);if(!a)return;const i=this.buckets.get(e);if(!i)return;const s=i.get(n);s&&(a.scope==="global"&&s.global.forEach(l=>{var c;(c=l.onHandlerActiveStart)==null||c.call(l,n)}),a.scope==="page"&&s.page.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveStart)==null||u.call(c,n)})}))}notifyHandlersInactive(e,n){var o,r;(o=this.alwaysGlobal.get(e))==null||o.forEach(l=>{var c;(c=l.onHandlerActiveEnd)==null||c.call(l,n)}),(r=this.alwaysPage.get(e))==null||r.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveEnd)==null||u.call(c,n)})});const a=this.modes.get(n);if(!a)return;const i=this.buckets.get(e);if(!i)return;const s=i.get(n);s&&(a.scope==="global"&&s.global.forEach(l=>{var c;(c=l.onHandlerActiveEnd)==null||c.call(l,n)}),a.scope==="page"&&s.page.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveEnd)==null||u.call(c,n)})}))}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&this.onStateChange$.emit({documentId:o,state:a})}}async initialize(e){this.logger.info("InteractionManagerPlugin","Initialize","Interaction Manager Plugin initialized")}async destroy(){this.pageActivities.clear(),this.onModeChange$.clear(),this.onCursorChange$.clear(),this.onHandlerChange$.clear(),this.onStateChange$.clear(),this.onPageActivityChange$.clear(),await super.destroy()}};qd.id="interaction-manager";let Kd=qd;const Xd="interaction-manager",py={id:Xd,name:"Interaction Manager Plugin",version:"1.0.0",provides:["interaction-manager"],requires:[],optional:[],defaultConfig:{exclusionRules:{classes:[],dataAttributes:["data-no-interaction"]}}},Zd={defaultMode:"pointerMode",exclusionRules:{classes:[],dataAttributes:["data-no-interaction"]},documents:{},activeDocumentId:null},hy={manifest:py,create:(t,e)=>new Kd(Xd,t,e),reducer:(t=Zd,e)=>{switch(e.type){case Od:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case kd:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case ey:return{...t,activeDocumentId:e.payload};case Id:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,activeMode:o}}}:t}case $d:{const{documentId:n,cursor:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,cursor:o}}}:t}case Gd:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,paused:!0}}}:t}case Ld:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,paused:!1}}}:t}case Nd:return{...t,defaultMode:e.payload.mode};case jd:return{...t,exclusionRules:e.payload.rules};case Ud:return{...t,exclusionRules:{...t.exclusionRules,classes:[...t.exclusionRules.classes||[],e.payload.className].filter((n,o,r)=>r.indexOf(n)===o)}};case Bd:return{...t,exclusionRules:{...t.exclusionRules,classes:(t.exclusionRules.classes||[]).filter(n=>n!==e.payload.className)}};case zd:return{...t,exclusionRules:{...t.exclusionRules,dataAttributes:[...t.exclusionRules.dataAttributes||[],e.payload.attribute].filter((n,o,r)=>r.indexOf(n)===o)}};case Wd:return{...t,exclusionRules:{...t.exclusionRules,dataAttributes:(t.exclusionRules.dataAttributes||[]).filter(n=>n!==e.payload.attribute)}};default:return t}},initialState:Zd},gy={pointerdown:"onPointerDown",pointerup:"onPointerUp",pointermove:"onPointerMove",pointerenter:"onPointerEnter",pointerleave:"onPointerLeave",pointercancel:"onPointerCancel",mousedown:"onMouseDown",mouseup:"onMouseUp",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mousecancel:"onMouseCancel",click:"onClick",dblclick:"onDoubleClick",touchstart:"onPointerDown",touchend:"onPointerUp",touchmove:"onPointerMove",touchcancel:"onPointerCancel"},Qd=["pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","mousedown","mouseup","mousemove","mouseenter","mouseleave","mousecancel","click","dblclick"],fy=["touchstart","touchend","touchmove","touchcancel"],Jd=typeof PointerEvent<"u"?Qd:[...Qd,...fy];function my(t,e){return t.startsWith("touch")?{passive:!e}:{passive:!1}}function ep(t){return typeof TouchEvent<"u"&&t instanceof TouchEvent}function Py(t,e){var n,o,r;if(!t)return!1;let a=t;for(;a;){if((n=e.classes)!=null&&n.length){for(const i of e.classes)if((o=a.classList)!=null&&o.contains(i))return!0}if((r=e.dataAttributes)!=null&&r.length){for(const i of e.dataAttributes)if(a.hasAttribute(i))return!0}a=a.parentElement}return!1}function tp(t,e,n,o){const r=t.forDocument(e.documentId);let a=t.getHandlersForScope(e);const i=()=>{var y;return((y=r.getActiveInteractionMode())==null?void 0:y.wantsRawTouch)!==!1},s={};let l=i();const c=y=>{Jd.forEach(E=>{const A=s[E]??(s[E]=_);n.addEventListener(E,A,my(E,y))})},u=()=>{Jd.forEach(y=>{const E=s[y];E&&n.removeEventListener(y,E)})};c(l),n.style.touchAction=l?"none":"";const d=r.onModeChange(()=>{if(e.type==="global"){const E=r.getActiveInteractionMode();n.style.cursor=(E==null?void 0:E.scope)==="global"?E.cursor??"auto":"auto"}a=t.getHandlersForScope(e);const y=i();y!==l&&(u(),c(y),l=y,n.style.touchAction=l?"none":"")}),p=t.onHandlerChange(()=>{a=t.getHandlersForScope(e)}),h=r.getActiveInteractionMode(),g=r.getCurrentCursor();n.style.cursor=e.type==="global"&&(h==null?void 0:h.scope)!=="global"?"auto":g;const f=r.onCursorChange(y=>{var E;e.type==="global"&&((E=r.getActiveInteractionMode())==null?void 0:E.scope)!=="global"||(n.style.cursor=y)}),F=(y,E)=>{if(o)return o(y,E);const A=E.getBoundingClientRect();return{x:y.clientX-A.left,y:y.clientY-A.top}};function _(y){var E;if(t.isPaused())return;const A=t.getExclusionRules();if(y.target&&Py(y.target,A))return;const T=gy[y.type];if(!T||!(a!=null&&a[T]))return;ep(y)&&l&&(y.type==="touchmove"||y.type==="touchcancel")&&y.preventDefault();let q,w,G=!1;if(ep(y)){const W=y.type==="touchend"||y.type==="touchcancel"?y.changedTouches[0]:y.touches[0];if(!W)return;q=F(W,n),w={clientX:W.clientX,clientY:W.clientY,ctrlKey:y.ctrlKey,shiftKey:y.shiftKey,altKey:y.altKey,metaKey:y.metaKey,target:y.target,currentTarget:y.currentTarget,setPointerCapture:()=>{},releasePointerCapture:()=>{},stopImmediatePropagation:()=>{G=!0},isImmediatePropagationStopped:()=>G}}else{const W=y;q=F(W,n),w={clientX:W.clientX,clientY:W.clientY,ctrlKey:W.ctrlKey,shiftKey:W.shiftKey,altKey:W.altKey,metaKey:W.metaKey,target:W.target,currentTarget:W.currentTarget,setPointerCapture:()=>{var J,ue;(ue=(J=W.target)==null?void 0:J.setPointerCapture)==null||ue.call(J,W.pointerId)},releasePointerCapture:()=>{var J,ue;(ue=(J=W.target)==null?void 0:J.releasePointerCapture)==null||ue.call(J,W.pointerId)},stopImmediatePropagation:()=>{G=!0},isImmediatePropagationStopped:()=>G}}(E=a[T])==null||E.call(a,q,w,r.getActiveMode())}return()=>{u(),d(),f(),p()}}const Qa=()=>It(Kd.id);function Fy({modeId:t,pageIndex:e,documentId:n}){const{provides:o}=Qa();return{register:(r,a)=>{const i=(a==null?void 0:a.modeId)??t,s=$t((a==null?void 0:a.pageIndex)??e),l=$t((a==null?void 0:a.documentId)??n),c=o.value;return i?c==null?void 0:c.registerHandlers({modeId:i,handlers:r,pageIndex:s,documentId:l}):c==null?void 0:c.registerAlways({scope:s!==void 0?{type:"page",documentId:l,pageIndex:s}:{type:"global",documentId:l},handlers:r})}}}function by(t){const{provides:e}=Qa(),n=Q(!1);return Se([e,()=>$t(t)],([o,r],a,i)=>{if(!o){n.value=!1;return}const s=o.forDocument(r),l=s.getActiveInteractionMode();n.value=(l==null?void 0:l.scope)==="page"&&!!l.exclusive;const c=s.onModeChange(()=>{const u=s.getActiveInteractionMode();n.value=(u==null?void 0:u.scope)==="page"&&!!(u!=null&&u.exclusive)});i(c)},{immediate:!0}),n}const _y=ie({__name:"global-pointer-provider",props:{documentId:{}},setup(t){const e=t,n=Q(null),{provides:o}=Qa();return Xn(r=>{if(o.value&&n.value){const a=tp(o.value,{type:"global",documentId:e.documentId},n.value);r(a)}}),(r,a)=>(v(),C("div",{ref_key:"divRef",ref:n,style:{width:"100%",height:"100%"}},[$e(r.$slots,"default")],512))}}),yy={key:0,style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10}},vy=ie({__name:"page-pointer-provider",props:{documentId:{},pageIndex:{},rotation:{},scale:{},convertEventToPoint:{type:Function}},setup(t){const e=t,n=Q(null),{provides:o}=Qa(),r=by(()=>e.documentId),a=Dn(()=>e.documentId),i=P(()=>{var h,g,f;return(f=(g=(h=a.value)==null?void 0:h.document)==null?void 0:g.pages)==null?void 0:f[e.pageIndex]}),s=P(()=>{var h;return((h=i.value)==null?void 0:h.size)??{width:0,height:0}}),l=P(()=>{var h;return((h=i.value)==null?void 0:h.rotation)??0}),c=P(()=>{var h;if(e.rotation!==void 0)return e.rotation;const g=((h=a.value)==null?void 0:h.rotation)??0;return(l.value+g)%4}),u=P(()=>{var h;return e.scale??((h=a.value)==null?void 0:h.scale)??1}),d=P(()=>Ca(s.value,0,u.value)),p=P(()=>(h,g)=>{const f=g.getBoundingClientRect(),F={x:h.clientX-f.left,y:h.clientY-f.top},_=Ca({width:d.value.width,height:d.value.height},c.value,1);return QP(_,F,c.value,u.value)});return Se([o,()=>$t(e.documentId),()=>e.pageIndex,()=>e.convertEventToPoint,p],([h,g,f,F,_],y,E)=>{if(!h||!n.value)return;const A=tp(h,{type:"page",documentId:g,pageIndex:f},n.value,F||_);E(A)},{immediate:!0}),(h,g)=>(v(),C("div",xe({ref_key:"divRef",ref:n,style:{position:"relative",width:d.value.width+"px",height:d.value.height+"px"}},h.$attrs),[$e(h.$slots,"default"),I(r)?(v(),C("div",yy)):ae("",!0)],16))}}),np="selection",Dy={id:np,name:"Selection Plugin",version:"1.0.0",provides:["selection"],requires:["interaction-manager"],optional:["viewport","scroll"],defaultConfig:{menuHeight:40}},op="SELECTION/INIT_STATE",rp="SELECTION/CLEANUP_STATE",ap="SELECTION/CACHE_PAGE_GEOMETRY",ip="SELECTION/SET_SELECTION",sp="SELECTION/START_SELECTION",lp="SELECTION/END_SELECTION",cp="SELECTION/CLEAR_SELECTION",up="SELECTION/SET_RECTS",dp="SELECTION/SET_SLICES",pp="SELECTION/EVICT_PAGE_GEOMETRY",Sy="SELECTION/RESET",Ey=(t,e)=>({type:op,payload:{documentId:t,state:e}}),Ay=t=>({type:rp,payload:t}),xy=(t,e,n)=>({type:ap,payload:{documentId:t,page:e,geo:n}}),hp=(t,e)=>({type:ip,payload:{documentId:t,selection:e}}),gp=t=>({type:sp,payload:{documentId:t}}),fp=t=>({type:lp,payload:{documentId:t}}),Cy=t=>({type:cp,payload:{documentId:t}}),mp=(t,e)=>({type:up,payload:{documentId:t,rects:e}}),Pp=(t,e)=>({type:dp,payload:{documentId:t,slices:e}}),Ty=(t,e)=>({type:pp,payload:{documentId:t,pages:e}}),Fp={geometry:{},rects:{},slices:{},selection:null,active:!1,selecting:!1},bp={documents:{}},Sn=(t,e,n)=>({...t,documents:{...t.documents,[e]:n}}),My=(t=bp,e)=>{switch(e.type){case op:{const{documentId:n,state:o}=e.payload;return Sn(t,n,o)}case rp:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r}}case ap:{const{documentId:n,page:o,geo:r}=e.payload,a=t.documents[n];return a?Sn(t,n,{...a,geometry:{...a.geometry,[o]:r}}):t}case ip:{const{documentId:n,selection:o}=e.payload,r=t.documents[n];return r?Sn(t,n,{...r,selection:o,active:!0}):t}case sp:{const{documentId:n}=e.payload,o=t.documents[n];return o?Sn(t,n,{...o,selecting:!0,selection:null,rects:{}}):t}case lp:{const{documentId:n}=e.payload,o=t.documents[n];return o?Sn(t,n,{...o,selecting:!1}):t}case cp:{const{documentId:n}=e.payload,o=t.documents[n];return o?Sn(t,n,{...o,selecting:!1,selection:null,rects:{},active:!1}):t}case up:{const{documentId:n,rects:o}=e.payload,r=t.documents[n];return r?Sn(t,n,{...r,rects:o}):t}case dp:{const{documentId:n,slices:o}=e.payload,r=t.documents[n];return r?Sn(t,n,{...r,slices:o}):t}case pp:{const{documentId:n,pages:o}=e.payload,r=t.documents[n];if(!r)return t;const a={...r.geometry},i={...r.rects},s={...r.slices};for(const l of o)delete a[l],delete i[l],delete s[l];return Sn(t,n,{...r,geometry:a,rects:i,slices:s})}case Sy:{const{documentId:n}=e.payload;return t.documents[n]?Sn(t,n,Fp):t}default:return t}};function Gr(t,e){return t.rects[e]??[]}function Zo(t,e){return Xi(Gr(t,e))}function Ls(t){const e=[],n=t.rects;for(const o in n){const r=Number(o),a=Xi(n[r]);a&&e.push({page:r,rect:a})}return e}function _p(t,e){const n=t.rects[e]||[];if(n.length===0)return null;const o=Zo(t,e);return o?{pageIndex:e,rect:o,segmentRects:n}:null}function yp(t){const e=[],n=Object.keys(t.rects).map(Number);for(const o of n){const r=t.rects[o]||[];if(r.length===0)continue;const a=Zo(t,o);a&&e.push({pageIndex:o,rect:a,segmentRects:r})}return e}function Ja(t,e,n=1.5){for(const s of t.runs){if(!(e.y>=s.rect.y&&e.y<=s.rect.y+s.rect.height&&e.x>=s.rect.x&&e.x<=s.rect.x+s.rect.width))continue;const c=s.glyphs.findIndex(u=>{const d=u.tightX??u.x,p=u.tightY??u.y,h=u.tightWidth??u.width,g=u.tightHeight??u.height;return e.x>=d&&e.x<=d+h&&e.y>=p&&e.y<=p+g});if(c!==-1)return s.charStart+c}if(n<=0)return-1;const r=Ry(t,n)/2;let a=-1,i=1/0;for(const s of t.runs)if(!(e.y<s.rect.y-r||e.y>s.rect.y+s.rect.height+r||e.x<s.rect.x-r||e.x>s.rect.x+s.rect.width+r))for(let l=0;l<s.glyphs.length;l++){const c=s.glyphs[l];if(c.flags===2)continue;const u=c.tightX??c.x,d=c.tightY??c.y,p=c.tightWidth??c.width,h=c.tightHeight??c.height,g=u-r,f=u+p+r,F=d-r,_=d+h+r;if(e.x<g||e.x>f||e.y<F||e.y>_)continue;const y=Math.min(Math.abs(e.x-u),Math.abs(e.x-(u+p))),E=Math.min(Math.abs(e.y-d),Math.abs(e.y-(d+h))),A=y+E;A<i&&(i=A,a=s.charStart+l)}return a}function Ry(t,e){let n=0,o=0;for(const r of t.runs)for(const a of r.glyphs)a.flags!==2&&(n+=a.height,o++);return o===0?0:n/o*e}function vp(t,e,n){if(!t||!e||n<t.start.page||n>t.end.page)return null;const o=n===t.start.page?t.start.index:0,r=e.runs[e.runs.length-1],a=r.charStart+r.glyphs.length-1,i=n===t.end.page?t.end.index:a;return{from:o,to:i}}function Dp(t,e,n,o=!0){const r=[];for(const i of t.runs){const s=i.charStart,l=s+i.glyphs.length-1;if(l<e||s>n)continue;const c=Math.max(e,s)-s,u=Math.min(n,l)-s;let d=1/0,p=-1/0,h=1/0,g=-1/0,f=0,F=0,_=-1/0;const y=()=>{d!==1/0&&f>0&&r.push({rect:{origin:{x:d,y:h},size:{width:p-d,height:g-h}},charCount:f,fontSize:i.fontSize}),d=1/0,p=-1/0,h=1/0,g=-1/0,f=0,F=0,_=-1/0};for(let E=c;E<=u;E++){const A=i.glyphs[E];if(A.flags!==2){if(f>0&&_>-1/0){const T=Math.abs(A.x-_),q=F/f;q>0&&T>2.5*q&&y()}d=Math.min(d,A.x),p=Math.max(p,A.x+A.width),h=Math.min(h,A.y),g=Math.max(g,A.y+A.height),f++,F+=A.width,_=A.x+A.width}}y()}return o?Iy(r):r.map(i=>i.rect)}function Sp(t,e){const n=Math.min(t.origin.x,e.origin.x),o=Math.min(t.origin.y,e.origin.y),r=Math.max(t.origin.x+t.size.width,e.origin.x+e.size.width),a=Math.max(t.origin.y+t.size.height,e.origin.y+e.size.height);return{origin:{x:n,y:o},size:{width:r-n,height:a-o}}}function wy(t,e){const n=Math.max(t.origin.x,e.origin.x),o=Math.max(t.origin.y,e.origin.y),r=Math.min(t.origin.x+t.size.width,e.origin.x+e.size.width),a=Math.min(t.origin.y+t.size.height,e.origin.y+e.size.height),i=Math.max(0,r-n),s=Math.max(0,a-o);return{origin:{x:n,y:o},size:{width:i,height:s}}}function $s(t){return t.size.width<=0||t.size.height<=0}function Oy(t,e){if($s(t)||$s(e))return 0;const n=Sp(t,e);return n.size.height===t.size.height||n.size.height===e.size.height?1:wy(t,e).size.height/n.size.height}function ky(t,e){if(t.fontSize!=null&&e.fontSize!=null&&t.fontSize>0&&e.fontSize>0&&Math.max(t.fontSize,e.fontSize)/Math.min(t.fontSize,e.fontSize)>1.5)return!1;const o=.8,r=t.rect,a=e.rect;if(Oy(r,a)<o)return!1;const i=1,s=i*r.size.width/t.charCount,l=i*a.size.width/e.charCount,c=r.origin.x-s,u=r.origin.x+r.size.width+s,d=a.origin.x-l,p=a.origin.x+a.size.width+l;return c<p&&u>d}function Iy(t){const e=[];let n=null,o=null;for(const r of t)n&&o?ky(n,r)?o=Sp(o,r.rect):(e.push(o),o=r.rect):o=r.rect,n=r;return o&&!$s(o)&&e.push(o),e}const Gy=.5;function ei(t,e){for(let n=0;n<t.runs.length;n++){const o=t.runs[n],r=e-o.charStart;if(r>=0&&r<o.glyphs.length)return{runIdx:n,localIdx:r}}return null}function Ep(t){return t===1||t===2}function Ly(t,e){if(!ei(t,e))return null;const o=Ny(t);if(o===0)return null;let r=e;for(;r>0;){const i=ei(t,r-1);if(!i||Ep(t.runs[i.runIdx].glyphs[i.localIdx].flags))break;r--}let a=e;for(;a<o-1;){const i=ei(t,a+1);if(!i||Ep(t.runs[i.runIdx].glyphs[i.localIdx].flags))break;a++}return{from:r,to:a}}function $y(t,e){const n=ei(t,e);if(!n)return null;const o=t.runs[n.runIdx],r=o.rect.y,a=o.rect.y+o.rect.height;let i=o.charStart,s=o.charStart+o.glyphs.length-1;for(let l=n.runIdx-1;l>=0;l--){const c=t.runs[l];if(!Ap(c)){if(!xp(c.rect.y,c.rect.y+c.rect.height,r,a))break;i=c.charStart}}for(let l=n.runIdx+1;l<t.runs.length;l++){const c=t.runs[l];if(!Ap(c)){if(!xp(c.rect.y,c.rect.y+c.rect.height,r,a))break;s=c.charStart+c.glyphs.length-1}}return{from:i,to:s}}function Ap(t){return t.rect.width===0&&t.rect.height===0}function xp(t,e,n,o){const r=Math.max(e,o)-Math.min(t,n),a=Math.max(0,Math.min(e,o)-Math.max(t,n));return r===0?!1:a/r>=Gy}function Ny(t){if(t.runs.length===0)return 0;const e=t.runs[t.runs.length-1];return e.charStart+e.glyphs.length}const Cp=500;function jy(t){const e=t.minDragDistance??3,n=t.toleranceFactor??1.5;let o=null,r=null,a=!1,i=0;function s(){var l;o=null,r=null,a=!1,(l=t.setHasTextAnchor)==null||l.call(t,!1)}return{onPointerDown:(l,c,u)=>{var d,p;if(c.target===c.currentTarget&&((d=t.onEmptySpaceClick)==null||d.call(t,u)),!t.isEnabled(u))return;const h=Date.now();(i===0||h-i>=Cp)&&t.onClear(u);const g=t.getGeometry();if(!g)return;const f=Ja(g,l,n);f!==-1&&(o=f,r=l,a=!1,(p=t.setHasTextAnchor)==null||p.call(t,!0))},onPointerMove:(l,c,u)=>{if(!t.isEnabled(u))return;const d=t.getGeometry();if(!d)return;const p=Ja(d,l,n);if(t.setCursor(p!==-1?"text":null),o!==null&&r&&!a){const h=l.x-r.x,g=l.y-r.y;Math.sqrt(h*h+g*g)>=e&&(a=!0,t.onBegin(o,u),p!==-1&&t.onUpdate(p,u));return}t.isSelecting()&&p!==-1&&t.onUpdate(p,u)},onPointerUp:(l,c,u)=>{if(!t.isEnabled(u)){s();return}a&&t.onEnd(u),s()},onDoubleClick:(l,c,u)=>{var d;if(!t.isEnabled(u))return;const p=t.getGeometry();if(!p)return;const h=Ja(p,l,n);h!==-1&&(i=Date.now(),(d=t.onWordSelect)==null||d.call(t,h,u))},onClick:(l,c,u)=>{var d;if(!t.isEnabled(u)||i===0)return;if(Date.now()-i>Cp){i=0;return}i=0;const h=t.getGeometry();if(!h)return;const g=Ja(h,l,n);g!==-1&&((d=t.onLineSelect)==null||d.call(t,g,u))},onHandlerActiveEnd:l=>{s(),t.isEnabled(l)&&t.onClear(l)}}}function Uy(t){const{pageSize:e,scale:n,minDragPx:o=5}=t;let r=null,a=null;return{onPointerDown:(i,s,l)=>{var c,u;t.isEnabled(l)&&((c=t.isTextSelecting)!=null&&c.call(t)||(r=i,a={origin:{x:i.x,y:i.y},size:{width:0,height:0}},t.onBegin(i,l),(u=s.setPointerCapture)==null||u.call(s)))},onPointerMove:(i,s,l)=>{if(!r||!t.isEnabled(l))return;const c=et(i.x,0,e.width),u=et(i.y,0,e.height);a={origin:{x:Math.min(r.x,c),y:Math.min(r.y,u)},size:{width:Math.abs(c-r.x),height:Math.abs(u-r.y)}},t.onChange(a,l)},onPointerUp:(i,s,l)=>{var c;t.isEnabled(l)&&(a&&r&&(Math.max(a.size.width,a.size.height)*n>o?t.onEnd(a,l):t.onCancel(l)),r=null,a=null,(c=s.releasePointerCapture)==null||c.call(s))},onPointerCancel:(i,s,l)=>{var c;t.isEnabled(l)&&(r=null,a=null,t.onCancel(l),(c=s.releasePointerCapture)==null||c.call(s))}}}const Tp=class extends jt{constructor(e,n,o){var r,a,i;super(e,n),this.enabledModesPerDoc=new Map,this.selecting=new Map,this.anchor=new Map,this.hasTextAnchor=new Map,this.marqueePage=new Map,this.pageCallbacks=new Map,this.geoAccessOrder=new Map,this.menuPlacement$=Tt((l,c)=>({documentId:l,placement:c})),this.selChange$=Tt((l,c)=>({documentId:l,selection:c,modeId:this.interactionManagerCapability.forDocument(l).getActiveMode()})),this.textRetrieved$=Tt((l,c)=>({documentId:l,text:c})),this.copyToClipboard$=Tt((l,c)=>({documentId:l,text:c}),{cache:!1}),this.beginSelection$=Tt((l,c)=>({documentId:l,page:c.page,index:c.index,modeId:c.modeId}),{cache:!1}),this.endSelection$=Tt((l,c)=>({documentId:l,modeId:c.modeId}),{cache:!1}),this.marqueeChange$=Tt((l,c)=>({documentId:l,pageIndex:c.pageIndex,rect:c.rect,modeId:c.modeId}),{cache:!1}),this.marqueeEnd$=Tt((l,c)=>({documentId:l,pageIndex:c.pageIndex,rect:c.rect,modeId:c.modeId}),{cache:!1}),this.emptySpaceClick$=Tt((l,c)=>({documentId:l,pageIndex:c.pageIndex,modeId:c.modeId}),{cache:!1}),this.viewportCapability=null,this.scrollCapability=null,this.config=o,this.menuHeight=o.menuHeight??40;const s=n.getPlugin("interaction-manager");if(!s)throw new Error("SelectionPlugin: InteractionManagerPlugin is required.");this.interactionManagerCapability=s.provides(),this.viewportCapability=((r=n.getPlugin("viewport"))==null?void 0:r.provides())??null,this.scrollCapability=((a=n.getPlugin("scroll"))==null?void 0:a.provides())??null,this.coreStore.onAction(Vo,l=>{const{documentId:c,pageIndexes:u}=l.payload,d=u.map(p=>this.getNewPageGeometryAndCache(c,p));Ie.all(d).wait(()=>{u.forEach(p=>{this.notifyPage(c,p)})},Yt)}),(i=this.viewportCapability)==null||i.onViewportChange(l=>{this.recalculateMenuPlacement(l.documentId)},{mode:"throttle",wait:100})}onDocumentLoadingStarted(e){var n;this.dispatch(Ey(e,Fp));const o=((n=this.config.marquee)==null?void 0:n.enabled)!==!1;this.enabledModesPerDoc.set(e,new Map([["pointerMode",{enableSelection:!0,showSelectionRects:!0,enableMarquee:o,showMarqueeRects:!0}]])),this.pageCallbacks.set(e,new Map),this.geoAccessOrder.set(e,[]),this.selecting.set(e,!1),this.anchor.set(e,void 0),this.hasTextAnchor.set(e,!1)}onDocumentClosed(e){this.dispatch(Ay(e)),this.enabledModesPerDoc.delete(e),this.pageCallbacks.delete(e),this.geoAccessOrder.delete(e),this.selecting.delete(e),this.hasTextAnchor.delete(e),this.anchor.delete(e),this.marqueePage.delete(e),this.selChange$.clearScope(e),this.textRetrieved$.clearScope(e),this.copyToClipboard$.clearScope(e),this.beginSelection$.clearScope(e),this.endSelection$.clearScope(e),this.menuPlacement$.clearScope(e),this.marqueeChange$.clearScope(e),this.marqueeEnd$.clearScope(e),this.emptySpaceClick$.clearScope(e)}async initialize(){}async destroy(){this.selChange$.clear(),this.textRetrieved$.clear(),this.copyToClipboard$.clear(),this.beginSelection$.clear(),this.endSelection$.clear(),this.menuPlacement$.clear(),this.marqueeChange$.clear(),this.marqueeEnd$.clear(),this.emptySpaceClick$.clear(),super.destroy()}buildCapability(){const e=n=>n??this.getActiveDocumentId();return{getFormattedSelection:n=>yp(this.getDocumentState(e(n))),getFormattedSelectionForPage:(n,o)=>_p(this.getDocumentState(e(o)),n),getHighlightRectsForPage:(n,o)=>Gr(this.getDocumentState(e(o)),n),getHighlightRects:n=>this.getDocumentState(e(n)).rects,getBoundingRectForPage:(n,o)=>Zo(this.getDocumentState(e(o)),n),getBoundingRects:n=>Ls(this.getDocumentState(e(n))),getSelectedText:n=>this.getSelectedText(e(n)),clear:n=>this.clearSelection(e(n)),copyToClipboard:n=>this.copyToClipboard(e(n)),getState:n=>this.getDocumentState(e(n)),enableForMode:(n,o,r)=>{var a;return(a=this.enabledModesPerDoc.get(e(r)))==null?void 0:a.set(n,{...o})},isEnabledForMode:(n,o)=>{var r;return((r=this.enabledModesPerDoc.get(e(o)))==null?void 0:r.has(n))??!1},setMarqueeEnabled:(n,o)=>this.setMarqueeEnabled(e(o),n),isMarqueeEnabled:n=>this.isMarqueeEnabled(e(n)),forDocument:this.createSelectionScope.bind(this),onCopyToClipboard:this.copyToClipboard$.onGlobal,onSelectionChange:this.selChange$.onGlobal,onTextRetrieved:this.textRetrieved$.onGlobal,onBeginSelection:this.beginSelection$.onGlobal,onEndSelection:this.endSelection$.onGlobal,onMarqueeChange:this.marqueeChange$.onGlobal,onMarqueeEnd:this.marqueeEnd$.onGlobal,onEmptySpaceClick:this.emptySpaceClick$.onGlobal}}createSelectionScope(e){return{getFormattedSelection:()=>yp(this.getDocumentState(e)),getFormattedSelectionForPage:n=>_p(this.getDocumentState(e),n),getHighlightRectsForPage:n=>Gr(this.getDocumentState(e),n),getHighlightRects:()=>this.getDocumentState(e).rects,getBoundingRectForPage:n=>Zo(this.getDocumentState(e),n),getBoundingRects:()=>Ls(this.getDocumentState(e)),getSelectedText:()=>this.getSelectedText(e),clear:()=>this.clearSelection(e),copyToClipboard:()=>this.copyToClipboard(e),getState:()=>this.getDocumentState(e),setMarqueeEnabled:n=>this.setMarqueeEnabled(e,n),isMarqueeEnabled:()=>this.isMarqueeEnabled(e),onSelectionChange:this.selChange$.forScope(e),onTextRetrieved:this.textRetrieved$.forScope(e),onCopyToClipboard:this.copyToClipboard$.forScope(e),onBeginSelection:this.beginSelection$.forScope(e),onEndSelection:this.endSelection$.forScope(e),onMarqueeChange:this.marqueeChange$.forScope(e),onMarqueeEnd:this.marqueeEnd$.forScope(e),onEmptySpaceClick:this.emptySpaceClick$.forScope(e)}}getDocumentState(e){const n=this.state.documents[e];if(!n)throw new Error(`Selection state not found for document: ${e}`);return n}onMenuPlacement(e,n){return this.menuPlacement$.forScope(e)(n)}registerSelectionOnPage(e){var n;const{documentId:o,pageIndex:r,onRectsChange:a}=e,i=this.state.documents[o];if(!i)return this.logger.warn("SelectionPlugin","RegisterFailed",`Cannot register selection on page ${r} for document ${o}: document state not initialized.`),()=>{};(n=this.pageCallbacks.get(o))==null||n.set(r,a);const s=this.getOrLoadGeometry(o,r),l=this.interactionManagerCapability.forDocument(o),c=this.enabledModesPerDoc.get(o);a({rects:Gr(i,r),boundingRect:Zo(i,r)}),s.wait(p=>{const h=this.getDocumentState(o),g=h.selection;if(!g||r<g.start.page||r>g.end.page)return;const f=vp(g,p,r);if(!f)return;const F=Dp(p,f.from,f.to);this.dispatch(mp(o,{...h.rects,[r]:F})),this.dispatch(Pp(o,{...h.slices,[r]:{start:f.from,count:f.to-f.from+1}})),this.notifyPage(o,r)},Yt);const u=jy({getGeometry:()=>this.getDocumentState(o).geometry[r],isEnabled:p=>{const h=c==null?void 0:c.get(p);return h?h.enableSelection!==!1:!1},onBegin:(p,h)=>this.beginSelection(o,r,p,h),onUpdate:(p,h)=>this.updateSelection(o,r,p,h),onEnd:p=>this.endSelection(o,p),onClear:p=>this.clearSelection(o,p),isSelecting:()=>this.selecting.get(o)??!1,setCursor:p=>p?l.setCursor("selection-text",p,10):l.removeCursor("selection-text"),onEmptySpaceClick:p=>this.emptySpaceClick$.emit(o,{pageIndex:r,modeId:p}),onWordSelect:(p,h)=>this.selectWord(o,r,p,h),onLineSelect:(p,h)=>this.selectLine(o,r,p,h),setHasTextAnchor:p=>this.hasTextAnchor.set(o,p),minDragDistance:this.config.minSelectionDragDistance,toleranceFactor:this.config.toleranceFactor}),d=this.interactionManagerCapability.registerAlways({scope:{type:"page",documentId:o,pageIndex:r},handlers:u});return()=>{var p;d(),(p=this.pageCallbacks.get(o))==null||p.delete(r),s.abort({code:ve.Cancelled,message:"Cleanup"})}}registerMarqueeOnPage(e){var n;const{documentId:o,pageIndex:r,scale:a,onRectChange:i}=e;if(!this.state.documents[o])return this.logger.warn("SelectionPlugin","RegisterMarqueeFailed",`Cannot register marquee on page ${r} for document ${o}: document state not initialized.`),()=>{};const l=this.coreState.core.documents[o];if(!l||!l.document)return this.logger.warn("SelectionPlugin","DocumentNotFound",`Cannot register marquee on page ${r}: document not found`),()=>{};const c=l.document.pages[r];if(!c)return this.logger.warn("SelectionPlugin","PageNotFound",`Cannot register marquee on page ${r}: page not found`),()=>{};const u=c.size,d=((n=this.config.marquee)==null?void 0:n.minDragPx)??5,p=()=>{var f;const F=this.interactionManagerCapability.forDocument(o).getActiveMode(),_=(f=this.enabledModesPerDoc.get(o))==null?void 0:f.get(F);return(_==null?void 0:_.showMarqueeRects)!==!1},h=Uy({pageSize:u,scale:a,minDragPx:d,isEnabled:f=>{var F;const _=(F=this.enabledModesPerDoc.get(o))==null?void 0:F.get(f);return(_==null?void 0:_.enableMarquee)===!0},isTextSelecting:()=>(this.selecting.get(o)??!1)||(this.hasTextAnchor.get(o)??!1),onBegin:(f,F)=>this.beginMarquee(o,r,f,F),onChange:(f,F)=>{this.updateMarquee(o,r,f,F),i(p()?f:null)},onEnd:(f,F)=>{this.endMarquee(o,r,f,F),i(null)},onCancel:f=>{this.cancelMarquee(o,f),i(null)}});return this.interactionManagerCapability.registerAlways({scope:{type:"page",documentId:o,pageIndex:r},handlers:h})}getPlacementMetrics(e,n,o,r){var a;const i=(a=this.scrollCapability)==null?void 0:a.forDocument(e),s=i==null?void 0:i.getRectPositionForPage(n,o);if(!s)return null;const l=s.origin.y-r.scrollTop,c=s.origin.y+s.size.height-r.scrollTop;return{pageIndex:n,rect:o,spaceAbove:l,spaceBelow:r.clientHeight-c,isBottomVisible:c>0&&c<=r.clientHeight,isTopVisible:l>=0&&l<r.clientHeight}}emitMenuPlacement(e,n){this.menuPlacement$.emit(e,n),n?this.interactionManagerCapability.claimPageActivity(e,"selection-menu",n.pageIndex):this.interactionManagerCapability.releasePageActivity(e,"selection-menu")}recalculateMenuPlacement(e){const n=this.state.documents[e];if(!n)return;if(n.selecting||n.selection===null){this.emitMenuPlacement(e,null);return}const o=Ls(n);if(o.length===0){this.emitMenuPlacement(e,null);return}const r=o[o.length-1];if(!this.viewportCapability||!this.scrollCapability){this.emitMenuPlacement(e,{pageIndex:r.page,rect:r.rect,spaceAbove:0,spaceBelow:1/0,suggestTop:!1,isVisible:!0});return}const i=this.viewportCapability.forDocument(e).getMetrics(),s=o[0],l=this.getPlacementMetrics(e,r.page,r.rect,i),c=this.getPlacementMetrics(e,s.page,s.rect,i);if(l&&l.isBottomVisible&&l.spaceBelow>this.menuHeight){this.emitMenuPlacement(e,{...l,suggestTop:!1,isVisible:!0});return}if(c&&c.isTopVisible){this.emitMenuPlacement(e,{...c,suggestTop:!0,isVisible:!0});return}if(l&&l.isBottomVisible){this.emitMenuPlacement(e,{...l,suggestTop:!1,isVisible:!0});return}this.emitMenuPlacement(e,null)}notifyPage(e,n){var o,r;const a=(o=this.pageCallbacks.get(e))==null?void 0:o.get(n);if(a){const i=this.getDocumentState(e),s=this.interactionManagerCapability.forDocument(e).getActiveMode(),l=(r=this.enabledModesPerDoc.get(e))==null?void 0:r.get(s),c=l&&(l.showSelectionRects??l.showRects)!==!1;a(c?{rects:Gr(i,n),boundingRect:Zo(i,n)}:{rects:[],boundingRect:null})}}notifyAllPages(e){var n;(n=this.pageCallbacks.get(e))==null||n.forEach((o,r)=>{this.notifyPage(e,r)})}getNewPageGeometryAndCache(e,n){const o=this.getCoreDocument(e);if(!o||!o.document)return Ue.reject({code:ve.NotFound,message:"Doc Not Found"});const r=o.document.pages.find(i=>i.index===n),a=this.engine.getPageGeometry(o.document,r);return a.wait(i=>{this.dispatch(xy(e,n,i)),this.touchGeometry(e,n)},Yt),a}getOrLoadGeometry(e,n){const o=this.getDocumentState(e).geometry[n];return o?(this.touchGeometry(e,n),Ue.resolve(o)):this.getNewPageGeometryAndCache(e,n)}touchGeometry(e,n){const o=this.geoAccessOrder.get(e);if(!o)return;const r=o.indexOf(n);r>-1&&o.splice(r,1),o.push(n),this.evictGeometryIfNeeded(e)}evictGeometryIfNeeded(e){const n=this.config.maxCachedGeometries??50,o=this.geoAccessOrder.get(e);if(!o||o.length<=n)return;const r=this.pageCallbacks.get(e),a=[];for(;o.length-a.length>n;){const i=o.find(s=>!a.includes(s)&&!(r!=null&&r.has(s)));if(i===void 0)break;a.push(i)}if(a.length!==0){for(const i of a){const s=o.indexOf(i);s>-1&&o.splice(s,1)}this.dispatch(Ty(e,a))}}beginSelection(e,n,o,r){this.selecting.set(e,!0),this.anchor.set(e,{page:n,index:o}),this.dispatch(gp(e)),this.beginSelection$.emit(e,{page:n,index:o,modeId:r}),this.recalculateMenuPlacement(e)}endSelection(e,n){this.selecting.set(e,!1),this.anchor.set(e,void 0),this.dispatch(fp(e)),this.endSelection$.emit(e,{modeId:n}),this.recalculateMenuPlacement(e)}clearSelection(e,n){this.selecting.set(e,!1),this.anchor.set(e,void 0),this.dispatch(Cy(e)),this.selChange$.emit(e,null),this.emitMenuPlacement(e,null),this.notifyAllPages(e)}selectWord(e,n,o,r){const a=this.getDocumentState(e).geometry[n];if(!a)return;const i=Ly(a,o);i&&this.applyInstantSelection(e,n,i.from,i.to,r)}selectLine(e,n,o,r){const a=this.getDocumentState(e).geometry[n];if(!a)return;const i=$y(a,o);i&&this.applyInstantSelection(e,n,i.from,i.to,r)}applyInstantSelection(e,n,o,r,a){const i={start:{page:n,index:o},end:{page:n,index:r}};this.selecting.set(e,!1),this.anchor.set(e,void 0),this.dispatch(gp(e)),this.dispatch(hp(e,i)),this.updateRectsAndSlices(e,i),this.dispatch(fp(e)),this.selChange$.emit(e,i),this.beginSelection$.emit(e,{page:n,index:o,modeId:a}),this.endSelection$.emit(e,{modeId:a});for(let s=i.start.page;s<=i.end.page;s++)this.notifyPage(e,s);this.recalculateMenuPlacement(e)}updateSelection(e,n,o,r){if(!this.selecting.get(e)||!this.anchor.get(e))return;const a=this.anchor.get(e),i=n>a.page||n===a.page&&o>=a.index,c={start:i?a:{page:n,index:o},end:i?{page:n,index:o}:a};this.dispatch(hp(e,c)),this.updateRectsAndSlices(e,c),this.selChange$.emit(e,c);for(let u=c.start.page;u<=c.end.page;u++)this.notifyPage(e,u)}updateRectsAndSlices(e,n){const o=this.getDocumentState(e),r={},a={};for(let i=n.start.page;i<=n.end.page;i++){const s=o.geometry[i],l=vp(n,s,i);l&&(r[i]=Dp(s,l.from,l.to),a[i]={start:l.from,count:l.to-l.from+1})}this.dispatch(mp(e,r)),this.dispatch(Pp(e,a))}getSelectedText(e){if(!this.checkPermission(e,te.CopyContents))return this.logger.debug("SelectionPlugin","GetSelectedText",`Cannot get selected text: document ${e} lacks CopyContents permission`),Ue.reject({code:ve.Security,message:"Document lacks CopyContents permission"});const n=this.getCoreDocument(e),o=this.getDocumentState(e);if(!(n!=null&&n.document)||!o.selection)return Ue.reject({code:ve.NotFound,message:"Doc Not Found or No Selection"});const r=o.selection,a=[];for(let s=r.start.page;s<=r.end.page;s++){const l=o.slices[s];l&&a.push({pageIndex:s,charIndex:l.start,charCount:l.count})}if(a.length===0)return Ue.resolve([]);const i=this.engine.getTextSlices(n.document,a);return i.wait(s=>{this.textRetrieved$.emit(e,s)},Yt),i}copyToClipboard(e){if(!this.checkPermission(e,te.CopyContents)){this.logger.debug("SelectionPlugin","CopyToClipboard",`Cannot copy to clipboard: document ${e} lacks CopyContents permission`);return}this.getSelectedText(e).wait(o=>{this.copyToClipboard$.emit(e,o.join(`
22
- `))},Yt)}beginMarquee(e,n,o,r){this.marqueePage.set(e,n)}updateMarquee(e,n,o,r){this.marqueeChange$.emit(e,{pageIndex:n,rect:o,modeId:r})}endMarquee(e,n,o,r){this.marqueeEnd$.emit(e,{pageIndex:n,rect:o,modeId:r}),this.marqueeChange$.emit(e,{pageIndex:n,rect:null,modeId:r}),this.marqueePage.delete(e)}cancelMarquee(e,n){const o=this.marqueePage.get(e);o!==void 0&&(this.marqueeChange$.emit(e,{pageIndex:o,rect:null,modeId:n}),this.marqueePage.delete(e))}setMarqueeEnabled(e,n){const o=this.enabledModesPerDoc.get(e);if(!o)return;const r=o.get("pointerMode");r?r.enableMarquee=n:n&&o.set("pointerMode",{enableMarquee:!0})}isMarqueeEnabled(e){var n;const o=(n=this.enabledModesPerDoc.get(e))==null?void 0:n.get("pointerMode");return(o==null?void 0:o.enableMarquee)!==!1}};Tp.id="selection";let Ns=Tp;const By={manifest:Dy,create:(t,e)=>new Ns(np,t,e),reducer:My,initialState:bp},js=()=>It(Ns.id),Mp=()=>Nn(Ns.id),zy=ie({__name:"text-selection",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:Er.Degree0},background:{default:"rgba(33,150,243)"},selectionMenu:{}},setup(t){const e=t,n=ma(),{plugin:o}=Mp(),r=Dn(()=>e.documentId),a=P(()=>{var f,F,_;return(_=(F=(f=r.value)==null?void 0:f.document)==null?void 0:F.pages)==null?void 0:_[e.pageIndex]}),i=Q([]),s=Q(null),l=Q(null),c=P(()=>{var f;return e.scale!==void 0?e.scale:((f=r.value)==null?void 0:f.scale)??1}),u=P(()=>{var f,F;if(e.rotation!==void 0)return e.rotation;const _=((f=a.value)==null?void 0:f.rotation)??0,y=((F=r.value)==null?void 0:F.rotation)??0;return(_+y)%4}),d=P(()=>!l.value||l.value.pageIndex!==e.pageIndex||!l.value.isVisible?!1:!!e.selectionMenu||!!n["selection-menu"]);Se([()=>o.value,()=>e.documentId,()=>e.pageIndex],([f,F,_],y,E)=>{if(!f||!F){i.value=[],s.value=null;return}const A=f.registerSelectionOnPage({documentId:F,pageIndex:_,onRectsChange:({rects:T,boundingRect:q})=>{i.value=T,s.value=q}});E(A)},{immediate:!0}),Se([()=>o.value,()=>e.documentId],([f,F],_,y)=>{if(!f||!F){l.value=null;return}const E=f.onMenuPlacement(F,A=>{l.value=A});y(E)},{immediate:!0});const p=()=>({type:"selection",pageIndex:e.pageIndex}),h=()=>{var f,F,_;return{suggestTop:((f=l.value)==null?void 0:f.suggestTop)??!1,spaceAbove:((F=l.value)==null?void 0:F.spaceAbove)??0,spaceBelow:((_=l.value)==null?void 0:_.spaceBelow)??0}},g=(f,F)=>e.selectionMenu?e.selectionMenu({rect:f,menuWrapperProps:F,selected:!0,placement:h(),context:p()}):null;return(f,F)=>s.value?(v(),C(pe,{key:0},[m("div",{style:Z({position:"absolute",left:`${s.value.origin.x*c.value}px`,top:`${s.value.origin.y*c.value}px`,width:`${s.value.size.width*c.value}px`,height:`${s.value.size.height*c.value}px`,mixBlendMode:"multiply",isolation:"isolate",pointerEvents:"none"})},[(v(!0),C(pe,null,tt(i.value,(_,y)=>(v(),C("div",{key:y,style:Z({position:"absolute",left:`${(_.origin.x-s.value.origin.x)*c.value}px`,top:`${(_.origin.y-s.value.origin.y)*c.value}px`,width:`${_.size.width*c.value}px`,height:`${_.size.height*c.value}px`,background:t.background})},null,4))),128))],4),d.value?(v(),he(I(Ir),{key:0,rect:{origin:{x:l.value.rect.origin.x*c.value,y:l.value.rect.origin.y*c.value},size:{width:l.value.rect.size.width*c.value,height:l.value.rect.size.height*c.value}},rotation:u.value},{default:We(({rect:_,menuWrapperProps:y})=>[t.selectionMenu?(v(),he(Fn(g(_,y)),{key:0})):$e(f.$slots,"selection-menu",{key:1,context:p(),selected:!0,rect:_,placement:h(),menuWrapperProps:y})]),_:3},8,["rect","rotation"])):ae("",!0)],64)):ae("",!0)}}),Wy=ie({__name:"marquee-selection",props:{documentId:{},pageIndex:{},scale:{},className:{},background:{},borderColor:{},borderStyle:{default:"dashed"},stroke:{},fill:{}},setup(t){const e=t,n=P(()=>e.borderColor??e.stroke??"rgba(0,122,204,0.8)"),o=P(()=>e.background??e.fill??"rgba(0,122,204,0.15)"),r=P(()=>e.borderStyle),{plugin:a}=Mp(),i=Dn(()=>e.documentId),s=Q(null),l=P(()=>{var c;return e.scale!==void 0?e.scale:((c=i.value)==null?void 0:c.scale)??1});return Se([a,()=>e.documentId,()=>e.pageIndex,l],([c,u,d,p],h,g)=>{if(s.value=null,!c)return;const f=c.registerMarqueeOnPage({documentId:u,pageIndex:d,scale:p,onRectChange:F=>{s.value=F}});g(()=>{f==null||f()})},{immediate:!0}),(c,u)=>s.value?(v(),C("div",{key:0,style:Z({position:"absolute",pointerEvents:"none",left:`${s.value.origin.x*l.value}px`,top:`${s.value.origin.y*l.value}px`,width:`${s.value.size.width*l.value}px`,height:`${s.value.size.height*l.value}px`,border:`1px ${r.value} ${n.value}`,background:o.value,boxSizing:"border-box",zIndex:1e3}),class:St(t.className)},null,6)):ae("",!0)}}),Hy=ie({__name:"selection-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:Er.Degree0},background:{},textStyle:{},marqueeStyle:{},marqueeClassName:{},selectionMenu:{}},setup(t){const e=t,n=P(()=>{var o;return((o=e.textStyle)==null?void 0:o.background)??e.background});return(o,r)=>{var a,i,s;return v(),C(pe,null,[je(zy,{"document-id":t.documentId,"page-index":t.pageIndex,scale:t.scale,rotation:t.rotation,background:n.value,"selection-menu":t.selectionMenu},{"selection-menu":We(l=>[$e(o.$slots,"selection-menu",zt(Qt(l)))]),_:3},8,["document-id","page-index","scale","rotation","background","selection-menu"]),je(Wy,{"document-id":t.documentId,"page-index":t.pageIndex,scale:t.scale,background:(a=t.marqueeStyle)==null?void 0:a.background,"border-color":(i=t.marqueeStyle)==null?void 0:i.borderColor,"border-style":(s=t.marqueeStyle)==null?void 0:s.borderStyle,"class-name":t.marqueeClassName},null,8,["document-id","page-index","scale","background","border-color","border-style","class-name"])],64)}}}),Vy=ie({__name:"copy-to-clipboard",setup(t){const{provides:e}=js();return Xn(n=>{if(e.value){const o=e.value.onCopyToClipboard(({text:r})=>{navigator.clipboard.writeText(r).catch(a=>{console.error("Failed to copy text to clipboard:",a)})});n(o)}}),(n,o)=>null}}),Yy=Tr(By).addUtility(Vy).build(),qy=["src"],Ky=ie({__name:"appearance-image",props:{appearance:{},style:{}},setup(t){const e=t,n=Q(null),o=Q(null);Xn(a=>{const i=URL.createObjectURL(e.appearance.data);n.value=i,o.value=i,a(()=>{o.value&&(URL.revokeObjectURL(o.value),o.value=null)})});const r=()=>{o.value&&(URL.revokeObjectURL(o.value),o.value=null)};return(a,i)=>n.value?(v(),C("img",{key:0,src:n.value,alt:"",draggable:"false",onLoad:r,style:Z({position:"absolute",width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none",...t.style})},null,44,qy)):ae("",!0)}}),ti=()=>Nn(Is.id),Bn=()=>It(Is.id),Us=16;function Xy(){try{const t=navigator;return/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&(t==null?void 0:t.maxTouchPoints)>1}catch{return!1}}let Bs;function Zy(){return Bs===void 0&&(Bs=Xy()),Bs}function Qy(t,e){const n=Zy();return P(()=>{const o=$t(t),r=$t(e),a=n&&r&&o>0&&o<Us,i=a?Us:o,s=a?o/Us:1,l=a?{width:`${100/s}%`,height:`${100/s}%`,transform:`scale(${s})`,transformOrigin:"top left"}:void 0;return{needsComp:a,adjustedFontPx:i,scaleComp:s,wrapperStyle:l}})}const Jy=["width","height","stroke"],ev=["width","height","stroke"],tv=ie({...{inheritAttrs:!1},__name:"annotation-container",props:{scale:{},documentId:{},pageIndex:{},rotation:{},pageWidth:{},pageHeight:{},trackedAnnotation:{},isSelected:{type:Boolean},isEditing:{type:Boolean,default:!1},isMultiSelected:{type:Boolean,default:!1},isDraggable:{type:Boolean},isResizable:{type:Boolean},isRotatable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},vertexConfig:{},selectionMenu:{},outlineOffset:{default:1},onDoubleClick:{},onSelect:{},appearance:{},zIndex:{default:1},selectionOutlineColor:{default:"#007ACC"},selectionOutline:{},resizeUi:{},vertexUi:{},rotationUi:{},blendMode:{},style:{}},setup(t){const e=t,n=P(()=>{var X;return((X=e.resizeUi)==null?void 0:X.color)??"#007ACC"}),o=P(()=>{var X;return((X=e.vertexUi)==null?void 0:X.color)??"#007ACC"}),r=P(()=>{var X;return((X=e.resizeUi)==null?void 0:X.size)??12}),a=P(()=>{var X;return((X=e.vertexUi)==null?void 0:X.size)??12}),i=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.size)??32}),s=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.color)??"white"}),l=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.connectorColor)??"#007ACC"}),c=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.iconColor)??"#007ACC"}),u=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.showConnector)??!1}),d=P(()=>{var X;return(X=e.rotationUi)==null?void 0:X.margin}),p=P(()=>{var X,Ne;return((Ne=(X=e.rotationUi)==null?void 0:X.border)==null?void 0:Ne.color)??"#007ACC"}),h=P(()=>{var X,Ne;return((Ne=(X=e.rotationUi)==null?void 0:X.border)==null?void 0:Ne.width)??1}),g=P(()=>{var X,Ne;return((Ne=(X=e.rotationUi)==null?void 0:X.border)==null?void 0:Ne.style)??"solid"}),f=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.color)??e.selectionOutlineColor??"#007ACC"}),F=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.style)??"solid"}),_=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.width)??1}),y=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.offset)??e.outlineOffset??1}),E=ln(ke(e.trackedAnnotation.object)),A=Q(null),T=Q(null),q=Q(!1),w=Q(!1),{provides:G}=Bn(),{plugin:W}=ti(),J=ms(e.documentId),ue=Q(null),ce=ln(null),ee=P(()=>J.value.canModifyAnnotations&&e.isDraggable&&!e.isMultiSelected),ge=P(()=>J.value.canModifyAnnotations&&e.isResizable&&!e.isMultiSelected),_e=P(()=>J.value.canModifyAnnotations&&e.isRotatable&&!e.isMultiSelected),Ee=e.onDoubleClick?X=>{var Ne;J.value.canModifyAnnotations&&((Ne=e.onDoubleClick)==null||Ne.call(e,X))}:void 0,Te=P(()=>G.value?G.value.forDocument(e.documentId):null),oe=P(()=>({...ke(e.trackedAnnotation.object),...ke(E.value)})),He=P(()=>(e.trackedAnnotation.object.flags??[]).includes("noZoom")),ft=P(()=>(e.trackedAnnotation.object.flags??[]).includes("noRotate")),Ve=P(()=>He.value?1:e.scale),O=P(()=>ft.value?0:e.rotation),H=P(()=>A.value??oe.value.rotation??0),V=P(()=>A.value??oe.value.rotation??0),se=P(()=>{const X=V.value;return Number.isFinite(X)?Math.round(X*10)/10:0}),L=P(()=>A.value!==null),de=P(()=>oe.value.unrotatedRect),Pe=P(()=>de.value??oe.value.rect),Re=P(()=>{if(de.value&&H.value!==0)return cu(Pe.value,oe.value.rect,H.value)}),vt=P(()=>Pe.value),Ut=P(()=>de.value?{...oe.value,rect:de.value}:oe.value),D=P(()=>e.isSelected&&!e.isMultiSelected),S=P(()=>e.isSelected&&!e.isMultiSelected&&(e.selectionMenu||Cn["selection-menu"])),R=P(()=>({origin:{x:oe.value.rect.origin.x*e.scale,y:oe.value.rect.origin.y*e.scale},size:{width:oe.value.rect.size.width*Ve.value,height:oe.value.rect.size.height*Ve.value}})),N=P(()=>({type:"annotation",annotation:e.trackedAnnotation,pageIndex:e.pageIndex})),$=P(()=>{const X=((H.value+O.value*90)%360+360)%360;return{suggestTop:_e.value&&X>90&&X<270}}),j=(X,Ne)=>e.selectionMenu?e.selectionMenu({rect:X,menuWrapperProps:Ne,selected:e.isSelected,placement:$.value,context:N.value}):null,ne=P(()=>{var X;const Ne=ke(oe.value);return((X=e.vertexConfig)==null?void 0:X.extractVertices(Ne))??[]}),K=P(()=>({minWidth:10,minHeight:10,boundingBox:{width:e.pageWidth,height:e.pageHeight}})),{dragProps:Y,vertices:B,resize:be,rotation:re}=wd({controller:{element:vt,vertices:ne,constraints:K,maintainAspectRatio:P(()=>e.lockAspectRatio),pageRotation:P(()=>e.rotation),annotationRotation:P(()=>H.value),rotationCenter:P(()=>Re.value),rotationElement:P(()=>oe.value.rect),scale:P(()=>e.scale),enabled:P(()=>e.isSelected&&!e.isMultiSelected),onUpdate:X=>{var Ne,Xt,Pt;if(!((Ne=X.transformData)!=null&&Ne.type)||e.isMultiSelected)return;const st=W.value;if(!st)return;const{type:qe,changes:on,metadata:Rt}=X.transformData,er=e.trackedAnnotation.object.id,li={width:e.pageWidth,height:e.pageHeight};if(X.state==="start"&&(ce.value=e.trackedAnnotation.object.unrotatedRect??e.trackedAnnotation.object.rect,ue.value=oe.value,(qe==="resize"||qe==="vertex-edit")&&(w.value=!0),qe==="move"?st.startDrag(e.documentId,{annotationIds:[er],pageSize:li}):qe==="resize"&&st.startResize(e.documentId,{annotationIds:[er],pageSize:li,resizeHandle:(Rt==null?void 0:Rt.handle)??"se"})),on.rect&&ce.value)if(qe==="move"){const Zt={x:on.rect.origin.x-ce.value.origin.x,y:on.rect.origin.y-ce.value.origin.y};st.updateDrag(e.documentId,Zt)}else qe==="resize"&&st.updateResize(e.documentId,on.rect);if(qe==="vertex-edit"&&on.vertices&&e.vertexConfig){const Zt=ue.value??oe.value,Co=e.vertexConfig.transformAnnotation(ke(Zt),on.vertices),Br=(Xt=G.value)==null?void 0:Xt.transformAnnotation(Zt,{type:qe,changes:Co,metadata:Rt});Br&&(E.value={...ke(E.value),...Br},X.state==="end"&&((Pt=Te.value)==null||Pt.updateAnnotation(e.pageIndex,er,Br)))}if(qe==="rotate"){const Zt=(Rt==null?void 0:Rt.rotationAngle)??H.value,Co=Rt==null?void 0:Rt.cursorPosition;Co&&(T.value={x:Co.clientX,y:Co.clientY}),X.state==="start"?(A.value=Zt,st.startRotation(e.documentId,{annotationIds:[er],cursorAngle:Zt,rotationCenter:Rt==null?void 0:Rt.rotationCenter})):X.state==="move"?(A.value=Zt,st.updateRotation(e.documentId,Zt,Rt==null?void 0:Rt.rotationDelta)):X.state==="end"&&(A.value=null,T.value=null,st.commitRotation(e.documentId));return}X.state==="end"&&(w.value=!1,ce.value=null,ue.value=null,qe==="move"?st.commitDrag(e.documentId):qe==="resize"&&st.commitResize(e.documentId))}},resizeUI:{handleSize:r.value,spacing:y.value,offsetMode:"outside",includeSides:!e.lockAspectRatio,zIndex:e.zIndex+1},vertexUI:{vertexSize:a.value,zIndex:e.zIndex+2},rotationUI:{handleSize:i.value,margin:d.value,zIndex:e.zIndex+3,showConnector:u.value},includeVertices:!!e.vertexConfig,includeRotation:_e,currentRotation:H}),Fe=Q_(Ee),De=X=>{L.value||(T.value={x:X.clientX,y:X.clientY})};Xn(()=>{e.trackedAnnotation.object&&(E.value=e.trackedAnnotation.object)}),Xn(X=>{const Ne=W.value;if(!Ne)return;const Xt=e.trackedAnnotation.object.id,Pt=qe=>{var on;if(qe.documentId!==e.documentId)return;(qe.type==="end"||qe.type==="cancel")&&(A.value=null);const Rt=(on=qe.previewPatches)==null?void 0:on[Xt];qe.type==="update"&&Rt?E.value={...ke(E.value),...Rt}:qe.type==="cancel"&&(E.value=e.trackedAnnotation.object)},st=[Ne.onDragChange(Pt),Ne.onResizeChange(Pt),Ne.onRotateChange(Pt)];X(()=>st.forEach(qe=>qe()))});const we=P(()=>oe.value.rect.size.width*Ve.value),Ge=P(()=>oe.value.rect.size.height*Ve.value),Oe=P(()=>Pe.value.size.width*Ve.value),k=P(()=>Pe.value.size.height*Ve.value),ye=P(()=>!!de.value&&H.value!==0),Le=P(()=>ye.value?(Pe.value.origin.x-oe.value.rect.origin.x)*Ve.value:(we.value-Oe.value)/2),Ke=P(()=>ye.value?(Pe.value.origin.y-oe.value.rect.origin.y)*Ve.value:(Ge.value-k.value)/2),Xe=P(()=>ye.value&&Re.value?`${(Re.value.x-Pe.value.origin.x)*Ve.value}px ${(Re.value.y-Pe.value.origin.y)*Ve.value}px`:"center center"),Kt=P(()=>Re.value?(Re.value.x-oe.value.rect.origin.x)*Ve.value:we.value/2),dt=P(()=>Re.value?(Re.value.y-oe.value.rect.origin.y)*Ve.value:Ge.value/2),Ze=P(()=>Math.max(300,Math.max(we.value,Ge.value)+80)),Dt=P(()=>ft.value?Ad({size:{width:we.value,height:Ge.value}},e.rotation):null),Ft=P(()=>Math.round(i.value*.6)),gt=P(()=>{var X;return!!((X=e.appearance)!=null&&X.normal)&&!w.value&&!e.isEditing&&!e.trackedAnnotation.dictMode}),Gt={display:"contents"},Ye=P(()=>({position:"absolute",left:`${oe.value.rect.origin.x*e.scale}px`,top:`${oe.value.rect.origin.y*e.scale}px`,width:`${Dt.value?Dt.value.width:we.value}px`,height:`${Dt.value?Dt.value.height:Ge.value}px`,pointerEvents:"none",zIndex:e.zIndex,...Dt.value?{transform:Dt.value.matrix,transformOrigin:"0 0"}:{}})),nn=P(()=>({...Ye.value,...e.blendMode?{mixBlendMode:e.blendMode}:{},...e.style})),xn=P(()=>Ye.value),Ur=P(()=>({position:"absolute",left:`${Le.value}px`,top:`${Ke.value}px`,width:`${Oe.value}px`,height:`${k.value}px`,transform:H.value!==0?`rotate(${H.value}deg)`:void 0,transformOrigin:Xe.value,pointerEvents:e.isEditing?"auto":"none"})),lo=P(()=>({position:"absolute",left:`${Le.value}px`,top:`${Ke.value}px`,width:`${Oe.value}px`,height:`${k.value}px`,transform:H.value!==0?`rotate(${H.value}deg)`:void 0,transformOrigin:Xe.value,outline:D.value?`${_.value}px ${F.value} ${f.value}`:"none",outlineOffset:D.value?`${y.value}px`:"0px",pointerEvents:e.isSelected&&!e.isMultiSelected&&!e.isEditing?"auto":"none",touchAction:"none",cursor:e.isSelected&&ee.value?"move":"default"})),ii=P(()=>({position:"absolute",left:`${Kt.value-Ze.value/2}px`,top:`${dt.value}px`,width:`${Ze.value}px`,height:"1px",backgroundColor:l.value,opacity:.35,pointerEvents:"none"})),ol=P(()=>({position:"absolute",left:`${Kt.value}px`,top:`${dt.value-Ze.value/2}px`,width:"1px",height:`${Ze.value}px`,backgroundColor:l.value,opacity:.35,pointerEvents:"none"})),si=P(()=>({position:"absolute",left:`${Kt.value-Ze.value/2}px`,top:`${dt.value}px`,width:`${Ze.value}px`,height:"1px",transformOrigin:"center center",transform:`rotate(${H.value}deg)`,backgroundColor:l.value,opacity:.8,pointerEvents:"none"})),co=P(()=>{var X;return{...((X=re.value)==null?void 0:X.connector.style)??{},backgroundColor:l.value,opacity:L.value?0:1}}),uo=P(()=>{var X;return{...((X=re.value)==null?void 0:X.handle.style)??{},backgroundColor:s.value,border:`${h.value}px ${g.value} ${p.value}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:L.value?0:1}}),Jo=P(()=>{if(!re.value)return{};const{style:X,...Ne}=re.value.handle;return Ne}),xo=P(()=>re.value?{...re.value.handle,backgroundColor:s.value,iconColor:c.value,connectorStyle:co.value,showConnector:u.value,opacity:L.value?0:1,border:{color:p.value,width:h.value,style:g.value}}:{}),rl=P(()=>({position:"fixed",left:T.value?`${T.value.x+16}px`:"0",top:T.value?`${T.value.y-16}px`:"0",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"})),Cn=ma();return(X,Ne)=>{var Xt;return v(),C("div",{"data-no-interaction":"",style:Gt},[m("div",{style:Z(nn.value)},[m("div",{style:Z(Ur.value)},[$e(X.$slots,"default",{annotation:Ut.value,appearanceActive:gt.value}),(Xt=t.appearance)!=null&&Xt.normal?(v(),he(Ky,{key:0,appearance:t.appearance.normal,style:Z({display:gt.value?"block":"none"})},null,8,["appearance","style"])):ae("",!0)],4)],4),m("div",{style:Z(xn.value)},[L.value?(v(),C(pe,{key:0},[m("div",{style:Z(ii.value)},null,4),m("div",{style:Z(ol.value)},null,4),m("div",{style:Z(si.value)},null,4)],64)):ae("",!0),t.isSelected&&_e.value&&I(re)?(v(),C("div",{key:1,onPointerenter:Ne[0]||(Ne[0]=Pt=>q.value=!0),onPointerleave:Ne[1]||(Ne[1]=Pt=>{q.value=!1,T.value=null}),onPointermove:De,style:Gt},[u.value?(v(),C("div",{key:0,style:Z(co.value)},null,4)):ae("",!0),I(Cn)["rotation-handle"]?$e(X.$slots,"rotation-handle",zt(xe({key:1},xo.value)),()=>[m("div",xe(Jo.value,{style:uo.value}),[(v(),C("svg",{width:Ft.value,height:Ft.value,viewBox:"0 0 24 24",fill:"none",stroke:c.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...Ne[2]||(Ne[2]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,Jy))],16)]):(v(),C("div",xe({key:2},Jo.value,{style:uo.value}),[(v(),C("svg",{width:Ft.value,height:Ft.value,viewBox:"0 0 24 24",fill:"none",stroke:c.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...Ne[3]||(Ne[3]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,ev))],16))],32)):ae("",!0),m("div",xe({...ee.value&&t.isSelected?I(Y):{},...I(Fe)},{style:lo.value}),[t.isSelected&&ge.value&&!L.value?(v(!0),C(pe,{key:0},tt(I(be),({key:Pt,style:st,...qe})=>(v(),C(pe,{key:Pt},[I(Cn)["resize-handle"]?$e(X.$slots,"resize-handle",xe({key:0,ref_for:!0},{key:Pt,style:st,...qe,backgroundColor:n.value}),()=>[m("div",xe({ref_for:!0},qe,{style:[st,{backgroundColor:n.value}]}),null,16)]):(v(),C("div",xe({key:1,ref_for:!0},qe,{style:[st,{backgroundColor:n.value}]}),null,16))],64))),128)):ae("",!0),t.isSelected&&I(J).canModifyAnnotations&&!t.isMultiSelected&&!L.value&&I(B).length>0?(v(!0),C(pe,{key:1},tt(I(B),({key:Pt,style:st,...qe})=>(v(),C(pe,{key:Pt},[I(Cn)["vertex-handle"]?$e(X.$slots,"vertex-handle",xe({key:0,ref_for:!0},{key:Pt,style:st,...qe,backgroundColor:o.value}),()=>[m("div",xe({ref_for:!0},qe,{style:[st,{backgroundColor:o.value}]}),null,16)]):(v(),C("div",xe({key:1,ref_for:!0},qe,{style:[st,{backgroundColor:o.value}]}),null,16))],64))),128)):ae("",!0)],16)],4),S.value&&!L.value?(v(),he(I(Ir),{key:0,rect:R.value,rotation:t.rotation},{default:We(({rect:Pt,menuWrapperProps:st})=>[t.selectionMenu?(v(),he(Fn(j(Pt,st)),{key:0})):$e(X.$slots,"selection-menu",{key:1,context:N.value,selected:t.isSelected,rect:Pt,placement:$.value,menuWrapperProps:st})]),_:3},8,["rect","rotation"])):ae("",!0),(L.value||q.value)&&T.value?(v(),he(Ql,{key:1,to:"body"},[m("div",{style:Z(rl.value)},fe(se.value.toFixed(0))+"°",5)])):ae("",!0)])}}});function ni(t,e,n,o,r){switch(r){case 1:return{x:e,y:o-t};case 2:return{x:n-t,y:o-e};case 3:return{x:n-e,y:t};default:return{x:t,y:e}}}function nv(t,e,n){const o=t.object.flags??[],r=o.includes("noZoom"),a=o.includes("noRotate"),i=t.object.rect.origin.x*e,s=t.object.rect.origin.y*e,l=t.object.rect.size.width*(r?1:e),c=t.object.rect.size.height*(r?1:e);if(!a||n===0)return{left:i,top:s,right:i+l,bottom:s+c};const u=[ni(0,0,l,c,n),ni(l,0,l,c,n),ni(0,c,l,c,n),ni(l,c,l,c,n)];let d=1/0,p=1/0,h=-1/0,g=-1/0;for(const f of u)f.x<d&&(d=f.x),f.y<p&&(p=f.y),f.x>h&&(h=f.x),f.y>g&&(g=f.y);return{left:i+d,top:s+p,right:i+h,bottom:s+g}}const ov={key:0,"data-group-selection-box":"","data-no-interaction":""},rv=["width","height","stroke"],av=["width","height","stroke"],iv=ie({__name:"group-selection-box",props:{documentId:{},pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},selectedAnnotations:{},isDraggable:{type:Boolean},isResizable:{type:Boolean},isRotatable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},resizeUi:{},rotationUi:{},selectionOutlineColor:{default:"#007ACC"},outlineOffset:{default:2},selectionOutline:{},zIndex:{default:100},groupSelectionMenu:{}},setup(t){const e=t,n=ma(),{plugin:o}=ti(),r=ms(()=>e.documentId),a=ln(null),i=Q(!1),s=Q(!1),l=Q(null),c=Q(null),u=Q(!1),d=P(()=>r.value.canModifyAnnotations&&e.isDraggable),p=P(()=>r.value.canModifyAnnotations&&e.isResizable),h=P(()=>r.value.canModifyAnnotations&&e.isRotatable),g=P(()=>{var k;return((k=e.resizeUi)==null?void 0:k.color)??"#007ACC"}),f=P(()=>{var k;return((k=e.resizeUi)==null?void 0:k.size)??12}),F=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.size)??32}),_=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.color)??"white"}),y=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.connectorColor)??"#007ACC"}),E=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.iconColor)??"#007ACC"}),A=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.showConnector)??!1}),T=P(()=>{var k;return(k=e.rotationUi)==null?void 0:k.margin}),q=P(()=>{var k,ye;return((ye=(k=e.rotationUi)==null?void 0:k.border)==null?void 0:ye.color)??"#007ACC"}),w=P(()=>{var k,ye;return((ye=(k=e.rotationUi)==null?void 0:k.border)==null?void 0:ye.width)??1}),G=P(()=>{var k,ye;return((ye=(k=e.rotationUi)==null?void 0:k.border)==null?void 0:ye.style)??"solid"}),W=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.color)??e.selectionOutlineColor??"#007ACC"}),J=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.style)??"dashed"}),ue=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.width)??2}),ce=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.offset)??e.outlineOffset??2}),ee=P(()=>l.value??0),ge=P(()=>l.value!==null),_e=P(()=>{const k=ee.value;return Number.isFinite(k)?Math.round(k*10)/10:0}),Ee=P(()=>Math.round(F.value*.6)),Te=P(()=>{const k=e.selectedAnnotations.map(ye=>ye.object.rect);return oF(k)}),oe=ln(Te.value);Se(()=>Te.value,k=>{!i.value&&!s.value&&(oe.value=k)},{immediate:!0}),Se(()=>o.value,(k,ye,Le)=>{if(!k)return;const Ke=k.onRotateChange(Xe=>{Xe.documentId===e.documentId&&(Xe.type==="end"||Xe.type==="cancel")&&(l.value=null)});Le(Ke)},{immediate:!0});const He=P(()=>{let k=1/0,ye=1/0,Le=-1/0,Ke=-1/0;for(const Ft of e.selectedAnnotations){const gt=nv(Ft,e.scale,e.rotation);gt.left<k&&(k=gt.left),gt.top<ye&&(ye=gt.top),gt.right>Le&&(Le=gt.right),gt.bottom>Ke&&(Ke=gt.bottom)}const Xe=Te.value,Kt=Xe.origin.x*e.scale,dt=Xe.origin.y*e.scale,Ze=(Xe.origin.x+Xe.size.width)*e.scale,Dt=(Xe.origin.y+Xe.size.height)*e.scale;return{left:k-Kt,top:ye-dt,right:Le-Ze,bottom:Ke-Dt}}),ft=P(()=>oe.value.origin.x*e.scale+He.value.left),Ve=P(()=>oe.value.origin.y*e.scale+He.value.top),O=P(()=>oe.value.size.width*e.scale+(He.value.right-He.value.left)),H=P(()=>oe.value.size.height*e.scale+(He.value.bottom-He.value.top)),V=P(()=>O.value/2),se=P(()=>H.value/2),L=P(()=>Math.max(300,Math.max(O.value,H.value)+80)),de={display:"contents"},Pe=P(()=>({position:"absolute",left:`${ft.value}px`,top:`${Ve.value}px`,width:`${O.value}px`,height:`${H.value}px`,pointerEvents:"none",zIndex:e.zIndex})),Re=P(()=>({position:"absolute",left:0,top:0,width:`${O.value}px`,height:`${H.value}px`,outline:ge.value?"none":`${ue.value}px ${J.value} ${W.value}`,outlineOffset:`${ce.value-1}px`,cursor:d.value?"move":"default",touchAction:"none",pointerEvents:"auto"})),vt=P(()=>({position:"absolute",left:`${V.value-L.value/2}px`,top:`${se.value}px`,width:`${L.value}px`,height:"1px",backgroundColor:g.value,opacity:.35,pointerEvents:"none"})),Ut=P(()=>({position:"absolute",left:`${V.value}px`,top:`${se.value-L.value/2}px`,width:"1px",height:`${L.value}px`,backgroundColor:g.value,opacity:.35,pointerEvents:"none"})),D=P(()=>({position:"absolute",left:`${V.value-L.value/2}px`,top:`${se.value}px`,width:`${L.value}px`,height:"1px",transformOrigin:"center center",transform:`rotate(${ee.value}deg)`,backgroundColor:g.value,opacity:.8,pointerEvents:"none"})),S=P(()=>{var k;return{...((k=Oe.value)==null?void 0:k.connector.style)??{},backgroundColor:y.value,opacity:ge.value?0:1}}),R=P(()=>{var k;return{...((k=Oe.value)==null?void 0:k.handle.style)??{},backgroundColor:_.value,border:`${w.value}px ${G.value} ${q.value}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:ge.value?0:1}}),N=P(()=>{if(!Oe.value)return{};const{style:k,...ye}=Oe.value.handle;return ye}),$=P(()=>Oe.value?{...Oe.value.handle,backgroundColor:_.value,iconColor:E.value,connectorStyle:S.value,showConnector:A.value,opacity:ge.value?0:1,border:{color:q.value,width:w.value,style:G.value}}:{}),j=P(()=>({position:"fixed",left:c.value?`${c.value.x+16}px`:"0",top:c.value?`${c.value.y-16}px`:"0",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"})),ne=P(()=>({origin:{x:ft.value,y:Ve.value},size:{width:O.value,height:H.value}})),K=P(()=>({type:"group",annotations:e.selectedAnnotations,pageIndex:e.pageIndex})),Y=P(()=>{const k=((ee.value+e.rotation*90)%360+360)%360;return{suggestTop:h.value&&k>90&&k<270}}),B=P(()=>e.groupSelectionMenu||n["group-selection-menu"]),be=(k,ye)=>e.groupSelectionMenu?e.groupSelectionMenu({rect:k,menuWrapperProps:ye,selected:!0,placement:Y.value,context:K.value}):null,re=k=>{ge.value||(c.value={x:k.clientX,y:k.clientY})},Fe=P(()=>oe.value),De=P(()=>({minWidth:20,minHeight:20,boundingBox:{width:e.pageWidth,height:e.pageHeight}})),{dragProps:we,resize:Ge,rotation:Oe}=wd({controller:{element:Fe,vertices:P(()=>[]),constraints:De,maintainAspectRatio:P(()=>e.lockAspectRatio),pageRotation:P(()=>e.rotation),scale:P(()=>e.scale),enabled:P(()=>!0),onUpdate:k=>{var ye,Le,Ke,Xe,Kt,dt;if(!((ye=k.transformData)!=null&&ye.type)||!o.value)return;const Ze=o.value,Dt=k.transformData.type,Ft=Dt==="move",gt=Dt==="resize";if(Ft&&!d.value)return;if(k.state==="start"&&(a.value=Te.value,Ft?(i.value=!0,Ze.startDrag(e.documentId,{annotationIds:e.selectedAnnotations.map(Ye=>Ye.object.id),pageSize:{width:e.pageWidth,height:e.pageHeight}})):gt&&(s.value=!0,Ze.startResize(e.documentId,{annotationIds:e.selectedAnnotations.map(Ye=>Ye.object.id),pageSize:{width:e.pageWidth,height:e.pageHeight},resizeHandle:((Le=k.transformData.metadata)==null?void 0:Le.handle)??"se"}))),Dt==="rotate"){if(!e.isRotatable)return;const Ye=e.selectedAnnotations.map(Ur=>Ur.object.id),nn=((Ke=k.transformData.metadata)==null?void 0:Ke.rotationAngle)??0,xn=(Xe=k.transformData.metadata)==null?void 0:Xe.cursorPosition;xn&&(c.value={x:xn.clientX,y:xn.clientY}),k.state==="start"?(l.value=nn,Ze.startRotation(e.documentId,{annotationIds:Ye,cursorAngle:nn,rotationCenter:(Kt=k.transformData.metadata)==null?void 0:Kt.rotationCenter})):k.state==="move"?(l.value=nn,Ze.updateRotation(e.documentId,nn,(dt=k.transformData.metadata)==null?void 0:dt.rotationDelta)):k.state==="end"&&(l.value=null,c.value=null,Ze.commitRotation(e.documentId));return}const Gt=a.value??Te.value;if(Ft&&k.transformData.changes.rect){const Ye=k.transformData.changes.rect,nn={x:Ye.origin.x-Gt.origin.x,y:Ye.origin.y-Gt.origin.y},xn=Ze.updateDrag(e.documentId,nn);oe.value={...Gt,origin:{x:Gt.origin.x+xn.x,y:Gt.origin.y+xn.y}}}else if(gt&&k.transformData.changes.rect){const Ye=k.transformData.changes.rect;Ze.updateResize(e.documentId,Ye),oe.value=Ye}k.state==="end"&&(a.value=null,Ft&&i.value?(i.value=!1,Ze.commitDrag(e.documentId)):gt&&s.value&&(s.value=!1,Ze.commitResize(e.documentId)))}},resizeUI:{handleSize:f.value,spacing:ce.value,offsetMode:"outside",includeSides:!e.lockAspectRatio,zIndex:e.zIndex+1},vertexUI:{vertexSize:0,zIndex:e.zIndex},rotationUI:{handleSize:F.value,margin:T.value,zIndex:e.zIndex+2,showConnector:A.value},includeVertices:!1,includeRotation:h,currentRotation:P(()=>l.value??0)});return(k,ye)=>t.selectedAnnotations.length>=2?(v(),C("div",ov,[m("div",{style:Z(Pe.value)},[ge.value?(v(),C(pe,{key:0},[m("div",{style:Z(vt.value)},null,4),m("div",{style:Z(Ut.value)},null,4),m("div",{style:Z(D.value)},null,4)],64)):ae("",!0),h.value&&I(Oe)?(v(),C("div",{key:1,onPointerenter:ye[0]||(ye[0]=Le=>u.value=!0),onPointerleave:ye[1]||(ye[1]=Le=>{u.value=!1,c.value=null}),onPointermove:re,style:de},[A.value?(v(),C("div",{key:0,style:Z(S.value)},null,4)):ae("",!0),I(n)["rotation-handle"]?$e(k.$slots,"rotation-handle",zt(xe({key:1},$.value)),()=>[m("div",xe(N.value,{style:R.value}),[(v(),C("svg",{width:Ee.value,height:Ee.value,viewBox:"0 0 24 24",fill:"none",stroke:E.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...ye[2]||(ye[2]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,rv))],16)]):(v(),C("div",xe({key:2},N.value,{style:R.value}),[(v(),C("svg",{width:Ee.value,height:Ee.value,viewBox:"0 0 24 24",fill:"none",stroke:E.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...ye[3]||(ye[3]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,av))],16))],32)):ae("",!0),m("div",xe(d.value?I(we):{onPointerdown:Le=>Le.stopPropagation()},{style:Re.value}),[p.value&&!ge.value?(v(!0),C(pe,{key:0},tt(I(Ge),({key:Le,style:Ke,...Xe})=>(v(),C(pe,{key:Le},[I(n)["resize-handle"]?$e(k.$slots,"resize-handle",xe({key:0,ref_for:!0},{key:Le,style:Ke,...Xe,backgroundColor:g.value}),()=>[m("div",xe({ref_for:!0},Xe,{style:[Ke,{backgroundColor:g.value}]}),null,16)]):(v(),C("div",xe({key:1,ref_for:!0},Xe,{style:[Ke,{backgroundColor:g.value}]}),null,16))],64))),128)):ae("",!0)],16)],4),B.value&&!ge.value?(v(),he(I(Ir),{key:0,rect:ne.value,rotation:t.rotation},{default:We(({rect:Le,menuWrapperProps:Ke})=>[t.groupSelectionMenu?(v(),he(Fn(be(Le,Ke)),{key:0})):$e(k.$slots,"group-selection-menu",{key:1,context:K.value,selected:!0,rect:Le,placement:Y.value,menuWrapperProps:Ke})]),_:3},8,["rect","rotation"])):ae("",!0),(ge.value||u.value)&&c.value?(v(),he(Ql,{key:1,to:"body"},[m("div",{style:Z(j.value)},fe(_e.value.toFixed(0))+"°",5)])):ae("",!0)])):ae("",!0)}}),Rp=Symbol("AnnotationRendererRegistry");function sv(){const t=ln([]);return{register(e){const n=new Set(e.map(o=>o.id));return t.value=[...t.value.filter(o=>!n.has(o.id)),...e],()=>{t.value=t.value.filter(o=>!e.some(r=>r.id===o.id))}},getAll(){return t.value}}}function lv(){const t=sv();return da(Rp,t),t}function zs(){return Po(Rp,null)}function cv(t){const e=zs();if(!e)return;const n=e.register(t);$o(n)}function yt(t){return{id:t.id,matches:t.matches,component:dr(t.component),vertexConfig:t.vertexConfig,zIndex:t.zIndex,defaultBlendMode:t.defaultBlendMode,containerStyle:t.containerStyle,interactionDefaults:t.interactionDefaults,useAppearanceStream:t.useAppearanceStream,isDraggable:t.isDraggable,onDoubleClick:t.onDoubleClick,selectOverride:t.selectOverride,hideSelectionMenu:t.hideSelectionMenu,renderPreview:t.renderPreview?dr(t.renderPreview):void 0,hiddenWhenLocked:t.hiddenWhenLocked,renderLocked:t.renderLocked?dr(t.renderLocked):void 0}}const uv=ie({...{inheritAttrs:!1},__name:"link-locked",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){const e=t,{provides:n}=Bn(),o=()=>{const r=e.annotation.object.target;!r||!n.value||n.value.forDocument(e.documentId).navigateTarget(r)};return(r,a)=>(v(),C("div",{onClick:o,style:{width:"100%",height:"100%",cursor:"pointer",pointerEvents:"auto"}}))}}),dv=ie({__name:"link-preview",props:{data:{},bounds:{},scale:{}},setup(t){const e=t,n=P(()=>({position:"absolute",left:0,top:0,width:`${e.bounds.size.width*e.scale}px`,height:`${e.bounds.size.height*e.scale}px`,borderBottom:`${e.data.strokeWidth*e.scale}px solid ${e.data.strokeColor}`,backgroundColor:"rgba(0, 0, 255, 0.05)",boxSizing:"border-box"}));return(o,r)=>(v(),C("div",{style:Z(n.value)},null,4))}}),pv=["width","height","viewBox"],hv=["d","stroke-width"],gv=["d","opacity"],wp=ie({...{inheritAttrs:!1},__name:"ink",props:{isSelected:{type:Boolean},strokeColor:{},opacity:{default:1},strokeWidth:{},inkList:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const n=t,o=P(()=>n.strokeColor??"#000000"),r=P(()=>n.inkList.map(({points:l})=>{let c="";return l.forEach(({x:u,y:d},p)=>{const h=u-n.rect.origin.x,g=d-n.rect.origin.y;c+=(p===0?"M":"L")+`${h} ${g} `}),c.trim()})),a=P(()=>n.rect.size.width*n.scale),i=P(()=>n.rect.size.height*n.scale),s=P(()=>Math.max(n.strokeWidth,20/n.scale));return(l,c)=>(v(),C("svg",{style:Z({position:"absolute",width:`${a.value}px`,height:`${i.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:a.value,height:i.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[(v(!0),C(pe,null,tt(r.value,(u,d)=>(v(),C("path",{key:`hit-${d}`,d:u,fill:"none",stroke:"transparent","stroke-width":s.value,onPointerdown:c[0]||(c[0]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visibleStroke":"none",strokeLinecap:"round",strokeLinejoin:"round"})},null,44,hv))),128)),t.appearanceActive?ae("",!0):(v(!0),C(pe,{key:0},tt(r.value,(u,d)=>(v(),C("path",{key:`vis-${d}`,d:u,fill:"none",opacity:t.opacity,style:Z({pointerEvents:"none",stroke:o.value,strokeWidth:t.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round"})},null,12,gv))),128))],12,pv))}}),fv=ie({__name:"ink-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(wp,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),mv=["width","height","viewBox"],Pv=["d","stroke-width"],Fv=["x","y","width","height","stroke-width"],bv=["d","fill","opacity"],_v=["x","y","width","height","fill","opacity"],Op=ie({...{inheritAttrs:!1},__name:"square",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1},cloudyBorderIntensity:{},rectangleDifferences:{}},setup(t){const n=t,o=P(()=>(n.cloudyBorderIntensity??0)>0),r=P(()=>{const c=n.rect.size.width,u=n.rect.size.height,d=Math.max(c-n.strokeWidth,0),p=Math.max(u-n.strokeWidth,0);return{width:d,height:p,x:n.strokeWidth/2,y:n.strokeWidth/2}}),a=P(()=>o.value?n_({width:n.rect.size.width,height:n.rect.size.height},n.rectangleDifferences,n.cloudyBorderIntensity,n.strokeWidth):null),i=P(()=>n.rect.size.width*n.scale),s=P(()=>n.rect.size.height*n.scale),l=P(()=>Math.max(n.strokeWidth,20/n.scale));return(c,u)=>{var d;return v(),C("svg",{style:Z({position:"absolute",width:i.value,height:s.value,pointerEvents:"none",zIndex:2}),width:i.value,height:s.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`,overflow:"visible"},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[0]||(u[0]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,Pv)):(v(),C("rect",{key:1,x:r.value.x,y:r.value.y,width:r.value.width,height:r.value.height,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[1]||(u[1]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,Fv)),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,strokeLinejoin:"round"})},null,12,bv)):(v(),C("rect",{key:1,x:r.value.x,y:r.value.y,width:r.value.width,height:r.value.height,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,_v))],64))],12,mv)}}}),yv=ie({__name:"square-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Op,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),vv=["width","height","viewBox"],Dv=["d","stroke-width"],Sv=["cx","cy","rx","ry","stroke-width"],Ev=["d","fill","opacity"],Av=["cx","cy","rx","ry","fill","opacity"],kp=ie({...{inheritAttrs:!1},__name:"circle",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1},cloudyBorderIntensity:{},rectangleDifferences:{}},setup(t){const n=t,o=P(()=>(n.cloudyBorderIntensity??0)>0),r=P(()=>{const c=n.rect.size.width,u=n.rect.size.height,d=Math.max(c-n.strokeWidth,0),p=Math.max(u-n.strokeWidth,0);return{width:c,height:u,cx:n.strokeWidth/2+d/2,cy:n.strokeWidth/2+p/2,rx:d/2,ry:p/2}}),a=P(()=>o.value?o_({width:n.rect.size.width,height:n.rect.size.height},n.rectangleDifferences,n.cloudyBorderIntensity,n.strokeWidth):null),i=P(()=>r.value.width*n.scale),s=P(()=>r.value.height*n.scale),l=P(()=>Math.max(n.strokeWidth,20/n.scale));return(c,u)=>{var d;return v(),C("svg",{style:Z({position:"absolute",width:i.value,height:s.value,pointerEvents:"none",zIndex:2}),width:i.value,height:s.value,viewBox:`0 0 ${r.value.width} ${r.value.height}`,overflow:"visible"},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[0]||(u[0]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,Dv)):(v(),C("ellipse",{key:1,cx:r.value.cx,cy:r.value.cy,rx:r.value.rx,ry:r.value.ry,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[1]||(u[1]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,Sv)),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,strokeLinejoin:"round"})},null,12,Ev)):(v(),C("ellipse",{key:1,cx:r.value.cx,cy:r.value.cy,rx:r.value.rx,ry:r.value.ry,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,Av))],64))],12,vv)}}}),xv=ie({__name:"circle-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(kp,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Cv=["width","height","viewBox"],Tv=["x1","y1","x2","y2","stroke-width"],Mv=["d","transform","stroke-width"],Rv=["d","transform","stroke-width"],wv=["x1","y1","x2","y2","opacity"],Ov=["d","transform","stroke","fill"],kv=["d","transform","stroke","fill"],Ip=ie({...{inheritAttrs:!1},__name:"line",props:{color:{default:"transparent"},opacity:{default:1},strokeWidth:{},strokeColor:{default:"#000000"},strokeStyle:{default:rt.SOLID},strokeDashArray:{},rect:{},linePoints:{},lineEndings:{},scale:{},onClick:{},isSelected:{type:Boolean},appearanceActive:{type:Boolean,default:!1}},setup(t){const n=t,o=P(()=>({x1:n.linePoints.start.x-n.rect.origin.x,y1:n.linePoints.start.y-n.rect.origin.y,x2:n.linePoints.end.x-n.rect.origin.x,y2:n.linePoints.end.y-n.rect.origin.y})),r=P(()=>{var l,c;const{x1:u,y1:d,x2:p,y2:h}=o.value,g=Math.atan2(h-d,p-u);return{start:qa.createEnding((l=n.lineEndings)==null?void 0:l.start,n.strokeWidth,g+Math.PI,u,d),end:qa.createEnding((c=n.lineEndings)==null?void 0:c.end,n.strokeWidth,g,p,h)}}),a=P(()=>n.rect.size.width*n.scale),i=P(()=>n.rect.size.height*n.scale),s=P(()=>Math.max(n.strokeWidth,20/n.scale));return(l,c)=>{var u,d,p;return v(),C("svg",{style:Z({position:"absolute",width:`${a.value}px`,height:`${i.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:a.value,height:i.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[m("line",{x1:o.value.x1,y1:o.value.y1,x2:o.value.x2,y2:o.value.y2,stroke:"transparent","stroke-width":s.value,onPointerdown:c[0]||(c[0]=(...h)=>t.onClick&&t.onClick(...h)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,Tv),r.value.start?(v(),C("path",{key:0,d:r.value.start.d,transform:r.value.start.transform,fill:"transparent",stroke:"transparent","stroke-width":s.value,onPointerdown:c[1]||(c[1]=(...h)=>t.onClick&&t.onClick(...h)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":r.value.start.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,Mv)):ae("",!0),r.value.end?(v(),C("path",{key:1,d:r.value.end.d,transform:r.value.end.transform,fill:"transparent",stroke:"transparent","stroke-width":s.value,onPointerdown:c[2]||(c[2]=(...h)=>t.onClick&&t.onClick(...h)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":r.value.end.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,Rv)):ae("",!0),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[m("line",{x1:o.value.x1,y1:o.value.y1,x2:o.value.x2,y2:o.value.y2,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(u=t.strokeDashArray)==null?void 0:u.join(",")}})},null,12,wv),r.value.start?(v(),C("path",{key:0,d:r.value.start.d,transform:r.value.start.transform,stroke:t.strokeColor,fill:r.value.start.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,Ov)):ae("",!0),r.value.end?(v(),C("path",{key:1,d:r.value.end.d,transform:r.value.end.transform,stroke:t.strokeColor,fill:r.value.end.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(p=t.strokeDashArray)==null?void 0:p.join(",")}})},null,12,kv)):ae("",!0)],64))],12,Cv)}}}),Iv=ie({__name:"line-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Ip,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Gv=["width","height","viewBox"],Lv=["d","stroke-width"],$v=["d","transform","stroke-width"],Nv=["d","transform","stroke-width"],jv=["d","opacity"],Uv=["d","transform","stroke","fill"],Bv=["d","transform","stroke","fill"],Gp=ie({...{inheritAttrs:!1},__name:"polyline",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},scale:{},isSelected:{type:Boolean},onClick:{},lineEndings:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const n=t,o=P(()=>n.vertices.map(({x:c,y:u})=>({x:c-n.rect.origin.x,y:u-n.rect.origin.y}))),r=P(()=>{if(o.value.length===0)return"";const[c,...u]=o.value;return(`M ${c.x} ${c.y} `+u.map(d=>`L ${d.x} ${d.y} `).join("")).trim()}),a=P(()=>{var c,u;if(o.value.length<2)return{start:null,end:null};const d=(g,f)=>Math.atan2(f.y-g.y,f.x-g.x),p=d(o.value[0],o.value[1]),h=d(o.value[o.value.length-2],o.value[o.value.length-1]);return{start:qa.createEnding((c=n.lineEndings)==null?void 0:c.start,n.strokeWidth,p+Math.PI,o.value[0].x,o.value[0].y),end:qa.createEnding((u=n.lineEndings)==null?void 0:u.end,n.strokeWidth,h,o.value[o.value.length-1].x,o.value[o.value.length-1].y)}}),i=P(()=>n.rect.size.width*n.scale),s=P(()=>n.rect.size.height*n.scale),l=P(()=>Math.max(n.strokeWidth,20/n.scale));return(c,u)=>{var d,p,h;return v(),C("svg",{style:Z({position:"absolute",width:`${i.value}px`,height:`${s.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:i.value,height:s.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[m("path",{d:r.value,fill:"none",stroke:"transparent","stroke-width":l.value,onPointerdown:u[0]||(u[0]=(...g)=>t.onClick&&t.onClick(...g)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visibleStroke":"none",strokeLinecap:"butt",strokeLinejoin:"miter"})},null,44,Lv),a.value.start?(v(),C("path",{key:0,d:a.value.start.d,transform:a.value.start.transform,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[1]||(u[1]=(...g)=>t.onClick&&t.onClick(...g)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":a.value.start.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,$v)):ae("",!0),a.value.end?(v(),C("path",{key:1,d:a.value.end.d,transform:a.value.end.transform,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[2]||(u[2]=(...g)=>t.onClick&&t.onClick(...g)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":a.value.end.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,Nv)):ae("",!0),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[m("path",{d:r.value,opacity:t.opacity,style:Z({fill:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,jv),a.value.start?(v(),C("path",{key:0,d:a.value.start.d,transform:a.value.start.transform,stroke:t.strokeColor,fill:a.value.start.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(p=t.strokeDashArray)==null?void 0:p.join(",")}})},null,12,Uv)):ae("",!0),a.value.end?(v(),C("path",{key:1,d:a.value.end.d,transform:a.value.end.transform,stroke:t.strokeColor,fill:a.value.end.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(h=t.strokeDashArray)==null?void 0:h.join(",")}})},null,12,Bv)):ae("",!0)],64))],12,Gv)}}}),zv=ie({__name:"polyline-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Gp,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Wv=["width","height","viewBox"],Hv=["d","stroke-width"],Vv=["d","opacity"],Yv=["d","opacity"],qv=["d"],Kv=["x","y","width","height","fill","stroke","stroke-width"],Lp=ie({...{inheritAttrs:!1},__name:"polygon",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},scale:{},isSelected:{type:Boolean},onClick:{},currentVertex:{},handleSize:{default:14},appearanceActive:{type:Boolean,default:!1},cloudyBorderIntensity:{}},setup(t){const n=t,o=P(()=>(n.cloudyBorderIntensity??0)>0),r=P(()=>n.currentVertex?[...n.vertices,n.currentVertex]:n.vertices),a=P(()=>r.value.map(({x:p,y:h})=>({x:p-n.rect.origin.x,y:h-n.rect.origin.y}))),i=P(()=>{if(!a.value.length)return"";const[p,...h]=a.value,g=!!n.currentVertex;return(`M ${p.x} ${p.y} `+h.map(f=>`L ${f.x} ${f.y}`).join(" ")+(g?"":" Z")).trim()}),s=P(()=>!o.value||r.value.length<3?null:r_(r.value,n.rect.origin,n.cloudyBorderIntensity,n.strokeWidth)),l=P(()=>n.currentVertex&&n.vertices.length>0),c=P(()=>n.rect.size.width*n.scale),u=P(()=>n.rect.size.height*n.scale),d=P(()=>Math.max(n.strokeWidth,20/n.scale));return(p,h)=>{var g;return v(),C("svg",{style:Z({position:"absolute",width:`${c.value}px`,height:`${u.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:c.value,height:u.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[m("path",{d:o.value&&s.value?s.value.path:i.value,fill:"transparent",stroke:"transparent","stroke-width":d.value,onPointerdown:h[0]||(h[0]=(...f)=>t.onClick&&t.onClick(...f)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none",strokeLinecap:"butt",strokeLinejoin:"miter"})},null,44,Hv),t.appearanceActive?ae("",!0):(v(),C(pe,{key:0},[o.value&&s.value?(v(),C("path",{key:0,d:s.value.path,opacity:t.opacity,style:Z({fill:t.color,stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,pointerEvents:"none",strokeLinejoin:"round"})},null,12,Vv)):(v(),C(pe,{key:1},[m("path",{d:i.value,opacity:t.opacity,style:Z({fill:t.currentVertex?"none":t.color,stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(g=t.strokeDashArray)==null?void 0:g.join(",")}})},null,12,Yv),l.value&&a.value.length>1?(v(),C("path",{key:0,d:`M ${a.value[a.value.length-1].x} ${a.value[a.value.length-1].y} L ${a.value[0].x} ${a.value[0].y}`,fill:"none",style:Z({stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeDasharray:"4,4",opacity:.7,pointerEvents:"none"})},null,12,qv)):ae("",!0),l.value&&a.value.length>=2?(v(),C("rect",{key:1,x:a.value[0].x-t.handleSize/t.scale/2,y:a.value[0].y-t.handleSize/t.scale/2,width:t.handleSize/t.scale,height:t.handleSize/t.scale,fill:t.strokeColor,opacity:.4,stroke:t.strokeColor,"stroke-width":t.strokeWidth/2,style:{"pointer-events":"none"}},null,8,Kv)):ae("",!0)],64))],64))],12,Wv)}}}),Xv=ie({__name:"polygon-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Lp,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Zv=["contenteditable"],Qv=ie({...{inheritAttrs:!1},__name:"free-text",props:{documentId:{},isSelected:{type:Boolean},isEditing:{type:Boolean},annotation:{},pageIndex:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=Q(null),o=Q(!1),{provides:r}=Bn(),a=P(()=>{var c;return((c=r.value)==null?void 0:c.forDocument(e.documentId))??null}),i=Qy(()=>e.annotation.object.fontSize*e.scale,()=>e.isEditing);Se(()=>e.isEditing,async c=>{var u,d;if(!c||(await ca(),!n.value))return;o.value=!0;const p=n.value;p.focus();const h=(u=a.value)==null?void 0:u.findToolForAnnotation(e.annotation.object),g=((d=h==null?void 0:h.defaults)==null?void 0:d.contents)!=null&&e.annotation.object.contents===h.defaults.contents,f=window.getSelection();if(f){const F=document.createRange();F.selectNodeContents(p),g||F.collapse(!1),f.removeAllRanges(),f.addRange(F)}},{immediate:!0});const s=()=>{o.value&&(o.value=!1,!(!a.value||!n.value)&&a.value.updateAnnotation(e.pageIndex,e.annotation.object.id,{contents:n.value.innerText.replace(/\u00A0/g," ")}))},l=P(()=>{const{object:c}=e.annotation,{needsComp:u,adjustedFontPx:d,scaleComp:p}=i.value,h=u?100/p:100;return{color:c.fontColor,fontSize:`${d}px`,...ns(c.fontFamily),textAlign:es(c.textAlign),flexDirection:"column",justifyContent:c.verticalAlign===Ar.Top?"flex-start":c.verticalAlign===Ar.Middle?"center":"flex-end",display:"flex",backgroundColor:c.color??c.backgroundColor,opacity:c.opacity,width:u?`${h}%`:"100%",height:u?`${h}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:e.isEditing?"text":e.onClick?"pointer":"default",outline:"none",transform:u?`scale(${p})`:void 0,transformOrigin:"top left"}});return(c,u)=>(v(),C("div",{style:Z({position:"absolute",width:`${t.annotation.object.rect.size.width*t.scale}px`,height:`${t.annotation.object.rect.size.height*t.scale}px`,cursor:t.isSelected&&!t.isEditing?"move":"default",pointerEvents:t.onClick?t.isSelected&&!t.isEditing?"none":"auto":"none",zIndex:2,opacity:t.appearanceActive?0:1}),onPointerdown:u[0]||(u[0]=(...d)=>t.onClick&&t.onClick(...d))},[m("span",{ref_key:"editorRef",ref:n,onBlur:s,tabindex:"0",style:Z(l.value),contenteditable:t.isEditing},fe(t.annotation.object.contents),45,Zv)],36))}}),Jv=ie({__name:"free-text-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Qv,{documentId:t.documentId,isSelected:t.isSelected,isEditing:t.isEditing,annotation:{...t.annotation,object:t.currentObject},pageIndex:t.pageIndex,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive},null,8,["documentId","isSelected","isEditing","annotation","pageIndex","scale","onClick","appearanceActive"]))}}),eD=["src"],tD=ie({__name:"render-annotation",props:{documentId:{},pageIndex:{},annotation:{},scaleFactor:{default:1},unrotated:{type:Boolean,default:!1},style:{}},setup(t){const e=t,{provides:n}=Bn(),o=Q(null),r=Q(null),a=Q(null),i=P(()=>e.annotation.id),s=P(()=>e.annotation.rect.size.width),l=P(()=>e.annotation.rect.size.height);Se(()=>[e.pageIndex,e.scaleFactor,e.unrotated,e.documentId,i.value,s.value,l.value,n.value],(u,d,p)=>{if(n.value){r.value&&(URL.revokeObjectURL(r.value),r.value=null);const h=n.value.forDocument(e.documentId).renderAnnotation({pageIndex:e.pageIndex,annotation:J_(e.annotation),options:{scaleFactor:e.scaleFactor,dpr:window.devicePixelRatio,unrotated:e.unrotated}});a.value=h,h.wait(g=>{const f=URL.createObjectURL(g);o.value=f,r.value=f},Yt),p(()=>{r.value?(URL.revokeObjectURL(r.value),r.value=null):h.abort({code:ve.Cancelled,message:"canceled render task"})})}},{immediate:!0}),$o(()=>{r.value&&(URL.revokeObjectURL(r.value),r.value=null),a.value&&a.value.abort({code:ve.Cancelled,message:"canceled render task on unmount"})});const c=()=>{r.value&&(URL.revokeObjectURL(r.value),r.value=null)};return(u,d)=>o.value?(v(),C("img",{key:0,src:o.value,onLoad:c,style:Z({width:"100%",height:"100%",display:"block",...t.style})},null,44,eD)):ae("",!0)}}),nD=ie({...{inheritAttrs:!1},__name:"stamp",props:{isSelected:{type:Boolean},annotation:{},documentId:{},pageIndex:{},scale:{},onClick:{type:Function}},setup(t){const e=t,n=P(()=>!!e.annotation.object.rotation&&!!e.annotation.object.unrotatedRect);return(o,r)=>(v(),C("div",{style:Z({position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:t.onClick?t.isSelected?"none":"auto":"none",cursor:t.onClick?"pointer":"default"}),onPointerdown:r[0]||(r[0]=(...a)=>t.onClick&&t.onClick(...a))},[je(tD,{documentId:t.documentId,pageIndex:t.pageIndex,annotation:{...t.annotation.object,id:t.annotation.object.id},scaleFactor:t.scale,unrotated:n.value},null,8,["documentId","pageIndex","annotation","scaleFactor","unrotated"])],36))}}),oD=ie({__name:"stamp-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(nD,{isSelected:t.isSelected,annotation:t.annotation,documentId:t.documentId,pageIndex:t.pageIndex,scale:t.scale,onClick:t.onClick},null,8,["isSelected","annotation","documentId","pageIndex","scale","onClick"]))}}),rD=["width","height","viewBox"],aD=["width","height"],iD=["y1","x2","y2","stroke","stroke-width","stroke-dasharray"],sD=["x","y","width","height","stroke","stroke-width","stroke-dasharray"],lD=ie({...{inheritAttrs:!1},__name:"link",props:{isSelected:{type:Boolean},strokeColor:{default:"#0000FF"},strokeWidth:{default:2},strokeStyle:{default:rt.UNDERLINE},strokeDashArray:{},rect:{},scale:{},onClick:{},hasIRT:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.rect.size.width),o=P(()=>e.rect.size.height),r=P(()=>n.value*e.scale),a=P(()=>o.value*e.scale),i=P(()=>{var u;if(e.strokeStyle===rt.DASHED)return((u=e.strokeDashArray)==null?void 0:u.join(","))??`${e.strokeWidth*3},${e.strokeWidth}`}),s=P(()=>e.strokeStyle===rt.UNDERLINE),l=P(()=>e.hasIRT||!e.onClick?"default":e.isSelected?"move":"pointer"),c=P(()=>e.hasIRT||!e.onClick||e.isSelected?"none":"visible");return(u,d)=>(v(),C("svg",{style:Z({position:"absolute",width:`${r.value}px`,height:`${a.value}px`,pointerEvents:"none",zIndex:2}),width:r.value,height:a.value,viewBox:`0 0 ${n.value} ${o.value}`},[m("rect",{x:0,y:0,width:n.value,height:o.value,fill:"transparent",onPointerdown:d[0]||(d[0]=p=>{var h;return t.hasIRT||(h=t.onClick)==null?void 0:h.call(t,p)}),style:Z({cursor:l.value,pointerEvents:c.value})},null,44,aD),s.value?(v(),C("line",{key:0,x1:1,y1:o.value-1,x2:n.value-1,y2:o.value-1,stroke:t.strokeColor,"stroke-width":t.strokeWidth,"stroke-dasharray":i.value,style:{"pointer-events":"none"}},null,8,iD)):(v(),C("rect",{key:1,x:t.strokeWidth/2,y:t.strokeWidth/2,width:Math.max(n.value-t.strokeWidth,0),height:Math.max(o.value-t.strokeWidth,0),fill:"transparent",stroke:t.strokeColor,"stroke-width":t.strokeWidth,"stroke-dasharray":i.value,style:{"pointer-events":"none"}},null,8,sD))],12,rD))}}),cD=ie({__name:"link-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(lD,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,hasIRT:!!t.currentObject.inReplyToId}),null,16,["isSelected","scale","onClick","hasIRT"]))}}),$p=ie({...{inheritAttrs:!1},__name:"highlight",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00");return(o,r)=>(v(!0),C(pe,null,tt(t.segmentRects,(a,i)=>(v(),C("div",{key:i,onPointerdown:r[0]||(r[0]=(...s)=>t.onClick&&t.onClick(...s)),style:Z({position:"absolute",left:`${(t.rect?a.origin.x-t.rect.origin.x:a.origin.x)*t.scale}px`,top:`${(t.rect?a.origin.y-t.rect.origin.y:a.origin.y)*t.scale}px`,width:`${a.size.width*t.scale}px`,height:`${a.size.height*t.scale}px`,background:t.appearanceActive?"transparent":n.value,opacity:t.appearanceActive?void 0:t.opacity,pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:void 0})},null,36))),128))}}),uD=ie({__name:"highlight-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he($p,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),Np=ie({...{inheritAttrs:!1},__name:"underline",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00"),o=P(()=>2*e.scale);return(r,a)=>(v(!0),C(pe,null,tt(t.segmentRects,(i,s)=>(v(),C("div",{key:s,onPointerdown:a[0]||(a[0]=(...l)=>t.onClick&&t.onClick(...l)),style:Z({position:"absolute",left:`${(t.rect?i.origin.x-t.rect.origin.x:i.origin.x)*t.scale}px`,top:`${(t.rect?i.origin.y-t.rect.origin.y:i.origin.y)*t.scale}px`,width:`${i.size.width*t.scale}px`,height:`${i.size.height*t.scale}px`,background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[t.appearanceActive?ae("",!0):(v(),C("div",{key:0,style:Z({position:"absolute",left:0,bottom:0,width:"100%",height:`${o.value}px`,background:n.value,opacity:t.opacity,pointerEvents:"none"})},null,4))],36))),128))}}),dD=ie({__name:"underline-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Np,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),jp=ie({...{inheritAttrs:!1},__name:"strikeout",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00"),o=P(()=>2*e.scale);return(r,a)=>(v(!0),C(pe,null,tt(t.segmentRects,(i,s)=>(v(),C("div",{key:s,onPointerdown:a[0]||(a[0]=(...l)=>t.onClick&&t.onClick(...l)),style:Z({position:"absolute",left:`${(t.rect?i.origin.x-t.rect.origin.x:i.origin.x)*t.scale}px`,top:`${(t.rect?i.origin.y-t.rect.origin.y:i.origin.y)*t.scale}px`,width:`${i.size.width*t.scale}px`,height:`${i.size.height*t.scale}px`,background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[t.appearanceActive?ae("",!0):(v(),C("div",{key:0,style:Z({position:"absolute",left:0,top:"50%",width:"100%",height:`${o.value}px`,background:n.value,opacity:t.opacity,transform:"translateY(-50%)",pointerEvents:"none"})},null,4))],36))),128))}}),pD=ie({__name:"strikeout-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(jp,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),Up=ie({...{inheritAttrs:!1},__name:"squiggly",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00"),o=P(()=>2*e.scale),r=P(()=>6*e.scale),a=P(()=>{const i=o.value,s=r.value,l=`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${i*2}" viewBox="0 0 ${s} ${i*2}">
20
+ **/let Hi;const Hc=typeof window<"u"&&window.trustedTypes;if(Hc)try{Hi=Hc.createPolicy("vue",{createHTML:t=>t})}catch{}const Vc=Hi?t=>Hi.createHTML(t):t=>t,DP="http://www.w3.org/2000/svg",SP="http://www.w3.org/1998/Math/MathML",Gn=typeof document<"u"?document:null,Yc=Gn&&Gn.createElement("template"),EP={insert:(t,e,n)=>{e.insertBefore(t,n||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,n,o)=>{const r=e==="svg"?Gn.createElementNS(DP,t):e==="mathml"?Gn.createElementNS(SP,t):n?Gn.createElement(t,{is:n}):Gn.createElement(t);return t==="select"&&o&&o.multiple!=null&&r.setAttribute("multiple",o.multiple),r},createText:t=>Gn.createTextNode(t),createComment:t=>Gn.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Gn.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,n,o,r,a){const i=n?n.previousSibling:e.lastChild;if(r&&(r===a||r.nextSibling))for(;e.insertBefore(r.cloneNode(!0),n),!(r===a||!(r=r.nextSibling)););else{Yc.innerHTML=Vc(o==="svg"?`<svg>${t}</svg>`:o==="mathml"?`<math>${t}</math>`:t);const s=Yc.content;if(o==="svg"||o==="mathml"){const l=s.firstChild;for(;l.firstChild;)s.appendChild(l.firstChild);s.removeChild(l)}e.insertBefore(s,n)}return[i?i.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}},AP=Symbol("_vtc");function xP(t,e,n){const o=t[AP];o&&(e=(e?[e,...o]:[...o]).join(" ")),e==null?t.removeAttribute("class"):n?t.setAttribute("class",e):t.className=e}const qc=Symbol("_vod"),CP=Symbol("_vsh"),TP=Symbol(""),MP=/(?:^|;)\s*display\s*:/;function RP(t,e,n){const o=t.style,r=ut(n);let a=!1;if(n&&!r){if(e)if(ut(e))for(const i of e.split(";")){const s=i.slice(0,i.indexOf(":")).trim();n[s]==null&&Aa(o,s,"")}else for(const i in e)n[i]==null&&Aa(o,i,"");for(const i in n)i==="display"&&(a=!0),Aa(o,i,n[i])}else if(r){if(e!==n){const i=o[TP];i&&(n+=";"+i),o.cssText=n,a=MP.test(n)}}else e&&t.removeAttribute("style");qc in t&&(t[qc]=a?o.display:"",t[CP]&&(o.display="none"))}const Kc=/\s*!important$/;function Aa(t,e,n){if(Ce(n))n.forEach(o=>Aa(t,e,o));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const o=wP(t,e);Kc.test(n)?t.setProperty(Yn(o),n.replace(Kc,""),"important"):t[o]=n}}const Xc=["Webkit","Moz","ms"],Vi={};function wP(t,e){const n=Vi[e];if(n)return n;let o=wt(e);if(o!=="filter"&&o in t)return Vi[e]=o;o=Xr(o);for(let r=0;r<Xc.length;r++){const a=Xc[r]+o;if(a in t)return Vi[e]=a}return e}const Zc="http://www.w3.org/1999/xlink";function Qc(t,e,n,o,r,a=Mf(e)){o&&e.startsWith("xlink:")?n==null?t.removeAttributeNS(Zc,e.slice(6,e.length)):t.setAttributeNS(Zc,e,n):n==null||a&&!Pl(n)?t.removeAttribute(e):t.setAttribute(e,a?"":Bt(n)?String(n):n)}function Jc(t,e,n,o,r){if(e==="innerHTML"||e==="textContent"){n!=null&&(t[e]=e==="innerHTML"?Vc(n):n);return}const a=t.tagName;if(e==="value"&&a!=="PROGRESS"&&!a.includes("-")){const s=a==="OPTION"?t.getAttribute("value")||"":t.value,l=n==null?t.type==="checkbox"?"on":"":String(n);(s!==l||!("_value"in t))&&(t.value=l),n==null&&t.removeAttribute(e),t._value=n;return}let i=!1;if(n===""||n==null){const s=typeof t[e];s==="boolean"?n=Pl(n):n==null&&s==="string"?(n="",i=!0):s==="number"&&(n=0,i=!0)}try{t[e]=n}catch{}i&&t.removeAttribute(r||e)}function bo(t,e,n,o){t.addEventListener(e,n,o)}function OP(t,e,n,o){t.removeEventListener(e,n,o)}const eu=Symbol("_vei");function kP(t,e,n,o,r=null){const a=t[eu]||(t[eu]={}),i=a[e];if(o&&i)i.value=o;else{const[s,l]=IP(e);if(o){const c=a[e]=$P(o,r);bo(t,s,c,l)}else i&&(OP(t,s,i,l),a[e]=void 0)}}const tu=/(?:Once|Passive|Capture)$/;function IP(t){let e;if(tu.test(t)){e={};let o;for(;o=t.match(tu);)t=t.slice(0,t.length-o[0].length),e[o[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Yn(t.slice(2)),e]}let Yi=0;const GP=Promise.resolve(),LP=()=>Yi||(GP.then(()=>Yi=0),Yi=Date.now());function $P(t,e){const n=o=>{if(!o._vts)o._vts=Date.now();else if(o._vts<=n.attached)return;mn(NP(o,n.value),e,5,[o])};return n.value=t,n.attached=LP(),n}function NP(t,e){if(Ce(e)){const n=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{n.call(t),t._stopped=!0},e.map(o=>r=>!r._stopped&&o&&o(r))}else return e}const nu=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,jP=(t,e,n,o,r,a)=>{const i=r==="svg";e==="class"?xP(t,o,i):e==="style"?RP(t,n,o):Hr(e)?Vr(e)||kP(t,e,n,o,a):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):UP(t,e,o,i))?(Jc(t,e,o),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&Qc(t,e,o,i,a,e!=="value")):t._isVueCE&&(BP(t,e)||t._def.__asyncLoader&&(/[A-Z]/.test(e)||!ut(o)))?Jc(t,wt(e),o,a,e):(e==="true-value"?t._trueValue=o:e==="false-value"&&(t._falseValue=o),Qc(t,e,o,i))};function UP(t,e,n,o){if(o)return!!(e==="innerHTML"||e==="textContent"||e in t&&nu(e)&&Me(n));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const r=t.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return nu(e)&&ut(n)?!1:e in t}function BP(t,e){const n=t._def.props;if(!n)return!1;const o=wt(e);return Array.isArray(n)?n.some(r=>wt(r)===o):Object.keys(n).some(r=>wt(r)===o)}const xa=t=>{const e=t.props["onUpdate:modelValue"]||!1;return Ce(e)?n=>Zr(e,n):e};function zP(t){t.target.composing=!0}function ou(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Uo=Symbol("_assign");function ru(t,e,n){return e&&(t=t.trim()),n&&(t=Qr(t)),t}const Bo={created(t,{modifiers:{lazy:e,trim:n,number:o}},r){t[Uo]=xa(r);const a=o||r.props&&r.props.type==="number";bo(t,e?"change":"input",i=>{i.target.composing||t[Uo](ru(t.value,n,a))}),(n||a)&&bo(t,"change",()=>{t.value=ru(t.value,n,a)}),e||(bo(t,"compositionstart",zP),bo(t,"compositionend",ou),bo(t,"change",ou))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:n,modifiers:{lazy:o,trim:r,number:a}},i){if(t[Uo]=xa(i),t.composing)return;const s=(a||t.type==="number")&&!/^0\d/.test(t.value)?Qr(t.value):t.value,l=e??"";if(s===l)return;const c=t.getRootNode();(c instanceof Document||c instanceof ShadowRoot)&&c.activeElement===t&&t.type!=="range"&&(o&&e===n||r&&t.value.trim()===l)||(t.value=l)}},WP={deep:!0,created(t,{value:e,modifiers:{number:n}},o){const r=Yr(e);bo(t,"change",()=>{const a=Array.prototype.filter.call(t.options,i=>i.selected).map(i=>n?Qr(Ca(i)):Ca(i));t[Uo](t.multiple?r?new Set(a):a:a[0]),t._assigning=!0,ua(()=>{t._assigning=!1})}),t[Uo]=xa(o)},mounted(t,{value:e}){au(t,e)},beforeUpdate(t,e,n){t[Uo]=xa(n)},updated(t,{value:e}){t._assigning||au(t,e)}};function au(t,e){const n=t.multiple,o=Ce(e);if(!(n&&!o&&!Yr(e))){for(let r=0,a=t.options.length;r<a;r++){const i=t.options[r],s=Ca(i);if(n)if(o){const l=typeof s;l==="string"||l==="number"?i.selected=e.some(c=>String(c)===String(s)):i.selected=wf(e,s)>-1}else i.selected=e.has(s);else if(rr(Ca(i),e)){t.selectedIndex!==r&&(t.selectedIndex=r);return}}!n&&t.selectedIndex!==-1&&(t.selectedIndex=-1)}}function Ca(t){return"_value"in t?t._value:t.value}const HP=["ctrl","shift","alt","meta"],VP={stop:t=>t.stopPropagation(),prevent:t=>t.preventDefault(),self:t=>t.target!==t.currentTarget,ctrl:t=>!t.ctrlKey,shift:t=>!t.shiftKey,alt:t=>!t.altKey,meta:t=>!t.metaKey,left:t=>"button"in t&&t.button!==0,middle:t=>"button"in t&&t.button!==1,right:t=>"button"in t&&t.button!==2,exact:(t,e)=>HP.some(n=>t[`${n}Key`]&&!e.includes(n))},qi=(t,e)=>{if(!t)return t;const n=t._withMods||(t._withMods={}),o=e.join(".");return n[o]||(n[o]=(r,...a)=>{for(let i=0;i<e.length;i++){const s=VP[e[i]];if(s&&s(r,e))return}return t(r,...a)})},YP={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},qP=(t,e)=>{const n=t._withKeys||(t._withKeys={}),o=e.join(".");return n[o]||(n[o]=r=>{if(!("key"in r))return;const a=Yn(r.key);if(e.some(i=>i===a||YP[i]===a))return t(r)})},KP=bt({patchProp:jP},EP);let iu;function XP(){return iu||(iu=rP(KP))}const ZP=(...t)=>{const e=XP().createApp(...t),{mount:n}=e;return e.mount=o=>{const r=JP(o);if(!r)return;const a=e._component;!Me(a)&&!a.render&&!a.template&&(a.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const i=n(r,!1,QP(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),i},e};function QP(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function JP(t){return ut(t)?document.querySelector(t):t}var Er=(t=>(t[t.Degree0=0]="Degree0",t[t.Degree90=1]="Degree90",t[t.Degree180=2]="Degree180",t[t.Degree270=3]="Degree270",t))(Er||{});function Ki(t){const{width:e,height:n}=t;return{width:n,height:e}}function Ta(t,e,n){return t=e%2===0?t:Ki(t),{width:t.width*n,height:t.height*n}}function su(t,e,n){let o=e.x,r=e.y;switch(n){case 0:o=e.x,r=e.y;break;case 1:o=t.height-e.y,r=e.x;break;case 2:o=t.width-e.x,r=t.height-e.y;break;case 3:o=e.y,r=t.width-e.x;break}return{x:o,y:r}}function Ma(t,e){return{x:t.x*e,y:t.y*e}}function eF(t,e,n,o){return Ma(su(t,e,n),o)}function tF(t,e,n,o){return Ma(su(t,e,(4-n)%4),1/o)}function cn(t){if(t.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};const e=t.map(a=>a.x),n=t.map(a=>a.y),o=Math.min(...e),r=Math.min(...n);return{origin:{x:o,y:r},size:{width:Math.max(...e)-o,height:Math.max(...n)-r}}}function nF(t,e,n){const o=Math.cos(e),r=Math.sin(e),a=t.x*o-t.y*r,i=t.x*r+t.y*o;return{x:a+n.x,y:i+n.y}}function _n(t,e){return{origin:{x:t.origin.x-e,y:t.origin.y-e},size:{width:t.size.width+e*2,height:t.size.height+e*2}}}function Xi(t,e,n){let o=e.origin.x,r=e.origin.y,a=e.size;switch(n){case 0:break;case 1:o=t.height-e.origin.y-e.size.height,r=e.origin.x,a=Ki(e.size);break;case 2:o=t.width-e.origin.x-e.size.width,r=t.height-e.origin.y-e.size.height;break;case 3:o=e.origin.y,r=t.width-e.origin.x-e.size.width,a=Ki(e.size);break}return{origin:{x:o,y:r},size:{width:a.width,height:a.height}}}function lu(t,e){return{origin:{x:t.origin.x*e,y:t.origin.y*e},size:{width:t.size.width*e,height:t.size.height*e}}}function oF(t,e,n,o){return lu(Xi(t,e,n),o)}function rF(t,e,n,o){return lu(Xi(t,e,(4-n)%4),1/o)}const aF={origin:{x:0,y:0},size:{width:0,height:0}};function Zi(t){if(t.length===0)return null;let e=t[0].origin.x,n=t[0].origin.y,o=t[0].origin.x+t[0].size.width,r=t[0].origin.y+t[0].size.height;for(const a of t)e=Math.min(e,a.origin.x),n=Math.min(n,a.origin.y),o=Math.max(o,a.origin.x+a.size.width),r=Math.max(r,a.origin.y+a.size.height);return{origin:{x:e,y:n},size:{width:o-e,height:r-n}}}function iF(t){return Zi(t)??aF}function Ra(t){const e=t%360;return e<0?e+360:e}function yo(t){return{x:t.origin.x+t.size.width/2,y:t.origin.y+t.size.height/2}}function _o(t,e,n){const o=n*Math.PI/180,r=Math.cos(o),a=Math.sin(o),i=t.x-e.x,s=t.y-e.y;return{x:e.x+i*r-s*a,y:e.y+i*a+s*r}}function cu(t,e,n){return t.map(o=>_o(o,e,n))}function Qn(t,e,n){const o=[{x:t.origin.x,y:t.origin.y},{x:t.origin.x+t.size.width,y:t.origin.y},{x:t.origin.x+t.size.width,y:t.origin.y+t.size.height},{x:t.origin.x,y:t.origin.y+t.size.height}],r=cu(o,n,e);return cn(r)}function Qi(t,e){return Qn(t,e,yo(t))}function uu(t,e,n){const o=n*Math.PI/180,r=Math.cos(o),a=Math.sin(o),i=1-r,s=a,l=-a,c=1-r,u=i*c-s*l,d=yo(t);if(Math.abs(u)<1e-10)return d;const p=yo(e),h=p.x-(r*d.x-a*d.y),g=p.y-(a*d.x+r*d.y);return{x:(c*h-s*g)/u,y:(-l*h+i*g)/u}}class zo{isEnabled(){return!1}debug(){}info(){}warn(){}error(){}perf(){}}class sF{isEnabled(){return!0}debug(e,n,...o){console.debug(`${e}.${n}`,...o)}info(e,n,...o){console.info(`${e}.${n}`,...o)}warn(e,n,...o){console.warn(`${e}.${n}`,...o)}error(e,n,...o){console.error(`${e}.${n}`,...o)}perf(e,n,o,r,...a){console.info(`${e}.${n}.${o}.${r}`,...a)}}class lF{constructor(e,n){this.logger=e,this.level=n}isEnabled(e){const n={debug:0,info:1,warn:2,error:3};return this.level<=n[e]}debug(e,n,...o){this.level<=0&&this.logger.debug(e,n,...o)}info(e,n,...o){this.level<=1&&this.logger.info(e,n,...o)}warn(e,n,...o){this.level<=2&&this.logger.warn(e,n,...o)}error(e,n,...o){this.level<=3&&this.logger.error(e,n,...o)}perf(e,n,o,r,...a){this.logger.perf(e,n,o,r,...a)}}class cF{constructor(){this.marks=new Map}isEnabled(){return!1}debug(e,n,...o){}info(e,n,...o){}warn(e,n,...o){}error(e,n,...o){}perf(e,n,o,r,a,...i){const s=`${e}.${n}.${o}.${r}.${a}`;switch(r){case"Begin":globalThis.performance.mark(s,{detail:i}),this.marks.set(`${e}.${n}.${o}.${a}`,Date.now());break;case"End":globalThis.performance.mark(s,{detail:i});const l=`${e}.${n}.${o}.Measure.${a}`,c=`${e}.${n}.${o}.Begin.${a}`;globalThis.performance.measure(l,c,s);const u=this.marks.get(`${e}.${n}.${o}.${a}`);if(u){const d=Date.now()-u;console.info(`⏱️ ${e}.${n}.${o}.${a}: ${d}ms`),this.marks.delete(`${e}.${n}.${o}.${a}`)}break}}}class uF{constructor(e){this.loggers=e}isEnabled(e){return this.loggers.some(n=>n.isEnabled(e))}debug(e,n,...o){for(const r of this.loggers)r.debug(e,n,...o)}info(e,n,...o){for(const r of this.loggers)r.info(e,n,...o)}warn(e,n,...o){for(const r of this.loggers)r.warn(e,n,...o)}error(e,n,...o){for(const r of this.loggers)r.error(e,n,...o)}perf(e,n,o,r,...a){for(const i of this.loggers)i.perf(e,n,o,r,...a)}}var Wo=(t=>(t[t.Pending=0]="Pending",t[t.Resolved=1]="Resolved",t[t.Rejected=2]="Rejected",t[t.Aborted=3]="Aborted",t))(Wo||{});class dF extends Error{constructor(e){super(`Task aborted: ${JSON.stringify(e)}`),this.name="TaskAbortedError",this.reason=e}}class pF extends Error{constructor(e){super(`Task rejected: ${JSON.stringify(e)}`),this.name="TaskRejectedError",this.reason=e}}class Ie{constructor(){this.state={stage:0},this.resolvedCallbacks=[],this.rejectedCallbacks=[],this._promise=null,this.progressCbs=[]}toPromise(){return this._promise||(this._promise=new Promise((e,n)=>{this.wait(o=>e(o),o=>{o.type==="abort"?n(new dF(o.reason)):n(new pF(o.reason))})})),this._promise}wait(e,n){switch(this.state.stage){case 0:this.resolvedCallbacks.push(e),this.rejectedCallbacks.push(n);break;case 1:e(this.state.result);break;case 2:n({type:"reject",reason:this.state.reason});break;case 3:n({type:"abort",reason:this.state.reason});break}}resolve(e){if(this.state.stage===0){this.state={stage:1,result:e};for(const n of this.resolvedCallbacks)try{n(e)}catch{}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}reject(e){if(this.state.stage===0){this.state={stage:2,reason:e};for(const n of this.rejectedCallbacks)try{n({type:"reject",reason:e})}catch{}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}abort(e){if(this.state.stage===0){this.state={stage:3,reason:e};for(const n of this.rejectedCallbacks)try{n({type:"abort",reason:e})}catch{}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}fail(e){e.type==="abort"?this.abort(e.reason):this.reject(e.reason)}onProgress(e){this.progressCbs.push(e)}progress(e){for(const n of this.progressCbs)n(e)}static all(e){const n=new Ie;if(e.length===0)return n.resolve([]),n;const o=new Array(e.length);let r=0,a=!1;return e.forEach((i,s)=>{i.wait(l=>{a||(o[s]=l,r++,r===e.length&&(a=!0,n.resolve(o)))},l=>{a||(a=!0,l.type==="abort"?n.abort(l.reason):n.reject(l.reason))})}),n}static allSettled(e){const n=new Ie;if(e.length===0)return n.resolve([]),n;const o=new Array(e.length);let r=0;return e.forEach((a,i)=>{a.wait(s=>{o[i]={status:"resolved",value:s},r++,r===e.length&&n.resolve(o)},s=>{o[i]={status:s.type==="abort"?"aborted":"rejected",reason:s.reason},r++,r===e.length&&n.resolve(o)})}),n}static race(e){const n=new Ie;if(e.length===0)return n.reject("No tasks provided"),n;let o=!1;return e.forEach(r=>{r.wait(a=>{o||(o=!0,n.resolve(a))},a=>{o||(o=!0,a.type==="abort"?n.abort(a.reason):n.reject(a.reason))})}),n}static withProgress(e,n){const o=Ie.all(e);if(n){let r=0;e.forEach(a=>{a.wait(()=>{r++,n(r,e.length)},()=>{r++,n(r,e.length)})})}return o}}const hF=Object.freeze(["­","​","⁠","\uFEFF","￾","￿"]);new RegExp(`[${hF.join("")}]`,"g");var du=(t=>(t[t.Unknown=0]="Unknown",t[t.XYZ=1]="XYZ",t[t.FitPage=2]="FitPage",t[t.FitHorizontal=3]="FitHorizontal",t[t.FitVertical=4]="FitVertical",t[t.FitRectangle=5]="FitRectangle",t[t.FitBoundingBox=6]="FitBoundingBox",t[t.FitBoundingBoxHorizontal=7]="FitBoundingBoxHorizontal",t[t.FitBoundingBoxVertical=8]="FitBoundingBoxVertical",t))(du||{}),mt=(t=>(t[t.Unknown=-1]="Unknown",t[t.Courier=0]="Courier",t[t.Courier_Bold=1]="Courier_Bold",t[t.Courier_BoldOblique=2]="Courier_BoldOblique",t[t.Courier_Oblique=3]="Courier_Oblique",t[t.Helvetica=4]="Helvetica",t[t.Helvetica_Bold=5]="Helvetica_Bold",t[t.Helvetica_BoldOblique=6]="Helvetica_BoldOblique",t[t.Helvetica_Oblique=7]="Helvetica_Oblique",t[t.Times_Roman=8]="Times_Roman",t[t.Times_Bold=9]="Times_Bold",t[t.Times_BoldItalic=10]="Times_BoldItalic",t[t.Times_Italic=11]="Times_Italic",t[t.Symbol=12]="Symbol",t[t.ZapfDingbats=13]="ZapfDingbats",t))(mt||{}),Vt=(t=>(t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t))(Vt||{}),Ar=(t=>(t[t.Top=0]="Top",t[t.Middle=1]="Middle",t[t.Bottom=2]="Bottom",t))(Ar||{}),it=(t=>(t[t.Normal=0]="Normal",t[t.Multiply=1]="Multiply",t[t.Screen=2]="Screen",t[t.Overlay=3]="Overlay",t[t.Darken=4]="Darken",t[t.Lighten=5]="Lighten",t[t.ColorDodge=6]="ColorDodge",t[t.ColorBurn=7]="ColorBurn",t[t.HardLight=8]="HardLight",t[t.SoftLight=9]="SoftLight",t[t.Difference=10]="Difference",t[t.Exclusion=11]="Exclusion",t[t.Hue=12]="Hue",t[t.Saturation=13]="Saturation",t[t.Color=14]="Color",t[t.Luminosity=15]="Luminosity",t))(it||{}),wa=(t=>(t[t.Unsupported=0]="Unsupported",t[t.Goto=1]="Goto",t[t.RemoteGoto=2]="RemoteGoto",t[t.URI=3]="URI",t[t.LaunchAppOrOpenFile=4]="LaunchAppOrOpenFile",t))(wa||{}),M=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.TEXT=1]="TEXT",t[t.LINK=2]="LINK",t[t.FREETEXT=3]="FREETEXT",t[t.LINE=4]="LINE",t[t.SQUARE=5]="SQUARE",t[t.CIRCLE=6]="CIRCLE",t[t.POLYGON=7]="POLYGON",t[t.POLYLINE=8]="POLYLINE",t[t.HIGHLIGHT=9]="HIGHLIGHT",t[t.UNDERLINE=10]="UNDERLINE",t[t.SQUIGGLY=11]="SQUIGGLY",t[t.STRIKEOUT=12]="STRIKEOUT",t[t.STAMP=13]="STAMP",t[t.CARET=14]="CARET",t[t.INK=15]="INK",t[t.POPUP=16]="POPUP",t[t.FILEATTACHMENT=17]="FILEATTACHMENT",t[t.SOUND=18]="SOUND",t[t.MOVIE=19]="MOVIE",t[t.WIDGET=20]="WIDGET",t[t.SCREEN=21]="SCREEN",t[t.PRINTERMARK=22]="PRINTERMARK",t[t.TRAPNET=23]="TRAPNET",t[t.WATERMARK=24]="WATERMARK",t[t.THREED=25]="THREED",t[t.RICHMEDIA=26]="RICHMEDIA",t[t.XFAWIDGET=27]="XFAWIDGET",t[t.REDACT=28]="REDACT",t))(M||{}),Ji=(t=>(t[t.Unknown=-1]="Unknown",t[t.Comment=0]="Comment",t[t.Key=1]="Key",t[t.Note=2]="Note",t[t.Help=3]="Help",t[t.NewParagraph=4]="NewParagraph",t[t.Paragraph=5]="Paragraph",t[t.Insert=6]="Insert",t[t.Graph=7]="Graph",t[t.PushPin=8]="PushPin",t[t.Paperclip=9]="Paperclip",t[t.Tag=10]="Tag",t[t.Speaker=11]="Speaker",t[t.Mic=12]="Mic",t[t.Approved=13]="Approved",t[t.Experimental=14]="Experimental",t[t.NotApproved=15]="NotApproved",t[t.AsIs=16]="AsIs",t[t.Expired=17]="Expired",t[t.NotForPublicRelease=18]="NotForPublicRelease",t[t.Confidential=19]="Confidential",t[t.Final=20]="Final",t[t.Sold=21]="Sold",t[t.Departmental=22]="Departmental",t[t.ForComment=23]="ForComment",t[t.TopSecret=24]="TopSecret",t[t.Draft=25]="Draft",t[t.ForPublicRelease=26]="ForPublicRelease",t))(Ji||{}),Ct=(t=>(t[t.None=0]="None",t[t.Square=1]="Square",t[t.Circle=2]="Circle",t[t.Diamond=3]="Diamond",t[t.OpenArrow=4]="OpenArrow",t[t.ClosedArrow=5]="ClosedArrow",t[t.Butt=6]="Butt",t[t.ROpenArrow=7]="ROpenArrow",t[t.RClosedArrow=8]="RClosedArrow",t[t.Slash=9]="Slash",t[t.Unknown=10]="Unknown",t))(Ct||{}),Ln=(t=>(t[t.Unknown=0]="Unknown",t[t.Reply=1]="Reply",t[t.Group=2]="Group",t))(Ln||{}),rt=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.SOLID=1]="SOLID",t[t.DASHED=2]="DASHED",t[t.BEVELED=3]="BEVELED",t[t.INSET=4]="INSET",t[t.UNDERLINE=5]="UNDERLINE",t[t.CLOUDY=6]="CLOUDY",t))(rt||{});const gF=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"});Object.entries(gF).reduce((t,[e,n])=>(t[n]=Number(e),t),{});var vn=(t=>(t[t.ANSI=0]="ANSI",t[t.DEFAULT=1]="DEFAULT",t[t.SYMBOL=2]="SYMBOL",t[t.SHIFTJIS=128]="SHIFTJIS",t[t.HANGEUL=129]="HANGEUL",t[t.GB2312=134]="GB2312",t[t.CHINESEBIG5=136]="CHINESEBIG5",t[t.GREEK=161]="GREEK",t[t.VIETNAMESE=163]="VIETNAMESE",t[t.HEBREW=177]="HEBREW",t[t.ARABIC=178]="ARABIC",t[t.CYRILLIC=204]="CYRILLIC",t[t.THAI=222]="THAI",t[t.EASTERNEUROPEAN=238]="EASTERNEUROPEAN",t))(vn||{}),xr=(t=>(t[t.Create=0]="Create",t[t.Read=1]="Read",t[t.Update=2]="Update",t[t.Delete=3]="Delete",t))(xr||{}),te=(t=>(t[t.Print=4]="Print",t[t.ModifyContents=8]="ModifyContents",t[t.CopyContents=16]="CopyContents",t[t.ModifyAnnotations=32]="ModifyAnnotations",t[t.FillForms=256]="FillForms",t[t.ExtractForAccessibility=512]="ExtractForAccessibility",t[t.AssembleDocument=1024]="AssembleDocument",t[t.PrintHighQuality=2048]="PrintHighQuality",t[t.AllowAll=3900]="AllowAll",t))(te||{});class fF extends Error{constructor(e,n){const o=e.map(r=>te[r]).join(", ");super(`Permission denied. Required: ${o}`),this.requiredFlags=e,this.currentPermissions=n,this.name="PermissionDeniedError"}}var ve=(t=>(t[t.Ok=0]="Ok",t[t.Unknown=1]="Unknown",t[t.NotFound=2]="NotFound",t[t.WrongFormat=3]="WrongFormat",t[t.Password=4]="Password",t[t.Security=5]="Security",t[t.PageError=6]="PageError",t[t.XFALoad=7]="XFALoad",t[t.XFALayout=8]="XFALayout",t[t.Cancelled=9]="Cancelled",t[t.Initialization=10]="Initialization",t[t.NotReady=11]="NotReady",t[t.NotSupport=12]="NotSupport",t[t.LoadDoc=13]="LoadDoc",t[t.DocNotOpen=14]="DocNotOpen",t[t.CantCloseDoc=15]="CantCloseDoc",t[t.CantCreateNewDoc=16]="CantCreateNewDoc",t[t.CantImportPages=17]="CantImportPages",t[t.CantCreateAnnot=18]="CantCreateAnnot",t[t.CantSetAnnotRect=19]="CantSetAnnotRect",t[t.CantSetAnnotContent=20]="CantSetAnnotContent",t[t.CantRemoveInkList=21]="CantRemoveInkList",t[t.CantAddInkStoke=22]="CantAddInkStoke",t[t.CantReadAttachmentSize=23]="CantReadAttachmentSize",t[t.CantReadAttachmentContent=24]="CantReadAttachmentContent",t[t.CantFocusAnnot=25]="CantFocusAnnot",t[t.CantSelectText=26]="CantSelectText",t[t.CantSelectOption=27]="CantSelectOption",t[t.CantCheckField=28]="CantCheckField",t[t.CantSetAnnotString=29]="CantSetAnnotString",t))(ve||{});class Ue{static create(){return new Ie}static resolve(e){const n=new Ie;return n.resolve(e),n}static reject(e){const n=new Ie;return n.reject(e),n}static abort(e){const n=new Ie;return n.reject(e),n}}function mF(t){/^#?[0-9a-f]{3}$/i.test(t)&&(t=t.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"#$1$1$2$2$3$3").toLowerCase());const[,e,n,o]=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t)??(()=>{throw new Error(`Invalid hex colour: "${t}"`)})();return{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(o,16)}}function PF(t){try{const{red:e,green:n,blue:o}=mF(t);return(.299*e+.587*n+.114*o)/255<.45?"#fff":"#000"}catch{return"#000"}}const es=Object.freeze([{id:Vt.Left,label:"Left",css:"left"},{id:Vt.Center,label:"Center",css:"center"},{id:Vt.Right,label:"Right",css:"right"}]),pu=es.reduce((t,e)=>(t[e.id]=e,t),{});es.reduce((t,e)=>(t[e.css]=e.id,t),{});function FF(t){return pu[t]??pu[Vt.Left]}function ts(t){return FF(t).css}es.map(t=>({value:t.id,label:t.label}));var hu=(t=>(t.Courier="Courier",t.Helvetica="Helvetica",t.Times="Times",t.Symbol="Symbol",t.ZapfDingbats="ZapfDingbats",t.Unknown="Unknown",t))(hu||{});mt.Helvetica;const gu={id:mt.Helvetica,family:"Helvetica",bold:!1,italic:!1,label:"Helvetica",css:"Helvetica, Arial, sans-serif"},ns=Object.freeze([{id:mt.Courier,family:"Courier",bold:!1,italic:!1,label:"Courier",css:"Courier, monospace"},{id:mt.Courier_Bold,family:"Courier",bold:!0,italic:!1,label:"Courier Bold",css:"Courier, monospace"},{id:mt.Courier_BoldOblique,family:"Courier",bold:!0,italic:!0,label:"Courier Bold Oblique",css:"Courier, monospace"},{id:mt.Courier_Oblique,family:"Courier",bold:!1,italic:!0,label:"Courier Oblique",css:"Courier, monospace"},gu,{id:mt.Helvetica_Bold,family:"Helvetica",bold:!0,italic:!1,label:"Helvetica Bold",css:"Helvetica, Arial, sans-serif"},{id:mt.Helvetica_BoldOblique,family:"Helvetica",bold:!0,italic:!0,label:"Helvetica Bold Oblique",css:"Helvetica, Arial, sans-serif"},{id:mt.Helvetica_Oblique,family:"Helvetica",bold:!1,italic:!0,label:"Helvetica Oblique",css:"Helvetica, Arial, sans-serif"},{id:mt.Times_Roman,family:"Times",bold:!1,italic:!1,label:"Times Roman",css:'"Times New Roman", Times, serif'},{id:mt.Times_Bold,family:"Times",bold:!0,italic:!1,label:"Times Bold",css:'"Times New Roman", Times, serif'},{id:mt.Times_BoldItalic,family:"Times",bold:!0,italic:!0,label:"Times Bold Italic",css:'"Times New Roman", Times, serif'},{id:mt.Times_Italic,family:"Times",bold:!1,italic:!0,label:"Times Italic",css:'"Times New Roman", Times, serif'},{id:mt.Symbol,family:"Symbol",bold:!1,italic:!1,label:"Symbol",css:"Symbol, serif"},{id:mt.ZapfDingbats,family:"ZapfDingbats",bold:!1,italic:!1,label:"Zapf Dingbats",css:"ZapfDingbats, serif"}]),bF=ns.reduce((t,e)=>(t[e.id]=e,t),{}),yF=new Map;for(const t of ns)yF.set(`${t.family}_${t.bold}_${t.italic}`,t.id);function _F(){return gu}function vF(t){return bF[t]??_F()}function os(t){const e=vF(t);return{fontFamily:e.css,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal"}}Object.values(hu).filter(t=>t!=="Unknown").map(t=>({value:t,label:t})),[...new Set(ns.map(t=>t.family))];const Oa=Object.freeze([{id:it.Normal,label:"Normal",css:"normal"},{id:it.Multiply,label:"Multiply",css:"multiply"},{id:it.Screen,label:"Screen",css:"screen"},{id:it.Overlay,label:"Overlay",css:"overlay"},{id:it.Darken,label:"Darken",css:"darken"},{id:it.Lighten,label:"Lighten",css:"lighten"},{id:it.ColorDodge,label:"Color Dodge",css:"color-dodge"},{id:it.ColorBurn,label:"Color Burn",css:"color-burn"},{id:it.HardLight,label:"Hard Light",css:"hard-light"},{id:it.SoftLight,label:"Soft Light",css:"soft-light"},{id:it.Difference,label:"Difference",css:"difference"},{id:it.Exclusion,label:"Exclusion",css:"exclusion"},{id:it.Hue,label:"Hue",css:"hue"},{id:it.Saturation,label:"Saturation",css:"saturation"},{id:it.Color,label:"Color",css:"color"},{id:it.Luminosity,label:"Luminosity",css:"luminosity"}]),fu=Oa.reduce((t,e)=>(t[e.id]=e,t),{});Oa.reduce((t,e)=>(t[e.css]=e.id,t),{});function DF(t){return fu[t]??fu[it.Normal]}function ka(t){return DF(t).css}Oa.map(t=>({value:t.id,label:t.label})),Oa.map(t=>t.id);function rs(t){if(t instanceof zo)return{type:"noop"};if(t instanceof sF)return{type:"console"};if(t instanceof cF)return{type:"perf"};if(t instanceof lF){const e=t;return{type:"level",config:{level:e.level,logger:rs(e.logger)}}}return t instanceof uF?{type:"all",config:{loggers:t.loggers.map(rs)}}:{type:"noop"}}function SF(t){var e;if(typeof((e=globalThis.crypto)==null?void 0:e.getRandomValues)=="function")return globalThis.crypto.getRandomValues(new Uint8Array(t));if(typeof require=="function")try{const{randomBytes:o}=require("crypto");return o(t)}catch{}const n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=Math.floor(Math.random()*256);return n}function pt(){var t;if(typeof((t=globalThis.crypto)==null?void 0:t.randomUUID)=="function")return globalThis.crypto.randomUUID();const e=SF(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=Array.from(e,o=>o.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}class vo extends Ie{constructor(e={}){super(),this.children=new Map,this.childResults=[],this.completedCount=0,this.expectedCount=0,this.isFinalized=!1,this.config={aggregate:e.aggregate??(n=>n),onChildComplete:e.onChildComplete??(()=>{}),failFast:e.failFast??!0}}addChild(e,n){if(this.state.stage!==Wo.Pending)return this.state.stage===Wo.Aborted&&e.abort(this.state.reason),this;const o=n??this.expectedCount;return this.expectedCount=Math.max(this.expectedCount,o+1),this.children.set(e,o),e.wait(r=>this.handleChildSuccess(e,r,o),r=>this.handleChildError(e,r,o)),this}finalize(){return this.isFinalized?this:(this.isFinalized=!0,this.expectedCount===0&&this.resolve(this.config.aggregate([])),this)}handleChildSuccess(e,n,o){if(this.state.stage!==Wo.Pending)return;this.childResults[o]=n,this.completedCount++,this.children.delete(e);const r=this.config.onChildComplete(this.completedCount,this.expectedCount,n,o);if(r!==void 0&&this.progress(r),this.completedCount===this.expectedCount){const a=this.config.aggregate(this.childResults);this.resolve(a)}}handleChildError(e,n,o){if(this.state.stage===Wo.Pending){if(this.children.delete(e),this.config.failFast){for(const[r]of this.children)r.abort("Sibling task failed");this.children.clear(),this.fail(n)}else if(this.childResults[o]=void 0,this.completedCount++,this.completedCount===this.expectedCount){const r=this.config.aggregate(this.childResults);this.resolve(r)}}}abort(e){for(const[n]of this.children)n.abort(e);this.children.clear(),super.abort(e)}reject(e){for(const[n]of this.children)n.abort(e);this.children.clear(),super.reject(e)}getPendingCount(){return this.children.size}getCompletedCount(){return this.completedCount}static gather(e){const n=new vo({aggregate:o=>o,onChildComplete:(o,r)=>({completed:o,total:r})});return e.forEach((o,r)=>n.addChild(o,r)),n.finalize(),n}static gatherIndexed(e){const n=new vo({aggregate:o=>{const r={};return o.forEach((a,i)=>{r[i]=a}),r},onChildComplete:(o,r,a,i)=>({page:i,result:a})});return e.forEach((o,r)=>n.addChild(o,r)),n.finalize(),n}static gatherFrom(e,n){const o=new vo(n);return e.forEach((r,a)=>o.addChild(r,a)),o.finalize(),o}static first(e){let n=!1;const o=new vo({aggregate:r=>r[0],failFast:!1});return o.handleChildSuccess=(r,a)=>{if(!n){n=!0;for(const[i]of o.children)i!==r&&i.abort("Race won by sibling");o.resolve(a)}},e.forEach((r,a)=>o.addChild(r,a)),o.finalize(),o}}function Yt(){}class mu{constructor(){this.dependencyGraph=new Map}addNode(e,n=[]){this.dependencyGraph.set(e,new Set(n))}hasCircularDependencies(){const e=new Set,n=new Set,o=r=>{e.add(r),n.add(r);const a=this.dependencyGraph.get(r)||new Set;for(const i of a)if(e.has(i)){if(n.has(i))return!0}else if(o(i))return!0;return n.delete(r),!1};for(const r of this.dependencyGraph.keys())if(!e.has(r)&&o(r))return!0;return!1}resolveLoadOrder(){if(this.hasCircularDependencies())throw new Error("Circular dependencies detected");const e=[],n=new Set,o=new Set,r=a=>{if(o.has(a))throw new Error("Circular dependency");if(n.has(a))return;o.add(a);const i=this.dependencyGraph.get(a)||new Set;for(const s of i)r(s);o.delete(a),n.add(a),e.push(a)};for(const a of this.dependencyGraph.keys())n.has(a)||r(a);return e}}class Nt extends Error{constructor(e){super(e),this.name="PluginRegistrationError"}}class Ho extends Error{constructor(e){super(e),this.name="PluginNotFoundError"}}class EF extends Error{constructor(e){super(e),this.name="CircularDependencyError"}}class AF extends Error{constructor(e){super(e),this.name="PluginConfigurationError"}}class xF{constructor(e,n){this.store=e,this.pluginId=n}getState(){return this.store.getState().plugins[this.pluginId]}dispatch(e){return this.store.dispatchToPlugin(this.pluginId,e)}subscribeToState(e){return this.store.subscribeToPlugin(this.pluginId,(n,o,r)=>{e(n,o,r)})}onAction(e,n){return this.store.onAction(e,(o,r,a)=>{n(o,r.plugins[this.pluginId],a.plugins[this.pluginId])})}}const Ia="START_LOADING_DOCUMENT",Pu="UPDATE_DOCUMENT_LOADING_PROGRESS",Ga="SET_DOCUMENT_LOADED",as="SET_DOCUMENT_ERROR",is="RETRY_LOADING_DOCUMENT",La="CLOSE_DOCUMENT",ss="SET_ACTIVE_DOCUMENT",ls="REORDER_DOCUMENTS",cs="MOVE_DOCUMENT",us="UPDATE_DOCUMENT_SECURITY",CF="REFRESH_DOCUMENT",Vo="REFRESH_PAGES",TF="SET_PAGES",$a="SET_SCALE",ds="SET_ROTATION",MF=[Ia,Pu,Ga,La,ss,as,is,CF,Vo,TF,$a,ds,"SET_DEFAULT_SCALE","SET_DEFAULT_ROTATION",ls,cs,us],Fu=(t,e,n,o,r,a,i)=>({type:Ia,payload:{documentId:t,name:e,scale:n,rotation:o,passwordProvided:r,autoActivate:a,permissions:i}}),RF=(t,e)=>({type:Ga,payload:{documentId:t,document:e}}),wF=(t,e,n,o)=>({type:as,payload:{documentId:t,error:e,errorCode:n,errorDetails:o}}),OF=(t,e)=>({type:is,payload:{documentId:t,passwordProvided:e}}),bu=(t,e)=>({type:La,payload:{documentId:t,nextActiveDocumentId:e}}),kF=t=>({type:ss,payload:t}),Na=(t,e)=>({type:Vo,payload:{documentId:t,pageIndexes:e}}),IF=(t,e)=>({type:$a,payload:{scale:t,documentId:e}}),GF=t=>({type:ls,payload:t}),LF=(t,e)=>({type:cs,payload:{documentId:t,toIndex:e}}),$F=(t,e,n)=>({type:us,payload:{documentId:t,permissions:e,isOwnerUnlocked:n}});class NF{constructor(e,n){this.initialCoreState=n,this.pluginReducers={},this.listeners=[],this.pluginListeners={},this.isDispatching=!1,this.state={core:n,plugins:{}},this.coreReducer=e}addPluginReducer(e,n,o){this.state.plugins[e]=o,this.pluginReducers[e]=n}dispatchToCore(e){if(!this.coreReducer)return this.getState();if(this.isDispatching)throw new Error("Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.");const n=this.getState();try{this.isDispatching=!0,this.state.core=this.coreReducer(this.state.core,e)}finally{this.isDispatching=!1}return this.listeners.forEach(o=>{const r=this.getState();o(e,r,n)}),this.getState()}dispatchToPlugin(e,n,o=!0){if(this.isDispatching)throw new Error("Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.");const r=this.getState(),a=this.pluginReducers[e];if(!a)return r.plugins[e];const i=r.plugins[e];try{this.isDispatching=!0;const s=a(i,n);this.state.plugins[e]=s}finally{this.isDispatching=!1}return o&&this.listeners.forEach(s=>{const l=this.getState();s(n,l,r)}),this.pluginListeners[e]&&this.pluginListeners[e].forEach(s=>{const l=this.getState().plugins[e];s(n,l,i)}),this.getState().plugins[e]}dispatch(e){if(this.isDispatching)throw new Error("Reducers may not dispatch actions. To trigger cascading actions, dispatch from a listener callback instead.");const n=this.getState();try{this.isDispatching=!0,this.isCoreAction(e)&&(this.state.core=this.coreReducer(this.state.core,e));for(const o in this.pluginReducers){const r=this.pluginReducers[o],a=n.plugins[o];r&&(this.state.plugins[o]=r(a,e))}}finally{this.isDispatching=!1}return this.listeners.forEach(o=>{const r=this.getState();o(e,r,n)}),this.getState()}getState(){if(this.isDispatching)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return{core:{...this.state.core},plugins:{...this.state.plugins}}}subscribe(e){if(this.isDispatching)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state.");return this.listeners.push(e),()=>{if(this.isDispatching)throw new Error("You may not unsubscribe from a store listener while the reducer is executing.");this.listeners=this.listeners.filter(n=>n!==e)}}subscribeToPlugin(e,n){if(!(e in this.state.plugins))throw new Error(`Plugin state not found for plugin "${e}". Did you forget to call addPluginReducer?`);if(this.isDispatching)throw new Error("You may not call store.subscribeToPlugin() while the reducer is executing.");return this.pluginListeners[e]||(this.pluginListeners[e]=[]),this.pluginListeners[e].push(n),()=>{if(this.isDispatching)throw new Error("You may not unsubscribe from a store listener while the reducer is executing.");this.pluginListeners[e]=this.pluginListeners[e].filter(o=>o!==n),this.pluginListeners[e].length===0&&delete this.pluginListeners[e]}}onAction(e,n){return this.subscribe((o,r,a)=>{o.type===e&&n(o,r,a)})}getPluginStore(e){if(!(e in this.state.plugins))throw new Error(`Plugin state not found for plugin "${e}". Did you forget to call addPluginReducer?`);return new xF(this,e)}isCoreAction(e){return MF.includes(e.type)}destroy(){var e,n;this.listeners.length=0;for(const o in this.pluginListeners)(n=(e=this.pluginListeners[o])==null?void 0:e.splice)==null||n.call(e,0);this.pluginListeners={},this.pluginReducers={},this.state.plugins={},this.state.core={...this.initialCoreState}}}const jF=t=>({documents:{},documentOrder:[],activeDocumentId:null,defaultScale:(t==null?void 0:t.defaultScale)??1,defaultRotation:(t==null?void 0:t.defaultRotation)??Er.Degree0,globalPermissions:t==null?void 0:t.permissions});te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality;const UF=[te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality],BF={[te.Print]:"print",[te.ModifyContents]:"modifyContents",[te.CopyContents]:"copyContents",[te.ModifyAnnotations]:"modifyAnnotations",[te.FillForms]:"fillForms",[te.ExtractForAccessibility]:"extractForAccessibility",[te.AssembleDocument]:"assembleDocument",[te.PrintHighQuality]:"printHighQuality"};function yu(t,e){if(!t)return;if(e in t)return t[e];const n=BF[e];if(n&&n in t)return t[n]}function ps(t,e,n){var o;const r=t.documents[e],a=r==null?void 0:r.permissions,i=t.globalPermissions,s=((o=r==null?void 0:r.document)==null?void 0:o.permissions)??te.AllowAll,l=yu(a==null?void 0:a.overrides,n);if(l!==void 0)return l;const c=yu(i==null?void 0:i.overrides,n);return c!==void 0?c:(a==null?void 0:a.enforceDocumentPermissions)??(i==null?void 0:i.enforceDocumentPermissions)??!0?(s&n)!==0:!0}function _u(t,e){return UF.reduce((n,o)=>ps(t,e,o)?n|o:n,0)}function zF(t,e,n){const o=t.activeDocumentId;if(o!==e)return o;if(n!==void 0)return n&&t.documents[n]?n:null;const r=t.documentOrder.indexOf(e);return r===-1?null:r>0?t.documentOrder[r-1]:r<t.documentOrder.length-1?t.documentOrder[r+1]:null}function WF(t,e,n){const o=t.indexOf(e);if(o===-1||n<0||n>=t.length||o===n)return null;const r=[...t];return r.splice(o,1),r.splice(n,0,e),r}const HF=(t,e)=>{switch(e.type){case Ia:{const{documentId:n,name:o,scale:r,rotation:a,passwordProvided:i,autoActivate:s=!0,permissions:l}=e.payload,c={id:n,name:o,status:"loading",loadingProgress:0,error:null,document:null,scale:r??t.defaultScale,rotation:a??t.defaultRotation,passwordProvided:i??!1,pageRefreshVersions:{},permissions:l,loadStartedAt:Date.now()};return{...t,documents:{...t.documents,[n]:c},documentOrder:[...t.documentOrder,n],activeDocumentId:s||!t.activeDocumentId?n:t.activeDocumentId}}case Pu:{const{documentId:n,progress:o}=e.payload,r=t.documents[n];return!r||r.status!=="loading"?t:{...t,documents:{...t.documents,[n]:{...r,loadingProgress:o}}}}case Ga:{const{documentId:n,document:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,status:"loaded",document:o,error:null,errorCode:void 0,errorDetails:void 0,passwordProvided:void 0,loadedAt:Date.now()}}}:t}case as:{const{documentId:n,error:o,errorCode:r,errorDetails:a}=e.payload,i=t.documents[n];return i?{...t,documents:{...t.documents,[n]:{...i,status:"error",error:o,errorCode:r,errorDetails:a}}}:t}case is:{const{documentId:n,passwordProvided:o}=e.payload,r=t.documents[n];return!r||r.status!=="error"?t:{...t,documents:{...t.documents,[n]:{...r,status:"loading",loadingProgress:0,error:null,errorCode:void 0,errorDetails:void 0,passwordProvided:o??!1,loadStartedAt:Date.now()}}}}case La:{const{documentId:n,nextActiveDocumentId:o}=e.payload,{[n]:r,...a}=t.documents;return{...t,documents:a,documentOrder:t.documentOrder.filter(i=>i!==n),activeDocumentId:zF(t,n,o)}}case cs:{const{documentId:n,toIndex:o}=e.payload,r=WF(t.documentOrder,n,o);return r?{...t,documentOrder:r}:t}case ls:return{...t,documentOrder:e.payload};case ss:return{...t,activeDocumentId:e.payload};case $a:{const{scale:n,documentId:o}=e.payload,r=o??t.activeDocumentId;if(!r)return t;const a=t.documents[r];return a?{...t,documents:{...t.documents,[r]:{...a,scale:n}}}:t}case ds:{const{rotation:n,documentId:o}=e.payload,r=o??t.activeDocumentId;if(!r)return t;const a=t.documents[r];return a?{...t,documents:{...t.documents,[r]:{...a,rotation:n}}}:t}case Vo:{const{documentId:n,pageIndexes:o}=e.payload,r=t.documents[n];if(!r)return t;const a={...r.pageRefreshVersions};for(const i of o)a[i]=(a[i]||0)+1;return{...t,documents:{...t.documents,[n]:{...r,pageRefreshVersions:a}}}}case us:{const{documentId:n,permissions:o,isOwnerUnlocked:r}=e.payload,a=t.documents[n];return a!=null&&a.document?{...t,documents:{...t.documents,[n]:{...a,document:{...a.document,permissions:o,isOwnerUnlocked:r}}}}:t}default:return t}};class VF{constructor(e,n){this.plugins=new Map,this.manifests=new Map,this.capabilities=new Map,this.status=new Map,this.configurations=new Map,this.initPromise=null,this.pendingRegistrations=[],this.processingRegistrations=[],this.initialized=!1,this.isInitializing=!1,this.pluginsReadyPromise=null,this.destroyed=!1,this.resolver=new mu,this.engine=e,this.initialCoreState=jF(n),this.store=new NF(HF,this.initialCoreState),this.logger=(n==null?void 0:n.logger)??new zo}getLogger(){return this.logger}registerPlugin(e,n){if(this.initialized&&!this.isInitializing)throw new Nt("Cannot register plugins after initialization");this.validateManifest(e.manifest),this.store.addPluginReducer(e.manifest.id,e.reducer,typeof e.initialState=="function"?e.initialState(this.initialCoreState,{...e.manifest.defaultConfig,...n}):e.initialState),this.pendingRegistrations.push({package:e,config:n})}getStore(){return this.store}getEngine(){return this.engine}pluginsReady(){return this.pluginsReadyPromise?this.pluginsReadyPromise:(this.pluginsReadyPromise=(async()=>{this.initialized||await this.initialize();const e=Array.from(this.plugins.values()).map(n=>typeof n.ready=="function"?n.ready():Promise.resolve());await Promise.all(e)})(),this.pluginsReadyPromise)}async initialize(){if(this.destroyed)throw new Nt("Registry has been destroyed");return this.initPromise?this.initPromise:(this.initPromise=(async()=>{if(this.initialized)throw new Nt("Registry is already initialized");this.isInitializing=!0;try{if(this.destroyed)return;for(;this.pendingRegistrations.length>0;){if(this.destroyed)return;this.processingRegistrations=[...this.pendingRegistrations],this.pendingRegistrations=[];for(const n of this.processingRegistrations){const o=new Set,r=[...n.package.manifest.requires,...n.package.manifest.optional];for(const a of r){const i=this.processingRegistrations.find(s=>s.package.manifest.provides.includes(a));i&&o.add(i.package.manifest.id)}this.resolver.addNode(n.package.manifest.id,[...o])}const e=this.resolver.resolveLoadOrder();for(const n of e){const o=this.processingRegistrations.find(r=>r.package.manifest.id===n);this.instantiatePlugin(o.package.manifest,o.package.create,o.config)}for(const n of e)await this.runPluginInitialization(n);this.processingRegistrations=[],this.resolver=new mu}this.initialized=!0}catch(e){throw e instanceof Error?new EF(`Failed to resolve plugin dependencies: ${e.message}`):e}finally{this.isInitializing=!1}})(),this.initPromise)}instantiatePlugin(e,n,o){const r={...e.defaultConfig,...o};this.validateConfig(e.id,r,e.defaultConfig);const a=n(this,r);this.validatePlugin(a);for(const i of e.provides){if(this.capabilities.has(i))throw new Nt(`Capability ${i} is already provided by plugin ${this.capabilities.get(i)}`);this.capabilities.set(i,e.id)}this.plugins.set(e.id,a),this.manifests.set(e.id,e),this.status.set(e.id,"registered"),this.configurations.set(e.id,r)}async runPluginInitialization(e){const n=this.plugins.get(e);if(!n)return;const o=this.manifests.get(e),r=this.configurations.get(e);for(const a of o.requires)if(!this.capabilities.has(a))throw new Nt(`Missing required capability: ${a} for plugin ${e}`);this.logger.debug("PluginRegistry","InitializePlugin",`Initializing plugin ${e}`);try{n.initialize&&await n.initialize(r),this.status.set(e,"active"),this.logger.info("PluginRegistry","PluginInitialized",`Plugin ${e} initialized successfully`)}catch(a){throw this.status.set(e,"error"),this.logger.error("PluginRegistry","InitializationFailed",`Plugin ${e} initialization failed`,{error:a}),a}}getPluginConfig(e){const n=this.configurations.get(e);if(!n)throw new Ho(`Configuration for plugin ${e} not found`);return n}validateConfig(e,n,o){const a=Object.keys(o).filter(i=>!n.hasOwnProperty(i));if(a.length>0)throw new AF(`Missing required configuration keys for plugin ${e}: ${a.join(", ")}`)}async updatePluginConfig(e,n){const o=this.getPlugin(e);if(!o)throw new Ho(`Plugin ${e} not found`);const r=this.manifests.get(e),a=this.configurations.get(e);if(!r||!a)throw new Ho(`Plugin ${e} not found`);const i={...a,...n};this.validateConfig(e,i,r.defaultConfig),this.configurations.set(e,i),o.initialize&&await o.initialize(i)}registerPluginBatch(e){for(const n of e)this.registerPlugin(n.package,n.config)}async unregisterPlugin(e){const n=this.plugins.get(e);if(!n)throw new Ho(`Plugin ${e} is not registered`);const o=this.manifests.get(e);if(!o)throw new Ho(`Manifest for plugin ${e} not found`);for(const[r,a]of this.manifests.entries()){if(r===e)continue;if([...a.requires,...a.optional].some(s=>o.provides.includes(s)))throw new Nt(`Cannot unregister plugin ${e}: plugin ${r} depends on it`)}try{n.destroy&&await n.destroy();for(const r of o.provides)this.capabilities.delete(r);this.plugins.delete(e),this.manifests.delete(e),this.status.delete(e)}catch(r){throw r instanceof Error?new Error(`Failed to unregister plugin ${e}: ${r.message}`):r}}getPlugin(e){const n=this.plugins.get(e);return n||null}getCapabilityProvider(e){const n=this.capabilities.get(e);return n?this.getPlugin(n):null}hasCapability(e){return this.capabilities.has(e)}getAllPlugins(){return Array.from(this.plugins.values())}getPluginStatus(e){const n=this.status.get(e);if(!n)throw new Ho(`Plugin ${e} not found`);return n}validatePlugin(e){if(!e.id)throw new Nt("Plugin must have an id")}validateManifest(e){if(!e.id)throw new Nt("Manifest must have an id");if(!e.name)throw new Nt("Manifest must have a name");if(!e.version)throw new Nt("Manifest must have a version");if(!Array.isArray(e.provides))throw new Nt("Manifest must have a provides array");if(!Array.isArray(e.requires))throw new Nt("Manifest must have a requires array");if(!Array.isArray(e.optional))throw new Nt("Manifest must have an optional array")}isDestroyed(){return this.destroyed}async destroy(){var e;if(this.destroyed)throw new Nt("Registry has already been destroyed");this.destroyed=!0;try{await this.initPromise}catch{}for(const n of Array.from(this.plugins.values()).reverse())await((e=n.destroy)==null?void 0:e.call(n));this.store.destroy(),this.plugins.clear(),this.manifests.clear(),this.capabilities.clear(),this.status.clear(),this.pendingRegistrations.length=0,this.processingRegistrations.length=0}}function YF(t){return"autoMountElements"in t&&typeof t.autoMountElements=="function"}class jt{constructor(e,n){if(this.id=e,this.registry=n,this.cooldownActions={},this.debouncedTimeouts={},this.unsubscribeFromState=null,this.unsubscribeFromCoreStore=null,this.unsubscribeFromStartLoadingDocument=null,this.unsubscribeFromSetDocumentLoaded=null,this.unsubscribeFromCloseDocument=null,this.unsubscribeFromSetScale=null,this.unsubscribeFromSetRotation=null,e!==this.constructor.id)throw new Error(`Plugin ID mismatch: ${e} !== ${this.constructor.id}`);this.engine=this.registry.getEngine(),this.logger=this.registry.getLogger(),this.coreStore=this.registry.getStore(),this.pluginStore=this.coreStore.getPluginStore(this.id),this.unsubscribeFromState=this.pluginStore.subscribeToState((o,r,a)=>{this.onStoreUpdated(a,r)}),this.unsubscribeFromCoreStore=this.coreStore.subscribe((o,r,a)=>{this.onCoreStoreUpdated(a,r),r.core.activeDocumentId!==a.core.activeDocumentId&&this.onActiveDocumentChanged(a.core.activeDocumentId,r.core.activeDocumentId)}),this.unsubscribeFromStartLoadingDocument=this.coreStore.onAction(Ia,o=>{this.onDocumentLoadingStarted(o.payload.documentId)}),this.unsubscribeFromSetDocumentLoaded=this.coreStore.onAction(Ga,o=>{this.onDocumentLoaded(o.payload.documentId)}),this.unsubscribeFromCloseDocument=this.coreStore.onAction(La,o=>{this.onDocumentClosed(o.payload.documentId)}),this.unsubscribeFromSetScale=this.coreStore.onAction($a,(o,r)=>{const a=o.payload.documentId??r.core.activeDocumentId;a&&this.onScaleChanged(a,o.payload.scale)}),this.unsubscribeFromSetRotation=this.coreStore.onAction(ds,(o,r)=>{const a=o.payload.documentId??r.core.activeDocumentId;a&&this.onRotationChanged(a,o.payload.rotation)}),this.readyPromise=new Promise(o=>{this.readyResolve=o}),this.readyResolve()}provides(){if(!this._capability){const e=this.buildCapability();this._capability=Object.freeze(e)}return this._capability}get state(){return this.pluginStore.getState()}get coreState(){return this.coreStore.getState()}getState(){return this.pluginStore.getState()}getCoreState(){return this.coreStore.getState()}dispatchCoreAction(e){return this.coreStore.dispatchToCore(e)}dispatchToAllPlugins(e){return this.coreStore.dispatch(e)}dispatch(e){return this.pluginStore.dispatch(e)}cooldownDispatch(e,n=100){const o=Date.now(),r=this.cooldownActions[e.type]||0;return o-r>=n?(this.cooldownActions[e.type]=o,this.dispatch(e),!0):!1}debouncedDispatch(e,n=100){const o=e.type;this.debouncedTimeouts[o]&&clearTimeout(this.debouncedTimeouts[o]),this.debouncedTimeouts[o]=setTimeout(()=>{this.dispatch(e),delete this.debouncedTimeouts[o]},n)}cancelDebouncedDispatch(e){this.debouncedTimeouts[e]&&(clearTimeout(this.debouncedTimeouts[e]),delete this.debouncedTimeouts[e])}subscribe(e){return this.pluginStore.subscribeToState(e)}subscribeToCoreStore(e){return this.coreStore.subscribe(e)}onStoreUpdated(e,n){}onCoreStoreUpdated(e,n){}onDocumentLoadingStarted(e){}onDocumentLoaded(e){}onDocumentClosed(e){}onActiveDocumentChanged(e,n){}onScaleChanged(e,n){}onRotationChanged(e,n){}destroy(){Object.values(this.debouncedTimeouts).forEach(e=>{clearTimeout(e)}),this.debouncedTimeouts={},this.unsubscribeFromState&&(this.unsubscribeFromState(),this.unsubscribeFromState=null),this.unsubscribeFromCoreStore&&(this.unsubscribeFromCoreStore(),this.unsubscribeFromCoreStore=null),this.unsubscribeFromStartLoadingDocument&&(this.unsubscribeFromStartLoadingDocument(),this.unsubscribeFromStartLoadingDocument=null),this.unsubscribeFromSetDocumentLoaded&&(this.unsubscribeFromSetDocumentLoaded(),this.unsubscribeFromSetDocumentLoaded=null),this.unsubscribeFromCloseDocument&&(this.unsubscribeFromCloseDocument(),this.unsubscribeFromCloseDocument=null),this.unsubscribeFromSetScale&&(this.unsubscribeFromSetScale(),this.unsubscribeFromSetScale=null),this.unsubscribeFromSetRotation&&(this.unsubscribeFromSetRotation(),this.unsubscribeFromSetRotation=null)}ready(){return this.readyPromise}markReady(){this.readyResolve()}resetReady(){this.readyPromise=new Promise(e=>{this.readyResolve=e})}getActiveDocumentId(){const e=this.coreState.core.activeDocumentId;if(!e)throw new Error("No active document");return e}getActiveDocumentIdOrNull(){return this.coreState.core.activeDocumentId}getCoreDocument(e){const n=e??this.getActiveDocumentIdOrNull();return n?this.coreState.core.documents[n]??null:null}getCoreDocumentOrThrow(e){const n=this.getCoreDocument(e);if(!n)throw new Error(`Document not found: ${e??"active"}`);return n}getDocumentPermissions(e){const n=e??this.coreState.core.activeDocumentId;return n?_u(this.coreState.core,n):te.AllowAll}checkPermission(e,...n){const o=e??this.coreState.core.activeDocumentId;return o?n.every(r=>ps(this.coreState.core,o,r)):!0}requirePermission(e,...n){const o=e??this.coreState.core.activeDocumentId;if(!o)return;const r=[];for(const a of n)ps(this.coreState.core,o,a)||r.push(a);if(r.length>0){const a=_u(this.coreState.core,o);throw new fF(r,a)}}}class ja{constructor(e,n){this.handler=e,this.options=n,this.lastRun=0,this.handle=o=>{this.options.mode==="debounce"?this.debounce(o):this.throttle(o)}}debounce(e){this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.handler(e),this.timeoutId=void 0},this.options.wait)}throttle(e){if(this.options.mode==="debounce")return;const n=Date.now(),o=this.options.throttleMode||"leading-trailing";n-this.lastRun>=this.options.wait&&(o==="leading-trailing"&&this.handler(e),this.lastRun=n),this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.handler(e),this.lastRun=Date.now(),this.timeoutId=void 0},this.options.wait-(n-this.lastRun))}destroy(){this.timeoutId&&window.clearTimeout(this.timeoutId)}}class hs{constructor(e,n){this.handler=e,this.options=n,this.controls=new Map,this.handle=o=>{const r=String(this.options.keyExtractor(o));let a=this.controls.get(r);a||(a=new ja(this.handler,this.baseOptions),this.controls.set(r,a)),a.handle(o)},this.baseOptions={mode:n.mode,wait:n.wait,...n.mode==="throttle"&&"throttleMode"in n?{throttleMode:n.throttleMode}:{}}}destroy(){for(const e of this.controls.values())e.destroy();this.controls.clear()}}function gs(t){return"keyExtractor"in t}function et(t,e,n){return t<e?e:t>n?n:t}function Cr(t,e,n){if(t===e)return!0;if(t==null||e==null)return t===e;const o=typeof t;if(o!==typeof e)return!1;if(o==="object"){n||(n=new Set);const a=qF(t,e);if(n.has(a))return!0;n.add(a);const i=Array.isArray(t),s=Array.isArray(e);return i&&s?XF(t,e,n):!i&&!s?ZF(t,e,n):!1}return!1}function qF(t,e){return`${vu(t)}__${vu(e)}`}let KF=0;const fs=new WeakMap;function vu(t){return fs.has(t)||fs.set(t,++KF),fs.get(t)}function XF(t,e,n){if(t.length!==e.length)return!1;const o=new Array(e.length).fill(!1);e:for(let r=0;r<t.length;r++){const a=t[r];for(let i=0;i<e.length;i++)if(!o[i]&&Cr(a,e[i],n)){o[i]=!0;continue e}return!1}return!0}function ZF(t,e,n){const o=Object.keys(t).sort(),r=Object.keys(e).sort();if(o.length!==r.length)return!1;for(let a=0;a<o.length;a++)if(o[a]!==r[a])return!1;for(const a of o){const i=t[a],s=e[a];if(!Cr(i,s,n))return!1}return!0}function $n(){const t=new Set;return{emit:(n=void 0)=>t.forEach(o=>o(n)),on:n=>(t.add(n),()=>t.delete(n)),off:n=>t.delete(n),clear:()=>t.clear()}}function Be(t,e=Cr){const n=new Set,o=new Map;let r=t;const a=s=>n.forEach(l=>l(s)),i=(s,l)=>{let c=s,u=()=>{};if(l){if(gs(l)){const d=new hs(s,l);c=d.handle,u=()=>d.destroy()}else{const d=new ja(s,l);c=d.handle,u=()=>d.destroy()}o.set(s,{wrapped:c,destroy:u})}return r!==void 0&&c(r),n.add(c),()=>{n.delete(c),u(),o.delete(s)}};return{get value(){return r},emit(s=void 0){(r===void 0||!e(r,s))&&(r=s,a(s))},on:i,off(s){const l=o.get(s);l?(n.delete(l.wrapped),l.destroy(),o.delete(s)):n.delete(s)},clear(){n.clear(),o.forEach(s=>s.destroy()),o.clear()},select(s,l=Cr){return(c,u)=>{let d;if(r!==void 0){const p=s(r);d=p,c(p)}return i(p=>{const h=s(p);(d===void 0||!l(d,h))&&(d=h,c(h))},u)}}}}function Tt(t,e){const n=(e==null?void 0:e.cache)??!0,o=(e==null?void 0:e.equality)??Cr,r=new Map,a=new Map,i=new Map,s=new Set,l=new Map,c=h=>String(h),u=h=>{let g=a.get(h);return g||(g=new Set,a.set(h,g)),g},d=h=>{let g=i.get(h);return g||(g=new Map,i.set(h,g)),g};return{emit(h,g){const f=c(h);if(n){const _=r.get(f);if(_!==void 0&&o(_,g))return;r.set(f,g)}const F=a.get(f);F&&F.forEach(_=>_(g));const y=t(h,g);s.forEach(_=>_(y))},forScope(h){const g=c(h);return(f,F)=>{const y=u(g),_=d(g);let E=f,A=()=>{};if(F){if(gs(F)){const T=new hs(f,F);E=T.handle,A=()=>T.destroy()}else{const T=new ja(f,F);E=T.handle,A=()=>T.destroy()}_.set(f,{wrapped:E,destroy:A})}if(n){const T=r.get(g);T!==void 0&&E(T)}return y.add(E),()=>{y.delete(E),A(),_.delete(f),y.size===0&&a.delete(g),_.size===0&&i.delete(g)}}},onGlobal:(h,g)=>{let f=h,F=()=>{};if(g){if(gs(g)){const y=new hs(h,g);f=y.handle,F=()=>y.destroy()}else{const y=new ja(h,g);f=y.handle,F=()=>y.destroy()}l.set(h,{wrapped:f,destroy:F})}return s.add(f),()=>{s.delete(f),F(),l.delete(h)}},getValue(h){return n?r.get(c(h)):void 0},getScopes(){return n?Array.from(r.keys()):Array.from(a.keys())},clearScope(h){const g=c(h);n&&r.delete(g);const f=a.get(g);f&&(f.clear(),a.delete(g));const F=i.get(g);F&&(F.forEach(y=>y.destroy()),F.clear(),i.delete(g))},clear(){n&&r.clear(),a.forEach(h=>h.clear()),a.clear(),i.forEach(h=>{h.forEach(g=>g.destroy()),h.clear()}),i.clear(),s.clear(),l.forEach(h=>h.destroy()),l.clear()}}}class QF{constructor(e){this.autoMountElements=[],this.package=e}addUtility(e){return this.autoMountElements.push({component:e,type:"utility"}),this}addWrapper(e){return this.autoMountElements.push({component:e,type:"wrapper"}),this}build(){return{...this.package,autoMountElements:()=>this.autoMountElements}}}function Tr(t){return new QF(t)}const Du=Symbol("pdfKey");function Su(){const t=Po(Du);if(!t)throw new Error("useRegistry must be used inside <EmbedPDF>");return t}function Eu(){const{coreState:t}=Su();return t}function Dn(t){const e=Eu();return P(()=>{const o=e.value,r=$t(t);return!o||!r?null:o.documents[r]??null})}te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality;const JF=[te.Print,te.ModifyContents,te.CopyContents,te.ModifyAnnotations,te.FillForms,te.ExtractForAccessibility,te.AssembleDocument,te.PrintHighQuality],eb={[te.Print]:"print",[te.ModifyContents]:"modifyContents",[te.CopyContents]:"copyContents",[te.ModifyAnnotations]:"modifyAnnotations",[te.FillForms]:"fillForms",[te.ExtractForAccessibility]:"extractForAccessibility",[te.AssembleDocument]:"assembleDocument",[te.PrintHighQuality]:"printHighQuality"};function Au(t,e){if(!t)return;if(e in t)return t[e];const n=eb[e];if(n&&n in t)return t[n]}function ms(t,e,n){var o;const r=t.documents[e],a=r==null?void 0:r.permissions,i=t.globalPermissions,s=((o=r==null?void 0:r.document)==null?void 0:o.permissions)??te.AllowAll,l=Au(a==null?void 0:a.overrides,n);if(l!==void 0)return l;const c=Au(i==null?void 0:i.overrides,n);return c!==void 0?c:(a==null?void 0:a.enforceDocumentPermissions)??(i==null?void 0:i.enforceDocumentPermissions)??!0?(s&n)!==0:!0}function tb(t,e){return JF.reduce((n,o)=>ms(t,e,o)?n|o:n,0)}function Ps(t){const e=Eu();return P(()=>{var n,o;const r=$t(t),a=e.value;if(!a)return{permissions:te.AllowAll,pdfPermissions:te.AllowAll,hasPermission:()=>!0,hasAllPermissions:()=>!0,canPrint:!0,canModifyContents:!0,canCopyContents:!0,canModifyAnnotations:!0,canFillForms:!0,canExtractForAccessibility:!0,canAssembleDocument:!0,canPrintHighQuality:!0};const i=tb(a,r),s=((o=(n=a.documents[r])==null?void 0:n.document)==null?void 0:o.permissions)??te.AllowAll,l=u=>ms(a,r,u);return{permissions:i,pdfPermissions:s,hasPermission:l,hasAllPermissions:(...u)=>u.every(d=>ms(a,r,d)),canPrint:l(te.Print),canModifyContents:l(te.ModifyContents),canCopyContents:l(te.CopyContents),canModifyAnnotations:l(te.ModifyAnnotations),canFillForms:l(te.FillForms),canExtractForAccessibility:l(te.ExtractForAccessibility),canAssembleDocument:l(te.AssembleDocument),canPrintHighQuality:l(te.PrintHighQuality)}})}function Nn(t){const{registry:e}=Su(),n=ln(null),o=Q(!0),r=Q(new Promise(()=>{})),a=()=>{var i;if(!e.value)return;const s=e.value.getPlugin(t);if(!s)throw new Error(`Plugin ${t} not found`);n.value=s,o.value=!1,r.value=((i=s.ready)==null?void 0:i.call(s))??Promise.resolve()};return Lo(a),Se(e,a),{plugin:n,isLoading:o,ready:r}}function It(t){const{plugin:e,isLoading:n,ready:o}=Nn(t);return{provides:P(()=>{if(!e.value)return null;if(!e.value.provides)throw new Error(`Plugin ${t} does not implement provides()`);return e.value.provides()}),isLoading:n,ready:o}}const nb=ie({__name:"nested-wrapper",props:{wrappers:{},utilities:{}},setup(t){return(e,n)=>{const o=km("NestedWrapper",!0);return v(),he(Fn(t.wrappers[0]),null,{default:We(()=>[t.wrappers.length>1?(v(),he(o,{key:0,wrappers:t.wrappers.slice(1),utilities:t.utilities},{default:We(()=>[$e(e.$slots,"default")]),_:3},8,["wrappers","utilities"])):(v(),C(pe,{key:1},[$e(e.$slots,"default"),(v(!0),C(pe,null,tt(t.utilities,(r,a)=>(v(),he(Fn(r),{key:`utility-${a}`}))),128))],64))]),_:3})}}}),ob=ie({__name:"auto-mount",props:{plugins:{}},setup(t){const e=t,n=P(()=>{const o=[],r=[];for(const a of e.plugins){const i=a.package;if(YF(i)){const s=i.autoMountElements()||[];for(const l of s)l.type==="utility"?o.push(l.component):l.type==="wrapper"&&r.push(l.component)}}return{utilities:o,wrappers:r}});return(o,r)=>n.value.wrappers.length>0?(v(),he(nb,{key:0,wrappers:n.value.wrappers,utilities:n.value.utilities},{default:We(()=>[$e(o.$slots,"default")]),_:3},8,["wrappers","utilities"])):(v(),C(pe,{key:1},[$e(o.$slots,"default"),(v(!0),C(pe,null,tt(n.value.utilities,(a,i)=>(v(),he(Fn(a),{key:`utility-${i}`}))),128))],64))}}),rb=ie({__name:"embed-pdf",props:{engine:{},config:{},logger:{},plugins:{},onInitialized:{},autoMountDomElements:{type:Boolean,default:!0}},setup(t){const e=t,n=ln(null),o=Q(null),r=Q(!0),a=Q(!1),i=P(()=>{var d;return((d=o.value)==null?void 0:d.activeDocumentId)??null}),s=P(()=>{var d;return((d=o.value)==null?void 0:d.documents)??{}}),l=P(()=>{var d;return((d=o.value)==null?void 0:d.documentOrder)??[]}),c=P(()=>{const d=i.value,p=s.value;return d&&p[d]?p[d]:null}),u=P(()=>{const d=s.value;return l.value.map(h=>d[h]).filter(h=>h!=null)});return pa(Du,{registry:n,coreState:o,isInitializing:r,pluginsReady:a,activeDocumentId:i,activeDocument:c,documents:s,documentStates:u}),Lo(async()=>{var d,p;const h={...e.config,logger:((d=e.config)==null?void 0:d.logger)??e.logger},g=new VF(e.engine,h);if(g.registerPluginBatch(e.plugins),await g.initialize(),g.isDestroyed())return;const f=g.getStore();o.value=f.getState().core;const F=f.subscribe((y,_,E)=>{f.isCoreAction(y)&&_.core!==E.core&&(o.value=_.core)});if(await((p=e.onInitialized)==null?void 0:p.call(e,g)),g.isDestroyed()){F();return}n.value=g,r.value=!1,g.pluginsReady().then(()=>{g.isDestroyed()||(a.value=!0)}),mr(()=>{var y;F(),(y=n.value)==null||y.destroy()})}),(d,p)=>a.value&&t.autoMountDomElements?(v(),he(ob,{key:0,plugins:t.plugins},{default:We(()=>[$e(d.$slots,"default",{registry:n.value,coreState:o.value,isInitializing:r.value,pluginsReady:a.value,activeDocumentId:i.value,activeDocument:c.value,documents:s.value,documentStates:u.value})]),_:3},8,["plugins"])):$e(d.$slots,"default",{key:1,registry:n.value,coreState:o.value,isInitializing:r.value,pluginsReady:a.value,activeDocumentId:i.value,activeDocument:c.value,documents:s.value,documentStates:u.value})}}),xu="annotation",ab={id:xu,name:"Annotation Plugin",version:"1.0.0",provides:["annotation"],requires:["interaction-manager","selection"],optional:["history","scroll"],defaultConfig:{autoCommit:!0,annotationAuthor:"Guest",deactivateToolAfterCreate:!1,selectAfterCreate:!0,autoOpenLinks:!0}},Cu="ANNOTATION/INIT_STATE",Tu="ANNOTATION/CLEANUP_STATE",ib="ANNOTATION/SET_ACTIVE_DOCUMENT",Mu="ANNOTATION/SET_ANNOTATIONS",Ru="ANNOTATION/SELECT_ANNOTATION",wu="ANNOTATION/DESELECT_ANNOTATION",Ou="ANNOTATION/ADD_TO_SELECTION",ku="ANNOTATION/REMOVE_FROM_SELECTION",Iu="ANNOTATION/SET_SELECTION",Gu="ANNOTATION/SET_ACTIVE_TOOL_ID",Lu="ANNOTATION/CREATE_ANNOTATION",$u="ANNOTATION/PATCH_ANNOTATION",Nu="ANNOTATION/MOVE_ANNOTATION",ju="ANNOTATION/DELETE_ANNOTATION",Uu="ANNOTATION/COMMIT",Bu="ANNOTATION/PURGE_ANNOTATION",zu="ANNOTATION/SET_LOCKED",Wu="ANNOTATION/SYNC_OBJECT",Hu="ANNOTATION/ADD_COLOR_PRESET",Vu="ANNOTATION/SET_TOOL_DEFAULTS",Yu="ANNOTATION/ADD_TOOL";function sb(t,e){return{type:Cu,payload:{documentId:t,state:e}}}function lb(t){return{type:Tu,payload:t}}const cb=(t,e)=>({type:Mu,payload:{documentId:t,annotations:e}}),ub=(t,e,n)=>({type:Ru,payload:{documentId:t,pageIndex:e,id:n}}),Fs=t=>({type:wu,payload:{documentId:t}}),bs=(t,e,n)=>({type:Ou,payload:{documentId:t,pageIndex:e,id:n}}),qu=(t,e)=>({type:ku,payload:{documentId:t,id:e}}),ys=(t,e)=>({type:Iu,payload:{documentId:t,ids:e}}),Ku=(t,e)=>({type:Gu,payload:{documentId:t,toolId:e}}),Ua=(t,e,n)=>({type:Lu,payload:{documentId:t,pageIndex:e,annotation:n}}),Ba=(t,e,n,o)=>({type:$u,payload:{documentId:t,pageIndex:e,id:n,patch:o}}),Xu=(t,e,n,o)=>({type:Nu,payload:{documentId:t,pageIndex:e,id:n,patch:o}}),_s=(t,e,n)=>({type:ju,payload:{documentId:t,pageIndex:e,id:n}}),db=(t,e)=>({type:Uu,payload:{documentId:t,committedUids:e}}),vs=(t,e,n)=>({type:Bu,payload:{documentId:t,pageIndex:e,uid:n}}),pb=(t,e)=>({type:zu,payload:{documentId:t,mode:e}}),hb=(t,e,n)=>({type:Wu,payload:{documentId:t,id:e,patch:n}}),gb=t=>({type:Hu,payload:t}),fb=(t,e)=>({type:Vu,payload:{toolId:t,patch:e}}),mb=t=>({type:Yu,payload:t});var jn=(t=>(t.None="none",t.All="all",t.Include="include",t.Exclude="exclude",t))(jn||{});function Pb(t,e){return!(t.origin.x+t.size.width<e.origin.x||e.origin.x+e.size.width<t.origin.x||t.origin.y+t.size.height<e.origin.y||e.origin.y+e.size.height<t.origin.y)}function Fb(t){return t.object.type===M.INK}function bb(t){return t.object.type===M.CIRCLE}function yb(t){return t.object.type===M.POLYGON}function _b(t){return t.object.type===M.SQUARE}function vb(t){return t.object.type===M.LINE}function Db(t){return t.object.type===M.POLYLINE}function Sb(t){return t.object.type===M.HIGHLIGHT}function Eb(t){return t.object.type===M.UNDERLINE}function Ab(t){return t.object.type===M.STRIKEOUT}function xb(t){return t.object.type===M.SQUIGGLY}function Cb(t){return Sb(t)||Eb(t)||Ab(t)||xb(t)}function Tb(t){return t.object.type===M.FREETEXT}function Mb(t){return t.object.type===M.STAMP}function Zu(t){return t.object.type===M.TEXT}function Rb(t){return t.object.type===M.REDACT}function wb(t){return t.object.type===M.CARET}function Ob(t){return t.object.type===M.WIDGET}function Ds(t){return Zu(t)&&!t.object.inReplyToId||Cb(t)||Fb(t)||_b(t)||bb(t)||yb(t)||vb(t)||Db(t)||Tb(t)||Mb(t)||Rb(t)||wb(t)}function kb(t){return Ds(t)||Ob(t)}function Ss(t){return(t==null?void 0:t.categories)??[]}function za(t,e){switch(e.type){case jn.None:return!1;case jn.All:return!0;case jn.Include:return t.length===0?!1:t.some(n=>e.categories.includes(n));case jn.Exclude:return t.length===0?!0:!t.some(n=>e.categories.includes(n))}}function Qu(t){var e;return((e=t.flags)==null?void 0:e.includes("locked"))??!1}const Ib=(t,e)=>(t.pages[e]??[]).map(n=>t.byUid[n]),Gb=t=>t.selectedUids.length>0?t.byUid[t.selectedUids[0]]??null:null,Ju=t=>t.selectedUids.map(e=>t.byUid[e]).filter(e=>e!==void 0),ed=t=>t.selectedUids,Lb=(t,e)=>t.byUid[e]??null,$b=t=>{const e={};for(const a of Object.values(t.pages))for(const i of a){const s=t.byUid[i];if(s&&Zu(s)){const l=s.object.inReplyToId;l&&(e[l]||(e[l]=[])).push(s)}}const n={},o=new Set;for(const a of Object.values(t.pages))for(const i of a){const s=t.byUid[i];if(s&&s.object.inReplyToId&&s.object.replyType===Ln.Group&&s.object.type!==M.LINK&&Ds(s)){const l=s.object.inReplyToId;(n[l]||(n[l]=[])).push(s),o.add(s.object.id)}}const r={};for(const[a,i]of Object.entries(t.pages)){const s=Number(a),l=[];for(const c of i){const u=t.byUid[c];if(!u||!Ds(u)||o.has(u.object.id))continue;const d=n[u.object.id];l.push({page:s,annotation:u,replies:e[u.object.id]??[],...d&&d.length>0?{groupMembers:d}:{}})}l.length>0&&(r[s]=l)}return r},Nb=t=>{const e=$b(t),n=[],o=Object.keys(e).map(Number).sort((r,a)=>r-a);for(const r of o)n.push(...e[r]);return n},jb=(t,e)=>{const n=[];for(const o of Object.values(t.pages))for(const r of o){const a=t.byUid[r];a&&"inReplyToId"in a.object&&a.object.inReplyToId===e&&n.push({id:a.object.id,pageIndex:a.object.pageIndex})}return n},Ub=(t,e,n)=>{const o=[];for(const r of Object.values(t.pages))for(const a of r){const i=t.byUid[a];i&&"inReplyToId"in i.object&&i.object.inReplyToId===e&&n.includes(i.object.type)&&o.push(i)}return o},Bb=(t,e)=>Ub(t,e,[M.LINK]),zb=(t,e)=>{const n=t.byUid[e];if(n)return n.object.inReplyToId&&n.object.replyType===Ln.Group?n.object.inReplyToId:e},td=(t,e)=>{const n=zb(t,e);if(!n)return[];const o=[],r=t.byUid[n];r&&r.object.type!==M.LINK&&o.push(r);for(const a of Object.values(t.pages))for(const i of a){const s=t.byUid[i];s&&s.object.inReplyToId===n&&s.object.replyType===Ln.Group&&s.object.type!==M.LINK&&o.push(s)}return o},nd=(t,e)=>{const n=t.byUid[e];if(!n||n.object.type===M.LINK)return!1;if(n.object.inReplyToId&&n.object.replyType===Ln.Group)return!0;for(const o of Object.values(t.pages))for(const r of o){const a=t.byUid[r];if(a&&a.object.inReplyToId===e&&a.object.replyType===Ln.Group&&a.object.type!==M.LINK)return!0}return!1},Wb=t=>{const e=Ju(t);if(e.length===0)return"disabled";const n=e[0].object.id;if(nd(t,n)){const o=td(t,n),r=new Set(o.map(a=>a.object.id));if(e.every(a=>r.has(a.object.id)))return"ungroup"}return e.length>=2?"group":"disabled"};function qt(t){let e=t;return[()=>e,r=>{e=r}]}function Hb(t,e){if(t.length<3)return!0;const n=t[0],o=t[t.length-1],r=Math.hypot(o.x-n.x,o.y-n.y);return r<5?!1:t.reduce((i,s)=>{const l=Math.abs((o.x-n.x)*(n.y-s.y)-(n.x-s.x)*(o.y-n.y))/r;return Math.max(i,l)},0)/r<e}const Es={annotationType:M.INK,create(t){const{onCommit:e,onPreview:n,getTool:o,pageSize:r}=t,[a,i]=qt([]),[s,l]=qt(!1),c={current:null},u=h=>({x:et(h.x,0,r.width),y:et(h.y,0,r.height)}),d=()=>{const h=o();return h?{...h.defaults,strokeWidth:h.defaults.strokeWidth??1,strokeColor:h.defaults.strokeColor??h.defaults.color??"#000000",opacity:h.defaults.opacity??1,flags:h.defaults.flags??["print"]}:null},p=()=>{const h=a();if(h.length===0||h[0].points.length===0)return null;const g=d();if(!g)return null;const f=h.flatMap(y=>y.points),F=_n(cn(f),g.strokeWidth/2);return{type:M.INK,bounds:F,data:{...g,rect:F,inkList:h,blendMode:g.blendMode}}};return{onPointerDown:(h,g)=>{var f;const F=u(h);l(!0),c.current&&clearTimeout(c.current);const y=[...a(),{points:[F]}];i(y),n(p()),(f=g.setPointerCapture)==null||f.call(g)},onPointerMove:h=>{if(!s())return;const g=a();if(g.length===0)return;const f=u(h);g[g.length-1].points.push(f),i(g),n(p())},onPointerUp:(h,g)=>{var f;l(!1),(f=g.releasePointerCapture)==null||f.call(g);const F=o(),y=F==null?void 0:F.behavior;if(y!=null&&y.smartLineRecognition){const E=y.smartLineThreshold??.15,A=a(),T=A[A.length-1];if(T&&T.points.length>1&&Hb(T.points,E)){const q=T.points[0],w=T.points[T.points.length-1],G=w.x-q.x,W=w.y-q.y,J=Math.atan2(Math.abs(W),Math.abs(G))*(180/Math.PI),ue=y.snapAngleDeg??15;if(J<=ue){const ce=T.points.reduce((ee,ge)=>ee+ge.y,0)/T.points.length;T.points=[{x:q.x,y:ce},{x:w.x,y:ce}]}else if(J>=90-ue){const ce=T.points.reduce((ee,ge)=>ee+ge.x,0)/T.points.length;T.points=[{x:ce,y:q.y},{x:ce,y:w.y}]}i([...A]),n(p())}}const _=(y==null?void 0:y.commitDelay)??800;c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{const E=a();if(E.length>0&&E[0].points.length>1){const A=d();if(!A)return;const T=E.flatMap(w=>w.points),q=_n(cn(T),A.strokeWidth/2);e({...A,inkList:E,rect:q,type:M.INK,pageIndex:t.pageIndex,id:pt(),created:new Date})}i([]),n(null)},_)},onPointerCancel:(h,g)=>{var f;i([]),l(!1),n(null),c.current&&clearTimeout(c.current),(f=g.releasePointerCapture)==null||f.call(g)}}}};function od(t){const e=n=>{const o=n*9,r=Math.PI/6;return{x:-o*Math.cos(r),y:o*Math.sin(r)}};return{getSvgPath:n=>{const{x:o,y:r}=e(n);return t?`M 0 0 L ${o} ${r} L ${o} ${-r} Z`:`M ${o} ${r} L 0 0 L ${o} ${-r}`},getLocalPoints:n=>{const{x:o,y:r}=e(n);return[{x:0,y:0},{x:o,y:r},{x:o,y:-r}]},getRotation:n=>n,filled:t}}function rd(t,e){const n=o=>o*t/2;return{getSvgPath:o=>{const r=n(o);return`M ${-r} 0 L ${r} 0`},getLocalPoints:o=>{const r=n(o);return[{x:-r,y:0},{x:r,y:0}]},getRotation:e,filled:!1}}const ad=od(!1),id=od(!0),As={[Ct.OpenArrow]:ad,[Ct.ClosedArrow]:id,[Ct.ROpenArrow]:{...ad,getRotation:t=>t+Math.PI},[Ct.RClosedArrow]:{...id,getRotation:t=>t+Math.PI},[Ct.Circle]:{getSvgPath:t=>{const e=t*5/2;return`M ${e} 0 A ${e} ${e} 0 1 1 ${-e} 0 A ${e} ${e} 0 1 1 ${e} 0`},getLocalPoints:t=>{const e=t*5/2;return[{x:-e,y:-e},{x:e,y:e}]},getRotation:()=>0,filled:!0},[Ct.Square]:{getSvgPath:t=>{const e=t*6/2;return`M ${-e} ${-e} L ${e} ${-e} L ${e} ${e} L ${-e} ${e} Z`},getLocalPoints:t=>{const e=t*6/2;return[{x:-e,y:-e},{x:e,y:-e},{x:e,y:e},{x:-e,y:e}]},getRotation:t=>t,filled:!0},[Ct.Diamond]:{getSvgPath:t=>{const e=t*6/2;return`M 0 ${-e} L ${e} 0 L 0 ${e} L ${-e} 0 Z`},getLocalPoints:t=>{const e=t*6/2;return[{x:0,y:-e},{x:e,y:0},{x:0,y:e},{x:-e,y:0}]},getRotation:t=>t,filled:!0},[Ct.Butt]:rd(6,t=>t+Math.PI/2),[Ct.Slash]:rd(18,t=>t+Math.PI/1.5)},Vb=1.2;function Yb(t,e=0){if(t.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};const n=cn(t);return e>0?_n(n,e):n}function Jt(t,e,n){if(!t||t.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};const o=[...t],r=(l,c)=>Math.atan2(c.y-l.y,c.x-l.x),a=(l,c,u)=>{if(!l)return;const d=As[l];if(!d)return;const p=d.getLocalPoints(e),h=d.getRotation(u),g=p.map(f=>nF(f,h,c));o.push(...g)};if(t.length>=2){const l=r(t[1],t[0]);a(n==null?void 0:n.start,t[0],l);const c=t.length-1,u=r(t[c-1],t[c]);a(n==null?void 0:n.end,t[c],u)}if(o.length<=1){const l=t[0]||{x:0,y:0},c=e;return{origin:{x:l.x-c,y:l.y-c},size:{width:c*2,height:c*2}}}const i=cn(o),s=e/2+Vb*e;return _n(i,s)}function Wa(t,e){if(!t.unrotatedRect)return{rect:e};const n=yo(e);return{rect:Qn(e,t.rotation??0,n),unrotatedRect:e}}function Jn(t){return t.unrotatedRect?uu(t.unrotatedRect,t.rect,t.rotation??0):yo(t.rect)}function xs(t,e,n){const o=Jn(t),r=t.unrotatedRect??t.rect,a={x:e.origin.x-r.origin.x,y:e.origin.y-r.origin.y},i={x:o.x+a.x,y:o.y+a.y};return{rect:Qn(e,n,i),unrotatedRect:e}}function Ha(t,e,n){if(!t.unrotatedRect)return e;const o=t.rotation??0;if(Math.abs(o%360)<1e-8)return e;const r=Jn(t),a=yo(n),i=o*Math.PI/180,s=Math.cos(i),l=Math.sin(i),c=r.x-a.x,u=r.y-a.y,d=(1-s)*c+l*u,p=-l*c+(1-s)*u;return Math.abs(d)<1e-8&&Math.abs(p)<1e-8?e:e.map(h=>({x:h.x+d,y:h.y+p}))}function qb(t,e,n,o,r){if(!t)return null;const a=As[t];if(!a)return null;const i=l=>l*180/Math.PI,s=a.getRotation(n);return{d:a.getSvgPath(e),transform:`translate(${o} ${r}) rotate(${i(s)})`,filled:a.filled}}class sd{constructor(){this.patches=new Map}register(e,n){this.patches.set(e,n)}transform(e,n){const o=this.patches.get(e.type);return o?o(e,n):n.changes}}const Kb=new sd;function eo(t,e){var n;if(((n=e.metadata)==null?void 0:n.rotationAngle)===void 0)return null;const o=e.metadata.rotationAngle,r=e.changes.unrotatedRect??t.unrotatedRect??t.rect,a={origin:{...r.origin},size:{...r.size}};return{...xs(t,a,o),rotation:o}}function Mr(t,e){const n=t.unrotatedRect??t.rect;return{rotation:e,...xs(t,n,e)}}function to(t,e){const n=e.origin.x-t.rect.origin.x,o=e.origin.y-t.rect.origin.y,r={rect:e};return t.unrotatedRect&&(r.unrotatedRect={origin:{x:t.unrotatedRect.origin.x+n,y:t.unrotatedRect.origin.y+o},size:{...t.unrotatedRect.size}}),{dx:n,dy:o,rects:r}}function no(t,e,n){const o=t.unrotatedRect??t.rect;let r=e.size.width/o.size.width,a=e.size.height/o.size.height;const i=10;if((e.size.width<i||e.size.height<i)&&(r=Math.max(r,i/o.size.width),a=Math.max(a,i/o.size.height),e={origin:e.origin,size:{width:o.size.width*r,height:o.size.height*a}}),n!=null&&n.maintainAspectRatio){const l=Math.min(r,a);r=l,a=l,e={origin:e.origin,size:{width:o.size.width*l,height:o.size.height*l}}}const s=t.unrotatedRect?{unrotatedRect:e,rect:Qi(e,t.rotation??0)}:{rect:e};return{scaleX:r,scaleY:a,oldRect:o,resolvedRect:e,rects:s}}function Va(t,e){const n=t.unrotatedRect??t.rect,o=e.unrotatedRect??n;return{dx:o.origin.x-n.origin.x,dy:o.origin.y-n.origin.y}}function Ya(t,e,n){if(e===0||t.rotation!==void 0)return t;const o=(4-e)%4*90;let r=t;if(n&&(e===1||e===3)){const l=t.rect,c=l.origin.x+l.size.width/2,u=l.origin.y+l.size.height/2;r={...t,rect:{origin:{x:c-l.size.height/2,y:u-l.size.width/2},size:{width:l.size.height,height:l.size.width}}}}const{rotation:a,rect:i,unrotatedRect:s}=Mr(r,o);return{...r,rotation:a,rect:i,unrotatedRect:s}}function qa(t,e){const n=et(t.rect.origin.x,0,e.width-t.rect.size.width),o=et(t.rect.origin.y,0,e.height-t.rect.size.height),r=n-t.rect.origin.x,a=o-t.rect.origin.y;return r===0&&a===0?t:{...t,rect:{origin:{x:n,y:o},size:t.rect.size},...t.unrotatedRect?{unrotatedRect:{origin:{x:t.unrotatedRect.origin.x+r,y:t.unrotatedRect.origin.y+a},size:t.unrotatedRect.size}}:{}}}const Ka=Object.freeze(Object.defineProperty({__proto__:null,LINE_ENDING_HANDLERS:As,PatchRegistry:sd,applyInsertUpright:Ya,calculateAABBFromVertices:Yb,calculateRotatedRectAABB:Qi,calculateRotatedRectAABBAroundPoint:Qn,clampAnnotationToPage:qa,compensateRotatedVertexEdit:Ha,createEnding:qb,getRectCenter:yo,lineRectWithEndings:Jt,patchRegistry:Kb,resolveAnnotationRotationCenter:Jn,resolveRotateRects:xs,resolveVertexEditRects:Wa,rotatePointAroundCenter:_o,rotateVertices:cu},Symbol.toStringTag,{value:"Module"})),Xa=24,ld={annotationType:M.TEXT,create(t){const{onCommit:e,getTool:n,pageSize:o}=t;return{onPointerDown:r=>{const a=n();if(!a)return;const i={origin:{x:r.x-Xa/2,y:r.y-Xa/2},size:{width:Xa,height:Xa}};let s={...a.defaults,rect:i,type:M.TEXT,icon:a.defaults.icon??Ji.Comment,contents:a.defaults.contents??"",flags:a.defaults.flags??["print","noRotate","noZoom"],pageIndex:t.pageIndex,id:pt(),created:new Date};s=qa(s,o),e(s)}}}};function Rr({threshold:t=5,getTool:e,onClickDetected:n}){const[o,r]=qt(null),[a,i]=qt(!1);return{onStart:s=>{r(s),i(!1)},onMove:s=>{const l=o();if(!l||a())return;Math.sqrt(Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2))>t&&i(!0)},onEnd:s=>{var l;if(o()&&!a()){const u=e();u&&"clickBehavior"in u&&((l=u.clickBehavior)!=null&&l.enabled)&&n(s,u)}r(null),i(!1)},hasMoved:a,reset:()=>{r(null),i(!1)}}}const cd={annotationType:M.FREETEXT,create(t){const{onCommit:e,onPreview:n,getTool:o,pageSize:r,pageIndex:a,pageRotation:i}=t,[s,l]=qt(null),c=h=>({x:et(h.x,0,r.width),y:et(h.y,0,r.height)}),u=()=>{const h=o();return h?{...h.defaults,fontColor:h.defaults.fontColor??"#000000",opacity:h.defaults.opacity??1,fontSize:h.defaults.fontSize??12,fontFamily:h.defaults.fontFamily??mt.Helvetica,color:h.defaults.color??h.defaults.backgroundColor??"transparent",textAlign:h.defaults.textAlign??Vt.Left,verticalAlign:h.defaults.verticalAlign??Ar.Top,contents:h.defaults.contents??"Insert text here",flags:h.defaults.flags??["print"]}:null},d=Rr({threshold:5,getTool:o,onClickDetected:(h,g)=>{var f;const F=u();if(!F)return;const y=g.clickBehavior;if(!(y!=null&&y.enabled))return;const{width:_,height:E}=y.defaultSize,A={origin:{x:h.x-_/2,y:h.y-E/2},size:{width:_,height:E}},T=y.defaultContent??F.contents;let q={...F,contents:T,type:M.FREETEXT,rect:A,pageIndex:a,id:pt(),created:new Date};(f=g.behavior)!=null&&f.insertUpright&&(q=Ya(q,i,!1)),q=qa(q,r),e(q)}}),p=h=>{const g=s();if(!g)return null;const f=u();if(!f)return null;const F=Math.min(g.x,h.x),y=Math.min(g.y,h.y),_=Math.abs(g.x-h.x),E=Math.abs(g.y-h.y),A={origin:{x:F,y},size:{width:_,height:E}};return{type:M.FREETEXT,bounds:A,data:{...f,rect:A}}};return{onPointerDown:(h,g)=>{var f;const F=c(h);l(F),d.onStart(F),n(p(F)),(f=g.setPointerCapture)==null||f.call(g)},onPointerMove:h=>{const g=c(h);d.onMove(g),s()&&d.hasMoved()&&n(p(g))},onPointerUp:(h,g)=>{var f,F;const y=s();if(!y)return;const _=u();if(!_)return;const E=c(h);if(!d.hasMoved())d.onEnd(E);else{const A=Math.min(y.x,E.x),T=Math.min(y.y,E.y),q=Math.abs(y.x-E.x),w=Math.abs(y.y-E.y),G={origin:{x:A,y:T},size:{width:q,height:w}},W=o();let J={..._,type:M.FREETEXT,rect:G,pageIndex:t.pageIndex,id:pt(),created:new Date};(f=W==null?void 0:W.behavior)!=null&&f.insertUpright&&(J=Ya(J,i,!0)),e(J)}l(null),n(null),d.reset(),(F=g.releasePointerCapture)==null||F.call(g)},onPointerLeave:(h,g)=>{var f;l(null),n(null),d.reset(),(f=g.releasePointerCapture)==null||f.call(g)},onPointerCancel:(h,g)=>{var f;l(null),n(null),d.reset(),(f=g.releasePointerCapture)==null||f.call(g)}}}},Cs={annotationType:M.LINE,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,strokeWidth:p.defaults.strokeWidth??1,lineEndings:p.defaults.lineEndings??{start:Ct.None,end:Ct.None},color:p.defaults.color??"#000000",opacity:p.defaults.opacity??1,strokeStyle:p.defaults.strokeStyle??rt.SOLID,strokeDashArray:p.defaults.strokeDashArray??[],strokeColor:p.defaults.strokeColor??"#000000",flags:p.defaults.flags??["print"]}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const F=f.defaultAngle??0,_=f.defaultLength/2,E=p.x-_*Math.cos(F),A=p.y-_*Math.sin(F),T=p.x+_*Math.cos(F),q=p.y+_*Math.sin(F),w=l({x:E,y:A}),G=l({x:T,y:q}),W=Jt([w,G],g.strokeWidth,g.lineEndings);n({...g,rect:W,linePoints:{start:w,end:G},pageIndex:e,id:pt(),created:new Date,type:M.LINE})}}),d=p=>{const h=i();if(!h)return null;const g=c();if(!g)return null;const f=Jt([h,p],g.strokeWidth,g.lineEndings);return{type:M.LINE,bounds:f,data:{...g,rect:f,linePoints:{start:h,end:p}}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;const f=i();if(!f)return;const F=l(p);if(!u.hasMoved())u.onEnd(F);else{const y=c();if(!y)return;if(Math.abs(F.x-f.x)>2||Math.abs(F.y-f.y)>2){const _=Jt([f,F],y.strokeWidth,y.lineEndings);n({...y,rect:_,linePoints:{start:f,end:F},pageIndex:e,id:pt(),flags:["print"],created:new Date,type:M.LINE})}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},ud={annotationType:M.POLYLINE,create(t){const{onCommit:e,onPreview:n,getTool:o,pageSize:r}=t,[a,i]=qt([]),[s,l]=qt(null),c=h=>({x:et(h.x,0,r.width),y:et(h.y,0,r.height)}),u=()=>{const h=o();return h?{...h.defaults,strokeWidth:h.defaults.strokeWidth??1,lineEndings:h.defaults.lineEndings??{start:Ct.None,end:Ct.None},color:h.defaults.color??"#000000",opacity:h.defaults.opacity??1,strokeColor:h.defaults.strokeColor??"#000000",strokeStyle:h.defaults.strokeStyle??rt.SOLID,strokeDashArray:h.defaults.strokeDashArray??[],flags:h.defaults.flags??["print"]}:null},d=()=>{const h=a();if(h.length<2)return;const g=u();if(!g)return;const f=Jt(h,g.strokeWidth,g.lineEndings),F={...g,vertices:h,rect:f,type:M.POLYLINE,pageIndex:t.pageIndex,id:pt(),created:new Date};e(F),i([]),l(null),n(null)},p=()=>{const h=a(),g=s();if(h.length===0||!g)return null;const f=u();if(!f)return null;const F=[...h,g],y=Jt(F,f.strokeWidth,f.lineEndings);return{type:M.POLYLINE,bounds:y,data:{...f,rect:y,vertices:F,currentVertex:g}}};return{onClick:(h,g)=>{if(g.metaKey||g.ctrlKey)return;const f=c(h),F=a(),y=F[F.length-1];y&&Math.abs(y.x-f.x)<1&&Math.abs(y.y-f.y)<1||(i([...F,f]),l(f),n(p()))},onDoubleClick:()=>{d()},onPointerMove:h=>{if(a().length>0){const g=c(h);l(g),n(p())}},onPointerCancel:()=>{i([]),l(null),n(null)}}}};function dd(t,e,n,o){const r=o*Math.PI/180,a=Math.abs(Math.cos(r)),i=Math.abs(Math.sin(r)),s=a*a-i*i,l=t.size.width,c=t.size.height;let u,d;if(Math.abs(s)>1e-6)u=(a*l-i*c)/s,d=(a*c-i*l)/s,u=Math.max(u,1),d=Math.max(d,1);else{const g=e.size.width*e.size.height,f=l*c,F=g>0?Math.sqrt(f/g):1;u=n.size.width*F,d=n.size.height*F}const p=t.origin.x+l/2,h=t.origin.y+c/2;return{origin:{x:p-u/2,y:h-d/2},size:{width:u,height:d}}}const Yo=Math.PI,wr=Math.PI/2,Un=34*Math.PI/180,pd=30*Math.PI/180,Ts=12*Math.PI/180;class Ms{constructor(){this.parts=[],this.bbox={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},this.started=!1}moveTo(e,n){const o=-n;this.updateBBox(e,o),this.parts.push(`M ${oo(e)} ${oo(o)}`),this.started=!0}curveTo(e,n,o,r,a,i){const s=-n,l=-r,c=-i;this.updateBBox(e,s),this.updateBBox(o,l),this.updateBBox(a,c),this.parts.push(`C ${oo(e)} ${oo(s)}, ${oo(o)} ${oo(l)}, ${oo(a)} ${oo(c)}`)}close(){this.started&&this.parts.push("Z")}build(e){const n=e>0?e/2:0;return{path:this.parts.join(" "),bbox:{minX:this.bbox.minX-n,minY:this.bbox.minY-n,maxX:this.bbox.maxX+n,maxY:this.bbox.maxY+n}}}updateBBox(e,n){e<this.bbox.minX&&(this.bbox.minX=e),n<this.bbox.minY&&(this.bbox.minY=n),e>this.bbox.maxX&&(this.bbox.maxX=e),n>this.bbox.maxY&&(this.bbox.maxY=n)}}function oo(t){return Number(t.toFixed(4)).toString()}function Or(t,e){const n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}function hd(t,e){return e===0?0:t/e}function gd(t,e){return e===0?0:t/e}function Xb(t){let e=0;const n=t.length;for(let o=0;o<n;o++){const r=(o+1)%n;e+=t[o].x*t[r].y-t[o].y*t[r].x}return e}function Zb(t){Xb(t)<0&&t.reverse()}function Qb(t){if(t.length<=2)return t;const e=.5,n=[t[0]];for(let o=1;o<t.length;o++){const r=n[n.length-1],a=t[o];(Math.abs(a.x-r.x)>=e||Math.abs(a.y-r.y)>=e)&&n.push(a)}return n}function qo(t,e,n,o,r,a,i,s){const l=Math.cos(t),c=Math.sin(t),u=Math.cos(e),d=Math.sin(e),p=Math.sin((e-t)/2);if(p===0){s&&i.moveTo(n+r*l,o+a*c);return}const h=4/3*(1-Math.cos((e-t)/2))/p,g=n+r*(l-h*c),f=o+a*(c+h*l),F=n+r*(u+h*d),y=o+a*(d-h*u),_=n+r*u,E=o+a*d;s&&i.moveTo(n+r*l,o+a*c),i.curveTo(g,f,F,y,_,E)}function Rs(t,e,n,o,r,a){const i=Math.cos(t),s=Math.sin(t),l=Math.cos(e),c=Math.sin(e),u=Math.sin((e-t)/2);if(u===0)return[];const d=4/3*(1-Math.cos((e-t)/2))/u;return[{x:n+r*(i-d*s),y:o+a*(s+d*i)},{x:n+r*(l+d*c),y:o+a*(c-d*l)},{x:n+r*l,y:o+a*c}]}function kr(t,e,n,o,r,a,i,s){const l=wr;let c=e-t;for(;c<0;)c+=2*Math.PI;const u=c;let d=0;for(s&&i.moveTo(r+n*Math.cos(t),a+o*Math.sin(t));c>l;)qo(t+d,t+d+l,r,a,n,o,i,!1),d+=l,c-=l;c>0&&qo(t+d,t+u,r,a,n,o,i,!1)}function fd(t,e,n,o,r,a,i,s,l){let c=t+Yo+i;const u=t+Yo+i-22*Math.PI/180;qo(c,u,o,r,n,n,s,l),c=u;const d=e-a;kr(c,d,n,n,o,r,s,!1)}function Jb(t,e,n,o,r,a){const i=t+Yo;qo(i+n,i+n-pd,o,r,e,e,a,!1),qo(i+n-pd,i+wr,o,r,e,e,a,!1),qo(i+wr,i+Yo-Un,o,r,e,e,a,!1)}function ey(t,e){const n=[],o=t+Yo;return n.push(...Rs(o+Un,o+Ts,0,0,e,e)),n.push(...Rs(o+Ts,o+wr,0,0,e,e)),n.push(...Rs(o+wr,o+Yo-Un,0,0,e,e)),n}function ty(t,e,n,o){for(let r=0;r+2<t.length;r+=3){const a=t[r],i=t[r+1],s=t[r+2];o.curveTo(a.x+e,a.y+n,i.x+e,i.y+n,s.x+e,s.y+n)}}function ny(t,e,n){if(n===0)return{n:-1,adjustedRadius:t};const o=2*e*t,r=n-o;if(r<=0)return{n:0,adjustedRadius:t};const a=2*e*t,i=Math.max(1,Math.ceil(r/a)),s=r/(i*2*e);return{n:i,adjustedRadius:s}}function ws(t,e,n,o,r){let a=Qb(t);Zb(a);const i=a.length;if(i<2)return;if(n<=0){r.moveTo(a[0].x,a[0].y);for(let p=1;p<i;p++)r.curveTo(a[p].x,a[p].y,a[p].x,a[p].y,a[p].x,a[p].y);return}let s=e?Os(n,o):md(n,o);s<.5&&(s=.5);const l=Math.cos(Un),c=[];for(let p=0;p+1<i;p++){const h=Or(a[p],a[p+1]);h<=0||h>=2*l*s?c.push(Un):c.push(Math.acos(Math.min(1,h/(2*s))))}let u=0,d=!1;for(let p=0;p+1<i;p++){const h=a[p],g=a[p+1],f=Or(h,g);if(f===0)continue;const F=ny(s,l,f);if(F.n<0){d||(r.moveTo(h.x,h.y),d=!0);continue}const y=Math.max(.5,F.adjustedRadius),_=2*l*y,E=l*s+l*y;let A=Math.atan2(g.y-h.y,g.x-h.x);if(p===0){const ce=a[i-2];u=Math.atan2(h.y-ce.y,h.x-ce.x)}const T=hd(g.x-h.x,f),q=gd(g.y-h.y,f);let w=h.x,G=h.y;const W=c[p],J=p===0?i-2:p-1,ue=c[J]??Un;if(fd(u,A,s,h.x,h.y,W,ue,r,!d),d=!0,F.n===0)w+=f*T,G+=f*q;else{w+=E*T,G+=E*q;let ce=F.n;F.n>=1&&(Jb(A,y,Un,w,G,r),w+=_*T,G+=_*q,ce=F.n-1);const ee=ey(A,y);for(let ge=0;ge<ce;ge++)ty(ee,w,G,r),w+=_*T,G+=_*q}u=A}}function oy(t,e,n,o){const r=(t+n)/2,a=(e+o)/2,i=(n-t)/2,s=(o-e)/2;if(i<=0||s<=0)return[];const l=Math.max(32,Math.ceil(Math.max(i,s)*2)),c=[];for(let u=0;u<=l;u++){const d=2*Math.PI*u/l;c.push({x:r+i*Math.cos(d),y:a+s*Math.sin(d)})}return c}function Os(t,e){return 4.75*t+.5*e}function md(t,e){return 4*t+.5*e}function ry(t,e,n,o,r,a,i){if(r<=0){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,ye=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,ye,Ee,i,!0);return}const s=n-t,l=o-e;let c=Os(r,a);const u=.5*c;if(s<u&&l<u){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,ye=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,ye,Ee,i,!0);return}const d=5;if(s<d&&l>20||s>20&&l<d){ws([{x:t,y:e},{x:n,y:e},{x:n,y:o},{x:t,y:o},{x:t,y:e}],!0,r,a,i);return}const p=Math.sin(Ts)*c-1.5;let h=t,g=n,f=e,F=o;if(s>2*p)h+=p,g-=p;else{const ee=(t+n)/2;h=ee-.1,g=ee+.1}if(l>2*p)f+=p,F-=p;else{const ee=(o+e)/2;F=ee+.1,f=ee-.1}const y=oy(h,f,g,F),_=y.length;if(_<2)return;let E=0;for(let ee=1;ee<_;ee++)E+=Or(y[ee-1],y[ee]);const A=Math.cos(Un);let T=2*A*c,q=Math.ceil(E/T);if(q<2){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,ye=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,ye,Ee,i,!0);return}if(T=E/q,c=T/(2*A),c<.5)c=.5,T=2*A*c;else if(c<3){const ee=Math.abs(n-t)/2,ge=Math.abs(o-e)/2,ye=(t+n)/2,Ee=(e+o)/2;kr(0,2*Math.PI,ee,ge,ye,Ee,i,!0);return}const w=[];let G=0;const W=a*.1;for(let ee=0;ee+1<_;ee++){const ge=y[ee],ye=y[ee+1],Ee=ye.x-ge.x,Te=ye.y-ge.y,oe=Or(ge,ye);if(oe===0)continue;let He=oe+G;if(He>=T-W||ee===_-2){const ft=hd(Ee,oe),Ve=gd(Te,oe);let O=T-G;for(;He>=T-W;)w.push({x:ge.x+O*ft,y:ge.y+O*Ve}),He-=T,O+=T;G=Math.max(0,He)}else G+=oe}const J=w.length;let ue=0,ce=0;for(let ee=0;ee<J;ee++){const ge=(ee+1)%J,ye=w[ee],Ee=w[ge];if(ee===0){const He=w[J-1];ue=Math.atan2(ye.y-He.y,ye.x-He.x),ce=Pd(He,ye,c,T)}const Te=Math.atan2(Ee.y-ye.y,Ee.x-ye.x),oe=Pd(ye,Ee,c,T);fd(ue,Te,c,ye.x,ye.y,oe,ce,i,ee===0),ue=Te,ce=oe}}function Pd(t,e,n,o){const r=Or(t,e);if(r===0)return Un;const a=r-o,i=(o/2+a/2)/n;return i<-1||i>1?0:Math.acos(i)}function en(t,e,n){return(n?Os(t,e):md(t,e))+e/2}function ay(t,e,n,o){const r=new Ms;let a=0,i=0,s=t.width,l=t.height;e?(a+=e.left,i+=e.top,s-=e.right,l-=e.bottom):(a+=o/2,i+=o/2,s-=o/2,l-=o/2);const c=[{x:a,y:-i},{x:s,y:-i},{x:s,y:-l},{x:a,y:-l},{x:a,y:-i}];return ws(c,!1,n,o,r),r.close(),r.build(o)}function iy(t,e,n,o){const r=new Ms;let a=0,i=0,s=t.width,l=t.height;return e&&(a+=e.left,i+=e.top,s-=e.right,l-=e.bottom),ry(a,-l,s,-i,n,o,r),r.close(),r.build(o)}function sy(t,e,n,o){const r=new Ms;if(t.length<3)return r.build(o);const a=t.map(l=>({x:l.x-e.x,y:-(l.y-e.y)})),i=a[0],s=a[a.length-1];return(i.x!==s.x||i.y!==s.y)&&a.push({x:i.x,y:i.y}),ws(a,!1,n,o,r),r.close(),r.build(o)}const ly=14,Fd={annotationType:M.POLYGON,create(t){const{onCommit:e,onPreview:n,getTool:o,scale:r,pageSize:a}=t,[i,s]=qt([]),[l,c]=qt(null),u=f=>({x:et(f.x,0,a.width),y:et(f.y,0,a.height)}),d=f=>{const F=i();if(F.length<2)return!1;const _=ly/r/2,E=F[0];return f.x>=E.x-_&&f.x<=E.x+_&&f.y>=E.y-_&&f.y<=E.y+_},p=()=>{const f=o();return f?{...f.defaults,color:f.defaults.color??"#000000",opacity:f.defaults.opacity??1,strokeWidth:f.defaults.strokeWidth??1,strokeColor:f.defaults.strokeColor??"#000000",strokeStyle:f.defaults.strokeStyle??rt.SOLID,strokeDashArray:f.defaults.strokeDashArray??[],flags:f.defaults.flags??["print"]}:null},h=()=>{const f=i();if(f.length<3)return;const F=p();if(!F)return;const y=F.cloudyBorderIntensity??0,_=y>0?en(y,F.strokeWidth,!1):F.strokeWidth/2,E=_n(cn(f),_),A={...F,vertices:f,rect:E,type:M.POLYGON,pageIndex:t.pageIndex,id:pt(),created:new Date,...y>0&&{rectangleDifferences:{left:_,top:_,right:_,bottom:_}}};e(A),s([]),c(null),n(null)},g=()=>{const f=i(),F=l();if(f.length===0||!F)return null;const y=p();if(!y)return null;const _=y.cloudyBorderIntensity??0,E=_>0?en(_,y.strokeWidth,!1):y.strokeWidth/2,A=[...f,F],T=_n(cn(A),E);return{type:M.POLYGON,bounds:T,data:{...y,rect:T,vertices:f,currentVertex:F}}};return{onClick:(f,F)=>{if(F.metaKey||F.ctrlKey)return;const y=u(f);if(d(y)&&i().length>=3){h();return}const _=i(),E=_[_.length-1];E&&Math.abs(E.x-y.x)<1&&Math.abs(E.y-y.y)<1||(s([..._,y]),c(y),n(g()))},onDoubleClick:f=>{h()},onPointerMove:f=>{if(i().length>0){const F=u(f);c(F),n(g())}},onPointerCancel:f=>{s([]),c(null),n(null)}}}},bd={annotationType:M.SQUARE,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,flags:p.defaults.flags??["print"],strokeWidth:p.defaults.strokeWidth??2,strokeColor:p.defaults.strokeColor??"#000000",strokeStyle:p.defaults.strokeStyle??rt.SOLID,strokeDashArray:p.defaults.strokeDashArray??[],color:p.defaults.color??"#000000",opacity:p.defaults.opacity??1}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const{width:F,height:y}=f.defaultSize,_=F/2,E=y/2,A=et(p.x-_,0,a.width-F),T=et(p.y-E,0,a.height-y),q=g.strokeWidth,w=g.cloudyBorderIntensity??0,G=w>0?en(w,q,!1):q/2,W={origin:{x:A-G,y:T-G},size:{width:F+2*G,height:y+2*G}},J={...g,type:M.SQUARE,created:new Date,id:pt(),pageIndex:e,rect:W,...w>0&&{rectangleDifferences:{left:G,top:G,right:G,bottom:G}}};n(J)}}),d=p=>{const h=i();if(!h)return null;const g=Math.min(h.x,p.x),f=Math.min(h.y,p.y),F=Math.abs(h.x-p.x),y=Math.abs(h.y-p.y),_=c();if(!_)return null;const E=_.strokeWidth,A=_.cloudyBorderIntensity??0,T=A>0?en(A,E,!1):E/2,q={origin:{x:g-T,y:f-T},size:{width:F+2*T,height:y+2*T}};return{type:M.SQUARE,bounds:q,data:{rect:q,..._,...A>0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;if(!i()||!c())return;const y=l(p);if(!u.hasMoved())u.onEnd(y);else{const _=c();if(!_)return;const E=d(y);if(E){const A=_.cloudyBorderIntensity??0,T=A>0?en(A,_.strokeWidth,!1):void 0,q={..._,type:M.SQUARE,created:new Date,id:pt(),pageIndex:e,rect:E.data.rect,...T!==void 0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}};n(q)}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},yd={annotationType:M.STAMP,create(t){const{services:e,onCommit:n,getTool:o,pageSize:r,pageRotation:a}=t;return{onPointerDown:i=>{const s=o();if(!s)return;const{imageSrc:l,imageSize:c}=s.defaults,u=(d,p,h)=>{var g;const f={origin:{x:i.x-p/2,y:i.y-h/2},size:{width:p,height:h}};let F={...s.defaults,rect:f,type:M.STAMP,icon:s.defaults.icon??Ji.Draft,subject:s.defaults.subject??"Stamp",flags:s.defaults.flags??["print"],pageIndex:t.pageIndex,id:pt(),created:new Date};(g=s.behavior)!=null&&g.insertUpright&&(F=Ya(F,a,!1)),F=qa(F,r),n(F,{imageData:d})};l?e.processImage({source:l,maxWidth:r.width,maxHeight:r.height,onComplete:d=>u(d.imageData,(c==null?void 0:c.width)??d.width,(c==null?void 0:c.height)??d.height)}):e.requestFile({accept:"image/png,image/jpeg",onFile:d=>{e.processImage({source:d,maxWidth:r.width,maxHeight:r.height,onComplete:p=>u(p.imageData,p.width,p.height)})}})}}}},_d={annotationType:M.CIRCLE,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,strokeWidth:p.defaults.strokeWidth??2,strokeColor:p.defaults.strokeColor??"#000000",strokeStyle:p.defaults.strokeStyle??rt.SOLID,strokeDashArray:p.defaults.strokeDashArray??[],color:p.defaults.color??"#000000",opacity:p.defaults.opacity??1,flags:p.defaults.flags??["print"]}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const{width:F,height:y}=f.defaultSize,_=F/2,E=y/2,A=et(p.x-_,0,a.width-F),T=et(p.y-E,0,a.height-y),q=g.strokeWidth,w=g.cloudyBorderIntensity??0,G=w>0?en(w,q,!0):q/2,W={origin:{x:A-G,y:T-G},size:{width:F+2*G,height:y+2*G}},J={...g,type:M.CIRCLE,created:new Date,id:pt(),pageIndex:e,rect:W,...w>0&&{rectangleDifferences:{left:G,top:G,right:G,bottom:G}}};n(J)}}),d=p=>{const h=i();if(!h)return null;const g=Math.min(h.x,p.x),f=Math.min(h.y,p.y),F=Math.abs(h.x-p.x),y=Math.abs(h.y-p.y),_=c();if(!_)return null;const E=_.strokeWidth,A=_.cloudyBorderIntensity??0,T=A>0?en(A,E,!0):E/2,q={origin:{x:g-T,y:f-T},size:{width:F+2*T,height:y+2*T}};return{type:M.CIRCLE,bounds:q,data:{rect:q,..._,...A>0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;if(!i()||!c())return;const y=l(p);if(!u.hasMoved())u.onEnd(y);else{const _=c();if(!_)return;const E=d(y);if(E){const A=_.cloudyBorderIntensity??0,T=A>0?en(A,_.strokeWidth,!0):void 0,q={..._,type:M.CIRCLE,flags:["print"],created:new Date,id:pt(),pageIndex:e,rect:E.data.rect,...T!==void 0&&{rectangleDifferences:{left:T,top:T,right:T,bottom:T}}};n(q)}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},vd={annotationType:M.LINK,create(t){const{pageIndex:e,onCommit:n,onPreview:o,getTool:r,pageSize:a}=t,[i,s]=qt(null),l=p=>({x:et(p.x,0,a.width),y:et(p.y,0,a.height)}),c=()=>{const p=r();return p?{...p.defaults,flags:p.defaults.flags??["print"],strokeWidth:p.defaults.strokeWidth??2,strokeColor:p.defaults.strokeColor??"#0000FF",strokeStyle:p.defaults.strokeStyle??rt.UNDERLINE,strokeDashArray:p.defaults.strokeDashArray??[]}:null},u=Rr({threshold:5,getTool:r,onClickDetected:(p,h)=>{const g=c();if(!g)return;const f=h.clickBehavior;if(!(f!=null&&f.enabled))return;const{width:F,height:y}=f.defaultSize,_=F/2,E=y/2,A=et(p.x-_,0,a.width-F),T=et(p.y-E,0,a.height-y),q={origin:{x:A,y:T},size:{width:F,height:y}},w={...g,type:M.LINK,target:void 0,created:new Date,id:pt(),pageIndex:e,rect:q};n(w)}}),d=p=>{const h=i();if(!h)return null;const g=Math.min(h.x,p.x),f=Math.min(h.y,p.y),F=Math.abs(h.x-p.x),y=Math.abs(h.y-p.y),_=c();if(!_)return null;const E={origin:{x:g,y:f},size:{width:F,height:y}};return{type:M.LINK,bounds:E,data:{rect:E,strokeColor:_.strokeColor,strokeWidth:_.strokeWidth,strokeStyle:_.strokeStyle,strokeDashArray:_.strokeDashArray}}};return{onPointerDown:(p,h)=>{var g;const f=l(p);s(f),u.onStart(f),o(d(f)),(g=h.setPointerCapture)==null||g.call(h)},onPointerMove:p=>{const h=l(p);u.onMove(h),i()&&u.hasMoved()&&o(d(h))},onPointerUp:(p,h)=>{var g;if(!i())return;const F=c();if(!F)return;const y=l(p);if(!u.hasMoved())u.onEnd(y);else{const _=d(y);if(_){const E={...F,type:M.LINK,target:void 0,created:new Date,id:pt(),pageIndex:e,rect:_.data.rect};n(E)}}s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerLeave:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)},onPointerCancel:(p,h)=>{var g;s(null),o(null),u.reset(),(g=h.releasePointerCapture)==null||g.call(h)}}}},cy={toolId:"__textMarkup__",handle(t,e,n){const o=t.getTool();if(o)for(const r of e){const a=pt();n().then(i=>{var s;t.createAnnotation(r.pageIndex,{...o.defaults,rect:r.rect,segmentRects:r.segmentRects,pageIndex:r.pageIndex,created:new Date,id:a,...i!=null&&{custom:{text:i}}}),(s=o.behavior)!=null&&s.selectAfterCreate&&t.selectAnnotation(r.pageIndex,a)})}}};function Dd(t){const e=t.size.height,n=e/2,o=n;return{origin:{x:t.origin.x+t.size.width-o/2,y:t.origin.y+e/2},size:{width:o,height:n}}}const uy={toolId:"insertText",handle(t,e,n){const o=t.getTool();if(!o)return;const r=()=>({strokeColor:o.defaults.strokeColor??"#E44234",opacity:o.defaults.opacity??1,flags:o.defaults.flags??["print"]});for(const a of e){const i=a.segmentRects[a.segmentRects.length-1];if(!i)continue;const s=Dd(i),l=pt(),c=r();n().then(u=>{var d;t.createAnnotation(a.pageIndex,{type:M.CARET,id:l,pageIndex:a.pageIndex,rect:s,strokeColor:c.strokeColor,opacity:c.opacity,intent:"Insert",rectangleDifferences:{left:.5,top:.5,right:.5,bottom:.5},created:new Date,flags:c.flags,...u!=null&&{custom:{text:u}}}),(d=o.behavior)!=null&&d.selectAfterCreate&&t.selectAnnotation(a.pageIndex,l)})}}},dy={toolId:"replaceText",handle(t,e,n){const o=t.getTool();if(!o)return;const r=()=>({strokeColor:o.defaults.strokeColor??"#E44234",opacity:o.defaults.opacity??1,flags:o.defaults.flags??["print"]});for(const a of e){const i=a.segmentRects[a.segmentRects.length-1];if(!i)continue;const s=Dd(i),l=pt(),c=pt(),u=r();n().then(d=>{var p;t.createAnnotation(a.pageIndex,{type:M.CARET,id:l,pageIndex:a.pageIndex,rect:s,strokeColor:u.strokeColor,opacity:u.opacity,intent:"Replace",rectangleDifferences:{left:.5,top:.5,right:.5,bottom:.5},created:new Date,flags:u.flags}),t.createAnnotation(a.pageIndex,{type:M.STRIKEOUT,id:c,pageIndex:a.pageIndex,rect:a.rect,segmentRects:a.segmentRects,strokeColor:u.strokeColor,opacity:u.opacity,intent:"StrikeOutTextEdit",inReplyToId:l,replyType:Ln.Group,created:new Date,flags:u.flags,...d!=null&&{custom:{text:d}}}),(p=o.behavior)!=null&&p.selectAfterCreate&&t.selectAnnotation(a.pageIndex,l)})}}},Sd=(t,e)=>{switch(e.type){case"vertex-edit":return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,inkList:t.inkList.map(a=>({points:a.points.map(i=>({x:i.x+n,y:i.y+o}))}))}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata),s=(A,T)=>({origin:{x:A.origin.x+T,y:A.origin.y+T},size:{width:Math.max(1,A.size.width-T*2),height:Math.max(1,A.size.height-T*2)}}),l=.001,c=Math.abs(n-1)>l,u=Math.abs(o-1)>l,d=c&&!u?n:!c&&u?o:Math.min(n,o),p=Math.max(1,t.strokeWidth*d),h=Math.max(1,Math.min(a.size.width,a.size.height)),g=Math.min(p,h),f=Number(g.toFixed(1)),F=s(r,t.strokeWidth/2),y=s(a,f/2),_=y.size.width/Math.max(F.size.width,1e-6),E=y.size.height/Math.max(F.size.height,1e-6);return{...i,inkList:t.inkList.map(A=>({points:A.points.map(T=>({x:y.origin.x+(T.x-F.origin.x)*_,y:y.origin.y+(T.y-F.origin.y)*E}))})),strokeWidth:f}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Va(t,n);return{...n,inkList:t.inkList.map(a=>({points:a.points.map(i=>({x:i.x+o,y:i.y+r}))}))}}case"property-update":{if(!(e.changes.strokeWidth!==void 0||e.changes.rotation!==void 0))return e.changes;const o={...t,...e.changes},r=o.inkList.flatMap(s=>s.points),a=_n(cn(r),o.strokeWidth/2),i=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...e.changes,unrotatedRect:a,rect:Qn(a,i,Jn(t))}:{...e.changes,rect:a}}default:return e.changes}},Ed=(t,e)=>{switch(e.type){case"vertex-edit":if(e.changes.linePoints){const{start:n,end:o}=e.changes.linePoints,r=[n,o],a=Jt(r,t.strokeWidth,t.lineEndings),i=Ha(t,r,a),s=Jt(i,t.strokeWidth,t.lineEndings);return{...Wa(t,s),linePoints:{start:i[0],end:i[1]}}}return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,linePoints:{start:{x:t.linePoints.start.x+n,y:t.linePoints.start.y+o},end:{x:t.linePoints.end.x+n,y:t.linePoints.end.y+o}}}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata);return{...i,linePoints:{start:{x:a.origin.x+(t.linePoints.start.x-r.origin.x)*n,y:a.origin.y+(t.linePoints.start.y-r.origin.y)*o},end:{x:a.origin.x+(t.linePoints.end.x-r.origin.x)*n,y:a.origin.y+(t.linePoints.end.y-r.origin.y)*o}}}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Va(t,n);return{...n,linePoints:{start:{x:t.linePoints.start.x+o,y:t.linePoints.start.y+r},end:{x:t.linePoints.end.x+o,y:t.linePoints.end.y+r}}}}case"property-update":{if(!(e.changes.strokeWidth!==void 0||e.changes.lineEndings!==void 0||e.changes.rotation!==void 0))return e.changes;const o={...t,...e.changes},r=Jt([o.linePoints.start,o.linePoints.end],o.strokeWidth,o.lineEndings),a=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...e.changes,unrotatedRect:r,rect:Qn(r,a,Jn(t))}:{...e.changes,rect:r}}default:return e.changes}},py=(t,e)=>{switch(e.type){case"vertex-edit":if(e.changes.vertices&&e.changes.vertices.length){const n=e.changes.vertices,o=Jt(n,t.strokeWidth,t.lineEndings),r=Ha(t,n,o),a=Jt(r,t.strokeWidth,t.lineEndings);return{...Wa(t,a),vertices:r}}return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,vertices:t.vertices.map(a=>({x:a.x+n,y:a.y+o}))}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata);return{...i,vertices:t.vertices.map(s=>({x:a.origin.x+(s.x-r.origin.x)*n,y:a.origin.y+(s.y-r.origin.y)*o}))}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Va(t,n);return{...n,vertices:t.vertices.map(a=>({x:a.x+o,y:a.y+r}))}}case"property-update":{if(!(e.changes.strokeWidth!==void 0||e.changes.lineEndings!==void 0||e.changes.rotation!==void 0))return e.changes;const o={...t,...e.changes},r=Jt(o.vertices,o.strokeWidth,o.lineEndings),a=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...e.changes,unrotatedRect:r,rect:Qn(r,a,Jn(t))}:{...e.changes,rect:r}}default:return e.changes}};function Ad(t,e){return(t??0)>0?en(t,e,!1):e/2}const hy=(t,e)=>{switch(e.type){case"vertex-edit":if(e.changes.vertices&&e.changes.vertices.length){const n=Ad(t.cloudyBorderIntensity,t.strokeWidth),o=e.changes.vertices,r=_n(cn(o),n),a=Ha(t,o,r),i=_n(cn(a),n);return{...Wa(t,i),vertices:a}}return e.changes;case"move":{if(!e.changes.rect)return e.changes;const{dx:n,dy:o,rects:r}=to(t,e.changes.rect);return{...r,vertices:t.vertices.map(a=>({x:a.x+n,y:a.y+o}))}}case"resize":{if(!e.changes.rect)return e.changes;const{scaleX:n,scaleY:o,oldRect:r,resolvedRect:a,rects:i}=no(t,e.changes.rect,e.metadata);return{...i,vertices:t.vertices.map(s=>({x:a.origin.x+(s.x-r.origin.x)*n,y:a.origin.y+(s.y-r.origin.y)*o}))}}case"rotate":{const n=eo(t,e);if(!n)return e.changes;const{dx:o,dy:r}=Va(t,n);return{...n,vertices:t.vertices.map(a=>({x:a.x+o,y:a.y+r}))}}case"property-update":{const n=e.changes.cloudyBorderIntensity!==void 0;if(!(e.changes.strokeWidth!==void 0||e.changes.rotation!==void 0||n))return e.changes;const r={...t,...e.changes},a=Ad(r.cloudyBorderIntensity,r.strokeWidth),i=_n(cn(r.vertices),a);let s=e.changes;const l=(t.cloudyBorderIntensity??0)>0;if(n||e.changes.strokeWidth!==void 0&&l){const u=r.cloudyBorderIntensity??0;if(u>0){const d=en(u,r.strokeWidth,!1);s={...s,rectangleDifferences:{left:d,top:d,right:d,bottom:d}}}else s={...s,rectangleDifferences:void 0}}const c=e.changes.rotation??t.rotation??0;return t.unrotatedRect||e.changes.rotation!==void 0?{...s,unrotatedRect:i,rect:Qn(i,c,Jn(t))}:{...s,rect:i}}default:return e.changes}},gy=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":{let n=e.changes;const o=e.changes.cloudyBorderIntensity!==void 0,r=e.changes.strokeWidth!==void 0,a=(t.cloudyBorderIntensity??0)>0;if(o||r&&a){const i={...t,...e.changes},s=i.cloudyBorderIntensity??0;if(s>0){const l=en(s,i.strokeWidth,!0);n={...n,rectangleDifferences:{left:l,top:l,right:l,bottom:l}}}else n={...n,rectangleDifferences:void 0}}return e.changes.rotation!==void 0&&(n={...n,...Mr(t,e.changes.rotation)}),n}default:return e.changes}},fy=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":{let n=e.changes;const o=e.changes.cloudyBorderIntensity!==void 0,r=e.changes.strokeWidth!==void 0,a=(t.cloudyBorderIntensity??0)>0;if(o||r&&a){const i={...t,...e.changes},s=i.cloudyBorderIntensity??0;if(s>0){const l=en(s,i.strokeWidth,!1);n={...n,rectangleDifferences:{left:l,top:l,right:l,bottom:l}}}else n={...n,rectangleDifferences:void 0}}return e.changes.rotation!==void 0&&(n={...n,...Mr(t,e.changes.rotation)}),n}default:return e.changes}},my=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":return e.changes.rotation!==void 0?{...e.changes,...Mr(t,e.changes.rotation)}:e.changes;default:return e.changes}},Py=(t,e)=>{switch(e.type){case"move":return e.changes.rect?to(t,e.changes.rect).rects:e.changes;case"resize":return e.changes.rect?no(t,e.changes.rect,e.metadata).rects:e.changes;case"rotate":return eo(t,e)??e.changes;case"property-update":return e.changes.rotation!==void 0?{...e.changes,...Mr(t,e.changes.rotation)}:e.changes;default:return e.changes}},Fy=[{id:"highlight",name:"Highlight",labelKey:"annotation.highlight",categories:["annotation","markup"],matchScore:t=>t.type===M.HIGHLIGHT?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.HIGHLIGHT,strokeColor:"#FFCD45",color:"#FFCD45",opacity:1,blendMode:it.Multiply}},{id:"underline",name:"Underline",labelKey:"annotation.underline",categories:["annotation","markup"],matchScore:t=>t.type===M.UNDERLINE?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.UNDERLINE,strokeColor:"#E44234",color:"#E44234",opacity:1}},{id:"strikeout",name:"Strikeout",labelKey:"annotation.strikeout",categories:["annotation","markup"],matchScore:t=>t.type===M.STRIKEOUT?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.STRIKEOUT,strokeColor:"#E44234",color:"#E44234",opacity:1}},{id:"squiggly",name:"Squiggly",labelKey:"annotation.squiggly",categories:["annotation","markup"],matchScore:t=>t.type===M.SQUIGGLY?1:0,interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.SQUIGGLY,strokeColor:"#E44234",color:"#E44234",opacity:1}}],by=[{id:"insertText",name:"Insert Text",labelKey:"annotation.insertText",categories:["annotation","markup"],matchScore:t=>{var e;return t.type!==M.CARET?0:(e=t.intent)!=null&&e.includes("Insert")?2:1},interaction:{exclusive:!1,textSelection:!0,showSelectionRects:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.CARET,strokeColor:"#E44234",opacity:1,intent:"Insert"},selectionHandler:uy}],yy=[{id:"replaceText",name:"Replace Text",labelKey:"annotation.replaceText",categories:["annotation","markup"],matchScore:t=>{var e,n;return t.type===M.STRIKEOUT&&((e=t.intent)!=null&&e.includes("StrikeOutTextEdit"))||t.type===M.CARET&&((n=t.intent)!=null&&n.includes("Replace"))?2:0},interaction:{exclusive:!1,textSelection:!0,isDraggable:!1,isResizable:!1,isRotatable:!1,isGroupDraggable:!1,isGroupResizable:!1},defaults:{type:M.STRIKEOUT,strokeColor:"#E44234",opacity:1,intent:"StrikeOutTextEdit"},selectionHandler:dy}],_y=[{id:"ink",name:"Pen",labelKey:"annotation.ink",categories:["annotation","markup"],matchScore:t=>t.type===M.INK&&t.intent!=="InkHighlight"?5:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1},defaults:{type:M.INK,strokeColor:"#E44234",color:"#E44234",opacity:1,strokeWidth:6},behavior:{commitDelay:800},transform:Sd,pointerHandler:Es},{id:"inkHighlighter",name:"Ink Highlighter",labelKey:"annotation.inkHighlighter",categories:["annotation","markup"],matchScore:t=>t.type===M.INK&&t.intent==="InkHighlight"?10:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.INK,intent:"InkHighlight",strokeColor:"#FFCD45",color:"#FFCD45",opacity:1,strokeWidth:14,blendMode:it.Multiply},behavior:{commitDelay:800,smartLineRecognition:!0,smartLineThreshold:.15},transform:Sd,pointerHandler:Es}],vy=[{id:"circle",name:"Circle",labelKey:"annotation.circle",categories:["annotation","shape"],matchScore:t=>t.type===M.CIRCLE?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.CIRCLE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234",strokeStyle:rt.SOLID},clickBehavior:{enabled:!0,defaultSize:{width:100,height:100}},transform:gy,pointerHandler:_d}],Dy=[{id:"square",name:"Square",labelKey:"annotation.square",categories:["annotation","shape"],matchScore:t=>t.type===M.SQUARE?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.SQUARE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234",strokeStyle:rt.SOLID},clickBehavior:{enabled:!0,defaultSize:{width:100,height:100}},transform:fy,pointerHandler:bd}],Sy=[{id:"line",name:"Line",labelKey:"annotation.line",categories:["annotation","shape"],matchScore:t=>t.type===M.LINE&&t.intent!=="LineArrow"?5:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.LINE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234"},clickBehavior:{enabled:!0,defaultLength:100,defaultAngle:0},transform:Ed,pointerHandler:Cs},{id:"lineArrow",name:"Arrow",labelKey:"annotation.arrow",categories:["annotation","shape"],matchScore:t=>t.type===M.LINE&&t.intent==="LineArrow"?10:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.LINE,intent:"LineArrow",color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234",lineEndings:{start:Ct.None,end:Ct.OpenArrow}},clickBehavior:{enabled:!0,defaultLength:100,defaultAngle:0},transform:Ed,pointerHandler:Cs}],Ey=[{id:"polyline",name:"Polyline",labelKey:"annotation.polyline",categories:["annotation","shape"],matchScore:t=>t.type===M.POLYLINE?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.POLYLINE,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234"},transform:py,pointerHandler:ud}],Ay=[{id:"polygon",name:"Polygon",labelKey:"annotation.polygon",categories:["annotation","shape"],matchScore:t=>t.type===M.POLYGON?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,lockAspectRatio:!1,isGroupResizable:!0,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.POLYGON,color:"transparent",opacity:1,strokeWidth:6,strokeColor:"#E44234"},transform:hy,pointerHandler:Fd}],xy=[{id:"textComment",name:"Comment",labelKey:"annotation.text",categories:["annotation","markup"],matchScore:t=>t.type===M.TEXT&&!t.inReplyToId?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!1,isRotatable:!1},defaults:{type:M.TEXT,strokeColor:"#FFCD45",opacity:1},behavior:{selectAfterCreate:!0},pointerHandler:ld}],Cy=[{id:"freeText",name:"Free Text",labelKey:"annotation.freeText",categories:["annotation","markup"],matchScore:t=>t.type===M.FREETEXT?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,lockAspectRatio:!1,lockGroupAspectRatio:t=>{const e=((t.rotation??0)%90+90)%90;return e>=6&&e<=84}},defaults:{type:M.FREETEXT,contents:"Insert text",fontSize:14,fontColor:"#E44234",fontFamily:mt.Helvetica,textAlign:Vt.Left,verticalAlign:Ar.Top,color:"transparent",backgroundColor:"transparent",opacity:1},clickBehavior:{enabled:!0,defaultSize:{width:100,height:20},defaultContent:"Insert text"},behavior:{insertUpright:!0,editAfterCreate:!0,selectAfterCreate:!0},transform:my,pointerHandler:cd}],Ty=[{id:"stamp",name:"Image",labelKey:"annotation.stamp",categories:["annotation","markup"],matchScore:t=>t.type===M.STAMP?1:0,interaction:{exclusive:!1,cursor:"copy",isDraggable:!0,isResizable:!0,lockAspectRatio:!0,lockGroupAspectRatio:!0},defaults:{type:M.STAMP},behavior:{insertUpright:!0,useAppearanceStream:!1},transform:Py,pointerHandler:yd}],My=[{id:"link",name:"Link",labelKey:"annotation.link",categories:["annotation","markup"],matchScore:t=>t.type===M.LINK?1:0,interaction:{exclusive:!1,cursor:"crosshair",isDraggable:!0,isResizable:!0,isRotatable:!1},defaults:{type:M.LINK,strokeColor:"#0000FF",strokeWidth:2,strokeStyle:rt.UNDERLINE},clickBehavior:{enabled:!0,defaultSize:{width:100,height:20}},pointerHandler:vd}],Ry=[...Fy,...by,...yy,..._y,...vy,...Dy,...Sy,...Ey,...Ay,...xy,...Cy,...Ty,...My],wy=["#E44234","#FF8D00","#FFCD45","#5CC96E","#25D2D1","#597CE2","#C544CE","#7D2E25","#000000","#FFFFFF"],ks=t=>t.length===1?t[0]:null,Za=t=>({pages:{},byUid:{},selectedUids:[],selectedUid:null,activeToolId:null,hasPendingChanges:!1,locked:(t==null?void 0:t.locked)??{type:jn.None}}),Oy=(t,e,n)=>{const o=t.byUid[e];return o?{...t,byUid:{...t.byUid,[e]:{...o,commitState:o.commitState==="synced"||o.commitState==="moved"?"dirty":o.commitState,object:{...o.object,...n},dictMode:!0}},hasPendingChanges:!0}:t},ky=(t,e,n)=>{const o=t.byUid[e];return o?{...t,byUid:{...t.byUid,[e]:{...o,commitState:o.commitState==="synced"?"moved":o.commitState,object:{...o.object,...n}}},hasPendingChanges:!0}:t},Iy=t=>{const e=new Map;Ry.forEach(r=>e.set(r.id,r));const n=new Map(e);(t.tools||[]).forEach(r=>{const a=e.get(r.id);a?n.set(r.id,{...a,...r,defaults:{...a.defaults,...r.defaults},interaction:{...a.interaction,...r.interaction},behavior:{...a.behavior,...r.behavior},...a.clickBehavior||r.clickBehavior?{clickBehavior:{...a.clickBehavior,...r.clickBehavior}}:{}}):n.set(r.id,r)});const o=Array.from(n.values()).map(r=>{var a,i,s;return{...r,behavior:{...r.behavior,deactivateToolAfterCreate:((a=r.behavior)==null?void 0:a.deactivateToolAfterCreate)??t.deactivateToolAfterCreate??!1,selectAfterCreate:((i=r.behavior)==null?void 0:i.selectAfterCreate)??t.selectAfterCreate??!0,editAfterCreate:((s=r.behavior)==null?void 0:s.editAfterCreate)??t.editAfterCreate??!1}}});return{documents:{},activeDocumentId:null,tools:o,colorPresets:t.colorPresets??wy}},Gy=(t,e)=>{switch(e.type){case Cu:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case Tu:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case ib:return{...t,activeDocumentId:e.payload};case Mu:{const{documentId:n,annotations:o}=e.payload,r=t.documents[n];if(!r)return t;const a={},i={};for(const[s,l]of Object.entries(o)){const c=Number(s),u=r.pages[c]||[];for(const p of u)delete i[p];const d=l.map(p=>{const h=p.id;return i[h]={commitState:"synced",object:p},h});a[c]=d}return{...t,documents:{...t.documents,[n]:{...r,pages:a,byUid:i}}}}case Ru:{const{documentId:n,id:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,selectedUids:[o],selectedUid:o}}}:t}case wu:{const{documentId:n}=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,selectedUids:[],selectedUid:null}}}:t}case Ou:{const{documentId:n,id:o}=e.payload,r=t.documents[n];if(!r||r.selectedUids.includes(o))return t;const a=[...r.selectedUids,o];return{...t,documents:{...t.documents,[n]:{...r,selectedUids:a,selectedUid:ks(a)}}}}case ku:{const{documentId:n,id:o}=e.payload,r=t.documents[n];if(!r)return t;const a=r.selectedUids.filter(i=>i!==o);return{...t,documents:{...t.documents,[n]:{...r,selectedUids:a,selectedUid:ks(a)}}}}case Iu:{const{documentId:n,ids:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,selectedUids:o,selectedUid:ks(o)}}}:t}case Gu:{const{documentId:n,toolId:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,activeToolId:o}}}:t}case Lu:{const{documentId:n,pageIndex:o,annotation:r}=e.payload,a=t.documents[n];if(!a)return t;const i=r.id;return{...t,documents:{...t.documents,[n]:{...a,pages:{...a.pages,[o]:[...a.pages[o]??[],i]},byUid:{...a.byUid,[i]:{commitState:"new",object:r,dictMode:!0}},hasPendingChanges:!0}}}}case ju:{const{documentId:n,pageIndex:o,id:r}=e.payload,a=t.documents[n];return!a||!a.byUid[r]?t:{...t,documents:{...t.documents,[n]:{...a,pages:{...a.pages,[o]:(a.pages[o]??[]).filter(i=>i!==r)},byUid:{...a.byUid,[r]:{...a.byUid[r],commitState:"deleted"}},hasPendingChanges:!0}}}}case $u:{const{documentId:n,id:o,patch:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:Oy(a,o,r)}}:t}case Nu:{const{documentId:n,id:o,patch:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:ky(a,o,r)}}:t}case Uu:{const{documentId:n,committedUids:o}=e.payload,r=t.documents[n];if(!r)return t;const a=new Set(o),i={};let s=!1;for(const[l,c]of Object.entries(r.byUid))a.has(l)?i[l]={...c,commitState:c.commitState==="dirty"||c.commitState==="new"||c.commitState==="moved"?"synced":c.commitState}:(i[l]=c,(c.commitState==="new"||c.commitState==="dirty"||c.commitState==="moved"||c.commitState==="deleted")&&(s=!0));return{...t,documents:{...t.documents,[n]:{...r,byUid:i,hasPendingChanges:s}}}}case Bu:{const{documentId:n,pageIndex:o,uid:r}=e.payload,a=t.documents[n];if(!a||!a.byUid[r])return t;const{[r]:i,...s}=a.byUid;return{...t,documents:{...t.documents,[n]:{...a,pages:{...a.pages,[o]:(a.pages[o]??[]).filter(l=>l!==r)},byUid:s}}}}case zu:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,locked:o}}}:t}case Wu:{const{documentId:n,id:o,patch:r}=e.payload,a=t.documents[n];if(!a)return t;const i=a.byUid[o];return i?{...t,documents:{...t.documents,[n]:{...a,byUid:{...a.byUid,[o]:{...i,object:{...i.object,...r}}}}}}:t}case Yu:{const n=new Map(t.tools.map(o=>[o.id,o]));return n.set(e.payload.id,e.payload),{...t,tools:Array.from(n.values())}}case Vu:{const{toolId:n,patch:o}=e.payload;return{...t,tools:t.tools.map(r=>r.id===n?{...r,defaults:{...r.defaults,...o}}:r)}}case Hu:return t.colorPresets.includes(e.payload)?t:{...t,colorPresets:[...t.colorPresets,e.payload]};default:return t}},Is=class _f extends jt{constructor(e,n,o){var r,a,i,s;super(e,n),this.ANNOTATION_HISTORY_TOPIC="annotations",this.state$=Tt((l,c)=>({documentId:l,state:c})),this.pendingContexts=new Map,this.isInitialLoadComplete=new Map,this.importQueue=new Map,this.commitInProgress=new Map,this.activeTool$=Tt((l,c)=>({documentId:l,tool:c})),this.events$=Tt((l,c)=>c,{cache:!1}),this.toolsChange$=Be(),this.appearanceCache=new Map,this.unifiedDragStates=new Map,this.unifiedDrag$=Be(),this.unifiedResizeStates=new Map,this.unifiedResize$=Be(),this.unifiedRotateStates=new Map,this.unifiedRotate$=Be(),this.navigate$=Tt((l,c)=>c,{cache:!1}),this.config=o,this.selection=((r=n.getPlugin("selection"))==null?void 0:r.provides())??null,this.history=((a=n.getPlugin("history"))==null?void 0:a.provides())??null,this.scroll=((i=n.getPlugin("scroll"))==null?void 0:i.provides())??null,this.interactionManager=((s=n.getPlugin("interaction-manager"))==null?void 0:s.provides())??null}onDocumentLoadingStarted(e){this.dispatch(sb(e,Za(this.config))),this.pendingContexts.set(e,new Map),this.isInitialLoadComplete.set(e,!1),this.importQueue.set(e,[]),this.logger.debug("AnnotationPlugin","DocumentOpened",`Initialized annotation state for document: ${e}`)}onDocumentLoaded(e){const n=this.getCoreDocument(e);if(n!=null&&n.document&&this.getAllAnnotations(e,n.document),this.selection)for(const o of this.state.tools)o.interaction.textSelection&&this.selection.enableForMode(o.interaction.mode??o.id,{showSelectionRects:o.interaction.showSelectionRects??!1,enableSelection:!0,enableMarquee:!1})}onDocumentClosed(e){this.dispatch(lb(e)),this.pendingContexts.delete(e),this.isInitialLoadComplete.delete(e),this.importQueue.delete(e),this.appearanceCache.delete(e),this.state$.clearScope(e),this.activeTool$.clearScope(e),this.events$.clearScope(e),this.navigate$.clearScope(e),this.logger.debug("AnnotationPlugin","DocumentClosed",`Cleaned up annotation state for document: ${e}`)}async initialize(){var e,n,o;this.state.tools.forEach(r=>this.registerInteractionForTool(r)),this.history&&this.history.onHistoryChange(r=>{r.topic===this.ANNOTATION_HISTORY_TOPIC&&this.config.autoCommit!==!1&&this.commit(r.documentId)}),(e=this.interactionManager)==null||e.onModeChange(r=>{var a,i;const s=((a=this.state.tools.find(c=>(c.interaction.mode??c.id)===r.activeMode))==null?void 0:a.id)??null,l=((i=this.state.documents[r.documentId])==null?void 0:i.activeToolId)??null;s!==l&&r.documentId&&this.dispatch(Ku(r.documentId,s))}),(n=this.selection)==null||n.onMarqueeEnd(({documentId:r,pageIndex:a,rect:i,modeId:s})=>{if(s!=="pointerMode")return;const l=this.state.documents[r];if(!l)return;const u=(l.pages[a]??[]).map(d=>l.byUid[d]).filter(d=>d!==void 0).filter(d=>kb(d)).filter(d=>Pb(i,d.object.rect)).filter(d=>!this.isAnnotationLocked(d.object,r)).map(d=>d.object.id);if(u.length>0){const d=new Set;for(const p of u)if(this.isInGroupMethod(p,r)){const h=this.getGroupMembersMethod(p,r);for(const g of h)d.add(g.object.id)}else d.add(p);this.setSelectionMethod([...d],r)}}),(o=this.selection)==null||o.onEndSelection(({documentId:r})=>{var a,i,s,l;if(!this.checkPermission(r,te.ModifyAnnotations))return;const c=this.getActiveTool(r);if(!c||!c.interaction.textSelection)return;const u=(a=this.selection)==null?void 0:a.getFormattedSelection(),d=(i=this.selection)==null?void 0:i.getSelectedText();if(!u||!d)return;const p=()=>new Promise(f=>{d.wait(F=>f(F.join(`
21
+ `)),()=>f(void 0))}),h={toolId:c.id,documentId:r,getTool:()=>this.getActiveTool(r)??null,createAnnotation:(f,F)=>this.createAnnotation(f,F,void 0,r),selectAnnotation:(f,F)=>this.selectAnnotation(f,F,r)};(c.selectionHandler??cy).handle(h,u,p),(s=c.behavior)!=null&&s.deactivateToolAfterCreate&&this.setActiveTool(null,r),(l=this.selection)==null||l.clear()})}registerInteractionForTool(e){var n;(n=this.interactionManager)==null||n.registerMode({id:e.interaction.mode??e.id,scope:"page",exclusive:e.interaction.exclusive,cursor:e.interaction.cursor})}buildCapability(){return{getActiveTool:()=>this.getActiveTool(),setActiveTool:e=>this.setActiveTool(e),getState:()=>this.getDocumentState(),getPageAnnotations:e=>this.getPageAnnotations(e),getSelectedAnnotation:()=>this.getSelectedAnnotation(),getSelectedAnnotations:()=>this.getSelectedAnnotationsMethod(),getSelectedAnnotationIds:()=>this.getSelectedAnnotationIdsMethod(),getAnnotationById:e=>this.getAnnotationById(e),selectAnnotation:(e,n)=>this.selectAnnotation(e,n),toggleSelection:(e,n)=>this.toggleSelectionMethod(e,n),addToSelection:(e,n)=>this.addToSelectionMethod(e,n),removeFromSelection:e=>this.removeFromSelectionMethod(e),setSelection:e=>this.setSelectionMethod(e),deselectAnnotation:()=>this.deselectAnnotation(),importAnnotations:e=>this.importAnnotations(e),createAnnotation:(e,n,o)=>this.createAnnotation(e,n,o),updateAnnotation:(e,n,o)=>this.updateAnnotation(e,n,o),updateAnnotations:e=>this.updateAnnotationsMethod(e),moveAnnotation:(e,n,o,r,a)=>this.moveAnnotationMethod(e,n,o,r,a),deleteAnnotation:(e,n)=>this.deleteAnnotation(e,n),deleteAnnotations:(e,n)=>this.deleteAnnotationsMethod(e,n),purgeAnnotation:(e,n,o)=>this.purgeAnnotationMethod(e,n,o),renderAnnotation:e=>this.renderAnnotation(e),getPageAppearances:(e,n,o)=>this.getPageAppearances(e,n,o),invalidatePageAppearances:(e,n)=>this.invalidatePageAppearances(e,n),commit:()=>this.commit(),getAttachedLinks:(e,n)=>this.getAttachedLinksMethod(e,n),hasAttachedLinks:(e,n)=>this.hasAttachedLinksMethod(e,n),deleteAttachedLinks:(e,n)=>this.deleteAttachedLinksMethod(e,n),groupAnnotations:e=>this.groupAnnotationsMethod(e),ungroupAnnotations:(e,n)=>this.ungroupAnnotationsMethod(e,n),getGroupMembers:(e,n)=>this.getGroupMembersMethod(e,n),isInGroup:(e,n)=>this.isInGroupMethod(e,n),setLocked:(e,n)=>this.setLocked(e,n),getLocked:e=>this.getLocked(e),isAnnotationLocked:(e,n)=>this.isAnnotationLocked(e,n),isCategoryLocked:(e,n)=>this.isCategoryLockedMethod(e,n),isToolLocked:(e,n)=>this.isToolLockedMethod(e,n),syncAnnotationObject:(e,n,o)=>this.syncAnnotationObject(e,n,o),navigateTarget:(e,n)=>this.navigateTargetMethod(e,n),forDocument:e=>this.createAnnotationScope(e),getTools:()=>this.state.tools,getTool:e=>this.getTool(e),addTool:e=>{this.dispatch(mb(e)),this.registerInteractionForTool(e)},findToolForAnnotation:e=>this.findToolForAnnotation(e),setToolDefaults:(e,n)=>this.dispatch(fb(e,n)),getColorPresets:()=>[...this.state.colorPresets],addColorPreset:e=>this.dispatch(gb(e)),transformAnnotation:(e,n)=>this.transformAnnotation(e,n),onStateChange:this.state$.onGlobal,onActiveToolChange:this.activeTool$.onGlobal,onAnnotationEvent:this.events$.onGlobal,onToolsChange:this.toolsChange$.on,onNavigate:this.navigate$.onGlobal}}createAnnotationScope(e){return{getState:()=>this.getDocumentState(e),getPageAnnotations:n=>this.getPageAnnotations(n,e),getSelectedAnnotation:()=>this.getSelectedAnnotation(e),getSelectedAnnotations:()=>this.getSelectedAnnotationsMethod(e),getSelectedAnnotationIds:()=>this.getSelectedAnnotationIdsMethod(e),getAnnotationById:n=>this.getAnnotationById(n,e),selectAnnotation:(n,o)=>this.selectAnnotation(n,o,e),toggleSelection:(n,o)=>this.toggleSelectionMethod(n,o,e),addToSelection:(n,o)=>this.addToSelectionMethod(n,o,e),removeFromSelection:n=>this.removeFromSelectionMethod(n,e),setSelection:n=>this.setSelectionMethod(n,e),deselectAnnotation:()=>this.deselectAnnotation(e),getActiveTool:()=>this.getActiveTool(e),setActiveTool:n=>this.setActiveTool(n,e),findToolForAnnotation:n=>this.findToolForAnnotation(n),importAnnotations:n=>this.importAnnotations(n,e),createAnnotation:(n,o,r)=>this.createAnnotation(n,o,r,e),updateAnnotation:(n,o,r)=>this.updateAnnotation(n,o,r,e),updateAnnotations:n=>this.updateAnnotationsMethod(n,e),moveAnnotation:(n,o,r,a)=>this.moveAnnotationMethod(n,o,r,a,e),deleteAnnotation:(n,o)=>this.deleteAnnotation(n,o,e),deleteAnnotations:n=>this.deleteAnnotationsMethod(n,e),purgeAnnotation:(n,o)=>this.purgeAnnotationMethod(n,o,e),renderAnnotation:n=>this.renderAnnotation(n,e),getPageAppearances:(n,o)=>this.getPageAppearances(n,o,e),invalidatePageAppearances:n=>this.invalidatePageAppearances(n,e),commit:()=>this.commit(e),getAttachedLinks:n=>this.getAttachedLinksMethod(n,e),hasAttachedLinks:n=>this.hasAttachedLinksMethod(n,e),deleteAttachedLinks:n=>this.deleteAttachedLinksMethod(n,e),groupAnnotations:()=>this.groupAnnotationsMethod(e),ungroupAnnotations:n=>this.ungroupAnnotationsMethod(n,e),getGroupMembers:n=>this.getGroupMembersMethod(n,e),isInGroup:n=>this.isInGroupMethod(n,e),getGroupingAction:()=>this.getGroupingActionMethod(e),setLocked:n=>this.setLocked(n,e),getLocked:()=>this.getLocked(e),isAnnotationLocked:n=>this.isAnnotationLocked(n,e),isCategoryLocked:n=>this.isCategoryLockedMethod(n,e),isToolLocked:n=>this.isToolLockedMethod(n,e),syncAnnotationObject:(n,o)=>this.syncAnnotationObject(n,o,e),navigateTarget:n=>this.navigateTargetMethod(n,e),onStateChange:this.state$.forScope(e),onAnnotationEvent:this.events$.forScope(e),onActiveToolChange:this.activeTool$.forScope(e),onNavigate:this.navigate$.forScope(e)}}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&(this.state$.emit(o,a),r&&r.activeToolId!==a.activeToolId&&this.activeTool$.emit(o,this.getActiveTool(o)),(r==null?void 0:r.selectedUids)!==a.selectedUids&&this.updateAnnotationSelectionActivity(o,a))}if(e.tools!==n.tools){for(const o in n.documents)this.activeTool$.emit(o,this.getActiveTool(o));this.toolsChange$.emit({tools:n.tools})}}transformAnnotation(e,n){const o={type:n.type,changes:n.changes,metadata:n.metadata},r=this.findToolForAnnotation(e);return r!=null&&r.transform?r.transform(e,o):o.changes}registerPageHandlers(e,n,o,r){var a,i;const s=this.getCoreDocument(e),l=(a=s==null?void 0:s.document)==null?void 0:a.pages[n];if(!l)return()=>{};if(!this.interactionManager)return()=>{};const c=[],u=((l.rotation??0)+((s==null?void 0:s.rotation)??0))%4;for(const d of this.state.tools){const p=d.pointerHandler??((i=d.defaults)!=null&&i.type?_f.defaultHandlerFactories.get(d.defaults.type):void 0);if(!p)continue;const h={pageIndex:n,pageSize:l.size,pageRotation:u,scale:o,services:r.services,onPreview:f=>r.onPreview(d.id,f),onCommit:(f,F)=>{var y,_,E;const A=((y=d.behavior)==null?void 0:y.editAfterCreate)??!1;this.createAnnotation(n,f,F,e,{editAfterCreate:A}),(_=d.behavior)!=null&&_.deactivateToolAfterCreate&&this.setActiveTool(null,e),((E=d.behavior)!=null&&E.selectAfterCreate||A)&&this.selectAnnotation(n,f.id,e)},getTool:()=>this.state.tools.find(f=>f.id===d.id)},g=this.interactionManager.registerHandlers({documentId:e,modeId:d.interaction.mode??d.id,handlers:p.create(h),pageIndex:n});c.push(g)}return()=>c.forEach(d=>d())}getDocumentState(e){const n=e??this.getActiveDocumentId(),o=this.state.documents[n];if(!o)throw new Error(`Annotation state not found for document: ${n}`);return o}getAllAnnotations(e,n){this.engine.getAllAnnotations(n).wait(r=>{this.dispatch(cb(e,r)),this.isInitialLoadComplete.set(e,!0);const a=this.importQueue.get(e);a&&a.length>0&&this.processImportQueue(e),this.events$.emit(e,{type:"loaded",documentId:e,total:Object.values(r).reduce((i,s)=>i+s.length,0)})},Yt)}getPageAnnotations(e,n){const{pageIndex:o}=e,r=n??this.getActiveDocumentId(),a=this.getCoreDocument(r),i=a==null?void 0:a.document;if(!i)return Ue.reject({code:ve.NotFound,message:"Document not found"});const s=i.pages.find(l=>l.index===o);return s?this.engine.getPageAnnotations(i,s):Ue.reject({code:ve.NotFound,message:"Page not found"})}getSelectedAnnotation(e){return Gb(this.getDocumentState(e))}getAnnotationById(e,n){const o=this.getDocumentState(n);return Lb(o,e)}renderAnnotation({pageIndex:e,annotation:n,options:o},r){const a=r??this.getActiveDocumentId(),i=this.getCoreDocument(a),s=i==null?void 0:i.document;if(!s)return Ue.reject({code:ve.NotFound,message:"Document not found"});const l=s.pages.find(c=>c.index===e);return l?this.engine.renderPageAnnotation(s,l,n,o):Ue.reject({code:ve.NotFound,message:"Page not found"})}getPageAppearances(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getCoreDocument(r),i=a==null?void 0:a.document;if(!i)return Ue.reject({code:ve.NotFound,message:"Document not found"});const s=i.pages.find(p=>p.index===e);if(!s)return Ue.reject({code:ve.NotFound,message:"Page not found"});let l=this.appearanceCache.get(r);l||(l=new Map,this.appearanceCache.set(r,l));const c=l.get(e);if(c&&!n){const p=new Ie;return p.resolve(c),p}const u=this.engine.renderPageAnnotations(i,s,n),d=new Ie;return u.wait(p=>{l.set(e,p),d.resolve(p)},p=>{d.fail(p)}),d}invalidatePageAppearances(e,n){const o=n??this.getActiveDocumentId(),r=this.appearanceCache.get(o);r&&r.delete(e)}invalidateAnnotationAppearance(e,n,o){const r=o??this.getActiveDocumentId(),a=this.appearanceCache.get(r);if(!a)return;const i=a.get(n);i&&delete i[e]}importAnnotations(e,n){const o=n??this.getActiveDocumentId();if(!this.isInitialLoadComplete.get(o)){const r=this.importQueue.get(o)||[];r.push(...e),this.importQueue.set(o,r);return}this.processImportItems(o,e)}processImportQueue(e){const n=this.importQueue.get(e);if(!n||n.length===0)return;const o=[...n];this.importQueue.set(e,[]),this.processImportItems(e,o)}processImportItems(e,n){const o=this.pendingContexts.get(e);if(o){for(const r of n){const{annotation:a,ctx:i}=r,s=a.pageIndex,l=a.id;this.dispatch(Ua(e,s,a)),i&&o.set(l,i)}this.config.autoCommit!==!1&&this.commit(e)}}createAnnotation(e,n,o,r,a){const i=r??this.getActiveDocumentId();if(!this.checkPermission(i,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","CreateAnnotation",`Cannot create annotation: document ${i} lacks ModifyAnnotations permission`);return}const s=n.id,l=this.pendingContexts.get(i);if(!l)return;const c={...n,author:n.author??this.config.annotationAuthor},u=a==null?void 0:a.editAfterCreate,d=()=>{this.dispatch(Ua(i,e,c)),o&&l.set(s,o),this.events$.emit(i,{type:"create",documentId:i,annotation:c,pageIndex:e,ctx:o,committed:!1,editAfterCreate:u})};if(!this.history){d(),this.config.autoCommit&&this.commit(i);return}const p={execute:d,undo:()=>{l.delete(s),this.dispatch(Fs(i)),this.dispatch(_s(i,e,s)),this.events$.emit(i,{type:"delete",documentId:i,annotation:c,pageIndex:e,committed:!1})},metadata:{annotationIds:[s]}};this.history.forDocument(i).register(p,this.ANNOTATION_HISTORY_TOPIC)}buildPatch(e,n){return"rect"in n?n:this.transformAnnotation(e,{type:"property-update",changes:n})}updateAnnotation(e,n,o,r){const a=r??this.getActiveDocumentId();if(!this.checkPermission(a,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","UpdateAnnotation",`Cannot update annotation: document ${a} lacks ModifyAnnotations permission`);return}const s=this.getDocumentState(a).byUid[n].object,l=this.buildPatch(s,{...o,author:o.author??this.config.annotationAuthor}),c=()=>{this.dispatch(Ba(a,e,n,l)),this.events$.emit(a,{type:"update",documentId:a,annotation:s,pageIndex:e,patch:l,committed:!1})};if(!this.history){c(),this.config.autoCommit!==!1&&this.commit(a);return}const u=Object.fromEntries(Object.keys(o).map(h=>[h,s[h]])),d={execute:c,undo:()=>{this.dispatch(Ba(a,e,n,u)),this.events$.emit(a,{type:"update",documentId:a,annotation:s,pageIndex:e,patch:u,committed:!1})},metadata:{annotationIds:[n]}};this.history.forDocument(a).register(d,this.ANNOTATION_HISTORY_TOPIC)}deleteAnnotation(e,n,o){var r;const a=o??this.getActiveDocumentId();if(!this.checkPermission(a,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","DeleteAnnotation",`Cannot delete annotation: document ${a} lacks ModifyAnnotations permission`);return}const i=this.getDocumentState(a),s=(r=i.byUid[n])==null?void 0:r.object;if(!s)return;const l=jb(i,n),c=l.map(h=>{var g;return(g=i.byUid[h.id])==null?void 0:g.object}).filter(h=>h!==void 0),u=()=>{var h;for(const g of l){const f=(h=i.byUid[g.id])==null?void 0:h.object;f&&(this.dispatch(_s(a,g.pageIndex,g.id)),this.events$.emit(a,{type:"delete",documentId:a,annotation:f,pageIndex:g.pageIndex,committed:!1}))}this.dispatch(Fs(a)),this.dispatch(_s(a,e,n)),this.events$.emit(a,{type:"delete",documentId:a,annotation:s,pageIndex:e,committed:!1})};if(!this.history){u(),this.config.autoCommit!==!1&&this.commit(a);return}const d={execute:u,undo:()=>{this.dispatch(Ua(a,e,s)),this.events$.emit(a,{type:"create",documentId:a,annotation:s,pageIndex:e,committed:!1});for(const h of c)this.dispatch(Ua(a,h.pageIndex,h)),this.events$.emit(a,{type:"create",documentId:a,annotation:h,pageIndex:h.pageIndex,committed:!1})},metadata:{annotationIds:[n,...l.map(h=>h.id)]}};this.history.forDocument(a).register(d,this.ANNOTATION_HISTORY_TOPIC)}deleteAnnotationsMethod(e,n){for(const{pageIndex:o,id:r}of e)this.deleteAnnotation(o,r,n)}purgeAnnotationMethod(e,n,o){const r=o??this.getActiveDocumentId();this.dispatch(vs(r,e,n))}selectAnnotation(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getAnnotationById(n,r);if(!(a&&this.isAnnotationLocked(a.object,r)))if(this.isInGroupMethod(n,r)){const s=this.getGroupMembersMethod(n,r).map(l=>l.object.id);this.dispatch(ys(r,s))}else this.dispatch(ub(r,e,n))}deselectAnnotation(e){const n=e??this.getActiveDocumentId();this.dispatch(Fs(n))}updateAnnotationSelectionActivity(e,n){var o,r;if(n.selectedUids.length===0){(o=this.interactionManager)==null||o.releasePageActivity(e,"annotation-selection");return}const a=n.selectedUids[0],i=n.byUid[a];i&&((r=this.interactionManager)==null||r.claimPageActivity(e,"annotation-selection",i.object.pageIndex))}getSelectedAnnotationsMethod(e){return Ju(this.getDocumentState(e))}getSelectedAnnotationIdsMethod(e){return ed(this.getDocumentState(e))}toggleSelectionMethod(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getAnnotationById(n,r);if(a&&this.isAnnotationLocked(a.object,r))return;const i=this.getDocumentState(r);if(i.selectedUids.includes(n))this.dispatch(qu(r,n));else if(this.isInGroupMethod(n,r)){const s=this.getGroupMembersMethod(n,r);for(const l of s)i.selectedUids.includes(l.object.id)||this.dispatch(bs(r,l.object.pageIndex,l.object.id))}else this.dispatch(bs(r,e,n))}addToSelectionMethod(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getAnnotationById(n,r);a&&this.isAnnotationLocked(a.object,r)||this.dispatch(bs(r,e,n))}removeFromSelectionMethod(e,n){const o=n??this.getActiveDocumentId();this.dispatch(qu(o,e))}setSelectionMethod(e,n){const o=n??this.getActiveDocumentId(),r=this.getDocumentState(o),a=e.filter(i=>{const s=r.byUid[i];return!s||!this.isAnnotationLocked(s.object,o)});this.dispatch(ys(o,a))}getAttachedLinksMethod(e,n){return Bb(this.getDocumentState(n),e)}hasAttachedLinksMethod(e,n){return this.getAttachedLinksMethod(e,n).length>0}deleteAttachedLinksMethod(e,n){const o=this.getAttachedLinksMethod(e,n);for(const r of o)this.deleteAnnotation(r.object.pageIndex,r.object.id,n)}groupAnnotationsMethod(e){const n=e??this.getActiveDocumentId();if(!this.checkPermission(n,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","GroupAnnotations",`Cannot group annotations: document ${n} lacks ModifyAnnotations permission`);return}const o=this.getSelectedAnnotationsMethod(n);if(o.length<2){this.logger.debug("AnnotationPlugin","GroupAnnotations","Need at least 2 annotations to group");return}const r=o[0],i=o.slice(1).map(s=>({pageIndex:s.object.pageIndex,id:s.object.id,patch:{inReplyToId:r.object.id,replyType:Ln.Group}}));this.updateAnnotationsMethod(i,n)}ungroupAnnotationsMethod(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","UngroupAnnotations",`Cannot ungroup annotations: document ${o} lacks ModifyAnnotations permission`);return}const a=this.getGroupMembersMethod(e,o).filter(i=>i.object.inReplyToId&&i.object.replyType===Ln.Group).map(i=>({pageIndex:i.object.pageIndex,id:i.object.id,patch:{inReplyToId:void 0,replyType:void 0}}));a.length>0&&this.updateAnnotationsMethod(a,o)}getGroupMembersMethod(e,n){return td(this.getDocumentState(n),e)}isInGroupMethod(e,n){return nd(this.getDocumentState(n),e)}getGroupingActionMethod(e){return Wb(this.getDocumentState(e))}computeCombinedConstraints(e){let n=1/0,o=1/0,r=1/0,a=1/0;for(const i of e){const s=i.rect.origin.y,l=i.pageSize.height-(i.rect.origin.y+i.rect.size.height),c=i.rect.origin.x,u=i.pageSize.width-(i.rect.origin.x+i.rect.size.width);n=Math.min(n,s),o=Math.min(o,l),r=Math.min(r,c),a=Math.min(a,u)}return isFinite(n)||(n=0),isFinite(o)||(o=0),isFinite(r)||(r=0),isFinite(a)||(a=0),{maxUp:n,maxDown:o,maxLeft:r,maxRight:a}}clampDelta(e,n){return{x:Math.max(-n.maxLeft,Math.min(n.maxRight,e.x)),y:Math.max(-n.maxUp,Math.min(n.maxDown,e.y))}}startDrag(e,n){const{annotationIds:o,pageSize:r}=n,a=[];for(const d of o){const p=this.getAttachedLinksMethod(d,e);for(const h of p)a.includes(h.object.id)||a.push(h.object.id)}const i=[...o,...a],s=new Map,l=[];for(const d of i){const p=this.getAnnotationById(d,e);p&&(s.set(d,{...p.object.rect}),l.push({id:d,rect:p.object.rect,pageIndex:p.object.pageIndex,pageSize:r}))}const c=this.computeCombinedConstraints(l),u={documentId:e,isDragging:!0,primaryIds:o,attachedLinkIds:a,allParticipantIds:i,originalRects:s,delta:{x:0,y:0},combinedConstraints:c};this.unifiedDragStates.set(e,u),this.unifiedDrag$.emit({documentId:e,type:"start",state:u,previewPatches:{}})}computeDragPreviewPatches(e,n){const o={};for(const r of e.allParticipantIds){const a=this.getAnnotationById(r,n);if(!a)continue;const i=e.originalRects.get(r);if(!i)continue;const s={...i,origin:{x:i.origin.x+e.delta.x,y:i.origin.y+e.delta.y}};o[r]=this.transformAnnotation(a.object,{type:"move",changes:{rect:s}})}return o}updateDrag(e,n){const o=this.unifiedDragStates.get(e);if(!(o!=null&&o.isDragging))return{x:0,y:0};const r=this.clampDelta(n,o.combinedConstraints),a={...o,delta:r};this.unifiedDragStates.set(e,a);const i=this.computeDragPreviewPatches(a,e);return this.unifiedDrag$.emit({documentId:e,type:"update",state:a,previewPatches:i}),r}commitDrag(e){const n=this.unifiedDragStates.get(e);if(!n)return;const o=n.delta;if(o.x!==0||o.y!==0){const a=[];for(const i of n.allParticipantIds){const s=this.getAnnotationById(i,e);if(!s)continue;const l=n.originalRects.get(i)??s.object.rect,c={...l,origin:{x:l.origin.x+o.x,y:l.origin.y+o.y}},u=this.transformAnnotation(s.object,{type:"move",changes:{rect:c}});a.push({pageIndex:s.object.pageIndex,id:i,patch:u})}a.length>0&&this.moveAnnotationsMethod(a,e)}const r=this.computeDragPreviewPatches(n,e);this.unifiedDrag$.emit({documentId:e,type:"end",state:{...n,isDragging:!1},previewPatches:r}),this.unifiedDragStates.delete(e)}cancelDrag(e){const n=this.unifiedDragStates.get(e);n&&(this.unifiedDrag$.emit({documentId:e,type:"cancel",state:{...n,isDragging:!1,delta:{x:0,y:0}},previewPatches:{}}),this.unifiedDragStates.delete(e))}getDragState(e){return this.unifiedDragStates.get(e)??null}get onDragChange(){return this.unifiedDrag$.on}computeUnifiedGroupBoundingBox(e){if(e.length===0)return{origin:{x:0,y:0},size:{width:0,height:0}};let n=1/0,o=1/0,r=-1/0,a=-1/0;for(const i of e)n=Math.min(n,i.origin.x),o=Math.min(o,i.origin.y),r=Math.max(r,i.origin.x+i.size.width),a=Math.max(a,i.origin.y+i.size.height);return{origin:{x:n,y:o},size:{width:r-n,height:a-o}}}computeUnifiedRelativePositions(e,n){return e.map(o=>({id:o.id,originalRect:o.rect,originalUnrotatedRect:o.unrotatedRect,pageIndex:o.pageIndex,isAttachedLink:o.isAttachedLink,parentId:o.parentId,relativeX:n.size.width>0?(o.rect.origin.x-n.origin.x)/n.size.width:0,relativeY:n.size.height>0?(o.rect.origin.y-n.origin.y)/n.size.height:0,relativeWidth:n.size.width>0?o.rect.size.width/n.size.width:1,relativeHeight:n.size.height>0?o.rect.size.height/n.size.height:1}))}computeUnifiedResizedRects(e,n,o=10){const r=new Map;for(const a of e){const i=Math.max(o,a.relativeWidth*n.size.width),s=Math.max(o,a.relativeHeight*n.size.height);r.set(a.id,{origin:{x:n.origin.x+a.relativeX*n.size.width,y:n.origin.y+a.relativeY*n.size.height},size:{width:i,height:s}})}return r}computeResizePreviewPatches(e,n){const o={},r=this.unifiedResizeStates.get(n),a=r?new Map(r.participatingAnnotations.map(i=>[i.id,i])):void 0;for(const[i,s]of e){const l=this.getAnnotationById(i,n);if(!l)continue;let c=s;const u=a==null?void 0:a.get(i);r!=null&&r.isGroupResize&&(u!=null&&u.originalUnrotatedRect)&&(c=dd(s,u.originalRect,u.originalUnrotatedRect,l.object.rotation??0)),o[i]=this.transformAnnotation(l.object,{type:"resize",changes:{rect:c}})}return o}startResize(e,n){const{annotationIds:o,pageSize:r,resizeHandle:a}=n,i=[],s=[];for(const f of o){const F=this.getAnnotationById(f,e);if(F){s.push({id:f,rect:F.object.rect,unrotatedRect:F.object.unrotatedRect?this.cloneRect(F.object.unrotatedRect):void 0,pageIndex:F.object.pageIndex,isAttachedLink:!1});const y=this.getAttachedLinksMethod(f,e);for(const _ of y)i.includes(_.object.id)||(i.push(_.object.id),s.push({id:_.object.id,rect:_.object.rect,unrotatedRect:_.object.unrotatedRect?this.cloneRect(_.object.unrotatedRect):void 0,pageIndex:_.object.pageIndex,isAttachedLink:!0,parentId:f}))}}const l=[...o,...i],c=s.map(f=>f.rect),u=this.computeUnifiedGroupBoundingBox(c),d=this.computeUnifiedRelativePositions(s,u),p=this.computeUnifiedResizedRects(d,u),h={documentId:e,isResizing:!0,isGroupResize:o.length>1,primaryIds:o,attachedLinkIds:i,allParticipantIds:l,originalGroupBox:u,currentGroupBox:u,participatingAnnotations:d,resizeHandle:a,computedRects:p};this.unifiedResizeStates.set(e,h);const g=this.computeResizePreviewPatches(p,e);this.unifiedResize$.emit({documentId:e,type:"start",state:h,computedRects:Object.fromEntries(p),previewPatches:g})}updateResize(e,n){const o=this.unifiedResizeStates.get(e);if(!(o!=null&&o.isResizing))return{};const r=this.computeUnifiedResizedRects(o.participatingAnnotations,n),a={...o,currentGroupBox:n,computedRects:r};this.unifiedResizeStates.set(e,a);const i=Object.fromEntries(r),s=this.computeResizePreviewPatches(r,e);return this.unifiedResize$.emit({documentId:e,type:"update",state:a,computedRects:i,previewPatches:s}),i}commitResize(e){const n=this.unifiedResizeStates.get(e);if(!n)return;const o=this.computeUnifiedResizedRects(n.participatingAnnotations,n.currentGroupBox),r=[],a=new Map(n.participatingAnnotations.map(s=>[s.id,s]));for(const[s,l]of o){const c=this.getAnnotationById(s,e);if(!c)continue;let u=l;const d=a.get(s);n.isGroupResize&&(d!=null&&d.originalUnrotatedRect)&&(u=dd(l,d.originalRect,d.originalUnrotatedRect,c.object.rotation??0));const p=this.transformAnnotation(c.object,{type:"resize",changes:{rect:u}});r.push({pageIndex:c.object.pageIndex,id:s,patch:p})}r.length>0&&this.updateAnnotationsMethod(r,e);const i=this.computeResizePreviewPatches(o,e);this.unifiedResize$.emit({documentId:e,type:"end",state:{...n,isResizing:!1},computedRects:Object.fromEntries(o),previewPatches:i}),this.unifiedResizeStates.delete(e)}cancelResize(e){const n=this.unifiedResizeStates.get(e);if(!n)return;const o=this.computeUnifiedResizedRects(n.participatingAnnotations,n.originalGroupBox);this.unifiedResize$.emit({documentId:e,type:"cancel",state:{...n,isResizing:!1,currentGroupBox:n.originalGroupBox},computedRects:Object.fromEntries(o),previewPatches:{}}),this.unifiedResizeStates.delete(e)}getResizeState(e){return this.unifiedResizeStates.get(e)??null}get onResizeChange(){return this.unifiedResize$.on}cloneRect(e){return{origin:{x:e.origin.x,y:e.origin.y},size:{width:e.size.width,height:e.size.height}}}translateRect(e,n){return{origin:{x:e.origin.x+n.x,y:e.origin.y+n.y},size:{...e.size}}}normalizeAngle(e){const n=e%360;return n<0?n+360:n}normalizeDelta(e){return(e+540)%360-180}buildRotationParticipants(e,n){const o=[],r=[];for(const a of e){const i=this.getAnnotationById(a,n);if(!i)continue;o.push({id:a,rect:this.cloneRect(i.object.rect),pageIndex:i.object.pageIndex,rotation:i.object.rotation??0,unrotatedRect:i.object.unrotatedRect?this.cloneRect(i.object.unrotatedRect):void 0,isAttachedLink:!1});const s=this.getAttachedLinksMethod(a,n);for(const l of s)r.includes(l.object.id)||(r.push(l.object.id),o.push({id:l.object.id,rect:this.cloneRect(l.object.rect),pageIndex:l.object.pageIndex,rotation:l.object.rotation??0,unrotatedRect:l.object.unrotatedRect?this.cloneRect(l.object.unrotatedRect):void 0,isAttachedLink:!0,parentId:a}))}return{participants:o,attachedLinkIds:r}}computeRotatePreviewPatches(e,n){const o={};for(const r of e.participants){const a=this.getAnnotationById(r.id,n);if(!a)continue;const i=Jn({rect:r.rect,unrotatedRect:r.unrotatedRect,rotation:r.rotation}),s=_o(i,e.rotationCenter,e.delta),l={x:s.x-i.x,y:s.y-i.y},c=this.normalizeAngle(r.rotation+e.delta),u=this.transformAnnotation(a.object,{type:"rotate",changes:{rotation:c,unrotatedRect:this.translateRect(r.unrotatedRect??r.rect,l)},metadata:{rotationAngle:c,rotationDelta:e.delta,rotationCenter:e.rotationCenter}});!u.rect&&(l.x!==0||l.y!==0)&&(u.rect={origin:{x:a.object.rect.origin.x+l.x,y:a.object.rect.origin.y+l.y},size:{...a.object.rect.size}}),o[r.id]=u}return o}startRotation(e,n){const{annotationIds:o,cursorAngle:r,rotationCenter:a}=n,{participants:i,attachedLinkIds:s}=this.buildRotationParticipants(o,e);if(i.length===0)return;const l=i.map(h=>h.rect),c=this.computeUnifiedGroupBoundingBox(l),u=a??{x:c.origin.x+c.size.width/2,y:c.origin.y+c.size.height/2},d={documentId:e,isRotating:!0,primaryIds:o,attachedLinkIds:s,allParticipantIds:i.map(h=>h.id),rotationCenter:u,cursorStartAngle:r,currentAngle:r,delta:0,participants:i};this.unifiedRotateStates.set(e,d);const p=this.computeRotatePreviewPatches(d,e);this.unifiedRotate$.emit({documentId:e,type:"start",state:d,previewPatches:p})}updateRotation(e,n,o){const r=this.unifiedRotateStates.get(e);if(!(r!=null&&r.isRotating))return;const a=o!==void 0?o:this.normalizeDelta(n-r.cursorStartAngle),i={...r,currentAngle:n,delta:a};this.unifiedRotateStates.set(e,i);const s=this.computeRotatePreviewPatches(i,e);this.unifiedRotate$.emit({documentId:e,type:"update",state:i,previewPatches:s})}commitRotation(e){const n=this.unifiedRotateStates.get(e);if(!n)return;const o=this.computeRotatePreviewPatches(n,e),r=[];for(const[a,i]of Object.entries(o)){const s=this.getAnnotationById(a,e);s&&r.push({pageIndex:s.object.pageIndex,id:a,patch:i})}r.length>0&&this.updateAnnotationsMethod(r,e),this.unifiedRotate$.emit({documentId:e,type:"end",state:{...n,isRotating:!1},previewPatches:o}),this.unifiedRotateStates.delete(e)}cancelRotation(e){const n=this.unifiedRotateStates.get(e);n&&(this.unifiedRotate$.emit({documentId:e,type:"cancel",state:{...n,isRotating:!1,delta:0,currentAngle:n.cursorStartAngle},previewPatches:{}}),this.unifiedRotateStates.delete(e))}getRotateState(e){return this.unifiedRotateStates.get(e)??null}get onRotateChange(){return this.unifiedRotate$.on}updateAnnotationsMethod(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","UpdateAnnotations",`Cannot update annotations: document ${o} lacks ModifyAnnotations permission`);return}const r=this.getDocumentState(o),a=e.map(({pageIndex:u,id:d,patch:p})=>{var h;const g=(h=r.byUid[d])==null?void 0:h.object;if(!g)return null;const f=this.buildPatch(g,{...p,author:p.author??this.config.annotationAuthor});return{pageIndex:u,id:d,patch:f,originalObject:g}}).filter(u=>u!==null);if(a.length===0)return;const i=()=>{for(const{pageIndex:u,id:d,patch:p,originalObject:h}of a)this.dispatch(Ba(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})};if(!this.history){i(),this.config.autoCommit!==!1&&this.commit(o);return}const s=a.map(({pageIndex:u,id:d,patch:p,originalObject:h})=>({pageIndex:u,id:d,originalPatch:Object.fromEntries(Object.keys(p).map(g=>[g,h[g]])),originalObject:h})),l={execute:i,undo:()=>{for(const{pageIndex:u,id:d,originalPatch:p,originalObject:h}of s)this.dispatch(Ba(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})},metadata:{annotationIds:a.map(u=>u.id)}};this.history.forDocument(o).register(l,this.ANNOTATION_HISTORY_TOPIC)}moveAnnotationsMethod(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","MoveAnnotations",`Cannot move annotations: document ${o} lacks ModifyAnnotations permission`);return}const r=this.getDocumentState(o),a=e.map(({pageIndex:u,id:d,patch:p})=>{var h;const g=(h=r.byUid[d])==null?void 0:h.object;return g?{pageIndex:u,id:d,patch:p,originalObject:g}:null}).filter(u=>u!==null);if(a.length===0)return;const i=()=>{for(const{pageIndex:u,id:d,patch:p,originalObject:h}of a)this.dispatch(Xu(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})};if(!this.history){i(),this.config.autoCommit!==!1&&this.commit(o);return}const s=a.map(({pageIndex:u,id:d,patch:p,originalObject:h})=>({pageIndex:u,id:d,originalPatch:Object.fromEntries(Object.keys(p).map(g=>[g,h[g]])),originalObject:h})),l={execute:i,undo:()=>{for(const{pageIndex:u,id:d,originalPatch:p,originalObject:h}of s)this.dispatch(Xu(o,u,d,p)),this.events$.emit(o,{type:"update",documentId:o,annotation:h,pageIndex:u,patch:p,committed:!1})},metadata:{annotationIds:a.map(u=>u.id)}};this.history.forDocument(o).register(l,this.ANNOTATION_HISTORY_TOPIC)}moveAnnotationMethod(e,n,o,r="delta",a){const i=a??this.getActiveDocumentId(),s=this.getAnnotationById(n,i);if(!s)return;const l=s.object.rect,c={...l,origin:r==="absolute"?{x:o.x,y:o.y}:{x:l.origin.x+o.x,y:l.origin.y+o.y}},u=this.transformAnnotation(s.object,{type:"move",changes:{rect:c}});this.moveAnnotationsMethod([{pageIndex:e,id:n,patch:u}],i)}getActiveTool(e){const n=this.getDocumentState(e);return n.activeToolId?this.state.tools.find(o=>o.id===n.activeToolId)??null:null}setActiveTool(e,n){var o,r;const a=n??this.getActiveDocumentId();if(e!==null&&!this.checkPermission(a,te.ModifyAnnotations)){this.logger.debug("AnnotationPlugin","SetActiveTool",`Cannot activate tool: document ${a} lacks ModifyAnnotations permission`);return}const i=this.getDocumentState(a);if(e===i.activeToolId)return;this.dispatch(Ku(a,e));const s=this.state.tools.find(l=>l.id===e);s?(o=this.interactionManager)==null||o.forDocument(a).activate(s.interaction.mode??s.id):(r=this.interactionManager)==null||r.forDocument(a).activateDefaultMode()}getTool(e){return this.state.tools.find(n=>n.id===e)}findToolForAnnotation(e){let n=null,o=0;for(const r of this.state.tools){const a=r.matchScore(e);a>o&&(o=a,n=r)}return n}setLocked(e,n){const o=n??this.getActiveDocumentId();this.dispatch(pb(o,e));const r=this.getDocumentState(o),a=r.selectedUids.filter(i=>{const s=r.byUid[i];return s?this.isAnnotationLocked(s.object,o):!1});if(a.length>0){const i=r.selectedUids.filter(s=>!a.includes(s));this.dispatch(ys(o,i))}}getLocked(e){return this.getDocumentState(e).locked}isAnnotationLocked(e,n){if(Qu(e))return!0;const o=this.findToolForAnnotation(e),r=Ss(o);return za(r,this.getLocked(n))}isCategoryLockedMethod(e,n){return za([e],this.getLocked(n))}isToolLockedMethod(e,n){const o=this.getTool(e);if(!o)return!1;const r=Ss(o);return za(r,this.getLocked(n))}syncAnnotationObject(e,n,o){const r=o??this.getActiveDocumentId();this.dispatch(hb(r,e,n))}navigateTargetMethod(e,n){var o;const r=n??this.getActiveDocumentId(),a=l=>(this.navigate$.emit(r,{documentId:r,result:l,target:e}),Ue.resolve(l));let i;if(e.type==="destination")i=e.destination;else if(e.type==="action"){const l=e.action;if(l.type===wa.Goto||l.type===wa.RemoteGoto)i=l.destination;else return l.type===wa.URI?a({outcome:"uri",uri:l.uri}):a({outcome:"unsupported"})}if(!i)return a({outcome:"unsupported"});if(!this.scroll)return a({outcome:"destination",destination:i});const s=this.scroll.forDocument(r);if(i.zoom.mode===du.XYZ){const l=this.getCoreDocument(r),c=(o=l==null?void 0:l.document)==null?void 0:o.pages.find(u=>u.index===i.pageIndex);s.scrollToPage({pageNumber:i.pageIndex+1,pageCoordinates:c&&i.zoom.params?{x:i.zoom.params.x,y:c.size.height-i.zoom.params.y}:void 0,behavior:"smooth"})}else s.scrollToPage({pageNumber:i.pageIndex+1,behavior:"smooth"});return a({outcome:"navigated"})}collectPendingChanges(e,n){const o=this.getDocumentState(e),r=this.pendingContexts.get(e),a={creations:[],updates:[],deletions:[],committedUids:[],isEmpty:!0};for(const[i,s]of Object.entries(o.byUid))if(!(s.commitState==="synced"||!n.pages.find(c=>c.index===s.object.pageIndex)))switch(a.committedUids.push(i),a.isEmpty=!1,s.commitState){case"new":a.creations.push({uid:i,ta:s,ctx:r==null?void 0:r.get(s.object.id)});break;case"moved":a.updates.push({uid:i,ta:s,moved:!0});break;case"dirty":a.updates.push({uid:i,ta:s});break;case"deleted":a.deletions.push({uid:i,ta:s});break}return a}executeCommitBatch(e,n,o){const r=new Ie,a=this.pendingContexts.get(e),i=[];for(const{uid:l,ta:c,ctx:u}of o.creations){const d=n.pages.find(h=>h.index===c.object.pageIndex);if(!d)continue;const p=this.engine.createPageAnnotation(n,d,c.object,u);i.push({type:"create",task:p,ta:c,uid:l,ctx:u})}for(const{uid:l,ta:c,moved:u}of o.updates){const d=n.pages.find(h=>h.index===c.object.pageIndex);if(!d)continue;const p=u?this.engine.updatePageAnnotation(n,d,c.object,{regenerateAppearance:!1}):this.engine.updatePageAnnotation(n,d,c.object);i.push({type:"update",task:p,ta:c,uid:l,moved:u})}for(const{uid:l,ta:c}of o.deletions){const u=n.pages.find(d=>d.index===c.object.pageIndex);if(u)if(c.object.id){const d=new Ie;this.engine.removePageAnnotation(n,u,c.object).wait(()=>d.resolve(!0),d.fail),i.push({type:"delete",task:d,ta:c,uid:l})}else this.dispatch(vs(e,c.object.pageIndex,l))}const s=i.map(l=>l.task);return Ie.allSettled(s).wait(()=>{this.emitCommitEvents(e,i,a);for(const l of i)l.type==="update"&&l.moved||(l.type==="create"||l.type==="update"||l.type==="delete")&&this.invalidateAnnotationAppearance(l.ta.object.id,l.ta.object.pageIndex,e);this.dispatch(db(e,o.committedUids)),r.resolve(!0)},l=>r.fail(l)),r}emitCommitEvents(e,n,o){for(const r of n)if(r.task.state.stage===Wo.Resolved)switch(r.type){case"create":this.events$.emit(e,{type:"create",documentId:e,annotation:r.ta.object,pageIndex:r.ta.object.pageIndex,ctx:r.ctx,committed:!0}),o==null||o.delete(r.ta.object.id);break;case"update":this.events$.emit(e,{type:"update",documentId:e,annotation:r.ta.object,pageIndex:r.ta.object.pageIndex,patch:r.ta.object,committed:!0});break;case"delete":this.dispatch(vs(e,r.ta.object.pageIndex,r.uid)),this.events$.emit(e,{type:"delete",documentId:e,annotation:r.ta.object,pageIndex:r.ta.object.pageIndex,committed:!0});break}}acquireCommitLock(e){return this.commitInProgress.get(e)?!1:(this.commitInProgress.set(e,!0),!0)}releaseCommitLock(e){this.commitInProgress.set(e,!1)}commit(e){const n=e??this.getActiveDocumentId();if(!this.getDocumentState(n).hasPendingChanges||!this.acquireCommitLock(n))return Ue.resolve(!0);const r=this.getCoreDocument(n),a=r==null?void 0:r.document;if(!a)return this.releaseCommitLock(n),Ue.reject({code:ve.NotFound,message:"Document not found"});const i=this.collectPendingChanges(n,a);if(i.isEmpty)return this.releaseCommitLock(n),Ue.resolve(!0);const s=new Ie;return this.executeCommitBatch(n,a,i).wait(()=>{this.releaseCommitLock(n),this.getDocumentState(n).hasPendingChanges?this.commit(n).wait(c=>s.resolve(c),c=>s.fail(c)):s.resolve(!0)},l=>{this.releaseCommitLock(n),s.fail(l)}),s}};Is.id="annotation",Is.defaultHandlerFactories=new Map([[M.CIRCLE,_d],[M.SQUARE,bd],[M.STAMP,yd],[M.POLYGON,Fd],[M.POLYLINE,ud],[M.LINE,Cs],[M.INK,Es],[M.FREETEXT,cd],[M.TEXT,ld],[M.LINK,vd]]);let Gs=Is;function tn(t,e,n){return t===void 0?n:typeof t=="function"?t(e):t}const Ly=t=>t,$y={manifest:ab,create:(t,e)=>new Gs(xu,t,e),reducer:Gy,initialState:(t,e)=>Iy(e)};function xd(t,e){const{width:n,height:o}=t.size;switch(e%4){case 1:return{matrix:`matrix(0, -1, 1, 0, 0, ${o})`,width:o,height:n};case 2:return{matrix:`matrix(-1, 0, 0, -1, ${n}, ${o})`,width:n,height:o};case 3:return{matrix:`matrix(0, 1, -1, 0, ${n}, 0)`,width:o,height:n};default:return{matrix:"matrix(1, 0, 0, 1, 0, 0)",width:n,height:o}}}const Ir=ie({__name:"counter-rotate-container",props:{rect:{},rotation:{}},setup(t){const e=t,n=P(()=>xd(e.rect,e.rotation)),o=P(()=>({style:{position:"absolute",left:`${e.rect.origin.x}px`,top:`${e.rect.origin.y}px`,transform:n.value.matrix,transformOrigin:"0 0",width:`${n.value.width}px`,height:`${n.value.height}px`,pointerEvents:"none",zIndex:3},onPointerdown:a=>{a.stopPropagation(),a.preventDefault()},onTouchstart:a=>{a.stopPropagation(),a.preventDefault()}})),r=P(()=>({origin:{x:e.rect.origin.x,y:e.rect.origin.y},size:{width:n.value.width,height:n.value.height}}));return(a,i)=>$e(a.$slots,"default",{menuWrapperProps:o.value,matrix:n.value.matrix,rect:r.value})}});function Ny(t){return{x:t.includes("e")?"left":t.includes("w")?"right":"center",y:t.includes("s")?"top":t.includes("n")?"bottom":"center"}}function jy(t,e){const n=e.x==="left"?t.origin.x:e.x==="right"?t.origin.x+t.size.width:t.origin.x+t.size.width/2,o=e.y==="top"?t.origin.y:e.y==="bottom"?t.origin.y+t.size.height:t.origin.y+t.size.height/2;return{x:n,y:o}}function Uy(t,e,n){let o=t.origin.x,r=t.origin.y,a=t.size.width,i=t.size.height;return n.x==="left"?a+=e.x:n.x==="right"&&(o+=e.x,a-=e.x),n.y==="top"?i+=e.y:n.y==="bottom"&&(r+=e.y,i-=e.y),{origin:{x:o,y:r},size:{width:a,height:i}}}function By(t,e,n,o){let{x:r,y:a}=t.origin,{width:i,height:s}=t.size;if(n.x==="center"||n.y==="center")n.y==="center"?(s=i/o,a=e.origin.y+(e.size.height-s)/2):(i=s*o,r=e.origin.x+(e.size.width-i)/2);else{const c=Math.abs(i-e.size.width),u=Math.abs(s-e.size.height),d=c+u;if(d===0)i=e.size.width,s=e.size.height;else{const p=c/d,h=u/d,g=i,f=i/o,F=s*o,y=s;i=p*g+h*F,s=p*f+h*y}}return n.x==="right"&&(r=e.origin.x+e.size.width-i),n.y==="bottom"&&(a=e.origin.y+e.size.height-s),{origin:{x:r,y:a},size:{width:i,height:s}}}function zy(t,e,n,o,r){if(!o)return t;let{x:a,y:i}=t.origin,{width:s,height:l}=t.size;s=Math.max(1,s),l=Math.max(1,l);const c=n.x==="left"?e.origin.x:e.origin.x+e.size.width,u=n.y==="top"?e.origin.y:e.origin.y+e.size.height,d=n.x==="left"?o.width-c:n.x==="right"?c:Math.min(e.origin.x,o.width-e.origin.x-e.size.width)*2+e.size.width,p=n.y==="top"?o.height-u:n.y==="bottom"?u:Math.min(e.origin.y,o.height-e.origin.y-e.size.height)*2+e.size.height;if(r){const h=s>d?d/s:1,g=l>p?p/l:1,f=Math.min(h,g);f<1&&(s*=f,l*=f)}else s=Math.min(s,d),l=Math.min(l,p);return n.x==="left"?a=c:n.x==="right"?a=c-s:a=e.origin.x+(e.size.width-s)/2,n.y==="top"?i=u:n.y==="bottom"?i=u-l:i=e.origin.y+(e.size.height-l)/2,a=Math.max(0,Math.min(a,o.width-s)),i=Math.max(0,Math.min(i,o.height-l)),{origin:{x:a,y:i},size:{width:s,height:l}}}function Wy(t,e,n){let o,r;return n.x==="left"?o=e.origin.x:n.x==="right"?o=e.origin.x+e.size.width-t.size.width:o=e.origin.x+(e.size.width-t.size.width)/2,n.y==="top"?r=e.origin.y:n.y==="bottom"?r=e.origin.y+e.size.height-t.size.height:r=e.origin.y+(e.size.height-t.size.height)/2,{origin:{x:o,y:r},size:t.size}}function Cd(t,e,n,o=!1){if(!e)return t;let{origin:{x:r,y:a},size:{width:i,height:s}}=t;const l=e.minWidth??1,c=e.minHeight??1,u=e.maxWidth,d=e.maxHeight;if(n&&i>0&&s>0){const p=i/s;i<l&&(i=l,s=i/p),s<c&&(s=c,i=s*p),u!==void 0&&i>u&&(i=u,s=i/p),d!==void 0&&s>d&&(s=d,i=s*p)}else i=Math.max(l,i),s=Math.max(c,s),u!==void 0&&(i=Math.min(u,i)),d!==void 0&&(s=Math.min(d,s));return e.boundingBox&&!o&&(r=Math.max(0,Math.min(r,e.boundingBox.width-i)),a=Math.max(0,Math.min(a,e.boundingBox.height-s))),{origin:{x:r,y:a},size:{width:i,height:s}}}function Td(t,e,n){const r=Qi(t,e);return r.origin.x>=-1e-6&&r.origin.y>=-1e-6&&r.origin.x+r.size.width<=n.width+1e-6&&r.origin.y+r.size.height<=n.height+1e-6}function Qa(t,e,n,o,r){const{startRect:a,maintainAspectRatio:i=!1,annotationRotation:s=0,constraints:l}=n,c=Ny(e),u=a.size.width/a.size.height||1;let d=Uy(a,t,c);if(i&&(d=By(d,a,c,u)),o&&(d=zy(d,a,c,l==null?void 0:l.boundingBox,i)),d=Cd(d,l,i,r),r&&(d=Wy(d,a,c)),s!==0){const p=jy(a,c),h={x:a.origin.x+a.size.width/2,y:a.origin.y+a.size.height/2},g={x:d.origin.x+d.size.width/2,y:d.origin.y+d.size.height/2},f=_o(p,h,s),F=_o(p,g,s);d={origin:{x:d.origin.x+(f.x-F.x),y:d.origin.y+(f.y-F.y)},size:d.size}}return d}function Hy(t,e,n){const{annotationRotation:o=0,constraints:r}=n,a=r==null?void 0:r.boundingBox;if(o!==0&&a){const i=Qa(t,e,n,!1,!0);if(Td(i,o,a))return i;let s=Qa({x:0,y:0},e,n,!1,!0),l=0,c=1;for(let u=0;u<20;u+=1){const d=(l+c)/2,p=Qa({x:t.x*d,y:t.y*d},e,n,!1,!0);Td(p,o,a)?(s=p,l=d):c=d}return s}return Qa(t,e,n,!0,!1)}const Md=35,Vy={n:0,ne:45,e:90,se:135,s:180,sw:225,w:270,nw:315},Yy=["ns-resize","nesw-resize","ew-resize","nwse-resize","ns-resize","nesw-resize","ew-resize","nwse-resize"];function qy(t,e,n=0){const o=e*90,a=((Vy[t]+o+n)%360+360)%360,i=Math.round(a/45)%8;return Yy[i]}function Ky(t,e,n){const o=-t/2;return n==="center"?o:n==="outside"?o-e:o+e}function Xy(t,e={}){const{handleSize:n=8,spacing:o=1,offsetMode:r="outside",includeSides:a=!1,zIndex:i=3,rotationAwareCursor:s=!0}=e,l=(t.pageRotation??0)%4,c=t.annotationRotation??0,u=g=>({[g]:Ky(n,o,r)+"px"}),d=[["nw",{...u("top"),...u("left")}],["ne",{...u("top"),...u("right")}],["sw",{...u("bottom"),...u("left")}],["se",{...u("bottom"),...u("right")}]],p=a?[["n",{...u("top"),left:`calc(50% - ${n/2}px)`}],["s",{...u("bottom"),left:`calc(50% - ${n/2}px)`}],["w",{...u("left"),top:`calc(50% - ${n/2}px)`}],["e",{...u("right"),top:`calc(50% - ${n/2}px)`}]]:[];return[...d,...p].map(([g,f])=>({handle:g,style:{position:"absolute",width:n+"px",height:n+"px",borderRadius:"50%",zIndex:i,cursor:s?qy(g,l,c):"default",pointerEvents:"auto",touchAction:"none",...f},attrs:{"data-epdf-handle":g}}))}function Zy(t,e={},n){const{vertexSize:o=12,zIndex:r=4}=e,a=t.element,i=t.scale??1;return(n??t.vertices??[]).map((l,c)=>{const u=(l.x-a.origin.x)*i-o/2,d=(l.y-a.origin.y)*i-o/2;return{handle:"nw",style:{position:"absolute",left:u+"px",top:d+"px",width:o+"px",height:o+"px",borderRadius:"50%",cursor:"pointer",zIndex:r,pointerEvents:"auto",touchAction:"none"},attrs:{"data-epdf-vertex":c}}})}function Qy(t,e={},n=0){const{handleSize:o=16,zIndex:r=5,showConnector:a=!0,connectorWidth:i=1}=e,s=t.scale??1,l=t.element,c=t.rotationElement??l,u=t.rotationCenter??{x:l.origin.x+l.size.width/2,y:l.origin.y+l.size.height/2};c.size.width*s,c.size.height*s;const d=(u.x-c.origin.x)*s,p=(u.y-c.origin.y)*s,h=n*Math.PI/180,g=e.margin??Md,f=l.size.height*s/2+g,F=d+f*Math.sin(h),y=p-f*Math.cos(h),_=F-o/2,E=y-o/2;return{handleStyle:{position:"absolute",left:_+"px",top:E+"px",width:o+"px",height:o+"px",borderRadius:"50%",cursor:"grab",zIndex:r,pointerEvents:"auto",touchAction:"none"},connectorStyle:a?{position:"absolute",left:d-i/2+"px",top:p-f+"px",width:i+"px",height:f+"px",transformOrigin:"center bottom",transform:`rotate(${n}deg)`,zIndex:r-1,pointerEvents:"none"}:{},radius:f,attrs:{"data-epdf-rotation-handle":!0}}}class Jy{constructor(e,n){this.config=e,this.onUpdate=n,this.state="idle",this.startPoint=null,this.startElement=null,this.startRotationElement=null,this.gestureRotationCenter=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.currentVertices=[],this.rotationCenter=null,this.centerScreen=null,this.initialRotation=0,this.lastComputedRotation=0,this.rotationDelta=0,this.rotationSnappedAngle=null,this.currentVertices=e.vertices||[]}updateConfig(e){this.config={...this.config,...e},this.state!=="vertex-editing"&&(this.currentVertices=e.vertices||[])}startDrag(e,n){this.state="dragging",this.startPoint={x:e,y:n},this.startElement={...this.config.element},this.startRotationElement=this.config.rotationElement?{...this.config.rotationElement}:null,this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"move",changes:{rect:this.startElement}}})}startResize(e,n,o){this.state="resizing",this.activeHandle=e,this.startPoint={x:n,y:o},this.startElement={...this.config.element},this.currentPosition={...this.config.element},this.onUpdate({state:"start",transformData:{type:"resize",changes:{rect:this.startElement},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio}}})}startVertexEdit(e,n,o){this.currentVertices=[...this.config.vertices??this.currentVertices],!(e<0||e>=this.currentVertices.length)&&(this.state="vertex-editing",this.activeVertexIndex=e,this.startPoint={x:n,y:o},this.startVertices=[...this.currentVertices],this.gestureRotationCenter=this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2},this.onUpdate({state:"start",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:e}}}))}startRotation(e,n,o=0,r){this.state="rotating",this.startPoint={x:e,y:n},this.startElement={...this.config.element},this.rotationCenter=this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2};const{scale:a=1}=this.config,i=this.config.rotationElement??this.config.element,s=i.size.width*a,l=i.size.height*a,c=r??Math.max(s,l)/2+Md,u=(this.config.pageRotation??0)*90,d=(o+u)*Math.PI/180;this.centerScreen={x:e-c*Math.sin(d),y:n+c*Math.cos(d)},this.initialRotation=o,this.lastComputedRotation=o,this.rotationDelta=0,this.rotationSnappedAngle=null,this.onUpdate({state:"start",transformData:{type:"rotate",changes:{rotation:o},metadata:{rotationAngle:o,rotationDelta:0,rotationCenter:this.rotationCenter,isSnapped:!1}}})}move(e,n,o,r){if(!(this.state==="idle"||!this.startPoint)){if(o!==void 0&&o===0){this.end();return}if(this.state==="dragging"&&this.startElement){const a=this.calculateDelta(e,n),i=this.calculateDragPosition(a);this.currentPosition=i,this.onUpdate({state:"move",transformData:{type:"move",changes:{rect:i}}})}else if(this.state==="resizing"&&this.activeHandle&&this.startElement){const a=this.calculateLocalDelta(e,n),i=Hy(a,this.activeHandle,{startRect:this.startElement,maintainAspectRatio:this.config.maintainAspectRatio||!!r,annotationRotation:this.config.annotationRotation,constraints:this.config.constraints});this.currentPosition=i,this.onUpdate({state:"move",transformData:{type:"resize",changes:{rect:i},metadata:{handle:this.activeHandle,maintainAspectRatio:this.config.maintainAspectRatio||!!r}}})}else if(this.state==="vertex-editing"&&this.activeVertexIndex!==null){const a=this.calculateVertexPosition(e,n);this.currentVertices=a,this.onUpdate({state:"move",transformData:{type:"vertex-edit",changes:{vertices:a},metadata:{vertexIndex:this.activeVertexIndex}}})}else if(this.state==="rotating"&&this.rotationCenter){const a=this.calculateAngleFromMouse(e,n),i=this.applyRotationSnapping(a),s=Ra(i.angle),l=this.lastComputedRotation,c=s-l,u=c>180?c-360:c<-180?c+360:c;this.rotationDelta+=u,this.lastComputedRotation=s,this.rotationSnappedAngle=i.isSnapped?s:null,this.onUpdate({state:"move",transformData:{type:"rotate",changes:{rotation:s},metadata:{rotationAngle:s,rotationDelta:this.rotationDelta,rotationCenter:this.rotationCenter,isSnapped:i.isSnapped,snappedAngle:this.rotationSnappedAngle??void 0,cursorPosition:{clientX:e,clientY:n}}}})}}}end(){if(this.state==="idle")return;const e=this.state,n=this.activeHandle,o=this.activeVertexIndex;if(e==="vertex-editing")this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.currentVertices},metadata:{vertexIndex:o||void 0}}});else if(e==="rotating")this.onUpdate({state:"end",transformData:{type:"rotate",changes:{rotation:this.lastComputedRotation},metadata:{rotationAngle:this.lastComputedRotation,rotationDelta:this.rotationDelta,rotationCenter:this.rotationCenter||void 0,isSnapped:this.rotationSnappedAngle!==null,snappedAngle:this.rotationSnappedAngle??void 0}}});else{const r=this.currentPosition||this.config.element;this.onUpdate({state:"end",transformData:{type:e==="dragging"?"move":"resize",changes:{rect:r},metadata:e==="dragging"?void 0:{handle:n||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}})}this.reset()}cancel(){this.state!=="idle"&&(this.state==="vertex-editing"?this.onUpdate({state:"end",transformData:{type:"vertex-edit",changes:{vertices:this.startVertices},metadata:{vertexIndex:this.activeVertexIndex||void 0}}}):this.state==="rotating"?this.onUpdate({state:"end",transformData:{type:"rotate",changes:{rotation:this.initialRotation},metadata:{rotationAngle:this.initialRotation,rotationDelta:0,rotationCenter:this.rotationCenter||void 0,isSnapped:!1}}}):this.startElement&&this.onUpdate({state:"end",transformData:{type:this.state==="dragging"?"move":"resize",changes:{rect:this.startElement},metadata:this.state==="dragging"?void 0:{handle:this.activeHandle||void 0,maintainAspectRatio:this.config.maintainAspectRatio}}}),this.reset())}reset(){this.state="idle",this.startPoint=null,this.startElement=null,this.startRotationElement=null,this.gestureRotationCenter=null,this.activeHandle=null,this.currentPosition=null,this.activeVertexIndex=null,this.startVertices=[],this.rotationCenter=null,this.centerScreen=null,this.initialRotation=0,this.lastComputedRotation=0,this.rotationDelta=0,this.rotationSnappedAngle=null}calculateDelta(e,n){if(!this.startPoint)return{x:0,y:0};const o={x:e-this.startPoint.x,y:n-this.startPoint.y};return this.transformDelta(o)}transformDelta(e){const{pageRotation:n=0,scale:o=1}=this.config,r=n*Math.PI/2,a=Math.cos(r),i=Math.sin(r),s=e.x/o,l=e.y/o;return{x:a*s+i*l,y:-i*s+a*l}}calculateLocalDelta(e,n){const o=this.calculateDelta(e,n),{annotationRotation:r=0}=this.config;if(r===0)return o;const a=r*Math.PI/180,i=Math.cos(a),s=Math.sin(a);return{x:i*o.x+s*o.y,y:-s*o.x+i*o.y}}clampPoint(e){var n;const o=(n=this.config.constraints)==null?void 0:n.boundingBox;if(!o)return e;const{annotationRotation:r=0}=this.config;if(r===0)return{x:Math.max(0,Math.min(e.x,o.width)),y:Math.max(0,Math.min(e.y,o.height))};const a=this.gestureRotationCenter??this.config.rotationCenter??{x:this.config.element.origin.x+this.config.element.size.width/2,y:this.config.element.origin.y+this.config.element.size.height/2},i=_o(e,a,r),s=Math.max(0,Math.min(i.x,o.width)),l=Math.max(0,Math.min(i.y,o.height));return s===i.x&&l===i.y?e:_o({x:s,y:l},a,-r)}calculateVertexPosition(e,n){if(this.activeVertexIndex===null)return this.startVertices;const o=this.calculateLocalDelta(e,n),r=[...this.startVertices],a=r[this.activeVertexIndex],i={x:a.x+o.x,y:a.y+o.y};return r[this.activeVertexIndex]=this.clampPoint(i),r}calculateDragPosition(e){if(!this.startElement)return this.config.element;const n={origin:{x:this.startElement.origin.x+e.x,y:this.startElement.origin.y+e.y},size:{width:this.startElement.size.width,height:this.startElement.size.height}},{annotationRotation:o=0,constraints:r}=this.config,a=r==null?void 0:r.boundingBox;if(o!==0&&a){let i,s,l,c;if(this.startRotationElement)i=this.startRotationElement.size.width,s=this.startRotationElement.size.height,l=this.startRotationElement.origin.x-this.startElement.origin.x,c=this.startRotationElement.origin.y-this.startElement.origin.y;else{const p=Math.abs(o*Math.PI/180),h=Math.abs(Math.cos(p)),g=Math.abs(Math.sin(p)),f=n.size.width,F=n.size.height;i=f*h+F*g,s=f*g+F*h,l=(f-i)/2,c=(F-s)/2}let{x:u,y:d}=n.origin;return u=Math.max(-l,Math.min(u,a.width-i-l)),d=Math.max(-c,Math.min(d,a.height-s-c)),{origin:{x:u,y:d},size:n.size}}return Cd(n,r,this.config.maintainAspectRatio??!1)}calculateAngleFromMouse(e,n){if(!this.centerScreen)return this.initialRotation;const o=e-this.centerScreen.x,r=n-this.centerScreen.y;if(Math.sqrt(o*o+r*r)<10)return this.lastComputedRotation;const i=(this.config.pageRotation??0)*90,s=Math.atan2(r,o)*(180/Math.PI)+90-i;return Ra(Math.round(s))}applyRotationSnapping(e){const n=this.config.rotationSnapAngles??[0,90,180,270],o=this.config.rotationSnapThreshold??4,r=Ra(e);for(const a of n){const i=Ra(a),s=Math.abs(r-i);if(Math.min(s,360-s)<=o)return{angle:i,isSnapped:!0,snapTarget:i}}return{angle:r,isSnapped:!1}}}const nt=t=>ke(ht(t)?I(t):t),Do=(t,e=0)=>{const n=Number(t);return Number.isFinite(n)?n:e},Ko=t=>{var e,n,o,r;return{origin:{x:Do((e=t==null?void 0:t.origin)==null?void 0:e.x),y:Do((n=t==null?void 0:t.origin)==null?void 0:n.y)},size:{width:Do((o=t==null?void 0:t.size)==null?void 0:o.width),height:Do((r=t==null?void 0:t.size)==null?void 0:r.height)}}},Ls=(t=[])=>t.map(e=>({x:Do(e==null?void 0:e.x),y:Do(e==null?void 0:e.y)})),Rd=t=>t===void 0?void 0:!!t,Xo=t=>t===void 0?void 0:Do(t),wd=t=>t?nt(t):void 0;function e_(t){const e=Q(null),{onUpdate:n,element:o,rotationCenter:r,rotationElement:a,vertices:i,constraints:s,maintainAspectRatio:l,pageRotation:c,annotationRotation:u,scale:d,enabled:p}=t,h={element:Ko(nt(o)),rotationCenter:r?nt(r):void 0,rotationElement:a?Ko(nt(a)):void 0,vertices:i?Ls(nt(i)):void 0,constraints:wd(s),maintainAspectRatio:Rd(p===void 0?void 0:nt(l)),pageRotation:Xo(c===void 0?void 0:nt(c)),annotationRotation:Xo(u===void 0?void 0:nt(u)),scale:Xo(d===void 0?void 0:nt(d))};e.value||(e.value=dr(new Jy(h,w=>n==null?void 0:n(w)))),Se(()=>({element:o,rotationCenter:r,rotationElement:a,vertices:i,constraints:s,maintainAspectRatio:l,pageRotation:c,annotationRotation:u,scale:d}),w=>{var G;(G=e.value)==null||G.updateConfig({element:Ko(nt(w.element)),rotationCenter:w.rotationCenter?nt(w.rotationCenter):void 0,rotationElement:w.rotationElement?Ko(nt(w.rotationElement)):void 0,vertices:w.vertices?Ls(nt(w.vertices)):void 0,constraints:wd(w.constraints),maintainAspectRatio:Rd(w.maintainAspectRatio===void 0?void 0:nt(w.maintainAspectRatio)),pageRotation:Xo(w.pageRotation===void 0?void 0:nt(w.pageRotation)),annotationRotation:Xo(w.annotationRotation===void 0?void 0:nt(w.annotationRotation)),scale:Xo(w.scale===void 0?void 0:nt(w.scale))})},{deep:!0}),$o(()=>{e.value=null});const g=()=>!!(p===void 0||nt(p)),f=w=>{var G,W,J;g()&&(w.preventDefault(),w.stopPropagation(),(G=e.value)==null||G.startDrag(w.clientX,w.clientY),(J=(W=w.currentTarget).setPointerCapture)==null||J.call(W,w.pointerId))},F=w=>{var G;return(G=e.value)==null?void 0:G.move(w.clientX,w.clientY,w.buttons,w.shiftKey)},y=w=>{var G,W,J;(G=e.value)==null||G.end(),(J=(W=w.currentTarget).releasePointerCapture)==null||J.call(W,w.pointerId)},_=w=>{var G,W,J;(G=e.value)==null||G.cancel(),(J=(W=w.currentTarget).releasePointerCapture)==null||J.call(W,w.pointerId)},E=w=>({onPointerdown:G=>{var W,J,ue;g()&&(G.preventDefault(),G.stopPropagation(),(W=e.value)==null||W.startResize(w,G.clientX,G.clientY),(ue=(J=G.currentTarget).setPointerCapture)==null||ue.call(J,G.pointerId))},onPointermove:F,onPointerup:y,onPointercancel:_}),A=w=>({onPointerdown:G=>{var W,J,ue;g()&&(G.preventDefault(),G.stopPropagation(),(W=e.value)==null||W.startVertexEdit(w,G.clientX,G.clientY),(ue=(J=G.currentTarget).setPointerCapture)==null||ue.call(J,G.pointerId))},onPointermove:F,onPointerup:y,onPointercancel:_}),T=(w=0,G)=>({onPointerdown:W=>{var J,ue,ce;if(!g())return;W.preventDefault(),W.stopPropagation();const ee=W.currentTarget.getBoundingClientRect(),ge=ee.left+ee.width/2,ye=ee.top+ee.height/2;(J=e.value)==null||J.startRotation(ge,ye,w,G),(ce=(ue=W.currentTarget).setPointerCapture)==null||ce.call(ue,W.pointerId)},onPointermove:F,onPointerup:y,onPointercancel:_});return{dragProps:P(()=>g()?{onPointerdown:f,onPointermove:F,onPointerup:y,onPointercancel:_}:{}),createResizeProps:E,createVertexProps:A,createRotationProps:T}}function t_(t,{delay:e=300,tolerancePx:n=18}={}){const o=Q({t:0,x:0,y:0});return t?{onDblclick:i=>{t==null||t(i)},onPointerupCapture:i=>{if(!t||i.pointerType==="mouse"||i.isPrimary===!1)return;const s=performance.now(),l=i.clientX,c=i.clientY,u=s-o.value.t<=e,d=l-o.value.x,p=c-o.value.y,h=d*d+p*p<=n*n;u&&h&&(t==null||t(i)),o.value={t:s,x:l,y:c}}}:{}}function Od(t){const{controller:e,resizeUI:n,vertexUI:o,rotationUI:r,includeVertices:a=!1,includeRotation:i=!1,currentRotation:s=0,handleAttrs:l,vertexAttrs:c,rotationAttrs:u}=t,{dragProps:d,createResizeProps:p,createVertexProps:h,createRotationProps:g}=e_(e),f=P(()=>Ko(nt(e.element))),F=P(()=>e.vertices?Ls(nt(e.vertices)):void 0),y=P(()=>Number(nt(e.scale??1))),_=P(()=>Number(nt(e.pageRotation??0))),E=P(()=>e.annotationRotation!==void 0?Number(nt(e.annotationRotation)):void 0),A=P(()=>e.maintainAspectRatio===void 0?void 0:!!nt(e.maintainAspectRatio)),T=P(()=>nt(e.constraints??void 0)),q=P(()=>e.rotationCenter?nt(e.rotationCenter):void 0),w=P(()=>e.rotationElement?Ko(nt(e.rotationElement)):void 0),G=P(()=>Xy({element:f.value,scale:y.value,pageRotation:_.value,annotationRotation:E.value,maintainAspectRatio:A.value,constraints:T.value},n).map(ce=>{var ee;return{key:((ee=ce.attrs)==null?void 0:ee["data-epdf-handle"])??ce.handle,style:ce.style,...p(ce.handle),...ce.attrs??{},...(l==null?void 0:l(ce.handle))??{}}})),W=P(()=>{if(!a)return[];const ue=F.value??[];return Zy({element:f.value,scale:y.value,vertices:ue},o,ue).map((ee,ge)=>({key:ge,style:ee.style,...h(ge),...ee.attrs??{},...(c==null?void 0:c(ge))??{}}))}),J=P(()=>{if(!!!nt(i??!1))return null;const ce=Number(nt(s??0)),ee=Qy({element:f.value,rotationCenter:q.value,rotationElement:w.value,scale:y.value},r,ce);return{handle:{style:ee.handleStyle,...g(ce,ee.radius),...ee.attrs??{},...(u==null?void 0:u())??{}},connector:{style:ee.connectorStyle,"data-epdf-rotation-connector":!0}}});return{dragProps:d,resize:G,vertices:W,rotation:J}}function n_(t){const e=n=>Array.isArray(n)?n.map(o=>e(o)):ht(n)||qn(n)||ur(n)?e(ke(n)):n&&typeof n=="object"?Object.keys(n).reduce((o,r)=>(o[r]=e(n[r]),o),{}):n;return e(t)}const kd="INTERACTION/INIT_STATE",Id="INTERACTION/CLEANUP_STATE",Gd="INTERACTION/ACTIVATE_MODE",Ld="INTERACTION/PAUSE",$d="INTERACTION/RESUME",Nd="INTERACTION/SET_CURSOR",o_="INTERACTION/SET_ACTIVE_DOCUMENT",jd="INTERACTION/SET_DEFAULT_MODE",Ud="INTERACTION/SET_EXCLUSION_RULES",Bd="INTERACTION/ADD_EXCLUSION_CLASS",zd="INTERACTION/REMOVE_EXCLUSION_CLASS",Wd="INTERACTION/ADD_EXCLUSION_ATTRIBUTE",Hd="INTERACTION/REMOVE_EXCLUSION_ATTRIBUTE";function r_(t,e){return{type:kd,payload:{documentId:t,state:e}}}function a_(t){return{type:Id,payload:t}}function i_(t,e){return{type:Gd,payload:{documentId:t,mode:e}}}function s_(t){return{type:Ld,payload:t}}function l_(t){return{type:$d,payload:t}}function c_(t,e){return{type:Nd,payload:{documentId:t,cursor:e}}}function Vd(t){return{type:jd,payload:{mode:t}}}function Yd(t){return{type:Ud,payload:{rules:t}}}function u_(t){return{type:Bd,payload:{className:t}}}function d_(t){return{type:zd,payload:{className:t}}}function p_(t){return{type:Wd,payload:{attribute:t}}}function h_(t){return{type:Hd,payload:{attribute:t}}}function g_(t){const e=["onPointerDown","onPointerUp","onPointerMove","onPointerEnter","onPointerLeave","onPointerCancel","onMouseDown","onMouseUp","onMouseMove","onMouseEnter","onMouseLeave","onMouseCancel","onClick","onDoubleClick"],n={};for(const o of e)n[o]=(r,a,i)=>{var s;for(const l of t){if(a.isImmediatePropagationStopped())break;(s=l[o])==null||s.call(l,r,a,i)}};return n}const qd="pointerMode",Kd=class extends jt{constructor(e,n,o){super(e,n),this.modes=new Map,this.cursorClaims=new Map,this.buckets=new Map,this.alwaysGlobal=new Map,this.alwaysPage=new Map,this.pageActivities=new Map,this.onModeChange$=$n(),this.onHandlerChange$=$n(),this.onCursorChange$=$n(),this.onStateChange$=Be(),this.onPageActivityChange$=$n(),this.registerMode({id:qd,scope:"page",exclusive:!1,cursor:"auto"}),this.dispatch(Vd(qd)),o.exclusionRules&&this.dispatch(Yd(o.exclusionRules))}onDocumentLoadingStarted(e){const n={activeMode:this.state.defaultMode,cursor:"auto",paused:!1};this.dispatch(r_(e,n)),this.cursorClaims.set(e,new Map),this.buckets.set(e,new Map),this.alwaysGlobal.set(e,new Set),this.alwaysPage.set(e,new Map),this.pageActivities.set(e,new Map);const o=this.buckets.get(e);for(const r of this.modes.keys())o.set(r,{global:new Set,page:new Map});this.logger.debug("InteractionManagerPlugin","DocumentOpened",`Initialized interaction state for document: ${e}`)}onDocumentClosed(e){const n=this.pageActivities.get(e);if(n){const o=new Set(n.values());n.clear();for(const r of o)this.onPageActivityChange$.emit({documentId:e,pageIndex:r,hasActivity:!1})}this.cursorClaims.delete(e),this.buckets.delete(e),this.alwaysGlobal.delete(e),this.alwaysPage.delete(e),this.pageActivities.delete(e),this.dispatch(a_(e)),this.logger.debug("InteractionManagerPlugin","DocumentClosed",`Cleaned up interaction state for document: ${e}`)}buildCapability(){return{getActiveMode:()=>this.getActiveMode(),getActiveInteractionMode:()=>this.getActiveInteractionMode(),activate:e=>this.activate(e),activateDefaultMode:()=>this.activateDefaultMode(),setCursor:(e,n,o)=>this.setCursor(e,n,o),getCurrentCursor:()=>this.getCurrentCursor(),removeCursor:e=>this.removeCursor(e),getHandlersForScope:e=>this.getHandlersForScope(e),activeModeIsExclusive:()=>this.activeModeIsExclusive(),pause:()=>this.pause(),resume:()=>this.resume(),isPaused:()=>this.registry.isDestroyed()||this.isPaused(),getState:()=>this.getDocumentStateOrThrow(),forDocument:e=>this.createInteractionScope(e),registerMode:e=>this.registerMode(e),registerHandlers:e=>this.registerHandlers(e),registerAlways:e=>this.registerAlways(e),setDefaultMode:e=>this.setDefaultMode(e),getDefaultMode:()=>this.state.defaultMode,getExclusionRules:()=>this.state.exclusionRules,setExclusionRules:e=>this.dispatch(Yd(e)),addExclusionClass:e=>this.dispatch(u_(e)),removeExclusionClass:e=>this.dispatch(d_(e)),addExclusionAttribute:e=>this.dispatch(p_(e)),removeExclusionAttribute:e=>this.dispatch(h_(e)),claimPageActivity:(e,n,o)=>this.claimPageActivity(e,n,o),releasePageActivity:(e,n)=>this.releasePageActivity(e,n),hasPageActivity:(e,n)=>this.hasPageActivity(e,n),onModeChange:this.onModeChange$.on,onCursorChange:this.onCursorChange$.on,onHandlerChange:this.onHandlerChange$.on,onStateChange:this.onStateChange$.on,onPageActivityChange:this.onPageActivityChange$.on}}createInteractionScope(e){return{getActiveMode:()=>this.getActiveMode(e),getActiveInteractionMode:()=>this.getActiveInteractionMode(e),activate:n=>this.activate(n,e),activateDefaultMode:()=>this.activateDefaultMode(e),setCursor:(n,o,r)=>this.setCursor(n,o,r,e),getCurrentCursor:()=>this.getCurrentCursor(e),removeCursor:n=>this.removeCursor(n,e),getHandlersForScope:n=>this.getHandlersForScope(n),activeModeIsExclusive:()=>this.activeModeIsExclusive(e),pause:()=>this.pause(e),resume:()=>this.resume(e),isPaused:()=>this.isPaused(e),getState:()=>this.getDocumentStateOrThrow(e),claimPageActivity:(n,o)=>this.claimPageActivity(e,n,o),releasePageActivity:n=>this.releasePageActivity(e,n),hasPageActivity:n=>this.hasPageActivity(e,n),onModeChange:n=>this.onModeChange$.on(o=>{o.documentId===e&&n(o.activeMode)}),onCursorChange:n=>this.onCursorChange$.on(o=>{o.documentId===e&&n(o.cursor)}),onStateChange:n=>this.onStateChange$.on(o=>{o.documentId===e&&n(o.state)}),onPageActivityChange:n=>this.onPageActivityChange$.on(o=>{o.documentId===e&&n({pageIndex:o.pageIndex,hasActivity:o.hasActivity})})}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Interaction state not found for document: ${e??"active"}`);return n}activate(e,n){var o;const r=n??this.getActiveDocumentId(),a=this.getDocumentStateOrThrow(r);if(!this.modes.has(e))throw new Error(`[interaction] unknown mode '${e}'`);if(e===a.activeMode)return;const i=a.activeMode;(o=this.cursorClaims.get(r))==null||o.clear(),this.notifyHandlersInactive(r,i),this.dispatch(i_(r,e)),this.emitCursor(r),this.notifyHandlersActive(r,e),this.onModeChange$.emit({documentId:r,activeMode:e,previousMode:i})}activateDefaultMode(e){const n=e??this.getActiveDocumentIdOrNull();n&&this.activate(this.state.defaultMode,n)}setDefaultMode(e){if(!this.modes.has(e))throw new Error(`[interaction] cannot set unknown mode '${e}' as default`);this.dispatch(Vd(e))}getActiveMode(e){return this.getDocumentStateOrThrow(e).activeMode}getActiveInteractionMode(e){const n=this.getDocumentState(e);return n?this.modes.get(n.activeMode)??null:null}activeModeIsExclusive(e){const n=this.getActiveInteractionMode(e);return!!(n!=null&&n.exclusive)}pause(e){const n=e??this.getActiveDocumentId();this.dispatch(s_(n))}resume(e){const n=e??this.getActiveDocumentId();this.dispatch(l_(n))}isPaused(e){return this.getDocumentStateOrThrow(e).paused}registerMode(e){this.modes.set(e.id,e);for(const n of this.buckets.keys()){const o=this.buckets.get(n);o.has(e.id)||o.set(e.id,{global:new Set,page:new Map})}}registerHandlers({documentId:e,modeId:n,handlers:o,pageIndex:r}){const a=Array.isArray(n)?n:[n],i=[],s=this.buckets.get(e);if(!s)throw new Error(`No buckets found for document: ${e}`);for(const l of a){const c=s.get(l);if(!c)throw new Error(`unknown mode '${l}'`);if(r==null)c.global.add(o);else{const u=c.page.get(r)??new Set;u.add(o),c.page.set(r,u)}i.push(()=>{if(r==null)c.global.delete(o);else{const u=c.page.get(r);u&&(u.delete(o),u.size===0&&c.page.delete(r))}})}return this.onHandlerChange$.emit({...this.state}),()=>{i.forEach(l=>l()),this.onHandlerChange$.emit({...this.state})}}registerAlways({scope:e,handlers:n}){if(e.type==="global"){const a=this.alwaysGlobal.get(e.documentId)??new Set;return a.add(n),this.alwaysGlobal.set(e.documentId,a),this.onHandlerChange$.emit({...this.state}),()=>{a.delete(n),this.onHandlerChange$.emit({...this.state})}}const o=this.alwaysPage.get(e.documentId)??new Map,r=o.get(e.pageIndex)??new Set;return r.add(n),o.set(e.pageIndex,r),this.alwaysPage.set(e.documentId,o),this.onHandlerChange$.emit({...this.state}),()=>{r.delete(n),this.onHandlerChange$.emit({...this.state})}}getHandlersForScope(e){var n;const o=this.getDocumentState(e.documentId);if(!o)return null;const r=this.modes.get(o.activeMode);if(!r)return null;const a=this.buckets.get(e.documentId);if(!a)return null;const i=a.get(r.id);if(!i)return null;const s=(u,d)=>u.size||d.size?g_([...u,...d]):null;if(e.type==="global"){const u=this.alwaysGlobal.get(e.documentId)??new Set,d=r.scope==="global"?i.global:new Set;return s(u,d)}const l=((n=this.alwaysPage.get(e.documentId))==null?void 0:n.get(e.pageIndex))??new Set,c=r.scope==="page"?i.page.get(e.pageIndex)??new Set:new Set;return s(l,c)}setCursor(e,n,o=0,r){const a=r??this.getActiveDocumentId(),i=this.cursorClaims.get(a);i&&(i.set(e,{cursor:n,priority:o}),this.emitCursor(a))}removeCursor(e,n){const o=n??this.getActiveDocumentId(),r=this.cursorClaims.get(o);r&&(r.delete(e),this.emitCursor(o))}getCurrentCursor(e){return this.getDocumentStateOrThrow(e).cursor}emitCursor(e){var n;const o=this.cursorClaims.get(e);if(!o)return;const r=this.getDocumentState(e);if(!r)return;const a=[...o.values()].sort((i,s)=>s.priority-i.priority)[0]??{cursor:((n=this.modes.get(r.activeMode))==null?void 0:n.cursor)??"auto"};a.cursor!==r.cursor&&(this.dispatch(c_(e,a.cursor)),this.onCursorChange$.emit({documentId:e,cursor:a.cursor}))}claimPageActivity(e,n,o){let r=this.pageActivities.get(e);r||(r=new Map,this.pageActivities.set(e,r));const a=r.get(n);a!==o&&(r.set(n,o),a!==void 0&&!this.pageHasAnyTopic(e,a)&&this.onPageActivityChange$.emit({documentId:e,pageIndex:a,hasActivity:!1}),this.countTopicsOnPage(e,o)===1&&this.onPageActivityChange$.emit({documentId:e,pageIndex:o,hasActivity:!0}))}releasePageActivity(e,n){const o=this.pageActivities.get(e);if(!o)return;const r=o.get(n);r!==void 0&&(o.delete(n),this.pageHasAnyTopic(e,r)||this.onPageActivityChange$.emit({documentId:e,pageIndex:r,hasActivity:!1}))}hasPageActivity(e,n){return this.pageHasAnyTopic(e,n)}pageHasAnyTopic(e,n){const o=this.pageActivities.get(e);if(!o)return!1;for(const r of o.values())if(r===n)return!0;return!1}countTopicsOnPage(e,n){const o=this.pageActivities.get(e);if(!o)return 0;let r=0;for(const a of o.values())a===n&&r++;return r}notifyHandlersActive(e,n){var o,r;(o=this.alwaysGlobal.get(e))==null||o.forEach(l=>{var c;(c=l.onHandlerActiveStart)==null||c.call(l,n)}),(r=this.alwaysPage.get(e))==null||r.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveStart)==null||u.call(c,n)})});const a=this.modes.get(n);if(!a)return;const i=this.buckets.get(e);if(!i)return;const s=i.get(n);s&&(a.scope==="global"&&s.global.forEach(l=>{var c;(c=l.onHandlerActiveStart)==null||c.call(l,n)}),a.scope==="page"&&s.page.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveStart)==null||u.call(c,n)})}))}notifyHandlersInactive(e,n){var o,r;(o=this.alwaysGlobal.get(e))==null||o.forEach(l=>{var c;(c=l.onHandlerActiveEnd)==null||c.call(l,n)}),(r=this.alwaysPage.get(e))==null||r.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveEnd)==null||u.call(c,n)})});const a=this.modes.get(n);if(!a)return;const i=this.buckets.get(e);if(!i)return;const s=i.get(n);s&&(a.scope==="global"&&s.global.forEach(l=>{var c;(c=l.onHandlerActiveEnd)==null||c.call(l,n)}),a.scope==="page"&&s.page.forEach(l=>{l.forEach(c=>{var u;(u=c.onHandlerActiveEnd)==null||u.call(c,n)})}))}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&this.onStateChange$.emit({documentId:o,state:a})}}async initialize(e){this.logger.info("InteractionManagerPlugin","Initialize","Interaction Manager Plugin initialized")}async destroy(){this.pageActivities.clear(),this.onModeChange$.clear(),this.onCursorChange$.clear(),this.onHandlerChange$.clear(),this.onStateChange$.clear(),this.onPageActivityChange$.clear(),await super.destroy()}};Kd.id="interaction-manager";let Xd=Kd;const Zd="interaction-manager",f_={id:Zd,name:"Interaction Manager Plugin",version:"1.0.0",provides:["interaction-manager"],requires:[],optional:[],defaultConfig:{exclusionRules:{classes:[],dataAttributes:["data-no-interaction"]}}},Qd={defaultMode:"pointerMode",exclusionRules:{classes:[],dataAttributes:["data-no-interaction"]},documents:{},activeDocumentId:null},m_={manifest:f_,create:(t,e)=>new Xd(Zd,t,e),reducer:(t=Qd,e)=>{switch(e.type){case kd:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case Id:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case o_:return{...t,activeDocumentId:e.payload};case Gd:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,activeMode:o}}}:t}case Nd:{const{documentId:n,cursor:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,cursor:o}}}:t}case Ld:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,paused:!0}}}:t}case $d:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,paused:!1}}}:t}case jd:return{...t,defaultMode:e.payload.mode};case Ud:return{...t,exclusionRules:e.payload.rules};case Bd:return{...t,exclusionRules:{...t.exclusionRules,classes:[...t.exclusionRules.classes||[],e.payload.className].filter((n,o,r)=>r.indexOf(n)===o)}};case zd:return{...t,exclusionRules:{...t.exclusionRules,classes:(t.exclusionRules.classes||[]).filter(n=>n!==e.payload.className)}};case Wd:return{...t,exclusionRules:{...t.exclusionRules,dataAttributes:[...t.exclusionRules.dataAttributes||[],e.payload.attribute].filter((n,o,r)=>r.indexOf(n)===o)}};case Hd:return{...t,exclusionRules:{...t.exclusionRules,dataAttributes:(t.exclusionRules.dataAttributes||[]).filter(n=>n!==e.payload.attribute)}};default:return t}},initialState:Qd},P_={pointerdown:"onPointerDown",pointerup:"onPointerUp",pointermove:"onPointerMove",pointerenter:"onPointerEnter",pointerleave:"onPointerLeave",pointercancel:"onPointerCancel",mousedown:"onMouseDown",mouseup:"onMouseUp",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mousecancel:"onMouseCancel",click:"onClick",dblclick:"onDoubleClick",touchstart:"onPointerDown",touchend:"onPointerUp",touchmove:"onPointerMove",touchcancel:"onPointerCancel"},Jd=["pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","mousedown","mouseup","mousemove","mouseenter","mouseleave","mousecancel","click","dblclick"],F_=["touchstart","touchend","touchmove","touchcancel"],ep=typeof PointerEvent<"u"?Jd:[...Jd,...F_];function b_(t,e){return t.startsWith("touch")?{passive:!e}:{passive:!1}}function tp(t){return typeof TouchEvent<"u"&&t instanceof TouchEvent}function y_(t,e){var n,o,r;if(!t)return!1;let a=t;for(;a;){if((n=e.classes)!=null&&n.length){for(const i of e.classes)if((o=a.classList)!=null&&o.contains(i))return!0}if((r=e.dataAttributes)!=null&&r.length){for(const i of e.dataAttributes)if(a.hasAttribute(i))return!0}a=a.parentElement}return!1}function np(t,e,n,o){const r=t.forDocument(e.documentId);let a=t.getHandlersForScope(e);const i=()=>{var _;return((_=r.getActiveInteractionMode())==null?void 0:_.wantsRawTouch)!==!1},s={};let l=i();const c=_=>{ep.forEach(E=>{const A=s[E]??(s[E]=y);n.addEventListener(E,A,b_(E,_))})},u=()=>{ep.forEach(_=>{const E=s[_];E&&n.removeEventListener(_,E)})};c(l),n.style.touchAction=l?"none":"";const d=r.onModeChange(()=>{if(e.type==="global"){const E=r.getActiveInteractionMode();n.style.cursor=(E==null?void 0:E.scope)==="global"?E.cursor??"auto":"auto"}a=t.getHandlersForScope(e);const _=i();_!==l&&(u(),c(_),l=_,n.style.touchAction=l?"none":"")}),p=t.onHandlerChange(()=>{a=t.getHandlersForScope(e)}),h=r.getActiveInteractionMode(),g=r.getCurrentCursor();n.style.cursor=e.type==="global"&&(h==null?void 0:h.scope)!=="global"?"auto":g;const f=r.onCursorChange(_=>{var E;e.type==="global"&&((E=r.getActiveInteractionMode())==null?void 0:E.scope)!=="global"||(n.style.cursor=_)}),F=(_,E)=>{if(o)return o(_,E);const A=E.getBoundingClientRect();return{x:_.clientX-A.left,y:_.clientY-A.top}};function y(_){var E;if(t.isPaused())return;const A=t.getExclusionRules();if(_.target&&y_(_.target,A))return;const T=P_[_.type];if(!T||!(a!=null&&a[T]))return;tp(_)&&l&&(_.type==="touchmove"||_.type==="touchcancel")&&_.preventDefault();let q,w,G=!1;if(tp(_)){const W=_.type==="touchend"||_.type==="touchcancel"?_.changedTouches[0]:_.touches[0];if(!W)return;q=F(W,n),w={clientX:W.clientX,clientY:W.clientY,ctrlKey:_.ctrlKey,shiftKey:_.shiftKey,altKey:_.altKey,metaKey:_.metaKey,target:_.target,currentTarget:_.currentTarget,setPointerCapture:()=>{},releasePointerCapture:()=>{},stopImmediatePropagation:()=>{G=!0},isImmediatePropagationStopped:()=>G}}else{const W=_;q=F(W,n),w={clientX:W.clientX,clientY:W.clientY,ctrlKey:W.ctrlKey,shiftKey:W.shiftKey,altKey:W.altKey,metaKey:W.metaKey,target:W.target,currentTarget:W.currentTarget,setPointerCapture:()=>{var J,ue;(ue=(J=W.target)==null?void 0:J.setPointerCapture)==null||ue.call(J,W.pointerId)},releasePointerCapture:()=>{var J,ue;(ue=(J=W.target)==null?void 0:J.releasePointerCapture)==null||ue.call(J,W.pointerId)},stopImmediatePropagation:()=>{G=!0},isImmediatePropagationStopped:()=>G}}(E=a[T])==null||E.call(a,q,w,r.getActiveMode())}return()=>{u(),d(),f(),p()}}const Ja=()=>It(Xd.id);function __({modeId:t,pageIndex:e,documentId:n}){const{provides:o}=Ja();return{register:(r,a)=>{const i=(a==null?void 0:a.modeId)??t,s=$t((a==null?void 0:a.pageIndex)??e),l=$t((a==null?void 0:a.documentId)??n),c=o.value;return i?c==null?void 0:c.registerHandlers({modeId:i,handlers:r,pageIndex:s,documentId:l}):c==null?void 0:c.registerAlways({scope:s!==void 0?{type:"page",documentId:l,pageIndex:s}:{type:"global",documentId:l},handlers:r})}}}function v_(t){const{provides:e}=Ja(),n=Q(!1);return Se([e,()=>$t(t)],([o,r],a,i)=>{if(!o){n.value=!1;return}const s=o.forDocument(r),l=s.getActiveInteractionMode();n.value=(l==null?void 0:l.scope)==="page"&&!!l.exclusive;const c=s.onModeChange(()=>{const u=s.getActiveInteractionMode();n.value=(u==null?void 0:u.scope)==="page"&&!!(u!=null&&u.exclusive)});i(c)},{immediate:!0}),n}const D_=ie({__name:"global-pointer-provider",props:{documentId:{}},setup(t){const e=t,n=Q(null),{provides:o}=Ja();return Xn(r=>{if(o.value&&n.value){const a=np(o.value,{type:"global",documentId:e.documentId},n.value);r(a)}}),(r,a)=>(v(),C("div",{ref_key:"divRef",ref:n,style:{width:"100%",height:"100%"}},[$e(r.$slots,"default")],512))}}),S_={key:0,style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10}},E_=ie({__name:"page-pointer-provider",props:{documentId:{},pageIndex:{},rotation:{},scale:{},convertEventToPoint:{type:Function}},setup(t){const e=t,n=Q(null),{provides:o}=Ja(),r=v_(()=>e.documentId),a=Dn(()=>e.documentId),i=P(()=>{var h,g,f;return(f=(g=(h=a.value)==null?void 0:h.document)==null?void 0:g.pages)==null?void 0:f[e.pageIndex]}),s=P(()=>{var h;return((h=i.value)==null?void 0:h.size)??{width:0,height:0}}),l=P(()=>{var h;return((h=i.value)==null?void 0:h.rotation)??0}),c=P(()=>{var h;if(e.rotation!==void 0)return e.rotation;const g=((h=a.value)==null?void 0:h.rotation)??0;return(l.value+g)%4}),u=P(()=>{var h;return e.scale??((h=a.value)==null?void 0:h.scale)??1}),d=P(()=>Ta(s.value,0,u.value)),p=P(()=>(h,g)=>{const f=g.getBoundingClientRect(),F={x:h.clientX-f.left,y:h.clientY-f.top},y=Ta({width:d.value.width,height:d.value.height},c.value,1);return tF(y,F,c.value,u.value)});return Se([o,()=>$t(e.documentId),()=>e.pageIndex,()=>e.convertEventToPoint,p],([h,g,f,F,y],_,E)=>{if(!h||!n.value)return;const A=np(h,{type:"page",documentId:g,pageIndex:f},n.value,F||y);E(A)},{immediate:!0}),(h,g)=>(v(),C("div",xe({ref_key:"divRef",ref:n,style:{position:"relative",width:d.value.width+"px",height:d.value.height+"px"}},h.$attrs),[$e(h.$slots,"default"),I(r)?(v(),C("div",S_)):ae("",!0)],16))}}),op="selection",A_={id:op,name:"Selection Plugin",version:"1.0.0",provides:["selection"],requires:["interaction-manager"],optional:["viewport","scroll"],defaultConfig:{menuHeight:40}},rp="SELECTION/INIT_STATE",ap="SELECTION/CLEANUP_STATE",ip="SELECTION/CACHE_PAGE_GEOMETRY",sp="SELECTION/SET_SELECTION",lp="SELECTION/START_SELECTION",cp="SELECTION/END_SELECTION",up="SELECTION/CLEAR_SELECTION",dp="SELECTION/SET_RECTS",pp="SELECTION/SET_SLICES",hp="SELECTION/EVICT_PAGE_GEOMETRY",x_="SELECTION/RESET",C_=(t,e)=>({type:rp,payload:{documentId:t,state:e}}),T_=t=>({type:ap,payload:t}),M_=(t,e,n)=>({type:ip,payload:{documentId:t,page:e,geo:n}}),gp=(t,e)=>({type:sp,payload:{documentId:t,selection:e}}),fp=t=>({type:lp,payload:{documentId:t}}),mp=t=>({type:cp,payload:{documentId:t}}),R_=t=>({type:up,payload:{documentId:t}}),Pp=(t,e)=>({type:dp,payload:{documentId:t,rects:e}}),Fp=(t,e)=>({type:pp,payload:{documentId:t,slices:e}}),w_=(t,e)=>({type:hp,payload:{documentId:t,pages:e}}),bp={geometry:{},rects:{},slices:{},selection:null,active:!1,selecting:!1},yp={documents:{}},Sn=(t,e,n)=>({...t,documents:{...t.documents,[e]:n}}),O_=(t=yp,e)=>{switch(e.type){case rp:{const{documentId:n,state:o}=e.payload;return Sn(t,n,o)}case ap:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r}}case ip:{const{documentId:n,page:o,geo:r}=e.payload,a=t.documents[n];return a?Sn(t,n,{...a,geometry:{...a.geometry,[o]:r}}):t}case sp:{const{documentId:n,selection:o}=e.payload,r=t.documents[n];return r?Sn(t,n,{...r,selection:o,active:!0}):t}case lp:{const{documentId:n}=e.payload,o=t.documents[n];return o?Sn(t,n,{...o,selecting:!0,selection:null,rects:{}}):t}case cp:{const{documentId:n}=e.payload,o=t.documents[n];return o?Sn(t,n,{...o,selecting:!1}):t}case up:{const{documentId:n}=e.payload,o=t.documents[n];return o?Sn(t,n,{...o,selecting:!1,selection:null,rects:{},active:!1}):t}case dp:{const{documentId:n,rects:o}=e.payload,r=t.documents[n];return r?Sn(t,n,{...r,rects:o}):t}case pp:{const{documentId:n,slices:o}=e.payload,r=t.documents[n];return r?Sn(t,n,{...r,slices:o}):t}case hp:{const{documentId:n,pages:o}=e.payload,r=t.documents[n];if(!r)return t;const a={...r.geometry},i={...r.rects},s={...r.slices};for(const l of o)delete a[l],delete i[l],delete s[l];return Sn(t,n,{...r,geometry:a,rects:i,slices:s})}case x_:{const{documentId:n}=e.payload;return t.documents[n]?Sn(t,n,bp):t}default:return t}};function Gr(t,e){return t.rects[e]??[]}function Zo(t,e){return Zi(Gr(t,e))}function $s(t){const e=[],n=t.rects;for(const o in n){const r=Number(o),a=Zi(n[r]);a&&e.push({page:r,rect:a})}return e}function _p(t,e){const n=t.rects[e]||[];if(n.length===0)return null;const o=Zo(t,e);return o?{pageIndex:e,rect:o,segmentRects:n}:null}function vp(t){const e=[],n=Object.keys(t.rects).map(Number);for(const o of n){const r=t.rects[o]||[];if(r.length===0)continue;const a=Zo(t,o);a&&e.push({pageIndex:o,rect:a,segmentRects:r})}return e}function ei(t,e,n=1.5){for(const s of t.runs){if(!(e.y>=s.rect.y&&e.y<=s.rect.y+s.rect.height&&e.x>=s.rect.x&&e.x<=s.rect.x+s.rect.width))continue;const c=s.glyphs.findIndex(u=>{const d=u.tightX??u.x,p=u.tightY??u.y,h=u.tightWidth??u.width,g=u.tightHeight??u.height;return e.x>=d&&e.x<=d+h&&e.y>=p&&e.y<=p+g});if(c!==-1)return s.charStart+c}if(n<=0)return-1;const r=k_(t,n)/2;let a=-1,i=1/0;for(const s of t.runs)if(!(e.y<s.rect.y-r||e.y>s.rect.y+s.rect.height+r||e.x<s.rect.x-r||e.x>s.rect.x+s.rect.width+r))for(let l=0;l<s.glyphs.length;l++){const c=s.glyphs[l];if(c.flags===2)continue;const u=c.tightX??c.x,d=c.tightY??c.y,p=c.tightWidth??c.width,h=c.tightHeight??c.height,g=u-r,f=u+p+r,F=d-r,y=d+h+r;if(e.x<g||e.x>f||e.y<F||e.y>y)continue;const _=Math.min(Math.abs(e.x-u),Math.abs(e.x-(u+p))),E=Math.min(Math.abs(e.y-d),Math.abs(e.y-(d+h))),A=_+E;A<i&&(i=A,a=s.charStart+l)}return a}function k_(t,e){let n=0,o=0;for(const r of t.runs)for(const a of r.glyphs)a.flags!==2&&(n+=a.height,o++);return o===0?0:n/o*e}function Dp(t,e,n){if(!t||!e||n<t.start.page||n>t.end.page)return null;const o=n===t.start.page?t.start.index:0,r=e.runs[e.runs.length-1],a=r.charStart+r.glyphs.length-1,i=n===t.end.page?t.end.index:a;return{from:o,to:i}}function Sp(t,e,n,o=!0){const r=[];for(const i of t.runs){const s=i.charStart,l=s+i.glyphs.length-1;if(l<e||s>n)continue;const c=Math.max(e,s)-s,u=Math.min(n,l)-s;let d=1/0,p=-1/0,h=1/0,g=-1/0,f=0,F=0,y=-1/0;const _=()=>{d!==1/0&&f>0&&r.push({rect:{origin:{x:d,y:h},size:{width:p-d,height:g-h}},charCount:f,fontSize:i.fontSize}),d=1/0,p=-1/0,h=1/0,g=-1/0,f=0,F=0,y=-1/0};for(let E=c;E<=u;E++){const A=i.glyphs[E];if(A.flags!==2){if(f>0&&y>-1/0){const T=Math.abs(A.x-y),q=F/f;q>0&&T>2.5*q&&_()}d=Math.min(d,A.x),p=Math.max(p,A.x+A.width),h=Math.min(h,A.y),g=Math.max(g,A.y+A.height),f++,F+=A.width,y=A.x+A.width}}_()}return o?$_(r):r.map(i=>i.rect)}function Ep(t,e){const n=Math.min(t.origin.x,e.origin.x),o=Math.min(t.origin.y,e.origin.y),r=Math.max(t.origin.x+t.size.width,e.origin.x+e.size.width),a=Math.max(t.origin.y+t.size.height,e.origin.y+e.size.height);return{origin:{x:n,y:o},size:{width:r-n,height:a-o}}}function I_(t,e){const n=Math.max(t.origin.x,e.origin.x),o=Math.max(t.origin.y,e.origin.y),r=Math.min(t.origin.x+t.size.width,e.origin.x+e.size.width),a=Math.min(t.origin.y+t.size.height,e.origin.y+e.size.height),i=Math.max(0,r-n),s=Math.max(0,a-o);return{origin:{x:n,y:o},size:{width:i,height:s}}}function Ns(t){return t.size.width<=0||t.size.height<=0}function G_(t,e){if(Ns(t)||Ns(e))return 0;const n=Ep(t,e);return n.size.height===t.size.height||n.size.height===e.size.height?1:I_(t,e).size.height/n.size.height}function L_(t,e){if(t.fontSize!=null&&e.fontSize!=null&&t.fontSize>0&&e.fontSize>0&&Math.max(t.fontSize,e.fontSize)/Math.min(t.fontSize,e.fontSize)>1.5)return!1;const o=.8,r=t.rect,a=e.rect;if(G_(r,a)<o)return!1;const i=1,s=i*r.size.width/t.charCount,l=i*a.size.width/e.charCount,c=r.origin.x-s,u=r.origin.x+r.size.width+s,d=a.origin.x-l,p=a.origin.x+a.size.width+l;return c<p&&u>d}function $_(t){const e=[];let n=null,o=null;for(const r of t)n&&o?L_(n,r)?o=Ep(o,r.rect):(e.push(o),o=r.rect):o=r.rect,n=r;return o&&!Ns(o)&&e.push(o),e}const N_=.5;function ti(t,e){for(let n=0;n<t.runs.length;n++){const o=t.runs[n],r=e-o.charStart;if(r>=0&&r<o.glyphs.length)return{runIdx:n,localIdx:r}}return null}function Ap(t){return t===1||t===2}function j_(t,e){if(!ti(t,e))return null;const o=B_(t);if(o===0)return null;let r=e;for(;r>0;){const i=ti(t,r-1);if(!i||Ap(t.runs[i.runIdx].glyphs[i.localIdx].flags))break;r--}let a=e;for(;a<o-1;){const i=ti(t,a+1);if(!i||Ap(t.runs[i.runIdx].glyphs[i.localIdx].flags))break;a++}return{from:r,to:a}}function U_(t,e){const n=ti(t,e);if(!n)return null;const o=t.runs[n.runIdx],r=o.rect.y,a=o.rect.y+o.rect.height;let i=o.charStart,s=o.charStart+o.glyphs.length-1;for(let l=n.runIdx-1;l>=0;l--){const c=t.runs[l];if(!xp(c)){if(!Cp(c.rect.y,c.rect.y+c.rect.height,r,a))break;i=c.charStart}}for(let l=n.runIdx+1;l<t.runs.length;l++){const c=t.runs[l];if(!xp(c)){if(!Cp(c.rect.y,c.rect.y+c.rect.height,r,a))break;s=c.charStart+c.glyphs.length-1}}return{from:i,to:s}}function xp(t){return t.rect.width===0&&t.rect.height===0}function Cp(t,e,n,o){const r=Math.max(e,o)-Math.min(t,n),a=Math.max(0,Math.min(e,o)-Math.max(t,n));return r===0?!1:a/r>=N_}function B_(t){if(t.runs.length===0)return 0;const e=t.runs[t.runs.length-1];return e.charStart+e.glyphs.length}const Tp=500;function z_(t){const e=t.minDragDistance??3,n=t.toleranceFactor??1.5;let o=null,r=null,a=!1,i=0;function s(){var l;o=null,r=null,a=!1,(l=t.setHasTextAnchor)==null||l.call(t,!1)}return{onPointerDown:(l,c,u)=>{var d,p;if(c.target===c.currentTarget&&((d=t.onEmptySpaceClick)==null||d.call(t,u)),!t.isEnabled(u))return;const h=Date.now();(i===0||h-i>=Tp)&&t.onClear(u);const g=t.getGeometry();if(!g)return;const f=ei(g,l,n);f!==-1&&(o=f,r=l,a=!1,(p=t.setHasTextAnchor)==null||p.call(t,!0))},onPointerMove:(l,c,u)=>{if(!t.isEnabled(u))return;const d=t.getGeometry();if(!d)return;const p=ei(d,l,n);if(t.setCursor(p!==-1?"text":null),o!==null&&r&&!a){const h=l.x-r.x,g=l.y-r.y;Math.sqrt(h*h+g*g)>=e&&(a=!0,t.onBegin(o,u),p!==-1&&t.onUpdate(p,u));return}t.isSelecting()&&p!==-1&&t.onUpdate(p,u)},onPointerUp:(l,c,u)=>{if(!t.isEnabled(u)){s();return}a&&t.onEnd(u),s()},onDoubleClick:(l,c,u)=>{var d;if(!t.isEnabled(u))return;const p=t.getGeometry();if(!p)return;const h=ei(p,l,n);h!==-1&&(i=Date.now(),(d=t.onWordSelect)==null||d.call(t,h,u))},onClick:(l,c,u)=>{var d;if(!t.isEnabled(u)||i===0)return;if(Date.now()-i>Tp){i=0;return}i=0;const h=t.getGeometry();if(!h)return;const g=ei(h,l,n);g!==-1&&((d=t.onLineSelect)==null||d.call(t,g,u))},onHandlerActiveEnd:l=>{s(),t.isEnabled(l)&&t.onClear(l)}}}function W_(t){const{pageSize:e,scale:n,minDragPx:o=5}=t;let r=null,a=null;return{onPointerDown:(i,s,l)=>{var c,u;t.isEnabled(l)&&((c=t.isTextSelecting)!=null&&c.call(t)||(r=i,a={origin:{x:i.x,y:i.y},size:{width:0,height:0}},t.onBegin(i,l),(u=s.setPointerCapture)==null||u.call(s)))},onPointerMove:(i,s,l)=>{if(!r||!t.isEnabled(l))return;const c=et(i.x,0,e.width),u=et(i.y,0,e.height);a={origin:{x:Math.min(r.x,c),y:Math.min(r.y,u)},size:{width:Math.abs(c-r.x),height:Math.abs(u-r.y)}},t.onChange(a,l)},onPointerUp:(i,s,l)=>{var c;t.isEnabled(l)&&(a&&r&&(Math.max(a.size.width,a.size.height)*n>o?t.onEnd(a,l):t.onCancel(l)),r=null,a=null,(c=s.releasePointerCapture)==null||c.call(s))},onPointerCancel:(i,s,l)=>{var c;t.isEnabled(l)&&(r=null,a=null,t.onCancel(l),(c=s.releasePointerCapture)==null||c.call(s))}}}const Mp=class extends jt{constructor(e,n,o){var r,a,i;super(e,n),this.enabledModesPerDoc=new Map,this.selecting=new Map,this.anchor=new Map,this.hasTextAnchor=new Map,this.marqueePage=new Map,this.pageCallbacks=new Map,this.geoAccessOrder=new Map,this.menuPlacement$=Tt((l,c)=>({documentId:l,placement:c})),this.selChange$=Tt((l,c)=>({documentId:l,selection:c,modeId:this.interactionManagerCapability.forDocument(l).getActiveMode()})),this.textRetrieved$=Tt((l,c)=>({documentId:l,text:c})),this.copyToClipboard$=Tt((l,c)=>({documentId:l,text:c}),{cache:!1}),this.beginSelection$=Tt((l,c)=>({documentId:l,page:c.page,index:c.index,modeId:c.modeId}),{cache:!1}),this.endSelection$=Tt((l,c)=>({documentId:l,modeId:c.modeId}),{cache:!1}),this.marqueeChange$=Tt((l,c)=>({documentId:l,pageIndex:c.pageIndex,rect:c.rect,modeId:c.modeId}),{cache:!1}),this.marqueeEnd$=Tt((l,c)=>({documentId:l,pageIndex:c.pageIndex,rect:c.rect,modeId:c.modeId}),{cache:!1}),this.emptySpaceClick$=Tt((l,c)=>({documentId:l,pageIndex:c.pageIndex,modeId:c.modeId}),{cache:!1}),this.viewportCapability=null,this.scrollCapability=null,this.config=o,this.menuHeight=o.menuHeight??40;const s=n.getPlugin("interaction-manager");if(!s)throw new Error("SelectionPlugin: InteractionManagerPlugin is required.");this.interactionManagerCapability=s.provides(),this.viewportCapability=((r=n.getPlugin("viewport"))==null?void 0:r.provides())??null,this.scrollCapability=((a=n.getPlugin("scroll"))==null?void 0:a.provides())??null,this.coreStore.onAction(Vo,l=>{const{documentId:c,pageIndexes:u}=l.payload,d=u.map(p=>this.getNewPageGeometryAndCache(c,p));Ie.all(d).wait(()=>{u.forEach(p=>{this.notifyPage(c,p)})},Yt)}),(i=this.viewportCapability)==null||i.onViewportChange(l=>{this.recalculateMenuPlacement(l.documentId)},{mode:"throttle",wait:100})}onDocumentLoadingStarted(e){var n;this.dispatch(C_(e,bp));const o=((n=this.config.marquee)==null?void 0:n.enabled)!==!1;this.enabledModesPerDoc.set(e,new Map([["pointerMode",{enableSelection:!0,showSelectionRects:!0,enableMarquee:o,showMarqueeRects:!0}]])),this.pageCallbacks.set(e,new Map),this.geoAccessOrder.set(e,[]),this.selecting.set(e,!1),this.anchor.set(e,void 0),this.hasTextAnchor.set(e,!1)}onDocumentClosed(e){this.dispatch(T_(e)),this.enabledModesPerDoc.delete(e),this.pageCallbacks.delete(e),this.geoAccessOrder.delete(e),this.selecting.delete(e),this.hasTextAnchor.delete(e),this.anchor.delete(e),this.marqueePage.delete(e),this.selChange$.clearScope(e),this.textRetrieved$.clearScope(e),this.copyToClipboard$.clearScope(e),this.beginSelection$.clearScope(e),this.endSelection$.clearScope(e),this.menuPlacement$.clearScope(e),this.marqueeChange$.clearScope(e),this.marqueeEnd$.clearScope(e),this.emptySpaceClick$.clearScope(e)}async initialize(){}async destroy(){this.selChange$.clear(),this.textRetrieved$.clear(),this.copyToClipboard$.clear(),this.beginSelection$.clear(),this.endSelection$.clear(),this.menuPlacement$.clear(),this.marqueeChange$.clear(),this.marqueeEnd$.clear(),this.emptySpaceClick$.clear(),super.destroy()}buildCapability(){const e=n=>n??this.getActiveDocumentId();return{getFormattedSelection:n=>vp(this.getDocumentState(e(n))),getFormattedSelectionForPage:(n,o)=>_p(this.getDocumentState(e(o)),n),getHighlightRectsForPage:(n,o)=>Gr(this.getDocumentState(e(o)),n),getHighlightRects:n=>this.getDocumentState(e(n)).rects,getBoundingRectForPage:(n,o)=>Zo(this.getDocumentState(e(o)),n),getBoundingRects:n=>$s(this.getDocumentState(e(n))),getSelectedText:n=>this.getSelectedText(e(n)),clear:n=>this.clearSelection(e(n)),copyToClipboard:n=>this.copyToClipboard(e(n)),getState:n=>this.getDocumentState(e(n)),enableForMode:(n,o,r)=>{var a;return(a=this.enabledModesPerDoc.get(e(r)))==null?void 0:a.set(n,{...o})},isEnabledForMode:(n,o)=>{var r;return((r=this.enabledModesPerDoc.get(e(o)))==null?void 0:r.has(n))??!1},setMarqueeEnabled:(n,o)=>this.setMarqueeEnabled(e(o),n),isMarqueeEnabled:n=>this.isMarqueeEnabled(e(n)),forDocument:this.createSelectionScope.bind(this),onCopyToClipboard:this.copyToClipboard$.onGlobal,onSelectionChange:this.selChange$.onGlobal,onTextRetrieved:this.textRetrieved$.onGlobal,onBeginSelection:this.beginSelection$.onGlobal,onEndSelection:this.endSelection$.onGlobal,onMarqueeChange:this.marqueeChange$.onGlobal,onMarqueeEnd:this.marqueeEnd$.onGlobal,onEmptySpaceClick:this.emptySpaceClick$.onGlobal}}createSelectionScope(e){return{getFormattedSelection:()=>vp(this.getDocumentState(e)),getFormattedSelectionForPage:n=>_p(this.getDocumentState(e),n),getHighlightRectsForPage:n=>Gr(this.getDocumentState(e),n),getHighlightRects:()=>this.getDocumentState(e).rects,getBoundingRectForPage:n=>Zo(this.getDocumentState(e),n),getBoundingRects:()=>$s(this.getDocumentState(e)),getSelectedText:()=>this.getSelectedText(e),clear:()=>this.clearSelection(e),copyToClipboard:()=>this.copyToClipboard(e),getState:()=>this.getDocumentState(e),setMarqueeEnabled:n=>this.setMarqueeEnabled(e,n),isMarqueeEnabled:()=>this.isMarqueeEnabled(e),onSelectionChange:this.selChange$.forScope(e),onTextRetrieved:this.textRetrieved$.forScope(e),onCopyToClipboard:this.copyToClipboard$.forScope(e),onBeginSelection:this.beginSelection$.forScope(e),onEndSelection:this.endSelection$.forScope(e),onMarqueeChange:this.marqueeChange$.forScope(e),onMarqueeEnd:this.marqueeEnd$.forScope(e),onEmptySpaceClick:this.emptySpaceClick$.forScope(e)}}getDocumentState(e){const n=this.state.documents[e];if(!n)throw new Error(`Selection state not found for document: ${e}`);return n}onMenuPlacement(e,n){return this.menuPlacement$.forScope(e)(n)}registerSelectionOnPage(e){var n;const{documentId:o,pageIndex:r,onRectsChange:a}=e,i=this.state.documents[o];if(!i)return this.logger.warn("SelectionPlugin","RegisterFailed",`Cannot register selection on page ${r} for document ${o}: document state not initialized.`),()=>{};(n=this.pageCallbacks.get(o))==null||n.set(r,a);const s=this.getOrLoadGeometry(o,r),l=this.interactionManagerCapability.forDocument(o),c=this.enabledModesPerDoc.get(o);a({rects:Gr(i,r),boundingRect:Zo(i,r)}),s.wait(p=>{const h=this.getDocumentState(o),g=h.selection;if(!g||r<g.start.page||r>g.end.page)return;const f=Dp(g,p,r);if(!f)return;const F=Sp(p,f.from,f.to);this.dispatch(Pp(o,{...h.rects,[r]:F})),this.dispatch(Fp(o,{...h.slices,[r]:{start:f.from,count:f.to-f.from+1}})),this.notifyPage(o,r)},Yt);const u=z_({getGeometry:()=>this.getDocumentState(o).geometry[r],isEnabled:p=>{const h=c==null?void 0:c.get(p);return h?h.enableSelection!==!1:!1},onBegin:(p,h)=>this.beginSelection(o,r,p,h),onUpdate:(p,h)=>this.updateSelection(o,r,p,h),onEnd:p=>this.endSelection(o,p),onClear:p=>this.clearSelection(o,p),isSelecting:()=>this.selecting.get(o)??!1,setCursor:p=>p?l.setCursor("selection-text",p,10):l.removeCursor("selection-text"),onEmptySpaceClick:p=>this.emptySpaceClick$.emit(o,{pageIndex:r,modeId:p}),onWordSelect:(p,h)=>this.selectWord(o,r,p,h),onLineSelect:(p,h)=>this.selectLine(o,r,p,h),setHasTextAnchor:p=>this.hasTextAnchor.set(o,p),minDragDistance:this.config.minSelectionDragDistance,toleranceFactor:this.config.toleranceFactor}),d=this.interactionManagerCapability.registerAlways({scope:{type:"page",documentId:o,pageIndex:r},handlers:u});return()=>{var p;d(),(p=this.pageCallbacks.get(o))==null||p.delete(r),s.abort({code:ve.Cancelled,message:"Cleanup"})}}registerMarqueeOnPage(e){var n;const{documentId:o,pageIndex:r,scale:a,onRectChange:i}=e;if(!this.state.documents[o])return this.logger.warn("SelectionPlugin","RegisterMarqueeFailed",`Cannot register marquee on page ${r} for document ${o}: document state not initialized.`),()=>{};const l=this.coreState.core.documents[o];if(!l||!l.document)return this.logger.warn("SelectionPlugin","DocumentNotFound",`Cannot register marquee on page ${r}: document not found`),()=>{};const c=l.document.pages[r];if(!c)return this.logger.warn("SelectionPlugin","PageNotFound",`Cannot register marquee on page ${r}: page not found`),()=>{};const u=c.size,d=((n=this.config.marquee)==null?void 0:n.minDragPx)??5,p=()=>{var f;const F=this.interactionManagerCapability.forDocument(o).getActiveMode(),y=(f=this.enabledModesPerDoc.get(o))==null?void 0:f.get(F);return(y==null?void 0:y.showMarqueeRects)!==!1},h=W_({pageSize:u,scale:a,minDragPx:d,isEnabled:f=>{var F;const y=(F=this.enabledModesPerDoc.get(o))==null?void 0:F.get(f);return(y==null?void 0:y.enableMarquee)===!0},isTextSelecting:()=>(this.selecting.get(o)??!1)||(this.hasTextAnchor.get(o)??!1),onBegin:(f,F)=>this.beginMarquee(o,r,f,F),onChange:(f,F)=>{this.updateMarquee(o,r,f,F),i(p()?f:null)},onEnd:(f,F)=>{this.endMarquee(o,r,f,F),i(null)},onCancel:f=>{this.cancelMarquee(o,f),i(null)}});return this.interactionManagerCapability.registerAlways({scope:{type:"page",documentId:o,pageIndex:r},handlers:h})}getPlacementMetrics(e,n,o,r){var a;const i=(a=this.scrollCapability)==null?void 0:a.forDocument(e),s=i==null?void 0:i.getRectPositionForPage(n,o);if(!s)return null;const l=s.origin.y-r.scrollTop,c=s.origin.y+s.size.height-r.scrollTop;return{pageIndex:n,rect:o,spaceAbove:l,spaceBelow:r.clientHeight-c,isBottomVisible:c>0&&c<=r.clientHeight,isTopVisible:l>=0&&l<r.clientHeight}}emitMenuPlacement(e,n){this.menuPlacement$.emit(e,n),n?this.interactionManagerCapability.claimPageActivity(e,"selection-menu",n.pageIndex):this.interactionManagerCapability.releasePageActivity(e,"selection-menu")}recalculateMenuPlacement(e){const n=this.state.documents[e];if(!n)return;if(n.selecting||n.selection===null){this.emitMenuPlacement(e,null);return}const o=$s(n);if(o.length===0){this.emitMenuPlacement(e,null);return}const r=o[o.length-1];if(!this.viewportCapability||!this.scrollCapability){this.emitMenuPlacement(e,{pageIndex:r.page,rect:r.rect,spaceAbove:0,spaceBelow:1/0,suggestTop:!1,isVisible:!0});return}const i=this.viewportCapability.forDocument(e).getMetrics(),s=o[0],l=this.getPlacementMetrics(e,r.page,r.rect,i),c=this.getPlacementMetrics(e,s.page,s.rect,i);if(l&&l.isBottomVisible&&l.spaceBelow>this.menuHeight){this.emitMenuPlacement(e,{...l,suggestTop:!1,isVisible:!0});return}if(c&&c.isTopVisible){this.emitMenuPlacement(e,{...c,suggestTop:!0,isVisible:!0});return}if(l&&l.isBottomVisible){this.emitMenuPlacement(e,{...l,suggestTop:!1,isVisible:!0});return}this.emitMenuPlacement(e,null)}notifyPage(e,n){var o,r;const a=(o=this.pageCallbacks.get(e))==null?void 0:o.get(n);if(a){const i=this.getDocumentState(e),s=this.interactionManagerCapability.forDocument(e).getActiveMode(),l=(r=this.enabledModesPerDoc.get(e))==null?void 0:r.get(s),c=l&&(l.showSelectionRects??l.showRects)!==!1;a(c?{rects:Gr(i,n),boundingRect:Zo(i,n)}:{rects:[],boundingRect:null})}}notifyAllPages(e){var n;(n=this.pageCallbacks.get(e))==null||n.forEach((o,r)=>{this.notifyPage(e,r)})}getNewPageGeometryAndCache(e,n){const o=this.getCoreDocument(e);if(!o||!o.document)return Ue.reject({code:ve.NotFound,message:"Doc Not Found"});const r=o.document.pages.find(i=>i.index===n),a=this.engine.getPageGeometry(o.document,r);return a.wait(i=>{this.dispatch(M_(e,n,i)),this.touchGeometry(e,n)},Yt),a}getOrLoadGeometry(e,n){const o=this.getDocumentState(e).geometry[n];return o?(this.touchGeometry(e,n),Ue.resolve(o)):this.getNewPageGeometryAndCache(e,n)}touchGeometry(e,n){const o=this.geoAccessOrder.get(e);if(!o)return;const r=o.indexOf(n);r>-1&&o.splice(r,1),o.push(n),this.evictGeometryIfNeeded(e)}evictGeometryIfNeeded(e){const n=this.config.maxCachedGeometries??50,o=this.geoAccessOrder.get(e);if(!o||o.length<=n)return;const r=this.pageCallbacks.get(e),a=[];for(;o.length-a.length>n;){const i=o.find(s=>!a.includes(s)&&!(r!=null&&r.has(s)));if(i===void 0)break;a.push(i)}if(a.length!==0){for(const i of a){const s=o.indexOf(i);s>-1&&o.splice(s,1)}this.dispatch(w_(e,a))}}beginSelection(e,n,o,r){this.selecting.set(e,!0),this.anchor.set(e,{page:n,index:o}),this.dispatch(fp(e)),this.beginSelection$.emit(e,{page:n,index:o,modeId:r}),this.recalculateMenuPlacement(e)}endSelection(e,n){this.selecting.set(e,!1),this.anchor.set(e,void 0),this.dispatch(mp(e)),this.endSelection$.emit(e,{modeId:n}),this.recalculateMenuPlacement(e)}clearSelection(e,n){this.selecting.set(e,!1),this.anchor.set(e,void 0),this.dispatch(R_(e)),this.selChange$.emit(e,null),this.emitMenuPlacement(e,null),this.notifyAllPages(e)}selectWord(e,n,o,r){const a=this.getDocumentState(e).geometry[n];if(!a)return;const i=j_(a,o);i&&this.applyInstantSelection(e,n,i.from,i.to,r)}selectLine(e,n,o,r){const a=this.getDocumentState(e).geometry[n];if(!a)return;const i=U_(a,o);i&&this.applyInstantSelection(e,n,i.from,i.to,r)}applyInstantSelection(e,n,o,r,a){const i={start:{page:n,index:o},end:{page:n,index:r}};this.selecting.set(e,!1),this.anchor.set(e,void 0),this.dispatch(fp(e)),this.dispatch(gp(e,i)),this.updateRectsAndSlices(e,i),this.dispatch(mp(e)),this.selChange$.emit(e,i),this.beginSelection$.emit(e,{page:n,index:o,modeId:a}),this.endSelection$.emit(e,{modeId:a});for(let s=i.start.page;s<=i.end.page;s++)this.notifyPage(e,s);this.recalculateMenuPlacement(e)}updateSelection(e,n,o,r){if(!this.selecting.get(e)||!this.anchor.get(e))return;const a=this.anchor.get(e),i=n>a.page||n===a.page&&o>=a.index,c={start:i?a:{page:n,index:o},end:i?{page:n,index:o}:a};this.dispatch(gp(e,c)),this.updateRectsAndSlices(e,c),this.selChange$.emit(e,c);for(let u=c.start.page;u<=c.end.page;u++)this.notifyPage(e,u)}updateRectsAndSlices(e,n){const o=this.getDocumentState(e),r={},a={};for(let i=n.start.page;i<=n.end.page;i++){const s=o.geometry[i],l=Dp(n,s,i);l&&(r[i]=Sp(s,l.from,l.to),a[i]={start:l.from,count:l.to-l.from+1})}this.dispatch(Pp(e,r)),this.dispatch(Fp(e,a))}getSelectedText(e){if(!this.checkPermission(e,te.CopyContents))return this.logger.debug("SelectionPlugin","GetSelectedText",`Cannot get selected text: document ${e} lacks CopyContents permission`),Ue.reject({code:ve.Security,message:"Document lacks CopyContents permission"});const n=this.getCoreDocument(e),o=this.getDocumentState(e);if(!(n!=null&&n.document)||!o.selection)return Ue.reject({code:ve.NotFound,message:"Doc Not Found or No Selection"});const r=o.selection,a=[];for(let s=r.start.page;s<=r.end.page;s++){const l=o.slices[s];l&&a.push({pageIndex:s,charIndex:l.start,charCount:l.count})}if(a.length===0)return Ue.resolve([]);const i=this.engine.getTextSlices(n.document,a);return i.wait(s=>{this.textRetrieved$.emit(e,s)},Yt),i}copyToClipboard(e){if(!this.checkPermission(e,te.CopyContents)){this.logger.debug("SelectionPlugin","CopyToClipboard",`Cannot copy to clipboard: document ${e} lacks CopyContents permission`);return}this.getSelectedText(e).wait(o=>{this.copyToClipboard$.emit(e,o.join(`
22
+ `))},Yt)}beginMarquee(e,n,o,r){this.marqueePage.set(e,n)}updateMarquee(e,n,o,r){this.marqueeChange$.emit(e,{pageIndex:n,rect:o,modeId:r})}endMarquee(e,n,o,r){this.marqueeEnd$.emit(e,{pageIndex:n,rect:o,modeId:r}),this.marqueeChange$.emit(e,{pageIndex:n,rect:null,modeId:r}),this.marqueePage.delete(e)}cancelMarquee(e,n){const o=this.marqueePage.get(e);o!==void 0&&(this.marqueeChange$.emit(e,{pageIndex:o,rect:null,modeId:n}),this.marqueePage.delete(e))}setMarqueeEnabled(e,n){const o=this.enabledModesPerDoc.get(e);if(!o)return;const r=o.get("pointerMode");r?r.enableMarquee=n:n&&o.set("pointerMode",{enableMarquee:!0})}isMarqueeEnabled(e){var n;const o=(n=this.enabledModesPerDoc.get(e))==null?void 0:n.get("pointerMode");return(o==null?void 0:o.enableMarquee)!==!1}};Mp.id="selection";let js=Mp;const H_={manifest:A_,create:(t,e)=>new js(op,t,e),reducer:O_,initialState:yp},Us=()=>It(js.id),Rp=()=>Nn(js.id),V_=ie({__name:"text-selection",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:Er.Degree0},background:{default:"rgba(33,150,243)"},selectionMenu:{}},setup(t){const e=t,n=Pa(),{plugin:o}=Rp(),r=Dn(()=>e.documentId),a=P(()=>{var f,F,y;return(y=(F=(f=r.value)==null?void 0:f.document)==null?void 0:F.pages)==null?void 0:y[e.pageIndex]}),i=Q([]),s=Q(null),l=Q(null),c=P(()=>{var f;return e.scale!==void 0?e.scale:((f=r.value)==null?void 0:f.scale)??1}),u=P(()=>{var f,F;if(e.rotation!==void 0)return e.rotation;const y=((f=a.value)==null?void 0:f.rotation)??0,_=((F=r.value)==null?void 0:F.rotation)??0;return(y+_)%4}),d=P(()=>!l.value||l.value.pageIndex!==e.pageIndex||!l.value.isVisible?!1:!!e.selectionMenu||!!n["selection-menu"]);Se([()=>o.value,()=>e.documentId,()=>e.pageIndex],([f,F,y],_,E)=>{if(!f||!F){i.value=[],s.value=null;return}const A=f.registerSelectionOnPage({documentId:F,pageIndex:y,onRectsChange:({rects:T,boundingRect:q})=>{i.value=T,s.value=q}});E(A)},{immediate:!0}),Se([()=>o.value,()=>e.documentId],([f,F],y,_)=>{if(!f||!F){l.value=null;return}const E=f.onMenuPlacement(F,A=>{l.value=A});_(E)},{immediate:!0});const p=()=>({type:"selection",pageIndex:e.pageIndex}),h=()=>{var f,F,y;return{suggestTop:((f=l.value)==null?void 0:f.suggestTop)??!1,spaceAbove:((F=l.value)==null?void 0:F.spaceAbove)??0,spaceBelow:((y=l.value)==null?void 0:y.spaceBelow)??0}},g=(f,F)=>e.selectionMenu?e.selectionMenu({rect:f,menuWrapperProps:F,selected:!0,placement:h(),context:p()}):null;return(f,F)=>s.value?(v(),C(pe,{key:0},[m("div",{style:Z({position:"absolute",left:`${s.value.origin.x*c.value}px`,top:`${s.value.origin.y*c.value}px`,width:`${s.value.size.width*c.value}px`,height:`${s.value.size.height*c.value}px`,mixBlendMode:"multiply",isolation:"isolate",pointerEvents:"none"})},[(v(!0),C(pe,null,tt(i.value,(y,_)=>(v(),C("div",{key:_,style:Z({position:"absolute",left:`${(y.origin.x-s.value.origin.x)*c.value}px`,top:`${(y.origin.y-s.value.origin.y)*c.value}px`,width:`${y.size.width*c.value}px`,height:`${y.size.height*c.value}px`,background:t.background})},null,4))),128))],4),d.value?(v(),he(I(Ir),{key:0,rect:{origin:{x:l.value.rect.origin.x*c.value,y:l.value.rect.origin.y*c.value},size:{width:l.value.rect.size.width*c.value,height:l.value.rect.size.height*c.value}},rotation:u.value},{default:We(({rect:y,menuWrapperProps:_})=>[t.selectionMenu?(v(),he(Fn(g(y,_)),{key:0})):$e(f.$slots,"selection-menu",{key:1,context:p(),selected:!0,rect:y,placement:h(),menuWrapperProps:_})]),_:3},8,["rect","rotation"])):ae("",!0)],64)):ae("",!0)}}),Y_=ie({__name:"marquee-selection",props:{documentId:{},pageIndex:{},scale:{},className:{},background:{},borderColor:{},borderStyle:{default:"dashed"},stroke:{},fill:{}},setup(t){const e=t,n=P(()=>e.borderColor??e.stroke??"rgba(0,122,204,0.8)"),o=P(()=>e.background??e.fill??"rgba(0,122,204,0.15)"),r=P(()=>e.borderStyle),{plugin:a}=Rp(),i=Dn(()=>e.documentId),s=Q(null),l=P(()=>{var c;return e.scale!==void 0?e.scale:((c=i.value)==null?void 0:c.scale)??1});return Se([a,()=>e.documentId,()=>e.pageIndex,l],([c,u,d,p],h,g)=>{if(s.value=null,!c)return;const f=c.registerMarqueeOnPage({documentId:u,pageIndex:d,scale:p,onRectChange:F=>{s.value=F}});g(()=>{f==null||f()})},{immediate:!0}),(c,u)=>s.value?(v(),C("div",{key:0,style:Z({position:"absolute",pointerEvents:"none",left:`${s.value.origin.x*l.value}px`,top:`${s.value.origin.y*l.value}px`,width:`${s.value.size.width*l.value}px`,height:`${s.value.size.height*l.value}px`,border:`1px ${r.value} ${n.value}`,background:o.value,boxSizing:"border-box",zIndex:1e3}),class:St(t.className)},null,6)):ae("",!0)}}),q_=ie({__name:"selection-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:Er.Degree0},background:{},textStyle:{},marqueeStyle:{},marqueeClassName:{},selectionMenu:{}},setup(t){const e=t,n=P(()=>{var o;return((o=e.textStyle)==null?void 0:o.background)??e.background});return(o,r)=>{var a,i,s;return v(),C(pe,null,[je(V_,{"document-id":t.documentId,"page-index":t.pageIndex,scale:t.scale,rotation:t.rotation,background:n.value,"selection-menu":t.selectionMenu},{"selection-menu":We(l=>[$e(o.$slots,"selection-menu",zt(Qt(l)))]),_:3},8,["document-id","page-index","scale","rotation","background","selection-menu"]),je(Y_,{"document-id":t.documentId,"page-index":t.pageIndex,scale:t.scale,background:(a=t.marqueeStyle)==null?void 0:a.background,"border-color":(i=t.marqueeStyle)==null?void 0:i.borderColor,"border-style":(s=t.marqueeStyle)==null?void 0:s.borderStyle,"class-name":t.marqueeClassName},null,8,["document-id","page-index","scale","background","border-color","border-style","class-name"])],64)}}}),K_=ie({__name:"copy-to-clipboard",setup(t){const{provides:e}=Us();return Xn(n=>{if(e.value){const o=e.value.onCopyToClipboard(({text:r})=>{navigator.clipboard.writeText(r).catch(a=>{console.error("Failed to copy text to clipboard:",a)})});n(o)}}),(n,o)=>null}}),X_=Tr(H_).addUtility(K_).build(),Z_=["src"],Q_=ie({__name:"appearance-image",props:{appearance:{},style:{}},setup(t){const e=t,n=Q(null),o=Q(null);Xn(a=>{const i=URL.createObjectURL(e.appearance.data);n.value=i,o.value=i,a(()=>{o.value&&(URL.revokeObjectURL(o.value),o.value=null)})});const r=()=>{o.value&&(URL.revokeObjectURL(o.value),o.value=null)};return(a,i)=>n.value?(v(),C("img",{key:0,src:n.value,alt:"",draggable:"false",onLoad:r,style:Z({position:"absolute",width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none",...t.style})},null,44,Z_)):ae("",!0)}}),ni=()=>Nn(Gs.id),Bn=()=>It(Gs.id),Bs=16;function J_(){try{const t=navigator;return/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&(t==null?void 0:t.maxTouchPoints)>1}catch{return!1}}let zs;function ev(){return zs===void 0&&(zs=J_()),zs}function tv(t,e){const n=ev();return P(()=>{const o=$t(t),r=$t(e),a=n&&r&&o>0&&o<Bs,i=a?Bs:o,s=a?o/Bs:1,l=a?{width:`${100/s}%`,height:`${100/s}%`,transform:`scale(${s})`,transformOrigin:"top left"}:void 0;return{needsComp:a,adjustedFontPx:i,scaleComp:s,wrapperStyle:l}})}const nv=["width","height","stroke"],ov=["width","height","stroke"],rv=ie({...{inheritAttrs:!1},__name:"annotation-container",props:{scale:{},documentId:{},pageIndex:{},rotation:{},pageWidth:{},pageHeight:{},trackedAnnotation:{},isSelected:{type:Boolean},isEditing:{type:Boolean,default:!1},isMultiSelected:{type:Boolean,default:!1},isDraggable:{type:Boolean},isResizable:{type:Boolean},isRotatable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},vertexConfig:{},selectionMenu:{},outlineOffset:{default:1},onDoubleClick:{},onSelect:{},appearance:{},zIndex:{default:1},selectionOutlineColor:{default:"#007ACC"},selectionOutline:{},resizeUi:{},vertexUi:{},rotationUi:{},blendMode:{},style:{}},setup(t){const e=t,n=P(()=>{var X;return((X=e.resizeUi)==null?void 0:X.color)??"#007ACC"}),o=P(()=>{var X;return((X=e.vertexUi)==null?void 0:X.color)??"#007ACC"}),r=P(()=>{var X;return((X=e.resizeUi)==null?void 0:X.size)??12}),a=P(()=>{var X;return((X=e.vertexUi)==null?void 0:X.size)??12}),i=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.size)??32}),s=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.color)??"white"}),l=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.connectorColor)??"#007ACC"}),c=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.iconColor)??"#007ACC"}),u=P(()=>{var X;return((X=e.rotationUi)==null?void 0:X.showConnector)??!1}),d=P(()=>{var X;return(X=e.rotationUi)==null?void 0:X.margin}),p=P(()=>{var X,Ne;return((Ne=(X=e.rotationUi)==null?void 0:X.border)==null?void 0:Ne.color)??"#007ACC"}),h=P(()=>{var X,Ne;return((Ne=(X=e.rotationUi)==null?void 0:X.border)==null?void 0:Ne.width)??1}),g=P(()=>{var X,Ne;return((Ne=(X=e.rotationUi)==null?void 0:X.border)==null?void 0:Ne.style)??"solid"}),f=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.color)??e.selectionOutlineColor??"#007ACC"}),F=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.style)??"solid"}),y=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.width)??1}),_=P(()=>{var X;return((X=e.selectionOutline)==null?void 0:X.offset)??e.outlineOffset??1}),E=ln(ke(e.trackedAnnotation.object)),A=Q(null),T=Q(null),q=Q(!1),w=Q(!1),{provides:G}=Bn(),{plugin:W}=ni(),J=Ps(e.documentId),ue=Q(null),ce=ln(null),ee=P(()=>J.value.canModifyAnnotations&&e.isDraggable&&!e.isMultiSelected),ge=P(()=>J.value.canModifyAnnotations&&e.isResizable&&!e.isMultiSelected),ye=P(()=>J.value.canModifyAnnotations&&e.isRotatable&&!e.isMultiSelected),Ee=e.onDoubleClick?X=>{var Ne;J.value.canModifyAnnotations&&((Ne=e.onDoubleClick)==null||Ne.call(e,X))}:void 0,Te=P(()=>G.value?G.value.forDocument(e.documentId):null),oe=P(()=>({...ke(e.trackedAnnotation.object),...ke(E.value)})),He=P(()=>(e.trackedAnnotation.object.flags??[]).includes("noZoom")),ft=P(()=>(e.trackedAnnotation.object.flags??[]).includes("noRotate")),Ve=P(()=>He.value?1:e.scale),O=P(()=>ft.value?0:e.rotation),H=P(()=>A.value??oe.value.rotation??0),V=P(()=>A.value??oe.value.rotation??0),se=P(()=>{const X=V.value;return Number.isFinite(X)?Math.round(X*10)/10:0}),L=P(()=>A.value!==null),de=P(()=>oe.value.unrotatedRect),Pe=P(()=>de.value??oe.value.rect),Re=P(()=>{if(de.value&&H.value!==0)return uu(Pe.value,oe.value.rect,H.value)}),vt=P(()=>Pe.value),Ut=P(()=>de.value?{...oe.value,rect:de.value}:oe.value),D=P(()=>e.isSelected&&!e.isMultiSelected),S=P(()=>e.isSelected&&!e.isMultiSelected&&(e.selectionMenu||Cn["selection-menu"])),R=P(()=>({origin:{x:oe.value.rect.origin.x*e.scale,y:oe.value.rect.origin.y*e.scale},size:{width:oe.value.rect.size.width*Ve.value,height:oe.value.rect.size.height*Ve.value}})),N=P(()=>({type:"annotation",annotation:e.trackedAnnotation,pageIndex:e.pageIndex})),$=P(()=>{const X=((H.value+O.value*90)%360+360)%360;return{suggestTop:ye.value&&X>90&&X<270}}),j=(X,Ne)=>e.selectionMenu?e.selectionMenu({rect:X,menuWrapperProps:Ne,selected:e.isSelected,placement:$.value,context:N.value}):null,ne=P(()=>{var X;const Ne=ke(oe.value);return((X=e.vertexConfig)==null?void 0:X.extractVertices(Ne))??[]}),K=P(()=>({minWidth:10,minHeight:10,boundingBox:{width:e.pageWidth,height:e.pageHeight}})),{dragProps:Y,vertices:B,resize:be,rotation:re}=Od({controller:{element:vt,vertices:ne,constraints:K,maintainAspectRatio:P(()=>e.lockAspectRatio),pageRotation:P(()=>e.rotation),annotationRotation:P(()=>H.value),rotationCenter:P(()=>Re.value),rotationElement:P(()=>oe.value.rect),scale:P(()=>e.scale),enabled:P(()=>e.isSelected&&!e.isMultiSelected),onUpdate:X=>{var Ne,Xt,Pt;if(!((Ne=X.transformData)!=null&&Ne.type)||e.isMultiSelected)return;const st=W.value;if(!st)return;const{type:qe,changes:on,metadata:Rt}=X.transformData,er=e.trackedAnnotation.object.id,ci={width:e.pageWidth,height:e.pageHeight};if(X.state==="start"&&(ce.value=e.trackedAnnotation.object.unrotatedRect??e.trackedAnnotation.object.rect,ue.value=oe.value,(qe==="resize"||qe==="vertex-edit")&&(w.value=!0),qe==="move"?st.startDrag(e.documentId,{annotationIds:[er],pageSize:ci}):qe==="resize"&&st.startResize(e.documentId,{annotationIds:[er],pageSize:ci,resizeHandle:(Rt==null?void 0:Rt.handle)??"se"})),on.rect&&ce.value)if(qe==="move"){const Zt={x:on.rect.origin.x-ce.value.origin.x,y:on.rect.origin.y-ce.value.origin.y};st.updateDrag(e.documentId,Zt)}else qe==="resize"&&st.updateResize(e.documentId,on.rect);if(qe==="vertex-edit"&&on.vertices&&e.vertexConfig){const Zt=ue.value??oe.value,Co=e.vertexConfig.transformAnnotation(ke(Zt),on.vertices),zr=(Xt=G.value)==null?void 0:Xt.transformAnnotation(Zt,{type:qe,changes:Co,metadata:Rt});zr&&(E.value={...ke(E.value),...zr},X.state==="end"&&((Pt=Te.value)==null||Pt.updateAnnotation(e.pageIndex,er,zr)))}if(qe==="rotate"){const Zt=(Rt==null?void 0:Rt.rotationAngle)??H.value,Co=Rt==null?void 0:Rt.cursorPosition;Co&&(T.value={x:Co.clientX,y:Co.clientY}),X.state==="start"?(A.value=Zt,st.startRotation(e.documentId,{annotationIds:[er],cursorAngle:Zt,rotationCenter:Rt==null?void 0:Rt.rotationCenter})):X.state==="move"?(A.value=Zt,st.updateRotation(e.documentId,Zt,Rt==null?void 0:Rt.rotationDelta)):X.state==="end"&&(A.value=null,T.value=null,st.commitRotation(e.documentId));return}X.state==="end"&&(w.value=!1,ce.value=null,ue.value=null,qe==="move"?st.commitDrag(e.documentId):qe==="resize"&&st.commitResize(e.documentId))}},resizeUI:{handleSize:r.value,spacing:_.value,offsetMode:"outside",includeSides:!e.lockAspectRatio,zIndex:e.zIndex+1},vertexUI:{vertexSize:a.value,zIndex:e.zIndex+2},rotationUI:{handleSize:i.value,margin:d.value,zIndex:e.zIndex+3,showConnector:u.value},includeVertices:!!e.vertexConfig,includeRotation:ye,currentRotation:H}),Fe=t_(Ee),De=X=>{L.value||(T.value={x:X.clientX,y:X.clientY})};Xn(()=>{e.trackedAnnotation.object&&(E.value=e.trackedAnnotation.object)}),Xn(X=>{const Ne=W.value;if(!Ne)return;const Xt=e.trackedAnnotation.object.id,Pt=qe=>{var on;if(qe.documentId!==e.documentId)return;(qe.type==="end"||qe.type==="cancel")&&(A.value=null);const Rt=(on=qe.previewPatches)==null?void 0:on[Xt];qe.type==="update"&&Rt?E.value={...ke(E.value),...Rt}:qe.type==="cancel"&&(E.value=e.trackedAnnotation.object)},st=[Ne.onDragChange(Pt),Ne.onResizeChange(Pt),Ne.onRotateChange(Pt)];X(()=>st.forEach(qe=>qe()))});const we=P(()=>oe.value.rect.size.width*Ve.value),Ge=P(()=>oe.value.rect.size.height*Ve.value),Oe=P(()=>Pe.value.size.width*Ve.value),k=P(()=>Pe.value.size.height*Ve.value),_e=P(()=>!!de.value&&H.value!==0),Le=P(()=>_e.value?(Pe.value.origin.x-oe.value.rect.origin.x)*Ve.value:(we.value-Oe.value)/2),Ke=P(()=>_e.value?(Pe.value.origin.y-oe.value.rect.origin.y)*Ve.value:(Ge.value-k.value)/2),Xe=P(()=>_e.value&&Re.value?`${(Re.value.x-Pe.value.origin.x)*Ve.value}px ${(Re.value.y-Pe.value.origin.y)*Ve.value}px`:"center center"),Kt=P(()=>Re.value?(Re.value.x-oe.value.rect.origin.x)*Ve.value:we.value/2),dt=P(()=>Re.value?(Re.value.y-oe.value.rect.origin.y)*Ve.value:Ge.value/2),Ze=P(()=>Math.max(300,Math.max(we.value,Ge.value)+80)),Dt=P(()=>ft.value?xd({size:{width:we.value,height:Ge.value}},e.rotation):null),Ft=P(()=>Math.round(i.value*.6)),gt=P(()=>{var X;return!!((X=e.appearance)!=null&&X.normal)&&!w.value&&!e.isEditing&&!e.trackedAnnotation.dictMode}),Gt={display:"contents"},Ye=P(()=>({position:"absolute",left:`${oe.value.rect.origin.x*e.scale}px`,top:`${oe.value.rect.origin.y*e.scale}px`,width:`${Dt.value?Dt.value.width:we.value}px`,height:`${Dt.value?Dt.value.height:Ge.value}px`,pointerEvents:"none",zIndex:e.zIndex,...Dt.value?{transform:Dt.value.matrix,transformOrigin:"0 0"}:{}})),nn=P(()=>({...Ye.value,...e.blendMode?{mixBlendMode:e.blendMode}:{},...e.style})),xn=P(()=>Ye.value),Br=P(()=>({position:"absolute",left:`${Le.value}px`,top:`${Ke.value}px`,width:`${Oe.value}px`,height:`${k.value}px`,transform:H.value!==0?`rotate(${H.value}deg)`:void 0,transformOrigin:Xe.value,pointerEvents:e.isEditing?"auto":"none"})),lo=P(()=>({position:"absolute",left:`${Le.value}px`,top:`${Ke.value}px`,width:`${Oe.value}px`,height:`${k.value}px`,transform:H.value!==0?`rotate(${H.value}deg)`:void 0,transformOrigin:Xe.value,outline:D.value?`${y.value}px ${F.value} ${f.value}`:"none",outlineOffset:D.value?`${_.value}px`:"0px",pointerEvents:e.isSelected&&!e.isMultiSelected&&!e.isEditing?"auto":"none",touchAction:"none",cursor:e.isSelected&&ee.value?"move":"default"})),si=P(()=>({position:"absolute",left:`${Kt.value-Ze.value/2}px`,top:`${dt.value}px`,width:`${Ze.value}px`,height:"1px",backgroundColor:l.value,opacity:.35,pointerEvents:"none"})),rl=P(()=>({position:"absolute",left:`${Kt.value}px`,top:`${dt.value-Ze.value/2}px`,width:"1px",height:`${Ze.value}px`,backgroundColor:l.value,opacity:.35,pointerEvents:"none"})),li=P(()=>({position:"absolute",left:`${Kt.value-Ze.value/2}px`,top:`${dt.value}px`,width:`${Ze.value}px`,height:"1px",transformOrigin:"center center",transform:`rotate(${H.value}deg)`,backgroundColor:l.value,opacity:.8,pointerEvents:"none"})),co=P(()=>{var X;return{...((X=re.value)==null?void 0:X.connector.style)??{},backgroundColor:l.value,opacity:L.value?0:1}}),uo=P(()=>{var X;return{...((X=re.value)==null?void 0:X.handle.style)??{},backgroundColor:s.value,border:`${h.value}px ${g.value} ${p.value}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:L.value?0:1}}),Jo=P(()=>{if(!re.value)return{};const{style:X,...Ne}=re.value.handle;return Ne}),xo=P(()=>re.value?{...re.value.handle,backgroundColor:s.value,iconColor:c.value,connectorStyle:co.value,showConnector:u.value,opacity:L.value?0:1,border:{color:p.value,width:h.value,style:g.value}}:{}),al=P(()=>({position:"fixed",left:T.value?`${T.value.x+16}px`:"0",top:T.value?`${T.value.y-16}px`:"0",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"})),Cn=Pa();return(X,Ne)=>{var Xt;return v(),C("div",{"data-no-interaction":"",style:Gt},[m("div",{style:Z(nn.value)},[m("div",{style:Z(Br.value)},[$e(X.$slots,"default",{annotation:Ut.value,appearanceActive:gt.value}),(Xt=t.appearance)!=null&&Xt.normal?(v(),he(Q_,{key:0,appearance:t.appearance.normal,style:Z({display:gt.value?"block":"none"})},null,8,["appearance","style"])):ae("",!0)],4)],4),m("div",{style:Z(xn.value)},[L.value?(v(),C(pe,{key:0},[m("div",{style:Z(si.value)},null,4),m("div",{style:Z(rl.value)},null,4),m("div",{style:Z(li.value)},null,4)],64)):ae("",!0),t.isSelected&&ye.value&&I(re)?(v(),C("div",{key:1,onPointerenter:Ne[0]||(Ne[0]=Pt=>q.value=!0),onPointerleave:Ne[1]||(Ne[1]=Pt=>{q.value=!1,T.value=null}),onPointermove:De,style:Gt},[u.value?(v(),C("div",{key:0,style:Z(co.value)},null,4)):ae("",!0),I(Cn)["rotation-handle"]?$e(X.$slots,"rotation-handle",zt(xe({key:1},xo.value)),()=>[m("div",xe(Jo.value,{style:uo.value}),[(v(),C("svg",{width:Ft.value,height:Ft.value,viewBox:"0 0 24 24",fill:"none",stroke:c.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...Ne[2]||(Ne[2]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,nv))],16)]):(v(),C("div",xe({key:2},Jo.value,{style:uo.value}),[(v(),C("svg",{width:Ft.value,height:Ft.value,viewBox:"0 0 24 24",fill:"none",stroke:c.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[...Ne[3]||(Ne[3]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,ov))],16))],32)):ae("",!0),m("div",xe({...ee.value&&t.isSelected?I(Y):{},...I(Fe)},{style:lo.value}),[t.isSelected&&ge.value&&!L.value?(v(!0),C(pe,{key:0},tt(I(be),({key:Pt,style:st,...qe})=>(v(),C(pe,{key:Pt},[I(Cn)["resize-handle"]?$e(X.$slots,"resize-handle",xe({key:0,ref_for:!0},{key:Pt,style:st,...qe,backgroundColor:n.value}),()=>[m("div",xe({ref_for:!0},qe,{style:[st,{backgroundColor:n.value}]}),null,16)]):(v(),C("div",xe({key:1,ref_for:!0},qe,{style:[st,{backgroundColor:n.value}]}),null,16))],64))),128)):ae("",!0),t.isSelected&&I(J).canModifyAnnotations&&!t.isMultiSelected&&!L.value&&I(B).length>0?(v(!0),C(pe,{key:1},tt(I(B),({key:Pt,style:st,...qe})=>(v(),C(pe,{key:Pt},[I(Cn)["vertex-handle"]?$e(X.$slots,"vertex-handle",xe({key:0,ref_for:!0},{key:Pt,style:st,...qe,backgroundColor:o.value}),()=>[m("div",xe({ref_for:!0},qe,{style:[st,{backgroundColor:o.value}]}),null,16)]):(v(),C("div",xe({key:1,ref_for:!0},qe,{style:[st,{backgroundColor:o.value}]}),null,16))],64))),128)):ae("",!0)],16)],4),S.value&&!L.value?(v(),he(I(Ir),{key:0,rect:R.value,rotation:t.rotation},{default:We(({rect:Pt,menuWrapperProps:st})=>[t.selectionMenu?(v(),he(Fn(j(Pt,st)),{key:0})):$e(X.$slots,"selection-menu",{key:1,context:N.value,selected:t.isSelected,rect:Pt,placement:$.value,menuWrapperProps:st})]),_:3},8,["rect","rotation"])):ae("",!0),(L.value||q.value)&&T.value?(v(),he(Jl,{key:1,to:"body"},[m("div",{style:Z(al.value)},fe(se.value.toFixed(0))+"°",5)])):ae("",!0)])}}});function oi(t,e,n,o,r){switch(r){case 1:return{x:e,y:o-t};case 2:return{x:n-t,y:o-e};case 3:return{x:n-e,y:t};default:return{x:t,y:e}}}function av(t,e,n){const o=t.object.flags??[],r=o.includes("noZoom"),a=o.includes("noRotate"),i=t.object.rect.origin.x*e,s=t.object.rect.origin.y*e,l=t.object.rect.size.width*(r?1:e),c=t.object.rect.size.height*(r?1:e);if(!a||n===0)return{left:i,top:s,right:i+l,bottom:s+c};const u=[oi(0,0,l,c,n),oi(l,0,l,c,n),oi(0,c,l,c,n),oi(l,c,l,c,n)];let d=1/0,p=1/0,h=-1/0,g=-1/0;for(const f of u)f.x<d&&(d=f.x),f.y<p&&(p=f.y),f.x>h&&(h=f.x),f.y>g&&(g=f.y);return{left:i+d,top:s+p,right:i+h,bottom:s+g}}const iv={key:0,"data-group-selection-box":"","data-no-interaction":""},sv=["width","height","stroke"],lv=["width","height","stroke"],cv=ie({__name:"group-selection-box",props:{documentId:{},pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},selectedAnnotations:{},isDraggable:{type:Boolean},isResizable:{type:Boolean},isRotatable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},resizeUi:{},rotationUi:{},selectionOutlineColor:{default:"#007ACC"},outlineOffset:{default:2},selectionOutline:{},zIndex:{default:100},groupSelectionMenu:{}},setup(t){const e=t,n=Pa(),{plugin:o}=ni(),r=Ps(()=>e.documentId),a=ln(null),i=Q(!1),s=Q(!1),l=Q(null),c=Q(null),u=Q(!1),d=P(()=>r.value.canModifyAnnotations&&e.isDraggable),p=P(()=>r.value.canModifyAnnotations&&e.isResizable),h=P(()=>r.value.canModifyAnnotations&&e.isRotatable),g=P(()=>{var k;return((k=e.resizeUi)==null?void 0:k.color)??"#007ACC"}),f=P(()=>{var k;return((k=e.resizeUi)==null?void 0:k.size)??12}),F=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.size)??32}),y=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.color)??"white"}),_=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.connectorColor)??"#007ACC"}),E=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.iconColor)??"#007ACC"}),A=P(()=>{var k;return((k=e.rotationUi)==null?void 0:k.showConnector)??!1}),T=P(()=>{var k;return(k=e.rotationUi)==null?void 0:k.margin}),q=P(()=>{var k,_e;return((_e=(k=e.rotationUi)==null?void 0:k.border)==null?void 0:_e.color)??"#007ACC"}),w=P(()=>{var k,_e;return((_e=(k=e.rotationUi)==null?void 0:k.border)==null?void 0:_e.width)??1}),G=P(()=>{var k,_e;return((_e=(k=e.rotationUi)==null?void 0:k.border)==null?void 0:_e.style)??"solid"}),W=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.color)??e.selectionOutlineColor??"#007ACC"}),J=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.style)??"dashed"}),ue=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.width)??2}),ce=P(()=>{var k;return((k=e.selectionOutline)==null?void 0:k.offset)??e.outlineOffset??2}),ee=P(()=>l.value??0),ge=P(()=>l.value!==null),ye=P(()=>{const k=ee.value;return Number.isFinite(k)?Math.round(k*10)/10:0}),Ee=P(()=>Math.round(F.value*.6)),Te=P(()=>{const k=e.selectedAnnotations.map(_e=>_e.object.rect);return iF(k)}),oe=ln(Te.value);Se(()=>Te.value,k=>{!i.value&&!s.value&&(oe.value=k)},{immediate:!0}),Se(()=>o.value,(k,_e,Le)=>{if(!k)return;const Ke=k.onRotateChange(Xe=>{Xe.documentId===e.documentId&&(Xe.type==="end"||Xe.type==="cancel")&&(l.value=null)});Le(Ke)},{immediate:!0});const He=P(()=>{let k=1/0,_e=1/0,Le=-1/0,Ke=-1/0;for(const Ft of e.selectedAnnotations){const gt=av(Ft,e.scale,e.rotation);gt.left<k&&(k=gt.left),gt.top<_e&&(_e=gt.top),gt.right>Le&&(Le=gt.right),gt.bottom>Ke&&(Ke=gt.bottom)}const Xe=Te.value,Kt=Xe.origin.x*e.scale,dt=Xe.origin.y*e.scale,Ze=(Xe.origin.x+Xe.size.width)*e.scale,Dt=(Xe.origin.y+Xe.size.height)*e.scale;return{left:k-Kt,top:_e-dt,right:Le-Ze,bottom:Ke-Dt}}),ft=P(()=>oe.value.origin.x*e.scale+He.value.left),Ve=P(()=>oe.value.origin.y*e.scale+He.value.top),O=P(()=>oe.value.size.width*e.scale+(He.value.right-He.value.left)),H=P(()=>oe.value.size.height*e.scale+(He.value.bottom-He.value.top)),V=P(()=>O.value/2),se=P(()=>H.value/2),L=P(()=>Math.max(300,Math.max(O.value,H.value)+80)),de={display:"contents"},Pe=P(()=>({position:"absolute",left:`${ft.value}px`,top:`${Ve.value}px`,width:`${O.value}px`,height:`${H.value}px`,pointerEvents:"none",zIndex:e.zIndex})),Re=P(()=>({position:"absolute",left:0,top:0,width:`${O.value}px`,height:`${H.value}px`,outline:ge.value?"none":`${ue.value}px ${J.value} ${W.value}`,outlineOffset:`${ce.value-1}px`,cursor:d.value?"move":"default",touchAction:"none",pointerEvents:"auto"})),vt=P(()=>({position:"absolute",left:`${V.value-L.value/2}px`,top:`${se.value}px`,width:`${L.value}px`,height:"1px",backgroundColor:g.value,opacity:.35,pointerEvents:"none"})),Ut=P(()=>({position:"absolute",left:`${V.value}px`,top:`${se.value-L.value/2}px`,width:"1px",height:`${L.value}px`,backgroundColor:g.value,opacity:.35,pointerEvents:"none"})),D=P(()=>({position:"absolute",left:`${V.value-L.value/2}px`,top:`${se.value}px`,width:`${L.value}px`,height:"1px",transformOrigin:"center center",transform:`rotate(${ee.value}deg)`,backgroundColor:g.value,opacity:.8,pointerEvents:"none"})),S=P(()=>{var k;return{...((k=Oe.value)==null?void 0:k.connector.style)??{},backgroundColor:_.value,opacity:ge.value?0:1}}),R=P(()=>{var k;return{...((k=Oe.value)==null?void 0:k.handle.style)??{},backgroundColor:y.value,border:`${w.value}px ${G.value} ${q.value}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:ge.value?0:1}}),N=P(()=>{if(!Oe.value)return{};const{style:k,..._e}=Oe.value.handle;return _e}),$=P(()=>Oe.value?{...Oe.value.handle,backgroundColor:y.value,iconColor:E.value,connectorStyle:S.value,showConnector:A.value,opacity:ge.value?0:1,border:{color:q.value,width:w.value,style:G.value}}:{}),j=P(()=>({position:"fixed",left:c.value?`${c.value.x+16}px`:"0",top:c.value?`${c.value.y-16}px`:"0",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"})),ne=P(()=>({origin:{x:ft.value,y:Ve.value},size:{width:O.value,height:H.value}})),K=P(()=>({type:"group",annotations:e.selectedAnnotations,pageIndex:e.pageIndex})),Y=P(()=>{const k=((ee.value+e.rotation*90)%360+360)%360;return{suggestTop:h.value&&k>90&&k<270}}),B=P(()=>e.groupSelectionMenu||n["group-selection-menu"]),be=(k,_e)=>e.groupSelectionMenu?e.groupSelectionMenu({rect:k,menuWrapperProps:_e,selected:!0,placement:Y.value,context:K.value}):null,re=k=>{ge.value||(c.value={x:k.clientX,y:k.clientY})},Fe=P(()=>oe.value),De=P(()=>({minWidth:20,minHeight:20,boundingBox:{width:e.pageWidth,height:e.pageHeight}})),{dragProps:we,resize:Ge,rotation:Oe}=Od({controller:{element:Fe,vertices:P(()=>[]),constraints:De,maintainAspectRatio:P(()=>e.lockAspectRatio),pageRotation:P(()=>e.rotation),scale:P(()=>e.scale),enabled:P(()=>!0),onUpdate:k=>{var _e,Le,Ke,Xe,Kt,dt;if(!((_e=k.transformData)!=null&&_e.type)||!o.value)return;const Ze=o.value,Dt=k.transformData.type,Ft=Dt==="move",gt=Dt==="resize";if(Ft&&!d.value)return;if(k.state==="start"&&(a.value=Te.value,Ft?(i.value=!0,Ze.startDrag(e.documentId,{annotationIds:e.selectedAnnotations.map(Ye=>Ye.object.id),pageSize:{width:e.pageWidth,height:e.pageHeight}})):gt&&(s.value=!0,Ze.startResize(e.documentId,{annotationIds:e.selectedAnnotations.map(Ye=>Ye.object.id),pageSize:{width:e.pageWidth,height:e.pageHeight},resizeHandle:((Le=k.transformData.metadata)==null?void 0:Le.handle)??"se"}))),Dt==="rotate"){if(!e.isRotatable)return;const Ye=e.selectedAnnotations.map(Br=>Br.object.id),nn=((Ke=k.transformData.metadata)==null?void 0:Ke.rotationAngle)??0,xn=(Xe=k.transformData.metadata)==null?void 0:Xe.cursorPosition;xn&&(c.value={x:xn.clientX,y:xn.clientY}),k.state==="start"?(l.value=nn,Ze.startRotation(e.documentId,{annotationIds:Ye,cursorAngle:nn,rotationCenter:(Kt=k.transformData.metadata)==null?void 0:Kt.rotationCenter})):k.state==="move"?(l.value=nn,Ze.updateRotation(e.documentId,nn,(dt=k.transformData.metadata)==null?void 0:dt.rotationDelta)):k.state==="end"&&(l.value=null,c.value=null,Ze.commitRotation(e.documentId));return}const Gt=a.value??Te.value;if(Ft&&k.transformData.changes.rect){const Ye=k.transformData.changes.rect,nn={x:Ye.origin.x-Gt.origin.x,y:Ye.origin.y-Gt.origin.y},xn=Ze.updateDrag(e.documentId,nn);oe.value={...Gt,origin:{x:Gt.origin.x+xn.x,y:Gt.origin.y+xn.y}}}else if(gt&&k.transformData.changes.rect){const Ye=k.transformData.changes.rect;Ze.updateResize(e.documentId,Ye),oe.value=Ye}k.state==="end"&&(a.value=null,Ft&&i.value?(i.value=!1,Ze.commitDrag(e.documentId)):gt&&s.value&&(s.value=!1,Ze.commitResize(e.documentId)))}},resizeUI:{handleSize:f.value,spacing:ce.value,offsetMode:"outside",includeSides:!e.lockAspectRatio,zIndex:e.zIndex+1},vertexUI:{vertexSize:0,zIndex:e.zIndex},rotationUI:{handleSize:F.value,margin:T.value,zIndex:e.zIndex+2,showConnector:A.value},includeVertices:!1,includeRotation:h,currentRotation:P(()=>l.value??0)});return(k,_e)=>t.selectedAnnotations.length>=2?(v(),C("div",iv,[m("div",{style:Z(Pe.value)},[ge.value?(v(),C(pe,{key:0},[m("div",{style:Z(vt.value)},null,4),m("div",{style:Z(Ut.value)},null,4),m("div",{style:Z(D.value)},null,4)],64)):ae("",!0),h.value&&I(Oe)?(v(),C("div",{key:1,onPointerenter:_e[0]||(_e[0]=Le=>u.value=!0),onPointerleave:_e[1]||(_e[1]=Le=>{u.value=!1,c.value=null}),onPointermove:re,style:de},[A.value?(v(),C("div",{key:0,style:Z(S.value)},null,4)):ae("",!0),I(n)["rotation-handle"]?$e(k.$slots,"rotation-handle",zt(xe({key:1},$.value)),()=>[m("div",xe(N.value,{style:R.value}),[(v(),C("svg",{width:Ee.value,height:Ee.value,viewBox:"0 0 24 24",fill:"none",stroke:E.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[..._e[2]||(_e[2]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,sv))],16)]):(v(),C("div",xe({key:2},N.value,{style:R.value}),[(v(),C("svg",{width:Ee.value,height:Ee.value,viewBox:"0 0 24 24",fill:"none",stroke:E.value,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[..._e[3]||(_e[3]=[m("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},null,-1),m("path",{d:"M21 3v5h-5"},null,-1)])],8,lv))],16))],32)):ae("",!0),m("div",xe(d.value?I(we):{onPointerdown:Le=>Le.stopPropagation()},{style:Re.value}),[p.value&&!ge.value?(v(!0),C(pe,{key:0},tt(I(Ge),({key:Le,style:Ke,...Xe})=>(v(),C(pe,{key:Le},[I(n)["resize-handle"]?$e(k.$slots,"resize-handle",xe({key:0,ref_for:!0},{key:Le,style:Ke,...Xe,backgroundColor:g.value}),()=>[m("div",xe({ref_for:!0},Xe,{style:[Ke,{backgroundColor:g.value}]}),null,16)]):(v(),C("div",xe({key:1,ref_for:!0},Xe,{style:[Ke,{backgroundColor:g.value}]}),null,16))],64))),128)):ae("",!0)],16)],4),B.value&&!ge.value?(v(),he(I(Ir),{key:0,rect:ne.value,rotation:t.rotation},{default:We(({rect:Le,menuWrapperProps:Ke})=>[t.groupSelectionMenu?(v(),he(Fn(be(Le,Ke)),{key:0})):$e(k.$slots,"group-selection-menu",{key:1,context:K.value,selected:!0,rect:Le,placement:Y.value,menuWrapperProps:Ke})]),_:3},8,["rect","rotation"])):ae("",!0),(ge.value||u.value)&&c.value?(v(),he(Jl,{key:1,to:"body"},[m("div",{style:Z(j.value)},fe(ye.value.toFixed(0))+"°",5)])):ae("",!0)])):ae("",!0)}}),wp=Symbol("AnnotationRendererRegistry");function uv(){const t=ln([]);return{register(e){const n=new Set(e.map(o=>o.id));return t.value=[...t.value.filter(o=>!n.has(o.id)),...e],()=>{t.value=t.value.filter(o=>!e.some(r=>r.id===o.id))}},getAll(){return t.value}}}function dv(){const t=uv();return pa(wp,t),t}function Ws(){return Po(wp,null)}function pv(t){const e=Ws();if(!e)return;const n=e.register(t);$o(n)}function _t(t){return{id:t.id,matches:t.matches,component:dr(t.component),vertexConfig:t.vertexConfig,zIndex:t.zIndex,defaultBlendMode:t.defaultBlendMode,containerStyle:t.containerStyle,interactionDefaults:t.interactionDefaults,useAppearanceStream:t.useAppearanceStream,isDraggable:t.isDraggable,onDoubleClick:t.onDoubleClick,selectOverride:t.selectOverride,hideSelectionMenu:t.hideSelectionMenu,renderPreview:t.renderPreview?dr(t.renderPreview):void 0,hiddenWhenLocked:t.hiddenWhenLocked,renderLocked:t.renderLocked?dr(t.renderLocked):void 0}}const hv=ie({...{inheritAttrs:!1},__name:"link-locked",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){const e=t,{provides:n}=Bn(),o=()=>{const r=e.annotation.object.target;!r||!n.value||n.value.forDocument(e.documentId).navigateTarget(r)};return(r,a)=>(v(),C("div",{onClick:o,style:{width:"100%",height:"100%",cursor:"pointer",pointerEvents:"auto"}}))}}),gv=ie({__name:"link-preview",props:{data:{},bounds:{},scale:{}},setup(t){const e=t,n=P(()=>({position:"absolute",left:0,top:0,width:`${e.bounds.size.width*e.scale}px`,height:`${e.bounds.size.height*e.scale}px`,borderBottom:`${e.data.strokeWidth*e.scale}px solid ${e.data.strokeColor}`,backgroundColor:"rgba(0, 0, 255, 0.05)",boxSizing:"border-box"}));return(o,r)=>(v(),C("div",{style:Z(n.value)},null,4))}}),fv=["width","height","viewBox"],mv=["d","stroke-width"],Pv=["d","opacity"],Op=ie({...{inheritAttrs:!1},__name:"ink",props:{isSelected:{type:Boolean},strokeColor:{},opacity:{default:1},strokeWidth:{},inkList:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const n=t,o=P(()=>n.strokeColor??"#000000"),r=P(()=>n.inkList.map(({points:l})=>{let c="";return l.forEach(({x:u,y:d},p)=>{const h=u-n.rect.origin.x,g=d-n.rect.origin.y;c+=(p===0?"M":"L")+`${h} ${g} `}),c.trim()})),a=P(()=>n.rect.size.width*n.scale),i=P(()=>n.rect.size.height*n.scale),s=P(()=>Math.max(n.strokeWidth,20/n.scale));return(l,c)=>(v(),C("svg",{style:Z({position:"absolute",width:`${a.value}px`,height:`${i.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:a.value,height:i.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[(v(!0),C(pe,null,tt(r.value,(u,d)=>(v(),C("path",{key:`hit-${d}`,d:u,fill:"none",stroke:"transparent","stroke-width":s.value,onPointerdown:c[0]||(c[0]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visibleStroke":"none",strokeLinecap:"round",strokeLinejoin:"round"})},null,44,mv))),128)),t.appearanceActive?ae("",!0):(v(!0),C(pe,{key:0},tt(r.value,(u,d)=>(v(),C("path",{key:`vis-${d}`,d:u,fill:"none",opacity:t.opacity,style:Z({pointerEvents:"none",stroke:o.value,strokeWidth:t.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round"})},null,12,Pv))),128))],12,fv))}}),Fv=ie({__name:"ink-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Op,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),bv=["width","height","viewBox"],yv=["d","stroke-width"],_v=["x","y","width","height","stroke-width"],vv=["d","fill","opacity"],Dv=["x","y","width","height","fill","opacity"],kp=ie({...{inheritAttrs:!1},__name:"square",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1},cloudyBorderIntensity:{},rectangleDifferences:{}},setup(t){const n=t,o=P(()=>(n.cloudyBorderIntensity??0)>0),r=P(()=>{const c=n.rect.size.width,u=n.rect.size.height,d=Math.max(c-n.strokeWidth,0),p=Math.max(u-n.strokeWidth,0);return{width:d,height:p,x:n.strokeWidth/2,y:n.strokeWidth/2}}),a=P(()=>o.value?ay({width:n.rect.size.width,height:n.rect.size.height},n.rectangleDifferences,n.cloudyBorderIntensity,n.strokeWidth):null),i=P(()=>n.rect.size.width*n.scale),s=P(()=>n.rect.size.height*n.scale),l=P(()=>Math.max(n.strokeWidth,20/n.scale));return(c,u)=>{var d;return v(),C("svg",{style:Z({position:"absolute",width:i.value,height:s.value,pointerEvents:"none",zIndex:2}),width:i.value,height:s.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`,overflow:"visible"},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[0]||(u[0]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,yv)):(v(),C("rect",{key:1,x:r.value.x,y:r.value.y,width:r.value.width,height:r.value.height,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[1]||(u[1]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,_v)),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,strokeLinejoin:"round"})},null,12,vv)):(v(),C("rect",{key:1,x:r.value.x,y:r.value.y,width:r.value.width,height:r.value.height,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,Dv))],64))],12,bv)}}}),Sv=ie({__name:"square-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(kp,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Ev=["width","height","viewBox"],Av=["d","stroke-width"],xv=["cx","cy","rx","ry","stroke-width"],Cv=["d","fill","opacity"],Tv=["cx","cy","rx","ry","fill","opacity"],Ip=ie({...{inheritAttrs:!1},__name:"circle",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1},cloudyBorderIntensity:{},rectangleDifferences:{}},setup(t){const n=t,o=P(()=>(n.cloudyBorderIntensity??0)>0),r=P(()=>{const c=n.rect.size.width,u=n.rect.size.height,d=Math.max(c-n.strokeWidth,0),p=Math.max(u-n.strokeWidth,0);return{width:c,height:u,cx:n.strokeWidth/2+d/2,cy:n.strokeWidth/2+p/2,rx:d/2,ry:p/2}}),a=P(()=>o.value?iy({width:n.rect.size.width,height:n.rect.size.height},n.rectangleDifferences,n.cloudyBorderIntensity,n.strokeWidth):null),i=P(()=>r.value.width*n.scale),s=P(()=>r.value.height*n.scale),l=P(()=>Math.max(n.strokeWidth,20/n.scale));return(c,u)=>{var d;return v(),C("svg",{style:Z({position:"absolute",width:i.value,height:s.value,pointerEvents:"none",zIndex:2}),width:i.value,height:s.value,viewBox:`0 0 ${r.value.width} ${r.value.height}`,overflow:"visible"},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[0]||(u[0]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,Av)):(v(),C("ellipse",{key:1,cx:r.value.cx,cy:r.value.cy,rx:r.value.rx,ry:r.value.ry,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[1]||(u[1]=(...p)=>t.onClick&&t.onClick(...p)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none"})},null,44,xv)),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[o.value&&a.value?(v(),C("path",{key:0,d:a.value.path,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,strokeLinejoin:"round"})},null,12,Cv)):(v(),C("ellipse",{key:1,cx:r.value.cx,cy:r.value.cy,rx:r.value.rx,ry:r.value.ry,fill:t.color,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,Tv))],64))],12,Ev)}}}),Mv=ie({__name:"circle-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Ip,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Rv=["width","height","viewBox"],wv=["x1","y1","x2","y2","stroke-width"],Ov=["d","transform","stroke-width"],kv=["d","transform","stroke-width"],Iv=["x1","y1","x2","y2","opacity"],Gv=["d","transform","stroke","fill"],Lv=["d","transform","stroke","fill"],Gp=ie({...{inheritAttrs:!1},__name:"line",props:{color:{default:"transparent"},opacity:{default:1},strokeWidth:{},strokeColor:{default:"#000000"},strokeStyle:{default:rt.SOLID},strokeDashArray:{},rect:{},linePoints:{},lineEndings:{},scale:{},onClick:{},isSelected:{type:Boolean},appearanceActive:{type:Boolean,default:!1}},setup(t){const n=t,o=P(()=>({x1:n.linePoints.start.x-n.rect.origin.x,y1:n.linePoints.start.y-n.rect.origin.y,x2:n.linePoints.end.x-n.rect.origin.x,y2:n.linePoints.end.y-n.rect.origin.y})),r=P(()=>{var l,c;const{x1:u,y1:d,x2:p,y2:h}=o.value,g=Math.atan2(h-d,p-u);return{start:Ka.createEnding((l=n.lineEndings)==null?void 0:l.start,n.strokeWidth,g+Math.PI,u,d),end:Ka.createEnding((c=n.lineEndings)==null?void 0:c.end,n.strokeWidth,g,p,h)}}),a=P(()=>n.rect.size.width*n.scale),i=P(()=>n.rect.size.height*n.scale),s=P(()=>Math.max(n.strokeWidth,20/n.scale));return(l,c)=>{var u,d,p;return v(),C("svg",{style:Z({position:"absolute",width:`${a.value}px`,height:`${i.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:a.value,height:i.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[m("line",{x1:o.value.x1,y1:o.value.y1,x2:o.value.x2,y2:o.value.y2,stroke:"transparent","stroke-width":s.value,onPointerdown:c[0]||(c[0]=(...h)=>t.onClick&&t.onClick(...h)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,wv),r.value.start?(v(),C("path",{key:0,d:r.value.start.d,transform:r.value.start.transform,fill:"transparent",stroke:"transparent","stroke-width":s.value,onPointerdown:c[1]||(c[1]=(...h)=>t.onClick&&t.onClick(...h)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":r.value.start.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,Ov)):ae("",!0),r.value.end?(v(),C("path",{key:1,d:r.value.end.d,transform:r.value.end.transform,fill:"transparent",stroke:"transparent","stroke-width":s.value,onPointerdown:c[2]||(c[2]=(...h)=>t.onClick&&t.onClick(...h)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":r.value.end.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,kv)):ae("",!0),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[m("line",{x1:o.value.x1,y1:o.value.y1,x2:o.value.x2,y2:o.value.y2,opacity:t.opacity,style:Z({pointerEvents:"none",stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(u=t.strokeDashArray)==null?void 0:u.join(",")}})},null,12,Iv),r.value.start?(v(),C("path",{key:0,d:r.value.start.d,transform:r.value.start.transform,stroke:t.strokeColor,fill:r.value.start.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,Gv)):ae("",!0),r.value.end?(v(),C("path",{key:1,d:r.value.end.d,transform:r.value.end.transform,stroke:t.strokeColor,fill:r.value.end.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(p=t.strokeDashArray)==null?void 0:p.join(",")}})},null,12,Lv)):ae("",!0)],64))],12,Rv)}}}),$v=ie({__name:"line-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Gp,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Nv=["width","height","viewBox"],jv=["d","stroke-width"],Uv=["d","transform","stroke-width"],Bv=["d","transform","stroke-width"],zv=["d","opacity"],Wv=["d","transform","stroke","fill"],Hv=["d","transform","stroke","fill"],Lp=ie({...{inheritAttrs:!1},__name:"polyline",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},scale:{},isSelected:{type:Boolean},onClick:{},lineEndings:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const n=t,o=P(()=>n.vertices.map(({x:c,y:u})=>({x:c-n.rect.origin.x,y:u-n.rect.origin.y}))),r=P(()=>{if(o.value.length===0)return"";const[c,...u]=o.value;return(`M ${c.x} ${c.y} `+u.map(d=>`L ${d.x} ${d.y} `).join("")).trim()}),a=P(()=>{var c,u;if(o.value.length<2)return{start:null,end:null};const d=(g,f)=>Math.atan2(f.y-g.y,f.x-g.x),p=d(o.value[0],o.value[1]),h=d(o.value[o.value.length-2],o.value[o.value.length-1]);return{start:Ka.createEnding((c=n.lineEndings)==null?void 0:c.start,n.strokeWidth,p+Math.PI,o.value[0].x,o.value[0].y),end:Ka.createEnding((u=n.lineEndings)==null?void 0:u.end,n.strokeWidth,h,o.value[o.value.length-1].x,o.value[o.value.length-1].y)}}),i=P(()=>n.rect.size.width*n.scale),s=P(()=>n.rect.size.height*n.scale),l=P(()=>Math.max(n.strokeWidth,20/n.scale));return(c,u)=>{var d,p,h;return v(),C("svg",{style:Z({position:"absolute",width:`${i.value}px`,height:`${s.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:i.value,height:s.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[m("path",{d:r.value,fill:"none",stroke:"transparent","stroke-width":l.value,onPointerdown:u[0]||(u[0]=(...g)=>t.onClick&&t.onClick(...g)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visibleStroke":"none",strokeLinecap:"butt",strokeLinejoin:"miter"})},null,44,jv),a.value.start?(v(),C("path",{key:0,d:a.value.start.d,transform:a.value.start.transform,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[1]||(u[1]=(...g)=>t.onClick&&t.onClick(...g)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":a.value.start.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,Uv)):ae("",!0),a.value.end?(v(),C("path",{key:1,d:a.value.end.d,transform:a.value.end.transform,fill:"transparent",stroke:"transparent","stroke-width":l.value,onPointerdown:u[2]||(u[2]=(...g)=>t.onClick&&t.onClick(...g)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":a.value.end.filled?"visible":"visibleStroke":"none",strokeLinecap:"butt"})},null,44,Bv)):ae("",!0),t.appearanceActive?ae("",!0):(v(),C(pe,{key:2},[m("path",{d:r.value,opacity:t.opacity,style:Z({fill:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(d=t.strokeDashArray)==null?void 0:d.join(",")}})},null,12,zv),a.value.start?(v(),C("path",{key:0,d:a.value.start.d,transform:a.value.start.transform,stroke:t.strokeColor,fill:a.value.start.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(p=t.strokeDashArray)==null?void 0:p.join(",")}})},null,12,Wv)):ae("",!0),a.value.end?(v(),C("path",{key:1,d:a.value.end.d,transform:a.value.end.transform,stroke:t.strokeColor,fill:a.value.end.filled?t.color:"none",style:Z({pointerEvents:"none",strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(h=t.strokeDashArray)==null?void 0:h.join(",")}})},null,12,Hv)):ae("",!0)],64))],12,Nv)}}}),Vv=ie({__name:"polyline-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Lp,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),Yv=["width","height","viewBox"],qv=["d","stroke-width"],Kv=["d","opacity"],Xv=["d","opacity"],Zv=["d"],Qv=["x","y","width","height","fill","stroke","stroke-width"],$p=ie({...{inheritAttrs:!1},__name:"polygon",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},strokeStyle:{default:rt.SOLID},strokeDashArray:{},scale:{},isSelected:{type:Boolean},onClick:{},currentVertex:{},handleSize:{default:14},appearanceActive:{type:Boolean,default:!1},cloudyBorderIntensity:{}},setup(t){const n=t,o=P(()=>(n.cloudyBorderIntensity??0)>0),r=P(()=>n.currentVertex?[...n.vertices,n.currentVertex]:n.vertices),a=P(()=>r.value.map(({x:p,y:h})=>({x:p-n.rect.origin.x,y:h-n.rect.origin.y}))),i=P(()=>{if(!a.value.length)return"";const[p,...h]=a.value,g=!!n.currentVertex;return(`M ${p.x} ${p.y} `+h.map(f=>`L ${f.x} ${f.y}`).join(" ")+(g?"":" Z")).trim()}),s=P(()=>!o.value||r.value.length<3?null:sy(r.value,n.rect.origin,n.cloudyBorderIntensity,n.strokeWidth)),l=P(()=>n.currentVertex&&n.vertices.length>0),c=P(()=>n.rect.size.width*n.scale),u=P(()=>n.rect.size.height*n.scale),d=P(()=>Math.max(n.strokeWidth,20/n.scale));return(p,h)=>{var g;return v(),C("svg",{style:Z({position:"absolute",width:`${c.value}px`,height:`${u.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:c.value,height:u.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[m("path",{d:o.value&&s.value?s.value.path:i.value,fill:"transparent",stroke:"transparent","stroke-width":d.value,onPointerdown:h[0]||(h[0]=(...f)=>t.onClick&&t.onClick(...f)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":t.color==="transparent"?"visibleStroke":"visible":"none",strokeLinecap:"butt",strokeLinejoin:"miter"})},null,44,qv),t.appearanceActive?ae("",!0):(v(),C(pe,{key:0},[o.value&&s.value?(v(),C("path",{key:0,d:s.value.path,opacity:t.opacity,style:Z({fill:t.color,stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,pointerEvents:"none",strokeLinejoin:"round"})},null,12,Kv)):(v(),C(pe,{key:1},[m("path",{d:i.value,opacity:t.opacity,style:Z({fill:t.currentVertex?"none":t.color,stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...t.strokeStyle===I(rt).DASHED&&{strokeDasharray:(g=t.strokeDashArray)==null?void 0:g.join(",")}})},null,12,Xv),l.value&&a.value.length>1?(v(),C("path",{key:0,d:`M ${a.value[a.value.length-1].x} ${a.value[a.value.length-1].y} L ${a.value[0].x} ${a.value[0].y}`,fill:"none",style:Z({stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeDasharray:"4,4",opacity:.7,pointerEvents:"none"})},null,12,Zv)):ae("",!0),l.value&&a.value.length>=2?(v(),C("rect",{key:1,x:a.value[0].x-t.handleSize/t.scale/2,y:a.value[0].y-t.handleSize/t.scale/2,width:t.handleSize/t.scale,height:t.handleSize/t.scale,fill:t.strokeColor,opacity:.4,stroke:t.strokeColor,"stroke-width":t.strokeWidth/2,style:{"pointer-events":"none"}},null,8,Qv)):ae("",!0)],64))],64))],12,Yv)}}}),Jv=ie({__name:"polygon-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he($p,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),eD=["contenteditable"],tD=ie({...{inheritAttrs:!1},__name:"free-text",props:{documentId:{},isSelected:{type:Boolean},isEditing:{type:Boolean},annotation:{},pageIndex:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=Q(null),o=Q(!1),{provides:r}=Bn(),a=P(()=>{var c;return((c=r.value)==null?void 0:c.forDocument(e.documentId))??null}),i=tv(()=>e.annotation.object.fontSize*e.scale,()=>e.isEditing);Se(()=>e.isEditing,async c=>{var u,d;if(!c||(await ua(),!n.value))return;o.value=!0;const p=n.value;p.focus();const h=(u=a.value)==null?void 0:u.findToolForAnnotation(e.annotation.object),g=((d=h==null?void 0:h.defaults)==null?void 0:d.contents)!=null&&e.annotation.object.contents===h.defaults.contents,f=window.getSelection();if(f){const F=document.createRange();F.selectNodeContents(p),g||F.collapse(!1),f.removeAllRanges(),f.addRange(F)}},{immediate:!0});const s=()=>{o.value&&(o.value=!1,!(!a.value||!n.value)&&a.value.updateAnnotation(e.pageIndex,e.annotation.object.id,{contents:n.value.innerText.replace(/\u00A0/g," ")}))},l=P(()=>{const{object:c}=e.annotation,{needsComp:u,adjustedFontPx:d,scaleComp:p}=i.value,h=u?100/p:100;return{color:c.fontColor,fontSize:`${d}px`,...os(c.fontFamily),textAlign:ts(c.textAlign),flexDirection:"column",justifyContent:c.verticalAlign===Ar.Top?"flex-start":c.verticalAlign===Ar.Middle?"center":"flex-end",display:"flex",backgroundColor:c.color??c.backgroundColor,opacity:c.opacity,width:u?`${h}%`:"100%",height:u?`${h}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:e.isEditing?"text":e.onClick?"pointer":"default",outline:"none",transform:u?`scale(${p})`:void 0,transformOrigin:"top left"}});return(c,u)=>(v(),C("div",{style:Z({position:"absolute",width:`${t.annotation.object.rect.size.width*t.scale}px`,height:`${t.annotation.object.rect.size.height*t.scale}px`,cursor:t.isSelected&&!t.isEditing?"move":"default",pointerEvents:t.onClick?t.isSelected&&!t.isEditing?"none":"auto":"none",zIndex:2,opacity:t.appearanceActive?0:1}),onPointerdown:u[0]||(u[0]=(...d)=>t.onClick&&t.onClick(...d))},[m("span",{ref_key:"editorRef",ref:n,onBlur:s,tabindex:"0",style:Z(l.value),contenteditable:t.isEditing},fe(t.annotation.object.contents),45,eD)],36))}}),nD=ie({__name:"free-text-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(tD,{documentId:t.documentId,isSelected:t.isSelected,isEditing:t.isEditing,annotation:{...t.annotation,object:t.currentObject},pageIndex:t.pageIndex,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive},null,8,["documentId","isSelected","isEditing","annotation","pageIndex","scale","onClick","appearanceActive"]))}}),oD=["src"],rD=ie({__name:"render-annotation",props:{documentId:{},pageIndex:{},annotation:{},scaleFactor:{default:1},unrotated:{type:Boolean,default:!1},style:{}},setup(t){const e=t,{provides:n}=Bn(),o=Q(null),r=Q(null),a=Q(null),i=P(()=>e.annotation.id),s=P(()=>e.annotation.rect.size.width),l=P(()=>e.annotation.rect.size.height);Se(()=>[e.pageIndex,e.scaleFactor,e.unrotated,e.documentId,i.value,s.value,l.value,n.value],(u,d,p)=>{if(n.value){r.value&&(URL.revokeObjectURL(r.value),r.value=null);const h=n.value.forDocument(e.documentId).renderAnnotation({pageIndex:e.pageIndex,annotation:n_(e.annotation),options:{scaleFactor:e.scaleFactor,dpr:window.devicePixelRatio,unrotated:e.unrotated}});a.value=h,h.wait(g=>{const f=URL.createObjectURL(g);o.value=f,r.value=f},Yt),p(()=>{r.value?(URL.revokeObjectURL(r.value),r.value=null):h.abort({code:ve.Cancelled,message:"canceled render task"})})}},{immediate:!0}),$o(()=>{r.value&&(URL.revokeObjectURL(r.value),r.value=null),a.value&&a.value.abort({code:ve.Cancelled,message:"canceled render task on unmount"})});const c=()=>{r.value&&(URL.revokeObjectURL(r.value),r.value=null)};return(u,d)=>o.value?(v(),C("img",{key:0,src:o.value,onLoad:c,style:Z({width:"100%",height:"100%",display:"block",...t.style})},null,44,oD)):ae("",!0)}}),aD=ie({...{inheritAttrs:!1},__name:"stamp",props:{isSelected:{type:Boolean},annotation:{},documentId:{},pageIndex:{},scale:{},onClick:{type:Function}},setup(t){const e=t,n=P(()=>!!e.annotation.object.rotation&&!!e.annotation.object.unrotatedRect);return(o,r)=>(v(),C("div",{style:Z({position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:t.onClick?t.isSelected?"none":"auto":"none",cursor:t.onClick?"pointer":"default"}),onPointerdown:r[0]||(r[0]=(...a)=>t.onClick&&t.onClick(...a))},[je(rD,{documentId:t.documentId,pageIndex:t.pageIndex,annotation:{...t.annotation.object,id:t.annotation.object.id},scaleFactor:t.scale,unrotated:n.value},null,8,["documentId","pageIndex","annotation","scaleFactor","unrotated"])],36))}}),iD=ie({__name:"stamp-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(aD,{isSelected:t.isSelected,annotation:t.annotation,documentId:t.documentId,pageIndex:t.pageIndex,scale:t.scale,onClick:t.onClick},null,8,["isSelected","annotation","documentId","pageIndex","scale","onClick"]))}}),sD=["width","height","viewBox"],lD=["width","height"],cD=["y1","x2","y2","stroke","stroke-width","stroke-dasharray"],uD=["x","y","width","height","stroke","stroke-width","stroke-dasharray"],dD=ie({...{inheritAttrs:!1},__name:"link",props:{isSelected:{type:Boolean},strokeColor:{default:"#0000FF"},strokeWidth:{default:2},strokeStyle:{default:rt.UNDERLINE},strokeDashArray:{},rect:{},scale:{},onClick:{},hasIRT:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.rect.size.width),o=P(()=>e.rect.size.height),r=P(()=>n.value*e.scale),a=P(()=>o.value*e.scale),i=P(()=>{var u;if(e.strokeStyle===rt.DASHED)return((u=e.strokeDashArray)==null?void 0:u.join(","))??`${e.strokeWidth*3},${e.strokeWidth}`}),s=P(()=>e.strokeStyle===rt.UNDERLINE),l=P(()=>e.hasIRT||!e.onClick?"default":e.isSelected?"move":"pointer"),c=P(()=>e.hasIRT||!e.onClick||e.isSelected?"none":"visible");return(u,d)=>(v(),C("svg",{style:Z({position:"absolute",width:`${r.value}px`,height:`${a.value}px`,pointerEvents:"none",zIndex:2}),width:r.value,height:a.value,viewBox:`0 0 ${n.value} ${o.value}`},[m("rect",{x:0,y:0,width:n.value,height:o.value,fill:"transparent",onPointerdown:d[0]||(d[0]=p=>{var h;return t.hasIRT||(h=t.onClick)==null?void 0:h.call(t,p)}),style:Z({cursor:l.value,pointerEvents:c.value})},null,44,lD),s.value?(v(),C("line",{key:0,x1:1,y1:o.value-1,x2:n.value-1,y2:o.value-1,stroke:t.strokeColor,"stroke-width":t.strokeWidth,"stroke-dasharray":i.value,style:{"pointer-events":"none"}},null,8,cD)):(v(),C("rect",{key:1,x:t.strokeWidth/2,y:t.strokeWidth/2,width:Math.max(n.value-t.strokeWidth,0),height:Math.max(o.value-t.strokeWidth,0),fill:"transparent",stroke:t.strokeColor,"stroke-width":t.strokeWidth,"stroke-dasharray":i.value,style:{"pointer-events":"none"}},null,8,uD))],12,sD))}}),pD=ie({__name:"link-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(dD,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,hasIRT:!!t.currentObject.inReplyToId}),null,16,["isSelected","scale","onClick","hasIRT"]))}}),Np=ie({...{inheritAttrs:!1},__name:"highlight",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00");return(o,r)=>(v(!0),C(pe,null,tt(t.segmentRects,(a,i)=>(v(),C("div",{key:i,onPointerdown:r[0]||(r[0]=(...s)=>t.onClick&&t.onClick(...s)),style:Z({position:"absolute",left:`${(t.rect?a.origin.x-t.rect.origin.x:a.origin.x)*t.scale}px`,top:`${(t.rect?a.origin.y-t.rect.origin.y:a.origin.y)*t.scale}px`,width:`${a.size.width*t.scale}px`,height:`${a.size.height*t.scale}px`,background:t.appearanceActive?"transparent":n.value,opacity:t.appearanceActive?void 0:t.opacity,pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:void 0})},null,36))),128))}}),hD=ie({__name:"highlight-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Np,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),jp=ie({...{inheritAttrs:!1},__name:"underline",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00"),o=P(()=>2*e.scale);return(r,a)=>(v(!0),C(pe,null,tt(t.segmentRects,(i,s)=>(v(),C("div",{key:s,onPointerdown:a[0]||(a[0]=(...l)=>t.onClick&&t.onClick(...l)),style:Z({position:"absolute",left:`${(t.rect?i.origin.x-t.rect.origin.x:i.origin.x)*t.scale}px`,top:`${(t.rect?i.origin.y-t.rect.origin.y:i.origin.y)*t.scale}px`,width:`${i.size.width*t.scale}px`,height:`${i.size.height*t.scale}px`,background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[t.appearanceActive?ae("",!0):(v(),C("div",{key:0,style:Z({position:"absolute",left:0,bottom:0,width:"100%",height:`${o.value}px`,background:n.value,opacity:t.opacity,pointerEvents:"none"})},null,4))],36))),128))}}),gD=ie({__name:"underline-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(jp,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),Up=ie({...{inheritAttrs:!1},__name:"strikeout",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00"),o=P(()=>2*e.scale);return(r,a)=>(v(!0),C(pe,null,tt(t.segmentRects,(i,s)=>(v(),C("div",{key:s,onPointerdown:a[0]||(a[0]=(...l)=>t.onClick&&t.onClick(...l)),style:Z({position:"absolute",left:`${(t.rect?i.origin.x-t.rect.origin.x:i.origin.x)*t.scale}px`,top:`${(t.rect?i.origin.y-t.rect.origin.y:i.origin.y)*t.scale}px`,width:`${i.size.width*t.scale}px`,height:`${i.size.height*t.scale}px`,background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[t.appearanceActive?ae("",!0):(v(),C("div",{key:0,style:Z({position:"absolute",left:0,top:"50%",width:"100%",height:`${o.value}px`,background:n.value,opacity:t.opacity,transform:"translateY(-50%)",pointerEvents:"none"})},null,4))],36))),128))}}),fD=ie({__name:"strikeout-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Up,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),Bp=ie({...{inheritAttrs:!1},__name:"squiggly",props:{strokeColor:{},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.strokeColor??"#FFFF00"),o=P(()=>2*e.scale),r=P(()=>6*e.scale),a=P(()=>{const i=o.value,s=r.value,l=`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${i*2}" viewBox="0 0 ${s} ${i*2}">
23
23
  <path d="M0 ${i} Q ${s/4} 0 ${s/2} ${i} T ${s} ${i}"
24
24
  fill="none" stroke="${n.value}" stroke-width="${i}" stroke-linecap="round"/>
25
- </svg>`;return`url("data:image/svg+xml;utf8,${encodeURIComponent(l)}")`});return(i,s)=>(v(!0),C(pe,null,tt(t.segmentRects,(l,c)=>(v(),C("div",{key:c,onPointerdown:s[0]||(s[0]=(...u)=>t.onClick&&t.onClick(...u)),style:Z({position:"absolute",left:`${(t.rect?l.origin.x-t.rect.origin.x:l.origin.x)*t.scale}px`,top:`${(t.rect?l.origin.y-t.rect.origin.y:l.origin.y)*t.scale}px`,width:`${l.size.width*t.scale}px`,height:`${l.size.height*t.scale}px`,background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[t.appearanceActive?ae("",!0):(v(),C("div",{key:0,style:Z({position:"absolute",left:0,bottom:0,width:"100%",height:`${o.value*2}px`,backgroundImage:a.value,backgroundRepeat:"repeat-x",backgroundSize:`${r.value}px ${o.value*2}px`,opacity:t.opacity,pointerEvents:"none"})},null,4))],36))),128))}}),hD=ie({__name:"squiggly-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Up,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),gD=["width","height","viewBox"],fD=["d"],mD=["d","fill","stroke","opacity"],PD=ie({...{inheritAttrs:!1},__name:"caret",props:{isSelected:{type:Boolean},strokeColor:{default:"#000000"},opacity:{default:1},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.rect.size.width),o=P(()=>e.rect.size.height),r=P(()=>{const s=n.value,l=o.value,c=s/2;return[`M 0 ${l}`,`C ${s*.27} ${l} ${c} ${l-l*.44} ${c} 0`,`C ${c} ${l-l*.44} ${s-s*.27} ${l} ${s} ${l}`,"Z"].join(" ")}),a=P(()=>n.value*e.scale),i=P(()=>o.value*e.scale);return(s,l)=>(v(),C("svg",{style:Z({position:"absolute",width:a.value,height:i.value,pointerEvents:"none",zIndex:2}),width:a.value,height:i.value,viewBox:`0 0 ${n.value} ${o.value}`,overflow:"visible"},[m("path",{d:r.value,fill:"transparent",stroke:"transparent","stroke-width":4,onPointerdown:l[0]||(l[0]=(...c)=>t.onClick&&t.onClick(...c)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visible":"none"})},null,44,fD),t.appearanceActive?ae("",!0):(v(),C("path",{key:0,d:r.value,fill:t.strokeColor,stroke:t.strokeColor,"stroke-width":.5,opacity:t.opacity,"fill-rule":"evenodd",style:{pointerEvents:"none"}},null,8,mD))],12,gD))}}),FD=ie({__name:"caret-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(PD,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),bD={key:0,style:{position:"absolute",inset:0,pointerEvents:"none"},viewBox:"0 0 20 20",width:"100%",height:"100%"},_D=["fill","opacity","stroke"],yD=["stroke"],vD=["stroke"],DD=["stroke"],SD=ie({__name:"text",props:{isSelected:{type:Boolean},color:{default:"#facc15"},opacity:{default:1},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>gF(e.color));return(o,r)=>(v(),C("div",{style:Z({position:"absolute",inset:0,zIndex:2,pointerEvents:t.onClick?t.isSelected?"none":"auto":"none",cursor:t.isSelected?"move":t.onClick?"pointer":"default"}),onPointerdown:r[0]||(r[0]=(...a)=>t.onClick&&t.onClick(...a))},[t.appearanceActive?ae("",!0):(v(),C("svg",bD,[m("path",{d:"M 0.5 15.5 L 0.5 0.5 L 19.5 0.5 L 19.5 15.5 L 8.5 15.5 L 6.5 19.5 L 4.5 15.5 Z",fill:t.color,opacity:t.opacity,stroke:n.value,"stroke-width":"1","stroke-linejoin":"miter"},null,8,_D),m("line",{x1:"2.5",y1:"4.25",x2:"17.5",y2:"4.25",stroke:n.value,"stroke-width":"1"},null,8,yD),m("line",{x1:"2.5",y1:"8",x2:"17.5",y2:"8",stroke:n.value,"stroke-width":"1"},null,8,vD),m("line",{x1:"2.5",y1:"11.75",x2:"17.5",y2:"11.75",stroke:n.value,"stroke-width":"1"},null,8,DD)]))],36))}}),ED=ie({__name:"text-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(SD,{isSelected:t.isSelected,color:t.currentObject.strokeColor??t.currentObject.color,opacity:t.currentObject.opacity,onClick:t.onClick,appearanceActive:t.appearanceActive},null,8,["isSelected","color","opacity","onClick","appearanceActive"]))}}),AD=[yt({id:"ink",matches:t=>t.type===M.INK,component:fv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),yt({id:"square",matches:t=>t.type===M.SQUARE,component:yv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),yt({id:"circle",matches:t=>t.type===M.CIRCLE,component:xv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),yt({id:"line",matches:t=>t.type===M.LINE,component:Iv,vertexConfig:{extractVertices:t=>[t.linePoints.start,t.linePoints.end],transformAnnotation:(t,e)=>({...t,linePoints:{start:e[0],end:e[1]}})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),yt({id:"polyline",matches:t=>t.type===M.POLYLINE,component:zv,vertexConfig:{extractVertices:t=>t.vertices,transformAnnotation:(t,e)=>({...t,vertices:e})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),yt({id:"polygon",matches:t=>t.type===M.POLYGON,component:Xv,vertexConfig:{extractVertices:t=>t.vertices,transformAnnotation:(t,e)=>({...t,vertices:e})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),yt({id:"highlight",matches:t=>t.type===M.HIGHLIGHT,component:uD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},defaultBlendMode:it.Multiply}),yt({id:"underline",matches:t=>t.type===M.UNDERLINE,component:dD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),yt({id:"strikeout",matches:t=>t.type===M.STRIKEOUT,component:pD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),yt({id:"squiggly",matches:t=>t.type===M.SQUIGGLY,component:hD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),yt({id:"text",matches:t=>t.type===M.TEXT&&!t.inReplyToId,component:ED,interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1}}),yt({id:"caret",matches:t=>t.type===M.CARET,component:FD,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),yt({id:"freeText",matches:t=>t.type===M.FREETEXT,component:Jv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(t,{isEditing:e})=>t&&!e,onDoubleClick:(t,e)=>e(t)}),yt({id:"stamp",matches:t=>t.type===M.STAMP,component:oD,useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),yt({id:"link",matches:t=>t.type===M.LINK,component:cD,renderPreview:dv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,selectOverride:(t,e,n)=>{if(t.stopPropagation(),n.clearSelection(),e.object.inReplyToId){const o=n.allAnnotations.find(r=>r.object.id===e.object.inReplyToId);if(o){n.selectAnnotation(o.object.pageIndex,o.object.id);return}}n.selectAnnotation(n.pageIndex,e.object.id)},hideSelectionMenu:t=>!!t.inReplyToId,renderLocked:uv})],xD=ie({__name:"annotations",props:{documentId:{},pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},resizeUi:{},vertexUi:{},rotationUi:{},selectionOutlineColor:{},selectionOutline:{},groupSelectionOutline:{},selectionMenu:{type:Function},groupSelectionMenu:{type:Function},annotationRenderers:{}},setup(t){const e=t,{provides:n}=Bn(),{provides:o}=js(),r=ln([]),a=ln([]),{register:i}=Fy({documentId:()=>e.documentId,pageIndex:e.pageIndex}),s=Q(null),l=ln({}),c=ln({type:jn.None});let u=e.scale;const d=P(()=>n.value?n.value.forDocument(e.documentId):null),p=P(()=>a.value.length>1),h=P(()=>{const O=e.annotationRenderers??[],H=new Set(O.map(V=>V.id));return[...O,...AD.filter(V=>!H.has(V.id))]}),g=O=>h.value.find(H=>H.matches(O.object))??null,f=O=>{if(O.dictMode||O.object.rotation&&O.object.unrotatedRect)return null;const H=l.value[O.object.id];return H!=null&&H.normal?H:null};Se([d,()=>e.pageIndex],([O,H],V,se)=>{if(!O){r.value=[],a.value=[];return}const L=Re=>{r.value=wb(Re,H),a.value=Ju(Re),c.value=Re.locked};L(O.getState());const de=O.onStateChange(L);se(de);const Pe=O.onAnnotationEvent(Re=>{Re.type==="create"&&Re.editAfterCreate&&(s.value=Re.annotation.id)});se(Pe)},{immediate:!0}),Se([d,()=>e.pageIndex,()=>e.scale],([O,H,V],se,L)=>{if(!O){l.value={};return}u!==V&&(O.invalidatePageAppearances(H),u=V);let de=!1;L(()=>{de=!0}),O.getPageAppearances(H,{scaleFactor:V,dpr:typeof window<"u"?window.devicePixelRatio:1}).wait(Re=>{de||(l.value=Re)},()=>{de||(l.value={})})},{immediate:!0});const F=P(()=>r.value.map(O=>{var H;const V=g(O);if(!V)return null;const se=((H=d.value)==null?void 0:H.findToolForAnnotation(O.object))??null,L=Ds(se),de=Zu(O.object)||Ba(L,c.value);return de&&V.hiddenWhenLocked?null:{annotation:O,renderer:V,tool:se,locked:de}}).filter(O=>O!==null)),_=(O,H,V)=>{var se;if(V)return!1;const L=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object),de=H.interactionDefaults,Pe=s.value===O.object.id,Re=tn(L==null?void 0:L.interaction.isDraggable,O.object,(de==null?void 0:de.isDraggable)??!0);return H.isDraggable?H.isDraggable(Re,{isEditing:Pe}):Re},y=(O,H,V)=>{var se,L;if(V)return!1;const de=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object);return tn(de==null?void 0:de.interaction.isResizable,O.object,((L=H.interactionDefaults)==null?void 0:L.isResizable)??!1)},E=(O,H)=>{var V,se;const L=(V=d.value)==null?void 0:V.findToolForAnnotation(O.object);return tn(L==null?void 0:L.interaction.lockAspectRatio,O.object,((se=H.interactionDefaults)==null?void 0:se.lockAspectRatio)??!1)},A=(O,H,V)=>{var se,L;if(V)return!1;const de=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object);return tn(de==null?void 0:de.interaction.isRotatable,O.object,((L=H.interactionDefaults)==null?void 0:L.isRotatable)??!1)},T=(O,H,V)=>{var se;if(!V&&!((se=H.hideSelectionMenu)!=null&&se.call(H,O.object))&&!p.value)return e.selectionMenu},q=O=>{O.stopPropagation()},w=(O,H,V)=>{if(V)return q;if(H.selectOverride){const se={defaultSelect:W,selectAnnotation:(L,de)=>{var Pe;return(Pe=d.value)==null?void 0:Pe.selectAnnotation(L,de)},clearSelection:()=>{var L;return(L=o.value)==null?void 0:L.clear()},allAnnotations:r.value,pageIndex:e.pageIndex};return L=>H.selectOverride(L,O,se)}return se=>W(se,O)},G=(O,H)=>{H.target===H.currentTarget&&d.value&&(s.value&&r.value.some(V=>V.object.id===s.value)&&H.stopImmediatePropagation(),d.value.deselectAnnotation(),s.value=null)},W=(O,H)=>{O.stopPropagation(),d.value&&o.value&&(o.value.clear(),("metaKey"in O?O.metaKey||O.ctrlKey:!1)?d.value.toggleSelection(e.pageIndex,H.object.id):d.value.selectAnnotation(e.pageIndex,H.object.id),H.object.id!==s.value&&(s.value=null))},J=O=>{s.value=O},ue={onPointerDown:G};Se(d,(O,H,V)=>{if(!O)return;const se=i(ue);se&&V(se)},{immediate:!0});const ce=P(()=>r.value.filter(O=>a.value.includes(O.object.id))),ee=P(()=>ce.value.length<2?!1:ce.value.every(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.isGroupDraggable,O.object,!0),L=tn(V==null?void 0:V.interaction.isDraggable,O.object,!0);return(V==null?void 0:V.interaction.isGroupDraggable)!==void 0?se:L})),ge=P(()=>ce.value.length<2?!1:ce.value.every(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.isGroupResizable,O.object,!0),L=tn(V==null?void 0:V.interaction.isResizable,O.object,!0);return(V==null?void 0:V.interaction.isGroupResizable)!==void 0?se:L})),_e=P(()=>ce.value.length<2?!1:ce.value.every(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.isGroupRotatable,O.object,!0),L=tn(V==null?void 0:V.interaction.isRotatable,O.object,!0);return(V==null?void 0:V.interaction.isGroupRotatable)!==void 0?se:L})),Ee=P(()=>ce.value.length<2?!1:ce.value.some(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.lockGroupAspectRatio,O.object,!1),L=tn(V==null?void 0:V.interaction.lockAspectRatio,O.object,!1);return(V==null?void 0:V.interaction.lockGroupAspectRatio)!==void 0?se:L})),Te=P(()=>!d.value||a.value.length<2?!1:d.value.getSelectedAnnotations().every(H=>H.object.pageIndex===e.pageIndex)),oe=(O,H,V)=>{if(!V&&O.onDoubleClick)return se=>{se.stopPropagation(),O.onDoubleClick(H.object.id,J)}},He=(O,H)=>Oa(O.object.blendMode??H.defaultBlendMode??it.Normal),ft=(O,H,V)=>{var se,L;if(V&&H.renderLocked)return;const de=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object);return((L=de==null?void 0:de.behavior)==null?void 0:L.useAppearanceStream)??H.useAppearanceStream??!0?f(O):void 0},Ve=P(()=>{const{selectionMenu:O,groupSelectionMenu:H,groupSelectionOutline:V,annotationRenderers:se,...L}=e;return L});return(O,H)=>(v(),C(pe,null,[(v(!0),C(pe,null,tt(F.value,({annotation:V,renderer:se,locked:L})=>{var de;return v(),he(tv,xe({key:V.object.id,trackedAnnotation:V,isSelected:L?!1:a.value.includes(V.object.id),isEditing:L?!1:s.value===V.object.id,isMultiSelected:L?!1:p.value,isDraggable:_(V,se,L),isResizable:y(V,se,L),lockAspectRatio:E(V,se),isRotatable:A(V,se,L),vertexConfig:L?void 0:se.vertexConfig,selectionMenu:T(V,se,L),onSelect:w(V,se,L),onDoubleClick:oe(se,V,L),zIndex:se.zIndex,blendMode:He(V,se),style:(de=se.containerStyle)==null?void 0:de.call(se,V.object),appearance:ft(V,se,L)},{ref_for:!0},Ve.value),wm({default:We(({annotation:Pe,appearanceActive:Re})=>[(v(),he(Fn(L&&se.renderLocked?se.renderLocked:se.component),{annotation:V,currentObject:Pe,isSelected:L?!1:a.value.includes(V.object.id),isEditing:L?!1:s.value===V.object.id,scale:t.scale,pageIndex:t.pageIndex,documentId:t.documentId,onClick:L?void 0:w(V,se,L),appearanceActive:Re},null,8,["annotation","currentObject","isSelected","isEditing","scale","pageIndex","documentId","onClick","appearanceActive"]))]),"resize-handle":We(Pe=>[$e(O.$slots,"resize-handle",xe({ref_for:!0},Pe))]),"vertex-handle":We(Pe=>[$e(O.$slots,"vertex-handle",xe({ref_for:!0},Pe))]),"rotation-handle":We(Pe=>[$e(O.$slots,"rotation-handle",xe({ref_for:!0},Pe))]),_:2},[p.value?void 0:{name:"selection-menu",fn:We(Pe=>[$e(O.$slots,"selection-menu",xe({ref_for:!0},Pe))]),key:"0"}]),1040,["trackedAnnotation","isSelected","isEditing","isMultiSelected","isDraggable","isResizable","lockAspectRatio","isRotatable","vertexConfig","selectionMenu","onSelect","onDoubleClick","zIndex","blendMode","style","appearance"])}),128)),Te.value&&ce.value.length>=2?(v(),he(iv,{key:0,documentId:t.documentId,pageIndex:t.pageIndex,scale:t.scale,rotation:t.rotation,pageWidth:t.pageWidth,pageHeight:t.pageHeight,selectedAnnotations:ce.value,isDraggable:ee.value,isResizable:ge.value,isRotatable:_e.value,lockAspectRatio:Ee.value,resizeUi:t.resizeUi,rotationUi:t.rotationUi,selectionOutlineColor:t.selectionOutlineColor,selectionOutline:t.groupSelectionOutline??t.selectionOutline,groupSelectionMenu:t.groupSelectionMenu},{"selection-menu":We(V=>[$e(O.$slots,"group-selection-menu",zt(Qt(V)))]),"resize-handle":We(V=>[$e(O.$slots,"resize-handle",zt(Qt(V)))]),"rotation-handle":We(V=>[$e(O.$slots,"rotation-handle",zt(Qt(V)))]),_:3},8,["documentId","pageIndex","scale","rotation","pageWidth","pageHeight","selectedAnnotations","isDraggable","isResizable","isRotatable","lockAspectRatio","resizeUi","rotationUi","selectionOutlineColor","selectionOutline","groupSelectionMenu"])):ae("",!0)],64))}}),CD=ie({__name:"text-markup",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{provides:n}=js(),{provides:o}=Bn(),r=Q([]),a=Q(null),i=Q(null);Xn(l=>{const c=[];if(n.value){const u=n.value.forDocument(e.documentId),d=u.onSelectionChange(()=>{r.value=u.getHighlightRectsForPage(e.pageIndex),a.value=u.getBoundingRectForPage(e.pageIndex)});c.push(d)}if(o.value){const u=o.value.forDocument(e.documentId);i.value=u.getActiveTool();const d=u.onActiveToolChange(p=>i.value=p);c.push(d)}l(()=>{c.forEach(u=>u())})});const s=P(()=>{if(!i.value)return Oa(it.Normal);const l=i.value.defaults.type===M.HIGHLIGHT?it.Multiply:it.Normal;return Oa(i.value.defaults.blendMode??l)});return(l,c)=>a.value&&i.value?(v(),C("div",{key:0,style:Z({mixBlendMode:s.value,pointerEvents:"none",position:"absolute",inset:0})},[i.value.defaults.type===I(M).HIGHLIGHT?(v(),he($p,{key:0,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):i.value.defaults.type===I(M).UNDERLINE?(v(),he(Np,{key:1,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):i.value.defaults.type===I(M).STRIKEOUT?(v(),he(jp,{key:2,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):i.value.defaults.type===I(M).SQUIGGLY?(v(),he(Up,{key:3,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):ae("",!0)],4)):ae("",!0)}}),TD=ie({__name:"preview-renderer",props:{toolId:{},preview:{},scale:{}},setup(t){const e=t,n=zs(),o=P(()=>(n==null?void 0:n.getAll().find(a=>a.id===e.toolId&&a.renderPreview))??null),r=P(()=>{const a={position:"absolute",left:`${e.preview.bounds.origin.x*e.scale}px`,top:`${e.preview.bounds.origin.y*e.scale}px`,width:`${e.preview.bounds.size.width*e.scale}px`,height:`${e.preview.bounds.size.height*e.scale}px`,pointerEvents:"none",zIndex:10};return e.preview.type===M.INK&&(a.mixBlendMode=Oa(e.preview.data.blendMode??it.Normal)),a});return(a,i)=>{var s;return v(),C("div",{style:Z(r.value)},[t.preview.type===I(M).CIRCLE?(v(),he(I(kp),xe({key:0,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).SQUARE?(v(),he(I(Op),xe({key:1,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).POLYGON?(v(),he(I(Lp),xe({key:2,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).POLYLINE?(v(),he(I(Gp),xe({key:3,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).LINE?(v(),he(I(Ip),xe({key:4,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).INK?(v(),he(I(wp),xe({key:5,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).FREETEXT?(v(),C("div",{key:6,style:Z({width:"100%",height:"100%",border:`1px dashed ${t.preview.data.fontColor||"#000000"}`,backgroundColor:"transparent"})},null,4)):(s=o.value)!=null&&s.renderPreview?(v(),he(Fn(o.value.renderPreview),{key:7,data:t.preview.data,bounds:t.preview.bounds,scale:t.scale},null,8,["data","bounds","scale"])):ae("",!0)],4)}}}),Bp=ie({__name:"annotation-paint-layer",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{plugin:n}=ti(),o=Q(new Map),r=Q(null),a=Q(null),i=P(()=>({requestFile:({accept:l,onFile:c})=>{const u=r.value;u&&(u.accept=l,u.onchange=d=>{var p;const h=(p=d.target.files)==null?void 0:p[0];h&&(c(h),u.value="")},u.click())},processImage:({source:l,maxWidth:c,maxHeight:u,onComplete:d})=>{const p=a.value;if(!p||!p.getContext)return;const h=p.getContext("2d");if(!h)return;const g=new Image;g.crossOrigin="Anonymous",g.onload=()=>{let{naturalWidth:f,naturalHeight:F}=g;const _=c?c/f:1,y=u?u/F:1,E=Math.min(_,y,1),A=f*E,T=F*E;p.width=A,p.height=T,h.drawImage(g,0,0,A,T);const q=h.getImageData(0,0,A,T);typeof l!="string"&&URL.revokeObjectURL(g.src),d({imageData:q,width:A,height:T})},g.src=typeof l=="string"?l:URL.createObjectURL(l)}}));let s;return Xn(l=>{n.value&&(s=n.value.registerPageHandlers(e.documentId,e.pageIndex,e.scale,{services:i.value,onPreview:(c,u)=>{const d=new Map(o.value);u?d.set(c,u):d.delete(c),o.value=d}})),l(()=>{s==null||s()})}),(l,c)=>(v(),C(pe,null,[m("input",{ref_key:"fileInputRef",ref:r,type:"file",style:{display:"none"}},null,512),m("canvas",{ref_key:"canvasRef",ref:a,style:{display:"none"}},null,512),(v(!0),C(pe,null,tt(o.value.entries(),([u,d])=>(v(),he(TD,{key:u,toolId:u,preview:d,scale:t.scale},null,8,["toolId","preview","scale"]))),128))],64))}}),MD=ie({__name:"annotation-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{},resizeUi:{},resizeUI:{},vertexUi:{},vertexUI:{},rotationUi:{},selectionOutlineColor:{},selectionOutline:{},groupSelectionOutline:{},selectionMenu:{type:Function},groupSelectionMenu:{type:Function},annotationRenderers:{}},setup(t){const e=t,n=P(()=>e.resizeUi??e.resizeUI),o=P(()=>e.vertexUi??e.vertexUI);Lo(()=>{e.resizeUI&&console.warn('[AnnotationLayer] The "resizeUI" prop is deprecated. Use :resize-ui in templates instead.'),e.vertexUI&&console.warn('[AnnotationLayer] The "vertexUI" prop is deprecated. Use :vertex-ui in templates instead.')});const r=zs(),a=P(()=>{const p=(r==null?void 0:r.getAll())??[],h=e.annotationRenderers??[],g=[...p];for(const f of h){const F=g.findIndex(_=>_.id===f.id);F>=0?g[F]=f:g.push(f)}return g}),i=Dn(()=>e.documentId),s=P(()=>{var p,h,g;return(g=(h=(p=i.value)==null?void 0:p.document)==null?void 0:h.pages)==null?void 0:g[e.pageIndex]}),l=P(()=>{var p,h;return((h=(p=s.value)==null?void 0:p.size)==null?void 0:h.width)??0}),c=P(()=>{var p,h;return((h=(p=s.value)==null?void 0:p.size)==null?void 0:h.height)??0}),u=P(()=>{var p;return e.scale!==void 0?e.scale:((p=i.value)==null?void 0:p.scale)??1}),d=P(()=>{var p,h;if(e.rotation!==void 0)return e.rotation;const g=((p=s.value)==null?void 0:p.rotation)??0,f=((h=i.value)==null?void 0:h.rotation)??0;return(g+f)%4});return(p,h)=>(v(),C("div",null,[je(xD,{documentId:t.documentId,pageIndex:t.pageIndex,scale:u.value,rotation:d.value,pageWidth:l.value,pageHeight:c.value,resizeUi:n.value,vertexUi:o.value,rotationUi:t.rotationUi,selectionOutlineColor:t.selectionOutlineColor,selectionOutline:t.selectionOutline,groupSelectionOutline:t.groupSelectionOutline,selectionMenu:t.selectionMenu,groupSelectionMenu:t.groupSelectionMenu,annotationRenderers:a.value},{"selection-menu":We(g=>[$e(p.$slots,"selection-menu",zt(Qt(g)))]),"group-selection-menu":We(g=>[$e(p.$slots,"group-selection-menu",zt(Qt(g)))]),"resize-handle":We(g=>[$e(p.$slots,"resize-handle",zt(Qt(g)))]),"vertex-handle":We(g=>[$e(p.$slots,"vertex-handle",zt(Qt(g)))]),"rotation-handle":We(g=>[$e(p.$slots,"rotation-handle",zt(Qt(g)))]),_:3},8,["documentId","pageIndex","scale","rotation","pageWidth","pageHeight","resizeUi","vertexUi","rotationUi","selectionOutlineColor","selectionOutline","groupSelectionOutline","selectionMenu","groupSelectionMenu","annotationRenderers"]),je(CD,{documentId:t.documentId,pageIndex:t.pageIndex,scale:u.value},null,8,["documentId","pageIndex","scale"]),je(Bp,{documentId:t.documentId,pageIndex:t.pageIndex,scale:u.value},null,8,["documentId","pageIndex","scale"])]))}}),RD=ie({__name:"renderer-registry-provider",setup(t){return lv(),(e,n)=>$e(e.$slots,"default")}}),wD={style:{display:"none"}},OD=ie({__name:"annotation-navigation-handler",setup(t){const{plugin:e}=ti(),{provides:n}=Bn();return Xn(o=>{const r=n.value,a=e.value;if(!r||!a)return;const i=r.onNavigate(s=>{s.result.outcome==="uri"&&a.config.autoOpenLinks!==!1&&window.open(s.result.uri,"_blank","noopener,noreferrer")});o(i)}),(o,r)=>(v(),C("span",wD))}}),kD=Tr(I_).addWrapper(RD).addUtility(OD).build(),zp=class extends jt{constructor(e,n,o){super(e,n),this.id=e,this.documentOpened$=Be(),this.documentClosed$=Be(),this.activeDocumentChanged$=Be(),this.documentError$=Be(),this.documentOrderChanged$=Be(),this.openFileRequest$=$n(),this.loadOptions=new Map,this.maxDocuments=o==null?void 0:o.maxDocuments}buildCapability(){return{openFileDialog:e=>this.openFileDialog(e),openDocumentUrl:e=>this.openDocumentUrl(e),openDocumentBuffer:e=>this.openDocumentBuffer(e),retryDocument:(e,n)=>this.retryDocument(e,n),closeDocument:e=>this.closeDocument(e),closeAllDocuments:()=>this.closeAllDocuments(),setActiveDocument:e=>{if(!this.isDocumentOpen(e))throw new Error(`Cannot set active document: ${e} is not open`);this.dispatchCoreAction(RF(e))},getActiveDocumentId:()=>this.coreState.core.activeDocumentId,getActiveDocument:()=>{var e;const n=this.coreState.core.activeDocumentId;return n?((e=this.coreState.core.documents[n])==null?void 0:e.document)??null:null},getDocumentOrder:()=>this.coreState.core.documentOrder,moveDocument:(e,n)=>{this.dispatchCoreAction(kF(e,n))},swapDocuments:(e,n)=>{const o=this.coreState.core.documentOrder,r=o.indexOf(e),a=o.indexOf(n);if(r===-1||a===-1)throw new Error("One or both documents not found in order");const i=[...o];[i[r],i[a]]=[i[a],i[r]],this.dispatchCoreAction(OF(i))},getDocument:e=>{var n;return((n=this.coreState.core.documents[e])==null?void 0:n.document)??null},getDocumentState:e=>this.coreState.core.documents[e]??null,getOpenDocuments:()=>this.coreState.core.documentOrder.map(e=>this.coreState.core.documents[e]).filter(e=>e!==null),isDocumentOpen:e=>this.isDocumentOpen(e),getDocumentCount:()=>Object.keys(this.coreState.core.documents).length,getDocumentIndex:e=>this.coreState.core.documentOrder.indexOf(e),setDocumentEncryption:(e,n)=>this.setDocumentEncryption(e,n),unlockOwnerPermissions:(e,n)=>this.unlockOwnerPermissions(e,n),removeEncryption:e=>this.removeEncryption(e),onDocumentOpened:this.documentOpened$.on,onDocumentClosed:this.documentClosed$.on,onDocumentError:this.documentError$.on,onActiveDocumentChanged:this.activeDocumentChanged$.on,onDocumentOrderChanged:this.documentOrderChanged$.on}}isDocumentOpen(e){return!!this.coreState.core.documents[e]}onDocumentLoaded(e){const n=this.coreState.core.documents[e];!n||n.status!=="loaded"||(this.loadOptions.delete(e),this.documentOpened$.emit(n),this.logger.info("DocumentManagerPlugin","DocumentOpened",`Document ${e} opened successfully`,{name:n.name}))}onDocumentClosed(e){this.loadOptions.delete(e),this.documentClosed$.emit(e),this.logger.info("DocumentManagerPlugin","DocumentClosed",`Document ${e} closed`)}onActiveDocumentChanged(e,n){this.activeDocumentChanged$.emit({previousDocumentId:e,currentDocumentId:n}),this.logger.info("DocumentManagerPlugin","ActiveDocumentChanged",`Active document changed from ${e} to ${n}`)}onCoreStoreUpdated(e,n){e.core.documentOrder!==n.core.documentOrder&&this.documentOrderChanged$.emit({order:n.core.documentOrder})}onOpenFileRequest(e){return this.openFileRequest$.on(e)}openDocumentUrl(e){const n=new Ie,o=e.documentId||this.generateDocumentId(),r=this.checkDocumentLimit();if(r)return n.reject(r),n;const a=e.name??this.extractNameFromUrl(e.url);this.loadOptions.set(o,e),this.dispatchCoreAction(Pu(o,a,e.scale,e.rotation,!!e.password,e.autoActivate,e.permissions)),this.logger.info("DocumentManagerPlugin","OpenDocumentUrl",`Starting to load document from URL: ${e.url}`,{documentId:o,passwordProvided:!!e.password});const i={id:o,url:e.url},s=this.engine.openDocumentUrl(i,{password:e.password,mode:e.mode,requestOptions:e.requestOptions,normalizeRotation:!0});return n.resolve({documentId:o,task:s}),this.handleLoadTask(o,s,"OpenDocumentUrl"),n}openDocumentBuffer(e){const n=new Ie,o=this.checkDocumentLimit();if(o)return n.reject(o),n;const r=e.documentId||this.generateDocumentId();this.loadOptions.set(r,e),this.dispatchCoreAction(Pu(r,e.name,e.scale,e.rotation,!!e.password,e.autoActivate,e.permissions)),this.logger.info("DocumentManagerPlugin","OpenDocumentBuffer",`Starting to load document from buffer: ${e.name}`,{documentId:r,passwordProvided:!!e.password});const a={id:r,content:e.buffer},i=this.engine.openDocumentBuffer(a,{password:e.password,normalizeRotation:!0});return n.resolve({documentId:r,task:i}),this.handleLoadTask(r,i,"OpenDocumentBuffer"),n}retryDocument(e,n){const o=new Ie,r=this.validateRetry(e);if(!r.valid)return o.reject(r.error),o;const i={...this.loadOptions.get(e),...(n==null?void 0:n.password)&&{password:n.password}};this.loadOptions.set(e,i),this.dispatchCoreAction(MF(e,!!(n!=null&&n.password))),this.logger.info("DocumentManagerPlugin","RetryDocument",`Retrying to load document ${e}`,{passwordProvided:!!(n!=null&&n.password)});const s="url"in i?this.retryUrlDocument(e,i):this.retryBufferDocument(e,i);return o.resolve({documentId:e,task:s}),this.handleLoadTask(e,s,"RetryDocument"),o}openFileDialog(e){const n=new Ie;return this.openFileRequest$.emit({task:n,options:e}),n}closeDocument(e){const n=new Ie,o=this.coreState.core.documents[e];return o?(o.status==="loaded"&&o.document?this.engine.closeDocument(o.document).wait(()=>{this.dispatchCoreAction(Fu(e)),n.resolve()},r=>{this.logger.error("DocumentManagerPlugin","CloseDocument",`Failed to close document ${e}`,r),n.fail(r)}):(this.logger.info("DocumentManagerPlugin","CloseDocument",`Closing document ${e} in ${o.status} state (skipping engine close)`),this.dispatchCoreAction(Fu(e)),n.resolve()),n):(this.logger.warn("DocumentManagerPlugin","CloseDocument",`Cannot close document ${e}: not found in state`),n.resolve(),n)}closeAllDocuments(){const e=Object.keys(this.coreState.core.documents),n=e.map(o=>this.closeDocument(o));return this.logger.info("DocumentManagerPlugin","CloseAllDocuments",`Closing ${e.length} documents`),Ie.all(n)}setDocumentEncryption(e,n){const o=new Ie,r=this.coreState.core.documents[e];return r!=null&&r.document?(this.logger.info("DocumentManagerPlugin","SetDocumentEncryption",`Setting encryption on document ${e}`,{hasUserPassword:!!n.userPassword,allowedFlags:n.allowedFlags}),this.engine.setDocumentEncryption(r.document,n.userPassword??"",n.ownerPassword,n.allowedFlags).wait(i=>{i&&this.logger.info("DocumentManagerPlugin","SetDocumentEncryption",`Encryption set successfully on document ${e}`),o.resolve(i)},i=>{this.logger.error("DocumentManagerPlugin","SetDocumentEncryption",`Failed to set encryption on document ${e}`,i),o.fail(i)}),o):(o.reject({code:ve.DocNotOpen,message:`Document ${e} is not open`}),o)}unlockOwnerPermissions(e,n){const o=new Ie,r=this.coreState.core.documents[e];if(!(r!=null&&r.document))return o.reject({code:ve.DocNotOpen,message:`Document ${e} is not open`}),o;const a=r.document;return this.logger.info("DocumentManagerPlugin","UnlockOwnerPermissions",`Attempting to unlock owner permissions on document ${e}`),this.engine.unlockOwnerPermissions(a,n).wait(s=>{s&&(this.logger.info("DocumentManagerPlugin","UnlockOwnerPermissions",`Owner permissions unlocked on document ${e}`),this.dispatchCoreAction(IF(e,4294967295,!0))),o.resolve(s)},s=>{this.logger.error("DocumentManagerPlugin","UnlockOwnerPermissions",`Failed to unlock owner permissions on document ${e}`,s),o.fail(s)}),o}removeEncryption(e){const n=new Ie,o=this.coreState.core.documents[e];return o!=null&&o.document?(this.logger.info("DocumentManagerPlugin","RemoveEncryption",`Marking document ${e} for encryption removal on save`),this.engine.removeEncryption(o.document).wait(a=>{a&&this.logger.info("DocumentManagerPlugin","RemoveEncryption",`Document ${e} marked for encryption removal`),n.resolve(a)},a=>{this.logger.error("DocumentManagerPlugin","RemoveEncryption",`Failed to mark document ${e} for encryption removal`,a),n.fail(a)}),n):(n.reject({code:ve.DocNotOpen,message:`Document ${e} is not open`}),n)}checkDocumentLimit(){return this.maxDocuments&&Object.keys(this.coreState.core.documents).length>=this.maxDocuments?{code:ve.Unknown,message:`Maximum number of documents (${this.maxDocuments}) reached`}:null}validateRetry(e){const n=this.coreState.core.documents[e];return n?n.status==="loaded"?{valid:!1,error:{code:ve.Unknown,message:`Document ${e} is already loaded successfully`}}:n.status!=="error"?{valid:!1,error:{code:ve.Unknown,message:`Document ${e} is not in error state (current state: ${n.status})`}}:this.loadOptions.has(e)?{valid:!0}:{valid:!1,error:{code:ve.Unknown,message:`No retry information available for document ${e}`}}:{valid:!1,error:{code:ve.NotFound,message:`Document ${e} not found`}}}retryUrlDocument(e,n){const o={id:e,url:n.url};return this.engine.openDocumentUrl(o,{password:n.password,mode:n.mode,requestOptions:n.requestOptions})}retryBufferDocument(e,n){const o={id:e,content:n.buffer};return this.engine.openDocumentBuffer(o,{password:n.password,normalizeRotation:!0})}handleLoadTask(e,n,o){n.wait(r=>{this.dispatchCoreAction(CF(e,r))},r=>{this.handleLoadError(e,r,o)})}handleLoadError(e,n,o){var r,a,i;const s=((r=n.reason)==null?void 0:r.message)||"Failed to load document";this.logger.error("DocumentManagerPlugin",o,"Failed to load document",n),this.dispatchCoreAction(TF(e,s,(a=n.reason)==null?void 0:a.code,n.reason)),this.documentError$.emit({documentId:e,message:s,code:(i=n.reason)==null?void 0:i.code,reason:n.reason})}generateDocumentId(){return`doc-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}extractNameFromUrl(e){try{const r=new URL(e).pathname.split("/").pop();if(!r)return;let a=decodeURIComponent(r);return a.toLowerCase().endsWith(".pdf")||(a+=".pdf"),a}catch{return}}async initialize(e){var n;if(this.logger.info("DocumentManagerPlugin","Initialize","Document Manager Plugin initialized",{maxDocuments:this.maxDocuments,initialDocumentsCount:((n=e.initialDocuments)==null?void 0:n.length)??0}),e.initialDocuments&&e.initialDocuments.length>0)for(const o of e.initialDocuments)try{"buffer"in o?this.openDocumentBuffer(o):"url"in o&&this.openDocumentUrl(o)}catch(r){this.logger.error("DocumentManagerPlugin","Initialize","Failed to initiate initial document load",r)}}async destroy(){await this.closeAllDocuments().toPromise(),this.loadOptions.clear(),this.documentOpened$.clear(),this.documentClosed$.clear(),this.activeDocumentChanged$.clear(),this.documentOrderChanged$.clear(),this.documentError$.clear(),super.destroy()}};zp.id="document-manager";let Ws=zp;const Wp="document-manager",ID={manifest:{id:Wp,name:"Document Manager Plugin",version:"1.0.0",provides:["document-manager"],requires:[],optional:[],defaultConfig:{maxDocuments:10}},create:(t,e)=>new Ws(Wp,t,e),reducer:t=>t,initialState:{}},GD=ie({__name:"document-content",props:{documentId:{}},setup(t){const e=t,n=Dn(()=>$t(e.documentId)),o=P(()=>{var i;return((i=n.value)==null?void 0:i.status)==="loading"}),r=P(()=>{var i;return((i=n.value)==null?void 0:i.status)==="error"}),a=P(()=>{var i;return((i=n.value)==null?void 0:i.status)==="loaded"});return(i,s)=>I(n)?$e(i.$slots,"default",{key:0,documentState:I(n),isLoading:o.value,isError:r.value,isLoaded:a.value}):ae("",!0)}}),LD=()=>Nn(Ws.id),Hp=()=>It(Ws.id),$D=ie({__name:"file-picker",setup(t){const{plugin:e}=LD(),{provides:n}=Hp(),o=Q(null),r=Q(null),a=Q(void 0);Se(e,(s,l,c)=>{if(!(s!=null&&s.onOpenFileRequest))return;const u=s.onOpenFileRequest(({task:d,options:p})=>{var h;r.value=d,a.value=p,(h=o.value)==null||h.click()});c(u)},{immediate:!0});const i=async s=>{var l,c,u,d,p;const g=(l=s.target.files)==null?void 0:l[0],f=n.value;if(!g||!f)return;const F=await g.arrayBuffer();f.openDocumentBuffer({name:g.name,buffer:F,documentId:(c=a.value)==null?void 0:c.documentId,scale:(u=a.value)==null?void 0:u.scale,rotation:(d=a.value)==null?void 0:d.rotation,autoActivate:(p=a.value)==null?void 0:p.autoActivate}).wait(y=>{var E;(E=r.value)==null||E.resolve(y)},y=>{var E;(E=r.value)==null||E.fail(y)})};return(s,l)=>(v(),C("input",{ref_key:"inputRef",ref:o,type:"file",accept:"application/pdf",style:{display:"none"},onChange:i},null,544))}}),ND=Tr(ID).addUtility($D).build(),Vp=class extends jt{constructor(e,n,o){super(e,n),this.downloadRequest$=$n(),this.config=o}buildCapability(){return{saveAsCopy:()=>this.saveAsCopy(),download:()=>this.download(),forDocument:e=>this.createExportScope(e)}}createExportScope(e){return{saveAsCopy:()=>this.saveAsCopy(e),download:()=>this.download(e)}}download(e){const n=e??this.getActiveDocumentId();this.downloadRequest$.emit({documentId:n})}saveAsCopy(e){const n=e??this.getActiveDocumentId(),o=this.coreState.core.documents[n];return o!=null&&o.document?this.engine.saveAsCopy(o.document):Ue.reject({code:ve.DocNotOpen,message:`Document ${n} not found`})}saveAsCopyAndGetBufferAndName(e){const n=new Ie,o=this.coreState.core.documents[e];return o!=null&&o.document?(this.saveAsCopy(e).wait(r=>{n.resolve({buffer:r,name:o.name??this.config.defaultFileName})},r=>n.fail(r)),n):Ue.reject({code:ve.DocNotOpen,message:`Document ${e} not found`})}onRequest(e){return this.downloadRequest$.on(e)}async initialize(e){this.logger.info("ExportPlugin","Initialize","Export plugin initialized")}async destroy(){this.downloadRequest$.clear(),await super.destroy()}};Vp.id="export";let Hs=Vp;const Yp="export",jD={manifest:{id:Yp,name:"Export Plugin",version:"1.0.0",provides:["export"],requires:[],optional:[],defaultConfig:{defaultFileName:"document.pdf"}},create:(t,e)=>new Hs(Yp,t,e),reducer:()=>{},initialState:{}},UD=()=>Nn(Hs.id),qp=()=>It(Hs.id),BD=ie({__name:"download",setup(t){const{provides:e}=qp(),{plugin:n}=UD(),o=Q(null);let r=null;return Lo(()=>{const a=e.value,i=n.value;!a||!i||(r=i.onRequest(s=>{const l=o.value;if(!l)return;i.saveAsCopyAndGetBufferAndName(s.documentId).wait(({buffer:u,name:d})=>{const p=URL.createObjectURL(new Blob([u]));l.href=p,l.download=d,l.click(),URL.revokeObjectURL(p)},Yt)}))}),$o(()=>{r&&r()}),(a,i)=>(v(),C("a",{ref_key:"anchorRef",ref:o,style:{display:"none"}},null,512))}}),zD=Tr(jD).addUtility(BD).build(),Kp="history",WD={id:Kp,name:"History Plugin",version:"1.0.0",provides:["history"],requires:[],optional:[],defaultConfig:{}},Xp="HISTORY/INIT_STATE",Zp="HISTORY/CLEANUP_STATE",Qp="HISTORY/SET_DOCUMENT_STATE",HD="HISTORY/SET_ACTIVE_DOCUMENT",VD=t=>({type:Xp,payload:{documentId:t}}),YD=t=>({type:Zp,payload:{documentId:t}}),qD=(t,e)=>({type:Qp,payload:{documentId:t,state:e}}),Jp=class extends jt{constructor(e,n){super(e,n),this.documentHistories=new Map,this.historyChange$=$n()}async initialize(e){this.logger.info("HistoryPlugin","Initialize","History plugin initialized")}onDocumentLoadingStarted(e){this.dispatch(VD(e)),this.documentHistories.set(e,{topicHistories:new Map,globalTimeline:[],globalIndex:-1}),this.logger.debug("HistoryPlugin","DocumentOpened",`Initialized history state for document: ${e}`)}onDocumentClosed(e){this.dispatch(YD(e)),this.documentHistories.delete(e),this.logger.debug("HistoryPlugin","DocumentClosed",`Cleaned up history state for document: ${e}`)}getDocumentHistoryData(e){const n=e??this.getActiveDocumentId(),o=this.documentHistories.get(n);if(!o)throw new Error(`History data not found for document: ${n}`);return o}getDocumentHistoryState(e){const n=this.documentHistories.get(e);if(!n)throw new Error(`History data not found for document: ${e}`);const o={};return Array.from(n.topicHistories.entries()).forEach(([r,a])=>{o[r]={canUndo:a.currentIndex>-1,canRedo:a.currentIndex<a.commands.length-1}}),{global:{canUndo:n.globalIndex>-1,canRedo:n.globalIndex<n.globalTimeline.length-1},topics:o}}emitHistoryChange(e,n){const o=this.getDocumentHistoryState(e);this.dispatch(qD(e,o)),this.historyChange$.emit({documentId:e,topic:n,state:o})}register(e,n,o){const r=this.getDocumentHistoryData(o);r.topicHistories.has(n)||r.topicHistories.set(n,{commands:[],currentIndex:-1});const a=r.topicHistories.get(n);a.commands.splice(a.currentIndex+1),a.commands.push(e),a.currentIndex++;const i={command:e,topic:n};r.globalTimeline.splice(r.globalIndex+1),r.globalTimeline.push(i),r.globalIndex++,e.execute(),this.emitHistoryChange(o,n)}undo(e,n){const o=this.getDocumentHistoryData(n);let r;if(e){const a=o.topicHistories.get(e);a&&a.currentIndex>-1&&(a.commands[a.currentIndex].undo(),a.currentIndex--,r=e)}else if(o.globalIndex>-1){const a=o.globalTimeline[o.globalIndex];a.command.undo(),o.topicHistories.get(a.topic).currentIndex--,o.globalIndex--,r=a.topic}r&&this.emitHistoryChange(n,r)}redo(e,n){const o=this.getDocumentHistoryData(n);let r;if(e){const a=o.topicHistories.get(e);a&&a.currentIndex<a.commands.length-1&&(a.currentIndex++,a.commands[a.currentIndex].execute(),r=e)}else if(o.globalIndex<o.globalTimeline.length-1){o.globalIndex++;const a=o.globalTimeline[o.globalIndex];a.command.execute(),o.topicHistories.get(a.topic).currentIndex++,r=a.topic}r&&this.emitHistoryChange(n,r)}canUndo(e,n){const o=this.getDocumentHistoryData(n);if(e){const r=o.topicHistories.get(e);return!!r&&r.currentIndex>-1}return o.globalIndex>-1}canRedo(e,n){const o=this.getDocumentHistoryData(n);if(e){const r=o.topicHistories.get(e);return!!r&&r.currentIndex<r.commands.length-1}return o.globalIndex<o.globalTimeline.length-1}purgeByMetadata(e,n,o){const r=this.getDocumentHistoryData(o);let a=0;const i=u=>e(u.metadata),s=n?[n]:Array.from(r.topicHistories.keys());for(const u of s){const d=r.topicHistories.get(u);if(!d)continue;const p=[];let h=0;for(let g=0;g<d.commands.length;g++){const f=d.commands[g];i(f)?(g<=d.currentIndex&&h++,a++):p.push(f)}d.commands=p,d.currentIndex=Math.max(-1,d.currentIndex-h)}const l=[];let c=0;for(let u=0;u<r.globalTimeline.length;u++){const d=r.globalTimeline[u];(!n||d.topic===n)&&i(d.command)?u<=r.globalIndex&&c++:l.push(d)}return r.globalTimeline=l,r.globalIndex=Math.max(-1,r.globalIndex-c),a>0&&(this.emitHistoryChange(o,n),this.logger.debug("HistoryPlugin","PurgeByMetadata",`Purged ${a} history entries for document: ${o}${n?`, topic: ${n}`:""}`)),a}createHistoryScope(e){return{register:(n,o)=>this.register(n,o,e),undo:n=>this.undo(n,e),redo:n=>this.redo(n,e),canUndo:n=>this.canUndo(n,e),canRedo:n=>this.canRedo(n,e),getHistoryState:()=>this.getDocumentHistoryState(e),onHistoryChange:n=>this.historyChange$.on(o=>{o.documentId===e&&n(o.topic)}),purgeByMetadata:(n,o)=>this.purgeByMetadata(n,o,e)}}buildCapability(){return{register:(e,n)=>{const o=this.getActiveDocumentId();this.register(e,n,o)},undo:e=>{const n=this.getActiveDocumentId();this.undo(e,n)},redo:e=>{const n=this.getActiveDocumentId();this.redo(e,n)},canUndo:e=>{const n=this.getActiveDocumentId();return this.canUndo(e,n)},canRedo:e=>{const n=this.getActiveDocumentId();return this.canRedo(e,n)},getHistoryState:()=>{const e=this.getActiveDocumentId();return this.getDocumentHistoryState(e)},forDocument:e=>this.createHistoryScope(e),onHistoryChange:this.historyChange$.on,purgeByMetadata:(e,n)=>{const o=this.getActiveDocumentId();return this.purgeByMetadata(e,n,o)}}}async destroy(){this.historyChange$.clear(),this.documentHistories.clear(),super.destroy()}};Jp.id="history";let eh=Jp;const KD={global:{canUndo:!1,canRedo:!1},topics:{}},th={documents:{},activeDocumentId:null},XD={manifest:WD,create:t=>new eh(Kp,t),reducer:(t=th,e)=>{switch(e.type){case Xp:{const{documentId:n}=e.payload;return{...t,documents:{...t.documents,[n]:{...KD}}}}case Zp:{const{documentId:n}=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case Qp:{const{documentId:n,state:o}=e.payload;return t.documents[n]?{...t,documents:{...t.documents,[n]:o}}:t}case HD:return{...t,activeDocumentId:e.payload};default:return t}},initialState:th};var ct=(t=>(t.Redact="redact",t.MarqueeRedact="marqueeRedact",t.RedactSelection="redactSelection",t))(ct||{});const nh="REDACTION/INIT_STATE",oh="REDACTION/CLEANUP_STATE",ZD="REDACTION/SET_ACTIVE_DOCUMENT",rh="START_REDACTION",ah="END_REDACTION",QD="SET_ACTIVE_TYPE",ih="ADD_PENDING",sh="REMOVE_PENDING",lh="UPDATE_PENDING",ch="CLEAR_PENDING",uh="SELECT_PENDING",dh="DESELECT_PENDING";function JD(t,e){return{type:nh,payload:{documentId:t,state:e}}}function eS(t){return{type:oh,payload:t}}const Lr=(t,e)=>({type:ih,payload:{documentId:t,items:e}}),$r=(t,e,n)=>({type:sh,payload:{documentId:t,page:e,id:n}}),Vs=t=>({type:ch,payload:t}),ph=(t,e,n,o)=>({type:lh,payload:{documentId:t,page:e,id:n,patch:o}}),tS=(t,e)=>({type:rh,payload:{documentId:t,mode:e}}),nS=t=>({type:ah,payload:t}),hh=(t,e,n)=>({type:uh,payload:{documentId:t,page:e,id:n}}),gh=t=>({type:dh,payload:t}),fh=t=>Object.values(t).reduce((e,n)=>e+n.length,0),oi={isRedacting:!1,activeType:null,pending:{},pendingCount:0,selected:null},mh={documents:{},activeDocumentId:null},oS=(t=mh,e)=>{switch(e.type){case nh:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case oh:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case ZD:return{...t,activeDocumentId:e.payload};case ih:{const{documentId:n,items:o}=e.payload,r=t.documents[n];if(!r)return t;const a={...r.pending};for(const i of o){const s=a[i.page]??[];s.some(l=>l.id===i.id)||(a[i.page]=s.concat(i))}return{...t,documents:{...t.documents,[n]:{...r,pending:a,pendingCount:fh(a)}}}}case sh:{const{documentId:n,page:o,id:r}=e.payload,a=t.documents[n];if(!a)return t;const s=(a.pending[o]??[]).filter(u=>u.id!==r),l={...a.pending,[o]:s},c=a.selected&&!(a.selected.page===o&&a.selected.id===r);return{...t,documents:{...t.documents,[n]:{...a,pending:l,pendingCount:fh(l),selected:c?a.selected:null}}}}case lh:{const{documentId:n,page:o,id:r,patch:a}=e.payload,i=t.documents[n];if(!i)return t;const l=(i.pending[o]??[]).map(c=>c.id===r?{...c,...a}:c);return{...t,documents:{...t.documents,[n]:{...i,pending:{...i.pending,[o]:l}}}}}case ch:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,pending:{},pendingCount:0,selected:null}}}:t}case uh:{const{documentId:n,page:o,id:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:{...a,selected:{page:o,id:r}}}}:t}case dh:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,selected:null}}}:t}case rh:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isRedacting:!0,activeType:o}}}:t}case ah:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,isRedacting:!1,activeType:null}}}:t}case QD:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,activeType:o}}}:t}default:return t}},Ph=k_({id:"redact",name:"Redact",categories:["annotation","redaction"],matchScore:t=>t.type===M.REDACT?10:0,interaction:{mode:ct.Redact,exclusive:!1,cursor:"crosshair",textSelection:!0,isDraggable:t=>{var e;return t.type!==M.REDACT?!0:!((e=t.segmentRects)!=null&&e.length)},isResizable:t=>{var e;return t.type!==M.REDACT?!0:!((e=t.segmentRects)!=null&&e.length)},isRotatable:!1,lockAspectRatio:!1,isGroupDraggable:!1,isGroupResizable:!1,isGroupRotatable:!1},defaults:{type:M.REDACT,color:"#000000",overlayColor:"#FFFFFF",strokeColor:"#E44234",opacity:1},behavior:{useAppearanceStream:!1}}),rS=[Ph],Fh=class extends jt{constructor(e,n,o){var r,a,i,s;if(super(e,n),this.redactionSelection$=new Map,this.redactionMarquee$=new Map,this.pending$=Be(),this.selected$=Be(),this.state$=Be(),this.events$=Be(),this.documentUnsubscribers=new Map,this.config=o,this.selectionCapability=(r=this.registry.getPlugin("selection"))==null?void 0:r.provides(),this.interactionManagerCapability=(a=this.registry.getPlugin("interaction-manager"))==null?void 0:a.provides(),this.annotationCapability=(i=this.registry.getPlugin("annotation"))==null?void 0:i.provides(),this.historyCapability=(s=this.registry.getPlugin("history"))==null?void 0:s.provides(),this.config.useAnnotationMode?this.annotationCapability?this.useAnnotationMode=!0:(this.logger.warn("RedactionPlugin","ConfigError","useAnnotationMode is enabled but annotation plugin is not available. Falling back to legacy mode."),this.useAnnotationMode=!1):this.useAnnotationMode=!1,this.useAnnotationMode&&this.annotationCapability)for(const l of rS)this.annotationCapability.addTool(l);this.setupRedactionModes(),!this.useAnnotationMode&&this.annotationCapability&&this.logger.info("RedactionPlugin","LegacyMode","Using legacy redaction mode. Set useAnnotationMode: true in config to use annotation-based redactions."),this.setupModeChangeListener()}setupRedactionModes(){this.interactionManagerCapability&&(this.interactionManagerCapability.registerMode({id:ct.Redact,scope:"page",exclusive:!1,cursor:"crosshair"}),this.interactionManagerCapability.registerMode({id:ct.MarqueeRedact,scope:"page",exclusive:!1,cursor:"crosshair"}),this.interactionManagerCapability.registerMode({id:ct.RedactSelection,scope:"page",exclusive:!1}))}setupModeChangeListener(){var e;(e=this.interactionManagerCapability)==null||e.onModeChange(n=>{const o=n.documentId;if(n.activeMode===ct.Redact||n.activeMode===ct.MarqueeRedact||n.activeMode===ct.RedactSelection)this.dispatch(tS(o,n.activeMode));else{const a=this.getDocumentState(o);a!=null&&a.isRedacting&&this.dispatch(nS(o))}})}onDocumentLoadingStarted(e){this.dispatch(JD(e,{...oi})),this.redactionSelection$.set(e,Be()),this.redactionMarquee$.set(e,Be());const n=[];if(this.selectionCapability){const o=this.selectionCapability.forDocument(e),r=o.onSelectionChange(()=>{const c=this.getDocumentState(e);if(!(c!=null&&c.isRedacting))return;const u=o.getFormattedSelection(),d=this.redactionSelection$.get(e);d==null||d.emit(u)}),a=o.onEndSelection(()=>{const c=this.getDocumentState(e);if(!(c!=null&&c.isRedacting)||!this.checkPermission(e,te.ModifyContents))return;const u=o.getFormattedSelection();if(!u.length)return;const d=o.getSelectedText(),p=this.redactionSelection$.get(e);p==null||p.emit([]),o.clear(),d.wait(h=>{const g=h.join(" ");this.createRedactionsFromSelection(e,u,g)},()=>{this.createRedactionsFromSelection(e,u)})}),i=o.onMarqueeChange(c=>{var u;const d=this.getDocumentState(e);d!=null&&d.isRedacting&&((u=this.redactionMarquee$.get(e))==null||u.emit({pageIndex:c.pageIndex,rect:c.rect,modeId:c.modeId}))}),s=o.onMarqueeEnd(c=>{const u=this.getDocumentState(e);if(u!=null&&u.isRedacting&&this.checkPermission(e,te.ModifyContents))if(this.useAnnotationMode)this.createRedactAnnotationFromArea(e,c.pageIndex,c.rect);else{const d=this.config.drawBlackBoxes?"#000000":"transparent",p={id:pt(),kind:"area",page:c.pageIndex,rect:c.rect,source:"legacy",markColor:"#FF0000",redactionColor:d};this.dispatch(Lr(e,[p])),this.selectPending(c.pageIndex,p.id,e)}}),l=o.onEmptySpaceClick(()=>{this.deselectPending(e)});n.push(r,a,i,s,l)}if(this.useAnnotationMode&&this.annotationCapability){const o=this.annotationCapability.forDocument(e),r=o.onAnnotationEvent(i=>{var s;if(i.type==="loaded"){this.syncFromAnnotationLoad(e);return}if(((s=i.annotation)==null?void 0:s.type)!==M.REDACT)return;const l=i.annotation;i.type==="create"?(this.syncFromAnnotationCreate(e,l),this.events$.emit({type:"add",documentId:e,items:[this.annotationToRedactionItem(l)]})):i.type==="update"?(this.logger.debug("RedactionPlugin","AnnotationUpdated",{documentId:e,redactAnno:l,patch:i.patch}),this.syncFromAnnotationUpdate(e,l,i.patch)):i.type==="delete"&&(this.syncFromAnnotationDelete(e,l),this.events$.emit({type:"remove",documentId:e,page:l.pageIndex,id:l.id}))}),a=o.onStateChange(()=>{this.syncSelectionFromAnnotation(e)});n.push(r,a)}this.documentUnsubscribers.set(e,n),this.logger.debug("RedactionPlugin","DocumentOpened",`Initialized redaction state for document: ${e}`)}onDocumentLoaded(e){var n,o,r;(n=this.selectionCapability)==null||n.enableForMode(ct.Redact,{enableSelection:!0,showSelectionRects:!1,enableMarquee:!0,showMarqueeRects:!1},e),(o=this.selectionCapability)==null||o.enableForMode(ct.MarqueeRedact,{enableSelection:!1,enableMarquee:!0,showMarqueeRects:!1},e),(r=this.selectionCapability)==null||r.enableForMode(ct.RedactSelection,{enableSelection:!0,showSelectionRects:!1},e)}onDocumentClosed(e){this.dispatch(eS(e));const n=this.redactionSelection$.get(e);n==null||n.clear(),this.redactionSelection$.delete(e);const o=this.redactionMarquee$.get(e);o==null||o.clear(),this.redactionMarquee$.delete(e);const r=this.documentUnsubscribers.get(e);r&&(r.forEach(a=>a()),this.documentUnsubscribers.delete(e)),this.logger.debug("RedactionPlugin","DocumentClosed",`Cleaned up redaction state for document: ${e}`)}async initialize(e){this.logger.info("RedactionPlugin","Initialize","Redaction plugin initialized")}buildCapability(){return{queueCurrentSelectionAsPending:()=>this.queueCurrentSelectionAsPending(),enableRedact:()=>this.enableRedact(),toggleRedact:()=>this.toggleRedact(),isRedactActive:()=>this.isRedactActive(),endRedact:()=>this.endRedact(),enableMarqueeRedact:()=>this.enableMarqueeRedact(),toggleMarqueeRedact:()=>this.toggleMarqueeRedact(),isMarqueeRedactActive:()=>this.isMarqueeRedactActive(),enableRedactSelection:()=>this.enableRedactSelection(),toggleRedactSelection:()=>this.toggleRedactSelection(),isRedactSelectionActive:()=>this.isRedactSelectionActive(),addPending:e=>this.addPendingItems(e),removePending:(e,n)=>this.removePendingItem(e,n),clearPending:()=>this.clearPendingItems(),commitAllPending:()=>this.commitAllPending(),commitPending:(e,n)=>this.commitPendingOne(e,n),selectPending:(e,n)=>this.selectPending(e,n),getSelectedPending:()=>this.getSelectedPending(),deselectPending:()=>this.deselectPending(),getState:()=>this.getDocumentStateOrThrow(),forDocument:e=>this.createRedactionScope(e),onPendingChange:this.pending$.on,onSelectedChange:this.selected$.on,onRedactionEvent:this.events$.on,onStateChange:this.state$.on}}createRedactionScope(e){return{queueCurrentSelectionAsPending:()=>this.queueCurrentSelectionAsPending(e),enableRedact:()=>this.enableRedact(e),toggleRedact:()=>this.toggleRedact(e),isRedactActive:()=>this.isRedactActive(e),endRedact:()=>this.endRedact(e),enableMarqueeRedact:()=>this.enableMarqueeRedact(e),toggleMarqueeRedact:()=>this.toggleMarqueeRedact(e),isMarqueeRedactActive:()=>this.isMarqueeRedactActive(e),enableRedactSelection:()=>this.enableRedactSelection(e),toggleRedactSelection:()=>this.toggleRedactSelection(e),isRedactSelectionActive:()=>this.isRedactSelectionActive(e),addPending:n=>this.addPendingItems(n,e),removePending:(n,o)=>this.removePendingItem(n,o,e),clearPending:()=>this.clearPendingItems(e),commitAllPending:()=>this.commitAllPending(e),commitPending:(n,o)=>this.commitPendingOne(n,o,e),selectPending:(n,o)=>this.selectPending(n,o,e),getSelectedPending:()=>this.getSelectedPending(e),deselectPending:()=>this.deselectPending(e),getState:()=>this.getDocumentStateOrThrow(e),onPendingChange:n=>this.pending$.on(o=>{o.documentId===e&&n(o.pending)}),onSelectedChange:n=>this.selected$.on(o=>{o.documentId===e&&n(o.selected)}),onRedactionEvent:n=>this.events$.on(o=>{o.documentId===e&&n(o)}),onStateChange:n=>this.state$.on(o=>{o.documentId===e&&n(o.state)})}}getPendingFromAnnotations(e){if(!this.annotationCapability)return{};try{const n=this.annotationCapability.forDocument(e).getState(),o={};for(const r of Object.values(n.byUid))if(r.object.type===M.REDACT){const a=this.annotationToRedactionItem(r.object),i=r.object.pageIndex;(o[i]??(o[i]=[])).push(a)}return o}catch{return{}}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Redaction state not found for document: ${e??"active"}`);return n}isRedactTool(e){return(e==null?void 0:e.id)===Ph.id&&e.defaults.type===M.REDACT}getRedactTool(){var e;const n=(e=this.annotationCapability)==null?void 0:e.getTool("redact");return this.isRedactTool(n)?n:void 0}syncFromAnnotationCreate(e,n){const o=this.annotationToRedactionItem(n);this.dispatch(Lr(e,[o]))}syncFromAnnotationUpdate(e,n,o){if(!("rect"in o)&&!("segmentRects"in o)&&!("strokeColor"in o)&&!("color"in o))return;const r={};o.rect&&(r.rect=o.rect),o.segmentRects&&(r.rects=o.segmentRects),o.strokeColor&&(r.markColor=o.strokeColor),o.color&&(r.redactionColor=o.color),this.logger.debug("RedactionPlugin","AnnotationUpdated",{documentId:e,annotation:n,patch:r}),this.dispatch(ph(e,n.pageIndex,n.id,r))}syncFromAnnotationDelete(e,n){this.dispatch($r(e,n.pageIndex,n.id))}syncFromAnnotationLoad(e){const n=this.getPendingFromAnnotations(e);this.dispatch(Vs(e));for(const[,o]of Object.entries(n))o.length>0&&this.dispatch(Lr(e,o))}syncSelectionFromAnnotation(e){var n;const o=(n=this.annotationCapability)==null?void 0:n.forDocument(e).getState();if(!o)return;const r=o.selectedUids.map(a=>o.byUid[a]).find(a=>(a==null?void 0:a.object.type)===M.REDACT);if(r){const a=r.object;this.dispatch(hh(e,a.pageIndex,a.id))}else{const a=this.getDocumentState(e);a!=null&&a.selected&&this.dispatch(gh(e))}}addPendingItems(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","AddPendingItems",`Cannot add redactions: document ${o} lacks ModifyContents permission`);return}if(this.useAnnotationMode){if(!this.annotationCapability)return;const r=this.annotationCapability.forDocument(o);for(const a of e){const i=this.redactionItemToAnnotation(a);r.createAnnotation(a.page,i)}if(e.length>0){const a=e[e.length-1];r.selectAnnotation(a.page,a.id)}}else this.dispatch(Lr(o,e));this.events$.emit({type:"add",documentId:o,items:e})}removePendingItem(e,n,o){var r;const a=o??this.getActiveDocumentId();this.useAnnotationMode?(r=this.annotationCapability)==null||r.forDocument(a).deleteAnnotation(e,n):this.dispatch($r(a,e,n)),this.events$.emit({type:"remove",documentId:a,page:e,id:n})}clearPendingItems(e){var n;const o=e??this.getActiveDocumentId();if(this.useAnnotationMode){const r=this.getPendingFromAnnotations(o),a=(n=this.annotationCapability)==null?void 0:n.forDocument(o);for(const[i,s]of Object.entries(r)){const l=Number(i);for(const c of s)a==null||a.deleteAnnotation(l,c.id)}}else this.dispatch(Vs(o));this.events$.emit({type:"clear",documentId:o})}selectPending(e,n,o){var r,a,i;const s=o??this.getActiveDocumentId();this.useAnnotationMode?(r=this.annotationCapability)==null||r.forDocument(s).selectAnnotation(e,n):(this.dispatch(hh(s,e,n)),(a=this.interactionManagerCapability)==null||a.claimPageActivity(s,"redaction-selection",e)),(i=this.selectionCapability)==null||i.forDocument(s).clear()}getSelectedPending(e){var n;const o=e??this.getActiveDocumentId();return((n=this.getDocumentState(o))==null?void 0:n.selected)??null}deselectPending(e){var n,o;const r=e??this.getActiveDocumentId();this.useAnnotationMode?(n=this.annotationCapability)==null||n.forDocument(r).deselectAnnotation():(this.dispatch(gh(r)),(o=this.interactionManagerCapability)==null||o.releasePageActivity(r,"redaction-selection"))}enableRedactSelection(e){var n;const o=e??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","EnableRedactSelection",`Cannot enable redact selection: document ${o} lacks ModifyContents permission`);return}(n=this.interactionManagerCapability)==null||n.forDocument(o).activate(ct.RedactSelection)}toggleRedactSelection(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o);if((r==null?void 0:r.getActiveMode())===ct.RedactSelection)r==null||r.activateDefaultMode();else{if(!this.checkPermission(o,te.ModifyContents))return;r==null||r.activate(ct.RedactSelection)}}isRedactSelectionActive(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o).getActiveMode();return r===ct.Redact||r===ct.RedactSelection}enableMarqueeRedact(e){var n;const o=e??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","EnableMarqueeRedact",`Cannot enable marquee redact: document ${o} lacks ModifyContents permission`);return}(n=this.interactionManagerCapability)==null||n.forDocument(o).activate(ct.MarqueeRedact)}toggleMarqueeRedact(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o);if((r==null?void 0:r.getActiveMode())===ct.MarqueeRedact)r==null||r.activateDefaultMode();else{if(!this.checkPermission(o,te.ModifyContents))return;r==null||r.activate(ct.MarqueeRedact)}}isMarqueeRedactActive(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o).getActiveMode();return r===ct.Redact||r===ct.MarqueeRedact}enableRedact(e){var n;const o=e??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","EnableRedact",`Cannot enable redact mode: document ${o} lacks ModifyContents permission`);return}(n=this.interactionManagerCapability)==null||n.forDocument(o).activate(ct.Redact)}toggleRedact(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o);if((r==null?void 0:r.getActiveMode())===ct.Redact)r==null||r.activateDefaultMode();else{if(!this.checkPermission(o,te.ModifyContents))return;r==null||r.activate(ct.Redact)}}isRedactActive(e){var n;const o=e??this.getActiveDocumentId();return((n=this.interactionManagerCapability)==null?void 0:n.forDocument(o).getActiveMode())===ct.Redact}endRedact(e){var n;const o=e??this.getActiveDocumentId();(n=this.interactionManagerCapability)==null||n.forDocument(o).activateDefaultMode()}onRedactionSelectionChange(e,n){const o=this.redactionSelection$.get(e);return(o==null?void 0:o.on(n))??(()=>{})}onRedactionMarqueeChange(e,n){const o=this.redactionMarquee$.get(e);return(o==null?void 0:o.on(n))??(()=>{})}getPreviewStrokeColor(){var e;return this.useAnnotationMode?((e=this.getRedactTool())==null?void 0:e.defaults.strokeColor)??"#FF0000":"#FF0000"}queueCurrentSelectionAsPending(e){const n=e??this.getActiveDocumentId();if(!this.selectionCapability)return Ue.reject({code:ve.NotFound,message:"[RedactionPlugin] selection plugin required"});const o=this.coreState.core.documents[n];if(!(o!=null&&o.document))return Ue.reject({code:ve.NotFound,message:"Document not found"});const r=this.selectionCapability.forDocument(n),a=r.getFormattedSelection();if(!a.length)return Ue.resolve(!0);const i=r.getSelectedText(),s=this.redactionSelection$.get(n);s==null||s.emit([]),r.clear(),this.useAnnotationMode||this.enableRedactSelection(n);const l=new Ie;return i.wait(c=>{const u=c.join(" ");this.createRedactionsFromSelection(n,a,u),l.resolve(!0)},()=>{this.createRedactionsFromSelection(n,a),l.resolve(!0)}),l}commitPendingOne(e,n,o){const r=o??this.getActiveDocumentId();if(!this.checkPermission(r,te.ModifyContents))return this.logger.debug("RedactionPlugin","CommitPendingOne",`Cannot commit redaction: document ${r} lacks ModifyContents permission`),Ue.reject({code:ve.Security,message:"Document lacks ModifyContents permission"});const a=this.coreState.core.documents[r];if(!(a!=null&&a.document))return Ue.reject({code:ve.NotFound,message:"Document not found"});const i=a.document.pages[e];if(!i)return Ue.reject({code:ve.NotFound,message:"Page not found"});if(this.useAnnotationMode)return this.logger.debug("RedactionPlugin","CommitPendingOne",`Applying redaction in annotation mode: page ${e}, id ${n}`),this.applyRedactionAnnotationMode(r,a.document,i,n);const s=this.getDocumentState(r);if(!s)return Ue.reject({code:ve.NotFound,message:"Document state not found"});const l=(s.pending[e]??[]).find(c=>c.id===n);return l?this.commitPendingOneLegacy(r,a.document,i,e,l):(this.logger.debug("RedactionPlugin","CommitPendingOne",`No pending item found for page ${e}, id ${n}`),Ue.resolve(!0))}commitPendingOneLegacy(e,n,o,r,a){const i=a.kind==="text"?a.rects:[a.rect],s=new Ie;return this.engine.redactTextInRects(n,o,i,{drawBlackBoxes:this.config.drawBlackBoxes}).wait(()=>{this.dispatch($r(e,r,a.id)),this.dispatchCoreAction($a(e,[r])),this.events$.emit({type:"commit",documentId:e,success:!0}),s.resolve(!0)},l=>{this.events$.emit({type:"commit",documentId:e,success:!1,error:l.reason}),s.reject({code:ve.Unknown,message:"Failed to commit redactions"})}),s}applyRedactionAnnotationMode(e,n,o,r){var a;const i=new Ie,s=(a=this.annotationCapability)==null?void 0:a.forDocument(e).getAnnotationById(r);return this.logger.debug("RedactionPlugin","ApplyRedactionAnnotationMode",`Looking for annotation ${r}, found: ${!!s}, type: ${s==null?void 0:s.object.type}`),!s||s.object.type!==M.REDACT?(this.logger.warn("RedactionPlugin","ApplyRedactionAnnotationMode",`Redaction annotation not found or wrong type: ${r}`),Ue.reject({code:ve.NotFound,message:"Redaction annotation not found"})):(this.logger.debug("RedactionPlugin","ApplyRedactionAnnotationMode",`Calling engine.applyRedaction for annotation ${r} on page ${o.index}`),this.engine.applyRedaction(n,o,s.object).wait(()=>{var l,c;this.logger.debug("RedactionPlugin","ApplyRedactionAnnotationMode",`Successfully applied redaction ${r} on page ${o.index}`),(l=this.annotationCapability)==null||l.forDocument(e).purgeAnnotation(o.index,r),this.dispatch($r(e,o.index,r)),(c=this.historyCapability)==null||c.forDocument(e).purgeByMetadata(u=>{var d;return((d=u==null?void 0:u.annotationIds)==null?void 0:d.includes(r))??!1},"annotations"),this.dispatchCoreAction($a(e,[o.index])),this.events$.emit({type:"commit",documentId:e,success:!0}),i.resolve(!0)},l=>{var c;this.logger.error("RedactionPlugin","ApplyRedactionAnnotationMode",`Failed to apply redaction ${r}: ${((c=l.reason)==null?void 0:c.message)??"Unknown error"}`),this.events$.emit({type:"commit",documentId:e,success:!1,error:l.reason}),i.reject({code:ve.Unknown,message:"Failed to apply redaction"})}),i)}commitAllPending(e){const n=e??this.getActiveDocumentId();if(!this.checkPermission(n,te.ModifyContents))return this.logger.debug("RedactionPlugin","CommitAllPending",`Cannot commit redactions: document ${n} lacks ModifyContents permission`),Ue.reject({code:ve.Security,message:"Document lacks ModifyContents permission"});const o=this.coreState.core.documents[n];if(!(o!=null&&o.document))return Ue.reject({code:ve.NotFound,message:"Document not found"});const r=this.getDocumentState(n);return r?this.useAnnotationMode?this.applyAllRedactionsAnnotationMode(n,o.document):this.commitAllPendingLegacy(n,o.document,r):Ue.reject({code:ve.NotFound,message:"Document state not found"})}commitAllPendingLegacy(e,n,o){const r=new Map;for(const[l,c]of Object.entries(o.pending)){const u=Number(l),d=r.get(u)??[];for(const p of c)p.kind==="text"?d.push(...p.rects):d.push(p.rect);r.set(u,d)}const a=Array.from(r.entries()).filter(([l,c])=>c.length>0).map(([l])=>l),i=[];for(const[l,c]of r){const u=n.pages[l];u&&c.length&&i.push(this.engine.redactTextInRects(n,u,c,{drawBlackBoxes:this.config.drawBlackBoxes}))}const s=new Ie;return Ie.all(i).wait(()=>{this.dispatch(Vs(e)),this.dispatchCoreAction($a(e,a)),this.events$.emit({type:"commit",documentId:e,success:!0}),s.resolve(!0)},l=>{this.events$.emit({type:"commit",documentId:e,success:!1,error:l.reason}),s.reject({code:ve.Unknown,message:"Failed to commit redactions"})}),s}applyAllRedactionsAnnotationMode(e,n){const o=this.annotationCapability;if(!o)return Ue.reject({code:ve.NotFound,message:"Annotation capability not found"});const r=o.forDocument(e).getState(),a=new Map;for(const c of Object.values(r.byUid))if(c.object.type===M.REDACT){const u=a.get(c.object.pageIndex)??[];u.push(c.object.id),a.set(c.object.pageIndex,u)}const i=Array.from(a.keys());if(i.length===0)return Ue.resolve(!0);const s=[];for(const c of i){const u=n.pages[c];u&&s.push(this.engine.applyAllRedactions(n,u))}const l=new Ie;return Ie.all(s).wait(()=>{var c;const u=o.forDocument(e),d=[];for(const[p,h]of a)for(const g of h)u.purgeAnnotation(p,g),this.dispatch($r(e,p,g)),d.push(g);d.length>0&&((c=this.historyCapability)==null||c.forDocument(e).purgeByMetadata(p=>{var h;return((h=p==null?void 0:p.annotationIds)==null?void 0:h.some(g=>d.includes(g)))??!1},"annotations")),this.dispatchCoreAction($a(e,i)),this.events$.emit({type:"commit",documentId:e,success:!0}),l.resolve(!0)},c=>{this.events$.emit({type:"commit",documentId:e,success:!1,error:c.reason}),l.reject({code:ve.Unknown,message:"Failed to apply redactions"})}),l}createRedactAnnotationsFromSelection(e,n,o){var r;if(!this.annotationCapability)return[];const a=this.annotationCapability.forDocument(e),i=(r=this.getRedactTool())==null?void 0:r.defaults,s=[];for(const l of n){const c=pt();s.push(c);const u={...i,id:c,type:M.REDACT,pageIndex:l.pageIndex,rect:l.rect,segmentRects:l.segmentRects,...o?{custom:{text:o}}:{},created:new Date};a.createAnnotation(l.pageIndex,u),l===n[n.length-1]&&a.selectAnnotation(l.pageIndex,c)}if(o)for(let l=0;l<s.length;l++){const c=n[l].pageIndex;this.dispatch(ph(e,c,s[l],{text:o}))}return s}createLegacyRedactionsFromSelection(e,n,o){const r=this.config.drawBlackBoxes?"#000000":"transparent",a=n.map(i=>({id:pt(),kind:"text",page:i.pageIndex,rect:i.rect,rects:i.segmentRects,source:"legacy",markColor:"#FF0000",redactionColor:r,text:o}));this.dispatch(Lr(e,a)),a.length&&this.selectPending(a[a.length-1].page,a[a.length-1].id,e)}createRedactionsFromSelection(e,n,o){this.useAnnotationMode?this.createRedactAnnotationsFromSelection(e,n,o):this.createLegacyRedactionsFromSelection(e,n,o)}createRedactAnnotationFromArea(e,n,o){var r;if(!this.annotationCapability)return;const a=this.annotationCapability.forDocument(e),i=(r=this.getRedactTool())==null?void 0:r.defaults,s=pt(),l={...i,id:s,type:M.REDACT,pageIndex:n,rect:o,segmentRects:[],created:new Date};a.createAnnotation(n,l),a.selectAnnotation(n,s)}redactionItemToAnnotation(e){var n;return{...((n=this.getRedactTool())==null?void 0:n.defaults)??{},id:e.id,type:M.REDACT,pageIndex:e.page,rect:e.rect,segmentRects:e.kind==="text"?e.rects:[],created:new Date}}annotationToRedactionItem(e){var n;const o=e.strokeColor??"#FF0000",r=e.color??"transparent";return e.segmentRects&&e.segmentRects.length>0?{id:e.id,kind:"text",page:e.pageIndex,rect:e.rect,rects:e.segmentRects,source:"annotation",markColor:o,redactionColor:r,...(n=e.custom)!=null&&n.text?{text:e.custom.text}:{}}:{id:e.id,kind:"area",page:e.pageIndex,rect:e.rect,source:"annotation",markColor:o,redactionColor:r}}emitPendingChange(e){const n=this.getDocumentState(e);n&&this.pending$.emit({documentId:e,pending:n.pending})}emitSelectedChange(e){const n=this.getDocumentState(e);n&&this.selected$.emit({documentId:e,selected:n.selected})}emitStateChange(e){const n=this.getDocumentState(e);n&&this.state$.emit({documentId:e,state:n})}onStoreUpdated(e,n){for(const o in n.documents)n.documents[o]&&(this.emitPendingChange(o),this.emitSelectedChange(o),this.emitStateChange(o))}async destroy(){this.pending$.clear(),this.selected$.clear(),this.state$.clear(),this.events$.clear(),this.redactionSelection$.forEach(e=>e.clear()),this.redactionSelection$.clear(),this.redactionMarquee$.forEach(e=>e.clear()),this.redactionMarquee$.clear(),this.documentUnsubscribers.forEach(e=>{e.forEach(n=>n())}),this.documentUnsubscribers.clear(),await super.destroy()}};Fh.id="redaction";let Ys=Fh;const bh="redaction",aS={manifest:{id:bh,name:"Redaction Plugin",version:"1.0.0",provides:["redaction"],requires:[],optional:["interaction-manager","selection","annotation"],defaultConfig:{drawBlackBoxes:!0}},create:(t,e)=>new Ys(bh,t,e),reducer:oS,initialState:mh},_h=ie({__name:"highlight",props:{color:{default:"#FFFF00"},opacity:{default:1},border:{default:"1px solid red"},rects:{},rect:{},scale:{},onClick:{}},setup(t){const n=t.rect;return(o,r)=>(v(!0),C(pe,null,tt(t.rects,(a,i)=>(v(),C("div",xe({key:i,onPointerdown:r[0]||(r[0]=(...s)=>t.onClick&&t.onClick(...s)),style:{position:"absolute",border:t.border,left:`${(I(n)?a.origin.x-I(n).origin.x:a.origin.x)*t.scale}px`,top:`${(I(n)?a.origin.y-I(n).origin.y:a.origin.y)*t.scale}px`,width:`${a.size.width*t.scale}px`,height:`${a.size.height*t.scale}px`,background:t.color,opacity:t.opacity,pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:void 0}},{ref_for:!0},o.$attrs),null,16))),128))}}),yh=()=>Nn(Ys.id),vh=()=>It(Ys.id),Dh=ie({__name:"marquee-redact",props:{documentId:{},pageIndex:{},scale:{},className:{},stroke:{default:"red"},fill:{default:"transparent"}},setup(t){const e=t,{plugin:n}=yh(),o=Dn(()=>e.documentId),r=Q(null),a=P(()=>{var s;return e.scale!==void 0?e.scale:((s=o.value)==null?void 0:s.scale)??1}),i=P(()=>{var s;return e.stroke??((s=n.value)==null?void 0:s.getPreviewStrokeColor())??"red"});return Se([n,()=>e.documentId,()=>e.pageIndex],([s,l,c],u,d)=>{if(!s||!l)return;const p=s.onRedactionMarqueeChange(l,h=>{r.value=h.pageIndex===c?h.rect:null});d(p)},{immediate:!0}),(s,l)=>r.value?(v(),C("div",{key:0,style:Z({position:"absolute",pointerEvents:"none",left:`${r.value.origin.x*a.value}px`,top:`${r.value.origin.y*a.value}px`,width:`${r.value.size.width*a.value}px`,height:`${r.value.size.height*a.value}px`,border:`1px solid ${i.value}`,background:t.fill,boxSizing:"border-box"}),class:St(t.className)},null,6)):ae("",!0)}}),iS={key:0,style:{mixBlendMode:"normal",pointerEvents:"none",position:"absolute",inset:0}},Sh=ie({__name:"selection-redact",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{plugin:n}=yh(),o=Q([]),r=Q(null),a=P(()=>{var i;return((i=n.value)==null?void 0:i.getPreviewStrokeColor())??"red"});return Se([n,()=>e.documentId,()=>e.pageIndex],([i,s,l],c,u)=>{if(!i){o.value=[],r.value=null;return}const d=i.onRedactionSelectionChange(s,p=>{const h=p.find(g=>g.pageIndex===l);o.value=(h==null?void 0:h.segmentRects)??[],r.value=(h==null?void 0:h.rect)??null});u(d)},{immediate:!0}),(i,s)=>r.value?(v(),C("div",iS,[je(_h,{color:"transparent",opacity:1,rects:o.value,scale:t.scale,border:`1px solid ${a.value}`},null,8,["rects","scale","border"])])):ae("",!0)}}),sS={key:0,style:{position:"absolute",inset:0,pointerEvents:"none"}},lS=["onPointerdown"],Eh=ie({__name:"pending-redactions",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:Er.Degree0},bboxStroke:{default:"rgba(0,0,0,0.8)"},selectionMenu:{}},setup(t){const e=t,n=ma(),{provides:o}=vh(),r=Q([]),a=Q(null);Se([o,()=>e.documentId,()=>e.pageIndex],([d,p,h],g,f)=>{if(!d){r.value=[],a.value=null;return}const F=d.forDocument(p),_=F.getState();r.value=(_.pending[h]??[]).filter(A=>A.source==="legacy"),a.value=_.selected&&_.selected.page===h?_.selected.id:null;const y=F.onPendingChange(A=>{r.value=(A[h]??[]).filter(T=>T.source==="legacy")}),E=F.onSelectedChange(A=>{a.value=A&&A.page===h?A.id:null});f(()=>{y==null||y(),E==null||E()})},{immediate:!0});const i=(d,p)=>{d.stopPropagation();const h=o.value;h&&h.forDocument(e.documentId).selectPending(e.pageIndex,p)},s=d=>a.value===d&&(!!e.selectionMenu||!!n["selection-menu"]),l=d=>({type:"redaction",item:d,pageIndex:e.pageIndex}),c={suggestTop:!1,spaceAbove:0,spaceBelow:0},u=(d,p,h)=>e.selectionMenu?e.selectionMenu({rect:p,menuWrapperProps:h,selected:a.value===d.id,placement:c,context:l(d)}):null;return(d,p)=>r.value.length?(v(),C("div",sS,[(v(!0),C(pe,null,tt(r.value,h=>(v(),C(pe,{key:h.id},[h.kind==="area"?(v(),C(pe,{key:0},[m("div",{style:Z({position:"absolute",left:`${h.rect.origin.x*t.scale}px`,top:`${h.rect.origin.y*t.scale}px`,width:`${h.rect.size.width*t.scale}px`,height:`${h.rect.size.height*t.scale}px`,background:"transparent",outline:a.value===h.id?`1px solid ${t.bboxStroke}`:"none",outlineOffset:"2px",border:"1px solid red",pointerEvents:"auto",cursor:"pointer"}),onPointerdown:g=>i(g,h.id)},null,44,lS),s(h.id)?(v(),he(I(Ir),{key:0,rect:{origin:{x:h.rect.origin.x*t.scale,y:h.rect.origin.y*t.scale},size:{width:h.rect.size.width*t.scale,height:h.rect.size.height*t.scale}},rotation:t.rotation},{default:We(({rect:g,menuWrapperProps:f})=>[t.selectionMenu?(v(),he(Fn(u(h,g,f)),{key:0})):$e(d.$slots,"selection-menu",{key:1,context:l(h),selected:a.value===h.id,rect:g,placement:c,menuWrapperProps:f})]),_:2},1032,["rect","rotation"])):ae("",!0)],64)):(v(),C(pe,{key:1},[m("div",{style:Z({position:"absolute",left:`${h.rect.origin.x*t.scale}px`,top:`${h.rect.origin.y*t.scale}px`,width:`${h.rect.size.width*t.scale}px`,height:`${h.rect.size.height*t.scale}px`,background:"transparent",outline:a.value===h.id?`1px solid ${t.bboxStroke}`:"none",outlineOffset:"2px",pointerEvents:"auto",cursor:a.value===h.id?"pointer":"default"})},[je(_h,{rect:h.rect,rects:h.rects,color:"transparent",border:"1px solid red",scale:t.scale,"on-click":g=>i(g,h.id)},null,8,["rect","rects","scale","on-click"])],4),s(h.id)?(v(),he(I(Ir),{key:0,rect:{origin:{x:h.rect.origin.x*t.scale,y:h.rect.origin.y*t.scale},size:{width:h.rect.size.width*t.scale,height:h.rect.size.height*t.scale}},rotation:t.rotation},{default:We(({rect:g,menuWrapperProps:f})=>[t.selectionMenu?(v(),he(Fn(u(h,g,f)),{key:0})):$e(d.$slots,"selection-menu",{key:1,context:l(h),selected:a.value===h.id,rect:g,placement:c,menuWrapperProps:f})]),_:2},1032,["rect","rotation"])):ae("",!0)],64))],64))),128))])):ae("",!0)}}),cS=ie({__name:"redaction-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{},bboxStroke:{default:"rgba(0,0,0,0.8)"},selectionMenu:{}},setup(t){const e=t,n=Dn(()=>e.documentId),o=P(()=>{var i,s,l;return(l=(s=(i=n.value)==null?void 0:i.document)==null?void 0:s.pages)==null?void 0:l[e.pageIndex]}),r=P(()=>{var i;return e.scale!==void 0?e.scale:((i=n.value)==null?void 0:i.scale)??1}),a=P(()=>{var i,s;if(e.rotation!==void 0)return e.rotation;const l=((i=o.value)==null?void 0:i.rotation)??0,c=((s=n.value)==null?void 0:s.rotation)??0;return(l+c)%4});return(i,s)=>(v(),C(pe,null,[je(Eh,{"document-id":t.documentId,"page-index":t.pageIndex,scale:r.value,rotation:a.value,"bbox-stroke":t.bboxStroke,"selection-menu":t.selectionMenu},{"selection-menu":We(l=>[$e(i.$slots,"selection-menu",zt(Qt(l)))]),_:3},8,["document-id","page-index","scale","rotation","bbox-stroke","selection-menu"]),je(Dh,{"document-id":t.documentId,"page-index":t.pageIndex,scale:r.value},null,8,["document-id","page-index","scale"]),je(Sh,{"document-id":t.documentId,"page-index":t.pageIndex,scale:r.value},null,8,["document-id","page-index","scale"])],64))}}),uS=ie({__name:"redact-highlight",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){const e=t,n=Q(!1),o=P(()=>e.annotation.object.segmentRects??[]),r=P(()=>e.annotation.object.rect),a=P(()=>e.annotation.object.strokeColor??"#FF0000"),i=P(()=>e.annotation.object.color??"#000000"),s=P(()=>e.annotation.object.opacity??1),l=P(()=>e.annotation.object.fontColor??e.annotation.object.overlayColor??"#FFFFFF"),c=P(()=>e.annotation.object.overlayText),u=P(()=>e.annotation.object.overlayTextRepeat??!1),d=P(()=>e.annotation.object.fontSize??12),p=P(()=>e.annotation.object.fontFamily??mt.Helvetica),h=P(()=>e.annotation.object.textAlign??Vt.Center),g=P(()=>c.value?u.value?Array(10).fill(c.value).join(" "):c.value:""),f=_=>({position:"absolute",left:`${(r.value?_.origin.x-r.value.origin.x:_.origin.x)*e.scale}px`,top:`${(r.value?_.origin.y-r.value.origin.y:_.origin.y)*e.scale}px`,width:`${_.size.width*e.scale}px`,height:`${_.size.height*e.scale}px`,background:n.value?i.value:"transparent",border:n.value?"none":`2px solid ${a.value}`,opacity:n.value?s.value:1,boxSizing:"border-box",pointerEvents:"auto",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:h.value===Vt.Left?"flex-start":h.value===Vt.Right?"flex-end":"center",overflow:"hidden"}),F=_=>({color:l.value,fontSize:`${Math.min(d.value*e.scale,_.size.height*e.scale*.8)}px`,...ns(p.value),textAlign:es(h.value),whiteSpace:u.value?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1});return(_,y)=>(v(),C("div",{onMouseenter:y[1]||(y[1]=E=>n.value=!0),onMouseleave:y[2]||(y[2]=E=>n.value=!1),style:{position:"absolute",inset:0}},[(v(!0),C(pe,null,tt(o.value,(E,A)=>(v(),C("div",{key:A,onPointerdown:y[0]||(y[0]=(...T)=>t.onClick&&t.onClick(...T)),style:Z(f(E))},[n.value&&c.value?(v(),C("span",{key:0,style:Z(F(E))},fe(g.value),5)):ae("",!0)],36))),128))],32))}}),dS=ie({__name:"redact-area",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){const e=t,n=Q(!1),o=P(()=>e.annotation.object.strokeColor??"#FF0000"),r=P(()=>e.annotation.object.color??"#000000"),a=P(()=>e.annotation.object.opacity??1),i=P(()=>e.annotation.object.fontColor??e.annotation.object.overlayColor??"#FFFFFF"),s=P(()=>e.annotation.object.overlayText),l=P(()=>e.annotation.object.overlayTextRepeat??!1),c=P(()=>e.annotation.object.fontSize??12),u=P(()=>e.annotation.object.fontFamily??mt.Helvetica),d=P(()=>e.annotation.object.textAlign??Vt.Center),p=P(()=>s.value?l.value?Array(10).fill(s.value).join(" "):s.value:""),h=P(()=>({position:"absolute",inset:0,background:n.value?r.value:"transparent",border:n.value?"none":`2px solid ${o.value}`,opacity:n.value?a.value:1,boxSizing:"border-box",pointerEvents:"auto",cursor:e.isSelected?"move":"pointer",display:"flex",alignItems:"center",justifyContent:d.value===Vt.Left?"flex-start":d.value===Vt.Right?"flex-end":"center",overflow:"hidden"})),g=P(()=>({color:i.value,fontSize:`${c.value*e.scale}px`,...ns(u.value),textAlign:es(d.value),whiteSpace:l.value?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis",padding:"4px"}));return(f,F)=>(v(),C("div",{onPointerdown:F[0]||(F[0]=_=>{var y;t.isSelected||(y=t.onClick)==null||y.call(t,_)}),onMouseenter:F[1]||(F[1]=_=>n.value=!0),onMouseleave:F[2]||(F[2]=_=>n.value=!1),style:Z(h.value)},[n.value&&s.value?(v(),C("span",{key:0,style:Z(g.value)},fe(p.value),5)):ae("",!0)],36))}}),pS=[yt({id:"redactHighlight",matches:t=>{var e;return t.type===M.REDACT&&"segmentRects"in t&&(((e=t.segmentRects)==null?void 0:e.length)??0)>0},component:uS,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},useAppearanceStream:!1}),yt({id:"redactArea",matches:t=>{var e;return t.type===M.REDACT&&(!("segmentRects"in t)||!(((e=t.segmentRects)==null?void 0:e.length)??0))},component:dS,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},useAppearanceStream:!1})],Ah=ie({__name:"redact-renderer-registration",setup(t){return cv(pS),(e,n)=>$e(e.$slots,"default")}}),hS=Tr(aS).addUtility(Ah).build(),xh=class extends jt{constructor(e,n,o){super(e,n),this.config=o}buildCapability(){return{renderPage:e=>this.renderPage(e),renderPageRect:e=>this.renderPageRect(e),renderPageRaw:e=>this.renderPageRaw(e),renderPageRectRaw:e=>this.renderPageRectRaw(e),forDocument:e=>this.createRenderScope(e)}}createRenderScope(e){return{renderPage:n=>this.renderPage(n,e),renderPageRect:n=>this.renderPageRect(n,e),renderPageRaw:n=>this.renderPageRaw(n,e),renderPageRectRaw:n=>this.renderPageRectRaw(n,e)}}renderPage({pageIndex:e,options:n},o){const r=o??this.getActiveDocumentId(),a=this.coreState.core.documents[r];if(!(a!=null&&a.document))throw new Error(`Document ${r} not loaded`);const i=a.document.pages.find(l=>l.index===e);if(!i)throw new Error(`Page ${e} not found in document ${r}`);const s={...n??{},withForms:(n==null?void 0:n.withForms)??this.config.withForms??!1,withAnnotations:(n==null?void 0:n.withAnnotations)??this.config.withAnnotations??!1,imageType:(n==null?void 0:n.imageType)??this.config.defaultImageType??"image/png",imageQuality:(n==null?void 0:n.imageQuality)??this.config.defaultImageQuality??.92};return this.engine.renderPage(a.document,i,s)}renderPageRect({pageIndex:e,rect:n,options:o},r){const a=r??this.getActiveDocumentId(),i=this.coreState.core.documents[a];if(!(i!=null&&i.document))throw new Error(`Document ${a} not loaded`);const s=i.document.pages.find(c=>c.index===e);if(!s)throw new Error(`Page ${e} not found in document ${a}`);const l={...o??{},withForms:(o==null?void 0:o.withForms)??this.config.withForms??!1,withAnnotations:(o==null?void 0:o.withAnnotations)??this.config.withAnnotations??!1,imageType:(o==null?void 0:o.imageType)??this.config.defaultImageType??"image/png",imageQuality:(o==null?void 0:o.imageQuality)??this.config.defaultImageQuality??.92};return this.engine.renderPageRect(i.document,s,n,l)}renderPageRaw({pageIndex:e,options:n},o){const r=o??this.getActiveDocumentId(),a=this.coreState.core.documents[r];if(!(a!=null&&a.document))throw new Error(`Document ${r} not loaded`);const i=a.document.pages.find(l=>l.index===e);if(!i)throw new Error(`Page ${e} not found in document ${r}`);const s={...n??{},withForms:(n==null?void 0:n.withForms)??this.config.withForms??!1,withAnnotations:(n==null?void 0:n.withAnnotations)??this.config.withAnnotations??!1};return this.engine.renderPageRaw(a.document,i,s)}renderPageRectRaw({pageIndex:e,rect:n,options:o},r){const a=r??this.getActiveDocumentId(),i=this.coreState.core.documents[a];if(!(i!=null&&i.document))throw new Error(`Document ${a} not loaded`);const s=i.document.pages.find(c=>c.index===e);if(!s)throw new Error(`Page ${e} not found in document ${a}`);const l={...o??{},withForms:(o==null?void 0:o.withForms)??this.config.withForms??!1,withAnnotations:(o==null?void 0:o.withAnnotations)??this.config.withAnnotations??!1};return this.engine.renderPageRectRaw(i.document,s,n,l)}async initialize(e){this.logger.info("RenderPlugin","Initialize","Render plugin initialized")}async destroy(){super.destroy()}};xh.id="render";let Ch=xh;const Th="render",gS={manifest:{id:Th,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{}},create:(t,e)=>new Ch(Th,t,e),reducer:()=>{},initialState:{}};var ro=(t=>(t.Vertical="vertical",t.Horizontal="horizontal",t))(ro||{});class Mh{constructor(e){this.pageGap=e.pageGap??20,this.viewportGap=e.viewportGap??20,this.bufferSize=e.bufferSize??2}getCenteringOffsetX(e,n){return!n||e.width>=n.width?0:(n.width-e.width)/2}getCenteringOffsetY(e,n){return 0}getVisibleRange(e,n,o){const r=this.getScrollOffset(e),a=this.getClientSize(e),i=r,s=r+a;let l=0;for(;l<n.length&&(n[l].offset+this.getItemSizeAlongScrollAxis(n[l]))*o<=i;)l++;let c=l;for(;c<n.length&&n[c].offset*o<=s;)c++;return{start:Math.max(0,l-this.bufferSize),end:Math.min(n.length-1,c+this.bufferSize-1)}}handleScroll(e,n,o){const r=this.getVisibleRange(e,n,o),a=n.slice(r.start,r.end+1),i=this.getTotalContentSize(n),s=this.calculatePageVisibility(a,e,o,i),l=s.map(F=>F.pageNumber),c=n.slice(r.start,r.end+1).flatMap(F=>F.index),u=this.determineCurrentPage(s),d=n[r.start],p=n[r.end],h=d?d.offset*o:0,g=n[n.length-1],f=p?(g.offset+this.getItemSizeAlongScrollAxis(g))*o-(p.offset+this.getItemSizeAlongScrollAxis(p))*o:0;return{currentPage:u,visiblePages:l,pageVisibilityMetrics:s,renderedPageIndexes:c,scrollOffset:{x:e.scrollLeft,y:e.scrollTop},startSpacing:h,endSpacing:f}}calculatePageVisibility(e,n,o,r){const a=[];return e.forEach(i=>{const s=this.getCenteringOffsetX(i,r),l=this.getCenteringOffsetY(i,r);i.pageLayouts.forEach(c=>{const u=(i.x+s)*o,d=(i.y+l)*o,p=u+c.x*o,h=d+c.y*o,g=c.rotatedWidth*o,f=c.rotatedHeight*o,F=n.scrollLeft,_=n.scrollTop,y=F+n.clientWidth,E=_+n.clientHeight,A=Math.max(p,F),T=Math.max(h,_),q=Math.min(p+g,y),w=Math.min(h+f,E);if(A<q&&T<w){const G=q-A,W=w-T,J=g*f,ue=G*W;a.push({pageNumber:c.pageNumber,viewportX:A-F,viewportY:T-_,visiblePercentage:ue/J*100,original:{pageX:(A-p)/o,pageY:(T-h)/o,visibleWidth:G/o,visibleHeight:W/o,scale:1},scaled:{pageX:A-p,pageY:T-h,visibleWidth:G,visibleHeight:W,scale:o}})}})}),a}determineCurrentPage(e){if(e.length===0)return 1;const n=Math.max(...e.map(r=>r.visiblePercentage)),o=e.filter(r=>r.visiblePercentage===n);return o.length===1?o[0].pageNumber:o.sort((r,a)=>r.pageNumber-a.pageNumber)[0].pageNumber}getRectLocationForPage(e,n,o){const r=n.find(l=>l.pageNumbers.includes(e));if(!r)return null;const a=r.pageLayouts.find(l=>l.pageNumber===e);if(!a)return null;const i=this.getCenteringOffsetX(r,o),s=this.getCenteringOffsetY(r,o);return{origin:{x:r.x+a.x+i,y:r.y+a.y+s},size:{width:a.width,height:a.height}}}getScrollPositionForPage(e,n,o,r,a){const i=this.getTotalContentSize(n),s=this.getRectLocationForPage(e,n,i);if(!s)return null;const l=Ta(s.origin,o);if(a){const c=ZP({width:s.size.width,height:s.size.height},{x:a.x,y:a.y},r,o);return{x:l.x+c.x+this.viewportGap,y:l.y+c.y+this.viewportGap}}return{x:l.x+this.viewportGap,y:l.y+this.viewportGap}}getRectPositionForPage(e,n,o,r,a){const i=this.getTotalContentSize(n),s=this.getRectLocationForPage(e,n,i);if(!s)return null;const l=Ta(s.origin,o),c=eF({width:s.size.width,height:s.size.height},a,r,o);return{origin:{x:l.x+c.origin.x,y:l.y+c.origin.y},size:c.size}}}class fS extends Mh{constructor(e){super(e)}createVirtualItems(e){let n=0;return e.map((o,r)=>{let a=0;const i=o.map(u=>{const d={pageNumber:u.index+1,pageIndex:u.index,x:a,y:0,width:u.size.width,height:u.size.height,rotatedWidth:u.rotatedSize.width,rotatedHeight:u.rotatedSize.height,elevated:!1};return a+=u.rotatedSize.width+this.pageGap,d}),s=o.reduce((u,d,p)=>u+d.rotatedSize.width+(p<o.length-1?this.pageGap:0),0),l=Math.max(...o.map(u=>u.rotatedSize.height)),c={id:`item-${r}`,x:0,y:n,offset:n,width:s,height:l,pageLayouts:i,pageNumbers:o.map(u=>u.index+1),index:r};return n+=l+this.pageGap,c})}getTotalContentSize(e){if(e.length===0)return{width:0,height:0};const n=Math.max(...e.map(r=>r.width)),o=e[e.length-1].y+e[e.length-1].height;return{width:n,height:o}}getScrollOffset(e){return e.scrollTop}getClientSize(e){return e.clientHeight}getItemSizeAlongScrollAxis(e){return e.height}}class mS extends Mh{constructor(e){super(e)}createVirtualItems(e){let n=0;return e.map((o,r)=>{let a=0;const i=o.map(u=>{const d={pageNumber:u.index+1,pageIndex:u.index,x:a,y:0,width:u.size.width,height:u.size.height,rotatedWidth:u.rotatedSize.width,rotatedHeight:u.rotatedSize.height,elevated:!1};return a+=u.rotatedSize.width+this.pageGap,d}),s=o.reduce((u,d,p)=>u+d.rotatedSize.width+(p<o.length-1?this.pageGap:0),0),l=Math.max(...o.map(u=>u.rotatedSize.height)),c={id:`item-${r}`,x:n,y:0,offset:n,width:s,height:l,pageLayouts:i,pageNumbers:o.map(u=>u.index+1),index:r};return n+=s+this.pageGap,c})}getTotalContentSize(e){if(e.length===0)return{width:0,height:0};const n=e[e.length-1].x+e[e.length-1].width,o=Math.max(...e.map(r=>r.height));return{width:n,height:o}}getScrollOffset(e){return e.scrollLeft}getClientSize(e){return e.clientWidth}getItemSizeAlongScrollAxis(e){return e.width}getCenteringOffsetX(e,n){return 0}getCenteringOffsetY(e,n){return!n||e.height>=n.height?0:(n.height-e.height)/2}}const Rh="INIT_SCROLL_STATE",wh="CLEANUP_SCROLL_STATE",Oh="UPDATE_DOCUMENT_SCROLL_STATE",kh="SET_SCROLL_STRATEGY";function PS(t,e){return{type:Rh,payload:{documentId:t,state:e}}}function FS(t){return{type:wh,payload:t}}function Nr(t,e){return{type:Oh,payload:{documentId:t,state:e}}}function bS(t,e){return{type:kh,payload:{documentId:t,strategy:e}}}const _S={isChanging:!1,targetPage:1,fromPage:1,startTime:0},yS=(t,e)=>({defaultStrategy:e.defaultStrategy??ro.Vertical,defaultPageGap:e.defaultPageGap??10,defaultBufferSize:e.defaultBufferSize??2,documents:{}}),vS=(t,e)=>{switch(e.type){case Rh:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o}}}case wh:{const{[e.payload]:n,...o}=t.documents;return{...t,documents:o}}case Oh:{const{documentId:n,state:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,...o}}}:t}case kh:{const{documentId:n,strategy:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,strategy:o}}}:t}default:return t}},DS=(t,e,n)=>({startSpacing:t.startSpacing,endSpacing:t.endSpacing,totalWidth:t.totalContentSize.width*e,totalHeight:t.totalContentSize.height*e,pageGap:t.pageGap*e,strategy:t.strategy,items:t.renderedPageIndexes.map(o=>({...t.virtualItems[o],pageLayouts:t.virtualItems[o].pageLayouts.map(r=>({...r,rotatedWidth:r.rotatedWidth*e,rotatedHeight:r.rotatedHeight*e,width:r.width*e,height:r.height*e,elevated:(n==null?void 0:n.has(r.pageIndex))??!1}))}))}),Ih=class extends jt{constructor(e,n,o){var r,a,i;super(e,n),this.id=e,this.config=o,this.elevatedPages=new Map,this.strategies=new Map,this.layoutReady=new Set,this.initialLayoutFired=new Set,this.scrollerLayoutEmitters=new Map,this.pageChange$=Be(),this.scroll$=Be(),this.layoutChange$=Be(),this.pageChangeState$=Be(),this.layoutReady$=Be(),this.state$=Be(),this.viewport=this.registry.getPlugin("viewport").provides(),this.spread=((r=this.registry.getPlugin("spread"))==null?void 0:r.provides())??null,this.viewport.onScrollActivity(l=>{const c=this.getDocumentState(l.documentId);c!=null&&c.pageChangeState.isChanging&&!l.activity.isSmoothScrolling&&this.completePageChange(l.documentId)}),(a=this.spread)==null||a.onSpreadChange(l=>{this.refreshDocumentLayout(l.documentId)});const s=(i=this.registry.getPlugin("interaction-manager"))==null?void 0:i.provides();s&&s.onPageActivityChange(l=>{let c=this.elevatedPages.get(l.documentId);l.hasActivity?(c||(c=new Set,this.elevatedPages.set(l.documentId,c)),c.add(l.pageIndex)):c==null||c.delete(l.pageIndex),this.pushScrollerLayout(l.documentId)}),this.viewport.onViewportChange(l=>{const c=this.getDocumentState(l.documentId);if(!c)return;const u=this.computeMetrics(l.documentId,l.metrics);this.layoutReady.has(l.documentId)?this.commitMetrics(l.documentId,u):this.commitMetrics(l.documentId,{...u,scrollOffset:c.scrollOffset})})}onDocumentLoadingStarted(e){const n=this.getCoreDocument(e);if(!n)return;const o=this.createDocumentState(n);this.dispatch(PS(e,o));const r=this.createStrategy(o.strategy);this.strategies.set(e,r),this.scrollerLayoutEmitters.set(e,Be())}onDocumentLoaded(e){var n;const o=this.getCoreDocument(e);o&&(this.dispatch(Nr(e,{totalPages:((n=o.document)==null?void 0:n.pageCount)??0})),this.refreshDocumentLayout(e),this.logger.debug("ScrollPlugin","DocumentOpened",`Initialized scroll state for document: ${e}`))}onDocumentClosed(e){this.strategies.delete(e),this.layoutReady.delete(e),this.initialLayoutFired.delete(e),this.elevatedPages.delete(e);const n=this.scrollerLayoutEmitters.get(e);n&&(n.clear(),this.scrollerLayoutEmitters.delete(e)),this.dispatch(FS(e)),this.logger.debug("ScrollPlugin","DocumentClosed",`Cleaned up scroll state for document: ${e}`)}onScaleChanged(e){const n=this.coreState.core.documents[e];if(!n||n.status!=="loaded")return;const o=this.viewport.forDocument(e),r=this.computeMetrics(e,o.getMetrics());this.commitMetrics(e,r)}onRotationChanged(e){this.refreshDocumentLayout(e)}onScrollerData(e,n){const o=this.scrollerLayoutEmitters.get(e);if(!o)throw new Error(`No scroller layout emitter found for document: ${e}`);return o.on(n)}getScrollerLayout(e){const n=this.getDocumentState(e),o=this.getCoreDocumentOrThrow(e);if(!n||!o)throw new Error(`Cannot get scroller layout for document: ${e}`);return DS(n,o.scale,this.elevatedPages.get(e))}setLayoutReady(e){if(this.layoutReady.has(e))return;const n=this.getDocumentState(e);if(!n)return;this.layoutReady.add(e);const o=!this.initialLayoutFired.has(e);o&&this.initialLayoutFired.add(e),this.viewport.forDocument(e).scrollTo({...n.scrollOffset,behavior:"instant"}),this.layoutReady$.emit({documentId:e,isInitial:o,pageNumber:n.currentPage,totalPages:n.totalPages})}clearLayoutReady(e){this.layoutReady.delete(e)}buildCapability(){return{getCurrentPage:()=>this.getCurrentPage(),getTotalPages:()=>this.getTotalPages(),getPageChangeState:()=>this.getPageChangeState(),scrollToPage:e=>this.scrollToPage(e),scrollToNextPage:e=>this.scrollToNextPage(e),scrollToPreviousPage:e=>this.scrollToPreviousPage(e),getMetrics:e=>this.getMetrics(e),getLayout:()=>this.getLayout(),getRectPositionForPage:(e,n,o,r)=>this.getRectPositionForPage(e,n,o,r),forDocument:e=>this.createScrollScope(e),setScrollStrategy:(e,n)=>this.setScrollStrategyForDocument(e,n),getPageGap:()=>this.state.defaultPageGap,onPageChange:this.pageChange$.on,onScroll:this.scroll$.on,onLayoutChange:this.layoutChange$.on,onLayoutReady:this.layoutReady$.on,onPageChangeState:this.pageChangeState$.on,onStateChange:this.state$.on}}createScrollScope(e){return{getCurrentPage:()=>this.getCurrentPage(e),getTotalPages:()=>this.getTotalPages(e),getPageChangeState:()=>this.getPageChangeState(e),scrollToPage:n=>this.scrollToPage(n,e),scrollToNextPage:n=>this.scrollToNextPage(n,e),scrollToPreviousPage:n=>this.scrollToPreviousPage(n,e),getSpreadPagesWithRotatedSize:()=>this.getSpreadPagesWithRotatedSize(e),getMetrics:n=>this.getMetrics(n,e),getLayout:()=>this.getLayout(e),getRectPositionForPage:(n,o,r,a)=>this.getRectPositionForPage(n,o,r,a,e),setScrollStrategy:n=>this.setScrollStrategyForDocument(n,e),onPageChange:n=>this.pageChange$.on(o=>{o.documentId===e&&n(o)}),onScroll:n=>this.scroll$.on(o=>{o.documentId===e&&n(o.metrics)}),onLayoutChange:n=>this.layoutChange$.on(o=>{o.documentId===e&&n(o.layout)})}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Scroll state not found for document: ${e??"active"}`);return n}getStrategy(e){const n=e??this.getActiveDocumentId(),o=this.strategies.get(n);if(!o)throw new Error(`Strategy not found for document: ${n}`);return o}createStrategy(e){const n={pageGap:this.state.defaultPageGap,viewportGap:this.viewport.getViewportGap(),bufferSize:this.state.defaultBufferSize};return e===ro.Horizontal?new mS(n):new fS(n)}createDocumentState(e){var n;return{virtualItems:[],totalPages:((n=e.document)==null?void 0:n.pageCount)??0,currentPage:1,totalContentSize:{width:0,height:0},strategy:this.state.defaultStrategy,pageGap:this.state.defaultPageGap,visiblePages:[],pageVisibilityMetrics:[],renderedPageIndexes:[],scrollOffset:{x:0,y:0},startSpacing:0,endSpacing:0,pageChangeState:_S}}startPageChange(e,n,o="smooth"){const r=this.getDocumentState(e);if(!r)return;const a={isChanging:!0,targetPage:n,fromPage:r.currentPage,startTime:Date.now()};this.dispatch(Nr(e,{pageChangeState:a,currentPage:n})),this.pageChange$.emit({documentId:e,pageNumber:n,totalPages:r.totalPages}),o==="instant"&&this.completePageChange(e)}completePageChange(e){const n=this.getDocumentState(e);if(!n||!n.pageChangeState.isChanging)return;const o={isChanging:!1,targetPage:n.pageChangeState.targetPage,fromPage:n.pageChangeState.fromPage,startTime:n.pageChangeState.startTime};this.dispatch(Nr(e,{pageChangeState:o}))}computeLayout(e,n){const o=this.getStrategy(e),r=o.createVirtualItems(n),a=o.getTotalContentSize(r);return{virtualItems:r,totalContentSize:a}}computeMetrics(e,n,o){const r=this.getCoreDocumentOrThrow(e),a=this.getDocumentState(e),i=this.getStrategy(e);if(!a)throw new Error(`Document state not found: ${e}`);return i.handleScroll(n,o??a.virtualItems,r.scale)}commitMetrics(e,n){const o=this.getDocumentState(e);if(!o)return;const r=o.pageChangeState.isChanging,a=r&&n.currentPage!==o.currentPage?{...n,currentPage:o.currentPage}:n;this.dispatch(Nr(e,a)),this.scroll$.emit({documentId:e,metrics:a}),!r&&n.currentPage!==o.currentPage&&this.pageChange$.emit({documentId:e,pageNumber:n.currentPage,totalPages:o.totalPages}),this.pushScrollerLayout(e)}pushScrollerLayout(e){const n=this.scrollerLayoutEmitters.get(e);if(n)try{const o=this.getScrollerLayout(e);n.emit(o)}catch{}}refreshDocumentLayout(e){const n=this.coreState.core.documents[e],o=this.getDocumentState(e);if(!n||!o||n.status!=="loaded")return;const r=this.getSpreadPagesWithRotatedSize(e),a=this.computeLayout(e,r),i=this.viewport.forDocument(e),s=this.computeMetrics(e,i.getMetrics(),a.virtualItems);this.dispatch(Nr(e,{...a,...s})),this.layoutChange$.emit({documentId:e,layout:a}),this.pushScrollerLayout(e)}getSpreadPagesWithRotatedSize(e){var n,o;const r=e??this.getActiveDocumentId(),a=this.coreState.core.documents[r];if(!a)throw new Error(`Document ${r} not loaded`);return(((n=this.spread)==null?void 0:n.forDocument(r).getSpreadPages())||((o=a.document)==null?void 0:o.pages.map(s=>[s]))||[]).map(s=>s.map(l=>{const c=((l.rotation??0)+a.rotation)%4;return{...l,rotatedSize:Ca(l.size,c,1)}}))}getCurrentPage(e){return this.getDocumentStateOrThrow(e).currentPage}getTotalPages(e){return this.getDocumentStateOrThrow(e).totalPages}getPageChangeState(e){return this.getDocumentStateOrThrow(e).pageChangeState}scrollToPage(e,n){var o;const r=n??this.getActiveDocumentId(),a=this.getDocumentStateOrThrow(r),i=this.getStrategy(r),s=this.getCoreDocumentOrThrow(r),{pageNumber:l,behavior:c="smooth",pageCoordinates:u,alignX:d,alignY:p}=e;this.startPageChange(r,l,c);const h=(o=s.document)==null?void 0:o.pages[l-1],g=(((h==null?void 0:h.rotation)??0)+s.rotation)%4,f=i.getScrollPositionForPage(l,a.virtualItems,s.scale,g,u);f?this.viewport.forDocument(r).scrollTo({...f,behavior:c,alignX:d,alignY:p}):this.completePageChange(r)}scrollToNextPage(e="smooth",n){const o=n??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(o),a=this.getStrategy(o),i=this.getCoreDocumentOrThrow(o),s=r.virtualItems.findIndex(l=>l.pageNumbers.includes(r.currentPage));if(s>=0&&s<r.virtualItems.length-1){const c=r.virtualItems[s+1].pageNumbers[0];this.startPageChange(o,c,e);const u=a.getScrollPositionForPage(c,r.virtualItems,i.scale,i.rotation);u?this.viewport.forDocument(o).scrollTo({...u,behavior:e}):this.completePageChange(o)}}scrollToPreviousPage(e="smooth",n){const o=n??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(o),a=this.getStrategy(o),i=this.coreState.core.documents[o],s=r.virtualItems.findIndex(l=>l.pageNumbers.includes(r.currentPage));if(s>0){const c=r.virtualItems[s-1].pageNumbers[0];this.startPageChange(o,c,e);const u=a.getScrollPositionForPage(c,r.virtualItems,i.scale,i.rotation);u?this.viewport.forDocument(o).scrollTo({...u,behavior:e}):this.completePageChange(o)}}getMetrics(e,n){const o=n??this.getActiveDocumentId();if(e)return this.computeMetrics(o,e);const r=this.viewport.forDocument(o);return this.computeMetrics(o,r.getMetrics())}getLayout(e){const n=this.getDocumentStateOrThrow(e);return{virtualItems:n.virtualItems,totalContentSize:n.totalContentSize}}getRectPositionForPage(e,n,o,r,a){var i;const s=a??this.getActiveDocumentId(),l=this.getDocumentStateOrThrow(s),c=this.getStrategy(s),u=this.getCoreDocumentOrThrow(s);let d=r;if(d===void 0){const p=(i=u.document)==null?void 0:i.pages[e];d=(((p==null?void 0:p.rotation)??0)+u.rotation)%4}return c.getRectPositionForPage(e+1,l.virtualItems,o??u.scale,d,n)}setScrollStrategyForDocument(e,n){const o=n??this.getActiveDocumentId(),r=this.getDocumentState(o);if(!r||r.strategy===e)return;const a=this.createStrategy(e);this.strategies.set(o,a),this.dispatch(bS(o,e)),this.refreshDocumentLayout(o)}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&(this.state$.emit(a),(r==null?void 0:r.pageChangeState)!==a.pageChangeState&&this.pageChangeState$.emit({documentId:o,state:a.pageChangeState}),this.pushScrollerLayout(o))}}async initialize(){this.logger.info("ScrollPlugin","Initialize","Scroll plugin initialized")}async destroy(){this.strategies.clear(),this.layoutReady.clear(),this.initialLayoutFired.clear(),this.elevatedPages.clear();for(const e of this.scrollerLayoutEmitters.values())e.clear();this.scrollerLayoutEmitters.clear(),this.pageChange$.clear(),this.scroll$.clear(),this.layoutChange$.clear(),this.pageChangeState$.clear(),this.layoutReady$.clear(),this.state$.clear(),super.destroy()}};Ih.id="scroll";let qs=Ih;const Gh="scroll",SS={manifest:{id:Gh,name:"Scroll Plugin",version:"1.0.0",provides:["scroll"],requires:["viewport"],optional:["spread","interaction-manager"],defaultConfig:{defaultPageGap:10,defaultBufferSize:4,defaultStrategy:ro.Vertical}},create:(t,e)=>new qs(Gh,t,e),reducer:vS,initialState:(t,e)=>yS(t,e)},Lh="SEARCH/INIT_STATE",$h="SEARCH/CLEANUP_STATE",Nh="SEARCH/START_SEARCH_SESSION",jh="SEARCH/STOP_SEARCH_SESSION",Uh="SEARCH/SET_SEARCH_FLAGS",Bh="SEARCH/SET_SHOW_ALL_RESULTS",zh="SEARCH/START_SEARCH",Wh="SEARCH/SET_SEARCH_RESULTS",Hh="SEARCH/APPEND_SEARCH_RESULTS",Vh="SEARCH/SET_ACTIVE_RESULT_INDEX";function ES(t,e){return{type:Lh,payload:{documentId:t,state:e}}}function AS(t){return{type:$h,payload:t}}function xS(t){return{type:Nh,payload:{documentId:t}}}function CS(t){return{type:jh,payload:{documentId:t}}}function TS(t,e){return{type:Uh,payload:{documentId:t,flags:e}}}function Yh(t,e){return{type:Bh,payload:{documentId:t,showAll:e}}}function MS(t,e){return{type:zh,payload:{documentId:t,query:e}}}function Ks(t,e,n,o){return{type:Wh,payload:{documentId:t,results:e,total:n,activeResultIndex:o}}}function RS(t,e){return{type:Hh,payload:{documentId:t,results:e}}}function qh(t,e){return{type:Vh,payload:{documentId:t,index:e}}}const jr={flags:[],results:[],total:0,activeResultIndex:-1,showAllResults:!0,query:"",loading:!1,active:!1},Kh={documents:{}},ao=(t,e,n)=>{const o=t.documents[e]||jr;return{...t,documents:{...t.documents,[e]:{...o,...n}}}},wS=(t=Kh,e)=>{switch(e.type){case Lh:return{...t,documents:{...t.documents,[e.payload.documentId]:e.payload.state}};case $h:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r}}case Nh:return ao(t,e.payload.documentId,{active:!0});case jh:return ao(t,e.payload.documentId,{results:[],total:0,activeResultIndex:-1,query:"",loading:!1,active:!1});case Uh:return ao(t,e.payload.documentId,{flags:e.payload.flags});case Bh:return ao(t,e.payload.documentId,{showAllResults:e.payload.showAll});case zh:return ao(t,e.payload.documentId,{loading:!0,query:e.payload.query,results:[],total:0,activeResultIndex:-1});case Hh:{const{documentId:n,results:o}=e.payload,r=t.documents[n];if(!r)return t;const a=[...r.results,...o],i=r.activeResultIndex===-1&&a.length>0?0:r.activeResultIndex;return ao(t,n,{results:a,total:a.length,activeResultIndex:i,loading:!0})}case Wh:{const{documentId:n,results:o,total:r,activeResultIndex:a}=e.payload;return ao(t,n,{results:o,total:r,activeResultIndex:a,loading:!1})}case Vh:return ao(t,e.payload.documentId,{activeResultIndex:e.payload.index});default:return t}},Xh=class extends jt{constructor(e,n,o){super(e,n),this.searchStop$=Be(),this.searchStart$=Be(),this.searchResult$=Be(),this.searchActiveResultChange$=Be(),this.searchResultState$=Be(),this.searchState$=Be(),this.currentTask=new Map,this.pluginConfig=o}onDocumentLoadingStarted(e){const n={...jr,flags:this.pluginConfig.flags||[],showAllResults:this.pluginConfig.showAllResults??!0};this.dispatch(ES(e,n))}onDocumentClosed(e){this.stopSearchSession(e),this.dispatch(AS(e)),this.currentTask.delete(e)}async initialize(){}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&(this.searchState$.emit({documentId:o,state:a}),(!r||r.results!==a.results||r.activeResultIndex!==a.activeResultIndex||r.showAllResults!==a.showAllResults||r.active!==a.active)&&this.searchResultState$.emit({documentId:o,state:{results:a.results,activeResultIndex:a.activeResultIndex,showAllResults:a.showAllResults,active:a.active}}))}}buildCapability(){const e=o=>o??this.getActiveDocumentId(),n=o=>{const r=e(o),a=this.state.documents[r];if(!a)throw new Error(`Search state not found for document ${r}`);return a};return{startSearch:o=>this.startSearchSession(e(o)),stopSearch:o=>this.stopSearchSession(e(o)),searchAllPages:(o,r)=>this.searchAllPages(o,e(r)),nextResult:o=>this.nextResult(e(o)),previousResult:o=>this.previousResult(e(o)),goToResult:(o,r)=>this.goToResult(o,e(r)),setShowAllResults:(o,r)=>this.dispatch(Yh(e(r),o)),getShowAllResults:o=>n(o).showAllResults,getFlags:o=>n(o).flags,setFlags:(o,r)=>this.setFlags(o,e(r)),getState:o=>n(o),forDocument:this.createSearchScope.bind(this),onSearchResult:this.searchResult$.on,onSearchStart:this.searchStart$.on,onSearchStop:this.searchStop$.on,onActiveResultChange:this.searchActiveResultChange$.on,onSearchResultStateChange:this.searchResultState$.on,onStateChange:this.searchState$.on}}createSearchScope(e){const n=()=>{const o=this.state.documents[e];if(!o)throw new Error(`Search state not found for document ${e}`);return o};return{startSearch:()=>this.startSearchSession(e),stopSearch:()=>this.stopSearchSession(e),searchAllPages:o=>this.searchAllPages(o,e),nextResult:()=>this.nextResult(e),previousResult:()=>this.previousResult(e),goToResult:o=>this.goToResult(o,e),setShowAllResults:o=>this.dispatch(Yh(e,o)),getShowAllResults:()=>n().showAllResults,getFlags:()=>n().flags,setFlags:o=>this.setFlags(o,e),getState:n,onSearchResult:o=>this.searchResult$.on(r=>{r.documentId===e&&o(r.results)}),onSearchStart:o=>this.searchStart$.on(r=>{r.documentId===e&&o()}),onSearchStop:o=>this.searchStop$.on(r=>{r.documentId===e&&o()}),onActiveResultChange:o=>this.searchActiveResultChange$.on(r=>{r.documentId===e&&o(r.index)}),onSearchResultStateChange:o=>this.searchResultState$.on(r=>{r.documentId===e&&o(r.state)}),onStateChange:o=>this.searchState$.on(r=>{r.documentId===e&&o(r.state)})}}setFlags(e,n){this.dispatch(TS(n,e));const o=this.state.documents[n];o!=null&&o.active&&this.searchAllPages(o.query,n,!0)}notifySearchStart(e){this.searchStart$.emit({documentId:e})}notifySearchStop(e){this.searchStop$.emit({documentId:e})}notifyActiveResultChange(e,n){this.searchActiveResultChange$.emit({documentId:e,index:n})}startSearchSession(e){this.getCoreDocument(e)&&(this.dispatch(xS(e)),this.notifySearchStart(e))}stopSearchSession(e){var n;const o=this.state.documents[e];if(!(o!=null&&o.active))return;const r=this.currentTask.get(e);if(r){try{(n=r.abort)==null||n.call(r,{code:ve.Cancelled,message:"search stopped"})}catch{}this.currentTask.delete(e)}this.dispatch(CS(e)),this.notifySearchStop(e)}searchAllPages(e,n,o=!1){var r;const a=this.state.documents[n];if(!a)return Ue.reject({code:ve.NotFound,message:"Search state not initialized"});const i=this.getCoreDocument(n);if(!(i!=null&&i.document))return Ue.reject({code:ve.NotFound,message:"Document not loaded"});const s=e.trim();if(a.query===s&&!o)return Ue.resolve({results:a.results,total:a.total});const l=this.currentTask.get(n);if(l){try{(r=l.abort)==null||r.call(l,{code:ve.Cancelled,message:"new search"})}catch{}this.currentTask.delete(n)}if(this.dispatch(MS(n,s)),!s)return this.dispatch(Ks(n,[],0,-1)),Ue.resolve({results:[],total:0});a.active||this.startSearchSession(n);const c=this.engine.searchAllPages(i.document,s,{flags:a.flags});return this.currentTask.set(n,c),c.onProgress(u=>{var d;(d=u==null?void 0:u.results)!=null&&d.length&&this.currentTask.get(n)===c&&(this.dispatch(RS(n,u.results)),this.state.documents[n].activeResultIndex===-1&&(this.dispatch(qh(n,0)),this.notifyActiveResultChange(n,0)))}),c.wait(u=>{this.currentTask.delete(n);const d=u.total>0?0:-1;this.dispatch(Ks(n,u.results,u.total,d)),this.searchResult$.emit({documentId:n,results:u}),u.total>0&&this.notifyActiveResultChange(n,0)},u=>{var d;((d=u==null?void 0:u.reason)==null?void 0:d.code)!==ve.Cancelled&&(console.error("Error during search:",u),this.dispatch(Ks(n,[],0,-1))),this.currentTask.delete(n)}),c}nextResult(e){const n=this.state.documents[e];if(!n||n.results.length===0)return-1;const o=n.activeResultIndex>=n.results.length-1?0:n.activeResultIndex+1;return this.goToResult(o,e)}previousResult(e){const n=this.state.documents[e];if(!n||n.results.length===0)return-1;const o=n.activeResultIndex<=0?n.results.length-1:n.activeResultIndex-1;return this.goToResult(o,e)}goToResult(e,n){const o=this.state.documents[n];return!o||o.results.length===0||e<0||e>=o.results.length?-1:(this.dispatch(qh(n,e)),this.notifyActiveResultChange(n,e),e)}async destroy(){for(const e of Object.keys(this.state.documents))this.stopSearchSession(e);this.searchResult$.clear(),this.searchStart$.clear(),this.searchStop$.clear(),this.searchActiveResultChange$.clear(),this.searchResultState$.clear(),this.searchState$.clear(),super.destroy()}};Xh.id="search";let Zh=Xh;const Qh="search",OS={manifest:{id:Qh,name:"Search Plugin",version:"1.0.0",provides:["search"],requires:[],optional:[],defaultConfig:{flags:[]}},create:(t,e)=>new Zh(Qh,t,e),reducer:wS,initialState:Kh},Jh="thumbnail",kS={id:Jh,name:"Thumbnail Plugin",version:"1.0.0",provides:["thumbnail"],requires:["render"],optional:["scroll"],defaultConfig:{width:150,gap:10,buffer:3,labelHeight:16,autoScroll:!0,scrollBehavior:"smooth",imagePadding:0,paddingY:0}},eg="THUMBNAIL/INIT_STATE",tg="THUMBNAIL/CLEANUP_STATE",IS="THUMBNAIL/SET_ACTIVE_DOCUMENT",ng="THUMBNAIL/SET_WINDOW_STATE",og="THUMBNAIL/UPDATE_VIEWPORT_METRICS";function rg(t,e){return{type:eg,payload:{documentId:t,state:e}}}function GS(t){return{type:tg,payload:t}}function LS(t,e){return{type:ng,payload:{documentId:t,window:e}}}function $S(t,e,n){return{type:og,payload:{documentId:t,scrollY:e,viewportH:n}}}const NS={thumbs:[],window:null,viewportH:0,scrollY:0},ag={documents:{},activeDocumentId:null},jS=(t=ag,e)=>{switch(e.type){case eg:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case tg:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case IS:return{...t,activeDocumentId:e.payload};case ng:{const{documentId:n,window:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,window:o}}}:t}case og:{const{documentId:n,scrollY:o,viewportH:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:{...a,scrollY:o,viewportH:r}}}:t}default:return t}},ig=class extends jt{constructor(e,n,o){var r;super(e,n),this.cfg=o,this.scrollCapability=null,this.taskCaches=new Map,this.canAutoScroll=new Map,this.window$=Tt((a,i)=>({documentId:a,window:i})),this.scrollTo$=Tt((a,i)=>({documentId:a,options:i})),this.refreshPages$=Tt((a,i)=>({documentId:a,pages:i}),{cache:!1}),this.renderCapability=this.registry.getPlugin("render").provides(),this.scrollCapability=((r=this.registry.getPlugin("scroll"))==null?void 0:r.provides())??null,this.coreStore.onAction(Vo,a=>{const i=a.payload.documentId??this.getActiveDocumentId(),s=a.payload.pageIndexes;this.refreshPages$.emit(i,s);const l=this.taskCaches.get(i);if(l)for(const c of s)l.delete(c)}),this.scrollCapability&&this.cfg.autoScroll!==!1&&(this.scrollCapability.onPageChangeState(({documentId:a,state:i})=>{this.canAutoScroll.set(a,!i.isChanging),i.isChanging||this.scrollToThumb(i.targetPage-1,a)}),this.scrollCapability.onPageChange(({documentId:a,pageNumber:i})=>{this.canAutoScroll.get(a)!==!1&&this.scrollToThumb(i-1,a)}))}onDocumentLoadingStarted(e){this.dispatch(rg(e,{...NS})),this.taskCaches.set(e,new Map),this.canAutoScroll.set(e,!0),this.logger.debug("ThumbnailPlugin","DocumentOpened",`Initialized thumbnail state for document: ${e}`)}onDocumentLoaded(e){this.calculateWindowState(e)}onDocumentClosed(e){this.dispatch(GS(e));const n=this.taskCaches.get(e);n&&(n.forEach(o=>{o.abort({code:"cancelled",message:"Document closed"})}),n.clear(),this.taskCaches.delete(e)),this.canAutoScroll.delete(e),this.window$.clearScope(e),this.scrollTo$.clearScope(e),this.refreshPages$.clearScope(e),this.logger.debug("ThumbnailPlugin","DocumentClosed",`Cleaned up thumbnail state for document: ${e}`)}onRotationChanged(e){this.calculateWindowState(e)}buildCapability(){return{scrollToThumb:e=>this.scrollToThumb(e),renderThumb:(e,n)=>this.renderThumb(e,n),updateWindow:(e,n)=>this.updateWindow(e,n),getWindow:()=>this.getWindow(),forDocument:e=>this.createThumbnailScope(e),onWindow:this.window$.onGlobal,onScrollTo:this.scrollTo$.onGlobal,onRefreshPages:this.refreshPages$.onGlobal}}createThumbnailScope(e){return{scrollToThumb:n=>this.scrollToThumb(n,e),renderThumb:(n,o)=>this.renderThumb(n,o,e),updateWindow:(n,o)=>this.updateWindow(n,o,e),getWindow:()=>this.getWindow(e),onWindow:this.window$.forScope(e),onScrollTo:this.scrollTo$.forScope(e),onRefreshPages:this.refreshPages$.forScope(e)}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}calculateWindowState(e){const n=this.coreState.core.documents[e];if(!(n!=null&&n.document))return;const o=this.cfg.width??120,r=this.cfg.labelHeight??16,a=this.cfg.gap??8,i=this.cfg.imagePadding??0,s=this.cfg.paddingY??0,l=Math.max(1,o-2*i);let c=s;const u=n.document.pages.map(h=>{const g=h.rotation%2===1,f=g?h.size.height:h.size.width,_=(g?h.size.width:h.size.height)/f,y=Math.round(l*_),E=i+y+i+r,A={pageIndex:h.index,width:l,height:y,wrapperHeight:E,top:c,labelHeight:r,padding:i};return c+=E+a,A}),d={start:-1,end:-1,items:[],totalHeight:c-a+s},p=this.getDocumentState(e);p&&(this.dispatch(rg(e,{...p,thumbs:u,window:d})),p.viewportH>0?this.updateWindow(p.scrollY,p.viewportH,e):this.window$.emit(e,d))}updateWindow(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getDocumentState(r);if(!a||!a.window||a.thumbs.length===0)return;const i=this.cfg.buffer??3;this.dispatch($S(r,e,n));let s=0,l=a.thumbs.length-1,c=0;for(;s<=l;){const g=s+l>>1,f=a.thumbs[g];f.top+f.wrapperHeight<e?s=g+1:(c=g,l=g-1)}let u=c;const d=e+n;for(;u+1<a.thumbs.length&&a.thumbs[u].top<d;)u++;u=Math.min(a.thumbs.length-1,u+i);const p=Math.max(0,c-i);if(p===a.window.start&&u===a.window.end)return;const h={start:p,end:u,items:a.thumbs.slice(p,u+1),totalHeight:a.window.totalHeight};this.dispatch(LS(r,h)),this.window$.emit(r,h)}getWindow(e){const n=this.getDocumentState(e);return(n==null?void 0:n.window)??null}scrollToThumb(e,n){const o=n??this.getActiveDocumentId(),r=this.getDocumentState(o);if(!r||!r.window)return;const a=r.thumbs[e];if(!a)return;const i=this.cfg.scrollBehavior??"smooth",s=this.cfg.paddingY??0;if(r.viewportH<=0){const h=Math.max(s,a.top-a.wrapperHeight);this.scrollTo$.emit(o,{top:h,behavior:i});return}const l=8,c=a.top,u=a.top+a.wrapperHeight,d=c<r.scrollY+l+s,p=u>r.scrollY+r.viewportH-l;d?this.scrollTo$.emit(o,{top:Math.max(0,c-s),behavior:i}):p&&this.scrollTo$.emit(o,{top:Math.max(0,u-r.viewportH+s),behavior:i})}renderThumb(e,n,o){const r=o??this.getActiveDocumentId(),a=this.taskCaches.get(r);if(!a)throw new Error(`Task cache not found for document: ${r}`);if(a.has(e))return a.get(e);const i=this.coreState.core.documents[r];if(!(i!=null&&i.document))throw new Error(`Document not found: ${r}`);const s=i.document.pages[e];if(!s)throw new Error(`Page ${e} not found in document: ${r}`);const l=this.cfg.width??120,c=this.cfg.imagePadding??0,d=Math.max(1,l-2*c)/s.size.width,p=this.renderCapability.forDocument(r).renderPageRect({pageIndex:e,rect:{origin:{x:0,y:0},size:s.size},options:{scaleFactor:d,dpr:n,rotation:s.rotation}});return a.set(e,p),p.wait(Yt,()=>a.delete(e)),p}async initialize(){this.logger.info("ThumbnailPlugin","Initialize","Thumbnail plugin initialized")}async destroy(){this.window$.clear(),this.refreshPages$.clear(),this.scrollTo$.clear(),this.taskCaches.forEach(e=>{e.forEach(n=>{n.abort({code:"cancelled",message:"Plugin destroyed"})}),e.clear()}),this.taskCaches.clear(),this.canAutoScroll.clear(),super.destroy()}};ig.id="thumbnail";let Xs=ig;const US={manifest:kS,create:(t,e)=>new Xs(Jh,t,e),reducer:jS,initialState:ag},sg="tiling",BS={id:sg,name:"Tiling Plugin",version:"1.0.0",provides:["tiling"],requires:["render","scroll","viewport"],optional:[],defaultConfig:{tileSize:768,overlapPx:2.5,extraRings:0}},lg="TILING/INIT_STATE",cg="TILING/CLEANUP_STATE",ug="TILING/UPDATE_VISIBLE_TILES",dg="TILING/MARK_TILE_STATUS",zS=(t,e)=>({type:lg,payload:{documentId:t,state:e}}),WS=t=>({type:cg,payload:t}),pg=(t,e)=>({type:ug,payload:{documentId:t,tiles:e}}),hg=(t,e,n,o)=>({type:dg,payload:{documentId:t,pageIndex:e,tileId:n,status:o}}),HS={visibleTiles:{}},VS={documents:{}},YS=(t,e)=>{var n,o;switch(e.type){case lg:{const{documentId:r,state:a}=e.payload;return{...t,documents:{...t.documents,[r]:a}}}case cg:{const r=e.payload,{[r]:a,...i}=t.documents;return{...t,documents:i}}case ug:{const{documentId:r,tiles:a}=e.payload,i=t.documents[r];if(!i)return t;const s={...i.visibleTiles};for(const l in a){const c=Number(l),u=a[c],d=s[c]??[],p=(n=d.find(f=>!f.isFallback))==null?void 0:n.srcScale,h=u.length>0?u[0].srcScale:p;if(p!==void 0&&p!==h){const f=d.filter(_=>!_.isFallback&&_.status==="ready").map(_=>({..._,isFallback:!0})),F=f.length>0?[]:d.filter(_=>_.isFallback);s[c]=[...F,...f,...u]}else{const f=new Set(u.map(y=>y.id)),F=[],_=new Set;for(const y of d)(y.isFallback||f.has(y.id))&&(F.push(y),_.add(y.id));for(const y of u)_.has(y.id)||F.push(y);s[c]=F}}return{...t,documents:{...t.documents,[r]:{...i,visibleTiles:s}}}}case dg:{const{documentId:r,pageIndex:a,tileId:i,status:s}=e.payload,l=t.documents[r];if(!l)return t;const c=((o=l.visibleTiles[a])==null?void 0:o.map(h=>h.id===i?{...h,status:s}:h))??[],u=c.filter(h=>!h.isFallback),p=u.length>0&&u.every(h=>h.status==="ready")?u:c;return{...t,documents:{...t.documents,[r]:{...l,visibleTiles:{...l.visibleTiles,[a]:p}}}}}default:return t}};function gg({tileSize:t=768,overlapPx:e=2.5,extraRings:n=0,scale:o,rotation:r,page:a,metric:i}){const s=a.size.width*o,l=a.size.height*o,c=t-e,u=Ca(a.size,r,o),d={origin:{x:i.scaled.pageX,y:i.scaled.pageY},size:{width:i.scaled.visibleWidth,height:i.scaled.visibleHeight}},p=tF(u,d,r,1),h=p.origin.x,g=p.origin.y,f=h+p.size.width,F=g+p.size.height,_=Math.floor((s-1)/c),y=Math.floor((l-1)/c),E=Math.max(0,Math.floor(h/c)-n),A=Math.min(_,Math.floor((f-1)/c)+n),T=Math.max(0,Math.floor(g/c)-n),q=Math.min(y,Math.floor((F-1)/c)+n),w=[];for(let G=E;G<=A;G++){const W=G*c,J=Math.min(t,s-W),ue=W/o,ce=J/o;for(let ee=T;ee<=q;ee++){const ge=ee*c,_e=Math.min(t,l-ge),Ee=ge/o,Te=_e/o;w.push({id:`p${a.index}-${o}-x${W}-y${ge}-w${J}-h${_e}`,col:G,row:ee,pageRect:{origin:{x:ue,y:Ee},size:{width:ce,height:Te}},screenRect:{origin:{x:W,y:ge},size:{width:J,height:_e}},status:"queued",srcScale:o,isFallback:!1})}}return w}const fg=class extends jt{constructor(e,n,o){super(e,n),this.tileRendering$=Be(),this.config=o,this.renderCapability=this.registry.getPlugin("render").provides(),this.scrollCapability=this.registry.getPlugin("scroll").provides(),this.viewportCapability=this.registry.getPlugin("viewport").provides(),this.scrollCapability.onScroll(r=>this.calculateVisibleTiles(r.documentId,r.metrics),{mode:"throttle",wait:50,throttleMode:"trailing"}),this.coreStore.onAction(Vo,r=>this.recalculateTiles(r.payload))}onDocumentLoadingStarted(e){this.dispatch(zS(e,HS))}onDocumentClosed(e){this.dispatch(WS(e))}onScaleChanged(e){this.recalculateTilesForDocument(e)}onRotationChanged(e){this.recalculateTilesForDocument(e)}recalculateTilesForDocument(e){const n=this.scrollCapability.forDocument(e),o=this.viewportCapability.forDocument(e),r=n.getMetrics(o.getMetrics());this.calculateVisibleTiles(e,r)}async recalculateTiles(e){const{documentId:n,pageIndexes:o}=e,r=this.getCoreDocument(n);if(!r||!r.document)return;const a=this.scrollCapability.forDocument(n),i=this.viewportCapability.forDocument(n),s=a.getMetrics(i.getMetrics()),l={},c=Date.now(),u=r.scale;for(const d of o){const p=s.pageVisibilityMetrics.find(f=>f.pageNumber===d+1);if(!p)continue;const h=r.document.pages[d];if(!h)continue;const g=((h.rotation??0)+r.rotation)%4;l[d]=gg({page:h,metric:p,scale:u,rotation:g,tileSize:this.config.tileSize,overlapPx:this.config.overlapPx,extraRings:this.config.extraRings}).map(f=>({...f,id:`${f.id}-r${c}`}))}Object.keys(l).length>0&&this.dispatch(pg(n,l))}async initialize(){}calculateVisibleTiles(e,n){const o=this.getCoreDocument(e);if(!o||!o.document)return;const r=o.scale,a={};for(const i of n.pageVisibilityMetrics){const s=i.pageNumber-1,l=o.document.pages[s];if(!l)continue;const c=((l.rotation??0)+o.rotation)%4,u=gg({page:l,metric:i,scale:r,rotation:c,tileSize:this.config.tileSize,overlapPx:this.config.overlapPx,extraRings:this.config.extraRings});a[s]=u}this.dispatch(pg(e,a))}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&this.tileRendering$.emit({documentId:o,tiles:a.visibleTiles})}}buildCapability(){return{renderTile:this.renderTile.bind(this),forDocument:this.createTilingScope.bind(this),onTileRendering:this.tileRendering$.on}}createTilingScope(e){return{renderTile:n=>this.renderTile(n,e),onTileRendering:n=>this.tileRendering$.on(o=>{o.documentId===e&&n(o.tiles)})}}renderTile(e,n){const o=n??this.getActiveDocumentId();if(!this.renderCapability)throw new Error("Render capability not available.");this.dispatch(hg(o,e.pageIndex,e.tile.id,"rendering"));const r=this.renderCapability.forDocument(o).renderPageRect({pageIndex:e.pageIndex,rect:e.tile.pageRect,options:{scaleFactor:e.tile.srcScale,dpr:e.dpr}});return r.wait(()=>{this.dispatch(hg(o,e.pageIndex,e.tile.id,"ready"))},Yt),r}};fg.id="tiling";let mg=fg;const qS={manifest:BS,create:(t,e)=>new mg(sg,t,e),reducer:(t,e)=>YS(t,e),initialState:VS},Pg="viewport",KS={id:Pg,name:"Viewport Plugin",version:"1.0.0",provides:["viewport"],requires:[],optional:[],defaultConfig:{viewportGap:10,scrollEndDelay:300}},Fg="INIT_VIEWPORT_STATE",bg="CLEANUP_VIEWPORT_STATE",_g="REGISTER_VIEWPORT",yg="UNREGISTER_VIEWPORT",vg="SET_VIEWPORT_METRICS",Dg="SET_VIEWPORT_SCROLL_METRICS",Sg="SET_VIEWPORT_GAP",Eg="SET_SCROLL_ACTIVITY",Ag="SET_SMOOTH_SCROLL_ACTIVITY",XS="SET_ACTIVE_VIEWPORT_DOCUMENT",xg="ADD_VIEWPORT_GATE",Cg="REMOVE_VIEWPORT_GATE";function ZS(t){return{type:Fg,payload:{documentId:t}}}function QS(t){return{type:bg,payload:{documentId:t}}}function JS(t){return{type:_g,payload:{documentId:t}}}function eE(t){return{type:yg,payload:{documentId:t}}}function tE(t){return{type:Sg,payload:t}}function nE(t,e){return{type:vg,payload:{documentId:t,metrics:e}}}function oE(t,e){return{type:Dg,payload:{documentId:t,scrollMetrics:e}}}function rE(t,e){return{type:Eg,payload:{documentId:t,isScrolling:e}}}function Tg(t,e){return{type:Ag,payload:{documentId:t,isSmoothScrolling:e}}}function aE(t,e){return{type:xg,payload:{documentId:t,key:e}}}function iE(t,e){return{type:Cg,payload:{documentId:t,key:e}}}const sE={viewportMetrics:{width:0,height:0,scrollTop:0,scrollLeft:0,clientWidth:0,clientHeight:0,scrollWidth:0,scrollHeight:0,clientLeft:0,clientTop:0,relativePosition:{x:0,y:0}},isScrolling:!1,isSmoothScrolling:!1,gates:new Set},Mg={viewportGap:0,documents:{},activeViewports:new Set,activeDocumentId:null},lE=(t=Mg,e)=>{switch(e.type){case Fg:{const{documentId:n}=e.payload;return{...t,documents:{...t.documents,[n]:{...sE,gates:new Set}}}}case bg:{const{documentId:n}=e.payload,{[n]:o,...r}=t.documents,a=new Set(t.activeViewports);return a.delete(n),{...t,documents:r,activeViewports:a,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case _g:{const{documentId:n}=e.payload,o=new Set(t.activeViewports);return o.add(n),{...t,activeViewports:o,activeDocumentId:t.activeDocumentId??n}}case yg:{const{documentId:n}=e.payload,o=new Set(t.activeViewports);return o.delete(n),{...t,activeViewports:o}}case XS:return{...t,activeDocumentId:e.payload};case Sg:return{...t,viewportGap:e.payload};case vg:{const{documentId:n,metrics:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,viewportMetrics:{width:o.width,height:o.height,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft,clientWidth:o.clientWidth,clientHeight:o.clientHeight,scrollWidth:o.scrollWidth,scrollHeight:o.scrollHeight,clientLeft:o.clientLeft,clientTop:o.clientTop,relativePosition:{x:o.scrollWidth<=o.clientWidth?0:o.scrollLeft/(o.scrollWidth-o.clientWidth),y:o.scrollHeight<=o.clientHeight?0:o.scrollTop/(o.scrollHeight-o.clientHeight)}}}}}:t}case Dg:{const{documentId:n,scrollMetrics:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,viewportMetrics:{...r.viewportMetrics,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft},isScrolling:!0}}}:t}case Eg:{const{documentId:n,isScrolling:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isScrolling:o}}}:t}case Ag:{const{documentId:n,isSmoothScrolling:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isSmoothScrolling:o}}}:t}case xg:{const{documentId:n,key:o}=e.payload,r=t.documents[n];if(!r)return t;const a=new Set(r.gates);return a.add(o),{...t,documents:{...t.documents,[n]:{...r,gates:a}}}}case Cg:{const{documentId:n,key:o}=e.payload,r=t.documents[n];if(!r)return t;const a=new Set(r.gates);return a.delete(o),{...t,documents:{...t.documents,[n]:{...r,gates:a}}}}default:return t}},Rg=class extends jt{constructor(e,n,o){super(e,n),this.id=e,this.viewportResize$=Be(),this.viewportMetrics$=Be(),this.scrollMetrics$=Be(),this.scrollActivity$=Be(),this.gateState$=Be(),this.scrollRequests$=new Map,o.viewportGap&&this.dispatch(tE(o.viewportGap)),this.scrollEndDelay=o.scrollEndDelay||100}onDocumentLoadingStarted(e){this.dispatch(ZS(e)),this.scrollRequests$.set(e,$n()),this.logger.debug("ViewportPlugin","DocumentOpened",`Initialized viewport state for document: ${e}`)}onDocumentClosed(e){var n;this.dispatch(QS(e)),(n=this.scrollRequests$.get(e))==null||n.clear(),this.scrollRequests$.delete(e),this.logger.debug("ViewportPlugin","DocumentClosed",`Cleaned up viewport state for document: ${e}`)}buildCapability(){return{getViewportGap:()=>this.state.viewportGap,getMetrics:()=>this.getMetrics(),scrollTo:e=>this.scrollTo(e),isScrolling:()=>this.isScrolling(),isSmoothScrolling:()=>this.isSmoothScrolling(),isGated:e=>this.isGated(e),hasGate:(e,n)=>this.hasGate(e,n),getGates:e=>this.getGates(e),forDocument:e=>this.createViewportScope(e),gate:(e,n)=>this.gate(e,n),releaseGate:(e,n)=>this.releaseGate(e,n),isViewportMounted:e=>this.state.activeViewports.has(e),onViewportChange:this.viewportMetrics$.on,onViewportResize:this.viewportResize$.on,onScrollChange:this.scrollMetrics$.on,onScrollActivity:this.scrollActivity$.on,onGateChange:this.gateState$.on}}createViewportScope(e){return{getMetrics:()=>this.getMetrics(e),scrollTo:n=>this.scrollTo(n,e),isScrolling:()=>this.isScrolling(e),isSmoothScrolling:()=>this.isSmoothScrolling(e),isGated:()=>this.isGated(e),hasGate:n=>this.hasGate(n,e),getGates:()=>this.getGates(e),gate:n=>this.gate(n,e),releaseGate:n=>this.releaseGate(n,e),onViewportChange:n=>this.viewportMetrics$.on(o=>{o.documentId===e&&n(o.metrics)}),onScrollChange:n=>this.scrollMetrics$.on(o=>{o.documentId===e&&n(o.scrollMetrics)}),onScrollActivity:n=>this.scrollActivity$.on(o=>{o.documentId===e&&n(o.activity)}),onGateChange:n=>this.gateState$.on(o=>{(o==null?void 0:o.documentId)===e&&n(o)})}}registerViewport(e){if(!this.state.documents[e])throw new Error(`Cannot register viewport for ${e}: document state not found. Document must be opened before registering viewport.`);this.state.activeViewports.has(e)||(this.dispatch(JS(e)),this.logger.debug("ViewportPlugin","RegisterViewport",`Registered viewport (DOM mounted) for document: ${e}`))}unregisterViewport(e){this.registry.isDestroyed()||this.state.activeViewports.has(e)&&(this.dispatch(eE(e)),this.logger.debug("ViewportPlugin","UnregisterViewport",`Unregistered viewport (DOM unmounted) for document: ${e}. State preserved.`))}setViewportResizeMetrics(e,n){if(this.registry.isDestroyed())return;this.dispatch(nE(e,n));const o=this.state.documents[e];o&&this.viewportResize$.emit({documentId:e,metrics:o.viewportMetrics})}setViewportScrollMetrics(e,n){if(this.registry.isDestroyed())return;const o=this.state.documents[e];o&&(n.scrollTop!==o.viewportMetrics.scrollTop||n.scrollLeft!==o.viewportMetrics.scrollLeft)&&(this.dispatch(oE(e,n)),this.bumpScrollActivity(e),this.scrollMetrics$.emit({documentId:e,scrollMetrics:n}))}onScrollRequest(e,n){const o=this.scrollRequests$.get(e);if(!o)throw new Error(`Cannot subscribe to scroll requests for ${e}: document state not initialized`);return o.on(n)}gate(e,n){const o=this.state.documents[n];if(!o){this.logger.warn("ViewportPlugin","GateViewport",`Cannot gate viewport for ${n}: document not found`);return}o.gates.has(e)||(this.dispatch(aE(n,e)),this.logger.debug("ViewportPlugin","GateAdded",`Added gate '${e}' for document: ${n}. Total gates: ${o.gates.size+1}`))}releaseGate(e,n){const o=this.state.documents[n];if(!o){this.logger.warn("ViewportPlugin","ReleaseGate",`Cannot release gate for ${n}: document not found`);return}o.gates.has(e)&&(this.dispatch(iE(n,e)),this.logger.debug("ViewportPlugin","GateReleased",`Released gate '${e}' for document: ${n}. Remaining gates: ${o.gates.size-1}`))}getViewportState(e){const n=e??this.getActiveDocumentId(),o=this.state.documents[n];if(!o)throw new Error(`Viewport state not found for document: ${n}`);return o}getMetrics(e){return this.getViewportState(e).viewportMetrics}isScrolling(e){return this.getViewportState(e).isScrolling}isSmoothScrolling(e){return this.getViewportState(e).isSmoothScrolling}isGated(e){return this.getViewportState(e).gates.size>0}hasGate(e,n){return this.getViewportState(n).gates.has(e)}getGates(e){const n=this.getViewportState(e);return Array.from(n.gates)}scrollTo(e,n){const o=n??this.getActiveDocumentId(),r=this.getViewportState(o),{x:a,y:i,alignX:s,alignY:l,behavior:c="auto"}=e;c==="smooth"&&this.dispatch(Tg(o,!0));const u=r.viewportMetrics;let d=a,p=i;s!==void 0&&(d=a-u.clientWidth*(s/100)),l!==void 0&&(p=i-u.clientHeight*(l/100));const h=this.scrollRequests$.get(o);h&&h.emit({x:d,y:p,behavior:c})}bumpScrollActivity(e){this.debouncedDispatch(rE(e,!1),this.scrollEndDelay),this.debouncedDispatch(Tg(e,!1),this.scrollEndDelay)}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];if(r!==a&&(this.viewportMetrics$.emit({documentId:o,metrics:a.viewportMetrics}),r&&(r.isScrolling!==a.isScrolling||r.isSmoothScrolling!==a.isSmoothScrolling)&&this.scrollActivity$.emit({documentId:o,activity:{isScrolling:a.isScrolling,isSmoothScrolling:a.isSmoothScrolling}}),r&&r.gates!==a.gates)){const i=Array.from(r.gates),s=Array.from(a.gates),l=s.find(u=>!i.includes(u)),c=i.find(u=>!s.includes(u));this.gateState$.emit({documentId:o,isGated:a.gates.size>0,gates:s,addedGate:l,removedGate:c}),this.logger.debug("ViewportPlugin","GateStateChanged",`Gate state changed for document ${o}. Gates: [${s.join(", ")}], Gated: ${a.gates.size>0}`)}}}async initialize(e){this.logger.info("ViewportPlugin","Initialize","Viewport plugin initialized")}async destroy(){this.viewportMetrics$.clear(),this.viewportResize$.clear(),this.scrollMetrics$.clear(),this.scrollActivity$.clear(),this.gateState$.clear(),this.scrollRequests$.forEach(e=>e.clear()),this.scrollRequests$.clear(),super.destroy()}};Rg.id="viewport";let Zs=Rg;const cE={manifest:KS,create:(t,e)=>new Zs(Pg,t,e),reducer:lE,initialState:Mg};var Mt=(t=>(t.Automatic="automatic",t.FitPage="fit-page",t.FitWidth="fit-width",t))(Mt||{}),So=(t=>(t[t.Center=0]="Center",t[t.Top=1]="Top",t))(So||{});const wg="zoom",uE={id:wg,name:"Zoom Plugin",version:"1.0.0",provides:["zoom"],requires:["viewport","scroll"],optional:["interaction-manager","spread"],defaultConfig:{defaultZoomLevel:Mt.Automatic,minZoom:.2,maxZoom:60,zoomStep:.1,zoomRanges:[{min:.2,max:.5,step:.05},{min:.5,max:1,step:.1},{min:1,max:2,step:.2},{min:2,max:4,step:.4},{min:4,max:10,step:.8},{min:10,max:20,step:1.6},{min:20,max:40,step:3.2},{min:40,max:60,step:6.4}],presets:[{name:"Fit Page",value:Mt.FitPage},{name:"Fit Width",value:Mt.FitWidth},{name:"Automatic",value:Mt.Automatic},{name:"25%",value:.25},{name:"50%",value:.5},{name:"100%",value:1},{name:"125%",value:1.25},{name:"150%",value:1.5},{name:"200%",value:2},{name:"400%",value:4},{name:"800%",value:8},{name:"1600%",value:16}]}},Og="ZOOM/INIT_STATE",kg="ZOOM/CLEANUP_STATE",dE="ZOOM/SET_ACTIVE_DOCUMENT",Ig="ZOOM/SET_ZOOM_LEVEL",Gg="ZOOM/SET_MARQUEE_ZOOM_ACTIVE";function pE(t,e){return{type:Og,payload:{documentId:t,state:e}}}function hE(t){return{type:kg,payload:t}}function gE(t,e,n){return{type:Ig,payload:{documentId:t,zoomLevel:e,currentZoomLevel:n}}}function fE(t,e){return{type:Gg,payload:{documentId:t,isActive:e}}}const ri={zoomLevel:Mt.Automatic,currentZoomLevel:1,isMarqueeZoomActive:!1},Lg={documents:{},activeDocumentId:null},mE=(t=Lg,e)=>{switch(e.type){case Og:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case kg:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case dE:return{...t,activeDocumentId:e.payload};case Ig:{const{documentId:n,zoomLevel:o,currentZoomLevel:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:{...a,zoomLevel:o,currentZoomLevel:r}}}:t}case Gg:{const{documentId:n,isActive:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isMarqueeZoomActive:o}}}:t}default:return t}};function PE(t){const{pageSize:e,scale:n,minDragPx:o=5,onPreview:r,onCommit:a,onSmallDrag:i}=t;let s=null,l=null;return{onPointerDown:(c,u)=>{var d;s=c,l={origin:{x:c.x,y:c.y},size:{width:0,height:0}},r==null||r(l),(d=u.setPointerCapture)==null||d.call(u)},onPointerMove:c=>{if(!s)return;const u=et(c.x,0,e.width),d=et(c.y,0,e.height);l={origin:{x:Math.min(s.x,u),y:Math.min(s.y,d)},size:{width:Math.abs(u-s.x),height:Math.abs(d-s.y)}},r==null||r(l)},onPointerUp:(c,u)=>{var d;l&&(Math.max(l.size.width,l.size.height)*n>o?a==null||a(l):i==null||i()),s=null,l=null,r==null||r(null),(d=u.releasePointerCapture)==null||d.call(u)},onPointerCancel:(c,u)=>{var d;s=null,l=null,r==null||r(null),(d=u.releasePointerCapture)==null||d.call(u)}}}const $g=class extends jt{constructor(e,n,o){var r,a,i;super(e,n),this.zoom$=$n(),this.state$=Be(),this.viewportPlugin=n.getPlugin("viewport"),this.viewport=this.viewportPlugin.provides(),this.scroll=n.getPlugin("scroll").provides();const s=n.getPlugin("interaction-manager");this.interactionManager=(s==null?void 0:s.provides())??null;const l=n.getPlugin("spread");this.spread=(l==null?void 0:l.provides())??null,this.minZoom=o.minZoom??.25,this.maxZoom=o.maxZoom??10,this.zoomStep=o.zoomStep??.1,this.defaultZoomLevel=o.defaultZoomLevel,this.presets=o.presets??[],this.zoomRanges=this.normalizeRanges(o.zoomRanges??[]),this.viewport.onViewportResize(c=>this.recalcAuto(c.documentId,So.Top),{mode:"debounce",wait:150,keyExtractor:c=>c.documentId}),(r=this.spread)==null||r.onSpreadChange(c=>{this.recalcAuto(c.documentId,So.Top)}),(a=this.interactionManager)==null||a.registerMode({id:"marqueeZoom",scope:"page",exclusive:!0,cursor:"zoom-in"}),(i=this.interactionManager)==null||i.onModeChange(c=>{const u=c.activeMode==="marqueeZoom",d=this.getDocumentState(c.documentId);d&&d.isMarqueeZoomActive!==u&&this.dispatch(fE(c.documentId,u))})}onDocumentLoadingStarted(e){this.viewport.gate("zoom",e);const n={...ri,zoomLevel:this.defaultZoomLevel};this.dispatch(pE(e,n)),this.logger.debug("ZoomPlugin","DocumentOpened",`Initialized zoom state for document: ${e}`)}onDocumentLoaded(e){this.recalcAuto(e,So.Top)}onDocumentClosed(e){this.dispatch(hE(e)),this.logger.debug("ZoomPlugin","DocumentClosed",`Cleaned up zoom state for document: ${e}`)}onRotationChanged(e){this.recalcAuto(e,So.Top)}buildCapability(){return{requestZoom:(e,n)=>this.requestZoom(e,n),requestZoomBy:(e,n)=>this.requestZoomBy(e,n),zoomIn:()=>this.zoomIn(),zoomOut:()=>this.zoomOut(),zoomToArea:(e,n)=>this.zoomToArea(e,n),enableMarqueeZoom:()=>this.enableMarqueeZoom(),disableMarqueeZoom:()=>this.disableMarqueeZoom(),toggleMarqueeZoom:()=>this.toggleMarqueeZoom(),isMarqueeZoomActive:()=>this.isMarqueeZoomActive(),getState:()=>this.getDocumentStateOrThrow(),forDocument:e=>this.createZoomScope(e),registerMarqueeOnPage:e=>this.registerMarqueeOnPage(e),getPresets:()=>this.presets,onZoomChange:this.zoom$.on,onStateChange:this.state$.on}}createZoomScope(e){return{requestZoom:(n,o)=>this.requestZoom(n,o,e),requestZoomBy:(n,o)=>this.requestZoomBy(n,o,e),zoomIn:()=>this.zoomIn(e),zoomOut:()=>this.zoomOut(e),zoomToArea:(n,o)=>this.zoomToArea(n,o,e),enableMarqueeZoom:()=>this.enableMarqueeZoom(e),disableMarqueeZoom:()=>this.disableMarqueeZoom(e),toggleMarqueeZoom:()=>this.toggleMarqueeZoom(e),isMarqueeZoomActive:()=>this.isMarqueeZoomActive(e),getState:()=>this.getDocumentStateOrThrow(e),onZoomChange:n=>this.zoom$.on(o=>{o.documentId===e&&n(o)}),onStateChange:n=>this.state$.on(o=>{o.documentId===e&&n(o.state)})}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Zoom state not found for document: ${e??"active"}`);return n}requestZoom(e,n,o){this.handleRequest({level:e,center:n},o)}requestZoomBy(e,n,o){const r=o??this.getActiveDocumentId(),i=this.getDocumentStateOrThrow(r).currentZoomLevel,s=this.toZoom(i+e);this.handleRequest({level:s,center:n},r)}zoomIn(e){const n=e??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(n).currentZoomLevel;this.handleRequest({level:r,delta:this.stepFor(r)},n)}zoomOut(e){const n=e??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(n).currentZoomLevel;this.handleRequest({level:r,delta:-this.stepFor(r)},n)}zoomToArea(e,n,o){const r=o??this.getActiveDocumentId();this.handleZoomToArea(r,e,n)}enableMarqueeZoom(e){var n;const o=e??this.getActiveDocumentId();(n=this.interactionManager)==null||n.forDocument(o).activate("marqueeZoom")}disableMarqueeZoom(e){var n;const o=e??this.getActiveDocumentId();(n=this.interactionManager)==null||n.forDocument(o).activateDefaultMode()}toggleMarqueeZoom(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManager)==null?void 0:n.forDocument(o);(r==null?void 0:r.getActiveMode())==="marqueeZoom"?r.activateDefaultMode():r==null||r.activate("marqueeZoom")}isMarqueeZoomActive(e){var n;const o=e??this.getActiveDocumentId();return((n=this.interactionManager)==null?void 0:n.forDocument(o).getActiveMode())==="marqueeZoom"}handleRequest({level:e,delta:n=0,center:o,focus:r=So.Center,align:a="keep"},i){const s=i??this.getActiveDocumentId(),l=this.getDocumentStateOrThrow(s);if(!this.coreState.core.documents[s])return;const u=this.viewport.forDocument(s),d=u.getMetrics(),p=l.currentZoomLevel;if(d.clientWidth===0||d.clientHeight===0)return;const h=typeof e=="number"?e:this.computeZoomForMode(s,e,d);if(h===!1)return;const g=et(h+n,this.minZoom,this.maxZoom),f=Math.floor(g*1e3)/1e3,F=o??{vx:d.clientWidth/2,vy:r===So.Top?0:d.clientHeight/2},{desiredScrollLeft:_,desiredScrollTop:y}=this.computeScrollForZoomChange(s,d,p,f,F,a);!isNaN(_)&&!isNaN(y)&&this.viewportPlugin.setViewportScrollMetrics(s,{scrollLeft:_,scrollTop:y}),this.dispatch(gE(s,typeof e=="number"?f:e,f)),this.dispatchCoreAction(wF(f,s)),this.viewport.isGated(s)&&this.viewport.releaseGate("zoom",s),u.scrollTo({x:_,y,behavior:"instant"});const E={documentId:s,oldZoom:p,newZoom:f,level:e,center:F,desiredScrollLeft:_,desiredScrollTop:y,viewport:d};this.zoom$.emit(E)}computeZoomForMode(e,n,o){if(!this.coreState.core.documents[e])return!1;const a=this.scroll.forDocument(e),i=a?this.scroll.getPageGap():0,s=this.viewport.getViewportGap(),l=a.getSpreadPagesWithRotatedSize();if(!l.length||o.clientWidth===0||o.clientHeight===0)return!1;const c=o.clientWidth-2*s,u=o.clientHeight-2*s;if(c<=0||u<=0)return!1;let d=0,p=0;switch(l.forEach(h=>{const g=h.reduce((F,_,y)=>F+_.rotatedSize.width+(y?i:0),0),f=Math.max(...h.map(F=>F.rotatedSize.height));d=Math.max(d,g),p=Math.max(p,f)}),n){case Mt.FitWidth:return c/d;case Mt.FitPage:return Math.min(c/d,u/p);case Mt.Automatic:return Math.min(c/d,1);default:return 1}}computeScrollForZoomChange(e,n,o,r,a,i="keep"){const l=this.scroll.forDocument(e).getLayout(),c=this.viewport.getViewportGap(),u=l.totalContentSize.width,d=l.totalContentSize.height,p=n.clientWidth-2*c,h=n.clientHeight-2*c,g=(W,J,ue)=>J*ue<W?(W-J*ue)/2:0,f=g(p,u,o),F=g(h,d,o),_=g(p,u,r),y=g(h,d,r),E=(n.scrollLeft+a.vx-c-f)/o,A=(n.scrollTop+a.vy-c-F)/o,T=E*r+c+_,q=A*r+c+y,w=i==="center"?T-n.clientWidth/2:T-a.vx,G=i==="center"?q-n.clientHeight/2:q-a.vy;return{desiredScrollLeft:Math.max(0,w),desiredScrollTop:Math.max(0,G)}}handleZoomToArea(e,n,o){const r=this.coreState.core.documents[e];if(!r)return;const a=r.rotation,s=this.viewport.forDocument(e).getMetrics(),l=this.viewport.getViewportGap(),u=this.getDocumentStateOrThrow(e).currentZoomLevel,d=s.clientWidth-2*l,p=s.clientHeight-2*l,g=this.scroll.forDocument(e).getLayout(),f=g.virtualItems.find(ce=>ce.pageLayouts.some(ee=>ee.pageIndex===n));if(!f)return;const F=f.pageLayouts.find(ce=>ce.pageIndex===n),_=Ki({width:F.width,height:F.height},o,a),y=this.toZoom(Math.min(d/_.size.width,p/_.size.height)),E=f.x+F.x,A=f.y+F.y,T=E+_.origin.x+_.size.width/2,q=A+_.origin.y+_.size.height/2,w=(ce,ee,ge)=>ee*ge<ce?(ce-ee*ge)/2:0,G=w(d,g.totalContentSize.width,u),W=w(p,g.totalContentSize.height,u),J=l+G+T*u-s.scrollLeft,ue=l+W+q*u-s.scrollTop;this.handleRequest({level:y,center:{vx:J,vy:ue},align:"center"},e)}recalcAuto(e,n){const o=this.getDocumentState(e);o&&(o.zoomLevel===Mt.Automatic||o.zoomLevel===Mt.FitPage||o.zoomLevel===Mt.FitWidth)&&this.handleRequest({level:o.zoomLevel,focus:n},e)}normalizeRanges(e){return[...e].filter(n=>n.step>0&&n.max>n.min).sort((n,o)=>n.min-o.min)}stepFor(e){const n=this.zoomRanges.find(o=>e>=o.min&&e<o.max);return n?n.step:this.zoomStep}toZoom(e){return parseFloat(et(e,this.minZoom,this.maxZoom).toFixed(2))}registerMarqueeOnPage(e){if(!this.interactionManager)return this.logger.warn("ZoomPlugin","MissingDependency","Interaction manager plugin not loaded, marquee zoom disabled"),()=>{};const n=this.coreState.core.documents[e.documentId];if(!n||!n.document)return this.logger.warn("ZoomPlugin","DocumentNotFound","Document not found"),()=>{};const o=n.document.pages[e.pageIndex];if(!o)return this.logger.warn("ZoomPlugin","PageNotFound",`Page ${e.pageIndex} not found`),()=>{};const r=PE({pageSize:o.size,scale:e.scale,onPreview:e.callback.onPreview,onCommit:i=>{var s,l;this.zoomToArea(e.pageIndex,i,e.documentId),(l=(s=e.callback).onCommit)==null||l.call(s,i)},onSmallDrag:()=>{var i,s;this.zoomIn(e.documentId),(s=(i=e.callback).onSmallDrag)==null||s.call(i)}});return this.interactionManager.registerHandlers({documentId:e.documentId,modeId:"marqueeZoom",handlers:r,pageIndex:e.pageIndex})}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r&&a&&(r.currentZoomLevel!==a.currentZoomLevel||r.zoomLevel!==a.zoomLevel||r.isMarqueeZoomActive!==a.isMarqueeZoomActive)&&this.state$.emit({documentId:o,state:a})}}async initialize(){this.logger.info("ZoomPlugin","Initialize","Zoom plugin initialized")}async destroy(){this.zoom$.clear(),this.state$.clear(),super.destroy()}};$g.id="zoom";let Ng=$g;const FE={manifest:uE,create:(t,e)=>new Ng(wg,t,e),reducer:mE,initialState:Lg},io="TaskQueue",so="Queue";var me=(t=>(t[t.CRITICAL=3]="CRITICAL",t[t.HIGH=2]="HIGH",t[t.MEDIUM=1]="MEDIUM",t[t.LOW=0]="LOW",t))(me||{});class bE{constructor(e={}){this.queue=[],this.running=0,this.resultTasks=new Map,this.idleListeners=new Set;const{concurrency:n=1,comparator:o,ranker:r,onIdle:a,maxQueueSize:i,autoStart:s=!0,logger:l}=e;this.logger=l??new zo,this.opts={concurrency:Math.max(1,n),comparator:o,ranker:r,onIdle:a??(()=>{}),maxQueueSize:i??Number.POSITIVE_INFINITY,autoStart:s}}setComparator(e){this.opts.comparator=e}setRanker(e){this.opts.ranker=e}size(){return this.queue.length}inFlight(){return this.running}isIdle(){return this.queue.length===0&&this.running===0}async drain(){this.isIdle()||await new Promise(e=>{const n=()=>{this.isIdle()&&(this.offIdle(n),e())};this.onIdle(n)})}notifyIdle(){this.isIdle()&&([...this.idleListeners].forEach(e=>e()),this.idleListeners.clear(),this.opts.onIdle())}onIdle(e){this.idleListeners.add(e)}offIdle(e){this.idleListeners.delete(e)}enqueue(e,n={}){const o=this.generateId(),r=n.priority??1,a=new Ie;if(this.queue.length>=this.opts.maxQueueSize){const l=new Error("Queue is full (maxQueueSize reached).");return a.reject(l),a}this.resultTasks.set(o,a);const i={id:o,priority:r,meta:n.meta??e.meta,executeFactory:e.execute};this.queue.push(i),this.logger.debug(io,so,`Task enqueued: ${o} | Priority: ${r} | Running: ${this.running} | Queued: ${this.queue.length}`);const s=a.abort.bind(a);return a.abort=l=>{this.logger.debug(io,so,`Task aborted: ${o}`),this.cancel(o),s(l)},this.opts.autoStart&&this.process(n.fifo===!0),a}cancel(e){const n=this.queue.length;this.queue=this.queue.filter(o=>o.id===e?(o.cancelled=!0,!1):!0),this.resultTasks.delete(e),n!==this.queue.length&&(this.logger.debug(io,so,`Task cancelled and removed: ${e}`),this.kick())}kick(){queueMicrotask(()=>this.process())}async process(e=!1){for(this.logger.debug(io,so,`process() called | Running: ${this.running} | Concurrency: ${this.opts.concurrency} | Queued: ${this.queue.length}`);this.running<this.opts.concurrency&&this.queue.length>0;){this.logger.debug(io,so,`Starting new task | Running: ${this.running} | Queued: ${this.queue.length}`),e||this.sortQueue();const n=this.queue.shift();if(n.cancelled){this.logger.debug(io,so,`Skipping cancelled task: ${n.id}`);continue}const o=this.resultTasks.get(n.id);o&&(this.running++,(async()=>{let r=null;try{if(r=n.executeFactory(),!r)throw new Error("Task factory returned null/undefined");r.wait(a=>{o.state.stage===0&&o.resolve(a)},a=>{o.state.stage===0&&(a.type==="abort"?o.abort(a.reason):o.reject(a.reason))}),r.onProgress(a=>{o.progress(a)}),await r.toPromise()}catch(a){o.state.stage===0&&o.reject(a)}finally{this.resultTasks.delete(n.id),this.running--,this.logger.debug(io,so,`Task completed: ${n.id} | Running: ${this.running} | Queued: ${this.queue.length}`),this.isIdle()?this.notifyIdle():this.queue.length>0&&this.kick()}})().catch(r=>{this.logger.error(io,so,"Unhandled error in task execution wrapper:",r),this.running=Math.max(0,this.running-1),this.isIdle()?this.notifyIdle():this.queue.length>0&&this.kick()}))}}sortQueue(){const{comparator:e,ranker:n}=this.opts;if(e){this.queue.sort(e);return}const o=new Map,r=a=>n?(o.has(a.id)||o.set(a.id,n(a)),o.get(a.id)):this.defaultRank(a);this.queue.sort((a,i)=>{if(a.priority!==i.priority)return i.priority-a.priority;const s=r(a),l=r(i);return s!==l?l-s:this.extractTime(a.id)-this.extractTime(i.id)})}defaultRank(e){return 0}generateId(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}extractTime(e){const n=Number(e.split("-")[0]);return Number.isFinite(n)?n:0}}const Qs="PdfEngine",Js="Orchestrator";class _E{constructor(e,n){this.executor=e,this.logger=n.logger??new zo,this.options={imageConverter:n.imageConverter,fetcher:n.fetcher??(typeof fetch<"u"?(o,r)=>fetch(o,r):void 0),logger:this.logger},this.workerQueue=new bE({concurrency:1,autoStart:!0,logger:this.logger}),this.logger.debug(Qs,Js,"PdfEngine orchestrator created")}chunkArray(e,n){const o=[];for(let r=0;r<e.length;r+=n)o.push(e.slice(r,r+n));return o}isSupport(e){const n=new Ie;return n.resolve([xr.Create,xr.Read,xr.Update,xr.Delete]),n}destroy(){var e,n;const o=new Ie;try{this.executor.destroy(),(n=(e=this.options.imageConverter).destroy)==null||n.call(e),o.resolve(!0)}catch(r){o.reject({code:ve.Unknown,message:String(r)})}return o}openDocumentUrl(e,n){const o=new Ie;return(async()=>{try{if(!this.options.fetcher)throw new Error("Fetcher is not set");const a=await(await this.options.fetcher(e.url,n==null?void 0:n.requestOptions)).arrayBuffer(),i={id:e.id,content:a};this.openDocumentBuffer(i,{password:n==null?void 0:n.password,normalizeRotation:n==null?void 0:n.normalizeRotation}).wait(s=>o.resolve(s),s=>o.fail(s))}catch(r){o.reject({code:ve.Unknown,message:String(r)})}})(),o}openDocumentBuffer(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.openDocumentBuffer(e,n),meta:{docId:e.id,operation:"openDocumentBuffer"}},{priority:me.CRITICAL})}getMetadata(e){return this.workerQueue.enqueue({execute:()=>this.executor.getMetadata(e),meta:{docId:e.id,operation:"getMetadata"}},{priority:me.MEDIUM})}setMetadata(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.setMetadata(e,n),meta:{docId:e.id,operation:"setMetadata"}},{priority:me.MEDIUM})}getDocPermissions(e){return this.workerQueue.enqueue({execute:()=>this.executor.getDocPermissions(e),meta:{docId:e.id,operation:"getDocPermissions"}},{priority:me.MEDIUM})}getDocUserPermissions(e){return this.workerQueue.enqueue({execute:()=>this.executor.getDocUserPermissions(e),meta:{docId:e.id,operation:"getDocUserPermissions"}},{priority:me.MEDIUM})}getSignatures(e){return this.workerQueue.enqueue({execute:()=>this.executor.getSignatures(e),meta:{docId:e.id,operation:"getSignatures"}},{priority:me.MEDIUM})}getBookmarks(e){return this.workerQueue.enqueue({execute:()=>this.executor.getBookmarks(e),meta:{docId:e.id,operation:"getBookmarks"}},{priority:me.MEDIUM})}setBookmarks(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.setBookmarks(e,n),meta:{docId:e.id,operation:"setBookmarks"}},{priority:me.MEDIUM})}deleteBookmarks(e){return this.workerQueue.enqueue({execute:()=>this.executor.deleteBookmarks(e),meta:{docId:e.id,operation:"deleteBookmarks"}},{priority:me.MEDIUM})}renderPage(e,n,o){return this.renderWithEncoding(()=>this.executor.renderPageRaw(e,n,o),o,e.id,n.index,me.CRITICAL)}renderPageRect(e,n,o,r){return this.renderWithEncoding(()=>this.executor.renderPageRect(e,n,o,r),r,e.id,n.index,me.HIGH)}renderPageRaw(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.renderPageRaw(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageRaw"}},{priority:me.HIGH})}renderPageRectRaw(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.renderPageRect(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageRectRaw"}},{priority:me.HIGH})}renderThumbnail(e,n,o){return this.renderWithEncoding(()=>this.executor.renderThumbnailRaw(e,n,o),o,e.id,n.index,me.MEDIUM)}renderPageAnnotation(e,n,o,r){return this.renderWithEncoding(()=>this.executor.renderPageAnnotationRaw(e,n,o,r),r,e.id,n.index,me.MEDIUM)}renderPageAnnotations(e,n,o){const r=new Ie,a=this.workerQueue.enqueue({execute:()=>this.executor.renderPageAnnotationsRaw(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageAnnotationsRaw"}},{priority:me.MEDIUM}),i=r.abort.bind(r);return r.abort=s=>{a.abort(s),i(s)},a.wait(s=>{r.state.stage===0&&this.encodeAppearanceMap(s,o,r)},s=>{r.state.stage===0&&r.fail(s)}),r}renderPageAnnotationsRaw(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.renderPageAnnotationsRaw(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageAnnotationsRaw"}},{priority:me.MEDIUM})}renderWithEncoding(e,n,o,r,a=me.CRITICAL){const i=new Ie,s=this.workerQueue.enqueue({execute:()=>e(),meta:{docId:o,pageIndex:r,operation:"render"}},{priority:a}),l=i.abort.bind(i);return i.abort=c=>{s.abort(c),l(c)},s.wait(c=>{i.state.stage===0&&this.encodeImage(c,n,i)},c=>{i.state.stage===0&&i.fail(c)}),i}encodeImage(e,n,o){const r=(n==null?void 0:n.imageType)??"image/webp",a=n==null?void 0:n.quality,i={data:new Uint8ClampedArray(e.data),width:e.width,height:e.height};this.options.imageConverter(()=>i,r,a).then(s=>o.resolve(s)).catch(s=>o.reject({code:ve.Unknown,message:String(s)}))}encodeAppearanceMap(e,n,o){const r=(n==null?void 0:n.imageType)??"image/webp",a=n==null?void 0:n.imageQuality,i=u=>{const d={data:new Uint8ClampedArray(u.data),width:u.width,height:u.height};return this.options.imageConverter(()=>d,r,a)},s=[],l={},c=["normal","rollover","down"];for(const[u,d]of Object.entries(e)){const p={};l[u]=p;for(const h of c){const g=d[h];g&&s.push(i(g.data).then(f=>{p[h]={data:f,rect:g.rect}}))}}Promise.all(s).then(()=>{o.state.stage===0&&o.resolve(l)}).catch(u=>{o.state.stage===0&&o.reject({code:ve.Unknown,message:String(u)})})}getPageAnnotations(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageAnnotations(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageAnnotations"}},{priority:me.MEDIUM})}createPageAnnotation(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.createPageAnnotation(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"createPageAnnotation"}},{priority:me.MEDIUM})}updatePageAnnotation(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.updatePageAnnotation(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"updatePageAnnotation"}},{priority:me.MEDIUM})}removePageAnnotation(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.removePageAnnotation(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"removePageAnnotation"}},{priority:me.MEDIUM})}getAllAnnotations(e){const n=this.chunkArray(e.pages,500);this.logger.debug(Qs,Js,`getAllAnnotations: ${e.pages.length} pages in ${n.length} chunks`);const o=new vo({aggregate:r=>Object.assign({},...r)});return n.forEach((r,a)=>{const i=this.workerQueue.enqueue({execute:()=>this.executor.getAnnotationsBatch(e,r),meta:{docId:e.id,operation:"getAnnotationsBatch",chunkSize:r.length}},{priority:me.LOW});i.onProgress(s=>{o.progress({page:s.pageIndex,result:s.result})}),o.addChild(i,a)}),o.finalize(),o}getPageTextRects(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageTextRects(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageTextRects"}},{priority:me.MEDIUM})}searchAllPages(e,n,o){const r=Array.isArray(o==null?void 0:o.flags)?o.flags.reduce((s,l)=>s|l,0):(o==null?void 0:o.flags)??0,a=this.chunkArray(e.pages,25);this.logger.debug(Qs,Js,`searchAllPages: ${e.pages.length} pages in ${a.length} chunks`);const i=new vo({aggregate:s=>{const l=s.flatMap(c=>Object.values(c).flat());return{results:l,total:l.length}}});return a.forEach((s,l)=>{const c=this.workerQueue.enqueue({execute:()=>this.executor.searchBatch(e,s,n,r),meta:{docId:e.id,operation:"searchBatch",chunkSize:s.length}},{priority:me.LOW});c.onProgress(u=>{i.progress({page:u.pageIndex,results:u.result})}),i.addChild(c,l)}),i.finalize(),i}getAttachments(e){return this.workerQueue.enqueue({execute:()=>this.executor.getAttachments(e),meta:{docId:e.id,operation:"getAttachments"}},{priority:me.MEDIUM})}addAttachment(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.addAttachment(e,n),meta:{docId:e.id,operation:"addAttachment"}},{priority:me.MEDIUM})}removeAttachment(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.removeAttachment(e,n),meta:{docId:e.id,operation:"removeAttachment"}},{priority:me.MEDIUM})}readAttachmentContent(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.readAttachmentContent(e,n),meta:{docId:e.id,operation:"readAttachmentContent"}},{priority:me.MEDIUM})}getDocumentJavaScriptActions(e){return this.workerQueue.enqueue({execute:()=>this.executor.getDocumentJavaScriptActions(e),meta:{docId:e.id,operation:"getDocumentJavaScriptActions"}},{priority:me.MEDIUM})}getPageAnnoWidgets(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageAnnoWidgets(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageAnnoWidgets"}},{priority:me.MEDIUM})}getPageWidgetJavaScriptActions(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageWidgetJavaScriptActions(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageWidgetJavaScriptActions"}},{priority:me.MEDIUM})}setFormFieldValue(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.setFormFieldValue(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"setFormFieldValue"}},{priority:me.MEDIUM})}setFormFieldState(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.setFormFieldState(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"setFormFieldState"}},{priority:me.MEDIUM})}renameWidgetField(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.renameWidgetField(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"renameWidgetField"}},{priority:me.MEDIUM})}shareWidgetField(e,n,o,r,a){return this.workerQueue.enqueue({execute:()=>this.executor.shareWidgetField(e,n,o,r,a),meta:{docId:e.id,pageIndex:n.index,operation:"shareWidgetField"}},{priority:me.MEDIUM})}regenerateWidgetAppearances(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.regenerateWidgetAppearances(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"regenerateWidgetAppearances"}},{priority:me.MEDIUM})}flattenPage(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.flattenPage(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"flattenPage"}},{priority:me.MEDIUM})}extractPages(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.extractPages(e,n),meta:{docId:e.id,pageIndexes:n,operation:"extractPages"}},{priority:me.MEDIUM})}extractText(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.extractText(e,n),meta:{docId:e.id,pageIndexes:n,operation:"extractText"}},{priority:me.MEDIUM})}redactTextInRects(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.redactTextInRects(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"redactTextInRects"}},{priority:me.MEDIUM})}applyRedaction(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.applyRedaction(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"applyRedaction"}},{priority:me.MEDIUM})}applyAllRedactions(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.applyAllRedactions(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"applyAllRedactions"}},{priority:me.MEDIUM})}flattenAnnotation(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.flattenAnnotation(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"flattenAnnotation"}},{priority:me.MEDIUM})}getTextSlices(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getTextSlices(e,n),meta:{docId:e.id,slices:n,operation:"getTextSlices"}},{priority:me.MEDIUM})}getPageGlyphs(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageGlyphs(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageGlyphs"}},{priority:me.MEDIUM})}getPageGeometry(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageGeometry(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageGeometry"}},{priority:me.MEDIUM})}getPageTextRuns(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageTextRuns(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageTextRuns"}},{priority:me.MEDIUM})}merge(e){return this.workerQueue.enqueue({execute:()=>this.executor.merge(e),meta:{docId:e.map(n=>n.id).join(","),operation:"merge"}},{priority:me.MEDIUM})}mergePages(e){return this.workerQueue.enqueue({execute:()=>this.executor.mergePages(e),meta:{docId:e.map(n=>n.docId).join(","),operation:"mergePages"}},{priority:me.MEDIUM})}preparePrintDocument(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.preparePrintDocument(e,n),meta:{docId:e.id,operation:"preparePrintDocument"}},{priority:me.MEDIUM})}saveAsCopy(e){return this.workerQueue.enqueue({execute:()=>this.executor.saveAsCopy(e),meta:{docId:e.id,operation:"saveAsCopy"}},{priority:me.MEDIUM})}closeDocument(e){return this.workerQueue.enqueue({execute:()=>this.executor.closeDocument(e),meta:{docId:e.id,operation:"closeDocument"}},{priority:me.MEDIUM})}closeAllDocuments(){return this.workerQueue.enqueue({execute:()=>this.executor.closeAllDocuments(),meta:{operation:"closeAllDocuments"}},{priority:me.MEDIUM})}setDocumentEncryption(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.setDocumentEncryption(e,n,o,r),meta:{docId:e.id,operation:"setDocumentEncryption"}},{priority:me.MEDIUM})}removeEncryption(e){return this.workerQueue.enqueue({execute:()=>this.executor.removeEncryption(e),meta:{docId:e.id,operation:"removeEncryption"}},{priority:me.MEDIUM})}unlockOwnerPermissions(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.unlockOwnerPermissions(e,n),meta:{docId:e.id,operation:"unlockOwnerPermissions"}},{priority:me.MEDIUM})}isEncrypted(e){return this.workerQueue.enqueue({execute:()=>this.executor.isEncrypted(e),meta:{docId:e.id,operation:"isEncrypted"}},{priority:me.MEDIUM})}isOwnerUnlocked(e){return this.workerQueue.enqueue({execute:()=>this.executor.isOwnerUnlocked(e),meta:{docId:e.id,operation:"isOwnerUnlocked"}},{priority:me.MEDIUM})}}class jg extends Error{constructor(e){super(e),this.name="ImageConverterError"}}const yE=(t,e="image/webp",n)=>{if(typeof document>"u")return Promise.reject(new jg("document is not available. This converter requires a browser environment."));const o=t(),r=new ImageData(o.data,o.width,o.height);return new Promise((a,i)=>{const s=document.createElement("canvas");s.width=r.width,s.height=r.height,s.getContext("2d").putImageData(r,0,0),s.toBlob(l=>{l?a(l):i(new jg("Canvas toBlob returned null"))},e,n)})};function vE(t){const e=async(n,o="image/webp",r)=>{try{const a=n(),i=new Uint8ClampedArray(a.data);return await t.encode({data:i,width:a.width,height:a.height},o,r)}catch(a){return console.warn("Worker encoding failed, falling back to main-thread Canvas:",a),yE(n,o,r)}};return e.destroy=()=>t.destroy(),e}const DE=[{file:"NotoSansJP-Thin.otf",weight:100},{file:"NotoSansJP-Light.otf",weight:300},{file:"NotoSansJP-DemiLight.otf",weight:350},{file:"NotoSansJP-Regular.otf",weight:400},{file:"NotoSansJP-Medium.otf",weight:500},{file:"NotoSansJP-Bold.otf",weight:700},{file:"NotoSansJP-Black.otf",weight:900}],SE=[{file:"NotoSansKR-Thin.otf",weight:100},{file:"NotoSansKR-Light.otf",weight:300},{file:"NotoSansKR-DemiLight.otf",weight:350},{file:"NotoSansKR-Regular.otf",weight:400},{file:"NotoSansKR-Medium.otf",weight:500},{file:"NotoSansKR-Bold.otf",weight:700},{file:"NotoSansKR-Black.otf",weight:900}],EE=[{file:"NotoSansHans-Light.otf",weight:300},{file:"NotoSansHans-DemiLight.otf",weight:350},{file:"NotoSansHans-Regular.otf",weight:400},{file:"NotoSansHans-Medium.otf",weight:500},{file:"NotoSansHans-Bold.otf",weight:700}],AE=[{file:"NotoSansHant-Thin.otf",weight:100},{file:"NotoSansHant-Light.otf",weight:300},{file:"NotoSansHant-DemiLight.otf",weight:350},{file:"NotoSansHant-Regular.otf",weight:400},{file:"NotoSansHant-Medium.otf",weight:500},{file:"NotoSansHant-Bold.otf",weight:700},{file:"NotoSansHant-Black.otf",weight:900}],xE=[{file:"NotoNaskhArabic-Regular.ttf",weight:400},{file:"NotoNaskhArabic-Bold.ttf",weight:700}],CE=[{file:"NotoSansHebrew-Regular.ttf",weight:400},{file:"NotoSansHebrew-Bold.ttf",weight:700}],el=[{file:"NotoSans-Thin.ttf",weight:100},{file:"NotoSans-ThinItalic.ttf",weight:100,italic:!0},{file:"NotoSans-ExtraLight.ttf",weight:200},{file:"NotoSans-ExtraLightItalic.ttf",weight:200,italic:!0},{file:"NotoSans-Light.ttf",weight:300},{file:"NotoSans-LightItalic.ttf",weight:300,italic:!0},{file:"NotoSans-Regular.ttf",weight:400},{file:"NotoSans-Italic.ttf",weight:400,italic:!0},{file:"NotoSans-Medium.ttf",weight:500},{file:"NotoSans-MediumItalic.ttf",weight:500,italic:!0},{file:"NotoSans-SemiBold.ttf",weight:600},{file:"NotoSans-SemiBoldItalic.ttf",weight:600,italic:!0},{file:"NotoSans-Bold.ttf",weight:700},{file:"NotoSans-BoldItalic.ttf",weight:700,italic:!0},{file:"NotoSans-ExtraBold.ttf",weight:800},{file:"NotoSans-ExtraBoldItalic.ttf",weight:800,italic:!0},{file:"NotoSans-Black.ttf",weight:900},{file:"NotoSans-BlackItalic.ttf",weight:900,italic:!0}],En="RemoteExecutor",An="Worker",Ug=class di{constructor(e,n){this.worker=e,this.pendingRequests=new Map,this.requestCounter=0,this.handleMessage=o=>{const r=o.data;if(r.type==="ready"){this.logger.debug(En,An,"Worker is ready"),this.readyTask.resolve(!0);return}const a=this.pendingRequests.get(r.id);if(!a){this.logger.warn(En,An,`Received response for unknown request: ${r.id}`);return}switch(r.type){case"result":this.logger.debug(En,An,`Received result for ${r.id}`),a.resolve(r.data),this.pendingRequests.delete(r.id);break;case"error":this.logger.debug(En,An,`Received error for ${r.id}:`,r.error),r.error?a.fail(r.error):a.reject({code:ve.Unknown,message:"Unknown error"}),this.pendingRequests.delete(r.id);break;case"progress":this.logger.debug(En,An,`Received progress for ${r.id}`),a.progress(r.progress);break}},this.logger=n.logger??new zo,this.worker.addEventListener("message",this.handleMessage),this.readyTask=new Ie,this.pendingRequests.set(di.READY_TASK_ID,this.readyTask),this.worker.postMessage({id:di.READY_TASK_ID,type:"wasmInit",wasmUrl:n.wasmUrl,logger:n.logger?os(n.logger):void 0,fontFallback:n.fontFallback}),this.logger.debug(En,An,"RemoteExecutor created")}generateId(){return`req-${Date.now()}-${this.requestCounter++}`}send(e,n){const o=this.generateId(),r=new Ie,a={id:o,type:"execute",method:e,args:n};return this.readyTask.wait(()=>{this.pendingRequests.set(o,r),this.logger.debug(En,An,`Sending ${e} request:`,o),this.worker.postMessage(a)},i=>{this.logger.error(En,An,`Worker init failed, rejecting ${e}:`,i),r.reject({code:ve.Initialization,message:"Worker initialization failed"})}),r}destroy(){this.worker.removeEventListener("message",this.handleMessage),this.pendingRequests.forEach((e,n)=>{n!==di.READY_TASK_ID&&(e.abort("Worker destroyed"),this.logger.debug(En,An,`Aborted pending request: ${n}`))}),this.pendingRequests.clear(),this.worker.terminate(),this.logger.debug(En,An,"RemoteExecutor destroyed")}openDocumentBuffer(e,n){return this.send("openDocumentBuffer",[e,n])}getMetadata(e){return this.send("getMetadata",[e])}setMetadata(e,n){return this.send("setMetadata",[e,n])}getDocPermissions(e){return this.send("getDocPermissions",[e])}getDocUserPermissions(e){return this.send("getDocUserPermissions",[e])}getSignatures(e){return this.send("getSignatures",[e])}getBookmarks(e){return this.send("getBookmarks",[e])}setBookmarks(e,n){return this.send("setBookmarks",[e,n])}deleteBookmarks(e){return this.send("deleteBookmarks",[e])}renderPageRaw(e,n,o){return this.send("renderPageRaw",[e,n,o])}renderPageRect(e,n,o,r){return this.send("renderPageRect",[e,n,o,r])}renderThumbnailRaw(e,n,o){return this.send("renderThumbnailRaw",[e,n,o])}renderPageAnnotationRaw(e,n,o,r){return this.send("renderPageAnnotationRaw",[e,n,o,r])}renderPageAnnotationsRaw(e,n,o){return this.send("renderPageAnnotationsRaw",[e,n,o])}getPageAnnotationsRaw(e,n){return this.send("getPageAnnotationsRaw",[e,n])}getPageAnnotations(e,n){return this.send("getPageAnnotations",[e,n])}createPageAnnotation(e,n,o,r){return this.send("createPageAnnotation",[e,n,o,r])}updatePageAnnotation(e,n,o,r){return this.send("updatePageAnnotation",[e,n,o,r])}removePageAnnotation(e,n,o){return this.send("removePageAnnotation",[e,n,o])}getPageTextRects(e,n){return this.send("getPageTextRects",[e,n])}searchInPage(e,n,o,r){return this.send("searchInPage",[e,n,o,r])}getAnnotationsBatch(e,n){return this.send("getAnnotationsBatch",[e,n])}searchBatch(e,n,o,r){return this.send("searchBatch",[e,n,o,r])}getAttachments(e){return this.send("getAttachments",[e])}addAttachment(e,n){return this.send("addAttachment",[e,n])}removeAttachment(e,n){return this.send("removeAttachment",[e,n])}readAttachmentContent(e,n){return this.send("readAttachmentContent",[e,n])}getDocumentJavaScriptActions(e){return this.send("getDocumentJavaScriptActions",[e])}getPageAnnoWidgets(e,n){return this.send("getPageAnnoWidgets",[e,n])}getPageWidgetJavaScriptActions(e,n){return this.send("getPageWidgetJavaScriptActions",[e,n])}setFormFieldValue(e,n,o,r){return this.send("setFormFieldValue",[e,n,o,r])}setFormFieldState(e,n,o,r){return this.send("setFormFieldState",[e,n,o,r])}renameWidgetField(e,n,o,r){return this.send("renameWidgetField",[e,n,o,r])}shareWidgetField(e,n,o,r,a){return this.send("shareWidgetField",[e,n,o,r,a])}regenerateWidgetAppearances(e,n,o){return this.send("regenerateWidgetAppearances",[e,n,o])}flattenPage(e,n,o){return this.send("flattenPage",[e,n,o])}extractPages(e,n){return this.send("extractPages",[e,n])}extractText(e,n){return this.send("extractText",[e,n])}redactTextInRects(e,n,o,r){return this.send("redactTextInRects",[e,n,o,r])}applyRedaction(e,n,o){return this.send("applyRedaction",[e,n,o])}applyAllRedactions(e,n){return this.send("applyAllRedactions",[e,n])}flattenAnnotation(e,n,o){return this.send("flattenAnnotation",[e,n,o])}getTextSlices(e,n){return this.send("getTextSlices",[e,n])}getPageGlyphs(e,n){return this.send("getPageGlyphs",[e,n])}getPageGeometry(e,n){return this.send("getPageGeometry",[e,n])}getPageTextRuns(e,n){return this.send("getPageTextRuns",[e,n])}merge(e){return this.send("merge",[e])}mergePages(e){return this.send("mergePages",[e])}preparePrintDocument(e,n){return this.send("preparePrintDocument",[e,n])}saveAsCopy(e){return this.send("saveAsCopy",[e])}closeDocument(e){return this.send("closeDocument",[e])}closeAllDocuments(){return this.send("closeAllDocuments",[])}setDocumentEncryption(e,n,o,r){return this.send("setDocumentEncryption",[e,n,o,r])}removeEncryption(e){return this.send("removeEncryption",[e])}unlockOwnerPermissions(e,n){return this.send("unlockOwnerPermissions",[e,n])}isEncrypted(e){return this.send("isEncrypted",[e])}isOwnerUnlocked(e){return this.send("isOwnerUnlocked",[e])}};Ug.READY_TASK_ID="0";let TE=Ug;const zn="ImageEncoderPool",Wn="Encoder";class ME{constructor(e=2,n,o){this.poolSize=e,this.workerUrl=n,this.workers=[],this.pendingTasks=new Map,this.nextWorkerId=0,this.requestCounter=0,this.logger=o??new zo,this.initialize()}initialize(){this.logger.debug(zn,Wn,`Creating worker pool with ${this.poolSize} workers`);for(let e=0;e<this.poolSize;e++)try{const n=new Worker(this.workerUrl,{type:"module"});n.onmessage=this.handleWorkerMessage.bind(this),n.onerror=this.handleWorkerError.bind(this),this.workers.push(n),this.logger.debug(zn,Wn,`Worker ${e} created successfully`)}catch(n){this.logger.error(zn,Wn,`Failed to create worker ${e}:`,n)}}handleWorkerMessage(e){const n=e.data,o=this.pendingTasks.get(n.id);if(!o){this.logger.warn(zn,Wn,`Received response for unknown task: ${n.id}`);return}if(this.pendingTasks.delete(n.id),n.type==="result")o.resolve(n.data);else{const r=n.data;o.reject(new Error(r.message))}}handleWorkerError(e){this.logger.error(zn,Wn,"Worker error:",e.message)}getNextWorker(){if(this.workers.length===0)return null;const e=this.workers[this.nextWorkerId];return this.nextWorkerId=(this.nextWorkerId+1)%this.workers.length,e}encode(e,n="image/webp",o){return new Promise((r,a)=>{const i=this.getNextWorker();if(!i){a(new Error("No workers available in the pool"));return}const s=`encode-${Date.now()}-${this.requestCounter++}`;this.pendingTasks.set(s,{resolve:r,reject:a});const l={id:s,type:"encode",data:{imageData:{data:e.data,width:e.width,height:e.height},imageType:n,quality:o}};this.logger.debug(zn,Wn,`Sending encoding request ${s} (${e.width}x${e.height})`),i.postMessage(l,[e.data.buffer])})}destroy(){this.logger.debug(zn,Wn,"Destroying worker pool"),this.pendingTasks.forEach((e,n)=>{e.reject(new Error("Worker pool destroyed")),this.logger.debug(zn,Wn,`Rejected pending task: ${n}`)}),this.pendingTasks.clear(),this.workers.forEach((e,n)=>{e.terminate(),this.logger.debug(zn,Wn,`Worker ${n} terminated`)}),this.workers=[]}get activeWorkers(){return this.workers.length}get pendingTasksCount(){return this.pendingTasks.size}}function RE(t,e){const n=e instanceof Object&&"debug"in e?{logger:e}:e||{},{logger:o,encoderPoolSize:r,fontFallback:a}=n,i=new Worker(URL.createObjectURL(new Blob([`var Rotation = /* @__PURE__ */ ((Rotation2) => {
25
+ </svg>`;return`url("data:image/svg+xml;utf8,${encodeURIComponent(l)}")`});return(i,s)=>(v(!0),C(pe,null,tt(t.segmentRects,(l,c)=>(v(),C("div",{key:c,onPointerdown:s[0]||(s[0]=(...u)=>t.onClick&&t.onClick(...u)),style:Z({position:"absolute",left:`${(t.rect?l.origin.x-t.rect.origin.x:l.origin.x)*t.scale}px`,top:`${(t.rect?l.origin.y-t.rect.origin.y:l.origin.y)*t.scale}px`,width:`${l.size.width*t.scale}px`,height:`${l.size.height*t.scale}px`,background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[t.appearanceActive?ae("",!0):(v(),C("div",{key:0,style:Z({position:"absolute",left:0,bottom:0,width:"100%",height:`${o.value*2}px`,backgroundImage:a.value,backgroundRepeat:"repeat-x",backgroundSize:`${r.value}px ${o.value*2}px`,opacity:t.opacity,pointerEvents:"none"})},null,4))],36))),128))}}),mD=ie({__name:"squiggly-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(Bp,xe(t.currentObject,{scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["scale","onClick","appearanceActive"]))}}),PD=["width","height","viewBox"],FD=["d"],bD=["d","fill","stroke","opacity"],yD=ie({...{inheritAttrs:!1},__name:"caret",props:{isSelected:{type:Boolean},strokeColor:{default:"#000000"},opacity:{default:1},rect:{},scale:{},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>e.rect.size.width),o=P(()=>e.rect.size.height),r=P(()=>{const s=n.value,l=o.value,c=s/2;return[`M 0 ${l}`,`C ${s*.27} ${l} ${c} ${l-l*.44} ${c} 0`,`C ${c} ${l-l*.44} ${s-s*.27} ${l} ${s} ${l}`,"Z"].join(" ")}),a=P(()=>n.value*e.scale),i=P(()=>o.value*e.scale);return(s,l)=>(v(),C("svg",{style:Z({position:"absolute",width:a.value,height:i.value,pointerEvents:"none",zIndex:2}),width:a.value,height:i.value,viewBox:`0 0 ${n.value} ${o.value}`,overflow:"visible"},[m("path",{d:r.value,fill:"transparent",stroke:"transparent","stroke-width":4,onPointerdown:l[0]||(l[0]=(...c)=>t.onClick&&t.onClick(...c)),style:Z({cursor:t.isSelected?"move":t.onClick?"pointer":"default",pointerEvents:t.onClick?t.isSelected?"none":"visible":"none"})},null,44,FD),t.appearanceActive?ae("",!0):(v(),C("path",{key:0,d:r.value,fill:t.strokeColor,stroke:t.strokeColor,"stroke-width":.5,opacity:t.opacity,"fill-rule":"evenodd",style:{pointerEvents:"none"}},null,8,bD))],12,PD))}}),_D=ie({__name:"caret-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(yD,xe(t.currentObject,{isSelected:t.isSelected,scale:t.scale,onClick:t.onClick,appearanceActive:t.appearanceActive}),null,16,["isSelected","scale","onClick","appearanceActive"]))}}),vD={key:0,style:{position:"absolute",inset:0,pointerEvents:"none"},viewBox:"0 0 20 20",width:"100%",height:"100%"},DD=["fill","opacity","stroke"],SD=["stroke"],ED=["stroke"],AD=["stroke"],xD=ie({__name:"text",props:{isSelected:{type:Boolean},color:{default:"#facc15"},opacity:{default:1},onClick:{},appearanceActive:{type:Boolean,default:!1}},setup(t){const e=t,n=P(()=>PF(e.color));return(o,r)=>(v(),C("div",{style:Z({position:"absolute",inset:0,zIndex:2,pointerEvents:t.onClick?t.isSelected?"none":"auto":"none",cursor:t.isSelected?"move":t.onClick?"pointer":"default"}),onPointerdown:r[0]||(r[0]=(...a)=>t.onClick&&t.onClick(...a))},[t.appearanceActive?ae("",!0):(v(),C("svg",vD,[m("path",{d:"M 0.5 15.5 L 0.5 0.5 L 19.5 0.5 L 19.5 15.5 L 8.5 15.5 L 6.5 19.5 L 4.5 15.5 Z",fill:t.color,opacity:t.opacity,stroke:n.value,"stroke-width":"1","stroke-linejoin":"miter"},null,8,DD),m("line",{x1:"2.5",y1:"4.25",x2:"17.5",y2:"4.25",stroke:n.value,"stroke-width":"1"},null,8,SD),m("line",{x1:"2.5",y1:"8",x2:"17.5",y2:"8",stroke:n.value,"stroke-width":"1"},null,8,ED),m("line",{x1:"2.5",y1:"11.75",x2:"17.5",y2:"11.75",stroke:n.value,"stroke-width":"1"},null,8,AD)]))],36))}}),CD=ie({__name:"text-renderer",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){return(e,n)=>(v(),he(xD,{isSelected:t.isSelected,color:t.currentObject.strokeColor??t.currentObject.color,opacity:t.currentObject.opacity,onClick:t.onClick,appearanceActive:t.appearanceActive},null,8,["isSelected","color","opacity","onClick","appearanceActive"]))}}),TD=[_t({id:"ink",matches:t=>t.type===M.INK,component:Fv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),_t({id:"square",matches:t=>t.type===M.SQUARE,component:Sv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),_t({id:"circle",matches:t=>t.type===M.CIRCLE,component:Mv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),_t({id:"line",matches:t=>t.type===M.LINE,component:$v,vertexConfig:{extractVertices:t=>[t.linePoints.start,t.linePoints.end],transformAnnotation:(t,e)=>({...t,linePoints:{start:e[0],end:e[1]}})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),_t({id:"polyline",matches:t=>t.type===M.POLYLINE,component:Vv,vertexConfig:{extractVertices:t=>t.vertices,transformAnnotation:(t,e)=>({...t,vertices:e})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),_t({id:"polygon",matches:t=>t.type===M.POLYGON,component:Jv,vertexConfig:{extractVertices:t=>t.vertices,transformAnnotation:(t,e)=>({...t,vertices:e})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),_t({id:"highlight",matches:t=>t.type===M.HIGHLIGHT,component:hD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},defaultBlendMode:it.Multiply}),_t({id:"underline",matches:t=>t.type===M.UNDERLINE,component:gD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),_t({id:"strikeout",matches:t=>t.type===M.STRIKEOUT,component:fD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),_t({id:"squiggly",matches:t=>t.type===M.SQUIGGLY,component:mD,zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),_t({id:"text",matches:t=>t.type===M.TEXT&&!t.inReplyToId,component:CD,interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1}}),_t({id:"caret",matches:t=>t.type===M.CARET,component:_D,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),_t({id:"freeText",matches:t=>t.type===M.FREETEXT,component:nD,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(t,{isEditing:e})=>t&&!e,onDoubleClick:(t,e)=>e(t)}),_t({id:"stamp",matches:t=>t.type===M.STAMP,component:iD,useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),_t({id:"link",matches:t=>t.type===M.LINK,component:pD,renderPreview:gv,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,selectOverride:(t,e,n)=>{if(t.stopPropagation(),n.clearSelection(),e.object.inReplyToId){const o=n.allAnnotations.find(r=>r.object.id===e.object.inReplyToId);if(o){n.selectAnnotation(o.object.pageIndex,o.object.id);return}}n.selectAnnotation(n.pageIndex,e.object.id)},hideSelectionMenu:t=>!!t.inReplyToId,renderLocked:hv})],MD=ie({__name:"annotations",props:{documentId:{},pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},resizeUi:{},vertexUi:{},rotationUi:{},selectionOutlineColor:{},selectionOutline:{},groupSelectionOutline:{},selectionMenu:{type:Function},groupSelectionMenu:{type:Function},annotationRenderers:{}},setup(t){const e=t,{provides:n}=Bn(),{provides:o}=Us(),r=ln([]),a=ln([]),{register:i}=__({documentId:()=>e.documentId,pageIndex:e.pageIndex}),s=Q(null),l=ln({}),c=ln({type:jn.None});let u=e.scale;const d=P(()=>n.value?n.value.forDocument(e.documentId):null),p=P(()=>a.value.length>1),h=P(()=>{const O=e.annotationRenderers??[],H=new Set(O.map(V=>V.id));return[...O,...TD.filter(V=>!H.has(V.id))]}),g=O=>h.value.find(H=>H.matches(O.object))??null,f=O=>{if(O.dictMode||O.object.rotation&&O.object.unrotatedRect)return null;const H=l.value[O.object.id];return H!=null&&H.normal?H:null};Se([d,()=>e.pageIndex],([O,H],V,se)=>{if(!O){r.value=[],a.value=[];return}const L=Re=>{r.value=Ib(Re,H),a.value=ed(Re),c.value=Re.locked};L(O.getState());const de=O.onStateChange(L);se(de);const Pe=O.onAnnotationEvent(Re=>{Re.type==="create"&&Re.editAfterCreate&&(s.value=Re.annotation.id)});se(Pe)},{immediate:!0}),Se([d,()=>e.pageIndex,()=>e.scale],([O,H,V],se,L)=>{if(!O){l.value={};return}u!==V&&(O.invalidatePageAppearances(H),u=V);let de=!1;L(()=>{de=!0}),O.getPageAppearances(H,{scaleFactor:V,dpr:typeof window<"u"?window.devicePixelRatio:1}).wait(Re=>{de||(l.value=Re)},()=>{de||(l.value={})})},{immediate:!0});const F=P(()=>r.value.map(O=>{var H;const V=g(O);if(!V)return null;const se=((H=d.value)==null?void 0:H.findToolForAnnotation(O.object))??null,L=Ss(se),de=Qu(O.object)||za(L,c.value);return de&&V.hiddenWhenLocked?null:{annotation:O,renderer:V,tool:se,locked:de}}).filter(O=>O!==null)),y=(O,H,V)=>{var se;if(V)return!1;const L=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object),de=H.interactionDefaults,Pe=s.value===O.object.id,Re=tn(L==null?void 0:L.interaction.isDraggable,O.object,(de==null?void 0:de.isDraggable)??!0);return H.isDraggable?H.isDraggable(Re,{isEditing:Pe}):Re},_=(O,H,V)=>{var se,L;if(V)return!1;const de=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object);return tn(de==null?void 0:de.interaction.isResizable,O.object,((L=H.interactionDefaults)==null?void 0:L.isResizable)??!1)},E=(O,H)=>{var V,se;const L=(V=d.value)==null?void 0:V.findToolForAnnotation(O.object);return tn(L==null?void 0:L.interaction.lockAspectRatio,O.object,((se=H.interactionDefaults)==null?void 0:se.lockAspectRatio)??!1)},A=(O,H,V)=>{var se,L;if(V)return!1;const de=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object);return tn(de==null?void 0:de.interaction.isRotatable,O.object,((L=H.interactionDefaults)==null?void 0:L.isRotatable)??!1)},T=(O,H,V)=>{var se;if(!V&&!((se=H.hideSelectionMenu)!=null&&se.call(H,O.object))&&!p.value)return e.selectionMenu},q=O=>{O.stopPropagation()},w=(O,H,V)=>{if(V)return q;if(H.selectOverride){const se={defaultSelect:W,selectAnnotation:(L,de)=>{var Pe;return(Pe=d.value)==null?void 0:Pe.selectAnnotation(L,de)},clearSelection:()=>{var L;return(L=o.value)==null?void 0:L.clear()},allAnnotations:r.value,pageIndex:e.pageIndex};return L=>H.selectOverride(L,O,se)}return se=>W(se,O)},G=(O,H)=>{H.target===H.currentTarget&&d.value&&(s.value&&r.value.some(V=>V.object.id===s.value)&&H.stopImmediatePropagation(),d.value.deselectAnnotation(),s.value=null)},W=(O,H)=>{O.stopPropagation(),d.value&&o.value&&(o.value.clear(),("metaKey"in O?O.metaKey||O.ctrlKey:!1)?d.value.toggleSelection(e.pageIndex,H.object.id):d.value.selectAnnotation(e.pageIndex,H.object.id),H.object.id!==s.value&&(s.value=null))},J=O=>{s.value=O},ue={onPointerDown:G};Se(d,(O,H,V)=>{if(!O)return;const se=i(ue);se&&V(se)},{immediate:!0});const ce=P(()=>r.value.filter(O=>a.value.includes(O.object.id))),ee=P(()=>ce.value.length<2?!1:ce.value.every(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.isGroupDraggable,O.object,!0),L=tn(V==null?void 0:V.interaction.isDraggable,O.object,!0);return(V==null?void 0:V.interaction.isGroupDraggable)!==void 0?se:L})),ge=P(()=>ce.value.length<2?!1:ce.value.every(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.isGroupResizable,O.object,!0),L=tn(V==null?void 0:V.interaction.isResizable,O.object,!0);return(V==null?void 0:V.interaction.isGroupResizable)!==void 0?se:L})),ye=P(()=>ce.value.length<2?!1:ce.value.every(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.isGroupRotatable,O.object,!0),L=tn(V==null?void 0:V.interaction.isRotatable,O.object,!0);return(V==null?void 0:V.interaction.isGroupRotatable)!==void 0?se:L})),Ee=P(()=>ce.value.length<2?!1:ce.value.some(O=>{var H;const V=(H=d.value)==null?void 0:H.findToolForAnnotation(O.object),se=tn(V==null?void 0:V.interaction.lockGroupAspectRatio,O.object,!1),L=tn(V==null?void 0:V.interaction.lockAspectRatio,O.object,!1);return(V==null?void 0:V.interaction.lockGroupAspectRatio)!==void 0?se:L})),Te=P(()=>!d.value||a.value.length<2?!1:d.value.getSelectedAnnotations().every(H=>H.object.pageIndex===e.pageIndex)),oe=(O,H,V)=>{if(!V&&O.onDoubleClick)return se=>{se.stopPropagation(),O.onDoubleClick(H.object.id,J)}},He=(O,H)=>ka(O.object.blendMode??H.defaultBlendMode??it.Normal),ft=(O,H,V)=>{var se,L;if(V&&H.renderLocked)return;const de=(se=d.value)==null?void 0:se.findToolForAnnotation(O.object);return((L=de==null?void 0:de.behavior)==null?void 0:L.useAppearanceStream)??H.useAppearanceStream??!0?f(O):void 0},Ve=P(()=>{const{selectionMenu:O,groupSelectionMenu:H,groupSelectionOutline:V,annotationRenderers:se,...L}=e;return L});return(O,H)=>(v(),C(pe,null,[(v(!0),C(pe,null,tt(F.value,({annotation:V,renderer:se,locked:L})=>{var de;return v(),he(rv,xe({key:V.object.id,trackedAnnotation:V,isSelected:L?!1:a.value.includes(V.object.id),isEditing:L?!1:s.value===V.object.id,isMultiSelected:L?!1:p.value,isDraggable:y(V,se,L),isResizable:_(V,se,L),lockAspectRatio:E(V,se),isRotatable:A(V,se,L),vertexConfig:L?void 0:se.vertexConfig,selectionMenu:T(V,se,L),onSelect:w(V,se,L),onDoubleClick:oe(se,V,L),zIndex:se.zIndex,blendMode:He(V,se),style:(de=se.containerStyle)==null?void 0:de.call(se,V.object),appearance:ft(V,se,L)},{ref_for:!0},Ve.value),Im({default:We(({annotation:Pe,appearanceActive:Re})=>[(v(),he(Fn(L&&se.renderLocked?se.renderLocked:se.component),{annotation:V,currentObject:Pe,isSelected:L?!1:a.value.includes(V.object.id),isEditing:L?!1:s.value===V.object.id,scale:t.scale,pageIndex:t.pageIndex,documentId:t.documentId,onClick:L?void 0:w(V,se,L),appearanceActive:Re},null,8,["annotation","currentObject","isSelected","isEditing","scale","pageIndex","documentId","onClick","appearanceActive"]))]),"resize-handle":We(Pe=>[$e(O.$slots,"resize-handle",xe({ref_for:!0},Pe))]),"vertex-handle":We(Pe=>[$e(O.$slots,"vertex-handle",xe({ref_for:!0},Pe))]),"rotation-handle":We(Pe=>[$e(O.$slots,"rotation-handle",xe({ref_for:!0},Pe))]),_:2},[p.value?void 0:{name:"selection-menu",fn:We(Pe=>[$e(O.$slots,"selection-menu",xe({ref_for:!0},Pe))]),key:"0"}]),1040,["trackedAnnotation","isSelected","isEditing","isMultiSelected","isDraggable","isResizable","lockAspectRatio","isRotatable","vertexConfig","selectionMenu","onSelect","onDoubleClick","zIndex","blendMode","style","appearance"])}),128)),Te.value&&ce.value.length>=2?(v(),he(cv,{key:0,documentId:t.documentId,pageIndex:t.pageIndex,scale:t.scale,rotation:t.rotation,pageWidth:t.pageWidth,pageHeight:t.pageHeight,selectedAnnotations:ce.value,isDraggable:ee.value,isResizable:ge.value,isRotatable:ye.value,lockAspectRatio:Ee.value,resizeUi:t.resizeUi,rotationUi:t.rotationUi,selectionOutlineColor:t.selectionOutlineColor,selectionOutline:t.groupSelectionOutline??t.selectionOutline,groupSelectionMenu:t.groupSelectionMenu},{"selection-menu":We(V=>[$e(O.$slots,"group-selection-menu",zt(Qt(V)))]),"resize-handle":We(V=>[$e(O.$slots,"resize-handle",zt(Qt(V)))]),"rotation-handle":We(V=>[$e(O.$slots,"rotation-handle",zt(Qt(V)))]),_:3},8,["documentId","pageIndex","scale","rotation","pageWidth","pageHeight","selectedAnnotations","isDraggable","isResizable","isRotatable","lockAspectRatio","resizeUi","rotationUi","selectionOutlineColor","selectionOutline","groupSelectionMenu"])):ae("",!0)],64))}}),RD=ie({__name:"text-markup",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{provides:n}=Us(),{provides:o}=Bn(),r=Q([]),a=Q(null),i=Q(null);Xn(l=>{const c=[];if(n.value){const u=n.value.forDocument(e.documentId),d=u.onSelectionChange(()=>{r.value=u.getHighlightRectsForPage(e.pageIndex),a.value=u.getBoundingRectForPage(e.pageIndex)});c.push(d)}if(o.value){const u=o.value.forDocument(e.documentId);i.value=u.getActiveTool();const d=u.onActiveToolChange(p=>i.value=p);c.push(d)}l(()=>{c.forEach(u=>u())})});const s=P(()=>{if(!i.value)return ka(it.Normal);const l=i.value.defaults.type===M.HIGHLIGHT?it.Multiply:it.Normal;return ka(i.value.defaults.blendMode??l)});return(l,c)=>a.value&&i.value?(v(),C("div",{key:0,style:Z({mixBlendMode:s.value,pointerEvents:"none",position:"absolute",inset:0})},[i.value.defaults.type===I(M).HIGHLIGHT?(v(),he(Np,{key:0,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):i.value.defaults.type===I(M).UNDERLINE?(v(),he(jp,{key:1,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):i.value.defaults.type===I(M).STRIKEOUT?(v(),he(Up,{key:2,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):i.value.defaults.type===I(M).SQUIGGLY?(v(),he(Bp,{key:3,strokeColor:i.value.defaults.strokeColor,opacity:i.value.defaults.opacity,segmentRects:r.value,scale:t.scale},null,8,["strokeColor","opacity","segmentRects","scale"])):ae("",!0)],4)):ae("",!0)}}),wD=ie({__name:"preview-renderer",props:{toolId:{},preview:{},scale:{}},setup(t){const e=t,n=Ws(),o=P(()=>(n==null?void 0:n.getAll().find(a=>a.id===e.toolId&&a.renderPreview))??null),r=P(()=>{const a={position:"absolute",left:`${e.preview.bounds.origin.x*e.scale}px`,top:`${e.preview.bounds.origin.y*e.scale}px`,width:`${e.preview.bounds.size.width*e.scale}px`,height:`${e.preview.bounds.size.height*e.scale}px`,pointerEvents:"none",zIndex:10};return e.preview.type===M.INK&&(a.mixBlendMode=ka(e.preview.data.blendMode??it.Normal)),a});return(a,i)=>{var s;return v(),C("div",{style:Z(r.value)},[t.preview.type===I(M).CIRCLE?(v(),he(I(Ip),xe({key:0,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).SQUARE?(v(),he(I(kp),xe({key:1,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).POLYGON?(v(),he(I($p),xe({key:2,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).POLYLINE?(v(),he(I(Lp),xe({key:3,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).LINE?(v(),he(I(Gp),xe({key:4,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).INK?(v(),he(I(Op),xe({key:5,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===I(M).FREETEXT?(v(),C("div",{key:6,style:Z({width:"100%",height:"100%",border:`1px dashed ${t.preview.data.fontColor||"#000000"}`,backgroundColor:"transparent"})},null,4)):(s=o.value)!=null&&s.renderPreview?(v(),he(Fn(o.value.renderPreview),{key:7,data:t.preview.data,bounds:t.preview.bounds,scale:t.scale},null,8,["data","bounds","scale"])):ae("",!0)],4)}}}),zp=ie({__name:"annotation-paint-layer",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{plugin:n}=ni(),o=Q(new Map),r=Q(null),a=Q(null),i=P(()=>({requestFile:({accept:l,onFile:c})=>{const u=r.value;u&&(u.accept=l,u.onchange=d=>{var p;const h=(p=d.target.files)==null?void 0:p[0];h&&(c(h),u.value="")},u.click())},processImage:({source:l,maxWidth:c,maxHeight:u,onComplete:d})=>{const p=a.value;if(!p||!p.getContext)return;const h=p.getContext("2d");if(!h)return;const g=new Image;g.crossOrigin="Anonymous",g.onload=()=>{let{naturalWidth:f,naturalHeight:F}=g;const y=c?c/f:1,_=u?u/F:1,E=Math.min(y,_,1),A=f*E,T=F*E;p.width=A,p.height=T,h.drawImage(g,0,0,A,T);const q=h.getImageData(0,0,A,T);typeof l!="string"&&URL.revokeObjectURL(g.src),d({imageData:q,width:A,height:T})},g.src=typeof l=="string"?l:URL.createObjectURL(l)}}));let s;return Xn(l=>{n.value&&(s=n.value.registerPageHandlers(e.documentId,e.pageIndex,e.scale,{services:i.value,onPreview:(c,u)=>{const d=new Map(o.value);u?d.set(c,u):d.delete(c),o.value=d}})),l(()=>{s==null||s()})}),(l,c)=>(v(),C(pe,null,[m("input",{ref_key:"fileInputRef",ref:r,type:"file",style:{display:"none"}},null,512),m("canvas",{ref_key:"canvasRef",ref:a,style:{display:"none"}},null,512),(v(!0),C(pe,null,tt(o.value.entries(),([u,d])=>(v(),he(wD,{key:u,toolId:u,preview:d,scale:t.scale},null,8,["toolId","preview","scale"]))),128))],64))}}),OD=ie({__name:"annotation-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{},resizeUi:{},resizeUI:{},vertexUi:{},vertexUI:{},rotationUi:{},selectionOutlineColor:{},selectionOutline:{},groupSelectionOutline:{},selectionMenu:{type:Function},groupSelectionMenu:{type:Function},annotationRenderers:{}},setup(t){const e=t,n=P(()=>e.resizeUi??e.resizeUI),o=P(()=>e.vertexUi??e.vertexUI);Lo(()=>{e.resizeUI&&console.warn('[AnnotationLayer] The "resizeUI" prop is deprecated. Use :resize-ui in templates instead.'),e.vertexUI&&console.warn('[AnnotationLayer] The "vertexUI" prop is deprecated. Use :vertex-ui in templates instead.')});const r=Ws(),a=P(()=>{const p=(r==null?void 0:r.getAll())??[],h=e.annotationRenderers??[],g=[...p];for(const f of h){const F=g.findIndex(y=>y.id===f.id);F>=0?g[F]=f:g.push(f)}return g}),i=Dn(()=>e.documentId),s=P(()=>{var p,h,g;return(g=(h=(p=i.value)==null?void 0:p.document)==null?void 0:h.pages)==null?void 0:g[e.pageIndex]}),l=P(()=>{var p,h;return((h=(p=s.value)==null?void 0:p.size)==null?void 0:h.width)??0}),c=P(()=>{var p,h;return((h=(p=s.value)==null?void 0:p.size)==null?void 0:h.height)??0}),u=P(()=>{var p;return e.scale!==void 0?e.scale:((p=i.value)==null?void 0:p.scale)??1}),d=P(()=>{var p,h;if(e.rotation!==void 0)return e.rotation;const g=((p=s.value)==null?void 0:p.rotation)??0,f=((h=i.value)==null?void 0:h.rotation)??0;return(g+f)%4});return(p,h)=>(v(),C("div",null,[je(MD,{documentId:t.documentId,pageIndex:t.pageIndex,scale:u.value,rotation:d.value,pageWidth:l.value,pageHeight:c.value,resizeUi:n.value,vertexUi:o.value,rotationUi:t.rotationUi,selectionOutlineColor:t.selectionOutlineColor,selectionOutline:t.selectionOutline,groupSelectionOutline:t.groupSelectionOutline,selectionMenu:t.selectionMenu,groupSelectionMenu:t.groupSelectionMenu,annotationRenderers:a.value},{"selection-menu":We(g=>[$e(p.$slots,"selection-menu",zt(Qt(g)))]),"group-selection-menu":We(g=>[$e(p.$slots,"group-selection-menu",zt(Qt(g)))]),"resize-handle":We(g=>[$e(p.$slots,"resize-handle",zt(Qt(g)))]),"vertex-handle":We(g=>[$e(p.$slots,"vertex-handle",zt(Qt(g)))]),"rotation-handle":We(g=>[$e(p.$slots,"rotation-handle",zt(Qt(g)))]),_:3},8,["documentId","pageIndex","scale","rotation","pageWidth","pageHeight","resizeUi","vertexUi","rotationUi","selectionOutlineColor","selectionOutline","groupSelectionOutline","selectionMenu","groupSelectionMenu","annotationRenderers"]),je(RD,{documentId:t.documentId,pageIndex:t.pageIndex,scale:u.value},null,8,["documentId","pageIndex","scale"]),je(zp,{documentId:t.documentId,pageIndex:t.pageIndex,scale:u.value},null,8,["documentId","pageIndex","scale"])]))}}),kD=ie({__name:"renderer-registry-provider",setup(t){return dv(),(e,n)=>$e(e.$slots,"default")}}),ID={style:{display:"none"}},GD=ie({__name:"annotation-navigation-handler",setup(t){const{plugin:e}=ni(),{provides:n}=Bn();return Xn(o=>{const r=n.value,a=e.value;if(!r||!a)return;const i=r.onNavigate(s=>{s.result.outcome==="uri"&&a.config.autoOpenLinks!==!1&&window.open(s.result.uri,"_blank","noopener,noreferrer")});o(i)}),(o,r)=>(v(),C("span",ID))}}),LD=Tr($y).addWrapper(kD).addUtility(GD).build(),Wp=class extends jt{constructor(e,n,o){super(e,n),this.id=e,this.documentOpened$=Be(),this.documentClosed$=Be(),this.activeDocumentChanged$=Be(),this.documentError$=Be(),this.documentOrderChanged$=Be(),this.openFileRequest$=$n(),this.loadOptions=new Map,this.maxDocuments=o==null?void 0:o.maxDocuments}buildCapability(){return{openFileDialog:e=>this.openFileDialog(e),openDocumentUrl:e=>this.openDocumentUrl(e),openDocumentBuffer:e=>this.openDocumentBuffer(e),retryDocument:(e,n)=>this.retryDocument(e,n),closeDocument:e=>this.closeDocument(e),closeAllDocuments:()=>this.closeAllDocuments(),setActiveDocument:e=>{if(!this.isDocumentOpen(e))throw new Error(`Cannot set active document: ${e} is not open`);this.dispatchCoreAction(kF(e))},getActiveDocumentId:()=>this.coreState.core.activeDocumentId,getActiveDocument:()=>{var e;const n=this.coreState.core.activeDocumentId;return n?((e=this.coreState.core.documents[n])==null?void 0:e.document)??null:null},getDocumentOrder:()=>this.coreState.core.documentOrder,moveDocument:(e,n)=>{this.dispatchCoreAction(LF(e,n))},swapDocuments:(e,n)=>{const o=this.coreState.core.documentOrder,r=o.indexOf(e),a=o.indexOf(n);if(r===-1||a===-1)throw new Error("One or both documents not found in order");const i=[...o];[i[r],i[a]]=[i[a],i[r]],this.dispatchCoreAction(GF(i))},getDocument:e=>{var n;return((n=this.coreState.core.documents[e])==null?void 0:n.document)??null},getDocumentState:e=>this.coreState.core.documents[e]??null,getOpenDocuments:()=>this.coreState.core.documentOrder.map(e=>this.coreState.core.documents[e]).filter(e=>e!==null),isDocumentOpen:e=>this.isDocumentOpen(e),getDocumentCount:()=>Object.keys(this.coreState.core.documents).length,getDocumentIndex:e=>this.coreState.core.documentOrder.indexOf(e),setDocumentEncryption:(e,n)=>this.setDocumentEncryption(e,n),unlockOwnerPermissions:(e,n)=>this.unlockOwnerPermissions(e,n),removeEncryption:e=>this.removeEncryption(e),onDocumentOpened:this.documentOpened$.on,onDocumentClosed:this.documentClosed$.on,onDocumentError:this.documentError$.on,onActiveDocumentChanged:this.activeDocumentChanged$.on,onDocumentOrderChanged:this.documentOrderChanged$.on}}isDocumentOpen(e){return!!this.coreState.core.documents[e]}onDocumentLoaded(e){const n=this.coreState.core.documents[e];!n||n.status!=="loaded"||(this.loadOptions.delete(e),this.documentOpened$.emit(n),this.logger.info("DocumentManagerPlugin","DocumentOpened",`Document ${e} opened successfully`,{name:n.name}))}onDocumentClosed(e){this.loadOptions.delete(e),this.documentClosed$.emit(e),this.logger.info("DocumentManagerPlugin","DocumentClosed",`Document ${e} closed`)}onActiveDocumentChanged(e,n){this.activeDocumentChanged$.emit({previousDocumentId:e,currentDocumentId:n}),this.logger.info("DocumentManagerPlugin","ActiveDocumentChanged",`Active document changed from ${e} to ${n}`)}onCoreStoreUpdated(e,n){e.core.documentOrder!==n.core.documentOrder&&this.documentOrderChanged$.emit({order:n.core.documentOrder})}onOpenFileRequest(e){return this.openFileRequest$.on(e)}openDocumentUrl(e){const n=new Ie,o=e.documentId||this.generateDocumentId(),r=this.checkDocumentLimit();if(r)return n.reject(r),n;const a=e.name??this.extractNameFromUrl(e.url);this.loadOptions.set(o,e),this.dispatchCoreAction(Fu(o,a,e.scale,e.rotation,!!e.password,e.autoActivate,e.permissions)),this.logger.info("DocumentManagerPlugin","OpenDocumentUrl",`Starting to load document from URL: ${e.url}`,{documentId:o,passwordProvided:!!e.password});const i={id:o,url:e.url},s=this.engine.openDocumentUrl(i,{password:e.password,mode:e.mode,requestOptions:e.requestOptions,normalizeRotation:!0});return n.resolve({documentId:o,task:s}),this.handleLoadTask(o,s,"OpenDocumentUrl"),n}openDocumentBuffer(e){const n=new Ie,o=this.checkDocumentLimit();if(o)return n.reject(o),n;const r=e.documentId||this.generateDocumentId();this.loadOptions.set(r,e),this.dispatchCoreAction(Fu(r,e.name,e.scale,e.rotation,!!e.password,e.autoActivate,e.permissions)),this.logger.info("DocumentManagerPlugin","OpenDocumentBuffer",`Starting to load document from buffer: ${e.name}`,{documentId:r,passwordProvided:!!e.password});const a={id:r,content:e.buffer},i=this.engine.openDocumentBuffer(a,{password:e.password,normalizeRotation:!0});return n.resolve({documentId:r,task:i}),this.handleLoadTask(r,i,"OpenDocumentBuffer"),n}retryDocument(e,n){const o=new Ie,r=this.validateRetry(e);if(!r.valid)return o.reject(r.error),o;const i={...this.loadOptions.get(e),...(n==null?void 0:n.password)&&{password:n.password}};this.loadOptions.set(e,i),this.dispatchCoreAction(OF(e,!!(n!=null&&n.password))),this.logger.info("DocumentManagerPlugin","RetryDocument",`Retrying to load document ${e}`,{passwordProvided:!!(n!=null&&n.password)});const s="url"in i?this.retryUrlDocument(e,i):this.retryBufferDocument(e,i);return o.resolve({documentId:e,task:s}),this.handleLoadTask(e,s,"RetryDocument"),o}openFileDialog(e){const n=new Ie;return this.openFileRequest$.emit({task:n,options:e}),n}closeDocument(e){const n=new Ie,o=this.coreState.core.documents[e];return o?(o.status==="loaded"&&o.document?this.engine.closeDocument(o.document).wait(()=>{this.dispatchCoreAction(bu(e)),n.resolve()},r=>{this.logger.error("DocumentManagerPlugin","CloseDocument",`Failed to close document ${e}`,r),n.fail(r)}):(this.logger.info("DocumentManagerPlugin","CloseDocument",`Closing document ${e} in ${o.status} state (skipping engine close)`),this.dispatchCoreAction(bu(e)),n.resolve()),n):(this.logger.warn("DocumentManagerPlugin","CloseDocument",`Cannot close document ${e}: not found in state`),n.resolve(),n)}closeAllDocuments(){const e=Object.keys(this.coreState.core.documents),n=e.map(o=>this.closeDocument(o));return this.logger.info("DocumentManagerPlugin","CloseAllDocuments",`Closing ${e.length} documents`),Ie.all(n)}setDocumentEncryption(e,n){const o=new Ie,r=this.coreState.core.documents[e];return r!=null&&r.document?(this.logger.info("DocumentManagerPlugin","SetDocumentEncryption",`Setting encryption on document ${e}`,{hasUserPassword:!!n.userPassword,allowedFlags:n.allowedFlags}),this.engine.setDocumentEncryption(r.document,n.userPassword??"",n.ownerPassword,n.allowedFlags).wait(i=>{i&&this.logger.info("DocumentManagerPlugin","SetDocumentEncryption",`Encryption set successfully on document ${e}`),o.resolve(i)},i=>{this.logger.error("DocumentManagerPlugin","SetDocumentEncryption",`Failed to set encryption on document ${e}`,i),o.fail(i)}),o):(o.reject({code:ve.DocNotOpen,message:`Document ${e} is not open`}),o)}unlockOwnerPermissions(e,n){const o=new Ie,r=this.coreState.core.documents[e];if(!(r!=null&&r.document))return o.reject({code:ve.DocNotOpen,message:`Document ${e} is not open`}),o;const a=r.document;return this.logger.info("DocumentManagerPlugin","UnlockOwnerPermissions",`Attempting to unlock owner permissions on document ${e}`),this.engine.unlockOwnerPermissions(a,n).wait(s=>{s&&(this.logger.info("DocumentManagerPlugin","UnlockOwnerPermissions",`Owner permissions unlocked on document ${e}`),this.dispatchCoreAction($F(e,4294967295,!0))),o.resolve(s)},s=>{this.logger.error("DocumentManagerPlugin","UnlockOwnerPermissions",`Failed to unlock owner permissions on document ${e}`,s),o.fail(s)}),o}removeEncryption(e){const n=new Ie,o=this.coreState.core.documents[e];return o!=null&&o.document?(this.logger.info("DocumentManagerPlugin","RemoveEncryption",`Marking document ${e} for encryption removal on save`),this.engine.removeEncryption(o.document).wait(a=>{a&&this.logger.info("DocumentManagerPlugin","RemoveEncryption",`Document ${e} marked for encryption removal`),n.resolve(a)},a=>{this.logger.error("DocumentManagerPlugin","RemoveEncryption",`Failed to mark document ${e} for encryption removal`,a),n.fail(a)}),n):(n.reject({code:ve.DocNotOpen,message:`Document ${e} is not open`}),n)}checkDocumentLimit(){return this.maxDocuments&&Object.keys(this.coreState.core.documents).length>=this.maxDocuments?{code:ve.Unknown,message:`Maximum number of documents (${this.maxDocuments}) reached`}:null}validateRetry(e){const n=this.coreState.core.documents[e];return n?n.status==="loaded"?{valid:!1,error:{code:ve.Unknown,message:`Document ${e} is already loaded successfully`}}:n.status!=="error"?{valid:!1,error:{code:ve.Unknown,message:`Document ${e} is not in error state (current state: ${n.status})`}}:this.loadOptions.has(e)?{valid:!0}:{valid:!1,error:{code:ve.Unknown,message:`No retry information available for document ${e}`}}:{valid:!1,error:{code:ve.NotFound,message:`Document ${e} not found`}}}retryUrlDocument(e,n){const o={id:e,url:n.url};return this.engine.openDocumentUrl(o,{password:n.password,mode:n.mode,requestOptions:n.requestOptions})}retryBufferDocument(e,n){const o={id:e,content:n.buffer};return this.engine.openDocumentBuffer(o,{password:n.password,normalizeRotation:!0})}handleLoadTask(e,n,o){n.wait(r=>{this.dispatchCoreAction(RF(e,r))},r=>{this.handleLoadError(e,r,o)})}handleLoadError(e,n,o){var r,a,i;const s=((r=n.reason)==null?void 0:r.message)||"Failed to load document";this.logger.error("DocumentManagerPlugin",o,"Failed to load document",n),this.dispatchCoreAction(wF(e,s,(a=n.reason)==null?void 0:a.code,n.reason)),this.documentError$.emit({documentId:e,message:s,code:(i=n.reason)==null?void 0:i.code,reason:n.reason})}generateDocumentId(){return`doc-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}extractNameFromUrl(e){try{const r=new URL(e).pathname.split("/").pop();if(!r)return;let a=decodeURIComponent(r);return a.toLowerCase().endsWith(".pdf")||(a+=".pdf"),a}catch{return}}async initialize(e){var n;if(this.logger.info("DocumentManagerPlugin","Initialize","Document Manager Plugin initialized",{maxDocuments:this.maxDocuments,initialDocumentsCount:((n=e.initialDocuments)==null?void 0:n.length)??0}),e.initialDocuments&&e.initialDocuments.length>0)for(const o of e.initialDocuments)try{"buffer"in o?this.openDocumentBuffer(o):"url"in o&&this.openDocumentUrl(o)}catch(r){this.logger.error("DocumentManagerPlugin","Initialize","Failed to initiate initial document load",r)}}async destroy(){await this.closeAllDocuments().toPromise(),this.loadOptions.clear(),this.documentOpened$.clear(),this.documentClosed$.clear(),this.activeDocumentChanged$.clear(),this.documentOrderChanged$.clear(),this.documentError$.clear(),super.destroy()}};Wp.id="document-manager";let Hs=Wp;const Hp="document-manager",$D={manifest:{id:Hp,name:"Document Manager Plugin",version:"1.0.0",provides:["document-manager"],requires:[],optional:[],defaultConfig:{maxDocuments:10}},create:(t,e)=>new Hs(Hp,t,e),reducer:t=>t,initialState:{}},ND=ie({__name:"document-content",props:{documentId:{}},setup(t){const e=t,n=Dn(()=>$t(e.documentId)),o=P(()=>{var i;return((i=n.value)==null?void 0:i.status)==="loading"}),r=P(()=>{var i;return((i=n.value)==null?void 0:i.status)==="error"}),a=P(()=>{var i;return((i=n.value)==null?void 0:i.status)==="loaded"});return(i,s)=>I(n)?$e(i.$slots,"default",{key:0,documentState:I(n),isLoading:o.value,isError:r.value,isLoaded:a.value}):ae("",!0)}}),jD=()=>Nn(Hs.id),Vp=()=>It(Hs.id),UD=ie({__name:"file-picker",setup(t){const{plugin:e}=jD(),{provides:n}=Vp(),o=Q(null),r=Q(null),a=Q(void 0);Se(e,(s,l,c)=>{if(!(s!=null&&s.onOpenFileRequest))return;const u=s.onOpenFileRequest(({task:d,options:p})=>{var h;r.value=d,a.value=p,(h=o.value)==null||h.click()});c(u)},{immediate:!0});const i=async s=>{var l,c,u,d,p;const g=(l=s.target.files)==null?void 0:l[0],f=n.value;if(!g||!f)return;const F=await g.arrayBuffer();f.openDocumentBuffer({name:g.name,buffer:F,documentId:(c=a.value)==null?void 0:c.documentId,scale:(u=a.value)==null?void 0:u.scale,rotation:(d=a.value)==null?void 0:d.rotation,autoActivate:(p=a.value)==null?void 0:p.autoActivate}).wait(_=>{var E;(E=r.value)==null||E.resolve(_)},_=>{var E;(E=r.value)==null||E.fail(_)})};return(s,l)=>(v(),C("input",{ref_key:"inputRef",ref:o,type:"file",accept:"application/pdf",style:{display:"none"},onChange:i},null,544))}}),BD=Tr($D).addUtility(UD).build(),Yp=class extends jt{constructor(e,n,o){super(e,n),this.downloadRequest$=$n(),this.config=o}buildCapability(){return{saveAsCopy:()=>this.saveAsCopy(),download:()=>this.download(),forDocument:e=>this.createExportScope(e)}}createExportScope(e){return{saveAsCopy:()=>this.saveAsCopy(e),download:()=>this.download(e)}}download(e){const n=e??this.getActiveDocumentId();this.downloadRequest$.emit({documentId:n})}saveAsCopy(e){const n=e??this.getActiveDocumentId(),o=this.coreState.core.documents[n];return o!=null&&o.document?this.engine.saveAsCopy(o.document):Ue.reject({code:ve.DocNotOpen,message:`Document ${n} not found`})}saveAsCopyAndGetBufferAndName(e){const n=new Ie,o=this.coreState.core.documents[e];return o!=null&&o.document?(this.saveAsCopy(e).wait(r=>{n.resolve({buffer:r,name:o.name??this.config.defaultFileName})},r=>n.fail(r)),n):Ue.reject({code:ve.DocNotOpen,message:`Document ${e} not found`})}onRequest(e){return this.downloadRequest$.on(e)}async initialize(e){this.logger.info("ExportPlugin","Initialize","Export plugin initialized")}async destroy(){this.downloadRequest$.clear(),await super.destroy()}};Yp.id="export";let Vs=Yp;const qp="export",zD={manifest:{id:qp,name:"Export Plugin",version:"1.0.0",provides:["export"],requires:[],optional:[],defaultConfig:{defaultFileName:"document.pdf"}},create:(t,e)=>new Vs(qp,t,e),reducer:()=>{},initialState:{}},WD=()=>Nn(Vs.id),Kp=()=>It(Vs.id),HD=ie({__name:"download",setup(t){const{provides:e}=Kp(),{plugin:n}=WD(),o=Q(null);let r=null;return Lo(()=>{const a=e.value,i=n.value;!a||!i||(r=i.onRequest(s=>{const l=o.value;if(!l)return;i.saveAsCopyAndGetBufferAndName(s.documentId).wait(({buffer:u,name:d})=>{const p=URL.createObjectURL(new Blob([u]));l.href=p,l.download=d,l.click(),URL.revokeObjectURL(p)},Yt)}))}),$o(()=>{r&&r()}),(a,i)=>(v(),C("a",{ref_key:"anchorRef",ref:o,style:{display:"none"}},null,512))}}),VD=Tr(zD).addUtility(HD).build(),Xp="history",YD={id:Xp,name:"History Plugin",version:"1.0.0",provides:["history"],requires:[],optional:[],defaultConfig:{}},Zp="HISTORY/INIT_STATE",Qp="HISTORY/CLEANUP_STATE",Jp="HISTORY/SET_DOCUMENT_STATE",qD="HISTORY/SET_ACTIVE_DOCUMENT",KD=t=>({type:Zp,payload:{documentId:t}}),XD=t=>({type:Qp,payload:{documentId:t}}),ZD=(t,e)=>({type:Jp,payload:{documentId:t,state:e}}),eh=class extends jt{constructor(e,n){super(e,n),this.documentHistories=new Map,this.historyChange$=$n()}async initialize(e){this.logger.info("HistoryPlugin","Initialize","History plugin initialized")}onDocumentLoadingStarted(e){this.dispatch(KD(e)),this.documentHistories.set(e,{topicHistories:new Map,globalTimeline:[],globalIndex:-1}),this.logger.debug("HistoryPlugin","DocumentOpened",`Initialized history state for document: ${e}`)}onDocumentClosed(e){this.dispatch(XD(e)),this.documentHistories.delete(e),this.logger.debug("HistoryPlugin","DocumentClosed",`Cleaned up history state for document: ${e}`)}getDocumentHistoryData(e){const n=e??this.getActiveDocumentId(),o=this.documentHistories.get(n);if(!o)throw new Error(`History data not found for document: ${n}`);return o}getDocumentHistoryState(e){const n=this.documentHistories.get(e);if(!n)throw new Error(`History data not found for document: ${e}`);const o={};return Array.from(n.topicHistories.entries()).forEach(([r,a])=>{o[r]={canUndo:a.currentIndex>-1,canRedo:a.currentIndex<a.commands.length-1}}),{global:{canUndo:n.globalIndex>-1,canRedo:n.globalIndex<n.globalTimeline.length-1},topics:o}}emitHistoryChange(e,n){const o=this.getDocumentHistoryState(e);this.dispatch(ZD(e,o)),this.historyChange$.emit({documentId:e,topic:n,state:o})}register(e,n,o){const r=this.getDocumentHistoryData(o);r.topicHistories.has(n)||r.topicHistories.set(n,{commands:[],currentIndex:-1});const a=r.topicHistories.get(n);a.commands.splice(a.currentIndex+1),a.commands.push(e),a.currentIndex++;const i={command:e,topic:n};r.globalTimeline.splice(r.globalIndex+1),r.globalTimeline.push(i),r.globalIndex++,e.execute(),this.emitHistoryChange(o,n)}undo(e,n){const o=this.getDocumentHistoryData(n);let r;if(e){const a=o.topicHistories.get(e);a&&a.currentIndex>-1&&(a.commands[a.currentIndex].undo(),a.currentIndex--,r=e)}else if(o.globalIndex>-1){const a=o.globalTimeline[o.globalIndex];a.command.undo(),o.topicHistories.get(a.topic).currentIndex--,o.globalIndex--,r=a.topic}r&&this.emitHistoryChange(n,r)}redo(e,n){const o=this.getDocumentHistoryData(n);let r;if(e){const a=o.topicHistories.get(e);a&&a.currentIndex<a.commands.length-1&&(a.currentIndex++,a.commands[a.currentIndex].execute(),r=e)}else if(o.globalIndex<o.globalTimeline.length-1){o.globalIndex++;const a=o.globalTimeline[o.globalIndex];a.command.execute(),o.topicHistories.get(a.topic).currentIndex++,r=a.topic}r&&this.emitHistoryChange(n,r)}canUndo(e,n){const o=this.getDocumentHistoryData(n);if(e){const r=o.topicHistories.get(e);return!!r&&r.currentIndex>-1}return o.globalIndex>-1}canRedo(e,n){const o=this.getDocumentHistoryData(n);if(e){const r=o.topicHistories.get(e);return!!r&&r.currentIndex<r.commands.length-1}return o.globalIndex<o.globalTimeline.length-1}purgeByMetadata(e,n,o){const r=this.getDocumentHistoryData(o);let a=0;const i=u=>e(u.metadata),s=n?[n]:Array.from(r.topicHistories.keys());for(const u of s){const d=r.topicHistories.get(u);if(!d)continue;const p=[];let h=0;for(let g=0;g<d.commands.length;g++){const f=d.commands[g];i(f)?(g<=d.currentIndex&&h++,a++):p.push(f)}d.commands=p,d.currentIndex=Math.max(-1,d.currentIndex-h)}const l=[];let c=0;for(let u=0;u<r.globalTimeline.length;u++){const d=r.globalTimeline[u];(!n||d.topic===n)&&i(d.command)?u<=r.globalIndex&&c++:l.push(d)}return r.globalTimeline=l,r.globalIndex=Math.max(-1,r.globalIndex-c),a>0&&(this.emitHistoryChange(o,n),this.logger.debug("HistoryPlugin","PurgeByMetadata",`Purged ${a} history entries for document: ${o}${n?`, topic: ${n}`:""}`)),a}createHistoryScope(e){return{register:(n,o)=>this.register(n,o,e),undo:n=>this.undo(n,e),redo:n=>this.redo(n,e),canUndo:n=>this.canUndo(n,e),canRedo:n=>this.canRedo(n,e),getHistoryState:()=>this.getDocumentHistoryState(e),onHistoryChange:n=>this.historyChange$.on(o=>{o.documentId===e&&n(o.topic)}),purgeByMetadata:(n,o)=>this.purgeByMetadata(n,o,e)}}buildCapability(){return{register:(e,n)=>{const o=this.getActiveDocumentId();this.register(e,n,o)},undo:e=>{const n=this.getActiveDocumentId();this.undo(e,n)},redo:e=>{const n=this.getActiveDocumentId();this.redo(e,n)},canUndo:e=>{const n=this.getActiveDocumentId();return this.canUndo(e,n)},canRedo:e=>{const n=this.getActiveDocumentId();return this.canRedo(e,n)},getHistoryState:()=>{const e=this.getActiveDocumentId();return this.getDocumentHistoryState(e)},forDocument:e=>this.createHistoryScope(e),onHistoryChange:this.historyChange$.on,purgeByMetadata:(e,n)=>{const o=this.getActiveDocumentId();return this.purgeByMetadata(e,n,o)}}}async destroy(){this.historyChange$.clear(),this.documentHistories.clear(),super.destroy()}};eh.id="history";let th=eh;const QD={global:{canUndo:!1,canRedo:!1},topics:{}},nh={documents:{},activeDocumentId:null},JD={manifest:YD,create:t=>new th(Xp,t),reducer:(t=nh,e)=>{switch(e.type){case Zp:{const{documentId:n}=e.payload;return{...t,documents:{...t.documents,[n]:{...QD}}}}case Qp:{const{documentId:n}=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case Jp:{const{documentId:n,state:o}=e.payload;return t.documents[n]?{...t,documents:{...t.documents,[n]:o}}:t}case qD:return{...t,activeDocumentId:e.payload};default:return t}},initialState:nh};var ct=(t=>(t.Redact="redact",t.MarqueeRedact="marqueeRedact",t.RedactSelection="redactSelection",t))(ct||{});const oh="REDACTION/INIT_STATE",rh="REDACTION/CLEANUP_STATE",eS="REDACTION/SET_ACTIVE_DOCUMENT",ah="START_REDACTION",ih="END_REDACTION",tS="SET_ACTIVE_TYPE",sh="ADD_PENDING",lh="REMOVE_PENDING",ch="UPDATE_PENDING",uh="CLEAR_PENDING",dh="SELECT_PENDING",ph="DESELECT_PENDING";function nS(t,e){return{type:oh,payload:{documentId:t,state:e}}}function oS(t){return{type:rh,payload:t}}const Lr=(t,e)=>({type:sh,payload:{documentId:t,items:e}}),$r=(t,e,n)=>({type:lh,payload:{documentId:t,page:e,id:n}}),Ys=t=>({type:uh,payload:t}),hh=(t,e,n,o)=>({type:ch,payload:{documentId:t,page:e,id:n,patch:o}}),rS=(t,e)=>({type:ah,payload:{documentId:t,mode:e}}),aS=t=>({type:ih,payload:t}),gh=(t,e,n)=>({type:dh,payload:{documentId:t,page:e,id:n}}),fh=t=>({type:ph,payload:t}),mh=t=>Object.values(t).reduce((e,n)=>e+n.length,0),ri={isRedacting:!1,activeType:null,pending:{},pendingCount:0,selected:null},Ph={documents:{},activeDocumentId:null},iS=(t=Ph,e)=>{switch(e.type){case oh:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case rh:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case eS:return{...t,activeDocumentId:e.payload};case sh:{const{documentId:n,items:o}=e.payload,r=t.documents[n];if(!r)return t;const a={...r.pending};for(const i of o){const s=a[i.page]??[];s.some(l=>l.id===i.id)||(a[i.page]=s.concat(i))}return{...t,documents:{...t.documents,[n]:{...r,pending:a,pendingCount:mh(a)}}}}case lh:{const{documentId:n,page:o,id:r}=e.payload,a=t.documents[n];if(!a)return t;const s=(a.pending[o]??[]).filter(u=>u.id!==r),l={...a.pending,[o]:s},c=a.selected&&!(a.selected.page===o&&a.selected.id===r);return{...t,documents:{...t.documents,[n]:{...a,pending:l,pendingCount:mh(l),selected:c?a.selected:null}}}}case ch:{const{documentId:n,page:o,id:r,patch:a}=e.payload,i=t.documents[n];if(!i)return t;const l=(i.pending[o]??[]).map(c=>c.id===r?{...c,...a}:c);return{...t,documents:{...t.documents,[n]:{...i,pending:{...i.pending,[o]:l}}}}}case uh:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,pending:{},pendingCount:0,selected:null}}}:t}case dh:{const{documentId:n,page:o,id:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:{...a,selected:{page:o,id:r}}}}:t}case ph:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,selected:null}}}:t}case ah:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isRedacting:!0,activeType:o}}}:t}case ih:{const n=e.payload,o=t.documents[n];return o?{...t,documents:{...t.documents,[n]:{...o,isRedacting:!1,activeType:null}}}:t}case tS:{const{documentId:n,mode:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,activeType:o}}}:t}default:return t}},Fh=Ly({id:"redact",name:"Redact",categories:["annotation","redaction"],matchScore:t=>t.type===M.REDACT?10:0,interaction:{mode:ct.Redact,exclusive:!1,cursor:"crosshair",textSelection:!0,isDraggable:t=>{var e;return t.type!==M.REDACT?!0:!((e=t.segmentRects)!=null&&e.length)},isResizable:t=>{var e;return t.type!==M.REDACT?!0:!((e=t.segmentRects)!=null&&e.length)},isRotatable:!1,lockAspectRatio:!1,isGroupDraggable:!1,isGroupResizable:!1,isGroupRotatable:!1},defaults:{type:M.REDACT,color:"#000000",overlayColor:"#FFFFFF",strokeColor:"#E44234",opacity:1},behavior:{useAppearanceStream:!1}}),sS=[Fh],bh=class extends jt{constructor(e,n,o){var r,a,i,s;if(super(e,n),this.redactionSelection$=new Map,this.redactionMarquee$=new Map,this.pending$=Be(),this.selected$=Be(),this.state$=Be(),this.events$=Be(),this.documentUnsubscribers=new Map,this.config=o,this.selectionCapability=(r=this.registry.getPlugin("selection"))==null?void 0:r.provides(),this.interactionManagerCapability=(a=this.registry.getPlugin("interaction-manager"))==null?void 0:a.provides(),this.annotationCapability=(i=this.registry.getPlugin("annotation"))==null?void 0:i.provides(),this.historyCapability=(s=this.registry.getPlugin("history"))==null?void 0:s.provides(),this.config.useAnnotationMode?this.annotationCapability?this.useAnnotationMode=!0:(this.logger.warn("RedactionPlugin","ConfigError","useAnnotationMode is enabled but annotation plugin is not available. Falling back to legacy mode."),this.useAnnotationMode=!1):this.useAnnotationMode=!1,this.useAnnotationMode&&this.annotationCapability)for(const l of sS)this.annotationCapability.addTool(l);this.setupRedactionModes(),!this.useAnnotationMode&&this.annotationCapability&&this.logger.info("RedactionPlugin","LegacyMode","Using legacy redaction mode. Set useAnnotationMode: true in config to use annotation-based redactions."),this.setupModeChangeListener()}setupRedactionModes(){this.interactionManagerCapability&&(this.interactionManagerCapability.registerMode({id:ct.Redact,scope:"page",exclusive:!1,cursor:"crosshair"}),this.interactionManagerCapability.registerMode({id:ct.MarqueeRedact,scope:"page",exclusive:!1,cursor:"crosshair"}),this.interactionManagerCapability.registerMode({id:ct.RedactSelection,scope:"page",exclusive:!1}))}setupModeChangeListener(){var e;(e=this.interactionManagerCapability)==null||e.onModeChange(n=>{const o=n.documentId;if(n.activeMode===ct.Redact||n.activeMode===ct.MarqueeRedact||n.activeMode===ct.RedactSelection)this.dispatch(rS(o,n.activeMode));else{const a=this.getDocumentState(o);a!=null&&a.isRedacting&&this.dispatch(aS(o))}})}onDocumentLoadingStarted(e){this.dispatch(nS(e,{...ri})),this.redactionSelection$.set(e,Be()),this.redactionMarquee$.set(e,Be());const n=[];if(this.selectionCapability){const o=this.selectionCapability.forDocument(e),r=o.onSelectionChange(()=>{const c=this.getDocumentState(e);if(!(c!=null&&c.isRedacting))return;const u=o.getFormattedSelection(),d=this.redactionSelection$.get(e);d==null||d.emit(u)}),a=o.onEndSelection(()=>{const c=this.getDocumentState(e);if(!(c!=null&&c.isRedacting)||!this.checkPermission(e,te.ModifyContents))return;const u=o.getFormattedSelection();if(!u.length)return;const d=o.getSelectedText(),p=this.redactionSelection$.get(e);p==null||p.emit([]),o.clear(),d.wait(h=>{const g=h.join(" ");this.createRedactionsFromSelection(e,u,g)},()=>{this.createRedactionsFromSelection(e,u)})}),i=o.onMarqueeChange(c=>{var u;const d=this.getDocumentState(e);d!=null&&d.isRedacting&&((u=this.redactionMarquee$.get(e))==null||u.emit({pageIndex:c.pageIndex,rect:c.rect,modeId:c.modeId}))}),s=o.onMarqueeEnd(c=>{const u=this.getDocumentState(e);if(u!=null&&u.isRedacting&&this.checkPermission(e,te.ModifyContents))if(this.useAnnotationMode)this.createRedactAnnotationFromArea(e,c.pageIndex,c.rect);else{const d=this.config.drawBlackBoxes?"#000000":"transparent",p={id:pt(),kind:"area",page:c.pageIndex,rect:c.rect,source:"legacy",markColor:"#FF0000",redactionColor:d};this.dispatch(Lr(e,[p])),this.selectPending(c.pageIndex,p.id,e)}}),l=o.onEmptySpaceClick(()=>{this.deselectPending(e)});n.push(r,a,i,s,l)}if(this.useAnnotationMode&&this.annotationCapability){const o=this.annotationCapability.forDocument(e),r=o.onAnnotationEvent(i=>{var s;if(i.type==="loaded"){this.syncFromAnnotationLoad(e);return}if(((s=i.annotation)==null?void 0:s.type)!==M.REDACT)return;const l=i.annotation;i.type==="create"?(this.syncFromAnnotationCreate(e,l),this.events$.emit({type:"add",documentId:e,items:[this.annotationToRedactionItem(l)]})):i.type==="update"?(this.logger.debug("RedactionPlugin","AnnotationUpdated",{documentId:e,redactAnno:l,patch:i.patch}),this.syncFromAnnotationUpdate(e,l,i.patch)):i.type==="delete"&&(this.syncFromAnnotationDelete(e,l),this.events$.emit({type:"remove",documentId:e,page:l.pageIndex,id:l.id}))}),a=o.onStateChange(()=>{this.syncSelectionFromAnnotation(e)});n.push(r,a)}this.documentUnsubscribers.set(e,n),this.logger.debug("RedactionPlugin","DocumentOpened",`Initialized redaction state for document: ${e}`)}onDocumentLoaded(e){var n,o,r;(n=this.selectionCapability)==null||n.enableForMode(ct.Redact,{enableSelection:!0,showSelectionRects:!1,enableMarquee:!0,showMarqueeRects:!1},e),(o=this.selectionCapability)==null||o.enableForMode(ct.MarqueeRedact,{enableSelection:!1,enableMarquee:!0,showMarqueeRects:!1},e),(r=this.selectionCapability)==null||r.enableForMode(ct.RedactSelection,{enableSelection:!0,showSelectionRects:!1},e)}onDocumentClosed(e){this.dispatch(oS(e));const n=this.redactionSelection$.get(e);n==null||n.clear(),this.redactionSelection$.delete(e);const o=this.redactionMarquee$.get(e);o==null||o.clear(),this.redactionMarquee$.delete(e);const r=this.documentUnsubscribers.get(e);r&&(r.forEach(a=>a()),this.documentUnsubscribers.delete(e)),this.logger.debug("RedactionPlugin","DocumentClosed",`Cleaned up redaction state for document: ${e}`)}async initialize(e){this.logger.info("RedactionPlugin","Initialize","Redaction plugin initialized")}buildCapability(){return{queueCurrentSelectionAsPending:()=>this.queueCurrentSelectionAsPending(),enableRedact:()=>this.enableRedact(),toggleRedact:()=>this.toggleRedact(),isRedactActive:()=>this.isRedactActive(),endRedact:()=>this.endRedact(),enableMarqueeRedact:()=>this.enableMarqueeRedact(),toggleMarqueeRedact:()=>this.toggleMarqueeRedact(),isMarqueeRedactActive:()=>this.isMarqueeRedactActive(),enableRedactSelection:()=>this.enableRedactSelection(),toggleRedactSelection:()=>this.toggleRedactSelection(),isRedactSelectionActive:()=>this.isRedactSelectionActive(),addPending:e=>this.addPendingItems(e),removePending:(e,n)=>this.removePendingItem(e,n),clearPending:()=>this.clearPendingItems(),commitAllPending:()=>this.commitAllPending(),commitPending:(e,n)=>this.commitPendingOne(e,n),selectPending:(e,n)=>this.selectPending(e,n),getSelectedPending:()=>this.getSelectedPending(),deselectPending:()=>this.deselectPending(),getState:()=>this.getDocumentStateOrThrow(),forDocument:e=>this.createRedactionScope(e),onPendingChange:this.pending$.on,onSelectedChange:this.selected$.on,onRedactionEvent:this.events$.on,onStateChange:this.state$.on}}createRedactionScope(e){return{queueCurrentSelectionAsPending:()=>this.queueCurrentSelectionAsPending(e),enableRedact:()=>this.enableRedact(e),toggleRedact:()=>this.toggleRedact(e),isRedactActive:()=>this.isRedactActive(e),endRedact:()=>this.endRedact(e),enableMarqueeRedact:()=>this.enableMarqueeRedact(e),toggleMarqueeRedact:()=>this.toggleMarqueeRedact(e),isMarqueeRedactActive:()=>this.isMarqueeRedactActive(e),enableRedactSelection:()=>this.enableRedactSelection(e),toggleRedactSelection:()=>this.toggleRedactSelection(e),isRedactSelectionActive:()=>this.isRedactSelectionActive(e),addPending:n=>this.addPendingItems(n,e),removePending:(n,o)=>this.removePendingItem(n,o,e),clearPending:()=>this.clearPendingItems(e),commitAllPending:()=>this.commitAllPending(e),commitPending:(n,o)=>this.commitPendingOne(n,o,e),selectPending:(n,o)=>this.selectPending(n,o,e),getSelectedPending:()=>this.getSelectedPending(e),deselectPending:()=>this.deselectPending(e),getState:()=>this.getDocumentStateOrThrow(e),onPendingChange:n=>this.pending$.on(o=>{o.documentId===e&&n(o.pending)}),onSelectedChange:n=>this.selected$.on(o=>{o.documentId===e&&n(o.selected)}),onRedactionEvent:n=>this.events$.on(o=>{o.documentId===e&&n(o)}),onStateChange:n=>this.state$.on(o=>{o.documentId===e&&n(o.state)})}}getPendingFromAnnotations(e){if(!this.annotationCapability)return{};try{const n=this.annotationCapability.forDocument(e).getState(),o={};for(const r of Object.values(n.byUid))if(r.object.type===M.REDACT){const a=this.annotationToRedactionItem(r.object),i=r.object.pageIndex;(o[i]??(o[i]=[])).push(a)}return o}catch{return{}}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Redaction state not found for document: ${e??"active"}`);return n}isRedactTool(e){return(e==null?void 0:e.id)===Fh.id&&e.defaults.type===M.REDACT}getRedactTool(){var e;const n=(e=this.annotationCapability)==null?void 0:e.getTool("redact");return this.isRedactTool(n)?n:void 0}syncFromAnnotationCreate(e,n){const o=this.annotationToRedactionItem(n);this.dispatch(Lr(e,[o]))}syncFromAnnotationUpdate(e,n,o){if(!("rect"in o)&&!("segmentRects"in o)&&!("strokeColor"in o)&&!("color"in o))return;const r={};o.rect&&(r.rect=o.rect),o.segmentRects&&(r.rects=o.segmentRects),o.strokeColor&&(r.markColor=o.strokeColor),o.color&&(r.redactionColor=o.color),this.logger.debug("RedactionPlugin","AnnotationUpdated",{documentId:e,annotation:n,patch:r}),this.dispatch(hh(e,n.pageIndex,n.id,r))}syncFromAnnotationDelete(e,n){this.dispatch($r(e,n.pageIndex,n.id))}syncFromAnnotationLoad(e){const n=this.getPendingFromAnnotations(e);this.dispatch(Ys(e));for(const[,o]of Object.entries(n))o.length>0&&this.dispatch(Lr(e,o))}syncSelectionFromAnnotation(e){var n;const o=(n=this.annotationCapability)==null?void 0:n.forDocument(e).getState();if(!o)return;const r=o.selectedUids.map(a=>o.byUid[a]).find(a=>(a==null?void 0:a.object.type)===M.REDACT);if(r){const a=r.object;this.dispatch(gh(e,a.pageIndex,a.id))}else{const a=this.getDocumentState(e);a!=null&&a.selected&&this.dispatch(fh(e))}}addPendingItems(e,n){const o=n??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","AddPendingItems",`Cannot add redactions: document ${o} lacks ModifyContents permission`);return}if(this.useAnnotationMode){if(!this.annotationCapability)return;const r=this.annotationCapability.forDocument(o);for(const a of e){const i=this.redactionItemToAnnotation(a);r.createAnnotation(a.page,i)}if(e.length>0){const a=e[e.length-1];r.selectAnnotation(a.page,a.id)}}else this.dispatch(Lr(o,e));this.events$.emit({type:"add",documentId:o,items:e})}removePendingItem(e,n,o){var r;const a=o??this.getActiveDocumentId();this.useAnnotationMode?(r=this.annotationCapability)==null||r.forDocument(a).deleteAnnotation(e,n):this.dispatch($r(a,e,n)),this.events$.emit({type:"remove",documentId:a,page:e,id:n})}clearPendingItems(e){var n;const o=e??this.getActiveDocumentId();if(this.useAnnotationMode){const r=this.getPendingFromAnnotations(o),a=(n=this.annotationCapability)==null?void 0:n.forDocument(o);for(const[i,s]of Object.entries(r)){const l=Number(i);for(const c of s)a==null||a.deleteAnnotation(l,c.id)}}else this.dispatch(Ys(o));this.events$.emit({type:"clear",documentId:o})}selectPending(e,n,o){var r,a,i;const s=o??this.getActiveDocumentId();this.useAnnotationMode?(r=this.annotationCapability)==null||r.forDocument(s).selectAnnotation(e,n):(this.dispatch(gh(s,e,n)),(a=this.interactionManagerCapability)==null||a.claimPageActivity(s,"redaction-selection",e)),(i=this.selectionCapability)==null||i.forDocument(s).clear()}getSelectedPending(e){var n;const o=e??this.getActiveDocumentId();return((n=this.getDocumentState(o))==null?void 0:n.selected)??null}deselectPending(e){var n,o;const r=e??this.getActiveDocumentId();this.useAnnotationMode?(n=this.annotationCapability)==null||n.forDocument(r).deselectAnnotation():(this.dispatch(fh(r)),(o=this.interactionManagerCapability)==null||o.releasePageActivity(r,"redaction-selection"))}enableRedactSelection(e){var n;const o=e??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","EnableRedactSelection",`Cannot enable redact selection: document ${o} lacks ModifyContents permission`);return}(n=this.interactionManagerCapability)==null||n.forDocument(o).activate(ct.RedactSelection)}toggleRedactSelection(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o);if((r==null?void 0:r.getActiveMode())===ct.RedactSelection)r==null||r.activateDefaultMode();else{if(!this.checkPermission(o,te.ModifyContents))return;r==null||r.activate(ct.RedactSelection)}}isRedactSelectionActive(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o).getActiveMode();return r===ct.Redact||r===ct.RedactSelection}enableMarqueeRedact(e){var n;const o=e??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","EnableMarqueeRedact",`Cannot enable marquee redact: document ${o} lacks ModifyContents permission`);return}(n=this.interactionManagerCapability)==null||n.forDocument(o).activate(ct.MarqueeRedact)}toggleMarqueeRedact(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o);if((r==null?void 0:r.getActiveMode())===ct.MarqueeRedact)r==null||r.activateDefaultMode();else{if(!this.checkPermission(o,te.ModifyContents))return;r==null||r.activate(ct.MarqueeRedact)}}isMarqueeRedactActive(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o).getActiveMode();return r===ct.Redact||r===ct.MarqueeRedact}enableRedact(e){var n;const o=e??this.getActiveDocumentId();if(!this.checkPermission(o,te.ModifyContents)){this.logger.debug("RedactionPlugin","EnableRedact",`Cannot enable redact mode: document ${o} lacks ModifyContents permission`);return}(n=this.interactionManagerCapability)==null||n.forDocument(o).activate(ct.Redact)}toggleRedact(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManagerCapability)==null?void 0:n.forDocument(o);if((r==null?void 0:r.getActiveMode())===ct.Redact)r==null||r.activateDefaultMode();else{if(!this.checkPermission(o,te.ModifyContents))return;r==null||r.activate(ct.Redact)}}isRedactActive(e){var n;const o=e??this.getActiveDocumentId();return((n=this.interactionManagerCapability)==null?void 0:n.forDocument(o).getActiveMode())===ct.Redact}endRedact(e){var n;const o=e??this.getActiveDocumentId();(n=this.interactionManagerCapability)==null||n.forDocument(o).activateDefaultMode()}onRedactionSelectionChange(e,n){const o=this.redactionSelection$.get(e);return(o==null?void 0:o.on(n))??(()=>{})}onRedactionMarqueeChange(e,n){const o=this.redactionMarquee$.get(e);return(o==null?void 0:o.on(n))??(()=>{})}getPreviewStrokeColor(){var e;return this.useAnnotationMode?((e=this.getRedactTool())==null?void 0:e.defaults.strokeColor)??"#FF0000":"#FF0000"}queueCurrentSelectionAsPending(e){const n=e??this.getActiveDocumentId();if(!this.selectionCapability)return Ue.reject({code:ve.NotFound,message:"[RedactionPlugin] selection plugin required"});const o=this.coreState.core.documents[n];if(!(o!=null&&o.document))return Ue.reject({code:ve.NotFound,message:"Document not found"});const r=this.selectionCapability.forDocument(n),a=r.getFormattedSelection();if(!a.length)return Ue.resolve(!0);const i=r.getSelectedText(),s=this.redactionSelection$.get(n);s==null||s.emit([]),r.clear(),this.useAnnotationMode||this.enableRedactSelection(n);const l=new Ie;return i.wait(c=>{const u=c.join(" ");this.createRedactionsFromSelection(n,a,u),l.resolve(!0)},()=>{this.createRedactionsFromSelection(n,a),l.resolve(!0)}),l}commitPendingOne(e,n,o){const r=o??this.getActiveDocumentId();if(!this.checkPermission(r,te.ModifyContents))return this.logger.debug("RedactionPlugin","CommitPendingOne",`Cannot commit redaction: document ${r} lacks ModifyContents permission`),Ue.reject({code:ve.Security,message:"Document lacks ModifyContents permission"});const a=this.coreState.core.documents[r];if(!(a!=null&&a.document))return Ue.reject({code:ve.NotFound,message:"Document not found"});const i=a.document.pages[e];if(!i)return Ue.reject({code:ve.NotFound,message:"Page not found"});if(this.useAnnotationMode)return this.logger.debug("RedactionPlugin","CommitPendingOne",`Applying redaction in annotation mode: page ${e}, id ${n}`),this.applyRedactionAnnotationMode(r,a.document,i,n);const s=this.getDocumentState(r);if(!s)return Ue.reject({code:ve.NotFound,message:"Document state not found"});const l=(s.pending[e]??[]).find(c=>c.id===n);return l?this.commitPendingOneLegacy(r,a.document,i,e,l):(this.logger.debug("RedactionPlugin","CommitPendingOne",`No pending item found for page ${e}, id ${n}`),Ue.resolve(!0))}commitPendingOneLegacy(e,n,o,r,a){const i=a.kind==="text"?a.rects:[a.rect],s=new Ie;return this.engine.redactTextInRects(n,o,i,{drawBlackBoxes:this.config.drawBlackBoxes}).wait(()=>{this.dispatch($r(e,r,a.id)),this.dispatchCoreAction(Na(e,[r])),this.events$.emit({type:"commit",documentId:e,success:!0}),s.resolve(!0)},l=>{this.events$.emit({type:"commit",documentId:e,success:!1,error:l.reason}),s.reject({code:ve.Unknown,message:"Failed to commit redactions"})}),s}applyRedactionAnnotationMode(e,n,o,r){var a;const i=new Ie,s=(a=this.annotationCapability)==null?void 0:a.forDocument(e).getAnnotationById(r);return this.logger.debug("RedactionPlugin","ApplyRedactionAnnotationMode",`Looking for annotation ${r}, found: ${!!s}, type: ${s==null?void 0:s.object.type}`),!s||s.object.type!==M.REDACT?(this.logger.warn("RedactionPlugin","ApplyRedactionAnnotationMode",`Redaction annotation not found or wrong type: ${r}`),Ue.reject({code:ve.NotFound,message:"Redaction annotation not found"})):(this.logger.debug("RedactionPlugin","ApplyRedactionAnnotationMode",`Calling engine.applyRedaction for annotation ${r} on page ${o.index}`),this.engine.applyRedaction(n,o,s.object).wait(()=>{var l,c;this.logger.debug("RedactionPlugin","ApplyRedactionAnnotationMode",`Successfully applied redaction ${r} on page ${o.index}`),(l=this.annotationCapability)==null||l.forDocument(e).purgeAnnotation(o.index,r),this.dispatch($r(e,o.index,r)),(c=this.historyCapability)==null||c.forDocument(e).purgeByMetadata(u=>{var d;return((d=u==null?void 0:u.annotationIds)==null?void 0:d.includes(r))??!1},"annotations"),this.dispatchCoreAction(Na(e,[o.index])),this.events$.emit({type:"commit",documentId:e,success:!0}),i.resolve(!0)},l=>{var c;this.logger.error("RedactionPlugin","ApplyRedactionAnnotationMode",`Failed to apply redaction ${r}: ${((c=l.reason)==null?void 0:c.message)??"Unknown error"}`),this.events$.emit({type:"commit",documentId:e,success:!1,error:l.reason}),i.reject({code:ve.Unknown,message:"Failed to apply redaction"})}),i)}commitAllPending(e){const n=e??this.getActiveDocumentId();if(!this.checkPermission(n,te.ModifyContents))return this.logger.debug("RedactionPlugin","CommitAllPending",`Cannot commit redactions: document ${n} lacks ModifyContents permission`),Ue.reject({code:ve.Security,message:"Document lacks ModifyContents permission"});const o=this.coreState.core.documents[n];if(!(o!=null&&o.document))return Ue.reject({code:ve.NotFound,message:"Document not found"});const r=this.getDocumentState(n);return r?this.useAnnotationMode?this.applyAllRedactionsAnnotationMode(n,o.document):this.commitAllPendingLegacy(n,o.document,r):Ue.reject({code:ve.NotFound,message:"Document state not found"})}commitAllPendingLegacy(e,n,o){const r=new Map;for(const[l,c]of Object.entries(o.pending)){const u=Number(l),d=r.get(u)??[];for(const p of c)p.kind==="text"?d.push(...p.rects):d.push(p.rect);r.set(u,d)}const a=Array.from(r.entries()).filter(([l,c])=>c.length>0).map(([l])=>l),i=[];for(const[l,c]of r){const u=n.pages[l];u&&c.length&&i.push(this.engine.redactTextInRects(n,u,c,{drawBlackBoxes:this.config.drawBlackBoxes}))}const s=new Ie;return Ie.all(i).wait(()=>{this.dispatch(Ys(e)),this.dispatchCoreAction(Na(e,a)),this.events$.emit({type:"commit",documentId:e,success:!0}),s.resolve(!0)},l=>{this.events$.emit({type:"commit",documentId:e,success:!1,error:l.reason}),s.reject({code:ve.Unknown,message:"Failed to commit redactions"})}),s}applyAllRedactionsAnnotationMode(e,n){const o=this.annotationCapability;if(!o)return Ue.reject({code:ve.NotFound,message:"Annotation capability not found"});const r=o.forDocument(e).getState(),a=new Map;for(const c of Object.values(r.byUid))if(c.object.type===M.REDACT){const u=a.get(c.object.pageIndex)??[];u.push(c.object.id),a.set(c.object.pageIndex,u)}const i=Array.from(a.keys());if(i.length===0)return Ue.resolve(!0);const s=[];for(const c of i){const u=n.pages[c];u&&s.push(this.engine.applyAllRedactions(n,u))}const l=new Ie;return Ie.all(s).wait(()=>{var c;const u=o.forDocument(e),d=[];for(const[p,h]of a)for(const g of h)u.purgeAnnotation(p,g),this.dispatch($r(e,p,g)),d.push(g);d.length>0&&((c=this.historyCapability)==null||c.forDocument(e).purgeByMetadata(p=>{var h;return((h=p==null?void 0:p.annotationIds)==null?void 0:h.some(g=>d.includes(g)))??!1},"annotations")),this.dispatchCoreAction(Na(e,i)),this.events$.emit({type:"commit",documentId:e,success:!0}),l.resolve(!0)},c=>{this.events$.emit({type:"commit",documentId:e,success:!1,error:c.reason}),l.reject({code:ve.Unknown,message:"Failed to apply redactions"})}),l}createRedactAnnotationsFromSelection(e,n,o){var r;if(!this.annotationCapability)return[];const a=this.annotationCapability.forDocument(e),i=(r=this.getRedactTool())==null?void 0:r.defaults,s=[];for(const l of n){const c=pt();s.push(c);const u={...i,id:c,type:M.REDACT,pageIndex:l.pageIndex,rect:l.rect,segmentRects:l.segmentRects,...o?{custom:{text:o}}:{},created:new Date};a.createAnnotation(l.pageIndex,u),l===n[n.length-1]&&a.selectAnnotation(l.pageIndex,c)}if(o)for(let l=0;l<s.length;l++){const c=n[l].pageIndex;this.dispatch(hh(e,c,s[l],{text:o}))}return s}createLegacyRedactionsFromSelection(e,n,o){const r=this.config.drawBlackBoxes?"#000000":"transparent",a=n.map(i=>({id:pt(),kind:"text",page:i.pageIndex,rect:i.rect,rects:i.segmentRects,source:"legacy",markColor:"#FF0000",redactionColor:r,text:o}));this.dispatch(Lr(e,a)),a.length&&this.selectPending(a[a.length-1].page,a[a.length-1].id,e)}createRedactionsFromSelection(e,n,o){this.useAnnotationMode?this.createRedactAnnotationsFromSelection(e,n,o):this.createLegacyRedactionsFromSelection(e,n,o)}createRedactAnnotationFromArea(e,n,o){var r;if(!this.annotationCapability)return;const a=this.annotationCapability.forDocument(e),i=(r=this.getRedactTool())==null?void 0:r.defaults,s=pt(),l={...i,id:s,type:M.REDACT,pageIndex:n,rect:o,segmentRects:[],created:new Date};a.createAnnotation(n,l),a.selectAnnotation(n,s)}redactionItemToAnnotation(e){var n;return{...((n=this.getRedactTool())==null?void 0:n.defaults)??{},id:e.id,type:M.REDACT,pageIndex:e.page,rect:e.rect,segmentRects:e.kind==="text"?e.rects:[],created:new Date}}annotationToRedactionItem(e){var n;const o=e.strokeColor??"#FF0000",r=e.color??"transparent";return e.segmentRects&&e.segmentRects.length>0?{id:e.id,kind:"text",page:e.pageIndex,rect:e.rect,rects:e.segmentRects,source:"annotation",markColor:o,redactionColor:r,...(n=e.custom)!=null&&n.text?{text:e.custom.text}:{}}:{id:e.id,kind:"area",page:e.pageIndex,rect:e.rect,source:"annotation",markColor:o,redactionColor:r}}emitPendingChange(e){const n=this.getDocumentState(e);n&&this.pending$.emit({documentId:e,pending:n.pending})}emitSelectedChange(e){const n=this.getDocumentState(e);n&&this.selected$.emit({documentId:e,selected:n.selected})}emitStateChange(e){const n=this.getDocumentState(e);n&&this.state$.emit({documentId:e,state:n})}onStoreUpdated(e,n){for(const o in n.documents)n.documents[o]&&(this.emitPendingChange(o),this.emitSelectedChange(o),this.emitStateChange(o))}async destroy(){this.pending$.clear(),this.selected$.clear(),this.state$.clear(),this.events$.clear(),this.redactionSelection$.forEach(e=>e.clear()),this.redactionSelection$.clear(),this.redactionMarquee$.forEach(e=>e.clear()),this.redactionMarquee$.clear(),this.documentUnsubscribers.forEach(e=>{e.forEach(n=>n())}),this.documentUnsubscribers.clear(),await super.destroy()}};bh.id="redaction";let qs=bh;const yh="redaction",lS={manifest:{id:yh,name:"Redaction Plugin",version:"1.0.0",provides:["redaction"],requires:[],optional:["interaction-manager","selection","annotation"],defaultConfig:{drawBlackBoxes:!0}},create:(t,e)=>new qs(yh,t,e),reducer:iS,initialState:Ph},_h=ie({__name:"highlight",props:{color:{default:"#FFFF00"},opacity:{default:1},border:{default:"1px solid red"},rects:{},rect:{},scale:{},onClick:{}},setup(t){const n=t.rect;return(o,r)=>(v(!0),C(pe,null,tt(t.rects,(a,i)=>(v(),C("div",xe({key:i,onPointerdown:r[0]||(r[0]=(...s)=>t.onClick&&t.onClick(...s)),style:{position:"absolute",border:t.border,left:`${(I(n)?a.origin.x-I(n).origin.x:a.origin.x)*t.scale}px`,top:`${(I(n)?a.origin.y-I(n).origin.y:a.origin.y)*t.scale}px`,width:`${a.size.width*t.scale}px`,height:`${a.size.height*t.scale}px`,background:t.color,opacity:t.opacity,pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:void 0}},{ref_for:!0},o.$attrs),null,16))),128))}}),vh=()=>Nn(qs.id),Dh=()=>It(qs.id),Sh=ie({__name:"marquee-redact",props:{documentId:{},pageIndex:{},scale:{},className:{},stroke:{default:"red"},fill:{default:"transparent"}},setup(t){const e=t,{plugin:n}=vh(),o=Dn(()=>e.documentId),r=Q(null),a=P(()=>{var s;return e.scale!==void 0?e.scale:((s=o.value)==null?void 0:s.scale)??1}),i=P(()=>{var s;return e.stroke??((s=n.value)==null?void 0:s.getPreviewStrokeColor())??"red"});return Se([n,()=>e.documentId,()=>e.pageIndex],([s,l,c],u,d)=>{if(!s||!l)return;const p=s.onRedactionMarqueeChange(l,h=>{r.value=h.pageIndex===c?h.rect:null});d(p)},{immediate:!0}),(s,l)=>r.value?(v(),C("div",{key:0,style:Z({position:"absolute",pointerEvents:"none",left:`${r.value.origin.x*a.value}px`,top:`${r.value.origin.y*a.value}px`,width:`${r.value.size.width*a.value}px`,height:`${r.value.size.height*a.value}px`,border:`1px solid ${i.value}`,background:t.fill,boxSizing:"border-box"}),class:St(t.className)},null,6)):ae("",!0)}}),cS={key:0,style:{mixBlendMode:"normal",pointerEvents:"none",position:"absolute",inset:0}},Eh=ie({__name:"selection-redact",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{plugin:n}=vh(),o=Q([]),r=Q(null),a=P(()=>{var i;return((i=n.value)==null?void 0:i.getPreviewStrokeColor())??"red"});return Se([n,()=>e.documentId,()=>e.pageIndex],([i,s,l],c,u)=>{if(!i){o.value=[],r.value=null;return}const d=i.onRedactionSelectionChange(s,p=>{const h=p.find(g=>g.pageIndex===l);o.value=(h==null?void 0:h.segmentRects)??[],r.value=(h==null?void 0:h.rect)??null});u(d)},{immediate:!0}),(i,s)=>r.value?(v(),C("div",cS,[je(_h,{color:"transparent",opacity:1,rects:o.value,scale:t.scale,border:`1px solid ${a.value}`},null,8,["rects","scale","border"])])):ae("",!0)}}),uS={key:0,style:{position:"absolute",inset:0,pointerEvents:"none"}},dS=["onPointerdown"],Ah=ie({__name:"pending-redactions",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:Er.Degree0},bboxStroke:{default:"rgba(0,0,0,0.8)"},selectionMenu:{}},setup(t){const e=t,n=Pa(),{provides:o}=Dh(),r=Q([]),a=Q(null);Se([o,()=>e.documentId,()=>e.pageIndex],([d,p,h],g,f)=>{if(!d){r.value=[],a.value=null;return}const F=d.forDocument(p),y=F.getState();r.value=(y.pending[h]??[]).filter(A=>A.source==="legacy"),a.value=y.selected&&y.selected.page===h?y.selected.id:null;const _=F.onPendingChange(A=>{r.value=(A[h]??[]).filter(T=>T.source==="legacy")}),E=F.onSelectedChange(A=>{a.value=A&&A.page===h?A.id:null});f(()=>{_==null||_(),E==null||E()})},{immediate:!0});const i=(d,p)=>{d.stopPropagation();const h=o.value;h&&h.forDocument(e.documentId).selectPending(e.pageIndex,p)},s=d=>a.value===d&&(!!e.selectionMenu||!!n["selection-menu"]),l=d=>({type:"redaction",item:d,pageIndex:e.pageIndex}),c={suggestTop:!1,spaceAbove:0,spaceBelow:0},u=(d,p,h)=>e.selectionMenu?e.selectionMenu({rect:p,menuWrapperProps:h,selected:a.value===d.id,placement:c,context:l(d)}):null;return(d,p)=>r.value.length?(v(),C("div",uS,[(v(!0),C(pe,null,tt(r.value,h=>(v(),C(pe,{key:h.id},[h.kind==="area"?(v(),C(pe,{key:0},[m("div",{style:Z({position:"absolute",left:`${h.rect.origin.x*t.scale}px`,top:`${h.rect.origin.y*t.scale}px`,width:`${h.rect.size.width*t.scale}px`,height:`${h.rect.size.height*t.scale}px`,background:"transparent",outline:a.value===h.id?`1px solid ${t.bboxStroke}`:"none",outlineOffset:"2px",border:"1px solid red",pointerEvents:"auto",cursor:"pointer"}),onPointerdown:g=>i(g,h.id)},null,44,dS),s(h.id)?(v(),he(I(Ir),{key:0,rect:{origin:{x:h.rect.origin.x*t.scale,y:h.rect.origin.y*t.scale},size:{width:h.rect.size.width*t.scale,height:h.rect.size.height*t.scale}},rotation:t.rotation},{default:We(({rect:g,menuWrapperProps:f})=>[t.selectionMenu?(v(),he(Fn(u(h,g,f)),{key:0})):$e(d.$slots,"selection-menu",{key:1,context:l(h),selected:a.value===h.id,rect:g,placement:c,menuWrapperProps:f})]),_:2},1032,["rect","rotation"])):ae("",!0)],64)):(v(),C(pe,{key:1},[m("div",{style:Z({position:"absolute",left:`${h.rect.origin.x*t.scale}px`,top:`${h.rect.origin.y*t.scale}px`,width:`${h.rect.size.width*t.scale}px`,height:`${h.rect.size.height*t.scale}px`,background:"transparent",outline:a.value===h.id?`1px solid ${t.bboxStroke}`:"none",outlineOffset:"2px",pointerEvents:"auto",cursor:a.value===h.id?"pointer":"default"})},[je(_h,{rect:h.rect,rects:h.rects,color:"transparent",border:"1px solid red",scale:t.scale,"on-click":g=>i(g,h.id)},null,8,["rect","rects","scale","on-click"])],4),s(h.id)?(v(),he(I(Ir),{key:0,rect:{origin:{x:h.rect.origin.x*t.scale,y:h.rect.origin.y*t.scale},size:{width:h.rect.size.width*t.scale,height:h.rect.size.height*t.scale}},rotation:t.rotation},{default:We(({rect:g,menuWrapperProps:f})=>[t.selectionMenu?(v(),he(Fn(u(h,g,f)),{key:0})):$e(d.$slots,"selection-menu",{key:1,context:l(h),selected:a.value===h.id,rect:g,placement:c,menuWrapperProps:f})]),_:2},1032,["rect","rotation"])):ae("",!0)],64))],64))),128))])):ae("",!0)}}),pS=ie({__name:"redaction-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{},bboxStroke:{default:"rgba(0,0,0,0.8)"},selectionMenu:{}},setup(t){const e=t,n=Dn(()=>e.documentId),o=P(()=>{var i,s,l;return(l=(s=(i=n.value)==null?void 0:i.document)==null?void 0:s.pages)==null?void 0:l[e.pageIndex]}),r=P(()=>{var i;return e.scale!==void 0?e.scale:((i=n.value)==null?void 0:i.scale)??1}),a=P(()=>{var i,s;if(e.rotation!==void 0)return e.rotation;const l=((i=o.value)==null?void 0:i.rotation)??0,c=((s=n.value)==null?void 0:s.rotation)??0;return(l+c)%4});return(i,s)=>(v(),C(pe,null,[je(Ah,{"document-id":t.documentId,"page-index":t.pageIndex,scale:r.value,rotation:a.value,"bbox-stroke":t.bboxStroke,"selection-menu":t.selectionMenu},{"selection-menu":We(l=>[$e(i.$slots,"selection-menu",zt(Qt(l)))]),_:3},8,["document-id","page-index","scale","rotation","bbox-stroke","selection-menu"]),je(Sh,{"document-id":t.documentId,"page-index":t.pageIndex,scale:r.value},null,8,["document-id","page-index","scale"]),je(Eh,{"document-id":t.documentId,"page-index":t.pageIndex,scale:r.value},null,8,["document-id","page-index","scale"])],64))}}),hS=ie({__name:"redact-highlight",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){const e=t,n=Q(!1),o=P(()=>e.annotation.object.segmentRects??[]),r=P(()=>e.annotation.object.rect),a=P(()=>e.annotation.object.strokeColor??"#FF0000"),i=P(()=>e.annotation.object.color??"#000000"),s=P(()=>e.annotation.object.opacity??1),l=P(()=>e.annotation.object.fontColor??e.annotation.object.overlayColor??"#FFFFFF"),c=P(()=>e.annotation.object.overlayText),u=P(()=>e.annotation.object.overlayTextRepeat??!1),d=P(()=>e.annotation.object.fontSize??12),p=P(()=>e.annotation.object.fontFamily??mt.Helvetica),h=P(()=>e.annotation.object.textAlign??Vt.Center),g=P(()=>c.value?u.value?Array(10).fill(c.value).join(" "):c.value:""),f=y=>({position:"absolute",left:`${(r.value?y.origin.x-r.value.origin.x:y.origin.x)*e.scale}px`,top:`${(r.value?y.origin.y-r.value.origin.y:y.origin.y)*e.scale}px`,width:`${y.size.width*e.scale}px`,height:`${y.size.height*e.scale}px`,background:n.value?i.value:"transparent",border:n.value?"none":`2px solid ${a.value}`,opacity:n.value?s.value:1,boxSizing:"border-box",pointerEvents:"auto",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:h.value===Vt.Left?"flex-start":h.value===Vt.Right?"flex-end":"center",overflow:"hidden"}),F=y=>({color:l.value,fontSize:`${Math.min(d.value*e.scale,y.size.height*e.scale*.8)}px`,...os(p.value),textAlign:ts(h.value),whiteSpace:u.value?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1});return(y,_)=>(v(),C("div",{onMouseenter:_[1]||(_[1]=E=>n.value=!0),onMouseleave:_[2]||(_[2]=E=>n.value=!1),style:{position:"absolute",inset:0}},[(v(!0),C(pe,null,tt(o.value,(E,A)=>(v(),C("div",{key:A,onPointerdown:_[0]||(_[0]=(...T)=>t.onClick&&t.onClick(...T)),style:Z(f(E))},[n.value&&c.value?(v(),C("span",{key:0,style:Z(F(E))},fe(g.value),5)):ae("",!0)],36))),128))],32))}}),gS=ie({__name:"redact-area",props:{annotation:{},currentObject:{},isSelected:{type:Boolean},isEditing:{type:Boolean},scale:{},pageIndex:{},documentId:{},onClick:{type:Function},appearanceActive:{type:Boolean}},setup(t){const e=t,n=Q(!1),o=P(()=>e.annotation.object.strokeColor??"#FF0000"),r=P(()=>e.annotation.object.color??"#000000"),a=P(()=>e.annotation.object.opacity??1),i=P(()=>e.annotation.object.fontColor??e.annotation.object.overlayColor??"#FFFFFF"),s=P(()=>e.annotation.object.overlayText),l=P(()=>e.annotation.object.overlayTextRepeat??!1),c=P(()=>e.annotation.object.fontSize??12),u=P(()=>e.annotation.object.fontFamily??mt.Helvetica),d=P(()=>e.annotation.object.textAlign??Vt.Center),p=P(()=>s.value?l.value?Array(10).fill(s.value).join(" "):s.value:""),h=P(()=>({position:"absolute",inset:0,background:n.value?r.value:"transparent",border:n.value?"none":`2px solid ${o.value}`,opacity:n.value?a.value:1,boxSizing:"border-box",pointerEvents:"auto",cursor:e.isSelected?"move":"pointer",display:"flex",alignItems:"center",justifyContent:d.value===Vt.Left?"flex-start":d.value===Vt.Right?"flex-end":"center",overflow:"hidden"})),g=P(()=>({color:i.value,fontSize:`${c.value*e.scale}px`,...os(u.value),textAlign:ts(d.value),whiteSpace:l.value?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis",padding:"4px"}));return(f,F)=>(v(),C("div",{onPointerdown:F[0]||(F[0]=y=>{var _;t.isSelected||(_=t.onClick)==null||_.call(t,y)}),onMouseenter:F[1]||(F[1]=y=>n.value=!0),onMouseleave:F[2]||(F[2]=y=>n.value=!1),style:Z(h.value)},[n.value&&s.value?(v(),C("span",{key:0,style:Z(g.value)},fe(p.value),5)):ae("",!0)],36))}}),fS=[_t({id:"redactHighlight",matches:t=>{var e;return t.type===M.REDACT&&"segmentRects"in t&&(((e=t.segmentRects)==null?void 0:e.length)??0)>0},component:hS,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},useAppearanceStream:!1}),_t({id:"redactArea",matches:t=>{var e;return t.type===M.REDACT&&(!("segmentRects"in t)||!(((e=t.segmentRects)==null?void 0:e.length)??0))},component:gS,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},useAppearanceStream:!1})],xh=ie({__name:"redact-renderer-registration",setup(t){return pv(fS),(e,n)=>$e(e.$slots,"default")}}),mS=Tr(lS).addUtility(xh).build(),Ch=class extends jt{constructor(e,n,o){super(e,n),this.config=o}buildCapability(){return{renderPage:e=>this.renderPage(e),renderPageRect:e=>this.renderPageRect(e),renderPageRaw:e=>this.renderPageRaw(e),renderPageRectRaw:e=>this.renderPageRectRaw(e),forDocument:e=>this.createRenderScope(e)}}createRenderScope(e){return{renderPage:n=>this.renderPage(n,e),renderPageRect:n=>this.renderPageRect(n,e),renderPageRaw:n=>this.renderPageRaw(n,e),renderPageRectRaw:n=>this.renderPageRectRaw(n,e)}}renderPage({pageIndex:e,options:n},o){const r=o??this.getActiveDocumentId(),a=this.coreState.core.documents[r];if(!(a!=null&&a.document))throw new Error(`Document ${r} not loaded`);const i=a.document.pages.find(l=>l.index===e);if(!i)throw new Error(`Page ${e} not found in document ${r}`);const s={...n??{},withForms:(n==null?void 0:n.withForms)??this.config.withForms??!1,withAnnotations:(n==null?void 0:n.withAnnotations)??this.config.withAnnotations??!1,imageType:(n==null?void 0:n.imageType)??this.config.defaultImageType??"image/png",imageQuality:(n==null?void 0:n.imageQuality)??this.config.defaultImageQuality??.92};return this.engine.renderPage(a.document,i,s)}renderPageRect({pageIndex:e,rect:n,options:o},r){const a=r??this.getActiveDocumentId(),i=this.coreState.core.documents[a];if(!(i!=null&&i.document))throw new Error(`Document ${a} not loaded`);const s=i.document.pages.find(c=>c.index===e);if(!s)throw new Error(`Page ${e} not found in document ${a}`);const l={...o??{},withForms:(o==null?void 0:o.withForms)??this.config.withForms??!1,withAnnotations:(o==null?void 0:o.withAnnotations)??this.config.withAnnotations??!1,imageType:(o==null?void 0:o.imageType)??this.config.defaultImageType??"image/png",imageQuality:(o==null?void 0:o.imageQuality)??this.config.defaultImageQuality??.92};return this.engine.renderPageRect(i.document,s,n,l)}renderPageRaw({pageIndex:e,options:n},o){const r=o??this.getActiveDocumentId(),a=this.coreState.core.documents[r];if(!(a!=null&&a.document))throw new Error(`Document ${r} not loaded`);const i=a.document.pages.find(l=>l.index===e);if(!i)throw new Error(`Page ${e} not found in document ${r}`);const s={...n??{},withForms:(n==null?void 0:n.withForms)??this.config.withForms??!1,withAnnotations:(n==null?void 0:n.withAnnotations)??this.config.withAnnotations??!1};return this.engine.renderPageRaw(a.document,i,s)}renderPageRectRaw({pageIndex:e,rect:n,options:o},r){const a=r??this.getActiveDocumentId(),i=this.coreState.core.documents[a];if(!(i!=null&&i.document))throw new Error(`Document ${a} not loaded`);const s=i.document.pages.find(c=>c.index===e);if(!s)throw new Error(`Page ${e} not found in document ${a}`);const l={...o??{},withForms:(o==null?void 0:o.withForms)??this.config.withForms??!1,withAnnotations:(o==null?void 0:o.withAnnotations)??this.config.withAnnotations??!1};return this.engine.renderPageRectRaw(i.document,s,n,l)}async initialize(e){this.logger.info("RenderPlugin","Initialize","Render plugin initialized")}async destroy(){super.destroy()}};Ch.id="render";let Th=Ch;const Mh="render",PS={manifest:{id:Mh,name:"Render Plugin",version:"1.0.0",provides:["render"],requires:[],optional:[],defaultConfig:{}},create:(t,e)=>new Th(Mh,t,e),reducer:()=>{},initialState:{}};var ro=(t=>(t.Vertical="vertical",t.Horizontal="horizontal",t))(ro||{});class Rh{constructor(e){this.pageGap=e.pageGap??20,this.viewportGap=e.viewportGap??20,this.bufferSize=e.bufferSize??2}getCenteringOffsetX(e,n){return!n||e.width>=n.width?0:(n.width-e.width)/2}getCenteringOffsetY(e,n){return 0}getVisibleRange(e,n,o){const r=this.getScrollOffset(e),a=this.getClientSize(e),i=r,s=r+a;let l=0;for(;l<n.length&&(n[l].offset+this.getItemSizeAlongScrollAxis(n[l]))*o<=i;)l++;let c=l;for(;c<n.length&&n[c].offset*o<=s;)c++;return{start:Math.max(0,l-this.bufferSize),end:Math.min(n.length-1,c+this.bufferSize-1)}}handleScroll(e,n,o){const r=this.getVisibleRange(e,n,o),a=n.slice(r.start,r.end+1),i=this.getTotalContentSize(n),s=this.calculatePageVisibility(a,e,o,i),l=s.map(F=>F.pageNumber),c=n.slice(r.start,r.end+1).flatMap(F=>F.index),u=this.determineCurrentPage(s),d=n[r.start],p=n[r.end],h=d?d.offset*o:0,g=n[n.length-1],f=p?(g.offset+this.getItemSizeAlongScrollAxis(g))*o-(p.offset+this.getItemSizeAlongScrollAxis(p))*o:0;return{currentPage:u,visiblePages:l,pageVisibilityMetrics:s,renderedPageIndexes:c,scrollOffset:{x:e.scrollLeft,y:e.scrollTop},startSpacing:h,endSpacing:f}}calculatePageVisibility(e,n,o,r){const a=[];return e.forEach(i=>{const s=this.getCenteringOffsetX(i,r),l=this.getCenteringOffsetY(i,r);i.pageLayouts.forEach(c=>{const u=(i.x+s)*o,d=(i.y+l)*o,p=u+c.x*o,h=d+c.y*o,g=c.rotatedWidth*o,f=c.rotatedHeight*o,F=n.scrollLeft,y=n.scrollTop,_=F+n.clientWidth,E=y+n.clientHeight,A=Math.max(p,F),T=Math.max(h,y),q=Math.min(p+g,_),w=Math.min(h+f,E);if(A<q&&T<w){const G=q-A,W=w-T,J=g*f,ue=G*W;a.push({pageNumber:c.pageNumber,viewportX:A-F,viewportY:T-y,visiblePercentage:ue/J*100,original:{pageX:(A-p)/o,pageY:(T-h)/o,visibleWidth:G/o,visibleHeight:W/o,scale:1},scaled:{pageX:A-p,pageY:T-h,visibleWidth:G,visibleHeight:W,scale:o}})}})}),a}determineCurrentPage(e){if(e.length===0)return 1;const n=Math.max(...e.map(r=>r.visiblePercentage)),o=e.filter(r=>r.visiblePercentage===n);return o.length===1?o[0].pageNumber:o.sort((r,a)=>r.pageNumber-a.pageNumber)[0].pageNumber}getRectLocationForPage(e,n,o){const r=n.find(l=>l.pageNumbers.includes(e));if(!r)return null;const a=r.pageLayouts.find(l=>l.pageNumber===e);if(!a)return null;const i=this.getCenteringOffsetX(r,o),s=this.getCenteringOffsetY(r,o);return{origin:{x:r.x+a.x+i,y:r.y+a.y+s},size:{width:a.width,height:a.height}}}getScrollPositionForPage(e,n,o,r,a){const i=this.getTotalContentSize(n),s=this.getRectLocationForPage(e,n,i);if(!s)return null;const l=Ma(s.origin,o);if(a){const c=eF({width:s.size.width,height:s.size.height},{x:a.x,y:a.y},r,o);return{x:l.x+c.x+this.viewportGap,y:l.y+c.y+this.viewportGap}}return{x:l.x+this.viewportGap,y:l.y+this.viewportGap}}getRectPositionForPage(e,n,o,r,a){const i=this.getTotalContentSize(n),s=this.getRectLocationForPage(e,n,i);if(!s)return null;const l=Ma(s.origin,o),c=oF({width:s.size.width,height:s.size.height},a,r,o);return{origin:{x:l.x+c.origin.x,y:l.y+c.origin.y},size:c.size}}}class FS extends Rh{constructor(e){super(e)}createVirtualItems(e){let n=0;return e.map((o,r)=>{let a=0;const i=o.map(u=>{const d={pageNumber:u.index+1,pageIndex:u.index,x:a,y:0,width:u.size.width,height:u.size.height,rotatedWidth:u.rotatedSize.width,rotatedHeight:u.rotatedSize.height,elevated:!1};return a+=u.rotatedSize.width+this.pageGap,d}),s=o.reduce((u,d,p)=>u+d.rotatedSize.width+(p<o.length-1?this.pageGap:0),0),l=Math.max(...o.map(u=>u.rotatedSize.height)),c={id:`item-${r}`,x:0,y:n,offset:n,width:s,height:l,pageLayouts:i,pageNumbers:o.map(u=>u.index+1),index:r};return n+=l+this.pageGap,c})}getTotalContentSize(e){if(e.length===0)return{width:0,height:0};const n=Math.max(...e.map(r=>r.width)),o=e[e.length-1].y+e[e.length-1].height;return{width:n,height:o}}getScrollOffset(e){return e.scrollTop}getClientSize(e){return e.clientHeight}getItemSizeAlongScrollAxis(e){return e.height}}class bS extends Rh{constructor(e){super(e)}createVirtualItems(e){let n=0;return e.map((o,r)=>{let a=0;const i=o.map(u=>{const d={pageNumber:u.index+1,pageIndex:u.index,x:a,y:0,width:u.size.width,height:u.size.height,rotatedWidth:u.rotatedSize.width,rotatedHeight:u.rotatedSize.height,elevated:!1};return a+=u.rotatedSize.width+this.pageGap,d}),s=o.reduce((u,d,p)=>u+d.rotatedSize.width+(p<o.length-1?this.pageGap:0),0),l=Math.max(...o.map(u=>u.rotatedSize.height)),c={id:`item-${r}`,x:n,y:0,offset:n,width:s,height:l,pageLayouts:i,pageNumbers:o.map(u=>u.index+1),index:r};return n+=s+this.pageGap,c})}getTotalContentSize(e){if(e.length===0)return{width:0,height:0};const n=e[e.length-1].x+e[e.length-1].width,o=Math.max(...e.map(r=>r.height));return{width:n,height:o}}getScrollOffset(e){return e.scrollLeft}getClientSize(e){return e.clientWidth}getItemSizeAlongScrollAxis(e){return e.width}getCenteringOffsetX(e,n){return 0}getCenteringOffsetY(e,n){return!n||e.height>=n.height?0:(n.height-e.height)/2}}const wh="INIT_SCROLL_STATE",Oh="CLEANUP_SCROLL_STATE",kh="UPDATE_DOCUMENT_SCROLL_STATE",Ih="SET_SCROLL_STRATEGY";function yS(t,e){return{type:wh,payload:{documentId:t,state:e}}}function _S(t){return{type:Oh,payload:t}}function Nr(t,e){return{type:kh,payload:{documentId:t,state:e}}}function vS(t,e){return{type:Ih,payload:{documentId:t,strategy:e}}}const DS={isChanging:!1,targetPage:1,fromPage:1,startTime:0},SS=(t,e)=>({defaultStrategy:e.defaultStrategy??ro.Vertical,defaultPageGap:e.defaultPageGap??10,defaultBufferSize:e.defaultBufferSize??2,documents:{}}),ES=(t,e)=>{switch(e.type){case wh:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o}}}case Oh:{const{[e.payload]:n,...o}=t.documents;return{...t,documents:o}}case kh:{const{documentId:n,state:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,...o}}}:t}case Ih:{const{documentId:n,strategy:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,strategy:o}}}:t}default:return t}},AS=(t,e,n)=>({startSpacing:t.startSpacing,endSpacing:t.endSpacing,totalWidth:t.totalContentSize.width*e,totalHeight:t.totalContentSize.height*e,pageGap:t.pageGap*e,strategy:t.strategy,items:t.renderedPageIndexes.map(o=>({...t.virtualItems[o],pageLayouts:t.virtualItems[o].pageLayouts.map(r=>({...r,rotatedWidth:r.rotatedWidth*e,rotatedHeight:r.rotatedHeight*e,width:r.width*e,height:r.height*e,elevated:(n==null?void 0:n.has(r.pageIndex))??!1}))}))}),Gh=class extends jt{constructor(e,n,o){var r,a,i;super(e,n),this.id=e,this.config=o,this.elevatedPages=new Map,this.strategies=new Map,this.layoutReady=new Set,this.initialLayoutFired=new Set,this.scrollerLayoutEmitters=new Map,this.pageChange$=Be(),this.scroll$=Be(),this.layoutChange$=Be(),this.pageChangeState$=Be(),this.layoutReady$=Be(),this.state$=Be(),this.viewport=this.registry.getPlugin("viewport").provides(),this.spread=((r=this.registry.getPlugin("spread"))==null?void 0:r.provides())??null,this.viewport.onScrollActivity(l=>{const c=this.getDocumentState(l.documentId);c!=null&&c.pageChangeState.isChanging&&!l.activity.isSmoothScrolling&&this.completePageChange(l.documentId)}),(a=this.spread)==null||a.onSpreadChange(l=>{this.refreshDocumentLayout(l.documentId)});const s=(i=this.registry.getPlugin("interaction-manager"))==null?void 0:i.provides();s&&s.onPageActivityChange(l=>{let c=this.elevatedPages.get(l.documentId);l.hasActivity?(c||(c=new Set,this.elevatedPages.set(l.documentId,c)),c.add(l.pageIndex)):c==null||c.delete(l.pageIndex),this.pushScrollerLayout(l.documentId)}),this.viewport.onViewportChange(l=>{const c=this.getDocumentState(l.documentId);if(!c)return;const u=this.computeMetrics(l.documentId,l.metrics);this.layoutReady.has(l.documentId)?this.commitMetrics(l.documentId,u):this.commitMetrics(l.documentId,{...u,scrollOffset:c.scrollOffset})})}onDocumentLoadingStarted(e){const n=this.getCoreDocument(e);if(!n)return;const o=this.createDocumentState(n);this.dispatch(yS(e,o));const r=this.createStrategy(o.strategy);this.strategies.set(e,r),this.scrollerLayoutEmitters.set(e,Be())}onDocumentLoaded(e){var n;const o=this.getCoreDocument(e);o&&(this.dispatch(Nr(e,{totalPages:((n=o.document)==null?void 0:n.pageCount)??0})),this.refreshDocumentLayout(e),this.logger.debug("ScrollPlugin","DocumentOpened",`Initialized scroll state for document: ${e}`))}onDocumentClosed(e){this.strategies.delete(e),this.layoutReady.delete(e),this.initialLayoutFired.delete(e),this.elevatedPages.delete(e);const n=this.scrollerLayoutEmitters.get(e);n&&(n.clear(),this.scrollerLayoutEmitters.delete(e)),this.dispatch(_S(e)),this.logger.debug("ScrollPlugin","DocumentClosed",`Cleaned up scroll state for document: ${e}`)}onScaleChanged(e){const n=this.coreState.core.documents[e];if(!n||n.status!=="loaded")return;const o=this.viewport.forDocument(e),r=this.computeMetrics(e,o.getMetrics());this.commitMetrics(e,r)}onRotationChanged(e){this.refreshDocumentLayout(e)}onScrollerData(e,n){const o=this.scrollerLayoutEmitters.get(e);if(!o)throw new Error(`No scroller layout emitter found for document: ${e}`);return o.on(n)}getScrollerLayout(e){const n=this.getDocumentState(e),o=this.getCoreDocumentOrThrow(e);if(!n||!o)throw new Error(`Cannot get scroller layout for document: ${e}`);return AS(n,o.scale,this.elevatedPages.get(e))}setLayoutReady(e){if(this.layoutReady.has(e))return;const n=this.getDocumentState(e);if(!n)return;this.layoutReady.add(e);const o=!this.initialLayoutFired.has(e);o&&this.initialLayoutFired.add(e),this.viewport.forDocument(e).scrollTo({...n.scrollOffset,behavior:"instant"}),this.layoutReady$.emit({documentId:e,isInitial:o,pageNumber:n.currentPage,totalPages:n.totalPages})}clearLayoutReady(e){this.layoutReady.delete(e)}buildCapability(){return{getCurrentPage:()=>this.getCurrentPage(),getTotalPages:()=>this.getTotalPages(),getPageChangeState:()=>this.getPageChangeState(),scrollToPage:e=>this.scrollToPage(e),scrollToNextPage:e=>this.scrollToNextPage(e),scrollToPreviousPage:e=>this.scrollToPreviousPage(e),getMetrics:e=>this.getMetrics(e),getLayout:()=>this.getLayout(),getRectPositionForPage:(e,n,o,r)=>this.getRectPositionForPage(e,n,o,r),forDocument:e=>this.createScrollScope(e),setScrollStrategy:(e,n)=>this.setScrollStrategyForDocument(e,n),getPageGap:()=>this.state.defaultPageGap,onPageChange:this.pageChange$.on,onScroll:this.scroll$.on,onLayoutChange:this.layoutChange$.on,onLayoutReady:this.layoutReady$.on,onPageChangeState:this.pageChangeState$.on,onStateChange:this.state$.on}}createScrollScope(e){return{getCurrentPage:()=>this.getCurrentPage(e),getTotalPages:()=>this.getTotalPages(e),getPageChangeState:()=>this.getPageChangeState(e),scrollToPage:n=>this.scrollToPage(n,e),scrollToNextPage:n=>this.scrollToNextPage(n,e),scrollToPreviousPage:n=>this.scrollToPreviousPage(n,e),getSpreadPagesWithRotatedSize:()=>this.getSpreadPagesWithRotatedSize(e),getMetrics:n=>this.getMetrics(n,e),getLayout:()=>this.getLayout(e),getRectPositionForPage:(n,o,r,a)=>this.getRectPositionForPage(n,o,r,a,e),setScrollStrategy:n=>this.setScrollStrategyForDocument(n,e),onPageChange:n=>this.pageChange$.on(o=>{o.documentId===e&&n(o)}),onScroll:n=>this.scroll$.on(o=>{o.documentId===e&&n(o.metrics)}),onLayoutChange:n=>this.layoutChange$.on(o=>{o.documentId===e&&n(o.layout)})}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Scroll state not found for document: ${e??"active"}`);return n}getStrategy(e){const n=e??this.getActiveDocumentId(),o=this.strategies.get(n);if(!o)throw new Error(`Strategy not found for document: ${n}`);return o}createStrategy(e){const n={pageGap:this.state.defaultPageGap,viewportGap:this.viewport.getViewportGap(),bufferSize:this.state.defaultBufferSize};return e===ro.Horizontal?new bS(n):new FS(n)}createDocumentState(e){var n;return{virtualItems:[],totalPages:((n=e.document)==null?void 0:n.pageCount)??0,currentPage:1,totalContentSize:{width:0,height:0},strategy:this.state.defaultStrategy,pageGap:this.state.defaultPageGap,visiblePages:[],pageVisibilityMetrics:[],renderedPageIndexes:[],scrollOffset:{x:0,y:0},startSpacing:0,endSpacing:0,pageChangeState:DS}}startPageChange(e,n,o="smooth"){const r=this.getDocumentState(e);if(!r)return;const a={isChanging:!0,targetPage:n,fromPage:r.currentPage,startTime:Date.now()};this.dispatch(Nr(e,{pageChangeState:a,currentPage:n})),this.pageChange$.emit({documentId:e,pageNumber:n,totalPages:r.totalPages}),o==="instant"&&this.completePageChange(e)}completePageChange(e){const n=this.getDocumentState(e);if(!n||!n.pageChangeState.isChanging)return;const o={isChanging:!1,targetPage:n.pageChangeState.targetPage,fromPage:n.pageChangeState.fromPage,startTime:n.pageChangeState.startTime};this.dispatch(Nr(e,{pageChangeState:o}))}computeLayout(e,n){const o=this.getStrategy(e),r=o.createVirtualItems(n),a=o.getTotalContentSize(r);return{virtualItems:r,totalContentSize:a}}computeMetrics(e,n,o){const r=this.getCoreDocumentOrThrow(e),a=this.getDocumentState(e),i=this.getStrategy(e);if(!a)throw new Error(`Document state not found: ${e}`);return i.handleScroll(n,o??a.virtualItems,r.scale)}commitMetrics(e,n){const o=this.getDocumentState(e);if(!o)return;const r=o.pageChangeState.isChanging,a=r&&n.currentPage!==o.currentPage?{...n,currentPage:o.currentPage}:n;this.dispatch(Nr(e,a)),this.scroll$.emit({documentId:e,metrics:a}),!r&&n.currentPage!==o.currentPage&&this.pageChange$.emit({documentId:e,pageNumber:n.currentPage,totalPages:o.totalPages}),this.pushScrollerLayout(e)}pushScrollerLayout(e){const n=this.scrollerLayoutEmitters.get(e);if(n)try{const o=this.getScrollerLayout(e);n.emit(o)}catch{}}refreshDocumentLayout(e){const n=this.coreState.core.documents[e],o=this.getDocumentState(e);if(!n||!o||n.status!=="loaded")return;const r=this.getSpreadPagesWithRotatedSize(e),a=this.computeLayout(e,r),i=this.viewport.forDocument(e),s=this.computeMetrics(e,i.getMetrics(),a.virtualItems);this.dispatch(Nr(e,{...a,...s})),this.layoutChange$.emit({documentId:e,layout:a}),this.pushScrollerLayout(e)}getSpreadPagesWithRotatedSize(e){var n,o;const r=e??this.getActiveDocumentId(),a=this.coreState.core.documents[r];if(!a)throw new Error(`Document ${r} not loaded`);return(((n=this.spread)==null?void 0:n.forDocument(r).getSpreadPages())||((o=a.document)==null?void 0:o.pages.map(s=>[s]))||[]).map(s=>s.map(l=>{const c=((l.rotation??0)+a.rotation)%4;return{...l,rotatedSize:Ta(l.size,c,1)}}))}getCurrentPage(e){return this.getDocumentStateOrThrow(e).currentPage}getTotalPages(e){return this.getDocumentStateOrThrow(e).totalPages}getPageChangeState(e){return this.getDocumentStateOrThrow(e).pageChangeState}scrollToPage(e,n){var o;const r=n??this.getActiveDocumentId(),a=this.getDocumentStateOrThrow(r),i=this.getStrategy(r),s=this.getCoreDocumentOrThrow(r),{pageNumber:l,behavior:c="smooth",pageCoordinates:u,alignX:d,alignY:p}=e;this.startPageChange(r,l,c);const h=(o=s.document)==null?void 0:o.pages[l-1],g=(((h==null?void 0:h.rotation)??0)+s.rotation)%4,f=i.getScrollPositionForPage(l,a.virtualItems,s.scale,g,u);f?this.viewport.forDocument(r).scrollTo({...f,behavior:c,alignX:d,alignY:p}):this.completePageChange(r)}scrollToNextPage(e="smooth",n){const o=n??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(o),a=this.getStrategy(o),i=this.getCoreDocumentOrThrow(o),s=r.virtualItems.findIndex(l=>l.pageNumbers.includes(r.currentPage));if(s>=0&&s<r.virtualItems.length-1){const c=r.virtualItems[s+1].pageNumbers[0];this.startPageChange(o,c,e);const u=a.getScrollPositionForPage(c,r.virtualItems,i.scale,i.rotation);u?this.viewport.forDocument(o).scrollTo({...u,behavior:e}):this.completePageChange(o)}}scrollToPreviousPage(e="smooth",n){const o=n??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(o),a=this.getStrategy(o),i=this.coreState.core.documents[o],s=r.virtualItems.findIndex(l=>l.pageNumbers.includes(r.currentPage));if(s>0){const c=r.virtualItems[s-1].pageNumbers[0];this.startPageChange(o,c,e);const u=a.getScrollPositionForPage(c,r.virtualItems,i.scale,i.rotation);u?this.viewport.forDocument(o).scrollTo({...u,behavior:e}):this.completePageChange(o)}}getMetrics(e,n){const o=n??this.getActiveDocumentId();if(e)return this.computeMetrics(o,e);const r=this.viewport.forDocument(o);return this.computeMetrics(o,r.getMetrics())}getLayout(e){const n=this.getDocumentStateOrThrow(e);return{virtualItems:n.virtualItems,totalContentSize:n.totalContentSize}}getRectPositionForPage(e,n,o,r,a){var i;const s=a??this.getActiveDocumentId(),l=this.getDocumentStateOrThrow(s),c=this.getStrategy(s),u=this.getCoreDocumentOrThrow(s);let d=r;if(d===void 0){const p=(i=u.document)==null?void 0:i.pages[e];d=(((p==null?void 0:p.rotation)??0)+u.rotation)%4}return c.getRectPositionForPage(e+1,l.virtualItems,o??u.scale,d,n)}setScrollStrategyForDocument(e,n){const o=n??this.getActiveDocumentId(),r=this.getDocumentState(o);if(!r||r.strategy===e)return;const a=this.createStrategy(e);this.strategies.set(o,a),this.dispatch(vS(o,e)),this.refreshDocumentLayout(o)}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&(this.state$.emit(a),(r==null?void 0:r.pageChangeState)!==a.pageChangeState&&this.pageChangeState$.emit({documentId:o,state:a.pageChangeState}),this.pushScrollerLayout(o))}}async initialize(){this.logger.info("ScrollPlugin","Initialize","Scroll plugin initialized")}async destroy(){this.strategies.clear(),this.layoutReady.clear(),this.initialLayoutFired.clear(),this.elevatedPages.clear();for(const e of this.scrollerLayoutEmitters.values())e.clear();this.scrollerLayoutEmitters.clear(),this.pageChange$.clear(),this.scroll$.clear(),this.layoutChange$.clear(),this.pageChangeState$.clear(),this.layoutReady$.clear(),this.state$.clear(),super.destroy()}};Gh.id="scroll";let Ks=Gh;const Lh="scroll",xS={manifest:{id:Lh,name:"Scroll Plugin",version:"1.0.0",provides:["scroll"],requires:["viewport"],optional:["spread","interaction-manager"],defaultConfig:{defaultPageGap:10,defaultBufferSize:4,defaultStrategy:ro.Vertical}},create:(t,e)=>new Ks(Lh,t,e),reducer:ES,initialState:(t,e)=>SS(t,e)},$h="SEARCH/INIT_STATE",Nh="SEARCH/CLEANUP_STATE",jh="SEARCH/START_SEARCH_SESSION",Uh="SEARCH/STOP_SEARCH_SESSION",Bh="SEARCH/SET_SEARCH_FLAGS",zh="SEARCH/SET_SHOW_ALL_RESULTS",Wh="SEARCH/START_SEARCH",Hh="SEARCH/SET_SEARCH_RESULTS",Vh="SEARCH/APPEND_SEARCH_RESULTS",Yh="SEARCH/SET_ACTIVE_RESULT_INDEX";function CS(t,e){return{type:$h,payload:{documentId:t,state:e}}}function TS(t){return{type:Nh,payload:t}}function MS(t){return{type:jh,payload:{documentId:t}}}function RS(t){return{type:Uh,payload:{documentId:t}}}function wS(t,e){return{type:Bh,payload:{documentId:t,flags:e}}}function qh(t,e){return{type:zh,payload:{documentId:t,showAll:e}}}function OS(t,e){return{type:Wh,payload:{documentId:t,query:e}}}function Xs(t,e,n,o){return{type:Hh,payload:{documentId:t,results:e,total:n,activeResultIndex:o}}}function kS(t,e){return{type:Vh,payload:{documentId:t,results:e}}}function Kh(t,e){return{type:Yh,payload:{documentId:t,index:e}}}const jr={flags:[],results:[],total:0,activeResultIndex:-1,showAllResults:!0,query:"",loading:!1,active:!1},Xh={documents:{}},ao=(t,e,n)=>{const o=t.documents[e]||jr;return{...t,documents:{...t.documents,[e]:{...o,...n}}}},IS=(t=Xh,e)=>{switch(e.type){case $h:return{...t,documents:{...t.documents,[e.payload.documentId]:e.payload.state}};case Nh:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r}}case jh:return ao(t,e.payload.documentId,{active:!0});case Uh:return ao(t,e.payload.documentId,{results:[],total:0,activeResultIndex:-1,query:"",loading:!1,active:!1});case Bh:return ao(t,e.payload.documentId,{flags:e.payload.flags});case zh:return ao(t,e.payload.documentId,{showAllResults:e.payload.showAll});case Wh:return ao(t,e.payload.documentId,{loading:!0,query:e.payload.query,results:[],total:0,activeResultIndex:-1});case Vh:{const{documentId:n,results:o}=e.payload,r=t.documents[n];if(!r)return t;const a=[...r.results,...o],i=r.activeResultIndex===-1&&a.length>0?0:r.activeResultIndex;return ao(t,n,{results:a,total:a.length,activeResultIndex:i,loading:!0})}case Hh:{const{documentId:n,results:o,total:r,activeResultIndex:a}=e.payload;return ao(t,n,{results:o,total:r,activeResultIndex:a,loading:!1})}case Yh:return ao(t,e.payload.documentId,{activeResultIndex:e.payload.index});default:return t}},Zh=class extends jt{constructor(e,n,o){super(e,n),this.searchStop$=Be(),this.searchStart$=Be(),this.searchResult$=Be(),this.searchActiveResultChange$=Be(),this.searchResultState$=Be(),this.searchState$=Be(),this.currentTask=new Map,this.pluginConfig=o}onDocumentLoadingStarted(e){const n={...jr,flags:this.pluginConfig.flags||[],showAllResults:this.pluginConfig.showAllResults??!0};this.dispatch(CS(e,n))}onDocumentClosed(e){this.stopSearchSession(e),this.dispatch(TS(e)),this.currentTask.delete(e)}async initialize(){}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&(this.searchState$.emit({documentId:o,state:a}),(!r||r.results!==a.results||r.activeResultIndex!==a.activeResultIndex||r.showAllResults!==a.showAllResults||r.active!==a.active)&&this.searchResultState$.emit({documentId:o,state:{results:a.results,activeResultIndex:a.activeResultIndex,showAllResults:a.showAllResults,active:a.active}}))}}buildCapability(){const e=o=>o??this.getActiveDocumentId(),n=o=>{const r=e(o),a=this.state.documents[r];if(!a)throw new Error(`Search state not found for document ${r}`);return a};return{startSearch:o=>this.startSearchSession(e(o)),stopSearch:o=>this.stopSearchSession(e(o)),searchAllPages:(o,r)=>this.searchAllPages(o,e(r)),nextResult:o=>this.nextResult(e(o)),previousResult:o=>this.previousResult(e(o)),goToResult:(o,r)=>this.goToResult(o,e(r)),setShowAllResults:(o,r)=>this.dispatch(qh(e(r),o)),getShowAllResults:o=>n(o).showAllResults,getFlags:o=>n(o).flags,setFlags:(o,r)=>this.setFlags(o,e(r)),getState:o=>n(o),forDocument:this.createSearchScope.bind(this),onSearchResult:this.searchResult$.on,onSearchStart:this.searchStart$.on,onSearchStop:this.searchStop$.on,onActiveResultChange:this.searchActiveResultChange$.on,onSearchResultStateChange:this.searchResultState$.on,onStateChange:this.searchState$.on}}createSearchScope(e){const n=()=>{const o=this.state.documents[e];if(!o)throw new Error(`Search state not found for document ${e}`);return o};return{startSearch:()=>this.startSearchSession(e),stopSearch:()=>this.stopSearchSession(e),searchAllPages:o=>this.searchAllPages(o,e),nextResult:()=>this.nextResult(e),previousResult:()=>this.previousResult(e),goToResult:o=>this.goToResult(o,e),setShowAllResults:o=>this.dispatch(qh(e,o)),getShowAllResults:()=>n().showAllResults,getFlags:()=>n().flags,setFlags:o=>this.setFlags(o,e),getState:n,onSearchResult:o=>this.searchResult$.on(r=>{r.documentId===e&&o(r.results)}),onSearchStart:o=>this.searchStart$.on(r=>{r.documentId===e&&o()}),onSearchStop:o=>this.searchStop$.on(r=>{r.documentId===e&&o()}),onActiveResultChange:o=>this.searchActiveResultChange$.on(r=>{r.documentId===e&&o(r.index)}),onSearchResultStateChange:o=>this.searchResultState$.on(r=>{r.documentId===e&&o(r.state)}),onStateChange:o=>this.searchState$.on(r=>{r.documentId===e&&o(r.state)})}}setFlags(e,n){this.dispatch(wS(n,e));const o=this.state.documents[n];o!=null&&o.active&&this.searchAllPages(o.query,n,!0)}notifySearchStart(e){this.searchStart$.emit({documentId:e})}notifySearchStop(e){this.searchStop$.emit({documentId:e})}notifyActiveResultChange(e,n){this.searchActiveResultChange$.emit({documentId:e,index:n})}startSearchSession(e){this.getCoreDocument(e)&&(this.dispatch(MS(e)),this.notifySearchStart(e))}stopSearchSession(e){var n;const o=this.state.documents[e];if(!(o!=null&&o.active))return;const r=this.currentTask.get(e);if(r){try{(n=r.abort)==null||n.call(r,{code:ve.Cancelled,message:"search stopped"})}catch{}this.currentTask.delete(e)}this.dispatch(RS(e)),this.notifySearchStop(e)}searchAllPages(e,n,o=!1){var r;const a=this.state.documents[n];if(!a)return Ue.reject({code:ve.NotFound,message:"Search state not initialized"});const i=this.getCoreDocument(n);if(!(i!=null&&i.document))return Ue.reject({code:ve.NotFound,message:"Document not loaded"});const s=e.trim();if(a.query===s&&!o)return Ue.resolve({results:a.results,total:a.total});const l=this.currentTask.get(n);if(l){try{(r=l.abort)==null||r.call(l,{code:ve.Cancelled,message:"new search"})}catch{}this.currentTask.delete(n)}if(this.dispatch(OS(n,s)),!s)return this.dispatch(Xs(n,[],0,-1)),Ue.resolve({results:[],total:0});a.active||this.startSearchSession(n);const c=this.engine.searchAllPages(i.document,s,{flags:a.flags});return this.currentTask.set(n,c),c.onProgress(u=>{var d;(d=u==null?void 0:u.results)!=null&&d.length&&this.currentTask.get(n)===c&&(this.dispatch(kS(n,u.results)),this.state.documents[n].activeResultIndex===-1&&(this.dispatch(Kh(n,0)),this.notifyActiveResultChange(n,0)))}),c.wait(u=>{this.currentTask.delete(n);const d=u.total>0?0:-1;this.dispatch(Xs(n,u.results,u.total,d)),this.searchResult$.emit({documentId:n,results:u}),u.total>0&&this.notifyActiveResultChange(n,0)},u=>{var d;((d=u==null?void 0:u.reason)==null?void 0:d.code)!==ve.Cancelled&&(console.error("Error during search:",u),this.dispatch(Xs(n,[],0,-1))),this.currentTask.delete(n)}),c}nextResult(e){const n=this.state.documents[e];if(!n||n.results.length===0)return-1;const o=n.activeResultIndex>=n.results.length-1?0:n.activeResultIndex+1;return this.goToResult(o,e)}previousResult(e){const n=this.state.documents[e];if(!n||n.results.length===0)return-1;const o=n.activeResultIndex<=0?n.results.length-1:n.activeResultIndex-1;return this.goToResult(o,e)}goToResult(e,n){const o=this.state.documents[n];return!o||o.results.length===0||e<0||e>=o.results.length?-1:(this.dispatch(Kh(n,e)),this.notifyActiveResultChange(n,e),e)}async destroy(){for(const e of Object.keys(this.state.documents))this.stopSearchSession(e);this.searchResult$.clear(),this.searchStart$.clear(),this.searchStop$.clear(),this.searchActiveResultChange$.clear(),this.searchResultState$.clear(),this.searchState$.clear(),super.destroy()}};Zh.id="search";let Qh=Zh;const Jh="search",GS={manifest:{id:Jh,name:"Search Plugin",version:"1.0.0",provides:["search"],requires:[],optional:[],defaultConfig:{flags:[]}},create:(t,e)=>new Qh(Jh,t,e),reducer:IS,initialState:Xh},eg="thumbnail",LS={id:eg,name:"Thumbnail Plugin",version:"1.0.0",provides:["thumbnail"],requires:["render"],optional:["scroll"],defaultConfig:{width:150,gap:10,buffer:3,labelHeight:16,autoScroll:!0,scrollBehavior:"smooth",imagePadding:0,paddingY:0}},tg="THUMBNAIL/INIT_STATE",ng="THUMBNAIL/CLEANUP_STATE",$S="THUMBNAIL/SET_ACTIVE_DOCUMENT",og="THUMBNAIL/SET_WINDOW_STATE",rg="THUMBNAIL/UPDATE_VIEWPORT_METRICS";function ag(t,e){return{type:tg,payload:{documentId:t,state:e}}}function NS(t){return{type:ng,payload:t}}function jS(t,e){return{type:og,payload:{documentId:t,window:e}}}function US(t,e,n){return{type:rg,payload:{documentId:t,scrollY:e,viewportH:n}}}const BS={thumbs:[],window:null,viewportH:0,scrollY:0},ig={documents:{},activeDocumentId:null},zS=(t=ig,e)=>{switch(e.type){case tg:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case ng:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case $S:return{...t,activeDocumentId:e.payload};case og:{const{documentId:n,window:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,window:o}}}:t}case rg:{const{documentId:n,scrollY:o,viewportH:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:{...a,scrollY:o,viewportH:r}}}:t}default:return t}},sg=class extends jt{constructor(e,n,o){var r;super(e,n),this.cfg=o,this.scrollCapability=null,this.taskCaches=new Map,this.canAutoScroll=new Map,this.window$=Tt((a,i)=>({documentId:a,window:i})),this.scrollTo$=Tt((a,i)=>({documentId:a,options:i})),this.refreshPages$=Tt((a,i)=>({documentId:a,pages:i}),{cache:!1}),this.renderCapability=this.registry.getPlugin("render").provides(),this.scrollCapability=((r=this.registry.getPlugin("scroll"))==null?void 0:r.provides())??null,this.coreStore.onAction(Vo,a=>{const i=a.payload.documentId??this.getActiveDocumentId(),s=a.payload.pageIndexes;this.refreshPages$.emit(i,s);const l=this.taskCaches.get(i);if(l)for(const c of s)l.delete(c)}),this.scrollCapability&&this.cfg.autoScroll!==!1&&(this.scrollCapability.onPageChangeState(({documentId:a,state:i})=>{this.canAutoScroll.set(a,!i.isChanging),i.isChanging||this.scrollToThumb(i.targetPage-1,a)}),this.scrollCapability.onPageChange(({documentId:a,pageNumber:i})=>{this.canAutoScroll.get(a)!==!1&&this.scrollToThumb(i-1,a)}))}onDocumentLoadingStarted(e){this.dispatch(ag(e,{...BS})),this.taskCaches.set(e,new Map),this.canAutoScroll.set(e,!0),this.logger.debug("ThumbnailPlugin","DocumentOpened",`Initialized thumbnail state for document: ${e}`)}onDocumentLoaded(e){this.calculateWindowState(e)}onDocumentClosed(e){this.dispatch(NS(e));const n=this.taskCaches.get(e);n&&(n.forEach(o=>{o.abort({code:"cancelled",message:"Document closed"})}),n.clear(),this.taskCaches.delete(e)),this.canAutoScroll.delete(e),this.window$.clearScope(e),this.scrollTo$.clearScope(e),this.refreshPages$.clearScope(e),this.logger.debug("ThumbnailPlugin","DocumentClosed",`Cleaned up thumbnail state for document: ${e}`)}onRotationChanged(e){this.calculateWindowState(e)}buildCapability(){return{scrollToThumb:e=>this.scrollToThumb(e),renderThumb:(e,n)=>this.renderThumb(e,n),updateWindow:(e,n)=>this.updateWindow(e,n),getWindow:()=>this.getWindow(),forDocument:e=>this.createThumbnailScope(e),onWindow:this.window$.onGlobal,onScrollTo:this.scrollTo$.onGlobal,onRefreshPages:this.refreshPages$.onGlobal}}createThumbnailScope(e){return{scrollToThumb:n=>this.scrollToThumb(n,e),renderThumb:(n,o)=>this.renderThumb(n,o,e),updateWindow:(n,o)=>this.updateWindow(n,o,e),getWindow:()=>this.getWindow(e),onWindow:this.window$.forScope(e),onScrollTo:this.scrollTo$.forScope(e),onRefreshPages:this.refreshPages$.forScope(e)}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}calculateWindowState(e){const n=this.coreState.core.documents[e];if(!(n!=null&&n.document))return;const o=this.cfg.width??120,r=this.cfg.labelHeight??16,a=this.cfg.gap??8,i=this.cfg.imagePadding??0,s=this.cfg.paddingY??0,l=Math.max(1,o-2*i);let c=s;const u=n.document.pages.map(h=>{const g=h.rotation%2===1,f=g?h.size.height:h.size.width,y=(g?h.size.width:h.size.height)/f,_=Math.round(l*y),E=i+_+i+r,A={pageIndex:h.index,width:l,height:_,wrapperHeight:E,top:c,labelHeight:r,padding:i};return c+=E+a,A}),d={start:-1,end:-1,items:[],totalHeight:c-a+s},p=this.getDocumentState(e);p&&(this.dispatch(ag(e,{...p,thumbs:u,window:d})),p.viewportH>0?this.updateWindow(p.scrollY,p.viewportH,e):this.window$.emit(e,d))}updateWindow(e,n,o){const r=o??this.getActiveDocumentId(),a=this.getDocumentState(r);if(!a||!a.window||a.thumbs.length===0)return;const i=this.cfg.buffer??3;this.dispatch(US(r,e,n));let s=0,l=a.thumbs.length-1,c=0;for(;s<=l;){const g=s+l>>1,f=a.thumbs[g];f.top+f.wrapperHeight<e?s=g+1:(c=g,l=g-1)}let u=c;const d=e+n;for(;u+1<a.thumbs.length&&a.thumbs[u].top<d;)u++;u=Math.min(a.thumbs.length-1,u+i);const p=Math.max(0,c-i);if(p===a.window.start&&u===a.window.end)return;const h={start:p,end:u,items:a.thumbs.slice(p,u+1),totalHeight:a.window.totalHeight};this.dispatch(jS(r,h)),this.window$.emit(r,h)}getWindow(e){const n=this.getDocumentState(e);return(n==null?void 0:n.window)??null}scrollToThumb(e,n){const o=n??this.getActiveDocumentId(),r=this.getDocumentState(o);if(!r||!r.window)return;const a=r.thumbs[e];if(!a)return;const i=this.cfg.scrollBehavior??"smooth",s=this.cfg.paddingY??0;if(r.viewportH<=0){const h=Math.max(s,a.top-a.wrapperHeight);this.scrollTo$.emit(o,{top:h,behavior:i});return}const l=8,c=a.top,u=a.top+a.wrapperHeight,d=c<r.scrollY+l+s,p=u>r.scrollY+r.viewportH-l;d?this.scrollTo$.emit(o,{top:Math.max(0,c-s),behavior:i}):p&&this.scrollTo$.emit(o,{top:Math.max(0,u-r.viewportH+s),behavior:i})}renderThumb(e,n,o){const r=o??this.getActiveDocumentId(),a=this.taskCaches.get(r);if(!a)throw new Error(`Task cache not found for document: ${r}`);if(a.has(e))return a.get(e);const i=this.coreState.core.documents[r];if(!(i!=null&&i.document))throw new Error(`Document not found: ${r}`);const s=i.document.pages[e];if(!s)throw new Error(`Page ${e} not found in document: ${r}`);const l=this.cfg.width??120,c=this.cfg.imagePadding??0,d=Math.max(1,l-2*c)/s.size.width,p=this.renderCapability.forDocument(r).renderPageRect({pageIndex:e,rect:{origin:{x:0,y:0},size:s.size},options:{scaleFactor:d,dpr:n,rotation:s.rotation}});return a.set(e,p),p.wait(Yt,()=>a.delete(e)),p}async initialize(){this.logger.info("ThumbnailPlugin","Initialize","Thumbnail plugin initialized")}async destroy(){this.window$.clear(),this.refreshPages$.clear(),this.scrollTo$.clear(),this.taskCaches.forEach(e=>{e.forEach(n=>{n.abort({code:"cancelled",message:"Plugin destroyed"})}),e.clear()}),this.taskCaches.clear(),this.canAutoScroll.clear(),super.destroy()}};sg.id="thumbnail";let Zs=sg;const WS={manifest:LS,create:(t,e)=>new Zs(eg,t,e),reducer:zS,initialState:ig},lg="tiling",HS={id:lg,name:"Tiling Plugin",version:"1.0.0",provides:["tiling"],requires:["render","scroll","viewport"],optional:[],defaultConfig:{tileSize:768,overlapPx:2.5,extraRings:0}},cg="TILING/INIT_STATE",ug="TILING/CLEANUP_STATE",dg="TILING/UPDATE_VISIBLE_TILES",pg="TILING/MARK_TILE_STATUS",VS=(t,e)=>({type:cg,payload:{documentId:t,state:e}}),YS=t=>({type:ug,payload:t}),hg=(t,e)=>({type:dg,payload:{documentId:t,tiles:e}}),gg=(t,e,n,o)=>({type:pg,payload:{documentId:t,pageIndex:e,tileId:n,status:o}}),qS={visibleTiles:{}},KS={documents:{}},XS=(t,e)=>{var n,o;switch(e.type){case cg:{const{documentId:r,state:a}=e.payload;return{...t,documents:{...t.documents,[r]:a}}}case ug:{const r=e.payload,{[r]:a,...i}=t.documents;return{...t,documents:i}}case dg:{const{documentId:r,tiles:a}=e.payload,i=t.documents[r];if(!i)return t;const s={...i.visibleTiles};for(const l in a){const c=Number(l),u=a[c],d=s[c]??[],p=(n=d.find(f=>!f.isFallback))==null?void 0:n.srcScale,h=u.length>0?u[0].srcScale:p;if(p!==void 0&&p!==h){const f=d.filter(y=>!y.isFallback&&y.status==="ready").map(y=>({...y,isFallback:!0})),F=f.length>0?[]:d.filter(y=>y.isFallback);s[c]=[...F,...f,...u]}else{const f=new Set(u.map(_=>_.id)),F=[],y=new Set;for(const _ of d)(_.isFallback||f.has(_.id))&&(F.push(_),y.add(_.id));for(const _ of u)y.has(_.id)||F.push(_);s[c]=F}}return{...t,documents:{...t.documents,[r]:{...i,visibleTiles:s}}}}case pg:{const{documentId:r,pageIndex:a,tileId:i,status:s}=e.payload,l=t.documents[r];if(!l)return t;const c=((o=l.visibleTiles[a])==null?void 0:o.map(h=>h.id===i?{...h,status:s}:h))??[],u=c.filter(h=>!h.isFallback),p=u.length>0&&u.every(h=>h.status==="ready")?u:c;return{...t,documents:{...t.documents,[r]:{...l,visibleTiles:{...l.visibleTiles,[a]:p}}}}}default:return t}};function fg({tileSize:t=768,overlapPx:e=2.5,extraRings:n=0,scale:o,rotation:r,page:a,metric:i}){const s=a.size.width*o,l=a.size.height*o,c=t-e,u=Ta(a.size,r,o),d={origin:{x:i.scaled.pageX,y:i.scaled.pageY},size:{width:i.scaled.visibleWidth,height:i.scaled.visibleHeight}},p=rF(u,d,r,1),h=p.origin.x,g=p.origin.y,f=h+p.size.width,F=g+p.size.height,y=Math.floor((s-1)/c),_=Math.floor((l-1)/c),E=Math.max(0,Math.floor(h/c)-n),A=Math.min(y,Math.floor((f-1)/c)+n),T=Math.max(0,Math.floor(g/c)-n),q=Math.min(_,Math.floor((F-1)/c)+n),w=[];for(let G=E;G<=A;G++){const W=G*c,J=Math.min(t,s-W),ue=W/o,ce=J/o;for(let ee=T;ee<=q;ee++){const ge=ee*c,ye=Math.min(t,l-ge),Ee=ge/o,Te=ye/o;w.push({id:`p${a.index}-${o}-x${W}-y${ge}-w${J}-h${ye}`,col:G,row:ee,pageRect:{origin:{x:ue,y:Ee},size:{width:ce,height:Te}},screenRect:{origin:{x:W,y:ge},size:{width:J,height:ye}},status:"queued",srcScale:o,isFallback:!1})}}return w}const mg=class extends jt{constructor(e,n,o){super(e,n),this.tileRendering$=Be(),this.config=o,this.renderCapability=this.registry.getPlugin("render").provides(),this.scrollCapability=this.registry.getPlugin("scroll").provides(),this.viewportCapability=this.registry.getPlugin("viewport").provides(),this.scrollCapability.onScroll(r=>this.calculateVisibleTiles(r.documentId,r.metrics),{mode:"throttle",wait:50,throttleMode:"trailing"}),this.coreStore.onAction(Vo,r=>this.recalculateTiles(r.payload))}onDocumentLoadingStarted(e){this.dispatch(VS(e,qS))}onDocumentClosed(e){this.dispatch(YS(e))}onScaleChanged(e){this.recalculateTilesForDocument(e)}onRotationChanged(e){this.recalculateTilesForDocument(e)}recalculateTilesForDocument(e){const n=this.scrollCapability.forDocument(e),o=this.viewportCapability.forDocument(e),r=n.getMetrics(o.getMetrics());this.calculateVisibleTiles(e,r)}async recalculateTiles(e){const{documentId:n,pageIndexes:o}=e,r=this.getCoreDocument(n);if(!r||!r.document)return;const a=this.scrollCapability.forDocument(n),i=this.viewportCapability.forDocument(n),s=a.getMetrics(i.getMetrics()),l={},c=Date.now(),u=r.scale;for(const d of o){const p=s.pageVisibilityMetrics.find(f=>f.pageNumber===d+1);if(!p)continue;const h=r.document.pages[d];if(!h)continue;const g=((h.rotation??0)+r.rotation)%4;l[d]=fg({page:h,metric:p,scale:u,rotation:g,tileSize:this.config.tileSize,overlapPx:this.config.overlapPx,extraRings:this.config.extraRings}).map(f=>({...f,id:`${f.id}-r${c}`}))}Object.keys(l).length>0&&this.dispatch(hg(n,l))}async initialize(){}calculateVisibleTiles(e,n){const o=this.getCoreDocument(e);if(!o||!o.document)return;const r=o.scale,a={};for(const i of n.pageVisibilityMetrics){const s=i.pageNumber-1,l=o.document.pages[s];if(!l)continue;const c=((l.rotation??0)+o.rotation)%4,u=fg({page:l,metric:i,scale:r,rotation:c,tileSize:this.config.tileSize,overlapPx:this.config.overlapPx,extraRings:this.config.extraRings});a[s]=u}this.dispatch(hg(e,a))}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r!==a&&this.tileRendering$.emit({documentId:o,tiles:a.visibleTiles})}}buildCapability(){return{renderTile:this.renderTile.bind(this),forDocument:this.createTilingScope.bind(this),onTileRendering:this.tileRendering$.on}}createTilingScope(e){return{renderTile:n=>this.renderTile(n,e),onTileRendering:n=>this.tileRendering$.on(o=>{o.documentId===e&&n(o.tiles)})}}renderTile(e,n){const o=n??this.getActiveDocumentId();if(!this.renderCapability)throw new Error("Render capability not available.");this.dispatch(gg(o,e.pageIndex,e.tile.id,"rendering"));const r=this.renderCapability.forDocument(o).renderPageRect({pageIndex:e.pageIndex,rect:e.tile.pageRect,options:{scaleFactor:e.tile.srcScale,dpr:e.dpr}});return r.wait(()=>{this.dispatch(gg(o,e.pageIndex,e.tile.id,"ready"))},Yt),r}};mg.id="tiling";let Pg=mg;const ZS={manifest:HS,create:(t,e)=>new Pg(lg,t,e),reducer:(t,e)=>XS(t,e),initialState:KS},Fg="viewport",QS={id:Fg,name:"Viewport Plugin",version:"1.0.0",provides:["viewport"],requires:[],optional:[],defaultConfig:{viewportGap:10,scrollEndDelay:300}},bg="INIT_VIEWPORT_STATE",yg="CLEANUP_VIEWPORT_STATE",_g="REGISTER_VIEWPORT",vg="UNREGISTER_VIEWPORT",Dg="SET_VIEWPORT_METRICS",Sg="SET_VIEWPORT_SCROLL_METRICS",Eg="SET_VIEWPORT_GAP",Ag="SET_SCROLL_ACTIVITY",xg="SET_SMOOTH_SCROLL_ACTIVITY",JS="SET_ACTIVE_VIEWPORT_DOCUMENT",Cg="ADD_VIEWPORT_GATE",Tg="REMOVE_VIEWPORT_GATE";function eE(t){return{type:bg,payload:{documentId:t}}}function tE(t){return{type:yg,payload:{documentId:t}}}function nE(t){return{type:_g,payload:{documentId:t}}}function oE(t){return{type:vg,payload:{documentId:t}}}function rE(t){return{type:Eg,payload:t}}function aE(t,e){return{type:Dg,payload:{documentId:t,metrics:e}}}function iE(t,e){return{type:Sg,payload:{documentId:t,scrollMetrics:e}}}function sE(t,e){return{type:Ag,payload:{documentId:t,isScrolling:e}}}function Mg(t,e){return{type:xg,payload:{documentId:t,isSmoothScrolling:e}}}function lE(t,e){return{type:Cg,payload:{documentId:t,key:e}}}function cE(t,e){return{type:Tg,payload:{documentId:t,key:e}}}const uE={viewportMetrics:{width:0,height:0,scrollTop:0,scrollLeft:0,clientWidth:0,clientHeight:0,scrollWidth:0,scrollHeight:0,clientLeft:0,clientTop:0,relativePosition:{x:0,y:0}},isScrolling:!1,isSmoothScrolling:!1,gates:new Set},Rg={viewportGap:0,documents:{},activeViewports:new Set,activeDocumentId:null},dE=(t=Rg,e)=>{switch(e.type){case bg:{const{documentId:n}=e.payload;return{...t,documents:{...t.documents,[n]:{...uE,gates:new Set}}}}case yg:{const{documentId:n}=e.payload,{[n]:o,...r}=t.documents,a=new Set(t.activeViewports);return a.delete(n),{...t,documents:r,activeViewports:a,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case _g:{const{documentId:n}=e.payload,o=new Set(t.activeViewports);return o.add(n),{...t,activeViewports:o,activeDocumentId:t.activeDocumentId??n}}case vg:{const{documentId:n}=e.payload,o=new Set(t.activeViewports);return o.delete(n),{...t,activeViewports:o}}case JS:return{...t,activeDocumentId:e.payload};case Eg:return{...t,viewportGap:e.payload};case Dg:{const{documentId:n,metrics:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,viewportMetrics:{width:o.width,height:o.height,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft,clientWidth:o.clientWidth,clientHeight:o.clientHeight,scrollWidth:o.scrollWidth,scrollHeight:o.scrollHeight,clientLeft:o.clientLeft,clientTop:o.clientTop,relativePosition:{x:o.scrollWidth<=o.clientWidth?0:o.scrollLeft/(o.scrollWidth-o.clientWidth),y:o.scrollHeight<=o.clientHeight?0:o.scrollTop/(o.scrollHeight-o.clientHeight)}}}}}:t}case Sg:{const{documentId:n,scrollMetrics:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,viewportMetrics:{...r.viewportMetrics,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft},isScrolling:!0}}}:t}case Ag:{const{documentId:n,isScrolling:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isScrolling:o}}}:t}case xg:{const{documentId:n,isSmoothScrolling:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isSmoothScrolling:o}}}:t}case Cg:{const{documentId:n,key:o}=e.payload,r=t.documents[n];if(!r)return t;const a=new Set(r.gates);return a.add(o),{...t,documents:{...t.documents,[n]:{...r,gates:a}}}}case Tg:{const{documentId:n,key:o}=e.payload,r=t.documents[n];if(!r)return t;const a=new Set(r.gates);return a.delete(o),{...t,documents:{...t.documents,[n]:{...r,gates:a}}}}default:return t}},wg=class extends jt{constructor(e,n,o){super(e,n),this.id=e,this.viewportResize$=Be(),this.viewportMetrics$=Be(),this.scrollMetrics$=Be(),this.scrollActivity$=Be(),this.gateState$=Be(),this.scrollRequests$=new Map,o.viewportGap&&this.dispatch(rE(o.viewportGap)),this.scrollEndDelay=o.scrollEndDelay||100}onDocumentLoadingStarted(e){this.dispatch(eE(e)),this.scrollRequests$.set(e,$n()),this.logger.debug("ViewportPlugin","DocumentOpened",`Initialized viewport state for document: ${e}`)}onDocumentClosed(e){var n;this.dispatch(tE(e)),(n=this.scrollRequests$.get(e))==null||n.clear(),this.scrollRequests$.delete(e),this.logger.debug("ViewportPlugin","DocumentClosed",`Cleaned up viewport state for document: ${e}`)}buildCapability(){return{getViewportGap:()=>this.state.viewportGap,getMetrics:()=>this.getMetrics(),scrollTo:e=>this.scrollTo(e),isScrolling:()=>this.isScrolling(),isSmoothScrolling:()=>this.isSmoothScrolling(),isGated:e=>this.isGated(e),hasGate:(e,n)=>this.hasGate(e,n),getGates:e=>this.getGates(e),forDocument:e=>this.createViewportScope(e),gate:(e,n)=>this.gate(e,n),releaseGate:(e,n)=>this.releaseGate(e,n),isViewportMounted:e=>this.state.activeViewports.has(e),onViewportChange:this.viewportMetrics$.on,onViewportResize:this.viewportResize$.on,onScrollChange:this.scrollMetrics$.on,onScrollActivity:this.scrollActivity$.on,onGateChange:this.gateState$.on}}createViewportScope(e){return{getMetrics:()=>this.getMetrics(e),scrollTo:n=>this.scrollTo(n,e),isScrolling:()=>this.isScrolling(e),isSmoothScrolling:()=>this.isSmoothScrolling(e),isGated:()=>this.isGated(e),hasGate:n=>this.hasGate(n,e),getGates:()=>this.getGates(e),gate:n=>this.gate(n,e),releaseGate:n=>this.releaseGate(n,e),onViewportChange:n=>this.viewportMetrics$.on(o=>{o.documentId===e&&n(o.metrics)}),onScrollChange:n=>this.scrollMetrics$.on(o=>{o.documentId===e&&n(o.scrollMetrics)}),onScrollActivity:n=>this.scrollActivity$.on(o=>{o.documentId===e&&n(o.activity)}),onGateChange:n=>this.gateState$.on(o=>{(o==null?void 0:o.documentId)===e&&n(o)})}}registerViewport(e){if(!this.state.documents[e])throw new Error(`Cannot register viewport for ${e}: document state not found. Document must be opened before registering viewport.`);this.state.activeViewports.has(e)||(this.dispatch(nE(e)),this.logger.debug("ViewportPlugin","RegisterViewport",`Registered viewport (DOM mounted) for document: ${e}`))}unregisterViewport(e){this.registry.isDestroyed()||this.state.activeViewports.has(e)&&(this.dispatch(oE(e)),this.logger.debug("ViewportPlugin","UnregisterViewport",`Unregistered viewport (DOM unmounted) for document: ${e}. State preserved.`))}setViewportResizeMetrics(e,n){if(this.registry.isDestroyed())return;this.dispatch(aE(e,n));const o=this.state.documents[e];o&&this.viewportResize$.emit({documentId:e,metrics:o.viewportMetrics})}setViewportScrollMetrics(e,n){if(this.registry.isDestroyed())return;const o=this.state.documents[e];o&&(n.scrollTop!==o.viewportMetrics.scrollTop||n.scrollLeft!==o.viewportMetrics.scrollLeft)&&(this.dispatch(iE(e,n)),this.bumpScrollActivity(e),this.scrollMetrics$.emit({documentId:e,scrollMetrics:n}))}onScrollRequest(e,n){const o=this.scrollRequests$.get(e);if(!o)throw new Error(`Cannot subscribe to scroll requests for ${e}: document state not initialized`);return o.on(n)}gate(e,n){const o=this.state.documents[n];if(!o){this.logger.warn("ViewportPlugin","GateViewport",`Cannot gate viewport for ${n}: document not found`);return}o.gates.has(e)||(this.dispatch(lE(n,e)),this.logger.debug("ViewportPlugin","GateAdded",`Added gate '${e}' for document: ${n}. Total gates: ${o.gates.size+1}`))}releaseGate(e,n){const o=this.state.documents[n];if(!o){this.logger.warn("ViewportPlugin","ReleaseGate",`Cannot release gate for ${n}: document not found`);return}o.gates.has(e)&&(this.dispatch(cE(n,e)),this.logger.debug("ViewportPlugin","GateReleased",`Released gate '${e}' for document: ${n}. Remaining gates: ${o.gates.size-1}`))}getViewportState(e){const n=e??this.getActiveDocumentId(),o=this.state.documents[n];if(!o)throw new Error(`Viewport state not found for document: ${n}`);return o}getMetrics(e){return this.getViewportState(e).viewportMetrics}isScrolling(e){return this.getViewportState(e).isScrolling}isSmoothScrolling(e){return this.getViewportState(e).isSmoothScrolling}isGated(e){return this.getViewportState(e).gates.size>0}hasGate(e,n){return this.getViewportState(n).gates.has(e)}getGates(e){const n=this.getViewportState(e);return Array.from(n.gates)}scrollTo(e,n){const o=n??this.getActiveDocumentId(),r=this.getViewportState(o),{x:a,y:i,alignX:s,alignY:l,behavior:c="auto"}=e;c==="smooth"&&this.dispatch(Mg(o,!0));const u=r.viewportMetrics;let d=a,p=i;s!==void 0&&(d=a-u.clientWidth*(s/100)),l!==void 0&&(p=i-u.clientHeight*(l/100));const h=this.scrollRequests$.get(o);h&&h.emit({x:d,y:p,behavior:c})}bumpScrollActivity(e){this.debouncedDispatch(sE(e,!1),this.scrollEndDelay),this.debouncedDispatch(Mg(e,!1),this.scrollEndDelay)}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];if(r!==a&&(this.viewportMetrics$.emit({documentId:o,metrics:a.viewportMetrics}),r&&(r.isScrolling!==a.isScrolling||r.isSmoothScrolling!==a.isSmoothScrolling)&&this.scrollActivity$.emit({documentId:o,activity:{isScrolling:a.isScrolling,isSmoothScrolling:a.isSmoothScrolling}}),r&&r.gates!==a.gates)){const i=Array.from(r.gates),s=Array.from(a.gates),l=s.find(u=>!i.includes(u)),c=i.find(u=>!s.includes(u));this.gateState$.emit({documentId:o,isGated:a.gates.size>0,gates:s,addedGate:l,removedGate:c}),this.logger.debug("ViewportPlugin","GateStateChanged",`Gate state changed for document ${o}. Gates: [${s.join(", ")}], Gated: ${a.gates.size>0}`)}}}async initialize(e){this.logger.info("ViewportPlugin","Initialize","Viewport plugin initialized")}async destroy(){this.viewportMetrics$.clear(),this.viewportResize$.clear(),this.scrollMetrics$.clear(),this.scrollActivity$.clear(),this.gateState$.clear(),this.scrollRequests$.forEach(e=>e.clear()),this.scrollRequests$.clear(),super.destroy()}};wg.id="viewport";let Qs=wg;const pE={manifest:QS,create:(t,e)=>new Qs(Fg,t,e),reducer:dE,initialState:Rg};var Mt=(t=>(t.Automatic="automatic",t.FitPage="fit-page",t.FitWidth="fit-width",t))(Mt||{}),So=(t=>(t[t.Center=0]="Center",t[t.Top=1]="Top",t))(So||{});const Og="zoom",hE={id:Og,name:"Zoom Plugin",version:"1.0.0",provides:["zoom"],requires:["viewport","scroll"],optional:["interaction-manager","spread"],defaultConfig:{defaultZoomLevel:Mt.Automatic,minZoom:.2,maxZoom:60,zoomStep:.1,zoomRanges:[{min:.2,max:.5,step:.05},{min:.5,max:1,step:.1},{min:1,max:2,step:.2},{min:2,max:4,step:.4},{min:4,max:10,step:.8},{min:10,max:20,step:1.6},{min:20,max:40,step:3.2},{min:40,max:60,step:6.4}],presets:[{name:"Fit Page",value:Mt.FitPage},{name:"Fit Width",value:Mt.FitWidth},{name:"Automatic",value:Mt.Automatic},{name:"25%",value:.25},{name:"50%",value:.5},{name:"100%",value:1},{name:"125%",value:1.25},{name:"150%",value:1.5},{name:"200%",value:2},{name:"400%",value:4},{name:"800%",value:8},{name:"1600%",value:16}]}},kg="ZOOM/INIT_STATE",Ig="ZOOM/CLEANUP_STATE",gE="ZOOM/SET_ACTIVE_DOCUMENT",Gg="ZOOM/SET_ZOOM_LEVEL",Lg="ZOOM/SET_MARQUEE_ZOOM_ACTIVE";function fE(t,e){return{type:kg,payload:{documentId:t,state:e}}}function mE(t){return{type:Ig,payload:t}}function PE(t,e,n){return{type:Gg,payload:{documentId:t,zoomLevel:e,currentZoomLevel:n}}}function FE(t,e){return{type:Lg,payload:{documentId:t,isActive:e}}}const ai={zoomLevel:Mt.Automatic,currentZoomLevel:1,isMarqueeZoomActive:!1},$g={documents:{},activeDocumentId:null},bE=(t=$g,e)=>{switch(e.type){case kg:{const{documentId:n,state:o}=e.payload;return{...t,documents:{...t.documents,[n]:o},activeDocumentId:t.activeDocumentId??n}}case Ig:{const n=e.payload,{[n]:o,...r}=t.documents;return{...t,documents:r,activeDocumentId:t.activeDocumentId===n?null:t.activeDocumentId}}case gE:return{...t,activeDocumentId:e.payload};case Gg:{const{documentId:n,zoomLevel:o,currentZoomLevel:r}=e.payload,a=t.documents[n];return a?{...t,documents:{...t.documents,[n]:{...a,zoomLevel:o,currentZoomLevel:r}}}:t}case Lg:{const{documentId:n,isActive:o}=e.payload,r=t.documents[n];return r?{...t,documents:{...t.documents,[n]:{...r,isMarqueeZoomActive:o}}}:t}default:return t}};function yE(t){const{pageSize:e,scale:n,minDragPx:o=5,onPreview:r,onCommit:a,onSmallDrag:i}=t;let s=null,l=null;return{onPointerDown:(c,u)=>{var d;s=c,l={origin:{x:c.x,y:c.y},size:{width:0,height:0}},r==null||r(l),(d=u.setPointerCapture)==null||d.call(u)},onPointerMove:c=>{if(!s)return;const u=et(c.x,0,e.width),d=et(c.y,0,e.height);l={origin:{x:Math.min(s.x,u),y:Math.min(s.y,d)},size:{width:Math.abs(u-s.x),height:Math.abs(d-s.y)}},r==null||r(l)},onPointerUp:(c,u)=>{var d;l&&(Math.max(l.size.width,l.size.height)*n>o?a==null||a(l):i==null||i()),s=null,l=null,r==null||r(null),(d=u.releasePointerCapture)==null||d.call(u)},onPointerCancel:(c,u)=>{var d;s=null,l=null,r==null||r(null),(d=u.releasePointerCapture)==null||d.call(u)}}}const Ng=class extends jt{constructor(e,n,o){var r,a,i;super(e,n),this.zoom$=$n(),this.state$=Be(),this.viewportPlugin=n.getPlugin("viewport"),this.viewport=this.viewportPlugin.provides(),this.scroll=n.getPlugin("scroll").provides();const s=n.getPlugin("interaction-manager");this.interactionManager=(s==null?void 0:s.provides())??null;const l=n.getPlugin("spread");this.spread=(l==null?void 0:l.provides())??null,this.minZoom=o.minZoom??.25,this.maxZoom=o.maxZoom??10,this.zoomStep=o.zoomStep??.1,this.defaultZoomLevel=o.defaultZoomLevel,this.presets=o.presets??[],this.zoomRanges=this.normalizeRanges(o.zoomRanges??[]),this.viewport.onViewportResize(c=>this.recalcAuto(c.documentId,So.Top),{mode:"debounce",wait:150,keyExtractor:c=>c.documentId}),(r=this.spread)==null||r.onSpreadChange(c=>{this.recalcAuto(c.documentId,So.Top)}),(a=this.interactionManager)==null||a.registerMode({id:"marqueeZoom",scope:"page",exclusive:!0,cursor:"zoom-in"}),(i=this.interactionManager)==null||i.onModeChange(c=>{const u=c.activeMode==="marqueeZoom",d=this.getDocumentState(c.documentId);d&&d.isMarqueeZoomActive!==u&&this.dispatch(FE(c.documentId,u))})}onDocumentLoadingStarted(e){this.viewport.gate("zoom",e);const n={...ai,zoomLevel:this.defaultZoomLevel};this.dispatch(fE(e,n)),this.logger.debug("ZoomPlugin","DocumentOpened",`Initialized zoom state for document: ${e}`)}onDocumentLoaded(e){this.recalcAuto(e,So.Top)}onDocumentClosed(e){this.dispatch(mE(e)),this.logger.debug("ZoomPlugin","DocumentClosed",`Cleaned up zoom state for document: ${e}`)}onRotationChanged(e){this.recalcAuto(e,So.Top)}buildCapability(){return{requestZoom:(e,n)=>this.requestZoom(e,n),requestZoomBy:(e,n)=>this.requestZoomBy(e,n),zoomIn:()=>this.zoomIn(),zoomOut:()=>this.zoomOut(),zoomToArea:(e,n)=>this.zoomToArea(e,n),enableMarqueeZoom:()=>this.enableMarqueeZoom(),disableMarqueeZoom:()=>this.disableMarqueeZoom(),toggleMarqueeZoom:()=>this.toggleMarqueeZoom(),isMarqueeZoomActive:()=>this.isMarqueeZoomActive(),getState:()=>this.getDocumentStateOrThrow(),forDocument:e=>this.createZoomScope(e),registerMarqueeOnPage:e=>this.registerMarqueeOnPage(e),getPresets:()=>this.presets,onZoomChange:this.zoom$.on,onStateChange:this.state$.on}}createZoomScope(e){return{requestZoom:(n,o)=>this.requestZoom(n,o,e),requestZoomBy:(n,o)=>this.requestZoomBy(n,o,e),zoomIn:()=>this.zoomIn(e),zoomOut:()=>this.zoomOut(e),zoomToArea:(n,o)=>this.zoomToArea(n,o,e),enableMarqueeZoom:()=>this.enableMarqueeZoom(e),disableMarqueeZoom:()=>this.disableMarqueeZoom(e),toggleMarqueeZoom:()=>this.toggleMarqueeZoom(e),isMarqueeZoomActive:()=>this.isMarqueeZoomActive(e),getState:()=>this.getDocumentStateOrThrow(e),onZoomChange:n=>this.zoom$.on(o=>{o.documentId===e&&n(o)}),onStateChange:n=>this.state$.on(o=>{o.documentId===e&&n(o.state)})}}getDocumentState(e){const n=e??this.getActiveDocumentId();return this.state.documents[n]??null}getDocumentStateOrThrow(e){const n=this.getDocumentState(e);if(!n)throw new Error(`Zoom state not found for document: ${e??"active"}`);return n}requestZoom(e,n,o){this.handleRequest({level:e,center:n},o)}requestZoomBy(e,n,o){const r=o??this.getActiveDocumentId(),i=this.getDocumentStateOrThrow(r).currentZoomLevel,s=this.toZoom(i+e);this.handleRequest({level:s,center:n},r)}zoomIn(e){const n=e??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(n).currentZoomLevel;this.handleRequest({level:r,delta:this.stepFor(r)},n)}zoomOut(e){const n=e??this.getActiveDocumentId(),r=this.getDocumentStateOrThrow(n).currentZoomLevel;this.handleRequest({level:r,delta:-this.stepFor(r)},n)}zoomToArea(e,n,o){const r=o??this.getActiveDocumentId();this.handleZoomToArea(r,e,n)}enableMarqueeZoom(e){var n;const o=e??this.getActiveDocumentId();(n=this.interactionManager)==null||n.forDocument(o).activate("marqueeZoom")}disableMarqueeZoom(e){var n;const o=e??this.getActiveDocumentId();(n=this.interactionManager)==null||n.forDocument(o).activateDefaultMode()}toggleMarqueeZoom(e){var n;const o=e??this.getActiveDocumentId(),r=(n=this.interactionManager)==null?void 0:n.forDocument(o);(r==null?void 0:r.getActiveMode())==="marqueeZoom"?r.activateDefaultMode():r==null||r.activate("marqueeZoom")}isMarqueeZoomActive(e){var n;const o=e??this.getActiveDocumentId();return((n=this.interactionManager)==null?void 0:n.forDocument(o).getActiveMode())==="marqueeZoom"}handleRequest({level:e,delta:n=0,center:o,focus:r=So.Center,align:a="keep"},i){const s=i??this.getActiveDocumentId(),l=this.getDocumentStateOrThrow(s);if(!this.coreState.core.documents[s])return;const u=this.viewport.forDocument(s),d=u.getMetrics(),p=l.currentZoomLevel;if(d.clientWidth===0||d.clientHeight===0)return;const h=typeof e=="number"?e:this.computeZoomForMode(s,e,d);if(h===!1)return;const g=et(h+n,this.minZoom,this.maxZoom),f=Math.floor(g*1e3)/1e3,F=o??{vx:d.clientWidth/2,vy:r===So.Top?0:d.clientHeight/2},{desiredScrollLeft:y,desiredScrollTop:_}=this.computeScrollForZoomChange(s,d,p,f,F,a);!isNaN(y)&&!isNaN(_)&&this.viewportPlugin.setViewportScrollMetrics(s,{scrollLeft:y,scrollTop:_}),this.dispatch(PE(s,typeof e=="number"?f:e,f)),this.dispatchCoreAction(IF(f,s)),this.viewport.isGated(s)&&this.viewport.releaseGate("zoom",s),u.scrollTo({x:y,y:_,behavior:"instant"});const E={documentId:s,oldZoom:p,newZoom:f,level:e,center:F,desiredScrollLeft:y,desiredScrollTop:_,viewport:d};this.zoom$.emit(E)}computeZoomForMode(e,n,o){if(!this.coreState.core.documents[e])return!1;const a=this.scroll.forDocument(e),i=a?this.scroll.getPageGap():0,s=this.viewport.getViewportGap(),l=a.getSpreadPagesWithRotatedSize();if(!l.length||o.clientWidth===0||o.clientHeight===0)return!1;const c=o.clientWidth-2*s,u=o.clientHeight-2*s;if(c<=0||u<=0)return!1;let d=0,p=0;switch(l.forEach(h=>{const g=h.reduce((F,y,_)=>F+y.rotatedSize.width+(_?i:0),0),f=Math.max(...h.map(F=>F.rotatedSize.height));d=Math.max(d,g),p=Math.max(p,f)}),n){case Mt.FitWidth:return c/d;case Mt.FitPage:return Math.min(c/d,u/p);case Mt.Automatic:return Math.min(c/d,1);default:return 1}}computeScrollForZoomChange(e,n,o,r,a,i="keep"){const l=this.scroll.forDocument(e).getLayout(),c=this.viewport.getViewportGap(),u=l.totalContentSize.width,d=l.totalContentSize.height,p=n.clientWidth-2*c,h=n.clientHeight-2*c,g=(W,J,ue)=>J*ue<W?(W-J*ue)/2:0,f=g(p,u,o),F=g(h,d,o),y=g(p,u,r),_=g(h,d,r),E=(n.scrollLeft+a.vx-c-f)/o,A=(n.scrollTop+a.vy-c-F)/o,T=E*r+c+y,q=A*r+c+_,w=i==="center"?T-n.clientWidth/2:T-a.vx,G=i==="center"?q-n.clientHeight/2:q-a.vy;return{desiredScrollLeft:Math.max(0,w),desiredScrollTop:Math.max(0,G)}}handleZoomToArea(e,n,o){const r=this.coreState.core.documents[e];if(!r)return;const a=r.rotation,s=this.viewport.forDocument(e).getMetrics(),l=this.viewport.getViewportGap(),u=this.getDocumentStateOrThrow(e).currentZoomLevel,d=s.clientWidth-2*l,p=s.clientHeight-2*l,g=this.scroll.forDocument(e).getLayout(),f=g.virtualItems.find(ce=>ce.pageLayouts.some(ee=>ee.pageIndex===n));if(!f)return;const F=f.pageLayouts.find(ce=>ce.pageIndex===n),y=Xi({width:F.width,height:F.height},o,a),_=this.toZoom(Math.min(d/y.size.width,p/y.size.height)),E=f.x+F.x,A=f.y+F.y,T=E+y.origin.x+y.size.width/2,q=A+y.origin.y+y.size.height/2,w=(ce,ee,ge)=>ee*ge<ce?(ce-ee*ge)/2:0,G=w(d,g.totalContentSize.width,u),W=w(p,g.totalContentSize.height,u),J=l+G+T*u-s.scrollLeft,ue=l+W+q*u-s.scrollTop;this.handleRequest({level:_,center:{vx:J,vy:ue},align:"center"},e)}recalcAuto(e,n){const o=this.getDocumentState(e);o&&(o.zoomLevel===Mt.Automatic||o.zoomLevel===Mt.FitPage||o.zoomLevel===Mt.FitWidth)&&this.handleRequest({level:o.zoomLevel,focus:n},e)}normalizeRanges(e){return[...e].filter(n=>n.step>0&&n.max>n.min).sort((n,o)=>n.min-o.min)}stepFor(e){const n=this.zoomRanges.find(o=>e>=o.min&&e<o.max);return n?n.step:this.zoomStep}toZoom(e){return parseFloat(et(e,this.minZoom,this.maxZoom).toFixed(2))}registerMarqueeOnPage(e){if(!this.interactionManager)return this.logger.warn("ZoomPlugin","MissingDependency","Interaction manager plugin not loaded, marquee zoom disabled"),()=>{};const n=this.coreState.core.documents[e.documentId];if(!n||!n.document)return this.logger.warn("ZoomPlugin","DocumentNotFound","Document not found"),()=>{};const o=n.document.pages[e.pageIndex];if(!o)return this.logger.warn("ZoomPlugin","PageNotFound",`Page ${e.pageIndex} not found`),()=>{};const r=yE({pageSize:o.size,scale:e.scale,onPreview:e.callback.onPreview,onCommit:i=>{var s,l;this.zoomToArea(e.pageIndex,i,e.documentId),(l=(s=e.callback).onCommit)==null||l.call(s,i)},onSmallDrag:()=>{var i,s;this.zoomIn(e.documentId),(s=(i=e.callback).onSmallDrag)==null||s.call(i)}});return this.interactionManager.registerHandlers({documentId:e.documentId,modeId:"marqueeZoom",handlers:r,pageIndex:e.pageIndex})}onStoreUpdated(e,n){for(const o in n.documents){const r=e.documents[o],a=n.documents[o];r&&a&&(r.currentZoomLevel!==a.currentZoomLevel||r.zoomLevel!==a.zoomLevel||r.isMarqueeZoomActive!==a.isMarqueeZoomActive)&&this.state$.emit({documentId:o,state:a})}}async initialize(){this.logger.info("ZoomPlugin","Initialize","Zoom plugin initialized")}async destroy(){this.zoom$.clear(),this.state$.clear(),super.destroy()}};Ng.id="zoom";let jg=Ng;const _E={manifest:hE,create:(t,e)=>new jg(Og,t,e),reducer:bE,initialState:$g},io="TaskQueue",so="Queue";var me=(t=>(t[t.CRITICAL=3]="CRITICAL",t[t.HIGH=2]="HIGH",t[t.MEDIUM=1]="MEDIUM",t[t.LOW=0]="LOW",t))(me||{});class vE{constructor(e={}){this.queue=[],this.running=0,this.resultTasks=new Map,this.idleListeners=new Set;const{concurrency:n=1,comparator:o,ranker:r,onIdle:a,maxQueueSize:i,autoStart:s=!0,logger:l}=e;this.logger=l??new zo,this.opts={concurrency:Math.max(1,n),comparator:o,ranker:r,onIdle:a??(()=>{}),maxQueueSize:i??Number.POSITIVE_INFINITY,autoStart:s}}setComparator(e){this.opts.comparator=e}setRanker(e){this.opts.ranker=e}size(){return this.queue.length}inFlight(){return this.running}isIdle(){return this.queue.length===0&&this.running===0}async drain(){this.isIdle()||await new Promise(e=>{const n=()=>{this.isIdle()&&(this.offIdle(n),e())};this.onIdle(n)})}notifyIdle(){this.isIdle()&&([...this.idleListeners].forEach(e=>e()),this.idleListeners.clear(),this.opts.onIdle())}onIdle(e){this.idleListeners.add(e)}offIdle(e){this.idleListeners.delete(e)}enqueue(e,n={}){const o=this.generateId(),r=n.priority??1,a=new Ie;if(this.queue.length>=this.opts.maxQueueSize){const l=new Error("Queue is full (maxQueueSize reached).");return a.reject(l),a}this.resultTasks.set(o,a);const i={id:o,priority:r,meta:n.meta??e.meta,executeFactory:e.execute};this.queue.push(i),this.logger.debug(io,so,`Task enqueued: ${o} | Priority: ${r} | Running: ${this.running} | Queued: ${this.queue.length}`);const s=a.abort.bind(a);return a.abort=l=>{this.logger.debug(io,so,`Task aborted: ${o}`),this.cancel(o),s(l)},this.opts.autoStart&&this.process(n.fifo===!0),a}cancel(e){const n=this.queue.length;this.queue=this.queue.filter(o=>o.id===e?(o.cancelled=!0,!1):!0),this.resultTasks.delete(e),n!==this.queue.length&&(this.logger.debug(io,so,`Task cancelled and removed: ${e}`),this.kick())}kick(){queueMicrotask(()=>this.process())}async process(e=!1){for(this.logger.debug(io,so,`process() called | Running: ${this.running} | Concurrency: ${this.opts.concurrency} | Queued: ${this.queue.length}`);this.running<this.opts.concurrency&&this.queue.length>0;){this.logger.debug(io,so,`Starting new task | Running: ${this.running} | Queued: ${this.queue.length}`),e||this.sortQueue();const n=this.queue.shift();if(n.cancelled){this.logger.debug(io,so,`Skipping cancelled task: ${n.id}`);continue}const o=this.resultTasks.get(n.id);o&&(this.running++,(async()=>{let r=null;try{if(r=n.executeFactory(),!r)throw new Error("Task factory returned null/undefined");r.wait(a=>{o.state.stage===0&&o.resolve(a)},a=>{o.state.stage===0&&(a.type==="abort"?o.abort(a.reason):o.reject(a.reason))}),r.onProgress(a=>{o.progress(a)}),await r.toPromise()}catch(a){o.state.stage===0&&o.reject(a)}finally{this.resultTasks.delete(n.id),this.running--,this.logger.debug(io,so,`Task completed: ${n.id} | Running: ${this.running} | Queued: ${this.queue.length}`),this.isIdle()?this.notifyIdle():this.queue.length>0&&this.kick()}})().catch(r=>{this.logger.error(io,so,"Unhandled error in task execution wrapper:",r),this.running=Math.max(0,this.running-1),this.isIdle()?this.notifyIdle():this.queue.length>0&&this.kick()}))}}sortQueue(){const{comparator:e,ranker:n}=this.opts;if(e){this.queue.sort(e);return}const o=new Map,r=a=>n?(o.has(a.id)||o.set(a.id,n(a)),o.get(a.id)):this.defaultRank(a);this.queue.sort((a,i)=>{if(a.priority!==i.priority)return i.priority-a.priority;const s=r(a),l=r(i);return s!==l?l-s:this.extractTime(a.id)-this.extractTime(i.id)})}defaultRank(e){return 0}generateId(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}extractTime(e){const n=Number(e.split("-")[0]);return Number.isFinite(n)?n:0}}const Js="PdfEngine",el="Orchestrator";class DE{constructor(e,n){this.executor=e,this.logger=n.logger??new zo,this.options={imageConverter:n.imageConverter,fetcher:n.fetcher??(typeof fetch<"u"?(o,r)=>fetch(o,r):void 0),logger:this.logger},this.workerQueue=new vE({concurrency:1,autoStart:!0,logger:this.logger}),this.logger.debug(Js,el,"PdfEngine orchestrator created")}chunkArray(e,n){const o=[];for(let r=0;r<e.length;r+=n)o.push(e.slice(r,r+n));return o}isSupport(e){const n=new Ie;return n.resolve([xr.Create,xr.Read,xr.Update,xr.Delete]),n}destroy(){var e,n;const o=new Ie;try{this.executor.destroy(),(n=(e=this.options.imageConverter).destroy)==null||n.call(e),o.resolve(!0)}catch(r){o.reject({code:ve.Unknown,message:String(r)})}return o}openDocumentUrl(e,n){const o=new Ie;return(async()=>{try{if(!this.options.fetcher)throw new Error("Fetcher is not set");const a=await(await this.options.fetcher(e.url,n==null?void 0:n.requestOptions)).arrayBuffer(),i={id:e.id,content:a};this.openDocumentBuffer(i,{password:n==null?void 0:n.password,normalizeRotation:n==null?void 0:n.normalizeRotation}).wait(s=>o.resolve(s),s=>o.fail(s))}catch(r){o.reject({code:ve.Unknown,message:String(r)})}})(),o}openDocumentBuffer(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.openDocumentBuffer(e,n),meta:{docId:e.id,operation:"openDocumentBuffer"}},{priority:me.CRITICAL})}getMetadata(e){return this.workerQueue.enqueue({execute:()=>this.executor.getMetadata(e),meta:{docId:e.id,operation:"getMetadata"}},{priority:me.MEDIUM})}setMetadata(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.setMetadata(e,n),meta:{docId:e.id,operation:"setMetadata"}},{priority:me.MEDIUM})}getDocPermissions(e){return this.workerQueue.enqueue({execute:()=>this.executor.getDocPermissions(e),meta:{docId:e.id,operation:"getDocPermissions"}},{priority:me.MEDIUM})}getDocUserPermissions(e){return this.workerQueue.enqueue({execute:()=>this.executor.getDocUserPermissions(e),meta:{docId:e.id,operation:"getDocUserPermissions"}},{priority:me.MEDIUM})}getSignatures(e){return this.workerQueue.enqueue({execute:()=>this.executor.getSignatures(e),meta:{docId:e.id,operation:"getSignatures"}},{priority:me.MEDIUM})}getBookmarks(e){return this.workerQueue.enqueue({execute:()=>this.executor.getBookmarks(e),meta:{docId:e.id,operation:"getBookmarks"}},{priority:me.MEDIUM})}setBookmarks(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.setBookmarks(e,n),meta:{docId:e.id,operation:"setBookmarks"}},{priority:me.MEDIUM})}deleteBookmarks(e){return this.workerQueue.enqueue({execute:()=>this.executor.deleteBookmarks(e),meta:{docId:e.id,operation:"deleteBookmarks"}},{priority:me.MEDIUM})}renderPage(e,n,o){return this.renderWithEncoding(()=>this.executor.renderPageRaw(e,n,o),o,e.id,n.index,me.CRITICAL)}renderPageRect(e,n,o,r){return this.renderWithEncoding(()=>this.executor.renderPageRect(e,n,o,r),r,e.id,n.index,me.HIGH)}renderPageRaw(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.renderPageRaw(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageRaw"}},{priority:me.HIGH})}renderPageRectRaw(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.renderPageRect(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageRectRaw"}},{priority:me.HIGH})}renderThumbnail(e,n,o){return this.renderWithEncoding(()=>this.executor.renderThumbnailRaw(e,n,o),o,e.id,n.index,me.MEDIUM)}renderPageAnnotation(e,n,o,r){return this.renderWithEncoding(()=>this.executor.renderPageAnnotationRaw(e,n,o,r),r,e.id,n.index,me.MEDIUM)}renderPageAnnotations(e,n,o){const r=new Ie,a=this.workerQueue.enqueue({execute:()=>this.executor.renderPageAnnotationsRaw(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageAnnotationsRaw"}},{priority:me.MEDIUM}),i=r.abort.bind(r);return r.abort=s=>{a.abort(s),i(s)},a.wait(s=>{r.state.stage===0&&this.encodeAppearanceMap(s,o,r)},s=>{r.state.stage===0&&r.fail(s)}),r}renderPageAnnotationsRaw(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.renderPageAnnotationsRaw(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"renderPageAnnotationsRaw"}},{priority:me.MEDIUM})}renderWithEncoding(e,n,o,r,a=me.CRITICAL){const i=new Ie,s=this.workerQueue.enqueue({execute:()=>e(),meta:{docId:o,pageIndex:r,operation:"render"}},{priority:a}),l=i.abort.bind(i);return i.abort=c=>{s.abort(c),l(c)},s.wait(c=>{i.state.stage===0&&this.encodeImage(c,n,i)},c=>{i.state.stage===0&&i.fail(c)}),i}encodeImage(e,n,o){const r=(n==null?void 0:n.imageType)??"image/webp",a=n==null?void 0:n.quality,i={data:new Uint8ClampedArray(e.data),width:e.width,height:e.height};this.options.imageConverter(()=>i,r,a).then(s=>o.resolve(s)).catch(s=>o.reject({code:ve.Unknown,message:String(s)}))}encodeAppearanceMap(e,n,o){const r=(n==null?void 0:n.imageType)??"image/webp",a=n==null?void 0:n.imageQuality,i=u=>{const d={data:new Uint8ClampedArray(u.data),width:u.width,height:u.height};return this.options.imageConverter(()=>d,r,a)},s=[],l={},c=["normal","rollover","down"];for(const[u,d]of Object.entries(e)){const p={};l[u]=p;for(const h of c){const g=d[h];g&&s.push(i(g.data).then(f=>{p[h]={data:f,rect:g.rect}}))}}Promise.all(s).then(()=>{o.state.stage===0&&o.resolve(l)}).catch(u=>{o.state.stage===0&&o.reject({code:ve.Unknown,message:String(u)})})}getPageAnnotations(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageAnnotations(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageAnnotations"}},{priority:me.MEDIUM})}createPageAnnotation(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.createPageAnnotation(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"createPageAnnotation"}},{priority:me.MEDIUM})}updatePageAnnotation(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.updatePageAnnotation(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"updatePageAnnotation"}},{priority:me.MEDIUM})}removePageAnnotation(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.removePageAnnotation(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"removePageAnnotation"}},{priority:me.MEDIUM})}getAllAnnotations(e){const n=this.chunkArray(e.pages,500);this.logger.debug(Js,el,`getAllAnnotations: ${e.pages.length} pages in ${n.length} chunks`);const o=new vo({aggregate:r=>Object.assign({},...r)});return n.forEach((r,a)=>{const i=this.workerQueue.enqueue({execute:()=>this.executor.getAnnotationsBatch(e,r),meta:{docId:e.id,operation:"getAnnotationsBatch",chunkSize:r.length}},{priority:me.LOW});i.onProgress(s=>{o.progress({page:s.pageIndex,result:s.result})}),o.addChild(i,a)}),o.finalize(),o}getPageTextRects(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageTextRects(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageTextRects"}},{priority:me.MEDIUM})}searchAllPages(e,n,o){const r=Array.isArray(o==null?void 0:o.flags)?o.flags.reduce((s,l)=>s|l,0):(o==null?void 0:o.flags)??0,a=this.chunkArray(e.pages,25);this.logger.debug(Js,el,`searchAllPages: ${e.pages.length} pages in ${a.length} chunks`);const i=new vo({aggregate:s=>{const l=s.flatMap(c=>Object.values(c).flat());return{results:l,total:l.length}}});return a.forEach((s,l)=>{const c=this.workerQueue.enqueue({execute:()=>this.executor.searchBatch(e,s,n,r),meta:{docId:e.id,operation:"searchBatch",chunkSize:s.length}},{priority:me.LOW});c.onProgress(u=>{i.progress({page:u.pageIndex,results:u.result})}),i.addChild(c,l)}),i.finalize(),i}getAttachments(e){return this.workerQueue.enqueue({execute:()=>this.executor.getAttachments(e),meta:{docId:e.id,operation:"getAttachments"}},{priority:me.MEDIUM})}addAttachment(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.addAttachment(e,n),meta:{docId:e.id,operation:"addAttachment"}},{priority:me.MEDIUM})}removeAttachment(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.removeAttachment(e,n),meta:{docId:e.id,operation:"removeAttachment"}},{priority:me.MEDIUM})}readAttachmentContent(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.readAttachmentContent(e,n),meta:{docId:e.id,operation:"readAttachmentContent"}},{priority:me.MEDIUM})}getDocumentJavaScriptActions(e){return this.workerQueue.enqueue({execute:()=>this.executor.getDocumentJavaScriptActions(e),meta:{docId:e.id,operation:"getDocumentJavaScriptActions"}},{priority:me.MEDIUM})}getPageAnnoWidgets(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageAnnoWidgets(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageAnnoWidgets"}},{priority:me.MEDIUM})}getPageWidgetJavaScriptActions(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageWidgetJavaScriptActions(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageWidgetJavaScriptActions"}},{priority:me.MEDIUM})}setFormFieldValue(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.setFormFieldValue(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"setFormFieldValue"}},{priority:me.MEDIUM})}setFormFieldState(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.setFormFieldState(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"setFormFieldState"}},{priority:me.MEDIUM})}renameWidgetField(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.renameWidgetField(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"renameWidgetField"}},{priority:me.MEDIUM})}shareWidgetField(e,n,o,r,a){return this.workerQueue.enqueue({execute:()=>this.executor.shareWidgetField(e,n,o,r,a),meta:{docId:e.id,pageIndex:n.index,operation:"shareWidgetField"}},{priority:me.MEDIUM})}regenerateWidgetAppearances(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.regenerateWidgetAppearances(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"regenerateWidgetAppearances"}},{priority:me.MEDIUM})}flattenPage(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.flattenPage(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"flattenPage"}},{priority:me.MEDIUM})}extractPages(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.extractPages(e,n),meta:{docId:e.id,pageIndexes:n,operation:"extractPages"}},{priority:me.MEDIUM})}extractText(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.extractText(e,n),meta:{docId:e.id,pageIndexes:n,operation:"extractText"}},{priority:me.MEDIUM})}redactTextInRects(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.redactTextInRects(e,n,o,r),meta:{docId:e.id,pageIndex:n.index,operation:"redactTextInRects"}},{priority:me.MEDIUM})}applyRedaction(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.applyRedaction(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"applyRedaction"}},{priority:me.MEDIUM})}applyAllRedactions(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.applyAllRedactions(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"applyAllRedactions"}},{priority:me.MEDIUM})}flattenAnnotation(e,n,o){return this.workerQueue.enqueue({execute:()=>this.executor.flattenAnnotation(e,n,o),meta:{docId:e.id,pageIndex:n.index,operation:"flattenAnnotation"}},{priority:me.MEDIUM})}getTextSlices(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getTextSlices(e,n),meta:{docId:e.id,slices:n,operation:"getTextSlices"}},{priority:me.MEDIUM})}getPageGlyphs(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageGlyphs(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageGlyphs"}},{priority:me.MEDIUM})}getPageGeometry(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageGeometry(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageGeometry"}},{priority:me.MEDIUM})}getPageTextRuns(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.getPageTextRuns(e,n),meta:{docId:e.id,pageIndex:n.index,operation:"getPageTextRuns"}},{priority:me.MEDIUM})}merge(e){return this.workerQueue.enqueue({execute:()=>this.executor.merge(e),meta:{docId:e.map(n=>n.id).join(","),operation:"merge"}},{priority:me.MEDIUM})}mergePages(e){return this.workerQueue.enqueue({execute:()=>this.executor.mergePages(e),meta:{docId:e.map(n=>n.docId).join(","),operation:"mergePages"}},{priority:me.MEDIUM})}preparePrintDocument(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.preparePrintDocument(e,n),meta:{docId:e.id,operation:"preparePrintDocument"}},{priority:me.MEDIUM})}saveAsCopy(e){return this.workerQueue.enqueue({execute:()=>this.executor.saveAsCopy(e),meta:{docId:e.id,operation:"saveAsCopy"}},{priority:me.MEDIUM})}closeDocument(e){return this.workerQueue.enqueue({execute:()=>this.executor.closeDocument(e),meta:{docId:e.id,operation:"closeDocument"}},{priority:me.MEDIUM})}closeAllDocuments(){return this.workerQueue.enqueue({execute:()=>this.executor.closeAllDocuments(),meta:{operation:"closeAllDocuments"}},{priority:me.MEDIUM})}setDocumentEncryption(e,n,o,r){return this.workerQueue.enqueue({execute:()=>this.executor.setDocumentEncryption(e,n,o,r),meta:{docId:e.id,operation:"setDocumentEncryption"}},{priority:me.MEDIUM})}removeEncryption(e){return this.workerQueue.enqueue({execute:()=>this.executor.removeEncryption(e),meta:{docId:e.id,operation:"removeEncryption"}},{priority:me.MEDIUM})}unlockOwnerPermissions(e,n){return this.workerQueue.enqueue({execute:()=>this.executor.unlockOwnerPermissions(e,n),meta:{docId:e.id,operation:"unlockOwnerPermissions"}},{priority:me.MEDIUM})}isEncrypted(e){return this.workerQueue.enqueue({execute:()=>this.executor.isEncrypted(e),meta:{docId:e.id,operation:"isEncrypted"}},{priority:me.MEDIUM})}isOwnerUnlocked(e){return this.workerQueue.enqueue({execute:()=>this.executor.isOwnerUnlocked(e),meta:{docId:e.id,operation:"isOwnerUnlocked"}},{priority:me.MEDIUM})}}class Ug extends Error{constructor(e){super(e),this.name="ImageConverterError"}}const SE=(t,e="image/webp",n)=>{if(typeof document>"u")return Promise.reject(new Ug("document is not available. This converter requires a browser environment."));const o=t(),r=new ImageData(o.data,o.width,o.height);return new Promise((a,i)=>{const s=document.createElement("canvas");s.width=r.width,s.height=r.height,s.getContext("2d").putImageData(r,0,0),s.toBlob(l=>{l?a(l):i(new Ug("Canvas toBlob returned null"))},e,n)})};function EE(t){const e=async(n,o="image/webp",r)=>{try{const a=n(),i=new Uint8ClampedArray(a.data);return await t.encode({data:i,width:a.width,height:a.height},o,r)}catch(a){return console.warn("Worker encoding failed, falling back to main-thread Canvas:",a),SE(n,o,r)}};return e.destroy=()=>t.destroy(),e}const AE=[{file:"NotoSansJP-Thin.otf",weight:100},{file:"NotoSansJP-Light.otf",weight:300},{file:"NotoSansJP-DemiLight.otf",weight:350},{file:"NotoSansJP-Regular.otf",weight:400},{file:"NotoSansJP-Medium.otf",weight:500},{file:"NotoSansJP-Bold.otf",weight:700},{file:"NotoSansJP-Black.otf",weight:900}],xE=[{file:"NotoSansKR-Thin.otf",weight:100},{file:"NotoSansKR-Light.otf",weight:300},{file:"NotoSansKR-DemiLight.otf",weight:350},{file:"NotoSansKR-Regular.otf",weight:400},{file:"NotoSansKR-Medium.otf",weight:500},{file:"NotoSansKR-Bold.otf",weight:700},{file:"NotoSansKR-Black.otf",weight:900}],CE=[{file:"NotoSansHans-Light.otf",weight:300},{file:"NotoSansHans-DemiLight.otf",weight:350},{file:"NotoSansHans-Regular.otf",weight:400},{file:"NotoSansHans-Medium.otf",weight:500},{file:"NotoSansHans-Bold.otf",weight:700}],TE=[{file:"NotoSansHant-Thin.otf",weight:100},{file:"NotoSansHant-Light.otf",weight:300},{file:"NotoSansHant-DemiLight.otf",weight:350},{file:"NotoSansHant-Regular.otf",weight:400},{file:"NotoSansHant-Medium.otf",weight:500},{file:"NotoSansHant-Bold.otf",weight:700},{file:"NotoSansHant-Black.otf",weight:900}],ME=[{file:"NotoNaskhArabic-Regular.ttf",weight:400},{file:"NotoNaskhArabic-Bold.ttf",weight:700}],RE=[{file:"NotoSansHebrew-Regular.ttf",weight:400},{file:"NotoSansHebrew-Bold.ttf",weight:700}],tl=[{file:"NotoSans-Thin.ttf",weight:100},{file:"NotoSans-ThinItalic.ttf",weight:100,italic:!0},{file:"NotoSans-ExtraLight.ttf",weight:200},{file:"NotoSans-ExtraLightItalic.ttf",weight:200,italic:!0},{file:"NotoSans-Light.ttf",weight:300},{file:"NotoSans-LightItalic.ttf",weight:300,italic:!0},{file:"NotoSans-Regular.ttf",weight:400},{file:"NotoSans-Italic.ttf",weight:400,italic:!0},{file:"NotoSans-Medium.ttf",weight:500},{file:"NotoSans-MediumItalic.ttf",weight:500,italic:!0},{file:"NotoSans-SemiBold.ttf",weight:600},{file:"NotoSans-SemiBoldItalic.ttf",weight:600,italic:!0},{file:"NotoSans-Bold.ttf",weight:700},{file:"NotoSans-BoldItalic.ttf",weight:700,italic:!0},{file:"NotoSans-ExtraBold.ttf",weight:800},{file:"NotoSans-ExtraBoldItalic.ttf",weight:800,italic:!0},{file:"NotoSans-Black.ttf",weight:900},{file:"NotoSans-BlackItalic.ttf",weight:900,italic:!0}],En="RemoteExecutor",An="Worker",Bg=class pi{constructor(e,n){this.worker=e,this.pendingRequests=new Map,this.requestCounter=0,this.handleMessage=o=>{const r=o.data;if(r.type==="ready"){this.logger.debug(En,An,"Worker is ready"),this.readyTask.resolve(!0);return}const a=this.pendingRequests.get(r.id);if(!a){this.logger.warn(En,An,`Received response for unknown request: ${r.id}`);return}switch(r.type){case"result":this.logger.debug(En,An,`Received result for ${r.id}`),a.resolve(r.data),this.pendingRequests.delete(r.id);break;case"error":this.logger.debug(En,An,`Received error for ${r.id}:`,r.error),r.error?a.fail(r.error):a.reject({code:ve.Unknown,message:"Unknown error"}),this.pendingRequests.delete(r.id);break;case"progress":this.logger.debug(En,An,`Received progress for ${r.id}`),a.progress(r.progress);break}},this.logger=n.logger??new zo,this.worker.addEventListener("message",this.handleMessage),this.readyTask=new Ie,this.pendingRequests.set(pi.READY_TASK_ID,this.readyTask),this.worker.postMessage({id:pi.READY_TASK_ID,type:"wasmInit",wasmUrl:n.wasmUrl,logger:n.logger?rs(n.logger):void 0,fontFallback:n.fontFallback}),this.logger.debug(En,An,"RemoteExecutor created")}generateId(){return`req-${Date.now()}-${this.requestCounter++}`}send(e,n){const o=this.generateId(),r=new Ie,a={id:o,type:"execute",method:e,args:n};return this.readyTask.wait(()=>{this.pendingRequests.set(o,r),this.logger.debug(En,An,`Sending ${e} request:`,o),this.worker.postMessage(a)},i=>{this.logger.error(En,An,`Worker init failed, rejecting ${e}:`,i),r.reject({code:ve.Initialization,message:"Worker initialization failed"})}),r}destroy(){this.worker.removeEventListener("message",this.handleMessage),this.pendingRequests.forEach((e,n)=>{n!==pi.READY_TASK_ID&&(e.abort("Worker destroyed"),this.logger.debug(En,An,`Aborted pending request: ${n}`))}),this.pendingRequests.clear(),this.worker.terminate(),this.logger.debug(En,An,"RemoteExecutor destroyed")}openDocumentBuffer(e,n){return this.send("openDocumentBuffer",[e,n])}getMetadata(e){return this.send("getMetadata",[e])}setMetadata(e,n){return this.send("setMetadata",[e,n])}getDocPermissions(e){return this.send("getDocPermissions",[e])}getDocUserPermissions(e){return this.send("getDocUserPermissions",[e])}getSignatures(e){return this.send("getSignatures",[e])}getBookmarks(e){return this.send("getBookmarks",[e])}setBookmarks(e,n){return this.send("setBookmarks",[e,n])}deleteBookmarks(e){return this.send("deleteBookmarks",[e])}renderPageRaw(e,n,o){return this.send("renderPageRaw",[e,n,o])}renderPageRect(e,n,o,r){return this.send("renderPageRect",[e,n,o,r])}renderThumbnailRaw(e,n,o){return this.send("renderThumbnailRaw",[e,n,o])}renderPageAnnotationRaw(e,n,o,r){return this.send("renderPageAnnotationRaw",[e,n,o,r])}renderPageAnnotationsRaw(e,n,o){return this.send("renderPageAnnotationsRaw",[e,n,o])}getPageAnnotationsRaw(e,n){return this.send("getPageAnnotationsRaw",[e,n])}getPageAnnotations(e,n){return this.send("getPageAnnotations",[e,n])}createPageAnnotation(e,n,o,r){return this.send("createPageAnnotation",[e,n,o,r])}updatePageAnnotation(e,n,o,r){return this.send("updatePageAnnotation",[e,n,o,r])}removePageAnnotation(e,n,o){return this.send("removePageAnnotation",[e,n,o])}getPageTextRects(e,n){return this.send("getPageTextRects",[e,n])}searchInPage(e,n,o,r){return this.send("searchInPage",[e,n,o,r])}getAnnotationsBatch(e,n){return this.send("getAnnotationsBatch",[e,n])}searchBatch(e,n,o,r){return this.send("searchBatch",[e,n,o,r])}getAttachments(e){return this.send("getAttachments",[e])}addAttachment(e,n){return this.send("addAttachment",[e,n])}removeAttachment(e,n){return this.send("removeAttachment",[e,n])}readAttachmentContent(e,n){return this.send("readAttachmentContent",[e,n])}getDocumentJavaScriptActions(e){return this.send("getDocumentJavaScriptActions",[e])}getPageAnnoWidgets(e,n){return this.send("getPageAnnoWidgets",[e,n])}getPageWidgetJavaScriptActions(e,n){return this.send("getPageWidgetJavaScriptActions",[e,n])}setFormFieldValue(e,n,o,r){return this.send("setFormFieldValue",[e,n,o,r])}setFormFieldState(e,n,o,r){return this.send("setFormFieldState",[e,n,o,r])}renameWidgetField(e,n,o,r){return this.send("renameWidgetField",[e,n,o,r])}shareWidgetField(e,n,o,r,a){return this.send("shareWidgetField",[e,n,o,r,a])}regenerateWidgetAppearances(e,n,o){return this.send("regenerateWidgetAppearances",[e,n,o])}flattenPage(e,n,o){return this.send("flattenPage",[e,n,o])}extractPages(e,n){return this.send("extractPages",[e,n])}extractText(e,n){return this.send("extractText",[e,n])}redactTextInRects(e,n,o,r){return this.send("redactTextInRects",[e,n,o,r])}applyRedaction(e,n,o){return this.send("applyRedaction",[e,n,o])}applyAllRedactions(e,n){return this.send("applyAllRedactions",[e,n])}flattenAnnotation(e,n,o){return this.send("flattenAnnotation",[e,n,o])}getTextSlices(e,n){return this.send("getTextSlices",[e,n])}getPageGlyphs(e,n){return this.send("getPageGlyphs",[e,n])}getPageGeometry(e,n){return this.send("getPageGeometry",[e,n])}getPageTextRuns(e,n){return this.send("getPageTextRuns",[e,n])}merge(e){return this.send("merge",[e])}mergePages(e){return this.send("mergePages",[e])}preparePrintDocument(e,n){return this.send("preparePrintDocument",[e,n])}saveAsCopy(e){return this.send("saveAsCopy",[e])}closeDocument(e){return this.send("closeDocument",[e])}closeAllDocuments(){return this.send("closeAllDocuments",[])}setDocumentEncryption(e,n,o,r){return this.send("setDocumentEncryption",[e,n,o,r])}removeEncryption(e){return this.send("removeEncryption",[e])}unlockOwnerPermissions(e,n){return this.send("unlockOwnerPermissions",[e,n])}isEncrypted(e){return this.send("isEncrypted",[e])}isOwnerUnlocked(e){return this.send("isOwnerUnlocked",[e])}};Bg.READY_TASK_ID="0";let wE=Bg;const zn="ImageEncoderPool",Wn="Encoder";class OE{constructor(e=2,n,o){this.poolSize=e,this.workerUrl=n,this.workers=[],this.pendingTasks=new Map,this.nextWorkerId=0,this.requestCounter=0,this.logger=o??new zo,this.initialize()}initialize(){this.logger.debug(zn,Wn,`Creating worker pool with ${this.poolSize} workers`);for(let e=0;e<this.poolSize;e++)try{const n=new Worker(this.workerUrl,{type:"module"});n.onmessage=this.handleWorkerMessage.bind(this),n.onerror=this.handleWorkerError.bind(this),this.workers.push(n),this.logger.debug(zn,Wn,`Worker ${e} created successfully`)}catch(n){this.logger.error(zn,Wn,`Failed to create worker ${e}:`,n)}}handleWorkerMessage(e){const n=e.data,o=this.pendingTasks.get(n.id);if(!o){this.logger.warn(zn,Wn,`Received response for unknown task: ${n.id}`);return}if(this.pendingTasks.delete(n.id),n.type==="result")o.resolve(n.data);else{const r=n.data;o.reject(new Error(r.message))}}handleWorkerError(e){this.logger.error(zn,Wn,"Worker error:",e.message)}getNextWorker(){if(this.workers.length===0)return null;const e=this.workers[this.nextWorkerId];return this.nextWorkerId=(this.nextWorkerId+1)%this.workers.length,e}encode(e,n="image/webp",o){return new Promise((r,a)=>{const i=this.getNextWorker();if(!i){a(new Error("No workers available in the pool"));return}const s=`encode-${Date.now()}-${this.requestCounter++}`;this.pendingTasks.set(s,{resolve:r,reject:a});const l={id:s,type:"encode",data:{imageData:{data:e.data,width:e.width,height:e.height},imageType:n,quality:o}};this.logger.debug(zn,Wn,`Sending encoding request ${s} (${e.width}x${e.height})`),i.postMessage(l,[e.data.buffer])})}destroy(){this.logger.debug(zn,Wn,"Destroying worker pool"),this.pendingTasks.forEach((e,n)=>{e.reject(new Error("Worker pool destroyed")),this.logger.debug(zn,Wn,`Rejected pending task: ${n}`)}),this.pendingTasks.clear(),this.workers.forEach((e,n)=>{e.terminate(),this.logger.debug(zn,Wn,`Worker ${n} terminated`)}),this.workers=[]}get activeWorkers(){return this.workers.length}get pendingTasksCount(){return this.pendingTasks.size}}function kE(t,e){const n=e instanceof Object&&"debug"in e?{logger:e}:e||{},{logger:o,encoderPoolSize:r,fontFallback:a}=n,i=new Worker(URL.createObjectURL(new Blob([`var Rotation = /* @__PURE__ */ ((Rotation2) => {
26
26
  Rotation2[Rotation2["Degree0"] = 0] = "Degree0";
27
27
  Rotation2[Rotation2["Degree90"] = 1] = "Degree90";
28
28
  Rotation2[Rotation2["Degree180"] = 2] = "Degree180";
@@ -18821,7 +18821,7 @@ self.onmessage = async (event) => {
18821
18821
  }
18822
18822
  }
18823
18823
  };
18824
- `],{type:"application/javascript"})),{type:"module"}),s=new TE(i,{wasmUrl:t,logger:o,fontFallback:a}),l=URL.createObjectURL(new Blob([`async function encodeImage(imageData, imageType, quality) {
18824
+ `],{type:"application/javascript"})),{type:"module"}),s=new wE(i,{wasmUrl:t,logger:o,fontFallback:a}),l=URL.createObjectURL(new Blob([`async function encodeImage(imageData, imageType, quality) {
18825
18825
  if (typeof OffscreenCanvas === "undefined") {
18826
18826
  throw new Error("OffscreenCanvas is not available in this worker environment");
18827
18827
  }
@@ -18860,4 +18860,10 @@ self.onmessage = async (event) => {
18860
18860
  self.postMessage(response);
18861
18861
  }
18862
18862
  };
18863
- `],{type:"application/javascript"})),c=new ME(r??2,l,o);return new _E(s,{imageConverter:vE(c),logger:o})}function wE(t="latest"){return{jp:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-jp@${t}/fonts`,kr:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-kr@${t}/fonts`,sc:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-sc@${t}/fonts`,tc:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-tc@${t}/fonts`,arabic:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-arabic@${t}/fonts`,hebrew:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-hebrew@${t}/fonts`,latin:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-latin@${t}/fonts`}}function Hn(t,e){return t.map(n=>({url:`${e}/${n.file}`,weight:n.weight,italic:n.italic}))}function OE(t){return{fonts:{[vn.SHIFTJIS]:Hn(DE,t.jp),[vn.HANGEUL]:Hn(SE,t.kr),[vn.GB2312]:Hn(EE,t.sc),[vn.CHINESEBIG5]:Hn(AE,t.tc),[vn.ARABIC]:Hn(xE,t.arabic),[vn.HEBREW]:Hn(CE,t.hebrew),[vn.CYRILLIC]:Hn(el,t.latin),[vn.GREEK]:Hn(el,t.latin),[vn.VIETNAMESE]:Hn(el,t.latin)}}}const kE=wE("latest"),IE=OE(kE),GE="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.10.1/dist/pdfium.wasm",Bg=()=>It(Ng.id);function zg(t){const[e,n]=[t[0],t[1]],o=n.clientX-e.clientX,r=n.clientY-e.clientY;return Math.hypot(o,r)}function LE(t){const[e,n]=[t[0],t[1]];return{x:(e.clientX+n.clientX)/2,y:(e.clientY+n.clientY)/2}}function $E({element:t,container:e,documentId:n,zoomProvides:o,viewportGap:r=0,options:a={}}){const{enablePinch:i=!0,enableWheel:s=!0}=a;if(typeof window>"u")return()=>{};const l=o.forDocument(n),c=()=>l.getState();let u=0,d=1,p=!1,h=0,g=null,f=1,F=0,_=0,y=0,E=0,A=0,T=0,q=0,w=0,G=0,W=0,J=0,ue=0,ce=0;const ee=(L,de,Pe)=>Math.min(Math.max(L,de),Pe),ge=()=>{const L=e.clientWidth-2*r,de=t.offsetWidth,Pe=de<L?(L-de)/2:0;t.style.marginLeft=`${Pe}px`},_e=L=>{const de=F*L,Pe=_*L;let Re=G*(1-L);const Ut=w-de/2-y,D=W-ce*L-y,S=Math.max(0,de-q),R=q*.3,N=Math.min(1,S/R);let $=Ut+(D-Ut)*N;const j=T-ue*2;if(Pe>j){const K=E+Re,Y=ue,B=T-ue-Pe;Re=ee(K,B,Y)-E}const ne=A-ue*2;if(de>ne){const K=y+$,Y=ue,B=A-ue-de;$=ee(K,B,Y)-y}return{tx:$,ty:Re,blend:N,finalWidth:de}},Ee=L=>{d=L;const{tx:de,ty:Pe}=_e(L);t.style.transformOrigin="0 0",t.style.transform=`translate(${de}px, ${Pe}px) scale(${L})`},Te=()=>{t.style.transform="none",t.style.transformOrigin="0 0",d=1},oe=()=>{const{tx:L,finalWidth:de}=_e(d),Pe=(d-1)*u;let Re,vt=J;if(de<=q)Re=w;else{const Ut=1-d;Re=Math.abs(Ut)>.001?y+L/Ut:W}l.requestZoomBy(Pe,{vx:Re,vy:vt}),Te(),u=0},He=(L,de)=>{const Pe=e.getBoundingClientRect(),Re=t.getBoundingClientRect();ue=r,F=Re.width,_=Re.height,y=Re.left-Pe.left,E=Re.top-Pe.top,A=Pe.width,T=Pe.height,q=e.clientWidth,w=e.clientLeft+q/2;const vt=L-Re.left;G=de-Re.top,W=L-Pe.left,J=de-Pe.top,F<q?ce=W*F/q:ce=vt},ft=L=>{if(L.touches.length!==2)return;p=!0,u=c().currentZoomLevel,h=zg(L.touches);const de=LE(L.touches);He(de.x,de.y),L.preventDefault()},Ve=L=>{if(!p||L.touches.length!==2)return;const Pe=zg(L.touches)/h;Ee(Pe),L.preventDefault()},O=L=>{p&&(L.touches.length>=2||(p=!1,oe()))},H=L=>{if(!L.ctrlKey&&!L.metaKey)return;L.preventDefault(),g===null?(u=c().currentZoomLevel,f=1,He(L.clientX,L.clientY)):clearTimeout(g);const de=1-L.deltaY*.01;f*=de,f=Math.max(.1,Math.min(10,f)),Ee(f),g=setTimeout(()=>{g=null,oe(),f=1},150)},V=l.onStateChange(()=>ge()),se=new ResizeObserver(()=>ge());return se.observe(t),se.observe(e),ge(),i&&(e.addEventListener("touchstart",ft,{passive:!1}),e.addEventListener("touchmove",Ve,{passive:!1}),e.addEventListener("touchend",O),e.addEventListener("touchcancel",O)),s&&e.addEventListener("wheel",H,{passive:!1}),()=>{i&&(e.removeEventListener("touchstart",ft),e.removeEventListener("touchmove",Ve),e.removeEventListener("touchend",O),e.removeEventListener("touchcancel",O)),s&&e.removeEventListener("wheel",H),g&&clearTimeout(g),V(),se.disconnect(),Te(),t.style.marginLeft=""}}function NE(t,e={}){const{provides:n}=It("viewport"),{provides:o}=Bg(),r=Po("viewport-element"),a=Q(null);let i;return Se([a,n,o,()=>$t(t),()=>$t(e.enablePinch??!0),()=>$t(e.enableWheel??!0)],([s,l,c,u,d,p])=>{i&&(i(),i=void 0);const h=r==null?void 0:r.value;!s||!h||!c||(i=$E({element:s,container:h,documentId:u,zoomProvides:c,viewportGap:(l==null?void 0:l.getViewportGap())||0,options:{enablePinch:d,enableWheel:p}}))},{immediate:!0}),{elementRef:a}}const jE=ie({__name:"zoom-gesture-wrapper",props:{documentId:{},enablePinch:{type:Boolean,default:!0},enableWheel:{type:Boolean,default:!0}},setup(t){const e=t,{elementRef:n}=NE(()=>e.documentId,{enablePinch:Nl(()=>e.enablePinch),enableWheel:Nl(()=>e.enableWheel)});return(o,r)=>(v(),C("div",xe({ref_key:"elementRef",ref:n,style:{display:"inline-block",overflow:"visible",boxSizing:"border-box"}},o.$attrs),[$e(o.$slots,"default")],16))}}),Wg=()=>Nn(Xs.id),UE=()=>It(Xs.id),BE=ie({__name:"thumbnails-pane",props:{documentId:{}},setup(t){const e=t,{plugin:n}=Wg(),o=Q(null),r=Q({window:null,docId:null}),a=Q(null);Se(r,s=>{a.value=s.docId===e.documentId?s.window:null},{deep:!0}),Se([()=>n.value,()=>e.documentId],([s,l],c,u)=>{if(!s){r.value={window:null,docId:null};return}const d=s.provides().forDocument(l),p=d.getWindow();p&&(r.value={window:p,docId:l});const h=d.onWindow(g=>{r.value={window:g,docId:l}});u(()=>{h(),r.value={window:null,docId:null}})},{immediate:!0}),Se([o,()=>n.value,()=>e.documentId],([s,l,c],u,d)=>{if(!s||!l)return;const p=l.provides().forDocument(c),h=()=>p.updateWindow(s.scrollTop,s.clientHeight);s.addEventListener("scroll",h);const g=new ResizeObserver(()=>{p.updateWindow(s.scrollTop,s.clientHeight)});g.observe(s),p.updateWindow(s.scrollTop,s.clientHeight),d(()=>{s.removeEventListener("scroll",h),g.disconnect()})},{immediate:!0}),Se([o,()=>n.value,()=>e.documentId,a],([s,l,c])=>{if(!s||!l)return;l.provides().forDocument(c).updateWindow(s.scrollTop,s.clientHeight)}),Se([o,()=>n.value,()=>e.documentId,()=>!!a.value],([s,l,c,u],d,p)=>{if(!s||!l||!u)return;const g=l.provides().forDocument(c).onScrollTo(({top:f,behavior:F})=>{ca(()=>{s.scrollTo({top:f,behavior:F})})});p(g)},{immediate:!0});const i=Q(0);return Se(()=>n.value,s=>{i.value=(s==null?void 0:s.cfg.paddingY)??0},{immediate:!0}),(s,l)=>{var c,u;return v(),C("div",xe({ref_key:"viewportRef",ref:o,style:{overflowY:"auto",position:"relative",paddingTop:`${i.value}px`,paddingBottom:`${i.value}px`,height:"100%"}},s.$attrs),[m("div",{style:Z({height:`${((c=a.value)==null?void 0:c.totalHeight)??0}px`,position:"relative"})},[(v(!0),C(pe,null,tt(((u=a.value)==null?void 0:u.items)??[],d=>$e(s.$slots,"default",{key:d.pageIndex,meta:d})),128))],4)],16)}}}),zE=["src"],WE=ie({__name:"thumbnail-img",props:{documentId:{},meta:{}},setup(t){const e=t,{provides:n}=UE(),{plugin:o}=Wg(),r=Q(null);let a=null;const i=Q(0);Se([()=>o.value,()=>e.documentId,()=>e.meta.pageIndex],([c,u,d],p,h)=>{if(!c)return;const f=c.provides().forDocument(u).onRefreshPages(F=>{F.includes(d)&&i.value++});h(f)},{immediate:!0});function s(){a&&(URL.revokeObjectURL(a),a=null)}let l=null;return Se([()=>n.value,()=>e.documentId,()=>e.meta.pageIndex,i],([c,u,d],p,h)=>{if(l&&(l(),l=null),!c){r.value=null;return}const f=c.forDocument(u).renderThumb(d,window.devicePixelRatio);l=()=>f.abort({code:ve.Cancelled,message:"canceled render task"}),f.wait(F=>{s();const _=URL.createObjectURL(F);a=_,r.value=_,l=null},Yt),h(()=>{l&&(l(),l=null),s()})},{immediate:!0}),(c,u)=>r.value?(v(),C("img",xe({key:0,src:r.value},c.$attrs,{onLoad:s}),null,16,zE)):ae("",!0)}}),Hg=()=>It(Zh.id),HE=ie({__name:"search-layer",props:{documentId:{},pageIndex:{},scale:{},highlightColor:{default:"#FFFF00"},activeHighlightColor:{default:"#FFBF00"}},setup(t){const e=t,{provides:n}=Hg(),o=Dn(()=>e.documentId),r=Q(null),a=P(()=>{var c;return((c=n.value)==null?void 0:c.forDocument(e.documentId))??null}),i=P(()=>{var c;return e.scale!==void 0?e.scale:((c=o.value)==null?void 0:c.scale)??1});Se(a,(c,u,d)=>{if(!c){r.value=null;return}const p=c.getState();r.value={results:p.results,activeResultIndex:p.activeResultIndex,showAllResults:p.showAllResults,active:p.active};const h=c.onSearchResultStateChange(g=>{r.value=g});d(h)},{immediate:!0});const s=P(()=>r.value?r.value.results.map((c,u)=>({result:c,originalIndex:u})).filter(({result:c})=>c.pageIndex===e.pageIndex):[]),l=P(()=>r.value?s.value.filter(({originalIndex:c})=>r.value.showAllResults||c===r.value.activeResultIndex):[]);return(c,u)=>r.value&&r.value.active?(v(),C("div",xe({key:0,style:{pointerEvents:"none"}},c.$attrs),[(v(!0),C(pe,null,tt(l.value,({result:d,originalIndex:p},h)=>(v(),C(pe,{key:`result-${h}`},[(v(!0),C(pe,null,tt(d.rects,(g,f)=>(v(),C("div",{key:`rect-${h}-${f}`,style:Z({position:"absolute",top:`${g.origin.y*i.value}px`,left:`${g.origin.x*i.value}px`,width:`${g.size.width*i.value}px`,height:`${g.size.height*i.value}px`,backgroundColor:p===r.value.activeResultIndex?t.activeHighlightColor:t.highlightColor,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1})},null,4))),128))],64))),128))],16)):ae("",!0)}}),VE=()=>Nn(qs.id),YE=()=>It(qs.id),qE=ie({__name:"scroller",props:{documentId:{}},setup(t){const e=t,{plugin:n}=VE(),o=Q({layout:null,docId:null});Se([n,()=>e.documentId],([a,i],s,l)=>{if(!a||!i){o.value={layout:null,docId:null};return}const c=a.onScrollerData(i,u=>{o.value={layout:u,docId:i}});l(()=>{c(),o.value={layout:null,docId:null},a.clearLayoutReady(i)})},{immediate:!0});const r=P(()=>o.value.docId===e.documentId?o.value.layout:null);return Se([n,()=>e.documentId,r],([a,i,s])=>{!a||!i||!s||a.setLayoutReady(i)},{immediate:!0}),(a,i)=>r.value?(v(),C("div",xe({key:0,style:{width:`${r.value.totalWidth}px`,height:`${r.value.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...r.value.strategy===I(ro).Horizontal&&{display:"flex",flexDirection:"row"}}},a.$attrs),[m("div",{style:Z(r.value.strategy===I(ro).Horizontal?{width:`${r.value.startSpacing}px`,height:"100%",flexShrink:0}:{height:`${r.value.startSpacing}px`,width:"100%"})},null,4),m("div",{style:Z({gap:`${r.value.pageGap}px`,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",...r.value.strategy===I(ro).Horizontal?{flexDirection:"row",minHeight:"100%"}:{flexDirection:"column",minWidth:"fit-content"}})},[(v(!0),C(pe,null,tt(r.value.items,s=>(v(),C("div",{key:s.pageNumbers[0],style:Z({display:"flex",justifyContent:"center",gap:`${r.value.pageGap}px`})},[(v(!0),C(pe,null,tt(s.pageLayouts,l=>(v(),C("div",{key:l.pageNumber,style:Z({width:`${l.rotatedWidth}px`,height:`${l.rotatedHeight}px`,position:"relative",zIndex:l.elevated?1:void 0})},[$e(a.$slots,"default",{page:l})],4))),128))],4))),128))],4),m("div",{style:Z(r.value.strategy===I(ro).Horizontal?{width:`${r.value.endSpacing}px`,height:"100%",flexShrink:0}:{height:`${r.value.endSpacing}px`,width:"100%"})},null,4)],16)):ae("",!0)}}),KE=()=>It(eh.id),XE=()=>Nn(Zs.id),Vg=()=>It(Zs.id),ZE=t=>{const{provides:e}=Vg(),n=Q(!1);return Se([e,()=>$t(t)],([o,r],a,i)=>{if(!o){n.value=!1;return}n.value=o.isGated(r);const s=o.onGateChange(l=>{l.documentId===r&&(n.value=l.isGated)});i(s)},{immediate:!0}),n};function QE(t){const{plugin:e}=XE(),n=Q(null);let o=null;const r=a=>{const i=e.value,s=n.value;if(!s||!i)return;try{i.registerViewport(a)}catch(d){console.error(`Failed to register viewport for document ${a}:`,d);return}const l=()=>{i.setViewportScrollMetrics(a,{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft})};s.addEventListener("scroll",l),new ResizeObserver(()=>{i.setViewportResizeMetrics(a,{width:s.offsetWidth,height:s.offsetHeight,clientWidth:s.clientWidth,clientHeight:s.clientHeight,scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,scrollWidth:s.scrollWidth,scrollHeight:s.scrollHeight,clientLeft:s.clientLeft,clientTop:s.clientTop})}).observe(s);const u=i.onScrollRequest(a,({x:d,y:p,behavior:h="auto"})=>{requestAnimationFrame(()=>{s.scrollTo({left:d,top:p,behavior:h})})});return()=>{i.unregisterViewport(a),s.removeEventListener("scroll",l),u()}};return Se([e,n,()=>$t(t)],([,,a])=>{o&&(o(),o=null),o=r(a)||null},{immediate:!0}),mr(()=>{o&&(o(),o=null)}),n}const JE=ie({__name:"viewport",props:{documentId:{}},setup(t){const e=t,n=km(),{provides:o}=Vg(),r=Q(0);Se(o,s=>{s&&(r.value=s.getViewportGap())},{immediate:!0});const a=ZE(()=>e.documentId),i=QE(()=>e.documentId);return da("viewport-element",i),(s,l)=>(v(),C("div",xe({ref_key:"viewportRef",ref:i},I(n),{style:{padding:`${r.value}px`,width:"100%",height:"100%",overflow:"auto"}}),[I(a)?ae("",!0):$e(s.$slots,"default",{key:0})],16))}}),Yg=()=>It(mg.id),eA=["src"],tA=ie({__name:"tile-img",props:{documentId:{},pageIndex:{},tile:{},scale:{},dpr:{default:()=>typeof window<"u"?window.devicePixelRatio:1}},setup(t){const e=t,{provides:n}=Yg(),o=Q(),r=P(()=>e.scale/e.tile.srcScale);let a,i=null;return Se([()=>e.tile.id,()=>e.documentId,n],([s,l,c],[u,d])=>{if(!c)return;const p=c.forDocument(l);d!==void 0&&d!==l&&(o.value&&(URL.revokeObjectURL(o.value),o.value=void 0),i&&(i.abort({code:ve.Cancelled,message:"switching documents"}),i=null),a=void 0),!(a===s&&d===l)&&(i&&(i.abort({code:ve.Cancelled,message:"switching tiles"}),i=null),o.value&&(URL.revokeObjectURL(o.value),o.value=void 0),a=s,i=p.renderTile({pageIndex:e.pageIndex,tile:ke(e.tile),dpr:e.dpr}),i.wait(h=>{o.value=URL.createObjectURL(h),i=null},Yt))},{immediate:!0}),mr(()=>{i&&i.abort({code:ve.Cancelled,message:"unmounting"}),o.value&&URL.revokeObjectURL(o.value)}),(s,l)=>o.value?(v(),C("img",{key:0,src:o.value,style:Z({position:"absolute",left:`${t.tile.screenRect.origin.x*r.value}px`,top:`${t.tile.screenRect.origin.y*r.value}px`,width:`${t.tile.screenRect.size.width*r.value}px`,height:`${t.tile.screenRect.size.height*r.value}px`,display:"block"})},null,12,eA)):ae("",!0)}}),nA=ie({__name:"tiling-layer",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{provides:n}=Yg(),o=Dn(()=>e.documentId),r=Q([]),a=P(()=>{var i;return e.scale!==void 0?e.scale:((i=o.value)==null?void 0:i.scale)??1});return Se([n,()=>e.documentId,()=>e.pageIndex],([i,s,l],c,u)=>{if(!i){r.value=[];return}const d=i.onTileRendering(p=>{p.documentId===s&&(r.value=p.tiles[l]??[])});u(d)},{immediate:!0}),(i,s)=>(v(),C("div",zt(Qt(i.$attrs)),[(v(!0),C(pe,null,tt(r.value,l=>(v(),he(tA,{key:l.id,documentId:t.documentId,pageIndex:t.pageIndex,tile:l,scale:a.value},null,8,["documentId","pageIndex","tile","scale"]))),128))],16))}}),oA=()=>It(Ch.id),rA=["src"],aA=ie({__name:"render-layer",props:{documentId:{},pageIndex:{},scale:{},dpr:{}},setup(t){const e=t,{provides:n}=oA(),o=Dn(()=>e.documentId),r=Q(null);let a=null,i=!1;const s=P(()=>o.value&&o.value.pageRefreshVersions[e.pageIndex]||0),l=P(()=>{var d;return e.scale!==void 0?e.scale:((d=o.value)==null?void 0:d.scale)??1}),c=P(()=>e.dpr!==void 0?e.dpr:window.devicePixelRatio);Se([()=>e.documentId,()=>e.pageIndex,l,c,n,s],([d,p,h,g,f],[F],_)=>{if(!f){r.value=null;return}F!==void 0&&F!==d&&(r.value=null,a&&i&&(URL.revokeObjectURL(a),a=null,i=!1)),a&&i&&F===d&&(URL.revokeObjectURL(a),a=null,i=!1);const y=f.forDocument(d).renderPage({pageIndex:p,options:{scaleFactor:h,dpr:g}});y.wait(E=>{const A=URL.createObjectURL(E);a=A,r.value=A,i=!1},Yt),_(()=>{a?i&&(URL.revokeObjectURL(a),a=null,i=!1):y.abort({code:ve.Cancelled,message:"canceled render task"})})},{immediate:!0});function u(){i=!0}return(d,p)=>r.value?(v(),C("img",xe({key:0,src:r.value,style:{width:"100%",height:"100%"},onLoad:u},d.$attrs),null,16,rA)):ae("",!0)}}),iA={annotation:!0,ink:!0,freeText:!0,redaction:!0,export:!0,thumbnail:!0,search:!0};function qg(t){const e=Q("正在初始化 PDF 编辑器"),n=Q(!1),o=Q(!1),r=P(()=>{var i,s,l,c,u;return{...iA,...t.capabilities??{},annotation:t.readonly?!1:((i=t.capabilities)==null?void 0:i.annotation)??!0,ink:t.readonly?!1:((s=t.capabilities)==null?void 0:s.ink)??!0,freeText:t.readonly?!1:((l=t.capabilities)==null?void 0:l.freeText)??!0,redaction:t.readonly?!1:((c=t.capabilities)==null?void 0:c.redaction)??!0,export:((u=t.capabilities)==null?void 0:u.export)??!0}}),a=P(()=>t.source.type!=="url"&&r.value.export);return{capabilities:r,canSaveToService:a,statusMessage:e,leftDrawerOpen:n,rightDrawerOpen:o}}function tl(t,e){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="bigint")return t.toString();if(!(typeof t>"u"||typeof t=="function"||typeof t=="symbol")){if(t instanceof Date)return t.toISOString();if(t instanceof Blob||t instanceof ArrayBuffer||ArrayBuffer.isView(t))return t;if(Array.isArray(t))return t.map(n=>tl(n,e)).filter(n=>n!==void 0);if(typeof t=="object"){const n=t;if(e.has(n))return e.get(n);const o={};e.set(n,o);for(const[r,a]of Object.entries(n)){const i=tl(a,e);i!==void 0&&(o[r]=i)}return o}}}function Kg(t){return t.map(e=>tl(e,new WeakMap)).filter(e=>!!e)}const sA={class:"jit-pdf-editor"},lA={class:"jit-ribbon"},cA={class:"jit-ribbon__topbar"},uA={class:"jit-ribbon__document"},dA={class:"jit-toolbar__title"},pA={class:"jit-ribbon__meta"},hA={class:"jit-ribbon__badge"},gA={class:"jit-ribbon__page"},fA={class:"jit-ribbon__actions"},mA=["disabled"],PA=["disabled"],FA=["data-tooltip"],bA=["data-tooltip"],_A=["data-tooltip"],yA={class:"jit-ribbon__tabs",role:"tablist","aria-label":"编辑器功能区"},vA=["data-tooltip","aria-selected","onClick"],DA={class:"jit-ribbon__panels"},SA={key:0,class:"jit-ribbon__bar"},EA={class:"jit-ribbon__section jit-ribbon__section--view"},AA={class:"jit-ribbon__section-body"},xA={class:"jit-zoom-chip"},CA={class:"jit-ribbon__section jit-ribbon__section--history"},TA={class:"jit-ribbon__section-body"},MA=["disabled"],RA=["disabled"],wA={class:"jit-ribbon__section jit-ribbon__section--save"},OA={class:"jit-ribbon__section-body jit-ribbon__section-body--save"},kA=["disabled"],IA=["disabled"],GA={key:1,class:"jit-ribbon__bar jit-ribbon__bar--annotate"},LA={class:"jit-ribbon__section jit-ribbon__section--tools"},$A={class:"jit-ribbon__section-body jit-ribbon__section-body--tools"},NA=["aria-label","disabled","onClick"],jA={key:0,viewBox:"0 0 24 24","aria-hidden":"true"},UA={key:1,viewBox:"0 0 24 24","aria-hidden":"true"},BA={key:2,viewBox:"0 0 24 24","aria-hidden":"true"},zA={key:3,viewBox:"0 0 24 24","aria-hidden":"true"},WA={key:4,viewBox:"0 0 24 24","aria-hidden":"true"},HA={key:5,viewBox:"0 0 24 24","aria-hidden":"true"},VA={class:"jit-ribbon__section jit-ribbon__section--style"},YA={class:"jit-style-panel"},qA={class:"jit-style-row"},KA={class:"jit-color-palette"},XA=["title","disabled","onClick"],ZA={key:0,class:"jit-style-row"},QA={class:"jit-style-control"},JA={key:1,class:"jit-style-row"},ex={class:"jit-style-control"},tx={key:2,class:"jit-style-row"},nx={class:"jit-style-control"},ox={class:"jit-ribbon__section jit-ribbon__section--hint"},rx={class:"jit-ribbon__hint"},ax={class:"jit-ribbon__metric"},ix={class:"jit-ribbon__hint-chip"},sx=["disabled"],lx={key:2,class:"jit-ribbon__bar jit-ribbon__bar--view"},cx={class:"jit-ribbon__section jit-ribbon__section--view"},ux={class:"jit-ribbon__section-body"},dx={class:"jit-zoom-chip"},px={class:"jit-ribbon__section jit-ribbon__section--layout"},hx={class:"jit-ribbon__section-body"},gx=["aria-label"],fx=["aria-label"],mx={class:"jit-ribbon__section jit-ribbon__section--summary"},Px={class:"jit-ribbon__summary"},Fx={class:"jit-ribbon__metric"},bx={class:"jit-ribbon__metric"},_x={key:3,class:"jit-ribbon__bar jit-ribbon__bar--review"},yx={class:"jit-ribbon__section jit-ribbon__section--search-wide"},vx={class:"jit-ribbon__section-body jit-ribbon__section-body--search"},Dx={class:"jit-search-box"},Sx=["onKeydown"],Ex=["disabled"],Ax=["disabled"],xx=["disabled"],Cx={class:"jit-ribbon__section jit-ribbon__section--save"},Tx={class:"jit-ribbon__section-body jit-ribbon__section-body--save"},Mx=["disabled"],Rx=["disabled"],wx={class:"jit-ribbon__section jit-ribbon__section--summary"},Ox={class:"jit-ribbon__summary"},kx={class:"jit-ribbon__metric"},Ix={class:"jit-ribbon__metric"},Gx={class:"jit-sidebar__header"},Lx={key:0,class:"jit-sidebar__headline"},$x=["aria-label"],Nx={key:0,viewBox:"0 0 24 24","aria-hidden":"true"},jx={key:1,viewBox:"0 0 24 24","aria-hidden":"true"},Ux=["onClick"],Bx={class:"jit-thumbnail__paper"},zx={class:"jit-thumbnail__meta"},Wx={class:"jit-thumbnail__label"},Hx={key:0,class:"jit-thumbnail__current"},Vx={key:1,class:"jit-sidebar__empty"},Yx={class:"jit-canvas"},qx={class:"jit-right-rail"},Kx=["aria-label"],Xx=["aria-label"],Zx={class:"jit-inspector__header"},Qx={class:"jit-inspector__body"},Jx={key:0,class:"jit-note-editor"},eC={class:"jit-note-editor__header"},tC={class:"jit-note-editor__title-row"},nC=["disabled"],oC={class:"jit-note-editor__field"},rC={class:"jit-note-editor__footer"},aC={class:"jit-meta"},iC={class:"jit-panel-note"},sC={key:0},lC={key:1},cC={key:2},uC={class:"jit-annotation-panel__header"},dC={class:"jit-annotation-panel__header-actions"},pC=["disabled"],hC=["disabled"],gC={class:"jit-annotation-panel__body"},fC={class:"jit-annotation-toolbar"},mC={class:"jit-annotation-toolbar__search"},PC={class:"jit-annotation-toolbar__filter"},FC=["value"],bC={key:0,class:"jit-annotation-list"},_C={class:"jit-annotation-group__header"},yC=["aria-label","onClick"],vC={key:0},DC=["onClick"],SC={class:"jit-annotation-item__meta"},EC={class:"jit-annotation-item__chips"},AC={key:0,class:"jit-annotation-chip"},xC={key:1,class:"jit-annotation-chip"},CC={key:2,class:"jit-annotation-chip is-active"},TC={key:3,class:"jit-annotation-chip is-warning"},MC=["aria-label","onClick"],RC={key:1,class:"jit-annotation-panel__empty"},wC={key:0,class:"jit-state"},OC={key:1,class:"jit-state jit-state--error"},kC={key:3,class:"jit-state"},IC=ie({__name:"JitPdfEditorInner",props:{source:{},locale:{},theme:{},capabilities:{},service:{},readonly:{type:Boolean},activeDocumentId:{},pluginsReady:{type:Boolean},isInitializing:{type:Boolean}},emits:["ready","dirty-change","save-start","save-success","save-error","load-error"],setup(t,{emit:e}){const n=t,o=e,{capabilities:r,canSaveToService:a,leftDrawerOpen:i,rightDrawerOpen:s,statusMessage:l}=qg(n),c=Q(""),u=Q(""),d=Q("浏览"),p=Q(!1),h=Q("home"),g=P(()=>n.source.type==="url"?`url:${n.source.url}`:`${n.source.type}:${n.source.fileId}`),f=P(()=>n.source.type==="url"?null:n.source.fileId),{provides:F}=Hp(),{provides:_}=Bn(),{provides:y}=KE(),E=ms(()=>n.activeDocumentId??"");function A(x){const{provides:b}=Bg(),z=Q(ri);return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=ri;return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=ri;return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function T(x){const{provides:b}=Hg(),z=Q(jr);return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=jr;return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=jr;return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function q(x){const{provides:b}=Bn(),z=Q(Xa());return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=Xa();return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=Xa();return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function w(x){const{provides:b}=vh(),z=Q(oi);return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=oi;return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=oi;return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function G(x){const{provides:b}=YE(),z=Q({currentPage:1,totalPages:1});return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value={currentPage:1,totalPages:1};return}const ze=le.forDocument(U);z.value={currentPage:ze.getCurrentPage(),totalPages:ze.getTotalPages()};const Vn=le.onPageChange(un=>{un.documentId===U&&(z.value={currentPage:un.pageNumber,totalPages:un.totalPages})});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function W(x){const{provides:b}=qp();return{provides:P(()=>{const z=x.value;return z&&b.value?b.value.forDocument(z):null})}}const J=P(()=>n.activeDocumentId??null),{provides:ue,state:ce}=A(J),{provides:ee,state:ge}=T(J),{provides:_e,state:Ee}=q(J),{provides:Te,state:oe}=w(J),{provides:He}=W(J),{provides:ft,state:Ve}=G(J),O=P(()=>Ee.value.hasPendingChanges||oe.value.pendingCount>0),H=P(()=>ce.value.currentZoomLevel||1),V=P(()=>Ve.value.currentPage||1),se=P(()=>Ve.value.totalPages||0),L=P(()=>{var x;return((x=y.value)==null?void 0:x.canUndo())??!1}),de=P(()=>{var x;return((x=y.value)==null?void 0:x.canRedo())??!1}),Pe=P(()=>ge.value.total||0),Re=P(()=>`${Math.round(H.value*100)}%`),vt=P(()=>!n.readonly&&E.value.canModifyAnnotations),Ut=P(()=>n.readonly?"只读":vt.value?"可批注":"受限"),D=P(()=>{var x;return[...((x=_.value)==null?void 0:x.getColorPresets())??[],"#1677FF","#0958D9","#18A058","#D03050","#FA8C16"].filter((b,z,le)=>le.indexOf(b)===z)}),S=Q(null),R=Q("#1677FF"),N=Q(.7),$=Q(6),j=Q(14),ne=Q(""),K=Q("idle");let Y=null;const B=P(()=>["highlight","textComment","freeText","ink"].includes(S.value??"")),be=P(()=>["highlight","textComment","freeText","ink"].includes(S.value??"")),re=P(()=>S.value==="ink"),Fe=P(()=>S.value==="freeText"),De=P(()=>Ee.value.selectedUids??[]),we=P(()=>De.value.length),Ge=P(()=>De.value[0]??null),Oe=P(()=>Ge.value?Ee.value.byUid[Ge.value]??null:null),k=P(()=>Ge.value?qe(Ge.value):null),ye=P(()=>{var x,b;return Oe.value?((b=(x=_e.value)==null?void 0:x.findToolForAnnotation(Oe.value.object))==null?void 0:b.id)??null:null}),Le=P(()=>ye.value==="textComment"),Ke=P(()=>{if(!Le.value||!Oe.value)return"";const{contents:x}=Oe.value.object;return typeof x=="string"?x:""}),Xe=P(()=>!Le.value||!Oe.value?null:{id:Ge.value,pageIndex:k.value,pageLabel:k.value===null?"-":String(k.value+1)}),Kt=P(()=>ne.value.length),dt=P(()=>{if(!Le.value)return"未选中便签";switch(K.value){case"editing":return"编辑中";case"saving":return"正在保存";case"saved":return"已保存";case"error":return"保存失败";default:return"可编辑"}}),Ze=P(()=>Gb(Ee.value)),Dt=P(()=>Ze.value.length),Ft=Q(""),gt=Q("all"),Gt=Q(!1),Ye=Q([]),nn=Q(!1);function xn(x){return Kg(x)}const Ur=P(()=>xn(Object.values(Ee.value.byUid).filter(x=>x.commitState!=="deleted").map(x=>x.object))),lo={browse:"浏览",highlight:"高亮",textComment:"便签",freeText:"自由文本",ink:"涂鸦",redact:"脱敏"},ii=[{id:"home",label:"开始",description:"页面浏览、缩放和保存"},{id:"annotate",label:"批注",description:"高亮、便签、文本框、涂鸦、脱敏"},{id:"view",label:"视图",description:"页面定位、目录和阅读布局"},{id:"review",label:"审阅",description:"搜索、结果导航和脱敏提交"}],ol=P(()=>[{id:"browse",label:"浏览",icon:"pointer",active:d.value==="浏览",disabled:!1,danger:!1,onClick:()=>Cn(null,"浏览")},{id:"highlight",label:"高亮",icon:"highlight",active:d.value==="高亮",disabled:!r.value.annotation,danger:!1,onClick:()=>Cn("highlight","高亮")},{id:"note",label:"便签",icon:"note",active:d.value==="便签",disabled:!r.value.annotation,danger:!1,onClick:()=>Cn("textComment","便签")},{id:"freeText",label:"文本框",icon:"text",active:d.value==="自由文本",disabled:!r.value.freeText,danger:!1,onClick:()=>Cn("freeText","自由文本")},{id:"ink",label:"涂鸦",icon:"draw",active:d.value==="涂鸦",disabled:!r.value.ink,danger:!1,onClick:()=>Cn("ink","涂鸦")},{id:"redact",label:"脱敏",icon:"redact",active:d.value==="脱敏",disabled:!r.value.redaction,danger:!0,onClick:()=>X()}]);let si="",co=!1,uo=0,Jo="",xo=null;function rl(x){return/^(https?:\/\/|\/)/.test(x)}Se(O,x=>{o("dirty-change",{dirty:x})}),Se([g,()=>n.pluginsReady,F],async([x,b,z])=>{if(!b||!z||x===si)return;const le=++uo;co=!1,Jo="",d.value="浏览",S.value=null,l.value="正在分段加载文档",u.value="";try{const U=n.source.type==="url"?n.source.url:n.service.getFileStreamUrl(n.source.fileId),Ae=n.source.name??(n.source.type==="url"?"外部文档.pdf":(await n.service.getFileMeta(n.source.fileId)).name);if(le!==uo||(await z.closeAllDocuments().toPromise().catch(()=>[]),le!==uo))return;const ze=await z.openDocumentUrl({url:U,name:Ae,autoActivate:!0,...rl(U)?{mode:"range-request"}:{}}).toPromise();if(le!==uo){await z.closeAllDocuments().toPromise().catch(()=>[]);return}si=x,co=!0,l.value="文档已就绪",o("ready",{documentId:ze.documentId})}catch(U){if(le!==uo)return;l.value="文档加载失败",o("load-error",{message:U instanceof Error?U.message:"文档加载失败",cause:U})}},{immediate:!0}),Se([f,()=>n.activeDocumentId,_e,()=>n.pluginsReady],async([x,b,z,le])=>{if(!x||!b||!z||!le||!co)return;const U=`${x}:${b}`;if(Jo!==U){Jo=U,nn.value=!0;try{const Ae=await n.service.loadAnnotations(x),lt=Object.keys(Ee.value.byUid).length>0;Ae.length&&!lt&&z.importAnnotations(Ae.map(ze=>({annotation:ze})))}catch(Ae){u.value=Ae instanceof Error?`批注恢复失败:${Ae.message}`:"批注恢复失败"}finally{window.setTimeout(()=>{nn.value=!1},0)}}},{immediate:!0}),Se([f,Ur,()=>n.activeDocumentId],([x,b,z])=>{!x||!z||nn.value||!co||(xo!==null&&window.clearTimeout(xo),xo=window.setTimeout(async()=>{try{await n.service.saveAnnotations(x,b)}catch(le){u.value=le instanceof Error?`批注同步失败:${le.message}`:"批注同步失败"}},320))},{deep:!0});function Cn(x,b){var z,le;if((z=Te.value)==null||z.endRedact(),x&&!vt.value){S.value=null,d.value="浏览",u.value="当前文档未授予批注权限,已保持浏览模式。",l.value="当前文档禁止批注";return}(le=_e.value)==null||le.setActiveTool(x),queueMicrotask(()=>{var Ae,lt;const U=((lt=(Ae=_e.value)==null?void 0:Ae.getActiveTool())==null?void 0:lt.id)??Ee.value.activeToolId??null;if(x&&U!==x){S.value=U,d.value=lo[U??"browse"]??b,u.value="批注工具尚未真正激活,已保持当前浏览状态。",l.value="批注工具未成功激活";return}if(S.value=U,d.value=lo[U??"browse"]??b,u.value="",U){st(U),l.value=`已切换到${lo[U]??b}`;return}l.value="浏览模式"})}Se(()=>Ee.value.activeToolId,x=>{S.value==="redact"&&!x||(S.value=x,d.value=lo[x??"browse"]??"浏览",x&&st(x))}),Se([Le,Ke,Ge],([x,b])=>{if(Y!==null&&(window.clearTimeout(Y),Y=null),!x){ne.value="",K.value="idle";return}ne.value=b,K.value="idle",s.value=!0},{immediate:!0}),Se(()=>S.value,x=>{x==="textComment"&&(s.value=!0,u.value="点击页面插入便签,随后可在右侧填写说明内容。",l.value="便签模式")});function X(){var x,b;(x=Te.value)==null||x.enableRedact(),(b=_e.value)==null||b.setActiveTool(null),S.value="redact",d.value="脱敏",u.value="",l.value="脱敏模式"}function Ne(){p.value=!p.value}function Xt(){s.value=!s.value}function Pt(x){var b;(b=ft.value)==null||b.scrollToPage({pageNumber:x+1,behavior:"smooth",alignY:0}),l.value=`已定位到第 ${x+1} 页`}function st(x){var z,le;const b=(le=(z=_.value)==null?void 0:z.getTool(x))==null?void 0:le.defaults;b&&(R.value=String(b.strokeColor??b.fontColor??b.color??R.value),N.value=Number(b.opacity??N.value),$.value=Number(b.strokeWidth??$.value),j.value=Number(b.fontSize??j.value))}function qe(x){const b=Object.entries(Ee.value.pages).find(([,z])=>z.includes(x));return b?Number(b[0]):null}function on(){var z;if(!((z=Xe.value)!=null&&z.id)||Xe.value.pageIndex===null||!_e.value)return;const x=ne.value.replace(/\u00A0/g," "),b=Ke.value.replace(/\u00A0/g," ");if(x===b){K.value=K.value==="error"?"error":"saved";return}K.value="saving";try{_e.value.updateAnnotation(Xe.value.pageIndex,Xe.value.id,{contents:x}),K.value="saved",l.value="便签内容已更新",u.value="便签内容已自动保存。"}catch(le){K.value="error",u.value=le instanceof Error?`便签保存失败:${le.message}`:"便签保存失败"}}function Rt(){Y!==null&&window.clearTimeout(Y),Y=window.setTimeout(()=>{Y=null,on()},320)}function er(){Le.value&&(K.value="editing",Rt())}function li(){Le.value&&(Y!==null&&(window.clearTimeout(Y),Y=null),on())}function Zt(x){const b=Object.entries(Ee.value.byUid).find(([z,le])=>z===x.object.id||le===x||le.object===x.object);return(b==null?void 0:b[0])??x.object.id}function Co(x){const b=new Map;for(const z of x){const le=[z.annotation,...z.groupMembers??[],...z.replies];for(const U of le){const Ae=Zt(U),lt=qe(Ae)??z.page;lt!==null&&b.set(Ae,{id:Ae,pageIndex:lt})}}return[...b.values()]}function Br(x){var z;const b=Zt(x.annotation);Pt(x.page),(z=_e.value)==null||z.selectAnnotation(x.page,b),u.value=`已定位到第 ${x.page+1} 页的${sl(x)}。`}function al(){if(!_e.value||!we.value){u.value="当前没有选中的批注。";return}const x=De.value.map(b=>{const z=qe(b);return z===null?null:{id:b,pageIndex:z}}).filter(b=>b!==null);if(!x.length){u.value="当前选中的批注暂时无法删除。";return}_e.value.deleteAnnotations(x),u.value=`已删除 ${x.length} 个选中批注。`,l.value=`已删除 ${x.length} 个批注`}function qC(x){if(!_e.value)return;const b=Co([x]);if(!b.length){u.value="当前批注暂时无法删除。";return}_e.value.deleteAnnotations(b),u.value=`已删除第 ${x.page+1} 页的${sl(x)}。`,l.value="批注已删除"}function il(){Gt.value=!Gt.value}function KC(x){Ye.value=Ye.value.includes(x)?Ye.value.filter(b=>b!==x):[...Ye.value,x]}function XC(){if(lf.value){const x=new Set(zr.value);Ye.value=Ye.value.filter(b=>!x.has(b));return}Ye.value=[...new Set([...Ye.value,...zr.value])]}function ZC(){if(!_e.value||!ui.value){u.value="请先在批注管理面板中勾选要删除的批注。";return}const x=Ye.value.map(b=>{const z=qe(b);return z===null?null:{id:b,pageIndex:z}}).filter(b=>b!==null);if(!x.length){u.value="当前筛选结果里没有可删除的批注。";return}_e.value.deleteAnnotations(x),Ye.value=[],u.value=`已批量删除 ${x.length} 个批注。`,l.value=`已删除 ${x.length} 个批注`}function sl(x){var z,le;const b=(le=(z=_e.value)==null?void 0:z.findToolForAnnotation(x.annotation.object))==null?void 0:le.id;return lo[b??""]??"批注"}function QC(x){const b=x.annotation.object.contents,z=typeof b=="string"?b.trim():"";if(z)return z;const le=x.replies.map(U=>U.object.contents).find(U=>typeof U=="string"&&U.trim().length>0);return le?le.trim():`${sl(x)} · 第 ${x.page+1} 页`}const ci=P(()=>Ze.value.map(x=>{var Ae,lt,ze;const b=Zt(x.annotation),z=((lt=(Ae=_e.value)==null?void 0:Ae.findToolForAnnotation(x.annotation.object))==null?void 0:lt.id)??"annotation",le=lo[z]??"批注",U=QC(x);return{id:b,page:x.page,kindId:z,kindLabel:le,summary:U,repliesCount:x.replies.length,groupCount:(((ze=x.groupMembers)==null?void 0:ze.length)??0)+1,isCanvasSelected:De.value.includes(b),entry:x,searchText:`${le} ${U} 第 ${x.page+1} 页`.toLowerCase()}})),rf=P(()=>{const x=new Map;for(const b of ci.value){const z=x.get(b.kindId);if(z){z.count+=1;continue}x.set(b.kindId,{id:b.kindId,label:b.kindLabel,count:1})}return[{id:"all",label:"全部类型",count:ci.value.length},...[...x.values()].sort((b,z)=>b.label.localeCompare(z.label,"zh-CN"))]}),af=P(()=>{const x=Ft.value.trim().toLowerCase();return ci.value.filter(b=>{const z=gt.value==="all"||b.kindId===gt.value,le=!x||b.searchText.includes(x);return z&&le})}),sf=P(()=>{const x=new Map;for(const b of af.value){const z=x.get(b.page)??[];z.push(b),x.set(b.page,z)}return[...x.entries()].sort(([b],[z])=>b-z).map(([b,z])=>({page:b,items:z}))}),zr=P(()=>af.value.map(x=>x.id)),ui=P(()=>Ye.value.length),lf=P(()=>zr.value.length>0&&zr.value.every(x=>Ye.value.includes(x)));Se(ci,x=>{const b=new Set(x.map(z=>z.id));Ye.value=Ye.value.filter(z=>b.has(z))}),Se(rf,x=>{x.some(b=>b.id===gt.value)||(gt.value="all")});function cf(x){const b=x.target;b&&(b instanceof HTMLInputElement||b instanceof HTMLTextAreaElement||b.isContentEditable)||x.key!=="Backspace"&&x.key!=="Delete"||we.value&&(x.preventDefault(),al())}function tr(x){var b;!S.value||S.value==="redact"||(b=_.value)==null||b.setToolDefaults(S.value,x)}function JC(x){if(R.value=x,S.value==="freeText"){tr({fontColor:x});return}if(S.value==="ink"){tr({strokeColor:x,color:x});return}tr({strokeColor:x})}function eT(){tr({opacity:N.value})}function tT(){S.value==="ink"&&tr({strokeWidth:$.value})}function nT(){S.value==="freeText"&&tr({fontSize:j.value})}async function uf(){const x=c.value.trim();!x||!ee.value||(l.value="正在检索全文",await ee.value.searchAllPages(x).toPromise(),ee.value.setShowAllResults(!0),ge.value.total>0&&ee.value.goToResult(0),l.value=ge.value.total?`已定位 ${ge.value.total} 处结果`:"未找到匹配内容")}function oT(){var x;(x=ue.value)==null||x.zoomIn()}function rT(){var x;(x=ue.value)==null||x.zoomOut()}function df(){var x;(x=ue.value)==null||x.requestZoom(Mt.FitWidth)}function pf(){var x;(x=ue.value)==null||x.requestZoom(Mt.FitPage)}function aT(){var x;(x=ue.value)==null||x.requestZoom(Mt.Automatic)}function hf(){var x;(x=ft.value)==null||x.scrollToPreviousPage("smooth")}function gf(){var x;(x=ft.value)==null||x.scrollToNextPage("smooth")}function ff(){var x;(x=y.value)==null||x.undo()}function mf(){var x;(x=y.value)==null||x.redo()}async function ll(x="manual-save"){if(!n.activeDocumentId||!He.value||!a.value){u.value="当前文档来源不支持另存副本";return}o("save-start");try{const b=await He.value.saveAsCopy().toPromise(),z=await n.service.saveCopy({fileId:f.value??n.activeDocumentId,fileName:n.source.name??"document.pdf",content:new Blob([b],{type:"application/pdf"}),reason:x});u.value=`已保存到 ${z.relativePath}`,o("save-success",z)}catch(b){const z=b instanceof Error?b.message:"保存失败";u.value=z,o("save-error",{message:z,cause:b})}}async function Pf(){if(!Te.value||!oe.value.pendingCount){u.value="当前没有待提交的脱敏内容";return}if(!window.confirm("脱敏提交后将影响导出副本内容,是否继续并另存新副本?"))return;if(!await Te.value.commitAllPending().toPromise()){u.value="脱敏提交未完成";return}await ll("redaction-save")}const iT=P(()=>n.readonly?"只读状态":Le.value?"便签编辑":oe.value.pendingCount>0?"待提交脱敏":"编辑状态");return Lo(()=>{window.addEventListener("keydown",cf)}),mr(()=>{window.removeEventListener("keydown",cf),xo!==null&&window.clearTimeout(xo),Y!==null&&window.clearTimeout(Y)}),Se(()=>n.activeDocumentId,x=>{x&&co&&(l.value="文档已就绪")}),(x,b)=>{var z,le;return v(),C("div",sA,[m("header",lA,[m("div",cA,[m("div",uA,[m("button",{class:"jit-toolbar__toggle",onClick:b[0]||(b[0]=U=>i.value=!I(i))},"目录"),m("div",dA,[m("strong",null,fe(t.source.name??"未命名文档"),1),m("span",null,fe(I(l)),1)])]),m("div",pA,[m("span",hA,fe(((z=ii.find(U=>U.id===h.value))==null?void 0:z.label)??"开始"),1),m("span",gA,"第 "+fe(V.value)+" 页 / 共 "+fe(se.value||"-")+" 页",1)]),m("div",fA,[m("button",{class:"jit-ribbon__action","data-tooltip":"撤销最近一次操作",disabled:!L.value,onClick:ff},"撤销",8,mA),m("button",{class:"jit-ribbon__action","data-tooltip":"重做刚刚撤销的内容",disabled:!de.value,onClick:mf},"重做",8,PA),m("button",{class:"jit-ribbon__action","data-tooltip":p.value?"展开左侧缩略图导航":"收起左侧缩略图导航",onClick:Ne},fe(p.value?"展开目录":"收起目录"),9,FA),m("button",{class:"jit-ribbon__action","data-tooltip":Gt.value?"隐藏批注管理抽屉":"显示批注管理抽屉",onClick:il},fe(Gt.value?"隐藏批注":"显示批注"),9,bA),m("button",{class:"jit-ribbon__action","data-tooltip":I(s)?"隐藏悬浮属性面板":"显示悬浮属性面板",onClick:Xt},fe(I(s)?"隐藏属性":"显示属性"),9,_A),m("button",{class:"jit-toolbar__toggle",onClick:Xt},"状态")])]),m("div",yA,[(v(),C(pe,null,tt(ii,U=>m("button",{key:U.id,class:St(["jit-ribbon__tab",{"is-active":h.value===U.id}]),"data-tooltip":U.description,"aria-selected":h.value===U.id,onClick:Ae=>h.value=U.id},fe(U.label),11,vA)),64))]),m("div",DA,[h.value==="home"?(v(),C("div",SA,[m("section",{class:"jit-ribbon__section jit-ribbon__section--nav"},[m("div",{class:"jit-ribbon__section-body"},[m("button",{class:"jit-icon-button","aria-label":"上一页",onClick:hf},[...b[12]||(b[12]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 18l-6-6 6-6"})],-1),m("span",null,"上一页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"下一页",onClick:gf},[...b[13]||(b[13]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 6l6 6-6 6"})],-1),m("span",null,"下一页",-1)])])]),b[14]||(b[14]=m("div",{class:"jit-ribbon__section-label"},"页面浏览",-1))]),m("section",EA,[m("div",AA,[m("button",{class:"jit-icon-button","aria-label":"缩小",onClick:rT},[...b[15]||(b[15]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 12h8"}),m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1),m("span",null,"缩小",-1)])]),m("button",{class:"jit-icon-button","aria-label":"放大",onClick:oT},[...b[16]||(b[16]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M10 7v6"></path><path d="M7 10h6"></path><path d="M14.5 14.5L20 20"></path><circle cx="10" cy="10" r="6"></circle></svg><span>放大</span>',2)])]),m("button",{class:"jit-icon-button","aria-label":"适应整页",onClick:pf},[...b[17]||(b[17]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("rect",{x:"7",y:"4",width:"10",height:"16",rx:"1.5"})],-1),m("span",null,"整页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"适应页宽",onClick:df},[...b[18]||(b[18]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 8V5h3"></path><path d="M20 8V5h-3"></path><path d="M4 16v3h3"></path><path d="M20 16v3h-3"></path><path d="M8 12h8"></path></svg><span>页宽</span>',2)])]),m("div",xA,fe(Re.value),1)]),b[19]||(b[19]=m("div",{class:"jit-ribbon__section-label"},"缩放与阅读",-1))]),m("section",CA,[m("div",TA,[m("button",{class:"jit-icon-button","aria-label":"撤销",disabled:!L.value,onClick:ff},[...b[20]||(b[20]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 7H5v4"}),m("path",{d:"M5 11c2-3 5-5 9-5 3 0 6 2 7 5"})],-1),m("span",null,"撤销",-1)])],8,MA),m("button",{class:"jit-icon-button","aria-label":"重做",disabled:!de.value,onClick:mf},[...b[21]||(b[21]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 7h4v4"}),m("path",{d:"M19 11c-2-3-5-5-9-5-3 0-6 2-7 5"})],-1),m("span",null,"重做",-1)])],8,RA)]),b[22]||(b[22]=m("div",{class:"jit-ribbon__section-label"},"历史记录",-1))]),m("section",wA,[m("div",OA,[m("button",{class:"jit-icon-button jit-icon-button--primary","aria-label":"另存副本",disabled:!I(a),onClick:b[1]||(b[1]=U=>ll())},[...b[23]||(b[23]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 4h9l3 3v13H6z"}),m("path",{d:"M9 4v5h6"}),m("path",{d:"M9 16h6"})],-1),m("span",null,"另存副本",-1)])],8,kA),m("button",{class:"jit-icon-button is-danger","aria-label":"提交脱敏并导出",disabled:!I(r).redaction||!I(oe).pendingCount,onClick:Pf},[...b[24]||(b[24]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg><span>提交脱敏</span>',2)])],8,IA)]),b[25]||(b[25]=m("div",{class:"jit-ribbon__section-label"},"保存导出",-1))])])):h.value==="annotate"?(v(),C("div",GA,[m("section",LA,[m("div",$A,[(v(!0),C(pe,null,tt(ol.value,U=>(v(),C("button",{key:U.id,class:St(["jit-icon-button jit-icon-button--tool",{"is-active":U.active,"is-danger":U.danger}]),"aria-label":U.label,disabled:U.disabled,onClick:U.onClick},[U.icon==="pointer"?(v(),C("svg",jA,[...b[26]||(b[26]=[m("path",{d:"M6 4l10 8-5 1 2 5-2 1-2-5-3 3z"},null,-1)])])):U.icon==="highlight"?(v(),C("svg",UA,[...b[27]||(b[27]=[m("path",{d:"M6 15l5-5 4 4-5 5H6z"},null,-1),m("path",{d:"M13 8l2-2 3 3-2 2z"},null,-1),m("path",{d:"M5 19h9"},null,-1)])])):U.icon==="note"?(v(),C("svg",BA,[...b[28]||(b[28]=[m("path",{d:"M7 4h10v12H7z"},null,-1),m("path",{d:"M9 8h6"},null,-1),m("path",{d:"M9 12h4"},null,-1),m("path",{d:"M7 16h3"},null,-1)])])):U.icon==="text"?(v(),C("svg",zA,[...b[29]||(b[29]=[m("path",{d:"M6 6h12"},null,-1),m("path",{d:"M12 6v12"},null,-1),m("path",{d:"M8 18h8"},null,-1)])])):U.icon==="draw"?(v(),C("svg",WA,[...b[30]||(b[30]=[m("path",{d:"M4 16c2-4 5-6 8-7 2-1 4 0 5 2 1 2 0 4-2 5-3 2-7 2-11 0z"},null,-1),m("path",{d:"M14 6l2-2 4 4-2 2z"},null,-1)])])):(v(),C("svg",HA,[...b[31]||(b[31]=[Zn('<path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M7 11h10"></path><path d="M7 15h10"></path><path d="M7 19h10"></path>',5)])])),m("span",null,fe(U.label),1)],10,NA))),128))]),b[32]||(b[32]=m("div",{class:"jit-ribbon__section-label"},"批注工具",-1))]),m("section",VA,[m("div",YA,[m("div",qA,[b[33]||(b[33]=m("span",{class:"jit-style-label"},"颜色",-1)),m("div",KA,[(v(!0),C(pe,null,tt(D.value,U=>(v(),C("button",{key:U,class:St(["jit-color-swatch",{"is-active":R.value===U}]),style:Z({background:U}),title:U,disabled:!B.value,onClick:Ae=>JC(U)},null,14,XA))),128))])]),re.value?(v(),C("div",ZA,[b[34]||(b[34]=m("label",{class:"jit-style-label",for:"jit-stroke-width"},"线条粗细",-1)),m("div",QA,[fo(m("input",{id:"jit-stroke-width","onUpdate:modelValue":b[2]||(b[2]=U=>$.value=U),type:"range",min:"2",max:"20",step:"1",onChange:tT},null,544),[[Bo,$.value,void 0,{number:!0}]]),m("span",null,fe($.value),1)])])):ae("",!0),Fe.value?(v(),C("div",JA,[b[35]||(b[35]=m("label",{class:"jit-style-label",for:"jit-font-size"},"字号",-1)),m("div",ex,[fo(m("input",{id:"jit-font-size","onUpdate:modelValue":b[3]||(b[3]=U=>j.value=U),type:"range",min:"10",max:"32",step:"1",onChange:nT},null,544),[[Bo,j.value,void 0,{number:!0}]]),m("span",null,fe(j.value),1)])])):ae("",!0),be.value?(v(),C("div",tx,[b[36]||(b[36]=m("label",{class:"jit-style-label",for:"jit-opacity"},"透明度",-1)),m("div",nx,[fo(m("input",{id:"jit-opacity","onUpdate:modelValue":b[4]||(b[4]=U=>N.value=U),type:"range",min:"0.2",max:"1",step:"0.1",onChange:eT},null,544),[[Bo,N.value,void 0,{number:!0}]]),m("span",null,fe(Math.round(N.value*100))+"%",1)])])):ae("",!0)]),b[37]||(b[37]=m("div",{class:"jit-ribbon__section-label"},"样式属性",-1))]),m("section",ox,[m("div",rx,[m("div",ax,[b[38]||(b[38]=m("em",null,"当前工具",-1)),m("strong",null,fe(d.value),1)]),m("span",{class:St(["jit-ribbon__hint-chip",{"is-danger":Ut.value==="受限"}])},fe(Ut.value),3),m("span",ix,"待脱敏 "+fe(I(oe).pendingCount)+" 处",1),m("button",{class:"jit-ribbon__hint-action",disabled:!we.value,onClick:al}," 删除选中 "+fe(we.value||""),9,sx)]),b[39]||(b[39]=m("div",{class:"jit-ribbon__section-label"},"使用提示",-1))])])):h.value==="view"?(v(),C("div",lx,[m("section",{class:"jit-ribbon__section jit-ribbon__section--nav"},[m("div",{class:"jit-ribbon__section-body"},[m("button",{class:"jit-icon-button","aria-label":"上一页",onClick:hf},[...b[40]||(b[40]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 18l-6-6 6-6"})],-1),m("span",null,"上一页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"下一页",onClick:gf},[...b[41]||(b[41]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 6l6 6-6 6"})],-1),m("span",null,"下一页",-1)])])]),b[42]||(b[42]=m("div",{class:"jit-ribbon__section-label"},"翻页",-1))]),m("section",cx,[m("div",ux,[m("button",{class:"jit-icon-button","aria-label":"适应整页",onClick:pf},[...b[43]||(b[43]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("rect",{x:"7",y:"4",width:"10",height:"16",rx:"1.5"})],-1),m("span",null,"整页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"适应页宽",onClick:df},[...b[44]||(b[44]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 8V5h3"></path><path d="M20 8V5h-3"></path><path d="M4 16v3h3"></path><path d="M20 16v3h-3"></path><path d="M8 12h8"></path></svg><span>页宽</span>',2)])]),m("button",{class:"jit-icon-button","aria-label":"自动缩放",onClick:aT},[...b[45]||(b[45]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("circle",{cx:"12",cy:"12",r:"8"}),m("path",{d:"M12 8v4l3 2"})],-1),m("span",null,"自动",-1)])]),m("div",dx,fe(Re.value),1)]),b[46]||(b[46]=m("div",{class:"jit-ribbon__section-label"},"阅读模式",-1))]),m("section",px,[m("div",hx,[m("button",{class:"jit-icon-button","aria-label":p.value?"展开缩略图":"收起缩略图",onClick:Ne},[b[47]||(b[47]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M4 6h16"}),m("path",{d:"M4 12h10"}),m("path",{d:"M4 18h16"})],-1)),m("span",null,fe(p.value?"展开目录":"收起目录"),1)],8,gx),m("button",{class:"jit-icon-button","aria-label":I(s)?"隐藏属性面板":"显示属性面板",onClick:Xt},[b[48]||(b[48]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 5h14v14H5z"}),m("path",{d:"M12 5v14"})],-1)),m("span",null,fe(I(s)?"隐藏侧栏":"显示侧栏"),1)],8,fx)]),b[49]||(b[49]=m("div",{class:"jit-ribbon__section-label"},"界面布局",-1))]),m("section",mx,[m("div",Px,[m("div",Fx,[b[50]||(b[50]=m("em",null,"工具",-1)),m("strong",null,fe(d.value),1)]),m("div",bx,[b[51]||(b[51]=m("em",null,"搜索",-1)),m("strong",null,fe(Pe.value)+" 处",1)])]),b[52]||(b[52]=m("div",{class:"jit-ribbon__section-label"},"阅读摘要",-1))])])):(v(),C("div",_x,[m("section",yx,[m("div",vx,[m("div",Dx,[b[53]||(b[53]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1)),fo(m("input",{"onUpdate:modelValue":b[5]||(b[5]=U=>c.value=U),placeholder:"搜索全文",onKeydown:HP(Yi(uf,["prevent"]),["enter"])},null,40,Sx),[[Bo,c.value]])]),m("button",{class:"jit-icon-button","aria-label":"执行搜索",disabled:!I(r).search,onClick:uf},[...b[54]||(b[54]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1),m("span",null,"查找",-1)])],8,Ex),m("button",{class:"jit-icon-button","aria-label":"上一个结果",disabled:!I(r).search||!Pe.value,onClick:b[6]||(b[6]=U=>{var Ae;return(Ae=I(ee))==null?void 0:Ae.previousResult()})},[...b[55]||(b[55]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 6l-6 6 6 6"})],-1),m("span",null,"上一个",-1)])],8,Ax),m("button",{class:"jit-icon-button","aria-label":"下一个结果",disabled:!I(r).search||!Pe.value,onClick:b[7]||(b[7]=U=>{var Ae;return(Ae=I(ee))==null?void 0:Ae.nextResult()})},[...b[56]||(b[56]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 6l6 6-6 6"})],-1),m("span",null,"下一个",-1)])],8,xx)]),b[57]||(b[57]=m("div",{class:"jit-ribbon__section-label"},"全文检索",-1))]),m("section",Cx,[m("div",Tx,[m("button",{class:"jit-icon-button jit-icon-button--primary","aria-label":"另存副本",disabled:!I(a),onClick:b[8]||(b[8]=U=>ll())},[...b[58]||(b[58]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 4h9l3 3v13H6z"}),m("path",{d:"M9 4v5h6"}),m("path",{d:"M9 16h6"})],-1),m("span",null,"另存副本",-1)])],8,Mx),m("button",{class:"jit-icon-button is-danger","aria-label":"提交脱敏并导出",disabled:!I(r).redaction||!I(oe).pendingCount,onClick:Pf},[...b[59]||(b[59]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg><span>提交脱敏</span>',2)])],8,Rx)]),b[60]||(b[60]=m("div",{class:"jit-ribbon__section-label"},"审阅输出",-1))]),m("section",wx,[m("div",Ox,[m("div",kx,[b[61]||(b[61]=m("em",null,"搜索",-1)),m("strong",null,fe(Pe.value)+" 处",1)]),m("div",Ix,[b[62]||(b[62]=m("em",null,"修改",-1)),m("strong",null,fe(O.value?"待保存":"已同步"),1)])]),b[63]||(b[63]=m("div",{class:"jit-ribbon__section-label"},"当前状态",-1))])]))])]),m("div",{class:St(["jit-layout",{"is-left-collapsed":p.value}])},[m("aside",{class:St(["jit-sidebar jit-sidebar--left",{"is-open":I(i),"is-collapsed":p.value}])},[m("div",Gx,[p.value?ae("",!0):(v(),C("div",Lx,[b[64]||(b[64]=m("strong",null,"缩略图",-1)),m("span",null,"第 "+fe(V.value)+" / "+fe(se.value||"-")+" 页",1)])),m("button",{class:"jit-sidebar__collapse","aria-label":p.value?"展开缩略图":"收起缩略图",onClick:Ne},[p.value?(v(),C("svg",Nx,[...b[65]||(b[65]=[m("path",{d:"M9 6l6 6-6 6"},null,-1)])])):(v(),C("svg",jx,[...b[66]||(b[66]=[m("path",{d:"M15 6l-6 6 6 6"},null,-1)])]))],8,$x)]),!p.value&&I(r).thumbnail&&t.activeDocumentId?(v(),he(I(BE),{key:0,class:"jit-thumbnails","document-id":t.activeDocumentId},{default:We(({meta:U})=>[m("button",{class:St(["jit-thumbnail",{"is-active":V.value===U.pageIndex+1}]),style:Z({top:`${U.top}px`,height:`${U.wrapperHeight}px`}),onClick:Ae=>Pt(U.pageIndex)},[m("div",Bx,[je(I(WE),{"document-id":t.activeDocumentId,meta:U,class:"jit-thumbnail__image"},null,8,["document-id","meta"])]),m("div",zx,[m("span",Wx,"第 "+fe(U.pageIndex+1)+" 页",1),V.value===U.pageIndex+1?(v(),C("span",Hx,"当前")):ae("",!0)])],14,Ux)]),_:1},8,["document-id"])):p.value?ae("",!0):(v(),C("p",Vx,"缩略图已关闭"))],2),m("main",Yx,[m("div",qx,[m("button",{class:"jit-annotation-drawer-toggle","aria-label":Gt.value?"隐藏批注管理抽屉":"显示批注管理抽屉",onClick:il},[...b[67]||(b[67]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 6h14"}),m("path",{d:"M5 12h14"}),m("path",{d:"M5 18h10"})],-1)])],8,Kx),m("button",{class:"jit-inspector-toggle","aria-label":I(s)?"隐藏属性面板":"显示属性面板",onClick:Xt},[...b[68]||(b[68]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 5h14v14H5z"}),m("path",{d:"M12 5v14"})],-1)])],8,Xx),m("aside",{class:St(["jit-inspector",{"is-open":I(s)}])},[m("div",Zx,[m("div",null,[m("strong",null,fe(iT.value),1),m("span",null,fe(d.value)+" · "+fe(Math.round(H.value*100))+"%",1)]),m("button",{class:"jit-inspector__close","aria-label":"收起属性面板",onClick:Xt},[...b[69]||(b[69]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 6l12 12"}),m("path",{d:"M18 6L6 18"})],-1)])])]),m("div",Qx,[Le.value?(v(),C("section",Jx,[m("div",eC,[m("div",null,[m("div",tC,[b[71]||(b[71]=m("strong",null,"便签内容",-1)),m("button",{class:"jit-note-editor__delete",disabled:!we.value,"aria-label":"删除便签",onClick:al},[...b[70]||(b[70]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg>',1)])],8,nC)]),m("span",null,"第 "+fe((le=Xe.value)==null?void 0:le.pageLabel)+" 页 · "+fe(dt.value),1)])]),m("label",oC,[b[72]||(b[72]=m("span",null,"说明内容",-1)),fo(m("textarea",{"onUpdate:modelValue":b[9]||(b[9]=U=>ne.value=U),placeholder:"为这条便签补充说明、结论或处理意见",onInput:er,onBlur:li},null,544),[[Bo,ne.value]])]),m("div",rC,[b[73]||(b[73]=m("span",null,"便签会在停止输入后自动保存",-1)),m("strong",null,fe(Kt.value)+" 字",1)])])):ae("",!0),m("dl",aC,[m("div",null,[b[74]||(b[74]=m("dt",null,"当前工具",-1)),m("dd",null,fe(d.value),1)]),m("div",null,[b[75]||(b[75]=m("dt",null,"批注权限",-1)),m("dd",null,fe(Ut.value),1)]),m("div",null,[b[76]||(b[76]=m("dt",null,"缩放",-1)),m("dd",null,fe(Math.round(H.value*100))+"%",1)]),m("div",null,[b[77]||(b[77]=m("dt",null,"搜索结果",-1)),m("dd",null,fe(Pe.value)+" 处",1)]),m("div",null,[b[78]||(b[78]=m("dt",null,"待提交脱敏",-1)),m("dd",null,fe(I(oe).pendingCount)+" 处",1)]),m("div",null,[b[79]||(b[79]=m("dt",null,"待保存修改",-1)),m("dd",null,fe(O.value?"是":"否"),1)]),b[80]||(b[80]=m("div",null,[m("dt",null,"保存策略"),m("dd",null,"仅另存新副本")],-1))]),m("div",iC,[b[81]||(b[81]=m("p",null,"属性面板已改成悬浮检查器,需要时展开,不占主阅读空间。",-1)),Le.value?(v(),C("p",sC,"当前便签已接入内容编辑器,支持随写随存,适合记录审核意见和处理说明。")):(v(),C("p",lC,"高亮类工具需要先框选文本;涂鸦和文本框工具可以直接在画布中绘制或点击创建。")),u.value?(v(),C("p",cC,fe(u.value),1)):ae("",!0)])])],2)]),m("aside",{class:St(["jit-annotation-drawer",{"is-open":Gt.value}])},[m("div",uC,[m("div",null,[b[82]||(b[82]=m("strong",null,"批注管理",-1)),m("span",null,fe(Dt.value)+" 个批注,"+fe(ui.value)+" 个待批量操作",1)]),m("div",dC,[m("button",{class:"jit-annotation-panel__action jit-annotation-panel__action--secondary",disabled:!zr.value.length,onClick:XC},fe(lf.value?"清空当前结果":"全选当前结果"),9,pC),m("button",{class:"jit-annotation-panel__action",disabled:!ui.value,onClick:ZC}," 批量删除 "+fe(ui.value||""),9,hC),m("button",{class:"jit-annotation-panel__close","aria-label":"关闭批注管理抽屉",onClick:il},[...b[83]||(b[83]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 6l12 12"}),m("path",{d:"M18 6L6 18"})],-1)])])])]),m("div",gC,[m("div",fC,[m("label",mC,[b[84]||(b[84]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1)),fo(m("input",{"onUpdate:modelValue":b[10]||(b[10]=U=>Ft.value=U),placeholder:"搜索批注内容、页码或类型"},null,512),[[Bo,Ft.value]])]),m("label",PC,[b[85]||(b[85]=m("span",null,"类型",-1)),fo(m("select",{"onUpdate:modelValue":b[11]||(b[11]=U=>gt.value=U)},[(v(!0),C(pe,null,tt(rf.value,U=>(v(),C("option",{key:U.id,value:U.id},fe(U.label)+"("+fe(U.count)+") ",9,FC))),128))],512),[[UP,gt.value]])])]),sf.value.length?(v(),C("div",bC,[(v(!0),C(pe,null,tt(sf.value,U=>(v(),C("section",{key:U.page,class:"jit-annotation-group"},[m("header",_C,[m("strong",null,"第 "+fe(U.page+1)+" 页",1),m("span",null,fe(U.items.length)+" 条批注",1)]),(v(!0),C(pe,null,tt(U.items,Ae=>(v(),C("article",{key:Ae.id,class:St(["jit-annotation-item",{"is-selected":Ae.isCanvasSelected,"is-batch-selected":Ye.value.includes(Ae.id)}])},[m("button",{class:"jit-annotation-item__selector","aria-label":Ye.value.includes(Ae.id)?"取消批量选择":"加入批量选择",onClick:Yi(lt=>KC(Ae.id),["stop"])},[Ye.value.includes(Ae.id)?(v(),C("span",vC)):ae("",!0)],8,yC),m("button",{class:"jit-annotation-item__main",onClick:lt=>Br(Ae.entry)},[m("div",SC,[m("strong",null,fe(Ae.kindLabel),1),m("span",null,"第 "+fe(Ae.page+1)+" 页",1)]),m("p",null,fe(Ae.summary),1),m("div",EC,[Ae.groupCount>1?(v(),C("span",AC," 组合 "+fe(Ae.groupCount),1)):ae("",!0),Ae.repliesCount?(v(),C("span",xC," 回复 "+fe(Ae.repliesCount),1)):ae("",!0),Ae.isCanvasSelected?(v(),C("span",CC," 画布已选中 ")):ae("",!0),Ye.value.includes(Ae.id)?(v(),C("span",TC," 待批量处理 ")):ae("",!0)])],8,DC),m("button",{class:"jit-annotation-item__delete","aria-label":`删除第 ${Ae.page+1} 页的${Ae.kindLabel}`,onClick:Yi(lt=>qC(Ae.entry),["stop"])},[...b[86]||(b[86]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg>',1)])],8,MC)],2))),128))]))),128))])):(v(),C("div",RC,[...b[87]||(b[87]=[m("p",null,"当前筛选条件下没有批注。你可以修改类型筛选,或直接搜索批注内容与页码。",-1)])]))])],2),je(I(GD),{"document-id":t.activeDocumentId},{default:We(({isLoading:U,isError:Ae,isLoaded:lt})=>[U||t.isInitializing?(v(),C("div",wC,"正在分段加载文档")):Ae?(v(),C("div",OC," 文档加载失败,请检查本地文件服务和 PDF 路径 ")):lt&&t.activeDocumentId?(v(),he(I(JE),{key:2,class:"jit-viewport","document-id":t.activeDocumentId},{default:We(()=>[je(I(_y),{"document-id":t.activeDocumentId},{default:We(()=>[je(I(jE),{class:"jit-zoom-surface","document-id":t.activeDocumentId},{default:We(()=>[je(I(qE),{class:"jit-scroller","document-id":t.activeDocumentId},{default:We(({page:ze})=>[je(I(vy),{class:"jit-page","document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,style:Z({zIndex:ze.elevated?1:void 0})},{default:We(()=>[I(r).redaction?(v(),he(I(Ah),{key:0})):ae("",!0),je(I(aA),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"]),je(I(nA),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"]),je(I(Hy),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,"text-style":{background:"rgba(22, 119, 255, 0.22)"}},null,8,["document-id","page-index","scale"]),je(I(HE),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,"highlight-color":"rgba(22, 119, 255, 0.28)","active-highlight-color":"rgba(9, 88, 217, 0.42)"},null,8,["document-id","page-index","scale"]),I(r).annotation||I(r).ink||I(r).freeText?(v(),he(I(Bp),{key:1,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).annotation||I(r).ink||I(r).freeText?(v(),he(I(MD),{key:2,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(Dh),{key:3,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,stroke:"rgba(208, 48, 80, 0.9)",fill:"rgba(208, 48, 80, 0.14)"},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(Sh),{key:4,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(Eh),{key:5,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,rotation:0},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(cS),{key:6,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0)]),_:2},1032,["document-id","page-index","scale","style"])]),_:1},8,["document-id"])]),_:1},8,["document-id"])]),_:1},8,["document-id"])]),_:1},8,["document-id"])):(v(),C("div",kC,"准备打开文档"))]),_:1},8,["document-id"])])],2)])}}}),Xg=ie({__name:"JitPdfEditor",props:{source:{},locale:{default:"zh-CN"},theme:{default:"blue-enterprise"},capabilities:{},service:{},readonly:{type:Boolean,default:!1}},emits:["ready","dirty-change","save-start","save-success","save-error","load-error"],setup(t,{emit:e}){const n=t,o=e,r=RE(GE,{encoderPoolSize:2,fontFallback:IE}),a=P(()=>({permissions:{enforceDocumentPermissions:!1,overrides:{modifyAnnotations:!n.readonly,modifyContents:!n.readonly,copyContents:!0,print:!0}}})),i=P(()=>[{package:ND},{package:cE},{package:SS,config:{defaultPageGap:40,defaultBufferSize:4}},{package:gS},{package:qS},{package:hy},{package:Yy},{package:XD},{package:OS,config:{showAllResults:!0}},{package:US},{package:FE,config:{defaultZoomLevel:Mt.FitPage}},{package:kD,config:{autoCommit:!0,annotationAuthor:"Jit PDF",locked:{type:n.readonly?jn.All:jn.None},colorPresets:["#1677FF","#0958D9","#18A058","#D03050","#FAAD14"]}},{package:hS,config:{drawBlackBoxes:!0,useAnnotationMode:!0}},{package:zD,config:{defaultFileName:n.source.name??"jit-pdf-export.pdf"}}]);return(s,l)=>(v(),he(I(tb),{class:"jit-pdf-shell",engine:I(r),config:a.value,plugins:i.value,"auto-mount-dom-elements":!0},{default:We(({activeDocumentId:c,pluginsReady:u,isInitializing:d})=>[je(IC,xe(n,{"active-document-id":c,"plugins-ready":u,"is-initializing":d,onReady:l[0]||(l[0]=p=>o("ready",p)),onDirtyChange:l[1]||(l[1]=p=>o("dirty-change",p)),onSaveStart:l[2]||(l[2]=p=>o("save-start")),onSaveSuccess:l[3]||(l[3]=p=>o("save-success",p)),onSaveError:l[4]||(l[4]=p=>o("save-error",p)),onLoadError:l[5]||(l[5]=p=>o("load-error",p))}),null,16,["active-document-id","plugins-ready","is-initializing"])]),_:1},8,["engine","config","plugins"]))}}),Zg="jit-pdf-sdk",Eo="files",ai="annotations";function Qg(t){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${t}-${crypto.randomUUID()}`:`${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`}function GC(t=new Date){const e=n=>n.toString().padStart(2,"0");return[t.getFullYear(),e(t.getMonth()+1),e(t.getDate())].join("")+`-${e(t.getHours())}${e(t.getMinutes())}${e(t.getSeconds())}`}function LC(t){const e=t.lastIndexOf(".");return e>=0?t.slice(0,e):t}function $C(t){const e=t.lastIndexOf(".");return e>=0?t.slice(e):".pdf"}function NC(t){return`${LC(t)}-副本-${GC()}${$C(t)}`}function Jg(t){return Kg(t)}function jC(t){return new Promise((e,n)=>{const o=indexedDB.open(t,1);o.onupgradeneeded=()=>{const r=o.result;if(!r.objectStoreNames.contains(Eo)){const a=r.createObjectStore(Eo,{keyPath:"id"});a.createIndex("updatedAt","updatedAt",{unique:!1}),a.createIndex("originId","originId",{unique:!1})}r.objectStoreNames.contains(ai)||r.createObjectStore(ai,{keyPath:"fileId"})},o.onsuccess=()=>e(o.result),o.onerror=()=>n(o.error??new Error("IndexedDB 打开失败"))})}function nl(t){return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error??new Error("IndexedDB 请求失败"))})}async function Ao(t,e,n,o){const r=await jC(t);try{const a=r.transaction(e,n),i=a.objectStore(e),s=await o(i);return await new Promise((l,c)=>{a.oncomplete=()=>l(),a.onerror=()=>c(a.error??new Error("IndexedDB 事务失败")),a.onabort=()=>c(a.error??new Error("IndexedDB 事务中断"))}),s}finally{r.close()}}function UC(t){return{id:t.id,name:t.name,relativePath:t.relativePath,size:t.size,updatedAt:t.updatedAt,pageCount:null}}function BC(t){return{id:t.id,name:t.name,relativePath:t.relativePath,size:t.size,updatedAt:t.updatedAt}}function zC(t){return{kind:"file",id:t.id,name:t.name,relativePath:t.relativePath,size:t.size,updatedAt:t.updatedAt}}function ef(t){return{async load(e){const n=await Ao(t,ai,"readonly",async o=>nl(o.get(e)));return Jg((n==null?void 0:n.annotations)??[])},async save(e,n){await Ao(t,ai,"readwrite",async o=>{o.put({fileId:e,annotations:Jg(n),updatedAt:new Date().toISOString()})})}}}function tf(t={}){const e=t.databaseName??Zg,n=ef(e),o=new Map;function r(s){const l=o.get(s.id);if(l)return l;const c=URL.createObjectURL(s.blob);return o.set(s.id,c),c}async function a(){const s=await Ao(e,Eo,"readonly",async l=>nl(l.getAll()));return s.forEach(l=>r(l)),s.sort((l,c)=>c.updatedAt.localeCompare(l.updatedAt))}async function i(s){const l=await Ao(e,Eo,"readonly",async c=>nl(c.get(s)));if(!l)throw new Error("未找到本地 PDF 文件");return r(l),l}return{async getFileList(){return{rootDir:"IndexedDB",items:(await a()).map(zC)}},async getFileMeta(s){return UC(await i(s))},async getFileHistory(s){const l=await i(s),c=l.originId||l.id;return(await a()).filter(d=>d.id!==l.id&&d.originId===c).map(BC)},getFileStreamUrl(s){return o.get(s)??""},async uploadFile(s){const l=Qg("local"),c=new Date().toISOString(),u={id:l,name:s.name,relativePath:`indexeddb/${l}/${s.name}`,size:s.size,updatedAt:c,blob:s,originId:l};await Ao(e,Eo,"readwrite",async p=>{p.put(u)});const d=o.get(l);return d&&URL.revokeObjectURL(d),o.set(l,URL.createObjectURL(s)),{id:l,name:u.name,relativePath:u.relativePath,size:u.size,updatedAt:c}},async deleteFile(s){const l=await i(s);await Ao(e,Eo,"readwrite",async u=>{u.delete(s)});const c=o.get(s);return c&&(URL.revokeObjectURL(c),o.delete(s)),await n.save(s,[]),{fileId:s,relativePath:l.relativePath}},async saveCopy(s){const l=await i(s.fileId),c=new Blob([await s.content.arrayBuffer()],{type:"application/pdf"}),u=Qg("local-copy"),d=NC(s.fileName||l.name),p=new Date().toISOString(),h={id:u,name:d,relativePath:`indexeddb/${u}/${d}`,size:c.size,updatedAt:p,blob:c,originId:l.originId||l.id};await Ao(e,Eo,"readwrite",async f=>{f.put(h)});const g=o.get(u);return g&&URL.revokeObjectURL(g),o.set(u,URL.createObjectURL(c)),await n.save(u,[]),{fileId:u,fileName:d,relativePath:h.relativePath,absolutePath:h.relativePath,savedAt:p,size:h.size}},async loadAnnotations(s){return n.load(s)},async saveAnnotations(s,l){await n.save(s,l)}}}function WC(t={}){const e=t.databaseName??Zg;return ef(e)}function HC(t){return encodeURIComponent(t)}async function Qo(t){if(!t.ok){let e=null;try{e=await t.json()}catch{e=null}throw new Error((e==null?void 0:e.message)??`请求失败: ${t.status}`)}return await t.json()}function nf(t={}){const e=t.baseUrl??"",n=WC({databaseName:t.annotationDatabaseName});return{async getFileList(){const o=await fetch(`${e}/api/files`);return Qo(o)},async getFileMeta(o){const r=await fetch(`${e}/api/files/${encodeURIComponent(o)}/meta`);return Qo(r)},async getFileHistory(o){const r=await fetch(`${e}/api/files/${encodeURIComponent(o)}/history`);return Qo(r)},getFileStreamUrl(o){return`${e}/api/files/${encodeURIComponent(o)}/content`},async uploadFile(o){const r=new FormData;r.append("file",o);const a=await fetch(`${e}/api/files/upload`,{method:"POST",body:r});return Qo(a)},async deleteFile(o){const r=await fetch(`${e}/api/files/${encodeURIComponent(o)}`,{method:"DELETE"});return Qo(r)},async saveCopy(o){const r=await o.content.arrayBuffer(),a=await fetch(`${e}/api/files/${encodeURIComponent(o.fileId)}/save-copy`,{method:"POST",headers:{"Content-Type":"application/pdf","X-File-Name":HC(o.fileName),"X-Save-Reason":o.reason??"manual-save"},body:r});return Qo(a)},async loadAnnotations(o){return n.load(o)},async saveAnnotations(o,r){await n.save(o,r)}}}function VC(t){if(typeof t=="string"){const e=document.querySelector(t);if(!e)throw new Error(`未找到挂载容器:${t}`);return e}return t}function of(t){const{target:e,onReady:n,onDirtyChange:o,onSaveStart:r,onSaveSuccess:a,onSaveError:i,onLoadError:s,...l}=t,c=VC(e),u=qP({render(){return FP(Xg,{...l,onReady:n,onDirtyChange:o,onSaveStart:r,onSaveSuccess:a,onSaveError:i,onLoadError:s})}});return u.mount(c),{app:u,element:c,unmount(){u.unmount()}}}const YC={mountJitPdfEditor:of,createHttpPdfEditorService:nf,createIndexedDbPdfEditorService:tf};rn.JitPdfEditor=Xg,rn.browser=YC,rn.createHttpPdfEditorService=nf,rn.createIndexedDbPdfEditorService=tf,rn.mountJitPdfEditor=of,rn.usePdfEditorSdk=qg,Object.defineProperty(rn,Symbol.toStringTag,{value:"Module"})});
18863
+ `],{type:"application/javascript"})),c=new OE(r??2,l,o);return new DE(s,{imageConverter:EE(c),logger:o})}function IE(t="latest"){return{jp:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-jp@${t}/fonts`,kr:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-kr@${t}/fonts`,sc:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-sc@${t}/fonts`,tc:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-tc@${t}/fonts`,arabic:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-arabic@${t}/fonts`,hebrew:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-hebrew@${t}/fonts`,latin:`https://cdn.jsdelivr.net/npm/@embedpdf/fonts-latin@${t}/fonts`}}function Hn(t,e){return t.map(n=>({url:`${e}/${n.file}`,weight:n.weight,italic:n.italic}))}function GE(t){return{fonts:{[vn.SHIFTJIS]:Hn(AE,t.jp),[vn.HANGEUL]:Hn(xE,t.kr),[vn.GB2312]:Hn(CE,t.sc),[vn.CHINESEBIG5]:Hn(TE,t.tc),[vn.ARABIC]:Hn(ME,t.arabic),[vn.HEBREW]:Hn(RE,t.hebrew),[vn.CYRILLIC]:Hn(tl,t.latin),[vn.GREEK]:Hn(tl,t.latin),[vn.VIETNAMESE]:Hn(tl,t.latin)}}}const LE=IE("latest"),$E=GE(LE),NE="https://cdn.jsdelivr.net/npm/@embedpdf/pdfium@2.10.1/dist/pdfium.wasm",zg=()=>It(jg.id);function Wg(t){const[e,n]=[t[0],t[1]],o=n.clientX-e.clientX,r=n.clientY-e.clientY;return Math.hypot(o,r)}function jE(t){const[e,n]=[t[0],t[1]];return{x:(e.clientX+n.clientX)/2,y:(e.clientY+n.clientY)/2}}function UE({element:t,container:e,documentId:n,zoomProvides:o,viewportGap:r=0,options:a={}}){const{enablePinch:i=!0,enableWheel:s=!0}=a;if(typeof window>"u")return()=>{};const l=o.forDocument(n),c=()=>l.getState();let u=0,d=1,p=!1,h=0,g=null,f=1,F=0,y=0,_=0,E=0,A=0,T=0,q=0,w=0,G=0,W=0,J=0,ue=0,ce=0;const ee=(L,de,Pe)=>Math.min(Math.max(L,de),Pe),ge=()=>{const L=e.clientWidth-2*r,de=t.offsetWidth,Pe=de<L?(L-de)/2:0;t.style.marginLeft=`${Pe}px`},ye=L=>{const de=F*L,Pe=y*L;let Re=G*(1-L);const Ut=w-de/2-_,D=W-ce*L-_,S=Math.max(0,de-q),R=q*.3,N=Math.min(1,S/R);let $=Ut+(D-Ut)*N;const j=T-ue*2;if(Pe>j){const K=E+Re,Y=ue,B=T-ue-Pe;Re=ee(K,B,Y)-E}const ne=A-ue*2;if(de>ne){const K=_+$,Y=ue,B=A-ue-de;$=ee(K,B,Y)-_}return{tx:$,ty:Re,blend:N,finalWidth:de}},Ee=L=>{d=L;const{tx:de,ty:Pe}=ye(L);t.style.transformOrigin="0 0",t.style.transform=`translate(${de}px, ${Pe}px) scale(${L})`},Te=()=>{t.style.transform="none",t.style.transformOrigin="0 0",d=1},oe=()=>{const{tx:L,finalWidth:de}=ye(d),Pe=(d-1)*u;let Re,vt=J;if(de<=q)Re=w;else{const Ut=1-d;Re=Math.abs(Ut)>.001?_+L/Ut:W}l.requestZoomBy(Pe,{vx:Re,vy:vt}),Te(),u=0},He=(L,de)=>{const Pe=e.getBoundingClientRect(),Re=t.getBoundingClientRect();ue=r,F=Re.width,y=Re.height,_=Re.left-Pe.left,E=Re.top-Pe.top,A=Pe.width,T=Pe.height,q=e.clientWidth,w=e.clientLeft+q/2;const vt=L-Re.left;G=de-Re.top,W=L-Pe.left,J=de-Pe.top,F<q?ce=W*F/q:ce=vt},ft=L=>{if(L.touches.length!==2)return;p=!0,u=c().currentZoomLevel,h=Wg(L.touches);const de=jE(L.touches);He(de.x,de.y),L.preventDefault()},Ve=L=>{if(!p||L.touches.length!==2)return;const Pe=Wg(L.touches)/h;Ee(Pe),L.preventDefault()},O=L=>{p&&(L.touches.length>=2||(p=!1,oe()))},H=L=>{if(!L.ctrlKey&&!L.metaKey)return;L.preventDefault(),g===null?(u=c().currentZoomLevel,f=1,He(L.clientX,L.clientY)):clearTimeout(g);const de=1-L.deltaY*.01;f*=de,f=Math.max(.1,Math.min(10,f)),Ee(f),g=setTimeout(()=>{g=null,oe(),f=1},150)},V=l.onStateChange(()=>ge()),se=new ResizeObserver(()=>ge());return se.observe(t),se.observe(e),ge(),i&&(e.addEventListener("touchstart",ft,{passive:!1}),e.addEventListener("touchmove",Ve,{passive:!1}),e.addEventListener("touchend",O),e.addEventListener("touchcancel",O)),s&&e.addEventListener("wheel",H,{passive:!1}),()=>{i&&(e.removeEventListener("touchstart",ft),e.removeEventListener("touchmove",Ve),e.removeEventListener("touchend",O),e.removeEventListener("touchcancel",O)),s&&e.removeEventListener("wheel",H),g&&clearTimeout(g),V(),se.disconnect(),Te(),t.style.marginLeft=""}}function BE(t,e={}){const{provides:n}=It("viewport"),{provides:o}=zg(),r=Po("viewport-element"),a=Q(null);let i;return Se([a,n,o,()=>$t(t),()=>$t(e.enablePinch??!0),()=>$t(e.enableWheel??!0)],([s,l,c,u,d,p])=>{i&&(i(),i=void 0);const h=r==null?void 0:r.value;!s||!h||!c||(i=UE({element:s,container:h,documentId:u,zoomProvides:c,viewportGap:(l==null?void 0:l.getViewportGap())||0,options:{enablePinch:d,enableWheel:p}}))},{immediate:!0}),{elementRef:a}}const zE=ie({__name:"zoom-gesture-wrapper",props:{documentId:{},enablePinch:{type:Boolean,default:!0},enableWheel:{type:Boolean,default:!0}},setup(t){const e=t,{elementRef:n}=BE(()=>e.documentId,{enablePinch:jl(()=>e.enablePinch),enableWheel:jl(()=>e.enableWheel)});return(o,r)=>(v(),C("div",xe({ref_key:"elementRef",ref:n,style:{display:"inline-block",overflow:"visible",boxSizing:"border-box"}},o.$attrs),[$e(o.$slots,"default")],16))}}),Hg=()=>Nn(Zs.id),WE=()=>It(Zs.id),HE=ie({__name:"thumbnails-pane",props:{documentId:{}},setup(t){const e=t,{plugin:n}=Hg(),o=Q(null),r=Q({window:null,docId:null}),a=Q(null);Se(r,s=>{a.value=s.docId===e.documentId?s.window:null},{deep:!0}),Se([()=>n.value,()=>e.documentId],([s,l],c,u)=>{if(!s){r.value={window:null,docId:null};return}const d=s.provides().forDocument(l),p=d.getWindow();p&&(r.value={window:p,docId:l});const h=d.onWindow(g=>{r.value={window:g,docId:l}});u(()=>{h(),r.value={window:null,docId:null}})},{immediate:!0}),Se([o,()=>n.value,()=>e.documentId],([s,l,c],u,d)=>{if(!s||!l)return;const p=l.provides().forDocument(c),h=()=>p.updateWindow(s.scrollTop,s.clientHeight);s.addEventListener("scroll",h);const g=new ResizeObserver(()=>{p.updateWindow(s.scrollTop,s.clientHeight)});g.observe(s),p.updateWindow(s.scrollTop,s.clientHeight),d(()=>{s.removeEventListener("scroll",h),g.disconnect()})},{immediate:!0}),Se([o,()=>n.value,()=>e.documentId,a],([s,l,c])=>{if(!s||!l)return;l.provides().forDocument(c).updateWindow(s.scrollTop,s.clientHeight)}),Se([o,()=>n.value,()=>e.documentId,()=>!!a.value],([s,l,c,u],d,p)=>{if(!s||!l||!u)return;const g=l.provides().forDocument(c).onScrollTo(({top:f,behavior:F})=>{ua(()=>{s.scrollTo({top:f,behavior:F})})});p(g)},{immediate:!0});const i=Q(0);return Se(()=>n.value,s=>{i.value=(s==null?void 0:s.cfg.paddingY)??0},{immediate:!0}),(s,l)=>{var c,u;return v(),C("div",xe({ref_key:"viewportRef",ref:o,style:{overflowY:"auto",position:"relative",paddingTop:`${i.value}px`,paddingBottom:`${i.value}px`,height:"100%"}},s.$attrs),[m("div",{style:Z({height:`${((c=a.value)==null?void 0:c.totalHeight)??0}px`,position:"relative"})},[(v(!0),C(pe,null,tt(((u=a.value)==null?void 0:u.items)??[],d=>$e(s.$slots,"default",{key:d.pageIndex,meta:d})),128))],4)],16)}}}),VE=["src"],YE=ie({__name:"thumbnail-img",props:{documentId:{},meta:{}},setup(t){const e=t,{provides:n}=WE(),{plugin:o}=Hg(),r=Q(null);let a=null;const i=Q(0);Se([()=>o.value,()=>e.documentId,()=>e.meta.pageIndex],([c,u,d],p,h)=>{if(!c)return;const f=c.provides().forDocument(u).onRefreshPages(F=>{F.includes(d)&&i.value++});h(f)},{immediate:!0});function s(){a&&(URL.revokeObjectURL(a),a=null)}let l=null;return Se([()=>n.value,()=>e.documentId,()=>e.meta.pageIndex,i],([c,u,d],p,h)=>{if(l&&(l(),l=null),!c){r.value=null;return}const f=c.forDocument(u).renderThumb(d,window.devicePixelRatio);l=()=>f.abort({code:ve.Cancelled,message:"canceled render task"}),f.wait(F=>{s();const y=URL.createObjectURL(F);a=y,r.value=y,l=null},Yt),h(()=>{l&&(l(),l=null),s()})},{immediate:!0}),(c,u)=>r.value?(v(),C("img",xe({key:0,src:r.value},c.$attrs,{onLoad:s}),null,16,VE)):ae("",!0)}}),Vg=()=>It(Qh.id),qE=ie({__name:"search-layer",props:{documentId:{},pageIndex:{},scale:{},highlightColor:{default:"#FFFF00"},activeHighlightColor:{default:"#FFBF00"}},setup(t){const e=t,{provides:n}=Vg(),o=Dn(()=>e.documentId),r=Q(null),a=P(()=>{var c;return((c=n.value)==null?void 0:c.forDocument(e.documentId))??null}),i=P(()=>{var c;return e.scale!==void 0?e.scale:((c=o.value)==null?void 0:c.scale)??1});Se(a,(c,u,d)=>{if(!c){r.value=null;return}const p=c.getState();r.value={results:p.results,activeResultIndex:p.activeResultIndex,showAllResults:p.showAllResults,active:p.active};const h=c.onSearchResultStateChange(g=>{r.value=g});d(h)},{immediate:!0});const s=P(()=>r.value?r.value.results.map((c,u)=>({result:c,originalIndex:u})).filter(({result:c})=>c.pageIndex===e.pageIndex):[]),l=P(()=>r.value?s.value.filter(({originalIndex:c})=>r.value.showAllResults||c===r.value.activeResultIndex):[]);return(c,u)=>r.value&&r.value.active?(v(),C("div",xe({key:0,style:{pointerEvents:"none"}},c.$attrs),[(v(!0),C(pe,null,tt(l.value,({result:d,originalIndex:p},h)=>(v(),C(pe,{key:`result-${h}`},[(v(!0),C(pe,null,tt(d.rects,(g,f)=>(v(),C("div",{key:`rect-${h}-${f}`,style:Z({position:"absolute",top:`${g.origin.y*i.value}px`,left:`${g.origin.x*i.value}px`,width:`${g.size.width*i.value}px`,height:`${g.size.height*i.value}px`,backgroundColor:p===r.value.activeResultIndex?t.activeHighlightColor:t.highlightColor,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1})},null,4))),128))],64))),128))],16)):ae("",!0)}}),KE=()=>Nn(Ks.id),XE=()=>It(Ks.id),ZE=ie({__name:"scroller",props:{documentId:{}},setup(t){const e=t,{plugin:n}=KE(),o=Q({layout:null,docId:null});Se([n,()=>e.documentId],([a,i],s,l)=>{if(!a||!i){o.value={layout:null,docId:null};return}const c=a.onScrollerData(i,u=>{o.value={layout:u,docId:i}});l(()=>{c(),o.value={layout:null,docId:null},a.clearLayoutReady(i)})},{immediate:!0});const r=P(()=>o.value.docId===e.documentId?o.value.layout:null);return Se([n,()=>e.documentId,r],([a,i,s])=>{!a||!i||!s||a.setLayoutReady(i)},{immediate:!0}),(a,i)=>r.value?(v(),C("div",xe({key:0,style:{width:`${r.value.totalWidth}px`,height:`${r.value.totalHeight}px`,position:"relative",boxSizing:"border-box",margin:"0 auto",...r.value.strategy===I(ro).Horizontal&&{display:"flex",flexDirection:"row"}}},a.$attrs),[m("div",{style:Z(r.value.strategy===I(ro).Horizontal?{width:`${r.value.startSpacing}px`,height:"100%",flexShrink:0}:{height:`${r.value.startSpacing}px`,width:"100%"})},null,4),m("div",{style:Z({gap:`${r.value.pageGap}px`,display:"flex",alignItems:"center",position:"relative",boxSizing:"border-box",...r.value.strategy===I(ro).Horizontal?{flexDirection:"row",minHeight:"100%"}:{flexDirection:"column",minWidth:"fit-content"}})},[(v(!0),C(pe,null,tt(r.value.items,s=>(v(),C("div",{key:s.pageNumbers[0],style:Z({display:"flex",justifyContent:"center",gap:`${r.value.pageGap}px`})},[(v(!0),C(pe,null,tt(s.pageLayouts,l=>(v(),C("div",{key:l.pageNumber,style:Z({width:`${l.rotatedWidth}px`,height:`${l.rotatedHeight}px`,position:"relative",zIndex:l.elevated?1:void 0})},[$e(a.$slots,"default",{page:l})],4))),128))],4))),128))],4),m("div",{style:Z(r.value.strategy===I(ro).Horizontal?{width:`${r.value.endSpacing}px`,height:"100%",flexShrink:0}:{height:`${r.value.endSpacing}px`,width:"100%"})},null,4)],16)):ae("",!0)}}),QE=()=>It(th.id),JE=()=>Nn(Qs.id),Yg=()=>It(Qs.id),eA=t=>{const{provides:e}=Yg(),n=Q(!1);return Se([e,()=>$t(t)],([o,r],a,i)=>{if(!o){n.value=!1;return}n.value=o.isGated(r);const s=o.onGateChange(l=>{l.documentId===r&&(n.value=l.isGated)});i(s)},{immediate:!0}),n};function tA(t){const{plugin:e}=JE(),n=Q(null);let o=null;const r=a=>{const i=e.value,s=n.value;if(!s||!i)return;try{i.registerViewport(a)}catch(d){console.error(`Failed to register viewport for document ${a}:`,d);return}const l=()=>{i.setViewportScrollMetrics(a,{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft})};s.addEventListener("scroll",l),new ResizeObserver(()=>{i.setViewportResizeMetrics(a,{width:s.offsetWidth,height:s.offsetHeight,clientWidth:s.clientWidth,clientHeight:s.clientHeight,scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,scrollWidth:s.scrollWidth,scrollHeight:s.scrollHeight,clientLeft:s.clientLeft,clientTop:s.clientTop})}).observe(s);const u=i.onScrollRequest(a,({x:d,y:p,behavior:h="auto"})=>{requestAnimationFrame(()=>{s.scrollTo({left:d,top:p,behavior:h})})});return()=>{i.unregisterViewport(a),s.removeEventListener("scroll",l),u()}};return Se([e,n,()=>$t(t)],([,,a])=>{o&&(o(),o=null),o=r(a)||null},{immediate:!0}),mr(()=>{o&&(o(),o=null)}),n}const nA=ie({__name:"viewport",props:{documentId:{}},setup(t){const e=t,n=Lm(),{provides:o}=Yg(),r=Q(0);Se(o,s=>{s&&(r.value=s.getViewportGap())},{immediate:!0});const a=eA(()=>e.documentId),i=tA(()=>e.documentId);return pa("viewport-element",i),(s,l)=>(v(),C("div",xe({ref_key:"viewportRef",ref:i},I(n),{style:{padding:`${r.value}px`,width:"100%",height:"100%",overflow:"auto"}}),[I(a)?ae("",!0):$e(s.$slots,"default",{key:0})],16))}}),qg=()=>It(Pg.id),oA=["src"],rA=ie({__name:"tile-img",props:{documentId:{},pageIndex:{},tile:{},scale:{},dpr:{default:()=>typeof window<"u"?window.devicePixelRatio:1}},setup(t){const e=t,{provides:n}=qg(),o=Q(),r=P(()=>e.scale/e.tile.srcScale);let a,i=null;return Se([()=>e.tile.id,()=>e.documentId,n],([s,l,c],[u,d])=>{if(!c)return;const p=c.forDocument(l);d!==void 0&&d!==l&&(o.value&&(URL.revokeObjectURL(o.value),o.value=void 0),i&&(i.abort({code:ve.Cancelled,message:"switching documents"}),i=null),a=void 0),!(a===s&&d===l)&&(i&&(i.abort({code:ve.Cancelled,message:"switching tiles"}),i=null),o.value&&(URL.revokeObjectURL(o.value),o.value=void 0),a=s,i=p.renderTile({pageIndex:e.pageIndex,tile:ke(e.tile),dpr:e.dpr}),i.wait(h=>{o.value=URL.createObjectURL(h),i=null},Yt))},{immediate:!0}),mr(()=>{i&&i.abort({code:ve.Cancelled,message:"unmounting"}),o.value&&URL.revokeObjectURL(o.value)}),(s,l)=>o.value?(v(),C("img",{key:0,src:o.value,style:Z({position:"absolute",left:`${t.tile.screenRect.origin.x*r.value}px`,top:`${t.tile.screenRect.origin.y*r.value}px`,width:`${t.tile.screenRect.size.width*r.value}px`,height:`${t.tile.screenRect.size.height*r.value}px`,display:"block"})},null,12,oA)):ae("",!0)}}),aA=ie({__name:"tiling-layer",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const e=t,{provides:n}=qg(),o=Dn(()=>e.documentId),r=Q([]),a=P(()=>{var i;return e.scale!==void 0?e.scale:((i=o.value)==null?void 0:i.scale)??1});return Se([n,()=>e.documentId,()=>e.pageIndex],([i,s,l],c,u)=>{if(!i){r.value=[];return}const d=i.onTileRendering(p=>{p.documentId===s&&(r.value=p.tiles[l]??[])});u(d)},{immediate:!0}),(i,s)=>(v(),C("div",zt(Qt(i.$attrs)),[(v(!0),C(pe,null,tt(r.value,l=>(v(),he(rA,{key:l.id,documentId:t.documentId,pageIndex:t.pageIndex,tile:l,scale:a.value},null,8,["documentId","pageIndex","tile","scale"]))),128))],16))}}),iA=()=>It(Th.id),sA=["src"],lA=ie({__name:"render-layer",props:{documentId:{},pageIndex:{},scale:{},dpr:{}},setup(t){const e=t,{provides:n}=iA(),o=Dn(()=>e.documentId),r=Q(null);let a=null,i=!1;const s=P(()=>o.value&&o.value.pageRefreshVersions[e.pageIndex]||0),l=P(()=>{var d;return e.scale!==void 0?e.scale:((d=o.value)==null?void 0:d.scale)??1}),c=P(()=>e.dpr!==void 0?e.dpr:window.devicePixelRatio);Se([()=>e.documentId,()=>e.pageIndex,l,c,n,s],([d,p,h,g,f],[F],y)=>{if(!f){r.value=null;return}F!==void 0&&F!==d&&(r.value=null,a&&i&&(URL.revokeObjectURL(a),a=null,i=!1)),a&&i&&F===d&&(URL.revokeObjectURL(a),a=null,i=!1);const _=f.forDocument(d).renderPage({pageIndex:p,options:{scaleFactor:h,dpr:g}});_.wait(E=>{const A=URL.createObjectURL(E);a=A,r.value=A,i=!1},Yt),y(()=>{a?i&&(URL.revokeObjectURL(a),a=null,i=!1):_.abort({code:ve.Cancelled,message:"canceled render task"})})},{immediate:!0});function u(){i=!0}return(d,p)=>r.value?(v(),C("img",xe({key:0,src:r.value,style:{width:"100%",height:"100%"},onLoad:u},d.$attrs),null,16,sA)):ae("",!0)}}),cA={annotation:!0,ink:!0,freeText:!0,redaction:!0,export:!0,thumbnail:!0,search:!0};function Kg(t){const e=Q("正在初始化 PDF 编辑器"),n=Q(!1),o=Q(!1),r=P(()=>{var i,s,l,c,u;return{...cA,...t.capabilities??{},annotation:t.readonly?!1:((i=t.capabilities)==null?void 0:i.annotation)??!0,ink:t.readonly?!1:((s=t.capabilities)==null?void 0:s.ink)??!0,freeText:t.readonly?!1:((l=t.capabilities)==null?void 0:l.freeText)??!0,redaction:t.readonly?!1:((c=t.capabilities)==null?void 0:c.redaction)??!0,export:((u=t.capabilities)==null?void 0:u.export)??!0}}),a=P(()=>t.source.type!=="url"&&r.value.export);return{capabilities:r,canSaveToService:a,statusMessage:e,leftDrawerOpen:n,rightDrawerOpen:o}}function nl(t,e){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="bigint")return t.toString();if(!(typeof t>"u"||typeof t=="function"||typeof t=="symbol")){if(t instanceof Date)return t.toISOString();if(t instanceof Blob||t instanceof ArrayBuffer||ArrayBuffer.isView(t))return t;if(Array.isArray(t))return t.map(n=>nl(n,e)).filter(n=>n!==void 0);if(typeof t=="object"){const n=t;if(e.has(n))return e.get(n);const o={};e.set(n,o);for(const[r,a]of Object.entries(n)){const i=nl(a,e);i!==void 0&&(o[r]=i)}return o}}}function Xg(t){return t.map(e=>nl(e,new WeakMap)).filter(e=>!!e)}const uA={class:"jit-pdf-editor"},dA={class:"jit-ribbon"},pA={class:"jit-ribbon__topbar"},hA={class:"jit-ribbon__document"},gA={class:"jit-toolbar__title"},fA={class:"jit-ribbon__meta"},mA={class:"jit-ribbon__badge"},PA={class:"jit-ribbon__page"},FA={class:"jit-ribbon__actions"},bA=["disabled"],yA=["disabled"],_A=["data-tooltip"],vA=["data-tooltip"],DA=["data-tooltip"],SA={class:"jit-ribbon__tabs",role:"tablist","aria-label":"编辑器功能区"},EA=["data-tooltip","aria-selected","onClick"],AA={class:"jit-ribbon__panels"},xA={key:0,class:"jit-ribbon__bar"},CA={class:"jit-ribbon__section jit-ribbon__section--view"},TA={class:"jit-ribbon__section-body"},MA={class:"jit-zoom-chip"},RA={class:"jit-ribbon__section jit-ribbon__section--history"},wA={class:"jit-ribbon__section-body"},OA=["disabled"],kA=["disabled"],IA={class:"jit-ribbon__section jit-ribbon__section--save"},GA={class:"jit-ribbon__section-body jit-ribbon__section-body--save"},LA=["disabled"],$A=["disabled"],NA={key:1,class:"jit-ribbon__bar jit-ribbon__bar--annotate"},jA={class:"jit-ribbon__section jit-ribbon__section--tools"},UA={class:"jit-ribbon__section-body jit-ribbon__section-body--tools"},BA=["aria-label","disabled","onClick"],zA={key:0,viewBox:"0 0 24 24","aria-hidden":"true"},WA={key:1,viewBox:"0 0 24 24","aria-hidden":"true"},HA={key:2,viewBox:"0 0 24 24","aria-hidden":"true"},VA={key:3,viewBox:"0 0 24 24","aria-hidden":"true"},YA={key:4,viewBox:"0 0 24 24","aria-hidden":"true"},qA={key:5,viewBox:"0 0 24 24","aria-hidden":"true"},KA={class:"jit-ribbon__section jit-ribbon__section--style"},XA={class:"jit-style-panel"},ZA={class:"jit-style-row"},QA={class:"jit-color-palette"},JA=["title","disabled","onClick"],ex={key:0,class:"jit-style-row"},tx={class:"jit-style-control"},nx={key:1,class:"jit-style-row"},ox={class:"jit-style-control"},rx={key:2,class:"jit-style-row"},ax={class:"jit-style-control"},ix={class:"jit-ribbon__section jit-ribbon__section--hint"},sx={class:"jit-ribbon__hint"},lx={class:"jit-ribbon__metric"},cx={class:"jit-ribbon__hint-chip"},ux=["disabled"],dx={key:2,class:"jit-ribbon__bar jit-ribbon__bar--view"},px={class:"jit-ribbon__section jit-ribbon__section--view"},hx={class:"jit-ribbon__section-body"},gx={class:"jit-zoom-chip"},fx={class:"jit-ribbon__section jit-ribbon__section--layout"},mx={class:"jit-ribbon__section-body"},Px=["aria-label"],Fx=["aria-label"],bx={class:"jit-ribbon__section jit-ribbon__section--summary"},yx={class:"jit-ribbon__summary"},_x={class:"jit-ribbon__metric"},vx={class:"jit-ribbon__metric"},Dx={key:3,class:"jit-ribbon__bar jit-ribbon__bar--review"},Sx={class:"jit-ribbon__section jit-ribbon__section--search-wide"},Ex={class:"jit-ribbon__section-body jit-ribbon__section-body--search"},Ax={class:"jit-search-box"},xx=["onKeydown"],Cx=["disabled"],Tx=["disabled"],Mx=["disabled"],Rx={class:"jit-ribbon__section jit-ribbon__section--save"},wx={class:"jit-ribbon__section-body jit-ribbon__section-body--save"},Ox=["disabled"],kx=["disabled"],Ix={class:"jit-ribbon__section jit-ribbon__section--summary"},Gx={class:"jit-ribbon__summary"},Lx={class:"jit-ribbon__metric"},$x={class:"jit-ribbon__metric"},Nx={class:"jit-sidebar__header"},jx={key:0,class:"jit-sidebar__headline"},Ux=["aria-label"],Bx={key:0,viewBox:"0 0 24 24","aria-hidden":"true"},zx={key:1,viewBox:"0 0 24 24","aria-hidden":"true"},Wx=["onClick"],Hx={class:"jit-thumbnail__paper"},Vx={class:"jit-thumbnail__meta"},Yx={class:"jit-thumbnail__label"},qx={key:0,class:"jit-thumbnail__current"},Kx={key:1,class:"jit-sidebar__empty"},Xx={class:"jit-canvas"},Zx={class:"jit-right-rail"},Qx=["aria-label"],Jx=["aria-label"],eC={class:"jit-inspector__header"},tC={class:"jit-inspector__body"},nC={key:0,class:"jit-note-editor"},oC={class:"jit-note-editor__header"},rC={class:"jit-note-editor__title-row"},aC=["disabled"],iC={class:"jit-note-editor__field"},sC={class:"jit-note-editor__footer"},lC={class:"jit-meta"},cC={class:"jit-panel-note"},uC={key:0},dC={key:1},pC={key:2},hC={class:"jit-annotation-panel__header"},gC={class:"jit-annotation-panel__header-actions"},fC=["disabled"],mC=["disabled"],PC={class:"jit-annotation-panel__body"},FC={class:"jit-annotation-toolbar"},bC={class:"jit-annotation-toolbar__search"},yC={class:"jit-annotation-toolbar__filter"},_C=["value"],vC={key:0,class:"jit-annotation-list"},DC={class:"jit-annotation-group__header"},SC=["aria-label","onClick"],EC={key:0},AC=["onClick"],xC={class:"jit-annotation-item__meta"},CC={class:"jit-annotation-item__chips"},TC={key:0,class:"jit-annotation-chip"},MC={key:1,class:"jit-annotation-chip"},RC={key:2,class:"jit-annotation-chip is-active"},wC={key:3,class:"jit-annotation-chip is-warning"},OC=["aria-label","onClick"],kC={key:1,class:"jit-annotation-panel__empty"},IC={key:0,class:"jit-state"},GC={key:1,class:"jit-state jit-state--error"},LC={key:3,class:"jit-state"},$C="https://jitword.com/jit-pdf.html",NC=ie({__name:"JitPdfEditorInner",props:{source:{},locale:{},theme:{},capabilities:{},service:{},readonly:{type:Boolean},activeDocumentId:{},pluginsReady:{type:Boolean},isInitializing:{type:Boolean}},emits:["ready","dirty-change","save-start","save-success","save-error","load-error"],setup(t,{emit:e}){const n=t,o=e,{capabilities:r,canSaveToService:a,leftDrawerOpen:i,rightDrawerOpen:s,statusMessage:l}=Kg(n),c=Q(""),u=Q(""),d=Q("浏览"),p=Q(!1),h=Q("home"),g=P(()=>n.source.type==="url"?`url:${n.source.url}`:`${n.source.type}:${n.source.fileId}`),f=P(()=>n.source.type==="url"?null:n.source.fileId),{provides:F}=Vp(),{provides:y}=Bn(),{provides:_}=QE(),E=Ps(()=>n.activeDocumentId??"");function A(x){const{provides:b}=zg(),z=Q(ai);return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=ai;return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=ai;return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function T(x){const{provides:b}=Vg(),z=Q(jr);return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=jr;return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=jr;return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function q(x){const{provides:b}=Bn(),z=Q(Za());return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=Za();return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=Za();return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function w(x){const{provides:b}=Dh(),z=Q(ri);return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value=ri;return}const ze=le.forDocument(U);try{z.value=ze.getState()}catch{z.value=ri;return}const Vn=ze.onStateChange(un=>{z.value=un});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function G(x){const{provides:b}=XE(),z=Q({currentPage:1,totalPages:1});return Se([b,x],([le,U],Ae,lt)=>{if(!le||!U){z.value={currentPage:1,totalPages:1};return}const ze=le.forDocument(U);z.value={currentPage:ze.getCurrentPage(),totalPages:ze.getTotalPages()};const Vn=le.onPageChange(un=>{un.documentId===U&&(z.value={currentPage:un.pageNumber,totalPages:un.totalPages})});lt(Vn)},{immediate:!0}),{state:z,provides:P(()=>{const le=x.value;return le&&b.value?b.value.forDocument(le):null})}}function W(x){const{provides:b}=Kp();return{provides:P(()=>{const z=x.value;return z&&b.value?b.value.forDocument(z):null})}}const J=P(()=>n.activeDocumentId??null),{provides:ue,state:ce}=A(J),{provides:ee,state:ge}=T(J),{provides:ye,state:Ee}=q(J),{provides:Te,state:oe}=w(J),{provides:He}=W(J),{provides:ft,state:Ve}=G(J),O=P(()=>Ee.value.hasPendingChanges||oe.value.pendingCount>0),H=P(()=>ce.value.currentZoomLevel||1),V=P(()=>Ve.value.currentPage||1),se=P(()=>Ve.value.totalPages||0),L=P(()=>{var x;return((x=_.value)==null?void 0:x.canUndo())??!1}),de=P(()=>{var x;return((x=_.value)==null?void 0:x.canRedo())??!1}),Pe=P(()=>ge.value.total||0),Re=P(()=>`${Math.round(H.value*100)}%`),vt=P(()=>!n.readonly&&E.value.canModifyAnnotations),Ut=P(()=>n.readonly?"只读":vt.value?"可批注":"受限"),D=P(()=>{var x;return[...((x=y.value)==null?void 0:x.getColorPresets())??[],"#1677FF","#0958D9","#18A058","#D03050","#FA8C16"].filter((b,z,le)=>le.indexOf(b)===z)}),S=Q(null),R=Q("#1677FF"),N=Q(.7),$=Q(6),j=Q(14),ne=Q(""),K=Q("idle");let Y=null;const B=P(()=>["highlight","textComment","freeText","ink"].includes(S.value??"")),be=P(()=>["highlight","textComment","freeText","ink"].includes(S.value??"")),re=P(()=>S.value==="ink"),Fe=P(()=>S.value==="freeText"),De=P(()=>Ee.value.selectedUids??[]),we=P(()=>De.value.length),Ge=P(()=>De.value[0]??null),Oe=P(()=>Ge.value?Ee.value.byUid[Ge.value]??null:null),k=P(()=>Ge.value?qe(Ge.value):null),_e=P(()=>{var x,b;return Oe.value?((b=(x=ye.value)==null?void 0:x.findToolForAnnotation(Oe.value.object))==null?void 0:b.id)??null:null}),Le=P(()=>_e.value==="textComment"),Ke=P(()=>{if(!Le.value||!Oe.value)return"";const{contents:x}=Oe.value.object;return typeof x=="string"?x:""}),Xe=P(()=>!Le.value||!Oe.value?null:{id:Ge.value,pageIndex:k.value,pageLabel:k.value===null?"-":String(k.value+1)}),Kt=P(()=>ne.value.length),dt=P(()=>{if(!Le.value)return"未选中便签";switch(K.value){case"editing":return"编辑中";case"saving":return"正在保存";case"saved":return"已保存";case"error":return"保存失败";default:return"可编辑"}}),Ze=P(()=>Nb(Ee.value)),Dt=P(()=>Ze.value.length),Ft=Q(""),gt=Q("all"),Gt=Q(!1),Ye=Q([]),nn=Q(!1);function xn(x){return Xg(x)}const Br=P(()=>xn(Object.values(Ee.value.byUid).filter(x=>x.commitState!=="deleted").map(x=>x.object))),lo={browse:"浏览",highlight:"高亮",textComment:"便签",freeText:"自由文本",ink:"涂鸦",redact:"脱敏"},si=[{id:"home",label:"开始",description:"页面浏览、缩放和保存"},{id:"annotate",label:"批注",description:"高亮、便签、文本框、涂鸦、脱敏"},{id:"view",label:"视图",description:"页面定位、目录和阅读布局"},{id:"review",label:"审阅",description:"搜索、结果导航和脱敏提交"}],rl=P(()=>[{id:"browse",label:"浏览",icon:"pointer",active:d.value==="浏览",disabled:!1,danger:!1,onClick:()=>Cn(null,"浏览")},{id:"highlight",label:"高亮",icon:"highlight",active:d.value==="高亮",disabled:!r.value.annotation,danger:!1,onClick:()=>Cn("highlight","高亮")},{id:"note",label:"便签",icon:"note",active:d.value==="便签",disabled:!r.value.annotation,danger:!1,onClick:()=>Cn("textComment","便签")},{id:"freeText",label:"文本框",icon:"text",active:d.value==="自由文本",disabled:!r.value.freeText,danger:!1,onClick:()=>Cn("freeText","自由文本")},{id:"ink",label:"涂鸦",icon:"draw",active:d.value==="涂鸦",disabled:!r.value.ink,danger:!1,onClick:()=>Cn("ink","涂鸦")},{id:"redact",label:"脱敏",icon:"redact",active:d.value==="脱敏",disabled:!r.value.redaction,danger:!0,onClick:()=>X()}]);let li="",co=!1,uo=0,Jo="",xo=null;function al(x){return/^(https?:\/\/|\/)/.test(x)}Se(O,x=>{o("dirty-change",{dirty:x})}),Se([g,()=>n.pluginsReady,F],async([x,b,z])=>{if(!b||!z||x===li)return;const le=++uo;co=!1,Jo="",d.value="浏览",S.value=null,l.value="正在分段加载文档",u.value="";try{const U=n.source.type==="url"?n.source.url:n.service.getFileStreamUrl(n.source.fileId),Ae=n.source.name??(n.source.type==="url"?"外部文档.pdf":(await n.service.getFileMeta(n.source.fileId)).name);if(le!==uo||(await z.closeAllDocuments().toPromise().catch(()=>[]),le!==uo))return;const ze=await z.openDocumentUrl({url:U,name:Ae,autoActivate:!0,...al(U)?{mode:"range-request"}:{}}).toPromise();if(le!==uo){await z.closeAllDocuments().toPromise().catch(()=>[]);return}li=x,co=!0,l.value="文档已就绪",o("ready",{documentId:ze.documentId})}catch(U){if(le!==uo)return;l.value="文档加载失败",o("load-error",{message:U instanceof Error?U.message:"文档加载失败",cause:U})}},{immediate:!0}),Se([f,()=>n.activeDocumentId,ye,()=>n.pluginsReady],async([x,b,z,le])=>{if(!x||!b||!z||!le||!co)return;const U=`${x}:${b}`;if(Jo!==U){Jo=U,nn.value=!0;try{const Ae=await n.service.loadAnnotations(x),lt=Object.keys(Ee.value.byUid).length>0;Ae.length&&!lt&&z.importAnnotations(Ae.map(ze=>({annotation:ze})))}catch(Ae){u.value=Ae instanceof Error?`批注恢复失败:${Ae.message}`:"批注恢复失败"}finally{window.setTimeout(()=>{nn.value=!1},0)}}},{immediate:!0}),Se([f,Br,()=>n.activeDocumentId],([x,b,z])=>{!x||!z||nn.value||!co||(xo!==null&&window.clearTimeout(xo),xo=window.setTimeout(async()=>{try{await n.service.saveAnnotations(x,b)}catch(le){u.value=le instanceof Error?`批注同步失败:${le.message}`:"批注同步失败"}},320))},{deep:!0});function Cn(x,b){var z,le;if((z=Te.value)==null||z.endRedact(),x&&!vt.value){S.value=null,d.value="浏览",u.value="当前文档未授予批注权限,已保持浏览模式。",l.value="当前文档禁止批注";return}(le=ye.value)==null||le.setActiveTool(x),queueMicrotask(()=>{var Ae,lt;const U=((lt=(Ae=ye.value)==null?void 0:Ae.getActiveTool())==null?void 0:lt.id)??Ee.value.activeToolId??null;if(x&&U!==x){S.value=U,d.value=lo[U??"browse"]??b,u.value="批注工具尚未真正激活,已保持当前浏览状态。",l.value="批注工具未成功激活";return}if(S.value=U,d.value=lo[U??"browse"]??b,u.value="",U){st(U),l.value=`已切换到${lo[U]??b}`;return}l.value="浏览模式"})}Se(()=>Ee.value.activeToolId,x=>{S.value==="redact"&&!x||(S.value=x,d.value=lo[x??"browse"]??"浏览",x&&st(x))}),Se([Le,Ke,Ge],([x,b])=>{if(Y!==null&&(window.clearTimeout(Y),Y=null),!x){ne.value="",K.value="idle";return}ne.value=b,K.value="idle",s.value=!0},{immediate:!0}),Se(()=>S.value,x=>{x==="textComment"&&(s.value=!0,u.value="点击页面插入便签,随后可在右侧填写说明内容。",l.value="便签模式")});function X(){var x,b;(x=Te.value)==null||x.enableRedact(),(b=ye.value)==null||b.setActiveTool(null),S.value="redact",d.value="脱敏",u.value="",l.value="脱敏模式"}function Ne(){p.value=!p.value}function Xt(){s.value=!s.value}function Pt(x){var b;(b=ft.value)==null||b.scrollToPage({pageNumber:x+1,behavior:"smooth",alignY:0}),l.value=`已定位到第 ${x+1} 页`}function st(x){var z,le;const b=(le=(z=y.value)==null?void 0:z.getTool(x))==null?void 0:le.defaults;b&&(R.value=String(b.strokeColor??b.fontColor??b.color??R.value),N.value=Number(b.opacity??N.value),$.value=Number(b.strokeWidth??$.value),j.value=Number(b.fontSize??j.value))}function qe(x){const b=Object.entries(Ee.value.pages).find(([,z])=>z.includes(x));return b?Number(b[0]):null}function on(){var z;if(!((z=Xe.value)!=null&&z.id)||Xe.value.pageIndex===null||!ye.value)return;const x=ne.value.replace(/\u00A0/g," "),b=Ke.value.replace(/\u00A0/g," ");if(x===b){K.value=K.value==="error"?"error":"saved";return}K.value="saving";try{ye.value.updateAnnotation(Xe.value.pageIndex,Xe.value.id,{contents:x}),K.value="saved",l.value="便签内容已更新",u.value="便签内容已自动保存。"}catch(le){K.value="error",u.value=le instanceof Error?`便签保存失败:${le.message}`:"便签保存失败"}}function Rt(){Y!==null&&window.clearTimeout(Y),Y=window.setTimeout(()=>{Y=null,on()},320)}function er(){Le.value&&(K.value="editing",Rt())}function ci(){Le.value&&(Y!==null&&(window.clearTimeout(Y),Y=null),on())}function Zt(x){const b=Object.entries(Ee.value.byUid).find(([z,le])=>z===x.object.id||le===x||le.object===x.object);return(b==null?void 0:b[0])??x.object.id}function Co(x){const b=new Map;for(const z of x){const le=[z.annotation,...z.groupMembers??[],...z.replies];for(const U of le){const Ae=Zt(U),lt=qe(Ae)??z.page;lt!==null&&b.set(Ae,{id:Ae,pageIndex:lt})}}return[...b.values()]}function zr(x){var z;const b=Zt(x.annotation);Pt(x.page),(z=ye.value)==null||z.selectAnnotation(x.page,b),u.value=`已定位到第 ${x.page+1} 页的${ll(x)}。`}function il(){if(!ye.value||!we.value){u.value="当前没有选中的批注。";return}const x=De.value.map(b=>{const z=qe(b);return z===null?null:{id:b,pageIndex:z}}).filter(b=>b!==null);if(!x.length){u.value="当前选中的批注暂时无法删除。";return}ye.value.deleteAnnotations(x),u.value=`已删除 ${x.length} 个选中批注。`,l.value=`已删除 ${x.length} 个批注`}function iT(x){if(!ye.value)return;const b=Co([x]);if(!b.length){u.value="当前批注暂时无法删除。";return}ye.value.deleteAnnotations(b),u.value=`已删除第 ${x.page+1} 页的${ll(x)}。`,l.value="批注已删除"}function sl(){Gt.value=!Gt.value}function sT(x){Ye.value=Ye.value.includes(x)?Ye.value.filter(b=>b!==x):[...Ye.value,x]}function lT(){if(df.value){const x=new Set(Wr.value);Ye.value=Ye.value.filter(b=>!x.has(b));return}Ye.value=[...new Set([...Ye.value,...Wr.value])]}function cT(){if(!ye.value||!di.value){u.value="请先在批注管理面板中勾选要删除的批注。";return}const x=Ye.value.map(b=>{const z=qe(b);return z===null?null:{id:b,pageIndex:z}}).filter(b=>b!==null);if(!x.length){u.value="当前筛选结果里没有可删除的批注。";return}ye.value.deleteAnnotations(x),Ye.value=[],u.value=`已批量删除 ${x.length} 个批注。`,l.value=`已删除 ${x.length} 个批注`}function ll(x){var z,le;const b=(le=(z=ye.value)==null?void 0:z.findToolForAnnotation(x.annotation.object))==null?void 0:le.id;return lo[b??""]??"批注"}function uT(x){const b=x.annotation.object.contents,z=typeof b=="string"?b.trim():"";if(z)return z;const le=x.replies.map(U=>U.object.contents).find(U=>typeof U=="string"&&U.trim().length>0);return le?le.trim():`${ll(x)} · 第 ${x.page+1} 页`}const ui=P(()=>Ze.value.map(x=>{var Ae,lt,ze;const b=Zt(x.annotation),z=((lt=(Ae=ye.value)==null?void 0:Ae.findToolForAnnotation(x.annotation.object))==null?void 0:lt.id)??"annotation",le=lo[z]??"批注",U=uT(x);return{id:b,page:x.page,kindId:z,kindLabel:le,summary:U,repliesCount:x.replies.length,groupCount:(((ze=x.groupMembers)==null?void 0:ze.length)??0)+1,isCanvasSelected:De.value.includes(b),entry:x,searchText:`${le} ${U} 第 ${x.page+1} 页`.toLowerCase()}})),lf=P(()=>{const x=new Map;for(const b of ui.value){const z=x.get(b.kindId);if(z){z.count+=1;continue}x.set(b.kindId,{id:b.kindId,label:b.kindLabel,count:1})}return[{id:"all",label:"全部类型",count:ui.value.length},...[...x.values()].sort((b,z)=>b.label.localeCompare(z.label,"zh-CN"))]}),cf=P(()=>{const x=Ft.value.trim().toLowerCase();return ui.value.filter(b=>{const z=gt.value==="all"||b.kindId===gt.value,le=!x||b.searchText.includes(x);return z&&le})}),uf=P(()=>{const x=new Map;for(const b of cf.value){const z=x.get(b.page)??[];z.push(b),x.set(b.page,z)}return[...x.entries()].sort(([b],[z])=>b-z).map(([b,z])=>({page:b,items:z}))}),Wr=P(()=>cf.value.map(x=>x.id)),di=P(()=>Ye.value.length),df=P(()=>Wr.value.length>0&&Wr.value.every(x=>Ye.value.includes(x)));Se(ui,x=>{const b=new Set(x.map(z=>z.id));Ye.value=Ye.value.filter(z=>b.has(z))}),Se(lf,x=>{x.some(b=>b.id===gt.value)||(gt.value="all")});function pf(x){const b=x.target;b&&(b instanceof HTMLInputElement||b instanceof HTMLTextAreaElement||b.isContentEditable)||x.key!=="Backspace"&&x.key!=="Delete"||we.value&&(x.preventDefault(),il())}function tr(x){var b;!S.value||S.value==="redact"||(b=y.value)==null||b.setToolDefaults(S.value,x)}function dT(x){if(R.value=x,S.value==="freeText"){tr({fontColor:x});return}if(S.value==="ink"){tr({strokeColor:x,color:x});return}tr({strokeColor:x})}function pT(){tr({opacity:N.value})}function hT(){S.value==="ink"&&tr({strokeWidth:$.value})}function gT(){S.value==="freeText"&&tr({fontSize:j.value})}async function hf(){const x=c.value.trim();!x||!ee.value||(l.value="正在检索全文",await ee.value.searchAllPages(x).toPromise(),ee.value.setShowAllResults(!0),ge.value.total>0&&ee.value.goToResult(0),l.value=ge.value.total?`已定位 ${ge.value.total} 处结果`:"未找到匹配内容")}function fT(){var x;(x=ue.value)==null||x.zoomIn()}function mT(){var x;(x=ue.value)==null||x.zoomOut()}function gf(){var x;(x=ue.value)==null||x.requestZoom(Mt.FitWidth)}function ff(){var x;(x=ue.value)==null||x.requestZoom(Mt.FitPage)}function PT(){var x;(x=ue.value)==null||x.requestZoom(Mt.Automatic)}function mf(){var x;(x=ft.value)==null||x.scrollToPreviousPage("smooth")}function Pf(){var x;(x=ft.value)==null||x.scrollToNextPage("smooth")}function Ff(){var x;(x=_.value)==null||x.undo()}function bf(){var x;(x=_.value)==null||x.redo()}async function cl(x="manual-save"){if(!n.activeDocumentId||!He.value||!a.value){u.value="当前文档来源不支持另存副本";return}o("save-start");try{const b=await He.value.saveAsCopy().toPromise(),z=await n.service.saveCopy({fileId:f.value??n.activeDocumentId,fileName:n.source.name??"document.pdf",content:new Blob([b],{type:"application/pdf"}),reason:x});u.value=`已保存到 ${z.relativePath}`,o("save-success",z)}catch(b){const z=b instanceof Error?b.message:"保存失败";u.value=z,o("save-error",{message:z,cause:b})}}async function yf(){if(!Te.value||!oe.value.pendingCount){u.value="当前没有待提交的脱敏内容";return}if(!window.confirm("脱敏提交后将影响导出副本内容,是否继续并另存新副本?"))return;if(!await Te.value.commitAllPending().toPromise()){u.value="脱敏提交未完成";return}await cl("redaction-save")}const FT=P(()=>n.readonly?"只读状态":Le.value?"便签编辑":oe.value.pendingCount>0?"待提交脱敏":"编辑状态");return Lo(()=>{window.addEventListener("keydown",pf)}),mr(()=>{window.removeEventListener("keydown",pf),xo!==null&&window.clearTimeout(xo),Y!==null&&window.clearTimeout(Y)}),Se(()=>n.activeDocumentId,x=>{x&&co&&(l.value="文档已就绪")}),(x,b)=>{var z,le;return v(),C("div",uA,[m("header",dA,[m("div",pA,[m("div",hA,[m("button",{class:"jit-toolbar__toggle",onClick:b[0]||(b[0]=U=>i.value=!I(i))},"目录"),m("div",gA,[m("strong",null,fe(t.source.name??"未命名文档"),1),m("span",null,fe(I(l)),1)])]),m("div",fA,[m("span",mA,fe(((z=si.find(U=>U.id===h.value))==null?void 0:z.label)??"开始"),1),m("span",PA,"第 "+fe(V.value)+" 页 / 共 "+fe(se.value||"-")+" 页",1)]),m("div",FA,[m("button",{class:"jit-ribbon__action","data-tooltip":"撤销最近一次操作",disabled:!L.value,onClick:Ff},"撤销",8,bA),m("button",{class:"jit-ribbon__action","data-tooltip":"重做刚刚撤销的内容",disabled:!de.value,onClick:bf},"重做",8,yA),m("button",{class:"jit-ribbon__action","data-tooltip":p.value?"展开左侧缩略图导航":"收起左侧缩略图导航",onClick:Ne},fe(p.value?"展开目录":"收起目录"),9,_A),m("button",{class:"jit-ribbon__action","data-tooltip":Gt.value?"隐藏批注管理抽屉":"显示批注管理抽屉",onClick:sl},fe(Gt.value?"隐藏批注":"显示批注"),9,vA),m("button",{class:"jit-ribbon__action","data-tooltip":I(s)?"隐藏悬浮属性面板":"显示悬浮属性面板",onClick:Xt},fe(I(s)?"隐藏属性":"显示属性"),9,DA),m("button",{class:"jit-toolbar__toggle",onClick:Xt},"状态")])]),m("div",SA,[(v(),C(pe,null,tt(si,U=>m("button",{key:U.id,class:St(["jit-ribbon__tab",{"is-active":h.value===U.id}]),"data-tooltip":U.description,"aria-selected":h.value===U.id,onClick:Ae=>h.value=U.id},fe(U.label),11,EA)),64))]),m("div",AA,[h.value==="home"?(v(),C("div",xA,[m("section",{class:"jit-ribbon__section jit-ribbon__section--nav"},[m("div",{class:"jit-ribbon__section-body"},[m("button",{class:"jit-icon-button","aria-label":"上一页",onClick:mf},[...b[12]||(b[12]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 18l-6-6 6-6"})],-1),m("span",null,"上一页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"下一页",onClick:Pf},[...b[13]||(b[13]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 6l6 6-6 6"})],-1),m("span",null,"下一页",-1)])])]),b[14]||(b[14]=m("div",{class:"jit-ribbon__section-label"},"页面浏览",-1))]),m("section",CA,[m("div",TA,[m("button",{class:"jit-icon-button","aria-label":"缩小",onClick:mT},[...b[15]||(b[15]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 12h8"}),m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1),m("span",null,"缩小",-1)])]),m("button",{class:"jit-icon-button","aria-label":"放大",onClick:fT},[...b[16]||(b[16]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M10 7v6"></path><path d="M7 10h6"></path><path d="M14.5 14.5L20 20"></path><circle cx="10" cy="10" r="6"></circle></svg><span>放大</span>',2)])]),m("button",{class:"jit-icon-button","aria-label":"适应整页",onClick:ff},[...b[17]||(b[17]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("rect",{x:"7",y:"4",width:"10",height:"16",rx:"1.5"})],-1),m("span",null,"整页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"适应页宽",onClick:gf},[...b[18]||(b[18]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 8V5h3"></path><path d="M20 8V5h-3"></path><path d="M4 16v3h3"></path><path d="M20 16v3h-3"></path><path d="M8 12h8"></path></svg><span>页宽</span>',2)])]),m("div",MA,fe(Re.value),1)]),b[19]||(b[19]=m("div",{class:"jit-ribbon__section-label"},"缩放与阅读",-1))]),m("section",RA,[m("div",wA,[m("button",{class:"jit-icon-button","aria-label":"撤销",disabled:!L.value,onClick:Ff},[...b[20]||(b[20]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 7H5v4"}),m("path",{d:"M5 11c2-3 5-5 9-5 3 0 6 2 7 5"})],-1),m("span",null,"撤销",-1)])],8,OA),m("button",{class:"jit-icon-button","aria-label":"重做",disabled:!de.value,onClick:bf},[...b[21]||(b[21]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 7h4v4"}),m("path",{d:"M19 11c-2-3-5-5-9-5-3 0-6 2-7 5"})],-1),m("span",null,"重做",-1)])],8,kA)]),b[22]||(b[22]=m("div",{class:"jit-ribbon__section-label"},"历史记录",-1))]),m("section",IA,[m("div",GA,[m("button",{class:"jit-icon-button jit-icon-button--primary","aria-label":"另存副本",disabled:!I(a),onClick:b[1]||(b[1]=U=>cl())},[...b[23]||(b[23]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 4h9l3 3v13H6z"}),m("path",{d:"M9 4v5h6"}),m("path",{d:"M9 16h6"})],-1),m("span",null,"另存副本",-1)])],8,LA),m("button",{class:"jit-icon-button is-danger","aria-label":"提交脱敏并导出",disabled:!I(r).redaction||!I(oe).pendingCount,onClick:yf},[...b[24]||(b[24]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg><span>提交脱敏</span>',2)])],8,$A)]),b[25]||(b[25]=m("div",{class:"jit-ribbon__section-label"},"保存导出",-1))])])):h.value==="annotate"?(v(),C("div",NA,[m("section",jA,[m("div",UA,[(v(!0),C(pe,null,tt(rl.value,U=>(v(),C("button",{key:U.id,class:St(["jit-icon-button jit-icon-button--tool",{"is-active":U.active,"is-danger":U.danger}]),"aria-label":U.label,disabled:U.disabled,onClick:U.onClick},[U.icon==="pointer"?(v(),C("svg",zA,[...b[26]||(b[26]=[m("path",{d:"M6 4l10 8-5 1 2 5-2 1-2-5-3 3z"},null,-1)])])):U.icon==="highlight"?(v(),C("svg",WA,[...b[27]||(b[27]=[m("path",{d:"M6 15l5-5 4 4-5 5H6z"},null,-1),m("path",{d:"M13 8l2-2 3 3-2 2z"},null,-1),m("path",{d:"M5 19h9"},null,-1)])])):U.icon==="note"?(v(),C("svg",HA,[...b[28]||(b[28]=[m("path",{d:"M7 4h10v12H7z"},null,-1),m("path",{d:"M9 8h6"},null,-1),m("path",{d:"M9 12h4"},null,-1),m("path",{d:"M7 16h3"},null,-1)])])):U.icon==="text"?(v(),C("svg",VA,[...b[29]||(b[29]=[m("path",{d:"M6 6h12"},null,-1),m("path",{d:"M12 6v12"},null,-1),m("path",{d:"M8 18h8"},null,-1)])])):U.icon==="draw"?(v(),C("svg",YA,[...b[30]||(b[30]=[m("path",{d:"M4 16c2-4 5-6 8-7 2-1 4 0 5 2 1 2 0 4-2 5-3 2-7 2-11 0z"},null,-1),m("path",{d:"M14 6l2-2 4 4-2 2z"},null,-1)])])):(v(),C("svg",qA,[...b[31]||(b[31]=[Zn('<path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M7 11h10"></path><path d="M7 15h10"></path><path d="M7 19h10"></path>',5)])])),m("span",null,fe(U.label),1)],10,BA))),128))]),b[32]||(b[32]=m("div",{class:"jit-ribbon__section-label"},"批注工具",-1))]),m("section",KA,[m("div",XA,[m("div",ZA,[b[33]||(b[33]=m("span",{class:"jit-style-label"},"颜色",-1)),m("div",QA,[(v(!0),C(pe,null,tt(D.value,U=>(v(),C("button",{key:U,class:St(["jit-color-swatch",{"is-active":R.value===U}]),style:Z({background:U}),title:U,disabled:!B.value,onClick:Ae=>dT(U)},null,14,JA))),128))])]),re.value?(v(),C("div",ex,[b[34]||(b[34]=m("label",{class:"jit-style-label",for:"jit-stroke-width"},"线条粗细",-1)),m("div",tx,[fo(m("input",{id:"jit-stroke-width","onUpdate:modelValue":b[2]||(b[2]=U=>$.value=U),type:"range",min:"2",max:"20",step:"1",onChange:hT},null,544),[[Bo,$.value,void 0,{number:!0}]]),m("span",null,fe($.value),1)])])):ae("",!0),Fe.value?(v(),C("div",nx,[b[35]||(b[35]=m("label",{class:"jit-style-label",for:"jit-font-size"},"字号",-1)),m("div",ox,[fo(m("input",{id:"jit-font-size","onUpdate:modelValue":b[3]||(b[3]=U=>j.value=U),type:"range",min:"10",max:"32",step:"1",onChange:gT},null,544),[[Bo,j.value,void 0,{number:!0}]]),m("span",null,fe(j.value),1)])])):ae("",!0),be.value?(v(),C("div",rx,[b[36]||(b[36]=m("label",{class:"jit-style-label",for:"jit-opacity"},"透明度",-1)),m("div",ax,[fo(m("input",{id:"jit-opacity","onUpdate:modelValue":b[4]||(b[4]=U=>N.value=U),type:"range",min:"0.2",max:"1",step:"0.1",onChange:pT},null,544),[[Bo,N.value,void 0,{number:!0}]]),m("span",null,fe(Math.round(N.value*100))+"%",1)])])):ae("",!0)]),b[37]||(b[37]=m("div",{class:"jit-ribbon__section-label"},"样式属性",-1))]),m("section",ix,[m("div",sx,[m("div",lx,[b[38]||(b[38]=m("em",null,"当前工具",-1)),m("strong",null,fe(d.value),1)]),m("span",{class:St(["jit-ribbon__hint-chip",{"is-danger":Ut.value==="受限"}])},fe(Ut.value),3),m("span",cx,"待脱敏 "+fe(I(oe).pendingCount)+" 处",1),m("button",{class:"jit-ribbon__hint-action",disabled:!we.value,onClick:il}," 删除选中 "+fe(we.value||""),9,ux)]),b[39]||(b[39]=m("div",{class:"jit-ribbon__section-label"},"使用提示",-1))])])):h.value==="view"?(v(),C("div",dx,[m("section",{class:"jit-ribbon__section jit-ribbon__section--nav"},[m("div",{class:"jit-ribbon__section-body"},[m("button",{class:"jit-icon-button","aria-label":"上一页",onClick:mf},[...b[40]||(b[40]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 18l-6-6 6-6"})],-1),m("span",null,"上一页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"下一页",onClick:Pf},[...b[41]||(b[41]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 6l6 6-6 6"})],-1),m("span",null,"下一页",-1)])])]),b[42]||(b[42]=m("div",{class:"jit-ribbon__section-label"},"翻页",-1))]),m("section",px,[m("div",hx,[m("button",{class:"jit-icon-button","aria-label":"适应整页",onClick:ff},[...b[43]||(b[43]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("rect",{x:"7",y:"4",width:"10",height:"16",rx:"1.5"})],-1),m("span",null,"整页",-1)])]),m("button",{class:"jit-icon-button","aria-label":"适应页宽",onClick:gf},[...b[44]||(b[44]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 8V5h3"></path><path d="M20 8V5h-3"></path><path d="M4 16v3h3"></path><path d="M20 16v3h-3"></path><path d="M8 12h8"></path></svg><span>页宽</span>',2)])]),m("button",{class:"jit-icon-button","aria-label":"自动缩放",onClick:PT},[...b[45]||(b[45]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("circle",{cx:"12",cy:"12",r:"8"}),m("path",{d:"M12 8v4l3 2"})],-1),m("span",null,"自动",-1)])]),m("div",gx,fe(Re.value),1)]),b[46]||(b[46]=m("div",{class:"jit-ribbon__section-label"},"阅读模式",-1))]),m("section",fx,[m("div",mx,[m("button",{class:"jit-icon-button","aria-label":p.value?"展开缩略图":"收起缩略图",onClick:Ne},[b[47]||(b[47]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M4 6h16"}),m("path",{d:"M4 12h10"}),m("path",{d:"M4 18h16"})],-1)),m("span",null,fe(p.value?"展开目录":"收起目录"),1)],8,Px),m("button",{class:"jit-icon-button","aria-label":I(s)?"隐藏属性面板":"显示属性面板",onClick:Xt},[b[48]||(b[48]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 5h14v14H5z"}),m("path",{d:"M12 5v14"})],-1)),m("span",null,fe(I(s)?"隐藏侧栏":"显示侧栏"),1)],8,Fx)]),b[49]||(b[49]=m("div",{class:"jit-ribbon__section-label"},"界面布局",-1))]),m("section",bx,[m("div",yx,[m("div",_x,[b[50]||(b[50]=m("em",null,"工具",-1)),m("strong",null,fe(d.value),1)]),m("div",vx,[b[51]||(b[51]=m("em",null,"搜索",-1)),m("strong",null,fe(Pe.value)+" 处",1)])]),b[52]||(b[52]=m("div",{class:"jit-ribbon__section-label"},"阅读摘要",-1))])])):(v(),C("div",Dx,[m("section",Sx,[m("div",Ex,[m("div",Ax,[b[53]||(b[53]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1)),fo(m("input",{"onUpdate:modelValue":b[5]||(b[5]=U=>c.value=U),placeholder:"搜索全文",onKeydown:qP(qi(hf,["prevent"]),["enter"])},null,40,xx),[[Bo,c.value]])]),m("button",{class:"jit-icon-button","aria-label":"执行搜索",disabled:!I(r).search,onClick:hf},[...b[54]||(b[54]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1),m("span",null,"查找",-1)])],8,Cx),m("button",{class:"jit-icon-button","aria-label":"上一个结果",disabled:!I(r).search||!Pe.value,onClick:b[6]||(b[6]=U=>{var Ae;return(Ae=I(ee))==null?void 0:Ae.previousResult()})},[...b[55]||(b[55]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M15 6l-6 6 6 6"})],-1),m("span",null,"上一个",-1)])],8,Tx),m("button",{class:"jit-icon-button","aria-label":"下一个结果",disabled:!I(r).search||!Pe.value,onClick:b[7]||(b[7]=U=>{var Ae;return(Ae=I(ee))==null?void 0:Ae.nextResult()})},[...b[56]||(b[56]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M9 6l6 6-6 6"})],-1),m("span",null,"下一个",-1)])],8,Mx)]),b[57]||(b[57]=m("div",{class:"jit-ribbon__section-label"},"全文检索",-1))]),m("section",Rx,[m("div",wx,[m("button",{class:"jit-icon-button jit-icon-button--primary","aria-label":"另存副本",disabled:!I(a),onClick:b[8]||(b[8]=U=>cl())},[...b[58]||(b[58]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 4h9l3 3v13H6z"}),m("path",{d:"M9 4v5h6"}),m("path",{d:"M9 16h6"})],-1),m("span",null,"另存副本",-1)])],8,Ox),m("button",{class:"jit-icon-button is-danger","aria-label":"提交脱敏并导出",disabled:!I(r).redaction||!I(oe).pendingCount,onClick:yf},[...b[59]||(b[59]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg><span>提交脱敏</span>',2)])],8,kx)]),b[60]||(b[60]=m("div",{class:"jit-ribbon__section-label"},"审阅输出",-1))]),m("section",Ix,[m("div",Gx,[m("div",Lx,[b[61]||(b[61]=m("em",null,"搜索",-1)),m("strong",null,fe(Pe.value)+" 处",1)]),m("div",$x,[b[62]||(b[62]=m("em",null,"修改",-1)),m("strong",null,fe(O.value?"待保存":"已同步"),1)])]),b[63]||(b[63]=m("div",{class:"jit-ribbon__section-label"},"当前状态",-1))])]))])]),m("div",{class:St(["jit-layout",{"is-left-collapsed":p.value}])},[m("aside",{class:St(["jit-sidebar jit-sidebar--left",{"is-open":I(i),"is-collapsed":p.value}])},[m("div",Nx,[p.value?ae("",!0):(v(),C("div",jx,[b[64]||(b[64]=m("strong",null,"缩略图",-1)),m("span",null,"第 "+fe(V.value)+" / "+fe(se.value||"-")+" 页",1)])),m("button",{class:"jit-sidebar__collapse","aria-label":p.value?"展开缩略图":"收起缩略图",onClick:Ne},[p.value?(v(),C("svg",Bx,[...b[65]||(b[65]=[m("path",{d:"M9 6l6 6-6 6"},null,-1)])])):(v(),C("svg",zx,[...b[66]||(b[66]=[m("path",{d:"M15 6l-6 6 6 6"},null,-1)])]))],8,Ux)]),!p.value&&I(r).thumbnail&&t.activeDocumentId?(v(),he(I(HE),{key:0,class:"jit-thumbnails","document-id":t.activeDocumentId},{default:We(({meta:U})=>[m("button",{class:St(["jit-thumbnail",{"is-active":V.value===U.pageIndex+1}]),style:Z({top:`${U.top}px`,height:`${U.wrapperHeight}px`}),onClick:Ae=>Pt(U.pageIndex)},[m("div",Hx,[je(I(YE),{"document-id":t.activeDocumentId,meta:U,class:"jit-thumbnail__image"},null,8,["document-id","meta"])]),m("div",Vx,[m("span",Yx,"第 "+fe(U.pageIndex+1)+" 页",1),V.value===U.pageIndex+1?(v(),C("span",qx,"当前")):ae("",!0)])],14,Wx)]),_:1},8,["document-id"])):p.value?ae("",!0):(v(),C("p",Kx,"缩略图已关闭"))],2),m("main",Xx,[m("div",Zx,[m("button",{class:"jit-annotation-drawer-toggle","aria-label":Gt.value?"隐藏批注管理抽屉":"显示批注管理抽屉",onClick:sl},[...b[67]||(b[67]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 6h14"}),m("path",{d:"M5 12h14"}),m("path",{d:"M5 18h10"})],-1)])],8,Qx),m("button",{class:"jit-inspector-toggle","aria-label":I(s)?"隐藏属性面板":"显示属性面板",onClick:Xt},[...b[68]||(b[68]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M5 5h14v14H5z"}),m("path",{d:"M12 5v14"})],-1)])],8,Jx),m("aside",{class:St(["jit-inspector",{"is-open":I(s)}])},[m("div",eC,[m("div",null,[m("strong",null,fe(FT.value),1),m("span",null,fe(d.value)+" · "+fe(Math.round(H.value*100))+"%",1)]),m("button",{class:"jit-inspector__close","aria-label":"收起属性面板",onClick:Xt},[...b[69]||(b[69]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 6l12 12"}),m("path",{d:"M18 6L6 18"})],-1)])])]),m("div",tC,[Le.value?(v(),C("section",nC,[m("div",oC,[m("div",null,[m("div",rC,[b[71]||(b[71]=m("strong",null,"便签内容",-1)),m("button",{class:"jit-note-editor__delete",disabled:!we.value,"aria-label":"删除便签",onClick:il},[...b[70]||(b[70]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg>',1)])],8,aC)]),m("span",null,"第 "+fe((le=Xe.value)==null?void 0:le.pageLabel)+" 页 · "+fe(dt.value),1)])]),m("label",iC,[b[72]||(b[72]=m("span",null,"说明内容",-1)),fo(m("textarea",{"onUpdate:modelValue":b[9]||(b[9]=U=>ne.value=U),placeholder:"为这条便签补充说明、结论或处理意见",onInput:er,onBlur:ci},null,544),[[Bo,ne.value]])]),m("div",sC,[b[73]||(b[73]=m("span",null,"便签会在停止输入后自动保存",-1)),m("strong",null,fe(Kt.value)+" 字",1)])])):ae("",!0),m("dl",lC,[m("div",null,[b[74]||(b[74]=m("dt",null,"当前工具",-1)),m("dd",null,fe(d.value),1)]),m("div",null,[b[75]||(b[75]=m("dt",null,"批注权限",-1)),m("dd",null,fe(Ut.value),1)]),m("div",null,[b[76]||(b[76]=m("dt",null,"缩放",-1)),m("dd",null,fe(Math.round(H.value*100))+"%",1)]),m("div",null,[b[77]||(b[77]=m("dt",null,"搜索结果",-1)),m("dd",null,fe(Pe.value)+" 处",1)]),m("div",null,[b[78]||(b[78]=m("dt",null,"待提交脱敏",-1)),m("dd",null,fe(I(oe).pendingCount)+" 处",1)]),m("div",null,[b[79]||(b[79]=m("dt",null,"待保存修改",-1)),m("dd",null,fe(O.value?"是":"否"),1)]),b[80]||(b[80]=m("div",null,[m("dt",null,"保存策略"),m("dd",null,"仅另存新副本")],-1))]),m("div",cC,[b[81]||(b[81]=m("p",null,"属性面板已改成悬浮检查器,需要时展开,不占主阅读空间。",-1)),Le.value?(v(),C("p",uC,"当前便签已接入内容编辑器,支持随写随存,适合记录审核意见和处理说明。")):(v(),C("p",dC,"高亮类工具需要先框选文本;涂鸦和文本框工具可以直接在画布中绘制或点击创建。")),u.value?(v(),C("p",pC,fe(u.value),1)):ae("",!0)])])],2)]),m("aside",{class:St(["jit-annotation-drawer",{"is-open":Gt.value}])},[m("div",hC,[m("div",null,[b[82]||(b[82]=m("strong",null,"批注管理",-1)),m("span",null,fe(Dt.value)+" 个批注,"+fe(di.value)+" 个待批量操作",1)]),m("div",gC,[m("button",{class:"jit-annotation-panel__action jit-annotation-panel__action--secondary",disabled:!Wr.value.length,onClick:lT},fe(df.value?"清空当前结果":"全选当前结果"),9,fC),m("button",{class:"jit-annotation-panel__action",disabled:!di.value,onClick:cT}," 批量删除 "+fe(di.value||""),9,mC),m("button",{class:"jit-annotation-panel__close","aria-label":"关闭批注管理抽屉",onClick:sl},[...b[83]||(b[83]=[m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M6 6l12 12"}),m("path",{d:"M18 6L6 18"})],-1)])])])]),m("div",PC,[m("div",FC,[m("label",bC,[b[84]||(b[84]=m("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},[m("path",{d:"M14.5 14.5L20 20"}),m("circle",{cx:"10",cy:"10",r:"6"})],-1)),fo(m("input",{"onUpdate:modelValue":b[10]||(b[10]=U=>Ft.value=U),placeholder:"搜索批注内容、页码或类型"},null,512),[[Bo,Ft.value]])]),m("label",yC,[b[85]||(b[85]=m("span",null,"类型",-1)),fo(m("select",{"onUpdate:modelValue":b[11]||(b[11]=U=>gt.value=U)},[(v(!0),C(pe,null,tt(lf.value,U=>(v(),C("option",{key:U.id,value:U.id},fe(U.label)+"("+fe(U.count)+") ",9,_C))),128))],512),[[WP,gt.value]])])]),uf.value.length?(v(),C("div",vC,[(v(!0),C(pe,null,tt(uf.value,U=>(v(),C("section",{key:U.page,class:"jit-annotation-group"},[m("header",DC,[m("strong",null,"第 "+fe(U.page+1)+" 页",1),m("span",null,fe(U.items.length)+" 条批注",1)]),(v(!0),C(pe,null,tt(U.items,Ae=>(v(),C("article",{key:Ae.id,class:St(["jit-annotation-item",{"is-selected":Ae.isCanvasSelected,"is-batch-selected":Ye.value.includes(Ae.id)}])},[m("button",{class:"jit-annotation-item__selector","aria-label":Ye.value.includes(Ae.id)?"取消批量选择":"加入批量选择",onClick:qi(lt=>sT(Ae.id),["stop"])},[Ye.value.includes(Ae.id)?(v(),C("span",EC)):ae("",!0)],8,SC),m("button",{class:"jit-annotation-item__main",onClick:lt=>zr(Ae.entry)},[m("div",xC,[m("strong",null,fe(Ae.kindLabel),1),m("span",null,"第 "+fe(Ae.page+1)+" 页",1)]),m("p",null,fe(Ae.summary),1),m("div",CC,[Ae.groupCount>1?(v(),C("span",TC," 组合 "+fe(Ae.groupCount),1)):ae("",!0),Ae.repliesCount?(v(),C("span",MC," 回复 "+fe(Ae.repliesCount),1)):ae("",!0),Ae.isCanvasSelected?(v(),C("span",RC," 画布已选中 ")):ae("",!0),Ye.value.includes(Ae.id)?(v(),C("span",wC," 待批量处理 ")):ae("",!0)])],8,AC),m("button",{class:"jit-annotation-item__delete","aria-label":`删除第 ${Ae.page+1} 页的${Ae.kindLabel}`,onClick:qi(lt=>iT(Ae.entry),["stop"])},[...b[86]||(b[86]=[Zn('<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 7h14"></path><path d="M8 7V5h8v2"></path><path d="M8 10v7"></path><path d="M12 10v7"></path><path d="M16 10v7"></path><path d="M6 7l1 12h10l1-12"></path></svg>',1)])],8,OC)],2))),128))]))),128))])):(v(),C("div",kC,[...b[87]||(b[87]=[m("p",null,"当前筛选条件下没有批注。你可以修改类型筛选,或直接搜索批注内容与页码。",-1)])]))])],2),m("a",{class:"jit-copyright-badge",href:$C,target:"_blank",rel:"noopener noreferrer","aria-label":"查看 Jit PDF 版权信息",title:"Jit PDF 版权所有,点击查看"},[...b[88]||(b[88]=[m("span",{class:"jit-copyright-badge__mark"},"©",-1),m("span",{class:"jit-copyright-badge__text"},"Jit PDF",-1)])]),je(I(ND),{"document-id":t.activeDocumentId},{default:We(({isLoading:U,isError:Ae,isLoaded:lt})=>[U||t.isInitializing?(v(),C("div",IC,"正在分段加载文档")):Ae?(v(),C("div",GC," 文档加载失败,请检查本地文件服务和 PDF 路径 ")):lt&&t.activeDocumentId?(v(),he(I(nA),{key:2,class:"jit-viewport","document-id":t.activeDocumentId},{default:We(()=>[je(I(D_),{"document-id":t.activeDocumentId},{default:We(()=>[je(I(zE),{class:"jit-zoom-surface","document-id":t.activeDocumentId},{default:We(()=>[je(I(ZE),{class:"jit-scroller","document-id":t.activeDocumentId},{default:We(({page:ze})=>[je(I(E_),{class:"jit-page","document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,style:Z({zIndex:ze.elevated?1:void 0})},{default:We(()=>[I(r).redaction?(v(),he(I(xh),{key:0})):ae("",!0),je(I(lA),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"]),je(I(aA),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"]),je(I(q_),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,"text-style":{background:"rgba(22, 119, 255, 0.22)"}},null,8,["document-id","page-index","scale"]),je(I(qE),{"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,"highlight-color":"rgba(22, 119, 255, 0.28)","active-highlight-color":"rgba(9, 88, 217, 0.42)"},null,8,["document-id","page-index","scale"]),I(r).annotation||I(r).ink||I(r).freeText?(v(),he(I(zp),{key:1,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).annotation||I(r).ink||I(r).freeText?(v(),he(I(OD),{key:2,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(Sh),{key:3,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,stroke:"rgba(208, 48, 80, 0.9)",fill:"rgba(208, 48, 80, 0.14)"},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(Eh),{key:4,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(Ah),{key:5,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value,rotation:0},null,8,["document-id","page-index","scale"])):ae("",!0),I(r).redaction?(v(),he(I(pS),{key:6,"document-id":t.activeDocumentId,"page-index":ze.pageIndex,scale:H.value},null,8,["document-id","page-index","scale"])):ae("",!0)]),_:2},1032,["document-id","page-index","scale","style"])]),_:1},8,["document-id"])]),_:1},8,["document-id"])]),_:1},8,["document-id"])]),_:1},8,["document-id"])):(v(),C("div",LC,"准备打开文档"))]),_:1},8,["document-id"])])],2)])}}}),Zg=ie({__name:"JitPdfEditor",props:{source:{},locale:{default:"zh-CN"},theme:{default:"blue-enterprise"},capabilities:{},service:{},readonly:{type:Boolean,default:!1}},emits:["ready","dirty-change","save-start","save-success","save-error","load-error"],setup(t,{emit:e}){const n=t,o=e,r=kE(NE,{encoderPoolSize:2,fontFallback:$E}),a=P(()=>({permissions:{enforceDocumentPermissions:!1,overrides:{modifyAnnotations:!n.readonly,modifyContents:!n.readonly,copyContents:!0,print:!0}}})),i=P(()=>[{package:BD},{package:pE},{package:xS,config:{defaultPageGap:40,defaultBufferSize:4}},{package:PS},{package:ZS},{package:m_},{package:X_},{package:JD},{package:GS,config:{showAllResults:!0}},{package:WS},{package:_E,config:{defaultZoomLevel:Mt.FitPage}},{package:LD,config:{autoCommit:!0,annotationAuthor:"Jit PDF",locked:{type:n.readonly?jn.All:jn.None},colorPresets:["#1677FF","#0958D9","#18A058","#D03050","#FAAD14"]}},{package:mS,config:{drawBlackBoxes:!0,useAnnotationMode:!0}},{package:VD,config:{defaultFileName:n.source.name??"jit-pdf-export.pdf"}}]);return(s,l)=>(v(),he(I(rb),{class:"jit-pdf-shell",engine:I(r),config:a.value,plugins:i.value,"auto-mount-dom-elements":!0},{default:We(({activeDocumentId:c,pluginsReady:u,isInitializing:d})=>[je(NC,xe(n,{"active-document-id":c,"plugins-ready":u,"is-initializing":d,onReady:l[0]||(l[0]=p=>o("ready",p)),onDirtyChange:l[1]||(l[1]=p=>o("dirty-change",p)),onSaveStart:l[2]||(l[2]=p=>o("save-start")),onSaveSuccess:l[3]||(l[3]=p=>o("save-success",p)),onSaveError:l[4]||(l[4]=p=>o("save-error",p)),onLoadError:l[5]||(l[5]=p=>o("load-error",p))}),null,16,["active-document-id","plugins-ready","is-initializing"])]),_:1},8,["engine","config","plugins"]))}}),Qg="jit-pdf-sdk",Eo="files",ii="annotations";function Jg(t){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${t}-${crypto.randomUUID()}`:`${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`}function jC(t=new Date){const e=n=>n.toString().padStart(2,"0");return[t.getFullYear(),e(t.getMonth()+1),e(t.getDate())].join("")+`-${e(t.getHours())}${e(t.getMinutes())}${e(t.getSeconds())}`}function UC(t){const e=t.lastIndexOf(".");return e>=0?t.slice(0,e):t}function BC(t){const e=t.lastIndexOf(".");return e>=0?t.slice(e):".pdf"}function zC(t){return`${UC(t)}-副本-${jC()}${BC(t)}`}function ef(t){return Xg(t)}function WC(t){return new Promise((e,n)=>{const o=indexedDB.open(t,1);o.onupgradeneeded=()=>{const r=o.result;if(!r.objectStoreNames.contains(Eo)){const a=r.createObjectStore(Eo,{keyPath:"id"});a.createIndex("updatedAt","updatedAt",{unique:!1}),a.createIndex("originId","originId",{unique:!1})}r.objectStoreNames.contains(ii)||r.createObjectStore(ii,{keyPath:"fileId"})},o.onsuccess=()=>e(o.result),o.onerror=()=>n(o.error??new Error("IndexedDB 打开失败"))})}function ol(t){return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error??new Error("IndexedDB 请求失败"))})}async function Ao(t,e,n,o){const r=await WC(t);try{const a=r.transaction(e,n),i=a.objectStore(e),s=await o(i);return await new Promise((l,c)=>{a.oncomplete=()=>l(),a.onerror=()=>c(a.error??new Error("IndexedDB 事务失败")),a.onabort=()=>c(a.error??new Error("IndexedDB 事务中断"))}),s}finally{r.close()}}function HC(t){return{id:t.id,name:t.name,relativePath:t.relativePath,size:t.size,updatedAt:t.updatedAt,pageCount:null}}function VC(t){return{id:t.id,name:t.name,relativePath:t.relativePath,size:t.size,updatedAt:t.updatedAt}}function YC(t){return{kind:"file",id:t.id,name:t.name,relativePath:t.relativePath,size:t.size,updatedAt:t.updatedAt}}function tf(t){return{async load(e){const n=await Ao(t,ii,"readonly",async o=>ol(o.get(e)));return ef((n==null?void 0:n.annotations)??[])},async save(e,n){await Ao(t,ii,"readwrite",async o=>{o.put({fileId:e,annotations:ef(n),updatedAt:new Date().toISOString()})})}}}function nf(t={}){const e=t.databaseName??Qg,n=tf(e),o=new Map;function r(s){const l=o.get(s.id);if(l)return l;const c=URL.createObjectURL(s.blob);return o.set(s.id,c),c}async function a(){const s=await Ao(e,Eo,"readonly",async l=>ol(l.getAll()));return s.forEach(l=>r(l)),s.sort((l,c)=>c.updatedAt.localeCompare(l.updatedAt))}async function i(s){const l=await Ao(e,Eo,"readonly",async c=>ol(c.get(s)));if(!l)throw new Error("未找到本地 PDF 文件");return r(l),l}return{async getFileList(){return{rootDir:"IndexedDB",items:(await a()).map(YC)}},async getFileMeta(s){return HC(await i(s))},async getFileHistory(s){const l=await i(s),c=l.originId||l.id;return(await a()).filter(d=>d.id!==l.id&&d.originId===c).map(VC)},getFileStreamUrl(s){return o.get(s)??""},async uploadFile(s){const l=Jg("local"),c=new Date().toISOString(),u={id:l,name:s.name,relativePath:`indexeddb/${l}/${s.name}`,size:s.size,updatedAt:c,blob:s,originId:l};await Ao(e,Eo,"readwrite",async p=>{p.put(u)});const d=o.get(l);return d&&URL.revokeObjectURL(d),o.set(l,URL.createObjectURL(s)),{id:l,name:u.name,relativePath:u.relativePath,size:u.size,updatedAt:c}},async deleteFile(s){const l=await i(s);await Ao(e,Eo,"readwrite",async u=>{u.delete(s)});const c=o.get(s);return c&&(URL.revokeObjectURL(c),o.delete(s)),await n.save(s,[]),{fileId:s,relativePath:l.relativePath}},async saveCopy(s){const l=await i(s.fileId),c=new Blob([await s.content.arrayBuffer()],{type:"application/pdf"}),u=Jg("local-copy"),d=zC(s.fileName||l.name),p=new Date().toISOString(),h={id:u,name:d,relativePath:`indexeddb/${u}/${d}`,size:c.size,updatedAt:p,blob:c,originId:l.originId||l.id};await Ao(e,Eo,"readwrite",async f=>{f.put(h)});const g=o.get(u);return g&&URL.revokeObjectURL(g),o.set(u,URL.createObjectURL(c)),await n.save(u,[]),{fileId:u,fileName:d,relativePath:h.relativePath,absolutePath:h.relativePath,savedAt:p,size:h.size}},async loadAnnotations(s){return n.load(s)},async saveAnnotations(s,l){await n.save(s,l)}}}function qC(t={}){const e=t.databaseName??Qg;return tf(e)}function KC(t){return encodeURIComponent(t)}async function Qo(t){if(!t.ok){let e=null;try{e=await t.json()}catch{e=null}throw new Error((e==null?void 0:e.message)??`请求失败: ${t.status}`)}return await t.json()}function of(t={}){const e=t.baseUrl??"",n=qC({databaseName:t.annotationDatabaseName});return{async getFileList(){const o=await fetch(`${e}/api/files`);return Qo(o)},async getFileMeta(o){const r=await fetch(`${e}/api/files/${encodeURIComponent(o)}/meta`);return Qo(r)},async getFileHistory(o){const r=await fetch(`${e}/api/files/${encodeURIComponent(o)}/history`);return Qo(r)},getFileStreamUrl(o){return`${e}/api/files/${encodeURIComponent(o)}/content`},async uploadFile(o){const r=new FormData;r.append("file",o);const a=await fetch(`${e}/api/files/upload`,{method:"POST",body:r});return Qo(a)},async deleteFile(o){const r=await fetch(`${e}/api/files/${encodeURIComponent(o)}`,{method:"DELETE"});return Qo(r)},async saveCopy(o){const r=await o.content.arrayBuffer(),a=await fetch(`${e}/api/files/${encodeURIComponent(o.fileId)}/save-copy`,{method:"POST",headers:{"Content-Type":"application/pdf","X-File-Name":KC(o.fileName),"X-Save-Reason":o.reason??"manual-save"},body:r});return Qo(a)},async loadAnnotations(o){return n.load(o)},async saveAnnotations(o,r){await n.save(o,r)}}}const XC=".jit-copyright-badge",ZC="data-jit-pdf-copyright-notice",Ur="data-jit-pdf-copyright-target",QC="https://jitword.com/jit-pdf.html";function JC(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`jit-pdf-${crypto.randomUUID()}`:`jit-pdf-${Date.now()}-${Math.random().toString(16).slice(2)}`}function eT(t){const e=t.getAttribute(Ur);if(e)return e;const n=JC();return t.setAttribute(Ur,n),n}function rf(t){return document.querySelector(`.jit-copyright-integrity-notice[${Ur}="${t}"]`)}function af(t){var e;(e=rf(t))==null||e.remove()}function tT(t){const e=rf(t);if(e)return e;const n=document.createElement("a");return n.className="jit-copyright-integrity-notice",n.href=QC,n.target="_blank",n.rel="noopener noreferrer",n.setAttribute(ZC,"true"),n.setAttribute(Ur,t),n.setAttribute("aria-label","Jit PDF 版权提示,点击查看"),n.innerHTML=`
18864
+ <span class="jit-copyright-integrity-notice__mark">!</span>
18865
+ <span class="jit-copyright-integrity-notice__content">
18866
+ <strong>请保留 Jit PDF 版权信息</strong>
18867
+ <span>检测到浏览器挂载模式下的版权标识被隐藏或移除,点击查看说明。</span>
18868
+ </span>
18869
+ `,document.body.appendChild(n),n}function nT(t){const e=window.getComputedStyle(t),n=t.getBoundingClientRect(),o=Number.parseFloat(e.opacity||"1");return e.display!=="none"&&e.visibility!=="hidden"&&o>.05&&n.width>0&&n.height>0}function oT(t){if(typeof window>"u"||typeof document>"u")return()=>{};const e=eT(t);let n=!1;const o=()=>{const s=t.querySelector(XC);if(!!s&&nT(s)){n=!1,af(e);return}tT(e),n||(n=!0,console.warn("[jit-pdf] Please keep the Jit PDF copyright badge visible in browser/UMD mode. See https://jitword.com/jit-pdf.html"))},r=new MutationObserver(()=>{window.requestAnimationFrame(o)});r.observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class","hidden","aria-hidden"]});const a=window.setInterval(o,2e3),i=window.setTimeout(o,120);return window.addEventListener("resize",o),()=>{r.disconnect(),window.clearInterval(a),window.clearTimeout(i),window.removeEventListener("resize",o),af(e),t.removeAttribute(Ur)}}function rT(t){if(typeof t=="string"){const e=document.querySelector(t);if(!e)throw new Error(`未找到挂载容器:${t}`);return e}return t}function sf(t){const{target:e,onReady:n,onDirtyChange:o,onSaveStart:r,onSaveSuccess:a,onSaveError:i,onLoadError:s,...l}=t,c=rT(e),u=ZP({render(){return _P(Zg,{...l,onReady:n,onDirtyChange:o,onSaveStart:r,onSaveSuccess:a,onSaveError:i,onLoadError:s})}});u.mount(c);const d=oT(c);return{app:u,element:c,unmount(){d(),u.unmount()}}}const aT={mountJitPdfEditor:sf,createHttpPdfEditorService:of,createIndexedDbPdfEditorService:nf};rn.JitPdfEditor=Zg,rn.browser=aT,rn.createHttpPdfEditorService=of,rn.createIndexedDbPdfEditorService=nf,rn.mountJitPdfEditor=sf,rn.usePdfEditorSdk=Kg,Object.defineProperty(rn,Symbol.toStringTag,{value:"Module"})});