hypothesis 1.1720.0 → 1.1722.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-template.js +1 -1
- package/build/boot.js +1 -1
- package/build/manifest.json +5 -5
- package/build/scripts/annotator.bundle.js +17 -17
- package/build/scripts/annotator.bundle.js.map +1 -1
- package/build/scripts/sidebar.bundle.js +513 -513
- package/build/scripts/sidebar.bundle.js.map +1 -1
- package/package.json +1 -1
package/build/boot-template.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?3c95c6","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?a8ba5d","styles/annotator.css":"styles/annotator.css?62a3c0","styles/annotator.css.map":"styles/annotator.css.map?2a66f1","styles/highlights.css":"styles/highlights.css?ef86d1","styles/highlights.css.map":"styles/highlights.css.map?6ce8dd","styles/katex.min.css":"styles/katex.min.css?e31f39","styles/katex.min.css.map":"styles/katex.min.css.map?0511b4","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?d58df4","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?5a12c5","styles/sidebar.css":"styles/sidebar.css?aac3b6","styles/sidebar.css.map":"styles/sidebar.css.map?fdf923","styles/ui-playground.css":"styles/ui-playground.css?e93149","styles/ui-playground.css.map":"styles/ui-playground.css.map?c01a36","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?ea08c1","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?535e02","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?a9e548","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?6a3a7e"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.esModule,n=void 0===o||o,a=r.forceReload,i=void 0!==a&&a,l=s.createElement("script");n&&(l.type="module"),i&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function o(s,t,r,o){var n=s.createElement("link");n.rel=t,n.href=o,n.type="application/annotator+".concat(r),e(n),s.head.appendChild(n)}function n(s,t,r){var o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).crossOrigin,n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,(o||"fetch"===t)&&(n.crossOrigin="anonymous",n.removeAttribute=()=>{}),e(n),s.head.appendChild(n)}function a(s,e){return s.assetRoot+"build/"+s.manifest[e]}function i(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),r=0;r<t.length;r++){var o=void 0;try{o=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),o={}}Object.assign(e,o)}return e}(document),c=i(l.assetRoot||"__ASSET_ROOT__");if(document.querySelector("hypothesis-app")){!function(s,e){n(s,"fetch",e.apiUrl),n(s,"fetch",e.apiUrl+"links");for(var o=0,i=["scripts/sidebar.bundle.js"];o<i.length;o++)r(s,a(e,i[o]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,a(e,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=i(d.notebookAppUrl||"__NOTEBOOK_APP_URL__"),h=i(d.profileAppUrl||"__PROFILE_APP_URL__"),y=i(d.sidebarAppUrl||"__SIDEBAR_APP_URL__");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){o(s,"sidebar","html",e.sidebarAppUrl),o(s,"notebook","html",e.notebookAppUrl),o(s,"profile","html",e.profileAppUrl),n(s,"style",a(e,"styles/annotator.css"),{crossOrigin:!0}),o(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)r(s,a(e,l[i]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)t(s,a(e,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?3c95c6","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?a8ba5d","styles/annotator.css":"styles/annotator.css?62a3c0","styles/annotator.css.map":"styles/annotator.css.map?2a66f1","styles/highlights.css":"styles/highlights.css?ef86d1","styles/highlights.css.map":"styles/highlights.css.map?6ce8dd","styles/katex.min.css":"styles/katex.min.css?e31f39","styles/katex.min.css.map":"styles/katex.min.css.map?0511b4","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?d58df4","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?5a12c5","styles/sidebar.css":"styles/sidebar.css?aac3b6","styles/sidebar.css.map":"styles/sidebar.css.map?fdf923","styles/ui-playground.css":"styles/ui-playground.css?e93149","styles/ui-playground.css.map":"styles/ui-playground.css.map?c01a36","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?ea08c1","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?535e02","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?a9e548","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?6a3a7e"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.esModule,n=void 0===o||o,a=r.forceReload,i=void 0!==a&&a,l=s.createElement("script");n&&(l.type="module"),i&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function o(s,t,r,o){var n=s.createElement("link");n.rel=t,n.href=o,n.type="application/annotator+".concat(r),e(n),s.head.appendChild(n)}function n(s,t,r){var o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).crossOrigin,n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,(o||"fetch"===t)&&(n.crossOrigin="anonymous",n.removeAttribute=()=>{}),e(n),s.head.appendChild(n)}function a(s,e){return s.assetRoot+"build/"+s.manifest[e]}function i(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),r=0;r<t.length;r++){var o=void 0;try{o=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),o={}}Object.assign(e,o)}return e}(document),c=i(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1722.0/");if(document.querySelector("hypothesis-app")){!function(s,e){n(s,"fetch",e.apiUrl),n(s,"fetch",e.apiUrl+"links");for(var o=0,i=["scripts/sidebar.bundle.js"];o<i.length;o++)r(s,a(e,i[o]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,a(e,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=i(d.notebookAppUrl||"https://hypothes.is/notebook"),h=i(d.profileAppUrl||"https://hypothes.is/user-profile"),y=i(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){o(s,"sidebar","html",e.sidebarAppUrl),o(s,"notebook","html",e.notebookAppUrl),o(s,"profile","html",e.profileAppUrl),n(s,"style",a(e,"styles/annotator.css"),{crossOrigin:!0}),o(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)r(s,a(e,l[i]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)t(s,a(e,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
package/build/manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?3c95c6",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?a8ba5d",
|
|
4
4
|
"styles/annotator.css": "styles/annotator.css?62a3c0",
|
|
5
|
-
"styles/highlights.css": "styles/highlights.css?ef86d1",
|
|
6
5
|
"styles/annotator.css.map": "styles/annotator.css.map?2a66f1",
|
|
6
|
+
"styles/highlights.css": "styles/highlights.css?ef86d1",
|
|
7
7
|
"styles/highlights.css.map": "styles/highlights.css.map?6ce8dd",
|
|
8
8
|
"styles/katex.min.css": "styles/katex.min.css?e31f39",
|
|
9
9
|
"styles/katex.min.css.map": "styles/katex.min.css.map?0511b4",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"styles/sidebar.css.map": "styles/sidebar.css.map?fdf923",
|
|
14
14
|
"styles/ui-playground.css": "styles/ui-playground.css?e93149",
|
|
15
15
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?c01a36",
|
|
16
|
-
"scripts/
|
|
17
|
-
"scripts/
|
|
16
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?ea08c1",
|
|
17
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?535e02",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?a9e548",
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?6a3a7e"
|
|
20
20
|
}
|
|
@@ -58,14 +58,14 @@ var i,r;return n}function nn(e,t=document.documentElement,n=new DOMRect(0,0,wind
|
|
|
58
58
|
return Vt(t,e)?t[e]:Vt(n,e)?n[e]:void 0}return{get annotations(){return rn(n.annotations)||function(){const t=e.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get clientUrl(){return on(e,"hypothesis-client","javascript")},get group(){return rn(n.group)||function(){const t=e.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get notebookAppUrl(){return on(e,"notebook","html")},get profileAppUrl(){return on(e,"profile","html")},get showHighlights(){return function(){const e=o("showHighlights");switch(e){case"always":case"never":case"whenSidebarOpen":return e;case!0:return"always";case!1:return"never";default:return"always"}}()},get sidebarAppUrl(){return on(e,"sidebar","html")},get query(){return rn(n.query)||function(){const t=e.location.href.match(/#annotations:(query|q):(.+)$/i);if(t)try{return decodeURIComponent(t[2])}catch{}return null}()},get sideBySide(){return function(){const e=o("sideBySide");if(!function(e){
|
|
59
59
|
return null!==e&&"object"==typeof e}(e))return{mode:"auto"};const t="mode"in e&&function(e){return"string"==typeof e&&["auto","manual"].includes(e)}(e.mode)?e.mode:"auto";return"auto"===t?{mode:t}:{mode:t,isActive:"isActive"in e&&"function"==typeof e.isActive?e.isActive:void 0}}()},hostPageSetting:o}}const an=(e,t)=>e.hostPageSetting(t),ln={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:an},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:an},bucketContainerSelector:{defaultValue:null,allowInBrowserExt:!1,getValue:an},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.clientUrl},contentInfoBanner:{allowInBrowserExt:!1,defaultValue:null,getValue:an},contentReady:{allowInBrowserExt:!0,defaultValue:null,getValue:an},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:an},group:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.group},focus:{allowInBrowserExt:!1,
|
|
60
60
|
defaultValue:null,getValue:an},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:an},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:an},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:an},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:Ht,getValue:an},query:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:an},services:{allowInBrowserExt:!1,defaultValue:null,getValue:an},showHighlights:{allowInBrowserExt:!1,defaultValue:"always",getValue:e=>e.showHighlights},notebookAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.notebookAppUrl},profileAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.profileAppUrl},sidebarAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.sidebarAppUrl},subFrameIdentifier:{allowInBrowserExt:!0,defaultValue:null,getValue:an},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:an},sideBySide:{
|
|
61
|
-
allowInBrowserExt:!0,getValue:e=>e.sideBySide}};function cn(e,t=window){const n=sn(t),o={};for(const r of function(e){const t={annotator:["clientUrl","contentInfoBanner","contentReady","subFrameIdentifier","sideBySide"],sidebar:["appType","annotations","branding","bucketContainerSelector","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"],profile:["profileAppUrl"]};return"all"===e?Object.values(t).flat():t[e]}(e)){const e=ln[r],s=void 0!==e.defaultValue,a=!((i=on(t,"sidebar","html")).startsWith("http://")||i.startsWith("https://"));if(!e.allowInBrowserExt&&a){s&&(o[r]=e.defaultValue)
|
|
62
|
-
if(!(e instanceof KeyboardEvent))return!1;const n=t.split("+").map((e=>e.toLowerCase()));let o=0,i=null;for(const e of n){const t=hn[e];if(t)o|=t;else{if(null!==i)throw new Error("Multiple non-modifier keys specified");i=e}}if(!i)throw new Error(`Invalid shortcut: ${t}`);return((e.ctrlKey?hn.ctrl:0)|(e.metaKey?hn.meta:0)|(e.altKey?hn.alt:0)|(e.shiftKey?hn.shift:0))===o&&e.key.toLowerCase()===i}function un(e,t,{rootElement:n}={}){ne((()=>{if(e)return function(e,t,{rootElement:n=document.documentElement??void 0}={}){const o=n=>{dn(n,e)&&t(n)};return n?(n.addEventListener("keydown",o),()=>n.removeEventListener("keydown",o)):()=>{}}(e,t,{rootElement:n})}),[e,t,n])}const fn=(e=window)=>e.matchMedia("(pointer: coarse)").matches;function pn({badgeCount:e}){return Se("span",{className:Ne("rounded px-1 py-0.5","bg-current"),children:Se("span",{
|
|
63
|
-
className:Ne("absolute left-1/2 -translate-x-1/2 z-2","fill-white text-grey-3",{"top-0 -translate-y-full":"up"===e}),children:Se("up"===e?Ge:Ke,{})})}function _n({badgeCount:e,icon:t,label:n,onClick:o,shortcut:i}){un(i,o);const r=i?`${n} (${i})`:n;return Se(tt,{classes:Ne("text-grey-7","group-hover:text-grey-5","hover:group-hover:text-grey-9"),onClick:o,title:r,size:"custom",variant:"custom",children:Se("div",{className:Ne("flex flex-col items-center gap-y-1 py-2.5 px-2","text-annotator-sm leading-none"),children:[t&&Se(t,{className:"text-annotator-lg",title:r}),"number"==typeof e&&Se(pn,{badgeCount:e}),Se("span",{"data-testid":"adder-button-label",children:n})]})})}function mn({annotationCount:e,isVisible:t}){return Se("div",{className:"sr-only",children:[Se("span",{"aria-live":"polite","aria-atomic":"true",role:"status","data-testid":"annotation-count-announce",children:e>0&&Se("span",{
|
|
64
|
-
"data-testid":"annotate-shortcuts-announce",children:t&&Se(b,{children:[e>0&&Se("li",{children:["Press ","'S'"," to show annotations."]}),Se("li",{children:["Press ","'A'"," to annotate."]}),Se("li",{children:["Press ","'H'"," to highlight."]})]})})]})}function wn({arrowDirection:e,isVisible:t,onCommand:n,annotationCount:o=0}){const i=t?"a":null,r=t?"h":null,s=t?"s":null;return un(t?"Escape":null,(()=>n("hide"))),Se("div",{className:Ne("all-initial","border border-solid border-grey-3","absolute select-none bg-white rounded shadow-intense","opacity-5",{"animate-adder-pop-up":"up"===e&&t,"animate-adder-pop-down":"down"===e&&t}),"data-component":"AdderToolbar",dir:"ltr",style:{visibility:t?"visible":"hidden"},children:[Se("div",{className:Ne("flex group"),children:[Se(_n,{icon:Ie,onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),Se(_n,{icon:$e,onClick:()=>n("highlight"),label:"Highlight",shortcut:r
|
|
65
|
-
badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]})]}),Se(gn,{arrowDirection:e}),Se(mn,{annotationCount:o,isVisible:t})]})}let bn;function yn(e){const t=e.attachShadow({mode:"open"}),n=function(e){const t=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]')?.href;if(!t)return Promise.resolve();const n=document.createElement("link");if(n.rel="stylesheet",n.href=t,n.crossOrigin="anonymous",n.removeAttribute=()=>{},e.appendChild(n),void 0===bn){bn=new CSSStyleSheet;const e=bn;n.addEventListener("load",(()=>{if(n.sheet){for(const t of n.sheet.rules)t instanceof CSSPropertyRule&&e.insertRule(t.cssText);document.adoptedStyleSheets.push(e)}}),{once:!0})}return new Promise((e=>{n.addEventListener("load",(()=>e()))}))}(t);return{shadowRoot:t,stylesLoaded:n}}class vn{constructor(e,t){const n=`hypothesis-${e}`;this._element=document.createElement(n)
|
|
66
|
-
get element(){return this._element}render(){D(this._render(),this._shadowRoot)}}let xn=function(e){return e[e.DOWN=1]="DOWN",e[e.UP=2]="UP",e}({});function Cn(e){return e.toString()+"px"}class Sn{constructor(e,t){this._view=e.ownerDocument.defaultView,this._isVisible=!1,this._arrowDirection="up",this._annotationsForSelection=[],this._onAnnotate=t.onAnnotate,this._onHighlight=t.onHighlight,this._onShowAnnotations=t.onShowAnnotations,this._container=new vn("adder",(()=>this._render())),e.appendChild(this._container.element),Object.assign(this._container.element.style,{position:"absolute",top:0,left:0}),this._container.render()}get annotationsForSelection(){return this._annotationsForSelection}set annotationsForSelection(e){this._annotationsForSelection=e,this._container.render()}hide(){this._isVisible=!1,this._container.render(),Object.assign(this._container.element.style,{top:0,
|
|
67
|
-
;this._showAt(n,o),this._isVisible=!0,this._arrowDirection=i===xn.UP?"up":"down",this._container.render()}_firstChild(){return this._container.element.shadowRoot.firstChild}_width(){return this._firstChild().getBoundingClientRect().width}_height(){return this._firstChild().getBoundingClientRect().height}_calculateTarget(e,t){let n,o,i;n=t&&!fn()?xn.DOWN:xn.UP;const r=Math.min(20,e.width),s=this._width(),a=fn()?10:0,l=this._height();return i=t?e.left-s/2+r:e.left+e.width-s/2-r,e.top-l<0&&n===xn.DOWN?n=xn.UP:e.top+l>this._view.innerHeight&&(n=xn.DOWN),o=n===xn.UP?e.top+e.height+10+a:e.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(e,t){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),o=this._height(),i=e=>{const t=parseInt(getComputedStyle(e).zIndex)
|
|
68
|
-
},r=[...new Set([...document.elementsFromPoint(e,t),...document.elementsFromPoint(e,t+o),...document.elementsFromPoint(e+n/2,t+o/2),...document.elementsFromPoint(e+n,t),...document.elementsFromPoint(e+n,t+o)])].map(i).filter(Number.isInteger);let s=0;for(const e of document.querySelectorAll("hypothesis-highlight"))s=Math.max(s,i(e));return r.push(s),Math.max(...r)+1}_showAt(e,t){const n=function(e){let t=e.parentElement;for(;t.parentElement&&"static"===getComputedStyle(t).position;)t=t.parentElement;return t}(this._container.element).getBoundingClientRect(),o=this._findZindex(e,t);Object.assign(this._container.element.style,{left:Cn(e-n.left),top:Cn(t-n.top),zIndex:o})}_render(){return Se(wn,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:e=>{switch(e){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()}},
|
|
61
|
+
allowInBrowserExt:!0,getValue:e=>e.sideBySide},commentsMode:{defaultValue:!1,allowInBrowserExt:!1,getValue:an},groupsAllowlist:{allowInBrowserExt:!1,getValue:an}};function cn(e,t=window){const n=sn(t),o={};for(const r of function(e){const t={annotator:["clientUrl","contentInfoBanner","contentReady","subFrameIdentifier","sideBySide","commentsMode"],sidebar:["appType","annotations","branding","bucketContainerSelector","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl","commentsMode","groupsAllowlist"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"],profile:["profileAppUrl"]};return"all"===e?Object.values(t).flat():t[e]}(e)){const e=ln[r],s=void 0!==e.defaultValue,a=!((i=on(t,"sidebar","html")).startsWith("http://")||i.startsWith("https://"));if(!e.allowInBrowserExt&&a){s&&(o[r]=e.defaultValue)
|
|
62
|
+
;continue}const l=e.getValue(n,r);void 0!==l?o[r]=e.coerce?e.coerce(l):l:s&&(o[r]=e.defaultValue)}var i;return o}const hn={alt:1,ctrl:2,meta:4,shift:8};function dn(e,t){if(!(e instanceof KeyboardEvent))return!1;const n=t.split("+").map((e=>e.toLowerCase()));let o=0,i=null;for(const e of n){const t=hn[e];if(t)o|=t;else{if(null!==i)throw new Error("Multiple non-modifier keys specified");i=e}}if(!i)throw new Error(`Invalid shortcut: ${t}`);return((e.ctrlKey?hn.ctrl:0)|(e.metaKey?hn.meta:0)|(e.altKey?hn.alt:0)|(e.shiftKey?hn.shift:0))===o&&e.key.toLowerCase()===i}function un(e,t,{rootElement:n}={}){ne((()=>{if(e)return function(e,t,{rootElement:n=document.documentElement??void 0}={}){const o=n=>{dn(n,e)&&t(n)};return n?(n.addEventListener("keydown",o),()=>n.removeEventListener("keydown",o)):()=>{}}(e,t,{rootElement:n})}),[e,t,n])}const fn=(e=window)=>e.matchMedia("(pointer: coarse)").matches;function pn({badgeCount:e}){return Se("span",{className:Ne("rounded px-1 py-0.5","bg-current"),children:Se("span",{
|
|
63
|
+
className:"font-bold text-color-text-inverted",children:e})})}function gn({arrowDirection:e}){return Se("div",{className:Ne("absolute left-1/2 -translate-x-1/2 z-2","fill-white text-grey-3",{"top-0 -translate-y-full":"up"===e}),children:Se("up"===e?Ge:Ke,{})})}function _n({badgeCount:e,icon:t,label:n,onClick:o,shortcut:i}){un(i,o);const r=i?`${n} (${i})`:n;return Se(tt,{classes:Ne("text-grey-7","group-hover:text-grey-5","hover:group-hover:text-grey-9"),onClick:o,title:r,size:"custom",variant:"custom",children:Se("div",{className:Ne("flex flex-col items-center gap-y-1 py-2.5 px-2","text-annotator-sm leading-none"),children:[t&&Se(t,{className:"text-annotator-lg",title:r}),"number"==typeof e&&Se(pn,{badgeCount:e}),Se("span",{"data-testid":"adder-button-label",children:n})]})})}function mn({annotationCount:e,isVisible:t}){return Se("div",{className:"sr-only",children:[Se("span",{"aria-live":"polite","aria-atomic":"true",role:"status","data-testid":"annotation-count-announce",children:e>0&&Se("span",{
|
|
64
|
+
children:[e," ",1===e?"annotation":"annotations"," for this selection."]})}),Se("ul",{"aria-live":"polite","data-testid":"annotate-shortcuts-announce",children:t&&Se(b,{children:[e>0&&Se("li",{children:["Press ","'S'"," to show annotations."]}),Se("li",{children:["Press ","'A'"," to annotate."]}),Se("li",{children:["Press ","'H'"," to highlight."]})]})})]})}function wn({arrowDirection:e,isVisible:t,onCommand:n,annotationCount:o=0}){const i=t?"a":null,r=t?"h":null,s=t?"s":null;return un(t?"Escape":null,(()=>n("hide"))),Se("div",{className:Ne("all-initial","border border-solid border-grey-3","absolute select-none bg-white rounded shadow-intense","opacity-5",{"animate-adder-pop-up":"up"===e&&t,"animate-adder-pop-down":"down"===e&&t}),"data-component":"AdderToolbar",dir:"ltr",style:{visibility:t?"visible":"hidden"},children:[Se("div",{className:Ne("flex group"),children:[Se(_n,{icon:Ie,onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),Se(_n,{icon:$e,onClick:()=>n("highlight"),label:"Highlight",shortcut:r
|
|
65
|
+
}),o>0&&Se(b,{children:[Se("div",{className:Ne("m-1.5 border-r border-grey-4 border-solid")}),Se(_n,{badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]})]}),Se(gn,{arrowDirection:e}),Se(mn,{annotationCount:o,isVisible:t})]})}let bn;function yn(e){const t=e.attachShadow({mode:"open"}),n=function(e){const t=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]')?.href;if(!t)return Promise.resolve();const n=document.createElement("link");if(n.rel="stylesheet",n.href=t,n.crossOrigin="anonymous",n.removeAttribute=()=>{},e.appendChild(n),void 0===bn){bn=new CSSStyleSheet;const e=bn;n.addEventListener("load",(()=>{if(n.sheet){for(const t of n.sheet.rules)t instanceof CSSPropertyRule&&e.insertRule(t.cssText);document.adoptedStyleSheets.push(e)}}),{once:!0})}return new Promise((e=>{n.addEventListener("load",(()=>e()))}))}(t);return{shadowRoot:t,stylesLoaded:n}}class vn{constructor(e,t){const n=`hypothesis-${e}`;this._element=document.createElement(n)
|
|
66
|
+
;const{shadowRoot:o}=yn(this._element);this._shadowRoot=o,this._render=t}destroy(){D(null,this._shadowRoot),this._element.remove()}get element(){return this._element}render(){D(this._render(),this._shadowRoot)}}let xn=function(e){return e[e.DOWN=1]="DOWN",e[e.UP=2]="UP",e}({});function Cn(e){return e.toString()+"px"}class Sn{constructor(e,t){this._view=e.ownerDocument.defaultView,this._isVisible=!1,this._arrowDirection="up",this._annotationsForSelection=[],this._onAnnotate=t.onAnnotate,this._onHighlight=t.onHighlight,this._onShowAnnotations=t.onShowAnnotations,this._container=new vn("adder",(()=>this._render())),e.appendChild(this._container.element),Object.assign(this._container.element.style,{position:"absolute",top:0,left:0}),this._container.render()}get annotationsForSelection(){return this._annotationsForSelection}set annotationsForSelection(e){this._annotationsForSelection=e,this._container.render()}hide(){this._isVisible=!1,this._container.render(),Object.assign(this._container.element.style,{top:0,
|
|
67
|
+
left:0})}destroy(){this._container.destroy()}show(e,t){const{left:n,top:o,arrowDirection:i}=this._calculateTarget(e,t);this._showAt(n,o),this._isVisible=!0,this._arrowDirection=i===xn.UP?"up":"down",this._container.render()}_firstChild(){return this._container.element.shadowRoot.firstChild}_width(){return this._firstChild().getBoundingClientRect().width}_height(){return this._firstChild().getBoundingClientRect().height}_calculateTarget(e,t){let n,o,i;n=t&&!fn()?xn.DOWN:xn.UP;const r=Math.min(20,e.width),s=this._width(),a=fn()?10:0,l=this._height();return i=t?e.left-s/2+r:e.left+e.width-s/2-r,e.top-l<0&&n===xn.DOWN?n=xn.UP:e.top+l>this._view.innerHeight&&(n=xn.DOWN),o=n===xn.UP?e.top+e.height+10+a:e.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(e,t){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),o=this._height(),i=e=>{const t=parseInt(getComputedStyle(e).zIndex)
|
|
68
|
+
;return Number.isInteger(t)?t:0},r=[...new Set([...document.elementsFromPoint(e,t),...document.elementsFromPoint(e,t+o),...document.elementsFromPoint(e+n/2,t+o/2),...document.elementsFromPoint(e+n,t),...document.elementsFromPoint(e+n,t+o)])].map(i).filter(Number.isInteger);let s=0;for(const e of document.querySelectorAll("hypothesis-highlight"))s=Math.max(s,i(e));return r.push(s),Math.max(...r)+1}_showAt(e,t){const n=function(e){let t=e.parentElement;for(;t.parentElement&&"static"===getComputedStyle(t).position;)t=t.parentElement;return t}(this._container.element).getBoundingClientRect(),o=this._findZindex(e,t);Object.assign(this._container.element.style,{left:Cn(e-n.left),top:Cn(t-n.top),zIndex:o})}_render(){return Se(wn,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:e=>{switch(e){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()}},
|
|
69
69
|
annotationCount:this.annotationsForSelection.length})}}var An=function(e){return e[e.Forwards=1]="Forwards",e[e.Backwards=2]="Backwards",e}(An||{});function Rn(e,t,n){const o=n===An.Forwards?t:t-1;if(""!==e.charAt(o).trim())return t;let i,r;if(n===An.Backwards?(i=e.substring(0,t),r=i.trimEnd()):(i=e.substring(t),r=i.trimStart()),!r.length)return-1;const s=i.length-r.length;return n===An.Backwards?t-s:t+s}function En(e,t){const n=e.commonAncestorContainer.ownerDocument.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT),o=t===An.Forwards?e.startContainer:e.endContainer,i=t===An.Forwards?e.endContainer:e.startContainer;let r=n.nextNode();for(;r&&r!==o;)r=n.nextNode();t===An.Backwards&&(r=n.previousNode());let s=-1;const a=()=>{if(r=t===An.Forwards?n.nextNode():n.previousNode(),r){const e=r.textContent,n=t===An.Forwards?0:e.length;s=Rn(e,n,t)}};for(;r&&-1===s&&r!==i;)a();if(r&&s>=0)return{node:r,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function kn(e){
|
|
70
70
|
switch(e.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return e.textContent?.length??0;default:return 0}}function Pn(e){let t=e.previousSibling,n=0;for(;t;)n+=kn(t),t=t.previousSibling;return n}function Tn(e,...t){let n=t.shift();const o=e.ownerDocument.createNodeIterator(e,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=t.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=t.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}let Nn=function(e){return e[e.FORWARDS=1]="FORWARDS",e[e.BACKWARDS=2]="BACKWARDS",e}({});class Mn{constructor(e,t){if(t<0)throw new Error("Offset is invalid");this.element=e,this.offset=t}relativeTo(e){if(!e.contains(this.element))throw new Error("Parent is not an ancestor of current element");let t=this.element,n=this.offset;for(;t!==e;)n+=Pn(t),t=t.parentElement;return new Mn(t,n)}resolve(e={}){try{
|
|
71
71
|
return Tn(this.element,this.offset)[0]}catch(t){if(0===this.offset&&void 0!==e.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=e.direction===Nn.FORWARDS,i=o?n.nextNode():n.previousNode();if(!i)throw t;return{node:i,offset:o?0:i.data.length}}throw t}}static fromCharOffset(e,t){switch(e.nodeType){case Node.TEXT_NODE:return Mn.fromPoint(e,t);case Node.ELEMENT_NODE:return new Mn(e,t);default:throw new Error("Node is not an element or text node")}}static fromPoint(e,t){switch(e.nodeType){case Node.TEXT_NODE:{if(t<0||t>e.data.length)throw new Error("Text node offset is out of range");if(!e.parentElement)throw new Error("Text node has no parent");const n=Pn(e)+t;return new Mn(e.parentElement,n)}case Node.ELEMENT_NODE:{if(t<0||t>e.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let o=0;o<t;o++)n+=kn(e.childNodes[o]);return new Mn(e,n)}default:throw new Error("Point is not in an element or text node")}}}
|
|
@@ -138,7 +138,7 @@ const n=t.parentElement,o=this._textLayer,i=window.innerWidth-e.width;return thi
|
|
|
138
138
|
const[n,o,i]=await Promise.all([this._bookElement.getCurrentPage(),e?this._bookElement.getTOC():void 0,t?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const e of r)if(!(e in n))throw new Error(`Page metadata field "${e}" is missing`);let s;if(o){s=n.chapterTitle;const e=Hi(n.cfi),t=o.data?.find((t=>Hi(t.cfi)===e));t&&(s=t.title)}let a=n.index;if(void 0===a&&i){const e=i.data?.findIndex((e=>e.cfi===n.cfi));-1!==e&&(a=e)}return{cfi:n.cfi,index:a,page:n.page,title:s,url:new URL(n.absoluteURL,document.baseURI).toString()}}async _getPageRange(e){let t=[];try{const e=await this._bookElement.getPageBreaks();e.ok&&e.data&&(t=e.data)}catch(e){console.error("Failed to get page breaks",e)}const n=Fi(e),o=t.filter((e=>e.cfiWithoutAssertions.split("!")[0]===n));let i;if(o.length>0){i={start:o[0].label,end:o[o.length-1].label}}return i}async segmentInfo(){const{cfi:e,url:t}=await this._getPageInfo();return{cfi:e,pages:await this._getPageRange(e),url:t}}async uri(){
|
|
139
139
|
const e=this._bookElement.getBookInfo().isbn;if(!e)throw new Error("Unable to get book ID from VitalSource");return`https://bookshelf.vitalsource.com/reader/books/${e}`}async scrollToAnchor(e){return this._htmlIntegration.scrollToAnchor(e)}}function Gi(e){if(void 0!==window.PDFViewerApplication)return new Bi({annotator:e,features:e.features});return"content"===ji()?new Ki(document.body):new Xo({features:e.features,sideBySideOptions:e.sideBySide})}function Qi(){return Se(_t,{classes:"fixed left-[10px] top-[10px]","data-testid":"outside-assignment-notice",status:"notice",variant:"raised",children:"You are outside the page range for this assignment. Annotations made here may not be counted."})}class Ji{constructor(e){this._visible=!1,this._container=new vn("notice",(()=>this._render())),e.appendChild(this._container.element)}destroy(){this._container.destroy()}setVisible(e){this._visible=e,this._container.render()}_render(){return this._visible?Se(Qi,{}):null}}class Zi{constructor(e,t=document){let n=!1
|
|
140
140
|
;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{e(Fn(t.getSelection()))}),n)},i=e=>{if("mousedown"===e.type&&(n=!0),"mouseup"===e.type&&(n=!1),n)return;this._cancelPendingCallback();const t="mouseup"===e.type?10:100;o(t)};this._document=t,this._listeners=new me,this._listeners.add(t,"selectionchange",i),this._listeners.add(t.body,"mousedown",i),this._listeners.add(t.body,"mouseup",i),o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function er(e,t){if(e===t)return!0;if(e.parent!==t)return!1;if(!e.frameElement)return!1;return e.frameElement.getBoundingClientRect().width/e.parent.innerWidth>=.8}function tr(){return function(e,t){const n=new Set,o=new Set;return Vn(e,(e=>{for(;e&&!n.has(e);){n.add(e);const i=t(e);null!=i&&o.add(i),e=e.parentNode}})),[...o]}(Fn()??new Range,(e=>e._annotation?.$tag))}function nr(e,t,n){
|
|
141
|
-
return e.getHighlightsFromPoint(t,n).map((e=>e._annotation?.$tag)).filter((e=>void 0!==e))}function or(e){if(!e.region)return null;if(!function(e){return void 0!==e&&"toRange"in e&&"function"==typeof e.toRange}(e.region))return e.region;try{return e.region.toRange()}catch{return null}}function ir(){document.getSelection()?.removeAllRanges()}class rr extends CustomEvent{constructor(e){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:e}),this._ready=null}get ready(){return this._ready}waitUntil(e){this._ready=e}}class sr extends Et{constructor(e,t={},n=window){super(),this.element=e,this._contentReady=t.contentReady,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._highlighter=new $n(this.element),this._adder=new Sn(this.element,{onAnnotate:()=>this.createAnnotationFromSelection(),onHighlight:()=>this.createAnnotationFromSelection({highlight:!0}),
|
|
141
|
+
return e.getHighlightsFromPoint(t,n).map((e=>e._annotation?.$tag)).filter((e=>void 0!==e))}function or(e){if(!e.region)return null;if(!function(e){return void 0!==e&&"toRange"in e&&"function"==typeof e.toRange}(e.region))return e.region;try{return e.region.toRange()}catch{return null}}function ir(){document.getSelection()?.removeAllRanges()}class rr extends CustomEvent{constructor(e){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:e}),this._ready=null}get ready(){return this._ready}waitUntil(e){this._ready=e}}class sr extends Et{constructor(e,t={},n=window){super(),this.element=e,this._contentReady=t.contentReady,this._commentsMode=t.commentsMode??!1,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._highlighter=new $n(this.element),this._adder=new Sn(this.element,{onAnnotate:()=>this.createAnnotationFromSelection(),onHighlight:()=>this.createAnnotationFromSelection({highlight:!0}),
|
|
142
142
|
onShowAnnotations:e=>this.selectAnnotations(e,{focusInSidebar:!0})}),this._drawTool=new io(this.element),this._selectionObserver=new Zi((e=>{e?this._onSelection(e):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=t.subFrameIdentifier||null,this._portFinder=new Rt({hostFrame:this._hostFrame,source:"guest",sourceId:this._frameIdentifier??void 0}),this.features=new co,this._featureFlagsReceived=new Promise((e=>{this.features.on("flagsChanged",e)})),this.sideBySide=t.sideBySide,this._integration=Gi(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),t.contentInfoBanner&&this._integration.showContentInfo?.(t.contentInfoBanner),this._integration.canStyleClusteredHighlights?.()&&(this._clusterToolbar=new go(this._integration.contentContainer(),{features:this.features})),this._integration.on("supportedToolsChanged",(()=>this._notifySupportedToolsChanged())),this._hostRPC=new Ft,this._connectHost(n),this._sidebarRPC=new Ft,this._sidebarLayout=null,
|
|
143
143
|
this._connectSidebar(),this._bucketBarClient=new to({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._listeners=new me,this._setupElementEvents(),this._hoveredAnnotations=new Set}_sideBySideActive(){return"manual"===this.sideBySide?.mode&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(e=>{if(!document.getSelection()?.isCollapsed)return;const{clientX:t,clientY:n,metaKey:o,ctrlKey:i}=e,r=nr(this._highlighter,t,n);if(r.length){const e=o||i;this.selectAnnotations(r,{toggle:e})}})),this._listeners.add(this.element,"pointerdown",(e=>{this._sideBySideActive()||e.composedPath().some((e=>e instanceof Element&&e.localName.startsWith("hypothesis-")))||nr(this._highlighter,e.clientX,e.clientY).length||er(window,this._hostFrame)&&this._sidebarLayout?.expanded&&window.innerWidth-e.clientX<this._sidebarLayout.width||this._sidebarRPC.call("closeSidebar")})),
|
|
144
144
|
this._listeners.add(this.element,"mouseover",(({clientX:e,clientY:t})=>{const n=nr(this._highlighter,e,t);n.length&&this._sidebarRPC.call("hoverAnnotations",n)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(e=>{this._handleShortcut(e)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){const[e,t,n]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),this._integration.segmentInfo?.()]);return{uri:Wo(e),metadata:t,segmentInfo:n,persistent:this._integration.persistFrame?.()??!1}}async _sendDocumentInfo(){this._integration.waitForFeatureFlags?.()&&await this._featureFlagsReceived;const e=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",e)}_repositionAdder(){if(!this._isAdderVisible)return;const e=Fn();e&&this._onSelection(e)}async _connectHost(e){this._hostRPC.on("clearSelection",(()=>{
|
|
@@ -148,14 +148,14 @@ this._sidebarRPC.on("navigateToSegment",(e=>this._integration.navigateToSegment?
|
|
|
148
148
|
this._contentReady&&(await this._contentReady,this._contentReady=void 0);const t=e=>{const t=or(e);if(!t)return;let n;n=t instanceof Range?this._highlighter.highlightRange(t,e.annotation?.$cluster):this._highlighter.highlightShape(t),n.forEach((t=>{t._annotation=e.annotation})),e.highlights=n,this._hoveredAnnotations.has(e.annotation.$tag)&&this._highlighter.setHighlightsFocused(n,!0)};this.detach(e.$tag,!1),this._annotations.add(e.$tag),e.target||(e.target=[]);const n=await Promise.all(e.target.map((async t=>{if(!t.selector||!t.selector.some((e=>"TextQuoteSelector"===e.type||"ShapeSelector"===e.type)))return{annotation:e,target:t};let n;try{const o=await this._integration.anchor(this.element,t.selector);if(o instanceof Range){const i=On.fromRange(o);n={annotation:e,target:t,region:i}}else n={annotation:e,target:t,region:o}}catch{n={annotation:e,target:t}}return n})));if(!this._annotations.has(e.$tag))return[];for(const e of n)t(e);return e.$orphan=n.length>0&&n.every((e=>e.target.selector&&!e.region)),
|
|
149
149
|
this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",e),n}detach(e,t=!0){this._annotations.delete(e);const n=[];for(const t of this.anchors)t.annotation.$tag!==e?n.push(t):t.highlights&&this._highlighter.removeHighlights(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation(e){if("selection"===e)return this.createAnnotationFromSelection();if(!["rect","point"].includes(e))throw new Error("Unsupported annotation tool");{let t=!1;try{this._hostRPC.call("activeToolChanged",e);const t=await this._drawTool.draw(e),n=await this.getDocumentInfo(),o=[{source:n.uri,selector:await this._integration.describe(this.element,t)}],i={uri:n.uri,document:n.metadata,target:o,$tag:"a:"+Ct(8)};return this._sidebarRPC.call("createAnnotation",i),this.anchor(i),i}catch(e){if(e instanceof oo&&["canceled","restarted"].includes(e.kind))return t="restarted"===e.kind,
|
|
150
150
|
null;throw e}finally{t||this._hostRPC.call("activeToolChanged",null)}}}async createAnnotationFromSelection({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(t.map((e=>this._integration.describe(o,e))))).map((e=>({source:n.uri,selector:e}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+Ct(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),ir(),r}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);this._highlighter.setHighlightsFocused(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e);if(!t)return void this._onClearSelection();const n=document.getSelection(),o=Hn(n),i=Un(n);i?(this.selectedRanges=[t],
|
|
151
|
-
this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=tr(),this._isAdderVisible=!0,this._adder.show(i,o)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){this._highlighter.setHighlightsVisible(e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){dn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}
|
|
152
|
-
this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Ji(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function ar(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function lr(e,t){const n={};for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.
|
|
153
|
-
;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Se("dialog",{ref:r,className:"relative m-5 w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function hr({closed:e,children:t,...n}){return Se("div",{...n,className:Ne("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Se("div",{className:"relative w-full h-full",children:t})})}function dr({document_:e=document,...t}){return Se(re((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?cr:hr),[e]),{...t})}function ur({config:e,groupId:t}){return Se("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:ar(e.notebookAppUrl,{...lr(e.notebookAppUrl,e),group:t})})}function fr({eventBus:e,config:t}){const[n,o]=te(0),[i,r]=te(!0),[s,a]=te(null),l=ie(""),c=ie(null)
|
|
154
|
-
document.body.style.overflow=i?l.current:"hidden"}),[i]),ne((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const h=se((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:Se(dr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close notebook",onClick:h,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Se(Le,{className:"w-4 h-4"})})}),Se(ur,{config:t,groupId:s},n)]})}class pr{constructor(e,t,n){this._container=new vn("notebook",(()=>Se(fr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function gr({eventBus:e,config:t}){const[n,o]=te(!0),i=ie(null);ne((()=>{
|
|
155
|
-
}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:Se(dr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),children:Se(Le,{className:"w-4 h-4"})})}),Se("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class _r{constructor(e,t,n){this._container=new vn("profile",(()=>Se(gr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function mr({above:e,below:t,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return Se("ul",{className:"relative",
|
|
156
|
-
"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),title:`Go up to next annotations (${e.anchors.length})`,children:e.anchors.length})}),n.map(((e,t)=>Se("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:e.position},children:Se(vt,{direction:"left",onClick:t=>r(l(e),t.metaKey||t.ctrlKey),onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),title:`Select nearby annotations (${e.anchors.length})`,children:e.anchors.length})},t))),a&&Se("li",{className:"absolute right-0 pointer-events-auto",style:{top:t.position},children:Se(vt,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const e=[...t.anchors].sort(((e,t)=>e.top-t.top)),n=e[0];i(n.tag)},
|
|
157
|
-
title:`Go up to next annotations (${t.anchors.length})`,children:t.anchors.length})})]})}class wr{constructor(e,{onFocusAnnotations:t,onScrollToAnnotation:n,onSelectAnnotations:o}){this._positions=[],this._container=new vn("bucket-bar",(()=>this._render())),Object.assign(this._container.element.style,{display:"block",flexGrow:"1",width:"100%"}),e.appendChild(this._container.element),this._onFocusAnnotations=t,this._onScrollToAnnotation=n,this._onSelectAnnotations=o,this._container.render()}destroy(){this._container.destroy()}update(e){this._positions=e,this._container.render()}_render(){const e=function(e,t){const n=[],o=[],i=[];let r=null;function s(e){const{bottom:t,top:n}=e;return{bottom:t,position:n+(t-n)/2,anchors:[e],top:n}}const a=t.getBoundingClientRect(),l=e.map((e=>({tag:e.tag,top:e.top-a.top,bottom:e.bottom-a.top})));for(const e of l){const t=(e.top+e.bottom)/2;if(t<30){n.push(e);continue}if(t>a.height-30){o.push(e)
|
|
158
|
-
;if(e.top-r.bottom>60&&!l)i.push(r),r=s(e);else{const t=e.bottom>r.bottom?e.bottom:r.bottom,n=t-r.top;r.anchors.push(e),r.bottom=t,r.position=r.top+n/2}}return r&&i.push(r),{above:{anchors:n,position:25},below:{anchors:o,position:a.height-30},buckets:i}}(this._positions,this._container.element);return Se(mr,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:e=>this._onFocusAnnotations(e),onScrollToAnnotation:e=>this._onScrollToAnnotation(e),onSelectAnnotations:(e,t)=>this._onSelectAnnotations(e,t)})}}function br({emitter:e}){const[t,n]=te([]),o=se((e=>n((t=>[...t,e]))),[]),i=se((e=>n((t=>t.filter((t=>t.id!==e))))),[]);return ne((()=>(e.subscribe("toastMessageAdded",o),e.subscribe("toastMessageDismissed",i),()=>{e.unsubscribe("toastMessageAdded",o),e.unsubscribe("toastMessageDismissed",i)})),[e,i,o]),Se(bt,{messages:t,onMessageDismiss:i})}function yr({icon:e,pressedBackground:t=!0,...n}){return Se(tt,{
|
|
151
|
+
this._hostRPC.call("textSelected"),this._commentsMode||(this._adder.annotationsForSelection=tr(),this._isAdderVisible=!0,this._adder.show(i,o))):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){this._highlighter.setHighlightsVisible(e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){dn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible&&!this._commentsMode)}
|
|
152
|
+
_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Ji(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function ar(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function lr(e,t){const n={};for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1722.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function cr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=ie(null);return ne((()=>{
|
|
153
|
+
e?r.current?.close():r.current?.showModal()}),[e]),ne((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Se("dialog",{ref:r,className:"relative m-5 w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function hr({closed:e,children:t,...n}){return Se("div",{...n,className:Ne("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Se("div",{className:"relative w-full h-full",children:t})})}function dr({document_:e=document,...t}){return Se(re((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?cr:hr),[e]),{...t})}function ur({config:e,groupId:t}){return Se("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:ar(e.notebookAppUrl,{...lr(e.notebookAppUrl,e),group:t})})}function fr({eventBus:e,config:t}){const[n,o]=te(0),[i,r]=te(!0),[s,a]=te(null),l=ie(""),c=ie(null)
|
|
154
|
+
;ne((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),ne((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),ne((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const h=se((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:Se(dr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close notebook",onClick:h,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Se(Le,{className:"w-4 h-4"})})}),Se(ur,{config:t,groupId:s},n)]})}class pr{constructor(e,t,n){this._container=new vn("notebook",(()=>Se(fr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function gr({eventBus:e,config:t}){const[n,o]=te(!0),i=ie(null);ne((()=>{
|
|
155
|
+
const t=e.createEmitter();return t.subscribe("openProfile",(()=>{o(!1)})),i.current=t,()=>{t.destroy()}}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:Se(dr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),children:Se(Le,{className:"w-4 h-4"})})}),Se("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class _r{constructor(e,t,n){this._container=new vn("profile",(()=>Se(gr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function mr({above:e,below:t,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return Se("ul",{className:"relative",
|
|
156
|
+
children:[s&&Se("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:Se(vt,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),title:`Go up to next annotations (${e.anchors.length})`,children:e.anchors.length})}),n.map(((e,t)=>Se("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:e.position},children:Se(vt,{direction:"left",onClick:t=>r(l(e),t.metaKey||t.ctrlKey),onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),title:`Select nearby annotations (${e.anchors.length})`,children:e.anchors.length})},t))),a&&Se("li",{className:"absolute right-0 pointer-events-auto",style:{top:t.position},children:Se(vt,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const e=[...t.anchors].sort(((e,t)=>e.top-t.top)),n=e[0];i(n.tag)},
|
|
157
|
+
onBlur:()=>o([]),onFocus:()=>o(l(t)),onMouseEnter:()=>o(l(t)),onMouseOut:()=>o([]),title:`Go up to next annotations (${t.anchors.length})`,children:t.anchors.length})})]})}class wr{constructor(e,{onFocusAnnotations:t,onScrollToAnnotation:n,onSelectAnnotations:o}){this._positions=[],this._container=new vn("bucket-bar",(()=>this._render())),Object.assign(this._container.element.style,{display:"block",flexGrow:"1",width:"100%"}),e.appendChild(this._container.element),this._onFocusAnnotations=t,this._onScrollToAnnotation=n,this._onSelectAnnotations=o,this._container.render()}destroy(){this._container.destroy()}update(e){this._positions=e,this._container.render()}_render(){const e=function(e,t){const n=[],o=[],i=[];let r=null;function s(e){const{bottom:t,top:n}=e;return{bottom:t,position:n+(t-n)/2,anchors:[e],top:n}}const a=t.getBoundingClientRect(),l=e.map((e=>({tag:e.tag,top:e.top-a.top,bottom:e.bottom-a.top})));for(const e of l){const t=(e.top+e.bottom)/2;if(t<30){n.push(e);continue}if(t>a.height-30){o.push(e)
|
|
158
|
+
;continue}if(!r){r=s(e);continue}const l=e.top>r.top&&e.bottom<r.bottom;if(e.top-r.bottom>60&&!l)i.push(r),r=s(e);else{const t=e.bottom>r.bottom?e.bottom:r.bottom,n=t-r.top;r.anchors.push(e),r.bottom=t,r.position=r.top+n/2}}return r&&i.push(r),{above:{anchors:n,position:25},below:{anchors:o,position:a.height-30},buckets:i}}(this._positions,this._container.element);return Se(mr,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:e=>this._onFocusAnnotations(e),onScrollToAnnotation:e=>this._onScrollToAnnotation(e),onSelectAnnotations:(e,t)=>this._onSelectAnnotations(e,t)})}}function br({emitter:e}){const[t,n]=te([]),o=se((e=>n((t=>[...t,e]))),[]),i=se((e=>n((t=>t.filter((t=>t.id!==e))))),[]);return ne((()=>(e.subscribe("toastMessageAdded",o),e.subscribe("toastMessageDismissed",i),()=>{e.unsubscribe("toastMessageAdded",o),e.unsubscribe("toastMessageDismissed",i)})),[e,i,o]),Se(bt,{messages:t,onMessageDismiss:i})}function yr({icon:e,pressedBackground:t=!0,...n}){return Se(tt,{
|
|
159
159
|
classes:Ne("justify-center rounded","w-[30px] h-[30px] touch:h-[40px]","shadow border bg-white text-grey-6 hover:text-grey-9",t&&"aria-pressed:bg-grey-3"),...n,size:"custom",variant:"custom",children:Se(e,{})})}function vr({highlightsVisible:e}){return Se("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:e?"Highlights visible":"Highlights hidden"})}function xr({activeTool:e=null,closeSidebar:t,createAnnotation:n,isSidebarOpen:o,sidebarContainerId:i,newAnnotationType:r,showHighlights:s,supportedTools:a=["selection"],toggleHighlights:l,toggleSidebar:c,toggleSidebarRef:h,useMinimalControls:d=!1}){return Se("div",{className:Ne({"absolute right-full":d,"relative right-[11px]":!d},"w-[33px] z-2","text-px-base leading-none"),children:[d&&o&&Se(tt,{classes:Ne("transition-colors focus-visible-ring ring-inset","w-[27px] h-[27px] mt-[140px] ml-[6px]","flex items-center justify-center bg-white border","text-grey-6 hover:text-grey-9 transition-colors","border-r-0","shadow-sidebar"),
|
|
160
160
|
title:"Close annotation sidebar",onClick:t,unstyled:!0,children:Se(Le,{})}),!d&&Se(b,{children:[Se(tt,{classes:Ne("transition-colors focus-visible-ring ring-inset","h-[40px] w-[33px] pl-[6px] rounded-bl","bg-white text-grey-5 hover:text-grey-9","border-l border-b"),elementRef:h,title:"Annotation sidebar",expanded:o,"aria-controls":i,onClick:c,unstyled:!0,children:Se(o?He:Fe,{})}),Se("div",{className:"space-y-[6px] mt-[8px]",children:[Se(yr,{title:"Show highlights",icon:s?et:qe,pressed:s,pressedBackground:!1,onClick:l}),a.includes("selection")&&Se(yr,{"data-testid":"text-annotation",title:"note"===r?"New page note":"New annotation",icon:"note"===r?Xe:Ie,onClick:()=>n("selection")}),a.includes("rect")&&Se(yr,{"data-testid":"rect-annotation",pressed:"rect"===e,title:"Rectangle annotation",icon:Ze,onClick:()=>n("rect"===e?null:"rect")}),a.includes("point")&&Se(yr,{"data-testid":"point-annotation",pressed:"point"===e,title:"Pin annotation",icon:Ye,onClick:()=>n("point"===e?null:"point")})]}),Se(vr,{
|
|
161
161
|
highlightsVisible:s})]})]})}class Cr{constructor(e,t){const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:i}=t;this.container=e,this._activeTool=null,this._useMinimalControls=!1,this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._sidebarContainerId=t.sidebarContainerId,this._supportedAnnotationTools=["selection"],this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>i(!this._highlightsVisible),this._createAnnotation=e=>{n(e),"selection"===e&&o(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this.container.firstChild.getBoundingClientRect().width}set activeTool(e){this._activeTool=e,this.render()}get activeTool(){return this._activeTool}set useMinimalControls(e){this._useMinimalControls=e,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(e){this._sidebarOpen=e,this.render()}get sidebarOpen(){return this._sidebarOpen}set newAnnotationType(e){
|