hypothesis 1.1548.0 → 1.1549.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?5c5f4f","styles/annotator.css":"styles/annotator.css?c0916c","styles/annotator.css.map":"styles/annotator.css.map?8d0b08","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?095380","styles/katex.min.css.map":"styles/katex.min.css.map?e7e03f","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css.map":"styles/sidebar.css.map?67af10","styles/sidebar.css":"styles/sidebar.css?e2f13a","styles/ui-playground.css.map":"styles/ui-playground.css.map?0d6e99","styles/ui-playground.css":"styles/ui-playground.css?49365c","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?fb36f3","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?835978","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?a12e9c","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?2784a9","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?7ba414"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var o=s.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=e,t(o),s.head.appendChild(o)}function o(s,e){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=o.esModule,n=void 0===r||r,i=o.forceReload,a=void 0!==i&&i,l=s.createElement("script");n&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,o,r){var n=s.createElement("link");n.rel=e,n.href=r,n.type="application/annotator+".concat(o),t(n),s.head.appendChild(n)}function n(s,e,o){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=o,"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=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),o=0;o<e.length;o++){var r=void 0;try{r=JSON.parse(e[o].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1549.0/");if(document.querySelector("hypothesis-app")){!function(s,t){n(s,"fetch",t.apiUrl),n(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)o(s,i(t,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)e(s,i(t,p[l]))}(document,{assetRoot:p,manifest:s,apiUrl:l.apiUrl})}else{var c=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(c&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(c))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,h=a(d.notebookAppUrl||"https://hypothes.is/notebook"),u=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,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),n(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++)o(s,i(t,l[a]),{esModule:!1});var p=[];void 0!==window.PDFViewerApplication&&p.push("styles/pdfjs-overrides.css"),p.push("styles/highlights.css");for(var c=0,d=p;c<d.length;c++)e(s,i(t,d[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:h,profileAppUrl:u,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
|
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?5c5f4f",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?c0916c",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?8d0b08",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?6b4ebd",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"styles/katex.min.css.map": "styles/katex.min.css.map?e7e03f",
|
|
9
9
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
|
|
10
10
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
|
|
11
|
-
"styles/sidebar.css": "styles/sidebar.css?e2f13a",
|
|
12
11
|
"styles/sidebar.css.map": "styles/sidebar.css.map?67af10",
|
|
13
|
-
"styles/
|
|
12
|
+
"styles/sidebar.css": "styles/sidebar.css?e2f13a",
|
|
14
13
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?0d6e99",
|
|
14
|
+
"styles/ui-playground.css": "styles/ui-playground.css?49365c",
|
|
15
15
|
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?fb36f3",
|
|
16
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?
|
|
16
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?835978",
|
|
17
17
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?a12e9c",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?2784a9",
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?7ba414"
|
|
20
20
|
}
|
|
@@ -144,7 +144,7 @@ this._sidebarRPC.on("navigateToSegment",(e=>this._integration.navigateToSegment?
|
|
|
144
144
|
if(!t.selector||!t.selector.some((e=>"TextQuoteSelector"===e.type)))return{annotation:e,target:t};let n;try{const o=await this._integration.anchor(this.element,t.selector),i=mo.fromRange(o);n={annotation:e,target:t,range:i}}catch{n={annotation:e,target:t}}return n})));if(!this._annotations.has(e.$tag))return[];for(const e of n)t(e);return e.$orphan=n.length>0&&n.every((e=>e.target.selector&&!e.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",e),n}detach(e,t=!0){this._annotations.delete(e);const n=[];for(const t of this.anchors)t.annotation.$tag!==e?n.push(t):t.highlights&&ko(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(t.map((e=>this._integration.describe(o,e))))).map((e=>({
|
|
145
145
|
source:n.uri,selector:e}))),s={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Er(),s}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);Ao(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e);if(!t)return void this._onClearSelection();const n=document.getSelection(),o=wo(n),i=xo(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Nr(),this._isAdderVisible=!0,this._adder.show(i,o)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}
|
|
146
146
|
selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){!function(e,t){e.classList.toggle("hypothesis-highlights-always-on",t)}(this.element,e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){ct(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new vr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Rr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Tr(e,t){const n={}
|
|
147
|
-
;for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.
|
|
147
|
+
;for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1549.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function Pr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=Ge(null);return Ke((()=>{e?r.current?.close():r.current?.showModal()}),[e]),Ke((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),St("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Lr({closed:e,children:t,...n}){return St("div",{...n,
|
|
148
148
|
className:Nt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:St("div",{className:"relative w-full h-full",children:t})})}function Or({document_:e=document,...t}){return St(Ye((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Pr:Lr),[e]),{...t})}function Mr({config:e,groupId:t}){return St("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Rr(e.notebookAppUrl,{...Tr(e.notebookAppUrl,e),group:t})})}function Ir({eventBus:e,config:t}){const[n,o]=Xe(0),[i,r]=Xe(!0),[s,a]=Xe(null),l=Ge(""),c=Ge(null);Ke((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Ke((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),Ke((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const d=Je((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
|
|
149
149
|
;return null===s?null:St(Or,{closed:i,onClose:d,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[St("div",{className:"absolute right-0 m-3",children:St(yn,{title:"Close notebook",onClick:d,variant:"dark",classes:Nt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:St(Ot,{className:"w-4 h-4"})})}),St(Mr,{config:t,groupId:s},n)]})}class Br{constructor(e,t,n){this._container=new to("notebook",(()=>St(Ir,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Fr({eventBus:e,config:t}){const[n,o]=Xe(!0),i=Ge(null);Ke((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{o(!1)})),i.current=t,()=>{t.destroy()}}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:St(Or,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[St("div",{className:"absolute right-0 m-3",children:St(yn,{
|
|
150
150
|
title:"Close profile dialog",onClick:r,variant:"dark",classes:Nt("!bg-transparent enabled:hover:!bg-grey-3"),children:St(Ot,{className:"w-4 h-4"})})}),St("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Dr{constructor(e,t,n){this._container=new to("profile",(()=>St(Fr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Hr({above:e,below:t,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return St("ul",{className:"relative",children:[s&&St("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:St(Kn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),
|
|
@@ -526,9 +526,9 @@ variant:"text-light",href:e,lang:"",target:"_blank","aria-label":`Tag: ${n}`,tit
|
|
|
526
526
|
;var vp=Lo((function({annotation:e,settings:t}){const[n,r]=ae(!0),[o,i]=ae(!1),a=ms(),s=a.defaultAuthority(),l=a.getDraft(e),c=l?.tags??e.tags,u=l?.text??e.text,d=u.length>0,h=c.length>0,m=zo(["annotationFontFamily"],t),p=de((()=>e&&!Ts(e?.user,s)),[e,s]),f=e=>a.getLink("search.tag",{tag:e});return Ze("div",{className:"space-y-4",children:[d&&Ze(Vs,{collapse:n,collapsedHeight:400,inlineControls:!1,onCollapsibleChanged:i,onToggleCollapsed:r,overflowThreshold:20,children:Ze(mp,{markdown:u,classes:Xe({"p-redacted-text":xi(e)}),style:m})}),(o||h)&&Ze("div",{className:"flex flex-row gap-x-2",children:[Ze("div",{className:"grow",children:h&&Ze(pp,{children:c.map((e=>Ze(fp,{tag:e,href:p?f(e):void 0},e)))})}),o&&Ze("div",{children:Ze(gp,{classes:Xe("-mt-3"),collapsed:n,setCollapsed:r})})]})]})}),["settings"]);let bp=function(e){return e.ANCHOR_LINK="ANCHOR_LINK",e.IMAGE_LINK="IMAGE_LINK",e}({});function yp(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd;return o>=t+n?(o+=r.length-n,
|
|
527
527
|
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 _p(e,t=bp.ANCHOR_LINK){const n=e.text.slice(e.selectionStart,e.selectionEnd);let r,o="";if(t===bp.IMAGE_LINK&&(o="!"),n.match(/[a-z]+:\/\/.*/)){const t="Description";return r=yp(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=yp(e,e.selectionStart,n.length,t+i+")"),r.selectionStart=e.selectionStart+t.length,r.selectionEnd=r.selectionStart+i.length,r}}function wp(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=yp(e,e.selectionStart,0,r),a.selectionStart=a.selectionEnd-r.length),
|
|
528
528
|
o===t&&i===n?(a=yp(a,a.selectionStart-t.length,t.length,""),a=yp(a,a.selectionEnd,n.length,"")):(a=yp(a,a.selectionStart,0,t),a=yp(a,a.selectionEnd,0,n)),a}function xp(e,t){const n=e.indexOf("\n",t);return n<0?e.length:n}function kp(e,t,n,r){let o=function(e,t){const n=e.lastIndexOf("\n",t);return n<0?0:n+1}(e.text,t),i=xp(e.text,t),a=0;for(;i<=xp(e.text,n);){const t=i===e.text.length,s=i-o,l=xp((e=r(e,o,i,a)).text,o)-o;if(n+=l-s,t)break;o=o+l+1,i=xp(e.text,o),a+=1}return e}function Np(e,t){const n=e.selectionStart,r=e.selectionEnd,o=e=>"function"==typeof t?t(e):t;let i=!0;return kp(e,n,r,((e,t,n,r)=>{const a=o(r);return e.text.slice(t,t+a.length)!==a&&(i=!1),e})),kp(e,n,r,i?(e,t,n,r)=>yp(e,t,o(r).length,""):(e,t,n,r)=>{const i=o(r);return e.text.slice(t,t+i.length)===i?e:yp(e,t,0,i)})}const Sp={bold:"b",image:"g",italic:"i",link:"l",list:"u",math:"m",numlist:"o",quote:"q"};function Ap({disabled:e=!1,icon:t,label:n,onClick:r,shortcutKey:o,title:i=""}){const a=de((()=>Ps()?"Cmd":"Ctrl"),[]);let s=i
|
|
529
|
-
;o&&(s+=` (${a}-${o.toUpperCase()})`);const l={disabled:e,onClick:r,title:s};return n?Ze(xr,{classes:"p-1.5 text-grey-7 hover:text-grey-9",...l,size:"custom",variant:"custom",children:n}):Ze(Er,{classes:"px-2 py-2.5",...l,children:t&&Ze(t,{className:"w-[10px] h-[10px] touch:w-[13px] touch:h-[13px]"})})}function Ep({classes:e,containerRef:t,atMentionsEnabled:n,...r}){const[o,i]=ae(!1),a=ze(t);return le((()=>{if(!n)return()=>{};const e=a.current,t=new ys
|
|
530
|
-
;return Se(r),Ze("div",{className:Xe("flex flex-wrap w-full items-center","p-1 border-x border-t rounded-t bg-white","touch:h-auto touch:overflow-x-scroll touch:flex-nowrap touch:pb-2.5"),"data-testid":"markdown-toolbar",role:"toolbar","aria-label":"Markdown editor toolbar",ref:r,children:[Ze(Ap,{disabled:e,icon:Yt,onClick:()=>t("bold"),shortcutKey:Sp.bold,title:"Bold"}),Ze(Ap,{disabled:e,icon:Jt,onClick:()=>t("italic"),shortcutKey:Sp.italic,title:"Italic"}),Ze(Ap,{disabled:e,icon:Wt,onClick:()=>t("quote"),shortcutKey:Sp.quote,title:"Quote"}),Ze(Ap,{disabled:e,icon:Mn,onClick:()=>t("link"),shortcutKey:Sp.link,title:"Insert link"}),Ze(Ap,{disabled:e,icon:An,onClick:()=>t("image"),shortcutKey:Sp.image,title:"Insert image"}),Ze(Ap,{disabled:e,icon:Gt,onClick:()=>t("math"),title:"Insert math (LaTeX is supported)"}),Ze(Ap,{disabled:e,icon:zn,onClick:()=>t("numlist"),shortcutKey:Sp.numlist,title:"Numbered list"}),Ze(Ap,{disabled:e,icon:Ln,
|
|
531
|
-
className:"grow flex justify-end",children:[Ze(bo,{classes:"text-grey-7 hover:!text-grey-7",href:"https://web.hypothes.is/help/formatting-annotations-with-markdown/",target:"_blank",title:"Formatting help","aria-label":"Formatting help",underline:"none",variant:"custom",children:Ze("div",{className:Xe("flex justify-center items-center","touch:h-touch-minimum touch:w-touch-minimum","px-2 py-2.5 touch:p-0"),children:Ze(_n,{className:"w-2.5 h-2.5"})})}),Ze(Ap,{label:e?"Write":"Preview",onClick:n})]})]})}function Cp({atMentionsEnabled:e=!1,label:t,onEditText:n=(()=>{}),text:r,textStyle:o={}}){const[i,a]=ae(!1),s=ue(null);le((()=>{i||s.current?.focus()}),[i]);const l=e=>{s.current&&(!function(e,t){const n=e=>{const n=e({text:t.value,selectionStart:t.selectionStart,selectionEnd:t.selectionEnd});t.value=n.text,t.selectionStart=n.selectionStart,t.selectionEnd=n.selectionEnd,t.focus()},r=e=>{const t=e.text.slice(0,e.selectionStart)
|
|
529
|
+
;o&&(s+=` (${a}-${o.toUpperCase()})`);const l={disabled:e,onClick:r,title:s};return n?Ze(xr,{classes:"p-1.5 text-grey-7 hover:text-grey-9",...l,size:"custom",variant:"custom",children:n}):Ze(Er,{classes:"px-2 py-2.5",...l,children:t&&Ze(t,{className:"w-[10px] h-[10px] touch:w-[13px] touch:h-[13px]"})})}function Ep({classes:e,containerRef:t,atMentionsEnabled:n,...r}){const[o,i]=ae(!1),a=ze(t);return le((()=>{if(!n)return()=>{};const e=a.current,t=new ys,r=()=>{const t=function(e,t){return e.slice(0,t).match(/\S+$/)?.[0]??""}(e.value,e.selectionStart);i(t.startsWith("@"))};return t.add(e,"keyup",(e=>{"Escape"!==e.key&&r()})),t.add(e,"click",r),()=>t.removeAll()}),[n,o,a]),Ze("div",{className:"relative",children:[Ze("textarea",{className:Xe("border rounded p-2","text-color-text-light bg-grey-0","focus:bg-white focus:outline-none focus:shadow-focus-inner",e),...r,ref:a}),n&&Ze(to,{open:o,onClose:()=>i(!1),anchorElementRef:a,classes:"p-2",children:"Suggestions"})]})}
|
|
530
|
+
function Tp({isPreviewing:e,onCommand:t,onTogglePreview:n}){const r=ue(null);return Se(r),Ze("div",{className:Xe("flex flex-wrap w-full items-center","p-1 border-x border-t rounded-t bg-white","touch:h-auto touch:overflow-x-scroll touch:flex-nowrap touch:pb-2.5"),"data-testid":"markdown-toolbar",role:"toolbar","aria-label":"Markdown editor toolbar",ref:r,children:[Ze(Ap,{disabled:e,icon:Yt,onClick:()=>t("bold"),shortcutKey:Sp.bold,title:"Bold"}),Ze(Ap,{disabled:e,icon:Jt,onClick:()=>t("italic"),shortcutKey:Sp.italic,title:"Italic"}),Ze(Ap,{disabled:e,icon:Wt,onClick:()=>t("quote"),shortcutKey:Sp.quote,title:"Quote"}),Ze(Ap,{disabled:e,icon:Mn,onClick:()=>t("link"),shortcutKey:Sp.link,title:"Insert link"}),Ze(Ap,{disabled:e,icon:An,onClick:()=>t("image"),shortcutKey:Sp.image,title:"Insert image"}),Ze(Ap,{disabled:e,icon:Gt,onClick:()=>t("math"),title:"Insert math (LaTeX is supported)"}),Ze(Ap,{disabled:e,icon:zn,onClick:()=>t("numlist"),shortcutKey:Sp.numlist,title:"Numbered list"}),Ze(Ap,{disabled:e,icon:Ln,
|
|
531
|
+
onClick:()=>t("list"),shortcutKey:Sp.list,title:"Bulleted list"}),Ze("div",{className:"grow flex justify-end",children:[Ze(bo,{classes:"text-grey-7 hover:!text-grey-7",href:"https://web.hypothes.is/help/formatting-annotations-with-markdown/",target:"_blank",title:"Formatting help","aria-label":"Formatting help",underline:"none",variant:"custom",children:Ze("div",{className:Xe("flex justify-center items-center","touch:h-touch-minimum touch:w-touch-minimum","px-2 py-2.5 touch:p-0"),children:Ze(_n,{className:"w-2.5 h-2.5"})})}),Ze(Ap,{label:e?"Write":"Preview",onClick:n})]})]})}function Cp({atMentionsEnabled:e=!1,label:t,onEditText:n=(()=>{}),text:r,textStyle:o={}}){const[i,a]=ae(!1),s=ue(null);le((()=>{i||s.current?.focus()}),[i]);const l=e=>{s.current&&(!function(e,t){const n=e=>{const n=e({text:t.value,selectionStart:t.selectionStart,selectionEnd:t.selectionEnd});t.value=n.text,t.selectionStart=n.selectionStart,t.selectionEnd=n.selectionEnd,t.focus()},r=e=>{const t=e.text.slice(0,e.selectionStart)
|
|
532
532
|
;return 0===t.length||"\n"===t.slice(-1)||"$$"===t.slice(-2)?wp(e,"$$","$$","Insert LaTeX"):wp(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>wp(e,"**","**","Bold")));break;case"italic":n((e=>wp(e,"*","*","Italic")));break;case"quote":n((e=>Np(e,"> ")));break;case"link":n((e=>_p(e)));break;case"image":n((e=>_p(e,bp.IMAGE_LINK)));break;case"math":n(r);break;case"numlist":n((e=>Np(e,(e=>`${e+1}. `))));break;case"list":n((e=>Np(e,"* ")))}}(e,s.current),n(s.current.value))};return Ze("div",{className:"leading-none",children:[Ze(Tp,{onCommand:l,isPreviewing:i,onTogglePreview:()=>a(!i)}),i?Ze(mp,{markdown:r,classes:"border bg-grey-1 p-2",style:o}):Ze(Ep,{"aria-label":t,placeholder:t,dir:"auto",classes:Xe("w-full min-h-[8em] resize-y","rounded-t-none","text-base touch:text-touch-base"),containerRef:s,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(const[t,n]of Object.entries(Sp))n===e.key&&(e.stopPropagation(),e.preventDefault(),l(t))},onInput:e=>n(e.target.value),value:r,style:o,
|
|
533
533
|
atMentionsEnabled:e})]})}const Mp=e=>e;function Ip({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Mp,onSelectItem:i,open:a=!1}){const s=de((()=>r.map(((t,r)=>{const a=n?{id:`${n}${r}`}:{};return Ze("li",{role:"option","aria-selected":e===r,className:Xe("flex items-center","border-l-4 py-1 px-3 cursor-pointer hover:bg-grey-2","touch:h-touch-minimum",{"border-brand bg-grey-1":e===r,"border-transparent":e!==r}),onClick:()=>{i(t)},...a,children:o(t,r)},`AutocompleteList-${r}`)}))),[e,n,r,o,i]),l=t?{id:t}:{},c=0===r.length||!a;return Ze("div",{className:"relative",children:Ze("div",{className:Xe({hidden:c},"absolute top-[3px] z-3","min-w-[10em]"),"data-testid":"autocomplete-list-container",children:Ze(st,{width:"auto",classes:"overflow-hidden",children:[Ze("ul",{tabIndex:-1,"aria-label":"Suggestions",role:"listbox",...l,children:s}),Ze(Bs,{direction:"up",classes:"top-[-8px] left-2"})]})})})}let zp=0;var Op=Lo((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){
|
|
534
534
|
const i=ue(),[a,s]=ae([]),[l,c]=ae(-1),[u,d]=ae(!1),[h]=ae((()=>(++zp,`TagEditor-${zp}`))),m=ue(null);Ce(m,(()=>d(!1)),{enabled:u});const p=()=>i.current.value.trim(),f=()=>p()&&p().length>0,g=()=>{i.current.value="",n?.("")},v=t=>{e(t)&&(d(!1),c(-1),g(),i.current.focus())},b=e=>{let t=l+e;t<-1?t=a.length-1:t>=a.length&&(t=-1),c(t)},y=l>=0?`${h}-AutocompleteList-item-${l}`:"";return Ze("div",{className:"space-y-4",children:[Ze(pp,{children:r.map((e=>Ze(fp,{onRemoveTag:t,tag:e},e)))}),Ze("div",{id:h,"data-testid":"combobox-container",ref:m,children:[Ze(Kr,{onInput:()=>{n?.(p()),(()=>{if(f()){const e=o.filter(p());s(((e,t)=>{const n=[];for(const r of e)t.indexOf(r)<0&&n.push(r);return n.sort()})(e,r)),d(e.length>0)}else d(!1);c(-1)})()},onKeyDown:e=>{switch(e.key){case"ArrowUp":b(-1),e.preventDefault();break;case"ArrowDown":b(1),e.preventDefault();break;case"Escape":g(),e.preventDefault();break;case"Enter":case",":v(-1===l?p():a[l]),e.preventDefault();break;case"Tab":if(!f())break
|
|
@@ -563,7 +563,7 @@ const Cf=/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5
|
|
|
563
563
|
return t}function qf(e){return Ni(e)?"orphan":Si(e)?"note":"annotation"}function $f(e){return Ss([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function Uf(e){return Ss([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}const Gf={Newest:(e,t)=>{const n=$f(e),r=$f(t);return n>r?-1:n<r?1:0},Oldest:(e,t)=>{const n=Uf(e),r=Uf(t);return n<r?-1:n>r?1:0},Location:(e,t)=>{if(!e.annotation||!t.annotation)return function(e,t){return e.annotation||t.annotation?e.annotation?1:-1:0}(e,t);const n=Ti(e.annotation),r=Ti(t.annotation);if(n.cfi&&r.cfi){const e=kf(n.cfi,r.cfi);if(0!==e)return Math.sign(e)}else{if(n.cfi)return-1;if(r.cfi)return 1}const o=n.position??Number.MAX_SAFE_INTEGER,i=r.position??Number.MAX_SAFE_INTEGER;return Math.sign(o-i)}};const Vf=function(e){if(1!==e.length)throw new Error("Memoize input must be a function of one argument");let t,n;return function(r){return r===t||(t=r,n=e(r)),n}}((function(e){const t=e.selection,n={expanded:t.expanded,forcedVisible:t.forcedVisible,
|
|
564
564
|
selected:t.selected,sortCompareFn:Gf[t.sortKey]};if(!!t.filterQuery||Object.keys(t.filters).length>0){const e=function(e,t={}){const n=e=>{const n=t[e];return"string"==typeof n?[n]:[]},r=n("cfi"),o=n("page"),i=n("quote"),a=n("tag"),s=n("text"),l=n("uri"),c=n("user"),u=[],d=[],h=Hf(e,Pf);for(const e of h){const t=e.slice(0,e.indexOf(":")),n=e.slice(t.length+1);switch(t){case"cfi":r.push(n);break;case"quote":i.push(n);break;case"page":o.push(n);break;case"since":{const t=86400,n={sec:1,min:60,hour:3600,day:t,week:7*t,month:30*t,year:365*t},r=e.slice(6).toLowerCase().match(/^(\d+)(sec|min|hour|day|week|month|year)?$/);if(r){const e=parseFloat(r[1]),t=r[2]||"sec";d.push(e*n[t])}}break;case"tag":a.push(n);break;case"text":s.push(n);break;case"uri":l.push(n);break;case"user":c.push(n);break;default:u.push(e)}}return{any:{terms:u,operator:"and",filterReplies:!0},cfi:{terms:r,operator:"or",filterReplies:!1},quote:{terms:i,operator:"and",filterReplies:!1},page:{terms:o,operator:"or",filterReplies:!1},since:{terms:d,
|
|
565
565
|
operator:"and",filterReplies:!0},tag:{terms:a,operator:"and",filterReplies:!0},text:{terms:s,operator:"and",filterReplies:!0},uri:{terms:l,operator:"or",filterReplies:!1},user:{terms:c,operator:"or",filterReplies:!0}}}(t.filterQuery||"",t.filters),r={},o={};for(const[t,n]of Object.entries(e))n.filterReplies?r[t]=n:o[t]=n;n.filterFn=e=>Rf([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&Rf([e.annotation],o).length>0)}const r=_f(e.annotations,n),o={annotation:0,note:0,orphan:0};return e.showTabs&&(r.children=r.children.filter((e=>{if(!e.annotation)return!1;if(wi(e.annotation))return!1;const n=qf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function Wf(){const e=ms(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=de((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return Vf(s)}
|
|
566
|
-
var Kf,Yf,Xf=Lo((function({loadAnnotationsService:e,onLogin:t}){const n=ms(),r=n.routeParams().id??"",{rootThread:o}=Wf(),i=n.profile().userid,[a,s]=ae(!1);return le((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Ze(x,{children:[a&&Ze(ps,{errorType:"annotation",onLoginRequest:t}),Ze(uf,{threads:o.children})]})}),["loadAnnotationsService"]);class Jf{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.
|
|
566
|
+
var Kf,Yf,Xf=Lo((function({loadAnnotationsService:e,onLogin:t}){const n=ms(),r=n.routeParams().id??"",{rootThread:o}=Wf(),i=n.profile().userid,[a,s]=ae(!1);return le((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Ze(x,{children:[a&&Ze(ps,{errorType:"annotation",onLoginRequest:t}),Ze(uf,{threads:o.children})]})}),["loadAnnotationsService"]);class Jf{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.1549.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||r,this.fingerprint=t[0]?.metadata?.documentFingerprint??r,this.account=o,this.timestamp=(new Date).toString();const i=t[0]?.segment;if(i){const e=[];if(i.cfi&&e.push(["CFI",i.cfi]),i.pages){const t=`${i.pages.start}-${i.pages.end}`;e.push(["Pages",t])}
|
|
567
567
|
i.url&&e.push(["URL",i.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}var Qf=function(){if(Yf)return Kf;Yf=1;var e="complete",t="canceled";function n(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function r(t){var o=t._scrollSettings;if(o){var i=o.maxSynchronousAlignments,a=function(e,t){var n,r,o,i,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,h=c&&null!=c.top?c.top:.5,m=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,f=d,g=h;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),r=u.left+t.pageXOffset-t.innerWidth*f+s*f,o=u.top+t.pageYOffset-t.innerHeight*g+l*g,r-=m,o-=p,r=e.align.lockX?t.pageXOffset:r,
|
|
568
568
|
o=e.align.lockY?t.pageYOffset:o,i=r-t.pageXOffset,a=o-t.pageYOffset;else{s=u.width,l=u.height,n=t.getBoundingClientRect();var v=u.left-(n.left-t.scrollLeft),b=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=b+l*g-t.clientHeight*g,r-=m,o-=p,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,a=o-t.scrollTop}return{x:r,y:o,differenceX:i,differenceY:a}}(o,t),s=Date.now()-o.startTime,l=Math.min(1/o.time*s,1);if(o.endIterations>=i)return n(t,a.x,a.y),t._scrollSettings=null,o.end(e);var c=1-o.ease(l);if(n(t,a.x-a.differenceX*c,a.y-a.differenceY*c),s>=o.time)return o.endIterations++,o.scrollAncestor&&r(o.scrollAncestor),void r(t);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(r.bind(null,t))}}function o(e){return e.self===e}function i(e){
|
|
569
569
|
return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function a(){return!0}function s(e){if(e.assignedSlot)return s(e.assignedSlot);if(e.parentElement)return"body"===e.parentElement.tagName.toLowerCase()?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t.host}}return Kf=function(n,l,c){if(n){"function"==typeof l&&(c=l,l=null),l||(l={}),l.time=isNaN(l.time)?1e3:l.time,l.ease=l.ease||function(e){return 1-Math.pow(1-e,e/2)},l.align=l.align||{};var u=s(n),d=1,h=l.validTarget||a,m=l.isScrollable;l.debug&&(console.log("About to scroll to",n),u||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var p=[];u;)if(l.debug&&console.log("Scrolling parent node",u),h(u,d)&&(m?m(u,i):i(u))&&(d++,p.push(u)),!(u=s(u))){f(e);break}return p.reduce(((e,i,a)=>function(e,n,i,a,s){
|
|
@@ -650,7 +650,7 @@ null==v._nextState&&null==v.__s&&(v._nextState=v.__s=v.state),v.context=y,h.getD
|
|
|
650
650
|
}),Ze("body",{children:[Ze("section",{children:[Ze("h1",{children:"Summary"}),Ze("p",{children:Ze("time",{dateTime:o.toISOString(),children:Hb(o)})}),Ze("p",{children:Ze("strong",{children:a})}),Ze("p",{children:Ze("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Ze("table",{children:Ze("tbody",{style:{verticalAlign:"top"},children:[Ze("tr",{children:[Ze("td",{children:"Group:"}),Ze("td",{children:t})]}),Ze("tr",{children:[Ze("td",{children:"Total users:"}),Ze("td",{children:s.length})]}),Ze("tr",{children:[Ze("td",{children:"Users:"}),Ze("td",{children:s.join(", ")})]}),Ze("tr",{children:[Ze("td",{children:"Total annotations:"}),Ze("td",{children:e.length})]}),Ze("tr",{children:[Ze("td",{children:"Total replies:"}),Ze("td",{children:l.length})]})]})})]}),Ze("hr",{}),Ze("section",{children:[Ze("h1",{children:"Annotations"}),e.map(((e,t)=>{const n=Ii(e),r=Ci(e),o=dp(e.text),i=o===`<p>${e.text}</p>`?e.text:o;return Ze("article",{children:[Ze("h2",{children:["Annotation ",t+1,":"]
|
|
651
651
|
}),Ze("table",{children:Ze("tbody",{style:{verticalAlign:"top"},children:[Ze("tr",{children:[Ze("td",{children:"Created at:"}),Ze("td",{children:Ze("time",{dateTime:e.created,children:Hb(new Date(e.created))})})]}),Ze("tr",{children:[Ze("td",{children:"Author:"}),Ze("td",{children:c(e)})]}),n&&Ze("tr",{children:[Ze("td",{children:"Page:"}),Ze("td",{children:n})]}),Ze("tr",{children:[Ze("td",{children:"Type:"}),Ze("td",{children:Ei(e)})]}),r&&Ze("tr",{children:[Ze("td",{children:"Quote:"}),Ze("td",{children:Ze("blockquote",{style:{margin:0},children:r})})]}),Ze("tr",{children:[Ze("td",{children:"Comment:"}),Ze("td",{dangerouslySetInnerHTML:{__html:i}})]}),e.tags.length>0&&Ze("tr",{children:[Ze("td",{children:"Tags:"}),Ze("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}_exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e;if(!r)throw new Error("No annotations to export");const o=e=>Cs(e,n,t),{uri:i,title:a}=hi(r);return{uri:i,title:a,
|
|
652
652
|
uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>gi(e))),extractUsername:o}}}jb.$inject=[];class qb extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),this.url=e,this.response=t,this.reason=n}}async function $b(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new qb(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch{throw new qb(e,n,"Failed to parse response")}if(!n.ok)throw new qb(e,n,r?.reason);return r}class Ub{constructor(e,t,n){this._clientId=null;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{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={
|
|
653
|
-
"Content-Type":"application/json","Hypothesis-Client-Version":"1.
|
|
653
|
+
"Content-Type":"application/json","Hypothesis-Client-Version":"1.1549.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=Ba(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 $b(m.toString(),{body:s?JSON.stringify(Bb(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"),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")},
|
|
654
654
|
this.analytics={events:{create:i("analytics.events.create")}}}setClientId(e){this._clientId=e}}Ub.$inject=["apiRoutes","auth","store"];var Gb,Vb,Wb,Kb,Yb,Xb={};function Jb(){return Wb||(Wb=1,e=Xb,t=function(){if(Vb)return Gb;function e(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return Vb=1,Gb=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1
|
|
655
655
|
;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},e.prototype.try=function(e){
|
|
656
656
|
console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=o,n=a)}return t},Gb}(),e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t))
|
|
@@ -762,8 +762,8 @@ const e=JSON.stringify(this._messageQueue.shift());this._socket.send(e)}}}class
|
|
|
762
762
|
this._socket?.isConnected()&&this._socket.send(t)}async _reconnect(){const e=await this._websocketURL;if(!e)return;let t,n;this._socket?.close();try{t=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(t){const r=new URL(e);r.searchParams.set("access_token",t),n=r.toString()}else n=e;const r=new kN(n);r.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(r)})),r.on("disconnect",(()=>{if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),r.on("error",(t=>this._handleSocketError(e,t))),r.on("message",(e=>this._handleSocketMessage(e))),this._socket=r,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){this._updateImmediately=e.applyUpdatesImmediately??!0,
|
|
763
763
|
this._reconnectSetUp||(this._reconnectSetUp=!0,vy(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}NN.$inject=["store","apiRoutes","auth","groups","session","$window"];const SN="hypothesis.user.tags.list",AN="hypothesis.user.tags.map";class EN{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(SN)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${zv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(AN)||{};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(AN,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(SN,n)}}EN.$inject=["localStorage"];class TN{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),
|
|
764
764
|
e.visible||this._store.setForcedVisible(e.id,!0)}}TN.$inject=["store"];class CN extends dg.TinyEmitter{constructor(e,t){super(),this._store=e,this._window=t,this._delayedMessageQueue=[],this._window.addEventListener("focus",(()=>{this._delayedMessageQueue.forEach((({type:e,messageText:t,options:n})=>this._addMessage(e,t,n))),this._delayedMessageQueue=[]}))}dismiss(e){this._store.getToastMessage(e)&&(this._store.removeToastMessage(e),this.emit("toastMessageDismissed",e))}_addMessage(e,t,{autoDismiss:n=!0,visuallyHidden:r=!1,delayed:o=!1}={}){if(this._store.hasToastMessage(e,t))return;if(o&&!this._window.document.hasFocus()){const o={autoDismiss:n,visuallyHidden:r};return void this._delayedMessageQueue.push({type:e,messageText:t,options:o})}const i={type:e,id:wv(10),message:t,visuallyHidden:r,autoDismiss:n};this._store.addToastMessage(i),this.emit("toastMessageAdded",i)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}
|
|
765
|
-
CN.$inject=["store","$window"];const MN=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),IN=function(e){const{version:t,origin:n}=kv(e.location.href);return"1.
|
|
766
|
-
n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}MN.sentry&&IN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;cN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.
|
|
765
|
+
CN.$inject=["store","$window"];const MN=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),IN=function(e){const{version:t,origin:n}=kv(e.location.href);return"1.1549.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1549.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function zN(e,t){e.setClientId(t.clientId)}function ON(e){e.sync()}function LN(e,t){e.load(),t.load()}function RN(e,t,n){e.init(),t.init(),n.init()}function PN(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{
|
|
766
|
+
n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}MN.sentry&&IN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;cN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1549.0",beforeSend:(e,t)=>{if(uN>=5)return Cv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++uN;try{const n=t&&t.originalException;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch{}return e}});try{cx("host_config",kv(window.location.href))}catch{}cx("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),uy(((e,t)=>{dN(e,t)}))}(MN.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),
|
|
767
767
|
zN.$inject=["api","streamer"],ON.$inject=["router"],LN.$inject=["groups","session"],RN.$inject=["autosaveService","persistedDefaults","serviceURL"],PN.$inject=["frameSync","store","toastMessenger"];const DN=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",Bv)}(),async function(e,t=window){const n=function(e){const t=kv(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Nv,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Av(t.origin),ancestorLevel:Sv(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
|
|
768
768
|
;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:Ev(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await xv(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=xv(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,r)}else o=n;const i={...e,...o};return r&&(i.rpc=r),i.apiUrl=function(e){const t=Co(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(MN).then((e=>{!function(e,t){const n=new G
|
|
769
769
|
;n.register("analytics",Hv).register("annotationsExporter",jb).register("annotationsService",qv).register("annotationActivity",jv).register("api",Ub).register("apiRoutes",ty).register("auth",oy).register("autosaveService",iy).register("dashboard",ay).register("frameSync",_y).register("groups",ky).register("importAnnotationsService",mN).register("loadAnnotationsService",pN).register("localStorage",gN).register("persistedDefaults",bN).register("router",yN).register("serviceURL",_N).register("session",wN).register("streamer",NN).register("streamFilter",xN).register("tags",EN).register("threadsService",TN).register("toastMessenger",CN).register("store",{factory:hs}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(ON),n.run(RN),n.run(zN),n.run(LN),n.run(Fv),n.run(PN),H(Ze(Oo.Provider,{value:n,children:Ze(bv,{})}),t)}(e,DN)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),H(Ze(yv,{error:e}),t)}(e,DN)));
|