hypothesis 1.1580.0 → 1.1582.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?698d42","styles/annotator.css":"styles/annotator.css?427463","styles/annotator.css.map":"styles/annotator.css.map?94a857","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?d92c5a","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?a3d7cb","styles/sidebar.css.map":"styles/sidebar.css.map?526530","styles/ui-playground.css":"styles/ui-playground.css?8d6c66","styles/ui-playground.css.map":"styles/ui-playground.css.map?b2e29b","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b57f89","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?eb40ec","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?d38ce4","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?f9f8f4","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?964b5b"};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.1580.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?058c3e","styles/annotator.css":"styles/annotator.css?427463","styles/annotator.css.map":"styles/annotator.css.map?94a857","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?d92c5a","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?0e33f1","styles/sidebar.css.map":"styles/sidebar.css.map?9a27bf","styles/ui-playground.css":"styles/ui-playground.css?c7ef72","styles/ui-playground.css.map":"styles/ui-playground.css.map?0df86b","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b57f89","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?616c4e","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?d38ce4","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?964b5b","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?4fc569"};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.1582.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?698d42",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?058c3e",
3
3
  "styles/annotator.css": "styles/annotator.css?427463",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?94a857",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
@@ -8,13 +8,13 @@
8
8
  "styles/katex.min.css.map": "styles/katex.min.css.map?e7e03f",
9
9
  "styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
10
10
  "styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
11
- "styles/sidebar.css": "styles/sidebar.css?a3d7cb",
12
- "styles/sidebar.css.map": "styles/sidebar.css.map?526530",
13
- "styles/ui-playground.css": "styles/ui-playground.css?8d6c66",
14
- "styles/ui-playground.css.map": "styles/ui-playground.css.map?b2e29b",
11
+ "styles/sidebar.css": "styles/sidebar.css?0e33f1",
12
+ "styles/sidebar.css.map": "styles/sidebar.css.map?9a27bf",
13
+ "styles/ui-playground.css": "styles/ui-playground.css?c7ef72",
14
+ "styles/ui-playground.css.map": "styles/ui-playground.css.map?0df86b",
15
15
  "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?b57f89",
16
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?eb40ec",
16
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?616c4e",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?d38ce4",
18
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?f9f8f4",
19
- "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?964b5b"
18
+ "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?964b5b",
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?4fc569"
20
20
  }
@@ -147,7 +147,7 @@ this._sidebarRPC.on("navigateToSegment",(e=>this._integration.navigateToSegment?
147
147
  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=ho.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&&So(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=>({
148
148
  source:n.uri,selector:e}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+Zt(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Cr(),r}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);Eo(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=_o(n),i=wo(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=yr(),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}
149
149
  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){zn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new br(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Ar(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Rr(e,t){const n={}
150
- ;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.1580.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 kr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=se(null);return ie((()=>{e?r.current?.close():r.current?.showModal()}),[e]),ie((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Te("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Pr({closed:e,children:t,...n}){return Te("div",{...n,
150
+ ;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.1582.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 kr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=se(null);return ie((()=>{e?r.current?.close():r.current?.showModal()}),[e]),ie((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Te("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Pr({closed:e,children:t,...n}){return Te("div",{...n,
151
151
  className:ke("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Te("div",{className:"relative w-full h-full",children:t})})}function Tr({document_:e=document,...t}){return Te(ae((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?kr:Pr),[e]),{...t})}function Mr({config:e,groupId:t}){return Te("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Ar(e.notebookAppUrl,{...Rr(e.notebookAppUrl,e),group:t})})}function Lr({eventBus:e,config:t}){const[n,o]=oe(0),[i,r]=oe(!0),[s,a]=oe(null),l=se(""),c=se(null);ie((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),ie((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),ie((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const u=le((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
152
152
  ;return null===s?null:Te(Tr,{closed:i,onClose:u,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Te("div",{className:"absolute right-0 m-3",children:Te(Ct,{title:"Close notebook",onClick:u,variant:"dark",classes:ke("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Te(Fe,{className:"w-4 h-4"})})}),Te(Mr,{config:t,groupId:s},n)]})}class Or{constructor(e,t,n){this._container=new Zn("notebook",(()=>Te(Lr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Ir({eventBus:e,config:t}){const[n,o]=oe(!0),i=se(null);ie((()=>{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:Te(Tr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Te("div",{className:"absolute right-0 m-3",children:Te(Ct,{
153
153
  title:"Close profile dialog",onClick:r,variant:"dark",classes:ke("!bg-transparent enabled:hover:!bg-grey-3"),children:Te(Fe,{className:"w-4 h-4"})})}),Te("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Br{constructor(e,t,n){this._container=new Zn("profile",(()=>Te(Ir,{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 Te("ul",{className:"relative",children:[s&&Te("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:Te(Qt,{"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([]),
@@ -147,32 +147,32 @@ filters:{},focusActive:new Set(Object.keys(t)),focusFilters:t,query:e.query||nul
147
147
  ;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(var s=Object.prototype.hasOwnProperty.bind(t),l=0;l<i.length;l++){var c=i[l];if(!s(c))return!1;var u=e[c],d=t[c];if(!1===(o=n?n.call(r,u,d,c):void 0)||void 0===o&&u!==d)return!1}return!0}));const Sa={CONNECT_FRAME(e,t){const n=e.frames.findIndex((e=>e.id===t.frame.id)),r=[...e.frames];return-1!==n?r[n]=t.frame:r.push(t.frame),{frames:r}},DESTROY_FRAME(e,t){const n=e.frames.filter((e=>e!==t.frame));return{frames:n}},UPDATE_FRAME_ANNOTATION_FETCH_STATUS:(e,t)=>({frames:e.frames.map((e=>e.uri&&e.uri===t.uri?Object.assign({},e,{isAnnotationFetchComplete:t.isAnnotationFetchComplete}):e))}),SET_CONTENT_INFO:(e,t)=>({contentInfo:t.info})};const Aa=e=>e.find((e=>!e.id))||null,Ea=ai((e=>e.frames),Aa),Ta=ai((e=>e.frames),(e=>{const t=Aa(e);return t||(e.length>0?e[0]:null)}));const Ca=ii((function(e,t){const n="object"==typeof t?t:{equalityCheck:t
148
148
  },{equalityCheck:r=Qo,maxSize:o=1,resultEqualityCheck:i}=n,a=function(e){return function(t,n){if(null===t||null===n||t.length!==n.length)return!1;const{length:r}=t;for(let o=0;o<r;o++)if(!e(t[o],n[o]))return!1;return!0}}(r);let s=0;const l=o<=1?function(e){let t;return{get:n=>t&&e(t.key,n)?t.value:Xo,put(e,n){t={key:e,value:n}},getEntries:()=>t?[t]:[],clear(){t=void 0}}}(a):function(e,t){let n=[];function r(e){const r=n.findIndex((n=>t(e,n.key)));if(r>-1){const e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return Xo}return{get:r,put:function(t,o){r(t)===Xo&&(n.unshift({key:t,value:o}),n.length>e&&n.pop())},getEntries:function(){return n},clear:function(){n=[]}}}(o,a);function c(){let t=l.get(arguments);if(t===Xo){if(t=e.apply(null,arguments),s++,i){const e=l.getEntries().find((e=>i(e.value,t)));e&&(t=e.value,0!==s&&s--)}l.put(arguments,t)}return t}return c.clearCache=()=>{l.clear(),c.resetResultsCount()},c.resultsCount=()=>s,c.resetResultsCount=()=>{s=0},c
149
149
  }),Na),Ma=Ca((e=>e.frames.reduce(((e,t)=>e.concat(function(e){let t=[e.uri];return e.metadata&&e.metadata.documentFingerprint&&(t=e.metadata.link.map((e=>e.href))),e.metadata&&e.metadata.link&&e.metadata.link.forEach((e=>{e.href.startsWith("doi:")&&t.push(e.href)})),t}(t))),[])),(e=>e),{devModeChecks:{identityFunctionCheck:"never"}});const Ia=Vo({frames:[],contentInfo:null},{namespace:"frames",reducers:Sa,actionCreators:{connectFrame:function(e){return Go(0,"CONNECT_FRAME",{frame:e})},destroyFrame:function(e){return Go(0,"DESTROY_FRAME",{frame:e})},setContentInfo:function(e){return Go(0,"SET_CONTENT_INFO",{info:e})},updateFrameAnnotationFetchStatus:function(e,t){return Go(0,"UPDATE_FRAME_ANNOTATION_FETCH_STATUS",{uri:e,isAnnotationFetchComplete:t})}},selectors:{getContentInfo:function(e){return e.contentInfo},frames:function(e){return e.frames},mainFrame:Ea,defaultContentFrame:Ta,searchUris:Ma}}),za={FILTER_GROUPS(e,t){if(!t.filteredGroupIds?.length)return{filteredGroupIds:null}
150
- ;const n=e.groups.filter((e=>t.filteredGroupIds.includes(e.id)));if(!n.length)return{filteredGroupIds:null};let r=e.focusedGroupId;return r&&t.filteredGroupIds.includes(r)||(r=n[0].id),{filteredGroupIds:t.filteredGroupIds,focusedGroupId:r}},FOCUS_GROUP(e,t){const n=e.groups.find((e=>e.id===t.id));if(!n)return console.error(`Attempted to focus group ${t.id} which is not loaded`),{};return e.focusedGroupId===t.id?{focusedGroupId:t.id}:{focusedGroupId:t.id,focusedGroupMembers:null}},LOAD_GROUPS(e,t){const n=t.groups;let r=e.focusedGroupId;return null!==e.focusedGroupId&&n.find((t=>t.id===e.focusedGroupId))||(r=n.length>0?n[0].id:null),{focusedGroupId:r,groups:t.groups}},LOAD_FOCUSED_GROUP_MEMBERS(e,t){if(!e.focusedGroupId)throw new Error("A group needs to be focused before loading its members");const{focusedGroupMembers:n}=t;return{focusedGroupMembers:n}},CLEAR_GROUPS:()=>({filteredGroupIds:null,focusedGroupId:null,groups:[],focusedGroupMembers:null})};function La(e){
151
- return e.filteredGroupIds?e.groups.filter((t=>e.filteredGroupIds?.includes(t.id))):e.groups}function Oa(e,t){return e.groups.find((e=>e.id===t))}const Ra=ai((e=>La(e)),(e=>e.filter((e=>!e.isMember&&e.isScopedToUri)))),Pa=ai((e=>La(e)),(e=>e.filter((e=>e.isScopedToUri)))),Da=ai((e=>La(e.groups)),(e=>ji.selectors.isLoggedIn(e.session)),((e,t)=>t?e.filter((e=>e.isMember)):[])),Fa=ai((e=>La(e.groups)),(e=>Da(e)),(e=>Ra(e.groups)),((e,t,n)=>e.filter((e=>!t.includes(e)&&!n.includes(e))))),Ba=Vo({filteredGroupIds:null,groups:[],focusedGroupId:null,focusedGroupMembers:null},{namespace:"groups",reducers:za,actionCreators:{filterGroups:function(e){return Go(0,"FILTER_GROUPS",{filteredGroupIds:e})},focusGroup:function(e){return Go(0,"FOCUS_GROUP",{id:e})},loadGroups:function(e){return Go(0,"LOAD_GROUPS",{groups:e})},startLoadingFocusedGroupMembers:function(){return Go(0,"LOAD_FOCUSED_GROUP_MEMBERS",{focusedGroupMembers:"loading"})},loadFocusedGroupMembers:function(e){return Go(0,"LOAD_FOCUSED_GROUP_MEMBERS",{
152
- focusedGroupMembers:e})},clearGroups:function(){return Go(0,"CLEAR_GROUPS",void 0)}},selectors:{allGroups:function(e){return e.groups},filteredGroups:La,filteredGroupIds:function(e){return e.filteredGroupIds},focusedGroup:function(e){return e.focusedGroupId?Oa(e,e.focusedGroupId)??null:null},focusedGroupId:function(e){return e.focusedGroupId},getFocusedGroupMembers:function(e){return e.focusedGroupMembers},getFeaturedGroups:Ra,getGroup:Oa,getInScopeGroups:Pa},rootSelectors:{getCurrentlyViewingGroups:Fa,getMyGroups:Da}});function Ha(e,t){const n={};for(const r in t)if(li(t,r)){const o=t[r],i=":"+r;-1!==e.indexOf(i)?e=e.replace(i,encodeURIComponent(String(o))):n[r]=o}return{url:e,unusedParams:n}}const ja={UPDATE_LINKS:(e,t)=>({...t.links})};const $a=Vo(null,{namespace:"links",reducers:ja,actionCreators:{updateLinks:function(e){return Go(0,"UPDATE_LINKS",{links:e})}},selectors:{getLink:function(e,t,n={}){if(!e)return"";const r=e[t];if(!r)throw new Error(`Unknown link "${t}"`)
153
- ;const{url:o,unusedParams:i}=Ha(r,n),a=Object.keys(i);if(a.length>0)throw new Error(`Unused parameters: ${a.join(", ")}`);return o}}}),qa={RECEIVE_REAL_TIME_UPDATES:(e,t)=>({pendingUpdates:{...t.pendingUpdates},pendingDeletions:{...t.pendingDeletions}}),CLEAR_PENDING_UPDATES:()=>({pendingUpdates:{},pendingDeletions:{}}),ADD_ANNOTATIONS(e,{annotations:t}){const n={...e.pendingUpdates};for(const e of t)e.id&&delete n[e.id];return{pendingUpdates:n}},REMOVE_ANNOTATIONS(e,{annotationsToRemove:t}){const n={...e.pendingUpdates},r={...e.pendingDeletions};for(const e of t)e.id&&(delete n[e.id],delete r[e.id]);return{pendingUpdates:n,pendingDeletions:r}},FOCUS_GROUP:()=>({pendingUpdates:{},pendingDeletions:{}})};const Ua=ai((e=>e.pendingUpdates),(e=>e.pendingDeletions),((e,t)=>Object.keys(e).length+Object.keys(t).length));const Ga=Vo({pendingUpdates:{},pendingDeletions:{}},{namespace:"realTimeUpdates",reducers:qa,actionCreators:{receiveRealTimeUpdates:function({updatedAnnotations:e=[],deletedAnnotations:t=[]}){
154
- return(n,r)=>{const o={...r().realTimeUpdates.pendingUpdates},i={...r().realTimeUpdates.pendingDeletions};e.forEach((e=>{const t=r().groups,n=r().route;e.group!==Ba.selectors.focusedGroupId(t)&&"sidebar"===Di.selectors.route(n)||(o[e.id]=e)})),t.forEach((e=>{const t=e.id;delete o[t];const n=r().annotations;oa.selectors.annotationExists(n,t)&&(i[t]=!0)})),n(Go(0,"RECEIVE_REAL_TIME_UPDATES",{pendingUpdates:o,pendingDeletions:i}))}},clearPendingUpdates:function(){return Go(0,"CLEAR_PENDING_UPDATES",void 0)}},selectors:{hasPendingDeletion:function(e,t){return li(e.pendingDeletions,t)},hasPendingUpdates:function(e){return Object.keys(e.pendingUpdates).length>0},hasPendingUpdatesOrDeletions:function(e){return Ua(e)>0},pendingDeletions:function(e){return e.pendingDeletions},pendingUpdates:function(e){return e.pendingUpdates},pendingUpdateCount:Ua}}),Va={annotation:"Location",note:"Oldest",orphan:"Location"};function Wa(e){const t={};return e.annotations&&!e.query&&(t[e.annotations]=!0),t}function Ka(e,t){
155
- return t===e?{}:{selectedTab:e,sortKey:Va[e]}}const Ya={CLEAR_ANNOTATION_FOCUS_REQUEST:()=>({focusRequest:null}),CLEAR_SELECTION:()=>({forcedVisible:{},selected:{}}),SELECT_ANNOTATIONS:(e,t)=>({selected:t.selection}),SELECT_TAB:(e,t)=>Ka(t.tab,e.selectedTab),SET_EXPANDED(e,t){const n={...e.expanded};return n[t.id]=t.expanded,{expanded:n}},SET_ANNOTATION_FOCUS_REQUEST:(e,t)=>({focusRequest:t.id}),SET_FORCED_VISIBLE:(e,t)=>({forcedVisible:{...e.forcedVisible,[t.id]:t.visible}}),SET_SORT_KEY:(e,t)=>({sortKey:t.key}),TOGGLE_SELECTED_ANNOTATIONS(e,t){const n={...e.selected};return t.toggleIds.forEach((e=>{n[e]=!n[e]})),{selected:n}},ADD_ANNOTATIONS(e,t){const n=t.annotations.filter((e=>!gi(e))),r=zi(t.annotations,Si)===n.length;return 0===t.currentAnnotationCount&&r?Ka("note",e.selectedTab):{}},CHANGE_FOCUS_MODE_USER:()=>({forcedVisible:{},selected:{}}),SET_FILTER:()=>({forcedVisible:{},selected:{},expanded:{}}),SET_FILTER_QUERY:()=>({forcedVisible:{},selected:{},expanded:{}}),SET_FOCUS_MODE:()=>({
156
- forcedVisible:{},selected:{}}),REMOVE_ANNOTATIONS(e,t){let n=e.selectedTab;"orphan"===n&&0===zi(t.remainingAnnotations,Ni)&&(n="annotation");const r=e=>(t.annotationsToRemove.forEach((t=>{t.id&&delete e[t.id],t.$tag&&delete e[t.$tag]})),e);return{...Ka(n,e.selectedTab),expanded:r({...e.expanded}),forcedVisible:r({...e.forcedVisible}),selected:r({...e.selected})}}};function Xa(){return Go(0,"CLEAR_SELECTION",void 0)}function Za(e){return e.expanded}const Ja=ai((e=>e.forcedVisible),(e=>Oi(e))),Qa=ai((e=>e.selected),(e=>Oi(e).length>0)),es=ai((e=>e.selected),(e=>Oi(e)));function ts(e){return e.selectedTab}const ns=ai((e=>e),(e=>({expanded:Za(e),forcedVisible:Ja(e),selected:es(e),sortKey:rs(e),selectedTab:ts(e)})));function rs(e){return e.sortKey}const os=ai((e=>e.selectedTab),(e=>{const t=["Newest","Oldest"];return"note"!==e&&t.push("Location"),t})),is=Vo((function(e){return{selected:Wa(e),expanded:Wa(e),forcedVisible:{},selectedTab:"annotation",sortKey:Va.annotation,focusRequest:null}}),{namespace:"selection",
157
- reducers:Ya,actionCreators:{clearAnnotationFocusRequest:function(){return Go(0,"CLEAR_ANNOTATION_FOCUS_REQUEST",void 0)},clearSelection:Xa,selectAnnotations:function(e){return t=>{t(Xa()),t(Go(0,"SELECT_ANNOTATIONS",{selection:Li(e)}))}},selectTab:function(e){return Go(0,"SELECT_TAB",{tab:e})},setAnnotationFocusRequest:function(e){return Go(0,"SET_ANNOTATION_FOCUS_REQUEST",{id:e})},setExpanded:function(e,t){return Go(0,"SET_EXPANDED",{id:e,expanded:t})},setForcedVisible:function(e,t){return Go(0,"SET_FORCED_VISIBLE",{id:e,visible:t})},setSortKey:function(e){return Go(0,"SET_SORT_KEY",{key:e})},toggleSelectedAnnotations:function(e){return Go(0,"TOGGLE_SELECTED_ANNOTATIONS",{toggleIds:e})}},selectors:{expandedMap:Za,annotationFocusRequest:function(e){return e.focusRequest},forcedVisibleThreads:Ja,hasSelectedAnnotations:Qa,selectedAnnotations:es,selectedTab:ts,selectionState:ns,sortKey:rs,sortKeys:os}}),as={OPEN_SIDEBAR_PANEL:(e,t)=>({activePanelName:t.panelName}),CLOSE_SIDEBAR_PANEL(e,t){let n=e.activePanelName
158
- ;return t.panelName===n&&(n=null),{activePanelName:n}},TOGGLE_SIDEBAR_PANEL(e,t){let n;const r=e.activePanelName===t.panelName,o=void 0!==t.panelState?t.panelState:!r;return n=o?t.panelName:r&&!o?null:e.activePanelName,{activePanelName:n}}};const ss=Vo({activePanelName:null},{namespace:"sidebarPanels",reducers:as,actionCreators:{openSidebarPanel:function(e){return Go(0,"OPEN_SIDEBAR_PANEL",{panelName:e})},closeSidebarPanel:function(e){return Go(0,"CLOSE_SIDEBAR_PANEL",{panelName:e})},toggleSidebarPanel:function(e,t){return Go(0,"TOGGLE_SIDEBAR_PANEL",{panelName:e,panelState:t})}},selectors:{isSidebarPanelOpen:function(e,t){return e.activePanelName===t}}}),ls={ADD_MESSAGE:(e,t)=>({messages:e.messages.concat({...t.message})}),REMOVE_MESSAGE:(e,t)=>({messages:e.messages.filter((e=>e.id!==t.id))})};const cs=Vo({messages:[]},{namespace:"toastMessages",reducers:ls,actionCreators:{addToastMessage:function(e){return Go(0,"ADD_MESSAGE",{message:e})},removeToastMessage:function(e){return Go(0,"REMOVE_MESSAGE",{id:e})}
159
- },selectors:{getToastMessage:function(e,t){return e.messages.find((e=>e.id===t))},getToastMessages:function(e){return e.messages},hasToastMessage:function(e,t,n){return e.messages.some((e=>e.type===t&&e.message===n))}}}),us={SET_SIDEBAR_OPENED:(e,t)=>!0===t.opened?{sidebarHasOpened:!0}:{}};const ds=Vo({sidebarHasOpened:!1},{namespace:"viewer",reducers:us,actionCreators:{setSidebarOpened:function(e){return Go(0,"SET_SIDEBAR_OPENED",{opened:e})}},selectors:{hasSidebarOpened:function(e){return e.sidebarHasOpened}}});class hs{constructor(e,t,n,r){this.name=e,this.method=t,this.args=n,this.result=r}matches(e,t){return this.name===e&&this.args.every(((e,n)=>t[n]===e))}}function ms(e){return Uo([Yo,oa,aa,la,fa,wa,Ia,$a,Ba,Ga,Di,is,ji,ss,cs,ds],[e],[Wo])}function ps(){var e;return function(e){const[,t]=le((e=>e+1),0),n=de([]).current,r=de(null);if(!r.current){const t=new Map,o=(e,r)=>{const o=e[r];if("function"!=typeof o)return o;let i=t.get(r);return i||(i=(...t)=>{const i=n.find((e=>e.matches(r,t)))
160
- ;if(i)return i.result;const a=e.getState(),s=o.apply(e,t);return a===e.getState()&&n.push(new hs(r,o,t,s)),s},t.set(r,i),i)};r.current=new Proxy(e,{get:o})}return ue((()=>e.subscribe((()=>{n.find((t=>t.method.apply(e,t.args)!==t.result))&&(n.splice(0,n.length),t(0))}))),[n,e]),r.current}((e="store",pe(Mo).get(e)))}function fs({errorType:e,onLoginRequest:t,showClearSelection:n=!1}){const r=ps(),o=r.isLoggedIn();return et("div",{className:"mb-4",children:et(zr,{icon:rr,title:"annotation"===e?"Annotation unavailable":"Group unavailable",children:[et("p",{children:o?"group"===e?"The current URL links to a group, but that group cannot be found,\n or you do not have permission to view the annotations in that group.":"The current URL links to an annotation, but that annotation\n cannot be found, or you do not have permission to view it.":`The ${e} associated with the current URL is unavailable.\n You may need to log in to see it.`}),et("div",{className:"flex justify-end space-x-2",
161
- children:[n&&et(yr,{variant:o?"primary":void 0,onClick:()=>r.clearSelection(),children:"Show all annotations"}),!o&&et(yr,{variant:"primary",onClick:t,children:"Log in"})]})]})})}var gs,vs;ms.$inject=["settings"];var bs=function(){if(vs)return gs;vs=1;var t=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt,l="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,u=l||c||Function("return this")(),d=Object.prototype.toString,h=Math.max,m=Math.min,p=function(){return u.Date.now()};function f(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&d.call(e)==n}(e))return t;if(f(e)){var l="function"==typeof e.valueOf?e.valueOf():e;e=f(l)?l+"":l}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var c=i.test(e);return c||a.test(e)?s(e.slice(2),c?2:8):o.test(e)?t:+e}
162
- return gs=function(e,t,n){var r,o,i,a,s,l,c=0,u=!1,d=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var n=r,i=o;return r=o=void 0,c=t,a=e.apply(i,n)}function y(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=i}function _(){var e=p();if(y(e))return w(e);s=setTimeout(_,function(e){var n=t-(e-l);return d?m(n,i-(e-c)):n}(e))}function w(e){return s=void 0,v&&r?b(e):(r=o=void 0,a)}function x(){var e=p(),n=y(e);if(r=arguments,o=this,l=e,n){if(void 0===s)return function(e){return c=e,s=setTimeout(_,t),u?b(e):a}(l);if(d)return s=setTimeout(_,t),b(l)}return void 0===s&&(s=setTimeout(_,t)),a}return t=g(t)||0,f(n)&&(u=!!n.leading,i=(d="maxWait"in n)?h(g(n.maxWait)||0,t):i,v="trailing"in n?!!n.trailing:v),x.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=o=s=void 0},x.flush=function(){return void 0===s?a:w(p())},x},gs}(),ys=t(bs);const _s={defaultHeight:200,marginAbove:800,marginBelow:800};function ws(e){const t=window.getComputedStyle(e)
163
- ;return e.getBoundingClientRect().height+(parseFloat(t.marginTop)+parseFloat(t.marginBottom))}function xs(e,t){const n=e.visible===t;return e.children.reduce(((e,n)=>e+xs(n,t)),n?1:0)}function ks(e){return xs(e,!1)}function Ns(e){return xs(e,!0)}function Ss(e){const t=e.filter((e=>!!e.annotation)).map((e=>e.annotation));if(t.length)return t;const n=[];if(e.forEach((e=>{e.children&&n.push(...e.children)})),n.length)return Ss(n);throw new Error("Thread contains no annotations")}function As(e,t,n){const r=di(e.user,t);return(n||r)&&e.user_info?.display_name?e.user_info.display_name:ui(e.user)}function Es(e){return/^http(s?):/i.test(e)}function Ts(e){return{read:[e],update:[e],delete:[e]}}function Cs(e,t){return Object.assign(Ts(e),{read:["group:"+t]})}function Ms(e,t,n){return"private"===function(e){switch(e){case"private":case"shared":return e;default:return"shared"}}(n)&&e?Ts(e):Cs(e,t)}function Is(e){return e.read.some((e=>0===e.indexOf("group:")))}function zs(e){return!Is(e)}
164
- const Ls=(e=window.navigator.userAgent)=>e.indexOf("Mac OS")>=0,Os=(e=window.navigator,t="ontouchend"in document)=>["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(e.platform)||e.userAgent.includes("Mac")&&t;async function Rs(e,t=navigator){await t.clipboard.writeText(e)}function Ps({classes:e,direction:t="up"}){return et("up"===t?Wn:Gn,{className:Ze("absolute inline z-2 text-grey-3 fill-white",e)})}function Ds({label:e,icon:t,uri:n}){return et("li",{children:et(fo,{"aria-label":e,classes:"text-grey-6 hover:text-color-text",href:n,title:e,target:"_blank",variant:"custom",underline:"none",children:et(t,{className:"w-em h-em"})})})}function Fs({shareURI:e}){const t=encodeURIComponent(e);return et("div",{className:"pt-2 border-t",children:et("ul",{className:"flex flex-row gap-x-4 items-center justify-center",children:[et(Ds,{icon:dr,label:"Tweet share link",uri:`https://twitter.com/intent/tweet?url=${t}&hashtags=annotated`}),et(Ds,{icon:cr,label:"Share on Facebook",
165
- uri:`https://www.facebook.com/sharer/sharer.php?u=${t}`}),et(Ds,{icon:Jt,label:"Share via email",uri:`mailto:?subject=${encodeURIComponent("Let's Annotate")}&body=${t}`})]})})}var Bs=Io((function({annotation:e,toastMessenger:t,shareUri:n}){const r=ps().getGroup(e.group),o=zs(e.permissions),i=Es(e.uri),a=de(null),s=de(null),[l,c]=se(!1),u=de(l);if(Me(s,(()=>c(!1)),{enabled:l}),ce((()=>{u.current!==l&&(u.current=l,l&&!Os()&&(a.current?.focus(),a.current?.select()))}),[l]),!r)return null;const d=i,h="private"===r.type?et("span",{children:["Only members of the group ",et("em",{children:r.name})," may view this annotation."]}):et("span",{children:"Anyone using this link may view this annotation."}),m=o?et("span",{children:"Only you may view this annotation."}):h;return et("div",{className:"relative",ref:s,tabIndex:-1,children:[et(Nr,{icon:sr,title:"Share",onClick:()=>c(!l),expanded:l}),l&&et("div",{className:"absolute bottom-8 right-0 touch:bottom-touch-minimum",children:et(lt,{
166
- classes:Ze("w-96 max-w-[85vw]","space-y-2 p-2"),width:"custom",children:[et("h2",{className:"text-brand text-md font-medium",children:"Share this annotation"}),et("div",{className:Ze("flex w-full text-xs touch:text-base"),children:et(xr,{children:[et(Gr,{"aria-label":"Use this URL to share this annotation",type:"text",value:n,readOnly:!0,elementRef:a}),et(Nr,{icon:Ft,title:"Copy share link to clipboard",onClick:async()=>{try{await Rs(n),t.success("Copied share link to clipboard")}catch{t.error("Unable to copy link")}},variant:"dark"})]})}),et("div",{className:"text-base font-normal","data-testid":"share-details",children:et(x,i?{children:m}:{children:"This annotation cannot be shared in its original context because it was made on a document that is not available on the web. This link shares the annotation by itself."})}),d&&et(Fs,{shareURI:n}),et(Ps,{direction:"down",classes:"bottom-[-8px] right-2 touch:right-[9px]"})]})})]})}),["toastMessenger"])
167
- ;var Hs=Io((function({annotation:e,annotationsService:t,onReply:n,settings:r,toastMessenger:o}){const i=ps(),a=i.profile(),s=i.isLoggedIn(),l=t=>function(e,t,n){return-1!==e[t].indexOf(n||"")}(e.permissions,t,a.userid),c=l("delete"),u=l("update"),d=function(e){const t=Ao(e);return!1!==t?.allowFlagging}(r)&&!!a.userid&&a.userid!==e.user,h=function(e){const t=Ao(e);return!1!==t?.enableShareLinks}(r)&&function(e){return Es(e.uri)?e.links?.incontext??e.links?.html??null:e.links?.html??null}(e);return et("div",{className:"flex text-[16px]","data-testid":"annotation-action-bar",children:[u&&et(Nr,{icon:$t,title:"Edit",onClick:()=>{i.createDraft(e,{tags:e.tags,text:e.text,isPrivate:zs(e.permissions)})}}),c&&et(Nr,{icon:vr,title:"Delete",onClick:async()=>{const n=Ei(e);if(await Fr({title:`Delete ${n.toLowerCase()}?`,message:`Are you sure you want to delete this ${n.toLowerCase()}?`,confirmAction:"Delete"}))try{await t.delete(e),o.success(`${n} deleted`,{visuallyHidden:!0})}catch(e){o.error(e.message)}}}),et(Nr,{
168
- icon:tr,title:"Reply",onClick:()=>{s?n():i.openSidebarPanel("loginPrompt")}}),h&&et(Bs,{annotation:e,shareUri:h}),d&&!e.flagged&&et(Nr,{icon:sn,title:"Report this annotation to moderators",onClick:()=>{t.flag(e).catch((()=>o.error("Flagging annotation failed")))}}),d&&e.flagged&&et(Nr,{pressed:!0,icon:cn,title:"Annotation has been reported to the moderators"})]})}),["annotationsService","settings","toastMessenger"]);function js({isCollapsed:e,setCollapsed:t,linkStyle:n}){return et("div",{className:Ze("absolute block right-0 bottom-0","w-20 bg-gradient-to-l from-white"),children:et("div",{className:"flex justify-end",children:et(vo,{variant:"text",onClick:()=>t(!e),expanded:!e,title:"Toggle visibility of full excerpt text",style:n,underline:"always",inline:!0,children:e?"More":"Less"})})})}const $s=()=>{};var qs=Io((function({children:e,collapse:t=!1,collapsedHeight:n,inlineControls:r=!0,onCollapsibleChanged:o=$s,onToggleCollapsed:i=$s,overflowThreshold:a=0,settings:s={}}){
169
- const[l,c]=se(!0),u=de(null),[d,h]=se(0),m=me((()=>{const e=u.current.clientHeight;h(e);o(e>n+a)}),[n,o,a]);ue((()=>{const e=function(e,t){const n=new ResizeObserver((()=>t(e.clientWidth,e.clientHeight)));return n.observe(e),()=>n.disconnect()}(u.current,m);return m(),e}),[m]);const p=d>n+a,f=p&&(r?l:t),g={};0!==d&&(g["max-height"]=f?n:d);const v=e=>r?c(e):i(e);return et("div",{"data-testid":"excerpt-container",className:Ze("relative overflow-hidden","transition-[max-height] ease-in duration-150"),style:g,children:[et("div",{className:Ze("inline-block w-full"),"data-testid":"excerpt-content",ref:u,children:e}),et("div",{"data-testid":"excerpt-expand",role:"presentation",onClick:()=>v(!1),className:Ze("transition-[opacity] duration-150 ease-linear","absolute w-full bottom-0 h-touch-minimum",{"bg-gradient-to-b from-excerpt-stop-1 via-excerpt-stop-2 to-excerpt-stop-3":!r&&f,"bg-none":r,"opacity-0 pointer-events-none":!f}),title:"Show the full excerpt"}),p&&r&&et(js,{isCollapsed:l,setCollapsed:v,
170
- linkStyle:Co(["selectionFontFamily"],s)})]})}),["settings"]);const Us=String.raw`[\s,.;:|?!'"\-()[\]{}]`,Gs=new RegExp(`(^|${Us})@([A-Za-z0-9_][A-Za-z0-9._]+[A-Za-z0-9_])(?=${Us}|$)`,"g");const Vs=/<a[^>]\bdata-hyp-mention\b[^>]*>([^<]+)<\/a>/g;function Ws(e,t){const n=e.textContent??"",r=t??n;if(e.hasAttribute("data-hyp-mention-type"))return[e,r];const o=t&&t.link?"link":t?"no-link":"invalid",i=document.createElement("link"===o?"a":"span");return i.setAttribute("data-hyp-mention",""),i.setAttribute("data-hyp-mention-type",o),i.textContent=n,"link"===o&&(i.setAttribute("href",t?.link??""),i.setAttribute("target","_blank")),"invalid"!==o&&i.setAttribute("data-userid",e.dataset.userid??""),e.replaceWith(i),[i,r]}function Ks(e,t){const n=[...e.slice(0,t).matchAll(new RegExp(Us,"g"))],r=n.length>0?Math.max(...n.map((e=>e.index))):-1,o=e.slice(t).search(new RegExp(Us));return{start:r+1,end:-1===o?e.length:t+o}}function Ys(e,t=16/9){const n=document.createElement("iframe");return n.src=e,
171
- n.setAttribute("frameborder","0"),n.setAttribute("allowfullscreen",""),function(e,t){e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%";const n=document.createElement("div");return n.style.paddingBottom=1/t*100+"%",n.style.position="relative",n.appendChild(e),n}(n,t)}function Xs(e){const t=/(\d+)([hms]?)/g,n={h:3600,m:60,s:1};let r,o=0;for(;null!==(r=t.exec(e));)if(r[2]){const e=r[2];o+=Number(r[1])*n[e]}else o+=+r[1];return o.toString()}function Zs(e,t){const n=function(e){const t=["end","start","t"],n=new URLSearchParams(e.search),r=new URLSearchParams;for(const[e,o]of n)t.includes(e)&&("t"===e?r.append("start",Xs(o)):r.append(e,o));r.sort();let o=r.toString();return o&&(o=`?${o}`),o}(t);return Ys(`https://www.youtube.com/embed/${e}${n}`)}function Js(e,t,n,{aspectRatio:r}={}){return o=>{if(o.hostname!==e)return null;const i=t.exec(o.pathname);if(!i)return null;const a=i[1];return Ys(n(a),r)}}const Qs=[function(e){
172
- if("www.youtube.com"!==e.hostname)return null;if(!/\/watch\/?/.test(e.pathname))return null;const t=/[&?]v=([^&#]+)/.exec(e.search);return t?Zs(t[1],e):null},function(e){if("youtu.be"!==e.hostname)return null;const t=/^\/([^/]+)\/?$/.exec(e.pathname);return t?Zs(t[1],e):null},Js("vimeo.com",/^\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),Js("vimeo.com",/^\/channels\/[^/]+\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),function(e){if("archive.org"!==e.hostname)return null;const t=/^\/(embed|details)\/(.+)/.exec(e.pathname);if(!t)return null;let n=t[2];const r=new URLSearchParams(e.search);let o=r.get("start"),i=r.get("end");if(!o){const e=n.match(/\/start\/([^/]+)/);e&&(o=e[1],n=n.replace(e[0],""))}if(!i){const e=n.match(/\/end\/([^/]+)/);e&&(i=e[1],n=n.replace(e[0],""))}const a=new URL(`https://archive.org/embed/${n}`);return o&&a.searchParams.append("start",o),i&&a.searchParams.append("end",i),Ys(a.href)},function(e){
173
- return e.pathname.endsWith(".mp3")||e.pathname.endsWith(".ogg")||e.pathname.endsWith(".wav")?function(e){const t=document.createElement("audio");return t.controls=!0,t.src=e,t}(e.href):null}];function el(e){if(e.href!==e.textContent)try{const t=encodeURI(e.textContent);if(e.href!==t)return null}catch{return null}const t=function(e){let t,n;for(n=0;n<Qs.length;n++)if(t=Qs[n](e),t)return t;return null}(e);return t&&e.parentElement.replaceChild(t,e),t}const{entries:tl,setPrototypeOf:nl,isFrozen:rl,getPrototypeOf:ol,getOwnPropertyDescriptor:il}=Object;let{freeze:al,seal:sl,create:ll}=Object,{apply:cl,construct:ul}="undefined"!=typeof Reflect&&Reflect;al||(al=function(e){return e}),sl||(sl=function(e){return e}),cl||(cl=function(e,t,n){return e.apply(t,n)}),ul||(ul=function(e,t){return new e(...t)})
174
- ;const dl=Al(Array.prototype.forEach),hl=Al(Array.prototype.lastIndexOf),ml=Al(Array.prototype.pop),pl=Al(Array.prototype.push),fl=Al(Array.prototype.splice),gl=Al(String.prototype.toLowerCase),vl=Al(String.prototype.toString),bl=Al(String.prototype.match),yl=Al(String.prototype.replace),_l=Al(String.prototype.indexOf),wl=Al(String.prototype.trim),xl=Al(Object.prototype.hasOwnProperty),kl=Al(RegExp.prototype.test),Nl=(Sl=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ul(Sl,t)});var Sl;function Al(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return cl(e,t,r)}}function El(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:gl;nl&&nl(e,null);let r=t.length;for(;r--;){let o=t[r];if("string"==typeof o){const e=n(o);e!==o&&(rl(t)||(t[r]=e),o=e)}e[o]=!0}return e}function Tl(e){for(let t=0;t<e.length;t++){xl(e,t)||(e[t]=null)}return e}function Cl(e){const t=ll(null);for(const[n,r]of tl(e)){
175
- xl(e,n)&&(Array.isArray(r)?t[n]=Tl(r):r&&"object"==typeof r&&r.constructor===Object?t[n]=Cl(r):t[n]=r)}return t}function Ml(e,t){for(;null!==e;){const n=il(e,t);if(n){if(n.get)return Al(n.get);if("function"==typeof n.value)return Al(n.value)}e=ol(e)}return function(){return null}}
150
+ ;const n=e.groups.filter((e=>t.filteredGroupIds.includes(e.id)));if(!n.length)return{filteredGroupIds:null};let r=e.focusedGroupId;return r&&t.filteredGroupIds.includes(r)||(r=n[0].id),{filteredGroupIds:t.filteredGroupIds,focusedGroupId:r}},FOCUS_GROUP(e,t){const n=e.groups.find((e=>e.id===t.id));if(!n)return console.error(`Attempted to focus group ${t.id} which is not loaded`),{};return e.focusedGroupId===t.id?{focusedGroupId:t.id}:{focusedGroupId:t.id,focusedGroupMembers:{status:"not-loaded"}}},LOAD_GROUPS(e,t){const n=t.groups;let r=e.focusedGroupId;return null!==e.focusedGroupId&&n.find((t=>t.id===e.focusedGroupId))||(r=n.length>0?n[0].id:null),{focusedGroupId:r,groups:t.groups}},LOAD_FOCUSED_GROUP_MEMBERS(e,t){if(!e.focusedGroupId)throw new Error("A group needs to be focused before loading its members");const{focusedGroupMembers:n}=t;return{focusedGroupMembers:n}},CLEAR_GROUPS:()=>({filteredGroupIds:null,focusedGroupId:null,groups:[],focusedGroupMembers:{status:"not-loaded"}})};function La(e){
151
+ return e.filteredGroupIds?e.groups.filter((t=>e.filteredGroupIds?.includes(t.id))):e.groups}function Oa(e,t){return e.groups.find((e=>e.id===t))}const Ra=ai((e=>La(e)),(e=>e.filter((e=>!e.isMember&&e.isScopedToUri)))),Pa=ai((e=>La(e)),(e=>e.filter((e=>e.isScopedToUri)))),Da=ai((e=>La(e.groups)),(e=>ji.selectors.isLoggedIn(e.session)),((e,t)=>t?e.filter((e=>e.isMember)):[])),Fa=ai((e=>La(e.groups)),(e=>Da(e)),(e=>Ra(e.groups)),((e,t,n)=>e.filter((e=>!t.includes(e)&&!n.includes(e))))),Ba=Vo({filteredGroupIds:null,groups:[],focusedGroupId:null,focusedGroupMembers:{status:"not-loaded"}},{namespace:"groups",reducers:za,actionCreators:{filterGroups:function(e){return Go(0,"FILTER_GROUPS",{filteredGroupIds:e})},focusGroup:function(e){return Go(0,"FOCUS_GROUP",{id:e})},loadGroups:function(e){return Go(0,"LOAD_GROUPS",{groups:e})},startLoadingFocusedGroupMembers:function(){return Go(0,"LOAD_FOCUSED_GROUP_MEMBERS",{focusedGroupMembers:{status:"loading"}})},loadFocusedGroupMembers:function(e){
152
+ return Go(0,"LOAD_FOCUSED_GROUP_MEMBERS",{focusedGroupMembers:null===e?{status:"not-loaded"}:{status:"loaded",members:e}})},clearGroups:function(){return Go(0,"CLEAR_GROUPS",void 0)}},selectors:{allGroups:function(e){return e.groups},filteredGroups:La,filteredGroupIds:function(e){return e.filteredGroupIds},focusedGroup:function(e){return e.focusedGroupId?Oa(e,e.focusedGroupId)??null:null},focusedGroupId:function(e){return e.focusedGroupId},getFocusedGroupMembers:function(e){return e.focusedGroupMembers},getFeaturedGroups:Ra,getGroup:Oa,getInScopeGroups:Pa},rootSelectors:{getCurrentlyViewingGroups:Fa,getMyGroups:Da}});function Ha(e,t){const n={};for(const r in t)if(li(t,r)){const o=t[r],i=":"+r;-1!==e.indexOf(i)?e=e.replace(i,encodeURIComponent(String(o))):n[r]=o}return{url:e,unusedParams:n}}const ja={UPDATE_LINKS:(e,t)=>({...t.links})};const $a=Vo(null,{namespace:"links",reducers:ja,actionCreators:{updateLinks:function(e){return Go(0,"UPDATE_LINKS",{links:e})}},selectors:{getLink:function(e,t,n={}){
153
+ if(!e)return"";const r=e[t];if(!r)throw new Error(`Unknown link "${t}"`);const{url:o,unusedParams:i}=Ha(r,n),a=Object.keys(i);if(a.length>0)throw new Error(`Unused parameters: ${a.join(", ")}`);return o}}}),qa={RECEIVE_REAL_TIME_UPDATES:(e,t)=>({pendingUpdates:{...t.pendingUpdates},pendingDeletions:{...t.pendingDeletions}}),CLEAR_PENDING_UPDATES:()=>({pendingUpdates:{},pendingDeletions:{}}),ADD_ANNOTATIONS(e,{annotations:t}){const n={...e.pendingUpdates};for(const e of t)e.id&&delete n[e.id];return{pendingUpdates:n}},REMOVE_ANNOTATIONS(e,{annotationsToRemove:t}){const n={...e.pendingUpdates},r={...e.pendingDeletions};for(const e of t)e.id&&(delete n[e.id],delete r[e.id]);return{pendingUpdates:n,pendingDeletions:r}},FOCUS_GROUP:()=>({pendingUpdates:{},pendingDeletions:{}})};const Ua=ai((e=>e.pendingUpdates),(e=>e.pendingDeletions),((e,t)=>Object.keys(e).length+Object.keys(t).length));const Ga=Vo({pendingUpdates:{},pendingDeletions:{}},{namespace:"realTimeUpdates",reducers:qa,actionCreators:{
154
+ receiveRealTimeUpdates:function({updatedAnnotations:e=[],deletedAnnotations:t=[]}){return(n,r)=>{const o={...r().realTimeUpdates.pendingUpdates},i={...r().realTimeUpdates.pendingDeletions};e.forEach((e=>{const t=r().groups,n=r().route;e.group!==Ba.selectors.focusedGroupId(t)&&"sidebar"===Di.selectors.route(n)||(o[e.id]=e)})),t.forEach((e=>{const t=e.id;delete o[t];const n=r().annotations;oa.selectors.annotationExists(n,t)&&(i[t]=!0)})),n(Go(0,"RECEIVE_REAL_TIME_UPDATES",{pendingUpdates:o,pendingDeletions:i}))}},clearPendingUpdates:function(){return Go(0,"CLEAR_PENDING_UPDATES",void 0)}},selectors:{hasPendingDeletion:function(e,t){return li(e.pendingDeletions,t)},hasPendingUpdates:function(e){return Object.keys(e.pendingUpdates).length>0},hasPendingUpdatesOrDeletions:function(e){return Ua(e)>0},pendingDeletions:function(e){return e.pendingDeletions},pendingUpdates:function(e){return e.pendingUpdates},pendingUpdateCount:Ua}}),Va={annotation:"Location",note:"Oldest",orphan:"Location"};function Wa(e){const t={}
155
+ ;return e.annotations&&!e.query&&(t[e.annotations]=!0),t}function Ka(e,t){return t===e?{}:{selectedTab:e,sortKey:Va[e]}}const Ya={CLEAR_ANNOTATION_FOCUS_REQUEST:()=>({focusRequest:null}),CLEAR_SELECTION:()=>({forcedVisible:{},selected:{}}),SELECT_ANNOTATIONS:(e,t)=>({selected:t.selection}),SELECT_TAB:(e,t)=>Ka(t.tab,e.selectedTab),SET_EXPANDED(e,t){const n={...e.expanded};return n[t.id]=t.expanded,{expanded:n}},SET_ANNOTATION_FOCUS_REQUEST:(e,t)=>({focusRequest:t.id}),SET_FORCED_VISIBLE:(e,t)=>({forcedVisible:{...e.forcedVisible,[t.id]:t.visible}}),SET_SORT_KEY:(e,t)=>({sortKey:t.key}),TOGGLE_SELECTED_ANNOTATIONS(e,t){const n={...e.selected};return t.toggleIds.forEach((e=>{n[e]=!n[e]})),{selected:n}},ADD_ANNOTATIONS(e,t){const n=t.annotations.filter((e=>!gi(e))),r=zi(t.annotations,Si)===n.length;return 0===t.currentAnnotationCount&&r?Ka("note",e.selectedTab):{}},CHANGE_FOCUS_MODE_USER:()=>({forcedVisible:{},selected:{}}),SET_FILTER:()=>({forcedVisible:{},selected:{},expanded:{}}),SET_FILTER_QUERY:()=>({
156
+ forcedVisible:{},selected:{},expanded:{}}),SET_FOCUS_MODE:()=>({forcedVisible:{},selected:{}}),REMOVE_ANNOTATIONS(e,t){let n=e.selectedTab;"orphan"===n&&0===zi(t.remainingAnnotations,Ni)&&(n="annotation");const r=e=>(t.annotationsToRemove.forEach((t=>{t.id&&delete e[t.id],t.$tag&&delete e[t.$tag]})),e);return{...Ka(n,e.selectedTab),expanded:r({...e.expanded}),forcedVisible:r({...e.forcedVisible}),selected:r({...e.selected})}}};function Xa(){return Go(0,"CLEAR_SELECTION",void 0)}function Za(e){return e.expanded}const Ja=ai((e=>e.forcedVisible),(e=>Oi(e))),Qa=ai((e=>e.selected),(e=>Oi(e).length>0)),es=ai((e=>e.selected),(e=>Oi(e)));function ts(e){return e.selectedTab}const ns=ai((e=>e),(e=>({expanded:Za(e),forcedVisible:Ja(e),selected:es(e),sortKey:rs(e),selectedTab:ts(e)})));function rs(e){return e.sortKey}const os=ai((e=>e.selectedTab),(e=>{const t=["Newest","Oldest"];return"note"!==e&&t.push("Location"),t})),is=Vo((function(e){return{selected:Wa(e),expanded:Wa(e),forcedVisible:{},selectedTab:"annotation",
157
+ sortKey:Va.annotation,focusRequest:null}}),{namespace:"selection",reducers:Ya,actionCreators:{clearAnnotationFocusRequest:function(){return Go(0,"CLEAR_ANNOTATION_FOCUS_REQUEST",void 0)},clearSelection:Xa,selectAnnotations:function(e){return t=>{t(Xa()),t(Go(0,"SELECT_ANNOTATIONS",{selection:Li(e)}))}},selectTab:function(e){return Go(0,"SELECT_TAB",{tab:e})},setAnnotationFocusRequest:function(e){return Go(0,"SET_ANNOTATION_FOCUS_REQUEST",{id:e})},setExpanded:function(e,t){return Go(0,"SET_EXPANDED",{id:e,expanded:t})},setForcedVisible:function(e,t){return Go(0,"SET_FORCED_VISIBLE",{id:e,visible:t})},setSortKey:function(e){return Go(0,"SET_SORT_KEY",{key:e})},toggleSelectedAnnotations:function(e){return Go(0,"TOGGLE_SELECTED_ANNOTATIONS",{toggleIds:e})}},selectors:{expandedMap:Za,annotationFocusRequest:function(e){return e.focusRequest},forcedVisibleThreads:Ja,hasSelectedAnnotations:Qa,selectedAnnotations:es,selectedTab:ts,selectionState:ns,sortKey:rs,sortKeys:os}}),as={OPEN_SIDEBAR_PANEL:(e,t)=>({
158
+ activePanelName:t.panelName}),CLOSE_SIDEBAR_PANEL(e,t){let n=e.activePanelName;return t.panelName===n&&(n=null),{activePanelName:n}},TOGGLE_SIDEBAR_PANEL(e,t){let n;const r=e.activePanelName===t.panelName,o=void 0!==t.panelState?t.panelState:!r;return n=o?t.panelName:r&&!o?null:e.activePanelName,{activePanelName:n}}};const ss=Vo({activePanelName:null},{namespace:"sidebarPanels",reducers:as,actionCreators:{openSidebarPanel:function(e){return Go(0,"OPEN_SIDEBAR_PANEL",{panelName:e})},closeSidebarPanel:function(e){return Go(0,"CLOSE_SIDEBAR_PANEL",{panelName:e})},toggleSidebarPanel:function(e,t){return Go(0,"TOGGLE_SIDEBAR_PANEL",{panelName:e,panelState:t})}},selectors:{isSidebarPanelOpen:function(e,t){return e.activePanelName===t}}}),ls={ADD_MESSAGE:(e,t)=>({messages:e.messages.concat({...t.message})}),REMOVE_MESSAGE:(e,t)=>({messages:e.messages.filter((e=>e.id!==t.id))})};const cs=Vo({messages:[]},{namespace:"toastMessages",reducers:ls,actionCreators:{addToastMessage:function(e){return Go(0,"ADD_MESSAGE",{
159
+ message:e})},removeToastMessage:function(e){return Go(0,"REMOVE_MESSAGE",{id:e})}},selectors:{getToastMessage:function(e,t){return e.messages.find((e=>e.id===t))},getToastMessages:function(e){return e.messages},hasToastMessage:function(e,t,n){return e.messages.some((e=>e.type===t&&e.message===n))}}}),us={SET_SIDEBAR_OPENED:(e,t)=>!0===t.opened?{sidebarHasOpened:!0}:{}};const ds=Vo({sidebarHasOpened:!1},{namespace:"viewer",reducers:us,actionCreators:{setSidebarOpened:function(e){return Go(0,"SET_SIDEBAR_OPENED",{opened:e})}},selectors:{hasSidebarOpened:function(e){return e.sidebarHasOpened}}});class hs{constructor(e,t,n,r){this.name=e,this.method=t,this.args=n,this.result=r}matches(e,t){return this.name===e&&this.args.every(((e,n)=>t[n]===e))}}function ms(e){return Uo([Yo,oa,aa,la,fa,wa,Ia,$a,Ba,Ga,Di,is,ji,ss,cs,ds],[e],[Wo])}function ps(){var e;return function(e){const[,t]=le((e=>e+1),0),n=de([]).current,r=de(null);if(!r.current){const t=new Map,o=(e,r)=>{const o=e[r];if("function"!=typeof o)return o
160
+ ;let i=t.get(r);return i||(i=(...t)=>{const i=n.find((e=>e.matches(r,t)));if(i)return i.result;const a=e.getState(),s=o.apply(e,t);return a===e.getState()&&n.push(new hs(r,o,t,s)),s},t.set(r,i),i)};r.current=new Proxy(e,{get:o})}return ue((()=>e.subscribe((()=>{n.find((t=>t.method.apply(e,t.args)!==t.result))&&(n.splice(0,n.length),t(0))}))),[n,e]),r.current}((e="store",pe(Mo).get(e)))}function fs({errorType:e,onLoginRequest:t,showClearSelection:n=!1}){const r=ps(),o=r.isLoggedIn();return et("div",{className:"mb-4",children:et(zr,{icon:rr,title:"annotation"===e?"Annotation unavailable":"Group unavailable",children:[et("p",{
161
+ children:o?"group"===e?"The current URL links to a group, but that group cannot be found,\n or you do not have permission to view the annotations in that group.":"The current URL links to an annotation, but that annotation\n cannot be found, or you do not have permission to view it.":`The ${e} associated with the current URL is unavailable.\n You may need to log in to see it.`}),et("div",{className:"flex justify-end space-x-2",children:[n&&et(yr,{variant:o?"primary":void 0,onClick:()=>r.clearSelection(),children:"Show all annotations"}),!o&&et(yr,{variant:"primary",onClick:t,children:"Log in"})]})]})})}var gs,vs;ms.$inject=["settings"];var bs=function(){if(vs)return gs;vs=1;var t=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt,l="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,u=l||c||Function("return this")(),d=Object.prototype.toString,h=Math.max,m=Math.min,p=function(){
162
+ return u.Date.now()};function f(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&d.call(e)==n}(e))return t;if(f(e)){var l="function"==typeof e.valueOf?e.valueOf():e;e=f(l)?l+"":l}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var c=i.test(e);return c||a.test(e)?s(e.slice(2),c?2:8):o.test(e)?t:+e}return gs=function(e,t,n){var r,o,i,a,s,l,c=0,u=!1,d=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var n=r,i=o;return r=o=void 0,c=t,a=e.apply(i,n)}function y(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=i}function _(){var e=p();if(y(e))return w(e);s=setTimeout(_,function(e){var n=t-(e-l);return d?m(n,i-(e-c)):n}(e))}function w(e){return s=void 0,v&&r?b(e):(r=o=void 0,a)}function x(){var e=p(),n=y(e);if(r=arguments,o=this,l=e,n){if(void 0===s)return function(e){return c=e,s=setTimeout(_,t),u?b(e):a}(l)
163
+ ;if(d)return s=setTimeout(_,t),b(l)}return void 0===s&&(s=setTimeout(_,t)),a}return t=g(t)||0,f(n)&&(u=!!n.leading,i=(d="maxWait"in n)?h(g(n.maxWait)||0,t):i,v="trailing"in n?!!n.trailing:v),x.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=o=s=void 0},x.flush=function(){return void 0===s?a:w(p())},x},gs}(),ys=t(bs);const _s={defaultHeight:200,marginAbove:800,marginBelow:800};function ws(e){const t=window.getComputedStyle(e);return e.getBoundingClientRect().height+(parseFloat(t.marginTop)+parseFloat(t.marginBottom))}function xs(e,t){const n=e.visible===t;return e.children.reduce(((e,n)=>e+xs(n,t)),n?1:0)}function ks(e){return xs(e,!1)}function Ns(e){return xs(e,!0)}function Ss(e){const t=e.filter((e=>!!e.annotation)).map((e=>e.annotation));if(t.length)return t;const n=[];if(e.forEach((e=>{e.children&&n.push(...e.children)})),n.length)return Ss(n);throw new Error("Thread contains no annotations")}function As(e,t,n){const r=di(e.user,t)
164
+ ;return(n||r)&&e.user_info?.display_name?e.user_info.display_name:ui(e.user)}function Es(e){return/^http(s?):/i.test(e)}function Ts(e){return{read:[e],update:[e],delete:[e]}}function Cs(e,t){return Object.assign(Ts(e),{read:["group:"+t]})}function Ms(e,t,n){return"private"===function(e){switch(e){case"private":case"shared":return e;default:return"shared"}}(n)&&e?Ts(e):Cs(e,t)}function Is(e){return e.read.some((e=>0===e.indexOf("group:")))}function zs(e){return!Is(e)}const Ls=(e=window.navigator.userAgent)=>e.indexOf("Mac OS")>=0,Os=(e=window.navigator,t="ontouchend"in document)=>["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(e.platform)||e.userAgent.includes("Mac")&&t;async function Rs(e,t=navigator){await t.clipboard.writeText(e)}function Ps({classes:e,direction:t="up"}){return et("up"===t?Wn:Gn,{className:Ze("absolute inline z-2 text-grey-3 fill-white",e)})}function Ds({label:e,icon:t,uri:n}){return et("li",{children:et(fo,{"aria-label":e,
165
+ classes:"text-grey-6 hover:text-color-text",href:n,title:e,target:"_blank",variant:"custom",underline:"none",children:et(t,{className:"w-em h-em"})})})}function Fs({shareURI:e}){const t=encodeURIComponent(e);return et("div",{className:"pt-2 border-t",children:et("ul",{className:"flex flex-row gap-x-4 items-center justify-center",children:[et(Ds,{icon:dr,label:"Tweet share link",uri:`https://twitter.com/intent/tweet?url=${t}&hashtags=annotated`}),et(Ds,{icon:cr,label:"Share on Facebook",uri:`https://www.facebook.com/sharer/sharer.php?u=${t}`}),et(Ds,{icon:Jt,label:"Share via email",uri:`mailto:?subject=${encodeURIComponent("Let's Annotate")}&body=${t}`})]})})}var Bs=Io((function({annotation:e,toastMessenger:t,shareUri:n}){const r=ps().getGroup(e.group),o=zs(e.permissions),i=Es(e.uri),a=de(null),s=de(null),[l,c]=se(!1),u=de(l);if(Me(s,(()=>c(!1)),{enabled:l}),ce((()=>{u.current!==l&&(u.current=l,l&&!Os()&&(a.current?.focus(),a.current?.select()))}),[l]),!r)return null;const d=i,h="private"===r.type?et("span",{
166
+ children:["Only members of the group ",et("em",{children:r.name})," may view this annotation."]}):et("span",{children:"Anyone using this link may view this annotation."}),m=o?et("span",{children:"Only you may view this annotation."}):h;return et("div",{className:"relative",ref:s,tabIndex:-1,children:[et(Nr,{icon:sr,title:"Share",onClick:()=>c(!l),expanded:l}),l&&et("div",{className:"absolute bottom-8 right-0 touch:bottom-touch-minimum",children:et(lt,{classes:Ze("w-96 max-w-[85vw]","space-y-2 p-2"),width:"custom",children:[et("h2",{className:"text-brand text-md font-medium",children:"Share this annotation"}),et("div",{className:Ze("flex w-full text-xs touch:text-base"),children:et(xr,{children:[et(Gr,{"aria-label":"Use this URL to share this annotation",type:"text",value:n,readOnly:!0,elementRef:a}),et(Nr,{icon:Ft,title:"Copy share link to clipboard",onClick:async()=>{try{await Rs(n),t.success("Copied share link to clipboard")}catch{t.error("Unable to copy link")}},variant:"dark"})]})}),et("div",{
167
+ className:"text-base font-normal","data-testid":"share-details",children:et(x,i?{children:m}:{children:"This annotation cannot be shared in its original context because it was made on a document that is not available on the web. This link shares the annotation by itself."})}),d&&et(Fs,{shareURI:n}),et(Ps,{direction:"down",classes:"bottom-[-8px] right-2 touch:right-[9px]"})]})})]})}),["toastMessenger"]);var Hs=Io((function({annotation:e,annotationsService:t,onReply:n,settings:r,toastMessenger:o}){const i=ps(),a=i.profile(),s=i.isLoggedIn(),l=t=>function(e,t,n){return-1!==e[t].indexOf(n||"")}(e.permissions,t,a.userid),c=l("delete"),u=l("update"),d=function(e){const t=Ao(e);return!1!==t?.allowFlagging}(r)&&!!a.userid&&a.userid!==e.user,h=function(e){const t=Ao(e);return!1!==t?.enableShareLinks}(r)&&function(e){return Es(e.uri)?e.links?.incontext??e.links?.html??null:e.links?.html??null}(e);return et("div",{className:"flex text-[16px]","data-testid":"annotation-action-bar",children:[u&&et(Nr,{icon:$t,
168
+ title:"Edit",onClick:()=>{i.createDraft(e,{tags:e.tags,text:e.text,isPrivate:zs(e.permissions)})}}),c&&et(Nr,{icon:vr,title:"Delete",onClick:async()=>{const n=Ei(e);if(await Fr({title:`Delete ${n.toLowerCase()}?`,message:`Are you sure you want to delete this ${n.toLowerCase()}?`,confirmAction:"Delete"}))try{await t.delete(e),o.success(`${n} deleted`,{visuallyHidden:!0})}catch(e){o.error(e.message)}}}),et(Nr,{icon:tr,title:"Reply",onClick:()=>{s?n():i.openSidebarPanel("loginPrompt")}}),h&&et(Bs,{annotation:e,shareUri:h}),d&&!e.flagged&&et(Nr,{icon:sn,title:"Report this annotation to moderators",onClick:()=>{t.flag(e).catch((()=>o.error("Flagging annotation failed")))}}),d&&e.flagged&&et(Nr,{pressed:!0,icon:cn,title:"Annotation has been reported to the moderators"})]})}),["annotationsService","settings","toastMessenger"]);function js({isCollapsed:e,setCollapsed:t,linkStyle:n}){return et("div",{className:Ze("absolute block right-0 bottom-0","w-20 bg-gradient-to-l from-white"),children:et("div",{
169
+ className:"flex justify-end",children:et(vo,{variant:"text",onClick:()=>t(!e),expanded:!e,title:"Toggle visibility of full excerpt text",style:n,underline:"always",inline:!0,children:e?"More":"Less"})})})}const $s=()=>{};var qs=Io((function({children:e,collapse:t=!1,collapsedHeight:n,inlineControls:r=!0,onCollapsibleChanged:o=$s,onToggleCollapsed:i=$s,overflowThreshold:a=0,settings:s={}}){const[l,c]=se(!0),u=de(null),[d,h]=se(0),m=me((()=>{const e=u.current.clientHeight;h(e);o(e>n+a)}),[n,o,a]);ue((()=>{const e=function(e,t){const n=new ResizeObserver((()=>t(e.clientWidth,e.clientHeight)));return n.observe(e),()=>n.disconnect()}(u.current,m);return m(),e}),[m]);const p=d>n+a,f=p&&(r?l:t),g={};0!==d&&(g["max-height"]=f?n:d);const v=e=>r?c(e):i(e);return et("div",{"data-testid":"excerpt-container",className:Ze("relative overflow-hidden","transition-[max-height] ease-in duration-150"),style:g,children:[et("div",{className:Ze("inline-block w-full"),"data-testid":"excerpt-content",ref:u,children:e}),et("div",{
170
+ "data-testid":"excerpt-expand",role:"presentation",onClick:()=>v(!1),className:Ze("transition-[opacity] duration-150 ease-linear","absolute w-full bottom-0 h-touch-minimum",{"bg-gradient-to-b from-excerpt-stop-1 via-excerpt-stop-2 to-excerpt-stop-3":!r&&f,"bg-none":r,"opacity-0 pointer-events-none":!f}),title:"Show the full excerpt"}),p&&r&&et(js,{isCollapsed:l,setCollapsed:v,linkStyle:Co(["selectionFontFamily"],s)})]})}),["settings"]);const Us=String.raw`[\s,.;:|?!'"\-()[\]{}]`,Gs=new RegExp(`(^|${Us})@([A-Za-z0-9_][A-Za-z0-9._]+[A-Za-z0-9_])(?=${Us}|$)`,"g");const Vs=/<a[^>]\bdata-hyp-mention\b[^>]*>([^<]+)<\/a>/g;function Ws(e,t){const n=e.textContent??"",r=t??n;if(e.hasAttribute("data-hyp-mention-type"))return[e,r];const o=t&&t.link?"link":t?"no-link":"invalid",i=document.createElement("link"===o?"a":"span");return i.setAttribute("data-hyp-mention",""),i.setAttribute("data-hyp-mention-type",o),i.textContent=n,"link"===o&&(i.setAttribute("href",t?.link??""),i.setAttribute("target","_blank")),
171
+ "invalid"!==o&&i.setAttribute("data-userid",e.dataset.userid??""),e.replaceWith(i),[i,r]}function Ks(e,t){const n=[...e.slice(0,t).matchAll(new RegExp(Us,"g"))],r=n.length>0?Math.max(...n.map((e=>e.index))):-1,o=e.slice(t).search(new RegExp(Us));return{start:r+1,end:-1===o?e.length:t+o}}function Ys(e,t=16/9){const n=document.createElement("iframe");return n.src=e,n.setAttribute("frameborder","0"),n.setAttribute("allowfullscreen",""),function(e,t){e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%";const n=document.createElement("div");return n.style.paddingBottom=1/t*100+"%",n.style.position="relative",n.appendChild(e),n}(n,t)}function Xs(e){const t=/(\d+)([hms]?)/g,n={h:3600,m:60,s:1};let r,o=0;for(;null!==(r=t.exec(e));)if(r[2]){const e=r[2];o+=Number(r[1])*n[e]}else o+=+r[1];return o.toString()}function Zs(e,t){const n=function(e){const t=["end","start","t"],n=new URLSearchParams(e.search),r=new URLSearchParams
172
+ ;for(const[e,o]of n)t.includes(e)&&("t"===e?r.append("start",Xs(o)):r.append(e,o));r.sort();let o=r.toString();return o&&(o=`?${o}`),o}(t);return Ys(`https://www.youtube.com/embed/${e}${n}`)}function Js(e,t,n,{aspectRatio:r}={}){return o=>{if(o.hostname!==e)return null;const i=t.exec(o.pathname);if(!i)return null;const a=i[1];return Ys(n(a),r)}}const Qs=[function(e){if("www.youtube.com"!==e.hostname)return null;if(!/\/watch\/?/.test(e.pathname))return null;const t=/[&?]v=([^&#]+)/.exec(e.search);return t?Zs(t[1],e):null},function(e){if("youtu.be"!==e.hostname)return null;const t=/^\/([^/]+)\/?$/.exec(e.pathname);return t?Zs(t[1],e):null},Js("vimeo.com",/^\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),Js("vimeo.com",/^\/channels\/[^/]+\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),function(e){if("archive.org"!==e.hostname)return null;const t=/^\/(embed|details)\/(.+)/.exec(e.pathname);if(!t)return null;let n=t[2];const r=new URLSearchParams(e.search)
173
+ ;let o=r.get("start"),i=r.get("end");if(!o){const e=n.match(/\/start\/([^/]+)/);e&&(o=e[1],n=n.replace(e[0],""))}if(!i){const e=n.match(/\/end\/([^/]+)/);e&&(i=e[1],n=n.replace(e[0],""))}const a=new URL(`https://archive.org/embed/${n}`);return o&&a.searchParams.append("start",o),i&&a.searchParams.append("end",i),Ys(a.href)},function(e){return e.pathname.endsWith(".mp3")||e.pathname.endsWith(".ogg")||e.pathname.endsWith(".wav")?function(e){const t=document.createElement("audio");return t.controls=!0,t.src=e,t}(e.href):null}];function el(e){if(e.href!==e.textContent)try{const t=encodeURI(e.textContent);if(e.href!==t)return null}catch{return null}const t=function(e){let t,n;for(n=0;n<Qs.length;n++)if(t=Qs[n](e),t)return t;return null}(e);return t&&e.parentElement.replaceChild(t,e),t}const{entries:tl,setPrototypeOf:nl,isFrozen:rl,getPrototypeOf:ol,getOwnPropertyDescriptor:il}=Object;let{freeze:al,seal:sl,create:ll}=Object,{apply:cl,construct:ul}="undefined"!=typeof Reflect&&Reflect;al||(al=function(e){return e}),
174
+ sl||(sl=function(e){return e}),cl||(cl=function(e,t,n){return e.apply(t,n)}),ul||(ul=function(e,t){return new e(...t)});const dl=Al(Array.prototype.forEach),hl=Al(Array.prototype.lastIndexOf),ml=Al(Array.prototype.pop),pl=Al(Array.prototype.push),fl=Al(Array.prototype.splice),gl=Al(String.prototype.toLowerCase),vl=Al(String.prototype.toString),bl=Al(String.prototype.match),yl=Al(String.prototype.replace),_l=Al(String.prototype.indexOf),wl=Al(String.prototype.trim),xl=Al(Object.prototype.hasOwnProperty),kl=Al(RegExp.prototype.test),Nl=(Sl=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ul(Sl,t)});var Sl;function Al(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return cl(e,t,r)}}function El(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:gl;nl&&nl(e,null);let r=t.length;for(;r--;){let o=t[r];if("string"==typeof o){const e=n(o);e!==o&&(rl(t)||(t[r]=e),o=e)}e[o]=!0}return e}
175
+ function Tl(e){for(let t=0;t<e.length;t++){xl(e,t)||(e[t]=null)}return e}function Cl(e){const t=ll(null);for(const[n,r]of tl(e)){xl(e,n)&&(Array.isArray(r)?t[n]=Tl(r):r&&"object"==typeof r&&r.constructor===Object?t[n]=Cl(r):t[n]=r)}return t}function Ml(e,t){for(;null!==e;){const n=il(e,t);if(n){if(n.get)return Al(n.get);if("function"==typeof n.value)return Al(n.value)}e=ol(e)}return function(){return null}}
176
176
  const Il=al(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),zl=al(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ll=al(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ol=al(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Rl=al(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Pl=al(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Dl=al(["#text"]),Fl=al(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Bl=al(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Hl=al(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),jl=al(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$l=sl(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ql=sl(/<%[\w\W]*|[\w\W]*%>/gm),Ul=sl(/\$\{[\w\W]*/gm),Gl=sl(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vl=sl(/^aria-[\-\w]+$/),Wl=sl(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Kl=sl(/^(?:\w+script|data):/i),Yl=sl(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xl=sl(/^html$/i),Zl=sl(/^[a-z][.\w]*(-[.\w]+)+$/i)
177
177
  ;var Jl=Object.freeze({__proto__:null,ARIA_ATTR:Vl,ATTR_WHITESPACE:Yl,CUSTOM_ELEMENT:Zl,DATA_ATTR:Gl,DOCTYPE_NAME:Xl,ERB_EXPR:ql,IS_ALLOWED_URI:Wl,IS_SCRIPT_OR_DATA:Kl,MUSTACHE_EXPR:$l,TMPLIT_EXPR:Ul});const Ql=1,ec=3,tc=7,nc=8,rc=9,oc=function(){return"undefined"==typeof window?null:window};var ic,ac,sc=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:oc();const n=t=>e(t);if(n.version="3.2.4",n.removed=[],!t||!t.document||t.document.nodeType!==rc||!t.Element)return n.isSupported=!1,n;let{document:r}=t;const o=r,i=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:l,Element:c,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:h,DOMParser:m,trustedTypes:p}=t,f=c.prototype,g=Ml(f,"cloneNode"),v=Ml(f,"remove"),b=Ml(f,"nextSibling"),y=Ml(f,"childNodes"),_=Ml(f,"parentNode");if("function"==typeof s){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let w,x=""
178
178
  ;const{implementation:k,createNodeIterator:N,createDocumentFragment:S,getElementsByTagName:A}=r,{importNode:E}=o;let T={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof tl&&"function"==typeof _&&k&&void 0!==k.createHTMLDocument;const{MUSTACHE_EXPR:C,ERB_EXPR:M,TMPLIT_EXPR:I,DATA_ATTR:z,ARIA_ATTR:L,IS_SCRIPT_OR_DATA:O,ATTR_WHITESPACE:R,CUSTOM_ELEMENT:P}=Jl;let{IS_ALLOWED_URI:D}=Jl,F=null;const B=El({},[...Il,...zl,...Ll,...Rl,...Dl]);let H=null;const j=El({},[...Fl,...Bl,...Hl,...jl]);let $=Object.seal(ll(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}
@@ -539,7 +539,7 @@ className:Ze("px-1.5 py-1 touch:p-2","border-l rounded rounded-l-none","text-gre
539
539
  const[n,r]=se(!0),[o,i]=se(!1),a=ps(),s=a.defaultAuthority(),l=a.getDraft(e),c=a.isFeatureEnabled("at_mentions"),u=l?.tags??e.tags,d=l?.text??e.text,h=d.length>0,m=u.length>0,p=Co(["annotationFontFamily"],t),f=he((()=>e&&!di(e?.user,s)),[e,s]),g=e=>a.getLink("search.tag",{tag:e});return et("div",{className:"space-y-4",children:[h&&et(qs,{collapse:n,collapsedHeight:400,inlineControls:!1,onCollapsibleChanged:i,onToggleCollapsed:r,overflowThreshold:20,children:et(_p,{markdown:d,classes:Ze({"p-redacted-text":xi(e)}),style:p,mentions:e.mentions,mentionsEnabled:c})}),(o||m)&&et("div",{className:"flex flex-row gap-x-2",children:[et("div",{className:"grow",children:m&&et(wp,{children:u.map((e=>et(xp,{tag:e,href:f?g(e):void 0},e)))})}),o&&et("div",{children:et(kp,{classes:Ze("-mt-3"),collapsed:n,setCollapsed:r})})]})]})}),["settings"]);let Sp,Ap=function(e){return e.ANCHOR_LINK="ANCHOR_LINK",e.IMAGE_LINK="IMAGE_LINK",e}({});function Ep(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd;return o>=t+n?(o+=r.length-n,
540
540
  i+=r.length-n):i<=t||(o<=t&&i>=t+n?i+=r.length-n:o<t&&i<t+n?o=t:o<t+n&&i>t+n?i+=r.length-n:t<o&&t+n>i&&(o=t,i=t+n)),{text:e.text.slice(0,t)+r+e.text.slice(t+n),selectionStart:o,selectionEnd:i}}function Tp(e,t=Ap.ANCHOR_LINK){const n=e.text.slice(e.selectionStart,e.selectionEnd);let r,o="";if(t===Ap.IMAGE_LINK&&(o="!"),n.match(/[a-z]+:\/\/.*/)){const t="Description";return r=Ep(e,e.selectionStart,n.length,o+"["+t+"]("+n+")"),r.selectionStart=e.selectionStart+o.length+1,r.selectionEnd=r.selectionStart+t.length,r}{const t=o+"["+n+"](",i="http://insert-your-link-here.com";return r=Ep(e,e.selectionStart,n.length,t+i+")"),r.selectionStart=e.selectionStart+t.length,r.selectionEnd=r.selectionStart+i.length,r}}function Cp(e,t,n,r){void 0===n&&(n=t);const o=e.text.slice(e.selectionStart-t.length,e.selectionStart),i=e.text.slice(e.selectionEnd,e.selectionEnd+t.length);let a=e;return e.selectionStart===e.selectionEnd&&r&&(a=Ep(e,e.selectionStart,0,r),a.selectionStart=a.selectionEnd-r.length),
541
541
  o===t&&i===n?(a=Ep(a,a.selectionStart-t.length,t.length,""),a=Ep(a,a.selectionEnd,n.length,"")):(a=Ep(a,a.selectionStart,0,t),a=Ep(a,a.selectionEnd,0,n)),a}function Mp(e,t){const n=e.indexOf("\n",t);return n<0?e.length:n}function Ip(e,t,n,r){let o=function(e,t){const n=e.lastIndexOf("\n",t);return n<0?0:n+1}(e.text,t),i=Mp(e.text,t),a=0;for(;i<=Mp(e.text,n);){const t=i===e.text.length,s=i-o,l=Mp((e=r(e,o,i,a)).text,o)-o;if(n+=l-s,t)break;o=o+l+1,i=Mp(e.text,o),a+=1}return e}function zp(e,t){const n=e.selectionStart,r=e.selectionEnd,o=e=>"function"==typeof t?t(e):t;let i=!0;return Ip(e,n,r,((e,t,n,r)=>{const a=o(r);return e.text.slice(t,t+a.length)!==a&&(i=!1),e})),Ip(e,n,r,i?(e,t,n,r)=>Ep(e,t,o(r).length,""):(e,t,n,r)=>{const i=o(r);return e.text.slice(t,t+i.length)===i?e:Ep(e,t,0,i)})}const Lp=!1;function Op({loadingUsers:e,users:t,onSelectUser:n,highlightedSuggestion:r,usersListboxId:o,...i}){return et(Jr,{...i,classes:"p-1",children:et("ul",{className:"flex-col gap-y-0.5",role:"listbox",
542
- "aria-orientation":"vertical",id:o,children:e?et("li",{className:"italic p-2","data-testid":"suggestions-loading-indicator",children:"Loading suggestions…"}):et(x,{children:[t.map(((e,t)=>et("li",{id:`${o}-${e.username}`,className:Ze("flex justify-between items-center gap-x-2","rounded p-2 hover:bg-grey-2",{"bg-grey-2":r===t}),onClick:t=>{t.stopPropagation(),n(e)},role:"option","aria-selected":r===t,children:[et("span",{className:"truncate",children:e.username}),et("span",{className:"text-color-text-light",children:e.displayName})]},e.username))),0===t.length&&et("li",{className:"italic p-2","data-testid":"suggestions-fallback",children:"No matches. You can still write the username"})]})})})}const Rp={bold:"b",image:"g",italic:"i",link:"l",list:"u",math:"m",numlist:"o",quote:"q"};function Pp({disabled:e=!1,icon:t,label:n,onClick:r,shortcutKey:o,title:i=""}){const a=he((()=>Ls()?"Cmd":"Ctrl"),[]);let s=i;o&&(s+=` (${a}-${o.toUpperCase()})`);const l={disabled:e,onClick:r,title:s};return n?et(yr,{
542
+ "aria-orientation":"vertical",id:o,children:e?et("li",{className:"italic p-2","data-testid":"suggestions-loading-indicator",children:"Loading suggestions…"}):et(x,{children:[t.map(((e,t)=>et("li",{id:`${o}-${e.username}`,className:Ze("flex justify-between items-center gap-x-2","rounded p-2 leading-4 hover:bg-grey-2",{"bg-grey-2":r===t}),onClick:t=>{t.stopPropagation(),n(e)},role:"option","aria-selected":r===t,children:[et("span",{className:"truncate",children:e.username}),et("span",{className:"text-color-text-light",children:e.displayName})]},e.username))),0===t.length&&et("li",{className:"italic p-2","data-testid":"suggestions-fallback",children:"No matches. You can still write the username"})]})})})}const Rp={bold:"b",image:"g",italic:"i",link:"l",list:"u",math:"m",numlist:"o",quote:"q"};function Pp({disabled:e=!1,icon:t,label:n,onClick:r,shortcutKey:o,title:i=""}){const a=he((()=>Ls()?"Cmd":"Ctrl"),[]);let s=i;o&&(s+=` (${a}-${o.toUpperCase()})`);const l={disabled:e,onClick:r,title:s};return n?et(yr,{
543
543
  classes:"p-1.5 text-grey-7 hover:text-grey-9",...l,size:"custom",variant:"custom",children:n}):et(Nr,{classes:"px-2 py-2.5",...l,children:t&&et(t,{className:"w-[10px] h-[10px] touch:w-[13px] touch:h-[13px]"})})}function Dp({classes:e,containerRef:t,mentionsEnabled:n,usersForMentions:r,onEditText:o,onKeyDown:i,...a}){const[s,l]=se(!1),[c,u]=se(),d=Le(t),[h,m]=se(0),p=de(null),f=he((()=>n?function(e,t,n){return void 0===e||"loading"===t.status?[]:t.users.filter((t=>!e||`${t.username} ${t.displayName??""}`.toLowerCase().match(e.toLowerCase()))).slice(0,10)}(c,r):[]),[c,n,r]),g=me((e=>{if(!n)return;const{x:t,y:r}=function(e){Sp||(Sp=document.createElement("div"),document.body.append(Sp));try{const t=e.getBoundingClientRect(),n=window.getComputedStyle(e);Sp.style.font=n.font,Sp.style.padding=n.padding,Sp.style.whiteSpace="pre-wrap",Sp.style.wordWrap="break-word",Sp.style.position="fixed",Lp||(Sp.style.visibility="hidden"),Sp.style.width=`${t.width}px`,Sp.style.height=`${t.height}px`,Sp.style.top=`${t.top}px`,
544
544
  Sp.style.left=`${t.left}px`;const r=e.selectionStart,o=document.createElement("span");o.style.display="inline-block",o.style.verticalAlign="bottom";const i=e.value.substring(0,r),a=e.value.slice(r),s="\nx";Sp.innerHTML="",Sp.append(i,o,a,s),Sp.style.overflowY="auto",Sp.scrollTop=e.scrollTop;const l=o.getBoundingClientRect();return{x:l.left-t.left,y:l.top-t.top}}finally{Sp.remove(),Sp=void 0}}(e);p.current&&(p.current.style.transform=`translate(${t}px, ${r}px)`);const o=function(e,t){const{start:n}=Ks(e,t);return e.slice(n,t)}(e.value,e.selectionStart),i=o.startsWith("@");l(i),u(i?o.substring(1):void 0),i||m(0)}),[n]),v=me((e=>{const t=d.current,{value:n}=t,{start:r,end:i}=Ks(n,t.selectionStart),a=`${n.slice(0,r)}@${e.username} `,s=n.slice(i);t.value=`${a}${s}`,t.selectionStart=a.length,t.selectionEnd=a.length,t.focus(),o(t.value),l(!1),m(0)}),[o,d]),b=fe(),y=he((()=>{if(!s)return{};const e=f[h],t=e?`${b}-${e.username}`:void 0;return{role:"combobox","aria-controls":b,"aria-expanded":!0,
545
545
  "aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":t}}),[h,s,f,b]);return et("div",{className:"relative",children:[et("textarea",{className:Ze("border rounded p-2","text-color-text-light bg-grey-0","focus:bg-white focus:outline-none focus:shadow-focus-inner",e),onInput:e=>o(e.target.value),...a,onKeyUp:e=>{["Escape","Enter"].includes(e.key)||g(e.target)},onKeyDown:e=>{i?.(e),s&&0!==f.length&&("ArrowDown"===e.key?(e.preventDefault(),m((e=>Math.min(e+1,f.length-1)))):"ArrowUp"===e.key?(e.preventDefault(),m((e=>Math.max(e-1,0)))):"Enter"===e.key&&(e.preventDefault(),v(f[h])))},onClick:e=>{e.stopPropagation(),g(e.target)},ref:d,...y}),et("div",{ref:p,className:"absolute top-0 left-0 w-0 h-0 pointer-events-none"}),n&&et(Op,{open:s,onClose:()=>l(!1),anchorElementRef:p,loadingUsers:"loading"===r.status,users:f,highlightedSuggestion:h,onSelectUser:v,usersListboxId:b})]})}function Fp({isPreviewing:e,onCommand:t,onTogglePreview:n,showHelpLink:r}){const o=de(null);return Ae(o),et("div",{
@@ -556,8 +556,8 @@ i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDe
556
556
  isExpanded:a,onToggleSubmenu:u})]}),S=Ze("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?et("a",{ref:m,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:N}):et("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}),et(x,{children:[f,g&&et(So,{direction:a?"in":"out",children:et(Vp,{closeMenu:e=>{u&&u(e),p=setTimeout((()=>{m.current.focus()}))},
557
557
  visible:a,className:"border-y border-grey-3",children:d})})]})}var Jp=Io((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=Co(["ctaTextColor","ctaBackgroundColor"],a),l=et("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:et(Bn,{className:"w-4 h-4"})});return et("div",{className:"flex flex-row gap-x-3",children:[et("div",{className:"flex relative",children:[et(yr,{classes:Ze("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]}),et("div",{className:Ze("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:et(Yp,{containerPositioned:!1,contentClass:Ze("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[et(Zp,{icon:"open"===e.type?dn:fn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),et(Zp,{icon:Ln,label:"Only Me",isSelected:n,onClick:()=>i(!0)
558
558
  })]})})]}),et("div",{children:et(yr,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[et(_t,{}),"Cancel"]})})]})}),["settings"]);var Qp=Io((function({annotation:e,draft:t,annotationsService:n,groups:r,settings:o,tags:i,toastMessenger:a}){const[s,l]=se(null),c=ps(),u=c.getGroup(e.group),d=he((()=>gi(e)),[e]),h=!t.isPrivate&&u&&"private"!==u.type,m=Ao(o)?.enableHelpPanel??!0,p=t.tags,f=t.text,g=!f&&!p.length,v=me((e=>{c.createDraft(t.annotation,{...t,tags:e})}),[t,c]),b=me((e=>{if(!e||p.indexOf(e)>=0)return!1;const t=[...p,e];return i.store(t),v(t),!0}),[v,p,i]),y=me((e=>{const t=[...p],n=t.indexOf(e);return n>=0&&(t.splice(n,1),v(t),!0)}),[v,p]),_=me((e=>{c.createDraft(t.annotation,{...t,text:e})}),[t,c]),w=me((n=>{c.createDraft(e,{...t,isPrivate:n}),d||c.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,d,c]),x=async()=>{s&&b(s);const t=`${Ei(e)} ${vi(e)?"updated":"saved"}`;try{await n.save(e),a.success(t,{visuallyHidden:!0})}catch{a.error("Saving annotation failed")}},k=me((()=>{
559
- c.removeDraft(e),vi(e)||c.removeAnnotations([e])}),[e,c]),N=Co(["annotationFontFamily"],o),S=c.isFeatureEnabled("at_mentions"),A=c.usersWhoAnnotated(),E=c.getFocusedGroupMembers(),T=he((()=>function(e,t){if(!Array.isArray(t))return{status:"loading"};const n=t.map((({username:e,display_name:t})=>({username:e,displayName:t}))),r=new Set,o=[...e,...n].filter((({username:e})=>{const t=r.has(e);return r.add(e),!t})).sort(((e,t)=>e.username.localeCompare(t.username)));return{status:"loaded",users:o}}(A,E)),[E,A]);return ce((()=>{S&&null===E&&r.loadFocusedGroupMembers()}),[E,r,S]),et("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;g||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),x())},children:[et(Bp,{textStyle:N,label:d?"Enter reply":"Enter comment",text:f,onEditText:_,mentionsEnabled:S,usersForMentions:T,showHelpLink:m,mentions:e.mentions}),et(qp,{onAddTag:b,onRemoveTag:y,onTagInput:l,tagList:p}),u&&et(Jp,{group:u,isDisabled:g,
560
- isPrivate:t.isPrivate,onCancel:k,onSave:x,onSetPrivate:w}),h&&et(Up,{})]})}),["annotationsService","groups","settings","tags","toastMessenger"]);function ef({domain:e,link:t,title:n}){return et("div",{className:"flex gap-x-1",children:[et("div",{className:"text-color-text-light",children:['on "',t?et(fo,{href:t,target:"_blank",underline:"none",children:n}):et("span",{children:n}),'"']}),e&&et("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function tf({group:e}){const t=e?.links.html;return et(x,{children:e&&t&&et(fo,{classes:Ze("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:et("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?et(dn,{className:"w-2.5 h-2.5"}):et(fn,{className:"w-2.5 h-2.5"}),et("span",{children:e.name})]})})})}function nf({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){
559
+ c.removeDraft(e),vi(e)||c.removeAnnotations([e])}),[e,c]),N=Co(["annotationFontFamily"],o),S=c.isFeatureEnabled("at_mentions"),A=c.usersWhoAnnotated(),E=c.getFocusedGroupMembers(),T=he((()=>function(e,t){if("loaded"!==t.status)return{status:"loading"};const n=t.members.map((({username:e,display_name:t})=>({username:e,displayName:t}))),r=new Set,o=[...e,...n].filter((({username:e})=>{const t=r.has(e);return r.add(e),!t})).sort(((e,t)=>e.username.localeCompare(t.username)));return{status:"loaded",users:o}}(A,E)),[E,A]);return ce((()=>{S&&"not-loaded"===E.status&&r.loadFocusedGroupMembers()}),[E,r,S]),et("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;g||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),x())},children:[et(Bp,{textStyle:N,label:d?"Enter reply":"Enter comment",text:f,onEditText:_,mentionsEnabled:S,usersForMentions:T,showHelpLink:m,mentions:e.mentions}),et(qp,{onAddTag:b,onRemoveTag:y,onTagInput:l,tagList:p}),u&&et(Jp,{group:u,
560
+ isDisabled:g,isPrivate:t.isPrivate,onCancel:k,onSave:x,onSetPrivate:w}),h&&et(Up,{})]})}),["annotationsService","groups","settings","tags","toastMessenger"]);function ef({domain:e,link:t,title:n}){return et("div",{className:"flex gap-x-1",children:[et("div",{className:"text-color-text-light",children:['on "',t?et(fo,{href:t,target:"_blank",underline:"none",children:n}):et("span",{children:n}),'"']}),e&&et("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function tf({group:e}){const t=e?.links.html;return et(x,{children:e&&t&&et(fo,{classes:Ze("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:et("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?et(dn,{className:"w-2.5 h-2.5"}):et(fn,{className:"w-2.5 h-2.5"}),et("span",{children:e.name})]})})})}function nf({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){
561
561
  const[o,i]=se((()=>new Date)),a=he((()=>new Date(e)),[e]),s=he((()=>r&&new Date(t)),[t,r]),l=he((()=>({absolute:Ve(a,{includeWeekday:!0}),relative:Ge(a,o)})),[a,o]),c=he((()=>s?{absolute:Ve(s,{includeWeekday:!0}),relative:Ge(s,o)}:{}),[s,o]);ce((()=>Ue(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return et("div",{children:[r&&et("span",{className:"text-color-text-light text-xs italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?et(fo,{classes:"text-color-text-light hover:text-color-text-light",target:"_blank",title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative}):et("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function rf({authorLink:e,displayName:t}){const n=et("h3",{className:"text-color-text font-bold",children:t});return e?et(fo,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):et("div",{
562
562
  children:n})}var of=Io((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){const i=ps(),a=i.defaultAuthority(),s=i.isFeatureEnabled("client_display_names"),l=i.getLink("user",{user:e.user}),c=he((()=>As(e,a,s)),[e,a,s]),u=he((()=>function(e,t,n,r){return!di(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${ui(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=gi(e)&&r,h=e.links?.html||"",m=he((()=>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}(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 et("header",{children:[et("div",{className:"flex gap-x-1 items-center flex-wrap-reverse",children:[zs(e.permissions)&&!t&&et(Ln,{className:"w-[12px] h-[12px]",
563
563
  title:"This annotation is visible only to you"}),et(rf,{authorLink:u,displayName:c}),n>0&&d&&et(vo,{variant:"text-light",onClick:()=>i.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&et("div",{className:"flex justify-end grow",children:et(nf,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,withEditedTimestamp:m})})]}),!gi(e)&&et("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[v&&et(tf,{group:v}),!t&&ki(e)&&et(wn,{title:"This is a highlight. Click 'edit' to add a note or tag.",className:"w-[10px] h-[10px] text-color-text-light"}),(g||b)&&et("span",{className:"flex",children:[g&&et(ef,{domain:p.domain,link:f,title:p.titleText}),b&&et("span",{className:"text-grey-6","data-testid":"page-number",children:[g&&", ","p. ",b]})]})]})]})}),["settings"]);var af=Io((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return et(qs,{collapsedHeight:35,
@@ -580,7 +580,7 @@ const Bf=/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5
580
580
  return t}function Jf(e){return Ni(e)?"orphan":Si(e)?"note":"annotation"}function Qf(e){return Ss([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function eg(e){return Ss([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}const tg={Newest:(e,t)=>{const n=Qf(e),r=Qf(t);return n>r?-1:n<r?1:0},Oldest:(e,t)=>{const n=eg(e),r=eg(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=Lf(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 ng=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,
581
581
  selected:t.selected,sortCompareFn:tg[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=Xf(e,Vf);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,
582
582
  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=>Gf([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&Gf([e.annotation],o).length>0)}const r=Mf(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=Jf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function rg(){const e=ps(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=he((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return ng(s)}
583
- var og,ig,ag=Io((function({loadAnnotationsService:e,onLogin:t}){const n=ps(),r=n.routeParams().id??"",{rootThread:o}=rg(),i=n.profile().userid,[a,s]=se(!1);return ce((()=>{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]),et(x,{children:[a&&et(fs,{errorType:"annotation",onLoginRequest:t}),et(_f,{threads:o.children})]})}),["loadAnnotationsService"]);class sg{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.1580.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])}
583
+ var og,ig,ag=Io((function({loadAnnotationsService:e,onLogin:t}){const n=ps(),r=n.routeParams().id??"",{rootThread:o}=rg(),i=n.profile().userid,[a,s]=se(!1);return ce((()=>{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]),et(x,{children:[a&&et(fs,{errorType:"annotation",onLoginRequest:t}),et(_f,{threads:o.children})]})}),["loadAnnotationsService"]);class sg{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.1582.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])}
584
584
  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 lg=function(){if(ig)return og;ig=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,
585
585
  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){
586
586
  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 og=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){
@@ -667,7 +667,7 @@ buildTextExportContent(e,{groupName:t="",displayNamesEnabled:n=!1,defaultAuthori
667
667
  }),et("body",{children:[et("section",{children:[et("h1",{children:"Summary"}),et("p",{children:et("time",{dateTime:o.toISOString(),children:Zb(o)})}),et("p",{children:et("strong",{children:a})}),et("p",{children:et("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),et("table",{children:et("tbody",{style:{verticalAlign:"top"},children:[et("tr",{children:[et("td",{children:"Group:"}),et("td",{children:t})]}),et("tr",{children:[et("td",{children:"Total users:"}),et("td",{children:s.length})]}),et("tr",{children:[et("td",{children:"Users:"}),et("td",{children:s.join(", ")})]}),et("tr",{children:[et("td",{children:"Total annotations:"}),et("td",{children:e.length})]}),et("tr",{children:[et("td",{children:"Total replies:"}),et("td",{children:l.length})]})]})})]}),et("hr",{}),et("section",{children:[et("h1",{children:"Annotations"}),e.map(((e,t)=>{const n=Ii(e),r=Ci(e),o=vp(e.text),i=o===`<p>${e.text}</p>`?e.text:o;return et("article",{children:[et("h2",{children:["Annotation ",t+1,":"]
668
668
  }),et("table",{children:et("tbody",{style:{verticalAlign:"top"},children:[et("tr",{children:[et("td",{children:"Created at:"}),et("td",{children:et("time",{dateTime:e.created,children:Zb(new Date(e.created))})})]}),et("tr",{children:[et("td",{children:"Author:"}),et("td",{children:c(e)})]}),n&&et("tr",{children:[et("td",{children:"Page:"}),et("td",{children:n})]}),et("tr",{children:[et("td",{children:"Type:"}),et("td",{children:Ei(e)})]}),r&&et("tr",{children:[et("td",{children:"Quote:"}),et("td",{children:et("blockquote",{style:{margin:0},children:r})})]}),et("tr",{children:[et("td",{children:"Comment:"}),et("td",{dangerouslySetInnerHTML:{__html:i}})]}),e.tags.length>0&&et("tr",{children:[et("td",{children:"Tags:"}),et("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=>As(e,n,t),{uri:i,title:a}=hi(r);return{uri:i,title:a,
669
669
  uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>gi(e))),extractUsername:o}}}Jb.$inject=[];class Qb 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 ey(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Qb(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch{throw new Qb(e,n,"Failed to parse response")}if(!n.ok)throw new Qb(e,n,r?.reason);return r}class ty{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,l)=>{o();try{const[o,i]=await Promise.all([e,n()]),c=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(!c)throw new Error(`Missing API route: ${t}`);const u={
670
- "Content-Type":"application/json","Hypothesis-Client-Version":"1.1580.0"};i&&(u.Authorization="Bearer "+i);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:m}=Ha(c.url,a),p=new URL(h);for(const[e,t]of Object.entries(m)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&p.searchParams.append(e,t.toString())}return await ey(p.toString(),{body:s?JSON.stringify(Xb(s)):null,headers:u,method:c.method,signal:l})}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")},members:{read:i("group.members.read")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},
670
+ "Content-Type":"application/json","Hypothesis-Client-Version":"1.1582.0"};i&&(u.Authorization="Bearer "+i);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:m}=Ha(c.url,a),p=new URL(h);for(const[e,t]of Object.entries(m)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&p.searchParams.append(e,t.toString())}return await ey(p.toString(),{body:s?JSON.stringify(Xb(s)):null,headers:u,method:c.method,signal:l})}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")},members:{read:i("group.members.read")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},
671
671
  read:i("profile.read"),update:i("profile.update")},this.analytics={events:{create:i("analytics.events.create")}}}setClientId(e){this._clientId=e}}ty.$inject=["apiRoutes","auth","store"];var ny,ry,oy,iy,ay,sy={};function ly(){return oy||(oy=1,e=sy,t=function(){if(ry)return ny;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 ry=1,ny=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){
672
672
  if(this._timeout&&clearTimeout(this._timeout),!e)return!1;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)},
673
673
  e.prototype.try=function(e){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},ny}(),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))
@@ -779,8 +779,8 @@ this._store.highlightAnnotations(e.map((({id:e})=>e)).filter(Boolean)),this._win
779
779
  this._groups.load();else if("whoyouare"===t.type){const e=this._store.profile().userid;t.userid!==e&&console.warn('WebSocket user ID "%s" does not match logged-in ID "%s"',t.userid,e)}else Hv("Received unsupported notification",t.type)}_sendClientConfig(e){Object.keys(this._configMessages).forEach((t=>{this._configMessages[t]&&e.send(this._configMessages[t])}))}setConfig(e,t){this._configMessages[e]=t,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 jN(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)
780
780
  }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,this._reconnectSetUp||(this._reconnectSetUp=!0,Ty(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}$N.$inject=["store","apiRoutes","auth","groups","session","$window"];const qN="hypothesis.user.tags.list",UN="hypothesis.user.tags.map";class GN{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(qN)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${qv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){
781
781
  const t=this._storage.getObject(UN)||{};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(UN,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(qN,n)}}GN.$inject=["localStorage"];class VN{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}VN.$inject=["store"];class WN extends wg.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}={}){
782
- 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:zv(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)}}WN.$inject=["store","$window"];const KN=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),YN=function(e){const{version:t,origin:n}=Ov(e.location.href);return"1.1580.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1580.0) than the host page (${t}). It may not work.`),
783
- !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 XN(e,t){e.setClientId(t.clientId)}function ZN(e){e.sync()}function JN(e,t){e.load(),t.load()}function QN(e,t,n){e.init(),t.init(),n.init()}function eS(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}KN.sentry&&YN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;EN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1580.0",beforeSend:(e,t)=>{if(TN>=5)return Hv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++TN;try{const n=t&&t.originalException
782
+ 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:zv(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)}}WN.$inject=["store","$window"];const KN=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),YN=function(e){const{version:t,origin:n}=Ov(e.location.href);return"1.1582.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1582.0) than the host page (${t}). It may not work.`),
783
+ !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 XN(e,t){e.setClientId(t.clientId)}function ZN(e){e.sync()}function JN(e,t){e.load(),t.load()}function QN(e,t,n){e.init(),t.init(),n.init()}function eS(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}KN.sentry&&YN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;EN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1582.0",beforeSend:(e,t)=>{if(TN>=5)return Hv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++TN;try{const n=t&&t.originalException
784
784
  ;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch{}return e}});try{Nx("host_config",Ov(window.location.href))}catch{}Nx("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),wy(((e,t)=>{CN(e,t)}))}(KN.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),XN.$inject=["api","streamer"],ZN.$inject=["router"],JN.$inject=["groups","session"],QN.$inject=["autosaveService","persistedDefaults","serviceURL"],eS.$inject=["frameSync","store","toastMessenger"];const tS=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",Xv)}(),async function(e,t=window){const n=function(e){
785
785
  const t=Ov(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Rv,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Dv(t.origin),ancestorLevel:Pv(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;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:Fv(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await Lv(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services
786
786
  ;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=Lv(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=Ao(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(KN).then((e=>{!function(e,t){const n=new V