hypothesis 1.1526.0 → 1.1528.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/boot.js +1 -1
- package/build/manifest.json +8 -8
- package/build/scripts/annotator.bundle.js +9 -9
- package/build/scripts/annotator.bundle.js.map +1 -1
- package/build/scripts/sidebar.bundle.js +23 -23
- package/build/scripts/sidebar.bundle.js.map +1 -1
- package/build/styles/annotator.css +2 -2
- package/build/styles/sidebar.css +2 -2
- package/build/styles/ui-playground.css +2 -2
- package/package.json +11 -11
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?c6124b","styles/annotator.css":"styles/annotator.css?fff16e","styles/annotator.css.map":"styles/annotator.css.map?4dcebd","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?58e394","styles/katex.min.css.map":"styles/katex.min.css.map?1785d7","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?620132","styles/sidebar.css.map":"styles/sidebar.css.map?7780ad","styles/ui-playground.css.map":"styles/ui-playground.css.map?647144","styles/ui-playground.css":"styles/ui-playground.css?cf227f","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?02aa14","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?b1d8ce","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?340899","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?4863fe","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?b19c9e"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1528.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:d,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
package/build/manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
3
|
-
"styles/annotator.css": "styles/annotator.css?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?c6124b",
|
|
3
|
+
"styles/annotator.css": "styles/annotator.css?fff16e",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?4dcebd",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?6b4ebd",
|
|
6
6
|
"styles/highlights.css.map": "styles/highlights.css.map?241350",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"styles/katex.min.css.map": "styles/katex.min.css.map?1785d7",
|
|
9
9
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
|
|
10
10
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
|
|
11
|
-
"styles/sidebar.css": "styles/sidebar.css?
|
|
11
|
+
"styles/sidebar.css": "styles/sidebar.css?620132",
|
|
12
12
|
"styles/sidebar.css.map": "styles/sidebar.css.map?7780ad",
|
|
13
|
-
"styles/ui-playground.css": "styles/ui-playground.css?47f01e",
|
|
14
13
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?647144",
|
|
15
|
-
"
|
|
16
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?085a60",
|
|
14
|
+
"styles/ui-playground.css": "styles/ui-playground.css?cf227f",
|
|
17
15
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?02aa14",
|
|
18
|
-
"scripts/sidebar.bundle.js
|
|
19
|
-
"scripts/
|
|
16
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?b1d8ce",
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?340899",
|
|
18
|
+
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?4863fe",
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?b19c9e"
|
|
20
20
|
}
|
|
@@ -12,7 +12,7 @@ const e=this._methods.get(t.method);if(!e)return;const i=(...e)=>{const i={argum
|
|
|
12
12
|
return A(e.top,e.bottom,t.top,t.bottom)}function R(e,t){return A(e.left,e.right,t.left,t.right)}function P(e,t){if(E(e))return t;if(E(t))return e;const n=Math.min(e.left,t.left),i=Math.min(e.top,t.top),o=Math.max(e.right,t.right),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,i,o-n,r-i)}function I(e){return new DOMPoint((e.left+e.right)/2,(e.top+e.bottom)/2)}function O(e){return e.nodeType===Node.ELEMENT_NODE}function M(e){return e.nodeType===Node.TEXT_NODE}const L=["p",".para"];let B;function D(e,t=0,n=e.data.length){return B||(B=document.createRange()),B.setStart(e,t),B.setEnd(e,n),B.getBoundingClientRect()}function F(e){const t=e.getBoundingClientRect();return t.x-=e.scrollLeft,t.y-=e.scrollTop,t.height=Math.max(t.height,e.scrollHeight),t.width=Math.max(t.width,e.scrollWidth),t}function*H(e,t,n){let i=e.firstChild;for(;i;){if(O(i)){const e=k(F(i),t);n(i)&&e&&(yield*H(i,t,n))}else M(i)&&k(D(i),t)&&(yield i);i=i.nextSibling}}function V(e,t){let n=null;const i=e=>!function(e){
|
|
13
13
|
switch(getComputedStyle(e).position){case"fixed":case"sticky":return!0;default:return!1}}(e);e:for(const s of H(e,t,i)){let e=0;for(const i of s.data.split(/\b/)){if(/\S/.test(i)){const a=e,l=e+i.length,c=D(s,a,l);if(r=c,!E(o=t)&&!E(r)&&r.left>=o.left&&r.right<=o.right&&r.top>=o.top&&r.bottom<=o.bottom){n=document.createRange(),n.setStart(s,a),n.setEnd(s,l);break e}}e+=i.length}}var o,r;return n}function U(e,t=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const i=V(t,n);if(!i)return e(),0;const o=i.getBoundingClientRect().top;e();const r=i.getBoundingClientRect().top-o;return t.scrollTop+=r,r}function q(e,t,n){const i=e.document.querySelector(`link[type="application/annotator+${n}"][rel="${t}"]`);if(!i)throw new Error(`No application/annotator+${n} (rel="${t}") link in the document`);if(!i.href)throw new Error(`application/annotator+${n} (rel="${t}") link has no href`);return i.href}function W(e){return"string"==typeof e?e:null}function $(e){const t=function(e){
|
|
14
14
|
if(!S(e,"hypothesisConfig"))return{};if("function"!=typeof e.hypothesisConfig){const e="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#window.hypothesisConfig";return console.warn("hypothesisConfig must be a function, see: "+e),{}}return e.hypothesisConfig()}(e),n=C(t.ignoreOtherConfiguration)?{}:N(e.document);function i(e){return S(t,e)?t[e]:S(n,e)?n[e]:void 0}return{get annotations(){return W(n.annotations)||function(){const t=e.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get clientUrl(){return q(e,"hypothesis-client","javascript")},get group(){return W(n.group)||function(){const t=e.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get notebookAppUrl(){return q(e,"notebook","html")},get profileAppUrl(){return q(e,"profile","html")},get showHighlights(){return function(){const e=i("showHighlights");switch(e){case"always":case"never":case"whenSidebarOpen":return e;case!0:return"always";case!1:return"never";default:
|
|
15
|
-
return"always"}}()},get sidebarAppUrl(){return q(e,"sidebar","html")},get query(){return W(n.query)||function(){const t=e.location.href.match(/#annotations:(query|q):(.+)$/i);if(t)try{return decodeURIComponent(t[2])}catch
|
|
15
|
+
return"always"}}()},get sidebarAppUrl(){return q(e,"sidebar","html")},get query(){return W(n.query)||function(){const t=e.location.href.match(/#annotations:(query|q):(.+)$/i);if(t)try{return decodeURIComponent(t[2])}catch{}return null}()},get sideBySide(){return function(){const e=i("sideBySide");if(!function(e){return null!==e&&"object"==typeof e}(e))return{mode:"auto"};const t="mode"in e&&function(e){return"string"==typeof e&&["auto","manual"].includes(e)}(e.mode)?e.mode:"auto";return"auto"===t?{mode:t}:{mode:t,isActive:"isActive"in e&&"function"==typeof e.isActive?e.isActive:void 0}}()},hostPageSetting:i}}const z=(e,t)=>e.hostPageSetting(t),j={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:z},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:z},bucketContainerSelector:{defaultValue:null,allowInBrowserExt:!1,getValue:z},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.clientUrl},
|
|
16
16
|
contentInfoBanner:{allowInBrowserExt:!1,defaultValue:null,getValue:z},contentReady:{allowInBrowserExt:!0,defaultValue:null,getValue:z},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:z},group:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:z},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:z},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:z},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:z},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:C,getValue:z},query:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:z},services:{allowInBrowserExt:!1,defaultValue:null,getValue:z},showHighlights:{allowInBrowserExt:!1,defaultValue:"always",getValue:e=>e.showHighlights},notebookAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.notebookAppUrl},profileAppUrl:{allowInBrowserExt:!0,
|
|
17
17
|
defaultValue:null,getValue:e=>e.profileAppUrl},sidebarAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.sidebarAppUrl},subFrameIdentifier:{allowInBrowserExt:!0,defaultValue:null,getValue:z},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:z},sideBySide:{allowInBrowserExt:!0,getValue:e=>e.sideBySide}};function X(e,t=window){const n=$(t),i={};for(const r of function(e){const t={annotator:["clientUrl","contentInfoBanner","contentReady","subFrameIdentifier","sideBySide"],sidebar:["appType","annotations","branding","bucketContainerSelector","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"],profile:["profileAppUrl"]};return"all"===e?Object.values(t).flat():t[e]}(e)){
|
|
18
18
|
const e=j[r],s=void 0!==e.defaultValue,a=!((o=q(t,"sidebar","html")).startsWith("http://")||o.startsWith("https://"));if(!e.allowInBrowserExt&&a){s&&(i[r]=e.defaultValue);continue}const l=e.getValue(n,r);void 0!==l?i[r]=e.coerce?e.coerce(l):l:s&&(i[r]=e.defaultValue)}var o;return i}var Y,G,K,Q,Z,J,ee,te,ne,ie,oe,re={},se=[],ae=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,le=Array.isArray;function ce(e,t){for(var n in t)e[n]=t[n];return e}function ue(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function he(e,t,n,i,o){var r={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==o?++K:o,__i:-1,__u:0};return null==o&&null!=G.vnode&&G.vnode(r),r}function de(e){return e.children}function fe(e,t){this.props=e,this.context=t}function me(e,t){if(null==t)return e.__?me(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?me(e):null}function pe(e){var t,n
|
|
@@ -77,7 +77,7 @@ zIndex:i})}_render(){return Nt(Yn,{isVisible:this._isVisible,arrowDirection:this
|
|
|
77
77
|
}({});class ai{constructor(e,t){if(t<0)throw new Error("Offset is invalid");this.element=e,this.offset=t}relativeTo(e){if(!e.contains(this.element))throw new Error("Parent is not an ancestor of current element");let t=this.element,n=this.offset;for(;t!==e;)n+=oi(t),t=t.parentElement;return new ai(t,n)}resolve(e={}){try{return ri(this.element,this.offset)[0]}catch(t){if(0===this.offset&&void 0!==e.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const i=e.direction===si.FORWARDS,o=i?n.nextNode():n.previousNode();if(!o)throw t;return{node:o,offset:i?0:o.data.length}}throw t}}static fromCharOffset(e,t){switch(e.nodeType){case Node.TEXT_NODE:return ai.fromPoint(e,t);case Node.ELEMENT_NODE:return new ai(e,t);default:throw new Error("Node is not an element or text node")}}static fromPoint(e,t){switch(e.nodeType){case Node.TEXT_NODE:{if(t<0||t>e.data.length)throw new Error("Text node offset is out of range")
|
|
78
78
|
;if(!e.parentElement)throw new Error("Text node has no parent");const n=oi(e)+t;return new ai(e.parentElement,n)}case Node.ELEMENT_NODE:{if(t<0||t>e.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let i=0;i<t;i++)n+=ii(e.childNodes[i]);return new ai(e,n)}default:throw new Error("Point is not in an element or text node")}}}class li{constructor(e,t){this.start=e,this.end=t}relativeTo(e){return new li(this.start.relativeTo(e),this.end.relativeTo(e))}toRange(){let e,t;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[e,t]=ri(this.start.element,this.start.offset,this.end.offset):(e=this.start.resolve({direction:si.FORWARDS}),t=this.end.resolve({direction:si.BACKWARDS}));const n=new Range;return n.setStart(e.node,e.offset),n.setEnd(t.node,t.offset),n}static fromRange(e){const t=ai.fromPoint(e.startContainer,e.startOffset),n=ai.fromPoint(e.endContainer,e.endOffset);return new li(t,n)}static fromOffsets(e,t,n){return new li(new ai(e,t),new ai(e,n))}
|
|
79
79
|
static trimmedRange(e){return function(e){if(!e.toString().trim().length)throw new RangeError("Range contains no non-whitespace text");if(e.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(e.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const t=e.cloneRange();let n=!1,i=!1;const o={start:ti(e.startContainer.textContent,e.startOffset,ei.Forwards),end:ti(e.endContainer.textContent,e.endOffset,ei.Backwards)};if(o.start>=0&&(t.setStart(e.startContainer,o.start),n=!0),o.end>0&&(t.setEnd(e.endContainer,o.end),i=!0),n&&i)return t;if(!n){const{node:e,offset:n}=ni(t,ei.Forwards);e&&n>=0&&t.setStart(e,n)}if(!i){const{node:e,offset:n}=ni(t,ei.Backwards);e&&n>0&&t.setEnd(e,n)}return t}(li.fromRange(e).toRange())}}const ci=".annotator-placeholder";function ui(e){return!!e.parentElement&&null!==e.parentElement.closest(ci)}function hi(e,t){const n=new Range
|
|
80
|
-
;return e.compareBoundaryPoints(Range.START_TO_START,t)<=0?n.setStart(e.startContainer,e.startOffset):n.setStart(t.startContainer,t.startOffset),e.compareBoundaryPoints(Range.END_TO_END,t)>=0?n.setEnd(e.endContainer,e.endOffset):n.setEnd(t.endContainer,t.endOffset),n}function di(e=document.getSelection()){if(!e||0===e.rangeCount)return null;let t=e.getRangeAt(0);for(let n=1;n<e.rangeCount;n++)t=hi(t,e.getRangeAt(n));return t.collapsed?null:t}function fi(e){if(e.focusNode===e.anchorNode)return e.focusOffset<e.anchorOffset;return di(e).startContainer===e.focusNode}function mi(e,t){try{const n=t.nodeValue?.length??t.childNodes.length;return e.comparePoint(t,0)<=0&&e.comparePoint(t,n)>=0}catch
|
|
80
|
+
;return e.compareBoundaryPoints(Range.START_TO_START,t)<=0?n.setStart(e.startContainer,e.startOffset):n.setStart(t.startContainer,t.startOffset),e.compareBoundaryPoints(Range.END_TO_END,t)>=0?n.setEnd(e.endContainer,e.endOffset):n.setEnd(t.endContainer,t.endOffset),n}function di(e=document.getSelection()){if(!e||0===e.rangeCount)return null;let t=e.getRangeAt(0);for(let n=1;n<e.rangeCount;n++)t=hi(t,e.getRangeAt(n));return t.collapsed?null:t}function fi(e){if(e.focusNode===e.anchorNode)return e.focusOffset<e.anchorOffset;return di(e).startContainer===e.focusNode}function mi(e,t){try{const n=t.nodeValue?.length??t.childNodes.length;return e.comparePoint(t,0)<=0&&e.comparePoint(t,n)>=0}catch{return!1}}function pi(e,t){const n=e.commonAncestorContainer,i=n.ownerDocument.createNodeIterator(n,NodeFilter.SHOW_ALL);let o;for(;o=i.nextNode();)mi(e,o)&&t(o)}function gi(e){const t=di(e);if(!t)return null;const n=function(e){const t=[];return pi(e,(e=>{M(e)&&!e.textContent.match(/^\s*$/)&&t.push(e)})),t.flatMap((t=>{
|
|
81
81
|
const n=t.ownerDocument.createRange();if(n.selectNodeContents(t),t===e.startContainer&&n.setStart(t,e.startOffset),t===e.endContainer&&n.setEnd(t,e.endOffset),n.collapsed)return[];const i=Array.from(n.getClientRects());return n.detach(),i}))}(t);return 0===n.length?null:fi(e)?n[0]:n[n.length-1]}const _i="http://www.w3.org/2000/svg",bi=["user-annotations","user-highlights","other-content"];function vi(e,t){const n=function(e){if(e.collapsed)return[];let t=e.commonAncestorContainer;if(t&&t.nodeType!==Node.ELEMENT_NODE&&(t=t.parentElement),!t)return[];const n=[],i=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT);let o;for(;o=i.nextNode();){if(!mi(e,o))continue;const t=o;t===e.startContainer&&e.startOffset>0?t.splitText(e.startOffset):(t===e.endContainer&&e.endOffset<t.data.length&&t.splitText(e.endOffset),n.push(t))}return n}(e),i=n.length>0&&ui(n[0]);let o=[],r=null,s=null;n.forEach((e=>{r&&r.nextSibling===e?s.push(e):(s=[e],o.push(s)),r=e}));const a=/^\s*$/;o=o.filter((e=>{const t=e[0].parentElement
|
|
82
82
|
;return 1===t?.childNodes.length&&"SPAN"===t?.tagName||e.some((e=>!a.test(e.data)))}));const l=[];return o.forEach((e=>{const n=document.createElement("hypothesis-highlight");n.className=xt("hypothesis-highlight",t);e[0].parentNode.replaceChild(n,e[0]),e.forEach((e=>n.appendChild(e))),l.push(n)})),i||function(e,t){if(0===e.length)return;const n=function(e){const t=e.closest(".page");if(!t)return null;return t.querySelector(".canvasWrapper > canvas")||null}(e[0]);if(!n||!n.parentElement)return;let i=n.parentElement.querySelector(".hypothesis-highlight-layer");if(!i){i=document.createElementNS(_i,"svg"),i.setAttribute("class","hypothesis-highlight-layer"),n.parentElement.appendChild(i),n.parentElement.style.position="relative";const e=i.style;e.position="absolute",e.left="0",e.top="0",e.width="100%",e.height="100%",e.mixBlendMode="multiply"}const o=n.getBoundingClientRect(),r=e.map((e=>{const n=e.getBoundingClientRect(),i=document.createElementNS(_i,"rect");return i.setAttribute("x",(n.left-o.left).toString()),
|
|
83
83
|
i.setAttribute("y",(n.top-o.top).toString()),i.setAttribute("width",n.width.toString()),i.setAttribute("height",n.height.toString()),i.setAttribute("class",xt("hypothesis-svg-highlight",t)),e.classList.add("is-transparent"),e.svgHighlight=i,i}));i.append(...r)}(l,t),l}function yi(e,t){const n=e.parentNode;t.forEach((t=>n.insertBefore(t,e))),e.remove()}function wi(e){xi(e,!1);for(const t of e){if(t.parentNode){yi(t,Array.from(t.childNodes))}t.svgHighlight&&t.svgHighlight.remove()}}function xi(e,t){e.forEach((e=>{e.svgHighlight?function(e,t){const n=e.parentNode,i=e.getAttribute("data-focused-id");if(Boolean(i)!==t)if(t){e.setAttribute("data-focused-id",r(8));const t=e.cloneNode();t.setAttribute("data-is-focused","data-is-focused"),n.append(t)}else{const t=n.querySelector(`[data-focused-id="${i}"][data-is-focused]`);t?.remove(),e.removeAttribute("data-focused-id")}}(e.svgHighlight,t):e.classList.toggle("hypothesis-highlight-focused",t)}))}function Ci(e){Ei(Si(e)),function(e){for(const[t,n]of function(e){
|
|
@@ -91,7 +91,7 @@ this._features.on("flagsChanged",(()=>{this._activate(this._isActive())})),this.
|
|
|
91
91
|
active:this._isActive(),availableStyles:Di,currentStyles:this.appliedStyles,onStyleChange:(e,t)=>this._onChangeClusterStyle(e,t)})}}function Vi(e){return e.split("").reverse().join("")}function Ui(e){return(e|-e)>>31&1}function qi(e,t,n,i){let o=e.P[n],r=e.M[n];const s=i>>>31,a=t[n]|s,l=a|r,c=(a&o)+o^o|a;let u=r|~(c|o),h=o&c;const d=Ui(u&e.lastRowMask[n])-Ui(h&e.lastRowMask[n]);return u<<=1,h<<=1,h|=s,u|=Ui(i)-s,o=h|~(l|u),r=u&l,e.P[n]=o,e.M[n]=r,d}function Wi(e,t,n){if(0===t.length)return[];n=Math.min(n,t.length);const i=[],o=32,r=Math.ceil(t.length/o)-1,s={P:new Uint32Array(r+1),M:new Uint32Array(r+1),lastRowMask:new Uint32Array(r+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[r]=1<<(t.length-1)%o;const a=new Uint32Array(r+1),l=new Map,c=[];for(let e=0;e<256;e++)c.push(a);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(l.has(n))continue;const i=new Uint32Array(r+1);l.set(n,i),n<c.length&&(c[n]=i);for(let e=0;e<=r;e+=1){i[e]=0;for(let r=0;r<o;r+=1){const s=e*o+r;if(s>=t.length)continue
|
|
92
92
|
;t.charCodeAt(s)===n&&(i[e]|=1<<r)}}}let u=Math.max(0,Math.ceil(n/o)-1);const h=new Uint32Array(r+1);for(let e=0;e<=u;e+=1)h[e]=(e+1)*o;h[r]=t.length;for(let e=0;e<=u;e+=1)s.P[e]=-1,s.M[e]=0;for(let d=0;d<e.length;d+=1){const f=e.charCodeAt(d);let m;f<c.length?m=c[f]:(m=l.get(f),void 0===m&&(m=a));let p=0;for(let e=0;e<=u;e+=1)p=qi(s,m,e,p),h[e]+=p;if(h[u]-p<=n&&u<r&&(1&m[u+1]||p<0)){let e;if(u+=1,s.P[u]=-1,s.M[u]=0,u===r){const n=t.length%o;e=0===n?o:n}else e=o;h[u]=h[u-1]+e-p+qi(s,m,u,p)}else for(;u>0&&h[u]>=n+o;)u-=1;u===r&&h[u]<=n&&(h[u]<n&&i.splice(0,i.length),i.push({start:-1,end:d+1,errors:h[u]}),n=h[u])}return i}function $i(e,t,n){return function(e,t,n){const i=Vi(t);return n.map((n=>{const o=Math.max(0,n.end-t.length-n.errors);return{start:Wi(Vi(e.slice(o,n.end)),i,n.errors).reduce(((e,t)=>n.end-t.end<e?n.end-t.end:e),n.end),end:n.end,errors:n.errors}}))}(e,t,Wi(e,t,n))}function zi(e,t,n){let i=0;const o=[];for(;-1!==i;)i=e.indexOf(t,i),-1!==i&&(o.push({start:i,end:i+t.length,errors:0}),i+=1)
|
|
93
93
|
;return o.length>0?o:$i(e,t,n)}function ji(e,t){if(0===t.length||0===e.length)return 0;return 1-zi(e,t,t.length)[0].errors/t.length}function Xi(e,t,n={}){if(0===t.length)return null;const i=Math.min(256,t.length/2),o=zi(e,t,i);if(0===o.length)return null;const r=i=>{const o=1-i.errors/t.length,r=n.prefix?ji(e.slice(Math.max(0,i.start-n.prefix.length),i.start),n.prefix):1,s=n.suffix?ji(e.slice(i.end,i.end+n.suffix.length),n.suffix):1;let a=1;if("number"==typeof n.hint){a=1-Math.abs(i.start-n.hint)/e.length}return(50*o+20*r+20*s+2*a)/92},s=o.map((e=>({start:e.start,end:e.end,score:r(e)})));return s.sort(((e,t)=>t.score-e.score)),s[0]}function Yi(e){const t=function(e){const t=e.nodeName.toLowerCase();return"#text"===t?"text()":t}(e),n=function(e){let t=0,n=e;for(;n;)n.nodeName===e.nodeName&&(t+=1),n=n.previousSibling;return t}(e);return`${t}[${n}]`}function Gi(e,t){let n="",i=e;for(;i!==t;){if(!i)throw new Error("Node is not a descendant of root");n=Yi(i)+"/"+n,i=i.parentNode}return n="/"+n,
|
|
94
|
-
n=n.replace(/\/$/,""),n}function Ki(e,t,n){t=t.toUpperCase();let i=-1;for(let o=0;o<e.children.length;o++){const r=e.children[o];if(r.nodeName.toUpperCase()===t&&(++i,i===n))return r}return null}function Qi(e,t=document.body){try{return function(e,t){if(null===e.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+\])?)+$/))throw new Error("Expression is not a simple XPath");const n=e.split("/");let i=t;n.shift();for(const e of n){let t,n;const o=e.indexOf("[");if(-1!==o){t=e.slice(0,o);const i=e.slice(o+1,e.indexOf("]"));if(n=parseInt(i)-1,n<0)return null}else t=e,n=0;const r=Ki(i,t,n);if(!r)return null;i=r}return i}(e,t)}catch
|
|
94
|
+
n=n.replace(/\/$/,""),n}function Ki(e,t,n){t=t.toUpperCase();let i=-1;for(let o=0;o<e.children.length;o++){const r=e.children[o];if(r.nodeName.toUpperCase()===t&&(++i,i===n))return r}return null}function Qi(e,t=document.body){try{return function(e,t){if(null===e.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+\])?)+$/))throw new Error("Expression is not a simple XPath");const n=e.split("/");let i=t;n.shift();for(const e of n){let t,n;const o=e.indexOf("[");if(-1!==o){t=e.slice(0,o);const i=e.slice(o+1,e.indexOf("]"));if(n=parseInt(i)-1,n<0)return null}else t=e,n=0;const r=Ki(i,t,n);if(!r)return null;i=r}return i}(e,t)}catch{return document.evaluate("."+e,t,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}}class Zi{constructor(e,t){this.root=e,this.range=t}static fromRange(e,t){return new Zi(e,t)}static fromSelector(e,t){const n=Qi(t.startContainer,e);if(!n)throw new Error("Failed to resolve startContainer XPath");const i=Qi(t.endContainer,e);if(!i)throw new Error("Failed to resolve endContainer XPath")
|
|
95
95
|
;const o=ai.fromCharOffset(n,t.startOffset),r=ai.fromCharOffset(i,t.endOffset),s=new li(o,r).toRange();return new Zi(e,s)}toRange(){return this.range}toSelector(){const e=li.fromRange(this.range).toRange(),t=li.fromRange(e),n=Gi(t.start.element,this.root),i=Gi(t.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:t.start.offset,endContainer:i,endOffset:t.end.offset}}}class Ji{constructor(e,t,n){this.root=e,this.start=t,this.end=n}static fromRange(e,t){const n=li.fromRange(t).relativeTo(e);return new Ji(e,n.start.offset,n.end.offset)}static fromSelector(e,t){return new Ji(e,t.start,t.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return li.fromOffsets(this.root,this.start,this.end).toRange()}}class eo{constructor(e,t,n={}){this.root=e,this.exact=t,this.context=n}static fromRange(e,t){const n=e.textContent,i=li.fromRange(t).relativeTo(e),o=i.start.offset,r=i.end.offset;return new eo(e,n.slice(o,r),{prefix:n.slice(Math.max(0,o-32),o),
|
|
96
96
|
suffix:n.slice(r,Math.min(n.length,r+32))})}static fromSelector(e,t){const{prefix:n,suffix:i}=t;return new eo(e,t.exact,{prefix:n,suffix:i})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(e={}){return this.toPositionAnchor(e).toRange()}toPositionAnchor(e={}){const t=Xi(this.root.textContent,this.exact,{...this.context,hint:e.hint});if(!t)throw new Error("Quote not found");return new Ji(this.root,t.start,t.end)}}function to(e){const t=parseFloat(e);return!Number.isFinite(t)||t<0?null:t}function no(e){return e instanceof Element?e:e.parentElement}function io(e,t=e){const n=to(e?.getAttribute("data-time-start")??""),i=to(t?.getAttribute("data-time-end")??"");return"number"!=typeof n||"number"!=typeof i||i<n?null:[n,i]}class oo{constructor(e,t,n){this.root=e,this.start=t,this.end=n}static fromRange(e,t){const n=no(t.startContainer)?.closest("[data-time-start]"),i=no(t.endContainer)?.closest("[data-time-end]"),o=io(n,i);if(!o)return null
|
|
97
97
|
;const[r,s]=o;return new oo(e,r,s)}toRange(){const e=[...this.root.querySelectorAll("[data-time-start]")].map((e=>{const t=io(e);if(!t)return null;const[n,i]=t;return{element:e,start:n,end:i}})).filter((e=>null!==e));e.sort(((e,t)=>e.start-t.start));const t=function(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}(e,(e=>e.start<=this.start&&e.end>=this.start));if(-1===t)throw new Error("Start segment not found");const n=t+e.slice(t).findIndex((e=>e.start<=this.end&&e.end>=this.end));if(-1===n)throw new Error("End segment not found");const i=new Range;i.setStart(e[t].element,0);const o=e[n].element;return i.setEnd(o,o.childNodes.length),i}static fromSelector(e,t){const{start:n,end:i}=t;return new oo(e,n,i)}toSelector(){return{type:"MediaTimeSelector",start:this.start,end:this.end}}}async function ro(e,t){return e.toRange(t)}function so(e,t,n){const i=e[t];if("function"!=typeof i)throw new Error("Can only intercept functions");return e[t]=(...t)=>{const o=i.call(e,...t);return n(...t),o},()=>{
|
|
@@ -101,9 +101,9 @@ t._scrollSettings=null,o.end(e);var c=1-o.ease(l);if(n(t,s.x-s.differenceX*c,s.y
|
|
|
101
101
|
;var u=a(n),h=1,d=l.validTarget||s,f=l.isScrollable;l.debug&&(console.log("About to scroll to",n),u||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var m=[];u;)if(l.debug&&console.log("Scrolling parent node",u),d(u,h)&&(f?f(u,r):r(u))&&(h++,m.push(u)),!(u=a(u))){p(e);break}return m.reduce(((e,r,s)=>function(e,n,r,s,a){var l,c=!n._scrollSettings,u=n._scrollSettings,h=Date.now(),d={passive:!0};function f(e){n._scrollSettings=null,n.parentElement&&n.parentElement._scrollSettings&&n.parentElement._scrollSettings.end(e),r.debug&&console.log("Scrolling ended with type",e,"for",n),a(e),l&&(n.removeEventListener("touchstart",l,d),n.removeEventListener("wheel",l,d))}u&&u.end(t);var m=r.maxSynchronousAlignments;return null==m&&(m=3),n._scrollSettings={startTime:h,endIterations:0,target:e,time:r.time,ease:r.ease,align:r.align,isWindow:r.isWindow||o,maxSynchronousAlignments:m,end:f,scrollAncestor:s},"cancellable"in r&&!r.cancellable||(l=f.bind(null,t),n.addEventListener("touchstart",l,d),
|
|
102
102
|
n.addEventListener("wheel",l,d)),c&&i(n),l}(n,r,l,m[s+1],p)),null)}function p(e){--h||c&&c(e)}},co}(),fo=t(ho);function mo(e,t,n){return e+n*(t-e)}async function po(e,t,{maxDuration:n=500}={}){const i=e.scrollTop,o=t,r=Date.now(),s=Math.min(Math.abs(o-i)/3,n);let a=0;for(;a<1;)await new Promise((e=>{requestAnimationFrame(e)})),a=Math.min(1,(Date.now()-r)/s),e.scrollTop=mo(i,o,a)}function go(e,t=document.baseURI){return new URL(e,t).href.toString().replace(/#.*/,"")}class _o{constructor(e={}){this.document=e.document||document}uri(){let e=this._getDocumentHref();try{e=decodeURIComponent(e)}catch(e){console.error("Error decoding URI:",e)}const t=this._getLinks();for(const n of t)"canonical"===n.rel&&(e=n.href);return e}getDocumentMetadata(){const e={title:document.title,link:[],dc:this._getMetaTags("name","dc."),eprints:this._getMetaTags("name","eprints."),facebook:this._getMetaTags("property","og:"),highwire:this._getMetaTags("name","citation_"),prism:this._getMetaTags("name","prism."),
|
|
103
103
|
twitter:this._getMetaTags("name","twitter:")},t=this._getFavicon();t&&(e.favicon=t),e.title=this._getTitle(e),e.link=this._getLinks(e);const n=e.link.find((e=>e.href.startsWith("urn:x-dc")));return n&&(e.documentFingerprint=n.href),e}_getMetaTags(e,t){const n={};for(const i of Array.from(this.document.querySelectorAll("meta"))){const o=i.getAttribute(e),{content:r}=i;if(o&&r){const e=o.match(RegExp(`^${t}(.+)$`,"i"));if(e){const t=e[1].toLowerCase();n[t]?n[t].push(r):n[t]=[r]}}}return n}_getTitle(e){return e.highwire.title?e.highwire.title[0]:e.eprints.title?e.eprints.title[0]:e.prism.title?e.prism.title[0]:e.facebook.title?e.facebook.title[0]:e.twitter.title?e.twitter.title[0]:e.dc.title?e.dc.title[0]:this.document.title}_getLinks(e={dc:{},highwire:{}}){const t=[{href:this._getDocumentHref()}],n=Array.from(this.document.querySelectorAll("link"));for(const e of n)if(["alternate","canonical","bookmark","shortlink"].includes(e.rel)){if("alternate"===e.rel){
|
|
104
|
-
if(e.type&&e.type.match(/^application\/(rss|atom)\+xml/))continue;if(e.hreflang)continue}try{const n=this._absoluteUrl(e.href);t.push({href:n,rel:e.rel,type:e.type})}catch
|
|
104
|
+
if(e.type&&e.type.match(/^application\/(rss|atom)\+xml/))continue;if(e.hreflang)continue}try{const n=this._absoluteUrl(e.href);t.push({href:n,rel:e.rel,type:e.type})}catch{}}for(const n of Object.keys(e.highwire)){const i=e.highwire[n];if("pdf_url"===n)for(const e of i)try{t.push({href:this._absoluteUrl(e),type:"application/pdf"})}catch{}if("doi"===n)for(let e of i)"doi:"!==e.slice(0,4)&&(e=`doi:${e}`),t.push({href:e})}for(const n of Object.keys(e.dc)){const i=e.dc[n];if("identifier"===n)for(const e of i)"doi:"===e.slice(0,4)&&t.push({href:e})}const i=e.dc["relation.ispartof"],o=e.dc.identifier;if(i&&o){const e=i[i.length-1],n=o[o.length-1],r="urn:x-dc:"+encodeURIComponent(e)+"/"+encodeURIComponent(n);t.push({href:r})}return t}_getFavicon(){let e=null;for(const t of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(t.rel))try{e=this._absoluteUrl(t.href)}catch{}return e}_absoluteUrl(e){return go(e,this.document.baseURI)}_getDocumentHref(){
|
|
105
105
|
const{href:e}=this.document.location,t=["http:","https:","file:"],n=new URL(e).protocol;return t.includes(n)?e:this.document.baseURI&&t.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:e}}class bo extends h.TinyEmitter{constructor({features:e,container:t=document.body,sideBySideOptions:n}){super(),this.features=e,this.container=t,this._htmlMeta=new _o,this._prevURI=this._htmlMeta.uri(),this._sideBySideEnabled=!0,this._sideBySideOptions=n??{mode:"auto"},this._sideBySideActive=!1,this._lastLayout=null,this._navObserver=new lo((()=>this._checkForURIChange())),this._metaObserver=new MutationObserver((()=>this._checkForURIChange())),this._metaObserver.observe(document.head,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["rel","href","name","content"]}),this._flagsChanged=()=>{},this.features.on("flagsChanged",this._flagsChanged)}anchor(e,t){return function(e,t,n={}){let i=null,o=null,r=null,s=null;for(const e of t)switch(e.type){case"TextPositionSelector":o=e,n.hint=o.start;break
|
|
106
|
-
;case"TextQuoteSelector":r=e;break;case"RangeSelector":s=e;break;case"MediaTimeSelector":i=e}const a=e=>{if(r?.exact&&e.toString()!==r.exact)throw new Error("quote mismatch");return e};let l=Promise.reject("unable to anchor");if(s){const t=s;l=l.catch((()=>ro(Zi.fromSelector(e,t),n).then(a)))}if(o){const t=o;l=l.catch((()=>ro(Ji.fromSelector(e,t),n).then(a)))}if(r){const t=r;l=l.catch((()=>ro(eo.fromSelector(e,t),n)))}if(i){const t=i;l=l.catch((()=>oo.fromSelector(e,t).toRange()))}return l}(e,t)}describe(e,t){return function(e,t){const n=[oo,Zi,Ji,eo],i=[];for(const o of n)try{const n=o.fromRange(e,t);n&&i.push(n.toSelector())}catch
|
|
106
|
+
;case"TextQuoteSelector":r=e;break;case"RangeSelector":s=e;break;case"MediaTimeSelector":i=e}const a=e=>{if(r?.exact&&e.toString()!==r.exact)throw new Error("quote mismatch");return e};let l=Promise.reject("unable to anchor");if(s){const t=s;l=l.catch((()=>ro(Zi.fromSelector(e,t),n).then(a)))}if(o){const t=o;l=l.catch((()=>ro(Ji.fromSelector(e,t),n).then(a)))}if(r){const t=r;l=l.catch((()=>ro(eo.fromSelector(e,t),n)))}if(i){const t=i;l=l.catch((()=>oo.fromSelector(e,t).toRange()))}return l}(e,t)}describe(e,t){return function(e,t){const n=[oo,Zi,Ji,eo],i=[];for(const o of n)try{const n=o.fromRange(e,t);n&&i.push(n.toSelector())}catch{}return i}(e,t)}_checkForURIChange(){const e=this._htmlMeta.uri();e!==this._prevURI&&(this._prevURI=e,this.emit("uriChanged",e))}getAnnotatableRange(e){try{return li.trimmedRange(e)}catch(e){if(e instanceof RangeError)return null;throw e}}canStyleClusteredHighlights(){return!0}destroy(){this._deactivateSideBySide(),this._navObserver.disconnect(),this._metaObserver.disconnect(),
|
|
107
107
|
this.features.off("flagsChanged",this._flagsChanged)}contentContainer(){return this.container}fitSideBySide(e){this._lastLayout=e;const t=window.innerWidth-e.width,n=this._sideBySideEnabled&&"auto"===this._sideBySideOptions.mode&&e.expanded&&t>=480;return n?this._activateSideBySide(e.width):this._sideBySideActive&&this._deactivateSideBySide(),this._sideBySideActive=n,this.container.classList.toggle("hypothesis-sidebyside-active",this._sideBySideActive),n}sideBySideActive(){return this._sideBySideActive}_activateSideBySide(e){const t=e+12,n=e=>parseInt(window.getComputedStyle(e).marginLeft,10);U((()=>{document.body.style.marginLeft="",document.body.style.marginRight="";const e=n(document.body);document.body.style.marginRight=`${t}px`;const i=function(e){const t=new Map,n=new Map,i=L.join(","),o=Array.from(e.querySelectorAll(i)).map((e=>({rect:e.getBoundingClientRect(),textLength:e.textContent.length}))).filter((({rect:e})=>e.width>0&&e.height>0)).sort(((e,t)=>t.textLength-e.textLength)).slice(0,15)
|
|
108
108
|
;if(o.forEach((({rect:e})=>{let i=t.get(e.left)??0;i+=1,t.set(e.left,i);let o=n.get(e.right)??0;o+=1,n.set(e.right,o)})),0===t.size||0===n.size)return null;const r=[...t.entries()].sort(((e,t)=>t[1]-e[1])),s=[...n.entries()].sort(((e,t)=>t[1]-e[1])),[a]=r[0],[l]=s[0];return{left:a,right:l}}(document.body);if(i){const o=Math.max(0,window.innerWidth-t-i.right);if(o>0){const e=Math.max(0,t-o);document.body.style.marginRight=`${e}px`}n(document.body)>e&&(document.body.style.marginLeft=`${e}px`),i.left<12&&(document.body.style.marginLeft="12px")}else document.body.style.marginLeft="",document.body.style.marginRight=""}))}_deactivateSideBySide(){U((()=>{document.body.style.marginLeft="",document.body.style.marginRight=""}))}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}async scrollToAnchor(e){const t=e.highlights?.[0];t&&await async function(e,{maxDuration:t=500}={}){const n=e.closest("body");n&&"BODY"!==n.tagName&&Object.defineProperty(n,"tagName",{
|
|
109
109
|
value:"BODY",configurable:!0});const i=e.closest("details");i&&!i.hasAttribute("open")&&(i.open=!0),await new Promise((n=>fo(e,{time:t},n)))}(t)}}var vo,yo;var wo=function(){if(yo)return vo;yo=1;var t=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt,l="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,u=l||c||Function("return this")(),h=Object.prototype.toString,d=Math.max,f=Math.min,m=function(){return u.Date.now()};function p(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&h.call(e)==n}(e))return t;if(p(e)){var l="function"==typeof e.valueOf?e.valueOf():e;e=p(l)?l+"":l}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var c=r.test(e);return c||s.test(e)?a(e.slice(2),c?2:8):o.test(e)?t:+e}return vo=function(e,t,n){var i,o,r,s,a,l,c=0,u=!1,h=!1,_=!0
|
|
@@ -119,9 +119,9 @@ target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",un
|
|
|
119
119
|
const e=await this._loaded,{info:t,contentDispositionFilename:n,metadata:i}=await e.pdfDocument.getMetadata(),o=Xo(e),r=Go(e);let s;s=i?.has("dc:title")&&"Untitled"!==i.get("dc:title")?i.get("dc:title"):t?.Title?t.Title:n||(r?function(e){const t=new URL(e),n=t.pathname.split("/");return n[n.length-1]}(r):"");const a=[{href:Yo(o)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:o}}}function Xo(e){return Array.isArray(e.pdfDocument.fingerprints)?e.pdfDocument.fingerprints[0]:e.pdfDocument.fingerprint}function Yo(e){return`urn:x-pdf:${e}`}function Go(e){if(!e.url)return null;const t=go(e.url);return 0!==t.indexOf("file://")?t:null}function Ko(e){const t=e.highlights?.[0];return t&&ui(t)}function Qo(e){return new Promise((t=>setTimeout(t,e)))}class Zo{constructor(){this._pdfjsContainer=document.querySelector("#outerContainer"),this._contentInfo=null,this._noTextWarning=!1,this._container=null}setContentInfo(e){this._contentInfo=e,this._update()}showNoTextWarning(e){this._noTextWarning=e,
|
|
120
120
|
this._update()}destroy(){this._container?.destroy()}_update(){if(!(this._noTextWarning||this._contentInfo))return this._container?.destroy(),this._container=null,void(this._pdfjsContainer.style.height="");this._container||(this._container=new Kn("banner",(()=>this._render())),document.body.prepend(this._container.element)),this._container.render();const e=this._container.element.getBoundingClientRect().height;this._pdfjsContainer.style.height=`calc(100% - ${e}px)`}_render(){return Nt(Wo,{children:[this._contentInfo&&Nt($o,{info:this._contentInfo}),this._noTextWarning&&Nt(zo,{})]})}}class Jo extends h.TinyEmitter{constructor(e,t={}){super(),this._annotator=e;const n=window,o=n.PDFViewerApplication;this._pdfViewer=o.pdfViewer,this._pdfViewer.viewer.classList.add("has-transparent-text-layer"),this._pdfContainer=o.appConfig?.appContainer??document.body,this._pdfMetadata=new jo(o),this._observer=new MutationObserver(xo((()=>this._update()),100)),this._observer.observe(this._pdfViewer.viewer,{attributes:!0,
|
|
121
121
|
attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=t.reanchoringMaxWait??3e3,this._banner=new Zo,this._checkForSelectableText(),this._sideBySideActive=!1,this._updateAnnotationLayerVisibility=()=>{const e=n.getSelection();this._pdfViewer.viewer.classList.toggle("is-selecting",!e.isCollapsed)},this._listeners=new i,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){this.fitSideBySide({expanded:!1,width:0,toolbarWidth:0,height:window.innerHeight}),this._listeners.removeAll(),this._pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this._observer.disconnect(),this._banner.destroy(),this._destroyed=!0}uri(){return this._pdfMetadata.getUri()}getMetadata(){return this._pdfMetadata.getMetadata()}showContentInfo(e){this._banner.setContentInfo(e)}anchor(e,t){return Vo(0,t)}getAnnotatableRange(e){try{const t=li.trimmedRange(e);if(function(e){try{return Uo(e),!0}catch{return!1}}(t))return t}catch(e){
|
|
122
|
-
if(!(e instanceof RangeError))throw e}return null}canStyleClusteredHighlights(){return!0}describe(e,t){return qo(e,t)}async _checkForSelectableText(){try{await this.uri()}catch
|
|
122
|
+
if(!(e instanceof RangeError))throw e}return null}canStyleClusteredHighlights(){return!0}describe(e,t){return qo(e,t)}async _checkForSelectableText(){try{await this.uri()}catch{return}if(!this._destroyed)try{const e=await async function(){const e=Po();let t=!1;for(let n=0;n<e.pagesCount;n++)if((await Oo(n)).trim().length>0){t=!0;break}return t}();this._banner.showNoTextWarning(!e)}catch(e){console.warn("Unable to check for text in PDF:",e)}}_update(){const e=[],t=this._pdfViewer.pagesCount;for(let e=0;e<t;e++){const t=this._pdfViewer.getPageView(e);if(t?.textLayer&&Do(t.textLayer))switch(t.renderingState){case Eo.INITIAL:t.textLayer=null;break;case Eo.FINISHED:n=t.div,n.querySelector(ci)?.remove()}}var n;for(const t of this._annotator.anchors)if(t.highlights){if(e.includes(t.annotation))continue;for(let n=0;n<t.highlights.length;n++){const i=t.highlights[n];if(!document.body.contains(i)){t.highlights.splice(n,1),delete t.range,e.push(t.annotation);break}}}e.map((e=>this._annotator.anchor(e)))}
|
|
123
123
|
contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(e){const t=window.innerWidth-e.width,n=e.expanded&&t>=680,i=n?e.width:e.toolbarWidth;this._pdfContainer.style.width=`calc(100% - ${i}px)`;const o=this._pdfViewer.currentScaleValue;return"auto"!==o&&"page-fit"!==o&&"page-width"!==o||(this._pdfViewer.currentScaleValue=o),this._pdfViewer.update(),this._sideBySideActive=n,n}sideBySideActive(){return this._sideBySideActive}async scrollToAnchor(e){const t=e.annotation,n=Ko(e),i=this._anchorOffset(e);if(null!==i&&(await po(this.contentContainer(),i),n)){const e=await this._waitForAnnotationToBeAnchored(t,this._reanchoringMaxWait);if(!e)return;const n=this._anchorOffset(e);if(null===n)return;await po(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(e,t){const n=Date.now();let i;do{i=this._annotator.anchors.find((t=>t.annotation===e)),i&&!Ko(i)||(i=null,await Qo(20))}while(!i&&Date.now()-n<t);return i??null}_anchorOffset(e){if(!e.highlights)return null
|
|
124
|
-
;return function(e,t){let n=0;for(;e!==t&&t.contains(e);)n+=e.offsetTop,e=e.offsetParent;return n}(e.highlights[0],this.contentContainer())}}function er(e){if(!e.includes("["))return e;let t="",n=!1,i=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&i&&"]"===o?i=!1:i||(t+=o):i=!0,n=!1):n=!0;return t}function tr(e){const t=er(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}class nr{constructor(e,t,n){this._element=e,this._onFrameAdded=t,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(xo((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(e){this._annotatableFrames.add(e);try{if(await ir(e),this._isDisconnected)return;e.contentWindow.addEventListener("unload",(()=>{this._removeFrame(e)})),this._onFrameAdded(e)}catch
|
|
124
|
+
;return function(e,t){let n=0;for(;e!==t&&t.contains(e);)n+=e.offsetTop,e=e.offsetParent;return n}(e.highlights[0],this.contentContainer())}}function er(e){if(!e.includes("["))return e;let t="",n=!1,i=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&i&&"]"===o?i=!1:i||(t+=o):i=!0,n=!1):n=!0;return t}function tr(e){const t=er(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}class nr{constructor(e,t,n){this._element=e,this._onFrameAdded=t,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(xo((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(e){this._annotatableFrames.add(e);try{if(await ir(e),this._isDisconnected)return;e.contentWindow.addEventListener("unload",(()=>{this._removeFrame(e)})),this._onFrameAdded(e)}catch{
|
|
125
125
|
console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${e.src}')`)}}_removeFrame(e){this._annotatableFrames.delete(e),this._onFrameRemoved(e)}_discoverFrames(){const e=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(const t of e)this._annotatableFrames.has(t)||this._addFrame(t);for(const t of this._annotatableFrames)e.has(t)||this._removeFrame(t)}}function ir(e){return new Promise(((t,n)=>{const i=or(e,((e,o)=>{i(),o?t(o):n(e)}))}))}function or(e,t,{pollInterval:n=10}={}){let i,o;const r=new WeakSet,s=()=>{clearTimeout(i),i=void 0},a=()=>{const n=e.contentDocument;if(n){if(!r.has(n)){if(r.add(n),s(),!function(e){return"about:blank"===e.contentDocument?.location.href&&e.hasAttribute("src")&&"about:blank"!==e.src}(e)){"interactive"===n.readyState||"complete"===n.readyState?t(null,n):n.addEventListener("DOMContentLoaded",(()=>t(null,n)))}e.contentDocument&&e.contentWindow?.addEventListener("unload",o)}}else{s()
|
|
126
126
|
;const n=e.isConnected?"Frame is cross-origin":"Frame is disconnected";t(new Error(n))}};let l=!1;o=()=>{s(),l||(i=setInterval(a,n))},e.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),e.removeEventListener("load",a)}}class rr{constructor(e,t){this._config=t,this._frameObserver=new nr(e,(e=>sr(e,t)),(()=>{}))}destroy(){this._frameObserver.disconnect()}}async function sr(e,t,n){if(null!==e.contentDocument.querySelector("script.js-hypothesis-config"))return;await ir(e);const{assetRoot:i,notebookAppUrl:o,profileAppUrl:s,sidebarAppUrl:a}=N(document),l={...t,assetRoot:i,notebookAppUrl:o,profileAppUrl:s,sidebarAppUrl:a,subFrameIdentifier:n??r(10)},c=document.createElement("script");c.className="js-hypothesis-config",c.setAttribute("data-remove-on-unload",""),c.type="application/json",c.innerText=JSON.stringify(l);const u=document.createElement("script");u.async=!0,u.src=t.clientUrl;const h=e.contentDocument;h.body.appendChild(c),h.body.appendChild(u)}class ar{
|
|
127
127
|
constructor(e,t,n){if(t.length!==n.length)throw new Error("Char boxes length does not match text length");const o=e.parentNode,r=document.createElement("hypothesis-text-layer");o.insertBefore(r,e.nextSibling),o.style.position="relative",r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.color="transparent",r.style.textAlign="left",r.style.mixBlendMode="multiply";const s="sans-serif";r.style.fontSize="16px",r.style.fontFamily=s;const a=document.createElement("canvas").getContext("2d");a.font=`16px ${s}`;const l=(e,t,n="px")=>`calc(var(--${e}-scale) * ${t}${n})`,c=function(e,t){const n=[];let i={text:"",rect:new DOMRect};const o=()=>{i.text.length>0&&(n.push(i),i={text:"",rect:new DOMRect})};for(const[n,r]of e.entries()){const e=t[n],s=/\s/.test(e);i.text.length>0&&!T(i.rect,r)&&o(),i.rect=P(i.rect,r),i.text+=s?" ":e,s&&o()}o();const r=[];let s={words:[],rect:new DOMRect};const a=()=>{s.words.length>0&&(r.push(s),s={words:[],rect:new DOMRect})};for(const e of n){
|
|
@@ -140,10 +140,10 @@ this._listeners.add(this.element,"pointerdown",(e=>{this._sideBySideActive()||vr
|
|
|
140
140
|
;const e=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",e)}_repositionAdder(){if(!this._isAdderVisible)return;const e=di();e&&this._onSelection(e)}async _connectHost(e){this._hostRPC.on("clearSelection",(()=>{di()&&(this._informHostOnNextSelectionClear=!1,wr())})),this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("hoverAnnotations",(e=>this._hoverAnnotations(e))),this._hostRPC.on("scrollToAnnotation",(e=>{this._scrollToAnnotation(e)})),this._hostRPC.on("selectAnnotations",((e,t)=>this.selectAnnotations(e,{toggle:t}))),this._hostRPC.on("sidebarLayoutChanged",(t=>{_r(window,e)&&this.fitSideBySide(t),this.element.dispatchEvent(new Ri({sidebarLayout:t,sideBySideActive:this._sideBySideActive()}))})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected")));const t=await this._portFinder.discover("host");this._hostRPC.connect(t)}async _scrollToAnchor(e){const t=yr(e);if(!t)return;const n=new xr(t);this.element.dispatchEvent(n)&&(await n.ready,
|
|
141
141
|
await this._integration.scrollToAnchor(e))}async _scrollToAnnotation(e){const t=this.anchors.find((t=>t.annotation.$tag===e));t?.highlights&&await this._scrollToAnchor(t)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(e=>this.features.update(e))),this._sidebarRPC.on("hoverAnnotations",(e=>this._hoverAnnotations(e))),this._sidebarRPC.on("scrollToAnnotation",(e=>{this._scrollToAnnotation(e)})),this._sidebarRPC.on("setHighlightsVisible",(e=>{this.setHighlightsVisible(e,!1)})),this._sidebarRPC.on("deleteAnnotation",(e=>this.detach(e))),this._sidebarRPC.on("loadAnnotations",(async e=>{try{await Promise.all(e.map((e=>this.anchor(e))))}catch(e){console.warn("Failed to anchor annotations:",e)}})),this._sidebarRPC.on("showContentInfo",(e=>this._integration.showContentInfo?.(e))),this._sidebarRPC.on("setOutsideAssignmentNoticeVisible",(e=>{this._setOutsideAssignmentNoticeVisible(e)})),this._sidebarRPC.on("navigateToSegment",(e=>this._integration.navigateToSegment?.(e))),
|
|
142
142
|
this._portFinder.discover("sidebar").then((e=>{this._sidebarRPC.connect(e)})),this._sendDocumentInfo()}destroy(){var e;this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),this._clusterToolbar?.destroy(),this._outsideAssignmentNotice?.destroy(),e=this.element,wi(Array.from(e.querySelectorAll("hypothesis-highlight"))),this._integration.destroy()}async anchor(e){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const t=e=>{const t=yr(e);if(!t)return;const n=vi(t,e.annotation?.$cluster);n.forEach((t=>{t._annotation=e.annotation})),e.highlights=n,this._hoveredAnnotations.has(e.annotation.$tag)&&xi(n,!0)};this.detach(e.$tag,!1),this._annotations.add(e.$tag),e.target||(e.target=[]);const n=await Promise.all(e.target.map((async t=>{if(!t.selector||!t.selector.some((e=>"TextQuoteSelector"===e.type)))return{annotation:e,target:t};let n;try{
|
|
143
|
-
const i=await this._integration.anchor(this.element,t.selector),o=li.fromRange(i);n={annotation:e,target:t,range:o}}catch
|
|
143
|
+
const i=await this._integration.anchor(this.element,t.selector),o=li.fromRange(i);n={annotation:e,target:t,range:o}}catch{n={annotation:e,target:t}}return n})));if(!this._annotations.has(e.$tag))return[];for(const e of n)t(e);return e.$orphan=n.length>0&&n.every((e=>e.target.selector&&!e.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",e),n}detach(e,t=!0){this._annotations.delete(e);const n=[];for(const t of this.anchors)t.annotation.$tag!==e?n.push(t):t.highlights&&wi(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(t.map((e=>this._integration.describe(i,e))))).map((e=>({source:n.uri,selector:e}))),s={uri:n.uri,document:n.metadata,target:o,$highlight:e,
|
|
144
144
|
$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),wr(),s}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);xi(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e);if(!t)return void this._onClearSelection();const n=document.getSelection(),i=fi(n),o=gi(n);o?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=br(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){
|
|
145
145
|
t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){!function(e,t){e.classList.toggle("hypothesis-highlights-always-on",t)}(this.element,e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){lt(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new pr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Nr(e,t){const n=new URL(e),i=new URLSearchParams;return i.append("config",JSON.stringify(t)),n.hash=i.toString(),n.toString()}function Sr(e,t){const n={}
|
|
146
|
-
;for(const[e,i]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=i&&(n[e]=i);n.origin=new URL(e).origin,n.version="1.
|
|
146
|
+
;for(const[e,i]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=i&&(n[e]=i);n.origin=new URL(e).origin,n.version="1.1528.0";const i=new URL(window.location.href);if(i.hash="",n.hostURL=i.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function Er({closed:e,onClose:t,children:n,"data-testid":i,"aria-label":o}){const r=Ge(null);return Xe((()=>{e?r.current?.close():r.current?.showModal()}),[e]),Xe((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Nt("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":i,"aria-label":o,children:n})}function Ar({closed:e,children:t,...n}){return Nt("div",{...n,
|
|
147
147
|
className:xt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Nt("div",{className:"relative w-full h-full",children:t})})}function kr({document_:e=document,...t}){return Nt(Ke((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Er:Ar),[e]),{...t})}function Tr({config:e,groupId:t}){return Nt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Nr(e.notebookAppUrl,{...Sr(e.notebookAppUrl,e),group:t})})}function Rr({eventBus:e,config:t}){const[n,i]=je(0),[o,r]=je(!0),[s,a]=je(null),l=Ge(""),c=Ge(null);Xe((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Xe((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),Xe((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),i((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const u=Qe((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
|
|
148
148
|
;return null===s?null:Nt(kr,{closed:o,onClose:u,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Nt("div",{className:"absolute right-0 m-3",children:Nt(yn,{title:"Close notebook",onClick:u,variant:"dark",classes:xt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Nt(It,{className:"w-4 h-4"})})}),Nt(Tr,{config:t,groupId:s},n)]})}class Pr{constructor(e,t,n){this._container=new Kn("notebook",(()=>Nt(Rr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Ir({eventBus:e,config:t}){const[n,i]=je(!0),o=Ge(null);Xe((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{i(!1)})),o.current=t,()=>{t.destroy()}}),[e]);const r=()=>{i(!0),o.current?.publish("closeProfile")};return n?null:Nt(kr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Nt("div",{className:"absolute right-0 m-3",children:Nt(yn,{
|
|
149
149
|
title:"Close profile dialog",onClick:r,variant:"dark",classes:xt("!bg-transparent enabled:hover:!bg-grey-3"),children:Nt(It,{className:"w-4 h-4"})})}),Nt("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Or{constructor(e,t,n){this._container=new Kn("profile",(()=>Nt(Ir,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}var Mr,Lr={exports:{}};var Br=(Mr||(Mr=1,function(e){!function(t,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,u=Math.abs,h=Date.now;function d(e,t,n){return setTimeout(v(e,n),t)}function f(e,t,n){return!!Array.isArray(e)&&(m(e,n[t],n),!0)}function m(e,t,n){var i;if(e)if(e.forEach)e.forEach(t,n);else if(e.length!==o)for(i=0;i<e.length;)t.call(n,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(n,e[i],i,e)}function p(e,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
|