hypothesis 1.1156.0 → 1.1158.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 +10 -10
- package/build/scripts/annotator.bundle.js +28 -27
- package/build/scripts/annotator.bundle.js.map +1 -1
- package/build/scripts/sidebar.bundle.js +86 -86
- package/build/scripts/sidebar.bundle.js.map +1 -1
- package/build/styles/sidebar.css +4 -0
- package/build/styles/sidebar.css.map +1 -1
- package/build/styles/ui-playground.css +4 -0
- package/build/styles/ui-playground.css.map +1 -1
- package/package.json +1 -1
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(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)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(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)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?e66b3e","styles/annotator.css":"styles/annotator.css?c10c10","styles/highlights.css":"styles/highlights.css?bb6e29","styles/annotator.css.map":"styles/annotator.css.map?02fa76","styles/highlights.css.map":"styles/highlights.css.map?51e295","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/katex.min.css":"styles/katex.min.css?776307","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css.map":"styles/sidebar.css.map?f950c5","styles/sidebar.css":"styles/sidebar.css?b1db12","styles/ui-playground.css":"styles/ui-playground.css?bcd7be","styles/ui-playground.css.map":"styles/ui-playground.css.map?7e7078","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?eac162","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?7c2adf","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?8b6a33","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?e0e9f5","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?3c1e44"};if(function(){var s=[function(){return Promise.resolve()},function(){return new Map},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 p=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),u=l(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1158.0/");if(document.querySelector("hypothesis-app")){!function(s,n){r(s,"fetch",n.apiUrl),r(s,"fetch",n.apiUrl+"links");for(var a=0,i=["scripts/sidebar.bundle.js"];a<i.length;a++)e(s,o(n,i[a]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,o(n,c[l]))}(document,{assetRoot:u,manifest:c,apiUrl:p.apiUrl})}else{var d=p,h=l(d.notebookAppUrl||"https://hypothes.is/notebook"),y=l(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,a){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",a.sidebarAppUrl),n(s,"notebook","html",a.notebookAppUrl),r(s,"style",o(a,"styles/annotator.css")),n(s,"hypothesis-client","javascript",a.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)e(s,o(a,l[i]),{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++)t(s,o(a,u[p]))}}(document,{assetRoot:u,manifest:c,notebookAppUrl: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,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?e66b3e",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?c10c10",
|
|
4
|
-
"styles/annotator.css.map": "styles/annotator.css.map?02fa76",
|
|
5
4
|
"styles/highlights.css": "styles/highlights.css?bb6e29",
|
|
5
|
+
"styles/annotator.css.map": "styles/annotator.css.map?02fa76",
|
|
6
6
|
"styles/highlights.css.map": "styles/highlights.css.map?51e295",
|
|
7
|
-
"styles/katex.min.css": "styles/katex.min.css?776307",
|
|
8
7
|
"styles/katex.min.css.map": "styles/katex.min.css.map?42d80c",
|
|
9
8
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
|
|
9
|
+
"styles/katex.min.css": "styles/katex.min.css?776307",
|
|
10
10
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
|
|
11
|
-
"styles/sidebar.css": "styles/sidebar.css?
|
|
12
|
-
"styles/sidebar.css
|
|
13
|
-
"styles/ui-playground.css": "styles/ui-playground.css?
|
|
14
|
-
"styles/ui-playground.css.map": "styles/ui-playground.css.map?
|
|
15
|
-
"scripts/
|
|
16
|
-
"scripts/
|
|
11
|
+
"styles/sidebar.css.map": "styles/sidebar.css.map?f950c5",
|
|
12
|
+
"styles/sidebar.css": "styles/sidebar.css?b1db12",
|
|
13
|
+
"styles/ui-playground.css": "styles/ui-playground.css?bcd7be",
|
|
14
|
+
"styles/ui-playground.css.map": "styles/ui-playground.css.map?7e7078",
|
|
15
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?eac162",
|
|
16
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?7c2adf",
|
|
17
17
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?8b6a33",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?e0e9f5",
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?3c1e44"
|
|
20
20
|
}
|
|
@@ -11,8 +11,8 @@ h=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++k<25);u.state
|
|
|
11
11
|
;t=r?document.createElementNS("http://www.w3.org/2000/svg",m):document.createElement(m,g.is&&g),s=null,l=!1}if(null===m)f===g||l&&t.data===g||(t.data=g);else{if(s=s&&i.call(t.childNodes),u=(f=n.props||h).dangerouslySetInnerHTML,d=g.dangerouslySetInnerHTML,!l){if(null!=s)for(f={},_=0;_<t.attributes.length;_++)f[t.attributes[_].name]=t.attributes[_].value;(d||u)&&(d&&(u&&d.__html==u.__html||d.__html===t.innerHTML)||(t.innerHTML=d&&d.__html||""))}if(function(t,e,n,i,o){var r;for(r in n)"children"===r||"key"===r||r in e||k(t,r,null,n[r],i);for(r in e)o&&"function"!=typeof e[r]||"children"===r||"key"===r||"value"===r||"checked"===r||n[r]===e[r]||k(t,r,e[r],n[r],i)}(t,g,f,r,l),d)e.__k=[];else if(_=e.props.children,C(t,Array.isArray(_)?_:[_],e,n,o,r&&"foreignObject"!==m,s,a,s?s[0]:n.__k&&v(n,0),l),null!=s)for(_=s.length;_--;)null!=s[_]&&p(s[_]);l||("value"in g&&void 0!==(_=g.value)&&(_!==t.value||"progress"===m&&!_||"option"===m&&_!==f.value)&&k(t,"value",_,f.value,!1),
|
|
12
12
|
"checked"in g&&void 0!==(_=g.checked)&&_!==t.checked&&k(t,"checked",_,f.checked,!1))}return t}function P(t,e,n){try{"function"==typeof t?t(e):t.current=e}catch(t){o.__e(t,n)}}function M(t,e,n){var i,r;if(o.unmount&&o.unmount(t),(i=t.ref)&&(i.current&&i.current!==t.__e||P(i,null,e)),null!=(i=t.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){o.__e(t,e)}i.base=i.__P=null,t.__c=void 0}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&M(i[r],e,n||"function"!=typeof t.type);n||null==t.__e||p(t.__e),t.__=t.__e=t.__d=void 0}function O(t,e,n){return this.constructor(t,n)}function I(t,e,n){var r,s,a;o.__&&o.__(t,e),s=(r="function"==typeof n)?null:n&&n.__k||e.__k,a=[],T(e,t=(!r&&n||e).__k=function(t,e,n){var o,r,s,a={};for(s in e)"key"==s?o=e[s]:"ref"==s?r=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?i.call(arguments,2):n),"function"==typeof t&&null!=t.defaultProps)for(s in t.defaultProps)void 0===a[s]&&(a[s]=t.defaultProps[s]);return g(t,a,o,r,null)
|
|
13
13
|
}(m,null,[t]),s||h,h,void 0!==e.ownerSVGElement,!r&&n?[n]:s?null:e.firstChild?i.call(e.childNodes):null,a,!r&&n?n:s?s.__e:e.firstChild,r),R(a,t)}function B(t,e){var n={__c:e="__cC"+l++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var n,i;return this.getChildContext||(n=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(t){this.props.value!==t.value&&n.some(b)},this.sub=function(t){n.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n.splice(n.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Provider.__=n.Consumer.contextType=n}i=u.slice,o={__e:function(t,e,n,i){for(var o,r,s;e=e.__;)if((o=e.__c)&&!o.__)try{if((r=o.constructor)&&null!=r.getDerivedStateFromError&&(o.setState(r.getDerivedStateFromError(t)),s=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(t,i||{}),s=o.__d),s)return o.__E=o}catch(e){t=e}throw t}},r=0,_.prototype.setState=function(t,e){var n
|
|
14
|
-
;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=f({},this.state),"function"==typeof t&&(t=t(f({},n),this.props)),t&&f(n,t),null!=t&&this.__v&&(e&&this._sb.push(e),b(this))},_.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),b(this))},_.prototype.render=m,s=[],w.__r=0,l=0;var F,H,D,V,q=0,U=[],z=[],$=o.__b,
|
|
15
|
-
;t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(s=!0)}})),!(!s&&i.__c.props===t)&&(!o||o.call(this,t,e,n))}}return i.__N||i.__}(at,t)}function K(t,e){var n=Z(F++,3);!o.__s&&st(n.__H,e)&&(n.__=t,n.i=e,H.__H.__h.push(n))}function Q(t,e){var n=Z(F++,4);!o.__s&&st(n.__H,e)&&(n.__=t,n.i=e,H.__h.push(n))}function J(t){return q=5,tt((function(){return{current:t}}),[])}function tt(t,e){var n=Z(F++,7);return st(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function et(){for(var t;t=U.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ot),t.__H.__h.forEach(rt),t.__H.__h=[]}catch(e){t.__H.__h=[],o.__e(e,t.__v)}}o.__b=function(t){H=null,$&&$(t)},o.__r=function(t){
|
|
14
|
+
;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=f({},this.state),"function"==typeof t&&(t=t(f({},n),this.props)),t&&f(n,t),null!=t&&this.__v&&(e&&this._sb.push(e),b(this))},_.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),b(this))},_.prototype.render=m,s=[],w.__r=0,l=0;var F,H,D,V,q=0,U=[],z=[],$=o.__b,j=o.__r,W=o.diffed,X=o.__c,Y=o.unmount;function Z(t,e){o.__h&&o.__h(H,t,q||e),q=0;var n=H.__H||(H.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({__V:z}),n.__[t]}function G(t){return q=1,function(t,e,n){var i=Z(F++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):at(void 0,e),function(t){var e=i.__N?i.__N[0]:i.__[0],n=i.t(e,t);e!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=H,!H.u)){H.u=!0;var o=H.shouldComponentUpdate;H.shouldComponentUpdate=function(t,e,n){if(!i.__c.__H)return!0;var r=i.__c.__H.__.filter((function(t){return t.__c}));if(r.every((function(t){return!t.__N})))return!o||o.call(this,t,e,n);var s=!1;return r.forEach((function(t){if(t.__N){var e=t.__[0]
|
|
15
|
+
;t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(s=!0)}})),!(!s&&i.__c.props===t)&&(!o||o.call(this,t,e,n))}}return i.__N||i.__}(at,t)}function K(t,e){var n=Z(F++,3);!o.__s&&st(n.__H,e)&&(n.__=t,n.i=e,H.__H.__h.push(n))}function Q(t,e){var n=Z(F++,4);!o.__s&&st(n.__H,e)&&(n.__=t,n.i=e,H.__h.push(n))}function J(t){return q=5,tt((function(){return{current:t}}),[])}function tt(t,e){var n=Z(F++,7);return st(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function et(){for(var t;t=U.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ot),t.__H.__h.forEach(rt),t.__H.__h=[]}catch(e){t.__H.__h=[],o.__e(e,t.__v)}}o.__b=function(t){H=null,$&&$(t)},o.__r=function(t){j&&j(t),F=0;var e=(H=t.__c).__H;e&&(D===H?(e.__h=[],H.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.__V=z,t.__N=t.i=void 0}))):(e.__h.forEach(ot),e.__h.forEach(rt),e.__h=[])),D=H},o.diffed=function(t){W&&W(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==U.push(e)&&V===o.requestAnimationFrame||((V=o.requestAnimationFrame)||it)(et)),e.__H.__.forEach((function(t){
|
|
16
16
|
t.i&&(t.__H=t.i),t.__V!==z&&(t.__=t.__V),t.i=void 0,t.__V=z}))),D=H=null},o.__c=function(t,e){e.some((function(t){try{t.__h.forEach(ot),t.__h=t.__h.filter((function(t){return!t.__||rt(t)}))}catch(n){e.some((function(t){t.__h&&(t.__h=[])})),e=[],o.__e(n,t.__v)}})),X&&X(t,e)},o.unmount=function(t){Y&&Y(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach((function(t){try{ot(t)}catch(t){e=t}})),n.__H=void 0,e&&o.__e(e,n.__v))};var nt="function"==typeof requestAnimationFrame;function it(t){var e,n=function(){clearTimeout(i),nt&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,100);nt&&(e=requestAnimationFrame(n))}function ot(t){var e=H,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),H=e}function rt(t){var e=H;t.__c=t.__(),H=e}function st(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function at(t,e){return"function"==typeof e?e(t):e}var lt=0;function ct(t,e,n,i,r){var s,a,l={};for(a in e)"ref"==a?s=e[a]:l[a]=e[a];var c={type:t,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,
|
|
17
17
|
__d:void 0,__c:null,__h:null,constructor:void 0,__v:--lt,__source:r,__self:i};if("function"==typeof t&&(s=t.defaultProps))for(a in s)void 0===l[a]&&(l[a]=s[a]);return o.vnode&&o.vnode(c),c}const ht=new Map;function ut({name:t,className:e="",inline:n=!1,title:i=""}){const o=ht.get(t);if(!o)throw new Error(`Icon "${t.toString()}" is not registered`);const r=J();Q((()=>{const t=r.current.querySelector("svg");t&&t.setAttribute("class",e)}),[e,o]);const s={};return i&&(s.title=i),ct("span",{className:c("Hyp-SvgIcon",{"Hyp-SvgIcon--inline":n}),dangerouslySetInnerHTML:{__html:o},ref:r,...s},void 0,!1,{fileName:"/home/runner/work/frontend-shared/frontend-shared/src/components/SvgIcon.js",lineNumber:69,columnNumber:5})}function dt(t,e){const n="string"==typeof t?Symbol(t):t;return ht.set(n,e),n}var ft="/home/runner/work/frontend-shared/frontend-shared/src/components/buttons.js"
|
|
18
18
|
;function pt({buttonRef:t,classes:e,className:n,icon:i,iconPosition:o="left",size:r="medium",variant:s="normal",expanded:a,pressed:l,type:h="button",...u}){var d;const f=null!==(d=null==u?void 0:u.role)&&void 0!==d?d:"button",p={"aria-label":u.title};return"tab"===f?p["aria-selected"]=l:(p["aria-pressed"]=l,p["aria-expanded"]=a),ct("button",{ref:t,className:c(n,`${n}--${r}`,`${n}--${s}`,{[`${n}--icon-${o}`]:i},e),type:h,...p,...u},void 0,!1,{fileName:ft,lineNumber:84,columnNumber:5})}function gt({className:t="Hyp-IconButton",...e}){const{icon:n}=e;return ct(pt,{className:t,...e,children:ct(ut,{name:n},void 0,!1,{fileName:ft,lineNumber:112,columnNumber:7})},void 0,!1,{fileName:ft,lineNumber:111,columnNumber:5})}function mt({children:t,className:e="Hyp-LabeledButton",...n}){const{icon:i,iconPosition:o="left"}=n;return ct(pt,{className:e,...n,children:[i&&"left"===o&&ct(ut,{name:i},void 0,!1,{fileName:ft,lineNumber:131,columnNumber:43}),t,i&&"right"===o&&ct(ut,{name:i},void 0,!1,{fileName:ft,lineNumber:133,
|
|
@@ -35,9 +35,9 @@ frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"
|
|
|
35
35
|
sourceId:l},d="null"===i?"*":i;o.postMessage(u,d,[h.port1]),"sidebar"===s?this._sidebarHostChannel.port2.postMessage(u,[h.port2]):"host"===s&&this._emitter.emit("frameConnected",r,h.port2)},o=t,(...t)=>{try{return i(...t)}catch(t){throw Mt(t,o),t}}))}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:i}){return("*"===e||i===e)&&kt(n,t)}on(t,e){this._emitter.on(t,e)}destroy(){this._listeners.removeAll()}}const Bt="1.0.0",Ft="frame-rpc";function Ht(t,e,n=[],i=-1){t.postMessage({protocol:Ft,version:Bt,arguments:n,method:e,sequence:i})}function Dt(t){const e=t.match(/\bAppleWebKit\/([0-9]+)\b/);if(!e)return!1;return!(parseInt(e[1])<=537)}class Vt{constructor({userAgent:t=navigator.userAgent,currentWindow:e=window}={}){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new Ct,this._listeners.add(e,"unload",(()=>{this._port&&(Ht(this._port,"close"),e!==e.parent&&Dt(t)&&e.parent.postMessage({type:"hypothesisPortClosed"},"*",[this._port]))})),
|
|
36
36
|
this._pendingCalls=[],this._receivedCloseEvent=!1}on(t,e){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(t,e)}connect(t){this._port=t,this._listeners.add(t,"message",(t=>this._handle(t))),t.start(),Ht(t,"connect");for(let[t,e]of this._pendingCalls)this.call(t,...e);this._pendingCalls=[]}destroy(){this._port&&(Ht(this._port,"close"),this._port.close()),this._destroyed=!0,this._listeners.removeAll()}call(t,...e){if(this._port||this._pendingCalls.push([t,e]),!this._port||this._destroyed)return;const n=this._sequence++,i=e[e.length-1];"function"==typeof i&&(this._callbacks.set(n,i),e=e.slice(0,-1)),Ht(this._port,t,e,n)}_parseMessage({data:t}){return t&&"object"==typeof t?t.protocol!==Ft||t.version!==Bt?null:Array.isArray(t.arguments)?t:null:null}_handle(t){const e=this._parseMessage(t),n=this._port;if(e&&n)if("method"in e){if("close"===e.method){if(this._receivedCloseEvent)return;this._receivedCloseEvent=!0}const t=this._methods.get(e.method);if(!t)return
|
|
37
37
|
;const i=(...t)=>{const i={arguments:t,protocol:Ft,response:e.sequence,version:Bt};n.postMessage(i)};t(...e.arguments,i)}else if("response"in e){const t=this._callbacks.get(e.response);this._callbacks.delete(e.response),t&&t(...e.arguments)}}}function qt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ut(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),i=0;i<n.length;i++){var o=void 0;try{o=JSON.parse(n[i].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),o={}}Object.assign(e,o)}return e}function zt(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function $t(t,e,n){const i=t.document.querySelector(`link[type="application/annotator+${n}"][rel="${e}"]`);if(!i)throw new Error(`No application/annotator+${n} (rel="${e}") link in the document`);if(!i.href)throw new Error(`application/annotator+${n} (rel="${e}") link has no href`);return i.href}
|
|
38
|
-
function
|
|
39
|
-
return"always";case!1:return"never";default:return"always"}}()},get sidebarAppUrl(){return $t(t,"sidebar","html")},get query(){return
|
|
40
|
-
defaultValue:null,getValue:Xt},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:zt,getValue:Xt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},showHighlights:{allowInBrowserExt:!1,defaultValue:"always",getValue:t=>t.showHighlights},notebookAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.notebookAppUrl},sidebarAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.sidebarAppUrl},subFrameIdentifier:{allowInBrowserExt:!0,defaultValue:null,getValue:Xt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt}};function Zt(t,e=window){const n=
|
|
38
|
+
function jt(t){return"string"==typeof t?t:null}function Wt(t){const e=function(t){if(!qt(t,"hypothesisConfig"))return{};if("function"!=typeof t.hypothesisConfig){const t="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#window.hypothesisConfig";return console.warn("hypothesisConfig must be a function, see: "+t),{}}return t.hypothesisConfig()}(t);let n;function i(t){return qt(e,t)?e[t]:qt(n,t)?n[t]:void 0}return n=zt(e.ignoreOtherConfiguration)?{}:Ut(t.document),{get annotations(){return jt(n.annotations)||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return $t(t,"hypothesis-client","javascript")},get group(){return jt(n.group)||function(){const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return $t(t,"notebook","html")},get showHighlights(){return function(){const t=i("showHighlights");switch(t){case"always":case"never":case"whenSidebarOpen":return t;case!0:
|
|
39
|
+
return"always";case!1:return"never";default:return"always"}}()},get sidebarAppUrl(){return $t(t,"sidebar","html")},get query(){return jt(n.query)||function(){const e=t.location.href.match(/#annotations:(query|q):(.+)$/i);if(e)try{return decodeURIComponent(e[2])}catch(t){}return null}()},hostPageSetting:i}}function Xt(t,e){return t.hostPageSetting(e)}const Yt={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:Xt},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:Xt},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},contentInfoBanner:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},usernameUrl:{allowInBrowserExt:!1,
|
|
40
|
+
defaultValue:null,getValue:Xt},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:zt,getValue:Xt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt},showHighlights:{allowInBrowserExt:!1,defaultValue:"always",getValue:t=>t.showHighlights},notebookAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.notebookAppUrl},sidebarAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.sidebarAppUrl},subFrameIdentifier:{allowInBrowserExt:!0,defaultValue:null,getValue:Xt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:Xt}};function Zt(t,e=window){const n=Wt(e),i={};for(let r of function(t){const e={annotator:["clientUrl","contentInfoBanner","subFrameIdentifier"],
|
|
41
41
|
sidebar:["appType","annotations","branding","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"]};switch(t){case"annotator":return e.annotator;case"sidebar":return e.sidebar;case"notebook":return e.notebook;case"all":return[...e.annotator,...e.sidebar,...e.notebook];default:throw new Error(`Invalid application context used: "${t}"`)}}(t)){const t=Yt[r],s=void 0!==t.defaultValue,a=!((o=$t(e,"sidebar","html")).startsWith("http://")||o.startsWith("https://"));if(!t.allowInBrowserExt&&a){s&&(i[r]=t.defaultValue);continue}const l=t.getValue(n,r);void 0!==l?i[r]=t.coerce?t.coerce(l):l:s&&(i[r]=t.defaultValue)}var o;return i}const Gt={alt:1,ctrl:2,meta:4,shift:8};function Kt(t,e){const n=e.split("+").map((t=>t.toLowerCase()));let i=0,o=null;for(const t of n){
|
|
42
42
|
const e=Gt[t];if(e)i|=e;else{if(null!==o)throw new Error("Multiple non-modifier keys specified");o=t}}if(!o)throw new Error(`Invalid shortcut: ${e}`);return((t.ctrlKey?Gt.ctrl:0)|(t.metaKey?Gt.meta:0)|(t.altKey?Gt.alt:0)|(t.shiftKey?Gt.shift:0))===i&&t.key.toLowerCase()===o}function Qt(t,e,{rootElement:n}={}){K((()=>{if(t)return function(t,e,{rootElement:n=document.documentElement}={}){const i=n=>{Kt(n,t)&&e(n)};return n.addEventListener("keydown",i),()=>n.removeEventListener("keydown",i)}(t,e,{rootElement:n})}),[t,e,n])}var Jt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Annotate.js";function te(t){return ct("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",...t,children:ct("path",{fill:"currentColor",
|
|
43
43
|
d:"M15 0c.27 0 .505.099.703.297A.961.961 0 0 1 16 1v15l-4-3H1a.974.974 0 0 1-.703-.29A.953.953 0 0 1 0 12V1A.96.96 0 0 1 .29.29.966.966 0 0 1 1 0h14zM7 3l-.469.063c-.312.041-.656.187-1.031.437-.375.25-.719.646-1.031 1.188C4.156 5.229 4 6 4 7l.002.063.006.062a.896.896 0 0 1 .008.11l-.002.074-.006.066a1.447 1.447 0 0 0 .43 1.188C4.729 8.854 5.082 9 5.5 9c.417 0 .77-.146 1.063-.438C6.854 8.271 7 7.918 7 7.5c0-.417-.146-.77-.438-1.063A1.447 1.447 0 0 0 5.5 6a1.467 1.467 0 0 0-.422.062c.177-1.03.542-1.632 1.094-1.804L7 4V3zm5 0-.469.063c-.312.041-.656.187-1.031.437-.375.25-.719.646-1.031 1.188C9.156 5.229 9 6 9 7l.002.063.006.062a.896.896 0 0 1 .008.11l-.002.074-.006.066a1.447 1.447 0 0 0 .43 1.188c.291.291.645.437 1.062.437.417 0 .77-.146 1.063-.438.291-.291.437-.645.437-1.062 0-.417-.146-.77-.438-1.063A1.447 1.447 0 0 0 10.5 6a1.467 1.467 0 0 0-.422.062c.177-1.03.542-1.632 1.094-1.804L12 4V3z"},void 0,!1,{fileName:Jt,lineNumber:17,columnNumber:7})},void 0,!1,{fileName:Jt,lineNumber:10,columnNumber:5})}
|
|
@@ -59,8 +59,8 @@ arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this.
|
|
|
59
59
|
case Node.ELEMENT_NODE:{if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let i=0;i<e;i++)n+=Le(t.childNodes[i]);return new Oe(t,n)}default:throw new Error("Point is not in an element or text node")}}}class Ie{constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new Ie(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=Me(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:1}),e=this.end.resolve({direction:2}));const n=new Range;return n.setStart(t.node,t.offset),n.setEnd(e.node,e.offset),n}static fromRange(t){const e=Oe.fromPoint(t.startContainer,t.startOffset),n=Oe.fromPoint(t.endContainer,t.endOffset);return new Ie(e,n)}static fromOffsets(t,e,n){return new Ie(new Oe(t,e),new Oe(t,n))}}const Be=".annotator-placeholder";function Fe(t){return!!t.parentElement&&null!==t.parentElement.closest(Be)}function He(t){
|
|
60
60
|
if(t.focusNode===t.anchorNode)return t.focusOffset<t.anchorOffset;return t.getRangeAt(0).startContainer===t.focusNode}function De(t,e){try{var n,i;const o=null!==(n=null===(i=e.nodeValue)||void 0===i?void 0:i.length)&&void 0!==n?n:e.childNodes.length;return t.comparePoint(e,0)<=0&&t.comparePoint(e,o)>=0}catch(t){return!1}}function Ve(t,e){const n=t.commonAncestorContainer,i=n.ownerDocument.createNodeIterator(n,NodeFilter.SHOW_ALL);let o;for(;o=i.nextNode();)De(t,o)&&e(o)}function qe(t){if(t.isCollapsed)return null;const e=function(t){const e=/^\s*$/,n=[];Ve(t,(t=>{t.nodeType!==Node.TEXT_NODE||t.textContent.match(e)||n.push(t)}));let i=[];return n.forEach((e=>{const n=e.ownerDocument.createRange();if(n.selectNodeContents(e),e===t.startContainer&&n.setStart(e,t.startOffset),e===t.endContainer&&n.setEnd(e,t.endOffset),n.collapsed)return;const o=Array.from(n.getClientRects());n.detach(),i=i.concat(o)})),i}(t.getRangeAt(0));return 0===e.length?null:He(t)?e[0]:e[e.length-1]}
|
|
61
61
|
const Ue="http://www.w3.org/2000/svg",ze=["user-annotations","user-highlights","other-content"];function $e(t,e){const n=function(t){if(t.collapsed)return[];let e=t.commonAncestorContainer;if(e&&e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentElement),!e)return[];const n=[],i=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT);let o;for(;o=i.nextNode();){if(!De(t,o))continue;const e=o;e===t.startContainer&&t.startOffset>0?e.splitText(t.startOffset):(e===t.endContainer&&t.endOffset<e.data.length&&e.splitText(t.endOffset),n.push(e))}return n}(t),i=n.length>0&&Fe(n[0]);let o=[],r=null,s=null;n.forEach((t=>{r&&r.nextSibling===t?s.push(t):(s=[t],o.push(s)),r=t}));const a=/^\s*$/;o=o.filter((t=>t.some((t=>!a.test(t.data)))));const l=[];return o.forEach((t=>{const n=document.createElement("hypothesis-highlight");n.className=c("hypothesis-highlight",e);t[0].parentNode.replaceChild(n,t[0]),t.forEach((t=>n.appendChild(t))),l.push(n)})),i||function(t,e){if(0===t.length)return;const n=function(t){
|
|
62
|
-
const e=t.closest(".page");return e&&e.querySelector(".canvasWrapper > canvas")||null}(t[0]);if(!n||!n.parentElement)return;let i=n.parentElement.querySelector(".hypothesis-highlight-layer");if(!i){i=document.createElementNS(Ue,"svg"),i.setAttribute("class","hypothesis-highlight-layer"),n.parentElement.appendChild(i),n.parentElement.style.position="relative";const t=i.style;t.position="absolute",t.left="0",t.top="0",t.width="100%",t.height="100%",t.mixBlendMode="multiply"}const o=n.getBoundingClientRect(),r=t.map((t=>{const n=t.getBoundingClientRect(),i=document.createElementNS(Ue,"rect");return i.setAttribute("x",(n.left-o.left).toString()),i.setAttribute("y",(n.top-o.top).toString()),i.setAttribute("width",n.width.toString()),i.setAttribute("height",n.height.toString()),i.setAttribute("class",c("hypothesis-svg-highlight",e)),t.classList.add("is-transparent"),t.svgHighlight=i,i}));i.append(...r)}(l,e),l}function
|
|
63
|
-
for(const e of t){if(e.parentNode){
|
|
62
|
+
const e=t.closest(".page");return e&&e.querySelector(".canvasWrapper > canvas")||null}(t[0]);if(!n||!n.parentElement)return;let i=n.parentElement.querySelector(".hypothesis-highlight-layer");if(!i){i=document.createElementNS(Ue,"svg"),i.setAttribute("class","hypothesis-highlight-layer"),n.parentElement.appendChild(i),n.parentElement.style.position="relative";const t=i.style;t.position="absolute",t.left="0",t.top="0",t.width="100%",t.height="100%",t.mixBlendMode="multiply"}const o=n.getBoundingClientRect(),r=t.map((t=>{const n=t.getBoundingClientRect(),i=document.createElementNS(Ue,"rect");return i.setAttribute("x",(n.left-o.left).toString()),i.setAttribute("y",(n.top-o.top).toString()),i.setAttribute("width",n.width.toString()),i.setAttribute("height",n.height.toString()),i.setAttribute("class",c("hypothesis-svg-highlight",e)),t.classList.add("is-transparent"),t.svgHighlight=i,i}));i.append(...r)}(l,e),l}function je(t,e){const n=t.parentNode;e.forEach((e=>n.insertBefore(e,t))),t.remove()}function We(t){
|
|
63
|
+
for(const e of t){if(e.parentNode){je(e,Array.from(e.childNodes))}e.svgHighlight&&e.svgHighlight.remove()}}function Xe(t,e){t.forEach((t=>{if(t.svgHighlight){if(t.svgHighlight.classList.toggle("is-focused",e),e){t.svgHighlight.parentNode.append(t.svgHighlight)}}else t.classList.toggle("hypothesis-highlight-focused",e)}))}function Ye(t){const e=t.map((t=>t.getBoundingClientRect()));return e.reduce(((t,e)=>({top:Math.min(t.top,e.top),left:Math.min(t.left,e.left),bottom:Math.max(t.bottom,e.bottom),right:Math.max(t.right,e.right)})))}function Ze(t){Qe(Ke(t)),function(t){const e=t=>{var e;return parseInt(null!==(e=t.getAttribute("data-nesting-level"))&&void 0!==e?e:"0",10)};for(const[n,i]of function(t){const e=new Map;for(const n of(null!=t?t:document).getElementsByClassName("hypothesis-highlight-layer"))e.set(n,Array.from(n.querySelectorAll(".hypothesis-svg-highlight")));return e}(t)){i.every(((t,n,i)=>0===n||e(t)>=e(i[n-1])))||(i.sort(((t,n)=>e(t)-e(n))),n.replaceChildren(...i))}}(t)}
|
|
64
64
|
const Ge=t=>"hypothesis-highlight"===t.tagName.toLowerCase();function Ke(t){let e;return e=Ge(t)?Array.from(t.children).filter(Ge):Array.from(t.getElementsByTagName("hypothesis-highlight")).filter((t=>!t.parentElement||!Ge(t.parentElement))),e}function Qe(t,e="",n=0,i=0){for(const r of t){var o;const t=null!==(o=ze.find((t=>r.classList.contains(t))))&&void 0!==o?o:"other-content",s=e&&t===e?i+1:0;r.setAttribute("data-nesting-level",`${n}`),r.setAttribute("data-cluster-level",`${s}`),r.svgHighlight&&(r.svgHighlight.setAttribute("data-nesting-level",`${n}`),r.svgHighlight.setAttribute("data-cluster-level",`${s}`)),Qe(Ke(r),t,n+1,s)}}class Je{constructor({contentContainer:t,hostRPC:e}){this._hostRPC=e,this._updatePending=!1,this._anchors=[],this._listeners=new Ct,this._listeners.add(window,"resize",(()=>this.update())),this._listeners.add(window,"scroll",(()=>this.update())),this._listeners.add(t,"scroll",(()=>this.update()))}destroy(){this._listeners.removeAll()}update(t){t&&(this._anchors=t),
|
|
65
65
|
this._updatePending||(this._updatePending=!0,requestAnimationFrame((()=>{const t=function(t){const e=[];return t.forEach((({annotation:t,highlights:n})=>{if(null==n||!n.length)return;const{top:i,bottom:o}=Ye(n);i>=o||e.push({tag:t.$tag,top:i,bottom:o})})),e.sort(((t,e)=>t.top-e.top)),e}(this._anchors);this._hostRPC.call("anchorsChanged",t),this._updatePending=!1})))}}function tn({cluster:t,label:e,onChange:n,currentStyles:i,highlightStyles:o}){const r=i[t],s="transparent"===r;return ct("div",{className:"space-y-2",children:[ct("div",{className:"flex items-center gap-x-2 text-annotator-base",children:ct("div",{className:"grow text-color-text px-2 py-1 rounded",style:{backgroundColor:o[r].color},children:e})}),ct("div",{className:"flex items-center gap-x-2",children:Object.keys(o).map((e=>ct("div",{className:"relative",children:[ct("input",{className:c("absolute w-6 h-6","opacity-[.00001]","cursor-pointer"),name:t,id:`hypothesis-${t}-${e}`,checked:r===e,onChange:n,type:"radio",value:e}),ct("label",{
|
|
66
66
|
className:"block",htmlFor:`${t}-${e}`,children:[ct("div",{style:{backgroundColor:o[e].color},className:c("block w-6 h-6 rounded-full flex items-center justify-center",{"border-2 border-slate-0":r!==e,"border-2 border-slate-3":r===e}),children:"transparent"===e&&ct(le,{className:c("w-3 h-3",{"text-slate-3":!s,"text-slate-7":s})})}),ct("span",{className:"sr-only",children:e})]})]},`${t}-${e}`)))})]})}function en({active:t,availableStyles:e,currentStyles:n,onStyleChange:i}){const o=function(t,e){return q=8,tt((function(){return t}),e)}((t=>{const e=t.target,n=e.name,o=e.value;i(n,o)}),[i]),[r,s]=G(!1);return t?ct(ve,{children:ct("div",{className:"flex flex-col text-annotator-base text-color-text",children:[ct(_e,{"data-testid":"control-toggle-button",onClick:()=>s(!r),title:r?"Hide highlight settings":"Show highlight settings",children:ct(m,r?{children:[ct(ne,{}),ct("span",{children:"Highlight Appearance"})]}:{children:[ct(se,{}),ct(he,{})]})}),r&&ct(ye,{"data-testid":"cluster-style-controls",size:"sm",
|
|
@@ -78,12 +78,12 @@ const n=Ie.fromRange(e).relativeTo(t);return new xn(t,n.start.offset,n.end.offse
|
|
|
78
78
|
return t.highwire.title?t.highwire.title[0]:t.eprints.title?t.eprints.title[0]:t.prism.title?t.prism.title[0]:t.facebook.title?t.facebook.title[0]:t.twitter.title?t.twitter.title[0]:t.dc.title?t.dc.title[0]:this.document.title}_getLinks(t={dc:{},highwire:{}}){const e=[{href:this._getDocumentHref()}],n=Array.from(this.document.querySelectorAll("link"));for(let t of n)if(["alternate","canonical","bookmark","shortlink"].includes(t.rel)){if("alternate"===t.rel){if(t.type&&t.type.match(/^application\/(rss|atom)\+xml/))continue;if(t.hreflang)continue}try{const n=this._absoluteUrl(t.href);e.push({href:n,rel:t.rel,type:t.type})}catch(t){}}for(let n of Object.keys(t.highwire)){const i=t.highwire[n];if("pdf_url"===n)for(let t of i)try{e.push({href:this._absoluteUrl(t),type:"application/pdf"})}catch(t){}if("doi"===n)for(let t of i)"doi:"!==t.slice(0,4)&&(t=`doi:${t}`),e.push({href:t})}for(let n of Object.keys(t.dc)){const i=t.dc[n];if("identifier"===n)for(let t of i)"doi:"===t.slice(0,4)&&e.push({href:t})}
|
|
79
79
|
const i=t.dc["relation.ispartof"],o=t.dc.identifier;if(i&&o){const t=i[i.length-1],n=o[o.length-1],r="urn:x-dc:"+encodeURIComponent(t)+"/"+encodeURIComponent(n);e.push({href:r})}return e}_getFavicon(){let t=null;for(let e of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(e.rel))try{t=this._absoluteUrl(e.href)}catch(t){}return t}_absoluteUrl(t){return An(t,this.document.baseURI)}_getDocumentHref(){const{href:t}=this.document.location,e=["http:","https:","file:"],n=new URL(t).protocol;return e.includes(n)?t:this.document.baseURI&&e.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:t}}function Rn(t){return t.width<=0||t.height<=0}function Ln(t,e,n,i){return Math.max(t,n)<Math.min(e,i)}function Pn(t,e){return!Rn(t)&&!Rn(e)&&(Ln(t.left,t.right,e.left,e.right)&&Ln(t.top,t.bottom,e.top,e.bottom))}function Mn(t,e){return Ln(t.top,t.bottom,e.top,e.bottom)}function On(t,e){return Ln(t.left,t.right,e.left,e.right)}function In(t,e){if(Rn(t))return e
|
|
80
80
|
;if(Rn(e))return t;const n=Math.min(t.left,e.left),i=Math.min(t.top,e.top),o=Math.max(t.right,e.right),r=Math.max(t.bottom,e.bottom);return new DOMRect(n,i,o-n,r-i)}function Bn(t){return new DOMPoint((t.left+t.right)/2,(t.top+t.bottom)/2)}const Fn=["p",".para"];let Hn;function Dn(t,e=0,n=t.data.length){return Hn||(Hn=document.createRange()),Hn.setStart(t,e),Hn.setEnd(t,n),Hn.getBoundingClientRect()}function Vn(t){const e=t.getBoundingClientRect();return e.x-=t.scrollLeft,e.y-=t.scrollTop,e.height=Math.max(e.height,t.scrollHeight),e.width=Math.max(e.width,t.scrollWidth),e}function*qn(t,e,n=(()=>!0)){let i=t.firstChild;for(;i;){if(i.nodeType===Node.ELEMENT_NODE){const t=i,o=Pn(Vn(t),e);n(t)&&o&&(yield*qn(t,e,n))}else if(i.nodeType===Node.TEXT_NODE){const t=i;Pn(Dn(t),e)&&(yield t)}i=i.nextSibling}}function Un(t,e){let n=null;const i=t=>!function(t){switch(getComputedStyle(t).position){case"fixed":case"sticky":return!0;default:return!1}}(t);t:for(let s of qn(t,e,i)){let t=0;for(let i of s.data.split(/\b/)){
|
|
81
|
-
if(/\S/.test(i)){const a=t,l=t+i.length,c=Dn(s,a,l);if(r=c,!Rn(o=e)&&!Rn(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 t}}t+=i.length}}var o,r;return n}function zn(t,e=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const i=Un(e,n);if(!i)return t(),0;const o=i.getBoundingClientRect().top;t();const r=i.getBoundingClientRect().top-o;return e.scrollTop+=r,r}function $n(t,e,n){const i=t[e];if("function"!=typeof i)throw new Error("Can only intercept functions");return t[e]=(...e)=>{const o=i.call(t,...e);return n(...e),o},()=>{t[e]=i}}function
|
|
81
|
+
if(/\S/.test(i)){const a=t,l=t+i.length,c=Dn(s,a,l);if(r=c,!Rn(o=e)&&!Rn(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 t}}t+=i.length}}var o,r;return n}function zn(t,e=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const i=Un(e,n);if(!i)return t(),0;const o=i.getBoundingClientRect().top;t();const r=i.getBoundingClientRect().top-o;return e.scrollTop+=r,r}function $n(t,e,n){const i=t[e];if("function"!=typeof i)throw new Error("Can only intercept functions");return t[e]=(...e)=>{const o=i.call(t,...e);return n(...e),o},()=>{t[e]=i}}function jn(t){return t.replace(/#.*/,"")}class Wn{constructor(t,e=(()=>location.href)){this._listeners=new Ct;let n=e();const i=(i=e())=>{jn(n)!==jn(i)&&(n=i,t(i))},o=window.navigation;if(o)this._listeners.add(o,"navigatesuccess",(()=>i()));else{const t=[$n(window.history,"pushState",(()=>i())),$n(window.history,"replaceState",(()=>i()))]
|
|
82
82
|
;this._unpatchHistory=()=>t.forEach((t=>t())),this._listeners.add(window,"popstate",(()=>i()))}}disconnect(){var t;null===(t=this._unpatchHistory)||void 0===t||t.call(this),this._listeners.removeAll()}}var Xn="complete",Yn="canceled";function Zn(t,e,n){t.self===t?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function Gn(t){var e=t._scrollSettings;if(e){var n=e.maxSynchronousAlignments,i=function(t,e){var n,i,o,r,s,a,l,c=t.align,h=t.target.getBoundingClientRect(),u=c&&null!=c.left?c.left:.5,d=c&&null!=c.top?c.top:.5,f=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,g=u,m=d;if(t.isWindow(e))a=Math.min(h.width,e.innerWidth),l=Math.min(h.height,e.innerHeight),i=h.left+e.pageXOffset-e.innerWidth*g+a*g,o=h.top+e.pageYOffset-e.innerHeight*m+l*m,i-=f,o-=p,i=t.align.lockX?e.pageXOffset:i,o=t.align.lockY?e.pageYOffset:o,r=i-e.pageXOffset,s=o-e.pageYOffset;else{a=h.width,l=h.height,n=e.getBoundingClientRect();var _=h.left-(n.left-e.scrollLeft),v=h.top-(n.top-e.scrollTop)
|
|
83
83
|
;i=_+a*g-e.clientWidth*g,o=v+l*m-e.clientHeight*m,i-=f,o-=p,i=Math.max(Math.min(i,e.scrollWidth-e.clientWidth),0),o=Math.max(Math.min(o,e.scrollHeight-e.clientHeight),0),i=t.align.lockX?e.scrollLeft:i,o=t.align.lockY?e.scrollTop:o,r=i-e.scrollLeft,s=o-e.scrollTop}return{x:i,y:o,differenceX:r,differenceY:s}}(e,t),o=Date.now()-e.startTime,r=Math.min(1/e.time*o,1);if(e.endIterations>=n)return Zn(t,i.x,i.y),t._scrollSettings=null,e.end(Xn);var s=1-e.ease(r);if(Zn(t,i.x-i.differenceX*s,i.y-i.differenceY*s),o>=e.time)return e.endIterations++,e.scrollAncestor&&Gn(e.scrollAncestor),void Gn(t);!function(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}(Gn.bind(null,t))}}function Kn(t){return t.self===t}function Qn(t){return"pageXOffset"in t||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function Jn(){return!0}function ti(t){if(t.assignedSlot)return ti(t.assignedSlot)
|
|
84
84
|
;if(t.parentElement)return"body"===t.parentElement.tagName.toLowerCase()?t.parentElement.ownerDocument.defaultView||t.parentElement.ownerDocument.ownerWindow:t.parentElement;if(t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e.host}}var ei=function(t,e,n){if(t){"function"==typeof e&&(n=e,e=null),e||(e={}),e.time=isNaN(e.time)?1e3:e.time,e.ease=e.ease||function(t){return 1-Math.pow(1-t,t/2)},e.align=e.align||{};var i=ti(t),o=1,r=e.validTarget||Jn,s=e.isScrollable;e.debug&&(console.log("About to scroll to",t),i||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var a=[];i;)if(e.debug&&console.log("Scrolling parent node",i),r(i,o)&&(s?s(i,Qn):Qn(i))&&(o++,a.push(i)),!(i=ti(i))){l(Xn);break}return a.reduce(((n,i,o)=>function(t,e,n,i,o){var r,s=!e._scrollSettings,a=e._scrollSettings,l=Date.now(),c={passive:!0};function h(t){e._scrollSettings=null,e.parentElement&&e.parentElement._scrollSettings&&e.parentElement._scrollSettings.end(t),
|
|
85
85
|
n.debug&&console.log("Scrolling ended with type",t,"for",e),o(t),r&&(e.removeEventListener("touchstart",r,c),e.removeEventListener("wheel",r,c))}a&&a.end(Yn);var u=n.maxSynchronousAlignments;return null==u&&(u=3),e._scrollSettings={startTime:l,endIterations:0,target:t,time:n.time,ease:n.ease,align:n.align,isWindow:n.isWindow||Kn,maxSynchronousAlignments:u,end:h,scrollAncestor:i},"cancellable"in n&&!n.cancellable||(r=h.bind(null,Yn),e.addEventListener("touchstart",r,c),e.addEventListener("wheel",r,c)),s&&Gn(e),r}(t,i,e,a[o+1],l)),null)}function l(t){--o||n&&n(t)}};function ni(t,e,n){return t+n*(e-t)}async function ii(t,e,{maxDuration:n=500}={}){const i=t.scrollTop,o=e,r=Date.now(),s=Math.min(Math.abs(o-i)/3,n);let a=0;for(;a<1;)await new Promise((t=>{requestAnimationFrame(t)})),a=Math.min(1,(Date.now()-r)/s),t.scrollTop=ni(i,o,a)}class oi extends Rt{constructor({features:t,container:e=document.body}){super(),this.features=t,this.container=e,this.anchor=kn,this.describe=Nn,this._htmlMeta=new Tn,
|
|
86
|
-
this._prevURI=this._htmlMeta.uri(),this._sideBySideEnabled=this.features.flagEnabled("html_side_by_side"),this._sideBySideActive=!1,this._lastLayout=null,this._navObserver=new
|
|
86
|
+
this._prevURI=this._htmlMeta.uri(),this._sideBySideEnabled=this.features.flagEnabled("html_side_by_side"),this._sideBySideActive=!1,this._lastLayout=null,this._navObserver=new Wn((()=>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=()=>{const e=t.flagEnabled("html_side_by_side");e!==this._sideBySideEnabled&&(this._sideBySideEnabled=e,this._lastLayout&&this.fitSideBySide(this._lastLayout))},this.features.on("flagsChanged",this._flagsChanged)}_checkForURIChange(){const t=this._htmlMeta.uri();t!==this._prevURI&&(this._prevURI=t,this.emit("uriChanged",t))}canAnnotate(){return!0}canStyleClusteredHighlights(){return!0}destroy(){this._navObserver.disconnect(),this._metaObserver.disconnect(),this.features.off("flagsChanged",this._flagsChanged)}contentContainer(){return this.container}fitSideBySide(t){this._lastLayout=t
|
|
87
87
|
;const e=window.innerWidth-t.width,n=this._sideBySideEnabled&&t.expanded&&e>=480;return n?this._activateSideBySide(t.width):this._sideBySideActive&&this._deactivateSideBySide(),this._sideBySideActive=n,n}_activateSideBySide(t){const e=t+12,n=t=>parseInt(window.getComputedStyle(t).marginLeft,10);zn((()=>{document.body.style.marginLeft="",document.body.style.marginRight="";const t=n(document.body);document.body.style.marginRight=`${e}px`;const i=function(t){const e=new Map,n=new Map,i=Fn.join(","),o=Array.from(t.querySelectorAll(i)).map((t=>({rect:t.getBoundingClientRect(),textLength:t.textContent.length}))).filter((({rect:t})=>t.width>0&&t.height>0)).sort(((t,e)=>e.textLength-t.textLength)).slice(0,15);if(o.forEach((({rect:t})=>{var i,o;let r=null!==(i=e.get(t.left))&&void 0!==i?i:0;r+=1,e.set(t.left,r);let s=null!==(o=n.get(t.right))&&void 0!==o?o:0;s+=1,n.set(t.right,s)})),0===e.size||0===n.size)return null
|
|
88
88
|
;const r=[...e.entries()].sort(((t,e)=>e[1]-t[1])),s=[...n.entries()].sort(((t,e)=>e[1]-t[1])),[a]=r[0],[l]=s[0];return{left:a,right:l}}(document.body);if(i){const o=Math.max(0,window.innerWidth-e-i.right);if(o>0){const t=Math.max(0,e-o);document.body.style.marginRight=`${t}px`}n(document.body)>t&&(document.body.style.marginLeft=`${t}px`),i.left<12&&(document.body.style.marginLeft="12px")}else document.body.style.marginLeft="",document.body.style.marginRight=""}))}_deactivateSideBySide(){zn((()=>{document.body.style.marginLeft="",document.body.style.marginRight=""}))}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}async scrollToAnchor(t){var e;const n=null===(e=t.highlights)||void 0===e?void 0:e[0];n&&await async function(t,{maxDuration:e=500}={}){const n=t.closest("body");n&&"BODY"!==n.tagName&&Object.defineProperty(n,"tagName",{value:"BODY",configurable:!0}),await new Promise((n=>ei(t,{time:e},n)))}(n)}}
|
|
89
89
|
var ri=/^\s+|\s+$/g,si=/^[-+]0x[0-9a-f]+$/i,ai=/^0b[01]+$/i,li=/^0o[0-7]+$/i,ci=parseInt,hi="object"==typeof t&&t&&t.Object===Object&&t,ui="object"==typeof self&&self&&self.Object===Object&&self,di=hi||ui||Function("return this")(),fi=Object.prototype.toString,pi=Math.max,gi=Math.min,mi=function(){return di.Date.now()};function _i(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function vi(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==fi.call(t)}(t))return NaN;if(_i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=_i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(ri,"");var n=ai.test(t);return n||li.test(t)?ci(t.slice(2),n?2:8):si.test(t)?NaN:+t}var yi=function(t,e,n){var i,o,r,s,a,l,c=0,h=!1,u=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var n=i,r=o;return i=o=void 0,c=e,s=t.apply(r,n)}function p(t){return c=t,a=setTimeout(m,e),h?f(t):s}
|
|
@@ -95,7 +95,7 @@ const o=Ni(t.exact,e);ki.set(o,{pageIndex:n,anchor:i})}return Ii(n,i.start,i.end
|
|
|
95
95
|
children:t})}function qi({info:t}){let e=t.item.title;return t.item.subtitle&&(e+=`: ${t.item.subtitle}`),ct("div",{className:c("h-10 bg-white px-4 text-slate-7 text-annotator-base border-b","grid items-center","grid-cols-[100px_minmax(0,auto)]","2xl:grid-cols-[100px_minmax(0,auto)_minmax(0,auto)] 2xl:gap-x-3"),children:[ct("div",{"data-testid":"content-logo",children:t.logo&&ct(we,{href:t.logo.link,target:"_blank","data-testid":"logo-link",children:ct("img",{alt:t.logo.title,src:t.logo.logo,"data-testid":"logo-image"})})}),ct("div",{className:c("hidden","2xl:block 2xl:whitespace-nowrap 2xl:overflow-hidden 2xl:text-ellipsis","font-semibold"),"data-testid":"content-container-info",title:t.container.title,children:t.container.title}),ct("div",{className:c("flex justify-center items-center gap-x-2"),"data-testid":"content-item-info",children:[ct("div",{className:c("hidden","2xl:block 2xl:grow")}),t.links.previousItem&&ct(m,{children:[ct(we,{classes:"flex gap-x-1 items-center text-annotator-sm whitespace-nowrap",
|
|
96
96
|
title:"Open previous item",href:t.links.previousItem,underline:"always",target:"_blank","data-testid":"content-previous-link",children:[ct(oe,{className:"w-em h-em"}),ct("span",{children:"Previous"})]}),ct("div",{className:"text-annotator-sm",children:"|"})]}),ct("div",{className:c("min-w-0 whitespace-nowrap overflow-hidden text-ellipsis shrink font-medium"),children:ct(be,{title:e,href:t.links.currentItem,"data-testid":"content-item-link",target:"_blank",unstyled:!0,children:e})}),t.links.nextItem&&ct(m,{children:[ct("div",{className:"text-annotator-sm",children:"|"}),ct(we,{title:"Open next item",classes:"flex gap-x-1 items-center text-annotator-sm whitespace-nowrap",href:t.links.nextItem,underline:"always",target:"_blank","data-testid":"content-next-link",children:[ct("span",{children:"Next"}),ct(se,{className:"w-em h-em"})]})]})]})]})}function Ui(){return ct("div",{className:"bg-white",children:ct("div",{
|
|
97
97
|
className:c("flex items-center gap-x-2","border border-yellow-notice bg-yellow-notice/10 text-annotator-base"),children:[ct("div",{className:"bg-yellow-notice text-white p-2",children:ct(vt,{name:"caution",classes:"text-annotator-xl"})}),ct("div",{children:[ct("strong",{children:"This PDF does not contain selectable text:"})," ",ct(yt,{target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})})}class zi{constructor(t){this._loaded=function(t){return t.initializedPromise?t.initializedPromise:t.initialized?Promise.resolve():new Promise((e=>{const n=setInterval((()=>{t.initialized&&(clearTimeout(n),e())}),5)}))}(t).then((()=>t.downloadComplete?t:new Promise((e=>{const n=()=>{t.eventBus?(t.eventBus.off("documentload",n),t.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),e(t)};t.eventBus?(t.eventBus.on("documentloaded",n),
|
|
98
|
-
t.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))))}getUri(){return this._loaded.then((t=>{let e=
|
|
98
|
+
t.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))))}getUri(){return this._loaded.then((t=>{let e=Wi(t);return e||(e=ji($i(t))),e}))}async getMetadata(){const t=await this._loaded,{info:e,contentDispositionFilename:n,metadata:i}=await t.pdfDocument.getMetadata(),o=$i(t),r=Wi(t);let s;s=null!=i&&i.has("dc:title")&&"Untitled"!==i.get("dc:title")?i.get("dc:title"):null!=e&&e.Title?e.Title:n||(r?function(t){const e=new URL(t).pathname.split("/");return e[e.length-1]}(r):"");const a=[{href:ji(o)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:o}}}function $i(t){return Array.isArray(t.pdfDocument.fingerprints)?t.pdfDocument.fingerprints[0]:t.pdfDocument.fingerprint}function ji(t){return`urn:x-pdf:${t}`}function Wi(t){if(!t.url)return null;const e=An(t.url);return 0!==e.indexOf("file://")?e:null}function Xi(t){var e;const n=null===(e=t.highlights)||void 0===e?void 0:e[0];return n&&Fe(n)}function Yi(t){return new Promise((e=>setTimeout(e,t)))}class Zi extends Rt{
|
|
99
99
|
constructor(t,e={}){var n,i,o;super(),this.annotator=t;const r=window,s=r.PDFViewerApplication;this.pdfViewer=s.pdfViewer,this.pdfViewer.viewer.classList.add("has-transparent-text-layer"),this.pdfContainer=null!==(n=null===(i=s.appConfig)||void 0===i?void 0:i.appContainer)&&void 0!==n?n:document.body,this.pdfMetadata=new zi(s),this.observer=new MutationObserver(yi((()=>this._update()),100)),this.observer.observe(this.pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=null!==(o=e.reanchoringMaxWait)&&void 0!==o?o:3e3,this._banner=null,this._bannerState={contentInfo:null,noTextWarning:!1},this._updateBannerState(this._bannerState),this._checkForSelectableText(),this._updateAnnotationLayerVisibility=()=>{const t=r.getSelection();this.pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new Ct,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){var t
|
|
100
100
|
;this._listeners.removeAll(),this.pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this.observer.disconnect(),null===(t=this._banner)||void 0===t||t.remove(),this._destroyed=!0}uri(){return this.pdfMetadata.getUri()}getMetadata(){return this.pdfMetadata.getMetadata()}showContentInfo(t){this._updateBannerState({contentInfo:t})}anchor(t,e){return Fi(0,e)}canAnnotate(t){return function(t){try{return Hi(t),!0}catch{return!1}}(t)}canStyleClusteredHighlights(){return!0}describe(t,e){return Di(t,e)}async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._destroyed)try{const t=await async function(){const t=Ti();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await Li(n)).trim().length>0){e=!0;break}return e}();this._updateBannerState({noTextWarning:!t})}catch(t){console.warn("Unable to check for text in PDF:",t)}}_updateBannerState(t){this._bannerState={...this._bannerState,...t};const e=document.querySelector("#outerContainer");var n
|
|
101
101
|
;if(!(this._bannerState.contentInfo||this._bannerState.noTextWarning))return null===(n=this._banner)||void 0===n||n.remove(),this._banner=null,void(e.style.height="");this._banner||(this._banner=document.createElement("hypothesis-banner"),document.body.prepend(this._banner),Ae(this._banner)),I(ct(Vi,{children:[this._bannerState.contentInfo&&ct(qi,{info:this._bannerState.contentInfo}),this._bannerState.noTextWarning&&ct(Ui,{})]}),this._banner.shadowRoot);const i=this._banner.getBoundingClientRect().height;e.style.height=`calc(100% - ${i}px)`}_update(){const t=[],e=this.pdfViewer.pagesCount;for(let t=0;t<e;t++){var n;const e=this.pdfViewer.getPageView(t);if(null!=e&&null!==(n=e.textLayer)&&void 0!==n&&n.renderingDone)switch(e.renderingState){case xi:e.textLayer=null;break;case Si:i=e.div,o=void 0,null===(o=i.querySelector(Be))||void 0===o||o.remove()}}var i,o;for(let e of this.annotator.anchors)if(e.highlights){if(t.includes(e.annotation))continue;for(let n=0;n<e.highlights.length;n++){const i=e.highlights[n]
|
|
@@ -105,30 +105,30 @@ this._annotatableFrames.delete(t),this._onFrameRemoved(t)}_discoverFrames(){cons
|
|
|
105
105
|
;let l=!1;o=()=>{s(),l||(i=setInterval(a,n))},t.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),t.removeEventListener("load",a)}}class Ji{constructor(t,e,n){if(e.length!==n.length)throw new Error("Char boxes length does not match text length");const i=t.parentNode,o=document.createElement("hypothesis-text-layer");i.insertBefore(o,t.nextSibling),i.style.position="relative",o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.color="transparent",o.style.textAlign="left",o.style.mixBlendMode="multiply";const r="sans-serif";o.style.fontSize="16px",o.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font="16px sans-serif";const a=(t,e,n="px")=>`calc(var(--${t}-scale) * ${e}${n})`,l=function(t,e){const n=[];let i={text:"",rect:new DOMRect};const o=()=>{i.text.length>0&&(n.push(i),i={text:"",rect:new DOMRect})};for(let[n,r]of t.entries()){const t=e[n],s=/\s/.test(t);i.rect=In(i.rect,r),i.text+=s?" ":t,s&&o()}o();const r=[];let s={
|
|
106
106
|
words:[],rect:new DOMRect};const a=()=>{s.words.length>0&&(r.push(s),s={words:[],rect:new DOMRect})};for(let t of n){const e=s.words[s.words.length-1];if(e){const n=Bn(e.rect),i=Bn(t.rect).x-n.x;(!Mn(e.rect,t.rect)||i<0)&&a()}s.words.push(t),s.rect=In(s.rect,t.rect)}a();const l=[];let c={lines:[],rect:new DOMRect};const h=()=>{c.lines.length>0&&(l.push(c),c={lines:[],rect:new DOMRect})};for(let t of r){const e=c.lines[c.lines.length-1];if(e){const n=Bn(e.rect),i=Bn(t.rect).y-n.y;(!On(e.rect,t.rect)||Mn(e.rect,t.rect)||i<0||i>4*t.rect.height)&&h()}c.lines.push(t),c.rect=In(c.rect,t.rect)}return h(),l}(e,n);for(let t of l){const e=document.createElement("hypothesis-text-column");e.style.display="block",e.style.position="absolute",e.style.left=a("x",t.rect.left),e.style.top=a("y",t.rect.top);let n=null;for(let i of t.lines){const o=document.createElement("hypothesis-text-line");o.style.display="block",o.style.marginLeft=a("x",i.rect.left-t.rect.left),o.style.height=a("y",i.rect.height),
|
|
107
107
|
n&&(o.style.marginTop=a("y",i.rect.top-n.rect.bottom)),n=i,o.style.whiteSpace="nowrap";let r=null;for(let t of i.words){const e=document.createElement("hypothesis-text-word");e.style.display="inline-block",e.style.transformOrigin="top left",e.textContent=t.text,r&&(e.style.marginLeft=a("x",t.rect.left-r.rect.right)),r=t,e.style.width=a("x",t.rect.width),e.style.height=a("y",t.rect.height),e.style.whiteSpace="pre";const n=s.measureText(t.text),i=a("x",t.rect.width/n.width,""),l=a("y",t.rect.height/16,"");e.style.transform=`scale(${i}, ${l})`,o.append(e)}e.append(o)}o.append(e)}const c=()=>{const{width:e,height:n}=t.getBoundingClientRect();o.style.width=e+"px",o.style.height=n+"px",o.style.setProperty("--x-scale",`${e}`),o.style.setProperty("--y-scale",`${n}`)};c(),this.container=o,this._updateTextLayerSize=yi(c,{maxWait:50}),this._listeners=new Ct,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(t)),
|
|
108
|
-
this._listeners.add(window,"resize",this._updateTextLayerSize)}updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){var t;this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),null===(t=this._imageSizeObserver)||void 0===t||t.disconnect()}}class to{constructor(t,e){this._config=e,this._frameObserver=new Gi(t,(t=>eo(t,e)),(()=>{}))}destroy(){this._frameObserver.disconnect()}}async function eo(t,e,n){if(null!==t.contentDocument.querySelector("script.js-hypothesis-config"))return;await Ki(t);const{assetRoot:i,notebookAppUrl:o,sidebarAppUrl:r}=Ut(document),s={...e,assetRoot:i,notebookAppUrl:o,sidebarAppUrl:r,subFrameIdentifier:null!=n?n:St(10)},a=document.createElement("script");a.className="js-hypothesis-config",a.type="application/json",a.innerText=JSON.stringify(s);const l=document.createElement("script");l.async=!0,l.src=e.clientUrl;const c=t.contentDocument;c.body.appendChild(a),c.body.appendChild(l)}
|
|
109
|
-
return t.querySelector("mosaic-book")}function io(t=window){var e;if(no(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&no(n)?"content":null}class oo{constructor(t){wt(this,"_frameObserver",void 0);const e=no();if(!e)throw new Error("Book container element not found");const n=new WeakSet,i=e.shadowRoot,o=()=>{const e=i.querySelector("iframe");e&&!n.has(e)&&(n.add(e),Qi(e,((n,i)=>{if(n)return;const o=i.body;o&&!o.querySelector("#page-content")&&eo(e,t,"vitalsource-content")})))};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(i,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function ro(){return document.querySelector("img#pbk-page")}class so extends Rt{constructor(t=document.body,e){var n;super(),wt(this,"_bookElement",void 0),wt(this,"_features",void 0),wt(this,"_htmlIntegration",void 0),wt(this,"_listeners",void 0),wt(this,"_textLayer",void 0),this._features=e.features
|
|
108
|
+
this._listeners.add(window,"resize",this._updateTextLayerSize)}updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){var t;this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),null===(t=this._imageSizeObserver)||void 0===t||t.disconnect()}}class to{constructor(t,e){this._config=e,this._frameObserver=new Gi(t,(t=>eo(t,e)),(()=>{}))}destroy(){this._frameObserver.disconnect()}}async function eo(t,e,n){if(null!==t.contentDocument.querySelector("script.js-hypothesis-config"))return;await Ki(t);const{assetRoot:i,notebookAppUrl:o,sidebarAppUrl:r}=Ut(document),s={...e,assetRoot:i,notebookAppUrl:o,sidebarAppUrl:r,subFrameIdentifier:null!=n?n:St(10)},a=document.createElement("script");a.className="js-hypothesis-config",a.setAttribute("data-remove-on-unload",""),a.type="application/json",a.innerText=JSON.stringify(s);const l=document.createElement("script");l.async=!0,l.src=e.clientUrl;const c=t.contentDocument;c.body.appendChild(a),c.body.appendChild(l)}
|
|
109
|
+
function no(t=document){return t.querySelector("mosaic-book")}function io(t=window){var e;if(no(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&no(n)?"content":null}class oo{constructor(t){wt(this,"_frameObserver",void 0);const e=no();if(!e)throw new Error("Book container element not found");const n=new WeakSet,i=e.shadowRoot,o=()=>{const e=i.querySelector("iframe");e&&!n.has(e)&&(n.add(e),Qi(e,((n,i)=>{if(n)return;const o=i.body;o&&!o.querySelector("#page-content")&&eo(e,t,"vitalsource-content")})))};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(i,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function ro(){return document.querySelector("img#pbk-page")}class so extends Rt{constructor(t=document.body,e){var n;super(),wt(this,"_bookElement",void 0),wt(this,"_features",void 0),wt(this,"_htmlIntegration",void 0),wt(this,"_listeners",void 0),wt(this,"_textLayer",void 0),this._features=e.features
|
|
110
110
|
;const i=null!==(n=e.bookElement)&&void 0!==n?n:no(window.parent.document);if(!i)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=i,this._features.on("flagsChanged",(()=>{this.emit("uriChanged")}));const o=new cn;o.update({html_side_by_side:!0}),this._htmlIntegration=new oi({container:t,features:o}),this._listeners=new Ct;const r=["mouseup","mousedown","mouseout"];for(const t of r)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const s=window.frameElement;s&&function(t){if("no"!==t.getAttribute("scrolling"))return;const e=document.createElement("style");e.textContent="iframe { height: 100% !important; }",t.insertAdjacentElement("beforebegin",e);const n=()=>t.removeAttribute("scrolling");n(),new MutationObserver(n).observe(t,{attributes:!0})}(s);const a=ro(),l=window.innerPageData;if(a&&l){const t=l.glyphs.glyphs.map((t=>{const e=t.l/100,n=t.r/100,i=t.t/100,o=t.b/100;return new DOMRect(e,i,n-e,o-i)}));this._textLayer=new Ji(a,t,l.words),
|
|
111
111
|
this._textLayer.container.style.zIndex="100"}}canAnnotate(){return!0}destroy(){var t;null===(t=this._textLayer)||void 0===t||t.destroy(),this._listeners.removeAll(),this._htmlIntegration.destroy()}anchor(t,e){return this._htmlIntegration.anchor(t,e)}async describe(t,e){const n=this._htmlIntegration.describe(t,e);if(!this._bookIsSingleDocument())return n;const i=await this._bookElement.getCurrentPage(),o=[{type:"EPUBContentSelector",cfi:i.cfi,url:i.absoluteURL,title:i.chapterTitle}];return"pbk"===this._bookElement.getBookInfo().format&&o.push({type:"PageSelector",index:i.index,label:i.page}),n.push(...o),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(t){const e=ro();if(e&&this._textLayer){const n=e.parentElement,i=this._textLayer,o=window.innerWidth-t.width;return zn((()=>{t.expanded&&o>480?(n.style.textAlign="left",e.style.width=`${o}px`):(n.style.textAlign="",e.style.width=""),i.updateSync()})),t.expanded}return this._htmlIntegration.fitSideBySide(t)}async getMetadata(){
|
|
112
112
|
if(this._bookIsSingleDocument()){return{title:this._bookElement.getBookInfo().title,link:[]}}return{title:document.title,link:[]}}navigateToSegment(t){var e;const n=null===(e=t.target[0].selector)||void 0===e?void 0:e.find((t=>"EPUBContentSelector"===t.type));if(null!=n&&n.cfi)this._bookElement.goToCfi(n.cfi);else{if(null==n||!n.url)throw new Error("No segment information available");this._bookElement.goToURL(n.url)}}persistFrame(){return!0}async segmentInfo(){const t=await this._bookElement.getCurrentPage();return{cfi:t.cfi,url:t.absoluteURL}}async uri(){if(this._bookIsSingleDocument()){return`https://bookshelf.vitalsource.com/reader/books/${this._bookElement.getBookInfo().isbn}`}const t=new URL(document.location.href);return t.search="",t.toString()}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}_bookIsSingleDocument(){return this._features.flagEnabled("book_as_single_document")}waitForFeatureFlags(){return!0}}function ao(t){
|
|
113
113
|
if("undefined"!=typeof PDFViewerApplication)return new Zi(t);return"content"===io()?new so(document.body,{features:t.features}):new oi({features:t.features})}function lo(t){const e=t.getSelection();if(!e||0===e.rangeCount)return null;const n=e.getRangeAt(0);return n.collapsed?null:n}class co{constructor(t,e=document){let n=!1;this._pendingCallback=null;const i=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(lo(e))}),n)},o=t=>{if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;i(e)};this._document=e,this._listeners=new Ct,this._listeners.add(e,"selectionchange",o),this._listeners.add(e.body,"mousedown",o),this._listeners.add(e.body,"mouseup",o),i(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function ho(){const t=function(t,e){const n=new Set,i=new Set;return Ve(t,(t=>{let o=t
|
|
114
|
-
;for(;o&&!n.has(o);){n.add(o);const t=e(o);null!=t&&i.add(t),o=o.parentNode}})),[...i]}(window.getSelection().getRangeAt(0),(t=>{var e;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}));return t}function uo(t){const e=function(t){let e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;const n=[];for(;e;)e.classList.contains("hypothesis-highlight")&&n.push(e),e=e.parentElement;return n}(t).map((t=>t._annotation)).filter((t=>void 0!==t)).map((t=>null==t?void 0:t.$tag));return e}function fo(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function po(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class go{constructor(t,e={},n=window){var i,o,r,s,a;(wt(this,"element",void 0),wt(this,"selectedRanges",void 0),wt(this,"anchors",void 0),wt(this,"features",void 0),wt(this,"_featureFlagsReceived",void 0),wt(this,"_adder",void 0),wt(this,"_clusterToolbar",void 0),wt(this,"_hostFrame",void 0),wt(this,"_highlightsVisible",void 0),
|
|
114
|
+
;for(;o&&!n.has(o);){n.add(o);const t=e(o);null!=t&&i.add(t),o=o.parentNode}})),[...i]}(window.getSelection().getRangeAt(0),(t=>{var e;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}));return t}function uo(t){const e=function(t){let e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;const n=[];for(;e;)e.classList.contains("hypothesis-highlight")&&n.push(e),e=e.parentElement;return n}(t).map((t=>t._annotation)).filter((t=>void 0!==t)).map((t=>null==t?void 0:t.$tag));return e}function fo(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function po(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class go extends Rt{constructor(t,e={},n=window){var i,o,r,s,a;(super(),wt(this,"element",void 0),wt(this,"selectedRanges",void 0),wt(this,"anchors",void 0),wt(this,"features",void 0),wt(this,"_featureFlagsReceived",void 0),wt(this,"_adder",void 0),wt(this,"_clusterToolbar",void 0),wt(this,"_hostFrame",void 0),wt(this,"_highlightsVisible",void 0),
|
|
115
115
|
wt(this,"_isAdderVisible",void 0),wt(this,"_informHostOnNextSelectionClear",void 0),wt(this,"_selectionObserver",void 0),wt(this,"_annotations",void 0),wt(this,"_frameIdentifier",void 0),wt(this,"_portFinder",void 0),wt(this,"_integration",void 0),wt(this,"_hostRPC",void 0),wt(this,"_sidebarRPC",void 0),wt(this,"_bucketBarClient",void 0),wt(this,"_sideBySideActive",void 0),wt(this,"_listeners",void 0),wt(this,"_hoveredAnnotations",void 0),this.element=t,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._adder=new Re(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0}),onShowAnnotations:t=>this.selectAnnotations(t,{focusInSidebar:!0})}),this._selectionObserver=new co((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new Nt({hostFrame:this._hostFrame,
|
|
116
116
|
source:"guest",sourceId:null!==(i=this._frameIdentifier)&&void 0!==i?i:void 0}),this.features=new cn,this._featureFlagsReceived=new Promise((t=>{this.features.on("flagsChanged",t)})),this._integration=ao(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),e.contentInfoBanner)&&(null===(s=(a=this._integration).showContentInfo)||void 0===s||s.call(a,e.contentInfoBanner));null!==(o=(r=this._integration).canStyleClusteredHighlights)&&void 0!==o&&o.call(r)&&(this._clusterToolbar=new rn(this._integration.contentContainer(),{features:this.features})),this._hostRPC=new Vt,this._connectHost(n),this._sidebarRPC=new Vt,this._connectSidebar(),this._bucketBarClient=new Je({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._sideBySideActive=!1,this._listeners=new Ct,this._setupElementEvents(),this._hoveredAnnotations=new Set}_setupElementEvents(){const t=t=>{this._sideBySideActive||uo(t).length||this._sidebarRPC.call("closeSidebar")}
|
|
117
117
|
;this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:i}=t,o=uo(e);if(o.length&&this._highlightsVisible){const t=n||i;this.selectAnnotations(o,{toggle:t})}})),this._listeners.add(this.element,"mousedown",(({target:e})=>{t(e)})),this._listeners.add(this.element,"touchstart",(({target:e})=>{t(e)})),this._listeners.add(this.element,"mouseover",(({target:t})=>{const e=uo(t);e.length&&this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(t=>{this._handleShortcut(t)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){var t,e,n,i,o;const[r,s,a]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),null===(t=(e=this._integration).segmentInfo)||void 0===t?void 0:t.call(e)]);return{uri:An(r),metadata:s,segmentInfo:a,
|
|
118
118
|
persistent:null!==(n=null===(i=(o=this._integration).persistFrame)||void 0===i?void 0:i.call(o))&&void 0!==n&&n}}async _sendDocumentInfo(){var t,e;null!==(t=(e=this._integration).waitForFeatureFlags)&&void 0!==t&&t.call(e)&&await this._featureFlagsReceived;const n=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",n)}_repositionAdder(){var t;if(!1===this._isAdderVisible)return;const e=null===(t=window.getSelection())||void 0===t?void 0:t.getRangeAt(0);e&&this._onSelection(e)}async _connectHost(t){this._hostRPC.on("clearSelection",(()=>{lo(document)&&(this._informHostOnNextSelectionClear=!1,po())})),this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._hostRPC.on("scrollToClosestOffScreenAnchor",((t,e)=>this._scrollToClosestOffScreenAnchor(t,e))),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,{toggle:e}))),this._hostRPC.on("sidebarLayoutChanged",(e=>{var n,i
|
|
119
|
-
;((n=window)===(i=t)||n.parent===i&&n.frameElement&&n.frameElement.getBoundingClientRect().width/n.parent.innerWidth>=.8)&&this.fitSideBySide(e)}));const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=fo(e);if(!n)return;const i=new CustomEvent("scrolltorange",{bubbles:!0,cancelable:!0,detail:n});this.element.dispatchEvent(i)&&this._integration.scrollToAnchor(e)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t))))),this._sidebarRPC.on("showContentInfo",(t=>{
|
|
120
|
-
;return null===(e=(n=this._integration).showContentInfo)||void 0===e?void 0:e.call(n,t)})),this._sidebarRPC.on("navigateToSegment",(t=>{var e,n;return null===(e=(n=this._integration).navigateToSegment)||void 0===e?void 0:e.call(n,t)})),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this._sendDocumentInfo()}destroy(){var t;this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),null===(t=this._clusterToolbar)||void 0===t||t.destroy(),function(t){
|
|
121
|
-
t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=Ie.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&
|
|
122
|
-
;const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+St(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),po(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);Xe(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(let r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue;const t=Ye(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}
|
|
123
|
-
if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=He(e),i=qe(e);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=ho(),this._isAdderVisible=!0,this._adder.show(i,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){
|
|
124
|
-
get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Kt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function mo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function _o(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.
|
|
125
|
-
title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:mo(t.notebookAppUrl,{..._o(t.notebookAppUrl,t),group:e})})}function yo({eventBus:t,config:e}){const[n,i]=G(0),[o,r]=G(!0),[s,a]=G(null),l=J(""),h=J(null);K((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),K((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),K((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),h.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ct("div",{className:c("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:ct("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ct("div",{className:"absolute right-0 text-xl m-3",children:ct(gt,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),
|
|
126
|
-
groupId:s},n)]})})}class bo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=Ae(this._outerContainer),I(ct(yo,{eventBus:e,config:n}),this.shadowRoot)}destroy(){I(null,this.shadowRoot),this._outerContainer.remove()}}var wo={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
|
|
119
|
+
;((n=window)===(i=t)||n.parent===i&&n.frameElement&&n.frameElement.getBoundingClientRect().width/n.parent.innerWidth>=.8)&&this.fitSideBySide(e)})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected")));const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=fo(e);if(!n)return;const i=new CustomEvent("scrolltorange",{bubbles:!0,cancelable:!0,detail:n});this.element.dispatchEvent(i)&&this._integration.scrollToAnchor(e)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t))))),this._sidebarRPC.on("showContentInfo",(t=>{
|
|
120
|
+
var e,n;return null===(e=(n=this._integration).showContentInfo)||void 0===e?void 0:e.call(n,t)})),this._sidebarRPC.on("navigateToSegment",(t=>{var e,n;return null===(e=(n=this._integration).navigateToSegment)||void 0===e?void 0:e.call(n,t)})),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this._sendDocumentInfo()}destroy(){var t;this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),null===(t=this._clusterToolbar)||void 0===t||t.destroy(),function(t){We(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){const e=t=>{var e;const n=fo(t);if(!n)return;const i=$e(n,null===(e=t.annotation)||void 0===e?void 0:e.$cluster);i.forEach((e=>{e._annotation=t.annotation})),t.highlights=i,this._hoveredAnnotations.has(t.annotation.$tag)&&Xe(i,!0)};this.detach(t.$tag,!1),
|
|
121
|
+
this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=Ie.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&We(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges
|
|
122
|
+
;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+St(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),po(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);Xe(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(let r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue;const t=Ye(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}
|
|
123
|
+
_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=He(e),i=qe(e);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=ho(),this._isAdderVisible=!0,this._adder.show(i,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){
|
|
124
|
+
this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Kt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function mo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function _o(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1158.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}
|
|
125
|
+
function vo({config:t,groupId:e}){return ct("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:mo(t.notebookAppUrl,{..._o(t.notebookAppUrl,t),group:e})})}function yo({eventBus:t,config:e}){const[n,i]=G(0),[o,r]=G(!0),[s,a]=G(null),l=J(""),h=J(null);K((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),K((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),K((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),h.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ct("div",{className:c("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:ct("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ct("div",{className:"absolute right-0 text-xl m-3",children:ct(gt,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),
|
|
126
|
+
null===(t=h.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),ct(vo,{config:e,groupId:s},n)]})})}class bo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=Ae(this._outerContainer),I(ct(yo,{eventBus:e,config:n}),this.shadowRoot)}destroy(){I(null,this.shadowRoot),this._outerContainer.remove()}}var wo={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
|
|
127
127
|
var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=e.console&&(e.console.warn||e.console.log);return r&&r.call(e.console,o,i),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===o||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==o&&null!==i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign;var g=p((function(t,e,n){for(var i=Object.keys(e),r=0;r<i.length;)(!n||n&&t[i[r]]===o)&&(t[i[r]]=e[i[r]]),r++;return t}),"extend","Use `assign`."),m=p((function(t,e){return g(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var i,o=e.prototype;(i=t.prototype=Object.create(o)).constructor=t,i._super=o,n&&r(i,n)}function v(t,e){return function(){return t.apply(e,arguments)}}function y(t,e){
|
|
128
128
|
return"function"==typeof t?t.apply(e&&e[0]||o,e):t}function b(t,e){return t===o?e:t}function w(t,e,n){f(E(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(E(e),(function(e){t.removeEventListener(e,n,!1)}))}function x(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function E(t){return t.trim().split(/\s+/g)}function k(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}function N(t){return Array.prototype.slice.call(t,0)}function A(t,e,n){for(var i=[],o=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];k(o,s)<0&&i.push(t[r]),o[r]=s,r++}return n&&(i=e?i.sort((function(t,n){return t[e]>n[e]})):i.sort()),i}function T(t,e){for(var n,i,r=e[0].toUpperCase()+e.slice(1),a=0;a<s.length;){if((i=(n=s[a])?n+r:e)in t)return i;a++}return o}var R=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
|
|
129
|
-
var P="ontouchstart"in e,M=T(e,"PointerEvent")!==o,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",B="mouse",F=24,H=["x","y"],D=["clientX","clientY"];function V(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){y(t.options.enable,[t])&&n.handler(e)},this.init()}function q(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=1&e&&i-r==0,a=12&e&&i-r==0;n.isFirst=!!s,n.isFinal=!!a,s&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=U(e));r>1&&!n.firstMultiple?n.firstMultiple=U(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,u=e.center=z(i);e.timeStamp=h(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=X(l,u),e.distance=
|
|
130
|
-
i=t.offsetDelta={x:n.x,y:n.y});e.deltaX=o.x+(n.x-i.x),e.deltaY=o.y+(n.y-i.y)}(n,e),e.offsetDirection=
|
|
131
|
-
function U(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:h(),pointers:e,center:z(e),deltaX:t.deltaX,deltaY:t.deltaY}}function z(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,i=0,o=0;o<e;)n+=t[o].clientX,i+=t[o].clientY,o++;return{x:l(n/e),y:l(i/e)}}function $(t,e,n){return{x:e/t||0,y:n/t||0}}function
|
|
129
|
+
var P="ontouchstart"in e,M=T(e,"PointerEvent")!==o,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",B="mouse",F=24,H=["x","y"],D=["clientX","clientY"];function V(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){y(t.options.enable,[t])&&n.handler(e)},this.init()}function q(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=1&e&&i-r==0,a=12&e&&i-r==0;n.isFirst=!!s,n.isFinal=!!a,s&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=U(e));r>1&&!n.firstMultiple?n.firstMultiple=U(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,u=e.center=z(i);e.timeStamp=h(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=X(l,u),e.distance=W(l,u),function(t,e){var n=e.center,i=t.offsetDelta||{},o=t.prevDelta||{},r=t.prevInput||{};1!==e.eventType&&4!==r.eventType||(o=t.prevDelta={x:r.deltaX||0,y:r.deltaY||0},
|
|
130
|
+
i=t.offsetDelta={x:n.x,y:n.y});e.deltaX=o.x+(n.x-i.x),e.deltaY=o.y+(n.y-i.y)}(n,e),e.offsetDirection=j(e.deltaX,e.deltaY);var d=$(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,e.scale=a?(f=a.pointers,p=i,W(p[0],p[1],D)/W(f[0],f[1],D)):1,e.rotation=a?function(t,e){return X(e[1],e[0],D)+X(t[1],t[0],D)}(a.pointers,i):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,r,s,a=t.lastInterval||e,l=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(l>25||a.velocity===o)){var h=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=$(l,h,u);i=d.x,r=d.y,n=c(d.x)>c(d.y)?d.x:d.y,s=j(h,u),t.lastInterval=e}else n=a.velocity,i=a.velocityX,r=a.velocityY,s=a.direction;e.velocity=n,e.velocityX=i,e.velocityY=r,e.direction=s}(n,e);var f,p;var g=t.element;x(e.srcEvent.target,g)&&(g=e.srcEvent.target);e.target=g}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}
|
|
131
|
+
function U(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:h(),pointers:e,center:z(e),deltaX:t.deltaX,deltaY:t.deltaY}}function z(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,i=0,o=0;o<e;)n+=t[o].clientX,i+=t[o].clientY,o++;return{x:l(n/e),y:l(i/e)}}function $(t,e,n){return{x:e/t||0,y:n/t||0}}function j(t,e){return t===e?1:c(t)>=c(e)?t<0?2:4:e<0?8:16}function W(t,e,n){n||(n=H);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return Math.sqrt(i*i+o*o)}function X(t,e,n){n||(n=H);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return 180*Math.atan2(o,i)/Math.PI}V.prototype={handler:function(){},init:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(L(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),
|
|
132
132
|
this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(L(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4},Z="mousedown",G="mousemove mouseup";function K(){this.evEl=Z,this.evWin=G,this.pressed=!1,V.apply(this,arguments)}_(K,V,{handler:function(t){var e=Y[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:B,srcEvent:t}))}});var Q={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:I,3:"pen",4:B,5:"kinect"},tt="pointerdown",et="pointermove pointerup pointercancel";function nt(){this.evEl=tt,this.evWin=et,V.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(tt="MSPointerDown",et="MSPointerMove MSPointerUp MSPointerCancel"),_(nt,V,{handler:function(t){
|
|
133
133
|
var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),o=Q[i],r=J[t.pointerType]||t.pointerType,s=r==I,a=k(e,t.pointerId,"pointerId");1&o&&(0===t.button||s)?a<0&&(e.push(t),a=e.length-1):12&o&&(n=!0),a<0||(e[a]=t,this.callback(this.manager,o,{pointers:e,changedPointers:[t],pointerType:r,srcEvent:t}),n&&e.splice(a,1))}});var it={touchstart:1,touchmove:2,touchend:4,touchcancel:8},ot="touchstart",rt="touchstart touchmove touchend touchcancel";function st(){this.evTarget=ot,this.evWin=rt,this.started=!1,V.apply(this,arguments)}function at(t,e){var n=N(t.touches),i=N(t.changedTouches);return 12&e&&(n=A(n.concat(i),"identifier",!0)),[n,i]}_(st,V,{handler:function(t){var e=it[t.type];if(1===e&&(this.started=!0),this.started){var n=at.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:I,srcEvent:t})}}});var lt={touchstart:1,touchmove:2,touchend:4,touchcancel:8},ct="touchstart touchmove touchend touchcancel"
|
|
134
134
|
;function ht(){this.evTarget=ct,this.targetIds={},V.apply(this,arguments)}function ut(t,e){var n=N(t.touches),i=this.targetIds;if(3&e&&1===n.length)return i[n[0].identifier]=!0,[n,n];var o,r,s=N(t.changedTouches),a=[],l=this.target;if(r=n.filter((function(t){return x(t.target,l)})),1===e)for(o=0;o<r.length;)i[r[o].identifier]=!0,o++;for(o=0;o<s.length;)i[s[o].identifier]&&a.push(s[o]),12&e&&delete i[s[o].identifier],o++;return a.length?[A(r.concat(a),"identifier",!0),a]:void 0}_(ht,V,{handler:function(t){var e=lt[t.type],n=ut.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:I,srcEvent:t})}});function dt(){V.apply(this,arguments);var t=v(this.handler,this);this.touch=new ht(this.manager,t),this.mouse=new K(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function ft(t,e){1&t?(this.primaryTouch=e.changedPointers[0].identifier,pt.call(this,e)):12&t&&pt.call(this,e)}function pt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={
|
|
@@ -139,7 +139,7 @@ this.options.enable=b(this.options.enable,!0),this.state=1,this.simultaneous={},
|
|
|
139
139
|
return!0},recognize:function(t){var e=r({},t);if(!y(this.options.enable,[this,e]))return this.reset(),void(this.state=kt);56&this.state&&(this.state=1),this.state=this.process(e),30&this.state&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},_(Lt,Nt,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,n=t.eventType,i=6&e,o=this.attrTest(t);return i&&(8&n||!o)?16|e:i||o?4&n?8|e:2&e?4|e:2:kt}}),_(Pt,Lt,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var t=this.options.direction,e=[];return 6&t&&e.push(xt),t&F&&e.push(Ct),e},directionTest:function(t){var e=this.options,n=!0,i=t.distance,o=t.direction,r=t.deltaX,s=t.deltaY;return o&e.direction||(6&e.direction?(o=0===r?1:r<0?2:4,n=r!=this.pX,i=Math.abs(t.deltaX)):(o=0===s?1:s<0?8:16,n=s!=this.pY,i=Math.abs(t.deltaY))),t.direction=o,n&&i>e.threshold&&o&e.direction},attrTest:function(t){
|
|
140
140
|
return Lt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Tt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),_(Mt,Lt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[wt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),_(Ot,Nt,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,o=t.deltaTime>e.time;if(this._input=t,!i||!n||12&t.eventType&&!o)this.reset();else if(1&t.eventType)this.reset(),this._timer=u((function(){this.state=8,this.tryEmit()}),e.time,this);else if(4&t.eventType)return 8;return kt},
|
|
141
141
|
reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=h(),this.manager.emit(this.options.event,this._input)))}}),_(It,Lt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[wt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),_(Bt,Lt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Pt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:n&F&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&c(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=Tt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),
|
|
142
|
-
this.manager.emit(this.options.event,t)}}),_(Ft,Nt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[bt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,o=t.deltaTime<e.time;if(this.reset(),1&t.eventType&&0===this.count)return this.failTimeout();if(i&&o&&n){if(4!=t.eventType)return this.failTimeout();var r=!this.pTime||t.timeStamp-this.pTime<e.interval,s=!this.pCenter||
|
|
142
|
+
this.manager.emit(this.options.event,t)}}),_(Ft,Nt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[bt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,o=t.deltaTime<e.time;if(this.reset(),1&t.eventType&&0===this.count)return this.failTimeout();if(i&&o&&n){if(4!=t.eventType)return this.failTimeout();var r=!this.pTime||t.timeStamp-this.pTime<e.interval,s=!this.pCenter||W(this.pCenter,t.center)<e.posThreshold;if(this.pTime=t.timeStamp,this.pCenter=t.center,s&&r?this.count+=1:this.count=1,this._input=t,0===this.count%e.taps)return this.hasRequireFailures()?(this._timer=u((function(){this.state=8,this.tryEmit()}),e.interval,this),2):8}return kt},failTimeout:function(){return this._timer=u((function(){this.state=kt}),this.options.interval,this),kt},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,
|
|
143
143
|
this.manager.emit(this.options.event,this._input))}}),Ht.VERSION="2.0.7",Ht.defaults={domEvents:!1,touchAction:vt,enable:!0,inputTarget:null,inputClass:null,preset:[[It,{enable:!1}],[Mt,{enable:!1},["rotate"]],[Bt,{direction:6}],[Pt,{direction:6},["swipe"]],[Ft],[Ft,{event:"doubletap",taps:2},["tap"]],[Ot]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Dt(t,e){var n;this.options=r({},Ht.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(M?nt:O?ht:P?dt:K))(n,q),this.touchAction=new Et(this,this.options.touchAction),Vt(this,!0),f(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function Vt(t,e){var n,i=t.element;i.style&&(f(t.options.cssProps,(function(o,r){n=T(i.style,r),
|
|
144
144
|
e?(t.oldCssProps[n]=i.style[n],i.style[n]=o):i.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Dt.prototype={set:function(t){return r(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,o=e.curRecognizer;(!o||o&&8&o.state)&&(o=e.curRecognizer=null);for(var r=0;r<i.length;)n=i[r],2===e.stopped||o&&n!=o&&!n.canRecognizeWith(o)?n.reset():n.recognize(t),!o&&14&n.state&&(o=e.curRecognizer=n),r++}},get:function(t){if(t instanceof Nt)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event==t)return e[n];return null},add:function(t){if(d(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){
|
|
145
145
|
if(d(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=k(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==o&&e!==o){var n=this.handlers;return f(E(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==o){var n=this.handlers;return f(E(t),(function(t){e?n[t]&&n[t].splice(k(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var i=n.createEvent("Event");i.initEvent(t,!0,!0),i.gesture=e,e.target.dispatchEvent(i)}(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var o=0;o<i.length;)i[o](e),o++}},destroy:function(){this.element&&Vt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},r(Ht,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:kt,
|
|
@@ -157,6 +157,7 @@ this._sidebarRPC.on("publicAnnotationCountChanged",(function(e){const n=t.queryS
|
|
|
157
157
|
this._emitter.subscribe("closeNotebook",(()=>{this.show()}));[["loginRequested",this.onLoginRequest],["logoutRequested",this.onLogoutRequest],["signupRequested",this.onSignupRequest],["profileRequested",this.onProfileRequest],["helpRequested",this.onHelpRequest]].forEach((([t,e])=>{e&&this._sidebarRPC.on(t,(()=>e()))}))}_resetGestureState(){this._gestureState={initial:null,final:null}}_setupGestures(){const t=this.toolbar.sidebarToggleButton;t&&(this._hammerManager=new wo.exports.Manager(t),this._hammerManager.on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new wo.exports.Pan({direction:wo.exports.DIRECTION_HORIZONTAL})))}_updateLayout(){this.renderFrame||(this.renderFrame=requestAnimationFrame((()=>{if(this.renderFrame=null,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const t=this._gestureState.final,e=-t;this.iframeContainer.style.marginLeft=`${t}px`,e>=Ro&&(this.iframeContainer.style.width=`${e}px`),this._updateLayoutState()}})))}
|
|
158
158
|
_updateLayoutState(t){var e;const n=this.iframeContainer&&this.toolbar.getWidth()||0,i=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,o=i.getBoundingClientRect(),r=window.getComputedStyle(i),s=parseInt(r.width),a=parseInt(r.marginLeft);let l=n;"boolean"==typeof t?t&&(l+=s):(a<Ro?l-=a:l+=s,t=l>n);const c={expanded:t,width:t?l:n,height:o.height,toolbarWidth:n};this._layoutState=c,this.onLayoutChange&&this.onLayoutChange(c),this._guestRPC.forEach((t=>t.call("sidebarLayoutChanged",c)))}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<Ro?this.close():this.open())}_onPan(t){const e=this.iframeContainer;if(e)switch(t.type){case"panstart":this._resetGestureState(),e.classList.add("sidebar-no-transition"),e.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(e).marginLeft);break;case"panend":e.classList.remove("sidebar-no-transition"),e.style.pointerEvents="",null===this._gestureState.final||this._gestureState.final<=-280?this.open():this.close(),
|
|
159
159
|
this._resetGestureState();break;case"panleft":case"panright":{if("number"!=typeof this._gestureState.initial)return;const e=this._gestureState.initial,n=t.deltaX;this._gestureState.final=Math.min(Math.round(e+n),0),this._updateLayout();break}}}open(){if(this._sidebarRPC.call("sidebarOpened"),this.iframeContainer){const t=this.iframeContainer.getBoundingClientRect().width;this.iframeContainer.style.marginLeft=-1*t+"px",this.iframeContainer.classList.remove("sidebar-collapsed")}this.toolbar.sidebarOpen=!0,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!0),this._updateLayoutState(!0)}close(){this.iframeContainer&&(this.iframeContainer.style.marginLeft="",this.iframeContainer.classList.add("sidebar-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!1),this._updateLayoutState(!1)}setHighlightsVisible(t){this.toolbar.highlightsVisible=t,this._sidebarRPC.call("setHighlightsVisible",t)}show(){
|
|
160
|
-
this.iframeContainer&&this.iframeContainer.classList.remove("is-hidden")}hide(){this.iframeContainer&&this.iframeContainer.classList.add("is-hidden")}}class Po{constructor(t){this._emitter=t,this._subscriptions=[]}publish(t,...e){this._emitter.emit(t,...e)}subscribe(t,e){this._emitter.on(t,e),this._subscriptions.push([t,e])}unsubscribe(t,e){this._emitter.off(t,e),this._subscriptions=this._subscriptions.filter((([n,i])=>n!==t||i!==e))}destroy(){for(let[t,e]of this._subscriptions)this._emitter.off(t,e);this._subscriptions=[]}}class Mo{constructor(){this._emitter=new Rt}createEmitter(){return new Po(this._emitter)}}!function(t,{reset:e=!1}={}){e&&ht.clear();for(let[e,n]of Object.entries(t))ht.set(e,n)}(bt);const Oo=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=Zt("annotator")
|
|
161
|
-
const t=function(t=navigator.userAgent){if(!Dt(t))return()=>{};const e=t=>{var e;if("hypothesisPortClosed"===(null===(e=t.data)||void 0===e?void 0:e.type)&&t.ports[0]){const e=t.ports[0];Ht(e,"close"),e.close()}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}();
|
|
160
|
+
this.iframeContainer&&this.iframeContainer.classList.remove("is-hidden")}hide(){this.iframeContainer&&this.iframeContainer.classList.add("is-hidden")}}class Po{constructor(t){this._emitter=t,this._subscriptions=[]}publish(t,...e){this._emitter.emit(t,...e)}subscribe(t,e){this._emitter.on(t,e),this._subscriptions.push([t,e])}unsubscribe(t,e){this._emitter.off(t,e),this._subscriptions=this._subscriptions.filter((([n,i])=>n!==t||i!==e))}destroy(){for(let[t,e]of this._subscriptions)this._emitter.off(t,e);this._subscriptions=[]}}class Mo{constructor(){this._emitter=new Rt}createEmitter(){return new Po(this._emitter)}}!function(t,{reset:e=!1}={}){e&&ht.clear();for(let[e,n]of Object.entries(t))ht.set(e,n)}(bt);const Oo=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=Zt("annotator");let e=()=>{};const n=new Promise((t=>{e=t}))
|
|
161
|
+
;Oo.addEventListener("destroy",e);const i=t.subFrameIdentifier?window.parent:window,o=[];if(i===window){const t=function(t=navigator.userAgent){if(!Dt(t))return()=>{};const e=t=>{var e;if("hypothesisPortClosed"===(null===(e=t.data)||void 0===e?void 0:e.type)&&t.ports[0]){const e=t.ports[0];Ht(e,"close"),e.close()}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}();o.push({destroy:t});const e=Zt("sidebar"),n=new URL(e.sidebarAppUrl).origin,i=new It(n),r=new Mo,s=new Lo(document.body,r,e),a=new bo(document.body,r,Zt("notebook"));i.on("frameConnected",((t,e)=>s.onFrameConnected(t,e))),o.push(i,s,a)}if("container"===io()){const e=new oo(t);o.push(e)}else{const n=new to(document.body,t),r=new go(document.body,t,i);r.on("hostDisconnected",e),o.push(n,r)}n.then((()=>{o.forEach((t=>t.destroy()));document.querySelectorAll("[data-hypothesis-asset]").forEach((t=>t.remove())),function(t=document){
|
|
162
|
+
Array.from(t.querySelectorAll("script.js-hypothesis-config[data-remove-on-unload]")).forEach((t=>t.remove()))}()}))}))}();
|
|
162
163
|
//# sourceMappingURL=annotator.bundle.js.map
|