hypothesis 1.1547.0 → 1.1548.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?eae64b","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":"styles/sidebar.css?e2f13a","styles/sidebar.css.map":"styles/sidebar.css.map?67af10","styles/ui-playground.css":"styles/ui-playground.css?49365c","styles/ui-playground.css.map":"styles/ui-playground.css.map?0d6e99","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?fb36f3","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?4914f0","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?f2cedc"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var o=s.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=t,e(o),s.head.appendChild(o)}function o(s,t){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&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function r(s,t,o,r){var n=s.createElement("link");n.rel=t,n.href=r,n.type="application/annotator+".concat(o),e(n),s.head.appendChild(n)}function n(s,t,o){var r=s.createElement("link");r.rel="preload",r.as=t,r.href=o,"fetch"===t&&(r.crossOrigin="anonymous"),e(r),s.head.appendChild(r)}function i(s,e){return s.assetRoot+"build/"+s.manifest[e]}function a(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),o=0;o<t.length;o++){var r=void 0;try{r=JSON.parse(t[o].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(e,r)}return e}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1548.0/");if(document.querySelector("hypothesis-app")){!function(s,e){n(s,"fetch",e.apiUrl),n(s,"fetch",e.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)o(s,i(e,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)t(s,i(e,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,e){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",e.sidebarAppUrl),r(s,"notebook","html",e.notebookAppUrl),r(s,"profile","html",e.profileAppUrl),n(s,"style",i(e,"styles/annotator.css")),r(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)o(s,i(e,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++)t(s,i(e,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?eae64b",
|
|
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",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"styles/sidebar.css.map": "styles/sidebar.css.map?67af10",
|
|
13
13
|
"styles/ui-playground.css": "styles/ui-playground.css?49365c",
|
|
14
14
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?0d6e99",
|
|
15
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?d9480e",
|
|
16
15
|
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?fb36f3",
|
|
16
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?4914f0",
|
|
17
17
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?a12e9c",
|
|
18
|
-
"scripts/
|
|
19
|
-
"scripts/
|
|
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?f2cedc"
|
|
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.1548.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,44 +526,44 @@ 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,...n}){return 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),...
|
|
530
|
-
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,onClick:()=>t("list"),shortcutKey:Sp.list,title:"Bulleted list"}),Ze("div",{
|
|
531
|
-
className:"w-2.5 h-2.5"})})}),Ze(Ap,{label:e?"Write":"Preview",onClick:n})]})]})}function Cp({
|
|
532
|
-
children:[Ze(Tp,{onCommand:
|
|
533
|
-
;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
|
-
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
|
|
535
|
-
;return Ze("span",{children:[Ze("strong",{children:r}),o,Ze("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Lp(){return Ze("div",{className:"pt-2 border-t text-xs leading-none",children:Ze(bo,{href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",
|
|
536
|
-
role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Rp);let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(e.key){case"ArrowLeft":case"Escape":t&&(t(e),i=!0);break;case"ArrowUp":r-=1,r<0&&(r=n.length-1),i=!0;break;case"ArrowDown":r+=1,r===n.length&&(r=0),i=!0;break;case"Home":r=0,
|
|
537
|
-
;const v=e=>e.stopPropagation();return Ze("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:n?"relative":"static"},onClick:v,onMouseDown:v,children:[Ze("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:Xe("focus-visible-ring","flex items-center justify-center rounded transition-colors",{"text-grey-7 hover:text-grey-9":!d,
|
|
538
|
-
visible:!0,children:t})})]})}function Hp({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?Hn:qn;return Ze("div",{"data-testid":"submenu-toggle",role:"none",className:Xe("flex flex-col items-center justify-center w-10 h-10","text-grey-6 bg-grey-1","bg-clip-content border-[8px] border-transparent rounded-xl","group-hover:hover:text-grey-8",{"bg-grey-4":t,
|
|
539
|
-
className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??y}),Ze("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),w&&Ze("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:_}),f&&Ze(Hp,{title:`Show actions for ${s}`,isExpanded:a,onToggleSubmenu:u})]
|
|
540
|
-
}):Ze("div",{ref:h,className:N,"data-testid":"menu-item",tabIndex:-1,onKeyDown:v,onClick:c,role:g?"menuitemradio":"menuitem","aria-checked":g?o:void 0,"aria-haspopup":f,"aria-expanded":f?a:void 0,children:k}),Ze(x,{children:[p,f&&Ze(To,{direction:a?"in":"out",children:Ze(Pp,{closeMenu:e=>{u&&u(e),m=setTimeout((()=>{h.current.focus()}))},visible:a,
|
|
541
|
-
className:Xe("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Ze(Bp,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Ze(jp,{icon:"open"===e.type?hn:bn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Ze(jp,{icon:Pn,label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]
|
|
542
|
-
l.createDraft(t.annotation,{...t,text:e})}),[t,l]),y=he((n=>{l.createDraft(e,{...t,isPrivate:n}),u||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,u,l]),_=async()=>{a&&g(a);const t=`${Ei(e)} ${vi(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch{i.error("Saving annotation failed")}},w=he((()=>{l.removeDraft(e),vi(e)||l.removeAnnotations([e])
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
return!Ts(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${Es(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=gi(e)&&r,h=e.links?.html||"",m=de((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
"
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
const r=!!t.parent,o=t.children.filter((e=>Ns(e)>0)),i=ms(),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&&Ze(x,{children:t.annotation?Ze(x,{children:[Ze(ef,{annotation:t.annotation}),Ze(Qp,{annotation:t.annotation,isReply:r,
|
|
552
|
-
replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Ze("div",{children:Ze(xr,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",ks(t)," more in conversation"]})})]}),!t.collapsed&&Ze("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Ze("li",{className:Xe("mt-2","[text-align:start]"),children:Ze(e,{thread:t,threadsService:n})},t.id)))})]})]})
|
|
553
|
-
onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Ze(dt,{children:l})},t.id)}),["frameSync"]);const of=50;function af(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function sf(e){return Math.max(e-e%of,0)}
|
|
554
|
-
;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=_s){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=de((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=lf(n.annotation)
|
|
555
|
-
const e=v.filter((e=>e.id&&g.includes(e.id))).reduce(((e,t)=>!e||e.updated<t.updated?t:e),null);return e?.id}),[v,g]);return le((()=>{!f&&y&&l(y)}),[f,y]),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)||_s.defaultHeight)(t)),0);af().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=ws(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))
|
|
556
|
-
const r=e[n];return!(!r||r.parent===t)&&(!r.parent||mf(e,t,r.parent))}function pf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...df,children:[],id:r},pf(e,r,n.slice(0,-1))),mf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function ff(e,t){return Object.assign({},t(e),{children:e.children.map((e=>ff(e,t)))})}function gf(e,t,n){const r=e.children.map((e=>gf(e,n,n))).slice().sort(t);return{...e,children:r}}function vf(e,t){const n=e.children.map((e=>vf(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function bf(e){
|
|
557
|
-
;return pf(t,hf(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...df,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=ff(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),
|
|
558
|
-
;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function kf(e,t){const n=e=>function(e){const t=xf(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){if(typeof e[n]!=typeof t[n])return"number"==typeof e[n]?-1:1;if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}(n(e),n(t))}function Nf(e,t,n){return kf(e,t)>=0&&kf(e,n)<0}function Sf(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e]
|
|
559
|
-
;if(!n||!r)return e&&t&&e===t?Af.Overlap:Af.Unknown;const o=2**31,[i,a]=Ef(n,1,o),[s,l]=Ef(r,1,o);return i<=s?s<=a?Af.Overlap:Af.NoOverlap:i<=l?Af.Overlap:Af.NoOverlap}
|
|
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;return t.add(e,"keyup",(t=>{"Escape"!==t.key&&i(function(e,t){return e.slice(0,t).match(/\S+$/)?.[0]??""}(e.value,e.selectionStart).startsWith("@"))})),()=>{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"})]})}function Tp({isPreviewing:e,onCommand:t,onTogglePreview:n}){const r=ue(null)
|
|
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,onClick:()=>t("list"),shortcutKey:Sp.list,title:"Bulleted list"}),Ze("div",{
|
|
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)
|
|
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
|
+
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
|
+
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
|
|
535
|
+
;-1!==l?v(a[l]):1===a.length?v(a[0]):v(p()),e.preventDefault()}},onFocus:()=>{f()&&d(!0)},elementRef:i,placeholder:"Add new tags",type:"text",autoComplete:"off","aria-autocomplete":"list","aria-activedescendant":y,"aria-controls":`${h}-AutocompleteList`,"aria-expanded":u,"aria-label":"Add tags",dir:"auto",role:"combobox",classes:Xe("text-base touch:text-touch-base")}),Ze(Ip,{id:`${h}-AutocompleteList`,list:a,listFormatter:e=>{const t=p().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return Ze("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return Ze("span",{children:[Ze("strong",{children:r}),o,Ze("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Lp(){return Ze("div",{className:"pt-2 border-t text-xs leading-none",children:Ze(bo,{href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",
|
|
536
|
+
title:"View more information about the Creative Commons Public Domain dedication",underline:"none",variant:"text-light",children:Ze("div",{className:"flex items-center",children:[Ze(St,{className:"w-[10px] h-[10px]"}),Ze(Et,{className:"w-[10px] h-[10px] ml-px"}),Ze("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})})}function Rp(e){return null!==e.offsetParent}function Pp({className:e,closeMenu:t,children:n,visible:r}){const o=ue(null);le((()=>{let e;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return Ze("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Rp);let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(e.key){case"ArrowLeft":case"Escape":t&&(t(e),i=!0);break;case"ArrowUp":r-=1,r<0&&(r=n.length-1),i=!0;break;case"ArrowDown":r+=1,r===n.length&&(r=0),i=!0;break;case"Home":r=0,
|
|
537
|
+
i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}let Dp=!1;const Fp=()=>{};function Bp({align:e="left",children:t,containerPositioned:n=!0,contentClass:r,defaultOpen:o=!1,disabled:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[d,h]=ae(o);"boolean"==typeof s&&(d=s,h=l||Fp);const m=ue(d);le((()=>{"function"==typeof l&&m.current!==d&&(m.current=d,l(d))}),[d,l]);const p=e=>{if("mousedown"===e.type)Dp=!0;else if("click"===e.type&&Dp)return Dp=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=he((()=>h(!1)),[h]),g=ue(null);Ce(g,f,{enabled:d});const v=e=>e.stopPropagation();return Ze("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:n?"relative":"static"},onClick:v,onMouseDown:v,children:[Ze("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:Xe("focus-visible-ring","flex items-center justify-center rounded transition-colors",{"text-grey-7 hover:text-grey-9":!d,
|
|
538
|
+
"text-brand":d}),"data-testid":"menu-toggle-button",disabled:i,onMouseDown:p,onClick:p,"aria-label":u,title:u,children:Ze("span",{className:"flex items-center gap-x-1",children:[a,c&&Ze("span",{className:Xe({"rotate-180 text-color-text":d}),children:Ze(qn,{className:"w-2.5 h-2.5"})})]})}),d&&Ze("div",{className:Xe("focus-visible-ring","absolute top-[calc(100%+3px)] z-1","border shadow-intense rounded-lg overflow-hidden bg-white text-md",{"left-0":"left"===e,"right-0":"right"===e},r),"data-testid":"menu-content",role:"menu",tabIndex:-1,onClick:f,onKeyDown:e=>{const t=e.key;"Enter"!==t&&" "!==t||setTimeout((()=>{f()}))},children:Ze(Pp,{visible:!0,children:t})})]})}function Hp({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?Hn:qn;return Ze("div",{"data-testid":"submenu-toggle",role:"none",className:Xe("flex flex-col items-center justify-center w-10 h-10","text-grey-6 bg-grey-1","bg-clip-content border-[8px] border-transparent rounded-xl","group-hover:hover:text-grey-8",{"bg-grey-4":t,
|
|
539
|
+
"group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Ze(r,{className:"w-3 h-3",viewBox:"0 0 16 16"})})}function jp({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d}){const h=ue(null);let m,p;const f="boolean"==typeof a,g="boolean"==typeof o;le((()=>()=>{clearTimeout(m)}),[]);const v=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},b=t?Ze(t,{className:"h-3 w-3"}):null,y=i?null:b,_=i?b:null,w=!!_,k=Ze(x,{children:[(l||i||!!y)&&Ze("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??y}),Ze("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),w&&Ze("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:_}),f&&Ze(Hp,{title:`Show actions for ${s}`,isExpanded:a,onToggleSubmenu:u})]
|
|
540
|
+
}),N=Xe("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","rounded-none",{"focus-visible:rounded-lg":!o,"focus-visible:rounded-r-lg":o,"cursor-pointer":!n},"group",{"min-h-[30px] font-normal":i,"min-h-[40px] font-medium":!i,"bg-grey-1":i||r,"hover:bg-grey-3":!n&&(i||r),"bg-white":!i&&!r,"hover:bg-grey-1":!n&&!i&&!r,"pr-1":!f},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return p=e?Ze("a",{ref:h,className:N,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:v,children:k}):Ze("div",{ref:h,className:N,"data-testid":"menu-item",tabIndex:-1,onKeyDown:v,onClick:c,role:g?"menuitemradio":"menuitem","aria-checked":g?o:void 0,"aria-haspopup":f,"aria-expanded":f?a:void 0,children:k}),Ze(x,{children:[p,f&&Ze(To,{direction:a?"in":"out",children:Ze(Pp,{closeMenu:e=>{u&&u(e),m=setTimeout((()=>{h.current.focus()}))},visible:a,
|
|
541
|
+
className:"border-y border-grey-3",children:d})})]})}var qp=Lo((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=zo(["ctaTextColor","ctaBackgroundColor"],a),l=Ze("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Ze(qn,{className:"w-4 h-4"})});return Ze("div",{className:"flex flex-row gap-x-3",children:[Ze("div",{className:"flex relative",children:[Ze(xr,{classes:Xe("rounded-r-none"),"data-testid":"publish-control-button",style:s,onClick:o,disabled:t,size:"lg",variant:"primary",children:["Post to ",n?"Only Me":e.name]}),Ze("div",{className:Xe("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Ze(Bp,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Ze(jp,{icon:"open"===e.type?hn:bn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Ze(jp,{icon:Pn,label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]
|
|
542
|
+
}),Ze("div",{children:Ze(xr,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Ze(yt,{}),"Cancel"]})})]})}),["settings"]);var $p=Lo((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){const[a,s]=ae(null),l=ms(),c=l.getGroup(e.group),u=de((()=>gi(e)),[e]),d=!t.isPrivate&&c&&"private"!==c.type,h=t.tags,m=t.text,p=!m&&!h.length,f=he((e=>{l.createDraft(t.annotation,{...t,tags:e})}),[t,l]),g=he((e=>{if(!e||h.indexOf(e)>=0)return!1;const t=[...h,e];return o.store(t),f(t),!0}),[f,h,o]),v=he((e=>{const t=[...h],n=t.indexOf(e);return n>=0&&(t.splice(n,1),f(t),!0)}),[f,h]),b=he((e=>{l.createDraft(t.annotation,{...t,text:e})}),[t,l]),y=he((n=>{l.createDraft(e,{...t,isPrivate:n}),u||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,u,l]),_=async()=>{a&&g(a);const t=`${Ei(e)} ${vi(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch{i.error("Saving annotation failed")}},w=he((()=>{l.removeDraft(e),vi(e)||l.removeAnnotations([e])
|
|
543
|
+
}),[e,l]);return Ze("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;p||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),_())},children:[Ze(Cp,{textStyle:zo(["annotationFontFamily"],r),label:u?"Enter reply":"Enter comment",text:m,onEditText:b,atMentionsEnabled:l.isFeatureEnabled("at_mentions")}),Ze(Op,{onAddTag:g,onRemoveTag:v,onTagInput:s,tagList:h}),c&&Ze(qp,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:w,onSave:_,onSetPrivate:y}),d&&Ze(Lp,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Up({domain:e,link:t,title:n}){return Ze("div",{className:"flex gap-x-1",children:[Ze("div",{className:"text-color-text-light",children:['on "',t?Ze(bo,{href:t,target:"_blank",underline:"none",children:n}):Ze("span",{children:n}),'"']}),e&&Ze("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function Gp({group:e}){const t=e?.links.html;return Ze(x,{children:e&&t&&Ze(bo,{
|
|
544
|
+
classes:Xe("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:Ze("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?Ze(hn,{className:"w-2.5 h-2.5"}):Ze(bn,{className:"w-2.5 h-2.5"}),Ze("span",{children:e.name})]})})})}function Vp({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){const[o,i]=ae((()=>new Date)),a=de((()=>new Date(e)),[e]),s=de((()=>r&&new Date(t)),[t,r]),l=de((()=>({absolute:Ge(a,{includeWeekday:!0}),relative:Ue(a,o)})),[a,o]),c=de((()=>s?{absolute:Ge(s,{includeWeekday:!0}),relative:Ue(s,o)}:{}),[s,o]);le((()=>$e(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Ze("div",{children:[r&&Ze("span",{className:"text-color-text-light text-xs italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Ze(bo,{classes:"text-color-text-light hover:text-color-text-light",target:"_blank",
|
|
545
|
+
title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative}):Ze("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function Wp({authorLink:e,displayName:t}){const n=Ze("h3",{className:"text-color-text font-bold",children:t});return e?Ze(bo,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):Ze("div",{children:n})}var Kp=Lo((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){const i=ms(),a=i.defaultAuthority(),s=i.isFeatureEnabled("client_display_names"),l=i.getLink("user",{user:e.user}),c=de((()=>Cs(e,a,s)),[e,a,s]),u=de((()=>function(e,t,n,r){return!Ts(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${Es(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=gi(e)&&r,h=e.links?.html||"",m=de((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3
|
|
546
|
+
}(e)&&!d),[e,d]),p=function(e){return{domain:pi(e),titleText:fi(e),titleLink:mi(e)}}(e),f=h&&p.titleLink?p.titleLink:"",g="sidebar"!==i.route()&&p.titleText;let v;"sidebar"!==i.route()&&(v=i.getGroup(e.group));const b=Ii(e);return Ze("header",{children:[Ze("div",{className:"flex gap-x-1 items-center flex-wrap-reverse",children:[Rs(e.permissions)&&!t&&Ze(Pn,{className:"w-[12px] h-[12px]",title:"This annotation is visible only to you"}),Ze(Wp,{authorLink:u,displayName:c}),n>0&&d&&Ze(_o,{variant:"text-light",onClick:()=>i.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Ze("div",{className:"flex justify-end grow",children:Ze(Vp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,withEditedTimestamp:m})})]}),!gi(e)&&Ze("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[v&&Ze(Gp,{group:v}),!t&&ki(e)&&Ze(Nn,{
|
|
547
|
+
title:"This is a highlight. Click 'edit' to add a note or tag.",className:"w-[10px] h-[10px] text-color-text-light"}),(g||b)&&Ze("span",{className:"flex",children:[g&&Ze(Up,{domain:p.domain,link:f,title:p.titleText}),b&&Ze("span",{className:"text-grey-6","data-testid":"page-number",children:[g&&", ","p. ",b]})]})]})]})}),["settings"]);var Yp=Lo((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Ze(Vs,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Ze(hp,{classes:Xe({"p-redacted-text":n}),children:Ze("blockquote",{className:Xe("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:zo(["selectionFontFamily"],r),children:e})})})}),["settings"]);function Xp({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Ze(xr,{classes:Xe("text-grey-7 enabled:hover:text-brand-dark","enabled:hover:underline"),onClick:e,title:r,variant:"custom",children:r})}function Jp(){return Ze("div",{
|
|
548
|
+
className:Xe("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Ze("span",{className:"text-[16px] animate-fade-in-slow",children:Ze(co,{size:"sm"})}),Ze("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var Qp=Lo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ms(),s=Ci(e),l=a.getDraft(e),c=a.profile().userid,u=a.isAnnotationHovered(e.$tag),d=a.isSavingAnnotation(e),h=!!l&&!d,m=t&&o,p=!d&&!h&&vi(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=de((()=>Cs(e,f,g)),[e,f,g]);return Ze("article",{className:"space-y-4","aria-label":`${vi(e)?Ei(e):`New ${Ei(e).toLowerCase()}`} by ${v}${a.isAnnotationHighlighted(e)?" - Highlighted":""}`,children:[Ze(Kp,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Ze(Yp,{quote:s,isHovered:u,isOrphan:Ni(e)}),!m&&!h&&Ze(vp,{annotation:e}),h&&Ze($p,{annotation:e,draft:l
|
|
549
|
+
}),!m&&Ze("footer",{className:"flex items-center",children:[n&&Ze(Xp,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Ze(Jp,{}),p&&Ze(ct,{classes:"grow",children:Ze($s,{annotation:e,onReply:()=>{vi(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function Zp({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Ze("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Ze("div",{children:Ze("em",{children:"Message not available."})}),r&&Ze("footer",{className:"flex items-center",children:Ze(Xp,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var ef=Lo((function({annotation:e,api:t,toastMessenger:n}){const r=ms(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Ze("div",{className:Xe("flex gap-x-3 bg-grey-1 text-color-text font-semibold","mb-2 ",{"-mt-3 -ml-3 -mr-3":!gi(e),"-mr-3":gi(e)}),children:[Ze("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,
|
|
550
|
+
"bg-grey-6":e.hidden}),children:e.hidden?Ze(xn,{className:"w-em h-em"}):Ze(ln,{className:"w-em h-em"})}),Ze("div",{className:"self-center grow",children:[!e.hidden&&Ze("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Ze("span",{children:"Hidden from users"})]}),Ze("div",{className:"self-center pr-2",children:Ze(xr,{classes:Xe("px-1.5 py-1","bg-slate-1 text-grey-7 bg-grey-2","enabled:hover:text-grey-9 enabled:hover:bg-grey-3 disabled:text-grey-5","aria-pressed:bg-grey-3 aria-expanded:bg-grey-3"),onClick:e.hidden?()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))}:()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},title:e.hidden?"Make this annotation visible to everyone":"Hide this annotationn from non-moderators",size:"custom",variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null
|
|
551
|
+
}),["api","toastMessenger"]);function tf({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:qn,r=e?"Expand replies":"Collapse replies";return Ze("div",{className:Xe("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Ze("div",{className:Xe("bg-white"),children:Ze(xr,{classes:Xe("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-5 hover:text-grey-7"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Ze(n,{className:"w-em h-em"})})})})}var nf=Lo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Ns(e)>0)),i=ms(),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&&Ze(x,{children:t.annotation?Ze(x,{children:[Ze(ef,{annotation:t.annotation}),Ze(Qp,{annotation:t.annotation,isReply:r,
|
|
552
|
+
onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Ze(Zp,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Ze("section",{className:"flex","data-testid":"thread-container",children:[r&&Ze(tf,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ze("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,ks(t)>0&&Ze("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ze(Kp,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Ze("div",{children:Ze(xr,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",ks(t)," more in conversation"]})})]}),!t.collapsed&&Ze("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Ze("li",{className:Xe("mt-2","[text-align:start]"),children:Ze(e,{thread:t,threadsService:n})},t.id)))})]})]})
|
|
553
|
+
}),["threadsService"]);var rf=Lo((function({frameSync:e,thread:t}){const n=ms(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=de((()=>bs((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=he((t=>{e.scrollToAnnotation(t)}),[e]),l=de((()=>Ze(nf,{thread:t})),[t]),c=n.annotationFocusRequest(),u=ue(null);return le((()=>{c===t.id&&u.current&&(u.current.focus(),n.clearAnnotationFocusRequest())}),[c,n,t.id]),Ze(st,{active:o,classes:Xe("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a}),"data-testid":"thread-card",elementRef:u,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Ze(dt,{children:l})},t.id)}),["frameSync"]);const of=50;function af(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function sf(e){return Math.max(e-e%of,0)}
|
|
554
|
+
function lf(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function cf(e){if(!e.annotation)return null;const t=lf(e.annotation);return t?.cfi??null}function uf({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ys,t=af();n(t.clientHeight),o(sf(t.scrollTop));const r=bs((()=>{n(t.clientHeight),o(sf(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=_s){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=de((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=lf(n.annotation)
|
|
555
|
+
;e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=cf(i);if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),p=ms(),f=p.countDrafts()>0,g=p.highlightedAnnotations(),v=p.allAnnotations(),b=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();le((()=>{b&&(p.setForcedVisible(b,!0),l(b))}),[p,b]);const y=de((()=>{const e=v.filter((e=>e.id&&g.includes(e.id))).reduce(((e,t)=>!e||e.updated<t.updated?t:e),null);return e?.id}),[v,g]);return le((()=>{!f&&y&&l(y)}),[f,y]),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)||_s.defaultHeight)(t)),0);af().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=ws(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))
|
|
556
|
+
}),[h]),Ze("div",{children:[Ze("div",{style:{height:d}}),h.map((e=>Ze("div",{className:Xe("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[m.get(e)&&Ze("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(e)}),Ze(rf,{thread:e})]},e.id))),Ze("div",{style:{height:u}})]})}const df={collapsed:!1,depth:0,visible:!0,replyCount:0};function hf(e){return e.id||e.$tag}function mf(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||mf(e,t,r.parent))}function pf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...df,children:[],id:r},pf(e,r,n.slice(0,-1))),mf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function ff(e,t){return Object.assign({},t(e),{children:e.children.map((e=>ff(e,t)))})}function gf(e,t,n){const r=e.children.map((e=>gf(e,n,n))).slice().sort(t);return{...e,children:r}}function vf(e,t){const n=e.children.map((e=>vf(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function bf(e){
|
|
557
|
+
return e.children.some((e=>e.visible||bf(e)))}const yf=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function _f(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=hf(e);t[n]={...df,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return pf(t,hf(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...df,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=ff(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),
|
|
558
|
+
o.children=o.children.filter((e=>e.visible||bf(e))),o=ff(o,(e=>{const n={collapsed:e.collapsed};if(di(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&bf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=gf(o,t.sortCompareFn,yf),o=vf(o,-1),o}function wf(e){const t=xf(e),[n,r]=t.split("-",2);return[n,r??n]}function xf(e){if(!e.includes("["))return e;let t="",n=!1,r=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function kf(e,t){const n=e=>function(e){const t=xf(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){if(typeof e[n]!=typeof t[n])return"number"==typeof e[n]?-1:1;if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}(n(e),n(t))}function Nf(e,t,n){return kf(e,t)>=0&&kf(e,n)<0}function Sf(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e]
|
|
559
|
+
;let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let Af=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function Ef(e,t,n){return[e[0]??t,e[1]??n]}function Tf(e,t){const n=Sf(e),r=Sf(t);if(!n||!r)return e&&t&&e===t?Af.Overlap:Af.Unknown;const o=2**31,[i,a]=Ef(n,1,o),[s,l]=Ef(r,1,o);return i<=s?s<=a?Af.Overlap:Af.NoOverlap:i<=l?Af.Overlap:Af.NoOverlap}
|
|
560
560
|
const Cf=/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u08FE\u0900-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D02\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1DC0-\u1DE6\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE26]/g
|
|
561
561
|
;function Mf(e){return function(e){return e.replace(Cf,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class If{constructor(e,t){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 zf{constructor(e,t){this.operator=e,this.filters=t}matches(e){return"and"===this.operator?this.filters.every((t=>t.matches(e))):this.filters.some((t=>t.matches(e)))}}function Of(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:Mf}}const Lf={quote:Of((e=>[Ci(e)??""])),cfi:{fieldValues:e=>[Mi(e)?.trim()??""],matches:(e,t)=>{const[n,r]=wf(t);return Nf(e,n,r)},normalize:e=>xf(e.trim())},page:{fieldValues:e=>[Ii(e)?.trim()??""],matches:(e,t)=>Tf(e,t)===Af.Overlap,normalize:e=>e.trim()},since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:Of((e=>e.tags)),text:Of((e=>[e.text])),uri:Of((e=>[e.uri])),user:Of((e=>[e.user,e.user_info?.display_name??""]))}
|
|
562
562
|
;function Rf(e,t){const n=(e,t)=>new If(t,Lf[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 zf("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new zf(t.operator,r)})),o=new zf("and",r);return e.filter((e=>o.matches(e)))}const Pf=["cfi","quote","page","since","tag","text","uri","user"],Df=["group","quote","tag","text","uri","user"];function Ff(e,t){const n=e.slice(0,e.indexOf(":"));if(!n)return[null,e];if(t.includes(n)){return[n,e.slice(n.length+1)]}return[null,e]}function Bf(e){const t=e.slice(0,1),n=e.slice(-1);return'"'!==t&&"'"!==t||t!==n||(e=e.slice(1,e.length-1)),e}function Hf(e,t){const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map(Bf).filter((e=>e.length>0)).map((e=>{const[n,r]=Ff(e,t);return n?n+":"+Bf(r):e})):[]}function jf(e){const t={},n=e=>"tag"===e?"tags":e,r=Hf(e,Df);for(const e of r){let[r,o]=Ff(e,Df);r||(r="any",o=e);const i=n(r);t[i]?t[i].push(o):t[i]=[o]}
|
|
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.1548.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.1548.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.1548.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1548.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.1548.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)));
|