hypothesis 1.933.0 → 1.934.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
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?8959c7","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?e0d71a","styles/annotator.css":"styles/annotator.css?1c6c62","styles/annotator.css.map":"styles/annotator.css.map?191b99","styles/highlights.css":"styles/highlights.css?c308d0","styles/highlights.css.map":"styles/highlights.css.map?5be890","styles/katex.min.css":"styles/katex.min.css?123be2","styles/katex.min.css.map":"styles/katex.min.css.map?4daef7","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?dd8179","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?bf5f6c","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?609d9f","styles/sidebar.css":"styles/sidebar.css?9deb89","styles/sidebar.css.map":"styles/sidebar.css.map?62189c","styles/ui-playground.css":"styles/ui-playground.css?f79501","styles/ui-playground.css.map":"styles/ui-playground.css.map?7f7573","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?ddb40b","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?d13b06","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?d80b6a"};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.934.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,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?8959c7",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?e0d71a",
|
|
4
4
|
"styles/annotator.css": "styles/annotator.css?1c6c62",
|
|
5
5
|
"styles/annotator.css.map": "styles/annotator.css.map?191b99",
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"styles/katex.min.css.map": "styles/katex.min.css.map?4daef7",
|
|
10
10
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?dd8179",
|
|
11
11
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?bf5f6c",
|
|
12
|
+
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?609d9f",
|
|
12
13
|
"styles/sidebar.css": "styles/sidebar.css?9deb89",
|
|
13
14
|
"styles/sidebar.css.map": "styles/sidebar.css.map?62189c",
|
|
14
15
|
"styles/ui-playground.css": "styles/ui-playground.css?f79501",
|
|
15
16
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?7f7573",
|
|
16
|
-
"scripts/
|
|
17
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?ddb40b",
|
|
17
18
|
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?d13b06",
|
|
18
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?66184d",
|
|
19
19
|
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?d80b6a"
|
|
20
20
|
}
|
|
@@ -3,7 +3,7 @@ var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?windo
|
|
|
3
3
|
Copyright (c) 2018 Jed Watson.
|
|
4
4
|
Licensed under the MIT License (MIT), see
|
|
5
5
|
http://jedwatson.github.io/classnames
|
|
6
|
-
*/$=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)}}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(" ")}$.exports?(e.default=e,$.exports=e):window.classNames=e}();var X,Y,G,Z=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(){J.forEach((function(t){if(t.__P)try{t.__H.__h.forEach(ut),t.__H.__h.forEach(dt),t.__H.__h=[]}catch(e){t.__H.__h=[],n.__e(e,t.__v)}})),J=[]}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)&&G===n.requestAnimationFrame||((G=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}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 mt=0;function gt(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:--mt,__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),gt("span",{className:Z("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})}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),gt("button",{ref:t,className:Z(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 gt(bt,{className:t,...e,children:gt(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 gt(bt,{className:e,...n,children:[o&&"left"===i&>(vt,{name:o},void 0,!1,{fileName:wt,lineNumber:127,columnNumber:43}),t,o&&"right"===i&>(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>');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 Tt({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",Z("Hyp-Icon",e))}),[e,i]);const s={};return o&&(s.title=o),gt("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);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>');var xt={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',cancel:St,caution:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',"caret-left":'<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="M10 12L6 8l4-4"></path></g></svg>',"caret-right":'<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="M6 4l4 4-4 4"></path></g></svg>',hide:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M1.61289944,0.209704612 L1.70710678,0.292893219 L15.7071068,14.2928932 C16.0976311,14.6834175 16.0976311,15.3165825 15.7071068,15.7071068 C15.3466228,16.0675907 14.7793918,16.0953203 14.3871006,15.7902954 L14.2928932,15.7071068 L0.292893219,1.70710678 C-0.0976310729,1.31658249 -0.0976310729,0.683417511 0.292893219,0.292893219 C0.65337718,-0.0675907428 1.22060824,-0.0953202783 1.61289944,0.209704612 Z M2.19604887,5.05494269 C2.65878442,5.35642943 2.78950241,5.97595401 2.48801567,6.43868956 C2.16488794,6.93464068 2,7.46139686 2,8 C2,10.1228856 4.62796016,12 8,12 C8.22060643,12 8.4396701,11.9919023 8.65660209,11.9758355 C9.20737829,11.9350431 9.68693944,12.3484666 9.72773191,12.8992428 C9.76852437,13.450019 9.35510087,13.9295801 8.80432467,13.9703726 C8.53822524,13.9900809 8.26988704,14 8,14 C3.64005335,14 0,11.3999619 0,8 C0,7.06308249 0.28281658,6.15958778 0.812302005,5.34690949 C1.11378875,4.88417394 1.73331332,4.75345595 2.19604887,5.05494269 Z M8,2 C12.3599467,2 16,4.6000381 16,8 C16,8.93691751 15.7171834,9.84041222 15.187698,10.6530905 C14.8862113,11.1158261 14.2666867,11.246544 13.8039511,10.9450573 C13.3412156,10.6435706 13.2104976,10.024046 13.5119843,9.56131044 C13.8351121,9.06535932 14,8.53860314 14,8 C14,5.8771144 11.3720398,4 8,4 C7.77939357,4 7.5603299,4.00809769 7.34339791,4.02416445 C6.79262171,4.06495692 6.31306056,3.65153342 6.27226809,3.10075722 C6.23147563,2.54998102 6.64489913,2.07041987 7.19567533,2.02962741 C7.46177476,2.00991913 7.73011296,2 8,2 Z"></path></svg>',highlight:'<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="M12 15H1h11zm-.5-6v2l-1 1v-2l1-1zm.5-7v6h-2V2h2zm0-1h-2 2zm0 8h-2 2z"></path></g></svg>',note:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M14,0 C15.0543618,0 15.9181651,0.815877791 15.9945143,1.85073766 L16,2 L16,9 C16,9.27541264 15.8865388,9.53676152 15.6894833,9.7243131 L15.6,9.8 L7.6,15.8 C7.46152306,15.9038577 7.29908616,15.9695431 7.12886893,15.9916629 L7,16 L2,16 C0.945638205,16 0.0818348781,15.1841222 0.00548573643,14.1492623 L0,14 L0,2 C0,0.945638205 0.815877791,0.0818348781 1.85073766,0.00548573643 L2,0 L14,0 Z M14,2 L2,2 L2,14 L6,14 L6,9 C6,8.48716416 6.38604019,8.06449284 6.88337887,8.00672773 L7,8 L14,8 L14,2 Z M12,10 L8,10 L8,13 L12,10 Z"></path></svg>',pointer:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="8" viewBox="0 0 15 8" aria-hidden="true" focusable="false"><path d="M0 8 L7 0 L15 8" stroke="currentColor" strokeWidth="2" /></svg>\n',show:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M8,2 C12.3599467,2 16,4.6000381 16,8 C16,11.3999619 12.3599467,14 8,14 C3.64005335,14 0,11.3999619 0,8 C0,4.6000381 3.64005335,2 8,2 Z M8,4 C4.62796016,4 2,5.8771144 2,8 C2,10.1228856 4.62796016,12 8,12 C11.3720398,12 14,10.1228856 14,8 C14,5.8771144 11.3720398,4 8,4 Z M8,6 C9.1045695,6 10,6.8954305 10,8 C10,9.1045695 9.1045695,10 8,10 C6.8954305,10 6,9.1045695 6,8 C6,6.8954305 6.8954305,6 8,6 Z"></path></svg>'},At={exports:{}};function kt(){}kt.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}},At.exports=kt;var Nt=At.exports.TinyEmitter=kt;let Lt=null;function Rt(t,e){return(...n)=>{try{return t(...n)}catch(t){throw function(t,e){if(!Lt)return;const n={type:"hypothesis-error",error:t instanceof Error?t:Mt(t),context:e};try{try{Lt.postMessage(n,"*")}catch(t){if(!(t instanceof DOMException&&"DataCloneError"===t.name))throw t;n.error=Mt(n.error),Lt.postMessage(n,"*")}}catch(t){console.warn("Unable to report Hypothesis error",t)}}(t,e),t}}}function Mt(t){return t instanceof Error?{message:t.message,stack:t.stack}:{message:String(t),stack:void 0}}function Ot(t){Lt=t}class Pt{constructor(){this._listeners=new Map}add(t,e,n,o){t.addEventListener(e,n,o);const i=Symbol();return this._listeners.set(i,{eventTarget:t,eventType:e,listener:n}),i}remove(t){const e=this._listeners.get(t);if(e){const{eventTarget:n,eventType:o,listener:i}=e;n.removeEventListener(o,i),this._listeners.delete(t)}}removeAll(){this._listeners.forEach((({eventTarget:t,eventType:e,listener:n})=>{t.removeEventListener(e,n)})),this._listeners.clear()}}function It(t,e){if(!function(t){if(null===t||"object"!=typeof t)return!1;for(let e of["frame1","frame2","type"])if("string"!=typeof t[e])return!1;return!0}(t))return!1;try{return JSON.stringify(t,Object.keys(t).sort())===JSON.stringify(e,Object.keys(e).sort())}catch{return!1}}class Dt{constructor(t){this._hypothesisAppsOrigin=t,this._emitter=new Nt,this._sentChannels=new Map,this._sidebarHostChannel=new MessageChannel,this._listeners=new Pt,this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"request"},{allowedOrigin:"*",frame1:"guest",frame2:"sidebar",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"sidebar",frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"notebook",frame2:"sidebar",type:"request"}]}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:o}){return("*"===e||o===e)&&It(n,t)}on(t,e){this._emitter.on(t,e)}listen(){this._listeners.add(window,"message",Rt((t=>{const{data:e,origin:n,source:o}=t;if(!function(t){return!(null===t||t instanceof MessagePort||window.ServiceWorker&&t instanceof ServiceWorker)}(o))return;const i=this._allowedMessages.find((({allowedOrigin:t,...o})=>this._messageMatches({allowedMessage:o,allowedOrigin:t,data:e,origin:n})));if(void 0===i)return;const{frame1:r,frame2:s}=i,a=`${r}-${s}`;let l=this._sentChannels.get(o);if(l||(l=new Set,this._sentChannels.set(o,l)),l.has(a))return;l.add(a);const c="sidebar-host"===a?this._sidebarHostChannel:new MessageChannel,h={frame1:r,frame2:s,type:"offer"};o.postMessage(h,n,[c.port1]),"sidebar"===s?this._sidebarHostChannel.port2.postMessage(h,[c.port2]):"host"===s&&this._emitter.emit("frameConnected",r,c.port2)}),"Handling port request"))}destroy(){this._listeners.removeAll()}}function Ft(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Bt(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),i={}}Ft(e,i)}return e}function Ht(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function Vt(t,e,n){const o=t.document.querySelector(`link[type="application/annotator+${n}"][rel="${e}"]`);if(!o)throw new Error(`No application/annotator+${n} (rel="${e}") link in the document`);if(!o.href)throw new Error(`application/annotator+${n} (rel="${e}") link has no href`);return o.href}function Ut(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=Ht(e.ignoreOtherConfiguration)?{}:Bt(t.document),{get annotations(){return n.annotations||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return Vt(t,"hypothesis-client","javascript")},get group(){return n.group||function(){const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return Vt(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 Vt(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 qt(t,e){return t.hostPageSetting(e)}const Wt={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:qt},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:qt},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:Ht,getValue:qt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},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:qt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:qt}};function jt(t="annotator",e=window){const n=Ut(e),o={};let i=function(t){const e={annotator:["clientUrl","subFrameIdentifier"],sidebar:["appType","annotations","branding","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],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=Wt[t],r=void 0!==i.defaultValue,s=!((a=Vt(e,"sidebar","html")).startsWith("http://")||a.startsWith("https://"));var a;if(!i.allowInBrowserExt&&s)return void(r&&(o[t]=i.defaultValue));const l=i.getValue(n,t);void 0!==l?o[t]=i.coerce?i.coerce(l):l:r&&(o[t]=i.defaultValue)})),o}class $t{constructor(t,e){this._port=t,this._methods=e,this._sequence=0,this._callbacks={},this._destroyed=!1,this._listeners=new Pt,this._listeners.add(this._port,"message",(t=>this._handle(t))),this._port.start()}destroy(){this._destroyed=!0,this._listeners.removeAll(),this._port.close()}call(t,...e){if(this._destroyed)return;const n=this._sequence++,o=e[e.length-1];"function"==typeof o&&(this._callbacks[n]=o,e=e.slice(0,-1));const i={arguments:e,method:t,protocol:"frame-rpc",sequence:n,version:"1.0.0"};this._port.postMessage(i)}_parseMessage({data:t}){return t&&"object"==typeof t?"frame-rpc"!==t.protocol||"1.0.0"!==t.version?null:Array.isArray(t.arguments)?t:null:null}_handle(t){const e=this._parseMessage(t);if(null!==e)if("method"in e){if(!this._methods.hasOwnProperty(e.method))return;const t=(...t)=>{const n={arguments:t,protocol:"frame-rpc",response:e.sequence,version:"1.0.0"};this._port.postMessage(n)};this._methods[e.method](...e.arguments,t)}else if("response"in e){const t=this._callbacks[e.response];delete this._callbacks[e.response],t&&t(...e.arguments)}}}class zt{constructor(){this.links=[],this.channelListeners={},this.onConnectListeners=[],this.on("connect",(t=>t()))}destroy(){this.links.forEach((t=>t.destroy())),this.links=[]}createChannel(t){const e=new $t(t,this.channelListeners);let n=!1;return e.call("connect",(()=>{n||(n=!0,this.onConnectListeners.forEach((t=>t(e))))})),this.links.push(e),e}call(t,...e){let n;const o=e[e.length-1];"function"==typeof o&&(n=o,e=e.slice(0,-1));const i=t=>e=>{throw t.destroy(),this.links=this.links.filter((e=>e!==t)),e},r=this.links.map((n=>new Promise(((o,i)=>{const r=setTimeout((()=>o(null)),1e3);try{n.call(t,...e,((t,e)=>{clearTimeout(r),t?i(t):o(e)}))}catch(t){i(t)}})).catch(i(n))));let s=Promise.all(r);return n&&(s=s.then((t=>n(null,t))).catch((t=>n(t)))),s}on(t,e){if(this.links.length>0)throw new Error(`Listener '${t}' can't be registered because a channel has already been created`);if(this.channelListeners[t])throw new Error(`Listener '${t}' already bound in Bridge`);return this.channelListeners[t]=e,this}onConnect(t){return this.onConnectListeners.push(t),this}}class Xt{constructor({hostFrame:t,source:e}){this._hostFrame=t,this._source=e,this._listeners=new Pt}destroy(){this._listeners.removeAll()}async discover(t){let e=!1;if(("guest"===this._source&&"host"===t||"guest"===this._source&&"sidebar"===t||"sidebar"===this._source&&"host"===t||"notebook"===this._source&&"sidebar"===t)&&(e=!0),!e)throw new Error("Invalid request of channel/port");return new Promise(((e,n)=>{const o=()=>{this._hostFrame.postMessage({frame1:this._source,frame2:t,type:"request"},"*")},i=setInterval(o,250),r=setTimeout((()=>{clearInterval(i),n(new Error(`Unable to establish ${this._source}-${t} communication channel`))}),1e4),s=this._listeners.add(window,"message",(n=>{const{data:o,ports:a}=n;It(o,{frame1:this._source,frame2:t,type:"offer"})&&(clearInterval(i),clearTimeout(r),this._listeners.remove(s),e(a[0]))}));o()}))}}function Yt(t){const e=t.toString(16);return 1===e.length?"0"+e:e}function Gt(t){const e=new Uint8Array(t/2);return window.crypto.getRandomValues(e),Array.from(e).map(Yt).join("")}const Zt={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=Zt[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?Zt.ctrl:0)|(t.metaKey?Zt.meta:0)|(t.altKey?Zt.alt:0)|(t.shiftKey?Zt.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 gt(Et,{classes:"LabeledIconButton AdderToolbar__button",icon:e,onClick:o,title:i?`${n} (${i})`:n,children:["number"==typeof t&>("span",{className:"hyp-u-bg-color--grey-7 AdderToolbar__badge",children:t}),gt("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"))),gt("div",{className:Z("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:[gt("div",{className:"hyp-u-layout-row AdderToolbar__actions",children:[gt(Qt,{icon:"annotate",onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),gt(Qt,{icon:"highlight",onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),o>0&>("div",{className:"hyp-u-margin--2 AdderToolbar__separator"}),o>0&>(Qt,{badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]}),gt(Tt,{name:"pointer",classes:Z("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,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(){M(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),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(){M(gt(te,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":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){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:{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){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 me(t,e="hypothesis-highlight"){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;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 ge(t,e){const n=t.parentNode;e.forEach((e=>n.insertBefore(e,t))),t.remove()}function _e(t){for(let e of t){if(e.parentNode){ge(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)})))}var we=/^\s+|\s+$/g,be=/^[-+]0x[0-9a-f]+$/i,Ce=/^0b[01]+$/i,Ee=/^0o[0-7]+$/i,Se=parseInt,Te="object"==typeof t&&t&&t.Object===Object&&t,xe="object"==typeof self&&self&&self.Object===Object&&self,Ae=Te||xe||Function("return this")(),ke=Object.prototype.toString,Ne=Math.max,Le=Math.min,Re=function(){return Ae.Date.now()};function Me(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Oe(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==ke.call(t)}(t))return NaN;if(Me(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Me(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(we,"");var n=Ce.test(t);return n||Ee.test(t)?Se(t.slice(2),n?2:8):be.test(t)?NaN:+t}var Pe=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(g,e),h?f(t):s}function m(t){var n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=r}function g(){var t=Re();if(m(t))return _(t);a=setTimeout(g,function(t){var n=e-(t-l);return u?Le(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=Re(),n=m(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return p(l);if(u)return a=setTimeout(g,e),f(l)}return void 0===a&&(a=setTimeout(g,e)),s}return e=Oe(e)||0,Me(n)&&(h=!!n.leading,r=(u="maxWait"in n)?Ne(Oe(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:_(Re())},v};class Ie{constructor(t,e,n){this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Pe((()=>{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)}}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 Fe{constructor(t,e){this._config=e,this._frameObserver=new Ie(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}=Bt(document),i=Gt(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){t.self===t?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function He(t){var e=t._scrollSettings;if(e){var n=e.maxSynchronousAlignments,o=function(t,e){var n,o,i,r,s,a,l,c=t.align,h=t.target.getBoundingClientRect(),u=c&&null!=c.left?c.left:.5,d=c&&null!=c.top?c.top:.5,f=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,m=u,g=d;if(t.isWindow(e))a=Math.min(h.width,e.innerWidth),l=Math.min(h.height,e.innerHeight),o=h.left+e.pageXOffset-e.innerWidth*m+a*m,i=h.top+e.pageYOffset-e.innerHeight*g+l*g,o-=f,i-=p,o=t.align.lockX?e.pageXOffset:o,i=t.align.lockY?e.pageYOffset:i,r=o-e.pageXOffset,s=i-e.pageYOffset;else{a=h.width,l=h.height,n=e.getBoundingClientRect();var _=h.left-(n.left-e.scrollLeft),v=h.top-(n.top-e.scrollTop);o=_+a*m-e.clientWidth*m,i=v+l*g-e.clientHeight*g,o-=f,i-=p,o=Math.max(Math.min(o,e.scrollWidth-e.clientWidth),0),i=Math.max(Math.min(i,e.scrollHeight-e.clientHeight),0),o=t.align.lockX?e.scrollLeft:o,i=t.align.lockY?e.scrollTop:i,r=o-e.scrollLeft,s=i-e.scrollTop}return{x:o,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&&He(e.scrollAncestor),void He(t);!function(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}(He.bind(null,t))}}function Ve(t){return t.self===t}function Ue(t){return"pageXOffset"in t||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function qe(){return!0}function We(t){if(t.assignedSlot)return We(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={}),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=We(t),i=1,r=e.validTarget||qe,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,Ue):Ue(o))&&(i++,a.push(o)),!(o=We(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||Ve,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&&He(e),r}(t,o,e,a[i+1],l)),null)}function l(t){--i||n&&n(t)}};function $e(t){return t.split("").reverse().join("")}function ze(t){return(t|-t)>>31&1}function Xe(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=ze(h&t.lastRowMask[n])-ze(u&t.lastRowMask[n]);return h<<=1,u<<=1,u|=s,h|=ze(o)-s,i=u|~(l|h),r=h&l,t.P[n]=i,t.M[n]=r,d}function Ye(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),n<c.length&&(c[n]=o);for(let t=0;t<=r;t+=1){o[t]=0;for(let r=0;r<i;r+=1){const s=t*i+r;if(s>=e.length)continue;e.charCodeAt(s)===n&&(o[t]|=1<<r)}}}let h=Math.max(0,Math.ceil(n/i)-1);const u=new Uint32Array(r+1);for(let t=0;t<=h;t+=1)u[t]=(t+1)*i;u[r]=e.length;for(let t=0;t<=h;t+=1)s.P[t]=-1,s.M[t]=0;for(let d=0;d<t.length;d+=1){const f=t.charCodeAt(d);let p;f<c.length?p=c[f]:(p=l.get(f),void 0===p&&(p=a));let m=0;for(let t=0;t<=h;t+=1)m=Xe(s,p,t,m),u[t]+=m;if(u[h]-m<=n&&h<r&&(1&p[h+1]||m<0)){let t;if(h+=1,s.P[h]=-1,s.M[h]=0,h===r){const n=e.length%i;t=0===n?i:n}else t=i;u[h]=u[h-1]+t-m+Xe(s,p,h,m)}else for(;h>0&&u[h]>=n+i;)h-=1;h===r&&u[h]<=n&&(u[h]<n&&o.splice(0,o.length),o.push({start:-1,end:d+1,errors:u[h]}),n=u[h])}return o}function Ge(t,e,n){return function(t,e,n){const o=$e(e);return n.map((n=>{const i=Math.max(0,n.end-e.length-n.errors);return{start:Ye($e(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,Ye(t,e,n))}function Ze(t,e,n){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 Ke(t,e){if(0===e.length||0===t.length)return 0;return 1-Ze(t,e,e.length)[0].errors/e.length}function Je(t,e,n={}){if(0===e.length)return null;const o=Math.min(256,e.length/2),i=Ze(t,e,o);if(0===i.length)return null;const r=o=>{const i=1-o.errors/e.length,r=n.prefix?Ke(t.slice(Math.max(0,o.start-n.prefix.length),o.start),n.prefix):1,s=n.suffix?Ke(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 Qe(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 tn(t,e){let n="",o=t;for(;o!==e;){if(!o)throw new Error("Node is not a descendant of root");n=Qe(o)+"/"+n,o=o.parentNode}return n="/"+n,n=n.replace(/\/$/,""),n}function en(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 nn(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=en(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 on{constructor(t,e){this.root=t,this.range=e}static fromRange(t,e){return new on(t,e)}static fromSelector(t,e){const n=nn(e.startContainer,t);if(!n)throw new Error("Failed to resolve startContainer XPath");const o=nn(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 on(t,s)}toRange(){return this.range}toSelector(){const t=ce.fromRange(this.range).toRange(),e=ce.fromRange(t),n=tn(e.start.element,this.root),o=tn(e.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:e.start.offset,endContainer:o,endOffset:e.end.offset}}}class rn{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 rn(t,n.start.offset,n.end.offset)}static fromSelector(t,e){return new rn(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 sn{constructor(t,e,n={}){this.root=t,this.exact=e,this.context=n}static fromRange(t,e){const n=t.textContent,o=ce.fromRange(e).relativeTo(t),i=o.start.offset,r=o.end.offset;return new sn(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 sn(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=Je(this.root.textContent,this.exact,{...this.context,hint:t.hint});if(!e)throw new Error("Quote not found");return new rn(this.root,e.start,e.end)}}async function an(t,e={}){return t.toRange(e)}function ln(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};let a=Promise.reject("unable to anchor");return r&&(a=a.catch((()=>an(on.fromSelector(t,r),n).then(s)))),o&&(a=a.catch((()=>an(rn.fromSelector(t,o),n).then(s)))),i&&(a=a.catch((()=>an(sn.fromSelector(t,i),n)))),a}function cn(t,e){const n=[on,rn,sn],o=[];for(let i of n)try{const n=i.fromRange(t,e);o.push(n.toSelector())}catch(t){continue}return o}function hn(t,e=document.baseURI){return new URL(t,e).href.toString().replace(/#.*/,"")}class un{constructor(t={}){this.document=t.document||document}uri(){let t=decodeURIComponent(this._getDocumentHref());const e=this._getLinks();for(let n of e)"canonical"===n.rel&&(t=n.href);return t}getDocumentMetadata(){const t={title:document.title,link:[],dc:this._getMetaTags("dc","name","."),eprints:this._getMetaTags("eprints","name","."),facebook:this._getMetaTags("og","property",":"),highwire:this._getMetaTags("citation","name","_"),prism:this._getMetaTags("prism","name","."),twitter:this._getMetaTags("twitter","name",":")},e=this._getFavicon();e&&(t.favicon=e),t.title=this._getTitle(t),t.link=this._getLinks(t);const n=t.link.find((t=>t.href.startsWith("urn:x-dc")));return n&&(t.documentFingerprint=n.href),t}_getMetaTags(t,e,n){const o={};for(let i of Array.from(this.document.querySelectorAll("meta"))){const r=i.getAttribute(e),{content:s}=i;if(r){const e=r.match(RegExp(`^${t}${n}(.+)$`,"i"));if(e){const t=e[1];o[t]?o[t].push(s):o[t]=[s]}}}return o}_getTitle(t){return t.highwire.title?t.highwire.title[0]:t.eprints.title?t.eprints.title[0]:t.prism.title?t.prism.title[0]:t.facebook.title?t.facebook.title[0]:t.twitter.title?t.twitter.title[0]:t.dc.title?t.dc.title[0]:this.document.title}_getLinks(t={dc:{},highwire:{}}){const e=[{href:this._getDocumentHref()}],n=Array.from(this.document.querySelectorAll("link"));for(let t of n)if(["alternate","canonical","bookmark","shortlink"].includes(t.rel)){if("alternate"===t.rel){if(t.type&&t.type.match(/^application\/(rss|atom)\+xml/))continue;if(t.hreflang)continue}try{const n=this._absoluteUrl(t.href);e.push({href:n,rel:t.rel,type:t.type})}catch(t){}}for(let n of Object.keys(t.highwire)){const o=t.highwire[n];if("pdf_url"===n)for(let t of o)try{e.push({href:this._absoluteUrl(t),type:"application/pdf"})}catch(t){}if("doi"===n)for(let t of o)"doi:"!==t.slice(0,4)&&(t=`doi:${t}`),e.push({href:t})}for(let n of Object.keys(t.dc)){const o=t.dc[n];if("identifier"===n)for(let t of o)"doi:"===t.slice(0,4)&&e.push({href:t})}const o=t.dc["relation.ispartof"],i=t.dc.identifier;if(o&&i){const t=o[o.length-1],n=i[i.length-1],r="urn:x-dc:"+encodeURIComponent(t)+"/"+encodeURIComponent(n);e.push({href:r})}return e}_getFavicon(){let t=null;for(let e of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(e.rel))try{t=this._absoluteUrl(e.href)}catch(t){}return t}_absoluteUrl(t){return hn(t,this.document.baseURI)}_getDocumentHref(){const{href:t}=this.document.location,e=["http:","https:","file:"],n=new URL(t).protocol;return e.includes(n)?t:this.document.baseURI&&e.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:t}}class dn{constructor(t=document.body){this.container=t,this.anchor=ln,this.describe=cn,this._htmlMeta=new un}canAnnotate(){return!0}destroy(){}contentContainer(){return this.container}fitSideBySide(){return!1}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}scrollToAnchor(t){const e=t.highlights;return new Promise((t=>{je(e[0],t)}))}}let fn={};function pn(...t){const e=t.join();e in fn||(console.warn(...t),fn[e]=!0)}pn.reset=()=>{fn={}};const mn=0,gn=3,_n=new Map,vn=new Map;function yn(t,e){return`${t}:${e}`}function wn(t){var e;const n="closest"in t?t:t.parentElement;return null!==(e=null==n?void 0:n.closest(".textLayer"))&&void 0!==e?e:null}function bn(){return PDFViewerApplication.pdfViewer}async function Cn(t){const e=bn();let n=e.getPageView(t);return n&&n.pdfPage||(n=await new Promise((n=>{const o=()=>{e.eventBus?e.eventBus.off("pagesloaded",o):document.removeEventListener("pagesloaded",o),n(e.getPageView(t))};e.eventBus?e.eventBus.on("pagesloaded",o):document.addEventListener("pagesloaded",o)}))),n}function En(t){const e=_n.get(t);if(e)return e;const n=(async()=>{const e=await Cn(t);let n=(await e.pdfPage.getTextContent({normalizeWhitespace:!0})).items;return n.length>0&&!("hasEOL"in n[0])&&(n=n.filter((t=>/\S/.test(t.str)))),n.map((t=>t.str)).join("")})();return _n.set(t,n),n}async function Sn(t){const e=bn();let n=0,o=0,i="";for(let r=0;r<e.pagesCount;r++)if(i=await En(r),n=o,o+=i.length,o>=t)return{index:r,offset:n,text:i};return{index:e.pagesCount-1,offset:n,text:i}}async function Tn(t,e,n){const[o,i]=await Promise.all([Cn(t),En(t)]);if(o.renderingState===gn&&o.textLayer&&o.textLayer.renderingDone){const t=o.textLayer.textLayerDiv;i!==t.textContent&&pn("PDF text layer content does not match page text. This will cause anchoring misalignment.");const r=new le(t,e),s=new le(t,n);return new ce(r,s).toRange()}const r=function(t){let e=t.querySelector(".annotator-placeholder");return e||(e=document.createElement("span"),e.classList.add("annotator-placeholder"),e.textContent="Loading annotations...",t.appendChild(e),e)}(o.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function xn(t){const e=[];let n="";for(let o=0;o<t.length;o++){const i=t[o];" "!==i&&"\t"!==i&&"\n"!==i&&(n+=i,e.push(o))}return[n,e]}async function An(t,e){const n=e.find((t=>"TextQuoteSelector"===t.type));if(!n)throw new Error("No quote selector found");const o=e.find((t=>"TextPositionSelector"===t.type));if(o){try{const{index:t,offset:e,text:i}=await Sn(o.start),r=o.start-e,s=o.end-e,a=i.substring(r,s);if(n.exact!==a)throw new Error("quote mismatch");return await Tn(t,r,s)}catch{}try{const t=yn(n.exact,o.start),e=vn.get(t);if(e){const{pageIndex:t,anchor:n}=e;return await Tn(t,n.start,n.end)}}catch{}}return async function(t,e){const n=bn().pagesCount,o=Array(n).fill(0).map(((t,e)=>e));let i,r;if(e){const{index:t,offset:n}=await Sn(e);i=t,r=e-n,o.sort(((e,n)=>Math.abs(e-t)-Math.abs(n-t)))}const[s]=void 0!==t.prefix?xn(t.prefix):[],[a]=void 0!==t.suffix?xn(t.suffix):[],[l]=xn(t.exact);let c;for(let t of o){const e=await En(t),[n,o]=xn(e);let h;if(void 0!==i&&void 0!==r){let n;for(n=t<i?e.length:t===i?r:0,h=0;h<o.length&&o[h]<n;)++h}const u=Je(n,l,{prefix:s,suffix:a,hint:h});if(u&&(!c||u.score>c.match.score)){c={page:t,match:{start:o[u.start],end:o[u.end-1]+1,score:u.score}};const e=n.slice(u.start,u.end)===l,i=void 0!==s&&n.slice(Math.max(0,u.start-s.length),u.start)===s,r=void 0!==a&&n.slice(u.end,a.length)===a,h=void 0!==s||void 0!==a;if(e&&(i||r||!h))break}}if(c){const{page:n,match:o}=c;if(e){const i=yn(t.exact,e);vn.set(i,{pageIndex:n,anchor:o})}return Tn(n,o.start,o.end)}throw new Error("Quote not found")}(n,null==o?void 0:o.start)}function kn(t){try{t=ce.fromRange(t).toRange()}catch{throw new Error("Selection does not contain text")}const e=wn(t.startContainer),n=wn(t.endContainer);if(!e||!n)throw new Error("Selection is outside page text");if(e!==n)throw new Error("Selecting across page breaks is not supported");return[t,e]}async function Nn(t,e){const[n,o]=kn(e),i=le.fromPoint(n.startContainer,n.startOffset).relativeTo(o),r=le.fromPoint(n.endContainer,n.endOffset).relativeTo(o),s=function(t){let e=0;for(;t.previousSibling;)++e,t=t.previousSibling;return e}(o.parentNode),a=await async function(t){if(t>=bn().pagesCount)throw new Error("Invalid page index");let e=0;for(let n=0;n<t;n++)e+=(await En(n)).length;return e}(s);return[{type:"TextPositionSelector",start:a+i.offset,end:a+r.offset},sn.fromRange(t,n).toSelector()]}function Ln(){return gt("div",{className:"WarningBanner WarningBanner--notice",children:[gt("div",{className:"WarningBanner__type",children:gt(vt,{name:"caution",className:"WarningBanner__icon"})}),gt("div",{className:"WarningBanner__message",children:[gt("strong",{children:"This PDF does not contain selectable text:"})," ",gt("a",{target:"_blank",rel:"noreferrer",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})}function Rn(t,e,n){return t+n*(e-t)}async function Mn(t,e,{maxDuration:n=500}={}){const o=t.scrollTop,i=e,r=Date.now(),s=Math.min(Math.abs(i-o)/3,n);let a=0;for(;a<1;)await new Promise((t=>{requestAnimationFrame(t)})),a=Math.min(1,(Date.now()-r)/s),t.scrollTop=Rn(o,i,a)}class On{constructor(t){this._loaded=function(t){return t.initializedPromise?t.initializedPromise:t.initialized?Promise.resolve():new Promise((e=>{const n=setInterval((()=>{t.initialized&&(clearTimeout(n),e())}),5)}))}(t).then((()=>t.downloadComplete?t:new Promise((e=>{const n=()=>{t.eventBus?(t.eventBus.off("documentload",n),t.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),e(t)};t.eventBus?(t.eventBus.on("documentloaded",n),t.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))))}getUri(){return this._loaded.then((t=>{let e=Dn(t);return e||(e=In(Pn(t))),e}))}async getMetadata(){const t=await this._loaded,{info:e,contentDispositionFilename:n,metadata:o}=await t.pdfDocument.getMetadata(),i=Pn(t),r=Dn(t);let s;s=null!=o&&o.has("dc:title")&&"Untitled"!==o.get("dc:title")?o.get("dc:title"):null!=e&&e.Title?e.Title:n||(r?function(t){const e=new URL(t).pathname.split("/");return e[e.length-1]}(r):"");const a=[{href:In(i)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:i}}}function Pn(t){return Array.isArray(t.pdfDocument.fingerprints)?t.pdfDocument.fingerprints[0]:t.pdfDocument.fingerprint}function In(t){return`urn:x-pdf:${t}`}function Dn(t){if(!t.url)return null;const e=hn(t.url);return 0!==e.indexOf("file://")?e:null}function Fn(t){var e;const n=null===(e=t.highlights)||void 0===e?void 0:e[0];return n&&he(n)}function Bn(t){return new Promise((e=>setTimeout(e,t)))}class Hn{constructor(t,e={}){var n,o,i;this.annotator=t;const r=window,s=r.PDFViewerApplication;this.pdfViewer=s.pdfViewer,this.pdfViewer.viewer.classList.add("has-transparent-text-layer"),this.pdfContainer=null!==(n=null===(o=s.appConfig)||void 0===o?void 0:o.appContainer)&&void 0!==n?n:document.body,this.pdfMetadata=new On(s),this.observer=new MutationObserver(Pe((()=>this._update()),100)),this.observer.observe(this.pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=null!==(i=e.reanchoringMaxWait)&&void 0!==i?i:3e3,this._warningBanner=null,this._checkForSelectableText(),this._updateAnnotationLayerVisibility=()=>{const t=r.getSelection();this.pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new Pt,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){var t;this._listeners.removeAll(),this.pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this.observer.disconnect(),null===(t=this._warningBanner)||void 0===t||t.remove(),this._destroyed=!0}uri(){return this.pdfMetadata.getUri()}getMetadata(){return this.pdfMetadata.getMetadata()}anchor(t,e){return An(0,e)}canAnnotate(t){return function(t){try{return kn(t),!0}catch{return!1}}(t)}describe(t,e){return Nn(t,e)}async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._destroyed)try{const t=await async function(){const t=bn();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await En(n)).trim().length>0){e=!0;break}return e}();this._toggleNoSelectableTextWarning(!t)}catch(t){console.warn("Unable to check for text in PDF:",t)}}_toggleNoSelectableTextWarning(t){const e=document.querySelector("#outerContainer");var n;if(!t)return null===(n=this._warningBanner)||void 0===n||n.remove(),this._warningBanner=null,void(e.style.height="");this._warningBanner=document.createElement("hypothesis-banner"),document.body.prepend(this._warningBanner);const o=ne(this._warningBanner);M(gt(Ln,{}),o);const i=this._warningBanner.getBoundingClientRect().height;e.style.height=`calc(100% - ${i}px)`}_update(){const t=[],e=this.pdfViewer.pagesCount;for(let t=0;t<e;t++){var n;const e=this.pdfViewer.getPageView(t);if(null!=e&&null!==(n=e.textLayer)&&void 0!==n&&n.renderingDone)switch(e.renderingState){case mn:e.textLayer=null;break;case gn:o=e.div,i=void 0,null===(i=o.querySelector(".annotator-placeholder"))||void 0===i||i.remove()}}var o,i;for(let e of this.annotator.anchors)if(e.highlights){if(t.includes(e.annotation))continue;for(let n=0;n<e.highlights.length;n++){const o=e.highlights[n];if(!document.body.contains(o)){e.highlights.splice(n,1),delete e.range,t.push(e.annotation);break}}}t.map((t=>this.annotator.anchor(t)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(t){const e=window.innerWidth-t.width,n=t.expanded&&e>=680,o=n?t.width:t.toolbarWidth;this.pdfContainer.style.width=`calc(100% - ${o}px)`;const i=this.pdfViewer.currentScaleValue;return"auto"!==i&&"page-fit"!==i&&"page-width"!==i||(this.pdfViewer.currentScaleValue=i),this.pdfViewer.update(),n}async scrollToAnchor(t){const e=t.annotation,n=Fn(t),o=this._anchorOffset(t);if(null!==o&&(await Mn(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await Mn(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n;const o=Date.now();let i;do{i=this.annotator.anchors.find((e=>e.annotation===t)),i&&!Fn(i)||(i=null,await Bn(20))}while(!i&&Date.now()-o<e);return null!==(n=i)&&void 0!==n?n:null}_anchorOffset(t){if(!t.highlights)return null;return function(t,e){let n=0;for(;t!==e&&e.contains(t);)n+=t.offsetTop,t=t.offsetParent;return n}(t.highlights[0],this.contentContainer())}}function Vn(t,e){return t?{left:Math.min(t.left,e.left),right:Math.max(t.right,e.right),top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom)}:e}class Un{constructor(t,e,n){if(e.length!==n.length)throw new Error("Char boxes length does not match text length");const o=t.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,t.nextSibling),o.style.position="relative",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.mixBlendMode="multiply";const r="sans-serif";i.style.fontSize="16px",i.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font="16px sans-serif";let a=null,l="";const c=[];let h=0;const u=()=>{if(!a)return;const t=document.createElement("span");t.style.position="absolute",t.style.color="transparent",t.style.transformOrigin="top left",t.textContent=l,i.append(t),i.append(" "),h||(h=t.getBoundingClientRect().height),c.push({span:t,box:a,width:s.measureText(l).width,height:h}),a=null,l=""};for(let t=0;t<e.length;t++){const o=n[t];if(/\s/.test(o)){u();continue}const i=e[t];a=Vn(a,i),l+=o}u();const d=()=>{const{width:e,height:n}=t.getBoundingClientRect();i.style.width=e+"px",i.style.height=n+"px";for(let{span:t,box:o,width:i,height:r}of c){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=Pe(d,{maxWait:50}),this._listeners=new Pt,this._listeners.add(window,"resize",this._updateBoxSizes)}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateBoxSizes.cancel()}}function qn(t=document){return t.querySelector("mosaic-book")}class Wn{constructor(t){const e=qn();if(!e)throw new Error("Book container element not found");const n=e.shadowRoot,o=()=>{const e=n.querySelector("iframe");e&&t.injectClient(e)};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(n,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}canAnnotate(){return!1}async anchor(){return new Range}describe(){throw new Error("This frame cannot be annotated")}contentContainer(){return document.body}fitSideBySide(){return!1}async getMetadata(){return{title:"",link:[]}}async uri(){return document.location.href}async scrollToAnchor(){}}class jn{constructor(t=document.body){this._htmlIntegration=new dn(t),this._listeners=new Pt;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 Un(n,o.glyphs.glyphs.map((t=>({left:t.l/100,right:t.r/100,top:t.t/100,bottom:t.b/100}))),o.words),this._textLayer.container.style.zIndex="100")}canAnnotate(){return!0}destroy(){var t;null===(t=this._textLayer)||void 0===t||t.destroy(),this._listeners.removeAll(),this._htmlIntegration.destroy()}anchor(t,e){return this._htmlIntegration.anchor(t,e)}describe(t,e){return this._htmlIntegration.describe(t,e)}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(){return!1}async getMetadata(){return{title:document.title,link:[]}}async uri(){const t=new URL(document.location.href);return t.search="",t.toString()}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function $n(t){if("undefined"!=typeof PDFViewerApplication)return new Hn(t);const e=function(t=window){var e;if(qn(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&qn(n)?"content":null}();return"container"===e?new Wn(t):"content"===e?new jn:new dn}class zn{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 Pt,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 Xn(){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);t&&o.add(t),i=i.parentNode}})),[...o]}(window.getSelection().getRangeAt(0),(t=>t._annotation));return t}function Yn(t){const e=function(t){let e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;const n=[];for(;e;)e.classList.contains("hypothesis-highlight")&&n.push(e),e=e.parentElement;return n}(t).map((t=>t._annotation)).filter((t=>void 0!==t));return e}function Gn(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}class Zn{constructor(t,e,n={},o=window){this.element=t,this._emitter=e.createEmitter(),this._hostFrame=o,this._highlightsVisible=!1,this._isAdderVisible=!1,this._adder=new ie(this.element,{onAnnotate:async()=>{await this.createAnnotation(),document.getSelection().removeAllRanges()},onHighlight:async()=>{await this.createAnnotation({highlight:!0}),document.getSelection().removeAllRanges()},onShowAnnotations:t=>{this.selectAnnotations(t)}}),this._selectionObserver=new zn((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._frameIdentifier=n.subFrameIdentifier||null,this._portFinder=new Xt({hostFrame:this._hostFrame,source:"guest"}),this._sidebarRPC=new zt,this._connectSidebarEvents(),this._hypothesisInjector=new Fe(this.element,n),this._integration=$n(this),this._sideBySideActive=!1,this._listeners=new Pt,this._setupElementEvents(),this._focusedAnnotations=new Set,this._listeners.add(window,"unload",(()=>this._notifyGuestUnload()))}_setupElementEvents(){const t=t=>{this._sideBySideActive||Yn(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:o}=t,i=Yn(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=Yn(t);e.length&&this._highlightsVisible&&this._focusAnnotations(e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._focusAnnotations([])})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async injectClient(t){return this._hypothesisInjector.injectClient(t)}async getDocumentInfo(){const[t,e]=await Promise.all([this._integration.uri(),this._integration.getMetadata()]);return{uri:hn(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 _connectSidebarEvents(){this._sidebarRPC.on("focusAnnotations",((t=[])=>{this._focusedAnnotations.clear(),t.forEach((t=>this._focusedAnnotations.add(t)));for(let e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);ve(e.highlights,n)}})),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=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("getDocumentInfo",(t=>{this.getDocumentInfo().then((e=>t(null,e))).catch((e=>t(e)))})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t)))));const t=await this._portFinder.discover("sidebar");this._sidebarRPC.createChannel(t)}destroy(){this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),function(t){_e(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy(),this._emitter.destroy(),this._sidebarRPC.destroy()}_notifyGuestUnload(){const t={type:"hypothesisGuestUnloaded",frameIdentifier:this._frameIdentifier};this._hostFrame.postMessage(t,"*")}async anchor(t){const e=t=>{const e=Gn(t);if(!e)return;const n=me(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),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})));for(let t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){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){this.anchors=t,e&&this._emitter.publish("anchorsChanged",this.anchors)}async createAnnotation({highlight:t=!1}={}){var e;const n=null!==(e=this.selectedRanges)&&void 0!==e?e:[];this.selectedRanges=null;const o=await this.getDocumentInfo(),i=this.element,r=(await Promise.all(n.map((t=>this._integration.describe(i,t))))).map((t=>({source:o.uri,selector:t}))),s={uri:o.uri,document:o.metadata,target:r,$highlight:t,$tag:"a:"+Gt(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),s}_focusAnnotations(t){const e=t.map((t=>t.$tag));this._sidebarRPC.call("focusAnnotations",e)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=ue(e),o=pe(e);o?(this.selectedRanges=[t],this._emitter.publish("hasSelectionChanged",!0),this._adder.annotationsForSelection=Xn(),this._isAdderVisible=!0,this._adder.show(o,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._emitter.publish("hasSelectionChanged",!1)}selectAnnotations(t,e=!1){const n=t.map((t=>t.$tag));e?this._sidebarRPC.call("toggleAnnotationSelection",n):this._sidebarRPC.call("showAnnotations",n),this._sidebarRPC.call("openSidebar")}scrollToAnchor(t){return this._integration.scrollToAnchor(t)}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}contentContainer(){return this._integration.contentContainer()}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get focusedAnnotationTags(){return this._focusedAnnotations}}function Kn(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function Jn(t){var e;const n={};for(let[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.version="1.933.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),(null===(e=n.services)||void 0===e?void 0:e.length)>0){const t=n.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return n}function Qn({config:t,groupId:e}){return gt("iframe",{title:"Hypothesis annotation notebook",className:"NotebookIframe",allowFullScreen:!0,src:Kn(t.notebookAppUrl,{...Jn(t),group:e})})}function to({eventBus:t,config:e}){const[n,o]=rt(0),[i,r]=rt(!0),[s,a]=rt(null),l=lt(""),c=lt(null);st((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),st((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),st((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:gt("div",{className:Z("NotebookModal__outer",{"is-hidden":i}),children:gt("div",{className:"NotebookModal__inner",children:[gt("div",{className:"NotebookModal__close-button-container",children:gt(Ct,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),gt(Qn,{config:e,groupId:s},n)]})})}class eo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=ne(this._outerContainer),M(gt(to,{eventBus:e,config:n}),this.shadowRoot)}destroy(){M(null,this.shadowRoot),this._outerContainer.remove()}}var no={exports:{}};
|
|
6
|
+
*/$=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)}}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(" ")}$.exports?(e.default=e,$.exports=e):window.classNames=e}();var X,Y,G,Z=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(){J.forEach((function(t){if(t.__P)try{t.__H.__h.forEach(ut),t.__H.__h.forEach(dt),t.__H.__h=[]}catch(e){t.__H.__h=[],n.__e(e,t.__v)}})),J=[]}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)&&G===n.requestAnimationFrame||((G=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}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 mt=0;function gt(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:--mt,__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),gt("span",{className:Z("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})}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),gt("button",{ref:t,className:Z(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 gt(bt,{className:t,...e,children:gt(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 gt(bt,{className:e,...n,children:[o&&"left"===i&>(vt,{name:o},void 0,!1,{fileName:wt,lineNumber:127,columnNumber:43}),t,o&&"right"===i&>(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>');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 Tt({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",Z("Hyp-Icon",e))}),[e,i]);const s={};return o&&(s.title=o),gt("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);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>');var xt={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',cancel:St,caution:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',"caret-left":'<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="M10 12L6 8l4-4"></path></g></svg>',"caret-right":'<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="M6 4l4 4-4 4"></path></g></svg>',hide:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M1.61289944,0.209704612 L1.70710678,0.292893219 L15.7071068,14.2928932 C16.0976311,14.6834175 16.0976311,15.3165825 15.7071068,15.7071068 C15.3466228,16.0675907 14.7793918,16.0953203 14.3871006,15.7902954 L14.2928932,15.7071068 L0.292893219,1.70710678 C-0.0976310729,1.31658249 -0.0976310729,0.683417511 0.292893219,0.292893219 C0.65337718,-0.0675907428 1.22060824,-0.0953202783 1.61289944,0.209704612 Z M2.19604887,5.05494269 C2.65878442,5.35642943 2.78950241,5.97595401 2.48801567,6.43868956 C2.16488794,6.93464068 2,7.46139686 2,8 C2,10.1228856 4.62796016,12 8,12 C8.22060643,12 8.4396701,11.9919023 8.65660209,11.9758355 C9.20737829,11.9350431 9.68693944,12.3484666 9.72773191,12.8992428 C9.76852437,13.450019 9.35510087,13.9295801 8.80432467,13.9703726 C8.53822524,13.9900809 8.26988704,14 8,14 C3.64005335,14 0,11.3999619 0,8 C0,7.06308249 0.28281658,6.15958778 0.812302005,5.34690949 C1.11378875,4.88417394 1.73331332,4.75345595 2.19604887,5.05494269 Z M8,2 C12.3599467,2 16,4.6000381 16,8 C16,8.93691751 15.7171834,9.84041222 15.187698,10.6530905 C14.8862113,11.1158261 14.2666867,11.246544 13.8039511,10.9450573 C13.3412156,10.6435706 13.2104976,10.024046 13.5119843,9.56131044 C13.8351121,9.06535932 14,8.53860314 14,8 C14,5.8771144 11.3720398,4 8,4 C7.77939357,4 7.5603299,4.00809769 7.34339791,4.02416445 C6.79262171,4.06495692 6.31306056,3.65153342 6.27226809,3.10075722 C6.23147563,2.54998102 6.64489913,2.07041987 7.19567533,2.02962741 C7.46177476,2.00991913 7.73011296,2 8,2 Z"></path></svg>',highlight:'<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="M12 15H1h11zm-.5-6v2l-1 1v-2l1-1zm.5-7v6h-2V2h2zm0-1h-2 2zm0 8h-2 2z"></path></g></svg>',note:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M14,0 C15.0543618,0 15.9181651,0.815877791 15.9945143,1.85073766 L16,2 L16,9 C16,9.27541264 15.8865388,9.53676152 15.6894833,9.7243131 L15.6,9.8 L7.6,15.8 C7.46152306,15.9038577 7.29908616,15.9695431 7.12886893,15.9916629 L7,16 L2,16 C0.945638205,16 0.0818348781,15.1841222 0.00548573643,14.1492623 L0,14 L0,2 C0,0.945638205 0.815877791,0.0818348781 1.85073766,0.00548573643 L2,0 L14,0 Z M14,2 L2,2 L2,14 L6,14 L6,9 C6,8.48716416 6.38604019,8.06449284 6.88337887,8.00672773 L7,8 L14,8 L14,2 Z M12,10 L8,10 L8,13 L12,10 Z"></path></svg>',pointer:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="8" viewBox="0 0 15 8" aria-hidden="true" focusable="false"><path d="M0 8 L7 0 L15 8" stroke="currentColor" strokeWidth="2" /></svg>\n',show:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M8,2 C12.3599467,2 16,4.6000381 16,8 C16,11.3999619 12.3599467,14 8,14 C3.64005335,14 0,11.3999619 0,8 C0,4.6000381 3.64005335,2 8,2 Z M8,4 C4.62796016,4 2,5.8771144 2,8 C2,10.1228856 4.62796016,12 8,12 C11.3720398,12 14,10.1228856 14,8 C14,5.8771144 11.3720398,4 8,4 Z M8,6 C9.1045695,6 10,6.8954305 10,8 C10,9.1045695 9.1045695,10 8,10 C6.8954305,10 6,9.1045695 6,8 C6,6.8954305 6.8954305,6 8,6 Z"></path></svg>'},At={exports:{}};function kt(){}kt.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}},At.exports=kt;var Nt=At.exports.TinyEmitter=kt;let Lt=null;function Rt(t,e){return(...n)=>{try{return t(...n)}catch(t){throw function(t,e){if(!Lt)return;const n={type:"hypothesis-error",error:t instanceof Error?t:Mt(t),context:e};try{try{Lt.postMessage(n,"*")}catch(t){if(!(t instanceof DOMException&&"DataCloneError"===t.name))throw t;n.error=Mt(n.error),Lt.postMessage(n,"*")}}catch(t){console.warn("Unable to report Hypothesis error",t)}}(t,e),t}}}function Mt(t){return t instanceof Error?{message:t.message,stack:t.stack}:{message:String(t),stack:void 0}}function Ot(t){Lt=t}class Pt{constructor(){this._listeners=new Map}add(t,e,n,o){t.addEventListener(e,n,o);const i=Symbol();return this._listeners.set(i,{eventTarget:t,eventType:e,listener:n}),i}remove(t){const e=this._listeners.get(t);if(e){const{eventTarget:n,eventType:o,listener:i}=e;n.removeEventListener(o,i),this._listeners.delete(t)}}removeAll(){this._listeners.forEach((({eventTarget:t,eventType:e,listener:n})=>{t.removeEventListener(e,n)})),this._listeners.clear()}}function It(t,e){if(!function(t){if(null===t||"object"!=typeof t)return!1;for(let e of["frame1","frame2","type"])if("string"!=typeof t[e])return!1;return!0}(t))return!1;try{return JSON.stringify(t,Object.keys(t).sort())===JSON.stringify(e,Object.keys(e).sort())}catch{return!1}}class Dt{constructor(t){this._hypothesisAppsOrigin=t,this._emitter=new Nt,this._sentChannels=new Map,this._sidebarHostChannel=new MessageChannel,this._listeners=new Pt,this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"request"},{allowedOrigin:"*",frame1:"guest",frame2:"sidebar",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"sidebar",frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"notebook",frame2:"sidebar",type:"request"}]}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:o}){return("*"===e||o===e)&&It(n,t)}on(t,e){this._emitter.on(t,e)}listen(){this._listeners.add(window,"message",Rt((t=>{const{data:e,origin:n,source:o}=t;if(!function(t){return!(null===t||t instanceof MessagePort||window.ServiceWorker&&t instanceof ServiceWorker)}(o))return;const i=this._allowedMessages.find((({allowedOrigin:t,...o})=>this._messageMatches({allowedMessage:o,allowedOrigin:t,data:e,origin:n})));if(void 0===i)return;const{frame1:r,frame2:s}=i,a=`${r}-${s}`;let l=this._sentChannels.get(o);if(l||(l=new Set,this._sentChannels.set(o,l)),l.has(a))return;l.add(a);const c="sidebar-host"===a?this._sidebarHostChannel:new MessageChannel,h={frame1:r,frame2:s,type:"offer"};o.postMessage(h,n,[c.port1]),"sidebar"===s?this._sidebarHostChannel.port2.postMessage(h,[c.port2]):"host"===s&&this._emitter.emit("frameConnected",r,c.port2)}),"Handling port request"))}destroy(){this._listeners.removeAll()}}function Ft(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Bt(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),i={}}Ft(e,i)}return e}function Ht(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function Vt(t,e,n){const o=t.document.querySelector(`link[type="application/annotator+${n}"][rel="${e}"]`);if(!o)throw new Error(`No application/annotator+${n} (rel="${e}") link in the document`);if(!o.href)throw new Error(`application/annotator+${n} (rel="${e}") link has no href`);return o.href}function Ut(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=Ht(e.ignoreOtherConfiguration)?{}:Bt(t.document),{get annotations(){return n.annotations||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return Vt(t,"hypothesis-client","javascript")},get group(){return n.group||function(){const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return Vt(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 Vt(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 qt(t,e){return t.hostPageSetting(e)}const Wt={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:qt},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:qt},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:Ht,getValue:qt},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},services:{allowInBrowserExt:!1,defaultValue:null,getValue:qt},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:qt},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:qt}};function jt(t="annotator",e=window){const n=Ut(e),o={};let i=function(t){const e={annotator:["clientUrl","subFrameIdentifier"],sidebar:["appType","annotations","branding","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],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=Wt[t],r=void 0!==i.defaultValue,s=!((a=Vt(e,"sidebar","html")).startsWith("http://")||a.startsWith("https://"));var a;if(!i.allowInBrowserExt&&s)return void(r&&(o[t]=i.defaultValue));const l=i.getValue(n,t);void 0!==l?o[t]=i.coerce?i.coerce(l):l:r&&(o[t]=i.defaultValue)})),o}class $t{constructor(t,e){this._port=t,this._methods=e,this._sequence=0,this._callbacks={},this._destroyed=!1,this._listeners=new Pt,this._listeners.add(this._port,"message",(t=>this._handle(t))),this._port.start()}destroy(){this._destroyed=!0,this._listeners.removeAll(),this._port.close()}call(t,...e){if(this._destroyed)return;const n=this._sequence++,o=e[e.length-1];"function"==typeof o&&(this._callbacks[n]=o,e=e.slice(0,-1));const i={arguments:e,method:t,protocol:"frame-rpc",sequence:n,version:"1.0.0"};this._port.postMessage(i)}_parseMessage({data:t}){return t&&"object"==typeof t?"frame-rpc"!==t.protocol||"1.0.0"!==t.version?null:Array.isArray(t.arguments)?t:null:null}_handle(t){const e=this._parseMessage(t);if(null!==e)if("method"in e){if(!this._methods.hasOwnProperty(e.method))return;const t=(...t)=>{const n={arguments:t,protocol:"frame-rpc",response:e.sequence,version:"1.0.0"};this._port.postMessage(n)};this._methods[e.method](...e.arguments,t)}else if("response"in e){const t=this._callbacks[e.response];delete this._callbacks[e.response],t&&t(...e.arguments)}}}class zt{constructor(){this.links=[],this.channelListeners={},this.onConnectListeners=[],this.on("connect",(t=>t()))}destroy(){this.links.forEach((t=>t.destroy())),this.links=[]}createChannel(t){const e=new $t(t,this.channelListeners);let n=!1;return e.call("connect",(()=>{n||(n=!0,this.onConnectListeners.forEach((t=>t(e))))})),this.links.push(e),e}call(t,...e){let n;const o=e[e.length-1];"function"==typeof o&&(n=o,e=e.slice(0,-1));const i=t=>e=>{throw t.destroy(),this.links=this.links.filter((e=>e!==t)),e},r=this.links.map((n=>new Promise(((o,i)=>{const r=setTimeout((()=>o(null)),1e3);try{n.call(t,...e,((t,e)=>{clearTimeout(r),t?i(t):o(e)}))}catch(t){i(t)}})).catch(i(n))));let s=Promise.all(r);return n&&(s=s.then((t=>n(null,t))).catch((t=>n(t)))),s}on(t,e){if(this.links.length>0)throw new Error(`Listener '${t}' can't be registered because a channel has already been created`);if(this.channelListeners[t])throw new Error(`Listener '${t}' already bound in Bridge`);return this.channelListeners[t]=e,this}onConnect(t){return this.onConnectListeners.push(t),this}}class Xt{constructor({hostFrame:t,source:e}){this._hostFrame=t,this._source=e,this._listeners=new Pt}destroy(){this._listeners.removeAll()}async discover(t){let e=!1;if(("guest"===this._source&&"host"===t||"guest"===this._source&&"sidebar"===t||"sidebar"===this._source&&"host"===t||"notebook"===this._source&&"sidebar"===t)&&(e=!0),!e)throw new Error("Invalid request of channel/port");return new Promise(((e,n)=>{const o=()=>{this._hostFrame.postMessage({frame1:this._source,frame2:t,type:"request"},"*")},i=setInterval(o,250),r=setTimeout((()=>{clearInterval(i),n(new Error(`Unable to establish ${this._source}-${t} communication channel`))}),1e4),s=this._listeners.add(window,"message",(n=>{const{data:o,ports:a}=n;It(o,{frame1:this._source,frame2:t,type:"offer"})&&(clearInterval(i),clearTimeout(r),this._listeners.remove(s),e(a[0]))}));o()}))}}function Yt(t){const e=t.toString(16);return 1===e.length?"0"+e:e}function Gt(t){const e=new Uint8Array(t/2);return window.crypto.getRandomValues(e),Array.from(e).map(Yt).join("")}const Zt={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=Zt[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?Zt.ctrl:0)|(t.metaKey?Zt.meta:0)|(t.altKey?Zt.alt:0)|(t.shiftKey?Zt.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 gt(Et,{classes:"LabeledIconButton AdderToolbar__button",icon:e,onClick:o,title:i?`${n} (${i})`:n,children:["number"==typeof t&>("span",{className:"hyp-u-bg-color--grey-7 AdderToolbar__badge",children:t}),gt("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"))),gt("div",{className:Z("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:[gt("div",{className:"hyp-u-layout-row AdderToolbar__actions",children:[gt(Qt,{icon:"annotate",onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),gt(Qt,{icon:"highlight",onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),o>0&>("div",{className:"hyp-u-margin--2 AdderToolbar__separator"}),o>0&>(Qt,{badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]}),gt(Tt,{name:"pointer",classes:Z("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,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(){M(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),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(){M(gt(te,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":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){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:{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){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 me(t,e="hypothesis-highlight"){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;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 ge(t,e){const n=t.parentNode;e.forEach((e=>n.insertBefore(e,t))),t.remove()}function _e(t){for(let e of t){if(e.parentNode){ge(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)})))}var we=/^\s+|\s+$/g,be=/^[-+]0x[0-9a-f]+$/i,Ce=/^0b[01]+$/i,Ee=/^0o[0-7]+$/i,Se=parseInt,Te="object"==typeof t&&t&&t.Object===Object&&t,xe="object"==typeof self&&self&&self.Object===Object&&self,Ae=Te||xe||Function("return this")(),ke=Object.prototype.toString,Ne=Math.max,Le=Math.min,Re=function(){return Ae.Date.now()};function Me(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Oe(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==ke.call(t)}(t))return NaN;if(Me(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Me(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(we,"");var n=Ce.test(t);return n||Ee.test(t)?Se(t.slice(2),n?2:8):be.test(t)?NaN:+t}var Pe=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(g,e),h?f(t):s}function m(t){var n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=r}function g(){var t=Re();if(m(t))return _(t);a=setTimeout(g,function(t){var n=e-(t-l);return u?Le(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=Re(),n=m(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return p(l);if(u)return a=setTimeout(g,e),f(l)}return void 0===a&&(a=setTimeout(g,e)),s}return e=Oe(e)||0,Me(n)&&(h=!!n.leading,r=(u="maxWait"in n)?Ne(Oe(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:_(Re())},v};class Ie{constructor(t,e,n){this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Pe((()=>{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)}}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 Fe{constructor(t,e){this._config=e,this._frameObserver=new Ie(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}=Bt(document),i=Gt(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){t.self===t?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function He(t){var e=t._scrollSettings;if(e){var n=e.maxSynchronousAlignments,o=function(t,e){var n,o,i,r,s,a,l,c=t.align,h=t.target.getBoundingClientRect(),u=c&&null!=c.left?c.left:.5,d=c&&null!=c.top?c.top:.5,f=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,m=u,g=d;if(t.isWindow(e))a=Math.min(h.width,e.innerWidth),l=Math.min(h.height,e.innerHeight),o=h.left+e.pageXOffset-e.innerWidth*m+a*m,i=h.top+e.pageYOffset-e.innerHeight*g+l*g,o-=f,i-=p,o=t.align.lockX?e.pageXOffset:o,i=t.align.lockY?e.pageYOffset:i,r=o-e.pageXOffset,s=i-e.pageYOffset;else{a=h.width,l=h.height,n=e.getBoundingClientRect();var _=h.left-(n.left-e.scrollLeft),v=h.top-(n.top-e.scrollTop);o=_+a*m-e.clientWidth*m,i=v+l*g-e.clientHeight*g,o-=f,i-=p,o=Math.max(Math.min(o,e.scrollWidth-e.clientWidth),0),i=Math.max(Math.min(i,e.scrollHeight-e.clientHeight),0),o=t.align.lockX?e.scrollLeft:o,i=t.align.lockY?e.scrollTop:i,r=o-e.scrollLeft,s=i-e.scrollTop}return{x:o,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&&He(e.scrollAncestor),void He(t);!function(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}(He.bind(null,t))}}function Ve(t){return t.self===t}function Ue(t){return"pageXOffset"in t||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function qe(){return!0}function We(t){if(t.assignedSlot)return We(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={}),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=We(t),i=1,r=e.validTarget||qe,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,Ue):Ue(o))&&(i++,a.push(o)),!(o=We(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||Ve,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&&He(e),r}(t,o,e,a[i+1],l)),null)}function l(t){--i||n&&n(t)}};function $e(t){return t.split("").reverse().join("")}function ze(t){return(t|-t)>>31&1}function Xe(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=ze(h&t.lastRowMask[n])-ze(u&t.lastRowMask[n]);return h<<=1,u<<=1,u|=s,h|=ze(o)-s,i=u|~(l|h),r=h&l,t.P[n]=i,t.M[n]=r,d}function Ye(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),n<c.length&&(c[n]=o);for(let t=0;t<=r;t+=1){o[t]=0;for(let r=0;r<i;r+=1){const s=t*i+r;if(s>=e.length)continue;e.charCodeAt(s)===n&&(o[t]|=1<<r)}}}let h=Math.max(0,Math.ceil(n/i)-1);const u=new Uint32Array(r+1);for(let t=0;t<=h;t+=1)u[t]=(t+1)*i;u[r]=e.length;for(let t=0;t<=h;t+=1)s.P[t]=-1,s.M[t]=0;for(let d=0;d<t.length;d+=1){const f=t.charCodeAt(d);let p;f<c.length?p=c[f]:(p=l.get(f),void 0===p&&(p=a));let m=0;for(let t=0;t<=h;t+=1)m=Xe(s,p,t,m),u[t]+=m;if(u[h]-m<=n&&h<r&&(1&p[h+1]||m<0)){let t;if(h+=1,s.P[h]=-1,s.M[h]=0,h===r){const n=e.length%i;t=0===n?i:n}else t=i;u[h]=u[h-1]+t-m+Xe(s,p,h,m)}else for(;h>0&&u[h]>=n+i;)h-=1;h===r&&u[h]<=n&&(u[h]<n&&o.splice(0,o.length),o.push({start:-1,end:d+1,errors:u[h]}),n=u[h])}return o}function Ge(t,e,n){return function(t,e,n){const o=$e(e);return n.map((n=>{const i=Math.max(0,n.end-e.length-n.errors);return{start:Ye($e(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,Ye(t,e,n))}function Ze(t,e,n){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 Ke(t,e){if(0===e.length||0===t.length)return 0;return 1-Ze(t,e,e.length)[0].errors/e.length}function Je(t,e,n={}){if(0===e.length)return null;const o=Math.min(256,e.length/2),i=Ze(t,e,o);if(0===i.length)return null;const r=o=>{const i=1-o.errors/e.length,r=n.prefix?Ke(t.slice(Math.max(0,o.start-n.prefix.length),o.start),n.prefix):1,s=n.suffix?Ke(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 Qe(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 tn(t,e){let n="",o=t;for(;o!==e;){if(!o)throw new Error("Node is not a descendant of root");n=Qe(o)+"/"+n,o=o.parentNode}return n="/"+n,n=n.replace(/\/$/,""),n}function en(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 nn(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=en(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 on{constructor(t,e){this.root=t,this.range=e}static fromRange(t,e){return new on(t,e)}static fromSelector(t,e){const n=nn(e.startContainer,t);if(!n)throw new Error("Failed to resolve startContainer XPath");const o=nn(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 on(t,s)}toRange(){return this.range}toSelector(){const t=ce.fromRange(this.range).toRange(),e=ce.fromRange(t),n=tn(e.start.element,this.root),o=tn(e.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:e.start.offset,endContainer:o,endOffset:e.end.offset}}}class rn{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 rn(t,n.start.offset,n.end.offset)}static fromSelector(t,e){return new rn(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 sn{constructor(t,e,n={}){this.root=t,this.exact=e,this.context=n}static fromRange(t,e){const n=t.textContent,o=ce.fromRange(e).relativeTo(t),i=o.start.offset,r=o.end.offset;return new sn(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 sn(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=Je(this.root.textContent,this.exact,{...this.context,hint:t.hint});if(!e)throw new Error("Quote not found");return new rn(this.root,e.start,e.end)}}async function an(t,e={}){return t.toRange(e)}function ln(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};let a=Promise.reject("unable to anchor");return r&&(a=a.catch((()=>an(on.fromSelector(t,r),n).then(s)))),o&&(a=a.catch((()=>an(rn.fromSelector(t,o),n).then(s)))),i&&(a=a.catch((()=>an(sn.fromSelector(t,i),n)))),a}function cn(t,e){const n=[on,rn,sn],o=[];for(let i of n)try{const n=i.fromRange(t,e);o.push(n.toSelector())}catch(t){continue}return o}function hn(t,e=document.baseURI){return new URL(t,e).href.toString().replace(/#.*/,"")}class un{constructor(t={}){this.document=t.document||document}uri(){let t=decodeURIComponent(this._getDocumentHref());const e=this._getLinks();for(let n of e)"canonical"===n.rel&&(t=n.href);return t}getDocumentMetadata(){const t={title:document.title,link:[],dc:this._getMetaTags("dc","name","."),eprints:this._getMetaTags("eprints","name","."),facebook:this._getMetaTags("og","property",":"),highwire:this._getMetaTags("citation","name","_"),prism:this._getMetaTags("prism","name","."),twitter:this._getMetaTags("twitter","name",":")},e=this._getFavicon();e&&(t.favicon=e),t.title=this._getTitle(t),t.link=this._getLinks(t);const n=t.link.find((t=>t.href.startsWith("urn:x-dc")));return n&&(t.documentFingerprint=n.href),t}_getMetaTags(t,e,n){const o={};for(let i of Array.from(this.document.querySelectorAll("meta"))){const r=i.getAttribute(e),{content:s}=i;if(r){const e=r.match(RegExp(`^${t}${n}(.+)$`,"i"));if(e){const t=e[1];o[t]?o[t].push(s):o[t]=[s]}}}return o}_getTitle(t){return t.highwire.title?t.highwire.title[0]:t.eprints.title?t.eprints.title[0]:t.prism.title?t.prism.title[0]:t.facebook.title?t.facebook.title[0]:t.twitter.title?t.twitter.title[0]:t.dc.title?t.dc.title[0]:this.document.title}_getLinks(t={dc:{},highwire:{}}){const e=[{href:this._getDocumentHref()}],n=Array.from(this.document.querySelectorAll("link"));for(let t of n)if(["alternate","canonical","bookmark","shortlink"].includes(t.rel)){if("alternate"===t.rel){if(t.type&&t.type.match(/^application\/(rss|atom)\+xml/))continue;if(t.hreflang)continue}try{const n=this._absoluteUrl(t.href);e.push({href:n,rel:t.rel,type:t.type})}catch(t){}}for(let n of Object.keys(t.highwire)){const o=t.highwire[n];if("pdf_url"===n)for(let t of o)try{e.push({href:this._absoluteUrl(t),type:"application/pdf"})}catch(t){}if("doi"===n)for(let t of o)"doi:"!==t.slice(0,4)&&(t=`doi:${t}`),e.push({href:t})}for(let n of Object.keys(t.dc)){const o=t.dc[n];if("identifier"===n)for(let t of o)"doi:"===t.slice(0,4)&&e.push({href:t})}const o=t.dc["relation.ispartof"],i=t.dc.identifier;if(o&&i){const t=o[o.length-1],n=i[i.length-1],r="urn:x-dc:"+encodeURIComponent(t)+"/"+encodeURIComponent(n);e.push({href:r})}return e}_getFavicon(){let t=null;for(let e of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(e.rel))try{t=this._absoluteUrl(e.href)}catch(t){}return t}_absoluteUrl(t){return hn(t,this.document.baseURI)}_getDocumentHref(){const{href:t}=this.document.location,e=["http:","https:","file:"],n=new URL(t).protocol;return e.includes(n)?t:this.document.baseURI&&e.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:t}}class dn{constructor(t=document.body){this.container=t,this.anchor=ln,this.describe=cn,this._htmlMeta=new un}canAnnotate(){return!0}destroy(){}contentContainer(){return this.container}fitSideBySide(){return!1}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}scrollToAnchor(t){const e=t.highlights;return new Promise((t=>{je(e[0],t)}))}}let fn={};function pn(...t){const e=t.join();e in fn||(console.warn(...t),fn[e]=!0)}pn.reset=()=>{fn={}};const mn=0,gn=3,_n=new Map,vn=new Map;function yn(t,e){return`${t}:${e}`}function wn(t){var e;const n="closest"in t?t:t.parentElement;return null!==(e=null==n?void 0:n.closest(".textLayer"))&&void 0!==e?e:null}function bn(){return PDFViewerApplication.pdfViewer}async function Cn(t){const e=bn();let n=e.getPageView(t);return n&&n.pdfPage||(n=await new Promise((n=>{const o=()=>{e.eventBus?e.eventBus.off("pagesloaded",o):document.removeEventListener("pagesloaded",o),n(e.getPageView(t))};e.eventBus?e.eventBus.on("pagesloaded",o):document.addEventListener("pagesloaded",o)}))),n}function En(t){const e=_n.get(t);if(e)return e;const n=(async()=>{const e=await Cn(t);let n=(await e.pdfPage.getTextContent({normalizeWhitespace:!0})).items;return n.length>0&&!("hasEOL"in n[0])&&(n=n.filter((t=>/\S/.test(t.str)))),n.map((t=>t.str)).join("")})();return _n.set(t,n),n}async function Sn(t){const e=bn();let n=0,o=0,i="";for(let r=0;r<e.pagesCount;r++)if(i=await En(r),n=o,o+=i.length,o>=t)return{index:r,offset:n,text:i};return{index:e.pagesCount-1,offset:n,text:i}}async function Tn(t,e,n){const[o,i]=await Promise.all([Cn(t),En(t)]);if(o.renderingState===gn&&o.textLayer&&o.textLayer.renderingDone){const t=o.textLayer.textLayerDiv;i!==t.textContent&&pn("PDF text layer content does not match page text. This will cause anchoring misalignment.");const r=new le(t,e),s=new le(t,n);return new ce(r,s).toRange()}const r=function(t){let e=t.querySelector(".annotator-placeholder");return e||(e=document.createElement("span"),e.classList.add("annotator-placeholder"),e.textContent="Loading annotations...",t.appendChild(e),e)}(o.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function xn(t){const e=[];let n="";for(let o=0;o<t.length;o++){const i=t[o];" "!==i&&"\t"!==i&&"\n"!==i&&(n+=i,e.push(o))}return[n,e]}async function An(t,e){const n=e.find((t=>"TextQuoteSelector"===t.type));if(!n)throw new Error("No quote selector found");const o=e.find((t=>"TextPositionSelector"===t.type));if(o){try{const{index:t,offset:e,text:i}=await Sn(o.start),r=o.start-e,s=o.end-e,a=i.substring(r,s);if(n.exact!==a)throw new Error("quote mismatch");return await Tn(t,r,s)}catch{}try{const t=yn(n.exact,o.start),e=vn.get(t);if(e){const{pageIndex:t,anchor:n}=e;return await Tn(t,n.start,n.end)}}catch{}}return async function(t,e){const n=bn().pagesCount,o=Array(n).fill(0).map(((t,e)=>e));let i,r;if(e){const{index:t,offset:n}=await Sn(e);i=t,r=e-n,o.sort(((e,n)=>Math.abs(e-t)-Math.abs(n-t)))}const[s]=void 0!==t.prefix?xn(t.prefix):[],[a]=void 0!==t.suffix?xn(t.suffix):[],[l]=xn(t.exact);let c;for(let t of o){const e=await En(t),[n,o]=xn(e);let h;if(void 0!==i&&void 0!==r){let n;for(n=t<i?e.length:t===i?r:0,h=0;h<o.length&&o[h]<n;)++h}const u=Je(n,l,{prefix:s,suffix:a,hint:h});if(u&&(!c||u.score>c.match.score)){c={page:t,match:{start:o[u.start],end:o[u.end-1]+1,score:u.score}};const e=n.slice(u.start,u.end)===l,i=void 0!==s&&n.slice(Math.max(0,u.start-s.length),u.start)===s,r=void 0!==a&&n.slice(u.end,a.length)===a,h=void 0!==s||void 0!==a;if(e&&(i||r||!h))break}}if(c){const{page:n,match:o}=c;if(e){const i=yn(t.exact,e);vn.set(i,{pageIndex:n,anchor:o})}return Tn(n,o.start,o.end)}throw new Error("Quote not found")}(n,null==o?void 0:o.start)}function kn(t){try{t=ce.fromRange(t).toRange()}catch{throw new Error("Selection does not contain text")}const e=wn(t.startContainer),n=wn(t.endContainer);if(!e||!n)throw new Error("Selection is outside page text");if(e!==n)throw new Error("Selecting across page breaks is not supported");return[t,e]}async function Nn(t,e){const[n,o]=kn(e),i=le.fromPoint(n.startContainer,n.startOffset).relativeTo(o),r=le.fromPoint(n.endContainer,n.endOffset).relativeTo(o),s=function(t){let e=0;for(;t.previousSibling;)++e,t=t.previousSibling;return e}(o.parentNode),a=await async function(t){if(t>=bn().pagesCount)throw new Error("Invalid page index");let e=0;for(let n=0;n<t;n++)e+=(await En(n)).length;return e}(s);return[{type:"TextPositionSelector",start:a+i.offset,end:a+r.offset},sn.fromRange(t,n).toSelector()]}function Ln(){return gt("div",{className:"WarningBanner WarningBanner--notice",children:[gt("div",{className:"WarningBanner__type",children:gt(vt,{name:"caution",className:"WarningBanner__icon"})}),gt("div",{className:"WarningBanner__message",children:[gt("strong",{children:"This PDF does not contain selectable text:"})," ",gt("a",{target:"_blank",rel:"noreferrer",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})}function Rn(t,e,n){return t+n*(e-t)}async function Mn(t,e,{maxDuration:n=500}={}){const o=t.scrollTop,i=e,r=Date.now(),s=Math.min(Math.abs(i-o)/3,n);let a=0;for(;a<1;)await new Promise((t=>{requestAnimationFrame(t)})),a=Math.min(1,(Date.now()-r)/s),t.scrollTop=Rn(o,i,a)}class On{constructor(t){this._loaded=function(t){return t.initializedPromise?t.initializedPromise:t.initialized?Promise.resolve():new Promise((e=>{const n=setInterval((()=>{t.initialized&&(clearTimeout(n),e())}),5)}))}(t).then((()=>t.downloadComplete?t:new Promise((e=>{const n=()=>{t.eventBus?(t.eventBus.off("documentload",n),t.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),e(t)};t.eventBus?(t.eventBus.on("documentloaded",n),t.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))))}getUri(){return this._loaded.then((t=>{let e=Dn(t);return e||(e=In(Pn(t))),e}))}async getMetadata(){const t=await this._loaded,{info:e,contentDispositionFilename:n,metadata:o}=await t.pdfDocument.getMetadata(),i=Pn(t),r=Dn(t);let s;s=null!=o&&o.has("dc:title")&&"Untitled"!==o.get("dc:title")?o.get("dc:title"):null!=e&&e.Title?e.Title:n||(r?function(t){const e=new URL(t).pathname.split("/");return e[e.length-1]}(r):"");const a=[{href:In(i)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:i}}}function Pn(t){return Array.isArray(t.pdfDocument.fingerprints)?t.pdfDocument.fingerprints[0]:t.pdfDocument.fingerprint}function In(t){return`urn:x-pdf:${t}`}function Dn(t){if(!t.url)return null;const e=hn(t.url);return 0!==e.indexOf("file://")?e:null}function Fn(t){var e;const n=null===(e=t.highlights)||void 0===e?void 0:e[0];return n&&he(n)}function Bn(t){return new Promise((e=>setTimeout(e,t)))}class Hn{constructor(t,e={}){var n,o,i;this.annotator=t;const r=window,s=r.PDFViewerApplication;this.pdfViewer=s.pdfViewer,this.pdfViewer.viewer.classList.add("has-transparent-text-layer"),this.pdfContainer=null!==(n=null===(o=s.appConfig)||void 0===o?void 0:o.appContainer)&&void 0!==n?n:document.body,this.pdfMetadata=new On(s),this.observer=new MutationObserver(Pe((()=>this._update()),100)),this.observer.observe(this.pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=null!==(i=e.reanchoringMaxWait)&&void 0!==i?i:3e3,this._warningBanner=null,this._checkForSelectableText(),this._updateAnnotationLayerVisibility=()=>{const t=r.getSelection();this.pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new Pt,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){var t;this._listeners.removeAll(),this.pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this.observer.disconnect(),null===(t=this._warningBanner)||void 0===t||t.remove(),this._destroyed=!0}uri(){return this.pdfMetadata.getUri()}getMetadata(){return this.pdfMetadata.getMetadata()}anchor(t,e){return An(0,e)}canAnnotate(t){return function(t){try{return kn(t),!0}catch{return!1}}(t)}describe(t,e){return Nn(t,e)}async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._destroyed)try{const t=await async function(){const t=bn();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await En(n)).trim().length>0){e=!0;break}return e}();this._toggleNoSelectableTextWarning(!t)}catch(t){console.warn("Unable to check for text in PDF:",t)}}_toggleNoSelectableTextWarning(t){const e=document.querySelector("#outerContainer");var n;if(!t)return null===(n=this._warningBanner)||void 0===n||n.remove(),this._warningBanner=null,void(e.style.height="");this._warningBanner=document.createElement("hypothesis-banner"),document.body.prepend(this._warningBanner);const o=ne(this._warningBanner);M(gt(Ln,{}),o);const i=this._warningBanner.getBoundingClientRect().height;e.style.height=`calc(100% - ${i}px)`}_update(){const t=[],e=this.pdfViewer.pagesCount;for(let t=0;t<e;t++){var n;const e=this.pdfViewer.getPageView(t);if(null!=e&&null!==(n=e.textLayer)&&void 0!==n&&n.renderingDone)switch(e.renderingState){case mn:e.textLayer=null;break;case gn:o=e.div,i=void 0,null===(i=o.querySelector(".annotator-placeholder"))||void 0===i||i.remove()}}var o,i;for(let e of this.annotator.anchors)if(e.highlights){if(t.includes(e.annotation))continue;for(let n=0;n<e.highlights.length;n++){const o=e.highlights[n];if(!document.body.contains(o)){e.highlights.splice(n,1),delete e.range,t.push(e.annotation);break}}}t.map((t=>this.annotator.anchor(t)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(t){const e=window.innerWidth-t.width,n=t.expanded&&e>=680,o=n?t.width:t.toolbarWidth;this.pdfContainer.style.width=`calc(100% - ${o}px)`;const i=this.pdfViewer.currentScaleValue;return"auto"!==i&&"page-fit"!==i&&"page-width"!==i||(this.pdfViewer.currentScaleValue=i),this.pdfViewer.update(),n}async scrollToAnchor(t){const e=t.annotation,n=Fn(t),o=this._anchorOffset(t);if(null!==o&&(await Mn(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await Mn(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n;const o=Date.now();let i;do{i=this.annotator.anchors.find((e=>e.annotation===t)),i&&!Fn(i)||(i=null,await Bn(20))}while(!i&&Date.now()-o<e);return null!==(n=i)&&void 0!==n?n:null}_anchorOffset(t){if(!t.highlights)return null;return function(t,e){let n=0;for(;t!==e&&e.contains(t);)n+=t.offsetTop,t=t.offsetParent;return n}(t.highlights[0],this.contentContainer())}}function Vn(t,e){return t?{left:Math.min(t.left,e.left),right:Math.max(t.right,e.right),top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom)}:e}class Un{constructor(t,e,n){if(e.length!==n.length)throw new Error("Char boxes length does not match text length");const o=t.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,t.nextSibling),o.style.position="relative",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.mixBlendMode="multiply";const r="sans-serif";i.style.fontSize="16px",i.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font="16px sans-serif";let a=null,l="";const c=[];let h=0;const u=()=>{if(!a)return;const t=document.createElement("span");t.style.position="absolute",t.style.color="transparent",t.style.transformOrigin="top left",t.textContent=l,i.append(t),i.append(" "),h||(h=t.getBoundingClientRect().height),c.push({span:t,box:a,width:s.measureText(l).width,height:h}),a=null,l=""};for(let t=0;t<e.length;t++){const o=n[t];if(/\s/.test(o)){u();continue}const i=e[t];a=Vn(a,i),l+=o}u();const d=()=>{const{width:e,height:n}=t.getBoundingClientRect();i.style.width=e+"px",i.style.height=n+"px";for(let{span:t,box:o,width:i,height:r}of c){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=Pe(d,{maxWait:50}),this._listeners=new Pt,this._listeners.add(window,"resize",this._updateBoxSizes)}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateBoxSizes.cancel()}}function qn(t=document){return t.querySelector("mosaic-book")}class Wn{constructor(t){const e=qn();if(!e)throw new Error("Book container element not found");const n=e.shadowRoot,o=()=>{const e=n.querySelector("iframe");e&&t.injectClient(e)};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(n,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}canAnnotate(){return!1}async anchor(){return new Range}describe(){throw new Error("This frame cannot be annotated")}contentContainer(){return document.body}fitSideBySide(){return!1}async getMetadata(){return{title:"",link:[]}}async uri(){return document.location.href}async scrollToAnchor(){}}class jn{constructor(t=document.body){this._htmlIntegration=new dn(t),this._listeners=new Pt;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 Un(n,o.glyphs.glyphs.map((t=>({left:t.l/100,right:t.r/100,top:t.t/100,bottom:t.b/100}))),o.words),this._textLayer.container.style.zIndex="100")}canAnnotate(){return!0}destroy(){var t;null===(t=this._textLayer)||void 0===t||t.destroy(),this._listeners.removeAll(),this._htmlIntegration.destroy()}anchor(t,e){return this._htmlIntegration.anchor(t,e)}describe(t,e){return this._htmlIntegration.describe(t,e)}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(){return!1}async getMetadata(){return{title:document.title,link:[]}}async uri(){const t=new URL(document.location.href);return t.search="",t.toString()}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function $n(t){if("undefined"!=typeof PDFViewerApplication)return new Hn(t);const e=function(t=window){var e;if(qn(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&qn(n)?"content":null}();return"container"===e?new Wn(t):"content"===e?new jn:new dn}class zn{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 Pt,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 Xn(){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);t&&o.add(t),i=i.parentNode}})),[...o]}(window.getSelection().getRangeAt(0),(t=>t._annotation));return t}function Yn(t){const e=function(t){let e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;const n=[];for(;e;)e.classList.contains("hypothesis-highlight")&&n.push(e),e=e.parentElement;return n}(t).map((t=>t._annotation)).filter((t=>void 0!==t));return e}function Gn(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}class Zn{constructor(t,e,n={},o=window){this.element=t,this._emitter=e.createEmitter(),this._hostFrame=o,this._highlightsVisible=!1,this._isAdderVisible=!1,this._adder=new ie(this.element,{onAnnotate:async()=>{await this.createAnnotation(),document.getSelection().removeAllRanges()},onHighlight:async()=>{await this.createAnnotation({highlight:!0}),document.getSelection().removeAllRanges()},onShowAnnotations:t=>{this.selectAnnotations(t)}}),this._selectionObserver=new zn((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._frameIdentifier=n.subFrameIdentifier||null,this._portFinder=new Xt({hostFrame:this._hostFrame,source:"guest"}),this._sidebarRPC=new zt,this._connectSidebarEvents(),this._hypothesisInjector=new Fe(this.element,n),this._integration=$n(this),this._sideBySideActive=!1,this._listeners=new Pt,this._setupElementEvents(),this._focusedAnnotations=new Set,this._listeners.add(window,"unload",(()=>this._notifyGuestUnload()))}_setupElementEvents(){const t=t=>{this._sideBySideActive||Yn(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:o}=t,i=Yn(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=Yn(t);e.length&&this._highlightsVisible&&this._focusAnnotations(e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._focusAnnotations([])})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async injectClient(t){return this._hypothesisInjector.injectClient(t)}async getDocumentInfo(){const[t,e]=await Promise.all([this._integration.uri(),this._integration.getMetadata()]);return{uri:hn(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 _connectSidebarEvents(){this._sidebarRPC.on("focusAnnotations",((t=[])=>{this._focusedAnnotations.clear(),t.forEach((t=>this._focusedAnnotations.add(t)));for(let e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);ve(e.highlights,n)}})),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=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("getDocumentInfo",(t=>{this.getDocumentInfo().then((e=>t(null,e))).catch((e=>t(e)))})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t)))));const t=await this._portFinder.discover("sidebar");this._sidebarRPC.createChannel(t)}destroy(){this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),function(t){_e(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy(),this._emitter.destroy(),this._sidebarRPC.destroy()}_notifyGuestUnload(){const t={type:"hypothesisGuestUnloaded",frameIdentifier:this._frameIdentifier};this._hostFrame.postMessage(t,"*")}async anchor(t){const e=t=>{const e=Gn(t);if(!e)return;const n=me(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),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})));for(let t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){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){this.anchors=t,e&&this._emitter.publish("anchorsChanged",this.anchors)}async createAnnotation({highlight:t=!1}={}){var e;const n=null!==(e=this.selectedRanges)&&void 0!==e?e:[];this.selectedRanges=null;const o=await this.getDocumentInfo(),i=this.element,r=(await Promise.all(n.map((t=>this._integration.describe(i,t))))).map((t=>({source:o.uri,selector:t}))),s={uri:o.uri,document:o.metadata,target:r,$highlight:t,$tag:"a:"+Gt(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),s}_focusAnnotations(t){const e=t.map((t=>t.$tag));this._sidebarRPC.call("focusAnnotations",e)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=ue(e),o=pe(e);o?(this.selectedRanges=[t],this._emitter.publish("hasSelectionChanged",!0),this._adder.annotationsForSelection=Xn(),this._isAdderVisible=!0,this._adder.show(o,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._emitter.publish("hasSelectionChanged",!1)}selectAnnotations(t,e=!1){const n=t.map((t=>t.$tag));e?this._sidebarRPC.call("toggleAnnotationSelection",n):this._sidebarRPC.call("showAnnotations",n),this._sidebarRPC.call("openSidebar")}scrollToAnchor(t){return this._integration.scrollToAnchor(t)}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}contentContainer(){return this._integration.contentContainer()}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get focusedAnnotationTags(){return this._focusedAnnotations}}function Kn(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function Jn(t){var e;const n={};for(let[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.version="1.934.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),(null===(e=n.services)||void 0===e?void 0:e.length)>0){const t=n.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return n}function Qn({config:t,groupId:e}){return gt("iframe",{title:"Hypothesis annotation notebook",className:"NotebookIframe",allowFullScreen:!0,src:Kn(t.notebookAppUrl,{...Jn(t),group:e})})}function to({eventBus:t,config:e}){const[n,o]=rt(0),[i,r]=rt(!0),[s,a]=rt(null),l=lt(""),c=lt(null);st((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),st((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),st((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:gt("div",{className:Z("NotebookModal__outer",{"is-hidden":i}),children:gt("div",{className:"NotebookModal__inner",children:[gt("div",{className:"NotebookModal__close-button-container",children:gt(Ct,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),gt(Qn,{config:e,groupId:s},n)]})})}class eo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=ne(this._outerContainer),M(gt(to,{eventBus:e,config:n}),this.shadowRoot)}destroy(){M(null,this.shadowRoot),this._outerContainer.remove()}}var no={exports:{}};
|
|
7
7
|
/*! Hammer.JS - v2.0.7 - 2016-04-22
|
|
8
8
|
* http://hammerjs.github.io/
|
|
9
9
|
*
|