hypothesis 1.1654.0 → 1.1655.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
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?cc97d3","styles/annotator.css":"styles/annotator.css?ce3b25","styles/annotator.css.map":"styles/annotator.css.map?e7c11d","styles/highlights.css":"styles/highlights.css?24baca","styles/highlights.css.map":"styles/highlights.css.map?377599","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?e3cdd6","styles/sidebar.css.map":"styles/sidebar.css.map?e23f54","styles/ui-playground.css":"styles/ui-playground.css?769a10","styles/ui-playground.css.map":"styles/ui-playground.css.map?16dfd3","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?5df301","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?9ef589","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?a3156b","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?9b30d3","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?cfb386"};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?cc97d3","styles/annotator.css":"styles/annotator.css?ce3b25","styles/annotator.css.map":"styles/annotator.css.map?e7c11d","styles/highlights.css":"styles/highlights.css?24baca","styles/highlights.css.map":"styles/highlights.css.map?377599","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?e3cdd6","styles/sidebar.css.map":"styles/sidebar.css.map?e23f54","styles/ui-playground.css":"styles/ui-playground.css?769a10","styles/ui-playground.css.map":"styles/ui-playground.css.map?16dfd3","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?5df301","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?9ef589","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?a3156b","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?9b30d3","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?cfb386"};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.1655.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?cc97d3",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?ce3b25",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?e7c11d",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?24baca",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"styles/sidebar.css.map": "styles/sidebar.css.map?e23f54",
|
|
13
13
|
"styles/ui-playground.css": "styles/ui-playground.css?769a10",
|
|
14
14
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?16dfd3",
|
|
15
|
-
"scripts/
|
|
16
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?6064a1",
|
|
15
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?5df301",
|
|
17
16
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?9ef589",
|
|
18
|
-
"scripts/
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?a3156b",
|
|
18
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?9b30d3",
|
|
19
|
+
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?cfb386"
|
|
20
20
|
}
|
|
@@ -158,7 +158,7 @@ this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.des
|
|
|
158
158
|
;if(o instanceof Range){const i=uo.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)
|
|
159
159
|
;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:"+nn(8)};return this._sidebarRPC.call("createAnnotation",i),this.anchor(i),i}catch(e){if(e instanceof Bo&&["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:"+nn(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Br(),r}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)))
|
|
160
160
|
;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=_o(n),i=vo(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Or(),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,
|
|
161
|
-
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){$n(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Pr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Dr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Vr(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.
|
|
161
|
+
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){$n(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Pr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Dr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Vr(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.1655.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),
|
|
162
162
|
e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function Ur({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=oe(null);return te((()=>{e?r.current?.close():r.current?.showModal()}),[e]),te((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Pe("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function zr({closed:e,children:t,...n}){return Pe("div",{...n,className:Re("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Pe("div",{className:"relative w-full h-full",children:t})})}function qr({document_:e=document,...t}){return Pe(ie((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Ur:zr),[e]),{...t})}function $r({config:e,groupId:t}){
|
|
163
163
|
return Pe("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Dr(e.notebookAppUrl,{...Vr(e.notebookAppUrl,e),group:t})})}function Wr({eventBus:e,config:t}){const[n,o]=ee(0),[i,r]=ee(!0),[s,a]=ee(null),l=oe(""),c=oe(null);te((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),te((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),te((()=>{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=re((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:Pe(qr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Pe("div",{className:"absolute right-0 m-3",children:Pe(kt,{title:"Close notebook",onClick:h,variant:"dark",classes:Re("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Pe(He,{className:"w-4 h-4"})})}),Pe($r,{
|
|
164
164
|
config:t,groupId:s},n)]})}class jr{constructor(e,t,n){this._container=new Zn("notebook",(()=>Pe(Wr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Xr({eventBus:e,config:t}){const[n,o]=ee(!0),i=oe(null);te((()=>{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:Pe(qr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Pe("div",{className:"absolute right-0 m-3",children:Pe(kt,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Re("!bg-transparent enabled:hover:!bg-grey-3"),children:Pe(He,{className:"w-4 h-4"})})}),Pe("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Yr{constructor(e,t,n){this._container=new Zn("profile",(()=>Pe(Xr,{eventBus:t,config:n}))),e.append(this._container.element),
|
|
@@ -568,16 +568,16 @@ function yf({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedT
|
|
|
568
568
|
;return e?Qe(vo,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):Qe("div",{children:n})}var wf=Oo((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){const i=ws(),a=i.defaultAuthority(),s=i.isFeatureEnabled("client_display_names"),l=i.getLink("user",{user:e.user}),c=ce((()=>Ls(e,a,s)),[e,a,s]),u=ce((()=>function(e,t,n,r){return!pi(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${mi(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=yi(e)&&r,h=e.links?.html||"",m=ce((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3}(e)&&!d),[e,d]),p=function(e){return{domain:bi(e),titleText:vi(e),titleLink:gi(e)}}(e),f=h&&p.titleLink?p.titleLink:"",g="sidebar"!==i.route()&&p.titleText;let b;"sidebar"!==i.route()&&(b=i.getGroup(e.group));const v=Pi(e);return Qe("header",{children:[Qe("div",{className:"flex gap-x-1 items-center flex-wrap-reverse",
|
|
569
569
|
children:[Fs(e.permissions)&&!t&&Qe(On,{className:"w-[12px] h-[12px]",title:"This annotation is visible only to you"}),Qe(_f,{authorLink:u,displayName:c}),n>0&&d&&Qe(_o,{variant:"text-light",onClick:()=>i.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Qe("div",{className:"flex justify-end grow",children:Qe(yf,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,withEditedTimestamp:m})})]}),!yi(e)&&Qe("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[b&&Qe(vf,{group:b}),!t&&Si(e)&&Qe(_n,{title:"This is a highlight. Click 'edit' to add a note or tag.",className:"w-[10px] h-[10px] text-color-text-light"}),(g||v)&&Qe("span",{className:"flex",children:[g&&Qe(bf,{domain:p.domain,link:f,title:p.titleText}),v&&Qe("span",{className:"text-grey-6","data-testid":"page-number",children:[g&&", ","p. ",v]})]})]})]})}),["settings"])
|
|
570
570
|
;var xf=Oo((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Qe(Xs,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Qe(Cp,{classes:Xe({"p-redacted-text":n}),children:Qe("blockquote",{className:Xe("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:zo(["selectionFontFamily"],r),children:e})})})}),["settings"]);function kf({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Qe(xr,{classes:Xe("text-grey-7 enabled:hover:text-brand-dark","enabled:hover:underline"),onClick:e,title:r,variant:"custom",children:r})}var Nf=Oo((function({description:e,textInImage:t,tag:n,thumbnailService:r}){const[o,i]=oe((()=>r.get(n))),[a,s]=oe(),[l,c]=oe(!1),u=le(),d=ce((()=>window.devicePixelRatio),[]);let h;ae((()=>{o||a||r.fetch(n,{maxWidth:196*d,devicePixelRatio:d}).then(i).catch((e=>s(e.message)))}),[a,d,n,o,r]),h=e?`Thumbnail. ${e}`:t?`Thumbnail. Contains text: ${t}`:"Thumbnail";const m=o?o.width/d:0,p=o?o.height/d:0
|
|
571
|
-
;return Qe("div",{className:"flex flex-row justify-center relative","data-testid":"thumbnail-container",children:[o&&Qe("img",{src:o.url,alt:h,className:"border rounded-md",style:{width:`${m}px`,height:`${p}px`}}),o&&e&&Qe(y,{children:[Qe(Tr,{classes:"absolute
|
|
572
|
-
className:"text-color-text-light font-medium",children:"Saving..."})]})}var Af=Oo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ws(),s=zi(e),l=Li(e),c=a.getDraft(e),u=a.profile().userid,d=a.isAnnotationHovered(e.$tag),h=a.isSavingAnnotation(e),m=!!c&&!h,p=t&&o,f=!h&&!m&&_i(e),g=a.defaultAuthority(),b=a.isFeatureEnabled("client_display_names"),v=ce((()=>Ls(e,g,b)),[e,g,b]),y=_i(e)?Ci(e):`New ${Ci(e).toLowerCase()}`,_=a.isAnnotationHighlighted(e)?" - Highlighted":"",w=ce((()=>Oi(e)),[e]);return Qe("article",{className:"space-y-4","aria-label":`${y} by ${v}${_}`,children:[Qe(wf,{annotation:e,isEditing:m,replyCount:r,threadIsCollapsed:o}),w&&Qe(Nf,{tag:e.$tag,textInImage:w.text,description:l}),s&&Qe(xf,{quote:s,isHovered:d,isOrphan:Ai(e)}),!p&&!m&&Qe(Pp,{annotation:e}),m&&Qe(gf,{annotation:e,draft:c}),!p&&Qe("footer",{className:"flex items-center",
|
|
573
|
-
classes:"grow",children:Qe(Ws,{annotation:e,onReply:()=>{_i(e)&&u&&i.reply(e,u)}})})]})]})}),["annotationsService"]);function Tf({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Qe("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Qe("div",{children:Qe("em",{children:"Message not available."})}),r&&Qe("footer",{className:"flex items-center",children:Qe(kf,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var Ef=Oo((function({annotation:e,api:t,toastMessenger:n}){const r=ws(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Qe("div",{className:Xe("flex gap-x-3 bg-grey-1 text-color-text font-semibold","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!yi(e),"-mr-3":yi(e)}),children:[Qe("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden
|
|
574
|
-
className:"self-center grow",children:[!e.hidden&&Qe("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Qe("span",{children:"Hidden from users"})]}),Qe("div",{className:"self-center pr-2",children:Qe(xr,{classes:Xe("px-1.5 py-1","bg-slate-1 text-grey-7 bg-grey-2","enabled:hover:text-grey-9 enabled:hover:bg-grey-3 disabled:text-grey-5","aria-pressed:bg-grey-3 aria-expanded:bg-grey-3"),onClick:e.hidden?()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))}:()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},title:e.hidden?"Make this annotation visible to everyone":"Hide this annotation from non-moderators",size:"custom",variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"])
|
|
575
|
-
;return Qe("div",{className:Xe("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Qe("div",{className:Xe("bg-white"),children:Qe(xr,{classes:Xe("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-5 hover:text-grey-7"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Qe(n,{className:"w-em h-em"})})})})}var Mf=Oo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Is(e)>0)),i=ws(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=ue((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=ce((()=>t.visible&&Qe(y,{children:t.annotation?Qe(y,{children:[Qe(Ef,{annotation:t.annotation}),Qe(Af,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,
|
|
576
|
-
replyCount:t.replyCount,threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Qe("section",{className:"flex","data-testid":"thread-container",children:[r&&Qe(Cf,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Qe("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,Ms(t)>0&&Qe("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Qe(wf,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Qe("div",{children:Qe(xr,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",Ms(t)," more in conversation"]})})]}),!t.collapsed&&Qe("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Qe("li",{className:Xe("mt-2","[text-align:start]"),children:Qe(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"])
|
|
577
|
-
const n=ws(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=ce((()=>As((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=ue((t=>{e.scrollToAnnotation(t)}),[e]),l=ce((()=>Qe(Mf,{thread:t})),[t]),c=n.annotationFocusRequest(),u=le(null);return ae((()=>{c===t.id&&u.current&&(u.current.focus(),n.clearAnnotationFocusRequest())}),[c,n,t.id]),Qe(st,{active:o,classes:Xe("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a}),"data-testid":"thread-card",elementRef:u,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Qe(dt,{children:l})},t.id)}),["frameSync"]);const zf=50;function Lf(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function Of(e){return Math.max(e-e%zf,0)}function Rf(e){
|
|
578
|
-
;if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function Pf(e){if(!e.annotation)return null;const t=Rf(e.annotation);return t?.cfi??null}function Df({threads:e}){const[t,n]=oe(0),[r,o]=oe(0);se((()=>{const e=new we,t=Lf();n(t.clientHeight),o(Of(t.scrollTop));const r=As((()=>{n(t.clientHeight),o(Of(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=oe((()=>new Map)),[s,l]=oe(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=ce((()=>function(e,t,n,r,o=Ts){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d}}(c,i,r,t)),[c,i,r,t]),m=ce((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=Rf(n.annotation);e?.title&&t.set(e.cfi,e.title)}
|
|
579
|
-
;for(const i of e){const e=Pf(i);if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),p=ws(),f=p.profile().userid,g=p.countDrafts()>0,b=p.highlightedAnnotations(),v=p.allAnnotations(),y=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();ae((()=>{y&&(p.setForcedVisible(y,!0),l(y))}),[p,y]);const _=ce((()=>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}(v,{highlightedAnnotations:b,currentUserId:f})?.id),[v,f,b]);return ae((()=>{!g&&_&&l(_)}),[g,_]),ae((()=>{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)||Ts.defaultHeight)(t)),0);Lf().scrollTop=t}),[s,c,i]),ae((()=>{a((e=>{const t=new Map
|
|
580
|
-
const r=document.getElementById(n);if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=Es(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Qe("div",{children:[Qe("div",{style:{height:d}}),h.map((e=>Qe("div",{className:Xe("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[m.get(e)&&Qe("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(e)}),Qe(If,{thread:e})]},e.id))),Qe("div",{style:{height:u}})]})}const Hf={collapsed:!1,depth:0,visible:!0,replyCount:0};function Ff(e){return e.id||e.$tag}function $f(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||$f(e,t,r.parent))}function jf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...Hf,children:[],id:r},jf(e,r,n.slice(0,-1))),$f(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function Bf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>Bf(e,t)))})}function qf(e,t,n){
|
|
571
|
+
;return Qe("div",{className:"flex flex-row justify-center relative","data-testid":"thumbnail-container",children:[o&&Qe("img",{src:o.url,alt:h,className:"border rounded-md",style:{width:`${m}px`,height:`${p}px`}}),o&&e&&Qe(y,{children:[Qe(Tr,{classes:"absolute text-[white] text-[16px]",variant:"custom",icon:Nn,title:"Image description",onClick:()=>c(!0),expanded:l,elementRef:u,style:{left:`calc(50% + ${m}px / 2 - 16px)`,top:"16px",transform:"translateX(-50%) translateY(-50%)",filter:"drop-shadow(grey 1px 1px 1px)"}}),Qe(to,{open:l,align:"right",anchorElementRef:u,onClose:()=>c(!1),classes:"p-2",children:e})]}),!o&&!a&&Qe("span",{"data-testid":"placeholder",children:"Loading thumbnail..."}),!o&&a&&Qe("span",{"data-testid":"error",children:["Unable to render thumbnail: ",a]})]})}),["thumbnailService"]);function Sf(){return Qe("div",{className:Xe("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Qe("span",{
|
|
572
|
+
className:"text-[16px] animate-fade-in-slow",children:Qe(co,{size:"sm"})}),Qe("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var Af=Oo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ws(),s=zi(e),l=Li(e),c=a.getDraft(e),u=a.profile().userid,d=a.isAnnotationHovered(e.$tag),h=a.isSavingAnnotation(e),m=!!c&&!h,p=t&&o,f=!h&&!m&&_i(e),g=a.defaultAuthority(),b=a.isFeatureEnabled("client_display_names"),v=ce((()=>Ls(e,g,b)),[e,g,b]),y=_i(e)?Ci(e):`New ${Ci(e).toLowerCase()}`,_=a.isAnnotationHighlighted(e)?" - Highlighted":"",w=ce((()=>Oi(e)),[e]);return Qe("article",{className:"space-y-4","aria-label":`${y} by ${v}${_}`,children:[Qe(wf,{annotation:e,isEditing:m,replyCount:r,threadIsCollapsed:o}),w&&Qe(Nf,{tag:e.$tag,textInImage:w.text,description:l}),s&&Qe(xf,{quote:s,isHovered:d,isOrphan:Ai(e)}),!p&&!m&&Qe(Pp,{annotation:e}),m&&Qe(gf,{annotation:e,draft:c}),!p&&Qe("footer",{className:"flex items-center",
|
|
573
|
+
children:[n&&Qe(kf,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),h&&Qe(Sf,{}),f&&Qe(ct,{classes:"grow",children:Qe(Ws,{annotation:e,onReply:()=>{_i(e)&&u&&i.reply(e,u)}})})]})]})}),["annotationsService"]);function Tf({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Qe("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Qe("div",{children:Qe("em",{children:"Message not available."})}),r&&Qe("footer",{className:"flex items-center",children:Qe(kf,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var Ef=Oo((function({annotation:e,api:t,toastMessenger:n}){const r=ws(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Qe("div",{className:Xe("flex gap-x-3 bg-grey-1 text-color-text font-semibold","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!yi(e),"-mr-3":yi(e)}),children:[Qe("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden
|
|
574
|
+
}),children:e.hidden?Qe(vn,{className:"w-em h-em"}):Qe(an,{className:"w-em h-em"})}),Qe("div",{className:"self-center grow",children:[!e.hidden&&Qe("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Qe("span",{children:"Hidden from users"})]}),Qe("div",{className:"self-center pr-2",children:Qe(xr,{classes:Xe("px-1.5 py-1","bg-slate-1 text-grey-7 bg-grey-2","enabled:hover:text-grey-9 enabled:hover:bg-grey-3 disabled:text-grey-5","aria-pressed:bg-grey-3 aria-expanded:bg-grey-3"),onClick:e.hidden?()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))}:()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},title:e.hidden?"Make this annotation visible to everyone":"Hide this annotation from non-moderators",size:"custom",variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"])
|
|
575
|
+
;function Cf({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:Bn,r=e?"Expand replies":"Collapse replies";return Qe("div",{className:Xe("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Qe("div",{className:Xe("bg-white"),children:Qe(xr,{classes:Xe("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-5 hover:text-grey-7"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Qe(n,{className:"w-em h-em"})})})})}var Mf=Oo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Is(e)>0)),i=ws(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=ue((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=ce((()=>t.visible&&Qe(y,{children:t.annotation?Qe(y,{children:[Qe(Ef,{annotation:t.annotation}),Qe(Af,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,
|
|
576
|
+
replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Qe(Tf,{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 Qe("section",{className:"flex","data-testid":"thread-container",children:[r&&Qe(Cf,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Qe("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,Ms(t)>0&&Qe("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Qe(wf,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Qe("div",{children:Qe(xr,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",Ms(t)," more in conversation"]})})]}),!t.collapsed&&Qe("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Qe("li",{className:Xe("mt-2","[text-align:start]"),children:Qe(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"])
|
|
577
|
+
;var If=Oo((function({frameSync:e,thread:t}){const n=ws(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=ce((()=>As((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=ue((t=>{e.scrollToAnnotation(t)}),[e]),l=ce((()=>Qe(Mf,{thread:t})),[t]),c=n.annotationFocusRequest(),u=le(null);return ae((()=>{c===t.id&&u.current&&(u.current.focus(),n.clearAnnotationFocusRequest())}),[c,n,t.id]),Qe(st,{active:o,classes:Xe("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a}),"data-testid":"thread-card",elementRef:u,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Qe(dt,{children:l})},t.id)}),["frameSync"]);const zf=50;function Lf(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function Of(e){return Math.max(e-e%zf,0)}function Rf(e){
|
|
578
|
+
const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function Pf(e){if(!e.annotation)return null;const t=Rf(e.annotation);return t?.cfi??null}function Df({threads:e}){const[t,n]=oe(0),[r,o]=oe(0);se((()=>{const e=new we,t=Lf();n(t.clientHeight),o(Of(t.scrollTop));const r=As((()=>{n(t.clientHeight),o(Of(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=oe((()=>new Map)),[s,l]=oe(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=ce((()=>function(e,t,n,r,o=Ts){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d}}(c,i,r,t)),[c,i,r,t]),m=ce((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=Rf(n.annotation);e?.title&&t.set(e.cfi,e.title)}
|
|
579
|
+
return t}(e),o=new Map;for(const i of e){const e=Pf(i);if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),p=ws(),f=p.profile().userid,g=p.countDrafts()>0,b=p.highlightedAnnotations(),v=p.allAnnotations(),y=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();ae((()=>{y&&(p.setForcedVisible(y,!0),l(y))}),[p,y]);const _=ce((()=>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}(v,{highlightedAnnotations:b,currentUserId:f})?.id),[v,f,b]);return ae((()=>{!g&&_&&l(_)}),[g,_]),ae((()=>{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)||Ts.defaultHeight)(t)),0);Lf().scrollTop=t}),[s,c,i]),ae((()=>{a((e=>{const t=new Map
|
|
580
|
+
;for(const{id:n}of h){const r=document.getElementById(n);if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=Es(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Qe("div",{children:[Qe("div",{style:{height:d}}),h.map((e=>Qe("div",{className:Xe("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[m.get(e)&&Qe("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(e)}),Qe(If,{thread:e})]},e.id))),Qe("div",{style:{height:u}})]})}const Hf={collapsed:!1,depth:0,visible:!0,replyCount:0};function Ff(e){return e.id||e.$tag}function $f(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||$f(e,t,r.parent))}function jf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...Hf,children:[],id:r},jf(e,r,n.slice(0,-1))),$f(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function Bf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>Bf(e,t)))})}function qf(e,t,n){
|
|
581
581
|
const r=e.children.map((e=>qf(e,n,n))).slice().sort(t);return{...e,children:r}}function Uf(e,t){const n=e.children.map((e=>Uf(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function Gf(e){return e.children.some((e=>e.visible||Gf(e)))}const Vf=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function Wf(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=Ff(e);t[n]={...Hf,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return jf(t,Ff(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...Hf,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn
|
|
582
582
|
;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=Bf(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||Gf(e))),o=Bf(o,(e=>{const n={collapsed:e.collapsed};if(di(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&Gf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=qf(o,t.sortCompareFn,Vf),o=Uf(o,-1),o}function Kf(e){const t=Yf(e),[n,r]=t.split("-",2);return[n,r??n]}function Yf(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 Xf(e,t){const n=e=>function(e){const t=Yf(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){
|
|
583
583
|
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 Zf(e,t,n){return Xf(e,t)>=0&&Xf(e,n)<0}function Jf(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 Qf=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function eg(e,t,n){return[e[0]??t,e[1]??n]}function tg(e,t){const n=Jf(e),r=Jf(t);if(!n||!r)return e&&t&&e===t?Qf.Overlap:Qf.Unknown;const o=2**31,[i,a]=eg(n,1,o),[s,l]=eg(r,1,o);return i<=s?s<=a?Qf.Overlap:Qf.NoOverlap:i<=l?Qf.Overlap:Qf.NoOverlap}function ng(e){return function(e){return e.replace(/\p{M}/gu,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class rg{constructor(e,t){
|
|
@@ -586,7 +586,7 @@ const e=["quote","text","tag","user"];r=t.terms.map((t=>new og("or",e.map((e=>n(
|
|
|
586
586
|
return zs([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function gg(e){return zs([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}function bg(e,t){const n=e??Number.MIN_SAFE_INTEGER,r=t??Number.MIN_SAFE_INTEGER;return Math.sign(n-r)}function vg(e,t){return e===t?0:e<t?-1:1}function yg(e,t,n){switch(n.sortBy){case"newest":{const n=fg(e);return vg(fg(t),n)}case"oldest":return vg(gg(e),gg(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=Mi(e.annotation),r=Mi(t.annotation);if(n.cfi||r.cfi){const e="/0",t=Xf(n.cfi??e,r.cfi??e);if(0!==t)return Math.sign(t)}const o=bg(n.pageIndex,r.pageIndex);if(0!==o)return o;const i=bg(n.top,r.top);if(0!==i)return i;const a=bg(n.charOffset,r.charOffset);if(0!==a)return a;return vg(e.annotation.created,t.annotation.created)}(e,t);default:return 0}}const _g=function(e){if(1!==e.length)throw new Error("Memoize input must be a function of one argument")
|
|
587
587
|
;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)=>yg(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=hg(e,lg);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",
|
|
588
588
|
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=>sg([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&sg([e.annotation],o).length>0)}const r=Wf(e.annotations,n),o={annotation:0,note:0,orphan:0};return e.showTabs&&(r.children=r.children.filter((e=>{if(!e.annotation)return!1;if(ki(e.annotation))return!1;const n=pg(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function wg(){
|
|
589
|
-
const e=ws(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=ce((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return _g(s)}var xg,kg,Ng=Oo((function({loadAnnotationsService:e,onLogin:t}){const n=ws(),r=n.routeParams().id??"",{rootThread:o}=wg(),i=n.profile().userid,[a,s]=oe(!1);return ae((()=>{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]),Qe(y,{children:[a&&Qe(xs,{errorType:"annotation",onLoginRequest:t}),Qe(Df,{threads:o.children})]})}),["loadAnnotationsService"]);class Sg{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.
|
|
589
|
+
const e=ws(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=ce((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return _g(s)}var xg,kg,Ng=Oo((function({loadAnnotationsService:e,onLogin:t}){const n=ws(),r=n.routeParams().id??"",{rootThread:o}=wg(),i=n.profile().userid,[a,s]=oe(!1);return ae((()=>{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]),Qe(y,{children:[a&&Qe(xs,{errorType:"annotation",onLoginRequest:t}),Qe(Df,{threads:o.children})]})}),["loadAnnotationsService"]);class Sg{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.1655.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||r,
|
|
590
590
|
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 Ag=function(){if(kg)return xg;kg=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){
|
|
591
591
|
var n,r,o,i,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,h=c&&null!=c.top?c.top:.5,m=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,f=d,g=h;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),r=u.left+t.pageXOffset-t.innerWidth*f+s*f,o=u.top+t.pageYOffset-t.innerHeight*g+l*g,r-=m,o-=p,r=e.align.lockX?t.pageXOffset:r,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 b=u.left-(n.left-t.scrollLeft),v=u.top-(n.top-t.scrollTop);r=b+s*f-t.clientWidth*f,o=v+l*g-t.clientHeight*g,r-=m,o-=p,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,a=o-t.scrollTop}return{x:r,y:o,differenceX:i,differenceY:a}}(o,t),s=Date.now()-o.startTime,l=Math.min(1/o.time*s,1);if(o.endIterations>=i)return n(t,a.x,a.y),
|
|
592
592
|
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 xg=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||{}
|
|
@@ -674,7 +674,7 @@ null==b._nextState&&null==b.__s&&(b._nextState=b.__s=b.state),b.context=_,h.getD
|
|
|
674
674
|
}),Qe("meta",{charSet:"UTF-8"})]}),Qe("body",{children:[Qe("section",{children:[Qe("h1",{children:"Summary"}),Qe("p",{children:Qe("time",{dateTime:o.toISOString(),children:fy(o)})}),Qe("p",{children:Qe("strong",{children:a})}),Qe("p",{children:Qe("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Qe("table",{children:Qe("tbody",{style:{verticalAlign:"top"},children:[Qe("tr",{children:[Qe("td",{children:"Group:"}),Qe("td",{children:t})]}),Qe("tr",{children:[Qe("td",{children:"Total users:"}),Qe("td",{children:s.length})]}),Qe("tr",{children:[Qe("td",{children:"Users:"}),Qe("td",{children:s.join(", ")})]}),Qe("tr",{children:[Qe("td",{children:"Total annotations:"}),Qe("td",{children:e.length})]}),Qe("tr",{children:[Qe("td",{children:"Total replies:"}),Qe("td",{children:l.length})]})]})})]}),Qe("hr",{}),Qe("section",{children:[Qe("h1",{children:"Annotations"}),e.map(((e,t)=>{const n=Pi(e),r=zi(e),o=Li(e),i=Ep(e.text),a=i===`<p>${e.text}</p>`?e.text:i;return Qe("article",{children:[Qe("h2",{
|
|
675
675
|
children:["Annotation ",t+1,":"]}),Qe("table",{children:Qe("tbody",{style:{verticalAlign:"top"},children:[Qe("tr",{children:[Qe("td",{children:"Created at:"}),Qe("td",{children:Qe("time",{dateTime:e.created,children:fy(new Date(e.created))})})]}),Qe("tr",{children:[Qe("td",{children:"Author:"}),Qe("td",{children:c(e)})]}),n&&Qe("tr",{children:[Qe("td",{children:"Page:"}),Qe("td",{children:n})]}),Qe("tr",{children:[Qe("td",{children:"Type:"}),Qe("td",{children:Ci(e)})]}),r&&Qe("tr",{children:[Qe("td",{children:"Quote:"}),Qe("td",{children:Qe("blockquote",{style:{margin:0},children:r})})]}),o&&Qe("tr",{children:[Qe("td",{children:"Description:"}),Qe("td",{children:o})]}),Qe("tr",{children:[Qe("td",{children:"Comment:"}),Qe("td",{dangerouslySetInnerHTML:{__html:a}})]}),e.tags.length>0&&Qe("tr",{children:[Qe("td",{children:"Tags:"}),Qe("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}_exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e
|
|
676
676
|
;if(!r)throw new Error("No annotations to export");const o=e=>Ls(e,n,t),{uri:i,title:a}=fi(r);return{uri:i,title:a,uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>yi(e))),extractUsername:o}}}gy.$inject=[];class by extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),this.url=e,this.response=t,this.reason=n}}async function vy(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new by(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch{throw new by(e,n,"Failed to parse response")}if(!n.ok)throw new by(e,n,r?.reason);return r}class yy{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){
|
|
677
|
-
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.
|
|
677
|
+
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.1655.0"};i&&(u.Authorization="Bearer "+i);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:m}=Va(c.url,a),p=new URL(h);for(const[e,t]of Object.entries(m)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&p.searchParams.append(e,t.toString())}return await vy(p.toString(),{body:s?JSON.stringify(py(s)):null,headers:u,method:c.method,signal:l})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},members:{read:i("group.members.read")
|
|
678
678
|
},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}}yy.$inject=["apiRoutes","auth","store"];var _y,wy,xy,ky,Ny,Sy={};function Ay(){return xy||(xy=1,e=Sy,t=function(){if(wy)return _y;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 wy=1,_y=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),
|
|
679
679
|
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),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(){
|
|
680
680
|
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){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=o,n=a)}return t},_y}(),e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n]
|
|
@@ -789,8 +789,8 @@ this._socket?.isConnected()&&this._socket.send(t)}async _reconnect(){const e=awa
|
|
|
789
789
|
this._reconnectSetUp||(this._reconnectSetUp=!0,Vy(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}hS.$inject=["store","apiRoutes","auth","groups","session","$window"];const mS="hypothesis.user.tags.list",pS="hypothesis.user.tags.map";class fS{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(mS)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${sv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(pS)||{};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(pS,t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject(mS,n)}}fS.$inject=["localStorage"];class gS{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),
|
|
790
790
|
e.visible||this._store.setForcedVisible(e.id,!0)}}gS.$inject=["store"];class bS{#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(){return[...this.#t.keys()]}}bS.$inject=["frameSync"];class vS extends Dg{constructor(e,t){super(),this._store=e,this._window=t,this._delayedMessageQueue=[],
|
|
791
791
|
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:Xb(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)}}vS.$inject=["store","$window"];const yS=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){
|
|
792
|
-
console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),_S=function(e){const{version:t,origin:n}=Jb(e.location.href);return"1.
|
|
793
|
-
}(),n=t?[t]:void 0;!function(e={}){const t=!e.skipBrowserExtensionCheck&&ZN(),n={...e,enabled:!t&&e.enabled,stackParser:(r=e.stackParser||RN,Array.isArray(r)?qw(...r):r),integrations:Yx({integrations:e.integrations,defaultIntegrations:null==e.defaultIntegrations?[Tk(),Nk(),jN(),FN(),VN(),XN(),Pk(),YN(),GN()]:e.defaultIntegrations}),transport:e.transport||AN};var r;dk(uN,n)}({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.
|
|
792
|
+
console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),_S=function(e){const{version:t,origin:n}=Jb(e.location.href);return"1.1655.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1655.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 wS(e,t){e.setClientId(t.clientId)}function xS(e){e.sync()}function kS(e,t){e.load(),t.load()}function NS(e,t,n){e.init(),t.init(),n.init()}function SS(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}yS.sentry&&_S&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null
|
|
793
|
+
}(),n=t?[t]:void 0;!function(e={}){const t=!e.skipBrowserExtensionCheck&&ZN(),n={...e,enabled:!t&&e.enabled,stackParser:(r=e.stackParser||RN,Array.isArray(r)?qw(...r):r),integrations:Yx({integrations:e.integrations,defaultIntegrations:null==e.defaultIntegrations?[Tk(),Nk(),jN(),FN(),VN(),XN(),Pk(),YN(),GN()]:e.defaultIntegrations}),transport:e.transport||AN};var r;dk(uN,n)}({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1655.0",beforeSend:(e,t)=>{if(JN>=5)return ov("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++JN;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{jx("host_config",Jb(window.location.href))}catch{}jx("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),
|
|
794
794
|
Fy(((e,t)=>{QN(e,t)}))}(yS.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),wS.$inject=["api","streamer"],xS.$inject=["router"],kS.$inject=["groups","session"],NS.$inject=["autosaveService","persistedDefaults","serviceURL"],SS.$inject=["frameSync","store","toastMessenger"];const AS=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",pv)}(),async function(e,t=window){const n=function(e){const t=Jb(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Qb,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:tv(t.origin),ancestorLevel:ev(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)
|
|
795
795
|
;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:nv(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await Zb(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=Zb(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,r)}else o=n;const i={...e,...o};return r&&(i.rpc=r),i.apiUrl=function(e){const t=Co(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(yS).then((e=>{!function(e,t){const n=new q
|
|
796
796
|
;n.register("analytics",fv).register("annotationsExporter",gy).register("annotationsService",bv).register("annotationActivity",gv).register("api",yy).register("apiRoutes",My).register("auth",Ly).register("autosaveService",Oy).register("dashboard",Ry).register("frameSync",Yy).register("groups",Jy).register("importAnnotationsService",tS).register("loadAnnotationsService",nS).register("localStorage",oS).register("persistedDefaults",aS).register("router",sS).register("serviceURL",lS).register("session",cS).register("streamer",hS).register("streamFilter",uS).register("tags",fS).register("threadsService",gS).register("thumbnailService",bS).register("toastMessenger",vS).register("store",{factory:_s}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(xS),n.run(NS),n.run(wS),n.run(kS),n.run(mv),n.run(SS),H(Qe(Lo.Provider,{value:n,children:Qe(Wb,{})}),t)}(e,AS)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),H(Qe(Kb,{error:e}),t)}(e,AS)));
|