hypothesis 1.1191.0 → 1.1192.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?d5e3ee","styles/annotator.css":"styles/annotator.css?06256b","styles/annotator.css.map":"styles/annotator.css.map?fc23a9","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?e9b69c","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","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?d2d454","styles/sidebar.css.map":"styles/sidebar.css.map?3774ea","styles/ui-playground.css":"styles/ui-playground.css?e7ad8b","styles/ui-playground.css.map":"styles/ui-playground.css.map?3790c8","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?ca6217","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?99ff43","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?cfed99","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?f830c0","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?e71b2f"};if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var p=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),u=l(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1192.0/");if(document.querySelector("hypothesis-app")){!function(s,n){r(s,"fetch",n.apiUrl),r(s,"fetch",n.apiUrl+"links");for(var a=0,i=["scripts/sidebar.bundle.js"];a<i.length;a++)e(s,o(n,i[a]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,o(n,c[l]))}(document,{assetRoot:u,manifest:c,apiUrl:p.apiUrl})}else{var d=p,h=l(d.notebookAppUrl||"https://hypothes.is/notebook"),y=l(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,a){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",a.sidebarAppUrl),n(s,"notebook","html",a.notebookAppUrl),r(s,"style",o(a,"styles/annotator.css")),n(s,"hypothesis-client","javascript",a.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)e(s,o(a,l[i]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)t(s,o(a,u[p]))}}(document,{assetRoot:u,manifest:c,notebookAppUrl: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?d5e3ee",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?06256b",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?fc23a9",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?6b4ebd",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"styles/sidebar.css.map": "styles/sidebar.css.map?3774ea",
|
|
13
13
|
"styles/ui-playground.css": "styles/ui-playground.css?e7ad8b",
|
|
14
14
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?3790c8",
|
|
15
|
-
"scripts/
|
|
16
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?3aede7",
|
|
15
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?ca6217",
|
|
17
16
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?99ff43",
|
|
18
17
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?cfed99",
|
|
19
|
-
"scripts/
|
|
18
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?f830c0",
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?e71b2f"
|
|
20
20
|
}
|
|
@@ -127,7 +127,7 @@ this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)}
|
|
|
127
127
|
;const n=No(t);if(!n)return;const i=en(n,null===(e=t.annotation)||void 0===e?void 0:e.$cluster);i.forEach((e=>{e._annotation=t.annotation})),t.highlights=i,this._hoveredAnnotations.has(t.annotation.$tag)&&rn(i,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=je.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&on(e.highlights);this._updateAnchors(n,e)}
|
|
128
128
|
_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+Et(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),ko(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);rn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(let r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue
|
|
129
129
|
;const t=sn(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Ze(n),o=Qe(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=So(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){
|
|
130
|
-
t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Jt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function To(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Ro(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.
|
|
130
|
+
t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Jt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function To(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Ro(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1192.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0]
|
|
131
131
|
;t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function Lo({config:t,groupId:e}){return ht("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:To(t.notebookAppUrl,{...Ro(t.notebookAppUrl,t),group:e})})}function Po({eventBus:t,config:e}){const[n,i]=K(0),[o,r]=K(!0),[s,a]=K(null),l=tt(""),c=tt(null);Q((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Q((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),Q((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ht("div",{className:h("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",
|
|
132
132
|
children:ht("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ht("div",{className:"absolute right-0 m-3",children:ht(Se,{title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark",children:ht(oe,{className:"w-4 h-4"})})}),ht(Lo,{config:e,groupId:s},n)]})})}class Oo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=Ie(this._outerContainer),B(ht(Po,{eventBus:e,config:n}),this.shadowRoot)}destroy(){B(null,this.shadowRoot),this._outerContainer.remove()}}var Mo={},Io={get exports(){return Mo},set exports(t){Mo=t}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i
|
|
133
133
|
;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=e.console&&(e.console.warn||e.console.log);return r&&r.call(e.console,o,i),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===o||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==o&&null!==i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign;var g=p((function(t,e,n){for(var i=Object.keys(e),r=0;r<i.length;)(!n||n&&t[i[r]]===o)&&(t[i[r]]=e[i[r]]),r++;return t}),"extend","Use `assign`."),m=p((function(t,e){return g(t,e,!0)
|
|
@@ -138,11 +138,11 @@ put:function(t,o){"NOT_FOUND"===r(t)&&(n.unshift({key:t,value:o}),n.length>e&&n.
|
|
|
138
138
|
"function"!=typeof l)throw new Error("createSelector expects an output function after the inputs, but received: ["+typeof l+"]");var c=s,u=c.memoizeOptions,d=void 0===u?n:u,h=Array.isArray(d)?d:[d],p=li(r),m=e.apply(void 0,[function(){return a++,l.apply(null,arguments)}].concat(h)),f=e((function(){for(var e=[],t=p.length,n=0;n<t;n++)e.push(p[n].apply(null,arguments));return i=m.apply(null,e)}));return Object.assign(f,{resultFunc:l,memoizedResultFunc:m,dependencies:p,lastResult:function(){return i},recomputations:function(){return a},resetRecomputations:function(){return a=0}}),f};return o}var ui=ci(si);function di(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function hi(e){const t=e.uri;let n;try{n=new URL(t).hostname}catch{n=""}"localhost"===n&&(n="");let r=n;return e.document&&e.document.title&&(r=e.document.title[0]),{uri:t,domain:n,title:r}}function pi(e){let t=e.uri;return t&&0!==t.indexOf("http://")&&0!==t.indexOf("https://")&&(t=null),e.links&&e.links.incontext&&(t=e.links.incontext),t}
|
|
139
139
|
function mi(e){const t=hi(e);let n="";if(t.uri&&0===t.uri.indexOf("file://")&&t.title){const e=t.uri.split("/"),r=e[e.length-1];r&&(n=r)}else t.domain&&t.domain!==t.title&&(n=t.domain);return n}function fi(e){let t=hi(e).title;return t.length>30&&(t=t.slice(0,30)+"…"),t}function gi(e){return(e.references||[]).length>0}function vi(e){return!!e.id}function bi(e){return!e.id}function _i(e){let t=!1;return e.permissions?(e.permissions.read.forEach((e=>{const n=e.split(":");2===n.length&&"group"===n[0]&&(t=!0)})),t):t}function wi(e){return!!(e.target&&e.target.length>0&&e.target[0].selector)}function yi(e){return wi(e)&&void 0===e.$orphan&&!e.$anchorTimeout}function xi(e){return!!e.hidden}function ki(e){return!!e.$highlight||!bi(e)&&!(Ni(e)||gi(e)||e.hidden||e.text||e.tags&&e.tags.length)}function Si(e){return wi(e)&&!0===e.$orphan}function Ni(e){return!wi(e)&&!gi(e)}function Ci(e){return!(!wi(e)||Si(e))}function Ei(e){return gi(e)?"Reply":ki(e)?"Highlight":Ni(e)?"Page note":"Annotation"}function Ai(e){
|
|
140
140
|
const t=e.target;let n,r;for(const e of null!==(o=null===(i=t[0])||void 0===i?void 0:i.selector)&&void 0!==o?o:[]){var o,i;"TextPositionSelector"===e.type?r=e.start:"EPUBContentSelector"===e.type&&e.cfi&&(n=e.cfi)}return{cfi:n,position:r}}function Ti(e){if(0===e.target.length)return null;const t=e.target[0];if(!t.selector)return null;const n=t.selector.find((e=>"TextQuoteSelector"===e.type));return n?n.exact:null}function Mi(e,t){return e.reduce(((e,n)=>t(n)?e+1:e),0)}function Li(e){const t={};return e.forEach((e=>t[e]=!0)),t}function zi(e){return Object.keys(e).filter((t=>!0===e[t]))}function Ri(e){return Object.entries(e)}const Ii={CHANGE_ROUTE:(e,{name:t,params:n})=>({name:t,params:n})};const Oi=ni({name:null,params:{}},{namespace:"route",reducers:Ii,actionCreators:{changeRoute:function(e,t={}){return ti(0,"CHANGE_ROUTE",{name:e,params:t})}},selectors:{route:function(e){return e.name},routeParams:function(e){return e.params}}}),Di={features:{},preferences:{},userid:null};const Bi={UPDATE_PROFILE:(e,t)=>({
|
|
141
|
-
profile:{...t.profile}})};const Pi=ni((function(e){var t;return{defaultAuthority:null!==(t=null==e?void 0:e.authDomain)&&void 0!==t?t:"",profile:Di}}),{namespace:"session",reducers:Bi,actionCreators:{updateProfile:function(e){return ti(0,"UPDATE_PROFILE",{profile:e})}},selectors:{defaultAuthority:function(e){return e.defaultAuthority},hasFetchedProfile:function(e){return e.profile!==Di},isFeatureEnabled:function(e,t){return!!e.profile.features[t]},isLoggedIn:function(e){return null!==e.profile.userid},profile:function(e){return e.profile}}});function Hi(e,t){return e.find((e=>e.id===t))}function Fi(e,t){return e.find((e=>e.$tag===t))}function ji(e,t,n){let r=e.$orphan;e.id||(r=!1);let o="other-content";return e.user===n&&(o=ki(e)?"user-highlights":"user-annotations"),Object.assign({},e,{$anchorTimeout:!1,$cluster:o,$tag:e.$tag||t,$orphan:r})}const Ui={ADD_ANNOTATIONS(e,t){const n=new Set,r=new Set,o=[],i=[],a=[];let s=e.nextTag;for(
|
|
142
|
-
!l&&i.$tag&&(l=Fi(e.annotations,i.$tag)),l?(a.push(Object.assign({},l,i)),i.id&&n.add(i.id),l.$tag&&r.add(l.$tag)):(o.push(ji(i,"t"+s,t.currentUserId)),++s)}for(
|
|
143
|
-
annotations:e.annotations.map((e=>{if(e.id&&e.id===t.id){if(e.flagged===t.isFlagged)return e;const n=Object.assign({},e,{flagged:t.isFlagged});if(n.moderation){const e=t.isFlagged?1:-1;n.moderation={...n.moderation,flagCount:n.moderation.flagCount+e}}return n}return e}))})};function qi(e){return(t,n)=>{const r=function(e,t){const n=new Set,r=new Set;for(
|
|
144
|
-
;const Qi=ni({annotations:[],
|
|
145
|
-
return ti(0,"UNHIDE_ANNOTATION",{id:e})},updateAnchorStatus:$i,updateFlagStatus:function(e,t){return ti(0,"UPDATE_FLAG_STATUS",{id:e,isFlagged:t})}},selectors:{allAnnotations:function(e){return e.annotations},annotationCount:Gi,annotationExists:function(e,t){return e.annotations.some((e=>e.id===t))},findAnnotationByID:function(e,t){return Hi(e.annotations,t)},findIDsForTags:function(e,t){const n=[];for(
|
|
141
|
+
profile:{...t.profile}})};const Pi=ni((function(e){var t;return{defaultAuthority:null!==(t=null==e?void 0:e.authDomain)&&void 0!==t?t:"",profile:Di}}),{namespace:"session",reducers:Bi,actionCreators:{updateProfile:function(e){return ti(0,"UPDATE_PROFILE",{profile:e})}},selectors:{defaultAuthority:function(e){return e.defaultAuthority},hasFetchedProfile:function(e){return e.profile!==Di},isFeatureEnabled:function(e,t){return!!e.profile.features[t]},isLoggedIn:function(e){return null!==e.profile.userid},profile:function(e){return e.profile}}});function Hi(e,t){return e.find((e=>e.id===t))}function Fi(e,t){return e.find((e=>e.$tag===t))}function ji(e,t,n){let r=e.$orphan;e.id||(r=!1);let o="other-content";return e.user===n&&(o=ki(e)?"user-highlights":"user-annotations"),Object.assign({},e,{$anchorTimeout:!1,$cluster:o,$tag:e.$tag||t,$orphan:r})}const Ui={ADD_ANNOTATIONS(e,t){const n=new Set,r=new Set,o=[],i=[],a=[];let s=e.nextTag;for(const i of t.annotations){let l;i.id&&(l=Hi(e.annotations,i.id)),
|
|
142
|
+
!l&&i.$tag&&(l=Fi(e.annotations,i.$tag)),l?(a.push(Object.assign({},l,i)),i.id&&n.add(i.id),l.$tag&&r.add(l.$tag)):(o.push(ji(i,"t"+s,t.currentUserId)),++s)}for(const t of e.annotations)n.has(t.id)||r.has(t.$tag)||i.push(t);return{annotations:o.concat(a).concat(i),nextTag:s}},CLEAR_ANNOTATIONS:()=>({annotations:[],highlighted:{},hovered:{}}),HOVER_ANNOTATIONS:(e,t)=>({hovered:Li(t.tags)}),HIDE_ANNOTATION:(e,t)=>({annotations:e.annotations.map((e=>e.id!==t.id?e:{...e,hidden:!0}))}),HIGHLIGHT_ANNOTATIONS:(e,t)=>({highlighted:t.highlighted}),REMOVE_ANNOTATIONS:(e,t)=>({annotations:[...t.remainingAnnotations]}),UNHIDE_ANNOTATION:(e,t)=>({annotations:e.annotations.map((e=>e.id!==t.id?e:Object.assign({},e,{hidden:!1})))}),UPDATE_ANCHOR_STATUS:(e,t)=>({annotations:e.annotations.map((e=>{if(!di(t.statusUpdates,e.$tag))return e;const n=t.statusUpdates[e.$tag];return"timeout"===n?Object.assign({},e,{$anchorTimeout:!0}):Object.assign({},e,{$orphan:"orphan"===n})}))}),UPDATE_FLAG_STATUS:(e,t)=>({
|
|
143
|
+
annotations:e.annotations.map((e=>{if(e.id&&e.id===t.id){if(e.flagged===t.isFlagged)return e;const n=Object.assign({},e,{flagged:t.isFlagged});if(n.moderation){const e=t.isFlagged?1:-1;n.moderation={...n.moderation,flagCount:n.moderation.flagCount+e}}return n}return e}))})};function qi(e){return(t,n)=>{const r=function(e,t){const n=new Set,r=new Set;for(const e of t)e.id&&n.add(e.id),e.$tag&&r.add(e.$tag);return e.filter((e=>!(e.id&&n.has(e.id)||e.$tag&&r.has(e.$tag))))}(n().annotations.annotations,e);t(ti(0,"REMOVE_ANNOTATIONS",{annotationsToRemove:e,remainingAnnotations:r}))}}function $i(e){return ti(0,"UPDATE_ANCHOR_STATUS",{statusUpdates:e})}const Gi=ui((e=>e.annotations),(e=>Mi(e,Ci)));const Vi=ui((e=>e.hovered),(e=>zi(e))),Yi=ui((e=>e.highlighted),(e=>zi(e)));const Wi=ui((e=>e.annotations),(e=>e.some(yi))),Ki=ui((e=>e.annotations),(e=>e.filter((e=>bi(e)&&!ki(e))))),Zi=ui((e=>e.annotations),(e=>e.filter((e=>bi(e)&&ki(e))))),Xi=ui((e=>e.annotations),(e=>Mi(e,Ni))),Ji=ui((e=>e.annotations),(e=>Mi(e,Si)))
|
|
144
|
+
;const Qi=ni({annotations:[],highlighted:{},hovered:{},nextTag:1},{namespace:"annotations",reducers:Ui,actionCreators:{addAnnotations:function(e){return function(t,n){const r=e.filter((e=>!e.id||!Hi(n().annotations.annotations,e.id))),o=Pi.selectors.profile(n().session);if(t(ti(0,"ADD_ANNOTATIONS",{annotations:e,currentAnnotationCount:n().annotations.annotations.length,currentUserId:o.userid})),"sidebar"!==Oi.selectors.route(n().route))return;const i=r.filter(yi).map((e=>e.id));i.length>0&&setTimeout((()=>{const e=n().annotations.annotations,r=i.map((t=>t?Hi(e,t):null)).filter((e=>e&&yi(e))).reduce(((e,t)=>(e[t.$tag]="timeout",e)),{});t($i(r))}),500)}},clearAnnotations:function(){return ti(0,"CLEAR_ANNOTATIONS",void 0)},hoverAnnotations:function(e){return ti(0,"HOVER_ANNOTATIONS",{tags:e})},hideAnnotation:function(e){return ti(0,"HIDE_ANNOTATION",{id:e})},highlightAnnotations:function(e){return ti(0,"HIGHLIGHT_ANNOTATIONS",{highlighted:Li(e)})},removeAnnotations:qi,unhideAnnotation:function(e){
|
|
145
|
+
return ti(0,"UNHIDE_ANNOTATION",{id:e})},updateAnchorStatus:$i,updateFlagStatus:function(e,t){return ti(0,"UPDATE_FLAG_STATUS",{id:e,isFlagged:t})}},selectors:{allAnnotations:function(e){return e.annotations},annotationCount:Gi,annotationExists:function(e,t){return e.annotations.some((e=>e.id===t))},findAnnotationByID:function(e,t){return Hi(e.annotations,t)},findIDsForTags:function(e,t){const n=[];for(const r of t){const t=Fi(e.annotations,r);t&&t.id&&n.push(t.id)}return n},hoveredAnnotations:Vi,highlightedAnnotations:Yi,isAnnotationHovered:function(e,t){return!0===e.hovered[t]},isWaitingToAnchorAnnotations:Wi,newAnnotations:Ki,newHighlights:Zi,noteCount:Xi,orphanCount:Ji,savedAnnotations:function(e){return e.annotations.filter((e=>vi(e)))}}}),ea={SET_DEFAULT:(e,t)=>({[t.defaultKey]:t.value})};const ta=ni({annotationPrivacy:null,focusedGroup:null},{namespace:"defaults",reducers:ea,actionCreators:{setDefault:function(e,t){return ti(0,"SET_DEFAULT",{defaultKey:e,value:t})}},selectors:{getDefault:function(e,t){
|
|
146
146
|
return e[t]},getDefaults:function(e){return e}}});const na={UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED:(e,t)=>({directLinkedGroupFetchFailed:t.directLinkedGroupFetchFailed}),UPDATE_DIRECT_LINKED_GROUP_ID:(e,t)=>({directLinkedGroupId:t.directLinkedGroupId}),UPDATE_DIRECT_LINKED_ANNOTATION_ID:(e,t)=>({directLinkedAnnotationId:t.directLinkedAnnotationId}),CLEAR_DIRECT_LINKED_IDS:()=>({directLinkedAnnotationId:null,directLinkedGroupId:null}),CLEAR_SELECTION:()=>({directLinkedAnnotationId:null,directLinkedGroupId:null,directLinkedGroupFetchFailed:!1})};const ra=ni((function(e){return{directLinkedGroupId:e.group||null,directLinkedAnnotationId:e.annotations||null,directLinkedGroupFetchFailed:!1}}),{namespace:"directLinked",reducers:na,actionCreators:{setDirectLinkedGroupFetchFailed:function(){return ti(0,"UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED",{directLinkedGroupFetchFailed:!0})},setDirectLinkedGroupId:function(e){return ti(0,"UPDATE_DIRECT_LINKED_GROUP_ID",{directLinkedGroupId:e})},
|
|
147
147
|
setDirectLinkedAnnotationId:function(e){return ti(0,"UPDATE_DIRECT_LINKED_ANNOTATION_ID",{directLinkedAnnotationId:e})},clearDirectLinkedGroupFetchFailed:function(){return ti(0,"UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED",{directLinkedGroupFetchFailed:!1})},clearDirectLinkedIds:function(){return ti(0,"CLEAR_DIRECT_LINKED_IDS",void 0)}},selectors:{directLinkedAnnotationId:function(e){return e.directLinkedAnnotationId},directLinkedGroupFetchFailed:function(e){return e.directLinkedGroupFetchFailed},directLinkedGroupId:function(e){return e.directLinkedGroupId}}});class oa{constructor(e,t){this.annotation={id:e.id,$tag:e.$tag},this.isPrivate=t.isPrivate,this.tags=t.tags,this.text=t.text}match(e){return this.annotation.$tag&&e.$tag===this.annotation.$tag||this.annotation.id&&e.id===this.annotation.id}isEmpty(){return!this.text&&0===this.tags.length}}const ia={DISCARD_ALL_DRAFTS:()=>({drafts:[]}),REMOVE_DRAFT:(e,t)=>({drafts:e.drafts.filter((e=>!e.match(t.annotation)))}),UPDATE_DRAFT(e,t){
|
|
148
148
|
const n=e.drafts.filter((e=>!e.match(t.draft.annotation)));return n.push(t.draft),{drafts:n}}};function aa(e){return ti(0,"REMOVE_DRAFT",{annotation:e})}function sa(e,t){const n=e.drafts;for(let e=0;e<n.length;e++){const r=n[e];if(r.match(t))return r}return null}function la(e,t){const n=sa(e,t);return n?n.isEmpty()?null:n:null}const ca=ui((e=>e.drafts),(e=>e.filter((e=>!e.annotation.id)).map((e=>e.annotation)))),ua=ni({drafts:[]},{namespace:"drafts",reducers:ia,actionCreators:{createDraft:function(e,t){return ti(0,"UPDATE_DRAFT",{draft:new oa(e,t)})},deleteNewAndEmptyDrafts:function(){return(e,t)=>{const n=t().drafts.drafts.filter((e=>!e.annotation.id&&!la(t().drafts,e.annotation))).map((t=>(e(aa(t.annotation)),t.annotation)));e(qi(n))}},discardAllDrafts:function(){return ti(0,"DISCARD_ALL_DRAFTS",void 0)},removeDraft:aa},selectors:{countDrafts:function(e){return e.drafts.length},getDraft:sa,getDraftIfNotEmpty:la,unsavedAnnotations:ca}});function da(e){var t,n
|
|
@@ -635,7 +635,7 @@ align:n.align,isWindow:n.isWindow||Bv,maxSynchronousAlignments:d,end:u,scrollAnc
|
|
|
635
635
|
variant:"primary",onClick:e,children:"Log in"})]})]})}function $v({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i}){const a=()=>{r||i()},s=t>0?`${o} (${t} available)`:o;return Qr(Xc,{classes:Kn("bg-transparent min-w-[5.25rem]",{"font-bold":r}),color:"text",onClick:a,onMouseDown:a,pressed:!!r,role:"tab",tabIndex:0,title:s,underline:"none",children:Qr(nr,{children:[e,t>0&&!n&&Qr("span",{className:"relative bottom-[3px] left-[2px] text-[10px]",children:t})]})})}var Gv=Oo((function({annotationsService:e,isLoading:t,settings:n}){const r=is(),o=r.selectedTab(),i=r.noteCount(),a=r.annotationCount(),s=r.orphanCount(),l=r.isWaitingToAnchorAnnotations(),c=e=>{r.clearSelection(),r.selectTab(e)},u="annotation"===o&&0===a&&!l,d="note"===o&&0===i;return Qr("div",{className:Kn("space-y-3 pb-[9px]"),children:[Qr("div",{className:"flex gap-x-6 theme-clean:ml-[15px]",role:"tablist",children:[Qr($v,{count:a,isWaitingToAnchor:l,isSelected:"annotation"===o,label:"Annotations",onSelect:()=>c("annotation"),
|
|
636
636
|
children:"Annotations"}),Qr($v,{count:i,isWaitingToAnchor:l,isSelected:"note"===o,label:"Page notes",onSelect:()=>c("note"),children:"Page Notes"}),s>0&&Qr($v,{count:s,isWaitingToAnchor:l,isSelected:"orphan"===o,label:"Orphans",onSelect:()=>c("orphan"),children:"Orphans"})]}),"note"===o&&n.enableExperimentalNewNoteButton&&Qr("div",{className:"flex justify-end",children:Qr(Fc,{"data-testid":"new-note-button",onClick:()=>e.createPageNote(),variant:"primary",style:Ro(["ctaBackgroundColor"],n),children:[Qr(mc,{}),"New note"]})}),!t&&d&&Qr(Vc,{"data-testid":"notes-unavailable-message",variant:"flat",children:Qr(Yc,{classes:"text-center",children:"There are no page notes in this group."})}),!t&&u&&Qr(Vc,{"data-testid":"annotations-unavailable-message",variant:"flat",children:Qr(Yc,{classes:"text-center !space-y-1",children:[Qr("p",{children:"There are no annotations in this group."}),Qr("p",{children:["Create one by selecting some text and clicking the"," ",Qr(ol,{className:"w-em h-em inline m-0.5 -mt-0.5",
|
|
637
637
|
title:"Annotate"})," ","button."]})]})})]})}),["annotationsService","settings"]);var Vv=Oo((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const i=Bs(),a=is(),s=a.focusedGroupId(),l=a.hasAppliedFilter()||a.hasSelectedAnnotations(),c=a.isLoading(),u=a.isLoggedIn(),d=a.directLinkedAnnotationId(),h=d?a.findAnnotationByID(d):void 0,p=h?Cs(h):"annotation",m=a.searchUris(),f=a.hasSidebarOpened(),g=a.profile().userid,v=!(c||!d)&&!h,b=a.directLinkedGroupFetchFailed(),_=v||b,w=!_,y=!_&&!l,x=d&&!u&&!v&&!c,k=jr(s);Hr((()=>{if(!k.current||k.current!==s){if(k.current){const e=a.focusState().active;a.clearSelection(),e&&a.toggleFocusMode(!0)}k.current=s}s&&m.length&&r.load({groupId:s,uris:m})}),[a,r,s,g,m]),Hr((()=>{h&&!1===h.$orphan?(e.hoverAnnotation(h),e.scrollToAnnotation(h),a.selectTab(p)):h&&a.selectTab(p)}),[p,e,h,a]);const S=a.hasFetchedProfile();return Hr((()=>{S&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[S,u,f,o]),Qr("div",{children:[Qr("h2",{className:"sr-only",
|
|
638
|
-
children:"Annotations"}),w&&Qr(Rv,{}),Qr(qv,{onLogin:t,onSignUp:n}),v&&Qr(Mv,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),b&&Qr(Mv,{errorType:"group",onLoginRequest:t}),y&&Qr(Gv,{isLoading:c}),Qr(Tv,{threads:i.children}),x&&Qr(Iv,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Yv=Oo((function({api:e,toastMessenger:t}){const n=is(),r=n.routeParams().q,o=qr((async t=>{const r={_separate_replies:!0,offset:0,limit:20,..._s(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Hr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Qr(Tv,{threads:Bs().children})}),["api","toastMessenger"]);class Wv{constructor(e,t,n=window){var r,o,i,a;const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.
|
|
638
|
+
children:"Annotations"}),w&&Qr(Rv,{}),Qr(qv,{onLogin:t,onSignUp:n}),v&&Qr(Mv,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),b&&Qr(Mv,{errorType:"group",onLoginRequest:t}),y&&Qr(Gv,{isLoading:c}),Qr(Tv,{threads:i.children}),x&&Qr(Iv,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Yv=Oo((function({api:e,toastMessenger:t}){const n=is(),r=n.routeParams().q,o=qr((async t=>{const r={_separate_replies:!0,offset:0,limit:20,..._s(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Hr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Qr(Tv,{threads:Bs().children})}),["api","toastMessenger"]);class Wv{constructor(e,t,n=window){var r,o,i,a;const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.1192.0",this.userAgent=n.navigator.userAgent,
|
|
639
639
|
this.urls=t.map((e=>e.uri)).join(", ")||s,this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(i=o.metadata)||void 0===i?void 0:i.documentFingerprint)&&void 0!==r?r:s,this.account=l,this.timestamp=(new Date).toString();const c=null===(a=t[0])||void 0===a?void 0:a.segment;if(c){const e=[];c.cfi&&e.push(["CFI",c.cfi]),c.url&&e.push(["URL",c.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())}}function Kv(e){const n=t(e);return!(null==n||!n.authority)&&n.authority!==e.authDomain}function Zv({commandName:e,icon:t}){return Qr("span",{className:"whitespace-nowrap","data-testid":"instruction",children:[Qr(t,{className:Kn("w-em h-em","mx-1 -mt-1","text-color-text-light inline")}),Qr("em",{"data-testid":"command-name",children:e})]})}
|
|
640
640
|
var Xv=Oo((function({settings:e}){const t=!Kv(e);return Qr("ol",{className:"list-decimal pl-10 space-y-2",children:[Qr("li",{children:["To create an annotation, select text and then select the"," ",Qr(Zv,{icon:ol,commandName:"Annotate"})," button."]}),Qr("li",{children:["To create a highlight (",Qr(Zc,{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"," ",Qr(Zv,{icon:Jl,commandName:"Highlight"})," button."]}),t&&Qr("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"," ",Qr(Zc,{href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",underline:"always",children:"join link"}),"."]}),Qr("li",{children:["To reply to an annotation, select the"," ",Qr(Zv,{icon:Sc,commandName:"Reply"})," button."]})]})}),["settings"]);function Jv({label:e,children:t,classes:n}){
|
|
641
641
|
return Qr(nr,{children:[Qr("dt",{className:"col-span-1 sm:text-right font-medium",children:e}),Qr("dd",{className:Kn("col-span-1 sm:col-span-3 text-color-text-light break-words",n),children:t})]})}var Qv=Oo((function({toastMessenger:e,versionData:t}){return Qr("div",{className:"space-y-4",children:[Qr("dl",{className:"grid grid-cols-1 sm:grid-cols-4 sm:gap-x-2",children:[Qr(Jv,{label:"Version",children:t.version}),Qr(Jv,{label:"User Agent",children:t.userAgent}),Qr(Jv,{classes:Kn("break-all"),label:"URL",children:t.urls}),Qr(Jv,{label:"Fingerprint",children:t.fingerprint}),t.segment&&Qr(Jv,{label:"Segment",children:t.segment}),Qr(Jv,{label:"Account",children:t.account}),Qr(Jv,{label:"Date",children:t.timestamp})]}),Qr("div",{className:"flex items-center justify-center",children:Qr(Fc,{onClick:()=>{try{cu(t.asFormattedString()),e.success("Copied version info to clipboard")}catch(t){e.error("Unable to copy version info")}},icon:Sl,children:"Copy version details"})})]})}),["toastMessenger"])
|
|
@@ -666,7 +666,7 @@ children:[Qr(_b,{}),Qr(nb,{}),Qr(vb,{}),l&&Qr("main",{children:["annotation"===l
|
|
|
666
666
|
permissions:iu(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:s,$tag:l,hidden:!1,links:{},document:{title:""}},e);return ki(c)&&(c.permissions=ru(i)),c}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),ki(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!_i(n)}),Ni(n)?this._store.selectTab("note"):Ci(n)&&this._store.selectTab("annotation"),(n.references||[]).forEach((e=>{this._store.setExpanded(e,!0)}))}createPageNote(){const e=this._store.mainFrame();if(!this._store.isLoggedIn())return void this._store.openSidebarPanel("loginPrompt");if(!e)return;const t={target:[],uri:e.uri};this.create(t)}async delete(e){await this._api.annotation.delete({id:e.id}),this._activity.reportActivity("delete",e),this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._activity.reportActivity("flag",e),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,
|
|
667
667
|
permissions:_i(e)?ou(t,e.group):ru(t),references:(e.references||[]).concat(e.id),target:[{source:e.target[0].source}],uri:e.uri};this.create(n)}async save(e){let t,n;const r=this._applyDraftChanges(e);let o;vi(e)?(t=this._api.annotation.update({id:e.id},r),n="update"):(t=this._api.annotation.create({},r),n="create"),this._store.annotationSaveStarted(e);try{o=await t,this._activity.reportActivity(n,o)}finally{this._store.annotationSaveFinished(e)}for(let[t,n]of Object.entries(e))if(t.startsWith("$")){o[t]=n}return this._store.removeDraft(e),this._store.addAnnotations([o]),o}}Bb.$inject=["annotationActivity","api","store"];class Pb{constructor(e){this._rpc=e.rpc,this._reportConfig=e.reportActivity}reportActivity(e,t){if(!this._rpc||!this._reportConfig)return;let n;switch(e){case"create":n=new Date(t.created).toISOString();break;case"update":n=new Date(t.updated).toISOString();break;default:n=(new Date).toISOString()}const r={date:n,annotation:{id:t.id,isShared:au(t.permissions)}}
|
|
668
668
|
;this._reportConfig.events.includes(e)&&function(e,t,n,r=[]){const o={jsonrpc:"2.0",method:n,params:r};e.postMessage(o,t)}(this._rpc.targetFrame,this._rpc.origin,this._reportConfig.method,[e,r])}}Pb.$inject=["settings"];class Hb 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 Fb(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Hb(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new Hb(e,n,"Failed to parse response")}var o;if(!n.ok)throw new Hb(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function jb(e){const t={};for(let[n,r]of Object.entries(e))n.startsWith("$")||(t[n]=r);return t}function Ub(e){return"url"in e}function qb(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,l]=await Promise.all([e,n()]),c=function(e,t){let n=e;const r=t.split(".")
|
|
669
|
-
;for(let[e,t]of r.entries()){const o=n[t];if(!o||Ub(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.
|
|
669
|
+
;for(let[e,t]of r.entries()){const o=n[t];if(!o||Ub(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.1192.0"};l&&(u.Authorization="Bearer "+l);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:p}=La(c.url,a),m=new URL(h);for(let[e,t]of Object.entries(p)){Array.isArray(t)||(t=[t]);for(let n of t)null!=n&&m.searchParams.append(e,n.toString())}return await Fb(m.toString(),{body:s?JSON.stringify(jb(s)):null,headers:u,method:c.method})}finally{i()}}}class $b{constructor(e,t,n){const r=e.routes();this._clientId=null;const o=()=>this._clientId,i=e=>qb(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"),
|
|
670
670
|
hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")}}setClientId(e){this._clientId=e}}$b.$inject=["apiRoutes","auth","store"];var Gb={},Vb={get exports(){return Gb},set exports(e){Gb=e}},Yb={};function Wb(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))}var Kb=Wb;Wb.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},Wb.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),
|
|
671
671
|
this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},Wb.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},Wb.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(){
|
|
672
672
|
n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},Wb.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},Wb.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},Wb.prototype.start=Wb.prototype.try,Wb.prototype.errors=function(){return this._errors},Wb.prototype.attempts=function(){return this._attempts},Wb.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},function(e){var t=Kb;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]
|
|
@@ -703,7 +703,7 @@ this._sendClientConfig(o)})),o.on("disconnect",(()=>{if(++this._reconnectionAtte
|
|
|
703
703
|
if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${p(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject("hypothesis.user.tags.map")||{};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("hypothesis.user.tags.map",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("hypothesis.user.tags.list",n)}}A_.$inject=["localStorage"];class T_{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}T_.$inject=["store"];class M_{constructor(e){this._store=e}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}
|
|
704
704
|
_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r="",visuallyHidden:o=!1}={}){if(this._store.hasToastMessage(e,t))return;const i=a(10),s={type:e,id:i,message:t,moreInfoURL:r,visuallyHidden:o};this._store.addToastMessage({isDismissed:!1,...s}),n&&setTimeout((()=>{this.dismiss(i)}),5e3)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}M_.$inject=["store"];class L_{constructor(){this._providers=new Map,this._instances=new Map,this._constructing=new Set}get(e){if(this._instances.has(e))return this._instances.get(e);const t=this._providers.get(e);if(!t)throw new Error(`"${e}" is not registered`);if("value"in t)return this._instances.set(e,t.value),t.value;if(this._constructing.has(e))throw new Error(`Encountered a circular dependency when constructing "${e}"`);this._constructing.add(e);try{const n=[],r="class"in t&&t.class.$inject||"factory"in t&&t.factory.$inject||[];for(const t of r)try{n.push(this.get(t))}catch(n){
|
|
705
705
|
const r=new Error(`Failed to construct dependency "${t}" of "${e}": ${n.message}`);throw r.cause=n,r}let o;if(t.class)o=new t.class(...n);else{o=(0,t.factory)(...n)}return this._instances.set(e,o),o}finally{this._constructing.delete(e)}}register(e,t){if("function"==typeof t)t={class:t};else if(!function(e){return"object"==typeof e&&null!==e&&("value"in e||"function"==typeof e.class||"function"==typeof e.factory)}(t))throw new Error(`Invalid provider for "${e}"`);return this._providers.set(e,t),this}run(e){const t="Injector.run";this.register(t,{factory:e});try{return this.get(t)}finally{this._instances.delete(t),this._providers.delete(t)}}}const z_=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),R_=function(t){const{version:n,origin:r}=e(t.location.href)
|
|
706
|
-
;return"1.
|
|
706
|
+
;return"1.1192.0"!==n?(console.warn(`The Hypothesis sidebar is using a different version (1.1192.0) than the host page (${n}). It may not work.`),!1):"null"===t.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):t.origin===r||(console.warn(`The Hypothesis sidebar is running in a different origin (${t.origin}) than expected (${r}). It may not work.`),!1)}(window);function I_(e,t){e.setClientId(t.clientId)}function O_(e,t,n){e.load(),t.load(),n.sync()}function D_(e,t,n){e.init(),t.init(),n.init()}function B_(e,t){"sidebar"===t.route()&&e.connect()}z_.sentry&&R_&&function(t){const n=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),r=n?[n]:void 0;Dn({dsn:t.dsn,environment:t.environment,allowUrls:r,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1192.0",beforeSend:(e,t)=>{if(Hn>=5)return u("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Hn;try{const n=t&&t.originalException
|
|
707
707
|
;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch(e){}return e}});try{bt("host_config",e(window.location.href))}catch(e){}bt("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Pn(((e,t)=>{vt(e,{tags:{context:t}})}))}(z_.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;if("A"===t.tagName){const e=t;"_blank"===e.target&&(e.rel="noopener")}}))}(document.body),I_.$inject=["api","streamer"],O_.$inject=["groups","session","router"],D_.$inject=["autosaveService","persistedDefaults","serviceURL"],B_.$inject=["frameSync","store"],function(e,{reset:t=!1}={}){t&&eo.clear();for(let[t,n]of Object.entries(e))eo.set(t,n)}(Mo);const P_=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",v)}(),async function(i,a=window){const c=function(t){
|
|
708
708
|
const i=e(t.location.href),a=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],s={openSidebar:n,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:o(t.origin),ancestorLevel:r(t.ancestorLevel)}}},l={};for(let[e,t]of Object.entries(i))a.includes(e)&&null!==t&&(s[e]?l[e]=s[e](t):l[e]=t);return l}(window),u=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:l(n.ancestorLevel,t),origin:n.origin}}(c,a);let d;if(u){const e=await async function(e,t){return{...await s(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(c,u);d=function(e,t){const n=e.services
|
|
709
709
|
;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=s(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,u)}else d=c;const h={...i,...d};return u&&(h.rpc=u),h.apiUrl=function(e){const n=t(e);if(n){if(n.apiUrl)return n.apiUrl;throw new Error("Service should contain an apiUrl value.")}return e.apiUrl}(h),h}(z_).then((e=>{!function(e,t){const n=new L_;n.register("annotationsService",Bb).register("annotationActivity",Pb).register("api",$b).register("apiRoutes",Qb).register("auth",n_).register("autosaveService",r_).register("frameSync",p_).register("groups",g_).register("loadAnnotationsService",v_).register("localStorage",__).register("persistedDefaults",y_).register("router",x_).register("serviceURL",k_).register("session",S_).register("streamer",E_).register("streamFilter",N_).register("tags",A_).register("threadsService",T_).register("toastMessenger",M_).register("store",{factory:os}),n.register("$window",{
|