hypothesis 1.1283.0 → 1.1284.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?74f5b5","styles/annotator.css":"styles/annotator.css?3b7633","styles/annotator.css.map":"styles/annotator.css.map?8cd8b2","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?185199","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?cdb663","styles/sidebar.css.map":"styles/sidebar.css.map?a22863","styles/ui-playground.css":"styles/ui-playground.css?1948cd","styles/ui-playground.css.map":"styles/ui-playground.css.map?f300f2","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?adf796","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?782e1c","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?966424","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?75a653","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?771b89"};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),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1283.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,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s,t;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(t=s.runtime)||void 0===t?void 0:t.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 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 c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:c,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?e51362","styles/annotator.css":"styles/annotator.css?3b7633","styles/annotator.css.map":"styles/annotator.css.map?8cd8b2","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?185199","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?cdb663","styles/sidebar.css.map":"styles/sidebar.css.map?a22863","styles/ui-playground.css":"styles/ui-playground.css?1948cd","styles/ui-playground.css.map":"styles/ui-playground.css.map?f300f2","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?097cc0","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?5b0c12","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?966424","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?75a653","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?0269a8"};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),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1284.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,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s,t;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(t=s.runtime)||void 0===t?void 0:t.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 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 c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:c,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,5 +1,5 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?74f5b5",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?e51362",
3
3
  "styles/annotator.css": "styles/annotator.css?3b7633",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?8cd8b2",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
@@ -12,9 +12,9 @@
12
12
  "styles/sidebar.css.map": "styles/sidebar.css.map?a22863",
13
13
  "styles/ui-playground.css": "styles/ui-playground.css?1948cd",
14
14
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?f300f2",
15
- "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?adf796",
16
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?782e1c",
15
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?097cc0",
16
+ "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?5b0c12",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?966424",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?75a653",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?771b89"
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?0269a8"
20
20
  }
@@ -44,12 +44,12 @@ stroke:"currentColor",d:"m.5 9 7-8 8 8"},void 0,0,{fileName:fe,lineNumber:18,col
44
44
  expanded:o,unstyled:!0,children:[r&&zt(r,{className:"w-em h-em"},void 0,0,{fileName:Ne,lineNumber:97,columnNumber:16},this),t]},void 0,0,{fileName:Ne,lineNumber:59,columnNumber:5},this)};const Re=function({children:t,classes:e,elementRef:n,underline:i="none",color:o,unstyled:r=!1,variant:s="brand",...a}){const l="string"==typeof o?o:s,c=!r;return zt("a",{"data-component":"Link",rel:"noopener noreferrer",...a,className:be(c&&{"focus-visible-ring rounded-sm":!0,"no-underline hover:no-underline":"none"===i,"underline hover:underline":"always"===i,"no-underline hover:underline":"hover"===i},c&&"custom"!==l&&{"text-brand hover:text-brand-dark":"brand"===l,"text-color-text-light hover:text-brand":"text-light"===l,"text-color-text hover:text-brand-dark":"text"===l},e),ref:n,children:t},void 0,0,{fileName:"/home/runner/work/frontend-shared/frontend-shared/src/components/navigation/Link.tsx",lineNumber:43,columnNumber:5},this)}
45
45
  ;const Te=function({children:t,classes:e,elementRef:n,expanded:i,pressed:o,title:r,direction:s,...a}){return zt(Se,{"data-component":"PointerButton",...a,elementRef:n,classes:be("relative w-[26px] h-[16px]","flex items-center justify-center","bg-white rounded-[4px] border","before:absolute before:border-transparent","after:absolute after:border-transparent","text-[10px] text-color-text-light leading-none font-semibold",{"shadow-[1px_1px_1px_rgba(0,0,0,0.1)]":"down"!==s,"shadow-[1px_0px_1px_rgba(0,0,0,0.1)]":"down"===s},{"rounded-r-[4px] rounded-l-[2px]":"left"===s,"before:right-full before:top-1/2 after:right-full after:top-1/2":"left"===s,"before:mt-[-8px] before:border-8 before:border-r-[5px] before:border-r-grey-3":"left"===s,"after:mt-[-7px] after:border-[7px] after:border-r-[4px] after:border-r-white":"left"===s},{"z-1 rounded-t-px-sm rounded-b-px":"up"===s,"before:top-auto before:left-1/2 before:bottom-full after:top-auto after:left-1/2 after:bottom-full":"up"===s,
46
46
  "before:ml-[-13px] before:border-[13px] before:border-b-[6px] before:border-b-grey-3":"up"===s,"after:ml-[-12px] after:border-[12px] after:border-b-[5px] after:border-b-white":"up"===s},{"z-1 rounded-t-px rounded-b-px-sm":"down"===s,"before:top-full before:left-1/2 after:top-full after:left-1/2":"down"===s,"before:ml-[-13px] before:border-[13px] before:border-t-[6px] before:border-t-grey-3":"down"===s,"after:ml-[-12px] after:border-[12px] after:border-t-[5px] after:border-t-white":"down"===s},e),expanded:i,pressed:o,title:r,children:t},void 0,0,{fileName:"/home/runner/work/frontend-shared/frontend-shared/src/components/navigation/PointerButton.tsx",lineNumber:52,columnNumber:5},this)};function ke({badgeCount:t}){return zt("span",{className:be("rounded px-1 py-0.5","bg-current"),children:zt("span",{className:"font-bold text-color-text-inverted",children:t})})}function Pe({arrowDirection:t}){return zt("div",{className:be("absolute left-1/2 -translate-x-1/2 z-2","fill-white text-grey-3",{
47
- "top-0 -translate-y-full":"up"===t}),children:zt("up"===t?pe:de,{})})}function Oe({badgeCount:t,icon:e,label:n,onClick:i,shortcut:o}){Ut(o,i);const r=o?`${n} (${o})`:n;return zt(Se,{classes:be("flex-col gap-y-1 py-2.5 px-2","text-annotator-sm leading-none","text-grey-7","group-hover:text-grey-5","hover:group-hover:text-grey-9"),onClick:i,title:r,children:[e&&zt(e,{className:"text-annotator-lg",title:r}),"number"==typeof t&&zt(ke,{badgeCount:t}),zt("span",{children:n})]})}function Me({annotationCount:t,isVisible:e}){return zt("div",{className:"sr-only",children:[zt("span",{"aria-live":"polite","aria-atomic":"true",role:"status","data-testid":"annotation-count-announce",children:t>0&&zt("span",{children:[t," ",1===t?"annotation":"annotations"," for this selection."]})}),zt("ul",{"aria-live":"polite","data-testid":"annotate-shortcuts-announce",children:e&&zt(j,{children:[t>0&&zt("li",{children:["Press ","'S'"," to show annotations."]}),zt("li",{children:["Press ","'A'"," to annotate."]}),zt("li",{
48
- children:["Press ","'H'"," to highlight."]})]})})]})}function Le({arrowDirection:t,isVisible:e,onCommand:n,annotationCount:i=0}){const o=e?"a":null,r=e?"h":null,s=e?"s":null;return Ut(e?"Escape":null,(()=>n("hide"))),zt("div",{className:be("all-initial","border border-solid border-grey-3","absolute select-none bg-white rounded shadow-adder-toolbar","opacity-5",{"animate-adder-pop-up":"up"===t&&e,"animate-adder-pop-down":"down"===t&&e}),"data-component":"AdderToolbar",dir:"ltr",style:{visibility:e?"visible":"hidden"},children:[zt("div",{className:be("flex group"),children:[zt(Oe,{icon:jt,onClick:()=>n("annotate"),label:"Annotate",shortcut:o}),zt(Oe,{icon:le,onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),i>0&&zt(j,{children:[zt("div",{className:be("m-1.5 border-r border-grey-4 border-solid")}),zt(Oe,{badgeCount:i,onClick:()=>n("show"),label:"Show",shortcut:s})]})]}),zt(Pe,{arrowDirection:t}),zt(Me,{annotationCount:i,isVisible:e})]})}function Ie(t){const e=t.attachShadow({mode:"open"});!function(t){
49
- var e;const n=null===(e=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]'))||void 0===e?void 0:e.href;if(!n)return;const i=document.createElement("link");i.rel="stylesheet",i.href=n,t.appendChild(i)}(e);const n=window.applyFocusVisiblePolyfill;var i;return n&&n(e),(i=e).addEventListener("mouseup",(t=>t.stopPropagation())),i.addEventListener("mousedown",(t=>t.stopPropagation())),i.addEventListener("touchstart",(t=>t.stopPropagation()),{passive:!0}),e}let Fe=function(t){return t[t.DOWN=1]="DOWN",t[t.UP=2]="UP",t}({});function De(t){return t.toString()+"px"}class Be{constructor(t,e){n(this,"_outerContainer",void 0),n(this,"_shadowRoot",void 0),n(this,"_view",void 0),n(this,"_isVisible",void 0),n(this,"_arrowDirection",void 0),n(this,"_onAnnotate",void 0),n(this,"_onHighlight",void 0),n(this,"_onShowAnnotations",void 0),n(this,"_annotationsForSelection",void 0),this._outerContainer=document.createElement("hypothesis-adder"),t.appendChild(this._outerContainer),
50
- this._shadowRoot=Ie(this._outerContainer),Object.assign(this._outerContainer.style,{position:"absolute",top:0,left:0}),this._view=t.ownerDocument.defaultView,this._isVisible=!1,this._arrowDirection="up",this._annotationsForSelection=[],this._onAnnotate=e.onAnnotate,this._onHighlight=e.onHighlight,this._onShowAnnotations=e.onShowAnnotations,this._render()}get annotationsForSelection(){return this._annotationsForSelection}set annotationsForSelection(t){this._annotationsForSelection=t,this._render()}hide(){this._isVisible=!1,this._render(),Object.assign(this._outerContainer.style,{top:0,left:0})}destroy(){dt(null,this._shadowRoot),this._outerContainer.remove()}show(t,e){const{left:n,top:i,arrowDirection:o}=this._calculateTarget(t,e);this._showAt(n,i),this._isVisible=!0,this._arrowDirection=o===Fe.UP?"up":"down",this._render()}_width(){return this._shadowRoot.firstChild.getBoundingClientRect().width}_height(){return this._shadowRoot.firstChild.getBoundingClientRect().height}_calculateTarget(t,e){let n,i,o
51
- ;n=e&&!qt()?Fe.DOWN:Fe.UP;const r=Math.min(20,t.width),s=this._width(),a=qt()?10:0,l=this._height();return o=e?t.left-s/2+r:t.left+t.width-s/2-r,t.top-l<0&&n===Fe.DOWN?n=Fe.UP:t.top+l>this._view.innerHeight&&(n=Fe.DOWN),i=n===Fe.UP?t.top+t.height+10+a:t.top-l-10,o=Math.max(o,0),o=Math.min(o,this._view.innerWidth-s),i=Math.max(i,0),i=Math.min(i,this._view.innerHeight-l),{top:i,left:o,arrowDirection:n}}_findZindex(t,e){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),i=this._height(),o=[...new Set([...document.elementsFromPoint(t,e),...document.elementsFromPoint(t,e+i),...document.elementsFromPoint(t+n/2,e+i/2),...document.elementsFromPoint(t+n,e),...document.elementsFromPoint(t+n,e+i)])].map((t=>+getComputedStyle(t).zIndex)).filter(Number.isInteger);return o.push(0),Math.max(...o)+1}_showAt(t,e){const n=function(t){let e=t.parentElement;for(;e.parentElement&&"static"===getComputedStyle(e).position;)e=e.parentElement;return e
52
- }(this._outerContainer).getBoundingClientRect(),i=this._findZindex(t,e);Object.assign(this._outerContainer.style,{left:De(t-n.left),top:De(e-n.top),zIndex:i})}_render(){dt(zt(Le,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":this._onHighlight(),this.hide();break;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length}),this._shadowRoot)}}var He=function(t){return t[t.Forwards=1]="Forwards",t[t.Backwards=2]="Backwards",t}(He||{});function Ve(t,e,n){const i=n===He.Forwards?e:e-1;if(""!==t.charAt(i).trim())return e;let o,r;if(n===He.Backwards?(o=t.substring(0,e),r=o.trimEnd()):(o=t.substring(e),r=o.trimStart()),!r.length)return-1;const s=o.length-r.length;return n===He.Backwards?e-s:e+s}function Ue(t,e){
47
+ "top-0 -translate-y-full":"up"===t}),children:zt("up"===t?pe:de,{})})}function Oe({badgeCount:t,icon:e,label:n,onClick:i,shortcut:o}){Ut(o,i);const r=o?`${n} (${o})`:n;return zt(Ce,{classes:be("text-grey-7","group-hover:text-grey-5","hover:group-hover:text-grey-9"),onClick:i,title:r,size:"custom",variant:"custom",children:zt("div",{className:be("flex flex-col items-center gap-y-1 py-2.5 px-2","text-annotator-sm leading-none"),children:[e&&zt(e,{className:"text-annotator-lg",title:r}),"number"==typeof t&&zt(ke,{badgeCount:t}),zt("span",{"data-testid":"adder-button-label",children:n})]})})}function Me({annotationCount:t,isVisible:e}){return zt("div",{className:"sr-only",children:[zt("span",{"aria-live":"polite","aria-atomic":"true",role:"status","data-testid":"annotation-count-announce",children:t>0&&zt("span",{children:[t," ",1===t?"annotation":"annotations"," for this selection."]})}),zt("ul",{"aria-live":"polite","data-testid":"annotate-shortcuts-announce",children:e&&zt(j,{children:[t>0&&zt("li",{
48
+ children:["Press ","'S'"," to show annotations."]}),zt("li",{children:["Press ","'A'"," to annotate."]}),zt("li",{children:["Press ","'H'"," to highlight."]})]})})]})}function Le({arrowDirection:t,isVisible:e,onCommand:n,annotationCount:i=0}){const o=e?"a":null,r=e?"h":null,s=e?"s":null;return Ut(e?"Escape":null,(()=>n("hide"))),zt("div",{className:be("all-initial","border border-solid border-grey-3","absolute select-none bg-white rounded shadow-adder-toolbar","opacity-5",{"animate-adder-pop-up":"up"===t&&e,"animate-adder-pop-down":"down"===t&&e}),"data-component":"AdderToolbar",dir:"ltr",style:{visibility:e?"visible":"hidden"},children:[zt("div",{className:be("flex group"),children:[zt(Oe,{icon:jt,onClick:()=>n("annotate"),label:"Annotate",shortcut:o}),zt(Oe,{icon:le,onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),i>0&&zt(j,{children:[zt("div",{className:be("m-1.5 border-r border-grey-4 border-solid")}),zt(Oe,{badgeCount:i,onClick:()=>n("show"),label:"Show",shortcut:s})]})]}),zt(Pe,{
49
+ arrowDirection:t}),zt(Me,{annotationCount:i,isVisible:e})]})}function Ie(t){const e=t.attachShadow({mode:"open"});!function(t){var e;const n=null===(e=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]'))||void 0===e?void 0:e.href;if(!n)return;const i=document.createElement("link");i.rel="stylesheet",i.href=n,t.appendChild(i)}(e);const n=window.applyFocusVisiblePolyfill;var i;return n&&n(e),(i=e).addEventListener("mouseup",(t=>t.stopPropagation())),i.addEventListener("mousedown",(t=>t.stopPropagation())),i.addEventListener("touchstart",(t=>t.stopPropagation()),{passive:!0}),e}let Fe=function(t){return t[t.DOWN=1]="DOWN",t[t.UP=2]="UP",t}({});function De(t){return t.toString()+"px"}class Be{constructor(t,e){n(this,"_outerContainer",void 0),n(this,"_shadowRoot",void 0),n(this,"_view",void 0),n(this,"_isVisible",void 0),n(this,"_arrowDirection",void 0),n(this,"_onAnnotate",void 0),n(this,"_onHighlight",void 0),n(this,"_onShowAnnotations",void 0),
50
+ n(this,"_annotationsForSelection",void 0),this._outerContainer=document.createElement("hypothesis-adder"),t.appendChild(this._outerContainer),this._shadowRoot=Ie(this._outerContainer),Object.assign(this._outerContainer.style,{position:"absolute",top:0,left:0}),this._view=t.ownerDocument.defaultView,this._isVisible=!1,this._arrowDirection="up",this._annotationsForSelection=[],this._onAnnotate=e.onAnnotate,this._onHighlight=e.onHighlight,this._onShowAnnotations=e.onShowAnnotations,this._render()}get annotationsForSelection(){return this._annotationsForSelection}set annotationsForSelection(t){this._annotationsForSelection=t,this._render()}hide(){this._isVisible=!1,this._render(),Object.assign(this._outerContainer.style,{top:0,left:0})}destroy(){dt(null,this._shadowRoot),this._outerContainer.remove()}show(t,e){const{left:n,top:i,arrowDirection:o}=this._calculateTarget(t,e);this._showAt(n,i),this._isVisible=!0,this._arrowDirection=o===Fe.UP?"up":"down",this._render()}_width(){
51
+ return this._shadowRoot.firstChild.getBoundingClientRect().width}_height(){return this._shadowRoot.firstChild.getBoundingClientRect().height}_calculateTarget(t,e){let n,i,o;n=e&&!qt()?Fe.DOWN:Fe.UP;const r=Math.min(20,t.width),s=this._width(),a=qt()?10:0,l=this._height();return o=e?t.left-s/2+r:t.left+t.width-s/2-r,t.top-l<0&&n===Fe.DOWN?n=Fe.UP:t.top+l>this._view.innerHeight&&(n=Fe.DOWN),i=n===Fe.UP?t.top+t.height+10+a:t.top-l-10,o=Math.max(o,0),o=Math.min(o,this._view.innerWidth-s),i=Math.max(i,0),i=Math.min(i,this._view.innerHeight-l),{top:i,left:o,arrowDirection:n}}_findZindex(t,e){if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),i=this._height(),o=[...new Set([...document.elementsFromPoint(t,e),...document.elementsFromPoint(t,e+i),...document.elementsFromPoint(t+n/2,e+i/2),...document.elementsFromPoint(t+n,e),...document.elementsFromPoint(t+n,e+i)])].map((t=>+getComputedStyle(t).zIndex)).filter(Number.isInteger);return o.push(0),Math.max(...o)+1}_showAt(t,e){const n=function(t){
52
+ let e=t.parentElement;for(;e.parentElement&&"static"===getComputedStyle(e).position;)e=e.parentElement;return e}(this._outerContainer).getBoundingClientRect(),i=this._findZindex(t,e);Object.assign(this._outerContainer.style,{left:De(t-n.left),top:De(e-n.top),zIndex:i})}_render(){dt(zt(Le,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":this._onHighlight(),this.hide();break;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length}),this._shadowRoot)}}var He=function(t){return t[t.Forwards=1]="Forwards",t[t.Backwards=2]="Backwards",t}(He||{});function Ve(t,e,n){const i=n===He.Forwards?e:e-1;if(""!==t.charAt(i).trim())return e;let o,r;if(n===He.Backwards?(o=t.substring(0,e),r=o.trimEnd()):(o=t.substring(e),r=o.trimStart()),!r.length)return-1;const s=o.length-r.length;return n===He.Backwards?e-s:e+s}function Ue(t,e){
53
53
  const n=t.commonAncestorContainer.ownerDocument.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_TEXT),i=e===He.Forwards?t.startContainer:t.endContainer,o=e===He.Forwards?t.endContainer:t.startContainer;let r=n.nextNode();for(;r&&r!==i;)r=n.nextNode();e===He.Backwards&&(r=n.previousNode());let s=-1;const a=()=>{if(r=e===He.Forwards?n.nextNode():n.previousNode(),r){const t=r.textContent,n=e===He.Forwards?0:t.length;s=Ve(t,n,e)}};for(;r&&-1===s&&r!==o;)a();if(r&&s>=0)return{node:r,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function qe(t){var e,n;switch(t.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return null!==(e=null===(n=t.textContent)||void 0===n?void 0:n.length)&&void 0!==e?e:0;default:return 0}}function We(t){let e=t.previousSibling,n=0;for(;e;)n+=qe(e),e=e.previousSibling;return n}function ze(t,...e){let n=e.shift();const i=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),o=[];let r,s=i.nextNode(),a=0;for(;void 0!==n&&s;)r=s,
54
54
  a+r.data.length>n?(o.push({node:r,offset:n-a}),n=e.shift()):(s=i.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)o.push({node:r,offset:r.data.length}),n=e.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return o}let $e=function(t){return t[t.FORWARDS=1]="FORWARDS",t[t.BACKWARDS=2]="BACKWARDS",t}({});class je{constructor(t,e){if(n(this,"element",void 0),n(this,"offset",void 0),e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){if(!t.contains(this.element))throw new Error("Parent is not an ancestor of current element");let e=this.element,n=this.offset;for(;e!==t;)n+=We(e),e=e.parentElement;return new je(e,n)}resolve(t={}){try{return ze(this.element,this.offset)[0]}catch(e){if(0===this.offset&&void 0!==t.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const i=t.direction===$e.FORWARDS,o=i?n.nextNode():n.previousNode();if(!o)throw e;return{node:o,offset:i?0:o.data.length}}
55
55
  throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return je.fromPoint(t,e);case Node.ELEMENT_NODE:return new je(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const n=We(t)+e;return new je(t.parentElement,n)}case Node.ELEMENT_NODE:{if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let i=0;i<e;i++)n+=qe(t.childNodes[i]);return new je(t,n)}default:throw new Error("Point is not in an element or text node")}}}class Xe{constructor(t,e){n(this,"start",void 0),n(this,"end",void 0),this.start=t,this.end=e}relativeTo(t){return new Xe(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e
@@ -122,7 +122,7 @@ this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),th
122
122
  const i=await this._integration.anchor(this.element,e.selector),o=Xe.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);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&&an(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,
123
123
  $highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Po(),s}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);ln(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(const r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue;const t=cn(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Qe(n),o=en(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),
124
124
  this._adder.annotationsForSelection=Ro(),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)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){
125
- Vt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Lo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Io(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.1283.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),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function Fo({config:t,groupId:e}){return zt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:Lo(t.notebookAppUrl,{...Io(t.notebookAppUrl,t),
125
+ Vt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Lo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Io(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.1284.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),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function Fo({config:t,groupId:e}){return zt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:Lo(t.notebookAppUrl,{...Io(t.notebookAppUrl,t),
126
126
  group:e})})}function Do({eventBus:t,config:e}){const[n,i]=At(0),[o,r]=At(!0),[s,a]=At(null),l=Tt(""),c=Tt(null);Rt((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Rt((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),Rt((()=>{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:zt("div",{className:be("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:zt("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[zt("div",{className:"absolute right-0 m-3",children:zt(Ae,{title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark",classes:be("!bg-transparent enabled:hover:!bg-grey-3"),children:zt(Yt,{className:"w-4 h-4"})})}),zt(Fo,{config:e,groupId:s},n)]})})}class Bo{constructor(t,e,i){
127
127
  n(this,"_outerContainer",void 0),n(this,"_shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this._shadowRoot=Ie(this._outerContainer),dt(zt(Do,{eventBus:e,config:i}),this._shadowRoot)}destroy(){dt(null,this._shadowRoot),this._outerContainer.remove()}}function Ho({eventBus:t,config:e}){const[n,i]=At(!0),o=Tt(null);Rt((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{i(!1)})),o.current=e,()=>{e.destroy()}}),[t]);return n?null:zt("div",{className:"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50","data-testid":"profile-outer",children:zt("div",{className:"relative w-full h-full","data-testid":"profile-inner",children:[zt("div",{className:"absolute right-0 m-3",children:zt(Ae,{title:"Close the Profile",onClick:()=>{var t;i(!0),null===(t=o.current)||void 0===t||t.publish("closeProfile")},variant:"dark",classes:be("!bg-transparent enabled:hover:!bg-grey-3"),children:zt(Yt,{className:"w-4 h-4"})})}),zt("iframe",{
128
128
  title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class Vo{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=Ie(this._outerContainer),dt(zt(Ho,{eventBus:e,config:i}),this.shadowRoot)}destroy(){dt(null,this.shadowRoot),this._outerContainer.remove()}}var Uo={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)}function p(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function m(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
@@ -150,19 +150,19 @@ const s=t.tags.size>0,a=e.tags.size>0;return zt("ul",{className:be("absolute w-[
150
150
  "data-testid":"down-navigation-button",direction:"down",onClick:()=>o([...e.tags],"down"),onBlur:()=>i([]),onFocus:()=>i([...e.tags]),onMouseEnter:()=>i([...e.tags]),onMouseOut:()=>i([]),title:`Go up to next annotations (${e.tags.size})`,children:e.tags.size})})]})}class zo{constructor(t,{onFocusAnnotations:e,onScrollToClosestOffScreenAnchor:i,onSelectAnnotations:o}){n(this,"_bucketsContainer",void 0),n(this,"_onFocusAnnotations",void 0),n(this,"_onScrollToClosestOffScreenAnchor",void 0),n(this,"_onSelectAnnotations",void 0),this._bucketsContainer=document.createElement("div"),t.appendChild(this._bucketsContainer),this._onFocusAnnotations=e,this._onScrollToClosestOffScreenAnchor=i,this._onSelectAnnotations=o,this.update([])}destroy(){dt(null,this._bucketsContainer),this._bucketsContainer.remove()}update(t){const e=function(t){const e=new Set,n=new Set,i=[];let o=null;function r({bottom:t,tag:e,top:n}){return{bottom:t,position:n+(t-n)/2,tags:new Set([e]),top:n}}return t.forEach((t=>{
151
151
  if(t.top<137)return void e.add(t.tag);if(t.top>window.innerHeight-22)return void n.add(t.tag);if(!o)return void(o=r(t));const s=t.top>o.top&&t.bottom<o.bottom;if(t.top-o.bottom>60&&!s)i.push(o),o=r(t);else{const e=t.bottom>o.bottom?t.bottom:o.bottom,n=e-o.top;o.tags.add(t.tag),o.bottom=e,o.position=o.top+n/2}})),o&&i.push(o),{above:{tags:e,position:137},below:{tags:n,position:window.innerHeight-22},buckets:i}}(t);dt(zt(Wo,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:t=>this._onFocusAnnotations(t),onScrollToClosestOffScreenAnchor:(t,e)=>this._onScrollToClosestOffScreenAnchor(t,e),onSelectAnnotations:(t,e)=>this._onSelectAnnotations(t,e)}),this._bucketsContainer)}}function $o({message:t,onDismiss:e}){const n="notice"!==t.type?`${t.type.charAt(0).toUpperCase()+t.type.slice(1)}: `:"";let i;switch(t.type){case"success":i=oe;break;case"error":i=Yt;break;default:i=ne}return zt(ye,{classes:be("flex",{"sr-only":t.visuallyHidden,"border-red-error":"error"===t.type,
152
152
  "border-yellow-notice":"notice"===t.type,"border-green-success":"success"===t.type}),onClick:()=>e(t.id),children:[zt("div",{className:be("flex items-center p-3 text-white",{"bg-red-error":"error"===t.type,"bg-yellow-notice":"notice"===t.type,"bg-green-success":"success"===t.type}),children:zt(i,{className:be("mt-[2px]")})}),zt("div",{className:"grow p-3","data-testid":"toast-message-text",children:[zt("strong",{children:n}),t.message,t.moreInfoURL&&zt("div",{className:"text-right",children:zt(Re,{href:t.moreInfoURL,onClick:t=>t.stopPropagation(),target:"_new",underline:"none",children:"More info"})})]})]})}function jo({messages:t,onMessageDismiss:e}){return zt("div",{children:zt("ul",{"aria-live":"polite","aria-relevant":"additions",className:"absolute z-2 left-0 w-full",children:t.map((t=>zt("li",{className:be("relative w-full container hover:cursor-pointer",{"mb-2":!t.visuallyHidden,"motion-safe:animate-slide-in-from-right lg:animate-fade-in":!t.isDismissed,"motion-reduce:animate-fade-in":!t.isDismissed,
153
- "animate-fade-out":t.isDismissed}),children:zt($o,{message:t,onDismiss:e})},t.id)))})})}function Xo({emitter:t}){const[e,n]=At([]),i=Pt((t=>n((e=>[...e,t]))),[]),o=Pt((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return Rt((()=>(t.subscribe("toastMessageAdded",i),t.subscribe("toastMessageDismissed",o),()=>{t.unsubscribe("toastMessageAdded",i),t.unsubscribe("toastMessageDismissed",o)})),[t,o,i]),zt(jo,{messages:e,onMessageDismiss:o})}function Yo({icon:t,...e}){return zt(Se,{classes:be("w-[30px] h-[30px]","rounded-px","flex items-center justify-center","border bg-white text-grey-6 hover:text-grey-9","shadow transition-colors"),...e,children:zt(t,{})})}function Go({highlightsVisible:t}){return zt("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:t?"Highlights visible":"Highlights hidden"})}function Zo({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:i,showHighlights:o,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return zt("div",{
154
- className:be("absolute left-[-33px] w-[33px] z-2","text-px-base leading-none"),children:[l&&n&&zt(Se,{classes:be("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,children:zt(Yt,{})}),!l&&zt(j,{children:[zt(Se,{classes:be("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,children:zt(n?te:Qt,{})}),zt("div",{className:"space-y-px-1.5 mt-px-2",children:[zt(Yo,{title:"Show highlights",icon:o?ge:se,selected:o,onClick:r}),zt(Yo,{title:"note"===i?"New page note":"New annotation",icon:"note"===i?he:jt,onClick:e})]}),zt(Go,{highlightsVisible:o})]})]})}class Ko{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),
155
- 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(){return this._newAnnotationType}
156
- set highlightsVisible(t){this._highlightsVisible=t,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){dt(zt(Zo,{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 Qo=280;class Jo{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),
157
- 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=Lo(e,Io(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 bn,o.externalContainerSelector){var r;this.externalFrame=null!==(r=document.querySelector(o.externalContainerSelector))&&void 0!==r?r:t,this.externalFrame.appendChild(this.iframe)}else{this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",
158
- this.iframeContainer.className="sidebar-container","clean"===o.theme?this.iframeContainer.classList.add("theme-clean"):this.bucketBar=new zo(this.iframeContainer,{onFocusAnnotations:t=>this._guestRPC.forEach((e=>e.call("hoverAnnotations",t))),onScrollToClosestOffScreenAnchor:(t,e)=>this._guestRPC.forEach((n=>n.call("scrollToClosestOffScreenAnchor",t,e))),onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))}),this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const e=Ie(this._hypothesisSidebar);e.appendChild(this.iframeContainer),t.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),e.appendChild(this._messagesElement),dt(zt(Xo,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&m(this.iframe.contentWindow),this._listeners=new i;const s=document.createElement("div");this.toolbar=new Ko(s,{createAnnotation:()=>{var t;if(0===this._guestRPC.length)return
159
- ;(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();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(),
160
- null===(t=this.bucketBar)||void 0===t||t.destroy(),this._listeners.removeAll(),null===(e=this._hammerManager)||void 0===e||e.destroy(),this._hypothesisSidebar?(dt(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(),
161
- 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(),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()})),
162
- 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)})),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}}
163
- _setupGestures(){const t=this.toolbar.sidebarToggleButton;t&&(this._hammerManager=new qo.Manager(t),this._hammerManager.on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new qo.Pan({direction:qo.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>=Qo&&(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<Qo?c-=l:c+=a,t=c>i);const h={expanded:t,width:t?c:i,height:r,toolbarWidth:i};this._layoutState=h,
164
- 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<Qo?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
165
- ;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)}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 tr{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){
166
- 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 er{constructor(){n(this,"_emitter",void 0),this._emitter=new u}createEmitter(){return new tr(this._emitter)}}const nr=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=k("annotator");let e=()=>{};const n=new Promise((t=>{e=t}));nr.addEventListener("destroy",e);const i=t.subFrameIdentifier?window.parent:window,o=[];if(i===window){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),
167
- ()=>window.removeEventListener("message",e)}();o.push({destroy:t});const e=k("sidebar"),n=new URL(e.sidebarAppUrl).origin,i=new g(n),r=new er,s=new Jo(document.body,r,e),a=new Bo(document.body,r,k("notebook")),l=new Vo(document.body,r,k("profile"));i.on("frameConnected",((t,e)=>s.onFrameConnected(t,e))),o.push(i,s,a,l)}if("container"===wo()){const e=new xo(t);o.push(e)}else{const n=new _o(document.body,t),r=new Mo(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()))}()}))}))}();
153
+ "animate-fade-out":t.isDismissed}),children:zt($o,{message:t,onDismiss:e})},t.id)))})})}function Xo({emitter:t}){const[e,n]=At([]),i=Pt((t=>n((e=>[...e,t]))),[]),o=Pt((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return Rt((()=>(t.subscribe("toastMessageAdded",i),t.subscribe("toastMessageDismissed",o),()=>{t.unsubscribe("toastMessageAdded",i),t.unsubscribe("toastMessageDismissed",o)})),[t,o,i]),zt(jo,{messages:e,onMessageDismiss:o})}function Yo({icon:t,...e}){return zt(Ce,{classes:be("justify-center rounded-px","w-[30px] h-[30px]","shadow border bg-white text-grey-6 hover:text-grey-9"),...e,size:"custom",variant:"custom",children:zt(t,{})})}function Go({highlightsVisible:t}){return zt("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:t?"Highlights visible":"Highlights hidden"})}function Zo({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:i,showHighlights:o,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return zt("div",{
154
+ className:be("absolute left-[-33px] w-[33px] z-2","text-px-base leading-none"),children:[l&&n&&zt(Ce,{classes:be("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:zt(Yt,{})}),!l&&zt(j,{children:[zt(Ce,{classes:be("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:zt(n?te:Qt,{})}),zt("div",{className:"space-y-px-1.5 mt-px-2",children:[zt(Yo,{title:"Show highlights",icon:o?ge:se,selected:o,onClick:r}),zt(Yo,{title:"note"===i?"New page note":"New annotation",icon:"note"===i?he:jt,onClick:e})]}),zt(Go,{highlightsVisible:o})]})]})}class Ko{constructor(t,e){n(this,"_container",void 0),
155
+ 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)},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}
156
+ 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(){dt(zt(Zo,{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 Qo=280;class Jo{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),
157
+ 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=Lo(e,Io(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 bn,o.externalContainerSelector){var r;this.externalFrame=null!==(r=document.querySelector(o.externalContainerSelector))&&void 0!==r?r:t,
158
+ this.externalFrame.appendChild(this.iframe)}else{this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="sidebar-container","clean"===o.theme?this.iframeContainer.classList.add("theme-clean"):this.bucketBar=new zo(this.iframeContainer,{onFocusAnnotations:t=>this._guestRPC.forEach((e=>e.call("hoverAnnotations",t))),onScrollToClosestOffScreenAnchor:(t,e)=>this._guestRPC.forEach((n=>n.call("scrollToClosestOffScreenAnchor",t,e))),onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))}),this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const e=Ie(this._hypothesisSidebar);e.appendChild(this.iframeContainer),t.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),e.appendChild(this._messagesElement),dt(zt(Xo,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&m(this.iframe.contentWindow),
159
+ this._listeners=new i;const s=document.createElement("div");this.toolbar=new Ko(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();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},
160
+ 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?(dt(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
161
+ ;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(),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),
162
+ (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)})),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])=>{
163
+ e&&this._sidebarRPC.on(t,(()=>e()))}))}_resetGestureState(){this._gestureState={initial:null,final:null}}_setupGestures(){const t=this.toolbar.sidebarToggleButton;t&&(this._hammerManager=new qo.Manager(t),this._hammerManager.on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new qo.Pan({direction:qo.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>=Qo&&(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
164
+ ;"boolean"==typeof t?t&&(c+=a):(l<Qo?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<Qo?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(){
165
+ 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)}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 tr{constructor(t){n(this,"_emitter",void 0),
166
+ 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 er{constructor(){n(this,"_emitter",void 0),this._emitter=new u}createEmitter(){return new tr(this._emitter)}}const nr=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=k("annotator");let e=()=>{};const n=new Promise((t=>{e=t}));nr.addEventListener("destroy",e);const i=t.subFrameIdentifier?window.parent:window,o=[];if(i===window){const t=function(t=navigator.userAgent){if(!y(t))return()=>{};const e=t=>{var e
167
+ ;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=k("sidebar"),n=new URL(e.sidebarAppUrl).origin,i=new g(n),r=new er,s=new Jo(document.body,r,e),a=new Bo(document.body,r,k("notebook")),l=new Vo(document.body,r,k("profile"));i.on("frameConnected",((t,e)=>s.onFrameConnected(t,e))),o.push(i,s,a,l)}if("container"===wo()){const e=new xo(t);o.push(e)}else{const n=new _o(document.body,t),r=new Mo(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()))}()}))}))}();
168
168
  //# sourceMappingURL=annotator.bundle.js.map