hypothesis 1.1555.0 → 1.1556.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?871ed7","styles/annotator.css.map":"styles/annotator.css.map?969663","styles/annotator.css":"styles/annotator.css?4a2cb6","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?d92c5a","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?5068b6","styles/sidebar.css.map":"styles/sidebar.css.map?c64c75","styles/ui-playground.css":"styles/ui-playground.css?b9b933","styles/ui-playground.css.map":"styles/ui-playground.css.map?d1c947","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?f2a47e","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?923a7c","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?d4fffd","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?e7c571","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?243dea"};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.1555.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/.")}();
1
+ !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?e12fce","styles/annotator.css":"styles/annotator.css?4a2cb6","styles/annotator.css.map":"styles/annotator.css.map?969663","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?d92c5a","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?5068b6","styles/sidebar.css.map":"styles/sidebar.css.map?c64c75","styles/ui-playground.css":"styles/ui-playground.css?b9b933","styles/ui-playground.css.map":"styles/ui-playground.css.map?d1c947","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?923a7c","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?a6593a","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?d4fffd","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?f839d0","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?243dea"};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.1556.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/.")}();
@@ -1,7 +1,7 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?871ed7",
3
- "styles/annotator.css.map": "styles/annotator.css.map?969663",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?e12fce",
4
3
  "styles/annotator.css": "styles/annotator.css?4a2cb6",
4
+ "styles/annotator.css.map": "styles/annotator.css.map?969663",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
6
6
  "styles/highlights.css.map": "styles/highlights.css.map?241350",
7
7
  "styles/katex.min.css": "styles/katex.min.css?d92c5a",
@@ -12,9 +12,9 @@
12
12
  "styles/sidebar.css.map": "styles/sidebar.css.map?c64c75",
13
13
  "styles/ui-playground.css": "styles/ui-playground.css?b9b933",
14
14
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?d1c947",
15
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?f2a47e",
16
15
  "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?923a7c",
16
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?a6593a",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?d4fffd",
18
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?e7c571",
18
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?f839d0",
19
19
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?243dea"
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=fo.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&&Eo(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}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+en(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Sr(),r}_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);ko(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=bo(n),i=yo(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=xr(),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){zn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new wr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Ar(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Rr(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.1555.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=re(null);return oe((()=>{e?r.current?.close():r.current?.showModal()}),[e]),oe((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Pe("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Tr({closed:e,children:t,...n}){return Pe("div",{...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.1556.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=re(null);return oe((()=>{e?r.current?.close():r.current?.showModal()}),[e]),oe((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Pe("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Tr({closed:e,children:t,...n}){return Pe("div",{...n,
148
148
  className:Ae("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Pe("div",{className:"relative w-full h-full",children:t})})}function Or({document_:e=document,...t}){return Pe(se((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Pr:Tr),[e]),{...t})}function Lr({config:e,groupId:t}){return Pe("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Ar(e.notebookAppUrl,{...Rr(e.notebookAppUrl,e),group:t})})}function Mr({eventBus:e,config:t}){const[n,o]=ne(0),[i,r]=ne(!0),[s,a]=ne(null),l=re(""),c=re(null);oe((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),oe((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),oe((()=>{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=ae((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
149
149
  ;return null===s?null:Pe(Or,{closed:i,onClose:d,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Pe("div",{className:"absolute right-0 m-3",children:Pe(St,{title:"Close notebook",onClick:d,variant:"dark",classes:Ae("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Pe(De,{className:"w-4 h-4"})})}),Pe(Lr,{config:t,groupId:s},n)]})}class Ir{constructor(e,t,n){this._container=new eo("notebook",(()=>Pe(Mr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Br({eventBus:e,config:t}){const[n,o]=ne(!0),i=re(null);oe((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{o(!1)})),i.current=t,()=>{t.destroy()}}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:Pe(Or,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Pe("div",{className:"absolute right-0 m-3",children:Pe(St,{
150
150
  title:"Close profile dialog",onClick:r,variant:"dark",classes:Ae("!bg-transparent enabled:hover:!bg-grey-3"),children:Pe(De,{className:"w-4 h-4"})})}),Pe("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Fr{constructor(e,t,n){this._container=new eo("profile",(()=>Pe(Br,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Dr({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 Pe("ul",{className:"relative",children:[s&&Pe("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:Pe(Jt,{"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,47 +526,47 @@ n=ic(t.expression)}return e.replace(hp(t.id),n)}),e)}(n,t.mathBlocks);return r}f
526
526
  variant:"text-light",href:e,lang:"",target:"_blank","aria-label":`Tag: ${n}`,title:`View annotations with tag: ${n}`,underline:"none",children:n}):Ze("span",{className:"text-color-text-light cursor-default","aria-label":`Tag: ${n}`,lang:"",children:n})}),t&&Ze("button",{className:Xe("px-1.5 py-1 touch:p-2","border-l rounded rounded-l-none","text-grey-6 hover:text-color-text hover:bg-grey-2","transition-colors duration-200","focus-visible-ring ring-inset"),onClick:()=>{t(n)},title:`Remove tag: ${n}`,children:Ze(yt,{className:"font-base w-em h-em",title:`Remove ${n}`})})]})}function bp({classes:e,setCollapsed:t,collapsed:n}){const r=n?"More":"Less";return Ze(xr,{classes:Xe("text-grey-7 font-normal",e),expanded:!n,onClick:()=>t(!n),title:`Toggle visibility of full annotation text: Show ${r}`,children:Ze("div",{className:"flex items-center gap-x-2",children:[Ze(n?tn:Dt,{className:"w-3 h-3"}),Ze("div",{children:r})]})})}cp.addHook("afterSanitizeAttributes",(e=>{"target"in e&&e.setAttribute("target","_blank")}))
527
527
  ;var yp=Lo((function({annotation:e,settings:t}){const[n,r]=ae(!0),[o,i]=ae(!1),a=vs(),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&&!pi(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(fp,{markdown:u,classes:Xe({"p-redacted-text":Si(e)}),style:m})}),(o||h)&&Ze("div",{className:"flex flex-row gap-x-2",children:[Ze("div",{className:"grow",children:h&&Ze(gp,{children:c.map((e=>Ze(vp,{tag:e,href:p?f(e):void 0},e)))})}),o&&Ze("div",{children:Ze(bp,{classes:Xe("-mt-3"),collapsed:n,setCollapsed:r})})]})]})}),["settings"]);let _p=function(e){return e.ANCHOR_LINK="ANCHOR_LINK",e.IMAGE_LINK="IMAGE_LINK",e}({});function wp(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd;return o>=t+n?(o+=r.length-n,
528
528
  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 xp(e,t=_p.ANCHOR_LINK){const n=e.text.slice(e.selectionStart,e.selectionEnd);let r,o="";if(t===_p.IMAGE_LINK&&(o="!"),n.match(/[a-z]+:\/\/.*/)){const t="Description";return r=wp(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=wp(e,e.selectionStart,n.length,t+i+")"),r.selectionStart=e.selectionStart+t.length,r.selectionEnd=r.selectionStart+i.length,r}}function kp(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=wp(e,e.selectionStart,0,r),a.selectionStart=a.selectionEnd-r.length),
529
- o===t&&i===n?(a=wp(a,a.selectionStart-t.length,t.length,""),a=wp(a,a.selectionEnd,n.length,"")):(a=wp(a,a.selectionStart,0,t),a=wp(a,a.selectionEnd,0,n)),a}function Np(e,t){const n=e.indexOf("\n",t);return n<0?e.length:n}function Sp(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=Np(e.text,t),a=0;for(;i<=Np(e.text,n);){const t=i===e.text.length,s=i-o,l=Np((e=r(e,o,i,a)).text,o)-o;if(n+=l-s,t)break;o=o+l+1,i=Np(e.text,o),a+=1}return e}function Ap(e,t){const n=e.selectionStart,r=e.selectionEnd,o=e=>"function"==typeof t?t(e):t;let i=!0;return Sp(e,n,r,((e,t,n,r)=>{const a=o(r);return e.text.slice(t,t+a.length)!==a&&(i=!1),e})),Sp(e,n,r,i?(e,t,n,r)=>wp(e,t,o(r).length,""):(e,t,n,r)=>{const i=o(r);return e.text.slice(t,t+i.length)===i?e:wp(e,t,0,i)})}function Ep({users:e,onSelectUser:t,highlightedSuggestion:n,...r}){return Ze(to,{...r,classes:"p-1",children:Ze("ul",{className:"flex-col gap-y-0.5",role:"listbox","aria-orientation":"vertical",children:[e.map(((e,r)=>Ze("li",{
530
- className:Xe("flex justify-between items-center","rounded p-2 hover:bg-grey-2",{"bg-grey-2":n===r}),onClick:n=>{n.stopPropagation(),t(e)},role:"option","aria-selected":n===r,children:[Ze("span",{className:"truncate",children:e.username}),Ze("span",{className:"text-color-text-light",children:e.displayName})]},e.username))),0===e.length&&Ze("li",{className:"italic p-2","data-testid":"suggestions-fallback",children:"No matches. You can still write the username"})]})})}const Tp={bold:"b",image:"g",italic:"i",link:"l",list:"u",math:"m",numlist:"o",quote:"q"};function Cp({disabled:e=!1,icon:t,label:n,onClick:r,shortcutKey:o,title:i=""}){const a=de((()=>Ps()?"Cmd":"Ctrl"),[]);let s=i;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]"})})}
531
- function Mp({classes:e,containerRef:t,mentionsEnabled:n,usersForMentions:r,onEditText:o,onKeyDown:i,...a}){const[s,l]=ae(!1),[c,u]=ae(),d=ze(t),[h,m]=ae(0),p=de((()=>n&&void 0!==c?r.filter((e=>!c||`${e.username} ${e.displayName??""}`.toLowerCase().match(c.toLowerCase()))).slice(0,10):[]),[c,n,r]),f=he((e=>{if(!n)return;const t=function(e,t){return e.slice(0,t).match(/\S+$/)?.[0]??""}(e.value,e.selectionStart),r=t.startsWith("@");l(r),u(r?t.substring(1):void 0),r||m(0)}),[n]),g=he((e=>{const t=d.current,{value:n}=t,{start:r,end:i}=function(e,t){const n=e.slice(0,t).search(/\s\S*$/),r=e.slice(t).search(/\s/);return{start:(-1===n?-1:n)+1,end:-1===r?e.length:t+r}}(n,t.selectionStart),a=`${n.slice(0,r)}@${e.username} `,s=n.slice(i);t.value=`${a}${s}`,t.selectionStart=a.length,t.selectionEnd=a.length,t.focus(),o(t.value),l(!1),m(0)}),[o,d]);return Ze("div",{className:"relative",children:[Ze("textarea",{
532
- className:Xe("border rounded p-2","text-color-text-light bg-grey-0","focus:bg-white focus:outline-none focus:shadow-focus-inner",e),onInput:e=>o(e.target.value),...a,onKeyUp:e=>{["Escape","Enter"].includes(e.key)||f(e.target)},onKeyDown:e=>{i?.(e),s&&0!==p.length&&("ArrowDown"===e.key?(e.preventDefault(),m((e=>Math.min(e+1,p.length-1)))):"ArrowUp"===e.key?(e.preventDefault(),m((e=>Math.max(e-1,0)))):"Enter"===e.key&&(e.preventDefault(),g(p[h])))},onClick:e=>{e.stopPropagation(),f(e.target)},ref:d}),n&&Ze(Ep,{open:s,onClose:()=>l(!1),anchorElementRef:d,users:p,highlightedSuggestion:h,onSelectUser:g})]})}function Ip({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(Cp,{disabled:e,icon:Yt,
533
- onClick:()=>t("bold"),shortcutKey:Tp.bold,title:"Bold"}),Ze(Cp,{disabled:e,icon:Jt,onClick:()=>t("italic"),shortcutKey:Tp.italic,title:"Italic"}),Ze(Cp,{disabled:e,icon:Wt,onClick:()=>t("quote"),shortcutKey:Tp.quote,title:"Quote"}),Ze(Cp,{disabled:e,icon:Mn,onClick:()=>t("link"),shortcutKey:Tp.link,title:"Insert link"}),Ze(Cp,{disabled:e,icon:An,onClick:()=>t("image"),shortcutKey:Tp.image,title:"Insert image"}),Ze(Cp,{disabled:e,icon:Gt,onClick:()=>t("math"),title:"Insert math (LaTeX is supported)"}),Ze(Cp,{disabled:e,icon:zn,onClick:()=>t("numlist"),shortcutKey:Tp.numlist,title:"Numbered list"}),Ze(Cp,{disabled:e,icon:Ln,onClick:()=>t("list"),shortcutKey:Tp.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",{
534
- 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(Cp,{label:e?"Write":"Preview",onClick:n})]})]})}function zp({mentionsEnabled:e=!1,label:t,onEditText:n=(()=>{}),text:r,textStyle:o={},usersForMentions:i}){const[a,s]=ae(!1),l=ue(null);le((()=>{a||l.current?.focus()}),[a]);const c=e=>{l.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);return 0===t.length||"\n"===t.slice(-1)||"$$"===t.slice(-2)?kp(e,"$$","$$","Insert LaTeX"):kp(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>kp(e,"**","**","Bold")));break;case"italic":n((e=>kp(e,"*","*","Italic")));break;case"quote":n((e=>Ap(e,"> ")));break;case"link":n((e=>xp(e)));break;case"image":n((e=>xp(e,_p.IMAGE_LINK)));break;case"math":
535
- n(r);break;case"numlist":n((e=>Ap(e,(e=>`${e+1}. `))));break;case"list":n((e=>Ap(e,"* ")))}}(e,l.current),n(l.current.value))};return Ze("div",{className:"leading-none",children:[Ze(Ip,{onCommand:c,isPreviewing:a,onTogglePreview:()=>s(!a)}),a?Ze(fp,{markdown:r,classes:"border bg-grey-1 p-2",style:o}):Ze(Mp,{"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:l,onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(const[t,n]of Object.entries(Tp))n===e.key&&(e.stopPropagation(),e.preventDefault(),c(t))},onEditText:n,value:r,style:o,mentionsEnabled:e,usersForMentions:i})]})}const Op=e=>e;function Lp({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Op,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",{
536
- "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 Rp=0;var Pp=Lo((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){const i=ue(),[a,s]=ae([]),[l,c]=ae(-1),[u,d]=ae(!1),[h]=ae((()=>(++Rp,`TagEditor-${Rp}`))),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}`:""
537
- ;return Ze("div",{className:"space-y-4",children:[Ze(gp,{children:r.map((e=>Ze(vp,{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;-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(Lp,{id:`${h}-AutocompleteList`,
538
- 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 Dp(){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",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 Fp(e){return null!==e.offsetParent}function Bp({className:e,closeMenu:t,children:n,visible:r}){
539
- 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(Fp);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,i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}let jp=!1;const Hp=()=>{};function $p({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||Hp);const m=ue(d);le((()=>{"function"==typeof l&&m.current!==d&&(m.current=d,l(d))}),[d,l]);const p=e=>{
540
- if("mousedown"===e.type)jp=!0;else if("click"===e.type&&jp)return jp=!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,"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($n,{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,
541
- "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(Bp,{visible:!0,children:t})})]})}function qp({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?jn:$n;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,"group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Ze(r,{className:"w-3 h-3",viewBox:"0 0 16 16"})})}function Up({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d,submenuToggleTitle:h}){const m=ue(null);let p,f;const g="boolean"==typeof a,v="boolean"==typeof o;le((()=>()=>{clearTimeout(p)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),
542
- e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},y=t?Ze(t,{className:"h-3 w-3"}):null,_=i?null:y,w=i?y:null,k=!!w,N=Ze(x,{children:[(l||i||!!_)&&Ze("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??_}),Ze("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),k&&Ze("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),g&&Ze(qp,{title:h??("string"==typeof s?`Show actions for ${s}`:"Toggle submenu"),isExpanded:a,onToggleSubmenu:u})]}),S=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":!g},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,
543
- "text-color-text hover:text-color-text":!n});return f=e?Ze("a",{ref:m,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:N}):Ze("div",{ref:m,className:S,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:v?"menuitemradio":"menuitem","aria-checked":v?o:void 0,"aria-haspopup":g,"aria-expanded":g?a:void 0,children:N}),Ze(x,{children:[f,g&&Ze(To,{direction:a?"in":"out",children:Ze(Bp,{closeMenu:e=>{u&&u(e),p=setTimeout((()=>{m.current.focus()}))},visible:a,className:"border-y border-grey-3",children:d})})]})}var Gp=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($n,{className:"w-4 h-4"})});return Ze("div",{className:"flex flex-row gap-x-3",children:[Ze("div",{className:"flex relative",children:[Ze(xr,{
544
- 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($p,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Ze(Up,{icon:"open"===e.type?hn:bn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Ze(Up,{icon:Pn,label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]}),Ze("div",{children:Ze(xr,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Ze(yt,{}),"Cancel"]})})]})}),["settings"]);var Vp=Lo((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){const[a,s]=ae(null),l=vs(),c=l.getGroup(e.group),u=de((()=>yi(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=>{
545
- 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=`${Mi(e)} ${_i(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch{i.error("Saving annotation failed")}},w=he((()=>{l.removeDraft(e),_i(e)||l.removeAnnotations([e])}),[e,l]),x=zo(["annotationFontFamily"],r),k=l.isFeatureEnabled("at_mentions"),N=l.usersWhoAnnotated();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(zp,{textStyle:x,label:u?"Enter reply":"Enter comment",text:m,onEditText:b,mentionsEnabled:k,usersForMentions:N}),Ze(Pp,{onAddTag:g,onRemoveTag:v,
546
- onTagInput:s,tagList:h}),c&&Ze(Gp,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:w,onSave:_,onSetPrivate:y}),d&&Ze(Dp,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Wp({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 Kp({group:e}){const t=e?.links.html;return Ze(x,{children:e&&t&&Ze(bo,{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 Yp({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){
547
- 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((()=>qe(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",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 Xp({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",{
548
- children:n})}var Jp=Lo((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){const i=vs(),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!pi(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${mi(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=yi(e)&&r,h=e.links?.html||"",m=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}(e)&&!d),[e,d]),p=function(e){return{domain:vi(e),titleText:bi(e),titleLink:gi(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=Li(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]",
549
- title:"This annotation is visible only to you"}),Ze(Xp,{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(Yp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,withEditedTimestamp:m})})]}),!yi(e)&&Ze("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[v&&Ze(Kp,{group:v}),!t&&Ai(e)&&Ze(Nn,{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(Wp,{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 Qp=Lo((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Ze(Vs,{collapsedHeight:35,
550
- inlineControls:!0,overflowThreshold:20,children:Ze(pp,{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 Zp({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 ef(){return Ze("div",{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 tf=Lo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){
551
- const a=vs(),s=zi(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&&_i(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":`${_i(e)?Mi(e):`New ${Mi(e).toLowerCase()}`} by ${v}${a.isAnnotationHighlighted(e)?" - Highlighted":""}`,children:[Ze(Jp,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Ze(Qp,{quote:s,isHovered:u,isOrphan:Ei(e)}),!m&&!h&&Ze(yp,{annotation:e}),h&&Ze(Vp,{annotation:e,draft:l}),!m&&Ze("footer",{className:"flex items-center",children:[n&&Ze(Zp,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Ze(ef,{}),p&&Ze(ct,{classes:"grow",children:Ze(qs,{annotation:e,onReply:()=>{_i(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function nf({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Ze("article",{className:"space-y-4",
552
- "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(Zp,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var rf=Lo((function({annotation:e,api:t,toastMessenger:n}){const r=vs(),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","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!yi(e),"-mr-3":yi(e)}),children:[Ze("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,"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,{
553
- 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}),["api","toastMessenger"]);function of({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:$n,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,{
554
- 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 af=Lo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Es(e)>0)),i=vs(),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(rf,{annotation:t.annotation}),Ze(tf,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Ze(nf,{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",
555
- children:[r&&Ze(of,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ze("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,As(t)>0&&Ze("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ze(Jp,{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 ",As(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)))})]})]})}),["threadsService"]);var sf=Lo((function({frameSync:e,thread:t}){const n=vs(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=de((()=>xs((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=he((t=>{e.scrollToAnnotation(t)}),[e]),l=de((()=>Ze(af,{thread:t
556
- })),[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 lf=50;function cf(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function uf(e){return Math.max(e-e%lf,0)}function df(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function hf(e){if(!e.annotation)return null;const t=df(e.annotation);return t?.cfi??null}function mf({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ke,t=cf();n(t.clientHeight),
557
- o(uf(t.scrollTop));const r=xs((()=>{n(t.clientHeight),o(uf(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=ks){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=df(n.annotation);e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=hf(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=vs(),f=p.countDrafts()>0,g=p.highlightedAnnotations(),v=p.allAnnotations(),b=(()=>{const e=p.unsavedAnnotations()
558
- ;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)||ks.defaultHeight)(t)),0);cf().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=Ns(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[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(sf,{thread:e})]},e.id))),Ze("div",{style:{height:u}})]})}
559
- const pf={collapsed:!1,depth:0,visible:!0,replyCount:0};function ff(e){return e.id||e.$tag}function gf(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||gf(e,t,r.parent))}function vf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...pf,children:[],id:r},vf(e,r,n.slice(0,-1))),gf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function bf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>bf(e,t)))})}function yf(e,t,n){const r=e.children.map((e=>yf(e,n,n))).slice().sort(t);return{...e,children:r}}function _f(e,t){const n=e.children.map((e=>_f(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function wf(e){return e.children.some((e=>e.visible||wf(e)))}const xf=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function kf(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=ff(e)
560
- ;t[n]={...pf,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return vf(t,ff(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...pf,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=bf(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),o.children=o.children.filter((e=>e.visible||wf(e))),o=bf(o,(e=>{const n={collapsed:e.collapsed};if(di(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&wf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=yf(o,t.sortCompareFn,xf),o=_f(o,-1),o}function Nf(e){const t=Sf(e),[n,r]=t.split("-",2)
561
- ;return[n,r??n]}function Sf(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 Af(e,t){const n=e=>function(e){const t=Sf(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 Ef(e,t,n){return Af(e,t)>=0&&Af(e,n)<0}function Tf(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e];let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let Cf=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function Mf(e,t,n){
562
- return[e[0]??t,e[1]??n]}function If(e,t){const n=Tf(e),r=Tf(t);if(!n||!r)return e&&t&&e===t?Cf.Overlap:Cf.Unknown;const o=2**31,[i,a]=Mf(n,1,o),[s,l]=Mf(r,1,o);return i<=s?s<=a?Cf.Overlap:Cf.NoOverlap:i<=l?Cf.Overlap:Cf.NoOverlap}
529
+ o===t&&i===n?(a=wp(a,a.selectionStart-t.length,t.length,""),a=wp(a,a.selectionEnd,n.length,"")):(a=wp(a,a.selectionStart,0,t),a=wp(a,a.selectionEnd,0,n)),a}function Np(e,t){const n=e.indexOf("\n",t);return n<0?e.length:n}function Sp(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=Np(e.text,t),a=0;for(;i<=Np(e.text,n);){const t=i===e.text.length,s=i-o,l=Np((e=r(e,o,i,a)).text,o)-o;if(n+=l-s,t)break;o=o+l+1,i=Np(e.text,o),a+=1}return e}function Ap(e,t){const n=e.selectionStart,r=e.selectionEnd,o=e=>"function"==typeof t?t(e):t;let i=!0;return Sp(e,n,r,((e,t,n,r)=>{const a=o(r);return e.text.slice(t,t+a.length)!==a&&(i=!1),e})),Sp(e,n,r,i?(e,t,n,r)=>wp(e,t,o(r).length,""):(e,t,n,r)=>{const i=o(r);return e.text.slice(t,t+i.length)===i?e:wp(e,t,0,i)})}function Ep({users:e,onSelectUser:t,highlightedSuggestion:n,usersListboxId:r,...o}){return Ze(to,{...o,classes:"p-1",children:Ze("ul",{className:"flex-col gap-y-0.5",role:"listbox","aria-orientation":"vertical",id:r,
530
+ children:[e.map(((e,o)=>Ze("li",{id:`${r}-${e.username}`,className:Xe("flex justify-between items-center","rounded p-2 hover:bg-grey-2",{"bg-grey-2":n===o}),onClick:n=>{n.stopPropagation(),t(e)},role:"option","aria-selected":n===o,children:[Ze("span",{className:"truncate",children:e.username}),Ze("span",{className:"text-color-text-light",children:e.displayName})]},e.username))),0===e.length&&Ze("li",{className:"italic p-2","data-testid":"suggestions-fallback",children:"No matches. You can still write the username"})]})})}const Tp={bold:"b",image:"g",italic:"i",link:"l",list:"u",math:"m",numlist:"o",quote:"q"};function Cp({disabled:e=!1,icon:t,label:n,onClick:r,shortcutKey:o,title:i=""}){const a=de((()=>Ps()?"Cmd":"Ctrl"),[]);let s=i;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,{
531
+ className:"w-[10px] h-[10px] touch:w-[13px] touch:h-[13px]"})})}function Mp({classes:e,containerRef:t,mentionsEnabled:n,usersForMentions:r,onEditText:o,onKeyDown:i,...a}){const[s,l]=ae(!1),[c,u]=ae(),d=ze(t),[h,m]=ae(0),p=de((()=>n&&void 0!==c?r.filter((e=>!c||`${e.username} ${e.displayName??""}`.toLowerCase().match(c.toLowerCase()))).slice(0,10):[]),[c,n,r]),f=he((e=>{if(!n)return;const t=function(e,t){return e.slice(0,t).match(/\S+$/)?.[0]??""}(e.value,e.selectionStart),r=t.startsWith("@");l(r),u(r?t.substring(1):void 0),r||m(0)}),[n]),g=he((e=>{const t=d.current,{value:n}=t,{start:r,end:i}=function(e,t){const n=e.slice(0,t).search(/\s\S*$/),r=e.slice(t).search(/\s/);return{start:(-1===n?-1:n)+1,end:-1===r?e.length:t+r}}(n,t.selectionStart),a=`${n.slice(0,r)}@${e.username} `,s=n.slice(i);t.value=`${a}${s}`,t.selectionStart=a.length,t.selectionEnd=a.length,t.focus(),o(t.value),l(!1),m(0)}),[o,d]),v=pe(),b=de((()=>{if(!s)return{};const e=p[h],t=e?`${v}-${e.username}`:void 0;return{role:"combobox",
532
+ "aria-controls":v,"aria-expanded":!0,"aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":t}}),[h,v,s,p]);return 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),onInput:e=>o(e.target.value),...a,onKeyUp:e=>{["Escape","Enter"].includes(e.key)||f(e.target)},onKeyDown:e=>{i?.(e),s&&0!==p.length&&("ArrowDown"===e.key?(e.preventDefault(),m((e=>Math.min(e+1,p.length-1)))):"ArrowUp"===e.key?(e.preventDefault(),m((e=>Math.max(e-1,0)))):"Enter"===e.key&&(e.preventDefault(),g(p[h])))},onClick:e=>{e.stopPropagation(),f(e.target)},ref:d,...b}),n&&Ze(Ep,{open:s,onClose:()=>l(!1),anchorElementRef:d,users:p,highlightedSuggestion:h,onSelectUser:g,usersListboxId:v})]})}function Ip({isPreviewing:e,onCommand:t,onTogglePreview:n}){const r=ue(null);return Se(r),Ze("div",{
533
+ 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(Cp,{disabled:e,icon:Yt,onClick:()=>t("bold"),shortcutKey:Tp.bold,title:"Bold"}),Ze(Cp,{disabled:e,icon:Jt,onClick:()=>t("italic"),shortcutKey:Tp.italic,title:"Italic"}),Ze(Cp,{disabled:e,icon:Wt,onClick:()=>t("quote"),shortcutKey:Tp.quote,title:"Quote"}),Ze(Cp,{disabled:e,icon:Mn,onClick:()=>t("link"),shortcutKey:Tp.link,title:"Insert link"}),Ze(Cp,{disabled:e,icon:An,onClick:()=>t("image"),shortcutKey:Tp.image,title:"Insert image"}),Ze(Cp,{disabled:e,icon:Gt,onClick:()=>t("math"),title:"Insert math (LaTeX is supported)"}),Ze(Cp,{disabled:e,icon:zn,onClick:()=>t("numlist"),shortcutKey:Tp.numlist,title:"Numbered list"}),Ze(Cp,{disabled:e,icon:Ln,onClick:()=>t("list"),shortcutKey:Tp.list,title:"Bulleted list"}),Ze("div",{
534
+ 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(Cp,{label:e?"Write":"Preview",onClick:n})]})]})}function zp({mentionsEnabled:e=!1,label:t,onEditText:n=(()=>{}),text:r,textStyle:o={},usersForMentions:i}){const[a,s]=ae(!1),l=ue(null);le((()=>{a||l.current?.focus()}),[a]);const c=e=>{l.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)
535
+ ;return 0===t.length||"\n"===t.slice(-1)||"$$"===t.slice(-2)?kp(e,"$$","$$","Insert LaTeX"):kp(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>kp(e,"**","**","Bold")));break;case"italic":n((e=>kp(e,"*","*","Italic")));break;case"quote":n((e=>Ap(e,"> ")));break;case"link":n((e=>xp(e)));break;case"image":n((e=>xp(e,_p.IMAGE_LINK)));break;case"math":n(r);break;case"numlist":n((e=>Ap(e,(e=>`${e+1}. `))));break;case"list":n((e=>Ap(e,"* ")))}}(e,l.current),n(l.current.value))};return Ze("div",{className:"leading-none",children:[Ze(Ip,{onCommand:c,isPreviewing:a,onTogglePreview:()=>s(!a)}),a?Ze(fp,{markdown:r,classes:"border bg-grey-1 p-2",style:o}):Ze(Mp,{"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:l,onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(const[t,n]of Object.entries(Tp))n===e.key&&(e.stopPropagation(),e.preventDefault(),c(t))},onEditText:n,value:r,style:o,mentionsEnabled:e,usersForMentions:i})]})}
536
+ const Op=e=>e;function Lp({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Op,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 Rp=0;var Pp=Lo((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){
537
+ const i=ue(),[a,s]=ae([]),[l,c]=ae(-1),[u,d]=ae(!1),[h]=ae((()=>(++Rp,`TagEditor-${Rp}`))),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(gp,{children:r.map((e=>Ze(vp,{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
538
+ ;-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(Lp,{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 Dp(){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",
539
+ 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 Fp(e){return null!==e.offsetParent}function Bp({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(Fp);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,
540
+ i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}let jp=!1;const Hp=()=>{};function $p({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||Hp);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)jp=!0;else if("click"===e.type&&jp)return jp=!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,
541
+ "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($n,{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(Bp,{visible:!0,children:t})})]})}function qp({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?jn:$n;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,
542
+ "group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Ze(r,{className:"w-3 h-3",viewBox:"0 0 16 16"})})}function Up({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d,submenuToggleTitle:h}){const m=ue(null);let p,f;const g="boolean"==typeof a,v="boolean"==typeof o;le((()=>()=>{clearTimeout(p)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},y=t?Ze(t,{className:"h-3 w-3"}):null,_=i?null:y,w=i?y:null,k=!!w,N=Ze(x,{children:[(l||i||!!_)&&Ze("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??_}),Ze("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),k&&Ze("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),g&&Ze(qp,{title:h??("string"==typeof s?`Show actions for ${s}`:"Toggle submenu"),
543
+ isExpanded:a,onToggleSubmenu:u})]}),S=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":!g},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return f=e?Ze("a",{ref:m,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:N}):Ze("div",{ref:m,className:S,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:v?"menuitemradio":"menuitem","aria-checked":v?o:void 0,"aria-haspopup":g,"aria-expanded":g?a:void 0,children:N}),Ze(x,{children:[f,g&&Ze(To,{direction:a?"in":"out",children:Ze(Bp,{closeMenu:e=>{u&&u(e),p=setTimeout((()=>{m.current.focus()}))},
544
+ visible:a,className:"border-y border-grey-3",children:d})})]})}var Gp=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($n,{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($p,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Ze(Up,{icon:"open"===e.type?hn:bn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Ze(Up,{icon:Pn,label:"Only Me",isSelected:n,onClick:()=>i(!0)
545
+ })]})})]}),Ze("div",{children:Ze(xr,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Ze(yt,{}),"Cancel"]})})]})}),["settings"]);var Vp=Lo((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){const[a,s]=ae(null),l=vs(),c=l.getGroup(e.group),u=de((()=>yi(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=`${Mi(e)} ${_i(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch{i.error("Saving annotation failed")}},w=he((()=>{l.removeDraft(e),
546
+ _i(e)||l.removeAnnotations([e])}),[e,l]),x=zo(["annotationFontFamily"],r),k=l.isFeatureEnabled("at_mentions"),N=l.usersWhoAnnotated();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(zp,{textStyle:x,label:u?"Enter reply":"Enter comment",text:m,onEditText:b,mentionsEnabled:k,usersForMentions:N}),Ze(Pp,{onAddTag:g,onRemoveTag:v,onTagInput:s,tagList:h}),c&&Ze(Gp,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:w,onSave:_,onSetPrivate:y}),d&&Ze(Dp,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Wp({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 Kp({group:e}){
547
+ const t=e?.links.html;return Ze(x,{children:e&&t&&Ze(bo,{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 Yp({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((()=>qe(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,{
548
+ classes:"text-color-text-light hover:text-color-text-light",target:"_blank",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 Xp({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 Jp=Lo((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){const i=vs(),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!pi(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${mi(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=yi(e)&&r,h=e.links?.html||"",m=de((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1
549
+ ;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3}(e)&&!d),[e,d]),p=function(e){return{domain:vi(e),titleText:bi(e),titleLink:gi(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=Li(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(Xp,{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(Yp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,withEditedTimestamp:m})})]}),!yi(e)&&Ze("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse",
550
+ "data-testid":"extended-header-info",children:[v&&Ze(Kp,{group:v}),!t&&Ai(e)&&Ze(Nn,{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(Wp,{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 Qp=Lo((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Ze(Vs,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Ze(pp,{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 Zp({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",
551
+ children:r})}function ef(){return Ze("div",{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 tf=Lo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=vs(),s=zi(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&&_i(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":`${_i(e)?Mi(e):`New ${Mi(e).toLowerCase()}`} by ${v}${a.isAnnotationHighlighted(e)?" - Highlighted":""}`,children:[Ze(Jp,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Ze(Qp,{quote:s,isHovered:u,isOrphan:Ei(e)}),!m&&!h&&Ze(yp,{annotation:e
552
+ }),h&&Ze(Vp,{annotation:e,draft:l}),!m&&Ze("footer",{className:"flex items-center",children:[n&&Ze(Zp,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Ze(ef,{}),p&&Ze(ct,{classes:"grow",children:Ze(qs,{annotation:e,onReply:()=>{_i(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function nf({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(Zp,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var rf=Lo((function({annotation:e,api:t,toastMessenger:n}){const r=vs(),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","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!yi(e),"-mr-3":yi(e)}),
553
+ children:[Ze("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,"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",
554
+ variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"]);function of({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:$n,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 af=Lo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Es(e)>0)),i=vs(),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(rf,{
555
+ annotation:t.annotation}),Ze(tf,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Ze(nf,{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(of,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Ze("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,As(t)>0&&Ze("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Ze(Jp,{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 ",As(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]"),
556
+ children:Ze(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var sf=Lo((function({frameSync:e,thread:t}){const n=vs(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=de((()=>xs((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=he((t=>{e.scrollToAnnotation(t)}),[e]),l=de((()=>Ze(af,{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 lf=50;function cf(){const e=document.querySelector(".js-thread-list-scroll-root")
557
+ ;if(!e)throw new Error("Scroll container is missing");return e}function uf(e){return Math.max(e-e%lf,0)}function df(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function hf(e){if(!e.annotation)return null;const t=df(e.annotation);return t?.cfi??null}function mf({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ke,t=cf();n(t.clientHeight),o(uf(t.scrollTop));const r=xs((()=>{n(t.clientHeight),o(uf(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=ks){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){
558
+ const t=new Map;for(const n of e){if(!n.annotation)continue;const e=df(n.annotation);e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=hf(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=vs(),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)||ks.defaultHeight)(t)),0);cf().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
559
+ ;const o=Ns(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[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(sf,{thread:e})]},e.id))),Ze("div",{style:{height:u}})]})}const pf={collapsed:!1,depth:0,visible:!0,replyCount:0};function ff(e){return e.id||e.$tag}function gf(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||gf(e,t,r.parent))}function vf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...pf,children:[],id:r},vf(e,r,n.slice(0,-1))),gf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function bf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>bf(e,t)))})}function yf(e,t,n){const r=e.children.map((e=>yf(e,n,n))).slice().sort(t);return{...e,children:r}}function _f(e,t){
560
+ const n=e.children.map((e=>_f(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function wf(e){return e.children.some((e=>e.visible||wf(e)))}const xf=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function kf(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=ff(e);t[n]={...pf,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return vf(t,ff(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...pf,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=bf(o,(e=>{if(n)return{...e,visible:!0}
561
+ ;let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),o.children=o.children.filter((e=>e.visible||wf(e))),o=bf(o,(e=>{const n={collapsed:e.collapsed};if(di(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&wf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=yf(o,t.sortCompareFn,xf),o=_f(o,-1),o}function Nf(e){const t=Sf(e),[n,r]=t.split("-",2);return[n,r??n]}function Sf(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 Af(e,t){const n=e=>function(e){const t=Sf(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
562
+ }(n(e),n(t))}function Ef(e,t,n){return Af(e,t)>=0&&Af(e,n)<0}function Tf(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e];let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let Cf=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function Mf(e,t,n){return[e[0]??t,e[1]??n]}function If(e,t){const n=Tf(e),r=Tf(t);if(!n||!r)return e&&t&&e===t?Cf.Overlap:Cf.Unknown;const o=2**31,[i,a]=Mf(n,1,o),[s,l]=Mf(r,1,o);return i<=s?s<=a?Cf.Overlap:Cf.NoOverlap:i<=l?Cf.Overlap:Cf.NoOverlap}
563
563
  const zf=/[\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
564
564
  ;function Of(e){return function(e){return e.replace(zf,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class Lf{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 Rf{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 Pf(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:Of}}const Df={quote:Pf((e=>[zi(e)??""])),cfi:{fieldValues:e=>[Oi(e)?.trim()??""],matches:(e,t)=>{const[n,r]=Nf(t);return Ef(e,n,r)},normalize:e=>Sf(e.trim())},page:{fieldValues:e=>[Li(e)?.trim()??""],matches:(e,t)=>If(e,t)===Cf.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:Pf((e=>e.tags)),text:Pf((e=>[e.text])),uri:Pf((e=>[e.uri])),user:Pf((e=>[e.user,e.user_info?.display_name??""]))}
565
565
  ;function Ff(e,t){const n=(e,t)=>new Lf(t,Df[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 Rf("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new Rf(t.operator,r)})),o=new Rf("and",r);return e.filter((e=>o.matches(e)))}const Bf=["cfi","quote","page","since","tag","text","uri","user"],jf=["group","quote","tag","text","uri","user"];function Hf(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 $f(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 qf(e,t){const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map($f).filter((e=>e.length>0)).map((e=>{const[n,r]=Hf(e,t);return n?n+":"+$f(r):e})):[]}function Uf(e){const t={},n=e=>"tag"===e?"tags":e,r=qf(e,jf);for(const e of r){let[r,o]=Hf(e,jf);r||(r="any",o=e);const i=n(r);t[i]?t[i].push(o):t[i]=[o]}
566
566
  return t}function Gf(e){return Ei(e)?"orphan":Ti(e)?"note":"annotation"}function Vf(e){return Ts([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function Wf(e){return Ts([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}const Kf={Newest:(e,t)=>{const n=Vf(e),r=Vf(t);return n>r?-1:n<r?1:0},Oldest:(e,t)=>{const n=Wf(e),r=Wf(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=Ii(e.annotation),r=Ii(t.annotation);if(n.cfi&&r.cfi){const e=Af(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 Yf=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,
567
567
  selected:t.selected,sortCompareFn:Kf[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=qf(e,Bf);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,
568
568
  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=>Ff([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&Ff([e.annotation],o).length>0)}const r=kf(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(Ni(e.annotation))return!1;const n=Gf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function Xf(){const e=vs(),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 Yf(s)}
569
- var Jf,Qf,Zf=Lo((function({loadAnnotationsService:e,onLogin:t}){const n=vs(),r=n.routeParams().id??"",{rootThread:o}=Xf(),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(bs,{errorType:"annotation",onLoginRequest:t}),Ze(mf,{threads:o.children})]})}),["loadAnnotationsService"]);class eg{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.1555.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])}
569
+ var Jf,Qf,Zf=Lo((function({loadAnnotationsService:e,onLogin:t}){const n=vs(),r=n.routeParams().id??"",{rootThread:o}=Xf(),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(bs,{errorType:"annotation",onLoginRequest:t}),Ze(mf,{threads:o.children})]})}),["loadAnnotationsService"]);class eg{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.1556.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])}
570
570
  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 tg=function(){if(Qf)return Jf;Qf=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,
571
571
  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){
572
572
  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 Jf=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){
@@ -653,7 +653,7 @@ null==v._nextState&&null==v.__s&&(v._nextState=v.__s=v.state),v.context=y,h.getD
653
653
  }),Ze("body",{children:[Ze("section",{children:[Ze("h1",{children:"Summary"}),Ze("p",{children:Ze("time",{dateTime:o.toISOString(),children:qb(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=Li(e),r=zi(e),o=mp(e.text),i=o===`<p>${e.text}</p>`?e.text:o;return Ze("article",{children:[Ze("h2",{children:["Annotation ",t+1,":"]
654
654
  }),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:qb(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:Mi(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}=fi(r);return{uri:i,title:a,
655
655
  uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>yi(e))),extractUsername:o}}}Ub.$inject=[];class Gb 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 Vb(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Gb(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch{throw new Gb(e,n,"Failed to parse response")}if(!n.ok)throw new Gb(e,n,r?.reason);return r}class Wb{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={
656
- "Content-Type":"application/json","Hypothesis-Client-Version":"1.1555.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=qa(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 Vb(m.toString(),{body:s?JSON.stringify($b(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")},
656
+ "Content-Type":"application/json","Hypothesis-Client-Version":"1.1556.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=qa(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 Vb(m.toString(),{body:s?JSON.stringify($b(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")},
657
657
  this.analytics={events:{create:i("analytics.events.create")}}}setClientId(e){this._clientId=e}}Wb.$inject=["apiRoutes","auth","store"];var Kb,Yb,Xb,Jb,Qb,Zb={};function ey(){return Xb||(Xb=1,e=Zb,t=function(){if(Yb)return Kb;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 Yb=1,Kb=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
658
658
  ;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){
659
659
  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},Kb}(),e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];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))
@@ -765,8 +765,8 @@ const e=JSON.stringify(this._messageQueue.shift());this._socket.send(e)}}}class
765
765
  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 AN(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,
766
766
  this._reconnectSetUp||(this._reconnectSetUp=!0,_y(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}EN.$inject=["store","apiRoutes","auth","groups","session","$window"];const TN="hypothesis.user.tags.list",CN="hypothesis.user.tags.map";class MN{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(TN)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${Rv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(CN)||{};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(CN,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(TN,n)}}MN.$inject=["localStorage"];class IN{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),
767
767
  e.visible||this._store.setForcedVisible(e.id,!0)}}IN.$inject=["store"];class zN extends pg.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:Nv(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)}}
768
- zN.$inject=["store","$window"];const ON=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),LN=function(e){const{version:t,origin:n}=Av(e.location.href);return"1.1555.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1555.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 RN(e,t){e.setClientId(t.clientId)}function PN(e){e.sync()}function DN(e,t){e.load(),t.load()}function FN(e,t,n){e.init(),t.init(),n.init()}function BN(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{
769
- n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}ON.sentry&&LN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;hN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1555.0",beforeSend:(e,t)=>{if(mN>=5)return zv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++mN;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{hx("host_config",Av(window.location.href))}catch{}hx("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),my(((e,t)=>{pN(e,t)}))}(ON.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),
768
+ zN.$inject=["store","$window"];const ON=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),LN=function(e){const{version:t,origin:n}=Av(e.location.href);return"1.1556.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1556.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 RN(e,t){e.setClientId(t.clientId)}function PN(e){e.sync()}function DN(e,t){e.load(),t.load()}function FN(e,t,n){e.init(),t.init(),n.init()}function BN(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{
769
+ n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}ON.sentry&&LN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;hN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1556.0",beforeSend:(e,t)=>{if(mN>=5)return zv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++mN;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{hx("host_config",Av(window.location.href))}catch{}hx("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),my(((e,t)=>{pN(e,t)}))}(ON.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),
770
770
  RN.$inject=["api","streamer"],PN.$inject=["router"],DN.$inject=["groups","session"],FN.$inject=["autosaveService","persistedDefaults","serviceURL"],BN.$inject=["frameSync","store","toastMessenger"];const jN=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",$v)}(),async function(e,t=window){const n=function(e){const t=Av(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Ev,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Cv(t.origin),ancestorLevel:Tv(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
771
771
  ;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:Mv(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await Sv(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=Sv(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}(ON).then((e=>{!function(e,t){const n=new G
772
772
  ;n.register("analytics",qv).register("annotationsExporter",Ub).register("annotationsService",Gv).register("annotationActivity",Uv).register("api",Wb).register("apiRoutes",oy).register("auth",sy).register("autosaveService",ly).register("dashboard",cy).register("frameSync",ky).register("groups",Ay).register("importAnnotationsService",gN).register("loadAnnotationsService",vN).register("localStorage",yN).register("persistedDefaults",wN).register("router",xN).register("serviceURL",kN).register("session",NN).register("streamer",EN).register("streamFilter",SN).register("tags",MN).register("threadsService",IN).register("toastMessenger",zN).register("store",{factory:gs}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(PN),n.run(FN),n.run(RN),n.run(DN),n.run(Hv),n.run(BN),j(Ze(Oo.Provider,{value:n,children:Ze(wv,{})}),t)}(e,jN)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),j(Ze(xv,{error:e}),t)}(e,jN)));