@recogito/text-annotator 3.0.0-rc.29 → 3.0.0-rc.30
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.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(L,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(L=typeof globalThis<"u"?globalThis:L||self,D(L.RecogitoJS={}))})(this,function(L){"use strict";const D={fill:"rgb(0, 128, 255)",fillOpacity:.18},G={fill:"rgb(0, 128, 255)",fillOpacity:.45},At=(t,e,n,o,i)=>{var a,s;const r=n?typeof n=="function"?n(t.annotation,t.state,i)||((a=t.state)!=null&&a.selected?G:D):n:(s=t.state)!=null&&s.selected?G:D;return o&&o.paint(t,e)||r},lt="not-annotatable",X=`.${lt}`,ae=t=>{var n;const e=t.commonAncestorContainer;return e instanceof HTMLElement?!e.closest(X):!((n=e.parentElement)!=null&&n.closest(X))},ce=function*(t){const e=document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(lt)&&!o.parentElement.closest(X)&&t.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=e.nextNode();)n instanceof HTMLElement&&(yield n)},Et=t=>{if(!ae(t))return[];const e=[];let n=null;for(const o of ce(t)){let i;n?(i=document.createRange(),i.setStartAfter(n),i.setEndBefore(o)):(i=t.cloneRange(),i.setEndBefore(o)),i.collapsed||e.push(i),n=o}if(n){const o=t.cloneRange();o.setStartAfter(n),o.collapsed||e.push(o)}return e.length>0?e:[t]},et=t=>{const e=t.cloneContents();return e.querySelectorAll(X).forEach(n=>n.remove()),e},xt=t=>{t.addEventListener("click",e=>{!e.target.closest(X)&&!e.target.closest("a")&&e.preventDefault()})},nt=(t,e=10)=>{let n;return(...o)=>{clearTimeout(n),n=setTimeout(()=>t.apply(void 0,o),e)}},le=t=>{const e=t.cloneContents();return e.querySelectorAll(X).forEach(n=>n.remove()),e},St=(t,e)=>{const n=document.createNodeIterator(e);let o=0,i=n.nextNode();for(;i!==null;){if(i===t)return o;o+=1,i=n.nextNode()}},Tt=(t,e)=>{const n=document.createNodeIterator(e);let o=null;for(let i=0;i<t+1;i++)o=n.nextNode();return o},de=t=>{const{commonAncestorContainer:e,startContainer:n,startOffset:o,endContainer:i,endOffset:r}=t,a=Array.from(e.childNodes).map(c=>{const p=c.cloneNode(!0);return c.nodeName==="CANVAS"?c:p}),s=St(n,e),u=St(i,e),f=()=>{const c=e;c.replaceChildren(...a);const p=Tt(s,c),g=Tt(u,c);return t.setStart(p,o),t.setEnd(g,r),t},m=c=>{const p=document.createElement("SPAN");return c.surroundContents(p),p};if(n===i)throw"Not implemented";{const c=document.createRange();c.selectNodeContents(n),c.setStart(n,o);const p=m(c),g=document.createRange();g.selectNode(i),g.setEnd(i,r);const A=m(g),h=ue(t).reverse().map(d=>{var y;const l=document.createElement("SPAN");return(y=d.parentNode)==null||y.insertBefore(l,d),l.appendChild(d),l});return{unwrap:f,nodes:[p,...h,A]}}},ue=t=>{const{commonAncestorContainer:e,startContainer:n,endContainer:o}=t,i=document.createNodeIterator(e,NodeFilter.SHOW_TEXT);let r=i.nextNode(),a=!1;const s=[];for(;r!=null;)r===o&&(a=!1),a&&s.push(r),r===n&&(a=!0),r=i.nextNode();return s},he=t=>{const{startContainer:e,endContainer:n}=t;if(e===n)return Array.from(t.getClientRects());{const{unwrap:o,nodes:i}=de(t),r=i.reduce((a,s)=>[...a,...s.getClientRects()],[]);return o(),r}},Ct=(t,e,n=10,o)=>{const i=o?t.startContainer.parentElement.closest(o):e,r=document.createRange();r.setStart(i,0),r.setEnd(t.startContainer,t.startOffset);const a=et(r).textContent,s=document.createRange();s.setStart(t.endContainer,t.endOffset),i===document.body?s.setEnd(i,i.childNodes.length):s.setEndAfter(i);const u=et(s).textContent;return{prefix:a.substring(a.length-n),suffix:u.substring(0,n)}},H=t=>t.every(e=>e.range instanceof Range&&!e.range.collapsed),fe=(t,e)=>{const n=r=>Math.round(r*10)/10,o={top:n(t.top),bottom:n(t.bottom),left:n(t.left),right:n(t.right)},i={top:n(e.top),bottom:n(e.bottom),left:n(e.left),right:n(e.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=(t,e)=>{const n=Math.min(t.left,e.left),o=Math.max(t.right,e.right),i=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom);return new DOMRect(n,i,o-n,r-i)},Rt=t=>t.reduce((e,n)=>{if(n.width===0||n.height===0)return e;let o=[...e],i=!1;for(const r of e){const a=fe(n,r);if(a==="inline-adjacent"){o=o.map(s=>s===r?ge(n,r):s),i=!0;break}else if(a==="inline-contains"){o=o.map(s=>s===r?n:s),i=!0;break}else if(a==="inline-is-contained"){i=!0;break}else if(a==="block-contains"||a==="block-is-contained"){n.width<r.width&&(o=o.map(s=>s===r?n:s)),i=!0;break}}return i?o:[...o,n]},[]),Nt=(t,e,n)=>{const o=document.createRange(),i=n?t.startContainer.parentElement.closest(n):e;o.setStart(i,0),o.setEnd(t.startContainer,t.startOffset);const r=et(o).textContent,a=t.toString(),s=r.length||0,u=s+a.length;return n?{quote:a,start:s,end:u,range:t,offsetReference:i}:{quote:a,start:s,end:u,range:t}},dt=(t,e)=>{var m,c;const{start:n,end:o}=t,i=t.offsetReference||e,r=document.createNodeIterator(e,NodeFilter.SHOW_TEXT,p=>{var g;return(g=p.parentElement)!=null&&g.closest(X)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let a=0;const s=document.createRange();let u=r.nextNode();u===null&&console.error("Could not revive annotation target. Content missing.");let f=!i;for(;u!==null;){if(f||(f=i==null?void 0:i.contains(u)),f){const p=((m=u.textContent)==null?void 0:m.length)||0;if(a+p>n){s.setStart(u,n-a);break}a+=p}u=r.nextNode()}for(;u!==null;){const p=((c=u.textContent)==null?void 0:c.length)||0;if(a+p>=o){s.setEnd(u,o-a);break}a+=p,u=r.nextNode()}return{...t,range:s}},Q=(t,e)=>H(t.selector)?t:{...t,selector:t.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:dt(n,e))},ot=(t,e)=>H(t.target.selector)?t:{...t,target:Q(t.target,e)},Lt=t=>{var i;const{startContainer:e,endContainer:n}=t;if(e.nodeType===Node.TEXT_NODE&&n.nodeType===Node.TEXT_NODE)return t;if(e.nodeType!==Node.TEXT_NODE){const r=e.nextSibling||e.parentNode,a=(r==null?void 0:r.nodeType)===Node.TEXT_NODE?r:Array.from(r.childNodes).filter(s=>s.nodeType===Node.TEXT_NODE).shift();t.setEnd(a,0)}if(n.nodeType!==Node.TEXT_NODE){const r=n.previousSibling||n.parentNode,a=(r==null?void 0:r.nodeType)===Node.TEXT_NODE?r:Array.from(r.childNodes).filter(s=>s.nodeType===Node.TEXT_NODE).pop();t.setEnd(a,((i=a==null?void 0:a.textContent)==null?void 0:i.length)||0)}return t},pe=t=>{const{top:e,left:n}=t.getBoundingClientRect(),{innerWidth:o,innerHeight:i}=window,r=-n,a=-e,s=o-n,u=i-e;return{top:e,left:n,minX:r,minY:a,maxX:s,maxY:u}},me=t=>{let e=new Set;return o=>{const i=o.map(r=>r.id);(e.size!==i.length||i.some(r=>!e.has(r)))&&t.set(i),e=new Set(i)}},ut=(t,e,n,o)=>{const{store:i,selection:r,hover:a}=e;let s,u,f;const m=me(n),c=N=>{const{x:I,y:b}=t.getBoundingClientRect(),w=i.getAt(N.clientX-I,N.clientY-b);w&&(!u||u(w))?a.current!==w.id&&(t.classList.add("hovered"),a.set(w.id)):a.current&&(t.classList.remove("hovered"),a.set(null))};t.addEventListener("pointermove",c);const p=(N=!1)=>{f&&f.clear();const I=pe(t),{minX:b,minY:w,maxX:E,maxY:S}=I,B=u?i.getIntersecting(b,w,E,S).filter(({annotation:P})=>u(P)):i.getIntersecting(b,w,E,S),M=r.selected.map(({id:P})=>P),F=B.map(({annotation:P,rects:On})=>{const In=M.includes(P.id),Mn=P.id===a.current;return{annotation:P,rects:On,state:{selected:In,hover:Mn}}});o.redraw(F,I,s,f,N),setTimeout(()=>m(B.map(({annotation:P})=>P)),1)},g=N=>{f=N,p()},A=N=>{s=N,p()},v=N=>{u=N,p(!1)},h=()=>p();i.observe(h);const d=r.subscribe(()=>p()),l=()=>p(!0);document.addEventListener("scroll",l,{capture:!0,passive:!0});const y=nt(()=>{i.recalculatePositions(),f&&f.reset(),p()});window.addEventListener("resize",y);const C=new ResizeObserver(y);C.observe(t);const T={attributes:!0,childList:!0,subtree:!0},x=new MutationObserver(N=>{N.every(b=>b.target===t||t.contains(b.target))||p(!0)});return x.observe(document.body,T),{destroy:()=>{t.removeEventListener("pointermove",c),o.destroy(),i.unobserve(h),d(),document.removeEventListener("scroll",l),window.removeEventListener("resize",y),C.disconnect(),x.disconnect()},redraw:p,setStyle:A,setFilter:v,setPainter:g,setVisible:o.setVisible}},be=()=>{const t=document.createElement("canvas");return t.width=window.innerWidth,t.height=window.innerHeight,t.className="r6o-highlight-layer bg",t},ve=(t,e)=>{t.width=window.innerWidth,t.height=window.innerHeight},ye=t=>{t.classList.add("r6o-annotatable");const e=be(),n=e.getContext("2d");t.insertBefore(e,t.firstChild);const o=(s,u,f,m)=>requestAnimationFrame(()=>{const{width:c,height:p}=e;n.clearRect(-.5,-.5,c+1,p+1),m&&m.clear();const{top:g,left:A}=u;[...s].sort((h,d)=>{const{annotation:{target:{created:l}}}=h,{annotation:{target:{created:y}}}=d;return l.getTime()-y.getTime()}).forEach(h=>{var T;const d=f?typeof f=="function"?f(h.annotation,h.state):f:(T=h.state)!=null&&T.selected?G:D,l=m&&m.paint(h,u)||d,y=h.rects.map(({x,y:R,width:N,height:I})=>({x:x+A,y:R+g,width:N,height:I}));n.fillStyle=l.fill,n.globalAlpha=l.fillOpacity||1;const C=5;if(y.forEach(({x,y:R,width:N,height:I})=>n.fillRect(x,R-C/2,N,I+C)),l.underlineColor){n.globalAlpha=1,n.strokeStyle=l.underlineColor,n.lineWidth=l.underlineThickness??1;const x=C/2+(l.underlineOffset??0);y.forEach(({x:R,y:N,width:I,height:b})=>{n.beginPath(),n.moveTo(R,N+b+x),n.lineTo(R+I,N+b+x),n.stroke()})}})}),i=nt(()=>{ve(e)});return window.addEventListener("resize",i),{destroy:()=>{t.removeChild(e),window.removeEventListener("resize",i)},setVisible:s=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},Bt=(t,e,n)=>ut(t,e,n,ye(t));var we={grad:.9,turn:360,rad:360/(2*Math.PI)},$=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},_=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},k=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},Ot=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},It=function(t){return{r:k(t.r,0,255),g:k(t.g,0,255),b:k(t.b,0,255),a:k(t.a)}},ht=function(t){return{r:_(t.r),g:_(t.g),b:_(t.b),a:_(t.a,3)}},Ae=/^#([0-9a-f]{3,8})$/i,it=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Mt=function(t){var e=t.r,n=t.g,o=t.b,i=t.a,r=Math.max(e,n,o),a=r-Math.min(e,n,o),s=a?r===e?(n-o)/a:r===n?2+(o-e)/a:4+(e-n)/a:0;return{h:60*(s<0?s+6:s),s:r?a/r*100:0,v:r/255*100,a:i}},_t=function(t){var e=t.h,n=t.s,o=t.v,i=t.a;e=e/360*6,n/=100,o/=100;var r=Math.floor(e),a=o*(1-n),s=o*(1-(e-r)*n),u=o*(1-(1-e+r)*n),f=r%6;return{r:255*[o,s,a,a,u,o][f],g:255*[u,o,o,s,a,a][f],b:255*[a,a,u,o,o,s][f],a:i}},Ut=function(t){return{h:Ot(t.h),s:k(t.s,0,100),l:k(t.l,0,100),a:k(t.a)}},Vt=function(t){return{h:_(t.h),s:_(t.s),l:_(t.l),a:_(t.a,3)}},Dt=function(t){return _t((n=(e=t).s,{h:e.h,s:(n*=((o=e.l)<50?o:100-o)/100)>0?2*n/(o+n)*100:0,v:o+n,a:e.a}));var e,n,o},J=function(t){return{h:(e=Mt(t)).h,s:(i=(200-(n=e.s))*(o=e.v)/100)>0&&i<200?n*o/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,o,i},Ee=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,xe=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Se=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Te=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,kt={string:[[function(t){var e=Ae.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?_(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?_(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Se.exec(t)||Te.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:It({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Ee.exec(t)||xe.exec(t);if(!e)return null;var n,o,i=Ut({h:(n=e[1],o=e[2],o===void 0&&(o="deg"),Number(n)*(we[o]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Dt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,o=t.b,i=t.a,r=i===void 0?1:i;return $(e)&&$(n)&&$(o)?It({r:Number(e),g:Number(n),b:Number(o),a:Number(r)}):null},"rgb"],[function(t){var e=t.h,n=t.s,o=t.l,i=t.a,r=i===void 0?1:i;if(!$(e)||!$(n)||!$(o))return null;var a=Ut({h:Number(e),s:Number(n),l:Number(o),a:Number(r)});return Dt(a)},"hsl"],[function(t){var e=t.h,n=t.s,o=t.v,i=t.a,r=i===void 0?1:i;if(!$(e)||!$(n)||!$(o))return null;var a=function(s){return{h:Ot(s.h),s:k(s.s,0,100),v:k(s.v,0,100),a:k(s.a)}}({h:Number(e),s:Number(n),v:Number(o),a:Number(r)});return _t(a)},"hsv"]]},Xt=function(t,e){for(var n=0;n<e.length;n++){var o=e[n][0](t);if(o)return[o,e[n][1]]}return[null,void 0]},Ce=function(t){return typeof t=="string"?Xt(t.trim(),kt.string):typeof t=="object"&&t!==null?Xt(t,kt.object):[null,void 0]},ft=function(t,e){var n=J(t);return{h:n.h,s:k(n.s+100*e,0,100),l:n.l,a:n.a}},gt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Yt=function(t,e){var n=J(t);return{h:n.h,s:n.s,l:k(n.l+100*e,0,100),a:n.a}},Ht=function(){function t(e){this.parsed=Ce(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return _(gt(this.rgba),2)},t.prototype.isDark=function(){return gt(this.rgba)<.5},t.prototype.isLight=function(){return gt(this.rgba)>=.5},t.prototype.toHex=function(){return e=ht(this.rgba),n=e.r,o=e.g,i=e.b,a=(r=e.a)<1?it(_(255*r)):"","#"+it(n)+it(o)+it(i)+a;var e,n,o,i,r,a},t.prototype.toRgb=function(){return ht(this.rgba)},t.prototype.toRgbString=function(){return e=ht(this.rgba),n=e.r,o=e.g,i=e.b,(r=e.a)<1?"rgba("+n+", "+o+", "+i+", "+r+")":"rgb("+n+", "+o+", "+i+")";var e,n,o,i,r},t.prototype.toHsl=function(){return Vt(J(this.rgba))},t.prototype.toHslString=function(){return e=Vt(J(this.rgba)),n=e.h,o=e.s,i=e.l,(r=e.a)<1?"hsla("+n+", "+o+"%, "+i+"%, "+r+")":"hsl("+n+", "+o+"%, "+i+"%)";var e,n,o,i,r},t.prototype.toHsv=function(){return e=Mt(this.rgba),{h:_(e.h),s:_(e.s),v:_(e.v),a:_(e.a,3)};var e},t.prototype.invert=function(){return Y({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),Y(ft(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),Y(ft(this.rgba,-e))},t.prototype.grayscale=function(){return Y(ft(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),Y(Yt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),Y(Yt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?Y({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):_(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=J(this.rgba);return typeof e=="number"?Y({h:e,s:n.s,l:n.l,a:n.a}):_(n.h)},t.prototype.isEqual=function(e){return this.toHex()===Y(e).toHex()},t}(),Y=function(t){return t instanceof Ht?t:new Ht(t)};const Re=t=>[`background-color:${Y((t==null?void 0:t.fill)||D.fill).alpha((t==null?void 0:t.fillOpacity)===void 0?D.fillOpacity:t.fillOpacity).toHex()}`,t!=null&&t.underlineThickness?"text-decoration:underline":void 0,t!=null&&t.underlineColor?`text-decoration-color:${t.underlineColor}`:void 0,t!=null&&t.underlineOffset?`text-underline-offset:${t.underlineOffset}px`:void 0,t!=null&&t.underlineThickness?`text-decoration-thickness:${t.underlineThickness}px`:void 0].filter(Boolean).join(";"),$t=()=>{const t=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(t);let e=new Set;return{destroy:()=>{CSS.highlights.clear(),t.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,a,s,u)=>{u&&u.clear();const f=new Set(r.map(c=>c.annotation.id));Array.from(e).filter(c=>!f.has(c));const m=r.map(c=>{var A;const p=s?typeof s=="function"?s(c.annotation,c.state):s:(A=c.state)!=null&&A.selected?G:D,g=u&&u.paint(c,a)||p;return`::highlight(_${c.annotation.id}) { ${Re(g)} }`});t.innerHTML=m.join(`
|
|
2
|
-
`),CSS.highlights.clear(),r.forEach(({annotation:c})=>{const p=c.target.selector.map(A=>A.range),g=new Highlight(...p);CSS.highlights.set(`_${c.id}`,g)}),e=f}}},Pt=(t,e,n)=>ut(t,e,n,$t());var Ft=Object.prototype.hasOwnProperty;function pt(t,e){var n,o;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((o=t.length)===e.length)for(;o--&&pt(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Ft.call(t,n)&&++o&&!Ft.call(e,n)||!(n in e)||!pt(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}const Ne=(t,e)=>{const n=(o,i)=>o.x<=i.x+i.width&&o.x+o.width>=i.x&&o.y<=i.y+i.height&&o.y+o.height>=i.y;return e.filter(o=>t!==o&&n(t,o)&&o.width>t.width).length},Le=t=>{t.classList.add("r6o-annotatable");const e=document.createElement("div");e.className="r6o-span-highlight-layer",t.insertBefore(e,t.firstChild);let n=[];return{destroy:()=>{e.remove()},redraw:(a,s,u,f,m)=>{const p=!(pt(n,a)&&m);if(!f&&!p)return;p&&(e.innerHTML="");const g=a.reduce((A,{rects:v})=>[...A,...v],[]);a.forEach(A=>{A.rects.map(v=>{const h=Ne(v,g),d=At(A,s,u,f,h);if(p){const l=document.createElement("span");l.className="r6o-annotation",l.dataset.annotation=A.annotation.id,l.style.left=`${v.x}px`,l.style.top=`${v.y}px`,l.style.width=`${v.width}px`,l.style.height=`${v.height}px`;const y=Y((d==null?void 0:d.fill)||D.fill).alpha((d==null?void 0:d.fillOpacity)===void 0?D.fillOpacity:d.fillOpacity).toHex();l.style.backgroundColor=y,d.underlineStyle&&(l.style.borderStyle=d.underlineStyle),d.underlineColor&&(l.style.borderColor=d.underlineColor),d.underlineThickness&&(l.style.borderBottomWidth=`${d.underlineThickness}px`),d.underlineOffset&&(l.style.paddingBottom=`${d.underlineOffset}px`),e.appendChild(l)}})}),n=a},setVisible:a=>{a?e.classList.remove("hidden"):e.classList.add("hidden")}}},zt=(t,e,n)=>ut(t,e,n,Le(t));let rt;const Be=new Uint8Array(16);function Oe(){if(!rt&&(rt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!rt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return rt(Be)}const U=[];for(let t=0;t<256;++t)U.push((t+256).toString(16).slice(1));function Ie(t,e=0){return U[t[e+0]]+U[t[e+1]]+U[t[e+2]]+U[t[e+3]]+"-"+U[t[e+4]]+U[t[e+5]]+"-"+U[t[e+6]]+U[t[e+7]]+"-"+U[t[e+8]]+U[t[e+9]]+"-"+U[t[e+10]]+U[t[e+11]]+U[t[e+12]]+U[t[e+13]]+U[t[e+14]]+U[t[e+15]]}const Wt={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function jt(t,e,n){if(Wt.randomUUID&&!e&&!t)return Wt.randomUUID();t=t||{};const o=t.random||(t.rng||Oe)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Ie(o)}var qt=Object.prototype.hasOwnProperty;function z(t,e){var n,o;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((o=t.length)===e.length)for(;o--&&z(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(qt.call(t,n)&&++o&&!qt.call(e,n)||!(n in e)||!z(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}function mt(){}function Me(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}const W=[];function bt(t,e=mt){let n;const o=new Set;function i(s){if(Me(t,s)&&(t=s,n)){const u=!W.length;for(const f of o)f[1](),W.push(f,t);if(u){for(let f=0;f<W.length;f+=2)W[f][0](W[f+1]);W.length=0}}}function r(s){i(s(t))}function a(s,u=mt){const f=[s,u];return o.add(f),o.size===1&&(n=e(i,r)||mt),s(t),()=>{o.delete(f),o.size===0&&n&&(n(),n=null)}}return{set:i,update:r,subscribe:a}}const _e=t=>{const{subscribe:e,set:n}=bt();let o;return e(i=>o=i),t.observe(({changes:i})=>{if(o){(i.deleted||[]).some(a=>a.id===o)&&n(void 0);const r=(i.updated||[]).find(({oldValue:a})=>a.id===o);r&&n(r.newValue.id)}}),{get current(){return o},subscribe:e,set:n}};var Gt=(t=>(t.EDIT="EDIT",t.SELECT="SELECT",t.NONE="NONE",t))(Gt||{});const vt={selected:[]},Ue=(t,e="EDIT")=>{const{subscribe:n,set:o}=bt(vt);let i=vt;n(c=>i=c);const r=()=>o(vt),a=()=>{var c;return((c=i.selected)==null?void 0:c.length)===0},s=c=>{if(i.selected.length===0)return!1;const p=typeof c=="string"?c:c.id;return i.selected.some(g=>g.id===p)},u=(c,p)=>{const g=t.getAnnotation(c);if(g){const A=Ve(g,e);o(A==="EDIT"?{selected:[{id:c,editable:!0}],pointerEvent:p}:A==="SELECT"?{selected:[{id:c}],pointerEvent:p}:{selected:[],pointerEvent:p})}else console.warn("Invalid selection: "+c)},f=(c,p=!0)=>{const g=Array.isArray(c)?c:[c],A=g.map(v=>t.getAnnotation(v)).filter(Boolean);o({selected:A.map(({id:v})=>({id:v,editable:p}))}),A.length!==g.length&&console.warn("Invalid selection",c)},m=c=>{if(i.selected.length===0)return!1;const{selected:p}=i;p.filter(({id:g})=>c.includes(g)).length>0&&o({selected:p.filter(({id:g})=>!c.includes(g))})};return t.observe(({changes:c})=>m((c.deleted||[]).map(p=>p.id))),{clear:r,clickSelect:u,get selected(){return i?[...i.selected]:null},get pointerEvent(){return i?i.pointerEvent:null},isEmpty:a,isSelected:s,setSelected:f,subscribe:n}},Ve=(t,e)=>typeof e=="function"?e(t)||"EDIT":e||"EDIT";let st;const De=new Uint8Array(16);function ke(){if(!st&&(st=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!st))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return st(De)}const V=[];for(let t=0;t<256;++t)V.push((t+256).toString(16).slice(1));function Xe(t,e=0){return V[t[e+0]]+V[t[e+1]]+V[t[e+2]]+V[t[e+3]]+"-"+V[t[e+4]]+V[t[e+5]]+"-"+V[t[e+6]]+V[t[e+7]]+"-"+V[t[e+8]]+V[t[e+9]]+"-"+V[t[e+10]]+V[t[e+11]]+V[t[e+12]]+V[t[e+13]]+V[t[e+14]]+V[t[e+15]]}const Ye=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Qt={randomUUID:Ye};function He(t,e,n){if(Qt.randomUUID&&!e&&!t)return Qt.randomUUID();t=t||{};const o=t.random||(t.rng||ke)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Xe(o)}const $e=(t,e,n,o)=>({id:He(),annotation:t.id,created:n||new Date,creator:o,...e}),Pe=(t,e)=>{const n=new Set(t.bodies.map(o=>o.id));return e.bodies.filter(o=>!n.has(o.id))},Fe=(t,e)=>{const n=new Set(e.bodies.map(o=>o.id));return t.bodies.filter(o=>!n.has(o.id))},ze=(t,e)=>e.bodies.map(n=>{const o=t.bodies.find(i=>i.id===n.id);return{newBody:n,oldBody:o&&!z(o,n)?o:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:o})=>({oldBody:n,newBody:o})),We=(t,e)=>!z(t.target,e.target),Jt=(t,e)=>{const n=Pe(t,e),o=Fe(t,e),i=ze(t,e);return{oldValue:t,newValue:e,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:o.length>0?o:void 0,bodiesUpdated:i.length>0?i:void 0,targetUpdated:We(t,e)?{oldTarget:t.target,newTarget:e.target}:void 0}};var O=(t=>(t.LOCAL="LOCAL",t.REMOTE="REMOTE",t))(O||{});const je=(t,e)=>{var n,o;const{changes:i,origin:r}=e;if(!(!t.options.origin||t.options.origin===r))return!1;if(t.options.ignore){const{ignore:a}=t.options,s=u=>u&&u.length>0;if(!(s(i.created)||s(i.deleted))){const u=(n=i.updated)==null?void 0:n.some(m=>s(m.bodiesCreated)||s(m.bodiesDeleted)||s(m.bodiesUpdated)),f=(o=i.updated)==null?void 0:o.some(m=>m.targetUpdated);if(a==="BODY_ONLY"&&u&&!f||a==="TARGET_ONLY"&&f&&!u)return!1}}if(t.options.annotations){const a=new Set([...(i.created||[]).map(s=>s.id),...(i.deleted||[]).map(s=>s.id),...(i.updated||[]).map(({oldValue:s})=>s.id)]);return!!(Array.isArray(t.options.annotations)?t.options.annotations:[t.options.annotations]).find(s=>a.has(s))}else return!0},qe=(t,e)=>{const n=new Set((t.created||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({newValue:c})=>c.id)),i=new Set((e.created||[]).map(c=>c.id)),r=new Set((e.deleted||[]).map(c=>c.id)),a=new Set((e.updated||[]).map(({oldValue:c})=>c.id)),s=new Set((e.updated||[]).filter(({oldValue:c})=>n.has(c.id)||o.has(c.id)).map(({oldValue:c})=>c.id)),u=[...(t.created||[]).filter(c=>!r.has(c.id)).map(c=>a.has(c.id)?e.updated.find(({oldValue:p})=>p.id===c.id).newValue:c),...e.created||[]],f=[...(t.deleted||[]).filter(c=>!i.has(c.id)),...(e.deleted||[]).filter(c=>!n.has(c.id))],m=[...(t.updated||[]).filter(({newValue:c})=>!r.has(c.id)).map(c=>{const{oldValue:p,newValue:g}=c;if(a.has(g.id)){const A=e.updated.find(v=>v.oldValue.id===g.id).newValue;return Jt(p,A)}else return c}),...(e.updated||[]).filter(({oldValue:c})=>!s.has(c.id))];return{created:u,deleted:f,updated:m}},Ge=t=>t.id!==void 0,Qe=()=>{const t=new Map,e=new Map,n=[],o=(b,w={})=>n.push({onChange:b,options:w}),i=b=>{const w=n.findIndex(E=>E.onChange==b);w>-1&&n.splice(w,1)},r=(b,w)=>{const E={origin:b,changes:{created:w.created||[],updated:w.updated||[],deleted:w.deleted||[]},state:[...t.values()]};n.forEach(S=>{je(S,E)&&S.onChange(E)})},a=(b,w=O.LOCAL)=>{if(t.get(b.id))throw Error(`Cannot add annotation ${b.id} - exists already`);t.set(b.id,b),b.bodies.forEach(E=>e.set(E.id,b.id)),r(w,{created:[b]})},s=(b,w)=>{const E=typeof b=="string"?w:b,S=typeof b=="string"?b:b.id,B=t.get(S);if(B){const M=Jt(B,E);return S===E.id?t.set(S,E):(t.delete(S),t.set(E.id,E)),B.bodies.forEach(F=>e.delete(F.id)),E.bodies.forEach(F=>e.set(F.id,E.id)),M}else console.warn(`Cannot update annotation ${S} - does not exist`)},u=(b,w=O.LOCAL,E=O.LOCAL)=>{const S=Ge(w)?E:w,B=s(b,w);B&&r(S,{updated:[B]})},f=(b,w=O.LOCAL)=>{const E=b.reduce((S,B)=>{const M=s(B);return M?[...S,M]:S},[]);E.length>0&&r(w,{updated:E})},m=(b,w=O.LOCAL)=>{const E=t.get(b.annotation);if(E){const S={...E,bodies:[...E.bodies,b]};t.set(E.id,S),e.set(b.id,S.id),r(w,{updated:[{oldValue:E,newValue:S,bodiesCreated:[b]}]})}else console.warn(`Attempt to add body to missing annotation: ${b.annotation}`)},c=()=>[...t.values()],p=(b=O.LOCAL)=>{const w=[...t.values()];t.clear(),e.clear(),r(b,{deleted:w})},g=(b,w=!0,E=O.LOCAL)=>{if(w){const S=[...t.values()];t.clear(),e.clear(),b.forEach(B=>{t.set(B.id,B),B.bodies.forEach(M=>e.set(M.id,B.id))}),r(E,{created:b,deleted:S})}else{const S=b.reduce((B,M)=>{const F=t.get(M.id);return F?[...B,F]:B},[]);if(S.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${S.map(B=>B.id).join(", ")}`);b.forEach(B=>{t.set(B.id,B),B.bodies.forEach(M=>e.set(M.id,B.id))}),r(E,{created:b})}},A=b=>{const w=typeof b=="string"?b:b.id,E=t.get(w);if(E)return t.delete(w),E.bodies.forEach(S=>e.delete(S.id)),E;console.warn(`Attempt to delete missing annotation: ${w}`)},v=(b,w=O.LOCAL)=>{const E=A(b);E&&r(w,{deleted:[E]})},h=(b,w=O.LOCAL)=>{const E=b.reduce((S,B)=>{const M=A(B);return M?[...S,M]:S},[]);E.length>0&&r(w,{deleted:E})},d=b=>{const w=t.get(b.annotation);if(w){const E=w.bodies.find(S=>S.id===b.id);if(E){e.delete(E.id);const S={...w,bodies:w.bodies.filter(B=>B.id!==b.id)};return t.set(w.id,S),{oldValue:w,newValue:S,bodiesDeleted:[E]}}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}`)},l=(b,w=O.LOCAL)=>{const E=d(b);E&&r(w,{updated:[E]})},y=(b,w=O.LOCAL)=>{const E=b.map(S=>d(S)).filter(Boolean);E.length>0&&r(w,{updated:E})},C=b=>{const w=t.get(b);return w?{...w}:void 0},T=b=>{const w=e.get(b);if(w){const E=C(w).bodies.find(S=>S.id===b);if(E)return E;console.error(`Store integrity error: body ${b} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${b}`)},x=(b,w)=>{if(b.annotation!==w.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=t.get(b.annotation);if(E){const S=E.bodies.find(M=>M.id===b.id),B={...E,bodies:E.bodies.map(M=>M.id===S.id?w:M)};return t.set(E.id,B),S.id!==w.id&&(e.delete(S.id),e.set(w.id,B.id)),{oldValue:E,newValue:B,bodiesUpdated:[{oldBody:S,newBody:w}]}}else console.warn(`Attempt to add body to missing annotation ${b.annotation}`)},R=(b,w,E=O.LOCAL)=>{const S=x(b,w);S&&r(E,{updated:[S]})},N=(b,w=O.LOCAL)=>{const E=b.map(S=>x({id:S.id,annotation:S.annotation},S)).filter(Boolean);r(w,{updated:E})},I=b=>{const w=t.get(b.annotation);if(w){const E={...w,target:{...w.target,...b}};return t.set(w.id,E),{oldValue:w,newValue:E,targetUpdated:{oldTarget:w.target,newTarget:b}}}else console.warn(`Attempt to update target on missing annotation: ${b.annotation}`)};return{addAnnotation:a,addBody:m,all:c,bulkAddAnnotation:g,bulkDeleteAnnotation:h,bulkDeleteBodies:y,bulkUpdateAnnotation:f,bulkUpdateBodies:N,bulkUpdateTargets:(b,w=O.LOCAL)=>{const E=b.map(S=>I(S)).filter(Boolean);E.length>0&&r(w,{updated:E})},clear:p,deleteAnnotation:v,deleteBody:l,getAnnotation:C,getBody:T,observe:o,unobserve:i,updateAnnotation:u,updateBody:R,updateTarget:(b,w=O.LOCAL)=>{const E=I(b);E&&r(w,{updated:[E]})}}};let Je=()=>({emit(t,...e){for(let n=0,o=this.events[t]||[],i=o.length;n<i;n++)o[n](...e)},events:{},on(t,e){var n;return((n=this.events)[t]||(n[t]=[])).push(e),()=>{var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>e!==i)}}});const Ke=250,Ze=t=>{const e=Je(),n=[];let o=-1,i=!1,r=0;const a=g=>{if(!i){const{changes:A}=g,v=performance.now();if(v-r>Ke)n.splice(o+1),n.push(A),o=n.length-1;else{const h=n.length-1;n[h]=qe(n[h],A)}r=v}i=!1};t.observe(a,{origin:O.LOCAL});const s=g=>g&&g.length>0&&t.bulkDeleteAnnotation(g),u=g=>g&&g.length>0&&t.bulkAddAnnotation(g,!1),f=g=>g&&g.length>0&&t.bulkUpdateAnnotation(g.map(({oldValue:A})=>A)),m=g=>g&&g.length>0&&t.bulkUpdateAnnotation(g.map(({newValue:A})=>A)),c=g=>g&&g.length>0&&t.bulkAddAnnotation(g,!1),p=g=>g&&g.length>0&&t.bulkDeleteAnnotation(g);return{canRedo:()=>n.length-1>o,canUndo:()=>o>-1,destroy:()=>t.unobserve(a),on:(g,A)=>e.on(g,A),redo:()=>{if(n.length-1>o){i=!0;const{created:g,updated:A,deleted:v}=n[o+1];u(g),m(A),p(v),e.emit("redo",n[o+1]),o+=1}},undo:()=>{if(o>-1){i=!0;const{created:g,updated:A,deleted:v}=n[o];s(g),f(A),c(v),e.emit("undo",n[o]),o-=1}}}},tn=()=>{const{subscribe:t,set:e}=bt([]);return{subscribe:t,set:e}},en=(t,e,n,o)=>{const{store:i,selection:r,hover:a,viewport:s}=t,u=new Map;let f=[],m;const c=(v,h)=>{u.has(v)?u.get(v).push(h):u.set(v,[h])},p=(v,h)=>{const d=u.get(v);d&&d.indexOf(h)>0&&d.splice(d.indexOf(h),1)},g=(v,h,d)=>{u.has(v)&&setTimeout(()=>{u.get(v).forEach(l=>{if(n){const y=Array.isArray(h)?h.map(T=>n.serialize(T)):n.serialize(h),C=d?d instanceof PointerEvent?d:n.serialize(d):void 0;l(y,C)}else l(h,d)})},1)};r.subscribe(({selected:v})=>{if(!(f.length===0&&v.length===0)){if(f.length===0&&v.length>0)f=v.map(({id:h})=>i.getAnnotation(h));else if(f.length>0&&v.length===0)f.forEach(h=>{const d=i.getAnnotation(h.id);d&&!z(d,h)&&g("updateAnnotation",d,h)}),f=[];else{const h=new Set(f.map(l=>l.id)),d=new Set(v.map(({id:l})=>l));f.filter(l=>!d.has(l.id)).forEach(l=>{const y=i.getAnnotation(l.id);y&&!z(y,l)&&g("updateAnnotation",y,l)}),f=[...f.filter(l=>d.has(l.id)),...v.filter(({id:l})=>!h.has(l)).map(({id:l})=>i.getAnnotation(l))]}g("selectionChanged",f)}}),a.subscribe(v=>{!m&&v?g("mouseEnterAnnotation",i.getAnnotation(v)):m&&!v?g("mouseLeaveAnnotation",i.getAnnotation(m)):m&&v&&(g("mouseLeaveAnnotation",i.getAnnotation(m)),g("mouseEnterAnnotation",i.getAnnotation(v))),m=v}),s==null||s.subscribe(v=>g("viewportIntersect",v.map(h=>i.getAnnotation(h)))),i.observe(v=>{const{created:h,deleted:d}=v.changes;(h||[]).forEach(l=>g("createAnnotation",l)),(d||[]).forEach(l=>g("deleteAnnotation",l)),(v.changes.updated||[]).filter(l=>[...l.bodiesCreated||[],...l.bodiesDeleted||[],...l.bodiesUpdated||[]].length>0).forEach(({oldValue:l,newValue:y})=>{const C=f.find(T=>T.id===l.id)||l;f=f.map(T=>T.id===l.id?y:T),g("updateAnnotation",y,C)})},{origin:O.LOCAL}),i.observe(v=>{if(f){const h=new Set(f.map(l=>l.id)),d=(v.changes.updated||[]).filter(({newValue:l})=>h.has(l.id)).map(({newValue:l})=>l);d.length>0&&(f=f.map(l=>d.find(C=>C.id===l.id)||l))}},{origin:O.REMOTE});const A=v=>h=>{const{updated:d}=h;v?(d||[]).forEach(l=>g("updateAnnotation",l.oldValue,l.newValue)):(d||[]).forEach(l=>g("updateAnnotation",l.newValue,l.oldValue))};return e.on("undo",A(!0)),e.on("redo",A(!1)),{on:c,off:p,emit:g}},nn=t=>e=>e.reduce((n,o)=>{const{parsed:i,error:r}=t.parse(o);return r?{parsed:n.parsed,failed:[...n.failed,o]}:i?{parsed:[...n.parsed,i],failed:n.failed}:{...n}},{parsed:[],failed:[]}),on=(t,e,n)=>{const{store:o,selection:i}=t,r=h=>{if(n){const{parsed:d,error:l}=n.parse(h);d?o.addAnnotation(d,O.REMOTE):console.error(l)}else o.addAnnotation(h,O.REMOTE)},a=()=>i.clear(),s=()=>o.clear(),u=h=>{const d=o.getAnnotation(h);return n&&d?n.serialize(d):d},f=()=>n?o.all().map(n.serialize):o.all(),m=()=>{var h;const d=(((h=i.selected)==null?void 0:h.map(l=>l.id))||[]).map(l=>o.getAnnotation(l)).filter(Boolean);return n?d.map(n.serialize):d},c=(h,d=!0)=>fetch(h).then(l=>l.json()).then(l=>(g(l,d),l)),p=h=>{if(typeof h=="string"){const d=o.getAnnotation(h);if(o.deleteAnnotation(h),d)return n?n.serialize(d):d}else{const d=n?n.parse(h).parsed:h;if(d)return o.deleteAnnotation(d),h}},g=(h,d=!0)=>{if(n){const{parsed:l,failed:y}=nn(n)(h);y.length>0&&console.warn(`Discarded ${y.length} invalid annotations`,y),o.bulkAddAnnotation(l,d,O.REMOTE)}else o.bulkAddAnnotation(h,d,O.REMOTE)},A=h=>{h?i.setSelected(h):i.clear()},v=h=>{if(n){const d=n.parse(h).parsed,l=n.serialize(o.getAnnotation(d.id));return o.updateAnnotation(d),l}else{const d=o.getAnnotation(h.id);return o.updateAnnotation(h),d}};return{addAnnotation:r,cancelSelected:a,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:s,getAnnotationById:u,getAnnotations:f,getSelected:m,loadAnnotations:c,redo:e.redo,removeAnnotation:p,setAnnotations:g,setSelected:A,undo:e.undo,updateAnnotation:v}},rn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let sn=t=>crypto.getRandomValues(new Uint8Array(t)),an=(t,e,n)=>{let o=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*o*e/t.length);return(r=e)=>{let a="";for(;;){let s=n(i),u=i;for(;u--;)if(a+=t[s[u]&o]||"",a.length===r)return a}}},cn=(t,e=21)=>an(t,e,sn),ln=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=rn[n[t]&63];return e};const dn=()=>({isGuest:!0,id:cn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),un=t=>{const e=JSON.stringify(t);let n=0;for(let o=0,i=e.length;o<i;o++){let r=e.charCodeAt(o);n=(n<<5)-n+r,n|=0}return`${n}`},Kt=t=>t?typeof t=="object"?{...t}:t:void 0,hn=(t,e)=>(Array.isArray(t)?t:[t]).map(n=>{const{id:o,type:i,purpose:r,value:a,created:s,modified:u,creator:f,...m}=n;return{id:o||`temp-${un(n)}`,annotation:e,type:i,purpose:r,value:a,creator:Kt(f),created:s?new Date(s):void 0,updated:u?new Date(u):void 0,...m}}),fn=t=>t.map(e=>{var n;const{annotation:o,created:i,updated:r,...a}=e,s={...a,created:i==null?void 0:i.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=s.id)!=null&&n.startsWith("temp-")&&delete s.id,s});ln();const gn=(t,e)=>({parse:n=>Zt(n),serialize:n=>te(n,t,e)}),pn=t=>t.quote!==void 0&&t.start!==void 0&&t.end!==void 0,mn=t=>{const{id:e,creator:n,created:o,modified:i,target:r}=t,a=Array.isArray(r)?r:[r],s={creator:Kt(n),created:o?new Date(o):void 0,updated:i?new Date(i):void 0,annotation:e,selector:[]};for(const u of a){const m=(Array.isArray(u.selector)?u.selector:[u.selector]).reduce((c,p)=>{switch(p.type){case"TextQuoteSelector":c.quote=p.exact;break;case"TextPositionSelector":c.start=p.start,c.end=p.end;break}return c},{});if(pn(m))s.selector.push({id:u.id,...m});else{const c=[m.start?void 0:"TextPositionSelector",m.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${c.join(" and ")} for annotation: ${t.id}`)}}}return{parsed:s}},Zt=t=>{const e=t.id||jt(),{creator:n,created:o,modified:i,body:r,...a}=t,s=hn(r,e),u=mn(t);return"error"in u?{error:u.error}:{parsed:{...a,id:e,bodies:s,target:u.parsed}}},te=(t,e,n)=>{const{bodies:o,target:i,...r}=t,{selector:a,creator:s,created:u,updated:f,...m}=i,c=a.map(p=>{const{quote:g,start:A,end:v,range:h}=p,{prefix:d,suffix:l}=Ct(h,n),y=[{type:"TextQuoteSelector",exact:g,prefix:d,suffix:l},{type:"TextPositionSelector",start:A,end:v}];return{...m,id:p.id,source:e,selector:y}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:t.id,type:"Annotation",body:fn(t.bodies),creator:s,created:u==null?void 0:u.toISOString(),modified:f==null?void 0:f.toISOString(),target:c}};function bn(t,e,n,o,i){ee(t,e,n||0,o||t.length-1,i||vn)}function ee(t,e,n,o,i){for(;o>n;){if(o-n>600){var r=o-n+1,a=e-n+1,s=Math.log(r),u=.5*Math.exp(2*s/3),f=.5*Math.sqrt(s*u*(r-u)/r)*(a-r/2<0?-1:1),m=Math.max(n,Math.floor(e-a*u/r+f)),c=Math.min(o,Math.floor(e+(r-a)*u/r+f));ee(t,e,m,c,i)}var p=t[e],g=n,A=o;for(K(t,n,e),i(t[o],p)>0&&K(t,n,o);g<A;){for(K(t,g,A),g++,A--;i(t[g],p)<0;)g++;for(;i(t[A],p)>0;)A--}i(t[n],p)===0?K(t,n,A):(A++,K(t,A,o)),A<=e&&(n=A+1),e<=A&&(o=A-1)}}function K(t,e,n){var o=t[e];t[e]=t[n],t[n]=o}function vn(t,e){return t<e?-1:t>e?1:0}class yn{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let n=this.data;const o=[];if(!ct(e,n))return o;const i=this.toBBox,r=[];for(;n;){for(let a=0;a<n.children.length;a++){const s=n.children[a],u=n.leaf?i(s):s;ct(e,u)&&(n.leaf?o.push(s):wt(e,u)?this._all(s,o):r.push(s))}n=r.pop()}return o}collides(e){let n=this.data;if(!ct(e,n))return!1;const o=[];for(;n;){for(let i=0;i<n.children.length;i++){const r=n.children[i],a=n.leaf?this.toBBox(r):r;if(ct(e,a)){if(n.leaf||wt(e,a))return!0;o.push(r)}}n=o.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let o=0;o<e.length;o++)this.insert(e[o]);return this}let n=this._build(e.slice(),0,e.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(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=q([]),this}remove(e,n){if(!e)return this;let o=this.data;const i=this.toBBox(e),r=[],a=[];let s,u,f;for(;o||r.length;){if(o||(o=r.pop(),u=r[r.length-1],s=a.pop(),f=!0),o.leaf){const m=wn(e,o.children,n);if(m!==-1)return o.children.splice(m,1),r.push(o),this._condense(r),this}!f&&!o.leaf&&wt(o,i)?(r.push(o),a.push(s),s=0,u=o,o=o.children[0]):u?(s++,o=u.children[s],f=!1):o=null}return this}toBBox(e){return e}compareMinX(e,n){return e.minX-n.minX}compareMinY(e,n){return e.minY-n.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,n){const o=[];for(;e;)e.leaf?n.push(...e.children):o.push(...e.children),e=o.pop();return n}_build(e,n,o,i){const r=o-n+1;let a=this._maxEntries,s;if(r<=a)return s=q(e.slice(n,o+1)),j(s,this.toBBox),s;i||(i=Math.ceil(Math.log(r)/Math.log(a)),a=Math.ceil(r/Math.pow(a,i-1))),s=q([]),s.leaf=!1,s.height=i;const u=Math.ceil(r/a),f=u*Math.ceil(Math.sqrt(a));ne(e,n,o,f,this.compareMinX);for(let m=n;m<=o;m+=f){const c=Math.min(m+f-1,o);ne(e,m,c,u,this.compareMinY);for(let p=m;p<=c;p+=u){const g=Math.min(p+u-1,c);s.children.push(this._build(e,p,g,i-1))}}return j(s,this.toBBox),s}_chooseSubtree(e,n,o,i){for(;i.push(n),!(n.leaf||i.length-1===o);){let r=1/0,a=1/0,s;for(let u=0;u<n.children.length;u++){const f=n.children[u],m=yt(f),c=xn(e,f)-m;c<a?(a=c,r=m<r?m:r,s=f):c===a&&m<r&&(r=m,s=f)}n=s||n.children[0]}return n}_insert(e,n,o){const i=o?e:this.toBBox(e),r=[],a=this._chooseSubtree(i,this.data,n,r);for(a.children.push(e),tt(a,i);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(i,r,n)}_split(e,n){const o=e[n],i=o.children.length,r=this._minEntries;this._chooseSplitAxis(o,r,i);const a=this._chooseSplitIndex(o,r,i),s=q(o.children.splice(a,o.children.length-a));s.height=o.height,s.leaf=o.leaf,j(o,this.toBBox),j(s,this.toBBox),n?e[n-1].children.push(s):this._splitRoot(o,s)}_splitRoot(e,n){this.data=q([e,n]),this.data.height=e.height+1,this.data.leaf=!1,j(this.data,this.toBBox)}_chooseSplitIndex(e,n,o){let i,r=1/0,a=1/0;for(let s=n;s<=o-n;s++){const u=Z(e,0,s,this.toBBox),f=Z(e,s,o,this.toBBox),m=Sn(u,f),c=yt(u)+yt(f);m<r?(r=m,i=s,a=c<a?c:a):m===r&&c<a&&(a=c,i=s)}return i||o-n}_chooseSplitAxis(e,n,o){const i=e.leaf?this.compareMinX:An,r=e.leaf?this.compareMinY:En,a=this._allDistMargin(e,n,o,i),s=this._allDistMargin(e,n,o,r);a<s&&e.children.sort(i)}_allDistMargin(e,n,o,i){e.children.sort(i);const r=this.toBBox,a=Z(e,0,n,r),s=Z(e,o-n,o,r);let u=at(a)+at(s);for(let f=n;f<o-n;f++){const m=e.children[f];tt(a,e.leaf?r(m):m),u+=at(a)}for(let f=o-n-1;f>=n;f--){const m=e.children[f];tt(s,e.leaf?r(m):m),u+=at(s)}return u}_adjustParentBBoxes(e,n,o){for(let i=o;i>=0;i--)tt(n[i],e)}_condense(e){for(let n=e.length-1,o;n>=0;n--)e[n].children.length===0?n>0?(o=e[n-1].children,o.splice(o.indexOf(e[n]),1)):this.clear():j(e[n],this.toBBox)}}function wn(t,e,n){if(!n)return e.indexOf(t);for(let o=0;o<e.length;o++)if(n(t,e[o]))return o;return-1}function j(t,e){Z(t,0,t.children.length,e,t)}function Z(t,e,n,o,i){i||(i=q(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=e;r<n;r++){const a=t.children[r];tt(i,t.leaf?o(a):a)}return i}function tt(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function An(t,e){return t.minX-e.minX}function En(t,e){return t.minY-e.minY}function yt(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function at(t){return t.maxX-t.minX+(t.maxY-t.minY)}function xn(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Sn(t,e){const n=Math.max(t.minX,e.minX),o=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),r=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,r-o)}function wt(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function ct(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function q(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function ne(t,e,n,o,i){const r=[e,n];for(;r.length;){if(n=r.pop(),e=r.pop(),n-e<=o)continue;const a=e+Math.ceil((n-e)/o/2)*o;bn(t,a,e,n,i),r.push(e,a,a,n)}}const Tn=(t,e)=>{const n=new yn,o=new Map,i=(d,l)=>{const y=d.selector.flatMap(T=>{const R=T.range instanceof Range&&!T.range.collapsed&&T.range.startContainer.nodeType===Node.TEXT_NODE&&T.range.endContainer.nodeType===Node.TEXT_NODE?T.range:dt(T,e).range;return Array.from(R.getClientRects())}),C=Rt(y).map(({left:T,top:x,right:R,bottom:N})=>new DOMRect(T-l.left,x-l.top,R-T,N-x));return C.map(T=>{const{x,y:R,width:N,height:I}=T;return{minX:x,minY:R,maxX:x+N,maxY:R+I,annotation:{id:d.annotation,rects:C}}})},r=()=>[...o.values()],a=()=>{n.clear(),o.clear()},s=d=>{const l=i(d,e.getBoundingClientRect());l.forEach(y=>n.insert(y)),o.set(d.annotation,l)},u=d=>{const l=o.get(d.annotation);l&&(l.forEach(y=>n.remove(y)),o.delete(d.annotation))},f=d=>{u(d),s(d)},m=(d,l=!0)=>{l&&a();const y=e.getBoundingClientRect(),C=d.map(x=>({target:x,rects:i(x,y)}));C.forEach(({target:x,rects:R})=>o.set(x.annotation,R));const T=C.reduce((x,{rects:R})=>[...x,...R],[]);n.load(T)},c=(d,l)=>{const y=n.search({minX:d,minY:l,maxX:d,maxY:l}),C=T=>T.annotation.rects.reduce((x,R)=>x+R.width*R.height,0);if(y.length>0)return y.sort((T,x)=>C(T)-C(x)),y[0].annotation.id},p=d=>{const l=g(d);if(l.length===0)return;let y=l[0].left,C=l[0].top,T=l[0].right,x=l[0].bottom;for(let R=1;R<l.length;R++){const N=l[R];y=Math.min(y,N.left),C=Math.min(C,N.top),T=Math.max(T,N.right),x=Math.max(x,N.bottom)}return new DOMRect(y,C,T-y,x-C)},g=d=>{const l=o.get(d);return l?l[0].annotation.rects:[]};return{all:r,clear:a,getAt:c,getAnnotationBounds:p,getAnnotationRects:g,getIntersecting:(d,l,y,C)=>{const T=n.search({minX:d,minY:l,maxX:y,maxY:C}),x=new Set(T.reduce((R,N)=>[...R,N.annotation.id],[]));return Array.from(x).map(R=>({annotation:t.getAnnotation(R),rects:g(R)})).filter(R=>!!R.annotation)},insert:s,recalculate:()=>m(t.all().map(d=>d.target),!0),remove:u,set:m,size:()=>n.all().length,update:f}},oe=(t,e)=>{const n=Qe(),o=Tn(n,t),i=Ue(n,e),r=_e(n),a=tn(),s=(v,h=O.LOCAL)=>{const d=ot(v,t),l=H(d.target.selector);return l&&n.addAnnotation(d,h),l},u=(v,h=!0,d=O.LOCAL)=>{const l=v.map(C=>ot(C,t)),y=l.filter(C=>!H(C.target.selector));return y.length>0?(console.warn("Could not revive all targets for these annotations:",y),n.bulkAddAnnotation(l,h,d),y):(n.bulkAddAnnotation(l,h,d),[])},f=(v,h=O.LOCAL)=>{const d=v.map(y=>ot(y,t)),l=d.filter(y=>!H(y.target.selector));return l.length>0&&console.warn("Could not revive all targets for these annotations:",l),d.forEach(y=>{n.getAnnotation(y.id)?n.updateAnnotation(y,h):n.addAnnotation(y,h)}),l},m=(v,h=O.LOCAL)=>{const d=Q(v,t);n.updateTarget(d,h)},c=(v,h=O.LOCAL)=>{const d=v.map(l=>Q(l,t));n.bulkUpdateTargets(d,h)},p=(v,h)=>{const d=o.getAt(v,h);return d?n.getAnnotation(d):void 0},g=(v,h,d,l=5)=>{const y=o.getAnnotationRects(v);if(y.length!==0){if(h&&d){const C=y.find(({top:T,right:x,bottom:R,left:N})=>h>=N-l&&h<=x+l&&d>=T-l&&d<=R+l);if(C)return C}return o.getAnnotationBounds(v)}},A=()=>o.recalculate();return n.observe(({changes:v})=>{const h=(v.created||[]).filter(y=>H(y.target.selector)),d=(v.deleted||[]).filter(y=>H(y.target.selector)),l=(v.updated||[]).filter(y=>H(y.newValue.target.selector));h.length>0&&o.set(h.map(y=>y.target),!1),(d==null?void 0:d.length)>0&&d.forEach(y=>o.remove(y.target)),(l==null?void 0:l.length)>0&&l.forEach(({newValue:y})=>o.update(y.target))}),{store:{...n,addAnnotation:s,bulkAddAnnotation:u,bulkUpdateTargets:c,bulkUpsertAnnotations:f,getAnnotationBounds:g,getAt:p,getIntersecting:o.getIntersecting,recalculatePositions:A,updateTarget:m},selection:i,hover:r,viewport:a}},Cn=()=>{const t=document.createElement("canvas");t.width=2*window.innerWidth,t.height=2*window.innerHeight,t.className="r6o-highlight-layer presence";const e=t.getContext("2d");return e.scale(2,2),e.translate(.5,.5),t},Rn=(t,e,n={})=>{const o=Cn(),i=o.getContext("2d");t.appendChild(o);const r=new Map,a=c=>Array.from(r.entries()).filter(([p,g])=>g.presenceKey===c.presenceKey).map(([p,g])=>p);return e.on("selectionChange",(c,p)=>{a(c).forEach(A=>r.delete(A)),p&&p.forEach(A=>r.set(A,c))}),{clear:()=>{const{width:c,height:p}=o;i.clearRect(-.5,-.5,c+1,p+1)},destroy:()=>{o.remove()},paint:(c,p,g)=>{n.font&&(i.font=n.font);const A=r.get(c.annotation.id);if(A){const{height:v}=c.rects[0],h=c.rects[0].x+p.left,d=c.rects[0].y+p.top;i.fillStyle=A.appearance.color,i.fillRect(h-2,d-2.5,2,v+5);const l=i.measureText(A.appearance.label),y=l.width+6,C=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent+8,T=l.fontBoundingBoxAscent?8:6.5;return i.fillRect(h-2,d-2.5-C,y,C),i.fillStyle="#fff",i.fillText(A.appearance.label,h+1,d-T),{fill:A.appearance.color,fillOpacity:g?.45:.18}}},reset:()=>{o.width=2*window.innerWidth,o.height=2*window.innerHeight;const c=o.getContext("2d");c.scale(2,2),c.translate(.5,.5)}}},ie=t=>{if(t===null)return document.scrollingElement;const{overflowY:e}=window.getComputedStyle(t);return e!=="visible"&&e!=="hidden"&&t.scrollHeight>t.clientHeight?t:ie(t.parentElement)},Nn=(t,e)=>n=>{const o=r=>{const a=i.getBoundingClientRect(),s=i.clientHeight,u=i.clientWidth,f=r.selector[0].range.getBoundingClientRect(),{width:m,height:c}=e.getAnnotationBounds(n.id),p=f.top-a.top,g=f.left-a.left,A=i.parentElement?i.scrollTop:0,v=i.parentElement?i.scrollLeft:0,h=p+A-(s-c)/2,d=g+v-(u-m)/2;i.scroll({top:h,left:d,behavior:"smooth"})},i=ie(t);if(i){const r=e.getAnnotation(n.id),{range:a}=r.target.selector[0];if(a&&!a.collapsed)return o(r.target),!0;{const s=Q(r.target,t),{range:u}=s.selector[0];if(u&&!u.collapsed)return o(s),!0}}return!1},re=(t,e)=>({...t,annotationEnabled:t.annotationEnabled===void 0?e.annotationEnabled:t.annotationEnabled}),Ln=(t,e,n,o)=>{const{store:i,selection:r}=e;let a,s;const u=h=>a=h;let f=!1,m;const c=h=>{var l;if(!f)return;!((l=h.target.parentElement)!=null&&l.closest(X))?s={annotation:jt(),selector:[],creator:a,created:new Date}:s=void 0};n&&t.addEventListener("selectstart",c);const p=nt(h=>{var R,N;const d=document.getSelection();if(!!((N=(R=d.anchorNode)==null?void 0:R.parentElement)!=null&&N.closest(X))){s=void 0;return}if(h.timeStamp-((m==null?void 0:m.timeStamp)||h.timeStamp)<1e3&&!s&&c(m),d.isCollapsed||!f||!s)return;const y=d.getRangeAt(0),C=Lt(y.cloneRange()),T=Et(C);(T.length!==s.selector.length||T.some((I,b)=>{var w;return I.toString()!==((w=s.selector[b])==null?void 0:w.quote)}))&&(s={...s,selector:T.map(I=>Nt(I,t,o))},i.getAnnotation(s.annotation)?i.updateTarget(s,O.LOCAL):(i.addAnnotation({id:s.annotation,bodies:[],target:s}),r.clickSelect(s.annotation,m)))});n&&document.addEventListener("selectionchange",p);const g=h=>{const{target:d,timeStamp:l,offsetX:y,offsetY:C,type:T}=h;m={...h,target:d,timeStamp:l,offsetX:y,offsetY:C,type:T},f=h.button===0};t.addEventListener("pointerdown",g);const A=h=>{var C;if(!!((C=h.target.parentElement)!=null&&C.closest(X))||!f)return;const l=()=>{const{x:T,y:x}=t.getBoundingClientRect(),R=i.getAt(h.clientX-T,h.clientY-x);if(R){const{selected:N}=r;(N.length!==1||N[0].id!==R.id)&&r.clickSelect(R.id,h)}else r.isEmpty()||r.clear()},y=h.timeStamp-m.timeStamp;document.getSelection().isCollapsed&&y<300?(s=void 0,l()):s&&r.clickSelect(s.annotation,h)};return document.addEventListener("pointerup",A),{destroy:()=>{t.removeEventListener("selectstart",c),document.removeEventListener("selectionchange",p),t.removeEventListener("pointerdown",g),document.removeEventListener("pointerup",A)},setUser:u}},se="SPANS",Bn=(t,e={})=>{xt(t);const n=re(e,{annotationEnabled:!0}),o=oe(t,n.pointerAction),{selection:i,viewport:r}=o,a=o.store,s=Ze(a),u=en(o,s,n.adapter);let f=dn();const m=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":se:n.renderer||se,c=m==="SPANS"?zt(t,o,r):m==="CSS_HIGHLIGHTS"?Pt(t,o,r):m==="CANVAS"?Bt(t,o,r):void 0;if(!c)throw`Unknown renderer implementation: ${m}`;console.debug(`Using ${m} renderer`),n.style&&c.setStyle(n.style);const p=Ln(t,o,n.annotationEnabled,n.offsetReferenceSelector);return p.setUser(f),{...on(o,s,n.adapter),destroy:()=>{c.destroy(),p.destroy(),s.destroy()},element:t,getUser:()=>f,setFilter:x=>c.setFilter(x),setStyle:x=>c.setStyle(x),setUser:x=>{f=x,p.setUser(x)},setSelected:x=>{x?i.setSelected(x):i.clear()},setPresenceProvider:x=>{x&&(c.setPainter(Rn(t,x,n.presence)),x.on("selectionChange",()=>c.redraw()))},setVisible:x=>c.setVisible(x),on:u.on,off:u.off,scrollIntoView:Nn(t,a),state:o}};L.DEFAULT_SELECTED_STYLE=G,L.DEFAULT_STYLE=D,L.NOT_ANNOTATABLE_CLASS=lt,L.NOT_ANNOTATABLE_SELECTOR=X,L.Origin=O,L.PointerSelectAction=Gt,L.W3CTextFormat=gn,L.cancelSingleClickEvents=xt,L.createBody=$e,L.createCanvasRenderer=Bt,L.createHighlightsRenderer=Pt,L.createRenderer=$t,L.createSpansRenderer=zt,L.createTextAnnotator=Bn,L.createTextAnnotatorState=oe,L.debounce=nt,L.fillDefaults=re,L.getAnnotatableFragment=le,L.getClientRectsPonyfill=he,L.getQuoteContext=Ct,L.getRangeAnnotatableContents=et,L.isRevived=H,L.mergeClientRects=Rt,L.paint=At,L.parseW3CTextAnnotation=Zt,L.rangeToSelector=Nt,L.reviveAnnotation=ot,L.reviveSelector=dt,L.reviveTarget=Q,L.serializeW3CTextAnnotation=te,L.splitAnnotatableRanges=Et,L.trimRange=Lt,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(N,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(N=typeof globalThis<"u"?globalThis:N||self,U(N.RecogitoJS={}))})(this,function(N){"use strict";const U={fill:"rgb(0, 128, 255)",fillOpacity:.18},G={fill:"rgb(0, 128, 255)",fillOpacity:.45},xt=(t,e,n,o,i)=>{var a,s;const r=n?typeof n=="function"?n(t.annotation,t.state,i)||((a=t.state)!=null&&a.selected?G:U):n:(s=t.state)!=null&&s.selected?G:U;return o&&o.paint(t,e)||r},lt="not-annotatable",X=`.${lt}`,de=t=>{var n;const e=t.commonAncestorContainer;return e instanceof HTMLElement?!e.closest(X):!((n=e.parentElement)!=null&&n.closest(X))},ue=function*(t){const e=document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(lt)&&!o.parentElement.closest(X)&&t.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=e.nextNode();)n instanceof HTMLElement&&(yield n)},St=t=>{if(!de(t))return[];const e=[];let n=null;for(const o of ue(t)){let i;n?(i=document.createRange(),i.setStartAfter(n),i.setEndBefore(o)):(i=t.cloneRange(),i.setEndBefore(o)),i.collapsed||e.push(i),n=o}if(n){const o=t.cloneRange();o.setStartAfter(n),o.collapsed||e.push(o)}return e.length>0?e:[t]},et=t=>{const e=t.cloneContents();return e.querySelectorAll(X).forEach(n=>n.remove()),e},Ct=t=>{t.addEventListener("click",e=>{!e.target.closest(X)&&!e.target.closest("a")&&e.preventDefault()})},nt=(t,e=10)=>{let n;return(...o)=>{clearTimeout(n),n=setTimeout(()=>t.apply(void 0,o),e)}},he=t=>{const e=t.cloneContents();return e.querySelectorAll(X).forEach(n=>n.remove()),e},Tt=(t,e)=>{const n=document.createNodeIterator(e);let o=0,i=n.nextNode();for(;i!==null;){if(i===t)return o;o+=1,i=n.nextNode()}},Lt=(t,e)=>{const n=document.createNodeIterator(e);let o=null;for(let i=0;i<t+1;i++)o=n.nextNode();return o},fe=t=>{const{commonAncestorContainer:e,startContainer:n,startOffset:o,endContainer:i,endOffset:r}=t,a=Array.from(e.childNodes).map(l=>{const p=l.cloneNode(!0);return l.nodeName==="CANVAS"?l:p}),s=Tt(n,e),u=Tt(i,e),f=()=>{const l=e;l.replaceChildren(...a);const p=Lt(s,l),g=Lt(u,l);return t.setStart(p,o),t.setEnd(g,r),t},m=l=>{const p=document.createElement("SPAN");return l.surroundContents(p),p};if(n===i)throw"Not implemented";{const l=document.createRange();l.selectNodeContents(n),l.setStart(n,o);const p=m(l),g=document.createRange();g.selectNode(i),g.setEnd(i,r);const A=m(g),h=ge(t).reverse().map(d=>{var y;const c=document.createElement("SPAN");return(y=d.parentNode)==null||y.insertBefore(c,d),c.appendChild(d),c});return{unwrap:f,nodes:[p,...h,A]}}},ge=t=>{const{commonAncestorContainer:e,startContainer:n,endContainer:o}=t,i=document.createNodeIterator(e,NodeFilter.SHOW_TEXT);let r=i.nextNode(),a=!1;const s=[];for(;r!=null;)r===o&&(a=!1),a&&s.push(r),r===n&&(a=!0),r=i.nextNode();return s},pe=t=>{const{startContainer:e,endContainer:n}=t;if(e===n)return Array.from(t.getClientRects());{const{unwrap:o,nodes:i}=fe(t),r=i.reduce((a,s)=>[...a,...s.getClientRects()],[]);return o(),r}},Rt=(t,e,n=10,o)=>{const i=o?t.startContainer.parentElement.closest(o):e,r=document.createRange();r.setStart(i,0),r.setEnd(t.startContainer,t.startOffset);const a=et(r).textContent,s=document.createRange();s.setStart(t.endContainer,t.endOffset),i===document.body?s.setEnd(i,i.childNodes.length):s.setEndAfter(i);const u=et(s).textContent;return{prefix:a.substring(a.length-n),suffix:u.substring(0,n)}},H=t=>t.every(e=>e.range instanceof Range&&!e.range.collapsed),me=(t,e)=>{const n=r=>Math.round(r*10)/10,o={top:n(t.top),bottom:n(t.bottom),left:n(t.left),right:n(t.right)},i={top:n(e.top),bottom:n(e.bottom),left:n(e.left),right:n(e.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"},be=(t,e)=>{const n=Math.min(t.left,e.left),o=Math.max(t.right,e.right),i=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom);return new DOMRect(n,i,o-n,r-i)},Nt=t=>t.reduce((e,n)=>{if(n.width===0||n.height===0)return e;let o=[...e],i=!1;for(const r of e){const a=me(n,r);if(a==="inline-adjacent"){o=o.map(s=>s===r?be(n,r):s),i=!0;break}else if(a==="inline-contains"){o=o.map(s=>s===r?n:s),i=!0;break}else if(a==="inline-is-contained"){i=!0;break}else if(a==="block-contains"||a==="block-is-contained"){n.width<r.width&&(o=o.map(s=>s===r?n:s)),i=!0;break}}return i?o:[...o,n]},[]),Bt=(t,e,n)=>{const o=document.createRange(),i=n?t.startContainer.parentElement.closest(n):e;o.setStart(i,0),o.setEnd(t.startContainer,t.startOffset);const r=et(o).textContent,a=t.toString(),s=r.length||0,u=s+a.length;return n?{quote:a,start:s,end:u,range:t,offsetReference:i}:{quote:a,start:s,end:u,range:t}},dt=(t,e)=>{var m,l;const{start:n,end:o}=t,i=t.offsetReference||e,r=document.createNodeIterator(e,NodeFilter.SHOW_TEXT,p=>{var g;return(g=p.parentElement)!=null&&g.closest(X)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let a=0;const s=document.createRange();let u=r.nextNode();u===null&&console.error("Could not revive annotation target. Content missing.");let f=!i;for(;u!==null;){if(f||(f=i==null?void 0:i.contains(u)),f){const p=((m=u.textContent)==null?void 0:m.length)||0;if(a+p>n){s.setStart(u,n-a);break}a+=p}u=r.nextNode()}for(;u!==null;){const p=((l=u.textContent)==null?void 0:l.length)||0;if(a+p>=o){s.setEnd(u,o-a);break}a+=p,u=r.nextNode()}return{...t,range:s}},Q=(t,e)=>H(t.selector)?t:{...t,selector:t.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:dt(n,e))},ot=(t,e)=>H(t.target.selector)?t:{...t,target:Q(t.target,e)},Ot=t=>{var i;const{startContainer:e,endContainer:n}=t;if(e.nodeType===Node.TEXT_NODE&&n.nodeType===Node.TEXT_NODE)return t;if(e.nodeType!==Node.TEXT_NODE){const r=e.nextSibling||e.parentNode,a=(r==null?void 0:r.nodeType)===Node.TEXT_NODE?r:Array.from(r.childNodes).filter(s=>s.nodeType===Node.TEXT_NODE).shift();t.setEnd(a,0)}if(n.nodeType!==Node.TEXT_NODE){const r=n.previousSibling||n.parentNode,a=(r==null?void 0:r.nodeType)===Node.TEXT_NODE?r:Array.from(r.childNodes).filter(s=>s.nodeType===Node.TEXT_NODE).pop();t.setEnd(a,((i=a==null?void 0:a.textContent)==null?void 0:i.length)||0)}return t},ve=t=>{const{top:e,left:n}=t.getBoundingClientRect(),{innerWidth:o,innerHeight:i}=window,r=-n,a=-e,s=o-n,u=i-e;return{top:e,left:n,minX:r,minY:a,maxX:s,maxY:u}},ye=t=>{let e=new Set;return o=>{const i=o.map(r=>r.id);(e.size!==i.length||i.some(r=>!e.has(r)))&&t.set(i),e=new Set(i)}},ut=(t,e,n,o)=>{const{store:i,selection:r,hover:a}=e;let s,u,f;const m=ye(n),l=R=>{const{x:M,y:b}=t.getBoundingClientRect(),w=i.getAt(R.clientX-M,R.clientY-b);w&&(!u||u(w))?a.current!==w.id&&(t.classList.add("hovered"),a.set(w.id)):a.current&&(t.classList.remove("hovered"),a.set(null))};t.addEventListener("pointermove",l);const p=(R=!1)=>{f&&f.clear();const M=ve(t),{minX:b,minY:w,maxX:E,maxY:S}=M,B=u?i.getIntersecting(b,w,E,S).filter(({annotation:P})=>u(P)):i.getIntersecting(b,w,E,S),I=r.selected.map(({id:P})=>P),F=B.map(({annotation:P,rects:_n})=>{const Dn=I.includes(P.id),Vn=P.id===a.current;return{annotation:P,rects:_n,state:{selected:Dn,hover:Vn}}});o.redraw(F,M,s,f,R),setTimeout(()=>m(B.map(({annotation:P})=>P)),1)},g=R=>{f=R,p()},A=R=>{s=R,p()},v=R=>{u=R,p(!1)},h=()=>p();i.observe(h);const d=r.subscribe(()=>p()),c=()=>p(!0);document.addEventListener("scroll",c,{capture:!0,passive:!0});const y=nt(()=>{i.recalculatePositions(),f&&f.reset(),p()});window.addEventListener("resize",y);const T=new ResizeObserver(y);T.observe(t);const C={attributes:!0,childList:!0,subtree:!0},x=new MutationObserver(R=>{R.every(b=>b.target===t||t.contains(b.target))||p(!0)});return x.observe(document.body,C),{destroy:()=>{t.removeEventListener("pointermove",l),o.destroy(),i.unobserve(h),d(),document.removeEventListener("scroll",c),window.removeEventListener("resize",y),T.disconnect(),x.disconnect()},redraw:p,setStyle:A,setFilter:v,setPainter:g,setVisible:o.setVisible}},we=()=>{const t=document.createElement("canvas");return t.width=window.innerWidth,t.height=window.innerHeight,t.className="r6o-highlight-layer bg",t},Ae=(t,e)=>{t.width=window.innerWidth,t.height=window.innerHeight},Ee=t=>{t.classList.add("r6o-annotatable");const e=we(),n=e.getContext("2d");t.insertBefore(e,t.firstChild);const o=(s,u,f,m)=>requestAnimationFrame(()=>{const{width:l,height:p}=e;n.clearRect(-.5,-.5,l+1,p+1),m&&m.clear();const{top:g,left:A}=u;[...s].sort((h,d)=>{const{annotation:{target:{created:c}}}=h,{annotation:{target:{created:y}}}=d;return c.getTime()-y.getTime()}).forEach(h=>{var C;const d=f?typeof f=="function"?f(h.annotation,h.state):f:(C=h.state)!=null&&C.selected?G:U,c=m&&m.paint(h,u)||d,y=h.rects.map(({x,y:L,width:R,height:M})=>({x:x+A,y:L+g,width:R,height:M}));n.fillStyle=c.fill,n.globalAlpha=c.fillOpacity||1;const T=5;if(y.forEach(({x,y:L,width:R,height:M})=>n.fillRect(x,L-T/2,R,M+T)),c.underlineColor){n.globalAlpha=1,n.strokeStyle=c.underlineColor,n.lineWidth=c.underlineThickness??1;const x=T/2+(c.underlineOffset??0);y.forEach(({x:L,y:R,width:M,height:b})=>{n.beginPath(),n.moveTo(L,R+b+x),n.lineTo(L+M,R+b+x),n.stroke()})}})}),i=nt(()=>{Ae(e)});return window.addEventListener("resize",i),{destroy:()=>{t.removeChild(e),window.removeEventListener("resize",i)},setVisible:s=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},Mt=(t,e,n)=>ut(t,e,n,Ee(t));var xe={grad:.9,turn:360,rad:360/(2*Math.PI)},$=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},_=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},k=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},It=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},_t=function(t){return{r:k(t.r,0,255),g:k(t.g,0,255),b:k(t.b,0,255),a:k(t.a)}},ht=function(t){return{r:_(t.r),g:_(t.g),b:_(t.b),a:_(t.a,3)}},Se=/^#([0-9a-f]{3,8})$/i,it=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Dt=function(t){var e=t.r,n=t.g,o=t.b,i=t.a,r=Math.max(e,n,o),a=r-Math.min(e,n,o),s=a?r===e?(n-o)/a:r===n?2+(o-e)/a:4+(e-n)/a:0;return{h:60*(s<0?s+6:s),s:r?a/r*100:0,v:r/255*100,a:i}},Vt=function(t){var e=t.h,n=t.s,o=t.v,i=t.a;e=e/360*6,n/=100,o/=100;var r=Math.floor(e),a=o*(1-n),s=o*(1-(e-r)*n),u=o*(1-(1-e+r)*n),f=r%6;return{r:255*[o,s,a,a,u,o][f],g:255*[u,o,o,s,a,a][f],b:255*[a,a,u,o,o,s][f],a:i}},Ut=function(t){return{h:It(t.h),s:k(t.s,0,100),l:k(t.l,0,100),a:k(t.a)}},kt=function(t){return{h:_(t.h),s:_(t.s),l:_(t.l),a:_(t.a,3)}},Xt=function(t){return Vt((n=(e=t).s,{h:e.h,s:(n*=((o=e.l)<50?o:100-o)/100)>0?2*n/(o+n)*100:0,v:o+n,a:e.a}));var e,n,o},J=function(t){return{h:(e=Dt(t)).h,s:(i=(200-(n=e.s))*(o=e.v)/100)>0&&i<200?n*o/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,o,i},Ce=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Te=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Le=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Re=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yt={string:[[function(t){var e=Se.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?_(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?_(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Le.exec(t)||Re.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:_t({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Ce.exec(t)||Te.exec(t);if(!e)return null;var n,o,i=Ut({h:(n=e[1],o=e[2],o===void 0&&(o="deg"),Number(n)*(xe[o]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Xt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,o=t.b,i=t.a,r=i===void 0?1:i;return $(e)&&$(n)&&$(o)?_t({r:Number(e),g:Number(n),b:Number(o),a:Number(r)}):null},"rgb"],[function(t){var e=t.h,n=t.s,o=t.l,i=t.a,r=i===void 0?1:i;if(!$(e)||!$(n)||!$(o))return null;var a=Ut({h:Number(e),s:Number(n),l:Number(o),a:Number(r)});return Xt(a)},"hsl"],[function(t){var e=t.h,n=t.s,o=t.v,i=t.a,r=i===void 0?1:i;if(!$(e)||!$(n)||!$(o))return null;var a=function(s){return{h:It(s.h),s:k(s.s,0,100),v:k(s.v,0,100),a:k(s.a)}}({h:Number(e),s:Number(n),v:Number(o),a:Number(r)});return Vt(a)},"hsv"]]},Ht=function(t,e){for(var n=0;n<e.length;n++){var o=e[n][0](t);if(o)return[o,e[n][1]]}return[null,void 0]},Ne=function(t){return typeof t=="string"?Ht(t.trim(),Yt.string):typeof t=="object"&&t!==null?Ht(t,Yt.object):[null,void 0]},ft=function(t,e){var n=J(t);return{h:n.h,s:k(n.s+100*e,0,100),l:n.l,a:n.a}},gt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},$t=function(t,e){var n=J(t);return{h:n.h,s:n.s,l:k(n.l+100*e,0,100),a:n.a}},Pt=function(){function t(e){this.parsed=Ne(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return _(gt(this.rgba),2)},t.prototype.isDark=function(){return gt(this.rgba)<.5},t.prototype.isLight=function(){return gt(this.rgba)>=.5},t.prototype.toHex=function(){return e=ht(this.rgba),n=e.r,o=e.g,i=e.b,a=(r=e.a)<1?it(_(255*r)):"","#"+it(n)+it(o)+it(i)+a;var e,n,o,i,r,a},t.prototype.toRgb=function(){return ht(this.rgba)},t.prototype.toRgbString=function(){return e=ht(this.rgba),n=e.r,o=e.g,i=e.b,(r=e.a)<1?"rgba("+n+", "+o+", "+i+", "+r+")":"rgb("+n+", "+o+", "+i+")";var e,n,o,i,r},t.prototype.toHsl=function(){return kt(J(this.rgba))},t.prototype.toHslString=function(){return e=kt(J(this.rgba)),n=e.h,o=e.s,i=e.l,(r=e.a)<1?"hsla("+n+", "+o+"%, "+i+"%, "+r+")":"hsl("+n+", "+o+"%, "+i+"%)";var e,n,o,i,r},t.prototype.toHsv=function(){return e=Dt(this.rgba),{h:_(e.h),s:_(e.s),v:_(e.v),a:_(e.a,3)};var e},t.prototype.invert=function(){return Y({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),Y(ft(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),Y(ft(this.rgba,-e))},t.prototype.grayscale=function(){return Y(ft(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),Y($t(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),Y($t(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?Y({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):_(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=J(this.rgba);return typeof e=="number"?Y({h:e,s:n.s,l:n.l,a:n.a}):_(n.h)},t.prototype.isEqual=function(e){return this.toHex()===Y(e).toHex()},t}(),Y=function(t){return t instanceof Pt?t:new Pt(t)};const Be=t=>[`background-color:${Y((t==null?void 0:t.fill)||U.fill).alpha((t==null?void 0:t.fillOpacity)===void 0?U.fillOpacity:t.fillOpacity).toHex()}`,t!=null&&t.underlineThickness?"text-decoration:underline":void 0,t!=null&&t.underlineColor?`text-decoration-color:${t.underlineColor}`:void 0,t!=null&&t.underlineOffset?`text-underline-offset:${t.underlineOffset}px`:void 0,t!=null&&t.underlineThickness?`text-decoration-thickness:${t.underlineThickness}px`:void 0].filter(Boolean).join(";"),Ft=()=>{const t=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(t);let e=new Set;return{destroy:()=>{CSS.highlights.clear(),t.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,a,s,u)=>{u&&u.clear();const f=new Set(r.map(l=>l.annotation.id));Array.from(e).filter(l=>!f.has(l));const m=r.map(l=>{var A;const p=s?typeof s=="function"?s(l.annotation,l.state):s:(A=l.state)!=null&&A.selected?G:U,g=u&&u.paint(l,a)||p;return`::highlight(_${l.annotation.id}) { ${Be(g)} }`});t.innerHTML=m.join(`
|
|
2
|
+
`),CSS.highlights.clear(),r.forEach(({annotation:l})=>{const p=l.target.selector.map(A=>A.range),g=new Highlight(...p);CSS.highlights.set(`_${l.id}`,g)}),e=f}}},zt=(t,e,n)=>ut(t,e,n,Ft());var Wt=Object.prototype.hasOwnProperty;function pt(t,e){var n,o;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((o=t.length)===e.length)for(;o--&&pt(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Wt.call(t,n)&&++o&&!Wt.call(e,n)||!(n in e)||!pt(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}const Oe=(t,e)=>{const n=(o,i)=>o.x<=i.x+i.width&&o.x+o.width>=i.x&&o.y<=i.y+i.height&&o.y+o.height>=i.y;return e.filter(o=>t!==o&&n(t,o)&&o.width>t.width).length},Me=t=>{t.classList.add("r6o-annotatable");const e=document.createElement("div");e.className="r6o-span-highlight-layer",t.insertBefore(e,t.firstChild);let n=[];return{destroy:()=>{e.remove()},redraw:(a,s,u,f,m)=>{const p=!(pt(n,a)&&m);if(!f&&!p)return;p&&(e.innerHTML="");const g=a.reduce((A,{rects:v})=>[...A,...v],[]);a.forEach(A=>{A.rects.map(v=>{const h=Oe(v,g),d=xt(A,s,u,f,h);if(p){const c=document.createElement("span");c.className="r6o-annotation",c.dataset.annotation=A.annotation.id,c.style.left=`${v.x}px`,c.style.top=`${v.y}px`,c.style.width=`${v.width}px`,c.style.height=`${v.height}px`;const y=Y((d==null?void 0:d.fill)||U.fill).alpha((d==null?void 0:d.fillOpacity)===void 0?U.fillOpacity:d.fillOpacity).toHex();c.style.backgroundColor=y,d.underlineStyle&&(c.style.borderStyle=d.underlineStyle),d.underlineColor&&(c.style.borderColor=d.underlineColor),d.underlineThickness&&(c.style.borderBottomWidth=`${d.underlineThickness}px`),d.underlineOffset&&(c.style.paddingBottom=`${d.underlineOffset}px`),e.appendChild(c)}})}),n=a},setVisible:a=>{a?e.classList.remove("hidden"):e.classList.add("hidden")}}},jt=(t,e,n)=>ut(t,e,n,Me(t));for(var D=[],mt=0;mt<256;++mt)D.push((mt+256).toString(16).slice(1));function Ie(t,e=0){return(D[t[e+0]]+D[t[e+1]]+D[t[e+2]]+D[t[e+3]]+"-"+D[t[e+4]]+D[t[e+5]]+"-"+D[t[e+6]]+D[t[e+7]]+"-"+D[t[e+8]]+D[t[e+9]]+"-"+D[t[e+10]]+D[t[e+11]]+D[t[e+12]]+D[t[e+13]]+D[t[e+14]]+D[t[e+15]]).toLowerCase()}var rt,_e=new Uint8Array(16);function De(){if(!rt&&(rt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!rt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return rt(_e)}var Ve=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const qt={randomUUID:Ve};function Gt(t,e,n){if(qt.randomUUID&&!e&&!t)return qt.randomUUID();t=t||{};var o=t.random||(t.rng||De)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Ie(o)}var Qt=Object.prototype.hasOwnProperty;function z(t,e){var n,o;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((o=t.length)===e.length)for(;o--&&z(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Qt.call(t,n)&&++o&&!Qt.call(e,n)||!(n in e)||!z(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}function bt(){}function Ue(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}const W=[];function vt(t,e=bt){let n;const o=new Set;function i(s){if(Ue(t,s)&&(t=s,n)){const u=!W.length;for(const f of o)f[1](),W.push(f,t);if(u){for(let f=0;f<W.length;f+=2)W[f][0](W[f+1]);W.length=0}}}function r(s){i(s(t))}function a(s,u=bt){const f=[s,u];return o.add(f),o.size===1&&(n=e(i,r)||bt),s(t),()=>{o.delete(f),o.size===0&&n&&(n(),n=null)}}return{set:i,update:r,subscribe:a}}const ke=t=>{const{subscribe:e,set:n}=vt();let o;return e(i=>o=i),t.observe(({changes:i})=>{if(o){(i.deleted||[]).some(a=>a.id===o)&&n(void 0);const r=(i.updated||[]).find(({oldValue:a})=>a.id===o);r&&n(r.newValue.id)}}),{get current(){return o},subscribe:e,set:n}};var Jt=(t=>(t.EDIT="EDIT",t.SELECT="SELECT",t.NONE="NONE",t))(Jt||{});const yt={selected:[]},Xe=(t,e="EDIT")=>{const{subscribe:n,set:o}=vt(yt);let i=yt;n(l=>i=l);const r=()=>o(yt),a=()=>{var l;return((l=i.selected)==null?void 0:l.length)===0},s=l=>{if(i.selected.length===0)return!1;const p=typeof l=="string"?l:l.id;return i.selected.some(g=>g.id===p)},u=(l,p)=>{const g=t.getAnnotation(l);if(g){const A=Kt(g,e);o(A==="EDIT"?{selected:[{id:l,editable:!0}],pointerEvent:p}:A==="SELECT"?{selected:[{id:l}],pointerEvent:p}:{selected:[],pointerEvent:p})}else console.warn("Invalid selection: "+l)},f=(l,p)=>{const g=Array.isArray(l)?l:[l],A=g.map(v=>t.getAnnotation(v)).filter(Boolean);o({selected:A.map(v=>{const h=p===void 0?Kt(v,e)==="EDIT":p;return{id:v.id,editable:h}})}),A.length!==g.length&&console.warn("Invalid selection",l)},m=l=>{if(i.selected.length===0)return!1;const{selected:p}=i;p.filter(({id:g})=>l.includes(g)).length>0&&o({selected:p.filter(({id:g})=>!l.includes(g))})};return t.observe(({changes:l})=>m((l.deleted||[]).map(p=>p.id))),{clear:r,clickSelect:u,get selected(){return i?[...i.selected]:null},get pointerEvent(){return i?i.pointerEvent:null},isEmpty:a,isSelected:s,setSelected:f,subscribe:n}},Kt=(t,e)=>typeof e=="function"?e(t)||"EDIT":e||"EDIT";for(var V=[],wt=0;wt<256;++wt)V.push((wt+256).toString(16).slice(1));function Ye(t,e=0){return(V[t[e+0]]+V[t[e+1]]+V[t[e+2]]+V[t[e+3]]+"-"+V[t[e+4]]+V[t[e+5]]+"-"+V[t[e+6]]+V[t[e+7]]+"-"+V[t[e+8]]+V[t[e+9]]+"-"+V[t[e+10]]+V[t[e+11]]+V[t[e+12]]+V[t[e+13]]+V[t[e+14]]+V[t[e+15]]).toLowerCase()}var st,He=new Uint8Array(16);function $e(){if(!st&&(st=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!st))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return st(He)}var Pe=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Zt={randomUUID:Pe};function Fe(t,e,n){if(Zt.randomUUID&&!e&&!t)return Zt.randomUUID();t=t||{};var o=t.random||(t.rng||$e)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Ye(o)}const ze=(t,e,n,o)=>({id:Fe(),annotation:t.id,created:n||new Date,creator:o,...e}),We=(t,e)=>{const n=new Set(t.bodies.map(o=>o.id));return e.bodies.filter(o=>!n.has(o.id))},je=(t,e)=>{const n=new Set(e.bodies.map(o=>o.id));return t.bodies.filter(o=>!n.has(o.id))},qe=(t,e)=>e.bodies.map(n=>{const o=t.bodies.find(i=>i.id===n.id);return{newBody:n,oldBody:o&&!z(o,n)?o:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:o})=>({oldBody:n,newBody:o})),Ge=(t,e)=>!z(t.target,e.target),te=(t,e)=>{const n=We(t,e),o=je(t,e),i=qe(t,e);return{oldValue:t,newValue:e,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:o.length>0?o:void 0,bodiesUpdated:i.length>0?i:void 0,targetUpdated:Ge(t,e)?{oldTarget:t.target,newTarget:e.target}:void 0}};var O=(t=>(t.LOCAL="LOCAL",t.REMOTE="REMOTE",t))(O||{});const Qe=(t,e)=>{var n,o;const{changes:i,origin:r}=e;if(!(!t.options.origin||t.options.origin===r))return!1;if(t.options.ignore){const{ignore:a}=t.options,s=u=>u&&u.length>0;if(!(s(i.created)||s(i.deleted))){const u=(n=i.updated)==null?void 0:n.some(m=>s(m.bodiesCreated)||s(m.bodiesDeleted)||s(m.bodiesUpdated)),f=(o=i.updated)==null?void 0:o.some(m=>m.targetUpdated);if(a==="BODY_ONLY"&&u&&!f||a==="TARGET_ONLY"&&f&&!u)return!1}}if(t.options.annotations){const a=new Set([...(i.created||[]).map(s=>s.id),...(i.deleted||[]).map(s=>s.id),...(i.updated||[]).map(({oldValue:s})=>s.id)]);return!!(Array.isArray(t.options.annotations)?t.options.annotations:[t.options.annotations]).find(s=>a.has(s))}else return!0},Je=(t,e)=>{const n=new Set((t.created||[]).map(l=>l.id)),o=new Set((t.updated||[]).map(({newValue:l})=>l.id)),i=new Set((e.created||[]).map(l=>l.id)),r=new Set((e.deleted||[]).map(l=>l.id)),a=new Set((e.updated||[]).map(({oldValue:l})=>l.id)),s=new Set((e.updated||[]).filter(({oldValue:l})=>n.has(l.id)||o.has(l.id)).map(({oldValue:l})=>l.id)),u=[...(t.created||[]).filter(l=>!r.has(l.id)).map(l=>a.has(l.id)?e.updated.find(({oldValue:p})=>p.id===l.id).newValue:l),...e.created||[]],f=[...(t.deleted||[]).filter(l=>!i.has(l.id)),...(e.deleted||[]).filter(l=>!n.has(l.id))],m=[...(t.updated||[]).filter(({newValue:l})=>!r.has(l.id)).map(l=>{const{oldValue:p,newValue:g}=l;if(a.has(g.id)){const A=e.updated.find(v=>v.oldValue.id===g.id).newValue;return te(p,A)}else return l}),...(e.updated||[]).filter(({oldValue:l})=>!s.has(l.id))];return{created:u,deleted:f,updated:m}},Ke=t=>t.id!==void 0,Ze=()=>{const t=new Map,e=new Map,n=[],o=(b,w={})=>n.push({onChange:b,options:w}),i=b=>{const w=n.findIndex(E=>E.onChange==b);w>-1&&n.splice(w,1)},r=(b,w)=>{const E={origin:b,changes:{created:w.created||[],updated:w.updated||[],deleted:w.deleted||[]},state:[...t.values()]};n.forEach(S=>{Qe(S,E)&&S.onChange(E)})},a=(b,w=O.LOCAL)=>{if(t.get(b.id))throw Error(`Cannot add annotation ${b.id} - exists already`);t.set(b.id,b),b.bodies.forEach(E=>e.set(E.id,b.id)),r(w,{created:[b]})},s=(b,w)=>{const E=typeof b=="string"?w:b,S=typeof b=="string"?b:b.id,B=t.get(S);if(B){const I=te(B,E);return S===E.id?t.set(S,E):(t.delete(S),t.set(E.id,E)),B.bodies.forEach(F=>e.delete(F.id)),E.bodies.forEach(F=>e.set(F.id,E.id)),I}else console.warn(`Cannot update annotation ${S} - does not exist`)},u=(b,w=O.LOCAL,E=O.LOCAL)=>{const S=Ke(w)?E:w,B=s(b,w);B&&r(S,{updated:[B]})},f=(b,w=O.LOCAL)=>{const E=b.reduce((S,B)=>{const I=s(B);return I?[...S,I]:S},[]);E.length>0&&r(w,{updated:E})},m=(b,w=O.LOCAL)=>{const E=t.get(b.annotation);if(E){const S={...E,bodies:[...E.bodies,b]};t.set(E.id,S),e.set(b.id,S.id),r(w,{updated:[{oldValue:E,newValue:S,bodiesCreated:[b]}]})}else console.warn(`Attempt to add body to missing annotation: ${b.annotation}`)},l=()=>[...t.values()],p=(b=O.LOCAL)=>{const w=[...t.values()];t.clear(),e.clear(),r(b,{deleted:w})},g=(b,w=!0,E=O.LOCAL)=>{if(w){const S=[...t.values()];t.clear(),e.clear(),b.forEach(B=>{t.set(B.id,B),B.bodies.forEach(I=>e.set(I.id,B.id))}),r(E,{created:b,deleted:S})}else{const S=b.reduce((B,I)=>{const F=t.get(I.id);return F?[...B,F]:B},[]);if(S.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${S.map(B=>B.id).join(", ")}`);b.forEach(B=>{t.set(B.id,B),B.bodies.forEach(I=>e.set(I.id,B.id))}),r(E,{created:b})}},A=b=>{const w=typeof b=="string"?b:b.id,E=t.get(w);if(E)return t.delete(w),E.bodies.forEach(S=>e.delete(S.id)),E;console.warn(`Attempt to delete missing annotation: ${w}`)},v=(b,w=O.LOCAL)=>{const E=A(b);E&&r(w,{deleted:[E]})},h=(b,w=O.LOCAL)=>{const E=b.reduce((S,B)=>{const I=A(B);return I?[...S,I]:S},[]);E.length>0&&r(w,{deleted:E})},d=b=>{const w=t.get(b.annotation);if(w){const E=w.bodies.find(S=>S.id===b.id);if(E){e.delete(E.id);const S={...w,bodies:w.bodies.filter(B=>B.id!==b.id)};return t.set(w.id,S),{oldValue:w,newValue:S,bodiesDeleted:[E]}}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}`)},c=(b,w=O.LOCAL)=>{const E=d(b);E&&r(w,{updated:[E]})},y=(b,w=O.LOCAL)=>{const E=b.map(S=>d(S)).filter(Boolean);E.length>0&&r(w,{updated:E})},T=b=>{const w=t.get(b);return w?{...w}:void 0},C=b=>{const w=e.get(b);if(w){const E=T(w).bodies.find(S=>S.id===b);if(E)return E;console.error(`Store integrity error: body ${b} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${b}`)},x=(b,w)=>{if(b.annotation!==w.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const E=t.get(b.annotation);if(E){const S=E.bodies.find(I=>I.id===b.id),B={...E,bodies:E.bodies.map(I=>I.id===S.id?w:I)};return t.set(E.id,B),S.id!==w.id&&(e.delete(S.id),e.set(w.id,B.id)),{oldValue:E,newValue:B,bodiesUpdated:[{oldBody:S,newBody:w}]}}else console.warn(`Attempt to add body to missing annotation ${b.annotation}`)},L=(b,w,E=O.LOCAL)=>{const S=x(b,w);S&&r(E,{updated:[S]})},R=(b,w=O.LOCAL)=>{const E=b.map(S=>x({id:S.id,annotation:S.annotation},S)).filter(Boolean);r(w,{updated:E})},M=b=>{const w=t.get(b.annotation);if(w){const E={...w,target:{...w.target,...b}};return t.set(w.id,E),{oldValue:w,newValue:E,targetUpdated:{oldTarget:w.target,newTarget:b}}}else console.warn(`Attempt to update target on missing annotation: ${b.annotation}`)};return{addAnnotation:a,addBody:m,all:l,bulkAddAnnotation:g,bulkDeleteAnnotation:h,bulkDeleteBodies:y,bulkUpdateAnnotation:f,bulkUpdateBodies:R,bulkUpdateTargets:(b,w=O.LOCAL)=>{const E=b.map(S=>M(S)).filter(Boolean);E.length>0&&r(w,{updated:E})},clear:p,deleteAnnotation:v,deleteBody:c,getAnnotation:T,getBody:C,observe:o,unobserve:i,updateAnnotation:u,updateBody:L,updateTarget:(b,w=O.LOCAL)=>{const E=M(b);E&&r(w,{updated:[E]})}}};let tn=()=>({emit(t,...e){for(let n=0,o=this.events[t]||[],i=o.length;n<i;n++)o[n](...e)},events:{},on(t,e){var n;return((n=this.events)[t]||(n[t]=[])).push(e),()=>{var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>e!==i)}}});const en=250,nn=t=>{const e=tn(),n=[];let o=-1,i=!1,r=0;const a=g=>{if(!i){const{changes:A}=g,v=performance.now();if(v-r>en)n.splice(o+1),n.push(A),o=n.length-1;else{const h=n.length-1;n[h]=Je(n[h],A)}r=v}i=!1};t.observe(a,{origin:O.LOCAL});const s=g=>g&&g.length>0&&t.bulkDeleteAnnotation(g),u=g=>g&&g.length>0&&t.bulkAddAnnotation(g,!1),f=g=>g&&g.length>0&&t.bulkUpdateAnnotation(g.map(({oldValue:A})=>A)),m=g=>g&&g.length>0&&t.bulkUpdateAnnotation(g.map(({newValue:A})=>A)),l=g=>g&&g.length>0&&t.bulkAddAnnotation(g,!1),p=g=>g&&g.length>0&&t.bulkDeleteAnnotation(g);return{canRedo:()=>n.length-1>o,canUndo:()=>o>-1,destroy:()=>t.unobserve(a),on:(g,A)=>e.on(g,A),redo:()=>{if(n.length-1>o){i=!0;const{created:g,updated:A,deleted:v}=n[o+1];u(g),m(A),p(v),e.emit("redo",n[o+1]),o+=1}},undo:()=>{if(o>-1){i=!0;const{created:g,updated:A,deleted:v}=n[o];s(g),f(A),l(v),e.emit("undo",n[o]),o-=1}}}},on=()=>{const{subscribe:t,set:e}=vt([]);return{subscribe:t,set:e}},rn=(t,e,n,o)=>{const{store:i,selection:r,hover:a,viewport:s}=t,u=new Map;let f=[],m;const l=(v,h)=>{u.has(v)?u.get(v).push(h):u.set(v,[h])},p=(v,h)=>{const d=u.get(v);d&&d.indexOf(h)>0&&d.splice(d.indexOf(h),1)},g=(v,h,d)=>{u.has(v)&&setTimeout(()=>{u.get(v).forEach(c=>{if(n){const y=Array.isArray(h)?h.map(C=>n.serialize(C)):n.serialize(h),T=d?d instanceof PointerEvent?d:n.serialize(d):void 0;c(y,T)}else c(h,d)})},1)};r.subscribe(({selected:v})=>{if(!(f.length===0&&v.length===0)){if(f.length===0&&v.length>0)f=v.map(({id:h})=>i.getAnnotation(h));else if(f.length>0&&v.length===0)f.forEach(h=>{const d=i.getAnnotation(h.id);d&&!z(d,h)&&g("updateAnnotation",d,h)}),f=[];else{const h=new Set(f.map(c=>c.id)),d=new Set(v.map(({id:c})=>c));f.filter(c=>!d.has(c.id)).forEach(c=>{const y=i.getAnnotation(c.id);y&&!z(y,c)&&g("updateAnnotation",y,c)}),f=[...f.filter(c=>d.has(c.id)),...v.filter(({id:c})=>!h.has(c)).map(({id:c})=>i.getAnnotation(c))]}g("selectionChanged",f)}}),a.subscribe(v=>{!m&&v?g("mouseEnterAnnotation",i.getAnnotation(v)):m&&!v?g("mouseLeaveAnnotation",i.getAnnotation(m)):m&&v&&(g("mouseLeaveAnnotation",i.getAnnotation(m)),g("mouseEnterAnnotation",i.getAnnotation(v))),m=v}),s==null||s.subscribe(v=>g("viewportIntersect",v.map(h=>i.getAnnotation(h)))),i.observe(v=>{const{created:h,deleted:d}=v.changes;(h||[]).forEach(c=>g("createAnnotation",c)),(d||[]).forEach(c=>g("deleteAnnotation",c)),(v.changes.updated||[]).filter(c=>[...c.bodiesCreated||[],...c.bodiesDeleted||[],...c.bodiesUpdated||[]].length>0).forEach(({oldValue:c,newValue:y})=>{const T=f.find(C=>C.id===c.id)||c;f=f.map(C=>C.id===c.id?y:C),g("updateAnnotation",y,T)})},{origin:O.LOCAL}),i.observe(v=>{if(f){const h=new Set(f.map(c=>c.id)),d=(v.changes.updated||[]).filter(({newValue:c})=>h.has(c.id)).map(({newValue:c})=>c);d.length>0&&(f=f.map(c=>d.find(T=>T.id===c.id)||c))}},{origin:O.REMOTE});const A=v=>h=>{const{updated:d}=h;v?(d||[]).forEach(c=>g("updateAnnotation",c.oldValue,c.newValue)):(d||[]).forEach(c=>g("updateAnnotation",c.newValue,c.oldValue))};return e.on("undo",A(!0)),e.on("redo",A(!1)),{on:l,off:p,emit:g}},sn=t=>e=>e.reduce((n,o)=>{const{parsed:i,error:r}=t.parse(o);return r?{parsed:n.parsed,failed:[...n.failed,o]}:i?{parsed:[...n.parsed,i],failed:n.failed}:{...n}},{parsed:[],failed:[]}),an=(t,e,n)=>{const{store:o,selection:i}=t,r=h=>{if(n){const{parsed:d,error:c}=n.parse(h);d?o.addAnnotation(d,O.REMOTE):console.error(c)}else o.addAnnotation(h,O.REMOTE)},a=()=>i.clear(),s=()=>o.clear(),u=h=>{const d=o.getAnnotation(h);return n&&d?n.serialize(d):d},f=()=>n?o.all().map(n.serialize):o.all(),m=()=>{var h;const d=(((h=i.selected)==null?void 0:h.map(c=>c.id))||[]).map(c=>o.getAnnotation(c)).filter(Boolean);return n?d.map(n.serialize):d},l=(h,d=!0)=>fetch(h).then(c=>c.json()).then(c=>(g(c,d),c)),p=h=>{if(typeof h=="string"){const d=o.getAnnotation(h);if(o.deleteAnnotation(h),d)return n?n.serialize(d):d}else{const d=n?n.parse(h).parsed:h;if(d)return o.deleteAnnotation(d),h}},g=(h,d=!0)=>{if(n){const{parsed:c,failed:y}=sn(n)(h);y.length>0&&console.warn(`Discarded ${y.length} invalid annotations`,y),o.bulkAddAnnotation(c,d,O.REMOTE)}else o.bulkAddAnnotation(h,d,O.REMOTE)},A=(h,d)=>{h?i.setSelected(h,d):i.clear()},v=h=>{if(n){const d=n.parse(h).parsed,c=n.serialize(o.getAnnotation(d.id));return o.updateAnnotation(d),c}else{const d=o.getAnnotation(h.id);return o.updateAnnotation(h),d}};return{addAnnotation:r,cancelSelected:a,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:s,getAnnotationById:u,getAnnotations:f,getSelected:m,loadAnnotations:l,redo:e.redo,removeAnnotation:p,setAnnotations:g,setSelected:A,undo:e.undo,updateAnnotation:v}},cn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ln=t=>crypto.getRandomValues(new Uint8Array(t)),dn=(t,e,n)=>{let o=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*o*e/t.length);return(r=e)=>{let a="";for(;;){let s=n(i),u=i;for(;u--;)if(a+=t[s[u]&o]||"",a.length===r)return a}}},un=(t,e=21)=>dn(t,e,ln),hn=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=cn[n[t]&63];return e};const fn=()=>({isGuest:!0,id:un("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),gn=t=>{const e=JSON.stringify(t);let n=0;for(let o=0,i=e.length;o<i;o++){let r=e.charCodeAt(o);n=(n<<5)-n+r,n|=0}return`${n}`},ee=t=>t?typeof t=="object"?{...t}:t:void 0,pn=(t,e)=>(Array.isArray(t)?t:[t]).map(n=>{const{id:o,type:i,purpose:r,value:a,created:s,modified:u,creator:f,...m}=n;return{id:o||`temp-${gn(n)}`,annotation:e,type:i,purpose:r,value:a,creator:ee(f),created:s?new Date(s):void 0,updated:u?new Date(u):void 0,...m}}),mn=t=>t.map(e=>{var n;const{annotation:o,created:i,updated:r,...a}=e,s={...a,created:i==null?void 0:i.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=s.id)!=null&&n.startsWith("temp-")&&delete s.id,s});hn();const bn=(t,e)=>({parse:n=>ne(n),serialize:n=>oe(n,t,e)}),vn=t=>t.quote!==void 0&&t.start!==void 0&&t.end!==void 0,yn=t=>{const{id:e,creator:n,created:o,modified:i,target:r}=t,a=Array.isArray(r)?r:[r],s={creator:ee(n),created:o?new Date(o):void 0,updated:i?new Date(i):void 0,annotation:e,selector:[]};for(const u of a){const m=(Array.isArray(u.selector)?u.selector:[u.selector]).reduce((l,p)=>{switch(p.type){case"TextQuoteSelector":l.quote=p.exact;break;case"TextPositionSelector":l.start=p.start,l.end=p.end;break}return l},{});if(vn(m))s.selector.push({id:u.id,...m});else{const l=[m.start?void 0:"TextPositionSelector",m.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`)}}}return{parsed:s}},ne=t=>{const e=t.id||Gt(),{creator:n,created:o,modified:i,body:r,...a}=t,s=pn(r,e),u=yn(t);return"error"in u?{error:u.error}:{parsed:{...a,id:e,bodies:s,target:u.parsed}}},oe=(t,e,n)=>{const{bodies:o,target:i,...r}=t,{selector:a,creator:s,created:u,updated:f,...m}=i,l=a.map(p=>{const{quote:g,start:A,end:v,range:h}=p,{prefix:d,suffix:c}=Rt(h,n),y=[{type:"TextQuoteSelector",exact:g,prefix:d,suffix:c},{type:"TextPositionSelector",start:A,end:v}];return{...m,id:p.id,source:e,selector:y}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:t.id,type:"Annotation",body:mn(t.bodies),creator:s,created:u==null?void 0:u.toISOString(),modified:f==null?void 0:f.toISOString(),target:l}};function wn(t,e,n,o,i){ie(t,e,n||0,o||t.length-1,i||An)}function ie(t,e,n,o,i){for(;o>n;){if(o-n>600){var r=o-n+1,a=e-n+1,s=Math.log(r),u=.5*Math.exp(2*s/3),f=.5*Math.sqrt(s*u*(r-u)/r)*(a-r/2<0?-1:1),m=Math.max(n,Math.floor(e-a*u/r+f)),l=Math.min(o,Math.floor(e+(r-a)*u/r+f));ie(t,e,m,l,i)}var p=t[e],g=n,A=o;for(K(t,n,e),i(t[o],p)>0&&K(t,n,o);g<A;){for(K(t,g,A),g++,A--;i(t[g],p)<0;)g++;for(;i(t[A],p)>0;)A--}i(t[n],p)===0?K(t,n,A):(A++,K(t,A,o)),A<=e&&(n=A+1),e<=A&&(o=A-1)}}function K(t,e,n){var o=t[e];t[e]=t[n],t[n]=o}function An(t,e){return t<e?-1:t>e?1:0}class En{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let n=this.data;const o=[];if(!ct(e,n))return o;const i=this.toBBox,r=[];for(;n;){for(let a=0;a<n.children.length;a++){const s=n.children[a],u=n.leaf?i(s):s;ct(e,u)&&(n.leaf?o.push(s):Et(e,u)?this._all(s,o):r.push(s))}n=r.pop()}return o}collides(e){let n=this.data;if(!ct(e,n))return!1;const o=[];for(;n;){for(let i=0;i<n.children.length;i++){const r=n.children[i],a=n.leaf?this.toBBox(r):r;if(ct(e,a)){if(n.leaf||Et(e,a))return!0;o.push(r)}}n=o.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let o=0;o<e.length;o++)this.insert(e[o]);return this}let n=this._build(e.slice(),0,e.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(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=q([]),this}remove(e,n){if(!e)return this;let o=this.data;const i=this.toBBox(e),r=[],a=[];let s,u,f;for(;o||r.length;){if(o||(o=r.pop(),u=r[r.length-1],s=a.pop(),f=!0),o.leaf){const m=xn(e,o.children,n);if(m!==-1)return o.children.splice(m,1),r.push(o),this._condense(r),this}!f&&!o.leaf&&Et(o,i)?(r.push(o),a.push(s),s=0,u=o,o=o.children[0]):u?(s++,o=u.children[s],f=!1):o=null}return this}toBBox(e){return e}compareMinX(e,n){return e.minX-n.minX}compareMinY(e,n){return e.minY-n.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,n){const o=[];for(;e;)e.leaf?n.push(...e.children):o.push(...e.children),e=o.pop();return n}_build(e,n,o,i){const r=o-n+1;let a=this._maxEntries,s;if(r<=a)return s=q(e.slice(n,o+1)),j(s,this.toBBox),s;i||(i=Math.ceil(Math.log(r)/Math.log(a)),a=Math.ceil(r/Math.pow(a,i-1))),s=q([]),s.leaf=!1,s.height=i;const u=Math.ceil(r/a),f=u*Math.ceil(Math.sqrt(a));re(e,n,o,f,this.compareMinX);for(let m=n;m<=o;m+=f){const l=Math.min(m+f-1,o);re(e,m,l,u,this.compareMinY);for(let p=m;p<=l;p+=u){const g=Math.min(p+u-1,l);s.children.push(this._build(e,p,g,i-1))}}return j(s,this.toBBox),s}_chooseSubtree(e,n,o,i){for(;i.push(n),!(n.leaf||i.length-1===o);){let r=1/0,a=1/0,s;for(let u=0;u<n.children.length;u++){const f=n.children[u],m=At(f),l=Tn(e,f)-m;l<a?(a=l,r=m<r?m:r,s=f):l===a&&m<r&&(r=m,s=f)}n=s||n.children[0]}return n}_insert(e,n,o){const i=o?e:this.toBBox(e),r=[],a=this._chooseSubtree(i,this.data,n,r);for(a.children.push(e),tt(a,i);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(i,r,n)}_split(e,n){const o=e[n],i=o.children.length,r=this._minEntries;this._chooseSplitAxis(o,r,i);const a=this._chooseSplitIndex(o,r,i),s=q(o.children.splice(a,o.children.length-a));s.height=o.height,s.leaf=o.leaf,j(o,this.toBBox),j(s,this.toBBox),n?e[n-1].children.push(s):this._splitRoot(o,s)}_splitRoot(e,n){this.data=q([e,n]),this.data.height=e.height+1,this.data.leaf=!1,j(this.data,this.toBBox)}_chooseSplitIndex(e,n,o){let i,r=1/0,a=1/0;for(let s=n;s<=o-n;s++){const u=Z(e,0,s,this.toBBox),f=Z(e,s,o,this.toBBox),m=Ln(u,f),l=At(u)+At(f);m<r?(r=m,i=s,a=l<a?l:a):m===r&&l<a&&(a=l,i=s)}return i||o-n}_chooseSplitAxis(e,n,o){const i=e.leaf?this.compareMinX:Sn,r=e.leaf?this.compareMinY:Cn,a=this._allDistMargin(e,n,o,i),s=this._allDistMargin(e,n,o,r);a<s&&e.children.sort(i)}_allDistMargin(e,n,o,i){e.children.sort(i);const r=this.toBBox,a=Z(e,0,n,r),s=Z(e,o-n,o,r);let u=at(a)+at(s);for(let f=n;f<o-n;f++){const m=e.children[f];tt(a,e.leaf?r(m):m),u+=at(a)}for(let f=o-n-1;f>=n;f--){const m=e.children[f];tt(s,e.leaf?r(m):m),u+=at(s)}return u}_adjustParentBBoxes(e,n,o){for(let i=o;i>=0;i--)tt(n[i],e)}_condense(e){for(let n=e.length-1,o;n>=0;n--)e[n].children.length===0?n>0?(o=e[n-1].children,o.splice(o.indexOf(e[n]),1)):this.clear():j(e[n],this.toBBox)}}function xn(t,e,n){if(!n)return e.indexOf(t);for(let o=0;o<e.length;o++)if(n(t,e[o]))return o;return-1}function j(t,e){Z(t,0,t.children.length,e,t)}function Z(t,e,n,o,i){i||(i=q(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=e;r<n;r++){const a=t.children[r];tt(i,t.leaf?o(a):a)}return i}function tt(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Sn(t,e){return t.minX-e.minX}function Cn(t,e){return t.minY-e.minY}function At(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function at(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Tn(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Ln(t,e){const n=Math.max(t.minX,e.minX),o=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),r=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,r-o)}function Et(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function ct(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function q(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function re(t,e,n,o,i){const r=[e,n];for(;r.length;){if(n=r.pop(),e=r.pop(),n-e<=o)continue;const a=e+Math.ceil((n-e)/o/2)*o;wn(t,a,e,n,i),r.push(e,a,a,n)}}const Rn=(t,e)=>{const n=new En,o=new Map,i=(d,c)=>{const y=d.selector.flatMap(C=>{const L=C.range instanceof Range&&!C.range.collapsed&&C.range.startContainer.nodeType===Node.TEXT_NODE&&C.range.endContainer.nodeType===Node.TEXT_NODE?C.range:dt(C,e).range;return Array.from(L.getClientRects())}),T=Nt(y).map(({left:C,top:x,right:L,bottom:R})=>new DOMRect(C-c.left,x-c.top,L-C,R-x));return T.map(C=>{const{x,y:L,width:R,height:M}=C;return{minX:x,minY:L,maxX:x+R,maxY:L+M,annotation:{id:d.annotation,rects:T}}})},r=()=>[...o.values()],a=()=>{n.clear(),o.clear()},s=d=>{const c=i(d,e.getBoundingClientRect());c.forEach(y=>n.insert(y)),o.set(d.annotation,c)},u=d=>{const c=o.get(d.annotation);c&&(c.forEach(y=>n.remove(y)),o.delete(d.annotation))},f=d=>{u(d),s(d)},m=(d,c=!0)=>{c&&a();const y=e.getBoundingClientRect(),T=d.map(x=>({target:x,rects:i(x,y)}));T.forEach(({target:x,rects:L})=>o.set(x.annotation,L));const C=T.reduce((x,{rects:L})=>[...x,...L],[]);n.load(C)},l=(d,c)=>{const y=n.search({minX:d,minY:c,maxX:d,maxY:c}),T=C=>C.annotation.rects.reduce((x,L)=>x+L.width*L.height,0);if(y.length>0)return y.sort((C,x)=>T(C)-T(x)),y[0].annotation.id},p=d=>{const c=g(d);if(c.length===0)return;let y=c[0].left,T=c[0].top,C=c[0].right,x=c[0].bottom;for(let L=1;L<c.length;L++){const R=c[L];y=Math.min(y,R.left),T=Math.min(T,R.top),C=Math.max(C,R.right),x=Math.max(x,R.bottom)}return new DOMRect(y,T,C-y,x-T)},g=d=>{const c=o.get(d);return c?c[0].annotation.rects:[]};return{all:r,clear:a,getAt:l,getAnnotationBounds:p,getAnnotationRects:g,getIntersecting:(d,c,y,T)=>{const C=n.search({minX:d,minY:c,maxX:y,maxY:T}),x=new Set(C.reduce((L,R)=>[...L,R.annotation.id],[]));return Array.from(x).map(L=>({annotation:t.getAnnotation(L),rects:g(L)})).filter(L=>!!L.annotation)},insert:s,recalculate:()=>m(t.all().map(d=>d.target),!0),remove:u,set:m,size:()=>n.all().length,update:f}},se=(t,e)=>{const n=Ze(),o=Rn(n,t),i=Xe(n,e),r=ke(n),a=on(),s=(v,h=O.LOCAL)=>{const d=ot(v,t),c=H(d.target.selector);return c&&n.addAnnotation(d,h),c},u=(v,h=!0,d=O.LOCAL)=>{const c=v.map(T=>ot(T,t)),y=c.filter(T=>!H(T.target.selector));return y.length>0?(console.warn("Could not revive all targets for these annotations:",y),n.bulkAddAnnotation(c,h,d),y):(n.bulkAddAnnotation(c,h,d),[])},f=(v,h=O.LOCAL)=>{const d=v.map(y=>ot(y,t)),c=d.filter(y=>!H(y.target.selector));return c.length>0&&console.warn("Could not revive all targets for these annotations:",c),d.forEach(y=>{n.getAnnotation(y.id)?n.updateAnnotation(y,h):n.addAnnotation(y,h)}),c},m=(v,h=O.LOCAL)=>{const d=Q(v,t);n.updateTarget(d,h)},l=(v,h=O.LOCAL)=>{const d=v.map(c=>Q(c,t));n.bulkUpdateTargets(d,h)},p=(v,h)=>{const d=o.getAt(v,h);return d?n.getAnnotation(d):void 0},g=(v,h,d,c=5)=>{const y=o.getAnnotationRects(v);if(y.length!==0){if(h&&d){const T=y.find(({top:C,right:x,bottom:L,left:R})=>h>=R-c&&h<=x+c&&d>=C-c&&d<=L+c);if(T)return T}return o.getAnnotationBounds(v)}},A=()=>o.recalculate();return n.observe(({changes:v})=>{const h=(v.created||[]).filter(y=>H(y.target.selector)),d=(v.deleted||[]).filter(y=>H(y.target.selector)),c=(v.updated||[]).filter(y=>H(y.newValue.target.selector));h.length>0&&o.set(h.map(y=>y.target),!1),(d==null?void 0:d.length)>0&&d.forEach(y=>o.remove(y.target)),(c==null?void 0:c.length)>0&&c.forEach(({newValue:y})=>o.update(y.target))}),{store:{...n,addAnnotation:s,bulkAddAnnotation:u,bulkUpdateTargets:l,bulkUpsertAnnotations:f,getAnnotationBounds:g,getAt:p,getIntersecting:o.getIntersecting,recalculatePositions:A,updateTarget:m},selection:i,hover:r,viewport:a}},Nn=()=>{const t=document.createElement("canvas");t.width=2*window.innerWidth,t.height=2*window.innerHeight,t.className="r6o-highlight-layer presence";const e=t.getContext("2d");return e.scale(2,2),e.translate(.5,.5),t},Bn=(t,e,n={})=>{const o=Nn(),i=o.getContext("2d");t.appendChild(o);const r=new Map,a=l=>Array.from(r.entries()).filter(([p,g])=>g.presenceKey===l.presenceKey).map(([p,g])=>p);return e.on("selectionChange",(l,p)=>{a(l).forEach(A=>r.delete(A)),p&&p.forEach(A=>r.set(A,l))}),{clear:()=>{const{width:l,height:p}=o;i.clearRect(-.5,-.5,l+1,p+1)},destroy:()=>{o.remove()},paint:(l,p,g)=>{n.font&&(i.font=n.font);const A=r.get(l.annotation.id);if(A){const{height:v}=l.rects[0],h=l.rects[0].x+p.left,d=l.rects[0].y+p.top;i.fillStyle=A.appearance.color,i.fillRect(h-2,d-2.5,2,v+5);const c=i.measureText(A.appearance.label),y=c.width+6,T=c.actualBoundingBoxAscent+c.actualBoundingBoxDescent+8,C=c.fontBoundingBoxAscent?8:6.5;return i.fillRect(h-2,d-2.5-T,y,T),i.fillStyle="#fff",i.fillText(A.appearance.label,h+1,d-C),{fill:A.appearance.color,fillOpacity:g?.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)}}},ae=t=>{if(t===null)return document.scrollingElement;const{overflowY:e}=window.getComputedStyle(t);return e!=="visible"&&e!=="hidden"&&t.scrollHeight>t.clientHeight?t:ae(t.parentElement)},On=(t,e)=>n=>{const o=typeof n=="string"?n:n.id,i=a=>{const s=r.getBoundingClientRect(),u=r.clientHeight,f=r.clientWidth,m=a.selector[0].range.getBoundingClientRect(),{width:l,height:p}=e.getAnnotationBounds(o),g=m.top-s.top,A=m.left-s.left,v=r.parentElement?r.scrollTop:0,h=r.parentElement?r.scrollLeft:0,d=g+v-(u-p)/2,c=A+h-(f-l)/2;r.scroll({top:d,left:c,behavior:"smooth"})},r=ae(t);if(r){const a=e.getAnnotation(o),{range:s}=a.target.selector[0];if(s&&!s.collapsed)return i(a.target),!0;{const u=Q(a.target,t),{range:f}=u.selector[0];if(f&&!f.collapsed)return i(u),!0}}return!1},ce=(t,e)=>({...t,annotationEnabled:t.annotationEnabled===void 0?e.annotationEnabled:t.annotationEnabled}),Mn=(t,e,n,o)=>{const{store:i,selection:r}=e;let a,s;const u=h=>a=h;let f=!1,m;const l=h=>{var c;if(!f)return;!((c=h.target.parentElement)!=null&&c.closest(X))?s={annotation:Gt(),selector:[],creator:a,created:new Date}:s=void 0};n&&t.addEventListener("selectstart",l);const p=nt(h=>{var L,R;const d=document.getSelection();if(!!((R=(L=d.anchorNode)==null?void 0:L.parentElement)!=null&&R.closest(X))){s=void 0;return}if(h.timeStamp-((m==null?void 0:m.timeStamp)||h.timeStamp)<1e3&&!s&&l(m),d.isCollapsed||!f||!s)return;const y=d.getRangeAt(0),T=Ot(y.cloneRange()),C=St(T);(C.length!==s.selector.length||C.some((M,b)=>{var w;return M.toString()!==((w=s.selector[b])==null?void 0:w.quote)}))&&(s={...s,selector:C.map(M=>Bt(M,t,o)),updated:new Date},i.getAnnotation(s.annotation)?i.updateTarget(s,O.LOCAL):(i.addAnnotation({id:s.annotation,bodies:[],target:s}),r.clickSelect(s.annotation,m)))});n&&document.addEventListener("selectionchange",p);const g=h=>{const{target:d,timeStamp:c,offsetX:y,offsetY:T,type:C}=h;m={...h,target:d,timeStamp:c,offsetX:y,offsetY:T,type:C},f=h.button===0};t.addEventListener("pointerdown",g);const A=h=>{var T;if(!!((T=h.target.parentElement)!=null&&T.closest(X))||!f)return;const c=()=>{const{x:C,y:x}=t.getBoundingClientRect(),L=i.getAt(h.clientX-C,h.clientY-x);if(L){const{selected:R}=r;(R.length!==1||R[0].id!==L.id)&&r.clickSelect(L.id,h)}else r.isEmpty()||r.clear()},y=h.timeStamp-m.timeStamp;document.getSelection().isCollapsed&&y<300?(s=void 0,c()):s&&r.clickSelect(s.annotation,h)};return document.addEventListener("pointerup",A),{destroy:()=>{t.removeEventListener("selectstart",l),document.removeEventListener("selectionchange",p),t.removeEventListener("pointerdown",g),document.removeEventListener("pointerup",A)},setUser:u}},le="SPANS",In=(t,e={})=>{Ct(t);const n=ce(e,{annotationEnabled:!0}),o=se(t,n.pointerAction),{selection:i,viewport:r}=o,a=o.store,s=nn(a),u=rn(o,s,n.adapter);let f=fn();const m=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":le:n.renderer||le,l=m==="SPANS"?jt(t,o,r):m==="CSS_HIGHLIGHTS"?zt(t,o,r):m==="CANVAS"?Mt(t,o,r):void 0;if(!l)throw`Unknown renderer implementation: ${m}`;console.debug(`Using ${m} renderer`),n.style&&l.setStyle(n.style);const p=Mn(t,o,n.annotationEnabled,n.offsetReferenceSelector);return p.setUser(f),{...an(o,s,n.adapter),destroy:()=>{l.destroy(),p.destroy(),s.destroy()},element:t,getUser:()=>f,setFilter:x=>l.setFilter(x),setStyle:x=>l.setStyle(x),setUser:x=>{f=x,p.setUser(x)},setSelected:x=>{x?i.setSelected(x):i.clear()},setPresenceProvider:x=>{x&&(l.setPainter(Bn(t,x,n.presence)),x.on("selectionChange",()=>l.redraw()))},setVisible:x=>l.setVisible(x),on:u.on,off:u.off,scrollIntoView:On(t,a),state:o}};N.DEFAULT_SELECTED_STYLE=G,N.DEFAULT_STYLE=U,N.NOT_ANNOTATABLE_CLASS=lt,N.NOT_ANNOTATABLE_SELECTOR=X,N.Origin=O,N.PointerSelectAction=Jt,N.W3CTextFormat=bn,N.cancelSingleClickEvents=Ct,N.createBody=ze,N.createCanvasRenderer=Mt,N.createHighlightsRenderer=zt,N.createRenderer=Ft,N.createSpansRenderer=jt,N.createTextAnnotator=In,N.createTextAnnotatorState=se,N.debounce=nt,N.fillDefaults=ce,N.getAnnotatableFragment=he,N.getClientRectsPonyfill=pe,N.getQuoteContext=Rt,N.getRangeAnnotatableContents=et,N.isRevived=H,N.mergeClientRects=Nt,N.paint=xt,N.parseW3CTextAnnotation=ne,N.rangeToSelector=Bt,N.reviveAnnotation=ot,N.reviveSelector=dt,N.reviveTarget=Q,N.serializeW3CTextAnnotation=oe,N.splitAnnotatableRanges=St,N.trimRange=Ot,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
|
3
3
|
//# sourceMappingURL=text-annotator.umd.js.map
|