hypothesis 1.1686.0 → 1.1688.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-template.js +1 -1
- package/build/boot.js +1 -1
- package/build/manifest.json +7 -7
- package/build/scripts/annotator.bundle.js +1 -1
- package/build/scripts/sidebar.bundle.js +53 -53
- package/build/scripts/sidebar.bundle.js.map +1 -1
- package/build/styles/sidebar.css +3 -0
- package/build/styles/sidebar.css.map +1 -1
- package/build/styles/ui-playground.css +3 -0
- package/build/styles/ui-playground.css.map +1 -1
- package/package.json +1 -1
package/build/boot-template.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?07564f","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?ee8f84","styles/annotator.css":"styles/annotator.css?d8c51f","styles/annotator.css.map":"styles/annotator.css.map?4a856f","styles/highlights.css":"styles/highlights.css?470b72","styles/highlights.css.map":"styles/highlights.css.map?d94fe5","styles/katex.min.css":"styles/katex.min.css?921c28","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?e544d0","styles/sidebar.css.map":"styles/sidebar.css.map?0f2f52","styles/ui-playground.css":"styles/ui-playground.css?2d235e","styles/ui-playground.css.map":"styles/ui-playground.css.map?407f25","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?19cf86","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?c37ce3","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?f3e15d","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?8568ba"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.esModule,o=void 0===n||n,i=r.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function n(s,t,r,n){var o=s.createElement("link");o.rel=t,o.href=n,o.type="application/annotator+".concat(r),e(o),s.head.appendChild(o)}function o(s,t,r){var n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,"fetch"===t&&(n.crossOrigin="anonymous"),e(n),s.head.appendChild(n)}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"),r=0;r<t.length;r++){var n=void 0;try{n=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),n={}}Object.assign(e,n)}return e}(document),c=a(l.assetRoot||"__ASSET_ROOT__");if(document.querySelector("hypothesis-app")){!function(s,e){o(s,"fetch",e.apiUrl),o(s,"fetch",e.apiUrl+"links");for(var n=0,a=["scripts/sidebar.bundle.js"];n<a.length;n++)r(s,i(e,a[n]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,i(e,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=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(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=a(d.notebookAppUrl||"__NOTEBOOK_APP_URL__"),h=a(d.profileAppUrl||"__PROFILE_APP_URL__"),y=a(d.sidebarAppUrl||"__SIDEBAR_APP_URL__");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",e.sidebarAppUrl),n(s,"notebook","html",e.notebookAppUrl),n(s,"profile","html",e.profileAppUrl),o(s,"style",i(e,"styles/annotator.css")),n(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)r(s,i(e,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)t(s,i(e,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?07564f","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?ee8f84","styles/annotator.css":"styles/annotator.css?d8c51f","styles/annotator.css.map":"styles/annotator.css.map?4a856f","styles/highlights.css":"styles/highlights.css?470b72","styles/highlights.css.map":"styles/highlights.css.map?d94fe5","styles/katex.min.css":"styles/katex.min.css?921c28","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?e544d0","styles/sidebar.css.map":"styles/sidebar.css.map?0f2f52","styles/ui-playground.css":"styles/ui-playground.css?2d235e","styles/ui-playground.css.map":"styles/ui-playground.css.map?407f25","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?19cf86","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?c37ce3","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?f3e15d","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?8568ba"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.esModule,o=void 0===n||n,i=r.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function n(s,t,r,n){var o=s.createElement("link");o.rel=t,o.href=n,o.type="application/annotator+".concat(r),e(o),s.head.appendChild(o)}function o(s,t,r){var n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,"fetch"===t&&(n.crossOrigin="anonymous"),e(n),s.head.appendChild(n)}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"),r=0;r<t.length;r++){var n=void 0;try{n=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),n={}}Object.assign(e,n)}return e}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1688.0/");if(document.querySelector("hypothesis-app")){!function(s,e){o(s,"fetch",e.apiUrl),o(s,"fetch",e.apiUrl+"links");for(var n=0,a=["scripts/sidebar.bundle.js"];n<a.length;n++)r(s,i(e,a[n]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,i(e,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=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(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=a(d.notebookAppUrl||"https://hypothes.is/notebook"),h=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"]')){n(s,"sidebar","html",e.sidebarAppUrl),n(s,"notebook","html",e.notebookAppUrl),n(s,"profile","html",e.profileAppUrl),o(s,"style",i(e,"styles/annotator.css")),n(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)r(s,i(e,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)t(s,i(e,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
package/build/manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?07564f",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?ee8f84",
|
|
4
4
|
"styles/annotator.css": "styles/annotator.css?d8c51f",
|
|
5
5
|
"styles/annotator.css.map": "styles/annotator.css.map?4a856f",
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"styles/katex.min.css.map": "styles/katex.min.css.map?e7e03f",
|
|
10
10
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
|
|
11
11
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
|
|
12
|
-
"styles/sidebar.css": "styles/sidebar.css?
|
|
13
|
-
"styles/sidebar.css.map": "styles/sidebar.css.map?
|
|
14
|
-
"styles/ui-playground.css": "styles/ui-playground.css?
|
|
15
|
-
"styles/ui-playground.css.map": "styles/ui-playground.css.map?
|
|
16
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?ab9e6d",
|
|
12
|
+
"styles/sidebar.css": "styles/sidebar.css?e544d0",
|
|
13
|
+
"styles/sidebar.css.map": "styles/sidebar.css.map?0f2f52",
|
|
14
|
+
"styles/ui-playground.css": "styles/ui-playground.css?2d235e",
|
|
15
|
+
"styles/ui-playground.css.map": "styles/ui-playground.css.map?407f25",
|
|
17
16
|
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?19cf86",
|
|
17
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?c37ce3",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?f3e15d",
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?8568ba"
|
|
20
20
|
}
|
|
@@ -148,7 +148,7 @@ this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.des
|
|
|
148
148
|
;if(o instanceof Range){const i=Mn.fromRange(o);n={annotation:e,target:t,region:i}}else n={annotation:e,target:t,region:o}}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.region)),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&&this._highlighter.removeHighlights(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation(e){if("selection"===e)return this.createAnnotationFromSelection();if(!["rect","point"].includes(e))throw new Error("Unsupported annotation tool");{let t=!1;try{this._hostRPC.call("activeToolChanged",e)
|
|
149
149
|
;const t=await this._drawTool.draw(e),n=await this.getDocumentInfo(),o=[{source:n.uri,selector:await this._integration.describe(this.element,t)}],i={uri:n.uri,document:n.metadata,target:o,$tag:"a:"+Ct(8)};return this._sidebarRPC.call("createAnnotation",i),this.anchor(i),i}catch(e){if(e instanceof no&&["canceled","restarted"].includes(e.kind))return t="restarted"===e.kind,null;throw e}finally{t||this._hostRPC.call("activeToolChanged",null)}}}async createAnnotationFromSelection({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=>({source:n.uri,selector:e}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+Ct(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),or(),r}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)))
|
|
150
150
|
;for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);this._highlighter.setHighlightsFocused(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=Fn(n),i=Vn(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=er(),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}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){this._highlighter.setHighlightsVisible(e),this._highlightsVisible=e,
|
|
151
|
-
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){dn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Qi(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function sr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function ar(e,t){const n={};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.
|
|
151
|
+
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){dn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Qi(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function sr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function ar(e,t){const n={};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.1688.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),
|
|
152
152
|
e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function lr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=ie(null);return ne((()=>{e?r.current?.close():r.current?.showModal()}),[e]),ne((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Se("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function cr({closed:e,children:t,...n}){return Se("div",{...n,className:Ne("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Se("div",{className:"relative w-full h-full",children:t})})}function hr({document_:e=document,...t}){return Se(re((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?lr:cr),[e]),{...t})}function dr({config:e,groupId:t}){
|
|
153
153
|
return Se("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:sr(e.notebookAppUrl,{...ar(e.notebookAppUrl,e),group:t})})}function ur({eventBus:e,config:t}){const[n,o]=te(0),[i,r]=te(!0),[s,a]=te(null),l=ie(""),c=ie(null);ne((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),ne((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),ne((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const h=se((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:Se(hr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close notebook",onClick:h,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Se(Le,{className:"w-4 h-4"})})}),Se(dr,{
|
|
154
154
|
config:t,groupId:s},n)]})}class fr{constructor(e,t,n){this._container=new yn("notebook",(()=>Se(ur,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function pr({eventBus:e,config:t}){const[n,o]=te(!0),i=ie(null);ne((()=>{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:Se(hr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Se("div",{className:"absolute right-0 m-3",children:Se(ot,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Ne("!bg-transparent enabled:hover:!bg-grey-3"),children:Se(Le,{className:"w-4 h-4"})})}),Se("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class gr{constructor(e,t,n){this._container=new yn("profile",(()=>Se(pr,{eventBus:t,config:n}))),e.append(this._container.element),
|
|
@@ -565,58 +565,58 @@ return!Lr(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${zr(e.user)}`)??void
|
|
|
565
565
|
}),i&&u&&o&&Ve(xm,{collapsedHeight:35,children:Ve(Ia,{"aria-hidden":"true",children:Ve("blockquote",{id:p,children:u})})})]})}),["thumbnailService"]);function Tm(){return Ve("div",{className:Je("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Ve("span",{className:"text-[16px] animate-fade-in-slow",children:Ve(Rn,{size:"sm"})}),Ve("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var Em=Jn((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ji(),s=Kr(e),l=Yr(e),c=a.getDraft(e),u=a.profile().userid,d=a.isAnnotationHovered(e.$tag),h=a.isSavingAnnotation(e),p=!!c&&!h,m=t&&o,f=!h&&!p&&Rr(e),g=a.defaultAuthority(),v=a.isFeatureEnabled("client_display_names"),b=ue((()=>Xi(e,g,v)),[e,g,v]),y=ue((()=>Ue(e.created)),[e.created]),_=Rr(e)?Ur(e):`New ${Ur(e).toLowerCase()}`,w=a.isAnnotationHighlighted(e)?" - Highlighted":"",x=ue((()=>Xr(e)),[e])
|
|
566
566
|
;return Ve("article",{className:"space-y-4","aria-label":`${_} by ${b} on ${y}${w}`,children:[Ve(wm,{annotation:e,isEditing:p,replyCount:r,threadIsCollapsed:o}),x&&Ve(Am,{tag:e.$tag,textInImage:x.text,description:l,showDescription:!p}),s&&Ve(km,{quote:s,isHovered:d,isOrphan:$r(e)}),!m&&!p&&Ve(Ip,{annotation:e}),p&&Ve(_m,{annotation:e,draft:c}),!m&&Ve("footer",{className:"flex items-start",children:[Ve("div",{className:"flex flex-col items-start gap-y-1",children:[f&&Ve(_p,{annotation:e,groupIsPreModerated:!!a.focusedGroup()?.pre_moderated,badgeClasses:"mt-0.5"}),n&&Ve(Sm,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o})]}),h&&Ve(Tm,{}),f&&Ve(at,{classes:"grow",children:Ve(Ep,{annotation:e,onReply:()=>{Rr(e)&&u&&i.reply(e,u)}})})]})]})}),["annotationsService"]);function Cm({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Ve("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Ve("div",{children:Ve("em",{
|
|
567
567
|
children:"Message not available."})}),r&&Ve("footer",{className:"flex items-center",children:Ve(Sm,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}function Mm({annotation:e}){const t=Wr(e);return!!t?Ve("div",{className:Je("flex gap-x-3 bg-grey-1 text-color-text font-semibold","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!Pr(e),"-mr-3":Pr(e)}),children:[Ve("div",{className:Je("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:e.hidden?Ve(Dt,{className:"w-em h-em"}):Ve(It,{className:"w-em h-em"})}),Ve("div",{className:"self-center grow",children:[!e.hidden&&Ve("span",{children:["Flagged for review by ",t," ",1===t?"user":"users"]}),e.hidden&&Ve("span",{children:"Hidden from users"})]})]}):null}function Nm({threadIsCollapsed:e,onToggleReplies:t}){const n=e?ht:Yt,r=e?"Expand replies":"Collapse replies";return Ve("div",{className:Je("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Ve("div",{className:Je("bg-white"),
|
|
568
|
-
children:Ve(dn,{classes:Je("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-
|
|
568
|
+
children:Ve(dn,{classes:Je("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-6 hover:text-grey-8"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Ve(n,{className:"w-em h-em"})})})})}var Im=Jn((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Ki(e)>0)),i=ji(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=de((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=ue((()=>t.visible&&Ve(y,{children:t.annotation?Ve(y,{children:[Ve(Mm,{annotation:t.annotation}),Ve(Em,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Ve(Cm,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Ve("section",{className:"flex",
|
|
569
569
|
"data-testid":"thread-container",children:[r&&Ve(Nm,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ve("div",{className:Je("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,Wi(t)>0&&Ve("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ve(wm,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Ve("div",{children:Ve(dn,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",Wi(t)," more in conversation"]})})]}),!t.collapsed&&Ve("ul",{className:Je("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Ve("li",{className:Je("mt-2","[text-align:start]"),children:Ve(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var Om=Jn((function({frameSync:e,thread:t}){const n=ji(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=ue((()=>qi((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=de((t=>{e.scrollToAnnotation(t)
|
|
570
570
|
}),[e]),l=n.profile().userid,c="DENIED"===t.annotation?.moderation_status&&t.annotation.user===l,u=ue((()=>Ve(Im,{thread:t})),[t]),d=n.annotationFocusRequest(),h=ce(null);return se((()=>{d===t.id&&h.current&&(h.current.focus(),n.clearAnnotationFocusRequest())}),[d,n,t.id]),Ve(it,{active:o,classes:Je("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a,"border-red":!a&&c}),"data-testid":"thread-card",elementRef:h,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Ve(st,{children:u})},t.id)}),["frameSync"]);const zm=50;function Lm(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function Pm(e){return Math.max(e-e%zm,0)}function Rm(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function Dm(e){if(!e.annotation)return null
|
|
571
|
-
;const t=Rm(e.annotation);return t?.cfi??null}function jm({threads:e}){const[t,n]=ie(0),[r,o]=ie(0);le((()=>{const e=new xe,t=Lm();n(t.clientHeight),o(Pm(t.scrollTop));const r=qi((()=>{n(t.clientHeight),o(Pm(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=ie((()=>new Map)),[s,l]=ie(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=ue((()=>function(e,t,n,r,o=Ui){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d}}(c,i,r,t)),[c,i,r,t]),
|
|
572
|
-
o.set(i,a))}return o}),[e]),
|
|
573
|
-
;const o=Gi(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Ve("div",{children:[Ve("div",{style:{height:d}}),h.map((
|
|
574
|
-
const n=e.children.map((e=>Gm(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function Vm(e){return e.children.some((e=>e.visible||Vm(e)))}const Wm=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function Km(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=Fm(e);t[n]={...Hm,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return Bm(t,Fm(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...Hm,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn
|
|
575
|
-
;let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),o.children=o.children.filter((e=>e.visible||Vm(e))),o=qm(o,(e=>{const n={collapsed:e.collapsed};if(Ir(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&Vm(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=Um(o,t.sortCompareFn,Wm),o=Gm(o,-1),o}function Ym(e){const t=Xm(e),[n,r]=t.split("-",2);return[n,r??n]}function Xm(e){if(!e.includes("["))return e;let t="",n=!1,r=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function Zm(e,t){const n=e=>function(e){const t=Xm(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){
|
|
576
|
-
}(n(e),n(t))}function Qm(e,t,n){return Zm(e,t)>=0&&Zm(e,n)<0}function Jm(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e];let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let ef=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function tf(e,t,n){return[e[0]??t,e[1]??n]}function nf(e,t){const n=Jm(e),r=Jm(t);if(!n||!r)return e&&t&&e===t?ef.Overlap:ef.Unknown;const o=2**31,[i,a]=tf(n,1,o),[s,l]=tf(r,1,o);return i<=s?s<=a?ef.Overlap:ef.NoOverlap:i<=l?ef.Overlap:ef.NoOverlap}function rf(e){return function(e){return e.replace(/\p{M}/gu,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class of{constructor(e,t){
|
|
577
|
-
}matches(e){return"and"===this.operator?this.filters.every((t=>t.matches(e))):this.filters.some((t=>t.matches(e)))}}function sf(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:rf}}const lf={quote:sf((e=>[Kr(e)??Yr(e)??""])),cfi:{fieldValues:e=>[Zr(e)?.trim()??""],matches:(e,t)=>{const[n,r]=Ym(t);return Qm(e,n,r)},normalize:e=>Xm(e.trim())},page:{fieldValues:e=>[Qr(e)?.trim()??""],matches:(e,t)=>nf(e,t)===ef.Overlap,normalize:e=>e.trim()},since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:sf((e=>e.tags)),text:sf((e=>[e.text])),uri:sf((e=>[e.uri])),user:sf((e=>[e.user,e.user_info?.display_name??""]))};function cf(e,t){const n=(e,t)=>new of(t,lf[e]),r=Object.entries(t).filter((([,e])=>e.terms.length>0)).map((([e,t])=>{let r;if("any"===e){
|
|
578
|
-
;return e.filter((e=>o.matches(e)))}const uf=["cfi","quote","page","since","tag","text","uri","user"],df=["group","quote","tag","text","uri","user"];function hf(e,t){const n=e.slice(0,e.indexOf(":"));if(!n)return[null,e];if(t.includes(n)){return[n,e.slice(n.length+1)]}return[null,e]}function pf(e){const t=e.slice(0,1),n=e.slice(-1);return'"'!==t&&"'"!==t||t!==n||(e=e.slice(1,e.length-1)),e}function mf(e,t){const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map(pf).filter((e=>e.length>0)).map((e=>{const[n,r]=hf(e,t);return n?n+":"+pf(r):e})):[]}function ff(e){const t={},n=e=>"tag"===e?"tags":e,r=mf(e,df);for(const e of r){let[r,o]=hf(e,df);r||(r="any",o=e);const i=n(r);t[i]?t[i].push(o):t[i]=[o]}return t}function gf(e){return $r(e)?"orphan":Br(e)?"note":"annotation"}function vf(e){
|
|
579
|
-
const n=e??Number.MIN_SAFE_INTEGER,r=t??Number.MIN_SAFE_INTEGER;return Math.sign(n-r)}function _f(e,t){return e===t?0:e<t?-1:1}function wf(e,t,n){switch(n.sortBy){case"newest":{const n=vf(e);return _f(vf(t),n)}case"oldest":return _f(bf(e),bf(t));case"location":return function(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=Gr(e.annotation),r=Gr(t.annotation);if(n.cfi||r.cfi){const e="/0",t=Zm(n.cfi??e,r.cfi??e);if(0!==t)return Math.sign(t)}const o=yf(n.pageIndex,r.pageIndex);if(0!==o)return o;const i=yf(n.top,r.top);if(0!==i)return i;const a=yf(n.charOffset,r.charOffset);if(0!==a)return a;return _f(e.annotation.created,t.annotation.created)}(e,t);default:return 0}}const xf=function(e){if(1!==e.length)throw new Error("Memoize input must be a function of one argument")
|
|
580
|
-
sortCompareFn:(e,n)=>wf(e,n,{sortBy: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=mf(e,uf);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",
|
|
581
|
-
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=>cf([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&cf([e.annotation],o).length>0)}const r=Km(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(Hr(e.annotation))return!1;const n=gf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function kf(){
|
|
582
|
-
var Sf,Af,Tf=Jn((function({loadAnnotationsService:e,onLogin:t}){const n=ji(),r=n.routeParams().id??"",{rootThread:o}=kf(),i=n.profile().userid,[a,s]=ie(!1);return se((()=>{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]),Ve(y,{children:[a&&Ve(Hi,{errorType:"annotation",onLoginRequest:t}),Ve(jm,{threads:o.children})]})}),["loadAnnotationsService"]);class Ef{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.
|
|
583
|
-
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 Cf=function(){if(Af)return Sf;Af=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){
|
|
584
|
-
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-=p,o-=m,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),
|
|
585
|
-
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 Sf=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||{}
|
|
586
|
-
var l,c=!n._scrollSettings,u=n._scrollSettings,d=Date.now(),h={passive:!0};function p(e){n._scrollSettings=null,n.parentElement&&n.parentElement._scrollSettings&&n.parentElement._scrollSettings.end(e),i.debug&&console.log("Scrolling ended with type",e,"for",n),s(e),l&&(n.removeEventListener("touchstart",l,h),n.removeEventListener("wheel",l,h))}u&&u.end(t);var m=i.maxSynchronousAlignments;return null==m&&(m=3),n._scrollSettings={startTime:d,endIterations:0,target:e,time:i.time,ease:i.ease,align:i.align,isWindow:i.isWindow||o,maxSynchronousAlignments:m,end:p,scrollAncestor:a},"cancellable"in i&&!i.cancellable||(l=p.bind(null,t),n.addEventListener("touchstart",l,h),
|
|
587
|
-
}),[l,i]);const d=de((()=>{s.toggleSidebarPanel(n,!1)}),[s,n]);return Ve(y,{children:l&&Ve(yn,{initialFocus:a,restoreFocus:!0,ref:c,classes:"mb-4",title:r,icon:t,onClose:d,transitionComponent:Wn,variant:o,scrollable:!1,children:e})})}function If({commandName:e,icon:t}){return Ve("span",{className:"whitespace-nowrap","data-testid":"instruction",children:[Ve(t,{className:Je("w-em h-em","mx-1 -mt-1","text-color-text-light inline"),"aria-hidden":!0}),Ve("em",{"data-testid":"command-name",children:e})]})}var Of=Jn((function({settings:e}){const t=!Yn(e);return Ve("ol",{className:"list-decimal pl-10 space-y-2",children:[Ve("li",{
|
|
588
|
-
commandName:"Highlight"})," button."]}),t&&Ve("li",{children:["To annotate in a private group, select the group from the groups dropdown. Don't see your group? Ask the group creator to send a"," ",Ve($n,{href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",underline:"always",children:"join link"}),"."]}),Ve("li",{children:["To reply to an annotation, select the"," ",Ve(If,{icon:rn,commandName:"Reply"})," button."]})]})}),["settings"]);async function zf(e,t=navigator){await t.clipboard.writeText(e)}function Lf({label:e,children:t,classes:n}){return Ve(y,{children:[Ve("dt",{
|
|
589
|
-
children:t.userAgent}),Ve(Lf,{classes:Je("break-all"),label:"URL",children:t.urls}),Ve(Lf,{label:"Fingerprint",children:t.fingerprint}),t.segment&&Ve(Lf,{label:"Segment",children:t.segment}),Ve(Lf,{label:"Account",children:t.account}),Ve(Lf,{label:"Date",children:t.timestamp})]}),Ve("div",{className:"flex items-center justify-center",children:Ve(dn,{onClick:async()=>{try{await zf(t.asFormattedString()),e.success("Copied version info to clipboard")}catch{e.error("Unable to copy version info")}},icon:_t,children:"Copy version details"})})]})}),["toastMessenger"]);function Rf({children:e,closeTitle:t}){
|
|
590
|
-
className:Je("p-3 focus-visible-ring ring-inset",{hidden:!t}),hidden:!t,children:[n&&Ve(gn,{children:n}),Ve("div",{className:"space-y-3 pt-2",children:e})]})}function jf({linkText:e,url:t}){return Ve("div",{className:"flex-1 flex items-center justify-center border-r last-of-type:border-r-0 text-md font-medium",children:Ve($n,{variant:"text-light",href:t,target:"_blank",underline:"none",children:Ve("div",{className:"flex items-center gap-x-2",children:[Ve("span",{children:e})," ",Ve(Ct,{className:"w-3 h-3"})]})})})}var Hf=Jn((function({session:e}){
|
|
591
|
-
!t&&u&&e.dismissSidebarTutorial()}),[e,u]),variant:"custom",children:[Ve(Rf,{closeTitle:"Close help panel",children:[Ve(Gn,{id:a,"aria-controls":s,variant:"tab",textContent:"Help",selected:"tutorial"===d,onClick:()=>h("tutorial"),"data-testid":"tutorial-tab",children:"Help"}),Ve(Gn,{id:l,"aria-controls":c,variant:"tab",textContent:"Version",selected:"versionInfo"===d,onClick:()=>h("versionInfo"),"data-testid":"version-info-tab",children:"Version"})]}),Ve(it,{classes:Je({"rounded-tl-none":"tutorial"===d}),children:[Ve("div",{className:"border-b",
|
|
592
|
-
this.#e.push({name:e,callback:t})}off(e,t){this.#e=this.#e.filter((n=>!(n.name===e&&n.callback===t)))}emit(e,...t){for(const n of this.#e){if(n.name!==e)continue;(0,n.callback)(...t)}}}class $f extends Error{constructor(e){super(`Results size exceeds ${e}`)}}function Bf(e){return 0===e?50:200}class qf extends Ff{constructor(e,{getPageSize:t=Bf,separateReplies:n=!0,incremental:r=!0,maxResults:o=null,sortBy:i="created",sortOrder:a="asc"}={}){super(),this._searchFn=e,this._getPageSize=t,this._separateReplies=n,this._incremental=r,this._maxResults=o,
|
|
593
|
-
this._maxResults&&t.total>this._maxResults)return this.emit("error",new $f(this._maxResults)),void this.emit("end");const o=t.rows.concat(t.replies||[]);this._incremental?this.emit("results",o):this._results=this._results.concat(o),this._fetchedCount+=o.length;const i=this._fetchedCount<this._expectedCount||this._expectedCount>1e3;let a=null;o.length>0&&i&&(a=o[o.length-1][this._sortBy]),a?this._getPage(e,a,n+1):(this._incremental||this.emit("results",this._results),this.emit("end"))}catch(e){if(this._canceled)return;this.emit("error",e),this.emit("end")}}get(e){
|
|
594
|
-
contentClass:Je("max-h-[min(60vh,504px)] overflow-y-auto"),children:a.map((e=>Ve(vm,{onClick:()=>n(e),isSelected:e.value===s.value,label:e.display},e.value)))})}function Gf(){const e=ji(),t=e.getFilter("user"),n=function(){const e=ji(),t=e.allAnnotations(),n=e.getFocusFilters(),r=zr(e.profile().userid),o=e.defaultAuthority(),i=e.isFeatureEnabled("client_display_names");return ue((()=>{const e={};if(t.forEach((t=>{const n=zr(t.user);e[n]=Xi(t,o,i)})),n.user){const t=zr(n.user.value)||n.user.value;e[t]=n.user.display}const a=Object.keys(e).map((t=>({display:t===r?`${e[t]} (Me)`:e[t],value:t})))
|
|
595
|
-
const{rootThread:o}=kf(),i=n?r:Ki(o),a=o.children.length>0,s=t&&e>0,l=i-e,c=o.children.length;return Ve("div",{className:"flex gap-x-1 leading-none",children:[n&&Ve(Rn,{size:"sm"}),!n&&Ve("h2",{className:"font-bold",children:[!a&&Ve("span",{children:"No results"}),a&&t&&Ve("span",{children:[l," ",1===l?"result":"results"]}),a&&!t&&Ve("span",{children:[c," ",1===c?"thread":"threads"]})]}),s&&Ve("h3",{className:"italic font-normal",children:["(and ",e," more)"]}),!t&&a&&Ve("h3",{className:"italic font-normal",children:["(",i," ",1===i?"annotation":"annotations",")"]})]})}function Wf({currentPage:e,isLoading:t,onChangePage:n,threads:r,pageSize:o=25}){
|
|
596
|
-
;function Xf(e,t,{rootElement:n=document.documentElement??void 0}={}){const r=n=>{(function(e,t){if(!(e instanceof KeyboardEvent))return!1;const n=t.split("+").map((e=>e.toLowerCase()));let r=0,o=null;for(const e of n){const t=Yf[e];if(t)r|=t;else{if(null!==o)throw new Error("Multiple non-modifier keys specified");o=e}}if(!o)throw new Error(`Invalid shortcut: ${t}`);return((e.ctrlKey?Yf.ctrl:0)|(e.metaKey?Yf.meta:0)|(e.altKey?Yf.alt:0)|(e.shiftKey?Yf.shift:0))===r&&e.key.toLowerCase()===o})(n,e)&&t(n)};return n?(n.addEventListener("keydown",r),()=>n.removeEventListener("keydown",r)):()=>{}}function Zf(e,t,{rootElement:n}={}){se((()=>{if(e)return Xf(e,t,{
|
|
597
|
-
className:Je("flex gap-1.5 items-center px-2 py-1","border-l first:border-l-0 border-white/60"),children:[Ve(i,{className:"w-em h-em"}),Ve("div",{className:"flex gap-1",children:[Ve("span",{className:"font-bold",children:n}),Ve(Qf,{hidden:t,children:Kf(n,r,o)})]})]})}var eg=Jn((function({streamer:e,analytics:t,setTimeout_:n=setTimeout,clearTimeout_:r=clearTimeout}){const o=ji(),i=o.pendingUpdateCount(),a=o.pendingMentionCount(),s=o.isFeatureEnabled("at_mentions"),l=o.hasPendingUpdatesOrDeletions(),c=de((()=>{e.applyPendingUpdates(),t.trackEvent("client.realtime.apply_updates")}),[t,e]),[u,d]=ie(!1),h=ce(null);return Zf("l",(()=>l&&c())),se((()=>(l?h.current=n((()=>{d(!0),h.current=null
|
|
598
|
-
"data-collapsed":u,children:[Ve(Jf,{type:"updates",collapsed:u,count:i}),s&&a>0&&Ve(Jf,{type:"mentions",collapsed:u,count:a}),Ve("span",{className:"sr-only",children:"load them by pressing l"})]})}):null}),["streamer","analytics"]);var tg=Jn((function({loadAnnotationsService:e,streamer:t}){const n=ji(),r=n.getFilterValues(),o=n.focusedGroup(),i=n.forcedVisibleThreads().length,a=n.hasAppliedFilter(),s=n.isLoading(),l=n.annotationResultCount(),{rootThread:c}=kf(),u=o?.name??"…",d=o?.id||n.directLinkedGroupId(),h=ce(1),[p,m]=ie(1),[f,g]=ie(!1),v=e=>{e instanceof $f&&g(!0)},b=n.hasFetchedProfile();se((()=>{b&&t.connect({applyUpdatesImmediately:!1})}),[b,t]),se((()=>{n.setSortKey("newest"),d&&e.load({
|
|
599
|
-
"data-testid":"notebook-container",children:[Ve("header",{className:"leading-none lg:col-span-2",ref:_,children:Ve("h1",{className:"text-xl font-bold","data-testid":"notebook-group-name",children:u})}),Ve("div",{className:"absolute w-full z-5 left-0 lg:top-8 top-5",children:Ve("div",{className:Je("container flex flex-row-reverse relative","right-[4rem]"),children:Ve(eg,{})})}),Ve("div",{className:"justify-self-start",children:Ve(Gf,{})}),Ve("div",{className:"flex items-center lg:justify-self-end text-md font-medium",children:Ve(Vf,{forcedVisibleCount:i,isFiltered:a,isLoading:s,resultCount:l??0})}),Ve("div",{className:"lg:col-span-2",children:[f&&Ve("div",{className:"py-4","data-testid":"notebook-messages",children:Ve(bn,{
|
|
600
|
-
href:"mailto:support@hypothes.is?subject=Hypothesis%20Notebook&body=Please%20notify%20me%20when%20the%20Hypothesis%20Notebook%20is%20updated%20to%20support%20more%20than%205000%20annotations",underline:"always",children:"Contact us"})," ","if you would like to be notified when support for more annotations is available."]})]})}),Ve(Wf,{currentPage:p,isLoading:s,onChangePage:y,threads:c.children})]})]})}),["loadAnnotationsService","streamer"]);function ng({classes:e,children:t,onClose:n=(()=>{}),...r}){return Ve("div",{className:Je("flex items-center gap-x-1 py-1 px-2 rounded","bg-green-success/10 animate-pulse-fade-out",e),onAnimationEnd:n,...r,children:[Ve(gt,{className:"text-green-success w-em h-em p-[0.125em]"}),Ve("div",{className:"text-sm",children:t})]})}function rg(){
|
|
601
|
-
"data-testid":"profile-container",classes:"overflow-hidden",children:[Ve("div",{className:Je("h-12","px-3 border-b flex items-center"),children:[Ve("div",{className:"grow",children:Ve("h1",{className:"text-xl text-slate-7 font-normal",children:"Notifications"})}),Ve("ul",{className:"sr-only","aria-live":"polite",children:i&&Ve("li",{children:"Notification preferences saved"},r)}),r>0&&Ve(ng,{onClose:()=>o(0),children:"Saved"},r)]}),Ve(ot,{children:Ve(st,{size:"lg",children:Ve(kn,{defaultChecked:!0,disabled:t,onChange:()=>n(!0),checkedIcon:t?cn:void 0,icon:t?cn:void 0,children:"Email me a daily summary of activity in my courses"})})})]})}function og({annotations:e,getDisplayName:t,excludeReplies:n=!1}){const r=new Map;for(const o of e){if(n&&Pr(o))continue;let e=r.get(o.user);e||(e={
|
|
602
|
-
return`${e.getFullYear()}-${`${e.getMonth()+1}`.padStart(2,"0")}-${`${e.getDate()}`.padStart(2,"0")}`}function ag({documentMetadata:e,groupName:t,date:n=new Date}){const r=[ig(n)];return e?.title?r.push(function(e,t){const n=Array.from(e);return n.length<=t?e:n.slice(0,t).join("")}(e.title,50)):r.push("Hypothesis"),t&&r.push(t.replace(/ /g,"-")),r.join("-")}function sg(){return Ve("div",{className:"flex flex-row items-center justify-center","data-testid":"loading-spinner",children:Ve(Rn,{size:"md"})})}function lg({userAnnotations:e}){return Ve("div",{className:"flex gap-x-2",children:[e.displayName,Ve("div",{className:"rounded px-1 bg-grey-7 text-white",children:e.annotations.length})]})}const cg=[{value:"json",title:"JSON",description:"For import into another Hypothesis group or document"},{value:"txt",
|
|
603
|
-
description:"For import into word processors as rich text"},{value:"csv",title:"Table (CSV)",shortTitle:"CSV",description:"For import into a spreadsheet"}];var ug=Jn((function({annotationsExporter:e,toastMessenger:t}){const n=ji(),r=n.focusedGroup(),o=r&&!n.isLoading(),i=n.defaultContentFrame(),a=n.savedAnnotations(),s=n.defaultAuthority(),l=n.isFeatureEnabled("client_display_names"),c=de((e=>Xi(e,s,l)),[s,l]),u=ue((()=>og({annotations:a,getDisplayName:c})),[a,c]),d=n.profile(),h=d.userid,p=ue((()=>({annotations:a,displayName:"All annotations"})),[a]),[m,f]=ie(h),g=ue((()=>u.find((e=>e.userid===m))??p),[p,m,u]),[v,b]=ie(cg[0]),_=pe(),w=pe(),x=n.countDrafts(),k=ue((()=>ag({documentMetadata:i?.metadata,groupName:r?.name})),[i,r]),[S,A]=ie(),T=de(((t,n)=>{const o=g?.annotations??a;switch(t){case"json":{const t=e.buildJSONExportContent(o,{profile:d})
|
|
604
|
-
return e.buildCSVExportContent(o,{separator:"file"===n?",":"\t",groupName:r?.name,defaultAuthority:s,displayNamesEnabled:l});case"html":return e.buildHTMLExportContent(o,{groupName:r?.name,defaultAuthority:s,displayNamesEnabled:l});default:throw new Error(`Invalid format: ${t}`)}}),[e,s,l,a,r?.name,d,g?.annotations]),E=de((e=>{e.preventDefault();try{const e=v.value,t=`${S??k}.${e}`,n=T(e,"file"),r=function(e){return{json:"application/json",txt:"text/plain",csv:"text/csv",html:"text/html"}[e]}(e);!function(e,t,n,r=document){const o=new Blob([e],{type:t}),i=URL.createObjectURL(o),a=r.createElement("a");a.setAttribute("href",i),a.setAttribute("download",n),a.style.visibility="hidden",r.body.appendChild(a),a.click(),r.body.removeChild(a),URL.revokeObjectURL(i)}(n,r,t)}catch(e){t.error(`Exporting annotations failed: ${e.message}`,{autoDismiss:!1})}
|
|
605
|
-
;if(t.clipboard.write){const n=r.reduce(((t,n)=>(t[n]=new Blob([e],{type:n}),t)),{});await t.clipboard.write([new ClipboardItem(n)])}else{const t=t=>{r.forEach((n=>t.clipboardData?.setData(n,e))),t.preventDefault()};n.addEventListener("copy",t);try{n.execCommand("copy")}finally{n.removeEventListener("copy",t)}}}(n):await zf(n),t.success("Annotations copied")}catch(e){t.error(`Copying annotations failed: ${e.message}`,{autoDismiss:!1})}}),[T,v.value,t]);return o?Ve("form",{className:"space-y-3",onSubmit:E,"data-testid":"export-form",children:[a.length>0?Ve(y,{children:[Ve("p",{className:"text-color-text-light",children:[Ve($n,{variant:"text-light",underline:"always",href:"https://web.hypothes.is/help/exporting-and-importing-annotations-in-the-hypothesis-web-app/",target:"_blank",children:"Learn more"
|
|
606
|
-
}),Ve(Pn,{value:m,onChange:f,buttonId:w,buttonContent:Ve(lg,{userAnnotations:g}),"data-testid":"user-select",children:[Ve(Pn.Option,{value:void 0,children:Ve(lg,{userAnnotations:p})}),u.map((e=>Ve(Pn.Option,{value:e.userid,children:Ve(lg,{userAnnotations:e})},e.userid)))]}),Ve("label",{"data-testid":"export-count",htmlFor:_,className:"font-medium",children:"Name of export file:"}),Ve("div",{className:"flex",children:[Ve(An,{classes:"grow","data-testid":"export-filename",id:_,defaultValue:k,value:S,onChange:e=>A(e.target.value),required:!0,maxLength:250}),Ve("div",{className:"grow-0 ml-2 min-w-[5rem]",children:Ve(Pn,{"aria-label":"Export format",value:v,onChange:b,buttonContent:v.shortTitle??v.title,"data-testid":"export-format-select",alignListbox:"right",listboxOverflow:"wrap",
|
|
607
|
-
children:e.description})]})},e.value)))})})]})]})]}):Ve("p",{"data-testid":"no-annotations-message",children:"There are no annotations available for export."}),x>0&&Ve("p",{"data-testid":"drafts-message",children:["You have ",x," unsaved"," ",Kf(x,"draft","drafts"),a.length>0&&Ve(y,{children:" that will not be included"}),"."]}),Ve(at,{children:[Ve(dn,{"data-testid":"copy-button",icon:_t,onClick:C,disabled:0===a.length,children:"Copy to clipboard"}),Ve(dn,{"data-testid":"export-button",variant:"primary",disabled:0===a.length,type:"submit",children:"Export"})]})]}):Ve(sg,{})}),["annotationsExporter","toastMessenger"]);function dg(e,t=new FileReader){const{promise:n,resolve:r,reject:o}=function(){let e,t;return{promise:new Promise(((n,r)=>{e=n,t=r})),resolve:e,reject:t}}()
|
|
608
|
-
role:"progressbar","aria-valuenow":t,style:{width:`${e}px`,height:`${e}px`,transform:"rotate(-90deg)"},children:Ve("svg",{viewBox:`0 0 ${e} ${e}`,children:Ve("circle",{cx:e/2,cy:e/2,r:n/2,fill:"none",stroke:"currentColor","stroke-width":2,style:{strokeDasharray:r,strokeDashoffset:r-r*(t/100)+"px",transitionDuration:"300ms",transitionProperty:"stroke-dashoffset"}})})})}function pg({onFileSelected:e,disabled:t,id:n}){const r=ce(null),[o,i]=ie(null);return Ve(dn,{variant:"custom",classes:Je("w-full relative overflow-hidden border rounded","bg-grey-0 hover:bg-grey-0"),title:o?`${o}, Select a file`:"Select a file",onClick:()=>r.current?.click(),disabled:t,"data-testid":"file-input-proxy-button",children:[Ve("input",{ref:r,accept:".json",id:n,type:"file",disabled:t,
|
|
609
|
-
"data-testid":"filename-container",children:o??"Select a file"}),Ve("div",{className:"absolute right-0 h-full p-2 border-l bg-grey-2",children:Ve(Mt,{})})]})}var mg=Jn((function({importAnnotationsService:e}){const[t,n]=ie(null),[r,o]=ie(null),[i,a]=ie(null),s=ji(),l=s.profile().userid,c=s.defaultAuthority(),u=s.isFeatureEnabled("client_display_names"),d=de((e=>Xi(e,c,u)),[c,u]),h=ue((()=>r?og({annotations:r,getDisplayName:d,excludeReplies:!0}):null),[r,d]),[p,m]=ie(null),f=ue((()=>h?.find((e=>e.userid===p))??null),[p,h]);let g;se((()=>{l&&t&&(o(null),a(null),m(null),async function(e){let t;try{t=await dg(e)}catch{throw new Error("Not a valid JSON file")}if(null===(n=t)||"object"!=typeof n||!Array.isArray(t.annotations))throw new Error("Not a valid Hypothesis JSON file");var n
|
|
610
|
-
"data-testid":"log-in-message",children:"You must log in to import annotations."});const _=Boolean(s.focusedGroup()&&s.defaultContentFrame()&&s.hasFetchedAnnotations()&&!s.isFetchingAnnotations()&&g),w=t&&!r&&!i,x=s.importsPending(),k=s.importsTotal(),S=k-x,A=w||x>0,T=x>0?Math.round(S/k*100):null;return Ve(y,{children:[Ve("p",{className:"text-color-text-light mb-3",children:[Ve($n,{variant:"text-light",underline:"always",href:"https://web.hypothes.is/help/exporting-and-importing-annotations/",target:"_blank",children:"Learn more"})," ","about importing annotations."]}),Ve("label",{htmlFor:v,className:"font-medium",children:"Select Hypothesis export file:"}),Ve(pg,{onFileSelected:n,disabled:A,id:v}),h&&Ve(y,{children:[Ve("label",{htmlFor:b,className:"block font-medium",
|
|
611
|
-
children:h.map((e=>Ve(Pn.Option,{value:e,children:Ve(lg,{userAnnotations:e})},e.userid)))})]}),i&&Ve("p",{"data-testid":"error-info",children:[Ve("b",{children:"Unable to find annotations to import:"})," ",i]}),Ve(at,{children:[null!==T&&Ve("span",{"data-testid":"progress-text",className:"text-grey-6",children:[T,"% complete"]}),Ve(dn,{"data-testid":"import-button",disabled:!_||A,onClick:g,variant:"primary",children:[null!==T&&Ve(hg,{size:22,value:T}),"Import"]})]})]})}),["importAnnotationsService"]);var fg=Jn((function({toastMessenger:e}){const t=ji(),n=t.mainFrame(),r=t.focusedGroup(),o=r&&n,i=o&&(a=n.uri,s=r.id,/^http(s?):/i.test(a)?`https://hyp.is/go?url=${encodeURIComponent(a)}&group=${s}`:null);var a,s;const l=de((async()=>{try{i&&(await zf(i),
|
|
612
|
-
children:"private"===r.type?Ve("p",{children:"Use this link to share these annotations with other group members:"}):Ve("p",{children:"Use this link to share these annotations with anyone:"})}),Ve("div",{children:Ve(pn,{children:[Ve(An,{"aria-label":"Use this URL to share these annotations",type:"text",value:i,readOnly:!0}),Ve(mn,{icon:_t,onClick:l,title:"Copy share link",variant:"dark"})]})}),Ve("p",{"data-testid":"sharing-details",children:["private"===r.type?Ve("span",{children:["Annotations in the private group ",Ve("em",{children:r.name})," ","are only visible to group members."]}):Ve("span",{children:["Anyone using this link may view the annotations in the group"," ",Ve("em",{children:r.name}),"."]})," ",Ve("span",{children:["Private (",Ve(Gt,{
|
|
613
|
-
}):Ve(sg,{})}),["toastMessenger"]);function gg({shareTab:e}){const t=ji().focusedGroup(),n=t&&t.name||"...",r=`Share Annotations in ${n}`,o=e?"share":"export",[i,a]=ie(o),s=i===o;return Ve(Nf,{title:r,panelName:"shareGroupAnnotations",variant:"custom",children:[Ve(Rf,{closeTitle:"Close share panel",children:[e&&Ve(Gn,{id:"share-panel-tab","aria-controls":"share-panel",variant:"tab",selected:"share"===i,onClick:()=>a("share"),textContent:"Share",children:"Share"}),Ve(Gn,{id:"export-panel-tab","aria-controls":"export-panel",variant:"tab",selected:"export"===i,onClick:()=>a("export"),textContent:"Export",children:"Export"}),Ve(Gn,{id:"import-panel-tab","aria-controls":"import-panel",variant:"tab",selected:"import"===i,onClick:()=>a("import"),
|
|
614
|
-
"aria-labelledby":"export-panel-tab",title:`Export from ${n}`,children:Ve(ug,{})}),Ve(Df,{id:"import-panel",active:"import"===i,"aria-labelledby":"import-panel-tab",title:`Import into ${n}`,children:Ve(mg,{})})]})]})}function vg({onLogin:e}){const t=ji();return Ve("div",{className:"flex flex-col items-center m-6 space-y-6",children:[Ve("span",{className:"text-center",children:["This is a public annotation created with Hypothesis. ",Ve("br",{}),"To reply or make your own annotations on this document,"," ",Ve($n,{variant:"text",href:t.getLink("signup"),target:"_blank",underline:"always",children:"create a free account"})," ","or"," ",Ve(Bn,{inline:!0,variant:"text",onClick:e,underline:"always",children:"log in"}),"."]}),Ve("div",{children:Ve($n,{
|
|
615
|
-
return ji().isLoggedIn()?null:Ve(Nf,{icon:on,title:"Login needed",panelName:"loginPrompt",children:[Ve("p",{children:"Please log in to create annotations or highlights."}),Ve(at,{children:[Ve(dn,{title:"Sign up",onClick:t,children:"Sign up"}),Ve(dn,{title:"Log in",variant:"primary",onClick:e,children:"Log in"})]})]})}const yg=e=>`${e}-tab`,_g=e=>`${e}-panel`;function wg({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i,name:a}){const s=()=>{r||i()},l=t>0?`${o} (${t} available)`:o;return Ve(Bn,{classes:Je("bg-transparent min-w-[5.25rem]",{"font-bold":r}),variant:"text",onClick:s,onMouseDown:s,pressed:!!r,role:"tab",id:yg(a),"aria-controls":_g(a),tabIndex:0,title:l,underline:"none",children:Ve(y,{children:[e,t>0&&!n&&Ve("span",{
|
|
616
|
-
const{rootThread:r,tabCounts:o}=kf(),i=ji(),a=i.selectedTab(),s=o.note,l=o.annotation,c=o.orphan,u=i.isWaitingToAnchorAnnotations(),d=e=>{i.selectTab(e)},h="annotation"===a&&0===l&&!u,p="note"===a&&0===s,m=[];if(l>0){const e=Kf(l,"annotation","annotations");m.push(`${l} ${e}`)}if(s>0){const e=Kf(s,"note","notes");m.push(`${s} ${e}`)}if(c>0){const e=Kf(s,"orphan","orphans");m.push(`${c} ${e}`)}return Ve(y,{children:[Ve("div",{"aria-live":"polite",role:"status",className:"sr-only",children:m.join(", ")}),Ve("div",{className:Je("space-y-3 pb-[9px]"),children:[Ve("div",{className:"flex gap-x-6 theme-clean:ml-[15px] mt-1",role:"tablist",children:[Ve(wg,{count:l,isWaitingToAnchor:u,isSelected:"annotation"===a,label:"Annotations",name:"annotation",onSelect:()=>d("annotation"),children:"Annotations"}),Ve(wg,{count:s,isWaitingToAnchor:u,isSelected:"note"===a,label:"Page notes",
|
|
617
|
-
name:"orphan",onSelect:()=>d("orphan"),children:"Orphans"})]}),Ve("div",{className:"space-y-3",role:"tabpanel",id:_g(a),"aria-labelledby":yg(a),children:["note"===a&&n.enableExperimentalNewNoteButton&&Ve("div",{className:"flex justify-end",children:Ve(dn,{"data-testid":"new-note-button",onClick:()=>e.createPageNote(),variant:"primary",style:Zn(["ctaBackgroundColor"],n),children:[Ve(Zt,{}),"New note"]})}),!t&&p&&Ve(it,{"data-testid":"notes-unavailable-message",variant:"flat",children:Ve(st,{classes:"text-center",children:"There are no page notes in this group."})}),!t&&h&&Ve(it,{"data-testid":"annotations-unavailable-message",variant:"flat",children:Ve(st,{classes:"text-center !space-y-1",children:[Ve("p",{children:"There are no annotations in this group."}),Ve("p",{children:["Create one by selecting some text and clicking the"," ",Ve(lt,{
|
|
618
|
-
;function kg({label:e,icon:t,description:n,active:r,disabled:o=!1,setActive:i,testId:a}){return Ve(dn,{"data-testid":a,classes:Je({"font-medium rounded-lg py-1":!0,"text-grey-7 bg-grey-2":!r,"text-grey-1 bg-grey-7":r,"opacity-50":o}),disabled:o,onClick:()=>i(!r),pressed:r,variant:"custom",title:n,children:[t&&Ve(t,{className:"w-em h-em"}),Ve("span",{className:"max-w-36 truncate",children:e}),Ve("div",{className:Je({"h-[2em] w-[1.5px] -mt-1 -mb-1":!0,"bg-grey-3":!r,"bg-grey-5":r})}),Ve(r?Xt:Zt,{className:"w-em h-em"})]})}function Sg({children:e}){return Ve("div",{className:"mb-3",children:Ve(it,{children:Ve(st,{children:e})})})}function Ag({withCardContainer:e=!1}){const t=ji(),n=t.selectedAnnotations().length,r=n>0,o=t.getFocusActive(),i=t.getFocusFilters(),a=Object.keys(i).length>0;if(!(r||a))return null;return Ve(e?Sg:y,{children:Ve("div",{
|
|
619
|
-
description:`Show ${n} selected annotations`,active:!0,setActive:()=>t.clearSelection(),testId:"selection-toggle"}),i.user&&Ve(kg,{icon:en,label:`By ${i.user.display}`,description:`Show annotations by ${i.user.display}`,active:o.has("user"),disabled:r,setActive:()=>t.toggleFocusMode({key:"user"}),testId:"user-focus-toggle"}),i.page&&Ve(kg,{icon:Mt,label:`Pages ${i.page.display}`,description:`Show annotations on pages ${i.page.display}`,active:o.has("page"),disabled:r,setActive:()=>t.toggleFocusMode({key:"page"}),testId:"page-focus-toggle"}),i.cfi&&Ve(kg,{icon:Mt,label:"Selected chapter",description:"Show annotations on selected book chapter(s)",active:o.has("cfi"),disabled:r,setActive:()=>t.toggleFocusMode({key:"cfi"}),testId:"cfi-focus-toggle"})]})})}var Tg=Jn((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){
|
|
571
|
+
;const t=Rm(e.annotation);return t?.cfi??null}function jm({threads:e}){const[t,n]=ie(0),[r,o]=ie(0);le((()=>{const e=new xe,t=Lm();n(t.clientHeight),o(Pm(t.scrollTop));const r=qi((()=>{n(t.clientHeight),o(Pm(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=ie((()=>new Map)),[s,l]=ie(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h,offscreenThreadsAbove:p}=ue((()=>function(e,t,n,r,o=Ui){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0,h=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?(u+=o,h+=1):c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d,offscreenThreadsAbove:h}}(c,i,r,t)),[c,i,r,t]),m=ue((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=Rm(n.annotation);e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=Dm(i)
|
|
572
|
+
;if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),f=ji(),g=f.profile().userid,v=f.countDrafts()>0,b=f.highlightedAnnotations(),y=f.allAnnotations(),_=(()=>{const e=f.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();se((()=>{_&&(f.setForcedVisible(_,!0),l(_))}),[f,_]);const w=ue((()=>function(e,{highlightedAnnotations:t,currentUserId:n}){if(0===t.length)return null;const r=e.filter((e=>e.id&&t.includes(e.id))).sort(((e,t)=>t.updated===e.updated?0:t.updated>e.updated?1:-1));return(n?r.find((e=>e.mentions&&e.mentions.some((({userid:e})=>e===n)))):null)??r[0]??null}(y,{highlightedAnnotations:b,currentUserId:g})?.id),[y,g,b]);return se((()=>{!v&&w&&l(w)}),[v,w]),se((()=>{if(!s)return;const e=c.findIndex((e=>e.id===s));if(-1===e)return;l(null);const t=c.slice(0,e).reduce(((e,t)=>e+(e=>i.get(e.id)||Ui.defaultHeight)(t)),0);Lm().scrollTop=t}),[s,c,i]),se((()=>{a((e=>{const t=new Map;for(const{id:n}of h){const r=document.getElementById(n)
|
|
573
|
+
;if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=Gi(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Ve("div",{role:"list",children:[Ve("div",{style:{height:d}}),h.map(((t,n)=>Ve("div",{role:"listitem","aria-setsize":e.length,"aria-posinset":p+n+1,className:Je("mb-3"),"data-testid":"thread-card-container",id:t.id,children:[m.get(t)&&Ve("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(t)}),Ve(Om,{thread:t})]},t.id))),Ve("div",{style:{height:u}})]})}const Hm={collapsed:!1,depth:0,visible:!0,replyCount:0};function Fm(e){return e.id||e.$tag}function $m(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||$m(e,t,r.parent))}function Bm(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...Hm,children:[],id:r},Bm(e,r,n.slice(0,-1))),$m(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function qm(e,t){return Object.assign({},t(e),{children:e.children.map((e=>qm(e,t)))})}
|
|
574
|
+
function Um(e,t,n){const r=e.children.map((e=>Um(e,n,n))).slice().sort(t);return{...e,children:r}}function Gm(e,t){const n=e.children.map((e=>Gm(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function Vm(e){return e.children.some((e=>e.visible||Vm(e)))}const Wm=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function Km(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=Fm(e);t[n]={...Hm,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return Bm(t,Fm(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...Hm,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn
|
|
575
|
+
;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=qm(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),o.children=o.children.filter((e=>e.visible||Vm(e))),o=qm(o,(e=>{const n={collapsed:e.collapsed};if(Ir(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&Vm(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=Um(o,t.sortCompareFn,Wm),o=Gm(o,-1),o}function Ym(e){const t=Xm(e),[n,r]=t.split("-",2);return[n,r??n]}function Xm(e){if(!e.includes("["))return e;let t="",n=!1,r=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function Zm(e,t){const n=e=>function(e){const t=Xm(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){
|
|
576
|
+
for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){if(typeof e[n]!=typeof t[n])return"number"==typeof e[n]?-1:1;if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}(n(e),n(t))}function Qm(e,t,n){return Zm(e,t)>=0&&Zm(e,n)<0}function Jm(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e];let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let ef=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function tf(e,t,n){return[e[0]??t,e[1]??n]}function nf(e,t){const n=Jm(e),r=Jm(t);if(!n||!r)return e&&t&&e===t?ef.Overlap:ef.Unknown;const o=2**31,[i,a]=tf(n,1,o),[s,l]=tf(r,1,o);return i<=s?s<=a?ef.Overlap:ef.NoOverlap:i<=l?ef.Overlap:ef.NoOverlap}function rf(e){return function(e){return e.replace(/\p{M}/gu,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class of{constructor(e,t){
|
|
577
|
+
this.term=t.normalize(e),this.matcher=t}matches(e){const t=this.matcher;return t.fieldValues(e).some((e=>t.matches(t.normalize(e),this.term)))}}class af{constructor(e,t){this.operator=e,this.filters=t}matches(e){return"and"===this.operator?this.filters.every((t=>t.matches(e))):this.filters.some((t=>t.matches(e)))}}function sf(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:rf}}const lf={quote:sf((e=>[Kr(e)??Yr(e)??""])),cfi:{fieldValues:e=>[Zr(e)?.trim()??""],matches:(e,t)=>{const[n,r]=Ym(t);return Qm(e,n,r)},normalize:e=>Xm(e.trim())},page:{fieldValues:e=>[Qr(e)?.trim()??""],matches:(e,t)=>nf(e,t)===ef.Overlap,normalize:e=>e.trim()},since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:sf((e=>e.tags)),text:sf((e=>[e.text])),uri:sf((e=>[e.uri])),user:sf((e=>[e.user,e.user_info?.display_name??""]))};function cf(e,t){const n=(e,t)=>new of(t,lf[e]),r=Object.entries(t).filter((([,e])=>e.terms.length>0)).map((([e,t])=>{let r;if("any"===e){
|
|
578
|
+
const e=["quote","text","tag","user"];r=t.terms.map((t=>new af("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new af(t.operator,r)})),o=new af("and",r);return e.filter((e=>o.matches(e)))}const uf=["cfi","quote","page","since","tag","text","uri","user"],df=["group","quote","tag","text","uri","user"];function hf(e,t){const n=e.slice(0,e.indexOf(":"));if(!n)return[null,e];if(t.includes(n)){return[n,e.slice(n.length+1)]}return[null,e]}function pf(e){const t=e.slice(0,1),n=e.slice(-1);return'"'!==t&&"'"!==t||t!==n||(e=e.slice(1,e.length-1)),e}function mf(e,t){const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map(pf).filter((e=>e.length>0)).map((e=>{const[n,r]=hf(e,t);return n?n+":"+pf(r):e})):[]}function ff(e){const t={},n=e=>"tag"===e?"tags":e,r=mf(e,df);for(const e of r){let[r,o]=hf(e,df);r||(r="any",o=e);const i=n(r);t[i]?t[i].push(o):t[i]=[o]}return t}function gf(e){return $r(e)?"orphan":Br(e)?"note":"annotation"}function vf(e){
|
|
579
|
+
return Yi([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function bf(e){return Yi([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}function yf(e,t){const n=e??Number.MIN_SAFE_INTEGER,r=t??Number.MIN_SAFE_INTEGER;return Math.sign(n-r)}function _f(e,t){return e===t?0:e<t?-1:1}function wf(e,t,n){switch(n.sortBy){case"newest":{const n=vf(e);return _f(vf(t),n)}case"oldest":return _f(bf(e),bf(t));case"location":return function(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=Gr(e.annotation),r=Gr(t.annotation);if(n.cfi||r.cfi){const e="/0",t=Zm(n.cfi??e,r.cfi??e);if(0!==t)return Math.sign(t)}const o=yf(n.pageIndex,r.pageIndex);if(0!==o)return o;const i=yf(n.top,r.top);if(0!==i)return i;const a=yf(n.charOffset,r.charOffset);if(0!==a)return a;return _f(e.annotation.created,t.annotation.created)}(e,t);default:return 0}}const xf=function(e){if(1!==e.length)throw new Error("Memoize input must be a function of one argument")
|
|
580
|
+
;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,selected:t.selected,sortCompareFn:(e,n)=>wf(e,n,{sortBy: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=mf(e,uf);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",
|
|
581
|
+
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,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=>cf([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&cf([e.annotation],o).length>0)}const r=Km(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(Hr(e.annotation))return!1;const n=gf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function kf(){
|
|
582
|
+
const e=ji(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=ue((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return xf(s)}var Sf,Af,Tf=Jn((function({loadAnnotationsService:e,onLogin:t}){const n=ji(),r=n.routeParams().id??"",{rootThread:o}=kf(),i=n.profile().userid,[a,s]=ie(!1);return se((()=>{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]),Ve(y,{children:[a&&Ve(Hi,{errorType:"annotation",onLoginRequest:t}),Ve(jm,{threads:o.children})]})}),["loadAnnotationsService"]);class Ef{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.1688.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||r,
|
|
583
|
+
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])}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 Cf=function(){if(Af)return Sf;Af=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){
|
|
584
|
+
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,p=c&&null!=c.leftOffset?c.leftOffset:0,m=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-=p,o-=m,r=e.align.lockX?t.pageXOffset:r,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-=p,o-=m,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),
|
|
585
|
+
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){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 Sf=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||{}
|
|
586
|
+
;var u=s(n),d=1,h=l.validTarget||a,p=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 m=[];u;)if(l.debug&&console.log("Scrolling parent node",u),h(u,d)&&(p?p(u,i):i(u))&&(d++,m.push(u)),!(u=s(u))){f(e);break}return m.reduce(((e,i,a)=>function(e,n,i,a,s){var l,c=!n._scrollSettings,u=n._scrollSettings,d=Date.now(),h={passive:!0};function p(e){n._scrollSettings=null,n.parentElement&&n.parentElement._scrollSettings&&n.parentElement._scrollSettings.end(e),i.debug&&console.log("Scrolling ended with type",e,"for",n),s(e),l&&(n.removeEventListener("touchstart",l,h),n.removeEventListener("wheel",l,h))}u&&u.end(t);var m=i.maxSynchronousAlignments;return null==m&&(m=3),n._scrollSettings={startTime:d,endIterations:0,target:e,time:i.time,ease:i.ease,align:i.align,isWindow:i.isWindow||o,maxSynchronousAlignments:m,end:p,scrollAncestor:a},"cancellable"in i&&!i.cancellable||(l=p.bind(null,t),n.addEventListener("touchstart",l,h),
|
|
587
|
+
n.addEventListener("wheel",l,h)),c&&r(n),l}(n,i,l,m[a+1],f)),null)}function f(e){--d||c&&c(e)}},Sf}(),Mf=Ke(Cf);function Nf({children:e,icon:t,panelName:n,title:r,variant:o="panel",onActiveChanged:i,initialFocus:a}){const s=ji(),l=s.isSidebarPanelOpen(n),c=ce(null),u=ce(l);se((()=>{u.current!==l&&(u.current=l,l&&c.current&&Mf(c.current),i?.(l))}),[l,i]);const d=de((()=>{s.toggleSidebarPanel(n,!1)}),[s,n]);return Ve(y,{children:l&&Ve(yn,{initialFocus:a,restoreFocus:!0,ref:c,classes:"mb-4",title:r,icon:t,onClose:d,transitionComponent:Wn,variant:o,scrollable:!1,children:e})})}function If({commandName:e,icon:t}){return Ve("span",{className:"whitespace-nowrap","data-testid":"instruction",children:[Ve(t,{className:Je("w-em h-em","mx-1 -mt-1","text-color-text-light inline"),"aria-hidden":!0}),Ve("em",{"data-testid":"command-name",children:e})]})}var Of=Jn((function({settings:e}){const t=!Yn(e);return Ve("ol",{className:"list-decimal pl-10 space-y-2",children:[Ve("li",{
|
|
588
|
+
children:["To create an annotation, select text and then select the"," ",Ve(If,{icon:lt,commandName:"Annotate"})," button."]}),Ve("li",{children:["To create a highlight (",Ve($n,{href:"https://web.hypothes.is/help/why-are-highlights-private-by-default/",target:"_blank",underline:"always",children:"visible only to you"}),"), select text and then select the"," ",Ve(If,{icon:jt,commandName:"Highlight"})," button."]}),t&&Ve("li",{children:["To annotate in a private group, select the group from the groups dropdown. Don't see your group? Ask the group creator to send a"," ",Ve($n,{href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",underline:"always",children:"join link"}),"."]}),Ve("li",{children:["To reply to an annotation, select the"," ",Ve(If,{icon:rn,commandName:"Reply"})," button."]})]})}),["settings"]);async function zf(e,t=navigator){await t.clipboard.writeText(e)}function Lf({label:e,children:t,classes:n}){return Ve(y,{children:[Ve("dt",{
|
|
589
|
+
className:"col-span-1 sm:text-right font-medium",children:e}),Ve("dd",{className:Je("col-span-1 sm:col-span-3 text-color-text-light break-words",n),children:t})]})}var Pf=Jn((function({toastMessenger:e,versionData:t}){return Ve("div",{className:"space-y-4",children:[Ve("dl",{className:"grid grid-cols-1 sm:grid-cols-4 sm:gap-x-2",children:[Ve(Lf,{label:"Version",children:t.version}),Ve(Lf,{label:"User Agent",children:t.userAgent}),Ve(Lf,{classes:Je("break-all"),label:"URL",children:t.urls}),Ve(Lf,{label:"Fingerprint",children:t.fingerprint}),t.segment&&Ve(Lf,{label:"Segment",children:t.segment}),Ve(Lf,{label:"Account",children:t.account}),Ve(Lf,{label:"Date",children:t.timestamp})]}),Ve("div",{className:"flex items-center justify-center",children:Ve(dn,{onClick:async()=>{try{await zf(t.asFormattedString()),e.success("Copied version info to clipboard")}catch{e.error("Unable to copy version info")}},icon:_t,children:"Copy version details"})})]})}),["toastMessenger"]);function Rf({children:e,closeTitle:t}){
|
|
590
|
+
return Ve("div",{"data-testid":"tab-header",className:"flex items-center",children:[Ve(fn,{classes:Je("order-last","text-[16px]","text-grey-6 hover:text-grey-7 hover:bg-grey-3/50","touch:!min-h-0"),title:t,variant:"custom",size:"sm"}),Ve(Vn,{classes:"grow gap-x-1 -mb-[1px] z-2",children:e})]})}function Df({children:e,active:t,title:n,...r}){return Ve("div",{role:"tabpanel",...r,className:Je("p-3 focus-visible-ring ring-inset",{hidden:!t}),hidden:!t,children:[n&&Ve(gn,{children:n}),Ve("div",{className:"space-y-3 pt-2",children:e})]})}function jf({linkText:e,url:t}){return Ve("div",{className:"flex-1 flex items-center justify-center border-r last-of-type:border-r-0 text-md font-medium",children:Ve($n,{variant:"text-light",href:t,target:"_blank",underline:"none",children:Ve("div",{className:"flex items-center gap-x-2",children:[Ve("span",{children:e})," ",Ve(Ct,{className:"w-3 h-3"})]})})})}var Hf=Jn((function({session:e}){
|
|
591
|
+
const t=ji(),n=t.frames(),r=t.mainFrame(),o=t.profile(),i=o.user_info?.display_name??zr(o.userid),a=pe(),s=pe(),l=pe(),c=pe(),u=!!t.profile().preferences.show_sidebar_tutorial,[d,h]=ie("tutorial"),p=ue((()=>{const e=[...n].sort(((e,t)=>e===r?-1:t===r?1:0));return new Ef({userid:o.userid,displayName:i},e)}),[o,i,n,r]),m=`https://web.hypothes.is/get-help/?sys_info=${p.asEncodedURLString()}`;return Ve(Nf,{title:"Help",panelName:"help",onActiveChanged:de((t=>{!t&&u&&e.dismissSidebarTutorial()}),[e,u]),variant:"custom",children:[Ve(Rf,{closeTitle:"Close help panel",children:[Ve(Gn,{id:a,"aria-controls":s,variant:"tab",textContent:"Help",selected:"tutorial"===d,onClick:()=>h("tutorial"),"data-testid":"tutorial-tab",children:"Help"}),Ve(Gn,{id:l,"aria-controls":c,variant:"tab",textContent:"Version",selected:"versionInfo"===d,onClick:()=>h("versionInfo"),"data-testid":"version-info-tab",children:"Version"})]}),Ve(it,{classes:Je({"rounded-tl-none":"tutorial"===d}),children:[Ve("div",{className:"border-b",
|
|
592
|
+
children:[Ve(Df,{id:s,"aria-labelledby":a,active:"tutorial"===d,title:"Getting started",children:Ve(Of,{})}),Ve(Df,{id:c,"aria-labelledby":l,active:"versionInfo"===d,title:"Version details",children:Ve(Pf,{versionData:p})})]}),Ve("div",{className:"flex items-center p-3",children:[Ve(jf,{linkText:"Help topics",url:"https://web.hypothes.is/help/"}),Ve(jf,{linkText:"New support ticket",url:m})]})]})]})}),["session"]);class Ff{#e=[];destroy(){this.#e=[]}on(e,t){this.#e.push({name:e,callback:t})}off(e,t){this.#e=this.#e.filter((n=>!(n.name===e&&n.callback===t)))}emit(e,...t){for(const n of this.#e){if(n.name!==e)continue;(0,n.callback)(...t)}}}class $f extends Error{constructor(e){super(`Results size exceeds ${e}`)}}function Bf(e){return 0===e?50:200}class qf extends Ff{constructor(e,{getPageSize:t=Bf,separateReplies:n=!0,incremental:r=!0,maxResults:o=null,sortBy:i="created",sortOrder:a="asc"}={}){super(),this._searchFn=e,this._getPageSize=t,this._separateReplies=n,this._incremental=r,this._maxResults=o,
|
|
593
|
+
this._sortBy=i,this._sortOrder=a,this._canceled=!1,this._expectedCount=null,this._fetchedCount=0,this._results=[]}async _getPage(e,t,n=0){const r={limit:this._getPageSize(n),sort:this._sortBy,order:this._sortOrder,_separate_replies:this._separateReplies,...e};t&&(r.search_after=t);try{const t=await this._searchFn(r);if(this._canceled)return;if(null===this._expectedCount&&(this._expectedCount=t.total,this.emit("resultCount",this._expectedCount)),this._maxResults&&t.total>this._maxResults)return this.emit("error",new $f(this._maxResults)),void this.emit("end");const o=t.rows.concat(t.replies||[]);this._incremental?this.emit("results",o):this._results=this._results.concat(o),this._fetchedCount+=o.length;const i=this._fetchedCount<this._expectedCount||this._expectedCount>1e3;let a=null;o.length>0&&i&&(a=o[o.length-1][this._sortBy]),a?this._getPage(e,a,n+1):(this._incremental||this.emit("results",this._results),this.emit("end"))}catch(e){if(this._canceled)return;this.emit("error",e),this.emit("end")}}get(e){
|
|
594
|
+
this._expectedCount=null,this._fetchedCount=0,this._results=[],this._getPage(e)}cancel(){this._canceled=!0,this.emit("end")}}function Uf({defaultOption:e,icon:t,onSelect:n,options:r,selectedOption:o,title:i}){const a=[e,...r],s=o??e,l=Ve("span",{className:Je("shrink-0 flex items-center gap-x-2","text-color-text font-bold text-md"),children:[t&&Ve(t,{className:"w-4 h-4"}),s.display]});return Ve(fm,{label:l,title:i,contentClass:Je("max-h-[min(60vh,504px)] overflow-y-auto"),children:a.map((e=>Ve(vm,{onClick:()=>n(e),isSelected:e.value===s.value,label:e.display},e.value)))})}function Gf(){const e=ji(),t=e.getFilter("user"),n=function(){const e=ji(),t=e.allAnnotations(),n=e.getFocusFilters(),r=zr(e.profile().userid),o=e.defaultAuthority(),i=e.isFeatureEnabled("client_display_names");return ue((()=>{const e={};if(t.forEach((t=>{const n=zr(t.user);e[n]=Xi(t,o,i)})),n.user){const t=zr(n.user.value)||n.user.value;e[t]=n.user.display}const a=Object.keys(e).map((t=>({display:t===r?`${e[t]} (Me)`:e[t],value:t})))
|
|
595
|
+
;return a.sort(((e,t)=>r===e.value?-1:r===t.value?1:e.display.localeCompare(t.display))),a}),[t,r,o,i,n.user])}();return Ve(Uf,{defaultOption:{value:"",display:"Everybody"},icon:en,onSelect:t=>e.setFilter("user",t),options:n,selectedOption:t,title:"Filter by user"})}function Vf({forcedVisibleCount:e,isFiltered:t,isLoading:n,resultCount:r}){const{rootThread:o}=kf(),i=n?r:Ki(o),a=o.children.length>0,s=t&&e>0,l=i-e,c=o.children.length;return Ve("div",{className:"flex gap-x-1 leading-none",children:[n&&Ve(Rn,{size:"sm"}),!n&&Ve("h2",{className:"font-bold",children:[!a&&Ve("span",{children:"No results"}),a&&t&&Ve("span",{children:[l," ",1===l?"result":"results"]}),a&&!t&&Ve("span",{children:[c," ",1===c?"thread":"threads"]})]}),s&&Ve("h3",{className:"italic font-normal",children:["(and ",e," more)"]}),!t&&a&&Ve("h3",{className:"italic font-normal",children:["(",i," ",1===i?"annotation":"annotations",")"]})]})}function Wf({currentPage:e,isLoading:t,onChangePage:n,threads:r,pageSize:o=25}){
|
|
596
|
+
const{paginatedThreads:i,totalPages:a}=ue((()=>{const t=r.filter((e=>Ki(e)>0)),n=(e-1)*o,i=n+o,a=Math.ceil(t.length/o);return{paginatedThreads:t.slice(n,i),totalPages:a}}),[r,e,o]);return Ve(y,{children:[Ve(jm,{threads:i}),!t&&Ve(Un,{currentPage:e,onChangePage:n,totalPages:a})]})}function Kf(e,t,n){return 1===e?t:n}const Yf={alt:1,ctrl:2,meta:4,shift:8};function Xf(e,t,{rootElement:n=document.documentElement??void 0}={}){const r=n=>{(function(e,t){if(!(e instanceof KeyboardEvent))return!1;const n=t.split("+").map((e=>e.toLowerCase()));let r=0,o=null;for(const e of n){const t=Yf[e];if(t)r|=t;else{if(null!==o)throw new Error("Multiple non-modifier keys specified");o=e}}if(!o)throw new Error(`Invalid shortcut: ${t}`);return((e.ctrlKey?Yf.ctrl:0)|(e.metaKey?Yf.meta:0)|(e.altKey?Yf.alt:0)|(e.shiftKey?Yf.shift:0))===r&&e.key.toLowerCase()===o})(n,e)&&t(n)};return n?(n.addEventListener("keydown",r),()=>n.removeEventListener("keydown",r)):()=>{}}function Zf(e,t,{rootElement:n}={}){se((()=>{if(e)return Xf(e,t,{
|
|
597
|
+
rootElement:n})}),[e,t,n])}function Qf({hidden:e,children:t}){return Ve("span",{className:Je("group-hover:inline group-focus:inline",{hidden:e}),children:t})}function Jf({type:e,collapsed:t,count:n}){const r="updates"===e?"update":"mention",o="updates"===e?"updates":"mentions",i="updates"===e?wt:Wt;return Ve("div",{className:Je("flex gap-1.5 items-center px-2 py-1","border-l first:border-l-0 border-white/60"),children:[Ve(i,{className:"w-em h-em"}),Ve("div",{className:"flex gap-1",children:[Ve("span",{className:"font-bold",children:n}),Ve(Qf,{hidden:t,children:Kf(n,r,o)})]})]})}var eg=Jn((function({streamer:e,analytics:t,setTimeout_:n=setTimeout,clearTimeout_:r=clearTimeout}){const o=ji(),i=o.pendingUpdateCount(),a=o.pendingMentionCount(),s=o.isFeatureEnabled("at_mentions"),l=o.hasPendingUpdatesOrDeletions(),c=de((()=>{e.applyPendingUpdates(),t.trackEvent("client.realtime.apply_updates")}),[t,e]),[u,d]=ie(!1),h=ce(null);return Zf("l",(()=>l&&c())),se((()=>(l?h.current=n((()=>{d(!0),h.current=null
|
|
598
|
+
}),5e3):d(!1),()=>h.current&&r(h.current))),[r,l,n]),l?Ve("div",{role:"status",className:"absolute right-0 animate-updates-notification-slide-in",children:Ve(dn,{onClick:c,unstyled:!0,classes:Je("flex items-center","rounded shadow-lg bg-gray-900 text-white","group focus-visible-ring"),"data-testid":"notification","data-collapsed":u,children:[Ve(Jf,{type:"updates",collapsed:u,count:i}),s&&a>0&&Ve(Jf,{type:"mentions",collapsed:u,count:a}),Ve("span",{className:"sr-only",children:"load them by pressing l"})]})}):null}),["streamer","analytics"]);var tg=Jn((function({loadAnnotationsService:e,streamer:t}){const n=ji(),r=n.getFilterValues(),o=n.focusedGroup(),i=n.forcedVisibleThreads().length,a=n.hasAppliedFilter(),s=n.isLoading(),l=n.annotationResultCount(),{rootThread:c}=kf(),u=o?.name??"…",d=o?.id||n.directLinkedGroupId(),h=ce(1),[p,m]=ie(1),[f,g]=ie(!1),v=e=>{e instanceof $f&&g(!0)},b=n.hasFetchedProfile();se((()=>{b&&t.connect({applyUpdatesImmediately:!1})}),[b,t]),se((()=>{n.setSortKey("newest"),d&&e.load({
|
|
599
|
+
groupId:d,sortBy:"updated",sortOrder:"desc",maxResults:5e3,onError:v,streamFilterBy:"group"})}),[e,d,n]);const y=e=>{m(e)};se((()=>{y(1)}),[r,o]);const _=ce(null);return le((()=>{p!==h.current&&(_.current&&Mf(_.current),h.current=p)}),[p]),Ve("div",{className:"grid gap-2 lg:grid-cols-2","data-testid":"notebook-container",children:[Ve("header",{className:"leading-none lg:col-span-2",ref:_,children:Ve("h1",{className:"text-xl font-bold","data-testid":"notebook-group-name",children:u})}),Ve("div",{className:"absolute w-full z-5 left-0 lg:top-8 top-5",children:Ve("div",{className:Je("container flex flex-row-reverse relative","right-[4rem]"),children:Ve(eg,{})})}),Ve("div",{className:"justify-self-start",children:Ve(Gf,{})}),Ve("div",{className:"flex items-center lg:justify-self-end text-md font-medium",children:Ve(Vf,{forcedVisibleCount:i,isFiltered:a,isLoading:s,resultCount:l??0})}),Ve("div",{className:"lg:col-span-2",children:[f&&Ve("div",{className:"py-4","data-testid":"notebook-messages",children:Ve(bn,{
|
|
600
|
+
title:"Too many results to show",children:[Ve("p",{children:["This preview of the Notebook can show"," ",Ve("strong",{children:["up to ",5e3," results"]})," at a time (there are"," ",l," to show here)."]}),Ve("p",{children:[Ve($n,{href:"mailto:support@hypothes.is?subject=Hypothesis%20Notebook&body=Please%20notify%20me%20when%20the%20Hypothesis%20Notebook%20is%20updated%20to%20support%20more%20than%205000%20annotations",underline:"always",children:"Contact us"})," ","if you would like to be notified when support for more annotations is available."]})]})}),Ve(Wf,{currentPage:p,isLoading:s,onChangePage:y,threads:c.children})]})]})}),["loadAnnotationsService","streamer"]);function ng({classes:e,children:t,onClose:n=(()=>{}),...r}){return Ve("div",{className:Je("flex items-center gap-x-1 py-1 px-2 rounded","bg-green-success/10 animate-pulse-fade-out",e),onAnimationEnd:n,...r,children:[Ve(gt,{className:"text-green-success w-em h-em p-[0.125em]"}),Ve("div",{className:"text-sm",children:t})]})}function rg(){
|
|
601
|
+
const e=ji(),[t,n]=ie(!1),[r,o]=ie(0);if(se((()=>{let e;return t&&(e=setTimeout((()=>{n(!1),o((e=>e+1))}),1e3)),()=>{clearTimeout(e)}}),[t]),!e.isFeatureEnabled("client_user_profile"))return null;const i=r>0&&!t;return Ve(it,{"data-testid":"profile-container",classes:"overflow-hidden",children:[Ve("div",{className:Je("h-12","px-3 border-b flex items-center"),children:[Ve("div",{className:"grow",children:Ve("h1",{className:"text-xl text-slate-7 font-normal",children:"Notifications"})}),Ve("ul",{className:"sr-only","aria-live":"polite",children:i&&Ve("li",{children:"Notification preferences saved"},r)}),r>0&&Ve(ng,{onClose:()=>o(0),children:"Saved"},r)]}),Ve(ot,{children:Ve(st,{size:"lg",children:Ve(kn,{defaultChecked:!0,disabled:t,onChange:()=>n(!0),checkedIcon:t?cn:void 0,icon:t?cn:void 0,children:"Email me a daily summary of activity in my courses"})})})]})}function og({annotations:e,getDisplayName:t,excludeReplies:n=!1}){const r=new Map;for(const o of e){if(n&&Pr(o))continue;let e=r.get(o.user);e||(e={
|
|
602
|
+
userid:o.user,displayName:t(o),annotations:[]},r.set(o.user,e)),e.annotations.push(o)}const o=[...r.values()];return o.sort(((e,t)=>e.displayName.localeCompare(t.displayName))),o}function ig(e){return`${e.getFullYear()}-${`${e.getMonth()+1}`.padStart(2,"0")}-${`${e.getDate()}`.padStart(2,"0")}`}function ag({documentMetadata:e,groupName:t,date:n=new Date}){const r=[ig(n)];return e?.title?r.push(function(e,t){const n=Array.from(e);return n.length<=t?e:n.slice(0,t).join("")}(e.title,50)):r.push("Hypothesis"),t&&r.push(t.replace(/ /g,"-")),r.join("-")}function sg(){return Ve("div",{className:"flex flex-row items-center justify-center","data-testid":"loading-spinner",children:Ve(Rn,{size:"md"})})}function lg({userAnnotations:e}){return Ve("div",{className:"flex gap-x-2",children:[e.displayName,Ve("div",{className:"rounded px-1 bg-grey-7 text-white",children:e.annotations.length})]})}const cg=[{value:"json",title:"JSON",description:"For import into another Hypothesis group or document"},{value:"txt",
|
|
603
|
+
title:"Plain text (TXT)",shortTitle:"Text",description:"For import into word processors as plain text"},{value:"html",title:"Rich text (HTML)",shortTitle:"HTML",description:"For import into word processors as rich text"},{value:"csv",title:"Table (CSV)",shortTitle:"CSV",description:"For import into a spreadsheet"}];var ug=Jn((function({annotationsExporter:e,toastMessenger:t}){const n=ji(),r=n.focusedGroup(),o=r&&!n.isLoading(),i=n.defaultContentFrame(),a=n.savedAnnotations(),s=n.defaultAuthority(),l=n.isFeatureEnabled("client_display_names"),c=de((e=>Xi(e,s,l)),[s,l]),u=ue((()=>og({annotations:a,getDisplayName:c})),[a,c]),d=n.profile(),h=d.userid,p=ue((()=>({annotations:a,displayName:"All annotations"})),[a]),[m,f]=ie(h),g=ue((()=>u.find((e=>e.userid===m))??p),[p,m,u]),[v,b]=ie(cg[0]),_=pe(),w=pe(),x=n.countDrafts(),k=ue((()=>ag({documentMetadata:i?.metadata,groupName:r?.name})),[i,r]),[S,A]=ie(),T=de(((t,n)=>{const o=g?.annotations??a;switch(t){case"json":{const t=e.buildJSONExportContent(o,{profile:d})
|
|
604
|
+
;return JSON.stringify(t,null,2)}case"txt":return e.buildTextExportContent(o,{groupName:r?.name,defaultAuthority:s,displayNamesEnabled:l});case"csv":return e.buildCSVExportContent(o,{separator:"file"===n?",":"\t",groupName:r?.name,defaultAuthority:s,displayNamesEnabled:l});case"html":return e.buildHTMLExportContent(o,{groupName:r?.name,defaultAuthority:s,displayNamesEnabled:l});default:throw new Error(`Invalid format: ${t}`)}}),[e,s,l,a,r?.name,d,g?.annotations]),E=de((e=>{e.preventDefault();try{const e=v.value,t=`${S??k}.${e}`,n=T(e,"file"),r=function(e){return{json:"application/json",txt:"text/plain",csv:"text/csv",html:"text/html"}[e]}(e);!function(e,t,n,r=document){const o=new Blob([e],{type:t}),i=URL.createObjectURL(o),a=r.createElement("a");a.setAttribute("href",i),a.setAttribute("download",n),a.style.visibility="hidden",r.body.appendChild(a),a.click(),r.body.removeChild(a),URL.revokeObjectURL(i)}(n,r,t)}catch(e){t.error(`Exporting annotations failed: ${e.message}`,{autoDismiss:!1})}
|
|
605
|
+
}),[T,S,k,v.value,t]),C=de((async()=>{const e=v.value,n=T(e,"clipboard");try{"html"===e?await async function(e,t=navigator,n=document){const r=["text/html","text/plain"];if(t.clipboard.write){const n=r.reduce(((t,n)=>(t[n]=new Blob([e],{type:n}),t)),{});await t.clipboard.write([new ClipboardItem(n)])}else{const t=t=>{r.forEach((n=>t.clipboardData?.setData(n,e))),t.preventDefault()};n.addEventListener("copy",t);try{n.execCommand("copy")}finally{n.removeEventListener("copy",t)}}}(n):await zf(n),t.success("Annotations copied")}catch(e){t.error(`Copying annotations failed: ${e.message}`,{autoDismiss:!1})}}),[T,v.value,t]);return o?Ve("form",{className:"space-y-3",onSubmit:E,"data-testid":"export-form",children:[a.length>0?Ve(y,{children:[Ve("p",{className:"text-color-text-light",children:[Ve($n,{variant:"text-light",underline:"always",href:"https://web.hypothes.is/help/exporting-and-importing-annotations-in-the-hypothesis-web-app/",target:"_blank",children:"Learn more"
|
|
606
|
+
})," ","about copying and exporting annotations."]}),Ve("div",{className:"flex flex-col gap-y-3",children:[Ve("label",{htmlFor:w,className:"font-medium",children:["Select which user","'","s annotations to export:"]}),Ve(Pn,{value:m,onChange:f,buttonId:w,buttonContent:Ve(lg,{userAnnotations:g}),"data-testid":"user-select",children:[Ve(Pn.Option,{value:void 0,children:Ve(lg,{userAnnotations:p})}),u.map((e=>Ve(Pn.Option,{value:e.userid,children:Ve(lg,{userAnnotations:e})},e.userid)))]}),Ve("label",{"data-testid":"export-count",htmlFor:_,className:"font-medium",children:"Name of export file:"}),Ve("div",{className:"flex",children:[Ve(An,{classes:"grow","data-testid":"export-filename",id:_,defaultValue:k,value:S,onChange:e=>A(e.target.value),required:!0,maxLength:250}),Ve("div",{className:"grow-0 ml-2 min-w-[5rem]",children:Ve(Pn,{"aria-label":"Export format",value:v,onChange:b,buttonContent:v.shortTitle??v.title,"data-testid":"export-format-select",alignListbox:"right",listboxOverflow:"wrap",
|
|
607
|
+
children:cg.map((e=>Ve(Pn.Option,{value:e,children:Ve("div",{className:"flex-col gap-y-2",children:[Ve("div",{className:"font-bold","data-testid":"format-name",children:e.title}),Ve("div",{"data-testid":"format-description",children:e.description})]})},e.value)))})})]})]})]}):Ve("p",{"data-testid":"no-annotations-message",children:"There are no annotations available for export."}),x>0&&Ve("p",{"data-testid":"drafts-message",children:["You have ",x," unsaved"," ",Kf(x,"draft","drafts"),a.length>0&&Ve(y,{children:" that will not be included"}),"."]}),Ve(at,{children:[Ve(dn,{"data-testid":"copy-button",icon:_t,onClick:C,disabled:0===a.length,children:"Copy to clipboard"}),Ve(dn,{"data-testid":"export-button",variant:"primary",disabled:0===a.length,type:"submit",children:"Export"})]})]}):Ve(sg,{})}),["annotationsExporter","toastMessenger"]);function dg(e,t=new FileReader){const{promise:n,resolve:r,reject:o}=function(){let e,t;return{promise:new Promise(((n,r)=>{e=n,t=r})),resolve:e,reject:t}}()
|
|
608
|
+
;return t.addEventListener("loadend",(e=>{try{const t=e.target?.result?.toString()??"",n=JSON.parse(t);r(n)}catch(e){o(e)}})),t.readAsText(e),n}function hg({size:e,value:t}){const n=e-4,r=Math.PI*n;return Ve("span",{className:"text-grey-3",role:"progressbar","aria-valuenow":t,style:{width:`${e}px`,height:`${e}px`,transform:"rotate(-90deg)"},children:Ve("svg",{viewBox:`0 0 ${e} ${e}`,children:Ve("circle",{cx:e/2,cy:e/2,r:n/2,fill:"none",stroke:"currentColor","stroke-width":2,style:{strokeDasharray:r,strokeDashoffset:r-r*(t/100)+"px",transitionDuration:"300ms",transitionProperty:"stroke-dashoffset"}})})})}function pg({onFileSelected:e,disabled:t,id:n}){const r=ce(null),[o,i]=ie(null);return Ve(dn,{variant:"custom",classes:Je("w-full relative overflow-hidden border rounded","bg-grey-0 hover:bg-grey-0"),title:o?`${o}, Select a file`:"Select a file",onClick:()=>r.current?.click(),disabled:t,"data-testid":"file-input-proxy-button",children:[Ve("input",{ref:r,accept:".json",id:n,type:"file",disabled:t,
|
|
609
|
+
className:"invisible absolute w-0 h-0","aria-hidden":!0,"data-testid":"file-input",onChange:t=>{const n=t.target.files;i(n?.[0]?.name??null),null!==n&&n.length>0&&e(n[0])}}),Ve("div",{className:"max-w-full pr-10 truncate","data-testid":"filename-container",children:o??"Select a file"}),Ve("div",{className:"absolute right-0 h-full p-2 border-l bg-grey-2",children:Ve(Mt,{})})]})}var mg=Jn((function({importAnnotationsService:e}){const[t,n]=ie(null),[r,o]=ie(null),[i,a]=ie(null),s=ji(),l=s.profile().userid,c=s.defaultAuthority(),u=s.isFeatureEnabled("client_display_names"),d=de((e=>Xi(e,c,u)),[c,u]),h=ue((()=>r?og({annotations:r,getDisplayName:d,excludeReplies:!0}):null),[r,d]),[p,m]=ie(null),f=ue((()=>h?.find((e=>e.userid===p))??null),[p,h]);let g;se((()=>{l&&t&&(o(null),a(null),m(null),async function(e){let t;try{t=await dg(e)}catch{throw new Error("Not a valid JSON file")}if(null===(n=t)||"object"!=typeof n||!Array.isArray(t.annotations))throw new Error("Not a valid Hypothesis JSON file");var n
|
|
610
|
+
;return t.annotations}(t).then((e=>{o(e);const t=e.some((e=>e.user===l));m(t?l:null)})).catch((e=>{a(e.message)})))}),[l,t]),f&&(g=async()=>{e.import(f.annotations)});const v=pe(),b=pe();if(!l)return Ve("p",{"data-testid":"log-in-message",children:"You must log in to import annotations."});const _=Boolean(s.focusedGroup()&&s.defaultContentFrame()&&s.hasFetchedAnnotations()&&!s.isFetchingAnnotations()&&g),w=t&&!r&&!i,x=s.importsPending(),k=s.importsTotal(),S=k-x,A=w||x>0,T=x>0?Math.round(S/k*100):null;return Ve(y,{children:[Ve("p",{className:"text-color-text-light mb-3",children:[Ve($n,{variant:"text-light",underline:"always",href:"https://web.hypothes.is/help/exporting-and-importing-annotations/",target:"_blank",children:"Learn more"})," ","about importing annotations."]}),Ve("label",{htmlFor:v,className:"font-medium",children:"Select Hypothesis export file:"}),Ve(pg,{onFileSelected:n,disabled:A,id:v}),h&&Ve(y,{children:[Ve("label",{htmlFor:b,className:"block font-medium",
|
|
611
|
+
children:"Select which user's annotations to import:"}),Ve(Pn,{value:f,onChange:e=>m(e?.userid??null),buttonId:b,buttonContent:f?Ve(lg,{userAnnotations:f}):Ve("span",{className:"text-grey-6",children:"Select a user..."}),children:h.map((e=>Ve(Pn.Option,{value:e,children:Ve(lg,{userAnnotations:e})},e.userid)))})]}),i&&Ve("p",{"data-testid":"error-info",children:[Ve("b",{children:"Unable to find annotations to import:"})," ",i]}),Ve(at,{children:[null!==T&&Ve("span",{"data-testid":"progress-text",className:"text-grey-6",children:[T,"% complete"]}),Ve(dn,{"data-testid":"import-button",disabled:!_||A,onClick:g,variant:"primary",children:[null!==T&&Ve(hg,{size:22,value:T}),"Import"]})]})]})}),["importAnnotationsService"]);var fg=Jn((function({toastMessenger:e}){const t=ji(),n=t.mainFrame(),r=t.focusedGroup(),o=r&&n,i=o&&(a=n.uri,s=r.id,/^http(s?):/i.test(a)?`https://hyp.is/go?url=${encodeURIComponent(a)}&group=${s}`:null);var a,s;const l=de((async()=>{try{i&&(await zf(i),
|
|
612
|
+
e.success("Copied share link to clipboard"))}catch{e.error("Unable to copy link")}}),[i,e]);return o?Ve("div",{className:"text-color-text-light space-y-3",children:i?Ve(y,{children:[Ve("div",{className:"text-color-text font-medium","data-testid":"sharing-intro",children:"private"===r.type?Ve("p",{children:"Use this link to share these annotations with other group members:"}):Ve("p",{children:"Use this link to share these annotations with anyone:"})}),Ve("div",{children:Ve(pn,{children:[Ve(An,{"aria-label":"Use this URL to share these annotations",type:"text",value:i,readOnly:!0}),Ve(mn,{icon:_t,onClick:l,title:"Copy share link",variant:"dark"})]})}),Ve("p",{"data-testid":"sharing-details",children:["private"===r.type?Ve("span",{children:["Annotations in the private group ",Ve("em",{children:r.name})," ","are only visible to group members."]}):Ve("span",{children:["Anyone using this link may view the annotations in the group"," ",Ve("em",{children:r.name}),"."]})," ",Ve("span",{children:["Private (",Ve(Gt,{
|
|
613
|
+
className:"inline w-[14px] h-[14px] -mt-0.5"})," ",Ve("em",{children:"Only Me"}),") annotations are only visible to you."]})]})]}):Ve("p",{"data-testid":"no-sharing",children:"These annotations cannot be shared because this document is not available on the web."})}):Ve(sg,{})}),["toastMessenger"]);function gg({shareTab:e}){const t=ji().focusedGroup(),n=t&&t.name||"...",r=`Share Annotations in ${n}`,o=e?"share":"export",[i,a]=ie(o),s=i===o;return Ve(Nf,{title:r,panelName:"shareGroupAnnotations",variant:"custom",children:[Ve(Rf,{closeTitle:"Close share panel",children:[e&&Ve(Gn,{id:"share-panel-tab","aria-controls":"share-panel",variant:"tab",selected:"share"===i,onClick:()=>a("share"),textContent:"Share",children:"Share"}),Ve(Gn,{id:"export-panel-tab","aria-controls":"export-panel",variant:"tab",selected:"export"===i,onClick:()=>a("export"),textContent:"Export",children:"Export"}),Ve(Gn,{id:"import-panel-tab","aria-controls":"import-panel",variant:"tab",selected:"import"===i,onClick:()=>a("import"),
|
|
614
|
+
textContent:"Import",children:"Import"})]}),Ve(it,{classes:Je({"rounded-tl-none":s}),children:[Ve(Df,{id:"share-panel",active:"share"===i,"aria-labelledby":"share-panel-tab",title:r,children:Ve(fg,{})}),Ve(Df,{id:"export-panel",active:"export"===i,"aria-labelledby":"export-panel-tab",title:`Export from ${n}`,children:Ve(ug,{})}),Ve(Df,{id:"import-panel",active:"import"===i,"aria-labelledby":"import-panel-tab",title:`Import into ${n}`,children:Ve(mg,{})})]})]})}function vg({onLogin:e}){const t=ji();return Ve("div",{className:"flex flex-col items-center m-6 space-y-6",children:[Ve("span",{className:"text-center",children:["This is a public annotation created with Hypothesis. ",Ve("br",{}),"To reply or make your own annotations on this document,"," ",Ve($n,{variant:"text",href:t.getLink("signup"),target:"_blank",underline:"always",children:"create a free account"})," ","or"," ",Ve(Bn,{inline:!0,variant:"text",onClick:e,underline:"always",children:"log in"}),"."]}),Ve("div",{children:Ve($n,{
|
|
615
|
+
href:"https://hypothes.is","aria-label":"Hypothesis homepage",target:"_blank",title:"Hypothesis homepage",underline:"none",variant:"custom",children:Ve(Vt,{className:"w-16 h-16 text-grey-7"})})})]})}function bg({onLogin:e,onSignUp:t}){return ji().isLoggedIn()?null:Ve(Nf,{icon:on,title:"Login needed",panelName:"loginPrompt",children:[Ve("p",{children:"Please log in to create annotations or highlights."}),Ve(at,{children:[Ve(dn,{title:"Sign up",onClick:t,children:"Sign up"}),Ve(dn,{title:"Log in",variant:"primary",onClick:e,children:"Log in"})]})]})}const yg=e=>`${e}-tab`,_g=e=>`${e}-panel`;function wg({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i,name:a}){const s=()=>{r||i()},l=t>0?`${o} (${t} available)`:o;return Ve(Bn,{classes:Je("bg-transparent min-w-[5.25rem]",{"font-bold":r}),variant:"text",onClick:s,onMouseDown:s,pressed:!!r,role:"tab",id:yg(a),"aria-controls":_g(a),tabIndex:0,title:l,underline:"none",children:Ve(y,{children:[e,t>0&&!n&&Ve("span",{
|
|
616
|
+
className:"relative bottom-[3px] left-[2px] text-[10px]",children:t})]})})}var xg=Jn((function({annotationsService:e,isLoading:t,settings:n}){const{rootThread:r,tabCounts:o}=kf(),i=ji(),a=i.selectedTab(),s=o.note,l=o.annotation,c=o.orphan,u=i.isWaitingToAnchorAnnotations(),d=e=>{i.selectTab(e)},h="annotation"===a&&0===l&&!u,p="note"===a&&0===s,m=[];if(l>0){const e=Kf(l,"annotation","annotations");m.push(`${l} ${e}`)}if(s>0){const e=Kf(s,"note","notes");m.push(`${s} ${e}`)}if(c>0){const e=Kf(s,"orphan","orphans");m.push(`${c} ${e}`)}return Ve(y,{children:[Ve("div",{"aria-live":"polite",role:"status",className:"sr-only",children:m.join(", ")}),Ve("div",{className:Je("space-y-3 pb-[9px]"),children:[Ve("div",{className:"flex gap-x-6 theme-clean:ml-[15px] mt-1",role:"tablist",children:[Ve(wg,{count:l,isWaitingToAnchor:u,isSelected:"annotation"===a,label:"Annotations",name:"annotation",onSelect:()=>d("annotation"),children:"Annotations"}),Ve(wg,{count:s,isWaitingToAnchor:u,isSelected:"note"===a,label:"Page notes",
|
|
617
|
+
name:"note",onSelect:()=>d("note"),children:"Page Notes"}),c>0&&Ve(wg,{count:c,isWaitingToAnchor:u,isSelected:"orphan"===a,label:"Orphans",name:"orphan",onSelect:()=>d("orphan"),children:"Orphans"})]}),Ve("div",{className:"space-y-3",role:"tabpanel",id:_g(a),"aria-labelledby":yg(a),children:["note"===a&&n.enableExperimentalNewNoteButton&&Ve("div",{className:"flex justify-end",children:Ve(dn,{"data-testid":"new-note-button",onClick:()=>e.createPageNote(),variant:"primary",style:Zn(["ctaBackgroundColor"],n),children:[Ve(Zt,{}),"New note"]})}),!t&&p&&Ve(it,{"data-testid":"notes-unavailable-message",variant:"flat",children:Ve(st,{classes:"text-center",children:"There are no page notes in this group."})}),!t&&h&&Ve(it,{"data-testid":"annotations-unavailable-message",variant:"flat",children:Ve(st,{classes:"text-center !space-y-1",children:[Ve("p",{children:"There are no annotations in this group."}),Ve("p",{children:["Create one by selecting some text and clicking the"," ",Ve(lt,{
|
|
618
|
+
className:"w-em h-em inline m-0.5 -mt-0.5",title:"Annotate"})," ","button."]})]})}),Ve(jm,{threads:r.children})]})]})]})}),["annotationsService","settings"]);function kg({label:e,icon:t,description:n,active:r,disabled:o=!1,setActive:i,testId:a}){return Ve(dn,{"data-testid":a,classes:Je({"font-medium rounded-lg py-1":!0,"text-grey-7 bg-grey-2":!r,"text-grey-1 bg-grey-7":r,"opacity-50":o}),disabled:o,onClick:()=>i(!r),pressed:r,variant:"custom",title:n,children:[t&&Ve(t,{className:"w-em h-em"}),Ve("span",{className:"max-w-36 truncate",children:e}),Ve("div",{className:Je({"h-[2em] w-[1.5px] -mt-1 -mb-1":!0,"bg-grey-3":!r,"bg-grey-5":r})}),Ve(r?Xt:Zt,{className:"w-em h-em"})]})}function Sg({children:e}){return Ve("div",{className:"mb-3",children:Ve(it,{children:Ve(st,{children:e})})})}function Ag({withCardContainer:e=!1}){const t=ji(),n=t.selectedAnnotations().length,r=n>0,o=t.getFocusActive(),i=t.getFocusFilters(),a=Object.keys(i).length>0;if(!(r||a))return null;return Ve(e?Sg:y,{children:Ve("div",{
|
|
619
|
+
className:"flex flex-row flex-wrap gap-2 items-center","data-testid":"filter-controls",children:[Ve("b",{children:"Filters"}),r&&Ve(kg,{label:`${n} selected`,description:`Show ${n} selected annotations`,active:!0,setActive:()=>t.clearSelection(),testId:"selection-toggle"}),i.user&&Ve(kg,{icon:en,label:`By ${i.user.display}`,description:`Show annotations by ${i.user.display}`,active:o.has("user"),disabled:r,setActive:()=>t.toggleFocusMode({key:"user"}),testId:"user-focus-toggle"}),i.page&&Ve(kg,{icon:Mt,label:`Pages ${i.page.display}`,description:`Show annotations on pages ${i.page.display}`,active:o.has("page"),disabled:r,setActive:()=>t.toggleFocusMode({key:"page"}),testId:"page-focus-toggle"}),i.cfi&&Ve(kg,{icon:Mt,label:"Selected chapter",description:"Show annotations on selected book chapter(s)",active:o.has("cfi"),disabled:r,setActive:()=>t.toggleFocusMode({key:"cfi"}),testId:"cfi-focus-toggle"})]})})}var Tg=Jn((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){
|
|
620
620
|
const i=ji(),a=i.focusedGroupId(),s=i.isLoading(),l=i.isLoggedIn(),c=i.directLinkedAnnotationId(),u=c?i.findAnnotationByID(c):void 0,d=u?gf(u):"annotation",h=i.searchUris(),p=i.hasSidebarOpened(),m=i.profile().userid,f=!(s||!c)&&!u,g=i.directLinkedGroupFetchFailed(),v=f||g,b=i.isSidebarPanelOpen("searchAnnotations"),y=!v&&!b,_=c&&!l&&!f&&!s,w=ce(a);se((()=>{if(!w.current||w.current!==a){if(w.current){const e=i.focusState().active;i.clearSelection(),e&&i.toggleFocusMode({active:!0})}w.current=a}a&&h.length&&r.load({groupId:a,uris:h})}),[i,r,a,m,h]),se((()=>{u&&!1===u.$orphan?(e.hoverAnnotation(u),e.scrollToAnnotation(u),i.selectTab(d)):u&&i.selectTab(d)}),[d,e,u,i]);const x=i.hasFetchedProfile();return se((()=>{x&&(p||l)&&o.connect({applyUpdatesImmediately:!1})}),[x,l,p,o]),Ve("div",{className:"relative",children:[Ve("h2",{className:"sr-only",children:"Annotations"}),Ve("div",{className:Je("fixed z-10","right-[9px] top-12"),children:Ve(eg,{})}),y&&Ve(Ag,{withCardContainer:!0}),Ve(bg,{onLogin:t,onSignUp:n
|
|
621
621
|
}),f&&Ve(Hi,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),g&&Ve(Hi,{errorType:"group",onLoginRequest:t}),!v&&Ve(xg,{isLoading:s}),_&&Ve(vg,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Eg=Jn((function({api:e,toastMessenger:t}){const n=ji(),r=n.routeParams().q,o=de((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...ff(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);se((()=>{n.setSortKey("newest"),n.clearAnnotations(),o(r??"").catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]);const{rootThread:i}=kf();return Ve(jm,{threads:i.children})}),["api","toastMessenger"]);var Cg=Jn((function({toastMessenger:e}){const t=ji().getToastMessages();return Ve("div",{className:Je("z-10","absolute left-0 w-full"),children:Ve(Fn,{messages:t,onMessageDismiss:t=>e.dismiss(t),transitionClasses:{
|
|
622
622
|
transitionIn:"motion-safe:animate-slide-in-from-right lg:animate-fade-in motion-reduce:animate-fade-in"}})})}),["toastMessenger"]);function Mg(e){return e.organization&&e.organization.name}const Ng="__default__";function Ig(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;const n=(r=e.organization).id===Ng?Ng:`${r.name.toLowerCase()}${r.id}`;var r;void 0===t[n]&&(t[n]={...e.organization,groups:[]}),function(e,t){const n=Object.assign({},e),r=t.groups;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function Og(e){const t=Ig(e),n=[],r=[];return Object.keys(t).sort().forEach((e=>{e===Ng?n.push(...t[e].groups):r.push(...t[e].groups)})),n.length&&r.push(...n),r}function zg({heading:e,children:t}){return Ve(y,{children:[e&&Ve("h2",{className:"text-color-text-light p-3 leading-none uppercase",children:e}),Ve("ul",{className:"border-b",children:E(t).map((e=>Ve("li",{children:e},e.key)))})]})}function Lg({type:e}){return Ve("div",{
|
|
@@ -667,7 +667,7 @@ const n=Qr(e),r=Kr(e),o=Yr(e);return xb`
|
|
|
667
667
|
${u.join("\n\n")}`}buildCSVExportContent(e,{groupName:t="",defaultAuthority:n="",displayNamesEnabled:r=!1,separator:o=","}={}){const{uri:i,extractUsername:a}=this._exportCommon(e,{displayNamesEnabled:r,defaultAuthority:n}),s=e=>[Sb(new Date(e.created)),a(e),Qr(e)??"",i,t,Ur(e),Kr(e)??Yr(e)??"",e.text,e.tags.join(",")].map((e=>function(e,t){return new RegExp(`["\n\r${t}]`).test(e)?`"${e.replace(/"/g,'""')}"`:e}(e,o))).join(o);return`${["Created at","Author","Page","URL","Group","Type","Quote/description","Comment","Tags"].join(o)}\n${e.map((e=>s(e))).join("\n")}`}buildHTMLExportContent(e,{groupName:t="",displayNamesEnabled:n=!1,defaultAuthority:r="",now:o=new Date}={}){const{uri:i,title:a,uniqueUsers:s,replies:l,extractUsername:c}=this._exportCommon(e,{displayNamesEnabled:n,defaultAuthority:r});return function(e,t,n){var r=Object.assign({},_b,n||{});return r.jsx||(r.attributeHook=null),Wv(e,t,r)}(Ve("html",{lang:"en",children:[Ve("head",{children:[Ve("title",{children:`Annotations on "${a}"`
|
|
668
668
|
}),Ve("meta",{charSet:"UTF-8"})]}),Ve("body",{children:[Ve("section",{children:[Ve("h1",{children:"Summary"}),Ve("p",{children:Ve("time",{dateTime:o.toISOString(),children:Sb(o)})}),Ve("p",{children:Ve("strong",{children:a})}),Ve("p",{children:Ve("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Ve("table",{children:Ve("tbody",{style:{verticalAlign:"top"},children:[Ve("tr",{children:[Ve("td",{children:"Group:"}),Ve("td",{children:t})]}),Ve("tr",{children:[Ve("td",{children:"Total users:"}),Ve("td",{children:s.length})]}),Ve("tr",{children:[Ve("td",{children:"Users:"}),Ve("td",{children:s.join(", ")})]}),Ve("tr",{children:[Ve("td",{children:"Total annotations:"}),Ve("td",{children:e.length})]}),Ve("tr",{children:[Ve("td",{children:"Total replies:"}),Ve("td",{children:l.length})]})]})})]}),Ve("hr",{}),Ve("section",{children:[Ve("h1",{children:"Annotations"}),e.map(((e,t)=>{const n=Qr(e),r=Kr(e),o=Yr(e),i=Jh(e.text),a=i===`<p>${e.text}</p>`?e.text:i;return Ve("article",{children:[Ve("h2",{
|
|
669
669
|
children:["Annotation ",t+1,":"]}),Ve("table",{children:Ve("tbody",{style:{verticalAlign:"top"},children:[Ve("tr",{children:[Ve("td",{children:"Created at:"}),Ve("td",{children:Ve("time",{dateTime:e.created,children:Sb(new Date(e.created))})})]}),Ve("tr",{children:[Ve("td",{children:"Author:"}),Ve("td",{children:c(e)})]}),n&&Ve("tr",{children:[Ve("td",{children:"Page:"}),Ve("td",{children:n})]}),Ve("tr",{children:[Ve("td",{children:"Type:"}),Ve("td",{children:Ur(e)})]}),r&&Ve("tr",{children:[Ve("td",{children:"Quote:"}),Ve("td",{children:Ve("blockquote",{style:{margin:0},children:r})})]}),o&&Ve("tr",{children:[Ve("td",{children:"Description:"}),Ve("td",{children:o})]}),Ve("tr",{children:[Ve("td",{children:"Comment:"}),Ve("td",{dangerouslySetInnerHTML:{__html:a}})]}),e.tags.length>0&&Ve("tr",{children:[Ve("td",{children:"Tags:"}),Ve("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}_exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e
|
|
670
|
-
;if(!r)throw new Error("No annotations to export");const o=e=>Xi(e,n,t),{uri:i,title:a}=Zi(r);return{uri:i,title:a,uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>Pr(e))),extractUsername:o}}}Ab.$inject=[];class Tb{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={"Content-Type":"application/json","Hypothesis-Client-Version":"1.
|
|
670
|
+
;if(!r)throw new Error("No annotations to export");const o=e=>Xi(e,n,t),{uri:i,title:a}=Zi(r);return{uri:i,title:a,uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>Pr(e))),extractUsername:o}}}Ab.$inject=[];class Tb{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={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1688.0"};i&&(u.Authorization="Bearer "+i);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:p}=ci(c.url,a),m=new URL(h);for(const[e,t]of Object.entries(p)){const n=Array.isArray(t)?t:[t]
|
|
671
671
|
;for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await bp(m.toString(),{body:s?JSON.stringify(kb(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={read:i("annotation.read"),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"),moderate:i("annotation.moderate")},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")},read:i("profile.read"),update:i("profile.update")},this.analytics={events:{create:i("analytics.events.create")}}}setClientId(e){this._clientId=e}}Tb.$inject=["apiRoutes","auth","store"]
|
|
672
672
|
;var Eb,Cb,Mb,Nb,Ib,Ob={};function zb(){return Mb||(Mb=1,e=Ob,t=function(){if(Cb)return Eb;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 Cb=1,Eb=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),
|
|
673
673
|
this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){
|
|
@@ -783,8 +783,8 @@ Object.keys(this._configMessages).forEach((t=>{this._configMessages[t]&&e.send(t
|
|
|
783
783
|
value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){this._updateImmediately=e.applyUpdatesImmediately??!0,this._reconnectSetUp||(this._reconnectSetUp=!0,Jb(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}ES.$inject=["store","apiRoutes","auth","groups","session","$window"];const CS="hypothesis.user.tags.list",MS="hypothesis.user.tags.map";class NS{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(CS)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${uv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(MS)||{};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(MS,t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)))
|
|
784
784
|
;this._storage.setObject(CS,n)}}NS.$inject=["localStorage"];class IS{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}IS.$inject=["store"];class OS{#t=new Map;#n=30;#r;constructor(e){this.#r=e}get cacheSize(){return this.#n}set cacheSize(e){this.#n=e,this.#o()}#o(){for(const e of this.#t.keys()){const t=this.#t.get(e);if(t&&URL.revokeObjectURL(t.url),this.#t.delete(e),this.#t.size<=this.cacheSize)break}}async fetch(e,t={}){const n=this.get(e);if(n)return n;const r=await this.#r.requestThumbnail(e,t),o=await async function(e){const t=new OffscreenCanvas(e.width,e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height);const n=await t.convertToBlob();return URL.createObjectURL(n)}(r),i={url:o,width:r.width,height:r.height};return this.#t.set(e,i),this.#t.size>this.cacheSize&&this.#o(),i}get(e){const t=this.#t.get(e);return t?(this.#t.delete(e),this.#t.set(e,t),t):null}cachedThumbnailTags(){
|
|
785
785
|
return[...this.#t.keys()]}}OS.$inject=["frameSync"];class zS extends Ff{constructor(e,t){super(),this._store=e,this._window=t,this._delayedMessageQueue=[],this._window.addEventListener("focus",(()=>{this._delayedMessageQueue.forEach((({type:e,messageText:t,options:n})=>this._addMessage(e,t,n))),this._delayedMessageQueue=[]}))}dismiss(e){this._store.getToastMessage(e)&&(this._store.removeToastMessage(e),this.emit("toastMessageDismissed",e))}_addMessage(e,t,{autoDismiss:n=!0,visuallyHidden:r=!1,delayed:o=!1}={}){if(this._store.hasToastMessage(e,t))return;if(o&&!this._window.document.hasFocus()){const o={autoDismiss:n,visuallyHidden:r};return void this._delayedMessageQueue.push({type:e,messageText:t,options:o})}const i={type:e,id:Jg(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)}}zS.$inject=["store","$window"]
|
|
786
|
-
;const LS=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),PS=function(e){const{version:t,origin:n}=tv(e.location.href);return"1.
|
|
787
|
-
n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}LS.sentry&&PS&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;!function(e={}){const t=!e.skipBrowserExtensionCheck&&hS(),n={...e,enabled:!t&&e.enabled,stackParser:(r=e.stackParser||Xk,Array.isArray(r)?Sy(...r):r),integrations:cx({integrations:e.integrations,defaultIntegrations:null==e.defaultIntegrations?[$x(),jx(),nS(),eS(),sS(),dS(),Xx(),uS(),aS()]:e.defaultIntegrations}),transport:e.transport||Fk};var r;Tx(Sk,n)}({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.
|
|
786
|
+
;const LS=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),PS=function(e){const{version:t,origin:n}=tv(e.location.href);return"1.1688.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1688.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function RS(e,t){e.setClientId(t.clientId)}function DS(e){e.sync()}function jS(e,t){e.load(),t.load()}function HS(e,t,n){e.init(),t.init(),n.init()}function FS(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{
|
|
787
|
+
n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}LS.sentry&&PS&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;!function(e={}){const t=!e.skipBrowserExtensionCheck&&hS(),n={...e,enabled:!t&&e.enabled,stackParser:(r=e.stackParser||Xk,Array.isArray(r)?Sy(...r):r),integrations:cx({integrations:e.integrations,defaultIntegrations:null==e.defaultIntegrations?[$x(),jx(),nS(),eS(),sS(),dS(),Xx(),uS(),aS()]:e.defaultIntegrations}),transport:e.transport||Fk};var r;Tx(Sk,n)}({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1688.0",beforeSend:(e,t)=>{if(pS>=5)return sv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++pS;try{const n=t&&t.originalException;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch{}return e}});try{
|
|
788
788
|
tx("host_config",tv(window.location.href))}catch{}tx("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Vb(((e,t)=>{mS(e,t)}))}(LS.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),RS.$inject=["api","streamer"],DS.$inject=["router"],jS.$inject=["groups","session"],HS.$inject=["autosaveService","persistedDefaults","serviceURL"],FS.$inject=["frameSync","store","toastMessenger"];const $S=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",vv)}(),async function(e,t=window){const n=function(e){const t=tv(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:nv,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){
|
|
789
789
|
return"object"==typeof e&&null!==e?e:{}}(e);return{origin:ov(t.origin),ancestorLevel:rv(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:iv(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await ev(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=ev(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=Kn(e)
|
|
790
790
|
;if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(LS).then((e=>{!function(e,t){const n=new U;n.register("analytics",bv).register("annotationsExporter",Ab).register("annotationsService",_v).register("annotationActivity",yv).register("api",Tb).register("apiRoutes",Db).register("auth",Fb).register("autosaveService",$b).register("dashboard",Bb).register("frameSync",ny).register("groups",iy).register("importAnnotationsService",gS).register("loadAnnotationsService",vS).register("localStorage",yS).register("persistedDefaults",wS).register("router",xS).register("serviceURL",kS).register("session",SS).register("streamer",ES).register("streamFilter",AS).register("tags",NS).register("threadsService",IS).register("thumbnailService",OS).register("toastMessenger",zS).register("store",{factory:Di}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(DS),n.run(HS),n.run(RS),n.run(jS),n.run(gv),n.run(FS),H(Ve(Qn.Provider,{value:n,
|