hypothesis 1.1551.0 → 1.1552.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?c1ec38","styles/annotator.css":"styles/annotator.css?4a2cb6","styles/annotator.css.map":"styles/annotator.css.map?969663","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?94f096","styles/katex.min.css.map":"styles/katex.min.css.map?e7e03f","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?3278f7","styles/sidebar.css.map":"styles/sidebar.css.map?6c7cc4","styles/ui-playground.css":"styles/ui-playground.css?fabf66","styles/ui-playground.css.map":"styles/ui-playground.css.map?057ae3","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b7dc0f","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?62e729","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?e9e4b6","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?e91bdd","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?ed10a4"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var o=s.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=t,e(o),s.head.appendChild(o)}function o(s,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=o.esModule,n=void 0===r||r,i=o.forceReload,a=void 0!==i&&i,l=s.createElement("script");n&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function r(s,t,o,r){var n=s.createElement("link");n.rel=t,n.href=r,n.type="application/annotator+".concat(o),e(n),s.head.appendChild(n)}function n(s,t,o){var r=s.createElement("link");r.rel="preload",r.as=t,r.href=o,"fetch"===t&&(r.crossOrigin="anonymous"),e(r),s.head.appendChild(r)}function i(s,e){return s.assetRoot+"build/"+s.manifest[e]}function a(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),o=0;o<t.length;o++){var r=void 0;try{r=JSON.parse(t[o].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(e,r)}return e}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1551.0/");if(document.querySelector("hypothesis-app")){!function(s,e){n(s,"fetch",e.apiUrl),n(s,"fetch",e.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)o(s,i(e,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)t(s,i(e,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 d=l,h=a(d.notebookAppUrl||"https://hypothes.is/notebook"),u=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",e.sidebarAppUrl),r(s,"notebook","html",e.notebookAppUrl),r(s,"profile","html",e.profileAppUrl),n(s,"style",i(e,"styles/annotator.css")),r(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)o(s,i(e,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,d=p;c<d.length;c++)t(s,i(e,d[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:h,profileAppUrl:u,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?447cee","styles/annotator.css":"styles/annotator.css?4a2cb6","styles/annotator.css.map":"styles/annotator.css.map?969663","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?94f096","styles/katex.min.css.map":"styles/katex.min.css.map?e7e03f","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?3278f7","styles/sidebar.css.map":"styles/sidebar.css.map?6c7cc4","styles/ui-playground.css":"styles/ui-playground.css?fabf66","styles/ui-playground.css.map":"styles/ui-playground.css.map?057ae3","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b7dc0f","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?f88f03","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?e9e4b6","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?98aad5","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?e91bdd"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var o=s.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=t,e(o),s.head.appendChild(o)}function o(s,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=o.esModule,n=void 0===r||r,i=o.forceReload,a=void 0!==i&&i,l=s.createElement("script");n&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function r(s,t,o,r){var n=s.createElement("link");n.rel=t,n.href=r,n.type="application/annotator+".concat(o),e(n),s.head.appendChild(n)}function n(s,t,o){var r=s.createElement("link");r.rel="preload",r.as=t,r.href=o,"fetch"===t&&(r.crossOrigin="anonymous"),e(r),s.head.appendChild(r)}function i(s,e){return s.assetRoot+"build/"+s.manifest[e]}function a(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),o=0;o<t.length;o++){var r=void 0;try{r=JSON.parse(t[o].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(e,r)}return e}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1552.0/");if(document.querySelector("hypothesis-app")){!function(s,e){n(s,"fetch",e.apiUrl),n(s,"fetch",e.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)o(s,i(e,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)t(s,i(e,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 d=l,h=a(d.notebookAppUrl||"https://hypothes.is/notebook"),u=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",e.sidebarAppUrl),r(s,"notebook","html",e.notebookAppUrl),r(s,"profile","html",e.profileAppUrl),n(s,"style",i(e,"styles/annotator.css")),r(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)o(s,i(e,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,d=p;c<d.length;c++)t(s,i(e,d[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:h,profileAppUrl:u,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?c1ec38",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?447cee",
3
3
  "styles/annotator.css": "styles/annotator.css?4a2cb6",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?969663",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
@@ -13,8 +13,8 @@
13
13
  "styles/ui-playground.css": "styles/ui-playground.css?fabf66",
14
14
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?057ae3",
15
15
  "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?b7dc0f",
16
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?62e729",
16
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?f88f03",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?e9e4b6",
18
- "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?e91bdd",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?ed10a4"
18
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?98aad5",
19
+ "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?e91bdd"
20
20
  }
@@ -144,7 +144,7 @@ this._sidebarRPC.on("navigateToSegment",(e=>this._integration.navigateToSegment?
144
144
  if(!t.selector||!t.selector.some((e=>"TextQuoteSelector"===e.type)))return{annotation:e,target:t};let n;try{const o=await this._integration.anchor(this.element,t.selector),i=mo.fromRange(o);n={annotation:e,target:t,range:i}}catch{n={annotation:e,target:t}}return n})));if(!this._annotations.has(e.$tag))return[];for(const e of n)t(e);return e.$orphan=n.length>0&&n.every((e=>e.target.selector&&!e.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",e),n}detach(e,t=!0){this._annotations.delete(e);const n=[];for(const t of this.anchors)t.annotation.$tag!==e?n.push(t):t.highlights&&ko(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(t.map((e=>this._integration.describe(o,e))))).map((e=>({
145
145
  source:n.uri,selector:e}))),s={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Er(),s}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);Ao(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e);if(!t)return void this._onClearSelection();const n=document.getSelection(),o=wo(n),i=xo(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Nr(),this._isAdderVisible=!0,this._adder.show(i,o)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}
146
146
  selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){!function(e,t){e.classList.toggle("hypothesis-highlights-always-on",t)}(this.element,e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){ct(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new vr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Rr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Tr(e,t){const n={}
147
- ;for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1551.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function Pr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=Ge(null);return Ke((()=>{e?r.current?.close():r.current?.showModal()}),[e]),Ke((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),St("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Lr({closed:e,children:t,...n}){return St("div",{...n,
147
+ ;for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1552.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function Pr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=Ge(null);return Ke((()=>{e?r.current?.close():r.current?.showModal()}),[e]),Ke((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),St("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Lr({closed:e,children:t,...n}){return St("div",{...n,
148
148
  className:Nt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:St("div",{className:"relative w-full h-full",children:t})})}function Or({document_:e=document,...t}){return St(Ye((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Pr:Lr),[e]),{...t})}function Mr({config:e,groupId:t}){return St("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Rr(e.notebookAppUrl,{...Tr(e.notebookAppUrl,e),group:t})})}function Ir({eventBus:e,config:t}){const[n,o]=Xe(0),[i,r]=Xe(!0),[s,a]=Xe(null),l=Ge(""),c=Ge(null);Ke((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Ke((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),Ke((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const d=Je((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
149
149
  ;return null===s?null:St(Or,{closed:i,onClose:d,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[St("div",{className:"absolute right-0 m-3",children:St(yn,{title:"Close notebook",onClick:d,variant:"dark",classes:Nt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:St(Ot,{className:"w-4 h-4"})})}),St(Mr,{config:t,groupId:s},n)]})}class Br{constructor(e,t,n){this._container=new to("notebook",(()=>St(Ir,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Fr({eventBus:e,config:t}){const[n,o]=Xe(!0),i=Ge(null);Ke((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{o(!1)})),i.current=t,()=>{t.destroy()}}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:St(Or,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[St("div",{className:"absolute right-0 m-3",children:St(yn,{
150
150
  title:"Close profile dialog",onClick:r,variant:"dark",classes:Nt("!bg-transparent enabled:hover:!bg-grey-3"),children:St(Ot,{className:"w-4 h-4"})})}),St("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Dr{constructor(e,t,n){this._container=new to("profile",(()=>St(Fr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Hr({above:e,below:t,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return St("ul",{className:"relative",children:[s&&St("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:St(Kn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),
@@ -547,24 +547,24 @@ title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative})
547
547
  }(e)&&!d),[e,d]),p=function(e){return{domain:pi(e),titleText:fi(e),titleLink:mi(e)}}(e),f=h&&p.titleLink?p.titleLink:"",g="sidebar"!==i.route()&&p.titleText;let v;"sidebar"!==i.route()&&(v=i.getGroup(e.group));const b=Ii(e);return Ze("header",{children:[Ze("div",{className:"flex gap-x-1 items-center flex-wrap-reverse",children:[Rs(e.permissions)&&!t&&Ze(Pn,{className:"w-[12px] h-[12px]",title:"This annotation is visible only to you"}),Ze(Kp,{authorLink:u,displayName:c}),n>0&&d&&Ze(_o,{variant:"text-light",onClick:()=>i.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Ze("div",{className:"flex justify-end grow",children:Ze(Wp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,withEditedTimestamp:m})})]}),!gi(e)&&Ze("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[v&&Ze(Vp,{group:v}),!t&&ki(e)&&Ze(Nn,{
548
548
  title:"This is a highlight. Click 'edit' to add a note or tag.",className:"w-[10px] h-[10px] text-color-text-light"}),(g||b)&&Ze("span",{className:"flex",children:[g&&Ze(Gp,{domain:p.domain,link:f,title:p.titleText}),b&&Ze("span",{className:"text-grey-6","data-testid":"page-number",children:[g&&", ","p. ",b]})]})]})]})}),["settings"]);var Xp=Lo((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Ze(Vs,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Ze(mp,{classes:Xe({"p-redacted-text":n}),children:Ze("blockquote",{className:Xe("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:zo(["selectionFontFamily"],r),children:e})})})}),["settings"]);function Jp({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Ze(xr,{classes:Xe("text-grey-7 enabled:hover:text-brand-dark","enabled:hover:underline"),onClick:e,title:r,variant:"custom",children:r})}function Qp(){return Ze("div",{
549
549
  className:Xe("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Ze("span",{className:"text-[16px] animate-fade-in-slow",children:Ze(co,{size:"sm"})}),Ze("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var Zp=Lo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ms(),s=Ci(e),l=a.getDraft(e),c=a.profile().userid,u=a.isAnnotationHovered(e.$tag),d=a.isSavingAnnotation(e),h=!!l&&!d,m=t&&o,p=!d&&!h&&vi(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=de((()=>Cs(e,f,g)),[e,f,g]);return Ze("article",{className:"space-y-4","aria-label":`${vi(e)?Ei(e):`New ${Ei(e).toLowerCase()}`} by ${v}${a.isAnnotationHighlighted(e)?" - Highlighted":""}`,children:[Ze(Yp,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Ze(Xp,{quote:s,isHovered:u,isOrphan:Ni(e)}),!m&&!h&&Ze(bp,{annotation:e}),h&&Ze(Up,{annotation:e,draft:l
550
- }),!m&&Ze("footer",{className:"flex items-center",children:[n&&Ze(Jp,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Ze(Qp,{}),p&&Ze(ct,{classes:"grow",children:Ze($s,{annotation:e,onReply:()=>{vi(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function ef({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Ze("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Ze("div",{children:Ze("em",{children:"Message not available."})}),r&&Ze("footer",{className:"flex items-center",children:Ze(Jp,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var tf=Lo((function({annotation:e,api:t,toastMessenger:n}){const r=ms(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Ze("div",{className:Xe("flex gap-x-3 bg-grey-1 text-color-text font-semibold","mb-2 ",{"-mt-3 -ml-3 -mr-3":!gi(e),"-mr-3":gi(e)}),children:[Ze("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,
551
- "bg-grey-6":e.hidden}),children:e.hidden?Ze(xn,{className:"w-em h-em"}):Ze(ln,{className:"w-em h-em"})}),Ze("div",{className:"self-center grow",children:[!e.hidden&&Ze("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Ze("span",{children:"Hidden from users"})]}),Ze("div",{className:"self-center pr-2",children:Ze(xr,{classes:Xe("px-1.5 py-1","bg-slate-1 text-grey-7 bg-grey-2","enabled:hover:text-grey-9 enabled:hover:bg-grey-3 disabled:text-grey-5","aria-pressed:bg-grey-3 aria-expanded:bg-grey-3"),onClick:e.hidden?()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))}:()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},title:e.hidden?"Make this annotation visible to everyone":"Hide this annotationn from non-moderators",size:"custom",variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null
552
- }),["api","toastMessenger"]);function nf({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:qn,r=e?"Expand replies":"Collapse replies";return Ze("div",{className:Xe("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Ze("div",{className:Xe("bg-white"),children:Ze(xr,{classes:Xe("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-5 hover:text-grey-7"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Ze(n,{className:"w-em h-em"})})})})}var rf=Lo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Ns(e)>0)),i=ms(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=he((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=de((()=>t.visible&&Ze(x,{children:t.annotation?Ze(x,{children:[Ze(tf,{annotation:t.annotation}),Ze(Zp,{annotation:t.annotation,isReply:r,
553
- onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Ze(ef,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Ze("section",{className:"flex","data-testid":"thread-container",children:[r&&Ze(nf,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ze("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,ks(t)>0&&Ze("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ze(Yp,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Ze("div",{children:Ze(xr,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",ks(t)," more in conversation"]})})]}),!t.collapsed&&Ze("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Ze("li",{className:Xe("mt-2","[text-align:start]"),children:Ze(e,{thread:t,threadsService:n})},t.id)))})]})]})
554
- }),["threadsService"]);var of=Lo((function({frameSync:e,thread:t}){const n=ms(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=de((()=>bs((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=he((t=>{e.scrollToAnnotation(t)}),[e]),l=de((()=>Ze(rf,{thread:t})),[t]),c=n.annotationFocusRequest(),u=ue(null);return le((()=>{c===t.id&&u.current&&(u.current.focus(),n.clearAnnotationFocusRequest())}),[c,n,t.id]),Ze(st,{active:o,classes:Xe("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a}),"data-testid":"thread-card",elementRef:u,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Ze(dt,{children:l})},t.id)}),["frameSync"]);const af=50;function sf(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function lf(e){return Math.max(e-e%af,0)}
555
- function cf(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function uf(e){if(!e.annotation)return null;const t=cf(e.annotation);return t?.cfi??null}function df({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ys,t=sf();n(t.clientHeight),o(lf(t.scrollTop));const r=bs((()=>{n(t.clientHeight),o(lf(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=ae((()=>new Map)),[s,l]=ae(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=de((()=>function(e,t,n,r,o=_s){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d}}(c,i,r,t)),[c,i,r,t]),m=de((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=cf(n.annotation)
556
- ;e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=uf(i);if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),p=ms(),f=p.countDrafts()>0,g=p.highlightedAnnotations(),v=p.allAnnotations(),b=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();le((()=>{b&&(p.setForcedVisible(b,!0),l(b))}),[p,b]);const y=de((()=>{const e=v.filter((e=>e.id&&g.includes(e.id))).reduce(((e,t)=>!e||e.updated<t.updated?t:e),null);return e?.id}),[v,g]);return le((()=>{!f&&y&&l(y)}),[f,y]),le((()=>{if(!s)return;const e=c.findIndex((e=>e.id===s));if(-1===e)return;l(null);const t=c.slice(0,e).reduce(((e,t)=>e+(e=>i.get(e.id)||_s.defaultHeight)(t)),0);sf().scrollTop=t}),[s,c,i]),le((()=>{a((e=>{const t=new Map;for(const{id:n}of h){const r=document.getElementById(n);if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=ws(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))
557
- }),[h]),Ze("div",{children:[Ze("div",{style:{height:d}}),h.map((e=>Ze("div",{className:Xe("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[m.get(e)&&Ze("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(e)}),Ze(of,{thread:e})]},e.id))),Ze("div",{style:{height:u}})]})}const hf={collapsed:!1,depth:0,visible:!0,replyCount:0};function mf(e){return e.id||e.$tag}function pf(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||pf(e,t,r.parent))}function ff(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...hf,children:[],id:r},ff(e,r,n.slice(0,-1))),pf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function gf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>gf(e,t)))})}function vf(e,t,n){const r=e.children.map((e=>vf(e,n,n))).slice().sort(t);return{...e,children:r}}function bf(e,t){const n=e.children.map((e=>bf(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function yf(e){
558
- return e.children.some((e=>e.visible||yf(e)))}const _f=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function wf(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=mf(e);t[n]={...hf,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return ff(t,mf(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...hf,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=gf(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),
559
- o.children=o.children.filter((e=>e.visible||yf(e))),o=gf(o,(e=>{const n={collapsed:e.collapsed};if(di(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&yf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=vf(o,t.sortCompareFn,_f),o=bf(o,-1),o}function xf(e){const t=kf(e),[n,r]=t.split("-",2);return[n,r??n]}function kf(e){if(!e.includes("["))return e;let t="",n=!1,r=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function Nf(e,t){const n=e=>function(e){const t=kf(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){if(typeof e[n]!=typeof t[n])return"number"==typeof e[n]?-1:1;if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}(n(e),n(t))}function Sf(e,t,n){return Nf(e,t)>=0&&Nf(e,n)<0}function Af(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e]
560
- ;let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let Ef=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function Tf(e,t,n){return[e[0]??t,e[1]??n]}function Cf(e,t){const n=Af(e),r=Af(t);if(!n||!r)return e&&t&&e===t?Ef.Overlap:Ef.Unknown;const o=2**31,[i,a]=Tf(n,1,o),[s,l]=Tf(r,1,o);return i<=s?s<=a?Ef.Overlap:Ef.NoOverlap:i<=l?Ef.Overlap:Ef.NoOverlap}
550
+ }),!m&&Ze("footer",{className:"flex items-center",children:[n&&Ze(Jp,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Ze(Qp,{}),p&&Ze(ct,{classes:"grow",children:Ze($s,{annotation:e,onReply:()=>{vi(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function ef({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Ze("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Ze("div",{children:Ze("em",{children:"Message not available."})}),r&&Ze("footer",{className:"flex items-center",children:Ze(Jp,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var tf=Lo((function({annotation:e,api:t,toastMessenger:n}){const r=ms(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Ze("div",{className:Xe("flex gap-x-3 bg-grey-1 text-color-text font-semibold","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!gi(e),"-mr-3":gi(e)}),children:[Ze("div",{
551
+ className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:e.hidden?Ze(xn,{className:"w-em h-em"}):Ze(ln,{className:"w-em h-em"})}),Ze("div",{className:"self-center grow",children:[!e.hidden&&Ze("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Ze("span",{children:"Hidden from users"})]}),Ze("div",{className:"self-center pr-2",children:Ze(xr,{classes:Xe("px-1.5 py-1","bg-slate-1 text-grey-7 bg-grey-2","enabled:hover:text-grey-9 enabled:hover:bg-grey-3 disabled:text-grey-5","aria-pressed:bg-grey-3 aria-expanded:bg-grey-3"),onClick:e.hidden?()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))}:()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},title:e.hidden?"Make this annotation visible to everyone":"Hide this annotationn from non-moderators",size:"custom",variant:"custom",
552
+ children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"]);function nf({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:qn,r=e?"Expand replies":"Collapse replies";return Ze("div",{className:Xe("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Ze("div",{className:Xe("bg-white"),children:Ze(xr,{classes:Xe("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-5 hover:text-grey-7"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Ze(n,{className:"w-em h-em"})})})})}var rf=Lo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Ns(e)>0)),i=ms(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=he((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=de((()=>t.visible&&Ze(x,{children:t.annotation?Ze(x,{children:[Ze(tf,{annotation:t.annotation}),Ze(Zp,{
553
+ annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Ze(ef,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Ze("section",{className:"flex","data-testid":"thread-container",children:[r&&Ze(nf,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ze("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,ks(t)>0&&Ze("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ze(Yp,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Ze("div",{children:Ze(xr,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",ks(t)," more in conversation"]})})]}),!t.collapsed&&Ze("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Ze("li",{className:Xe("mt-2","[text-align:start]"),children:Ze(e,{thread:t,threadsService:n
554
+ })},t.id)))})]})]})}),["threadsService"]);var of=Lo((function({frameSync:e,thread:t}){const n=ms(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=de((()=>bs((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=he((t=>{e.scrollToAnnotation(t)}),[e]),l=de((()=>Ze(rf,{thread:t})),[t]),c=n.annotationFocusRequest(),u=ue(null);return le((()=>{c===t.id&&u.current&&(u.current.focus(),n.clearAnnotationFocusRequest())}),[c,n,t.id]),Ze(st,{active:o,classes:Xe("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a}),"data-testid":"thread-card",elementRef:u,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Ze(dt,{children:l})},t.id)}),["frameSync"]);const af=50;function sf(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function lf(e){
555
+ return Math.max(e-e%af,0)}function cf(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function uf(e){if(!e.annotation)return null;const t=cf(e.annotation);return t?.cfi??null}function df({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ys,t=sf();n(t.clientHeight),o(lf(t.scrollTop));const r=bs((()=>{n(t.clientHeight),o(lf(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=ae((()=>new Map)),[s,l]=ae(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=de((()=>function(e,t,n,r,o=_s){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d}}(c,i,r,t)),[c,i,r,t]),m=de((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue
556
+ ;const e=cf(n.annotation);e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=uf(i);if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),p=ms(),f=p.countDrafts()>0,g=p.highlightedAnnotations(),v=p.allAnnotations(),b=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();le((()=>{b&&(p.setForcedVisible(b,!0),l(b))}),[p,b]);const y=de((()=>{const e=v.filter((e=>e.id&&g.includes(e.id))).reduce(((e,t)=>!e||e.updated<t.updated?t:e),null);return e?.id}),[v,g]);return le((()=>{!f&&y&&l(y)}),[f,y]),le((()=>{if(!s)return;const e=c.findIndex((e=>e.id===s));if(-1===e)return;l(null);const t=c.slice(0,e).reduce(((e,t)=>e+(e=>i.get(e.id)||_s.defaultHeight)(t)),0);sf().scrollTop=t}),[s,c,i]),le((()=>{a((e=>{const t=new Map;for(const{id:n}of h){const r=document.getElementById(n);if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=ws(r);o!==e.get(n)&&t.set(n,o)}
557
+ return 0===t.size?e:new Map([...e,...t])}))}),[h]),Ze("div",{children:[Ze("div",{style:{height:d}}),h.map((e=>Ze("div",{className:Xe("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[m.get(e)&&Ze("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(e)}),Ze(of,{thread:e})]},e.id))),Ze("div",{style:{height:u}})]})}const hf={collapsed:!1,depth:0,visible:!0,replyCount:0};function mf(e){return e.id||e.$tag}function pf(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||pf(e,t,r.parent))}function ff(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...hf,children:[],id:r},ff(e,r,n.slice(0,-1))),pf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function gf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>gf(e,t)))})}function vf(e,t,n){const r=e.children.map((e=>vf(e,n,n))).slice().sort(t);return{...e,children:r}}function bf(e,t){const n=e.children.map((e=>bf(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,
558
+ depth:t,replyCount:r}}function yf(e){return e.children.some((e=>e.visible||yf(e)))}const _f=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function wf(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=mf(e);t[n]={...hf,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return ff(t,mf(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...hf,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=gf(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible
559
+ ;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),o.children=o.children.filter((e=>e.visible||yf(e))),o=gf(o,(e=>{const n={collapsed:e.collapsed};if(di(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&yf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=vf(o,t.sortCompareFn,_f),o=bf(o,-1),o}function xf(e){const t=kf(e),[n,r]=t.split("-",2);return[n,r??n]}function kf(e){if(!e.includes("["))return e;let t="",n=!1,r=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function Nf(e,t){const n=e=>function(e){const t=kf(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){if(typeof e[n]!=typeof t[n])return"number"==typeof e[n]?-1:1;if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}(n(e),n(t))}
560
+ function Sf(e,t,n){return Nf(e,t)>=0&&Nf(e,n)<0}function Af(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e];let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let Ef=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function Tf(e,t,n){return[e[0]??t,e[1]??n]}function Cf(e,t){const n=Af(e),r=Af(t);if(!n||!r)return e&&t&&e===t?Ef.Overlap:Ef.Unknown;const o=2**31,[i,a]=Tf(n,1,o),[s,l]=Tf(r,1,o);return i<=s?s<=a?Ef.Overlap:Ef.NoOverlap:i<=l?Ef.Overlap:Ef.NoOverlap}
561
561
  const Mf=/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u08FE\u0900-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D02\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1DC0-\u1DE6\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE26]/g
562
562
  ;function If(e){return function(e){return e.replace(Mf,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class zf{constructor(e,t){this.term=t.normalize(e),this.matcher=t}matches(e){const t=this.matcher;return t.fieldValues(e).some((e=>t.matches(t.normalize(e),this.term)))}}class Of{constructor(e,t){this.operator=e,this.filters=t}matches(e){return"and"===this.operator?this.filters.every((t=>t.matches(e))):this.filters.some((t=>t.matches(e)))}}function Lf(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:If}}const Rf={quote:Lf((e=>[Ci(e)??""])),cfi:{fieldValues:e=>[Mi(e)?.trim()??""],matches:(e,t)=>{const[n,r]=xf(t);return Sf(e,n,r)},normalize:e=>kf(e.trim())},page:{fieldValues:e=>[Ii(e)?.trim()??""],matches:(e,t)=>Cf(e,t)===Ef.Overlap,normalize:e=>e.trim()},since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:Lf((e=>e.tags)),text:Lf((e=>[e.text])),uri:Lf((e=>[e.uri])),user:Lf((e=>[e.user,e.user_info?.display_name??""]))}
563
563
  ;function Pf(e,t){const n=(e,t)=>new zf(t,Rf[e]),r=Object.entries(t).filter((([,e])=>e.terms.length>0)).map((([e,t])=>{let r;if("any"===e){const e=["quote","text","tag","user"];r=t.terms.map((t=>new Of("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new Of(t.operator,r)})),o=new Of("and",r);return e.filter((e=>o.matches(e)))}const Df=["cfi","quote","page","since","tag","text","uri","user"],Ff=["group","quote","tag","text","uri","user"];function Bf(e,t){const n=e.slice(0,e.indexOf(":"));if(!n)return[null,e];if(t.includes(n)){return[n,e.slice(n.length+1)]}return[null,e]}function Hf(e){const t=e.slice(0,1),n=e.slice(-1);return'"'!==t&&"'"!==t||t!==n||(e=e.slice(1,e.length-1)),e}function jf(e,t){const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map(Hf).filter((e=>e.length>0)).map((e=>{const[n,r]=Bf(e,t);return n?n+":"+Hf(r):e})):[]}function qf(e){const t={},n=e=>"tag"===e?"tags":e,r=jf(e,Ff);for(const e of r){let[r,o]=Bf(e,Ff);r||(r="any",o=e);const i=n(r);t[i]?t[i].push(o):t[i]=[o]}
564
564
  return t}function $f(e){return Ni(e)?"orphan":Si(e)?"note":"annotation"}function Uf(e){return Ss([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function Gf(e){return Ss([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}const Vf={Newest:(e,t)=>{const n=Uf(e),r=Uf(t);return n>r?-1:n<r?1:0},Oldest:(e,t)=>{const n=Gf(e),r=Gf(t);return n<r?-1:n>r?1:0},Location:(e,t)=>{if(!e.annotation||!t.annotation)return function(e,t){return e.annotation||t.annotation?e.annotation?1:-1:0}(e,t);const n=Ti(e.annotation),r=Ti(t.annotation);if(n.cfi&&r.cfi){const e=Nf(n.cfi,r.cfi);if(0!==e)return Math.sign(e)}else{if(n.cfi)return-1;if(r.cfi)return 1}const o=n.position??Number.MAX_SAFE_INTEGER,i=r.position??Number.MAX_SAFE_INTEGER;return Math.sign(o-i)}};const Wf=function(e){if(1!==e.length)throw new Error("Memoize input must be a function of one argument");let t,n;return function(r){return r===t||(t=r,n=e(r)),n}}((function(e){const t=e.selection,n={expanded:t.expanded,forcedVisible:t.forcedVisible,
565
565
  selected:t.selected,sortCompareFn:Vf[t.sortKey]};if(!!t.filterQuery||Object.keys(t.filters).length>0){const e=function(e,t={}){const n=e=>{const n=t[e];return"string"==typeof n?[n]:[]},r=n("cfi"),o=n("page"),i=n("quote"),a=n("tag"),s=n("text"),l=n("uri"),c=n("user"),u=[],d=[],h=jf(e,Df);for(const e of h){const t=e.slice(0,e.indexOf(":")),n=e.slice(t.length+1);switch(t){case"cfi":r.push(n);break;case"quote":i.push(n);break;case"page":o.push(n);break;case"since":{const t=86400,n={sec:1,min:60,hour:3600,day:t,week:7*t,month:30*t,year:365*t},r=e.slice(6).toLowerCase().match(/^(\d+)(sec|min|hour|day|week|month|year)?$/);if(r){const e=parseFloat(r[1]),t=r[2]||"sec";d.push(e*n[t])}}break;case"tag":a.push(n);break;case"text":s.push(n);break;case"uri":l.push(n);break;case"user":c.push(n);break;default:u.push(e)}}return{any:{terms:u,operator:"and",filterReplies:!0},cfi:{terms:r,operator:"or",filterReplies:!1},quote:{terms:i,operator:"and",filterReplies:!1},page:{terms:o,operator:"or",filterReplies:!1},since:{terms:d,
566
566
  operator:"and",filterReplies:!0},tag:{terms:a,operator:"and",filterReplies:!0},text:{terms:s,operator:"and",filterReplies:!0},uri:{terms:l,operator:"or",filterReplies:!1},user:{terms:c,operator:"or",filterReplies:!0}}}(t.filterQuery||"",t.filters),r={},o={};for(const[t,n]of Object.entries(e))n.filterReplies?r[t]=n:o[t]=n;n.filterFn=e=>Pf([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&Pf([e.annotation],o).length>0)}const r=wf(e.annotations,n),o={annotation:0,note:0,orphan:0};return e.showTabs&&(r.children=r.children.filter((e=>{if(!e.annotation)return!1;if(wi(e.annotation))return!1;const n=$f(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function Kf(){const e=ms(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=de((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return Wf(s)}
567
- var Yf,Xf,Jf=Lo((function({loadAnnotationsService:e,onLogin:t}){const n=ms(),r=n.routeParams().id??"",{rootThread:o}=Kf(),i=n.profile().userid,[a,s]=ae(!1);return le((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Ze(x,{children:[a&&Ze(ps,{errorType:"annotation",onLoginRequest:t}),Ze(df,{threads:o.children})]})}),["loadAnnotationsService"]);class Qf{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.1551.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||r,this.fingerprint=t[0]?.metadata?.documentFingerprint??r,this.account=o,this.timestamp=(new Date).toString();const i=t[0]?.segment;if(i){const e=[];if(i.cfi&&e.push(["CFI",i.cfi]),i.pages){const t=`${i.pages.start}-${i.pages.end}`;e.push(["Pages",t])}
567
+ var Yf,Xf,Jf=Lo((function({loadAnnotationsService:e,onLogin:t}){const n=ms(),r=n.routeParams().id??"",{rootThread:o}=Kf(),i=n.profile().userid,[a,s]=ae(!1);return le((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Ze(x,{children:[a&&Ze(ps,{errorType:"annotation",onLoginRequest:t}),Ze(df,{threads:o.children})]})}),["loadAnnotationsService"]);class Qf{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.1552.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||r,this.fingerprint=t[0]?.metadata?.documentFingerprint??r,this.account=o,this.timestamp=(new Date).toString();const i=t[0]?.segment;if(i){const e=[];if(i.cfi&&e.push(["CFI",i.cfi]),i.pages){const t=`${i.pages.start}-${i.pages.end}`;e.push(["Pages",t])}
568
568
  i.url&&e.push(["URL",i.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}var Zf=function(){if(Xf)return Yf;Xf=1;var e="complete",t="canceled";function n(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function r(t){var o=t._scrollSettings;if(o){var i=o.maxSynchronousAlignments,a=function(e,t){var n,r,o,i,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,h=c&&null!=c.top?c.top:.5,m=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,f=d,g=h;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),r=u.left+t.pageXOffset-t.innerWidth*f+s*f,o=u.top+t.pageYOffset-t.innerHeight*g+l*g,r-=m,o-=p,r=e.align.lockX?t.pageXOffset:r,
569
569
  o=e.align.lockY?t.pageYOffset:o,i=r-t.pageXOffset,a=o-t.pageYOffset;else{s=u.width,l=u.height,n=t.getBoundingClientRect();var v=u.left-(n.left-t.scrollLeft),b=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=b+l*g-t.clientHeight*g,r-=m,o-=p,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,a=o-t.scrollTop}return{x:r,y:o,differenceX:i,differenceY:a}}(o,t),s=Date.now()-o.startTime,l=Math.min(1/o.time*s,1);if(o.endIterations>=i)return n(t,a.x,a.y),t._scrollSettings=null,o.end(e);var c=1-o.ease(l);if(n(t,a.x-a.differenceX*c,a.y-a.differenceY*c),s>=o.time)return o.endIterations++,o.scrollAncestor&&r(o.scrollAncestor),void r(t);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(r.bind(null,t))}}function o(e){return e.self===e}function i(e){
570
570
  return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function a(){return!0}function s(e){if(e.assignedSlot)return s(e.assignedSlot);if(e.parentElement)return"body"===e.parentElement.tagName.toLowerCase()?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t.host}}return Yf=function(n,l,c){if(n){"function"==typeof l&&(c=l,l=null),l||(l={}),l.time=isNaN(l.time)?1e3:l.time,l.ease=l.ease||function(e){return 1-Math.pow(1-e,e/2)},l.align=l.align||{};var u=s(n),d=1,h=l.validTarget||a,m=l.isScrollable;l.debug&&(console.log("About to scroll to",n),u||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var p=[];u;)if(l.debug&&console.log("Scrolling parent node",u),h(u,d)&&(m?m(u,i):i(u))&&(d++,p.push(u)),!(u=s(u))){f(e);break}return p.reduce(((e,i,a)=>function(e,n,i,a,s){
@@ -651,7 +651,7 @@ null==v._nextState&&null==v.__s&&(v._nextState=v.__s=v.state),v.context=y,h.getD
651
651
  }),Ze("body",{children:[Ze("section",{children:[Ze("h1",{children:"Summary"}),Ze("p",{children:Ze("time",{dateTime:o.toISOString(),children:jb(o)})}),Ze("p",{children:Ze("strong",{children:a})}),Ze("p",{children:Ze("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Ze("table",{children:Ze("tbody",{style:{verticalAlign:"top"},children:[Ze("tr",{children:[Ze("td",{children:"Group:"}),Ze("td",{children:t})]}),Ze("tr",{children:[Ze("td",{children:"Total users:"}),Ze("td",{children:s.length})]}),Ze("tr",{children:[Ze("td",{children:"Users:"}),Ze("td",{children:s.join(", ")})]}),Ze("tr",{children:[Ze("td",{children:"Total annotations:"}),Ze("td",{children:e.length})]}),Ze("tr",{children:[Ze("td",{children:"Total replies:"}),Ze("td",{children:l.length})]})]})})]}),Ze("hr",{}),Ze("section",{children:[Ze("h1",{children:"Annotations"}),e.map(((e,t)=>{const n=Ii(e),r=Ci(e),o=hp(e.text),i=o===`<p>${e.text}</p>`?e.text:o;return Ze("article",{children:[Ze("h2",{children:["Annotation ",t+1,":"]
652
652
  }),Ze("table",{children:Ze("tbody",{style:{verticalAlign:"top"},children:[Ze("tr",{children:[Ze("td",{children:"Created at:"}),Ze("td",{children:Ze("time",{dateTime:e.created,children:jb(new Date(e.created))})})]}),Ze("tr",{children:[Ze("td",{children:"Author:"}),Ze("td",{children:c(e)})]}),n&&Ze("tr",{children:[Ze("td",{children:"Page:"}),Ze("td",{children:n})]}),Ze("tr",{children:[Ze("td",{children:"Type:"}),Ze("td",{children:Ei(e)})]}),r&&Ze("tr",{children:[Ze("td",{children:"Quote:"}),Ze("td",{children:Ze("blockquote",{style:{margin:0},children:r})})]}),Ze("tr",{children:[Ze("td",{children:"Comment:"}),Ze("td",{dangerouslySetInnerHTML:{__html:i}})]}),e.tags.length>0&&Ze("tr",{children:[Ze("td",{children:"Tags:"}),Ze("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}_exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e;if(!r)throw new Error("No annotations to export");const o=e=>Cs(e,n,t),{uri:i,title:a}=hi(r);return{uri:i,title:a,
653
653
  uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>gi(e))),extractUsername:o}}}qb.$inject=[];class $b extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),this.url=e,this.response=t,this.reason=n}}async function Ub(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new $b(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch{throw new $b(e,n,"Failed to parse response")}if(!n.ok)throw new $b(e,n,r?.reason);return r}class Gb{constructor(e,t,n){this._clientId=null;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,i]=await Promise.all([e,n()]),l=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!l)throw new Error(`Missing API route: ${t}`);const c={
654
- "Content-Type":"application/json","Hypothesis-Client-Version":"1.1551.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=Ba(l.url,a),m=new URL(d);for(const[e,t]of Object.entries(h)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await Ub(m.toString(),{body:s?JSON.stringify(Hb(s)):null,headers:c,method:l.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")},
654
+ "Content-Type":"application/json","Hypothesis-Client-Version":"1.1552.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=Ba(l.url,a),m=new URL(d);for(const[e,t]of Object.entries(h)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await Ub(m.toString(),{body:s?JSON.stringify(Hb(s)):null,headers:c,method:l.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")},
655
655
  this.analytics={events:{create:i("analytics.events.create")}}}setClientId(e){this._clientId=e}}Gb.$inject=["apiRoutes","auth","store"];var Vb,Wb,Kb,Yb,Xb,Jb={};function Qb(){return Kb||(Kb=1,e=Jb,t=function(){if(Wb)return Vb;function e(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return Wb=1,Vb=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1
656
656
  ;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},e.prototype.try=function(e){
657
657
  console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=o,n=a)}return t},Vb}(),e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t))
@@ -763,8 +763,8 @@ const e=JSON.stringify(this._messageQueue.shift());this._socket.send(e)}}}class
763
763
  this._socket?.isConnected()&&this._socket.send(t)}async _reconnect(){const e=await this._websocketURL;if(!e)return;let t,n;this._socket?.close();try{t=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(t){const r=new URL(e);r.searchParams.set("access_token",t),n=r.toString()}else n=e;const r=new NN(n);r.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(r)})),r.on("disconnect",(()=>{if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),r.on("error",(t=>this._handleSocketError(e,t))),r.on("message",(e=>this._handleSocketMessage(e))),this._socket=r,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){this._updateImmediately=e.applyUpdatesImmediately??!0,
764
764
  this._reconnectSetUp||(this._reconnectSetUp=!0,by(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}SN.$inject=["store","apiRoutes","auth","groups","session","$window"];const AN="hypothesis.user.tags.list",EN="hypothesis.user.tags.map";class TN{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(AN)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${Ov(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(EN)||{};e.forEach((e=>{t[e]?(t[e].count+=1,t[e].updated=Date.now()):t[e]={text:e,count:1,updated:Date.now()}})),this._storage.setObject(EN,t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject(AN,n)}}TN.$inject=["localStorage"];class CN{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),
765
765
  e.visible||this._store.setForcedVisible(e.id,!0)}}CN.$inject=["store"];class MN extends hg.TinyEmitter{constructor(e,t){super(),this._store=e,this._window=t,this._delayedMessageQueue=[],this._window.addEventListener("focus",(()=>{this._delayedMessageQueue.forEach((({type:e,messageText:t,options:n})=>this._addMessage(e,t,n))),this._delayedMessageQueue=[]}))}dismiss(e){this._store.getToastMessage(e)&&(this._store.removeToastMessage(e),this.emit("toastMessageDismissed",e))}_addMessage(e,t,{autoDismiss:n=!0,visuallyHidden:r=!1,delayed:o=!1}={}){if(this._store.hasToastMessage(e,t))return;if(o&&!this._window.document.hasFocus()){const o={autoDismiss:n,visuallyHidden:r};return void this._delayedMessageQueue.push({type:e,messageText:t,options:o})}const i={type:e,id:xv(10),message:t,visuallyHidden:r,autoDismiss:n};this._store.addToastMessage(i),this.emit("toastMessageAdded",i)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}
766
- MN.$inject=["store","$window"];const IN=function(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r<n.length;r++){var o=void 0;try{o=JSON.parse(n[r].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),zN=function(e){const{version:t,origin:n}=Nv(e.location.href);return"1.1551.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1551.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function ON(e,t){e.setClientId(t.clientId)}function LN(e){e.sync()}function RN(e,t){e.load(),t.load()}function PN(e,t,n){e.init(),t.init(),n.init()}function DN(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{
767
- n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}IN.sentry&&zN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;uN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1551.0",beforeSend:(e,t)=>{if(dN>=5)return Mv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++dN;try{const n=t&&t.originalException;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch{}return e}});try{ux("host_config",Nv(window.location.href))}catch{}ux("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),dy(((e,t)=>{hN(e,t)}))}(IN.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),
766
+ MN.$inject=["store","$window"];const IN=function(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r<n.length;r++){var o=void 0;try{o=JSON.parse(n[r].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),zN=function(e){const{version:t,origin:n}=Nv(e.location.href);return"1.1552.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1552.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function ON(e,t){e.setClientId(t.clientId)}function LN(e){e.sync()}function RN(e,t){e.load(),t.load()}function PN(e,t,n){e.init(),t.init(),n.init()}function DN(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{
767
+ n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}IN.sentry&&zN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;uN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1552.0",beforeSend:(e,t)=>{if(dN>=5)return Mv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++dN;try{const n=t&&t.originalException;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch{}return e}});try{ux("host_config",Nv(window.location.href))}catch{}ux("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),dy(((e,t)=>{hN(e,t)}))}(IN.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),
768
768
  ON.$inject=["api","streamer"],LN.$inject=["router"],RN.$inject=["groups","session"],PN.$inject=["autosaveService","persistedDefaults","serviceURL"],DN.$inject=["frameSync","store","toastMessenger"];const FN=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",Hv)}(),async function(e,t=window){const n=function(e){const t=Nv(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Sv,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Ev(t.origin),ancestorLevel:Av(t.ancestorLevel)}}},o={};for(const[e,i]of Object.entries(t))n.includes(e)&&null!==i&&(r[e]?o[e]=r[e](i):o[e]=i);return o}(window),r=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null
769
769
  ;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified");return{targetFrame:Tv(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await kv(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=kv(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,r)}else o=n;const i={...e,...o};return r&&(i.rpc=r),i.apiUrl=function(e){const t=Co(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(IN).then((e=>{!function(e,t){const n=new G
770
770
  ;n.register("analytics",jv).register("annotationsExporter",qb).register("annotationsService",$v).register("annotationActivity",qv).register("api",Gb).register("apiRoutes",ny).register("auth",iy).register("autosaveService",ay).register("dashboard",sy).register("frameSync",wy).register("groups",Ny).register("importAnnotationsService",pN).register("loadAnnotationsService",fN).register("localStorage",vN).register("persistedDefaults",yN).register("router",_N).register("serviceURL",wN).register("session",xN).register("streamer",SN).register("streamFilter",kN).register("tags",TN).register("threadsService",CN).register("toastMessenger",MN).register("store",{factory:hs}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(LN),n.run(PN),n.run(ON),n.run(RN),n.run(Bv),n.run(DN),H(Ze(Oo.Provider,{value:n,children:Ze(yv,{})}),t)}(e,FN)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),H(Ze(_v,{error:e}),t)}(e,FN)));