hypothesis 1.1287.0 → 1.1288.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 +1 -1
- package/build/manifest.json +7 -7
- package/build/scripts/annotator.bundle.js +1 -1
- package/build/scripts/sidebar.bundle.js +6 -6
- package/build/scripts/sidebar.bundle.js.map +1 -1
- package/build/styles/sidebar.css +4 -0
- package/build/styles/sidebar.css.map +1 -1
- package/build/styles/ui-playground.css +4 -0
- package/build/styles/ui-playground.css.map +1 -1
- package/package.json +1 -1
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?da59fd","styles/annotator.css":"styles/annotator.css?3b7633","styles/annotator.css.map":"styles/annotator.css.map?8cd8b2","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?185199","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?d1f501","styles/sidebar.css.map":"styles/sidebar.css.map?fe1c72","styles/ui-playground.css":"styles/ui-playground.css?9cb29f","styles/ui-playground.css.map":"styles/ui-playground.css.map?5adc66","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?aa4d84","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?cb51f5","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?966424","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?75a653","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?ef9f1f"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(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)}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 l=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),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1288.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s,t;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(t=s.runtime)||void 0===t?void 0:t.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 u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,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,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:d,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?da59fd",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?3b7633",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?8cd8b2",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?6b4ebd",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"styles/katex.min.css.map": "styles/katex.min.css.map?42d80c",
|
|
9
9
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
|
|
10
10
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
|
|
11
|
-
"styles/sidebar.css
|
|
12
|
-
"styles/
|
|
13
|
-
"styles/ui-playground.css
|
|
14
|
-
"styles/
|
|
15
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?360efc",
|
|
11
|
+
"styles/sidebar.css": "styles/sidebar.css?d1f501",
|
|
12
|
+
"styles/sidebar.css.map": "styles/sidebar.css.map?fe1c72",
|
|
13
|
+
"styles/ui-playground.css": "styles/ui-playground.css?9cb29f",
|
|
14
|
+
"styles/ui-playground.css.map": "styles/ui-playground.css.map?5adc66",
|
|
16
15
|
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?aa4d84",
|
|
16
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?cb51f5",
|
|
17
17
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?966424",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?75a653",
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?ef9f1f"
|
|
20
20
|
}
|
|
@@ -122,7 +122,7 @@ persistent:null!==(n=null===(i=(o=this._integration).persistFrame)||void 0===i?v
|
|
|
122
122
|
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=Xe.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&&cn(e.highlights);this._updateAnchors(n,e)}_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=[]
|
|
123
123
|
;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}))),s={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Oo(),s}_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);hn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(const r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue;const t=un(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){
|
|
124
124
|
const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=tn(n),o=on(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=To(),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){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){
|
|
125
|
-
this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Vt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Io(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Do(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.
|
|
125
|
+
this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Vt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Io(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Do(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1288.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];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}
|
|
126
126
|
function Fo({config:t,groupId:e}){return zt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:Io(t.notebookAppUrl,{...Do(t.notebookAppUrl,t),group:e})})}function Bo({eventBus:t,config:e}){const[n,i]=At(0),[o,r]=At(!0),[s,a]=At(null),l=Tt(""),c=Tt(null);Rt((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Rt((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),Rt((()=>{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:zt("div",{className:be("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:zt("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[zt("div",{className:"absolute right-0 m-3",children:zt(Ae,{title:"Close the Notebook",onClick:()=>{var t;r(!0),
|
|
127
127
|
null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark",classes:be("!bg-transparent enabled:hover:!bg-grey-3"),children:zt(Yt,{className:"w-4 h-4"})})}),zt(Fo,{config:e,groupId:s},n)]})})}class Ho{constructor(t,e,i){n(this,"_outerContainer",void 0),n(this,"_shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this._shadowRoot=Ie(this._outerContainer),dt(zt(Bo,{eventBus:e,config:i}),this._shadowRoot)}destroy(){dt(null,this._shadowRoot),this._outerContainer.remove()}}function Vo({eventBus:t,config:e}){const[n,i]=At(!0),o=Tt(null);Rt((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{i(!1)})),o.current=e,()=>{e.destroy()}}),[t]);return n?null:zt("div",{className:"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50","data-testid":"profile-outer",children:zt("div",{className:"relative w-full h-full","data-testid":"profile-inner",children:[zt("div",{className:"absolute right-0 m-3",children:zt(Ae,{
|
|
128
128
|
title:"Close the Profile",onClick:()=>{var t;i(!0),null===(t=o.current)||void 0===t||t.publish("closeProfile")},variant:"dark",classes:be("!bg-transparent enabled:hover:!bg-grey-3"),children:zt(Yt,{className:"w-4 h-4"})})}),zt("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class Uo{constructor(t,e,i){n(this,"_outerContainer",void 0),n(this,"shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-profile"),t.appendChild(this._outerContainer),this.shadowRoot=Ie(this._outerContainer),dt(zt(Vo,{eventBus:e,config:i}),this.shadowRoot)}destroy(){dt(null,this.shadowRoot),this._outerContainer.remove()}}var qo={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,h=Math.abs,u=Date.now;function d(t,e,n){return setTimeout(b(t,n),e)}function f(t,e,n){return!!Array.isArray(t)&&(p(t,n[e],n),!0)}function p(t,e,n){var i
|
|
@@ -493,7 +493,7 @@ o=n.subParser("makeMarkdown.strikethrough")(e,t);break;case"a":o=n.subParser("ma
|
|
|
493
493
|
var r,o,i="",a=[[],[]],s=e.querySelectorAll("thead>tr>th"),l=e.querySelectorAll("tbody>tr");for(r=0;r<s.length;++r){var c=n.subParser("makeMarkdown.tableCell")(s[r],t),u="---";if(s[r].hasAttribute("style"))switch(s[r].getAttribute("style").toLowerCase().replace(/\s/g,"")){case"text-align:left;":u=":---";break;case"text-align:right;":u="---:";break;case"text-align:center;":u=":---:"}a[0][r]=c.trim(),a[1][r]=u}for(r=0;r<l.length;++r){var d=a.push([])-1,h=l[r].getElementsByTagName("td");for(o=0;o<s.length;++o){var m=" ";void 0!==h[o]&&(m=n.subParser("makeMarkdown.tableCell")(h[o],t)),a[d].push(m)}}var p=3;for(r=0;r<a.length;++r)for(o=0;o<a[r].length;++o){var f=a[r][o].length;f>p&&(p=f)}for(r=0;r<a.length;++r){for(o=0;o<a[r].length;++o)1===r?":"===a[r][o].slice(-1)?a[r][o]=n.helper.padEnd(a[r][o].slice(-1),p-1,"-")+":":a[r][o]=n.helper.padEnd(a[r][o],p,"-"):a[r][o]=n.helper.padEnd(a[r][o],p);i+="| "+a[r].join(" | ")+" |\n"}return i.trim()})),n.subParser("makeMarkdown.tableCell",(function(e,t){var r=""
|
|
494
494
|
;if(!e.hasChildNodes())return"";for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t,!0);return r.trim()})),n.subParser("makeMarkdown.txt",(function(e){var t=e.nodeValue;return t=(t=t.replace(/ +/g," ")).replace(/¨NBSP;/g," "),t=(t=(t=(t=(t=(t=(t=(t=(t=n.helper.unescapeHTMLEntities(t)).replace(/([*_~|`])/g,"\\$1")).replace(/^(\s*)>/g,"\\$1>")).replace(/^#/gm,"\\#")).replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3")).replace(/^( {0,3}\d+)\./gm,"$1\\.")).replace(/^( {0,3})([+-])/gm,"$1\\$2")).replace(/]([\s]*)\(/g,"\\]$1\\(")).replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:")}));t.exports?t.exports=n:this.showdown=n}).call(e)}(Ch);var Mh=t(Ch.exports);const Ih=Cs(window);function zh(){return[{type:"output",filter:function(e){return e.replace(/<a href=/g,'<a target="_blank" href=')}}]}let Rh;function Lh(e){return"{math:"+e.toString()+"}"}function Oh(e){const t=function(e){const t=[];let n=0,r=e;for(;;){const e=r.indexOf("$$",n),o=r.indexOf("\\(",n);if(-1===e&&-1===o)break;let i,a
|
|
495
495
|
;if(-1!==e&&(-1===o||e<o)?(i=e,a=r.indexOf("$$",i+2)):(i=o,a=r.indexOf("\\)",i+2)),-1===a)break;a+=2;const s=t.length+1,l=Lh(s);let c;t.push({id:s,expression:r.slice(i+2,a-2),inline:-1!==o}),c=-1!==o?l:"\n\n"+l+"\n\n",r=r.slice(0,i)+c+r.slice(a),n=i+c.length}return{mathBlocks:t,content:r}}(e),n=Ih.sanitize(function(e){return Rh||(Rh=new Mh.Converter({extensions:[zh],simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0})),Rh.makeHtml(e)}(t.content)),r=function(e,t){return t.reduce(((e,t)=>{let n;try{n=t.inline?Ah.renderToString(t.expression):Ah.renderToString(t.expression,{displayMode:!0})}catch(e){n=zs(t.expression)}return e.replace(Lh(t.id),n)}),e)}(n,t.mathBlocks);return r}function Dh({children:e,classes:t,...n}){return Ee("div",{dir:"auto",lang:"",className:X("StyledText",t),...n,children:e})}function Ph({markdown:e,classes:t,style:n}){const r=de((()=>e?Oh(e):""),[e]),o=ue(null);return le((()=>{!function(e,{className:t}={}){
|
|
496
|
-
const n=Array.from(e.getElementsByTagName("a"));for(const e of n){const n=La(e);n&&(t?n.className=t:n.style.width="350px")}}(o.current,{className:"w-full md:w-[380px]"})}),[e]),Ee("div",{className:"w-full break-
|
|
496
|
+
const n=Array.from(e.getElementsByTagName("a"));for(const e of n){const n=La(e);n&&(t?n.className=t:n.style.width="350px")}}(o.current,{className:"w-full md:w-[380px]"})}),[e]),Ee("div",{className:"w-full break-anywhere cursor-text",children:Ee(Dh,{children:Ee("div",{className:t,"data-testid":"markdown-text",ref:o,dangerouslySetInnerHTML:{__html:r},style:n})})})}function Bh({children:e}){return Ee("ul",{className:"flex flex-wrap gap-2 leading-none","aria-label":"Annotation tags",children:e})}function Fh({href:e,onRemoveTag:t,tag:n}){return Ee("li",{className:"flex items-center border rounded-sm bg-grey-0",children:[Ee("div",{className:"grow px-1.5 py-1 touch:p-2",children:e?Ee(er,{variant:"text-light",href:e,lang:"",target:"_blank","aria-label":`Tag: ${n}`,title:`View annotations with tag: ${n}`,underline:"none",children:n}):Ee("span",{className:"text-color-text-light cursor-default","aria-label":`Tag: ${n}`,lang:"",children:n})}),t&&Ee("button",{
|
|
497
497
|
className:X("px-1.5 py-1 touch:p-2","border-l rounded-sm rounded-l-none","text-grey-6 hover:text-color-text hover:bg-grey-2","transition-colors duration-200","focus-visible-ring ring-inset"),onClick:()=>{t(n)},title:`Remove tag: ${n}`,children:Ee(Le,{className:"font-base w-em h-em",title:`Remove ${n}`})})]})}function Hh({classes:e,setCollapsed:t,collapsed:n}){const r=n?"More":"Less";return Ee(In,{classes:X("text-grey-7 font-normal",e),expanded:!n,onClick:()=>t(!n),title:`Toggle visibility of full annotation text: Show ${r}`,children:Ee("div",{className:"flex items-center gap-x-2",children:[Ee(n?pt:Qe,{className:"w-3 h-3"}),Ee("div",{children:r})]})})}Ih.addHook("afterSanitizeAttributes",(e=>{"target"in e&&e.setAttribute("target","_blank")}));var Uh=lr((function({annotation:e,settings:t}){var n,r
|
|
498
498
|
;const[o,i]=ae(!0),[a,s]=ae(!1),l=Oi(),c=l.defaultAuthority(),u=l.getDraft(e),d=null!==(n=null==u?void 0:u.tags)&&void 0!==n?n:e.tags,h=null!==(r=null==u?void 0:u.text)&&void 0!==r?r:e.text,m=h.length>0,p=d.length>0,f=ar(["annotationFontFamily"],t),g=de((()=>e&&!ua(null==e?void 0:e.user,c)),[e,c]),v=e=>l.getLink("search.tag",{tag:e});return Ee("div",{className:"space-y-4",children:[m&&Ee(Aa,{collapse:o,collapsedHeight:400,inlineControls:!1,onCollapsibleChanged:s,onToggleCollapsed:i,overflowThreshold:20,children:Ee(Ph,{markdown:h,classes:X({"p-redacted-text":Zr(e)}),style:f})}),(a||p)&&Ee("div",{className:"flex flex-row gap-x-2",children:[Ee("div",{className:"grow",children:p&&Ee(Bh,{children:d.map((e=>Ee(Fh,{tag:e,href:g?v(e):void 0},e)))})}),a&&Ee("div",{children:Ee(Hh,{classes:X("-mt-3"),collapsed:o,setCollapsed:i})})]})]})}),["settings"]);let jh=function(e){return e.ANCHOR_LINK="ANCHOR_LINK",e.IMAGE_LINK="IMAGE_LINK",e}({});function qh(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd
|
|
499
499
|
;return o>=t+n?(o+=r.length-n,i+=r.length-n):i<=t||(o<=t&&i>=t+n?i+=r.length-n:o<t&&i<t+n?o=t:o<t+n&&i>t+n?i+=r.length-n:t<o&&t+n>i&&(o=t,i=t+n)),{text:e.text.slice(0,t)+r+e.text.slice(t+n),selectionStart:o,selectionEnd:i}}function $h(e,t=jh.ANCHOR_LINK){const n=e.text.slice(e.selectionStart,e.selectionEnd);let r,o="";if(t===jh.IMAGE_LINK&&(o="!"),n.match(/[a-z]+:\/\/.*/)){const t="Description";return r=qh(e,e.selectionStart,n.length,o+"["+t+"]("+n+")"),r.selectionStart=e.selectionStart+o.length+1,r.selectionEnd=r.selectionStart+t.length,r}{const t=o+"["+n+"](",i="http://insert-your-link-here.com";return r=qh(e,e.selectionStart,n.length,t+i+")"),r.selectionStart=e.selectionStart+t.length,r.selectionEnd=r.selectionStart+i.length,r}}function Gh(e,t,n,r){void 0===n&&(n=t);const o=e.text.slice(e.selectionStart-t.length,e.selectionStart),i=e.text.slice(e.selectionEnd,e.selectionEnd+t.length);let a=e;return e.selectionStart===e.selectionEnd&&r&&(a=qh(e,e.selectionStart,0,r),
|
|
@@ -523,7 +523,7 @@ className:"text-[16px] animate-fade-in-slow",children:Ee(Nn,{size:"sm"})}),Ee("d
|
|
|
523
523
|
Vr(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function Dm({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Ee("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Ee("div",{children:Ee("em",{children:"Message not available."})}),r&&Ee("footer",{className:"flex items-center",children:Ee(Rm,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var Pm=lr((function({annotation:e,api:t,toastMessenger:n}){const r=Oi(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Ee("div",{className:X("flex gap-x-3 bg-grey-1 text-color-text font-semibold","mb-2 ",{"-mt-3 -ml-3 -mr-3":!Gr(e),"-mr-3":Gr(e)}),children:[Ee("div",{className:X("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:e.hidden?Ee(At,{className:"w-em h-em"}):Ee(_t,{className:"w-em h-em"})}),Ee("div",{className:"self-center grow",children:[!e.hidden&&Ee("span",{
|
|
524
524
|
children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Ee("span",{children:"Hidden from users"})]}),Ee("div",{className:"self-center pr-2",children:Ee(In,{classes:X("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 annotationn from non-moderators",size:"custom",variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"]);function Bm({threadIsCollapsed:e,onToggleReplies:t}){const n=e?De:Vt,r=e?"Expand replies":"Collapse replies";return Ee("div",{className:X("cursor-auto",{"bg-thread-line":!e}),
|
|
525
525
|
"data-testid":"thread-collapse-channel",children:Ee("div",{className:X("bg-white"),children:Ee(In,{classes:X("-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:Ee(n,{className:"w-em h-em"})})})})}var Fm=lr((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>aa(e)>0)),i=Oi(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=he((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=de((()=>t.visible&&Ee(v,{children:t.annotation?Ee(v,{children:[Ee(Pm,{annotation:t.annotation}),Ee(Om,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Ee(Dm,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})
|
|
526
|
-
})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Ee("section",{className:"flex","data-testid":"thread-container",children:[r&&Ee(Bm,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ee("div",{className:X("grow max-w-full"),"data-testid":"thread-content",children:[d,ia(t)>0&&Ee("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ee(Im,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Ee("div",{children:Ee(In,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",ia(t)," more in conversation"]})})]}),!t.collapsed&&Ee("ul",{className:X("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Ee("li",{className:X("mt-2","[text-align:start]"),children:Ee(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var Hm=lr((function({frameSync:e,thread:t}){var n,r
|
|
526
|
+
})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Ee("section",{className:"flex","data-testid":"thread-container",children:[r&&Ee(Bm,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ee("div",{className:X("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,ia(t)>0&&Ee("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ee(Im,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Ee("div",{children:Ee(In,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",ia(t)," more in conversation"]})})]}),!t.collapsed&&Ee("ul",{className:X("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Ee("li",{className:X("mt-2","[text-align:start]"),children:Ee(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var Hm=lr((function({frameSync:e,thread:t}){var n,r
|
|
527
527
|
;const o=Oi(),i=null!==(n=null===(r=t.annotation)||void 0===r?void 0:r.$tag)&&void 0!==n?n:null,a=!(!i||!o.isAnnotationHovered(i)),s=de((()=>ea((t=>e.hoverAnnotation(t)),10)),[e]),l=he((t=>{e.scrollToAnnotation(t)}),[e]),c=de((()=>Ee(Fm,{thread:t})),[t]),u=o.annotationFocusRequest(),d=ue(null);return le((()=>{u===t.id&&d.current&&(d.current.focus(),o.clearAnnotationFocusRequest())}),[u,o,t.id]),Ee(Tn,{active:a,classes:"cursor-pointer focus-visible-ring theme-clean:border-none","data-testid":"thread-card",elementRef:d,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||l(t.annotation)},onMouseEnter:()=>{var e;return s(null!==(e=t.annotation)&&void 0!==e?e:null)},onMouseLeave:()=>s(null),children:Ee(Cn,{children:c})},t.id)}),["frameSync"]);const Um=50;function jm(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function qm(e){return Math.max(e-e%Um,0)}function $m(e){var t;const n=e.target[0]
|
|
528
528
|
;if(n)return null===(t=n.selector)||void 0===t?void 0:t.find((e=>"EPUBContentSelector"===e.type))}function Gm(e){var t;if(!e.annotation)return null;const n=$m(e.annotation);return null!==(t=null==n?void 0:n.cfi)&&void 0!==t?t:null}function Vm({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ta,t=jm();n(t.clientHeight),o(qm(t.scrollTop));const r=ea((()=>{n(t.clientHeight),o(qm(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=ae((()=>new Map)),[s,l]=ae(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=de((()=>function(e,t,n,r,o=na){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=Oi(),p=(()=>{const e=m.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})(),f=de((()=>{
|
|
529
529
|
let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=$m(n.annotation);null!=e&&e.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const a of e){var i;const e=Gm(a);if(!e||t===e)continue;t=e;const s=null!==(i=r.get(e))&&void 0!==i?i:"Untitled chapter";n!==s&&(n=s,o.set(a,s))}return o}),[e]);return le((()=>{p&&(m.setForcedVisible(p,!0),l(p))}),[m,p]),le((()=>{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)||na.defaultHeight)(t)),0);jm().scrollTop=t}),[s,c,i]),le((()=>{a((e=>{const t=new Map;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=ra(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Ee("div",{children:[Ee("div",{style:{height:d}}),h.map((e=>Ee("div",{className:X("mb-3"),"data-testid":"thread-card-container",id:e.id,
|
|
@@ -535,7 +535,7 @@ for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){if(typeof e[n]!=ty
|
|
|
535
535
|
;function pp(e){return function(e){return e.replace(mp,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class fp{constructor(e,t){H(this,"term",void 0),H(this,"matcher",void 0),this.term=t.normalize(e),this.matcher=t}matches(e){const t=this.matcher;return t.fieldValues(e).some((e=>t.matches(t.normalize(e),this.term)))}}class gp{constructor(e,t){H(this,"operator",void 0),H(this,"filters",void 0),this.operator=e,this.filters=t}matches(e){return"and"===this.operator?this.filters.every((t=>t.matches(e))):this.filters.some((t=>t.matches(e)))}}function vp(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:pp}}const _p={quote:vp((e=>{var t;return[null!==(t=oo(e))&&void 0!==t?t:""]})),since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:vp((e=>e.tags)),text:vp((e=>[e.text])),uri:vp((e=>[e.uri])),user:vp((e=>{var t,n;return[e.user,null!==(t=null===(n=e.user_info)||void 0===n?void 0:n.display_name)&&void 0!==t?t:""]}))};const bp=function(e){
|
|
536
536
|
if(1!==e.length)throw new Error("Memoize input must be a function of one argument");let t,n;return function(r){return r===t||(t=r,n=e(r)),n}}((function(e){const t=e.selection,n={expanded:t.expanded,forcedVisible:t.forcedVisible,selected:t.selected,sortCompareFn:hp[t.sortKey]},r=!!t.filterQuery||Object.keys(t.filters).length>0;if(r){const e=function(e,t={}){const n=[],r=[],o=[],i=[],a=[],s=[],l=t.user?[t.user]:[],c=Km(e);for(const e of c){const t=e.slice(0,e.indexOf(":")),c=e.slice(t.length+1);switch(t){case"quote":r.push(c);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";o.push(e*n[t])}}break;case"tag":i.push(c);break;case"text":a.push(c);break;case"uri":s.push(c);break;case"user":l.push(c);break;default:n.push(e)}}return{any:{terms:n,operator:"and"},quote:{terms:r,operator:"and"},since:{terms:o,operator:"and"},tag:{terms:i,operator:"and"
|
|
537
537
|
},text:{terms:a,operator:"and"},uri:{terms:s,operator:"or"},user:{terms:l,operator:"or"}}}(t.filterQuery||"",t.filters);n.filterFn=t=>function(e,t){const n=(e,t)=>new fp(t,_p[e]),r=Object.entries(t).filter((([,e])=>e.terms.length>0)).map((([e,t])=>{let r;if("any"===e){const e=["quote","text","tag","user"];r=t.terms.map((t=>new gp("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new gp(t.operator,r)})),o=new gp("and",r);return e.filter((e=>e.id&&o.matches(e))).map((e=>e.id))}([t],e).length>0}return!r&&"sidebar"===e.route&&(n.threadFilterFn=e=>{return!!e.annotation&&(n=e.annotation,r=t.selectedTab,!Xr(n)&&sp(n)===r);var n,r}),ap(e.annotations,n)}));function yp(){const e=Oi(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a=de((()=>({annotations:t,route:r,selection:{...o,filterQuery:n,filters:i}})),[t,n,r,o,i]);return bp(a)}var wp=lr((function({loadAnnotationsService:e,onLogin:t}){var n
|
|
538
|
-
;const r=Oi(),o=null!==(n=r.routeParams().id)&&void 0!==n?n:"",i=yp(),a=r.profile().userid,[s,l]=ae(!1);return le((()=>{l(!1),r.clearAnnotations(),e.loadThread(o).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&r.setExpanded(e.id,!0))),t.id!==o&&r.highlightAnnotations([o]))})).catch((()=>{l(!0)}))}),[o,a,e,r]),Ee(v,{children:[s&&Ee(Di,{errorType:"annotation",onLoginRequest:t}),Ee(Vm,{threads:i.children})]})}),["loadAnnotationsService"]);class xp{constructor(e,t,n=window){var r,o,i,a;H(this,"version",void 0),H(this,"userAgent",void 0),H(this,"urls",void 0),H(this,"fingerprint",void 0),H(this,"account",void 0),H(this,"timestamp",void 0),H(this,"segment",void 0);const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.
|
|
538
|
+
;const r=Oi(),o=null!==(n=r.routeParams().id)&&void 0!==n?n:"",i=yp(),a=r.profile().userid,[s,l]=ae(!1);return le((()=>{l(!1),r.clearAnnotations(),e.loadThread(o).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&r.setExpanded(e.id,!0))),t.id!==o&&r.highlightAnnotations([o]))})).catch((()=>{l(!0)}))}),[o,a,e,r]),Ee(v,{children:[s&&Ee(Di,{errorType:"annotation",onLoginRequest:t}),Ee(Vm,{threads:i.children})]})}),["loadAnnotationsService"]);class xp{constructor(e,t,n=window){var r,o,i,a;H(this,"version",void 0),H(this,"userAgent",void 0),H(this,"urls",void 0),H(this,"fingerprint",void 0),H(this,"account",void 0),H(this,"timestamp",void 0),H(this,"segment",void 0);const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.1288.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||s,
|
|
539
539
|
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())}}var kp="complete",Sp="canceled";function Np(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function Ep(e){var t=e._scrollSettings;if(t){var n=t.maxSynchronousAlignments,r=function(e,t){
|
|
540
540
|
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 v=u.left-(n.left-t.scrollLeft),_=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=_+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}}(t,e),o=Date.now()-t.startTime,i=Math.min(1/t.time*o,1);if(t.endIterations>=n)return Np(e,r.x,r.y),
|
|
541
541
|
e._scrollSettings=null,t.end(kp);var a=1-t.ease(i);if(Np(e,r.x-r.differenceX*a,r.y-r.differenceY*a),o>=t.time)return t.endIterations++,t.scrollAncestor&&Ep(t.scrollAncestor),void Ep(e);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(Ep.bind(null,e))}}function Tp(e){return e.self===e}function Ap(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function Cp(){return!0}function Mp(e){if(e.assignedSlot)return Mp(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}}var Ip=function(e,t,n){if(e){"function"==typeof t&&(n=t,t=null),t||(t={}),t.time=isNaN(t.time)?1e3:t.time,t.ease=t.ease||function(e){return 1-Math.pow(1-e,e/2)},t.align=t.align||{}
|
|
@@ -583,7 +583,7 @@ message:"Method not found"}};e.params?t(...e.params):t();return{jsonrpc:"2.0",re
|
|
|
583
583
|
this._activity=e,this._api=t,this._store=n}_applyDraftChanges(e){const t={},n=this._store.getDraft(e);return n&&(t.tags=n.tags,t.text=n.text,t.permissions=n.isPrivate?ma(e.user):pa(e.user,e.group)),{...e,...t}}_initialize(e,t){const n=this._store.getDefault("annotationPrivacy"),r=this._store.focusedGroupId(),o=this._store.profile();if(!r)throw new Error("Cannot create annotation without a group");const i=o.userid;if(!i)throw new Error("Cannot create annotation when logged out");const a=o.user_info,s="s:"+Df(8),l=Object.assign({created:t.toISOString(),group:r,permissions:fa(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return Qr(l)&&(l.permissions=ma(i)),l}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Qr(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!Wr(n)}),eo(n)?this._store.selectTab("note"):to(n)&&this._store.selectTab("annotation"),
|
|
584
584
|
(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,permissions:Wr(e)?pa(t,e.group):ma(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;Vr(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)}
|
|
585
585
|
for(const[t,n]of Object.entries(e))if(t.startsWith("$")){o[t]=n}return this._store.removeDraft(e),this._store.addAnnotations([o]),o}}Qf.$inject=["annotationActivity","api","store"];class Jf extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),H(this,"url",void 0),H(this,"response",void 0),H(this,"reason",void 0),this.url=e,this.response=t,this.reason=n}}async function eg(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Jf(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new Jf(e,n,"Failed to parse response")}var o;if(!n.ok)throw new Jf(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function tg(e){const t={};for(const[n,r]of Object.entries(e))n.startsWith("$")||(t[n]=r);return t}class ng{constructor(e,t,n){H(this,"_clientId",void 0),H(this,"search",void 0),H(this,"annotation",void 0),H(this,"group",void 0),H(this,"groups",void 0),H(this,"profile",void 0),this._clientId=null
|
|
586
|
-
;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,i]=await Promise.all([e,n()]),l=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!l)throw new Error(`Missing API route: ${t}`);const c={"Content-Type":"application/json","Hypothesis-Client-Version":"1.
|
|
586
|
+
;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,i]=await Promise.all([e,n()]),l=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!l)throw new Error(`Missing API route: ${t}`);const c={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1288.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=si(l.url,a),m=new URL(d);for(const[e,t]of Object.entries(h)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await eg(m.toString(),{body:s?JSON.stringify(tg(s)):null,headers:c,method:l.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),
|
|
587
587
|
this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")}}setClientId(e){this._clientId=e}}ng.$inject=["apiRoutes","auth","store"];var rg={};function og(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 ig=og;og.prototype.reset=function(){this._attempts=1,
|
|
588
588
|
this._timeouts=this._originalTimeouts.slice(0)},og.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},og.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},og.prototype.attempt=function(e,t){this._fn=e,
|
|
589
589
|
t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},og.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},og.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},og.prototype.start=og.prototype.try,og.prototype.errors=function(){return this._errors},og.prototype.attempts=function(){return this._attempts},og.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=ig;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})},
|
|
@@ -688,8 +688,8 @@ H(this,"_socket",void 0),H(this,"_reconnectSetUp",void 0),H(this,"_updateImmedia
|
|
|
688
688
|
n=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(n){const e=new URL(t);e.searchParams.set("access_token",n),r=e.toString()}else r=t;const o=new yy(r);o.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(o)})),o.on("disconnect",(()=>{if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),o.on("error",(e=>this._handleSocketError(t,e))),o.on("message",(e=>this._handleSocketMessage(e))),this._socket=o,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){var t;this._updateImmediately=null===(t=e.applyUpdatesImmediately)||void 0===t||t,this._reconnectSetUp||(this._reconnectSetUp=!0,
|
|
689
689
|
kg(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}wy.$inject=["store","apiRoutes","auth","groups","session"];const xy="hypothesis.user.tags.list",ky="hypothesis.user.tags.map";class Sy{constructor(e){H(this,"_storage",void 0),this._storage=e}filter(e,t=null){const n=this._storage.getObject(xy)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${Gf(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(ky)||{};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(ky,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(xy,n)}}Sy.$inject=["localStorage"];class Ny{constructor(e){H(this,"_store",void 0),this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),
|
|
690
690
|
e.visible||this._store.setForcedVisible(e.id,!0)}}Ny.$inject=["store"];class Ey extends $p{constructor(e,t){super(),H(this,"_store",void 0),H(this,"_window",void 0),H(this,"_delayedMessageQueue",void 0),this._store=e,this._window=t,this._delayedMessageQueue=[],this._window.addEventListener("focus",(()=>{this._delayedMessageQueue.forEach((({type:e,messageText:t,options:n})=>this._addMessage(e,t,n))),this._delayedMessageQueue=[]}))}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),this.emit("toastMessageDismissed",e),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r="",visuallyHidden:o=!1,delayed:i=!1}={}){if(this._store.hasToastMessage(e,t))return;if(i&&!this._window.document.hasFocus()){const i={autoDismiss:n,moreInfoURL:r,visuallyHidden:o};return void this._delayedMessageQueue.push({type:e,messageText:t,options:i})}const a=Df(10),s={type:e,id:a,message:t,moreInfoURL:r,
|
|
691
|
-
visuallyHidden:o};this._store.addToastMessage({isDismissed:!1,...s}),this.emit("toastMessageAdded",s),n&&setTimeout((()=>{this.dismiss(a)}),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)}}Ey.$inject=["store","$window"];const Ty=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),Ay=function(e){const{version:t,origin:n}=Bf(e.location.href);return"1.
|
|
692
|
-
!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 Cy(e,t){e.setClientId(t.clientId)}function My(e,t,n){e.load(),t.load(),n.sync()}function Iy(e,t,n){e.init(),t.init(),n.init()}function zy(e,t){"sidebar"===t.route()&&e.connect()}Ty.sentry&&Ay&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;py({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.
|
|
691
|
+
visuallyHidden:o};this._store.addToastMessage({isDismissed:!1,...s}),this.emit("toastMessageAdded",s),n&&setTimeout((()=>{this.dismiss(a)}),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)}}Ey.$inject=["store","$window"];const Ty=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),Ay=function(e){const{version:t,origin:n}=Bf(e.location.href);return"1.1288.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1288.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."),
|
|
692
|
+
!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 Cy(e,t){e.setClientId(t.clientId)}function My(e,t,n){e.load(),t.load(),n.sync()}function Iy(e,t,n){e.init(),t.init(),n.init()}function zy(e,t){"sidebar"===t.route()&&e.connect()}Ty.sentry&&Ay&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;py({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1288.0",beforeSend:(e,t)=>{if(gy>=5)return $f("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++gy;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(e){}return e}});try{G_("host_config",Bf(window.location.href))}catch(e){}
|
|
693
693
|
G_("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),vg(((e,t)=>{$_(e,{tags:{context:t}})}))}(Ty.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")}))}(document.body),Cy.$inject=["api","streamer"],My.$inject=["groups","session","router"],Iy.$inject=["autosaveService","persistedDefaults","serviceURL"],zy.$inject=["frameSync","store"];const Ry=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",Xf)}(),async function(e,t=window){const n=function(e){const t=Bf(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Ff,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{
|
|
694
694
|
origin:Uf(t.origin),ancestorLevel:Hf(t.ancestorLevel)}}},o={};for(const[e,i]of Object.entries(t))n.includes(e)&&null!==i&&(r[e]?o[e]=r[e](i):o[e]=i);return o}(window),r=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified");return{targetFrame:jf(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await Pf(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=Pf(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=or(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl
|
|
695
695
|
;throw new Error("Service should contain an apiUrl value.")}(i),i}(Ty).then((e=>{!function(e,t){const n=new $;n.register("annotationsService",Qf).register("annotationActivity",Zf).register("api",ng).register("apiRoutes",cg).register("auth",hg).register("autosaveService",mg).register("frameSync",Eg).register("groups",Cg).register("loadAnnotationsService",Mg).register("localStorage",zg).register("persistedDefaults",Lg).register("router",Og).register("serviceURL",Dg).register("session",_y).register("streamer",wy).register("streamFilter",by).register("tags",Sy).register("threadsService",Ny).register("toastMessenger",Ey).register("store",{factory:Li}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(Iy),n.run(Cy),n.run(My),n.run(Kf),n.run(zy),B(Ee(sr.Provider,{value:n,children:Ee(Rf,{})}),t)}(e,Ry)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),B(Ee(Lf,{error:e}),t)}(e,Ry)));
|