hypothesis 1.1362.0 → 1.1363.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";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?b1530d","styles/annotator.css":"styles/annotator.css?0f15d2","styles/annotator.css.map":"styles/annotator.css.map?85af3b","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?0b5991","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?e2cf56","styles/sidebar.css.map":"styles/sidebar.css.map?1ea137","styles/ui-playground.css":"styles/ui-playground.css?daa1e5","styles/ui-playground.css.map":"styles/ui-playground.css.map?776ff6","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?781e53","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?369791","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?1349a2","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?b798f3","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?ac6f70"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1362.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)e(s,i(t,p[l]))}(document,{assetRoot:p,manifest:s,apiUrl:l.apiUrl})}else{var c=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(c&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(c))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var p=[];void 0!==window.PDFViewerApplication&&p.push("styles/pdfjs-overrides.css"),p.push("styles/highlights.css");for(var c=0,u=p;c<u.length;c++)e(s,i(t,u[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:d,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/.")}();
1
+ !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?841807","styles/annotator.css":"styles/annotator.css?df7c65","styles/annotator.css.map":"styles/annotator.css.map?a1872c","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?0b5991","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?e2cf56","styles/sidebar.css.map":"styles/sidebar.css.map?1ea137","styles/ui-playground.css":"styles/ui-playground.css?daa1e5","styles/ui-playground.css.map":"styles/ui-playground.css.map?776ff6","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?197e24","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?451381","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?1349a2","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?b798f3","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?e099b7"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1363.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)e(s,i(t,p[l]))}(document,{assetRoot:p,manifest:s,apiUrl:l.apiUrl})}else{var c=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(c&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(c))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var p=[];void 0!==window.PDFViewerApplication&&p.push("styles/pdfjs-overrides.css"),p.push("styles/highlights.css");for(var c=0,u=p;c<u.length;c++)e(s,i(t,u[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:d,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/.")}();
@@ -1,7 +1,7 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?b1530d",
3
- "styles/annotator.css": "styles/annotator.css?0f15d2",
4
- "styles/annotator.css.map": "styles/annotator.css.map?85af3b",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?841807",
3
+ "styles/annotator.css": "styles/annotator.css?df7c65",
4
+ "styles/annotator.css.map": "styles/annotator.css.map?a1872c",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
6
6
  "styles/highlights.css.map": "styles/highlights.css.map?241350",
7
7
  "styles/katex.min.css": "styles/katex.min.css?0b5991",
@@ -12,9 +12,9 @@
12
12
  "styles/sidebar.css.map": "styles/sidebar.css.map?1ea137",
13
13
  "styles/ui-playground.css": "styles/ui-playground.css?daa1e5",
14
14
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?776ff6",
15
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?781e53",
16
- "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?369791",
15
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?197e24",
16
+ "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?451381",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?1349a2",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?b798f3",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?ac6f70"
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?e099b7"
20
20
  }
@@ -127,7 +127,7 @@ this._sidebarRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._sid
127
127
  this._bucketBarClient.destroy(),null===(t=this._clusterToolbar)||void 0===t||t.destroy(),function(t){En(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const e=t=>{var e;const n=Ho(t);if(!n)return;const i=Cn(n,null===(e=t.annotation)||void 0===e?void 0:e.$cluster);i.forEach((e=>{e._annotation=t.annotation})),t.highlights=i,this._hoveredAnnotations.has(t.annotation.$tag)&&Nn(i,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=dn.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t)
128
128
  ;return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&En(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),s={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Vo(),s}_hoverAnnotations(t){this._hoveredAnnotations.clear(),
129
129
  t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);Nn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=_n(n),o=yn(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Fo(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)
130
- }(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){ne(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Wo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function $o(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1362.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),
130
+ }(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){ne(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Wo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function $o(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1363.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),
131
131
  t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function zo({config:t,groupId:e}){return ce("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:Wo(t.notebookAppUrl,{...$o(t.notebookAppUrl,t),group:e})})}function jo({eventBus:t,config:e}){const[n,i]=Wt(0),[o,r]=Wt(!0),[s,a]=Wt(null),l=zt(""),c=zt(null);$t((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),$t((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),$t((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ce("div",{className:ae("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:ce("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ce("div",{className:"absolute right-0 m-3",children:ce(Ue,{
132
132
  title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark",classes:ae("!bg-transparent enabled:hover:!bg-grey-3"),children:ce(me,{className:"w-4 h-4"})})}),ce(zo,{config:e,groupId:s},n)]})})}class Xo{constructor(t,e,i){n(this,"_outerContainer",void 0),n(this,"_shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this._shadowRoot=Je(this._outerContainer),Rt(ce(jo,{eventBus:e,config:i}),this._shadowRoot)}destroy(){Rt(null,this._shadowRoot),this._outerContainer.remove()}}function Yo({eventBus:t,config:e}){const[n,i]=Wt(!0),o=zt(null);$t((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{i(!1)})),o.current=e,()=>{e.destroy()}}),[t]);return n?null:ce("div",{className:"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50","data-testid":"profile-outer",children:ce("div",{className:"relative w-full h-full","data-testid":"profile-inner",
133
133
  children:[ce("div",{className:"absolute right-0 m-3",children:ce(Ue,{title:"Close the Profile",onClick:()=>{var t;i(!0),null===(t=o.current)||void 0===t||t.publish("closeProfile")},variant:"dark",classes:ae("!bg-transparent enabled:hover:!bg-grey-3"),children:ce(me,{className:"w-4 h-4"})})}),ce("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class Go{constructor(t,e,i){n(this,"_outerContainer",void 0),n(this,"shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-profile"),t.appendChild(this._outerContainer),this.shadowRoot=Je(this._outerContainer),Rt(ce(Yo,{eventBus:e,config:i}),this.shadowRoot)}destroy(){Rt(null,this.shadowRoot),this._outerContainer.remove()}}var Zo={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,h=Math.abs,u=Date.now;function d(t,e,n){return setTimeout(b(t,n),e)}function f(t,e,n){return!!Array.isArray(t)&&(p(t,n[e],n),!0)}
@@ -154,21 +154,21 @@ e.srcEvent.preventDefault()};for(var o=0;o<i.length;)i[o](e),o++}},destroy:funct
154
154
  ;function Qo({above:t,below:e,buckets:n,onFocusAnnotations:i,onScrollToAnnotation:o,onSelectAnnotations:r}){const s=t.anchors.length>0,a=e.anchors.length>0,l=t=>t.anchors.map((t=>t.tag));return ce("ul",{className:"relative",children:[s&&ce("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:t.position},children:ce(Xe,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const e=[...t.anchors].sort(((t,e)=>t.bottom-e.bottom)),n=e[e.length-1];o(n.tag)},onBlur:()=>i([]),onFocus:()=>i(l(t)),onMouseEnter:()=>i(l(t)),onMouseOut:()=>i([]),title:`Go up to next annotations (${t.anchors.length})`,children:t.anchors.length})}),n.map(((t,e)=>ce("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:t.position},children:ce(Xe,{direction:"left",onClick:e=>r(l(t),e.metaKey||e.ctrlKey),onBlur:()=>i([]),onFocus:()=>i(l(t)),onMouseEnter:()=>i(l(t)),onMouseOut:()=>i([]),title:`Select nearby annotations (${t.anchors.length})`,children:t.anchors.length})},e))),a&&ce("li",{
155
155
  className:"absolute right-0 pointer-events-auto",style:{top:e.position},children:ce(Xe,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const t=[...e.anchors].sort(((t,e)=>t.top-e.top)),n=t[0];o(n.tag)},onBlur:()=>i([]),onFocus:()=>i(l(e)),onMouseEnter:()=>i(l(e)),onMouseOut:()=>i([]),title:`Go up to next annotations (${e.anchors.length})`,children:e.anchors.length})})]})}class Jo{constructor(t,{onFocusAnnotations:e,onScrollToAnnotation:i,onSelectAnnotations:o}){n(this,"_bucketsContainer",void 0),n(this,"_onFocusAnnotations",void 0),n(this,"_onScrollToAnnotation",void 0),n(this,"_onSelectAnnotations",void 0),this._bucketsContainer=document.createElement("hypothesis-bucket-bar"),Object.assign(this._bucketsContainer.style,{display:"block",flexGrow:"1",width:"100%"}),Je(this._bucketsContainer),t.appendChild(this._bucketsContainer),this._onFocusAnnotations=e,this._onScrollToAnnotation=i,this._onSelectAnnotations=o,this.update([])}destroy(){Rt(null,this._bucketsContainer),
156
156
  this._bucketsContainer.remove()}update(t){const e=function(t,e){const n=[],i=[],o=[];let r=null;function s(t){const{bottom:e,top:n}=t;return{bottom:e,position:n+(e-n)/2,anchors:[t],top:n}}const a=e.getBoundingClientRect(),l=t.map((t=>({tag:t.tag,top:t.top-a.top,bottom:t.bottom-a.top})));for(const t of l){const e=(t.top+t.bottom)/2;if(e<30){n.push(t);continue}if(e>a.height-30){i.push(t);continue}if(!r){r=s(t);continue}const l=t.top>r.top&&t.bottom<r.bottom;if(t.top-r.bottom>60&&!l)o.push(r),r=s(t);else{const e=t.bottom>r.bottom?t.bottom:r.bottom,n=e-r.top;r.anchors.push(t),r.bottom=e,r.position=r.top+n/2}}return r&&o.push(r),{above:{anchors:n,position:30},below:{anchors:i,position:a.height-30},buckets:o}}(t,this._bucketsContainer);Rt(ce(Qo,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:t=>this._onFocusAnnotations(t),onScrollToAnnotation:t=>this._onScrollToAnnotation(t),onSelectAnnotations:(t,e)=>this._onSelectAnnotations(t,e)}),this._bucketsContainer.shadowRoot)}}
157
- function tr({message:t,onDismiss:e}){const n="notice"!==t.type?`${t.type.charAt(0).toUpperCase()+t.type.slice(1)}: `:"";return ce(ze,{classes:ae({"sr-only":t.visuallyHidden}),status:t.type,onClick:()=>e(t.id),variant:"raised",children:[ce("strong",{children:n}),t.message,t.moreInfoURL&&ce("div",{className:"text-right",children:ce(je,{href:t.moreInfoURL,onClick:t=>t.stopPropagation(),target:"_new",underline:"none",children:"More info"})})]})}function er({messages:t,onMessageDismiss:e}){return ce("div",{children:ce("ul",{"aria-live":"polite","aria-relevant":"additions",className:ae("z-10","absolute left-0 w-full"),children:t.map((t=>ce("li",{className:ae("relative w-full container",{"mb-2":!t.visuallyHidden,"motion-safe:animate-slide-in-from-right lg:animate-fade-in":!t.isDismissed,"motion-reduce:animate-fade-in":!t.isDismissed,"animate-fade-out":t.isDismissed}),children:ce(tr,{message:t,onDismiss:e})},t.id)))})})}function nr({emitter:t}){
158
- const[e,n]=Wt([]),i=Xt((t=>n((e=>[...e,t]))),[]),o=Xt((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return $t((()=>(t.subscribe("toastMessageAdded",i),t.subscribe("toastMessageDismissed",o),()=>{t.unsubscribe("toastMessageAdded",i),t.unsubscribe("toastMessageDismissed",o)})),[t,o,i]),ce(er,{messages:e,onMessageDismiss:o})}function ir({icon:t,...e}){return ce(We,{classes:ae("justify-center rounded-[4px]","w-[30px] h-[30px]","shadow border bg-white text-grey-6 hover:text-grey-9"),...e,size:"custom",variant:"custom",children:ce(t,{})})}function or({highlightsVisible:t}){return ce("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:t?"Highlights visible":"Highlights hidden"})}function rr({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:i,showHighlights:o,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return ce("div",{className:ae("absolute left-[-33px] w-[33px] z-2","text-px-base leading-none"),children:[l&&n&&ce(We,{
159
- classes:ae("transition-colors focus-visible-ring ring-inset","w-[27px] h-[27px] mt-[140px] ml-px-1.5","flex items-center justify-center bg-white border","text-grey-6 hover:text-grey-9 transition-colors","border-r-0","shadow-sidebar"),title:"Close annotation sidebar",onClick:t,unstyled:!0,children:ce(me,{})}),!l&&ce(lt,{children:[ce(We,{classes:ae("transition-colors focus-visible-ring ring-inset","h-[40px] w-[33px] pl-[6px]","bg-white text-grey-5 hover:text-grey-9","border-l border-b"),elementRef:a,title:"Annotation sidebar",expanded:n,pressed:n,onClick:s,unstyled:!0,children:ce(n?we:be,{})}),ce("div",{className:"space-y-px-1.5 mt-px-2",children:[ce(ir,{title:"Show highlights",icon:o?Fe:Ae,selected:o,onClick:r}),ce(ir,{title:"note"===i?"New page note":"New annotation",icon:"note"===i?Pe:fe,onClick:e})]}),ce(or,{highlightsVisible:o})]})]})}class sr{constructor(t,e){n(this,"_container",void 0),n(this,"_newAnnotationType",void 0),n(this,"_useMinimalControls",void 0),n(this,"_highlightsVisible",void 0),
160
- n(this,"_sidebarOpen",void 0),n(this,"_closeSidebar",void 0),n(this,"_toggleSidebar",void 0),n(this,"_toggleHighlights",void 0),n(this,"_createAnnotation",void 0),n(this,"_sidebarToggleButton",void 0);const{createAnnotation:i,setSidebarOpen:o,setHighlightsVisible:r}=e;this._container=t,this._useMinimalControls=!1,this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>r(!this._highlightsVisible),this._createAnnotation=()=>{i(),o(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this._container.firstChild.getBoundingClientRect().width}set useMinimalControls(t){this._useMinimalControls=t,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(t){this._sidebarOpen=t,this.render()}get sidebarOpen(){return this._sidebarOpen}set newAnnotationType(t){this._newAnnotationType=t,this.render()}get newAnnotationType(){
161
- return this._newAnnotationType}set highlightsVisible(t){this._highlightsVisible=t,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){Rt(ce(rr,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,isSidebarOpen:this._sidebarOpen,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}const ar=280;class lr{constructor(t,e,o){if(n(this,"_emitter",void 0),n(this,"_config",void 0),n(this,"_listeners",void 0),n(this,"_gestureState",void 0),n(this,"_layoutState",void 0),n(this,"_hammerManager",void 0),n(this,"_hypothesisSidebar",void 0),n(this,"_messagesElement",void 0),n(this,"_toolbarWidth",void 0),n(this,"_renderFrame",void 0),n(this,"_guestWithSelection",void 0),n(this,"_sidebarRPC",void 0),
162
- n(this,"_guestRPC",void 0),n(this,"bucketBar",void 0),n(this,"features",void 0),n(this,"externalFrame",void 0),n(this,"iframeContainer",void 0),n(this,"toolbar",void 0),n(this,"onLoginRequest",void 0),n(this,"onLogoutRequest",void 0),n(this,"onSignupRequest",void 0),n(this,"onProfileRequest",void 0),n(this,"onHelpRequest",void 0),n(this,"onLayoutChange",void 0),n(this,"iframe",void 0),this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new w,this.iframe=function(t){const e=t.sidebarAppUrl,n=Wo(e,$o(e,t)),i=document.createElement("iframe");return i.setAttribute("allowfullscreen",""),i.src=n,i.title="Hypothesis annotation viewer",i.className="sidebar-frame",i}(o),this._config=o,this.bucketBar=null,this.features=new Dn,o.externalContainerSelector){var r;this.externalFrame=null!==(r=document.querySelector(o.externalContainerSelector))&&void 0!==r?r:t,this.externalFrame.appendChild(this.iframe)}else{if(this.iframeContainer=document.createElement("div"),
163
- this.iframeContainer.style.display="none",this.iframeContainer.className="sidebar-container","clean"===o.theme)this.iframeContainer.classList.add("theme-clean");else{let t;o.bucketContainerSelector&&(t=document.querySelector(o.bucketContainerSelector),t||console.warn(`Custom bucket container "${o.bucketContainerSelector}" not found`));const e=document.createElement("div");e.setAttribute("data-testid","sidebar-edge"),e.className=ae("absolute top-0 bottom-0 w-[23px] left-[-22px]","flex flex-col pt-[110px] pr-[5px]","bg-grey-2 sidebar-collapsed:bg-black/[.08]","pointer-events-none"),this.iframeContainer.append(e),t||(t=e),this.bucketBar=new Jo(t,{onFocusAnnotations:t=>this._guestRPC.forEach((e=>e.call("hoverAnnotations",t))),onScrollToAnnotation:t=>this._guestRPC.forEach((e=>e.call("scrollToAnnotation",t))),onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))})}this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar")
164
- ;const e=Je(this._hypothesisSidebar);e.appendChild(this.iframeContainer),t.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),e.appendChild(this._messagesElement),Rt(ce(nr,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&m(this.iframe.contentWindow),this._listeners=new i;const s=document.createElement("div");this.toolbar=new sr(s,{createAnnotation:()=>{var t;if(0===this._guestRPC.length)return;(null!==(t=this._guestWithSelection)&&void 0!==t?t:this._guestRPC[0]).call("createAnnotation")},setSidebarOpen:t=>t?this.open():this.close(),setHighlightsVisible:t=>this.setHighlightsVisible(t)}),"clean"===o.theme?this.toolbar.useMinimalControls=!0:this.toolbar.useMinimalControls=!1,this.iframeContainer?(this.iframeContainer.prepend(s),this._toolbarWidth=this.toolbar.getWidth()):this._toolbarWidth=0,this._listeners.add(window,"resize",(()=>this._onResize())),this._gestureState={initial:null,final:null},this._setupGestures(),this.close()
165
- ;const[a]=o.services||[];a&&(this.onLoginRequest=a.onLoginRequest,this.onLogoutRequest=a.onLogoutRequest,this.onSignupRequest=a.onSignupRequest,this.onProfileRequest=a.onProfileRequest,this.onHelpRequest=a.onHelpRequest),this.onLayoutChange=o.onLayoutChange,this._layoutState={expanded:!1,width:0,height:0,toolbarWidth:0},this._updateLayoutState(!1),this._setupSidebarEvents()}destroy(){var t,e;this._guestRPC.forEach((t=>t.destroy())),this._sidebarRPC.destroy(),null===(t=this.bucketBar)||void 0===t||t.destroy(),this._listeners.removeAll(),null===(e=this._hammerManager)||void 0===e||e.destroy(),this._hypothesisSidebar?(Rt(null,this._messagesElement),this._hypothesisSidebar.remove()):this.iframe.remove(),this._emitter.destroy(),m(null)}onFrameConnected(t,e){switch(t){case"guest":this._connectGuest(e);break;case"sidebar":this._sidebarRPC.connect(e)}}_connectGuest(t){const e=new w;e.on("textSelected",(()=>{this._guestWithSelection=e,this.toolbar.newAnnotationType="annotation",
166
- this._guestRPC.filter((t=>t!==e)).forEach((t=>t.call("clearSelection")))})),e.on("textUnselected",(()=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.filter((t=>t!==e)).forEach((t=>t.call("clearSelection")))})),e.on("highlightsVisibleChanged",(t=>{this.setHighlightsVisible(t)}));const n=this.bucketBar;n&&e.on("anchorsChanged",(t=>{0===this._guestRPC.indexOf(e)&&n.update(t)})),e.on("close",(()=>{e.destroy(),e===this._guestWithSelection&&(this._guestWithSelection=null),this._guestRPC=this._guestRPC.filter((t=>t!==e))})),e.connect(t),this._guestRPC.push(e),e.call("sidebarLayoutChanged",this._layoutState)}_setupSidebarEvents(){var t;t=document.body,this._sidebarRPC.on("publicAnnotationCountChanged",(function(e){const n=t.querySelectorAll("[data-hypothesis-annotation-count]");Array.from(n).forEach((t=>{t.textContent=e.toString()}))})),function(t,e){const n=t.querySelectorAll("[data-hypothesis-trigger]");Array.from(n).forEach((t=>{t.addEventListener("click",(t=>{e(),
167
- t.stopPropagation()}))}))}(document.body,(()=>this.open())),this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("connect",(()=>{this.iframeContainer&&(this.iframeContainer.style.display="");const t="always"===this._config.showHighlights;this.setHighlightsVisible(t),(this._config.openSidebar||this._config.annotations||this._config.query||this._config.group)&&this.open()})),this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),this._sidebarRPC.on("openSidebar",(()=>this.open())),this._sidebarRPC.on("closeSidebar",(()=>this.close())),this._sidebarRPC.on("openNotebook",(t=>{this.hide(),this._emitter.publish("openNotebook",t)})),this._sidebarRPC.on("openProfile",(()=>{this.hide(),this._emitter.publish("openProfile")})),this._emitter.subscribe("closeProfile",(()=>{this.show()})),this._emitter.subscribe("closeNotebook",(()=>{this.show()})),this._sidebarRPC.on("toastMessageAdded",(t=>{this._emitter.publish("toastMessageAdded",t)})),
168
- this._sidebarRPC.on("toastMessageDismissed",(t=>{this._emitter.publish("toastMessageDismissed",t)}));[["loginRequested",this.onLoginRequest],["logoutRequested",this.onLogoutRequest],["signupRequested",this.onSignupRequest],["profileRequested",this.onProfileRequest],["helpRequested",this.onHelpRequest]].forEach((([t,e])=>{e&&this._sidebarRPC.on(t,(()=>e()))}))}_resetGestureState(){this._gestureState={initial:null,final:null}}_setupGestures(){const t=this.toolbar.sidebarToggleButton;t&&(this._hammerManager=new Ko.Manager(t),this._hammerManager.on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new Ko.Pan({direction:Ko.DIRECTION_HORIZONTAL})))}_updateLayout(){this._renderFrame||(this._renderFrame=requestAnimationFrame((()=>{if(this._renderFrame=void 0,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const t=this._gestureState.final,e=-t;this.iframeContainer.style.marginLeft=`${t}px`,e>=ar&&(this.iframeContainer.style.width=`${e}px`),
169
- this._updateLayoutState()}})))}_updateLayoutState(t){var e,n;const i=this.iframeContainer&&this.toolbar.getWidth()||0,o=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,{height:r}=o.getBoundingClientRect(),s=window.getComputedStyle(o),a=parseInt(s.width),l=parseInt(s.marginLeft);let c=i;"boolean"==typeof t?t&&(c+=a):(l<ar?c-=l:c+=a,t=c>i);const h={expanded:t,width:t?c:i,height:r,toolbarWidth:i};this._layoutState=h,null===(n=this.onLayoutChange)||void 0===n||n.call(this,h),this._guestRPC.forEach((t=>t.call("sidebarLayoutChanged",h)))}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<ar?this.close():this.open())}_onPan(t){const e=this.iframeContainer;if(e)switch(t.type){case"panstart":this._resetGestureState(),e.classList.add("sidebar-no-transition"),e.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(e).marginLeft);break;case"panend":e.classList.remove("sidebar-no-transition"),e.style.pointerEvents="",
170
- null===this._gestureState.final||this._gestureState.final<=-280?this.open():this.close(),this._resetGestureState();break;case"panleft":case"panright":{if("number"!=typeof this._gestureState.initial)return;const e=this._gestureState.initial,n=t.deltaX;this._gestureState.final=Math.min(Math.round(e+n),0),this._updateLayout();break}}}open(){if(this._sidebarRPC.call("sidebarOpened"),this.iframeContainer){const t=this.iframeContainer.getBoundingClientRect().width;this.iframeContainer.style.marginLeft=-1*t+"px",this.iframeContainer.classList.remove("sidebar-collapsed")}this.toolbar.sidebarOpen=!0,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!0),this._updateLayoutState(!0)}close(){this._sidebarRPC.call("sidebarClosed"),this.iframeContainer&&(this.iframeContainer.style.marginLeft="",this.iframeContainer.classList.add("sidebar-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!1),this._updateLayoutState(!1)}
171
- setHighlightsVisible(t){this.toolbar.highlightsVisible=t,this._sidebarRPC.call("setHighlightsVisible",t)}show(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.remove("is-hidden")}hide(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.add("is-hidden")}}class cr{constructor(t){n(this,"_emitter",void 0),n(this,"_subscriptions",void 0),this._emitter=t,this._subscriptions=[]}publish(t,...e){this._emitter.emit(t,...e)}subscribe(t,e){this._emitter.on(t,e),this._subscriptions.push([t,e])}unsubscribe(t,e){this._emitter.off(t,e),this._subscriptions=this._subscriptions.filter((([n,i])=>n!==t||i!==e))}destroy(){for(const[t,e]of this._subscriptions)this._emitter.off(t,e);this._subscriptions=[]}}class hr{constructor(){n(this,"_emitter",void 0),this._emitter=new u}createEmitter(){return new cr(this._emitter)}}const ur=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),
172
- document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=j("annotator");let e=()=>{};const n=new Promise((t=>{e=t}));ur.addEventListener("destroy",e);const i=t.subFrameIdentifier?window.parent:window,o=[];if(i===window){if(function(){const t=document.querySelectorAll(["hypothesis-sidebar","hypothesis-notebook","hypothesis-profile"].join(","));return t.forEach((t=>t.remove())),t.length>0}())return void console.warn("Hypothesis did not load because it found an existing instance on the page.");const t=function(t=navigator.userAgent){if(!y(t))return()=>{};const e=t=>{var e;if("hypothesisPortClosed"===(null===(e=t.data)||void 0===e?void 0:e.type)&&t.ports[0]){const e=t.ports[0];b(e,"close"),e.close()}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}();o.push({destroy:t})
173
- ;const e=j("sidebar"),n=new URL(e.sidebarAppUrl).origin,i=new g(n),r=new hr,s=new lr(document.body,r,e),a=new Xo(document.body,r,j("notebook")),l=new Go(document.body,r,j("profile"));i.on("frameConnected",((t,e)=>s.onFrameConnected(t,e))),o.push(i,s,a,l)}if("container"===ko()){const e=new Po(t);o.push(e)}else{const n=new No(document.body,t),r=new qo(document.body,t,i);r.on("hostDisconnected",e),o.push(n,r)}n.then((()=>{o.forEach((t=>t.destroy()));document.querySelectorAll("[data-hypothesis-asset]").forEach((t=>t.remove())),function(t=document){Array.from(t.querySelectorAll("script.js-hypothesis-config[data-remove-on-unload]")).forEach((t=>t.remove()))}()}))}))}();
157
+ function tr({message:t,onDismiss:e}){const n="notice"!==t.type?`${t.type.charAt(0).toUpperCase()+t.type.slice(1)}: `:"";return ce(ze,{classes:ae({"sr-only":t.visuallyHidden}),status:t.type,onClick:()=>e(t.id),variant:"raised",children:[ce("strong",{children:n}),t.message]})}const er=({direction:t,onTransitionEnd:e,children:n,transitionClasses:i={}})=>{const o="out"===t,r=zt(null),s=jt((()=>{const{transitionIn:t="animate-fade-in",transitionOut:e="animate-fade-out"}=i;return{[t]:!o,[e]:o}}),[o,i]);return ce("div",{"data-testid":"animation-container",onAnimationEnd:n=>{n.target===r.current&&(null==e||e(null!=t?t:"in"))},ref:r,className:ae("relative w-full container",s),children:n})};function nr({messages:t,onMessageDismiss:e,transitionClasses:n,setTimeout_:i=setTimeout}){const[o,r]=Wt([]),s=zt(new Set),a=Xt((t=>r((e=>[...e,t]))),[]),l=Xt((t=>{s.current.has(t)||(s.current.add(t),i((()=>{a(t),s.current.delete(t)}),5e3))}),[a,i]),c=Xt(((t,n)=>{var i;const o=null===(i=n.autoDismiss)||void 0===i||i
158
+ ;"in"===t&&o&&l(n.id),"out"===t&&(e(n.id),r((t=>t.filter((t=>t!==n.id)))))}),[l,e]);return ce("ul",{"aria-live":"polite","aria-relevant":"additions",className:"w-full space-y-2",children:t.map((t=>{const e=o.includes(t.id);return ce("li",{className:ae({"mb-2":!t.visuallyHidden}),children:ce(er,{direction:e?"out":"in",onTransitionEnd:e=>c(e,t),transitionClasses:n,children:ce(tr,{message:t,onDismiss:a})})},t.id)}))})}function ir({emitter:t}){const[e,n]=Wt([]),i=Xt((t=>n((e=>[...e,t]))),[]),o=Xt((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return $t((()=>(t.subscribe("toastMessageAdded",i),t.subscribe("toastMessageDismissed",o),()=>{t.unsubscribe("toastMessageAdded",i),t.unsubscribe("toastMessageDismissed",o)})),[t,o,i]),ce(nr,{messages:e,onMessageDismiss:o})}function or({icon:t,...e}){return ce(We,{classes:ae("justify-center rounded-[4px]","w-[30px] h-[30px]","shadow border bg-white text-grey-6 hover:text-grey-9"),...e,size:"custom",variant:"custom",children:ce(t,{})})}function rr({highlightsVisible:t}){
159
+ return ce("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:t?"Highlights visible":"Highlights hidden"})}function sr({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:i,showHighlights:o,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return ce("div",{className:ae("absolute left-[-33px] w-[33px] z-2","text-px-base leading-none"),children:[l&&n&&ce(We,{classes:ae("transition-colors focus-visible-ring ring-inset","w-[27px] h-[27px] mt-[140px] ml-px-1.5","flex items-center justify-center bg-white border","text-grey-6 hover:text-grey-9 transition-colors","border-r-0","shadow-sidebar"),title:"Close annotation sidebar",onClick:t,unstyled:!0,children:ce(me,{})}),!l&&ce(lt,{children:[ce(We,{classes:ae("transition-colors focus-visible-ring ring-inset","h-[40px] w-[33px] pl-[6px]","bg-white text-grey-5 hover:text-grey-9","border-l border-b"),elementRef:a,title:"Annotation sidebar",expanded:n,pressed:n,onClick:s,unstyled:!0,
160
+ children:ce(n?we:be,{})}),ce("div",{className:"space-y-px-1.5 mt-px-2",children:[ce(or,{title:"Show highlights",icon:o?Fe:Ae,selected:o,onClick:r}),ce(or,{title:"note"===i?"New page note":"New annotation",icon:"note"===i?Pe:fe,onClick:e})]}),ce(rr,{highlightsVisible:o})]})]})}class ar{constructor(t,e){n(this,"_container",void 0),n(this,"_newAnnotationType",void 0),n(this,"_useMinimalControls",void 0),n(this,"_highlightsVisible",void 0),n(this,"_sidebarOpen",void 0),n(this,"_closeSidebar",void 0),n(this,"_toggleSidebar",void 0),n(this,"_toggleHighlights",void 0),n(this,"_createAnnotation",void 0),n(this,"_sidebarToggleButton",void 0);const{createAnnotation:i,setSidebarOpen:o,setHighlightsVisible:r}=e;this._container=t,this._useMinimalControls=!1,this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>r(!this._highlightsVisible),this._createAnnotation=()=>{i(),o(!0)},
161
+ this._sidebarToggleButton={current:null},this.render()}getWidth(){return this._container.firstChild.getBoundingClientRect().width}set useMinimalControls(t){this._useMinimalControls=t,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(t){this._sidebarOpen=t,this.render()}get sidebarOpen(){return this._sidebarOpen}set newAnnotationType(t){this._newAnnotationType=t,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(t){this._highlightsVisible=t,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){Rt(ce(sr,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,isSidebarOpen:this._sidebarOpen,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls
162
+ }),this._container)}}const lr=280;class cr{constructor(t,e,o){if(n(this,"_emitter",void 0),n(this,"_config",void 0),n(this,"_listeners",void 0),n(this,"_gestureState",void 0),n(this,"_layoutState",void 0),n(this,"_hammerManager",void 0),n(this,"_hypothesisSidebar",void 0),n(this,"_messagesElement",void 0),n(this,"_toolbarWidth",void 0),n(this,"_renderFrame",void 0),n(this,"_guestWithSelection",void 0),n(this,"_sidebarRPC",void 0),n(this,"_guestRPC",void 0),n(this,"bucketBar",void 0),n(this,"features",void 0),n(this,"externalFrame",void 0),n(this,"iframeContainer",void 0),n(this,"toolbar",void 0),n(this,"onLoginRequest",void 0),n(this,"onLogoutRequest",void 0),n(this,"onSignupRequest",void 0),n(this,"onProfileRequest",void 0),n(this,"onHelpRequest",void 0),n(this,"onLayoutChange",void 0),n(this,"iframe",void 0),this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new w,this.iframe=function(t){const e=t.sidebarAppUrl,n=Wo(e,$o(e,t)),i=document.createElement("iframe")
163
+ ;return i.setAttribute("allowfullscreen",""),i.src=n,i.title="Hypothesis annotation viewer",i.className="sidebar-frame",i}(o),this._config=o,this.bucketBar=null,this.features=new Dn,o.externalContainerSelector){var r;this.externalFrame=null!==(r=document.querySelector(o.externalContainerSelector))&&void 0!==r?r:t,this.externalFrame.appendChild(this.iframe)}else{if(this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="sidebar-container","clean"===o.theme)this.iframeContainer.classList.add("theme-clean");else{let t;o.bucketContainerSelector&&(t=document.querySelector(o.bucketContainerSelector),t||console.warn(`Custom bucket container "${o.bucketContainerSelector}" not found`));const e=document.createElement("div");e.setAttribute("data-testid","sidebar-edge"),e.className=ae("absolute top-0 bottom-0 w-[23px] left-[-22px]","flex flex-col pt-[110px] pr-[5px]","bg-grey-2 sidebar-collapsed:bg-black/[.08]","pointer-events-none"),
164
+ this.iframeContainer.append(e),t||(t=e),this.bucketBar=new Jo(t,{onFocusAnnotations:t=>this._guestRPC.forEach((e=>e.call("hoverAnnotations",t))),onScrollToAnnotation:t=>this._guestRPC.forEach((e=>e.call("scrollToAnnotation",t))),onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))})}this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const e=Je(this._hypothesisSidebar);e.appendChild(this.iframeContainer),t.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),e.appendChild(this._messagesElement),Rt(ce(ir,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&m(this.iframe.contentWindow),this._listeners=new i;const s=document.createElement("div");this.toolbar=new ar(s,{createAnnotation:()=>{var t;if(0===this._guestRPC.length)return;(null!==(t=this._guestWithSelection)&&void 0!==t?t:this._guestRPC[0]).call("createAnnotation")},
165
+ setSidebarOpen:t=>t?this.open():this.close(),setHighlightsVisible:t=>this.setHighlightsVisible(t)}),"clean"===o.theme?this.toolbar.useMinimalControls=!0:this.toolbar.useMinimalControls=!1,this.iframeContainer?(this.iframeContainer.prepend(s),this._toolbarWidth=this.toolbar.getWidth()):this._toolbarWidth=0,this._listeners.add(window,"resize",(()=>this._onResize())),this._gestureState={initial:null,final:null},this._setupGestures(),this.close();const[a]=o.services||[];a&&(this.onLoginRequest=a.onLoginRequest,this.onLogoutRequest=a.onLogoutRequest,this.onSignupRequest=a.onSignupRequest,this.onProfileRequest=a.onProfileRequest,this.onHelpRequest=a.onHelpRequest),this.onLayoutChange=o.onLayoutChange,this._layoutState={expanded:!1,width:0,height:0,toolbarWidth:0},this._updateLayoutState(!1),this._setupSidebarEvents()}destroy(){var t,e;this._guestRPC.forEach((t=>t.destroy())),this._sidebarRPC.destroy(),null===(t=this.bucketBar)||void 0===t||t.destroy(),this._listeners.removeAll(),
166
+ null===(e=this._hammerManager)||void 0===e||e.destroy(),this._hypothesisSidebar?(Rt(null,this._messagesElement),this._hypothesisSidebar.remove()):this.iframe.remove(),this._emitter.destroy(),m(null)}onFrameConnected(t,e){switch(t){case"guest":this._connectGuest(e);break;case"sidebar":this._sidebarRPC.connect(e)}}_connectGuest(t){const e=new w;e.on("textSelected",(()=>{this._guestWithSelection=e,this.toolbar.newAnnotationType="annotation",this._guestRPC.filter((t=>t!==e)).forEach((t=>t.call("clearSelection")))})),e.on("textUnselected",(()=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.filter((t=>t!==e)).forEach((t=>t.call("clearSelection")))})),e.on("highlightsVisibleChanged",(t=>{this.setHighlightsVisible(t)}));const n=this.bucketBar;n&&e.on("anchorsChanged",(t=>{0===this._guestRPC.indexOf(e)&&n.update(t)})),e.on("close",(()=>{e.destroy(),e===this._guestWithSelection&&(this._guestWithSelection=null),this._guestRPC=this._guestRPC.filter((t=>t!==e))})),e.connect(t),
167
+ this._guestRPC.push(e),e.call("sidebarLayoutChanged",this._layoutState)}_setupSidebarEvents(){var t;t=document.body,this._sidebarRPC.on("publicAnnotationCountChanged",(function(e){const n=t.querySelectorAll("[data-hypothesis-annotation-count]");Array.from(n).forEach((t=>{t.textContent=e.toString()}))})),function(t,e){const n=t.querySelectorAll("[data-hypothesis-trigger]");Array.from(n).forEach((t=>{t.addEventListener("click",(t=>{e(),t.stopPropagation()}))}))}(document.body,(()=>this.open())),this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("connect",(()=>{this.iframeContainer&&(this.iframeContainer.style.display="");const t="always"===this._config.showHighlights;this.setHighlightsVisible(t),(this._config.openSidebar||this._config.annotations||this._config.query||this._config.group)&&this.open()})),this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),this._sidebarRPC.on("openSidebar",(()=>this.open())),
168
+ this._sidebarRPC.on("closeSidebar",(()=>this.close())),this._sidebarRPC.on("openNotebook",(t=>{this.hide(),this._emitter.publish("openNotebook",t)})),this._sidebarRPC.on("openProfile",(()=>{this.hide(),this._emitter.publish("openProfile")})),this._emitter.subscribe("closeProfile",(()=>{this.show()})),this._emitter.subscribe("closeNotebook",(()=>{this.show()})),this._sidebarRPC.on("toastMessageAdded",(t=>{this._emitter.publish("toastMessageAdded",t)})),this._sidebarRPC.on("toastMessageDismissed",(t=>{this._emitter.publish("toastMessageDismissed",t)}));[["loginRequested",this.onLoginRequest],["logoutRequested",this.onLogoutRequest],["signupRequested",this.onSignupRequest],["profileRequested",this.onProfileRequest],["helpRequested",this.onHelpRequest]].forEach((([t,e])=>{e&&this._sidebarRPC.on(t,(()=>e()))}))}_resetGestureState(){this._gestureState={initial:null,final:null}}_setupGestures(){const t=this.toolbar.sidebarToggleButton;t&&(this._hammerManager=new Ko.Manager(t),
169
+ this._hammerManager.on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new Ko.Pan({direction:Ko.DIRECTION_HORIZONTAL})))}_updateLayout(){this._renderFrame||(this._renderFrame=requestAnimationFrame((()=>{if(this._renderFrame=void 0,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const t=this._gestureState.final,e=-t;this.iframeContainer.style.marginLeft=`${t}px`,e>=lr&&(this.iframeContainer.style.width=`${e}px`),this._updateLayoutState()}})))}_updateLayoutState(t){var e,n;const i=this.iframeContainer&&this.toolbar.getWidth()||0,o=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,{height:r}=o.getBoundingClientRect(),s=window.getComputedStyle(o),a=parseInt(s.width),l=parseInt(s.marginLeft);let c=i;"boolean"==typeof t?t&&(c+=a):(l<lr?c-=l:c+=a,t=c>i);const h={expanded:t,width:t?c:i,height:r,toolbarWidth:i};this._layoutState=h,null===(n=this.onLayoutChange)||void 0===n||n.call(this,h),
170
+ this._guestRPC.forEach((t=>t.call("sidebarLayoutChanged",h)))}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<lr?this.close():this.open())}_onPan(t){const e=this.iframeContainer;if(e)switch(t.type){case"panstart":this._resetGestureState(),e.classList.add("sidebar-no-transition"),e.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(e).marginLeft);break;case"panend":e.classList.remove("sidebar-no-transition"),e.style.pointerEvents="",null===this._gestureState.final||this._gestureState.final<=-280?this.open():this.close(),this._resetGestureState();break;case"panleft":case"panright":{if("number"!=typeof this._gestureState.initial)return;const e=this._gestureState.initial,n=t.deltaX;this._gestureState.final=Math.min(Math.round(e+n),0),this._updateLayout();break}}}open(){if(this._sidebarRPC.call("sidebarOpened"),this.iframeContainer){const t=this.iframeContainer.getBoundingClientRect().width;this.iframeContainer.style.marginLeft=-1*t+"px",
171
+ this.iframeContainer.classList.remove("sidebar-collapsed")}this.toolbar.sidebarOpen=!0,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!0),this._updateLayoutState(!0)}close(){this._sidebarRPC.call("sidebarClosed"),this.iframeContainer&&(this.iframeContainer.style.marginLeft="",this.iframeContainer.classList.add("sidebar-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!1),this._updateLayoutState(!1)}setHighlightsVisible(t){this.toolbar.highlightsVisible=t,this._sidebarRPC.call("setHighlightsVisible",t)}show(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.remove("is-hidden")}hide(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.add("is-hidden")}}class hr{constructor(t){n(this,"_emitter",void 0),n(this,"_subscriptions",void 0),this._emitter=t,this._subscriptions=[]}publish(t,...e){this._emitter.emit(t,...e)}subscribe(t,e){this._emitter.on(t,e),this._subscriptions.push([t,e])}
172
+ unsubscribe(t,e){this._emitter.off(t,e),this._subscriptions=this._subscriptions.filter((([n,i])=>n!==t||i!==e))}destroy(){for(const[t,e]of this._subscriptions)this._emitter.off(t,e);this._subscriptions=[]}}class ur{constructor(){n(this,"_emitter",void 0),this._emitter=new u}createEmitter(){return new hr(this._emitter)}}const dr=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=j("annotator");let e=()=>{};const n=new Promise((t=>{e=t}));dr.addEventListener("destroy",e);const i=t.subFrameIdentifier?window.parent:window,o=[];if(i===window){if(function(){const t=document.querySelectorAll(["hypothesis-sidebar","hypothesis-notebook","hypothesis-profile"].join(","));return t.forEach((t=>t.remove())),t.length>0}())return void console.warn("Hypothesis did not load because it found an existing instance on the page.")
173
+ ;const t=function(t=navigator.userAgent){if(!y(t))return()=>{};const e=t=>{var e;if("hypothesisPortClosed"===(null===(e=t.data)||void 0===e?void 0:e.type)&&t.ports[0]){const e=t.ports[0];b(e,"close"),e.close()}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}();o.push({destroy:t});const e=j("sidebar"),n=new URL(e.sidebarAppUrl).origin,i=new g(n),r=new ur,s=new cr(document.body,r,e),a=new Xo(document.body,r,j("notebook")),l=new Go(document.body,r,j("profile"));i.on("frameConnected",((t,e)=>s.onFrameConnected(t,e))),o.push(i,s,a,l)}if("container"===ko()){const e=new Po(t);o.push(e)}else{const n=new No(document.body,t),r=new qo(document.body,t,i);r.on("hostDisconnected",e),o.push(n,r)}n.then((()=>{o.forEach((t=>t.destroy()));document.querySelectorAll("[data-hypothesis-asset]").forEach((t=>t.remove())),function(t=document){Array.from(t.querySelectorAll("script.js-hypothesis-config[data-remove-on-unload]")).forEach((t=>t.remove()))}()}))}))}();
174
174
  //# sourceMappingURL=annotator.bundle.js.map