hypothesis 1.949.0 → 1.953.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.
@@ -6,16 +6,16 @@ var u,d,p,g,v,y,_,w,x,k,S,C=t.type;if(void 0!==t.constructor)return null;null!=r
6
6
  t.__v!==r.__v&&(d.__d=!1),d.__v=t,t.__e=r.__e,t.__k=r.__k,t.__k.forEach((function(e){e&&(e.__=t)})),d.__h.length&&s.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(w,d.__s,k),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(g,v,y)}))}d.context=k,d.props=w,d.state=d.__s,(u=n.__r)&&u(t),d.__d=!1,d.__v=t,d.__P=e,u=d.render(d.props,d.state,d.context),d.state=d.__s,null!=d.getChildContext&&(o=h(h({},o),d.getChildContext())),p||null==d.getSnapshotBeforeUpdate||(y=d.getSnapshotBeforeUpdate(g,v)),S=null!=u&&u.type===m&&null==u.key?u.props.children:u,b(e,Array.isArray(S)?S:[S],t,r,o,i,a,s,l,c),d.base=t.__e,t.__h=null,d.__h.length&&s.push(d),_&&(d.__E=d.__=null),d.__e=!1}else null==a&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=L(r.__e,t,r,o,i,a,s,c);(u=n.diffed)&&u(t)}catch(e){t.__v=null,(c||null!=a)&&(t.__e=l,t.__h=!!c,a[a.indexOf(l)]=null),n.__e(e,t,r)}}function N(e,t){n.__c&&n.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){
7
7
  n.__e(e,t.__v)}}))}function L(e,n,r,o,i,a,s,c){var u,h,p,m=r.props,f=n.props,v=n.type,y=0;if("svg"===v&&(i=!0),null!=a)for(;y<a.length;y++)if((u=a[y])&&"setAttribute"in u==!!v&&(v?u.localName===v:3===u.nodeType)){e=u,a[y]=null;break}if(null==e){if(null===v)return document.createTextNode(f);e=i?document.createElementNS("http://www.w3.org/2000/svg",v):document.createElement(v,f.is&&f),a=null,c=!1}if(null===v)m===f||c&&e.data===f||(e.data=f);else{if(a=a&&t.call(e.childNodes),h=(m=r.props||l).dangerouslySetInnerHTML,p=f.dangerouslySetInnerHTML,!c){if(null!=a)for(m={},y=0;y<e.attributes.length;y++)m[e.attributes[y].name]=e.attributes[y].value;(p||h)&&(p&&(h&&p.__html==h.__html||p.__html===e.innerHTML)||(e.innerHTML=p&&p.__html||""))}if(function(e,t,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in t||C(e,i,null,n[i],r);for(i in t)o&&"function"!=typeof t[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===t[i]||C(e,i,t[i],n[i],r)}(e,f,m,i,c),p)n.__k=[];else if(y=n.props.children,
8
8
  b(e,Array.isArray(y)?y:[y],n,r,o,i&&"foreignObject"!==v,a,s,a?a[0]:r.__k&&g(r,0),c),null!=a)for(y=a.length;y--;)null!=a[y]&&d(a[y]);c||("value"in f&&void 0!==(y=f.value)&&(y!==m.value||y!==e.value||"progress"===v&&!y)&&C(e,"value",y,m.value,!1),"checked"in f&&void 0!==(y=f.checked)&&y!==e.checked&&C(e,"checked",y,m.checked,!1))}return e}function M(e,t,r){try{"function"==typeof e?e(t):e.current=t}catch(e){n.__e(e,r)}}function O(e,t,r){var o,i;if(n.unmount&&n.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||M(o,null,t)),null!=(o=e.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(e){n.__e(e,t)}o.base=o.__P=null}if(o=e.__k)for(i=0;i<o.length;i++)o[i]&&O(o[i],t,"function"!=typeof e.type);r||null==e.__e||d(e.__e),e.__e=e.__d=void 0}function z(e,t,n){return this.constructor(e,n)}function I(e,r,o){var i,a,s;n.__&&n.__(e,r),a=(i="function"==typeof o)?null:o&&o.__k||r.__k,s=[],T(r,e=(!i&&o||r).__k=function(e,n,r){var o,i,a,s={};for(a in n)"key"==a?o=n[a]:"ref"==a?i=n[a]:s[a]=n[a]
9
- ;if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===s[a]&&(s[a]=e.defaultProps[a]);return p(e,s,o,i,null)}(m,null,[e]),a||l,l,void 0!==r.ownerSVGElement,!i&&o?[o]:a?null:r.firstChild?t.call(r.childNodes):null,s,!i&&o?o:a?a.__e:r.firstChild,i),N(s,e)}t=c.slice,n={__e:function(e,t){for(var n,r,o;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),o=n.__d),o)return n.__E=n}catch(t){e=t}throw e}},r=0,f.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(h({},n),this.props)),e&&h(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),y(this))},f.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),y(this))},f.prototype.render=m,o=[],
10
- i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_.__r=0,s=0;let R={};function P(...e){const t=e.join();t in R||(console.warn(...e),R[t]=!0)}P.reset=()=>{R={}};var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},B=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function F({services:e}){return Array.isArray(e)&&e[0]?e[0]:null}function j(e,t,n,r){const o=t.find((e=>"__world__"===e.id));o&&e.unshift(o);const i=e.map((e=>e.id));t=t.filter((e=>!i.includes(e.id))),t.forEach((e=>e.isMember=!1)),e.forEach((e=>e.isMember=!0));const a=e.concat(t);return a.forEach((e=>{e.canLeave=!!function(e){const t=F(e);return!t||!!t.allowLeavingGroups}(r)&&"private"===e.type})),a.forEach((e=>e.isScopedToUri=function(e,t){if(e.scopes&&e.scopes.uri_patterns.length>0&&t)return function(e,t){
11
- return void 0!==t.find((t=>e.match(t.split("*").map(B).join(".*"))))}(t,e.scopes.uri_patterns);return!0}(e,n))),a}let H=[];function U(e,t,n){const r=(e=>({changeFocusModeUser:t=>{var n;e.changeFocusModeUser(t);const r=null!==(n=null==t?void 0:t.groups)&&void 0!==n?n:[],o=function(e,t){return function(e,t){return t.filter((t=>e.includes(t.id)||t.groupid&&e.includes(t.groupid)))}(e,t).map((e=>e.id))}(r,e.allGroups());r.length&&!o.length&&console.error("No matching groups found in list of filtered group IDs"),e.filterGroups(o)}}))(e);function o(e){let n=t.rpcAllowedOrigins||[];if(null==(o=e.data)||"object"!=typeof o||"2.0"!==o.jsonrpc)return;var o;if(!n.includes(e.origin))return void P(`Ignoring JSON-RPC request from non-whitelisted origin ${e.origin}`);let i=e.data;e.source.postMessage(function(e){const t=r[e.method];if(void 0===t)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"Method not found"}};e.params?t(...e.params):t();return{jsonrpc:"2.0",result:"ok",id:e.id}}(i),e.origin)}H.forEach((e=>{o(e)
12
- })),H=[],window.removeEventListener("message",q),n.addEventListener("message",o)}function q(e){H.push(e)}function $(e){const t=F(e);if(t){if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}return e.apiUrl}function G(e){const t=new URL(e).hash.slice(1),n=new URLSearchParams(t).get("config");return JSON.parse(n||"{}")}function V(e){if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function W(e){return parseInt(e)}function Y(e){return e&&"function"==typeof e.toString?e.toString():""}function K(e){const t=G(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:V,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Y(t.origin),
13
- ancestorLevel:W(t.ancestorLevel)}}};return Object.keys(t).reduce(((e,o)=>(-1!==n.indexOf(o)&&null!==t[o]&&(r[o]?e[o]=r[o](t[o]):e[o]=t[o]),e)),{})}function X(e){const t=e.toString(16);return 1===t.length?"0"+t:t}function Z(e){const t=new Uint8Array(e/2);return window.crypto.getRandomValues(t),Array.from(t).map(X).join("")}function J(e,t,n,r=[],o=2e3,i=window){const a=Z(10),s={jsonrpc:"2.0",method:n,params:r,id:a};try{e.postMessage(s,t)}catch(e){return Promise.reject(e)}let l;const c=new Promise(((e,n)=>{l=r=>{if(r.origin!==t)return;if(!(r.data instanceof Object)||"2.0"!==r.data.jsonrpc||r.data.id!==a)return;const{error:o,result:i}=r.data;void 0!==o?n(o):void 0!==i?e(i):n(new Error("RPC reply had no result or error"))},i.addEventListener("message",l)})),u=[c];var h,d;return o&&u.push((h=o,d=`Request to ${t} timed out`,new Promise(((e,t)=>{setTimeout((()=>t(new Error(d))),h)})))),Promise.race(u).then((e=>(i.removeEventListener("message",l),e))).catch((e=>{throw i.removeEventListener("message",l),e}))}
14
- function Q(e,t=window){let n;return n=function(e,t=window){const n=[];for(let r of function(e){if(e===e.top)return[];const t=[];do{e=e.parent,t.push(e)}while(e!==e.top);return t}(t)){const t=J(r,e,"requestConfig",[],3e3);n.push(t)}return 0===n.length&&n.push(Promise.reject(new Error("Client is top frame"))),Promise.race(n)}(K(t).requestConfigFromFrame,t),n.then((t=>{const n=Object.assign({},e,t);return n.apiUrl=$(n),n}))}function ee(e,t){const n={...e,...t};return n.apiUrl=$(n),n}async function te(e,t,n){return async function(e,t){Array.isArray(e.services)&&e.services.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=t("requestGroups",[n],null).catch((()=>{throw new Error("Unable to fetch groups")})))}));return e}(ee(e,await J(t,n,"requestConfig",[],3e3)),((e,r=[],o=3e3)=>J(t,n,e,r,o)))}U.$inject=["store","settings","$window"];var ne=function(e,t){return ne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){
15
- for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},ne(e,t)};function re(e,t){function n(){this.constructor=e}ne(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var oe,ie,ae,se,le,ce=function(){return ce=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ce.apply(this,arguments)};function ue(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function he(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function de(){
16
- for(var e=[],t=0;t<arguments.length;t++)e=e.concat(he(arguments[t]));return e}function pe(){return"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}!function(e){e.Ok="ok",e.Exited="exited",e.Crashed="crashed",e.Abnormal="abnormal"}(oe||(oe={})),function(e){e.Ok="ok",e.Errored="errored",e.Crashed="crashed"}(ie||(ie={})),function(e){e.Fatal="fatal",e.Error="error",e.Warning="warning",e.Log="log",e.Info="info",e.Debug="debug",e.Critical="critical"}(ae||(ae={})),function(e){e.fromString=function(t){switch(t){case"debug":return e.Debug;case"info":return e.Info;case"warn":case"warning":return e.Warning;case"error":return e.Error;case"fatal":return e.Fatal;case"critical":return e.Critical;default:return e.Log}}}(ae||(ae={})),function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.Invalid="invalid",e.Failed="failed"}(se||(se={})),function(e){e.fromHttpCode=function(t){
17
- return t>=200&&t<300?e.Success:429===t?e.RateLimit:t>=400&&t<500?e.Invalid:t>=500?e.Failed:e.Unknown}}(se||(se={})),function(e){e.BeforeSend="before_send",e.EventProcessor="event_processor",e.NetworkError="network_error",e.QueueOverflow="queue_overflow",e.RateLimitBackoff="ratelimit_backoff",e.SampleRate="sample_rate"}(le||(le={}));var me={};function fe(){return pe()?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:me}function ge(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return Ce(e,Error)}}function ve(e){return"[object ErrorEvent]"===Object.prototype.toString.call(e)}function ye(e){return"[object DOMError]"===Object.prototype.toString.call(e)}function _e(e){return"[object String]"===Object.prototype.toString.call(e)}function be(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function we(e){return"[object Object]"===Object.prototype.toString.call(e)}function xe(e){
18
- return"undefined"!=typeof Event&&Ce(e,Event)}function ke(e){return"undefined"!=typeof Element&&Ce(e,Element)}function Se(e){return Boolean(e&&e.then&&"function"==typeof e.then)}function Ce(e,t){try{return e instanceof t}catch(e){return!1}}function Ee(e,t){try{for(var n=e,r=[],o=0,i=0,a=" > ".length,s=void 0;n&&o++<5&&!("html"===(s=Ae(n,t))||o>1&&i+r.length*a+s.length>=80);)r.push(s),i+=s.length,n=n.parentNode;return r.reverse().join(" > ")}catch(e){return"<unknown>"}}function Ae(e,t){var n,r,o,i,a,s,l,c=e,u=[];if(!c||!c.tagName)return"";u.push(c.tagName.toLowerCase());var h=(null===(n=t)||void 0===n?void 0:n.length)?t.filter((function(e){return c.getAttribute(e)})).map((function(e){return[e,c.getAttribute(e)]})):null;if(null===(r=h)||void 0===r?void 0:r.length)h.forEach((function(e){u.push("["+e[0]+'="'+e[1]+'"]')}));else if(c.id&&u.push("#"+c.id),(o=c.className)&&_e(o))for(i=o.split(/\s+/),l=0;l<i.length;l++)u.push("."+i[l]);var d=["type","name","title","alt"];for(l=0;l<d.length;l++)a=d[l],
9
+ ;if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(a in e.defaultProps)void 0===s[a]&&(s[a]=e.defaultProps[a]);return p(e,s,o,i,null)}(m,null,[e]),a||l,l,void 0!==r.ownerSVGElement,!i&&o?[o]:a?null:r.firstChild?t.call(r.childNodes):null,s,!i&&o?o:a?a.__e:r.firstChild,i),N(s,e)}function R(e){const t=new URL(e).hash.slice(1),n=new URLSearchParams(t).get("config");return JSON.parse(n||"{}")}function P({services:e}){return Array.isArray(e)&&e[0]?e[0]:null}function D(e){const t=P(e);if(t){if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}return e.apiUrl}function B(e){if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function F(e){return parseInt(e)}function j(e){return e&&"function"==typeof e.toString?e.toString():""}function H(e){
10
+ const t=R(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:B,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:j(t.origin),ancestorLevel:F(t.ancestorLevel)}}};return Object.keys(t).reduce(((e,o)=>(-1!==n.indexOf(o)&&null!==t[o]&&(r[o]?e[o]=r[o](t[o]):e[o]=t[o]),e)),{})}function U(e){const t=e.toString(16);return 1===t.length?"0"+t:t}function q(e){const t=new Uint8Array(e/2);return window.crypto.getRandomValues(t),Array.from(t).map(U).join("")}function $(e,t,n,r=[],o=2e3,i=window){const a=q(10),s={jsonrpc:"2.0",method:n,params:r,id:a};try{e.postMessage(s,t)}catch(e){return Promise.reject(e)}let l;const c=new Promise(((e,n)=>{l=r=>{if(r.origin!==t)return;if(!(r.data instanceof Object)||"2.0"!==r.data.jsonrpc||r.data.id!==a)return;const{error:o,result:i}=r.data
11
+ ;void 0!==o?n(o):void 0!==i?e(i):n(new Error("RPC reply had no result or error"))},i.addEventListener("message",l)})),u=[c];var h,d;return o&&u.push((h=o,d=`Request to ${t} timed out`,new Promise(((e,t)=>{setTimeout((()=>t(new Error(d))),h)})))),Promise.race(u).then((e=>(i.removeEventListener("message",l),e))).catch((e=>{throw i.removeEventListener("message",l),e}))}function G(e,t=window){let n;return n=function(e,t=window){const n=[];for(let r of function(e){if(e===e.top)return[];const t=[];do{e=e.parent,t.push(e)}while(e!==e.top);return t}(t)){const t=$(r,e,"requestConfig",[],3e3);n.push(t)}return 0===n.length&&n.push(Promise.reject(new Error("Client is top frame"))),Promise.race(n)}(H(t).requestConfigFromFrame,t),n.then((t=>{const n=Object.assign({},e,t);return n.apiUrl=D(n),n}))}function V(e,t){const n={...e,...t};return n.apiUrl=D(n),n}async function W(e,t,n){return async function(e,t){Array.isArray(e.services)&&e.services.forEach(((e,n)=>{
12
+ "$rpc:requestGroups"===e.groups&&(e.groups=t("requestGroups",[n],null).catch((()=>{throw new Error("Unable to fetch groups")})))}));return e}(V(e,await $(t,n,"requestConfig",[],3e3)),((e,r=[],o=3e3)=>$(t,n,e,r,o)))}t=c.slice,n={__e:function(e,t){for(var n,r,o;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),o=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e),o=n.__d),o)return n.__E=n}catch(t){e=t}throw e}},r=0,f.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(h({},n),this.props)),e&&h(n,e),null!=e&&this.__v&&(t&&this.__h.push(t),y(this))},f.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),y(this))},f.prototype.render=m,o=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_.__r=0,s=0;let Y={};function K(...e){const t=e.join();t in Y||(console.warn(...e),Y[t]=!0)}
13
+ K.reset=()=>{Y={}};var X="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Z=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")};function J(e,t,n,r){const o=t.find((e=>"__world__"===e.id));o&&e.unshift(o);const i=e.map((e=>e.id));t=t.filter((e=>!i.includes(e.id))),t.forEach((e=>e.isMember=!1)),e.forEach((e=>e.isMember=!0));const a=e.concat(t);return a.forEach((e=>{e.canLeave=!!function(e){const t=P(e);return!t||!!t.allowLeavingGroups}(r)&&"private"===e.type})),a.forEach((e=>e.isScopedToUri=function(e,t){if(e.scopes&&e.scopes.uri_patterns.length>0&&t)return function(e,t){return void 0!==t.find((t=>e.match(t.split("*").map(Z).join(".*"))))}(t,e.scopes.uri_patterns);return!0}(e,n))),a}let Q=[];function ee(e,t,n){const r=(e=>({changeFocusModeUser:t=>{var n;e.changeFocusModeUser(t)
14
+ ;const r=null!==(n=null==t?void 0:t.groups)&&void 0!==n?n:[],o=function(e,t){return function(e,t){return t.filter((t=>e.includes(t.id)||t.groupid&&e.includes(t.groupid)))}(e,t).map((e=>e.id))}(r,e.allGroups());r.length&&!o.length&&console.error("No matching groups found in list of filtered group IDs"),e.filterGroups(o)}}))(e);function o(e){let n=t.rpcAllowedOrigins||[];if(null==(o=e.data)||"object"!=typeof o||"2.0"!==o.jsonrpc)return;var o;if(!n.includes(e.origin))return void K(`Ignoring JSON-RPC request from non-whitelisted origin ${e.origin}`);let i=e.data;e.source.postMessage(function(e){const t=r[e.method];if(void 0===t)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"Method not found"}};e.params?t(...e.params):t();return{jsonrpc:"2.0",result:"ok",id:e.id}}(i),e.origin)}Q.forEach((e=>{o(e)})),Q=[],window.removeEventListener("message",te),n.addEventListener("message",o)}function te(e){Q.push(e)}ee.$inject=["store","settings","$window"];var ne=function(e,t){return ne=Object.setPrototypeOf||{
15
+ __proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},ne(e,t)};function re(e,t){function n(){this.constructor=e}ne(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var oe,ie,ae,se,le,ce=function(){return ce=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ce.apply(this,arguments)};function ue(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function he(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{
16
+ r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function de(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(he(arguments[t]));return e}function pe(){return"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}!function(e){e.Ok="ok",e.Exited="exited",e.Crashed="crashed",e.Abnormal="abnormal"}(oe||(oe={})),function(e){e.Ok="ok",e.Errored="errored",e.Crashed="crashed"}(ie||(ie={})),function(e){e.Fatal="fatal",e.Error="error",e.Warning="warning",e.Log="log",e.Info="info",e.Debug="debug",e.Critical="critical"}(ae||(ae={})),function(e){e.fromString=function(t){switch(t){case"debug":return e.Debug;case"info":return e.Info;case"warn":case"warning":return e.Warning;case"error":return e.Error;case"fatal":return e.Fatal;case"critical":return e.Critical;default:return e.Log}}}(ae||(ae={})),function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.Invalid="invalid",e.Failed="failed"}(se||(se={})),function(e){
17
+ e.fromHttpCode=function(t){return t>=200&&t<300?e.Success:429===t?e.RateLimit:t>=400&&t<500?e.Invalid:t>=500?e.Failed:e.Unknown}}(se||(se={})),function(e){e.BeforeSend="before_send",e.EventProcessor="event_processor",e.NetworkError="network_error",e.QueueOverflow="queue_overflow",e.RateLimitBackoff="ratelimit_backoff",e.SampleRate="sample_rate"}(le||(le={}));var me={};function fe(){return pe()?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:me}function ge(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return Ce(e,Error)}}function ve(e){return"[object ErrorEvent]"===Object.prototype.toString.call(e)}function ye(e){return"[object DOMError]"===Object.prototype.toString.call(e)}function _e(e){return"[object String]"===Object.prototype.toString.call(e)}function be(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function we(e){return"[object Object]"===Object.prototype.toString.call(e)}
18
+ function xe(e){return"undefined"!=typeof Event&&Ce(e,Event)}function ke(e){return"undefined"!=typeof Element&&Ce(e,Element)}function Se(e){return Boolean(e&&e.then&&"function"==typeof e.then)}function Ce(e,t){try{return e instanceof t}catch(e){return!1}}function Ee(e,t){try{for(var n=e,r=[],o=0,i=0,a=" > ".length,s=void 0;n&&o++<5&&!("html"===(s=Ae(n,t))||o>1&&i+r.length*a+s.length>=80);)r.push(s),i+=s.length,n=n.parentNode;return r.reverse().join(" > ")}catch(e){return"<unknown>"}}function Ae(e,t){var n,r,o,i,a,s,l,c=e,u=[];if(!c||!c.tagName)return"";u.push(c.tagName.toLowerCase());var h=(null===(n=t)||void 0===n?void 0:n.length)?t.filter((function(e){return c.getAttribute(e)})).map((function(e){return[e,c.getAttribute(e)]})):null;if(null===(r=h)||void 0===r?void 0:r.length)h.forEach((function(e){u.push("["+e[0]+'="'+e[1]+'"]')}));else if(c.id&&u.push("#"+c.id),(o=c.className)&&_e(o))for(i=o.split(/\s+/),l=0;l<i.length;l++)u.push("."+i[l]);var d=["type","name","title","alt"];for(l=0;l<d.length;l++)a=d[l],
19
19
  (s=c.getAttribute(a))&&u.push("["+a+'="'+s+'"]');return u.join("")}var Te=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){return e.__proto__=t,e}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n]);return e});var Ne=function(e){function t(t){var n=this.constructor,r=e.call(this,t)||this;return r.message=t,r.name=n.prototype.constructor.name,Te(r,n.prototype),r}return re(t,e),t}(Error),Le=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,Me=function(){function e(e){"string"==typeof e?this._fromString(e):this._fromComponents(e),this._validate()}return e.prototype.toString=function(e){void 0===e&&(e=!1);var t=this,n=t.host,r=t.path,o=t.pass,i=t.port,a=t.projectId;return t.protocol+"://"+t.publicKey+(e&&o?":"+o:"")+"@"+n+(i?":"+i:"")+"/"+(r?r+"/":r)+a},e.prototype._fromString=function(e){var t=Le.exec(e);if(!t)throw new Ne("Invalid Dsn")
20
20
  ;var n=he(t.slice(1),6),r=n[0],o=n[1],i=n[2],a=void 0===i?"":i,s=n[3],l=n[4],c=void 0===l?"":l,u="",h=n[5],d=h.split("/");if(d.length>1&&(u=d.slice(0,-1).join("/"),h=d.pop()),h){var p=h.match(/^\d+/);p&&(h=p[0])}this._fromComponents({host:s,pass:a,path:u,projectId:h,port:c,protocol:r,publicKey:o})},e.prototype._fromComponents=function(e){"user"in e&&!("publicKey"in e)&&(e.publicKey=e.user),this.user=e.publicKey||"",this.protocol=e.protocol,this.publicKey=e.publicKey||"",this.pass=e.pass||"",this.host=e.host,this.port=e.port||"",this.path=e.path||"",this.projectId=e.projectId},e.prototype._validate=function(){var e=this;if(["protocol","publicKey","host","projectId"].forEach((function(t){if(!e[t])throw new Ne("Invalid Dsn: "+t+" missing")})),!this.projectId.match(/^\d+$/))throw new Ne("Invalid Dsn: Invalid projectId "+this.projectId);if("http"!==this.protocol&&"https"!==this.protocol)throw new Ne("Invalid Dsn: Invalid protocol "+this.protocol)
21
21
  ;if(this.port&&isNaN(parseInt(this.port,10)))throw new Ne("Invalid Dsn: Invalid port "+this.port)},e}(),Oe=fe(),ze="Sentry Logger ";function Ie(e){var t=fe();if(!("console"in t))return e();var n=t.console,r={};["debug","info","warn","error","log","assert"].forEach((function(e){e in t.console&&n[e].__sentry_original__&&(r[e]=n[e],n[e]=n[e].__sentry_original__)}));var o=e();return Object.keys(r).forEach((function(e){n[e]=r[e]})),o}var Re=function(){function e(){this._enabled=!1}return e.prototype.disable=function(){this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&Ie((function(){Oe.console.log(ze+"[Log]: "+e.join(" "))}))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._enabled&&Ie((function(){Oe.console.warn(ze+"[Warn]: "+e.join(" "))}))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]
@@ -159,13 +159,13 @@ const oi=/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5
159
159
  autofalse:e=>"string"!=typeof e.user,value:e=>e.user+" "+function(e){return e.user_info&&e.user_info.display_name||""}(e),match:(e,t)=>t.indexOf(e)>-1}};function ci(e){return Qo(e)?"orphan":ei(e)?"note":"annotation"}function ui(e,t){const n=e.visible===t;return e.children.reduce(((e,n)=>e+ui(n,t)),n?1:0)}function hi(e){return ui(e,!1)}function di(e){return ui(e,!0)}function pi(e){const t=e.filter((e=>!!e.annotation)).map((e=>e.annotation));if(t.length)return t;const n=[];if(e.forEach((e=>{e.children&&n.push(...e.children)})),n.length)return pi(n);throw new Error("Thread contains no annotations")}function mi(e){return pi([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function fi(e){return pi([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}const gi={Newest:function(e,t){const n=mi(e),r=mi(t);return n>r?-1:n<r?1:0},Oldest:function(e,t){const n=fi(e),r=fi(t);return n<r?-1:n>r?1:0},Location:function(e,t){if(!e.annotation||!t.annotation)return function(e,t){
160
160
  return e.annotation||t.annotation?e.annotation?1:-1:0}(e,t);const n=ni(e.annotation),r=ni(t.annotation);return n<r?-1:n>r?1:0}};const vi=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,selected:t.selected,sortCompareFn:gi[t.sortKey]},r=!!t.filterQuery||Object.keys(t.filters).length>0;if(r){const e=function(e,t={}){let n;const r=[],o=[],i=[],a=[],s=[],l=[],c=t.user?[t.user]:[];if(e){n=jo(e);for(const e of n){const t=e.slice(0,e.indexOf(":")),n=e.slice(t.length+1);switch(t){case"quote":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";i.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":
161
161
  c.push(n);break;default:r.push(e)}}}return{any:{terms:r,operator:"and"},quote:{terms:o,operator:"and"},since:{terms:i,operator:"and"},tag:{terms:a,operator:"and"},text:{terms:s,operator:"and"},uri:{terms:l,operator:"or"},user:{terms:c,operator:"or"}}}(t.filterQuery||"",t.filters);n.filterFn=t=>function(e,t){const n=Object.entries(t).filter((([,e])=>e.terms.length>0)).map((([e,t])=>{const n=t.terms.map(ii);let r;if("any"===e){const e=["quote","text","tag","user"];r=n.map((t=>new si("or",e.map((e=>new ai(e,t,li[e]))))))}else r=n.map((t=>new ai(e,t,li[e])));return new si(t.operator,r)})),r=new si("and",n);return e.filter((e=>e.id&&r.matches(e))).map((e=>e.id))}([t],e).length>0}return!r&&"sidebar"===e.route&&(n.threadFilterFn=e=>{return!!e.annotation&&(n=e.annotation,r=t.selectedTab,!Xo(n)&&ci(n)===r);var n,r}),Bo(e.annotations,n)}));function yi(){const e=To(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a=Cr((()=>({annotations:t,route:r,selection:{...o,
162
- filterQuery:n,filters:i}})),[t,n,r,o,i]);return vi(a)}var _i=/^\s+|\s+$/g,bi=/^[-+]0x[0-9a-f]+$/i,wi=/^0b[01]+$/i,xi=/^0o[0-7]+$/i,ki=parseInt,Si="object"==typeof D&&D&&D.Object===Object&&D,Ci="object"==typeof self&&self&&self.Object===Object&&self,Ei=Si||Ci||Function("return this")(),Ai=Object.prototype.toString,Ti=Math.max,Ni=Math.min,Li=function(){return Ei.Date.now()};function Mi(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Oi(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==Ai.call(e)}(e))return NaN;if(Mi(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Mi(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(_i,"");var n=wi.test(e);return n||xi.test(e)?ki(e.slice(2),n?2:8):bi.test(e)?NaN:+e}var zi=function(e,t,n){var r,o,i,a,s,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var n=r,i=o;return r=o=void 0,c=t,a=e.apply(i,n)}
162
+ filterQuery:n,filters:i}})),[t,n,r,o,i]);return vi(a)}var _i=/^\s+|\s+$/g,bi=/^[-+]0x[0-9a-f]+$/i,wi=/^0b[01]+$/i,xi=/^0o[0-7]+$/i,ki=parseInt,Si="object"==typeof X&&X&&X.Object===Object&&X,Ci="object"==typeof self&&self&&self.Object===Object&&self,Ei=Si||Ci||Function("return this")(),Ai=Object.prototype.toString,Ti=Math.max,Ni=Math.min,Li=function(){return Ei.Date.now()};function Mi(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Oi(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==Ai.call(e)}(e))return NaN;if(Mi(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Mi(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(_i,"");var n=wi.test(e);return n||xi.test(e)?ki(e.slice(2),n?2:8):bi.test(e)?NaN:+e}var zi=function(e,t,n){var r,o,i,a,s,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var n=r,i=o;return r=o=void 0,c=t,a=e.apply(i,n)}
163
163
  function m(e){return c=e,s=setTimeout(g,t),u?p(e):a}function f(e){var n=e-l;return void 0===l||n>=t||n<0||h&&e-c>=i}function g(){var e=Li();if(f(e))return v(e);s=setTimeout(g,function(e){var n=t-(e-l);return h?Ni(n,i-(e-c)):n}(e))}function v(e){return s=void 0,d&&r?p(e):(r=o=void 0,a)}function y(){var e=Li(),n=f(e);if(r=arguments,o=this,l=e,n){if(void 0===s)return m(l);if(h)return s=setTimeout(g,t),p(l)}return void 0===s&&(s=setTimeout(g,t)),a}return t=Oi(t)||0,Mi(n)&&(u=!!n.leading,i=(h="maxWait"in n)?Ti(Oi(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d),y.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=o=s=void 0},y.flush=function(){return void 0===s?a:v(Li())},y};class Ii{constructor(){this._listeners=new Map}add(e,t,n,r){e.addEventListener(t,n,r);const o=Symbol();return this._listeners.set(o,{eventTarget:e,eventType:t,listener:n}),o}remove(e){const t=this._listeners.get(e);if(t){const{eventTarget:n,eventType:r,listener:o}=t;n.removeEventListener(r,o),this._listeners.delete(e)}}removeAll(){
164
164
  this._listeners.forEach((({eventTarget:e,eventType:t,listener:n})=>{e.removeEventListener(t,n)})),this._listeners.clear()}}const Ri={defaultHeight:200,marginAbove:800,marginBelow:800};function Pi(e){const t=window.getComputedStyle(e);return e.getBoundingClientRect().height+(parseFloat(t.marginTop)+parseFloat(t.marginBottom))}function Di(e){return/^http(s?):/i.test(e)}function Bi(e){return{read:[e],update:[e],delete:[e]}}function Fi(e,t){return Object.assign(Bi(e),{read:["group:"+t]})}function ji(e,t,n){return"private"===function(e){switch(e){case"private":case"shared":return e;default:return"shared"}}(n)&&e?Bi(e):Fi(e,t)}function Hi(e){return e.read.some((e=>0===e.indexOf("group:")))}function Ui(e){return!Hi(e)}function qi(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("data-testid","copy-text"),t.contentEditable="true",document.body.appendChild(t),t.focus();try{const e=document.createRange(),n=document.getSelection();n.removeAllRanges(),e.selectNodeContents(t),n.addRange(e),
165
165
  t.setSelectionRange(0,t.value.length),document.execCommand("copy")}finally{t.remove()}}function $i({label:e,iconName:t,uri:n}){return Rr("li",{className:"ShareLinks__link",children:Rr("a",{"aria-label":e,href:n,title:e,target:"_blank",rel:"noopener noreferrer",children:Rr(Qr,{name:t,classes:"ShareLinks__icon"})})})}function Gi({shareURI:e}){const t=encodeURIComponent(e);return Rr("ul",{className:"ShareLinks",children:[Rr($i,{iconName:"twitter",label:"Tweet share link",uri:`https://twitter.com/intent/tweet?url=${t}&hashtags=annotated`}),Rr($i,{iconName:"facebook",label:"Share on Facebook",uri:`https://www.facebook.com/sharer/sharer.php?u=${t}`}),Rr($i,{iconName:"email",label:"Share via email",uri:`mailto:?subject=${encodeURIComponent("Let's Annotate")}&body=${t}`})]})}function Vi(){return((e=window.navigator,t="ontouchend"in document)=>["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(e.platform)||e.userAgent.includes("Mac")&&t)()}
166
166
  var Wi=Eo((function({annotation:e,toastMessenger:t,group:n,shareUri:r}){const o=Ui(e.permissions),i=Di(e.uri),a=Sr(null),s=Sr(null),[l,c]=br(!1),u=Sr(l);if(ro(a,l,(()=>c(!1))),xr((()=>{var e,t;u.current!==l&&(u.current=l,l&&!Vi()&&(null===(e=s.current)||void 0===e||e.focus(),null===(t=s.current)||void 0===t||t.select()))}),[l]),!n)return null;const h=i,d="private"===n.type?Rr("span",{children:["Only members of the group ",Rr("em",{children:n.name})," may view this annotation."]}):Rr("span",{children:"Anyone using this link may view this annotation."}),p=o?Rr("span",{children:"Only you may view this annotation."}):d;return Rr("div",{className:"AnnotationShareControl",ref:a,children:[Rr(Hr,{icon:"share",title:"Share",onClick:()=>c(!l),expanded:l}),l&&Rr("div",{className:"annotation-share-panel",children:[Rr("div",{className:"annotation-share-panel__header",children:Rr("div",{className:"annotation-share-panel__title",children:"Share this annotation"})}),Rr("div",{className:"annotation-share-panel__content",
167
167
  children:[Rr("div",{className:"hyp-u-layout-row annotation-share-panel__inputs",children:Rr(fo,{children:[Rr(mo,{"aria-label":"Use this URL to share this annotation",type:"text",value:r,readOnly:!0,inputRef:s}),Rr(Hr,{icon:"copy",title:"Copy share link to clipboard",onClick:()=>{try{qi(r),t.success("Copied share link to clipboard")}catch(e){t.error("Unable to copy link")}},variant:"dark"})]})}),Rr("div",i?{className:"annotation-share-panel__details",children:p}:{className:"annotation-share-panel__details",children:"This annotation cannot be shared in its original context because it was made on a document that is not available on the web. This link shares the annotation by itself."}),h&&Rr(Gi,{shareURI:r})]}),Rr(Qr,{name:"pointer",classes:"annotation-share-panel__arrow"})]})]})}),["toastMessenger"]);var Yi=Eo((function({annotation:e,annotationsService:t,onReply:n,settings:r,toastMessenger:o}){const i=To(),a=i.profile(),s=i.getGroup(e.group),l=i.isLoggedIn(),c=t=>function(e,t,n){return-1!==e[t].indexOf(n||"")
168
- }(e.permissions,t,a.userid),u=c("delete"),h=c("update"),d=function(e){const t=F(e);return!1!==(null==t?void 0:t.allowFlagging)}(r)&&!!a.userid&&a.userid!==e.user,p=function(e){const t=F(e);return!1!==(null==t?void 0:t.enableShareLinks)}(r)&&function(e){var t,n,r,o,i,a;return Di(e.uri)?null!==(t=null!==(n=null===(r=e.links)||void 0===r?void 0:r.incontext)&&void 0!==n?n:null===(o=e.links)||void 0===o?void 0:o.html)&&void 0!==t?t:null:null!==(i=null===(a=e.links)||void 0===a?void 0:a.html)&&void 0!==i?i:null}(e);return Rr("div",{className:"AnnotationActionBar hyp-u-layout-row u-font--xlarge",children:[h&&Rr(Hr,{icon:"edit",title:"Edit",onClick:()=>{i.createDraft(e,{tags:e.tags,text:e.text,isPrivate:Ui(e.permissions)})}}),u&&Rr(Hr,{icon:"trash",title:"Delete",onClick:async()=>{if(await _o({title:"Delete annotation?",message:"Are you sure you want to delete this annotation?",confirmAction:"Delete"}))try{await t.delete(e)}catch(e){o.error(e.message)}}}),Rr(Hr,{icon:"reply",title:"Reply",onClick:()=>{
168
+ }(e.permissions,t,a.userid),u=c("delete"),h=c("update"),d=function(e){const t=P(e);return!1!==(null==t?void 0:t.allowFlagging)}(r)&&!!a.userid&&a.userid!==e.user,p=function(e){const t=P(e);return!1!==(null==t?void 0:t.enableShareLinks)}(r)&&function(e){var t,n,r,o,i,a;return Di(e.uri)?null!==(t=null!==(n=null===(r=e.links)||void 0===r?void 0:r.incontext)&&void 0!==n?n:null===(o=e.links)||void 0===o?void 0:o.html)&&void 0!==t?t:null:null!==(i=null===(a=e.links)||void 0===a?void 0:a.html)&&void 0!==i?i:null}(e);return Rr("div",{className:"AnnotationActionBar hyp-u-layout-row u-font--xlarge",children:[h&&Rr(Hr,{icon:"edit",title:"Edit",onClick:()=>{i.createDraft(e,{tags:e.tags,text:e.text,isPrivate:Ui(e.permissions)})}}),u&&Rr(Hr,{icon:"trash",title:"Delete",onClick:async()=>{if(await _o({title:"Delete annotation?",message:"Are you sure you want to delete this annotation?",confirmAction:"Delete"}))try{await t.delete(e)}catch(e){o.error(e.message)}}}),Rr(Hr,{icon:"reply",title:"Reply",onClick:()=>{
169
169
  l?n():i.openSidebarPanel("loginPrompt")}}),p&&Rr(Wi,{annotation:e,group:s,shareUri:p}),d&&!e.flagged&&Rr(Hr,{icon:"flag",title:"Report this annotation to moderators",onClick:()=>{t.flag(e).catch((()=>o.error("Flagging annotation failed")))}}),d&&e.flagged&&Rr(Hr,{pressed:!0,icon:"flag--active",title:"Annotation has been reported to the moderators"})]})}),["annotationsService","settings","toastMessenger"]);function Ki({isCollapsed:e,setCollapsed:t,linkStyle:n={}}){return Rr("div",{className:"Excerpt__inline-controls",children:Rr("div",{className:"Excerpt__toggle-container",children:Rr(qr,{classes:"InlineLinkButton InlineLinkButton--underlined",onClick:()=>t(!e),expanded:!e,title:"Toggle visibility of full excerpt text",style:n,variant:"dark",children:e?"More":"Less"})})})}const Xi=()=>{};var Zi=Eo((function({children:e,collapse:t=!1,collapsedHeight:n,inlineControls:r=!0,onCollapsibleChanged:o=Xi,onToggleCollapsed:i=Xi,overflowThreshold:a=0,settings:s={}}){const[l,c]=br(!0),u=Sr(),[h,d]=br(0),p=Er((()=>{
170
170
  const e=u.current.clientHeight;d(e);o(e>n+a)}),[n,o,a]);kr((()=>{const e=function(e,t){if("undefined"!=typeof ResizeObserver){const n=new ResizeObserver((()=>t(e.clientWidth,e.clientHeight)));return n.observe(e),()=>n.disconnect()}const n=new Ii;let r=e.clientWidth,o=e.clientHeight;const i=()=>{r===e.clientWidth&&o===e.clientHeight||(r=e.clientWidth,o=e.clientHeight,t(r,o))};n.add(e,"load",i),n.add(window,"resize",i);const a=new MutationObserver(i);return a.observe(e,{characterData:!0,childList:!0,subtree:!0}),()=>{n.removeAll(),a.disconnect()}}(u.current,p);return p(),e}),[p]);const m=h>n+a,f=m&&(r?l:t),g={};0!==h&&(g["max-height"]=f?n:h);const v=e=>r?c(e):i(e);return Rr("div",{className:"Excerpt",style:g,children:[Rr("div",{className:"Excerpt__content",ref:u,children:e}),Rr("div",{role:"presentation",onClick:()=>v(!1),className:hr({Excerpt__shadow:!0,"Excerpt__shadow--transparent":r,"is-hidden":!f}),title:"Show the full excerpt"}),m&&r&&Rr(Ki,{isCollapsed:l,setCollapsed:v,
171
171
  linkStyle:So(["selectionFontFamily"],s)})]})}),["settings"]);function Ji(e,t=16/9){const n=document.createElement("iframe");return n.src=e,n.setAttribute("frameborder","0"),n.setAttribute("allowfullscreen",""),function(e,t){e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%";const n=document.createElement("div");return n.style.paddingBottom=1/t*100+"%",n.style.position="relative",n.appendChild(e),n}(n,t)}function Qi(e){const t=/(\d+)([hms]?)/g,n={h:3600,m:60,s:1};let r,o=0;for(;null!==(r=t.exec(e));)r[2]?o+=Number(r[1])*n[r[2]]:o+=+r[1];return o.toString()}function ea(e,t){const n=function(e){const t=["end","start","t"],n=new URLSearchParams(e.search),r=new URLSearchParams;for(let[e,o]of n)t.includes(e)&&("t"===e?r.append("start",Qi(o)):r.append(e,o));r.sort();let o=r.toString();return o&&(o=`?${o}`),o}(t);return Ji(`https://www.youtube.com/embed/${e}${n}`)}function ta(e,t,n,{aspectRatio:r}={}){return o=>{if(o.hostname!==e)return null
@@ -520,7 +520,7 @@ e.hasAttribute("title")&&(r+=' "'+e.getAttribute("title")+'"'),r+=")"}return r})
520
520
  r||(o=n.subParser("makeMarkdown.header")(e,t,2)+"\n\n");break;case"h3":r||(o=n.subParser("makeMarkdown.header")(e,t,3)+"\n\n");break;case"h4":r||(o=n.subParser("makeMarkdown.header")(e,t,4)+"\n\n");break;case"h5":r||(o=n.subParser("makeMarkdown.header")(e,t,5)+"\n\n");break;case"h6":r||(o=n.subParser("makeMarkdown.header")(e,t,6)+"\n\n");break;case"p":r||(o=n.subParser("makeMarkdown.paragraph")(e,t)+"\n\n");break;case"blockquote":r||(o=n.subParser("makeMarkdown.blockquote")(e,t)+"\n\n");break;case"hr":r||(o=n.subParser("makeMarkdown.hr")(e,t)+"\n\n");break;case"ol":r||(o=n.subParser("makeMarkdown.list")(e,t,"ol")+"\n\n");break;case"ul":r||(o=n.subParser("makeMarkdown.list")(e,t,"ul")+"\n\n");break;case"precode":r||(o=n.subParser("makeMarkdown.codeBlock")(e,t)+"\n\n");break;case"pre":r||(o=n.subParser("makeMarkdown.pre")(e,t)+"\n\n");break;case"table":r||(o=n.subParser("makeMarkdown.table")(e,t)+"\n\n");break;case"code":o=n.subParser("makeMarkdown.codeSpan")(e,t);break;case"em":case"i":
521
521
  o=n.subParser("makeMarkdown.emphasis")(e,t);break;case"strong":case"b":o=n.subParser("makeMarkdown.strong")(e,t);break;case"del":o=n.subParser("makeMarkdown.strikethrough")(e,t);break;case"a":o=n.subParser("makeMarkdown.links")(e,t);break;case"img":o=n.subParser("makeMarkdown.image")(e,t);break;default:o=e.outerHTML+"\n\n"}return o})),n.subParser("makeMarkdown.paragraph",(function(e,t){var r="";if(e.hasChildNodes())for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t);return r=r.trim()})),n.subParser("makeMarkdown.pre",(function(e,t){var n=e.getAttribute("prenum");return"<pre>"+t.preList[n]+"</pre>"})),n.subParser("makeMarkdown.strikethrough",(function(e,t){var r="";if(e.hasChildNodes()){r+="~~";for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t);r+="~~"}return r})),n.subParser("makeMarkdown.strong",(function(e,t){var r="";if(e.hasChildNodes()){r+="**"
522
522
  ;for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t);r+="**"}return r})),n.subParser("makeMarkdown.table",(function(e,t){var r,o,i="",a=[[],[]],s=e.querySelectorAll("thead>tr>th"),l=e.querySelectorAll("tbody>tr");for(r=0;r<s.length;++r){var c=n.subParser("makeMarkdown.tableCell")(s[r],t),u="---";if(s[r].hasAttribute("style"))switch(s[r].getAttribute("style").toLowerCase().replace(/\s/g,"")){case"text-align:left;":u=":---";break;case"text-align:right;":u="---:";break;case"text-align:center;":u=":---:"}a[0][r]=c.trim(),a[1][r]=u}for(r=0;r<l.length;++r){var h=a.push([])-1,d=l[r].getElementsByTagName("td");for(o=0;o<s.length;++o){var p=" ";void 0!==d[o]&&(p=n.subParser("makeMarkdown.tableCell")(d[o],t)),a[h].push(p)}}var m=3;for(r=0;r<a.length;++r)for(o=0;o<a[r].length;++o){var f=a[r][o].length;f>m&&(m=f)}for(r=0;r<a.length;++r){
523
- for(o=0;o<a[r].length;++o)1===r?":"===a[r][o].slice(-1)?a[r][o]=n.helper.padEnd(a[r][o].slice(-1),m-1,"-")+":":a[r][o]=n.helper.padEnd(a[r][o],m,"-"):a[r][o]=n.helper.padEnd(a[r][o],m);i+="| "+a[r].join(" | ")+" |\n"}return i.trim()})),n.subParser("makeMarkdown.tableCell",(function(e,t){var r="";if(!e.hasChildNodes())return"";for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t,!0);return r.trim()})),n.subParser("makeMarkdown.txt",(function(e){var t=e.nodeValue;return t=(t=t.replace(/ +/g," ")).replace(/¨NBSP;/g," "),t=(t=(t=(t=(t=(t=(t=(t=(t=n.helper.unescapeHTMLEntities(t)).replace(/([*_~|`])/g,"\\$1")).replace(/^(\s*)>/g,"\\$1>")).replace(/^#/gm,"\\#")).replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3")).replace(/^( {0,3}\d+)\./gm,"$1\\.")).replace(/^( {0,3})([+-])/gm,"$1\\$2")).replace(/]([\s]*)\(/g,"\\]$1\\(")).replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:")}));e.exports?e.exports=n:this.showdown=n}).call(D)}(Rh);var Ph=Rh.exports;const Dh=Ja(window);function Bh(){return[{
523
+ for(o=0;o<a[r].length;++o)1===r?":"===a[r][o].slice(-1)?a[r][o]=n.helper.padEnd(a[r][o].slice(-1),m-1,"-")+":":a[r][o]=n.helper.padEnd(a[r][o],m,"-"):a[r][o]=n.helper.padEnd(a[r][o],m);i+="| "+a[r].join(" | ")+" |\n"}return i.trim()})),n.subParser("makeMarkdown.tableCell",(function(e,t){var r="";if(!e.hasChildNodes())return"";for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t,!0);return r.trim()})),n.subParser("makeMarkdown.txt",(function(e){var t=e.nodeValue;return t=(t=t.replace(/ +/g," ")).replace(/¨NBSP;/g," "),t=(t=(t=(t=(t=(t=(t=(t=(t=n.helper.unescapeHTMLEntities(t)).replace(/([*_~|`])/g,"\\$1")).replace(/^(\s*)>/g,"\\$1>")).replace(/^#/gm,"\\#")).replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3")).replace(/^( {0,3}\d+)\./gm,"$1\\.")).replace(/^( {0,3})([+-])/gm,"$1\\$2")).replace(/]([\s]*)\(/g,"\\]$1\\(")).replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:")}));e.exports?e.exports=n:this.showdown=n}).call(X)}(Rh);var Ph=Rh.exports;const Dh=Ja(window);function Bh(){return[{
524
524
  type:"output",filter:function(e){return e.replace(/<a href=/g,'<a target="_blank" href=')}}]}let Fh;function jh(e){return"{math:"+e.toString()+"}"}function Hh(e){const t=function(e){const t=[];let n=0,r=e;for(;;){const e=r.indexOf("$$",n),o=r.indexOf("\\(",n);if(-1===e&&-1===o)break;let i,a;if(-1!==e&&(-1===o||e<o)?(i=e,a=r.indexOf("$$",i+2)):(i=o,a=r.indexOf("\\)",i+2)),-1===a)break;a+=2;const s=t.length+1,l=jh(s);let c;t.push({id:s,expression:r.slice(i+2,a-2),inline:-1!==o}),c=-1!==o?l:"\n\n"+l+"\n\n",r=r.slice(0,i)+c+r.slice(a),n=i+c.length}return{mathBlocks:t,content:r}}(e),n=Dh.sanitize(function(e){return Fh||(Fh=new Ph.Converter({extensions:[Bh],simplifiedAutoLink:!0,literalMidWordUnderscores:!0,strikethrough:!0})),Fh.makeHtml(e)}(t.content)),r=function(e,t){return t.reduce(((e,t)=>{let n;try{n=t.inline?Ih(t.expression):Ih(t.expression,{displayMode:!0})}catch(e){n=es(t.expression)}return e.replace(jh(t.id),n)}),e)}(n,t.mathBlocks);return r}function Uh({markdown:e="",textClass:t={},textStyle:n={}}){
525
525
  const r=Cr((()=>e?Hh(e):""),[e]),o=Sr();xr((()=>{!function(e,{className:t}={}){const n=Array.from(e.getElementsByTagName("a"));for(let e of n){const n=ra(e);n&&(t?n.className=t:n.style.width="350px")}}(o.current,{className:"MarkdownView__embed"})}),[e]);return Rr("div",{className:hr("MarkdownView",t),dir:"auto",lang:"",ref:o,dangerouslySetInnerHTML:{__html:r},style:n})}function qh({annotation:e,tags:t}){const n=To(),r=n.defaultAuthority(),o=Cr((()=>!xo(e.user,r)),[e,r]),i=e=>n.getLink("search.tag",{tag:e});return Rr("ul",{className:"TagList","aria-label":"Annotation tags",children:t.map((e=>Rr("li",{className:"TagList__item",children:[o&&Rr("a",{className:"TagList__link",href:i(e),lang:"",target:"_blank",rel:"noopener noreferrer","aria-label":`Tag: ${e}`,title:`View annotations with tag: ${e}`,children:e}),!o&&Rr("span",{className:"TagList__text","aria-label":`Tag: ${e}`,lang:"",children:e})]},e)))})}Dh.addHook("afterSanitizeAttributes",(e=>{"target"in e&&e.setAttribute("target","_blank")}))
526
526
  ;var $h=Eo((function({annotation:e,settings:t}){var n,r;const[o,i]=br(!0),[a,s]=br(!1),l=To().getDraft(e),c=o?"More":"Less",u=null!==(n=null==l?void 0:l.tags)&&void 0!==n?n:e.tags,h=null!==(r=null==l?void 0:l.text)&&void 0!==r?r:e.text,d=h.length>0,p=u.length>0,m=So(["annotationFontFamily"],t);return Rr("div",{className:"hyp-u-vertical-spacing--2",children:[d&&Rr(Zi,{collapse:o,collapsedHeight:400,inlineControls:!1,onCollapsibleChanged:s,onToggleCollapsed:i,overflowThreshold:20,children:Rr(Uh,{textStyle:m,markdown:h,textClass:{AnnotationBody__text:!0,"p-redacted-content":Zo(e)}})}),a&&Rr("div",{className:"hyp-u-layout-row--justify-right",children:Rr(Ur,{expanded:!o,onClick:()=>i(!o),title:`Toggle visibility of full annotation text: Show ${c}`,children:c})}),p&&Rr(qh,{annotation:e,tags:u})]})}),["settings"]);const Gh=0,Vh=1;function Wh(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd;return o>=t+n?(o+=r.length-n,
@@ -564,8 +564,8 @@ t.addEventListener("touchstart",i,c),t.addEventListener("wheel",i,c)),a&&Qd(t),i
564
564
  },s=t>0?`${o} (${t} available)`:o;return Rr(Ur,{classes:hr("u-color-text","SelectionTab",{"is-selected":r}),onClick:a,onMouseDown:a,pressed:!!r,role:"tab",tabIndex:0,title:s,children:Rr(m,{children:[e,t>0&&!n&&Rr("span",{className:"u-font--xsmall",style:"position:relative;bottom:3px;left:2px",children:t})]})})}var lp=Eo((function({annotationsService:e,isLoading:t,settings:n}){const r=To(),o=r.selectedTab(),i=r.noteCount(),a=r.annotationCount(),s=r.orphanCount(),l=r.isWaitingToAnchorAnnotations(),c=e=>{r.clearSelection(),r.selectTab(e)},u="annotation"===o&&0===a&&!l,h="note"===o&&0===i;return Rr("div",{className:"hyp-u-vertical-spacing--4 SelectionTabs__container",children:[Rr("div",{className:"hyp-u-layout-row hyp-u-horizontal-spacing--6 SelectionTabs",role:"tablist",children:[Rr(sp,{count:a,isWaitingToAnchor:l,isSelected:"annotation"===o,label:"Annotations",onSelect:()=>c("annotation"),children:"Annotations"}),Rr(sp,{count:i,isWaitingToAnchor:l,isSelected:"note"===o,label:"Page notes",onSelect:()=>c("note"),
565
565
  children:"Page Notes"}),s>0&&Rr(sp,{count:s,isWaitingToAnchor:l,isSelected:"orphan"===o,label:"Orphans",onSelect:()=>c("orphan"),children:"Orphans"})]}),"note"===o&&n.enableExperimentalNewNoteButton&&Rr("div",{className:"hyp-u-layout-row--justify-right",children:Rr(Ur,{"data-testid":"new-note-button",icon:"add",onClick:()=>e.createPageNote(),variant:"primary",style:So(["ctaBackgroundColor"],n),children:"New note"})}),!t&&h&&Rr(Gr,{classes:"u-text--centered",children:Rr("span",{"data-testid":"notes-unavailable-message",children:"There are no page notes in this group."})}),!t&&u&&Rr(Gr,{classes:"u-text--centered",children:Rr("span",{"data-testid":"annotations-unavailable-message",children:["There are no annotations in this group.",Rr("br",{}),"Create one by selecting some text and clicking the"," ",Rr(Qr,{classes:"hyp-u-margin--1 u-inline",name:"annotate",title:"Annotate"})," ","button."]})})]})}),["annotationsService","settings"])
566
566
  ;var cp=Eo((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const i=yi(),a=To(),s=a.focusedGroupId(),l=a.hasAppliedFilter()||a.hasSelectedAnnotations(),c=a.isLoading(),u=a.isLoggedIn(),h=a.directLinkedAnnotationId(),d=h?a.findAnnotationByID(h):void 0,p=d?ci(d):"annotation",m=a.searchUris(),f=a.hasSidebarOpened(),g=a.profile().userid,v=d&&!1===d.$orphan?d.$tag:null,y=!(c||!h)&&!d,_=a.directLinkedGroupFetchFailed(),b=y||_,w=!b,x=!b&&!l,k=h&&!u&&!y&&!c,S=Sr(s);xr((()=>{if(!S.current||S.current!==s){if(S.current){let e=a.focusState().active;a.clearSelection(),e&&a.toggleFocusMode(!0)}S.current=s}s&&m.length&&r.load({groupId:s,uris:m})}),[a,r,s,g,m]),xr((()=>{v?(e.focusAnnotations([v]),e.scrollToAnnotation(v),a.selectTab(p)):d&&a.selectTab(p)}),[p,e,d,v,a]);const C=a.hasFetchedProfile();return xr((()=>{C&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[C,u,f,o]),Rr("div",{children:[Rr("h2",{className:"u-screen-reader-only",children:"Annotations"}),w&&Rr(Xd,{}),Rr(ap,{onLogin:t,
567
- onSignUp:n}),y&&Rr($d,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),_&&Rr($d,{errorType:"group",onLoginRequest:t}),x&&Rr(lp,{isLoading:c}),Rr(qd,{threads:i.children}),k&&Rr(Zd,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var up=Eo((function({api:e,toastMessenger:t}){const n=To(),r=n.routeParams().q,o=Er((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...Ho(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return xr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Rr(qd,{threads:yi().children})}),["api","toastMessenger"]);class hp{constructor(e,t,n=window){var r,o,i;const a="N/A";let s=a;e.userid&&(s=e.userid,e.displayName&&(s=`${e.displayName} (${s})`)),this.version="1.949.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,
568
- this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(i=o.metadata)||void 0===i?void 0:i.documentFingerprint)&&void 0!==r?r:a,this.account=s,this.timestamp=(new Date).toString()}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}function dp(e){const t=F(e);return!(null==t||!t.authority)&&t.authority!==e.authDomain}function pp({commandName:e,iconName:t}){return Rr("span",{className:"Tutorial__instruction",children:[Rr(Qr,{name:t,classes:"hyp-u-margin--right--1 hyp-u-color--grey-6 u-inline Tutorial__icon"}),Rr("em",{children:e})]})}var mp=Eo((function({settings:e}){const t=!dp(e);return Rr("ol",{className:"Tutorial__list",children:[Rr("li",{className:"Tutorial__item",children:["To create an annotation, select text and then select the"," ",Rr(pp,{iconName:"annotate",commandName:"Annotate"
567
+ onSignUp:n}),y&&Rr($d,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),_&&Rr($d,{errorType:"group",onLoginRequest:t}),x&&Rr(lp,{isLoading:c}),Rr(qd,{threads:i.children}),k&&Rr(Zd,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var up=Eo((function({api:e,toastMessenger:t}){const n=To(),r=n.routeParams().q,o=Er((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...Ho(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return xr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Rr(qd,{threads:yi().children})}),["api","toastMessenger"]);class hp{constructor(e,t,n=window){var r,o,i;const a="N/A";let s=a;e.userid&&(s=e.userid,e.displayName&&(s=`${e.displayName} (${s})`)),this.version="1.953.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,
568
+ this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(i=o.metadata)||void 0===i?void 0:i.documentFingerprint)&&void 0!==r?r:a,this.account=s,this.timestamp=(new Date).toString()}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}function dp(e){const t=P(e);return!(null==t||!t.authority)&&t.authority!==e.authDomain}function pp({commandName:e,iconName:t}){return Rr("span",{className:"Tutorial__instruction",children:[Rr(Qr,{name:t,classes:"hyp-u-margin--right--1 hyp-u-color--grey-6 u-inline Tutorial__icon"}),Rr("em",{children:e})]})}var mp=Eo((function({settings:e}){const t=!dp(e);return Rr("ol",{className:"Tutorial__list",children:[Rr("li",{className:"Tutorial__item",children:["To create an annotation, select text and then select the"," ",Rr(pp,{iconName:"annotate",commandName:"Annotate"
569
569
  })," ","button."]}),Rr("li",{className:"Tutorial__item",children:["To create a highlight (",Rr("a",{href:"https://web.hypothes.is/help/why-are-highlights-private-by-default/",target:"_blank",rel:"noopener noreferrer",children:"visible only to you"}),"), select text and then select the"," ",Rr(pp,{iconName:"highlight",commandName:"Highlight"})," ","button."]}),t&&Rr("li",{className:"Tutorial__item",children:["To annotate in a private group, select the group from the groups dropdown. Don't see your group? Ask the group creator to send a"," ",Rr("a",{href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",rel:"noopener noreferrer",children:"join link"}),")."]}),Rr("li",{className:"Tutorial__item",children:["To reply to an annotation, select the"," ",Rr(pp,{iconName:"reply",commandName:"Reply"})," button."]})]})}),["settings"]);var fp=Eo((function({toastMessenger:e,versionData:t}){return Rr("div",{className:"hyp-u-vertical-spacing",children:[Rr("dl",{className:"VersionInfo",
570
570
  children:[Rr("dt",{className:"VersionInfo__key",children:"Version"}),Rr("dd",{className:"VersionInfo__value",children:t.version}),Rr("dt",{className:"VersionInfo__key",children:"User Agent"}),Rr("dd",{className:"VersionInfo__value",children:t.userAgent}),Rr("dt",{className:"VersionInfo__key",children:"URL"}),Rr("dd",{className:"VersionInfo__value",children:t.urls}),Rr("dt",{className:"VersionInfo__key",children:"Fingerprint"}),Rr("dd",{className:"VersionInfo__value",children:t.fingerprint}),Rr("dt",{className:"VersionInfo__key",children:"Account"}),Rr("dd",{className:"VersionInfo__value",children:t.account}),Rr("dt",{className:"VersionInfo__key",children:"Date"}),Rr("dd",{className:"VersionInfo__value",children:t.timestamp})]}),Rr("div",{className:"hyp-u-layout-row--justify-center",children:Rr(Ur,{onClick:()=>{try{qi(t.asFormattedString()),e.success("Copied version info to clipboard")}catch(t){e.error("Unable to copy version info")}},icon:"copy",children:"Copy version details"})})]})}),["toastMessenger"])
571
571
  ;function gp({linkText:e,url:t}){return Rr("div",{className:"HelpPanel-tabs__tab",children:Rr("a",{href:t,className:"hyp-u-horizontal-spacing--2 hyp-u-layout-row--center HelpPanel-tabs__link",target:"_blank",rel:"noopener noreferrer",children:[Rr("span",{children:e})," ",Rr(Qr,{name:"external",classes:"u-icon--small"})]})})}var vp=Eo((function({auth:e,session:t}){const n=To(),r=n.frames(),o=n.mainFrame(),i=!!n.profile().preferences.show_sidebar_tutorial,[a,s]=br("tutorial"),l=Cr((()=>{const t=e||{status:"logged-out"},n=[...r].sort(((e,t)=>e===o?-1:t===o?1:0));return new hp(t,n)}),[e,r,o]),c=`https://web.hypothes.is/get-help/?sys_info=${l.asEncodedURLString()}`,u=(e,t)=>{e.preventDefault(),s(t)};return Rr(ip,{title:"Help",panelName:"help",onActiveChanged:Er((e=>{!e&&i&&t.dismissSidebarTutorial()}),[t,i]),children:Rr("div",{className:"hyp-u-vertical-spacing HelpPanel__content",children:[Rr("div",{className:"hyp-u-layout-row--align-center",children:[Rr("h3",{className:"HelpPanel__sub-panel-title",children:{
@@ -582,48 +582,48 @@ className:"NotebookView",children:[Rr("header",{className:"NotebookView__heading
582
582
  className:hr("toast-message-container",{"is-dismissed":e.isDismissed}),onClick:()=>t(e.id),children:Rr("div",{className:hr("toast-message",`toast-message--${e.type}`),children:[Rr("div",{className:"toast-message__type",children:Rr(Qr,{name:r,classes:"toast-message__icon"})}),Rr("div",{className:"toast-message__message",children:[Rr("strong",{children:[n,": "]}),e.message,e.moreInfoURL&&Rr("div",{className:"toast-message__link",children:Rr("a",{href:e.moreInfoURL,onClick:e=>e.stopPropagation(),target:"_new",children:"More info"})})]})]})})}var Op=Eo((function({toastMessenger:e}){return Rr("div",{children:Rr("ul",{"aria-live":"polite","aria-relevant":"additions",className:"ToastMessages",children:To().getToastMessages().map((t=>Rr(Mp,{message:t,onDismiss:t=>e.dismiss(t)},t.id)))})})}),["toastMessenger"]);function zp(e){return e.organization&&e.organization.name}function Ip(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return
583
583
  ;const n="__default__"===(r=e.organization).id?"__default__":`${r.name.toLowerCase()}${r.id}`;var r;void 0===t[n]&&(t[n]=Object.assign({},e.organization),t[n].groups=[]),function(e,t){const n=Object.assign({},e),r=t.groups;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function Rp(e){const t=Ip(e),n=[],r=[];return Object.keys(t).sort().forEach((e=>{"__default__"===e?n.push(...t[e].groups):r.push(...t[e].groups)})),n.length&&r.push(...n),r}function Pp({heading:e,children:t}){return Rr(m,{children:[e&&Rr("h2",{className:"MenuSection__heading",children:e}),Rr("ul",{className:"MenuSection__content",children:x(t).map((e=>Rr("li",{children:e},e.key)))})]})}var Dp=Eo((function({isExpanded:e,group:t,groups:n,onExpand:r,toastMessenger:o}){const i=t.links.html,a=i||t.canLeave,s=t.scopes&&!t.scopes.enforced||t.isScopedToUri,l=To(),c=l.focusedGroupId(),u=t.id===c,h=t=>{t.stopPropagation(),t.preventDefault(),r(!e)},d="private"===t.type?"Copy invite link":"Copy activity link"
584
584
  ;return Rr(fd,{icon:t.logo||"blank",iconAlt:zp(t),isDisabled:!s,isExpanded:!!a&&e,isSelected:u,isSubmenuVisible:a?e:void 0,label:t.name,onClick:s?()=>{l.clearDirectLinkedGroupFetchFailed(),l.clearDirectLinkedIds(),n.focus(t.id)}:h,onToggleSubmenu:h,submenu:Rr(m,{children:[Rr("ul",{children:[i&&Rr("li",{children:Rr(fd,{href:i,icon:"external",isSubmenuItem:!0,label:"View group activity"})}),i&&Rr("li",{children:Rr(fd,{onClick:()=>(e=>{try{qi(e),o.success(`Copied link for "${t.name}"`)}catch(e){o.error("Unable to copy link")}})(i),icon:"copy",isSubmenuItem:!0,label:d})}),t.canLeave&&Rr("li",{children:Rr(fd,{icon:"leave",isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await _o({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&Rr("p",{className:"GroupListItem__footer",children:"This group is restricted to specific URLs."})]})})}),["groups","toastMessenger"])
585
- ;function Bp({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return Rr(Pp,{heading:r,children:n.map((n=>Rr(Dp,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}var Fp=Eo((function({settings:e}){const t=To(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=Cr((()=>Rp(o)),[o]),l=Cr((()=>Rp(r)),[r]),c=Cr((()=>Rp(n)),[n]),u=t.defaultAuthority(),h=a&&!xo(a,u),d=t.getLink("groups.new"),[p,m]=br(null);let f;if(i){const t=i.organization.logo||function(e){const t=F(e);return t&&t.icon?t.icon:null}(e)||"",n=zp(i)?zp(i):"";f=Rr("span",{className:"GroupList__menu-label",children:[t&&Rr("img",{className:"GroupList__menu-icon",src:t,alt:n}),i.name]})}else f=Rr("span",{children:"…"});return!!dp(e)&&n.length+r.length+o.length<2?f:Rr(pd,{align:"left",contentClass:"GroupList__content",label:f,onOpenChanged:()=>m(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[c.length>0&&Rr(Bp,{expandedGroup:p,onExpandGroup:m,
585
+ ;function Bp({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return Rr(Pp,{heading:r,children:n.map((n=>Rr(Dp,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}var Fp=Eo((function({settings:e}){const t=To(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=Cr((()=>Rp(o)),[o]),l=Cr((()=>Rp(r)),[r]),c=Cr((()=>Rp(n)),[n]),u=t.defaultAuthority(),h=a&&!xo(a,u),d=t.getLink("groups.new"),[p,m]=br(null);let f;if(i){const t=i.organization.logo||function(e){const t=P(e);return t&&t.icon?t.icon:null}(e)||"",n=zp(i)?zp(i):"";f=Rr("span",{className:"GroupList__menu-label",children:[t&&Rr("img",{className:"GroupList__menu-icon",src:t,alt:n}),i.name]})}else f=Rr("span",{children:"…"});return!!dp(e)&&n.length+r.length+o.length<2?f:Rr(pd,{align:"left",contentClass:"GroupList__content",label:f,onOpenChanged:()=>m(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[c.length>0&&Rr(Bp,{expandedGroup:p,onExpandGroup:m,
586
586
  heading:"Currently Viewing",groups:c}),l.length>0&&Rr(Bp,{expandedGroup:p,onExpandGroup:m,heading:"Featured Groups",groups:l}),s.length>0&&Rr(Bp,{expandedGroup:p,onExpandGroup:m,heading:"My Groups",groups:s}),h&&Rr(fd,{icon:"add",href:d,label:"New private group"})]})}),["settings"]);function jp({alwaysExpanded:e,query:t,onSearch:n}){const r=To().isLoading(),o=Sr(),[i,a]=br(t),[s,l]=br(t);return t!==i&&(l(t),a(t)),Rr("form",{action:"#",className:"SearchInput__form",name:"searchForm",onSubmit:e=>{e.preventDefault(),(o.current.value||i)&&n(o.current.value)},children:[Rr("input",{"aria-label":"Search",className:hr("SearchInput__input",{"is-expanded":e||t}),dir:"auto",type:"text",name:"query",placeholder:r?"Loading…":"Search…",disabled:r,ref:o,value:s||"",onInput:e=>l(e.target.value)}),!r&&Rr("div",{className:"SearchInput__button-container",children:Rr(Hr,{icon:"search",onClick:()=>o.current.focus(),size:"small",title:"Search annotations"})}),r&&Rr("div",{style:"margin:0.5em 0",children:Rr(ho,{size:"small"})})]})}
587
- function Hp(){const e=To(),t=e.sortKey(),n=e.sortKeys().map((n=>Rr(fd,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Rr("span",{className:"TopBar__menu-label",children:Rr(Qr,{name:"sort",classes:"TopBar__menu-icon"})});return Rr("div",{className:"SortMenu",children:Rr(pd,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var Up=Eo((function({router:e}){return Rr(jp,{query:To().routeParams().q,onSearch:t=>{e.navigate("stream",{q:t})},alwaysExpanded:!0})}),["router"]);var qp=Eo((function({auth:e,frameSync:t,onLogout:n,settings:r}){const o=To(),i=o.defaultAuthority(),a=xo(e.userid,i),s=F(r),l=o.isFeatureEnabled("notebook_launch"),[c,u]=br(!1),h=e=>s&&!!s[e],d=!a||h("onProfileRequestProvided"),p=!a||h("onLogoutRequestProvided"),m=()=>{t.notifyHost("openNotebook",o.focusedGroupId())},f=()=>a&&t.notifyHost("profileRequested"),g=(()=>{const t={};return d&&(a||(t.href=o.getLink("user",{user:e.username})),t.onClick=f),t})(),v=Rr("span",{className:"TopBar__menu-label",
588
- children:Rr(Qr,{name:"profile",classes:"TopBar__menu-icon"})});return Rr("div",{className:"UserMenu",onKeyDown:e=>{"n"===e.key&&(m(),u(!1))},children:Rr(pd,{label:v,title:e.displayName,align:"right",open:c,onOpenChanged:u,children:[Rr(Pp,{children:[Rr(fd,{label:e.displayName,isDisabled:!d,...g}),!a&&Rr(fd,{label:"Account settings",href:o.getLink("account.settings")}),l&&Rr(fd,{label:"Open notebook",onClick:()=>m()})]}),p&&Rr(Pp,{children:Rr(fd,{label:"Log out",onClick:n})})]})})}),["frameSync","settings"]);var $p=Eo((function({auth:e,frameSync:t,isSidebar:n,onLogin:r,onLogout:o,onSignUp:i,settings:a,streamer:s}){const l=!dp(a),c=So(["accentColor"],a),u=To(),h=u.filterQuery(),d=u.pendingUpdateCount(),p=u.isSidebarPanelOpen("help"),f=u.isSidebarPanelOpen("shareGroupAnnotations"),g=()=>{const e=F(a);e&&e.onHelpRequestProvided?t.notifyHost("helpRequested"):u.toggleSidebarPanel("help")},v=Rr(m,{children:["unknown"===e.status&&Rr("span",{className:"TopBar__login-links",children:"⋯"
587
+ function Hp(){const e=To(),t=e.sortKey(),n=e.sortKeys().map((n=>Rr(fd,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Rr("span",{className:"TopBar__menu-label",children:Rr(Qr,{name:"sort",classes:"TopBar__menu-icon"})});return Rr("div",{className:"SortMenu",children:Rr(pd,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var Up=Eo((function({router:e}){return Rr(jp,{query:To().routeParams().q,onSearch:t=>{e.navigate("stream",{q:t})},alwaysExpanded:!0})}),["router"]);var qp=Eo((function({auth:e,frameSync:t,onLogout:n,settings:r}){const o=To(),i=o.defaultAuthority(),a=xo(e.userid,i),s=P(r),l=o.isFeatureEnabled("notebook_launch"),[c,u]=br(!1),h=e=>s&&!!s[e],d=!a||h("onProfileRequestProvided"),p=!a||h("onLogoutRequestProvided"),m=()=>{t.notifyHost("openNotebook",o.focusedGroupId())},f=()=>a&&t.notifyHost("profileRequested"),g=(()=>{const t={};return d&&(a||(t.href=o.getLink("user",{user:e.username})),t.onClick=f),t})(),v=Rr("span",{className:"TopBar__menu-label",
588
+ children:Rr(Qr,{name:"profile",classes:"TopBar__menu-icon"})});return Rr("div",{className:"UserMenu",onKeyDown:e=>{"n"===e.key&&(m(),u(!1))},children:Rr(pd,{label:v,title:e.displayName,align:"right",open:c,onOpenChanged:u,children:[Rr(Pp,{children:[Rr(fd,{label:e.displayName,isDisabled:!d,...g}),!a&&Rr(fd,{label:"Account settings",href:o.getLink("account.settings")}),l&&Rr(fd,{label:"Open notebook",onClick:()=>m()})]}),p&&Rr(Pp,{children:Rr(fd,{label:"Log out",onClick:n})})]})})}),["frameSync","settings"]);var $p=Eo((function({auth:e,frameSync:t,isSidebar:n,onLogin:r,onLogout:o,onSignUp:i,settings:a,streamer:s}){const l=!dp(a),c=So(["accentColor"],a),u=To(),h=u.filterQuery(),d=u.pendingUpdateCount(),p=u.isSidebarPanelOpen("help"),f=u.isSidebarPanelOpen("shareGroupAnnotations"),g=()=>{const e=P(a);e&&e.onHelpRequestProvided?t.notifyHost("helpRequested"):u.toggleSidebarPanel("help")},v=Rr(m,{children:["unknown"===e.status&&Rr("span",{className:"TopBar__login-links",children:"⋯"
589
589
  }),"logged-out"===e.status&&Rr("span",{className:"TopBar__login-links u-font--large hyp-u-horizontal-spacing--2",children:[Rr(qr,{classes:"InlineLinkButton",onClick:i,style:c,variant:"primary",children:"Sign up"}),Rr("div",{children:"/"}),Rr(qr,{classes:"InlineLinkButton",onClick:r,style:c,variant:"primary",children:"Log in"})]}),"logged-in"===e.status&&Rr(qp,{auth:e,onLogout:o})]});return Rr("div",{className:"TopBar",children:[!n&&Rr("div",{className:"TopBar__inner content",children:[Rr(Up,{}),Rr("div",{className:"hyp-u-stretch"}),Rr(Hr,{icon:"help",expanded:p,onClick:g,size:"small",title:"Help"}),v]}),n&&Rr("div",{className:"TopBar__inner content",children:[Rr(Fp,{}),Rr("div",{className:"hyp-u-stretch"}),d>0&&Rr(Hr,{icon:"refresh",onClick:()=>s.applyPendingUpdates(),size:"small",variant:"primary",title:`Show ${d} new/updated ${1===d?"annotation":"annotations"}`}),Rr(jp,{query:h||null,onSearch:u.setFilterQuery}),Rr(Hp,{}),l&&Rr(Hr,{icon:"share",expanded:f,onClick:()=>{
590
- u.toggleSidebarPanel("shareGroupAnnotations")},size:"small",title:"Share annotations on this page"}),Rr(Hr,{icon:"help",expanded:p,onClick:g,size:"small",title:"Help"}),v]})]})}),["frameSync","settings","streamer"]);var Gp=Eo((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=To(),a=i.hasFetchedProfile(),s=i.profile(),l=i.route(),c=Cr((()=>a?function(e){const t=bo(e.userid);if(t&&e.userid){let n=t.username;return e.user_info&&e.user_info.display_name&&(n=e.user_info.display_name),{status:"logged-in",displayName:n,userid:e.userid,username:t.username}}return{status:"logged-out"}}(s):{status:"unknown"}),[a,s]),u=Cr((()=>So(["appBackgroundColor"],n)),[n]),h="clean"===n.theme,d="sidebar"===l;xr((()=>{(function(e,t,n){const r="object"==typeof t.preferences&&!!t.preferences.show_sidebar_tutorial,o=F(n)||{onHelpRequestProvided:!1};return e&&!o.onHelpRequestProvided&&r})(d,s,n)&&i.openSidebarPanel("help")}),[d,s,n,i]);const p=async()=>{if(F(n))t.notifyHost("loginRequested");else try{
591
- await e.login(),i.closeSidebarPanel("loginPrompt"),i.clearGroups(),r.reload()}catch(e){o.error(e.message)}},m=()=>{F(n)?t.notifyHost("signupRequested"):window.open(i.getLink("signup"))};return Rr("div",{className:hr("HypothesisApp","js-thread-list-scroll-root",{"theme-clean":h,"HypothesisApp--notebook":"notebook"===l}),style:u,children:["notebook"!==l&&Rr($p,{auth:c,onLogin:p,onSignUp:m,onLogout:async()=>{await(async()=>{const e=i.countDrafts();if(0===e)return!0;let t="";return 1===e?t="You have an unsaved annotation.\nDo you really want to discard this draft?":e>1&&(t="You have "+e+" unsaved annotations.\nDo you really want to discard these drafts?"),_o({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),F(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),Rr("div",{className:"HypothesisApp__content",children:[Rr(Op,{}),Rr(vp,{auth:"logged-in"===c.status?c:{}}),Rr(Lp,{}),l&&Rr("main",{
592
- children:["annotation"===l&&Rr(Gd,{onLogin:p}),"notebook"===l&&Rr(Np,{}),"stream"===l&&Rr(up,{}),"sidebar"===l&&Rr(cp,{onLogin:p,onSignUp:m})]})]})]})}),["auth","frameSync","session","settings","toastMessenger"]);function Vp({error:e}){return Rr("div",{className:"LaunchErrorPanel",children:Rr(co,{title:"Unable to start Hypothesis",children:e.message})})}class Wp{constructor(e,t){this._api=e,this._store=t}_applyDraftChanges(e){const t={},n=this._store.getDraft(e);return n&&(t.tags=n.tags,t.text=n.text,t.permissions=n.isPrivate?Bi(e.user):Fi(e.user,e.group)),{...e,...t}}_initialize(e,t=new Date){const n=this._store.getDefault("annotationPrivacy"),r=this._store.focusedGroupId(),o=this._store.profile();if(!r)throw new Error("Cannot create annotation without a group");const i=o.userid,a=o.user_info,s="s:"+Z(8),l=Object.assign({created:t.toISOString(),group:r,permissions:ji(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e)
590
+ u.toggleSidebarPanel("shareGroupAnnotations")},size:"small",title:"Share annotations on this page"}),Rr(Hr,{icon:"help",expanded:p,onClick:g,size:"small",title:"Help"}),v]})]})}),["frameSync","settings","streamer"]);var Gp=Eo((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=To(),a=i.hasFetchedProfile(),s=i.profile(),l=i.route(),c=Cr((()=>a?function(e){const t=bo(e.userid);if(t&&e.userid){let n=t.username;return e.user_info&&e.user_info.display_name&&(n=e.user_info.display_name),{status:"logged-in",displayName:n,userid:e.userid,username:t.username}}return{status:"logged-out"}}(s):{status:"unknown"}),[a,s]),u=Cr((()=>So(["appBackgroundColor"],n)),[n]),h="clean"===n.theme,d="sidebar"===l;xr((()=>{(function(e,t,n){const r="object"==typeof t.preferences&&!!t.preferences.show_sidebar_tutorial,o=P(n)||{onHelpRequestProvided:!1};return e&&!o.onHelpRequestProvided&&r})(d,s,n)&&i.openSidebarPanel("help")}),[d,s,n,i]);const p=async()=>{if(P(n))t.notifyHost("loginRequested");else try{
591
+ await e.login(),i.closeSidebarPanel("loginPrompt"),i.clearGroups(),r.reload()}catch(e){o.error(e.message)}},m=()=>{P(n)?t.notifyHost("signupRequested"):window.open(i.getLink("signup"))};return Rr("div",{className:hr("HypothesisApp","js-thread-list-scroll-root",{"theme-clean":h,"HypothesisApp--notebook":"notebook"===l}),style:u,children:["notebook"!==l&&Rr($p,{auth:c,onLogin:p,onSignUp:m,onLogout:async()=>{await(async()=>{const e=i.countDrafts();if(0===e)return!0;let t="";return 1===e?t="You have an unsaved annotation.\nDo you really want to discard this draft?":e>1&&(t="You have "+e+" unsaved annotations.\nDo you really want to discard these drafts?"),_o({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),P(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),Rr("div",{className:"HypothesisApp__content",children:[Rr(Op,{}),Rr(vp,{auth:"logged-in"===c.status?c:{}}),Rr(Lp,{}),l&&Rr("main",{
592
+ children:["annotation"===l&&Rr(Gd,{onLogin:p}),"notebook"===l&&Rr(Np,{}),"stream"===l&&Rr(up,{}),"sidebar"===l&&Rr(cp,{onLogin:p,onSignUp:m})]})]})]})}),["auth","frameSync","session","settings","toastMessenger"]);function Vp({error:e}){return Rr("div",{className:"LaunchErrorPanel",children:Rr(co,{title:"Unable to start Hypothesis",children:e.message})})}class Wp{constructor(e,t){this._api=e,this._store=t}_applyDraftChanges(e){const t={},n=this._store.getDraft(e);return n&&(t.tags=n.tags,t.text=n.text,t.permissions=n.isPrivate?Bi(e.user):Fi(e.user,e.group)),{...e,...t}}_initialize(e,t=new Date){const n=this._store.getDefault("annotationPrivacy"),r=this._store.focusedGroupId(),o=this._store.profile();if(!r)throw new Error("Cannot create annotation without a group");const i=o.userid,a=o.user_info,s="s:"+q(8),l=Object.assign({created:t.toISOString(),group:r,permissions:ji(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e)
593
593
  ;return Jo(l)&&(l.permissions=Bi(i)),l}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Jo(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!Yo(n)}),ei(n)?this._store.selectTab("note"):ti(n)&&this._store.selectTab("annotation"),(n.references||[]).forEach((e=>{this._store.setExpanded(e,!0)}))}createPageNote(){const e=this._store.mainFrame();if(!this._store.isLoggedIn())return void this._store.openSidebarPanel("loginPrompt");if(!e)return;const t={target:[],uri:e.uri};this.create(t)}async delete(e){await this._api.annotation.delete({id:e.id}),this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,permissions:Yo(e)?Fi(t,e.group):Bi(t),references:(e.references||[]).concat(e.id),target:[{source:e.target[0].source}],uri:e.uri};this.create(n)}async save(e){let t;const n=this._applyDraftChanges(e);let r
594
594
  ;t=Wo(e)?this._api.annotation.create({},n):this._api.annotation.update({id:e.id},n),this._store.annotationSaveStarted(e);try{r=await t}finally{this._store.annotationSaveFinished(e)}return Object.keys(e).forEach((t=>{"$"===t[0]&&(r[t]=e[t])})),this._store.removeDraft(e),this._store.addAnnotations([r]),r}}Wp.$inject=["api","store"];class Yp 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 Kp(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Yp(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new Yp(e,n,"Failed to parse response")}var o;if(!n.ok)throw new Yp(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function Xp(e,t){const n={};for(const r in t)if(t.hasOwnProperty(r)){const o=t[r],i=":"+r;-1!==e.indexOf(i)?e=e.replace(i,encodeURIComponent(String(o))):n[r]=o}return{url:e,unusedParams:n}}function Zp(e){const t={}
595
- ;for(const n in e)e.hasOwnProperty(n)&&"$"!==n[0]&&(t[n]=e[n]);return t}class Jp{constructor(e,t,n){const r=e.routes();this._clientId=null;const o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,l]=await Promise.all([e,n()]),c=function(e,t){let n=e;return t.split(".").forEach((e=>{n=n[e]})),n}(o,t),u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.949.0"};l&&(u.Authorization="Bearer "+l);const h=r();h&&(u["X-Client-Id"]=h);const{url:d,unusedParams:p}=Xp(c.url,a),m=new URL(d);for(let[e,t]of Object.entries(p)){Array.isArray(t)||(t=[t]);for(let n of t)null!=n&&m.searchParams.append(e,n.toString())}return await Kp(m.toString(),{body:s?JSON.stringify(Zp(s)):null,headers:u,method:c.method})}finally{i()}}}(r,e,{getAccessToken:t.getAccessToken,getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={
595
+ ;for(const n in e)e.hasOwnProperty(n)&&"$"!==n[0]&&(t[n]=e[n]);return t}class Jp{constructor(e,t,n){const r=e.routes();this._clientId=null;const o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,l]=await Promise.all([e,n()]),c=function(e,t){let n=e;return t.split(".").forEach((e=>{n=n[e]})),n}(o,t),u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.953.0"};l&&(u.Authorization="Bearer "+l);const h=r();h&&(u["X-Client-Id"]=h);const{url:d,unusedParams:p}=Xp(c.url,a),m=new URL(d);for(let[e,t]of Object.entries(p)){Array.isArray(t)||(t=[t]);for(let n of t)null!=n&&m.searchParams.append(e,n.toString())}return await Kp(m.toString(),{body:s?JSON.stringify(Zp(s)):null,headers:u,method:c.method})}finally{i()}}}(r,e,{getAccessToken:t.getAccessToken,getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={
596
596
  create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")}}setClientId(e){this._clientId=e}}Jp.$inject=["apiRoutes","auth","store"];var Qp={};function em(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var tm=em;em.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},
597
597
  em.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},em.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n),this._options.unref&&this._timer.unref(),!0},em.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb))
598
598
  ;var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},em.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},em.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},em.prototype.start=em.prototype.try,em.prototype.errors=function(){return this._errors},em.prototype.attempts=function(){return this._attempts},em.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=o,n=a)}return t},function(e){var t=tm;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,
599
599
  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));return e&&e.forever&&!r.length&&r.push(this.createTimeout(o,t)),r.sort((function(e,t){return e-t})),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout)},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var o in r=[],t)"function"==typeof t[o]&&r.push(o);for(var i=0;i<r.length;i++){var a=r[i],s=t[a];t[a]=function(r){var o=e.operation(n),i=Array.prototype.slice.call(arguments,1),a=i.pop();i.push((function(e){o.retry(e)||(e&&(arguments[0]=o.mainError()),a.apply(this,arguments))})),o.attempt((function(){r.apply(t,i)}))}.bind(t,s),t[a].options=n}}}(Qp);var nm=Qp;function rm(e,t){return new Promise(((n,r)=>{const o=nm.operation(t);o.attempt((async()=>{try{const t=await e()
600
600
  ;o.retry(),n(t)}catch(e){o.retry(e)||r(e)}}))}))}function om(e){return rm((()=>Kp(e)))}class im{constructor(e){this._apiUrl=e.apiUrl,this._routeCache=null,this._linkCache=null}routes(){return this._routeCache||(this._routeCache=om(this._apiUrl).then((e=>e.links))),this._routeCache}links(){return this._linkCache||(this._linkCache=this.routes().then((e=>om(e.links.url)))),this._linkCache}}im.$inject=["settings"];class am extends Error{constructor(e,t){super(e),this.cause=t}}class sm{constructor(e){this.clientId=e.clientId,this.tokenEndpoint=e.tokenEndpoint,this.authorizationEndpoint=e.authorizationEndpoint,this.revokeEndpoint=e.revokeEndpoint}exchangeAuthCode(e){return this._getAccessToken({client_id:this.clientId,grant_type:"authorization_code",code:e})}exchangeGrantToken(e){return this._getAccessToken({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:e})}refreshToken(e){return this._getAccessToken({grant_type:"refresh_token",refresh_token:e})}async revokeToken(e){try{
601
- await this._formPost(this.revokeEndpoint,{token:e})}catch(e){throw new am("Failed to revoke access token",e)}}authorize(e,t){const n=Z(16),r=new Promise(((t,r)=>{e.addEventListener("message",(function o(i){"object"==typeof i.data&&i.data.state===n&&("authorization_response"===i.data.type&&t(i.data),"authorization_canceled"===i.data.type&&r(new Error("Authorization window was closed")),e.removeEventListener("message",o))}))})),o=new URL(this.authorizationEndpoint);return o.searchParams.set("client_id",this.clientId),o.searchParams.set("origin",e.location.origin),o.searchParams.set("response_mode","web_message"),o.searchParams.set("response_type","code"),o.searchParams.set("state",n),t.location=o.toString(),r.then((e=>e.code))}async _formPost(e,t){const n=new URLSearchParams;for(let[e,r]of Object.entries(t))n.set(e,r);n.sort();return Kp(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()})}async _getAccessToken(e){let t;try{t=await this._formPost(this.tokenEndpoint,e)
602
- }catch(e){throw new am("Failed to fetch access token",e)}return{accessToken:t.access_token,expiresAt:Date.now()+1e3*(t.expires_in-10),refreshToken:t.refresh_token}}static openAuthPopupWindow(e){const t=`left=${e.screen.width/2-237.5},top=${e.screen.height/2-215},width=475,height=430`,n=e.open("about:blank","Log in to Hypothesis",t);if(!n)throw new Error("Failed to open login window");return n}}class lm extends bp{constructor(e,t,n,r,o){let i,a,s;super();const l=(c="token",u=r.apiUrl,new URL(c,u).href);var c,u;function h(){let e=new URL(r.apiUrl).hostname;return e=e.replace(/\./g,"%2E"),`hypothesis.oauth.${e}.token`}function d(e){n.setObject(h(),e)}const p=async()=>{if(s)return s;const e=await t.links();return s=new sm({clientId:r.oauthClientId,authorizationEndpoint:e["oauth.authorize"],revokeEndpoint:e["oauth.revoke"],tokenEndpoint:l}),s},m=()=>{var e;return null===(e=F(r))||void 0===e?void 0:e.grantToken},f=async()=>{if(!a){const e=m();void 0!==e?a=e?p().then((t=>t.exchangeGrantToken(e))).catch((e=>{var t
601
+ await this._formPost(this.revokeEndpoint,{token:e})}catch(e){throw new am("Failed to revoke access token",e)}}authorize(e,t){const n=q(16),r=new Promise(((t,r)=>{e.addEventListener("message",(function o(i){"object"==typeof i.data&&i.data.state===n&&("authorization_response"===i.data.type&&t(i.data),"authorization_canceled"===i.data.type&&r(new Error("Authorization window was closed")),e.removeEventListener("message",o))}))})),o=new URL(this.authorizationEndpoint);return o.searchParams.set("client_id",this.clientId),o.searchParams.set("origin",e.location.origin),o.searchParams.set("response_mode","web_message"),o.searchParams.set("response_type","code"),o.searchParams.set("state",n),t.location=o.toString(),r.then((e=>e.code))}async _formPost(e,t){const n=new URLSearchParams;for(let[e,r]of Object.entries(t))n.set(e,r);n.sort();return Kp(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()})}async _getAccessToken(e){let t;try{t=await this._formPost(this.tokenEndpoint,e)
602
+ }catch(e){throw new am("Failed to fetch access token",e)}return{accessToken:t.access_token,expiresAt:Date.now()+1e3*(t.expires_in-10),refreshToken:t.refresh_token}}static openAuthPopupWindow(e){const t=`left=${e.screen.width/2-237.5},top=${e.screen.height/2-215},width=475,height=430`,n=e.open("about:blank","Log in to Hypothesis",t);if(!n)throw new Error("Failed to open login window");return n}}class lm extends bp{constructor(e,t,n,r,o){let i,a,s;super();const l=(c="token",u=r.apiUrl,new URL(c,u).href);var c,u;function h(){let e=new URL(r.apiUrl).hostname;return e=e.replace(/\./g,"%2E"),`hypothesis.oauth.${e}.token`}function d(e){n.setObject(h(),e)}const p=async()=>{if(s)return s;const e=await t.links();return s=new sm({clientId:r.oauthClientId,authorizationEndpoint:e["oauth.authorize"],revokeEndpoint:e["oauth.revoke"],tokenEndpoint:l}),s},m=()=>{var e;return null===(e=P(r))||void 0===e?void 0:e.grantToken},f=async()=>{if(!a){const e=m();void 0!==e?a=e?p().then((t=>t.exchangeGrantToken(e))).catch((e=>{var t
603
603
  ;throw t="You must reload the page to annotate.",o.error(`Hypothesis login lost: ${t}`,{autoDismiss:!1}),e})):Promise.resolve(null):i?(a=(async e=>{const t=await p(),n=await t.exchangeAuthCode(e);return d(n),n})(i),i=null):a=Promise.resolve(function(){const e=n.getObject(h());return e&&"string"==typeof e.accessToken&&"string"==typeof e.refreshToken&&"number"==typeof e.expiresAt?{accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt}:null}())}const e=a,t=await a;if(!t)return null;if(e!==a)return f();if(Date.now()>t.expiresAt){const e=m();return a=(async(e,t)=>{const n=await p();let r;try{if(r=await n.refreshToken(e),Date.now()>r.expiresAt)throw new Error("Refreshed token expired in the past")}catch{return null}return t.persist&&d(r),r})(t.refreshToken,{persist:void 0===e}),f()}return t.accessToken};(()=>{e.addEventListener("storage",(({key:e})=>{e===h()&&(a=null,this.emit("oauthTokensChanged"))}))})(),this.login=async function(){
604
604
  const t=sm.openAuthPopupWindow(e),n=await p(),r=await n.authorize(e,t);i=r,a=null},this.logout=async function(){const[e,t]=await Promise.all([a,p()]);e&&await t.revokeToken(e.accessToken),a=Promise.resolve(null),n.removeItem(h())},this.getAccessToken=f}}lm.$inject=["$window","apiRoutes","localStorage","settings","toastMessenger"];class cm{constructor(e,t){this._annotationsService=e,this._store=t,this._saving=new Set,this._failed=new Set}init(){const e=e=>!this._saving.has(e)&&!this._failed.has(e);this._store.subscribe((()=>{this._store.newHighlights().forEach((t=>{const n=t.$tag;e(n)&&(this._saving.add(n),rm((()=>this._annotationsService.save(t))).catch((()=>{this._failed.add(n)})).finally((()=>{this._saving.delete(n)})))}))}))}isSaving(){return this._saving.size>0}}cm.$inject=["annotationsService","store"];var um=function(e,t,n,r){var o=n?n.call(r,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),a=Object.keys(t)
605
605
  ;if(i.length!==a.length)return!1;for(var s=Object.prototype.hasOwnProperty.bind(t),l=0;l<i.length;l++){var c=i[l];if(!s(c))return!1;var u=e[c],h=t[c];if(!1===(o=n?n.call(r,u,h,c):void 0)||void 0===o&&u!==h)return!1}return!0};function hm(e,t,n){const r=Array.isArray(t),o=()=>r?t.map((e=>e())):t();let i=o();return e((()=>{const e=o();if(r?um(e,i):e===i)return;const t=i;i=e,n(e,t)}))}class dm{constructor(e,t){this._frameSync=e,this._store=t}init(){const e=()=>this._store.profile().features;hm(this._store.subscribe,[e,()=>this._store.frames()],(()=>{this._frameSync.notifyHost("featureFlagsUpdated",e()||{})}))}}dm.$inject=["frameSync","store"];class pm{constructor(e,t){this._port=e,this._methods=t,this._sequence=0,this._callbacks={},this._destroyed=!1,this._listeners=new Ii,this._listeners.add(this._port,"message",(e=>this._handle(e))),this._port.start()}destroy(){this._destroyed=!0,this._listeners.removeAll(),this._port.close()}call(e,...t){if(this._destroyed)return;const n=this._sequence++,r=t[t.length-1]
606
606
  ;"function"==typeof r&&(this._callbacks[n]=r,t=t.slice(0,-1));const o={arguments:t,method:e,protocol:"frame-rpc",sequence:n,version:"1.0.0"};this._port.postMessage(o)}_parseMessage({data:e}){return e&&"object"==typeof e?"frame-rpc"!==e.protocol||"1.0.0"!==e.version?null:Array.isArray(e.arguments)?e:null:null}_handle(e){const t=this._parseMessage(e);if(null!==t)if("method"in t){if(!this._methods.hasOwnProperty(t.method))return;const e=(...e)=>{const n={arguments:e,protocol:"frame-rpc",response:t.sequence,version:"1.0.0"};this._port.postMessage(n)};this._methods[t.method](...t.arguments,e)}else if("response"in t){const e=this._callbacks[t.response];delete this._callbacks[t.response],e&&e(...t.arguments)}}}class mm{constructor(){this.links=[],this.channelListeners={},this.onConnectListeners=[],this.on("connect",(e=>e()))}destroy(){this.links.forEach((e=>e.destroy())),this.links=[]}createChannel(e){const t=new pm(e,this.channelListeners);let n=!1;return t.call("connect",(()=>{n||(n=!0,
607
607
  this.onConnectListeners.forEach((e=>e(t))))})),this.links.push(t),t}call(e,...t){let n;const r=t[t.length-1];"function"==typeof r&&(n=r,t=t.slice(0,-1));const o=e=>t=>{throw e.destroy(),this.links=this.links.filter((t=>t!==e)),t},i=this.links.map((n=>{const r=new Promise(((r,o)=>{const i=setTimeout((()=>r(null)),1e3);try{n.call(e,...t,((e,t)=>{clearTimeout(i),e?o(e):r(t)}))}catch(e){o(e)}}));return r.catch(o(n))}));let a=Promise.all(i);return n&&(a=a.then((e=>n(null,e))).catch((e=>n(e)))),a}on(e,t){if(this.links.length>0)throw new Error(`Listener '${e}' can't be registered because a channel has already been created`);if(this.channelListeners[e])throw new Error(`Listener '${e}' already bound in Bridge`);return this.channelListeners[e]=t,this}onConnect(e){return this.onConnectListeners.push(e),this}}function fm(e,t){return!!function(e){if(null===e||"object"!=typeof e)return!1;for(let t of["frame1","frame2","type"])if("string"!=typeof e[t])return!1;return!0
608
- }(e)&&JSON.stringify(e,Object.keys(t).sort())===JSON.stringify(t,Object.keys(t).sort())}class gm{constructor({hostFrame:e,source:t}){this._hostFrame=e,this._source=t,this._listeners=new Ii}destroy(){this._listeners.removeAll()}async discover(e){let t=!1;if(("guest"===this._source&&"host"===e||"guest"===this._source&&"sidebar"===e||"sidebar"===this._source&&"host"===e||"notebook"===this._source&&"sidebar"===e)&&(t=!0),!t)throw new Error("Invalid request of channel/port");return new Promise(((t,n)=>{const r=()=>{this._hostFrame.postMessage({frame1:this._source,frame2:e,type:"request"},"*")},o=setInterval(r,250),i=setTimeout((()=>{clearInterval(o),n(new Error(`Unable to establish ${this._source}-${e} communication channel`))}),1e4),a=this._listeners.add(window,"message",(n=>{const{data:r,ports:s}=n;fm(r,{frame1:this._source,frame2:e,type:"offer"})&&(clearInterval(o),clearTimeout(i),this._listeners.remove(a),t(s[0]))}));r()}))}}function vm({$tag:e,target:t,uri:n}){return{$tag:e,target:t,uri:n}}class ym{
608
+ }(e)&&JSON.stringify(e,Object.keys(t).sort())===JSON.stringify(t,Object.keys(t).sort())}class gm{constructor({hostFrame:e,source:t}){this._hostFrame=e,this._source=t,this._listeners=new Ii}destroy(){this._listeners.removeAll()}async discover(e){let t=!1;if(("guest"===this._source&&"host"===e||"guest"===this._source&&"sidebar"===e||"sidebar"===this._source&&"host"===e||"notebook"===this._source&&"sidebar"===e)&&(t=!0),!t)throw new Error("Invalid request of channel/port");return new Promise(((t,n)=>{const r=()=>{this._hostFrame.postMessage({frame1:this._source,frame2:e,type:"request"},"*")},o=setInterval(r,250),i=setTimeout((()=>{clearInterval(o),n(new Error(`Unable to establish ${this._source}-${e} communication channel`))}),2e4),a=this._listeners.add(window,"message",(n=>{const{data:r,ports:s}=n;fm(r,{frame1:this._source,frame2:e,type:"offer"})&&(clearInterval(o),clearTimeout(i),this._listeners.remove(a),t(s[0]))}));r()}))}}function vm({$tag:e,target:t,uri:n}){return{$tag:e,target:t,uri:n}}class ym{
609
609
  constructor(e,t,n){this._window=e,this._annotationsService=t,this._store=n,this._portFinder=new gm({hostFrame:this._window.parent,source:"sidebar"}),this._listeners=new Ii,this._hostRPC=new mm,this._guestRPC=new mm,this._inFrame=new Set,this._highlightsVisible=!1,this._setupSyncToGuests(),this._setupSyncFromGuests(),this._setupHostEvents()}_setupSyncToGuests(){let e=0;hm(this._store.subscribe,[()=>this._store.allAnnotations(),()=>this._store.frames()],(([t,n],[r])=>{let o=0;const i=new Set,a=[];t.forEach((e=>{Vo(e)||(Yo(e)&&++o,i.add(e.$tag),this._inFrame.has(e.$tag)||a.push(e))}));const s=r.filter((e=>!i.has(e.$tag)));a.length>0&&(this._guestRPC.call("loadAnnotations",a.map(vm)),a.forEach((e=>{this._inFrame.add(e.$tag)}))),s.forEach((e=>{this._guestRPC.call("deleteAnnotation",e.$tag),this._inFrame.delete(e.$tag)})),n.length>0&&n.every((e=>e.isAnnotationFetchComplete))&&(0!==o&&o===e||(this._hostRPC.call("publicAnnotationCountChanged",o),e=o))}))}_setupSyncFromGuests(){
610
610
  this._guestRPC.on("createAnnotation",(e=>{if(!this._store.isLoggedIn())return this._hostRPC.call("openSidebar"),this._store.openSidebarPanel("loginPrompt"),void this._guestRPC.call("deleteAnnotation",e.$tag);this._inFrame.add(e.$tag),e.$highlight||this._hostRPC.call("openSidebar"),this._hostRPC.call("showHighlights"),this._annotationsService.create(e)}));let e={};const t=zi((()=>{this._store.updateAnchorStatus(e),e={}}),10);this._guestRPC.on("syncAnchoringStatus",(({$tag:n,$orphan:r})=>{this._inFrame.add(n),e[n]=r?"orphan":"anchored",t()})),this._guestRPC.on("showAnnotations",(e=>{this._store.selectAnnotations(this._store.findIDsForTags(e)),this._store.selectTab("annotation")})),this._guestRPC.on("focusAnnotations",(e=>{this._store.focusAnnotations(e||[])})),this._guestRPC.on("toggleAnnotationSelection",(e=>{this._store.toggleSelectedAnnotations(this._store.findIDsForTags(e))})),this._guestRPC.on("openSidebar",(()=>{this._hostRPC.call("openSidebar")})),this._guestRPC.on("closeSidebar",(()=>{
611
611
  this._hostRPC.call("closeSidebar")}));this._guestRPC.onConnect((e=>{e.call("setHighlightsVisible",this._highlightsVisible),e.call("getDocumentInfo",((t,n)=>{t?e.destroy():this._store.connectFrame({id:n.frameIdentifier,metadata:n.metadata,uri:n.uri})}))}))}_setupHostEvents(){this._hostRPC.on("sidebarOpened",(()=>{this._store.setSidebarOpened(!0)})),this._hostRPC.on("frameDestroyed",(e=>{const t=this._store.frames().find((t=>t.id===e));t&&this._store.destroyFrame(t)})),this._hostRPC.on("setHighlightsVisible",(e=>{this._highlightsVisible=e,this._guestRPC.call("setHighlightsVisible",e)}))}async connect(){const e=await this._portFinder.discover("host");this._hostRPC.createChannel(e),this._listeners.add(e,"message",(e=>{const{data:t,ports:n}=e;fm(t,{frame1:"guest",frame2:"sidebar",type:"offer"})&&this._guestRPC.createChannel(n[0])}))}notifyHost(e,...t){this._hostRPC.call(e,...t)}focusAnnotations(e){this._store.focusAnnotations(e),this._guestRPC.call("focusAnnotations",e)}scrollToAnnotation(e){
612
- this._guestRPC.call("scrollToAnnotation",e)}destroy(){this._portFinder.destroy(),this._listeners.removeAll()}}function _m(e){return Object.keys(e).reduce(((e,t)=>(e[t]=t,e)),{})}ym.$inject=["$window","annotationsService","store"];const bm={id:"__default__",name:"__DEFAULT__",logo:"data:image/svg+xml;utf8,"+encodeURIComponent(vo)};const wm=["organization","scopes"];class xm{constructor(e,t,n,r,o,i){this._store=e,this._api=t,this._auth=n,this._settings=o,this._toastMessenger=i,this._serviceConfig=F(o),this._reloadSetUp=!1}_mainURI(){var e,t;return null!==(e=null===(t=this._store.mainFrame())||void 0===t?void 0:t.uri)&&void 0!==e?e:null}async _filterGroups(e,t,n,r){if(r){const t=e.find((e=>e.id===r));t&&!t.isScopedToUri&&t.scopes&&t.scopes.enforced&&(e=e.filter((e=>e.id!==r)),this._store.setDirectLinkedGroupFetchFailed(),r=null)}if(t)return e;const o=e.some((e=>"__world__"!==e.id&&e.isScopedToUri));return o?"__world__"===r||"__world__"===n?e:e.filter((e=>"__world__"!==e.id)):e}_setupAutoReload(){
612
+ this._guestRPC.call("scrollToAnnotation",e)}destroy(){this._portFinder.destroy(),this._listeners.removeAll()}}function _m(e){return Object.keys(e).reduce(((e,t)=>(e[t]=t,e)),{})}ym.$inject=["$window","annotationsService","store"];const bm={id:"__default__",name:"__DEFAULT__",logo:"data:image/svg+xml;utf8,"+encodeURIComponent(vo)};const wm=["organization","scopes"];class xm{constructor(e,t,n,r,o,i){this._store=e,this._api=t,this._auth=n,this._settings=o,this._toastMessenger=i,this._serviceConfig=P(o),this._reloadSetUp=!1}_mainURI(){var e,t;return null!==(e=null===(t=this._store.mainFrame())||void 0===t?void 0:t.uri)&&void 0!==e?e:null}async _filterGroups(e,t,n,r){if(r){const t=e.find((e=>e.id===r));t&&!t.isScopedToUri&&t.scopes&&t.scopes.enforced&&(e=e.filter((e=>e.id!==r)),this._store.setDirectLinkedGroupFetchFailed(),r=null)}if(t)return e;const o=e.some((e=>"__world__"!==e.id&&e.isScopedToUri));return o?"__world__"===r||"__world__"===n?e:e.filter((e=>"__world__"!==e.id)):e}_setupAutoReload(){
613
613
  this._reloadSetUp||(this._reloadSetUp=!0,hm(this._store.subscribe,(()=>this._mainURI()),(()=>{this.load()})),hm(this._store.subscribe,[()=>this._store.hasFetchedProfile(),()=>this._store.profile().userid],((e,[t])=>{t&&this.load()})))}_addGroupsToStore(e,t){!function(e){e.forEach((e=>{e.organization&&"object"==typeof e.organization||(e.organization=bm)}))}(e);const n=0===this._store.allGroups().length,r=this._store.getDefault("focusedGroup");this._store.loadGroups(e),n&&(t&&e.some((e=>e.id===t))?this.focus(t):r&&e.some((e=>e.id===r))&&this.focus(r))}_fetchGroup(e){return this._api.group.read({id:e,expand:wm})}async _loadGroupsForUserAndDocument(){var e;const t=()=>function(e,t){const n=t(e);return null!==n?Promise.resolve(n):new Promise((n=>{const r=e.subscribe((()=>{const o=t(e);null!==o&&(r(),n(o))}))}))}(this._store,(()=>this._mainURI()));let n=null;"sidebar"===this._store.route()&&(n=await t()),this._setupAutoReload();const r=this._store.directLinkedAnnotationId();let o=null
614
- ;r&&(o=this._api.annotation.get({id:r}).catch((()=>null)));const i=this._store.directLinkedGroupId();let a=null;i&&(a=this._fetchGroup(i).then((e=>(this._store.clearDirectLinkedGroupFetchFailed(),e))).catch((()=>(this._store.setDirectLinkedGroupFetchFailed(),null))));const s={expand:wm},l=null===(e=this._serviceConfig)||void 0===e?void 0:e.authority;l&&(s.authority=l),n&&(s.document_uri=n);const[c,u,h,d,p]=await Promise.all([this._api.profile.groups.read({expand:wm}),this._api.groups.list(s),this._auth.getAccessToken(),o,a]);p&&!u.some((e=>e.id===p.id))&&u.push(p);let m=null;if(d){m=d.group;const e=c.concat(u).find((e=>e.id===d.group));if(!e)try{const e=await this._fetchGroup(d.group);u.push(e)}catch(e){this._toastMessenger.error("Unable to fetch group for linked annotation")}}const f=null!==h,g=await this._filterGroups(j(c,u,n,this._settings),f,m,i),v=m||i||null;return this._addGroupsToStore(g,v),g}async _loadServiceSpecifiedGroups(e){const t=await this._api.profile.groups.read({expand:wm});let n
614
+ ;r&&(o=this._api.annotation.get({id:r}).catch((()=>null)));const i=this._store.directLinkedGroupId();let a=null;i&&(a=this._fetchGroup(i).then((e=>(this._store.clearDirectLinkedGroupFetchFailed(),e))).catch((()=>(this._store.setDirectLinkedGroupFetchFailed(),null))));const s={expand:wm},l=null===(e=this._serviceConfig)||void 0===e?void 0:e.authority;l&&(s.authority=l),n&&(s.document_uri=n);const[c,u,h,d,p]=await Promise.all([this._api.profile.groups.read({expand:wm}),this._api.groups.list(s),this._auth.getAccessToken(),o,a]);p&&!u.some((e=>e.id===p.id))&&u.push(p);let m=null;if(d){m=d.group;const e=c.concat(u).find((e=>e.id===d.group));if(!e)try{const e=await this._fetchGroup(d.group);u.push(e)}catch(e){this._toastMessenger.error("Unable to fetch group for linked annotation")}}const f=null!==h,g=await this._filterGroups(J(c,u,n,this._settings),f,m,i),v=m||i||null;return this._addGroupsToStore(g,v),g}async _loadServiceSpecifiedGroups(e){const t=await this._api.profile.groups.read({expand:wm});let n
615
615
  ;const r=async e=>{try{return await this._fetchGroup(e)}catch(e){return n=e,null}},o=await Promise.all(e.map((e=>t.find((t=>t.id===e||t.groupid===e))||r(e)))),i=o.filter((e=>null!==e)),a=this._store.directLinkedGroupId();return this._addGroupsToStore(i,a),n&&this._toastMessenger.error(`Unable to fetch groups: ${n.message}`,{autoDismiss:!1}),i}async load(){var e;if(null!==(e=this._serviceConfig)&&void 0!==e&&e.groups){let e=[];try{e=await this._serviceConfig.groups}catch(e){this._toastMessenger.error(`Unable to fetch group configuration: ${e.message}`)}return this._loadServiceSpecifiedGroups(e)}return this._loadGroupsForUserAndDocument()}focus(e){const t=this._store.focusedGroupId();this._store.focusGroup(e);const n=this._store.focusedGroupId();if(t!==n&&null!==t&&n){const e=this._store.newAnnotations().filter((e=>!Vo(e))).map((e=>({...e,group:n})));e.length&&this._store.addAnnotations(e),this._store.setDefault("focusedGroup",n)}}leave(e){return this._api.group.member.delete({pubid:e,userid:"me"})}}
616
616
  xm.$inject=["store","api","auth","session","settings","toastMessenger"];class km{constructor(e,t,n,r){this._api=e,this._store=t,this._streamer=n,this._streamFilter=r,this._searchClient=null}load({groupId:e,uris:t,onError:n,maxResults:r,sortBy:o,sortOrder:i,streamFilterBy:a="uri"}){if(this._store.removeAnnotations(this._store.savedAnnotations()),this._searchClient&&this._searchClient.cancel(),"group"===a)this._streamFilter.resetFilter().addClause("/group","equals",e,!0),this._streamer.setConfig("filter",{filter:this._streamFilter.getFilter()});else t&&t.length>0&&(this._streamFilter.resetFilter().addClause("/uri","one_of",t),this._streamer.setConfig("filter",{filter:this._streamFilter.getFilter()}));const s={incremental:!0,separateReplies:!1,maxResults:r,sortBy:o,sortOrder:i};this._searchClient=new kp(this._api.search,s),this._searchClient.on("resultCount",(e=>{this._store.setAnnotationResultCount(e)})),this._searchClient.on("results",(e=>{e.length&&this._store.addAnnotations(e)})),
617
617
  this._searchClient.on("error",(e=>{"function"==typeof n?n(e):console.error(e)})),this._searchClient.on("end",(()=>{this._searchClient=null,t&&t.length>0&&this._store.frames().forEach((e=>{t.indexOf(e.uri)>=0&&this._store.updateFrameAnnotationFetchStatus(e.uri,!0)})),this._store.annotationFetchFinished()})),this._store.annotationFetchStarted(),this._searchClient.get({group:e,uri:t})}async loadThread(e){let t,n;this._store.clearAnnotations();try{this._store.annotationFetchStarted(),t=await this._api.annotation.get({id:e}),Vo(t)&&(t=await this._api.annotation.get({id:t.references[0]})),n=await this._api.search({references:t.id})}finally{this._store.annotationFetchFinished()}const r=[t,...n.rows];if(this._store.addAnnotations(r),!Vo(t)){const e=t.id;this._streamFilter.addClause("/references","one_of",e,!0).addClause("/id","equals",e,!0),this._streamer.setConfig("filter",{filter:this._streamFilter.getFilter()}),this._streamer.connect()}return r}}km.$inject=["api","store","streamer","streamFilter"];class Sm{
618
618
  constructor(){this._store={}}getItem(e){return e in this._store?this._store[e]:null}setItem(e,t){this._store[e]=t}removeItem(e){delete this._store[e]}}class Cm{constructor(e){let t="hypothesis.testKey";try{this._storage=e.localStorage,e.localStorage.setItem(t,t),e.localStorage.getItem(t),e.localStorage.removeItem(t)}catch(e){this._storage=new Sm}}getItem(e){return this._storage.getItem(e)}getObject(e){const t=this._storage.getItem(e);return t?JSON.parse(t):null}setItem(e,t){this._storage.setItem(e,t)}setObject(e,t){const n=JSON.stringify(t);this._storage.setItem(e,n)}removeItem(e){this._storage.removeItem(e)}}Cm.$inject=["$window"];const Em={annotationPrivacy:"hypothesis.privacy",focusedGroup:"hypothesis.groups.focus"};class Am{constructor(e,t){this._storage=e,this._store=t}init(){Object.keys(Em).forEach((e=>{const t=this._storage.getItem(Em[e]);this._store.setDefault(e,t)})),hm(this._store.subscribe,(()=>this._store.getDefaults()),((e,t)=>{
619
619
  for(let n in e)t[n]!==e[n]&&n in Em&&this._storage.setItem(Em[n],e[n])}))}}Am.$inject=["localStorage","store"];class Tm{constructor(e,t){this._window=e,this._store=t,this._didRegisterPopstateListener=!1}currentRoute(){const e=this._window.location.pathname.slice(1).split("/"),t=new URLSearchParams(this._window.location.search),n={};for(let[e,r]of t)n[e]=r;"client"===e[0]&&e.shift();let r;switch(e[0].replace(/\.html$/,"")){case"a":r="annotation",n.id=e[1]||"";break;case"notebook":r="notebook";break;case"stream":r="stream";break;default:r="sidebar"}return{route:r,params:n}}routeUrl(e,t={}){let n;const r={...t};switch(e){case"annotation":{const e=t.id;delete r.id,n=`/a/${e}`}break;case"notebook":n="/notebook";break;case"stream":n="/stream";break;default:throw new Error(`Cannot generate URL for route "${e}"`)}let o=!1;const i=new URLSearchParams;for(let[e,t]of Object.entries(r))o=!0,i.set(e,t);return o&&(n+="?"+i.toString()),n}sync(){const{route:e,params:t}=this.currentRoute();this._store.changeRoute(e,t),
620
- this._didRegisterPopstateListener||(this._window.addEventListener("popstate",(()=>{this.sync()})),this._didRegisterPopstateListener=!0)}navigate(e,t){this._window.history.pushState({},"",this.routeUrl(e,t)),this.sync()}}Tm.$inject=["$window","store"];class Nm{constructor(e,t){this._apiRoutes=e,this._store=t}async init(){try{const e=await this._apiRoutes.links();this._store.updateLinks(e)}catch(e){console.warn(`Failed to fetch Hypothesis links: ${e.message}`)}}}Nm.$inject=["apiRoutes","store"];class Lm{constructor(e,t,n,r,o){var i,a;this._api=t,this._auth=n,this._store=e,this._toastMessenger=o,this._authority=null!==(i=null===(a=F(r))||void 0===a?void 0:a.authority)&&void 0!==i?i:null,this._lastLoad=null,this._lastLoadTime=null,n.on("oauthTokensChanged",(()=>this.reload()))}load(){return(!this._lastLoad||!this._lastLoadTime||Date.now()-this._lastLoadTime>3e5)&&(this._lastLoadTime=Date.now(),this._lastLoad=rm((()=>{const e=this._authority?{authority:this._authority}:{};return this._api.profile.read(e)
620
+ this._didRegisterPopstateListener||(this._window.addEventListener("popstate",(()=>{this.sync()})),this._didRegisterPopstateListener=!0)}navigate(e,t){this._window.history.pushState({},"",this.routeUrl(e,t)),this.sync()}}Tm.$inject=["$window","store"];class Nm{constructor(e,t){this._apiRoutes=e,this._store=t}async init(){try{const e=await this._apiRoutes.links();this._store.updateLinks(e)}catch(e){console.warn(`Failed to fetch Hypothesis links: ${e.message}`)}}}Nm.$inject=["apiRoutes","store"];class Lm{constructor(e,t,n,r,o){var i,a;this._api=t,this._auth=n,this._store=e,this._toastMessenger=o,this._authority=null!==(i=null===(a=P(r))||void 0===a?void 0:a.authority)&&void 0!==i?i:null,this._lastLoad=null,this._lastLoadTime=null,n.on("oauthTokensChanged",(()=>this.reload()))}load(){return(!this._lastLoad||!this._lastLoadTime||Date.now()-this._lastLoadTime>3e5)&&(this._lastLoadTime=Date.now(),this._lastLoad=rm((()=>{const e=this._authority?{authority:this._authority}:{};return this._api.profile.read(e)
621
621
  })).then((e=>(this.update(e),this._lastLoadTime=Date.now(),e))).catch((e=>{throw this._lastLoadTime=null,e}))),this._lastLoad}async dismissSidebarTutorial(){const e=await this._api.profile.update({},{preferences:{show_sidebar_tutorial:!1}});this.update(e)}update(e){const t=this._store.profile(),n=e.userid!==t.userid;return this._store.updateProfile(e),this._lastLoad=Promise.resolve(e),this._lastLoadTime=Date.now(),n&&(e.userid?Yn({id:e.userid}):Yn(null)),e}async logout(){try{return await this._auth.logout(),this.reload()}catch(e){throw this._toastMessenger.error("Log out failed"),new Error(e)}}reload(){return this._lastLoad=null,this._lastLoadTime=null,this.load()}}Lm.$inject=["store","api","auth","settings","toastMessenger"];class Mm{constructor(){this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,delete:!0}}}addClause(e,t,n,r=!1){return this._filter.clauses.push({field:e,operator:t,value:n,case_sensitive:r}),this}getFilter(){return this._filter}resetFilter(){
622
- return this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,delete:!0}},this}}class Om extends bp{constructor(e){super();const t=[];let n;const r=()=>{for(;t.length>0;){const e=JSON.stringify(t.shift());n.send(e)}};this.close=()=>{n.close(1e3)},this.send=e=>{t.push(e),this.isConnected()&&r()},this.isConnected=()=>n.readyState===WebSocket.OPEN,(()=>{n=new WebSocket(e),n.onopen=e=>{r(),this.emit("open",e)},n.onclose=e=>{if(1e3===e.code||1001===e.code)return void this.emit("close",e);const t=new Error(`WebSocket closed abnormally, code: ${e.code}`);console.warn(t),this.emit("disconnect")},n.onerror=e=>{this.emit("error",e)},n.onmessage=e=>{this.emit("message",e)}})()}}class zm{constructor(e,t,n,r,o){this._auth=t,this._groups=n,this._session=r,this._store=e,this._websocketURL=o.websocketUrl,this.clientId=Z(32),this._socket=null,this._updateImmediately=!0,this._configMessages={},this._reconnectionAttempts=0,this._reconnectSetUp=!1}applyPendingUpdates(){
623
- const e=Object.values(this._store.pendingUpdates());e.length&&this._store.addAnnotations(e);const t=Object.keys(this._store.pendingDeletions()).map((e=>({id:e})));t.length&&this._store.removeAnnotations(t),this._store.clearPendingUpdates()}_handleSocketError(e){P("Error connecting to H push notification service:",e);const t=new URL(this._websocketURL).hostname;-1!==["localhost","127.0.0.1"].indexOf(t)&&P("Check that your H service is configured to allow WebSocket connections from "+window.location.origin)}_handleSocketMessage(e){const t=JSON.parse(e.data);if(t)if("annotation-notification"===t.type){const e=t.payload;switch(t.options.action){case"create":case"update":case"past":this._store.receiveRealTimeUpdates({updatedAnnotations:e});break;case"delete":this._store.receiveRealTimeUpdates({deletedAnnotations:e})}this._updateImmediately&&this.applyPendingUpdates()}else if("session-change"===t.type)this._session.update(t.model),this._groups.load();else if("whoyouare"===t.type){
624
- const e=this._store.profile().userid;t.userid!==e&&console.warn('WebSocket user ID "%s" does not match logged-in ID "%s"',t.userid,e)}else P("Received unsupported notification",t.type)}_sendClientConfig(e){Object.keys(this._configMessages).forEach((t=>{this._configMessages[t]&&e.send(this._configMessages[t])}))}setConfig(e,t){var n;this._configMessages[e]=t,null!==(n=this._socket)&&void 0!==n&&n.isConnected()&&this._socket.send(t)}async _reconnect(){var e;if(!this._websocketURL)return;let t,n;null===(e=this._socket)||void 0===e||e.close();try{t=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(t){const e=new URL(this._websocketURL);e.searchParams.set("access_token",t),n=e.toString()}else n=this._websocketURL;const r=new Om(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
625
- ;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),r.on("error",(e=>this._handleSocketError(e))),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={}){var t;this._updateImmediately=null===(t=e.applyUpdatesImmediately)||void 0===t||t,this._reconnectSetUp||(this._reconnectSetUp=!0,hm(this._store.subscribe,(()=>this._store.profile().userid),(()=>{this._reconnect()}))),this._socket||await this._reconnect()}}zm.$inject=["store","auth","groups","session","settings"];class Im{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject("hypothesis.user.tags.list")||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${B(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){
626
- const t=this._storage.getObject("hypothesis.user.tags.map")||{};e.forEach((e=>{t[e]?(t[e].count+=1,t[e].updated=Date.now()):t[e]={text:e,count:1,updated:Date.now()}})),this._storage.setObject("hypothesis.user.tags.map",t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject("hypothesis.user.tags.list",n)}}Im.$inject=["localStorage"];class Rm{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}Rm.$inject=["store"];class Pm{constructor(e){this._store=e}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r=""}={}){if(this._store.hasToastMessage(e,t))return;const o=Z(10),i={type:e,id:o,message:t,moreInfoURL:r};this._store.addToastMessage({isDismissed:!1,...i}),
622
+ return this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,delete:!0}},this}}class Om extends bp{constructor(e){super();const t=[];let n;const r=()=>{for(;t.length>0;){const e=JSON.stringify(t.shift());n.send(e)}};this.close=()=>{n.close(1e3)},this.send=e=>{t.push(e),this.isConnected()&&r()},this.isConnected=()=>n.readyState===WebSocket.OPEN,(()=>{n=new WebSocket(e),n.onopen=e=>{r(),this.emit("open",e)},n.onclose=e=>{if(1e3===e.code||1001===e.code)return void this.emit("close",e);const t=new Error(`WebSocket closed abnormally, code: ${e.code}`);console.warn(t),this.emit("disconnect")},n.onerror=e=>{this.emit("error",e)},n.onmessage=e=>{this.emit("message",e)}})()}}class zm{constructor(e,t,n,r,o){this._auth=t,this._groups=n,this._session=r,this._store=e,this._websocketURL=o.websocketUrl,this.clientId=q(32),this._socket=null,this._updateImmediately=!0,this._configMessages={},this._reconnectionAttempts=0,this._reconnectSetUp=!1}applyPendingUpdates(){
623
+ const e=Object.values(this._store.pendingUpdates());e.length&&this._store.addAnnotations(e);const t=Object.keys(this._store.pendingDeletions()).map((e=>({id:e})));t.length&&this._store.removeAnnotations(t),this._store.clearPendingUpdates()}_handleSocketError(e){K("Error connecting to H push notification service:",e);const t=new URL(this._websocketURL).hostname;-1!==["localhost","127.0.0.1"].indexOf(t)&&K("Check that your H service is configured to allow WebSocket connections from "+window.location.origin)}_handleSocketMessage(e){const t=JSON.parse(e.data);if(t)if("annotation-notification"===t.type){const e=t.payload;switch(t.options.action){case"create":case"update":case"past":this._store.receiveRealTimeUpdates({updatedAnnotations:e});break;case"delete":this._store.receiveRealTimeUpdates({deletedAnnotations:e})}this._updateImmediately&&this.applyPendingUpdates()}else if("session-change"===t.type)this._session.update(t.model),this._groups.load();else if("whoyouare"===t.type){
624
+ const e=this._store.profile().userid;t.userid!==e&&console.warn('WebSocket user ID "%s" does not match logged-in ID "%s"',t.userid,e)}else K("Received unsupported notification",t.type)}_sendClientConfig(e){Object.keys(this._configMessages).forEach((t=>{this._configMessages[t]&&e.send(this._configMessages[t])}))}setConfig(e,t){var n;this._configMessages[e]=t,null!==(n=this._socket)&&void 0!==n&&n.isConnected()&&this._socket.send(t)}async _reconnect(){var e;if(!this._websocketURL)return;let t,n;null===(e=this._socket)||void 0===e||e.close();try{t=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(t){const e=new URL(this._websocketURL);e.searchParams.set("access_token",t),n=e.toString()}else n=this._websocketURL;const r=new Om(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
625
+ ;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),r.on("error",(e=>this._handleSocketError(e))),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={}){var t;this._updateImmediately=null===(t=e.applyUpdatesImmediately)||void 0===t||t,this._reconnectSetUp||(this._reconnectSetUp=!0,hm(this._store.subscribe,(()=>this._store.profile().userid),(()=>{this._reconnect()}))),this._socket||await this._reconnect()}}zm.$inject=["store","auth","groups","session","settings"];class Im{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject("hypothesis.user.tags.list")||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${Z(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){
626
+ const t=this._storage.getObject("hypothesis.user.tags.map")||{};e.forEach((e=>{t[e]?(t[e].count+=1,t[e].updated=Date.now()):t[e]={text:e,count:1,updated:Date.now()}})),this._storage.setObject("hypothesis.user.tags.map",t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject("hypothesis.user.tags.list",n)}}Im.$inject=["localStorage"];class Rm{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}Rm.$inject=["store"];class Pm{constructor(e){this._store=e}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r=""}={}){if(this._store.hasToastMessage(e,t))return;const o=q(10),i={type:e,id:o,message:t,moreInfoURL:r};this._store.addToastMessage({isDismissed:!1,...i}),
627
627
  n&&setTimeout((()=>{this.dismiss(o)}),5e3)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}function Dm(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Fm(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Bm(Object(n),!0).forEach((function(t){Dm(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bm(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function jm(e){
628
628
  return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}Pm.$inject=["store"];var Hm="function"==typeof Symbol&&Symbol.observable||"@@observable",Um=function(){return Math.random().toString(36).substring(7).split("").join(".")},qm={INIT:"@@redux/INIT"+Um(),REPLACE:"@@redux/REPLACE"+Um(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Um()}};function $m(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Gm(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(jm(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(jm(1));return n(Gm)(e,t)}if("function"!=typeof e)throw new Error(jm(2));var o=e,i=t,a=[],s=a,l=!1;function c(){s===a&&(s=a.slice())}
629
629
  function u(){if(l)throw new Error(jm(3));return i}function h(e){if("function"!=typeof e)throw new Error(jm(4));if(l)throw new Error(jm(5));var t=!0;return c(),s.push(e),function(){if(t){if(l)throw new Error(jm(6));t=!1,c();var n=s.indexOf(e);s.splice(n,1),a=null}}}function d(e){if(!$m(e))throw new Error(jm(7));if(void 0===e.type)throw new Error(jm(8));if(l)throw new Error(jm(9));try{l=!0,i=o(i,e)}finally{l=!1}for(var t=a=s,n=0;n<t.length;n++){(0,t[n])()}return e}function p(e){if("function"!=typeof e)throw new Error(jm(10));o=e,d({type:qm.REPLACE})}function m(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(jm(11));function n(){e.next&&e.next(u())}return n(),{unsubscribe:t(n)}}})[Hm]=function(){return this},e}return d({type:qm.INIT}),(r={dispatch:d,subscribe:h,getState:u,replaceReducer:p})[Hm]=m,r}function Vm(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var o=t[r];"function"==typeof e[o]&&(n[o]=e[o])}var i,a=Object.keys(n);try{!function(e){
@@ -656,8 +656,9 @@ const t=["Newest","Oldest"];return"note"!==e&&t.push("Location"),t}));var Dg=Qm(
656
656
  activePanelName:t.panelName}},CLOSE_SIDEBAR_PANEL:function(e,t){let n=e.activePanelName;return t.panelName===n&&(n=null),{activePanelName:n}},TOGGLE_SIDEBAR_PANEL:function(e,t){let n;const r=e.activePanelName===t.panelName,o=void 0!==t.panelState?t.panelState:!r;return n=o?t.panelName:r&&!o?null:e.activePanelName,{activePanelName:n}}},Fg=_m(Bg);var jg=Qm({activePanelName:null},{namespace:"sidebarPanels",reducers:Bg,actionCreators:{openSidebarPanel:function(e){return{type:Fg.OPEN_SIDEBAR_PANEL,panelName:e}},closeSidebarPanel:function(e){return{type:Fg.CLOSE_SIDEBAR_PANEL,panelName:e}},toggleSidebarPanel:function(e,t){return{type:Fg.TOGGLE_SIDEBAR_PANEL,panelName:e,panelState:t}}},selectors:{isSidebarPanelOpen:function(e,t){return e.activePanelName===t}}});const Hg={ADD_MESSAGE:function(e,t){return{messages:e.messages.concat({...t.message})}},REMOVE_MESSAGE:function(e,t){return{messages:e.messages.filter((e=>e.id!==t.id))}},UPDATE_MESSAGE:function(e,t){return{
657
657
  messages:e.messages.map((e=>e.id&&e.id===t.message.id?{...t.message}:e))}}},Ug=_m(Hg);var qg=Qm({messages:[]},{namespace:"toastMessages",reducers:Hg,actionCreators:{addToastMessage:function(e){return{type:Ug.ADD_MESSAGE,message:e}},removeToastMessage:function(e){return{type:Ug.REMOVE_MESSAGE,id:e}},updateToastMessage:function(e){return{type:Ug.UPDATE_MESSAGE,message:e}}},selectors:{getToastMessage:function(e,t){return e.messages.find((e=>e.id===t))},getToastMessages:function(e){return e.messages},hasToastMessage:function(e,t,n){return e.messages.some((e=>e.type===t&&e.message===n))}}});const $g={SET_SIDEBAR_OPENED:(e,t)=>!0===t.opened?{sidebarHasOpened:!0}:{}},Gg=_m($g);var Vg=Qm({sidebarHasOpened:!1},{namespace:"viewer",reducers:$g,actionCreators:{setSidebarOpened:function(e){return{type:Gg.SET_SIDEBAR_OPENED,opened:e}}},selectors:{hasSidebarOpened:function(e){return e.sidebarHasOpened}}});function Wg(e){return Jm([rf,Lf,zf,Pf,$f,Jf,rg,_g,gg,kg,ff,Dg,sg,jg,qg,Vg],[e],[ef])}Wg.$inject=["settings"];class Yg{
658
658
  constructor(){this._providers=new Map,this._instances=new Map,this._constructing=new Set}get(e){if(this._instances.has(e))return this._instances.get(e);const t=this._providers.get(e);if(!t)throw new Error(`"${e}" is not registered`);if("value"in t)return this._instances.set(e,t.value),t.value;if(this._constructing.has(e))throw new Error(`Encountered a circular dependency when constructing "${e}"`);this._constructing.add(e);try{const n=[],r="class"in t&&t.class.$inject||"factory"in t&&t.factory.$inject||[];for(const t of r)try{n.push(this.get(t))}catch(n){const r=new Error(`Failed to construct dependency "${t}" of "${e}": ${n.message}`);throw r.cause=n,r}let o;if(t.class)o=new t.class(...n);else{o=(0,t.factory)(...n)}return this._instances.set(e,o),o}finally{this._constructing.delete(e)}}register(e,t){if("function"==typeof t)t={class:t};else if(!function(e){return"object"==typeof e&&null!==e&&("value"in e||"function"==typeof e.class||"function"==typeof e.factory)
659
- }(t))throw new Error(`Invalid provider for "${e}"`);return this._providers.set(e,t),this}run(e){const t="Injector.run";this.register(t,{factory:e});try{return this.get(t)}finally{this._instances.delete(t),this._providers.delete(t)}}}const Kg=function(t){for(var n={},r=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<r.length;o++){var i=void 0;try{i=JSON.parse(r[o].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),i={}}e(n,i)}return n}(document);function Xg(e,t){e.setClientId(t.clientId)}function Zg(e,t,n){e.load(),t.load(),n.sync()}function Jg(e,t,n,r){e.init(),t.init(),n.init(),r.init()}function Qg(e,t){"sidebar"===t.route()&&e.connect()}Kg.sentry&&function(e){const t=function(){try{const e=document.currentScript;return new URL(e.src).origin}catch(e){return null}}(),n=t?[t]:void 0;Gn({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.949.0",beforeSend:(e,t)=>{
660
- if(Wn>=5)return P("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Wn;try{const n=t&&t.originalException;n instanceof Event&&Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted})}catch(e){}return e}});try{jt("host_config",G(window.location.href))}catch(e){}jt("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Vn(((e,t)=>{Ft(e,{tags:{context:t}})}))}(Kg.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;if("A"===t.tagName){const e=t;"_blank"===e.target&&(e.rel="noopener")}}))}(document.body),function(e=n){let t=!1;try{document.createElement("div").dir="auto"}catch(e){t=!0}if(t){const t=e.vnode;e.vnode=e=>{"string"==typeof e.type&&"dir"in e.props&&"auto"===e.props.dir&&(e.props.dir=""),t&&t(e)}}}(),Xg.$inject=["api","streamer"],Zg.$inject=["groups","session","router"],Jg.$inject=["autosaveService","features","persistedDefaults","serviceURL"],
661
- Qg.$inject=["frameSync","store"],function(e,{reset:t=!1}={}){t&&Pr.clear();for(let[t,n]of Object.entries(e))Pr.set(t,n)}(yo);const ev=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",q)}(),async function(e,t=window){const n=K(window),r=n.requestConfigFromFrame;if(!r)return ee(e,n);if("string"==typeof r)return await Q(e,t);if("number"==typeof r.ancestorLevel&&"string"==typeof r.origin){const o=function(e,t=window){let n=t;for(let t=0;t<e;t++){if(n===n.top)throw new Error("The target parent frame has exceeded the ancestor tree. Try reducing the `requestConfigFromFrame.ancestorLevel` value in the `hypothesisConfig`");n=n.parent}return n}(r.ancestorLevel,t);return{...await te(e,o,r.origin),...n.group?{group:n.group}:{}}}throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified")}(Kg).then((e=>{!function(e,t){const n=new Yg
662
- ;n.register("annotationsService",Wp).register("api",Jp).register("apiRoutes",im).register("auth",lm).register("autosaveService",cm).register("features",dm).register("frameSync",ym).register("groups",xm).register("loadAnnotationsService",km).register("localStorage",Cm).register("persistedDefaults",Am).register("router",Tm).register("serviceURL",Nm).register("session",Lm).register("streamer",zm).register("streamFilter",Mm).register("tags",Im).register("threadsService",Rm).register("toastMessenger",Pm).register("store",{factory:Wg}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(Jg),n.run(Xg),n.run(Zg),n.run(U),n.run(Qg),I(Rr(Co.Provider,{value:n,children:Rr(Gp,{})}),t)}(e,ev)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),I(Rr(Vp,{error:e}),t)}(e,ev)));
659
+ }(t))throw new Error(`Invalid provider for "${e}"`);return this._providers.set(e,t),this}run(e){const t="Injector.run";this.register(t,{factory:e});try{return this.get(t)}finally{this._instances.delete(t),this._providers.delete(t)}}}const Kg=function(t){for(var n={},r=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<r.length;o++){var i=void 0;try{i=JSON.parse(r[o].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),i={}}e(n,i)}return n}(document),Xg=function(e){const{version:t,origin:n}=R(e.location.href);return"1.953.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.953.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 Zg(e,t){e.setClientId(t.clientId)}
660
+ function Jg(e,t,n){e.load(),t.load(),n.sync()}function Qg(e,t,n,r){e.init(),t.init(),n.init(),r.init()}function ev(e,t){"sidebar"===t.route()&&e.connect()}Kg.sentry&&Xg&&function(e){const t=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;Gn({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.953.0",beforeSend:(e,t)=>{if(Wn>=5)return K("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Wn;try{const n=t&&t.originalException;n instanceof Event&&Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted})}catch(e){}return e}});try{jt("host_config",R(window.location.href))}catch(e){}jt("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Vn(((e,t)=>{Ft(e,{tags:{context:t}})}))}(Kg.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target
661
+ ;if("A"===t.tagName){const e=t;"_blank"===e.target&&(e.rel="noopener")}}))}(document.body),function(e=n){let t=!1;try{document.createElement("div").dir="auto"}catch(e){t=!0}if(t){const t=e.vnode;e.vnode=e=>{"string"==typeof e.type&&"dir"in e.props&&"auto"===e.props.dir&&(e.props.dir=""),t&&t(e)}}}(),Zg.$inject=["api","streamer"],Jg.$inject=["groups","session","router"],Qg.$inject=["autosaveService","features","persistedDefaults","serviceURL"],ev.$inject=["frameSync","store"],function(e,{reset:t=!1}={}){t&&Pr.clear();for(let[t,n]of Object.entries(e))Pr.set(t,n)}(yo);const tv=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",te)}(),async function(e,t=window){const n=H(window),r=n.requestConfigFromFrame;if(!r)return V(e,n);if("string"==typeof r)return await G(e,t);if("number"==typeof r.ancestorLevel&&"string"==typeof r.origin){const o=function(e,t=window){let n=t;for(let t=0;t<e;t++){
662
+ if(n===n.top)throw new Error("The target parent frame has exceeded the ancestor tree. Try reducing the `requestConfigFromFrame.ancestorLevel` value in the `hypothesisConfig`");n=n.parent}return n}(r.ancestorLevel,t);return{...await W(e,o,r.origin),...n.group?{group:n.group}:{}}}throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified")}(Kg).then((e=>{!function(e,t){const n=new Yg;n.register("annotationsService",Wp).register("api",Jp).register("apiRoutes",im).register("auth",lm).register("autosaveService",cm).register("features",dm).register("frameSync",ym).register("groups",xm).register("loadAnnotationsService",km).register("localStorage",Cm).register("persistedDefaults",Am).register("router",Tm).register("serviceURL",Nm).register("session",Lm).register("streamer",zm).register("streamFilter",Mm).register("tags",Im).register("threadsService",Rm).register("toastMessenger",Pm).register("store",{factory:Wg}),n.register("$window",{value:window
663
+ }).register("settings",{value:e}),n.run(Qg),n.run(Zg),n.run(Jg),n.run(ee),n.run(ev),I(Rr(Co.Provider,{value:n,children:Rr(Gp,{})}),t)}(e,tv)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),I(Rr(Vp,{error:e}),t)}(e,tv)));
663
664
  //# sourceMappingURL=sidebar.bundle.js.map