hypothesis 1.976.0 → 1.977.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/boot.js +1 -1
- package/build/manifest.json +8 -8
- package/build/scripts/annotator.bundle.js +52 -52
- package/build/scripts/annotator.bundle.js.map +1 -1
- package/build/scripts/sidebar.bundle.js +59 -58
- package/build/scripts/sidebar.bundle.js.map +1 -1
- package/build/styles/annotator.css.map +1 -1
- package/build/styles/sidebar.css.map +1 -1
- package/build/styles/ui-playground.css.map +1 -1
- package/package.json +1 -1
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function 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
|
|
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 h(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 f(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?f(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?abb305","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?93dd5b","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?4a00cc","styles/annotator.css":"styles/annotator.css?1cff43","styles/annotator.css.map":"styles/annotator.css.map?2a0ac7","styles/highlights.css":"styles/highlights.css?c308d0","styles/highlights.css.map":"styles/highlights.css.map?5be890","styles/katex.min.css":"styles/katex.min.css?28919c","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?2ba841","styles/sidebar.css.map":"styles/sidebar.css.map?e255d5","styles/ui-playground.css":"styles/ui-playground.css?42a13e","styles/ui-playground.css.map":"styles/ui-playground.css.map?15e8ad","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?fb98d0","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?bc7d6a","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?d98ade"};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.977.0/");if(document.querySelector("hypothesis-app"))!function(t,e){u(t,"fetch",e.apiUrl),u(t,"fetch",e.apiUrl+"links");var s=h(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=h(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?abb305",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?93dd5b",
|
|
4
|
+
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?4a00cc",
|
|
4
5
|
"styles/annotator.css": "styles/annotator.css?1cff43",
|
|
5
|
-
"styles/annotator.css.map": "styles/annotator.css.map?
|
|
6
|
+
"styles/annotator.css.map": "styles/annotator.css.map?2a0ac7",
|
|
6
7
|
"styles/highlights.css": "styles/highlights.css?c308d0",
|
|
7
8
|
"styles/highlights.css.map": "styles/highlights.css.map?5be890",
|
|
8
9
|
"styles/katex.min.css": "styles/katex.min.css?28919c",
|
|
9
|
-
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?4a00cc",
|
|
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
13
|
"styles/sidebar.css": "styles/sidebar.css?2ba841",
|
|
14
|
-
"styles/sidebar.css.map": "styles/sidebar.css.map?
|
|
14
|
+
"styles/sidebar.css.map": "styles/sidebar.css.map?e255d5",
|
|
15
15
|
"styles/ui-playground.css": "styles/ui-playground.css?42a13e",
|
|
16
|
-
"styles/ui-playground.css.map": "styles/ui-playground.css.map?
|
|
17
|
-
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?
|
|
18
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
16
|
+
"styles/ui-playground.css.map": "styles/ui-playground.css.map?15e8ad",
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?fb98d0",
|
|
18
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?bc7d6a",
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?d98ade"
|
|
20
20
|
}
|
|
@@ -18,12 +18,12 @@ if(void 0!==o.__k&&void 0!==o.__e)throw new Error("Invalid type passed to create
|
|
|
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 "+M(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){
|
|
19
19
|
Object.keys(t).forEach((function(n){var r;try{r=t[n](e,n,o,"prop",null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(t){r=t}!r||r.message in O||(O[r.message]=!0,console.error("Failed prop type: "+r.message+(i&&"\n"+i()||"")))}))}(n.type.propTypes,c,0,M(n),(function(){return V(n)}))}e&&e(n)},n.__h=function(e,n,o){if(!e||!t)throw new Error("Hook can only be invoked from render methods.");a&&a(e,n,o)};var h=function(t,e){return{get:function(){var n="get"+t+e;c&&c.indexOf(n)<0&&(c.push(n),console.warn("getting vnode."+t+" is deprecated, "+e))},set:function(){var n="set"+t+e;c&&c.indexOf(n)<0&&(c.push(n),console.warn("setting vnode."+t+" is not allowed, "+e))}}},u={nodeName:h("nodeName","use vnode.type"),attributes:h("attributes","use vnode.props"),children:h("children","use vnode.props.children")},d=Object.create({},u);n.vnode=function(t){var e=t.props;if(null!==t.type&&null!=e&&("__source"in e||"__self"in e)){var n=t.props={};for(var o in e){var r=e[o]
|
|
20
20
|
;"__source"===o?t.__source=r:"__self"===o?t.__self=r:n[o]=r}}t.__proto__=d,i&&i(t)},n.diffed=function(e){if(e.__k&&e.__k.forEach((function(t){if(t&&void 0===t.type){delete t.__,delete t.__b;var n=Object.keys(t).join(",");throw new Error("Objects are not valid as a child. Encountered an object with the keys {"+n+"}.\n\n"+V(e))}})),t=!1,o&&o(e),null!=e.__k)for(var n=[],i=0;i<e.__k.length;i++){var r=e.__k[i];if(r&&null!=r.key){var s=r.key;if(-1!==n.indexOf(s)){console.error('Following component has two or more children with the same key attribute: "'+s+'". This may cause glitches and misbehavior in rendering process. Component: \n\n'+$(e)+"\n\n"+V(e));break}n.push(s)}}}}();var j,z={exports:{}};j=z,function(){var t={}.hasOwnProperty;function e(){for(var n=[],o=0;o<arguments.length;o++){var i=arguments[o];if(i){var r=typeof i;if("string"===r||"number"===r)n.push(i);else if(Array.isArray(i)){if(i.length){var s=e.apply(null,i);s&&n.push(s)}
|
|
21
|
-
}else if("object"===r)if(i.toString===Object.prototype.toString)for(var a in i)t.call(i,a)&&i[a]&&n.push(a);else n.push(i.toString())}}return n.join(" ")}j.exports?(e.default=e,j.exports=e):window.classNames=e}();var X,Y,G
|
|
22
|
-
t.__H.__h.forEach(dt),t.__H.__h=[]}catch(e){t.__H.__h=[],n.__e(e,t.__v)}}n.__b=function(t){Y=null,Q&&Q(t)},n.__r=function(t){tt&&tt(t),X=0;var e=(Y=t.__c).__H;e&&(e.__h.forEach(ut),e.__h.forEach(dt),e.__h=[])},n.diffed=function(t){et&&et(t);var e=t.__c;e&&e.__H&&e.__H.__h.length&&(1!==J.push(e)&&
|
|
23
|
-
function ft(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function pt(t,e){return"function"==typeof e?e(t):e}var gt=0;function mt(t,e,o,i,r){var s,a,l={};for(a in e)"ref"==a?s=e[a]:l[a]=e[a];var c={type:t,props:l,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--gt,__source:i,__self:r};if("function"==typeof t&&(s=t.defaultProps))for(a in s)void 0===l[a]&&(l[a]=s[a]);return n.vnode&&n.vnode(c),c}const _t=new Map;function vt({name:t,className:e="",inline:n=!1,title:o=""}){const i=_t.get(t);if(!i)throw new Error(`Icon "${t.toString()}" is not registered`);const r=lt();at((()=>{const t=r.current.querySelector("svg");t&&t.setAttribute("class",e)}),[e,i]);const s={};return o&&(s.title=o),mt("span",{className:
|
|
24
|
-
function yt(t,e){const n="string"==typeof t?Symbol(t):t;return _t.set(n,e),n}var wt="/home/runner/work/frontend-shared/frontend-shared/src/components/buttons.js";function bt({buttonRef:t,classes:e,className:n,icon:o,iconPosition:i="left",size:r="medium",variant:s="normal",expanded:a,pressed:l,type:c="button",...h}){var u;const d=null!==(u=null==h?void 0:h.role)&&void 0!==u?u:"button",f={"aria-label":h.title};return"tab"===d?f["aria-selected"]=l:(f["aria-pressed"]=l,f["aria-expanded"]=a),mt("button",{ref:t,className:
|
|
21
|
+
}else if("object"===r)if(i.toString===Object.prototype.toString)for(var a in i)t.call(i,a)&&i[a]&&n.push(a);else n.push(i.toString())}}return n.join(" ")}j.exports?(e.default=e,j.exports=e):window.classNames=e}();var X,Y,Z,G=z.exports,K=0,J=[],Q=n.__b,tt=n.__r,et=n.diffed,nt=n.__c,ot=n.unmount;function it(t,e){n.__h&&n.__h(Y,t,K||e),K=0;var o=Y.__H||(Y.__H={__:[],__h:[]});return t>=o.__.length&&o.__.push({}),o.__[t]}function rt(t){return K=1,function(t,e,n){var o=it(X++,2);return o.t=t,o.__c||(o.__=[n?n(e):pt(void 0,e),function(t){var e=o.t(o.__[0],t);o.__[0]!==e&&(o.__=[e,o.__[1]],o.__c.setState({}))}],o.__c=Y),o.__}(pt,t)}function st(t,e){var o=it(X++,3);!n.__s&&ft(o.__H,e)&&(o.__=t,o.__H=e,Y.__H.__h.push(o))}function at(t,e){var o=it(X++,4);!n.__s&&ft(o.__H,e)&&(o.__=t,o.__H=e,Y.__h.push(o))}function lt(t){return K=5,function(t,e){var n=it(X++,7);return ft(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}((function(){return{current:t}}),[])}function ct(){for(var t;t=J.shift();)if(t.__P)try{t.__H.__h.forEach(ut),
|
|
22
|
+
t.__H.__h.forEach(dt),t.__H.__h=[]}catch(e){t.__H.__h=[],n.__e(e,t.__v)}}n.__b=function(t){Y=null,Q&&Q(t)},n.__r=function(t){tt&&tt(t),X=0;var e=(Y=t.__c).__H;e&&(e.__h.forEach(ut),e.__h.forEach(dt),e.__h=[])},n.diffed=function(t){et&&et(t);var e=t.__c;e&&e.__H&&e.__H.__h.length&&(1!==J.push(e)&&Z===n.requestAnimationFrame||((Z=n.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(o),ht&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,100);ht&&(e=requestAnimationFrame(n))})(ct)),Y=null},n.__c=function(t,e){e.some((function(t){try{t.__h.forEach(ut),t.__h=t.__h.filter((function(t){return!t.__||dt(t)}))}catch(o){e.some((function(t){t.__h&&(t.__h=[])})),e=[],n.__e(o,t.__v)}})),nt&&nt(t,e)},n.unmount=function(t){ot&&ot(t);var e,o=t.__c;o&&o.__H&&(o.__H.__.forEach((function(t){try{ut(t)}catch(t){e=t}})),e&&n.__e(e,o.__v))};var ht="function"==typeof requestAnimationFrame;function ut(t){var e=Y,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),Y=e}function dt(t){var e=Y;t.__c=t.__(),Y=e}
|
|
23
|
+
function ft(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function pt(t,e){return"function"==typeof e?e(t):e}var gt=0;function mt(t,e,o,i,r){var s,a,l={};for(a in e)"ref"==a?s=e[a]:l[a]=e[a];var c={type:t,props:l,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--gt,__source:i,__self:r};if("function"==typeof t&&(s=t.defaultProps))for(a in s)void 0===l[a]&&(l[a]=s[a]);return n.vnode&&n.vnode(c),c}const _t=new Map;function vt({name:t,className:e="",inline:n=!1,title:o=""}){const i=_t.get(t);if(!i)throw new Error(`Icon "${t.toString()}" is not registered`);const r=lt();at((()=>{const t=r.current.querySelector("svg");t&&t.setAttribute("class",e)}),[e,i]);const s={};return o&&(s.title=o),mt("span",{className:G("Hyp-SvgIcon",{"Hyp-SvgIcon--inline":n}),dangerouslySetInnerHTML:{__html:i},ref:r,...s},void 0,!1,{fileName:"/home/runner/work/frontend-shared/frontend-shared/src/components/SvgIcon.js",lineNumber:69,columnNumber:5})}
|
|
24
|
+
function yt(t,e){const n="string"==typeof t?Symbol(t):t;return _t.set(n,e),n}var wt="/home/runner/work/frontend-shared/frontend-shared/src/components/buttons.js";function bt({buttonRef:t,classes:e,className:n,icon:o,iconPosition:i="left",size:r="medium",variant:s="normal",expanded:a,pressed:l,type:c="button",...h}){var u;const d=null!==(u=null==h?void 0:h.role)&&void 0!==u?u:"button",f={"aria-label":h.title};return"tab"===d?f["aria-selected"]=l:(f["aria-pressed"]=l,f["aria-expanded"]=a),mt("button",{ref:t,className:G(n,`${n}--${r}`,`${n}--${s}`,{[`${n}--icon-${i}`]:o},e),type:c,...f,...h},void 0,!1,{fileName:wt,lineNumber:82,columnNumber:5})}function Ct({className:t="Hyp-IconButton",...e}){const{icon:n}=e;return mt(bt,{className:t,...e,children:mt(vt,{name:n},void 0,!1,{fileName:wt,lineNumber:109,columnNumber:7})},void 0,!1,{fileName:wt,lineNumber:108,columnNumber:5})}function Et({children:t,className:e="Hyp-LabeledButton",...n}){const{icon:o,iconPosition:i="left"}=n;return mt(bt,{className:e,...n,
|
|
25
25
|
children:[o&&"left"===i&&mt(vt,{name:o},void 0,!1,{fileName:wt,lineNumber:127,columnNumber:43}),t,o&&"right"===i&&mt(vt,{name:o},void 0,!1,{fileName:wt,lineNumber:129,columnNumber:44})]},void 0,!0,{fileName:wt,lineNumber:126,columnNumber:5})}yt("checkbox",' <svg\n width="32"\n height="32"\n viewBox="-4 -4 39 39"\n aria-hidden="true"\n focusable="false"\n >\n <rect\n class="hyp-svg-checkbox--background"\n width="35"\n height="35"\n x="-2"\n y="-2"\n stroke="currentColor"\n fill="none"\n stroke-width="3"\n rx="5"\n ry="5"\n />\n <polyline\n class="hyp-svg-checkbox--checkmark"\n points="4,14 12,23 28,5"\n stroke="transparent"\n stroke-width="5"\n fill="none"\n />\n</svg>')
|
|
26
|
-
;var St='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><g fill-rule="evenodd"><rect fill="none" stroke="none" x="0" y="0" width="16" height="16"></rect><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 8l3.536-3.536L8 8 4.464 4.464 8 8zm0 0l-3.536 3.536L8 8l3.536 3.536L8 8z"></path></g></svg>\n';yt("cancel",St);function xt({name:t,classes:e="",containerClasses:n="",title:o=""}){const i=_t.get(t);if(!i)throw new Error(`Icon "${t.toString()}" is not registered`);const r=lt();at((()=>{const t=r.current.querySelector("svg");t&&t.setAttribute("class",
|
|
26
|
+
;var St='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><g fill-rule="evenodd"><rect fill="none" stroke="none" x="0" y="0" width="16" height="16"></rect><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 8l3.536-3.536L8 8 4.464 4.464 8 8zm0 0l-3.536 3.536L8 8l3.536 3.536L8 8z"></path></g></svg>\n';yt("cancel",St);function xt({name:t,classes:e="",containerClasses:n="",title:o=""}){const i=_t.get(t);if(!i)throw new Error(`Icon "${t.toString()}" is not registered`);const r=lt();at((()=>{const t=r.current.querySelector("svg");t&&t.setAttribute("class",G("Hyp-Icon",e))}),[e,i]);const s={};return o&&(s.title=o),mt("span",{className:n,dangerouslySetInnerHTML:{__html:i},ref:r,...s},void 0,!1,{fileName:"/home/runner/work/frontend-shared/frontend-shared/src/components/Icon.js",lineNumber:60,columnNumber:5})}yt("cancel",St)
|
|
27
27
|
;yt("spinner",'<svg viewBox="0 0 64 64">\n <g stroke-width="6" stroke="currentColor" stroke-linecap="round">\n <line y1="16" y2="28" transform="translate(32,32) rotate(180)">\n <animate attributeName="stroke-opacity" dur="750ms" values="0;1;.8;.65;.45;.3;.15;0" repeatCount="indefinite"></animate>\n </line>\n <line y1="16" y2="28" transform="translate(32,32) rotate(225)">\n <animate attributeName="stroke-opacity" dur="750ms" values=".15;0;1;.8;.65;.45;.3;.15" repeatCount="indefinite"></animate>\n </line>\n <line y1="16" y2="28" transform="translate(32,32) rotate(270)">\n <animate attributeName="stroke-opacity" dur="750ms" values=".3;.15;0;1;.8;.65;.45;.3" repeatCount="indefinite"></animate>\n </line>\n <line y1="16" y2="28" transform="translate(32,32) rotate(315)">\n <animate attributeName="stroke-opacity" dur="750ms" values=".45;.3;.15;0;1;.85;.65;.45" repeatCount="indefinite"></animate>\n </line>\n <line y1="16" y2="28" transform="translate(32,32) rotate(0)">\n <animate attributeName="stroke-opacity" dur="750ms" values=".65;.45;.3;.15;0;1;.8;.65;" repeatCount="indefinite"></animate>\n </line>\n <line y1="16" y2="28" transform="translate(32,32) rotate(45)">\n <animate attributeName="stroke-opacity" dur="750ms" values=".8;.65;.45;.3;.15;0;1;.8" repeatCount="indefinite"></animate>\n </line>\n <line y1="16" y2="28" transform="translate(32,32) rotate(90)">\n <animate attributeName="stroke-opacity" dur="750ms" values="1;.85;.6;.45;.3;.15;0;1;" repeatCount="indefinite"></animate>\n </line>\n <line y1="16" y2="28" transform="translate(32,32) rotate(135)">\n <animate attributeName="stroke-opacity" dur="750ms" values="0;1;.8;.65;.45;.3;.15;0" repeatCount="indefinite"></animate>\n </line>\n </g>\n</svg>')
|
|
28
28
|
;const Tt={
|
|
29
29
|
annotate:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">\n <path fill="currentColor" fill-rule="nonzero" d="M15 0c.27 0 .505.099.703.297A.961.961 0 0116 1v15l-4-3H1a.974.974 0 01-.703-.29A.953.953 0 010 12V1C0 .719.096.482.29.29A.966.966 0 011 0h14zM7 3l-.469.063c-.312.041-.656.187-1.031.437-.375.25-.719.646-1.031 1.188C4.156 5.229 4 6 4 7l.002.063.006.062a.896.896 0 01.008.11l-.002.074-.006.066a1.447 1.447 0 00.43 1.188C4.729 8.854 5.082 9 5.5 9c.417 0 .77-.146 1.063-.438C6.854 8.271 7 7.918 7 7.5c0-.417-.146-.77-.438-1.063A1.447 1.447 0 005.5 6c-.073 0-.146.005-.219.016-.073.01-.14.026-.203.046.177-1.03.542-1.632 1.094-1.804L7 4V3zm5 0l-.469.063c-.312.041-.656.187-1.031.437-.375.25-.719.646-1.031 1.188C9.156 5.229 9 6 9 7l.002.063.006.062a.896.896 0 01.008.11l-.002.074-.006.066a1.447 1.447 0 00.43 1.188c.291.291.645.437 1.062.437.417 0 .77-.146 1.063-.438.291-.291.437-.645.437-1.062 0-.417-.146-.77-.438-1.063A1.447 1.447 0 0010.5 6c-.073 0-.146.005-.219.016-.073.01-.14.026-.203.046.177-1.03.542-1.632 1.094-1.804L12 4V3z"/>\n</svg>\n',
|
|
@@ -37,34 +37,34 @@ this._listeners.clear()}}function kt(t){if(null===t||"object"!=typeof t)return!1
|
|
|
37
37
|
frame2:t,type:"offer"})&&(clearInterval(i),clearTimeout(r),this._listeners.remove(s),e(a[0]))}));o()}))}}var Pt={exports:{}};function Lt(){}Lt.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var o=this;function i(){o.off(t,i),e.apply(n,arguments)}return i._=e,this.on(t,i,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;o<i;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){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}},Pt.exports=Lt;var Ot=Pt.exports.TinyEmitter=Lt;let Mt=null;function It(t){return t instanceof Error?{message:t.message,stack:t.stack}:{message:String(t),stack:void 0}}function Ft(t,e){if(!Mt)return;const n={type:"hypothesis-error",error:t instanceof Error?t:It(t),context:e};try{try{Mt.postMessage(n,"*")}catch(t){
|
|
38
38
|
if(!(t instanceof DOMException&&"DataCloneError"===t.name))throw t;n.error=It(n.error),Mt.postMessage(n,"*")}}catch(t){console.warn("Unable to report Hypothesis error",t)}}function Dt(t){Mt=t}class Ht{constructor(t){this._hypothesisAppsOrigin=t,this._emitter=new Ot,this._sentChannels=new WeakMap,this._sidebarHostChannel=new MessageChannel,this._listeners=new At,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"}],this._listen()}_listen(){const t="Handling port request",e=new Set,n=n=>{e.has(n)||(e.add(n),Ft(new Error(n),t))};var o,i;this._listeners.add(window,"message",(o=t=>{const{data:e,origin:o,source:i}=t;if(!kt(e)||"request"!==e.type)return;const{frame1:r,frame2:s}=e,a=`${r}-${s}`;if(!function(t){
|
|
39
39
|
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]),"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 Ft(t,i),t}}))}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:o}){return("*"===e||o===e)&&Rt(n,t)}on(t,e){this._emitter.on(t,e)}destroy(){this._listeners.removeAll()}}class Bt{
|
|
40
|
-
constructor(){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new At,this._pendingCalls=[]}on(t,e){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(t,e)}connect(t){this._port=t,this._listeners.add(t,"message",(t=>this._handle(t))),t.start();for(let[t,e]of this._pendingCalls)this.call(t,...e);this._pendingCalls=[]}
|
|
41
|
-
const e=this._parseMessage(t),n=this._port;if(e&&n)if("method"in e){const t=this._methods.get(e.method);if(!t)return;const o=(...t)=>{const o={arguments:t,protocol:"frame-rpc",response:e.sequence,version:"1.0.0"};n.postMessage(o)};t(...e.arguments,o)}else if("response"in e){const t=this._callbacks.get(e.response);this._callbacks.delete(e.response),t&&t(...e.arguments)}}}function Vt(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Ut(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={}}Vt(e,i)}return e}function qt(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function Wt(t,e,n){
|
|
42
|
-
;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 $t(t){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=qt(e.ignoreOtherConfiguration)?{}:Ut(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 Wt(t,"hypothesis-client","javascript")},get group(){return n.group||function(){
|
|
43
|
-
return Wt(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(){return Wt(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 jt(t,e){return t.hostPageSetting(e)}const zt={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:jt},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:jt},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{
|
|
44
|
-
usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:qt,getValue:jt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},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:jt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:jt}};function Xt(t="annotator",e=window){const n=$t(e),o={};let i=function(t){const e={
|
|
45
|
-
sidebar:["appType","annotations","branding","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"]};switch(t){case"annotator":return e.annotator;case"sidebar":return e.sidebar;case"notebook":return e.notebook;case"all":return[...e.annotator,...e.sidebar,...e.notebook];default:throw new Error(`Invalid application context used: "${t}"`)}}(t);return i.forEach((t=>{const i=zt[t],r=void 0!==i.defaultValue,s=!((a=Wt(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}function Yt(t){const e=t.toString(16);return 1===e.length?"0"+e:e}
|
|
46
|
-
;return window.crypto.getRandomValues(e),Array.from(e).map(Yt).join("")}const
|
|
47
|
-
onClick:o,title:i?`${n} (${i})`:n,children:["number"==typeof t&&mt("span",{className:"hyp-u-bg-color--grey-7 AdderToolbar__badge",children:t}),mt("span",{className:"LabeledIconButton__label",children:n})]})}function te({arrowDirection:t,isVisible:e,onCommand:n,annotationCount:o=0}){const i=e?"a":null,r=e?"h":null,s=e?"s":null;return Jt(e?"Escape":null,(()=>n("hide"))),mt("div",{className:
|
|
48
|
-
"AdderToolbar__arrow--down":"down"===t,"AdderToolbar__arrow--up":"up"===t})})]})}const ee=(t=window)=>t.matchMedia("(pointer: coarse)").matches;function ne(t){const e=t.attachShadow({mode:"open"});!function(t){var e;const n=null===(e=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]'))||void 0===e?void 0:e.href;if(!n)return;const o=document.createElement("link");o.rel="stylesheet",o.href=n,t.appendChild(o)}(e);const n=window.applyFocusVisiblePolyfill;var o;return n&&n(e),(o=e).addEventListener("mouseup",(t=>t.stopPropagation())),o.addEventListener("mousedown",(t=>t.stopPropagation())),o.addEventListener("touchstart",(t=>t.stopPropagation()),{passive:!0}),e}function oe(t){return t.toString()+"px"}class ie{constructor(t,e){this._outerContainer=document.createElement("hypothesis-adder"),t.appendChild(this._outerContainer),this._shadowRoot=ne(this._outerContainer),Object.assign(this._outerContainer.style,{position:"absolute",top:0,
|
|
49
|
-
this._width=()=>this._shadowRoot.firstChild.getBoundingClientRect().width,this._height=()=>this._shadowRoot.firstChild.getBoundingClientRect().height,this._isVisible=!1,this._arrowDirection="up",this._onAnnotate=e.onAnnotate,this._onHighlight=e.onHighlight,this._onShowAnnotations=e.onShowAnnotations,this.annotationsForSelection=[],this._render()}hide(){this._isVisible=!1,this._render(),Object.assign(this._outerContainer.style,{top:0,left:0})}destroy(){L(null,this._shadowRoot),this._outerContainer.remove()}show(t,e){const{left:n,top:o,arrowDirection:i}=this._calculateTarget(t,e);this._showAt(n,o),this._isVisible=!0,this._arrowDirection=2===i?"up":"down",this._render()}_calculateTarget(t,e){let n,o,i;n=e&&!ee()?1:2;const r=Math.min(20,t.width),s=this._width(),a=ee()?10:0,l=this._height();return i=e?t.left-s/2+r:t.left+t.width-s/2-r,t.top-l<0&&1===n?n=2:t.top+l>this._view.innerHeight&&(n=1),o=2===n?t.top+t.height+10+a:t.top-l-10,i=Math.max(i,0),
|
|
50
|
-
o=Math.min(o,this._view.innerHeight-l),{top:o,left:i,arrowDirection:n}}_findZindex(t,e){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),o=this._height(),i=[...new Set([...document.elementsFromPoint(t,e),...document.elementsFromPoint(t,e+o),...document.elementsFromPoint(t+n/2,e+o/2),...document.elementsFromPoint(t+n,e),...document.elementsFromPoint(t+n,e+o)])].map((t=>+getComputedStyle(t).zIndex)).filter(Number.isInteger);return i.push(0),Math.max(...i)+1}_showAt(t,e){const n=function(t){let e=t.parentElement;for(;e.parentElement&&"static"===getComputedStyle(e).position;)e=e.parentElement;return e}(this._outerContainer).getBoundingClientRect(),o=this._findZindex(t,e);Object.assign(this._outerContainer.style,{left:oe(t-n.left),top:oe(e-n.top),zIndex:o})}_render(){L(mt(te,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":
|
|
51
|
-
this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length}),this._shadowRoot)}}function re(t){switch(t.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return t.textContent.length;default:return 0}}function se(t){let e=t.previousSibling,n=0;for(;e;)n+=re(e),e=e.previousSibling;return n}function ae(t,...e){let n=e.shift();const o=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),i=[];let r,s=o.nextNode(),a=0;for(;void 0!==n&&s;)r=s,a+r.data.length>n?(i.push({node:r,offset:n-a}),n=e.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=e.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}class le{constructor(t,e){if(e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){
|
|
52
|
-
;for(;e!==t;)n+=se(e),e=e.parentElement;return new le(e,n)}resolve(t={}){try{return ae(this.element,this.offset)[0]}catch(e){if(0===this.offset&&void 0!==t.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=1===t.direction,i=o?n.nextNode():n.previousNode();if(!i)throw e;return{node:i,offset:o?0:i.data.length}}throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return le.fromPoint(t,e);case Node.ELEMENT_NODE:return new le(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const n=se(t)+e;return new le(t.parentElement,n)}case Node.ELEMENT_NODE:{
|
|
53
|
-
default:throw new Error("Point is not in an element or text node")}}}class ce{constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new ce(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=ae(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:1}),e=this.end.resolve({direction:2}));const n=new Range;return n.setStart(t.node,t.offset),n.setEnd(e.node,e.offset),n}static fromRange(t){const e=le.fromPoint(t.startContainer,t.startOffset),n=le.fromPoint(t.endContainer,t.endOffset);return new ce(e,n)}static fromOffsets(t,e,n){return new ce(new le(t,e),new le(t,n))}}function he(t){return!!t.parentElement&&null!==t.parentElement.closest(".annotator-placeholder")}function ue(t){
|
|
54
|
-
;const i=null!==(n=null===(o=e.nodeValue)||void 0===o?void 0:o.length)&&void 0!==n?n:e.childNodes.length;return t.comparePoint(e,0)<=0&&t.comparePoint(e,i)>=0}catch(t){return!1}}function fe(t,e){const n=t.commonAncestorContainer,o=n.ownerDocument.createNodeIterator(n,NodeFilter.SHOW_ALL);let i;for(;i=o.nextNode();)de(t,i)&&e(i)}function pe(t){if(t.isCollapsed)return null;const e=function(t){const e=/^\s*$/,n=[];fe(t,(t=>{t.nodeType!==Node.TEXT_NODE||t.textContent.match(e)||n.push(t)}));let o=[];return n.forEach((e=>{const n=e.ownerDocument.createRange();if(n.selectNodeContents(e),e===t.startContainer&&n.setStart(e,t.startOffset),e===t.endContainer&&n.setEnd(e,t.endOffset),n.collapsed)return;const i=Array.from(n.getClientRects());n.detach(),o=o.concat(i)})),o}(t.getRangeAt(0));return 0===e.length?null:ue(t)?e[0]:e[e.length-1]}function ge(t,e="hypothesis-highlight"){
|
|
55
|
-
;const n=[],o=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT);let i;for(;i=o.nextNode();){if(!de(t,i))continue;let e=i;e===t.startContainer&&t.startOffset>0?e.splitText(t.startOffset):(e===t.endContainer&&t.endOffset<e.data.length&&e.splitText(t.endOffset),n.push(e))}return n}(t),o=n.length>0&&he(n[0]);let i=[],r=null,s=null;n.forEach((t=>{r&&r.nextSibling===t?s.push(t):(s=[t],i.push(s)),r=t}));const a=/^\s*$/;i=i.filter((t=>t.some((t=>!a.test(t.nodeValue)))));const l=[];return i.forEach((t=>{const n=document.createElement("hypothesis-highlight");n.className=e,t[0].parentNode.replaceChild(n,t[0]),t.forEach((t=>n.appendChild(t))),l.push(n)})),o||function(t){if(0===t.length)return;const e=function(t){const e=t.closest(".page");return e&&e.querySelector(".canvasWrapper > canvas")||null}(t[0]);if(!e||!e.parentElement)return
|
|
56
|
-
n=document.createElementNS("http://www.w3.org/2000/svg","svg"),n.setAttribute("class","hypothesis-highlight-layer"),e.parentElement.appendChild(n),e.parentElement.style.position="relative";const t=n.style;t.position="absolute",t.left="0",t.top="0",t.width="100%",t.height="100%",o?t.mixBlendMode="multiply":t.opacity="0.3"}const i=e.getBoundingClientRect(),r=t.map((t=>{const e=t.getBoundingClientRect(),n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("x",(e.left-i.left).toString()),n.setAttribute("y",(e.top-i.top).toString()),n.setAttribute("width",e.width.toString()),n.setAttribute("height",e.height.toString()),o?n.setAttribute("class","hypothesis-svg-highlight"):n.setAttribute("class","hypothesis-svg-highlight is-opaque"),t.classList.add("is-transparent"),t.svgHighlight=n,n}));n.append(...r)}(l),l}function me(t,e){const n=t.parentNode
|
|
57
|
-
e.svgHighlight&&e.svgHighlight.remove()}}function ve(t,e){t.forEach((t=>{if(t.svgHighlight){if(t.svgHighlight.classList.toggle("is-focused",e),e){t.svgHighlight.parentNode.append(t.svgHighlight)}}else t.classList.toggle("hypothesis-highlight-focused",e)}))}function ye(t){const e=t.map((t=>t.getBoundingClientRect()));return e.reduce(((t,e)=>({top:Math.min(t.top,e.top),left:Math.min(t.left,e.left),bottom:Math.max(t.bottom,e.bottom),right:Math.max(t.right,e.right)})))}class we{constructor({contentContainer:t,hostRPC:e}){this._hostRPC=e,this._updatePending=!1,this._anchors=[],this._listeners=new At,this._listeners.add(window,"resize",(()=>this.update())),this._listeners.add(window,"scroll",(()=>this.update())),this._listeners.add(t,"scroll",(()=>this.update()))}destroy(){this._listeners.removeAll()}update(t){t&&(this._anchors=t),this._updatePending||(this._updatePending=!0,
|
|
58
|
-
;const{top:o,bottom:i}=ye(n);o>=i||e.push({tag:t.$tag,top:o,bottom:i})})),e.sort(((t,e)=>t.top-e.top)),e}(this._anchors);this._hostRPC.call("anchorsChanged",t),this._updatePending=!1})))}}var be=/^\s+|\s+$/g,Ce=/^[-+]0x[0-9a-f]+$/i,Ee=/^0b[01]+$/i,Se=/^0o[0-7]+$/i,xe=parseInt,Te="object"==typeof t&&t&&t.Object===Object&&t,Ae="object"==typeof self&&self&&self.Object===Object&&self,ke=Te||Ae||Function("return this")(),Re=Object.prototype.toString,Ne=Math.max,Pe=Math.min,Le=function(){return ke.Date.now()};function Oe(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Me(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Re.call(t)}(t))return NaN;if(Oe(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Oe(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t
|
|
59
|
-
var o,i,r,s,a,l,c=0,h=!1,u=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var n=o,r=i;return o=i=void 0,c=e,s=t.apply(r,n)}function p(t){return c=t,a=setTimeout(m,e),h?f(t):s}function g(t){var n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=r}function m(){var t=Le();if(g(t))return _(t);a=setTimeout(m,function(t){var n=e-(t-l);return u?Pe(n,r-(t-c)):n}(t))}function _(t){return a=void 0,d&&o?f(t):(o=i=void 0,s)}function v(){var t=Le(),n=g(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return p(l);if(u)return a=setTimeout(m,e),f(l)}return void 0===a&&(a=setTimeout(m,e)),s}return e=Me(e)||0,Oe(n)&&(h=!!n.leading,r=(u="maxWait"in n)?Ne(Me(n.maxWait)||0,e):r,d="trailing"in n?!!n.trailing:d),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},v.flush=function(){return void 0===a?s:_(Le())},v};class Fe{constructor(t,e,n){this._element=t,
|
|
60
|
-
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 De(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
|
-
;"about:blank"===i.href&&t.hasAttribute("src")&&"about:blank"!==t.src?t.addEventListener("load",(()=>{e()})):"loading"!==o?e():n.addEventListener("DOMContentLoaded",(()=>e()))}))}class He{constructor(t,e){this._config=e,this._frameObserver=new Fe(t,(t=>this.injectClient(t)),(()=>{}))}destroy(){this._frameObserver.disconnect()}async injectClient(t){if("__hypothesis"in t.contentWindow)return;await De(t);const{assetRoot:e,notebookAppUrl:n,sidebarAppUrl:o}=Ut(document),i=
|
|
62
|
-
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,g=u,m=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*g+a*g,i=h.top+e.pageYOffset-e.innerHeight*m+l*m,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*g-e.clientWidth*g,i=v+l*m-e.clientHeight*m,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
|
-
;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.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
|
-
"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
|
|
66
|
-
;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 g=0;for(let t=0;t<=h;t+=1)g=Ye(s,p,t,g),u[t]+=g;if(u[h]-g<=n&&h<r&&(1&p[h+1]||g<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-g+Ye(s,p,h,g)}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
|
|
67
|
-
|
|
40
|
+
constructor(){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new At,this._pendingCalls=[]}on(t,e){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(t,e)}connect(t){this._port=t,this._listeners.add(t,"message",(t=>this._handle(t))),t.start();for(let[t,e]of this._pendingCalls)this.call(t,...e);this._pendingCalls=[]}disconnect(){const t=this._port;return this._port=null,this._listeners.removeAll(),t}destroy(){const t=this.disconnect();null==t||t.close(),this._destroyed=!0}call(t,...e){if(this._port||this._pendingCalls.push([t,e]),!this._port||this._destroyed)return;const n=this._sequence++,o=e[e.length-1];"function"==typeof o&&(this._callbacks.set(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}){
|
|
41
|
+
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),n=this._port;if(e&&n)if("method"in e){const t=this._methods.get(e.method);if(!t)return;const o=(...t)=>{const o={arguments:t,protocol:"frame-rpc",response:e.sequence,version:"1.0.0"};n.postMessage(o)};t(...e.arguments,o)}else if("response"in e){const t=this._callbacks.get(e.response);this._callbacks.delete(e.response),t&&t(...e.arguments)}}}function Vt(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Ut(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={}}Vt(e,i)}return e}function qt(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function Wt(t,e,n){
|
|
42
|
+
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 $t(t){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=qt(e.ignoreOtherConfiguration)?{}:Ut(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 Wt(t,"hypothesis-client","javascript")},get group(){return n.group||function(){
|
|
43
|
+
const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return Wt(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(){return Wt(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 jt(t,e){return t.hostPageSetting(e)}const zt={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:jt},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:jt},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{
|
|
44
|
+
allowInBrowserExt:!1,defaultValue:null,getValue:jt},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:qt,getValue:jt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:jt},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:jt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:jt}};function Xt(t="annotator",e=window){const n=$t(e),o={};let i=function(t){const e={
|
|
45
|
+
annotator:["clientUrl","subFrameIdentifier"],sidebar:["appType","annotations","branding","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"]};switch(t){case"annotator":return e.annotator;case"sidebar":return e.sidebar;case"notebook":return e.notebook;case"all":return[...e.annotator,...e.sidebar,...e.notebook];default:throw new Error(`Invalid application context used: "${t}"`)}}(t);return i.forEach((t=>{const i=zt[t],r=void 0!==i.defaultValue,s=!((a=Wt(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}function Yt(t){const e=t.toString(16);return 1===e.length?"0"+e:e}
|
|
46
|
+
function Zt(t){const e=new Uint8Array(t/2);return window.crypto.getRandomValues(e),Array.from(e).map(Yt).join("")}const Gt={alt:1,ctrl:2,meta:4,shift:8};function Kt(t,e,{rootElement:n=document.body}={}){const o=n=>{(function(t,e){const n=e.split("+").map((t=>t.toLowerCase()));let o=0,i=null;for(let t of n){const e=Gt[t];if(e)o|=e;else{if(null!==i)throw new Error("Multiple non-modifier keys specified");i=t}}if(!i)throw new Error(`Invalid shortcut: ${e}`);return((t.ctrlKey?Gt.ctrl:0)|(t.metaKey?Gt.meta:0)|(t.altKey?Gt.alt:0)|(t.shiftKey?Gt.shift:0))===o&&function(t){const e={Left:"ArrowLeft",Up:"ArrowUp",Down:"ArrowDown",Right:"ArrowRight",Spacebar:" ",Del:"Delete"};return e[t]?e[t]:t}(t.key).toLowerCase()===i})(n,t)&&e(n)};return n.addEventListener("keydown",o),()=>n.removeEventListener("keydown",o)}function Jt(t,e,{rootElement:n=document.body}={}){st((()=>{if(t)return Kt(t,e,{rootElement:n})}),[t,e,n])}function Qt({badgeCount:t,icon:e,label:n,onClick:o,shortcut:i}){Jt(i,o);return mt(Et,{
|
|
47
|
+
classes:"LabeledIconButton AdderToolbar__button",icon:e,onClick:o,title:i?`${n} (${i})`:n,children:["number"==typeof t&&mt("span",{className:"hyp-u-bg-color--grey-7 AdderToolbar__badge",children:t}),mt("span",{className:"LabeledIconButton__label",children:n})]})}function te({arrowDirection:t,isVisible:e,onCommand:n,annotationCount:o=0}){const i=e?"a":null,r=e?"h":null,s=e?"s":null;return Jt(e?"Escape":null,(()=>n("hide"))),mt("div",{className:G("hyp-u-border hyp-u-bg-color--white","AdderToolbar",{"AdderToolbar--down":"up"===t,"AdderToolbar--up":"down"===t,"is-active":e}),style:{visibility:e?"visible":"hidden"},children:[mt("div",{className:"hyp-u-layout-row AdderToolbar__actions",children:[mt(Qt,{icon:"annotate",onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),mt(Qt,{icon:"highlight",onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),o>0&&mt("div",{className:"hyp-u-margin--2 AdderToolbar__separator"}),o>0&&mt(Qt,{badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]}),mt(xt,{
|
|
48
|
+
name:"pointer",classes:G("AdderToolbar__arrow",{"AdderToolbar__arrow--down":"down"===t,"AdderToolbar__arrow--up":"up"===t})})]})}const ee=(t=window)=>t.matchMedia("(pointer: coarse)").matches;function ne(t){const e=t.attachShadow({mode:"open"});!function(t){var e;const n=null===(e=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]'))||void 0===e?void 0:e.href;if(!n)return;const o=document.createElement("link");o.rel="stylesheet",o.href=n,t.appendChild(o)}(e);const n=window.applyFocusVisiblePolyfill;var o;return n&&n(e),(o=e).addEventListener("mouseup",(t=>t.stopPropagation())),o.addEventListener("mousedown",(t=>t.stopPropagation())),o.addEventListener("touchstart",(t=>t.stopPropagation()),{passive:!0}),e}function oe(t){return t.toString()+"px"}class ie{constructor(t,e){this._outerContainer=document.createElement("hypothesis-adder"),t.appendChild(this._outerContainer),this._shadowRoot=ne(this._outerContainer),Object.assign(this._outerContainer.style,{position:"absolute",top:0,
|
|
49
|
+
left:0}),this._view=t.ownerDocument.defaultView,this._width=()=>this._shadowRoot.firstChild.getBoundingClientRect().width,this._height=()=>this._shadowRoot.firstChild.getBoundingClientRect().height,this._isVisible=!1,this._arrowDirection="up",this._onAnnotate=e.onAnnotate,this._onHighlight=e.onHighlight,this._onShowAnnotations=e.onShowAnnotations,this.annotationsForSelection=[],this._render()}hide(){this._isVisible=!1,this._render(),Object.assign(this._outerContainer.style,{top:0,left:0})}destroy(){L(null,this._shadowRoot),this._outerContainer.remove()}show(t,e){const{left:n,top:o,arrowDirection:i}=this._calculateTarget(t,e);this._showAt(n,o),this._isVisible=!0,this._arrowDirection=2===i?"up":"down",this._render()}_calculateTarget(t,e){let n,o,i;n=e&&!ee()?1:2;const r=Math.min(20,t.width),s=this._width(),a=ee()?10:0,l=this._height();return i=e?t.left-s/2+r:t.left+t.width-s/2-r,t.top-l<0&&1===n?n=2:t.top+l>this._view.innerHeight&&(n=1),o=2===n?t.top+t.height+10+a:t.top-l-10,i=Math.max(i,0),
|
|
50
|
+
i=Math.min(i,this._view.innerWidth-s),o=Math.max(o,0),o=Math.min(o,this._view.innerHeight-l),{top:o,left:i,arrowDirection:n}}_findZindex(t,e){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),o=this._height(),i=[...new Set([...document.elementsFromPoint(t,e),...document.elementsFromPoint(t,e+o),...document.elementsFromPoint(t+n/2,e+o/2),...document.elementsFromPoint(t+n,e),...document.elementsFromPoint(t+n,e+o)])].map((t=>+getComputedStyle(t).zIndex)).filter(Number.isInteger);return i.push(0),Math.max(...i)+1}_showAt(t,e){const n=function(t){let e=t.parentElement;for(;e.parentElement&&"static"===getComputedStyle(e).position;)e=e.parentElement;return e}(this._outerContainer).getBoundingClientRect(),o=this._findZindex(t,e);Object.assign(this._outerContainer.style,{left:oe(t-n.left),top:oe(e-n.top),zIndex:o})}_render(){L(mt(te,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":
|
|
51
|
+
this._onHighlight(),this.hide();break;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length}),this._shadowRoot)}}function re(t){switch(t.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return t.textContent.length;default:return 0}}function se(t){let e=t.previousSibling,n=0;for(;e;)n+=re(e),e=e.previousSibling;return n}function ae(t,...e){let n=e.shift();const o=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),i=[];let r,s=o.nextNode(),a=0;for(;void 0!==n&&s;)r=s,a+r.data.length>n?(i.push({node:r,offset:n-a}),n=e.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=e.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}class le{constructor(t,e){if(e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){
|
|
52
|
+
if(!t.contains(this.element))throw new Error("Parent is not an ancestor of current element");let e=this.element,n=this.offset;for(;e!==t;)n+=se(e),e=e.parentElement;return new le(e,n)}resolve(t={}){try{return ae(this.element,this.offset)[0]}catch(e){if(0===this.offset&&void 0!==t.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=1===t.direction,i=o?n.nextNode():n.previousNode();if(!i)throw e;return{node:i,offset:o?0:i.data.length}}throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return le.fromPoint(t,e);case Node.ELEMENT_NODE:return new le(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const n=se(t)+e;return new le(t.parentElement,n)}case Node.ELEMENT_NODE:{
|
|
53
|
+
if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let o=0;o<e;o++)n+=re(t.childNodes[o]);return new le(t,n)}default:throw new Error("Point is not in an element or text node")}}}class ce{constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new ce(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=ae(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:1}),e=this.end.resolve({direction:2}));const n=new Range;return n.setStart(t.node,t.offset),n.setEnd(e.node,e.offset),n}static fromRange(t){const e=le.fromPoint(t.startContainer,t.startOffset),n=le.fromPoint(t.endContainer,t.endOffset);return new ce(e,n)}static fromOffsets(t,e,n){return new ce(new le(t,e),new le(t,n))}}function he(t){return!!t.parentElement&&null!==t.parentElement.closest(".annotator-placeholder")}function ue(t){
|
|
54
|
+
if(t.focusNode===t.anchorNode)return t.focusOffset<t.anchorOffset;return t.getRangeAt(0).startContainer===t.focusNode}function de(t,e){try{var n,o;const i=null!==(n=null===(o=e.nodeValue)||void 0===o?void 0:o.length)&&void 0!==n?n:e.childNodes.length;return t.comparePoint(e,0)<=0&&t.comparePoint(e,i)>=0}catch(t){return!1}}function fe(t,e){const n=t.commonAncestorContainer,o=n.ownerDocument.createNodeIterator(n,NodeFilter.SHOW_ALL);let i;for(;i=o.nextNode();)de(t,i)&&e(i)}function pe(t){if(t.isCollapsed)return null;const e=function(t){const e=/^\s*$/,n=[];fe(t,(t=>{t.nodeType!==Node.TEXT_NODE||t.textContent.match(e)||n.push(t)}));let o=[];return n.forEach((e=>{const n=e.ownerDocument.createRange();if(n.selectNodeContents(e),e===t.startContainer&&n.setStart(e,t.startOffset),e===t.endContainer&&n.setEnd(e,t.endOffset),n.collapsed)return;const i=Array.from(n.getClientRects());n.detach(),o=o.concat(i)})),o}(t.getRangeAt(0));return 0===e.length?null:ue(t)?e[0]:e[e.length-1]}function ge(t,e="hypothesis-highlight"){
|
|
55
|
+
const n=function(t){if(t.collapsed)return[];let e=t.commonAncestorContainer;if(e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentElement),!e)return[];const n=[],o=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT);let i;for(;i=o.nextNode();){if(!de(t,i))continue;let e=i;e===t.startContainer&&t.startOffset>0?e.splitText(t.startOffset):(e===t.endContainer&&t.endOffset<e.data.length&&e.splitText(t.endOffset),n.push(e))}return n}(t),o=n.length>0&&he(n[0]);let i=[],r=null,s=null;n.forEach((t=>{r&&r.nextSibling===t?s.push(t):(s=[t],i.push(s)),r=t}));const a=/^\s*$/;i=i.filter((t=>t.some((t=>!a.test(t.nodeValue)))));const l=[];return i.forEach((t=>{const n=document.createElement("hypothesis-highlight");n.className=e,t[0].parentNode.replaceChild(n,t[0]),t.forEach((t=>n.appendChild(t))),l.push(n)})),o||function(t){if(0===t.length)return;const e=function(t){const e=t.closest(".page");return e&&e.querySelector(".canvasWrapper > canvas")||null}(t[0]);if(!e||!e.parentElement)return
|
|
56
|
+
;let n=e.parentElement.querySelector(".hypothesis-highlight-layer");const o=CSS.supports("mix-blend-mode","multiply");if(!n){n=document.createElementNS("http://www.w3.org/2000/svg","svg"),n.setAttribute("class","hypothesis-highlight-layer"),e.parentElement.appendChild(n),e.parentElement.style.position="relative";const t=n.style;t.position="absolute",t.left="0",t.top="0",t.width="100%",t.height="100%",o?t.mixBlendMode="multiply":t.opacity="0.3"}const i=e.getBoundingClientRect(),r=t.map((t=>{const e=t.getBoundingClientRect(),n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("x",(e.left-i.left).toString()),n.setAttribute("y",(e.top-i.top).toString()),n.setAttribute("width",e.width.toString()),n.setAttribute("height",e.height.toString()),o?n.setAttribute("class","hypothesis-svg-highlight"):n.setAttribute("class","hypothesis-svg-highlight is-opaque"),t.classList.add("is-transparent"),t.svgHighlight=n,n}));n.append(...r)}(l),l}function me(t,e){const n=t.parentNode
|
|
57
|
+
;e.forEach((e=>n.insertBefore(e,t))),t.remove()}function _e(t){for(let e of t){if(e.parentNode){me(e,Array.from(e.childNodes))}e.svgHighlight&&e.svgHighlight.remove()}}function ve(t,e){t.forEach((t=>{if(t.svgHighlight){if(t.svgHighlight.classList.toggle("is-focused",e),e){t.svgHighlight.parentNode.append(t.svgHighlight)}}else t.classList.toggle("hypothesis-highlight-focused",e)}))}function ye(t){const e=t.map((t=>t.getBoundingClientRect()));return e.reduce(((t,e)=>({top:Math.min(t.top,e.top),left:Math.min(t.left,e.left),bottom:Math.max(t.bottom,e.bottom),right:Math.max(t.right,e.right)})))}class we{constructor({contentContainer:t,hostRPC:e}){this._hostRPC=e,this._updatePending=!1,this._anchors=[],this._listeners=new At,this._listeners.add(window,"resize",(()=>this.update())),this._listeners.add(window,"scroll",(()=>this.update())),this._listeners.add(t,"scroll",(()=>this.update()))}destroy(){this._listeners.removeAll()}update(t){t&&(this._anchors=t),this._updatePending||(this._updatePending=!0,
|
|
58
|
+
requestAnimationFrame((()=>{const t=function(t){const e=[];return t.forEach((({annotation:t,highlights:n})=>{if(null==n||!n.length)return;const{top:o,bottom:i}=ye(n);o>=i||e.push({tag:t.$tag,top:o,bottom:i})})),e.sort(((t,e)=>t.top-e.top)),e}(this._anchors);this._hostRPC.call("anchorsChanged",t),this._updatePending=!1})))}}var be=/^\s+|\s+$/g,Ce=/^[-+]0x[0-9a-f]+$/i,Ee=/^0b[01]+$/i,Se=/^0o[0-7]+$/i,xe=parseInt,Te="object"==typeof t&&t&&t.Object===Object&&t,Ae="object"==typeof self&&self&&self.Object===Object&&self,ke=Te||Ae||Function("return this")(),Re=Object.prototype.toString,Ne=Math.max,Pe=Math.min,Le=function(){return ke.Date.now()};function Oe(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Me(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Re.call(t)}(t))return NaN;if(Oe(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Oe(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t
|
|
59
|
+
;t=t.replace(be,"");var n=Ee.test(t);return n||Se.test(t)?xe(t.slice(2),n?2:8):Ce.test(t)?NaN:+t}var Ie=function(t,e,n){var o,i,r,s,a,l,c=0,h=!1,u=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var n=o,r=i;return o=i=void 0,c=e,s=t.apply(r,n)}function p(t){return c=t,a=setTimeout(m,e),h?f(t):s}function g(t){var n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=r}function m(){var t=Le();if(g(t))return _(t);a=setTimeout(m,function(t){var n=e-(t-l);return u?Pe(n,r-(t-c)):n}(t))}function _(t){return a=void 0,d&&o?f(t):(o=i=void 0,s)}function v(){var t=Le(),n=g(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return p(l);if(u)return a=setTimeout(m,e),f(l)}return void 0===a&&(a=setTimeout(m,e)),s}return e=Me(e)||0,Oe(n)&&(h=!!n.leading,r=(u="maxWait"in n)?Ne(Me(n.maxWait)||0,e):r,d="trailing"in n?!!n.trailing:d),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},v.flush=function(){return void 0===a?s:_(Le())},v};class Fe{constructor(t,e,n){this._element=t,
|
|
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 De(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
|
+
function De(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 He{constructor(t,e){this._config=e,this._frameObserver=new Fe(t,(t=>this.injectClient(t)),(()=>{}))}destroy(){this._frameObserver.disconnect()}async injectClient(t){if("__hypothesis"in t.contentWindow)return;await De(t);const{assetRoot:e,notebookAppUrl:n,sidebarAppUrl:o}=Ut(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
|
+
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,g=u,m=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*g+a*g,i=h.top+e.pageYOffset-e.innerHeight*m+l*m,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*g-e.clientWidth*g,i=v+l*m-e.clientHeight*m,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 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
|
+
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 Ze(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
|
+
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 g=0;for(let t=0;t<=h;t+=1)g=Ye(s,p,t,g),u[t]+=g;if(u[h]-g<=n&&h<r&&(1&p[h+1]||g<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-g+Ye(s,p,h,g)}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 Ge(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:Ze(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,Ze(t,e,n))}function Ke(t,e,n){
|
|
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:Ge(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;){
|
|
68
68
|
if(!o)throw new Error("Node is not a descendant of root");n=tn(o)+"/"+n,o=o.parentNode}return n="/"+n,n=n.replace(/\/$/,""),n}function nn(t,e,n){e=e.toUpperCase();let o=-1;for(let i=0;i<t.children.length;i++){const r=t.children[i];if(r.nodeName.toUpperCase()===e&&(++o,o===n))return r}return null}function on(t,e=document.body){try{return function(t,e){if(null===t.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+\])?)+$/))throw new Error("Expression is not a simple XPath");const n=t.split("/");let o=e;n.shift();for(let t of n){let e,n;const i=t.indexOf("[");if(-1!==i){e=t.slice(0,i);const o=t.slice(i+1,t.indexOf("]"));if(n=parseInt(o)-1,n<0)return null}else e=t,n=0;const r=nn(o,e,n);if(!r)return null;o=r}return o}(t,e)}catch(n){return document.evaluate("."+t,e,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}}class rn{constructor(t,e){this.root=t,this.range=e}static fromRange(t,e){return new rn(t,e)}static fromSelector(t,e){const n=on(e.startContainer,t)
|
|
69
69
|
;if(!n)throw new Error("Failed to resolve startContainer XPath");const o=on(e.endContainer,t);if(!o)throw new Error("Failed to resolve endContainer XPath");const i=le.fromCharOffset(n,e.startOffset),r=le.fromCharOffset(o,e.endOffset),s=new ce(i,r).toRange();return new rn(t,s)}toRange(){return this.range}toSelector(){const t=ce.fromRange(this.range).toRange(),e=ce.fromRange(t),n=en(e.start.element,this.root),o=en(e.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:e.start.offset,endContainer:o,endOffset:e.end.offset}}}class sn{constructor(t,e,n){this.root=t,this.start=e,this.end=n}static fromRange(t,e){const n=ce.fromRange(e).relativeTo(t);return new sn(t,n.start.offset,n.end.offset)}static fromSelector(t,e){return new sn(t,e.start,e.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return ce.fromOffsets(this.root,this.start,this.end).toRange()}}class an{constructor(t,e,n={}){this.root=t,this.exact=e,this.context=n}static fromRange(t,e){
|
|
70
70
|
const n=t.textContent,o=ce.fromRange(e).relativeTo(t),i=o.start.offset,r=o.end.offset;return new an(t,n.slice(i,r),{prefix:n.slice(Math.max(0,i-32),i),suffix:n.slice(r,Math.min(n.length,r+32))})}static fromSelector(t,e){const{prefix:n,suffix:o}=e;return new an(t,e.exact,{prefix:n,suffix:o})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(t={}){return this.toPositionAnchor(t).toRange()}toPositionAnchor(t={}){const e=Qe(this.root.textContent,this.exact,{...this.context,hint:t.hint});if(!e)throw new Error("Quote not found");return new sn(this.root,e.start,e.end)}}async function ln(t,e={}){return t.toRange(e)}function cn(t,e,n={}){let o=null,i=null,r=null;for(let t of e)switch(t.type){case"TextPositionSelector":o=t,n.hint=o.start;break;case"TextQuoteSelector":i=t;break;case"RangeSelector":r=t}const s=t=>{var e;if(null!==(e=i)&&void 0!==e&&e.exact&&t.toString()!==i.exact)throw new Error("quote mismatch");return t}
|
|
@@ -86,23 +86,23 @@ async scrollToAnchor(t){const e=t.annotation,n=Hn(t),o=this._anchorOffset(t);if(
|
|
|
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 At,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=new WeakSet,o=e=>{var n;(null===(n=e.contentDocument)||void 0===n?void 0:n.querySelector("p"))&&t.injectClient(e)},i=e.shadowRoot,r=()=>{const t=i.querySelector("iframe");t&&!n.has(t)&&(n.add(t),o(t),t.addEventListener("load",(()=>{o(t)})))};r(),this._frameObserver=new MutationObserver(r),this._frameObserver.observe(i,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}canAnnotate(){return!1}async anchor(){return new Range}describe(){
|
|
87
87
|
throw new Error("This frame cannot be annotated")}contentContainer(){return document.body}fitSideBySide(){return!1}async getMetadata(){return{title:"",link:[]}}async uri(){return document.location.href}async scrollToAnchor(){}}class jn{constructor(t=document.body){this._htmlIntegration=new fn(t),this._listeners=new At;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()}
|
|
88
88
|
fitSideBySide(){return!1}async getMetadata(){return{title:document.title,link:[]}}async uri(){const t=new URL(document.location.href);return t.search="",t.toString()}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 At,
|
|
89
|
-
this._events=["mousedown","mouseup","selectionchange"];for(let t of this._events)this._listeners.add(e,t,this._eventHandler);o(1)}disconnect(){this._listeners.removeAll(),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 fe(t,(t=>{let i=t;for(;i&&!n.has(i);){n.add(i);const t=e(i);null!=t&&o.add(t),i=i.parentNode}})),[...o]}(window.getSelection().getRangeAt(0),(t=>{var e;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}));return t}function
|
|
89
|
+
this._events=["mousedown","mouseup","selectionchange"];for(let t of this._events)this._listeners.add(e,t,this._eventHandler);o(1)}disconnect(){this._listeners.removeAll(),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 fe(t,(t=>{let i=t;for(;i&&!n.has(i);){n.add(i);const t=e(i);null!=t&&o.add(t),i=i.parentNode}})),[...o]}(window.getSelection().getRangeAt(0),(t=>{var e;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}));return t}function Zn(t){const e=function(t){let e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;const n=[];for(;e;)e.classList.contains("hypothesis-highlight")&&n.push(e),e=e.parentElement;return n}(t).map((t=>t._annotation)).filter((t=>void 0!==t)).map((t=>null==t?void 0:t.$tag));return e}function Gn(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function Kn(){var t
|
|
90
90
|
;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 ie(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>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 Nt({hostFrame:this._hostFrame,source:"guest"}),this._hypothesisInjector=new He(this.element,e),this._integration=zn(this),this._hostRPC=new Bt,this._connectHost(),this._sidebarRPC=new Bt,this._connectSidebar(),this._bucketBarClient=null===this._frameIdentifier?new we({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}):null,this._sideBySideActive=!1,
|
|
91
|
-
this._listeners=new At,this._setupElementEvents(),this._focusedAnnotations=new Set,this._listeners.add(window,"unload",(()=>this.
|
|
92
|
-
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 _connectHost(){this._hostRPC.on("clearSelectionExceptIn",(t=>{this._frameIdentifier!==t&&(this._informHostOnNextSelectionClear=!1,Kn())})),this._hostRPC.on("createAnnotationIn",(t=>{this._frameIdentifier===t&&this.createAnnotation()})),this._hostRPC.on("focusAnnotations",(t=>this._focusAnnotations(t))),this._hostRPC.on("scrollToClosestOffScreenAnchor",((t,e)=>this._scrollToClosestOffScreenAnchor(t,e))),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,e))),this._hostRPC.on("sidebarLayoutChanged",(t=>{null===this._frameIdentifier&&this.fitSideBySide(t)}));const t=await this._portFinder.discover("host");this._hostRPC.connect(t)}async _connectSidebar(){
|
|
93
|
-
this._sidebarRPC.on("focusAnnotations",(t=>this._focusAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=
|
|
94
|
-
_e(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy(),this._sidebarRPC.
|
|
95
|
-
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&&_e(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;(this.anchors=t,e)&&(null===(n=this._bucketBarClient)||void 0===n||n.update(this.anchors))}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];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:"+
|
|
96
|
-
_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,o=0;for(let r of t){var i;if(null===(i=r.highlights)||void 0===i||!i.length)continue;const t=ye(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>o||"down"===e&&t<o)&&(n=r,o=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=ue(e),o=pe(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),
|
|
97
|
-
e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}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.
|
|
98
|
-
t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return o}function eo({config:t,groupId:e}){return mt("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:mt("div",{className:
|
|
99
|
-
onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),mt(eo,{config:e,groupId:s},n)]})})}class oo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=ne(this._outerContainer),L(mt(no,{eventBus:e,config:n}),this.shadowRoot)}destroy(){L(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),o++;else for(o in t)t.hasOwnProperty(o)&&e.call(n,t[o],o,t)}function p(t,n,o){
|
|
100
|
-
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 g=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`."),m=p((function(t,e){return g(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var o,i=e.prototype;(o=t.prototype=Object.create(i)).constructor=t,o._super=i,n&&r(o,n)}function v(t,e){return function(){return t.apply(e,arguments)}}
|
|
101
|
-
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 R(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 N=1;function P(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
|
|
91
|
+
this._listeners=new At,this._setupElementEvents(),this._focusedAnnotations=new Set,this._listeners.add(window,"unload",(()=>this._sendUnloadNotification()))}_setupElementEvents(){const t=t=>{this._sideBySideActive||Zn(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:o}=t,i=Zn(e);if(i.length&&this._highlightsVisible){const t=n||o;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=Zn(t);e.length&&this._highlightsVisible&&this._sidebarRPC.call("focusAnnotations",e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("focusAnnotations",[])})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async injectClient(t){return this._hypothesisInjector.injectClient(t)}
|
|
92
|
+
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 _connectHost(){this._hostRPC.on("clearSelectionExceptIn",(t=>{this._frameIdentifier!==t&&(this._informHostOnNextSelectionClear=!1,Kn())})),this._hostRPC.on("createAnnotationIn",(t=>{this._frameIdentifier===t&&this.createAnnotation()})),this._hostRPC.on("focusAnnotations",(t=>this._focusAnnotations(t))),this._hostRPC.on("scrollToClosestOffScreenAnchor",((t,e)=>this._scrollToClosestOffScreenAnchor(t,e))),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,e))),this._hostRPC.on("sidebarLayoutChanged",(t=>{null===this._frameIdentifier&&this.fitSideBySide(t)}));const t=await this._portFinder.discover("host");this._hostRPC.connect(t)}async _connectSidebar(){
|
|
93
|
+
this._sidebarRPC.on("focusAnnotations",(t=>this._focusAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=Gn(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("setHighlightsVisible",(t=>{this.setHighlightsVisible(t)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t))))),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this.getDocumentInfo().then((t=>this._sidebarRPC.call("documentInfoChanged",t)))}destroy(){var t;this._sendUnloadNotification(),this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),
|
|
94
|
+
null===(t=this._bucketBarClient)||void 0===t||t.destroy(),function(t){_e(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}_sendUnloadNotification(){const t=[],e=this._sidebarRPC.disconnect();e&&t.push(e);const n=this._hostRPC.disconnect();n&&t.push(n),this._hostFrame.postMessage({type:"hypothesisGuestUnloaded"},"*",t)}async anchor(t){const e=t=>{const e=Gn(t);if(!e)return;const n=ge(e);n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&ve(n,!0)};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=ce.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)
|
|
95
|
+
;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&&_e(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;(this.anchors=t,e)&&(null===(n=this._bucketBarClient)||void 0===n||n.update(this.anchors))}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];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){this._focusedAnnotations.clear(),t.forEach((t=>this._focusedAnnotations.add(t)));for(let e of this.anchors)if(e.highlights){
|
|
96
|
+
const n=t.includes(e.annotation.$tag);ve(e.highlights,n)}this._sidebarRPC.call("focusAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,o=0;for(let r of t){var i;if(null===(i=r.highlights)||void 0===i||!i.length)continue;const t=ye(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>o||"down"===e&&t<o)&&(n=r,o=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=ue(e),o=pe(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),
|
|
97
|
+
this._informHostOnNextSelectionClear=!0}selectAnnotations(t,e=!1){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}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.977.0";const i=new URL(window.location.href);if(i.hash="",o.hostURL=i.toString(),(null===(n=o.services)||void 0===n?void 0:n.length)>0){const t=o.services[0]
|
|
98
|
+
;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 mt("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:mt("div",{className:G("NotebookModal__outer",{"is-hidden":i}),children:mt("div",{className:"NotebookModal__inner",children:[mt("div",{
|
|
99
|
+
className:"NotebookModal__close-button-container",children:mt(Ct,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),mt(eo,{config:e,groupId:s},n)]})})}class oo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=ne(this._outerContainer),L(mt(no,{eventBus:e,config:n}),this.shadowRoot)}destroy(){L(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),o++;else for(o in t)t.hasOwnProperty(o)&&e.call(n,t[o],o,t)}function p(t,n,o){
|
|
100
|
+
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 g=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`."),m=p((function(t,e){return g(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var o,i=e.prototype;(o=t.prototype=Object.create(i)).constructor=t,o._super=i,n&&r(o,n)}function v(t,e){return function(){return t.apply(e,arguments)}}
|
|
101
|
+
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 R(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 N=1;function P(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
|
|
102
102
|
var L="ontouchstart"in e,O=R(e,"PointerEvent")!==i,M=L&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",F="mouse",D=24,H=["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||{};1!==e.eventType&&4!==r.eventType||(i=t.prevDelta={x:r.deltaX||0,y:r.deltaY||0},
|
|
103
103
|
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 g=t.element;E(e.srcEvent.target,g)&&(g=e.srcEvent.target);e.target=g}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}
|
|
104
104
|
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=H);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=H);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(P(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),
|
|
105
|
-
this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(P(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4},
|
|
105
|
+
this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(P(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4},Z="mousedown",G="mousemove mouseup";function K(){this.evEl=Z,this.evWin=G,this.pressed=!1,V.apply(this,arguments)}_(K,V,{handler:function(t){var e=Y[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:F,srcEvent:t}))}});var J={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:I,3:"pen",4:F,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){
|
|
106
106
|
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"
|
|
107
107
|
;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={
|
|
108
108
|
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 gt(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==F;if(!(i&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(o)ft.call(this,e,n);else if(i&>.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var mt=R(a.style,"touchAction"),_t=mt!==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){
|
|
@@ -117,18 +117,18 @@ this.manager.emit(this.options.event,this._input))}}),Ht.VERSION="2.0.7",Ht.defa
|
|
|
117
117
|
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){
|
|
118
118
|
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(Ht,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Tt,
|
|
119
119
|
DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:D,DIRECTION_ALL:30,Manager:Bt,Input:V,TouchAction:xt,TouchInput:ht,MouseInput:K,PointerEventInput:nt,TouchMouseInput:dt,SingleTouchInput:st,Recognizer:At,AttrRecognizer:Pt,Tap:Dt,Pan:Lt,Swipe:Ft,Pinch:Ot,Rotate:It,Press:Mt,on:b,off:C,each:f,merge:m,extend:g,assign:r,inherit:_,bindFn:v,prefixed:R}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Ht,t.exports?t.exports=Ht:e.Hammer=Ht}(window,document)}(io);var ro=io.exports;function so({bucket:t,onFocusAnnotations:e,onSelectAnnotations:n}){const o=`Select nearby annotations (${t.tags.size})`;function i(n){e(n?[...t.tags]:[])}return mt("button",{className:"Buckets__button Buckets__button--left",onClick:e=>function(e){n([...t.tags],e.metaKey||e.ctrlKey)}(e),onMouseMove:()=>i(!0),onMouseOut:()=>i(!1),onBlur:()=>i(!1),title:o,"aria-label":o,children:t.tags.size})}function ao({bucket:t,direction:e,onScrollToClosestOffScreenAnchor:n}){
|
|
120
|
-
const o=`Go ${e} to next annotations (${t.tags.size})`;return mt("button",{className:
|
|
120
|
+
const o=`Go ${e} to next annotations (${t.tags.size})`;return mt("button",{className:G("Buckets__button",`Buckets__button--${e}`),onClick:()=>n([...t.tags],e),title:o,"aria-label":o,children:t.tags.size})}function lo({above:t,below:e,buckets:n,onFocusAnnotations:o,onScrollToClosestOffScreenAnchor:i,onSelectAnnotations:r}){const s=t.tags.size>0,a=e.tags.size>0;return mt("ul",{className:"Buckets__list",children:[s&&mt("li",{className:"Buckets__bucket",style:{top:t.position},children:mt(ao,{bucket:t,direction:"up",onScrollToClosestOffScreenAnchor:i})}),n.map(((t,e)=>mt("li",{className:"Buckets__bucket",style:{top:t.position},children:mt(so,{bucket:t,onFocusAnnotations:o,onSelectAnnotations:r})},e))),a&&mt("li",{className:"Buckets__bucket",style:{top:e.position},children:mt(ao,{bucket:e,direction:"down",onScrollToClosestOffScreenAnchor:i})})]})}class co{constructor(t,{onFocusAnnotations:e,onScrollToClosestOffScreenAnchor:n,onSelectAnnotations:o}){this._bucketsContainer=document.createElement("div"),
|
|
121
121
|
t.appendChild(this._bucketsContainer),this._onFocusAnnotations=e,this._onScrollToClosestOffScreenAnchor=n,this._onSelectAnnotations=o,this.update([])}destroy(){L(null,this._bucketsContainer),this._bucketsContainer.remove()}update(t){const e=function(t){const e=new Set,n=new Set,o=[];let i=null;function r({bottom:t,tag:e,top:n}){return{bottom:t,position:n+(t-n)/2,tags:new Set([e]),top:n}}return t.forEach((t=>{if(t.top<137)return void e.add(t.tag);if(t.top>window.innerHeight-22)return void n.add(t.tag);if(!i)return void(i=r(t));const s=t.top>i.top&&t.bottom<i.bottom;if(t.top-i.bottom>60&&!s)o.push(i),i=r(t);else{const e=t.bottom>i.bottom?t.bottom:i.bottom,n=e-i.top;i.tags.add(t.tag),i.bottom=e,i.position=i.top+n/2}})),i&&o.push(i),{above:{tags:e,position:137},below:{tags:n,position:window.innerHeight-22},buckets:o}}(t);L(mt(lo,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:t=>this._onFocusAnnotations(t),onScrollToClosestOffScreenAnchor:(t,e)=>this._onScrollToClosestOffScreenAnchor(t,e),
|
|
122
122
|
onSelectAnnotations:(t,e)=>this._onSelectAnnotations(t,e)}),this._bucketsContainer)}}let ho={};const uo=t=>{ho=t||{}},fo=function(t){t.on("featureFlagsUpdated",uo)};function po({buttonRef:t,expanded:e,className:n="Toolbar__button",label:o,icon:i,onClick:r,selected:s=!1}){return mt("button",{className:n,"aria-label":o,"aria-expanded":e,"aria-pressed":s,onClick:r,ref:t,title:o,children:mt(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 mt("div",{className:"Toolbar",children:[l&&n&&mt(po,{className:"Toolbar__sidebar-close",label:"Close annotation sidebar",icon:"cancel",onClick:t}),!l&&mt(po,{className:"Toolbar__sidebar-toggle",buttonRef:a,label:"Annotation sidebar",icon:n?"caret-right":"caret-left",expanded:n,onClick:s}),!l&&mt("div",{className:"Toolbar__buttonbar",children:[mt(po,{label:"Show highlights",icon:i?"show":"hide",selected:i,onClick:r}),mt(po,{
|
|
123
123
|
label:"note"===o?"New page note":"New annotation",icon:"note"===o?"note":"annotate",onClick:e})]})]})}class mo{constructor(t,e){const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:i}=e;this._container=t,this._useMinimalControls=!1,this._newAnnotationType="note",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()
|
|
124
124
|
}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){L(mt(go,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,isSidebarOpen:this._sidebarOpen,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}class _o{constructor(t,e,n={}){if(this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new Bt,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}(n),this.options=n,this.bucketBar=null,n.externalContainerSelector){var o
|
|
125
125
|
;this.externalFrame=null!==(o=document.querySelector(n.externalContainerSelector))&&void 0!==o?o:t,this.externalFrame.appendChild(this.iframe)}else{this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="annotator-frame","clean"===n.theme?this.iframeContainer.classList.add("annotator-frame--theme-clean"):this.bucketBar=new co(this.iframeContainer,{onFocusAnnotations:t=>this._guestRPC.forEach((e=>e.call("focusAnnotations",t))),onScrollToClosestOffScreenAnchor:(t,e)=>this._guestRPC.forEach((n=>n.call("scrollToClosestOffScreenAnchor",t,e))),onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))}),this.iframeContainer.appendChild(this.iframe),this.hypothesisSidebar=document.createElement("hypothesis-sidebar");ne(this.hypothesisSidebar).appendChild(this.iframeContainer),t.appendChild(this.hypothesisSidebar)}this.iframe.contentWindow&&Dt(this.iframe.contentWindow),this._listeners=new At
|
|
126
126
|
;const i=document.createElement("div");this.toolbar=new mo(i,{createAnnotation:()=>this._guestRPC.forEach((t=>t.call("createAnnotationIn",this._guestWithSelection))),setSidebarOpen:t=>t?this.open():this.close(),setHighlightsVisible:t=>this.setHighlightsVisible(t)}),"clean"===n.theme?this.toolbar.useMinimalControls=!0:this.toolbar.useMinimalControls=!1,this.iframeContainer?(this.iframeContainer.prepend(i),this.toolbarWidth=this.toolbar.getWidth()):this.toolbarWidth=0,this._listeners.add(window,"resize",(()=>this._onResize())),this._gestureState={initial:null,final:null},this._setupGestures(),this.close();const[r]=n.services||[];r&&(this.onLoginRequest=r.onLoginRequest,this.onLogoutRequest=r.onLogoutRequest,this.onSignupRequest=r.onSignupRequest,this.onProfileRequest=r.onProfileRequest,this.onHelpRequest=r.onHelpRequest),this.onLayoutChange=n.onLayoutChange,this._notifyOfLayoutChange(!1),this._setupSidebarEvents(),this._sidebarRPC.on("ready",(()=>{this.iframeContainer&&(this.iframeContainer.style.display="")
|
|
127
|
-
;const t="always"===n.showHighlights;this.setHighlightsVisible(t),(n.openSidebar||n.annotations||n.query||n.group)&&this.open()})),this._listeners.add(window,"message",(t=>{const{data:e}=t;"hypothesisGuestUnloaded"===(null==e?void 0:e.type)
|
|
128
|
-
this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.forEach((e=>e.call("clearSelectionExceptIn",t)))})),e.on("anchorsChanged",(t=>{var e;null===(e=this.bucketBar)||void 0===e||e.update(t)})),e.connect(t),e}_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()}Array.from(n).forEach((t=>{t.addEventListener("click",o)}))}(document.body,(()=>this.open())),fo(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=>{
|
|
129
|
-
;[["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})))}_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()}
|
|
130
|
-
;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.forEach((t=>t.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(),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(),
|
|
131
|
-
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="",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(){
|
|
127
|
+
;const t="always"===n.showHighlights;this.setHighlightsVisible(t),(n.openSidebar||n.annotations||n.query||n.group)&&this.open()})),this._listeners.add(window,"message",(t=>{const{data:e,ports:n}=t;if("hypothesisGuestUnloaded"===(null==e?void 0:e.type))for(let t of n){const e=new Bt;e.connect(t),e.call("frameDestroyed"),e.destroy()}}))}destroy(){var t,e;this._guestRPC.forEach((t=>t.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(),this.hypothesisSidebar?this.hypothesisSidebar.remove():this.iframe.remove(),this._emitter.destroy(),Dt(null)}onFrameConnected(t,e){switch(t){case"guest":this._connectGuest(e);break;case"sidebar":this._sidebarRPC.connect(e)}}_connectGuest(t){const e=new Bt;e.on("textSelectedIn",(t=>{this._guestWithSelection=t,this.toolbar.newAnnotationType="annotation",this._guestRPC.forEach((e=>e.call("clearSelectionExceptIn",t)))})),e.on("textUnselectedIn",(t=>{
|
|
128
|
+
this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.forEach((e=>e.call("clearSelectionExceptIn",t)))})),e.on("anchorsChanged",(t=>{var e;null===(e=this.bucketBar)||void 0===e||e.update(t)})),e.on("frameDestroyed",(()=>{e.destroy(),this._guestRPC=this._guestRPC.filter((t=>t!==e))})),e.connect(t),this._guestRPC.push(e)}_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()}Array.from(n).forEach((t=>{t.addEventListener("click",o)}))}(document.body,(()=>this.open())),fo(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=>{
|
|
129
|
+
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})))}_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()}
|
|
130
|
+
})))}_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.forEach((t=>t.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(),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(),
|
|
131
|
+
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="",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(){
|
|
132
132
|
this.iframeContainer&&this.iframeContainer.classList.remove("is-hidden")}hide(){this.iframeContainer&&this.iframeContainer.classList.add("is-hidden")}}class vo{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 yo{constructor(){this._emitter=new Ot}createEmitter(){return new vo(this._emitter)}}!function(t,{reset:e=!1}={}){e&&_t.clear();for(let[e,n]of Object.entries(t))_t.set(e,n)}(Tt);const wo=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=Xt("annotator"),e=t.subFrameIdentifier?window.parent:window;let n,o,i
|
|
133
133
|
;if(e===window){const t=Xt("sidebar"),e=new URL(t.sidebarAppUrl).origin;i=new Ht(e);const r=new yo;n=new _o(document.body,r,t),o=new oo(document.body,r,Xt("notebook")),i.on("frameConnected",((t,e)=>n.onFrameConnected(t,e)))}const r=new Jn(document.body,t,e);wo.addEventListener("destroy",(()=>{var t,e,s;null===(t=i)||void 0===t||t.destroy(),null===(e=n)||void 0===e||e.destroy(),null===(s=o)||void 0===s||s.destroy(),r.destroy();document.querySelectorAll("[data-hypothesis-asset]").forEach((t=>t.remove()))}))}));
|
|
134
134
|
//# sourceMappingURL=annotator.bundle.js.map
|