@soomo/text-annotator 3.0.0-staging.33 → 3.0.0-staging.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/state/TextAnnotationStore.d.ts +3 -0
- package/dist/src/state/spatialTree.d.ts +5 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/trimRangeToContainer.d.ts +1 -0
- package/dist/text-annotator.es.js +995 -973
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(x,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):(x=typeof globalThis<"u"?globalThis:x||self,H(x.RecogitoJS={}))})(this,function(x){"use strict";const H={fill:"rgb(0, 128, 255)",fillOpacity:.18},et={fill:"rgb(0, 128, 255)",fillOpacity:.45},_t=(e,t,n,o,i)=>{var s,a;const r=n?typeof n=="function"?n(e.annotation,e.state,i)||((s=e.state)!=null&&s.selected?et:H):n:(a=e.state)!=null&&a.selected?et:H;return o&&o.paint(e,t)||r},St="not-annotatable",X=`.${St}`,_e=e=>{var n;const t=e.commonAncestorContainer;return t instanceof HTMLElement?!t.closest(X):!((n=t.parentElement)!=null&&n.closest(X))},He=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(St)&&!o.parentElement.closest(X)&&e.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Ht=e=>{if(!_e(e))return[];const t=[];let n=null;for(const o of He(e)){let i;n?(i=document.createRange(),i.setStartAfter(n),i.setEndBefore(o)):(i=e.cloneRange(),i.setEndBefore(o)),i.collapsed||t.push(i),n=o}if(n){const o=e.cloneRange();o.setStartAfter(n),o.collapsed||t.push(o)}return t.length>0?t:[e]},ft=e=>{const t=e.cloneContents();return t.querySelectorAll(X).forEach(n=>n.remove()),t},Yt=e=>e.addEventListener("click",t=>{!t.target.closest(X)&&!t.target.closest("a")&&t.preventDefault()}),Xt=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},pt=(e,t=10)=>{let n;return(...o)=>{clearTimeout(n),n=setTimeout(()=>e.apply(void 0,o),t)}},Ye=e=>{const t=e.cloneContents();return t.querySelectorAll(X).forEach(n=>n.remove()),t},$t=(e,t)=>{const n=document.createNodeIterator(t);let o=0,i=n.nextNode();for(;i!==null;){if(i===e)return o;o+=1,i=n.nextNode()}},jt=(e,t)=>{const n=document.createNodeIterator(t);let o=null;for(let i=0;i<e+1;i++)o=n.nextNode();return o},Xe=e=>{const{commonAncestorContainer:t,startContainer:n,startOffset:o,endContainer:i,endOffset:r}=e,s=Array.from(t.childNodes).map(l=>{const g=l.cloneNode(!0);return l.nodeName==="CANVAS"?l:g}),a=$t(n,t),f=$t(i,t),p=()=>{const l=t;l.replaceChildren(...s);const g=jt(a,l),d=jt(f,l);return e.setStart(g,o),e.setEnd(d,r),e},h=l=>{const g=document.createElement("SPAN");return l.surroundContents(g),g};if(n===i)throw"Not implemented";{const l=document.createRange();l.selectNodeContents(n),l.setStart(n,o);const g=h(l),d=document.createRange();d.selectNode(i),d.setEnd(i,r);const A=h(d),b=$e(e).reverse().map(u=>{var v;const c=document.createElement("SPAN");return(v=u.parentNode)==null||v.insertBefore(c,u),c.appendChild(u),c});return{unwrap:p,nodes:[g,...b,A]}}},$e=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o}=e,i=document.createNodeIterator(t,NodeFilter.SHOW_TEXT);let r=i.nextNode(),s=!1;const a=[];for(;r!=null;)r===o&&(s=!1),s&&a.push(r),r===n&&(s=!0),r=i.nextNode();return a},je=e=>{const{startContainer:t,endContainer:n}=e;if(t===n)return Array.from(e.getClientRects());{const{unwrap:o,nodes:i}=Xe(e),r=i.reduce((s,a)=>[...s,...a.getClientRects()],[]);return o(),r}},Wt=(e,t,n=10,o)=>{const i=o?e.startContainer.parentElement.closest(o):t,r=document.createRange();r.setStart(i,0),r.setEnd(e.startContainer,e.startOffset);const s=ft(r).textContent,a=document.createRange();a.setStart(e.endContainer,e.endOffset),i===document.body?a.setEnd(i,i.childNodes.length):a.setEndAfter(i);const f=ft(a).textContent;return{prefix:s.substring(s.length-n),suffix:f.substring(0,n)}},Gt=/^\s*$/,zt=e=>Gt.test(e.toString()),j=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),We=(e,t)=>{const n=r=>Math.round(r*10)/10,o={top:n(e.top),bottom:n(e.bottom),left:n(e.left),right:n(e.right)},i={top:n(t.top),bottom:n(t.bottom),left:n(t.left),right:n(t.right)};if(Math.abs(o.top-i.top)<.5&&Math.abs(o.bottom-i.bottom)<.5){if(Math.abs(o.left-i.right)<.5||Math.abs(o.right-i.left)<.5)return"inline-adjacent";if(o.left>=i.left&&o.right<=i.right)return"inline-is-contained";if(o.left<=i.left&&o.right>=i.right)return"inline-contains"}else if(o.top<=i.top&&o.bottom>=i.bottom){if(o.left<=i.left&&o.right>=i.right)return"block-contains"}else if(o.top>=i.top&&o.bottom<=i.bottom&&o.left>=i.left&&o.right<=i.right)return"block-is-contained"},Ge=(e,t)=>{const n=Math.min(e.left,t.left),o=Math.max(e.right,t.right),i=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,i,o-n,r-i)},qt=e=>e.reduce((t,n)=>{if(n.width===0||n.height===0)return t;let o=[...t],i=!1;for(const r of t){const s=We(n,r);if(s==="inline-adjacent"){o=o.map(a=>a===r?Ge(n,r):a),i=!0;break}else if(s==="inline-contains"){o=o.map(a=>a===r?n:a),i=!0;break}else if(s==="inline-is-contained"){i=!0;break}else if(s==="block-contains"||s==="block-is-contained"){n.width<r.width&&(o=o.map(a=>a===r?n:a)),i=!0;break}}return i?o:[...o,n]},[]),ze=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Zt=(e,t,n)=>{const o=document.createRange(),i=n?e.startContainer.parentElement.closest(n):t;o.setStart(i,0),o.setEnd(e.startContainer,e.startOffset);const r=ft(o).textContent,s=e.toString(),a=r.length||0,f=a+s.length;return n?{quote:s,start:a,end:f,range:e,offsetReference:i}:{quote:s,start:a,end:f,range:e}},Ct=(e,t)=>{var h,l;const{start:n,end:o}=e,i=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,g=>{var d;return(d=g.parentElement)!=null&&d.closest(X)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let s=0;const a=document.createRange();let f=r.nextNode();f===null&&console.error("Could not revive annotation target. Content missing.");let p=!i;for(;f!==null;){if(p||(p=i==null?void 0:i.contains(f)),p){const g=((h=f.textContent)==null?void 0:h.length)||0;if(s+g>n){a.setStart(f,n-s);break}s+=g}f=r.nextNode()}for(;f!==null;){const g=((l=f.textContent)==null?void 0:l.length)||0;if(s+g>=o){a.setEnd(f,o-s);break}s+=g,f=r.nextNode()}return{...e,range:a}},nt=(e,t)=>j(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:Ct(n,t))},ht=(e,t)=>j(e.target.selector)?e:{...e,target:nt(e.target,t)},Jt=(e,t)=>{const{left:n,top:o,right:i,bottom:r}=e;return new DOMRect(n-t.left,o-t.top,i-n,r-o)},qe=(e,t)=>{const{left:n,top:o,right:i,bottom:r}=e;return new DOMRect(n+t.left,o+t.top,i-n,r-o)},Qt=e=>({...e,type:e.type,x:e.x,y:e.y,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,screenX:e.screenX,screenY:e.screenY,isPrimary:e.isPrimary,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,button:e.button,buttons:e.buttons,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,eventPhase:e.eventPhase,pointerId:e.pointerId,pointerType:e.pointerType,timeStamp:e.timeStamp}),Kt=e=>({...e,type:e.type,key:e.key,code:e.code,location:e.location,repeat:e.repeat,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,timeStamp:e.timeStamp}),Ze=e=>{const{top:t,left:n}=e.getBoundingClientRect(),{innerWidth:o,innerHeight:i}=window,r=-n,s=-t,a=o-n,f=i-t;return{top:t,left:n,minX:r,minY:s,maxX:a,maxY:f}},Je=e=>{let t=new Set;return o=>{const i=o.map(r=>r.id);(t.size!==i.length||i.some(r=>!t.has(r)))&&e.set(i),t=new Set(i)}},Tt=(e,t,n,o)=>{const{store:i,selection:r,hover:s}=t;let a,f,p;const h=Je(n),l=B=>{const{x:U,y:w}=e.getBoundingClientRect(),S=i.getAt(B.clientX-U,B.clientY-w,f);S?s.current!==S.id&&(e.classList.add("hovered"),s.set(S.id)):s.current&&(e.classList.remove("hovered"),s.set(null))};e.addEventListener("pointermove",l);const g=(B=!1)=>{p&&p.clear();const U=Ze(e),{minX:w,minY:S,maxX:C,maxY:L}=U,R=f?i.getIntersecting(w,S,C,L).filter(({annotation:q})=>f(q)):i.getIntersecting(w,S,C,L),F=r.selected.map(({id:q})=>q),Z=R.map(({annotation:q,rects:Eo})=>{const Lo=F.includes(q.id),xo=q.id===s.current;return{annotation:q,rects:Eo,state:{selected:Lo,hover:xo}}});o.redraw(Z,U,a,p,B),setTimeout(()=>h(R.map(({annotation:q})=>q)),1)},d=B=>{p=B,g()},A=B=>{a=B,g()},m=B=>{f=B,g(!1)},b=()=>g();i.observe(b);const u=r.subscribe(()=>g()),c=()=>g(!0);document.addEventListener("scroll",c,{capture:!0,passive:!0});const v=pt(()=>{i.recalculatePositions(),p&&p.reset(),g()});window.addEventListener("resize",v);const T=new ResizeObserver(v);T.observe(e);const E={attributes:!0,childList:!0,subtree:!0},M=new MutationObserver(B=>{B.every(w=>w.target===e||e.contains(w.target))||g(!0)});return M.observe(document.body,E),{destroy:()=>{e.removeEventListener("pointermove",l),o.destroy(),i.unobserve(b),u(),document.removeEventListener("scroll",c),window.removeEventListener("resize",v),T.disconnect(),M.disconnect()},redraw:g,setStyle:A,setFilter:m,setPainter:d,setVisible:o.setVisible}},Qe=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},Ke=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},tn=e=>{e.classList.add("r6o-annotatable");const t=Qe(),n=t.getContext("2d");document.body.appendChild(t);const o=(a,f,p,h)=>requestAnimationFrame(()=>{const{width:l,height:g}=t;n.clearRect(-.5,-.5,l+1,g+1),h&&h.clear();const{top:d,left:A}=f;[...a].sort((b,u)=>{const{annotation:{target:{created:c}}}=b,{annotation:{target:{created:v}}}=u;return c.getTime()-v.getTime()}).forEach(b=>{var T;const u=p?typeof p=="function"?p(b.annotation,b.state):p:(T=b.state)!=null&&T.selected?et:H,c=h&&h.paint(b,f)||u,v=b.rects.map(({x:E,y:M,width:k,height:B})=>({x:E+A,y:M+d,width:k,height:B}));if(n.fillStyle=c.fill,n.globalAlpha=c.fillOpacity||1,v.forEach(({x:E,y:M,width:k,height:B})=>n.fillRect(E,M,k,B)),c.underlineColor){n.globalAlpha=1,n.strokeStyle=c.underlineColor,n.lineWidth=c.underlineThickness??1;const E=c.underlineOffset??0;v.forEach(({x:M,y:k,width:B,height:U})=>{n.beginPath(),n.moveTo(M,k+U+E),n.lineTo(M+B,k+U+E),n.stroke()})}})}),i=pt(()=>{Ke(t)});return window.addEventListener("resize",i),{destroy:()=>{t.remove(),window.removeEventListener("resize",i)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},te=(e,t,n)=>Tt(e,t,n,tn(e));var en={grad:.9,turn:360,rad:360/(2*Math.PI)},G=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},I=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},Y=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},ee=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},ne=function(e){return{r:Y(e.r,0,255),g:Y(e.g,0,255),b:Y(e.b,0,255),a:Y(e.a)}},Et=function(e){return{r:I(e.r),g:I(e.g),b:I(e.b),a:I(e.a,3)}},nn=/^#([0-9a-f]{3,8})$/i,gt=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},oe=function(e){var t=e.r,n=e.g,o=e.b,i=e.a,r=Math.max(t,n,o),s=r-Math.min(t,n,o),a=s?r===t?(n-o)/s:r===n?2+(o-t)/s:4+(t-n)/s:0;return{h:60*(a<0?a+6:a),s:r?s/r*100:0,v:r/255*100,a:i}},ie=function(e){var t=e.h,n=e.s,o=e.v,i=e.a;t=t/360*6,n/=100,o/=100;var r=Math.floor(t),s=o*(1-n),a=o*(1-(t-r)*n),f=o*(1-(1-t+r)*n),p=r%6;return{r:255*[o,a,s,s,f,o][p],g:255*[f,o,o,a,s,s][p],b:255*[s,s,f,o,o,a][p],a:i}},re=function(e){return{h:ee(e.h),s:Y(e.s,0,100),l:Y(e.l,0,100),a:Y(e.a)}},ae=function(e){return{h:I(e.h),s:I(e.s),l:I(e.l),a:I(e.a,3)}},se=function(e){return ie((n=(t=e).s,{h:t.h,s:(n*=((o=t.l)<50?o:100-o)/100)>0?2*n/(o+n)*100:0,v:o+n,a:t.a}));var t,n,o},ot=function(e){return{h:(t=oe(e)).h,s:(i=(200-(n=t.s))*(o=t.v)/100)>0&&i<200?n*o/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,o,i},on=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,sn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,le={string:[[function(e){var t=nn.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?I(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?I(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=an.exec(e)||sn.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:ne({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=on.exec(e)||rn.exec(e);if(!t)return null;var n,o,i=re({h:(n=t[1],o=t[2],o===void 0&&(o="deg"),Number(n)*(en[o]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return se(i)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,o=e.b,i=e.a,r=i===void 0?1:i;return G(t)&&G(n)&&G(o)?ne({r:Number(t),g:Number(n),b:Number(o),a:Number(r)}):null},"rgb"],[function(e){var t=e.h,n=e.s,o=e.l,i=e.a,r=i===void 0?1:i;if(!G(t)||!G(n)||!G(o))return null;var s=re({h:Number(t),s:Number(n),l:Number(o),a:Number(r)});return se(s)},"hsl"],[function(e){var t=e.h,n=e.s,o=e.v,i=e.a,r=i===void 0?1:i;if(!G(t)||!G(n)||!G(o))return null;var s=function(a){return{h:ee(a.h),s:Y(a.s,0,100),v:Y(a.v,0,100),a:Y(a.a)}}({h:Number(t),s:Number(n),v:Number(o),a:Number(r)});return ie(s)},"hsv"]]},ce=function(e,t){for(var n=0;n<t.length;n++){var o=t[n][0](e);if(o)return[o,t[n][1]]}return[null,void 0]},ln=function(e){return typeof e=="string"?ce(e.trim(),le.string):typeof e=="object"&&e!==null?ce(e,le.object):[null,void 0]},Lt=function(e,t){var n=ot(e);return{h:n.h,s:Y(n.s+100*t,0,100),l:n.l,a:n.a}},xt=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},de=function(e,t){var n=ot(e);return{h:n.h,s:n.s,l:Y(n.l+100*t,0,100),a:n.a}},ue=function(){function e(t){this.parsed=ln(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return I(xt(this.rgba),2)},e.prototype.isDark=function(){return xt(this.rgba)<.5},e.prototype.isLight=function(){return xt(this.rgba)>=.5},e.prototype.toHex=function(){return t=Et(this.rgba),n=t.r,o=t.g,i=t.b,s=(r=t.a)<1?gt(I(255*r)):"","#"+gt(n)+gt(o)+gt(i)+s;var t,n,o,i,r,s},e.prototype.toRgb=function(){return Et(this.rgba)},e.prototype.toRgbString=function(){return t=Et(this.rgba),n=t.r,o=t.g,i=t.b,(r=t.a)<1?"rgba("+n+", "+o+", "+i+", "+r+")":"rgb("+n+", "+o+", "+i+")";var t,n,o,i,r},e.prototype.toHsl=function(){return ae(ot(this.rgba))},e.prototype.toHslString=function(){return t=ae(ot(this.rgba)),n=t.h,o=t.s,i=t.l,(r=t.a)<1?"hsla("+n+", "+o+"%, "+i+"%, "+r+")":"hsl("+n+", "+o+"%, "+i+"%)";var t,n,o,i,r},e.prototype.toHsv=function(){return t=oe(this.rgba),{h:I(t.h),s:I(t.s),v:I(t.v),a:I(t.a,3)};var t},e.prototype.invert=function(){return $({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),$(Lt(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),$(Lt(this.rgba,-t))},e.prototype.grayscale=function(){return $(Lt(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),$(de(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),$(de(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?$({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):I(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=ot(this.rgba);return typeof t=="number"?$({h:t,s:n.s,l:n.l,a:n.a}):I(n.h)},e.prototype.isEqual=function(t){return this.toHex()===$(t).toHex()},e}(),$=function(e){return e instanceof ue?e:new ue(e)};const cn=e=>[`background-color:${$((e==null?void 0:e.fill)||H.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?H.fillOpacity:e.fillOpacity).toHex()}`,e!=null&&e.underlineThickness?"text-decoration:underline":void 0,e!=null&&e.underlineColor?`text-decoration-color:${e.underlineColor}`:void 0,e!=null&&e.underlineOffset?`text-underline-offset:${e.underlineOffset}px`:void 0,e!=null&&e.underlineThickness?`text-decoration-thickness:${e.underlineThickness}px`:void 0].filter(Boolean).join(";"),fe=()=>{const e=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(e);let t=new Set;return{destroy:()=>{CSS.highlights.clear(),e.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,s,a,f)=>{f&&f.clear();const p=new Set(r.map(l=>l.annotation.id));Array.from(t).filter(l=>!p.has(l));const h=r.map(l=>{var A;const g=a?typeof a=="function"?a(l.annotation,l.state):a:(A=l.state)!=null&&A.selected?et:H,d=f&&f.paint(l,s)||g;return`::highlight(_${l.annotation.id}) { ${cn(d)} }`});e.innerHTML=h.join(`
|
|
2
|
-
`),CSS.highlights.clear(),r.forEach(({annotation:l})=>{const g=l.target.selector.map(A=>A.range),d=new Highlight(...g);CSS.highlights.set(`_${l.id}`,d)}),t=p}}},pe=(e,t,n)=>Tt(e,t,n,fe());var he=Object.prototype.hasOwnProperty;function Mt(e,t){var n,o;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&Mt(e[o],t[o]););return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(he.call(e,n)&&++o&&!he.call(t,n)||!(n in t)||!Mt(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}const dn=(e,t)=>{const n=(r,s)=>r.x<=s.x+s.width&&r.x+r.width>=s.x&&r.y<=s.y+s.height&&r.y+r.height>=s.y,o=r=>r.rects.reduce((s,a)=>s+a.width,0),i=t.filter(({rects:r})=>r.some(s=>n(e,s)));return i.sort((r,s)=>o(s)-o(r)),i.findIndex(r=>r.rects.includes(e))},un=e=>{e.classList.add("r6o-annotatable");const t=document.createElement("div");t.className="r6o-span-highlight-layer",e.insertBefore(t,e.firstChild);let n=[];return{destroy:()=>{t.remove()},redraw:(s,a,f,p,h)=>{const g=!(Mt(n,s)&&h);!p&&!g||(g&&(t.innerHTML=""),s.forEach(d=>{d.rects.map(A=>{const m=dn(A,s),b=_t(d,a,f,p,m);if(g){const u=document.createElement("span");u.className="r6o-annotation",u.dataset.annotation=d.annotation.id,u.style.left=`${A.x}px`,u.style.top=`${A.y}px`,u.style.width=`${A.width}px`,u.style.height=`${A.height}px`,u.style.backgroundColor=$((b==null?void 0:b.fill)||H.fill).alpha((b==null?void 0:b.fillOpacity)===void 0?H.fillOpacity:b.fillOpacity).toHex(),b.underlineStyle&&(u.style.borderStyle=b.underlineStyle),b.underlineColor&&(u.style.borderColor=b.underlineColor),b.underlineThickness&&(u.style.borderBottomWidth=`${b.underlineThickness}px`),b.underlineOffset&&(u.style.paddingBottom=`${b.underlineOffset}px`),t.appendChild(u)}})}),n=s)},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},ge=(e,t,n)=>Tt(e,t,n,un(e));for(var P=[],Bt=0;Bt<256;++Bt)P.push((Bt+256).toString(16).slice(1));function fn(e,t=0){return(P[e[t+0]]+P[e[t+1]]+P[e[t+2]]+P[e[t+3]]+"-"+P[e[t+4]]+P[e[t+5]]+"-"+P[e[t+6]]+P[e[t+7]]+"-"+P[e[t+8]]+P[e[t+9]]+"-"+P[e[t+10]]+P[e[t+11]]+P[e[t+12]]+P[e[t+13]]+P[e[t+14]]+P[e[t+15]]).toLowerCase()}var mt,pn=new Uint8Array(16);function hn(){if(!mt&&(mt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!mt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return mt(pn)}var gn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const me={randomUUID:gn};function be(e,t,n){if(me.randomUUID&&!t&&!e)return me.randomUUID();e=e||{};var o=e.random||(e.rng||hn)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,fn(o)}var we=Object.prototype.hasOwnProperty;function J(e,t){var n,o;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&J(e[o],t[o]););return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(we.call(e,n)&&++o&&!we.call(t,n)||!(n in t)||!J(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}function Rt(){}function mn(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const Q=[];function kt(e,t=Rt){let n;const o=new Set;function i(a){if(mn(e,a)&&(e=a,n)){const f=!Q.length;for(const p of o)p[1](),Q.push(p,e);if(f){for(let p=0;p<Q.length;p+=2)Q[p][0](Q[p+1]);Q.length=0}}}function r(a){i(a(e))}function s(a,f=Rt){const p=[a,f];return o.add(p),o.size===1&&(n=t(i,r)||Rt),a(e),()=>{o.delete(p),o.size===0&&n&&(n(),n=null)}}return{set:i,update:r,subscribe:s}}const bn=e=>{const{subscribe:t,set:n}=kt();let o;return t(i=>o=i),e.observe(({changes:i})=>{if(o){(i.deleted||[]).some(s=>s.id===o)&&n(void 0);const r=(i.updated||[]).find(({oldValue:s})=>s.id===o);r&&n(r.newValue.id)}}),{get current(){return o},subscribe:t,set:n}};var Ae=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(Ae||{});const Ot={selected:[]},wn=(e,t="EDIT")=>{const{subscribe:n,set:o}=kt(Ot);let i=t,r=Ot;n(d=>r=d);const s=()=>o(Ot),a=()=>{var d;return((d=r.selected)==null?void 0:d.length)===0},f=d=>{if(a())return!1;const A=typeof d=="string"?d:d.id;return r.selected.some(m=>m.id===A)},p=(d,A)=>{const m=e.getAnnotation(d);if(!m){console.warn("Invalid selection: "+d);return}switch(ve(m,i)){case"EDIT":o({selected:[{id:d,editable:!0}],event:A});break;case"SELECT":o({selected:[{id:d}],event:A});break;default:o({selected:[],event:A})}},h=(d,A)=>{const m=Array.isArray(d)?d:[d],b=m.map(u=>e.getAnnotation(u)).filter(u=>!!u);o({selected:b.map(u=>{const c=A===void 0?ve(u,i)==="EDIT":A;return{id:u.id,editable:c}})}),b.length!==m.length&&console.warn("Invalid selection",d)},l=d=>{if(a())return!1;const{selected:A}=r;A.some(({id:m})=>d.includes(m))&&o({selected:A.filter(({id:m})=>!d.includes(m))})},g=d=>i=d;return e.observe(({changes:d})=>l((d.deleted||[]).map(A=>A.id))),{get event(){return r?r.event:null},get selected(){return r?[...r.selected]:null},clear:s,isEmpty:a,isSelected:f,setSelected:h,setUserSelectAction:g,subscribe:n,userSelect:p}},ve=(e,t)=>typeof t=="function"?t(e):t||"EDIT";for(var y=[],Vt=0;Vt<256;++Vt)y.push((Vt+256).toString(16).slice(1));function An(e,t=0){return(y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}var bt,vn=new Uint8Array(16);function Sn(){if(!bt&&(bt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!bt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return bt(vn)}var Cn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Se={randomUUID:Cn};function Tn(e,t,n){if(Se.randomUUID&&!t&&!e)return Se.randomUUID();e=e||{};var o=e.random||(e.rng||Sn)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,An(o)}const En=(e,t,n,o)=>({id:Tn(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:o,...t}),Ln=(e,t)=>{const n=new Set(e.bodies.map(o=>o.id));return t.bodies.filter(o=>!n.has(o.id))},xn=(e,t)=>{const n=new Set(t.bodies.map(o=>o.id));return e.bodies.filter(o=>!n.has(o.id))},Mn=(e,t)=>t.bodies.map(n=>{const o=e.bodies.find(i=>i.id===n.id);return{newBody:n,oldBody:o&&!J(o,n)?o:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:o})=>({oldBody:n,newBody:o})),Bn=(e,t)=>!J(e.target,t.target),Ce=(e,t)=>{const n=Ln(e,t),o=xn(e,t),i=Mn(e,t);return{oldValue:e,newValue:t,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:o.length>0?o:void 0,bodiesUpdated:i.length>0?i:void 0,targetUpdated:Bn(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var O=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e))(O||{});const Rn=(e,t)=>{var n,o;const{changes:i,origin:r}=t;if(!(!e.options.origin||e.options.origin===r))return!1;if(e.options.ignore){const{ignore:s}=e.options,a=f=>f&&f.length>0;if(!(a(i.created)||a(i.deleted))){const f=(n=i.updated)==null?void 0:n.some(h=>a(h.bodiesCreated)||a(h.bodiesDeleted)||a(h.bodiesUpdated)),p=(o=i.updated)==null?void 0:o.some(h=>h.targetUpdated);if(s==="BODY_ONLY"&&f&&!p||s==="TARGET_ONLY"&&p&&!f)return!1}}if(e.options.annotations){const s=new Set([...(i.created||[]).map(a=>a.id),...(i.deleted||[]).map(a=>a.id),...(i.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(e.options.annotations)?e.options.annotations:[e.options.annotations]).find(a=>s.has(a))}else return!0},kn=(e,t)=>{const n=new Set((e.created||[]).map(l=>l.id)),o=new Set((e.updated||[]).map(({newValue:l})=>l.id)),i=new Set((t.created||[]).map(l=>l.id)),r=new Set((t.deleted||[]).map(l=>l.id)),s=new Set((t.updated||[]).map(({oldValue:l})=>l.id)),a=new Set((t.updated||[]).filter(({oldValue:l})=>n.has(l.id)||o.has(l.id)).map(({oldValue:l})=>l.id)),f=[...(e.created||[]).filter(l=>!r.has(l.id)).map(l=>s.has(l.id)?t.updated.find(({oldValue:g})=>g.id===l.id).newValue:l),...t.created||[]],p=[...(e.deleted||[]).filter(l=>!i.has(l.id)),...(t.deleted||[]).filter(l=>!n.has(l.id))],h=[...(e.updated||[]).filter(({newValue:l})=>!r.has(l.id)).map(l=>{const{oldValue:g,newValue:d}=l;if(s.has(d.id)){const A=t.updated.find(m=>m.oldValue.id===d.id).newValue;return Ce(g,A)}else return l}),...(t.updated||[]).filter(({oldValue:l})=>!a.has(l.id))];return{created:f,deleted:p,updated:h}},On=e=>e.id!==void 0,Vn=()=>{const e=new Map,t=new Map,n=[],o=(w,S={})=>n.push({onChange:w,options:S}),i=w=>{const S=n.findIndex(C=>C.onChange==w);S>-1&&n.splice(S,1)},r=(w,S)=>{const C={origin:w,changes:{created:S.created||[],updated:S.updated||[],deleted:S.deleted||[]},state:[...e.values()]};n.forEach(L=>{Rn(L,C)&&L.onChange(C)})},s=(w,S=O.LOCAL)=>{if(e.get(w.id))throw Error(`Cannot add annotation ${w.id} - exists already`);e.set(w.id,w),w.bodies.forEach(C=>t.set(C.id,w.id)),r(S,{created:[w]})},a=(w,S)=>{const C=typeof w=="string"?S:w,L=typeof w=="string"?w:w.id,R=e.get(L);if(R){const F=Ce(R,C);return L===C.id?e.set(L,C):(e.delete(L),e.set(C.id,C)),R.bodies.forEach(Z=>t.delete(Z.id)),C.bodies.forEach(Z=>t.set(Z.id,C.id)),F}else console.warn(`Cannot update annotation ${L} - does not exist`)},f=(w,S=O.LOCAL,C=O.LOCAL)=>{const L=On(S)?C:S,R=a(w,S);R&&r(L,{updated:[R]})},p=(w,S=O.LOCAL)=>{const C=w.reduce((L,R)=>{const F=a(R);return F?[...L,F]:L},[]);C.length>0&&r(S,{updated:C})},h=(w,S=O.LOCAL)=>{const C=e.get(w.annotation);if(C){const L={...C,bodies:[...C.bodies,w]};e.set(C.id,L),t.set(w.id,L.id),r(S,{updated:[{oldValue:C,newValue:L,bodiesCreated:[w]}]})}else console.warn(`Attempt to add body to missing annotation: ${w.annotation}`)},l=()=>[...e.values()],g=(w=O.LOCAL)=>{const S=[...e.values()];e.clear(),t.clear(),r(w,{deleted:S})},d=(w,S=!0,C=O.LOCAL)=>{if(S){const L=[...e.values()];e.clear(),t.clear(),w.forEach(R=>{e.set(R.id,R),R.bodies.forEach(F=>t.set(F.id,R.id))}),r(C,{created:w,deleted:L})}else{const L=w.reduce((R,F)=>{const Z=e.get(F.id);return Z?[...R,Z]:R},[]);if(L.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${L.map(R=>R.id).join(", ")}`);w.forEach(R=>{e.set(R.id,R),R.bodies.forEach(F=>t.set(F.id,R.id))}),r(C,{created:w})}},A=w=>{const S=typeof w=="string"?w:w.id,C=e.get(S);if(C)return e.delete(S),C.bodies.forEach(L=>t.delete(L.id)),C;console.warn(`Attempt to delete missing annotation: ${S}`)},m=(w,S=O.LOCAL)=>{const C=A(w);C&&r(S,{deleted:[C]})},b=(w,S=O.LOCAL)=>{const C=w.reduce((L,R)=>{const F=A(R);return F?[...L,F]:L},[]);C.length>0&&r(S,{deleted:C})},u=w=>{const S=e.get(w.annotation);if(S){const C=S.bodies.find(L=>L.id===w.id);if(C){t.delete(C.id);const L={...S,bodies:S.bodies.filter(R=>R.id!==w.id)};return e.set(S.id,L),{oldValue:S,newValue:L,bodiesDeleted:[C]}}else console.warn(`Attempt to delete missing body ${w.id} from annotation ${w.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${w.annotation}`)},c=(w,S=O.LOCAL)=>{const C=u(w);C&&r(S,{updated:[C]})},v=(w,S=O.LOCAL)=>{const C=w.map(L=>u(L)).filter(Boolean);C.length>0&&r(S,{updated:C})},T=w=>{const S=e.get(w);return S?{...S}:void 0},E=w=>{const S=t.get(w);if(S){const C=T(S).bodies.find(L=>L.id===w);if(C)return C;console.error(`Store integrity error: body ${w} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${w}`)},M=(w,S)=>{if(w.annotation!==S.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const C=e.get(w.annotation);if(C){const L=C.bodies.find(F=>F.id===w.id),R={...C,bodies:C.bodies.map(F=>F.id===L.id?S:F)};return e.set(C.id,R),L.id!==S.id&&(t.delete(L.id),t.set(S.id,R.id)),{oldValue:C,newValue:R,bodiesUpdated:[{oldBody:L,newBody:S}]}}else console.warn(`Attempt to add body to missing annotation ${w.annotation}`)},k=(w,S,C=O.LOCAL)=>{const L=M(w,S);L&&r(C,{updated:[L]})},B=(w,S=O.LOCAL)=>{const C=w.map(L=>M({id:L.id,annotation:L.annotation},L)).filter(Boolean);r(S,{updated:C})},U=w=>{const S=e.get(w.annotation);if(S){const C={...S,target:{...S.target,...w}};return e.set(S.id,C),{oldValue:S,newValue:C,targetUpdated:{oldTarget:S.target,newTarget:w}}}else console.warn(`Attempt to update target on missing annotation: ${w.annotation}`)};return{addAnnotation:s,addBody:h,all:l,bulkAddAnnotation:d,bulkDeleteAnnotation:b,bulkDeleteBodies:v,bulkUpdateAnnotation:p,bulkUpdateBodies:B,bulkUpdateTargets:(w,S=O.LOCAL)=>{const C=w.map(L=>U(L)).filter(Boolean);C.length>0&&r(S,{updated:C})},clear:g,deleteAnnotation:m,deleteBody:c,getAnnotation:T,getBody:E,observe:o,unobserve:i,updateAnnotation:f,updateBody:k,updateTarget:(w,S=O.LOCAL)=>{const C=U(w);C&&r(S,{updated:[C]})}}};let Nn=()=>({emit(e,...t){for(let n=0,o=this.events[e]||[],i=o.length;n<i;n++)o[n](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var o;this.events[e]=(o=this.events[e])==null?void 0:o.filter(i=>t!==i)}}});const Fn=250,In=e=>{const t=Nn(),n=[];let o=-1,i=!1,r=0;const s=d=>{if(!i){const{changes:A}=d,m=performance.now();if(m-r>Fn)n.splice(o+1),n.push(A),o=n.length-1;else{const b=n.length-1;n[b]=kn(n[b],A)}r=m}i=!1};e.observe(s,{origin:O.LOCAL});const a=d=>d&&d.length>0&&e.bulkDeleteAnnotation(d),f=d=>d&&d.length>0&&e.bulkAddAnnotation(d,!1),p=d=>d&&d.length>0&&e.bulkUpdateAnnotation(d.map(({oldValue:A})=>A)),h=d=>d&&d.length>0&&e.bulkUpdateAnnotation(d.map(({newValue:A})=>A)),l=d=>d&&d.length>0&&e.bulkAddAnnotation(d,!1),g=d=>d&&d.length>0&&e.bulkDeleteAnnotation(d);return{canRedo:()=>n.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(s),on:(d,A)=>t.on(d,A),redo:()=>{if(n.length-1>o){i=!0;const{created:d,updated:A,deleted:m}=n[o+1];f(d),h(A),g(m),t.emit("redo",n[o+1]),o+=1}},undo:()=>{if(o>-1){i=!0;const{created:d,updated:A,deleted:m}=n[o];a(d),p(A),l(m),t.emit("undo",n[o]),o-=1}}}},Pn=()=>{const{subscribe:e,set:t}=kt([]);return{subscribe:e,set:t}},yn=(e,t,n,o)=>{const{store:i,selection:r,hover:s,viewport:a}=e,f=new Map;let p=[],h;const l=(m,b)=>{f.has(m)?f.get(m).push(b):f.set(m,[b])},g=(m,b)=>{const u=f.get(m);if(u){const c=u.indexOf(b);c!==-1&&u.splice(c,1)}},d=(m,b,u)=>{f.has(m)&&setTimeout(()=>{f.get(m).forEach(c=>{if(n){const v=Array.isArray(b)?b.map(E=>n.serialize(E)):n.serialize(b),T=u?u instanceof PointerEvent?u:n.serialize(u):void 0;c(v,T)}else c(b,u)})},1)};r.subscribe(({selected:m})=>{if(!(p.length===0&&m.length===0)){if(p.length===0&&m.length>0)p=m.map(({id:b})=>i.getAnnotation(b));else if(p.length>0&&m.length===0)p.forEach(b=>{const u=i.getAnnotation(b.id);u&&!J(u,b)&&d("updateAnnotation",u,b)}),p=[];else{const b=new Set(p.map(c=>c.id)),u=new Set(m.map(({id:c})=>c));p.filter(c=>!u.has(c.id)).forEach(c=>{const v=i.getAnnotation(c.id);v&&!J(v,c)&&d("updateAnnotation",v,c)}),p=[...p.filter(c=>u.has(c.id)),...m.filter(({id:c})=>!b.has(c)).map(({id:c})=>i.getAnnotation(c))]}d("selectionChanged",p)}}),s.subscribe(m=>{!h&&m?d("mouseEnterAnnotation",i.getAnnotation(m)):h&&!m?d("mouseLeaveAnnotation",i.getAnnotation(h)):h&&m&&(d("mouseLeaveAnnotation",i.getAnnotation(h)),d("mouseEnterAnnotation",i.getAnnotation(m))),h=m}),a==null||a.subscribe(m=>d("viewportIntersect",m.map(b=>i.getAnnotation(b)))),i.observe(m=>{const{created:b,deleted:u}=m.changes;(b||[]).forEach(c=>d("createAnnotation",c)),(u||[]).forEach(c=>d("deleteAnnotation",c)),(m.changes.updated||[]).filter(c=>[...c.bodiesCreated||[],...c.bodiesDeleted||[],...c.bodiesUpdated||[]].length>0).forEach(({oldValue:c,newValue:v})=>{const T=p.find(E=>E.id===c.id)||c;p=p.map(E=>E.id===c.id?v:E),d("updateAnnotation",v,T)})},{origin:O.LOCAL}),i.observe(m=>{if(p){const b=new Set(p.map(c=>c.id)),u=(m.changes.updated||[]).filter(({newValue:c})=>b.has(c.id)).map(({newValue:c})=>c);u.length>0&&(p=p.map(c=>u.find(T=>T.id===c.id)||c))}},{origin:O.REMOTE});const A=m=>b=>{const{updated:u}=b;m?(u||[]).forEach(c=>d("updateAnnotation",c.oldValue,c.newValue)):(u||[]).forEach(c=>d("updateAnnotation",c.newValue,c.oldValue))};return t.on("undo",A(!0)),t.on("redo",A(!1)),{on:l,off:g,emit:d}},Dn=e=>t=>t.reduce((n,o)=>{const{parsed:i,error:r}=e.parse(o);return r?{parsed:n.parsed,failed:[...n.failed,o]}:i?{parsed:[...n.parsed,i],failed:n.failed}:{...n}},{parsed:[],failed:[]}),Un=(e,t,n)=>{const{store:o,selection:i}=e,r=u=>{if(n){const{parsed:c,error:v}=n.parse(u);c?o.addAnnotation(c,O.REMOTE):console.error(v)}else o.addAnnotation(u,O.REMOTE)},s=()=>i.clear(),a=()=>o.clear(),f=u=>{const c=o.getAnnotation(u);return n&&c?n.serialize(c):c},p=()=>n?o.all().map(n.serialize):o.all(),h=()=>{var u;const c=(((u=i.selected)==null?void 0:u.map(v=>v.id))||[]).map(v=>o.getAnnotation(v)).filter(Boolean);return n?c.map(n.serialize):c},l=(u,c=!0)=>fetch(u).then(v=>v.json()).then(v=>(d(v,c),v)),g=u=>{if(typeof u=="string"){const c=o.getAnnotation(u);if(o.deleteAnnotation(u),c)return n?n.serialize(c):c}else{const c=n?n.parse(u).parsed:u;if(c)return o.deleteAnnotation(c),u}},d=(u,c=!0)=>{if(n){const{parsed:v,failed:T}=Dn(n)(u);T.length>0&&console.warn(`Discarded ${T.length} invalid annotations`,T),o.bulkAddAnnotation(v,c,O.REMOTE)}else o.bulkAddAnnotation(u,c,O.REMOTE)},A=(u,c)=>{u?i.setSelected(u,c):i.clear()},m=u=>{i.clear(),i.setUserSelectAction(u)},b=u=>{if(n){const c=n.parse(u).parsed,v=n.serialize(o.getAnnotation(c.id));return o.updateAnnotation(c),v}else{const c=o.getAnnotation(u.id);return o.updateAnnotation(u),c}};return{addAnnotation:r,cancelSelected:s,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:f,getAnnotations:p,getSelected:h,loadAnnotations:l,redo:t.redo,removeAnnotation:g,setAnnotations:d,setSelected:A,setUserSelectAction:m,undo:t.undo,updateAnnotation:b}},_n="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Hn=e=>crypto.getRandomValues(new Uint8Array(e)),Yn=(e,t,n)=>{let o=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*o*t/e.length);return(r=t)=>{let s="";for(;;){let a=n(i),f=i;for(;f--;)if(s+=e[a[f]&o]||"",s.length===r)return s}}},Xn=(e,t=21)=>Yn(e,t,Hn),$n=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=_n[n[e]&63];return t};const jn=()=>({isGuest:!0,id:Xn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Wn=e=>{const t=JSON.stringify(e);let n=0;for(let o=0,i=t.length;o<i;o++){let r=t.charCodeAt(o);n=(n<<5)-n+r,n|=0}return`${n}`},Te=e=>e?typeof e=="object"?{...e}:e:void 0,Gn=(e,t)=>(Array.isArray(e)?e:[e]).map(n=>{const{id:o,type:i,purpose:r,value:s,created:a,modified:f,creator:p,...h}=n;return{id:o||`temp-${Wn(n)}`,annotation:t,type:i,purpose:r,value:s,creator:Te(p),created:a?new Date(a):void 0,updated:f?new Date(f):void 0,...h}}),zn=e=>e.map(t=>{var n;const{annotation:o,created:i,updated:r,...s}=t,a={...s,created:i==null?void 0:i.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=a.id)!=null&&n.startsWith("temp-")&&delete a.id,a});$n();const qn=(e,t)=>({parse:n=>Ee(n),serialize:n=>Le(n,e,t)}),Zn=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,Jn=e=>{const{id:t,creator:n,created:o,modified:i,target:r}=e,s=Array.isArray(r)?r:[r];if(s.length===0)return{error:Error(`No targets found for annotation: ${e.id}`)};const a={creator:Te(n),created:o?new Date(o):void 0,updated:i?new Date(i):void 0,annotation:t,selector:[],styleClass:s[0].styleClass};for(const f of s){const h=(Array.isArray(f.selector)?f.selector:[f.selector]).reduce((l,g)=>{switch(g.type){case"TextQuoteSelector":l.quote=g.exact;break;case"TextPositionSelector":l.start=g.start,l.end=g.end;break}return l},{});if(Zn(h))a.selector.push({id:f.id,...h});else{const l=[h.start?void 0:"TextPositionSelector",h.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${l.join(" and ")} for annotation: ${e.id}`)}}}return{parsed:a}},Ee=e=>{const t=e.id||be(),{creator:n,created:o,modified:i,body:r,...s}=e,a=Gn(r,t),f=Jn(e);return"error"in f?{error:f.error}:{parsed:{...s,id:t,bodies:a,target:f.parsed}}},Le=(e,t,n)=>{const{bodies:o,target:i,...r}=e,{selector:s,creator:a,created:f,updated:p,...h}=i,l=s.map(g=>{const{quote:d,start:A,end:m,range:b}=g,{prefix:u,suffix:c}=Wt(b,n),v=[{type:"TextQuoteSelector",exact:d,prefix:u,suffix:c},{type:"TextPositionSelector",start:A,end:m}];return{...h,id:g.id,source:t,selector:v}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:zn(e.bodies),creator:a,created:f==null?void 0:f.toISOString(),modified:p==null?void 0:p.toISOString(),target:l}};function Qn(e,t,n,o,i){xe(e,t,n||0,o||e.length-1,i||Kn)}function xe(e,t,n,o,i){for(;o>n;){if(o-n>600){var r=o-n+1,s=t-n+1,a=Math.log(r),f=.5*Math.exp(2*a/3),p=.5*Math.sqrt(a*f*(r-f)/r)*(s-r/2<0?-1:1),h=Math.max(n,Math.floor(t-s*f/r+p)),l=Math.min(o,Math.floor(t+(r-s)*f/r+p));xe(e,t,h,l,i)}var g=e[t],d=n,A=o;for(it(e,n,t),i(e[o],g)>0&&it(e,n,o);d<A;){for(it(e,d,A),d++,A--;i(e[d],g)<0;)d++;for(;i(e[A],g)>0;)A--}i(e[n],g)===0?it(e,n,A):(A++,it(e,A,o)),A<=t&&(n=A+1),t<=A&&(o=A-1)}}function it(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function Kn(e,t){return e<t?-1:e>t?1:0}class to{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const o=[];if(!At(t,n))return o;const i=this.toBBox,r=[];for(;n;){for(let s=0;s<n.children.length;s++){const a=n.children[s],f=n.leaf?i(a):a;At(t,f)&&(n.leaf?o.push(a):Ft(t,f)?this._all(a,o):r.push(a))}n=r.pop()}return o}collides(t){let n=this.data;if(!At(t,n))return!1;const o=[];for(;n;){for(let i=0;i<n.children.length;i++){const r=n.children[i],s=n.leaf?this.toBBox(r):r;if(At(t,s)){if(n.leaf||Ft(t,s))return!0;o.push(r)}}n=o.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let o=0;o<t.length;o++)this.insert(t[o]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const o=this.data;this.data=n,n=o}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=tt([]),this}remove(t,n){if(!t)return this;let o=this.data;const i=this.toBBox(t),r=[],s=[];let a,f,p;for(;o||r.length;){if(o||(o=r.pop(),f=r[r.length-1],a=s.pop(),p=!0),o.leaf){const h=eo(t,o.children,n);if(h!==-1)return o.children.splice(h,1),r.push(o),this._condense(r),this}!p&&!o.leaf&&Ft(o,i)?(r.push(o),s.push(a),a=0,f=o,o=o.children[0]):f?(a++,o=f.children[a],p=!1):o=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const o=[];for(;t;)t.leaf?n.push(...t.children):o.push(...t.children),t=o.pop();return n}_build(t,n,o,i){const r=o-n+1;let s=this._maxEntries,a;if(r<=s)return a=tt(t.slice(n,o+1)),K(a,this.toBBox),a;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),a=tt([]),a.leaf=!1,a.height=i;const f=Math.ceil(r/s),p=f*Math.ceil(Math.sqrt(s));Me(t,n,o,p,this.compareMinX);for(let h=n;h<=o;h+=p){const l=Math.min(h+p-1,o);Me(t,h,l,f,this.compareMinY);for(let g=h;g<=l;g+=f){const d=Math.min(g+f-1,l);a.children.push(this._build(t,g,d,i-1))}}return K(a,this.toBBox),a}_chooseSubtree(t,n,o,i){for(;i.push(n),!(n.leaf||i.length-1===o);){let r=1/0,s=1/0,a;for(let f=0;f<n.children.length;f++){const p=n.children[f],h=Nt(p),l=io(t,p)-h;l<s?(s=l,r=h<r?h:r,a=p):l===s&&h<r&&(r=h,a=p)}n=a||n.children[0]}return n}_insert(t,n,o){const i=o?t:this.toBBox(t),r=[],s=this._chooseSubtree(i,this.data,n,r);for(s.children.push(t),at(s,i);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(i,r,n)}_split(t,n){const o=t[n],i=o.children.length,r=this._minEntries;this._chooseSplitAxis(o,r,i);const s=this._chooseSplitIndex(o,r,i),a=tt(o.children.splice(s,o.children.length-s));a.height=o.height,a.leaf=o.leaf,K(o,this.toBBox),K(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(o,a)}_splitRoot(t,n){this.data=tt([t,n]),this.data.height=t.height+1,this.data.leaf=!1,K(this.data,this.toBBox)}_chooseSplitIndex(t,n,o){let i,r=1/0,s=1/0;for(let a=n;a<=o-n;a++){const f=rt(t,0,a,this.toBBox),p=rt(t,a,o,this.toBBox),h=ro(f,p),l=Nt(f)+Nt(p);h<r?(r=h,i=a,s=l<s?l:s):h===r&&l<s&&(s=l,i=a)}return i||o-n}_chooseSplitAxis(t,n,o){const i=t.leaf?this.compareMinX:no,r=t.leaf?this.compareMinY:oo,s=this._allDistMargin(t,n,o,i),a=this._allDistMargin(t,n,o,r);s<a&&t.children.sort(i)}_allDistMargin(t,n,o,i){t.children.sort(i);const r=this.toBBox,s=rt(t,0,n,r),a=rt(t,o-n,o,r);let f=wt(s)+wt(a);for(let p=n;p<o-n;p++){const h=t.children[p];at(s,t.leaf?r(h):h),f+=wt(s)}for(let p=o-n-1;p>=n;p--){const h=t.children[p];at(a,t.leaf?r(h):h),f+=wt(a)}return f}_adjustParentBBoxes(t,n,o){for(let i=o;i>=0;i--)at(n[i],t)}_condense(t){for(let n=t.length-1,o;n>=0;n--)t[n].children.length===0?n>0?(o=t[n-1].children,o.splice(o.indexOf(t[n]),1)):this.clear():K(t[n],this.toBBox)}}function eo(e,t,n){if(!n)return t.indexOf(e);for(let o=0;o<t.length;o++)if(n(e,t[o]))return o;return-1}function K(e,t){rt(e,0,e.children.length,t,e)}function rt(e,t,n,o,i){i||(i=tt(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=t;r<n;r++){const s=e.children[r];at(i,e.leaf?o(s):s)}return i}function at(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function no(e,t){return e.minX-t.minX}function oo(e,t){return e.minY-t.minY}function Nt(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function wt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function io(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function ro(e,t){const n=Math.max(e.minX,t.minX),o=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,i-n)*Math.max(0,r-o)}function Ft(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function At(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function tt(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Me(e,t,n,o,i){const r=[t,n];for(;r.length;){if(n=r.pop(),t=r.pop(),n-t<=o)continue;const s=t+Math.ceil((n-t)/o/2)*o;Qn(e,s,t,n,i),r.push(t,s,s,n)}}const ao=(e,t)=>{const n=new to,o=new Map,i=(u,c)=>{const v=u.selector.flatMap(E=>{const M=j([E])?E.range:Ct(E,t).range;return Array.from(M.getClientRects())}),T=qt(v).map(E=>Jt(E,c));return T.map(E=>{const{x:M,y:k,width:B,height:U}=E;return{minX:M,minY:k,maxX:M+B,maxY:k+U,annotation:{id:u.annotation,rects:T}}})},r=()=>[...o.values()],s=()=>{n.clear(),o.clear()},a=u=>{const c=i(u,t.getBoundingClientRect());c.forEach(v=>n.insert(v)),o.set(u.annotation,c)},f=u=>{const c=o.get(u.annotation);c&&(c.forEach(v=>n.remove(v)),o.delete(u.annotation))},p=u=>{f(u),a(u)},h=(u,c=!0)=>{c&&s();const v=t.getBoundingClientRect(),T=u.map(M=>({target:M,rects:i(M,v)}));T.forEach(({target:M,rects:k})=>o.set(M.annotation,k));const E=T.flatMap(({rects:M})=>M);n.load(E)},l=(u,c,v=!1)=>{const T=n.search({minX:u,minY:c,maxX:u,maxY:c}),E=M=>M.annotation.rects.reduce((k,B)=>k+B.width*B.height,0);return T.length>0?(T.sort((M,k)=>E(M)-E(k)),v?T.map(M=>M.annotation.id):[T[0].annotation.id]):[]},g=u=>{const c=d(u);if(c.length===0)return;let v=c[0].left,T=c[0].top,E=c[0].right,M=c[0].bottom;for(let k=1;k<c.length;k++){const B=c[k];v=Math.min(v,B.left),T=Math.min(T,B.top),E=Math.max(E,B.right),M=Math.max(M,B.bottom)}return new DOMRect(v,T,E-v,M-T)},d=u=>{const c=o.get(u);return c?c[0].annotation.rects:[]};return{all:r,clear:s,getAt:l,getAnnotationBounds:g,getAnnotationRects:d,getIntersecting:(u,c,v,T)=>{const E=n.search({minX:u,minY:c,maxX:v,maxY:T}),M=new Set(E.map(k=>k.annotation.id));return Array.from(M).map(k=>({annotation:e.getAnnotation(k),rects:d(k)})).filter(k=>!!k.annotation)},insert:a,recalculate:()=>h(e.all().map(u=>u.target),!0),remove:f,set:h,size:()=>n.all().length,update:p}},Be=(e,t)=>{const n=Vn(),o=ao(n,e),i=wn(n,t),r=bn(n),s=Pn(),a=(m,b=O.LOCAL)=>{const u=ht(m,e),c=j(u.target.selector);return c&&n.addAnnotation(u,b),c},f=(m,b=!0,u=O.LOCAL)=>{const c=m.map(T=>ht(T,e)),v=c.filter(T=>!j(T.target.selector));return v.length>0?(console.warn("Could not revive all targets for these annotations:",v),n.bulkAddAnnotation(c,b,u),v):(n.bulkAddAnnotation(c,b,u),[])},p=(m,b=O.LOCAL)=>{const u=m.map(v=>ht(v,e)),c=u.filter(v=>!j(v.target.selector));return c.length>0&&console.warn("Could not revive all targets for these annotations:",c),u.forEach(v=>{n.getAnnotation(v.id)?n.updateAnnotation(v,b):n.addAnnotation(v,b)}),c},h=(m,b=O.LOCAL)=>{const u=nt(m,e);n.updateTarget(u,b)},l=(m,b=O.LOCAL)=>{const u=m.map(c=>nt(c,e));n.bulkUpdateTargets(u,b)},g=(m,b,u)=>{const c=o.getAt(m,b,!!u).map(T=>n.getAnnotation(T)),v=u?c.filter(u):c;return v.length>0?v[0]:void 0},d=(m,b,u,c=5)=>{const v=o.getAnnotationRects(m);if(v.length!==0){if(b&&u){const T=v.find(({top:E,right:M,bottom:k,left:B})=>b>=B-c&&b<=M+c&&u>=E-c&&u<=k+c);if(T)return T}return o.getAnnotationBounds(m)}},A=()=>o.recalculate();return n.observe(({changes:m})=>{const b=(m.deleted||[]).filter(v=>j(v.target.selector)),u=(m.created||[]).filter(v=>j(v.target.selector)),c=(m.updated||[]).filter(v=>j(v.newValue.target.selector));(b==null?void 0:b.length)>0&&b.forEach(v=>o.remove(v.target)),u.length>0&&o.set(u.map(v=>v.target),!1),(c==null?void 0:c.length)>0&&c.forEach(({newValue:v})=>o.update(v.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotation:f,bulkUpdateTargets:l,bulkUpsertAnnotations:p,getAnnotationBounds:d,getAt:g,getIntersecting:o.getIntersecting.bind(o),getAnnotationRects:o.getAnnotationRects.bind(o),recalculatePositions:A,updateTarget:h},selection:i,hover:r,viewport:s}},so=()=>{const e=document.createElement("canvas");e.width=2*window.innerWidth,e.height=2*window.innerHeight,e.className="r6o-presence-layer";const t=e.getContext("2d");return t.scale(2,2),t.translate(.5,.5),e},lo=(e,t,n={})=>{const o=so(),i=o.getContext("2d");document.body.appendChild(o);const r=new Map,s=l=>Array.from(r.entries()).filter(([g,d])=>d.presenceKey===l.presenceKey).map(([g,d])=>g);return t.on("selectionChange",(l,g)=>{s(l).forEach(A=>r.delete(A)),g&&g.forEach(A=>r.set(A,l))}),{clear:()=>{const{width:l,height:g}=o;i.clearRect(-.5,-.5,l+1,g+1)},destroy:()=>{o.remove()},paint:(l,g,d)=>{n.font&&(i.font=n.font);const A=r.get(l.annotation.id);if(A){const{height:m}=l.rects[0],b=l.rects[0].x+g.left,u=l.rects[0].y+g.top;i.fillStyle=A.appearance.color,i.fillRect(b-2,u-2.5,2,m+5);const c=i.measureText(A.appearance.label),v=c.width+6,T=c.actualBoundingBoxAscent+c.actualBoundingBoxDescent+8,E=c.fontBoundingBoxAscent?8:6.5;return i.fillRect(b-2,u-2.5-T,v,T),i.fillStyle="#fff",i.fillText(A.appearance.label,b+1,u-E),{fill:A.appearance.color,fillOpacity:d?.45:.18}}},reset:()=>{o.width=2*window.innerWidth,o.height=2*window.innerHeight;const l=o.getContext("2d");l.scale(2,2),l.translate(.5,.5)}}},Re=e=>{if(e===null)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:Re(e.parentElement)},co=(e,t)=>n=>{const o=typeof n=="string"?n:n.id,i=s=>{const a=r.getBoundingClientRect(),f=r.clientHeight,p=r.clientWidth,h=s.selector[0].range.getBoundingClientRect(),{width:l,height:g}=t.getAnnotationBounds(o),d=h.top-a.top,A=h.left-a.left,m=r.parentElement?r.scrollTop:0,b=r.parentElement?r.scrollLeft:0,u=d+m-(f-g)/2,c=A+b-(p-l)/2;r.scroll({top:u,left:c,behavior:"smooth"})},r=Re(e);if(r){const s=t.getAnnotation(o),{range:a}=s.target.selector[0];if(a&&!a.collapsed)return i(s.target),!0;{const f=nt(s.target,e),{range:p}=f.selector[0];if(p&&!p.collapsed)return i(f),!0}}return!1},ke=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),It=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Pt(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on".concat(t),n)}function st(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Oe(e,t){const n=t.slice(0,t.length-1);for(let o=0;o<n.length;o++)n[o]=e[n[o].toLowerCase()];return n}function Ve(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function uo(e,t){const n=e.length>=t.length?e:t,o=e.length>=t.length?t:e;let i=!0;for(let r=0;r<n.length;r++)o.indexOf(n[r])===-1&&(i=!1);return i}const lt={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":It?173:189,"=":It?61:187,";":It?59:186,"'":222,"[":219,"]":221,"\\":220},W={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},yt={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},D={16:!1,18:!1,17:!1,91:!1},N={};for(let e=1;e<20;e++)lt["f".concat(e)]=111+e;let V=[],ct=null,Ne="all";const z=new Map,dt=e=>lt[e.toLowerCase()]||W[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),fo=e=>Object.keys(lt).find(t=>lt[t]===e),po=e=>Object.keys(W).find(t=>W[t]===e);function Fe(e){Ne=e||"all"}function ut(){return Ne||"all"}function ho(){return V.slice(0)}function go(){return V.map(e=>fo(e)||po(e)||String.fromCharCode(e))}function mo(){const e=[];return Object.keys(N).forEach(t=>{N[t].forEach(n=>{let{key:o,scope:i,mods:r,shortcut:s}=n;e.push({scope:i,shortcut:s,mods:r,keys:o.split("+").map(a=>dt(a))})})}),e}function bo(e){const t=e.target||e.srcElement,{tagName:n}=t;let o=!0;const i=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(i||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(o=!1),o}function wo(e){return typeof e=="string"&&(e=dt(e)),V.indexOf(e)!==-1}function Ao(e,t){let n,o;e||(e=ut());for(const i in N)if(Object.prototype.hasOwnProperty.call(N,i))for(n=N[i],o=0;o<n.length;)n[o].scope===e?n.splice(o,1).forEach(s=>{let{element:a}=s;return Dt(a)}):o++;ut()===e&&Fe(t||"all")}function vo(e){let t=e.keyCode||e.which||e.charCode;const n=V.indexOf(t);if(n>=0&&V.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&V.splice(0,V.length),(t===93||t===224)&&(t=91),t in D){D[t]=!1;for(const o in W)W[o]===t&&(_[o]=!1)}}function Ie(e){if(typeof e>"u")Object.keys(N).forEach(i=>{Array.isArray(N[i])&&N[i].forEach(r=>vt(r)),delete N[i]}),Dt(null);else if(Array.isArray(e))e.forEach(i=>{i.key&&vt(i)});else if(typeof e=="object")e.key&&vt(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];let[i,r]=n;typeof i=="function"&&(r=i,i=""),vt({key:e,scope:i,method:r,splitKey:"+"})}}const vt=e=>{let{key:t,scope:n,method:o,splitKey:i="+"}=e;Ve(t).forEach(s=>{const a=s.split(i),f=a.length,p=a[f-1],h=p==="*"?"*":dt(p);if(!N[h])return;n||(n=ut());const l=f>1?Oe(W,a):[],g=[];N[h]=N[h].filter(d=>{const m=(o?d.method===o:!0)&&d.scope===n&&uo(d.mods,l);return m&&g.push(d.element),!m}),g.forEach(d=>Dt(d))})};function Pe(e,t,n,o){if(t.element!==o)return;let i;if(t.scope===n||t.scope==="all"){i=t.mods.length>0;for(const r in D)Object.prototype.hasOwnProperty.call(D,r)&&(!D[r]&&t.mods.indexOf(+r)>-1||D[r]&&t.mods.indexOf(+r)===-1)&&(i=!1);(t.mods.length===0&&!D[16]&&!D[18]&&!D[17]&&!D[91]||i||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(V),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function ye(e,t){const n=N["*"];let o=e.keyCode||e.which||e.charCode;if(!_.filter.call(this,e))return;if((o===93||o===224)&&(o=91),V.indexOf(o)===-1&&o!==229&&V.push(o),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const f=yt[a];e[a]&&V.indexOf(f)===-1?V.push(f):!e[a]&&V.indexOf(f)>-1?V.splice(V.indexOf(f),1):a==="metaKey"&&e[a]&&V.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(V=V.slice(V.indexOf(f))))}),o in D){D[o]=!0;for(const a in W)W[a]===o&&(_[a]=!0);if(!n)return}for(const a in D)Object.prototype.hasOwnProperty.call(D,a)&&(D[a]=e[yt[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(V.indexOf(17)===-1&&V.push(17),V.indexOf(18)===-1&&V.push(18),D[17]=!0,D[18]=!0);const i=ut();if(n)for(let a=0;a<n.length;a++)n[a].scope===i&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&Pe(e,n[a],i,t);if(!(o in N))return;const r=N[o],s=r.length;for(let a=0;a<s;a++)if((e.type==="keydown"&&r[a].keydown||e.type==="keyup"&&r[a].keyup)&&r[a].key){const f=r[a],{splitKey:p}=f,h=f.key.split(p),l=[];for(let g=0;g<h.length;g++)l.push(dt(h[g]));l.sort().join("")===V.sort().join("")&&Pe(e,f,i,t)}}function _(e,t,n){V=[];const o=Ve(e);let i=[],r="all",s=document,a=0,f=!1,p=!0,h="+",l=!1,g=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(r=t.scope),t.element&&(s=t.element),t.keyup&&(f=t.keyup),t.keydown!==void 0&&(p=t.keydown),t.capture!==void 0&&(l=t.capture),typeof t.splitKey=="string"&&(h=t.splitKey),t.single===!0&&(g=!0)),typeof t=="string"&&(r=t),g&&Ie(e,r);a<o.length;a++)e=o[a].split(h),i=[],e.length>1&&(i=Oe(W,e)),e=e[e.length-1],e=e==="*"?"*":dt(e),e in N||(N[e]=[]),N[e].push({keyup:f,keydown:p,scope:r,mods:i,shortcut:o[a],method:n,key:o[a],splitKey:h,element:s});if(typeof s<"u"&&window){if(!z.has(s)){const d=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return ye(m,s)},A=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;ye(m,s),vo(m)};z.set(s,{keydownListener:d,keyupListenr:A,capture:l}),Pt(s,"keydown",d,l),Pt(s,"keyup",A,l)}if(!ct){const d=()=>{V=[]};ct={listener:d,capture:l},Pt(window,"focus",d,l)}}}function So(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(N).forEach(n=>{N[n].filter(i=>i.scope===t&&i.shortcut===e).forEach(i=>{i&&i.method&&i.method()})})}function Dt(e){const t=Object.values(N).flat();if(t.findIndex(o=>{let{element:i}=o;return i===e})<0){const{keydownListener:o,keyupListenr:i,capture:r}=z.get(e)||{};o&&i&&(st(e,"keyup",i,r),st(e,"keydown",o,r),z.delete(e))}if((t.length<=0||z.size<=0)&&(Object.keys(z).forEach(i=>{const{keydownListener:r,keyupListenr:s,capture:a}=z.get(i)||{};r&&s&&(st(i,"keyup",s,a),st(i,"keydown",r,a),z.delete(i))}),z.clear(),Object.keys(N).forEach(i=>delete N[i]),ct)){const{listener:i,capture:r}=ct;st(window,"focus",i,r),ct=null}}const Ut={getPressedKeyString:go,setScope:Fe,getScope:ut,deleteScope:Ao,getPressedKeyCodes:ho,getAllKeyCodes:mo,isPressed:wo,filter:bo,trigger:So,unbind:Ie,keyMap:lt,modifier:W,modifierMap:yt};for(const e in Ut)Object.prototype.hasOwnProperty.call(Ut,e)&&(_[e]=Ut[e]);if(typeof window<"u"){const e=window.hotkeys;_.noConflict=t=>(t&&window.hotkeys===_&&(window.hotkeys=e),_),window.hotkeys=_}var De={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.Unidentified="Unidentified",t.Alt="Alt",t.AltGraph="AltGraph",t.CapsLock="CapsLock",t.Control="Control",t.Fn="Fn",t.FnLock="FnLock",t.Hyper="Hyper",t.Meta="Meta",t.NumLock="NumLock",t.ScrollLock="ScrollLock",t.Shift="Shift",t.Super="Super",t.Symbol="Symbol",t.SymbolLock="SymbolLock",t.Enter="Enter",t.Tab="Tab",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.ArrowUp="ArrowUp",t.End="End",t.Home="Home",t.PageDown="PageDown",t.PageUp="PageUp",t.Backspace="Backspace",t.Clear="Clear",t.Copy="Copy",t.CrSel="CrSel",t.Cut="Cut",t.Delete="Delete",t.EraseEof="EraseEof",t.ExSel="ExSel",t.Insert="Insert",t.Paste="Paste",t.Redo="Redo",t.Undo="Undo",t.Accept="Accept",t.Again="Again",t.Attn="Attn",t.Cancel="Cancel",t.ContextMenu="ContextMenu",t.Escape="Escape",t.Execute="Execute",t.Find="Find",t.Finish="Finish",t.Help="Help",t.Pause="Pause",t.Play="Play",t.Props="Props",t.Select="Select",t.ZoomIn="ZoomIn",t.ZoomOut="ZoomOut",t.BrightnessDown="BrightnessDown",t.BrightnessUp="BrightnessUp",t.Eject="Eject",t.LogOff="LogOff",t.Power="Power",t.PowerOff="PowerOff",t.PrintScreen="PrintScreen",t.Hibernate="Hibernate",t.Standby="Standby",t.WakeUp="WakeUp",t.AllCandidates="AllCandidates",t.Alphanumeric="Alphanumeric",t.CodeInput="CodeInput",t.Compose="Compose",t.Convert="Convert",t.Dead="Dead",t.FinalMode="FinalMode",t.GroupFirst="GroupFirst",t.GroupLast="GroupLast",t.GroupNext="GroupNext",t.GroupPrevious="GroupPrevious",t.ModeChange="ModeChange",t.NextCandidate="NextCandidate",t.NonConvert="NonConvert",t.PreviousCandidate="PreviousCandidate",t.Process="Process",t.SingleCandidate="SingleCandidate",t.HangulMode="HangulMode",t.HanjaMode="HanjaMode",t.JunjaMode="JunjaMode",t.Eisu="Eisu",t.Hankaku="Hankaku",t.Hiragana="Hiragana",t.HiraganaKatakana="HiraganaKatakana",t.KanaMode="KanaMode",t.KanjiMode="KanjiMode",t.Katakana="Katakana",t.Romaji="Romaji",t.Zenkaku="Zenkaku",t.ZenkakuHanaku="ZenkakuHanaku",t.F1="F1",t.F2="F2",t.F3="F3",t.F4="F4",t.F5="F5",t.F6="F6",t.F7="F7",t.F8="F8",t.F9="F9",t.F10="F10",t.F11="F11",t.F12="F12",t.F13="F13",t.F14="F14",t.F15="F15",t.F16="F16",t.F17="F17",t.F18="F18",t.F19="F19",t.F20="F20",t.Soft1="Soft1",t.Soft2="Soft2",t.Soft3="Soft3",t.Soft4="Soft4",t.AppSwitch="AppSwitch",t.Call="Call",t.Camera="Camera",t.CameraFocus="CameraFocus",t.EndCall="EndCall",t.GoBack="GoBack",t.GoHome="GoHome",t.HeadsetHook="HeadsetHook",t.LastNumberRedial="LastNumberRedial",t.Notification="Notification",t.MannerMode="MannerMode",t.VoiceDial="VoiceDial",t.ChannelDown="ChannelDown",t.ChannelUp="ChannelUp",t.MediaFastForward="MediaFastForward",t.MediaPause="MediaPause",t.MediaPlay="MediaPlay",t.MediaPlayPause="MediaPlayPause",t.MediaRecord="MediaRecord",t.MediaRewind="MediaRewind",t.MediaStop="MediaStop",t.MediaTrackNext="MediaTrackNext",t.MediaTrackPrevious="MediaTrackPrevious",t.AudioBalanceLeft="AudioBalanceLeft",t.AudioBalanceRight="AudioBalanceRight",t.AudioBassDown="AudioBassDown",t.AudioBassBoostDown="AudioBassBoostDown",t.AudioBassBoostToggle="AudioBassBoostToggle",t.AudioBassBoostUp="AudioBassBoostUp",t.AudioBassUp="AudioBassUp",t.AudioFaderFront="AudioFaderFront",t.AudioFaderRear="AudioFaderRear",t.AudioSurroundModeNext="AudioSurroundModeNext",t.AudioTrebleDown="AudioTrebleDown",t.AudioTrebleUp="AudioTrebleUp",t.AudioVolumeDown="AudioVolumeDown",t.AudioVolumeMute="AudioVolumeMute",t.AudioVolumeUp="AudioVolumeUp",t.MicrophoneToggle="MicrophoneToggle",t.MicrophoneVolumeDown="MicrophoneVolumeDown",t.MicrophoneVolumeMute="MicrophoneVolumeMute",t.MicrophoneVolumeUp="MicrophoneVolumeUp",t.TV="TV",t.TV3DMode="TV3DMode",t.TVAntennaCable="TVAntennaCable",t.TVAudioDescription="TVAudioDescription",t.TVAudioDescriptionMixDown="TVAudioDescriptionMixDown",t.TVAudioDescriptionMixUp="TVAudioDescriptionMixUp",t.TVContentsMenu="TVContentsMenu",t.TVDataService="TVDataService",t.TVInput="TVInput",t.TVInputComponent1="TVInputComponent1",t.TVInputComponent2="TVInputComponent2",t.TVInputComposite1="TVInputComposite1",t.TVInputComposite2="TVInputComposite2",t.TVInputHDMI1="TVInputHDMI1",t.TVInputHDMI2="TVInputHDMI2",t.TVInputHDMI3="TVInputHDMI3",t.TVInputHDMI4="TVInputHDMI4",t.TVInputVGA1="TVInputVGA1",t.TVMediaContext="TVMediaContext",t.TVNetwork="TVNetwork",t.TVNumberEntry="TVNumberEntry",t.TVPower="TVPower",t.TVRadioService="TVRadioService",t.TVSatellite="TVSatellite",t.TVSatelliteBS="TVSatelliteBS",t.TVSatelliteCS="TVSatelliteCS",t.TVSatelliteToggle="TVSatelliteToggle",t.TVTerrestrialAnalog="TVTerrestrialAnalog",t.TVTerrestrialDigital="TVTerrestrialDigital",t.TVTimer="TVTimer",t.AVRInput="AVRInput",t.AVRPower="AVRPower",t.ColorF0Red="ColorF0Red",t.ColorF1Green="ColorF1Green",t.ColorF2Yellow="ColorF2Yellow",t.ColorF3Blue="ColorF3Blue",t.ColorF4Grey="ColorF4Grey",t.ColorF5Brown="ColorF5Brown",t.ClosedCaptionToggle="ClosedCaptionToggle",t.Dimmer="Dimmer",t.DisplaySwap="DisplaySwap",t.DVR="DVR",t.Exit="Exit",t.FavoriteClear0="FavoriteClear0",t.FavoriteClear1="FavoriteClear1",t.FavoriteClear2="FavoriteClear2",t.FavoriteClear3="FavoriteClear3",t.FavoriteRecall0="FavoriteRecall0",t.FavoriteRecall1="FavoriteRecall1",t.FavoriteRecall2="FavoriteRecall2",t.FavoriteRecall3="FavoriteRecall3",t.FavoriteStore0="FavoriteStore0",t.FavoriteStore1="FavoriteStore1",t.FavoriteStore2="FavoriteStore2",t.FavoriteStore3="FavoriteStore3",t.Guide="Guide",t.GuideNextDay="GuideNextDay",t.GuidePreviousDay="GuidePreviousDay",t.Info="Info",t.InstantReplay="InstantReplay",t.Link="Link",t.ListProgram="ListProgram",t.LiveContent="LiveContent",t.Lock="Lock",t.MediaApps="MediaApps",t.MediaAudioTrack="MediaAudioTrack",t.MediaLast="MediaLast",t.MediaSkipBackward="MediaSkipBackward",t.MediaSkipForward="MediaSkipForward",t.MediaStepBackward="MediaStepBackward",t.MediaStepForward="MediaStepForward",t.MediaTopMenu="MediaTopMenu",t.NavigateIn="NavigateIn",t.NavigateNext="NavigateNext",t.NavigateOut="NavigateOut",t.NavigatePrevious="NavigatePrevious",t.NextFavoriteChannel="NextFavoriteChannel",t.NextUserProfile="NextUserProfile",t.OnDemand="OnDemand",t.Pairing="Pairing",t.PinPDown="PinPDown",t.PinPMove="PinPMove",t.PinPToggle="PinPToggle",t.PinPUp="PinPUp",t.PlaySpeedDown="PlaySpeedDown",t.PlaySpeedReset="PlaySpeedReset",t.PlaySpeedUp="PlaySpeedUp",t.RandomToggle="RandomToggle",t.RcLowBattery="RcLowBattery",t.RecordSpeedNext="RecordSpeedNext",t.RfBypass="RfBypass",t.ScanChannelsToggle="ScanChannelsToggle",t.ScreenModeNext="ScreenModeNext",t.Settings="Settings",t.SplitScreenToggle="SplitScreenToggle",t.STBInput="STBInput",t.STBPower="STBPower",t.Subtitle="Subtitle",t.Teletext="Teletext",t.VideoModeNext="VideoModeNext",t.Wink="Wink",t.ZoomToggle="ZoomToggle",t.SpeechCorrectionList="SpeechCorrectionList",t.SpeechInputToggle="SpeechInputToggle",t.Close="Close",t.New="New",t.Open="Open",t.Print="Print",t.Save="Save",t.SpellCheck="SpellCheck",t.MailForward="MailForward",t.MailReply="MailReply",t.MailSend="MailSend",t.LaunchCalculator="LaunchCalculator",t.LaunchCalendar="LaunchCalendar",t.LaunchContacts="LaunchContacts",t.LaunchMail="LaunchMail",t.LaunchMediaPlayer="LaunchMediaPlayer",t.LaunchMusicPlayer="LaunchMusicPlayer",t.LaunchMyComputer="LaunchMyComputer",t.LaunchPhone="LaunchPhone",t.LaunchScreenSaver="LaunchScreenSaver",t.LaunchSpreadsheet="LaunchSpreadsheet",t.LaunchWebBrowser="LaunchWebBrowser",t.LaunchWebCam="LaunchWebCam",t.LaunchWordProcessor="LaunchWordProcessor",t.LaunchApplication1="LaunchApplication1",t.LaunchApplication2="LaunchApplication2",t.LaunchApplication3="LaunchApplication3",t.LaunchApplication4="LaunchApplication4",t.LaunchApplication5="LaunchApplication5",t.LaunchApplication6="LaunchApplication6",t.LaunchApplication7="LaunchApplication7",t.LaunchApplication8="LaunchApplication8",t.LaunchApplication9="LaunchApplication9",t.LaunchApplication10="LaunchApplication10",t.LaunchApplication11="LaunchApplication11",t.LaunchApplication12="LaunchApplication12",t.LaunchApplication13="LaunchApplication13",t.LaunchApplication14="LaunchApplication14",t.LaunchApplication15="LaunchApplication15",t.LaunchApplication16="LaunchApplication16",t.BrowserBack="BrowserBack",t.BrowserFavorites="BrowserFavorites",t.BrowserForward="BrowserForward",t.BrowserHome="BrowserHome",t.BrowserRefresh="BrowserRefresh",t.BrowserSearch="BrowserSearch",t.BrowserStop="BrowserStop",t.Decimal="Decimal",t.Key11="Key11",t.Key12="Key12",t.Multiply="Multiply",t.Add="Add",t.Divide="Divide",t.Subtract="Subtract",t.Separator="Separator"}(e.Key||(e.Key={}))})(De);const Co=(e,t,n)=>{let o;const i=T=>o=T;let r;const s=T=>r=T;let a=!0;const f=T=>a=T,{store:p,selection:h}=t;let l,g,d;const A=T=>{var M;if(!a||g===!1)return;l=!((M=T.target.parentElement)!=null&&M.closest(X))?{annotation:be(),selector:[],creator:o,created:new Date}:void 0};e.addEventListener("selectstart",A);const m=pt(T=>{var w,S;if(!a)return;const E=document.getSelection();if(!!((S=(w=E.anchorNode)==null?void 0:w.parentElement)!=null&&S.closest(X))){l=void 0;return}if(T.timeStamp-((d==null?void 0:d.timeStamp)||T.timeStamp)<1e3&&!l&&A(d||T),E.isCollapsed||!l||g===!1)return;const k=E.getRangeAt(0);if(zt(k))return;const B=Ht(k.cloneRange());(B.length!==l.selector.length||B.some((C,L)=>{var R;return C.toString()!==((R=l.selector[L])==null?void 0:R.quote)}))&&(l={...l,selector:B.map(C=>Zt(C,e,n)),updated:new Date},p.getAnnotation(l.annotation)?p.updateTarget(l,O.LOCAL):(h.clear(),p.addAnnotation({id:l.annotation,bodies:[],target:l},O.LOCAL),h.userSelect(l.annotation,d)))});document.addEventListener("selectionchange",m);const b=T=>{d=Qt(T),g=d.button===0};e.addEventListener("pointerdown",b);const u=T=>{var B;if(!!((B=T.target.parentElement)!=null&&B.closest(X))||!g)return;const M=()=>{const{x:U,y:w}=e.getBoundingClientRect(),S=p.getAt(T.clientX-U,T.clientY-w,r);if(S){const{selected:C}=h;(C.length!==1||C[0].id!==S.id)&&h.userSelect(S.id,T)}else h.isEmpty()||h.clear()},k=T.timeStamp-d.timeStamp;document.getSelection().isCollapsed&&k<300?(l=void 0,M()):l&&h.userSelect(l.annotation,T)};document.addEventListener("pointerup",u),_("*",{element:e,keyup:!1,keydown:!0},(T,E)=>{T.repeat||(d=Kt(T))}),_("*",{keyup:!0,keydown:!1},T=>{_.shift&&T.key===De.Key.Shift&&!T.repeat&&l&&h.userSelect(l.annotation,T)});let c=!1;return _("ctrl+a, ⌘+a",{keyup:!1,keydown:!0},()=>{c=!0}),_("*",{keyup:!0,keydown:!1},T=>{c&&!T.repeat&&l&&h.userSelect(l.annotation,T),c=!1}),{destroy:()=>{e.removeEventListener("selectstart",A),document.removeEventListener("selectionchange",m),e.removeEventListener("pointerdown",b),document.removeEventListener("pointerup",u),_.unbind()},setFilter:s,setUser:i,setAnnotatingEnabled:f}},Ue="SPANS",To=(e,t={})=>{Yt(e),Xt(e);const n=ke(t,{annotatingEnabled:!0,user:jn()}),o=Be(e,n.userSelectAction),{selection:i,viewport:r}=o,s=o.store,a=In(s),f=yn(o,a,n.adapter);let p=n.user;const h=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Ue:n.renderer||Ue,l=h==="SPANS"?ge(e,o,r):h==="CSS_HIGHLIGHTS"?pe(e,o,r):h==="CANVAS"?te(e,o,r):void 0;if(!l)throw`Unknown renderer implementation: ${h}`;console.debug(`Using ${h} renderer`),n.style&&l.setStyle(n.style);const g=Co(e,o,n.offsetReferenceSelector);g.setUser(p),g.setAnnotatingEnabled(n.annotatingEnabled);const d=Un(o,a,n.adapter),A=()=>p,m=E=>{g.setAnnotatingEnabled(E)},b=E=>{l.setFilter(E),g.setFilter(E)},u=E=>{p=E,g.setUser(E)},c=E=>{E&&(l.setPainter(lo(e,E,n.presence)),E.on("selectionChange",()=>l.redraw()))},v=E=>{E?i.setSelected(E):i.clear()};return{...d,destroy:()=>{l.destroy(),g.destroy(),a.destroy()},element:e,getUser:A,setAnnotatingEnabled:m,setFilter:b,setStyle:l.setStyle.bind(l),redraw:l.redraw.bind(l),setUser:u,setSelected:v,setPresenceProvider:c,setVisible:l.setVisible.bind(l),on:f.on,off:f.off,scrollIntoView:co(e,s),state:o}};x.DEFAULT_SELECTED_STYLE=et,x.DEFAULT_STYLE=H,x.NOT_ANNOTATABLE_CLASS=St,x.NOT_ANNOTATABLE_SELECTOR=X,x.Origin=O,x.UserSelectAction=Ae,x.W3CTextFormat=qn,x.cancelSingleClickEvents=Yt,x.cloneKeyboardEvent=Kt,x.clonePointerEvent=Qt,x.createBody=En,x.createCanvasRenderer=te,x.createHighlightsRenderer=pe,x.createRenderer=fe,x.createSpansRenderer=ge,x.createTextAnnotator=To,x.createTextAnnotatorState=Be,x.debounce=pt,x.denormalizeRectWithOffset=qe,x.fillDefaults=ke,x.getAnnotatableFragment=Ye,x.getClientRectsPonyfill=je,x.getQuoteContext=Wt,x.getRangeAnnotatableContents=ft,x.isRevived=j,x.isWhitespaceOrEmpty=zt,x.mergeClientRects=qt,x.normalizeRectWithOffset=Jt,x.paint=_t,x.parseW3CTextAnnotation=Ee,x.programmaticallyFocusable=Xt,x.rangeToSelector=Zt,x.reviveAnnotation=ht,x.reviveSelector=Ct,x.reviveTarget=nt,x.serializeW3CTextAnnotation=Le,x.splitAnnotatableRanges=Ht,x.toDomRectList=ze,x.whitespaceOrEmptyRegex=Gt,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(M,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):(M=typeof globalThis<"u"?globalThis:M||self,H(M.RecogitoJS={}))})(this,function(M){"use strict";const H={fill:"rgb(0, 128, 255)",fillOpacity:.18},et={fill:"rgb(0, 128, 255)",fillOpacity:.45},_t=(e,t,n,o,i)=>{var s,a;const r=n?typeof n=="function"?n(e.annotation,e.state,i)||((s=e.state)!=null&&s.selected?et:H):n:(a=e.state)!=null&&a.selected?et:H;return o&&o.paint(e,t)||r},vt="not-annotatable",X=`.${vt}`,He=e=>{var n;const t=e.commonAncestorContainer;return t instanceof HTMLElement?!t.closest(X):!((n=t.parentElement)!=null&&n.closest(X))},Ye=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(vt)&&!o.parentElement.closest(X)&&e.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Ht=e=>{if(!He(e))return[];const t=[];let n=null;for(const o of Ye(e)){let i;n?(i=document.createRange(),i.setStartAfter(n),i.setEndBefore(o)):(i=e.cloneRange(),i.setEndBefore(o)),i.collapsed||t.push(i),n=o}if(n){const o=e.cloneRange();o.setStartAfter(n),o.collapsed||t.push(o)}return t.length>0?t:[e]},ft=e=>{const t=e.cloneContents();return t.querySelectorAll(X).forEach(n=>n.remove()),t},Yt=e=>e.addEventListener("click",t=>{!t.target.closest(X)&&!t.target.closest("a")&&t.preventDefault()}),Xt=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},pt=(e,t=10)=>{let n;return(...o)=>{clearTimeout(n),n=setTimeout(()=>e.apply(void 0,o),t)}},Xe=e=>{const t=e.cloneContents();return t.querySelectorAll(X).forEach(n=>n.remove()),t},$t=(e,t)=>{const n=document.createNodeIterator(t);let o=0,i=n.nextNode();for(;i!==null;){if(i===e)return o;o+=1,i=n.nextNode()}},jt=(e,t)=>{const n=document.createNodeIterator(t);let o=null;for(let i=0;i<e+1;i++)o=n.nextNode();return o},$e=e=>{const{commonAncestorContainer:t,startContainer:n,startOffset:o,endContainer:i,endOffset:r}=e,s=Array.from(t.childNodes).map(l=>{const m=l.cloneNode(!0);return l.nodeName==="CANVAS"?l:m}),a=$t(n,t),d=$t(i,t),f=()=>{const l=t;l.replaceChildren(...s);const m=jt(a,l),c=jt(d,l);return e.setStart(m,o),e.setEnd(c,r),e},g=l=>{const m=document.createElement("SPAN");return l.surroundContents(m),m};if(n===i)throw"Not implemented";{const l=document.createRange();l.selectNodeContents(n),l.setStart(n,o);const m=g(l),c=document.createRange();c.selectNode(i),c.setEnd(i,r);const S=g(c),w=je(e).reverse().map(p=>{var A;const u=document.createElement("SPAN");return(A=p.parentNode)==null||A.insertBefore(u,p),u.appendChild(p),u});return{unwrap:f,nodes:[m,...w,S]}}},je=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o}=e,i=document.createNodeIterator(t,NodeFilter.SHOW_TEXT);let r=i.nextNode(),s=!1;const a=[];for(;r!=null;)r===o&&(s=!1),s&&a.push(r),r===n&&(s=!0),r=i.nextNode();return a},We=e=>{const{startContainer:t,endContainer:n}=e;if(t===n)return Array.from(e.getClientRects());{const{unwrap:o,nodes:i}=$e(e),r=i.reduce((s,a)=>[...s,...a.getClientRects()],[]);return o(),r}},Wt=(e,t,n=10,o)=>{const i=o?e.startContainer.parentElement.closest(o):t,r=document.createRange();r.setStart(i,0),r.setEnd(e.startContainer,e.startOffset);const s=ft(r).textContent,a=document.createRange();a.setStart(e.endContainer,e.endOffset),i===document.body?a.setEnd(i,i.childNodes.length):a.setEndAfter(i);const d=ft(a).textContent;return{prefix:s.substring(s.length-n),suffix:d.substring(0,n)}},Gt=/^\s*$/,zt=e=>Gt.test(e.toString()),W=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),Ge=(e,t)=>{const n=r=>Math.round(r*10)/10,o={top:n(e.top),bottom:n(e.bottom),left:n(e.left),right:n(e.right)},i={top:n(t.top),bottom:n(t.bottom),left:n(t.left),right:n(t.right)};if(Math.abs(o.top-i.top)<.5&&Math.abs(o.bottom-i.bottom)<.5){if(Math.abs(o.left-i.right)<.5||Math.abs(o.right-i.left)<.5)return"inline-adjacent";if(o.left>=i.left&&o.right<=i.right)return"inline-is-contained";if(o.left<=i.left&&o.right>=i.right)return"inline-contains"}else if(o.top<=i.top&&o.bottom>=i.bottom){if(o.left<=i.left&&o.right>=i.right)return"block-contains"}else if(o.top>=i.top&&o.bottom<=i.bottom&&o.left>=i.left&&o.right<=i.right)return"block-is-contained"},ze=(e,t)=>{const n=Math.min(e.left,t.left),o=Math.max(e.right,t.right),i=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,i,o-n,r-i)},qt=e=>e.reduce((t,n)=>{if(n.width===0||n.height===0)return t;let o=[...t],i=!1;for(const r of t){const s=Ge(n,r);if(s==="inline-adjacent"){o=o.map(a=>a===r?ze(n,r):a),i=!0;break}else if(s==="inline-contains"){o=o.map(a=>a===r?n:a),i=!0;break}else if(s==="inline-is-contained"){i=!0;break}else if(s==="block-contains"||s==="block-is-contained"){n.width<r.width&&(o=o.map(a=>a===r?n:a)),i=!0;break}}return i?o:[...o,n]},[]),qe=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Zt=(e,t,n)=>{const o=document.createRange(),i=n?e.startContainer.parentElement.closest(n):t;o.setStart(i,0),o.setEnd(e.startContainer,e.startOffset);const r=ft(o).textContent,s=e.toString(),a=r.length||0,d=a+s.length;return n?{quote:s,start:a,end:d,range:e,offsetReference:i}:{quote:s,start:a,end:d,range:e}},Ct=(e,t)=>{var g,l;const{start:n,end:o}=e,i=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,m=>{var c;return(c=m.parentElement)!=null&&c.closest(X)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let s=0;const a=document.createRange();let d=r.nextNode();d===null&&console.error("Could not revive annotation target. Content missing.");let f=!i;for(;d!==null;){if(f||(f=i==null?void 0:i.contains(d)),f){const m=((g=d.textContent)==null?void 0:g.length)||0;if(s+m>n){a.setStart(d,n-s);break}s+=m}d=r.nextNode()}for(;d!==null;){const m=((l=d.textContent)==null?void 0:l.length)||0;if(s+m>=o){a.setEnd(d,o-s);break}s+=m,d=r.nextNode()}return{...e,range:a}},nt=(e,t)=>W(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:Ct(n,t))},ht=(e,t)=>W(e.target.selector)?e:{...e,target:nt(e.target,t)},Jt=(e,t)=>{const n=e.cloneRange();return t.contains(n.startContainer)||n.setStart(t,0),t.contains(n.endContainer)||n.setEnd(t,t.childNodes.length),n},Qt=(e,t)=>{const{left:n,top:o,right:i,bottom:r}=e;return new DOMRect(n-t.left,o-t.top,i-n,r-o)},Ze=(e,t)=>{const{left:n,top:o,right:i,bottom:r}=e;return new DOMRect(n+t.left,o+t.top,i-n,r-o)},Kt=e=>({...e,type:e.type,x:e.x,y:e.y,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,screenX:e.screenX,screenY:e.screenY,isPrimary:e.isPrimary,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,button:e.button,buttons:e.buttons,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,eventPhase:e.eventPhase,pointerId:e.pointerId,pointerType:e.pointerType,timeStamp:e.timeStamp}),te=e=>({...e,type:e.type,key:e.key,code:e.code,location:e.location,repeat:e.repeat,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,timeStamp:e.timeStamp}),Je=e=>{const{top:t,left:n}=e.getBoundingClientRect(),{innerWidth:o,innerHeight:i}=window,r=-n,s=-t,a=o-n,d=i-t;return{top:t,left:n,minX:r,minY:s,maxX:a,maxY:d}},Qe=e=>{let t=new Set;return o=>{const i=o.map(r=>r.id);(t.size!==i.length||i.some(r=>!t.has(r)))&&e.set(i),t=new Set(i)}},Tt=(e,t,n,o)=>{const{store:i,selection:r,hover:s}=t;let a,d,f;const g=Qe(n),l=x=>{const{x:B,y:b}=e.getBoundingClientRect(),C=i.getAt(x.clientX-B,x.clientY-b,d);C?s.current!==C.id&&(e.classList.add("hovered"),s.set(C.id)):s.current&&(e.classList.remove("hovered"),s.set(null))};e.addEventListener("pointermove",l);const m=(x=!1)=>{f&&f.clear();const B=Je(e),{minX:b,minY:C,maxX:T,maxY:L}=B,k=d?i.getIntersecting(b,C,T,L).filter(({annotation:Z})=>d(Z)):i.getIntersecting(b,C,T,L),I=r.selected.map(({id:Z})=>Z),j=k.map(({annotation:Z,rects:xo})=>{const Mo=I.includes(Z.id),Ro=Z.id===s.current;return{annotation:Z,rects:xo,state:{selected:Mo,hover:Ro}}});o.redraw(j,B,a,f,x),setTimeout(()=>g(k.map(({annotation:Z})=>Z)),1)},c=x=>{f=x,m()},S=x=>{a=x,m()},v=x=>{d=x,m(!1)},w=()=>m();i.observe(w);const p=r.subscribe(()=>m()),u=()=>m(!0);document.addEventListener("scroll",u,{capture:!0,passive:!0});const A=pt(()=>{i.recalculatePositions(),f&&f.reset(),m()});window.addEventListener("resize",A);const h=new ResizeObserver(A);h.observe(e);const E={attributes:!0,childList:!0,subtree:!0},R=new MutationObserver(x=>{x.every(b=>b.target===e||e.contains(b.target))||m(!0)});return R.observe(document.body,E),{destroy:()=>{e.removeEventListener("pointermove",l),o.destroy(),i.unobserve(w),p(),document.removeEventListener("scroll",u),window.removeEventListener("resize",A),h.disconnect(),R.disconnect()},redraw:m,setStyle:S,setFilter:v,setPainter:c,setVisible:o.setVisible}},Ke=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},tn=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},en=e=>{e.classList.add("r6o-annotatable");const t=Ke(),n=t.getContext("2d");document.body.appendChild(t);const o=(a,d,f,g)=>requestAnimationFrame(()=>{const{width:l,height:m}=t;n.clearRect(-.5,-.5,l+1,m+1),g&&g.clear();const{top:c,left:S}=d;[...a].sort((w,p)=>{const{annotation:{target:{created:u}}}=w,{annotation:{target:{created:A}}}=p;return u.getTime()-A.getTime()}).forEach(w=>{var h;const p=f?typeof f=="function"?f(w.annotation,w.state):f:(h=w.state)!=null&&h.selected?et:H,u=g&&g.paint(w,d)||p,A=w.rects.map(({x:E,y:R,width:O,height:x})=>({x:E+S,y:R+c,width:O,height:x}));if(n.fillStyle=u.fill,n.globalAlpha=u.fillOpacity||1,A.forEach(({x:E,y:R,width:O,height:x})=>n.fillRect(E,R,O,x)),u.underlineColor){n.globalAlpha=1,n.strokeStyle=u.underlineColor,n.lineWidth=u.underlineThickness??1;const E=u.underlineOffset??0;A.forEach(({x:R,y:O,width:x,height:B})=>{n.beginPath(),n.moveTo(R,O+B+E),n.lineTo(R+x,O+B+E),n.stroke()})}})}),i=pt(()=>{tn(t)});return window.addEventListener("resize",i),{destroy:()=>{t.remove(),window.removeEventListener("resize",i)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},ee=(e,t,n)=>Tt(e,t,n,en(e));var nn={grad:.9,turn:360,rad:360/(2*Math.PI)},z=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},P=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},Y=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},ne=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},oe=function(e){return{r:Y(e.r,0,255),g:Y(e.g,0,255),b:Y(e.b,0,255),a:Y(e.a)}},Et=function(e){return{r:P(e.r),g:P(e.g),b:P(e.b),a:P(e.a,3)}},on=/^#([0-9a-f]{3,8})$/i,gt=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},ie=function(e){var t=e.r,n=e.g,o=e.b,i=e.a,r=Math.max(t,n,o),s=r-Math.min(t,n,o),a=s?r===t?(n-o)/s:r===n?2+(o-t)/s:4+(t-n)/s:0;return{h:60*(a<0?a+6:a),s:r?s/r*100:0,v:r/255*100,a:i}},re=function(e){var t=e.h,n=e.s,o=e.v,i=e.a;t=t/360*6,n/=100,o/=100;var r=Math.floor(t),s=o*(1-n),a=o*(1-(t-r)*n),d=o*(1-(1-t+r)*n),f=r%6;return{r:255*[o,a,s,s,d,o][f],g:255*[d,o,o,a,s,s][f],b:255*[s,s,d,o,o,a][f],a:i}},ae=function(e){return{h:ne(e.h),s:Y(e.s,0,100),l:Y(e.l,0,100),a:Y(e.a)}},se=function(e){return{h:P(e.h),s:P(e.s),l:P(e.l),a:P(e.a,3)}},le=function(e){return re((n=(t=e).s,{h:t.h,s:(n*=((o=t.l)<50?o:100-o)/100)>0?2*n/(o+n)*100:0,v:o+n,a:t.a}));var t,n,o},ot=function(e){return{h:(t=ie(e)).h,s:(i=(200-(n=t.s))*(o=t.v)/100)>0&&i<200?n*o/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,o,i},rn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,sn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ln=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ce={string:[[function(e){var t=on.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?P(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?P(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=sn.exec(e)||ln.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:oe({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=rn.exec(e)||an.exec(e);if(!t)return null;var n,o,i=ae({h:(n=t[1],o=t[2],o===void 0&&(o="deg"),Number(n)*(nn[o]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return le(i)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,o=e.b,i=e.a,r=i===void 0?1:i;return z(t)&&z(n)&&z(o)?oe({r:Number(t),g:Number(n),b:Number(o),a:Number(r)}):null},"rgb"],[function(e){var t=e.h,n=e.s,o=e.l,i=e.a,r=i===void 0?1:i;if(!z(t)||!z(n)||!z(o))return null;var s=ae({h:Number(t),s:Number(n),l:Number(o),a:Number(r)});return le(s)},"hsl"],[function(e){var t=e.h,n=e.s,o=e.v,i=e.a,r=i===void 0?1:i;if(!z(t)||!z(n)||!z(o))return null;var s=function(a){return{h:ne(a.h),s:Y(a.s,0,100),v:Y(a.v,0,100),a:Y(a.a)}}({h:Number(t),s:Number(n),v:Number(o),a:Number(r)});return re(s)},"hsv"]]},de=function(e,t){for(var n=0;n<t.length;n++){var o=t[n][0](e);if(o)return[o,t[n][1]]}return[null,void 0]},cn=function(e){return typeof e=="string"?de(e.trim(),ce.string):typeof e=="object"&&e!==null?de(e,ce.object):[null,void 0]},Lt=function(e,t){var n=ot(e);return{h:n.h,s:Y(n.s+100*t,0,100),l:n.l,a:n.a}},xt=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},ue=function(e,t){var n=ot(e);return{h:n.h,s:n.s,l:Y(n.l+100*t,0,100),a:n.a}},fe=function(){function e(t){this.parsed=cn(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return P(xt(this.rgba),2)},e.prototype.isDark=function(){return xt(this.rgba)<.5},e.prototype.isLight=function(){return xt(this.rgba)>=.5},e.prototype.toHex=function(){return t=Et(this.rgba),n=t.r,o=t.g,i=t.b,s=(r=t.a)<1?gt(P(255*r)):"","#"+gt(n)+gt(o)+gt(i)+s;var t,n,o,i,r,s},e.prototype.toRgb=function(){return Et(this.rgba)},e.prototype.toRgbString=function(){return t=Et(this.rgba),n=t.r,o=t.g,i=t.b,(r=t.a)<1?"rgba("+n+", "+o+", "+i+", "+r+")":"rgb("+n+", "+o+", "+i+")";var t,n,o,i,r},e.prototype.toHsl=function(){return se(ot(this.rgba))},e.prototype.toHslString=function(){return t=se(ot(this.rgba)),n=t.h,o=t.s,i=t.l,(r=t.a)<1?"hsla("+n+", "+o+"%, "+i+"%, "+r+")":"hsl("+n+", "+o+"%, "+i+"%)";var t,n,o,i,r},e.prototype.toHsv=function(){return t=ie(this.rgba),{h:P(t.h),s:P(t.s),v:P(t.v),a:P(t.a,3)};var t},e.prototype.invert=function(){return $({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),$(Lt(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),$(Lt(this.rgba,-t))},e.prototype.grayscale=function(){return $(Lt(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),$(ue(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),$(ue(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?$({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):P(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=ot(this.rgba);return typeof t=="number"?$({h:t,s:n.s,l:n.l,a:n.a}):P(n.h)},e.prototype.isEqual=function(t){return this.toHex()===$(t).toHex()},e}(),$=function(e){return e instanceof fe?e:new fe(e)};const dn=e=>[`background-color:${$((e==null?void 0:e.fill)||H.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?H.fillOpacity:e.fillOpacity).toHex()}`,e!=null&&e.underlineThickness?"text-decoration:underline":void 0,e!=null&&e.underlineColor?`text-decoration-color:${e.underlineColor}`:void 0,e!=null&&e.underlineOffset?`text-underline-offset:${e.underlineOffset}px`:void 0,e!=null&&e.underlineThickness?`text-decoration-thickness:${e.underlineThickness}px`:void 0].filter(Boolean).join(";"),pe=()=>{const e=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(e);let t=new Set;return{destroy:()=>{CSS.highlights.clear(),e.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,s,a,d)=>{d&&d.clear();const f=new Set(r.map(l=>l.annotation.id));Array.from(t).filter(l=>!f.has(l));const g=r.map(l=>{var S;const m=a?typeof a=="function"?a(l.annotation,l.state):a:(S=l.state)!=null&&S.selected?et:H,c=d&&d.paint(l,s)||m;return`::highlight(_${l.annotation.id}) { ${dn(c)} }`});e.innerHTML=g.join(`
|
|
2
|
+
`),CSS.highlights.clear(),r.forEach(({annotation:l})=>{const m=l.target.selector.map(S=>S.range),c=new Highlight(...m);CSS.highlights.set(`_${l.id}`,c)}),t=f}}},he=(e,t,n)=>Tt(e,t,n,pe());var ge=Object.prototype.hasOwnProperty;function Mt(e,t){var n,o;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&Mt(e[o],t[o]););return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(ge.call(e,n)&&++o&&!ge.call(t,n)||!(n in t)||!Mt(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}const un=(e,t)=>{const n=(r,s)=>r.x<=s.x+s.width&&r.x+r.width>=s.x&&r.y<=s.y+s.height&&r.y+r.height>=s.y,o=r=>r.rects.reduce((s,a)=>s+a.width,0),i=t.filter(({rects:r})=>r.some(s=>n(e,s)));return i.sort((r,s)=>o(s)-o(r)),i.findIndex(r=>r.rects.includes(e))},fn=e=>{e.classList.add("r6o-annotatable");const t=document.createElement("div");t.className="r6o-span-highlight-layer",e.insertBefore(t,e.firstChild);let n=[];return{destroy:()=>{t.remove()},redraw:(s,a,d,f,g)=>{const m=!(Mt(n,s)&&g);!f&&!m||(m&&(t.innerHTML=""),s.forEach(c=>{c.rects.map(S=>{const v=un(S,s),w=_t(c,a,d,f,v);if(m){const p=document.createElement("span");p.className="r6o-annotation",p.dataset.annotation=c.annotation.id,p.style.left=`${S.x}px`,p.style.top=`${S.y}px`,p.style.width=`${S.width}px`,p.style.height=`${S.height}px`,p.style.backgroundColor=$((w==null?void 0:w.fill)||H.fill).alpha((w==null?void 0:w.fillOpacity)===void 0?H.fillOpacity:w.fillOpacity).toHex(),w.underlineStyle&&(p.style.borderStyle=w.underlineStyle),w.underlineColor&&(p.style.borderColor=w.underlineColor),w.underlineThickness&&(p.style.borderBottomWidth=`${w.underlineThickness}px`),w.underlineOffset&&(p.style.paddingBottom=`${w.underlineOffset}px`),t.appendChild(p)}})}),n=s)},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},me=(e,t,n)=>Tt(e,t,n,fn(e));for(var D=[],Rt=0;Rt<256;++Rt)D.push((Rt+256).toString(16).slice(1));function pn(e,t=0){return(D[e[t+0]]+D[e[t+1]]+D[e[t+2]]+D[e[t+3]]+"-"+D[e[t+4]]+D[e[t+5]]+"-"+D[e[t+6]]+D[e[t+7]]+"-"+D[e[t+8]]+D[e[t+9]]+"-"+D[e[t+10]]+D[e[t+11]]+D[e[t+12]]+D[e[t+13]]+D[e[t+14]]+D[e[t+15]]).toLowerCase()}var mt,hn=new Uint8Array(16);function gn(){if(!mt&&(mt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!mt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return mt(hn)}var mn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const be={randomUUID:mn};function we(e,t,n){if(be.randomUUID&&!t&&!e)return be.randomUUID();e=e||{};var o=e.random||(e.rng||gn)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,pn(o)}var Ae=Object.prototype.hasOwnProperty;function J(e,t){var n,o;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&J(e[o],t[o]););return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(Ae.call(e,n)&&++o&&!Ae.call(t,n)||!(n in t)||!J(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}function Bt(){}function bn(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const Q=[];function kt(e,t=Bt){let n;const o=new Set;function i(a){if(bn(e,a)&&(e=a,n)){const d=!Q.length;for(const f of o)f[1](),Q.push(f,e);if(d){for(let f=0;f<Q.length;f+=2)Q[f][0](Q[f+1]);Q.length=0}}}function r(a){i(a(e))}function s(a,d=Bt){const f=[a,d];return o.add(f),o.size===1&&(n=t(i,r)||Bt),a(e),()=>{o.delete(f),o.size===0&&n&&(n(),n=null)}}return{set:i,update:r,subscribe:s}}const wn=e=>{const{subscribe:t,set:n}=kt();let o;return t(i=>o=i),e.observe(({changes:i})=>{if(o){(i.deleted||[]).some(s=>s.id===o)&&n(void 0);const r=(i.updated||[]).find(({oldValue:s})=>s.id===o);r&&n(r.newValue.id)}}),{get current(){return o},subscribe:t,set:n}};var Se=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(Se||{});const Ot={selected:[]},An=(e,t="EDIT")=>{const{subscribe:n,set:o}=kt(Ot);let i=t,r=Ot;n(c=>r=c);const s=()=>o(Ot),a=()=>{var c;return((c=r.selected)==null?void 0:c.length)===0},d=c=>{if(a())return!1;const S=typeof c=="string"?c:c.id;return r.selected.some(v=>v.id===S)},f=(c,S)=>{const v=e.getAnnotation(c);if(!v){console.warn("Invalid selection: "+c);return}switch(ve(v,i)){case"EDIT":o({selected:[{id:c,editable:!0}],event:S});break;case"SELECT":o({selected:[{id:c}],event:S});break;default:o({selected:[],event:S})}},g=(c,S)=>{const v=Array.isArray(c)?c:[c],w=v.map(p=>e.getAnnotation(p)).filter(p=>!!p);o({selected:w.map(p=>{const u=S===void 0?ve(p,i)==="EDIT":S;return{id:p.id,editable:u}})}),w.length!==v.length&&console.warn("Invalid selection",c)},l=c=>{if(a())return!1;const{selected:S}=r;S.some(({id:v})=>c.includes(v))&&o({selected:S.filter(({id:v})=>!c.includes(v))})},m=c=>i=c;return e.observe(({changes:c})=>l((c.deleted||[]).map(S=>S.id))),{get event(){return r?r.event:null},get selected(){return r?[...r.selected]:null},clear:s,isEmpty:a,isSelected:d,setSelected:g,setUserSelectAction:m,subscribe:n,userSelect:f}},ve=(e,t)=>typeof t=="function"?t(e):t||"EDIT";for(var y=[],Vt=0;Vt<256;++Vt)y.push((Vt+256).toString(16).slice(1));function Sn(e,t=0){return(y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}var bt,vn=new Uint8Array(16);function Cn(){if(!bt&&(bt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!bt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return bt(vn)}var Tn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Ce={randomUUID:Tn};function En(e,t,n){if(Ce.randomUUID&&!t&&!e)return Ce.randomUUID();e=e||{};var o=e.random||(e.rng||Cn)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Sn(o)}const Ln=(e,t,n,o)=>({id:En(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:o,...t}),xn=(e,t)=>{const n=new Set(e.bodies.map(o=>o.id));return t.bodies.filter(o=>!n.has(o.id))},Mn=(e,t)=>{const n=new Set(t.bodies.map(o=>o.id));return e.bodies.filter(o=>!n.has(o.id))},Rn=(e,t)=>t.bodies.map(n=>{const o=e.bodies.find(i=>i.id===n.id);return{newBody:n,oldBody:o&&!J(o,n)?o:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:o})=>({oldBody:n,newBody:o})),Bn=(e,t)=>!J(e.target,t.target),Te=(e,t)=>{const n=xn(e,t),o=Mn(e,t),i=Rn(e,t);return{oldValue:e,newValue:t,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:o.length>0?o:void 0,bodiesUpdated:i.length>0?i:void 0,targetUpdated:Bn(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var V=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e))(V||{});const kn=(e,t)=>{var n,o;const{changes:i,origin:r}=t;if(!(!e.options.origin||e.options.origin===r))return!1;if(e.options.ignore){const{ignore:s}=e.options,a=d=>d&&d.length>0;if(!(a(i.created)||a(i.deleted))){const d=(n=i.updated)==null?void 0:n.some(g=>a(g.bodiesCreated)||a(g.bodiesDeleted)||a(g.bodiesUpdated)),f=(o=i.updated)==null?void 0:o.some(g=>g.targetUpdated);if(s==="BODY_ONLY"&&d&&!f||s==="TARGET_ONLY"&&f&&!d)return!1}}if(e.options.annotations){const s=new Set([...(i.created||[]).map(a=>a.id),...(i.deleted||[]).map(a=>a.id),...(i.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(e.options.annotations)?e.options.annotations:[e.options.annotations]).find(a=>s.has(a))}else return!0},On=(e,t)=>{const n=new Set((e.created||[]).map(l=>l.id)),o=new Set((e.updated||[]).map(({newValue:l})=>l.id)),i=new Set((t.created||[]).map(l=>l.id)),r=new Set((t.deleted||[]).map(l=>l.id)),s=new Set((t.updated||[]).map(({oldValue:l})=>l.id)),a=new Set((t.updated||[]).filter(({oldValue:l})=>n.has(l.id)||o.has(l.id)).map(({oldValue:l})=>l.id)),d=[...(e.created||[]).filter(l=>!r.has(l.id)).map(l=>s.has(l.id)?t.updated.find(({oldValue:m})=>m.id===l.id).newValue:l),...t.created||[]],f=[...(e.deleted||[]).filter(l=>!i.has(l.id)),...(t.deleted||[]).filter(l=>!n.has(l.id))],g=[...(e.updated||[]).filter(({newValue:l})=>!r.has(l.id)).map(l=>{const{oldValue:m,newValue:c}=l;if(s.has(c.id)){const S=t.updated.find(v=>v.oldValue.id===c.id).newValue;return Te(m,S)}else return l}),...(t.updated||[]).filter(({oldValue:l})=>!a.has(l.id))];return{created:d,deleted:f,updated:g}},Vn=e=>e.id!==void 0,Nn=()=>{const e=new Map,t=new Map,n=[],o=(b,C={})=>n.push({onChange:b,options:C}),i=b=>{const C=n.findIndex(T=>T.onChange==b);C>-1&&n.splice(C,1)},r=(b,C)=>{const T={origin:b,changes:{created:C.created||[],updated:C.updated||[],deleted:C.deleted||[]},state:[...e.values()]};n.forEach(L=>{kn(L,T)&&L.onChange(T)})},s=(b,C=V.LOCAL)=>{if(e.get(b.id))throw Error(`Cannot add annotation ${b.id} - exists already`);e.set(b.id,b),b.bodies.forEach(T=>t.set(T.id,b.id)),r(C,{created:[b]})},a=(b,C)=>{const T=typeof b=="string"?C:b,L=typeof b=="string"?b:b.id,k=e.get(L);if(k){const I=Te(k,T);return L===T.id?e.set(L,T):(e.delete(L),e.set(T.id,T)),k.bodies.forEach(j=>t.delete(j.id)),T.bodies.forEach(j=>t.set(j.id,T.id)),I}else console.warn(`Cannot update annotation ${L} - does not exist`)},d=(b,C=V.LOCAL,T=V.LOCAL)=>{const L=Vn(C)?T:C,k=a(b,C);k&&r(L,{updated:[k]})},f=(b,C=V.LOCAL)=>{const T=b.reduce((L,k)=>{const I=a(k);return I?[...L,I]:L},[]);T.length>0&&r(C,{updated:T})},g=(b,C=V.LOCAL)=>{const T=e.get(b.annotation);if(T){const L={...T,bodies:[...T.bodies,b]};e.set(T.id,L),t.set(b.id,L.id),r(C,{updated:[{oldValue:T,newValue:L,bodiesCreated:[b]}]})}else console.warn(`Attempt to add body to missing annotation: ${b.annotation}`)},l=()=>[...e.values()],m=(b=V.LOCAL)=>{const C=[...e.values()];e.clear(),t.clear(),r(b,{deleted:C})},c=(b,C=!0,T=V.LOCAL)=>{if(C){const L=[...e.values()];e.clear(),t.clear(),b.forEach(k=>{e.set(k.id,k),k.bodies.forEach(I=>t.set(I.id,k.id))}),r(T,{created:b,deleted:L})}else{const L=b.reduce((k,I)=>{const j=e.get(I.id);return j?[...k,j]:k},[]);if(L.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${L.map(k=>k.id).join(", ")}`);b.forEach(k=>{e.set(k.id,k),k.bodies.forEach(I=>t.set(I.id,k.id))}),r(T,{created:b})}},S=b=>{const C=typeof b=="string"?b:b.id,T=e.get(C);if(T)return e.delete(C),T.bodies.forEach(L=>t.delete(L.id)),T;console.warn(`Attempt to delete missing annotation: ${C}`)},v=(b,C=V.LOCAL)=>{const T=S(b);T&&r(C,{deleted:[T]})},w=(b,C=V.LOCAL)=>{const T=b.reduce((L,k)=>{const I=S(k);return I?[...L,I]:L},[]);T.length>0&&r(C,{deleted:T})},p=b=>{const C=e.get(b.annotation);if(C){const T=C.bodies.find(L=>L.id===b.id);if(T){t.delete(T.id);const L={...C,bodies:C.bodies.filter(k=>k.id!==b.id)};return e.set(C.id,L),{oldValue:C,newValue:L,bodiesDeleted:[T]}}else console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${b.annotation}`)},u=(b,C=V.LOCAL)=>{const T=p(b);T&&r(C,{updated:[T]})},A=(b,C=V.LOCAL)=>{const T=b.map(L=>p(L)).filter(Boolean);T.length>0&&r(C,{updated:T})},h=b=>{const C=e.get(b);return C?{...C}:void 0},E=b=>{const C=t.get(b);if(C){const T=h(C).bodies.find(L=>L.id===b);if(T)return T;console.error(`Store integrity error: body ${b} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${b}`)},R=(b,C)=>{if(b.annotation!==C.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const T=e.get(b.annotation);if(T){const L=T.bodies.find(I=>I.id===b.id),k={...T,bodies:T.bodies.map(I=>I.id===L.id?C:I)};return e.set(T.id,k),L.id!==C.id&&(t.delete(L.id),t.set(C.id,k.id)),{oldValue:T,newValue:k,bodiesUpdated:[{oldBody:L,newBody:C}]}}else console.warn(`Attempt to add body to missing annotation ${b.annotation}`)},O=(b,C,T=V.LOCAL)=>{const L=R(b,C);L&&r(T,{updated:[L]})},x=(b,C=V.LOCAL)=>{const T=b.map(L=>R({id:L.id,annotation:L.annotation},L)).filter(Boolean);r(C,{updated:T})},B=b=>{const C=e.get(b.annotation);if(C){const T={...C,target:{...C.target,...b}};return e.set(C.id,T),{oldValue:C,newValue:T,targetUpdated:{oldTarget:C.target,newTarget:b}}}else console.warn(`Attempt to update target on missing annotation: ${b.annotation}`)};return{addAnnotation:s,addBody:g,all:l,bulkAddAnnotation:c,bulkDeleteAnnotation:w,bulkDeleteBodies:A,bulkUpdateAnnotation:f,bulkUpdateBodies:x,bulkUpdateTargets:(b,C=V.LOCAL)=>{const T=b.map(L=>B(L)).filter(Boolean);T.length>0&&r(C,{updated:T})},clear:m,deleteAnnotation:v,deleteBody:u,getAnnotation:h,getBody:E,observe:o,unobserve:i,updateAnnotation:d,updateBody:O,updateTarget:(b,C=V.LOCAL)=>{const T=B(b);T&&r(C,{updated:[T]})}}};let Fn=()=>({emit(e,...t){for(let n=0,o=this.events[e]||[],i=o.length;n<i;n++)o[n](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var o;this.events[e]=(o=this.events[e])==null?void 0:o.filter(i=>t!==i)}}});const In=250,Pn=e=>{const t=Fn(),n=[];let o=-1,i=!1,r=0;const s=c=>{if(!i){const{changes:S}=c,v=performance.now();if(v-r>In)n.splice(o+1),n.push(S),o=n.length-1;else{const w=n.length-1;n[w]=On(n[w],S)}r=v}i=!1};e.observe(s,{origin:V.LOCAL});const a=c=>c&&c.length>0&&e.bulkDeleteAnnotation(c),d=c=>c&&c.length>0&&e.bulkAddAnnotation(c,!1),f=c=>c&&c.length>0&&e.bulkUpdateAnnotation(c.map(({oldValue:S})=>S)),g=c=>c&&c.length>0&&e.bulkUpdateAnnotation(c.map(({newValue:S})=>S)),l=c=>c&&c.length>0&&e.bulkAddAnnotation(c,!1),m=c=>c&&c.length>0&&e.bulkDeleteAnnotation(c);return{canRedo:()=>n.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(s),on:(c,S)=>t.on(c,S),redo:()=>{if(n.length-1>o){i=!0;const{created:c,updated:S,deleted:v}=n[o+1];d(c),g(S),m(v),t.emit("redo",n[o+1]),o+=1}},undo:()=>{if(o>-1){i=!0;const{created:c,updated:S,deleted:v}=n[o];a(c),f(S),l(v),t.emit("undo",n[o]),o-=1}}}},Dn=()=>{const{subscribe:e,set:t}=kt([]);return{subscribe:e,set:t}},yn=(e,t,n,o)=>{const{store:i,selection:r,hover:s,viewport:a}=e,d=new Map;let f=[],g;const l=(v,w)=>{d.has(v)?d.get(v).push(w):d.set(v,[w])},m=(v,w)=>{const p=d.get(v);if(p){const u=p.indexOf(w);u!==-1&&p.splice(u,1)}},c=(v,w,p)=>{d.has(v)&&setTimeout(()=>{d.get(v).forEach(u=>{if(n){const A=Array.isArray(w)?w.map(E=>n.serialize(E)):n.serialize(w),h=p?p instanceof PointerEvent?p:n.serialize(p):void 0;u(A,h)}else u(w,p)})},1)};r.subscribe(({selected:v})=>{if(!(f.length===0&&v.length===0)){if(f.length===0&&v.length>0)f=v.map(({id:w})=>i.getAnnotation(w));else if(f.length>0&&v.length===0)f.forEach(w=>{const p=i.getAnnotation(w.id);p&&!J(p,w)&&c("updateAnnotation",p,w)}),f=[];else{const w=new Set(f.map(u=>u.id)),p=new Set(v.map(({id:u})=>u));f.filter(u=>!p.has(u.id)).forEach(u=>{const A=i.getAnnotation(u.id);A&&!J(A,u)&&c("updateAnnotation",A,u)}),f=[...f.filter(u=>p.has(u.id)),...v.filter(({id:u})=>!w.has(u)).map(({id:u})=>i.getAnnotation(u))]}c("selectionChanged",f)}}),s.subscribe(v=>{!g&&v?c("mouseEnterAnnotation",i.getAnnotation(v)):g&&!v?c("mouseLeaveAnnotation",i.getAnnotation(g)):g&&v&&(c("mouseLeaveAnnotation",i.getAnnotation(g)),c("mouseEnterAnnotation",i.getAnnotation(v))),g=v}),a==null||a.subscribe(v=>c("viewportIntersect",v.map(w=>i.getAnnotation(w)))),i.observe(v=>{const{created:w,deleted:p}=v.changes;(w||[]).forEach(u=>c("createAnnotation",u)),(p||[]).forEach(u=>c("deleteAnnotation",u)),(v.changes.updated||[]).filter(u=>[...u.bodiesCreated||[],...u.bodiesDeleted||[],...u.bodiesUpdated||[]].length>0).forEach(({oldValue:u,newValue:A})=>{const h=f.find(E=>E.id===u.id)||u;f=f.map(E=>E.id===u.id?A:E),c("updateAnnotation",A,h)})},{origin:V.LOCAL}),i.observe(v=>{if(f){const w=new Set(f.map(u=>u.id)),p=(v.changes.updated||[]).filter(({newValue:u})=>w.has(u.id)).map(({newValue:u})=>u);p.length>0&&(f=f.map(u=>p.find(h=>h.id===u.id)||u))}},{origin:V.REMOTE});const S=v=>w=>{const{updated:p}=w;v?(p||[]).forEach(u=>c("updateAnnotation",u.oldValue,u.newValue)):(p||[]).forEach(u=>c("updateAnnotation",u.newValue,u.oldValue))};return t.on("undo",S(!0)),t.on("redo",S(!1)),{on:l,off:m,emit:c}},Un=e=>t=>t.reduce((n,o)=>{const{parsed:i,error:r}=e.parse(o);return r?{parsed:n.parsed,failed:[...n.failed,o]}:i?{parsed:[...n.parsed,i],failed:n.failed}:{...n}},{parsed:[],failed:[]}),_n=(e,t,n)=>{const{store:o,selection:i}=e,r=p=>{if(n){const{parsed:u,error:A}=n.parse(p);u?o.addAnnotation(u,V.REMOTE):console.error(A)}else o.addAnnotation(p,V.REMOTE)},s=()=>i.clear(),a=()=>o.clear(),d=p=>{const u=o.getAnnotation(p);return n&&u?n.serialize(u):u},f=()=>n?o.all().map(n.serialize):o.all(),g=()=>{var p;const u=(((p=i.selected)==null?void 0:p.map(A=>A.id))||[]).map(A=>o.getAnnotation(A)).filter(Boolean);return n?u.map(n.serialize):u},l=(p,u=!0)=>fetch(p).then(A=>A.json()).then(A=>(c(A,u),A)),m=p=>{if(typeof p=="string"){const u=o.getAnnotation(p);if(o.deleteAnnotation(p),u)return n?n.serialize(u):u}else{const u=n?n.parse(p).parsed:p;if(u)return o.deleteAnnotation(u),p}},c=(p,u=!0)=>{if(n){const{parsed:A,failed:h}=Un(n)(p);h.length>0&&console.warn(`Discarded ${h.length} invalid annotations`,h),o.bulkAddAnnotation(A,u,V.REMOTE)}else o.bulkAddAnnotation(p,u,V.REMOTE)},S=(p,u)=>{p?i.setSelected(p,u):i.clear()},v=p=>{i.clear(),i.setUserSelectAction(p)},w=p=>{if(n){const u=n.parse(p).parsed,A=n.serialize(o.getAnnotation(u.id));return o.updateAnnotation(u),A}else{const u=o.getAnnotation(p.id);return o.updateAnnotation(p),u}};return{addAnnotation:r,cancelSelected:s,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:d,getAnnotations:f,getSelected:g,loadAnnotations:l,redo:t.redo,removeAnnotation:m,setAnnotations:c,setSelected:S,setUserSelectAction:v,undo:t.undo,updateAnnotation:w}},Hn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Yn=e=>crypto.getRandomValues(new Uint8Array(e)),Xn=(e,t,n)=>{let o=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*o*t/e.length);return(r=t)=>{let s="";for(;;){let a=n(i),d=i;for(;d--;)if(s+=e[a[d]&o]||"",s.length===r)return s}}},$n=(e,t=21)=>Xn(e,t,Yn),jn=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=Hn[n[e]&63];return t};const Wn=()=>({isGuest:!0,id:$n("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Gn=e=>{const t=JSON.stringify(e);let n=0;for(let o=0,i=t.length;o<i;o++){let r=t.charCodeAt(o);n=(n<<5)-n+r,n|=0}return`${n}`},Ee=e=>e?typeof e=="object"?{...e}:e:void 0,zn=(e,t)=>(Array.isArray(e)?e:[e]).map(n=>{const{id:o,type:i,purpose:r,value:s,created:a,modified:d,creator:f,...g}=n;return{id:o||`temp-${Gn(n)}`,annotation:t,type:i,purpose:r,value:s,creator:Ee(f),created:a?new Date(a):void 0,updated:d?new Date(d):void 0,...g}}),qn=e=>e.map(t=>{var n;const{annotation:o,created:i,updated:r,...s}=t,a={...s,created:i==null?void 0:i.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=a.id)!=null&&n.startsWith("temp-")&&delete a.id,a});jn();const Zn=(e,t)=>({parse:n=>Le(n),serialize:n=>xe(n,e,t)}),Jn=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,Qn=e=>{const{id:t,creator:n,created:o,modified:i,target:r}=e,s=Array.isArray(r)?r:[r];if(s.length===0)return{error:Error(`No targets found for annotation: ${e.id}`)};const a={creator:Ee(n),created:o?new Date(o):void 0,updated:i?new Date(i):void 0,annotation:t,selector:[],styleClass:s[0].styleClass};for(const d of s){const g=(Array.isArray(d.selector)?d.selector:[d.selector]).reduce((l,m)=>{switch(m.type){case"TextQuoteSelector":l.quote=m.exact;break;case"TextPositionSelector":l.start=m.start,l.end=m.end;break}return l},{});if(Jn(g))a.selector.push({id:d.id,...g});else{const l=[g.start?void 0:"TextPositionSelector",g.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${l.join(" and ")} for annotation: ${e.id}`)}}}return{parsed:a}},Le=e=>{const t=e.id||we(),{creator:n,created:o,modified:i,body:r,...s}=e,a=zn(r,t),d=Qn(e);return"error"in d?{error:d.error}:{parsed:{...s,id:t,bodies:a,target:d.parsed}}},xe=(e,t,n)=>{const{bodies:o,target:i,...r}=e,{selector:s,creator:a,created:d,updated:f,...g}=i,l=s.map(m=>{const{quote:c,start:S,end:v,range:w}=m,{prefix:p,suffix:u}=Wt(w,n),A=[{type:"TextQuoteSelector",exact:c,prefix:p,suffix:u},{type:"TextPositionSelector",start:S,end:v}];return{...g,id:m.id,source:t,selector:A}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:qn(e.bodies),creator:a,created:d==null?void 0:d.toISOString(),modified:f==null?void 0:f.toISOString(),target:l}};function Kn(e,t,n,o,i){Me(e,t,n||0,o||e.length-1,i||to)}function Me(e,t,n,o,i){for(;o>n;){if(o-n>600){var r=o-n+1,s=t-n+1,a=Math.log(r),d=.5*Math.exp(2*a/3),f=.5*Math.sqrt(a*d*(r-d)/r)*(s-r/2<0?-1:1),g=Math.max(n,Math.floor(t-s*d/r+f)),l=Math.min(o,Math.floor(t+(r-s)*d/r+f));Me(e,t,g,l,i)}var m=e[t],c=n,S=o;for(it(e,n,t),i(e[o],m)>0&&it(e,n,o);c<S;){for(it(e,c,S),c++,S--;i(e[c],m)<0;)c++;for(;i(e[S],m)>0;)S--}i(e[n],m)===0?it(e,n,S):(S++,it(e,S,o)),S<=t&&(n=S+1),t<=S&&(o=S-1)}}function it(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function to(e,t){return e<t?-1:e>t?1:0}class eo{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const o=[];if(!At(t,n))return o;const i=this.toBBox,r=[];for(;n;){for(let s=0;s<n.children.length;s++){const a=n.children[s],d=n.leaf?i(a):a;At(t,d)&&(n.leaf?o.push(a):Ft(t,d)?this._all(a,o):r.push(a))}n=r.pop()}return o}collides(t){let n=this.data;if(!At(t,n))return!1;const o=[];for(;n;){for(let i=0;i<n.children.length;i++){const r=n.children[i],s=n.leaf?this.toBBox(r):r;if(At(t,s)){if(n.leaf||Ft(t,s))return!0;o.push(r)}}n=o.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let o=0;o<t.length;o++)this.insert(t[o]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const o=this.data;this.data=n,n=o}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=tt([]),this}remove(t,n){if(!t)return this;let o=this.data;const i=this.toBBox(t),r=[],s=[];let a,d,f;for(;o||r.length;){if(o||(o=r.pop(),d=r[r.length-1],a=s.pop(),f=!0),o.leaf){const g=no(t,o.children,n);if(g!==-1)return o.children.splice(g,1),r.push(o),this._condense(r),this}!f&&!o.leaf&&Ft(o,i)?(r.push(o),s.push(a),a=0,d=o,o=o.children[0]):d?(a++,o=d.children[a],f=!1):o=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const o=[];for(;t;)t.leaf?n.push(...t.children):o.push(...t.children),t=o.pop();return n}_build(t,n,o,i){const r=o-n+1;let s=this._maxEntries,a;if(r<=s)return a=tt(t.slice(n,o+1)),K(a,this.toBBox),a;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),a=tt([]),a.leaf=!1,a.height=i;const d=Math.ceil(r/s),f=d*Math.ceil(Math.sqrt(s));Re(t,n,o,f,this.compareMinX);for(let g=n;g<=o;g+=f){const l=Math.min(g+f-1,o);Re(t,g,l,d,this.compareMinY);for(let m=g;m<=l;m+=d){const c=Math.min(m+d-1,l);a.children.push(this._build(t,m,c,i-1))}}return K(a,this.toBBox),a}_chooseSubtree(t,n,o,i){for(;i.push(n),!(n.leaf||i.length-1===o);){let r=1/0,s=1/0,a;for(let d=0;d<n.children.length;d++){const f=n.children[d],g=Nt(f),l=ro(t,f)-g;l<s?(s=l,r=g<r?g:r,a=f):l===s&&g<r&&(r=g,a=f)}n=a||n.children[0]}return n}_insert(t,n,o){const i=o?t:this.toBBox(t),r=[],s=this._chooseSubtree(i,this.data,n,r);for(s.children.push(t),at(s,i);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(i,r,n)}_split(t,n){const o=t[n],i=o.children.length,r=this._minEntries;this._chooseSplitAxis(o,r,i);const s=this._chooseSplitIndex(o,r,i),a=tt(o.children.splice(s,o.children.length-s));a.height=o.height,a.leaf=o.leaf,K(o,this.toBBox),K(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(o,a)}_splitRoot(t,n){this.data=tt([t,n]),this.data.height=t.height+1,this.data.leaf=!1,K(this.data,this.toBBox)}_chooseSplitIndex(t,n,o){let i,r=1/0,s=1/0;for(let a=n;a<=o-n;a++){const d=rt(t,0,a,this.toBBox),f=rt(t,a,o,this.toBBox),g=ao(d,f),l=Nt(d)+Nt(f);g<r?(r=g,i=a,s=l<s?l:s):g===r&&l<s&&(s=l,i=a)}return i||o-n}_chooseSplitAxis(t,n,o){const i=t.leaf?this.compareMinX:oo,r=t.leaf?this.compareMinY:io,s=this._allDistMargin(t,n,o,i),a=this._allDistMargin(t,n,o,r);s<a&&t.children.sort(i)}_allDistMargin(t,n,o,i){t.children.sort(i);const r=this.toBBox,s=rt(t,0,n,r),a=rt(t,o-n,o,r);let d=wt(s)+wt(a);for(let f=n;f<o-n;f++){const g=t.children[f];at(s,t.leaf?r(g):g),d+=wt(s)}for(let f=o-n-1;f>=n;f--){const g=t.children[f];at(a,t.leaf?r(g):g),d+=wt(a)}return d}_adjustParentBBoxes(t,n,o){for(let i=o;i>=0;i--)at(n[i],t)}_condense(t){for(let n=t.length-1,o;n>=0;n--)t[n].children.length===0?n>0?(o=t[n-1].children,o.splice(o.indexOf(t[n]),1)):this.clear():K(t[n],this.toBBox)}}function no(e,t,n){if(!n)return t.indexOf(e);for(let o=0;o<t.length;o++)if(n(e,t[o]))return o;return-1}function K(e,t){rt(e,0,e.children.length,t,e)}function rt(e,t,n,o,i){i||(i=tt(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=t;r<n;r++){const s=e.children[r];at(i,e.leaf?o(s):s)}return i}function at(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function oo(e,t){return e.minX-t.minX}function io(e,t){return e.minY-t.minY}function Nt(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function wt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function ro(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function ao(e,t){const n=Math.max(e.minX,t.minX),o=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,i-n)*Math.max(0,r-o)}function Ft(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function At(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function tt(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Re(e,t,n,o,i){const r=[t,n];for(;r.length;){if(n=r.pop(),t=r.pop(),n-t<=o)continue;const s=t+Math.ceil((n-t)/o/2)*o;Kn(e,s,t,n,i),r.push(t,s,s,n)}}let so=()=>({emit(e,...t){for(let n=0,o=this.events[e]||[],i=o.length;n<i;n++)o[n](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var o;this.events[e]=(o=this.events[e])==null?void 0:o.filter(i=>t!==i)}}});const lo=(e,t)=>{const n=new eo,o=new Map,i=so(),r=(A,h)=>{const E=A.selector.flatMap(O=>{const x=W([O])?O.range:Ct(O,t).range;return Array.from(x.getClientRects())}),R=qt(E).map(O=>Qt(O,h));return R.map(O=>{const{x,y:B,width:b,height:C}=O;return{minX:x,minY:B,maxX:x+b,maxY:B+C,annotation:{id:A.annotation,rects:R}}})},s=()=>[...o.values()],a=()=>{n.clear(),o.clear()},d=A=>{const h=r(A,t.getBoundingClientRect());h.forEach(E=>n.insert(E)),o.set(A.annotation,h)},f=A=>{const h=o.get(A.annotation);h&&(h.forEach(E=>n.remove(E)),o.delete(A.annotation))},g=A=>{f(A),d(A)},l=(A,h=!0)=>{h&&a();const E=t.getBoundingClientRect(),R=A.map(x=>({target:x,rects:r(x,E)}));R.forEach(({target:x,rects:B})=>o.set(x.annotation,B));const O=R.flatMap(({rects:x})=>x);n.load(O)},m=(A,h,E=!1)=>{const R=n.search({minX:A,minY:h,maxX:A,maxY:h}),O=x=>x.annotation.rects.reduce((B,b)=>B+b.width*b.height,0);return R.length>0?(R.sort((x,B)=>O(x)-O(B)),E?R.map(x=>x.annotation.id):[R[0].annotation.id]):[]},c=A=>{const h=S(A);if(h.length===0)return;let E=h[0].left,R=h[0].top,O=h[0].right,x=h[0].bottom;for(let B=1;B<h.length;B++){const b=h[B];E=Math.min(E,b.left),R=Math.min(R,b.top),O=Math.max(O,b.right),x=Math.max(x,b.bottom)}return new DOMRect(E,R,O-E,x-R)},S=A=>{const h=o.get(A);return h?h[0].annotation.rects:[]};return{all:s,clear:a,getAt:m,getAnnotationBounds:c,getAnnotationRects:S,getIntersecting:(A,h,E,R)=>{const O=n.search({minX:A,minY:h,maxX:E,maxY:R}),x=new Set(O.map(B=>B.annotation.id));return Array.from(x).map(B=>({annotation:e.getAnnotation(B),rects:S(B)})).filter(B=>!!B.annotation)},insert:d,recalculate:()=>{l(e.all().map(A=>A.target),!0),i.emit("recalculate")},remove:f,set:l,size:()=>n.all().length,update:g,on:(A,h)=>i.on(A,h)}},Be=(e,t)=>{const n=Nn(),o=lo(n,e),i=An(n,t),r=wn(n),s=Dn(),a=(w,p=V.LOCAL)=>{const u=ht(w,e),A=W(u.target.selector);return A&&n.addAnnotation(u,p),A},d=(w,p=!0,u=V.LOCAL)=>{const A=w.map(E=>ht(E,e)),h=A.filter(E=>!W(E.target.selector));return h.length>0?(console.warn("Could not revive all targets for these annotations:",h),n.bulkAddAnnotation(A,p,u),h):(n.bulkAddAnnotation(A,p,u),[])},f=(w,p=V.LOCAL)=>{const u=w.map(h=>ht(h,e)),A=u.filter(h=>!W(h.target.selector));return A.length>0&&console.warn("Could not revive all targets for these annotations:",A),u.forEach(h=>{n.getAnnotation(h.id)?n.updateAnnotation(h,p):n.addAnnotation(h,p)}),A},g=(w,p=V.LOCAL)=>{const u=nt(w,e);n.updateTarget(u,p)},l=(w,p=V.LOCAL)=>{const u=w.map(A=>nt(A,e));n.bulkUpdateTargets(u,p)},m=(w,p,u)=>{const A=o.getAt(w,p,!!u).map(E=>n.getAnnotation(E)),h=u?A.filter(u):A;return h.length>0?h[0]:void 0},c=(w,p,u,A=5)=>{const h=o.getAnnotationRects(w);if(h.length!==0){if(p&&u){const E=h.find(({top:R,right:O,bottom:x,left:B})=>p>=B-A&&p<=O+A&&u>=R-A&&u<=x+A);if(E)return E}return o.getAnnotationBounds(w)}},S=()=>o.recalculate(),v=w=>o.on("recalculate",w);return n.observe(({changes:w})=>{const p=(w.deleted||[]).filter(h=>W(h.target.selector)),u=(w.created||[]).filter(h=>W(h.target.selector)),A=(w.updated||[]).filter(h=>W(h.newValue.target.selector));(p==null?void 0:p.length)>0&&p.forEach(h=>o.remove(h.target)),u.length>0&&o.set(u.map(h=>h.target),!1),(A==null?void 0:A.length)>0&&A.forEach(({newValue:h})=>o.update(h.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotation:d,bulkUpdateTargets:l,bulkUpsertAnnotations:f,getAnnotationBounds:c,getAt:m,getIntersecting:o.getIntersecting.bind(o),getAnnotationRects:o.getAnnotationRects.bind(o),recalculatePositions:S,onRecalculatePositions:v,updateTarget:g},selection:i,hover:r,viewport:s}},co=()=>{const e=document.createElement("canvas");e.width=2*window.innerWidth,e.height=2*window.innerHeight,e.className="r6o-presence-layer";const t=e.getContext("2d");return t.scale(2,2),t.translate(.5,.5),e},uo=(e,t,n={})=>{const o=co(),i=o.getContext("2d");document.body.appendChild(o);const r=new Map,s=l=>Array.from(r.entries()).filter(([m,c])=>c.presenceKey===l.presenceKey).map(([m,c])=>m);return t.on("selectionChange",(l,m)=>{s(l).forEach(S=>r.delete(S)),m&&m.forEach(S=>r.set(S,l))}),{clear:()=>{const{width:l,height:m}=o;i.clearRect(-.5,-.5,l+1,m+1)},destroy:()=>{o.remove()},paint:(l,m,c)=>{n.font&&(i.font=n.font);const S=r.get(l.annotation.id);if(S){const{height:v}=l.rects[0],w=l.rects[0].x+m.left,p=l.rects[0].y+m.top;i.fillStyle=S.appearance.color,i.fillRect(w-2,p-2.5,2,v+5);const u=i.measureText(S.appearance.label),A=u.width+6,h=u.actualBoundingBoxAscent+u.actualBoundingBoxDescent+8,E=u.fontBoundingBoxAscent?8:6.5;return i.fillRect(w-2,p-2.5-h,A,h),i.fillStyle="#fff",i.fillText(S.appearance.label,w+1,p-E),{fill:S.appearance.color,fillOpacity:c?.45:.18}}},reset:()=>{o.width=2*window.innerWidth,o.height=2*window.innerHeight;const l=o.getContext("2d");l.scale(2,2),l.translate(.5,.5)}}},ke=e=>{if(e===null)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:ke(e.parentElement)},fo=(e,t)=>n=>{const o=typeof n=="string"?n:n.id,i=s=>{const a=r.getBoundingClientRect(),d=r.clientHeight,f=r.clientWidth,g=s.selector[0].range.getBoundingClientRect(),{width:l,height:m}=t.getAnnotationBounds(o),c=g.top-a.top,S=g.left-a.left,v=r.parentElement?r.scrollTop:0,w=r.parentElement?r.scrollLeft:0,p=c+v-(d-m)/2,u=S+w-(f-l)/2;r.scroll({top:p,left:u,behavior:"smooth"})},r=ke(e);if(r){const s=t.getAnnotation(o),{range:a}=s.target.selector[0];if(a&&!a.collapsed)return i(s.target),!0;{const d=nt(s.target,e),{range:f}=d.selector[0];if(f&&!f.collapsed)return i(d),!0}}return!1},Oe=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),It=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Pt(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on".concat(t),n)}function st(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Ve(e,t){const n=t.slice(0,t.length-1);for(let o=0;o<n.length;o++)n[o]=e[n[o].toLowerCase()];return n}function Ne(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function po(e,t){const n=e.length>=t.length?e:t,o=e.length>=t.length?t:e;let i=!0;for(let r=0;r<n.length;r++)o.indexOf(n[r])===-1&&(i=!1);return i}const lt={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":It?173:189,"=":It?61:187,";":It?59:186,"'":222,"[":219,"]":221,"\\":220},G={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Dt={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},U={16:!1,18:!1,17:!1,91:!1},F={};for(let e=1;e<20;e++)lt["f".concat(e)]=111+e;let N=[],ct=null,Fe="all";const q=new Map,dt=e=>lt[e.toLowerCase()]||G[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),ho=e=>Object.keys(lt).find(t=>lt[t]===e),go=e=>Object.keys(G).find(t=>G[t]===e);function Ie(e){Fe=e||"all"}function ut(){return Fe||"all"}function mo(){return N.slice(0)}function bo(){return N.map(e=>ho(e)||go(e)||String.fromCharCode(e))}function wo(){const e=[];return Object.keys(F).forEach(t=>{F[t].forEach(n=>{let{key:o,scope:i,mods:r,shortcut:s}=n;e.push({scope:i,shortcut:s,mods:r,keys:o.split("+").map(a=>dt(a))})})}),e}function Ao(e){const t=e.target||e.srcElement,{tagName:n}=t;let o=!0;const i=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(i||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(o=!1),o}function So(e){return typeof e=="string"&&(e=dt(e)),N.indexOf(e)!==-1}function vo(e,t){let n,o;e||(e=ut());for(const i in F)if(Object.prototype.hasOwnProperty.call(F,i))for(n=F[i],o=0;o<n.length;)n[o].scope===e?n.splice(o,1).forEach(s=>{let{element:a}=s;return yt(a)}):o++;ut()===e&&Ie(t||"all")}function Co(e){let t=e.keyCode||e.which||e.charCode;const n=N.indexOf(t);if(n>=0&&N.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&N.splice(0,N.length),(t===93||t===224)&&(t=91),t in U){U[t]=!1;for(const o in G)G[o]===t&&(_[o]=!1)}}function Pe(e){if(typeof e>"u")Object.keys(F).forEach(i=>{Array.isArray(F[i])&&F[i].forEach(r=>St(r)),delete F[i]}),yt(null);else if(Array.isArray(e))e.forEach(i=>{i.key&&St(i)});else if(typeof e=="object")e.key&&St(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];let[i,r]=n;typeof i=="function"&&(r=i,i=""),St({key:e,scope:i,method:r,splitKey:"+"})}}const St=e=>{let{key:t,scope:n,method:o,splitKey:i="+"}=e;Ne(t).forEach(s=>{const a=s.split(i),d=a.length,f=a[d-1],g=f==="*"?"*":dt(f);if(!F[g])return;n||(n=ut());const l=d>1?Ve(G,a):[],m=[];F[g]=F[g].filter(c=>{const v=(o?c.method===o:!0)&&c.scope===n&&po(c.mods,l);return v&&m.push(c.element),!v}),m.forEach(c=>yt(c))})};function De(e,t,n,o){if(t.element!==o)return;let i;if(t.scope===n||t.scope==="all"){i=t.mods.length>0;for(const r in U)Object.prototype.hasOwnProperty.call(U,r)&&(!U[r]&&t.mods.indexOf(+r)>-1||U[r]&&t.mods.indexOf(+r)===-1)&&(i=!1);(t.mods.length===0&&!U[16]&&!U[18]&&!U[17]&&!U[91]||i||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(N),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function ye(e,t){const n=F["*"];let o=e.keyCode||e.which||e.charCode;if(!_.filter.call(this,e))return;if((o===93||o===224)&&(o=91),N.indexOf(o)===-1&&o!==229&&N.push(o),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const d=Dt[a];e[a]&&N.indexOf(d)===-1?N.push(d):!e[a]&&N.indexOf(d)>-1?N.splice(N.indexOf(d),1):a==="metaKey"&&e[a]&&N.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(N=N.slice(N.indexOf(d))))}),o in U){U[o]=!0;for(const a in G)G[a]===o&&(_[a]=!0);if(!n)return}for(const a in U)Object.prototype.hasOwnProperty.call(U,a)&&(U[a]=e[Dt[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(N.indexOf(17)===-1&&N.push(17),N.indexOf(18)===-1&&N.push(18),U[17]=!0,U[18]=!0);const i=ut();if(n)for(let a=0;a<n.length;a++)n[a].scope===i&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&De(e,n[a],i,t);if(!(o in F))return;const r=F[o],s=r.length;for(let a=0;a<s;a++)if((e.type==="keydown"&&r[a].keydown||e.type==="keyup"&&r[a].keyup)&&r[a].key){const d=r[a],{splitKey:f}=d,g=d.key.split(f),l=[];for(let m=0;m<g.length;m++)l.push(dt(g[m]));l.sort().join("")===N.sort().join("")&&De(e,d,i,t)}}function _(e,t,n){N=[];const o=Ne(e);let i=[],r="all",s=document,a=0,d=!1,f=!0,g="+",l=!1,m=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(r=t.scope),t.element&&(s=t.element),t.keyup&&(d=t.keyup),t.keydown!==void 0&&(f=t.keydown),t.capture!==void 0&&(l=t.capture),typeof t.splitKey=="string"&&(g=t.splitKey),t.single===!0&&(m=!0)),typeof t=="string"&&(r=t),m&&Pe(e,r);a<o.length;a++)e=o[a].split(g),i=[],e.length>1&&(i=Ve(G,e)),e=e[e.length-1],e=e==="*"?"*":dt(e),e in F||(F[e]=[]),F[e].push({keyup:d,keydown:f,scope:r,mods:i,shortcut:o[a],method:n,key:o[a],splitKey:g,element:s});if(typeof s<"u"&&window){if(!q.has(s)){const c=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return ye(v,s)},S=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;ye(v,s),Co(v)};q.set(s,{keydownListener:c,keyupListenr:S,capture:l}),Pt(s,"keydown",c,l),Pt(s,"keyup",S,l)}if(!ct){const c=()=>{N=[]};ct={listener:c,capture:l},Pt(window,"focus",c,l)}}}function To(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(F).forEach(n=>{F[n].filter(i=>i.scope===t&&i.shortcut===e).forEach(i=>{i&&i.method&&i.method()})})}function yt(e){const t=Object.values(F).flat();if(t.findIndex(o=>{let{element:i}=o;return i===e})<0){const{keydownListener:o,keyupListenr:i,capture:r}=q.get(e)||{};o&&i&&(st(e,"keyup",i,r),st(e,"keydown",o,r),q.delete(e))}if((t.length<=0||q.size<=0)&&(Object.keys(q).forEach(i=>{const{keydownListener:r,keyupListenr:s,capture:a}=q.get(i)||{};r&&s&&(st(i,"keyup",s,a),st(i,"keydown",r,a),q.delete(i))}),q.clear(),Object.keys(F).forEach(i=>delete F[i]),ct)){const{listener:i,capture:r}=ct;st(window,"focus",i,r),ct=null}}const Ut={getPressedKeyString:bo,setScope:Ie,getScope:ut,deleteScope:vo,getPressedKeyCodes:mo,getAllKeyCodes:wo,isPressed:So,filter:Ao,trigger:To,unbind:Pe,keyMap:lt,modifier:G,modifierMap:Dt};for(const e in Ut)Object.prototype.hasOwnProperty.call(Ut,e)&&(_[e]=Ut[e]);if(typeof window<"u"){const e=window.hotkeys;_.noConflict=t=>(t&&window.hotkeys===_&&(window.hotkeys=e),_),window.hotkeys=_}var Ue={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.Unidentified="Unidentified",t.Alt="Alt",t.AltGraph="AltGraph",t.CapsLock="CapsLock",t.Control="Control",t.Fn="Fn",t.FnLock="FnLock",t.Hyper="Hyper",t.Meta="Meta",t.NumLock="NumLock",t.ScrollLock="ScrollLock",t.Shift="Shift",t.Super="Super",t.Symbol="Symbol",t.SymbolLock="SymbolLock",t.Enter="Enter",t.Tab="Tab",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.ArrowUp="ArrowUp",t.End="End",t.Home="Home",t.PageDown="PageDown",t.PageUp="PageUp",t.Backspace="Backspace",t.Clear="Clear",t.Copy="Copy",t.CrSel="CrSel",t.Cut="Cut",t.Delete="Delete",t.EraseEof="EraseEof",t.ExSel="ExSel",t.Insert="Insert",t.Paste="Paste",t.Redo="Redo",t.Undo="Undo",t.Accept="Accept",t.Again="Again",t.Attn="Attn",t.Cancel="Cancel",t.ContextMenu="ContextMenu",t.Escape="Escape",t.Execute="Execute",t.Find="Find",t.Finish="Finish",t.Help="Help",t.Pause="Pause",t.Play="Play",t.Props="Props",t.Select="Select",t.ZoomIn="ZoomIn",t.ZoomOut="ZoomOut",t.BrightnessDown="BrightnessDown",t.BrightnessUp="BrightnessUp",t.Eject="Eject",t.LogOff="LogOff",t.Power="Power",t.PowerOff="PowerOff",t.PrintScreen="PrintScreen",t.Hibernate="Hibernate",t.Standby="Standby",t.WakeUp="WakeUp",t.AllCandidates="AllCandidates",t.Alphanumeric="Alphanumeric",t.CodeInput="CodeInput",t.Compose="Compose",t.Convert="Convert",t.Dead="Dead",t.FinalMode="FinalMode",t.GroupFirst="GroupFirst",t.GroupLast="GroupLast",t.GroupNext="GroupNext",t.GroupPrevious="GroupPrevious",t.ModeChange="ModeChange",t.NextCandidate="NextCandidate",t.NonConvert="NonConvert",t.PreviousCandidate="PreviousCandidate",t.Process="Process",t.SingleCandidate="SingleCandidate",t.HangulMode="HangulMode",t.HanjaMode="HanjaMode",t.JunjaMode="JunjaMode",t.Eisu="Eisu",t.Hankaku="Hankaku",t.Hiragana="Hiragana",t.HiraganaKatakana="HiraganaKatakana",t.KanaMode="KanaMode",t.KanjiMode="KanjiMode",t.Katakana="Katakana",t.Romaji="Romaji",t.Zenkaku="Zenkaku",t.ZenkakuHanaku="ZenkakuHanaku",t.F1="F1",t.F2="F2",t.F3="F3",t.F4="F4",t.F5="F5",t.F6="F6",t.F7="F7",t.F8="F8",t.F9="F9",t.F10="F10",t.F11="F11",t.F12="F12",t.F13="F13",t.F14="F14",t.F15="F15",t.F16="F16",t.F17="F17",t.F18="F18",t.F19="F19",t.F20="F20",t.Soft1="Soft1",t.Soft2="Soft2",t.Soft3="Soft3",t.Soft4="Soft4",t.AppSwitch="AppSwitch",t.Call="Call",t.Camera="Camera",t.CameraFocus="CameraFocus",t.EndCall="EndCall",t.GoBack="GoBack",t.GoHome="GoHome",t.HeadsetHook="HeadsetHook",t.LastNumberRedial="LastNumberRedial",t.Notification="Notification",t.MannerMode="MannerMode",t.VoiceDial="VoiceDial",t.ChannelDown="ChannelDown",t.ChannelUp="ChannelUp",t.MediaFastForward="MediaFastForward",t.MediaPause="MediaPause",t.MediaPlay="MediaPlay",t.MediaPlayPause="MediaPlayPause",t.MediaRecord="MediaRecord",t.MediaRewind="MediaRewind",t.MediaStop="MediaStop",t.MediaTrackNext="MediaTrackNext",t.MediaTrackPrevious="MediaTrackPrevious",t.AudioBalanceLeft="AudioBalanceLeft",t.AudioBalanceRight="AudioBalanceRight",t.AudioBassDown="AudioBassDown",t.AudioBassBoostDown="AudioBassBoostDown",t.AudioBassBoostToggle="AudioBassBoostToggle",t.AudioBassBoostUp="AudioBassBoostUp",t.AudioBassUp="AudioBassUp",t.AudioFaderFront="AudioFaderFront",t.AudioFaderRear="AudioFaderRear",t.AudioSurroundModeNext="AudioSurroundModeNext",t.AudioTrebleDown="AudioTrebleDown",t.AudioTrebleUp="AudioTrebleUp",t.AudioVolumeDown="AudioVolumeDown",t.AudioVolumeMute="AudioVolumeMute",t.AudioVolumeUp="AudioVolumeUp",t.MicrophoneToggle="MicrophoneToggle",t.MicrophoneVolumeDown="MicrophoneVolumeDown",t.MicrophoneVolumeMute="MicrophoneVolumeMute",t.MicrophoneVolumeUp="MicrophoneVolumeUp",t.TV="TV",t.TV3DMode="TV3DMode",t.TVAntennaCable="TVAntennaCable",t.TVAudioDescription="TVAudioDescription",t.TVAudioDescriptionMixDown="TVAudioDescriptionMixDown",t.TVAudioDescriptionMixUp="TVAudioDescriptionMixUp",t.TVContentsMenu="TVContentsMenu",t.TVDataService="TVDataService",t.TVInput="TVInput",t.TVInputComponent1="TVInputComponent1",t.TVInputComponent2="TVInputComponent2",t.TVInputComposite1="TVInputComposite1",t.TVInputComposite2="TVInputComposite2",t.TVInputHDMI1="TVInputHDMI1",t.TVInputHDMI2="TVInputHDMI2",t.TVInputHDMI3="TVInputHDMI3",t.TVInputHDMI4="TVInputHDMI4",t.TVInputVGA1="TVInputVGA1",t.TVMediaContext="TVMediaContext",t.TVNetwork="TVNetwork",t.TVNumberEntry="TVNumberEntry",t.TVPower="TVPower",t.TVRadioService="TVRadioService",t.TVSatellite="TVSatellite",t.TVSatelliteBS="TVSatelliteBS",t.TVSatelliteCS="TVSatelliteCS",t.TVSatelliteToggle="TVSatelliteToggle",t.TVTerrestrialAnalog="TVTerrestrialAnalog",t.TVTerrestrialDigital="TVTerrestrialDigital",t.TVTimer="TVTimer",t.AVRInput="AVRInput",t.AVRPower="AVRPower",t.ColorF0Red="ColorF0Red",t.ColorF1Green="ColorF1Green",t.ColorF2Yellow="ColorF2Yellow",t.ColorF3Blue="ColorF3Blue",t.ColorF4Grey="ColorF4Grey",t.ColorF5Brown="ColorF5Brown",t.ClosedCaptionToggle="ClosedCaptionToggle",t.Dimmer="Dimmer",t.DisplaySwap="DisplaySwap",t.DVR="DVR",t.Exit="Exit",t.FavoriteClear0="FavoriteClear0",t.FavoriteClear1="FavoriteClear1",t.FavoriteClear2="FavoriteClear2",t.FavoriteClear3="FavoriteClear3",t.FavoriteRecall0="FavoriteRecall0",t.FavoriteRecall1="FavoriteRecall1",t.FavoriteRecall2="FavoriteRecall2",t.FavoriteRecall3="FavoriteRecall3",t.FavoriteStore0="FavoriteStore0",t.FavoriteStore1="FavoriteStore1",t.FavoriteStore2="FavoriteStore2",t.FavoriteStore3="FavoriteStore3",t.Guide="Guide",t.GuideNextDay="GuideNextDay",t.GuidePreviousDay="GuidePreviousDay",t.Info="Info",t.InstantReplay="InstantReplay",t.Link="Link",t.ListProgram="ListProgram",t.LiveContent="LiveContent",t.Lock="Lock",t.MediaApps="MediaApps",t.MediaAudioTrack="MediaAudioTrack",t.MediaLast="MediaLast",t.MediaSkipBackward="MediaSkipBackward",t.MediaSkipForward="MediaSkipForward",t.MediaStepBackward="MediaStepBackward",t.MediaStepForward="MediaStepForward",t.MediaTopMenu="MediaTopMenu",t.NavigateIn="NavigateIn",t.NavigateNext="NavigateNext",t.NavigateOut="NavigateOut",t.NavigatePrevious="NavigatePrevious",t.NextFavoriteChannel="NextFavoriteChannel",t.NextUserProfile="NextUserProfile",t.OnDemand="OnDemand",t.Pairing="Pairing",t.PinPDown="PinPDown",t.PinPMove="PinPMove",t.PinPToggle="PinPToggle",t.PinPUp="PinPUp",t.PlaySpeedDown="PlaySpeedDown",t.PlaySpeedReset="PlaySpeedReset",t.PlaySpeedUp="PlaySpeedUp",t.RandomToggle="RandomToggle",t.RcLowBattery="RcLowBattery",t.RecordSpeedNext="RecordSpeedNext",t.RfBypass="RfBypass",t.ScanChannelsToggle="ScanChannelsToggle",t.ScreenModeNext="ScreenModeNext",t.Settings="Settings",t.SplitScreenToggle="SplitScreenToggle",t.STBInput="STBInput",t.STBPower="STBPower",t.Subtitle="Subtitle",t.Teletext="Teletext",t.VideoModeNext="VideoModeNext",t.Wink="Wink",t.ZoomToggle="ZoomToggle",t.SpeechCorrectionList="SpeechCorrectionList",t.SpeechInputToggle="SpeechInputToggle",t.Close="Close",t.New="New",t.Open="Open",t.Print="Print",t.Save="Save",t.SpellCheck="SpellCheck",t.MailForward="MailForward",t.MailReply="MailReply",t.MailSend="MailSend",t.LaunchCalculator="LaunchCalculator",t.LaunchCalendar="LaunchCalendar",t.LaunchContacts="LaunchContacts",t.LaunchMail="LaunchMail",t.LaunchMediaPlayer="LaunchMediaPlayer",t.LaunchMusicPlayer="LaunchMusicPlayer",t.LaunchMyComputer="LaunchMyComputer",t.LaunchPhone="LaunchPhone",t.LaunchScreenSaver="LaunchScreenSaver",t.LaunchSpreadsheet="LaunchSpreadsheet",t.LaunchWebBrowser="LaunchWebBrowser",t.LaunchWebCam="LaunchWebCam",t.LaunchWordProcessor="LaunchWordProcessor",t.LaunchApplication1="LaunchApplication1",t.LaunchApplication2="LaunchApplication2",t.LaunchApplication3="LaunchApplication3",t.LaunchApplication4="LaunchApplication4",t.LaunchApplication5="LaunchApplication5",t.LaunchApplication6="LaunchApplication6",t.LaunchApplication7="LaunchApplication7",t.LaunchApplication8="LaunchApplication8",t.LaunchApplication9="LaunchApplication9",t.LaunchApplication10="LaunchApplication10",t.LaunchApplication11="LaunchApplication11",t.LaunchApplication12="LaunchApplication12",t.LaunchApplication13="LaunchApplication13",t.LaunchApplication14="LaunchApplication14",t.LaunchApplication15="LaunchApplication15",t.LaunchApplication16="LaunchApplication16",t.BrowserBack="BrowserBack",t.BrowserFavorites="BrowserFavorites",t.BrowserForward="BrowserForward",t.BrowserHome="BrowserHome",t.BrowserRefresh="BrowserRefresh",t.BrowserSearch="BrowserSearch",t.BrowserStop="BrowserStop",t.Decimal="Decimal",t.Key11="Key11",t.Key12="Key12",t.Multiply="Multiply",t.Add="Add",t.Divide="Divide",t.Subtract="Subtract",t.Separator="Separator"}(e.Key||(e.Key={}))})(Ue);const Eo=(e,t,n)=>{let o;const i=h=>o=h;let r;const s=h=>r=h;let a=!0;const d=h=>a=h,{store:f,selection:g}=t;let l,m,c;const S=h=>{var R;if(!a||m===!1)return;l=!((R=h.target.parentElement)!=null&&R.closest(X))?{annotation:we(),selector:[],creator:o,created:new Date}:void 0};e.addEventListener("selectstart",S);const v=pt(h=>{var T,L;if(!a)return;const E=document.getSelection();if(!!((L=(T=E.anchorNode)==null?void 0:T.parentElement)!=null&&L.closest(X))){l=void 0;return}if(h.timeStamp-((c==null?void 0:c.timeStamp)||h.timeStamp)<1e3&&!l&&S(c||h),E.isCollapsed||!l||m===!1)return;const x=E.getRangeAt(0),B=Jt(x,e);if(zt(B))return;const b=Ht(B.cloneRange());(b.length!==l.selector.length||b.some((k,I)=>{var j;return k.toString()!==((j=l.selector[I])==null?void 0:j.quote)}))&&(l={...l,selector:b.map(k=>Zt(k,e,n)),updated:new Date},f.getAnnotation(l.annotation)?f.updateTarget(l,V.LOCAL):(g.clear(),f.addAnnotation({id:l.annotation,bodies:[],target:l},V.LOCAL),g.userSelect(l.annotation,c)))});document.addEventListener("selectionchange",v);const w=h=>{c=Kt(h),m=c.button===0};document.addEventListener("pointerdown",w);const p=h=>{var x;if(!!((x=h.target.parentElement)!=null&&x.closest(X))||!m)return;const R=()=>{const{x:B,y:b}=e.getBoundingClientRect(),C=h.target instanceof Node&&e.contains(h.target)&&f.getAt(h.clientX-B,h.clientY-b,r);if(C){const{selected:T}=g;(T.length!==1||T[0].id!==C.id)&&g.userSelect(C.id,h)}else g.isEmpty()||g.clear()},O=h.timeStamp-c.timeStamp;document.getSelection().isCollapsed&&O<300?(l=void 0,R()):l&&g.userSelect(l.annotation,h)};document.addEventListener("pointerup",p),_("*",{element:e,keyup:!1,keydown:!0},(h,E)=>{h.repeat||(c=te(h))}),_("*",{keyup:!0,keydown:!1},h=>{_.shift&&h.key===Ue.Key.Shift&&!h.repeat&&l&&g.userSelect(l.annotation,h)});let u=!1;return _("ctrl+a, ⌘+a",{keyup:!1,keydown:!0},()=>{u=!0}),_("*",{keyup:!0,keydown:!1},h=>{u&&!h.repeat&&l&&g.userSelect(l.annotation,h),u=!1}),{destroy:()=>{e.removeEventListener("selectstart",S),document.removeEventListener("selectionchange",v),document.removeEventListener("pointerdown",w),document.removeEventListener("pointerup",p),_.unbind()},setFilter:s,setUser:i,setAnnotatingEnabled:d}},_e="SPANS",Lo=(e,t={})=>{Yt(e),Xt(e);const n=Oe(t,{annotatingEnabled:!0,user:Wn()}),o=Be(e,n.userSelectAction),{selection:i,viewport:r}=o,s=o.store,a=Pn(s),d=yn(o,a,n.adapter);let f=n.user;const g=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":_e:n.renderer||_e,l=g==="SPANS"?me(e,o,r):g==="CSS_HIGHLIGHTS"?he(e,o,r):g==="CANVAS"?ee(e,o,r):void 0;if(!l)throw`Unknown renderer implementation: ${g}`;console.debug(`Using ${g} renderer`),n.style&&l.setStyle(n.style);const m=Eo(e,o,n.offsetReferenceSelector);m.setUser(f),m.setAnnotatingEnabled(n.annotatingEnabled);const c=_n(o,a,n.adapter),S=()=>f,v=E=>{m.setAnnotatingEnabled(E)},w=E=>{l.setFilter(E),m.setFilter(E)},p=E=>{f=E,m.setUser(E)},u=E=>{E&&(l.setPainter(uo(e,E,n.presence)),E.on("selectionChange",()=>l.redraw()))},A=E=>{E?i.setSelected(E):i.clear()};return{...c,destroy:()=>{l.destroy(),m.destroy(),a.destroy()},element:e,getUser:S,setAnnotatingEnabled:v,setFilter:w,setStyle:l.setStyle.bind(l),redraw:l.redraw.bind(l),setUser:p,setSelected:A,setPresenceProvider:u,setVisible:l.setVisible.bind(l),on:d.on,off:d.off,scrollIntoView:fo(e,s),state:o}};M.DEFAULT_SELECTED_STYLE=et,M.DEFAULT_STYLE=H,M.NOT_ANNOTATABLE_CLASS=vt,M.NOT_ANNOTATABLE_SELECTOR=X,M.Origin=V,M.UserSelectAction=Se,M.W3CTextFormat=Zn,M.cancelSingleClickEvents=Yt,M.cloneKeyboardEvent=te,M.clonePointerEvent=Kt,M.createBody=Ln,M.createCanvasRenderer=ee,M.createHighlightsRenderer=he,M.createRenderer=pe,M.createSpansRenderer=me,M.createTextAnnotator=Lo,M.createTextAnnotatorState=Be,M.debounce=pt,M.denormalizeRectWithOffset=Ze,M.fillDefaults=Oe,M.getAnnotatableFragment=Xe,M.getClientRectsPonyfill=We,M.getQuoteContext=Wt,M.getRangeAnnotatableContents=ft,M.isRevived=W,M.isWhitespaceOrEmpty=zt,M.mergeClientRects=qt,M.normalizeRectWithOffset=Qt,M.paint=_t,M.parseW3CTextAnnotation=Le,M.programmaticallyFocusable=Xt,M.rangeToSelector=Zt,M.reviveAnnotation=ht,M.reviveSelector=Ct,M.reviveTarget=nt,M.serializeW3CTextAnnotation=xe,M.splitAnnotatableRanges=Ht,M.toDomRectList=qe,M.trimRangeToContainer=Jt,M.whitespaceOrEmptyRegex=Gt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
3
3
|
//# sourceMappingURL=text-annotator.umd.js.map
|