This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/assets/index.baaa0776.js

22 lines
471 KiB
JavaScript
Raw Normal View History

2022-08-16 17:11:00 +05:30
var la=Object.defineProperty,ha=Object.defineProperties;var da=Object.getOwnPropertyDescriptors;var cs=Object.getOwnPropertySymbols;var fr=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable;var _r=(n,e,t)=>e in n?la(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ft=(n,e)=>{for(var t in e||(e={}))fr.call(e,t)&&_r(n,t,e[t]);if(cs)for(var t of cs(e))gr.call(e,t)&&_r(n,t,e[t]);return n},yr=(n,e)=>ha(n,da(e));var wr=(n,e)=>{var t={};for(var s in n)fr.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&cs)for(var s of cs(n))e.indexOf(s)<0&&gr.call(n,s)&&(t[s]=n[s]);return t};function xe(...n){const e={};for(const t of n)e[t]=t;return Object.freeze(e)}function vr(n){try{return new URL(n).origin}catch{return new URL(`https://${n}`).origin}}async function ua(n,e){const t={format:"json",timeout:3e4,method:"GET"};try{const s=`${n}/.well-known/matrix/client`;return await e(s,t).response()}catch(s){if(s.name==="ConnectionError")return null;throw s}}async function ma(n,e){var s;n=vr(n);const t=await ua(n,e);if(t&&t.status===200){const{body:i}=t,r=(s=i["m.homeserver"])==null?void 0:s.base_url;typeof r=="string"&&(n=vr(r))}return n}class ye extends Error{get name(){return"AbortError"}}class Ii{constructor(){this._handlers=new Set}onSubscribeFirst(){}onUnsubscribeLast(){}subscribe(e){return this._handlers.add(e),this._handlers.size===1&&this.onSubscribeFirst(),()=>this.unsubscribe(e)}unsubscribe(e){e&&(this._handlers.delete(e),this._handlers.size===0&&this.onUnsubscribeLast())}unsubscribeAll(){this._handlers.size!==0&&(this._handlers.clear(),this.onUnsubscribeLast())}get hasSubscriptions(){return this._handlers.size!==0}}class kt extends Ii{emit(e){for(const t of this._handlers)t(e)}waitFor(e){return e(this.get())?new _a(Promise.resolve(this.get())):new pa(this,e)}flatMap(e){return new fa(this,e)}}class pa{constructor(e,t){this._promise=new Promise((s,i)=>{this._reject=i,this._subscription=e.subscribe(r=>{t(r)&&(this._reject=null,s(r),this.dispose())})})}get promise(){return this._promise}dispose(){this._subscription&&(this._subscription(),this._subscription=null),this._reject&&(this._reject(new ye),this._reject=null)}}class _a{constructor(e){this.promise=e}dispose(){}}class we extends kt{constructor(e){super(),this._value=e}get(){return this._value}set(e){e!==this._value&&(this._value=e,this.emit(this._value))}}class ci extends we{constructor(e,t){super(e),this._freeCallback=t}onUnsubscribeLast(){super.onUnsubscribeLast(),this._freeCallback()}}class fa extends kt{constructor(e,t){super(),this.source=e,this.mapper=t}onUnsubscribeLast(){super.onUnsubscribeLast(),this.sourceSubscription=this.sourceSubscription(),this.targetSubscription&&(this.targetSubscription=this.targetSubscription())}onSubscribeFirst(){super.onSubscribeFirst(),this.sourceSubscription=this.source.subscribe(()=>{this.updateTargetSubscription(),this.emit(this.get())}),this.updateTargetSubscription()}updateTargetSubscription(){const e=this.source.get();if(e){const t=this.mapper(e);if(t){this.targetSubscription||(this.targetSubscription=t.subscribe(()=>this.emit(this.get())));return}}this.targetSubscription&&(this.targetSubscription=this.targetSubscription())}get(){const e=this.source.get();if(!e)return;const t=this.mapper(e);return t==null?void 0:t.get()}}class Mn{constructor(e){this._abortable=void 0;const t=i=>(this._abortable=i,i);this._progress=new we(void 0);const s=i=>{this._progress.set(i)};this.result=e(t,s)}get progress(){return this._progress}abort(){var e;(e=this._abortable)==null||e.abort(),this._abortable=void 0}}const ga={"image/jpeg":!0,"image/gif":!0,"image/png":!0,"video/mp4":!0,"video/webm":!0,"video/ogg":!0,"video/quicktime":!0,"video/VP8":!0,"audio/mp4":!0,"audio/webm":!0,"audio/aac":!0,"audio/mpeg":!0,"audio/ogg":!0,"audio/wave":!0,"audio/wav":!0,"audio/x-wav":!0,"audio/x-pn-wav":!0,"audio/flac":!0,"audio/x-flac":!0},br="application/octet-stream";class lt{constructor(e,t=null){this._blob=e,this._buffer=t,this._url=null}static fromBuffer(e,t){return t=t?t.split(";")[0].trim():"",ga[t]||(t=br),new lt(new Blob([e],{t
`]="\\n";Ne["\f"]="\\f";Ne["\r"]="\\r";Ne['"']='\\"';Ne["\\"]="\\\\";function Ln(n){return Er.lastIndex=0,n.replace(Er,function(e){return Ne[e]})}function Ei(n){switch(typeof n){case"string":return'"'+Ln(n)+'"';case"number":return isFinite(n)?n:"null";case"boolean":return n;case"object":return n===null?"null":Array.isArray(n)?Da(n):Va(n);default:throw new Error("Cannot stringify: "+typeof n)}}function Da(n){for(var e="[",t="",s=0;s<n.length;++s)t+=e,e=",",t+=Ei(n[s]);return e!=","?"[]":t+"]"}function Va(n){var e="{",t="",s=Object.keys(n);s.sort();for(var i=0;i<s.length;++i){var r=s[i];t+=e+'"'+Ln(r)+'":',e=",",t+=Ei(n[r])}return e!=","?"{}":t+"}"}var On={stringify:Ei};const st=xe("Sync","Timeline","Retry"),ie="e2ee:",ki="m.olm.v1.curve25519-aes-sha2",ve="m.megolm.v1.aes-sha2";class z extends Error{constructor(e,t,s=null){super(`Decryption error ${e}${s?": "+JSON.stringify(s):""}`),this.code=e,this.event=t,this.details=s}}const Pn="ed25519";function Un(n,e,t,s,i,r=void 0){var l,h;const o=Object.assign({},i);delete o.unsigned,delete o.signatures;const a=On.stringify(o),c=(h=(l=i==null?void 0:i.signatures)==null?void 0:l[e])==null?void 0:h[`${Pn}:${t}`];try{if(!c)throw new Error("no signature");return n.ed25519_verify(s,a,c),!0}catch(d){if(r){const u=r.log({l:"Invalid signature, ignoring.",ed25519Key:s,canonicalJson:a,signature:c});u.error=d,u.logLevel=r.level.Warn}return!1}}function La(){return{type:"m.room.encryption",state_key:"",content:{algorithm:ve,rotation_period_ms:6048e5,rotation_period_msgs:100}}}const ds=Object.freeze({Joined:"joined",Invited:"invited",WorldReadable:"world_readable",Shared:"shared"});function us(n,e){switch(e){case ds.WorldReadable:return!0;case ds.Shared:return n!==void 0;case ds.Joined:return n==="join";case ds.Invited:return n==="invite"||n==="join";default:return!1}}function Oa(n,e,t,s,i){return e.length&&(n=e.reduce((r,o)=>Ba(r,o,t,s,i),n)),n}function Fn(n,e,t){var r,o;const s=(r=n==null?void 0:n.state)==null?void 0:r.events;Array.isArray(s)&&(t=s.reduce(e,t));const i=(o=n==null?void 0:n.timeline)==null?void 0:o.events;return Array.isArray(i)&&(t=i.reduce((a,c)=>(typeof c.state_key=="string"&&(t=e(t,c)),t),t)),t}function Pa(n,e,t,s){e.summary&&(n=Ka(n,e.summary)),t!==n.membership&&(n=n.cloneIfNeeded(),n.membership=t),e.account_data&&(n=e.account_data.events.reduce(Fa,n)),n=Fn(e,(r,o)=>Bn(r,o,s),n);const i=e.unread_notifications;return i&&(n=Ua(n,i)),n}function Ua(n,e){const t=e.highlight_count||0;t!==n.highlightCount&&(n=n.cloneIfNeeded(),n.highlightCount=t);const s=e.notification_count;return s!==n.notificationCount&&(n=n.cloneIfNeeded(),n.notificationCount=s),n}function Fa(n,e){var t;if((e==null?void 0:e.type)==="m.tag"){let s=(t=e==null?void 0:e.content)==null?void 0:t.tags;(!s||Array.isArray(s)||typeof s!="object")&&(s=null),n=n.cloneIfNeeded(),n.tags=s}return n}function Bn(n,e,t){var s,i,r;if(e.type==="m.room.create")n=n.cloneIfNeeded(),n.lastMessageTimestamp=e.origin_server_ts;else if(e.type==="m.room.encryption"){const o=(s=e.content)==null?void 0:s.algorithm;!n.encryption&&o===ve&&(n=n.cloneIfNeeded(),n.encryption=e.content)}else if(e.type==="m.room.name"){const o=(i=e.content)==null?void 0:i.name;o!==n.name&&(n=n.cloneIfNeeded(),n.name=o)}else if(e.type==="m.room.avatar"){const o=(r=e.content)==null?void 0:r.url;o!==n.avatarUrl&&(n=n.cloneIfNeeded(),n.avatarUrl=o)}else if(e.type==="m.room.canonical_alias"){const o=e.content;n=n.cloneIfNeeded(),n.canonicalAlias=o.alias}else if(e.type==="m.room.member"){const o=e.content;if(o.is_direct===!0&&o.membership==="invite"&&!n.isDirectMessage){let a;e.sender===t?a=e.state_key:e.state_key===t&&(a=e.sender),a&&(n=n.cloneIfNeeded(),n.isDirectMessage=!0,n.dmUserId=a)}else o.membership==="leave"&&n.isDirectMessage&&n.dmUserId===e.state_key&&(n=n.cloneIfNeeded(),n.isDirectMessage=!1,n.dmUserId=null)}return n}function Ba(n,e,t,s,i){return e.eventType==="m.room.message"&&((!n.lastMessageTimestamp||e.timestamp>n.lastMessageTimestamp)&&(n=n.cloneIfNeeded(),n.lastMessageTimestamp=e.timestamp),!t&&e.sender!==i&&s&&(n=n.cloneIfNeeded(),n.isUnread=!0)),n}
`);h[0]=`> ${i}<${r}> ${h[0]}`;const u=h.join(`
> `)+`
`+t,p=c+kr(t);return Qa(n.id,e,u,p)}class jn extends Kn{constructor(e){super(e),this._pendingRedactions=null,this._pendingAnnotations=null,this._contextEntry=null,this._contextForEntries=null}get isReply(){var e;return!!((e=this.relation)!=null&&e["m.in_reply_to"])}get isRedacting(){return!!this._pendingRedactions}get isRedacted(){return this.isRedacting}get isRedaction(){return this.eventType===ge}get redactionReason(){var e;return this._pendingRedactions?(e=this._pendingRedactions[0].content)==null?void 0:e.reason:null}setContextEntry(e){this._contextEntry=e,e._setAsContextOf(this)}_setAsContextOf(e){this._contextForEntries||(this._contextForEntries=[]),this._contextForEntries.push(e)}get contextForEntries(){return this._contextForEntries}get contextEntry(){return this._contextEntry}addLocalRelation(e){if(e.eventType===ge&&e.isRelatedToId(this.id)){if(this._pendingRedactions||(this._pendingRedactions=[]),this._pendingRedactions.push(e),this._pendingRedactions.length===1)return"isRedacted"}else{const t=e.redactingEntry||e;if(t.isRelatedToId(this.id)&&t.relation.rel_type===We&&this._addPendingAnnotation(e))return"pendingAnnotations"}}removeLocalRelation(e){var t;if(e.eventType===ge&&e.isRelatedToId(this.id)&&this._pendingRedactions){const s=this._pendingRedactions.length;if(this._pendingRedactions=this._pendingRedactions.filter(i=>i!==e),this._pendingRedactions.length===0&&(this._pendingRedactions=null,s!==0))return"isRedacted"}else{const s=e.redactingEntry||e;if(s.isRelatedToId(this.id)&&((t=s.relation)==null?void 0:t.rel_type)===We&&this._pendingAnnotations&&this._removePendingAnnotation(e))return"pendingAnnotations"}}_addPendingAnnotation(e){this._pendingAnnotations||(this._pendingAnnotations=new Map);const{key:t}=(e.redactingEntry||e).relation;if(t){let s=this._pendingAnnotations.get(t);return s||(s=new za,this._pendingAnnotations.set(t,s)),s.add(e),!0}return!1}_removePendingAnnotation(e){const{key:t}=(e.redactingEntry||e).relation;if(t){let s=this._pendingAnnotations.get(t);return s.remove(e)&&s.isEmpty&&this._pendingAnnotations.delete(t),this._pendingAnnotations.size===0&&(this._pendingAnnotations=null),!0}return!1}async abortPendingRedaction(){if(this._pendingRedactions)for(const e of this._pendingRedactions)await e.pendingEvent.abort()}get pendingRedaction(){return this._pendingRedactions?this._pendingRedactions[0]:null}annotate(e){return Wa(this.id,e)}reply(e,t){return Ya(this,e,t)}isRelatedToId(e){return e&&this.relatedEventId===e}haveAnnotation(e){var r,o,a;const t=((o=(r=this.annotations)==null?void 0:r[e])==null?void 0:o.me)||!1,s=(a=this.pendingAnnotations)==null?void 0:a.get(e),i=(s==null?void 0:s.willAnnotate)||!1;return t&&(!s||i)||!t&&i}get relation(){return ze(this.content)}get pendingAnnotations(){return this._pendingAnnotations}get annotations(){return null}}class Xa extends jn{constructor({pendingEvent:e,member:t,clock:s,redactingEntry:i}){super(null),this._pendingEvent=e,this._member=t,this._timestamp=s.now()-(100-e.queueIndex),this._redactingEntry=i}get fragmentId(){return li}get entryIndex(){return this._pendingEvent.queueIndex}get content(){return this._pendingEvent.content}get event(){return null}get eventType(){return this._pendingEvent.eventType}get stateKey(){return null}get sender(){var e;return(e=this._member)==null?void 0:e.userId}get displayName(){var e;return(e=this._member)==null?void 0:e.name}get avatarUrl(){var e;return(e=this._member)==null?void 0:e.avatarUrl}get timestamp(){return this._timestamp}get isPending(){return!0}get id(){return this._pendingEvent.txnId}get pendingEvent(){return this._pendingEvent}notifyUpdate(){}isRelatedToId(e){return e&&e===this._pendingEvent.relatedTxnId?!0:super.isRelatedToId(e)}get relatedEventId(){return this._pendingEvent.relatedEventId}get redactingEntry(){return this._redactingEntry}get contextEventId(){var e;return this.isReply?(e=this._pendingEvent.relatedEventId)!=null?e:this._pendingEvent.relatedTxnId:null}}const V=xe("Waiting","EncryptingAttachments","UploadingAttachments","Encrypting","Sending","Sent","Error"),Rr=["m.relates_to"];class Za{c
* @license
* Based off baseSortedIndex function in Lodash <https://lodash.com/>
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/function He(n,e,t){let s=0,i=n.length;for(;s<i;){let r=s+i>>>1,o=t(e,n[r]);o>0?s=r+1:o<0?i=r:s=i=r}return i}class Ct extends Ii{emitReset(){for(let e of this._handlers)e.onReset()}emitAdd(e,t){for(let s of this._handlers)s.onAdd(e,t)}emitUpdate(e,t,s){for(let i of this._handlers)i.onUpdate(e,t,s)}emitRemove(e,t){for(let s of this._handlers)s.onRemove(e,t)}}class qt extends Ct{constructor(e){super(),this._values=new Map(e)}update(e,t){const s=this._values.get(e);return s!==void 0?(this._values.set(e,s),this.emitUpdate(e,s,t),!0):!1}add(e,t){return this._values.has(e)?!1:(this._values.set(e,t),this.emitAdd(e,t),!0)}remove(e){const t=this._values.get(e);return t!==void 0?(this._values.delete(e),this.emitRemove(e,t),!0):!1}set(e,t){return this._values.has(e)?(this._values.set(e,t),this.update(e,void 0)):this.add(e,t)}reset(){this._values.clear(),this.emitReset()}get(e){return this._values.get(e)}get size(){return this._values.size}[Symbol.iterator](){return this._values.entries()}values(){return this._values.values()}keys(){return this._values.keys()}}class fl extends Rt{constructor(e,t){super(),this._sourceMap=e,this._comparator=(s,i)=>t(s.value,i.value),this._sortedPairs=null,this._mapSubscription=null}onAdd(e,t){const s={key:e,value:t},i=He(this._sortedPairs,s,this._comparator);this._sortedPairs.splice(i,0,s),this.emitAdd(i,t)}onRemove(e,t){const s={key:e,value:t},i=He(this._sortedPairs,s,this._comparator);this._sortedPairs.splice(i,1),this.emitRemove(i,t)}onUpdate(e,t,s){if(!this._sortedPairs)return;const i=this._sortedPairs.findIndex(a=>a.key===e);this._sortedPairs.splice(i,1);const r={key:e,value:t},o=He(this._sortedPairs,r,this._comparator);this._sortedPairs.splice(o,0,r),i!==o&&this.emitMove(i,o,t),this.emitUpdate(o,t,s)}onReset(){this._sortedPairs=[],this.emitReset()}onSubscribeFirst(){this._mapSubscription=this._sourceMap.subscribe(this),this._sortedPairs=new Array(this._sourceMap.size);let e=0;for(let[t,s]of this._sourceMap)this._sortedPairs[e]={key:t,value:s},++e;this._sortedPairs.sort(this._comparator),super.onSubscribeFirst()}onUnsubscribeLast(){super.onUnsubscribeLast(),this._sortedPairs=null,this._mapSubscription=this._mapSubscription()}get(e){return this._sortedPairs[e].value}get length(){return this._sourceMap.size}[Symbol.iterator](){const e=this._sortedPairs.values();return{next(){const t=e.next();return t.value&&(t.value=t.value.value),t}}}}class gl extends Ct{constructor(e,t){super(),this._source=e,this._filter=t,this._included=null,this._subscription=null}setFilter(e){this._filter=e,this._subscription&&this._reapplyFilter()}_reapplyFilter(e=!1){if(this._filter){const t=this._included;this._included=this._included||new Map;for(const[s,i]of this._source){const r=this._filter(i,s);if(this._included.set(s,r),!e){const o=t?t.get(s):!0;this._emitForUpdate(o,r,s,i)}}}else{if(this._included&&!e)for(const[t,s]of this._source)this._included.get(t)||this.emitAdd(t,s);this._included=null}}onAdd(e,t){if(this._filter){const s=this._filter(t,e);if(this._included.set(e,s),!s)return}this.emitAdd(e,t)}onRemove(e,t){const s=!this._filter||this._included.get(e);this._included.delete(e),s&&this.emitRemove(e,t)}onUpdate(e,t,s){if(!!this._included)if(this._filter){const i=this._included.get(e),r=this._filter(t,e);this._included.set(e,r),this._emitForUpdate(i,r,e,t,s)}else this.emitUpdate(e,t,s)}_emitForUpdate(e,t,s,i,r=null){e&&!t?this.emitRemove(s,i):!e&&t?this.emitAdd(s,i):e&&t&&this.emitUpdate(s,i,r)}onSubscribeFirst(){this._subscription=this._source.subscribe(this),this._reapplyFilter(!0),super.onSubscribeFirst()}onUnsubscribeLast(){super.onUnsubscribeLast(),this._included=null,this._subscription=this._subscription()}onReset(){this._reapplyFilter(),this.emitReset()}[Symbol.iterator](){return new yl(this._source,this._included)}get size(){let e=0;return this._included.forEach(t=>{t&&(e+=1)}),e}get(e){const t=this._source.get(e);if(t&&this._filter(t,e))return t}}class yl{constructor(e,t){this._included=t,this._sourceIterator=e[Symbol.iterator]()}next(){for(;;){const e=this._sourceIterator.next();if(e.done)return e;cons
`)[0]}),s&&(r.f=!0),i&&(r.c=i),r}run(e){this.end!==void 0&&console.trace("log item is finished, additional logs will likely not be recorded");try{const t=e(this);return t instanceof Promise?t.then(s=>(this.finish(),s),s=>{throw this.catch(s)}):(this.finish(),t)}catch(t){throw this.catch(t)}}finish(){if(this.end===void 0){if(this._children)for(const e of this._children)e.finish();this.end=this._logger._now()}}get level(){return _e}catch(e){return this.error=e,this.logLevel=_e.Error,this.finish(),e}child(e,t,s){this.end&&console.trace("log item is finished, additional logs will likely not be recorded"),t||(t=this.logLevel||_e.Info);const i=new Wt(e,t,this._logger,s);return this._children||(this._children=[]),this._children.push(i),i}get logger(){return this._logger}get values(){return this._values}get children(){return this._children}}class go{constructor({platform:e,serializedTransformer:t=s=>s}){this._openItems=new Set,this._platform=e,this._serializedTransformer=t}log(e,t=_e.Info){const s=new Wt(e,t,this);s.end=s.start,this._persistItem(s,void 0,!1)}wrapOrRun(e,t,s,i,r){return e?e.wrap(t,s,i,r):this.run(t,s,i,r)}runDetached(e,t,s,i){s||(s=_e.Info);const r=new Wt(e,s,this);return this._run(r,t,s,!1,i),r}run(e,t,s,i){s===void 0&&(s=_e.Info);const r=new Wt(e,s,this);return this._run(r,t,s,!0,i)}_run(e,t,s,i,r){this._openItems.add(e);const o=()=>{let a=new mi;if(r)try{a=r(a,e)}catch(c){console.error("Error while creating log filter",c)}else a=a.minLevel(s);try{this._persistItem(e,a,!1)}catch(c){console.error("Could not persist log item",c)}this._openItems.delete(e)};try{let a=e.run(t);if(a instanceof Promise){if(a=a.then(c=>(o(),c),c=>{if(o(),i)throw c}),i)return a}else if(o(),i)return a}catch(a){if(o(),i)throw a}}_finishOpenItems(){for(const e of this._openItems){e.finish();try{this._persistItem(e,new mi,!0)}catch(t){console.error("Could not serialize log item",t)}}this._openItems.clear()}get level(){return _e}_now(){return this._platform.clock.now()}_createRefId(){return Math.round(this._platform.random()*Number.MAX_SAFE_INTEGER)}}class td extends go{_persistItem(e){yo(e)}async export(){}}const sd=["l","id"];function id(n){return Object.entries(n).filter(([e])=>!sd.includes(e)).reduce((e,[t,s])=>(e=e||{},e[t]=s,e),null)}function yo(n){const e=`${rd(n)} (${n.duration}ms)`,t=id(n.values),s=n.children||t;if(s?(n.error?console.group(e):console.groupCollapsed(e),n.error&&console.error(n.error)):n.error?console.error(n.error):console.log(e),t&&console.table(t),n.children)for(const i of n.children)yo(i);s&&console.groupEnd()}function rd(n){return n.values.t==="network"?`${n.values.method} ${n.values.url}`:n.values.l&&typeof n.values.id!="undefined"?`${n.values.l} ${n.values.id}`:n.values.l&&typeof n.values.status!="undefined"?`${n.values.l} (${n.values.status})`:n.values.l&&n.error?`${n.values.l} failed`:typeof n.values.ref!="undefined"?`ref ${n.values.ref}`:n.values.l||n.values.type}const zr="m.room.encrypted",Gr="m.room.history_visibility",nd=60*1e3;class od{constructor({room:e,deviceTracker:t,olmEncryption:s,megolmEncryption:i,megolmDecryption:r,encryptionParams:o,storage:a,keyBackup:c,notifyMissingMegolmSession:l,clock:h}){this._room=e,this._deviceTracker=t,this._olmEncryption=s,this._megolmEncryption=i,this._megolmDecryption=r,this._encryptionParams=o,this._senderDeviceCache=new Map,this._storage=a,this._keyBackup=c,this._notifyMissingMegolmSession=l,this._clock=h,this._isFlushingRoomKeyShares=!1,this._lastKeyPreShareTime=null,this._keySharePromise=null,this._historyVisibility=void 0,this._disposed=!1}enableKeyBackup(e){this._keyBackup&&!!e||(this._keyBackup=e)}async restoreMissingSessionsFromBackup(e,t){const s=e.filter(h=>h.isEncrypted&&!h.isDecrypted&&h.event).map(h=>h.event),i=gi(s),r=Array.from(i.values()),o=await this._storage.readTxn([this._storage.storeNames.inboundGroupSessions]),a=await Promise.all(r.map(async h=>this._megolmDecryption.hasSession(this._room.id,h.senderKey,h.sessionId,o))),c=r.filter((h,d)=>!a[d]);if(c.length)for(var l=c.length-1;l>=0;l--){const h=c[l];await t.wrap("session",d=>this._requestMissin
${e.stack}`),this._error=e,this.emitChange("error"),e}finally{this._loading=!1,this.emitChange("isLoading")}return!0}return!1}async notifyVisible(){let e=0,t;this._siblingChanged=!1;do t=await this.fill(),e=e+1;while(e<10&&!this._siblingChanged&&t&&!this.isDisposed)}get isAtTop(){return this._isAtTop}updatePreviousSibling(e){super.updatePreviousSibling(e);const t=!e;this._isAtTop!==t&&(this._isAtTop=t,this.emitChange("isAtTop")),this._siblingChanged=!0}updateNextSibling(){this._siblingChanged=!0}updateEntry(e,t){return super.updateEntry(e,t),e.isGap?fe.Nothing():fe.Remove()}get shape(){return"gap"}get isLoading(){return this._loading}get error(){return this._error?`Could not load ${this._entry.prev_batch?"previous":"next"} messages: ${this._error.message}`:null}}class Wd{constructor(e){this._parentTile=e,this._map=new qt,this._reactions=this._map.sortValues((t,s)=>t._compare(s))}update(e,t){if(e){for(const s in e)if(e.hasOwnProperty(s)){const i=e[s],r=this._map.get(s);r?r._tryUpdate(i)&&this._map.update(s):this._map.add(s,new Xr(s,i,null,this._parentTile))}}if(t)for(const[s,i]of t.entries()){const r=this._map.get(s);r?(r._tryUpdatePending(i),this._map.update(s)):this._map.add(s,new Xr(s,null,i,this._parentTile))}for(const s of this._map.keys()){const i=t==null?void 0:t.has(s),r=e==null?void 0:e.hasOwnProperty(s);!r&&!i?this._map.remove(s):r?i||this._map.get(s)._tryUpdatePending(null)&&this._map.update(s):this._map.get(s)._tryUpdate(null)&&this._map.update(s)}}get reactions(){return this._reactions}getReaction(e){return this._map.get(e)}}class Xr{constructor(e,t,s,i){this._key=e,this._annotation=t,this._pending=s,this._parentTile=i,this._isToggling=!1}_tryUpdate(e){const t=!!this._annotation!=!!e,i=this._annotation&&e&&(e.me!==this._annotation.me||e.count!==this._annotation.count||e.firstTimestamp!==this._annotation.firstTimestamp);return t||i?(this._annotation=e,!0):!1}_tryUpdatePending(e){return!e&&!this._pending?!1:(this._pending=e,!0)}get key(){return this._key}get count(){var e,t;return(((e=this._pending)==null?void 0:e.count)||0)+(((t=this._annotation)==null?void 0:t.count)||0)}get isPending(){return this._pending!==null}get isActive(){var e;return((e=this._annotation)==null?void 0:e.me)||this.isPending}get firstTimestamp(){let e=Number.MAX_SAFE_INTEGER;return this._annotation&&(e=Math.min(e,this._annotation.firstTimestamp)),this._pending&&(e=Math.min(e,this._pending.firstTimestamp)),e}_compare(e){if(e===this)return 0;if(this.count!==e.count)return e.count-this.count;{const t=this.firstTimestamp-e.firstTimestamp;return t===0?this.key<e.key?-1:1:t}}async toggle(e=null){if(this._isToggling){console.log("busy toggling reaction already");return}this._isToggling=!0;try{await this._parentTile.toggleReaction(this.key,e)}finally{this._isToggling=!1}}}class Je extends ss{constructor(e,t){super(e,t),this._date=this._entry.timestamp?new Date(this._entry.timestamp):null,this._isContinuation=!1,this._reactions=null,this._replyTile=null,(this._entry.annotations||this._entry.pendingAnnotations)&&this._updateReactions(),this._updateReplyTileIfNeeded(void 0)}notifyVisible(){var e;super.notifyVisible(),(e=this._replyTile)==null||e.notifyVisible()}get _mediaRepository(){return this._room.mediaRepository}get permaLink(){return`https://matrix.to/#/${encodeURIComponent(this._room.id)}/${encodeURIComponent(this._entry.id)}`}get senderProfileLink(){return`https://matrix.to/#/${encodeURIComponent(this.sender)}`}get displayName(){return this._entry.displayName||this.sender}get sender(){return this._entry.sender}get memberPanelLink(){return`${this.urlCreator.urlUntilSegment("room")}/member/${this.sender}`}get avatarColorNumber(){return de(this._entry.sender)}avatarUrl(e){return De(this._entry.avatarUrl,e,this.platform,this._mediaRepository)}get avatarLetter(){return he(this.sender)}get avatarTitle(){return this.displayName}get date(){return this._date&&this._date.toLocaleDateString({},{month:"numeric",day:"numeric"})}get time(){return this._date&&this._date.toLocaleTimeString({},{hour:"numeric",minute:"2-digit"})}get isOwn(){return this._ent
`),s=(i,r)=>{r?e.push(new bi(i,[new St(i)])):e.push(new St(i))};for(let i=0;i<t.length;i+=1){const r=t[i];r.length&&vo(r,s),i>=t.length-1||e.push(new bo)}return new Wi(n,e)}function Xd(n){return new Wi(n,[new St(n)])}class Zd{constructor(e,t){this.level=e,this.inlines=t}get type(){return"header"}}class en{constructor(e,t){this.language=e,this.text=t}get type(){return"codeblock"}}class eu{constructor(e,t){this.items=t,this.startOffset=e}get type(){return"list"}}class tu{constructor(e,t){this.head=e,this.body=t}get type(){return"table"}}class su{get type(){return"rule"}}class bo{get type(){return"newline"}}class ws{constructor(e,t){this.format=e.toLowerCase(),this.children=t}get type(){return"format"}}class iu{constructor(e,t,s,i,r){this.src=e,this.width=t,this.height=s,this.alt=i,this.title=r}get type(){return"image"}}class ru{constructor(e,t,s){this.id=e,this.href=t,this.children=s}get type(){return"pill"}get avatarColorNumber(){return de(this.id)}get avatarInitials(){return he(this.id)}}class bi{constructor(e,t){this.url=e,this.inlines=t}get type(){return"link"}}class St{constructor(e){this.text=e}get type(){return"text"}}function nu(n){return n.type==="format"&&n.format==="blockquote"}class Wi{constructor(e,t){this.sourceString=e,this.parts=t}insertEmote(e){let t=0;for(;t<this.parts.length&&nu(this.parts[t]);t++);this.parts.splice(t,0,new St(e))}}const Bt=xe("Plain","Html");class So extends Je{constructor(e,t){super(e,t),this._messageBody=null,this._format=null}get shape(){return"message"}_parseBody(e){return Xd(e)}_getBodyFormat(){return Bt.Plain}get body(){const e=this._getBody(),t=this._getBodyFormat();return(!this._messageBody||this._messageBody.sourceString!==e||this._format!==t)&&(this._messageBody=this._parseBody(e,t),this._format=t),this._messageBody}}const ou=["EM","STRONG","CODE","DEL","SPAN"],au=["DIV","BLOCKQUOTE"],cu=["https","http","ftp","mailto","magnet"].map(n=>`${n}://`),lu="https://matrix.to",tn=`${lu}/#/`;class hu{constructor(e,t){this.result=e,this.mediaRepository=t}parsePillLink(e){if(!e.startsWith(tn))return null;const t=e.substring(tn.length);return t[0]==="@"?t:null}parseLink(e,t){const s=this.result.getAttributeValue(e,"href"),i=s==null?void 0:s.toLowerCase();if(!i||!cu.some(o=>i.startsWith(o)))return new ws("span",t);const r=this.parsePillLink(s);return r?new ru(r,s,t):new bi(s,t)}parseList(e){const t=this.result;let s=null;t.getNodeElementName(e)==="OL"&&(s=parseInt(t.getAttributeValue(e,"start"))||1);const i=[];for(const r of t.getChildNodes(e)){if(t.getNodeElementName(r)!=="LI")continue;const o=this.parseAnyNodes(t.getChildNodes(r));i.push(o)}return new eu(s,i)}_ensureElement(e,t){return e&&this.result.isElementNode(e)&&this.result.getNodeElementName(e)===t}parseCodeBlock(e){const t=this.result;let s;for(const o of t.getChildNodes(e)){s=o;break}let i=null;if(!this._ensureElement(s,"CODE"))return new en(i,this.result.getNodeText(e));const r=t.getAttributeValue(s,"class")||"";for(const o of r.split(" "))if(o.startsWith("language-")&&!o.startsWith("language-_")){i=o.substring(9);break}return new en(i,this.result.getNodeText(s))}parseImage(e){const t=this.result,s=t.getAttributeValue(e,"src")||"",i=this.mediaRepository.mxcUrl(s);if(!i)return null;const r=parseInt(t.getAttributeValue(e,"width"))||null,o=parseInt(t.getAttributeValue(e,"height"))||null,a=t.getAttributeValue(e,"alt"),c=t.getAttributeValue(e,"title");return new iu(i,r,o,a,c)}parseTableRow(e,t){const s=[];for(const i of this.result.getChildNodes(e)){if(!this._ensureElement(i,t))continue;const r=this.result.getChildNodes(i),o=this.parseInlineNodes(r);s.push(o)}return s}parseTableHead(e){let t=null;for(const s of this.result.getChildNodes(e)){t=s;break}return this._ensureElement(t,"TR")?this.parseTableRow(t,"TH"):null}parseTableBody(e){const t=[];for(const s of this.result.getChildNodes(e))!this._ensureElement(s,"TR")||t.push(this.parseTableRow(s,"TD"));return t}parseTable(e){const t=Array.from(this.result.getChildNodes(e));let s,i;return this._ensureElement(t[0],"THEAD")&&this._ensureElement(t[1],"TBODY")?(s=this.parseTableHead(t[0])
${e.stack}`),this._timelineError=e,this.emitChange("error")}this._clearUnreadAfterDelay()}async _recreateComposerOnPowerLevelChange(){const e=await this._room.observePowerLevels(),t=()=>e.get().canSendType("m.room.message");let s=t();const i=r=>{this._composerVM=this.disposeTracked(this._composerVM),r?this._composerVM=this.track(new jd(this)):this._composerVM=this.track(new Tu(this.childOptions())),this.emitChange("powerLevelObservable")};this.track(e.subscribe(()=>{const r=t();s!==r&&(i(r),s=r)})),i(s)}async _clearUnreadAfterDelay(){if(!(this._room.isArchived||this._clearUnreadTimout)){this._clearUnreadTimout=this.clock.createTimeout(2e3);try{await this._clearUnreadTimout.elapsed(),await this._room.clearUnread(),this._clearUnreadTimout=null}catch(e){if(e.name!=="AbortError")throw e}}}focus(){this._clearUnreadAfterDelay()}dispose(){super.dispose(),this._room.off("change",this._onRoomChange),this._room.isArchived&&this._room.release(),this._clearUnreadTimout&&(this._clearUnreadTimout.abort(),this._clearUnreadTimout=null)}_onRoomChange(){this._composerVM.emitChange(),this.emitChange()}get kind(){return"room"}get closeUrl(){return this._closeUrl}get name(){return this._room.name||this.i18n`Empty Room`}get id(){return this._room.id}get timelineViewModel(){return this._timelineVM}get isEncrypted(){return this._room.isEncrypted}get error(){return this._timelineError?`Something went wrong loading the timeline: ${this._timelineError.message}`:this._sendError?`Something went wrong sending your message: ${this._sendError.message}`:""}get avatarLetter(){return he(this.name)}get avatarColorNumber(){return de(this._room.avatarColorId)}avatarUrl(e){return De(this._room.avatarUrl,e,this.platform,this._room.mediaRepository)}get avatarTitle(){return this.name}get canLeave(){return this._room.isJoined}leaveRoom(){this._room.leave()}get canForget(){return this._room.isArchived}forgetRoom(){this._room.forget()}get canRejoin(){return this._room.isArchived}rejoinRoom(){this._room.join()}_createTile(e){if(this._tileOptions){const t=this._tileOptions.tileClassForEntry(e);if(t)return new t(e,this._tileOptions)}}async _processCommandJoin(e){var t,s,i,r;try{const o=await this._options.client.session.joinRoom(e);await(await this._options.client.session.observeRoomStatus(o)).waitFor(c=>c===U.Joined),this.navigation.push("room",o)}catch(o){let a;((t=o.statusCode)!=null?t:o.status)===400?a=new Error(`/join : '${e}' was not legal room ID or room alias`):((s=o.statusCode)!=null?s:o.status)===404||((i=o.statusCode)!=null?i:o.status)===502||o.message=="Internal Server Error"?a=new Error(`/join : room '${e}' not found`):((r=o.statusCode)!=null?r:o.status)===403?a=new Error(`/join : you're not invited to join '${e}'`):a=o,this._sendError=a,this._timelineError=null,this.emitChange("error")}}async _processCommand(e){let t;const[s,...i]=e.substring(1).split(" ");switch(s){case"me":e=i.join(" "),t="m.emote";break;case"join":if(i.length===1){const r=i[0];await this._processCommandJoin(r)}else this._sendError=new Error("join syntax: /join <room-id>"),this._timelineError=null,this.emitChange("error");break;case"shrug":e="\xAF\\_(\u30C4)_/\xAF "+i.join(" "),t="m.text";break;case"tableflip":e="(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B "+i.join(" "),t="m.text";break;case"unflip":e="\u252C\u2500\u2500\u252C \u30CE( \u309C-\u309C\u30CE) "+i.join(" "),t="m.text";break;case"lenny":e="( \u0361\xB0 \u035C\u0296 \u0361\xB0) "+i.join(" "),t="m.text";break;default:this._sendError=new Error(`no command name "${s}". To send the message instead of executing, please type "/${e}"`),this._timelineError=null,this.emitChange("error"),e=void 0}return{type:t,message:e}}async _sendMessage(e,t){if(!this._room.isArchived&&e){let s={type:"m.text",message:e};e.startsWith("//")?s.message=e.substring(1).trim():e.startsWith("/")&&(s=await this._processCommand(e));try{const i=s.type,r=s.message;i&&r&&(t?await t.reply(i,r):await this._room.sendEvent("m.room.message",{msgtype:i,body:r}))}catch(i){return console.error(`room.sendMessage(): ${i.message}:
${i.stack}`),this._sendError=i,this._timelineError=null,this.emitChange("error"),!1}return!0}return!1}async _pickAndSendFile(){try{const e=await this.platform.openFile();return e?this._sendFile(e):void 0}catch(e){console.error(e)}}async _sendFile(e){const t={body:e.name,msgtype:"m.file"};await this._room.sendEvent("m.room.message",t,{url:this._room.createAttachment(e.blob,e.name)})}async _pickAndSendVideo(){try{if(!this.platform.hasReadPixelPermission()){alert("Please allow canvas image data access, so we can scale your images down.");return}const e=await this.platform.openFile("video/*");if(!e)return;if(!e.blob.mimeType.startsWith("video/"))return this._sendFile(e);let t;try{t=await this.platform.loadVideo(e.blob)}catch(c){throw c instanceof window.MediaError&&c.code===4?new Error(`this browser does not support videos of type ${e==null?void 0:e.blob.mimeType}.`):c}const s={body:e.name,msgtype:"m.video",info:Ru(t)},i={url:this._room.createAttachment(t.blob,e.name)},o=await this.platform.settingsStorage.getInt("sentImageSizeLimit")||Math.min(t.maxDimension,800),a=await t.scale(o);s.info.thumbnail_info=Ht(a),i["info.thumbnail_url"]=this._room.createAttachment(a.blob,e.name),await this._room.sendEvent("m.room.message",s,i)}catch(e){this._sendError=e,this.emitChange("error"),console.error(e.stack)}}async _pickAndSendPicture(){try{if(!this.platform.hasReadPixelPermission()){alert("Please allow canvas image data access, so we can scale your images down.");return}const e=await this.platform.openFile("image/*");if(!e)return;if(!e.blob.mimeType.startsWith("image/"))return this._sendFile(e);let t=await this.platform.loadImage(e.blob);const s=await this.platform.settingsStorage.getInt("sentImageSizeLimit");if(s&&t.maxDimension>s){const o=await t.scale(s);t.dispose(),t=o}const i={body:e.name,msgtype:"m.image",info:Ht(t)},r={url:this._room.createAttachment(t.blob,e.name)};if(t.maxDimension>600){const o=await t.scale(400);i.info.thumbnail_info=Ht(o),r["info.thumbnail_url"]=this._room.createAttachment(o.blob,e.name)}await this._room.sendEvent("m.room.message",i,r)}catch(e){this._sendError=e,this.emitChange("error"),console.error(e.stack)}}get room(){return this._room}get composerViewModel(){return this._composerVM}openDetailsPanel(){let e=this.navigation.path.until("room");e=e.with(this.navigation.segment("right-panel",!0)),e=e.with(this.navigation.segment("details",!0)),this.navigation.applyPath(e)}startReply(e){this._room.isArchived||this._composerVM.setReplyingTo(e)}dismissError(){this._sendError=null,this.emitChange("error")}}function Ru(n){const e=Ht(n);return e.duration=n.duration,e}class Cu extends A{constructor(e){super(e),this._archivedRoom=e.archivedRoom}get description(){return this._archivedRoom.isKicked?this._archivedRoom.kickReason?this.i18n`You were kicked from the room by ${this._archivedRoom.kickedBy.name} because: ${this._archivedRoom.kickReason}`:this.i18n`You were kicked from the room by ${this._archivedRoom.kickedBy.name}.`:this._archivedRoom.isBanned?this._archivedRoom.kickReason?this.i18n`You were banned from the room by ${this._archivedRoom.kickedBy.name} because: ${this._archivedRoom.kickReason}`:this.i18n`You were banned from the room by ${this._archivedRoom.kickedBy.name}.`:this.i18n`You left this room`}get kind(){return"disabled"}}class Tu extends A{get description(){return this.i18n`You do not have the powerlevel necessary to send messages`}get kind(){return"disabled"}}class Mu extends A{constructor(e){super(e);const{roomIdOrAlias:t,session:s}=e;this._session=s,this.roomIdOrAlias=t,this._error=null,this._busy=!1}get error(){var e;return(e=this._error)==null?void 0:e.message}async join(){this._busy=!0,this.emitChange("busy");try{const e=await this._session.joinRoom(this.roomIdOrAlias);this.navigation.push("room",e)}catch(e){this._error=e,this._busy=!1,this.emitChange("error")}}get busy(){return this._busy}get kind(){return"unknown"}}class Au extends A{constructor(e){super(e);const{invite:t,mediaRepository:s}=e;this._invite=t,this._mediaRepository=s,this._onInviteChange=this._onInviteChange.bind(this),this._
${e.stack}`)}}function cm(n,e,t,s){const i=n(e);let r=!1;return i.elapsed().then(()=>{r=!0,t.abort()},()=>{}),s.then(o=>(i.abort(),o),o=>{throw i.abort(),o.name==="AbortError"&&r?new qe(`Request timed out after ${e}ms`,!0):o})}function ko(n,e=Math.random){return n.includes("?")?n=n+"&":n=n+"?",n+`_cacheBuster=${Math.ceil(e()*Number.MAX_SAFE_INTEGER)}`}function Ro(n){var t;const e=new FormData;for(const[s,i]of n)((t=i.blob)==null?void 0:t.nativeBlob)&&i.name?e.set(s,i.blob.nativeBlob,i.name):e.set(s,i);return e}class lm{constructor(e,t){this._promise=e,this._xhr=t}abort(){this._xhr.abort()}response(){return this._promise}}function hm(n,{method:e,headers:t,timeout:s,format:i,uploadProgress:r}){const o=new XMLHttpRequest;if(r&&o.upload.addEventListener("progress",a=>r(a.loaded)),o.open(e,n),i==="buffer"&&(o.responseType="arraybuffer"),t)for(const[a,c]of t.entries())try{o.setRequestHeader(a,c)}catch(l){console.info(`Could not set ${a} header: ${l.message}`)}return s&&(o.timeout=s),o}function dm(n,e,t){return new Promise((s,i)=>{n.addEventListener("load",()=>s(n)),n.addEventListener("abort",()=>i(new ye)),n.addEventListener("error",()=>i(new qe(`Error ${e} ${t}`))),n.addEventListener("timeout",()=>i(new qe(`Timeout ${e} ${t}`,!0)))})}function Co(n,e){let{cache:t,format:s,body:i,method:r}=e;t||(n=ko(n));const o=hm(n,e),a=dm(o,r,n).then(c=>{const{status:l}=c;let h=null;return s==="buffer"?h=c.response:c.getResponseHeader("Content-Type")==="application/json"&&(h=JSON.parse(c.responseText)),{status:l,body:h}});return i!=null&&i.nativeBlob&&(i=i.nativeBlob),i instanceof Map&&(i=Ro(i)),o.send(i||null),new lm(a,o)}class an{constructor(e,t){if(t)this.promise=e,this._controller=t;else{const s=new Promise((i,r)=>{this._controller={abort(){const o=new Error("fetch request aborted");o.name="AbortError",r(o)}}});this.promise=Promise.race([e,s])}}abort(){this._controller.abort()}response(){return this.promise}}function um(n,e){return function(s,i){if(e!=null&&e.haltRequests)return new an(new Promise(()=>{}),{});if(i!=null&&i.uploadProgress)return Co(s,i);let{method:r,headers:o,body:a,timeout:c,format:l,cache:h=!1}=i;const d=typeof AbortController=="function"?new AbortController:null;a!=null&&a.nativeBlob&&(a=a.nativeBlob),a instanceof Map&&(a=Ro(a));let u={method:r,body:a};if(d&&(u=Object.assign(u,{signal:d.signal})),h||(s=ko(s)),u=Object.assign(u,{mode:"cors",credentials:"omit",referrer:"no-referrer",cache:"default"}),o){const f=new Headers;for(const[b,S]of o.entries())f.append(b,S);u.headers=f}const p=fetch(s,u).then(async f=>{const{status:b}=f;let S;try{l==="json"?S=await f.json():l==="buffer"?S=await f.arrayBuffer():l==="text"&&(S=await f.text())}catch(k){if(!(k.name==="SyntaxError"&&b>=400))throw k}return{status:b,body:S}},f=>{throw f.name==="AbortError"?new ye:f instanceof TypeError?new qe(`${r} ${s}: ${f.message}`):f}),_=new an(p,d);return c&&(_.promise=cm(n,c,_,_.promise)),_}}class mm{constructor(e){this._name=e}getAll(){const e=localStorage.getItem(this._name);if(e){const t=JSON.parse(e);if(Array.isArray(t))return Promise.resolve(t)}return Promise.resolve([])}async updateLastUsed(e,t){const s=await this.getAll();if(s){const i=s.find(r=>r.id===e);i&&(i.lastUsed=t,localStorage.setItem(this._name,JSON.stringify(s)))}}async get(e){const t=await this.getAll();if(t)return t.find(s=>s.id===e)}async add(e){const t=await this.getAll();t.push(e),localStorage.setItem(this._name,JSON.stringify(t))}async delete(e){let t=await this.getAll();t=t.filter(s=>s.id!==e),localStorage.setItem(this._name,JSON.stringify(t))}}class pm{constructor(e){this._prefix=e}async setInt(e,t){this._set(e,t)}async getInt(e,t=0){const s=window.localStorage.getItem(`${this._prefix}${e}`);return typeof s=="string"?parseInt(s,10):t}async setBool(e,t){this._set(e,t)}async getBool(e,t=!1){const s=window.localStorage.getItem(`${this._prefix}${e}`);return typeof s=="string"?s==="true":t}async setString(e,t){this._set(e,t)}async getString(e){return window.localStorage.getItem(`${this._prefix}${e}`)}async remove(e){window.localStorage.removeItem(`${this._prefix}${e}`)}async _
2022-08-19 17:41:59 +05:30
`)[1]),T.div([T.h2("Something went wrong\u2026"),T.h3(n.message),T.p(`This occurred while running ${t}.`),T.pre(n.stack)])}function ln(n,e,t){if(e===n.childElementCount)n.appendChild(t);else{const i=n.children[e];n.insertBefore(t,i)}}function xm(n){n.innerHTML=""}function Nm(n){return async e=>{var t,s;(t=e.target)==null||t.setAttribute("disabled","disabled"),await n(e),(s=e.target)==null||s.removeAttribute("disabled")}}class is{constructor({list:e,onItemClick:t,className:s,tagName:i="ul",parentProvidesUpdates:r=!0},o){this._onItemClick=t,this._list=e,this._className=s,this._tagName=i,this._root=void 0,this._subscription=void 0,this._childCreator=o,this._childInstances=void 0,this._mountArgs={parentProvidesUpdates:r}}root(){return this._root}update(e){if(e.list){if(this._subscription)for(this._unloadList();this._root.lastChild;)this._root.lastChild.remove();this._list=e.list,this.loadList()}}mount(){const e={};this._className&&(e.className=this._className);const t=this._root=Tm(this._tagName,e);return this.loadList(),this._onItemClick&&t.addEventListener("click",this),t}handleEvent(e){e.type==="click"&&this._handleClick(e)}unmount(){this._list&&this._unloadList()}_handleClick(e){if(e.target===this._root||!this._onItemClick)return;let t=e.target;for(;t.parentNode!==this._root;)t=t.parentNode;const s=Array.prototype.indexOf.call(this._root.childNodes,t),i=this._childInstances[s];i&&this._onItemClick(i,e)}_unloadList(){this._subscription=this._subscription();for(let e of this._childInstances)e.unmount();this._childInstances=void 0}loadList(){if(!this._list)return;this._subscription=this._list.subscribe(this),this._childInstances=[];const e=document.createDocumentFragment();for(let t of this._list){const s=this._childCreator(t);this._childInstances.push(s),e.appendChild(Xt(s,this._mountArgs))}this._root.appendChild(e)}onReset(){for(const e of this._childInstances)e.root().remove(),e.unmount();this._childInstances.length=0}onAdd(e,t){this.addChild(e,t)}onRemove(e,t){this.removeChild(e)}onMove(e,t,s){this.moveChild(e,t)}onUpdate(e,t,s){this.updateChild(e,t,s)}addChild(e,t){const s=this._childCreator(t);this._childInstances.splice(e,0,s),ln(this._root,e,Xt(s,this._mountArgs))}removeChild(e){const[t]=this._childInstances.splice(e,1);t.root().remove(),t.unmount()}moveChild(e,t){const[s]=this._childInstances.splice(e,1);this._childInstances.splice(t,0,s),s.root().remove(),ln(this._root,t,s.root())}updateChild(e,t,s){if(this._childInstances){const i=this._childInstances[e];i&&i.update(t,s)}}recreateItem(e,t){if(this._childInstances){const s=this._childCreator(t);if(!s)this.onRemove(e,t);else{const[i]=this._childInstances.splice(e,1,s);this._root.replaceChild(s.mount(this._mountArgs),i.root()),i.unmount()}}}getChildInstanceByIndex(e){var t;return(t=this._childInstances)==null?void 0:t[e]}}class No{constructor(e){this._value=e,this._boundUpdateFromValue=null}subscribeOnMount(e){e&&e.parentProvidesUpdates||this._subscribe()}unmount(){this._unsubscribe()}get value(){return this._value}_updateFromValue(e){this.update(this._value,e)}_subscribe(){var e;typeof((e=this._value)==null?void 0:e.on)=="function"&&(this._boundUpdateFromValue=this._updateFromValue.bind(this),this._value.on("change",this._boundUpdateFromValue))}_unsubscribe(){this._boundUpdateFromValue&&(typeof this._value.off=="function"&&this._value.off("change",this._boundUpdateFromValue),this._boundUpdateFromValue=null)}}function Dm(n){for(const e of Object.values(n))if(typeof e=="function")return!0;return!1}class E extends No{constructor(){super(...arguments),this._eventListeners=void 0,this._bindings=void 0,this._root=void 0,this._subViews=void 0}_attach(){if(this._eventListeners)for(let{node:e,name:t,fn:s,useCapture:i}of this._eventListeners)e.addEventListener(t,s,i)}_detach(){if(this._eventListeners)for(let{node:e,name:t,fn:s,useCapture:i}of this._eventListeners)e.removeEventListener(t,s,i)}mount(e){const t=new Do(this);try{this._root=this.render(t,this._value)}finally{t.close()}return this.subscribeOnMount(e),this._attach(),this._root}unmount(){if(this._detach(),super.unm
//# sourceMappingURL=index.baaa0776.js.map