@recogito/text-annotator 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/TextAnnotatorOptions.d.ts +1 -0
- package/dist/src/utils/isNotAnnotatable.d.ts +2 -2
- package/dist/src/utils/splitAnnotatableRanges.d.ts +1 -1
- package/dist/text-annotator.es.js +639 -2204
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(O,J){typeof exports=="object"&&typeof module<"u"?J(exports):typeof define=="function"&&define.amd?define(["exports"],J):(O=typeof globalThis<"u"?globalThis:O||self,J(O.RecogitoJS={}))})(this,(function(O){"use strict";const J="not-annotatable",Z=`.${J}`,nt=t=>{var n;return!!(t instanceof HTMLElement?t.closest(Z):(n=t.parentElement)==null?void 0:n.closest(Z))},zt=t=>{const e=t.commonAncestorContainer;return!nt(e)},Ft=t=>t.addEventListener("click",e=>{!e.target.closest(Z)&&!e.target.closest("a")&&e.preventDefault()}),wt=t=>({...t,type:t.type,x:t.x,y:t.y,clientX:t.clientX,clientY:t.clientY,offsetX:t.offsetX,offsetY:t.offsetY,screenX:t.screenX,screenY:t.screenY,isPrimary:t.isPrimary,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey,button:t.button,buttons:t.buttons,currentTarget:t.currentTarget,target:t.target,defaultPrevented:t.defaultPrevented,detail:t.detail,eventPhase:t.eventPhase,pointerId:t.pointerId,pointerType:t.pointerType,timeStamp:t.timeStamp}),at=t=>({...t,type:t.type,key:t.key,code:t.code,location:t.location,repeat:t.repeat,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey,currentTarget:t.currentTarget,target:t.target,defaultPrevented:t.defaultPrevented,detail:t.detail,timeStamp:t.timeStamp}),Wt=typeof navigator<"u"&&/mac/i.test(navigator.userAgentData?navigator.userAgentData.platform:navigator.platform),qt=t=>{!t.hasAttribute("tabindex")&&t.tabIndex<0&&t.setAttribute("tabindex","-1"),t.classList.add("no-focus-outline")},At=(t,e=10)=>{let n;return((...o)=>{clearTimeout(n),n=setTimeout(()=>t.apply(void 0,o),e)})},qe=function*(t){const e=document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(J)&&!o.parentElement.closest(Z)&&t.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=e.nextNode();)n instanceof HTMLElement&&(yield n)},Gt=t=>{if(!zt(t))return[];const e=[];let n=null;for(const o of qe(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]},vt=t=>{const e=t.cloneContents();return e.querySelectorAll(Z).forEach(n=>n.remove()),e},Qt=(t,e,n=10,o)=>{const i=o?t.startContainer.parentElement.closest(o):e,s=document.createRange();s.setStart(i,0),s.setEnd(t.startContainer,t.startOffset);const a=vt(s).textContent,r=document.createRange();r.setStart(t.endContainer,t.endOffset),i===document.body?r.setEnd(i,i.childNodes.length):r.setEndAfter(i);const d=vt(r).textContent;return{prefix:a.substring(a.length-n),suffix:d.substring(0,n)}},W=t=>t.every(e=>e.range instanceof Range&&!e.range.collapsed),Jt=/^\s*$/,Zt=t=>Jt.test(t.toString()),Ge=(t,e)=>{const n=s=>Math.round(s*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"},Qe=(t,e)=>{const n=Math.min(t.left,e.left),o=Math.max(t.right,e.right),i=Math.min(t.top,e.top),s=Math.max(t.bottom,e.bottom);return new DOMRect(n,i,o-n,s-i)},te=t=>t.reduce((e,n)=>{if(n.width===0||n.height===0)return e;let o=[...e],i=!1;for(const s of e){const a=Ge(n,s);if(a==="inline-adjacent"){o=o.map(r=>r===s?Qe(n,s):r),i=!0;break}else if(a==="inline-contains"){o=o.map(r=>r===s?n:r),i=!0;break}else if(a==="inline-is-contained"){i=!0;break}else if(a==="block-contains"||a==="block-is-contained"){n.width<s.width&&(o=o.map(r=>r===s?n:r)),i=!0;break}}return i?o:[...o,n]},[]),Je=t=>({length:t.length,item:e=>t[e],[Symbol.iterator]:function*(){for(let e=0;e<this.length;e++)yield this.item(e)}}),ee=(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 s=vt(o).textContent,a=t.toString(),r=s.length||0,d=r+a.length;return n?{quote:a,start:r,end:d,range:t,offsetReference:i}:{quote:a,start:r,end:d,range:t}},Rt=(t,e)=>{var g,u;const{start:n,end:o}=t,i=t.offsetReference||e,s=document.createNodeIterator(e,NodeFilter.SHOW_TEXT,h=>{var E;return(E=h.parentElement)!=null&&E.closest(Z)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let a=0;const r=document.createRange();let d=s.nextNode();d===null&&console.error("Could not revive annotation target. Content missing.");let f=!i;for(;d!==null;){if(f||(f=typeof(i==null?void 0:i.contains)=="function"?i.contains(d):!1),f){const h=((g=d.textContent)==null?void 0:g.length)||0;if(a+h>n){r.setStart(d,n-a);break}a+=h}d=s.nextNode()}for(;d!==null;){const h=((u=d.textContent)==null?void 0:u.length)||0;if(a+h>=o){r.setEnd(d,o-a);break}a+=h,d=s.nextNode()}return{...t,range:r}},lt=(t,e)=>W(t.selector)?t:{...t,selector:t.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:Rt(n,e))},Et=(t,e)=>W(t.target.selector)?t:{...t,target:lt(t.target,e)},ne=(t,e)=>{const n=t.cloneRange();return e.contains(n.startContainer)||n.setStart(e,0),e.contains(n.endContainer)||n.setEnd(e,e.childNodes.length),n},oe=t=>{if(t===null)return document.scrollingElement;const{overflowY:e}=window.getComputedStyle(t);return e!=="visible"&&e!=="hidden"&&t.scrollHeight>t.clientHeight?t:oe(t.parentElement)},ie=(t,e)=>n=>{const o=typeof n=="string"?n:n.id,i=g=>{const u=s.getBoundingClientRect(),h=s.clientHeight,E=s.clientWidth,b=g.selector[0].range.getBoundingClientRect(),{width:p,height:A}=e.getAnnotationBounds(o),c=b.top-u.top,l=b.left-u.left,m=s.parentElement?s.scrollTop:0,S=s.parentElement?s.scrollLeft:0,x=c+m-(h-A)/2,L=l+S-(E-p)/2;s.scroll({top:x,left:L,behavior:"smooth"})},s=oe(t);if(!s)return console.warn(`The scroll parent is missing for the annotation: ${o}`,{container:t}),!1;const a=e.getAnnotation(o);if(!a)return console.warn(`The annotation is missing in the store: ${o}`),!1;const{range:r}=a.target.selector[0];if(r&&!r.collapsed)return i(a.target),!0;const d=lt(a.target,t),{range:f}=d.selector[0];return f&&!f.collapsed?(i(d),!0):!1},q={fill:"rgb(0, 128, 255)",fillOpacity:.18},ct={fill:"rgb(0, 128, 255)",fillOpacity:.45},se=(t,e,n,o,i)=>{var a,r;const s=n?typeof n=="function"?n(t.annotation,t.state,i)||((a=t.state)!=null&&a.selected?ct:q):n:(r=t.state)!=null&&r.selected?ct:q;return o&&o.paint(t,e)||s},Ze=t=>{const{top:e,left:n}=t.getBoundingClientRect(),{innerWidth:o,innerHeight:i}=window,s=-n,a=-e,r=o-n,d=i-e;return{top:e,left:n,minX:s,minY:a,maxX:r,maxY:d}},tn=t=>{let e=new Set;return o=>{const i=o.map(s=>s.id);(e.size!==i.length||i.some(s=>!e.has(s)))&&t.set(i),e=new Set(i)}},Mt=(t,e,n,o)=>{const{store:i,selection:s,hover:a}=e;let r,d,f;const g=tn(n),u=V=>{const{x:T,y:k}=t.getBoundingClientRect(),y=i.getAt(V.clientX-T,V.clientY-k,!1,d);y?a.current!==y.id&&(t.classList.add("hovered"),a.set(y.id)):a.current&&(t.classList.remove("hovered"),a.set(null))};t.addEventListener("pointermove",u);const h=(V=!1)=>{f&&f.clear();const T=Ze(t),{minX:k,minY:y,maxX:w,maxY:v}=T,C=d?i.getIntersecting(k,y,w,v).filter(({annotation:B})=>d(B)):i.getIntersecting(k,y,w,v),_=s.selected.map(({id:B})=>B),R=C.map(({annotation:B,rects:H})=>{const et=_.includes(B.id),xo=B.id===a.current;return{annotation:B,rects:H,state:{selected:et,hovered:xo}}});o.redraw(R,T,r,f,V),setTimeout(()=>g(C.map(({annotation:B})=>B)),1)},E=V=>{f=V,h()},b=V=>{r=V,h()},p=V=>{d=V,h(!1)},A=()=>h();i.observe(A);const c=s.subscribe(()=>h()),l=a.subscribe(()=>h()),m=()=>h(!0);document.addEventListener("scroll",m,{capture:!0,passive:!0});const S=At(()=>{i.recalculatePositions(),f&&f.reset(),h()});window.addEventListener("resize",S);const x=new ResizeObserver(S);x.observe(t);const L={attributes:!0,childList:!0,subtree:!0},M=new MutationObserver(V=>{V.every(k=>k.target===t||t.contains(k.target))||h(!0)});return M.observe(document.body,L),{destroy:()=>{t.removeEventListener("pointermove",u),o.destroy(),i.unobserve(A),c(),l(),document.removeEventListener("scroll",m),window.removeEventListener("resize",S),x.disconnect(),M.disconnect()},redraw:h,setStyle:b,setFilter:p,setPainter:E,setVisible:o.setVisible}},en=()=>{const t=document.createElement("canvas");return t.width=window.innerWidth,t.height=window.innerHeight,t.className="r6o-canvas-highlight-layer bg",t},nn=(t,e)=>{t.width=window.innerWidth,t.height=window.innerHeight},on=t=>{t.classList.add("r6o-annotatable");const e=en(),n=e.getContext("2d");document.body.appendChild(e);const o=(r,d,f,g)=>requestAnimationFrame(()=>{const{width:u,height:h}=e;n.clearRect(-.5,-.5,u+1,h+1),g&&g.clear();const{top:E,left:b}=d;[...r].sort((A,c)=>{const{annotation:{target:{created:l}}}=A,{annotation:{target:{created:m}}}=c;return l.getTime()-m.getTime()}).forEach(A=>{var S;const c=f?typeof f=="function"?f(A.annotation,A.state):f:(S=A.state)!=null&&S.selected?ct:q,l=g&&g.paint(A,d)||c,m=A.rects.map(({x,y:L,width:M,height:N})=>({x:x+b,y:L+E,width:M,height:N}));if(n.fillStyle=l.fill,n.globalAlpha=l.fillOpacity||1,m.forEach(({x,y:L,width:M,height:N})=>n.fillRect(x,L,M,N)),l.underlineColor){n.globalAlpha=1,n.strokeStyle=l.underlineColor,n.lineWidth=l.underlineThickness??1;const x=l.underlineOffset??0;m.forEach(({x:L,y:M,width:N,height:V})=>{n.beginPath(),n.moveTo(L,M+V+x),n.lineTo(L+N,M+V+x),n.stroke()})}})}),i=At(()=>{nn(e)});return window.addEventListener("resize",i),{destroy:()=>{e.remove(),window.removeEventListener("resize",i)},setVisible:r=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},re=(t,e,n)=>Mt(t,e,n,on(t));var sn={grad:.9,turn:360,rad:360/(2*Math.PI)},G=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},Y=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},$=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},ae=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},le=function(t){return{r:$(t.r,0,255),g:$(t.g,0,255),b:$(t.b,0,255),a:$(t.a)}},kt=function(t){return{r:Y(t.r),g:Y(t.g),b:Y(t.b),a:Y(t.a,3)}},rn=/^#([0-9a-f]{3,8})$/i,xt=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},ce=function(t){var e=t.r,n=t.g,o=t.b,i=t.a,s=Math.max(e,n,o),a=s-Math.min(e,n,o),r=a?s===e?(n-o)/a:s===n?2+(o-e)/a:4+(e-n)/a:0;return{h:60*(r<0?r+6:r),s:s?a/s*100:0,v:s/255*100,a:i}},de=function(t){var e=t.h,n=t.s,o=t.v,i=t.a;e=e/360*6,n/=100,o/=100;var s=Math.floor(e),a=o*(1-n),r=o*(1-(e-s)*n),d=o*(1-(1-e+s)*n),f=s%6;return{r:255*[o,r,a,a,d,o][f],g:255*[d,o,o,r,a,a][f],b:255*[a,a,d,o,o,r][f],a:i}},ue=function(t){return{h:ae(t.h),s:$(t.s,0,100),l:$(t.l,0,100),a:$(t.a)}},fe=function(t){return{h:Y(t.h),s:Y(t.s),l:Y(t.l),a:Y(t.a,3)}},he=function(t){return de((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},dt=function(t){return{h:(e=ce(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},an=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ln=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,dn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ge={string:[[function(t){var e=rn.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?Y(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?Y(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=cn.exec(t)||dn.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:le({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=an.exec(t)||ln.exec(t);if(!e)return null;var n,o,i=ue({h:(n=e[1],o=e[2],o===void 0&&(o="deg"),Number(n)*(sn[o]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return he(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,o=t.b,i=t.a,s=i===void 0?1:i;return G(e)&&G(n)&&G(o)?le({r:Number(e),g:Number(n),b:Number(o),a:Number(s)}):null},"rgb"],[function(t){var e=t.h,n=t.s,o=t.l,i=t.a,s=i===void 0?1:i;if(!G(e)||!G(n)||!G(o))return null;var a=ue({h:Number(e),s:Number(n),l:Number(o),a:Number(s)});return he(a)},"hsl"],[function(t){var e=t.h,n=t.s,o=t.v,i=t.a,s=i===void 0?1:i;if(!G(e)||!G(n)||!G(o))return null;var a=(function(r){return{h:ae(r.h),s:$(r.s,0,100),v:$(r.v,0,100),a:$(r.a)}})({h:Number(e),s:Number(n),v:Number(o),a:Number(s)});return de(a)},"hsv"]]},pe=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]},un=function(t){return typeof t=="string"?pe(t.trim(),ge.string):typeof t=="object"&&t!==null?pe(t,ge.object):[null,void 0]},Bt=function(t,e){var n=dt(t);return{h:n.h,s:$(n.s+100*e,0,100),l:n.l,a:n.a}},It=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},me=function(t,e){var n=dt(t);return{h:n.h,s:n.s,l:$(n.l+100*e,0,100),a:n.a}},ye=(function(){function t(e){this.parsed=un(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 Y(It(this.rgba),2)},t.prototype.isDark=function(){return It(this.rgba)<.5},t.prototype.isLight=function(){return It(this.rgba)>=.5},t.prototype.toHex=function(){return e=kt(this.rgba),n=e.r,o=e.g,i=e.b,a=(s=e.a)<1?xt(Y(255*s)):"","#"+xt(n)+xt(o)+xt(i)+a;var e,n,o,i,s,a},t.prototype.toRgb=function(){return kt(this.rgba)},t.prototype.toRgbString=function(){return e=kt(this.rgba),n=e.r,o=e.g,i=e.b,(s=e.a)<1?"rgba("+n+", "+o+", "+i+", "+s+")":"rgb("+n+", "+o+", "+i+")";var e,n,o,i,s},t.prototype.toHsl=function(){return fe(dt(this.rgba))},t.prototype.toHslString=function(){return e=fe(dt(this.rgba)),n=e.h,o=e.s,i=e.l,(s=e.a)<1?"hsla("+n+", "+o+"%, "+i+"%, "+s+")":"hsl("+n+", "+o+"%, "+i+"%)";var e,n,o,i,s},t.prototype.toHsv=function(){return e=ce(this.rgba),{h:Y(e.h),s:Y(e.s),v:Y(e.v),a:Y(e.a,3)};var e},t.prototype.invert=function(){return z({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),z(Bt(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),z(Bt(this.rgba,-e))},t.prototype.grayscale=function(){return z(Bt(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),z(me(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),z(me(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"?z({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):Y(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=dt(this.rgba);return typeof e=="number"?z({h:e,s:n.s,l:n.l,a:n.a}):Y(n.h)},t.prototype.isEqual=function(e){return this.toHex()===z(e).toHex()},t})(),z=function(t){return t instanceof ye?t:new ye(t)};const fn=t=>[`background-color:${z((t==null?void 0:t.fill)||q.fill).alpha((t==null?void 0:t.fillOpacity)===void 0?q.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(";"),be=()=>{const t=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(t);let e=new Set;return{destroy:()=>{CSS.highlights.clear(),t.remove()},setVisible:s=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(s,a,r,d)=>{d&&d.clear();const f=new Set(s.map(u=>u.annotation.id));Array.from(e).filter(u=>!f.has(u));const g=s.map(u=>{var b;const h=r?typeof r=="function"?r(u.annotation,u.state):r:(b=u.state)!=null&&b.selected?ct:q,E=d&&d.paint(u,a)||h;return`::highlight(_${u.annotation.id}) { ${fn(E)} }`});t.innerHTML=g.join(`
|
|
2
|
-
`),CSS.highlights.clear(),s.forEach(({annotation:u})=>{const h=u.target.selector.map(b=>b.range),E=new Highlight(...h);CSS.highlights.set(`_${u.id}`,E)}),e=f}}},we=(t,e,n)=>Mt(t,e,n,be());var Ae=Object.prototype.hasOwnProperty;function _t(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--&&_t(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Ae.call(t,n)&&++o&&!Ae.call(e,n)||!(n in e)||!_t(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}const hn=(t,e)=>{const n=(s,a)=>s.x<=a.x+a.width&&s.x+s.width>=a.x&&s.y<=a.y+a.height&&s.y+s.height>=a.y,o=s=>s.rects.reduce((a,r)=>a+r.width,0),i=e.filter(({rects:s})=>s.some(a=>n(t,a)));return i.sort((s,a)=>o(a)-o(s)),i.findIndex(s=>s.rects.includes(t))},gn=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,r,d,f,g)=>{const h=!(_t(n,a)&&g);if(!f&&!h)return;h&&(e.innerHTML=""),[...a].sort((b,p)=>{const{annotation:{target:{created:A}}}=b,{annotation:{target:{created:c}}}=p;return A&&c?A.getTime()-c.getTime():0}).forEach(b=>{b.rects.map(p=>{const A=hn(p,a),c=se(b,r,d,f,A);if(h){const l=document.createElement("span");l.className="r6o-annotation",l.dataset.annotation=b.annotation.id,l.style.left=`${p.x}px`,l.style.top=`${p.y}px`,l.style.width=`${p.width}px`,l.style.height=`${p.height}px`,l.style.backgroundColor=z((c==null?void 0:c.fill)||q.fill).alpha((c==null?void 0:c.fillOpacity)===void 0?q.fillOpacity:c.fillOpacity).toHex(),c.underlineStyle&&(l.style.borderStyle=c.underlineStyle),c.underlineColor&&(l.style.borderColor=c.underlineColor),c.underlineThickness&&(l.style.borderBottomWidth=`${c.underlineThickness}px`),c.underlineOffset&&(l.style.paddingBottom=`${c.underlineOffset}px`),e.appendChild(l)}})}),n=a},setVisible:a=>{a?e.classList.remove("hidden"):e.classList.add("hidden")}}},ve=(t,e,n)=>Mt(t,e,n,gn(t)),K=[];for(let t=0;t<256;++t)K.push((t+256).toString(16).slice(1));function pn(t,e=0){return(K[t[e+0]]+K[t[e+1]]+K[t[e+2]]+K[t[e+3]]+"-"+K[t[e+4]]+K[t[e+5]]+"-"+K[t[e+6]]+K[t[e+7]]+"-"+K[t[e+8]]+K[t[e+9]]+"-"+K[t[e+10]]+K[t[e+11]]+K[t[e+12]]+K[t[e+13]]+K[t[e+14]]+K[t[e+15]]).toLowerCase()}let Nt;const mn=new Uint8Array(16);function yn(){if(!Nt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Nt=crypto.getRandomValues.bind(crypto)}return Nt(mn)}const Ee={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function xe(t,e,n){var i;if(Ee.randomUUID&&!t)return Ee.randomUUID();t=t||{};const o=t.random??((i=t.rng)==null?void 0:i.call(t))??yn();if(o.length<16)throw new Error("Random bytes length must be >= 16");return o[6]=o[6]&15|64,o[8]=o[8]&63|128,pn(o)}var Se=Object.prototype.hasOwnProperty;function tt(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--&&tt(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Se.call(t,n)&&++o&&!Se.call(e,n)||!(n in e)||!tt(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}function Ut(){}function bn(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}const ot=[];function Dt(t,e=Ut){let n;const o=new Set;function i(r){if(bn(t,r)&&(t=r,n)){const d=!ot.length;for(const f of o)f[1](),ot.push(f,t);if(d){for(let f=0;f<ot.length;f+=2)ot[f][0](ot[f+1]);ot.length=0}}}function s(r){i(r(t))}function a(r,d=Ut){const f=[r,d];return o.add(f),o.size===1&&(n=e(i,s)||Ut),r(t),()=>{o.delete(f),o.size===0&&n&&(n(),n=null)}}return{set:i,update:s,subscribe:a}}const wn=t=>{const{subscribe:e,set:n}=Dt();let o;return e(i=>o=i),t.observe(({changes:i})=>{if(o){(i.deleted||[]).some(a=>a.id===o)&&n(void 0);const s=(i.updated||[]).find(({oldValue:a})=>a.id===o);s&&n(s.newValue.id)}}),{get current(){return o},subscribe:e,set:n}};var Ce=(t=>(t.EDIT="EDIT",t.SELECT="SELECT",t.NONE="NONE",t))(Ce||{});const St={selected:[]},An=(t,e,n)=>{const{subscribe:o,set:i}=Dt(St);let s=e,a=St;o(p=>a=p);const r=()=>{tt(a,St)||i(St)},d=()=>{var p;return((p=a.selected)==null?void 0:p.length)===0},f=p=>{if(d())return!1;const A=typeof p=="string"?p:p.id;return a.selected.some(c=>c.id===A)},g=(p,A)=>{let c;if(Array.isArray(p)){if(c=p.map(m=>t.getAnnotation(m)).filter(Boolean),c.length<p.length){console.warn("Invalid selection: "+p.filter(m=>!c.some(S=>S.id===m)));return}}else{const m=t.getAnnotation(p);if(!m){console.warn("Invalid selection: "+p);return}c=[m]}const l=c.reduce((m,S)=>{const x=b(S);return x==="EDIT"?[...m,{id:S.id,editable:!0}]:x==="SELECT"?[...m,{id:S.id}]:m},[]);i({selected:l,event:A})},u=(p,A)=>{const c=Array.isArray(p)?p:[p],l=c.map(m=>t.getAnnotation(m)).filter(m=>!!m);i({selected:l.map(m=>{const S=A===void 0?b(m)==="EDIT":A;return{id:m.id,editable:S}})}),l.length!==c.length&&console.warn("Invalid selection",p)},h=p=>{if(d())return!1;const{selected:A}=a;A.some(({id:c})=>p.includes(c))&&i({selected:A.filter(({id:c})=>!p.includes(c))})},E=p=>{s=p,u(a.selected.map(({id:A})=>A))},b=p=>vn(p,s,n);return t.observe(({changes:p})=>h((p.deleted||[]).map(A=>A.id))),{get event(){return a?a.event:null},get selected(){return a?[...a.selected]:null},get userSelectAction(){return s},clear:r,evalSelectAction:b,isEmpty:d,isSelected:f,setSelected:u,setUserSelectAction:E,subscribe:o,userSelect:g}},vn=(t,e,n)=>{const o=n?n.serialize(t):t;return typeof e=="function"?e(o):e||"EDIT"},X=[];for(let t=0;t<256;++t)X.push((t+256).toString(16).slice(1));function En(t,e=0){return(X[t[e+0]]+X[t[e+1]]+X[t[e+2]]+X[t[e+3]]+"-"+X[t[e+4]]+X[t[e+5]]+"-"+X[t[e+6]]+X[t[e+7]]+"-"+X[t[e+8]]+X[t[e+9]]+"-"+X[t[e+10]]+X[t[e+11]]+X[t[e+12]]+X[t[e+13]]+X[t[e+14]]+X[t[e+15]]).toLowerCase()}let Vt;const xn=new Uint8Array(16);function Sn(){if(!Vt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Vt=crypto.getRandomValues.bind(crypto)}return Vt(xn)}const Cn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Le={randomUUID:Cn};function Te(t,e,n){var o;if(Le.randomUUID&&!t)return Le.randomUUID();t=t||{};const i=t.random??((o=t.rng)==null?void 0:o.call(t))??Sn();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,En(i)}const Yt=t=>{const e=n=>{const o={...n};return n.created&&typeof n.created=="string"&&(o.created=new Date(n.created)),n.updated&&typeof n.updated=="string"&&(o.updated=new Date(n.updated)),o};return{...t,bodies:(t.bodies||[]).map(e),target:e(t.target)}},Ln=(t,e,n,o)=>({id:Te(),annotation:typeof t=="string"?t:t.id,created:n||new Date,creator:o,...e}),Tn=(t,e)=>{const n=new Set(t.bodies.map(o=>o.id));return e.bodies.filter(o=>!n.has(o.id))},On=(t,e)=>{const n=new Set(e.bodies.map(o=>o.id));return t.bodies.filter(o=>!n.has(o.id))},Rn=(t,e)=>e.bodies.map(n=>{const o=t.bodies.find(i=>i.id===n.id);return{newBody:n,oldBody:o&&!tt(o,n)?o:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:o})=>({oldBody:n,newBody:o})),Mn=(t,e)=>!tt(t.target,e.target),Oe=(t,e)=>{const n=Tn(t,e),o=On(t,e),i=Rn(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:Mn(t,e)?{oldTarget:t.target,newTarget:e.target}:void 0}};var I=(t=>(t.LOCAL="LOCAL",t.REMOTE="REMOTE",t.SILENT="SILENT",t))(I||{});const kn=(t,e)=>{var n,o;const{changes:i,origin:s}=e;if(!(t.options.origin?t.options.origin===s:s!=="SILENT"))return!1;if(t.options.ignore){const{ignore:a}=t.options,r=d=>d&&d.length>0;if(!(r(i.created)||r(i.deleted))){const d=(n=i.updated)==null?void 0:n.some(g=>r(g.bodiesCreated)||r(g.bodiesDeleted)||r(g.bodiesUpdated)),f=(o=i.updated)==null?void 0:o.some(g=>g.targetUpdated);if(a==="BODY_ONLY"&&d&&!f||a==="TARGET_ONLY"&&f&&!d)return!1}}if(t.options.annotations){const a=new Set([...(i.created||[]).map(r=>r.id),...(i.deleted||[]).map(r=>r.id),...(i.updated||[]).map(({oldValue:r})=>r.id)]);return!!(Array.isArray(t.options.annotations)?t.options.annotations:[t.options.annotations]).find(r=>a.has(r))}else return!0},Bn=(t,e)=>{const n=new Set((t.created||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({newValue:u})=>u.id)),i=new Set((e.created||[]).map(u=>u.id)),s=new Set((e.deleted||[]).map(u=>u.id)),a=new Set((e.updated||[]).map(({oldValue:u})=>u.id)),r=new Set((e.updated||[]).filter(({oldValue:u})=>n.has(u.id)||o.has(u.id)).map(({oldValue:u})=>u.id)),d=[...(t.created||[]).filter(u=>!s.has(u.id)).map(u=>a.has(u.id)?e.updated.find(({oldValue:h})=>h.id===u.id).newValue:u),...e.created||[]],f=[...(t.deleted||[]).filter(u=>!i.has(u.id)),...(e.deleted||[]).filter(u=>!n.has(u.id))],g=[...(t.updated||[]).filter(({newValue:u})=>!s.has(u.id)).map(u=>{const{oldValue:h,newValue:E}=u;if(a.has(E.id)){const b=e.updated.find(p=>p.oldValue.id===E.id).newValue;return Oe(h,b)}else return u}),...(e.updated||[]).filter(({oldValue:u})=>!r.has(u.id))];return{created:d,deleted:f,updated:g}},Ct=t=>{const e=t.id===void 0?Te():t.id;return{...t,id:e,bodies:t.bodies===void 0?[]:t.bodies.map(n=>({...n,annotation:e})),target:{...t.target,annotation:e}}},In=t=>t.id!==void 0,_n=()=>{const t=new Map,e=new Map,n=[],o=(y,w={})=>{n.push({onChange:y,options:w})},i=y=>{const w=n.findIndex(v=>v.onChange==y);w>-1&&n.splice(w,1)},s=(y,w)=>{const v={origin:y,changes:{created:w.created||[],updated:w.updated||[],deleted:w.deleted||[]},state:[...t.values()]};n.forEach(C=>{kn(C,v)&&C.onChange(v)})},a=(y,w=I.LOCAL)=>{if(y.id&&t.get(y.id))throw Error(`Cannot add annotation ${y.id} - exists already`);{const v=Ct(y);t.set(v.id,v),v.bodies.forEach(C=>e.set(C.id,v.id)),s(w,{created:[v]})}},r=(y,w)=>{const v=Ct(typeof y=="string"?w:y),C=typeof y=="string"?y:y.id,_=C&&t.get(C);if(_){const R=Oe(_,v);return C===v.id?t.set(C,v):(t.delete(C),t.set(v.id,v)),_.bodies.forEach(B=>e.delete(B.id)),v.bodies.forEach(B=>e.set(B.id,v.id)),R}else console.warn(`Cannot update annotation ${C} - does not exist`)},d=(y,w=I.LOCAL,v=I.LOCAL)=>{const C=In(w)?v:w,_=r(y,w);_&&s(C,{updated:[_]})},f=(y,w=I.LOCAL)=>{t.get(y.id)?d(y,w):a(y,w)},g=(y,w=I.LOCAL)=>{const v=y.reduce((C,_)=>{const R=r(_);return R?[...C,R]:C},[]);v.length>0&&s(w,{updated:v})},u=(y,w=I.LOCAL)=>{const v=y.map(Ct),{toAdd:C,toUpdate:_}=v.reduce((B,H)=>t.get(H.id)?{...B,toUpdate:[...B.toUpdate,H]}:{...B,toAdd:[...B.toAdd,H]},{toAdd:[],toUpdate:[]}),R=_.map(B=>r(B,w)).filter(Boolean);C.forEach(B=>{t.set(B.id,B),B.bodies.forEach(H=>e.set(H.id,B.id))}),s(w,{created:C,updated:R})},h=(y,w=I.LOCAL)=>{const v=t.get(y.annotation);if(v){const C={...v,bodies:[...v.bodies,y]};t.set(v.id,C),e.set(y.id,C.id),s(w,{updated:[{oldValue:v,newValue:C,bodiesCreated:[y]}]})}else console.warn(`Attempt to add body to missing annotation: ${y.annotation}`)},E=()=>[...t.values()],b=(y=I.LOCAL)=>{const w=[...t.values()];t.clear(),e.clear(),s(y,{deleted:w})},p=(y,w=!0,v=I.LOCAL)=>{const C=y.map(Ct);if(w){const _=[...t.values()];t.clear(),e.clear(),C.forEach(R=>{t.set(R.id,R),R.bodies.forEach(B=>e.set(B.id,R.id))}),s(v,{created:C,deleted:_})}else{const _=y.reduce((R,B)=>{const H=B.id&&t.get(B.id);return H?[...R,H]:R},[]);if(_.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${_.map(R=>R.id).join(", ")}`);C.forEach(R=>{t.set(R.id,R),R.bodies.forEach(B=>e.set(B.id,R.id))}),s(v,{created:C})}},A=y=>{const w=typeof y=="string"?y:y.id,v=t.get(w);if(v)return t.delete(w),v.bodies.forEach(C=>e.delete(C.id)),v;console.warn(`Attempt to delete missing annotation: ${w}`)},c=(y,w=I.LOCAL)=>{const v=A(y);v&&s(w,{deleted:[v]})},l=(y,w=I.LOCAL)=>{const v=y.reduce((C,_)=>{const R=A(_);return R?[...C,R]:C},[]);v.length>0&&s(w,{deleted:v})},m=y=>{const w=t.get(y.annotation);if(w){const v=w.bodies.find(C=>C.id===y.id);if(v){e.delete(v.id);const C={...w,bodies:w.bodies.filter(_=>_.id!==y.id)};return t.set(w.id,C),{oldValue:w,newValue:C,bodiesDeleted:[v]}}else console.warn(`Attempt to delete missing body ${y.id} from annotation ${y.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${y.annotation}`)},S=(y,w=I.LOCAL)=>{const v=m(y);v&&s(w,{updated:[v]})},x=(y,w=I.LOCAL)=>{const v=y.map(C=>m(C)).filter(Boolean);v.length>0&&s(w,{updated:v})},L=y=>{const w=t.get(y);return w?{...w}:void 0},M=y=>{const w=e.get(y);if(w){const v=L(w).bodies.find(C=>C.id===y);if(v)return v;console.error(`Store integrity error: body ${y} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${y}`)},N=(y,w)=>{if(y.annotation!==w.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const v=t.get(y.annotation);if(v){const C=v.bodies.find(R=>R.id===y.id),_={...v,bodies:v.bodies.map(R=>R.id===C.id?w:R)};return t.set(v.id,_),C.id!==w.id&&(e.delete(C.id),e.set(w.id,_.id)),{oldValue:v,newValue:_,bodiesUpdated:[{oldBody:C,newBody:w}]}}else console.warn(`Attempt to add body to missing annotation ${y.annotation}`)},V=(y,w,v=I.LOCAL)=>{const C=N(y,w);C&&s(v,{updated:[C]})},T=(y,w=I.LOCAL)=>{const v=y.map(C=>N({id:C.id,annotation:C.annotation},C)).filter(Boolean);s(w,{updated:v})},k=y=>{const w=t.get(y.annotation);if(w){const v={...w,target:{...w.target,...y}};return t.set(w.id,v),{oldValue:w,newValue:v,targetUpdated:{oldTarget:w.target,newTarget:y}}}else console.warn(`Attempt to update target on missing annotation: ${y.annotation}`)};return{addAnnotation:a,addBody:h,all:E,bulkAddAnnotations:p,bulkDeleteAnnotations:l,bulkDeleteBodies:x,bulkUpdateAnnotations:g,bulkUpdateBodies:T,bulkUpdateTargets:(y,w=I.LOCAL)=>{const v=y.map(C=>k(C)).filter(Boolean);v.length>0&&s(w,{updated:v})},bulkUpsertAnnotations:u,clear:b,deleteAnnotation:c,deleteBody:S,getAnnotation:L,getBody:M,observe:o,unobserve:i,updateAnnotation:d,updateBody:V,updateTarget:(y,w=I.LOCAL)=>{const v=k(y);v&&s(w,{updated:[v]})},upsertAnnotation:f}};let Nn=()=>({emit(t,...e){for(let n=this.events[t]||[],o=0,i=n.length;o<i;o++)n[o](...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 Un=250,Dn=(t,e)=>{const n=Nn(),o=[];let i=-1,s=!1,a=0;const r=b=>{if(!s){const{changes:p}=b,A=performance.now();if(A-a>Un)o.splice(i+1),o.push(p),i=o.length-1;else{const c=o.length-1;o[c]=Bn(o[c],p)}a=A}s=!1};t.observe(r,{origin:I.LOCAL});const d=b=>b&&b.length>0&&t.bulkDeleteAnnotations(b),f=b=>b&&b.length>0&&t.bulkAddAnnotations(b,!1),g=b=>b&&b.length>0&&t.bulkUpdateAnnotations(b.map(({oldValue:p})=>p)),u=b=>b&&b.length>0&&t.bulkUpdateAnnotations(b.map(({newValue:p})=>p)),h=b=>b&&b.length>0&&t.bulkAddAnnotations(b,!1),E=b=>b&&b.length>0&&t.bulkDeleteAnnotations(b);return{canRedo:()=>o.length-1>i,canUndo:()=>i>-1,destroy:()=>t.unobserve(r),getHistory:()=>({changes:[...o],pointer:i}),on:(b,p)=>n.on(b,p),redo:()=>{if(o.length-1>i){s=!0;const{created:b,updated:p,deleted:A}=o[i+1];f(b),u(p),E(A),n.emit("redo",o[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:b,updated:p,deleted:A}=o[i];d(b),g(p),h(A),n.emit("undo",o[i]),i-=1}}}},Vn=()=>{const{subscribe:t,set:e}=Dt([]);return{subscribe:t,set:e}},Yn=(t,e,n,o)=>{const{hover:i,selection:s,store:a,viewport:r}=t,d=new Map;let f=[],g;const u=(p,A)=>{d.has(p)?d.get(p).push(A):d.set(p,[A])},h=(p,A)=>{const c=d.get(p);if(c){const l=c.indexOf(A);l!==-1&&c.splice(l,1)}},E=(p,A,c)=>{d.has(p)&&setTimeout(()=>{d.get(p).forEach(l=>{if(n){const m=Array.isArray(A)?A.map(x=>n.serialize(x)):n.serialize(A),S=c?c instanceof PointerEvent?c:n.serialize(c):void 0;l(m,S)}else l(A,c)})},1)};s.subscribe(({selected:p})=>{if(!(f.length===0&&p.length===0)){if(f.length===0&&p.length>0)f=p.map(({id:A})=>a.getAnnotation(A));else if(f.length>0&&p.length===0)f.forEach(A=>{const c=a.getAnnotation(A.id);c&&!tt(c,A)&&E("updateAnnotation",c,A)}),f=[];else{const A=new Set(f.map(l=>l.id)),c=new Set(p.map(({id:l})=>l));f.filter(l=>!c.has(l.id)).forEach(l=>{const m=a.getAnnotation(l.id);m&&!tt(m,l)&&E("updateAnnotation",m,l)}),f=[...f.filter(l=>c.has(l.id)),...p.filter(({id:l})=>!A.has(l)).map(({id:l})=>a.getAnnotation(l))]}E("selectionChanged",f)}}),i.subscribe(p=>{!g&&p?E("mouseEnterAnnotation",a.getAnnotation(p)):g&&!p?E("mouseLeaveAnnotation",a.getAnnotation(g)):g&&p&&(E("mouseLeaveAnnotation",a.getAnnotation(g)),E("mouseEnterAnnotation",a.getAnnotation(p))),g=p}),r==null||r.subscribe(p=>E("viewportIntersect",p.map(A=>a.getAnnotation(A)))),a.observe(p=>{const{created:A,deleted:c}=p.changes;(A||[]).forEach(l=>E("createAnnotation",l)),(c||[]).forEach(l=>E("deleteAnnotation",l)),(p.changes.updated||[]).filter(l=>[...l.bodiesCreated||[],...l.bodiesDeleted||[],...l.bodiesUpdated||[]].length>0).forEach(({oldValue:l,newValue:m})=>{const S=f.find(x=>x.id===l.id)||l;f=f.map(x=>x.id===l.id?m:x),E("updateAnnotation",m,S)})},{origin:I.LOCAL}),a.observe(p=>{if(f){const A=new Set(f.map(l=>l.id)),c=(p.changes.updated||[]).filter(({newValue:l})=>A.has(l.id)).map(({newValue:l})=>l);c.length>0&&(f=f.map(l=>c.find(S=>S.id===l.id)||l))}},{origin:I.REMOTE});const b=p=>A=>{const{updated:c}=A;p?(c||[]).forEach(l=>E("updateAnnotation",l.oldValue,l.newValue)):(c||[]).forEach(l=>E("updateAnnotation",l.newValue,l.oldValue))};return e.on("undo",b(!0)),e.on("redo",b(!1)),{on:u,off:h,emit:E}},Kn=t=>e=>e.reduce((n,o)=>{const{parsed:i,error:s}=t.parse(o);return s?{parsed:n.parsed,failed:[...n.failed,o]}:i?{parsed:[...n.parsed,i],failed:n.failed}:{...n}},{parsed:[],failed:[]}),Xn=(t,e,n)=>{const{store:o,selection:i}=t,s=c=>{if(n){const{parsed:l,error:m}=n.parse(c);l?o.addAnnotation(l,I.REMOTE):console.error(m)}else o.addAnnotation(Yt(c),I.REMOTE)},a=()=>i.clear(),r=()=>o.clear(),d=c=>{const l=o.getAnnotation(c);return n&&l?n.serialize(l):l},f=()=>n?o.all().map(n.serialize):o.all(),g=()=>{var c;const l=(((c=i.selected)==null?void 0:c.map(m=>m.id))||[]).map(m=>o.getAnnotation(m)).filter(Boolean);return n?l.map(n.serialize):l},u=(c,l=!0)=>fetch(c).then(m=>m.json()).then(m=>(E(m,l),m)),h=c=>{if(typeof c=="string"){const l=o.getAnnotation(c);if(o.deleteAnnotation(c),l)return n?n.serialize(l):l}else{const l=n?n.parse(c).parsed:c;if(l)return o.deleteAnnotation(l),c}},E=(c,l=!0)=>{if(n){const m=n.parseAll||Kn(n),{parsed:S,failed:x}=m(c);x.length>0&&console.warn(`Discarded ${x.length} invalid annotations`,x),o.bulkAddAnnotations(S,l,I.REMOTE)}else o.bulkAddAnnotations(c.map(Yt),l,I.REMOTE)},b=(c,l)=>{c?i.setSelected(c,l):i.clear()},p=c=>{i.clear(),i.setUserSelectAction(c)},A=c=>{if(n){const l=n.parse(c).parsed,m=n.serialize(o.getAnnotation(l.id));return o.updateAnnotation(l),m}else{const l=o.getAnnotation(c.id);return o.updateAnnotation(Yt(c)),l}};return{addAnnotation:s,cancelSelected:a,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:r,getAnnotationById:d,getAnnotations:f,getHistory:e.getHistory,getSelected:g,loadAnnotations:u,redo:e.redo,removeAnnotation:h,setAnnotations:E,setSelected:b,setUserSelectAction:p,undo:e.undo,updateAnnotation:A}},Pn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Hn=t=>crypto.getRandomValues(new Uint8Array(t)),$n=(t,e,n)=>{let o=(2<<Math.log2(t.length-1))-1,i=-~(1.6*o*e/t.length);return(s=e)=>{let a="";for(;;){let r=n(i),d=i|0;for(;d--;)if(a+=t[r[d]&o]||"",a.length>=s)return a}}},jn=(t,e=21)=>$n(t,e|0,Hn),zn=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Pn[n[t]&63];return e};const Fn=()=>({isGuest:!0,id:jn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Wn=t=>{const e=JSON.stringify(t);let n=0;for(let o=0,i=e.length;o<i;o++){let s=e.charCodeAt(o);n=(n<<5)-n+s,n|=0}return`${n}`},Re=t=>t?typeof t=="object"?{...t}:t:void 0,qn=(t,e)=>(Array.isArray(t)?t:[t]).map(n=>{const{id:o,type:i,purpose:s,value:a,created:r,modified:d,creator:f,...g}=n;return{id:o||`temp-${Wn(n)}`,annotation:e,type:i,purpose:s,value:a,creator:Re(f),created:r?new Date(r):void 0,updated:d?new Date(d):void 0,...g}}),Gn=t=>t.map(e=>{var n;const{annotation:o,created:i,updated:s,...a}=e,r={...a,created:i==null?void 0:i.toISOString(),modified:s==null?void 0:s.toISOString()};return(n=r.id)!=null&&n.startsWith("temp-")&&delete r.id,r});zn();const Qn=(t,e)=>({parse:n=>Me(n),serialize:n=>ke(n,t,e)}),Jn=t=>t.quote!==void 0&&t.start!==void 0&&t.end!==void 0,Zn=t=>{const{id:e,creator:n,created:o,modified:i,target:s}=t,a=Array.isArray(s)?s:[s];if(a.length===0)return{error:Error(`No targets found for annotation: ${t.id}`)};const r={creator:Re(n),created:o?new Date(o):void 0,updated:i?new Date(i):void 0,annotation:e,selector:[],styleClass:"styleClass"in a[0]?a[0].styleClass:void 0};for(const d of a){const g=(Array.isArray(d.selector)?d.selector:[d.selector]).reduce((u,h)=>{switch(h.type){case"TextQuoteSelector":u.quote=h.exact;break;case"TextPositionSelector":u.start=h.start,u.end=h.end;break}return u},{});if(Jn(g))r.selector.push({...g,id:d.id,scope:d.scope});else{const u=[g.start?void 0:"TextPositionSelector",g.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${u.join(" and ")} for annotation: ${t.id}`)}}}return{parsed:r}},Me=t=>{const e=t.id||xe(),{creator:n,created:o,modified:i,body:s,...a}=t,r=qn(s,e),d=Zn(t);return"error"in d?{error:d.error}:{parsed:{...a,id:e,bodies:r,target:d.parsed}}},ke=(t,e,n)=>{const{bodies:o,target:i,...s}=t,{selector:a,creator:r,created:d,updated:f,...g}=i,u=a.map(h=>{const{id:E,quote:b,start:p,end:A,range:c}=h,l={type:"TextQuoteSelector",exact:b};if(n){const{prefix:S,suffix:x}=Qt(c,n);l.prefix=S,l.suffix=x}const m={type:"TextPositionSelector",start:p,end:A};return{...g,id:E,scope:"scope"in h?h.scope:void 0,source:e,selector:[l,m]}});return{...s,"@context":"http://www.w3.org/ns/anno.jsonld",id:t.id,type:"Annotation",body:Gn(t.bodies),creator:r,created:d==null?void 0:d.toISOString(),modified:f==null?void 0:f.toISOString(),target:u}};function Be(t,e,n=0,o=t.length-1,i=to){for(;o>n;){if(o-n>600){const d=o-n+1,f=e-n+1,g=Math.log(d),u=.5*Math.exp(2*g/3),h=.5*Math.sqrt(g*u*(d-u)/d)*(f-d/2<0?-1:1),E=Math.max(n,Math.floor(e-f*u/d+h)),b=Math.min(o,Math.floor(e+(d-f)*u/d+h));Be(t,e,E,b,i)}const s=t[e];let a=n,r=o;for(ut(t,n,e),i(t[o],s)>0&&ut(t,n,o);a<r;){for(ut(t,a,r),a++,r--;i(t[a],s)<0;)a++;for(;i(t[r],s)>0;)r--}i(t[n],s)===0?ut(t,n,r):(r++,ut(t,r,o)),r<=e&&(n=r+1),e<=r&&(o=r-1)}}function ut(t,e,n){const o=t[e];t[e]=t[n],t[n]=o}function to(t,e){return t<e?-1:t>e?1:0}class eo{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(!Tt(e,n))return o;const i=this.toBBox,s=[];for(;n;){for(let a=0;a<n.children.length;a++){const r=n.children[a],d=n.leaf?i(r):r;Tt(e,d)&&(n.leaf?o.push(r):Xt(e,d)?this._all(r,o):s.push(r))}n=s.pop()}return o}collides(e){let n=this.data;if(!Tt(e,n))return!1;const o=[];for(;n;){for(let i=0;i<n.children.length;i++){const s=n.children[i],a=n.leaf?this.toBBox(s):s;if(Tt(e,a)){if(n.leaf||Xt(e,a))return!0;o.push(s)}}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=st([]),this}remove(e,n){if(!e)return this;let o=this.data;const i=this.toBBox(e),s=[],a=[];let r,d,f;for(;o||s.length;){if(o||(o=s.pop(),d=s[s.length-1],r=a.pop(),f=!0),o.leaf){const g=no(e,o.children,n);if(g!==-1)return o.children.splice(g,1),s.push(o),this._condense(s),this}!f&&!o.leaf&&Xt(o,i)?(s.push(o),a.push(r),r=0,d=o,o=o.children[0]):d?(r++,o=d.children[r],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 s=o-n+1;let a=this._maxEntries,r;if(s<=a)return r=st(e.slice(n,o+1)),it(r,this.toBBox),r;i||(i=Math.ceil(Math.log(s)/Math.log(a)),a=Math.ceil(s/Math.pow(a,i-1))),r=st([]),r.leaf=!1,r.height=i;const d=Math.ceil(s/a),f=d*Math.ceil(Math.sqrt(a));Ie(e,n,o,f,this.compareMinX);for(let g=n;g<=o;g+=f){const u=Math.min(g+f-1,o);Ie(e,g,u,d,this.compareMinY);for(let h=g;h<=u;h+=d){const E=Math.min(h+d-1,u);r.children.push(this._build(e,h,E,i-1))}}return it(r,this.toBBox),r}_chooseSubtree(e,n,o,i){for(;i.push(n),!(n.leaf||i.length-1===o);){let s=1/0,a=1/0,r;for(let d=0;d<n.children.length;d++){const f=n.children[d],g=Kt(f),u=so(e,f)-g;u<a?(a=u,s=g<s?g:s,r=f):u===a&&g<s&&(s=g,r=f)}n=r||n.children[0]}return n}_insert(e,n,o){const i=o?e:this.toBBox(e),s=[],a=this._chooseSubtree(i,this.data,n,s);for(a.children.push(e),ht(a,i);n>=0&&s[n].children.length>this._maxEntries;)this._split(s,n),n--;this._adjustParentBBoxes(i,s,n)}_split(e,n){const o=e[n],i=o.children.length,s=this._minEntries;this._chooseSplitAxis(o,s,i);const a=this._chooseSplitIndex(o,s,i),r=st(o.children.splice(a,o.children.length-a));r.height=o.height,r.leaf=o.leaf,it(o,this.toBBox),it(r,this.toBBox),n?e[n-1].children.push(r):this._splitRoot(o,r)}_splitRoot(e,n){this.data=st([e,n]),this.data.height=e.height+1,this.data.leaf=!1,it(this.data,this.toBBox)}_chooseSplitIndex(e,n,o){let i,s=1/0,a=1/0;for(let r=n;r<=o-n;r++){const d=ft(e,0,r,this.toBBox),f=ft(e,r,o,this.toBBox),g=ro(d,f),u=Kt(d)+Kt(f);g<s?(s=g,i=r,a=u<a?u:a):g===s&&u<a&&(a=u,i=r)}return i||o-n}_chooseSplitAxis(e,n,o){const i=e.leaf?this.compareMinX:oo,s=e.leaf?this.compareMinY:io,a=this._allDistMargin(e,n,o,i),r=this._allDistMargin(e,n,o,s);a<r&&e.children.sort(i)}_allDistMargin(e,n,o,i){e.children.sort(i);const s=this.toBBox,a=ft(e,0,n,s),r=ft(e,o-n,o,s);let d=Lt(a)+Lt(r);for(let f=n;f<o-n;f++){const g=e.children[f];ht(a,e.leaf?s(g):g),d+=Lt(a)}for(let f=o-n-1;f>=n;f--){const g=e.children[f];ht(r,e.leaf?s(g):g),d+=Lt(r)}return d}_adjustParentBBoxes(e,n,o){for(let i=o;i>=0;i--)ht(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():it(e[n],this.toBBox)}}function no(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 it(t,e){ft(t,0,t.children.length,e,t)}function ft(t,e,n,o,i){i||(i=st(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let s=e;s<n;s++){const a=t.children[s];ht(i,t.leaf?o(a):a)}return i}function ht(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 oo(t,e){return t.minX-e.minX}function io(t,e){return t.minY-e.minY}function Kt(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Lt(t){return t.maxX-t.minX+(t.maxY-t.minY)}function so(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 ro(t,e){const n=Math.max(t.minX,e.minX),o=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,s-o)}function Xt(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Tt(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function st(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ie(t,e,n,o,i){const s=[e,n];for(;s.length;){if(n=s.pop(),e=s.pop(),n-e<=o)continue;const a=e+Math.ceil((n-e)/o/2)*o;Be(t,a,e,n,i),s.push(e,a,a,n)}}const ao=(t,e)=>{const n=new eo,o=new Map,i=(c,l)=>{const m=c.selector.flatMap(x=>{const L=W([x])?x.range:Rt(x,e).range;return Array.from(L.getClientRects())}),S=te(m).map(({left:x,top:L,right:M,bottom:N})=>new DOMRect(x-l.left,L-l.top,M-x,N-L));return S.map(x=>{const{x:L,y:M,width:N,height:V}=x;return{minX:L,minY:M,maxX:L+N,maxY:M+V,annotation:{id:c.annotation,rects:S}}})},s=()=>[...o.values()],a=()=>{n.clear(),o.clear()},r=c=>{const l=i(c,e.getBoundingClientRect());l.length!==0&&(l.forEach(m=>n.insert(m)),o.set(c.annotation,l))},d=c=>{const l=o.get(c.annotation);l&&(l.forEach(m=>n.remove(m)),o.delete(c.annotation))},f=c=>{d(c),r(c)},g=(c,l=!0)=>{l&&a();const m=e.getBoundingClientRect(),S=c.map(L=>({target:L,rects:i(L,m)}));S.forEach(({target:L,rects:M})=>{M.length>0&&o.set(L.annotation,M)});const x=S.flatMap(({rects:L})=>L);n.load(x)},u=(c,l,m=!1)=>{const S=n.search({minX:c,minY:l,maxX:c,maxY:l}),x=L=>L.annotation.rects.reduce((M,N)=>M+N.width*N.height,0);return S.length>0?(S.sort((L,M)=>x(L)-x(M)),m?S.map(L=>L.annotation.id):[S[0].annotation.id]):[]},h=c=>{const l=E(c);if(l.length===0)return;let m=l[0].left,S=l[0].top,x=l[0].right,L=l[0].bottom;for(let M=1;M<l.length;M++){const N=l[M];m=Math.min(m,N.left),S=Math.min(S,N.top),x=Math.max(x,N.right),L=Math.max(L,N.bottom)}return new DOMRect(m,S,x-m,L-S)},E=c=>{const l=o.get(c);return l?l[0].annotation.rects:[]};return{all:s,clear:a,getAt:u,getAnnotationBounds:h,getAnnotationRects:E,getIntersecting:(c,l,m,S)=>{const x=n.search({minX:c,minY:l,maxX:m,maxY:S}),L=new Set(x.map(M=>M.annotation.id));return Array.from(L).map(M=>({annotation:t.getAnnotation(M),rects:E(M)})).filter(M=>!!M.annotation)},insert:r,recalculate:()=>g(t.all().map(c=>c.target),!0),remove:d,set:g,size:()=>n.all().length,update:f}},_e=(t,e)=>{const n=_n(),o=ao(n,t),i=An(n,e.userSelectAction,e.adapter),s=wn(n),a=Vn(),r=(c,l=I.LOCAL)=>{const m=Et(c,t),S=W(m.target.selector);return S&&n.addAnnotation(m,l),S},d=(c,l=!0,m=I.LOCAL)=>{const S=c.map(L=>Et(L,t)),x=S.filter(L=>!W(L.target.selector));return n.bulkAddAnnotations(S,l,m),x},f=(c,l=I.LOCAL)=>{const m=c.map(x=>Et(x,t)),S=m.filter(x=>!W(x.target.selector));return m.forEach(x=>{n.getAnnotation(x.id)?n.updateAnnotation(x,l):n.addAnnotation(x,l)}),S},g=(c,l=I.LOCAL)=>{const m=lt(c,t);n.updateTarget(m,l)},u=(c,l=I.LOCAL)=>{const m=c.map(S=>lt(S,t));n.bulkUpdateTargets(m,l)};function h(c,l,m,S){const x=m||!!S,L=o.getAt(c,l,x).map(N=>n.getAnnotation(N)),M=S?L.filter(S):L;if(M.length!==0)return m?M:M[0]}const E=c=>{if(o.getAnnotationRects(c).length!==0)return o.getAnnotationBounds(c)},b=(c,l,m,S)=>o.getIntersecting(c,l,m,S),p=c=>o.getAnnotationRects(c),A=()=>o.recalculate();return n.observe(({changes:c})=>{const l=(c.deleted||[]).filter(x=>W(x.target.selector)),m=(c.created||[]).filter(x=>W(x.target.selector)),S=(c.updated||[]).filter(x=>W(x.newValue.target.selector));(l==null?void 0:l.length)>0&&l.forEach(x=>o.remove(x.target)),m.length>0&&o.set(m.map(x=>x.target),!1),(S==null?void 0:S.length)>0&&S.forEach(({newValue:x})=>o.update(x.target))}),{store:{...n,addAnnotation:r,bulkAddAnnotations:d,bulkUpdateTargets:u,bulkUpsertAnnotations:f,getAnnotationBounds:E,getAnnotationRects:p,getIntersecting:b,getAt:h,recalculatePositions:A,updateTarget:g},selection:i,hover:s,viewport:a}},lo=()=>{const t=document.createElement("canvas");t.width=2*window.innerWidth,t.height=2*window.innerHeight,t.className="r6o-presence-layer";const e=t.getContext("2d");return e.scale(2,2),e.translate(.5,.5),t},Ne=(t,e={})=>{const n=lo(),o=n.getContext("2d");document.body.appendChild(n);const i=new Map,s=g=>Array.from(i.entries()).filter(([u,h])=>h.presenceKey===g.presenceKey).map(([u,h])=>u);return t.on("selectionChange",(g,u)=>{s(g).forEach(E=>i.delete(E)),u&&u.forEach(E=>i.set(E,g))}),{clear:()=>{const{width:g,height:u}=n;o.clearRect(-.5,-.5,g+1,u+1)},destroy:()=>{n.remove()},paint:(g,u,h)=>{e.font&&(o.font=e.font);const E=i.get(g.annotation.id);if(E){const{height:b}=g.rects[0],p=g.rects[0].x+u.left,A=g.rects[0].y+u.top;o.fillStyle=E.appearance.color,o.fillRect(p-2,A-2.5,2,b+5);const c=o.measureText(E.appearance.label),l=c.width+6,m=c.actualBoundingBoxAscent+c.actualBoundingBoxDescent+8,S=c.fontBoundingBoxAscent?8:6.5;return o.fillRect(p-2,A-2.5-m,l,m),o.fillStyle="#fff",o.fillText(E.appearance.label,p+1,A-S),{fill:E.appearance.color,fillOpacity:h?.45:.18}}},reset:()=>{n.width=2*window.innerWidth,n.height=2*window.innerHeight;const g=n.getContext("2d");g.scale(2,2),g.translate(.5,.5)}}},Pt=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Ht(t,e,n,o){t.addEventListener?t.addEventListener(e,n,o):t.attachEvent&&t.attachEvent("on".concat(e),n)}function gt(t,e,n,o){t.removeEventListener?t.removeEventListener(e,n,o):t.detachEvent&&t.detachEvent("on".concat(e),n)}function Ue(t,e){const n=e.slice(0,e.length-1);for(let o=0;o<n.length;o++)n[o]=t[n[o].toLowerCase()];return n}function De(t){typeof t!="string"&&(t=""),t=t.replace(/\s/g,"");const e=t.split(",");let n=e.lastIndexOf("");for(;n>=0;)e[n-1]+=",",e.splice(n,1),n=e.lastIndexOf("");return e}function co(t,e){const n=t.length>=e.length?t:e,o=t.length>=e.length?e:t;let i=!0;for(let s=0;s<n.length;s++)o.indexOf(n[s])===-1&&(i=!1);return i}const pt={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":Pt?173:189,"=":Pt?61:187,";":Pt?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},F={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},mt={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},P={16:!1,18:!1,17:!1,91:!1},D={};for(let t=1;t<20;t++)pt["f".concat(t)]=111+t;let U=[],yt=null,Ve="all";const Q=new Map,rt=t=>pt[t.toLowerCase()]||F[t.toLowerCase()]||t.toUpperCase().charCodeAt(0),uo=t=>Object.keys(pt).find(e=>pt[e]===t),fo=t=>Object.keys(F).find(e=>F[e]===t);function Ye(t){Ve=t||"all"}function bt(){return Ve||"all"}function ho(){return U.slice(0)}function go(){return U.map(t=>uo(t)||fo(t)||String.fromCharCode(t))}function po(){const t=[];return Object.keys(D).forEach(e=>{D[e].forEach(n=>{let{key:o,scope:i,mods:s,shortcut:a}=n;t.push({scope:i,shortcut:a,mods:s,keys:o.split("+").map(r=>rt(r))})})}),t}function mo(t){const e=t.target||t.srcElement,{tagName:n}=e;let o=!0;const i=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(e.type);return(e.isContentEditable||(i||n==="TEXTAREA"||n==="SELECT")&&!e.readOnly)&&(o=!1),o}function yo(t){return typeof t=="string"&&(t=rt(t)),U.indexOf(t)!==-1}function bo(t,e){let n,o;t||(t=bt());for(const i in D)if(Object.prototype.hasOwnProperty.call(D,i))for(n=D[i],o=0;o<n.length;)n[o].scope===t?n.splice(o,1).forEach(a=>{let{element:r}=a;return $t(r)}):o++;bt()===t&&Ye(e||"all")}function wo(t){let e=t.keyCode||t.which||t.charCode;t.key&&t.key.toLowerCase()==="capslock"&&(e=rt(t.key));const n=U.indexOf(e);if(n>=0&&U.splice(n,1),t.key&&t.key.toLowerCase()==="meta"&&U.splice(0,U.length),(e===93||e===224)&&(e=91),e in P){P[e]=!1;for(const o in F)F[o]===e&&(j[o]=!1)}}function Ke(t){if(typeof t>"u")Object.keys(D).forEach(i=>{Array.isArray(D[i])&&D[i].forEach(s=>Ot(s)),delete D[i]}),$t(null);else if(Array.isArray(t))t.forEach(i=>{i.key&&Ot(i)});else if(typeof t=="object")t.key&&Ot(t);else if(typeof t=="string"){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];let[i,s]=n;typeof i=="function"&&(s=i,i=""),Ot({key:t,scope:i,method:s,splitKey:"+"})}}const Ot=t=>{let{key:e,scope:n,method:o,splitKey:i="+"}=t;De(e).forEach(a=>{const r=a.split(i),d=r.length,f=r[d-1],g=f==="*"?"*":rt(f);if(!D[g])return;n||(n=bt());const u=d>1?Ue(F,r):[],h=[];D[g]=D[g].filter(E=>{const p=(o?E.method===o:!0)&&E.scope===n&&co(E.mods,u);return p&&h.push(E.element),!p}),h.forEach(E=>$t(E))})};function Xe(t,e,n,o){if(e.element!==o)return;let i;if(e.scope===n||e.scope==="all"){i=e.mods.length>0;for(const s in P)Object.prototype.hasOwnProperty.call(P,s)&&(!P[s]&&e.mods.indexOf(+s)>-1||P[s]&&e.mods.indexOf(+s)===-1)&&(i=!1);(e.mods.length===0&&!P[16]&&!P[18]&&!P[17]&&!P[91]||i||e.shortcut==="*")&&(e.keys=[],e.keys=e.keys.concat(U),e.method(t,e)===!1&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0)))}}function Pe(t,e){const n=D["*"];let o=t.keyCode||t.which||t.charCode;if(t.key&&t.key.toLowerCase()==="capslock"||!j.filter.call(this,t))return;if((o===93||o===224)&&(o=91),U.indexOf(o)===-1&&o!==229&&U.push(o),["metaKey","ctrlKey","altKey","shiftKey"].forEach(r=>{const d=mt[r];t[r]&&U.indexOf(d)===-1?U.push(d):!t[r]&&U.indexOf(d)>-1?U.splice(U.indexOf(d),1):r==="metaKey"&&t[r]&&(U=U.filter(f=>f in mt||f===o))}),o in P){P[o]=!0;for(const r in F)if(Object.prototype.hasOwnProperty.call(F,r)){const d=mt[F[r]];j[r]=t[d]}if(!n)return}for(const r in P)Object.prototype.hasOwnProperty.call(P,r)&&(P[r]=t[mt[r]]);t.getModifierState&&!(t.altKey&&!t.ctrlKey)&&t.getModifierState("AltGraph")&&(U.indexOf(17)===-1&&U.push(17),U.indexOf(18)===-1&&U.push(18),P[17]=!0,P[18]=!0);const i=bt();if(n)for(let r=0;r<n.length;r++)n[r].scope===i&&(t.type==="keydown"&&n[r].keydown||t.type==="keyup"&&n[r].keyup)&&Xe(t,n[r],i,e);if(!(o in D))return;const s=D[o],a=s.length;for(let r=0;r<a;r++)if((t.type==="keydown"&&s[r].keydown||t.type==="keyup"&&s[r].keyup)&&s[r].key){const d=s[r],{splitKey:f}=d,g=d.key.split(f),u=[];for(let h=0;h<g.length;h++)u.push(rt(g[h]));u.sort().join("")===U.sort().join("")&&Xe(t,d,i,e)}}function j(t,e,n){U=[];const o=De(t);let i=[],s="all",a=document,r=0,d=!1,f=!0,g="+",u=!1,h=!1;for(n===void 0&&typeof e=="function"&&(n=e),Object.prototype.toString.call(e)==="[object Object]"&&(e.scope&&(s=e.scope),e.element&&(a=e.element),e.keyup&&(d=e.keyup),e.keydown!==void 0&&(f=e.keydown),e.capture!==void 0&&(u=e.capture),typeof e.splitKey=="string"&&(g=e.splitKey),e.single===!0&&(h=!0)),typeof e=="string"&&(s=e),h&&Ke(t,s);r<o.length;r++)t=o[r].split(g),i=[],t.length>1&&(i=Ue(F,t)),t=t[t.length-1],t=t==="*"?"*":rt(t),t in D||(D[t]=[]),D[t].push({keyup:d,keydown:f,scope:s,mods:i,shortcut:o[r],method:n,key:o[r],splitKey:g,element:a});if(typeof a<"u"&&window){if(!Q.has(a)){const E=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return Pe(p,a)},b=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;Pe(p,a),wo(p)};Q.set(a,{keydownListener:E,keyupListenr:b,capture:u}),Ht(a,"keydown",E,u),Ht(a,"keyup",b,u)}if(!yt){const E=()=>{U=[]};yt={listener:E,capture:u},Ht(window,"focus",E,u)}}}function Ao(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(D).forEach(n=>{D[n].filter(i=>i.scope===e&&i.shortcut===t).forEach(i=>{i&&i.method&&i.method()})})}function $t(t){const e=Object.values(D).flat();if(e.findIndex(o=>{let{element:i}=o;return i===t})<0){const{keydownListener:o,keyupListenr:i,capture:s}=Q.get(t)||{};o&&i&&(gt(t,"keyup",i,s),gt(t,"keydown",o,s),Q.delete(t))}if((e.length<=0||Q.size<=0)&&(Object.keys(Q).forEach(i=>{const{keydownListener:s,keyupListenr:a,capture:r}=Q.get(i)||{};s&&a&&(gt(i,"keyup",a,r),gt(i,"keydown",s,r),Q.delete(i))}),Q.clear(),Object.keys(D).forEach(i=>delete D[i]),yt)){const{listener:i,capture:s}=yt;gt(window,"focus",i,s),yt=null}}const jt={getPressedKeyString:go,setScope:Ye,getScope:bt,deleteScope:bo,getPressedKeyCodes:ho,getAllKeyCodes:po,isPressed:yo,filter:mo,trigger:Ao,unbind:Ke,keyMap:pt,modifier:F,modifierMap:mt};for(const t in jt)Object.prototype.hasOwnProperty.call(jt,t)&&(j[t]=jt[t]);if(typeof window<"u"){const t=window.hotkeys;j.noConflict=e=>(e&&window.hotkeys===j&&(window.hotkeys=t),j),window.hotkeys=j}const He=300,$e=["up","down","left","right"],je=Wt?"⌘+a":"ctrl+a",vo=[...$e.map(t=>`shift+${t}`),je],ze=(t,e,n)=>{let o;const{annotatingEnabled:i,offsetReferenceSelector:s,selectionMode:a}=n,r=T=>o=T;let d;const f=T=>d=T,{store:g,selection:u}=e;let h,E,b;const p=T=>{const k=T;return k.ctrlKey||k.metaKey},A=T=>{if(E!==!1)if(nt(T.target))h=void 0;else{const{selected:k}=u;if(p({...T,...b})&&k.length===1&&k[0].editable){const y=g.getAnnotation(k[0].id);h={previous:{...y.target},next:{annotation:y.id,selector:[],created:y.target.created,creator:y.target.creator,updated:new Date,updatedBy:o}}}else h={next:{annotation:xe(),selector:[],created:new Date,creator:o}}}},c=At(T=>{const k=document.getSelection();if(!(k!=null&&k.anchorNode))return;if(nt(k.anchorNode)){h=void 0;return}const y=T.timeStamp-((b==null?void 0:b.timeStamp)||T.timeStamp);if((b==null?void 0:b.type)==="pointerdown"&&(y<1e3&&!h||k.isCollapsed&&y<He)&&A(b||T),!h)return;if(k.isCollapsed){g.getAnnotation(h.next.annotation)&&!p(b)&&(u.clear(),g.deleteAnnotation(h.next.annotation));return}const v=Array.from(Array(k.rangeCount).keys()).map(R=>k.getRangeAt(R)).map(R=>ne(R,t));if(v.every(R=>Zt(R)))return;const C=v.flatMap(R=>Gt(R.cloneRange()));(C.length!==h.next.selector.length||C.some((R,B)=>{var H;return R.toString()!==((H=h.next.selector[B])==null?void 0:H.quote)}))&&(h={...h,next:{...h.next,selector:[...h.previous?h.previous.selector:[],...C.map(R=>ee(R,t,s))],updated:new Date}},g.getAnnotation(h.next.annotation)?g.updateTarget(h.next,I.LOCAL):p(b)||u.clear())}),l=T=>{nt(T.target)||(b=wt(T),E=b.button===0)},m=T=>{if(nt(T.target)||!E)return;const k=()=>{const{x:w,y:v}=t.getBoundingClientRect(),C=T.target instanceof Node&&t.contains(T.target)&&g.getAt(T.clientX-w,T.clientY-v,a==="all",d);if(C){const{selected:_}=u,R=new Set(_.map(et=>et.id)),B=Array.isArray(C)?C.map(et=>et.id):[C.id];(R.size!==B.length||!B.every(et=>R.has(et)))&&u.userSelect(B,T)}else p(T)||u.clear()},y=T.timeStamp-b.timeStamp;setTimeout(()=>{const w=document.getSelection();w!=null&&w.isCollapsed&&y<He?(h=void 0,k()):h&&h.next.selector.length>0&&(N(),u.userSelect(h.next.annotation,wt(T)))})},S=T=>{const k=document.getSelection();k!=null&&k.isCollapsed||((!h||h.next.selector.length===0)&&c(T),h&&(N(),u.userSelect(h.next.annotation,wt(T))))},x=T=>{T.key==="Shift"&&h&&(document.getSelection().isCollapsed||(N(),u.userSelect(h.next.annotation,at(T))))},L=T=>{const k=()=>setTimeout(()=>{(h==null?void 0:h.next.selector.length)>0&&(u.clear(),g.addAnnotation({id:h.next.annotation,bodies:[],target:h.next}),u.userSelect(h.next.annotation,at(T))),document.removeEventListener("selectionchange",k)},100);document.addEventListener("selectionchange",k),A(T)};j(vo.join(","),{element:t,keydown:!0,keyup:!1},T=>{T.repeat||(b=at(T))}),j(je,{keydown:!0,keyup:!1},T=>{b=at(T),L(T)});const M=T=>{T.repeat||T.target!==t&&T.target!==document.body||(h=void 0,u.clear())};j($e.join(","),{keydown:!0,keyup:!1},M);const N=()=>{const T=g.getAnnotation(h.next.annotation);if(!T){g.addAnnotation({id:h.next.annotation,bodies:[],target:h.next});return}const{target:{updated:k}}=T,{updated:y}=h.next;(!k||!y||k<y)&&g.updateTarget(h.next)};return t.addEventListener("pointerdown",l),document.addEventListener("pointerup",m),document.addEventListener("contextmenu",S),i&&(t.addEventListener("keyup",x),t.addEventListener("selectstart",A),document.addEventListener("selectionchange",c)),{destroy:()=>{t.removeEventListener("pointerdown",l),document.removeEventListener("pointerup",m),document.removeEventListener("contextmenu",S),t.removeEventListener("keyup",x),t.removeEventListener("selectstart",A),document.removeEventListener("selectionchange",c),j.unbind()},setFilter:f,setUser:r}},Fe=(t,e)=>({...t,annotatingEnabled:t.annotatingEnabled??e.annotatingEnabled,user:t.user||e.user}),We="SPANS",Eo=(t,e={})=>{Ft(t),qt(t);const n=Fe(e,{annotatingEnabled:!0,user:Fn()}),o=_e(t,n),{selection:i,viewport:s}=o,a=o.store,r=Dn(a),d=Yn(o,r,n.adapter);let f=n.user;const g=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":We:n.renderer||We,u=g==="SPANS"?ve(t,o,s):g==="CSS_HIGHLIGHTS"?we(t,o,s):g==="CANVAS"?re(t,o,s):void 0;if(!u)throw`Unknown renderer implementation: ${g}`;console.debug(`Using ${g} renderer`),n.style&&u.setStyle(n.style);const h=ze(t,o,n);return h.setUser(f),{...Xn(o,r,n.adapter),destroy:()=>{u.destroy(),h.destroy(),r.destroy()},element:t,getUser:()=>f,setFilter:L=>{u.setFilter(L),h.setFilter(L)},setStyle:L=>u.setStyle(L),setUser:L=>{f=L,h.setUser(L)},setSelected:L=>{L?i.setSelected(L):i.clear()},setPresenceProvider:L=>{L&&(u.setPainter(Ne(L,n.presence)),L.on("selectionChange",()=>u.redraw()))},setVisible:L=>u.setVisible(L),on:d.on,off:d.off,scrollIntoView:ie(t,a),state:o}};O.DEFAULT_SELECTED_STYLE=ct,O.DEFAULT_STYLE=q,O.NOT_ANNOTATABLE_CLASS=J,O.NOT_ANNOTATABLE_SELECTOR=Z,O.Origin=I,O.SelectionHandler=ze,O.UserSelectAction=Ce,O.W3CTextFormat=Qn,O.cancelSingleClickEvents=Ft,O.cloneKeyboardEvent=at,O.clonePointerEvent=wt,O.createBody=Ln,O.createCanvasRenderer=re,O.createHighlightsRenderer=we,O.createPresencePainter=Ne,O.createRenderer=be,O.createSpansRenderer=ve,O.createTextAnnotator=Eo,O.createTextAnnotatorState=_e,O.debounce=At,O.fillDefaults=Fe,O.getQuoteContext=Qt,O.getRangeAnnotatableContents=vt,O.isMac=Wt,O.isNotAnnotatable=nt,O.isRangeAnnotatable=zt,O.isRevived=W,O.isWhitespaceOrEmpty=Zt,O.mergeClientRects=te,O.paint=se,O.parseW3CTextAnnotation=Me,O.programmaticallyFocusable=qt,O.rangeToSelector=ee,O.reviveAnnotation=Et,O.reviveSelector=Rt,O.reviveTarget=lt,O.scrollIntoView=ie,O.serializeW3CTextAnnotation=ke,O.splitAnnotatableRanges=Gt,O.toDomRectList=Je,O.trimRangeToContainer=ne,O.whitespaceOrEmptyRegex=Jt,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(S,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("colord"),require("dequal/lite"),require("uuid"),require("@annotorious/core"),require("rbush"),require("hotkeys-js")):typeof define=="function"&&define.amd?define(["exports","colord","dequal/lite","uuid","@annotorious/core","rbush","hotkeys-js"],D):(S=typeof globalThis<"u"?globalThis:S||self,D(S.RecogitoJS={},S.Colord,S.DequalLite,S.UUID,S.AnnotoriousCore,S.RBush,S.HotkeysJs))})(this,(function(S,D,Oe,ee,x,ke,z){"use strict";const Q="not-annotatable",M=`.${Q}`,K=(e,n)=>{var o;return e.contains(n)?!!(n instanceof HTMLElement?n.closest(M):(o=n.parentElement)==null?void 0:o.closest(M)):!0},te=(e,n)=>{const t=n.commonAncestorContainer;return!K(e,t)},ne=e=>e.addEventListener("click",n=>{!n.target.closest(M)&&!n.target.closest("a")&&n.preventDefault()}),X=e=>({...e,type:e.type,x:e.x,y:e.y,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,screenX:e.screenX,screenY:e.screenY,isPrimary:e.isPrimary,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,button:e.button,buttons:e.buttons,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,eventPhase:e.eventPhase,pointerId:e.pointerId,pointerType:e.pointerType,timeStamp:e.timeStamp}),$=e=>({...e,type:e.type,key:e.key,code:e.code,location:e.location,repeat:e.repeat,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,timeStamp:e.timeStamp}),oe=typeof navigator<"u"&&/mac/i.test(navigator.userAgentData?navigator.userAgentData.platform:navigator.platform),se=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},W=(e,n=10)=>{let t;return((...o)=>{clearTimeout(t),t=setTimeout(()=>e.apply(void 0,o),n)})},Ne=function*(e){const n=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(Q)&&!o.parentElement.closest(M)&&e.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let t;for(;t=n.nextNode();)t instanceof HTMLElement&&(yield t)},re=(e,n)=>{if(!te(e,n))return[];const t=[];let o=null;for(const s of Ne(n)){let r;o?(r=document.createRange(),r.setStartAfter(o),r.setEndBefore(s)):(r=n.cloneRange(),r.setEndBefore(s)),r.collapsed||t.push(r),o=s}if(o){const s=n.cloneRange();s.setStartAfter(o),s.collapsed||t.push(s)}return t.length>0?t:[n]},j=e=>{const n=e.cloneContents();return n.querySelectorAll(M).forEach(t=>t.remove()),n},ie=(e,n,t=10,o)=>{const s=o?e.startContainer.parentElement.closest(o):n,r=document.createRange();r.setStart(s,0),r.setEnd(e.startContainer,e.startOffset);const l=j(r).textContent,u=document.createRange();u.setStart(e.endContainer,e.endOffset),s===document.body?u.setEnd(s,s.childNodes.length):u.setEndAfter(s);const m=j(u).textContent;return{prefix:l.substring(l.length-t),suffix:m.substring(0,t)}},P=e=>e.every(n=>n.range instanceof Range&&!n.range.collapsed),ae=/^\s*$/,ce=e=>ae.test(e.toString()),Be=(e,n)=>{const t=r=>Math.round(r*10)/10,o={top:t(e.top),bottom:t(e.bottom),left:t(e.left),right:t(e.right)},s={top:t(n.top),bottom:t(n.bottom),left:t(n.left),right:t(n.right)};if(Math.abs(o.top-s.top)<.5&&Math.abs(o.bottom-s.bottom)<.5){if(Math.abs(o.left-s.right)<.5||Math.abs(o.right-s.left)<.5)return"inline-adjacent";if(o.left>=s.left&&o.right<=s.right)return"inline-is-contained";if(o.left<=s.left&&o.right>=s.right)return"inline-contains"}else if(o.top<=s.top&&o.bottom>=s.bottom){if(o.left<=s.left&&o.right>=s.right)return"block-contains"}else if(o.top>=s.top&&o.bottom<=s.bottom&&o.left>=s.left&&o.right<=s.right)return"block-is-contained"},Ie=(e,n)=>{const t=Math.min(e.left,n.left),o=Math.max(e.right,n.right),s=Math.min(e.top,n.top),r=Math.max(e.bottom,n.bottom);return new DOMRect(t,s,o-t,r-s)},le=e=>e.reduce((n,t)=>{if(t.width===0||t.height===0)return n;let o=[...n],s=!1;for(const r of n){const l=Be(t,r);if(l==="inline-adjacent"){o=o.map(u=>u===r?Ie(t,r):u),s=!0;break}else if(l==="inline-contains"){o=o.map(u=>u===r?t:u),s=!0;break}else if(l==="inline-is-contained"){s=!0;break}else if(l==="block-contains"||l==="block-is-contained"){t.width<r.width&&(o=o.map(u=>u===r?t:u)),s=!0;break}}return s?o:[...o,t]},[]),Pe=e=>({length:e.length,item:n=>e[n],[Symbol.iterator]:function*(){for(let n=0;n<this.length;n++)yield this.item(n)}}),de=(e,n,t)=>{const o=document.createRange(),s=t?e.startContainer.parentElement.closest(t):n;o.setStart(s,0),o.setEnd(e.startContainer,e.startOffset);const r=j(o).textContent,l=e.toString(),u=r.length||0,m=u+l.length;return t?{quote:l,start:u,end:m,range:e,offsetReference:s}:{quote:l,start:u,end:m,range:e}},J=(e,n)=>{var p,d;const{start:t,end:o}=e,s=e.offsetReference||n,r=document.createNodeIterator(n,NodeFilter.SHOW_TEXT,i=>{var T;return(T=i.parentElement)!=null&&T.closest(M)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let l=0;const u=document.createRange();let m=r.nextNode();m===null&&console.error("Could not revive annotation target. Content missing.");let C=!s;for(;m!==null;){if(C||(C=typeof(s==null?void 0:s.contains)=="function"?s.contains(m):!1),C){const i=((p=m.textContent)==null?void 0:p.length)||0;if(l+i>t){u.setStart(m,t-l);break}l+=i}m=r.nextNode()}for(;m!==null;){const i=((d=m.textContent)==null?void 0:d.length)||0;if(l+i>=o){u.setEnd(m,o-l);break}l+=i,m=r.nextNode()}return{...e,range:u}},V=(e,n)=>P(e.selector)?e:{...e,selector:e.selector.map(t=>t.range instanceof Range&&!t.range.collapsed?t:J(t,n))},G=(e,n)=>P(e.target.selector)?e:{...e,target:V(e.target,n)},ue=(e,n)=>{const t=e.cloneRange();return n.contains(t.startContainer)||t.setStart(n,0),n.contains(t.endContainer)||t.setEnd(n,n.childNodes.length),t},fe=e=>{if(e===null)return document.scrollingElement;const{overflowY:n}=window.getComputedStyle(e);return n!=="visible"&&n!=="hidden"&&e.scrollHeight>e.clientHeight?e:fe(e.parentElement)},ge=(e,n)=>t=>{const o=typeof t=="string"?t:t.id,s=p=>{const d=r.getBoundingClientRect(),i=r.clientHeight,T=r.clientWidth,E=p.selector[0].range.getBoundingClientRect(),{width:w,height:v}=n.getAnnotationBounds(o),a=E.top-d.top,c=E.left-d.left,y=r.parentElement?r.scrollTop:0,b=r.parentElement?r.scrollLeft:0,h=a+y-(i-v)/2,f=c+b-(T-w)/2;r.scroll({top:h,left:f,behavior:"smooth"})},r=fe(e);if(!r)return console.warn(`The scroll parent is missing for the annotation: ${o}`,{container:e}),!1;const l=n.getAnnotation(o);if(!l)return console.warn(`The annotation is missing in the store: ${o}`),!1;const{range:u}=l.target.selector[0];if(u&&!u.collapsed)return s(l.target),!0;const m=V(l.target,e),{range:C}=m.selector[0];return C&&!C.collapsed?(s(m),!0):!1},H={fill:"rgb(0, 128, 255)",fillOpacity:.18},Y={fill:"rgb(0, 128, 255)",fillOpacity:.45},me=(e,n,t,o,s)=>{var l,u;const r=t?typeof t=="function"?t(e.annotation,e.state,s)||((l=e.state)!=null&&l.selected?Y:H):t:(u=e.state)!=null&&u.selected?Y:H;return o&&o.paint(e,n)||r},He=e=>{const{top:n,left:t}=e.getBoundingClientRect(),{innerWidth:o,innerHeight:s}=window,r=-t,l=-n,u=o-t,m=s-n;return{top:n,left:t,minX:r,minY:l,maxX:u,maxY:m}},Me=e=>{let n=new Set;return o=>{const s=o.map(r=>r.id);(n.size!==s.length||s.some(r=>!n.has(r)))&&e.set(s),n=new Set(s)}},Z=(e,n,t,o)=>{const{store:s,selection:r,hover:l}=n;let u,m,C;const p=Me(t),d=g=>{const{x:R,y:k}=e.getBoundingClientRect(),N=s.getAt(g.clientX-R,g.clientY-k,!1,m);N?l.current!==N.id&&(e.classList.add("hovered"),l.set(N.id)):l.current&&(e.classList.remove("hovered"),l.set(null))};e.addEventListener("pointermove",d);const i=(g=!1)=>{C&&C.clear();const R=He(e),{minX:k,minY:N,maxX:_,maxY:I}=R,q=m?s.getIntersecting(k,N,_,I).filter(({annotation:B})=>m(B)):s.getIntersecting(k,N,_,I),O=r.selected.map(({id:B})=>B),U=q.map(({annotation:B,rects:F})=>{const Ge=O.includes(B.id),Qe=B.id===l.current;return{annotation:B,rects:F,state:{selected:Ge,hovered:Qe}}});o.redraw(U,R,u,C,g),setTimeout(()=>p(q.map(({annotation:B})=>B)),1)},T=g=>{C=g,i()},E=g=>{u=g,i()},w=g=>{m=g,i(!1)},v=()=>i();s.observe(v);const a=r.subscribe(()=>i()),c=l.subscribe(()=>i()),y=()=>i(!0);document.addEventListener("scroll",y,{capture:!0,passive:!0});const b=W(()=>{s.recalculatePositions(),C&&C.reset(),i()});window.addEventListener("resize",b);const h=new ResizeObserver(b);h.observe(e);const f={attributes:!0,childList:!0,subtree:!0},A=new MutationObserver(W(g=>{g.every(k=>k.target===e||e.contains(k.target))||i(!0)},150));return A.observe(document.body,f),{destroy:()=>{e.removeEventListener("pointermove",d),o.destroy(),s.unobserve(v),a(),c(),document.removeEventListener("scroll",y),window.removeEventListener("resize",b),h.disconnect(),A.disconnect()},redraw:i,setStyle:E,setFilter:w,setPainter:T,setVisible:o.setVisible}},_e=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},Ue=(e,n)=>{e.width=window.innerWidth,e.height=window.innerHeight},Fe=e=>{e.classList.add("r6o-annotatable");const n=_e(),t=n.getContext("2d");document.body.appendChild(n);const o=(u,m,C,p)=>requestAnimationFrame(()=>{const{width:d,height:i}=n;t.clearRect(-.5,-.5,d+1,i+1),p&&p.clear();const{top:T,left:E}=m;[...u].sort((v,a)=>{const{annotation:{target:{created:c}}}=v,{annotation:{target:{created:y}}}=a;return c.getTime()-y.getTime()}).forEach(v=>{var b;const a=C?typeof C=="function"?C(v.annotation,v.state):C:(b=v.state)!=null&&b.selected?Y:H,c=p&&p.paint(v,m)||a,y=v.rects.map(({x:h,y:f,width:A,height:L})=>({x:h+E,y:f+T,width:A,height:L}));if(t.fillStyle=c.fill,t.globalAlpha=c.fillOpacity||1,y.forEach(({x:h,y:f,width:A,height:L})=>t.fillRect(h,f,A,L)),c.underlineColor){t.globalAlpha=1,t.strokeStyle=c.underlineColor,t.lineWidth=c.underlineThickness??1;const h=c.underlineOffset??0;y.forEach(({x:f,y:A,width:L,height:g})=>{t.beginPath(),t.moveTo(f,A+g+h),t.lineTo(f+L,A+g+h),t.stroke()})}})}),s=W(()=>{Ue(n)});return window.addEventListener("resize",s),{destroy:()=>{n.remove(),window.removeEventListener("resize",s)},setVisible:u=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},he=(e,n,t)=>Z(e,n,t,Fe(e)),De=e=>[`background-color:${D.colord((e==null?void 0:e.fill)||H.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?H.fillOpacity:e.fillOpacity).toHex()}`,e!=null&&e.underlineThickness?"text-decoration:underline":void 0,e!=null&&e.underlineColor?`text-decoration-color:${e.underlineColor}`:void 0,e!=null&&e.underlineOffset?`text-underline-offset:${e.underlineOffset}px`:void 0,e!=null&&e.underlineThickness?`text-decoration-thickness:${e.underlineThickness}px`:void 0].filter(Boolean).join(";"),pe=()=>{const e=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(e);let n=new Set;return{destroy:()=>{CSS.highlights.clear(),e.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,l,u,m)=>{m&&m.clear();const C=new Set(r.map(d=>d.annotation.id));Array.from(n).filter(d=>!C.has(d));const p=r.map(d=>{var E;const i=u?typeof u=="function"?u(d.annotation,d.state):u:(E=d.state)!=null&&E.selected?Y:H,T=m&&m.paint(d,l)||i;return`::highlight(_${d.annotation.id}) { ${De(T)} }`});e.innerHTML=p.join(`
|
|
2
|
+
`),CSS.highlights.clear(),r.forEach(({annotation:d})=>{const i=d.target.selector.map(E=>E.range),T=new Highlight(...i);CSS.highlights.set(`_${d.id}`,T)}),n=C}}},ye=(e,n,t)=>Z(e,n,t,pe()),Ke=(e,n)=>{const t=(r,l)=>r.x<=l.x+l.width&&r.x+r.width>=l.x&&r.y<=l.y+l.height&&r.y+r.height>=l.y,o=r=>r.rects.reduce((l,u)=>l+u.width,0),s=n.filter(({rects:r})=>r.some(l=>t(e,l)));return s.sort((r,l)=>o(l)-o(r)),s.findIndex(r=>r.rects.includes(e))},$e=e=>{e.classList.add("r6o-annotatable");const n=document.createElement("div");n.className="r6o-span-highlight-layer",e.insertBefore(n,e.firstChild);let t=[];return{destroy:()=>{n.remove()},redraw:(l,u,m,C,p)=>{const i=!(Oe.dequal(t,l)&&p);if(!C&&!i)return;i&&(n.innerHTML=""),[...l].sort((E,w)=>{const{annotation:{target:{created:v}}}=E,{annotation:{target:{created:a}}}=w;return v&&a?v.getTime()-a.getTime():0}).forEach(E=>{E.rects.map(w=>{const v=Ke(w,l),a=me(E,u,m,C,v);if(i){const c=document.createElement("span");c.className="r6o-annotation",c.dataset.annotation=E.annotation.id,c.style.left=`${w.x}px`,c.style.top=`${w.y}px`,c.style.width=`${w.width}px`,c.style.height=`${w.height}px`,c.style.backgroundColor=D.colord((a==null?void 0:a.fill)||H.fill).alpha((a==null?void 0:a.fillOpacity)===void 0?H.fillOpacity:a.fillOpacity).toHex(),a.underlineStyle&&(c.style.borderStyle=a.underlineStyle),a.underlineColor&&(c.style.borderColor=a.underlineColor),a.underlineThickness&&(c.style.borderBottomWidth=`${a.underlineThickness}px`),a.underlineOffset&&(c.style.paddingBottom=`${a.underlineOffset}px`),n.appendChild(c)}})}),t=l},setVisible:l=>{l?n.classList.remove("hidden"):n.classList.add("hidden")}}},be=(e,n,t)=>Z(e,n,t,$e(e)),We=(e,n)=>({parse:t=>Se(t),serialize:t=>Ce(t,e,n)}),Ve=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,Ye=e=>{const{id:n,creator:t,created:o,modified:s,target:r}=e,l=Array.isArray(r)?r:[r];if(l.length===0)return{error:Error(`No targets found for annotation: ${e.id}`)};const u={creator:x.parseW3CUser(t),created:o?new Date(o):void 0,updated:s?new Date(s):void 0,annotation:n,selector:[],styleClass:"styleClass"in l[0]?l[0].styleClass:void 0};for(const m of l){const p=(Array.isArray(m.selector)?m.selector:[m.selector]).reduce((d,i)=>{switch(i.type){case"TextQuoteSelector":d.quote=i.exact;break;case"TextPositionSelector":d.start=i.start,d.end=i.end;break}return d},{});if(Ve(p))u.selector.push({...p,id:m.id,scope:m.scope});else{const d=[p.start?void 0:"TextPositionSelector",p.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${d.join(" and ")} for annotation: ${e.id}`)}}}return{parsed:u}},Se=e=>{const n=e.id||ee.v4(),{creator:t,created:o,modified:s,body:r,...l}=e,u=x.parseW3CBodies(r,n),m=Ye(e);return"error"in m?{error:m.error}:{parsed:{...l,id:n,bodies:u,target:m.parsed}}},Ce=(e,n,t)=>{const{bodies:o,target:s,...r}=e,{selector:l,creator:u,created:m,updated:C,...p}=s,d=l.map(i=>{const{id:T,quote:E,start:w,end:v,range:a}=i,c={type:"TextQuoteSelector",exact:E};if(t){const{prefix:b,suffix:h}=ie(a,t);c.prefix=b,c.suffix=h}const y={type:"TextPositionSelector",start:w,end:v};return{...p,id:T,scope:"scope"in i?i.scope:void 0,source:n,selector:[c,y]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:x.serializeW3CBodies(e.bodies),creator:u,created:m==null?void 0:m.toISOString(),modified:C==null?void 0:C.toISOString(),target:d}},qe=(e,n)=>{const t=new ke,o=new Map,s=(a,c)=>{const y=a.selector.flatMap(h=>{const f=P([h])?h.range:J(h,n).range;return Array.from(f.getClientRects())}),b=le(y).map(({left:h,top:f,right:A,bottom:L})=>new DOMRect(h-c.left,f-c.top,A-h,L-f));return b.map(h=>{const{x:f,y:A,width:L,height:g}=h;return{minX:f,minY:A,maxX:f+L,maxY:A+g,annotation:{id:a.annotation,rects:b}}})},r=()=>[...o.values()],l=()=>{t.clear(),o.clear()},u=a=>{const c=s(a,n.getBoundingClientRect());c.length!==0&&(c.forEach(y=>t.insert(y)),o.set(a.annotation,c))},m=a=>{const c=o.get(a.annotation);c&&(c.forEach(y=>t.remove(y)),o.delete(a.annotation))},C=a=>{m(a),u(a)},p=(a,c=!0)=>{c&&l();const y=n.getBoundingClientRect(),b=a.map(f=>({target:f,rects:s(f,y)}));b.forEach(({target:f,rects:A})=>{A.length>0&&o.set(f.annotation,A)});const h=b.flatMap(({rects:f})=>f);t.load(h)},d=(a,c,y=!1)=>{const b=t.search({minX:a,minY:c,maxX:a,maxY:c}),h=f=>f.annotation.rects.reduce((A,L)=>A+L.width*L.height,0);return b.length>0?(b.sort((f,A)=>h(f)-h(A)),y?b.map(f=>f.annotation.id):[b[0].annotation.id]):[]},i=a=>{const c=T(a);if(c.length===0)return;let y=c[0].left,b=c[0].top,h=c[0].right,f=c[0].bottom;for(let A=1;A<c.length;A++){const L=c[A];y=Math.min(y,L.left),b=Math.min(b,L.top),h=Math.max(h,L.right),f=Math.max(f,L.bottom)}return new DOMRect(y,b,h-y,f-b)},T=a=>{const c=o.get(a);return c?c[0].annotation.rects:[]};return{all:r,clear:l,getAt:d,getAnnotationBounds:i,getAnnotationRects:T,getIntersecting:(a,c,y,b)=>{const h=t.search({minX:a,minY:c,maxX:y,maxY:b}),f=new Set(h.map(A=>A.annotation.id));return Array.from(f).map(A=>({annotation:e.getAnnotation(A),rects:T(A)})).filter(A=>!!A.annotation)},insert:u,recalculate:()=>p(e.all().map(a=>a.target),!0),remove:m,set:p,size:()=>t.all().length,update:C}},Ae=(e,n)=>{const t=x.createStore(),o=qe(t,e),s=x.createSelectionState(t,n.userSelectAction,n.adapter),r=x.createHoverState(t),l=x.createViewportState(),u=(a,c=x.Origin.LOCAL)=>{const y=G(a,e),b=P(y.target.selector);return b&&t.addAnnotation(y,c),b},m=(a,c=!0,y=x.Origin.LOCAL)=>{const b=a.map(f=>G(f,e)),h=b.filter(f=>!P(f.target.selector));return t.bulkAddAnnotations(b,c,y),h},C=(a,c=x.Origin.LOCAL)=>{const y=a.map(h=>G(h,e)),b=y.filter(h=>!P(h.target.selector));return y.forEach(h=>{t.getAnnotation(h.id)?t.updateAnnotation(h,c):t.addAnnotation(h,c)}),b},p=(a,c=x.Origin.LOCAL)=>{const y=V(a,e);t.updateTarget(y,c)},d=(a,c=x.Origin.LOCAL)=>{const y=a.map(b=>V(b,e));t.bulkUpdateTargets(y,c)};function i(a,c,y,b){const h=y||!!b,f=o.getAt(a,c,h).map(L=>t.getAnnotation(L)),A=b?f.filter(b):f;if(A.length!==0)return y?A:A[0]}const T=a=>{if(o.getAnnotationRects(a).length!==0)return o.getAnnotationBounds(a)},E=(a,c,y,b)=>o.getIntersecting(a,c,y,b),w=a=>o.getAnnotationRects(a),v=()=>o.recalculate();return t.observe(({changes:a})=>{const c=(a.deleted||[]).filter(h=>P(h.target.selector)),y=(a.created||[]).filter(h=>P(h.target.selector)),b=(a.updated||[]).filter(h=>P(h.newValue.target.selector));(c==null?void 0:c.length)>0&&c.forEach(h=>o.remove(h.target)),y.length>0&&o.set(y.map(h=>h.target),!1),(b==null?void 0:b.length)>0&&b.forEach(({newValue:h})=>o.update(h.target))}),{store:{...t,addAnnotation:u,bulkAddAnnotations:m,bulkUpdateTargets:d,bulkUpsertAnnotations:C,getAnnotationBounds:T,getAnnotationRects:w,getIntersecting:E,getAt:i,recalculatePositions:v,updateTarget:p},selection:s,hover:r,viewport:l}},ze=()=>{const e=document.createElement("canvas");e.width=2*window.innerWidth,e.height=2*window.innerHeight,e.className="r6o-presence-layer";const n=e.getContext("2d");return n.scale(2,2),n.translate(.5,.5),e},Ee=(e,n={})=>{const t=ze(),o=t.getContext("2d");document.body.appendChild(t);const s=new Map,r=p=>Array.from(s.entries()).filter(([d,i])=>i.presenceKey===p.presenceKey).map(([d,i])=>d);return e.on("selectionChange",(p,d)=>{r(p).forEach(T=>s.delete(T)),d&&d.forEach(T=>s.set(T,p))}),{clear:()=>{const{width:p,height:d}=t;o.clearRect(-.5,-.5,p+1,d+1)},destroy:()=>{t.remove()},paint:(p,d,i)=>{n.font&&(o.font=n.font);const T=s.get(p.annotation.id);if(T){const{height:E}=p.rects[0],w=p.rects[0].x+d.left,v=p.rects[0].y+d.top;o.fillStyle=T.appearance.color,o.fillRect(w-2,v-2.5,2,E+5);const a=o.measureText(T.appearance.label),c=a.width+6,y=a.actualBoundingBoxAscent+a.actualBoundingBoxDescent+8,b=a.fontBoundingBoxAscent?8:6.5;return o.fillRect(w-2,v-2.5-y,c,y),o.fillStyle="#fff",o.fillText(T.appearance.label,w+1,v-b),{fill:T.appearance.color,fillOpacity:i?.45:.18}}},reset:()=>{t.width=2*window.innerWidth,t.height=2*window.innerHeight;const p=t.getContext("2d");p.scale(2,2),p.translate(.5,.5)}}},Te=300,ve=["up","down","left","right"],we=oe?"⌘+a":"ctrl+a",Xe=[...ve.map(e=>`shift+${e}`),we],Re=(e,n,t)=>{let o;const{annotatingEnabled:s,offsetReferenceSelector:r,selectionMode:l}=t,u=g=>o=g;let m;const C=g=>m=g,{store:p,selection:d}=n;let i,T,E;const w=g=>{T!==!1&&(i=K(e,g.target)?void 0:{annotation:ee.v4(),selector:[],creator:o,created:new Date})},v=W(g=>{const R=document.getSelection();if(!(R!=null&&R.anchorNode))return;if(K(e,R.anchorNode)){i=void 0;return}const k=g.timeStamp-((E==null?void 0:E.timeStamp)||g.timeStamp);if((E==null?void 0:E.type)==="pointerdown"&&(k<1e3&&!i||R.isCollapsed&&k<Te)&&w(E||g),!i)return;if(R.isCollapsed){p.getAnnotation(i.annotation)&&(d.clear(),p.deleteAnnotation(i.annotation));return}const _=Array.from(Array(R.rangeCount).keys()).map(O=>R.getRangeAt(O)).map(O=>ue(O,e));if(_.every(O=>ce(O)))return;const I=_.flatMap(O=>re(e,O.cloneRange()));(I.length!==i.selector.length||I.some((O,U)=>{var B;return O.toString()!==((B=i.selector[U])==null?void 0:B.quote)}))&&(i={...i,selector:I.map(O=>de(O,e,r)),updated:new Date},p.getAnnotation(i.annotation)?p.updateTarget(i,x.Origin.LOCAL):d.clear())}),a=g=>{K(e,g.target)||(E=X(g),T=E.button===0)},c=g=>{if(!T)return;if(K(e,g.target)){t.dismissOnClickOutside&&d.clear();return}const R=()=>{const{x:N,y:_}=e.getBoundingClientRect(),I=g.target instanceof Node&&e.contains(g.target)&&p.getAt(g.clientX-N,g.clientY-_,l==="all",m);if(I){const{selected:q}=d,O=new Set(q.map(F=>F.id)),U=Array.isArray(I)?I.map(F=>F.id):[I.id];(O.size!==U.length||!U.every(F=>O.has(F)))&&d.userSelect(U,g)}else d.clear()},k=g.timeStamp-E.timeStamp;setTimeout(()=>{const N=document.getSelection();N!=null&&N.isCollapsed&&k<Te?(i=void 0,R()):i&&i.selector.length>0&&(A(),d.userSelect(i.annotation,X(g)))})},y=g=>{const R=document.getSelection();R!=null&&R.isCollapsed||((!i||i.selector.length===0)&&v(g),i&&(A(),d.userSelect(i.annotation,X(g))))},b=g=>{g.key==="Shift"&&i&&(document.getSelection().isCollapsed||(A(),d.userSelect(i.annotation,$(g))))},h=g=>{const R=()=>setTimeout(()=>{(i==null?void 0:i.selector.length)>0&&(d.clear(),p.addAnnotation({id:i.annotation,bodies:[],target:i}),d.userSelect(i.annotation,$(g))),document.removeEventListener("selectionchange",R)},100);document.addEventListener("selectionchange",R),w(g)};z(Xe.join(","),{element:e,keydown:!0,keyup:!1},g=>{g.repeat||(E=$(g))}),z(we,{keydown:!0,keyup:!1},g=>{E=$(g),h(g)});const f=g=>{g.repeat||g.target!==e&&g.target!==document.body||(i=void 0,d.clear())};z(ve.join(","),{keydown:!0,keyup:!1},f);const A=()=>{const g=p.getAnnotation(i.annotation);if(!g){p.addAnnotation({id:i.annotation,bodies:[],target:i});return}const{target:{updated:R}}=g,{updated:k}=i;(!R||!k||R<k)&&p.updateTarget(i)};return e.addEventListener("pointerdown",a),document.addEventListener("pointerup",c),document.addEventListener("contextmenu",y),s&&(e.addEventListener("keyup",b),e.addEventListener("selectstart",w),document.addEventListener("selectionchange",v)),{destroy:()=>{e.removeEventListener("pointerdown",a),document.removeEventListener("pointerup",c),document.removeEventListener("contextmenu",y),e.removeEventListener("keyup",b),e.removeEventListener("selectstart",w),document.removeEventListener("selectionchange",v),z.unbind()},setFilter:C,setUser:u}},Le=(e,n)=>({...e,annotatingEnabled:e.annotatingEnabled??n.annotatingEnabled,user:e.user||n.user}),xe="SPANS",je=(e,n={})=>{ne(e),se(e);const t=Le(n,{annotatingEnabled:!0,user:x.createAnonymousGuest()}),o=Ae(e,t),{selection:s,viewport:r}=o,l=o.store,u=x.createUndoStack(l),m=x.createLifecycleObserver(o,u,t.adapter);let C=t.user;const p=t.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":xe:t.renderer||xe,d=p==="SPANS"?be(e,o,r):p==="CSS_HIGHLIGHTS"?ye(e,o,r):p==="CANVAS"?he(e,o,r):void 0;if(!d)throw`Unknown renderer implementation: ${p}`;console.debug(`Using ${p} renderer`),t.style&&d.setStyle(t.style);const i=Re(e,o,t);return i.setUser(C),{...x.createBaseAnnotator(o,u,t.adapter),destroy:()=>{d.destroy(),i.destroy(),u.destroy()},element:e,getUser:()=>C,setFilter:f=>{d.setFilter(f),i.setFilter(f)},setStyle:f=>d.setStyle(f),setUser:f=>{C=f,i.setUser(f)},setSelected:f=>{f?s.setSelected(f):s.clear()},setPresenceProvider:f=>{f&&(d.setPainter(Ee(f,t.presence)),f.on("selectionChange",()=>d.redraw()))},setVisible:f=>d.setVisible(f),on:m.on,off:m.off,scrollIntoView:ge(e,l),state:o}};Object.defineProperty(S,"Origin",{enumerable:!0,get:()=>x.Origin}),Object.defineProperty(S,"UserSelectAction",{enumerable:!0,get:()=>x.UserSelectAction}),Object.defineProperty(S,"createBody",{enumerable:!0,get:()=>x.createBody}),S.DEFAULT_SELECTED_STYLE=Y,S.DEFAULT_STYLE=H,S.NOT_ANNOTATABLE_CLASS=Q,S.NOT_ANNOTATABLE_SELECTOR=M,S.SelectionHandler=Re,S.W3CTextFormat=We,S.cancelSingleClickEvents=ne,S.cloneKeyboardEvent=$,S.clonePointerEvent=X,S.createCanvasRenderer=he,S.createHighlightsRenderer=ye,S.createPresencePainter=Ee,S.createRenderer=pe,S.createSpansRenderer=be,S.createTextAnnotator=je,S.createTextAnnotatorState=Ae,S.debounce=W,S.fillDefaults=Le,S.getQuoteContext=ie,S.getRangeAnnotatableContents=j,S.isMac=oe,S.isNotAnnotatable=K,S.isRangeAnnotatable=te,S.isRevived=P,S.isWhitespaceOrEmpty=ce,S.mergeClientRects=le,S.paint=me,S.parseW3CTextAnnotation=Se,S.programmaticallyFocusable=se,S.rangeToSelector=de,S.reviveAnnotation=G,S.reviveSelector=J,S.reviveTarget=V,S.scrollIntoView=ge,S.serializeW3CTextAnnotation=Ce,S.splitAnnotatableRanges=re,S.toDomRectList=Pe,S.trimRangeToContainer=ue,S.whitespaceOrEmptyRegex=ae,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
|
3
3
|
//# sourceMappingURL=text-annotator.umd.js.map
|