Warning: This is a dangerous setting. It allows you to delete relay
databases from other vaults.
`,i=T(),a=x("div"),l=x("div"),c=x("input"),u=T(),f=x("div"),d=T(),m&&m.c(),h(e,"class","modal-title"),h(s,"class","setting-item-info"),h(c,"type","checkbox"),h(c,"tabindex","-1"),c.checked=n[1],h(f,"class","checkbox-toggle"),h(l,"role","checkbox"),h(l,"aria-checked",n[1]),h(l,"tabindex","0"),h(l,"class","checkbox-container system3-dangerous svelte-1n3w4sk"),_e(l,"is-enabled",n[1]),h(a,"class","setting-item-control"),h(o,"class","setting-item"),h(r,"class","system3-indexeddb-analysis svelte-1n3w4sk")},m(M,E){_(M,e,E),_(M,t,E),_(M,r,E),b(r,o),b(o,s),b(o,i),b(o,a),b(a,l),b(l,c),b(l,u),b(l,f),b(r,d),~p&&C[p].m(r,null),y=!0,g||(I=[$(l,"keypress",n[15]),$(l,"click",n[16])],g=!0)},p(M,[E]){(!y||E&2)&&(c.checked=M[1]),(!y||E&2)&&h(l,"aria-checked",M[1]),(!y||E&2)&&_e(l,"is-enabled",M[1]);let U=p;p=S(M,E),p===U?~p&&C[p].p(M,E):(m&&(ee(),k(C[U],1,1,()=>{C[U]=null}),te()),~p?(m=C[p],m?m.p(M,E):(m=C[p]=L[p](M),m.c()),v(m,1),m.m(r,null)):m=null)},i(M){y||(v(m),y=!0)},o(M){k(m),y=!1},d(M){M&&(w(e),w(t),w(r)),~p&&C[p].d(),g=!1,me(I)}}}function QP(n,e,t){let r,o,s,i,a,l;var c;let{plugin:u}=e,f=ge(!0);ne(n,f,M=>t(3,i=M));let d=ge(0);ne(n,d,M=>t(4,a=M));let p=ge(null);ne(n,p,M=>t(0,s=M));let m=ge(null);ne(n,m,M=>t(5,l=M));let y=!1;function g(){return Ce(this,void 0,void 0,function*(){f.set(!0),m.set(null);try{let M=yield O_({appId:u.appId,filterByAppId:!y,onProgress:E=>d.set(E)});p.set(M)}catch(M){m.set(`Analysis failed: ${M.message}`)}finally{f.set(!1)}})}function I(M){return Ce(this,void 0,void 0,function*(){try{yield $_(M),s&&Ws(p,s.largeStores=s.largeStores.filter(E=>E.slug!==M),s)}catch(E){m.set(`Failed to delete ${M}: ${E.message}`)}})}st(()=>{g()});let L=()=>{t(1,y=!y),g()},C=()=>{t(1,y=!y),g()},S=M=>I(M.slug);return n.$$set=M=>{"plugin"in M&&t(12,u=M.plugin)},n.$$.update=()=>{n.$$.dirty&8193&&t(14,r=t(13,c=s==null?void 0:s.largeStores.reduce((M,E)=>{let U=E.relay||"local";return M[U]||(M[U]=[]),M[U].push(E),M},{}))!==null&&c!==void 0?c:{}),n.$$.dirty&16384&&t(2,o=Object.entries(r).sort(([M],[E])=>M==="local"?-1:E==="local"?1:M.localeCompare(E)))},[s,y,o,i,a,l,f,d,p,m,g,I,u,c,r,L,C,S]}var lh=class extends z{constructor(e){super(),W(this,e,QP,YP,j,{plugin:12},qP)}},j_=lh;var nu=class extends z_.Modal{constructor(t,r){super(t);this.plugin=r}onOpen(){let{contentEl:t}=this;this.component=new j_({target:t,props:{plugin:this.plugin}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};var qte=require("obsidian");function ch(n){return n.startsWith("v")?n.slice(1):n}function ZP(n,e){return n.map((t,r)=>[t,e[r]])}function XP(n,e){try{let t=ch(n).split(".").map(parseInt),r=ch(e).split(".").map(parseInt);for(let[o,s]of ZP(t,r))if(o>s)return!0}catch(t){}return!1}var su=class extends it{constructor(t,r,o){super("UpdateManager");this.plugin=t;this.timeProvider=r;this.releaseSettings=o;this.updateCheckInterval=null;this.lastReleaseCheck=0;this.lastChannelCheck=0;this.CHECK_INTERVAL=1e3*60*60*24;this.observableName="UpdateManager";this.githubReleases=new qo("system3-relay/releases"),this.releaseChannels=new qo("system3-relay/releaseChannels")}get releases(){return[...this.githubReleases.values()].sort((t,r)=>r.tag_name.localeCompare(t.tag_name,void 0,{numeric:!0,sensitivity:"base"}))}get beta(){return this.releaseChannels.get("beta")}get stable(){return this.releaseChannels.get("stable")}async fetchReleases(){let r=await at("https://api.github.com/repos/No-Instructions/Relay/releases",{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"Relay-Obsidian-Plugin"}});if(!r.ok)throw new Error(`GitHub API error: ${r.status}`);let o=await r.json();return He().enableNetworkLogging&&this.debug("GitHub releases fetched:",o),o}async fetchLatestRelease(){try{let o="https://api.github.com/repos/No-Instructions/Relay/releases/latest";this.debug(`Fetching latest release from: ${o}`);let s=await at(o,{headers:{"User-Agent":"Relay-Obsidian-Plugin"}});if(!s.ok)throw new Error(`GitHub API error: ${s.status}`);return await s.json()}catch(t){return this.error("Failed to fetch latest release:",t),null}}async fetchLatestTagFromChannel(t){try{let r={beta:"manifest-beta.json",stable:"manifest.json"}[t],o=r?await this.fetchRepoManifest(r):null;return o?(this.debug("repo manifest",o),o.version):null}catch(r){this.error("Failed to check for updates:",r)}return null}async getReleases(){try{let t=Date.now();if(t-this.lastReleaseCheck<300*1e3&&this.githubReleases.size>0)return[...this.githubReleases.values()];this.lastReleaseCheck=t;let r=await this.fetchReleases(),o=new Set([...this.githubReleases.keys()]),s=new Set;r.forEach(a=>{this.githubReleases.set(a.tag_name,a),s.add(a.tag_name)}),o.forEach(a=>{s.has(a)||this.githubReleases.delete(a)});let i=await this.fetchLatestRelease();i&&(i.latest=!0,this.githubReleases.set(i.tag_name,i)),this.notifyListeners()}catch(t){this.error("Failed to fetch GitHub releases:",t)}return[...this.githubReleases.values()]}async getChannelRelease(){let t=Date.now(),r=this.releaseChannels.get(this.releaseSettings.get().channel);if(t-this.lastChannelCheck<300*1e3&&r)return r;this.lastReleaseCheck=t;let o=await this.getReleases();if(o.length===0)return this.debug("No releases found"),null;let s=this.releaseSettings.get().channel;if(!s)return null;let i=await this.fetchLatestTagFromChannel(s);if(!i)return null;let a=o.find(l=>ch(l.tag_name)===i);return a?(this.releaseChannels.set(s,a),this.notifyListeners(),a):null}async update(){await this.getReleases(),await this.getChannelRelease()}start(){this.update(),this.updateCheckInterval=this.timeProvider.setInterval(()=>this.update(),this.CHECK_INTERVAL)}stop(){this.updateCheckInterval!==null&&(this.timeProvider.clearInterval(this.updateCheckInterval),this.updateCheckInterval=null)}async fetchRepoManifest(t,r="main"){try{let i=`https://raw.githubusercontent.com/No-Instructions/Relay/${r}/${t}`;this.debug(`Fetching ${i}`);let a=await at(i);if(!a.ok)throw new Error("unable to fetch manifest");return await a.json()}catch(o){return this.error("Failed to fetch:",o),null}}async fetchReleaseManifest(t){try{let r=t.assets.find(i=>i.name==="manifest.json");if(!r)return this.debug("No manifest found in release assets"),null;this.debug("Fetching manifest from release asset:",r.browser_download_url);let o=await at(r.browser_download_url,{headers:{Accept:"application/octet-stream","User-Agent":"Relay-Obsidian-Plugin"}});if(!o.ok)throw new Error(`Failed to fetch manifest asset: ${o.status}`);let s=await o.json();return He().enableNetworkLogging&&this.debug("manifest fetched:",s),s}catch(r){return this.error("Failed to fetch manifest for release:",t,r),null}}getNewRelease(){let t=this.releaseChannels.get(this.releaseSettings.get().channel);if(t&&XP(t.tag_name,this.plugin.version))return t}async installUpdate(t){let r=await this.fetchReleaseManifest(t);try{this.debug(`Installing update from v${this.plugin.version} to v${r.version}...`,r),await this.plugin.app.plugins.installPlugin("No-Instructions/Relay",r.version,r),this.notifyListeners(),this.debug("Update complete. Reloading plugin...");let o="system3-relay",s=this.plugin.app.plugins;return await s.disablePlugin(o),await s.enablePlugin(o),!0}catch(o){return this.error("Failed to install update:",o),!1}}destroy(){this.stop(),this.githubReleases=null,this.releaseChannels=null,super.destroy()}};var c1=require("obsidian");var a1=require("obsidian");function eD(n){we(n,"svelte-12doke6",'.modal-content.svelte-12doke6.svelte-12doke6{padding:0;display:flex;flex-direction:column;height:100%}.settings-container.svelte-12doke6.svelte-12doke6{margin:0 1rem;border-bottom:1px solid var(--background-modifier-border);margin-bottom:1rem}.settings-spacer.svelte-12doke6.svelte-12doke6{height:0.5rem}.checkbox-container.svelte-12doke6.svelte-12doke6{cursor:pointer}.loading-text.svelte-12doke6.svelte-12doke6,.no-releases-text.svelte-12doke6.svelte-12doke6{padding:12px;text-align:center;color:var(--text-muted);font-style:italic}.release-tags-container.svelte-12doke6.svelte-12doke6{display:flex;flex-wrap:wrap;column-gap:8px;row-gap:4px;padding:0 1rem 1rem;max-height:160px;overflow-y:auto}.release-tag-item.svelte-12doke6.svelte-12doke6{display:flex;justify-content:center;align-items:center;background-color:var(--background-secondary);border:1px solid var(--background-modifier-border);border-radius:4px;padding:4px 8px;height:24px;cursor:pointer;opacity:0.7;position:relative}.release-tag-item.svelte-12doke6.svelte-12doke6:hover{background-color:var(--background-modifier-hover);opacity:0.9}.release-tag-item[aria-selected="true"].svelte-12doke6.svelte-12doke6{background-color:var(--color-accent);border-color:var(--background-modifier-border);border-bottom-width:2px;opacity:1}.release-tag-item.current-version.svelte-12doke6.svelte-12doke6{border-width:1px}.release-tag-item.development-version.svelte-12doke6.svelte-12doke6{border-width:1px}.release-tag-item.main-branch-version.svelte-12doke6.svelte-12doke6{border-width:1px}.release-tag-item.beta-version.svelte-12doke6.svelte-12doke6{font-weight:bold}.release-tag-item.stable-version.svelte-12doke6.svelte-12doke6{font-weight:bold}.prerelease-badge.svelte-12doke6.svelte-12doke6{font-size:0.7em;color:var(--text-on-accent);border-radius:4px;padding:2px 6px;margin-left:8px;vertical-align:middle;text-transform:uppercase}.channel-badge.svelte-12doke6.svelte-12doke6{font-size:0.7em;border-radius:4px;padding:2px 6px;margin-left:8px;vertical-align:middle;text-transform:uppercase}.beta-badge.svelte-12doke6.svelte-12doke6{background-color:var(--background-modifier-hover);color:var(--text-normal)}.stable-badge.svelte-12doke6.svelte-12doke6{background-color:var(--background-modifier-hover);color:var(--text-normal)}.tag-name.svelte-12doke6.svelte-12doke6{font-weight:bold;font-size:0.8em;display:flex;align-items:center}.manifest-container.svelte-12doke6.svelte-12doke6{flex:1;display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);border-radius:8px;background-color:var(--background-secondary);margin:0 1rem 1rem;overflow:hidden}.manifest-header.svelte-12doke6.svelte-12doke6{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background-color:var(--background-secondary-alt);border-bottom:1px solid var(--background-modifier-border)}.manifest-header.svelte-12doke6 h3.svelte-12doke6{margin:0;font-size:1.1em;color:var(--text-normal);display:flex;align-items:center}.manifest-header-actions.svelte-12doke6.svelte-12doke6{display:flex;align-items:center;gap:10px}.manifest-close-btn.svelte-12doke6.svelte-12doke6{cursor:pointer;font-size:1.2em;background:transparent;border:none;color:var(--text-normal)}.manifest-content.svelte-12doke6.svelte-12doke6{padding:16px;border-top:1px solid var(--background-modifier-border)}.manifest-field.svelte-12doke6.svelte-12doke6{margin-bottom:8px;display:flex;align-items:flex-start}.manifest-label.svelte-12doke6.svelte-12doke6{font-weight:bold;min-width:120px;color:var(--text-normal)}.manifest-value.svelte-12doke6.svelte-12doke6{flex:1}.manifest-version-mismatch.svelte-12doke6.svelte-12doke6{margin-left:10px;color:var(--text-error);font-size:0.85em;display:flex;align-items:center;gap:4px}.manifest-version-mismatch-icon.svelte-12doke6.svelte-12doke6{font-size:1.2em}.release-changelog.svelte-12doke6.svelte-12doke6{padding:16px;overflow:hidden;display:flex;flex-direction:column;height:320px}.release-changelog-content.svelte-12doke6.svelte-12doke6{overflow-x:auto;margin:0;font-size:0.85em;flex:1;overflow-y:auto;line-height:1.4}.currently-installed.svelte-12doke6.svelte-12doke6{color:var(--interactive-accent);font-weight:bold;padding:4px 8px;border-radius:4px}.install-version-btn.svelte-12doke6.svelte-12doke6{font-size:0.9em;padding:4px 12px;cursor:pointer}.manifest-error.svelte-12doke6.svelte-12doke6{padding:16px;text-align:center;background-color:var(--background-modifier-error);border-radius:6px;color:var(--text-on-accent);margin:0 1rem 1rem}.manifest-error-message.svelte-12doke6.svelte-12doke6{margin-bottom:12px}')}function W_(n,e,t){let r=n.slice();return r[66]=e[t],r}function K_(n){let e,t;return e=new Gt({props:{name:"Show all releases",$$slots:{default:[tD]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&64|o[2]&128&&(s.$$scope={dirty:o,ctx:r}),e.$set(s)},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function tD(n){let e,t,r,o,s,i;return{c(){e=x("div"),t=x("input"),r=T(),o=x("div"),h(t,"type","checkbox"),t.checked=n[6],h(o,"class","checkbox-toggle"),h(e,"class","checkbox-container svelte-12doke6"),h(e,"role","checkbox"),h(e,"aria-checked",n[6]),h(e,"tabindex","0"),_e(e,"is-enabled",n[6])},m(a,l){_(a,e,l),b(e,t),b(e,r),b(e,o),s||(i=[$(e,"click",n[41]),$(e,"keydown",n[42])],s=!0)},p(a,l){l[0]&64&&(t.checked=a[6]),l[0]&64&&h(e,"aria-checked",a[6]),l[0]&64&&_e(e,"is-enabled",a[6])},d(a){a&&w(e),s=!1,me(i)}}}function rD(n){let e,t,r=!n[1]&&G_(n);function o(a,l){if(a[11])return aD;if(a[16])return iD}let s=o(n,[-1,-1,-1]),i=s&&s(n);return{c(){r&&r.c(),e=T(),i&&i.c(),t=ue()},m(a,l){r&&r.m(a,l),_(a,e,l),i&&i.m(a,l),_(a,t,l)},p(a,l){a[1]?r&&(r.d(1),r=null):r?r.p(a,l):(r=G_(a),r.c(),r.m(e.parentNode,e)),s===(s=o(a,l))&&i?i.p(a,l):(i&&i.d(1),i=s&&s(a),i&&(i.c(),i.m(t.parentNode,t)))},d(a){a&&(w(e),w(t)),r&&r.d(a),i&&i.d(a)}}}function oD(n){let e;return{c(){e=x("div"),e.textContent="No matching releases found with the current filter",h(e,"class","no-releases-text svelte-12doke6")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function nD(n){let e;return{c(){e=x("div"),e.textContent="No GitHub releases found",h(e,"class","no-releases-text svelte-12doke6")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function sD(n){let e;return{c(){e=x("div"),e.textContent="Loading GitHub releases...",h(e,"class","loading-text svelte-12doke6")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function G_(n){let e,t,r,o=!n[8].some(n[40]),s,i=n[5]&&J_(n),a=n[4]&&Y_(n),l=o&&Q_(n),c=!n[1]&&Z_(n);return{c(){e=x("div"),i&&i.c(),t=T(),a&&a.c(),r=T(),l&&l.c(),s=T(),c&&c.c(),h(e,"class","release-tags-container svelte-12doke6")},m(u,f){_(u,e,f),i&&i.m(e,null),b(e,t),a&&a.m(e,null),b(e,r),l&&l.m(e,null),b(e,s),c&&c.m(e,null)},p(u,f){u[5]?i?i.p(u,f):(i=J_(u),i.c(),i.m(e,t)):i&&(i.d(1),i=null),u[4]?a?a.p(u,f):(a=Y_(u),a.c(),a.m(e,r)):a&&(a.d(1),a=null),f[0]&256&&(o=!u[8].some(u[40])),o?l?l.p(u,f):(l=Q_(u),l.c(),l.m(e,s)):l&&(l.d(1),l=null),u[1]?c&&(c.d(1),c=null):c?c.p(u,f):(c=Z_(u),c.c(),c.m(e,null))},d(u){u&&w(e),i&&i.d(),a&&a.d(),l&&l.d(),c&&c.d()}}}function J_(n){let e,t,r,o,s;return{c(){e=x("div"),t=x("div"),t.textContent="Stable",h(t,"class","tag-name svelte-12doke6"),h(e,"class","release-tag-item main-branch-version stable-version svelte-12doke6"),h(e,"role","tab"),h(e,"aria-selected",r=n[9]==="stable"),h(e,"tabindex","0")},m(i,a){_(i,e,a),b(e,t),o||(s=[$(e,"click",n[43]),$(e,"keydown",n[44])],o=!0)},p(i,a){a[0]&512&&r!==(r=i[9]==="stable")&&h(e,"aria-selected",r)},d(i){i&&w(e),o=!1,me(s)}}}function Y_(n){let e,t,r,o,s;return{c(){e=x("div"),t=x("div"),t.textContent="Beta",h(t,"class","tag-name svelte-12doke6"),h(e,"class","release-tag-item main-branch-version beta-version svelte-12doke6"),h(e,"role","tab"),h(e,"aria-selected",r=n[9]==="beta"),h(e,"tabindex","0")},m(i,a){_(i,e,a),b(e,t),o||(s=[$(e,"click",n[45]),$(e,"keydown",n[46])],o=!0)},p(i,a){a[0]&512&&r!==(r=i[9]==="beta")&&h(e,"aria-selected",r)},d(i){i&&w(e),o=!1,me(s)}}}function Q_(n){let e,t,r,o,s;return{c(){e=x("div"),t=x("div"),t.textContent="Dev",h(t,"class","tag-name svelte-12doke6"),h(e,"class","release-tag-item development-version svelte-12doke6"),h(e,"role","tab"),h(e,"aria-selected",r=n[10]===n[0].version),h(e,"tabindex","0")},m(i,a){_(i,e,a),b(e,t),o||(s=[$(e,"click",n[47]),$(e,"keydown",n[48])],o=!0)},p(i,a){a[0]&1025&&r!==(r=i[10]===i[0].version)&&h(e,"aria-selected",r)},d(i){i&&w(e),o=!1,me(s)}}}function Z_(n){let e,t=he(n[8]),r=[];for(let o=0;o