hypothesis 1.950.0 → 1.954.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 +9 -9
- package/build/scripts/annotator.bundle.js +36 -36
- package/build/scripts/annotator.bundle.js.map +1 -1
- package/build/scripts/sidebar.bundle.js +37 -36
- package/build/scripts/sidebar.bundle.js.map +1 -1
- package/build/styles/annotator.css +1 -1
- package/build/styles/annotator.css.map +1 -1
- package/build/styles/sidebar.css +1 -1
- package/build/styles/sidebar.css.map +1 -1
- package/package.json +1 -1
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function t(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function e(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),n=1;n<e;n++)s[n-1]=arguments[n];return s.every((function(e){return"function"==typeof t[e]}))}var s={es2017:function(){return!e(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!e(Promise.prototype,"finally")}};function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);"Object"===s&&t.constructor&&(s=t.constructor.name);if("Map"===s||"Set"===s)return Array.from(t);if("Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=new Array(e);s<e;s++)n[s]=t[s];return n}var o=["es2017","es2018"];function a(t){t.setAttribute("data-hypothesis-asset","")}function i(t,e){var s=t.createElement("link");s.rel="stylesheet",s.type="text/css",s.href=e,a(s),t.head.appendChild(s)}function c(t,e){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=t.createElement("script");n.type="module",s&&(e+="#ts=".concat(Date.now())),n.src=e,n.async=!1,a(n),t.head.appendChild(n)}function l(t,e,s,n){var r=t.createElement("link");r.rel=e,r.href=n,r.type="application/annotator+".concat(s),a(r),t.head.appendChild(r)}function u(t,e,s){var n=t.createElement("link");n.rel="preload",n.as=e,n.href=s,"fetch"===e&&(n.crossOrigin="anonymous"),a(n),t.head.appendChild(n)}function p(t,e){return t.assetRoot+"build/"+t.manifest[e]}function d(t,e,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=n.forceModuleReload;s.forEach((function(s){var n=p(e,s);n.match(/\.css/)?i(t,n):c(t,n,r)}))}function f(t){return function(t){return t.filter((function(t){var e=s[t];if(!e)throw new Error('Unknown polyfill set "'.concat(t,'"'));return e()}))}(t).map((function(t){return"scripts/polyfills-".concat(t,".bundle.js")}))}function h(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?h(e.src):null}function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var s=y(e);if(!s)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",s.hostname)).replace("{current_scheme}",s.protocol)}var b={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";function t(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function e(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),n=1;n<e;n++)s[n-1]=arguments[n];return s.every((function(e){return"function"==typeof t[e]}))}var s={es2017:function(){return!e(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!e(Promise.prototype,"finally")}};function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);"Object"===s&&t.constructor&&(s=t.constructor.name);if("Map"===s||"Set"===s)return Array.from(t);if("Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return r(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=new Array(e);s<e;s++)n[s]=t[s];return n}var o=["es2017","es2018"];function a(t){t.setAttribute("data-hypothesis-asset","")}function i(t,e){var s=t.createElement("link");s.rel="stylesheet",s.type="text/css",s.href=e,a(s),t.head.appendChild(s)}function c(t,e){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=t.createElement("script");n.type="module",s&&(e+="#ts=".concat(Date.now())),n.src=e,n.async=!1,a(n),t.head.appendChild(n)}function l(t,e,s,n){var r=t.createElement("link");r.rel=e,r.href=n,r.type="application/annotator+".concat(s),a(r),t.head.appendChild(r)}function u(t,e,s){var n=t.createElement("link");n.rel="preload",n.as=e,n.href=s,"fetch"===e&&(n.crossOrigin="anonymous"),a(n),t.head.appendChild(n)}function p(t,e){return t.assetRoot+"build/"+t.manifest[e]}function d(t,e,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=n.forceModuleReload;s.forEach((function(s){var n=p(e,s);n.match(/\.css/)?i(t,n):c(t,n,r)}))}function f(t){return function(t){return t.filter((function(t){var e=s[t];if(!e)throw new Error('Unknown polyfill set "'.concat(t,'"'));return e()}))}(t).map((function(t){return"scripts/polyfills-".concat(t,".bundle.js")}))}function h(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?h(e.src):null}function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var s=y(e);if(!s)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",s.hostname)).replace("{current_scheme}",s.protocol)}var b={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?2be634","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?31366a","styles/annotator.css":"styles/annotator.css?178226","styles/annotator.css.map":"styles/annotator.css.map?771177","styles/highlights.css":"styles/highlights.css?c308d0","styles/highlights.css.map":"styles/highlights.css.map?5be890","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?ee2fe0","styles/katex.min.css":"styles/katex.min.css?123be2","styles/katex.min.css.map":"styles/katex.min.css.map?4daef7","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?dd8179","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?bf5f6c","styles/sidebar.css":"styles/sidebar.css?9e12af","styles/sidebar.css.map":"styles/sidebar.css.map?45509b","styles/ui-playground.css":"styles/ui-playground.css?3fe805","styles/ui-playground.css.map":"styles/ui-playground.css.map?c9b68e","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?af3f78","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?faeb7c","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?8b9a53"};if(function(){var t=[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 t.every((function(t){return t()}))}catch(t){return!1}}()){var v=function(e){for(var s={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r<n.length;r++){var o=void 0;try{o=JSON.parse(n[r].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),o={}}t(s,o)}return s}(document),g=m(v.assetRoot||"https://cdn.hypothes.is/hypothesis/1.954.0/");if(document.querySelector("hypothesis-app"))!function(t,e){u(t,"fetch",e.apiUrl),u(t,"fetch",e.apiUrl+"links");var s=f(o);d(t,e,[].concat(n(s),["scripts/sidebar.bundle.js","styles/katex.min.css","styles/sidebar.css"]))}(document,{assetRoot:g,manifest:b,apiUrl:v.apiUrl});else{var j=m(v.notebookAppUrl||"https://hypothes.is/notebook"),w=m(v.sidebarAppUrl||"https://hypothes.is/app.html");!function(t,e){if(!t.querySelector('link[type="application/annotator+html"]')){l(t,"sidebar","html",e.sidebarAppUrl),l(t,"notebook","html",e.notebookAppUrl),u(t,"style",p(e,"styles/annotator.css")),l(t,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");var s=f(o);d(t,e,[].concat(n(s),["scripts/annotator.bundle.js","styles/highlights.css","styles/pdfjs-overrides.css"]),{forceModuleReload:!0})}}(document,{assetRoot:g,manifest:b,notebookAppUrl:j,sidebarAppUrl:w})}}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?2be634",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?31366a",
|
|
4
|
-
"styles/annotator.css": "styles/annotator.css?
|
|
5
|
-
"styles/annotator.css.map": "styles/annotator.css.map?
|
|
4
|
+
"styles/annotator.css": "styles/annotator.css?178226",
|
|
5
|
+
"styles/annotator.css.map": "styles/annotator.css.map?771177",
|
|
6
6
|
"styles/highlights.css": "styles/highlights.css?c308d0",
|
|
7
7
|
"styles/highlights.css.map": "styles/highlights.css.map?5be890",
|
|
8
|
-
"styles/katex.min.css": "styles/katex.min.css?123be2",
|
|
9
8
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?ee2fe0",
|
|
9
|
+
"styles/katex.min.css": "styles/katex.min.css?123be2",
|
|
10
10
|
"styles/katex.min.css.map": "styles/katex.min.css.map?4daef7",
|
|
11
11
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?dd8179",
|
|
12
12
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?bf5f6c",
|
|
13
|
-
"styles/sidebar.css": "styles/sidebar.css?
|
|
14
|
-
"styles/sidebar.css.map": "styles/sidebar.css.map?
|
|
13
|
+
"styles/sidebar.css": "styles/sidebar.css?9e12af",
|
|
14
|
+
"styles/sidebar.css.map": "styles/sidebar.css.map?45509b",
|
|
15
15
|
"styles/ui-playground.css": "styles/ui-playground.css?3fe805",
|
|
16
16
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?c9b68e",
|
|
17
|
-
"scripts/
|
|
18
|
-
"scripts/
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?af3f78",
|
|
18
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?faeb7c",
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?8b9a53"
|
|
20
20
|
}
|
|
@@ -10,9 +10,9 @@ null!=d.componentWillUpdate&&d.componentWillUpdate(b,d.__s,E),null!=d.componentD
|
|
|
10
10
|
null!=s)for(;v<s.length;v++)if((h=s[v])&&"setAttribute"in h==!!_&&(_?h.localName===_:3===h.nodeType)){t=h,s[v]=null;break}if(null==t){if(null===_)return document.createTextNode(g);t=r?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,g.is&&g),s=null,c=!1}if(null===_)p===g||c&&t.data===g||(t.data=g);else{if(s=s&&e.call(t.childNodes),d=(p=o.props||a).dangerouslySetInnerHTML,f=g.dangerouslySetInnerHTML,!c){if(null!=s)for(p={},v=0;v<t.attributes.length;v++)p[t.attributes[v].name]=t.attributes[v].value;(f||d)&&(f&&(d&&f.__html==d.__html||f.__html===t.innerHTML)||(t.innerHTML=f&&f.__html||""))}if(function(t,e,n,o,i){var r;for(r in n)"children"===r||"key"===r||r in e||E(t,r,null,n[r],o);for(r in e)i&&"function"!=typeof e[r]||"children"===r||"key"===r||"value"===r||"checked"===r||n[r]===e[r]||E(t,r,e[r],n[r],o)}(t,g,p,r,c),f)n.__k=[];else if(v=n.props.children,y(t,Array.isArray(v)?v:[v],n,o,i,r&&"foreignObject"!==_,s,l,s?s[0]:o.__k&&m(o,0),c),
|
|
11
11
|
null!=s)for(v=s.length;v--;)null!=s[v]&&u(s[v]);c||("value"in g&&void 0!==(v=g.value)&&(v!==p.value||v!==t.value||"progress"===_&&!v)&&E(t,"value",v,p.value,!1),"checked"in g&&void 0!==(v=g.checked)&&v!==t.checked&&E(t,"checked",v,p.checked,!1))}return t}function N(t,e,o){try{"function"==typeof t?t(e):t.current=e}catch(t){n.__e(t,o)}}function R(t,e,o){var i,r;if(n.unmount&&n.unmount(t),(i=t.ref)&&(i.current&&i.current!==t.__e||N(i,null,e)),null!=(i=t.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){n.__e(t,e)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&R(i[r],e,"function"!=typeof t.type);o||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function P(t,o,i){var r,s,l;n.__&&n.__(t,o),s=(r="function"==typeof i)?null:i&&i.__k||o.__k,l=[],T(o,t=(!r&&i||o).__k=function(t,n,o){var i,r,s,a={};for(s in n)"key"==s?i=n[s]:"ref"==s?r=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?e.call(arguments,2):o),
|
|
12
12
|
"function"==typeof t&&null!=t.defaultProps)for(s in t.defaultProps)void 0===a[s]&&(a[s]=t.defaultProps[s]);return d(t,a,i,r,null)}(f,null,[t]),s||a,a,void 0!==o.ownerSVGElement,!r&&i?[i]:s?null:o.firstChild?e.call(o.childNodes):null,l,!r&&i?i:s?s.__e:o.firstChild,r),A(l,t)}e=l.slice,n={__e:function(t,e){for(var n,o,i;e=e.__;)if((n=e.__c)&&!n.__)try{if((o=n.constructor)&&null!=o.getDerivedStateFromError&&(n.setState(o.getDerivedStateFromError(t)),i=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(t),i=n.__d),i)return n.__E=n}catch(e){t=e}throw t}},o=0,p.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof t&&(t=t(h({},n),this.props)),t&&h(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),_(this))},p.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),_(this))},p.prototype.render=f,i=[],r="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,v.__r=0,
|
|
13
|
-
"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.6.4",n,{Fragment:f,Component:p});var M={};function O(t){return t.type===f?"Fragment":"function"==typeof t.type?t.type.displayName||t.type.name:"string"==typeof t.type?t.type:"#text"}var I=[],D=[];function H(){return I.length>0?I[I.length-1]:null}var F=!1;function B(t){return"function"==typeof t.type&&t.type!=f}function V(t){for(var e=[t],n=t;null!=n.__o;)e.push(n.__o),n=n.__o;return e.reduce((function(t,e){t+=" in "+O(e);var n=e.__source;return n?t+=" (at "+n.fileName+":"+n.lineNumber+")":F||(F=!0,console.warn("Add @babel/plugin-transform-react-jsx-source to get a more detailed component stack. Note that you should not add it to production builds of your App for bundle size reasons.")),t+"\n"}),"")}var
|
|
14
|
-
return null==this.__v?null==this.state&&console.warn('Calling "this.setState" inside the constructor of a component is a no-op and might be a bug in your application. Instead, set "this.state = {}" directly.\n\n'+V(H())):null==this.__P&&console.warn('Can\'t call "this.setState" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+V(this.__v)),
|
|
15
|
-
return null==this.__v?console.warn('Calling "this.forceUpdate" inside the constructor of a component is a no-op and might be a bug in your application.\n\n'+V(H())):null==this.__P&&console.warn('Can\'t call "this.forceUpdate" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+V(this.__v)),W.call(this,t)},function(){!function(){var t=n.__b,e=n.diffed,o=n.__,i=n.vnode,r=n.__r;n.diffed=function(t){B(t)&&D.pop(),I.pop(),e&&e(t)},n.__b=function(e){B(e)&&I.push(e),t&&t(e)},n.__=function(t,e){D=[],o&&o(t,e)},n.vnode=function(t){t.__o=D.length>0?D[D.length-1]:null,i&&i(t)},n.__r=function(t){B(t)&&D.push(t),r&&r(t)}}();var t=!1,e=n.__b,o=n.diffed,i=n.vnode,r=n.__e,s=n.__,a=n.__h,l=
|
|
13
|
+
"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.6.4",n,{Fragment:f,Component:p});var M={};function O(t){return t.type===f?"Fragment":"function"==typeof t.type?t.type.displayName||t.type.name:"string"==typeof t.type?t.type:"#text"}var I=[],D=[];function H(){return I.length>0?I[I.length-1]:null}var F=!1;function B(t){return"function"==typeof t.type&&t.type!=f}function V(t){for(var e=[t],n=t;null!=n.__o;)e.push(n.__o),n=n.__o;return e.reduce((function(t,e){t+=" in "+O(e);var n=e.__source;return n?t+=" (at "+n.fileName+":"+n.lineNumber+")":F||(F=!0,console.warn("Add @babel/plugin-transform-react-jsx-source to get a more detailed component stack. Note that you should not add it to production builds of your App for bundle size reasons.")),t+"\n"}),"")}var U="function"==typeof WeakMap,q=p.prototype.setState;p.prototype.setState=function(t,e){
|
|
14
|
+
return null==this.__v?null==this.state&&console.warn('Calling "this.setState" inside the constructor of a component is a no-op and might be a bug in your application. Instead, set "this.state = {}" directly.\n\n'+V(H())):null==this.__P&&console.warn('Can\'t call "this.setState" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+V(this.__v)),q.call(this,t,e)};var W=p.prototype.forceUpdate;function $(t){var e=t.props,n=O(t),o="";for(var i in e)if(e.hasOwnProperty(i)&&"children"!==i){var r=e[i];"function"==typeof r&&(r="function "+(r.displayName||r.name)+"() {}"),r=Object(r)!==r||r.toString?r+"":Object.prototype.toString.call(r),o+=" "+i+"="+JSON.stringify(r)}var s=e.children;return"<"+n+o+(s&&s.length?">..</"+n+">":" />")}p.prototype.forceUpdate=function(t){
|
|
15
|
+
return null==this.__v?console.warn('Calling "this.forceUpdate" inside the constructor of a component is a no-op and might be a bug in your application.\n\n'+V(H())):null==this.__P&&console.warn('Can\'t call "this.forceUpdate" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+V(this.__v)),W.call(this,t)},function(){!function(){var t=n.__b,e=n.diffed,o=n.__,i=n.vnode,r=n.__r;n.diffed=function(t){B(t)&&D.pop(),I.pop(),e&&e(t)},n.__b=function(e){B(e)&&I.push(e),t&&t(e)},n.__=function(t,e){D=[],o&&o(t,e)},n.vnode=function(t){t.__o=D.length>0?D[D.length-1]:null,i&&i(t)},n.__r=function(t){B(t)&&D.push(t),r&&r(t)}}();var t=!1,e=n.__b,o=n.diffed,i=n.vnode,r=n.__e,s=n.__,a=n.__h,l=U?{useEffect:new WeakMap,useLayoutEffect:new WeakMap,lazyPropTypes:new WeakMap}:null,c=[];n.__e=function(t,e,n){if(e&&e.__c&&"function"==typeof t.then){var o=t
|
|
16
16
|
;t=new Error("Missing Suspense. The throwing component was: "+O(e));for(var i=e;i;i=i.__)if(i.__c&&i.__c.__c){t=o;break}if(t instanceof Error)throw t}try{r(t,e,n),"function"!=typeof t.then&&setTimeout((function(){throw t}))}catch(t){throw t}},n.__=function(t,e){if(!e)throw new Error("Undefined parent passed to render(), this is the second argument.\nCheck if the element is available in the DOM/has the correct id.");var n;switch(e.nodeType){case 1:case 11:case 9:n=!0;break;default:n=!1}if(!n){var o=O(t);throw new Error("Expected a valid HTML node as a second argument to render.\tReceived "+e+" instead: render(<"+o+" />, "+e+");")}s&&s(t,e)},n.__b=function(n){var o=n.type,i=function t(e){return e?"function"==typeof e.type?t(e.__):e:{}}(n.__);if(t=!0,void 0===o)throw new Error("Undefined component passed to createElement()\n\nYou likely forgot to export your component or might have mixed up default and named imports"+$(n)+"\n\n"+V(n));if(null!=o&&"object"==typeof o){
|
|
17
17
|
if(void 0!==o.__k&&void 0!==o.__e)throw new Error("Invalid type passed to createElement(): "+o+"\n\nDid you accidentally pass a JSX literal as JSX twice?\n\n let My"+O(n)+" = "+$(o)+";\n let vnode = <My"+O(n)+" />;\n\nThis usually happens when you export a JSX literal and not the component.\n\n"+V(n));throw new Error("Invalid type passed to createElement(): "+(Array.isArray(o)?"array":o))}if("thead"!==o&&"tfoot"!==o&&"tbody"!==o||"table"===i.type?"tr"===o&&"thead"!==i.type&&"tfoot"!==i.type&&"tbody"!==i.type&&"table"!==i.type?console.error("Improper nesting of table. Your <tr> should have a <thead/tbody/tfoot/table> parent."+$(n)+"\n\n"+V(n)):"td"===o&&"tr"!==i.type?console.error("Improper nesting of table. Your <td> should have a <tr> parent."+$(n)+"\n\n"+V(n)):"th"===o&&"tr"!==i.type&&console.error("Improper nesting of table. Your <th> should have a <tr>."+$(n)+"\n\n"+V(n)):console.error("Improper nesting of table. Your <thead/tbody/tfoot> should have a <table> parent."+$(n)+"\n\n"+V(n)),
|
|
18
18
|
void 0!==n.ref&&"function"!=typeof n.ref&&"object"!=typeof n.ref&&!("$$typeof"in n))throw new Error('Component\'s "ref" property should be a function, or an object created by createRef(), but got ['+typeof n.ref+"] instead\n"+$(n)+"\n\n"+V(n));if("string"==typeof n.type)for(var r in n.props)if("o"===r[0]&&"n"===r[1]&&"function"!=typeof n.props[r]&&null!=n.props[r])throw new Error("Component's \""+r+'" property should be a function, but got ['+typeof n.props[r]+"] instead\n"+$(n)+"\n\n"+V(n));if("function"==typeof n.type&&n.type.propTypes){if("Lazy"===n.type.displayName&&l&&!l.lazyPropTypes.has(n.type)){var s="PropTypes are not supported on lazy(). Use propTypes on the wrapped component itself. ";try{var a=n.type();l.lazyPropTypes.set(n.type,!0),console.warn(s+"Component wrapped in lazy() is "+O(a))}catch(n){console.warn(s+"We will log the wrapped component's name once it is loaded.")}}var c=n.props;n.type.__f&&delete(c=function(t,e){for(var n in e)t[n]=e[n];return t}({},c)).ref,function(t,e,n,o,i){
|
|
@@ -36,11 +36,11 @@ show:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0
|
|
|
36
36
|
var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,s=o.length;r<s;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},At.exports=kt;var Nt=At.exports.TinyEmitter=kt;let Rt=null;function Lt(t){return t instanceof Error?{message:t.message,stack:t.stack}:{message:String(t),stack:void 0}}function Pt(t,e){if(!Rt)return;const n={type:"hypothesis-error",error:t instanceof Error?t:Lt(t),context:e};try{try{Rt.postMessage(n,"*")}catch(t){if(!(t instanceof DOMException&&"DataCloneError"===t.name))throw t;n.error=Lt(n.error),Rt.postMessage(n,"*")}}catch(t){console.warn("Unable to report Hypothesis error",t)}}function Mt(t){Rt=t}class Ot{constructor(){this._listeners=new Map}add(t,e,n,o){t.addEventListener(e,n,o);const i=Symbol();return this._listeners.set(i,{eventTarget:t,eventType:e,listener:n}),i}remove(t){const e=this._listeners.get(t);if(e){const{eventTarget:n,eventType:o,listener:i}=e;n.removeEventListener(o,i),this._listeners.delete(t)}}removeAll(){
|
|
37
37
|
this._listeners.forEach((({eventTarget:t,eventType:e,listener:n})=>{t.removeEventListener(e,n)})),this._listeners.clear()}}function It(t){if(null===t||"object"!=typeof t)return!1;for(let e of["frame1","frame2","type"])if("string"!=typeof t[e])return!1;return!0}function Dt(t,e){return!!It(t)&&JSON.stringify(t,Object.keys(e).sort())===JSON.stringify(e,Object.keys(e).sort())}class Ht{constructor(t){this._hypothesisAppsOrigin=t,this._emitter=new Nt,this._sentChannels=new WeakMap,this._sidebarHostChannel=new MessageChannel,this._listeners=new Ot,this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"request"},{allowedOrigin:"*",frame1:"guest",frame2:"sidebar",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"sidebar",frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"notebook",frame2:"sidebar",type:"request"}]}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:o}){return("*"===e||o===e)&&Dt(n,t)}on(t,e){this._emitter.on(t,e)}listen(){
|
|
38
38
|
const t="Handling port request",e=new Set,n=n=>{e.has(n)||(e.add(n),Pt(new Error(n),t))};var o,i;this._listeners.add(window,"message",(o=t=>{const{data:e,origin:o,source:i}=t;if(!It(e)||"request"!==e.type)return;const{frame1:r,frame2:s}=e,a=`${r}-${s}`;if(!function(t){return!(null===t||t instanceof MessagePort||window.ServiceWorker&&t instanceof ServiceWorker)}(i))return void n(`Ignored port request for channel ${a} from non-Window source`);if(void 0===this._allowedMessages.find((({allowedOrigin:t,...n})=>this._messageMatches({allowedMessage:n,allowedOrigin:t,data:e,origin:o}))))return void n(`Ignored invalid port request for channel ${a} from ${o}`);let l=this._sentChannels.get(i);if(l||(l=new Set,this._sentChannels.set(i,l)),l.has(a))return;l.add(a);const c="sidebar-host"===a?this._sidebarHostChannel:new MessageChannel,h={frame1:r,frame2:s,type:"offer"},u="null"===o?"*":o;i.postMessage(h,u,[c.port1]),
|
|
39
|
-
"sidebar"===s?this._sidebarHostChannel.port2.postMessage(h,[c.port2]):"host"===s&&this._emitter.emit("frameConnected",r,c.port2)},i=t,(...t)=>{try{return o(...t)}catch(t){throw Pt(t,i),t}}))}destroy(){this._listeners.removeAll()}}function Ft(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Bt(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),i={}}Ft(e,i)}return e}function Vt(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function
|
|
40
|
-
const e=function(t){if(!t.hasOwnProperty("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 o(t){return e.hasOwnProperty(t)?e[t]:n.hasOwnProperty(t)?n[t]:void 0}return n=Vt(e.ignoreOtherConfiguration)?{}:Bt(t.document),{get annotations(){return n.annotations||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return
|
|
41
|
-
return
|
|
42
|
-
getValue:Wt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},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:Wt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt}};function jt(t="annotator",e=window){const n=
|
|
43
|
-
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);return i.forEach((t=>{const i=$t[t],r=void 0!==i.defaultValue,s=!((a=
|
|
39
|
+
"sidebar"===s?this._sidebarHostChannel.port2.postMessage(h,[c.port2]):"host"===s&&this._emitter.emit("frameConnected",r,c.port2)},i=t,(...t)=>{try{return o(...t)}catch(t){throw Pt(t,i),t}}))}destroy(){this._listeners.removeAll()}}function Ft(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Bt(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),i={}}Ft(e,i)}return e}function Vt(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function Ut(t,e,n){const o=t.document.querySelector(`link[type="application/annotator+${n}"][rel="${e}"]`);if(!o)throw new Error(`No application/annotator+${n} (rel="${e}") link in the document`);if(!o.href)throw new Error(`application/annotator+${n} (rel="${e}") link has no href`);return o.href}function qt(t){
|
|
40
|
+
const e=function(t){if(!t.hasOwnProperty("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 o(t){return e.hasOwnProperty(t)?e[t]:n.hasOwnProperty(t)?n[t]:void 0}return n=Vt(e.ignoreOtherConfiguration)?{}:Bt(t.document),{get annotations(){return n.annotations||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return Ut(t,"hypothesis-client","javascript")},get group(){return n.group||function(){const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return Ut(t,"notebook","html")},get showHighlights(){return function(){let t=o("showHighlights");return void 0===t&&(t="always"),"boolean"==typeof t?t?"always":"never":t}()},get sidebarAppUrl(){
|
|
41
|
+
return Ut(t,"sidebar","html")},get query(){return 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:o}}function Wt(t,e){return t.hostPageSetting(e)}const $t={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:Wt},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:Wt},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:Vt,
|
|
42
|
+
getValue:Wt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt},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:Wt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:Wt}};function jt(t="annotator",e=window){const n=qt(e),o={};let i=function(t){const e={annotator:["clientUrl","subFrameIdentifier"],sidebar:["appType","annotations","branding","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],
|
|
43
|
+
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);return i.forEach((t=>{const i=$t[t],r=void 0!==i.defaultValue,s=!((a=Ut(e,"sidebar","html")).startsWith("http://")||a.startsWith("https://"));var a;if(!i.allowInBrowserExt&&s)return void(r&&(o[t]=i.defaultValue));const l=i.getValue(n,t);void 0!==l?o[t]=i.coerce?i.coerce(l):l:r&&(o[t]=i.defaultValue)})),o}class zt{constructor(t,e){this._port=t,this._methods=e,this._sequence=0,this._callbacks={},this._destroyed=!1,this._listeners=new Ot,this._listeners.add(this._port,"message",(t=>this._handle(t))),this._port.start()}destroy(){this._destroyed=!0,this._listeners.removeAll(),this._port.close()}call(t,...e){if(this._destroyed)return;const n=this._sequence++,o=e[e.length-1]
|
|
44
44
|
;"function"==typeof o&&(this._callbacks[n]=o,e=e.slice(0,-1));const i={arguments:e,method:t,protocol:"frame-rpc",sequence:n,version:"1.0.0"};this._port.postMessage(i)}_parseMessage({data:t}){return t&&"object"==typeof t?"frame-rpc"!==t.protocol||"1.0.0"!==t.version?null:Array.isArray(t.arguments)?t:null:null}_handle(t){const e=this._parseMessage(t);if(null!==e)if("method"in e){if(!this._methods.hasOwnProperty(e.method))return;const t=(...t)=>{const n={arguments:t,protocol:"frame-rpc",response:e.sequence,version:"1.0.0"};this._port.postMessage(n)};this._methods[e.method](...e.arguments,t)}else if("response"in e){const t=this._callbacks[e.response];delete this._callbacks[e.response],t&&t(...e.arguments)}}}class Xt{constructor(){this.links=[],this.channelListeners={},this.onConnectListeners=[],this.on("connect",(t=>t()))}destroy(){this.links.forEach((t=>t.destroy())),this.links=[]}createChannel(t){const e=new zt(t,this.channelListeners);let n=!1;return e.call("connect",(()=>{n||(n=!0,
|
|
45
45
|
this.onConnectListeners.forEach((t=>t(e))))})),this.links.push(e),e}call(t,...e){let n;const o=e[e.length-1];"function"==typeof o&&(n=o,e=e.slice(0,-1));const i=t=>e=>{throw t.destroy(),this.links=this.links.filter((e=>e!==t)),e},r=this.links.map((n=>new Promise(((o,i)=>{const r=setTimeout((()=>o(null)),1e3);try{n.call(t,...e,((t,e)=>{clearTimeout(r),t?i(t):o(e)}))}catch(t){i(t)}})).catch(i(n))));let s=Promise.all(r);return n&&(s=s.then((t=>n(null,t))).catch((t=>n(t)))),s}on(t,e){if(this.links.length>0)throw new Error(`Listener '${t}' can't be registered because a channel has already been created`);if(this.channelListeners[t])throw new Error(`Listener '${t}' already bound in Bridge`);return this.channelListeners[t]=e,this}onConnect(t){return this.onConnectListeners.push(t),this}}class Yt{constructor({hostFrame:t,source:e}){this._hostFrame=t,this._source=e,this._listeners=new Ot}destroy(){this._listeners.removeAll()}async discover(t){let e=!1
|
|
46
46
|
;if(("guest"===this._source&&"host"===t||"guest"===this._source&&"sidebar"===t||"sidebar"===this._source&&"host"===t||"notebook"===this._source&&"sidebar"===t)&&(e=!0),!e)throw new Error("Invalid request of channel/port");return new Promise(((e,n)=>{const o=()=>{this._hostFrame.postMessage({frame1:this._source,frame2:t,type:"request"},"*")},i=setInterval(o,250),r=setTimeout((()=>{clearInterval(i),n(new Error(`Unable to establish ${this._source}-${t} communication channel`))}),2e4),s=this._listeners.add(window,"message",(n=>{const{data:o,ports:a}=n;Dt(o,{frame1:this._source,frame2:t,type:"offer"})&&(clearInterval(i),clearTimeout(r),this._listeners.remove(s),e(a[0]))}));o()}))}}function Gt(t){const e=t.toString(16);return 1===e.length?"0"+e:e}function Zt(t){const e=new Uint8Array(t/2);return window.crypto.getRandomValues(e),Array.from(e).map(Gt).join("")}const Kt={alt:1,ctrl:2,meta:4,shift:8};function Jt(t,e,{rootElement:n=document.body}={}){const o=n=>{(function(t,e){
|
|
@@ -60,8 +60,8 @@ t.svgHighlight.parentNode.append(t.svgHighlight)}}else t.classList.toggle("hypot
|
|
|
60
60
|
this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Ie((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(t){this._annotatableFrames.add(t);try{if(await He(t),this._isDisconnected)return;t.contentWindow.addEventListener("unload",(()=>{this._removeFrame(t)})),this._onFrameAdded(t)}catch(e){console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${t.src}')`)}}_removeFrame(t){this._annotatableFrames.delete(t),this._onFrameRemoved(t)}_discoverFrames(){const t=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(let e of t)this._annotatableFrames.has(e)||this._addFrame(e);for(let e of this._annotatableFrames)t.has(e)||this._removeFrame(e)}}
|
|
61
61
|
function He(t){return new Promise((e=>{const n=t.contentWindow.document,{readyState:o,location:i}=n;"about:blank"===i.href&&t.hasAttribute("src")&&"about:blank"!==t.src?t.addEventListener("load",(()=>{e()})):"loading"!==o?e():n.addEventListener("DOMContentLoaded",(()=>e()))}))}class Fe{constructor(t,e){this._config=e,this._frameObserver=new De(t,(t=>this.injectClient(t)),(()=>{}))}destroy(){this._frameObserver.disconnect()}async injectClient(t){if("__hypothesis"in t.contentWindow)return;await He(t);const{assetRoot:e,notebookAppUrl:n,sidebarAppUrl:o}=Bt(document),i=Zt(10),r={...this._config,assetRoot:e,notebookAppUrl:n,sidebarAppUrl:o,subFrameIdentifier:i},{clientUrl:s}=this._config;!function(t,e,n){const o=document.createElement("script");o.className="js-hypothesis-config",o.type="application/json",o.innerText=JSON.stringify(n);const i=document.createElement("script");i.async=!0,i.src=e;const r=t.contentDocument;r.body.appendChild(o),r.body.appendChild(i)}(t,s,r)}}function Be(t,e,n){
|
|
62
62
|
t.self===t?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function Ve(t){var e=t._scrollSettings;if(e){var n=e.maxSynchronousAlignments,o=function(t,e){var n,o,i,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,m=u,g=d;if(t.isWindow(e))a=Math.min(h.width,e.innerWidth),l=Math.min(h.height,e.innerHeight),o=h.left+e.pageXOffset-e.innerWidth*m+a*m,i=h.top+e.pageYOffset-e.innerHeight*g+l*g,o-=f,i-=p,o=t.align.lockX?e.pageXOffset:o,i=t.align.lockY?e.pageYOffset:i,r=o-e.pageXOffset,s=i-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);o=_+a*m-e.clientWidth*m,i=v+l*g-e.clientHeight*g,o-=f,i-=p,o=Math.max(Math.min(o,e.scrollWidth-e.clientWidth),0),i=Math.max(Math.min(i,e.scrollHeight-e.clientHeight),0),o=t.align.lockX?e.scrollLeft:o,i=t.align.lockY?e.scrollTop:i,r=o-e.scrollLeft,s=i-e.scrollTop}return{x:o,
|
|
63
|
-
y:i,differenceX:r,differenceY:s}}(e,t),i=Date.now()-e.startTime,r=Math.min(1/e.time*i,1);if(e.endIterations>=n)return Be(t,o.x,o.y),t._scrollSettings=null,e.end("complete");var s=1-e.ease(r);if(Be(t,o.x-o.differenceX*s,o.y-o.differenceY*s),i>=e.time)return e.endIterations++,e.scrollAncestor&&Ve(e.scrollAncestor),void Ve(t);!function(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}(Ve.bind(null,t))}}function
|
|
64
|
-
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 o=$e(t),i=1,r=e.validTarget||We,s=e.isScrollable;e.debug&&(console.log("About to scroll to",t),o||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var a=[];o;)if(e.debug&&console.log("Scrolling parent node",o),r(o,i)&&(s?s(o,
|
|
63
|
+
y:i,differenceX:r,differenceY:s}}(e,t),i=Date.now()-e.startTime,r=Math.min(1/e.time*i,1);if(e.endIterations>=n)return Be(t,o.x,o.y),t._scrollSettings=null,e.end("complete");var s=1-e.ease(r);if(Be(t,o.x-o.differenceX*s,o.y-o.differenceY*s),i>=e.time)return e.endIterations++,e.scrollAncestor&&Ve(e.scrollAncestor),void Ve(t);!function(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}(Ve.bind(null,t))}}function Ue(t){return t.self===t}function qe(t){return"pageXOffset"in t||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function We(){return!0}function $e(t){if(t.assignedSlot)return $e(t.assignedSlot);if(t.parentElement)return"BODY"===t.parentElement.tagName?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 je=function(t,e,n){if(t){"function"==typeof e&&(n=e,e=null),e||(e={}),
|
|
64
|
+
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 o=$e(t),i=1,r=e.validTarget||We,s=e.isScrollable;e.debug&&(console.log("About to scroll to",t),o||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var a=[];o;)if(e.debug&&console.log("Scrolling parent node",o),r(o,i)&&(s?s(o,qe):qe(o))&&(i++,a.push(o)),!(o=$e(o))){l("complete");break}return a.reduce(((n,o,i)=>function(t,e,n,o,i){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),n.debug&&console.log("Scrolling ended with type",t,"for",e),i(t),r&&(e.removeEventListener("touchstart",r,c),e.removeEventListener("wheel",r,c))}a&&a.end("canceled");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||Ue,
|
|
65
65
|
maxSynchronousAlignments:u,end:h,scrollAncestor:o},"cancellable"in n&&!n.cancellable||(r=h.bind(null,"canceled"),e.addEventListener("touchstart",r,c),e.addEventListener("wheel",r,c)),s&&Ve(e),r}(t,o,e,a[i+1],l)),null)}function l(t){--i||n&&n(t)}};function ze(t){return t.split("").reverse().join("")}function Xe(t){return(t|-t)>>31&1}function Ye(t,e,n,o){let i=t.P[n],r=t.M[n];const s=o>>>31,a=e[n]|s,l=a|r,c=(a&i)+i^i|a;let h=r|~(c|i),u=i&c;const d=Xe(h&t.lastRowMask[n])-Xe(u&t.lastRowMask[n]);return h<<=1,u<<=1,u|=s,h|=Xe(o)-s,i=u|~(l|h),r=h&l,t.P[n]=i,t.M[n]=r,d}function Ge(t,e,n){if(0===e.length)return[];n=Math.min(n,e.length);const o=[],i=32,r=Math.ceil(e.length/i)-1,s={P:new Uint32Array(r+1),M:new Uint32Array(r+1),lastRowMask:new Uint32Array(r+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[r]=1<<(e.length-1)%i;const a=new Uint32Array(r+1),l=new Map,c=[];for(let t=0;t<256;t++)c.push(a);for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(l.has(n))continue;const o=new Uint32Array(r+1);l.set(n,o),
|
|
66
66
|
n<c.length&&(c[n]=o);for(let t=0;t<=r;t+=1){o[t]=0;for(let r=0;r<i;r+=1){const s=t*i+r;if(s>=e.length)continue;e.charCodeAt(s)===n&&(o[t]|=1<<r)}}}let h=Math.max(0,Math.ceil(n/i)-1);const u=new Uint32Array(r+1);for(let t=0;t<=h;t+=1)u[t]=(t+1)*i;u[r]=e.length;for(let t=0;t<=h;t+=1)s.P[t]=-1,s.M[t]=0;for(let d=0;d<t.length;d+=1){const f=t.charCodeAt(d);let p;f<c.length?p=c[f]:(p=l.get(f),void 0===p&&(p=a));let m=0;for(let t=0;t<=h;t+=1)m=Ye(s,p,t,m),u[t]+=m;if(u[h]-m<=n&&h<r&&(1&p[h+1]||m<0)){let t;if(h+=1,s.P[h]=-1,s.M[h]=0,h===r){const n=e.length%i;t=0===n?i:n}else t=i;u[h]=u[h-1]+t-m+Ye(s,p,h,m)}else for(;h>0&&u[h]>=n+i;)h-=1;h===r&&u[h]<=n&&(u[h]<n&&o.splice(0,o.length),o.push({start:-1,end:d+1,errors:u[h]}),n=u[h])}return o}function Ze(t,e,n){return function(t,e,n){const o=ze(e);return n.map((n=>{const i=Math.max(0,n.end-e.length-n.errors);return{start:Ge(ze(t.slice(i,n.end)),o,n.errors).reduce(((t,e)=>n.end-e.end<t?n.end-e.end:t),n.end),end:n.end,errors:n.errors}}))}(t,e,Ge(t,e,n))}function Ke(t,e,n){
|
|
67
67
|
let o=0,i=[];for(;-1!==o;)o=t.indexOf(e,o),-1!==o&&(i.push({start:o,end:o+e.length,errors:0}),o+=1);return i.length>0?i:Ze(t,e,n)}function Je(t,e){if(0===e.length||0===t.length)return 0;return 1-Ke(t,e,e.length)[0].errors/e.length}function Qe(t,e,n={}){if(0===e.length)return null;const o=Math.min(256,e.length/2),i=Ke(t,e,o);if(0===i.length)return null;const r=o=>{const i=1-o.errors/e.length,r=n.prefix?Je(t.slice(Math.max(0,o.start-n.prefix.length),o.start),n.prefix):1,s=n.suffix?Je(t.slice(o.end,o.end+n.suffix.length),n.suffix):1;let a=1;if("number"==typeof n.hint){a=1-Math.abs(o.start-n.hint)/t.length}return(50*i+20*r+20*s+2*a)/92},s=i.map((t=>({start:t.start,end:t.end,score:r(t)})));return s.sort(((t,e)=>e.score-t.score)),s[0]}function tn(t){const e=function(t){const e=t.nodeName.toLowerCase();let n=e;return"#text"===e&&(n="text()"),n}(t),n=function(t){let e=0,n=t;for(;n;)n.nodeName===t.nodeName&&(e+=1),n=n.previousSibling;return e}(t);return`${e}[${n}]`}function en(t,e){let n="",o=t;for(;o!==e;){
|
|
@@ -81,27 +81,27 @@ href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",children:"Learn ho
|
|
|
81
81
|
this.pdfViewer.viewer.classList.add("has-transparent-text-layer"),this.pdfContainer=null!==(n=null===(o=s.appConfig)||void 0===o?void 0:o.appContainer)&&void 0!==n?n:document.body,this.pdfMetadata=new On(s),this.observer=new MutationObserver(Ie((()=>this._update()),100)),this.observer.observe(this.pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=null!==(i=e.reanchoringMaxWait)&&void 0!==i?i:3e3,this._warningBanner=null,this._checkForSelectableText(),this._updateAnnotationLayerVisibility=()=>{const t=r.getSelection();this.pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new Ot,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){var t;this._listeners.removeAll(),this.pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this.observer.disconnect(),null===(t=this._warningBanner)||void 0===t||t.remove(),this._destroyed=!0}uri(){
|
|
82
82
|
return this.pdfMetadata.getUri()}getMetadata(){return this.pdfMetadata.getMetadata()}anchor(t,e){return kn(0,e)}canAnnotate(t){return function(t){try{return Nn(t),!0}catch{return!1}}(t)}describe(t,e){return Rn(t,e)}async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._destroyed)try{const t=await async function(){const t=Cn();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await Sn(n)).trim().length>0){e=!0;break}return e}();this._toggleNoSelectableTextWarning(!t)}catch(t){console.warn("Unable to check for text in PDF:",t)}}_toggleNoSelectableTextWarning(t){const e=document.querySelector("#outerContainer");var n;if(!t)return null===(n=this._warningBanner)||void 0===n||n.remove(),this._warningBanner=null,void(e.style.height="");this._warningBanner=document.createElement("hypothesis-banner"),document.body.prepend(this._warningBanner);const o=oe(this._warningBanner);P(gt(Ln,{}),o);const i=this._warningBanner.getBoundingClientRect().height;e.style.height=`calc(100% - ${i}px)`}_update(){
|
|
83
83
|
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 gn:e.textLayer=null;break;case _n:o=e.div,i=void 0,null===(i=o.querySelector(".annotator-placeholder"))||void 0===i||i.remove()}}var o,i;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 o=e.highlights[n];if(!document.body.contains(o)){e.highlights.splice(n,1),delete e.range,t.push(e.annotation);break}}}t.map((t=>this.annotator.anchor(t)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(t){const e=window.innerWidth-t.width,n=t.expanded&&e>=680,o=n?t.width:t.toolbarWidth;this.pdfContainer.style.width=`calc(100% - ${o}px)`;const i=this.pdfViewer.currentScaleValue;return"auto"!==i&&"page-fit"!==i&&"page-width"!==i||(this.pdfViewer.currentScaleValue=i),this.pdfViewer.update(),n}
|
|
84
|
-
async scrollToAnchor(t){const e=t.annotation,n=Fn(t),o=this._anchorOffset(t);if(null!==o&&(await Mn(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await Mn(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n;const o=Date.now();let i;do{i=this.annotator.anchors.find((e=>e.annotation===t)),i&&!Fn(i)||(i=null,await Bn(20))}while(!i&&Date.now()-o<e);return null!==(n=i)&&void 0!==n?n:null}_anchorOffset(t){if(!t.highlights)return null;return function(t,e){let n=0;for(;t!==e&&e.contains(t);)n+=t.offsetTop,t=t.offsetParent;return n}(t.highlights[0],this.contentContainer())}}function
|
|
85
|
-
;const o=t.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,t.nextSibling),o.style.position="relative",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.mixBlendMode="multiply";const r="sans-serif";i.style.fontSize="16px",i.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font="16px sans-serif";let a=null,l="";const c=[];let h=0;const u=()=>{if(!a)return;const t=document.createElement("span");t.style.position="absolute",t.style.color="transparent",t.style.transformOrigin="top left",t.textContent=l,i.append(t),i.append(" "),h||(h=t.getBoundingClientRect().height),c.push({span:t,box:a,width:s.measureText(l).width,height:h}),a=null,l=""};for(let t=0;t<e.length;t++){const o=n[t];if(/\s/.test(o)){u();continue}const i=e[t];a=
|
|
84
|
+
async scrollToAnchor(t){const e=t.annotation,n=Fn(t),o=this._anchorOffset(t);if(null!==o&&(await Mn(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await Mn(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n;const o=Date.now();let i;do{i=this.annotator.anchors.find((e=>e.annotation===t)),i&&!Fn(i)||(i=null,await Bn(20))}while(!i&&Date.now()-o<e);return null!==(n=i)&&void 0!==n?n:null}_anchorOffset(t){if(!t.highlights)return null;return function(t,e){let n=0;for(;t!==e&&e.contains(t);)n+=t.offsetTop,t=t.offsetParent;return n}(t.highlights[0],this.contentContainer())}}function Un(t,e){return t?{left:Math.min(t.left,e.left),right:Math.max(t.right,e.right),top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom)}:e}class qn{constructor(t,e,n){if(e.length!==n.length)throw new Error("Char boxes length does not match text length")
|
|
85
|
+
;const o=t.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,t.nextSibling),o.style.position="relative",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.mixBlendMode="multiply";const r="sans-serif";i.style.fontSize="16px",i.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font="16px sans-serif";let a=null,l="";const c=[];let h=0;const u=()=>{if(!a)return;const t=document.createElement("span");t.style.position="absolute",t.style.color="transparent",t.style.transformOrigin="top left",t.textContent=l,i.append(t),i.append(" "),h||(h=t.getBoundingClientRect().height),c.push({span:t,box:a,width:s.measureText(l).width,height:h}),a=null,l=""};for(let t=0;t<e.length;t++){const o=n[t];if(/\s/.test(o)){u();continue}const i=e[t];a=Un(a,i),l+=o}u();const d=()=>{const{width:e,height:n}=t.getBoundingClientRect();i.style.width=e+"px",i.style.height=n+"px";for(let{span:t,box:o,width:i,height:r}of c){
|
|
86
86
|
const s=o.left*e,a=o.top*n,l=o.right*e,c=o.bottom*n;t.style.left=s+"px",t.style.top=a+"px";const h=(l-s)/i,u=(c-a)/r;t.style.transform=`scale(${h}, ${u})`}};d(),this.container=i,this._updateBoxSizes=Ie(d,{maxWait:50}),this._listeners=new Ot,this._listeners.add(window,"resize",this._updateBoxSizes)}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateBoxSizes.cancel()}}function Wn(t=document){return t.querySelector("mosaic-book")}class $n{constructor(t){const e=Wn();if(!e)throw new Error("Book container element not found");const n=e.shadowRoot,o=()=>{const e=n.querySelector("iframe");e&&t.injectClient(e)};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(n,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}canAnnotate(){return!1}async anchor(){return new Range}describe(){throw new Error("This frame cannot be annotated")}contentContainer(){return document.body}fitSideBySide(){return!1}async getMetadata(){return{title:"",link:[]}}async uri(){
|
|
87
|
-
return document.location.href}async scrollToAnchor(){}}class jn{constructor(t=document.body){this._htmlIntegration=new fn(t),this._listeners=new Ot;const e=["mousedown","mouseup","mouseout"];for(let t of e)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const n=document.querySelector("#pbk-page"),o=window.innerPageData;n&&o&&(this._textLayer=new
|
|
87
|
+
return document.location.href}async scrollToAnchor(){}}class jn{constructor(t=document.body){this._htmlIntegration=new fn(t),this._listeners=new Ot;const e=["mousedown","mouseup","mouseout"];for(let t of e)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const n=document.querySelector("#pbk-page"),o=window.innerPageData;n&&o&&(this._textLayer=new qn(n,o.glyphs.glyphs.map((t=>({left:t.l/100,right:t.r/100,top:t.t/100,bottom:t.b/100}))),o.words),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)}describe(t,e){return this._htmlIntegration.describe(t,e)}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(){return!1}async getMetadata(){return{title:document.title,link:[]}}async uri(){const t=new URL(document.location.href);return t.search="",t.toString()}
|
|
88
88
|
async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function zn(t){if("undefined"!=typeof PDFViewerApplication)return new Vn(t);const e=function(t=window){var e;if(Wn(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&Wn(n)?"content":null}();return"container"===e?new $n(t):"content"===e?new jn:new fn}class Xn{constructor(t,e=document){let n=!1;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(function(t){const e=t.getSelection();if(!e||0===e.rangeCount)return null;const n=e.getRangeAt(0);return n.collapsed?null:n}(e))}),n)};this._eventHandler=t=>{if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;o(e)},this._document=e,this._listeners=new Ot,this._events=["mousedown","mouseup","selectionchange"];for(let t of this._events)this._listeners.add(e,t,this._eventHandler);o(1)}disconnect(){this._listeners.removeAll(),
|
|
89
89
|
this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function Yn(){const t=function(t,e){const n=new Set,o=new Set;return pe(t,(t=>{let i=t;for(;i&&!n.has(i);){n.add(i);const t=e(i);t&&o.add(t),i=i.parentNode}})),[...o]}(window.getSelection().getRangeAt(0),(t=>t._annotation));return t}function Gn(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));return e}function Zn(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function Kn(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class Jn{constructor(t,e={},n=window){this.element=t,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._adder=new re(this.element,{
|
|
90
90
|
onAnnotate:async()=>{await this.createAnnotation()},onHighlight:async()=>{await this.createAnnotation({highlight:!0})},onShowAnnotations:t=>{this.selectAnnotations(t)}}),this._selectionObserver=new Xn((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new Yt({hostFrame:this._hostFrame,source:"guest"}),this._hostRPC=new Xt,this._connectHostEvents(),this._sidebarRPC=new Xt,this._connectSidebarEvents(),this._hypothesisInjector=new Fe(this.element,e),this._integration=zn(this),this._sideBySideActive=!1,this._listeners=new Ot,this._setupElementEvents(),this._focusedAnnotations=new Set,this._listeners.add(window,"unload",(()=>this._notifyGuestUnload()))}_setupElementEvents(){const t=t=>{this._sideBySideActive||Gn(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:o}=t,i=Gn(e);if(i.length&&this._highlightsVisible){const t=n||o
|
|
91
91
|
;this.selectAnnotations(i,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=Gn(t);e.length&&this._highlightsVisible&&this._focusAnnotations(e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._focusAnnotations([])})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async injectClient(t){return this._hypothesisInjector.injectClient(t)}async getDocumentInfo(){const[t,e]=await Promise.all([this._integration.uri(),this._integration.getMetadata()]);return{uri:un(t),metadata:e,frameIdentifier:this._frameIdentifier}}_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 _connectHostEvents(){this._hostRPC.on("clearSelectionExceptIn",(t=>{
|
|
92
|
-
this._frameIdentifier!==t&&(this._informHostOnNextSelectionClear=!1,Kn())})),this._hostRPC.on("createAnnotationIn",(t=>{this._frameIdentifier===t&&this.createAnnotation()}));const t=await this._portFinder.discover("host");this._hostRPC.createChannel(t)}async _connectSidebarEvents(){this._sidebarRPC.on("focusAnnotations",((t=[])=>{this._focusedAnnotations.clear(),t.forEach((t=>this._focusedAnnotations.add(t)));for(let e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);ye(e.highlights,n)}})),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=Zn(e);if(!n)return;const o=new CustomEvent("scrolltorange",{bubbles:!0,cancelable:!0,detail:n});this.element.dispatchEvent(o)&&this._integration.scrollToAnchor(e)})),this._sidebarRPC.on("getDocumentInfo",(t=>{
|
|
93
|
-
this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t)))));const t=await this._portFinder.discover("sidebar");this._sidebarRPC.createChannel(t)}destroy(){this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),function(t){ve(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy(),this._sidebarRPC.destroy()}_notifyGuestUnload(){const t={type:"hypothesisGuestUnloaded",frameIdentifier:this._frameIdentifier};this._hostFrame.postMessage(t,"*")}async anchor(t){const e=t=>{const e=Zn(t);if(!e)return;const n=ge(e);n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&ye(n,!0)}
|
|
94
|
-
if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const o=await this._integration.anchor(this.element,e.selector),i=he.fromRange(o);n={annotation:t,target:e,range:i}}catch(o){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(let 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(let e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&ve(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,e&&null===this._frameIdentifier&&this._hostRPC.call("anchorsChanged")}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[]
|
|
95
|
-
}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:t,$tag:"a:"+Zt(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Kn(),r}_focusAnnotations(t){const e=t.map((t=>t.$tag));this._sidebarRPC.call("focusAnnotations",e)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=de(e),o=me(e);o?(this.selectedRanges=[t],this._hostRPC.call("textSelectedIn",this._frameIdentifier),this._adder.annotationsForSelection=Yn(),this._isAdderVisible=!0,this._adder.show(o,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselectedIn",this._frameIdentifier),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,e=!1){const n=t.map((t=>t.$tag))
|
|
96
|
-
return this._integration.scrollToAnchor(t)}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}contentContainer(){return this._integration.contentContainer()}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get focusedAnnotationTags(){return this._focusedAnnotations}}function Qn(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function to(t){var
|
|
97
|
-
t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return
|
|
98
|
-
null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),gt(eo,{config:e,groupId:s},n)]})})}class oo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=oe(this._outerContainer),P(gt(no,{eventBus:e,config:n}),this.shadowRoot)}destroy(){P(null,this.shadowRoot),this._outerContainer.remove()}}var io={exports:{}};!function(t){!function(e,n,o,i){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 o;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==i)for(o=0;o<t.length;)e.call(n,t[o],o,t),
|
|
99
|
-
var n=new Error("get-stack-trace"),o=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,i,o),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===i||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var o=arguments[n];if(o!==i&&null!==o)for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])}return e}:Object.assign;var m=p((function(t,e,n){for(var o=Object.keys(e),r=0;r<o.length;)(!n||n&&t[o[r]]===i)&&(t[o[r]]=e[o[r]]),r++;return t}),"extend","Use `assign`."),g=p((function(t,e){return m(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var o,i=e.prototype;(o=t.prototype=Object.create(i)).constructor=t,
|
|
100
|
-
return"function"==typeof t?t.apply(e&&e[0]||i,e):t}function w(t,e){return t===i?e:t}function b(t,e,n){f(x(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(x(e),(function(e){t.removeEventListener(e,n,!1)}))}function E(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function x(t){return t.trim().split(/\s+/g)}function T(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var o=0;o<t.length;){if(n&&t[o][n]==e||!n&&t[o]===e)return o;o++}return-1}function A(t){return Array.prototype.slice.call(t,0)}function k(t,e,n){for(var o=[],i=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];T(i,s)<0&&o.push(t[r]),i[r]=s,r++}return n&&(o=e?o.sort((function(t,n){return t[e]>n[e]})):o.sort()),o}function N(t,e){for(var n,o,r=e[0].toUpperCase()+e.slice(1),a=0;a<s.length;){if((o=(n=s[a])?n+r:e)in t)return o;a++}return i}var R=1;function L(t){var n=t.ownerDocument||t
|
|
101
|
-
var P="ontouchstart"in e,M=N(e,"PointerEvent")!==i,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",D="mouse",H=24,F=["x","y"],B=["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
|
|
102
|
-
o=t.offsetDelta={x:n.x,y:n.y});e.deltaX=i.x+(n.x-o.x),e.deltaY=i.y+(n.y-o.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=o,z(p[0],p[1],B)/z(f[0],f[1],B)):1,e.rotation=a?function(t,e){return X(e[1],e[0],B)+X(t[1],t[0],B)}(a.pointers,o):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,o,r,s,a=t.lastInterval||e,l=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(l>25||a.velocity===i)){var h=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=$(l,h,u);o=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,o=a.velocityX,r=a.velocityY,s=a.direction;e.velocity=n,e.velocityX=o,e.velocityY=r,e.direction=s}(n,e);var f,p;var m=t.element;E(e.srcEvent.target,m)&&(m=e.srcEvent.target)
|
|
103
|
-
function
|
|
104
|
-
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},G="mousedown",Z="mousemove mouseup";function K(){this.evEl=G,this.evWin=Z,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:D,srcEvent:t}))}});var J={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:I,3:"pen",4:D,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){
|
|
92
|
+
this._frameIdentifier!==t&&(this._informHostOnNextSelectionClear=!1,Kn())})),this._hostRPC.on("createAnnotationIn",(t=>{this._frameIdentifier===t&&this.createAnnotation()})),this._hostRPC.on("sidebarLayoutChanged",(t=>{null===this._frameIdentifier&&this.fitSideBySide(t)}));const t=await this._portFinder.discover("host");this._hostRPC.createChannel(t)}async _connectSidebarEvents(){this._sidebarRPC.on("focusAnnotations",((t=[])=>{this._focusedAnnotations.clear(),t.forEach((t=>this._focusedAnnotations.add(t)));for(let e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);ye(e.highlights,n)}})),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=Zn(e);if(!n)return;const o=new CustomEvent("scrolltorange",{bubbles:!0,cancelable:!0,detail:n});this.element.dispatchEvent(o)&&this._integration.scrollToAnchor(e)})),this._sidebarRPC.on("getDocumentInfo",(t=>{
|
|
93
|
+
this.getDocumentInfo().then((e=>t(null,e))).catch((e=>t(e)))})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t)))));const t=await this._portFinder.discover("sidebar");this._sidebarRPC.createChannel(t)}destroy(){this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),function(t){ve(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy(),this._sidebarRPC.destroy()}_notifyGuestUnload(){const t={type:"hypothesisGuestUnloaded",frameIdentifier:this._frameIdentifier};this._hostFrame.postMessage(t,"*")}async anchor(t){const e=t=>{const e=Zn(t);if(!e)return;const n=ge(e);n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&ye(n,!0)}
|
|
94
|
+
;this.detach(t.$tag,!1),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 o=await this._integration.anchor(this.element,e.selector),i=he.fromRange(o);n={annotation:t,target:e,range:i}}catch(o){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(let 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(let e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&ve(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,e&&null===this._frameIdentifier&&this._hostRPC.call("anchorsChanged")}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[]
|
|
95
|
+
;const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(e.map((t=>this._integration.describe(o,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:t,$tag:"a:"+Zt(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Kn(),r}_focusAnnotations(t){const e=t.map((t=>t.$tag));this._sidebarRPC.call("focusAnnotations",e)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=de(e),o=me(e);o?(this.selectedRanges=[t],this._hostRPC.call("textSelectedIn",this._frameIdentifier),this._adder.annotationsForSelection=Yn(),this._isAdderVisible=!0,this._adder.show(o,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselectedIn",this._frameIdentifier),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,e=!1){const n=t.map((t=>t.$tag))
|
|
96
|
+
;e?this._sidebarRPC.call("toggleAnnotationSelection",n):this._sidebarRPC.call("showAnnotations",n),this._sidebarRPC.call("openSidebar")}scrollToAnchor(t){return this._integration.scrollToAnchor(t)}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}contentContainer(){return this._integration.contentContainer()}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get focusedAnnotationTags(){return this._focusedAnnotations}}function Qn(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function to(t,e){var n;const o={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(o[t]=n);o.origin=new URL(t).origin,o.version="1.954.0";const i=new URL(window.location.href);if(i.hash="",o.hostURL=i.toString(),
|
|
97
|
+
(null===(n=o.services)||void 0===n?void 0:n.length)>0){const t=o.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 o}function eo({config:t,groupId:e}){return gt("iframe",{title:"Hypothesis annotation notebook",className:"NotebookIframe",allowFullScreen:!0,src:Qn(t.notebookAppUrl,{...to(t.notebookAppUrl,t),group:e})})}function no({eventBus:t,config:e}){const[n,o]=rt(0),[i,r]=rt(!0),[s,a]=rt(null),l=lt(""),c=lt(null);st((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),st((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),st((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:gt("div",{className:Z("NotebookModal__outer",{"is-hidden":i}),
|
|
98
|
+
children:gt("div",{className:"NotebookModal__inner",children:[gt("div",{className:"NotebookModal__close-button-container",children:gt(Ct,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),gt(eo,{config:e,groupId:s},n)]})})}class oo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=oe(this._outerContainer),P(gt(no,{eventBus:e,config:n}),this.shadowRoot)}destroy(){P(null,this.shadowRoot),this._outerContainer.remove()}}var io={exports:{}};!function(t){!function(e,n,o,i){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 o;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==i)for(o=0;o<t.length;)e.call(n,t[o],o,t),
|
|
99
|
+
o++;else for(o in t)t.hasOwnProperty(o)&&e.call(n,t[o],o,t)}function p(t,n,o){var i="DEPRECATED METHOD: "+n+"\n"+o+" AT \n";return function(){var n=new Error("get-stack-trace"),o=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,i,o),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===i||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var o=arguments[n];if(o!==i&&null!==o)for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])}return e}:Object.assign;var m=p((function(t,e,n){for(var o=Object.keys(e),r=0;r<o.length;)(!n||n&&t[o[r]]===i)&&(t[o[r]]=e[o[r]]),r++;return t}),"extend","Use `assign`."),g=p((function(t,e){return m(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var o,i=e.prototype;(o=t.prototype=Object.create(i)).constructor=t,
|
|
100
|
+
o._super=i,n&&r(o,n)}function v(t,e){return function(){return t.apply(e,arguments)}}function y(t,e){return"function"==typeof t?t.apply(e&&e[0]||i,e):t}function w(t,e){return t===i?e:t}function b(t,e,n){f(x(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(x(e),(function(e){t.removeEventListener(e,n,!1)}))}function E(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function x(t){return t.trim().split(/\s+/g)}function T(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var o=0;o<t.length;){if(n&&t[o][n]==e||!n&&t[o]===e)return o;o++}return-1}function A(t){return Array.prototype.slice.call(t,0)}function k(t,e,n){for(var o=[],i=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];T(i,s)<0&&o.push(t[r]),i[r]=s,r++}return n&&(o=e?o.sort((function(t,n){return t[e]>n[e]})):o.sort()),o}function N(t,e){for(var n,o,r=e[0].toUpperCase()+e.slice(1),a=0;a<s.length;){if((o=(n=s[a])?n+r:e)in t)return o;a++}return i}var R=1;function L(t){var n=t.ownerDocument||t
|
|
101
|
+
;return n.defaultView||n.parentWindow||e}var P="ontouchstart"in e,M=N(e,"PointerEvent")!==i,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",D="mouse",H=24,F=["x","y"],B=["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 U(t,e,n){var o=n.pointers.length,r=n.changedPointers.length,s=1&e&&o-r==0,a=12&e&&o-r==0;n.isFirst=!!s,n.isFinal=!!a,s&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,o=e.pointers,r=o.length;n.firstInput||(n.firstInput=q(e));r>1&&!n.firstMultiple?n.firstMultiple=q(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,u=e.center=W(o);e.timeStamp=h(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=X(l,u),e.distance=z(l,u),function(t,e){var n=e.center,o=t.offsetDelta||{},i=t.prevDelta||{},r=t.prevInput||{}
|
|
102
|
+
;1!==e.eventType&&4!==r.eventType||(i=t.prevDelta={x:r.deltaX||0,y:r.deltaY||0},o=t.offsetDelta={x:n.x,y:n.y});e.deltaX=i.x+(n.x-o.x),e.deltaY=i.y+(n.y-o.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=o,z(p[0],p[1],B)/z(f[0],f[1],B)):1,e.rotation=a?function(t,e){return X(e[1],e[0],B)+X(t[1],t[0],B)}(a.pointers,o):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,o,r,s,a=t.lastInterval||e,l=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(l>25||a.velocity===i)){var h=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=$(l,h,u);o=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,o=a.velocityX,r=a.velocityY,s=a.direction;e.velocity=n,e.velocityX=o,e.velocityY=r,e.direction=s}(n,e);var f,p;var m=t.element;E(e.srcEvent.target,m)&&(m=e.srcEvent.target)
|
|
103
|
+
;e.target=m}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function q(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:W(e),deltaX:t.deltaX,deltaY:t.deltaY}}function W(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,o=0,i=0;i<e;)n+=t[i].clientX,o+=t[i].clientY,i++;return{x:l(n/e),y:l(o/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 z(t,e,n){n||(n=F);var o=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return Math.sqrt(o*o+i*i)}function X(t,e,n){n||(n=F);var o=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return 180*Math.atan2(i,o)/Math.PI}V.prototype={handler:function(){},init:function(){this.evEl&&b(this.element,this.evEl,this.domHandler),this.evTarget&&b(this.target,this.evTarget,this.domHandler),this.evWin&&b(L(this.element),this.evWin,this.domHandler)},destroy:function(){
|
|
104
|
+
this.evEl&&C(this.element,this.evEl,this.domHandler),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},G="mousedown",Z="mousemove mouseup";function K(){this.evEl=G,this.evWin=Z,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:D,srcEvent:t}))}});var J={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:I,3:"pen",4:D,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){
|
|
105
105
|
var e=this.store,n=!1,o=t.type.toLowerCase().replace("ms",""),i=J[o],r=Q[t.pointerType]||t.pointerType,s=r==I,a=T(e,t.pointerId,"pointerId");1&i&&(0===t.button||s)?a<0&&(e.push(t),a=e.length-1):12&i&&(n=!0),a<0||(e[a]=t,this.callback(this.manager,i,{pointers:e,changedPointers:[t],pointerType:r,srcEvent:t}),n&&e.splice(a,1))}});var ot={touchstart:1,touchmove:2,touchend:4,touchcancel:8},it="touchstart",rt="touchstart touchmove touchend touchcancel";function st(){this.evTarget=it,this.evWin=rt,this.started=!1,V.apply(this,arguments)}function at(t,e){var n=A(t.touches),o=A(t.changedTouches);return 12&e&&(n=k(n.concat(o),"identifier",!0)),[n,o]}_(st,V,{handler:function(t){var e=ot[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"
|
|
106
106
|
;function ht(){this.evTarget=ct,this.targetIds={},V.apply(this,arguments)}function ut(t,e){var n=A(t.touches),o=this.targetIds;if(3&e&&1===n.length)return o[n[0].identifier]=!0,[n,n];var i,r,s=A(t.changedTouches),a=[],l=this.target;if(r=n.filter((function(t){return E(t.target,l)})),1===e)for(i=0;i<r.length;)o[r[i].identifier]=!0,i++;for(i=0;i<s.length;)o[s[i].identifier]&&a.push(s[i]),12&e&&delete o[s[i].identifier],i++;return a.length?[k(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={
|
|
107
107
|
x:e.clientX,y:e.clientY};this.lastTouches.push(n);var o=this.lastTouches;setTimeout((function(){var t=o.indexOf(n);t>-1&&o.splice(t,1)}),2500)}}function mt(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,o=0;o<this.lastTouches.length;o++){var i=this.lastTouches[o],r=Math.abs(e-i.x),s=Math.abs(n-i.y);if(r<=25&&s<=25)return!0}return!1}_(dt,V,{handler:function(t,e,n){var o=n.pointerType==I,i=n.pointerType==D;if(!(i&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(o)ft.call(this,e,n);else if(i&&mt.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var gt=N(a.style,"touchAction"),_t=gt!==i,vt="compute",yt="auto",wt="manipulation",bt="none",Ct="pan-x",Et="pan-y",St=function(){if(!_t)return!1;var t={},n=e.CSS&&e.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(o){t[o]=!n||e.CSS.supports("touch-action",o)})),t}();function xt(t,e){this.manager=t,this.set(e)}xt.prototype={set:function(t){
|
|
@@ -112,7 +112,7 @@ return!0},recognize:function(t){var e=r({},t);if(!y(this.options.enable,[this,e]
|
|
|
112
112
|
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=Nt(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[bt]},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,At,{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,o=t.distance<e.threshold,i=t.deltaTime>e.time;if(this._input=t,!o||!n||12&t.eventType&&!i)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 Tt},
|
|
113
113
|
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[bt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),_(Dt,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&H&&(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=Nt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),
|
|
114
114
|
this.manager.emit(this.options.event,t)}}),_(Ht,At,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[wt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,o=t.distance<e.threshold,i=t.deltaTime<e.time;if(this.reset(),1&t.eventType&&0===this.count)return this.failTimeout();if(o&&i&&n){if(4!=t.eventType)return this.failTimeout();var r=!this.pTime||t.timeStamp-this.pTime<e.interval,s=!this.pCenter||z(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 Tt},failTimeout:function(){return this._timer=u((function(){this.state=Tt}),this.options.interval,this),Tt},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,
|
|
115
|
-
this.manager.emit(this.options.event,this._input))}}),Ft.VERSION="2.0.7",Ft.defaults={domEvents:!1,touchAction:vt,enable:!0,inputTarget:null,inputClass:null,preset:[[It,{enable:!1}],[Mt,{enable:!1},["rotate"]],[Dt,{direction:6}],[Pt,{direction:6},["swipe"]],[Ht],[Ht,{event:"doubletap",taps:2},["tap"]],[Ot]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Bt(t,e){var n;this.options=r({},Ft.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,
|
|
115
|
+
this.manager.emit(this.options.event,this._input))}}),Ft.VERSION="2.0.7",Ft.defaults={domEvents:!1,touchAction:vt,enable:!0,inputTarget:null,inputClass:null,preset:[[It,{enable:!1}],[Mt,{enable:!1},["rotate"]],[Dt,{direction:6}],[Pt,{direction:6},["swipe"]],[Ht],[Ht,{event:"doubletap",taps:2},["tap"]],[Ot]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Bt(t,e){var n;this.options=r({},Ft.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,U),this.touchAction=new xt(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,o=t.element;o.style&&(f(t.options.cssProps,(function(i,r){n=N(o.style,r),
|
|
116
116
|
e?(t.oldCssProps[n]=o.style[n],o.style[n]=i):o.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Bt.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 o=this.recognizers,i=e.curRecognizer;(!i||i&&8&i.state)&&(i=e.curRecognizer=null);for(var r=0;r<o.length;)n=o[r],2===e.stopped||i&&n!=i&&!n.canRecognizeWith(i)?n.reset():n.recognize(t),!i&&14&n.state&&(i=e.curRecognizer=n),r++}},get:function(t){if(t instanceof At)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){
|
|
117
117
|
if(d(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=T(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==i&&e!==i){var n=this.handlers;return f(x(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==i){var n=this.handlers;return f(x(t),(function(t){e?n[t]&&n[t].splice(T(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var o=n.createEvent("Event");o.initEvent(t,!0,!0),o.gesture=e,e.target.dispatchEvent(o)}(t,e);var o=this.handlers[t]&&this.handlers[t].slice();if(o&&o.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var i=0;i<o.length;)o[i](e),i++}},destroy:function(){this.element&&Vt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},r(Ft,{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:Tt,
|
|
118
118
|
DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:H,DIRECTION_ALL:30,Manager:Bt,Input:V,TouchAction:xt,TouchInput:ht,MouseInput:K,PointerEventInput:nt,TouchMouseInput:dt,SingleTouchInput:st,Recognizer:At,AttrRecognizer:Lt,Tap:Ht,Pan:Pt,Swipe:Dt,Pinch:Mt,Rotate:It,Press:Ot,on:b,off:C,each:f,merge:g,extend:m,assign:r,inherit:_,bindFn:v,prefixed:N}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Ft,t.exports?t.exports=Ft:e.Hammer=Ft}(window,document)}(io);var ro=io.exports;function so(t){const e=function(t){const e=[];return t.forEach((t=>{var n;if(null===(n=t.highlights)||void 0===n||!n.length)return;const o=we(t.highlights);o.top>=o.bottom||e.push({top:o.top,bottom:o.bottom,anchor:t})})),e.sort(((t,e)=>t.top<e.top?-1:1)),e}(t),n=new Set,o=new Set,i=[];let r=null;function s(t){const e=t.bottom-t.top,n=t.top+e/2;return{anchors:[t.anchor],top:t.top,bottom:t.bottom,position:n}}e.forEach((t=>{
|
|
@@ -121,13 +121,13 @@ if(t.top<137)return void n.add(t.anchor);if(t.top>window.innerHeight-22)return v
|
|
|
121
121
|
constructor(t,e,{contentContainer:n=document.body}={}){this._contentContainer=n,this._bucketsContainer=document.createElement("div"),t.appendChild(this._bucketsContainer),this._guest=e,this._listeners=new Ot,this._listeners.add(window,"resize",(()=>this.update())),this._listeners.add(window,"scroll",(()=>this.update())),this._listeners.add(n,"scroll",(()=>this.update())),this._update()}destroy(){this._listeners.removeAll(),this._bucketsContainer.remove()}update(){this._updatePending||(this._updatePending=!0,requestAnimationFrame((()=>{this._update(),this._updatePending=!1})))}_update(){const t=so(this._guest.anchors);P(gt(co,{above:t.above,below:t.below,buckets:t.buckets,onSelectAnnotations:(t,e)=>this._guest.selectAnnotations(t,e),scrollToAnchor:t=>this._guest.scrollToAnchor(t)}),this._bucketsContainer)}}let uo={};const fo=t=>{uo=t||{}},po=function(t){t.on("featureFlagsUpdated",fo)};function mo({buttonRef:t,expanded:e,className:n="Toolbar__button",label:o,icon:i,onClick:r,selected:s=!1}){return gt("button",{
|
|
122
122
|
className:n,"aria-label":o,"aria-expanded":e,"aria-pressed":s,onClick:r,ref:t,title:o,children:gt(vt,{name:i})})}function go({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:o,showHighlights:i,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return gt("div",{className:"Toolbar",children:[l&&n&>(mo,{className:"Toolbar__sidebar-close",label:"Close annotation sidebar",icon:"cancel",onClick:t}),!l&>(mo,{className:"Toolbar__sidebar-toggle",buttonRef:a,label:"Annotation sidebar",icon:n?"caret-right":"caret-left",expanded:n,onClick:s}),!l&>("div",{className:"Toolbar__buttonbar",children:[gt(mo,{label:"Show highlights",icon:i?"show":"hide",selected:i,onClick:r}),gt(mo,{label:"note"===o?"New page note":"New annotation",icon:"note"===o?"note":"annotate",onClick:e})]})]})}class _o{constructor(t,e){const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:i}=e;this._container=t,this._useMinimalControls=!1,this._newAnnotationType="note",
|
|
123
123
|
this._highlightsVisible=!1,this._sidebarOpen=!1,this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>i(!this._highlightsVisible),this._createAnnotation=()=>{n(),o(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this._container.firstChild.getBoundingClientRect().width}set useMinimalControls(t){this._useMinimalControls=t,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(t){this._sidebarOpen=t,this.render()}get sidebarOpen(){return this._sidebarOpen}set newAnnotationType(t){this._newAnnotationType=t,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(t){this._highlightsVisible=t,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){P(gt(go,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,
|
|
124
|
-
isSidebarOpen:this._sidebarOpen,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}class vo{constructor(t,e,n,o={}){if(this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=new Xt,this._sidebarRPC=new Xt,this.iframe=function(t){const e=Qn(t.sidebarAppUrl,to(t)),n=document.createElement("iframe");return n.setAttribute("allowfullscreen",""),n.src=e,n.title="Hypothesis annotation viewer",n.className="h-sidebar-iframe",n}(o),this.options=o,this.bucketBar=null,o.externalContainerSelector){var i;this.externalFrame=null!==(i=document.querySelector(o.externalContainerSelector))&&void 0!==i?i:t,this.externalFrame.appendChild(this.iframe)}else{
|
|
125
|
-
"clean"===o.theme
|
|
126
|
-
this.
|
|
127
|
-
this.
|
|
128
|
-
t.addEventListener("click",o)}))}(document.body,(()=>this.open())),po(this._sidebarRPC),this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),this._sidebarRPC.on("openSidebar",(()=>this.open())),this._sidebarRPC.on("closeSidebar",(()=>this.close())),this._sidebarRPC.on("openNotebook",(t=>{this.hide(),this._emitter.publish("openNotebook",t)})),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 ro.Manager(t).on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new ro.Pan({direction:ro.DIRECTION_HORIZONTAL})))}
|
|
129
|
-
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>=280&&(this.iframeContainer.style.width=`${e}px`),this._notifyOfLayoutChange()}})))}_notifyOfLayoutChange(t){var e;const n=this.iframeContainer&&this.toolbar.getWidth()||0,o=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,i=o.getBoundingClientRect(),r=window.getComputedStyle(o),s=parseInt(r.width),a=parseInt(r.marginLeft);let l=n;"boolean"==typeof t?t&&(l+=s):(a<280?l-=a:l+=s,t=l>n);const c={expanded:t,width:t?l:n,height:i.height,toolbarWidth:n};this.onLayoutChange&&this.onLayoutChange(c),this.
|
|
130
|
-
|
|
131
|
-
this.iframeContainer
|
|
132
|
-
|
|
124
|
+
isSidebarOpen:this._sidebarOpen,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}class vo{constructor(t,e,n,o={}){if(this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=new Xt,this._sidebarRPC=new Xt,this.iframe=function(t){const e=Qn(t.sidebarAppUrl,to(t.sidebarAppUrl,t)),n=document.createElement("iframe");return n.setAttribute("allowfullscreen",""),n.src=e,n.title="Hypothesis annotation viewer",n.className="h-sidebar-iframe",n}(o),this.options=o,this.bucketBar=null,o.externalContainerSelector){var i;this.externalFrame=null!==(i=document.querySelector(o.externalContainerSelector))&&void 0!==i?i:t,this.externalFrame.appendChild(this.iframe)}else{this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="annotator-frame",
|
|
125
|
+
"clean"===o.theme?this.iframeContainer.classList.add("annotator-frame--theme-clean"):this.bucketBar=new ho(this.iframeContainer,n,{contentContainer:n.contentContainer()}),this.iframeContainer.appendChild(this.iframe),this.hypothesisSidebar=document.createElement("hypothesis-sidebar");oe(this.hypothesisSidebar).appendChild(this.iframeContainer),t.appendChild(this.hypothesisSidebar)}this.iframe.contentWindow&&Mt(this.iframe.contentWindow),this._listeners=new Ot;const r=document.createElement("div");this.toolbar=new _o(r,{createAnnotation:()=>this._guestRPC.call("createAnnotationIn",this._guestWithSelection),setSidebarOpen:t=>t?this.open():this.close(),setHighlightsVisible:t=>this.setHighlightsVisible(t)}),"clean"===o.theme?this.toolbar.useMinimalControls=!0:this.toolbar.useMinimalControls=!1,this.iframeContainer?(this.iframeContainer.prepend(r),this.toolbarWidth=this.toolbar.getWidth()):this.toolbarWidth=0,this._listeners.add(window,"resize",(()=>this._onResize())),this._gestureState={initial:null,final:null},
|
|
126
|
+
this._setupGestures(),this.close();const[s]=o.services||[];s&&(this.onLoginRequest=s.onLoginRequest,this.onLogoutRequest=s.onLogoutRequest,this.onSignupRequest=s.onSignupRequest,this.onProfileRequest=s.onProfileRequest,this.onHelpRequest=s.onHelpRequest),this.onLayoutChange=o.onLayoutChange,this._notifyOfLayoutChange(!1),this._setupSidebarEvents(),this._sidebarRPC.onConnect((()=>{this.iframeContainer&&(this.iframeContainer.style.display="");const t="always"===o.showHighlights;this.setHighlightsVisible(t),(o.openSidebar||o.annotations||o.query||o.group)&&this.open()})),this._setupGuestEvents(),this._listeners.add(window,"message",(t=>{const{data:e}=t;"hypothesisGuestUnloaded"===(null==e?void 0:e.type)&&this._sidebarRPC.call("frameDestroyed",e.frameIdentifier)}))}destroy(){var t,e;this._guestRPC.destroy(),this._sidebarRPC.destroy(),null===(t=this.bucketBar)||void 0===t||t.destroy(),this._listeners.removeAll(),null===(e=this._hammerManager)||void 0===e||e.destroy(),
|
|
127
|
+
this.hypothesisSidebar?this.hypothesisSidebar.remove():this.iframe.remove(),this._emitter.destroy(),Mt(null)}onFrameConnected(t,e){switch(t){case"guest":this._guestRPC.createChannel(e);break;case"sidebar":this._sidebarRPC.createChannel(e)}}_setupGuestEvents(){this._guestRPC.on("textSelectedIn",(t=>{this._guestWithSelection=t,this.toolbar.newAnnotationType="annotation",this._guestRPC.call("clearSelectionExceptIn",t)})),this._guestRPC.on("textUnselectedIn",(t=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.call("clearSelectionExceptIn",t)})),this._guestRPC.on("anchorsChanged",(()=>{var t;null===(t=this.bucketBar)||void 0===t||t.update()}))}_setupSidebarEvents(){var t;t=document.body,this._sidebarRPC.on("publicAnnotationCountChanged",(function(e){const n=t.querySelectorAll("[data-hypothesis-annotation-count]");Array.from(n).forEach((t=>{t.textContent=e}))})),function(t,e){const n=t.querySelectorAll("[data-hypothesis-trigger]");function o(t){e(),t.stopPropagation()}
|
|
128
|
+
Array.from(n).forEach((t=>{t.addEventListener("click",o)}))}(document.body,(()=>this.open())),po(this._sidebarRPC),this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),this._sidebarRPC.on("openSidebar",(()=>this.open())),this._sidebarRPC.on("closeSidebar",(()=>this.close())),this._sidebarRPC.on("openNotebook",(t=>{this.hide(),this._emitter.publish("openNotebook",t)})),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 ro.Manager(t).on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new ro.Pan({direction:ro.DIRECTION_HORIZONTAL})))}
|
|
129
|
+
_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>=280&&(this.iframeContainer.style.width=`${e}px`),this._notifyOfLayoutChange()}})))}_notifyOfLayoutChange(t){var e;const n=this.iframeContainer&&this.toolbar.getWidth()||0,o=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,i=o.getBoundingClientRect(),r=window.getComputedStyle(o),s=parseInt(r.width),a=parseInt(r.marginLeft);let l=n;"boolean"==typeof t?t&&(l+=s):(a<280?l-=a:l+=s,t=l>n);const c={expanded:t,width:t?l:n,height:i.height,toolbarWidth:n};this.onLayoutChange&&this.onLayoutChange(c),this._guestRPC.call("sidebarLayoutChanged",c)}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<280?this.close():this.open())}_onPan(t){const e=this.iframeContainer;if(e)switch(t.type){case"panstart":this._resetGestureState(),
|
|
130
|
+
e.classList.add("annotator-no-transition"),e.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(e).marginLeft);break;case"panend":e.classList.remove("annotator-no-transition"),e.style.pointerEvents="",null===this._gestureState.final||this._gestureState.final<=-280?this.open():this.close(),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("annotator-collapsed")}this.toolbar.sidebarOpen=!0,"whenSidebarOpen"===this.options.showHighlights&&this.setHighlightsVisible(!0),this._notifyOfLayoutChange(!0)}close(){this.iframeContainer&&(this.iframeContainer.style.marginLeft="",
|
|
131
|
+
this.iframeContainer.classList.add("annotator-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this.options.showHighlights&&this.setHighlightsVisible(!1),this._notifyOfLayoutChange(!1)}setHighlightsVisible(t){this.toolbar.highlightsVisible=t,this._sidebarRPC.call("setHighlightsVisible",t)}show(){this.iframeContainer&&this.iframeContainer.classList.remove("is-hidden")}hide(){this.iframeContainer&&this.iframeContainer.classList.add("is-hidden")}}class yo{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,o])=>n!==t||o!==e))}destroy(){for(let[t,e]of this._subscriptions)this._emitter.off(t,e);this._subscriptions=[]}}class wo{constructor(){this._emitter=new Nt}createEmitter(){return new yo(this._emitter)}}!function(t,{reset:e=!1}={}){e&&_t.clear();for(let[e,n]of Object.entries(t))_t.set(e,n)}(Tt)
|
|
132
|
+
;const bo=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=jt("annotator"),e=t.subFrameIdentifier?window.parent:window,n=new Jn(document.body,t,e);let o,i,r;if(e===window){const t=jt("sidebar"),e=new URL(t.sidebarAppUrl).origin;r=new Ht(e),r.listen();const s=new wo;o=new vo(document.body,s,n,t),i=new oo(document.body,s,jt("notebook")),r.on("frameConnected",((t,e)=>o.onFrameConnected(t,e)))}bo.addEventListener("destroy",(()=>{var t,e,s;null===(t=r)||void 0===t||t.destroy(),null===(e=o)||void 0===e||e.destroy(),null===(s=i)||void 0===s||s.destroy(),n.destroy();document.querySelectorAll("[data-hypothesis-asset]").forEach((t=>t.remove()))}))}));
|
|
133
133
|
//# sourceMappingURL=annotator.bundle.js.map
|