hypothesis 1.1550.0 → 1.1551.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?d730ec","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?4c623e","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?e9e4b6","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?a4f9be","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.1550.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?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,5 +1,5 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?d730ec",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?c1ec38",
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?4c623e",
16
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?62e729",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?e9e4b6",
18
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?a4f9be",
19
- "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?e91bdd"
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"
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.1550.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.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,
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([]),
@@ -537,11 +537,11 @@ const i=ue(),[a,s]=ae([]),[l,c]=ae(-1),[u,d]=ae(!1),[h]=ae((()=>(++Op,`TagEditor
537
537
  title:"View more information about the Creative Commons Public Domain dedication",underline:"none",variant:"text-light",children:Ze("div",{className:"flex items-center",children:[Ze(St,{className:"w-[10px] h-[10px]"}),Ze(Et,{className:"w-[10px] h-[10px] ml-px"}),Ze("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})})}function Pp(e){return null!==e.offsetParent}function Dp({className:e,closeMenu:t,children:n,visible:r}){const o=ue(null);le((()=>{let e;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return Ze("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Pp);let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(e.key){case"ArrowLeft":case"Escape":t&&(t(e),i=!0);break;case"ArrowUp":r-=1,r<0&&(r=n.length-1),i=!0;break;case"ArrowDown":r+=1,r===n.length&&(r=0),i=!0;break;case"Home":r=0,
538
538
  i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}let Fp=!1;const Bp=()=>{};function Hp({align:e="left",children:t,containerPositioned:n=!0,contentClass:r,defaultOpen:o=!1,disabled:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[d,h]=ae(o);"boolean"==typeof s&&(d=s,h=l||Bp);const m=ue(d);le((()=>{"function"==typeof l&&m.current!==d&&(m.current=d,l(d))}),[d,l]);const p=e=>{if("mousedown"===e.type)Fp=!0;else if("click"===e.type&&Fp)return Fp=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=he((()=>h(!1)),[h]),g=ue(null);Ce(g,f,{enabled:d});const v=e=>e.stopPropagation();return Ze("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:n?"relative":"static"},onClick:v,onMouseDown:v,children:[Ze("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:Xe("focus-visible-ring","flex items-center justify-center rounded transition-colors",{"text-grey-7 hover:text-grey-9":!d,
539
539
  "text-brand":d}),"data-testid":"menu-toggle-button",disabled:i,onMouseDown:p,onClick:p,"aria-label":u,title:u,children:Ze("span",{className:"flex items-center gap-x-1",children:[a,c&&Ze("span",{className:Xe({"rotate-180 text-color-text":d}),children:Ze(qn,{className:"w-2.5 h-2.5"})})]})}),d&&Ze("div",{className:Xe("focus-visible-ring","absolute top-[calc(100%+3px)] z-1","border shadow-intense rounded-lg overflow-hidden bg-white text-md",{"left-0":"left"===e,"right-0":"right"===e},r),"data-testid":"menu-content",role:"menu",tabIndex:-1,onClick:f,onKeyDown:e=>{const t=e.key;"Enter"!==t&&" "!==t||setTimeout((()=>{f()}))},children:Ze(Dp,{visible:!0,children:t})})]})}function jp({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?Hn:qn;return Ze("div",{"data-testid":"submenu-toggle",role:"none",className:Xe("flex flex-col items-center justify-center w-10 h-10","text-grey-6 bg-grey-1","bg-clip-content border-[8px] border-transparent rounded-xl","group-hover:hover:text-grey-8",{"bg-grey-4":t,
540
- "group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Ze(r,{className:"w-3 h-3",viewBox:"0 0 16 16"})})}function qp({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d}){const h=ue(null);let m,p;const f="boolean"==typeof a,g="boolean"==typeof o;le((()=>()=>{clearTimeout(m)}),[]);const v=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},b=t?Ze(t,{className:"h-3 w-3"}):null,y=i?null:b,_=i?b:null,w=!!_,k=Ze(x,{children:[(l||i||!!y)&&Ze("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??y}),Ze("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),w&&Ze("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:_}),f&&Ze(jp,{title:`Show actions for ${s}`,isExpanded:a,onToggleSubmenu:u})]
541
- }),N=Xe("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","rounded-none",{"focus-visible:rounded-lg":!o,"focus-visible:rounded-r-lg":o,"cursor-pointer":!n},"group",{"min-h-[30px] font-normal":i,"min-h-[40px] font-medium":!i,"bg-grey-1":i||r,"hover:bg-grey-3":!n&&(i||r),"bg-white":!i&&!r,"hover:bg-grey-1":!n&&!i&&!r,"pr-1":!f},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return p=e?Ze("a",{ref:h,className:N,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:v,children:k}):Ze("div",{ref:h,className:N,"data-testid":"menu-item",tabIndex:-1,onKeyDown:v,onClick:c,role:g?"menuitemradio":"menuitem","aria-checked":g?o:void 0,"aria-haspopup":f,"aria-expanded":f?a:void 0,children:k}),Ze(x,{children:[p,f&&Ze(To,{direction:a?"in":"out",children:Ze(Dp,{closeMenu:e=>{u&&u(e),m=setTimeout((()=>{h.current.focus()}))},visible:a,
542
- className:"border-y border-grey-3",children:d})})]})}var $p=Lo((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=zo(["ctaTextColor","ctaBackgroundColor"],a),l=Ze("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Ze(qn,{className:"w-4 h-4"})});return Ze("div",{className:"flex flex-row gap-x-3",children:[Ze("div",{className:"flex relative",children:[Ze(xr,{classes:Xe("rounded-r-none"),"data-testid":"publish-control-button",style:s,onClick:o,disabled:t,size:"lg",variant:"primary",children:["Post to ",n?"Only Me":e.name]}),Ze("div",{className:Xe("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Ze(Hp,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Ze(qp,{icon:"open"===e.type?hn:bn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Ze(qp,{icon:Pn,label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]
543
- }),Ze("div",{children:Ze(xr,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Ze(yt,{}),"Cancel"]})})]})}),["settings"]);var Up=Lo((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){const[a,s]=ae(null),l=ms(),c=l.getGroup(e.group),u=de((()=>gi(e)),[e]),d=!t.isPrivate&&c&&"private"!==c.type,h=t.tags,m=t.text,p=!m&&!h.length,f=he((e=>{l.createDraft(t.annotation,{...t,tags:e})}),[t,l]),g=he((e=>{if(!e||h.indexOf(e)>=0)return!1;const t=[...h,e];return o.store(t),f(t),!0}),[f,h,o]),v=he((e=>{const t=[...h],n=t.indexOf(e);return n>=0&&(t.splice(n,1),f(t),!0)}),[f,h]),b=he((e=>{l.createDraft(t.annotation,{...t,text:e})}),[t,l]),y=he((n=>{l.createDraft(e,{...t,isPrivate:n}),u||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,u,l]),_=async()=>{a&&g(a);const t=`${Ei(e)} ${vi(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch{i.error("Saving annotation failed")}},w=he((()=>{l.removeDraft(e),vi(e)||l.removeAnnotations([e])
544
- }),[e,l]);return Ze("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;p||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),_())},children:[Ze(Mp,{textStyle:zo(["annotationFontFamily"],r),label:u?"Enter reply":"Enter comment",text:m,onEditText:b,atMentionsEnabled:l.isFeatureEnabled("at_mentions")}),Ze(Lp,{onAddTag:g,onRemoveTag:v,onTagInput:s,tagList:h}),c&&Ze($p,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:w,onSave:_,onSetPrivate:y}),d&&Ze(Rp,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Gp({domain:e,link:t,title:n}){return Ze("div",{className:"flex gap-x-1",children:[Ze("div",{className:"text-color-text-light",children:['on "',t?Ze(bo,{href:t,target:"_blank",underline:"none",children:n}):Ze("span",{children:n}),'"']}),e&&Ze("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function Vp({group:e}){const t=e?.links.html;return Ze(x,{children:e&&t&&Ze(bo,{
540
+ "group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Ze(r,{className:"w-3 h-3",viewBox:"0 0 16 16"})})}function qp({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d,submenuToggleTitle:h}){const m=ue(null);let p,f;const g="boolean"==typeof a,v="boolean"==typeof o;le((()=>()=>{clearTimeout(p)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},y=t?Ze(t,{className:"h-3 w-3"}):null,_=i?null:y,w=i?y:null,k=!!w,N=Ze(x,{children:[(l||i||!!_)&&Ze("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??_}),Ze("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),k&&Ze("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),g&&Ze(jp,{title:h??("string"==typeof s?`Show actions for ${s}`:"Toggle submenu"),
541
+ isExpanded:a,onToggleSubmenu:u})]}),S=Xe("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","rounded-none",{"focus-visible:rounded-lg":!o,"focus-visible:rounded-r-lg":o,"cursor-pointer":!n},"group",{"min-h-[30px] font-normal":i,"min-h-[40px] font-medium":!i,"bg-grey-1":i||r,"hover:bg-grey-3":!n&&(i||r),"bg-white":!i&&!r,"hover:bg-grey-1":!n&&!i&&!r,"pr-1":!g},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return f=e?Ze("a",{ref:m,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:N}):Ze("div",{ref:m,className:S,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:v?"menuitemradio":"menuitem","aria-checked":v?o:void 0,"aria-haspopup":g,"aria-expanded":g?a:void 0,children:N}),Ze(x,{children:[f,g&&Ze(To,{direction:a?"in":"out",children:Ze(Dp,{closeMenu:e=>{u&&u(e),p=setTimeout((()=>{m.current.focus()}))},
542
+ visible:a,className:"border-y border-grey-3",children:d})})]})}var $p=Lo((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=zo(["ctaTextColor","ctaBackgroundColor"],a),l=Ze("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Ze(qn,{className:"w-4 h-4"})});return Ze("div",{className:"flex flex-row gap-x-3",children:[Ze("div",{className:"flex relative",children:[Ze(xr,{classes:Xe("rounded-r-none"),"data-testid":"publish-control-button",style:s,onClick:o,disabled:t,size:"lg",variant:"primary",children:["Post to ",n?"Only Me":e.name]}),Ze("div",{className:Xe("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Ze(Hp,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Ze(qp,{icon:"open"===e.type?hn:bn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Ze(qp,{icon:Pn,label:"Only Me",isSelected:n,onClick:()=>i(!0)
543
+ })]})})]}),Ze("div",{children:Ze(xr,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Ze(yt,{}),"Cancel"]})})]})}),["settings"]);var Up=Lo((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){const[a,s]=ae(null),l=ms(),c=l.getGroup(e.group),u=de((()=>gi(e)),[e]),d=!t.isPrivate&&c&&"private"!==c.type,h=t.tags,m=t.text,p=!m&&!h.length,f=he((e=>{l.createDraft(t.annotation,{...t,tags:e})}),[t,l]),g=he((e=>{if(!e||h.indexOf(e)>=0)return!1;const t=[...h,e];return o.store(t),f(t),!0}),[f,h,o]),v=he((e=>{const t=[...h],n=t.indexOf(e);return n>=0&&(t.splice(n,1),f(t),!0)}),[f,h]),b=he((e=>{l.createDraft(t.annotation,{...t,text:e})}),[t,l]),y=he((n=>{l.createDraft(e,{...t,isPrivate:n}),u||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,u,l]),_=async()=>{a&&g(a);const t=`${Ei(e)} ${vi(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch{i.error("Saving annotation failed")}},w=he((()=>{l.removeDraft(e),
544
+ vi(e)||l.removeAnnotations([e])}),[e,l]);return Ze("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;p||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),_())},children:[Ze(Mp,{textStyle:zo(["annotationFontFamily"],r),label:u?"Enter reply":"Enter comment",text:m,onEditText:b,atMentionsEnabled:l.isFeatureEnabled("at_mentions")}),Ze(Lp,{onAddTag:g,onRemoveTag:v,onTagInput:s,tagList:h}),c&&Ze($p,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:w,onSave:_,onSetPrivate:y}),d&&Ze(Rp,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Gp({domain:e,link:t,title:n}){return Ze("div",{className:"flex gap-x-1",children:[Ze("div",{className:"text-color-text-light",children:['on "',t?Ze(bo,{href:t,target:"_blank",underline:"none",children:n}):Ze("span",{children:n}),'"']}),e&&Ze("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function Vp({group:e}){const t=e?.links.html;return Ze(x,{children:e&&t&&Ze(bo,{
545
545
  classes:Xe("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:Ze("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?Ze(hn,{className:"w-2.5 h-2.5"}):Ze(bn,{className:"w-2.5 h-2.5"}),Ze("span",{children:e.name})]})})})}function Wp({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){const[o,i]=ae((()=>new Date)),a=de((()=>new Date(e)),[e]),s=de((()=>r&&new Date(t)),[t,r]),l=de((()=>({absolute:Ge(a,{includeWeekday:!0}),relative:Ue(a,o)})),[a,o]),c=de((()=>s?{absolute:Ge(s,{includeWeekday:!0}),relative:Ue(s,o)}:{}),[s,o]);le((()=>$e(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Ze("div",{children:[r&&Ze("span",{className:"text-color-text-light text-xs italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Ze(bo,{classes:"text-color-text-light hover:text-color-text-light",target:"_blank",
546
546
  title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative}):Ze("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function Kp({authorLink:e,displayName:t}){const n=Ze("h3",{className:"text-color-text font-bold",children:t});return e?Ze(bo,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):Ze("div",{children:n})}var Yp=Lo((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){const i=ms(),a=i.defaultAuthority(),s=i.isFeatureEnabled("client_display_names"),l=i.getLink("user",{user:e.user}),c=de((()=>Cs(e,a,s)),[e,a,s]),u=de((()=>function(e,t,n,r){return!Ts(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${Es(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=gi(e)&&r,h=e.links?.html||"",m=de((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3
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,{
@@ -564,7 +564,7 @@ const Mf=/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5
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.1550.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.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])}
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){
@@ -605,10 +605,10 @@ description:`Show ${n} selected annotations`,active:!0,setActive:()=>t.clearSele
605
605
  const i=ms(),a=i.focusedGroupId(),s=i.isLoading(),l=i.isLoggedIn(),c=i.directLinkedAnnotationId(),u=c?i.findAnnotationByID(c):void 0,d=u?$f(u):"annotation",h=i.searchUris(),m=i.hasSidebarOpened(),p=i.profile().userid,f=!(s||!c)&&!u,g=i.directLinkedGroupFetchFailed(),v=f||g,b=i.isSidebarPanelOpen("searchAnnotations"),y=!v&&!b,_=c&&!l&&!f&&!s,w=ue(a);le((()=>{if(!w.current||w.current!==a){if(w.current){const e=i.focusState().active;i.clearSelection(),e&&i.toggleFocusMode({active:!0})}w.current=a}a&&h.length&&r.load({groupId:a,uris:h})}),[i,r,a,p,h]),le((()=>{u&&!1===u.$orphan?(e.hoverAnnotation(u),e.scrollToAnnotation(u),i.selectTab(d)):u&&i.selectTab(d)}),[d,e,u,i]);const x=i.hasFetchedProfile();return le((()=>{x&&(m||l)&&o.connect({applyUpdatesImmediately:!1})}),[x,l,m,o]),Ze("div",{className:"relative",children:[Ze("h2",{className:"sr-only",children:"Annotations"}),Ze("div",{className:Xe("fixed z-10","right-[9px] top-12"),children:Ze(Sg,{})}),y&&Ze(Xg,{withCardContainer:!0}),Ze($g,{onLogin:t,onSignUp:n
606
606
  }),f&&Ze(ps,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),g&&Ze(ps,{errorType:"group",onLoginRequest:t}),!v&&Ze(Wg,{isLoading:s}),_&&Ze(qg,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Qg=Lo((function({api:e,toastMessenger:t}){const n=ms(),r=n.routeParams().q,o=he((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...qf(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);le((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r??"").catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]);const{rootThread:i}=Kf();return Ze(df,{threads:i.children})}),["api","toastMessenger"]);var Zg=Lo((function({toastMessenger:e}){const t=ms().getToastMessages();return Ze("div",{className:Xe("z-10","absolute left-0 w-full"),children:Ze(go,{messages:t,onMessageDismiss:t=>e.dismiss(t),transitionClasses:{
607
607
  transitionIn:"motion-safe:animate-slide-in-from-right lg:animate-fade-in motion-reduce:animate-fade-in"}})})}),["toastMessenger"]);function ev(e){return e.organization&&e.organization.name}const tv="__default__";function nv(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;const n=(r=e.organization).id===tv?tv:`${r.name.toLowerCase()}${r.id}`;var r;void 0===t[n]&&(t[n]={...e.organization,groups:[]}),function(e,t){const n=Object.assign({},e),r=t.groups;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function rv(e){const t=nv(e),n=[],r=[];return Object.keys(t).sort().forEach((e=>{e===tv?n.push(...t[e].groups):r.push(...t[e].groups)})),n.length&&r.push(...n),r}function ov({heading:e,children:t}){return Ze(x,{children:[e&&Ze("h2",{className:"text-color-text-light p-3 leading-none uppercase",children:e}),Ze("ul",{className:"border-b",children:M(t).map((e=>Ze("li",{children:e},e.key)))})]})}function iv({type:e}){return Ze("div",{
608
- className:"text-color-text-light",title:"open"===e?"Public group":"restricted"===e?"Restricted group":"Private group","data-testid":"group-icon",children:["open"===e&&Ze(pn,{}),"restricted"===e&&Ze(gn,{}),"private"===e&&Ze(Pn,{})]})}var av=Lo((function({isExpanded:e,group:t,groups:n,onExpand:r,toastMessenger:o}){const i=t.links.html,a=i||t.canLeave,s=t.scopes&&!t.scopes.enforced||t.isScopedToUri,l=ms(),c=l.focusedGroupId(),u=t.id===c,d=t=>{t.stopPropagation(),t.preventDefault(),r(!e)},h="private"===t.type?"Copy invite link":"Copy activity link",m=t.logo?Ze("img",{className:"w-4 h-4",alt:ev(t),src:t.logo}):Ze("span",{className:"sr-only",children:ev(t)});return Ze(qp,{isDisabled:!s,isExpanded:!!a&&e,isSelected:u,isSubmenuVisible:a?e:void 0,label:Ze("div",{className:"grow flex items-center justify-between gap-x-2",children:[t.name,Ze(iv,{type:t.type})]}),leftChannelContent:m,onClick:s?()=>{l.clearDirectLinkedGroupFetchFailed(),l.clearDirectLinkedIds(),n.focus(t.id)}:d,onToggleSubmenu:d,submenu:Ze(x,{
609
- children:[Ze("ul",{children:[i&&Ze("li",{children:Ze(qp,{href:i,icon:rn,isSubmenuItem:!0,label:"View group activity"})}),i&&Ze("li",{children:Ze(qp,{onClick:()=>(async e=>{try{await Fs(e),o.success(`Copied link for "${t.name}"`)}catch{o.error("Unable to copy link")}})(i),icon:Bt,isSubmenuItem:!0,label:h})}),t.canLeave&&Ze("li",{children:Ze(qp,{icon:Tn,isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await jr({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&Ze("p",{className:Xe("p-2 pl-9 bg-grey-1 hyphens-none"),"data-testid":"unselectable-group-note",children:"This group is restricted to specific URLs."})]})})}),["groups","toastMessenger"]);function sv({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return Ze(ov,{heading:r,children:n.map((n=>Ze(av,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}var lv=Lo((function({settings:e}){
610
- const t=ms(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=t.importsPending()>0,l=de((()=>rv(o)),[o]),c=de((()=>rv(r)),[r]),u=de((()=>rv(n)),[n]),d=t.defaultAuthority(),h=a&&!Ts(a,d),m=t.getLink("groups.new"),[p,f]=ae(null);let g;if(i){const t=i.organization.logo||function(e){const t=Co(e);return t&&t.icon?t.icon:null}(e)||"",n=ev(i)?ev(i):"";g=Ze("span",{className:Xe("py-1"),children:Ze("span",{className:Xe("shrink-0 flex items-center gap-x-1 text-md text-color-text font-bold"),children:[t&&Ze("img",{className:Xe("relative top-[1px] w-4 h-4"),src:t,alt:n}),i.name]})})}else g=Ze("span",{children:"…"});return!!Mo(e)&&n.length+r.length+o.length<2?g:Ze(Hp,{align:"left",contentClass:"min-w-[250px]",disabled:s,label:g,onOpenChanged:()=>f(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[u.length>0&&Ze(sv,{expandedGroup:p,onExpandGroup:f,heading:"Currently Viewing",groups:u}),c.length>0&&Ze(sv,{expandedGroup:p,
611
- onExpandGroup:f,heading:"Featured Groups",groups:c}),l.length>0&&Ze(sv,{expandedGroup:p,onExpandGroup:f,heading:"My Groups",groups:l}),h&&Ze(qp,{icon:Vn,href:m,label:"Create new group"})]})}),["settings"]);function cv(){const e=ms(),t=e.sortKey(),n=e.sortKeys().map((n=>Ze(qp,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Ze("span",{className:"p-1",children:Ze(gr,{})});return Ze("div",{"data-component":"SortMenu",children:Ze(Hp,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}function uv({classes:e,...t}){return Ze(Er,{...t,classes:Xe(e,"border border-transparent","aria-pressed:border-grey-3 aria-pressed:bg-grey-1")})}function dv(e){return Ze(uv,{size:"custom",classes:"touch:min-w-touch-minimum p-1",...e})}var hv=Lo((function({dashboard:e,isMenuOpen:t,toastMessenger:n}){const[r,o]=ae(),i=!r,a=he((()=>{"string"!=typeof r?r&&n.error("Can't open dashboard: You must reload the page.",{autoDismiss:!1}):e.open(r)}),[r,e,n])
608
+ className:"text-color-text-light",title:"open"===e?"Public group":"restricted"===e?"Restricted group":"Private group","data-testid":"group-icon",children:["open"===e&&Ze(pn,{}),"restricted"===e&&Ze(gn,{}),"private"===e&&Ze(Pn,{})]})}var av=Lo((function({isExpanded:e,group:t,groups:n,onExpand:r,toastMessenger:o}){const i=t.links.html,a=i||t.canLeave,s=t.scopes&&!t.scopes.enforced||t.isScopedToUri,l=ms(),c=l.focusedGroupId(),u=t.id===c,d=t=>{t.stopPropagation(),t.preventDefault(),r(!e)},h="private"===t.type?"Copy invite link":"Copy activity link",m=t.logo?Ze("img",{className:"w-4 h-4",alt:ev(t),src:t.logo}):Ze("span",{className:"sr-only",children:ev(t)});return Ze(qp,{isDisabled:!s,isExpanded:!!a&&e,isSelected:u,isSubmenuVisible:a?e:void 0,label:Ze("div",{className:"grow flex items-center justify-between gap-x-2",children:[t.name,Ze(iv,{type:t.type})]}),leftChannelContent:m,onClick:s?()=>{l.clearDirectLinkedGroupFetchFailed(),l.clearDirectLinkedIds(),n.focus(t.id)}:d,onToggleSubmenu:d,
609
+ submenuToggleTitle:`Show actions for ${t.name}`,submenu:Ze(x,{children:[Ze("ul",{children:[i&&Ze("li",{children:Ze(qp,{href:i,icon:rn,isSubmenuItem:!0,label:"View group activity"})}),i&&Ze("li",{children:Ze(qp,{onClick:()=>(async e=>{try{await Fs(e),o.success(`Copied link for "${t.name}"`)}catch{o.error("Unable to copy link")}})(i),icon:Bt,isSubmenuItem:!0,label:h})}),t.canLeave&&Ze("li",{children:Ze(qp,{icon:Tn,isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await jr({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&Ze("p",{className:Xe("p-2 pl-9 bg-grey-1 hyphens-none"),"data-testid":"unselectable-group-note",children:"This group is restricted to specific URLs."})]})})}),["groups","toastMessenger"]);function sv({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return Ze(ov,{heading:r,children:n.map((n=>Ze(av,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}
610
+ var lv=Lo((function({settings:e}){const t=ms(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=t.importsPending()>0,l=de((()=>rv(o)),[o]),c=de((()=>rv(r)),[r]),u=de((()=>rv(n)),[n]),d=t.defaultAuthority(),h=a&&!Ts(a,d),m=t.getLink("groups.new"),[p,f]=ae(null);let g;if(i){const t=i.organization.logo||function(e){const t=Co(e);return t&&t.icon?t.icon:null}(e)||"",n=ev(i)?ev(i):"";g=Ze("span",{className:Xe("py-1"),children:Ze("span",{className:Xe("shrink-0 flex items-center gap-x-1 text-md text-color-text font-bold"),children:[t&&Ze("img",{className:Xe("relative top-[1px] w-4 h-4"),src:t,alt:n}),i.name]})})}else g=Ze("span",{children:"…"});return!!Mo(e)&&n.length+r.length+o.length<2?g:Ze(Hp,{align:"left",contentClass:"min-w-[250px]",disabled:s,label:g,onOpenChanged:()=>f(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[u.length>0&&Ze(sv,{expandedGroup:p,onExpandGroup:f,heading:"Currently Viewing",groups:u
611
+ }),c.length>0&&Ze(sv,{expandedGroup:p,onExpandGroup:f,heading:"Featured Groups",groups:c}),l.length>0&&Ze(sv,{expandedGroup:p,onExpandGroup:f,heading:"My Groups",groups:l}),h&&Ze(qp,{icon:Vn,href:m,label:"Create new group"})]})}),["settings"]);function cv(){const e=ms(),t=e.sortKey(),n=e.sortKeys().map((n=>Ze(qp,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Ze("span",{className:"p-1",children:Ze(gr,{})});return Ze("div",{"data-component":"SortMenu",children:Ze(Hp,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}function uv({classes:e,...t}){return Ze(Er,{...t,classes:Xe(e,"border border-transparent","aria-pressed:border-grey-3 aria-pressed:bg-grey-1")})}function dv(e){return Ze(uv,{size:"custom",classes:"touch:min-w-touch-minimum p-1",...e})}var hv=Lo((function({dashboard:e,isMenuOpen:t,toastMessenger:n}){const[r,o]=ae(),i=!r,a=he((()=>{"string"!=typeof r?r&&n.error("Can't open dashboard: You must reload the page.",{autoDismiss:!1}):e.open(r)}),[r,e,n])
612
612
  ;return le((()=>(t&&e.getAuthToken().then(o).catch((e=>{console.warn("An error occurred while getting auth token",e),o(e)})),()=>o(void 0))),[e,t]),Ze(qp,{label:"Open dashboard",isDisabled:i,onClick:a})}),["dashboard","toastMessenger"]);var mv=Lo((function({frameSync:e,onLogout:t,settings:n}){const r=ms(),o=r.defaultAuthority(),i=r.profile(),a=Ts(i.userid,o),s=Co(n),l=Es(i.userid),c=i.user_info?.display_name??l,[u,d]=ae(!1),h=e=>s&&!!s[e],m=!a||h("onProfileRequestProvided"),p=!a||h("onLogoutRequestProvided"),f=r.importsPending()>0,g=r.isFeatureEnabled("client_user_profile"),v=()=>{e.notifyHost("openNotebook",r.focusedGroupId())},b=()=>e.notifyHost("openProfile"),y=m&&!a?r.getLink("user",{user:l}):void 0,_=Ze("span",{className:"p-1",children:Ze(Qn,{})});return Ze("div",{"data-testid":"user-menu",onKeyDown:e=>{"n"===e.key?(v(),d(!1)):g&&"p"===e.key&&(b(),d(!1))},children:Ze(Hp,{label:_,title:c,align:"right",open:u,onOpenChanged:d,children:[Ze(ov,{children:[Ze(qp,{label:c,isDisabled:!m,href:y,
613
613
  onClick:m?()=>a&&e.notifyHost("profileRequested"):void 0}),!a&&Ze(qp,{label:"Account settings",href:r.getLink("account.settings")}),g&&Ze(qp,{label:"Your profile",onClick:()=>b()}),Ze(qp,{label:"Open notebook",onClick:()=>v()})]}),n.dashboard?.showEntryPoint&&Ze(ov,{children:Ze(hv,{isMenuOpen:u})}),p&&Ze(ov,{children:Ze(qp,{isDisabled:f,label:"Log out",onClick:t})})]})})}),["frameSync","settings"]);function pv(){const e=ms(),t=e.isLoading(),n=e.isSidebarPanelOpen("searchAnnotations"),r=he((()=>{e.toggleSidebarPanel("searchAnnotations")}),[e]);return function(e){const t=ue(null),n=he((n=>{!n.metaKey&&!n.ctrlKey&&n.target instanceof HTMLElement&&["INPUT","TEXTAREA"].includes(n.target.tagName)||(t.current=document.activeElement,e.isSidebarPanelOpen("searchAnnotations")||(e.openSidebarPanel("searchAnnotations"),n.preventDefault(),n.stopPropagation()))}),[e]),r=Ps()?"meta":"ctrl";kg("/",n),kg(`${r}+k`,n)}(e),Ze(x,{children:[t&&Ze(co,{}),!t&&Ze(dv,{icon:lr,expanded:n,pressed:n,onClick:r,title:"Search annotations"
614
614
  })]})}function fv({classes:e,disabled:t=!1,inputRef:n,onClearSearch:r,onKeyDown:o,onSearch:i,query:a}){const s=ms().isLoading(),l=ze(n),[c,u]=ae(a),[d,h]=ae(a);kg("/",(e=>{document.activeElement!==l.current&&(e.preventDefault(),l.current?.focus())}));return a!==c&&(h(a),u(a)),Ze("form",{name:"searchForm",onSubmit:e=>{e.preventDefault(),(l.current?.value||c)&&i(l.current?.value??"")},className:Xe("space-y-3",e),children:Ze("div",{className:"relative",children:[Ze(Er,{classes:"absolute left-0 text-[16px] top-[50%] translate-y-[-50%]",icon:lr,size:"lg",title:"Search",type:"submit",disabled:t}),Ze(Kr,{"aria-label":"Search annotations",classes:Xe("pl-8 pr-8","disabled:text-grey-6","text-base touch:text-touch-base"),"data-testid":"search-input",dir:"auto",name:"query",placeholder:s?"Loading…":"Search annotations…",disabled:t||s,elementRef:l,value:d||"",onInput:e=>h(e.target.value),onKeyDown:o}),d&&Ze(Er,{classes:"absolute right-0 text-[16px] top-[50%] translate-y-[-50%]",size:"lg",icon:yt,
@@ -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.1550.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.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")},
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.1550.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1550.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.1550.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.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")})),
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)));