hypothesis 1.970.0 → 1.974.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.
@@ -49,44 +49,44 @@ function Zt(e,t){return""+Xt(e)+e.projectId+"/"+t+"/"}function Jt(e){return t={s
49
49
  tn.push(e.name),Be.log("Integration installed: "+e.name))}(e)})),$e(t,"initialized",!0),t}var on="Not capturing exception because it's already been captured.",an=function(){function e(e,t){this._integrations={},this._numProcessing=0,this._backend=new e(t),this._options=t,t.dsn&&(this._dsn=Oe(t.dsn))}return e.prototype.captureException=function(e,t,n){var r=this;if(!St(e)){var o=t&&t.event_id;return this._process(this._getBackend().eventFromException(e,t).then((function(e){return r._captureEvent(e,t,n)})).then((function(e){o=e}))),o}Be.log(on)},e.prototype.captureMessage=function(e,t,n,r){var o=this,i=n&&n.event_id,a=be(e)?this._getBackend().eventFromMessage(String(e),t,n):this._getBackend().eventFromException(e,n);return this._process(a.then((function(e){return o._captureEvent(e,n,r)})).then((function(e){i=e}))),i},e.prototype.captureEvent=function(e,t,n){if(!(t&&t.originalException&&St(t.originalException))){var r=t&&t.event_id;return this._process(this._captureEvent(e,t,n).then((function(e){r=e}))),r}
50
50
  Be.log(on)},e.prototype.captureSession=function(e){this._isEnabled()?"string"!=typeof e.release?ue()&&Be.warn("Discarded session because of missing or non-string release"):(this._sendSession(e),e.update({init:!1})):ue()&&Be.warn("SDK not enabled, will not capture session.")},e.prototype.getDsn=function(){return this._dsn},e.prototype.getOptions=function(){return this._options},e.prototype.getTransport=function(){return this._getBackend().getTransport()},e.prototype.flush=function(e){var t=this;return this._isClientDoneProcessing(e).then((function(n){return t.getTransport().close(e).then((function(e){return n&&e}))}))},e.prototype.close=function(e){var t=this;return this.flush(e).then((function(e){return t.getOptions().enabled=!1,e}))},e.prototype.setupIntegrations=function(){this._isEnabled()&&!this._integrations.initialized&&(this._integrations=rn(this._options))},e.prototype.getIntegration=function(e){try{return this._integrations[e.id]||null}catch(t){
51
51
  return Be.warn("Cannot retrieve integration "+e.id+" from the current Client"),null}},e.prototype._updateSessionFromEvent=function(e,t){var n,r,o=!1,i=!1,a=t.exception&&t.exception.values;if(a){i=!0;try{for(var s=ae(a),l=s.next();!l.done;l=s.next()){var c=l.value.mechanism;if(c&&!1===c.handled){o=!0;break}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}var u="ok"===e.status;(u&&0===e.errors||u&&o)&&(e.update(ie(ie({},o&&{status:"crashed"}),{errors:e.errors||Number(i||o)})),this.captureSession(e))},e.prototype._sendSession=function(e){this._getBackend().sendSession(e)},e.prototype._isClientDoneProcessing=function(e){var t=this;return new Et((function(n){var r=0,o=setInterval((function(){0==t._numProcessing?(clearInterval(o),n(!0)):(r+=1,e&&r>=e&&(clearInterval(o),n(!1)))}),1)}))},e.prototype._getBackend=function(){return this._backend},e.prototype._isEnabled=function(){return!1!==this.getOptions().enabled&&void 0!==this._dsn},
52
- e.prototype._prepareEvent=function(e,t,n){var r=this,o=this.getOptions().normalizeDepth,i=void 0===o?3:o,a=ie(ie({},e),{event_id:e.event_id||(n&&n.event_id?n.event_id:yt()),timestamp:e.timestamp||Ot()});this._applyClientOptions(a),this._applyIntegrationsMetadata(a);var s=t;n&&n.captureContext&&(s=Rt.clone(s).update(n.captureContext));var l=Ct(a);return s&&(l=s.applyToEvent(a,n)),l.then((function(e){return"number"==typeof i&&i>0?r._normalizeEvent(e,i):e}))},e.prototype._normalizeEvent=function(e,t){if(!e)return null;var n=ie(ie(ie(ie(ie({},e),e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map((function(e){return ie(ie({},e),e.data&&{data:Je(e.data,t)})}))}),e.user&&{user:Je(e.user,t)}),e.contexts&&{contexts:Je(e.contexts,t)}),e.extra&&{extra:Je(e.extra,t)});e.contexts&&e.contexts.trace&&(n.contexts.trace=e.contexts.trace);var r=this.getOptions()._experiments;return(void 0===r?{}:r).ensureNoCircularStructures?Je(n):n},e.prototype._applyClientOptions=function(e){
52
+ e.prototype._prepareEvent=function(e,t,n){var r=this,o=this.getOptions().normalizeDepth,i=void 0===o?3:o,a=ie(ie({},e),{event_id:e.event_id||(n&&n.event_id?n.event_id:yt()),timestamp:e.timestamp||Ot()});this._applyClientOptions(a),this._applyIntegrationsMetadata(a);var s=t;n&&n.captureContext&&(s=Rt.clone(s).update(n.captureContext));var l=Ct(a);return s&&(l=s.applyToEvent(a,n)),l.then((function(e){return"number"==typeof i&&i>0?r._normalizeEvent(e,i):e}))},e.prototype._normalizeEvent=function(e,t){if(!e)return null;var n=ie(ie(ie(ie(ie({},e),e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map((function(e){return ie(ie({},e),e.data&&{data:Je(e.data,t)})}))}),e.user&&{user:Je(e.user,t)}),e.contexts&&{contexts:Je(e.contexts,t)}),e.extra&&{extra:Je(e.extra,t)});return e.contexts&&e.contexts.trace&&(n.contexts.trace=e.contexts.trace),e.sdkProcessingMetadata=ie(ie({},e.sdkProcessingMetadata),{baseClientNormalized:!0}),n},e.prototype._applyClientOptions=function(e){
53
53
  var t=this.getOptions(),n=t.environment,r=t.release,o=t.dist,i=t.maxValueLength,a=void 0===i?250:i;"environment"in e||(e.environment="environment"in t?n:"production"),void 0===e.release&&void 0!==r&&(e.release=r),void 0===e.dist&&void 0!==o&&(e.dist=o),e.message&&(e.message=je(e.message,a));var s=e.exception&&e.exception.values&&e.exception.values[0];s&&s.value&&(s.value=je(s.value,a));var l=e.request;l&&l.url&&(l.url=je(l.url,a))},e.prototype._applyIntegrationsMetadata=function(e){var t=Object.keys(this._integrations);t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=le(e.sdk.integrations||[],t))},e.prototype._sendEvent=function(e){this._getBackend().sendEvent(e)},e.prototype._captureEvent=function(e,t,n){return this._processEvent(e,t,n).then((function(e){return e.event_id}),(function(e){Be.error(e)}))},e.prototype._processEvent=function(e,t,n){var r=this,o=this.getOptions(),i=o.beforeSend,a=o.sampleRate,s=this.getTransport();function l(e,t){s.recordLostEvent&&s.recordLostEvent(e,t)}
54
54
  if(!this._isEnabled())return At(new Ne("SDK not enabled, will not capture event."));var c="transaction"===e.type;return!c&&"number"==typeof a&&Math.random()>a?(l("sample_rate","event"),At(new Ne("Discarding event because it's not included in the random sample (sampling rate = "+a+")"))):this._prepareEvent(e,n,t).then((function(n){if(null===n)throw l("event_processor",e.type||"event"),new Ne("An event processor returned null, will not send event.");return t&&t.data&&!0===t.data.__sentry__||c||!i?n:function(e){var t="`beforeSend` method has to return `null` or a valid event.";if(Se(e))return e.then((function(e){if(!we(e)&&null!==e)throw new Ne(t);return e}),(function(e){throw new Ne("beforeSend rejected with "+e)}));if(!we(e)&&null!==e)throw new Ne(t);return e}(i(n,t))})).then((function(t){if(null===t)throw l("before_send",e.type||"event"),new Ne("`beforeSend` returned `null`, will not send event.");var o=n&&n.getSession&&n.getSession();return!c&&o&&r._updateSessionFromEvent(o,t),r._sendEvent(t),t
55
55
  })).then(null,(function(e){if(e instanceof Ne)throw e;throw r.captureException(e,{data:{__sentry__:!0},originalException:e}),new Ne("Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: "+e)}))},e.prototype._process=function(e){var t=this;this._numProcessing+=1,e.then((function(e){return t._numProcessing-=1,e}),(function(e){return t._numProcessing-=1,e}))},e}();var sn=function(){function e(){}return e.prototype.sendEvent=function(e){return Ct({reason:"NoopTransport: Event has been skipped because no Dsn is configured.",status:"skipped"})},e.prototype.close=function(e){return Ct(!0)},e}(),ln=function(){function e(e){this._options=e,this._options.dsn||Be.warn("No DSN provided, backend will not do anything."),this._transport=this._setupTransport()}return e.prototype.eventFromException=function(e,t){throw new Ne("Backend has to implement `eventFromException` method")},e.prototype.eventFromMessage=function(e,t,n){
56
- throw new Ne("Backend has to implement `eventFromMessage` method")},e.prototype.sendEvent=function(e){this._transport.sendEvent(e).then(null,(function(e){ue()&&Be.error("Error while sending event: "+e)}))},e.prototype.sendSession=function(e){this._transport.sendSession?this._transport.sendSession(e).then(null,(function(e){ue()&&Be.error("Error while sending session: "+e)})):ue()&&Be.warn("Dropping session because custom transport doesn't implement sendSession")},e.prototype.getTransport=function(){return this._transport},e.prototype._setupTransport=function(){return new sn},e}();function cn(e){if(e.metadata&&e.metadata.sdk){var t=e.metadata.sdk;return{name:t.name,version:t.version}}}function un(e,t){return t?(e.sdk=e.sdk||{},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=le(e.sdk.integrations||[],t.integrations||[]),e.sdk.packages=le(e.sdk.packages||[],t.packages||[]),e):e}var hn,dn=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){
57
- hn=Function.prototype.toString,Function.prototype.toString=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ve(this)||this;return hn.apply(n,e)}},e.id="FunctionToString",e}(),pn=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/],mn=function(){function e(t){void 0===t&&(t={}),this._options=t,this.name=e.id}return e.prototype.setupOnce=function(){Dt((function(t){var n=Ut();if(!n)return t;var r=n.getIntegration(e);if(r){var o=n.getClient(),i=o?o.getOptions():{},a="function"==typeof r._mergeOptions?r._mergeOptions(i):{};return"function"!=typeof r._shouldDropEvent?t:r._shouldDropEvent(t,a)?null:t}return t}))},e.prototype._shouldDropEvent=function(e,t){return this._isSentryError(e,t)?(ue()&&Be.warn("Event dropped due to being internal Sentry Error.\nEvent: "+wt(e)),!0):this._isIgnoredError(e,t)?(ue()&&Be.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: "+wt(e)),
58
- !0):this._isDeniedUrl(e,t)?(ue()&&Be.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: "+wt(e)+".\nUrl: "+this._getEventFilterUrl(e)),!0):!this._isAllowedUrl(e,t)&&(ue()&&Be.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: "+wt(e)+".\nUrl: "+this._getEventFilterUrl(e)),!0)},e.prototype._isSentryError=function(e,t){if(!t.ignoreInternal)return!1;try{return"SentryError"===e.exception.values[0].type}catch(e){}return!1},e.prototype._isIgnoredError=function(e,t){return!(!t.ignoreErrors||!t.ignoreErrors.length)&&this._getPossibleEventMessages(e).some((function(e){return t.ignoreErrors.some((function(t){return Ue(e,t)}))}))},e.prototype._isDeniedUrl=function(e,t){if(!t.denyUrls||!t.denyUrls.length)return!1;var n=this._getEventFilterUrl(e);return!!n&&t.denyUrls.some((function(e){return Ue(n,e)}))},e.prototype._isAllowedUrl=function(e,t){if(!t.allowUrls||!t.allowUrls.length)return!0;var n=this._getEventFilterUrl(e);return!n||t.allowUrls.some((function(e){return Ue(n,e)}))
59
- },e.prototype._mergeOptions=function(e){return void 0===e&&(e={}),{allowUrls:le(this._options.whitelistUrls||[],this._options.allowUrls||[],e.whitelistUrls||[],e.allowUrls||[]),denyUrls:le(this._options.blacklistUrls||[],this._options.denyUrls||[],e.blacklistUrls||[],e.denyUrls||[]),ignoreErrors:le(this._options.ignoreErrors||[],e.ignoreErrors||[],pn),ignoreInternal:void 0===this._options.ignoreInternal||this._options.ignoreInternal}},e.prototype._getPossibleEventMessages=function(e){if(e.message)return[e.message];if(e.exception)try{var t=e.exception.values&&e.exception.values[0]||{},n=t.type,r=void 0===n?"":n,o=t.value,i=void 0===o?"":o;return[""+i,r+": "+i]}catch(t){return ue()&&Be.error("Cannot extract message for event "+wt(e)),[]}return[]},e.prototype._getLastValidUrl=function(e){void 0===e&&(e=[]);for(var t=e.length-1;t>=0;t--){var n=e[t];if(n&&"<anonymous>"!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null},e.prototype._getEventFilterUrl=function(e){try{
60
- if(e.stacktrace)return this._getLastValidUrl(e.stacktrace.frames);var t;try{t=e.exception.values[0].stacktrace.frames}catch(e){}return t?this._getLastValidUrl(t):null}catch(t){return ue()&&Be.error("Cannot extract url for event "+wt(e)),null}},e.id="InboundFilters",e}(),fn=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,gn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,vn=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,yn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_n=/\((\S*)(?::(\d+))(?::(\d+))\)/,bn=/Minified React error #\d+;/i;function wn(e){var t=null,n=0;e&&("number"==typeof e.framesToPop?n=e.framesToPop:bn.test(e.message)&&(n=1));try{if(t=function(e){if(!e||!e.stacktrace)return null
56
+ throw new Ne("Backend has to implement `eventFromMessage` method")},e.prototype.sendEvent=function(e){this._transport.sendEvent(e).then(null,(function(e){ue()&&Be.error("Error while sending event: "+e)}))},e.prototype.sendSession=function(e){this._transport.sendSession?this._transport.sendSession(e).then(null,(function(e){ue()&&Be.error("Error while sending session: "+e)})):ue()&&Be.warn("Dropping session because custom transport doesn't implement sendSession")},e.prototype.getTransport=function(){return this._transport},e.prototype._setupTransport=function(){return new sn},e}();function cn(e){if(e.metadata&&e.metadata.sdk){var t=e.metadata.sdk;return{name:t.name,version:t.version}}}function un(e,t){var n,r=cn(t),o=e.type||"event",i="transaction"===o||!!t.tunnel,a=(e.sdkProcessingMetadata||{}).transactionSampling||{},s=a.method,l=a.rate;!function(e,t){t&&(e.sdk=e.sdk||{},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=le(e.sdk.integrations||[],t.integrations||[]),
57
+ e.sdk.packages=le(e.sdk.packages||[],t.packages||[]))}(e,t.metadata.sdk),e.tags=e.tags||{},e.extra=e.extra||{},e.sdkProcessingMetadata&&e.sdkProcessingMetadata.baseClientNormalized||(e.tags.skippedNormalization=!0),delete e.sdkProcessingMetadata;try{n=JSON.stringify(e)}catch(t){e.tags.JSONStringifyError=!0,e.extra.JSONStringifyError=t;try{n=JSON.stringify(Je(e))}catch(e){var c=e;n=JSON.stringify({message:"JSON.stringify error after renormalization",extra:{message:c.message,stack:c.stack}})}}var u={body:n,type:o,url:i?en(t.dsn,t.tunnel):Qt(t.dsn)};if(i){var h=JSON.stringify(ie(ie({event_id:e.event_id,sent_at:(new Date).toISOString()},r&&{sdk:r}),!!t.tunnel&&{dsn:Me(t.dsn)}))+"\n"+JSON.stringify({type:o,sample_rates:[{id:s,rate:l}]})+"\n"+u.body;u.body=h}return u}var hn,dn=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){hn=Function.prototype.toString,Function.prototype.toString=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ve(this)||this
58
+ ;return hn.apply(n,e)}},e.id="FunctionToString",e}(),pn=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/],mn=function(){function e(t){void 0===t&&(t={}),this._options=t,this.name=e.id}return e.prototype.setupOnce=function(){Dt((function(t){var n=Ut();if(!n)return t;var r=n.getIntegration(e);if(r){var o=n.getClient(),i=o?o.getOptions():{},a="function"==typeof r._mergeOptions?r._mergeOptions(i):{};return"function"!=typeof r._shouldDropEvent?t:r._shouldDropEvent(t,a)?null:t}return t}))},e.prototype._shouldDropEvent=function(e,t){return this._isSentryError(e,t)?(ue()&&Be.warn("Event dropped due to being internal Sentry Error.\nEvent: "+wt(e)),!0):this._isIgnoredError(e,t)?(ue()&&Be.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: "+wt(e)),!0):this._isDeniedUrl(e,t)?(ue()&&Be.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: "+wt(e)+".\nUrl: "+this._getEventFilterUrl(e)),
59
+ !0):!this._isAllowedUrl(e,t)&&(ue()&&Be.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: "+wt(e)+".\nUrl: "+this._getEventFilterUrl(e)),!0)},e.prototype._isSentryError=function(e,t){if(!t.ignoreInternal)return!1;try{return"SentryError"===e.exception.values[0].type}catch(e){}return!1},e.prototype._isIgnoredError=function(e,t){return!(!t.ignoreErrors||!t.ignoreErrors.length)&&this._getPossibleEventMessages(e).some((function(e){return t.ignoreErrors.some((function(t){return Ue(e,t)}))}))},e.prototype._isDeniedUrl=function(e,t){if(!t.denyUrls||!t.denyUrls.length)return!1;var n=this._getEventFilterUrl(e);return!!n&&t.denyUrls.some((function(e){return Ue(n,e)}))},e.prototype._isAllowedUrl=function(e,t){if(!t.allowUrls||!t.allowUrls.length)return!0;var n=this._getEventFilterUrl(e);return!n||t.allowUrls.some((function(e){return Ue(n,e)}))},e.prototype._mergeOptions=function(e){return void 0===e&&(e={}),{
60
+ allowUrls:le(this._options.whitelistUrls||[],this._options.allowUrls||[],e.whitelistUrls||[],e.allowUrls||[]),denyUrls:le(this._options.blacklistUrls||[],this._options.denyUrls||[],e.blacklistUrls||[],e.denyUrls||[]),ignoreErrors:le(this._options.ignoreErrors||[],e.ignoreErrors||[],pn),ignoreInternal:void 0===this._options.ignoreInternal||this._options.ignoreInternal}},e.prototype._getPossibleEventMessages=function(e){if(e.message)return[e.message];if(e.exception)try{var t=e.exception.values&&e.exception.values[0]||{},n=t.type,r=void 0===n?"":n,o=t.value,i=void 0===o?"":o;return[""+i,r+": "+i]}catch(t){return ue()&&Be.error("Cannot extract message for event "+wt(e)),[]}return[]},e.prototype._getLastValidUrl=function(e){void 0===e&&(e=[]);for(var t=e.length-1;t>=0;t--){var n=e[t];if(n&&"<anonymous>"!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null},e.prototype._getEventFilterUrl=function(e){try{if(e.stacktrace)return this._getLastValidUrl(e.stacktrace.frames);var t;try{
61
+ t=e.exception.values[0].stacktrace.frames}catch(e){}return t?this._getLastValidUrl(t):null}catch(t){return ue()&&Be.error("Cannot extract url for event "+wt(e)),null}},e.id="InboundFilters",e}(),fn=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,gn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,vn=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,yn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_n=/\((\S*)(?::(\d+))(?::(\d+))\)/,bn=/Minified React error #\d+;/i;function wn(e){var t=null,n=0;e&&("number"==typeof e.framesToPop?n=e.framesToPop:bn.test(e.message)&&(n=1));try{if(t=function(e){if(!e||!e.stacktrace)return null
61
62
  ;for(var t,n=e.stacktrace,r=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,o=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\((.*)\))? in (.*):\s*$/i,i=n.split("\n"),a=[],s=0;s<i.length;s+=2){var l=null;(t=r.exec(i[s]))?l={url:t[2],func:t[3],args:[],line:+t[1],column:null}:(t=o.exec(i[s]))&&(l={url:t[6],func:t[3]||t[4],args:t[5]?t[5].split(","):[],line:+t[1],column:+t[2]}),l&&(!l.func&&l.line&&(l.func="?"),a.push(l))}if(!a.length)return null;return{message:Sn(e),name:e.name,stack:a}}(e),t)return kn(t,n)}catch(e){}try{if(t=function(e){var t,n;if(!e||!e.stack)return null;for(var r,o,i,a=[],s=e.stack.split("\n"),l=0;l<s.length;++l){if(o=fn.exec(s[l])){var c=o[2]&&0===o[2].indexOf("native");o[2]&&0===o[2].indexOf("eval")&&(r=_n.exec(o[2]))&&(o[2]=r[1],o[3]=r[2],o[4]=r[3]);var u=o[2]&&0===o[2].indexOf("address at ")?o[2].substr("address at ".length):o[2],h=o[1]||"?";h=(t=se(xn(h,u),2))[0],i={url:u=t[1],func:h,args:c?[o[2]]:[],line:o[3]?+o[3]:null,column:o[4]?+o[4]:null}
62
63
  }else if(o=vn.exec(s[l]))i={url:o[2],func:o[1]||"?",args:[],line:+o[3],column:o[4]?+o[4]:null};else{if(!(o=gn.exec(s[l])))continue;o[3]&&o[3].indexOf(" > eval")>-1&&(r=yn.exec(o[3]))?(o[1]=o[1]||"eval",o[3]=r[1],o[4]=r[2],o[5]=""):0!==l||o[5]||void 0===e.columnNumber||(a[0].column=e.columnNumber+1);u=o[3],h=o[1]||"?";h=(n=se(xn(h,u),2))[0],i={url:u=n[1],func:h,args:o[2]?o[2].split(","):[],line:o[4]?+o[4]:null,column:o[5]?+o[5]:null}}!i.func&&i.line&&(i.func="?"),a.push(i)}if(!a.length)return null;return{message:Sn(e),name:e.name,stack:a}}(e),t)return kn(t,n)}catch(e){}return{message:Sn(e),name:e&&e.name,stack:[],failed:!0}}var xn=function(e,t){var n=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return n||r?[-1!==e.indexOf("@")?e.split("@")[0]:"?",n?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]};function kn(e,t){try{return ie(ie({},e),{stack:e.stack.slice(t)})}catch(t){return e}}function Sn(e){var t=e&&e.message
63
64
  ;return t?t.error&&"string"==typeof t.error.message?t.error.message:t:"No error message"}function Cn(e){var t=En(e.stack),n={type:e.name,value:e.message};return t&&t.length&&(n.stacktrace={frames:t}),void 0===n.type&&""===n.value&&(n.value="Unrecoverable error caught"),n}function An(e){return{exception:{values:[Cn(e)]}}}function En(e){if(!e||!e.length)return[];var t=e,n=t[0].func||"",r=t[t.length-1].func||"";return-1===n.indexOf("captureMessage")&&-1===n.indexOf("captureException")||(t=t.slice(1)),-1!==r.indexOf("sentryWrapped")&&(t=t.slice(0,-1)),t.slice(0,50).map((function(e){return{colno:null===e.column?void 0:e.column,filename:e.url||t[0].url,function:e.func||"?",in_app:!0,lineno:null===e.line?void 0:e.line}})).reverse()}function Tn(e,t,n){var r;if(void 0===n&&(n={}),ve(e)&&e.error)return r=An(wn(e=e.error));if(ye(e)||ge(e,"DOMException")){var o=e;if("stack"in e)r=An(wn(e));else{var i=o.name||(ye(o)?"DOMError":"DOMException"),a=o.message?i+": "+o.message:i;xt(r=Nn(a,t,n),a)}
64
65
  return"code"in o&&(r.tags=ie(ie({},r.tags),{"DOMException.code":""+o.code})),r}return fe(e)?r=An(wn(e)):we(e)||xe(e)?(r=function(e,t,n){var r={exception:{values:[{type:xe(e)?e.constructor.name:n?"UnhandledRejection":"Error",value:"Non-Error "+(n?"promise rejection":"exception")+" captured with keys: "+Qe(e)}]},extra:{__serialized__:Ke(e)}};if(t){var o=En(wn(t).stack);r.stacktrace={frames:o}}return r}(e,t,n.isRejection),kt(r,{synthetic:!0}),r):(xt(r=Nn(e,t,n),""+e,void 0),kt(r,{synthetic:!0}),r)}function Nn(e,t,n){void 0===n&&(n={});var r={message:e};if(n.attachStacktrace&&t){var o=En(wn(t).stack);r.stacktrace={frames:o}}return r}var Ln,Mn=pe();function zn(){if(Ln)return Ln;if(nt(Mn.fetch))return Ln=Mn.fetch.bind(Mn);var e=Mn.document,t=Mn.fetch;if(e&&"function"==typeof e.createElement)try{var n=e.createElement("iframe");n.hidden=!0,e.head.appendChild(n);var r=n.contentWindow;r&&r.fetch&&(t=r.fetch),e.head.removeChild(n)}catch(e){
65
- ue()&&Be.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return Ln=t.bind(Mn)}function On(e,t){if("[object Navigator]"===Object.prototype.toString.call(Mn&&Mn.navigator)&&"function"==typeof Mn.navigator.sendBeacon)return Mn.navigator.sendBeacon.bind(Mn.navigator)(e,t);if(tt()){var n=zn();n(e,{body:t,method:"POST",credentials:"omit",keepalive:!0}).then(null,(function(e){console.error(e)}))}else;}function In(e){return"event"===e?"error":e}var Rn=pe(),Pn=function(){function e(e){var t,n,r,o=this;this.options=e,this._buffer=Tt(30),this._rateLimits={},this._outcomes={},this._api=(t=e.dsn,n=e._metadata,r=e.tunnel,{initDsn:t,metadata:n||{},dsn:Oe(t),tunnel:r}),this.url=Qt(this._api.dsn),this.options.sendClientReports&&Rn.document&&Rn.document.addEventListener("visibilitychange",(function(){"hidden"===Rn.document.visibilityState&&o._flushOutcomes()}))}return e.prototype.sendEvent=function(e){return this._sendRequest(function(e,t){
66
- var n=cn(t),r=e.type||"event",o="transaction"===r||!!t.tunnel,i=(e.sdkProcessingMetadata||{}).transactionSampling||{},a=i.method,s=i.rate;delete e.sdkProcessingMetadata;var l={body:JSON.stringify(n?un(e,t.metadata.sdk):e),type:r,url:o?en(t.dsn,t.tunnel):Qt(t.dsn)};if(o){var c=JSON.stringify(ie(ie({event_id:e.event_id,sent_at:(new Date).toISOString()},n&&{sdk:n}),!!t.tunnel&&{dsn:Me(t.dsn)}))+"\n"+JSON.stringify({type:r,sample_rates:[{id:a,rate:s}]})+"\n"+l.body;l.body=c}return l}(e,this._api),e)},e.prototype.sendSession=function(e){return this._sendRequest(function(e,t){var n=cn(t),r="aggregates"in e?"sessions":"session";return{body:JSON.stringify(ie(ie({sent_at:(new Date).toISOString()},n&&{sdk:n}),!!t.tunnel&&{dsn:Me(t.dsn)}))+"\n"+JSON.stringify({type:r})+"\n"+JSON.stringify(e),type:r,url:en(t.dsn,t.tunnel)}}(e,this._api),e)},e.prototype.close=function(e){return this._buffer.drain(e)},e.prototype.recordLostEvent=function(e,t){var n;if(this.options.sendClientReports){var r=In(t)+":"+e
67
- ;Be.log("Adding outcome: "+r),this._outcomes[r]=(null!=(n=this._outcomes[r])?n:0)+1}},e.prototype._flushOutcomes=function(){if(this.options.sendClientReports){var e=this._outcomes;if(this._outcomes={},Object.keys(e).length){Be.log("Flushing outcomes:\n"+JSON.stringify(e,null,2));var t=en(this._api.dsn,this._api.tunnel),n=JSON.stringify(ie({},this._api.tunnel&&{dsn:Me(this._api.dsn)}))+"\n"+JSON.stringify({type:"client_report"})+"\n"+JSON.stringify({timestamp:Ot(),discarded_events:Object.keys(e).map((function(t){var n=se(t.split(":"),2),r=n[0];return{reason:n[1],category:r,quantity:e[t]}}))});try{On(t,n)}catch(e){Be.error(e)}}else Be.log("No outcomes to flush")}},e.prototype._handleResponse=function(e){var t,n=e.requestType,r=e.response,o=e.headers,i=e.resolve,a=e.reject,s=(t=r.status)>=200&&t<300?"success":429===t?"rate_limit":t>=400&&t<500?"invalid":t>=500?"failed":"unknown";this._handleRateLimit(o)&&ue()&&Be.warn("Too many "+n+" requests, backing off until: "+this._disabledUntil(n)),"success"!==s?a(r):i({
68
- status:s})},e.prototype._disabledUntil=function(e){var t=In(e);return this._rateLimits[t]||this._rateLimits.all},e.prototype._isRateLimited=function(e){return this._disabledUntil(e)>new Date(Date.now())},e.prototype._handleRateLimit=function(e){var t,n,r,o,i=Date.now(),a=e["x-sentry-rate-limits"],s=e["retry-after"];if(a){try{for(var l=ae(a.trim().split(",")),c=l.next();!c.done;c=l.next()){var u=c.value.split(":",2),h=parseInt(u[0],10),d=1e3*(isNaN(h)?60:h);try{for(var p=(r=void 0,ae(u[1].split(";"))),m=p.next();!m.done;m=p.next()){var f=m.value;this._rateLimits[f||"all"]=new Date(i+d)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return!0}return!!s&&(this._rateLimits.all=new Date(i+function(e,t){if(!t)return 6e4;var n=parseInt(""+t,10);if(!isNaN(n))return 1e3*n;var r=Date.parse(""+t);return isNaN(r)?6e4:r-e}(i,s)),!0)},e}(),Dn=function(e){function t(t,n){
69
- void 0===n&&(n=zn());var r=e.call(this,t)||this;return r._fetch=n,r}return re(t,e),t.prototype._sendRequest=function(e,t){var n=this;if(this._isRateLimited(e.type))return this.recordLostEvent("ratelimit_backoff",e.type),Promise.reject({event:t,type:e.type,reason:"Transport for "+e.type+" requests locked till "+this._disabledUntil(e.type)+" due to too many requests.",status:429});var r={body:e.body,method:"POST",referrerPolicy:rt()?"origin":""};return void 0!==this.options.fetchParameters&&Object.assign(r,this.options.fetchParameters),void 0!==this.options.headers&&(r.headers=this.options.headers),this._buffer.add((function(){return new Et((function(t,o){n._fetch(e.url,r).then((function(r){var i={"x-sentry-rate-limits":r.headers.get("X-Sentry-Rate-Limits"),"retry-after":r.headers.get("Retry-After")};n._handleResponse({requestType:e.type,response:r,headers:i,resolve:t,reject:o})})).catch(o)}))})).then(void 0,(function(t){
70
- throw t instanceof Ne?n.recordLostEvent("queue_overflow",e.type):n.recordLostEvent("network_error",e.type),t}))},t}(Pn),Bn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return re(t,e),t.prototype._sendRequest=function(e,t){var n=this;return this._isRateLimited(e.type)?(this.recordLostEvent("ratelimit_backoff",e.type),Promise.reject({event:t,type:e.type,reason:"Transport for "+e.type+" requests locked till "+this._disabledUntil(e.type)+" due to too many requests.",status:429})):this._buffer.add((function(){return new Et((function(t,r){var o=new XMLHttpRequest;for(var i in o.onreadystatechange=function(){if(4===o.readyState){var i={"x-sentry-rate-limits":o.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":o.getResponseHeader("Retry-After")};n._handleResponse({requestType:e.type,response:o,headers:i,resolve:t,reject:r})}},o.open("POST",e.url),n.options.headers)Object.prototype.hasOwnProperty.call(n.options.headers,i)&&o.setRequestHeader(i,n.options.headers[i]);o.send(e.body)}))
71
- })).then(void 0,(function(t){throw t instanceof Ne?n.recordLostEvent("queue_overflow",e.type):n.recordLostEvent("network_error",e.type),t}))},t}(Pn),Fn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return re(t,e),t.prototype.eventFromException=function(e,t){return function(e,t,n){var r=Tn(t,n&&n.syntheticException||void 0,{attachStacktrace:e.attachStacktrace});return kt(r),r.level=oe.Error,n&&n.event_id&&(r.event_id=n.event_id),Ct(r)}(this._options,e,t)},t.prototype.eventFromMessage=function(e,t,n){return void 0===t&&(t=oe.Info),function(e,t,n,r){void 0===n&&(n=oe.Info);var o=Nn(t,r&&r.syntheticException||void 0,{attachStacktrace:e.attachStacktrace});return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),Ct(o)}(this._options,e,t,n)},t.prototype._setupTransport=function(){if(!this._options.dsn)return e.prototype._setupTransport.call(this);var t=ie(ie({},this._options.transportOptions),{dsn:this._options.dsn,tunnel:this._options.tunnel,
72
- sendClientReports:this._options.sendClientReports,_metadata:this._options._metadata});return this._options.transport?new this._options.transport(t):tt()?new Dn(t):new Bn(t)},t}(ln),jn=pe(),Hn=0;function Un(){return Hn>0}function qn(){Hn+=1,setTimeout((function(){Hn-=1}))}function $n(e,t,n){if(void 0===t&&(t={}),"function"!=typeof e)return e;try{var r=e.__sentry_wrapped__;if(r)return r;if(Ve(e))return e}catch(t){return e}var o=function(){var r=Array.prototype.slice.call(arguments);try{n&&"function"==typeof n&&n.apply(this,arguments);var o=r.map((function(e){return $n(e,t)}));return e.apply(this,o)}catch(e){throw qn(),Kt((function(n){n.addEventProcessor((function(e){return t.mechanism&&(xt(e,void 0,void 0),kt(e,t.mechanism)),e.extra=ie(ie({},e.extra),{arguments:r}),e})),Wt(e)})),e}};try{for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i])}catch(e){}Ge(o,e),$e(e,"__sentry_wrapped__",o);try{Object.getOwnPropertyDescriptor(o,"name").configurable&&Object.defineProperty(o,"name",{get:function(){
73
- return e.name}})}catch(e){}return o}function Gn(e){if(void 0===e&&(e={}),jn.document)if(e.eventId)if(e.dsn){var t=jn.document.createElement("script");t.async=!0,t.src=function(e,t){var n=Oe(e),r=Xt(n)+"embed/error-page/",o="dsn="+Me(n);for(var i in t)if("dsn"!==i)if("user"===i){if(!t.user)continue;t.user.name&&(o+="&name="+encodeURIComponent(t.user.name)),t.user.email&&(o+="&email="+encodeURIComponent(t.user.email))}else o+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i]);return r+"?"+o}(e.dsn,e),e.onLoad&&(t.onload=e.onLoad);var n=jn.document.head||jn.document.body;n&&n.appendChild(t)}else ue()&&Be.error("Missing dsn option in showReportDialog call");else ue()&&Be.error("Missing eventId option in showReportDialog call")}var Vn=function(){function e(t){this.name=e.id,this._installFunc={onerror:Wn,onunhandledrejection:Yn},this._options=ie({onerror:!0,onunhandledrejection:!0},t)}return e.prototype.setupOnce=function(){Error.stackTraceLimit=50;var e=this._options;for(var t in e){var n=this._installFunc[t]
74
- ;n&&e[t]&&(Xn(t),n(),this._installFunc[t]=void 0)}},e.id="GlobalHandlers",e}();function Wn(){ct("error",(function(e){var t=se(Jn(),2),n=t[0],r=t[1];if(n.getIntegration(Vn)){var o=e.msg,i=e.url,a=e.line,s=e.column,l=e.error;if(!(Un()||l&&l.__sentry_own_request__)){var c=void 0===l&&_e(o)?function(e,t,n,r){var o=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,i=ve(e)?e.message:e,a="Error",s=i.match(o);s&&(a=s[1],i=s[2]);return Kn({exception:{values:[{type:a,value:i}]}},t,n,r)}(o,i,a,s):Kn(Tn(l||o,void 0,{attachStacktrace:r,isRejection:!1}),i,a,s);Zn(n,l,c,"onerror")}}}))}function Yn(){ct("unhandledrejection",(function(e){var t=se(Jn(),2),n=t[0],r=t[1];if(n.getIntegration(Vn)){var o=e;try{"reason"in e?o=e.reason:"detail"in e&&"reason"in e.detail&&(o=e.detail.reason)}catch(e){}if(Un()||o&&o.__sentry_own_request__)return!0;var i=be(o)?{exception:{values:[{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(o)}]}
75
- }:Tn(o,void 0,{attachStacktrace:r,isRejection:!0});i.level=oe.Error,Zn(n,o,i,"onunhandledrejection")}}))}function Kn(e,t,n,r){var o=e.exception=e.exception||{},i=o.values=o.values||[],a=i[0]=i[0]||{},s=a.stacktrace=a.stacktrace||{},l=s.frames=s.frames||[],c=isNaN(parseInt(r,10))?void 0:r,u=isNaN(parseInt(n,10))?void 0:n,h=_e(t)&&t.length>0?t:function(){var e=pe();try{return e.document.location.href}catch(e){return""}}();return 0===l.length&&l.push({colno:c,filename:h,function:"?",in_app:!0,lineno:u}),e}function Xn(e){ue()&&Be.log("Global Handler attached: "+e)}function Zn(e,t,n,r){kt(n,{handled:!1,type:r}),e.captureEvent(n,{originalException:t})}function Jn(){var e=Ut(),t=e.getClient();return[e,t&&t.getOptions().attachStacktrace]}
76
- var Qn=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],er=function(){function e(t){this.name=e.id,this._options=ie({XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0},t)}return e.prototype.setupOnce=function(){var e=pe();this._options.setTimeout&&qe(e,"setTimeout",tr),this._options.setInterval&&qe(e,"setInterval",tr),this._options.requestAnimationFrame&&qe(e,"requestAnimationFrame",nr),this._options.XMLHttpRequest&&"XMLHttpRequest"in e&&qe(XMLHttpRequest.prototype,"send",rr);var t=this._options.eventTarget;t&&(Array.isArray(t)?t:Qn).forEach(or)},e.id="TryCatch",e}()
77
- ;function tr(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0];return t[0]=$n(r,{mechanism:{data:{function:Fe(e)},handled:!0,type:"instrument"}}),e.apply(this,t)}}function nr(e){return function(t){return e.call(this,$n(t,{mechanism:{data:{function:"requestAnimationFrame",handler:Fe(e)},handled:!0,type:"instrument"}}))}}function rr(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this,o=["onload","onerror","onprogress","onreadystatechange"];return o.forEach((function(e){e in r&&"function"==typeof r[e]&&qe(r,e,(function(t){var n={mechanism:{data:{function:e,handler:Fe(t)},handled:!0,type:"instrument"}},r=Ve(t);return r&&(n.mechanism.data.handler=Fe(r)),$n(t,n)}))})),e.apply(this,t)}}function or(e){var t=pe(),n=t[e]&&t[e].prototype;n&&n.hasOwnProperty&&n.hasOwnProperty("addEventListener")&&(qe(n,"addEventListener",(function(t){return function(n,r,o){try{"function"==typeof r.handleEvent&&(r.handleEvent=$n(r.handleEvent.bind(r),{
78
- mechanism:{data:{function:"handleEvent",handler:Fe(r),target:e},handled:!0,type:"instrument"}}))}catch(e){}return t.call(this,n,$n(r,{mechanism:{data:{function:"addEventListener",handler:Fe(r),target:e},handled:!0,type:"instrument"}}),o)}})),qe(n,"removeEventListener",(function(e){return function(t,n,r){var o=n;try{var i=o&&o.__sentry_wrapped__;i&&e.call(this,t,i,r)}catch(e){}return e.call(this,t,o,r)}})))}var ir=function(){function e(t){this.name=e.id,this._options=ie({console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0},t)}return e.prototype.addSentryBreadcrumb=function(e){this._options.sentry&&Ut().addBreadcrumb({category:"sentry."+("transaction"===e.type?"transaction":"event"),event_id:e.event_id,level:e.level,message:wt(e)},{event:e})},e.prototype.setupOnce=function(){this._options.console&&ct("console",ar),this._options.dom&&ct("dom",function(e){function t(t){var n,r="object"==typeof e?e.serializeAttribute:void 0;"string"==typeof r&&(r=[r]);try{n=t.event.target?Ae(t.event.target,r):Ae(t.event,r)
79
- }catch(e){n="<unknown>"}0!==n.length&&Ut().addBreadcrumb({category:"ui."+t.name,message:n},{event:t.event,name:t.name,global:t.global})}return t}(this._options.dom)),this._options.xhr&&ct("xhr",sr),this._options.fetch&&ct("fetch",lr),this._options.history&&ct("history",cr)},e.id="Breadcrumbs",e}();function ar(e){var t={category:"console",data:{arguments:e.args,logger:"console"},level:Nt(e.level),message:He(e.args," ")};if("assert"===e.level){if(!1!==e.args[0])return;t.message="Assertion failed: "+(He(e.args.slice(1)," ")||"console.assert"),t.data.arguments=e.args.slice(1)}Ut().addBreadcrumb(t,{input:e.args,level:e.level})}function sr(e){if(e.endTimestamp){if(e.xhr.__sentry_own_request__)return;var t=e.xhr.__sentry_xhr__||{},n=t.method,r=t.url,o=t.status_code,i=t.body;Ut().addBreadcrumb({category:"xhr",data:{method:n,url:r,status_code:o},type:"http"},{xhr:e.xhr,input:i})}else;}function lr(e){e.endTimestamp&&(e.fetchData.url.match(/sentry_key/)&&"POST"===e.fetchData.method||(e.error?Ut().addBreadcrumb({
80
- category:"fetch",data:e.fetchData,level:oe.Error,type:"http"},{data:e.error,input:e.args}):Ut().addBreadcrumb({category:"fetch",data:ie(ie({},e.fetchData),{status_code:e.response.status}),type:"http"},{input:e.args,response:e.response})))}function cr(e){var t=pe(),n=e.from,r=e.to,o=_t(t.location.href),i=_t(n),a=_t(r);i.path||(i=o),o.protocol===a.protocol&&o.host===a.host&&(r=a.relative),o.protocol===i.protocol&&o.host===i.host&&(n=i.relative),Ut().addBreadcrumb({category:"navigation",data:{from:n,to:r}})}var ur=function(){function e(t){void 0===t&&(t={}),this.name=e.id,this._key=t.key||"cause",this._limit=t.limit||5}return e.prototype.setupOnce=function(){Dt((function(t,n){var r=Ut().getIntegration(e);return r?function(e,t,n,r){if(!(n.exception&&n.exception.values&&r&&Ce(r.originalException,Error)))return n;var o=hr(t,r.originalException,e);return n.exception.values=le(o,n.exception.values),n}(r._key,r._limit,t,n):t}))},e.id="LinkedErrors",e}();function hr(e,t,n,r){if(void 0===r&&(r=[]),
81
- !Ce(t[n],Error)||r.length+1>=e)return r;var o=Cn(wn(t[n]));return hr(e,t[n],n,le([o],r))}var dr=pe(),pr=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){Dt((function(t){if(Ut().getIntegration(e)){if(!dr.navigator&&!dr.location&&!dr.document)return t;var n=t.request&&t.request.url||dr.location&&dr.location.href,r=(dr.document||{}).referrer,o=(dr.navigator||{}).userAgent,i=ie(ie(ie({},t.request&&t.request.headers),r&&{Referer:r}),o&&{"User-Agent":o}),a=ie(ie({},n&&{url:n}),{headers:i});return ie(ie({},t),{request:a})}return t}))},e.id="UserAgent",e}(),mr=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(t,n){t((function(t){var r=n().getIntegration(e);if(r){try{if(function(e,t){if(!t)return!1;if(function(e,t){var n=e.message,r=t.message;if(!n&&!r)return!1;if(n&&!r||!n&&r)return!1;if(n!==r)return!1;if(!gr(e,t))return!1;if(!fr(e,t))return!1;return!0}(e,t))return!0;if(function(e,t){var n=vr(t),r=vr(e);if(!n||!r)return!1
82
- ;if(n.type!==r.type||n.value!==r.value)return!1;if(!gr(e,t))return!1;if(!fr(e,t))return!1;return!0}(e,t))return!0;return!1}(t,r._previousEvent))return Be.warn("Event dropped due to being a duplicate of previously captured event."),null}catch(e){return r._previousEvent=t}return r._previousEvent=t}return t}))},e.id="Dedupe",e}();function fr(e,t){var n=yr(e),r=yr(t);if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;if(n=n,(r=r).length!==n.length)return!1;for(var o=0;o<r.length;o++){var i=r[o],a=n[o];if(i.filename!==a.filename||i.lineno!==a.lineno||i.colno!==a.colno||i.function!==a.function)return!1}return!0}function gr(e,t){var n=e.fingerprint,r=t.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;n=n,r=r;try{return!(n.join("")!==r.join(""))}catch(e){return!1}}function vr(e){return e.exception&&e.exception.values&&e.exception.values[0]}function yr(e){var t=e.exception;if(t)try{return t.values[0].stacktrace.frames}catch(e){return}else if(e.stacktrace)return e.stacktrace.frames}var _r=function(e){function t(t){
83
- void 0===t&&(t={});return t._metadata=t._metadata||{},t._metadata.sdk=t._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:"npm:@sentry/browser",version:"6.17.0"}],version:"6.17.0"},e.call(this,Fn,t)||this}return re(t,e),t.prototype.showReportDialog=function(e){void 0===e&&(e={}),pe().document&&(this._isEnabled()?Gn(ie(ie({},e),{dsn:e.dsn||this.getDsn()})):Be.error("Trying to call showReportDialog with Sentry Client disabled"))},t.prototype._prepareEvent=function(t,n,r){return t.platform=t.platform||"javascript",e.prototype._prepareEvent.call(this,t,n,r)},t.prototype._sendEvent=function(t){var n=this.getIntegration(ir);n&&n.addSentryBreadcrumb(t),e.prototype._sendEvent.call(this,t)},t}(an),br=[new mn,new dn,new er,new ir,new Vn,new ur,new mr,new pr];function wr(e){if(void 0===e&&(e={}),void 0===e.defaultIntegrations&&(e.defaultIntegrations=br),void 0===e.release){var t=pe();t.SENTRY_RELEASE&&t.SENTRY_RELEASE.id&&(e.release=t.SENTRY_RELEASE.id)}
84
- void 0===e.autoSessionTracking&&(e.autoSessionTracking=!0),void 0===e.sendClientReports&&(e.sendClientReports=!0),function(e,t){!0===t.debug&&Be.enable();var n=Ut(),r=n.getScope();r&&r.update(t.initialScope);var o=new e(t);n.bindClient(o)}(_r,e),e.autoSessionTracking&&function(){if(void 0===pe().document)return void(ue()&&Be.warn("Session tracking in non-browser environment with @sentry/browser is not supported."));var e=Ut();if(!e.captureSession)return;xr(e),ct("history",(function(e){var t=e.from,n=e.to;void 0!==t&&t!==n&&xr(Ut())}))}()}function xr(e){e.startSession({ignoreDuration:!0}),e.captureSession()}function kr(e){const t=t=>{const{data:n}=t;if(n&&"hypothesis-error"===(null==n?void 0:n.type)){const{context:t,error:r}=n;e(r instanceof Error?r:function(e){const t=new Error(e.message);return t.stack=e.stack,t}(r),t)}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}let Sr=0;function Cr(e){!function(e){Vt("setUser",e)}(e)}!function(){function e(e){
85
- var t=!0,n=!1,r=null,o={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function i(e){return!!(e&&e!==document&&"HTML"!==e.nodeName&&"BODY"!==e.nodeName&&"classList"in e&&"contains"in e.classList)}function a(e){var t=e.type,n=e.tagName;return!("INPUT"!==n||!o[t]||e.readOnly)||"TEXTAREA"===n&&!e.readOnly||!!e.isContentEditable}function s(e){e.classList.contains("focus-visible")||(e.classList.add("focus-visible"),e.setAttribute("data-focus-visible-added",""))}function l(e){e.hasAttribute("data-focus-visible-added")&&(e.classList.remove("focus-visible"),e.removeAttribute("data-focus-visible-added"))}function c(n){n.metaKey||n.altKey||n.ctrlKey||(i(e.activeElement)&&s(e.activeElement),t=!0)}function u(e){t=!1}function h(e){i(e.target)&&(t||a(e.target))&&s(e.target)}function d(e){i(e.target)&&(e.target.classList.contains("focus-visible")||e.target.hasAttribute("data-focus-visible-added"))&&(n=!0,window.clearTimeout(r),
86
- r=window.setTimeout((function(){n=!1}),100),l(e.target))}function p(e){"hidden"===document.visibilityState&&(n&&(t=!0),m())}function m(){document.addEventListener("mousemove",g),document.addEventListener("mousedown",g),document.addEventListener("mouseup",g),document.addEventListener("pointermove",g),document.addEventListener("pointerdown",g),document.addEventListener("pointerup",g),document.addEventListener("touchmove",g),document.addEventListener("touchstart",g),document.addEventListener("touchend",g)}function f(){document.removeEventListener("mousemove",g),document.removeEventListener("mousedown",g),document.removeEventListener("mouseup",g),document.removeEventListener("pointermove",g),document.removeEventListener("pointerdown",g),document.removeEventListener("pointerup",g),document.removeEventListener("touchmove",g),document.removeEventListener("touchstart",g),document.removeEventListener("touchend",g)}function g(e){e.target.nodeName&&"html"===e.target.nodeName.toLowerCase()||(t=!1,f())}
87
- document.addEventListener("keydown",c,!0),document.addEventListener("mousedown",u,!0),document.addEventListener("pointerdown",u,!0),document.addEventListener("touchstart",u,!0),document.addEventListener("visibilitychange",p,!0),m(),e.addEventListener("focus",h,!0),e.addEventListener("blur",d,!0),e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host?e.host.setAttribute("data-js-focus-visible",""):e.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if("undefined"!=typeof window&&"undefined"!=typeof document){var t;window.applyFocusVisiblePolyfill=e;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(e){(t=document.createEvent("CustomEvent")).initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}"undefined"!=typeof document&&e(document)}(),"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.6.4",n,{Fragment:m,Component:f})
88
- ;var Ar={};function Er(e){return e.type===m?"Fragment":"function"==typeof e.type?e.type.displayName||e.type.name:"string"==typeof e.type?e.type:"#text"}var Tr=[],Nr=[];function Lr(){return Tr.length>0?Tr[Tr.length-1]:null}var Mr=!1;function zr(e){return"function"==typeof e.type&&e.type!=m}function Or(e){for(var t=[e],n=e;null!=n.__o;)t.push(n.__o),n=n.__o;return t.reduce((function(e,t){e+=" in "+Er(t);var n=t.__source;return n?e+=" (at "+n.fileName+":"+n.lineNumber+")":Mr||(Mr=!0,console.warn("Add @babel/plugin-transform-react-jsx-source to get a more detailed component stack. Note that you should not add it to production builds of your App for bundle size reasons.")),e+"\n"}),"")}var Ir="function"==typeof WeakMap,Rr=f.prototype.setState;f.prototype.setState=function(e,t){
89
- return null==this.__v?null==this.state&&console.warn('Calling "this.setState" inside the constructor of a component is a no-op and might be a bug in your application. Instead, set "this.state = {}" directly.\n\n'+Or(Lr())):null==this.__P&&console.warn('Can\'t call "this.setState" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+Or(this.__v)),Rr.call(this,e,t)};var Pr=f.prototype.forceUpdate;function Dr(e){var t=e.props,n=Er(e),r="";for(var o in t)if(t.hasOwnProperty(o)&&"children"!==o){var i=t[o];"function"==typeof i&&(i="function "+(i.displayName||i.name)+"() {}"),i=Object(i)!==i||i.toString?i+"":Object.prototype.toString.call(i),r+=" "+o+"="+JSON.stringify(i)}var a=t.children;return"<"+n+r+(a&&a.length?">..</"+n+">":" />")}f.prototype.forceUpdate=function(e){
66
+ ue()&&Be.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return Ln=t.bind(Mn)}function On(e,t){if("[object Navigator]"===Object.prototype.toString.call(Mn&&Mn.navigator)&&"function"==typeof Mn.navigator.sendBeacon)return Mn.navigator.sendBeacon.bind(Mn.navigator)(e,t);if(tt()){var n=zn();n(e,{body:t,method:"POST",credentials:"omit",keepalive:!0}).then(null,(function(e){console.error(e)}))}else;}function In(e){return"event"===e?"error":e}var Rn=pe(),Pn=function(){function e(e){var t,n,r,o=this;this.options=e,this._buffer=Tt(30),this._rateLimits={},this._outcomes={},this._api=(t=e.dsn,n=e._metadata,r=e.tunnel,{initDsn:t,metadata:n||{},dsn:Oe(t),tunnel:r}),this.url=Qt(this._api.dsn),this.options.sendClientReports&&Rn.document&&Rn.document.addEventListener("visibilitychange",(function(){"hidden"===Rn.document.visibilityState&&o._flushOutcomes()}))}return e.prototype.sendEvent=function(e){return this._sendRequest(un(e,this._api),e)},e.prototype.sendSession=function(e){
67
+ return this._sendRequest(function(e,t){var n=cn(t),r="aggregates"in e?"sessions":"session";return{body:JSON.stringify(ie(ie({sent_at:(new Date).toISOString()},n&&{sdk:n}),!!t.tunnel&&{dsn:Me(t.dsn)}))+"\n"+JSON.stringify({type:r})+"\n"+JSON.stringify(e),type:r,url:en(t.dsn,t.tunnel)}}(e,this._api),e)},e.prototype.close=function(e){return this._buffer.drain(e)},e.prototype.recordLostEvent=function(e,t){var n;if(this.options.sendClientReports){var r=In(t)+":"+e;Be.log("Adding outcome: "+r),this._outcomes[r]=(null!=(n=this._outcomes[r])?n:0)+1}},e.prototype._flushOutcomes=function(){if(this.options.sendClientReports){var e=this._outcomes;if(this._outcomes={},Object.keys(e).length){Be.log("Flushing outcomes:\n"+JSON.stringify(e,null,2));var t=en(this._api.dsn,this._api.tunnel),n=JSON.stringify(ie({},this._api.tunnel&&{dsn:Me(this._api.dsn)}))+"\n"+JSON.stringify({type:"client_report"})+"\n"+JSON.stringify({timestamp:Ot(),discarded_events:Object.keys(e).map((function(t){var n=se(t.split(":"),2),r=n[0];return{
68
+ reason:n[1],category:r,quantity:e[t]}}))});try{On(t,n)}catch(e){Be.error(e)}}else Be.log("No outcomes to flush")}},e.prototype._handleResponse=function(e){var t,n=e.requestType,r=e.response,o=e.headers,i=e.resolve,a=e.reject,s=(t=r.status)>=200&&t<300?"success":429===t?"rate_limit":t>=400&&t<500?"invalid":t>=500?"failed":"unknown";this._handleRateLimit(o)&&ue()&&Be.warn("Too many "+n+" requests, backing off until: "+this._disabledUntil(n)),"success"!==s?a(r):i({status:s})},e.prototype._disabledUntil=function(e){var t=In(e);return this._rateLimits[t]||this._rateLimits.all},e.prototype._isRateLimited=function(e){return this._disabledUntil(e)>new Date(Date.now())},e.prototype._handleRateLimit=function(e){var t,n,r,o,i=Date.now(),a=e["x-sentry-rate-limits"],s=e["retry-after"];if(a){try{for(var l=ae(a.trim().split(",")),c=l.next();!c.done;c=l.next()){var u=c.value.split(":",2),h=parseInt(u[0],10),d=1e3*(isNaN(h)?60:h);try{for(var p=(r=void 0,ae(u[1].split(";"))),m=p.next();!m.done;m=p.next()){var f=m.value
69
+ ;this._rateLimits[f||"all"]=new Date(i+d)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return!0}return!!s&&(this._rateLimits.all=new Date(i+function(e,t){if(!t)return 6e4;var n=parseInt(""+t,10);if(!isNaN(n))return 1e3*n;var r=Date.parse(""+t);return isNaN(r)?6e4:r-e}(i,s)),!0)},e}(),Dn=function(e){function t(t,n){void 0===n&&(n=zn());var r=e.call(this,t)||this;return r._fetch=n,r}return re(t,e),t.prototype._sendRequest=function(e,t){var n=this;if(this._isRateLimited(e.type))return this.recordLostEvent("ratelimit_backoff",e.type),Promise.reject({event:t,type:e.type,reason:"Transport for "+e.type+" requests locked till "+this._disabledUntil(e.type)+" due to too many requests.",status:429});var r={body:e.body,method:"POST",referrerPolicy:rt()?"origin":""};return void 0!==this.options.fetchParameters&&Object.assign(r,this.options.fetchParameters),
70
+ void 0!==this.options.headers&&(r.headers=this.options.headers),this._buffer.add((function(){return new Et((function(t,o){n._fetch(e.url,r).then((function(r){var i={"x-sentry-rate-limits":r.headers.get("X-Sentry-Rate-Limits"),"retry-after":r.headers.get("Retry-After")};n._handleResponse({requestType:e.type,response:r,headers:i,resolve:t,reject:o})})).catch(o)}))})).then(void 0,(function(t){throw t instanceof Ne?n.recordLostEvent("queue_overflow",e.type):n.recordLostEvent("network_error",e.type),t}))},t}(Pn),Bn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return re(t,e),t.prototype._sendRequest=function(e,t){var n=this;return this._isRateLimited(e.type)?(this.recordLostEvent("ratelimit_backoff",e.type),Promise.reject({event:t,type:e.type,reason:"Transport for "+e.type+" requests locked till "+this._disabledUntil(e.type)+" due to too many requests.",status:429})):this._buffer.add((function(){return new Et((function(t,r){var o=new XMLHttpRequest
71
+ ;for(var i in o.onreadystatechange=function(){if(4===o.readyState){var i={"x-sentry-rate-limits":o.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":o.getResponseHeader("Retry-After")};n._handleResponse({requestType:e.type,response:o,headers:i,resolve:t,reject:r})}},o.open("POST",e.url),n.options.headers)Object.prototype.hasOwnProperty.call(n.options.headers,i)&&o.setRequestHeader(i,n.options.headers[i]);o.send(e.body)}))})).then(void 0,(function(t){throw t instanceof Ne?n.recordLostEvent("queue_overflow",e.type):n.recordLostEvent("network_error",e.type),t}))},t}(Pn),Fn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return re(t,e),t.prototype.eventFromException=function(e,t){return function(e,t,n){var r=Tn(t,n&&n.syntheticException||void 0,{attachStacktrace:e.attachStacktrace});return kt(r),r.level=oe.Error,n&&n.event_id&&(r.event_id=n.event_id),Ct(r)}(this._options,e,t)},t.prototype.eventFromMessage=function(e,t,n){return void 0===t&&(t=oe.Info),function(e,t,n,r){
72
+ void 0===n&&(n=oe.Info);var o=Nn(t,r&&r.syntheticException||void 0,{attachStacktrace:e.attachStacktrace});return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),Ct(o)}(this._options,e,t,n)},t.prototype._setupTransport=function(){if(!this._options.dsn)return e.prototype._setupTransport.call(this);var t=ie(ie({},this._options.transportOptions),{dsn:this._options.dsn,tunnel:this._options.tunnel,sendClientReports:this._options.sendClientReports,_metadata:this._options._metadata});return this._options.transport?new this._options.transport(t):tt()?new Dn(t):new Bn(t)},t}(ln),jn=pe(),Hn=0;function Un(){return Hn>0}function qn(){Hn+=1,setTimeout((function(){Hn-=1}))}function $n(e,t,n){if(void 0===t&&(t={}),"function"!=typeof e)return e;try{var r=e.__sentry_wrapped__;if(r)return r;if(Ve(e))return e}catch(t){return e}var o=function(){var r=Array.prototype.slice.call(arguments);try{n&&"function"==typeof n&&n.apply(this,arguments);var o=r.map((function(e){return $n(e,t)}));return e.apply(this,o)}catch(e){throw qn(),
73
+ Kt((function(n){n.addEventProcessor((function(e){return t.mechanism&&(xt(e,void 0,void 0),kt(e,t.mechanism)),e.extra=ie(ie({},e.extra),{arguments:r}),e})),Wt(e)})),e}};try{for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i])}catch(e){}Ge(o,e),$e(e,"__sentry_wrapped__",o);try{Object.getOwnPropertyDescriptor(o,"name").configurable&&Object.defineProperty(o,"name",{get:function(){return e.name}})}catch(e){}return o}function Gn(e){if(void 0===e&&(e={}),jn.document)if(e.eventId)if(e.dsn){var t=jn.document.createElement("script");t.async=!0,t.src=function(e,t){var n=Oe(e),r=Xt(n)+"embed/error-page/",o="dsn="+Me(n);for(var i in t)if("dsn"!==i)if("user"===i){if(!t.user)continue;t.user.name&&(o+="&name="+encodeURIComponent(t.user.name)),t.user.email&&(o+="&email="+encodeURIComponent(t.user.email))}else o+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i]);return r+"?"+o}(e.dsn,e),e.onLoad&&(t.onload=e.onLoad);var n=jn.document.head||jn.document.body;n&&n.appendChild(t)
74
+ }else ue()&&Be.error("Missing dsn option in showReportDialog call");else ue()&&Be.error("Missing eventId option in showReportDialog call")}var Vn=function(){function e(t){this.name=e.id,this._installFunc={onerror:Wn,onunhandledrejection:Yn},this._options=ie({onerror:!0,onunhandledrejection:!0},t)}return e.prototype.setupOnce=function(){Error.stackTraceLimit=50;var e=this._options;for(var t in e){var n=this._installFunc[t];n&&e[t]&&(Xn(t),n(),this._installFunc[t]=void 0)}},e.id="GlobalHandlers",e}();function Wn(){ct("error",(function(e){var t=se(Jn(),2),n=t[0],r=t[1];if(n.getIntegration(Vn)){var o=e.msg,i=e.url,a=e.line,s=e.column,l=e.error;if(!(Un()||l&&l.__sentry_own_request__)){var c=void 0===l&&_e(o)?function(e,t,n,r){var o=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,i=ve(e)?e.message:e,a="Error",s=i.match(o);s&&(a=s[1],i=s[2]);return Kn({exception:{values:[{type:a,value:i}]}},t,n,r)}(o,i,a,s):Kn(Tn(l||o,void 0,{attachStacktrace:r,
75
+ isRejection:!1}),i,a,s);Zn(n,l,c,"onerror")}}}))}function Yn(){ct("unhandledrejection",(function(e){var t=se(Jn(),2),n=t[0],r=t[1];if(n.getIntegration(Vn)){var o=e;try{"reason"in e?o=e.reason:"detail"in e&&"reason"in e.detail&&(o=e.detail.reason)}catch(e){}if(Un()||o&&o.__sentry_own_request__)return!0;var i=be(o)?{exception:{values:[{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(o)}]}}:Tn(o,void 0,{attachStacktrace:r,isRejection:!0});i.level=oe.Error,Zn(n,o,i,"onunhandledrejection")}}))}function Kn(e,t,n,r){var o=e.exception=e.exception||{},i=o.values=o.values||[],a=i[0]=i[0]||{},s=a.stacktrace=a.stacktrace||{},l=s.frames=s.frames||[],c=isNaN(parseInt(r,10))?void 0:r,u=isNaN(parseInt(n,10))?void 0:n,h=_e(t)&&t.length>0?t:function(){var e=pe();try{return e.document.location.href}catch(e){return""}}();return 0===l.length&&l.push({colno:c,filename:h,function:"?",in_app:!0,lineno:u}),e}function Xn(e){ue()&&Be.log("Global Handler attached: "+e)}function Zn(e,t,n,r){
76
+ kt(n,{handled:!1,type:r}),e.captureEvent(n,{originalException:t})}function Jn(){var e=Ut(),t=e.getClient();return[e,t&&t.getOptions().attachStacktrace]}var Qn=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],er=function(){function e(t){this.name=e.id,this._options=ie({XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0},t)}return e.prototype.setupOnce=function(){var e=pe();this._options.setTimeout&&qe(e,"setTimeout",tr),this._options.setInterval&&qe(e,"setInterval",tr),this._options.requestAnimationFrame&&qe(e,"requestAnimationFrame",nr),
77
+ this._options.XMLHttpRequest&&"XMLHttpRequest"in e&&qe(XMLHttpRequest.prototype,"send",rr);var t=this._options.eventTarget;t&&(Array.isArray(t)?t:Qn).forEach(or)},e.id="TryCatch",e}();function tr(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0];return t[0]=$n(r,{mechanism:{data:{function:Fe(e)},handled:!0,type:"instrument"}}),e.apply(this,t)}}function nr(e){return function(t){return e.call(this,$n(t,{mechanism:{data:{function:"requestAnimationFrame",handler:Fe(e)},handled:!0,type:"instrument"}}))}}function rr(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this,o=["onload","onerror","onprogress","onreadystatechange"];return o.forEach((function(e){e in r&&"function"==typeof r[e]&&qe(r,e,(function(t){var n={mechanism:{data:{function:e,handler:Fe(t)},handled:!0,type:"instrument"}},r=Ve(t);return r&&(n.mechanism.data.handler=Fe(r)),$n(t,n)}))})),e.apply(this,t)}}function or(e){var t=pe(),n=t[e]&&t[e].prototype
78
+ ;n&&n.hasOwnProperty&&n.hasOwnProperty("addEventListener")&&(qe(n,"addEventListener",(function(t){return function(n,r,o){try{"function"==typeof r.handleEvent&&(r.handleEvent=$n(r.handleEvent.bind(r),{mechanism:{data:{function:"handleEvent",handler:Fe(r),target:e},handled:!0,type:"instrument"}}))}catch(e){}return t.call(this,n,$n(r,{mechanism:{data:{function:"addEventListener",handler:Fe(r),target:e},handled:!0,type:"instrument"}}),o)}})),qe(n,"removeEventListener",(function(e){return function(t,n,r){var o=n;try{var i=o&&o.__sentry_wrapped__;i&&e.call(this,t,i,r)}catch(e){}return e.call(this,t,o,r)}})))}var ir=function(){function e(t){this.name=e.id,this._options=ie({console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0},t)}return e.prototype.addSentryBreadcrumb=function(e){this._options.sentry&&Ut().addBreadcrumb({category:"sentry."+("transaction"===e.type?"transaction":"event"),event_id:e.event_id,level:e.level,message:wt(e)},{event:e})},e.prototype.setupOnce=function(){
79
+ this._options.console&&ct("console",ar),this._options.dom&&ct("dom",function(e){function t(t){var n,r="object"==typeof e?e.serializeAttribute:void 0;"string"==typeof r&&(r=[r]);try{n=t.event.target?Ae(t.event.target,r):Ae(t.event,r)}catch(e){n="<unknown>"}0!==n.length&&Ut().addBreadcrumb({category:"ui."+t.name,message:n},{event:t.event,name:t.name,global:t.global})}return t}(this._options.dom)),this._options.xhr&&ct("xhr",sr),this._options.fetch&&ct("fetch",lr),this._options.history&&ct("history",cr)},e.id="Breadcrumbs",e}();function ar(e){var t={category:"console",data:{arguments:e.args,logger:"console"},level:Nt(e.level),message:He(e.args," ")};if("assert"===e.level){if(!1!==e.args[0])return;t.message="Assertion failed: "+(He(e.args.slice(1)," ")||"console.assert"),t.data.arguments=e.args.slice(1)}Ut().addBreadcrumb(t,{input:e.args,level:e.level})}function sr(e){if(e.endTimestamp){if(e.xhr.__sentry_own_request__)return;var t=e.xhr.__sentry_xhr__||{},n=t.method,r=t.url,o=t.status_code,i=t.body
80
+ ;Ut().addBreadcrumb({category:"xhr",data:{method:n,url:r,status_code:o},type:"http"},{xhr:e.xhr,input:i})}else;}function lr(e){e.endTimestamp&&(e.fetchData.url.match(/sentry_key/)&&"POST"===e.fetchData.method||(e.error?Ut().addBreadcrumb({category:"fetch",data:e.fetchData,level:oe.Error,type:"http"},{data:e.error,input:e.args}):Ut().addBreadcrumb({category:"fetch",data:ie(ie({},e.fetchData),{status_code:e.response.status}),type:"http"},{input:e.args,response:e.response})))}function cr(e){var t=pe(),n=e.from,r=e.to,o=_t(t.location.href),i=_t(n),a=_t(r);i.path||(i=o),o.protocol===a.protocol&&o.host===a.host&&(r=a.relative),o.protocol===i.protocol&&o.host===i.host&&(n=i.relative),Ut().addBreadcrumb({category:"navigation",data:{from:n,to:r}})}var ur=function(){function e(t){void 0===t&&(t={}),this.name=e.id,this._key=t.key||"cause",this._limit=t.limit||5}return e.prototype.setupOnce=function(){Dt((function(t,n){var r=Ut().getIntegration(e);return r?function(e,t,n,r){
81
+ if(!(n.exception&&n.exception.values&&r&&Ce(r.originalException,Error)))return n;var o=hr(t,r.originalException,e);return n.exception.values=le(o,n.exception.values),n}(r._key,r._limit,t,n):t}))},e.id="LinkedErrors",e}();function hr(e,t,n,r){if(void 0===r&&(r=[]),!Ce(t[n],Error)||r.length+1>=e)return r;var o=Cn(wn(t[n]));return hr(e,t[n],n,le([o],r))}var dr=pe(),pr=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){Dt((function(t){if(Ut().getIntegration(e)){if(!dr.navigator&&!dr.location&&!dr.document)return t;var n=t.request&&t.request.url||dr.location&&dr.location.href,r=(dr.document||{}).referrer,o=(dr.navigator||{}).userAgent,i=ie(ie(ie({},t.request&&t.request.headers),r&&{Referer:r}),o&&{"User-Agent":o}),a=ie(ie({},n&&{url:n}),{headers:i});return ie(ie({},t),{request:a})}return t}))},e.id="UserAgent",e}(),mr=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(t,n){t((function(t){var r=n().getIntegration(e);if(r){try{if(function(e,t){if(!t)return!1
82
+ ;if(function(e,t){var n=e.message,r=t.message;if(!n&&!r)return!1;if(n&&!r||!n&&r)return!1;if(n!==r)return!1;if(!gr(e,t))return!1;if(!fr(e,t))return!1;return!0}(e,t))return!0;if(function(e,t){var n=vr(t),r=vr(e);if(!n||!r)return!1;if(n.type!==r.type||n.value!==r.value)return!1;if(!gr(e,t))return!1;if(!fr(e,t))return!1;return!0}(e,t))return!0;return!1}(t,r._previousEvent))return Be.warn("Event dropped due to being a duplicate of previously captured event."),null}catch(e){return r._previousEvent=t}return r._previousEvent=t}return t}))},e.id="Dedupe",e}();function fr(e,t){var n=yr(e),r=yr(t);if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;if(n=n,(r=r).length!==n.length)return!1;for(var o=0;o<r.length;o++){var i=r[o],a=n[o];if(i.filename!==a.filename||i.lineno!==a.lineno||i.colno!==a.colno||i.function!==a.function)return!1}return!0}function gr(e,t){var n=e.fingerprint,r=t.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;n=n,r=r;try{return!(n.join("")!==r.join(""))}catch(e){return!1}}function vr(e){
83
+ return e.exception&&e.exception.values&&e.exception.values[0]}function yr(e){var t=e.exception;if(t)try{return t.values[0].stacktrace.frames}catch(e){return}else if(e.stacktrace)return e.stacktrace.frames}var _r=function(e){function t(t){void 0===t&&(t={});return t._metadata=t._metadata||{},t._metadata.sdk=t._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:"npm:@sentry/browser",version:"6.17.3"}],version:"6.17.3"},e.call(this,Fn,t)||this}return re(t,e),t.prototype.showReportDialog=function(e){void 0===e&&(e={}),pe().document&&(this._isEnabled()?Gn(ie(ie({},e),{dsn:e.dsn||this.getDsn()})):Be.error("Trying to call showReportDialog with Sentry Client disabled"))},t.prototype._prepareEvent=function(t,n,r){return t.platform=t.platform||"javascript",e.prototype._prepareEvent.call(this,t,n,r)},t.prototype._sendEvent=function(t){var n=this.getIntegration(ir);n&&n.addSentryBreadcrumb(t),e.prototype._sendEvent.call(this,t)},t}(an),br=[new mn,new dn,new er,new ir,new Vn,new ur,new mr,new pr]
84
+ ;function wr(e){if(void 0===e&&(e={}),void 0===e.defaultIntegrations&&(e.defaultIntegrations=br),void 0===e.release){var t=pe();t.SENTRY_RELEASE&&t.SENTRY_RELEASE.id&&(e.release=t.SENTRY_RELEASE.id)}void 0===e.autoSessionTracking&&(e.autoSessionTracking=!0),void 0===e.sendClientReports&&(e.sendClientReports=!0),function(e,t){!0===t.debug&&Be.enable();var n=Ut(),r=n.getScope();r&&r.update(t.initialScope);var o=new e(t);n.bindClient(o)}(_r,e),e.autoSessionTracking&&function(){if(void 0===pe().document)return void(ue()&&Be.warn("Session tracking in non-browser environment with @sentry/browser is not supported."));var e=Ut();if(!e.captureSession)return;xr(e),ct("history",(function(e){var t=e.from,n=e.to;void 0!==t&&t!==n&&xr(Ut())}))}()}function xr(e){e.startSession({ignoreDuration:!0}),e.captureSession()}function kr(e){const t=t=>{const{data:n}=t;if(n&&"hypothesis-error"===(null==n?void 0:n.type)){const{context:t,error:r}=n;e(r instanceof Error?r:function(e){const t=new Error(e.message);return t.stack=e.stack,t
85
+ }(r),t)}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}let Sr=0;function Cr(e){!function(e){Vt("setUser",e)}(e)}!function(){function e(e){var t=!0,n=!1,r=null,o={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function i(e){return!!(e&&e!==document&&"HTML"!==e.nodeName&&"BODY"!==e.nodeName&&"classList"in e&&"contains"in e.classList)}function a(e){var t=e.type,n=e.tagName;return!("INPUT"!==n||!o[t]||e.readOnly)||"TEXTAREA"===n&&!e.readOnly||!!e.isContentEditable}function s(e){e.classList.contains("focus-visible")||(e.classList.add("focus-visible"),e.setAttribute("data-focus-visible-added",""))}function l(e){e.hasAttribute("data-focus-visible-added")&&(e.classList.remove("focus-visible"),e.removeAttribute("data-focus-visible-added"))}function c(n){n.metaKey||n.altKey||n.ctrlKey||(i(e.activeElement)&&s(e.activeElement),t=!0)}function u(e){t=!1}function h(e){
86
+ i(e.target)&&(t||a(e.target))&&s(e.target)}function d(e){i(e.target)&&(e.target.classList.contains("focus-visible")||e.target.hasAttribute("data-focus-visible-added"))&&(n=!0,window.clearTimeout(r),r=window.setTimeout((function(){n=!1}),100),l(e.target))}function p(e){"hidden"===document.visibilityState&&(n&&(t=!0),m())}function m(){document.addEventListener("mousemove",g),document.addEventListener("mousedown",g),document.addEventListener("mouseup",g),document.addEventListener("pointermove",g),document.addEventListener("pointerdown",g),document.addEventListener("pointerup",g),document.addEventListener("touchmove",g),document.addEventListener("touchstart",g),document.addEventListener("touchend",g)}function f(){document.removeEventListener("mousemove",g),document.removeEventListener("mousedown",g),document.removeEventListener("mouseup",g),document.removeEventListener("pointermove",g),document.removeEventListener("pointerdown",g),document.removeEventListener("pointerup",g),
87
+ document.removeEventListener("touchmove",g),document.removeEventListener("touchstart",g),document.removeEventListener("touchend",g)}function g(e){e.target.nodeName&&"html"===e.target.nodeName.toLowerCase()||(t=!1,f())}document.addEventListener("keydown",c,!0),document.addEventListener("mousedown",u,!0),document.addEventListener("pointerdown",u,!0),document.addEventListener("touchstart",u,!0),document.addEventListener("visibilitychange",p,!0),m(),e.addEventListener("focus",h,!0),e.addEventListener("blur",d,!0),e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host?e.host.setAttribute("data-js-focus-visible",""):e.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if("undefined"!=typeof window&&"undefined"!=typeof document){var t;window.applyFocusVisiblePolyfill=e;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(e){
88
+ (t=document.createEvent("CustomEvent")).initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}"undefined"!=typeof document&&e(document)}(),"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.6.5",n,{Fragment:m,Component:f});var Ar={};function Er(e){return e.type===m?"Fragment":"function"==typeof e.type?e.type.displayName||e.type.name:"string"==typeof e.type?e.type:"#text"}var Tr=[],Nr=[];function Lr(){return Tr.length>0?Tr[Tr.length-1]:null}var Mr=!1;function zr(e){return"function"==typeof e.type&&e.type!=m}function Or(e){for(var t=[e],n=e;null!=n.__o;)t.push(n.__o),n=n.__o;return t.reduce((function(e,t){e+=" in "+Er(t);var n=t.__source;return n?e+=" (at "+n.fileName+":"+n.lineNumber+")":Mr||(Mr=!0,console.warn("Add @babel/plugin-transform-react-jsx-source to get a more detailed component stack. Note that you should not add it to production builds of your App for bundle size reasons.")),e+"\n"}),"")}
89
+ var Ir="function"==typeof WeakMap,Rr=f.prototype.setState;f.prototype.setState=function(e,t){return null==this.__v?null==this.state&&console.warn('Calling "this.setState" inside the constructor of a component is a no-op and might be a bug in your application. Instead, set "this.state = {}" directly.\n\n'+Or(Lr())):null==this.__P&&console.warn('Can\'t call "this.setState" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+Or(this.__v)),Rr.call(this,e,t)};var Pr=f.prototype.forceUpdate;function Dr(e){var t=e.props,n=Er(e),r="";for(var o in t)if(t.hasOwnProperty(o)&&"children"!==o){var i=t[o];"function"==typeof i&&(i="function "+(i.displayName||i.name)+"() {}"),i=Object(i)!==i||i.toString?i+"":Object.prototype.toString.call(i),r+=" "+o+"="+JSON.stringify(i)}var a=t.children;return"<"+n+r+(a&&a.length?">..</"+n+">":" />")}f.prototype.forceUpdate=function(e){
90
90
  return null==this.__v?console.warn('Calling "this.forceUpdate" inside the constructor of a component is a no-op and might be a bug in your application.\n\n'+Or(Lr())):null==this.__P&&console.warn('Can\'t call "this.forceUpdate" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+Or(this.__v)),Pr.call(this,e)},function(){!function(){var e=n.__b,t=n.diffed,r=n.__,o=n.vnode,i=n.__r;n.diffed=function(e){zr(e)&&Nr.pop(),Tr.pop(),t&&t(e)},n.__b=function(t){zr(t)&&Tr.push(t),e&&e(t)},n.__=function(e,t){Nr=[],r&&r(e,t)},n.vnode=function(e){e.__o=Nr.length>0?Nr[Nr.length-1]:null,o&&o(e)},n.__r=function(e){zr(e)&&Nr.push(e),i&&i(e)}}();var e=!1,t=n.__b,r=n.diffed,o=n.vnode,i=n.__e,a=n.__,s=n.__h,l=Ir?{useEffect:new WeakMap,useLayoutEffect:new WeakMap,lazyPropTypes:new WeakMap}:null,c=[];n.__e=function(e,t,n){if(t&&t.__c&&"function"==typeof e.then){var r=e
91
91
  ;e=new Error("Missing Suspense. The throwing component was: "+Er(t));for(var o=t;o;o=o.__)if(o.__c&&o.__c.__c){e=r;break}if(e instanceof Error)throw e}try{i(e,t,n),"function"!=typeof e.then&&setTimeout((function(){throw e}))}catch(e){throw e}},n.__=function(e,t){if(!t)throw new Error("Undefined parent passed to render(), this is the second argument.\nCheck if the element is available in the DOM/has the correct id.");var n;switch(t.nodeType){case 1:case 11:case 9:n=!0;break;default:n=!1}if(!n){var r=Er(e);throw new Error("Expected a valid HTML node as a second argument to render.\tReceived "+t+" instead: render(<"+r+" />, "+t+");")}a&&a(e,t)},n.__b=function(n){var r=n.type,o=function e(t){return t?"function"==typeof t.type?e(t.__):t:{}}(n.__);if(e=!0,void 0===r)throw new Error("Undefined component passed to createElement()\n\nYou likely forgot to export your component or might have mixed up default and named imports"+Dr(n)+"\n\n"+Or(n));if(null!=r&&"object"==typeof r){
92
92
  if(void 0!==r.__k&&void 0!==r.__e)throw new Error("Invalid type passed to createElement(): "+r+"\n\nDid you accidentally pass a JSX literal as JSX twice?\n\n let My"+Er(n)+" = "+Dr(r)+";\n let vnode = <My"+Er(n)+" />;\n\nThis usually happens when you export a JSX literal and not the component.\n\n"+Or(n));throw new Error("Invalid type passed to createElement(): "+(Array.isArray(r)?"array":r))}if("thead"!==r&&"tfoot"!==r&&"tbody"!==r||"table"===o.type?"tr"===r&&"thead"!==o.type&&"tfoot"!==o.type&&"tbody"!==o.type&&"table"!==o.type?console.error("Improper nesting of table. Your <tr> should have a <thead/tbody/tfoot/table> parent."+Dr(n)+"\n\n"+Or(n)):"td"===r&&"tr"!==o.type?console.error("Improper nesting of table. Your <td> should have a <tr> parent."+Dr(n)+"\n\n"+Or(n)):"th"===r&&"tr"!==o.type&&console.error("Improper nesting of table. Your <th> should have a <tr>."+Dr(n)+"\n\n"+Or(n)):console.error("Improper nesting of table. Your <thead/tbody/tfoot> should have a <table> parent."+Dr(n)+"\n\n"+Or(n)),
@@ -94,9 +94,9 @@ void 0!==n.ref&&"function"!=typeof n.ref&&"object"!=typeof n.ref&&!("$$typeof"in
94
94
  Object.keys(e).forEach((function(n){var i;try{i=e[n](t,n,r,"prop",null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){i=e}!i||i.message in Ar||(Ar[i.message]=!0,console.error("Failed prop type: "+i.message+(o&&"\n"+o()||"")))}))}(n.type.propTypes,c,0,Er(n),(function(){return Or(n)}))}t&&t(n)},n.__h=function(t,n,r){if(!t||!e)throw new Error("Hook can only be invoked from render methods.");s&&s(t,n,r)};var u=function(e,t){return{get:function(){var n="get"+e+t;c&&c.indexOf(n)<0&&(c.push(n),console.warn("getting vnode."+e+" is deprecated, "+t))},set:function(){var n="set"+e+t;c&&c.indexOf(n)<0&&(c.push(n),console.warn("setting vnode."+e+" is not allowed, "+t))}}},h={nodeName:u("nodeName","use vnode.type"),attributes:u("attributes","use vnode.props"),children:u("children","use vnode.props.children")},d=Object.create({},h);n.vnode=function(e){var t=e.props;if(null!==e.type&&null!=t&&("__source"in t||"__self"in t)){var n=e.props={};for(var r in t){var i=t[r]
95
95
  ;"__source"===r?e.__source=i:"__self"===r?e.__self=i:n[r]=i}}e.__proto__=d,o&&o(e)},n.diffed=function(t){if(t.__k&&t.__k.forEach((function(e){if(e&&void 0===e.type){delete e.__,delete e.__b;var n=Object.keys(e).join(",");throw new Error("Objects are not valid as a child. Encountered an object with the keys {"+n+"}.\n\n"+Or(t))}})),e=!1,r&&r(t),null!=t.__k)for(var n=[],o=0;o<t.__k.length;o++){var i=t.__k[o];if(i&&null!=i.key){var a=i.key;if(-1!==n.indexOf(a)){console.error('Following component has two or more children with the same key attribute: "'+a+'". This may cause glitches and misbehavior in rendering process. Component: \n\n'+Dr(t)+"\n\n"+Or(t));break}n.push(a)}}}}();var Br={exports:{}};!function(e){!function(){var t={}.hasOwnProperty;function n(){for(var e=[],r=0;r<arguments.length;r++){var o=arguments[r];if(o){var i=typeof o;if("string"===i||"number"===i)e.push(o);else if(Array.isArray(o)){if(o.length){var a=n.apply(null,o);a&&e.push(a)}
96
96
  }else if("object"===i)if(o.toString===Object.prototype.toString)for(var s in o)t.call(o,s)&&o[s]&&e.push(s);else e.push(o.toString())}}return e.join(" ")}e.exports?(n.default=n,e.exports=n):window.classNames=n}()}(Br);var Fr,jr,Hr,Ur=Br.exports,qr=0,$r=[],Gr=n.__b,Vr=n.__r,Wr=n.diffed,Yr=n.__c,Kr=n.unmount;function Xr(e,t){n.__h&&n.__h(jr,e,qr||t),qr=0;var r=jr.__H||(jr.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function Zr(e){return qr=1,Jr(uo,e)}function Jr(e,t,n){var r=Xr(Fr++,2);return r.t=e,r.__c||(r.__=[n?n(t):uo(void 0,t),function(e){var t=r.t(r.__[0],e);r.__[0]!==t&&(r.__=[t,r.__[1]],r.__c.setState({}))}],r.__c=jr),r.__}function Qr(e,t){var r=Xr(Fr++,3);!n.__s&&co(r.__H,t)&&(r.__=e,r.__H=t,jr.__H.__h.push(r))}function eo(e,t){var r=Xr(Fr++,4);!n.__s&&co(r.__H,t)&&(r.__=e,r.__H=t,jr.__h.push(r))}function to(e){return qr=5,no((function(){return{current:e}}),[])}function no(e,t){var n=Xr(Fr++,7);return co(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ro(e,t){return qr=8,
97
- no((function(){return e}),t)}function oo(e){var t=jr.context[e.__c],n=Xr(Fr++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(jr)),t.props.value):e.__}function io(){var e;for($r.sort((function(e,t){return e.__v.__b-t.__v.__b}));e=$r.pop();)if(e.__P)try{e.__H.__h.forEach(so),e.__H.__h.forEach(lo),e.__H.__h=[]}catch(t){e.__H.__h=[],n.__e(t,e.__v)}}n.__b=function(e){jr=null,Gr&&Gr(e)},n.__r=function(e){Vr&&Vr(e),Fr=0;var t=(jr=e.__c).__H;t&&(t.__h.forEach(so),t.__h.forEach(lo),t.__h=[])},n.diffed=function(e){Wr&&Wr(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==$r.push(t)&&Hr===n.requestAnimationFrame||((Hr=n.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),ao&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);ao&&(t=requestAnimationFrame(n))})(io)),jr=null},n.__c=function(e,t){t.some((function(e){try{e.__h.forEach(so),e.__h=e.__h.filter((function(e){return!e.__||lo(e)}))}catch(r){t.some((function(e){e.__h&&(e.__h=[])})),t=[],n.__e(r,e.__v)}})),Yr&&Yr(e,t)},n.unmount=function(e){
98
- Kr&&Kr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach((function(e){try{so(e)}catch(e){t=e}})),t&&n.__e(t,r.__v))};var ao="function"==typeof requestAnimationFrame;function so(e){var t=jr,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),jr=t}function lo(e){var t=jr;e.__c=e.__(),jr=t}function co(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function uo(e,t){return"function"==typeof t?t(e):t}var ho=0;function po(e,t,r,o,i){var a,s,l={};for(s in t)"ref"==s?a=t[s]:l[s]=t[s];var c={type:e,props:l,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--ho,__source:o,__self:i};if("function"==typeof e&&(a=e.defaultProps))for(s in a)void 0===l[s]&&(l[s]=a[s]);return n.vnode&&n.vnode(c),c}const mo=new Map;function fo({name:e,className:t="",inline:n=!1,title:r=""}){const o=mo.get(e);if(!o)throw new Error(`Icon "${e.toString()}" is not registered`);const i=to();eo((()=>{const e=i.current.querySelector("svg");e&&e.setAttribute("class",t)}),[t,o])
99
- ;const a={};return r&&(a.title=r),po("span",{className:Ur("Hyp-SvgIcon",{"Hyp-SvgIcon--inline":n}),dangerouslySetInnerHTML:{__html:o},ref:i,...a},void 0,!1,{fileName:"/home/runner/work/frontend-shared/frontend-shared/src/components/SvgIcon.js",lineNumber:69,columnNumber:5})}function go(e,t){const n="string"==typeof e?Symbol(e):e;return mo.set(n,t),n}var vo="/home/runner/work/frontend-shared/frontend-shared/src/components/buttons.js";function yo({buttonRef:e,classes:t,className:n,icon:r,iconPosition:o="left",size:i="medium",variant:a="normal",expanded:s,pressed:l,type:c="button",...u}){var h;const d=null!==(h=null==u?void 0:u.role)&&void 0!==h?h:"button",p={"aria-label":u.title};return"tab"===d?p["aria-selected"]=l:(p["aria-pressed"]=l,p["aria-expanded"]=s),po("button",{ref:e,className:Ur(n,`${n}--${i}`,`${n}--${a}`,{[`${n}--icon-${o}`]:r},t),type:c,...p,...u},void 0,!1,{fileName:vo,lineNumber:82,columnNumber:5})}function _o({className:e="Hyp-IconButton",...t}){const{icon:n}=t;return po(yo,{className:e,...t,
97
+ no((function(){return e}),t)}function oo(e){var t=jr.context[e.__c],n=Xr(Fr++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(jr)),t.props.value):e.__}function io(){for(var e;e=$r.shift();)if(e.__P)try{e.__H.__h.forEach(so),e.__H.__h.forEach(lo),e.__H.__h=[]}catch(t){e.__H.__h=[],n.__e(t,e.__v)}}n.__b=function(e){jr=null,Gr&&Gr(e)},n.__r=function(e){Vr&&Vr(e),Fr=0;var t=(jr=e.__c).__H;t&&(t.__h.forEach(so),t.__h.forEach(lo),t.__h=[])},n.diffed=function(e){Wr&&Wr(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==$r.push(t)&&Hr===n.requestAnimationFrame||((Hr=n.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),ao&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);ao&&(t=requestAnimationFrame(n))})(io)),jr=null},n.__c=function(e,t){t.some((function(e){try{e.__h.forEach(so),e.__h=e.__h.filter((function(e){return!e.__||lo(e)}))}catch(r){t.some((function(e){e.__h&&(e.__h=[])})),t=[],n.__e(r,e.__v)}})),Yr&&Yr(e,t)},n.unmount=function(e){Kr&&Kr(e);var t,r=e.__c
98
+ ;r&&r.__H&&(r.__H.__.forEach((function(e){try{so(e)}catch(e){t=e}})),t&&n.__e(t,r.__v))};var ao="function"==typeof requestAnimationFrame;function so(e){var t=jr,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),jr=t}function lo(e){var t=jr;e.__c=e.__(),jr=t}function co(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function uo(e,t){return"function"==typeof t?t(e):t}var ho=0;function po(e,t,r,o,i){var a,s,l={};for(s in t)"ref"==s?a=t[s]:l[s]=t[s];var c={type:e,props:l,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--ho,__source:o,__self:i};if("function"==typeof e&&(a=e.defaultProps))for(s in a)void 0===l[s]&&(l[s]=a[s]);return n.vnode&&n.vnode(c),c}const mo=new Map;function fo({name:e,className:t="",inline:n=!1,title:r=""}){const o=mo.get(e);if(!o)throw new Error(`Icon "${e.toString()}" is not registered`);const i=to();eo((()=>{const e=i.current.querySelector("svg");e&&e.setAttribute("class",t)}),[t,o]);const a={}
99
+ ;return r&&(a.title=r),po("span",{className:Ur("Hyp-SvgIcon",{"Hyp-SvgIcon--inline":n}),dangerouslySetInnerHTML:{__html:o},ref:i,...a},void 0,!1,{fileName:"/home/runner/work/frontend-shared/frontend-shared/src/components/SvgIcon.js",lineNumber:69,columnNumber:5})}function go(e,t){const n="string"==typeof e?Symbol(e):e;return mo.set(n,t),n}var vo="/home/runner/work/frontend-shared/frontend-shared/src/components/buttons.js";function yo({buttonRef:e,classes:t,className:n,icon:r,iconPosition:o="left",size:i="medium",variant:a="normal",expanded:s,pressed:l,type:c="button",...u}){var h;const d=null!==(h=null==u?void 0:u.role)&&void 0!==h?h:"button",p={"aria-label":u.title};return"tab"===d?p["aria-selected"]=l:(p["aria-pressed"]=l,p["aria-expanded"]=s),po("button",{ref:e,className:Ur(n,`${n}--${i}`,`${n}--${a}`,{[`${n}--icon-${o}`]:r},t),type:c,...p,...u},void 0,!1,{fileName:vo,lineNumber:82,columnNumber:5})}function _o({className:e="Hyp-IconButton",...t}){const{icon:n}=t;return po(yo,{className:e,...t,
100
100
  children:po(fo,{name:n},void 0,!1,{fileName:vo,lineNumber:109,columnNumber:7})},void 0,!1,{fileName:vo,lineNumber:108,columnNumber:5})}function bo({children:e,className:t="Hyp-LabeledButton",...n}){const{icon:r,iconPosition:o="left"}=n;return po(yo,{className:t,...n,children:[r&&"left"===o&&po(fo,{name:r},void 0,!1,{fileName:vo,lineNumber:127,columnNumber:43}),e,r&&"right"===o&&po(fo,{name:r},void 0,!1,{fileName:vo,lineNumber:129,columnNumber:44})]},void 0,!0,{fileName:vo,lineNumber:126,columnNumber:5})}function wo(e){return po(yo,{className:"Hyp-LinkButton",...e},void 0,!1,{fileName:vo,lineNumber:140,columnNumber:10})}
101
101
  go("checkbox",' <svg\n width="32"\n height="32"\n viewBox="-4 -4 39 39"\n aria-hidden="true"\n focusable="false"\n >\n <rect\n class="hyp-svg-checkbox--background"\n width="35"\n height="35"\n x="-2"\n y="-2"\n stroke="currentColor"\n fill="none"\n stroke-width="3"\n rx="5"\n ry="5"\n />\n <polyline\n class="hyp-svg-checkbox--checkmark"\n points="4,14 12,23 28,5"\n stroke="transparent"\n stroke-width="5"\n fill="none"\n />\n</svg>');var xo="/home/runner/work/frontend-shared/frontend-shared/src/components/containers.js";function ko({children:e,classes:t="",containerRef:n}){return po("div",{className:Ur("Hyp-Frame",t),ref:n,children:e},void 0,!1,{fileName:xo,lineNumber:26,columnNumber:5})}function So({children:e,direction:t="row",classes:n="",containerRef:r}){return po("div",{className:Ur(`Hyp-Actions--${t}`,n),ref:r,children:e},void 0,!1,{fileName:xo,lineNumber:72,columnNumber:5})}
102
102
  var Co='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><g fill-rule="evenodd"><rect fill="none" stroke="none" x="0" y="0" width="16" height="16"></rect><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 8l3.536-3.536L8 8 4.464 4.464 8 8zm0 0l-3.536 3.536L8 8l3.536 3.536L8 8z"></path></g></svg>\n',Ao="/home/runner/work/frontend-shared/frontend-shared/src/components/Dialog.js";const Eo=go("cancel",Co);let To=0;function No(e){const[t]=Zr((()=>(++To,`${e}-${To}`)));return t}function Lo({buttons:e,cancelLabel:t="Cancel",children:n,contentClass:r,icon:o,initialFocus:i,onCancel:a,role:s="dialog",title:l,withCancelButton:c=!0,withCloseButton:u=!0}){const h=No("dialog-description"),d=No("dialog-title"),p=to(null);Qr((()=>{if(null!==i){const e=null==i?void 0:i.current;e&&!e.disabled?e.focus():p.current.focus()}}),[]),eo((()=>{const e=p.current.querySelector("p");e&&(e.id=h,
@@ -157,7 +157,7 @@ this._listeners.forEach((({eventTarget:e,eventType:t,listener:n})=>{e.removeEven
157
157
  t.setSelectionRange(0,t.value.length),document.execCommand("copy")}finally{t.remove()}}function wa({label:e,iconName:t,uri:n}){return po("li",{className:"ShareLinks__link",children:po("a",{"aria-label":e,href:n,title:e,target:"_blank",rel:"noopener noreferrer",children:po(Mo,{name:t,classes:"ShareLinks__icon"})})})}function xa({shareURI:e}){const t=encodeURIComponent(e);return po("ul",{className:"ShareLinks",children:[po(wa,{iconName:"twitter",label:"Tweet share link",uri:`https://twitter.com/intent/tweet?url=${t}&hashtags=annotated`}),po(wa,{iconName:"facebook",label:"Share on Facebook",uri:`https://www.facebook.com/sharer/sharer.php?u=${t}`}),po(wa,{iconName:"email",label:"Share via email",uri:`mailto:?subject=${encodeURIComponent("Let's Annotate")}&body=${t}`})]})}function ka(){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)()}
158
158
  var Sa=ri((function({annotation:e,toastMessenger:t,group:n,shareUri:r}){const o=_a(e.permissions),i=ma(e.uri),a=to(null),s=to(null),[l,c]=Zr(!1),u=to(l);if(Ro(a,l,(()=>c(!1))),Qr((()=>{var e,t;u.current!==l&&(u.current=l,l&&!ka()&&(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?po("span",{children:["Only members of the group ",po("em",{children:n.name})," may view this annotation."]}):po("span",{children:"Anyone using this link may view this annotation."}),p=o?po("span",{children:"Only you may view this annotation."}):d;return po("div",{className:"AnnotationShareControl",ref:a,children:[po(_o,{icon:"share",title:"Share",onClick:()=>c(!l),expanded:l}),l&&po("div",{className:"annotation-share-panel",children:[po("div",{className:"annotation-share-panel__header",children:po("div",{className:"annotation-share-panel__title",children:"Share this annotation"})}),po("div",{className:"annotation-share-panel__content",
159
159
  children:[po("div",{className:"hyp-u-layout-row annotation-share-panel__inputs",children:po(Vo,{children:[po(Go,{"aria-label":"Use this URL to share this annotation",type:"text",value:r,readOnly:!0,inputRef:s}),po(_o,{icon:"copy",title:"Copy share link to clipboard",onClick:()=>{try{ba(r),t.success("Copied share link to clipboard")}catch(e){t.error("Unable to copy link")}},variant:"dark"})]})}),po("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&&po(xa,{shareURI:r})]}),po(Mo,{name:"pointer",classes:"annotation-share-panel__arrow"})]})]})}),["toastMessenger"]);var Ca=ri((function({annotation:e,annotationsService:t,onReply:n,settings:r,toastMessenger:o}){const i=ii(),a=i.profile(),s=i.getGroup(e.group),l=i.isLoggedIn(),c=t=>function(e,t,n){return-1!==e[t].indexOf(n||"")
160
- }(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 ma(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 po("div",{className:"AnnotationActionBar hyp-u-layout-row u-font--xlarge",children:[h&&po(_o,{icon:"edit",title:"Edit",onClick:()=>{i.createDraft(e,{tags:e.tags,text:e.text,isPrivate:_a(e.permissions)})}}),u&&po(_o,{icon:"trash",title:"Delete",onClick:async()=>{if(await Xo({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)}}}),po(_o,{icon:"reply",title:"Reply",onClick:()=>{
160
+ }(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 ma(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 po("div",{className:"AnnotationActionBar hyp-u-layout-row text-xl font-medium",children:[h&&po(_o,{icon:"edit",title:"Edit",onClick:()=>{i.createDraft(e,{tags:e.tags,text:e.text,isPrivate:_a(e.permissions)})}}),u&&po(_o,{icon:"trash",title:"Delete",onClick:async()=>{if(await Xo({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)}}}),po(_o,{icon:"reply",title:"Reply",onClick:()=>{
161
161
  l?n():i.openSidebarPanel("loginPrompt")}}),p&&po(Sa,{annotation:e,group:s,shareUri:p}),d&&!e.flagged&&po(_o,{icon:"flag",title:"Report this annotation to moderators",onClick:()=>{t.flag(e).catch((()=>o.error("Flagging annotation failed")))}}),d&&e.flagged&&po(_o,{pressed:!0,icon:"flag--active",title:"Annotation has been reported to the moderators"})]})}),["annotationsService","settings","toastMessenger"]);function Aa({isCollapsed:e,setCollapsed:t,linkStyle:n={}}){return po("div",{className:"Excerpt__inline-controls",children:po("div",{className:"Excerpt__toggle-container",children:po(wo,{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 Ea=()=>{};var Ta=ri((function({children:e,collapse:t=!1,collapsedHeight:n,inlineControls:r=!0,onCollapsibleChanged:o=Ea,onToggleCollapsed:i=Ea,overflowThreshold:a=0,settings:s={}}){const[l,c]=Zr(!0),u=to(),[h,d]=Zr(0),p=ro((()=>{
162
162
  const e=u.current.clientHeight;d(e);o(e>n+a)}),[n,o,a]);eo((()=>{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 ha;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 po("div",{className:"Excerpt",style:g,children:[po("div",{className:"Excerpt__content",ref:u,children:e}),po("div",{role:"presentation",onClick:()=>v(!1),className:Ur({Excerpt__shadow:!0,"Excerpt__shadow--transparent":r,"is-hidden":!f}),title:"Show the full excerpt"}),m&&r&&po(Aa,{isCollapsed:l,setCollapsed:v,
163
163
  linkStyle:ti(["selectionFontFamily"],s)})]})}),["settings"]);function Na(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 La(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 Ma(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",La(o)):r.append(e,o));r.sort();let o=r.toString();return o&&(o=`?${o}`),o}(t);return Na(`https://www.youtube.com/embed/${e}${n}`)}function za(e,t,n,{aspectRatio:r}={}){return o=>{if(o.hostname!==e)return null
@@ -165,10 +165,10 @@ linkStyle:ti(["selectionFontFamily"],s)})]})}),["settings"]);function Na(e,t=16/
165
165
  const a=new URL(`https://archive.org/embed/${n}`);return o&&a.searchParams.append("start",o),i&&a.searchParams.append("end",i),Na(a.href)},function(e){return e.pathname.endsWith(".mp3")||e.pathname.endsWith(".ogg")||e.pathname.endsWith(".wav")?function(e){const t=document.createElement("audio");return t.controls=!0,t.src=e,t}(e.href):null}];function Ia(e){if(e.href!==e.textContent&&decodeURI(e.href)!==e.textContent)return null;const t=function(e){let t,n;for(n=0;n<Oa.length;n++)if(t=Oa[n](e),t)return t;return null}(e);return t&&e.parentElement.replaceChild(t,e),t}var Ra=Object.hasOwnProperty,Pa=Object.setPrototypeOf,Da=Object.isFrozen,Ba=Object.getPrototypeOf,Fa=Object.getOwnPropertyDescriptor,ja=Object.freeze,Ha=Object.seal,Ua=Object.create,qa="undefined"!=typeof Reflect&&Reflect,$a=qa.apply,Ga=qa.construct;$a||($a=function(e,t,n){return e.apply(t,n)}),ja||(ja=function(e){return e}),Ha||(Ha=function(e){return e}),Ga||(Ga=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){
166
166
  if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))});var Va,Wa=rs(Array.prototype.forEach),Ya=rs(Array.prototype.pop),Ka=rs(Array.prototype.push),Xa=rs(String.prototype.toLowerCase),Za=rs(String.prototype.match),Ja=rs(String.prototype.replace),Qa=rs(String.prototype.indexOf),es=rs(String.prototype.trim),ts=rs(RegExp.prototype.test),ns=(Va=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ga(Va,t)});function rs(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return $a(e,t,r)}}function os(e,t){Pa&&Pa(e,null);for(var n=t.length;n--;){var r=t[n];if("string"==typeof r){var o=Xa(r);o!==r&&(Da(t)||(t[n]=o),r=o)}e[r]=!0}return e}function is(e){var t=Ua(null),n=void 0;for(n in e)$a(Ra,e,[n])&&(t[n]=e[n]);return t}function as(e,t){for(;null!==e;){var n=Fa(e,t);if(n){if(n.get)return rs(n.get);if("function"==typeof n.value)return rs(n.value)}e=Ba(e)}
167
167
  return function(e){return console.warn("fallback value for",e),null}}
168
- var ss=ja(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ls=ja(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),cs=ja(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),us=ja(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),hs=ja(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),ds=ja(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ps=ja(["#text"]),ms=ja(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),fs=ja(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),gs=ja(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),vs=ja(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ys=Ha(/\{\{[\s\S]*|[\s\S]*\}\}/gm),_s=Ha(/<%[\s\S]*|[\s\S]*%>/gm),bs=Ha(/^data-[\-\w.\u00B7-\uFFFF]/),ws=Ha(/^aria-[\-\w]+$/),xs=Ha(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ks=Ha(/^(?:\w+script|data):/i),Ss=Ha(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){
169
- return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function As(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var Es=function(){return"undefined"==typeof window?null:window},Ts=function(e,t){if("object"!==(void 0===e?"undefined":Cs(e))||"function"!=typeof e.createPolicy)return null;var n=null,r="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(r)&&(n=t.currentScript.getAttribute(r));var o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};var Ns=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Es(),n=function(t){return e(t)};if(n.version="2.3.4",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n
170
- ;var r=t.document,o=t.document,i=t.DocumentFragment,a=t.HTMLTemplateElement,s=t.Node,l=t.Element,c=t.NodeFilter,u=t.NamedNodeMap,h=void 0===u?t.NamedNodeMap||t.MozNamedAttrMap:u,d=t.HTMLFormElement,p=t.DOMParser,m=t.trustedTypes,f=l.prototype,g=as(f,"cloneNode"),v=as(f,"nextSibling"),y=as(f,"childNodes"),_=as(f,"parentNode");if("function"==typeof a){var b=o.createElement("template");b.content&&b.content.ownerDocument&&(o=b.content.ownerDocument)}var w=Ts(m,r),x=w&&ee?w.createHTML(""):"",k=o,S=k.implementation,C=k.createNodeIterator,A=k.createDocumentFragment,E=k.getElementsByTagName,T=r.importNode,N={};try{N=is(o).documentMode?o.documentMode:{}}catch(e){}var L={};n.isSupported="function"==typeof _&&S&&void 0!==S.createHTMLDocument&&9!==N;var M=ys,z=_s,O=bs,I=ws,R=ks,P=Ss,D=xs,B=null,F=os({},[].concat(As(ss),As(ls),As(cs),As(hs),As(ps))),j=null,H=os({},[].concat(As(ms),As(fs),As(gs),As(vs))),U=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},
171
- attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),q=null,$=null,G=!0,V=!0,W=!1,Y=!1,K=!1,X=!1,Z=!1,J=!1,Q=!1,ee=!1,te=!0,ne=!0,re=!1,oe={},ie=null,ae=os({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),se=null,le=os({},["audio","video","img","source","image","track"]),ce=null,ue=os({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),he="http://www.w3.org/1998/Math/MathML",de="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml",me=pe,fe=!1,ge=void 0,ve=["application/xhtml+xml","text/html"],ye="text/html",_e=void 0,be=null,we=o.createElement("form"),xe=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){
168
+ var ss=ja(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ls=ja(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),cs=ja(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),us=ja(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),hs=ja(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),ds=ja(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ps=ja(["#text"]),ms=ja(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),fs=ja(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),gs=ja(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),vs=ja(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ys=Ha(/\{\{[\s\S]*|[\s\S]*\}\}/gm),_s=Ha(/<%[\s\S]*|[\s\S]*%>/gm),bs=Ha(/^data-[\-\w.\u00B7-\uFFFF]/),ws=Ha(/^aria-[\-\w]+$/),xs=Ha(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ks=Ha(/^(?:\w+script|data):/i),Ss=Ha(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){
169
+ return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function As(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var Es=function(){return"undefined"==typeof window?null:window},Ts=function(e,t){if("object"!==(void 0===e?"undefined":Cs(e))||"function"!=typeof e.createPolicy)return null;var n=null,r="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(r)&&(n=t.currentScript.getAttribute(r));var o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};var Ns=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Es(),n=function(t){return e(t)};if(n.version="2.3.5",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n
170
+ ;var r=t.document,o=t.document,i=t.DocumentFragment,a=t.HTMLTemplateElement,s=t.Node,l=t.Element,c=t.NodeFilter,u=t.NamedNodeMap,h=void 0===u?t.NamedNodeMap||t.MozNamedAttrMap:u,d=t.HTMLFormElement,p=t.DOMParser,m=t.trustedTypes,f=l.prototype,g=as(f,"cloneNode"),v=as(f,"nextSibling"),y=as(f,"childNodes"),_=as(f,"parentNode");if("function"==typeof a){var b=o.createElement("template");b.content&&b.content.ownerDocument&&(o=b.content.ownerDocument)}var w=Ts(m,r),x=w?w.createHTML(""):"",k=o,S=k.implementation,C=k.createNodeIterator,A=k.createDocumentFragment,E=k.getElementsByTagName,T=r.importNode,N={};try{N=is(o).documentMode?o.documentMode:{}}catch(e){}var L={};n.isSupported="function"==typeof _&&S&&void 0!==S.createHTMLDocument&&9!==N;var M=ys,z=_s,O=bs,I=ws,R=ks,P=Ss,D=xs,B=null,F=os({},[].concat(As(ss),As(ls),As(cs),As(hs),As(ps))),j=null,H=os({},[].concat(As(ms),As(fs),As(gs),As(vs))),U=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{
171
+ writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),q=null,$=null,G=!0,V=!0,W=!1,Y=!1,K=!1,X=!1,Z=!1,J=!1,Q=!1,ee=!1,te=!0,ne=!0,re=!1,oe={},ie=null,ae=os({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),se=null,le=os({},["audio","video","img","source","image","track"]),ce=null,ue=os({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),he="http://www.w3.org/1998/Math/MathML",de="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml",me=pe,fe=!1,ge=void 0,ve=["application/xhtml+xml","text/html"],ye="text/html",_e=void 0,be=null,we=o.createElement("form"),xe=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){
172
172
  be&&be===e||(e&&"object"===(void 0===e?"undefined":Cs(e))||(e={}),e=is(e),B="ALLOWED_TAGS"in e?os({},e.ALLOWED_TAGS):F,j="ALLOWED_ATTR"in e?os({},e.ALLOWED_ATTR):H,ce="ADD_URI_SAFE_ATTR"in e?os(is(ue),e.ADD_URI_SAFE_ATTR):ue,se="ADD_DATA_URI_TAGS"in e?os(is(le),e.ADD_DATA_URI_TAGS):le,ie="FORBID_CONTENTS"in e?os({},e.FORBID_CONTENTS):ae,q="FORBID_TAGS"in e?os({},e.FORBID_TAGS):{},$="FORBID_ATTR"in e?os({},e.FORBID_ATTR):{},oe="USE_PROFILES"in e&&e.USE_PROFILES,G=!1!==e.ALLOW_ARIA_ATTR,V=!1!==e.ALLOW_DATA_ATTR,W=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Y=e.SAFE_FOR_TEMPLATES||!1,K=e.WHOLE_DOCUMENT||!1,J=e.RETURN_DOM||!1,Q=e.RETURN_DOM_FRAGMENT||!1,ee=e.RETURN_TRUSTED_TYPE||!1,Z=e.FORCE_BODY||!1,te=!1!==e.SANITIZE_DOM,ne=!1!==e.KEEP_CONTENT,re=e.IN_PLACE||!1,D=e.ALLOWED_URI_REGEXP||D,me=e.NAMESPACE||pe,e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),
173
173
  e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(U.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ge=ge=-1===ve.indexOf(e.PARSER_MEDIA_TYPE)?ye:e.PARSER_MEDIA_TYPE,_e="application/xhtml+xml"===ge?function(e){return e}:Xa,Y&&(V=!1),Q&&(J=!0),oe&&(B=os({},[].concat(As(ps))),j=[],!0===oe.html&&(os(B,ss),os(j,ms)),!0===oe.svg&&(os(B,ls),os(j,fs),os(j,vs)),!0===oe.svgFilters&&(os(B,cs),os(j,fs),os(j,vs)),!0===oe.mathMl&&(os(B,hs),os(j,gs),os(j,vs))),e.ADD_TAGS&&(B===F&&(B=is(B)),os(B,e.ADD_TAGS)),e.ADD_ATTR&&(j===H&&(j=is(j)),os(j,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&os(ce,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(ie===ae&&(ie=is(ie)),os(ie,e.FORBID_CONTENTS)),ne&&(B["#text"]=!0),K&&os(B,["html","head","body"]),B.table&&(os(B,["tbody"]),delete q.tbody),ja&&ja(e),be=e)
174
174
  },Se=os({},["mi","mo","mn","ms","mtext"]),Ce=os({},["foreignobject","desc","title","annotation-xml"]),Ae=os({},ls);os(Ae,cs),os(Ae,us);var Ee=os({},hs);os(Ee,ds);var Te=function(e){var t=_(e);t&&t.tagName||(t={namespaceURI:pe,tagName:"template"});var n=Xa(e.tagName),r=Xa(t.tagName);if(e.namespaceURI===de)return t.namespaceURI===pe?"svg"===n:t.namespaceURI===he?"svg"===n&&("annotation-xml"===r||Se[r]):Boolean(Ae[n]);if(e.namespaceURI===he)return t.namespaceURI===pe?"math"===n:t.namespaceURI===de?"math"===n&&Ce[r]:Boolean(Ee[n]);if(e.namespaceURI===pe){if(t.namespaceURI===de&&!Ce[r])return!1;if(t.namespaceURI===he&&!Se[r])return!1;var o=os({},["title","style","font","a","script"]);return!Ee[n]&&(o[n]||!Ae[n])}return!1},Ne=function(e){Ka(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=x}catch(t){e.remove()}}},Le=function(e,t){try{Ka(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Ka(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),
@@ -176,12 +176,12 @@ e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U.
176
176
  return e instanceof d&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof h)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},Ie=function(e){return"object"===(void 0===s?"undefined":Cs(s))?e instanceof s:e&&"object"===(void 0===e?"undefined":Cs(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Re=function(e,t,r){L[e]&&Wa(L[e],(function(e){e.call(n,t,r,be)}))},Pe=function(e){var t=void 0;if(Re("beforeSanitizeElements",e,null),Oe(e))return Ne(e),!0;if(Za(e.nodeName,/[\u0080-\uFFFF]/))return Ne(e),!0;var r=_e(e.nodeName);if(Re("uponSanitizeElement",e,{tagName:r,allowedTags:B}),!Ie(e.firstElementChild)&&(!Ie(e.content)||!Ie(e.content.firstElementChild))&&ts(/<[/\w]/g,e.innerHTML)&&ts(/<[/\w]/g,e.textContent))return Ne(e),!0;if("select"===r&&ts(/<template/i,e.innerHTML))return Ne(e),!0;if(!B[r]||q[r]){if(ne&&!ie[r]){
177
177
  var o=_(e)||e.parentNode,i=y(e)||e.childNodes;if(i&&o)for(var a=i.length-1;a>=0;--a)o.insertBefore(g(i[a],!0),v(e))}if(!q[r]&&Be(r)){if(U.tagNameCheck instanceof RegExp&&ts(U.tagNameCheck,r))return!1;if(U.tagNameCheck instanceof Function&&U.tagNameCheck(r))return!1}return Ne(e),!0}return e instanceof l&&!Te(e)?(Ne(e),!0):"noscript"!==r&&"noembed"!==r||!ts(/<\/no(script|embed)/i,e.innerHTML)?(Y&&3===e.nodeType&&(t=e.textContent,t=Ja(t,M," "),t=Ja(t,z," "),e.textContent!==t&&(Ka(n.removed,{element:e.cloneNode()}),e.textContent=t)),Re("afterSanitizeElements",e,null),!1):(Ne(e),!0)},De=function(e,t,n){if(te&&("id"===t||"name"===t)&&(n in o||n in we))return!1;if(V&&!$[t]&&ts(O,t));else if(G&&ts(I,t));else if(!j[t]||$[t]){
178
178
  if(!(Be(e)&&(U.tagNameCheck instanceof RegExp&&ts(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&ts(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t))||"is"===t&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&ts(U.tagNameCheck,n)||U.tagNameCheck instanceof Function&&U.tagNameCheck(n))))return!1}else if(ce[t]);else if(ts(D,Ja(n,P,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Qa(n,"data:")||!se[e]){if(W&&!ts(R,Ja(n,P,"")));else if(n)return!1}else;return!0},Be=function(e){return e.indexOf("-")>0},Fe=function(e){var t=void 0,r=void 0,o=void 0,i=void 0;Re("beforeSanitizeAttributes",e,null);var a=e.attributes;if(a){var s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j};for(i=a.length;i--;){var l=t=a[i],c=l.name,u=l.namespaceURI;if(r=es(t.value),o=_e(c),s.attrName=o,s.attrValue=r,s.keepAttr=!0,s.forceKeepAttr=void 0,Re("uponSanitizeAttribute",e,s),
179
- r=s.attrValue,!s.forceKeepAttr&&(Le(c,e),s.keepAttr))if(ts(/\/>/i,r))Le(c,e);else{Y&&(r=Ja(r,M," "),r=Ja(r,z," "));var h=_e(e.nodeName);if(De(h,o,r))try{u?e.setAttributeNS(u,c,r):e.setAttribute(c,r),Ya(n.removed)}catch(e){}}}Re("afterSanitizeAttributes",e,null)}},je=function e(t){var n=void 0,r=ze(t);for(Re("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)Re("uponSanitizeShadowNode",n,null),Pe(n)||(n.content instanceof i&&e(n.content),Fe(n));Re("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,o){var a=void 0,l=void 0,c=void 0,u=void 0,h=void 0;if((fe=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ie(e)){if("function"!=typeof e.toString)throw ns("toString is not a function");if("string"!=typeof(e=e.toString()))throw ns("dirty is not a string, aborting")}if(!n.isSupported){if("object"===Cs(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Ie(e))return t.toStaticHTML(e.outerHTML)}return e}if(X||ke(o),n.removed=[],"string"==typeof e&&(re=!1),
180
- re);else if(e instanceof s)1===(l=(a=Me("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?a=l:a.appendChild(l);else{if(!J&&!Y&&!K&&-1===e.indexOf("<"))return w&&ee?w.createHTML(e):e;if(!(a=Me(e)))return J?null:x}a&&Z&&Ne(a.firstChild);for(var d=ze(re?e:a);c=d.nextNode();)3===c.nodeType&&c===u||Pe(c)||(c.content instanceof i&&je(c.content),Fe(c),u=c);if(u=null,re)return e;if(J){if(Q)for(h=A.call(a.ownerDocument);a.firstChild;)h.appendChild(a.firstChild);else h=a;return j.shadowroot&&(h=T.call(r,h,!0)),h}var p=K?a.outerHTML:a.innerHTML;return Y&&(p=Ja(p,M," "),p=Ja(p,z," ")),w&&ee?w.createHTML(p):p},n.setConfig=function(e){ke(e),X=!0},n.clearConfig=function(){be=null,X=!1},n.isValidAttribute=function(e,t,n){be||ke({});var r=_e(e),o=_e(t);return De(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(L[e]=L[e]||[],Ka(L[e],t))},n.removeHook=function(e){L[e]&&Ya(L[e])},n.removeHooks=function(e){L[e]&&(L[e]=[])},n.removeAllHooks=function(){L={}},n
181
- }(),Ls=/["'&<>]/,Ms=function(e){var t,n=""+e,r=Ls.exec(n);if(!r)return n;var o="",i=0,a=0;for(i=r.index;i<n.length;i++){switch(n.charCodeAt(i)){case 34:t="&quot;";break;case 38:t="&amp;";break;case 39:t="&#39;";break;case 60:t="&lt;";break;case 62:t="&gt;";break;default:continue}a!==i&&(o+=n.substring(a,i)),a=i+1,o+=t}return a!==i?o+n.substring(a,i):o};class zs{constructor(e,t,n){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=n}static range(e,t){return t?e&&e.loc&&t.loc&&e.loc.lexer===t.loc.lexer?new zs(e.loc.lexer,e.loc.start,t.loc.end):null:e&&e.loc}}class Os{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new Os(t,zs.range(this,e))}}class Is{constructor(e,t){this.position=void 0;var n,r="KaTeX parse error: "+e,o=t&&t.loc;if(o&&o.start<=o.end){var i=o.lexer.input;n=o.start;var a=o.end;n===i.length?r+=" at end of input: ":r+=" at position "+(n+1)+": "
182
- ;var s=i.slice(n,a).replace(/[^]/g,"$&̲");r+=(n>15?"…"+i.slice(n-15,n):i.slice(0,n))+s+(a+15<i.length?i.slice(a,a+15)+"…":i.slice(a))}var l=new Error(r);return l.name="ParseError",l.__proto__=Is.prototype,l.position=n,l}}Is.prototype.__proto__=Error.prototype;var Rs=/([A-Z])/g,Ps={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Ds=/[&><"']/g;var Bs=function e(t){return"ordgroup"===t.type||"color"===t.type?1===t.body.length?e(t.body[0]):t:"font"===t.type?e(t.body):t},Fs={contains:function(e,t){return-1!==e.indexOf(t)},deflt:function(e,t){return void 0===e?t:e},escape:function(e){return String(e).replace(Ds,(e=>Ps[e]))},hyphenate:function(e){return e.replace(Rs,"-$1").toLowerCase()},getBaseElem:Bs,isCharacterBox:function(e){var t=Bs(e);return"mathord"===t.type||"textord"===t.type||"atom"===t.type},protocolFromUrl:function(e){var t=/^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(e);return null!=t?t[1]:"_relative"}},js={displayMode:{type:"boolean",
183
- description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",
184
- cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],
179
+ r=s.attrValue,!s.forceKeepAttr&&(Le(c,e),s.keepAttr))if(ts(/\/>/i,r))Le(c,e);else{Y&&(r=Ja(r,M," "),r=Ja(r,z," "));var h=_e(e.nodeName);if(De(h,o,r))try{u?e.setAttributeNS(u,c,r):e.setAttribute(c,r),Ya(n.removed)}catch(e){}}}Re("afterSanitizeAttributes",e,null)}},je=function e(t){var n=void 0,r=ze(t);for(Re("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)Re("uponSanitizeShadowNode",n,null),Pe(n)||(n.content instanceof i&&e(n.content),Fe(n));Re("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,o){var a=void 0,l=void 0,c=void 0,u=void 0,h=void 0;if((fe=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ie(e)){if("function"!=typeof e.toString)throw ns("toString is not a function");if("string"!=typeof(e=e.toString()))throw ns("dirty is not a string, aborting")}if(!n.isSupported){if("object"===Cs(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Ie(e))return t.toStaticHTML(e.outerHTML)}return e}if(X||ke(o),n.removed=[],"string"==typeof e&&(re=!1),re){
180
+ if(e.nodeName){var d=_e(e.nodeName);if(!B[d]||q[d])throw ns("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)1===(l=(a=Me("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?a=l:a.appendChild(l);else{if(!J&&!Y&&!K&&-1===e.indexOf("<"))return w&&ee?w.createHTML(e):e;if(!(a=Me(e)))return J?null:ee?x:""}a&&Z&&Ne(a.firstChild);for(var p=ze(re?e:a);c=p.nextNode();)3===c.nodeType&&c===u||Pe(c)||(c.content instanceof i&&je(c.content),Fe(c),u=c);if(u=null,re)return e;if(J){if(Q)for(h=A.call(a.ownerDocument);a.firstChild;)h.appendChild(a.firstChild);else h=a;return j.shadowroot&&(h=T.call(r,h,!0)),h}var m=K?a.outerHTML:a.innerHTML;return Y&&(m=Ja(m,M," "),m=Ja(m,z," ")),w&&ee?w.createHTML(m):m},n.setConfig=function(e){ke(e),X=!0},n.clearConfig=function(){be=null,X=!1},n.isValidAttribute=function(e,t,n){be||ke({});var r=_e(e),o=_e(t);return De(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(L[e]=L[e]||[],Ka(L[e],t))},
181
+ n.removeHook=function(e){L[e]&&Ya(L[e])},n.removeHooks=function(e){L[e]&&(L[e]=[])},n.removeAllHooks=function(){L={}},n}(),Ls=/["'&<>]/,Ms=function(e){var t,n=""+e,r=Ls.exec(n);if(!r)return n;var o="",i=0,a=0;for(i=r.index;i<n.length;i++){switch(n.charCodeAt(i)){case 34:t="&quot;";break;case 38:t="&amp;";break;case 39:t="&#39;";break;case 60:t="&lt;";break;case 62:t="&gt;";break;default:continue}a!==i&&(o+=n.substring(a,i)),a=i+1,o+=t}return a!==i?o+n.substring(a,i):o};class zs{constructor(e,t,n){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=n}static range(e,t){return t?e&&e.loc&&t.loc&&e.loc.lexer===t.loc.lexer?new zs(e.loc.lexer,e.loc.start,t.loc.end):null:e&&e.loc}}class Os{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new Os(t,zs.range(this,e))}}class Is{constructor(e,t){this.position=void 0;var n,r="KaTeX parse error: "+e,o=t&&t.loc;if(o&&o.start<=o.end){var i=o.lexer.input
182
+ ;n=o.start;var a=o.end;n===i.length?r+=" at end of input: ":r+=" at position "+(n+1)+": ";var s=i.slice(n,a).replace(/[^]/g,"$&̲");r+=(n>15?"…"+i.slice(n-15,n):i.slice(0,n))+s+(a+15<i.length?i.slice(a,a+15)+"…":i.slice(a))}var l=new Error(r);return l.name="ParseError",l.__proto__=Is.prototype,l.position=n,l}}Is.prototype.__proto__=Error.prototype;var Rs=/([A-Z])/g,Ps={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},Ds=/[&><"']/g;var Bs=function e(t){return"ordgroup"===t.type||"color"===t.type?1===t.body.length?e(t.body[0]):t:"font"===t.type?e(t.body):t},Fs={contains:function(e,t){return-1!==e.indexOf(t)},deflt:function(e,t){return void 0===e?t:e},escape:function(e){return String(e).replace(Ds,(e=>Ps[e]))},hyphenate:function(e){return e.replace(Rs,"-$1").toLowerCase()},getBaseElem:Bs,isCharacterBox:function(e){var t=Bs(e);return"mathord"===t.type||"textord"===t.type||"atom"===t.type},protocolFromUrl:function(e){var t=/^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(e);return null!=t?t[1]:"_relative"}
183
+ },js={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",
184
+ cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],
185
185
  description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>"Infinity"===e?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function Hs(e){if(e.default)return e.default;var t=e.type,n=Array.isArray(t)?t[0]:t;if("string"!=typeof n)return n.enum[0];switch(n){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class Us{constructor(e){for(var t in this.displayMode=void 0,
186
186
  this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{},js)if(js.hasOwnProperty(t)){var n=js[t];this[t]=void 0!==e[t]?n.processor?n.processor(e[t]):e[t]:Hs(n)}}reportNonstrict(e,t,n){var r=this.strict;if("function"==typeof r&&(r=r(e,t,n)),r&&"ignore"!==r){if(!0===r||"error"===r)throw new Is("LaTeX-incompatible input and strict mode is set to 'error': "+t+" ["+e+"]",n);"warn"===r?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+r+"': "+t+" ["+e+"]")}}useStrictBehavior(e,t,n){var r=this.strict;if("function"==typeof r)try{r=r(e,t,n)}catch(e){r="error"}
187
187
  return!(!r||"ignore"===r)&&(!0===r||"error"===r||("warn"===r?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+r+"': "+t+" ["+e+"]"),!1)))}isTrusted(e){e.url&&!e.protocol&&(e.protocol=Fs.protocolFromUrl(e.url));var t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}class qs{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return $s[Gs[this.id]]}sub(){return $s[Vs[this.id]]}fracNum(){return $s[Ws[this.id]]}fracDen(){return $s[Ys[this.id]]}cramp(){return $s[Ks[this.id]]}text(){return $s[Xs[this.id]]}isTight(){return this.size>=2}}
@@ -518,138 +518,137 @@ const r=no((()=>e?yd(e):""),[e]),o=to();Qr((()=>{!function(e,{className:t}={}){c
518
518
  ;var wd=ri((function({annotation:e,settings:t}){var n,r;const[o,i]=Zr(!0),[a,s]=Zr(!1),l=ii().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=ti(["annotationFontFamily"],t);return po("div",{className:"hyp-u-vertical-spacing--2",children:[d&&po(Ta,{collapse:o,collapsedHeight:400,inlineControls:!1,onCollapsibleChanged:s,onToggleCollapsed:i,overflowThreshold:20,children:po(_d,{textStyle:m,markdown:h,textClass:{AnnotationBody__text:!0,"p-redacted-content":Ti(e)}})}),a&&po("div",{className:"hyp-u-layout-row--justify-right",children:po(bo,{expanded:!o,onClick:()=>i(!o),title:`Toggle visibility of full annotation text: Show ${c}`,children:c})}),p&&po(bd,{annotation:e,tags:u})]})}),["settings"]);const xd=0,kd=1;function Sd(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd;return o>=t+n?(o+=r.length-n,
519
519
  i+=r.length-n):i<=t||(o<=t&&i>=t+n?i+=r.length-n:o<t&&i<t+n?o=t:o<t+n&&i>t+n?i+=r.length-n:t<o&&t+n>i&&(o=t,i=t+n)),{text:e.text.slice(0,t)+r+e.text.slice(t+n),selectionStart:o,selectionEnd:i}}function Cd(e,t=xd){const n=e.text.slice(e.selectionStart,e.selectionEnd);let r,o="";if(t===kd&&(o="!"),n.match(/[a-z]+:\/\/.*/)){const t="Description";return r=Sd(e,e.selectionStart,n.length,o+"["+t+"]("+n+")"),r.selectionStart=e.selectionStart+o.length+1,r.selectionEnd=r.selectionStart+t.length,r}{const t=o+"["+n+"](",i="http://insert-your-link-here.com";return r=Sd(e,e.selectionStart,n.length,t+i+")"),r.selectionStart=e.selectionStart+t.length,r.selectionEnd=r.selectionStart+i.length,r}}function Ad(e,t,n,r){void 0===n&&(n=t);const o=e.text.slice(e.selectionStart-t.length,e.selectionStart),i=e.text.slice(e.selectionEnd,e.selectionEnd+t.length);let a=e;return e.selectionStart===e.selectionEnd&&r&&(a=Sd(e,e.selectionStart,0,r),a.selectionStart=a.selectionEnd-r.length),
520
520
  o===t&&i===n?(a=Sd(a,a.selectionStart-t.length,t.length,""),a=Sd(a,a.selectionEnd,n.length,"")):(a=Sd(a,a.selectionStart,0,t),a=Sd(a,a.selectionEnd,0,n)),a}function Ed(e,t){const n=e.indexOf("\n",t);return n<0?e.length:n}function Td(e,t,n,r){let o=function(e,t){const n=e.lastIndexOf("\n",t);return n<0?0:n+1}(e.text,t),i=Ed(e.text,t);for(;i<=Ed(e.text,n);){const t=i===e.text.length,a=i-o,s=Ed((e=r(e,o,i)).text,o)-o;if(n+=s-a,t)break;o=o+s+1,i=Ed(e.text,o)}return e}function Nd(e,t){const n=e.selectionStart,r=e.selectionEnd;let o=!0;return Td(e,n,r,((e,n)=>(e.text.slice(n,n+t.length)!==t&&(o=!1),e))),Td(e,n,r,o?(e,n)=>Sd(e,n,t.length,""):(e,n)=>e.text.slice(n,n+t.length)===t?e:Sd(e,n,0,t))}const Ld={bold:"b",italic:"i",link:"l",quote:"q",image:"g",numlist:"o",list:"u"};function Md({buttonRef:e,disabled:t=!1,iconName:n="",label:r,onClick:o,shortcutKey:i,tabIndex:a,title:s=""}){const l=no((()=>((e=window.navigator.userAgent)=>e.indexOf("Mac OS")>=0)()?"Cmd":"Ctrl"),[]);let c=s;i&&(c+=` (${l}-${i.toUpperCase()})`)
521
- ;const u={buttonRef:e,disabled:t,icon:n,onClick:o,tabIndex:a,title:c};return r?po(bo,{classes:"u-font--normal TransparentButton",...u,children:r}):po(_o,{classes:"MarkdownEditor__toolbar-button",...u})}function zd({isPreviewing:e,onCommand:t,onTogglePreview:n}){const r=0,o=1,i=2,a=3,s=4,l=5,c=6,u=7,h=8,d=9,p=10,[m,f]=Zr(0),g=to([]).current;if(0===g.length)for(let e=0;e<=p;e++)g.push({current:null});const v=e=>m===e?0:-1;return po("div",{className:"hyp-u-layout-row hyp-u-border--left hyp-u-border--right hyp-u-border--top hyp-u-bg-color--white MarkdownEditor__toolbar",role:"toolbar","aria-label":"Markdown editor toolbar",onKeyDown:t=>{let n=0;const r=p-1;e&&(n=h);let o=null;switch(Oo(t.key)){case"ArrowLeft":o=m<=n?r:m-1;break;case"ArrowRight":o=m>=r?n:m+1;break;case"Home":o=n;break;case"End":o=r}var i;null!==o&&(f(i=o),g[i].current.focus(),t.preventDefault())},children:[po(Md,{disabled:e,iconName:"format-bold",onClick:()=>t("bold"),shortcutKey:Ld.bold,buttonRef:g[r],tabIndex:v(r),title:"Bold"}),po(Md,{
522
- disabled:e,iconName:"format-italic",onClick:()=>t("italic"),shortcutKey:Ld.italic,buttonRef:g[o],tabIndex:v(o),title:"Italic"}),po(Md,{disabled:e,iconName:"format-quote",onClick:()=>t("quote"),shortcutKey:Ld.quote,buttonRef:g[i],tabIndex:v(i),title:"Quote"}),po(Md,{disabled:e,iconName:"link",onClick:()=>t("link"),shortcutKey:Ld.link,buttonRef:g[a],tabIndex:v(a),title:"Insert link"}),po(Md,{disabled:e,iconName:"image",onClick:()=>t("image"),shortcutKey:Ld.image,buttonRef:g[s],tabIndex:v(s),title:"Insert image"}),po(Md,{disabled:e,iconName:"format-functions",onClick:()=>t("math"),buttonRef:g[l],tabIndex:v(l),title:"Insert math (LaTeX is supported)"}),po(Md,{disabled:e,iconName:"format-list-numbered",onClick:()=>t("numlist"),shortcutKey:Ld.numlist,buttonRef:g[c],tabIndex:v(c),title:"Numbered list"}),po(Md,{disabled:e,iconName:"format-list-unordered",onClick:()=>t("list"),shortcutKey:Ld.list,buttonRef:g[u],tabIndex:v(u),title:"Bulleted list"}),po("span",{className:"hyp-u-stretch"}),po("div",{
523
- className:"hyp-u-layout-row--center",children:po(zo,{href:"https://web.hypothes.is/help/formatting-annotations-with-markdown/",target:"_blank",classes:"u-font--xsmall IconOnlyLink",linkRef:g[h],tabIndex:v(h),title:"Formatting help","aria-label":"Formatting help",children:po(Mo,{name:"help"})})}),po(Md,{label:e?"Write":"Preview",onClick:n,buttonRef:g[d],tabIndex:v(d)})]})}function Od({label:e="",onEditText:t=(()=>{}),text:n="",textStyle:r={}}){const[o,i]=Zr(!1),a=to(null);Qr((()=>{var e;o||(null===(e=a.current)||void 0===e||e.focus())}),[o]);const s=e=>{a.current&&(!function(e,t){const n=e=>{const n=e({text:t.value,selectionStart:t.selectionStart,selectionEnd:t.selectionEnd});t.value=n.text,t.selectionStart=n.selectionStart,t.selectionEnd=n.selectionEnd,t.focus()},r=e=>{const t=e.text.slice(0,e.selectionStart);return 0===t.length||"\n"===t.slice(-1)||"$$"===t.slice(-2)?Ad(e,"$$","$$","Insert LaTeX"):Ad(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>Ad(e,"**","**","Bold")));break;case"italic":
524
- n((e=>Ad(e,"*","*","Italic")));break;case"quote":n((e=>Nd(e,"> ")));break;case"link":n((e=>Cd(e)));break;case"image":n((e=>Cd(e,kd)));break;case"math":n(r);break;case"numlist":n((e=>Nd(e,"1. ")));break;case"list":n((e=>Nd(e,"* ")));break;default:throw new Error(`Unknown toolbar command "${e}"`)}}(e,a.current),t({text:a.current.value}))};return po("div",{className:"u-line-height",children:[po(zd,{onCommand:s,isPreviewing:o,onTogglePreview:()=>i(!o)}),o?po(_d,{markdown:n,textClass:{"hyp-u-border":!0,"hyp-u-bg-color--grey-1":!0,"hyp-u-padding":!0},textStyle:r}):po("textarea",{"aria-label":e,className:"MarkdownEditor__input",dir:"auto",ref:a,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(let[t,n]of Object.entries(Ld))n===Oo(e.key)&&(e.stopPropagation(),e.preventDefault(),s(t))},onInput:e=>{t({text:e.target.value})},value:n,style:r})]})}const Id=e=>e;function Rd({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Id,onSelectItem:i,open:a=!1}){const s=no((()=>r.map(((t,r)=>{
521
+ ;const u={buttonRef:e,disabled:t,icon:n,onClick:o,tabIndex:a,title:c};return r?po(bo,{classes:"font-normal TransparentButton",...u,children:r}):po(_o,{classes:"MarkdownEditor__toolbar-button",...u})}function zd({isPreviewing:e,onCommand:t,onTogglePreview:n}){const r=0,o=1,i=2,a=3,s=4,l=5,c=6,u=7,h=8,d=9,p=10,[m,f]=Zr(0),g=to([]).current;if(0===g.length)for(let e=0;e<=p;e++)g.push({current:null});const v=e=>m===e?0:-1;return po("div",{className:"hyp-u-layout-row hyp-u-border--left hyp-u-border--right hyp-u-border--top hyp-u-bg-color--white MarkdownEditor__toolbar",role:"toolbar","aria-label":"Markdown editor toolbar",onKeyDown:t=>{let n=0;const r=p-1;e&&(n=h);let o=null;switch(Oo(t.key)){case"ArrowLeft":o=m<=n?r:m-1;break;case"ArrowRight":o=m>=r?n:m+1;break;case"Home":o=n;break;case"End":o=r}var i;null!==o&&(f(i=o),g[i].current.focus(),t.preventDefault())},children:[po(Md,{disabled:e,iconName:"format-bold",onClick:()=>t("bold"),shortcutKey:Ld.bold,buttonRef:g[r],tabIndex:v(r),title:"Bold"}),po(Md,{disabled:e,
522
+ iconName:"format-italic",onClick:()=>t("italic"),shortcutKey:Ld.italic,buttonRef:g[o],tabIndex:v(o),title:"Italic"}),po(Md,{disabled:e,iconName:"format-quote",onClick:()=>t("quote"),shortcutKey:Ld.quote,buttonRef:g[i],tabIndex:v(i),title:"Quote"}),po(Md,{disabled:e,iconName:"link",onClick:()=>t("link"),shortcutKey:Ld.link,buttonRef:g[a],tabIndex:v(a),title:"Insert link"}),po(Md,{disabled:e,iconName:"image",onClick:()=>t("image"),shortcutKey:Ld.image,buttonRef:g[s],tabIndex:v(s),title:"Insert image"}),po(Md,{disabled:e,iconName:"format-functions",onClick:()=>t("math"),buttonRef:g[l],tabIndex:v(l),title:"Insert math (LaTeX is supported)"}),po(Md,{disabled:e,iconName:"format-list-numbered",onClick:()=>t("numlist"),shortcutKey:Ld.numlist,buttonRef:g[c],tabIndex:v(c),title:"Numbered list"}),po(Md,{disabled:e,iconName:"format-list-unordered",onClick:()=>t("list"),shortcutKey:Ld.list,buttonRef:g[u],tabIndex:v(u),title:"Bulleted list"}),po("span",{className:"hyp-u-stretch"}),po("div",{
523
+ className:"hyp-u-layout-row--center",children:po(zo,{href:"https://web.hypothes.is/help/formatting-annotations-with-markdown/",target:"_blank",classes:"text-tiny IconOnlyLink",linkRef:g[h],tabIndex:v(h),title:"Formatting help","aria-label":"Formatting help",children:po(Mo,{name:"help"})})}),po(Md,{label:e?"Write":"Preview",onClick:n,buttonRef:g[d],tabIndex:v(d)})]})}function Od({label:e="",onEditText:t=(()=>{}),text:n="",textStyle:r={}}){const[o,i]=Zr(!1),a=to(null);Qr((()=>{var e;o||(null===(e=a.current)||void 0===e||e.focus())}),[o]);const s=e=>{a.current&&(!function(e,t){const n=e=>{const n=e({text:t.value,selectionStart:t.selectionStart,selectionEnd:t.selectionEnd});t.value=n.text,t.selectionStart=n.selectionStart,t.selectionEnd=n.selectionEnd,t.focus()},r=e=>{const t=e.text.slice(0,e.selectionStart);return 0===t.length||"\n"===t.slice(-1)||"$$"===t.slice(-2)?Ad(e,"$$","$$","Insert LaTeX"):Ad(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>Ad(e,"**","**","Bold")));break;case"italic":
524
+ n((e=>Ad(e,"*","*","Italic")));break;case"quote":n((e=>Nd(e,"> ")));break;case"link":n((e=>Cd(e)));break;case"image":n((e=>Cd(e,kd)));break;case"math":n(r);break;case"numlist":n((e=>Nd(e,"1. ")));break;case"list":n((e=>Nd(e,"* ")));break;default:throw new Error(`Unknown toolbar command "${e}"`)}}(e,a.current),t({text:a.current.value}))};return po("div",{className:"leading-none",children:[po(zd,{onCommand:s,isPreviewing:o,onTogglePreview:()=>i(!o)}),o?po(_d,{markdown:n,textClass:{"hyp-u-border":!0,"hyp-u-bg-color--grey-1":!0,"hyp-u-padding":!0},textStyle:r}):po("textarea",{"aria-label":e,className:"MarkdownEditor__input",dir:"auto",ref:a,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(let[t,n]of Object.entries(Ld))n===Oo(e.key)&&(e.stopPropagation(),e.preventDefault(),s(t))},onInput:e=>{t({text:e.target.value})},value:n,style:r})]})}const Id=e=>e;function Rd({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Id,onSelectItem:i,open:a=!1}){const s=no((()=>r.map(((t,r)=>{
525
525
  const a=n?{id:`${n}${r}`}:{};return po("li",{role:"option","aria-selected":(e===r).toString(),className:Ur({"is-selected":e===r},"AutocompleteList__li"),onClick:()=>{i(t)},...a,children:o(t,r)},`AutocompleteList-${r}`)}))),[e,n,r,o,i]),l=t?{id:t}:{},c=0===r.length||!a;return po("div",{className:Ur({"is-hidden":c},"AutocompleteList"),children:po("ul",{className:"AutocompleteList__items",tabIndex:-1,"aria-label":"Suggestions",role:"listbox",...l,children:s})})}let Pd=0;var Dd=ri((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){const i=to(),[a,s]=Zr([]),[l,c]=Zr(-1),[u,h]=Zr(!1),[d]=Zr((()=>(++Pd,`TagEditor-${Pd}`))),p=to();Ro(p,u,(()=>{h(!1)}));const m=()=>i.current.value.trim(),f=()=>m()&&m().length>0,g=()=>{i.current.value="",null==n||n("")},v=t=>{e(t)&&(h(!1),c(-1),g(),i.current.focus())},y=e=>{let t=l+e;t<-1?t=a.length-1:t>=a.length&&(t=-1),c(t)},_=l>=0?`${d}-AutocompleteList-item-${l}`:"";return po("div",{className:"TagEditor",children:[po("ul",{className:"TagEditor__tags",
526
526
  "aria-label":"Suggested tags for annotation",children:r.map((e=>po("li",{className:"TagEditor__item","aria-label":`Tag: ${e}`,children:[po("span",{lang:"",className:"TagEditor__edit",children:e}),po("button",{onClick:()=>{t(e)},"aria-label":`Remove Tag: ${e}`,title:`Remove Tag: ${e}`,className:"TagEditor__delete",children:po(Mo,{name:"cancel"})})]},`${e}`)))}),po("span",{id:d,className:"TagEditor__combobox-wrapper",ref:p,role:"combobox","aria-expanded":u.toString(),"aria-owns":`${d}-AutocompleteList`,"aria-haspopup":"listbox",children:[po("input",{onInput:()=>{null==n||n(m()),(()=>{if(f()){const e=o.filter(m());s(((e,t)=>{const n=[];return e.forEach((e=>{t.indexOf(e)<0&&n.push(e)})),n.sort()})(e,r)),h(e.length>0)}else h(!1);c(-1)})()},onKeyDown:e=>{switch(Oo(e.key)){case"ArrowUp":y(-1),e.preventDefault();break;case"ArrowDown":y(1),e.preventDefault();break;case"Escape":g(),e.preventDefault();break;case"Enter":case",":v(-1===l?m():a[l]),e.preventDefault();break;case"Tab":if(!f())break
527
- ;-1!==l?v(a[l]):1===a.length?v(a[0]):v(m()),e.preventDefault()}},onFocus:()=>{f()&&h(!0)},ref:i,placeholder:"Add new tags",className:"TagEditor__input",type:"text",autoComplete:"off","aria-autocomplete":"list","aria-activedescendant":_,"aria-controls":`${d}-AutocompleteList`,dir:"auto"}),po(Rd,{id:`${d}-AutocompleteList`,list:a,listFormatter:e=>{const t=m().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return po("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return po("span",{children:[po("strong",{children:r}),o,po("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${d}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Bd(){return po("div",{className:"hyp-u-padding--top hyp-u-border--top u-font--small u-line-height",children:po(zo,{classes:"hyp-u-layout-row--align-center p-link--muted",href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",
528
- title:"View more information about the Creative Commons Public Domain dedication",children:[po(Mo,{name:"cc-std",classes:"u-icon--xsmall"}),po(Mo,{name:"cc-zero",classes:"hyp-u-margin--left--1 u-icon--xsmall"}),po("div",{className:"hyp-u-margin--left--2",children:"Annotations can be freely reused by anyone for any purpose."})]})})}function Fd(e){return null!==e.offsetParent}function jd({className:e,closeMenu:t,children:n,visible:r}){const o=to();Qr((()=>{let e=null;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return po("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Fd);let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(Oo(e.key)){case"ArrowLeft":case"Escape":t&&(t(e),i=!0);break;case"ArrowUp":r-=1,r<0&&(r=n.length-1),i=!0;break;case"ArrowDown":r+=1,r===n.length&&(r=0),i=!0;break;case"Home":r=0,i=!0;break;case"End":r=n.length-1,
529
- i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}function Hd({className:e}){return po("svg",{className:Ur("Menu__arrow",e),width:15,height:8,children:po("path",{d:"M0 8 L7 0 L15 8",stroke:"currentColor",strokeWidth:"2"})})}let Ud=!1;const qd=()=>{};function $d({align:e="left",arrowClass:t="",children:n,containerPositioned:r=!0,contentClass:o,defaultOpen:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[h,d]=Zr(i);"boolean"==typeof s&&(h=s,d=l||qd);const p=to(h);Qr((()=>{"function"==typeof l&&p.current!==h&&(p.current=h,l(h))}),[h,l]);const f=e=>{if("mousedown"===e.type)Ud=!0;else if("click"===e.type&&Ud)return Ud=!1,e.stopPropagation(),void e.preventDefault();d(!h)},g=ro((()=>d(!1)),[d]),v=to();Ro(v,h,g);const y=e=>e.stopPropagation();return po("div",{className:"Menu",ref:v,style:{position:r?"relative":"static"},onClick:y,onMouseDown:y,children:[po("button",{"aria-expanded":h?"true":"false","aria-haspopup":!0,className:"Menu__toggle",onMouseDown:f,onClick:f,
527
+ ;-1!==l?v(a[l]):1===a.length?v(a[0]):v(m()),e.preventDefault()}},onFocus:()=>{f()&&h(!0)},ref:i,placeholder:"Add new tags",className:"TagEditor__input",type:"text",autoComplete:"off","aria-autocomplete":"list","aria-activedescendant":_,"aria-controls":`${d}-AutocompleteList`,dir:"auto"}),po(Rd,{id:`${d}-AutocompleteList`,list:a,listFormatter:e=>{const t=m().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return po("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return po("span",{children:[po("strong",{children:r}),o,po("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${d}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Bd(){return po("div",{className:"hyp-u-padding--top hyp-u-border--top text-sm leading-none",children:po(zo,{classes:"hyp-u-layout-row--align-center p-link--muted",href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",
528
+ title:"View more information about the Creative Commons Public Domain dedication",children:[po(Mo,{name:"cc-std",classes:"text-tiny"}),po(Mo,{name:"cc-zero",classes:"hyp-u-margin--left--1 text-tiny"}),po("div",{className:"hyp-u-margin--left--2",children:"Annotations can be freely reused by anyone for any purpose."})]})})}function Fd(e){return null!==e.offsetParent}function jd({className:e,closeMenu:t,children:n,visible:r}){const o=to();Qr((()=>{let e=null;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return po("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Fd);let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(Oo(e.key)){case"ArrowLeft":case"Escape":t&&(t(e),i=!0);break;case"ArrowUp":r-=1,r<0&&(r=n.length-1),i=!0;break;case"ArrowDown":r+=1,r===n.length&&(r=0),i=!0;break;case"Home":r=0,i=!0;break;case"End":r=n.length-1,i=!0}
529
+ i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}function Hd({className:e}){return po("svg",{className:Ur("Menu__arrow",e),width:15,height:8,children:po("path",{d:"M0 8 L7 0 L15 8",stroke:"currentColor",strokeWidth:"2"})})}let Ud=!1;const qd=()=>{};function $d({align:e="left",arrowClass:t="",children:n,containerPositioned:r=!0,contentClass:o,defaultOpen:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[h,d]=Zr(i);"boolean"==typeof s&&(h=s,d=l||qd);const p=to(h);Qr((()=>{"function"==typeof l&&p.current!==h&&(p.current=h,l(h))}),[h,l]);const f=e=>{if("mousedown"===e.type)Ud=!0;else if("click"===e.type&&Ud)return Ud=!1,e.stopPropagation(),void e.preventDefault();d(!h)},g=ro((()=>d(!1)),[d]),v=to();Ro(v,h,g);const y=e=>e.stopPropagation();return po("div",{className:"Menu",ref:v,style:{position:r?"relative":"static"},onClick:y,onMouseDown:y,children:[po("button",{"aria-expanded":h?"true":"false","aria-haspopup":!0,className:"Menu__toggle",onMouseDown:f,onClick:f,
530
530
  "aria-label":u,title:u,children:po("span",{className:"Menu__toggle-wrapper",children:[a,c&&po("span",{className:Ur("Menu__toggle-arrow",h&&"is-open"),children:po(fo,{name:"expand-menu",className:"Menu__toggle-icon"})})]})}),h&&po(m,{children:[po(Hd,{className:t}),po("div",{className:Ur("Menu__content",`Menu__content--align-${e}`,o),role:"menu",tabIndex:-1,onClick:g,onKeyDown:e=>{const t=Oo(e.key);"Enter"!==t&&" "!==t||setTimeout((()=>{g()}))},children:po(jd,{visible:!0,children:n})})]})]})}function Gd({children:e,visible:t}){const n=to(),[r,o]=Zr(t?"auto":0),[i,a]=Zr(t);Qr((()=>{if(t===(0!==r))return;const e=n.current;t?(e.style.display="",a(!0),o(e.scrollHeight)):(e.style.height=`${e.scrollHeight}px`,e.getBoundingClientRect(),o(0))}),[r,t]);return po("div",{ontransitionend:ro((()=>{t?o("auto"):a(!1)}),[o,t]),ref:n,style:{display:i?"":"none",height:r,overflow:"auto"===r?"visible":"hidden",transition:"height 0.15s ease-in"},children:e})}
531
531
  function Vd({href:e,icon:t,iconAlt:n,isDisabled:r,isExpanded:o,isSelected:i,isSubmenuItem:a,isSubmenuVisible:s,label:l,onClick:c,onToggleSubmenu:u,submenu:h}){const d=t&&-1!==t.indexOf("/"),p=t||a,f=t&&a,g=to();let v=null,y=null;t&&"blank"!==t&&(y=d?po("img",{className:"MenuItem__icon",alt:n,src:t}):po(fo,{name:t,className:"MenuItem__icon"}));const _=a?null:y,b=a?y:null;let w;const x="boolean"==typeof s,k="boolean"==typeof i;Qr((()=>()=>{clearTimeout(v)}),[]);const S=e=>{switch(Oo(e.key)){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}};return w=e?po("a",{ref:g,className:Ur("MenuItem",{"is-submenu":a,"is-disabled":r}),href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:S,children:[p&&po("div",{className:"MenuItem__icon-container",children:_}),po("span",{className:"MenuItem__label",children:l}),f&&po("div",{className:"MenuItem__icon-container",children:b})]}):po("div",{ref:g,className:Ur("MenuItem",{"is-submenu":a,
532
532
  "is-disabled":r,"is-expanded":o,"is-selected":i}),tabIndex:-1,onKeyDown:S,onClick:c,role:k?"menuitemradio":"menuitem","aria-checked":k?i:void 0,"aria-haspopup":x,"aria-expanded":x?s:void 0,children:[p&&po("div",{className:"MenuItem__icon-container",children:_}),po("span",{className:"MenuItem__label",children:l}),f&&po("div",{className:"MenuItem__icon-container",children:b}),x&&po("div",{role:"none",icon:s?"collapse-menu":"expand-menu",className:"MenuItem__toggle",onClick:u,title:`Show actions for ${l}`,children:po(fo,{name:s?"collapse-menu":"expand-menu",className:"MenuItem__toggle-icon"})})]}),po(m,{children:[w,x&&po(Gd,{visible:s,children:po(jd,{closeMenu:e=>{u&&u(e),v=setTimeout((()=>{g.current.focus()}))},visible:s,className:"MenuItem__submenu",children:h})})]})}var Wd=ri((function({annotation:e,isDisabled:t,onSave:n,settings:r}){const o=ii(),i=o.getDraft(e),a=o.getGroup(e.group);if(!a)return null;const s=i?i.isPrivate:!ya(e.permissions),l=s?"Only Me":a.name,c=t=>{o.createDraft(e,{...i,
533
- isPrivate:"private"===t}),ki(e)||o.setDefault("annotationPrivacy",t)},u=ti(["ctaTextColor","ctaBackgroundColor"],r),h=po("div",{className:"annotation-publish-button__menu-label",style:u,children:po(Mo,{name:"expand-menu",classes:"u-icon--small"})});return po("div",{className:"hyp-u-layout-row hyp-u-horizontal-spacing--4",children:[po("div",{className:"annotation-publish-button",children:[po(bo,{classes:"PublishControlButton","data-testid":"publish-control-button",style:u,onClick:n,disabled:t,size:"large",variant:"primary",children:["Post to ",l]}),po("div",{className:"annotation-publish-button__menu-wrapper",style:u,children:po($d,{arrowClass:"annotation-publish-button__menu-arrow",containerPositioned:!1,contentClass:"annotation-publish-button__menu-content",label:h,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[po(Vd,{icon:"open"===a.type?"public":"groups",label:a.name,isSelected:!s,onClick:()=>c("shared")}),po(Vd,{icon:"lock",label:"Only Me",isSelected:s,
534
- onClick:()=>c("private")})]})})]}),po("div",{children:po(bo,{icon:"cancel",onClick:()=>{o.removeDraft(e),Si(e)&&o.removeAnnotations([e])},size:"large",children:"Cancel"})})]})}),["settings"]);var Yd=ri((function({annotation:e,annotationsService:t,settings:n,tags:r,toastMessenger:o}){const[i,a]=Zr(null),s=ii(),l=s.getDraft(e),c=s.getGroup(e.group);if(!l)return null;const u=!l.isPrivate&&c&&"private"!==c.type,h=l.tags,d=l.text,p=!d&&!h.length,m=({tags:e})=>{s.createDraft(l.annotation,{...l,tags:e})},f=e=>{if(!e||h.indexOf(e)>=0)return!1;const t=[...h,e];return r.store(t),m({tags:t}),!0},g=async()=>{i&&f(i);try{await t.save(e)}catch(e){o.error("Saving annotation failed")}};return po("div",{className:"hyp-u-vertical-spacing AnnotationEditor",onKeyDown:e=>{const t=Oo(e.key);p||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),g())},children:[po(Od,{textStyle:ti(["annotationFontFamily"],n),label:"Annotation body",text:d,onEditText:({text:e})=>{s.createDraft(l.annotation,{...l,text:e})}
535
- }),po(Dd,{onAddTag:f,onRemoveTag:e=>{const t=[...h],n=t.indexOf(e);return n>=0&&(t.splice(n,1),m({tags:t}),!0)},onTagInput:a,tagList:h}),po("div",{className:"hyp-u-layout-row annotation__form-actions",children:po(Wd,{annotation:e,isDisabled:p,onSave:g})}),u&&po(Bd,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Kd(e,t,n){var r;return(n||t)&&null!==(r=e.user_info)&&void 0!==r&&r.display_name?e.user_info.display_name:Jo(e.user)}function Xd({domain:e,link:t,title:n}){return po("div",{className:"hyp-u-layout-row hyp-u-horizontal-spacing--2",children:[po("div",{className:"u-color-text--muted",children:['on "',t?po(zo,{href:t,target:"_blank",children:n}):po("span",{children:n}),'"']}),e&&po("span",{className:"u-color-text--muted",children:["(",e,")"]})]})}function Zd({annotation:e}){const t=ii().getGroup(e.group),n=null==t?void 0:t.links.html,r=_a(e.permissions);return po("div",{className:"hyp-u-layout-row--align-baseline",children:[t&&n&&po(zo,{
536
- classes:"hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 p-link--muted p-link--hover-muted",href:t.links.html,target:"_blank",children:["open"===t.type?po(Mo,{classes:"u-icon--xsmall",name:"public"}):po(Mo,{classes:"u-icon--xsmall",name:"groups"}),po("span",{children:t.name})]}),r&&!n&&po("span",{className:"hyp-u-layout-row--align-baseline u-color-text--muted",children:po("span",{"data-testid":"private-info",children:"Only me"})})]})}let Jd={};function Qd(e,t){return t-e}function ep(e,t,n=window.Intl){const r=JSON.stringify(t);let o=Jd[r];return o||(o=Jd[r]=new n.DateTimeFormat(void 0,t)),o.format(e)}const tp=[{test:(e,t)=>Qd(e,t)<3e4,formatter:()=>"Just now",nextUpdate:1e3},{test:(e,t)=>Qd(e,t)<6e4,formatter:function(e,t){return`${Math.floor(Qd(e,t)/1e3)} secs ago`},nextUpdate:1e3},{test:(e,t)=>Qd(e,t)<36e5,formatter:function(e,t){const n=Math.floor(Qd(e,t)/6e4);return`${n} min${n>1?"s":""} ago`},nextUpdate:6e4},{test:(e,t)=>Qd(e,t)<864e5,formatter:function(e,t){const n=Math.floor(Qd(e,t)/36e5)
533
+ isPrivate:"private"===t}),ki(e)||o.setDefault("annotationPrivacy",t)},u=ti(["ctaTextColor","ctaBackgroundColor"],r),h=po("div",{className:"annotation-publish-button__menu-label",style:u,children:po(Mo,{name:"expand-menu"})});return po("div",{className:"hyp-u-layout-row hyp-u-horizontal-spacing--4",children:[po("div",{className:"annotation-publish-button",children:[po(bo,{classes:"PublishControlButton","data-testid":"publish-control-button",style:u,onClick:n,disabled:t,size:"large",variant:"primary",children:["Post to ",l]}),po("div",{className:"annotation-publish-button__menu-wrapper",style:u,children:po($d,{arrowClass:"annotation-publish-button__menu-arrow",containerPositioned:!1,contentClass:"annotation-publish-button__menu-content",label:h,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[po(Vd,{icon:"open"===a.type?"public":"groups",label:a.name,isSelected:!s,onClick:()=>c("shared")}),po(Vd,{icon:"lock",label:"Only Me",isSelected:s,onClick:()=>c("private")})]})})]
534
+ }),po("div",{children:po(bo,{icon:"cancel",onClick:()=>{o.removeDraft(e),Si(e)&&o.removeAnnotations([e])},size:"large",children:"Cancel"})})]})}),["settings"]);var Yd=ri((function({annotation:e,annotationsService:t,settings:n,tags:r,toastMessenger:o}){const[i,a]=Zr(null),s=ii(),l=s.getDraft(e),c=s.getGroup(e.group);if(!l)return null;const u=!l.isPrivate&&c&&"private"!==c.type,h=l.tags,d=l.text,p=!d&&!h.length,m=({tags:e})=>{s.createDraft(l.annotation,{...l,tags:e})},f=e=>{if(!e||h.indexOf(e)>=0)return!1;const t=[...h,e];return r.store(t),m({tags:t}),!0},g=async()=>{i&&f(i);try{await t.save(e)}catch(e){o.error("Saving annotation failed")}};return po("div",{className:"hyp-u-vertical-spacing AnnotationEditor",onKeyDown:e=>{const t=Oo(e.key);p||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),g())},children:[po(Od,{textStyle:ti(["annotationFontFamily"],n),label:"Annotation body",text:d,onEditText:({text:e})=>{s.createDraft(l.annotation,{...l,text:e})}}),po(Dd,{onAddTag:f,
535
+ onRemoveTag:e=>{const t=[...h],n=t.indexOf(e);return n>=0&&(t.splice(n,1),m({tags:t}),!0)},onTagInput:a,tagList:h}),po("div",{className:"hyp-u-layout-row annotation__form-actions",children:po(Wd,{annotation:e,isDisabled:p,onSave:g})}),u&&po(Bd,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Kd(e,t,n){var r;return(n||t)&&null!==(r=e.user_info)&&void 0!==r&&r.display_name?e.user_info.display_name:Jo(e.user)}function Xd({domain:e,link:t,title:n}){return po("div",{className:"hyp-u-layout-row hyp-u-horizontal-spacing--2",children:[po("div",{className:"text-color-text-light",children:['on "',t?po(zo,{href:t,target:"_blank",children:n}):po("span",{children:n}),'"']}),e&&po("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function Zd({annotation:e}){const t=ii().getGroup(e.group),n=null==t?void 0:t.links.html,r=_a(e.permissions);return po("div",{className:"hyp-u-layout-row--align-baseline",children:[t&&n&&po(zo,{
536
+ classes:"hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 p-link--muted p-link--hover-muted",href:t.links.html,target:"_blank",children:["open"===t.type?po(Mo,{classes:"text-tiny",name:"public"}):po(Mo,{classes:"text-tiny",name:"groups"}),po("span",{children:t.name})]}),r&&!n&&po("span",{className:"hyp-u-layout-row--align-baseline text-color-text-light",children:po("span",{"data-testid":"private-info",children:"Only me"})})]})}let Jd={};function Qd(e,t){return t-e}function ep(e,t,n=window.Intl){const r=JSON.stringify(t);let o=Jd[r];return o||(o=Jd[r]=new n.DateTimeFormat(void 0,t)),o.format(e)}const tp=[{test:(e,t)=>Qd(e,t)<3e4,formatter:()=>"Just now",nextUpdate:1e3},{test:(e,t)=>Qd(e,t)<6e4,formatter:function(e,t){return`${Math.floor(Qd(e,t)/1e3)} secs ago`},nextUpdate:1e3},{test:(e,t)=>Qd(e,t)<36e5,formatter:function(e,t){const n=Math.floor(Qd(e,t)/6e4);return`${n} min${n>1?"s":""} ago`},nextUpdate:6e4},{test:(e,t)=>Qd(e,t)<864e5,formatter:function(e,t){const n=Math.floor(Qd(e,t)/36e5)
537
537
  ;return`${n} hr${n>1?"s":""} ago`},nextUpdate:36e5},{test:(e,t)=>e.getFullYear()===t.getFullYear(),formatter:function(e,t,n){return ep(e,{month:"short",day:"numeric"},n)},nextUpdate:null}],np={test:()=>!0,formatter:function(e,t,n){return ep(e,{day:"numeric",month:"short",year:"numeric"},n)},nextUpdate:null};function rp(e,t){for(let n of tp)if(n.test(e,t))return n;return np}function op(e){return!isNaN(e.valueOf())}function ip(e,t){let n;const r=new Date(e),o=()=>{const e=function(e,t){if(!e||!op(e)||!op(t))return null;let n=rp(e,t).nextUpdate;return null===n?null:(n=Math.max(n,5e3),n=Math.min(n,20736e5),n)}(r,new Date);if(null===e)return;n=setTimeout((()=>{t(),o()}),e+500)};return o(),()=>clearTimeout(n)}function ap(e,t,n){return e?rp(e,t).formatter(e,t,n):""}function sp(e,t){return ep(e,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"},t)}function lp({annotationCreated:e,annotationUpdated:t,annotationUrl:n,withEditedTimestamp:r}){
538
- const[o,i]=Zr((()=>new Date)),a=no((()=>new Date(e)),[e]),s=no((()=>r&&new Date(t)),[t,r]),l=no((()=>({absolute:sp(a),relative:ap(a,o)})),[a,o]),c=no((()=>s?{absolute:sp(s),relative:ap(s,o)}:{}),[s,o]);Qr((()=>ip(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return po("div",{children:[r&&po("span",{className:"u-color-text--muted u-font--small u-font--italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?po(zo,{classes:"p-link--muted p-link--hover-muted",target:"_blank",title:l.absolute,href:n,children:l.relative}):po("span",{className:"u-color-text--muted","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function cp({authorLink:e,displayName:t}){const n=po("h3",{className:"u-color-text u-font--bold",children:t});return e?po(zo,{href:e,target:"_blank",children:n}):po("div",{children:n})}var up=ri((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){var i
539
- ;const a=ii(),s=a.defaultAuthority(),l=a.isFeatureEnabled("client_display_names"),c=Qo(e.user,s),u=Kd(e,c,l),h=(()=>{var t;return c?null!==(t=o.usernameUrl&&`${o.usernameUrl}${Jo(e.user)}`)&&void 0!==t?t:void 0:a.getLink("user",{user:e.user})})(),d=ki(e)&&r,p=_a(e.permissions),m=(null===(i=e.links)||void 0===i?void 0:i.html)||"",f=!t&&e.created,g=no((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3}(e)&&!d),[e,d]),v=`${n} ${n>1?"replies":"reply"}`,y=n>0&&d,_=!ki(e),b=function(e){return{domain:wi(e),titleText:xi(e),titleLink:bi(e)}}(e),w=m&&b.titleLink?b.titleLink:"",x="sidebar"!==a.route()&&b.titleText;return po("header",{children:[po("div",{className:"hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 u-wrap-reverse",children:[p&&!t&&po(Mo,{classes:"u-icon--xsmall",name:"lock",title:"This annotation is visible only to you"}),po(cp,{authorLink:h,displayName:u
540
- }),y&&po(wo,{onClick:()=>a.setExpanded(e.id,!0),title:"Expand replies",children:v}),f&&po("div",{className:"hyp-u-layout-row--justify-right hyp-u-stretch",children:po(lp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationUrl:m,withEditedTimestamp:g})})]}),_&&po("div",{className:"hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 u-wrap-reverse",children:[po(Zd,{annotation:e}),!t&&Ni(e)&&po(Mo,{name:"highlight",title:"This is a highlight. Click 'edit' to add a note or tag.",classes:"u-icon--xsmall u-color-text--muted"}),x&&po(Xd,{domain:b.domain,link:w,title:b.titleText})]})]})}),["settings"]);var hp=ri((function({annotation:e,isFocused:t,settings:n={}}){return po("div",{className:Ur({"is-orphan":Li(e)}),children:po(Ta,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:po("blockquote",{className:Ur("p-quoted-text",{"is-focused":t,"p-redacted-content":Li(e)}),dir:"auto",lang:"",style:ti(["selectionFontFamily"],n),children:Ii(e)})})})}),["settings"])
538
+ const[o,i]=Zr((()=>new Date)),a=no((()=>new Date(e)),[e]),s=no((()=>r&&new Date(t)),[t,r]),l=no((()=>({absolute:sp(a),relative:ap(a,o)})),[a,o]),c=no((()=>s?{absolute:sp(s),relative:ap(s,o)}:{}),[s,o]);Qr((()=>ip(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return po("div",{children:[r&&po("span",{className:"text-color-text-light text-sm italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?po(zo,{classes:"p-link--muted p-link--hover-muted",target:"_blank",title:l.absolute,href:n,children:l.relative}):po("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function cp({authorLink:e,displayName:t}){const n=po("h3",{className:"text-color-text font-bold",children:t});return e?po(zo,{href:e,target:"_blank",children:n}):po("div",{children:n})}var up=ri((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){var i
539
+ ;const a=ii(),s=a.defaultAuthority(),l=a.isFeatureEnabled("client_display_names"),c=Qo(e.user,s),u=Kd(e,c,l),h=(()=>{var t;return c?null!==(t=o.usernameUrl&&`${o.usernameUrl}${Jo(e.user)}`)&&void 0!==t?t:void 0:a.getLink("user",{user:e.user})})(),d=ki(e)&&r,p=_a(e.permissions),m=(null===(i=e.links)||void 0===i?void 0:i.html)||"",f=!t&&e.created,g=no((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3}(e)&&!d),[e,d]),v=`${n} ${n>1?"replies":"reply"}`,y=n>0&&d,_=!ki(e),b=function(e){return{domain:wi(e),titleText:xi(e),titleLink:bi(e)}}(e),w=m&&b.titleLink?b.titleLink:"",x="sidebar"!==a.route()&&b.titleText;return po("header",{children:[po("div",{className:"hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 flex-wrap-reverse",children:[p&&!t&&po(Mo,{classes:"text-tiny",name:"lock",title:"This annotation is visible only to you"}),po(cp,{authorLink:h,displayName:u}),y&&po(wo,{
540
+ onClick:()=>a.setExpanded(e.id,!0),title:"Expand replies",children:v}),f&&po("div",{className:"hyp-u-layout-row--justify-right hyp-u-stretch",children:po(lp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationUrl:m,withEditedTimestamp:g})})]}),_&&po("div",{className:"hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 flex-wrap-reverse",children:[po(Zd,{annotation:e}),!t&&Ni(e)&&po(Mo,{name:"highlight",title:"This is a highlight. Click 'edit' to add a note or tag.",classes:"text-tiny text-color-text-light"}),x&&po(Xd,{domain:b.domain,link:w,title:b.titleText})]})]})}),["settings"]);var hp=ri((function({annotation:e,isFocused:t,settings:n={}}){return po("div",{className:Ur({"is-orphan":Li(e)}),children:po(Ta,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:po("blockquote",{className:Ur("p-quoted-text",{"is-focused":t,"p-redacted-content":Li(e)}),dir:"auto",lang:"",style:ti(["selectionFontFamily"],n),children:Ii(e)})})})}),["settings"])
541
541
  ;function dp({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return po(wo,{onClick:e,title:r,children:r})}var pp=ri((function({annotation:e,hasAppliedFilter:t,isReply:n,onToggleReplies:r,replyCount:o,threadIsCollapsed:i,annotationsService:a}){const s=n&&i,l=ii(),c=e&&!!Ii(e),u=e&&l.isAnnotationFocused(e.$tag),h=e&&l.isSavingAnnotation(e),d=e&&!!l.getDraft(e)&&!h,p=l.profile().userid,f=!h&&!d,g=!n&&!t&&o>0;return po("article",{className:Ur("hyp-u-vertical-spacing",{"is-collapsed":i,"is-focused":u}),children:[e&&po(m,{children:[po(up,{annotation:e,isEditing:d,replyCount:o,threadIsCollapsed:i}),c&&po(hp,{annotation:e,isFocused:u}),!s&&!d&&po(wd,{annotation:e}),d&&po(Yd,{annotation:e})]}),!e&&!s&&po("div",{children:po("em",{children:"Message not available."})}),!s&&po("footer",{children:po("div",{className:"hyp-u-layout-row",children:[g&&po(dp,{onToggleReplies:r,replyCount:o,threadIsCollapsed:i}),h&&po("div",{
542
542
  className:"hyp-u-layout-row--justify-right hyp-u-stretch","data-testid":"saving-message",children:"Saving..."}),e&&f&&po(So,{classes:"hyp-u-stretch",children:po(Ca,{annotation:e,onReply:()=>a.reply(e,p)})})]})})]})}),["annotationsService"]);var mp=ri((function({annotation:e,api:t,toastMessenger:n}){const r=ii(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e),i=null!==o&&(o>0||e.hidden),a=()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},s=()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))},l=(()=>{const t={};return e.hidden?(t.onClick=s,t.title="Make this annotation visible to everyone"):(t.onClick=a,t.title="Hide this annotation from non-moderators"),t["aria-label"]=t.title,t})(),c=Ur("ModerationBanner",{"is-flagged":null!==o&&o>0,"is-hidden":e.hidden,"is-reply":ki(e)});return i?po("div",{className:c,
543
543
  children:[!!o&&!e.hidden&&po("span",{children:["Flagged for review x",o]}),e.hidden&&po("span",{children:["Hidden from users. Flagged x",o]}),po("span",{className:"hyp-u-stretch"}),po("button",{...l,children:e.hidden?"Unhide":"Hide"})]}):null}),["api","toastMessenger"]);function fp({annotation:e,...t}){const n=ii(),r=e&&n.isSavingAnnotation(e),o=e&&!!n.getDraft(e)&&!r;return e?po("div",{className:"Thread__top-annotation-header",children:po(up,{annotation:e,isEditing:o,...t})}):null}var gp=ri((function e({thread:t,threadsService:n}){const r=!t.collapsed,o=Ui(t)>0,i=!!t.parent,a=t.collapsed?"collapsed":"expand-menu",s=t.collapsed?"Expand replies":"Collapse replies",l=t.children.filter((e=>qi(e)>0)),c=ii(),u=c.hasAppliedFilter(),h=ro((()=>c.setExpanded(t.id,!!t.collapsed)),[c,t.id,t.collapsed]),d=no((()=>t.visible&&po(m,{children:[t.annotation&&po(mp,{annotation:t.annotation}),po(pp,{annotation:t.annotation,hasAppliedFilter:u,isReply:!!t.parent,onToggleReplies:h,replyCount:t.replyCount,
544
544
  threadIsCollapsed:t.collapsed})]})),[u,h,t.annotation,t.parent,t.replyCount,t.collapsed,t.visible]);return po("section",{className:Ur("Thread",{"Thread--reply":t.depth>0,"is-collapsed":t.collapsed}),children:[i&&po("div",{className:"Thread__collapse",children:po("div",{className:"Thread__collapse-button-container",children:po(_o,{classes:"NonResponsiveIconButton",expanded:!t.collapsed,icon:a,title:s,onClick:h,size:"medium",variant:"light"})})}),po("div",{className:"Thread__content",children:[d,o&&po(m,{children:[!t.parent&&po(fp,{annotation:t.annotation,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),po("div",{className:"Thread__hidden-toggle-button-container",children:po(bo,{onClick:()=>n.forceVisible(t),children:["Show ",Ui(t)," more in conversation"]})})]}),r&&po("ul",{className:"Thread__children",children:l.map((t=>po("li",{children:po(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var vp=ri((function({frameSync:e,thread:t}){
545
545
  const n=ii(),r=t.annotation&&t.annotation.$tag,o=r&&n.isAnnotationFocused(r),i=no((()=>ua((t=>{const n=t?[t]:[];e.focusAnnotations(n)}),10)),[e]),a=ro((t=>{e.scrollToAnnotation(t)}),[e]),s=no((()=>po(gp,{thread:t})),[t]);return po("div",{onClick:e=>{var t;(t=e.target).closest("button")||t.closest("a")||a(r)},onMouseEnter:()=>i(r),onMouseLeave:()=>i(null),className:Ur("ThreadCard",{"is-focused":o}),children:s},t.id)}),["frameSync"]);function yp(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function _p(e){return Math.max(e-e%50,0)}function bp({threads:e}){const[t,n]=Zr(0),[r,o]=Zr(0);eo((()=>{const e=new ha,t=yp();n(t.clientHeight),o(_p(t.scrollTop));const r=ua((()=>{n(t.clientHeight),o(_p(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[])
546
546
  ;const[i,a]=Zr({}),[s,l]=Zr(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:h,visibleThreads:d}=no((()=>function(e,t,n,r,o=da){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,h=0;return e.forEach((e=>{const o=t[e.id]||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):h+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:h}}(c,i,r,t)),[c,i,r,t]),p=ii(),m=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();return Qr((()=>{m&&(p.setForcedVisible(m,!0),l(m))}),[p,m]),Qr((()=>{if(!s)return;const e=c.findIndex((e=>e.id===s));if(-1===e)return;l(null);const t=c.slice(0,e).reduce(((e,t)=>e+(e=>i[e.id]||da.defaultHeight)(t)),0);yp().scrollTop=t}),[s,c,i]),Qr((()=>{a((e=>{const t={};for(let{id:n}of d){const r=document.getElementById(n);if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=pa(r);o!==e[n]&&(t[n]=o)}return 0===Object.keys(t).length?e:{...e,...t}}))}),[d]),po("div",{children:[po("div",{style:{height:h}
547
- }),d.map((e=>po("div",{className:"ThreadList__card",id:e.id,children:po(vp,{thread:e})},e.id))),po("div",{style:{height:u}})]})}function wp({errorType:e,onLoginRequest:t,showClearSelection:n=!1}){const r=ii(),o=r.isLoggedIn();return po("div",{className:"u-sidebar-container",children:po(Ho,{icon:"restricted",title:"annotation"===e?"Annotation unavailable":"Group unavailable",children:[po("p",{children:o?"group"===e?"The current URL links to a group, but that group cannot be found,\n or you do not have permission to view the annotations in that group.":"The current URL links to an annotation, but that annotation\n cannot be found, or you do not have permission to view it.":`The ${e} associated with the current URL is unavailable.\n You may need to log in to see it.`}),po("div",{className:"hyp-u-layout-row--justify-right hyp-u-horizontal-spacing",children:[n&&po(bo,{variant:o?"primary":void 0,onClick:()=>r.clearSelection(),children:"Show all annotations"}),!o&&po(bo,{variant:"primary",
548
- onClick:t,children:"Log in"})]})]})})}var xp=ri((function({loadAnnotationsService:e,onLogin:t}){const n=ii(),r=n.routeParams().id,o=Ki(),i=n.profile().userid,[a,s]=Zr(!1);return Qr((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),po(m,{children:[a&&po(wp,{errorType:"annotation",onLoginRequest:t}),po(bp,{threads:o.children})]})}),["loadAnnotationsService"]);function kp({actionButton:e,additionalCount:t=0,entitySingular:n="annotation",entityPlural:r="annotations",filterQuery:o,focusDisplayName:i,resultCount:a}){return po("div",{className:"FilterStatus",children:ii().isLoading()?po("div",{className:"hyp-u-layout-row--center",children:po(qo,{})}):po("div",{className:"hyp-u-layout-row--align-center",children:[po("div",{className:"FilterStatus__text",children:[a>0&&po("span",{children:"Showing "}),po("span",{className:"filter-facet",
547
+ }),d.map((e=>po("div",{className:"ThreadList__card",id:e.id,children:po(vp,{thread:e})},e.id))),po("div",{style:{height:u}})]})}function wp({errorType:e,onLoginRequest:t,showClearSelection:n=!1}){const r=ii(),o=r.isLoggedIn();return po("div",{className:"mb-4",children:po(Ho,{icon:"restricted",title:"annotation"===e?"Annotation unavailable":"Group unavailable",children:[po("p",{children:o?"group"===e?"The current URL links to a group, but that group cannot be found,\n or you do not have permission to view the annotations in that group.":"The current URL links to an annotation, but that annotation\n cannot be found, or you do not have permission to view it.":`The ${e} associated with the current URL is unavailable.\n You may need to log in to see it.`}),po("div",{className:"hyp-u-layout-row--justify-right hyp-u-horizontal-spacing",children:[n&&po(bo,{variant:o?"primary":void 0,onClick:()=>r.clearSelection(),children:"Show all annotations"}),!o&&po(bo,{variant:"primary",onClick:t,
548
+ children:"Log in"})]})]})})}var xp=ri((function({loadAnnotationsService:e,onLogin:t}){const n=ii(),r=n.routeParams().id,o=Ki(),i=n.profile().userid,[a,s]=Zr(!1);return Qr((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),po(m,{children:[a&&po(wp,{errorType:"annotation",onLoginRequest:t}),po(bp,{threads:o.children})]})}),["loadAnnotationsService"]);function kp({actionButton:e,additionalCount:t=0,entitySingular:n="annotation",entityPlural:r="annotations",filterQuery:o,focusDisplayName:i,resultCount:a}){return po("div",{className:"FilterStatus",children:ii().isLoading()?po("div",{className:"hyp-u-layout-row--center",children:po(qo,{})}):po("div",{className:"hyp-u-layout-row--align-center",children:[po("div",{className:"FilterStatus__text",children:[a>0&&po("span",{children:"Showing "}),po("span",{className:"filter-facet",
549
549
  children:[a>0?a:"No"," ",1===a?n:r]}),o&&po("span",{children:[" ","for"," ",po("span",{className:"filter-facet--pre",children:`'${o}'`})]}),i&&po("span",{children:[" ","by ",po("span",{className:"filter-facet",children:i})]}),t>0&&po("span",{className:"filter-facet--muted",children:[" ","(and ",t," more)"]})]}),po("div",{children:e})]})})}function Sp({filterState:e,rootThread:t}){const n=ii(),r=n.directLinkedAnnotationId(),o=n.annotationCount(),i=(t.children||[]).filter((e=>e.annotation&&e.visible)).length-e.selectedCount,a=!e.focusConfigured&&!r?`Show all (${o})`:"Show all",s=po(bo,{title:a,variant:"primary",onClick:()=>n.clearSelection(),icon:"cancel",children:a});return po(kp,{resultCount:e.selectedCount,additionalCount:i,actionButton:s})}function Cp({filterState:e,rootThread:t}){const n=ii(),r=qi(t)-e.forcedVisibleCount,o=po(bo,{icon:"cancel",variant:"primary",title:"Clear search",onClick:()=>n.clearSelection(),children:"Clear search"});return po(kp,{actionButton:o,additionalCount:e.forcedVisibleCount,
550
550
  entitySingular:"result",entityPlural:"results",filterQuery:e.filterQuery,focusDisplayName:e.focusDisplayName,resultCount:r})}function Ap({filterState:e,rootThread:t}){const n=ii(),r=qi(t)-e.forcedVisibleCount,o={};e.forcedVisibleCount>0?(o.onClick=()=>n.clearSelection(),o.title="Reset filters"):(o.onClick=()=>n.toggleFocusMode(),o.title=e.focusActive?"Show all":`Show only ${e.focusDisplayName}`);const i=e.focusActive?e.focusDisplayName:"",a=po(bo,{variant:"primary",...o,children:o.title});return po(kp,{resultCount:r,actionButton:a,additionalCount:e.forcedVisibleCount,filterQuery:e.filterQuery,focusDisplayName:i})}function Ep(){const e=Ki(),t=ii(),n=t.focusState(),r=t.forcedVisibleThreads().length,o=t.filterQuery(),i=t.selectedAnnotations().length,a=no((()=>({filterQuery:o,focusActive:n.active,focusConfigured:n.configured,focusDisplayName:n.displayName,forcedVisibleCount:r,selectedCount:i})),[n,r,o,i]);return a.selectedCount>0?po(Sp,{filterState:a,rootThread:e}):a.filterQuery?po(Cp,{filterState:a,rootThread:e
551
- }):a.focusConfigured?po(Ap,{filterState:a,rootThread:e}):null}function Tp({onLogin:e}){const t=ii();return po("div",{className:"LoggedOutMessage",children:[po("span",{children:["This is a public annotation created with Hypothesis. ",po("br",{}),"To reply or make your own annotations on this document,"," ",po("a",{className:"LoggedOutMessage__link",href:t.getLink("signup"),target:"_blank",rel:"noopener noreferrer",children:"create a free account"})," ","or"," ",po(wo,{classes:"InlineLinkButton InlineLinkButton--underlined",onClick:e,variant:"dark",children:"log in"}),"."]}),po("div",{className:"LoggedOutMessage__logo",children:po("a",{href:"https://hypothes.is","aria-label":"Hypothesis homepage",title:"Hypothesis homepage",children:po(Mo,{name:"logo",classes:"u-icon--xlarge hyp-u-color--grey-7"})})})]})}function Np(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function Lp(e){var t=e._scrollSettings;if(t){var n=t.maxSynchronousAlignments,r=function(e,t){
551
+ }):a.focusConfigured?po(Ap,{filterState:a,rootThread:e}):null}function Tp({onLogin:e}){const t=ii();return po("div",{className:"LoggedOutMessage",children:[po("span",{children:["This is a public annotation created with Hypothesis. ",po("br",{}),"To reply or make your own annotations on this document,"," ",po("a",{className:"LoggedOutMessage__link",href:t.getLink("signup"),target:"_blank",rel:"noopener noreferrer",children:"create a free account"})," ","or"," ",po(wo,{classes:"InlineLinkButton InlineLinkButton--underlined",onClick:e,variant:"dark",children:"log in"}),"."]}),po("div",{className:"LoggedOutMessage__logo",children:po("a",{href:"https://hypothes.is","aria-label":"Hypothesis homepage",title:"Hypothesis homepage",children:po(Mo,{name:"logo",classes:"w-16 h-16 hyp-u-color--grey-7"})})})]})}function Np(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function Lp(e){var t=e._scrollSettings;if(t){var n=t.maxSynchronousAlignments,r=function(e,t){
552
552
  var n,r,o,i,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),h=c&&null!=c.left?c.left:.5,d=c&&null!=c.top?c.top:.5,p=c&&null!=c.leftOffset?c.leftOffset:0,m=c&&null!=c.topOffset?c.topOffset:0,f=h,g=d;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),r=u.left+t.pageXOffset-t.innerWidth*f+s*f,o=u.top+t.pageYOffset-t.innerHeight*g+l*g,r-=p,o-=m,r=e.align.lockX?t.pageXOffset:r,o=e.align.lockY?t.pageYOffset:o,i=r-t.pageXOffset,a=o-t.pageYOffset;else{s=u.width,l=u.height,n=t.getBoundingClientRect();var v=u.left-(n.left-t.scrollLeft),y=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=y+l*g-t.clientHeight*g,r-=p,o-=m,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,a=o-t.scrollTop}return{x:r,y:o,differenceX:i,differenceY:a}}(t,e),o=Date.now()-t.startTime,i=Math.min(1/t.time*o,1);if(t.endIterations>=n)return Np(e,r.x,r.y),
553
553
  e._scrollSettings=null,t.end("complete");var a=1-t.ease(i);if(Np(e,r.x-r.differenceX*a,r.y-r.differenceY*a),o>=t.time)return t.endIterations++,t.scrollAncestor&&Lp(t.scrollAncestor),void Lp(e);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(Lp.bind(null,e))}}function Mp(e){return e.self===e}function zp(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function Op(){return!0}function Ip(e){if(e.assignedSlot)return Ip(e.assignedSlot);if(e.parentElement)return"BODY"===e.parentElement.tagName?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t.host}}var Rp=function(e,t,n){if(e){"function"==typeof t&&(n=t,t=null),t||(t={}),t.time=isNaN(t.time)?1e3:t.time,t.ease=t.ease||function(e){return 1-Math.pow(1-e,e/2)},t.align=t.align||{}
554
554
  ;var r=Ip(e),o=1,i=t.validTarget||Op,a=t.isScrollable;t.debug&&(console.log("About to scroll to",e),r||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var s=[];r;)if(t.debug&&console.log("Scrolling parent node",r),i(r,o)&&(a?a(r,zp):zp(r))&&(o++,s.push(r)),!(r=Ip(r))){l("complete");break}return s.reduce(((n,r,o)=>function(e,t,n,r,o){var i,a=!t._scrollSettings,s=t._scrollSettings,l=Date.now(),c={passive:!0};function u(e){t._scrollSettings=null,t.parentElement&&t.parentElement._scrollSettings&&t.parentElement._scrollSettings.end(e),n.debug&&console.log("Scrolling ended with type",e,"for",t),o(e),i&&(t.removeEventListener("touchstart",i,c),t.removeEventListener("wheel",i,c))}s&&s.end("canceled");var h=n.maxSynchronousAlignments;return null==h&&(h=3),t._scrollSettings={startTime:l,endIterations:0,target:e,time:n.time,ease:n.ease,align:n.align,isWindow:n.isWindow||Mp,maxSynchronousAlignments:h,end:u,scrollAncestor:r},"cancellable"in n&&!n.cancellable||(i=u.bind(null,"canceled"),
555
- t.addEventListener("touchstart",i,c),t.addEventListener("wheel",i,c)),a&&Lp(t),i}(e,r,t,s[o+1],l)),null)}function l(e){--o||n&&n(e)}};function Pp({children:e,icon:t="",panelName:n,title:r,onActiveChanged:o}){const i=ii(),a=i.isSidebarPanelOpen(n),s=to(null),l=to(a);Qr((()=>{l.current!==a&&(l.current=a,a&&Rp(s.current),"function"==typeof o&&o(a))}),[a,o]);const c=ro((()=>{i.toggleSidebarPanel(n,!1)}),[i,n]);return po(Gd,{visible:a,children:po("div",{ref:s,className:"u-sidebar-container",children:po(Ho,{title:r,icon:t,onClose:c,children:e})})})}function Dp({onLogin:e,onSignUp:t}){return ii().isLoggedIn()?null:po(Pp,{icon:"restricted",title:"Login needed",panelName:"loginPrompt",children:[po("p",{children:"Please log in to create annotations or highlights."}),po(So,{children:[po(bo,{title:"Sign up",onClick:t,children:"Sign up"}),po(bo,{title:"Log in",variant:"primary",onClick:e,children:"Log in"})]})]})}function Bp({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i}){const a=()=>{r||i()
556
- },s=t>0?`${o} (${t} available)`:o;return po(bo,{classes:Ur("u-color-text","SelectionTab",{"is-selected":r}),onClick:a,onMouseDown:a,pressed:!!r,role:"tab",tabIndex:0,title:s,children:po(m,{children:[e,t>0&&!n&&po("span",{className:"u-font--xsmall",style:"position:relative;bottom:3px;left:2px",children:t})]})})}var Fp=ri((function({annotationsService:e,isLoading:t,settings:n}){const r=ii(),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 po("div",{className:"hyp-u-vertical-spacing--4 SelectionTabs__container",children:[po("div",{className:"hyp-u-layout-row hyp-u-horizontal-spacing--6 SelectionTabs",role:"tablist",children:[po(Bp,{count:a,isWaitingToAnchor:l,isSelected:"annotation"===o,label:"Annotations",onSelect:()=>c("annotation"),children:"Annotations"}),po(Bp,{count:i,isWaitingToAnchor:l,isSelected:"note"===o,label:"Page notes",onSelect:()=>c("note"),
557
- children:"Page Notes"}),s>0&&po(Bp,{count:s,isWaitingToAnchor:l,isSelected:"orphan"===o,label:"Orphans",onSelect:()=>c("orphan"),children:"Orphans"})]}),"note"===o&&n.enableExperimentalNewNoteButton&&po("div",{className:"hyp-u-layout-row--justify-right",children:po(bo,{"data-testid":"new-note-button",icon:"add",onClick:()=>e.createPageNote(),variant:"primary",style:ti(["ctaBackgroundColor"],n),children:"New note"})}),!t&&h&&po(ko,{classes:"u-text--centered",children:po("span",{"data-testid":"notes-unavailable-message",children:"There are no page notes in this group."})}),!t&&u&&po(ko,{classes:"u-text--centered",children:po("span",{"data-testid":"annotations-unavailable-message",children:["There are no annotations in this group.",po("br",{}),"Create one by selecting some text and clicking the"," ",po(Mo,{classes:"m-0.5 inline -mt-0.5",name:"annotate",title:"Annotate"})," ","button."]})})]})}),["annotationsService","settings"])
558
- ;var jp=ri((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const i=Ki(),a=ii(),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?ji(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=to(s);Qr((()=>{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]),Qr((()=>{v?(e.focusAnnotations([v]),e.scrollToAnnotation(v),a.selectTab(p)):d&&a.selectTab(p)}),[p,e,d,v,a]);const C=a.hasFetchedProfile();return Qr((()=>{C&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[C,u,f,o]),po("div",{children:[po("h2",{className:"u-screen-reader-only",children:"Annotations"}),w&&po(Ep,{}),po(Dp,{onLogin:t,
559
- onSignUp:n}),y&&po(wp,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),_&&po(wp,{errorType:"group",onLoginRequest:t}),x&&po(Fp,{isLoading:c}),po(bp,{threads:i.children}),k&&po(Tp,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Hp=ri((function({api:e,toastMessenger:t}){const n=ii(),r=n.routeParams().q,o=ro((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...yi(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Qr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),po(bp,{threads:Ki().children})}),["api","toastMessenger"]);class Up{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.970.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,
555
+ t.addEventListener("touchstart",i,c),t.addEventListener("wheel",i,c)),a&&Lp(t),i}(e,r,t,s[o+1],l)),null)}function l(e){--o||n&&n(e)}};function Pp({children:e,icon:t="",panelName:n,title:r,onActiveChanged:o}){const i=ii(),a=i.isSidebarPanelOpen(n),s=to(null),l=to(a);Qr((()=>{l.current!==a&&(l.current=a,a&&Rp(s.current),"function"==typeof o&&o(a))}),[a,o]);const c=ro((()=>{i.toggleSidebarPanel(n,!1)}),[i,n]);return po(Gd,{visible:a,children:po("div",{ref:s,className:"mb-4",children:po(Ho,{title:r,icon:t,onClose:c,children:e})})})}function Dp({onLogin:e,onSignUp:t}){return ii().isLoggedIn()?null:po(Pp,{icon:"restricted",title:"Login needed",panelName:"loginPrompt",children:[po("p",{children:"Please log in to create annotations or highlights."}),po(So,{children:[po(bo,{title:"Sign up",onClick:t,children:"Sign up"}),po(bo,{title:"Log in",variant:"primary",onClick:e,children:"Log in"})]})]})}function Bp({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i}){const a=()=>{r||i()
556
+ },s=t>0?`${o} (${t} available)`:o;return po(bo,{classes:Ur("text-color-text","SelectionTab",{"is-selected":r}),onClick:a,onMouseDown:a,pressed:!!r,role:"tab",tabIndex:0,title:s,children:po(m,{children:[e,t>0&&!n&&po("span",{className:"text-tiny",style:"position:relative;bottom:3px;left:2px",children:t})]})})}var Fp=ri((function({annotationsService:e,isLoading:t,settings:n}){const r=ii(),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 po("div",{className:"hyp-u-vertical-spacing--4 SelectionTabs__container",children:[po("div",{className:"hyp-u-layout-row hyp-u-horizontal-spacing--6 SelectionTabs",role:"tablist",children:[po(Bp,{count:a,isWaitingToAnchor:l,isSelected:"annotation"===o,label:"Annotations",onSelect:()=>c("annotation"),children:"Annotations"}),po(Bp,{count:i,isWaitingToAnchor:l,isSelected:"note"===o,label:"Page notes",onSelect:()=>c("note"),
557
+ children:"Page Notes"}),s>0&&po(Bp,{count:s,isWaitingToAnchor:l,isSelected:"orphan"===o,label:"Orphans",onSelect:()=>c("orphan"),children:"Orphans"})]}),"note"===o&&n.enableExperimentalNewNoteButton&&po("div",{className:"hyp-u-layout-row--justify-right",children:po(bo,{"data-testid":"new-note-button",icon:"add",onClick:()=>e.createPageNote(),variant:"primary",style:ti(["ctaBackgroundColor"],n),children:"New note"})}),!t&&h&&po(ko,{classes:"text-center",children:po("span",{"data-testid":"notes-unavailable-message",children:"There are no page notes in this group."})}),!t&&u&&po(ko,{classes:"text-center",children:po("span",{"data-testid":"annotations-unavailable-message",children:["There are no annotations in this group.",po("br",{}),"Create one by selecting some text and clicking the"," ",po(Mo,{classes:"m-0.5 inline -mt-0.5",name:"annotate",title:"Annotate"})," ","button."]})})]})}),["annotationsService","settings"]);var jp=ri((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){
558
+ const i=Ki(),a=ii(),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?ji(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=to(s);Qr((()=>{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]),Qr((()=>{v?(e.focusAnnotations([v]),e.scrollToAnnotation(v),a.selectTab(p)):d&&a.selectTab(p)}),[p,e,d,v,a]);const C=a.hasFetchedProfile();return Qr((()=>{C&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[C,u,f,o]),po("div",{children:[po("h2",{className:"sr-only",children:"Annotations"}),w&&po(Ep,{}),po(Dp,{onLogin:t,onSignUp:n}),y&&po(wp,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),_&&po(wp,{
559
+ errorType:"group",onLoginRequest:t}),x&&po(Fp,{isLoading:c}),po(bp,{threads:i.children}),k&&po(Tp,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Hp=ri((function({api:e,toastMessenger:t}){const n=ii(),r=n.routeParams().q,o=ro((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...yi(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Qr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),po(bp,{threads:Ki().children})}),["api","toastMessenger"]);class Up{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.974.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,
560
560
  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 qp(e){const t=P(e);return!(null==t||!t.authority)&&t.authority!==e.authDomain}function $p({commandName:e,iconName:t}){return po("span",{className:"whitespace-nowrap",children:[po(Mo,{name:t,classes:Ur("mx-1 -mt-1","text-color-text-light inline")}),po("em",{children:e})]})}var Gp=ri((function({settings:e}){const t=!qp(e);return po("ol",{className:"list-decimal pl-10 space-y-2",children:[po("li",{children:["To create an annotation, select text and then select the"," ",po($p,{iconName:"annotate",commandName:"Annotate"})," ","button."]}),po("li",{
561
- children:["To create a highlight (",po(zo,{href:"https://web.hypothes.is/help/why-are-highlights-private-by-default/",target:"_blank",children:"visible only to you"}),"), select text and then select the"," ",po($p,{iconName:"highlight",commandName:"Highlight"})," ","button."]}),t&&po("li",{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"," ",po(zo,{href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",children:"join link"}),")."]}),po("li",{children:["To reply to an annotation, select the"," ",po($p,{iconName:"reply",commandName:"Reply"})," button."]})]})}),["settings"]);var Vp=ri((function({toastMessenger:e,versionData:t}){return po("div",{className:"hyp-u-vertical-spacing",children:[po("dl",{className:"VersionInfo",children:[po("dt",{className:"VersionInfo__key",children:"Version"}),po("dd",{className:"VersionInfo__value",children:t.version}),po("dt",{className:"VersionInfo__key",
562
- children:"User Agent"}),po("dd",{className:"VersionInfo__value",children:t.userAgent}),po("dt",{className:"VersionInfo__key",children:"URL"}),po("dd",{className:"VersionInfo__value",children:t.urls}),po("dt",{className:"VersionInfo__key",children:"Fingerprint"}),po("dd",{className:"VersionInfo__value",children:t.fingerprint}),po("dt",{className:"VersionInfo__key",children:"Account"}),po("dd",{className:"VersionInfo__value",children:t.account}),po("dt",{className:"VersionInfo__key",children:"Date"}),po("dd",{className:"VersionInfo__value",children:t.timestamp})]}),po("div",{className:"hyp-u-layout-row--justify-center",children:po(bo,{onClick:()=>{try{ba(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"]);function Wp({linkText:e,url:t}){return po("div",{className:"HelpPanel-tabs__tab",children:po("a",{href:t,
563
- className:"hyp-u-horizontal-spacing--2 hyp-u-layout-row--center HelpPanel-tabs__link",target:"_blank",rel:"noopener noreferrer",children:[po("span",{children:e})," ",po(Mo,{name:"external",classes:"u-icon--small"})]})})}var Yp=ri((function({auth:e,session:t}){const n=ii(),r=n.frames(),o=n.mainFrame(),i=!!n.profile().preferences.show_sidebar_tutorial,[a,s]=Zr("tutorial"),l=no((()=>{const t=e||{status:"logged-out"},n=[...r].sort(((e,t)=>e===o?-1:t===o?1:0));return new Up(t,n)}),[e,r,o]),c=`https://web.hypothes.is/get-help/?sys_info=${l.asEncodedURLString()}`,u=(e,t)=>{e.preventDefault(),s(t)};return po(Pp,{title:"Help",panelName:"help",onActiveChanged:ro((e=>{!e&&i&&t.dismissSidebarTutorial()}),[t,i]),children:po("div",{className:"hyp-u-vertical-spacing HelpPanel__content",children:[po("div",{className:"hyp-u-layout-row--align-center",children:[po("h3",{className:"HelpPanel__sub-panel-title",children:{tutorial:"Getting started",versionInfo:"About this version"}[a]}),po("div",{
564
- children:["versionInfo"===a&&po("button",{className:"HelpPanel__sub-panel-navigation-button",onClick:e=>u(e,"tutorial"),"aria-label":"Show tutorial panel",children:["Getting started",po(Mo,{name:"arrow-right"})]}),"tutorial"===a&&po("button",{className:"HelpPanel__sub-panel-navigation-button",onClick:e=>u(e,"versionInfo"),"aria-label":"Show version information panel",children:["About this version",po(Mo,{name:"arrow-right"})]})]})]}),po("div",{className:"HelpPanel__subcontent",children:["tutorial"===a&&po(Gp,{}),"versionInfo"===a&&po(Vp,{versionData:l})]}),po("div",{className:"HelpPanel-tabs",children:[po(Wp,{linkText:"Help topics",url:"https://web.hypothes.is/help/"}),po(Wp,{linkText:"New support ticket",url:c})]})]})})}),["session"]),Kp={exports:{}};function Xp(){}Xp.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function o(){r.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){
565
- for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),r=n[e],o=[];if(r&&t)for(var i=0,a=r.length;i<a;i++)r[i].fn!==t&&r[i].fn._!==t&&o.push(r[i]);return o.length?n[e]=o:delete n[e],this}},Kp.exports=Xp;var Zp=Kp.exports.TinyEmitter=Xp;class Jp extends Error{constructor(e){super(`Results size exceeds ${e}`)}}function Qp(e){return 0===e?50:200}class em extends Zp{constructor(e,{getPageSize:t=Qp,separateReplies:n=!0,incremental:r=!0,maxResults:o=null,sortBy:i="created",sortOrder:a="asc"}={}){super(),this._searchFn=e,this._getPageSize=t,this._separateReplies=n,this._incremental=r,this._maxResults=o,this._sortBy=i,this._sortOrder=a,this._canceled=!1,this._results=[],this._resultCount=null}async _getPage(e,t,n=0){const r=this._getPageSize(n),o={limit:r,sort:this._sortBy,order:this._sortOrder,_separate_replies:this._separateReplies,...e};t&&(o.search_after=t);try{
566
- const t=await this._searchFn(o);if(this._canceled)return;if(null===this._resultCount&&(this._resultCount=t.total,this.emit("resultCount",this._resultCount)),this._maxResults&&t.total>this._maxResults)return this.emit("error",new Jp(this._maxResults)),void this.emit("end");const i=t.rows.concat(t.replies||[]);this._incremental?this.emit("results",i):this._results=this._results.concat(i);const a=i.length===r,s=i.length>0?i[i.length-1][this._sortBy]:null;a&&s?this._getPage(e,s,n+1):(this._incremental||this.emit("results",this._results),this.emit("end"))}catch(e){if(this._canceled)return;this.emit("error",e),this.emit("end")}}get(e){this._results=[],this._resultCount=null,this._getPage(e)}cancel(){this._canceled=!0,this.emit("end")}}function tm({defaultOption:e,icon:t,onSelect:n,options:r,selectedOption:o,title:i}){const a=[e,...r],s=null!=o?o:e,l=po("span",{className:"FilterSelect__menu-label",children:[t&&po(Mo,{name:t,classes:"u-icon--medium hyp-u-margin--right--3"}),s.display]});return po($d,{label:l,title:i,
567
- contentClass:"FilterSelect__menu",children:a.map((e=>po(Vd,{onClick:()=>n(e),isSelected:e.value===s.value,label:e.display},e.value)))})}function nm(){const e=ii(),t=e.getFilter("user"),n=function(){const e=ii(),t=e.allAnnotations(),n=e.defaultAuthority(),r=e.isFeatureEnabled("client_display_names"),o=e.getFocusFilters(),i=Jo(e.profile().userid);return no((()=>{const e={};if(t.forEach((t=>{const o=Jo(t.user);e[o]=Kd(t,Qo(t.user,n),r)})),o.user){const t=Jo(o.user.value)||o.user.value;e[t]=o.user.display}const a=Object.keys(e).map((t=>({display:t===i?`${e[t]} (Me)`:e[t],value:t})));return a.sort(((e,t)=>i===e.value?-1:i===t.value?1:e.display.localeCompare(t.display))),a}),[t,i,n,r,o.user])}();return po(tm,{defaultOption:{value:"",display:"Everybody"},icon:"profile",onSelect:t=>e.setFilter("user",t),options:n,selectedOption:t,title:"Filter by user"})}function rm({forcedVisibleCount:e,isFiltered:t,isLoading:n,resultCount:r}){const o=Ki(),i=n?r:qi(o),a=o.children.length>0,s=t&&e>0,l=i-e,c=o.children.length
568
- ;return po("div",{className:"hyp-u-layout-row NotebookResultCount",children:[n&&po(qo,{size:"small"}),!n&&po("h2",{children:[!a&&po("strong",{children:"No results"}),a&&t&&po("strong",{children:[l," ",1===l?"result":"results"]}),a&&!t&&po("strong",{children:[c," ",1===c?"thread":"threads"]})]}),s&&po("h3",{children:["(and ",e," more)"]}),!t&&a&&po("h3",{children:["(",i," ",1===i?"annotation":"annotations",")"]})]})}function om({currentPage:e,onChangePage:t,totalPages:n}){const r=e<n,o=e>1,i=function(e,t,n=5){if(t<=1)return[];const r=new Set([1,e,t]);let o=1;for(;r.size<Math.min(t,n);)e+o<=t&&r.add(e+o),e-o>=1&&r.add(e-o),++o;const i=[];return[...r].sort(((e,t)=>e-t)).forEach(((e,t,n)=>{t>0&&e-n[t-1]>1&&i.push(null),i.push(e)})),i}(e,n),a=(e,n)=>{t(e),null==n||n.blur()};return po("div",{className:"PaginationNavigation",children:[po("div",{className:"PaginationNavigation__relative PaginationNavigation__prev",children:o&&po(bo,{classes:"PaginationPageButton",icon:"arrow-left",title:"Go to previous page",
569
- onClick:t=>a(e-1,t.target),variant:"dark",children:"prev"})}),po("ul",{className:"PaginationNavigation__pages",children:i.map(((t,n)=>po("li",{children:null===t?po("div",{className:"PaginationNavigation__gap",children:"..."}):po(bo,{classes:"PaginationPageButton",title:`Go to page ${t}`,pressed:t===e,onClick:e=>a(t,e.target),variant:"dark",children:t.toString()},`page-${n}`)},n)))}),po("div",{className:"PaginationNavigation__relative PaginationNavigation__next",children:r&&po(bo,{classes:"PaginationPageButton",icon:"arrow-right",iconPosition:"right",title:"Go to next page",onClick:t=>a(e+1,t.target),variant:"dark",children:"next"})})]})}function im({currentPage:e,isLoading:t,onChangePage:n,threads:r,pageSize:o=25}){const{paginatedThreads:i,totalPages:a}=no((()=>{const t=r.filter((e=>qi(e)>0)),n=(e-1)*o,i=n+o,a=Math.ceil(t.length/o);return{paginatedThreads:t.slice(n,i),totalPages:a}}),[r,e,o]);return po(m,{children:[po(bp,{threads:i}),!t&&po(om,{currentPage:e,onChangePage:n,totalPages:a})]})}
570
- var am=ri((function({loadAnnotationsService:e,streamer:t}){var n;const r=ii(),o=r.getFilterValues(),i=r.focusedGroup(),a=r.forcedVisibleThreads().length,s=r.hasAppliedFilter(),l=r.isLoading(),c=r.annotationResultCount(),u=r.pendingUpdateCount(),h=Ki(),d=null!==(n=null==i?void 0:i.name)&&void 0!==n?n:"…",p=(null==i?void 0:i.id)||r.directLinkedGroupId(),m=to(1),[f,g]=Zr(1),[v,y]=Zr(!1),_=e=>{e instanceof Jp&&y(!0)},b=r.hasFetchedProfile();Qr((()=>{b&&t.connect({applyUpdatesImmediately:!1})}),[b,t]),Qr((()=>{r.setSortKey("Newest"),p&&e.load({groupId:p,sortBy:"updated",sortOrder:"desc",maxResults:5e3,onError:_,streamFilterBy:"group"})}),[e,p,r]);const w=e=>{g(e)};Qr((()=>{w(1)}),[o,i]);const x=to(null);eo((()=>{f!==m.current&&(Rp(x.current),m.current=f)}),[f]);const k=`Show ${u} new or updated ${u>1?"annotations":"annotation"}`;return po("div",{className:"NotebookView",children:[po("header",{className:"NotebookView__heading",ref:x,children:po("h1",{className:"NotebookView__group-name",children:d})}),po("div",{
571
- className:"NotebookView__filters",children:po(nm,{})}),po("div",{className:"NotebookView__results hyp-u-layout-row--align-center u-font--large",children:[u>0&&!s&&po(_o,{icon:"refresh",onClick:()=>t.applyPendingUpdates(),variant:"primary",title:k}),po(rm,{forcedVisibleCount:a,isFiltered:s,isLoading:l,resultCount:c})]}),po("div",{className:"NotebookView__items",children:[v&&po("div",{className:"NotebookView__messages",children:po(Ho,{title:"Too many results to show",children:["This preview of the Notebook can show"," ",po("strong",{children:["up to ",5e3," results"]})," at a time (there are"," ",c," to show here)."," ",po("a",{href:"mailto:support@hypothes.is?subject=Hypothesis%20Notebook&body=Please%20notify%20me%20when%20the%20Hypothesis%20Notebook%20is%20updated%20to%20support%20more%20than%205000%20annotations",children:"Contact us"})," ","if you would like to be notified when support for more annotations is available."]})}),po(im,{currentPage:f,isLoading:l,onChangePage:w,threads:h.children})]})]})
572
- }),["loadAnnotationsService","streamer"]);var sm=ri((function({toastMessenger:e}){const t=ii(),n=t.mainFrame(),r=t.focusedGroup(),o=`Share Annotations in ${r&&r.name||"..."}`,i=r&&n,a=i&&(s=n.uri,l=r.id,ma(s)?`https://hyp.is/go?url=${encodeURIComponent(s)}&group=${l}`:null);var s,l;return po(Pp,{title:o,panelName:"shareGroupAnnotations",children:[!i&&po("div",{className:"flex flex-row items-center justify-center",children:po(qo,{})}),i&&po("div",{className:"text-color-text-light space-y-3",children:a?po(m,{children:[po("div",{className:"text-color-text font-medium","data-testid":"sharing-intro",children:"private"===r.type?po("p",{children:"Use this link to share these annotations with other group members:"}):po("p",{children:"Use this link to share these annotations with anyone:"})}),po("div",{children:po(Vo,{children:[po(Go,{"aria-label":"Use this URL to share these annotations",type:"text",value:a,readOnly:!0}),po(_o,{icon:"copy",onClick:()=>{try{ba(a),e.success("Copied share link to clipboard")}catch(t){
573
- e.error("Unable to copy link")}},title:"Copy share link",variant:"dark"})]})}),po("p",{"data-testid":"sharing-details",children:["private"===r.type?po("span",{children:["Annotations in the private group"," ",po("em",{children:r.name})," are only visible to group members."]}):po("span",{children:["Anyone using this link may view the annotations in the group"," ",po("em",{children:r.name}),"."]})," ",po("span",{children:["Private (",po(Mo,{name:"lock",classes:"inline -mt-0.5"})," ",po("em",{children:"Only Me"}),") annotations are only visible to you."]})]}),po(xa,{shareURI:a})]}):po("p",{"data-testid":"no-sharing",children:"These annotations cannot be shared because this document is not available on the web."})})]})}),["toastMessenger"]);function lm({message:e,onDismiss:t}){const n=e.type.charAt(0).toUpperCase()+e.type.slice(1),r="notice"===e.type?"cancel":e.type;return po("li",{className:Ur("toast-message-container",{"is-dismissed":e.isDismissed}),onClick:()=>t(e.id),children:po("div",{
574
- className:Ur("toast-message",`toast-message--${e.type}`),children:[po("div",{className:"toast-message__type",children:po(Mo,{name:r,classes:"toast-message__icon"})}),po("div",{className:"toast-message__message",children:[po("strong",{children:[n,": "]}),e.message,e.moreInfoURL&&po("div",{className:"toast-message__link",children:po("a",{href:e.moreInfoURL,onClick:e=>e.stopPropagation(),target:"_new",children:"More info"})})]})]})})}var cm=ri((function({toastMessenger:e}){return po("div",{children:po("ul",{"aria-live":"polite","aria-relevant":"additions",className:"ToastMessages",children:ii().getToastMessages().map((t=>po(lm,{message:t,onDismiss:t=>e.dismiss(t)},t.id)))})})}),["toastMessenger"]);function um(e){return e.organization&&e.organization.name}function hm(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;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=[]),
575
- 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 dm(e){const t=hm(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 pm({heading:e,children:t}){return po(m,{children:[e&&po("h2",{className:"MenuSection__heading",children:e}),po("ul",{className:"MenuSection__content",children:x(t).map((e=>po("li",{children:e},e.key)))})]})}var mm=ri((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=ii(),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";return po(Vd,{icon:t.logo||"blank",iconAlt:um(t),isDisabled:!s,isExpanded:!!a&&e,isSelected:u,isSubmenuVisible:a?e:void 0,label:t.name,onClick:s?()=>{
576
- l.clearDirectLinkedGroupFetchFailed(),l.clearDirectLinkedIds(),n.focus(t.id)}:h,onToggleSubmenu:h,submenu:po(m,{children:[po("ul",{children:[i&&po("li",{children:po(Vd,{href:i,icon:"external",isSubmenuItem:!0,label:"View group activity"})}),i&&po("li",{children:po(Vd,{onClick:()=>(e=>{try{ba(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&&po("li",{children:po(Vd,{icon:"leave",isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await Xo({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&po("p",{className:"GroupListItem__footer",children:"This group is restricted to specific URLs."})]})})}),["groups","toastMessenger"]);function fm({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return po(pm,{heading:r,children:n.map((n=>po(mm,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}
577
- var gm=ri((function({settings:e}){const t=ii(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=no((()=>dm(o)),[o]),l=no((()=>dm(r)),[r]),c=no((()=>dm(n)),[n]),u=t.defaultAuthority(),h=a&&!Qo(a,u),d=t.getLink("groups.new"),[p,m]=Zr(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=um(i)?um(i):"";f=po("span",{className:"GroupList__menu-label",children:[t&&po("img",{className:"GroupList__menu-icon",src:t,alt:n}),i.name]})}else f=po("span",{children:"…"});return!!qp(e)&&n.length+r.length+o.length<2?f:po($d,{align:"left",contentClass:"GroupList__content",label:f,onOpenChanged:()=>m(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[c.length>0&&po(fm,{expandedGroup:p,onExpandGroup:m,heading:"Currently Viewing",groups:c}),l.length>0&&po(fm,{expandedGroup:p,onExpandGroup:m,heading:"Featured Groups",groups:l}),s.length>0&&po(fm,{expandedGroup:p,onExpandGroup:m,
578
- heading:"My Groups",groups:s}),h&&po(Vd,{icon:"add",href:d,label:"New private group"})]})}),["settings"]);function vm({alwaysExpanded:e,query:t,onSearch:n}){const r=ii().isLoading(),o=to(),[i,a]=Zr(t),[s,l]=Zr(t);return t!==i&&(l(t),a(t)),po("form",{action:"#",className:"SearchInput__form",name:"searchForm",onSubmit:e=>{e.preventDefault(),(o.current.value||i)&&n(o.current.value)},children:[po("input",{"aria-label":"Search",className:Ur("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&&po("div",{className:"SearchInput__button-container",children:po(_o,{icon:"search",onClick:()=>o.current.focus(),size:"small",title:"Search annotations"})}),r&&po("div",{style:"margin:0.5em 0",children:po(qo,{size:"small"})})]})}function ym(){const e=ii(),t=e.sortKey(),n=e.sortKeys().map((n=>po(Vd,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=po("span",{className:"TopBar__menu-label",
579
- children:po(Mo,{name:"sort",classes:"TopBar__menu-icon"})});return po("div",{className:"SortMenu",children:po($d,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var _m=ri((function({router:e}){return po(vm,{query:ii().routeParams().q,onSearch:t=>{e.navigate("stream",{q:t})},alwaysExpanded:!0})}),["router"]);var bm=ri((function({auth:e,frameSync:t,onLogout:n,settings:r}){const o=ii(),i=o.defaultAuthority(),a=Qo(e.userid,i),s=P(r),l=o.isFeatureEnabled("notebook_launch"),[c,u]=Zr(!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=po("span",{className:"TopBar__menu-label",children:po(Mo,{name:"profile",classes:"TopBar__menu-icon"})});return po("div",{className:"UserMenu",onKeyDown:e=>{"n"===e.key&&(m(),u(!1))},children:po($d,{label:v,title:e.displayName,
580
- align:"right",open:c,onOpenChanged:u,children:[po(pm,{children:[po(Vd,{label:e.displayName,isDisabled:!d,...g}),!a&&po(Vd,{label:"Account settings",href:o.getLink("account.settings")}),l&&po(Vd,{label:"Open notebook",onClick:()=>m()})]}),p&&po(pm,{children:po(Vd,{label:"Log out",onClick:n})})]})})}),["frameSync","settings"]);var wm=ri((function({auth:e,frameSync:t,isSidebar:n,onLogin:r,onLogout:o,onSignUp:i,settings:a,streamer:s}){const l=!qp(a),c=ti(["accentColor"],a),u=ii(),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=po(m,{children:["unknown"===e.status&&po("span",{className:"TopBar__login-links",children:"⋯"}),"logged-out"===e.status&&po("span",{className:"TopBar__login-links u-font--large hyp-u-horizontal-spacing--2",children:[po(wo,{classes:"InlineLinkButton",onClick:i,style:c,variant:"primary",children:"Sign up"
581
- }),po("div",{children:"/"}),po(wo,{classes:"InlineLinkButton",onClick:r,style:c,variant:"primary",children:"Log in"})]}),"logged-in"===e.status&&po(bm,{auth:e,onLogout:o})]});return po("div",{className:"TopBar",children:[!n&&po("div",{className:"TopBar__inner content",children:[po(_m,{}),po("div",{className:"hyp-u-stretch"}),po(_o,{icon:"help",expanded:p,onClick:g,size:"small",title:"Help"}),v]}),n&&po("div",{className:"TopBar__inner content",children:[po(gm,{}),po("div",{className:"hyp-u-stretch"}),d>0&&po(_o,{icon:"refresh",onClick:()=>s.applyPendingUpdates(),size:"small",variant:"primary",title:`Show ${d} new/updated ${1===d?"annotation":"annotations"}`}),po(vm,{query:h||null,onSearch:u.setFilterQuery}),po(ym,{}),l&&po(_o,{icon:"share",expanded:f,onClick:()=>{u.toggleSidebarPanel("shareGroupAnnotations")},size:"small",title:"Share annotations on this page"}),po(_o,{icon:"help",expanded:p,onClick:g,size:"small",title:"Help"}),v]})]})}),["frameSync","settings","streamer"])
582
- ;var xm=ri((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=ii(),a=i.hasFetchedProfile(),s=i.profile(),l=i.route(),c=no((()=>a?function(e){const t=Zo(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=no((()=>ti(["appBackgroundColor"],n)),[n]),h="clean"===n.theme,d="sidebar"===l;Qr((()=>{(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{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 po("div",{
583
- className:Ur("HypothesisApp","js-thread-list-scroll-root",{"theme-clean":h,"HypothesisApp--notebook":"notebook"===l}),style:u,children:["notebook"!==l&&po(wm,{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?"),Xo({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),P(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),po("div",{className:"HypothesisApp__content",children:[po(cm,{}),po(Yp,{auth:"logged-in"===c.status?c:{}}),po(sm,{}),l&&po("main",{children:["annotation"===l&&po(xp,{onLogin:p}),"notebook"===l&&po(am,{}),"stream"===l&&po(Hp,{}),"sidebar"===l&&po(jp,{onLogin:p,onSignUp:m})]})]})]})}),["auth","frameSync","session","settings","toastMessenger"])
584
- ;function km({error:e}){return po("div",{className:"LaunchErrorPanel",children:po(Ho,{title:"Unable to start Hypothesis",children:e.message})})}class Sm{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?fa(e.user):ga(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:va(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return Ni(l)&&(l.permissions=fa(i)),l}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Ni(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!Ci(n)}),
561
+ children:["To create a highlight (",po(zo,{classes:"underline hover:underline",href:"https://web.hypothes.is/help/why-are-highlights-private-by-default/",target:"_blank",children:"visible only to you"}),"), select text and then select the"," ",po($p,{iconName:"highlight",commandName:"Highlight"})," ","button."]}),t&&po("li",{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"," ",po(zo,{classes:"underline hover:underline",href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",children:"join link"}),")."]}),po("li",{children:["To reply to an annotation, select the"," ",po($p,{iconName:"reply",commandName:"Reply"})," button."]})]})}),["settings"]);var Vp=ri((function({toastMessenger:e,versionData:t}){return po("div",{className:"hyp-u-vertical-spacing",children:[po("dl",{className:"VersionInfo",children:[po("dt",{className:"VersionInfo__key",children:"Version"}),po("dd",{
562
+ className:"VersionInfo__value",children:t.version}),po("dt",{className:"VersionInfo__key",children:"User Agent"}),po("dd",{className:"VersionInfo__value",children:t.userAgent}),po("dt",{className:"VersionInfo__key",children:"URL"}),po("dd",{className:"VersionInfo__value",children:t.urls}),po("dt",{className:"VersionInfo__key",children:"Fingerprint"}),po("dd",{className:"VersionInfo__value",children:t.fingerprint}),po("dt",{className:"VersionInfo__key",children:"Account"}),po("dd",{className:"VersionInfo__value",children:t.account}),po("dt",{className:"VersionInfo__key",children:"Date"}),po("dd",{className:"VersionInfo__value",children:t.timestamp})]}),po("div",{className:"hyp-u-layout-row--justify-center",children:po(bo,{onClick:()=>{try{ba(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"]);function Wp({children:e,onClick:t}){return po(wo,{
563
+ classes:"leading-none text-brand",onClick:t,children:[e,po(Mo,{classes:"ml-1",name:"arrow-right"})]})}function Yp({linkText:e,url:t}){return po("div",{className:"flex-1 border-r last-of-type:border-r-0",children:po(zo,{href:t,classes:"flex items-center justify-center space-x-2 text-color-text-light text-lg font-medium",target:"_blank",children:[po("span",{children:e})," ",po(Mo,{name:"external",classes:"w-3 h-3"})]})})}var Kp=ri((function({auth:e,session:t}){const n=ii(),r=n.frames(),o=n.mainFrame(),i=!!n.profile().preferences.show_sidebar_tutorial,[a,s]=Zr("tutorial"),l=no((()=>{const t=e||{status:"logged-out"},n=[...r].sort(((e,t)=>e===o?-1:t===o?1:0));return new Up(t,n)}),[e,r,o]),c=`https://web.hypothes.is/get-help/?sys_info=${l.asEncodedURLString()}`,u=(e,t)=>{e.preventDefault(),s(t)};return po(Pp,{title:"Help",panelName:"help",onActiveChanged:ro((e=>{!e&&i&&t.dismissSidebarTutorial()}),[t,i]),children:po("div",{className:"space-y-4",children:[po("div",{className:"flex items-center",children:[po("h3",{
564
+ className:"grow text-lg font-medium","data-testid":"subpanel-title",children:{tutorial:"Getting started",versionInfo:"About this version"}[a]}),"versionInfo"===a&&po(Wp,{onClick:e=>u(e,"tutorial"),children:"Getting started"}),"tutorial"===a&&po(Wp,{onClick:e=>u(e,"versionInfo"),children:"About this version"})]}),po("div",{className:"border-y py-4",children:["tutorial"===a&&po(Gp,{}),"versionInfo"===a&&po(Vp,{versionData:l})]}),po("div",{className:"flex items-center",children:[po(Yp,{linkText:"Help topics",url:"https://web.hypothes.is/help/"}),po(Yp,{linkText:"New support ticket",url:c})]})]})})}),["session"]),Xp={exports:{}};function Zp(){}Zp.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function o(){r.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,t);return this},
565
+ off:function(e,t){var n=this.e||(this.e={}),r=n[e],o=[];if(r&&t)for(var i=0,a=r.length;i<a;i++)r[i].fn!==t&&r[i].fn._!==t&&o.push(r[i]);return o.length?n[e]=o:delete n[e],this}},Xp.exports=Zp;var Jp=Xp.exports.TinyEmitter=Zp;class Qp extends Error{constructor(e){super(`Results size exceeds ${e}`)}}function em(e){return 0===e?50:200}class tm extends Jp{constructor(e,{getPageSize:t=em,separateReplies:n=!0,incremental:r=!0,maxResults:o=null,sortBy:i="created",sortOrder:a="asc"}={}){super(),this._searchFn=e,this._getPageSize=t,this._separateReplies=n,this._incremental=r,this._maxResults=o,this._sortBy=i,this._sortOrder=a,this._canceled=!1,this._results=[],this._resultCount=null}async _getPage(e,t,n=0){const r=this._getPageSize(n),o={limit:r,sort:this._sortBy,order:this._sortOrder,_separate_replies:this._separateReplies,...e};t&&(o.search_after=t);try{const t=await this._searchFn(o);if(this._canceled)return;if(null===this._resultCount&&(this._resultCount=t.total,this.emit("resultCount",this._resultCount)),
566
+ this._maxResults&&t.total>this._maxResults)return this.emit("error",new Qp(this._maxResults)),void this.emit("end");const i=t.rows.concat(t.replies||[]);this._incremental?this.emit("results",i):this._results=this._results.concat(i);const a=i.length===r,s=i.length>0?i[i.length-1][this._sortBy]:null;a&&s?this._getPage(e,s,n+1):(this._incremental||this.emit("results",this._results),this.emit("end"))}catch(e){if(this._canceled)return;this.emit("error",e),this.emit("end")}}get(e){this._results=[],this._resultCount=null,this._getPage(e)}cancel(){this._canceled=!0,this.emit("end")}}function nm({defaultOption:e,icon:t,onSelect:n,options:r,selectedOption:o,title:i}){const a=[e,...r],s=null!=o?o:e,l=po("span",{className:"FilterSelect__menu-label",children:[t&&po(Mo,{name:t,classes:"text-xl hyp-u-margin--right--3"}),s.display]});return po($d,{label:l,title:i,contentClass:"FilterSelect__menu",children:a.map((e=>po(Vd,{onClick:()=>n(e),isSelected:e.value===s.value,label:e.display},e.value)))})}function rm(){
567
+ const e=ii(),t=e.getFilter("user"),n=function(){const e=ii(),t=e.allAnnotations(),n=e.defaultAuthority(),r=e.isFeatureEnabled("client_display_names"),o=e.getFocusFilters(),i=Jo(e.profile().userid);return no((()=>{const e={};if(t.forEach((t=>{const o=Jo(t.user);e[o]=Kd(t,Qo(t.user,n),r)})),o.user){const t=Jo(o.user.value)||o.user.value;e[t]=o.user.display}const a=Object.keys(e).map((t=>({display:t===i?`${e[t]} (Me)`:e[t],value:t})));return a.sort(((e,t)=>i===e.value?-1:i===t.value?1:e.display.localeCompare(t.display))),a}),[t,i,n,r,o.user])}();return po(nm,{defaultOption:{value:"",display:"Everybody"},icon:"profile",onSelect:t=>e.setFilter("user",t),options:n,selectedOption:t,title:"Filter by user"})}function om({forcedVisibleCount:e,isFiltered:t,isLoading:n,resultCount:r}){const o=Ki(),i=n?r:qi(o),a=o.children.length>0,s=t&&e>0,l=i-e,c=o.children.length;return po("div",{className:"hyp-u-layout-row NotebookResultCount",children:[n&&po(qo,{size:"small"}),!n&&po("h2",{children:[!a&&po("strong",{
568
+ children:"No results"}),a&&t&&po("strong",{children:[l," ",1===l?"result":"results"]}),a&&!t&&po("strong",{children:[c," ",1===c?"thread":"threads"]})]}),s&&po("h3",{children:["(and ",e," more)"]}),!t&&a&&po("h3",{children:["(",i," ",1===i?"annotation":"annotations",")"]})]})}function im({currentPage:e,onChangePage:t,totalPages:n}){const r=e<n,o=e>1,i=function(e,t,n=5){if(t<=1)return[];const r=new Set([1,e,t]);let o=1;for(;r.size<Math.min(t,n);)e+o<=t&&r.add(e+o),e-o>=1&&r.add(e-o),++o;const i=[];return[...r].sort(((e,t)=>e-t)).forEach(((e,t,n)=>{t>0&&e-n[t-1]>1&&i.push(null),i.push(e)})),i}(e,n),a=(e,n)=>{t(e),null==n||n.blur()};return po("div",{className:"PaginationNavigation",children:[po("div",{className:"PaginationNavigation__relative PaginationNavigation__prev",children:o&&po(bo,{classes:"PaginationPageButton",icon:"arrow-left",title:"Go to previous page",onClick:t=>a(e-1,t.target),variant:"dark",children:"prev"})}),po("ul",{className:"PaginationNavigation__pages",children:i.map(((t,n)=>po("li",{
569
+ children:null===t?po("div",{className:"PaginationNavigation__gap",children:"..."}):po(bo,{classes:"PaginationPageButton",title:`Go to page ${t}`,pressed:t===e,onClick:e=>a(t,e.target),variant:"dark",children:t.toString()},`page-${n}`)},n)))}),po("div",{className:"PaginationNavigation__relative PaginationNavigation__next",children:r&&po(bo,{classes:"PaginationPageButton",icon:"arrow-right",iconPosition:"right",title:"Go to next page",onClick:t=>a(e+1,t.target),variant:"dark",children:"next"})})]})}function am({currentPage:e,isLoading:t,onChangePage:n,threads:r,pageSize:o=25}){const{paginatedThreads:i,totalPages:a}=no((()=>{const t=r.filter((e=>qi(e)>0)),n=(e-1)*o,i=n+o,a=Math.ceil(t.length/o);return{paginatedThreads:t.slice(n,i),totalPages:a}}),[r,e,o]);return po(m,{children:[po(bp,{threads:i}),!t&&po(im,{currentPage:e,onChangePage:n,totalPages:a})]})}var sm=ri((function({loadAnnotationsService:e,streamer:t}){var n
570
+ ;const r=ii(),o=r.getFilterValues(),i=r.focusedGroup(),a=r.forcedVisibleThreads().length,s=r.hasAppliedFilter(),l=r.isLoading(),c=r.annotationResultCount(),u=r.pendingUpdateCount(),h=Ki(),d=null!==(n=null==i?void 0:i.name)&&void 0!==n?n:"…",p=(null==i?void 0:i.id)||r.directLinkedGroupId(),m=to(1),[f,g]=Zr(1),[v,y]=Zr(!1),_=e=>{e instanceof Qp&&y(!0)},b=r.hasFetchedProfile();Qr((()=>{b&&t.connect({applyUpdatesImmediately:!1})}),[b,t]),Qr((()=>{r.setSortKey("Newest"),p&&e.load({groupId:p,sortBy:"updated",sortOrder:"desc",maxResults:5e3,onError:_,streamFilterBy:"group"})}),[e,p,r]);const w=e=>{g(e)};Qr((()=>{w(1)}),[o,i]);const x=to(null);eo((()=>{f!==m.current&&(Rp(x.current),m.current=f)}),[f]);const k=`Show ${u} new or updated ${u>1?"annotations":"annotation"}`;return po("div",{className:"NotebookView",children:[po("header",{className:"NotebookView__heading",ref:x,children:po("h1",{className:"NotebookView__group-name",children:d})}),po("div",{className:"NotebookView__filters",children:po(rm,{})}),po("div",{
571
+ className:"NotebookView__results hyp-u-layout-row--align-center text-lg font-medium",children:[u>0&&!s&&po(_o,{icon:"refresh",onClick:()=>t.applyPendingUpdates(),variant:"primary",title:k}),po(om,{forcedVisibleCount:a,isFiltered:s,isLoading:l,resultCount:c})]}),po("div",{className:"NotebookView__items",children:[v&&po("div",{className:"NotebookView__messages",children:po(Ho,{title:"Too many results to show",children:["This preview of the Notebook can show"," ",po("strong",{children:["up to ",5e3," results"]})," at a time (there are"," ",c," to show here)."," ",po("a",{href:"mailto:support@hypothes.is?subject=Hypothesis%20Notebook&body=Please%20notify%20me%20when%20the%20Hypothesis%20Notebook%20is%20updated%20to%20support%20more%20than%205000%20annotations",children:"Contact us"})," ","if you would like to be notified when support for more annotations is available."]})}),po(am,{currentPage:f,isLoading:l,onChangePage:w,threads:h.children})]})]})}),["loadAnnotationsService","streamer"])
572
+ ;var lm=ri((function({toastMessenger:e}){const t=ii(),n=t.mainFrame(),r=t.focusedGroup(),o=`Share Annotations in ${r&&r.name||"..."}`,i=r&&n,a=i&&(s=n.uri,l=r.id,ma(s)?`https://hyp.is/go?url=${encodeURIComponent(s)}&group=${l}`:null);var s,l;return po(Pp,{title:o,panelName:"shareGroupAnnotations",children:[!i&&po("div",{className:"flex flex-row items-center justify-center",children:po(qo,{})}),i&&po("div",{className:"text-color-text-light space-y-3",children:a?po(m,{children:[po("div",{className:"text-color-text font-medium","data-testid":"sharing-intro",children:"private"===r.type?po("p",{children:"Use this link to share these annotations with other group members:"}):po("p",{children:"Use this link to share these annotations with anyone:"})}),po("div",{children:po(Vo,{children:[po(Go,{"aria-label":"Use this URL to share these annotations",type:"text",value:a,readOnly:!0}),po(_o,{icon:"copy",onClick:()=>{try{ba(a),e.success("Copied share link to clipboard")}catch(t){e.error("Unable to copy link")}},
573
+ title:"Copy share link",variant:"dark"})]})}),po("p",{"data-testid":"sharing-details",children:["private"===r.type?po("span",{children:["Annotations in the private group"," ",po("em",{children:r.name})," are only visible to group members."]}):po("span",{children:["Anyone using this link may view the annotations in the group"," ",po("em",{children:r.name}),"."]})," ",po("span",{children:["Private (",po(Mo,{name:"lock",classes:"inline -mt-0.5"})," ",po("em",{children:"Only Me"}),") annotations are only visible to you."]})]}),po(xa,{shareURI:a})]}):po("p",{"data-testid":"no-sharing",children:"These annotations cannot be shared because this document is not available on the web."})})]})}),["toastMessenger"]);function cm({message:e,onDismiss:t}){const n=e.type.charAt(0).toUpperCase()+e.type.slice(1),r="notice"===e.type?"cancel":e.type;return po("li",{className:Ur("toast-message-container",{"is-dismissed":e.isDismissed}),onClick:()=>t(e.id),children:po("div",{className:Ur("toast-message",`toast-message--${e.type}`),
574
+ children:[po("div",{className:"toast-message__type",children:po(Mo,{name:r,classes:"toast-message__icon"})}),po("div",{className:"toast-message__message",children:[po("strong",{children:[n,": "]}),e.message,e.moreInfoURL&&po("div",{className:"toast-message__link",children:po("a",{href:e.moreInfoURL,onClick:e=>e.stopPropagation(),target:"_new",children:"More info"})})]})]})})}var um=ri((function({toastMessenger:e}){return po("div",{children:po("ul",{"aria-live":"polite","aria-relevant":"additions",className:"ToastMessages",children:ii().getToastMessages().map((t=>po(cm,{message:t,onDismiss:t=>e.dismiss(t)},t.id)))})})}),["toastMessenger"]);function hm(e){return e.organization&&e.organization.name}function dm(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;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
575
+ ;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function pm(e){const t=dm(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 mm({heading:e,children:t}){return po(m,{children:[e&&po("h2",{className:"MenuSection__heading",children:e}),po("ul",{className:"MenuSection__content",children:x(t).map((e=>po("li",{children:e},e.key)))})]})}var fm=ri((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=ii(),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";return po(Vd,{icon:t.logo||"blank",iconAlt:hm(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,
576
+ onToggleSubmenu:h,submenu:po(m,{children:[po("ul",{children:[i&&po("li",{children:po(Vd,{href:i,icon:"external",isSubmenuItem:!0,label:"View group activity"})}),i&&po("li",{children:po(Vd,{onClick:()=>(e=>{try{ba(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&&po("li",{children:po(Vd,{icon:"leave",isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await Xo({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&po("p",{className:"GroupListItem__footer",children:"This group is restricted to specific URLs."})]})})}),["groups","toastMessenger"]);function gm({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return po(mm,{heading:r,children:n.map((n=>po(fm,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}var vm=ri((function({settings:e}){
577
+ const t=ii(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=no((()=>pm(o)),[o]),l=no((()=>pm(r)),[r]),c=no((()=>pm(n)),[n]),u=t.defaultAuthority(),h=a&&!Qo(a,u),d=t.getLink("groups.new"),[p,m]=Zr(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=hm(i)?hm(i):"";f=po("span",{className:"GroupList__menu-label",children:[t&&po("img",{className:"GroupList__menu-icon",src:t,alt:n}),i.name]})}else f=po("span",{children:"…"});return!!qp(e)&&n.length+r.length+o.length<2?f:po($d,{align:"left",contentClass:"GroupList__content",label:f,onOpenChanged:()=>m(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[c.length>0&&po(gm,{expandedGroup:p,onExpandGroup:m,heading:"Currently Viewing",groups:c}),l.length>0&&po(gm,{expandedGroup:p,onExpandGroup:m,heading:"Featured Groups",groups:l}),s.length>0&&po(gm,{expandedGroup:p,onExpandGroup:m,heading:"My Groups",groups:s
578
+ }),h&&po(Vd,{icon:"add",href:d,label:"New private group"})]})}),["settings"]);function ym({alwaysExpanded:e,query:t,onSearch:n}){const r=ii().isLoading(),o=to(),[i,a]=Zr(t),[s,l]=Zr(t);return t!==i&&(l(t),a(t)),po("form",{action:"#",className:"SearchInput__form",name:"searchForm",onSubmit:e=>{e.preventDefault(),(o.current.value||i)&&n(o.current.value)},children:[po("input",{"aria-label":"Search",className:Ur("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&&po("div",{className:"SearchInput__button-container",children:po(_o,{icon:"search",onClick:()=>o.current.focus(),size:"small",title:"Search annotations"})}),r&&po("div",{style:"margin:0.5em 0",children:po(qo,{size:"small"})})]})}function _m(){const e=ii(),t=e.sortKey(),n=e.sortKeys().map((n=>po(Vd,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=po("span",{className:"TopBar__menu-label",children:po(Mo,{name:"sort",
579
+ classes:"TopBar__menu-icon"})});return po("div",{className:"SortMenu",children:po($d,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var bm=ri((function({router:e}){return po(ym,{query:ii().routeParams().q,onSearch:t=>{e.navigate("stream",{q:t})},alwaysExpanded:!0})}),["router"]);var wm=ri((function({auth:e,frameSync:t,onLogout:n,settings:r}){const o=ii(),i=o.defaultAuthority(),a=Qo(e.userid,i),s=P(r),l=o.isFeatureEnabled("notebook_launch"),[c,u]=Zr(!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=po("span",{className:"TopBar__menu-label",children:po(Mo,{name:"profile",classes:"TopBar__menu-icon"})});return po("div",{className:"UserMenu",onKeyDown:e=>{"n"===e.key&&(m(),u(!1))},children:po($d,{label:v,title:e.displayName,align:"right",open:c,
580
+ onOpenChanged:u,children:[po(mm,{children:[po(Vd,{label:e.displayName,isDisabled:!d,...g}),!a&&po(Vd,{label:"Account settings",href:o.getLink("account.settings")}),l&&po(Vd,{label:"Open notebook",onClick:()=>m()})]}),p&&po(mm,{children:po(Vd,{label:"Log out",onClick:n})})]})})}),["frameSync","settings"]);var xm=ri((function({auth:e,frameSync:t,isSidebar:n,onLogin:r,onLogout:o,onSignUp:i,settings:a,streamer:s}){const l=!qp(a),c=ti(["accentColor"],a),u=ii(),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=po(m,{children:["unknown"===e.status&&po("span",{className:"TopBar__login-links",children:"⋯"}),"logged-out"===e.status&&po("span",{className:"TopBar__login-links text-lg font-medium hyp-u-horizontal-spacing--2",children:[po(wo,{classes:"InlineLinkButton",onClick:i,style:c,variant:"primary",children:"Sign up"}),po("div",{
581
+ children:"/"}),po(wo,{classes:"InlineLinkButton",onClick:r,style:c,variant:"primary",children:"Log in"})]}),"logged-in"===e.status&&po(wm,{auth:e,onLogout:o})]});return po("div",{className:"TopBar",children:[!n&&po("div",{className:"TopBar__inner content",children:[po(bm,{}),po("div",{className:"hyp-u-stretch"}),po(_o,{icon:"help",expanded:p,onClick:g,size:"small",title:"Help"}),v]}),n&&po("div",{className:"TopBar__inner content",children:[po(vm,{}),po("div",{className:"hyp-u-stretch"}),d>0&&po(_o,{icon:"refresh",onClick:()=>s.applyPendingUpdates(),size:"small",variant:"primary",title:`Show ${d} new/updated ${1===d?"annotation":"annotations"}`}),po(ym,{query:h||null,onSearch:u.setFilterQuery}),po(_m,{}),l&&po(_o,{icon:"share",expanded:f,onClick:()=>{u.toggleSidebarPanel("shareGroupAnnotations")},size:"small",title:"Share annotations on this page"}),po(_o,{icon:"help",expanded:p,onClick:g,size:"small",title:"Help"}),v]})]})}),["frameSync","settings","streamer"])
582
+ ;var km=ri((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=ii(),a=i.hasFetchedProfile(),s=i.profile(),l=i.route(),c=no((()=>a?function(e){const t=Zo(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=no((()=>ti(["appBackgroundColor"],n)),[n]),h="clean"===n.theme,d="sidebar"===l;Qr((()=>{(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{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 po("div",{
583
+ className:Ur("HypothesisApp","js-thread-list-scroll-root",{"theme-clean":h,"HypothesisApp--notebook":"notebook"===l}),style:u,children:["notebook"!==l&&po(xm,{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?"),Xo({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),P(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),po("div",{className:"HypothesisApp__content",children:[po(um,{}),po(Kp,{auth:"logged-in"===c.status?c:{}}),po(lm,{}),l&&po("main",{children:["annotation"===l&&po(xp,{onLogin:p}),"notebook"===l&&po(sm,{}),"stream"===l&&po(Hp,{}),"sidebar"===l&&po(jp,{onLogin:p,onSignUp:m})]})]})]})}),["auth","frameSync","session","settings","toastMessenger"])
584
+ ;function Sm({error:e}){return po("div",{className:"LaunchErrorPanel",children:po(Ho,{title:"Unable to start Hypothesis",children:e.message})})}class Cm{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?fa(e.user):ga(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:va(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return Ni(l)&&(l.permissions=fa(i)),l}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Ni(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!Ci(n)}),
585
585
  Mi(n)?this._store.selectTab("note"):zi(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:Ci(e)?ga(t,e.group):fa(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;t=Si(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])})),
586
- this._store.removeDraft(e),this._store.addAnnotations([r]),r}}Sm.$inject=["api","store"];class Cm 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 Am(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Cm(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new Cm(e,n,"Failed to parse response")}var o;if(!n.ok)throw new Cm(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function Em(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 Tm(e){const t={};for(const n in e)e.hasOwnProperty(n)&&"$"!==n[0]&&(t[n]=e[n]);return t}class Nm{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}){
587
- 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.970.0"};l&&(u.Authorization="Bearer "+l);const h=r();h&&(u["X-Client-Id"]=h);const{url:d,unusedParams:p}=Em(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 Am(m.toString(),{body:s?JSON.stringify(Tm(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={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={
588
- 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}}Nm.$inject=["apiRoutes","auth","store"];var Lm={};function Mm(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 zm=Mm;Mm.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},Mm.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},Mm.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime()
589
- ;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},Mm.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},Mm.prototype.try=function(e){
590
- console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},Mm.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},Mm.prototype.start=Mm.prototype.try,Mm.prototype.errors=function(){return this._errors},Mm.prototype.attempts=function(){return this._attempts},Mm.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=zm;e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t))
591
- ;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}}}(Lm);var Om=Lm;function Im(e,t){return new Promise(((n,r)=>{const o=Om.operation(t);o.attempt((async()=>{try{const t=await e();o.retry(),n(t)}catch(e){o.retry(e)||r(e)}}))}))}function Rm(e){return Im((()=>Am(e)))}class Pm{constructor(e){this._apiUrl=e.apiUrl,this._routeCache=null,this._linkCache=null}routes(){
592
- return this._routeCache||(this._routeCache=Rm(this._apiUrl).then((e=>e.links))),this._routeCache}links(){return this._linkCache||(this._linkCache=this.routes().then((e=>Rm(e.links.url)))),this._linkCache}}Pm.$inject=["settings"];class Dm extends Error{constructor(e,t){super(e),this.cause=t}}class Bm{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{await this._formPost(this.revokeEndpoint,{token:e})}catch(e){throw new Dm("Failed to revoke access token",e)}}authorize(e,t){const n=q(16),r=new Promise(((t,r)=>{e.addEventListener("message",(function o(i){
593
- "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 Am(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)}catch(e){throw new Dm("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){
594
- 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 Fm extends Zp{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 Bm({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;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)
595
- ;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(){const t=Bm.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}}
596
- Fm.$inject=["$window","apiRoutes","localStorage","settings","toastMessenger"];class jm{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),Im((()=>this._annotationsService.save(t))).catch((()=>{this._failed.add(n)})).finally((()=>{this._saving.delete(n)})))}))}))}isSaving(){return this._saving.size>0}}jm.$inject=["annotationsService","store"];var Hm=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);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 Um(e,t,n){
597
- const r=Array.isArray(t),o=()=>r?t.map((e=>e())):t();let i=o();return e((()=>{const e=o();if(r?Hm(e,i):e===i)return;const t=i;i=e,n(e,t)}))}class qm{constructor(e,t){this._frameSync=e,this._store=t}init(){const e=()=>this._store.profile().features;Um(this._store.subscribe,[e,()=>this._store.frames()],(()=>{this._frameSync.notifyHost("featureFlagsUpdated",e()||{})}))}}function $m(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}(e)&&JSON.stringify(e,Object.keys(t).sort())===JSON.stringify(t,Object.keys(t).sort())}qm.$inject=["frameSync","store"];class Gm{constructor({hostFrame:e,source:t}){this._hostFrame=e,this._source=t,this._listeners=new ha}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),
598
- !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;$m(r,{frame1:this._source,frame2:e,type:"offer"})&&(clearInterval(o),clearTimeout(i),this._listeners.remove(a),t(s[0]))}));r()}))}}class Vm{constructor(){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new ha,this._pendingCalls=[]}on(e,t){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(e,t)}connect(e){this._port=e,this._listeners.add(e,"message",(e=>this._handle(e))),e.start();for(let[e,t]of this._pendingCalls)this.call(e,...t);this._pendingCalls=[]}destroy(){var e;this._destroyed=!0,this._listeners.removeAll(),
599
- null===(e=this._port)||void 0===e||e.close()}call(e,...t){if(this._port||this._pendingCalls.push([e,t]),!this._port||this._destroyed)return;const n=this._sequence++,r=t[t.length-1];"function"==typeof r&&(this._callbacks.set(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),n=this._port;if(t&&n)if("method"in t){const e=this._methods.get(t.method);if(!e)return;const r=(...e)=>{const r={arguments:e,protocol:"frame-rpc",response:t.sequence,version:"1.0.0"};n.postMessage(r)};e(...t.arguments,r)}else if("response"in t){const e=this._callbacks.get(t.response);this._callbacks.delete(t.response),e&&e(...t.arguments)}}}function Wm({$tag:e,target:t,uri:n}){return{$tag:e,target:t,uri:n}}class Ym{constructor(e,t,n){this._window=e,this._annotationsService=t,
600
- this._store=n,this._portFinder=new Gm({hostFrame:this._window.parent,source:"sidebar"}),this._listeners=new ha,this._hostRPC=new Vm,this._guestRPC=[],this._inFrame=new Set,this._highlightsVisible=!1,this._setupSyncToGuests(),this._setupHostEvents()}_setupSyncToGuests(){let e=0;Um(this._store.subscribe,[()=>this._store.allAnnotations(),()=>this._store.frames()],(([t,n],[r])=>{let o=0;const i=new Set,a=[];t.forEach((e=>{ki(e)||(Ci(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.forEach((e=>e.call("loadAnnotations",a.map(Wm)))),a.forEach((e=>{this._inFrame.add(e.$tag)}))),s.forEach((e=>{this._guestRPC.forEach((t=>t.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))}))}_connectGuest(e){const t=new Vm;t.on("documentInfoChanged",(e=>{this._store.connectFrame({id:e.frameIdentifier,
586
+ this._store.removeDraft(e),this._store.addAnnotations([r]),r}}Cm.$inject=["api","store"];class Am 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 Em(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Am(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new Am(e,n,"Failed to parse response")}var o;if(!n.ok)throw new Am(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function Tm(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 Nm(e){const t={};for(const n in e)e.hasOwnProperty(n)&&"$"!==n[0]&&(t[n]=e[n]);return t}class Lm{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}){
587
+ 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.974.0"};l&&(u.Authorization="Bearer "+l);const h=r();h&&(u["X-Client-Id"]=h);const{url:d,unusedParams:p}=Tm(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 Em(m.toString(),{body:s?JSON.stringify(Nm(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={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={
588
+ 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}}Lm.$inject=["apiRoutes","auth","store"];var Mm={};function zm(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 Om=zm;zm.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},zm.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},zm.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime()
589
+ ;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},zm.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},zm.prototype.try=function(e){
590
+ console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},zm.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},zm.prototype.start=zm.prototype.try,zm.prototype.errors=function(){return this._errors},zm.prototype.attempts=function(){return this._attempts},zm.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=Om;e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t))
591
+ ;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}}}(Mm);var Im=Mm;function Rm(e,t){return new Promise(((n,r)=>{const o=Im.operation(t);o.attempt((async()=>{try{const t=await e();o.retry(),n(t)}catch(e){o.retry(e)||r(e)}}))}))}function Pm(e){return Rm((()=>Em(e)))}class Dm{constructor(e){this._apiUrl=e.apiUrl,this._routeCache=null,this._linkCache=null}routes(){
592
+ return this._routeCache||(this._routeCache=Pm(this._apiUrl).then((e=>e.links))),this._routeCache}links(){return this._linkCache||(this._linkCache=this.routes().then((e=>Pm(e.links.url)))),this._linkCache}}Dm.$inject=["settings"];class Bm extends Error{constructor(e,t){super(e),this.cause=t}}class Fm{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{await this._formPost(this.revokeEndpoint,{token:e})}catch(e){throw new Bm("Failed to revoke access token",e)}}authorize(e,t){const n=q(16),r=new Promise(((t,r)=>{e.addEventListener("message",(function o(i){
593
+ "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 Em(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)}catch(e){throw new Bm("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){
594
+ 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 jm extends Jp{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 Fm({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;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)
595
+ ;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(){const t=Fm.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}}
596
+ jm.$inject=["$window","apiRoutes","localStorage","settings","toastMessenger"];class Hm{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}}Hm.$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);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 qm(e,t,n){
597
+ 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 $m{constructor(e,t){this._frameSync=e,this._store=t}init(){const e=()=>this._store.profile().features;qm(this._store.subscribe,[e,()=>this._store.frames()],(()=>{this._frameSync.notifyHost("featureFlagsUpdated",e()||{})}))}}function Gm(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}(e)&&JSON.stringify(e,Object.keys(t).sort())===JSON.stringify(t,Object.keys(t).sort())}$m.$inject=["frameSync","store"];class Vm{constructor({hostFrame:e,source:t}){this._hostFrame=e,this._source=t,this._listeners=new ha}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),
598
+ !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;Gm(r,{frame1:this._source,frame2:e,type:"offer"})&&(clearInterval(o),clearTimeout(i),this._listeners.remove(a),t(s[0]))}));r()}))}}class Wm{constructor(){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new ha,this._pendingCalls=[]}on(e,t){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(e,t)}connect(e){this._port=e,this._listeners.add(e,"message",(e=>this._handle(e))),e.start();for(let[e,t]of this._pendingCalls)this.call(e,...t);this._pendingCalls=[]}destroy(){var e;this._destroyed=!0,this._listeners.removeAll(),
599
+ null===(e=this._port)||void 0===e||e.close()}call(e,...t){if(this._port||this._pendingCalls.push([e,t]),!this._port||this._destroyed)return;const n=this._sequence++,r=t[t.length-1];"function"==typeof r&&(this._callbacks.set(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),n=this._port;if(t&&n)if("method"in t){const e=this._methods.get(t.method);if(!e)return;const r=(...e)=>{const r={arguments:e,protocol:"frame-rpc",response:t.sequence,version:"1.0.0"};n.postMessage(r)};e(...t.arguments,r)}else if("response"in t){const e=this._callbacks.get(t.response);this._callbacks.delete(t.response),e&&e(...t.arguments)}}}function Ym({$tag:e,target:t,uri:n}){return{$tag:e,target:t,uri:n}}class Km{constructor(e,t,n){this._window=e,this._annotationsService=t,
600
+ this._store=n,this._portFinder=new Vm({hostFrame:this._window.parent,source:"sidebar"}),this._listeners=new ha,this._hostRPC=new Wm,this._guestRPC=[],this._inFrame=new Set,this._highlightsVisible=!1,this._setupSyncToGuests(),this._setupHostEvents()}_setupSyncToGuests(){let e=0;qm(this._store.subscribe,[()=>this._store.allAnnotations(),()=>this._store.frames()],(([t,n],[r])=>{let o=0;const i=new Set,a=[];t.forEach((e=>{ki(e)||(Ci(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.forEach((e=>e.call("loadAnnotations",a.map(Ym)))),a.forEach((e=>{this._inFrame.add(e.$tag)}))),s.forEach((e=>{this._guestRPC.forEach((t=>t.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))}))}_connectGuest(e){const t=new Wm;t.on("documentInfoChanged",(e=>{this._store.connectFrame({id:e.frameIdentifier,
601
601
  metadata:e.metadata,uri:e.uri})})),t.on("createAnnotation",(e=>{if(!this._store.isLoggedIn())return this._hostRPC.call("openSidebar"),this._store.openSidebarPanel("loginPrompt"),void this._guestRPC.forEach((t=>t.call("deleteAnnotation",e.$tag)));this._inFrame.add(e.$tag),e.$highlight||this._hostRPC.call("openSidebar"),this._hostRPC.call("showHighlights"),this._annotationsService.create(e)}));let n={};const r=ua((()=>{this._store.updateAnchorStatus(n),n={}}),10);t.on("syncAnchoringStatus",(({$tag:e,$orphan:t})=>{this._inFrame.add(e),n[e]=t?"orphan":"anchored",r()})),t.on("showAnnotations",(e=>{this._store.selectAnnotations(this._store.findIDsForTags(e)),this._store.selectTab("annotation")})),t.on("focusAnnotations",(e=>{this._store.focusAnnotations(e||[])})),t.on("toggleAnnotationSelection",(e=>{this._store.toggleSelectedAnnotations(this._store.findIDsForTags(e))})),t.on("openSidebar",(()=>{this._hostRPC.call("openSidebar")})),t.on("closeSidebar",(()=>{this._hostRPC.call("closeSidebar")})),
602
- this._guestRPC.push(t),t.connect(e),t.call("setHighlightsVisible",this._highlightsVisible)}_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.forEach((t=>t.call("setHighlightsVisible",e)))}))}async connect(){const e=await this._portFinder.discover("host");this._hostRPC.connect(e),this._hostRPC.call("ready"),this._listeners.add(e,"message",(e=>{const{data:t,ports:n}=e;$m(t,{frame1:"guest",frame2:"sidebar",type:"offer"})&&this._connectGuest(n[0])}))}notifyHost(e,...t){this._hostRPC.call(e,...t)}focusAnnotations(e){this._store.focusAnnotations(e),this._guestRPC.forEach((t=>t.call("focusAnnotations",e)))}scrollToAnnotation(e){this._guestRPC.forEach((t=>t.call("scrollToAnnotation",e)))}destroy(){this._portFinder.destroy(),this._listeners.removeAll()}}function Km(e){
603
- return Object.keys(e).reduce(((e,t)=>(e[t]=t,e)),{})}Ym.$inject=["$window","annotationsService","store"];const Xm={id:"__default__",name:"__DEFAULT__",logo:"data:image/svg+xml;utf8,"+encodeURIComponent(Yo)};const Zm=["organization","scopes"];class Jm{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(){this._reloadSetUp||(this._reloadSetUp=!0,Um(this._store.subscribe,(()=>this._mainURI()),(()=>{this.load()})),
604
- Um(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=Xm)}))}(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:Zm})}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;r&&(o=this._api.annotation.get({id:r}).catch((()=>null)));const i=this._store.directLinkedGroupId();let a=null
605
- ;i&&(a=this._fetchGroup(i).then((e=>(this._store.clearDirectLinkedGroupFetchFailed(),e))).catch((()=>(this._store.setDirectLinkedGroupFetchFailed(),null))));const s={expand:Zm},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:Zm}),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:Zm});let n;const r=async e=>{try{return await this._fetchGroup(e)}catch(e){return n=e,null}
606
- },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=>!ki(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"})}}Jm.$inject=["store","api","auth","session","settings","toastMessenger"];class Qm{
607
- 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 em(this._api.search,s),this._searchClient.on("resultCount",(e=>{this._store.setAnnotationResultCount(e)})),this._searchClient.on("results",(e=>{e.length&&this._store.addAnnotations(e)})),this._searchClient.on("error",(e=>{"function"==typeof n?n(e):console.error(e)})),
608
- 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}),ki(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),!ki(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}}Qm.$inject=["api","store","streamer","streamFilter"];class ef{constructor(){this._store={}}getItem(e){return e in this._store?this._store[e]:null}
609
- setItem(e,t){this._store[e]=t}removeItem(e){delete this._store[e]}}class tf{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 ef}}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)}}tf.$inject=["$window"];const nf={annotationPrivacy:"hypothesis.privacy",focusedGroup:"hypothesis.groups.focus"};class rf{constructor(e,t){this._storage=e,this._store=t}init(){Object.keys(nf).forEach((e=>{const t=this._storage.getItem(nf[e]);this._store.setDefault(e,t)})),Um(this._store.subscribe,(()=>this._store.getDefaults()),((e,t)=>{for(let n in e)t[n]!==e[n]&&n in nf&&this._storage.setItem(nf[n],e[n])}))}}rf.$inject=["localStorage","store"];class of{constructor(e,t){this._window=e,
602
+ this._guestRPC.push(t),t.connect(e),t.call("setHighlightsVisible",this._highlightsVisible)}_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.forEach((t=>t.call("setHighlightsVisible",e)))}))}async connect(){const e=await this._portFinder.discover("host");this._hostRPC.connect(e),this._hostRPC.call("ready"),this._listeners.add(e,"message",(e=>{const{data:t,ports:n}=e;Gm(t,{frame1:"guest",frame2:"sidebar",type:"offer"})&&this._connectGuest(n[0])}))}notifyHost(e,...t){this._hostRPC.call(e,...t)}focusAnnotations(e){this._store.focusAnnotations(e),this._guestRPC.forEach((t=>t.call("focusAnnotations",e)))}scrollToAnnotation(e){this._guestRPC.forEach((t=>t.call("scrollToAnnotation",e)))}destroy(){this._portFinder.destroy(),this._listeners.removeAll()}}function Xm(e){
603
+ return Object.keys(e).reduce(((e,t)=>(e[t]=t,e)),{})}Km.$inject=["$window","annotationsService","store"];const Zm={id:"__default__",name:"__DEFAULT__",logo:"data:image/svg+xml;utf8,"+encodeURIComponent(Yo)};const Jm=["organization","scopes"];class Qm{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(){this._reloadSetUp||(this._reloadSetUp=!0,qm(this._store.subscribe,(()=>this._mainURI()),(()=>{this.load()})),
604
+ qm(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=Zm)}))}(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:Jm})}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;r&&(o=this._api.annotation.get({id:r}).catch((()=>null)));const i=this._store.directLinkedGroupId();let a=null
605
+ ;i&&(a=this._fetchGroup(i).then((e=>(this._store.clearDirectLinkedGroupFetchFailed(),e))).catch((()=>(this._store.setDirectLinkedGroupFetchFailed(),null))));const s={expand:Jm},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:Jm}),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:Jm});let n;const r=async e=>{try{return await this._fetchGroup(e)}catch(e){return n=e,null}
606
+ },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=>!ki(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"})}}Qm.$inject=["store","api","auth","session","settings","toastMessenger"];class ef{
607
+ 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 tm(this._api.search,s),this._searchClient.on("resultCount",(e=>{this._store.setAnnotationResultCount(e)})),this._searchClient.on("results",(e=>{e.length&&this._store.addAnnotations(e)})),this._searchClient.on("error",(e=>{"function"==typeof n?n(e):console.error(e)})),
608
+ 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}),ki(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),!ki(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}}ef.$inject=["api","store","streamer","streamFilter"];class tf{constructor(){this._store={}}getItem(e){return e in this._store?this._store[e]:null}
609
+ setItem(e,t){this._store[e]=t}removeItem(e){delete this._store[e]}}class nf{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 tf}}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)}}nf.$inject=["$window"];const rf={annotationPrivacy:"hypothesis.privacy",focusedGroup:"hypothesis.groups.focus"};class of{constructor(e,t){this._storage=e,this._store=t}init(){Object.keys(rf).forEach((e=>{const t=this._storage.getItem(rf[e]);this._store.setDefault(e,t)})),qm(this._store.subscribe,(()=>this._store.getDefaults()),((e,t)=>{for(let n in e)t[n]!==e[n]&&n in rf&&this._storage.setItem(rf[n],e[n])}))}}of.$inject=["localStorage","store"];class af{constructor(e,t){this._window=e,
610
610
  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),this._didRegisterPopstateListener||(this._window.addEventListener("popstate",(()=>{this.sync()})),this._didRegisterPopstateListener=!0)}navigate(e,t){
611
- this._window.history.pushState({},"",this.routeUrl(e,t)),this.sync()}}of.$inject=["$window","store"];class af{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}`)}}}af.$inject=["apiRoutes","store"];class sf{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=Im((()=>{const e=this._authority?{authority:this._authority}:{};return this._api.profile.read(e)})).then((e=>(this.update(e),this._lastLoadTime=Date.now(),e))).catch((e=>{throw this._lastLoadTime=null,e}))),this._lastLoad}async dismissSidebarTutorial(){
612
- 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?Cr({id:e.userid}):Cr(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()}}sf.$inject=["store","api","auth","settings","toastMessenger"];class lf{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(){return this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,delete:!0}},this}}class cf extends Zp{constructor(e){super();const t=[];let n
613
- ;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 uf{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(){const e=Object.values(this._store.pendingUpdates());e.length&&this._store.addAnnotations(e);const t=Object.keys(this._store.pendingDeletions()).map((e=>({id:e})))
614
- ;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){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)}
615
- _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 cf(n);r.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(r)})),r.on("disconnect",(()=>{if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),r.on("error",(e=>this._handleSocketError(e))),
616
- 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,Um(this._store.subscribe,(()=>this._store.profile().userid),(()=>{this._reconnect()}))),this._socket||await this._reconnect()}}uf.$inject=["store","auth","groups","session","settings"];class hf{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){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()}})),
617
- 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)}}hf.$inject=["localStorage"];class df{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}df.$inject=["store"];class pf{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}),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)}}
618
- function mf(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ff(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 gf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ff(Object(n),!0).forEach((function(t){mf(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ff(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function vf(e){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. "}pf.$inject=["store"];var yf="function"==typeof Symbol&&Symbol.observable||"@@observable",_f=function(){
619
- return Math.random().toString(36).substring(7).split("").join(".")},bf={INIT:"@@redux/INIT"+_f(),REPLACE:"@@redux/REPLACE"+_f(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+_f()}};function wf(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 xf(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(vf(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(vf(1));return n(xf)(e,t)}if("function"!=typeof e)throw new Error(vf(2));var o=e,i=t,a=[],s=a,l=!1;function c(){s===a&&(s=a.slice())}function u(){if(l)throw new Error(vf(3));return i}function h(e){if("function"!=typeof e)throw new Error(vf(4));if(l)throw new Error(vf(5));var t=!0;return c(),s.push(e),function(){if(t){if(l)throw new Error(vf(6));t=!1,c();var n=s.indexOf(e);s.splice(n,1),a=null}}}
620
- function d(e){if(!wf(e))throw new Error(vf(7));if(void 0===e.type)throw new Error(vf(8));if(l)throw new Error(vf(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(vf(10));o=e,d({type:bf.REPLACE})}function m(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(vf(11));function n(){e.next&&e.next(u())}return n(),{unsubscribe:t(n)}}})[yf]=function(){return this},e}return d({type:bf.INIT}),(r={dispatch:d,subscribe:h,getState:u,replaceReducer:p})[yf]=m,r}function kf(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){Object.keys(e).forEach((function(t){var n=e[t];if(void 0===n(void 0,{type:bf.INIT}))throw new Error(vf(12));if(void 0===n(void 0,{type:bf.PROBE_UNKNOWN_ACTION()}))throw new Error(vf(13))}))}(n)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i
621
- ;for(var r=!1,o={},s=0;s<a.length;s++){var l=a[s],c=n[l],u=e[l],h=c(u,t);if(void 0===h)throw t&&t.type,new Error(vf(14));o[l]=h,r=r||h!==u}return(r=r||a.length!==Object.keys(e).length)?o:e}}function Sf(e,t){return function(){return t(e.apply(this,arguments))}}function Cf(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function Af(e){return function(t){var n=t.dispatch,r=t.getState;return function(t){return function(o){return"function"==typeof o?o(n,r,e):t(o)}}}}var Ef=Af();Ef.withExtraArgument=Af;var Tf=Ef;function Nf(e,t=[],n=[]){const r={},o={},i={};e.forEach((e=>{e.namespace?(r[e.namespace]=e.initialState(...t),o[e.namespace]=function(e){return(t={},n)=>{const r=e[n.type];if(!r)return t;const o=r(t,n);return Array.isArray(o)?o:{...t,...o}}}(e.reducers),i[e.namespace]={selectors:e.selectors,rootSelectors:e.rootSelectors||{}
622
- }):console.warn("Store module does not specify a namespace",e)}));const a=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw new Error(vf(15))},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return r=Cf.apply(void 0,i)(n.dispatch),gf(gf({},n),{},{dispatch:r})}}}(...[Tf],...n);const s=xf(kf(o),r,a),l=Object.assign({},...e.map((e=>e.actionCreators))),c=function(e,t){if("function"==typeof e)return Sf(e,t);if("object"!=typeof e||null===e)throw new Error(vf(16));var n={};for(var r in e){var o=e[r];"function"==typeof o&&(n[r]=Sf(o,t))}return n}(l,s.dispatch),u=function(e,t){const n={};return Object.keys(e).forEach((r=>{const{selectors:o,rootSelectors:i={}}=e[r];Object.keys(o).forEach((e=>{if(n[e])throw new Error(`Duplicate selector "${e}"`);n[e]=(...n)=>o[e](t()[r],...n)})),Object.keys(i).forEach((e=>{
623
- if(n[e])throw new Error(`Duplicate selector "${e}"`);n[e]=(...n)=>i[e](t(),...n)}))})),n}(i,s.getState);return Object.assign(s,c,u),s}function Lf(e,t){if(!(e instanceof Function)){const t=e;e=()=>t}return{initialState:e,...t}}function Mf(e){let t=0;return function(n){return function(r){if(!window.debug)return void n(r);++t;const o=r.type+" ("+t.toString()+")";console.group(o),console.log("Prev State:",e.getState()),console.log("Action:",r),n(r),console.log("Next State:",e.getState()),console.groupEnd()}}}const zf={API_REQUEST_STARTED:e=>({...e,activeApiRequests:e.activeApiRequests+1}),API_REQUEST_FINISHED(e){if(0===e.activeApiRequests)throw new Error("API_REQUEST_FINISHED action when no requests were active");return{...e,activeApiRequests:e.activeApiRequests-1}},ANNOTATION_SAVE_STARTED(e,t){let n=[];t.annotation.$tag&&!e.activeAnnotationSaveRequests.includes(t.annotation.$tag)&&n.push(t.annotation.$tag);const r=e.activeAnnotationSaveRequests.concat(n);return{...e,activeAnnotationSaveRequests:r}},
624
- ANNOTATION_SAVE_FINISHED(e,t){const n=e.activeAnnotationSaveRequests.filter((e=>e!==t.annotation.$tag));return{...e,activeAnnotationSaveRequests:n}},ANNOTATION_FETCH_STARTED:e=>({...e,activeAnnotationFetches:e.activeAnnotationFetches+1}),ANNOTATION_FETCH_FINISHED(e){if(0===e.activeAnnotationFetches)throw new Error("ANNOTATION_FETCH_FINISHED action when no annotation fetches were active");return{...e,hasFetchedAnnotations:!0,activeAnnotationFetches:e.activeAnnotationFetches-1}},SET_ANNOTATION_RESULT_COUNT:(e,t)=>({annotationResultCount:t.resultCount})},Of=Km(zf);var If=Lf({activeAnnotationSaveRequests:[],activeApiRequests:0,activeAnnotationFetches:0,hasFetchedAnnotations:!1,annotationResultCount:null},{reducers:zf,namespace:"activity",actionCreators:{annotationFetchStarted:function(){return{type:Of.ANNOTATION_FETCH_STARTED}},annotationFetchFinished:function(){return{type:Of.ANNOTATION_FETCH_FINISHED}},annotationSaveStarted:function(e){return{type:Of.ANNOTATION_SAVE_STARTED,annotation:e}},
625
- annotationSaveFinished:function(e){return{type:Of.ANNOTATION_SAVE_FINISHED,annotation:e}},apiRequestStarted:function(){return{type:Of.API_REQUEST_STARTED}},apiRequestFinished:function(){return{type:Of.API_REQUEST_FINISHED}},setAnnotationResultCount:function(e){return{type:Of.SET_ANNOTATION_RESULT_COUNT,resultCount:e}}},selectors:{hasFetchedAnnotations:function(e){return e.hasFetchedAnnotations},isLoading:function(e){return e.activeApiRequests>0||!e.hasFetchedAnnotations},isFetchingAnnotations:function(e){return e.activeAnnotationFetches>0},isSavingAnnotation:function(e,t){return!!t.$tag&&e.activeAnnotationSaveRequests.includes(t.$tag)},annotationResultCount:function(e){return e.annotationResultCount}}});var Rf=function(e,t){return e===t};function Pf(e,t){var n,r,o="object"==typeof t?t:{equalityCheck:t},i=o.equalityCheck,a=void 0===i?Rf:i,s=o.maxSize,l=void 0===s?1:s,c=o.resultEqualityCheck,u=function(e){return function(t,n){if(null===t||null===n||t.length!==n.length)return!1
626
- ;for(var r=t.length,o=0;o<r;o++)if(!e(t[o],n[o]))return!1;return!0}}(a),h=1===l?(n=u,{get:function(e){return r&&n(r.key,e)?r.value:"NOT_FOUND"},put:function(e,t){r={key:e,value:t}},getEntries:function(){return r?[r]:[]},clear:function(){r=void 0}}):function(e,t){var n=[];function r(e){var r=n.findIndex((function(n){return t(e,n.key)}));if(r>-1){var o=n[r];return r>0&&(n.splice(r,1),n.unshift(o)),o.value}return"NOT_FOUND"}return{get:r,put:function(t,o){"NOT_FOUND"===r(t)&&(n.unshift({key:t,value:o}),n.length>e&&n.pop())},getEntries:function(){return n},clear:function(){n=[]}}}(l,u);function d(){var t=h.get(arguments);if("NOT_FOUND"===t){if(t=e.apply(null,arguments),c){var n=h.getEntries(),r=n.find((function(e){return c(e.value,t)}));r&&(t=r.value)}h.put(arguments,t)}return t}return d.clearCache=function(){return h.clear()},d}function Df(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var n=t.map((function(e){
627
- return"function"==typeof e?"function "+(e.name||"unnamed")+"()":typeof e})).join(", ");throw new Error("createSelector expects all input-selectors to be functions, but received the following types: ["+n+"]")}return t}function Bf(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];var i,a=0,s={memoizeOptions:void 0},l=r.pop();if("object"==typeof l&&(s=l,l=r.pop()),"function"!=typeof l)throw new Error("createSelector expects an output function after the inputs, but received: ["+typeof l+"]");var c=s,u=c.memoizeOptions,h=void 0===u?n:u,d=Array.isArray(h)?h:[h],p=Df(r),m=e.apply(void 0,[function(){return a++,l.apply(null,arguments)}].concat(d)),f=e((function(){for(var e=[],t=p.length,n=0;n<t;n++)e.push(p[n].apply(null,arguments));return i=m.apply(null,e)}));return Object.assign(f,{resultFunc:l,memoizedResultFunc:m,dependencies:p,lastResult:function(){return i},recomputations:function(){
628
- return a},resetRecomputations:function(){return a=0}}),f};return o}var Ff=Bf(Pf);function jf(e,t){return e.reduce(((e,n)=>t(n)?e+1:e),0)}function Hf(e){const t={};return e.forEach((e=>t[e]=!0)),t}function Uf(e){return Object.keys(e).filter((t=>!0===e[t]))}const qf={CHANGE_ROUTE:(e,{name:t,params:n})=>({name:t,params:n})},$f=Km(qf);var Gf=Lf({name:null,params:{}},{namespace:"route",reducers:qf,actionCreators:{changeRoute:function(e,t={}){return{type:$f.CHANGE_ROUTE,name:e,params:t}}},selectors:{route:function(e){return e.name},routeParams:function(e){return e.params}}});function Vf(e,t){return e.find((e=>e.id===t))}function Wf(e,t){return e.find((e=>e.$tag===t))}const Yf={ADD_ANNOTATIONS:function(e,t){const n={},r={},o=[],i=[],a=[];let s=e.nextTag;return t.annotations.forEach((t=>{let i;t.id&&(i=Vf(e.annotations,t.id)),!i&&t.$tag&&(i=Wf(e.annotations,t.$tag)),i?(a.push(Object.assign({},i,t)),t.id&&(n[t.id]=!0),i.$tag&&(r[i.$tag]=!0)):(o.push(function(e,t){let n=e.$orphan;return e.id||(n=!1),
629
- Object.assign({},e,{$anchorTimeout:!1,$tag:e.$tag||t,$orphan:n})}(t,"t"+s)),++s)})),e.annotations.forEach((e=>{n[e.id]||r[e.$tag]||i.push(e)})),{annotations:o.concat(a).concat(i),nextTag:s}},CLEAR_ANNOTATIONS:function(){return{annotations:[],focused:{},highlighted:{}}},FOCUS_ANNOTATIONS:function(e,t){return{focused:Hf(t.focusedTags)}},HIDE_ANNOTATION:function(e,t){return{annotations:e.annotations.map((e=>e.id!==t.id?e:{...e,hidden:!0}))}},HIGHLIGHT_ANNOTATIONS:function(e,t){return{highlighted:t.highlighted}},REMOVE_ANNOTATIONS:function(e,t){return{annotations:[...t.remainingAnnotations]}},UNHIDE_ANNOTATION:function(e,t){return{annotations:e.annotations.map((e=>e.id!==t.id?e:Object.assign({},e,{hidden:!1})))}},UPDATE_ANCHOR_STATUS:function(e,t){return{annotations:e.annotations.map((e=>{if(!t.statusUpdates.hasOwnProperty(e.$tag))return e;const n=t.statusUpdates[e.$tag];return"timeout"===n?Object.assign({},e,{$anchorTimeout:!0}):Object.assign({},e,{$orphan:"orphan"===n})}))}},UPDATE_FLAG_STATUS:function(e,t){
630
- return{annotations:e.annotations.map((e=>{if(e.id&&e.id===t.id){if(e.flagged===t.isFlagged)return e;const n=Object.assign({},e,{flagged:t.isFlagged});if(n.moderation){const r=t.isFlagged?1:-1;n.moderation=Object.assign({},e.moderation,{flagCount:e.moderation.flagCount+r})}return n}return e}))}}},Kf=Km(Yf);function Xf(e){return(t,n)=>{const r=function(e,t){const n={},r={};return t.forEach((e=>{e.id&&(n[e.id]=!0),e.$tag&&(r[e.$tag]=!0)})),e.filter((e=>!(e.id&&e.id in n||e.$tag&&e.$tag in r)))}(n().annotations.annotations,e);t({type:Kf.REMOVE_ANNOTATIONS,annotationsToRemove:e,remainingAnnotations:r})}}function Zf(e){return{type:Kf.UPDATE_ANCHOR_STATUS,statusUpdates:e}}const Jf=Ff((e=>e.annotations),(e=>jf(e,zi)));const Qf=Ff((e=>e.focused),(e=>Uf(e))),eg=Ff((e=>e.highlighted),(e=>Uf(e)))
631
- ;const tg=Ff((e=>e.annotations),(e=>e.some(Ei))),ng=Ff((e=>e.annotations),(e=>e.filter((e=>Si(e)&&!Ni(e))))),rg=Ff((e=>e.annotations),(e=>e.filter((e=>Si(e)&&Ni(e))))),og=Ff((e=>e.annotations),(e=>jf(e,Mi))),ig=Ff((e=>e.annotations),(e=>jf(e,Li)));var ag=Lf({annotations:[],focused:{},highlighted:{},nextTag:1},{namespace:"annotations",reducers:Yf,actionCreators:{addAnnotations:function(e){return function(t,n){const r=e.filter((e=>!Vf(n().annotations.annotations,e.id)));if(t({type:Kf.ADD_ANNOTATIONS,annotations:e,currentAnnotationCount:n().annotations.annotations.length}),"sidebar"!==Gf.selectors.route(n().route))return;const o=r.filter(Ei).map((e=>e.id));o.length>0&&setTimeout((()=>{const e=n().annotations.annotations,r=o.map((t=>Vf(e,t))).filter((e=>e&&Ei(e))).reduce(((e,t)=>(e[t.$tag]="timeout",e)),{});t(Zf(r))}),500)}},clearAnnotations:function(){return{type:Kf.CLEAR_ANNOTATIONS}},focusAnnotations:function(e){return{type:Kf.FOCUS_ANNOTATIONS,focusedTags:e}},hideAnnotation:function(e){return{
632
- type:Kf.HIDE_ANNOTATION,id:e}},highlightAnnotations:function(e){return{type:Kf.HIGHLIGHT_ANNOTATIONS,highlighted:Hf(e)}},removeAnnotations:Xf,unhideAnnotation:function(e){return{type:Kf.UNHIDE_ANNOTATION,id:e}},updateAnchorStatus:Zf,updateFlagStatus:function(e,t){return{type:Kf.UPDATE_FLAG_STATUS,id:e,isFlagged:t}}},selectors:{allAnnotations:function(e){return e.annotations},annotationCount:Jf,annotationExists:function(e,t){return e.annotations.some((e=>e.id===t))},findAnnotationByID:function(e,t){return Vf(e.annotations,t)},findIDsForTags:function(e,t){const n=[];return t.forEach((t=>{const r=Wf(e.annotations,t);r&&r.id&&n.push(r.id)})),n},focusedAnnotations:Qf,highlightedAnnotations:eg,isAnnotationFocused:function(e,t){return!0===e.focused[t]},isWaitingToAnchorAnnotations:tg,newAnnotations:ng,newHighlights:rg,noteCount:og,orphanCount:ig,savedAnnotations:function(e){return e.annotations.filter((e=>!Si(e)))}}});const sg={SET_DEFAULT:function(e,t){return{[t.defaultKey]:t.value}}},lg=Km(sg);var cg=Lf({
633
- annotationPrivacy:null,focusedGroup:null},{namespace:"defaults",reducers:sg,actionCreators:{setDefault:function(e,t){return{type:lg.SET_DEFAULT,defaultKey:e,value:t}}},selectors:{getDefault:function(e,t){return e[t]},getDefaults:function(e){return e}}});const ug={UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED:(e,t)=>({directLinkedGroupFetchFailed:t.directLinkedGroupFetchFailed}),UPDATE_DIRECT_LINKED_GROUP_ID:(e,t)=>({directLinkedGroupId:t.directLinkedGroupId}),UPDATE_DIRECT_LINKED_ANNOTATION_ID:(e,t)=>({directLinkedAnnotationId:t.directLinkedAnnotationId}),CLEAR_DIRECT_LINKED_IDS:()=>({directLinkedAnnotationId:null,directLinkedGroupId:null}),CLEAR_SELECTION:function(){return{directLinkedAnnotationId:null,directLinkedGroupId:null,directLinkedGroupFetchFailed:!1}}},hg=Km(ug);var dg=Lf((function(e){return{directLinkedGroupId:e.group||null,directLinkedAnnotationId:e.annotations||null,directLinkedGroupFetchFailed:!1}}),{namespace:"directLinked",reducers:ug,actionCreators:{setDirectLinkedGroupFetchFailed:function(){
634
- return{type:hg.UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED,directLinkedGroupFetchFailed:!0}},setDirectLinkedGroupId:function(e){return{type:hg.UPDATE_DIRECT_LINKED_GROUP_ID,directLinkedGroupId:e}},setDirectLinkedAnnotationId:function(e){return{type:hg.UPDATE_DIRECT_LINKED_ANNOTATION_ID,directLinkedAnnotationId:e}},clearDirectLinkedGroupFetchFailed:function(){return{type:hg.UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED,directLinkedGroupFetchFailed:!1}},clearDirectLinkedIds:function(){return{type:hg.CLEAR_DIRECT_LINKED_IDS}}},selectors:{directLinkedAnnotationId:function(e){return e.directLinkedAnnotationId},directLinkedGroupFetchFailed:function(e){return e.directLinkedGroupFetchFailed},directLinkedGroupId:function(e){return e.directLinkedGroupId}}});class pg{constructor(e,t){this.annotation={id:e.id,$tag:e.$tag},this.isPrivate=t.isPrivate,this.tags=t.tags,this.text=t.text}match(e){return this.annotation.$tag&&e.$tag===this.annotation.$tag||this.annotation.id&&e.id===this.annotation.id}isEmpty(){
635
- return!this.text&&0===this.tags.length}}const mg={DISCARD_ALL_DRAFTS:function(){return[]},REMOVE_DRAFT:function(e,t){return e.filter((e=>!e.match(t.annotation)))},UPDATE_DRAFT:function(e,t){const n=e.filter((e=>!e.match(t.draft.annotation)));return n.push(t.draft),n}},fg=Km(mg);function gg(e){return{type:fg.REMOVE_DRAFT,annotation:e}}function vg(e,t){const n=e;for(let e=0;e<n.length;e++){const r=n[e];if(r.match(t))return r}return null}function yg(e,t){const n=vg(e,t);return n?n.isEmpty()?null:n:null}const _g=Ff((e=>e),(e=>e.filter((e=>!e.annotation.id)).map((e=>e.annotation))));var bg=Lf([],{namespace:"drafts",reducers:mg,actionCreators:{createDraft:function(e,t){return{type:fg.UPDATE_DRAFT,draft:new pg(e,t)}},deleteNewAndEmptyDrafts:function(){return(e,t)=>{const n=t().drafts.filter((e=>Si(e.annotation)&&!yg(t().drafts,e.annotation))).map((t=>(e(gg(t.annotation)),t.annotation)));e(Xf(n))}},discardAllDrafts:function(){return{type:fg.DISCARD_ALL_DRAFTS}},removeDraft:gg},selectors:{countDrafts:function(e){
636
- return e.length},getDraft:vg,getDraftIfNotEmpty:yg,unsavedAnnotations:_g}});function wg(e){var t,n;return!!(null!==(t=e.user)&&void 0!==t&&t.username||null!==(n=e.user)&&void 0!==n&&n.userid)}function xg(e){if(!wg(e))return{};const t=e.user.username||e.user.userid||"";return{user:{value:t,display:e.user.displayName||t}}}const kg={CHANGE_FOCUS_MODE_USER:function(e,t){return{focusActive:wg({user:t.user}),focusFilters:xg({user:t.user})}},SET_FILTER:function(e,t){var n;const r={...e.filters,[t.filterName]:t.filterOption};return""===(null===(n=t.filterOption)||void 0===n?void 0:n.value)&&delete r[t.filterName],{filters:r}},SET_FILTER_QUERY:function(e,t){return{query:t.query}},SET_FOCUS_MODE:function(e,t){var n;return{focusActive:null!==(n=t.active)&&void 0!==n?n:!e.focusActive}},CLEAR_SELECTION:function(){return{filters:{},focusActive:!1,query:null}}},Sg=Km(kg);const Cg=Ff((e=>e.focusActive),(e=>e.focusFilters),((e,t)=>{var n;return{active:e,configured:!(null==t||!t.user),
637
- displayName:(null==t||null===(n=t.user)||void 0===n?void 0:n.display)||""}})),Ag=Ff((e=>e.filters),(e=>e.focusActive),(e=>e.focusFilters),((e,t,n)=>t?{...n,...e}:{...e}));const Eg=Ff((e=>Ag(e)),(e=>{const t={};return Object.keys(e).forEach((n=>t[n]=e[n].value)),t}));var Tg=Lf((function(e){const t=e.focus||{};return{filters:{},focusActive:wg(t),focusFilters:xg(t),query:e.query||null}}),{namespace:"filters",reducers:kg,actionCreators:{changeFocusModeUser:function(e){return{type:Sg.CHANGE_FOCUS_MODE_USER,user:e}},setFilter:function(e,t){return(n,r)=>{var o;null!==(o=r().filters.focusFilters)&&void 0!==o&&o[e]&&n({type:Sg.SET_FOCUS_MODE,active:!1}),n({type:Sg.SET_FILTER,filterName:e,filterOption:t})}},setFilterQuery:function(e){return{type:Sg.SET_FILTER_QUERY,query:e}},toggleFocusMode:function(e){return{type:Sg.SET_FOCUS_MODE,active:e}}},selectors:{filterQuery:function(e){return e.query},focusState:Cg,getFilter:function(e,t){return Ag(e)[t]},getFilters:Ag,getFilterValues:Eg,getFocusFilters:function(e){
638
- return e.focusFilters},hasAppliedFilter:function(e){return!(!e.query&&!Object.keys(Ag(e)).length)}}});const Ng={CONNECT_FRAME:function(e,t){return[...e,t.frame]},DESTROY_FRAME:function(e,t){return e.filter((e=>e!==t.frame))},UPDATE_FRAME_ANNOTATION_FETCH_STATUS:function(e,t){return e.map((e=>e.uri&&e.uri===t.uri?Object.assign({},e,{isAnnotationFetchComplete:t.isAnnotationFetchComplete}):e))}},Lg=Km(Ng);const Mg=Ff((e=>e),(e=>e.find((e=>!e.id))||null));const zg=Bf(Pf,Hm)((e=>e.reduce(((e,t)=>e.concat(function(e){let t=[e.uri];return e.metadata&&e.metadata.documentFingerprint&&(t=e.metadata.link.map((e=>e.href))),e.metadata&&e.metadata.link&&e.metadata.link.forEach((e=>{e.href.startsWith("doi:")&&t.push(e.href)})),t}(t))),[])),(e=>e));var Og=Lf([],{namespace:"frames",reducers:Ng,actionCreators:{connectFrame:function(e){return{type:Lg.CONNECT_FRAME,frame:e}},destroyFrame:function(e){return{type:Lg.DESTROY_FRAME,frame:e}},updateFrameAnnotationFetchStatus:function(e,t){return{
639
- type:Lg.UPDATE_FRAME_ANNOTATION_FETCH_STATUS,isAnnotationFetchComplete:t,uri:e}}},selectors:{frames:function(e){return e},mainFrame:Mg,searchUris:zg}});const Ig={features:{},preferences:{},userid:null};const Rg={UPDATE_PROFILE:function(e,t){return{profile:{...t.profile}}}},Pg=Km(Rg);var Dg=Lf((function(e){var t;return{defaultAuthority:null!==(t=null==e?void 0:e.authDomain)&&void 0!==t?t:"",profile:Ig}}),{namespace:"session",reducers:Rg,actionCreators:{updateProfile:function(e){return{type:Pg.UPDATE_PROFILE,profile:e}}},selectors:{defaultAuthority:function(e){return e.defaultAuthority},hasFetchedProfile:function(e){return e.profile!==Ig},isFeatureEnabled:function(e,t){return!!e.profile.features[t]},isLoggedIn:function(e){return null!==e.profile.userid},profile:function(e){return e.profile}}});const Bg={FILTER_GROUPS(e,t){var n;if(null===(n=t.filteredGroupIds)||void 0===n||!n.length)return{filteredGroupIds:null};const r=e.groups.filter((e=>t.filteredGroupIds.includes(e.id)));if(!r.length)return{
640
- filteredGroupIds:null};let o=e.focusedGroupId;return o&&t.filteredGroupIds.includes(o)||(o=r[0].id),{filteredGroupIds:t.filteredGroupIds,focusedGroupId:o}},FOCUS_GROUP(e,t){const n=e.groups.find((e=>e.id===t.id));return n?{focusedGroupId:t.id}:(console.error(`Attempted to focus group ${t.id} which is not loaded`),{})},LOAD_GROUPS(e,t){const n=t.groups;let r=e.focusedGroupId;return null!==e.focusedGroupId&&n.find((t=>t.id===e.focusedGroupId))||(r=n.length>0?n[0].id:null),{focusedGroupId:r,groups:t.groups}},CLEAR_GROUPS:()=>({filteredGroupIds:null,focusedGroupId:null,groups:[]})},Fg=Km(Bg);function jg(e){return e.filteredGroupIds?e.groups.filter((t=>{var n;return null===(n=e.filteredGroupIds)||void 0===n?void 0:n.includes(t.id)})):e.groups}function Hg(e,t){return e.groups.find((e=>e.id===t))}
641
- const Ug=Ff((e=>jg(e)),(e=>e.filter((e=>!e.isMember&&e.isScopedToUri)))),qg=Ff((e=>jg(e)),(e=>e.filter((e=>e.isScopedToUri)))),$g=Ff((e=>jg(e.groups)),(e=>Dg.selectors.isLoggedIn(e.session)),((e,t)=>t?e.filter((e=>e.isMember)):[])),Gg=Ff((e=>jg(e.groups)),(e=>$g(e)),(e=>Ug(e.groups)),((e,t,n)=>e.filter((e=>!t.includes(e)&&!n.includes(e)))));var Vg=Lf({filteredGroupIds:null,groups:[],focusedGroupId:null},{namespace:"groups",reducers:Bg,actionCreators:{filterGroups:function(e){return{type:Fg.FILTER_GROUPS,filteredGroupIds:e}},focusGroup:function(e){return{type:Fg.FOCUS_GROUP,id:e}},loadGroups:function(e){return{type:Fg.LOAD_GROUPS,groups:e}},clearGroups:function(){return{type:Fg.CLEAR_GROUPS}}},selectors:{allGroups:function(e){return e.groups},filteredGroups:jg,filteredGroupIds:function(e){return e.filteredGroupIds},focusedGroup:function(e){return e.focusedGroupId?Hg(e,e.focusedGroupId):null},focusedGroupId:function(e){return e.focusedGroupId},getFeaturedGroups:Ug,getGroup:Hg,getInScopeGroups:qg},
642
- rootSelectors:{getCurrentlyViewingGroups:Gg,getMyGroups:$g}});const Wg={UPDATE_LINKS:(e,t)=>({...t.links})},Yg=Km(Wg);var Kg=Lf(null,{namespace:"links",reducers:Wg,actionCreators:{updateLinks:function(e){return{type:Yg.UPDATE_LINKS,links:e}}},selectors:{getLink:function(e,t,n={}){if(!e)return"";const r=e[t];if(!r)throw new Error(`Unknown link "${t}"`);const{url:o,unusedParams:i}=Em(r,n),a=Object.keys(i);if(a.length>0)throw new Error(`Unused parameters: ${a.join(", ")}`);return o}}});const Xg={RECEIVE_REAL_TIME_UPDATES:(e,t)=>({pendingUpdates:{...t.pendingUpdates},pendingDeletions:{...t.pendingDeletions}}),CLEAR_PENDING_UPDATES:()=>({pendingUpdates:{},pendingDeletions:{}}),ADD_ANNOTATIONS(e,{annotations:t}){const n={...e.pendingUpdates};return t.forEach((e=>delete n[e.id])),{pendingUpdates:n}},REMOVE_ANNOTATIONS(e,{annotationsToRemove:t}){const n={...e.pendingUpdates},r={...e.pendingDeletions};return t.forEach((e=>{delete n[e.id],delete r[e.id]})),{pendingUpdates:n,pendingDeletions:r}},FOCUS_GROUP:()=>({
643
- pendingUpdates:{},pendingDeletions:{}})},Zg=Km(Xg);const Jg=Ff((e=>[e.pendingUpdates,e.pendingDeletions]),(([e,t])=>Object.keys(e).length+Object.keys(t).length));var Qg=Lf({pendingUpdates:{},pendingDeletions:{}},{namespace:"realTimeUpdates",reducers:Xg,actionCreators:{receiveRealTimeUpdates:function({updatedAnnotations:e=[],deletedAnnotations:t=[]}){return(n,r)=>{const o={...r().realTimeUpdates.pendingUpdates},i={...r().realTimeUpdates.pendingDeletions};e.forEach((e=>{const t=r().groups,n=r().route;e.group!==Vg.selectors.focusedGroupId(t)&&"sidebar"===Gf.selectors.route(n)||(o[e.id]=e)})),t.forEach((e=>{const t=e.id;delete o[t];const n=r().annotations;ag.selectors.annotationExists(n,t)&&(i[t]=!0)})),n({type:Zg.RECEIVE_REAL_TIME_UPDATES,pendingUpdates:o,pendingDeletions:i})}},clearPendingUpdates:function(){return{type:Zg.CLEAR_PENDING_UPDATES}}},selectors:{hasPendingDeletion:function(e,t){return e.pendingDeletions.hasOwnProperty(t)},pendingDeletions:function(e){return e.pendingDeletions},
644
- pendingUpdates:function(e){return e.pendingUpdates},pendingUpdateCount:Jg}});const ev={annotation:"Location",note:"Oldest",orphan:"Location"};function tv(e){const t={};return e.annotations&&!e.query&&(t[e.annotations]=!0),t}const nv=(e,t)=>t===e?{}:{selectedTab:e,sortKey:ev[e]},rv={CLEAR_SELECTION:function(){return{forcedVisible:{},selected:{}}},SELECT_ANNOTATIONS:function(e,t){return{selected:t.selection}},SELECT_TAB:function(e,t){return nv(t.tab,e.selectedTab)},SET_EXPANDED:function(e,t){const n={...e.expanded};return n[t.id]=t.expanded,{expanded:n}},SET_FORCED_VISIBLE:function(e,t){return{forcedVisible:{...e.forcedVisible,[t.id]:t.visible}}},SET_SORT_KEY:function(e,t){return{sortKey:t.key}},TOGGLE_SELECTED_ANNOTATIONS:function(e,t){const n={...e.selected};return t.toggleIds.forEach((e=>{n[e]=!n[e]})),{selected:n}},ADD_ANNOTATIONS(e,t){const n=t.annotations.filter((e=>!ki(e))),r=jf(t.annotations,Mi)===n.length;return 0===t.currentAnnotationCount&&r?nv("note",e.selectedTab):{}},
645
- CHANGE_FOCUS_MODE_USER:function(){return{forcedVisible:{},selected:{}}},SET_FILTER:function(){return{forcedVisible:{},selected:{},expanded:{}}},SET_FILTER_QUERY:function(){return{forcedVisible:{},selected:{},expanded:{}}},SET_FOCUS_MODE:function(){return{forcedVisible:{},selected:{}}},REMOVE_ANNOTATIONS:function(e,t){let n=e.selectedTab;"orphan"===n&&0===jf(t.remainingAnnotations,Li)&&(n="annotation");const r=e=>(t.annotationsToRemove.forEach((t=>{t.id&&delete e[t.id],t.$tag&&delete e[t.$tag]})),e);return{...nv(n,e.selectedTab),expanded:r({...e.expanded}),forcedVisible:r({...e.forcedVisible}),selected:r({...e.selected})}}},ov=Km(rv);function iv(e){return e.expanded}const av=Ff((e=>e.forcedVisible),(e=>Uf(e))),sv=Ff((e=>e.selected),(e=>Uf(e).length>0)),lv=Ff((e=>e.selected),(e=>Uf(e)));function cv(e){return e.selectedTab}const uv=Ff((e=>e),(e=>({expanded:iv(e),forcedVisible:av(e),selected:lv(e),sortKey:hv(e),selectedTab:cv(e)})));function hv(e){return e.sortKey}const dv=Ff((e=>e.selectedTab),(e=>{
646
- const t=["Newest","Oldest"];return"note"!==e&&t.push("Location"),t}));var pv=Lf((function(e){return{selected:tv(e),expanded:tv(e)||{},forcedVisible:{},selectedTab:"annotation",sortKey:ev.annotation}}),{namespace:"selection",reducers:rv,actionCreators:{clearSelection:function(){return{type:ov.CLEAR_SELECTION}},selectAnnotations:function(e){return t=>{t({type:ov.CLEAR_SELECTION}),t({type:ov.SELECT_ANNOTATIONS,selection:Hf(e)})}},selectTab:function(e){return{type:ov.SELECT_TAB,tab:e}},setExpanded:function(e,t){return{type:ov.SET_EXPANDED,id:e,expanded:t}},setForcedVisible:function(e,t){return{type:ov.SET_FORCED_VISIBLE,id:e,visible:t}},setSortKey:function(e){return{type:ov.SET_SORT_KEY,key:e}},toggleSelectedAnnotations:function(e){return{type:ov.TOGGLE_SELECTED_ANNOTATIONS,toggleIds:e}}},selectors:{expandedMap:iv,forcedVisibleThreads:av,hasSelectedAnnotations:sv,selectedAnnotations:lv,selectedTab:cv,selectionState:uv,sortKey:hv,sortKeys:dv}});const mv={OPEN_SIDEBAR_PANEL:function(e,t){return{
647
- 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}}},fv=Km(mv);var gv=Lf({activePanelName:null},{namespace:"sidebarPanels",reducers:mv,actionCreators:{openSidebarPanel:function(e){return{type:fv.OPEN_SIDEBAR_PANEL,panelName:e}},closeSidebarPanel:function(e){return{type:fv.CLOSE_SIDEBAR_PANEL,panelName:e}},toggleSidebarPanel:function(e,t){return{type:fv.TOGGLE_SIDEBAR_PANEL,panelName:e,panelState:t}}},selectors:{isSidebarPanelOpen:function(e,t){return e.activePanelName===t}}});const vv={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{
648
- messages:e.messages.map((e=>e.id&&e.id===t.message.id?{...t.message}:e))}}},yv=Km(vv);var _v=Lf({messages:[]},{namespace:"toastMessages",reducers:vv,actionCreators:{addToastMessage:function(e){return{type:yv.ADD_MESSAGE,message:e}},removeToastMessage:function(e){return{type:yv.REMOVE_MESSAGE,id:e}},updateToastMessage:function(e){return{type:yv.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 bv={SET_SIDEBAR_OPENED:(e,t)=>!0===t.opened?{sidebarHasOpened:!0}:{}},wv=Km(bv);var xv=Lf({sidebarHasOpened:!1},{namespace:"viewer",reducers:bv,actionCreators:{setSidebarOpened:function(e){return{type:wv.SET_SIDEBAR_OPENED,opened:e}}},selectors:{hasSidebarOpened:function(e){return e.sidebarHasOpened}}});function kv(e){return Nf([If,ag,cg,dg,bg,Tg,Og,Kg,Vg,Qg,Gf,pv,Dg,gv,_v,xv],[e],[Mf])}kv.$inject=["settings"];class Sv{
649
- 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)
650
- }(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 Cv=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),Av=function(e){const{version:t,origin:n}=R(e.location.href);return"1.970.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.970.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 Ev(e,t){e.setClientId(t.clientId)}
651
- function Tv(e,t,n){e.load(),t.load(),n.sync()}function Nv(e,t,n,r){e.init(),t.init(),n.init(),r.init()}function Lv(e,t){"sidebar"===t.route()&&e.connect()}Cv.sentry&&Av&&function(e){const t=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;wr({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.970.0",beforeSend:(e,t)=>{if(Sr>=5)return K("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Sr;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{Yt("host_config",R(window.location.href))}catch(e){}Yt("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),kr(((e,t)=>{Wt(e,{tags:{context:t}})}))}(Cv.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target
652
- ;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)}}}(),Ev.$inject=["api","streamer"],Tv.$inject=["groups","session","router"],Nv.$inject=["autosaveService","features","persistedDefaults","serviceURL"],Lv.$inject=["frameSync","store"],function(e,{reset:t=!1}={}){t&&mo.clear();for(let[t,n]of Object.entries(e))mo.set(t,n)}(Ko);const Mv=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++){
653
- 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")}(Cv).then((e=>{!function(e,t){const n=new Sv;n.register("annotationsService",Sm).register("api",Nm).register("apiRoutes",Pm).register("auth",Fm).register("autosaveService",jm).register("features",qm).register("frameSync",Ym).register("groups",Jm).register("loadAnnotationsService",Qm).register("localStorage",tf).register("persistedDefaults",rf).register("router",of).register("serviceURL",af).register("session",sf).register("streamer",uf).register("streamFilter",lf).register("tags",hf).register("threadsService",df).register("toastMessenger",pf).register("store",{factory:kv}),n.register("$window",{value:window
654
- }).register("settings",{value:e}),n.run(Nv),n.run(Ev),n.run(Tv),n.run(ee),n.run(Lv),I(po(ni.Provider,{value:n,children:po(xm,{})}),t)}(e,Mv)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),I(po(km,{error:e}),t)}(e,Mv)));
611
+ this._window.history.pushState({},"",this.routeUrl(e,t)),this.sync()}}af.$inject=["$window","store"];class sf{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}`)}}}sf.$inject=["apiRoutes","store"];class lf{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)})).then((e=>(this.update(e),this._lastLoadTime=Date.now(),e))).catch((e=>{throw this._lastLoadTime=null,e}))),this._lastLoad}async dismissSidebarTutorial(){
612
+ 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?Cr({id:e.userid}):Cr(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()}}lf.$inject=["store","api","auth","settings","toastMessenger"];class cf{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(){return this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,delete:!0}},this}}class uf extends Jp{constructor(e){super();const t=[];let n
613
+ ;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 hf{constructor(e,t,n,r,o){this._auth=n,this._groups=r,this._session=o,this._store=e,this._websocketURL=t.links().then((e=>e.websocket)),this.clientId=q(32),this._socket=null,this._updateImmediately=!0,this._configMessages={},this._reconnectionAttempts=0,this._reconnectSetUp=!1}applyPendingUpdates(){const e=Object.values(this._store.pendingUpdates());e.length&&this._store.addAnnotations(e);const t=Object.keys(this._store.pendingDeletions()).map((e=>({id:e})))
614
+ ;t.length&&this._store.removeAnnotations(t),this._store.clearPendingUpdates()}_handleSocketError(e,t){K("Error connecting to H push notification service:",t);const n=new URL(e).hostname;-1!==["localhost","127.0.0.1"].indexOf(n)&&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){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){
615
+ 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;const t=await this._websocketURL;if(!t)return;let n,r;null===(e=this._socket)||void 0===e||e.close();try{n=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(n){const e=new URL(t);e.searchParams.set("access_token",n),r=e.toString()}else r=t;const o=new uf(r);o.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(o)})),o.on("disconnect",(()=>{if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),o.on("error",(e=>this._handleSocketError(t,e))),o.on("message",(e=>this._handleSocketMessage(e))),
616
+ this._socket=o,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){var t;this._updateImmediately=null===(t=e.applyUpdatesImmediately)||void 0===t||t,this._reconnectSetUp||(this._reconnectSetUp=!0,qm(this._store.subscribe,(()=>this._store.profile().userid),(()=>{this._reconnect()}))),this._socket||await this._reconnect()}}hf.$inject=["store","apiRoutes","auth","groups","session"];class df{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){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)
617
+ ;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)}}df.$inject=["localStorage"];class pf{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}pf.$inject=["store"];class mf{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}),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 ff(e,t,n){return t in e?Object.defineProperty(e,t,{
618
+ value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gf(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 vf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gf(Object(n),!0).forEach((function(t){ff(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gf(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function yf(e){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. "}mf.$inject=["store"];var _f="function"==typeof Symbol&&Symbol.observable||"@@observable",bf=function(){return Math.random().toString(36).substring(7).split("").join(".")},wf={INIT:"@@redux/INIT"+bf(),
619
+ REPLACE:"@@redux/REPLACE"+bf(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+bf()}};function xf(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 kf(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(yf(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(yf(1));return n(kf)(e,t)}if("function"!=typeof e)throw new Error(yf(2));var o=e,i=t,a=[],s=a,l=!1;function c(){s===a&&(s=a.slice())}function u(){if(l)throw new Error(yf(3));return i}function h(e){if("function"!=typeof e)throw new Error(yf(4));if(l)throw new Error(yf(5));var t=!0;return c(),s.push(e),function(){if(t){if(l)throw new Error(yf(6));t=!1,c();var n=s.indexOf(e);s.splice(n,1),a=null}}}function d(e){if(!xf(e))throw new Error(yf(7));if(void 0===e.type)throw new Error(yf(8))
620
+ ;if(l)throw new Error(yf(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(yf(10));o=e,d({type:wf.REPLACE})}function m(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(yf(11));function n(){e.next&&e.next(u())}return n(),{unsubscribe:t(n)}}})[_f]=function(){return this},e}return d({type:wf.INIT}),(r={dispatch:d,subscribe:h,getState:u,replaceReducer:p})[_f]=m,r}function Sf(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){Object.keys(e).forEach((function(t){var n=e[t];if(void 0===n(void 0,{type:wf.INIT}))throw new Error(yf(12));if(void 0===n(void 0,{type:wf.PROBE_UNKNOWN_ACTION()}))throw new Error(yf(13))}))}(n)}catch(e){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var r=!1,o={},s=0;s<a.length;s++){var l=a[s],c=n[l],u=e[l],h=c(u,t);if(void 0===h)throw t&&t.type,
621
+ new Error(yf(14));o[l]=h,r=r||h!==u}return(r=r||a.length!==Object.keys(e).length)?o:e}}function Cf(e,t){return function(){return t(e.apply(this,arguments))}}function Af(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function Ef(e){return function(t){var n=t.dispatch,r=t.getState;return function(t){return function(o){return"function"==typeof o?o(n,r,e):t(o)}}}}var Tf=Ef();Tf.withExtraArgument=Ef;var Nf=Tf;function Lf(e,t=[],n=[]){const r={},o={},i={};e.forEach((e=>{e.namespace?(r[e.namespace]=e.initialState(...t),o[e.namespace]=function(e){return(t={},n)=>{const r=e[n.type];if(!r)return t;const o=r(t,n);return Array.isArray(o)?o:{...t,...o}}}(e.reducers),i[e.namespace]={selectors:e.selectors,rootSelectors:e.rootSelectors||{}}):console.warn("Store module does not specify a namespace",e)}));const a=function(){
622
+ for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw new Error(yf(15))},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return r=Af.apply(void 0,i)(n.dispatch),vf(vf({},n),{},{dispatch:r})}}}(...[Nf],...n);const s=kf(Sf(o),r,a),l=Object.assign({},...e.map((e=>e.actionCreators))),c=function(e,t){if("function"==typeof e)return Cf(e,t);if("object"!=typeof e||null===e)throw new Error(yf(16));var n={};for(var r in e){var o=e[r];"function"==typeof o&&(n[r]=Cf(o,t))}return n}(l,s.dispatch),u=function(e,t){const n={};return Object.keys(e).forEach((r=>{const{selectors:o,rootSelectors:i={}}=e[r];Object.keys(o).forEach((e=>{if(n[e])throw new Error(`Duplicate selector "${e}"`);n[e]=(...n)=>o[e](t()[r],...n)})),Object.keys(i).forEach((e=>{if(n[e])throw new Error(`Duplicate selector "${e}"`);n[e]=(...n)=>i[e](t(),...n)}))})),n}(i,s.getState)
623
+ ;return Object.assign(s,c,u),s}function Mf(e,t){if(!(e instanceof Function)){const t=e;e=()=>t}return{initialState:e,...t}}function zf(e){let t=0;return function(n){return function(r){if(!window.debug)return void n(r);++t;const o=r.type+" ("+t.toString()+")";console.group(o),console.log("Prev State:",e.getState()),console.log("Action:",r),n(r),console.log("Next State:",e.getState()),console.groupEnd()}}}const Of={API_REQUEST_STARTED:e=>({...e,activeApiRequests:e.activeApiRequests+1}),API_REQUEST_FINISHED(e){if(0===e.activeApiRequests)throw new Error("API_REQUEST_FINISHED action when no requests were active");return{...e,activeApiRequests:e.activeApiRequests-1}},ANNOTATION_SAVE_STARTED(e,t){let n=[];t.annotation.$tag&&!e.activeAnnotationSaveRequests.includes(t.annotation.$tag)&&n.push(t.annotation.$tag);const r=e.activeAnnotationSaveRequests.concat(n);return{...e,activeAnnotationSaveRequests:r}},ANNOTATION_SAVE_FINISHED(e,t){const n=e.activeAnnotationSaveRequests.filter((e=>e!==t.annotation.$tag));return{...e,
624
+ activeAnnotationSaveRequests:n}},ANNOTATION_FETCH_STARTED:e=>({...e,activeAnnotationFetches:e.activeAnnotationFetches+1}),ANNOTATION_FETCH_FINISHED(e){if(0===e.activeAnnotationFetches)throw new Error("ANNOTATION_FETCH_FINISHED action when no annotation fetches were active");return{...e,hasFetchedAnnotations:!0,activeAnnotationFetches:e.activeAnnotationFetches-1}},SET_ANNOTATION_RESULT_COUNT:(e,t)=>({annotationResultCount:t.resultCount})},If=Xm(Of);var Rf=Mf({activeAnnotationSaveRequests:[],activeApiRequests:0,activeAnnotationFetches:0,hasFetchedAnnotations:!1,annotationResultCount:null},{reducers:Of,namespace:"activity",actionCreators:{annotationFetchStarted:function(){return{type:If.ANNOTATION_FETCH_STARTED}},annotationFetchFinished:function(){return{type:If.ANNOTATION_FETCH_FINISHED}},annotationSaveStarted:function(e){return{type:If.ANNOTATION_SAVE_STARTED,annotation:e}},annotationSaveFinished:function(e){return{type:If.ANNOTATION_SAVE_FINISHED,annotation:e}},apiRequestStarted:function(){return{
625
+ type:If.API_REQUEST_STARTED}},apiRequestFinished:function(){return{type:If.API_REQUEST_FINISHED}},setAnnotationResultCount:function(e){return{type:If.SET_ANNOTATION_RESULT_COUNT,resultCount:e}}},selectors:{hasFetchedAnnotations:function(e){return e.hasFetchedAnnotations},isLoading:function(e){return e.activeApiRequests>0||!e.hasFetchedAnnotations},isFetchingAnnotations:function(e){return e.activeAnnotationFetches>0},isSavingAnnotation:function(e,t){return!!t.$tag&&e.activeAnnotationSaveRequests.includes(t.$tag)},annotationResultCount:function(e){return e.annotationResultCount}}});var Pf=function(e,t){return e===t};function Df(e,t){var n,r,o="object"==typeof t?t:{equalityCheck:t},i=o.equalityCheck,a=void 0===i?Pf:i,s=o.maxSize,l=void 0===s?1:s,c=o.resultEqualityCheck,u=function(e){return function(t,n){if(null===t||null===n||t.length!==n.length)return!1;for(var r=t.length,o=0;o<r;o++)if(!e(t[o],n[o]))return!1;return!0}}(a),h=1===l?(n=u,{get:function(e){return r&&n(r.key,e)?r.value:"NOT_FOUND"},
626
+ put:function(e,t){r={key:e,value:t}},getEntries:function(){return r?[r]:[]},clear:function(){r=void 0}}):function(e,t){var n=[];function r(e){var r=n.findIndex((function(n){return t(e,n.key)}));if(r>-1){var o=n[r];return r>0&&(n.splice(r,1),n.unshift(o)),o.value}return"NOT_FOUND"}return{get:r,put:function(t,o){"NOT_FOUND"===r(t)&&(n.unshift({key:t,value:o}),n.length>e&&n.pop())},getEntries:function(){return n},clear:function(){n=[]}}}(l,u);function d(){var t=h.get(arguments);if("NOT_FOUND"===t){if(t=e.apply(null,arguments),c){var n=h.getEntries(),r=n.find((function(e){return c(e.value,t)}));r&&(t=r.value)}h.put(arguments,t)}return t}return d.clearCache=function(){return h.clear()},d}function Bf(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var n=t.map((function(e){return"function"==typeof e?"function "+(e.name||"unnamed")+"()":typeof e})).join(", ")
627
+ ;throw new Error("createSelector expects all input-selectors to be functions, but received the following types: ["+n+"]")}return t}function Ff(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];var i,a=0,s={memoizeOptions:void 0},l=r.pop();if("object"==typeof l&&(s=l,l=r.pop()),"function"!=typeof l)throw new Error("createSelector expects an output function after the inputs, but received: ["+typeof l+"]");var c=s,u=c.memoizeOptions,h=void 0===u?n:u,d=Array.isArray(h)?h:[h],p=Bf(r),m=e.apply(void 0,[function(){return a++,l.apply(null,arguments)}].concat(d)),f=e((function(){for(var e=[],t=p.length,n=0;n<t;n++)e.push(p[n].apply(null,arguments));return i=m.apply(null,e)}));return Object.assign(f,{resultFunc:l,memoizedResultFunc:m,dependencies:p,lastResult:function(){return i},recomputations:function(){return a},resetRecomputations:function(){return a=0}}),f};return o}var jf=Ff(Df)
628
+ ;function Hf(e,t){return e.reduce(((e,n)=>t(n)?e+1:e),0)}function Uf(e){const t={};return e.forEach((e=>t[e]=!0)),t}function qf(e){return Object.keys(e).filter((t=>!0===e[t]))}const $f={CHANGE_ROUTE:(e,{name:t,params:n})=>({name:t,params:n})},Gf=Xm($f);var Vf=Mf({name:null,params:{}},{namespace:"route",reducers:$f,actionCreators:{changeRoute:function(e,t={}){return{type:Gf.CHANGE_ROUTE,name:e,params:t}}},selectors:{route:function(e){return e.name},routeParams:function(e){return e.params}}});function Wf(e,t){return e.find((e=>e.id===t))}function Yf(e,t){return e.find((e=>e.$tag===t))}const Kf={ADD_ANNOTATIONS:function(e,t){const n={},r={},o=[],i=[],a=[];let s=e.nextTag;return t.annotations.forEach((t=>{let i;t.id&&(i=Wf(e.annotations,t.id)),!i&&t.$tag&&(i=Yf(e.annotations,t.$tag)),i?(a.push(Object.assign({},i,t)),t.id&&(n[t.id]=!0),i.$tag&&(r[i.$tag]=!0)):(o.push(function(e,t){let n=e.$orphan;return e.id||(n=!1),Object.assign({},e,{$anchorTimeout:!1,$tag:e.$tag||t,$orphan:n})}(t,"t"+s)),++s)})),
629
+ e.annotations.forEach((e=>{n[e.id]||r[e.$tag]||i.push(e)})),{annotations:o.concat(a).concat(i),nextTag:s}},CLEAR_ANNOTATIONS:function(){return{annotations:[],focused:{},highlighted:{}}},FOCUS_ANNOTATIONS:function(e,t){return{focused:Uf(t.focusedTags)}},HIDE_ANNOTATION:function(e,t){return{annotations:e.annotations.map((e=>e.id!==t.id?e:{...e,hidden:!0}))}},HIGHLIGHT_ANNOTATIONS:function(e,t){return{highlighted:t.highlighted}},REMOVE_ANNOTATIONS:function(e,t){return{annotations:[...t.remainingAnnotations]}},UNHIDE_ANNOTATION:function(e,t){return{annotations:e.annotations.map((e=>e.id!==t.id?e:Object.assign({},e,{hidden:!1})))}},UPDATE_ANCHOR_STATUS:function(e,t){return{annotations:e.annotations.map((e=>{if(!t.statusUpdates.hasOwnProperty(e.$tag))return e;const n=t.statusUpdates[e.$tag];return"timeout"===n?Object.assign({},e,{$anchorTimeout:!0}):Object.assign({},e,{$orphan:"orphan"===n})}))}},UPDATE_FLAG_STATUS:function(e,t){return{annotations:e.annotations.map((e=>{if(e.id&&e.id===t.id){
630
+ if(e.flagged===t.isFlagged)return e;const n=Object.assign({},e,{flagged:t.isFlagged});if(n.moderation){const r=t.isFlagged?1:-1;n.moderation=Object.assign({},e.moderation,{flagCount:e.moderation.flagCount+r})}return n}return e}))}}},Xf=Xm(Kf);function Zf(e){return(t,n)=>{const r=function(e,t){const n={},r={};return t.forEach((e=>{e.id&&(n[e.id]=!0),e.$tag&&(r[e.$tag]=!0)})),e.filter((e=>!(e.id&&e.id in n||e.$tag&&e.$tag in r)))}(n().annotations.annotations,e);t({type:Xf.REMOVE_ANNOTATIONS,annotationsToRemove:e,remainingAnnotations:r})}}function Jf(e){return{type:Xf.UPDATE_ANCHOR_STATUS,statusUpdates:e}}const Qf=jf((e=>e.annotations),(e=>Hf(e,zi)));const eg=jf((e=>e.focused),(e=>qf(e))),tg=jf((e=>e.highlighted),(e=>qf(e)));const ng=jf((e=>e.annotations),(e=>e.some(Ei))),rg=jf((e=>e.annotations),(e=>e.filter((e=>Si(e)&&!Ni(e))))),og=jf((e=>e.annotations),(e=>e.filter((e=>Si(e)&&Ni(e))))),ig=jf((e=>e.annotations),(e=>Hf(e,Mi))),ag=jf((e=>e.annotations),(e=>Hf(e,Li)));var sg=Mf({annotations:[],focused:{},
631
+ highlighted:{},nextTag:1},{namespace:"annotations",reducers:Kf,actionCreators:{addAnnotations:function(e){return function(t,n){const r=e.filter((e=>!Wf(n().annotations.annotations,e.id)));if(t({type:Xf.ADD_ANNOTATIONS,annotations:e,currentAnnotationCount:n().annotations.annotations.length}),"sidebar"!==Vf.selectors.route(n().route))return;const o=r.filter(Ei).map((e=>e.id));o.length>0&&setTimeout((()=>{const e=n().annotations.annotations,r=o.map((t=>Wf(e,t))).filter((e=>e&&Ei(e))).reduce(((e,t)=>(e[t.$tag]="timeout",e)),{});t(Jf(r))}),500)}},clearAnnotations:function(){return{type:Xf.CLEAR_ANNOTATIONS}},focusAnnotations:function(e){return{type:Xf.FOCUS_ANNOTATIONS,focusedTags:e}},hideAnnotation:function(e){return{type:Xf.HIDE_ANNOTATION,id:e}},highlightAnnotations:function(e){return{type:Xf.HIGHLIGHT_ANNOTATIONS,highlighted:Uf(e)}},removeAnnotations:Zf,unhideAnnotation:function(e){return{type:Xf.UNHIDE_ANNOTATION,id:e}},updateAnchorStatus:Jf,updateFlagStatus:function(e,t){return{type:Xf.UPDATE_FLAG_STATUS,
632
+ id:e,isFlagged:t}}},selectors:{allAnnotations:function(e){return e.annotations},annotationCount:Qf,annotationExists:function(e,t){return e.annotations.some((e=>e.id===t))},findAnnotationByID:function(e,t){return Wf(e.annotations,t)},findIDsForTags:function(e,t){const n=[];return t.forEach((t=>{const r=Yf(e.annotations,t);r&&r.id&&n.push(r.id)})),n},focusedAnnotations:eg,highlightedAnnotations:tg,isAnnotationFocused:function(e,t){return!0===e.focused[t]},isWaitingToAnchorAnnotations:ng,newAnnotations:rg,newHighlights:og,noteCount:ig,orphanCount:ag,savedAnnotations:function(e){return e.annotations.filter((e=>!Si(e)))}}});const lg={SET_DEFAULT:function(e,t){return{[t.defaultKey]:t.value}}},cg=Xm(lg);var ug=Mf({annotationPrivacy:null,focusedGroup:null},{namespace:"defaults",reducers:lg,actionCreators:{setDefault:function(e,t){return{type:cg.SET_DEFAULT,defaultKey:e,value:t}}},selectors:{getDefault:function(e,t){return e[t]},getDefaults:function(e){return e}}});const hg={
633
+ UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED:(e,t)=>({directLinkedGroupFetchFailed:t.directLinkedGroupFetchFailed}),UPDATE_DIRECT_LINKED_GROUP_ID:(e,t)=>({directLinkedGroupId:t.directLinkedGroupId}),UPDATE_DIRECT_LINKED_ANNOTATION_ID:(e,t)=>({directLinkedAnnotationId:t.directLinkedAnnotationId}),CLEAR_DIRECT_LINKED_IDS:()=>({directLinkedAnnotationId:null,directLinkedGroupId:null}),CLEAR_SELECTION:function(){return{directLinkedAnnotationId:null,directLinkedGroupId:null,directLinkedGroupFetchFailed:!1}}},dg=Xm(hg);var pg=Mf((function(e){return{directLinkedGroupId:e.group||null,directLinkedAnnotationId:e.annotations||null,directLinkedGroupFetchFailed:!1}}),{namespace:"directLinked",reducers:hg,actionCreators:{setDirectLinkedGroupFetchFailed:function(){return{type:dg.UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED,directLinkedGroupFetchFailed:!0}},setDirectLinkedGroupId:function(e){return{type:dg.UPDATE_DIRECT_LINKED_GROUP_ID,directLinkedGroupId:e}},setDirectLinkedAnnotationId:function(e){return{
634
+ type:dg.UPDATE_DIRECT_LINKED_ANNOTATION_ID,directLinkedAnnotationId:e}},clearDirectLinkedGroupFetchFailed:function(){return{type:dg.UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED,directLinkedGroupFetchFailed:!1}},clearDirectLinkedIds:function(){return{type:dg.CLEAR_DIRECT_LINKED_IDS}}},selectors:{directLinkedAnnotationId:function(e){return e.directLinkedAnnotationId},directLinkedGroupFetchFailed:function(e){return e.directLinkedGroupFetchFailed},directLinkedGroupId:function(e){return e.directLinkedGroupId}}});class mg{constructor(e,t){this.annotation={id:e.id,$tag:e.$tag},this.isPrivate=t.isPrivate,this.tags=t.tags,this.text=t.text}match(e){return this.annotation.$tag&&e.$tag===this.annotation.$tag||this.annotation.id&&e.id===this.annotation.id}isEmpty(){return!this.text&&0===this.tags.length}}const fg={DISCARD_ALL_DRAFTS:function(){return[]},REMOVE_DRAFT:function(e,t){return e.filter((e=>!e.match(t.annotation)))},UPDATE_DRAFT:function(e,t){const n=e.filter((e=>!e.match(t.draft.annotation)));return n.push(t.draft),n
635
+ }},gg=Xm(fg);function vg(e){return{type:gg.REMOVE_DRAFT,annotation:e}}function yg(e,t){const n=e;for(let e=0;e<n.length;e++){const r=n[e];if(r.match(t))return r}return null}function _g(e,t){const n=yg(e,t);return n?n.isEmpty()?null:n:null}const bg=jf((e=>e),(e=>e.filter((e=>!e.annotation.id)).map((e=>e.annotation))));var wg=Mf([],{namespace:"drafts",reducers:fg,actionCreators:{createDraft:function(e,t){return{type:gg.UPDATE_DRAFT,draft:new mg(e,t)}},deleteNewAndEmptyDrafts:function(){return(e,t)=>{const n=t().drafts.filter((e=>Si(e.annotation)&&!_g(t().drafts,e.annotation))).map((t=>(e(vg(t.annotation)),t.annotation)));e(Zf(n))}},discardAllDrafts:function(){return{type:gg.DISCARD_ALL_DRAFTS}},removeDraft:vg},selectors:{countDrafts:function(e){return e.length},getDraft:yg,getDraftIfNotEmpty:_g,unsavedAnnotations:bg}});function xg(e){var t,n;return!!(null!==(t=e.user)&&void 0!==t&&t.username||null!==(n=e.user)&&void 0!==n&&n.userid)}function kg(e){if(!xg(e))return{};const t=e.user.username||e.user.userid||""
636
+ ;return{user:{value:t,display:e.user.displayName||t}}}const Sg={CHANGE_FOCUS_MODE_USER:function(e,t){return{focusActive:xg({user:t.user}),focusFilters:kg({user:t.user})}},SET_FILTER:function(e,t){var n;const r={...e.filters,[t.filterName]:t.filterOption};return""===(null===(n=t.filterOption)||void 0===n?void 0:n.value)&&delete r[t.filterName],{filters:r}},SET_FILTER_QUERY:function(e,t){return{query:t.query}},SET_FOCUS_MODE:function(e,t){var n;return{focusActive:null!==(n=t.active)&&void 0!==n?n:!e.focusActive}},CLEAR_SELECTION:function(){return{filters:{},focusActive:!1,query:null}}},Cg=Xm(Sg);const Ag=jf((e=>e.focusActive),(e=>e.focusFilters),((e,t)=>{var n;return{active:e,configured:!(null==t||!t.user),displayName:(null==t||null===(n=t.user)||void 0===n?void 0:n.display)||""}})),Eg=jf((e=>e.filters),(e=>e.focusActive),(e=>e.focusFilters),((e,t,n)=>t?{...n,...e}:{...e}));const Tg=jf((e=>Eg(e)),(e=>{const t={};return Object.keys(e).forEach((n=>t[n]=e[n].value)),t}));var Ng=Mf((function(e){const t=e.focus||{}
637
+ ;return{filters:{},focusActive:xg(t),focusFilters:kg(t),query:e.query||null}}),{namespace:"filters",reducers:Sg,actionCreators:{changeFocusModeUser:function(e){return{type:Cg.CHANGE_FOCUS_MODE_USER,user:e}},setFilter:function(e,t){return(n,r)=>{var o;null!==(o=r().filters.focusFilters)&&void 0!==o&&o[e]&&n({type:Cg.SET_FOCUS_MODE,active:!1}),n({type:Cg.SET_FILTER,filterName:e,filterOption:t})}},setFilterQuery:function(e){return{type:Cg.SET_FILTER_QUERY,query:e}},toggleFocusMode:function(e){return{type:Cg.SET_FOCUS_MODE,active:e}}},selectors:{filterQuery:function(e){return e.query},focusState:Ag,getFilter:function(e,t){return Eg(e)[t]},getFilters:Eg,getFilterValues:Tg,getFocusFilters:function(e){return e.focusFilters},hasAppliedFilter:function(e){return!(!e.query&&!Object.keys(Eg(e)).length)}}});const Lg={CONNECT_FRAME:function(e,t){return[...e,t.frame]},DESTROY_FRAME:function(e,t){return e.filter((e=>e!==t.frame))},UPDATE_FRAME_ANNOTATION_FETCH_STATUS:function(e,t){
638
+ return e.map((e=>e.uri&&e.uri===t.uri?Object.assign({},e,{isAnnotationFetchComplete:t.isAnnotationFetchComplete}):e))}},Mg=Xm(Lg);const zg=jf((e=>e),(e=>e.find((e=>!e.id))||null));const Og=Ff(Df,Um)((e=>e.reduce(((e,t)=>e.concat(function(e){let t=[e.uri];return e.metadata&&e.metadata.documentFingerprint&&(t=e.metadata.link.map((e=>e.href))),e.metadata&&e.metadata.link&&e.metadata.link.forEach((e=>{e.href.startsWith("doi:")&&t.push(e.href)})),t}(t))),[])),(e=>e));var Ig=Mf([],{namespace:"frames",reducers:Lg,actionCreators:{connectFrame:function(e){return{type:Mg.CONNECT_FRAME,frame:e}},destroyFrame:function(e){return{type:Mg.DESTROY_FRAME,frame:e}},updateFrameAnnotationFetchStatus:function(e,t){return{type:Mg.UPDATE_FRAME_ANNOTATION_FETCH_STATUS,isAnnotationFetchComplete:t,uri:e}}},selectors:{frames:function(e){return e},mainFrame:zg,searchUris:Og}});const Rg={features:{},preferences:{},userid:null};const Pg={UPDATE_PROFILE:function(e,t){return{profile:{...t.profile}}}},Dg=Xm(Pg);var Bg=Mf((function(e){var t
639
+ ;return{defaultAuthority:null!==(t=null==e?void 0:e.authDomain)&&void 0!==t?t:"",profile:Rg}}),{namespace:"session",reducers:Pg,actionCreators:{updateProfile:function(e){return{type:Dg.UPDATE_PROFILE,profile:e}}},selectors:{defaultAuthority:function(e){return e.defaultAuthority},hasFetchedProfile:function(e){return e.profile!==Rg},isFeatureEnabled:function(e,t){return!!e.profile.features[t]},isLoggedIn:function(e){return null!==e.profile.userid},profile:function(e){return e.profile}}});const Fg={FILTER_GROUPS(e,t){var n;if(null===(n=t.filteredGroupIds)||void 0===n||!n.length)return{filteredGroupIds:null};const r=e.groups.filter((e=>t.filteredGroupIds.includes(e.id)));if(!r.length)return{filteredGroupIds:null};let o=e.focusedGroupId;return o&&t.filteredGroupIds.includes(o)||(o=r[0].id),{filteredGroupIds:t.filteredGroupIds,focusedGroupId:o}},FOCUS_GROUP(e,t){const n=e.groups.find((e=>e.id===t.id));return n?{focusedGroupId:t.id}:(console.error(`Attempted to focus group ${t.id} which is not loaded`),{})},
640
+ LOAD_GROUPS(e,t){const n=t.groups;let r=e.focusedGroupId;return null!==e.focusedGroupId&&n.find((t=>t.id===e.focusedGroupId))||(r=n.length>0?n[0].id:null),{focusedGroupId:r,groups:t.groups}},CLEAR_GROUPS:()=>({filteredGroupIds:null,focusedGroupId:null,groups:[]})},jg=Xm(Fg);function Hg(e){return e.filteredGroupIds?e.groups.filter((t=>{var n;return null===(n=e.filteredGroupIds)||void 0===n?void 0:n.includes(t.id)})):e.groups}function Ug(e,t){return e.groups.find((e=>e.id===t))}const qg=jf((e=>Hg(e)),(e=>e.filter((e=>!e.isMember&&e.isScopedToUri)))),$g=jf((e=>Hg(e)),(e=>e.filter((e=>e.isScopedToUri)))),Gg=jf((e=>Hg(e.groups)),(e=>Bg.selectors.isLoggedIn(e.session)),((e,t)=>t?e.filter((e=>e.isMember)):[])),Vg=jf((e=>Hg(e.groups)),(e=>Gg(e)),(e=>qg(e.groups)),((e,t,n)=>e.filter((e=>!t.includes(e)&&!n.includes(e)))));var Wg=Mf({filteredGroupIds:null,groups:[],focusedGroupId:null},{namespace:"groups",reducers:Fg,actionCreators:{filterGroups:function(e){return{type:jg.FILTER_GROUPS,filteredGroupIds:e}},
641
+ focusGroup:function(e){return{type:jg.FOCUS_GROUP,id:e}},loadGroups:function(e){return{type:jg.LOAD_GROUPS,groups:e}},clearGroups:function(){return{type:jg.CLEAR_GROUPS}}},selectors:{allGroups:function(e){return e.groups},filteredGroups:Hg,filteredGroupIds:function(e){return e.filteredGroupIds},focusedGroup:function(e){return e.focusedGroupId?Ug(e,e.focusedGroupId):null},focusedGroupId:function(e){return e.focusedGroupId},getFeaturedGroups:qg,getGroup:Ug,getInScopeGroups:$g},rootSelectors:{getCurrentlyViewingGroups:Vg,getMyGroups:Gg}});const Yg={UPDATE_LINKS:(e,t)=>({...t.links})},Kg=Xm(Yg);var Xg=Mf(null,{namespace:"links",reducers:Yg,actionCreators:{updateLinks:function(e){return{type:Kg.UPDATE_LINKS,links:e}}},selectors:{getLink:function(e,t,n={}){if(!e)return"";const r=e[t];if(!r)throw new Error(`Unknown link "${t}"`);const{url:o,unusedParams:i}=Tm(r,n),a=Object.keys(i);if(a.length>0)throw new Error(`Unused parameters: ${a.join(", ")}`);return o}}});const Zg={RECEIVE_REAL_TIME_UPDATES:(e,t)=>({
642
+ pendingUpdates:{...t.pendingUpdates},pendingDeletions:{...t.pendingDeletions}}),CLEAR_PENDING_UPDATES:()=>({pendingUpdates:{},pendingDeletions:{}}),ADD_ANNOTATIONS(e,{annotations:t}){const n={...e.pendingUpdates};return t.forEach((e=>delete n[e.id])),{pendingUpdates:n}},REMOVE_ANNOTATIONS(e,{annotationsToRemove:t}){const n={...e.pendingUpdates},r={...e.pendingDeletions};return t.forEach((e=>{delete n[e.id],delete r[e.id]})),{pendingUpdates:n,pendingDeletions:r}},FOCUS_GROUP:()=>({pendingUpdates:{},pendingDeletions:{}})},Jg=Xm(Zg);const Qg=jf((e=>[e.pendingUpdates,e.pendingDeletions]),(([e,t])=>Object.keys(e).length+Object.keys(t).length));var ev=Mf({pendingUpdates:{},pendingDeletions:{}},{namespace:"realTimeUpdates",reducers:Zg,actionCreators:{receiveRealTimeUpdates:function({updatedAnnotations:e=[],deletedAnnotations:t=[]}){return(n,r)=>{const o={...r().realTimeUpdates.pendingUpdates},i={...r().realTimeUpdates.pendingDeletions};e.forEach((e=>{const t=r().groups,n=r().route
643
+ ;e.group!==Wg.selectors.focusedGroupId(t)&&"sidebar"===Vf.selectors.route(n)||(o[e.id]=e)})),t.forEach((e=>{const t=e.id;delete o[t];const n=r().annotations;sg.selectors.annotationExists(n,t)&&(i[t]=!0)})),n({type:Jg.RECEIVE_REAL_TIME_UPDATES,pendingUpdates:o,pendingDeletions:i})}},clearPendingUpdates:function(){return{type:Jg.CLEAR_PENDING_UPDATES}}},selectors:{hasPendingDeletion:function(e,t){return e.pendingDeletions.hasOwnProperty(t)},pendingDeletions:function(e){return e.pendingDeletions},pendingUpdates:function(e){return e.pendingUpdates},pendingUpdateCount:Qg}});const tv={annotation:"Location",note:"Oldest",orphan:"Location"};function nv(e){const t={};return e.annotations&&!e.query&&(t[e.annotations]=!0),t}const rv=(e,t)=>t===e?{}:{selectedTab:e,sortKey:tv[e]},ov={CLEAR_SELECTION:function(){return{forcedVisible:{},selected:{}}},SELECT_ANNOTATIONS:function(e,t){return{selected:t.selection}},SELECT_TAB:function(e,t){return rv(t.tab,e.selectedTab)},SET_EXPANDED:function(e,t){const n={...e.expanded}
644
+ ;return n[t.id]=t.expanded,{expanded:n}},SET_FORCED_VISIBLE:function(e,t){return{forcedVisible:{...e.forcedVisible,[t.id]:t.visible}}},SET_SORT_KEY:function(e,t){return{sortKey:t.key}},TOGGLE_SELECTED_ANNOTATIONS:function(e,t){const n={...e.selected};return t.toggleIds.forEach((e=>{n[e]=!n[e]})),{selected:n}},ADD_ANNOTATIONS(e,t){const n=t.annotations.filter((e=>!ki(e))),r=Hf(t.annotations,Mi)===n.length;return 0===t.currentAnnotationCount&&r?rv("note",e.selectedTab):{}},CHANGE_FOCUS_MODE_USER:function(){return{forcedVisible:{},selected:{}}},SET_FILTER:function(){return{forcedVisible:{},selected:{},expanded:{}}},SET_FILTER_QUERY:function(){return{forcedVisible:{},selected:{},expanded:{}}},SET_FOCUS_MODE:function(){return{forcedVisible:{},selected:{}}},REMOVE_ANNOTATIONS:function(e,t){let n=e.selectedTab;"orphan"===n&&0===Hf(t.remainingAnnotations,Li)&&(n="annotation");const r=e=>(t.annotationsToRemove.forEach((t=>{t.id&&delete e[t.id],t.$tag&&delete e[t.$tag]})),e);return{...rv(n,e.selectedTab),expanded:r({
645
+ ...e.expanded}),forcedVisible:r({...e.forcedVisible}),selected:r({...e.selected})}}},iv=Xm(ov);function av(e){return e.expanded}const sv=jf((e=>e.forcedVisible),(e=>qf(e))),lv=jf((e=>e.selected),(e=>qf(e).length>0)),cv=jf((e=>e.selected),(e=>qf(e)));function uv(e){return e.selectedTab}const hv=jf((e=>e),(e=>({expanded:av(e),forcedVisible:sv(e),selected:cv(e),sortKey:dv(e),selectedTab:uv(e)})));function dv(e){return e.sortKey}const pv=jf((e=>e.selectedTab),(e=>{const t=["Newest","Oldest"];return"note"!==e&&t.push("Location"),t}));var mv=Mf((function(e){return{selected:nv(e),expanded:nv(e)||{},forcedVisible:{},selectedTab:"annotation",sortKey:tv.annotation}}),{namespace:"selection",reducers:ov,actionCreators:{clearSelection:function(){return{type:iv.CLEAR_SELECTION}},selectAnnotations:function(e){return t=>{t({type:iv.CLEAR_SELECTION}),t({type:iv.SELECT_ANNOTATIONS,selection:Uf(e)})}},selectTab:function(e){return{type:iv.SELECT_TAB,tab:e}},setExpanded:function(e,t){return{type:iv.SET_EXPANDED,id:e,expanded:t}},
646
+ setForcedVisible:function(e,t){return{type:iv.SET_FORCED_VISIBLE,id:e,visible:t}},setSortKey:function(e){return{type:iv.SET_SORT_KEY,key:e}},toggleSelectedAnnotations:function(e){return{type:iv.TOGGLE_SELECTED_ANNOTATIONS,toggleIds:e}}},selectors:{expandedMap:av,forcedVisibleThreads:sv,hasSelectedAnnotations:lv,selectedAnnotations:cv,selectedTab:uv,selectionState:hv,sortKey:dv,sortKeys:pv}});const fv={OPEN_SIDEBAR_PANEL:function(e,t){return{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}}},gv=Xm(fv);var vv=Mf({activePanelName:null},{namespace:"sidebarPanels",reducers:fv,actionCreators:{openSidebarPanel:function(e){return{type:gv.OPEN_SIDEBAR_PANEL,panelName:e}},closeSidebarPanel:function(e){return{type:gv.CLOSE_SIDEBAR_PANEL,
647
+ panelName:e}},toggleSidebarPanel:function(e,t){return{type:gv.TOGGLE_SIDEBAR_PANEL,panelName:e,panelState:t}}},selectors:{isSidebarPanelOpen:function(e,t){return e.activePanelName===t}}});const yv={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{messages:e.messages.map((e=>e.id&&e.id===t.message.id?{...t.message}:e))}}},_v=Xm(yv);var bv=Mf({messages:[]},{namespace:"toastMessages",reducers:yv,actionCreators:{addToastMessage:function(e){return{type:_v.ADD_MESSAGE,message:e}},removeToastMessage:function(e){return{type:_v.REMOVE_MESSAGE,id:e}},updateToastMessage:function(e){return{type:_v.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 wv={
648
+ SET_SIDEBAR_OPENED:(e,t)=>!0===t.opened?{sidebarHasOpened:!0}:{}},xv=Xm(wv);var kv=Mf({sidebarHasOpened:!1},{namespace:"viewer",reducers:wv,actionCreators:{setSidebarOpened:function(e){return{type:xv.SET_SIDEBAR_OPENED,opened:e}}},selectors:{hasSidebarOpened:function(e){return e.sidebarHasOpened}}});function Sv(e){return Lf([Rf,sg,ug,pg,wg,Ng,Ig,Xg,Wg,ev,Vf,mv,Bg,vv,bv,kv],[e],[zf])}Sv.$inject=["settings"];class Cv{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){
649
+ 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)}(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 Av=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),Ev=function(e){const{version:t,origin:n}=R(e.location.href)
650
+ ;return"1.974.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.974.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 Tv(e,t){e.setClientId(t.clientId)}function Nv(e,t,n){e.load(),t.load(),n.sync()}function Lv(e,t,n,r){e.init(),t.init(),n.init(),r.init()}function Mv(e,t){"sidebar"===t.route()&&e.connect()}Av.sentry&&Ev&&function(e){const t=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;wr({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.974.0",beforeSend:(e,t)=>{if(Sr>=5)return K("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Sr;try{
651
+ 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{Yt("host_config",R(window.location.href))}catch(e){}Yt("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),kr(((e,t)=>{Wt(e,{tags:{context:t}})}))}(Av.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)}}}(),Tv.$inject=["api","streamer"],Nv.$inject=["groups","session","router"],Lv.$inject=["autosaveService","features","persistedDefaults","serviceURL"],Mv.$inject=["frameSync","store"],function(e,{reset:t=!1}={}){t&&mo.clear()
652
+ ;for(let[t,n]of Object.entries(e))mo.set(t,n)}(Ko);const zv=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++){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")}(Av).then((e=>{!function(e,t){const n=new Cv
653
+ ;n.register("annotationsService",Cm).register("api",Lm).register("apiRoutes",Dm).register("auth",jm).register("autosaveService",Hm).register("features",$m).register("frameSync",Km).register("groups",Qm).register("loadAnnotationsService",ef).register("localStorage",nf).register("persistedDefaults",of).register("router",af).register("serviceURL",sf).register("session",lf).register("streamer",hf).register("streamFilter",cf).register("tags",df).register("threadsService",pf).register("toastMessenger",mf).register("store",{factory:Sv}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(Lv),n.run(Tv),n.run(Nv),n.run(ee),n.run(Mv),I(po(ni.Provider,{value:n,children:po(km,{})}),t)}(e,zv)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),I(po(Sm,{error:e}),t)}(e,zv)));
655
654
  //# sourceMappingURL=sidebar.bundle.js.map