171 lines
821 KiB
JavaScript
171 lines
821 KiB
JavaScript
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
*/
|
|
|
|
"use strict";var j1=Object.create;var ui=Object.defineProperty;var z1=Object.getOwnPropertyDescriptor;var W1=Object.getOwnPropertyNames;var K1=Object.getPrototypeOf,G1=Object.prototype.hasOwnProperty;var J1=(n,e,t)=>e in n?ui(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var cu=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),uu=(n,e)=>{for(var t in e)ui(n,t,{get:e[t],enumerable:!0})},dh=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of W1(e))!G1.call(n,o)&&o!==t&&ui(n,o,{get:()=>e[o],enumerable:!(r=z1(e,o))||r.enumerable});return n};var Do=(n,e,t)=>(t=n!=null?j1(K1(n)):{},dh(e||!n||!n.__esModule?ui(t,"default",{value:n,enumerable:!0}):t,n)),Y1=n=>dh(ui({},"__esModule",{value:!0}),n);var St=(n,e,t)=>J1(n,typeof e!="symbol"?e+"":e,t);var An=cu((OD,mh)=>{"use strict";function fo(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function ph(n,e){for(var t="",r=0,o=-1,s=0,i,a=0;a<=n.length;++a){if(a<n.length)i=n.charCodeAt(a);else{if(i===47)break;i=47}if(i===47){if(!(o===a-1||s===1))if(o!==a-1&&s===2){if(t.length<2||r!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",r=0):(t=t.slice(0,l),r=t.length-1-t.lastIndexOf("/")),o=a,s=0;continue}}else if(t.length===2||t.length===1){t="",r=0,o=a,s=0;continue}}e&&(t.length>0?t+="/..":t="..",r=2)}else t.length>0?t+="/"+n.slice(o+1,a):t=n.slice(o+1,a),r=a-o-1;o=a,s=0}else i===46&&s!==-1?++s:s=-1}return t}function Q1(n,e){var t=e.dir||e.root,r=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+r:t+n+r:r}var is={resolve:function(){for(var e="",t=!1,r,o=arguments.length-1;o>=-1&&!t;o--){var s;o>=0?s=arguments[o]:(r===void 0&&(r=process.cwd()),s=r),fo(s),s.length!==0&&(e=s+"/"+e,t=s.charCodeAt(0)===47)}return e=ph(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(fo(e),e.length===0)return".";var t=e.charCodeAt(0)===47,r=e.charCodeAt(e.length-1)===47;return e=ph(e,!t),e.length===0&&!t&&(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return fo(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];fo(r),r.length>0&&(e===void 0?e=r:e+="/"+r)}return e===void 0?".":is.normalize(e)},relative:function(e,t){if(fo(e),fo(t),e===t||(e=is.resolve(e),t=is.resolve(t),e===t))return"";for(var r=1;r<e.length&&e.charCodeAt(r)===47;++r);for(var o=e.length,s=o-r,i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var a=t.length,l=a-i,c=s<l?s:l,u=-1,f=0;f<=c;++f){if(f===c){if(l>c){if(t.charCodeAt(i+f)===47)return t.slice(i+f+1);if(f===0)return t.slice(i+f)}else s>c&&(e.charCodeAt(r+f)===47?u=f:f===0&&(u=0));break}var d=e.charCodeAt(r+f),p=t.charCodeAt(i+f);if(d!==p)break;d===47&&(u=f)}var m="";for(f=r+u+1;f<=o;++f)(f===o||e.charCodeAt(f)===47)&&(m.length===0?m+="..":m+="/..");return m.length>0?m+t.slice(i+u):(i+=u,t.charCodeAt(i)===47&&++i,t.slice(i))},_makeLong:function(e){return e},dirname:function(e){if(fo(e),e.length===0)return".";for(var t=e.charCodeAt(0),r=t===47,o=-1,s=!0,i=e.length-1;i>=1;--i)if(t=e.charCodeAt(i),t===47){if(!s){o=i;break}}else s=!1;return o===-1?r?"/":".":r&&o===1?"//":e.slice(0,o)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');fo(e);var r=0,o=-1,s=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(i=e.length-1;i>=0;--i){var c=e.charCodeAt(i);if(c===47){if(!s){r=i+1;break}}else l===-1&&(s=!1,l=i+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(o=i):(a=-1,o=l))}return r===o?o=l:o===-1&&(o=e.length),e.slice(r,o)}else{for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!s){r=i+1;break}}else o===-1&&(s=!1,o=i+1);return o===-1?"":e.slice(r,o)}},extname:function(e){fo(e);for(var t=-1,r=0,o=-1,s=!0,i=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(l===47){if(!s){r=a+1;break}continue}o===-1&&(s=!1,o=a+1),l===46?t===-1?t=a:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||o===-1||i===0||i===1&&t===o-1&&t===r+1?"":e.slice(t,o)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return Q1("/",e)},parse:function(e){fo(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var r=e.charCodeAt(0),o=r===47,s;o?(t.root="/",s=1):s=0;for(var i=-1,a=0,l=-1,c=!0,u=e.length-1,f=0;u>=s;--u){if(r=e.charCodeAt(u),r===47){if(!c){a=u+1;break}continue}l===-1&&(c=!1,l=u+1),r===46?i===-1?i=u:f!==1&&(f=1):i!==-1&&(f=-1)}return i===-1||l===-1||f===0||f===1&&i===l-1&&i===a+1?l!==-1&&(a===0&&o?t.base=t.name=e.slice(1,l):t.base=t.name=e.slice(a,l)):(a===0&&o?(t.name=e.slice(1,i),t.base=e.slice(1,l)):(t.name=e.slice(a,i),t.base=e.slice(a,l)),t.ext=e.slice(i,l)),a>0?t.dir=e.slice(0,a-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};is.posix=is;mh.exports=is});var Ny=cu((UR,$y)=>{var Dy=require("url").parse,Ck=require("events"),Lk=require("https"),Mk=require("http"),Tk=require("util"),Ak=["pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","secureProtocol","servername","checkServerIdentity"],Oy=[239,187,191],Fk=58,Ek=32,Ry=10,Pk=13,Uy=1024*256,Dk=/^(cookie|authorization)$/i;function Rk(n){return Oy.every(function(e,t){return n[t]===e})}function Ct(n,e){var t=Ct.CONNECTING,r=e&&e.headers,o=!1;Object.defineProperty(this,"readyState",{get:function(){return t}}),Object.defineProperty(this,"url",{get:function(){return n}});var s=this;s.reconnectInterval=1e3,s.connectionInProgress=!1;function i(g){t!==Ct.CLOSED&&(t=Ct.CONNECTING,m("error",new Vi("error",{message:g})),d&&(n=d,d=null,o=!1),setTimeout(function(){t!==Ct.CONNECTING||s.connectionInProgress||(s.connectionInProgress=!0,p())},s.reconnectInterval))}var a,l="";r&&r["Last-Event-ID"]&&(l=r["Last-Event-ID"],delete r["Last-Event-ID"]);var c=!1,u="",f="",d=null;function p(){var g=Dy(n),I=g.protocol==="https:";if(g.headers={"Cache-Control":"no-cache",Accept:"text/event-stream"},l&&(g.headers["Last-Event-ID"]=l),r){var L=o?Ok(r):r;for(var C in L){var S=L[C];S&&(g.headers[C]=S)}}g.rejectUnauthorized=!(e&&!e.rejectUnauthorized),e&&e.createConnection!==void 0&&(g.createConnection=e.createConnection);var M=e&&e.proxy;if(M){var E=Dy(e.proxy);I=E.protocol==="https:",g.protocol=I?"https:":"http:",g.path=n,g.headers.Host=g.host,g.hostname=E.hostname,g.host=E.host,g.port=E.port}if(e&&e.https){for(var U in e.https)if(Ak.indexOf(U)!==-1){var K=e.https[U];K!==void 0&&(g[U]=K)}}e&&e.withCredentials!==void 0&&(g.withCredentials=e.withCredentials),a=(I?Lk:Mk).request(g,function(R){if(s.connectionInProgress=!1,R.statusCode===500||R.statusCode===502||R.statusCode===503||R.statusCode===504){m("error",new Vi("error",{status:R.statusCode,message:R.statusMessage})),i();return}if(R.statusCode===301||R.statusCode===302||R.statusCode===307){var O=R.headers.location;if(!O){m("error",new Vi("error",{status:R.statusCode,message:R.statusMessage}));return}var q=new URL(n).origin,H=new URL(O).origin;o=q!==H,R.statusCode===307&&(d=n),n=O,process.nextTick(p);return}if(R.statusCode!==200)return m("error",new Vi("error",{status:R.statusCode,message:R.statusMessage})),s.close();t=Ct.OPEN,R.on("close",function(){R.removeAllListeners("close"),R.removeAllListeners("end"),i()}),R.on("end",function(){R.removeAllListeners("close"),R.removeAllListeners("end"),i()}),m("open",new Vi("open"));var G,ce,N=0,X=-1,Me=0,Ie=0;R.on("data",function(D){G?(D.length>G.length-Ie&&(Me=G.length*2+D.length,Me>Uy&&(Me=G.length+D.length+Uy),ce=Buffer.alloc(Me),G.copy(ce,0,0,Ie),G=ce),D.copy(G,Ie),Ie+=D.length):(G=D,Rk(G)&&(G=G.slice(Oy.length)),Ie=G.length);for(var Q=0,de=Ie;Q<de;){c&&(G[Q]===Ry&&++Q,c=!1);for(var Le=-1,Ae=X,re,Z=N;Le<0&&Z<de;++Z)re=G[Z],re===Fk?Ae<0&&(Ae=Z-Q):re===Pk?(c=!0,Le=Z-Q):re===Ry&&(Le=Z-Q);if(Le<0){N=de-Q,X=Ae;break}else N=0,X=-1;y(G,Q,Ae,Le),Q+=Le+1}Q===de?(G=void 0,Ie=0):Q>0&&(G=G.slice(Q,Ie),Ie=G.length)})}),a.on("error",function(R){s.connectionInProgress=!1,i(R.message)}),a.setNoDelay&&a.setNoDelay(!0),a.end()}p();function m(){s.listeners(arguments[0]).length>0&&s.emit.apply(s,arguments)}this._close=function(){t!==Ct.CLOSED&&(t=Ct.CLOSED,a.abort&&a.abort(),a.xhr&&a.xhr.abort&&a.xhr.abort())};function y(g,I,L,C){if(C===0){if(u.length>0){var S=f||"message";m(S,new Uk(S,{data:u.slice(0,-1),lastEventId:l,origin:new URL(n).origin})),u=""}f=void 0}else if(L>0){var M=L<0,E=0,U=g.slice(I,I+(M?C:L)).toString();M?E=C:g[I+L+1]!==Ek?E=L+1:E=L+2,I+=E;var K=C-E,R=g.slice(I,I+K).toString();if(U==="data")u+=R+`
|
|
`;else if(U==="event")f=R;else if(U==="id")l=R;else if(U==="retry"){var O=parseInt(R,10);Number.isNaN(O)||(s.reconnectInterval=O)}}}}$y.exports=Ct;Tk.inherits(Ct,Ck.EventEmitter);Ct.prototype.constructor=Ct;["open","error","message"].forEach(function(n){Object.defineProperty(Ct.prototype,"on"+n,{get:function(){var t=this.listeners(n)[0];return t?t._listener?t._listener:t:void 0},set:function(t){this.removeAllListeners(n),this.addEventListener(n,t)}})});Object.defineProperty(Ct,"CONNECTING",{enumerable:!0,value:0});Object.defineProperty(Ct,"OPEN",{enumerable:!0,value:1});Object.defineProperty(Ct,"CLOSED",{enumerable:!0,value:2});Ct.prototype.CONNECTING=0;Ct.prototype.OPEN=1;Ct.prototype.CLOSED=2;Ct.prototype.close=function(){this._close()};Ct.prototype.addEventListener=function(e,t){typeof t=="function"&&(t._listener=t,this.on(e,t))};Ct.prototype.dispatchEvent=function(e){if(!e.type)throw new Error("UNSPECIFIED_EVENT_TYPE_ERR");this.emit(e.type,e.detail)};Ct.prototype.removeEventListener=function(e,t){typeof t=="function"&&(t._listener=void 0,this.removeListener(e,t))};function Vi(n,e){if(Object.defineProperty(this,"type",{writable:!1,value:n,enumerable:!0}),e)for(var t in e)e.hasOwnProperty(t)&&Object.defineProperty(this,t,{writable:!1,value:e[t],enumerable:!0})}function Uk(n,e){Object.defineProperty(this,"type",{writable:!1,value:n,enumerable:!0});for(var t in e)e.hasOwnProperty(t)&&Object.defineProperty(this,t,{writable:!1,value:e[t],enumerable:!0})}function Ok(n){var e={};for(var t in n)Dk.test(t)||(e[t]=n[t]);return e}});var Rl=cu((P5,Vs)=>{var fe=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},lt=-1,dt=1,je=0;fe.Diff=function(n,e){return[n,e]};fe.prototype.diff_main=function(n,e,t,r){typeof r=="undefined"&&(this.Diff_Timeout<=0?r=Number.MAX_VALUE:r=new Date().getTime()+this.Diff_Timeout*1e3);var o=r;if(n==null||e==null)throw new Error("Null input. (diff_main)");if(n==e)return n?[new fe.Diff(je,n)]:[];typeof t=="undefined"&&(t=!0);var s=t,i=this.diff_commonPrefix(n,e),a=n.substring(0,i);n=n.substring(i),e=e.substring(i),i=this.diff_commonSuffix(n,e);var l=n.substring(n.length-i);n=n.substring(0,n.length-i),e=e.substring(0,e.length-i);var c=this.diff_compute_(n,e,s,o);return a&&c.unshift(new fe.Diff(je,a)),l&&c.push(new fe.Diff(je,l)),this.diff_cleanupMerge(c),c};fe.prototype.diff_compute_=function(n,e,t,r){var o;if(!n)return[new fe.Diff(dt,e)];if(!e)return[new fe.Diff(lt,n)];var s=n.length>e.length?n:e,i=n.length>e.length?e:n,a=s.indexOf(i);if(a!=-1)return o=[new fe.Diff(dt,s.substring(0,a)),new fe.Diff(je,i),new fe.Diff(dt,s.substring(a+i.length))],n.length>e.length&&(o[0][0]=o[2][0]=lt),o;if(i.length==1)return[new fe.Diff(lt,n),new fe.Diff(dt,e)];var l=this.diff_halfMatch_(n,e);if(l){var c=l[0],u=l[1],f=l[2],d=l[3],p=l[4],m=this.diff_main(c,f,t,r),y=this.diff_main(u,d,t,r);return m.concat([new fe.Diff(je,p)],y)}return t&&n.length>100&&e.length>100?this.diff_lineMode_(n,e,r):this.diff_bisect_(n,e,r)};fe.prototype.diff_lineMode_=function(n,e,t){var r=this.diff_linesToChars_(n,e);n=r.chars1,e=r.chars2;var o=r.lineArray,s=this.diff_main(n,e,!1,t);this.diff_charsToLines_(s,o),this.diff_cleanupSemantic(s),s.push(new fe.Diff(je,""));for(var i=0,a=0,l=0,c="",u="";i<s.length;){switch(s[i][0]){case dt:l++,u+=s[i][1];break;case lt:a++,c+=s[i][1];break;case je:if(a>=1&&l>=1){s.splice(i-a-l,a+l),i=i-a-l;for(var f=this.diff_main(c,u,!1,t),d=f.length-1;d>=0;d--)s.splice(i,0,f[d]);i=i+f.length}l=0,a=0,c="",u="";break}i++}return s.pop(),s};fe.prototype.diff_bisect_=function(n,e,t){for(var r=n.length,o=e.length,s=Math.ceil((r+o)/2),i=s,a=2*s,l=new Array(a),c=new Array(a),u=0;u<a;u++)l[u]=-1,c[u]=-1;l[i+1]=0,c[i+1]=0;for(var f=r-o,d=f%2!=0,p=0,m=0,y=0,g=0,I=0;I<s&&!(new Date().getTime()>t);I++){for(var L=-I+p;L<=I-m;L+=2){var C=i+L,S;L==-I||L!=I&&l[C-1]<l[C+1]?S=l[C+1]:S=l[C-1]+1;for(var M=S-L;S<r&&M<o&&n.charAt(S)==e.charAt(M);)S++,M++;if(l[C]=S,S>r)m+=2;else if(M>o)p+=2;else if(d){var E=i+f-L;if(E>=0&&E<a&&c[E]!=-1){var U=r-c[E];if(S>=U)return this.diff_bisectSplit_(n,e,S,M,t)}}}for(var K=-I+y;K<=I-g;K+=2){var E=i+K,U;K==-I||K!=I&&c[E-1]<c[E+1]?U=c[E+1]:U=c[E-1]+1;for(var R=U-K;U<r&&R<o&&n.charAt(r-U-1)==e.charAt(o-R-1);)U++,R++;if(c[E]=U,U>r)g+=2;else if(R>o)y+=2;else if(!d){var C=i+f-K;if(C>=0&&C<a&&l[C]!=-1){var S=l[C],M=i+S-C;if(U=r-U,S>=U)return this.diff_bisectSplit_(n,e,S,M,t)}}}}return[new fe.Diff(lt,n),new fe.Diff(dt,e)]};fe.prototype.diff_bisectSplit_=function(n,e,t,r,o){var s=n.substring(0,t),i=e.substring(0,r),a=n.substring(t),l=e.substring(r),c=this.diff_main(s,i,!1,o),u=this.diff_main(a,l,!1,o);return c.concat(u)};fe.prototype.diff_linesToChars_=function(n,e){var t=[],r={};t[0]="";function o(l){for(var c="",u=0,f=-1,d=t.length;f<l.length-1;){f=l.indexOf(`
|
|
`,u),f==-1&&(f=l.length-1);var p=l.substring(u,f+1);(r.hasOwnProperty?r.hasOwnProperty(p):r[p]!==void 0)?c+=String.fromCharCode(r[p]):(d==s&&(p=l.substring(u),f=l.length),c+=String.fromCharCode(d),r[p]=d,t[d++]=p),u=f+1}return c}var s=4e4,i=o(n);s=65535;var a=o(e);return{chars1:i,chars2:a,lineArray:t}};fe.prototype.diff_charsToLines_=function(n,e){for(var t=0;t<n.length;t++){for(var r=n[t][1],o=[],s=0;s<r.length;s++)o[s]=e[r.charCodeAt(s)];n[t][1]=o.join("")}};fe.prototype.diff_commonPrefix=function(n,e){if(!n||!e||n.charAt(0)!=e.charAt(0))return 0;for(var t=0,r=Math.min(n.length,e.length),o=r,s=0;t<o;)n.substring(s,o)==e.substring(s,o)?(t=o,s=t):r=o,o=Math.floor((r-t)/2+t);return o};fe.prototype.diff_commonSuffix=function(n,e){if(!n||!e||n.charAt(n.length-1)!=e.charAt(e.length-1))return 0;for(var t=0,r=Math.min(n.length,e.length),o=r,s=0;t<o;)n.substring(n.length-o,n.length-s)==e.substring(e.length-o,e.length-s)?(t=o,s=t):r=o,o=Math.floor((r-t)/2+t);return o};fe.prototype.diff_commonOverlap_=function(n,e){var t=n.length,r=e.length;if(t==0||r==0)return 0;t>r?n=n.substring(t-r):t<r&&(e=e.substring(0,t));var o=Math.min(t,r);if(n==e)return o;for(var s=0,i=1;;){var a=n.substring(o-i),l=e.indexOf(a);if(l==-1)return s;i+=l,(l==0||n.substring(o-i)==e.substring(0,i))&&(s=i,i++)}};fe.prototype.diff_halfMatch_=function(n,e){if(this.Diff_Timeout<=0)return null;var t=n.length>e.length?n:e,r=n.length>e.length?e:n;if(t.length<4||r.length*2<t.length)return null;var o=this;function s(m,y,g){for(var I=m.substring(g,g+Math.floor(m.length/4)),L=-1,C="",S,M,E,U;(L=y.indexOf(I,L+1))!=-1;){var K=o.diff_commonPrefix(m.substring(g),y.substring(L)),R=o.diff_commonSuffix(m.substring(0,g),y.substring(0,L));C.length<R+K&&(C=y.substring(L-R,L)+y.substring(L,L+K),S=m.substring(0,g-R),M=m.substring(g+K),E=y.substring(0,L-R),U=y.substring(L+K))}return C.length*2>=m.length?[S,M,E,U,C]:null}var i=s(t,r,Math.ceil(t.length/4)),a=s(t,r,Math.ceil(t.length/2)),l;if(!i&&!a)return null;a?i?l=i[4].length>a[4].length?i:a:l=a:l=i;var c,u,f,d;n.length>e.length?(c=l[0],u=l[1],f=l[2],d=l[3]):(f=l[0],d=l[1],c=l[2],u=l[3]);var p=l[4];return[c,u,f,d,p]};fe.prototype.diff_cleanupSemantic=function(n){for(var e=!1,t=[],r=0,o=null,s=0,i=0,a=0,l=0,c=0;s<n.length;)n[s][0]==je?(t[r++]=s,i=l,a=c,l=0,c=0,o=n[s][1]):(n[s][0]==dt?l+=n[s][1].length:c+=n[s][1].length,o&&o.length<=Math.max(i,a)&&o.length<=Math.max(l,c)&&(n.splice(t[r-1],0,new fe.Diff(lt,o)),n[t[r-1]+1][0]=dt,r--,r--,s=r>0?t[r-1]:-1,i=0,a=0,l=0,c=0,o=null,e=!0)),s++;for(e&&this.diff_cleanupMerge(n),this.diff_cleanupSemanticLossless(n),s=1;s<n.length;){if(n[s-1][0]==lt&&n[s][0]==dt){var u=n[s-1][1],f=n[s][1],d=this.diff_commonOverlap_(u,f),p=this.diff_commonOverlap_(f,u);d>=p?(d>=u.length/2||d>=f.length/2)&&(n.splice(s,0,new fe.Diff(je,f.substring(0,d))),n[s-1][1]=u.substring(0,u.length-d),n[s+1][1]=f.substring(d),s++):(p>=u.length/2||p>=f.length/2)&&(n.splice(s,0,new fe.Diff(je,u.substring(0,p))),n[s-1][0]=dt,n[s-1][1]=f.substring(0,f.length-p),n[s+1][0]=lt,n[s+1][1]=u.substring(p),s++),s++}s++}};fe.prototype.diff_cleanupSemanticLossless=function(n){function e(p,m){if(!p||!m)return 6;var y=p.charAt(p.length-1),g=m.charAt(0),I=y.match(fe.nonAlphaNumericRegex_),L=g.match(fe.nonAlphaNumericRegex_),C=I&&y.match(fe.whitespaceRegex_),S=L&&g.match(fe.whitespaceRegex_),M=C&&y.match(fe.linebreakRegex_),E=S&&g.match(fe.linebreakRegex_),U=M&&p.match(fe.blanklineEndRegex_),K=E&&m.match(fe.blanklineStartRegex_);return U||K?5:M||E?4:I&&!C&&S?3:C||S?2:I||L?1:0}for(var t=1;t<n.length-1;){if(n[t-1][0]==je&&n[t+1][0]==je){var r=n[t-1][1],o=n[t][1],s=n[t+1][1],i=this.diff_commonSuffix(r,o);if(i){var a=o.substring(o.length-i);r=r.substring(0,r.length-i),o=a+o.substring(0,o.length-i),s=a+s}for(var l=r,c=o,u=s,f=e(r,o)+e(o,s);o.charAt(0)===s.charAt(0);){r+=o.charAt(0),o=o.substring(1)+s.charAt(0),s=s.substring(1);var d=e(r,o)+e(o,s);d>=f&&(f=d,l=r,c=o,u=s)}n[t-1][1]!=l&&(l?n[t-1][1]=l:(n.splice(t-1,1),t--),n[t][1]=c,u?n[t+1][1]=u:(n.splice(t+1,1),t--))}t++}};fe.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;fe.whitespaceRegex_=/\s/;fe.linebreakRegex_=/[\r\n]/;fe.blanklineEndRegex_=/\n\r?\n$/;fe.blanklineStartRegex_=/^\r?\n\r?\n/;fe.prototype.diff_cleanupEfficiency=function(n){for(var e=!1,t=[],r=0,o=null,s=0,i=!1,a=!1,l=!1,c=!1;s<n.length;)n[s][0]==je?(n[s][1].length<this.Diff_EditCost&&(l||c)?(t[r++]=s,i=l,a=c,o=n[s][1]):(r=0,o=null),l=c=!1):(n[s][0]==lt?c=!0:l=!0,o&&(i&&a&&l&&c||o.length<this.Diff_EditCost/2&&i+a+l+c==3)&&(n.splice(t[r-1],0,new fe.Diff(lt,o)),n[t[r-1]+1][0]=dt,r--,o=null,i&&a?(l=c=!0,r=0):(r--,s=r>0?t[r-1]:-1,l=c=!1),e=!0)),s++;e&&this.diff_cleanupMerge(n)};fe.prototype.diff_cleanupMerge=function(n){n.push(new fe.Diff(je,""));for(var e=0,t=0,r=0,o="",s="",i;e<n.length;)switch(n[e][0]){case dt:r++,s+=n[e][1],e++;break;case lt:t++,o+=n[e][1],e++;break;case je:t+r>1?(t!==0&&r!==0&&(i=this.diff_commonPrefix(s,o),i!==0&&(e-t-r>0&&n[e-t-r-1][0]==je?n[e-t-r-1][1]+=s.substring(0,i):(n.splice(0,0,new fe.Diff(je,s.substring(0,i))),e++),s=s.substring(i),o=o.substring(i)),i=this.diff_commonSuffix(s,o),i!==0&&(n[e][1]=s.substring(s.length-i)+n[e][1],s=s.substring(0,s.length-i),o=o.substring(0,o.length-i))),e-=t+r,n.splice(e,t+r),o.length&&(n.splice(e,0,new fe.Diff(lt,o)),e++),s.length&&(n.splice(e,0,new fe.Diff(dt,s)),e++),e++):e!==0&&n[e-1][0]==je?(n[e-1][1]+=n[e][1],n.splice(e,1)):e++,r=0,t=0,o="",s="";break}n[n.length-1][1]===""&&n.pop();var a=!1;for(e=1;e<n.length-1;)n[e-1][0]==je&&n[e+1][0]==je&&(n[e][1].substring(n[e][1].length-n[e-1][1].length)==n[e-1][1]?(n[e][1]=n[e-1][1]+n[e][1].substring(0,n[e][1].length-n[e-1][1].length),n[e+1][1]=n[e-1][1]+n[e+1][1],n.splice(e-1,1),a=!0):n[e][1].substring(0,n[e+1][1].length)==n[e+1][1]&&(n[e-1][1]+=n[e+1][1],n[e][1]=n[e][1].substring(n[e+1][1].length)+n[e+1][1],n.splice(e+1,1),a=!0)),e++;a&&this.diff_cleanupMerge(n)};fe.prototype.diff_xIndex=function(n,e){var t=0,r=0,o=0,s=0,i;for(i=0;i<n.length&&(n[i][0]!==dt&&(t+=n[i][1].length),n[i][0]!==lt&&(r+=n[i][1].length),!(t>e));i++)o=t,s=r;return n.length!=i&&n[i][0]===lt?s:s+(e-o)};fe.prototype.diff_prettyHtml=function(n){for(var e=[],t=/&/g,r=/</g,o=/>/g,s=/\n/g,i=0;i<n.length;i++){var a=n[i][0],l=n[i][1],c=l.replace(t,"&").replace(r,"<").replace(o,">").replace(s,"¶<br>");switch(a){case dt:e[i]='<ins style="background:#e6ffe6;">'+c+"</ins>";break;case lt:e[i]='<del style="background:#ffe6e6;">'+c+"</del>";break;case je:e[i]="<span>"+c+"</span>";break}}return e.join("")};fe.prototype.diff_text1=function(n){for(var e=[],t=0;t<n.length;t++)n[t][0]!==dt&&(e[t]=n[t][1]);return e.join("")};fe.prototype.diff_text2=function(n){for(var e=[],t=0;t<n.length;t++)n[t][0]!==lt&&(e[t]=n[t][1]);return e.join("")};fe.prototype.diff_levenshtein=function(n){for(var e=0,t=0,r=0,o=0;o<n.length;o++){var s=n[o][0],i=n[o][1];switch(s){case dt:t+=i.length;break;case lt:r+=i.length;break;case je:e+=Math.max(t,r),t=0,r=0;break}}return e+=Math.max(t,r),e};fe.prototype.diff_toDelta=function(n){for(var e=[],t=0;t<n.length;t++)switch(n[t][0]){case dt:e[t]="+"+encodeURI(n[t][1]);break;case lt:e[t]="-"+n[t][1].length;break;case je:e[t]="="+n[t][1].length;break}return e.join(" ").replace(/%20/g," ")};fe.prototype.diff_fromDelta=function(n,e){for(var t=[],r=0,o=0,s=e.split(/\t/g),i=0;i<s.length;i++){var a=s[i].substring(1);switch(s[i].charAt(0)){case"+":try{t[r++]=new fe.Diff(dt,decodeURI(a))}catch(u){throw new Error("Illegal escape in diff_fromDelta: "+a)}break;case"-":case"=":var l=parseInt(a,10);if(isNaN(l)||l<0)throw new Error("Invalid number in diff_fromDelta: "+a);var c=n.substring(o,o+=l);s[i].charAt(0)=="="?t[r++]=new fe.Diff(je,c):t[r++]=new fe.Diff(lt,c);break;default:if(s[i])throw new Error("Invalid diff operation in diff_fromDelta: "+s[i])}}if(o!=n.length)throw new Error("Delta length ("+o+") does not equal source text length ("+n.length+").");return t};fe.prototype.match_main=function(n,e,t){if(n==null||e==null||t==null)throw new Error("Null input. (match_main)");return t=Math.max(0,Math.min(t,n.length)),n==e?0:n.length?n.substring(t,t+e.length)==e?t:this.match_bitap_(n,e,t):-1};fe.prototype.match_bitap_=function(n,e,t){if(e.length>this.Match_MaxBits)throw new Error("Pattern too long for this browser.");var r=this.match_alphabet_(e),o=this;function s(S,M){var E=S/e.length,U=Math.abs(t-M);return o.Match_Distance?E+U/o.Match_Distance:U?1:E}var i=this.Match_Threshold,a=n.indexOf(e,t);a!=-1&&(i=Math.min(s(0,a),i),a=n.lastIndexOf(e,t+e.length),a!=-1&&(i=Math.min(s(0,a),i)));var l=1<<e.length-1;a=-1;for(var c,u,f=e.length+n.length,d,p=0;p<e.length;p++){for(c=0,u=f;c<u;)s(p,t+u)<=i?c=u:f=u,u=Math.floor((f-c)/2+c);f=u;var m=Math.max(1,t-u+1),y=Math.min(t+u,n.length)+e.length,g=Array(y+2);g[y+1]=(1<<p)-1;for(var I=y;I>=m;I--){var L=r[n.charAt(I-1)];if(p===0?g[I]=(g[I+1]<<1|1)&L:g[I]=(g[I+1]<<1|1)&L|((d[I+1]|d[I])<<1|1)|d[I+1],g[I]&l){var C=s(p,I-1);if(C<=i)if(i=C,a=I-1,a>t)m=Math.max(1,2*t-a);else break}}if(s(p+1,t)>i)break;d=g}return a};fe.prototype.match_alphabet_=function(n){for(var e={},t=0;t<n.length;t++)e[n.charAt(t)]=0;for(var t=0;t<n.length;t++)e[n.charAt(t)]|=1<<n.length-t-1;return e};fe.prototype.patch_addContext_=function(n,e){if(e.length!=0){if(n.start2===null)throw Error("patch not initialized");for(var t=e.substring(n.start2,n.start2+n.length1),r=0;e.indexOf(t)!=e.lastIndexOf(t)&&t.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)r+=this.Patch_Margin,t=e.substring(n.start2-r,n.start2+n.length1+r);r+=this.Patch_Margin;var o=e.substring(n.start2-r,n.start2);o&&n.diffs.unshift(new fe.Diff(je,o));var s=e.substring(n.start2+n.length1,n.start2+n.length1+r);s&&n.diffs.push(new fe.Diff(je,s)),n.start1-=o.length,n.start2-=o.length,n.length1+=o.length+s.length,n.length2+=o.length+s.length}};fe.prototype.patch_make=function(n,e,t){var r,o;if(typeof n=="string"&&typeof e=="string"&&typeof t=="undefined")r=n,o=this.diff_main(r,e,!0),o.length>2&&(this.diff_cleanupSemantic(o),this.diff_cleanupEfficiency(o));else if(n&&typeof n=="object"&&typeof e=="undefined"&&typeof t=="undefined")o=n,r=this.diff_text1(o);else if(typeof n=="string"&&e&&typeof e=="object"&&typeof t=="undefined")r=n,o=e;else if(typeof n=="string"&&typeof e=="string"&&t&&typeof t=="object")r=n,o=t;else throw new Error("Unknown call format to patch_make.");if(o.length===0)return[];for(var s=[],i=new fe.patch_obj,a=0,l=0,c=0,u=r,f=r,d=0;d<o.length;d++){var p=o[d][0],m=o[d][1];switch(!a&&p!==je&&(i.start1=l,i.start2=c),p){case dt:i.diffs[a++]=o[d],i.length2+=m.length,f=f.substring(0,c)+m+f.substring(c);break;case lt:i.length1+=m.length,i.diffs[a++]=o[d],f=f.substring(0,c)+f.substring(c+m.length);break;case je:m.length<=2*this.Patch_Margin&&a&&o.length!=d+1?(i.diffs[a++]=o[d],i.length1+=m.length,i.length2+=m.length):m.length>=2*this.Patch_Margin&&a&&(this.patch_addContext_(i,u),s.push(i),i=new fe.patch_obj,a=0,u=f,l=c);break}p!==dt&&(l+=m.length),p!==lt&&(c+=m.length)}return a&&(this.patch_addContext_(i,u),s.push(i)),s};fe.prototype.patch_deepCopy=function(n){for(var e=[],t=0;t<n.length;t++){var r=n[t],o=new fe.patch_obj;o.diffs=[];for(var s=0;s<r.diffs.length;s++)o.diffs[s]=new fe.Diff(r.diffs[s][0],r.diffs[s][1]);o.start1=r.start1,o.start2=r.start2,o.length1=r.length1,o.length2=r.length2,e[t]=o}return e};fe.prototype.patch_apply=function(n,e){if(n.length==0)return[e,[]];n=this.patch_deepCopy(n);var t=this.patch_addPadding(n);e=t+e+t,this.patch_splitMax(n);for(var r=0,o=[],s=0;s<n.length;s++){var i=n[s].start2+r,a=this.diff_text1(n[s].diffs),l,c=-1;if(a.length>this.Match_MaxBits?(l=this.match_main(e,a.substring(0,this.Match_MaxBits),i),l!=-1&&(c=this.match_main(e,a.substring(a.length-this.Match_MaxBits),i+a.length-this.Match_MaxBits),(c==-1||l>=c)&&(l=-1))):l=this.match_main(e,a,i),l==-1)o[s]=!1,r-=n[s].length2-n[s].length1;else{o[s]=!0,r=l-i;var u;if(c==-1?u=e.substring(l,l+a.length):u=e.substring(l,c+this.Match_MaxBits),a==u)e=e.substring(0,l)+this.diff_text2(n[s].diffs)+e.substring(l+a.length);else{var f=this.diff_main(a,u,!1);if(a.length>this.Match_MaxBits&&this.diff_levenshtein(f)/a.length>this.Patch_DeleteThreshold)o[s]=!1;else{this.diff_cleanupSemanticLossless(f);for(var d=0,p,m=0;m<n[s].diffs.length;m++){var y=n[s].diffs[m];y[0]!==je&&(p=this.diff_xIndex(f,d)),y[0]===dt?e=e.substring(0,l+p)+y[1]+e.substring(l+p):y[0]===lt&&(e=e.substring(0,l+p)+e.substring(l+this.diff_xIndex(f,d+y[1].length))),y[0]!==lt&&(d+=y[1].length)}}}}}return e=e.substring(t.length,e.length-t.length),[e,o]};fe.prototype.patch_addPadding=function(n){for(var e=this.Patch_Margin,t="",r=1;r<=e;r++)t+=String.fromCharCode(r);for(var r=0;r<n.length;r++)n[r].start1+=e,n[r].start2+=e;var o=n[0],s=o.diffs;if(s.length==0||s[0][0]!=je)s.unshift(new fe.Diff(je,t)),o.start1-=e,o.start2-=e,o.length1+=e,o.length2+=e;else if(e>s[0][1].length){var i=e-s[0][1].length;s[0][1]=t.substring(s[0][1].length)+s[0][1],o.start1-=i,o.start2-=i,o.length1+=i,o.length2+=i}if(o=n[n.length-1],s=o.diffs,s.length==0||s[s.length-1][0]!=je)s.push(new fe.Diff(je,t)),o.length1+=e,o.length2+=e;else if(e>s[s.length-1][1].length){var i=e-s[s.length-1][1].length;s[s.length-1][1]+=t.substring(0,i),o.length1+=i,o.length2+=i}return t};fe.prototype.patch_splitMax=function(n){for(var e=this.Match_MaxBits,t=0;t<n.length;t++)if(!(n[t].length1<=e)){var r=n[t];n.splice(t--,1);for(var o=r.start1,s=r.start2,i="";r.diffs.length!==0;){var a=new fe.patch_obj,l=!0;for(a.start1=o-i.length,a.start2=s-i.length,i!==""&&(a.length1=a.length2=i.length,a.diffs.push(new fe.Diff(je,i)));r.diffs.length!==0&&a.length1<e-this.Patch_Margin;){var c=r.diffs[0][0],u=r.diffs[0][1];c===dt?(a.length2+=u.length,s+=u.length,a.diffs.push(r.diffs.shift()),l=!1):c===lt&&a.diffs.length==1&&a.diffs[0][0]==je&&u.length>2*e?(a.length1+=u.length,o+=u.length,l=!1,a.diffs.push(new fe.Diff(c,u)),r.diffs.shift()):(u=u.substring(0,e-a.length1-this.Patch_Margin),a.length1+=u.length,o+=u.length,c===je?(a.length2+=u.length,s+=u.length):l=!1,a.diffs.push(new fe.Diff(c,u)),u==r.diffs[0][1]?r.diffs.shift():r.diffs[0][1]=r.diffs[0][1].substring(u.length))}i=this.diff_text2(a.diffs),i=i.substring(i.length-this.Patch_Margin);var f=this.diff_text1(r.diffs).substring(0,this.Patch_Margin);f!==""&&(a.length1+=f.length,a.length2+=f.length,a.diffs.length!==0&&a.diffs[a.diffs.length-1][0]===je?a.diffs[a.diffs.length-1][1]+=f:a.diffs.push(new fe.Diff(je,f))),l||n.splice(++t,0,a)}}};fe.prototype.patch_toText=function(n){for(var e=[],t=0;t<n.length;t++)e[t]=n[t];return e.join("")};fe.prototype.patch_fromText=function(n){var e=[];if(!n)return e;for(var t=n.split(`
|
|
`),r=0,o=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;r<t.length;){var s=t[r].match(o);if(!s)throw new Error("Invalid patch string: "+t[r]);var i=new fe.patch_obj;for(e.push(i),i.start1=parseInt(s[1],10),s[2]===""?(i.start1--,i.length1=1):s[2]=="0"?i.length1=0:(i.start1--,i.length1=parseInt(s[2],10)),i.start2=parseInt(s[3],10),s[4]===""?(i.start2--,i.length2=1):s[4]=="0"?i.length2=0:(i.start2--,i.length2=parseInt(s[4],10)),r++;r<t.length;){var a=t[r].charAt(0);try{var l=decodeURI(t[r].substring(1))}catch(c){throw new Error("Illegal escape in patch_fromText: "+l)}if(a=="-")i.diffs.push(new fe.Diff(lt,l));else if(a=="+")i.diffs.push(new fe.Diff(dt,l));else if(a==" ")i.diffs.push(new fe.Diff(je,l));else{if(a=="@")break;if(a!=="")throw new Error('Invalid patch mode "'+a+'" in: '+l)}r++}}return e};fe.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0};fe.patch_obj.prototype.toString=function(){var n,e;this.length1===0?n=this.start1+",0":this.length1==1?n=this.start1+1:n=this.start1+1+","+this.length1,this.length2===0?e=this.start2+",0":this.length2==1?e=this.start2+1:e=this.start2+1+","+this.length2;for(var t=["@@ -"+n+" +"+e+` @@
|
|
`],r,o=0;o<this.diffs.length;o++){switch(this.diffs[o][0]){case dt:r="+";break;case lt:r="-";break;case je:r=" ";break}t[o+1]=r+encodeURI(this.diffs[o][1])+`
|
|
`}return t.join("").replace(/%20/g," ")};Vs.exports=fe;Vs.exports.diff_match_patch=fe;Vs.exports.DIFF_DELETE=lt;Vs.exports.DIFF_INSERT=dt;Vs.exports.DIFF_EQUAL=je});var RD={};uu(RD,{default:()=>au});module.exports=Y1(RD);var tt=require("obsidian"),w1=require("obsidian"),_1=Do(An());var nt=require("obsidian");var qt=()=>new Map,ga=n=>{let e=qt();return n.forEach((t,r)=>{e.set(r,t)}),e},kr=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},hh=(n,e)=>{let t=[];for(let[r,o]of n)t.push(e(o,r));return t},gh=(n,e)=>{for(let[t,r]of n)if(e(r,t))return!0;return!1};var Dr=()=>new Set;var ba=n=>n[n.length-1];var yh=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},Gr=Array.from;var fu=Array.isArray;var va=class{constructor(){this._observers=qt()}on(e,t){return kr(this._observers,e,Dr).add(t),t}once(e,t){let r=(...o)=>{this.off(e,r),t(...o)};this.on(e,r)}off(e,t){let r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return Gr((this._observers.get(e)||qt()).values()).forEach(r=>r(...t))}destroy(){this._observers=qt()}},on=class{constructor(){this._observers=qt()}on(e,t){kr(this._observers,e,Dr).add(t)}once(e,t){let r=(...o)=>{this.off(e,r),t(...o)};this.on(e,r)}off(e,t){let r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return Gr((this._observers.get(e)||qt()).values()).forEach(r=>r(...t))}destroy(){this._observers=qt()}};var lr=Math.floor;var ls=Math.abs;var nn=(n,e)=>n<e?n:e,Jr=(n,e)=>n>e?n:e,ND=Number.isNaN,bh=Math.pow;var xa=n=>n!==0?n<0:1/n<0;var pu=Number.MAX_SAFE_INTEGER,BD=Number.MIN_SAFE_INTEGER,VD=1<<31;var vh=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&lr(n)===n),HD=Number.isNaN,qD=Number.parseInt;var mu=String.fromCharCode,jD=String.fromCodePoint,zD=mu(65535),Z1=n=>n.toLowerCase(),X1=/^\s*/g,e0=n=>n.replace(X1,""),t0=/([A-Z])/g,hu=(n,e)=>e0(n.replace(t0,t=>`${e}${Z1(t)}`));var r0=n=>{let e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let o=0;o<t;o++)r[o]=e.codePointAt(o);return r},us=typeof TextEncoder!="undefined"?new TextEncoder:null,o0=n=>us.encode(n),wh=us?o0:r0;var cs=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});cs&&cs.decode(new Uint8Array).length===1&&(cs=null);var En=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ut=()=>new En;var Sa=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e};var ut=n=>{let e=new Uint8Array(Sa(n)),t=0;for(let r=0;r<n.bufs.length;r++){let o=n.bufs[r];e.set(o,t),t+=o.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},n0=(n,e)=>{let t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(Jr(t,e)*2),n.cpos=0)},jt=(n,e)=>{let t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e};var ka=jt;var Fe=(n,e)=>{for(;e>127;)jt(n,128|127&e),e=lr(e/128);jt(n,127&e)},Ia=(n,e)=>{let t=xa(e);for(t&&(e=-e),jt(n,(e>63?128:0)|(t?64:0)|63&e),e=lr(e/64);e>0;)jt(n,(e>127?128:0)|127&e),e=lr(e/128)},gu=new Uint8Array(3e4),s0=gu.length/3,i0=(n,e)=>{if(e.length<s0){let t=us.encodeInto(e,gu).written||0;Fe(n,t);for(let r=0;r<t;r++)jt(n,gu[r])}else wt(n,wh(e))},a0=(n,e)=>{let t=unescape(encodeURIComponent(e)),r=t.length;Fe(n,r);for(let o=0;o<r;o++)jt(n,t.codePointAt(o))},Ro=us&&us.encodeInto?i0:a0;var di=(n,e)=>{let t=n.cbuf.length,r=n.cpos,o=nn(t-r,e.length),s=e.length-o;n.cbuf.set(e.subarray(0,o),r),n.cpos+=o,s>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(Jr(t*2,s)),n.cbuf.set(e.subarray(o)),n.cpos=s)},wt=(n,e)=>{Fe(n,e.byteLength),di(n,e)},yu=(n,e)=>{n0(n,e);let t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},l0=(n,e)=>yu(n,4).setFloat32(0,e,!1),c0=(n,e)=>yu(n,8).setFloat64(0,e,!1),u0=(n,e)=>yu(n,8).setBigInt64(0,e,!1);var Sh=new DataView(new ArrayBuffer(4)),f0=n=>(Sh.setFloat32(0,n),Sh.getFloat32(0)===n),ds=(n,e)=>{switch(typeof e){case"string":jt(n,119),Ro(n,e);break;case"number":vh(e)&&ls(e)<=2147483647?(jt(n,125),Ia(n,e)):f0(e)?(jt(n,124),l0(n,e)):(jt(n,123),c0(n,e));break;case"bigint":jt(n,122),u0(n,e);break;case"object":if(e===null)jt(n,126);else if(fu(e)){jt(n,117),Fe(n,e.length);for(let t=0;t<e.length;t++)ds(n,e[t])}else if(e instanceof Uint8Array)jt(n,116),wt(n,e);else{jt(n,118);let t=Object.keys(e);Fe(n,t.length);for(let r=0;r<t.length;r++){let o=t[r];Ro(n,o),ds(n,e[o])}}break;case"boolean":jt(n,e?120:121);break;default:jt(n,127)}},fi=class extends En{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Fe(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}};var kh=n=>{n.count>0&&(Ia(n.encoder,n.count===1?n.s:-n.s),n.count>1&&Fe(n.encoder,n.count-2))},Pn=class{constructor(){this.encoder=new En,this.s=0,this.count=0}write(e){this.s===e?this.count++:(kh(this),this.count=1,this.s=e)}toUint8Array(){return kh(this),ut(this.encoder)}};var Ih=n=>{if(n.count>0){let e=n.diff*2+(n.count===1?0:1);Ia(n.encoder,e),n.count>1&&Fe(n.encoder,n.count-2)}},ps=class{constructor(){this.encoder=new En,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ih(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ih(this),ut(this.encoder)}},_a=class{constructor(){this.sarr=[],this.s="",this.lensE=new Pn}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){let e=new En;return this.sarr.push(this.s),this.s="",Ro(e,this.sarr.join("")),di(e,this.lensE.toUint8Array()),ut(e)}};var Ur=n=>new Error(n),Yr=()=>{throw Ur("Method unimplemented")},Or=()=>{throw Ur("Unexpected case")};var Ch=Ur("Unexpected end of array"),Lh=Ur("Integer out of Range"),ms=class{constructor(e){this.arr=e,this.pos=0}},Ir=n=>new ms(n),Mh=n=>n.pos!==n.arr.length;var d0=(n,e)=>{let t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Ot=n=>d0(n,Oe(n));var Dn=n=>n.arr[n.pos++];var Oe=n=>{let e=0,t=1,r=n.arr.length;for(;n.pos<r;){let o=n.arr[n.pos++];if(e=e+(o&127)*t,t*=128,o<128)return e;if(e>pu)throw Lh}throw Ch},Ma=n=>{let e=n.arr[n.pos++],t=e&63,r=64,o=(e&64)>0?-1:1;if((e&128)===0)return o*t;let s=n.arr.length;for(;n.pos<s;){if(e=n.arr[n.pos++],t=t+(e&127)*r,r*=128,e<128)return o*t;if(t>pu)throw Lh}throw Ch};var p0=n=>{let e=Oe(n);if(e===0)return"";{let t=String.fromCodePoint(Dn(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(Dn(n));else for(;e>0;){let r=e<1e4?e:1e4,o=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,o),e-=r}return decodeURIComponent(escape(t))}},m0=n=>cs.decode(Ot(n)),Qr=cs?m0:p0;var vu=(n,e)=>{let t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},h0=n=>vu(n,4).getFloat32(0,!1),g0=n=>vu(n,8).getFloat64(0,!1),y0=n=>vu(n,8).getBigInt64(0,!1);var b0=[n=>{},n=>null,Ma,h0,g0,y0,n=>!1,n=>!0,Qr,n=>{let e=Oe(n),t={};for(let r=0;r<e;r++){let o=Qr(n);t[o]=hs(n)}return t},n=>{let e=Oe(n),t=[];for(let r=0;r<e;r++)t.push(hs(n));return t},Ot],hs=n=>b0[127-Dn(n)](n),pi=class extends ms{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Mh(this)?this.count=Oe(this)+1:this.count=-1),this.count--,this.s}};var Rn=class extends ms{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ma(this);let e=xa(this.s);this.count=1,e&&(this.s=-this.s,this.count=Oe(this)+2)}return this.count--,this.s}};var gs=class extends ms{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Ma(this),t=e&1;this.diff=lr(e/2),this.count=1,t&&(this.count=Oe(this)+2)}return this.s+=this.diff,this.count--,this.s}},La=class{constructor(e){this.decoder=new Rn(e),this.str=Qr(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};var GD=crypto.subtle,Th=crypto.getRandomValues.bind(crypto);var hi=()=>Th(new Uint32Array(1))[0];var v0="10000000-1000-4000-8000"+-1e11,ys=()=>v0.replace(/[018]/g,n=>(n^hi()&15>>n/4).toString(16));var Zr=Date.now;var Uo=n=>new Promise(n);var x0=Promise.all.bind(Promise);var _u=n=>n===void 0?null:n;var Su=class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},Fh=new Su,ku=!0;try{typeof localStorage!="undefined"&&localStorage&&(Fh=localStorage,ku=!1)}catch(n){}var Ta=Fh,Eh=n=>ku||addEventListener("storage",n),Ph=n=>ku||removeEventListener("storage",n);var Rh=Object.assign,_0=Object.keys,Uh=(n,e)=>{for(let t in n)e(n[t],t)},Oh=(n,e)=>{let t=[];for(let r in n)t.push(e(n[r],r));return t},gi=n=>_0(n).length;var $h=n=>{for(let e in n)return!1;return!0},S0=(n,e)=>{for(let t in n)if(!e(n[t],t))return!1;return!0},Iu=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),Cu=(n,e)=>n===e||gi(n)===gi(e)&&S0(n,(t,r)=>(t!==void 0||Iu(e,r))&&e[r]===t);var yi=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&yi(n,e,t+1)}};var Nh=n=>n,k0=(n,e)=>n===e;var bs=(n,e)=>{if(n==null||e==null)return k0(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(let t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(let t of n.keys())if(!e.has(t)||!bs(n.get(t),e.get(t)))return!1;break}case Object:if(gi(n)!==gi(e))return!1;for(let t in n)if(!Iu(n,t)||!bs(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!bs(n[t],e[t]))return!1;break;default:return!1}return!0},Bh=(n,e)=>e.includes(n);var vs=typeof process!="undefined"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]",Aa=typeof window!="undefined"&&typeof document!="undefined"&&!vs,QD=typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1,po,I0=[],C0=()=>{if(po===void 0)if(vs){po=qt();let n=process.argv,e=null;for(let t=0;t<n.length;t++){let r=n[t];r[0]==="-"?(e!==null&&po.set(e,""),e=r):e!==null?(po.set(e,r),e=null):I0.push(r)}e!==null&&po.set(e,"")}else typeof location=="object"?(po=qt(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){let[e,t]=n.split("=");po.set(`--${hu(e,"-")}`,t),po.set(`-${hu(e,"-")}`,t)}})):po=qt();return po},Tu=n=>C0().has(n);var Au=n=>vs?_u(process.env[n.toUpperCase().replaceAll("-","_")]):_u(Ta.getItem(n));var L0=n=>Tu("--"+n)||Au(n)!==null,ZD=L0("production"),Vh=vs&&Bh(process.env.FORCE_COLOR,["true","1","2"]),Hh=!Tu("no-colors")&&(!vs||process.stdout.isTTY||Vh)&&(!vs||Tu("color")||Vh||Au("COLORTERM")!==null||(Au("TERM")||"").includes("color"));var jh=n=>new Uint8Array(n),M0=(n,e,t)=>new Uint8Array(n,e,t),zh=n=>new Uint8Array(n),T0=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=mu(n[t]);return btoa(e)},A0=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),F0=n=>{let e=atob(n),t=jh(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},E0=n=>{let e=Buffer.from(n,"base64");return M0(e.buffer,e.byteOffset,e.byteLength)},Wh=Aa?T0:A0,Kh=Aa?F0:E0;var Gh=n=>{let e=jh(n.byteLength);return e.set(n),e};var Fu=class{constructor(e,t){this.left=e,this.right=t}},or=(n,e)=>new Fu(n,e);var Yh=(n,e)=>n.forEach(t=>e(t.left,t.right));var mo=typeof document!="undefined"?document:{},P0=n=>mo.createElement(n),D0=()=>mo.createDocumentFragment(),R0=n=>mo.createTextNode(n),XD=typeof DOMParser!="undefined"?new DOMParser:null;var U0=(n,e)=>(Yh(e,(t,r)=>{r===!1?n.removeAttribute(t):r===!0?n.setAttribute(t,""):n.setAttribute(t,r)}),n);var O0=n=>{let e=D0();for(let t=0;t<n.length;t++)Xh(e,n[t]);return e},Qh=(n,e)=>(Xh(n,O0(e)),n);var bi=(n,e=[],t=[])=>Qh(U0(P0(n),e),t);var xs=R0;var Zh=n=>hh(n,(e,t)=>`${t}:${e};`).join("");var Xh=(n,e)=>n.appendChild(e),eR=mo.ELEMENT_NODE,tR=mo.TEXT_NODE,rR=mo.CDATA_SECTION_NODE,oR=mo.COMMENT_NODE,nR=mo.DOCUMENT_NODE,sR=mo.DOCUMENT_TYPE_NODE,iR=mo.DOCUMENT_FRAGMENT_NODE;var ho=Symbol;var vi=ho(),xi=ho(),Pu=ho(),Du=ho(),Ru=ho(),wi=ho(),Uu=ho(),_i=ho(),Ou=ho(),tg=n=>{var o;n.length===1&&((o=n[0])==null?void 0:o.constructor)===Function&&(n=n[0]());let e=[],t=[],r=0;for(;r<n.length;r++){let s=n[r];s===void 0?e.push("undefined"):s.constructor===String||s.constructor===Number?e.push(s):s.constructor===Object&&t.push(JSON.stringify(s))}return t};var aR=Zr();var B0={[vi]:or("font-weight","bold"),[xi]:or("font-weight","normal"),[Pu]:or("color","blue"),[Ru]:or("color","green"),[Du]:or("color","grey"),[wi]:or("color","red"),[Uu]:or("color","purple"),[_i]:or("color","orange"),[Ou]:or("color","black")},V0=n=>{var i;n.length===1&&((i=n[0])==null?void 0:i.constructor)===Function&&(n=n[0]());let e=[],t=[],r=qt(),o=[],s=0;for(;s<n.length;s++){let a=n[s],l=B0[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){let c=Zh(r);s>0||c.length>0?(e.push("%c"+a),t.push(c)):e.push(a)}else break}}for(s>0&&(o=t,o.unshift(e.join("")));s<n.length;s++){let a=n[s];a instanceof Symbol||o.push(a)}return o},H0=Hh?V0:tg,rg=(...n)=>{console.log(...H0(n)),q0.forEach(e=>e.print(n))};var q0=Dr();var og=n=>({[Symbol.iterator](){return this},next:n}),ng=(n,e)=>og(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),Fa=(n,e)=>og(()=>{let{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});var ki=class{constructor(e,t){this.clock=e,this.len=t}},Un=class{constructor(){this.clients=new Map}},vg=(n,e,t)=>e.clients.forEach((r,o)=>{let s=n.doc.store.clients.get(o);for(let i=0;i<r.length;i++){let a=r[i];Mg(n,s,a.clock,a.len,t)}}),G0=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){let o=lr((t+r)/2),s=n[o],i=s.clock;if(i<=e){if(e<i+s.len)return o;t=o+1}else r=o-1}return null},rf=(n,e)=>{let t=n.clients.get(e.client);return t!==void 0&&G0(t,e.clock)!==null},of=n=>{n.clients.forEach(e=>{e.sort((o,s)=>o.clock-s.clock);let t,r;for(t=1,r=1;t<e.length;t++){let o=e[r-1],s=e[t];o.clock+o.len>=s.clock?o.len=Jr(o.len,s.clock+s.len-o.clock):(r<t&&(e[r]=s),r++)}e.length=r})},Nu=n=>{let e=new Un;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,o)=>{if(!e.clients.has(o)){let s=r.slice();for(let i=t+1;i<n.length;i++)yh(s,n[i].clients.get(o)||[]);e.clients.set(o,s)}});return of(e),e},$a=(n,e,t,r)=>{kr(n.clients,e,()=>[]).push(new ki(t,r))},nf=()=>new Un,J0=n=>{let e=nf();return n.clients.forEach((t,r)=>{let o=[];for(let s=0;s<t.length;s++){let i=t[s];if(i.deleted){let a=i.id.clock,l=i.length;if(s+1<t.length)for(let c=t[s+1];s+1<t.length&&c.deleted;c=t[++s+1])l+=c.length;o.push(new ki(a,l))}}o.length>0&&e.clients.set(r,o)}),e},un=(n,e)=>{Fe(n.restEncoder,e.clients.size),Gr(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),Fe(n.restEncoder,t);let o=r.length;Fe(n.restEncoder,o);for(let s=0;s<o;s++){let i=r[s];n.writeDsClock(i.clock),n.writeDsLen(i.len)}})},Ii=n=>{let e=new Un,t=Oe(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();let o=Oe(n.restDecoder),s=Oe(n.restDecoder);if(s>0){let i=kr(e.clients,o,()=>[]);for(let a=0;a<s;a++)i.push(new ki(n.readDsClock(),n.readDsLen()))}}return e},ag=(n,e,t)=>{let r=new Un,o=Oe(n.restDecoder);for(let s=0;s<o;s++){n.resetDsCurVal();let i=Oe(n.restDecoder),a=Oe(n.restDecoder),l=t.clients.get(i)||[],c=Ft(t,i);for(let u=0;u<a;u++){let f=n.readDsClock(),d=f+n.readDsLen();if(f<c){c<d&&$a(r,i,c,d-c);let p=go(l,f),m=l[p];for(!m.deleted&&m.id.clock<f&&(l.splice(p+1,0,Ga(e,m,f-m.id.clock)),p++);p<l.length&&(m=l[p++],m.id.clock<d);)m.deleted||(d<m.id.clock+m.length&&l.splice(p,0,Ga(e,m,d-m.id.clock)),m.delete(e))}else $a(r,i,f,d-f)}}if(r.clients.size>0){let s=new $o;return Fe(s.restEncoder,0),un(s,r),s.toUint8Array()}return null};var xg=hi,Oo=class n extends va{constructor({guid:e=ys(),collectionid:t=null,gc:r=!0,gcFilter:o=()=>!0,meta:s=null,autoLoad:i=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=o,this.clientID=xg(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new qa,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=i,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=Uo(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});let l=()=>Uo(c=>{let u=f=>{(f===void 0||f===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let e=this._item;e!==null&&!this.shouldLoad&&ot(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Gr(this.subdocs).map(e=>e.guid))}transact(e,t=null){return ot(this,e,t)}get(e,t=$t){let r=kr(this.share,e,()=>{let s=new t;return s._integrate(this,null),s}),o=r.constructor;if(t!==$t&&o!==t)if(o===$t){let s=new t;s._map=r._map,r._map.forEach(i=>{for(;i!==null;i=i.left)i.parent=s}),s._start=r._start;for(let i=s._start;i!==null;i=i.right)i.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Cs)}getText(e=""){return this.get(e,Fi)}getMap(e=""){return this.get(e,Ls)}getXmlElement(e=""){return this.get(e,Ei)}getXmlFragment(e=""){return this.get(e,Ms)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){Gr(this.subdocs).forEach(t=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new n({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,ot(e.parent.doc,r=>{let o=t.doc;e.deleted||r.subdocsAdded.add(o),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Ss=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Oe(this.restDecoder)}readDsLen(){return Oe(this.restDecoder)}},Na=class extends Ss{readLeftID(){return We(Oe(this.restDecoder),Oe(this.restDecoder))}readRightID(){return We(Oe(this.restDecoder),Oe(this.restDecoder))}readClient(){return Oe(this.restDecoder)}readInfo(){return Dn(this.restDecoder)}readString(){return Qr(this.restDecoder)}readParentInfo(){return Oe(this.restDecoder)===1}readTypeRef(){return Oe(this.restDecoder)}readLen(){return Oe(this.restDecoder)}readAny(){return hs(this.restDecoder)}readBuf(){return Gh(Ot(this.restDecoder))}readJSON(){return JSON.parse(Qr(this.restDecoder))}readKey(){return Qr(this.restDecoder)}},Bu=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Oe(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Oe(this.restDecoder)+1;return this.dsCurrVal+=e,e}},fn=class extends Bu{constructor(e){super(e),this.keys=[],Oe(e),this.keyClockDecoder=new gs(Ot(e)),this.clientDecoder=new Rn(Ot(e)),this.leftClockDecoder=new gs(Ot(e)),this.rightClockDecoder=new gs(Ot(e)),this.infoDecoder=new pi(Ot(e),Dn),this.stringDecoder=new La(Ot(e)),this.parentInfoDecoder=new pi(Ot(e),Dn),this.typeRefDecoder=new Rn(Ot(e)),this.lenDecoder=new Rn(Ot(e))}readLeftID(){return new cn(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new cn(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return hs(this.restDecoder)}readBuf(){return Ot(this.restDecoder)}readJSON(){return hs(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let t=this.stringDecoder.read();return this.keys.push(t),t}}},ks=class{constructor(){this.restEncoder=Ut()}toUint8Array(){return ut(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Fe(this.restEncoder,e)}writeDsLen(e){Fe(this.restEncoder,e)}},On=class extends ks{writeLeftID(e){Fe(this.restEncoder,e.client),Fe(this.restEncoder,e.clock)}writeRightID(e){Fe(this.restEncoder,e.client),Fe(this.restEncoder,e.clock)}writeClient(e){Fe(this.restEncoder,e)}writeInfo(e){ka(this.restEncoder,e)}writeString(e){Ro(this.restEncoder,e)}writeParentInfo(e){Fe(this.restEncoder,e?1:0)}writeTypeRef(e){Fe(this.restEncoder,e)}writeLen(e){Fe(this.restEncoder,e)}writeAny(e){ds(this.restEncoder,e)}writeBuf(e){wt(this.restEncoder,e)}writeJSON(e){Ro(this.restEncoder,JSON.stringify(e))}writeKey(e){Ro(this.restEncoder,e)}},Ba=class{constructor(){this.restEncoder=Ut(),this.dsCurrVal=0}toUint8Array(){return ut(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Fe(this.restEncoder,t)}writeDsLen(e){e===0&&Or(),Fe(this.restEncoder,e-1),this.dsCurrVal+=e}},$o=class extends Ba{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ps,this.clientEncoder=new Pn,this.leftClockEncoder=new ps,this.rightClockEncoder=new ps,this.infoEncoder=new fi(ka),this.stringEncoder=new _a,this.parentInfoEncoder=new fi(ka),this.typeRefEncoder=new Pn,this.lenEncoder=new Pn}toUint8Array(){let e=Ut();return Fe(e,0),wt(e,this.keyClockEncoder.toUint8Array()),wt(e,this.clientEncoder.toUint8Array()),wt(e,this.leftClockEncoder.toUint8Array()),wt(e,this.rightClockEncoder.toUint8Array()),wt(e,ut(this.infoEncoder)),wt(e,this.stringEncoder.toUint8Array()),wt(e,ut(this.parentInfoEncoder)),wt(e,this.typeRefEncoder.toUint8Array()),wt(e,this.lenEncoder.toUint8Array()),di(e,ut(this.restEncoder)),ut(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){ds(this.restEncoder,e)}writeBuf(e){wt(this.restEncoder,e)}writeJSON(e){ds(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Y0=(n,e,t,r)=>{r=Jr(r,e[0].id.clock);let o=go(e,r);Fe(n.restEncoder,e.length-o),n.writeClient(t),Fe(n.restEncoder,r);let s=e[o];s.write(n,r-s.id.clock);for(let i=o+1;i<e.length;i++)e[i].write(n,0)},sf=(n,e,t)=>{let r=new Map;t.forEach((o,s)=>{Ft(e,s)>o&&r.set(s,o)}),Ja(e).forEach((o,s)=>{t.has(s)||r.set(s,0)}),Fe(n.restEncoder,r.size),Gr(r.entries()).sort((o,s)=>s[0]-o[0]).forEach(([o,s])=>{Y0(n,e.clients.get(o),o,s)})},Q0=(n,e)=>{let t=qt(),r=Oe(n.restDecoder);for(let o=0;o<r;o++){let s=Oe(n.restDecoder),i=new Array(s),a=n.readClient(),l=Oe(n.restDecoder);t.set(a,{i:0,refs:i});for(let c=0;c<s;c++){let u=n.readInfo();switch(31&u){case 0:{let f=n.readLen();i[c]=new cr(We(a,l),f),l+=f;break}case 10:{let f=Oe(n.restDecoder);i[c]=new ur(We(a,l),f),l+=f;break}default:{let f=(u&192)===0,d=new Lt(We(a,l),null,(u&128)===128?n.readLeftID():null,null,(u&64)===64?n.readRightID():null,f?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,f&&(u&32)===32?n.readString():null,Kg(n,u));i[c]=d,l+=d.length}}}}return t},Z0=(n,e,t)=>{let r=[],o=Gr(t.keys()).sort((p,m)=>p-m);if(o.length===0)return null;let s=()=>{if(o.length===0)return null;let p=t.get(o[o.length-1]);for(;p.refs.length===p.i;)if(o.pop(),o.length>0)p=t.get(o[o.length-1]);else return null;return p},i=s();if(i===null)return null;let a=new qa,l=new Map,c=(p,m)=>{let y=l.get(p);(y==null||y>m)&&l.set(p,m)},u=i.refs[i.i++],f=new Map,d=()=>{for(let p of r){let m=p.id.client,y=t.get(m);y?(y.i--,a.clients.set(m,y.refs.slice(y.i)),t.delete(m),y.i=0,y.refs=[]):a.clients.set(m,[p]),o=o.filter(g=>g!==m)}r.length=0};for(;;){if(u.constructor!==ur){let m=kr(f,u.id.client,()=>Ft(e,u.id.client))-u.id.clock;if(m<0)r.push(u),c(u.id.client,u.id.clock-1),d();else{let y=u.getMissing(n,e);if(y!==null){r.push(u);let g=t.get(y)||{refs:[],i:0};if(g.refs.length===g.i)c(y,Ft(e,y)),d();else{u=g.refs[g.i++];continue}}else(m===0||m<u.length)&&(u.integrate(n,m),f.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else{if(i=s(),i===null)break;u=i.refs[i.i++]}}if(a.clients.size>0){let p=new $o;return sf(p,a,new Map),Fe(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},X0=(n,e)=>sf(n,e.doc.store,e.beforeState),eS=(n,e,t,r=new fn(n))=>ot(e,o=>{o.local=!1;let s=!1,i=o.doc,a=i.store,l=Q0(r,i),c=Z0(o,a,l),u=a.pendingStructs;if(u){for(let[d,p]of u.missing)if(p<Ft(a,d)){s=!0;break}if(c){for(let[d,p]of c.missing){let m=u.missing.get(d);(m==null||m>p)&&u.missing.set(d,p)}u.update=ja([u.update,c.update])}}else a.pendingStructs=c;let f=ag(r,o,a);if(a.pendingDs){let d=new fn(Ir(a.pendingDs));Oe(d.restDecoder);let p=ag(d,o,a);f&&p?a.pendingDs=ja([f,p]):a.pendingDs=f||p}else a.pendingDs=f;if(s){let d=a.pendingStructs.update;a.pendingStructs=null,wg(o.doc,d)}},t,!1);var wg=(n,e,t,r=fn)=>{let o=Ir(e);eS(o,n,t,new r(o))},bo=(n,e,t)=>wg(n,e,t,Na),tS=(n,e,t=new Map)=>{sf(n,e.store,t),un(n,J0(e.store))},rS=(n,e=new Uint8Array([0]),t=new $o)=>{let r=_g(e);tS(t,n,r);let o=[t.toUint8Array()];if(n.store.pendingDs&&o.push(n.store.pendingDs),n.store.pendingStructs&&o.push(hS(n.store.pendingStructs.update,e)),o.length>1){if(t.constructor===On)return pS(o.map((s,i)=>i===0?s:yS(s)));if(t.constructor===$o)return ja(o)}return o[0]},Ui=(n,e)=>rS(n,e,new On),oS=n=>{let e=new Map,t=Oe(n.restDecoder);for(let r=0;r<t;r++){let o=Oe(n.restDecoder),s=Oe(n.restDecoder);e.set(o,s)}return e},_g=n=>oS(new Ss(Ir(n))),Sg=(n,e)=>(Fe(n.restEncoder,e.size),Gr(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{Fe(n.restEncoder,t),Fe(n.restEncoder,r)}),n),nS=(n,e)=>Sg(n,Ja(e.store)),sS=(n,e=new Ba)=>(n instanceof Map?Sg(e,n):nS(e,n),e.toUint8Array()),kg=n=>sS(n,new ks),Vu=class{constructor(){this.l=[]}},lg=()=>new Vu,cg=(n,e)=>n.l.push(e),ug=(n,e)=>{let t=n.l,r=t.length;n.l=t.filter(o=>e!==o),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Ig=(n,e,t)=>yi(n.l,[e,t]),cn=class{constructor(e,t){this.client=e,this.clock=t}},_s=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,We=(n,e)=>new cn(n,e);var Cg=n=>{for(let[e,t]of n.doc.share.entries())if(t===n)return e;throw Or()};var Va=class{constructor(e,t=e.getMap("users")){let r=new Map;this.yusers=t,this.doc=e,this.clients=new Map,this.dss=r;let o=(s,i)=>{let a=s.get("ds"),l=s.get("ids"),c=u=>this.clients.set(u,i);a.observe(u=>{u.changes.added.forEach(f=>{f.content.getContent().forEach(d=>{d instanceof Uint8Array&&this.dss.set(i,Nu([this.dss.get(i)||nf(),Ii(new Ss(Ir(d)))]))})})}),this.dss.set(i,Nu(a.map(u=>Ii(new Ss(Ir(u)))))),l.observe(u=>u.changes.added.forEach(f=>f.content.getContent().forEach(c))),l.forEach(c)};t.observe(s=>{s.keysChanged.forEach(i=>o(t.get(i),i))}),t.forEach(o)}setUserMapping(e,t,r,{filter:o=()=>!0}={}){let s=this.yusers,i=s.get(r);i||(i=new Ls,i.set("ids",new Cs),i.set("ds",new Cs),s.set(r,i)),i.get("ids").push([t]),s.observe(a=>{setTimeout(()=>{let l=s.get(r);if(l!==i){i=l,this.clients.forEach((f,d)=>{r===f&&i.get("ids").push([d])});let c=new ks,u=this.dss.get(r);u&&(un(c,u),i.get("ds").push([c.toUint8Array()]))}},0)}),e.on("afterTransaction",a=>{setTimeout(()=>{let l=i.get("ds"),c=a.deleteSet;if(a.local&&c.clients.size>0&&o(a,c)){let u=new ks;un(u,c),l.push([u.toUint8Array()])}})})}getUserByClientId(e){return this.clients.get(e)||null}getUserByDeletedId(e){for(let[t,r]of this.dss.entries())if(rf(r,e))return t;return null}},Ha=class{constructor(e,t,r,o=0){this.type=e,this.tname=t,this.item=r,this.assoc=o}};var af=n=>new Ha(n.type==null?null:We(n.type.client,n.type.clock),n.tname||null,n.item==null?null:We(n.item.client,n.item.clock),n.assoc==null?0:n.assoc),Hu=class{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}},iS=(n,e,t=0)=>new Hu(n,e,t),Ea=(n,e,t)=>{let r=null,o=null;return n._item===null?o=Cg(n):r=We(n._item.id.client,n._item.id.clock),new Ha(r,o,e,t)},lf=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Ea(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Ea(n,We(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Ea(n,r.lastId,t);r=r.right}return Ea(n,null,t)};var cf=(n,e)=>{let t=e.store,r=n.item,o=n.type,s=n.tname,i=n.assoc,a=null,l=0;if(r!==null){if(Ft(t,r.client)<=r.clock)return null;let c=bg(t,r),u=c.item;if(!(u instanceof Lt))return null;if(a=u.parent,a._item===null||!a._item.deleted){l=u.deleted||!u.countable?0:c.diff+(i>=0?0:1);let f=u.left;for(;f!==null;)!f.deleted&&f.countable&&(l+=f.length),f=f.left}}else{if(s!==null)a=e.get(s);else if(o!==null){if(Ft(t,o.client)<=o.clock)return null;let{item:c}=bg(t,o);if(c instanceof Lt&&c.content instanceof yo)a=c.content.type;else return null}else throw Or();i>=0?l=a._length:l=0}return iS(a,l,n.assoc)},uf=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&_s(n.item,e.item)&&_s(n.type,e.type)&&n.assoc===e.assoc,qu=class{constructor(e,t){this.ds=e,this.sv=t}};var aS=(n,e)=>new qu(n,e),gR=aS(nf(),new Map);var ws=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!rf(e.ds,n.id),ju=(n,e)=>{let t=kr(n.meta,ju,Dr),r=n.doc.store;t.has(e)||(e.sv.forEach((o,s)=>{o<Ft(r,s)&&dn(n,We(s,o))}),vg(n,e.ds,o=>{}),t.add(e))};var qa=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ja=n=>{let e=new Map;return n.clients.forEach((t,r)=>{let o=t[t.length-1];e.set(r,o.id.clock+o.length)}),e},Ft=(n,e)=>{let t=n.clients.get(e);if(t===void 0)return 0;let r=t[t.length-1];return r.id.clock+r.length},Lg=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{let r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw Or()}t.push(e)},go=(n,e)=>{let t=0,r=n.length-1,o=n[r],s=o.id.clock;if(s===e)return r;let i=lr(e/(s+o.length-1)*r);for(;t<=r;){if(o=n[i],s=o.id.clock,s<=e){if(e<s+o.length)return i;t=i+1}else r=i-1;i=lr((t+r)/2)}throw Or()},lS=(n,e)=>{let t=n.clients.get(e.client);return t[go(t,e.clock)]},Ra=lS,zu=(n,e,t)=>{let r=go(e,t),o=e[r];return o.id.clock<t&&o instanceof Lt?(e.splice(r+1,0,Ga(n,o,t-o.id.clock)),r+1):r},dn=(n,e)=>{let t=n.doc.store.clients.get(e.client);return t[zu(n,t,e.clock)]},fg=(n,e,t)=>{let r=e.clients.get(t.client),o=go(r,t.clock),s=r[o];return t.clock!==s.id.clock+s.length-1&&s.constructor!==cr&&r.splice(o+1,0,Ga(n,s,t.clock-s.id.clock+1)),s},cS=(n,e,t)=>{let r=n.clients.get(e.id.client);r[go(r,e.id.clock)]=t},Mg=(n,e,t,r,o)=>{if(r===0)return;let s=t+r,i=zu(n,e,t),a;do a=e[i++],s<a.id.clock+a.length&&zu(n,e,s),o(a);while(i<e.length&&e[i].id.clock<s)},Wu=class{constructor(e,t,r){this.doc=e,this.deleteSet=new Un,this.beforeState=Ja(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},dg=(n,e)=>e.deleteSet.clients.size===0&&!gh(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(of(e.deleteSet),X0(n,e),un(n,e.deleteSet),!0),pg=(n,e,t)=>{let r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&kr(n.changed,e,Dr).add(t)},Ua=(n,e)=>{let t=n[e],r=n[e-1],o=e;for(;o>0;t=r,r=n[--o-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof Lt&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}let s=e-o;return s&&n.splice(e+1-s,s),s},uS=(n,e,t)=>{for(let[r,o]of n.clients.entries()){let s=e.clients.get(r);for(let i=o.length-1;i>=0;i--){let a=o[i],l=a.clock+a.len;for(let c=go(s,a.clock),u=s[c];c<s.length&&u.id.clock<l;u=s[++c]){let f=s[c];if(a.clock+a.len<=f.id.clock)break;f instanceof Lt&&f.deleted&&!f.keep&&t(f)&&f.gc(e,!1)}}}},fS=(n,e)=>{n.clients.forEach((t,r)=>{let o=e.clients.get(r);for(let s=t.length-1;s>=0;s--){let i=t[s],a=nn(o.length-1,1+go(o,i.clock+i.len-1));for(let l=a,c=o[l];l>0&&c.id.clock>=i.clock;c=o[l])l-=1+Ua(o,l)}})};var Tg=(n,e)=>{if(e<n.length){let t=n[e],r=t.doc,o=r.store,s=t.deleteSet,i=t._mergeStructs;try{of(s),t.afterState=Ja(t.doc.store),r.emit("beforeObserverCalls",[t,r]);let a=[];t.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,l)})),a.push(()=>{t.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,f)=>u.path.length-f.path.length),Ig(c._dEH,l,t))})}),a.push(()=>r.emit("afterTransaction",[t,r])),yi(a,[]),t._needFormattingCleanup&&MS(t)}finally{r.gc&&uS(s,o,r.gcFilter),fS(s,o),t.afterState.forEach((u,f)=>{let d=t.beforeState.get(f)||0;if(d!==u){let p=o.clients.get(f),m=Jr(go(p,d),1);for(let y=p.length-1;y>=m;)y-=1+Ua(p,y)}});for(let u=i.length-1;u>=0;u--){let{client:f,clock:d}=i[u].id,p=o.clients.get(f),m=go(p,d);m+1<p.length&&Ua(p,m+1)>1||m>0&&Ua(p,m)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(rg(_i,vi,"[yjs] ",xi,wi,"Changed the client-id because another client seems to be using it."),r.clientID=xg()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){let u=new On;dg(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){let u=new $o;dg(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}let{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=t;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):Tg(n,e+1)}}},ot=(n,e,t=null,r=!0)=>{let o=n._transactionCleanups,s=!1,i=null;n._transaction===null&&(s=!0,n._transaction=new Wu(n,t,r),o.push(n._transaction),o.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{i=e(n._transaction)}finally{if(s){let a=n._transaction===o[0];n._transaction=null,a&&Tg(o,0)}}return i};function*dS(n){let e=Oe(n.restDecoder);for(let t=0;t<e;t++){let r=Oe(n.restDecoder),o=n.readClient(),s=Oe(n.restDecoder);for(let i=0;i<r;i++){let a=n.readInfo();if(a===10){let l=Oe(n.restDecoder);yield new ur(We(o,s),l),s+=l}else if((31&a)!==0){let l=(a&192)===0,c=new Lt(We(o,s),null,(a&128)===128?n.readLeftID():null,null,(a&64)===64?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&32)===32?n.readString():null,Kg(n,a));yield c,s+=c.length}else{let l=n.readLen();yield new cr(We(o,s),l),s+=l}}}}var Ci=class{constructor(e,t){this.gen=dS(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===ur);return this.curr}};var Li=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},pS=n=>ja(n,Na,On);var mS=(n,e)=>{if(n.constructor===cr){let{client:t,clock:r}=n.id;return new cr(We(t,r+e),n.length-e)}else if(n.constructor===ur){let{client:t,clock:r}=n.id;return new ur(We(t,r+e),n.length-e)}else{let t=n,{client:r,clock:o}=t.id;return new Lt(We(r,o+e),null,We(r,o+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},ja=(n,e=fn,t=$o)=>{if(n.length===1)return n[0];let r=n.map(u=>new e(Ir(u))),o=r.map(u=>new Ci(u,!0)),s=null,i=new t,a=new Li(i);for(;o=o.filter(d=>d.curr!==null),o.sort((d,p)=>{if(d.curr.id.client===p.curr.id.client){let m=d.curr.id.clock-p.curr.id.clock;return m===0?d.curr.constructor===p.curr.constructor?0:d.curr.constructor===ur?1:-1:m}else return p.curr.id.client-d.curr.id.client}),o.length!==0;){let u=o[0],f=u.curr.id.client;if(s!==null){let d=u.curr,p=!1;for(;d!==null&&d.id.clock+d.length<=s.struct.id.clock+s.struct.length&&d.id.client>=s.struct.id.client;)d=u.next(),p=!0;if(d===null||d.id.client!==f||p&&d.id.clock>s.struct.id.clock+s.struct.length)continue;if(f!==s.struct.id.client)an(a,s.struct,s.offset),s={struct:d,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<d.id.clock)if(s.struct.constructor===ur)s.struct.length=d.id.clock+d.length-s.struct.id.clock;else{an(a,s.struct,s.offset);let m=d.id.clock-s.struct.id.clock-s.struct.length;s={struct:new ur(We(f,s.struct.id.clock+s.struct.length),m),offset:0}}else{let m=s.struct.id.clock+s.struct.length-d.id.clock;m>0&&(s.struct.constructor===ur?s.struct.length-=m:d=mS(d,m)),s.struct.mergeWith(d)||(an(a,s.struct,s.offset),s={struct:d,offset:0},u.next())}}else s={struct:u.curr,offset:0},u.next();for(let d=u.curr;d!==null&&d.id.client===f&&d.id.clock===s.struct.id.clock+s.struct.length&&d.constructor!==ur;d=u.next())an(a,s.struct,s.offset),s={struct:d,offset:0}}s!==null&&(an(a,s.struct,s.offset),s=null),ff(a);let l=r.map(u=>Ii(u)),c=Nu(l);return un(i,c),i.toUint8Array()},hS=(n,e,t=fn,r=$o)=>{let o=_g(e),s=new r,i=new Li(s),a=new t(Ir(n)),l=new Ci(a,!1);for(;l.curr;){let u=l.curr,f=u.id.client,d=o.get(f)||0;if(l.curr.constructor===ur){l.next();continue}if(u.id.clock+u.length>d)for(an(i,u,Jr(d-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)an(i,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=d;)l.next()}ff(i);let c=Ii(a);return un(s,c),s.toUint8Array()};var Ag=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:ut(n.encoder.restEncoder)}),n.encoder.restEncoder=Ut(),n.written=0)},an=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&Ag(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),Fe(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},ff=n=>{Ag(n);let e=n.encoder.restEncoder;Fe(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){let r=n.clientStructs[t];Fe(e,r.written),di(e,r.restEncoder)}},gS=(n,e,t,r)=>{let o=new t(Ir(n)),s=new Ci(o,!1),i=new r,a=new Li(i);for(let c=s.curr;c!==null;c=s.next())an(a,e(c),0);ff(a);let l=Ii(o);return un(i,l),i.toUint8Array()};var yS=n=>gS(n,Nh,fn,On),mg="You must not compute changes after the event-handler fired.",Is=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=bS(this.currentTarget,this.target))}deletes(e){return rf(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ur(mg);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(o=>{if(o!==null){let s=t._map.get(o),i,a;if(this.adds(s)){let l=s.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(s))if(l!==null&&this.deletes(l))i="delete",a=ba(l.content.getContent());else return;else l!==null&&this.deletes(l)?(i="update",a=ba(l.content.getContent())):(i="add",a=void 0)}else if(this.deletes(s))i="delete",a=ba(s.content.getContent());else return;e.set(o,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ur(mg);let t=this.target,r=Dr(),o=Dr(),s=[];if(e={added:r,deleted:o,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null,l=()=>{a&&s.push(a)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,o.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}},bS=(n,e)=>{let t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,o=e._item.parent._start;for(;o!==e._item&&o!==null;)o.deleted||r++,o=o.right;t.unshift(r)}e=e._item.parent}return t},Fg=80,df=0,Ku=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=df++}},vS=n=>{n.timestamp=df++},Eg=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=df++},xS=(n,e,t)=>{if(n.length>=Fg){let r=n.reduce((o,s)=>o.timestamp<s.timestamp?o:s);return Eg(r,e,t),r}else{let r=new Ku(e,t);return n.push(r),r}},Ya=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;let t=n._searchMarker.length===0?null:n._searchMarker.reduce((s,i)=>ls(e-s.index)<ls(e-i.index)?s:i),r=n._start,o=0;for(t!==null&&(r=t.p,o=t.index,vS(t));r.right!==null&&o<e;){if(!r.deleted&&r.countable){if(e<o+r.length)break;o+=r.length}r=r.right}for(;r.left!==null&&o>e;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return t!==null&&ls(t.index-o)<r.parent.length/Fg?(Eg(t,r,o),t):xS(n._searchMarker,r,o)},Mi=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){let o=n[r];if(t>0){let s=o.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(o.index-=s.length);if(s===null||s.marker===!0){n.splice(r,1);continue}o.p=s,s.marker=!0}(e<o.index||t>0&&e===o.index)&&(o.index=Jr(e,o.index+t))}};var Qa=(n,e,t)=>{let r=n,o=e.changedParentTypes;for(;kr(o,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Ig(r._eH,t,e)},$t=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=lg(),this._dEH=lg(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Yr()}clone(){throw Yr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){cg(this._eH,e)}observeDeep(e){cg(this._dEH,e)}unobserve(e){ug(this._eH,e)}unobserveDeep(e){ug(this._dEH,e)}toJSON(){}},Pg=(n,e,t)=>{e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e,o=[],s=n._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){let i=s.content.getContent();if(i.length<=e)e-=i.length;else{for(let a=e;a<i.length&&r>0;a++)o.push(i[a]),r--;e=0}}s=s.right}return o},Dg=n=>{let e=[],t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){let r=t.content.getContent();for(let o=0;o<r.length;o++)e.push(r[o])}t=t.right}return e};var Ti=(n,e)=>{let t=0,r=n._start;for(;r!==null;){if(r.countable&&!r.deleted){let o=r.content.getContent();for(let s=0;s<o.length;s++)e(o[s],t++,n)}r=r.right}},Rg=(n,e)=>{let t=[];return Ti(n,(r,o)=>{t.push(e(r,o,n))}),t},wS=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}let o=t[r++];return t.length<=r&&(t=null),{done:!1,value:o}}}},Ug=(n,e)=>{let t=Ya(n,e),r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},za=(n,e,t,r)=>{let o=t,s=n.doc,i=s.clientID,a=s.store,l=t===null?e._start:t.right,c=[],u=()=>{c.length>0&&(o=new Lt(We(i,Ft(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new Ts(c)),o.integrate(n,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:o=new Lt(We(i,Ft(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new Di(new Uint8Array(f))),o.integrate(n,0);break;case Oo:o=new Lt(We(i,Ft(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new Ri(f)),o.integrate(n,0);break;default:if(f instanceof $t)o=new Lt(We(i,Ft(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new yo(f)),o.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Og=()=>Ur("Length exceeded!"),$g=(n,e,t,r)=>{if(t>e._length)throw Og();if(t===0)return e._searchMarker&&Mi(e._searchMarker,t,r.length),za(n,e,null,r);let o=t,s=Ya(e,t),i=e._start;for(s!==null&&(i=s.p,t-=s.index,t===0&&(i=i.prev,t+=i&&i.countable&&!i.deleted?i.length:0));i!==null;i=i.right)if(!i.deleted&&i.countable){if(t<=i.length){t<i.length&&dn(n,We(i.id.client,i.id.clock+t));break}t-=i.length}return e._searchMarker&&Mi(e._searchMarker,o,r.length),za(n,e,i,r)},_S=(n,e,t)=>{let o=(e._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:e._start}).p;if(o)for(;o.right;)o=o.right;return za(n,e,o,t)},Ng=(n,e,t,r)=>{if(r===0)return;let o=t,s=r,i=Ya(e,t),a=e._start;for(i!==null&&(a=i.p,t-=i.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&dn(n,We(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&dn(n,We(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw Og();e._searchMarker&&Mi(e._searchMarker,o,-s+r)},Wa=(n,e,t)=>{let r=e._map.get(t);r!==void 0&&r.delete(n)},pf=(n,e,t,r)=>{let o=e._map.get(t)||null,s=n.doc,i=s.clientID,a;if(r==null)a=new Ts([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new Ts([r]);break;case Uint8Array:a=new Di(r);break;case Oo:a=new Ri(r);break;default:if(r instanceof $t)a=new yo(r);else throw new Error("Unexpected content type")}new Lt(We(i,Ft(s.store,i)),o,o&&o.lastId,null,null,e,t,a).integrate(n,0)},mf=(n,e)=>{let t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},Bg=n=>{let e={};return n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},Vg=(n,e)=>{let t=n._map.get(e);return t!==void 0&&!t.deleted};var SS=(n,e)=>{let t={};return n._map.forEach((r,o)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&ws(s,e)&&(t[o]=s.content.getContent()[s.length-1])}),t},Pa=n=>ng(n.entries(),e=>!e[1].deleted),Gu=class extends Is{constructor(e,t){super(e,t),this._transaction=t}},Cs=class n extends $t{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new n;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new n}clone(){let e=new n;return e.insert(0,this.toArray().map(t=>t instanceof $t?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),Qa(this,e,new Gu(this,e))}insert(e,t){this.doc!==null?ot(this.doc,r=>{$g(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?ot(this.doc,t=>{_S(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?ot(this.doc,r=>{Ng(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Ug(this,e)}toArray(){return Dg(this)}slice(e=0,t=this.length){return Pg(this,e,t)}toJSON(){return this.map(e=>e instanceof $t?e.toJSON():e)}map(e){return Rg(this,e)}forEach(e){Ti(this,e)}[Symbol.iterator](){return wS(this)}_write(e){e.writeTypeRef(jS)}},kS=n=>new Cs,Ju=class extends Is{constructor(e,t,r){super(e,t),this.keysChanged=r}},Ls=class n extends $t{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,o)=>{this.set(o,r)}),this._prelimContent=null}_copy(){return new n}clone(){let e=new n;return this.forEach((t,r)=>{e.set(r,t instanceof $t?t.clone():t)}),e}_callObserver(e,t){Qa(this,e,new Ju(this,e,t))}toJSON(){let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let o=t.content.getContent()[t.length-1];e[r]=o instanceof $t?o.toJSON():o}}),e}get size(){return[...Pa(this._map)].length}keys(){return Fa(Pa(this._map),e=>e[0])}values(){return Fa(Pa(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Fa(Pa(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ot(this.doc,t=>{Wa(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?ot(this.doc,r=>{pf(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return mf(this,e)}has(e){return Vg(this,e)}clear(){this.doc!==null?ot(this.doc,e=>{this.forEach(function(t,r,o){Wa(e,o,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(zS)}},IS=n=>new Ls,ln=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&Cu(n,e),Ai=class{constructor(e,t,r,o){this.left=e,this.right=t,this.index=r,this.currentAttributes=o}forward(){switch(this.right===null&&Or(),this.right.content.constructor){case Nt:this.right.deleted||As(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},hg=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case Nt:e.right.deleted||As(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&dn(n,We(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},Da=(n,e,t,r)=>{let o=new Map,s=r?Ya(e,t):null;if(s){let i=new Ai(s.p.left,s.p,s.index,o);return hg(n,i,t-s.index)}else{let i=new Ai(null,e._start,0,o);return hg(n,i,t)}},Hg=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Nt&&ln(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();let o=n.doc,s=o.clientID;r.forEach((i,a)=>{let l=t.left,c=t.right,u=new Lt(We(s,Ft(o.store,s)),l,l&&l.lastId,c,c&&c.id,e,null,new Nt(a,i));u.integrate(n,0),t.right=u,t.forward()})},As=(n,e)=>{let{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},qg=(n,e)=>{var t;for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Nt&&ln((t=e[n.right.content.key])!=null?t:null,n.right.content.value)))break;n.forward()}},jg=(n,e,t,r)=>{var a;let o=n.doc,s=o.clientID,i=new Map;for(let l in r){let c=r[l],u=(a=t.currentAttributes.get(l))!=null?a:null;if(!ln(u,c)){i.set(l,u);let{left:f,right:d}=t;t.right=new Lt(We(s,Ft(o.store,s)),f,f&&f.lastId,d,d&&d.id,e,null,new Nt(l,c)),t.right.integrate(n,0),t.forward()}}return i},$u=(n,e,t,r,o)=>{t.currentAttributes.forEach((d,p)=>{o[p]===void 0&&(o[p]=null)});let s=n.doc,i=s.clientID;qg(t,o);let a=jg(n,e,t,o),l=r.constructor===String?new No(r):r instanceof $t?new yo(r):new $n(r),{left:c,right:u,index:f}=t;e._searchMarker&&Mi(e._searchMarker,t.index,l.getLength()),u=new Lt(We(i,Ft(s.store,i)),c,c&&c.lastId,u,u&&u.id,e,null,l),u.integrate(n,0),t.right=u,t.index=f,t.forward(),Hg(n,e,t,a)},gg=(n,e,t,r,o)=>{let s=n.doc,i=s.clientID;qg(t,o);let a=jg(n,e,t,o);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===Nt));){if(!t.right.deleted)switch(t.right.content.constructor){case Nt:{let{key:l,value:c}=t.right.content,u=o[l];if(u!==void 0){if(ln(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}t.right.delete(n)}else t.currentAttributes.set(l,c);break}default:r<t.right.length&&dn(n,We(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
`;t.right=new Lt(We(i,Ft(s.store,i)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new No(l)),t.right.integrate(n,0),t.forward()}Hg(n,e,t,a)},zg=(n,e,t,r,o)=>{var c,u;let s=e,i=qt();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Nt){let f=s.content;i.set(f.key,f)}s=s.right}let a=0,l=!1;for(;e!==s;){if(t===e&&(l=!0),!e.deleted){let f=e.content;switch(f.constructor){case Nt:{let{key:d,value:p}=f,m=(c=r.get(d))!=null?c:null;(i.get(d)!==f||m===p)&&(e.delete(n),a++,!l&&((u=o.get(d))!=null?u:null)===p&&m!==p&&(m===null?o.delete(d):o.set(d,m))),!l&&!e.deleted&&As(o,f);break}}}e=e.right}return a},CS=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Nt){let r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},LS=n=>{let e=0;return ot(n.doc,t=>{let r=n._start,o=n._start,s=qt(),i=ga(s);for(;o;){if(o.deleted===!1)switch(o.content.constructor){case Nt:As(i,o.content);break;default:e+=zg(t,r,o,s,i),s=ga(i),r=o;break}o=o.right}}),e},MS=n=>{let e=new Set,t=n.doc;for(let[r,o]of n.afterState.entries()){let s=n.beforeState.get(r)||0;o!==s&&Mg(n,t.store.clients.get(r),s,o,i=>{!i.deleted&&i.content.constructor===Nt&&i.constructor!==cr&&e.add(i.parent)})}ot(t,r=>{vg(n,n.deleteSet,o=>{if(o instanceof cr||!o.parent._hasFormatting||e.has(o.parent))return;let s=o.parent;o.content.constructor===Nt?e.add(s):CS(r,o)});for(let o of e)LS(o)})},yg=(n,e,t)=>{let r=t,o=ga(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case yo:case $n:case No:t<e.right.length&&dn(n,We(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}s&&zg(n,s,e.right,o,e.currentAttributes);let i=(e.left||e.right).parent;return i._searchMarker&&Mi(i._searchMarker,e.index,-r+t),e},Yu=class extends Is{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(o=>{o===null?this.childListChanged=!0:this.keysChanged.add(o)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];ot(e,r=>{var p,m,y;let o=new Map,s=new Map,i=this.target._start,a=null,l={},c="",u=0,f=0,d=()=>{if(a!==null){let g=null;switch(a){case"delete":f>0&&(g={delete:f}),f=0;break;case"insert":(typeof c=="object"||c.length>0)&&(g={insert:c},o.size>0&&(g.attributes={},o.forEach((I,L)=>{I!==null&&(g.attributes[L]=I)}))),c="";break;case"retain":u>0&&(g={retain:u},$h(l)||(g.attributes=Rh({},l))),u=0;break}g&&t.push(g),a=null}};for(;i!==null;){switch(i.content.constructor){case yo:case $n:this.adds(i)?this.deletes(i)||(d(),a="insert",c=i.content.getContent()[0],d()):this.deletes(i)?(a!=="delete"&&(d(),a="delete"),f+=1):i.deleted||(a!=="retain"&&(d(),a="retain"),u+=1);break;case No:this.adds(i)?this.deletes(i)||(a!=="insert"&&(d(),a="insert"),c+=i.content.str):this.deletes(i)?(a!=="delete"&&(d(),a="delete"),f+=i.length):i.deleted||(a!=="retain"&&(d(),a="retain"),u+=i.length);break;case Nt:{let{key:g,value:I}=i.content;if(this.adds(i)){if(!this.deletes(i)){let L=(p=o.get(g))!=null?p:null;ln(L,I)?I!==null&&i.delete(r):(a==="retain"&&d(),ln(I,(m=s.get(g))!=null?m:null)?delete l[g]:l[g]=I)}}else if(this.deletes(i)){s.set(g,I);let L=(y=o.get(g))!=null?y:null;ln(L,I)||(a==="retain"&&d(),l[g]=L)}else if(!i.deleted){s.set(g,I);let L=l[g];L!==void 0&&(ln(L,I)?L!==null&&i.delete(r):(a==="retain"&&d(),I===null?delete l[g]:l[g]=I))}i.deleted||(a==="insert"&&d(),As(o,i.content));break}}i=i.right}for(d();t.length>0;){let g=t[t.length-1];if(g.retain!==void 0&&g.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},Fi=class n extends $t{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new n}clone(){let e=new n;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let r=new Yu(this,e,t);Qa(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===No&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?ot(this.doc,r=>{let o=new Ai(null,this._start,0,new Map);for(let s=0;s<e.length;s++){let i=e[s];if(i.insert!==void 0){let a=!t&&typeof i.insert=="string"&&s===e.length-1&&o.right===null&&i.insert.slice(-1)===`
|
|
`?i.insert.slice(0,-1):i.insert;(typeof a!="string"||a.length>0)&&$u(r,this,o,a,i.attributes||{})}else i.retain!==void 0?gg(r,this,o,i.retain,i.attributes||{}):i.delete!==void 0&&yg(r,o,i.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){let o=[],s=new Map,i=this.doc,a="",l=this._start;function c(){if(a.length>0){let f={},d=!1;s.forEach((m,y)=>{d=!0,f[y]=m});let p={insert:a};d&&(p.attributes=f),o.push(p),a=""}}let u=()=>{for(;l!==null;){if(ws(l,e)||t!==void 0&&ws(l,t))switch(l.content.constructor){case No:{let f=s.get("ychange");e!==void 0&&!ws(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(c(),s.set("ychange",r?r("removed",l.id):{type:"removed"})):t!==void 0&&!ws(l,t)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(c(),s.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(c(),s.delete("ychange")),a+=l.content.str;break}case yo:case $n:{c();let f={insert:l.content.getContent()[0]};if(s.size>0){let d={};f.attributes=d,s.forEach((p,m)=>{d[m]=p})}o.push(f);break}case Nt:ws(l,e)&&(c(),As(s,l.content));break}l=l.right}c()};return e||t?ot(i,f=>{e&&ju(f,e),t&&ju(f,t),u()},"cleanup"):u(),o}insert(e,t,r){if(t.length<=0)return;let o=this.doc;o!==null?ot(o,s=>{let i=Da(s,this,e,!r);r||(r={},i.currentAttributes.forEach((a,l)=>{r[l]=a})),$u(s,this,i,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){let o=this.doc;o!==null?ot(o,s=>{let i=Da(s,this,e,!r);$u(s,this,i,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;let r=this.doc;r!==null?ot(r,o=>{yg(o,Da(o,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;let o=this.doc;o!==null?ot(o,s=>{let i=Da(s,this,e,!1);i.right!==null&&gg(s,this,i,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?ot(this.doc,t=>{Wa(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?ot(this.doc,r=>{pf(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return mf(this,e)}getAttributes(){return Bg(this)}_write(e){e.writeTypeRef(WS)}},TS=n=>new Fi,Si=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Ei||t.constructor===Ms)&&t._start!==null)e=t._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Ms=class n extends $t{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new n}clone(){let e=new n;return e.insert(0,this.toArray().map(t=>t instanceof $t?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Si(this,e)}querySelector(e){e=e.toUpperCase();let r=new Si(this,o=>o.nodeName&&o.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Gr(new Si(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Qa(this,e,new Qu(this,t,e))}toString(){return Rg(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){let o=e.createDocumentFragment();return r!==void 0&&r._createAssociation(o,this),Ti(this,s=>{o.insertBefore(s.toDOM(e,t,r),null)}),o}insert(e,t){this.doc!==null?ot(this.doc,r=>{$g(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)ot(this.doc,r=>{let o=e&&e instanceof $t?e._item:e;za(r,this,o,t)});else{let r=this._prelimContent,o=e===null?0:r.findIndex(s=>s===e)+1;if(o===0&&e!==null)throw Ur("Reference item not found");r.splice(o,0,...t)}}delete(e,t=1){this.doc!==null?ot(this.doc,r=>{Ng(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Dg(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Ug(this,e)}slice(e=0,t=this.length){return Pg(this,e,t)}forEach(e){Ti(this,e)}_write(e){e.writeTypeRef(GS)}},AS=n=>new Ms,Ei=class n extends Ms{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,o)=>{this.setAttribute(o,r)}),this._prelimAttrs=null}_copy(){return new n(this.nodeName)}clone(){let e=new n(this.nodeName),t=this.getAttributes();return Uh(t,(r,o)=>{typeof r=="string"&&e.setAttribute(o,r)}),e.insert(0,this.toArray().map(r=>r instanceof $t?r.clone():r)),e}toString(){let e=this.getAttributes(),t=[],r=[];for(let a in e)r.push(a);r.sort();let o=r.length;for(let a=0;a<o;a++){let l=r[a];t.push(l+'="'+e[l]+'"')}let s=this.nodeName.toLocaleLowerCase(),i=t.length>0?" "+t.join(" "):"";return`<${s}${i}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?ot(this.doc,t=>{Wa(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?ot(this.doc,r=>{pf(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return mf(this,e)}hasAttribute(e){return Vg(this,e)}getAttributes(e){return e?SS(this,e):Bg(this)}toDOM(e=document,t={},r){let o=e.createElement(this.nodeName),s=this.getAttributes();for(let i in s){let a=s[i];typeof a=="string"&&o.setAttribute(i,a)}return Ti(this,i=>{o.appendChild(i.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(KS),e.writeKey(this.nodeName)}},FS=n=>new Ei(n.readKey()),Qu=class extends Is{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(o=>{o===null?this.childListChanged=!0:this.attributesChanged.add(o)})}},Zu=class n extends Ls{constructor(e){super(),this.hookName=e}_copy(){return new n(this.hookName)}clone(){let e=new n(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){let o=t[this.hookName],s;return o!==void 0?s=o.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(JS),e.writeKey(this.hookName)}},ES=n=>new Zu(n.readKey()),Xu=class n extends Fi{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new n}clone(){let e=new n;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){let o=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(o,this),o}toString(){return this.toDelta().map(e=>{let t=[];for(let o in e.attributes){let s=[];for(let i in e.attributes[o])s.push({key:i,value:e.attributes[o][i]});s.sort((i,a)=>i.key<a.key?-1:1),t.push({nodeName:o,attrs:s})}t.sort((o,s)=>o.nodeName<s.nodeName?-1:1);let r="";for(let o=0;o<t.length;o++){let s=t[o];r+=`<${s.nodeName}`;for(let i=0;i<s.attrs.length;i++){let a=s.attrs[i];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let o=t.length-1;o>=0;o--)r+=`</${t[o].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(YS)}},PS=n=>new Xu,Pi=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Yr()}mergeWith(e){return!1}write(e,t,r){throw Yr()}integrate(e,t){throw Yr()}},DS=0,cr=class extends Pi{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Lg(e.doc.store,this)}write(e,t){e.writeInfo(DS),e.writeLen(this.length-t)}getMissing(e,t){return null}},Di=class n{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new n(this.content)}splice(e){throw Yr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},RS=n=>new Di(n.readBuf()),Ka=class n{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new n(this.len)}splice(e){let t=new n(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){$a(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},US=n=>new Ka(n.readLen()),Wg=(n,e)=>new Oo({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),Ri=class n{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new n(Wg(this.doc.guid,this.opts))}splice(e){throw Yr()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},OS=n=>new Ri(Wg(n.readString(),n.readAny())),$n=class n{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new n(this.embed)}splice(e){throw Yr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},$S=n=>new $n(n.readJSON()),Nt=class n{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new n(this.key,this.value)}splice(e){throw Yr()}mergeWith(e){return!1}integrate(e,t){let r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},NS=n=>new Nt(n.readKey(),n.readJSON()),ef=class n{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new n(this.arr)}splice(e){let t=new n(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let o=t;o<r;o++){let s=this.arr[o];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}},BS=n=>{let e=n.readLen(),t=[];for(let r=0;r<e;r++){let o=n.readString();o==="undefined"?t.push(void 0):t.push(JSON.parse(o))}return new ef(t)},Ts=class n{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new n(this.arr)}splice(e){let t=new n(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let o=t;o<r;o++){let s=this.arr[o];e.writeAny(s)}}getRef(){return 8}},VS=n=>{let e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new Ts(t)},No=class n{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new n(this.str)}splice(e){let t=new n(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",t.str="\uFFFD"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},HS=n=>new No(n.readString()),qS=[kS,IS,TS,FS,AS,ES,PS],jS=0,zS=1,WS=2,KS=3,GS=4,JS=5,YS=6,yo=class n{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new n(this.type._copy())}splice(e){throw Yr()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},QS=n=>new yo(qS[n.readTypeRef()](n)),bg=(n,e)=>{let t=e,r=0,o;do r>0&&(t=We(t.client,t.clock+r)),o=Ra(n,t),r=t.clock-o.id.clock,t=o.redone;while(t!==null&&o instanceof Lt);return{item:o,diff:r}};var Ga=(n,e,t)=>{let{client:r,clock:o}=e.id,s=new Lt(We(r,o+t),e,We(r,o+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=We(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),n._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s};var Lt=class n extends Pi{constructor(e,t,r,o,s,i,a,l){super(e,l.getLength()),this.origin=r,this.left=t,this.right=o,this.rightOrigin=s,this.parent=i,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ft(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ft(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===cn&&this.id.client!==this.parent.client&&this.parent.clock>=Ft(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=fg(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=dn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===cr||this.right&&this.right.constructor===cr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===n&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===n&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===cn){let r=Ra(t,this.parent);r.constructor===cr?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=fg(e,e.doc.store,We(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,o;if(r!==null)o=r.right;else if(this.parentSub!==null)for(o=this.parent._map.get(this.parentSub)||null;o!==null&&o.left!==null;)o=o.left;else o=this.parent._start;let s=new Set,i=new Set;for(;o!==null&&o!==this.right;){if(i.add(o),s.add(o),_s(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,s.clear();else if(_s(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&i.has(Ra(e.doc.store,o.origin)))s.has(Ra(e.doc.store,o.origin))||(r=o,s.clear());else break;o=o.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Lg(e.doc.store,this),this.content.integrate(e,this),pg(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new cr(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:We(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&_s(e.origin,this.lastId)&&this.right===e&&_s(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),$a(e.deleteSet,this.id.client,this.id.clock,this.length),pg(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Or();this.content.gc(e),t?cS(e,this,new cr(this.id,this.length)):this.content=new Ka(this.length)}write(e,t){let r=t>0?We(this.id.client,this.id.clock+t-1):this.origin,o=this.rightOrigin,s=this.parentSub,i=this.content.getRef()&31|(r===null?0:128)|(o===null?0:64)|(s===null?0:32);if(e.writeInfo(i),r!==null&&e.writeLeftID(r),o!==null&&e.writeRightID(o),r===null&&o===null){let a=this.parent;if(a._item!==void 0){let l=a._item;if(l===null){let c=Cg(a);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===cn?(e.writeParentInfo(!1),e.writeLeftID(a)):Or();s!==null&&e.writeString(s)}this.content.write(e,t)}},Kg=(n,e)=>ZS[e&31](n),ZS=[()=>{Or()},US,BS,RS,HS,$S,NS,QS,VS,OS,()=>{Or()}],XS=10,ur=class extends Pi{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){Or()}write(e,t){e.writeInfo(XS),Fe(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Gg=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:{},Jg="__ $YJS$ __";Gg[Jg]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Gg[Jg]=!0;var Bn=n=>Uo((e,t)=>{n.onerror=r=>t(new Error(r.target.error)),n.onsuccess=r=>e(r.target.result)}),Yg=(n,e)=>Uo((t,r)=>{let o=indexedDB.open(n);o.onupgradeneeded=s=>e(s.target.result),o.onerror=s=>r(Ur(s.target.error)),o.onsuccess=s=>{let i=s.target.result;i.onversionchange=()=>{i.close()},t(i)}}),Qg=n=>Bn(indexedDB.deleteDatabase(n)),Zg=(n,e)=>e.forEach(t=>n.createObjectStore.apply(n,t)),Fs=(n,e,t="readwrite")=>{let r=n.transaction(e,t);return e.map(o=>ok(r,o))},hf=(n,e)=>Bn(n.count(e)),Xg=(n,e)=>Bn(n.get(e)),gf=(n,e)=>Bn(n.delete(e)),ey=(n,e,t)=>Bn(n.put(e,t));var Za=(n,e)=>Bn(n.add(e)),ty=(n,e,t)=>Bn(n.getAll(e,t));var ek=(n,e,t)=>{let r=null;return rk(n,e,o=>(r=o,!1),t).then(()=>r)},ry=(n,e=null)=>ek(n,e,"prev");var tk=(n,e)=>Uo((t,r)=>{n.onerror=r,n.onsuccess=async o=>{let s=o.target.result;if(s===null||await e(s)===!1)return t();s.continue()}});var rk=(n,e,t,r="next")=>tk(n.openKeyCursor(e,r),o=>t(o.key)),ok=(n,e)=>n.objectStore(e);var oy=(n,e)=>IDBKeyRange.upperBound(n,e),ny=(n,e)=>IDBKeyRange.lowerBound(n,e);var yf="custom",sy="updates",sk=500,iy=50,ay=(n,e=()=>{},t=()=>{})=>{let[r]=Fs(n.db,[sy]);return ty(r,ny(n._dbref,!1)).then(o=>{n._destroyed||(e(r),ot(n.doc,()=>{o.forEach(s=>bo(n.doc,s))},n,!1))}).then(()=>ry(r).then(o=>{n._dbref=o+1})).then(()=>hf(r).then(o=>{n._dbsize=o})).then(()=>(n._destroyed||t(r),r))},ik=(n,e=!0)=>ay(n).then(t=>{(e||n._dbsize>=iy)&&Za(t,Ui(n.doc)).then(()=>gf(t,oy(n._dbref,!0))).then(()=>hf(t).then(r=>{n._dbsize=r}))});var pn=class extends on{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._serverSynced=void 0,this._origin=void 0,this._db=Yg(e,r=>Zg(r,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=Uo(r=>this.on("synced",()=>r(this))),this._db.then(r=>{this.db=r,ay(this,i=>Za(i,Ui(t)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(r,o)=>{if(this.db&&o!==this){let[s]=Fs(this.db,[sy]);Za(s,r);let i=this.synced?iy:sk;++this._dbsize>=i&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{ik(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}once(e,t){return e==="synced"&&this.synced?(setTimeout(()=>t(this),0),this):super.once(e,t)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{Qg(this.name)})}get(e){return this._db.then(t=>{let[r]=Fs(t,[yf],"readonly");return Xg(r,e)})}set(e,t){return this._db.then(r=>{let[o]=Fs(r,[yf]);return ey(o,t,e)})}del(e){return this._db.then(t=>{let[r]=Fs(t,[yf]);return gf(r,e)})}hasUserData(){return this._dbsize>3}async markServerSynced(){return this._serverSynced=!0,this.set("serverSync",1)}async getServerSynced(){if(this._serverSynced!==void 0)return this._serverSynced;let e=await this.get("serverSync");return this._serverSynced=e===1,this._serverSynced}get hasServerSync(){return this._serverSynced===!0}async setOrigin(e){return this._origin=e,this.set("origin",e)}async getOrigin(){return this._origin!==void 0?this._origin:(this._origin=await this.get("origin"),this._origin)}isReady(e=!1){return this.synced&&(e||this.hasServerSync||this._origin==="local")}async awaitingServerUpdates(){let e=await this.getServerSynced(),t=await this.getOrigin();return!e&&t!=="local"&&!this.hasUserData()}};var Mr=Do(An());var ly=new Map,bf=class{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:Kh(t.newValue||"")}),Eh(this._onChange)}postMessage(e){Ta.setItem(this.room,Wh(zh(e)))}close(){Ph(this._onChange)}},ak=typeof BroadcastChannel=="undefined"?bf:BroadcastChannel,vf=n=>kr(ly,n,()=>{let e=Dr(),t=new ak(n);return t.onmessage=r=>e.forEach(o=>o(r.data,"broadcastchannel")),{bc:t,subs:e}}),cy=(n,e)=>(vf(n).subs.add(e),e),uy=(n,e)=>{let t=vf(n),r=t.subs.delete(e);return r&&t.subs.size===0&&(t.bc.close(),ly.delete(n)),r},Vn=(n,e,t=null)=>{let r=vf(n);r.bc.postMessage(e),r.subs.forEach(o=>o(e,t))};var fy=0,Xa=1,dy=2,el=(n,e)=>{Fe(n,fy);let t=kg(e);wt(n,t)},xf=(n,e,t)=>{Fe(n,Xa),wt(n,Ui(e,t))},ck=(n,e,t)=>xf(e,t,Ot(n)),py=(n,e,t)=>{try{bo(e,Ot(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},my=(n,e)=>{Fe(n,dy),wt(n,e)},uk=py,hy=(n,e,t,r)=>{let o=Oe(n);switch(o){case fy:ck(n,e,t);break;case Xa:py(n,t,r);break;case dy:uk(n,t,r);break;default:throw new Error("Unknown message type")}return o};var dk=0;var gy=(n,e,t)=>{switch(Oe(n)){case dk:t(e,Qr(n))}};var wf=3e4,tl=class extends on{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let t=Zr();this.getLocalState()!==null&&wf/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let r=[];this.meta.forEach((o,s)=>{s!==this.clientID&&wf<=t-o.lastUpdated&&this.states.has(s)&&r.push(s)}),r.length>0&&rl(this,r,"timeout")},lr(wf/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,r=this.meta.get(t),o=r===void 0?0:r.clock+1,s=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:o,lastUpdated:Zr()});let i=[],a=[],l=[],c=[];e===null?c.push(t):s==null?e!=null&&i.push(t):(a.push(t),bs(s,e)||l.push(t)),(i.length>0||l.length>0||c.length>0)&&this.emit("change",[{added:i,updated:l,removed:c},"local"]),this.emit("update",[{added:i,updated:a,removed:c},"local"])}setLocalStateField(e,t){let r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:t})}getStates(){return this.states}},rl=(n,e,t)=>{let r=[];for(let o=0;o<e.length;o++){let s=e[o];if(n.states.has(s)){if(n.states.delete(s),s===n.clientID){let i=n.meta.get(s);n.meta.set(s,{clock:i.clock+1,lastUpdated:Zr()})}r.push(s)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},Es=(n,e,t=n.states)=>{let r=e.length,o=Ut();Fe(o,r);for(let s=0;s<r;s++){let i=e[s],a=t.get(i)||null,l=n.meta.get(i).clock;Fe(o,i),Fe(o,l),Ro(o,JSON.stringify(a))}return ut(o)};var yy=(n,e,t)=>{let r=Ir(e),o=Zr(),s=[],i=[],a=[],l=[],c=Oe(r);for(let u=0;u<c;u++){let f=Oe(r),d=Oe(r),p=JSON.parse(Qr(r)),m=n.meta.get(f),y=n.states.get(f),g=m===void 0?0:m.clock;(g<d||g===d&&p===null&&n.states.has(f))&&(p===null?f===n.clientID&&n.getLocalState()!=null?d++:n.states.delete(f):n.states.set(f,p),n.meta.set(f,{clock:d,lastUpdated:o}),m===void 0&&p!==null?s.push(f):m!==void 0&&p===null?l.push(f):p!==null&&(bs(p,y)||a.push(f),i.push(f)))}(s.length>0||a.length>0||l.length>0)&&n.emit("change",[{added:s,updated:a,removed:l},t]),(s.length>0||i.length>0||l.length>0)&&n.emit("update",[{added:s,updated:i,removed:l},t])};var _f=n=>Oh(n,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");var Hn=0,vy=3,Ps=1,gk=2,Oi=[];Oi[Hn]=(n,e,t,r,o)=>{Fe(n,Hn);let s=hy(e,n,t.doc,t);r&&s===Xa&&!t.synced&&(t.synced=!0)};Oi[vy]=(n,e,t,r,o)=>{Fe(n,Ps),wt(n,Es(t.awareness,Array.from(t.awareness.getStates().keys())))};Oi[Ps]=(n,e,t,r,o)=>{yy(t.awareness,Ot(e),t)};Oi[gk]=(n,e,t,r,o)=>{gy(e,t.doc,(s,i)=>yk(t,i))};var by=3e4,yk=(n,e)=>console.warn(`Permission denied to access ${n.url}.
|
|
${e}`),xy=(n,e,t)=>{let r=Ir(e),o=Ut(),s=Oe(r),i=n.messageHandlers[s];return i?i(o,r,n,t,s):console.error("Unable to compute message"),o},wy=n=>{if(n.shouldConnect&&n.ws===null){let e=new n._WS(n.url);e.binaryType="arraybuffer",n.ws=e,n.wsconnecting=!0,n.wsconnected=!1,n.synced=!1,e.onmessage=t=>{n.wsLastMessageReceived=Zr();let r=xy(n,new Uint8Array(t.data),!0);Sa(r)>1&&e.send(ut(r))},e.onerror=t=>{n.emit("connection-error",[t,n])},e.onclose=t=>{n.emit("connection-close",[t,n]),n.ws=null,n.wsconnecting=!1,n.wsconnected?(n.wsconnected=!1,n.synced=!1,rl(n.awareness,Array.from(n.awareness.getStates().keys()).filter(r=>r!==n.doc.clientID),n),n.emit("status",[{status:"disconnected",intent:n.intent}])):n.wsUnsuccessfulReconnects++,n.canReconnect()&&setTimeout(wy,nn(bh(2,n.wsUnsuccessfulReconnects)*100,n.maxBackoffTime),n)},e.onopen=()=>{n.wsLastMessageReceived=Zr(),n.wsconnecting=!1,n.wsconnected=!0,n.wsUnsuccessfulReconnects=0,n.emit("status",[{status:"connected",intent:n.intent}]);let t=Ut();if(Fe(t,Hn),el(t,n.doc),e.send(ut(t)),n.awareness.getLocalState()!==null){let r=Ut();Fe(r,Ps),wt(r,Es(n.awareness,[n.doc.clientID])),e.send(ut(r))}},n.emit("status",[{status:"connecting",intent:n.intent}])}},Sf=(n,e)=>{let t=n.ws;n.wsconnected&&t&&t.readyState===t.OPEN&&t.send(e),n.bcconnected&&Vn(n.bcChannel,e,n)},ol=class extends on{constructor(e,t,r,{connect:o=!0,awareness:s=new tl(r),params:i={},WebSocketPolyfill:a=WebSocket,resyncInterval:l=-1,maxBackoffTime:c=2500,disableBc:u=!1,maxConnectionErrors:f=3}={}){for(super();e[e.length-1]==="/";)e=e.slice(0,e.length-1);let d=_f(i);this.maxBackoffTime=c,this.bcChannel=e+"/"+t,this.url=e+"/"+t+(d.length===0?"":"?"+d),this.roomname=t,this.doc=r,this._WS=a,this.awareness=s,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Oi.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=o,this.maxConnectionErrors=f,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let p=Ut();Fe(p,Hn),el(p,r),this.ws.send(ut(p))}},l)),this._bcSubscriber=(p,m)=>{if(m!==this){let y=xy(this,new Uint8Array(p),!1);Sa(y)>1&&Vn(this.bcChannel,ut(y),this)}},this._updateHandler=(p,m)=>{if(m!==this){let y=Ut();Fe(y,Hn),my(y,p),Sf(this,ut(y))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:p,updated:m,removed:y},g)=>{let I=p.concat(m).concat(y),L=Ut();Fe(L,Ps),wt(L,Es(s,I)),Sf(this,ut(L))},this._unloadHandler=()=>{rl(this.awareness,[r.clientID],"window unload")},typeof window!="undefined"?window.addEventListener("unload",this._unloadHandler):typeof process!="undefined"&&process.on("exit",this._unloadHandler),s.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{var p;this.wsconnected&&by<Zr()-this.wsLastMessageReceived&&((p=this.ws)==null||p.close())},by/10),o&&this.connect()}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}once(e,t){return e==="synced"&&this._synced?(setTimeout(()=>t(this._synced),0),this):super.once(e,t)}get intent(){return this.shouldConnect?"connected":"disconnected"}get connectionState(){var t,r;let e;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?e="connected":((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?e="connecting":e="disconnected",{status:e,intent:this.intent}}canReconnect(){return!!this.url&&this.shouldConnect&&this.wsUnsuccessfulReconnects<this.maxConnectionErrors}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onclose=null,(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)&&this.ws.close(1e3,"Destroyed"),this.ws=null),this.disconnect(),this.awareness.destroy(),this._observers.clear(),typeof window!="undefined"?(window.removeEventListener("unload",this._unloadHandler),window.clearInterval(this.awareness._checkInterval)):typeof process!="undefined"&&process.off("exit",this._unloadHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(cy(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);let e=Ut();Fe(e,Hn),el(e,this.doc),Vn(this.bcChannel,ut(e),this);let t=Ut();Fe(t,Hn),xf(t,this.doc),Vn(this.bcChannel,ut(t),this);let r=Ut();Fe(r,vy),Vn(this.bcChannel,ut(r),this);let o=Ut();Fe(o,Ps),wt(o,Es(this.awareness,[this.doc.clientID])),Vn(this.bcChannel,ut(o),this)}disconnectBc(){let e=Ut();Fe(e,Ps),wt(e,Es(this.awareness,[this.doc.clientID],new Map)),Sf(this,ut(e)),this.bcconnected&&(uy(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&(this.ws.close(),this.ws=null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(wy(this),this.connectBc())}refreshToken(e,t,r){for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);let s=_f({token:r}),i=e+"/"+t+(s.length===0?"":"?"+s),a=this.url!==i;return a&&(this.url=i,this.wsUnsuccessfulReconnects=0,this.ws&&this.ws.close()),{urlChanged:a,newUrl:i}}hasUrl(e){return this.url===e}};var _y=[{color:"#30bced",light:"#30bced33"},{color:"#6eeb83",light:"#6eeb8333"},{color:"#ffbc42",light:"#ffbc4233"},{color:"#ecd444",light:"#ecd44433"},{color:"#ee6352",light:"#ee635233"},{color:"#9ac2c9",light:"#9ac2c933"},{color:"#8acb88",light:"#8acb8833"},{color:"#1be7ff",light:"#1be7ff33"}],nl=class{constructor(e,t,r,o,s){this.id=e;this.name=t;this.email=r;this.picture=o;this.token=s;this.color=_y[hi()%_y.length]}};var Bt=new WeakMap,Sy=!1;function il(n){Sy=n}var $r={maxFileSize:1024*1024,maxBackups:5,disableConsole:!1,batchInterval:1e3,maxRetries:3,allowStackTraces:!1},nr,sr,sl=[];function ky(n,e,t,r){sr=n,nr=t,r&&($r={...$r,...r}),e.setInterval(If,$r.batchInterval)}async function If(){if(sl.length===0)return;let n=[...sl];sl.length=0;for(let e=0;e<$r.maxRetries;e++)try{await bk();let t=n.map(kf).join(`
|
|
`)+`
|
|
`;await sr.append(nr,t);return}catch(t){console.error(`Failed to write logs (attempt ${e+1}):`,t),e===$r.maxRetries-1&&console.error("Max retries reached. Discarding log entries.")}}async function bk(){let n=await sr.stat(nr);if(n&&n.size>$r.maxFileSize){for(let e=$r.maxBackups;e>0;e--){let t=`${nr}.${e}`,r=`${nr}.${e+1}`;await sr.exists(t)&&(e===$r.maxBackups?await sr.remove(t):await sr.rename(t,r))}await sr.exists(nr)&&await sr.rename(nr,`${nr}.1`),await sr.write(nr,"")}}function kf(n){return`[${n.timestamp}] [${n.level.toUpperCase()}] ${n.message}
|
|
at ${n.callerInfo}`}var vk=["token","authorization","email","key"];function xk(n){if(typeof n=="object"&&n!==null){let e=new WeakSet;try{return JSON.stringify(n,(t,r)=>{var o;if(typeof r=="object"&&r!==null){if(e.has(r))return"[Circular]";e.add(r)}return typeof t=="string"&&vk.some(s=>t.toLowerCase().includes(s.toLowerCase()))?"[REDACTED]":r instanceof Error?{name:r.name,message:r.message,stack:(o=r.stack)==null?void 0:o.split(`
|
|
`).map(s=>s.trim()).join(" ")}:r},2)}catch(t){return t instanceof Error?t instanceof RangeError?`[Complex Object: ${Object.prototype.toString.call(n)}]`:`[Unserializable: ${t.message}]`:"[Unknown Error]"}}return String(n)}function Te(n,e="log"){return(...t)=>{if(Sy){let r=new Date().toISOString(),o=new Error().stack,s=o?o.split(`
|
|
`)[2].trim():"",i=t.map(xk).join(" "),a={timestamp:r,level:e,message:`${n}: ${i}`,callerInfo:s};if(!$r.disableConsole)if($r.allowStackTraces||e==="debug"||e==="log")console[e](kf(a));else{let l={warn:"color: #ff8c00; background: rgba(255, 140, 0, 0.1); font-weight: normal; padding: 1px 4px; border-radius: 2px;",error:"color: #ff5555; background: rgba(255, 85, 85, 0.1); font-weight: normal; padding: 1px 4px; border-radius: 2px;"};console.log(`%c${kf(a)}`,l[e])}sl.push(a)}}}async function al(){let n=[];await sr.exists(nr)&&n.push(nr);for(let e=1;e<=$r.maxBackups;e++){let t=`${nr}.${e}`;await sr.exists(t)&&n.push(t)}return n}async function Iy(){let n=[];if(await sr.exists(nr)){let e=await sr.read(nr);n.push(e)}for(let e=1;e<=$r.maxBackups;e++){let t=`${nr}.${e}`;if(await sr.exists(t)){let r=await sr.read(t);n.push(r)}}return n.reverse().join(`
|
|
`)}var Ze=class{constructor(e){let t=e||this.constructor.name;this.debug=Te(`[${t}]`,"debug"),this.log=Te(`[${t}]`,"log"),this.warn=Te(`[${t}]`,"warn"),this.error=Te(`[${t}]`,"error")}setLoggers(e){this.debug=Te(`[${e}]`,"debug"),this.log=Te(`[${e}]`,"log"),this.warn=Te(`[${e}]`,"warn"),this.error=Te(`[${e}]`,"error")}};var Tl=require("obsidian");var Nr=class n extends Error{constructor(e){var t,r,o,s;super("ClientResponseError"),this.url="",this.status=0,this.response={},this.isAbort=!1,this.originalError=null,Object.setPrototypeOf(this,n.prototype),e!==null&&typeof e=="object"&&(this.url=typeof e.url=="string"?e.url:"",this.status=typeof e.status=="number"?e.status:0,this.isAbort=!!e.isAbort,this.originalError=e.originalError,e.response!==null&&typeof e.response=="object"?this.response=e.response:e.data!==null&&typeof e.data=="object"?this.response=e.data:this.response={}),this.originalError||e instanceof n||(this.originalError=e),typeof DOMException!="undefined"&&e instanceof DOMException&&(this.isAbort=!0),this.name="ClientResponseError "+this.status,this.message=(t=this.response)==null?void 0:t.message,this.message||(this.isAbort?this.message="The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.":(s=(o=(r=this.originalError)==null?void 0:r.cause)==null?void 0:o.message)!=null&&s.includes("ECONNREFUSED ::1")?this.message="Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).":this.message="Something went wrong while processing your request.")}get data(){return this.response}toJSON(){return{...this}}},ll=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function wk(n,e){let t={};if(typeof n!="string")return t;let r=Object.assign({},e||{}).decode||_k,o=0;for(;o<n.length;){let s=n.indexOf("=",o);if(s===-1)break;let i=n.indexOf(";",o);if(i===-1)i=n.length;else if(i<s){o=n.lastIndexOf(";",s-1)+1;continue}let a=n.slice(o,s).trim();if(t[a]===void 0){let l=n.slice(s+1,i).trim();l.charCodeAt(0)===34&&(l=l.slice(1,-1));try{t[a]=r(l)}catch(c){t[a]=l}}o=i+1}return t}function Cy(n,e,t){let r=Object.assign({},t||{}),o=r.encode||Sk;if(!ll.test(n))throw new TypeError("argument name is invalid");let s=o(e);if(s&&!ll.test(s))throw new TypeError("argument val is invalid");let i=n+"="+s;if(r.maxAge!=null){let a=r.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");i+="; Max-Age="+Math.floor(a)}if(r.domain){if(!ll.test(r.domain))throw new TypeError("option domain is invalid");i+="; Domain="+r.domain}if(r.path){if(!ll.test(r.path))throw new TypeError("option path is invalid");i+="; Path="+r.path}if(r.expires){if(!(function(l){return Object.prototype.toString.call(l)==="[object Date]"||l instanceof Date})(r.expires)||isNaN(r.expires.valueOf()))throw new TypeError("option expires is invalid");i+="; Expires="+r.expires.toUTCString()}if(r.httpOnly&&(i+="; HttpOnly"),r.secure&&(i+="; Secure"),r.priority)switch(typeof r.priority=="string"?r.priority.toLowerCase():r.priority){case"low":i+="; Priority=Low";break;case"medium":i+="; Priority=Medium";break;case"high":i+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}if(r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i}function _k(n){return n.indexOf("%")!==-1?decodeURIComponent(n):n}function Sk(n){return encodeURIComponent(n)}var Ty;function cl(n){if(n)try{let e=decodeURIComponent(Ty(n.split(".")[1]).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join(""));return JSON.parse(e)||{}}catch(e){}return{}}function Ay(n,e=0){let t=cl(n);return!(Object.keys(t).length>0&&(!t.exp||t.exp-e>Date.now()/1e3))}Ty=typeof atob=="function"?atob:n=>{let e=String(n).replace(/=+$/,"");if(e.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,r,o=0,s=0,i="";r=e.charAt(s++);~r&&(t=o%4?64*t+r:r,o++%4)?i+=String.fromCharCode(255&t>>(-2*o&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return i};var Ly="pb_auth",$i=class{constructor(){this.baseToken="",this.baseModel=null,this._onChangeCallbacks=[]}get token(){return this.baseToken}get model(){return this.baseModel}get isValid(){return!Ay(this.token)}get isAdmin(){return cl(this.token).type==="admin"}get isAuthRecord(){return cl(this.token).type==="authRecord"}save(e,t){this.baseToken=e||"",this.baseModel=t||null,this.triggerChange()}clear(){this.baseToken="",this.baseModel=null,this.triggerChange()}loadFromCookie(e,t=Ly){let r=wk(e||"")[t]||"",o={};try{o=JSON.parse(r),(typeof o===null||typeof o!="object"||Array.isArray(o))&&(o={})}catch(s){}this.save(o.token||"",o.model||null)}exportToCookie(e,t=Ly){var l,c;let r={secure:!0,sameSite:!0,httpOnly:!0,path:"/"},o=cl(this.token);r.expires=o!=null&&o.exp?new Date(1e3*o.exp):new Date("1970-01-01"),e=Object.assign({},r,e);let s={token:this.token,model:this.model?JSON.parse(JSON.stringify(this.model)):null},i=Cy(t,JSON.stringify(s),e),a=typeof Blob!="undefined"?new Blob([i]).size:i.length;if(s.model&&a>4096){s.model={id:(l=s==null?void 0:s.model)==null?void 0:l.id,email:(c=s==null?void 0:s.model)==null?void 0:c.email};let u=["collectionId","username","verified"];for(let f in this.model)u.includes(f)&&(s.model[f]=this.model[f]);i=Cy(t,JSON.stringify(s),e)}return i}onChange(e,t=!1){return this._onChangeCallbacks.push(e),t&&e(this.token,this.model),()=>{for(let r=this._onChangeCallbacks.length-1;r>=0;r--)if(this._onChangeCallbacks[r]==e)return delete this._onChangeCallbacks[r],void this._onChangeCallbacks.splice(r,1)}}triggerChange(){for(let e of this._onChangeCallbacks)e&&e(this.token,this.model)}},Lf=class extends $i{constructor(e="pocketbase_auth"){super(),this.storageFallback={},this.storageKey=e,this._bindStorageEvent()}get token(){return(this._storageGet(this.storageKey)||{}).token||""}get model(){return(this._storageGet(this.storageKey)||{}).model||null}save(e,t){this._storageSet(this.storageKey,{token:e,model:t}),super.save(e,t)}clear(){this._storageRemove(this.storageKey),super.clear()}_storageGet(e){if(typeof window!="undefined"&&(window!=null&&window.localStorage)){let t=window.localStorage.getItem(e)||"";try{return JSON.parse(t)}catch(r){return t}}return this.storageFallback[e]}_storageSet(e,t){if(typeof window!="undefined"&&(window!=null&&window.localStorage)){let r=t;typeof t!="string"&&(r=JSON.stringify(t)),window.localStorage.setItem(e,r)}else this.storageFallback[e]=t}_storageRemove(e){var t;typeof window!="undefined"&&(window!=null&&window.localStorage)&&((t=window.localStorage)==null||t.removeItem(e)),delete this.storageFallback[e]}_bindStorageEvent(){typeof window!="undefined"&&(window!=null&&window.localStorage)&&window.addEventListener&&window.addEventListener("storage",(e=>{if(e.key!=this.storageKey)return;let t=this._storageGet(this.storageKey)||{};super.save(t.token||"",t.model||null)}))}},Bo=class{constructor(e){this.client=e}},Mf=class extends Bo{async getAll(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/settings",e)}async update(e,t){return t=Object.assign({method:"PATCH",body:e},t),this.client.send("/api/settings",t)}async testS3(e="storage",t){return t=Object.assign({method:"POST",body:{filesystem:e}},t),this.client.send("/api/settings/test/s3",t).then((()=>!0))}async testEmail(e,t,r){return r=Object.assign({method:"POST",body:{email:e,template:t}},r),this.client.send("/api/settings/test/email",r).then((()=>!0))}async generateAppleClientSecret(e,t,r,o,s,i){return i=Object.assign({method:"POST",body:{clientId:e,teamId:t,keyId:r,privateKey:o,duration:s}},i),this.client.send("/api/settings/apple/generate-client-secret",i)}},Ni=class extends Bo{decode(e){return e}async getFullList(e,t){if(typeof e=="number")return this._getFullList(e,t);let r=500;return(t=Object.assign({},e,t)).batch&&(r=t.batch,delete t.batch),this._getFullList(r,t)}async getList(e=1,t=30,r){return(r=Object.assign({method:"GET"},r)).query=Object.assign({page:e,perPage:t},r.query),this.client.send(this.baseCrudPath,r).then((o=>{var s;return o.items=((s=o.items)==null?void 0:s.map((i=>this.decode(i))))||[],o}))}async getFirstListItem(e,t){return(t=Object.assign({requestKey:"one_by_filter_"+this.baseCrudPath+"_"+e},t)).query=Object.assign({filter:e,skipTotal:1},t.query),this.getList(1,1,t).then((r=>{var o;if(!((o=r==null?void 0:r.items)!=null&&o.length))throw new Nr({status:404,response:{code:404,message:"The requested resource wasn't found.",data:{}}});return r.items[0]}))}async getOne(e,t){if(!e)throw new Nr({url:this.client.buildUrl(this.baseCrudPath+"/"),status:404,response:{code:404,message:"Missing required record id.",data:{}}});return t=Object.assign({method:"GET"},t),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e),t).then((r=>this.decode(r)))}async create(e,t){return t=Object.assign({method:"POST",body:e},t),this.client.send(this.baseCrudPath,t).then((r=>this.decode(r)))}async update(e,t,r){return r=Object.assign({method:"PATCH",body:t},r),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e),r).then((o=>this.decode(o)))}async delete(e,t){return t=Object.assign({method:"DELETE"},t),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e),t).then((()=>!0))}_getFullList(e=500,t){(t=t||{}).query=Object.assign({skipTotal:1},t.query);let r=[],o=async s=>this.getList(s,e||500,t).then((i=>{let a=i.items;return r=r.concat(a),a.length==i.perPage?o(s+1):r}));return o(1)}};function Cr(n,e,t,r){let o=r!==void 0;return o||t!==void 0?o?(console.warn(n),e.body=Object.assign({},e.body,t),e.query=Object.assign({},e.query,r),e):Object.assign(e,t):e}function Cf(n){var e;(e=n._resetAutoRefresh)==null||e.call(n)}var Tf=class extends Ni{get baseCrudPath(){return"/api/admins"}async update(e,t,r){return super.update(e,t,r).then((o=>{var s,i;return((s=this.client.authStore.model)==null?void 0:s.id)===o.id&&((i=this.client.authStore.model)==null?void 0:i.collectionId)===void 0&&this.client.authStore.save(this.client.authStore.token,o),o}))}async delete(e,t){return super.delete(e,t).then((r=>{var o,s;return r&&((o=this.client.authStore.model)==null?void 0:o.id)===e&&((s=this.client.authStore.model)==null?void 0:s.collectionId)===void 0&&this.client.authStore.clear(),r}))}authResponse(e){let t=this.decode((e==null?void 0:e.admin)||{});return e!=null&&e.token&&(e!=null&&e.admin)&&this.client.authStore.save(e.token,t),Object.assign({},e,{token:(e==null?void 0:e.token)||"",admin:t})}async authWithPassword(e,t,r,o){let s={method:"POST",body:{identity:e,password:t}};s=Cr("This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).",s,r,o);let i=s.autoRefreshThreshold;delete s.autoRefreshThreshold,s.autoRefresh||Cf(this.client);let a=await this.client.send(this.baseCrudPath+"/auth-with-password",s);return a=this.authResponse(a),i&&(function(c,u,f,d){Cf(c);let p=c.beforeSend,m=c.authStore.model,y=c.authStore.onChange(((g,I)=>{(!g||(I==null?void 0:I.id)!=(m==null?void 0:m.id)||(I!=null&&I.collectionId||m!=null&&m.collectionId)&&(I==null?void 0:I.collectionId)!=(m==null?void 0:m.collectionId))&&Cf(c)}));c._resetAutoRefresh=function(){y(),c.beforeSend=p,delete c._resetAutoRefresh},c.beforeSend=async(g,I)=>{var M;let L=c.authStore.token;if((M=I.query)!=null&&M.autoRefresh)return p?p(g,I):{url:g,sendOptions:I};let C=c.authStore.isValid;if(C&&Ay(c.authStore.token,u))try{await f()}catch(E){C=!1}C||await d();let S=I.headers||{};for(let E in S)if(E.toLowerCase()=="authorization"&&L==S[E]&&c.authStore.token){S[E]=c.authStore.token;break}return I.headers=S,p?p(g,I):{url:g,sendOptions:I}}})(this.client,i,(()=>this.authRefresh({autoRefresh:!0})),(()=>this.authWithPassword(e,t,Object.assign({autoRefresh:!0},s)))),a}async authRefresh(e,t){let r={method:"POST"};return r=Cr("This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).",r,e,t),this.client.send(this.baseCrudPath+"/auth-refresh",r).then(this.authResponse.bind(this))}async requestPasswordReset(e,t,r){let o={method:"POST",body:{email:e}};return o=Cr("This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).",o,t,r),this.client.send(this.baseCrudPath+"/request-password-reset",o).then((()=>!0))}async confirmPasswordReset(e,t,r,o,s){let i={method:"POST",body:{token:e,password:t,passwordConfirm:r}};return i=Cr("This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).",i,o,s),this.client.send(this.baseCrudPath+"/confirm-password-reset",i).then((()=>!0))}},kk=["requestKey","$cancelKey","$autoCancel","fetch","headers","body","query","params","cache","credentials","headers","integrity","keepalive","method","mode","redirect","referrer","referrerPolicy","signal","window"];function Fy(n){if(n){n.query=n.query||{};for(let e in n)kk.includes(e)||(n.query[e]=n[e],delete n[e])}}var ul=class extends Bo{constructor(){super(...arguments),this.clientId="",this.eventSource=null,this.subscriptions={},this.lastSentSubscriptions=[],this.maxConnectTimeout=15e3,this.reconnectAttempts=0,this.maxReconnectAttempts=1/0,this.predefinedReconnectIntervals=[200,300,500,1e3,1200,1500,2e3],this.pendingConnects=[]}get isConnected(){return!!this.eventSource&&!!this.clientId&&!this.pendingConnects.length}async subscribe(e,t,r){var i;if(!e)throw new Error("topic must be set.");let o=e;if(r){Fy(r);let a="options="+encodeURIComponent(JSON.stringify({query:r.query,headers:r.headers}));o+=(o.includes("?")?"&":"?")+a}let s=function(a){let l=a,c;try{c=JSON.parse(l==null?void 0:l.data)}catch(u){}t(c||{})};return this.subscriptions[o]||(this.subscriptions[o]=[]),this.subscriptions[o].push(s),this.isConnected?this.subscriptions[o].length===1?await this.submitSubscriptions():(i=this.eventSource)==null||i.addEventListener(o,s):await this.connect(),async()=>this.unsubscribeByTopicAndListener(e,s)}async unsubscribe(e){var r;let t=!1;if(e){let o=this.getSubscriptionsByTopic(e);for(let s in o)if(this.hasSubscriptionListeners(s)){for(let i of this.subscriptions[s])(r=this.eventSource)==null||r.removeEventListener(s,i);delete this.subscriptions[s],t||(t=!0)}}else this.subscriptions={};this.hasSubscriptionListeners()?t&&await this.submitSubscriptions():this.disconnect()}async unsubscribeByPrefix(e){var r;let t=!1;for(let o in this.subscriptions)if((o+"?").startsWith(e)){t=!0;for(let s of this.subscriptions[o])(r=this.eventSource)==null||r.removeEventListener(o,s);delete this.subscriptions[o]}t&&(this.hasSubscriptionListeners()?await this.submitSubscriptions():this.disconnect())}async unsubscribeByTopicAndListener(e,t){var s;let r=!1,o=this.getSubscriptionsByTopic(e);for(let i in o){if(!Array.isArray(this.subscriptions[i])||!this.subscriptions[i].length)continue;let a=!1;for(let l=this.subscriptions[i].length-1;l>=0;l--)this.subscriptions[i][l]===t&&(a=!0,delete this.subscriptions[i][l],this.subscriptions[i].splice(l,1),(s=this.eventSource)==null||s.removeEventListener(i,t));a&&(this.subscriptions[i].length||delete this.subscriptions[i],r||this.hasSubscriptionListeners(i)||(r=!0))}this.hasSubscriptionListeners()?r&&await this.submitSubscriptions():this.disconnect()}hasSubscriptionListeners(e){var t,r;if(this.subscriptions=this.subscriptions||{},e)return!!((t=this.subscriptions[e])!=null&&t.length);for(let o in this.subscriptions)if((r=this.subscriptions[o])!=null&&r.length)return!0;return!1}async submitSubscriptions(){if(this.clientId)return this.addAllSubscriptionListeners(),this.lastSentSubscriptions=this.getNonEmptySubscriptionKeys(),this.client.send("/api/realtime",{method:"POST",body:{clientId:this.clientId,subscriptions:this.lastSentSubscriptions},requestKey:this.getSubscriptionsCancelKey()}).catch((e=>{if(!(e!=null&&e.isAbort))throw e}))}getSubscriptionsCancelKey(){return"realtime_"+this.clientId}getSubscriptionsByTopic(e){let t={};e=e.includes("?")?e:e+"?";for(let r in this.subscriptions)(r+"?").startsWith(e)&&(t[r]=this.subscriptions[r]);return t}getNonEmptySubscriptionKeys(){let e=[];for(let t in this.subscriptions)this.subscriptions[t].length&&e.push(t);return e}addAllSubscriptionListeners(){if(this.eventSource){this.removeAllSubscriptionListeners();for(let e in this.subscriptions)for(let t of this.subscriptions[e])this.eventSource.addEventListener(e,t)}}removeAllSubscriptionListeners(){if(this.eventSource)for(let e in this.subscriptions)for(let t of this.subscriptions[e])this.eventSource.removeEventListener(e,t)}async connect(){if(!(this.reconnectAttempts>0))return new Promise(((e,t)=>{this.pendingConnects.push({resolve:e,reject:t}),this.pendingConnects.length>1||this.initConnect()}))}initConnect(){this.disconnect(!0),clearTimeout(this.connectTimeoutId),this.connectTimeoutId=setTimeout((()=>{this.connectErrorHandler(new Error("EventSource connect took too long."))}),this.maxConnectTimeout),this.eventSource=new EventSource(this.client.buildUrl("/api/realtime")),this.eventSource.onerror=e=>{this.connectErrorHandler(new Error("Failed to establish realtime connection."))},this.eventSource.addEventListener("PB_CONNECT",(e=>{let t=e;this.clientId=t==null?void 0:t.lastEventId,this.submitSubscriptions().then((async()=>{let r=3;for(;this.hasUnsentSubscriptions()&&r>0;)r--,await this.submitSubscriptions()})).then((()=>{for(let o of this.pendingConnects)o.resolve();this.pendingConnects=[],this.reconnectAttempts=0,clearTimeout(this.reconnectTimeoutId),clearTimeout(this.connectTimeoutId);let r=this.getSubscriptionsByTopic("PB_CONNECT");for(let o in r)for(let s of r[o])s(e)})).catch((r=>{this.clientId="",this.connectErrorHandler(r)}))}))}hasUnsentSubscriptions(){let e=this.getNonEmptySubscriptionKeys();if(e.length!=this.lastSentSubscriptions.length)return!0;for(let t of e)if(!this.lastSentSubscriptions.includes(t))return!0;return!1}connectErrorHandler(e){if(clearTimeout(this.connectTimeoutId),clearTimeout(this.reconnectTimeoutId),!this.clientId&&!this.reconnectAttempts||this.reconnectAttempts>this.maxReconnectAttempts){for(let r of this.pendingConnects)r.reject(new Nr(e));return this.pendingConnects=[],void this.disconnect()}this.disconnect(!0);let t=this.predefinedReconnectIntervals[this.reconnectAttempts]||this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length-1];this.reconnectAttempts++,this.reconnectTimeoutId=setTimeout((()=>{this.initConnect()}),t)}disconnect(e=!1){var t;if(clearTimeout(this.connectTimeoutId),clearTimeout(this.reconnectTimeoutId),this.removeAllSubscriptionListeners(),this.client.cancelRequest(this.getSubscriptionsCancelKey()),(t=this.eventSource)==null||t.close(),this.eventSource=null,this.clientId="",!e){this.reconnectAttempts=0;for(let r of this.pendingConnects)r.resolve();this.pendingConnects=[]}}},Af=class extends Ni{constructor(e,t){super(e),this.collectionIdOrName=t}get baseCrudPath(){return this.baseCollectionPath+"/records"}get baseCollectionPath(){return"/api/collections/"+encodeURIComponent(this.collectionIdOrName)}async subscribe(e,t,r){if(!e)throw new Error("Missing topic.");if(!t)throw new Error("Missing subscription callback.");return this.client.realtime.subscribe(this.collectionIdOrName+"/"+e,t,r)}async unsubscribe(e){return e?this.client.realtime.unsubscribe(this.collectionIdOrName+"/"+e):this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName)}async getFullList(e,t){if(typeof e=="number")return super.getFullList(e,t);let r=Object.assign({},e,t);return super.getFullList(r)}async getList(e=1,t=30,r){return super.getList(e,t,r)}async getFirstListItem(e,t){return super.getFirstListItem(e,t)}async getOne(e,t){return super.getOne(e,t)}async create(e,t){return super.create(e,t)}async update(e,t,r){return super.update(e,t,r).then((o=>{var s,i,a;return((s=this.client.authStore.model)==null?void 0:s.id)!==(o==null?void 0:o.id)||((i=this.client.authStore.model)==null?void 0:i.collectionId)!==this.collectionIdOrName&&((a=this.client.authStore.model)==null?void 0:a.collectionName)!==this.collectionIdOrName||this.client.authStore.save(this.client.authStore.token,o),o}))}async delete(e,t){return super.delete(e,t).then((r=>{var o,s,i;return!r||((o=this.client.authStore.model)==null?void 0:o.id)!==e||((s=this.client.authStore.model)==null?void 0:s.collectionId)!==this.collectionIdOrName&&((i=this.client.authStore.model)==null?void 0:i.collectionName)!==this.collectionIdOrName||this.client.authStore.clear(),r}))}authResponse(e){let t=this.decode((e==null?void 0:e.record)||{});return this.client.authStore.save(e==null?void 0:e.token,t),Object.assign({},e,{token:(e==null?void 0:e.token)||"",record:t})}async listAuthMethods(e){return e=Object.assign({method:"GET"},e),this.client.send(this.baseCollectionPath+"/auth-methods",e).then((t=>Object.assign({},t,{usernamePassword:!!(t!=null&&t.usernamePassword),emailPassword:!!(t!=null&&t.emailPassword),authProviders:Array.isArray(t==null?void 0:t.authProviders)?t==null?void 0:t.authProviders:[]})))}async authWithPassword(e,t,r,o){let s={method:"POST",body:{identity:e,password:t}};return s=Cr("This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).",s,r,o),this.client.send(this.baseCollectionPath+"/auth-with-password",s).then((i=>this.authResponse(i)))}async authWithOAuth2Code(e,t,r,o,s,i,a){let l={method:"POST",body:{provider:e,code:t,codeVerifier:r,redirectUrl:o,createData:s}};return l=Cr("This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).",l,i,a),this.client.send(this.baseCollectionPath+"/auth-with-oauth2",l).then((c=>this.authResponse(c)))}async authWithOAuth2(...e){if(e.length>1||typeof(e==null?void 0:e[0])=="string")return console.warn("PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration."),this.authWithOAuth2Code((e==null?void 0:e[0])||"",(e==null?void 0:e[1])||"",(e==null?void 0:e[2])||"",(e==null?void 0:e[3])||"",(e==null?void 0:e[4])||{},(e==null?void 0:e[5])||{},(e==null?void 0:e[6])||{});let t=(e==null?void 0:e[0])||{},r=(await this.listAuthMethods()).authProviders.find((l=>l.name===t.provider));if(!r)throw new Nr(new Error(`Missing or invalid provider "${t.provider}".`));let o=this.client.buildUrl("/api/oauth2-redirect"),s=new ul(this.client),i=null;function a(){i==null||i.close(),s.unsubscribe()}return t.urlCallback||(i=My(void 0)),new Promise((async(l,c)=>{var u;try{await s.subscribe("@oauth2",(async m=>{let y=s.clientId;try{if(!m.state||y!==m.state)throw new Error("State parameters don't match.");let g=Object.assign({},t);delete g.provider,delete g.scopes,delete g.createData,delete g.urlCallback;let I=await this.authWithOAuth2Code(r.name,m.code,r.codeVerifier,o,t.createData,g);l(I)}catch(g){c(new Nr(g))}a()}));let f={state:s.clientId};(u=t.scopes)!=null&&u.length&&(f.scope=t.scopes.join(" "));let d=this._replaceQueryParams(r.authUrl+o,f);await(t.urlCallback||function(m){i?i.location.href=m:i=My(m)})(d)}catch(f){a(),c(new Nr(f))}}))}async authRefresh(e,t){let r={method:"POST"};return r=Cr("This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).",r,e,t),this.client.send(this.baseCollectionPath+"/auth-refresh",r).then((o=>this.authResponse(o)))}async requestPasswordReset(e,t,r){let o={method:"POST",body:{email:e}};return o=Cr("This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).",o,t,r),this.client.send(this.baseCollectionPath+"/request-password-reset",o).then((()=>!0))}async confirmPasswordReset(e,t,r,o,s){let i={method:"POST",body:{token:e,password:t,passwordConfirm:r}};return i=Cr("This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).",i,o,s),this.client.send(this.baseCollectionPath+"/confirm-password-reset",i).then((()=>!0))}async requestVerification(e,t,r){let o={method:"POST",body:{email:e}};return o=Cr("This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).",o,t,r),this.client.send(this.baseCollectionPath+"/request-verification",o).then((()=>!0))}async confirmVerification(e,t,r){let o={method:"POST",body:{token:e}};return o=Cr("This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).",o,t,r),this.client.send(this.baseCollectionPath+"/confirm-verification",o).then((()=>!0))}async requestEmailChange(e,t,r){let o={method:"POST",body:{newEmail:e}};return o=Cr("This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).",o,t,r),this.client.send(this.baseCollectionPath+"/request-email-change",o).then((()=>!0))}async confirmEmailChange(e,t,r,o){let s={method:"POST",body:{token:e,password:t}};return s=Cr("This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).",s,r,o),this.client.send(this.baseCollectionPath+"/confirm-email-change",s).then((()=>!0))}async listExternalAuths(e,t){return t=Object.assign({method:"GET"},t),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e)+"/external-auths",t)}async unlinkExternalAuth(e,t,r){return r=Object.assign({method:"DELETE"},r),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e)+"/external-auths/"+encodeURIComponent(t),r).then((()=>!0))}_replaceQueryParams(e,t={}){let r=e,o="";e.indexOf("?")>=0&&(r=e.substring(0,e.indexOf("?")),o=e.substring(e.indexOf("?")+1));let s={},i=o.split("&");for(let a of i){if(a=="")continue;let l=a.split("=");s[decodeURIComponent(l[0].replace(/\+/g," "))]=decodeURIComponent((l[1]||"").replace(/\+/g," "))}for(let a in t)t.hasOwnProperty(a)&&(t[a]==null?delete s[a]:s[a]=t[a]);o="";for(let a in s)s.hasOwnProperty(a)&&(o!=""&&(o+="&"),o+=encodeURIComponent(a.replace(/%20/g,"+"))+"="+encodeURIComponent(s[a].replace(/%20/g,"+")));return o!=""?r+"?"+o:r}};function My(n){if(typeof window=="undefined"||!(window!=null&&window.open))throw new Nr(new Error("Not in a browser context - please pass a custom urlCallback function."));let e=1024,t=768,r=window.innerWidth,o=window.innerHeight;e=e>r?r:e,t=t>o?o:t;let s=r/2-e/2,i=o/2-t/2;return window.open(n,"popup_window","width="+e+",height="+t+",top="+i+",left="+s+",resizable,menubar=no")}var Ff=class extends Ni{get baseCrudPath(){return"/api/collections"}async import(e,t=!1,r){return r=Object.assign({method:"PUT",body:{collections:e,deleteMissing:t}},r),this.client.send(this.baseCrudPath+"/import",r).then((()=>!0))}},Ef=class extends Bo{async getList(e=1,t=30,r){return(r=Object.assign({method:"GET"},r)).query=Object.assign({page:e,perPage:t},r.query),this.client.send("/api/logs",r)}async getOne(e,t){if(!e)throw new Nr({url:this.client.buildUrl("/api/logs/"),status:404,response:{code:404,message:"Missing required log id.",data:{}}});return t=Object.assign({method:"GET"},t),this.client.send("/api/logs/"+encodeURIComponent(e),t)}async getStats(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/logs/stats",e)}},Pf=class extends Bo{async check(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/health",e)}},Df=class extends Bo{getUrl(e,t,r={}){if(!t||!(e!=null&&e.id)||!(e!=null&&e.collectionId)&&!(e!=null&&e.collectionName))return"";let o=[];o.push("api"),o.push("files"),o.push(encodeURIComponent(e.collectionId||e.collectionName)),o.push(encodeURIComponent(e.id)),o.push(encodeURIComponent(t));let s=this.client.buildUrl(o.join("/"));if(Object.keys(r).length){r.download===!1&&delete r.download;let i=new URLSearchParams(r);s+=(s.includes("?")?"&":"?")+i}return s}async getToken(e){return e=Object.assign({method:"POST"},e),this.client.send("/api/files/token",e).then((t=>(t==null?void 0:t.token)||""))}},Rf=class extends Bo{async getFullList(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/backups",e)}async create(e,t){return t=Object.assign({method:"POST",body:{name:e}},t),this.client.send("/api/backups",t).then((()=>!0))}async upload(e,t){return t=Object.assign({method:"POST",body:e},t),this.client.send("/api/backups/upload",t).then((()=>!0))}async delete(e,t){return t=Object.assign({method:"DELETE"},t),this.client.send(`/api/backups/${encodeURIComponent(e)}`,t).then((()=>!0))}async restore(e,t){return t=Object.assign({method:"POST"},t),this.client.send(`/api/backups/${encodeURIComponent(e)}/restore`,t).then((()=>!0))}getDownloadUrl(e,t){return this.client.buildUrl(`/api/backups/${encodeURIComponent(t)}?token=${encodeURIComponent(e)}`)}},qn=class{constructor(e="/",t,r="en-US"){this.cancelControllers={},this.recordServices={},this.enableAutoCancellation=!0,this.baseUrl=e,this.lang=r,this.authStore=t||new Lf,this.admins=new Tf(this),this.collections=new Ff(this),this.files=new Df(this),this.logs=new Ef(this),this.settings=new Mf(this),this.realtime=new ul(this),this.health=new Pf(this),this.backups=new Rf(this)}collection(e){return this.recordServices[e]||(this.recordServices[e]=new Af(this,e)),this.recordServices[e]}autoCancellation(e){return this.enableAutoCancellation=!!e,this}cancelRequest(e){return this.cancelControllers[e]&&(this.cancelControllers[e].abort(),delete this.cancelControllers[e]),this}cancelAllRequests(){for(let e in this.cancelControllers)this.cancelControllers[e].abort();return this.cancelControllers={},this}filter(e,t){if(!t)return e;for(let r in t){let o=t[r];switch(typeof o){case"boolean":case"number":o=""+o;break;case"string":o="'"+o.replace(/'/g,"\\'")+"'";break;default:o=o===null?"null":o instanceof Date?"'"+o.toISOString().replace("T"," ")+"'":"'"+JSON.stringify(o).replace(/'/g,"\\'")+"'"}e=e.replaceAll("{:"+r+"}",o)}return e}getFileUrl(e,t,r={}){return this.files.getUrl(e,t,r)}buildUrl(e){var r;let t=this.baseUrl;return typeof window=="undefined"||!window.location||t.startsWith("https://")||t.startsWith("http://")||(t=(r=window.location.origin)!=null&&r.endsWith("/")?window.location.origin.substring(0,window.location.origin.length-1):window.location.origin||"",this.baseUrl.startsWith("/")||(t+=window.location.pathname||"/",t+=t.endsWith("/")?"":"/"),t+=this.baseUrl),e&&(t+=t.endsWith("/")?"":"/",t+=e.startsWith("/")?e.substring(1):e),t}async send(e,t){t=this.initSendOptions(e,t);let r=this.buildUrl(e);if(this.beforeSend){let o=Object.assign({},await this.beforeSend(r,t));o.url!==void 0||o.options!==void 0?(r=o.url||r,t=o.options||t):Object.keys(o).length&&(t=o,console!=null&&console.warn&&console.warn("Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`."))}if(t.query!==void 0){let o=this.serializeQueryParams(t.query);o&&(r+=(r.includes("?")?"&":"?")+o),delete t.query}return this.getHeader(t.headers,"Content-Type")=="application/json"&&t.body&&typeof t.body!="string"&&(t.body=JSON.stringify(t.body)),(t.fetch||fetch)(r,t).then((async o=>{let s={};try{s=await o.json()}catch(i){}if(this.afterSend&&(s=await this.afterSend(o,s)),o.status>=400)throw new Nr({url:o.url,status:o.status,data:s});return s})).catch((o=>{throw new Nr(o)}))}initSendOptions(e,t){if((t=Object.assign({method:"GET"},t)).body=this.convertToFormDataIfNeeded(t.body),Fy(t),t.query=Object.assign({},t.params,t.query),t.requestKey===void 0&&(t.$autoCancel===!1||t.query.$autoCancel===!1?t.requestKey=null:(t.$cancelKey||t.query.$cancelKey)&&(t.requestKey=t.$cancelKey||t.query.$cancelKey)),delete t.$autoCancel,delete t.query.$autoCancel,delete t.$cancelKey,delete t.query.$cancelKey,this.getHeader(t.headers,"Content-Type")!==null||this.isFormData(t.body)||(t.headers=Object.assign({},t.headers,{"Content-Type":"application/json"})),this.getHeader(t.headers,"Accept-Language")===null&&(t.headers=Object.assign({},t.headers,{"Accept-Language":this.lang})),this.authStore.token&&this.getHeader(t.headers,"Authorization")===null&&(t.headers=Object.assign({},t.headers,{Authorization:this.authStore.token})),this.enableAutoCancellation&&t.requestKey!==null){let r=t.requestKey||(t.method||"GET")+e;delete t.requestKey,this.cancelRequest(r);let o=new AbortController;this.cancelControllers[r]=o,t.signal=o.signal}return t}convertToFormDataIfNeeded(e){if(typeof FormData=="undefined"||e===void 0||typeof e!="object"||e===null||this.isFormData(e)||!this.hasBlobField(e))return e;let t=new FormData;for(let r in e){let o=this.normalizeFormDataValue(e[r]),s=Array.isArray(o)?o:[o];if(s.length)for(let i of s)t.append(r,i);else t.append(r,"")}return t}normalizeFormDataValue(e){return e===null||typeof e!="object"||e instanceof Date||this.hasBlobField({data:e})||Array.isArray(e)&&!e.filter((t=>typeof t!="string")).length?e:JSON.stringify(e)}hasBlobField(e){for(let t in e){let r=Array.isArray(e[t])?e[t]:[e[t]];for(let o of r)if(typeof Blob!="undefined"&&o instanceof Blob||typeof File!="undefined"&&o instanceof File)return!0}return!1}getHeader(e,t){e=e||{},t=t.toLowerCase();for(let r in e)if(r.toLowerCase()==t)return e[r];return null}isFormData(e){return e&&(e.constructor.name==="FormData"||typeof FormData!="undefined"&&e instanceof FormData)}serializeQueryParams(e){let t=[];for(let r in e){if(e[r]===null)continue;let o=e[r],s=encodeURIComponent(r);if(Array.isArray(o))for(let i of o)t.push(s+"="+encodeURIComponent(i));else o instanceof Date?t.push(s+"="+encodeURIComponent(o.toISOString())):typeof o!==null&&typeof o=="object"?t.push(s+"="+encodeURIComponent(JSON.stringify(o))):t.push(s+"="+encodeURIComponent(o))}return t.join("&")}};var Ds=class{constructor(){this.timeouts=[],this.intervals=[]}getTime(){return Date.now()}setInterval(e,t){let r=window.setInterval(e,t);return this.intervals.push(r),r}clearInterval(e){window.clearInterval(e)}setTimeout(e,t){let r=window.setTimeout(()=>{this.timeouts.remove(r),e()},t);return this.timeouts.push(r),r}clearTimeout(e){window.clearTimeout(e)}destroy(){for(let e of this.timeouts)this.clearTimeout(e);this.timeouts=[];for(let e of this.intervals)this.clearInterval(e);this.intervals=[]}debounce(e,t=500){let r;return(...o)=>{r&&clearTimeout(r),r=setTimeout(()=>{e(...o)},t)}}};var yt=class yt{constructor(e,t=20){this.timeProvider=e;this.deliveryWindow=t;this.mailboxes=new Map;this.allMailLog=[];this.deliveredMailLog=[];this.isDelivering=!1;this.deliveryInterval=null;this.currentTransactionId=0;this.isInTransaction=!1}static getInstance(){if(this._destroyed)throw new Error("tried to access postie during teardown");return yt.instance||(yt.instance=new yt(new Ds),Bt.set(this.instance,"postie")),yt.instance}beginTransaction(){this.isInTransaction=!0,this.currentTransactionId++}commitTransaction(){this.isInTransaction=!1,this.isDelivering||this.scheduleDelivery()}send(e,t,r=!1){let o={sender:e,recipient:t,transactionId:this.currentTransactionId,timestamp:Date.now(),recipientOrigin:this.getFunctionOrigin(t)};this.allMailLog.push(o),this.mailboxes.has(t)||this.mailboxes.set(t,new Set),this.mailboxes.get(t).add(e),r?this.deliverImmediate(e,t):!this.isInTransaction&&!this.isDelivering&&this.scheduleDelivery()}deliverImmediate(e,t){t(e),this.deliveredMailLog.push({sender:e,recipient:t,transactionId:this.currentTransactionId,timestamp:Date.now(),recipientOrigin:this.getFunctionOrigin(t)})}scheduleDelivery(){this.isDelivering=!0,this.deliveryInterval=this.timeProvider.setTimeout(()=>{this.deliver(),this.deliveryInterval=null,this.isDelivering=!1,this.mailboxes.size>0&&!this.isInTransaction&&this.scheduleDelivery()},this.deliveryWindow)}deliver(){let e=Te("[postie]","debug");for(let[t,r]of this.mailboxes){for(let o of r)t(o),e("send",o.constructor.name,t),this.deliveredMailLog.push({sender:o,recipient:t,transactionId:this.currentTransactionId,timestamp:Date.now(),recipientOrigin:this.getFunctionOrigin(t)});r.clear()}}getAllMailLog(){return[...this.allMailLog]}getDeliveredMailLog(){return[...this.deliveredMailLog]}prettyPrintAllMailLog(){Te("[postie]","warn")(`All Mail Log:
|
|
`+this.prettyPrintMailLog(this.allMailLog))}prettyPrintDeliveredMailLog(){Te("[postie]","warn")(`Delivered Mail Log:
|
|
`+this.prettyPrintMailLog(this.deliveredMailLog))}prettyPrintMailLog(e){let t="",r=o=>{t+=`${o}
|
|
`};return e.forEach((o,s)=>{r(`Mail #${s+1}:`),r(` Timestamp: ${new Date(o.timestamp).toISOString()}`),r(` Transaction ID: ${o.transactionId}`),r(` Sender: ${o.sender.observableName||o.sender.constructor.name}`),r(` Recipient: ${o.recipient.name||"Anonymous function"}`),r(` Recipient Origin: ${o.recipientOrigin||"Unknown"}`),r("---")}),t}getFunctionOrigin(e){if(e.name)return e.name;let t=e.toString(),r=t.match(/^(function|class)?\s*([^\s(]*)/);if(r&&r[2])return r[2];let o=200,s=t.replace(/\s+/g," ").slice(0,o);return s.length===o&&(s+="..."),`AnonymousFunction(${s})`}static destroy(){yt.instance&&(yt.instance.mailboxes=null,yt.instance.allMailLog=[],yt.instance.deliveredMailLog=[],yt.instance.timeProvider.destroy(),yt.instance.timeProvider=null,yt.instance.isDelivering=!1,yt.instance.isInTransaction=!1,yt.instance.currentTransactionId=0,yt._destroyed=!0,yt.instance=void 0)}static _resetForTesting(e){var t;yt.instance&&((t=yt.instance.timeProvider)==null||t.destroy()),yt._destroyed=!1,yt.instance=void 0,e&&(yt.instance=new yt(e),Bt.set(yt.instance,"postie"))}};yt._destroyed=!1;var Xr=yt;var Uf=new Map;function Ey(){for(let[,n]of Uf)n();Uf.clear()}var it=class extends Ze{constructor(t){super();this.observableName=t;this.destroyed=!1;Uf.set(this,()=>{this._listeners&&this._listeners.size>0&&this.warn(`Missing tear down of ${this._listeners.size} listeners on ${this.observableName}`)}),this._listeners=new Set,this.unsubscribes=[]}notifyListeners(){for(let t of this._listeners)Xr.getInstance().send(this,t)}on(t){return this._listeners.add(t),()=>{this.off(t)}}subscribe(t){return this._listeners.add(t),Xr.getInstance().send(this,t,!0),()=>{this.unsubscribe(t)}}off(t){this._listeners.delete(t)}unsubscribe(t){this._listeners&&this._listeners.delete(t)}destroy(){var t;this.destroyed=!0,this.unsubscribes&&this.unsubscribes.forEach(r=>{r()}),(t=this._listeners)==null||t.clear(),this._listeners=null}};var By=require("obsidian"),Vy=require("obsidian");var Bi={enableDocumentStatus:!1,enableNewLinkFormat:!1,enableDeltaLogging:!1,enableDocumentHistory:!1,enableEditorTweens:!1,enableNetworkLogging:!1,enableCanvasSync:!1,enableVerifyUploads:!1,enableAutomaticDiffResolution:!0,enableDiscordLogin:!1,enableSelfManageHosts:!0,enableToasts:!0,enablePresenceAvatars:!0,enableLiveEmbeds:!0,enablePreviewViewHooks:!0,enableMetadataViewHooks:!0,enableKanbanView:!0};function fl(n){return n in Bi}function Ik(){return new Proxy({},{get:(n,e)=>e})}var Vo=Ik();function He(){return{...fr.getInstance().flags}}function mn(n,e,t=()=>{}){fr.getInstance().flags[n]?e():t()}function Py(n,e,t=()=>{}){n.forEach(r=>{if(fr.getInstance().flags[r]){e();return}}),t()}var fr=class n extends it{constructor(){super("FeatureFlagManager"),this.flags=Bi}async applyServerFlags(e){if(!this.settings)return;let r=e.filter(o=>o.override).reduce((o,s)=>(o[s.name]=s.value,o),{});this.log("applying server flags",r),await this.settings.update(o=>({...o,...r}),!0)}static getInstance(){return n.instance||(n.instance=new n),n.instance}setSettings(e){this.settings=e,this.unsubscribes.push(this.settings.subscribe(t=>{this.flags={...this.flags,...t},this.notifyListeners()}))}getFlag(e){return this.flags[e]}setFlag(e,t){this.settings&&this.settings.update(r=>({...r,[e]:t}))}static destroy(){n.instance&&n.instance.destroy(),n.instance=null}};if(globalThis.Response===void 0||globalThis.Headers===void 0)try{if(console.warn("[Relay] Polyfilling Fetch API (Electron Bug: https://github.com/electron/electron/pull/42419)"),globalThis.blinkfetch){globalThis.fetch=globalThis.blinkfetch;let n=["fetch","Response","FormData","Request","Headers"];for(let e of n)globalThis[e]=globalThis[`blink${e}`]}}catch(n){console.error(n)}globalThis.EventSource===void 0&&(Vy.Platform.isMobile?console.warn("[Relay] Polyfilling EventSource API required, but unable to polyfill on Mobile"):(console.warn("[Relay] Polyfilling EventSource API"),globalThis.EventSource=Ny()));var at=async(n,e)=>{var c;let t=n instanceof URL?n.toString():n,r=(e==null?void 0:e.method)||"GET",o=Object.assign({},e==null?void 0:e.headers,{"Relay-Version":"0.7.4"}),s={url:t,method:r,body:e==null?void 0:e.body,headers:o,throw:!1},i;try{i=await(0,By.requestUrl)(s)}catch(u){if((c=u==null?void 0:u.message)!=null&&c.includes("net::ERR_FAILED"))return new Response(JSON.stringify({error:"Network request failed"}),{status:503,statusText:"Service Unavailable",headers:new Headers({"content-type":"application/json"})});throw u}if(!i.arrayBuffer.byteLength)return new Response(null,{status:i.status,statusText:i.status.toString(),headers:new Headers(i.headers)});let a=new Response(i.arrayBuffer,{status:i.status,statusText:i.status.toString(),headers:new Headers(i.headers)});if(Object.defineProperty(a,"json",{value:async()=>JSON.parse(i.text)}),He().enableNetworkLogging){let u=i.status>=500?"error":i.status>=400?"warn":"debug",f=i.text,d;if((i.headers["content-type"]||"").includes("application/json"))try{d=JSON.parse(f)}catch(m){}Te("[CustomFetch]",u)(i.status.toString(),r,t,d||f)}if(i.status>=500)throw new Error(i.text);return a};var dl=class extends $i{constructor(t="pocketbase_auth"){super();this.storageFallback={};this._storageChangeHandler=t=>{if(t.key!=this.storageKey)return;let r=this._storageGet(this.storageKey)||{};super.save(r.token||"",r.model||null)};this.storageKey=t,this._bindStorageEvent()}get token(){return(this._storageGet(this.storageKey)||{}).token||""}get model(){return(this._storageGet(this.storageKey)||{}).model||null}save(t,r){this._storageSet(this.storageKey,{token:t,model:r}),super.save(t,r)}clear(){this._storageRemove(this.storageKey),super.clear()}destroy(){this._unbindStorageEvent()}_storageGet(t){if(typeof window!="undefined"&&(window!=null&&window.localStorage)){let r=window.localStorage.getItem(t)||"";try{return JSON.parse(r)}catch(o){return r}}return this.storageFallback[t]}_storageSet(t,r){if(typeof window!="undefined"&&(window!=null&&window.localStorage)){let o=r;typeof r!="string"&&(o=JSON.stringify(r)),window.localStorage.setItem(t,o)}else this.storageFallback[t]=r}_storageRemove(t){var r;typeof window!="undefined"&&(window!=null&&window.localStorage)&&((r=window.localStorage)==null||r.removeItem(t)),delete this.storageFallback[t]}_bindStorageEvent(){if(typeof window=="undefined"||!(window!=null&&window.localStorage)||!window.addEventListener)return()=>{};window.addEventListener("storage",this._storageChangeHandler)}_unbindStorageEvent(){if(typeof window=="undefined"||!(window!=null&&window.localStorage)||!window.addEventListener)return()=>{};window.removeEventListener("storage",this._storageChangeHandler)}};var Et=crypto,Br=n=>n instanceof CryptoKey;var dr=new TextEncoder,Xt=new TextDecoder,WR=2**32;function hn(...n){let e=n.reduce((o,{length:s})=>o+s,0),t=new Uint8Array(e),r=0;for(let o of n)t.set(o,r),r+=o.length;return t}var Hy=n=>{let e=n;typeof e=="string"&&(e=dr.encode(e));let t=32768,r=[];for(let o=0;o<e.length;o+=t)r.push(String.fromCharCode.apply(null,e.subarray(o,o+t)));return btoa(r.join(""))},eo=n=>Hy(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),qy=n=>{let e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},vo=n=>{let e=n;e instanceof Uint8Array&&(e=Xt.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return qy(e)}catch(t){throw new TypeError("The input to be decoded is not correctly encoded.")}};var Of={};uu(Of,{JOSEAlgNotAllowed:()=>Us,JOSEError:()=>zt,JOSENotSupported:()=>bt,JWEDecryptionFailed:()=>Hi,JWEInvalid:()=>Lr,JWKInvalid:()=>pl,JWKSInvalid:()=>ml,JWKSMultipleMatchingKeys:()=>hl,JWKSNoMatchingKey:()=>qi,JWKSTimeout:()=>gl,JWSInvalid:()=>ft,JWSSignatureVerificationFailed:()=>Os,JWTClaimValidationFailed:()=>ir,JWTExpired:()=>Rs,JWTInvalid:()=>Jt});var zt=class extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(e){var t;super(e),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}},ir=class extends zt{static get code(){return"ERR_JWT_CLAIM_VALIDATION_FAILED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=t,this.reason=r}},Rs=class extends zt{static get code(){return"ERR_JWT_EXPIRED"}constructor(e,t="unspecified",r="unspecified"){super(e),this.code="ERR_JWT_EXPIRED",this.claim=t,this.reason=r}},Us=class extends zt{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}static get code(){return"ERR_JOSE_ALG_NOT_ALLOWED"}},bt=class extends zt{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}},Hi=class extends zt{constructor(){super(...arguments),this.code="ERR_JWE_DECRYPTION_FAILED",this.message="decryption operation failed"}static get code(){return"ERR_JWE_DECRYPTION_FAILED"}},Lr=class extends zt{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}},ft=class extends zt{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}},Jt=class extends zt{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}},pl=class extends zt{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}static get code(){return"ERR_JWK_INVALID"}},ml=class extends zt{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}static get code(){return"ERR_JWKS_INVALID"}},qi=class extends zt{constructor(){super(...arguments),this.code="ERR_JWKS_NO_MATCHING_KEY",this.message="no applicable key found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_NO_MATCHING_KEY"}},hl=class extends zt{constructor(){super(...arguments),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS",this.message="multiple matching keys found in the JSON Web Key Set"}static get code(){return"ERR_JWKS_MULTIPLE_MATCHING_KEYS"}},gl=class extends zt{constructor(){super(...arguments),this.code="ERR_JWKS_TIMEOUT",this.message="request timed out"}static get code(){return"ERR_JWKS_TIMEOUT"}},Os=class extends zt{constructor(){super(...arguments),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED",this.message="signature verification failed"}static get code(){return"ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}};var yl=Et.getRandomValues.bind(Et);function Ho(n,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${n}`)}function bl(n,e){return n.name===e}function $f(n){return parseInt(n.name.slice(4),10)}function Nk(n){switch(n){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Bk(n,e){if(e.length&&!e.some(t=>n.usages.includes(t))){let t="CryptoKey does not support this operation, its usages must include ";if(e.length>2){let r=e.pop();t+=`one of ${e.join(", ")}, or ${r}.`}else e.length===2?t+=`one of ${e[0]} or ${e[1]}.`:t+=`${e[0]}.`;throw new TypeError(t)}}function zy(n,e,...t){switch(e){case"HS256":case"HS384":case"HS512":{if(!bl(n.algorithm,"HMAC"))throw Ho("HMAC");let r=parseInt(e.slice(2),10);if($f(n.algorithm.hash)!==r)throw Ho(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!bl(n.algorithm,"RSASSA-PKCS1-v1_5"))throw Ho("RSASSA-PKCS1-v1_5");let r=parseInt(e.slice(2),10);if($f(n.algorithm.hash)!==r)throw Ho(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!bl(n.algorithm,"RSA-PSS"))throw Ho("RSA-PSS");let r=parseInt(e.slice(2),10);if($f(n.algorithm.hash)!==r)throw Ho(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":{if(n.algorithm.name!=="Ed25519"&&n.algorithm.name!=="Ed448")throw Ho("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!bl(n.algorithm,"ECDSA"))throw Ho("ECDSA");let r=Nk(e);if(n.algorithm.namedCurve!==r)throw Ho(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Bk(n,t)}function Wy(n,e,...t){var r;if(t.length>2){let o=t.pop();n+=`one of type ${t.join(", ")}, or ${o}.`}else t.length===2?n+=`one of type ${t[0]} or ${t[1]}.`:n+=`of type ${t[0]}.`;return e==null?n+=` Received ${e}`:typeof e=="function"&&e.name?n+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&(r=e.constructor)!=null&&r.name&&(n+=` Received an instance of ${e.constructor.name}`),n}var to=(n,...e)=>Wy("Key must be ",n,...e);function Nf(n,e,...t){return Wy(`Key for the ${n} algorithm must be `,e,...t)}var Bf=n=>Br(n),Pt=["CryptoKey"];var jk=(...n)=>{let e=n.filter(Boolean);if(e.length===0||e.length===1)return!0;let t;for(let r of e){let o=Object.keys(r);if(!t||t.size===0){t=new Set(o);continue}for(let s of o){if(t.has(s))return!1;t.add(s)}}return!0},$s=jk;function zk(n){return typeof n=="object"&&n!==null}function Wt(n){if(!zk(n)||Object.prototype.toString.call(n)!=="[object Object]")return!1;if(Object.getPrototypeOf(n)===null)return!0;let e=n;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e}var vl=(n,e)=>{if(n.startsWith("RS")||n.startsWith("PS")){let{modulusLength:t}=e.algorithm;if(typeof t!="number"||t<2048)throw new TypeError(`${n} requires key modulusLength to be 2048 bits or larger`)}};var gn=(n,e,t=0)=>{t===0&&(e.unshift(e.length),e.unshift(6));let r=n.indexOf(e[0],t);if(r===-1)return!1;let o=n.subarray(r,r+e.length);return o.length!==e.length?!1:o.every((s,i)=>s===e[i])||gn(n,e,r+1)},Gy=n=>{switch(!0){case gn(n,[42,134,72,206,61,3,1,7]):return"P-256";case gn(n,[43,129,4,0,34]):return"P-384";case gn(n,[43,129,4,0,35]):return"P-521";case gn(n,[43,101,110]):return"X25519";case gn(n,[43,101,111]):return"X448";case gn(n,[43,101,112]):return"Ed25519";case gn(n,[43,101,113]):return"Ed448";default:throw new bt("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},Jk=async(n,e,t,r,o)=>{var c;let s,i,a=new Uint8Array(atob(t.replace(n,"")).split("").map(u=>u.charCodeAt(0))),l=e==="spki";switch(r){case"PS256":case"PS384":case"PS512":s={name:"RSA-PSS",hash:`SHA-${r.slice(-3)}`},i=l?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":s={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.slice(-3)}`},i=l?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s={name:"RSA-OAEP",hash:`SHA-${parseInt(r.slice(-3),10)||1}`},i=l?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":s={name:"ECDSA",namedCurve:"P-256"},i=l?["verify"]:["sign"];break;case"ES384":s={name:"ECDSA",namedCurve:"P-384"},i=l?["verify"]:["sign"];break;case"ES512":s={name:"ECDSA",namedCurve:"P-521"},i=l?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let u=Gy(a);s=u.startsWith("P-")?{name:"ECDH",namedCurve:u}:{name:u},i=l?[]:["deriveBits"];break}case"EdDSA":s={name:Gy(a)},i=l?["verify"]:["sign"];break;default:throw new bt('Invalid or unsupported "alg" (Algorithm) value')}return Et.subtle.importKey(e,a,s,(c=o==null?void 0:o.extractable)!=null?c:!1,i)};var Jy=(n,e,t)=>Jk(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",n,e,t);async function Vf(n,e,t){if(typeof n!="string"||n.indexOf("-----BEGIN PUBLIC KEY-----")!==0)throw new TypeError('"spki" must be SPKI formatted string');return Jy(n,e,t)}var Yk=(n,e)=>{if(!(e instanceof Uint8Array)){if(!Bf(e))throw new TypeError(Nf(n,e,...Pt,"Uint8Array"));if(e.type!=="secret")throw new TypeError(`${Pt.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},Qk=(n,e,t)=>{if(!Bf(e))throw new TypeError(Nf(n,e,...Pt));if(e.type==="secret")throw new TypeError(`${Pt.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(t==="sign"&&e.type==="public")throw new TypeError(`${Pt.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(t==="decrypt"&&e.type==="public")throw new TypeError(`${Pt.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(e.algorithm&&t==="verify"&&e.type==="private")throw new TypeError(`${Pt.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(e.algorithm&&t==="encrypt"&&e.type==="private")throw new TypeError(`${Pt.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},Zk=(n,e,t)=>{n.startsWith("HS")||n==="dir"||n.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(n)?Yk(n,e):Qk(n,e,t)},zi=Zk;function nI(n,e,t,r,o){if(o.crit!==void 0&&(r==null?void 0:r.crit)===void 0)throw new n('"crit" (Critical) Header Parameter MUST be integrity protected');if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(i=>typeof i!="string"||i.length===0))throw new n('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let s;t!==void 0?s=new Map([...Object.entries(t),...e.entries()]):s=e;for(let i of r.crit){if(!s.has(i))throw new bt(`Extension Header Parameter "${i}" is not recognized`);if(o[i]===void 0)throw new n(`Extension Header Parameter "${i}" is missing`);if(s.get(i)&&r[i]===void 0)throw new n(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(r.crit)}var Ns=nI;var sI=(n,e)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(t=>typeof t!="string")))throw new TypeError(`"${n}" option must be an array of strings`);if(e)return new Set(e)},qf=sI;var lI=Symbol();function xl(n,e){let t=`SHA-${n.slice(-3)}`;switch(n){case"HS256":case"HS384":case"HS512":return{hash:t,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:t,name:"RSA-PSS",saltLength:n.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:t,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:t,name:"ECDSA",namedCurve:e.namedCurve};case"EdDSA":return{name:e.name};default:throw new bt(`alg ${n} is not supported either by JOSE or your javascript runtime`)}}function wl(n,e,t){if(Br(e))return zy(e,n,t),e;if(e instanceof Uint8Array){if(!n.startsWith("HS"))throw new TypeError(to(e,...Pt));return Et.subtle.importKey("raw",e,{hash:`SHA-${n.slice(-3)}`,name:"HMAC"},!1,[t])}throw new TypeError(to(e,...Pt,"Uint8Array"))}var cI=async(n,e,t,r)=>{let o=await wl(n,e,"verify");vl(n,o);let s=xl(n,o.algorithm);try{return await Et.subtle.verify(s,o,t,r)}catch(i){return!1}},Xy=cI;async function _l(n,e,t){var y;if(!Wt(n))throw new ft("Flattened JWS must be an object");if(n.protected===void 0&&n.header===void 0)throw new ft('Flattened JWS must have either of the "protected" or "header" members');if(n.protected!==void 0&&typeof n.protected!="string")throw new ft("JWS Protected Header incorrect type");if(n.payload===void 0)throw new ft("JWS Payload missing");if(typeof n.signature!="string")throw new ft("JWS Signature missing or incorrect type");if(n.header!==void 0&&!Wt(n.header))throw new ft("JWS Unprotected Header incorrect type");let r={};if(n.protected)try{let g=vo(n.protected);r=JSON.parse(Xt.decode(g))}catch(g){throw new ft("JWS Protected Header is invalid")}if(!$s(r,n.header))throw new ft("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...r,...n.header},s=Ns(ft,new Map([["b64",!0]]),t==null?void 0:t.crit,r,o),i=!0;if(s.has("b64")&&(i=r.b64,typeof i!="boolean"))throw new ft('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:a}=o;if(typeof a!="string"||!a)throw new ft('JWS "alg" (Algorithm) Header Parameter missing or invalid');let l=t&&qf("algorithms",t.algorithms);if(l&&!l.has(a))throw new Us('"alg" (Algorithm) Header Parameter value not allowed');if(i){if(typeof n.payload!="string")throw new ft("JWS Payload must be a string")}else if(typeof n.payload!="string"&&!(n.payload instanceof Uint8Array))throw new ft("JWS Payload must be a string or an Uint8Array instance");let c=!1;typeof e=="function"&&(e=await e(r,n),c=!0),zi(a,e,"verify");let u=hn(dr.encode((y=n.protected)!=null?y:""),dr.encode("."),typeof n.payload=="string"?dr.encode(n.payload):n.payload),f;try{f=vo(n.signature)}catch(g){throw new ft("Failed to base64url decode the signature")}if(!await Xy(a,e,f,u))throw new Os;let p;if(i)try{p=vo(n.payload)}catch(g){throw new ft("Failed to base64url decode the payload")}else typeof n.payload=="string"?p=dr.encode(n.payload):p=n.payload;let m={payload:p};return n.protected!==void 0&&(m.protectedHeader=r),n.header!==void 0&&(m.unprotectedHeader=n.header),c?{...m,key:e}:m}async function jf(n,e,t){if(n instanceof Uint8Array&&(n=Xt.decode(n)),typeof n!="string")throw new ft("Compact JWS must be a string or Uint8Array");let{0:r,1:o,2:s,length:i}=n.split(".");if(i!==3)throw new ft("Invalid Compact JWS");let a=await _l({payload:o,protected:r,signature:s},e,t),l={payload:a.payload,protectedHeader:a.protectedHeader};return typeof e=="function"?{...l,key:a.key}:l}var zf=n=>Math.floor(n.getTime()/1e3);var uI=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Sl=n=>{let e=uI.exec(n);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");let t=parseFloat(e[2]),r=e[3].toLowerCase(),o;switch(r){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(t);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(t*60);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(t*3600);break;case"day":case"days":case"d":o=Math.round(t*86400);break;case"week":case"weeks":case"w":o=Math.round(t*604800);break;default:o=Math.round(t*31557600);break}return e[1]==="-"||e[4]==="ago"?-o:o};var eb=n=>n.toLowerCase().replace(/^application\//,""),fI=(n,e)=>typeof n=="string"?e.includes(n):Array.isArray(n)?e.some(Set.prototype.has.bind(new Set(n))):!1,kl=(n,e,t={})=>{let{typ:r}=t;if(r&&(typeof n.typ!="string"||eb(n.typ)!==eb(r)))throw new ir('unexpected "typ" JWT header value',"typ","check_failed");let o;try{o=JSON.parse(Xt.decode(e))}catch(m){}if(!Wt(o))throw new Jt("JWT Claims Set must be a top-level JSON object");let{requiredClaims:s=[],issuer:i,subject:a,audience:l,maxTokenAge:c}=t,u=[...s];c!==void 0&&u.push("iat"),l!==void 0&&u.push("aud"),a!==void 0&&u.push("sub"),i!==void 0&&u.push("iss");for(let m of new Set(u.reverse()))if(!(m in o))throw new ir(`missing required "${m}" claim`,m,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(o.iss))throw new ir('unexpected "iss" claim value',"iss","check_failed");if(a&&o.sub!==a)throw new ir('unexpected "sub" claim value',"sub","check_failed");if(l&&!fI(o.aud,typeof l=="string"?[l]:l))throw new ir('unexpected "aud" claim value',"aud","check_failed");let f;switch(typeof t.clockTolerance){case"string":f=Sl(t.clockTolerance);break;case"number":f=t.clockTolerance;break;case"undefined":f=0;break;default:throw new TypeError("Invalid clockTolerance option type")}let{currentDate:d}=t,p=zf(d||new Date);if((o.iat!==void 0||c)&&typeof o.iat!="number")throw new ir('"iat" claim must be a number',"iat","invalid");if(o.nbf!==void 0){if(typeof o.nbf!="number")throw new ir('"nbf" claim must be a number',"nbf","invalid");if(o.nbf>p+f)throw new ir('"nbf" claim timestamp check failed',"nbf","check_failed")}if(o.exp!==void 0){if(typeof o.exp!="number")throw new ir('"exp" claim must be a number',"exp","invalid");if(o.exp<=p-f)throw new Rs('"exp" claim timestamp check failed',"exp","check_failed")}if(c){let m=p-o.iat,y=typeof c=="number"?c:Sl(c);if(m-f>y)throw new Rs('"iat" claim timestamp check failed (too far in the past)',"iat","check_failed");if(m<0-f)throw new ir('"iat" claim timestamp check failed (it should be in the past)',"iat","check_failed")}return o};async function Wf(n,e,t){var i;let r=await jf(n,e,t);if((i=r.protectedHeader.crit)!=null&&i.includes("b64")&&r.protectedHeader.b64===!1)throw new Jt("JWTs MUST NOT use unencoded payload");let s={payload:kl(r.protectedHeader,r.payload,t),protectedHeader:r.protectedHeader};return typeof e=="function"?{...s,key:r.key}:s}var gI,Il,ob;(typeof navigator=="undefined"||!((ob=(Il=navigator.userAgent)==null?void 0:Il.startsWith)!=null&&ob.call(Il,"Mozilla/5.0 ")))&&(gI="jose/v5.3.0");var Kf={};uu(Kf,{decode:()=>Cl,encode:()=>yI});var yI=eo,Cl=vo;function Wi(n){if(typeof n!="string")throw new Jt("JWTs must use Compact JWS serialization, JWT must be a string");let{1:e,length:t}=n.split(".");if(t===5)throw new Jt("Only JWTs using Compact JWS serialization can be decoded");if(t!==3)throw new Jt("Invalid JWT");if(!e)throw new Jt("JWTs must contain a payload");let r;try{r=Cl(e)}catch(s){throw new Jt("Failed to base64url decode the payload")}let o;try{o=JSON.parse(Xt.decode(r))}catch(s){throw new Jt("Failed to parse the decoded payload as JSON")}if(!Wt(o))throw new Jt("Invalid JWT Claims Set");return o}var bI=`
|
|
-----BEGIN PUBLIC KEY-----
|
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyDIav6xzBzyi6eQu8aJA
|
|
O8DufA/MyTMDsD9d6PmjhuPTSlVPharZSjxRkHi6sK50ZmRedQbyiBuNp0g6so30
|
|
+zunoqT9XUpvZD0+USlGvi0J48Cop+DQbbpTlAlsmX6BxhHJLUrmgU0AhHjvJLNL
|
|
rRuzzQxrn/Oi0byUHu/moitUypX1hSYrKH5meRy8zoyGb8b0qIOEKpcpVKGyD/ne
|
|
+u0Bhh6tI8t2vQDQK0RL87dc+EqlQXxtijXBSClqvJi7o3JYTtWtuaWcZ2pQdg5y
|
|
+gDMii2hZYLNdgDM+/NcJlp3fkPztVeVRpiV20gZDhqANSjWjx9iN1Jt9A97rCSH
|
|
XQIDAQAB
|
|
-----END PUBLIC KEY-----
|
|
`.trim();var Kt=class extends Error{constructor(t,r,o){super(t);this.type=r;this.details=o;this.name="ValidationError"}};function Gf(n){return typeof n=="object"&&n!==null&&"license"in n&&typeof n.license=="string"}function Ll(n){return Array.isArray(n)&&n.every(Gf)}var Ml=class{constructor(e){this.settings=e;this.log=Te("[EndpointManager]")}isStaging(){return!1}sanitizeUrlForLog(e){try{let t=new URL(e);return t.search="",t.toString()}catch(t){return e}}validateUrl(e){if(!e||typeof e!="string")throw new Kt("URL must be a non-empty string","URL_INVALID");let t;try{t=new URL(e)}catch(s){throw new Kt("Invalid URL format","URL_INVALID")}let r=this.isStaging();if(r){if(t.protocol!=="https:"&&t.protocol!=="http:")throw new Kt("Only HTTP and HTTPS URLs are allowed in development","URL_INVALID")}else if(t.protocol!=="https:")throw new Kt("Only HTTPS URLs are allowed in production","URL_INVALID");let o=t.hostname.toLowerCase();if((o==="localhost"||o==="127.0.0.1"||o==="::1")&&this.log(`Warning: Using localhost endpoint (development build: ${r})`),!o||o.length<3)throw new Kt("Invalid hostname","URL_INVALID")}async getPublicKey(){if(this._publicKeyCache)return this._publicKeyCache;try{return this._publicKeyCache=await Vf(bI,"RS256"),this._publicKeyCache}catch(e){throw new Kt("Failed to import public key","JWT_VERIFICATION_FAILED",e)}}getApiUrl(){return this._validatedApiUrl||"https://api.system3.md"}getAuthUrl(){return this._validatedAuthUrl||"https://auth.system3.md"}getDefaultUrls(){return{apiUrl:"https://api.system3.md",authUrl:"https://auth.system3.md",environment:"production"}}async validateAndSetEndpoints(e=1e4){let t=this.settings.get(),r=this.getActiveTenant(t);if(!r)return this.log("No active enterprise tenant configured, using defaults"),this._validatedApiUrl=void 0,this._validatedAuthUrl=void 0,{success:!0};try{let o=this.performTenantValidation(r.tenantUrl),s=new Promise((a,l)=>setTimeout(()=>l(new Error(`Validation timed out after ${e}ms`)),e));return await Promise.race([o,s])}catch(o){let s=o instanceof Error?o.message:"Unknown error";return this.log("Failed to validate tenant:",s),{success:!1,error:s}}}async performTenantValidation(e){try{this.validateUrl(e);let t=await this.fetchTenantLicense(e);if(!t.success)return{success:!1,error:`Failed to fetch tenant license: ${t.error}`};let r=await this.validateTenantLicense(t.license,e);if(!r.success)return{success:!1,error:`Tenant license validation failed: ${r.error}`};let o=await this.verifyJWT(t.license);return!o.apiUrl||!o.authUrl?{success:!1,error:"License missing required apiUrl or authUrl"}:o.authUrl!==e?{success:!1,error:`Tenant URL mismatch: expected ${e}, license has ${o.authUrl}`}:(this._validatedApiUrl=o.apiUrl,this._validatedAuthUrl=o.authUrl,this.log("Successfully validated enterprise tenant",{tenant:e,apiUrl:this._validatedApiUrl,authUrl:this._validatedAuthUrl,customer:o.customer}),{success:!0,licenseInfo:r.licenseInfo})}catch(t){return{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}async fetchTenantLicense(e){try{let t=new URL(e),r=`${t.protocol}//${t.host}/.well-known/relay.md/license`;this.log("Fetching tenant license from:",r);let o=await at(r,{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`License fetch failed: ${o.status} ${o.statusText}`);let s=await o.json(),i=[];if(Ll(s))i=s;else if(s&&typeof s=="object"&&"licenses"in s&&Ll(s.licenses))i=s.licenses;else if(Gf(s))i=[s];else throw new Kt("No valid licenses found in response","LICENSE_NOT_FOUND");if(i.length===0)throw new Error("Empty license list");return{success:!0,license:i[0].license}}catch(t){let r=t instanceof Error?t.message:"Unknown error";return r.includes("Failed to fetch")||r.includes("NetworkError")||r.includes("ERR_")||r.includes("ECONNREFUSED")?r=`Unable to connect to ${e}. Please check the URL and ensure the server is running.`:r.includes("404")?r=`No tenant license found at ${e}. This may not be a valid Enterprise Relay tenant.`:r.includes("License fetch failed"),this.log("Tenant license fetch error:",r),{success:!1,error:r}}}findMatchingEndpointLicense(e,t,r){this.log(`Searching for ${r} license for ${this.sanitizeUrlForLog(t)}`);for(let o of e)try{let s=Wi(o.license);if(s.endpointType===r&&s.url===t)return this.log(`Found matching license for ${r}: ${this.sanitizeUrlForLog(t)}`),o}catch(s){continue}return null}async validateTenantLicense(e,t){this.log(`Tenant license validation starting: ${this.sanitizeUrlForLog(t)}`);try{let r=await this.verifyJWT(e);if(r.iss!=="https://auth.system3.md")throw new Kt(`Invalid token issuer: expected https://auth.system3.md, got ${r.iss}`,"LICENSE_INVALID");if(r.sub!=="endpoint-certificate")throw new Kt(`Invalid token subject: expected "endpoint-certificate", got ${r.sub}`,"LICENSE_INVALID");let o={issuer:r.iss||"Unknown",subject:r.sub||"Unknown",validFrom:r.iat?new Date(r.iat*1e3).toISOString():"Unknown",validTo:r.exp?new Date(r.exp*1e3).toISOString():"Unknown",isValid:!0};return this.log(`Tenant license validation successful: ${this.sanitizeUrlForLog(t)}`),{success:!0,licenseInfo:o}}catch(r){let o=r instanceof Error?r.message:"Unknown error";return this.log(`Tenant license validation failed: ${this.sanitizeUrlForLog(t)} - ${o}`),{success:!1,error:o}}}validateLicenseClaims(e,t,r){if(e.iss!=="https://auth.system3.md")throw new Kt(`Invalid token issuer: expected https://auth.system3.md, got ${e.iss}`,"LICENSE_INVALID");if(e.sub!=="endpoint-certificate")throw new Kt(`Invalid token subject: expected "endpoint-certificate", got ${e.sub}`,"LICENSE_INVALID");if(e.endpointType!==t)throw new Kt(`License endpoint type mismatch: expected ${t}, got ${e.endpointType}`,"LICENSE_INVALID");if(e.url!==r)throw new Kt(`License URL mismatch: expected ${r}, got ${e.url}`,"LICENSE_INVALID")}async verifyJWT(e){try{let t=await this.getPublicKey(),{payload:r}=await Wf(e,t,{algorithms:["RS256"]});return r}catch(t){throw this.log("JWT verification failed:",t),new Kt(`JWT verification failed: ${t instanceof Error?t.message:"Unknown error"}`,"JWT_VERIFICATION_FAILED",t)}}clearValidatedEndpoints(){this._validatedApiUrl=void 0,this._validatedAuthUrl=void 0,this.log("Cleared validated endpoints, reverted to defaults")}hasValidatedEndpoints(){return!!(this._validatedApiUrl&&this._validatedAuthUrl)}getActiveTenant(e){if(!(!e.activeTenantId||!e.tenants))return e.tenants.find(t=>t.id===e.activeTenantId)}generateTenantId(e){try{let t=new URL(e);return`${t.hostname}:${t.port||(t.protocol==="https:"?"443":"80")}`}catch(t){return e.replace(/[^a-zA-Z0-9]/g,"_")}}async addTenant(e,t=!0){var r;try{this.validateUrl(e);let o=this.generateTenantId(e);if((r=this.settings.get().tenants)!=null&&r.some(l=>l.id===o))return{success:!1,error:"This tenant is already configured"};let i={id:o,name:e,tenantUrl:e,isValidated:!1},a;if(t){let l=await this.fetchTenantLicense(e);if(!l.success)return{success:!1,error:l.error||"Failed to fetch tenant license"};let c=await this.validateTenantLicense(l.license,e);if(!c.success)return{success:!1,error:c.error||"Tenant license validation failed"};a=c;let u=await this.verifyJWT(l.license);i={...i,name:u.customer||e,apiUrl:u.apiUrl,authUrl:u.authUrl,customer:u.customer,logo:u.logo,environment:u.environment,isValidated:!0,lastValidated:Date.now()}}return await this.settings.update(l=>({...l,tenants:[...l.tenants||[],i]})),{success:!0,tenantId:o,licenseInfo:a==null?void 0:a.licenseInfo}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Unknown error"}}}async removeTenant(e){let t=this.settings.get(),r=t.tenants||[];if(!r.some(s=>s.id===e))return!1;let o={tenants:r.filter(s=>s.id!==e)};return t.activeTenantId===e&&(o.activeTenantId=void 0,this._validatedApiUrl=void 0,this._validatedAuthUrl=void 0),await this.settings.update(s=>({...s,...o})),!0}async switchToTenant(e){var o;let r=(o=this.settings.get().tenants)==null?void 0:o.find(s=>s.id===e);return r?(await this.settings.update(s=>({...s,activeTenantId:e})),r.isValidated&&r.apiUrl&&r.authUrl?(this._validatedApiUrl=r.apiUrl,this._validatedAuthUrl=r.authUrl):(this._validatedApiUrl=void 0,this._validatedAuthUrl=void 0),{success:!0}):{success:!1,error:"Tenant not found"}}async getCustomerInfo(){if(!this.hasValidatedEndpoints())return null;let e=this.settings.get(),t=this.getActiveTenant(e);if(!t)return null;try{if(t.isValidated&&t.customer)return{customer:t.customer,logo:t.logo};let r=await this.fetchTenantLicense(t.tenantUrl);if(r.success&&r.license){let o=await this.verifyJWT(r.license);return{customer:o.customer,logo:o.logo}}}catch(r){this.log("Failed to get customer info:",r)}return null}async getDefaultTenantInfo(){try{let e=await this.fetchTenantLicense("https://auth.system3.md");if(e.success&&e.license){let t=await this.verifyJWT(e.license);return{customer:t.customer,logo:t.logo,environment:"production"}}}catch(e){this.log("Failed to get default tenant info:",e)}return null}async testValidateTenant(e,t=1e4){try{let r=this.performTestValidation(e),o=new Promise((i,a)=>setTimeout(()=>a(new Error(`Validation timed out after ${t}ms`)),t));return await Promise.race([r,o])}catch(r){let o=r instanceof Error?r.message:"Unknown error";return this.log("Failed to test validate endpoints:",o),{success:!1,error:o}}}async performTestValidation(e){try{this.validateUrl(e);let t=await this.fetchTenantLicense(e);if(!t.success)return{success:!1,error:`Failed to fetch tenant license: ${t.error}`};let r=await this.validateTenantLicense(t.license,e);if(!r.success)return{success:!1,error:`Tenant license validation failed: ${r.error}`};let o=await this.verifyJWT(t.license);return this.log("Test validation successful for tenant",{tenantUrl:e,apiUrl:o.apiUrl,authUrl:o.authUrl}),{success:!0,licenseInfo:r.licenseInfo}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}async fetchEndpointLicenseForUrl(e,t,r){try{let o=new URL(e),s=`${o.protocol}//${o.host}/.well-known/relay.md/license`;this.log(`Fetching ${t.toUpperCase()} licenses for test validation from:`,s);let i=await at(s,{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`License fetch failed: ${i.status} ${i.statusText}`);let a=await i.json();this.log("License response received from:",s);let l=[];if(Ll(a))l=a;else if(a&&typeof a=="object"&&"licenses"in a&&Ll(a.licenses))l=a.licenses;else if(Gf(a))l=[a];else throw new Kt("No valid licenses found in response","LICENSE_NOT_FOUND");if(this.log(`Parsed ${l.length} licenses`),l.length===0)throw new Error("Empty license list");let c=this.findMatchingEndpointLicense(l,r,t);if(!c)throw new Kt(`No valid ${t.toUpperCase()} license found for: ${r}`,"LICENSE_NOT_FOUND");return{success:!0,license:c.license}}catch(o){let s=o instanceof Error?o.message:"Unknown error";return this.log("License fetch error:",s),{success:!1,error:`License fetch failed: ${s}`}}}};function vI(n){if("email"in n&&"name"in n&&"given_name"in n&&"family_name"in n){let e=n;return{name:e.name,given_name:e.given_name,family_name:e.family_name,email:e.email,picture:e.picture}}if("email"in n&&"login"in n&&"avatar_url"in n){let e=n,t=(e.name||e.login).split(" ");return{name:e.name||e.login,given_name:t[0]||e.login,family_name:t.slice(1).join(" ")||"",email:e.email,picture:e.avatar_url}}if("mail"in n&&"displayName"in n){let e=n;return{name:e.displayName,given_name:e.givenName,family_name:e.surname,email:e.mail}}if("email"in n&&"given_name"in n&&"family_name"in n){let e=n;return{name:e.name||`${e.given_name} ${e.family_name}`,given_name:e.given_name,family_name:e.family_name,email:e.email,picture:e.picture}}return null}function xI(n,e,t,r){let o=r?vI(r):null;return new nl(n,(t==null?void 0:t.name)||(o==null?void 0:o.name)||"",(t==null?void 0:t.email)||(o==null?void 0:o.email)||"",(t==null?void 0:t.picture)||(o==null?void 0:o.picture)||"",e)}var Jf=class{constructor(e,t,r){this.fullAuthUrl=e,this.info=t,this.login=r}},Al=class extends it{constructor(t,r,o,s,i,a){var c;super();this.beforeLogin=s;this.loginSettings=i;let l=Te("[Pocketbase]","debug");this.authStore=new dl(`pocketbase_auth_${t}`),this.endpointManager=a,this.pb=new qn(this.endpointManager.getAuthUrl(),this.authStore),this.pb.beforeSend=(u,f)=>(l(u,f),!this.pb.authStore.isValid&&this.user&&this.logout(),f.fetch=at,f.headers=Object.assign({},f.headers,{"Relay-Version":"0.7.4"}),{url:u,options:f}),this.refreshToken(),o.setInterval(()=>this.refreshToken(),864e5),this.openSettings=r,this.pb.authStore.isValid||this.logout(),(c=this.pb.authStore.model)!=null&&c.id&&this.pb.collection("users").getOne(this.pb.authStore.model.id).then(()=>{this.getFlags()}).catch(u=>{u.status===404&&this.logout()}),Bt.set(this,"loginManager")}refreshToken(){this.pb.authStore.isValid&&(this.user=this.makeUser(this.pb.authStore),this.pb.collection("users").authRefresh().then(t=>{let r=t.token,[,o]=r.split("."),s=JSON.parse(atob(o)),i=new Date(s.exp*1e3),a=new Date,l=Math.ceil((i.getTime()-a.getTime())/(1e3*60*60*24));this.log("Token Refreshed"),this.log("JWT Info:",{expiresAt:i.toLocaleString(),expiresIn:`${l} days`,userId:s.id,email:s.email})}))}setup(t,r){var o,s;return this.pb.authStore.isValid?(this.user=this.makeUser(this.pb.authStore,(o=t==null?void 0:t.meta)==null?void 0:o.rawUser),this.notifyListeners(),t&&this.pb.collection("oauth2_response").create({user:t.record.id,oauth_response:(s=t.meta)==null?void 0:s.rawUser}).then(()=>{this.notifyListeners()}).catch(i=>{this.log(i)}),r&&this.loginSettings.set({provider:r}),!0):(this.notifyListeners(),!1)}clearPreferredProvider(){this.loginSettings.set({provider:void 0})}async checkRelayHost(t){let r={Authorization:`Bearer ${this.pb.authStore.token}`,"Relay-Version":"0.7.4"};return(0,Tl.requestUrl)({url:`${this.endpointManager.getApiUrl()}/relay/${t}/check-host`,method:"GET",headers:r})}getFlags(){let t={Authorization:`Bearer ${this.pb.authStore.token}`,"Relay-Version":"0.7.4"};(0,Tl.requestUrl)({url:`${this.endpointManager.getApiUrl()}/flags`,method:"GET",headers:t}).then(r=>{if(r.status===200){let o=r.json;fr.getInstance().applyServerFlags(o)}}).catch(r=>{this.log(r)})}whoami(){let t={Authorization:`Bearer ${this.pb.authStore.token}`};(0,Tl.requestUrl)({url:`${this.endpointManager.getApiUrl()}/whoami`,method:"GET",headers:t}).then(r=>{this.log(r.json)}).catch(r=>{this.log(r)})}get loggedIn(){return this.user!==void 0}getEndpointManager(){return this.endpointManager}async validateAndApplyEndpoints(t){let r=await this.endpointManager.validateAndSetEndpoints(t);if(r.success&&this.endpointManager.hasValidatedEndpoints()){let o=Te("[Pocketbase]","debug");this.pb=new qn(this.endpointManager.getAuthUrl(),this.authStore),this.pb.beforeSend=(s,i)=>(o(s,i),!this.pb.authStore.isValid&&this.user&&this.logout(),i.fetch=at,i.headers=Object.assign({},i.headers,{"Relay-Version":"0.7.4"}),{url:s,options:i}),this.log("Updated PocketBase instance with validated endpoints")}return r}get hasUser(){return this.user!==void 0}makeUser(t,r){var o;return xI((o=t.model)==null?void 0:o.id,t.token,t.model,r)}logout(){this.pb.cancelAllRequests(),this.pb.authStore.clear(),this.user=void 0,this.notifyListeners()}getWebviewIntercepts(t){var a;let r=this.pb.buildUrl("/api/oauth2-redirect"),o=l=>{let c=l.replace(/\//g,"\\/");return new RegExp(`^${c}.*?[?&]redirect_uri=(${r}|${encodeURIComponent(r)})`,"i")},s=l=>{let c=new URL(l),f=`${c.protocol}//${c.host}${c.pathname}`.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^${f}.*?[?&]redirect_uri=(${r}|${encodeURIComponent(r)})`,"i")},i=[o("https://accounts.google.com/o/oauth2/auth"),o("https://github.com/login/oauth/authorize"),o("https://discord.com/api/oauth2/authorize"),o("https://login.microsoftonline.com/common/oauth2/v2.0/authorize")];if(t){let l=t.oidc;(a=l==null?void 0:l.info)!=null&&a.authUrl&&(console.log("[OIDC Provider] Creating dynamic intercept for authUrl:",l.info.authUrl),i.push(s(l.info.authUrl)))}else i.push(new RegExp(`.*?/auth.*?[?&]redirect_uri=(${r}|${encodeURIComponent(r)})`,"i"));return i}updateWebviewIntercepts(t){let r=this.getWebviewIntercepts(t);return console.log("[OIDC Provider] Updated webview intercepts:",r.map(o=>o.source)),r}async initiateManualOAuth2CodeFlow(t,r){this.beforeLogin();let o=await this.pb.collection("users").listAuthMethods({fetch:t}).catch(a=>{throw a.originalError}),s=this.pb.buildUrl("/api/oauth2-redirect"),i={};for(let a of r){let l=o.authProviders.find(u=>u.name===a);if(!l){this.log(`Warning: unable to find provider: ${a}`);continue}let c=async u=>this.pb.collection("users").authWithOAuth2Code(l.name,u,l.codeVerifier,s,{fetch:t}).then(f=>(this.setup(f,l.name),f));i[a]=new Jf(l.authUrl+s,l,c)}if(Object.keys(i).length===0)throw new Error(`No valid providers found from requested list: ${r.join(", ")}`);return i}async poll(t){let r=0,o=1e3;return new Promise((s,i)=>{let a=setInterval(()=>{if(r+=1,r>=30)return clearInterval(a),i(new Error(`Auth timeout: Timed out after ${r*o/1e3} seconds`));this.pb.collection("code_exchange").getOne(t.info.state.slice(0,15)).then(l=>{if(l)return clearInterval(a),s(t.login(l.code))}).catch(l=>{})},o)})}async login(t){this.beforeLogin();let r=await this.pb.collection("users").authWithOAuth2({provider:t});return this.setup(r,t)}async openLoginPage(){return await this.openSettings(),await new Promise((r,o)=>{let s=()=>{this.loggedIn&&(this.off(s),r(!0)),r(!1)};this.on(s)})}destroy(){this.pb.cancelAllRequests(),this.pb.realtime.unsubscribe(),this.pb=null,this.authStore.destroy(),this.authStore=null,this.user=void 0,this.openSettings=null,super.destroy()}};function nb(n){return n<1e3?`${n}ms`:n<6e4?`${Math.round(n/1e3)}s`:n<36e5?`${Math.round(n/6e4)}m`:`${Math.round(n/36e5)}h`}function wI(n){let e=Wi(n.token);if(typeof e=="string")return 0;let t=e==null?void 0:e.exp;return t?t*1e3:0}var Fl=class{constructor(e,t=5){this.expiryMargin=300*1e3;this.activeConnections=0;this._activePromises=new Map,e.getStorage?this.tokenMap=e.getStorage():this.tokenMap=new Map,this.callbacks=new Map,this.refreshQueue=new Set,this._log=e.log,this.refresh=e.refresh,this.timeProvider=e.getTimeProvider(),e.getJwtExpiry?this.getJwtExpiry=e.getJwtExpiry:this.getJwtExpiry=wI,this.maxConnections=t,this.refreshInterval=null,Bt.set(this,"TokenStore")}onRefresh(e){return new Promise((r,o)=>{let s=a=>{r(a)},i=a=>{this.removeFromRefreshQueue(e),o(a)};this.refresh(e,s,i)})}start(){this.log("starting"),this.report(),this.refreshInterval=this.timeProvider.setInterval(()=>this.checkAndRefreshTokens(),60*1e3),this.checkAndRefreshTokens()}stop(){this.log("stopping"),this.refreshInterval&&(this.timeProvider.clearInterval(this.refreshInterval),this.refreshInterval=null)}_cleanupInvalidTokens(){let e=[];for(let[t,r]of this.tokenMap.entries())this.isTokenValid(r)||e.push(t);for(let t of e)this.tokenMap.delete(t)}checkAndRefreshTokens(){this.log("check and refresh tokens"),this._cleanupInvalidTokens();for(let[e,t]of this.tokenMap.entries())this.callbacks.has(e)&&this.shouldRefresh(t)&&(this.log("adding to refresh queue"),this.addToRefreshQueue(e));this.log(this.report())}dequeue(){if(this.log("getting next item in queue"),this.refreshQueue.size>0){let e=this.refreshQueue.values().next().value;return this.refreshQueue.delete(e),e}return null}addToRefreshQueue(e){if(this.activeConnections<this.maxConnections){this.log(`immediate refresh of ${e}`),this.activeConnections++;let t=o=>{this.onTokenRefreshed(e,o),this.activeConnections--;let s=this.dequeue();s&&this.addToRefreshQueue(s)},r=()=>{this.onRefreshFailure(e),this.activeConnections--;let o=this.dequeue();o&&this.addToRefreshQueue(o)};this.refresh(e,t,r)}else this.log(`enqueued refresh of ${e}`),this.refreshQueue.add(e)}removeFromRefreshQueue(e){return this.log(`removing ${e} from refresh queue`),this.refreshQueue.has(e)?(this.refreshQueue.delete(e),!0):!1}log(e){this._log(e)}onTokenRefreshed(e,t){let r=this.getJwtExpiry(t);if(this.tokenMap.has(e)){let o=this.tokenMap.get(e),s=this.callbacks.get(e);this.log(`new expiry time is ${r}`),this.tokenMap.set(e,{...o,token:t,expiryTime:r}),s(t),this.log(`Token refreshed for ${o.friendlyName} (${e})`)}}onRefreshFailure(e){var o;let t=this.tokenMap.get(e),r=((o=t==null?void 0:t.attempts)!=null?o:0)+1;r<=3?this.tokenMap.set(e,{...t,attempts:r}):this.tokenMap.delete(e)}isTokenValid(e){return this.timeProvider.getTime()<e.expiryTime}shouldRefresh(e){return this.timeProvider.getTime()+this.expiryMargin>e.expiryTime}getTokenSync(e){var t,r;return(r=(t=this.tokenMap)==null?void 0:t.get(e))==null?void 0:r.token}getTokenFromNetwork(e,t,r){var a;let o=this._activePromises.get(e);if(o)return o;let s=this.tokenMap.get(e);this.tokenMap.set(e,{token:null,friendlyName:t,expiryTime:0,attempts:(a=s==null?void 0:s.attempts)!=null?a:0}),this.callbacks.set(e,r);let i=this.onRefresh(e).then(l=>(this.onTokenRefreshed(e,l),this._activePromises.delete(e),l)).catch(l=>{throw this.onRefreshFailure(e),this._activePromises.delete(e),l});return this._activePromises.set(e,i),i}async getToken(e,t,r){if(this.log(`getting token ${t}`),this.tokenMap||Promise.reject(new Error("attempted to get token after TokenStore was destroyed.")),this.tokenMap.has(e)){let o=this.tokenMap.get(e);if(o.token&&this.isTokenValid(o))return this.callbacks.set(e,r),o.friendlyName=t,r(o.token),this.log("token was valid, cache hit!"),this._activePromises.delete(e),Promise.resolve(o.token)}return this.getTokenFromNetwork(e,t,r)}_reportWithFilter(e){let t=[],r=this.timeProvider.getTime(),o=Array.from(this.tokenMap.entries()).sort((s,i)=>s[1].expiryTime-i[1].expiryTime);for(let[s,{friendlyName:i,expiryTime:a,attempts:l}]of o){if(!e(s))continue;let c=a-r,u="";c>0?u=`expires in ${nb(c-this.expiryMargin)}`:u="expired",t.push(`${s} (${i}): ${l} attempts, (${u})`)}return t}report(){let e=[];return e.push("Token Store Report:"),e.push(`Expiry Margin: ${nb(this.expiryMargin)}`),e.push("Active Tokens:"),e.push(...this._reportWithFilter(t=>this.callbacks.has(t))),e.push("Stale Tokens:"),e.push(...this._reportWithFilter(t=>!this.callbacks.has(t))),e.push(`Queue size: ${this.refreshQueue.size}`),e.join(`
|
|
`)}async waitForQueue(){return new Promise(e=>{setInterval(()=>{if(this.refreshQueue.size==0)return e()},100)})}clearState(){this.refreshQueue.clear();for(let[e,t]of this.tokenMap.entries())this.isTokenValid(t)?this.tokenMap.set(e,{...t,attempts:0}):this.tokenMap.delete(e)}clear(e){e?this.tokenMap.forEach((t,r)=>{e(t)&&(this.tokenMap.delete(r),this.refreshQueue.delete(r))}):(this.tokenMap.clear(),this.refreshQueue.clear())}destroy(){this.clear(),this.timeProvider.destroy(),this.timeProvider=null,this.refresh=null,this.callbacks.clear(),this.callbacks=null,this._activePromises.clear(),this._activePromises=null,this.tokenMap=null}};var qo=class{constructor(e){this.seperator="/";this.namespace=e}fullKey(e){return`${this.namespace}${this.seperator}${e}`}get size(){return Object.keys(localStorage).filter(e=>e.startsWith(this.namespace+this.seperator)).length}clear(){Object.keys(localStorage).filter(e=>e.startsWith(this.namespace+this.seperator)).forEach(e=>localStorage.removeItem(e))}delete(e){let t=this.fullKey(e),r=localStorage.getItem(t)!==null;return localStorage.removeItem(t),r}forEach(e,t){Object.keys(localStorage).filter(r=>r.startsWith(this.namespace+this.seperator)).forEach(r=>{let o=r.split(`${this.namespace}${this.seperator}`)[1],s=this.get(o);e.call(t,s,o,this)})}get(e){let t=this.fullKey(e),r=localStorage.getItem(t);return r?JSON.parse(r):void 0}has(e){let t=this.fullKey(e);return localStorage.getItem(t)!==null}set(e,t){let r=this.fullKey(e);return localStorage.setItem(r,JSON.stringify(t)),this}keys(){return Object.keys(localStorage).filter(t=>t.startsWith(this.namespace+this.seperator)).map(t=>t.split(`${this.namespace}${this.seperator}`)[1]).values()}values(){return Array.from(this.keys()).map(t=>this.get(t)).values()}entries(){return Array.from(this.keys()).map(t=>[t,this.get(t)]).values()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"LocalStorage"}};var Yf=class{constructor(){this.platform="s3rn";this.product="relay"}},Qf=class{constructor(e){this.relayId=e;this.platform="s3rn";this.product="relay"}},jo=class{constructor(e,t){this.relayId=e;this.folderId=t;this.platform="s3rn";this.product="relay"}},xo=class{constructor(e,t,r){this.relayId=e;this.folderId=t;this.documentId=r;this.platform="s3rn";this.product="relay"}},ro=class{constructor(e,t,r){this.relayId=e;this.folderId=t;this.canvasId=r;this.platform="s3rn";this.product="relay"}},wo=class{constructor(e,t,r){this.relayId=e;this.folderId=t;this.fileId=r;this.platform="s3rn";this.product="relay"}},Zf=class{constructor(e,t,r,o,s,i){this.relayId=e;this.folderId=t;this.fileId=r;this.hash=o;this.contentType=s;this.contentLength=i;this.platform="s3rn";this.product="relay"}},Vr=class{constructor(e){this.folderId=e;this.platform="s3rn";this.product="relay"}},zo=class{constructor(e,t){this.folderId=e;this.documentId=t;this.platform="s3rn";this.product="relay"}},jn=class{constructor(e,t){this.folderId=e;this.canvasId=t;this.platform="s3rn";this.product="relay"}},Bs=class{constructor(e,t){this.folderId=e;this.fileId=t;this.platform="s3rn";this.product="relay"}},kt=class{static validateUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}static encode(e){let t=`${e.platform}:${e.product}`;if("relayId"in e){if(!this.validateUUID(e.relayId))throw new Error("Invalid relay UUID");t+=`:relay:${e.relayId}`}if("folderId"in e){if(!this.validateUUID(e.folderId))throw new Error("Invalid folder UUID");t+=`:folder:${e.folderId}`}if("documentId"in e){if(!this.validateUUID(e.documentId))throw new Error("Invalid document UUID");t+=`:doc:${e.documentId}`}if("canvasId"in e){if(!this.validateUUID(e.canvasId))throw new Error("Invalid document UUID");t+=`:canvas:${e.canvasId}`}if("fileId"in e){if(!this.validateUUID(e.fileId))throw new Error("Invalid document UUID");if(t+=`:file:${e.fileId}`,"hash"in e&&e.hash&&"contentType"in e&&"contentLength"in e){if(!this.validateUUID(e.fileId))throw new Error("Invalid document UUID");t+=`:sha256:${e.hash}`,t+=`:contentType:${e.contentType}`,t+=`:contentLength:${e.contentLength}`}}return t}static decode(e){let t=e.split(":");if(t.length<3)throw new Error("Invalid s3rn format");let[,r,o,s,i,a,l,c,u,f,d,p,m,y]=t;if(!this.validateUUID(s))throw new Error("Invalid UUID");if(a&&!this.validateUUID(a))throw new Error("Invalid UUID");if(c&&!this.validateUUID(c))throw new Error("Invalid UUID");if(r==="relay"&&o==="relay"&&i==="folder"&&l==="doc")return new xo(s,a,c);if(r==="relay"&&o==="relay"&&i==="folder"&&l==="canvas")return new ro(s,a,c);if(r==="relay"&&o==="relay"&&i==="folder"&&l==="file"&&u==="hash"&&d==="contentType"&&m==="contentLength")return new Zf(s,a,c,f,p,y);if(r==="relay"&&o==="relay"&&i==="folder"&&l==="file")return new wo(s,a,c);if(r==="relay"&&o==="relay"&&i=="folder")return new jo(s,a);if(r==="relay"&&o==="folder"&&i==="document")return new zo(s,a);if(r==="relay"&&o==="folder"&&i==="canvas")return new jn(s,a);if(r==="relay"&&o==="folder")return new Vr(s);if(r==="relay"&&o==="relay")return new Qf(s);if(o===void 0)return new Yf;throw new Error("Invalid s3rn format for the given product type")}};function _I(n){return n.expiryTime||0}function SI(n,e){return(...t)=>e(n,...t)}async function kI(n,e,t,r){var c;let o=Te("[TokenStore][Refresh]","debug"),s=Te("[TokenStore][Refresh]","error");o(`${e}`);let i=kt.decode(e),a;if(i instanceof xo)a=JSON.stringify({docId:i.documentId,relay:i.relayId,folder:i.folderId});else if(i instanceof ro)a=JSON.stringify({docId:i.canvasId,relay:i.relayId,folder:i.folderId});else if(i instanceof jo)a=JSON.stringify({docId:i.folderId,relay:i.relayId,folder:i.folderId});else if(i instanceof wo)a=JSON.stringify({docId:i.fileId,relay:i.relayId,folder:i.folderId});else{r(new Error("No remote to connect to"));return}if(!n.loggedIn){r(Error("Not logged in"));return}let l={Authorization:`Bearer ${(c=n.user)==null?void 0:c.token}`,"Relay-Version":"0.7.4","Content-Type":"application/json"};try{let u=n.getEndpointManager().getApiUrl(),f=await at(`${u}/token`,{method:"POST",headers:l,body:a});if(!f.ok){o(f.status,await f.text()),r(Error(`Received status code ${f.status} from an API.`));return}let d=await f.json();t(d)}catch(u){s(u,a),r(u)}}var El=class extends Fl{constructor(t,r,o,s=5){super({log:Te("[LiveTokenStore]","debug"),refresh:SI(t,kI),getJwtExpiry:_I,getStorage:function(){return new qo("TokenStore/"+o)},getTimeProvider:()=>r},s);this.loginManager=t}async getFileTokenFromNetwork(t,r,o,s){let i=`${t}${r}`,a=this._activePromises.get(i);if(a)return a;this.tokenMap.set(t,{token:null,expiryTime:0,attempts:0});let l=this.fetchFileToken(t,r,o,s).then(c=>{let u=this.getJwtExpiry(c),f=this.tokenMap.get(i);return this.tokenMap.set(r,{...f,token:c,expiryTime:u}),this._activePromises.delete(i),c}).catch(c=>{throw this._activePromises.delete(i),c});return this._activePromises.set(i,l),l}async fetchFileToken(t,r,o,s){var p;let i=Te("[TokenStore][Fetch]","debug");i(`${t}`);let a=kt.decode(t),l;if(a instanceof wo)l=JSON.stringify({docId:a.fileId,relay:a.relayId,folder:a.folderId,hash:r,contentType:o,contentLength:s});else throw new Error(`No remote to connect to for ${t}`);if(!this.loginManager.loggedIn)throw new Error("Not logged in");let c={Authorization:`Bearer ${(p=this.loginManager.user)==null?void 0:p.token}`,"Relay-Version":"0.7.4","Content-Type":"application/json"},u=this.loginManager.getEndpointManager().getApiUrl(),f=await at(`${u}/file-token`,{method:"POST",headers:c,body:l});if(!f.ok){i(f.status,await f.text());let m=await f.json();throw new Error(m.error)}return await f.json()}async getFileToken(t,r,o,s){let i=`${t}${r}`,a=this.tokenMap.get(i);return a&&a.token&&this.isTokenValid(a)?(this.log("token was valid, cache hit!"),this._activePromises.delete(i),Promise.resolve(a.token)):this.getFileTokenFromNetwork(t,r,o,s)}};function II(n){if(typeof window!="undefined"&&window.btoa)return window.btoa(n);if(typeof Buffer!="undefined")return Buffer.from(n).toString("base64");throw new Error("Unable to encode to Base64")}function sb(n){let e=JSON.stringify(n),t=II(e);return t=t.replace("+","-").replace("/","_").replace(/=+$/,""),t}function CI(n,e,t){let r={token:n.token},o=new ol(n.url,n.docId,e,{connect:!1,params:r,disableBc:!0,maxConnectionErrors:3});return t&&o.awareness.setLocalStateField("user",{name:t.name,id:t.id,color:t.color.color,colorLight:t.color.light}),o}var Wo=class extends Ze{constructor(t,r,o,s){var c;super();this.guid=t;this._s3rn=r;this.tokenStore=o;this.loginManager=s;this.listeners=new Map,this.loginManager=s;let i=(c=this.loginManager)==null?void 0:c.user;this.ydoc=new Oo,He().enableDocumentHistory&&(this.ydoc.gc=!1),i&&new Va(this.ydoc).setUserMapping(this.ydoc,this.ydoc.clientID,i.id),this.tokenStore=o,this.clientToken=this.tokenStore.getTokenSync(kt.encode(this.s3rn))||{token:"",url:"",docId:"-",expiryTime:0},this._provider=CI(this.clientToken,this.ydoc,i);let a=this.providerConnectionErrorSubscription(u=>{this.log(`[${this.path}] disconnection event`,u);let f=this._provider.canReconnect();this.disconnect(),f&&this.connect()});a.on(),this._offConnectionError=a.off;let l=this.providerStateSubscription(u=>{this.notifyListeners()});l.on(),this._offState=l.off}get s3rn(){return this._s3rn}set s3rn(t){this._s3rn=t,this.refreshProvider(this.clientToken)}get debuggerUrl(){return`https://debugger.y-sweet.dev/?payload=${sb(this.clientToken)}`}notifyListeners(){this.debug("[Provider State]",this.path,this.state),this.listeners.forEach(t=>{t(this.state)})}subscribe(t,r){return this.listeners.set(t,r),()=>{this.unsubscribe(t)}}unsubscribe(t){this.listeners.delete(t)}async getProviderToken(){return this.log("get provider token"),this.tokenStore.getToken(kt.encode(this.s3rn),this.path||"unknown",this.refreshProvider.bind(this))}providerActive(){var t;if(this.clientToken){let r=this._provider.hasUrl(this.clientToken.url),o=Date.now()>(((t=this.clientToken)==null?void 0:t.expiryTime)||0);return r&&!o}return!1}refreshProvider(t){if(this.clientToken=t,!this._provider)throw new Error("missing provider!");let r=this._provider.refreshToken(t.url,t.docId,t.token);if(r.urlChanged){let o=r.newUrl.replace(/token=[^&]+/,"token=[REDACTED]");this.log(`Token Refreshed: setting new provider url, ${o}`)}}get connected(){return this.state.status==="connected"}connect(){return this.connected?Promise.resolve(!0):this.getProviderToken().then(t=>(this.refreshProvider(t),this._provider.connect(),this.notifyListeners(),!0)).catch(t=>!1)}get state(){return this._provider.connectionState}get intent(){return this._provider.intent}get synced(){return this._provider.synced}disconnect(){this._provider.disconnect(),this.tokenStore.removeFromRefreshQueue(this.guid),this.notifyListeners()}withActiveProvider(){return this.providerActive()?new Promise(t=>{t(this)}):this.getProviderToken().then(t=>this)}onceConnected(){return new Promise(t=>{let r=o=>{o.status==="connected"&&t()};this._provider.on("status",r)})}onceProviderSynced(){return this._provider.synced?Promise.resolve():new Promise(t=>{this._provider.once("synced",()=>{t()})})}reset(){this.disconnect(),this.clientToken={token:"",url:"",docId:"-",expiryTime:0}}providerConnectionErrorSubscription(t){return{on:()=>{this._provider.on("connection-error",t)},off:()=>{this._provider.off("connection-error",t)}}}providerStateSubscription(t){return{on:()=>{this._provider.on("status",t)},off:()=>{this._provider.off("status",t)}}}destroy(){this._offConnectionError&&this._offConnectionError(),this._offState&&this._offState(),this._provider&&this._provider.destroy(),this.loginManager=null}};var lb=require("obsidian");var C5=require("obsidian"),Ko=class{constructor(e,t,r){this.vault=e;this.contents=r;this.parent=null;this.path=t,this.name=t.split("/").pop()||"",this.extension=this.name.includes(".")&&this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),this.stat={ctime:Date.now(),mtime:Date.now(),size:0}}delete(){return Promise.resolve()}rename(e){return this.path=e,this.name=e.split("/").pop()||"",this.extension=this.name.includes(".")&&this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),Promise.resolve()}getBasePath(){return this.path.substring(0,this.path.lastIndexOf("/"))}},Pl=class{constructor(){this.dbName="RelayDiskBuffer";this.storeName="diskBuffers";this.dbPromise=null}async getDB(){return this.dbPromise||(this.dbPromise=this.openDB()),this.dbPromise}async openDB(){return new Promise((e,t)=>{let r=indexedDB.open(this.dbName,1);r.onerror=()=>t(r.error),r.onsuccess=()=>e(r.result),r.onupgradeneeded=o=>{o.target.result.createObjectStore(this.storeName,{keyPath:"guid"})}})}async saveDiskBuffer(e,t){let r=await this.getDB();return new Promise((o,s)=>{try{let l=r.transaction(this.storeName,"readwrite").objectStore(this.storeName).put({guid:e,contents:t});l.onerror=()=>s(l.error),l.onsuccess=()=>o()}catch(i){s(i)}})}async loadDiskBuffer(e){let t=await this.getDB();return new Promise((r,o)=>{try{let a=t.transaction(this.storeName,"readonly").objectStore(this.storeName).get(e);a.onerror=()=>o(a.error),a.onsuccess=()=>r(a.result?a.result.contents:null)}catch(s){o(s)}})}async removeDiskBuffer(e){let t=await this.getDB();return new Promise((r,o)=>{try{let a=t.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(e);a.onerror=()=>o(a.error),a.onsuccess=()=>r()}catch(s){o(s)}})}};var oo=class{constructor(e,t){this.currentPromise=null;this.promiseFunction=e,this.checkFunction=t}getPromise(){let[e,t]=this.checkFunction(),r=o=>{if(this.currentPromise&&this.resolver){let s=this.resolver;s(o),this.timeoutId&&clearTimeout(this.timeoutId),this.resolver=void 0}return this.currentPromise};if(e){let o=r(t);if(o)return o}return this.currentPromise||(this.currentPromise=new Promise((o,s)=>{this.resolver=o,this.timeoutId=window.setTimeout(()=>{Te("[Promise]","debug")("Dependency stuck after 3s. Checking.",this.promiseFunction.toString());let[i,a]=this.checkFunction();i&&r(a)},3e3),this.promiseFunction().then(i=>{this.timeoutId&&clearTimeout(this.timeoutId),o(i)},i=>{this.timeoutId&&clearTimeout(this.timeoutId),this.currentPromise=null,s(i)})})),this.currentPromise}destroy(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.currentPromise=null,this.resolver=void 0}},Dl=class{constructor(e){this.currentPromise=null;this.promiseFunction=e}getPromise(){return this.currentPromise||(this.currentPromise=new Promise((e,t)=>{this.timeoutId=window.setTimeout(()=>{Te("[Promise]","error")("SharedPromise stuck after 3s:",this.promiseFunction.toString())},3e3),this.promiseFunction().then(r=>{this.timeoutId&&clearTimeout(this.timeoutId),this.currentPromise=null,e(r)},r=>{this.timeoutId&&clearTimeout(this.timeoutId),this.currentPromise=null,t(r)})})),this.currentPromise}destroy(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.currentPromise=null}};function ib(n,...e){return new Promise((t,r)=>{let o=window.setTimeout(()=>{Te("[Promise]","debug")("Promise stuck after 3s:",...e)},3e3);n.then(s=>{clearTimeout(o),t(s)},s=>{clearTimeout(o),r(s)})})}var LI={md:"text/markdown",txt:"text/plain",json:"application/json",js:"application/javascript",ts:"application/typescript",html:"text/html",css:"text/css",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",pdf:"application/pdf",canvas:"application/canvas+json",webp:"image/webp",avif:"image/avif",bmp:"image/bmp",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/x-m4a",flac:"audio/flac",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/opus",mp4:"video/mp4",webm:"video/webm",ogv:"video/ogg",mov:"video/quicktime",mkv:"video/x-matroska","3gp":"video/3gpp"};function yn(n){var t;let e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())||"";return LI[e]||"application/octet-stream"}var ab=Do(Rl());function no(n,e,t){let r=n.getText("contents"),o=r.toString(),s=new ab.diff_match_patch,i=s.diff_main(o,e);s.diff_cleanupSemantic(i);let a=0,l=He().enableDeltaLogging?Te("[diffMatchPatch]","debug"):(...c)=>{};l("Updating YDoc:"),l("Current content length:",o.length),l("Disk buffer length:",e.length),i.length!=0&&(n.transact(()=>{for(let[c,u]of i){switch(c){case 1:l(`Inserting "${u}" at position ${a}`),r.insert(a,u),a+=u.length;break;case 0:l(`Keeping "${u}" (length: ${u.length})`),a+=u.length;break;case-1:l(`Deleting "${u}" at position ${a}`),r.delete(a,u.length);break}l("intermediate",r.toString())}},t),l("result",r.toString()),l("Update complete. New content length:",r.toString().length))}function so(n){return n instanceof Mt}var Mt=class extends Wo{constructor(t,r,o,s){let i=s.relayId?new xo(s.relayId,s.guid,r):new zo(s.guid,r);super(r,i,s.tokenStore,o);this.whenSyncedPromise=null;this.persistenceSynced=!1;this.userLock=!1;this.unsubscribes=[];this.pendingOps=[];this.requestSave=(0,lb.debounce)(this.save,2e3);this._parent=s,this.path=t,this.name="[CRDT] "+t.split("/").pop()||"",this.setLoggers(this.name),this.extension=this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),this.vault=this._parent.vault,this.stat={ctime:Date.now(),mtime:Date.now(),size:0},this._diskBufferStore=this.sharedFolder.diskBufferStore,this.unsubscribes.push(this._parent.subscribe(this.path,a=>{a.intent==="disconnected"&&this.disconnect()})),this.setLoggers(`[SharedDoc](${this.path})`);try{let a=`${this.sharedFolder.appId}-relay-doc-${this.guid}`;this._persistence=new pn(a,this.ydoc)}catch(a){throw this.warn("Unable to open persistence.",this.guid),console.error(a),a}this.whenSynced().then(()=>{let a=l=>{let c=l.transaction.origin;l.changes.keys.size!==0&&c!=this&&this.updateStats()};this.ytext.observe(a),this.unsubscribes.push(()=>{var l;(l=this.ytext)==null||l.unobserve(a)}),this.updateStats();try{this._persistence.set("path",this.path),this._persistence.set("relay",this.sharedFolder.relayId||""),this._persistence.set("appId",this.sharedFolder.appId),this._persistence.set("s3rn",kt.encode(this.s3rn))}catch(l){}(async()=>await this.getServerSynced()||(await this.onceProviderSynced(),await this.markSynced()))()}),mn(Vo.enableDeltaLogging,()=>{let a=l=>{var u,f;let c="";c+=`Transaction origin: ${l.transaction.origin} ${(f=(u=l.transaction.origin)==null?void 0:u.constructor)==null?void 0:f.name}
|
|
`;for(let d of l.changes.delta)c+=`insert: ${d.insert}
|
|
|
|
retain: ${d.retain}
|
|
|
|
delete: ${d.delete}
|
|
`;this.debug(c)};this.ytext.observe(a),this.unsubscribes.push(()=>{this.ytext.unobserve(a)})}),this._tfile=null}move(t,r){this.path=t,this._parent=r,this.name=t.split("/").pop()||"",this.extension=this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),this.updateStats()}async process(t){this.tfile&&He().enableAutomaticDiffResolution&&this.pendingOps.push(t)}get parent(){var t;return((t=this.tfile)==null?void 0:t.parent)||null}get sharedFolder(){return this._parent}get tfile(){return this._tfile||(this._tfile=this.getTFile()),this._tfile}getTFile(){var t;return(t=this._parent)==null?void 0:t.getTFile(this)}get ytext(){return this.ydoc.getText("contents")}get text(){return this.ytext?this.ytext.toString():""}async diskBuffer(t=!1){if(t||this._diskBuffer===void 0){let r;try{let o=await this._parent.diskBufferStore.loadDiskBuffer(this.guid).catch(s=>null);return o!==null&&o!==""?r=o:r=await this._parent.read(this),this.setDiskBuffer(r.replace(/\r\n/g,`
|
|
`))}catch(o){throw console.error(o),o}}return this._diskBuffer}setDiskBuffer(t){return this._diskBuffer?this._diskBuffer.contents=t:this._diskBuffer=new Ko(this._parent.vault,"local disk",t),this._parent.diskBufferStore.saveDiskBuffer(this.guid,t).catch(r=>{}),this._diskBuffer}async clearDiskBuffer(){this._diskBuffer&&(this._diskBuffer.contents="",this._diskBuffer=void 0),await this._parent.diskBufferStore.removeDiskBuffer(this.guid).catch(t=>{})}async checkStale(){await this.whenSynced();let r=(await this.diskBuffer(!0)).contents,o=await this.sharedFolder.backgroundSync.downloadItem(this),s=new Uint8Array(o.arrayBuffer);bo(this.ydoc,s);let i=this.text!==r,a=this.text,l=a,c=[];for(let u of this.pendingOps)if(l=u(l),c.push(u),l==r){if(this.clearDiskBuffer(),a==this.text)no(this.ydoc,l,this);else return He().enableDeltaLogging?this.warn("diffMatchPatch solution is stale an cannot be applied",l,this.text):this.log("diffMatchPatch solution is stale an cannot be applied"),!0;return this.pendingOps=[],!0}return this.pendingOps=[],i||this.clearDiskBuffer(),i}async connect(){return this.sharedFolder.s3rn instanceof Vr?!1:(this.s3rn instanceof zo&&(this.sharedFolder.relayId?this.s3rn=new xo(this.sharedFolder.relayId,this.sharedFolder.guid,this.guid):this.s3rn=new zo(this.sharedFolder.guid,this.guid)),this.sharedFolder.shouldConnect&&this.sharedFolder.connect().then(t=>super.connect()))}get ready(){return this._persistence.isReady(this.synced)}hasLocalDB(){return this._persistence.hasServerSync||this._persistence.hasUserData()}async awaitingUpdates(){return await this.whenSynced(),await this.getServerSynced(),this._awaitingUpdates?(this._awaitingUpdates=!this.hasLocalDB(),this._awaitingUpdates):!1}async whenReady(){let t=async()=>await this.awaitingUpdates()?(this.log("awaiting updates"),this.connect(),await this.onceConnected(),this.log("connected"),await this.onceProviderSynced(),this.log("synced"),this):this;return this.readyPromise=this.readyPromise||new oo(t,()=>[this.ready,this]),this.readyPromise.getPromise()}whenSynced(){let t=async()=>(await this.sharedFolder.whenSynced(),new Promise(r=>{if(this.persistenceSynced){r();return}this._persistence.once("synced",()=>{this.persistenceSynced=!0,r()})}));return this.whenSyncedPromise=this.whenSyncedPromise||new oo(t,()=>[this.persistenceSynced,void 0]),this.whenSyncedPromise.getPromise()}async hasKnownPeers(){return await this.whenSynced(),this.hasLocalDB()}get mimetype(){return yn(this.path)}save(){if(this.tfile){if(this.sharedFolder.isPendingDelete(this.path)){this.warn("skipping save for pending delete",this.path);return}this.vault.modify(this.tfile,this.text),this.warn("file saved",this.path)}}async markOrigin(t){await this._persistence.setOrigin(t)}async getOrigin(){return this._persistence.getOrigin()}async markSynced(){await this._persistence.markServerSynced()}async getServerSynced(){return this._persistence.getServerSynced()}static checkExtension(t){return t.endsWith(".md")}destroy(){var t,r;this.unsubscribes.forEach(o=>{o()}),super.destroy(),this.ydoc.destroy(),this._diskBuffer&&(this._diskBuffer.contents="",this._diskBuffer=void 0),this._diskBufferStore=null,(t=this.whenSyncedPromise)==null||t.destroy(),this.whenSyncedPromise=null,(r=this.readyPromise)==null||r.destroy(),this.readyPromise=null,this._parent=null}async read(){return this.text}async cleanup(){var t;(t=this._diskBufferStore)==null||t.removeDiskBuffer(this.guid)}updateStats(){this.stat.mtime=Date.now(),this.stat.size=this.text.length}async write(t){this.ytext.delete(0,this.ytext.length),this.ytext.insert(0,t),this.updateStats()}async append(t){this.ytext.insert(this.ytext.length,t),this.updateStats()}};var bn=class extends it{constructor(){super(),this._set=new Set}add(e){let t=this._set.size;return this._set.add(e),this._set.size>t&&this.notifyListeners(),this}delete(e){let t=this._set.delete(e);return t&&this.notifyListeners(),t}clear(){this._set.clear(),this.notifyListeners()}has(e){return this._set.has(e)}items(){return[...this._set]}get size(){return this._set.size}map(e){return this.items().map(e)}forEach(e){this.items().forEach(e)}find(e){return this.items().find(e)}some(e){for(let t of this._set)if(e(t))return!0;return!1}filter(e){let t=[];for(let r of this._set)e(r)&&t.push(r);return t}};var Ul,MI=new Uint8Array(16);function Xf(){if(!Ul&&(Ul=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ul))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ul(MI)}var Yt=[];for(let n=0;n<256;++n)Yt.push((n+256).toString(16).slice(1));function cb(n,e=0){return Yt[n[e+0]]+Yt[n[e+1]]+Yt[n[e+2]]+Yt[n[e+3]]+"-"+Yt[n[e+4]]+Yt[n[e+5]]+"-"+Yt[n[e+6]]+Yt[n[e+7]]+"-"+Yt[n[e+8]]+Yt[n[e+9]]+"-"+Yt[n[e+10]]+Yt[n[e+11]]+Yt[n[e+12]]+Yt[n[e+13]]+Yt[n[e+14]]+Yt[n[e+15]]}var TI=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ed={randomUUID:TI};function AI(n,e,t){if(ed.randomUUID&&!e&&!n)return ed.randomUUID();n=n||{};let r=n.random||(n.rng||Xf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let o=0;o<16;++o)e[t+o]=r[o];return e}return cb(r)}var Hs=AI;function td(n){return Array.isArray(n.permissionParents)}var er=class extends it{constructor(t){super();this.observableName=t;this.derivedMapRefCounts=new WeakMap;this.activeDerivedMaps=new Set;this._map=new Map,this._derivedMaps=new WeakMap}set(t,r){return this._map.set(t,r),this.notifyListeners(),this}delete(t){let r=this._map.delete(t);return r&&this.notifyListeners(),r}clear(){this._map.clear(),this.notifyListeners()}has(t){return this._map.has(t)}get(t){return this._map.get(t)}keys(){return[...this._map.keys()]}values(){return[...this._map.values()]}entries(){return[...this._map.entries()]}get size(){return this._map.size}forEach(t){this._map.forEach(t)}find(t){for(let[r,o]of this._map)if(t(o,r))return o}some(t){for(let[r,o]of this._map)if(t(o,r))return!0;return!1}subscribe(t){let r=null;for(let s of this.activeDerivedMaps)if(s&&s.parentCallback===t){r=s;break}if(r){let s=this.derivedMapRefCounts.get(r)||0;this.derivedMapRefCounts.set(r,s+1)}let o=super.subscribe(t);return()=>{if(r){let i=(this.derivedMapRefCounts.get(r)||0)-1;i<=0?(this.derivedMapRefCounts.delete(r),this.activeDerivedMaps.delete(r),r.destroy()):this.derivedMapRefCounts.set(r,i)}o()}}unsubscribe(t){for(let r of this.activeDerivedMaps)if(r&&r.parentCallback===t){let s=(this.derivedMapRefCounts.get(r)||0)-1;s<=0?(this.derivedMapRefCounts.delete(r),this.activeDerivedMaps.delete(r),r.destroy()):this.derivedMapRefCounts.set(r,s);break}super.unsubscribe(t)}filter(t){let r=this._derivedMaps.get(t);if(r)return r;let o=new rd(this,t);return this._derivedMaps.set(t,o),this.derivedMapRefCounts.set(o,0),this.activeDerivedMaps.add(o),o}},rd=class extends er{constructor(t,r){super();this.parentMap=t;this.predicate=r;this.parentCallback=()=>{let o=new Map;this.parentMap.forEach((s,i)=>{this.predicate(s,i)&&o.set(i,s)}),this._map=o,this.notifyListeners()},this.observableName=t.observableName+"(filter: "+r.toString()+")",this.parentCallback(this.parentMap)}sub(){this.unsub||(this.unsub=this.parentMap.subscribe(this.parentCallback))}subscribe(t){return this.sub(),super.subscribe(t)}unsubscribe(t){super.unsubscribe(t),this._listeners.size===0&&this.unsub&&(this.unsub(),this.unsub=void 0)}destroy(){var t;this.destroyed||(this.destroyed=!0,this.unsub&&(this.unsub(),this.unsub=void 0),(t=this._listeners)==null||t.clear(),this.parentCallback=null)}};var qs=class extends it{constructor(t,r){super();this.evaluate=t;this.unsubscribes=[];this.subscriberCount=0;this.observableName="ObservablePermission";this.currentValue=this.evaluate(),r.forEach(o=>{let s=o.on(()=>{let i=this.evaluate();i!==this.currentValue&&(this.currentValue=i,this.notifyListeners())});this.unsubscribes.push(s)})}subscribe(t){if(this.destroyed)throw new Error("Cannot subscribe to destroyed ObservablePermission");this.subscriberCount++,t(this.currentValue);let r=this.on(()=>{t(this.currentValue)});return()=>{r(),this.subscriberCount--,this.subscriberCount===0&&this.destroy()}}destroy(){var t;this.destroyed||(this.destroyed=!0,this.unsubscribes.forEach(r=>r()),this.unsubscribes.length=0,(t=this._listeners)==null||t.clear())}},Ol=class{constructor(e){this.relayManager=e;this.policies=new Map;this.registerBuiltinPolicies()}isAllowed(e){let t=this.getResourceType(e.resource),r=`${t}:${e.action}`,o=this.policies.get(r);if(!o)return{allowed:!1,policy:r,context:{resourceType:t,action:e.action,principal:e.principal}};try{return{allowed:o.evaluate(e,this.relayManager),policy:r,context:{resourceType:t,action:e.action,principal:e.principal}}}catch(s){return{allowed:!1,policy:r,context:{resourceType:t,action:e.action,principal:e.principal}}}}can(e,t,r,o){let s=this.getResourceType(r),i=t[1];if(t[0]!==r[0])throw new Error(`unexpected permission/resource mismatch ${t[0]} ${r[0]}`);let a=`${s}:${i}`,l=this.policies.get(a),c={principal:e,action:i,resource:r,context:o},u=l?this.getFilteredCollections(l.dependencies,c):[];return new qs(()=>this.isAllowed(c).allowed,u)}getPolicies(){return Array.from(this.policies.keys()).sort()}registerPolicy(e){let[t,r]=e.permission,o=`${t}:${r}`;this.policies.set(o,e)}getResourceType(e){return e[0]}getResourceId(e){return e[1]}getFilteredCollections(e,t){let r=[];for(let o of Object.keys(e)){let s=this.relayManager.getCollectionMapByName(o);s&&r.push(s)}return r}registerBuiltinPolicies(){this.registerPolicy({permission:["folder","delete"],description:"Delete a shared folder",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource)&&e.userId===t.principal,relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId&&e.userId===t.principal)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource)},evaluate:this.evaluateFolderDelete.bind(this)}),this.registerPolicy({permission:["folder","rename"],description:"Rename a shared folder",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource)&&e.userId===t.principal,relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId&&e.userId===t.principal)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource)},evaluate:this.evaluateFolderRename.bind(this)}),this.registerPolicy({permission:["folder","read_content"],description:"Read folder contents and add to vault",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource),relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource)},evaluate:this.evaluateFolderRead.bind(this)}),this.registerPolicy({permission:["folder","edit_content"],description:"Edit notes in folder",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource),relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource)},evaluate:this.evaluateFolderWrite.bind(this)}),this.registerPolicy({permission:["folder","upload"],description:"Upload attachments to folder",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource),relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource),relays:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.id===r.relayId)},storage_quotas:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource)),o=r&&this.relayManager.relays.get(r.relayId);return!!(o&&e.id===o.storageQuotaId)}},evaluate:this.evaluateFolderUpload.bind(this)}),this.registerPolicy({permission:["folder","download"],description:"Download attachments from folder",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource),relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource)},evaluate:this.evaluateFolderDownload.bind(this)}),this.registerPolicy({permission:["folder","manage_files"],description:"Add/remove/rename files in folder",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource),relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource)},evaluate:this.evaluateFolderManageFiles.bind(this)}),this.registerPolicy({permission:["relay","delete"],description:"Delete a relay server",dependencies:{relay_roles:(e,t)=>e.relayId===this.getResourceId(t.resource)&&e.userId===t.principal},evaluate:this.evaluateRelayDelete.bind(this)}),this.registerPolicy({permission:["relay","rename"],description:"Rename a relay server",dependencies:{relay_roles:(e,t)=>e.relayId===this.getResourceId(t.resource)&&e.userId===t.principal},evaluate:this.evaluateRelayRename.bind(this)}),this.registerPolicy({permission:["relay","manage_users"],description:"Manage users in relay server (add/remove/change roles)",dependencies:{relay_roles:(e,t)=>e.relayId===this.getResourceId(t.resource)&&e.userId===t.principal},evaluate:this.evaluateRelayManageUsers.bind(this)}),this.registerPolicy({permission:["relay","manage_sharing"],description:"Manage relay share keys (enable/disable sharing, rotate keys)",dependencies:{relay_roles:(e,t)=>e.relayId===this.getResourceId(t.resource)&&e.userId===t.principal},evaluate:this.evaluateRelayManageSharing.bind(this)}),this.registerPolicy({permission:["subscription","manage"],description:"Manage relay subscriptions and plans",dependencies:{relay_roles:(e,t)=>e.relayId===this.getResourceId(t.resource)&&e.userId===t.principal},evaluate:this.evaluateSubscriptionManage.bind(this)}),this.registerPolicy({permission:["folder","manage_users"],description:"Manage users in folder (add/remove/change roles)",dependencies:{folder_roles:(e,t)=>e.sharedFolderId===this.getResourceId(t.resource)&&e.userId===t.principal,relay_roles:(e,t)=>{let r=this.relayManager.remoteFolders.get(this.getResourceId(t.resource));return!!(r&&e.relayId===r.relayId&&e.userId===t.principal)},shared_folders:(e,t)=>e.id===this.getResourceId(t.resource)},evaluate:this.evaluateFolderManageUsers.bind(this)})}isFolderCreator(e,t){let r=this.relayManager.remoteFolders.get(t);return(r==null?void 0:r.creatorId)===e}isRelayOwnerForFolder(e,t){let r=this.relayManager.remoteFolders.get(t);return r?this.isRelayOwner(e,r.relayId):!1}isRelayOwner(e,t){return!!this.relayManager.relayRoles.find(o=>o.relayId===t&&o.userId===e&&o.role==="Owner")}hasRelayRole(e,t,r){let o=Array.isArray(r)?r:[r];return!!this.relayManager.relayRoles.find(i=>i.relayId===t&&i.userId===e&&o.includes(i.role))}hasFolderRole(e,t,r){let o=Array.isArray(r)?r:[r];return!!this.relayManager.folderRoles.find(i=>i.sharedFolderId===t&&i.userId===e&&o.includes(i.role))}hasFolderAccess(e,t){let r=this.relayManager.remoteFolders.get(t);return r?this.getUserFolderRole(e,t)?!0:r.private?!1:!!this.getUserRelayRole(e,r.relayId):!1}hasFolderWriteAccess(e,t){let r=this.relayManager.remoteFolders.get(t);if(!r)return!1;let o=this.getUserFolderRole(e,t);if(o&&this.roleHasWritePermission(o))return!0;if(!r.private){let s=this.getUserRelayRole(e,r.relayId);if(s&&this.roleHasWritePermission(s))return!0}return!1}hasFolderManagementAccess(e,t){let r=this.relayManager.remoteFolders.get(t);return r?this.isRelayOwnerForFolder(e,t)?!0:r.private?this.hasFolderRole(e,t,["Owner"]):this.isFolderCreator(e,t):!1}getUserFolderRole(e,t){let r=this.relayManager.folderRoles.find(o=>o.sharedFolderId===t&&o.userId===e);return(r==null?void 0:r.role)||null}getUserRelayRole(e,t){let r=this.relayManager.relayRoles.find(o=>o.relayId===t&&o.userId===e);return(r==null?void 0:r.role)||null}roleHasWritePermission(e){return["Owner","Member"].includes(e)}hasStorageQuota(e,t){let r=this.relayManager.remoteFolders.get(e);if(!r)return!1;let o=this.relayManager.relays.get(r.relayId);if(!o)return!1;let s=o.storageQuota;return s?s.usage+t<=s.quota:!0}evaluateFolderDelete(e){let t=this.getResourceId(e.resource);return this.hasFolderManagementAccess(e.principal,t)}evaluateFolderRename(e){let t=this.getResourceId(e.resource);return this.hasFolderManagementAccess(e.principal,t)}evaluateFolderRead(e){let t=this.getResourceId(e.resource);return this.hasFolderAccess(e.principal,t)}evaluateFolderWrite(e){let t=this.getResourceId(e.resource);return this.hasFolderWriteAccess(e.principal,t)}evaluateFolderDownload(e){let t=this.getResourceId(e.resource);return this.hasFolderAccess(e.principal,t)}evaluateFolderManageFiles(e){let t=this.getResourceId(e.resource);return this.hasFolderWriteAccess(e.principal,t)}evaluateFolderUpload(e){var o;let t=this.getResourceId(e.resource),r=((o=e.context)==null?void 0:o.fileSize)||0;return this.hasFolderWriteAccess(e.principal,t)&&this.hasStorageQuota(t,r)}evaluateRelayDelete(e){let t=this.getResourceId(e.resource);return this.isRelayOwner(e.principal,t)}evaluateRelayRename(e){let t=this.getResourceId(e.resource);return this.isRelayOwner(e.principal,t)}evaluateRelayManageUsers(e){let t=this.getResourceId(e.resource);return this.isRelayOwner(e.principal,t)}evaluateRelayManageSharing(e){let t=this.getResourceId(e.resource);return this.isRelayOwner(e.principal,t)}evaluateSubscriptionManage(e){let t=this.getResourceId(e.resource);return this.isRelayOwner(e.principal,t)}evaluateFolderManageUsers(e){let t=this.getResourceId(e.resource);return this.relayManager.remoteFolders.get(t)?this.isRelayOwnerForFolder(e.principal,t)?!0:this.hasFolderRole(e.principal,t,["Owner"]):!1}};function od(n){return typeof n.id=="string"}function FI(n){return typeof n.name=="string"}var sd=class{constructor(e){this.collectionName="roles";this.roles=e}items(){return this.roles.values()}clear(){this.roles.clear()}get(e){return this.roles.get(e)}ingest(e){return this.roles.set(e.id,e),e}delete(e){this.roles.delete(e)}};function ub(n){return typeof n.aggregate_root=="object"}function nd(n){return n&&Array.isArray(n.permissionParents)}var Ki=class{get aggregate_root(){}get permissionParents(){return[]}},id=class extends it{constructor(t,r){super();this.storageQuota=t;this.relays=r}update(t){return this.storageQuota=t,this}get name(){return this.storageQuota.name}get id(){return this.storageQuota.id}get quota(){return this.storageQuota.quota}get pending(){return this.storageQuota.pending}get usage(){return this.storageQuota.usage}get maxFileSize(){return this.storageQuota.max_file_size}get metered(){return this.storageQuota.metered}get updated(){return this.storageQuota.updated}get created(){return this.storageQuota.created}get aggregate_root(){var t;return["relays",(t=this.relays.find(r=>r.storageQuotaId===this.storageQuota.id))==null?void 0:t.id]}},ad=class{constructor(e,t,r){this.subscribeRecord=e;this.storageQuota=t;this.relays=r;this.collectionName="storage_quotas"}items(){return this.storageQuota.values()}clear(){this.storageQuota.clear()}get(e){return this.storageQuota.get(e)}ingest(e){let t=this.storageQuota.get(e.id);if(t)return t.update(e),this.storageQuota.notifyListeners(),t;let r=new id(e,this.relays);return this.subscribeRecord(this.collectionName,e.id,[]).then(o=>{r.offRecordSubscription=o}),this.storageQuota.set(e.id,r),r}delete(e){var r;let t=this.storageQuota.get(e);(r=t==null?void 0:t.offRecordSubscription)==null||r.call(t),this.storageQuota.delete(e)}},$l=class extends Ki{constructor(t){super();this.user=t}get id(){return this.user.id}get name(){return this.user.name}get email(){return this.user.email}get picture(){return this.user.picture}update(t){return this.user=t,this}},ld=class extends it{constructor(t){super();this.provider=t}get id(){return this.provider.id}get name(){return this.provider.name}get url(){return this.provider.url}get selfHosted(){return this.provider.self_hosted}get publicKey(){return this.provider.public_key}get keyType(){return this.provider.key_type}get keyId(){return this.provider.key_id}update(t){return this.provider=t,this}},cd=class{constructor(e){this.providers=e;this.collectionName="providers"}items(){return this.providers.values()}clear(){this.providers.clear()}get(e){return this.providers.get(e)}ingest(e){let t=this.providers.get(e.id);if(t)return t.update(e),this.providers.notifyListeners(),t;let r=new ld(e);return this.providers.set(e.id,r),r}delete(e){this.providers.delete(e)}},ud=class extends it{constructor(t,r,o,s,i,a){super();this.remoteFolder=t;this.relays=r;this.relayRoles=o;this.folderRoles=s;this.users=i;this.user=a}update(t){return this.remoteFolder=t,this}get id(){return this.remoteFolder.id}get guid(){return this.remoteFolder.guid}get name(){return this.remoteFolder.name}set name(t){this.remoteFolder.name=t}get private(){return this.remoteFolder.private}get creator(){let t=this.users.get(this.remoteFolder.creator);if(!t)throw new Error("invalid remote folder");return t}get creatorId(){return this.remoteFolder.creator}get relay(){let t=this.relays.get(this.remoteFolder.relay);if(!t)throw new Error("invalid remote folder");return t}get relayId(){return this.remoteFolder.relay}get role(){var s,i;let t=this.remoteFolder.creator===this.user.id,r=(s=this.relayRoles.find(a=>a.relayId===this.relay.id&&a.userId===this.user.id))==null?void 0:s.role,o=(i=this.folderRoles.find(a=>a.sharedFolderId===this.remoteFolder.id&&a.userId===this.user.id))==null?void 0:i.role;if(this.remoteFolder.private){if(o)return o}else return r||this.warn("couldn't find role",this.relay.id,this.user,t),t?"Owner":r||"Member";return this.warn("couldn't find role",this.relay.id,this.user,t),t?"Owner":"Member"}get owner(){return this.role==="Owner"}get aggregate_root(){return["relays",this.remoteFolder.relay]}get permissionParents(){var r,o;let t=[];if(this.remoteFolder.private){let s=(r=this.folderRoles.find(i=>i.sharedFolderId===this.id&&i.userId===this.user.id))==null?void 0:r.id;s&&t.push(["shared_folder_roles",s])}else{let s=(o=this.relayRoles.find(i=>i.relayId===this.relayId&&i.userId===this.user.id))==null?void 0:o.id;s&&t.push(["relay_roles",s])}return t}},fd=class{constructor(e,t,r,o,s,i){this.remoteFolders=e;this.relays=t;this.folderRoles=r;this.relayRoles=o;this.users=s;this.user=i;this.collectionName="shared_folders"}items(){return this.remoteFolders.values()}clear(){this.remoteFolders.clear()}get(e){return this.remoteFolders.get(e)}ingest(e){let t=this.remoteFolders.get(e.id);if(t)return t.update(e),this.remoteFolders.notifyListeners(),t;let r=new ud(e,this.relays,this.relayRoles,this.folderRoles,this.users,this.user);return this.remoteFolders.set(e.id,r),r}delete(e){this.remoteFolders.delete(e)}},dd=class{constructor(e,t,r,o,s,i,a,l){this.relays=e;this.relayRoles=t;this.relayInvitations=r;this.remoteFolders=o;this.subscriptions=s;this.storageQuotas=i;this.providers=a;this.user=l;this.collectionName="relays"}items(){return this.relays.values()}clear(){this.relays.clear()}get(e){return this.relays.get(e)}ingest(e){let t=this.relays.get(e.id);if(t)return t.update(e),this.relays.notifyListeners(),t;let r=new Sd(e,this.relayRoles,this.relayInvitations,this.remoteFolders,this.subscriptions,this.storageQuotas,this.providers,this.user);return this.relays.set(r.id,r),r}delete(e){this.relays.delete(e)}},pd=class{constructor(e,t,r,o){this.collectionName="relay_roles";this.relayRoles=e,this.relays=t,this.users=r,this.roles=o}items(){return this.relayRoles.values()}clear(){this.relayRoles.clear()}get(e){return this.relayRoles.get(e)}ingest(e){let t=this.relayRoles.get(e.id);if(t)return t.update(e),this.relayRoles.notifyListeners(),t;let r=new vd(e,this.relays,this.users,this.roles);return this.relayRoles.set(r.id,r),r}delete(e){this.relayRoles.get(e)&&this.relayRoles.delete(e)}},md=class{constructor(e,t,r,o){this.folderRoles=e;this.remoteFolders=t;this.users=r;this.roles=o;this.collectionName="shared_folder_roles"}items(){return this.folderRoles.values()}clear(){this.folderRoles.clear()}get(e){return this.folderRoles.get(e)}ingest(e){let t=this.folderRoles.get(e.id);if(t)return t.update(e),this.folderRoles.notifyListeners(),t;let r=new xd(e,this.remoteFolders,this.users,this.roles);return this.folderRoles.set(r.id,r),r}delete(e){this.folderRoles.delete(e)}},hd=class{constructor(e,t,r){this.collectionName="relay_invitations";this.relayInvitations=e,this.relays=t,this.roles=r}items(){return this.relayInvitations.values()}clear(){this.relayInvitations.clear()}get(e){return this.relayInvitations.get(e)}ingest(e){let t=this.relayInvitations.get(e.id);if(t)return t.update(e),this.relayInvitations.notifyListeners(),t;let r=new wd(e,this.relays,this.roles);return this.relayInvitations.set(r.id,r),r}delete(e){this.relayInvitations.delete(e)}},gd=class{constructor(e){this.users=e;this.collectionName="users"}items(){return this.users.values()}clear(){this.users.clear()}get(e){return this.users.get(e)}ingest(e){let t=this.users.get(e.id);if(t)return t.update(e),this.users.notifyListeners(),t;let r=new $l(e);return this.users.set(e.id,r),r}delete(e){this.users.delete(e)}},yd=class{constructor(e,t,r){this.subscriptions=e;this.relays=t;this.users=r;this.collectionName="subscriptions"}items(){return this.subscriptions.values()}clear(){this.subscriptions.clear()}get(e){return this.subscriptions.get(e)}ingest(e){let t=this.subscriptions.get(e.id);if(t)return t.update(e),this.subscriptions.notifyListeners(),t;let r=new _d(e,this.relays,this.users);return this.subscriptions.set(e.id,r),r}delete(e){this.subscriptions.delete(e)}},bd=class extends Ze{constructor(e){super(),this.collections=new Map,this.relationships=new Map;for(let t of e)this.collections.set(t.collectionName,t);Bt.set(this,"Store")}getCollection(e){let t=this.collections.get(e);if(!t)throw this.error("No collection found for",e),new Error("No collection found for "+e);return t}clear(){let e=Xr.getInstance();e.beginTransaction(),this.collections.forEach(t=>{t.clear()}),this.collections.clear(),this.relationships.clear(),e.commitTransaction()}destroy(){this.clear(),this.collections=null,this.relationships=null}ingestPage(e){return this.ingestBatch(e==null?void 0:e.items)}ingestBatch(e){if(e)return e.map(t=>this.ingest(t))}ingest(e){let t=Xr.getInstance();t.beginTransaction();let r=this._ingest(e);return t.commitTransaction(),r}_ingest(e){if(!e)return;let t,r=this.collections.get(e.collectionName);if(r?t=r.ingest(e):this.error("No collection found for record",e),ub(t)){let o=t.aggregate_root;if(o){let s=e.id,i=this.relationships.get(o.join(":"))||new Set;i.add([e.collectionName,s].join(":")),this.relationships.set(o.join(":"),i)}}if(nd(t)){let o=t.permissionParents;for(let s of o){let i=e.id,a=this.relationships.get(s.join(":"))||new Set;a.add([e.collectionName,i].join(":")),this.relationships.set(s.join(":"),a)}}if(e.expand)for(let[,o]of Object.entries(e.expand))Array.isArray(o)?this.ingestBatch(o):this.ingest(o);return t}delete(e){this.cascade(e.collectionName,e.id)}graphviz(){let e=`digraph G {
|
|
`;for(let[t,r]of this.collections)for(let o of r.items()){if(!od(o)){this.warn("record has no id",o);continue}let s=t+"_"+o.id;if(FI(o)&&(s=t+"_"+o.name),e+=` ${t}_${o.id} [label="${s}"];
|
|
`,od(o)&&ub(o)&&o.aggregate_root){let[i,a]=o.aggregate_root;e+=` ${t}_${o.id} -> ${i}_${a};
|
|
`}if(od(o)&&nd(o))for(let i of o.permissionParents){let[a,l]=i;e+=` ${t}_${o.id} -> ${a}_${l} [style=dotted];
|
|
`}}return e+="}",e}cascade(e,t){let r=this.collections.get(e),o=this.relationships.get([e,t].join(":")),s=Xr.getInstance();s.beginTransaction(),r&&(this.warn("cascade delete parent",e,t),r.delete(t)),this.relationships.delete([e,t].join(":"));for(let i of o||[]){let[a,l]=i.split(":");try{let u=this.getCollection(a).get(l);if(nd(u)){let f=u.permissionParents.filter(d=>{let[p,m]=d;try{return!!this.getCollection(p).get(m)}catch(y){return this.warn("Parent collection not found during validation",p,y),!1}});f.length===0?(this.warn("cascade delete child (no valid permission parents)",a,l),this.cascade(a,l)):this.warn("preserving child with valid permission parents",a,l,f)}else this.warn("cascade delete child",a,l),this.cascade(a,l)}catch(c){this.warn("Failed to process child during cascade",a,l,c)}}s.commitTransaction()}},vd=class extends Ki{constructor(e,t,r,o){super(),this.users=r,this.roles=o,this.relays=t,this.relayRole=e}update(e){return this.relayRole=e,this}get id(){return this.relayRole.id}get userId(){return this.relayRole.user}get user(){let e=this.users.get(this.relayRole.user);if(!e)throw new Error(`Unable to find user: ${this.relayRole.user}`);return e}get role(){var e;return(e=this.roles.get(this.relayRole.role))==null?void 0:e.name}get relayId(){return this.relayRole.relay}get relay(){let e=this.relays.get(this.relayRole.relay);if(!e)throw new Error(`invalid role: unable to find relay ${this.relayRole.relay} on role ${this.relayRole.id}`);return e}get aggregate_root(){return["relays",this.relayRole.relay]}get permissionParents(){return[["users",this.relayRole.user]]}},xd=class extends Ki{constructor(t,r,o,s){super();this.folderRole=t;this.remoteFolders=r;this.users=o;this.roles=s}update(t){return this.folderRole=t,this}get id(){return this.folderRole.id}get userId(){return this.folderRole.user}get user(){let t=this.users.get(this.folderRole.user);if(!t)throw new Error(`Unable to find user: ${this.folderRole.user}`);return t}get role(){var t;return(t=this.roles.get(this.folderRole.role))==null?void 0:t.name}get sharedFolderId(){return this.folderRole.shared_folder}get sharedFolder(){let t=this.remoteFolders.get(this.folderRole.shared_folder);if(!t)throw new Error(`invalid role: unable to find folder ${this.folderRole.shared_folder} on role ${this.folderRole.id}`);return t}get aggregate_root(){return["shared_folders",this.folderRole.shared_folder]}get permissionParents(){return[["shared_folders",this.folderRole.shared_folder]]}},wd=class{constructor(e,t,r){this.relayInvitation=e,this.roles=r,this.relays=t}update(e){return this.relayInvitation=e,this}get key(){return this.relayInvitation.key}get id(){return this.relayInvitation.id}get role(){var e;return(e=this.roles.get(this.relayInvitation.role))==null?void 0:e.name}get relayId(){return this.relayInvitation.relay}get relay(){let e=this.relays.get(this.relayInvitation.relay);if(!e)throw new Error("invalid invitation");return e}get enabled(){return this.relayInvitation.enabled}get aggregate_root(){return["relays",this.relayInvitation.relay]}},_d=class extends it{constructor(t,r,o){super();this.subscription=t;this.relays=r;this.users=o}update(t){return this.subscription=t,this.notifyListeners(),this}get id(){return this.subscription.id}get token(){return this.subscription.token}get active(){return this.subscription.active}get user(){let t=this.users.get(this.subscription.user);if(!t)throw new Error("invalid subscription");return t}get relayId(){return this.subscription.relay}get relay(){let t=this.relays.get(this.subscription.relay);if(!t)throw new Error("invalid subscription");return t}get stripe_cancel_at(){return this.subscription.stripe_cancel_at}get cancelAt(){return this.subscription.stripe_cancel_at!==0?new Date(this.subscription.stripe_cancel_at*1e3):null}get quantity(){return this.subscription.stripe_quantity}get aggregate_root(){return["relays",this.subscription.relay]}get permissionParents(){return[["users",this.subscription.user]]}},Sd=class extends it{constructor(t,r,o,s,i,a,l,c){super();this.relay=t;this.relayRoles=r;this.relayInvitations=o;this.remoteFolders=s;this._subscriptions=i;this.storageQuotas=a;this.providers=l;this.user=c}update(t){return this.relay=t,this.notifyListeners(),this}get cta(){return this.relay.cta}get plan(){return this.relay.plan}get id(){return this.relay.id}get guid(){return this.relay.guid}get name(){return this.relay.name}set name(t){this.relay.name=t}get version(){return this.relay.version}get userLimit(){return this.relay.user_limit}get role(){var o;let t=this.relay.creator===this.user.id,r=(o=this.relayRoles.find(s=>s.relayId===this.relay.id&&s.userId===this.user.id))==null?void 0:o.role;return r||(this.warn("couldn't find role",this.relay.id,this.user,t),t?"Owner":"Member")}get owner(){return this.role==="Owner"}get invitation(){return this.relayInvitations.find(t=>t.relay.id===this.relay.id)}get storageQuota(){return this.storageQuotas.find(t=>t.id===this.relay.storage_quota)}get storageQuotaId(){return this.relay.storage_quota}get folders(){return this.remoteFolders.filter(t=>{let r=t.relayId===this.id,o=t.permissionParents.length>0;return r&&o})}get subscriptions(){return this._subscriptions.filter(t=>t.relayId===this.id)}get permissionParents(){var r;let t=(r=this.relayRoles.find(o=>o.relayId===this.id&&o.userId===this.user.id))==null?void 0:r.id;return t?[["relay_roles",t]]:[]}get provider(){if(this.relay.provider)return this.providers.get(this.relay.provider)}get providerId(){return this.relay.provider}},Nl=class extends Ze{constructor(t){super();this.loginManager=t;this.destroyed=!1;this._handleEvent=(t,r)=>{var o,s;this.debug(`[Event]: ${t}`,r.action,r.record),r.action==="delete"?(o=this.store)==null||o.delete(r.record):(s=this.store)==null||s.ingest(r.record)};this.pb=this.loginManager.pb,this.users=new er("users"),this.relays=new er("relays"),this.providers=new er("providers"),this.remoteFolders=new er("remote folders"),this.relayInvitations=new er("relay invitations"),this.relayRoles=new er("relay roles"),this.folderRoles=new er("folder roles"),this.roles=new er("roles"),this.roles.set("2arnubkcv7jpce8",{name:"Owner",id:"2arnubkcv7jpce8"}),this.roles.set("x6lllh2qsf9lxk6",{name:"Member",id:"x6lllh2qsf9lxk6"}),this.subscriptions=new er("subscriptions"),this.storageQuotas=new er("storage quotas"),this._offLoginManager=this.loginManager.on(()=>{this.loginManager.loggedIn?this.login():this.logout()}),this.setUser(),this.user&&(Bt.set(this,"RelayManager"),this.buildGraph(),this.subscribe(),this.update())}buildGraph(){if(!this.user)return;if(!this.pb){console.warn("no pb!");return}if(this.store)return;let t=new sd(this.roles),r=new gd(this.users),o=new cd(this.providers),s=new dd(this.relays,this.relayRoles,this.relayInvitations,this.remoteFolders,this.subscriptions,this.storageQuotas,this.providers,this.user),i=new pd(this.relayRoles,this.relays,this.users,this.roles),a=new md(this.folderRoles,this.remoteFolders,this.users,this.roles),l=new hd(this.relayInvitations,this.relays,this.roles),c=new fd(this.remoteFolders,this.relays,this.folderRoles,this.relayRoles,this.users,this.user),u=new yd(this.subscriptions,this.relays,this.users),f=new ad(this.subscribeRecord.bind(this),this.storageQuotas,this.relays);this.store=new bd([t,r,s,i,a,l,c,u,f,o]),this.policyManager=new Ol(this)}getCollectionMapByName(t){switch(t){case"folder_roles":return this.folderRoles;case"relay_roles":return this.relayRoles;case"shared_folders":return this.remoteFolders;case"relays":return this.relays;case"storage_quotas":return this.storageQuotas;case"subscriptions":return this.subscriptions;default:console.warn(`Unknown collection name: ${t}`);return}}setUser(){var t;this.authUser=(t=this.pb)==null?void 0:t.authStore.model,this.authUser&&(this.user=new $l(this.authUser),this.users.set(this.user.id,this.user))}login(){var t;this.authUser&&this.authUser==((t=this.pb)==null?void 0:t.authStore.model)||(this.setUser(),this.buildGraph(),this.subscribe(),this.update())}logout(){var t;(t=this.store)==null||t.clear(),this.user=void 0,this.store=void 0}async rotateKey(t){if(!this.pb)throw new Error("missing pocketbase");return this.pb.send("/api/rotate-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t.id})}).then(r=>{var s;let o=(s=this.store)==null?void 0:s.ingest(r);if(!o)throw new Error("unable to rotate key");return o})}async toggleRelayInvitation(t,r){if(!this.pb)throw new Error("missing pocketbase");return this.pb.collection("relay_invitations").update(t.id,{enabled:r}).then(o=>{var i;let s=(i=this.store)==null?void 0:i.ingest(o);if(!s)throw new Error("unable to toggle invitation enable");return s})}async getRelayInvitation(t){if(!this.pb)return;let r=this.relayInvitations.find(o=>o.relayId===t.id);return r||this.pb.collection("relay_invitations").getList(0,200).then(o=>{o.items.forEach(i=>{var a;(a=this.store)==null||a.ingest(i)});let s=this.relayInvitations.find(i=>i.relayId===t.id);if(s)return s})}async getSubscriptionToken(t){if(!this.pb||!this.pb.authStore.isValid)throw new Error("Auth is not valid");let r=`/api/subscription/${t.id}/token`,o=await this.pb.send(r,{method:"POST"});if(o!==200)throw new Error("Token API failed");return o.json().token}async subscribe(){var r;if(!this.pb||!this.pb.authStore.isValid||((r=this.pb.authStore.model)==null?void 0:r.id)===void 0){this.warn("unable to subscribe, pocketbase client is not ready");return}let t=[{name:"relays",expand:["relay_invitations_via_relay","shared_folders_via_relay","shared_folders_via_relay.creator","subscriptions_via_relay","subscriptions_via_relay.relay","subscriptions_via_relay.relay.storage_quota","creator"]},{name:"relay_invitations",expand:["relay"]},{name:"providers",expand:[]},{name:"relay_roles",expand:["user","relay"]},{name:"shared_folders",expand:["relay","creator"]},{name:"shared_folder_roles",expand:["user","shared_folder"]},{name:"subscriptions",expand:["user","relay"]}];for(let o of t)this.pb.collection(o.name).subscribe("*",s=>this._handleEvent(o.name,s),{expand:o.expand.join(","),fetch:at})}async subscribeRecord(t,r,o){var s;if(!this.pb||!this.pb.authStore.isValid||((s=this.pb.authStore.model)==null?void 0:s.id)===void 0){this.warn("unable to subscribe, pocketbase client is not ready");return}return this.pb.collection(t).subscribe(r,i=>this._handleEvent(t,i),{expand:o.join(","),fetch:at})}async refreshRemoteFolder(t){var o;if(!this.pb||!this.pb.authStore.isValid||((o=this.pb.authStore.model)==null?void 0:o.id)===void 0)return Promise.resolve([]);let r=await this.pb.collection("shared_folders").getOne(t.id,{expand:"shared_folder_roles_via_shared_folder"});!this.destroyed&&this.store&&this.store.ingest(r)}async refreshRelay(t){var o;if(!this.pb||!this.pb.authStore.isValid||((o=this.pb.authStore.model)==null?void 0:o.id)===void 0)return Promise.resolve([]);let r=await this.pb.collection("relays").getOne(t.id,{expand:"relay_roles_via_relay,shared_folders_via_relay,storage_quota"});!this.destroyed&&this.store&&this.store.ingest(r)}async update(){let t=(o,s={})=>{var i;return!this.pb||!this.pb.authStore.isValid||((i=this.pb.authStore.model)==null?void 0:i.id)===void 0?Promise.resolve([]):(typeof s=="function"&&(s=s(this.pb.authStore.model.id)),this.pb.collection(o).getFullList(s))};[t("users",o=>({filter:`id="${o}"`,expand:["relay_roles_via_user","relay_roles_via_user.relay","relay_roles_via_user.relay.storage_quota","relay_roles_via_user.role"].join(",")})),t("relay_roles",{expand:"user,role"}),t("providers"),t("relay_invitations"),t("shared_folders",{expand:"relay,creator"}),t("shared_folder_roles",{expand:"user,role"}),t("subscriptions",{expand:"relay,user"})].forEach(async o=>{let s=await o;for(let i of s)!this.destroyed&&this.store&&this.store.ingest(i)})}async acceptInvitation(t){var s;if(!this.pb)throw new Error("Failed to accept invitation");let r=await this.pb.send("/api/accept-invitation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:t})}).catch(i=>{throw i});this.debug("[InviteAccept]",r);let o=(s=this.store)==null?void 0:s.ingest(r);if(!o)throw new Error("Failed to accept invitation");return o}async createRelay(t){var i,a;let r=Hs(),o=await((i=this.pb)==null?void 0:i.collection("relays").create({guid:r,name:t,path:null},{expand:"relay_roles_via_relay,relay_invitations_via_relay,storage_quota"}));if(!o)throw new Error("Failed to create Relay");if(!this.user)throw new Error("Not Logged In");let s=(a=this.store)==null?void 0:a.ingest(o);if(!s)throw new Error("Failed to create relay");return s}async createSelfHostedRelay(t,r,o){var l;if(!this.pb)throw new Error("Not connected to relay service");let s={};if(r)s.provider=r;else if(t)s.url=t;else throw new Error("Either URL or provider ID must be provided");o&&(s.organization=o);let i=await this.pb.send("/api/collections/relays/self-host",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=(l=this.store)==null?void 0:l.ingest(i);if(!a)throw new Error("Failed to create self-hosted relay");return a}async updateRelay(t){var s;if(!this.pb)throw new Error("Failed to update relay");let r=await this.pb.collection("relays").update(t.id,{name:t.name.trim()}),o=(s=this.store)==null?void 0:s.ingest(r);if(!o)throw new Error("Failed to update relay");return o}async deleteRemote(t){var r;return await((r=this.pb)==null?void 0:r.collection("shared_folders").delete(t.id)),!0}async createRemoteFolder(t,r,o=!1,s=void 0){var l,c;if(!this.pb)throw new Error("Failed to create folder");let i=await this.pb.collection("shared_folders").create({name:s||t.name,guid:t.guid,relay:r.id,creator:(l=this.user)==null?void 0:l.id,private:o},{expand:"relay"}),a=(c=this.store)==null?void 0:c.ingest(i);if(!a)throw new Error("Failed to create folder");return a}async destroyRelay(t){var r,o;return(r=this.store)==null||r.cascade("relays",t.id),await((o=this.pb)==null?void 0:o.collection("relays").delete(t.id)),!0}async leaveRelay(t){var o,s;let r=this.relayRoles.find(i=>{var a;return i.userId===((a=this.user)==null?void 0:a.id)&&i.relayId===t.id});r?await((o=this.pb)==null?void 0:o.collection("relay_roles").delete(r.id)):this.warn("No role found to leave relay"),(s=this.store)==null||s.cascade("relay",t.id)}async kick(t){var r;return(r=this.pb)==null?void 0:r.collection("relay_roles").delete(t.id)}async updateRelayRole(t,r){var a;if(!this.pb)throw new Error("Failed to update relay role");let o=this.roles.find(l=>l.name===r);if(!o)throw new Error("Failed to update relay role");let s=await this.pb.collection("relay_roles").update(t.id,{role:o.id}),i=(a=this.store)==null?void 0:a.ingest(s);if(!i)throw new Error("Failed to update relay role");return i}async addFolderRole(t,r,o){var l;if(!this.pb)throw new Error("Failed to add folder role");let s=this.roles.find(c=>c.name===o);if(!s)throw new Error("Failed to find role");let i=await this.pb.collection("shared_folder_roles").create({user:r,shared_folder:t.id,role:s.id}),a=(l=this.store)==null?void 0:l.ingest(i);if(!a)throw new Error("Failed to add folder role");return a}async removeFolderRole(t){if(!this.pb)throw new Error("Failed to remove folder role");await this.pb.collection("shared_folder_roles").delete(t.id)}async updateFolderRole(t,r){var a;if(!this.pb)throw new Error("Failed to update folder role");let o=this.roles.find(l=>l.name===r);if(!o)throw new Error("Failed to update folder role");let s=await this.pb.collection("shared_folder_roles").update(t.id,{role:o.id}),i=(a=this.store)==null?void 0:a.ingest(s);if(!i)throw new Error("Failed to update folder role");return i}async updateFolderPrivacy(t,r){var i;if(!this.pb)throw new Error("Failed to update folder privacy");let o=await this.pb.collection("shared_folders").update(t.id,{private:r}),s=(i=this.store)==null?void 0:i.ingest(o);if(!s)throw new Error("Failed to update folder privacy");return s}async updateRemoteFolder(t,r){var i;if(!this.pb)throw new Error("Failed to update folder");let o=await this.pb.collection("shared_folders").update(t.id,r),s=(i=this.store)==null?void 0:i.ingest(o);if(!s)throw new Error("Failed to update folder");return s}can(t,r,o,s){if(!this.policyManager)return new qs(()=>!1,[]);let[i]=r,a=[i,o.id];return this.policyManager.can(t,r,a,s)}userCan(t,r,o){return this.user?this.can(this.user.id,t,r,o):new qs(()=>!1,[])}destroy(){var t,r,o;this.destroyed=!0,(t=this._offLoginManager)==null||t.call(this),this._offLoginManager=null,(r=this.pb)==null||r.cancelAllRequests(),this.loginManager=null,(o=this.store)==null||o.destroy(),this.pb=null,this.authUser=null,this.store=null,this.policyManager=void 0}};var gb=require("obsidian");function vn(n,e){if(!n||!e)return!1;for(let t in n)if(typeof n[t]=="object"&&n[t]!==null){if(!vn(n[t],e[t]))return!1}else if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}function io(n){return n instanceof Vt}var Vt=class n extends Wo{constructor(t,r,o,s){let i=s.relayId?new ro(s.relayId,s.guid,r):new jn(s.guid,r);super(r,i,s.tokenStore,o);this.whenSyncedPromise=null;this.persistenceSynced=!1;this.userLock=!1;this.unsubscribes=[];this._parent=s,this.path=t,this.name="[CRDT] "+t.split("/").pop()||"",this.setLoggers(this.name),this.extension=this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),this.vault=this._parent.vault,this.stat={ctime:Date.now(),mtime:Date.now(),size:0},this.unsubscribes.push(this._parent.subscribe(this.path,a=>{a.intent==="disconnected"&&this.disconnect()})),this.setLoggers(`[Canvas](${this.path})`);try{let a=`${this.sharedFolder.appId}-relay-canvas-${this.guid}`;this._persistence=new pn(a,this.ydoc)}catch(a){throw this.warn("Unable to open persistence.",this.guid),console.error(a),a}this.whenSynced().then(()=>{this.updateStats();try{this._persistence.set("path",this.path),this._persistence.set("relay",this.sharedFolder.relayId||""),this._persistence.set("appId",this.sharedFolder.appId),this._persistence.set("s3rn",kt.encode(this.s3rn))}catch(a){}(async()=>await this.getServerSynced()||(await this.onceProviderSynced(),await this.markSynced()))()}),this._tfile=null}get yedges(){return this.ydoc.getMap("edges")}get ynodes(){return this.ydoc.getMap("nodes")}textNode(t){let r=this.ydoc.getText(t.id);return r.toString()===""&&r.insert(0,t.text),r}static exportCanvasData(t){let r=t.getMap("edges"),o=t.getMap("nodes"),s=[],i=[];for(let[,a]of r.entries())s.push({...a});for(let[,a]of o.entries()){let l=t.getText(a.id);i.push({...a,text:l.toString()||a.text})}return{edges:s,nodes:i}}async markSynced(){await this._persistence.markServerSynced()}async getServerSynced(){return this._persistence.getServerSynced()}async connect(){return this.sharedFolder.s3rn instanceof Vr?!1:(this.s3rn instanceof jn&&(this.sharedFolder.relayId?this.s3rn=new ro(this.sharedFolder.relayId,this.sharedFolder.guid,this.guid):this.s3rn=new jn(this.sharedFolder.guid,this.guid)),this.sharedFolder.shouldConnect&&this.sharedFolder.connect().then(t=>super.connect()))}get ready(){return this._persistence.isReady(this.synced)}hasLocalDB(){return this._persistence.hasServerSync||this._persistence.hasUserData()}async awaitingUpdates(){return await this.whenSynced(),await this.getServerSynced(),this._awaitingUpdates?(this._awaitingUpdates=!this.hasLocalDB(),this._awaitingUpdates):!1}async whenReady(){let t=async()=>await this.awaitingUpdates()?(this.log("awaiting updates"),this.connect(),await this.onceConnected(),this.log("connected"),await this.onceProviderSynced(),this.log("synced"),this):this;return this.readyPromise=this.readyPromise||new oo(t,()=>[this.ready,this]),this.readyPromise.getPromise()}whenSynced(){let t=async()=>(await this.sharedFolder.whenSynced(),this._persistence.synced&&!this.persistenceSynced?(this.persistenceSynced=!0,Promise.resolve()):new Promise(r=>{this.persistenceSynced&&r(),this._persistence.once("synced",()=>{this.persistenceSynced=!0,r()})}));return this.whenSyncedPromise=this.whenSyncedPromise||new oo(t,()=>[this.persistenceSynced,void 0]),this.whenSyncedPromise.getPromise()}get sharedFolder(){return this._parent}get tfile(){return this._tfile||(this._tfile=this._parent.getTFile(this)),this._tfile}static checkExtension(t){return t.endsWith(".canvas")}async markOrigin(t){await this._persistence.setOrigin(t)}async getOrigin(){return this._persistence.getOrigin()}async applyJSON(t){if(t==="")return;let r=JSON.parse(t);return await this.applyData(r)}async importFromView(t){if(t.file&&t.file===this.tfile)return await this.applyData(t.canvas.getData())}async applyData(t){let r=this.yedges,o=this.ynodes,s=new Set,i=new Map,a=new Set,l=new Map,c=new Set;t.nodes.forEach(u=>{s.add(u.id);let f=o.get(u.id);f?vn(f,u)||i.set(u.id,u):(i.set(u.id,u),u.type==="text"&&this.textNode(u))});for(let u of o.keys())s.has(u)||a.add(u);t.edges.forEach(u=>{s.add(u.id);let f=r.get(u.id);f&&vn(f,u)||l.set(u.id,u)});for(let u of r.keys())s.has(u)||c.add(u);(i.size>0||a.size>0||l.size>0||c.size>0)&&ot(this.ydoc,()=>{for(let u of i.values())this.ynodes.set(u.id,u);for(let u of a)this.ynodes.delete(u);for(let u of l.values())this.yedges.set(u.id,u);for(let u of c)this.yedges.delete(u)},this)}move(t,r){this.path=t,this._parent=r,this.name=t.split("/").pop()||"",this.extension=this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),this.updateStats()}get mimetype(){return yn(this.path)}get json(){let t=n.exportCanvasData(this.ydoc);return JSON.stringify(t)}async cleanup(){}updateStats(){this.stat.mtime=Date.now(),this.stat.size=this.json.length}destroy(){var t,r;this.unsubscribes.forEach(o=>{o()}),super.destroy(),this.ydoc.destroy(),(t=this.whenSyncedPromise)==null||t.destroy(),this.whenSyncedPromise=null,(r=this.readyPromise)==null||r.destroy(),this.readyPromise=null}};function Gi(n,e){let t=n.path.split("/"),r=e.path.split("/");if(t.length===2&&r.length>2)return 1;if(r.length===2&&t.length>2)return-1;let o=Math.min(t.length,r.length);for(let s=0;s<o;s++)if(t[s]!==r[s]){if(s===t.length-1){let i=t[s].match(/\d+/g),a=r[s].match(/\d+/g);if(i&&a){let l=parseInt(i[0]),c=parseInt(a[0]);if(l!==c)return l-c}}return t[s].localeCompare(r[s])}return t.length-r.length}var pr=class extends Error{constructor(t,r){super(t);this.path=r;this.name="SettingsError"}};var Bl=class extends it{constructor(t,r){super("Settings");this.storage=t;this.defaults=r;this._loaded=!1;this.data={...r}}async load(){let t=await this.storage.loadData();this.data={...this.defaults,...t||{}},this._loaded=!0,this.log("Loaded settings from disk:",this.data)}async save(){if(!this._loaded){this.warn("Attempted to save before loading settings from disk");return}this.log("Saving settings to disk:",this.data),await this.storage.saveData(this.data)}get(){return this.data}async update(t){if(!this._loaded){this.warn("Attempted to update before loading settings from disk");return}let r=t(this.data),o=await this.storage.loadData();if(JSON.stringify(r)===JSON.stringify(o)){this.debug("updated matches disk, no change");return}this.data=r,await this.save(),this.notifyListeners()}notifyListeners(){for(let t of this._listeners)t(this.data)}},Hr=class n extends it{constructor(t,r){super(`NamespacedSettings[${r}]`);this.settings=t;this.patterns=[];this.validatePath(r),[this.path,this.basePath,this.patterns]=this.processPath(r),this.lastKnown=this.getNestedValue(this.settings.get()),this.setupSubscription()}isWildcardPattern(t){return t.type==="wildcard"}validatePath(t){if(!t)throw new pr("Path cannot be empty");if(t.startsWith("/")||t.endsWith("/"))throw new pr(`Invalid path format: ${t}`)}createPatternRegex(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*",".*")}setupSubscription(){this.unsub=this.settings.subscribe(()=>{let t=this.getNestedValue(this.settings.get());this.lastKnown===void 0&&t===void 0||JSON.stringify(this.lastKnown)!==JSON.stringify(t)&&(this.lastKnown=t,this.notifyListeners())})}hasArrayPatterns(){return this.patterns.some(t=>t.type==="arrayMatch")}destroy(){this.destroyed||(this.unsub&&(this.unsub(),this.unsub=void 0),this._listeners.clear(),this.destroyed=!0)}get(){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());let t=this.settings.get();if(!t)return{};let r=this.patterns.find(this.isWildcardPattern);if(r&&this.path.length===1){let s=new RegExp(`^${r.wildcardPattern}$`);return Object.entries(t).filter(([a])=>s.test(a)).reduce((a,[l,c])=>(a[l]=c,a),{})}let o=this.getNestedValue(t);return o===void 0?{}:o}async set(t){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());if(t===void 0)throw new pr("Cannot set undefined value",this.getPath());try{await this.settings.update(r=>{let o=this.patterns.find(this.isWildcardPattern);if(o){if(this.path.length===1){let l=new RegExp(`^${o.wildcardPattern}$`),c={...r};return Object.entries(t).forEach(([u,f])=>{l.test(u)&&(c[u]=f)}),c}let s={...r},i=s;this.path.forEach(l=>{i[l]=i[l]||{},i=i[l]});let a=new RegExp(`^${o.wildcardPattern}$`);return Object.entries(t).forEach(([l,c])=>{a.test(l)&&(i[l]=c)}),s}return this.setNestedValue(r,t)})}catch(r){let o=r instanceof Error?r.message:"Unknown error";throw new pr(`Failed to set value at path ${this.getPath()}: ${o}`,this.getPath())}}async update(t,r=!1){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());let o=this.get(),s=t(o);!r&&JSON.stringify(o)===JSON.stringify(s)||await this.set(s)}async flush(){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());await this.update(t=>t,!0)}processPath(t){let r=t.split("/").filter(a=>a),o=[],s=[],i=[];return r.forEach((a,l)=>{let c=a.match(/^\[(\w+)=(.+)\]$/),u=a.match(/^\((.+?)\)$/);if(c){let[,f,d]=c,p=l>0?s[l-1]:a.split("[")[0];i.push({type:"arrayMatch",key:f,value:d,level:l}),o.push(a),s.push(p)}else if(u){let[,f]=u;i.push({type:"wildcard",wildcardPattern:this.createPatternRegex(f),level:l}),o.push(a),s.push(a)}else o.push(a),s.push(a)}),[o,s,i]}getNestedValue(t){let r=t,o=this.patterns.find(this.isWildcardPattern);if(o&&this.path.length===1){let i=new RegExp(`^${o.wildcardPattern}$`);return Object.entries(r).filter(([l])=>i.test(l)).reduce((l,[c,u])=>(l[c]=u,l),{})}let s=this.patterns[0];if((s==null?void 0:s.type)==="arrayMatch"){let i=this.basePath[0];if(!Array.isArray(r[i]))return;let a=r[i].find(c=>c[s.key]===s.value);if(!a)return;let l=this.basePath.slice(s.level+1);if(l.length>0){let c=a;for(let u of l){if(!c||typeof c!="object")return;c=c[u]}return c}return a}for(let i=0;i<this.basePath.length;i++){if(!r)return;r=r[this.basePath[i]]}return r}setNestedValue(t,r){let o={...t},s=this.patterns.find(l=>l.type==="arrayMatch");if(s){let l=this.basePath[0];o[l]||(o[l]=[]);let c=o[l].findIndex(f=>f[s.key]===s.value),u=this.basePath.slice(s.level+1);if(c>=0)if(u.length>0){let f=o[l][c];for(let p=0;p<u.length-1;p++){let m=u[p];f[m]=f[m]||{},f=f[m]}let d=u[u.length-1];f[d]=r}else o[l][c]={...o[l][c],...r,[s.key]:s.value};else if(u.length>0){let f={[s.key]:s.value},d=f;for(let m=0;m<u.length-1;m++){let y=u[m];d[y]={},d=d[y]}let p=u[u.length-1];d[p]=r,o[l].push(f)}else o[l].push({...r,[s.key]:s.value});return o}let i=o;for(let l=0;l<this.basePath.length-1;l++){let c=this.basePath[l];i[c]=i[c]||{},i=i[c]}let a=this.basePath[this.basePath.length-1];return i[a]=r,o}getParent(){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());let t=this.path.slice(0,-1).join("/");return new n(this.settings,t)}getChild(t,r){let o=[...this.path,t].join("/");return r?r(this.settings,o):(this.log("getChild",this.path,t,o,this.patterns),new n(this.settings,o))}getPath(){return this.path.join("/")}exists(){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());let t=this.settings.get();return this.getNestedValue(t)!==void 0}async delete(){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());await this.settings.update(t=>{let r={...t},o=this.patterns.find(l=>l.type==="arrayMatch");if(o){let l=this.basePath[0];return Array.isArray(r[l])&&(r[l]=r[l].filter(c=>c[o.key]!==o.value),r[l].length===0&&delete r[l]),r}let s=r,i=this.basePath.slice(0,-1);for(let l of i){if(!s[l])return r;s=s[l]}let a=this.basePath[this.basePath.length-1];return delete s[a],r})}subscribe(t){if(this.destroyed)throw new pr("Cannot use destroyed settings",this.getPath());return this._listeners.add(t),t(this.get()),()=>{this._listeners.delete(t)}}notifyListeners(){if(this.destroyed)return;let t=this.get();for(let r of this._listeners)r(t)}};var _o=class _o extends Hr{constructor(t,r,o=!0){super(t,r);this.enabled=o}isExtensionEnabled(t){var s,i;let o=(t.split(".").pop()||"").toLowerCase();if(o==="md"||He().enableCanvasSync&&o==="canvas")return!0;if(!this.enabled)return!1;for(let[a,l]of Object.entries(_o.schema)){let c=a;if(((s=this.get()[c])!=null?s:l.defaultEnabled)&&l.extensions.includes(o))return!0}return(i=this.get().otherTypes)!=null?i:_o.schema.otherTypes.defaultEnabled}getCategory(t){var s;let r=_o.schema[t];return{enabled:(s=this.get()[t])!=null?s:r.defaultEnabled,name:r.name,description:r.description,extensions:r.extensions}}getCategories(){return Object.keys(_o.schema).reduce((t,r)=>(t[r]=this.getCategory(r),t),{})}async toggleCategory(t,r){await this.update(o=>({...o,[t]:r})),this.log(`setting ${t} to ${r}`),this.notifyListeners()}async resetToDefault(){await this.update(()=>({..._o.defaultFlags}))}};_o.schema={images:{name:"Images",description:"Sync image files (.bmp, .png, .jpg, .jpeg, .gif, .svg, .webp, .avif)",extensions:["bmp","png","jpg","jpeg","gif","svg","webp","avif"],defaultEnabled:!0},audio:{name:"Audio",description:"Sync audio files (.mp3, .wav, .m4a, .3gp, .flac, .ogg, .oga, .opus)",extensions:["mp3","wav","m4a","3gp","flac","ogg","oga","opus"],defaultEnabled:!0},videos:{name:"Videos",description:"Sync video files (.mp4, .webm, .ogv, .mov, .mkv)",extensions:["mp4","webm","ogv","mov","mkv"],defaultEnabled:!0},pdfs:{name:"PDFs",description:"Sync PDF files (.pdf)",extensions:["pdf"],defaultEnabled:!0},otherTypes:{name:"Other files",description:"Sync unsupported file types",extensions:[],defaultEnabled:!1}},_o.defaultFlags=Object.fromEntries(Object.entries(_o.schema).map(([t,r])=>[t,r.defaultEnabled]));var js=_o;var EI={images:"image",audio:"audio",videos:"video",pdfs:"pdf",otherTypes:"file"};function ql(n){return(n==null?void 0:n.type)==="markdown"}function fb(n){return(n==null?void 0:n.type)==="canvas"}function db(n){return(n==null?void 0:n.type)==="folder"}function pb(n){return(n==null?void 0:n.type)==="file"}function Ji(n){return{version:0,id:n,type:"markdown"}}function mb(n){return{version:0,id:n,type:"canvas"}}function jl(n){return{version:0,id:n,type:"folder"}}function hb(n,e,t,r,o){return o||(o=Date.now()),{version:0,id:e,type:n,mimetype:t,synctime:o,hash:r}}var Hl=class Hl extends it{constructor(t,r){super();this.syncSettings=t;this.configs=r;this.protocols=new Map;r=r||Hl.defaults,r.forEach(([o,s])=>this.protocols.set(o,s)),this.unsubscribes.push(t.subscribe(o=>{this.updateFromSettings(o)}))}setEnabled(t,r){let o=this.protocols.get(t);o&&this.protocols.set(t,{...o,enabled:r})}canSync(t,r){var i,a;if(t.endsWith(".md")||He().enableCanvasSync&&t.endsWith(".canvas")||!((i=t.split("/").pop())==null?void 0:i.includes(".")))return!0;if(r){let l=this.protocols.get(r.type);return l?l.enabled&&r.version<=l.maxVersion:!1}let s=this.getTypeForPath(t);return!!((a=this.protocols.get(s))!=null&&a.enabled)}updateFromSettings(t){Object.entries(EI).forEach(([r,o])=>{this.setEnabled(o,t[r])})}getEnabledFileSyncTypes(){let t=[];return this.protocols.forEach((r,o)=>{r!=null&&r.enabled&&o!=="folder"&&t.push(o)}),t}getTypeForPath(t){let r=yn(t);for(let[o,s]of this.protocols)if(s.mimetypes.includes(r))return!He().enableCanvasSync&&o==="canvas"?"file":o;return"file"}};Hl.defaults=[["folder",{maxVersion:0,mimetypes:[],enabled:!0}],["markdown",{maxVersion:0,mimetypes:["text/markdown"],enabled:!0}],["image",{maxVersion:0,mimetypes:["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/avif","image/bmp"],enabled:!0}],["pdf",{maxVersion:0,mimetypes:["application/pdf"],enabled:!0}],["audio",{maxVersion:0,mimetypes:["audio/mpeg","audio/wav","audio/flac","audio/mp4","audio/x-m4a","audio/ogg","audio/opus"],enabled:!0}],["video",{maxVersion:0,mimetypes:["video/mp4","video/webm","video/ogg","video/quicktime","video/x-matroska"],enabled:!0}],["canvas",{maxVersion:0,mimetypes:["application/canvas+json"],enabled:!0}],["file",{maxVersion:0,mimetypes:["application/octet-stream"],enabled:!1}]];var Vl=Hl;var Yi=require("obsidian");async function kd(n){let e=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function mr(n){return!!n&&n instanceof xn}var zl=class extends Ze{constructor(t){super();this.db=null;this.setLoggers("[ContentAddressedFileStore]"),this.dbName=`${t}-relay-hashes`,this.ready=this.openDB()}async openDB(){return new Promise((t,r)=>{let o=indexedDB.open(this.dbName,1);o.onupgradeneeded=s=>{let i=o.result;i.objectStoreNames.contains("files")||i.createObjectStore("files",{keyPath:"path"})},o.onsuccess=s=>{this.db=o.result,t()},o.onerror=s=>{this.error("Error opening ContentAddressedFile database:",o.error),r(o.error)}})}async saveHash(t,r,o){if(await this.ready,!!this.db)return new Promise((s,i)=>{if(!this.db)return;let c=this.db.transaction(["files"],"readwrite").objectStore("files").put({path:t,hash:r,modifiedAt:o});c.onsuccess=()=>s(),c.onerror=()=>{this.error("Error saving hash:",c.error),i(c.error)}})}async getHash(t){return await this.ready,this.db?new Promise((r,o)=>{if(!this.db)return null;let a=this.db.transaction(["files"],"readonly").objectStore("files").get(t);a.onsuccess=()=>{r(a.result||null)},a.onerror=()=>{this.error("Error retrieving hash:",a.error),o(a.error)}}):null}async removeHash(t){if(await this.ready,!!this.db)return new Promise((r,o)=>{if(!this.db)return null;let a=this.db.transaction(["files"],"readwrite").objectStore("files").delete(t);a.onsuccess=()=>r(),a.onerror=()=>{this.error("Error removing hash:",a.error),o(a.error)}})}destroy(){this.db&&(this.db.close(),this.db=null)}},Id=class extends Ze{constructor(t,r,o){super();this.vault=t;this.path=r;this.store=o;this.content=null;this._tfile=null;let s=this.vault.getAbstractFileByPath(r);s&&s instanceof Yi.TFile&&(this._tfile=s)}get tfile(){if(!this._tfile){let t=this.vault.getAbstractFileByPath(this.path);if(t&&t instanceof Yi.TFile)this._tfile=t;else throw new Error(`missing tfile: ${this.path}`)}return this._tfile}async loadHashFromStore(){try{let t=await this.store.getHash(this.path);if(t&&t.modifiedAt===this.tfile.stat.mtime)return t.hash}catch(t){this.warn("Failed to load hash from store:",t)}}get modifiedAt(){if(!this.tfile)throw new Error("missing tfile");return this.tfile.stat.mtime}async read(){this.log("reading content from disk");let t=this.tfile.stat.mtime,r=await this.vault.readBinary(this.tfile),o=await kd(r);try{await this.store.saveHash(this.path,o,t)}catch(s){this.warn("Failed to save hash to store:",s)}return r}async _hash(){let t=this.tfile.stat.mtime,r=await this.vault.readBinary(this.tfile),o=await kd(r);try{await this.store.saveHash(this.path,o,t)}catch(s){this.warn("Failed to save hash to store:",s)}return o}exists(){if(this._tfile)return!0;let t=this.vault.getAbstractFileByPath(this.path);return t&&t instanceof Yi.TFile?(this._tfile=t,!0):!1}async clear(){this._tfile=null,this.store.removeHash(this.path).catch(t=>{this.warn("Failed to remove hash from store:",t)})}async hash(){let t=await this.loadHashFromStore();return t||(t=await this._hash(),t)}destroy(){this.vault=null,this._tfile=null}},xn=class extends it{constructor(t,r,o,s){super();this.path=t;this._guid=r;this.hashStore=o;this.ready=!1;this.connected=!0;this.offFileInfo=()=>{};this.uploadError=void 0;this.s3rn=s.relayId?new wo(s.relayId,s.guid,r):new Bs(s.guid,r),this._parent=s,this.setLoggers(`[SharedFile](${this.path})`),this.name=this.path.split("/").pop()||"",this.extension=this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),this.vault=this._parent.vault;let i=this.sharedFolder.syncStore.typeRegistry.getTypeForPath(t);if(!i)throw new Error("unexpected synctype");this.type=i,this.caf=new Id(this.vault,this.sharedFolder.getPath(t),this.hashStore),this.log("created")}get guid(){return this._guid}set guid(t){this._guid=t,this.s3rn=this._parent.relayId?new wo(this._parent.relayId,this._parent.guid,t):new Bs(this._parent.guid,t)}get mimetype(){return yn(this.path)}disconnect(){}get inMeta(){return!!this.sharedFolder.syncStore.getMeta(this.path)}get pending(){return!!this.sharedFolder.syncStore.pendingUpload.has(this.path)}get tag(){return this.inMeta?"":this.uploadError?this.uploadError:this.pending?"pending":"unknown"}move(t,r){t!==this.path&&(this._parent=r,this.debug("setting new path",t),this.path=t,this.name=t.split("/").pop()||"",this.extension=this.name.split(".").pop()||"",this.basename=this.name.replace(`.${this.extension}`,""),this.setLoggers(`[SharedFile](${this.path})`))}get lastModified(){return this.stat.mtime}_refreshMeta(){let t=this.sharedFolder.syncStore.getMeta(this.path);return this.meta=t,t}async push(t=!1){if(this.log("push"),!this.sharedFolder.connected){this.log("skipping push -- folder is disconnected");return}if(!this.sharedFolder.syncStore.canSync(this.path)){this.log("skipping push -- filetype is disabled");return}let r=await this.caf.hash();if(this._refreshMeta(),!this.meta||r&&this.meta.hash!==r||t)try{await this.sharedFolder.cas.writeFile(this),await this.sharedFolder.markUploaded(this),this.uploadError=void 0,this.notifyListeners()}catch(o){let s="Failed to push file";try{s=o.toString()}catch(i){}this.uploadError=s.replace(/^Error:/,"").trim(),this.notifyListeners()}}async sync(){var t;if(this.log("sync"),this._refreshMeta(),this.caf.exists()){if(!this.meta){await this.push();return}}else{if(!this.meta)throw new Error("unexpected case");await this.pull();return}try{let r=await this.caf.hash();if(He().enableVerifyUploads)try{this.verifyUpload()||(this.warn("file in metadata, but not on the server!"),await this.push())}catch(o){}if(r!==this.meta.hash){if(this.stat.mtime>this.meta.synctime){await this.push();return}this.warn("synctime",this.meta.synctime,(t=this.meta)==null?void 0:t.synctime,this.stat.mtime),await this.pull();return}}catch(r){this.warn("unable to compute hash",r)}}shouldPull(t){return!this.tfile||t.synctime>this.stat.mtime}async verifyUpload(){if(this.log("verify upload"),this._refreshMeta(),!this.meta)throw new Error("cannot verify upload without meta");return this.sharedFolder.cas.verify(this)}async pull(){if(this.log("pull"),this._refreshMeta(),!this.meta)throw new Error("cannot pull without meta");if(!(this.caf.exists()&&await this.caf.hash()===this.meta.hash))try{let t=await this.sharedFolder.cas.readFile(this);await this.vault.adapter.writeBinary(this.sharedFolder.getPath(this.path),t),await this.caf.hash()}catch(t){this.log(t);return}}get tfile(){let t=this.vault.getAbstractFileByPath(this.sharedFolder.getPath(this.path));if(t instanceof Yi.TFile)return t;throw new Error("TFile API used before file existed")}get stat(){return this.tfile.stat}get parent(){var t;return((t=this.tfile)==null?void 0:t.parent)||null}get sharedFolder(){return this._parent}async connect(){return this.sharedFolder.s3rn instanceof Vr?!1:(this.s3rn instanceof zo&&(this.sharedFolder.relayId?this.s3rn=new wo(this.sharedFolder.relayId,this.sharedFolder.guid,this.guid):this.s3rn=new Bs(this.sharedFolder.guid,this.guid)),this.sharedFolder.shouldConnect&&this.sharedFolder.connect().then(t=>(this.connected=!0,this.connected)))}async read(){return this.vault.read(this.tfile)}async delete(){return await this.caf.clear(),this.vault.delete(this.tfile)}async write(t){this.vault.adapter.write(this.tfile.path,t),await this.caf.hash()}async append(t){this.vault.append(this.tfile,t),await this.caf.hash()}cleanup(){}destroy(){var t;(t=this.offFileInfo)==null||t.call(this),this.offFileInfo=null,this._parent=null,this.caf.destroy()}};var Wl=class extends Ze{constructor(t,r,o,s=3){super();this.loginManager=t;this.timeProvider=r;this.sharedFolders=o;this.concurrency=s;this.activeSync=new bn;this.activeDownloads=new bn;this.syncGroups=new er;this.syncQueue=[];this.downloadQueue=[];this.isProcessingSync=!1;this.isProcessingDownloads=!1;this.isPaused=!0;this.inProgressSyncs=new Set;this.inProgressDownloads=new Set;this.syncCompletionCallbacks=new Map;this.downloadCompletionCallbacks=new Map;this.loggedItems=new Map;this.subscriptions=[];this.start=this.resume;Bt.set(this,"BackgroundSync"),this.timeProvider.setInterval(()=>{this.processSyncQueue(),this.processDownloadQueue()},1e3)}get pendingSyncs(){return this.syncQueue}get pendingDownloads(){return this.downloadQueue}getOverallProgress(){let t=0,r=0,o=0,s=0,i=0,a=0;this.syncGroups.forEach(f=>{t+=f.total,r+=f.completed,o+=f.syncs,s+=f.completedSyncs,i+=f.downloads,a+=f.completedDownloads});let l=t>0?r/t*100:0,c=o>0?s/o*100:0,u=i>0?a/i*100:0;return{totalPercent:Math.round(l),syncPercent:Math.round(c),downloadPercent:Math.round(u),totalItems:t,completedItems:r,syncItems:o,completedSyncs:s,downloadItems:i,completedDownloads:a}}getGroupProgress(t){let r=this.syncGroups.get(t);if(!r)return null;let o=r.total>0?r.completed/r.total*100:0,s=r.syncs>0?r.completedSyncs/r.syncs*100:0,i=r.downloads>0?r.completedDownloads/r.downloads*100:0;return{percent:Math.round(o),syncPercent:Math.round(s),downloadPercent:Math.round(i),sharedFolder:t,status:r.status}}getAllGroupsProgress(){let t=[];return this.syncGroups.forEach((r,o)=>{let s=this.getGroupProgress(o);s&&t.push(s)}),t}async processSyncQueue(){if(this.isPaused||this.isProcessingSync)return;this.isProcessingSync=!0;let t=this.syncQueue.filter(r=>r.sharedFolder.connected);for(;t.length>0&&this.activeSync.size<this.concurrency;){let r=t.shift();if(!r)break;this.syncQueue=this.syncQueue.filter(o=>o.guid!==r.guid),r.status="running",this.activeSync.add(r);try{let o=r.doc,s;o instanceof xn?s=this.syncFile(o):s=this.syncDocument(o),s.then(()=>{r.status="completed";let i=this.syncCompletionCallbacks.get(r.guid);i&&(i.resolve(),this.syncCompletionCallbacks.delete(r.guid));let a=this.syncGroups.get(r.sharedFolder);a&&(this.debug(`[Sync Progress] Before: completed=${a.completed}, total=${a.total}, syncs=${a.syncs}, completedSyncs=${a.completedSyncs}`),a.completedSyncs++,a.completed++,this.debug(`[Sync Progress] After: completed=${a.completed}, total=${a.total}, syncs=${a.syncs}, completedSyncs=${a.completedSyncs}`),a.completed===a.total&&(a.status="completed",this.debug("[Sync Progress] Group completed!")),this.syncGroups.set(r.sharedFolder,a))}).catch(i=>{r.status="failed";let a=this.syncCompletionCallbacks.get(r.guid);a&&(a.reject(i instanceof Error?i:new Error(String(i))),this.syncCompletionCallbacks.delete(r.guid));let l=this.syncGroups.get(r.sharedFolder);l&&(this.error("[Sync Failed]",i),l.status="failed",this.syncGroups.set(r.sharedFolder,l))}).finally(()=>{this.activeSync.delete(r),this.inProgressSyncs.delete(r.guid),this.timeProvider.setTimeout(()=>{this.processSyncQueue()},0)})}catch(o){r.status="failed";let s=this.syncCompletionCallbacks.get(r.guid);s&&(s.reject(o instanceof Error?o:new Error(String(o))),this.syncCompletionCallbacks.delete(r.guid));let i=this.syncGroups.get(r.sharedFolder);i&&(this.error("[Sync Startup Failed]",o),i.status="failed",this.syncGroups.set(r.sharedFolder,i)),this.activeSync.delete(r),this.inProgressSyncs.delete(r.guid)}}this.isProcessingSync=!1}async processDownloadQueue(){if(this.isPaused||this.isProcessingDownloads)return;this.isProcessingDownloads=!0;let t=this.downloadQueue.filter(r=>r.sharedFolder.connected);for(;t.length>0&&this.activeDownloads.size<this.concurrency;){let r=t.shift();if(!r)break;this.downloadQueue=this.downloadQueue.filter(o=>o.guid!==r.guid),r.status="running",this.activeDownloads.add(r);try{let o;r.doc instanceof Vt?o=this.getCanvas(r.doc):r.doc instanceof xn?o=this.getSyncFile(r.doc):o=this.getDocument(r.doc),o.then(()=>{r.status="completed";let s=this.downloadCompletionCallbacks.get(r.guid);s&&(s.resolve(),this.downloadCompletionCallbacks.delete(r.guid));let i=this.syncGroups.get(r.sharedFolder);i&&(i.completedDownloads++,i.completed++,i.completed===i.total&&(i.status="completed"),this.syncGroups.set(r.sharedFolder,i))}).catch(s=>{r.status="failed";let i=this.downloadCompletionCallbacks.get(r.guid);i&&(i.reject(s instanceof Error?s:new Error(String(s))),this.downloadCompletionCallbacks.delete(r.guid));let a=this.syncGroups.get(r.sharedFolder);a&&(a.status="failed",this.syncGroups.set(r.sharedFolder,a)),this.error("[processDownloadQueue]",s)}).finally(()=>{this.activeDownloads.delete(r),this.inProgressDownloads.delete(r.guid),this.timeProvider.setTimeout(()=>{this.processDownloadQueue()},0)})}catch(o){r.status="failed";let s=this.downloadCompletionCallbacks.get(r.guid);s&&(s.reject(o instanceof Error?o:new Error(String(o))),this.downloadCompletionCallbacks.delete(r.guid));let i=this.syncGroups.get(r.sharedFolder);i&&(this.error("[Download Startup Failed]",o),i.status="failed",this.syncGroups.set(r.sharedFolder,i)),this.activeDownloads.delete(r),this.inProgressDownloads.delete(r.guid)}}this.isProcessingDownloads=!1}async enqueueSync(t){if(this.inProgressSyncs.has(t.guid)){this.debug(`[enqueueSync] Item ${t.guid} already in progress, skipping`);let a=this.syncCompletionCallbacks.get(t.guid);return a?new Promise((l,c)=>{a.resolve=l,a.reject=c}):(this.processSyncQueue(),Promise.resolve())}let r=t.sharedFolder,o={guid:t.guid,path:r.getPath(t.path),doc:t,status:"pending",sharedFolder:r},s=this.syncGroups.get(r);s||(s={sharedFolder:r,total:0,completed:0,status:"pending",downloads:0,syncs:0,completedDownloads:0,completedSyncs:0}),s.total++,s.syncs++,this.syncGroups.set(r,s),this.inProgressSyncs.add(t.guid);let i=new Promise((a,l)=>{this.syncCompletionCallbacks.set(t.guid,{resolve:a,reject:l})});return this.syncQueue.push(o),this.syncQueue.sort(Gi),this.processSyncQueue(),i}enqueueDownload(t){if(this.inProgressDownloads.has(t.guid)){this.debug(`[enqueueDownload] Item ${t.guid} already in progress, skipping`);let a=this.downloadCompletionCallbacks.get(t.guid);return a?(this.processDownloadQueue(),new Promise((l,c)=>{a.resolve=l,a.reject=c})):(this.processDownloadQueue(),Promise.resolve())}let r=t.sharedFolder,o=this.syncGroups.get(r);o||(o={sharedFolder:r,total:0,completed:0,status:"pending",downloads:0,syncs:0,completedDownloads:0,completedSyncs:0}),o.downloads++,o.total++,this.syncGroups.set(r,o);let s={guid:t.guid,path:r.getPath(t.path),doc:t,status:"pending",sharedFolder:r};this.inProgressDownloads.add(t.guid);let i=new Promise((a,l)=>{this.downloadCompletionCallbacks.set(t.guid,{resolve:a,reject:l})});return this.downloadQueue.push(s),this.downloadQueue.sort(Gi),this.processDownloadQueue(),i}enqueueSharedFolderSync(t){let r=[...t.files.values()].filter(so),o=[...t.files.values()].filter(io),s=[...t.files.values()].filter(mr),i=[...r,...o,...s],a={sharedFolder:t,total:i.length,completed:0,status:"pending",downloads:0,syncs:i.length,completedDownloads:0,completedSyncs:0};this.syncGroups.set(t,a);let l=[...r,...o,...s].sort(Gi);for(let c of l)this.enqueueForGroupSync(c);a.status="running",this.syncGroups.set(t,a)}async enqueueForGroupSync(t){if(this.inProgressSyncs.has(t.guid)){this.debug(`[enqueueForGroupSync] Item ${t.guid} already in progress, skipping`);let i=this.syncCompletionCallbacks.get(t.guid);return i?(this.processSyncQueue(),new Promise((a,l)=>{i.resolve=a,i.reject=l})):Promise.resolve()}let r=t.sharedFolder,o={guid:t.guid,path:r.getPath(t.path),doc:t,status:"pending",sharedFolder:r};this.inProgressSyncs.add(t.guid);let s=new Promise((i,a)=>{this.syncCompletionCallbacks.set(t.guid,{resolve:i,reject:a})});return this.syncQueue.push(o),this.syncQueue.sort(Gi),this.processSyncQueue(),s}getAuthHeader(t){return{Authorization:`Bearer ${t.token}`}}getBaseUrl(t,r){var a;let o=new URL(t.url);o.protocol="https:";let s=o.pathname.split("/");return s.pop(),s.push(t.docId),o.pathname=s.join("/"),((a=t.baseUrl)==null?void 0:a.replace(/\/$/,""))||o.toString()}async downloadItem(t){let r=u=>u instanceof ro?u.canvasId:u.documentId,o=t.s3rn;if(this.log("[downloadItem]",t.path,`${kt.encode(o)}`),!(o instanceof xo||o instanceof ro))throw new Error(`Unable to decode S3RN: ${kt.encode(o)}`);let s=await t.getProviderToken(),i=this.getAuthHeader(s),l=`${this.getBaseUrl(s,o)}/as-update`,c=await(0,gb.requestUrl)({url:l,method:"GET",headers:i,throw:!1});if(c.status===200)this.debug("[downloadItem]",r(o),c.status);else throw this.error("[downloadItem]",r(o),l,c.status,c.text),new Error(`Unable to download item: ${kt.encode(o)}`);return c}async syncDocumentWebsocket(t){let r="",o="",s=null;io(t)?(s=Vt.exportCanvasData(t.ydoc),o=JSON.stringify(s)):so(t)&&(o=t.text);try{r=await t.sharedFolder.read(t)}catch(c){}let i=!1;if(io(t)&&s){let c=r?JSON.parse(r):{nodes:[],edges:[]};i=vn(s,c)}else i=o===r;if(!i&&r)return this.log("file is not tracking local disk. resolve merge conflicts before syncing."),!1;let a=t.onceProviderSynced(),l=t.intent;return t.connect(),l==="disconnected"&&await a,l==="disconnected"&&!t.userLock&&(t.disconnect(),t.sharedFolder.tokenStore.removeFromRefreshQueue(kt.encode(t.s3rn))),!0}enqueueCanvasDownload(t){return this.enqueueDownload(t)}async getCanvas(t,r=3,o=3e3){try{let s=Vt.exportCanvasData(t.ydoc),i={edges:[],nodes:[]};try{let d=await t.sharedFolder.read(t);i=JSON.parse(d)}catch(d){}let a=vn(s.edges,i.edges)&&vn(s.nodes,i.nodes),l=i.nodes.length>0,u=(await this.downloadItem(t)).arrayBuffer,f=new Uint8Array(u);if(this.log("[getCanvas] applying content from server"),bo(t.ydoc,f),l&&!a){this.log("Skipping flush - file requires merge conflict resolution.");return}t.sharedFolder.syncStore.has(t.path)&&(t.sharedFolder.flush(t,t.json),this.log("[getCanvas] flushed"))}catch(s){throw this.error(s),s}}async getDocument(t,r=3,o=3e3){try{let s=t.text,i="";try{i=await t.sharedFolder.read(t)}catch(y){}let a=s===i,l=i!=="",u=(await this.downloadItem(t)).arrayBuffer,f=new Uint8Array(u),d=new Oo;bo(d,f);let p=d.getMap("users");if(d.getText("contents").toString()===""){if(p.size===0){this.log("[getDocument] Server contains uninitialized document. Waiting for peer to upload.",p.size,r,o),r>0&&this.timeProvider.setTimeout(()=>{this.getDocument(t,r-1,o*2)},o);return}if(t.text){this.log("[getDocument] local crdt has contents, but remote is empty"),this.enqueueSync(t);return}}if(this.log("[getDocument] applying content from server"),bo(t.ydoc,f),l&&!a){this.log("Skipping flush - file requires merge conflict resolution.");return}t.sharedFolder.syncStore.has(t.path)&&(t.sharedFolder.flush(t,t.text),this.log("[getDocument] flushed"))}catch(s){throw this.error(s),s}}async syncFile(t){await t.sync()}async getSyncFile(t){await t.pull()}async syncDocument(t){try{so(t)?await this.syncDocumentWebsocket(t):io(t)&&await this.syncDocumentWebsocket(t)}catch(r){console.error(r);return}}subscribeToSync(t){return this.activeSync.subscribe(t)}subscribeToDownloads(t){return this.activeDownloads.subscribe(t)}subscribeToSyncGroups(t){return this.syncGroups.subscribe(t)}subscribeToProgress(t){let r=()=>{t(this.getOverallProgress())},o=this.activeSync.subscribe(()=>r()),s=this.activeDownloads.subscribe(()=>r()),i=this.syncGroups.subscribe(()=>r());return()=>{o(),s(),i()}}subscribeToGroupProgress(t,r){return this.syncGroups.subscribe(()=>{r(this.getGroupProgress(t))})}pause(){this.isPaused=!0}resume(){this.debug("starting"),this.isPaused=!1,this.processSyncQueue(),this.processDownloadQueue()}getQueueStatus(){return{syncsQueued:this.syncQueue.length,syncsActive:this.activeSync.size,downloadsQueued:this.downloadQueue.length,downloadsActive:this.activeDownloads.size,isPaused:this.isPaused}}destroy(){for(let[t,r]of this.syncCompletionCallbacks)r.reject(new Error("BackgroundSync destroyed")),this.syncCompletionCallbacks.delete(t);for(let[t,r]of this.downloadCompletionCallbacks)r.reject(new Error("BackgroundSync destroyed")),this.downloadCompletionCallbacks.delete(t);this.activeSync.destroy(),this.activeDownloads.destroy(),this.syncGroups.destroy(),this.syncQueue=[],this.downloadQueue=[],this.inProgressSyncs.clear(),this.inProgressDownloads.clear(),this.loggedItems.clear(),this.loginManager=null,this.timeProvider=null,this.subscriptions.forEach(t=>t())}};var Cd=require("obsidian");function Ld(n){return n instanceof zs}var zs=class n extends Ze{constructor(t,r,o){super();this.path=t;this.guid=r;this._tfolder=null;this.ready=!1;this.createPromise=null;this.connected=!0;this._parent=o,this.name=this.path.split("/").pop()||"",this.vault=this._parent.vault;let s=()=>{let i=this.vault.getAbstractFileByPath(this.sharedFolder.getPath(t));return i instanceof Cd.TFolder?(this._tfolder=i,this.ready=!0,!0):!1};this.synctime=0,this.setLoggers(`[SyncFolder](${this.path})`),s()||(this._parent.isPendingDelete(t)?this.warn("skipping folder creation for pending delete",t):(this.createPromise=this.vault.createFolder(this.sharedFolder.getPath(t)),this.createPromise.then(i=>{this._tfolder=i,this.ready=!0}).catch(()=>{s()}))),this.offFolderStatusListener=this._parent.subscribe(this.path,i=>{i.intent==="disconnected"&&this.disconnect()}),(async()=>(this.createPromise&&await this.createPromise,o.markUploaded(this)))(),this.log("created")}static fromTFolder(t,r){return console.log("virtualpath for new syncfolder",t.getVirtualPath(r.path)),new n(t.getVirtualPath(r.path),ys(),t)}disconnect(){this.connected=!1}move(t,r){t!==this.path&&(this._parent=r,this.log("setting new path",t),this.path=t,this.name=t.split("/").pop()||"",this.setLoggers(`[SharedFolder](${this.path})`))}get tfolder(){let t=this.vault.getAbstractFileByPath(this.sharedFolder.getPath(this.path));if(t instanceof Cd.TFolder)return t;throw new Error("TFolder API used before file existed")}get parent(){var t;return((t=this.tfolder)==null?void 0:t.parent)||null}get sharedFolder(){return this._parent}async connect(){return this.sharedFolder.shouldConnect&&this.sharedFolder.connect().then(t=>(this.connected=!0,this.connected))}async delete(){return this.vault.delete(this.tfolder)}cleanup(){}destroy(){var t;(t=this.offFolderStatusListener)==null||t.call(this),this.offFolderStatusListener=null,this._parent=null,this._tfolder=null}};var So=Do(An());var Kl=class extends it{constructor(t,r,o,s){super();this.ydoc=t;this.namespace=r;this.pendingUpload=o;this.syncSettingsManager=s;this.legacyIds=this.ydoc.getMap("docs"),this.meta=this.ydoc.getMap("filemeta_v0"),this.overlay=new Map,this.renames=new Map,this.deleteSet=new Set,this.typeRegistry=new Vl(this.syncSettingsManager)}assertVPath(t){if(t.startsWith(this.namespace+So.sep))throw new Error("Expected virtual path"+t)}print(){this.log("files",Array.from(this.meta.entries()).map(([t,r])=>({path:t,...r}))),this.log("pending...",Array.from(this.pendingUpload.entries()).map(([t,r])=>({path:t,guid:r})))}canSync(t){let r=this.getMeta(t);return this.typeRegistry.canSync(t,r)}resolveMove(t){this.log("resolving alias",t),this.renames.delete(t)}resolveAll(){this.renames.clear()}move(t,r){this.log("moving file",t,"to",r),this.assertVPath(t),this.assertVPath(r),this.renames.set(t,r);let o=this.pendingUpload.get(t);o&&(this.pendingUpload.set(r,o),this.pendingUpload.delete(t)),this.deleteSet.has(t)&&(this.deleteSet.add(r),this.deleteSet.delete(t));let s=this.overlay.get(t);s&&(this.overlay.set(r,s),this.overlay.delete(t));let i=this.meta.get(t);db(i)?this.moveFolder(t,r):i&&(this.set(r,i),this.delete(t))}new(t){this.assertVPath(t);let r=Hs();return this.pendingUpload.set(t,r),r}forEach(t){this.meta.forEach((r,o)=>{this.deleteSet.has(o)||t(r,o)}),this.overlay.forEach((r,o)=>{this.deleteSet.has(o)||t(r,o)})}has(t){return this.renames.has(t)&&(t=this.renames.get(t)),this.deleteSet.has(t)?!1:this.meta.has(t)||this.legacyIds.has(t)||this.overlay.has(t)||this.pendingUpload.has(t)}willSet(t,r){if(this.assertVPath(t),ql(r)&&this.legacyIds.get(t)!==r.id)return this.log("legacy vpath set to a different ID",this.legacyIds.get(t),r.id),!0;let o=this.meta.get(t);return o&&o.id===r.id&&o.mimetype==r.mimetype&&o.type===r.type&&o.hash===r.hash?!1:(this.log("new meta diff",o,r),!0)}set(t,r){this.assertVPath(t),ql(r)&&this.legacyIds.get(t)!==r.id&&this.legacyIds.set(t,r.id);let o=this.meta.get(t);o&&o.id===r.id&&o.mimetype==r.mimetype&&o.type===r.type&&o.hash===r.hash||(this.log("metadata write (path, existing, meta)",t,o,r),this.meta.set(t,r),this.pendingUpload.has(t)&&this.pendingUpload.delete(t))}processFolderOperation(t){let r=new Map,o=new Map;t.changes.keys.forEach((s,i)=>{if(s.action==="delete"){let a=s.oldValue;(a==null?void 0:a.type)==="folder"&&r.set(a.id,i)}else if(s.action==="add"||s.action==="update"){let a=this.meta.get(i);(a==null?void 0:a.type)==="folder"&&o.set(a.id,i)}}),r.forEach((s,i)=>{let a=o.get(i);if(a&&s!==a){this.log(`Detected folder move from ${s} to ${a}`);let l=new Map;this.meta.forEach((c,u)=>{u.startsWith(a+So.sep)&&l.set(u,c)}),this.renames.set(s,a),this.log("setting alias",s,a),this.log("paths to move",l),l.forEach((c,u)=>{let f=u.slice(a.length),d=s+f;this.renames.set(d,u),this.log("setting alias",d,u)})}})}start(){mn(Vo.enableDeltaLogging,()=>{let o=s=>{var a,l;let i="";i+=`Transaction origin: ${s.transaction.origin}${(l=(a=s.transaction.origin)==null?void 0:a.constructor)==null?void 0:l.name}
|
|
`,s.changes.keys.forEach((c,u)=>{c.action==="add"&&(i+=`Added ${u}: ${this.get(u)}
|
|
`),c.action==="update"&&(i+=`Updated ${u}: ${this.get(u)}
|
|
`),c.action==="delete"&&(i+=`Deleted ${u}
|
|
`)}),this.debug(i)};this.legacyIds.observe(o),this.meta.observe(o),this.unsubscribes.push(()=>{this.legacyIds.unobserve(o)}),this.unsubscribes.push(()=>{this.meta.unobserve(o)})});let t=async o=>{if(o.changes.keys.size===0){this.log("no changes detected");return}o.transaction.origin!=this&&(this.processFolderOperation(o),this.notifyListeners())},r=async o=>{this.migrateUp(),this.notifyListeners()};this.legacyIds.observe(r),this.meta.observe(t),this.unsubscribes.push(()=>{this.legacyIds.unobserve(r)}),this.unsubscribes.push(()=>{this.meta.unobserve(t)}),this.unsubscribes.push(this.typeRegistry.subscribe(()=>{this.log("type registry change"),this.notifyListeners()}))}get(t){if(this.assertVPath(t),this.renames.has(t)&&(t=this.renames.get(t)),this.deleteSet.has(t))return;let r=this.pendingUpload.get(t);if(r)return r;let o=this.getMeta(t);if(o)return o.id}getMeta(t){if(this.assertVPath(t),this.renames.has(t)&&(t=this.renames.get(t)),this.deleteSet.has(t))return;let r=this.meta.get(t)||this.overlay.get(t),o=this.legacyIds.has(t);if(!r&&this.legacyIds.has(t)){let s=this.legacyIds.get(t),i=Ji(s);return this.overlay.set(t,i),i}if(r){if(ql(r)&&!o){this.deleteSet.add(t);return}return r}}delete(t){return this.assertVPath(t),this.legacyIds.delete(t),this.pendingUpload.delete(t),this.meta.delete(t)}get remoteIds(){let t=new Set;return this.forEach(r=>{t.add(r.id)}),t}commit(){this.overlay.size>0&&this.log("committing overlay",[...this.overlay.keys()]),this.overlay.forEach((t,r)=>{this.set(r,t),t.type==="markdown"&&this.legacyIds.get(r)!==t.id&&this.legacyIds.set(r,t.id)}),this.overlay=new Map,this.deleteSet.size>0&&this.log("committing deleteSet",[...this.deleteSet]),this.deleteSet.forEach(t=>this.delete(t)),this.deleteSet=new Set}detectFolderMoves(){let t=new Map,r=new Set;this.legacyIds.forEach((s,i)=>{let a;if(this.meta.forEach((l,c)=>{l.type==="markdown"&&l.id===s&&c!==i&&(a=c)}),a){let l=(0,So.dirname)(a),c=(0,So.dirname)(i);l!==c&&t.set(l,c)}}),Array.from(t.entries()).sort(([s],[i])=>i.length-s.length).forEach(([s,i])=>{r.has(s)||(this.moveFolder(s,i),r.add(s))})}moveFolder(t,r){this.log("moving folder",t,"to",r);let o=new Map;this.meta.forEach((i,a)=>{(a===t||a.startsWith(t+So.sep))&&o.set(a,i)}),this.overlay.forEach((i,a)=>{(a===t||a.startsWith(t+So.sep))&&o.set(a,i)});let s=this.meta.get(t);s&&(this.meta.set(r,s),this.meta.delete(t)),o.forEach((i,a)=>{if(a===t)return;let l=a.slice(t.length),c=r+l;this.move(a,c)})}markUploaded(t,r){if(!this.has(t))throw new Error(`unexpected vpath ${t} marked uploaded`);this.set(t,r)}migrateFile(t,r){var a;if(this.assertVPath(r),((a=this.meta.get(r))==null?void 0:a.id)===t)return;let o=new Set,s=r.split(So.sep),i="";for(let l=0;l<s.length-1;l++)i=s.slice(0,l+1).join(So.sep),o.add(i);this.meta.has(r)||this.overlay.has(r)||r.endsWith(".md")&&(this.warn(`migrated legacy key on ${r}`),this.overlay.set(r,Ji(t))),o.forEach(l=>{if(l&&!(this.meta.has(l)||this.overlay.has(l))){let c=Hs();console.log("creating folder path",l,c),this.overlay.set(l,jl(c))}})}migrateUp(){this.detectFolderMoves(),this.legacyIds.forEach((t,r)=>{this.migrateFile(t,r)})}destroy(){super.destroy(),this.overlay.clear(),this.deleteSet.clear(),this.renames.clear(),this.legacyIds=null,this.meta=null}};function yb(n,e,t=(r,o)=>r.substring(o.length).replace(/^\/+/,"")){return new Proxy(n,{get(r,o){let s=r[o];return typeof s=="function"?function(...i){return i.length>0&&typeof i[0]=="string"&&(i[0]=t(i[0],e)),s.apply(r,i)}:s}})}var Gl=class extends Ze{constructor(t){super();this.sharedFolder=t;let r=t.loginManager.getEndpointManager().getAuthUrl();this.pb=new qn(r,t.loginManager.authStore),this.tokenStore=t.tokenStore}async verify(t){if(!t.meta)throw new Error("cannot head file with missing hash");let r=t.meta.hash,o=await this.tokenStore.getFileToken(kt.encode(t.s3rn),r,t.mimetype,0);return(await at(o.baseUrl,{method:"HEAD",headers:{Authorization:`Bearer ${o.token}`}})).status===200}async readFile(t){if(!t.meta)throw new Error("cannot pull file with missing hash");let r=t.meta.hash,o=await this.tokenStore.getFileToken(kt.encode(t.s3rn),r,t.mimetype,0),s=await at(o.baseUrl+"/download-url",{method:"GET",headers:{Authorization:`Bearer ${o.token}`}});if(s.status===404)throw new Error(`[${this.sharedFolder.path}] File is missing: ${t.guid} ${t.meta.hash} ${t.meta.type}`);let a=(await s.json()).downloadUrl;return(await at(a)).arrayBuffer()}async writeFile(t){let r=await t.caf.read(),o=await t.caf.hash();if(this.log("writeFile",o),!(r&&o))throw new Error("invalid caf");let s=await this.tokenStore.getFileToken(kt.encode(t.s3rn),o,t.mimetype,r.byteLength),i=await at(s.baseUrl+"/upload-url",{method:"POST",headers:{Authorization:`Bearer ${s.token}`}}),a=await i.json();if(i.status!==200)throw new Error(a.error);let l=a.uploadUrl;await at(l,{method:"PUT",headers:{"Content-Type":t.mimetype},body:r})}destroy(){this.pb.cancelAllRequests(),this.pb=null,this.tokenStore=null,this.sharedFolder=null}};var Md=class extends bn{constructor(){super(...arguments);this.notifyListeners=(0,nt.debounce)(super.notifyListeners,100)}update(){this.notifyListeners()}add(t,r=!0){let o=this.find(s=>s.guid===t.guid);return o&&o!==t&&(this.error("duplicate guid",o,t),this._set.delete(o)),this._set.add(t),r&&this.notifyListeners(),this}},Jl=class extends Wo{constructor(t,r,o,s,i,a,l,c,u,f,d,p,m=!0){var g;let y=p?new jo(p,r):new Vr(r);super(r,y,l,s);this.appId=t;this.hashStore=u;this.backgroundSync=f;this._settings=d;this.destroyed=!1;this.readyPromise=null;this.whenSyncedPromise=null;this.persistenceSynced=!1;this.syncFileTreePromise=null;this.syncRequestedDuringSync=!1;this.unsubscribes=[];this.pendingDeletes=new Set;this.addLocalDocs=()=>{let t=this.getSyncFiles(),r=[];this.placeHold(t),t.forEach(o=>{let s=this.getFile(o,!1);s&&r.push(s)}),r.length>0&&this.fset.update()};this.path=o,this.setLoggers(`[SharedFile](${this.path})`),this.fileManager=a,this.vault=i,this.files=new Map,this.fset=new Md,this.pendingUpload=new qo(`${t}-system3-relay/folders/${this.guid}/pendingUploads`),this.pendingUpload.forEach((I,L)=>{this.existsSync(L)||(this.warn("deleting pending upload record because file is missing",L,I),this.pendingUpload.delete(L))}),this.relayManager=c,this.relayId=p,this.diskBufferStore=new Pl,this._shouldConnect=(g=this.settings.connect)!=null?g:!0,this.authoritative=!m,this.syncSettingsManager=this._settings.getChild("sync",(I,L)=>new js(I,L)),this.syncStore=new Kl(this.ydoc,this.path,this.pendingUpload,this.syncSettingsManager),this.syncStore.on(async()=>{await this.syncFileTree(this.syncStore)}),this.unsubscribes.push(this.relayManager.remoteFolders.subscribe(I=>{this.remote=I.find(L=>L.guid==this.guid)})),this.unsubscribes.push(this.relayManager.storageQuotas.subscribe(async I=>{let L=I.find(C=>{var S;return C.id===((S=this._remote)==null?void 0:S.relay.storageQuotaId)});L!==void 0&&this.storageQuota!==L.quota&&(this.storageQuota!==void 0&&L.quota!==void 0&&L.quota>this.storageQuota&&(this.debug("storage quota increase",this.storageQuota,L.quota),await this.netSync()),this.debug("storage quota update",this.storageQuota,L.quota),this.storageQuota=L.quota)})),this.proxy=yb(this,this.path,I=>this.getVirtualPath(I));try{this._persistence=new pn(this.guid,this.ydoc)}catch(I){throw this.warn("Unable to open persistence.",this.guid),console.error(I),I}s.loggedIn&&this.connect(),this.cas=new Gl(this),this.whenReady().then(()=>{this.destroyed||(this.addLocalDocs(),this.syncFileTree(this.syncStore))}),this.whenSynced().then(async()=>{this.syncStore.start();try{this._persistence.set("path",this.path),this._persistence.set("relay",this.relayId||""),this._persistence.set("appId",this.appId),this._persistence.set("s3rn",kt.encode(this.s3rn))}catch(I){}}),(async()=>await this.getServerSynced()||(await this.onceProviderSynced(),await this.markSynced()))(),Bt.set(this,this.path)}get server(){return this._server}set server(t){if(t===this._server)return;this.warn("server changed -- reinitializing all connections");let r=this.shouldConnect;this.reset();let o=[];this.fset.forEach(s=>{s instanceof Wo&&(s.connected&&o.push(s),s.reset())}),this.tokenStore.clear(s=>{var i;return((i=s.token)==null?void 0:i.folder)===this.guid}),r&&(this.connect(),o.forEach(s=>{s.connect()})),this._server=t}get tfolder(){let t=this.vault.getAbstractFileByPath(this.path);if(!(t instanceof nt.TFolder))throw new Error("tfolder is not a folder");return t}isSyncableTFile(t){let r=this.checkPath(t.path),o=this.getVirtualPath(t.path),s=this.syncStore.canSync(o);if(t instanceof nt.TFolder)return r&&s;let i=this.syncSettingsManager.isExtensionEnabled(o);return r&&s&&i}getSyncFiles(){let t=this.vault.getAbstractFileByPath(this.path);if(!(t instanceof nt.TFolder))throw new Error(`Could not find shared folders on file system at ${this.path}`);let r=[];return nt.Vault.recurseChildren(t,o=>{o!==t&&r.push(o)}),r.filter(o=>this.isSyncableTFile(o))}get shouldConnect(){return this._shouldConnect}set shouldConnect(t){this._settings.update(r=>({...r,connect:t})),this._shouldConnect=t}async netSync(){await this.whenReady(),this.addLocalDocs(),await this.syncFileTree(this.syncStore),this.backgroundSync.enqueueSharedFolderSync(this)}get settings(){return this._settings.get()}async sync(){await this.syncFileTree(this.syncStore)}connect(){return this.s3rn instanceof jo&&(this.connected||this.shouldConnect)?super.connect():Promise.resolve(!1)}get name(){return this.path.split("/").pop()||""}get location(){return this.path.split("/").slice(0,-1).join("/")}get remote(){var t;try{(t=this._remote)==null||t.relay}catch(r){return}return this._remote}set remote(t){var r;this._remote!==t&&(this._remote=t,this.relayId=(r=t==null?void 0:t.relay)==null?void 0:r.guid,this.s3rn=this.relayId?new jo(this.relayId,this.guid):new Vr(this.guid),this._settings.update(o=>({...o,relay:this.relayId})),t&&(this._server=t.relay.providerId,this.unsubscribes.push(t.relay.subscribe(o=>{o.guid===this.relayId&&(this.server=o.providerId)}))),this.server=t==null?void 0:t.relay.providerId,this.notifyListeners())}get ready(){return this.persistenceSynced&&(this.authoritative||this._persistence.hasServerSync||this.synced)}async markSynced(){await this._persistence.markServerSynced()}async getServerSynced(){return this._persistence.getServerSynced()}hasLocalDB(){return this._persistence.hasUserData()}async awaitingUpdates(){return await this.whenSynced(),this.authoritative||await this.getServerSynced()?!1:!this.hasLocalDB()}whenReady(){let t=async()=>await this.awaitingUpdates()?(this.connect(),await this.onceConnected(),await this.onceProviderSynced(),this):this;return this.readyPromise=this.readyPromise||new oo(t,()=>[this.ready,this]),this.readyPromise.getPromise()}whenSynced(){let t=async()=>{if(this._persistence.synced){this.persistenceSynced=!0;return}return new Promise(r=>{this._persistence.once("synced",()=>{this.persistenceSynced=!0,r()})})};return this.whenSyncedPromise=this.whenSyncedPromise||new oo(t,()=>(this._persistence.synced&&(this.persistenceSynced=!0),[this.persistenceSynced,void 0])),this.whenSyncedPromise.getPromise()}get intent(){return this.shouldConnect?"connected":"disconnected"}async _handleServerRename(t,r,o,s){if(s==null||s.push(`${o.path} was renamed to ${this.getPath(r)}`),o instanceof nt.TFile){let i=(0,Mr.dirname)(r);this.existsSync(i)||(await this.mkdir(i),s==null||s.push(`creating directory ${i}`))}await this.fileManager.renameFile(o,(0,nt.normalizePath)(this.getPath(r))).then(()=>{t.move(r,this)})}async _handleServerCreate(t,r,o){let s=(0,Mr.dirname)(t);if(this.existsSync(s)||(await this.mkdir(s),o==null||o.push(`creating directory ${s}`)),r.type==="markdown")return o==null||o.push(`created local .md file for remotely added doc ${t}`),await this.downloadDoc(t,!1);if(r.type==="canvas")return o==null||o.push(`created local .canvas file for remotely added canvas ${t}`),await this.downloadCanvas(t,!1);if(r.type==="folder")return o==null||o.push(`created local folder for remotely added folder ${t}`),this.getSyncFolder(t,!1);if(this.syncStore.canSync(t))return o==null||o.push(`created local file for remotely added file ${t}`),this.downloadSyncFile(t,!1);throw new Error(`${t}: Unexpected file type ${r.type} ${r.mimetype}`)}_assertNamespacing(t){try{this.assertPath(this.path+t)}catch(r){this.error("Deleting doc (somehow moved outside of shared folder)",t),this.syncStore.delete(t);return}}applyRemoteState(t,r,o,s){let i=this.files.get(t),a=this.syncStore.getMeta(r);if(!a)return this.warn("unknown sync type",r),{op:"noop",path:r,promise:Promise.resolve()};if(this.existsSync(r)){if(i&&mr(i)&&fb(a)){let c=this._upgradeToCanvas(i,t,r,s);return{op:"upgrade",path:r,promise:c}}if(i&&mr(i)&&i.shouldPull(a))return{op:"update",path:r,promise:i.pull()};if(!i&&pb(a)){let c=this.syncStore.get(r),u=c?this.files.get(c):null;if(c&&u&&mr(u)){let f=this.remapIfHashMatches(u,c,t,r,a);return{op:"update",path:r,promise:f}}}return{op:"noop",path:r,promise:Promise.resolve()}}if(o.has(t)&&i){let c=this.getPath(i.path),u=this.vault.getAbstractFileByPath(c);if(u){let f=this._handleServerRename(i,r,u,s);return{op:"rename",path:r,from:c,to:r,promise:f}}}let l=this._handleServerCreate(r,a,s);return{op:"create",path:r,promise:l}}async remapIfHashMatches(t,r,o,s,i){try{await t.caf.hash()===i.hash&&(this.files.delete(r),this.pendingUpload.delete(s),this.files.set(o,t),t.guid=o,this.log(`Remapped file ${s} from local GUID ${r} to remote GUID ${o}`))}catch(a){throw this.error("Error during GUID remapping:",a),a}}async _upgradeToCanvas(t,r,o,s){try{let i=t.guid;this.files.delete(i),this.fset.delete(t),t.destroy(),s==null||s.push(`Upgrading ${o} from SyncFile to Canvas`),this.log(`Upgrading ${o} from SyncFile to Canvas (GUID: ${i} \u2192 ${r})`),await this.downloadCanvas(o,!1),this.log(`Successfully upgraded ${o} to Canvas`)}catch(i){throw this.error("Error during SyncFile to Canvas upgrade:",i),i}}cleanupExtraLocalFiles(t,r){let o=this.getSyncFiles(),s=[],i=o.filter(c=>c instanceof nt.TFolder),a=o.filter(c=>c instanceof nt.TFile),l=c=>{var g,I;let u=this.isSyncableTFile(c),f=this.checkPath(c.path),d=t.contains(c.path.slice(this.path.length)),p=this.pendingUpload.has(this.getVirtualPath(c.path)),m=this.getVirtualPath(c.path),y=((g=this._provider)==null?void 0:g.synced)&&((I=this._persistence)==null?void 0:I.synced);if(f&&u&&!d&&!p&&y){r.push(`deleted local file ${m} for remotely deleted doc`);let L=this.vault.adapter.trashLocal(c.path);s.push({op:"delete",path:m,promise:L})}};return a.forEach(l),i.forEach(l),s}syncByType(t,r,o,s){t.forEach((i,a)=>{this._assertNamespacing(a),s.contains(i.type)&&(this._assertNamespacing(a),o.push(this.applyRemoteState(i.id,a,t.remoteIds,r)))})}syncFileTree(t){if(this.syncFileTreePromise){this.syncRequestedDuringSync=!0;let o=this.syncFileTreePromise.getPromise();return o.then(()=>{if(this.syncRequestedDuringSync)return this.syncRequestedDuringSync=!1,this.syncFileTree(t)}),o}let r=async()=>{try{let o=[],s=[];this.ydoc.transact(async()=>{this.syncStore.migrateUp(),this.syncByType(t,s,o,["folder"])},this),await Promise.all(o.map(u=>u.promise)),this.ydoc.transact(async()=>{this.syncByType(t,s,o,this.syncStore.typeRegistry.getEnabledFileSyncTypes()),this.syncStore.commit()},this);let i=o.filter(u=>u.op==="create"),a=o.filter(u=>u.op==="rename"),l=o.map(u=>u.path);await Promise.all([...i,...a].map(u=>ib(u.promise,u)));let c=this.cleanupExtraLocalFiles(l,s);[...o,...c].every(u=>u.op==="noop")?this.debug("sync: noop"):(this.log("remote paths",l),this.log("operations",[...o,...c])),(a.length>0||i.length>0||c.length>0)&&this.fset.update(),s.length>0&&this.log(`syncFileTree diff:
|
|
`+s.join(`
|
|
`))}finally{this.syncFileTreePromise=null}};return this.syncFileTreePromise=new Dl(r),this.syncFileTreePromise.getPromise()}move(t){this.path=t,this.setLoggers(`[SharedFile](${this.path})`),this._settings.update(r=>({...r,path:t}))}read(t){let r=(0,Mr.join)(this.path,t.path);return this.vault.adapter.read((0,nt.normalizePath)(r))}existsSync(t){let r=(0,nt.normalizePath)((0,Mr.join)(this.path,t));return this.vault.getAbstractFileByPath(r)!==null}exists(t){let r=(0,Mr.join)(this.path,t.path);return this.vault.adapter.exists((0,nt.normalizePath)(r))}flush(t,r){let o=(0,Mr.join)(this.path,t.path);return this.log("writing to ",(0,nt.normalizePath)(o)),this.vault.adapter.write((0,nt.normalizePath)(o),r)}getPath(t){return(0,Mr.join)(this.path,t)}assertPath(t){if(!this.checkPath(t))throw new Error("Path is not in shared folder: "+t)}mkdir(t){let r=(0,Mr.join)(this.path,t);return this.vault.adapter.mkdir((0,nt.normalizePath)(r))}checkPath(t){return t.startsWith(this.path+Mr.sep)}getVirtualPath(t){return this.assertPath(t),t.slice(this.path.length)}getTFile(t){let r=this.vault.getAbstractFileByPath(this.getPath(t.path));return r instanceof nt.TFile?r:null}getDoc(t,r=!0){let o=this.syncStore.get(t);if(o!==void 0){let s=this.files.get(o);if(s!==void 0){if(s.move(t,this),!so(s))throw new Error("getDoc(): unexpected ifile type");return s}else return this.log("[getDoc]: creating doc for shared ID"),this.pendingUpload.has(t)?this.uploadDoc(t,r):this.createDoc(t,r)}else{this.warn("[getDoc]: creating new shared ID for existing tfile");let s=this.vault.getAbstractFileByPath(this.getPath(t));if(!(s instanceof nt.TFile))throw new Error("unexpectedly missing tfile or got tfolder");return this.placeHold([s]).length>0?this.uploadDoc(t):this.createDoc(t,r)}}getCanvas(t,r=!0){let o=this.syncStore.get(t);if(o!==void 0){let s=this.files.get(o);if(s!==void 0){if(s.move(t,this),!io(s))throw new Error("getCanvas(): unexpected ifile type");return s}else return this.log("[getCanvas]: creating canvas for shared ID"),this.pendingUpload.has(t)?this.uploadCanvas(t,r):this.createCanvas(t,r)}else{this.warn("[getCanvas]: creating new shared ID for existing tfile");let s=this.vault.getAbstractFileByPath(this.getPath(t));if(!(s instanceof nt.TFile))throw new Error("unexpectedly missing tfile or got tfolder");return this.placeHold([s]).length>0?this.uploadCanvas(t):this.createCanvas(t,r)}}async markUploaded(t){let r=(o,s)=>{this.syncStore&&this.syncStore.willSet(o.path,s)&&(this.log("new meta",o.path,s),this.ydoc.transact(()=>{this.syncStore.markUploaded(o.path,s)},this))};if(so(t)){let o=Ji(t.guid);r(t,o);return}if(io(t)){let o=mb(t.guid);r(t,o);return}if(Ld(t)){let o=jl(t.guid);r(t,o);return}if(mr(t)){let o=this.syncStore.typeRegistry.getTypeForPath(t.path);if(!o)throw new Error("unexpected sync type");let s=await t.caf.hash();if(!s)throw new Error("file hash not yet computed");let i=hb(o,t.guid,t.mimetype,s,t.stat.mtime);r(t,i);return}}getFile(t,r=!0){let o=this.getVirtualPath(t.path),s=this.syncStore.get(o);if(s){let i=this.files.get(s);if(i)return i;let a=this.syncStore.getMeta(o);if(a){if(a.type==="markdown")return this.getDoc(o);if(a.type==="canvas")return this.getCanvas(o);if(a.type==="folder")return this.getSyncFolder(o,r);if(this.syncStore.canSync(o))return this.getSyncFile(o,r)}}if(t instanceof nt.TFolder)return this.getSyncFolder(o,r);if(t instanceof nt.TFile){if(Mt.checkExtension(o))return this.getDoc(o);if(Vt.checkExtension(o)&&He().enableCanvasSync)return this.getCanvas(o);if(this.syncStore.canSync(o))return this.getSyncFile(o,r)}return null}placeHold(t){let r=[];return this.ydoc.transact(()=>{t.forEach(o=>{let s=this.getVirtualPath(o.path);if(this.isPendingDelete(s)){this.log("skipping place hold for pending delete",s);return}this.syncStore.has(s)||(this.log("place hold new",s),this.syncStore.new(s),r.push(s))})},this),r}getOrCreateCanvas(t,r){let o=this.files.get(t)||new Vt(r,t,this.loginManager,this);if(!io(o))throw new Error("getOrCreateCanvas(): unexpected ifile type");return o.move(r,this),o}async downloadCanvas(t,r=!0){if(!Vt.checkExtension(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error(`called download on item that is not in ids ${t}`);let s=this.getOrCreateCanvas(o,t);return s.markOrigin("remote"),this.backgroundSync.enqueueCanvasDownload(s),this.files.set(o,s),this.fset.add(s,r),s}uploadCanvas(t,r=!0){if(!Vt.checkExtension(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error("expected guid");let s=this.getOrCreateCanvas(o,t),i=s.getOrigin(),a=this.awaitingUpdates();return(async()=>{if(!await this.exists(s))throw new Error(`Upload failed, doc does not exist at ${t}`);let[c,u,f]=await Promise.all([this.read(s),i,a]);!f&&u===void 0&&(this.log(`[${s.path}] No Known Peers: Syncing file into ytext.`),this.ydoc.transact(()=>{try{s.applyJSON(c)}catch(d){throw console.warn(c),d}},this._persistence),s.markOrigin("local"),this.log(`[${s.path}] Uploading file`),await this.backgroundSync.enqueueSync(s),this.markUploaded(s))})(),this.files.set(o,s),this.fset.add(s,r),s}createCanvas(t,r){if(!Vt.checkExtension(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error("expected guid");let s=this.getOrCreateCanvas(o,t);return(async()=>this.whenReady().then(async()=>{let i=await s.getServerSynced();s.stat.size===0&&!i?this.backgroundSync.enqueueCanvasDownload(s):this.pendingUpload.get(s.path)&&this.backgroundSync.enqueueSync(s)}))(),this.files.set(o,s),this.fset.add(s,r),s}viewDoc(t){let r=this.syncStore.get(t);if(!r)return;let o=this.files.get(r);if(!so(o))throw new Error("viewDoc(): unexpected ifile type");return o}viewSyncFile(t){let r=this.syncStore.get(t);if(!r)return;let o=this.files.get(r);if(!o){this.debug(`viewSyncFile(): file not loaded yet, guid=${r}, vpath=${t}`);return}if(!mr(o)){this.debug(`viewSyncFile(): file exists but is not SyncFile, guid=${r}, vpath=${t}, actual type=${o.constructor.name}`);return}return o}getOrCreateDoc(t,r){let o=this.files.get(t)||new Mt(r,t,this.loginManager,this);if(!so(o))throw new Error("unexpected ifile type");return o.move(r,this),o}async downloadDoc(t,r=!0){if(!Mt.checkExtension(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error(`called download on item that is not in ids ${t}`);let s=this.getOrCreateDoc(o,t);return s.markOrigin("remote"),this.backgroundSync.enqueueDownload(s),this.files.set(o,s),this.fset.add(s,r),s}uploadDoc(t,r=!0){if(!Mt.checkExtension(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error("missing guid");let s=this.getOrCreateDoc(o,t),i=s.getOrigin(),a=this.awaitingUpdates();return(async()=>{if(!await this.exists(s))throw new Error(`Upload failed, doc does not exist at ${t}`);let[c,u,f]=await Promise.all([this.read(s),i,a]),d=s.ydoc.getText("contents");!f&&u===void 0&&(this.log(`[${s.path}] No Known Peers: Syncing file into ytext.`),this.ydoc.transact(()=>{d.insert(0,c)},this._persistence),s.markOrigin("local"),this.log(`[${s.path}] Uploading file`),await this.backgroundSync.enqueueSync(s),this.markUploaded(s))})(),this.files.set(o,s),this.fset.add(s,r),s}createDoc(t,r=!0){if(!Mt.checkExtension(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error("expected guid");let s=this.getOrCreateDoc(o,t);return(async()=>this.whenReady().then(async()=>{var a;let i=await s.getServerSynced();((a=s.tfile)==null?void 0:a.stat.size)===0&&!i?this.backgroundSync.enqueueDownload(s):this.pendingUpload.get(s.path)&&this.backgroundSync.enqueueSync(s)}))(),this.files.set(o,s),this.fset.add(s,r),s}getOrCreateSyncFolder(t,r){let o=this.files.get(t)||new zs(r,t,this);if(!Ld(o))throw new Error("unexpected ifile type");return o.move(r,this),o}getSyncFolder(t,r){if(this.log("[getSyncFolder]","getting syncfolder"),!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error("expected guid");let s=this.getOrCreateSyncFolder(o,t);return this.files.set(o,s),this.fset.add(s,r),s}getOrCreateSyncFile(t,r,o){let s=this.files.get(t)||new xn(r,t,this.hashStore,this);if(!mr(s))throw new Error(`getOrCreateSyncFile(): unexpected ifile type, guid=${t}`);return s.move(r,this),this.files.set(t,s),s}syncFile(t,r){if(!this.syncStore.canSync(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error(`called sync on item that is not in ids ${t}`);let s=this.syncStore.getMeta(t);if(!s||!s.hash)return this.uploadSyncFile(t,r);let i=this.getOrCreateSyncFile(o,t,s.hash);return this.backgroundSync.enqueueSync(i),this.files.set(o,i),this.fset.add(i,r),i}downloadSyncFile(t,r){if(!this.syncStore.canSync(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error(`called download on item that is not in ids ${t}`);let s=this.syncStore.getMeta(t);if(!s||!s.hash)return this.uploadSyncFile(t,r);let i=this.getOrCreateSyncFile(o,t,s.hash);return this.backgroundSync.enqueueDownload(i),this.files.set(o,i),this.fset.add(i,r),i}uploadSyncFile(t,r=!0){if(!this.syncStore.canSync(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error("missing guid");let s=this.vault.getAbstractFileByPath(this.getPath(t));if(!s)throw new Error(`Upload failed, file does not exist at ${t}`);if(!(s instanceof nt.TFile))throw new Error(`Upload failed, expected file at ${t}`);let i=this.getOrCreateSyncFile(o,t,s);return this.backgroundSync.enqueueSync(i),this.fset.add(i,r),i}getSyncFile(t,r=!0){if(!this.syncStore.canSync(t))throw new Error("unexpected extension");if(!this.synced&&!this.syncStore.has(t))throw new Error(`potential for document split at ${t}`);let o=this.syncStore.get(t);if(!o)throw new Error("missing guid");let s=this.vault.getAbstractFileByPath(this.getPath(t));if(!s)throw new Error(`Upload failed, file does not exist at ${t}`);if(!(s instanceof nt.TFile))throw new Error(`Upload failed, expected file at ${t}`);let i=this.getOrCreateSyncFile(o,t,s);return this.syncStore.getMeta(t)?i.pull():(this.log("get syncfile missing meta"),i.push()),this.files.set(o,i),this.fset.add(i,r),i}uploadFile(t,r=!0){let o=this.getVirtualPath(t.path);if(t instanceof nt.TFolder)return this.getSyncFolder(o,r);if(t instanceof nt.TFile){if(Mt.checkExtension(o))return this.uploadDoc(o,r);if(Vt.checkExtension(o)&&He().enableCanvasSync)return this.uploadCanvas(o,r);if(this.syncStore.canSync(o))return this.uploadSyncFile(o,r)}throw new Error("unexpectedly unable to upload")}markPendingDelete(t){this.pendingDeletes.add(t),this.log("marked pending delete",t)}clearPendingDelete(t){this.pendingDeletes.delete(t),this.log("cleared pending delete",t)}isPendingDelete(t){return this.pendingDeletes.has(t)}deleteFile(t){var o;let r=(o=this.syncStore)==null?void 0:o.get(t);r&&this.ydoc.transact(()=>{this.syncStore.delete(t);let s=this.files.get(r);s&&(s.cleanup(),this.fset.delete(s)),this.files.delete(r)},this)}renameFile(t,r){let o=t.path,s="",i="";try{s=this.getVirtualPath(o)}catch(a){this.log("Moving out of shared folder")}try{i=this.getVirtualPath(r)}catch(a){this.log("Moving in from outside of shared folder")}if(!(!s&&!i))if(i){let a=this.syncStore.get(i);if(!a)return;let l=this.files.get(a);if(!s)this.ydoc.transact(()=>{this.syncStore.delete(i)},this),l&&(l.cleanup(),l.destroy(),this.fset.delete(l)),this.files.delete(a);else{if(!this.syncStore.get(i))return;let u=[];l instanceof zs&&this.syncStore.forEach((f,d)=>{if(d.startsWith(i+Mr.sep)){let p=d.replace(i,s);u.push([f.id,d,p])}}),this.ydoc.transact(()=>{this.syncStore.move(i,s),l&&l.move(s,this),u.forEach(f=>{let[d,p,m]=f;this.syncStore.move(p,m);let y=this.files.get(d);y&&y.move(m,this)})},this),this.syncStore.resolveMove(i)}}else{if(this.assertPath(o),!this.syncStore.canSync(s))return;this.placeHold([t]),this.uploadFile(t)}}destroy(){var t,r,o;this.destroyed=!0,this.unsubscribes.forEach(s=>{s()}),this.files.forEach(s=>{s.destroy(),this.files.delete(s.guid)}),this.syncStore.destroy(),this.syncSettingsManager.destroy(),super.destroy(),this.ydoc.destroy(),this.fset.clear(),this._settings.destroy(),this._settings=null,this.diskBufferStore=null,this.relayManager=null,this.backgroundSync=null,this.loginManager=null,this.tokenStore=null,this.fileManager=null,this.syncStore=null,this.syncSettingsManager=null,(t=this.whenSyncedPromise)==null||t.destroy(),this.whenSyncedPromise=null,(r=this.readyPromise)==null||r.destroy(),this.readyPromise=null,(o=this.syncFileTreePromise)==null||o.destroy(),this.syncFileTreePromise=null}},Yl=class extends bn{constructor(t,r,o,s){super();this.relayManager=t;this.vault=r;this.settings=s;this.update=(0,nt.debounce)(this.notifyListeners,100);this.folderBuilder=o,this._offRemoteUpdates||(this._offRemoteUpdates=this.relayManager.remoteFolders.subscribe(i=>{let a=!1;this.items().forEach(l=>{let c=i.find(u=>u.guid==l.guid);l.remote!=c&&(a=!0),l.remote=c}),a&&this.update()}))}delete(t){t==null||t.destroy();let r=super.delete(t);return this.settings.update(o=>o.filter(s=>s.guid!==t.guid)),r}get manager(){return this.relayManager}lookup(t){let r=this.find(o=>o.checkPath(t));return r||null}destroy(){this.items().forEach(t=>{t.destroy()}),this.clear(),this._offRemoteUpdates&&this._offRemoteUpdates(),this.unsubscribes.forEach(t=>{t()}),this.relayManager=null,this.folderBuilder=null}load(){this._load(this.settings.get())}_load(t){let r=!1;t.forEach(o=>{if(!this.vault.getFolderByPath(o.path)){this.warn(`Invalid settings, ${o.path} does not exist`);return}this._new(o.path,o.guid,o==null?void 0:o.relay),r=!0}),r&&this.notifyListeners()}_new(t,r,o,s){let i=this.find(u=>u.path==t&&u.guid==r);if(i)return i;let a=this.find(u=>u.guid==r);if(a)throw new Error(`This folder is already mounted at ${a.path}.`);if(this.find(u=>u.path==t))throw new Error("Conflict: Tracked folder exists at this location.");let c=this.folderBuilder(t,r,o,s);return this._set.add(c),c}new(t,r,o,s){let i=this._new(t,r,o,s);return this.notifyListeners(),i}};var Fc=require("@codemirror/state"),fK=require("@codemirror/view"),Ht=require("obsidian");function B(){}var Qi=n=>n;function le(n,e){for(let t in e)n[t]=e[t];return n}function bb(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Td(n){return n()}function Zl(){return Object.create(null)}function me(n){n.forEach(Td)}function Je(n){return typeof n=="function"}function j(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}var Ql;function hr(n,e){return n===e?!0:(Ql||(Ql=document.createElement("a")),Ql.href=e,n===Ql.href)}function vb(n){return Object.keys(n).length===0}function Dt(n,...e){if(n==null){for(let r of e)r(void 0);return B}let t=n.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ao(n){let e;return Dt(n,t=>e=t)(),e}function ne(n,e,t){n.$$.on_destroy.push(Dt(e,t))}function ye(n,e,t,r){if(n){let o=xb(n,e,t,r);return n[0](o)}}function xb(n,e,t,r){return n[1]&&r?le(t.ctx.slice(),n[1](r(e))):t.ctx}function be(n,e,t,r){if(n[2]&&r){let o=n[2](r(t));if(e.dirty===void 0)return o;if(typeof o=="object"){let s=[],i=Math.max(e.dirty.length,o.length);for(let a=0;a<i;a+=1)s[a]=e.dirty[a]|o[a];return s}return e.dirty|o}return e.dirty}function ve(n,e,t,r,o,s){if(o){let i=xb(e,t,r,s);n.p(i,o)}}function xe(n){if(n.ctx.length>32){let e=[],t=n.ctx.length/32;for(let r=0;r<t;r++)e[r]=-1;return e}return-1}function ke(n){let e={};for(let t in n)t[0]!=="$"&&(e[t]=n[t]);return e}function Ad(n,e){let t={};e=new Set(e);for(let r in n)!e.has(r)&&r[0]!=="$"&&(t[r]=n[r]);return t}function Tt(n){return n==null?"":n}function Ws(n,e,t){return n.set(t),e}function zn(n){return n&&Je(n.destroy)?n.destroy:B}var wb=typeof window!="undefined",Fd=wb?()=>window.performance.now():()=>Date.now(),Zi=wb?n=>requestAnimationFrame(n):B;var Ks=new Set;function _b(n){Ks.forEach(e=>{e.c(n)||(Ks.delete(e),e.f())}),Ks.size!==0&&Zi(_b)}function Ed(n){let e;return Ks.size===0&&Zi(_b),{promise:new Promise(t=>{Ks.add(e={c:n,f:t})}),abort(){Ks.delete(e)}}}var Pd=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var Xl=class n{constructor(e){St(this,"_listeners","WeakMap"in Pd?new WeakMap:void 0);St(this,"_observer");St(this,"options");this.options=e}observe(e,t){return this._listeners.set(e,t),this._getObserver().observe(e,this.options),()=>{this._listeners.delete(e),this._observer.unobserve(e)}}_getObserver(){var e;return(e=this._observer)!=null?e:this._observer=new ResizeObserver(t=>{var r;for(let o of t)n.entries.set(o.target,o),(r=this._listeners.get(o.target))==null||r(o)})}};Xl.entries="WeakMap"in Pd?new WeakMap:void 0;var Sb=!1;function kb(){Sb=!0}function Ib(){Sb=!1}function b(n,e){n.appendChild(e)}function we(n,e,t){let r=ec(n);if(!r.getElementById(e)){let o=x("style");o.id=e,o.textContent=t,Lb(r,o)}}function ec(n){if(!n)return document;let e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Cb(n){let e=x("style");return e.textContent="/* empty */",Lb(ec(n),e),e.sheet}function Lb(n,e){return b(n.head||n,e),e.sheet}function _(n,e,t){n.insertBefore(e,t||null)}function w(n){n.parentNode&&n.parentNode.removeChild(n)}function ze(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function x(n){return document.createElement(n)}function Qt(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function V(n){return document.createTextNode(n)}function T(){return V(" ")}function ue(){return V("")}function $(n,e,t,r){return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}function tc(n){return function(e){return e.preventDefault(),n.call(this,e)}}function rc(n){return function(e){return e.stopPropagation(),n.call(this,e)}}function h(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}var RI=["width","height"];function UI(n,e){let t=Object.getOwnPropertyDescriptors(n.__proto__);for(let r in e)e[r]==null?n.removeAttribute(r):r==="style"?n.style.cssText=e[r]:r==="__value"?n.value=n[r]=e[r]:t[r]&&t[r].set&&RI.indexOf(r)===-1?n[r]=e[r]:h(n,r,e[r])}function Xi(n,e){for(let t in e)h(n,t,e[t])}function OI(n,e){Object.keys(e).forEach(t=>{$I(n,t,e[t])})}function $I(n,e,t){let r=e.toLowerCase();r in n?n[r]=typeof n[r]=="boolean"&&t===""?!0:t:e in n?n[e]=typeof n[e]=="boolean"&&t===""?!0:t:h(n,e,t)}function Mb(n){return/-/.test(n)?OI:UI}function Tb(n){return Array.from(n.childNodes)}function J(n,e){e=""+e,n.data!==e&&(n.data=e)}function Ye(n,e){n.value=e==null?"":e}function se(n,e,t,r){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,r?"important":"")}function _n(n,e,t){for(let r=0;r<n.options.length;r+=1){let o=n.options[r];if(o.__value===e){o.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function _e(n,e,t){n.classList.toggle(e,!!t)}function ea(n,e,{bubbles:t=!1,cancelable:r=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:r})}var wn=class{constructor(e=!1){St(this,"is_svg",!1);St(this,"e");St(this,"n");St(this,"t");St(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,r=null){this.e||(this.is_svg?this.e=Qt(t.nodeName):this.e=x(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(r)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t<this.n.length;t+=1)_(this.t,this.n[t],e)}p(e){this.d(),this.h(e),this.i(this.a)}d(){this.n.forEach(w)}};function Ab(n){let e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}function Gs(n,e){return new n(e)}var oc=new Map,nc=0;function NI(n){let e=5381,t=n.length;for(;t--;)e=(e<<5)-e^n.charCodeAt(t);return e>>>0}function BI(n,e){let t={stylesheet:Cb(e),rules:{}};return oc.set(n,t),t}function sc(n,e,t,r,o,s,i,a=0){let l=16.666/r,c=`{
|
|
`;for(let g=0;g<=1;g+=l){let I=e+(t-e)*s(g);c+=g*100+`%{${i(I,1-I)}}
|
|
`}let u=c+`100% {${i(t,1-t)}}
|
|
}`,f=`__svelte_${NI(u)}_${a}`,d=ec(n),{stylesheet:p,rules:m}=oc.get(d)||BI(d,n);m[f]||(m[f]=!0,p.insertRule(`@keyframes ${f} ${u}`,p.cssRules.length));let y=n.style.animation||"";return n.style.animation=`${y?`${y}, `:""}${f} ${r}ms linear ${o}ms 1 both`,nc+=1,f}function Dd(n,e){let t=(n.style.animation||"").split(", "),r=t.filter(e?s=>s.indexOf(e)<0:s=>s.indexOf("__svelte")===-1),o=t.length-r.length;o&&(n.style.animation=r.join(", "),nc-=o,nc||VI())}function VI(){Zi(()=>{nc||(oc.forEach(n=>{let{ownerNode:e}=n.stylesheet;e&&w(e)}),oc.clear())})}var Sn;function Tr(n){Sn=n}function ta(){if(!Sn)throw new Error("Function called outside component initialization");return Sn}function st(n){ta().$$.on_mount.push(n)}function Go(n){ta().$$.on_destroy.push(n)}function Xe(){let n=ta();return(e,t,{cancelable:r=!1}={})=>{let o=n.$$.callbacks[e];if(o){let s=ea(e,t,{cancelable:r});return o.slice().forEach(i=>{i.call(n,s)}),!s.defaultPrevented}return!0}}function gr(n,e){let t=n.$$.callbacks[e.type];t&&t.slice().forEach(r=>r.call(this,e))}var Wn=[];var pt=[],Ys=[],Ud=[],Fb=Promise.resolve(),Od=!1;function $d(){Od||(Od=!0,Fb.then(ra))}function Nd(){return $d(),Fb}function ko(n){Ys.push(n)}function ic(n){Ud.push(n)}var Rd=new Set,Js=0;function ra(){if(Js!==0)return;let n=Sn;do{try{for(;Js<Wn.length;){let e=Wn[Js];Js++,Tr(e),HI(e.$$)}}catch(e){throw Wn.length=0,Js=0,e}for(Tr(null),Wn.length=0,Js=0;pt.length;)pt.pop()();for(let e=0;e<Ys.length;e+=1){let t=Ys[e];Rd.has(t)||(Rd.add(t),t())}Ys.length=0}while(Wn.length);for(;Ud.length;)Ud.pop()();Od=!1,Rd.clear(),Tr(n)}function HI(n){if(n.fragment!==null){n.update(),me(n.before_update);let e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(ko)}}function Eb(n){let e=[],t=[];Ys.forEach(r=>n.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),Ys=e}var oa;function qI(){return oa||(oa=Promise.resolve(),oa.then(()=>{oa=null})),oa}function Bd(n,e,t){n.dispatchEvent(ea(`${e?"intro":"outro"}${t}`))}var ac=new Set,Jo;function ee(){Jo={r:0,c:[],p:Jo}}function te(){Jo.r||me(Jo.c),Jo=Jo.p}function v(n,e){n&&n.i&&(ac.delete(n),n.i(e))}function k(n,e,t,r){if(n&&n.o){if(ac.has(n))return;ac.add(n),Jo.c.push(()=>{ac.delete(n),r&&(t&&n.d(1),r())}),n.o(e)}else r&&r()}var jI={duration:0};function Kn(n,e,t,r){let s=e(n,t,{direction:"both"}),i=r?0:1,a=null,l=null,c=null,u;function f(){c&&Dd(n,c)}function d(m,y){let g=m.b-i;return y*=Math.abs(g),{a:i,b:m.b,d:g,duration:y,start:m.start,end:m.start+y,group:m.group}}function p(m){let{delay:y=0,duration:g=300,easing:I=Qi,tick:L=B,css:C}=s||jI,S={start:Fd()+y,b:m};m||(S.group=Jo,Jo.r+=1),"inert"in n&&(m?u!==void 0&&(n.inert=u):(u=n.inert,n.inert=!0)),a||l?l=S:(C&&(f(),c=sc(n,i,m,g,y,I,C)),m&&L(0,1),a=d(S,g),ko(()=>Bd(n,m,"start")),Ed(M=>{if(l&&M>l.start&&(a=d(l,g),l=null,Bd(n,a.b,"start"),C&&(f(),c=sc(n,i,a.b,a.duration,0,I,s.css))),a){if(M>=a.end)L(i=a.b,1-i),Bd(n,a.b,"end"),l||(a.b?f():--a.group.r||me(a.group.c)),a=null;else if(M>=a.start){let E=M-a.start;i=a.a+a.d*I(E/a.duration),L(i,1-i)}}return!!(a||l)}))}return{run(m){Je(s)?qI().then(()=>{s=s({direction:m?"in":"out"}),p(m)}):p(m)},end(){f(),a=l=null}}}function Qs(n,e){let t=e.token={};function r(o,s,i,a){if(e.token!==t)return;e.resolved=a;let l=e.ctx;i!==void 0&&(l=l.slice(),l[i]=a);let c=o&&(e.current=o)(l),u=!1;e.block&&(e.blocks?e.blocks.forEach((f,d)=>{d!==s&&f&&(ee(),k(f,1,1,()=>{e.blocks[d]===f&&(e.blocks[d]=null)}),te())}):e.block.d(1),c.c(),v(c,1),c.m(e.mount(),e.anchor),u=!0),e.block=c,e.blocks&&(e.blocks[s]=c),u&&ra()}if(bb(n)){let o=ta();if(n.then(s=>{Tr(o),r(e.then,1,e.value,s),Tr(null)},s=>{if(Tr(o),r(e.catch,2,e.error,s),Tr(null),!e.hasCatch)throw s}),e.current!==e.pending)return r(e.pending,0),!0}else{if(e.current!==e.then)return r(e.then,1,e.value,n),!0;e.resolved=n}}function lc(n,e,t){let r=e.slice(),{resolved:o}=n;n.current===n.then&&(r[n.value]=o),n.current===n.catch&&(r[n.error]=o),n.block.p(r,t)}function he(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Zs(n,e){n.d(1),e.delete(n.key)}function Gn(n,e){k(n,1,1,()=>{e.delete(n.key)})}function qr(n,e,t,r,o,s,i,a,l,c,u,f){let d=n.length,p=s.length,m=d,y={};for(;m--;)y[n[m].key]=m;let g=[],I=new Map,L=new Map,C=[];for(m=p;m--;){let U=f(o,s,m),K=t(U),R=i.get(K);R?r&&C.push(()=>R.p(U,e)):(R=c(K,U),R.c()),I.set(K,g[m]=R),K in y&&L.set(K,Math.abs(m-y[K]))}let S=new Set,M=new Set;function E(U){v(U,1),U.m(a,u),i.set(U.key,U),u=U.first,p--}for(;d&&p;){let U=g[p-1],K=n[d-1],R=U.key,O=K.key;U===K?(u=U.first,d--,p--):I.has(O)?!i.has(R)||S.has(R)?E(U):M.has(O)?d--:L.get(R)>L.get(O)?(M.add(R),E(U)):(S.add(O),d--):(l(K,i),d--)}for(;d--;){let U=n[d];I.has(U.key)||l(U,i)}for(;p;)E(g[p-1]);return me(C),g}function $e(n,e){let t={},r={},o={$$scope:1},s=n.length;for(;s--;){let i=n[s],a=e[s];if(a){for(let l in i)l in a||(r[l]=1);for(let l in a)o[l]||(t[l]=a[l],o[l]=1);n[s]=a}else for(let l in i)o[l]=1}for(let i in r)i in t||(t[i]=void 0);return t}function Be(n){return typeof n=="object"&&n!==null?n:{}}var zI=["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],WI=new Set([...zI]);function cc(n,e,t){let r=n.$$.props[e];r!==void 0&&(n.$$.bound[r]=t,t(n.$$.ctx[r]))}function P(n){n&&n.c()}function A(n,e,t){let{fragment:r,after_update:o}=n.$$;r&&r.m(e,t),ko(()=>{let s=n.$$.on_mount.map(Td).filter(Je);n.$$.on_destroy?n.$$.on_destroy.push(...s):me(s),n.$$.on_mount=[]}),o.forEach(ko)}function F(n,e){let t=n.$$;t.fragment!==null&&(Eb(t.after_update),me(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function GI(n,e){n.$$.dirty[0]===-1&&(Wn.push(n),$d(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function W(n,e,t,r,o,s,i=null,a=[-1]){let l=Sn;Tr(n);let c=n.$$={fragment:null,ctx:[],props:s,update:B,not_equal:o,bound:Zl(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Zl(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};i&&i(c.root);let u=!1;if(c.ctx=t?t(n,e.props||{},(f,d,...p)=>{let m=p.length?p[0]:d;return c.ctx&&o(c.ctx[f],c.ctx[f]=m)&&(!c.skip_bound&&c.bound[f]&&c.bound[f](m),u&&GI(n,f)),d}):[],c.update(),u=!0,me(c.before_update),c.fragment=r?r(c.ctx):!1,e.target){if(e.hydrate){kb();let f=Tb(e.target);c.fragment&&c.fragment.l(f),f.forEach(w)}else c.fragment&&c.fragment.c();e.intro&&v(n.$$.fragment),A(n,e.target,e.anchor),Ib(),ra()}Tr(l)}var JI;typeof HTMLElement=="function"&&(JI=class extends HTMLElement{constructor(e,t,r){super();St(this,"$$ctor");St(this,"$$s");St(this,"$$c");St(this,"$$cn",!1);St(this,"$$d",{});St(this,"$$r",!1);St(this,"$$p_d",{});St(this,"$$l",{});St(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,r&&this.attachShadow({mode:"open"})}addEventListener(e,t,r){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){let o=this.$$c.$on(e,t);this.$$l_u.set(t,o)}super.addEventListener(e,t,r)}removeEventListener(e,t,r){if(super.removeEventListener(e,t,r),this.$$c){let o=this.$$l_u.get(t);o&&(o(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(s){return()=>{let i;return{c:function(){i=x("slot"),s!=="default"&&h(i,"name",s)},m:function(c,u){_(c,i,u)},d:function(c){c&&w(i)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let t={},r=Ab(this);for(let s of this.$$s)s in r&&(t[s]=[e(s)]);for(let s of this.attributes){let i=this.$$g_p(s.name);i in this.$$d||(this.$$d[i]=Vd(i,s.value,this.$$p_d,"toProp"))}for(let s in this.$$p_d)!(s in this.$$d)&&this[s]!==void 0&&(this.$$d[s]=this[s],delete this[s]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});let o=()=>{this.$$r=!0;for(let s in this.$$p_d)if(this.$$d[s]=this.$$c.$$.ctx[this.$$c.$$.props[s]],this.$$p_d[s].reflect){let i=Vd(s,this.$$d[s],this.$$p_d,"toAttribute");i==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,i)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(let s in this.$$l)for(let i of this.$$l[s]){let a=this.$$c.$on(s,i);this.$$l_u.set(i,a)}this.$$l={}}}attributeChangedCallback(e,t,r){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=Vd(e,r,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Vd(n,e,t,r){var s;let o=(s=t[n])==null?void 0:s.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!t[n])return e;if(r==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e==null?null:e;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}var z=class{constructor(){St(this,"$$");St(this,"$$set")}$destroy(){F(this,1),this.$destroy=B}$on(e,t){if(!Je(t))return B;let r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(t),()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!vb(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");function Ce(n,e,t,r){function o(s){return s instanceof t?s:new t(function(i){i(s)})}return new(t||(t=Promise))(function(s,i){function a(u){try{c(r.next(u))}catch(f){i(f)}}function l(u){try{c(r.throw(u))}catch(f){i(f)}}function c(u){u.done?s(u.value):o(u.value).then(a,l)}c((r=r.apply(n,e||[])).next())})}var QI={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},Hd=QI;function Pb(n,e,t){let r=n.slice();return r[11]=e[t][0],r[12]=e[t][1],r}function qd(n){let e,t=[n[12]],r={};for(let o=0;o<t.length;o+=1)r=le(r,t[o]);return{c(){e=Qt(n[11]),Xi(e,r)},m(o,s){_(o,e,s)},p(o,s){Xi(e,r=$e(t,[s&32&&o[12]]))},d(o){o&&w(e)}}}function Db(n){let e=n[11],t,r=n[11]&&qd(n);return{c(){r&&r.c(),t=ue()},m(o,s){r&&r.m(o,s),_(o,t,s)},p(o,s){o[11]?e?j(e,o[11])?(r.d(1),r=qd(o),e=o[11],r.c(),r.m(t.parentNode,t)):r.p(o,s):(r=qd(o),e=o[11],r.c(),r.m(t.parentNode,t)):e&&(r.d(1),r=null,e=o[11])},d(o){o&&w(t),r&&r.d(o)}}}function ZI(n){let e,t,r,o,s,i=he(n[5]),a=[];for(let d=0;d<i.length;d+=1)a[d]=Db(Pb(n,i,d));let l=n[10].default,c=ye(l,n,n[9],null),u=[Hd,n[7],{width:n[2]},{height:n[2]},{stroke:n[1]},{"stroke-width":r=n[4]?Number(n[3])*24/Number(n[2]):n[3]},{class:o=n[6]("lucide-icon","lucide",n[0]?`lucide-${n[0]}`:"",n[8].class)}],f={};for(let d=0;d<u.length;d+=1)f=le(f,u[d]);return{c(){e=Qt("svg");for(let d=0;d<a.length;d+=1)a[d].c();t=ue(),c&&c.c(),Xi(e,f)},m(d,p){_(d,e,p);for(let m=0;m<a.length;m+=1)a[m]&&a[m].m(e,null);b(e,t),c&&c.m(e,null),s=!0},p(d,[p]){if(p&32){i=he(d[5]);let m;for(m=0;m<i.length;m+=1){let y=Pb(d,i,m);a[m]?a[m].p(y,p):(a[m]=Db(y),a[m].c(),a[m].m(e,t))}for(;m<a.length;m+=1)a[m].d(1);a.length=i.length}c&&c.p&&(!s||p&512)&&ve(c,l,d,d[9],s?be(l,d[9],p,null):xe(d[9]),null),Xi(e,f=$e(u,[Hd,p&128&&d[7],(!s||p&4)&&{width:d[2]},(!s||p&4)&&{height:d[2]},(!s||p&2)&&{stroke:d[1]},(!s||p&28&&r!==(r=d[4]?Number(d[3])*24/Number(d[2]):d[3]))&&{"stroke-width":r},(!s||p&257&&o!==(o=d[6]("lucide-icon","lucide",d[0]?`lucide-${d[0]}`:"",d[8].class)))&&{class:o}]))},i(d){s||(v(c,d),s=!0)},o(d){k(c,d),s=!1},d(d){d&&w(e),ze(a,d),c&&c.d(d)}}}function XI(n,e,t){let r=["name","color","size","strokeWidth","absoluteStrokeWidth","iconNode","mergeClasses"],o=Ad(e,r),{$$slots:s={},$$scope:i}=e,{name:a=void 0}=e,{color:l="currentColor"}=e,{size:c=24}=e,{strokeWidth:u=2}=e,{absoluteStrokeWidth:f=!1}=e,{iconNode:d}=e,p=(...m)=>m.filter((y,g,I)=>!!y&&I.indexOf(y)===g).join(" ");return n.$$set=m=>{t(8,e=le(le({},e),ke(m))),t(7,o=Ad(e,r)),"name"in m&&t(0,a=m.name),"color"in m&&t(1,l=m.color),"size"in m&&t(2,c=m.size),"strokeWidth"in m&&t(3,u=m.strokeWidth),"absoluteStrokeWidth"in m&&t(4,f=m.absoluteStrokeWidth),"iconNode"in m&&t(5,d=m.iconNode),"$$scope"in m&&t(9,i=m.$$scope)},e=ke(e),[a,l,c,u,f,d,p,o,e,i,s]}var jd=class extends z{constructor(e){super(),W(this,e,XI,ZI,j,{name:0,color:1,size:2,strokeWidth:3,absoluteStrokeWidth:4,iconNode:5,mergeClasses:6})}get mergeClasses(){return this.$$.ctx[6]}},Ve=jd;function eC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function tC(n){let e,t,r=[{name:"arrow-right-left"},n[1],{iconNode:n[0]}],o={$$slots:{default:[eC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function rC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"m16 3 4 4-4 4"}],["path",{d:"M20 7H4"}],["path",{d:"m8 21-4-4 4-4"}],["path",{d:"M4 17h16"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var zd=class extends z{constructor(e){super(),W(this,e,rC,tC,j,{})}},Wd=zd;function oC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function nC(n){let e,t,r=[{name:"arrow-right"},n[1],{iconNode:n[0]}],o={$$slots:{default:[oC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function sC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M5 12h14"}],["path",{d:"m12 5 7 7-7 7"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var Kd=class extends z{constructor(e){super(),W(this,e,sC,nC,j,{})}},Gd=Kd;function iC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function aC(n){let e,t,r=[{name:"check"},n[1],{iconNode:n[0]}],o={$$slots:{default:[iC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function lC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M20 6 9 17l-5-5"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var Jd=class extends z{constructor(e){super(),W(this,e,lC,aC,j,{})}},na=Jd;function cC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function uC(n){let e,t,r=[{name:"chevron-left"},n[1],{iconNode:n[0]}],o={$$slots:{default:[cC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function fC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"m15 18-6-6 6-6"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var Yd=class extends z{constructor(e){super(),W(this,e,fC,uC,j,{})}},Qd=Yd;function dC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function pC(n){let e,t,r=[{name:"chevron-right"},n[1],{iconNode:n[0]}],o={$$slots:{default:[dC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function mC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"m9 18 6-6-6-6"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var Zd=class extends z{constructor(e){super(),W(this,e,mC,pC,j,{})}},Xd=Zd;function hC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function gC(n){let e,t,r=[{name:"circle-alert"},n[1],{iconNode:n[0]}],o={$$slots:{default:[hC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function yC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var ep=class extends z{constructor(e){super(),W(this,e,yC,gC,j,{})}},tp=ep;function bC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function vC(n){let e,t,r=[{name:"circle-check-big"},n[1],{iconNode:n[0]}],o={$$slots:{default:[bC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function xC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}],["path",{d:"m9 11 3 3L22 4"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var rp=class extends z{constructor(e){super(),W(this,e,xC,vC,j,{})}},op=rp;function wC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function _C(n){let e,t,r=[{name:"circle-help"},n[1],{iconNode:n[0]}],o={$$slots:{default:[wC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function SC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}],["path",{d:"M12 17h.01"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var np=class extends z{constructor(e){super(),W(this,e,SC,_C,j,{})}},sa=np;function kC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function IC(n){let e,t,r=[{name:"download"},n[1],{iconNode:n[0]}],o={$$slots:{default:[kC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function CC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["polyline",{points:"7 10 12 15 17 10"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var sp=class extends z{constructor(e){super(),W(this,e,CC,IC,j,{})}},uc=sp;function LC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function MC(n){let e,t,r=[{name:"folder-lock"},n[1],{iconNode:n[0]}],o={$$slots:{default:[LC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function TC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var ip=class extends z{constructor(e){super(),W(this,e,TC,MC,j,{})}},Jn=ip;function AC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function FC(n){let e,t,r=[{name:"folder-open"},n[1],{iconNode:n[0]}],o={$$slots:{default:[AC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function EC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var ap=class extends z{constructor(e){super(),W(this,e,EC,FC,j,{})}},lp=ap;function PC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function DC(n){let e,t,r=[{name:"folder"},n[1],{iconNode:n[0]}],o={$$slots:{default:[PC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function RC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var cp=class extends z{constructor(e){super(),W(this,e,RC,DC,j,{})}},Io=cp;function UC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function OC(n){let e,t,r=[{name:"home"},n[1],{iconNode:n[0]}],o={$$slots:{default:[UC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function $C(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}],["polyline",{points:"9 22 9 12 15 12 15 22"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var up=class extends z{constructor(e){super(),W(this,e,$C,OC,j,{})}},fp=up;function NC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function BC(n){let e,t,r=[{name:"info"},n[1],{iconNode:n[0]}],o={$$slots:{default:[NC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function VC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 16v-4"}],["path",{d:"M12 8h.01"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var dp=class extends z{constructor(e){super(),W(this,e,VC,BC,j,{})}},pp=dp;function HC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function qC(n){let e,t,r=[{name:"layers"},n[1],{iconNode:n[0]}],o={$$slots:{default:[HC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function jC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var mp=class extends z{constructor(e){super(),W(this,e,jC,qC,j,{})}},lo=mp;function zC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function WC(n){let e,t,r=[{name:"lock"},n[1],{iconNode:n[0]}],o={$$slots:{default:[zC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function KC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var hp=class extends z{constructor(e){super(),W(this,e,KC,WC,j,{})}},gp=hp;function GC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function JC(n){let e,t,r=[{name:"message-square-heart"},n[1],{iconNode:n[0]}],o={$$slots:{default:[GC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function YC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var yp=class extends z{constructor(e){super(),W(this,e,YC,JC,j,{})}},bp=yp;function QC(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function ZC(n){let e,t,r=[{name:"satellite"},n[1],{iconNode:n[0]}],o={$$slots:{default:[QC]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function XC(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M13 7 9 3 5 7l4 4"}],["path",{d:"m17 11 4 4-4 4-4-4"}],["path",{d:"m8 12 4 4 6-6-4-4Z"}],["path",{d:"m16 8 3-3"}],["path",{d:"M9 21a6 6 0 0 0-6-6"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var vp=class extends z{constructor(e){super(),W(this,e,XC,ZC,j,{})}},Yo=vp;function eL(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function tL(n){let e,t,r=[{name:"settings"},n[1],{iconNode:n[0]}],o={$$slots:{default:[eL]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function rL(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}],["circle",{cx:"12",cy:"12",r:"3"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var xp=class extends z{constructor(e){super(),W(this,e,rL,tL,j,{})}},wp=xp;function oL(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function nL(n){let e,t,r=[{name:"square-pen"},n[1],{iconNode:n[0]}],o={$$slots:{default:[oL]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function sL(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var _p=class extends z{constructor(e){super(),W(this,e,sL,nL,j,{})}},ia=_p;function iL(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function aL(n){let e,t,r=[{name:"triangle-alert"},n[1],{iconNode:n[0]}],o={$$slots:{default:[iL]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function lL(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var Sp=class extends z{constructor(e){super(),W(this,e,lL,aL,j,{})}},kp=Sp;function cL(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function uL(n){let e,t,r=[{name:"user-round-x"},n[1],{iconNode:n[0]}],o={$$slots:{default:[cL]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function fL(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M2 21a8 8 0 0 1 11.873-7"}],["circle",{cx:"10",cy:"8",r:"5"}],["path",{d:"m17 17 5 5"}],["path",{d:"m22 17-5 5"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var Ip=class extends z{constructor(e){super(),W(this,e,fL,uL,j,{})}},Cp=Ip;function dL(n){let e,t=n[2].default,r=ye(t,n,n[3],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&8)&&ve(r,t,o,o[3],e?be(t,o[3],s,null):xe(o[3]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function pL(n){let e,t,r=[{name:"x"},n[1],{iconNode:n[0]}],o={$$slots:{default:[dL]},$$scope:{ctx:n}};for(let s=0;s<r.length;s+=1)o=le(o,r[s]);return e=new Ve({props:o}),{c(){P(e.$$.fragment)},m(s,i){A(e,s,i),t=!0},p(s,[i]){let a=i&3?$e(r,[r[0],i&2&&Be(s[1]),i&1&&{iconNode:s[0]}]):{};i&8&&(a.$$scope={dirty:i,ctx:s}),e.$set(a)},i(s){t||(v(e.$$.fragment,s),t=!0)},o(s){k(e.$$.fragment,s),t=!1},d(s){F(e,s)}}}function mL(n,e,t){let{$$slots:r={},$$scope:o}=e,s=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];return n.$$set=i=>{t(1,e=le(le({},e),ke(i))),"$$scope"in i&&t(3,o=i.$$scope)},e=ke(e),[s,e,r,o]}var Lp=class extends z{constructor(e){super(),W(this,e,mL,pL,j,{})}},Xs=Lp;function hL(n){we(n,"svelte-cpi6rl","button.notebook.svelte-cpi6rl{color:var(--color-base-40);background-color:transparent}button.notebook-synced.svelte-cpi6rl{color:var(--color-accent)}button.system3-connected.svelte-cpi6rl{color:var(--color-accent)}button.system3-disconnected.svelte-cpi6rl{color:var(--color-base-40)}")}function gL(n){let e,t,r,o,s,i,a,l;return t=new lo({props:{class:"svg-icon inline-icon"}}),{c(){var c;e=x("button"),P(t.$$.fragment),h(e,"class",r="clickable-icon view-action system3-view-action "+(n[0].tracking?"notebook-synced":"notebook")+" svelte-cpi6rl"),h(e,"aria-label",o=n[0].tracking?"Tracking changes: local file and update log are in sync":"Not tracking changes: local file and update log are not in sync -- click to check"),h(e,"tabindex","0"),h(e,"data-filename",s=(c=n[0].view.file)==null?void 0:c.name)},m(c,u){_(c,e,u),A(t,e,null),i=!0,a||(l=[$(e,"click",n[6]),$(e,"keypress",n[7])],a=!0)},p(c,u){var f;(!i||u&1&&r!==(r="clickable-icon view-action system3-view-action "+(c[0].tracking?"notebook-synced":"notebook")+" svelte-cpi6rl"))&&h(e,"class",r),(!i||u&1&&o!==(o=c[0].tracking?"Tracking changes: local file and update log are in sync":"Not tracking changes: local file and update log are not in sync -- click to check"))&&h(e,"aria-label",o),(!i||u&1&&s!==(s=(f=c[0].view.file)==null?void 0:f.name))&&h(e,"data-filename",s)},i(c){i||(v(t.$$.fragment,c),i=!0)},o(c){k(t.$$.fragment,c),i=!1},d(c){c&&w(e),F(t),a=!1,me(l)}}}function yL(n){let e,t,r,o,s,i,a,l,c,u,f,d,p;return t=new lo({props:{class:"svg-icon inline-icon"}}),l=new Yo({props:{class:"svg-icon inline-icon"}}),{c(){var m;e=x("button"),P(t.$$.fragment),i=T(),a=x("button"),P(l.$$.fragment),h(e,"class",r="clickable-icon view-action system3-view-action "+(n[0].tracking?"notebook-synced":"notebook")+" svelte-cpi6rl"),h(e,"aria-label",o=n[0].tracking?"Tracking changes: local file and update log are in sync":"Not tracking changes: local file and update log are not in sync -- click to check"),h(e,"tabindex","0"),h(e,"data-filename",s=(m=n[0].view.file)==null?void 0:m.name),h(a,"class",c="system3-"+n[1].status+" clickable-icon view-action system3-view-action svelte-cpi6rl"),h(a,"aria-label",u=`${n[2].relay.name} (${n[1].status})`),h(a,"tabindex","0")},m(m,y){_(m,e,y),A(t,e,null),_(m,i,y),_(m,a,y),A(l,a,null),f=!0,d||(p=[$(e,"click",n[6]),$(e,"keypress",n[7]),$(a,"click",n[4]),$(a,"keypress",n[5])],d=!0)},p(m,y){var g;(!f||y&1&&r!==(r="clickable-icon view-action system3-view-action "+(m[0].tracking?"notebook-synced":"notebook")+" svelte-cpi6rl"))&&h(e,"class",r),(!f||y&1&&o!==(o=m[0].tracking?"Tracking changes: local file and update log are in sync":"Not tracking changes: local file and update log are not in sync -- click to check"))&&h(e,"aria-label",o),(!f||y&1&&s!==(s=(g=m[0].view.file)==null?void 0:g.name))&&h(e,"data-filename",s),(!f||y&2&&c!==(c="system3-"+m[1].status+" clickable-icon view-action system3-view-action svelte-cpi6rl"))&&h(a,"class",c),(!f||y&6&&u!==(u=`${m[2].relay.name} (${m[1].status})`))&&h(a,"aria-label",u)},i(m){f||(v(t.$$.fragment,m),v(l.$$.fragment,m),f=!0)},o(m){k(t.$$.fragment,m),k(l.$$.fragment,m),f=!1},d(m){m&&(w(e),w(i),w(a)),F(t),F(l),d=!1,me(p)}}}function bL(n){let e,t,r,o,s;return t=new Cp({props:{class:"svg-icon inline-icon"}}),{c(){e=x("button"),P(t.$$.fragment),h(e,"class","clickable-icon view-action system3-view-action mod-warning"),h(e,"aria-label","Login to enable Live edits"),h(e,"tabindex","0")},m(i,a){_(i,e,a),A(t,e,null),r=!0,o||(s=[$(e,"click",n[4]),$(e,"keypress",n[5])],o=!0)},p:B,i(i){r||(v(t.$$.fragment,i),r=!0)},o(i){k(t.$$.fragment,i),r=!1},d(i){i&&w(e),F(t),o=!1,me(s)}}}function vL(n){let e,t,r,o,s=[bL,yL,gL],i=[];function a(l,c){return l[3]?0:l[2]?1:2}return e=a(n,-1),t=i[e]=s[e](n),{c(){t.c(),r=ue()},m(l,c){i[e].m(l,c),_(l,r,c),o=!0},p(l,[c]){let u=e;e=a(l,c),e===u?i[e].p(l,c):(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),t=i[e],t?t.p(l,c):(t=i[e]=s[e](l),t.c()),v(t,1),t.m(r.parentNode,r))},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),i[e].d(l)}}}function xL(n,e,t){let{view:r}=e,{state:o}=e,{remote:s}=e,{isLoggedOut:i=!1}=e,{onLogin:a=void 0}=e,l={connected:"connected: click to go offline",connecting:"connecting...",disconnected:"disconnected: click to go online",unknown:"unknown status"},c=()=>{i&&a?a():r.toggleConnection()},u=p=>{p.key==="Enter"&&c()},f=()=>Ce(void 0,void 0,void 0,function*(){let p=yield r.document.diskBuffer();r.connectionManager.openDiffView({file1:r.document,file2:p,showMergeOption:!0,onResolve:()=>Ce(void 0,void 0,void 0,function*(){r.document.clearDiskBuffer(),yield r.syncViewToCRDT()})})}),d=p=>{p.key==="Enter"&&f()};return n.$$set=p=>{"view"in p&&t(0,r=p.view),"state"in p&&t(1,o=p.state),"remote"in p&&t(2,s=p.remote),"isLoggedOut"in p&&t(3,i=p.isLoggedOut),"onLogin"in p&&t(8,a=p.onLogin)},[r,o,s,i,c,u,f,d,a]}var Mp=class extends z{constructor(e){super(),W(this,e,xL,vL,j,{view:0,state:1,remote:2,isLoggedOut:3,onLogin:8},hL)}},Tp=Mp;var Rb=require("obsidian");var Ap=class{constructor(e,t,r=1e4){this.timeProvider=e;this.onOnline=[];this.onOffline=[];this.online=!0;this._log=Te("[NetworkStatus]"),this.url=t,this.interval=r,this._onceOnline=new Set}log(e,...t){this._log(e,...t)}start(){this.timer||(this.timer=this.checkStatusRepeatedly())}stop(){this.timer&&clearInterval(this.timer)}checkStatusRepeatedly(){return this.timeProvider.setInterval(this._checkStatus.bind(this),this.interval)}checkStatus(){return this.online?Promise.resolve(!0):new Promise(e=>{this._checkStatus().then(()=>{e(this.online)})})}async _checkStatus(){return(0,Rb.requestUrl)({url:this.url,method:"GET",headers:{"Relay-Version":"0.7.4"}}).then(e=>{if(e.status===200){if(e.json&&e.json.status&&(this.status=e.json),!this.online){this.log("back online"),this.online=!0,this.onOnline.forEach(t=>t(this.status)),this._onceOnline.forEach(t=>t(this.status)),this._onceOnline.clear();return}}else if(e.status!==200&&this.online)throw new Error("disconnected")}).catch(e=>{var t;if(e.message.includes("ERR_NETWORK_CHANGED")){this._checkStatus();return}this.online=!1,(t=this.onOffline)==null||t.forEach(r=>r(this.status))})}onceOnline(e){this._onceOnline.add(e)}addEventListener(e,t){e==="online"?this.onOnline.push(t):e==="offline"&&this.onOffline.push(t)}destroy(){this._onceOnline.clear(),this._onceOnline=null,this.onOnline=null,this.onOffline=null,this.timeProvider=null}},Ub=Ap;var m7=require("obsidian"),Yn=class{constructor(e,t,r){this.view=e,this.text=t,this.onClick=r,this.display()}display(){if(!this.view)return!0;let e=this.view.containerEl,t=this.view.containerEl.querySelector(".view-content");if(!e)return;let r=e.querySelector(".system3-banner-box");r||(r=document.createElement("div"),r.classList.add("system3-banner-box"),e.insertBefore(r,t));let o=e.querySelector(".system3-banner");if(!o){o=document.createElement("div"),o.classList.add("system3-banner");let s=o.createSpan();s.setText(this.text),o.appendChild(s),r.appendChild(o);let i=async()=>{await this.onClick()&&this.destroy()};o.addEventListener("click",i)}return!0}destroy(){let e=this.view.containerEl;if(!e)return;let t=e.querySelector(".system3-banner-box");return t&&t.replaceChildren(),this.onClick=async()=>!0,!0}};var gc=require("@codemirror/state"),Nb=require("@codemirror/view");function Ob(n,e){let t=Object.keys(e).map(r=>wL(n,r,e[r]));return t.length===1?t[0]:function(){t.forEach(r=>r())}}function wL(n,e,t){let r=n[e],o=n.hasOwnProperty(e),s=o?r:function(){return Object.getPrototypeOf(n)[e].apply(this,arguments)},i=t(s);return r&&Object.setPrototypeOf(i,r),Object.setPrototypeOf(a,i),n[e]=a,l;function a(...c){return i===s&&n[e]===a&&l(),i.apply(this,c)}function l(){n[e]===a&&(o?n[e]=s:delete n[e]),i!==s&&(i=s,Object.setPrototypeOf(a,r||Function))}}var Co=class Co extends Ze{constructor(){super("Patcher");this.unsubscribes=[];this.patchedMethods=new WeakMap;typeof window!="undefined"&&(window.relayPatches&&window.relayPatches.length>0&&console.warn(`Found ${window.relayPatches.length} existing unsubscribers on window.relayPatches at startup - possible memory leak or incomplete cleanup`),window.relayPatches=[])}static getInstance(){return Co.instance||(Co.instance=new Co),Co.instance}patch(t,r){var u,f;let o=this.patchedMethods.get(t)||new Set,s=Object.keys(r),i=s.filter(d=>o.has(d));if(i.length>0){this.warn(`Methods [${i.join(", ")}] already patched on ${(u=t.constructor)==null?void 0:u.name}, skipping duplicates`);let d={};if(s.filter(p=>!i.includes(p)).forEach(p=>d[p]=r[p]),Object.keys(d).length===0)return this.debug("All methods conflicted, returning no-op unsubscriber"),()=>{};r=d}let a=new Set([...o,...Object.keys(r)]);this.patchedMethods.set(t,a);let l=Ob(t,r);return this.unsubscribes.push(l),typeof window!="undefined"&&window.relayPatches&&window.relayPatches.push(l),this.debug("Applied monkeypatch",{target:(f=t.constructor)==null?void 0:f.name,methods:Object.keys(r),patchCount:this.unsubscribes.length}),()=>{Object.keys(r).forEach(p=>a.delete(p)),a.size===0&&this.patchedMethods.delete(t);let d=this.unsubscribes.indexOf(l);if(d>=0&&this.unsubscribes.splice(d,1),typeof window!="undefined"&&window.relayPatches){let p=window.relayPatches.indexOf(l);p>=0&&window.relayPatches.splice(p,1)}l()}}getCount(){return this.unsubscribes.length}cleanup(){let t=this.unsubscribes.length;this.debug("Starting cleanup of monkeypatches",{count:t}),this.unsubscribes.forEach((r,o)=>{try{r(),this.debug("Cleaned up monkeypatch",{index:o+1,total:t})}catch(s){this.error("Error during monkeypatch cleanup",{index:o+1,error:s})}}),this.unsubscribes.length=0,typeof window!="undefined"&&window.relayPatches&&(window.relayPatches.length=0),this.log("Completed cleanup of monkeypatches",{cleanedCount:t})}static destroy(){Co.instance&&(Co.instance.cleanup(),Co.instance=null),typeof window!="undefined"&&window.relayPatches&&(window.relayPatches.length=0)}hasRegisteredPatches(){return this.unsubscribes.length>0}};Co.instance=null;var aa=Co,yr=()=>aa.getInstance();var Bb=Do(Rl());var Vb=require("obsidian");var fc=class{constructor(e,t,r,o){this.containerEl=e;this.before=t;this.text=r,this.onClick=o,this.display()}display(){if(!this.containerEl||!this.before)return!0;let e=this.containerEl,t=this.before;if(!e)return;let r=e.querySelector(".system3-banner-box");r||(r=document.createElement("div"),r.classList.add("system3-banner-box"),e.insertBefore(r,t));let o=e.querySelector(".system3-banner");if(!o){o=document.createElement("div"),o.classList.add("system3-banner");let s=o.createSpan();s.setText(this.text),o.appendChild(s),r.appendChild(o);let i=async()=>{await this.onClick()&&this.destroy()};o.addEventListener("click",i)}return!0}destroy(){let e=this.containerEl;if(!e)return;let t=e.querySelector(".system3-banner-box");return t&&t.replaceChildren(),!0}};var _j=require("obsidian");var cj=require("obsidian");var dc=class extends Ze{constructor(t){var r;super();this.destroyed=!1;this.view=t,this.setLoggers(`[PreviewRenderer][${(r=t.file)==null?void 0:r.path}]`),this.debug("created")}render(t,r){var o,s;if(this.destroyed){this.debug("Skipping render - renderer destroyed");return}if(!He().enablePreviewViewHooks){this.debug("Preview view hooks disabled via flags");return}if(r!=="preview"){this.debug("Skipping render - not in preview mode");return}try{this.debug("Rendering preview from document"),this.view.text=t.text,this.view.previewMode.renderer.set(t.text),(s=(o=this.view).onInternalDataChange)==null||s.call(o),this.debug("Preview render completed")}catch(i){this.error("Error rendering preview:",i)}}destroy(){this.destroyed=!0,this.debug("destroyed"),this.view=null}};var $b=Do(Rl());var mc=require("obsidian");var pc=class extends Ze{constructor(t){var r;super();this.destroyed=!1;this.view=t,this.setLoggers(`[MetadataRenderer][${(r=t.file)==null?void 0:r.path}]`),this.debug("created")}render(t,r){if(this.destroyed){this.debug("Skipping render - renderer destroyed");return}if(!He().enableMetadataViewHooks){this.debug("Metadata view hooks disabled via flags");return}try{this.debug("Rendering metadata from document");let o=this.view.metadataEditor;if(!o){this.debug("No metadata editor available");return}let i=(0,mc.getFrontMatterInfo)(t.text).frontmatter;if(i){o.synchronize((0,mc.parseYaml)(i));for(let a of o.rendered)a.renderProperty(a.entry,!0)}else this.debug("No frontmatter found in document")}catch(o){this.error("Error rendering metadata:",o)}}destroy(){this.destroyed=!0,this.debug("destroyed"),this.view=null}};var kn=class extends Ze{constructor(t,r){super();this.unsubscribes=[];this.destroyed=!1;this.saving=!1;this.view=t,this.document=r,this.setLoggers(`[ViewHookPlugin][${r.path}]`),this.debug("created"),this.renderers=[],this.renderers.push(new dc(t)),this.renderers.push(new pc(t)),this._ytext=this.document.ytext,this.installMarkdownHooks(this.view),this.setupDocumentObserver(),this.renderAll()}installMarkdownHooks(t){let r=this;He().enableMetadataViewHooks&&this.unsubscribes.push(yr().patch(t,{saveFrontmatter(o){return function(s){r.debug("saveFrontmatter hook triggered"),r.saving=!0;let i=o.call(this,s);return r.saving=!1,i}}})),this.unsubscribes.push(yr().patch(t,{save(o){return function(s){var a,l;let i=o.call(this,s);try{((l=(a=r.view).getMode)==null?void 0:l.call(a))==="preview"&&r.saving&&(r.debug("Syncing metadata changes to CRDT during save"),no(r.document.ydoc,r.view.text,r.document))}catch(c){r.error("Error syncing during save:",c)}return i}}})),He().enablePreviewViewHooks&&this.unsubscribes.push(yr().patch(t.previewMode,{edit(o){return function(s){var i,a;if(r.debug("Preview edit hook triggered"),((a=(i=r.view).getMode)==null?void 0:a.call(i))==="preview"){if(r.view.editor){let l=r.incrementalBufferChange(s);r.view.editor.cm.dispatch({changes:l}),r.debug("Dispatched preview edit to CodeMirror")}else no(r.document.ydoc,s,r.document),r.debug("Synced preview edit directly to CRDT");return}return o.call(this,s)}}}))}setupDocumentObserver(){this.observer=async(t,r)=>{if(!this.active()){this.debug("Received yjs event against a non-active view");return}if(this.destroyed){this.debug("Received yjs event but plugin was destroyed");return}this.debug("Document changed, updating all renderers"),this.renderAll()},this._ytext.observe(this.observer)}active(){return!this.destroyed&&!!this.view}renderAll(){var r,o,s,i;let t=((o=(r=this.view).getMode)==null?void 0:o.call(r))||((i=(s=this.view).getViewType)==null?void 0:i.call(s))||"unknown";this.debug(`Rendering all components for mode: ${t}`),this.renderers.forEach(a=>{try{a.render(this.document,t)}catch(l){this.error("Error in renderer:",l)}})}incrementalBufferChange(t){let r=this.view.editor.cm.state.doc.toString(),o=new $b.default,s=o.diff_main(r,t);o.diff_cleanupSemantic(s);let i=[],a=0;for(let[l,c]of s)switch(l){case 0:a+=c.length;break;case 1:i.push({from:a,to:a,insert:c}),a+=c.length;break;case-1:i.push({from:a,to:a+c.length,insert:""});break}return i}async initialize(){await this.document.whenReady(),this.view.previewMode.renderer.set(this.document.text),this.renderAll(),this.document.connect(),this.debug("ViewHookPlugin initialized")}destroy(){var t;this.destroyed=!0,this.debug("destroyed"),this.observer&&((t=this._ytext)==null||t.unobserve(this.observer)),this.unsubscribes.forEach(r=>r()),this.unsubscribes.length=0,this.renderers.forEach(r=>r.destroy()),this.renderers.length=0,this._ytext=null,this.view=null,this.document=null}};var _L=25,Xj=gc.Facet.define({combine(n){return n[n.length-1]}}),hc=gc.Annotation.define(),Fp=class{constructor(e){this.initialSet=!1;this.destroyed=!1;this.keyFrameCounter=0;this.debug=(...e)=>{};this.log=(...e)=>{};this.warn=(...e)=>{};this.error=(...e)=>{};this.embed=!1;var a,l,c;this.unsubscribes=[],this.editor=e,this.sourceView=this.editor.dom.closest(".markdown-source-view"),this.connectionManager=this.editor.state.field(Lo);let t=this.editor.dom.closest(".relay-live-editor"),o=(a=this.sourceView)==null?void 0:a.classList.contains("mod-inside-iframe");if(!t&&!o){this.destroyed=!0;return}if(this.view=(l=this.connectionManager)==null?void 0:l.findView(this.editor),this.document=this.getDocument(),!this.document){this.destroyed=!0;return}this.view?this.viewHookPlugin=new kn(this.view.view,this.document):this.embed=!0,this.log=Te(`[LiveCMPluginValue][${this.document.path}]`,"log"),this.warn=Te(`[LiveCMPluginValue][${this.document.path}]`,"warn"),this.error=Te(`[LiveCMPluginValue][${this.document.path}]`,"error"),this.debug=Te(`[LiveCMPluginValue][${this.document.path}]`,"debug"),this.debug("created");let s=this,i=!1;(c=this.view)!=null&&c.view?this.unsubscribes.push(yr().patch(this.view.view,{setViewData(u){return function(f,d){if(d)jr(s.view)&&s.view.document.text===f&&(s.view.tracking=!0),s.resync();else if(i){let p=s.incrementalBufferChange(f);e.dispatch({changes:p});return}return u.call(this,f,d)}},saveFrontmatter(u){return function(f){i=!0;let d=u.call(this,f);return i=!1,d}},requestSave(u){return function(){let f=u.call(this);try{this.app.metadataCache.trigger("resolve",this.file)}catch(d){}return f}}})):this.document.connect(),this.document.connected?this.resync():this.document.onceConnected().then(()=>{this.resync()}),this.viewHookPlugin&&this.viewHookPlugin.initialize().catch(u=>{this.error("Error initializing ViewHookPlugin:",u)}),this._observer=async(u,f)=>{if(this.document=this.getDocument(),!this.active(this.view)){this.debug("Recived yjs event against a non-live view");return}if(this.destroyed){this.debug("Recived yjs event but editor was destroyed");return}if(f.origin!==this){let d=u.delta,p=[],m=0;for(let y=0;y<d.length;y++){let g=d[y];g.insert!=null?p.push({from:m,to:m,insert:g.insert}):g.delete!=null?(p.push({from:m,to:m+g.delete,insert:""}),m+=g.delete):g.retain!=null&&(m+=g.retain)}jr(this.view)&&!this.view.tracking||He().enableEditorTweens&&this.keyFrameCounter>_L?(this.keyFrameCounter=0,p=await this.getKeyFrame(!0),this.debug("dispatch (full)")):(this.keyFrameCounter+=1,this.debug(`dispatch (incremental + ${this.keyFrameCounter})`)),this.active(this.view)&&(e.dispatch({changes:p,annotations:[hc.of(this.editor)]}),jr(this.view)&&(this.view.tracking=!0))}},this.observer=(u,f)=>{var d;try{(d=this._observer)==null||d.call(this,u,f)}catch(p){p instanceof RangeError&&jr(this.view)&&(this.view.tracking=!1)}},this._ytext=this.document.ytext,this._ytext.observe(this.observer)}getDocument(){var r,o,s;let t=this.editor.state.field(Vb.editorInfoField).file;if(t){if(((r=this.document)==null?void 0:r._tfile)===t)return this.document;let i=(o=this.connectionManager)==null?void 0:o.sharedFolders.lookup(t.path);if(i)return this.document=i.proxy.getDoc(t.path),this.document}if(this.view=(s=this.connectionManager)==null?void 0:s.findView(this.editor),this.view&&this.view.document instanceof Mt)return this.view.document}active(e){return jr(e)||this.embed&&this.document}mergeBanner(){return this.destroyed||!this.editor?()=>{}:(this.banner=new fc(this.sourceView,this.editor.dom,"Merge conflict -- click to resolve",async()=>{var r;if(!this.document)return!0;let e=await this.document.diskBuffer();return await this.document.checkStale()&&((r=this.connectionManager)==null||r.openDiffView({file1:this.document,file2:e,showMergeOption:!0,onResolve:async()=>{this.destroyed||!this.editor||!this.document||(this.document.clearDiskBuffer(),this.resync())}})),!0}),()=>{})}incrementalBufferChange(e){let t=this.editor.state.doc.toString(),r=new Bb.default,o=r.diff_main(t,e);r.diff_cleanupSemantic(o);let s=[],i=0;for(let[a,l]of o)switch(a){case 0:i+=l.length;break;case 1:s.push({from:i,to:i,insert:l}),i+=l.length;break;case-1:s.push({from:i,to:i+l.length,insert:""});break}return s}getBufferChange(e,t=!1){return t?this.incrementalBufferChange(e):[{from:0,to:this.editor.state.doc.length,insert:e}]}async resync(){if(jr(this.view)&&!this.view.tracking&&!this.destroyed){await this.view.document.whenSynced();let e=await this.getKeyFrame();jr(this.view)&&!this.view.tracking&&!this.destroyed&&this.editor.dispatch({changes:e,annotations:[hc.of(this.editor)]})}else if(this.active(this.view)&&this.document){await this.document.whenSynced();let e=await this.getKeyFrame();this.active(this.view)&&!this.destroyed&&this.editor.dispatch({changes:e,annotations:[hc.of(this.editor)]})}}async getKeyFrame(e=!1){var t,r;return!this.active(this.view)||this.destroyed?[]:((t=this.document)==null?void 0:t.text)===this.editor.state.doc.toString()?(jr(this.view)&&(this.view.tracking=!0),[]):(He().enableDeltaLogging&&this.warn(`|${(r=this.document)==null?void 0:r.text}|
|
|
|${this.editor.state.doc.toString()}|`),this.document?(this.warn("ytext and editor buffer need syncing"),!this.document.hasLocalDB()&&this.document.text===""?(this.warn("local db missing, not setting buffer"),[]):(jr(this.view)&&!this.view.tracking?this.view.checkStale():this.document&&await this.document.checkStale()&&!this.destroyed&&this.editor&&this.mergeBanner(),this.active(this.view)&&!this.destroyed?[this.getBufferChange(this.document.text,e)]:[])):(this.warn("no document"),[]))}update(e){var r,o;if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(hc)===this.editor||this.destroyed)return;this.document=this.getDocument();let t=(r=this.document)==null?void 0:r.ytext;t&&((o=t.doc)==null||o.transact(()=>{let s=0;e.changes.iterChanges((i,a,l,c,u)=>{let f=u.sliceString(0,u.length,`
|
|
`);i!==a&&t.delete(i+s,a-i),f.length>0&&t.insert(i+s,f),s+=f.length-(a-i)})},this),this.embed&&this.document&&this.document.requestSave())}destroy(){var e,t;this.destroyed=!0,this.observer&&((e=this._ytext)==null||e.unobserve(this.observer)),this.unsubscribes.forEach(r=>{r()}),this.unsubscribes.length=0,(t=this.viewHookPlugin)==null||t.destroy(),this.connectionManager=null,this.view=void 0,this._ytext=void 0,this.editor=null}},Hb=Nb.ViewPlugin.fromClass(Fp);var yc=require("@codemirror/state"),br=require("@codemirror/view");var qb=require("obsidian");var jb=br.EditorView.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:"0px 2px 0px 4px"},".cm-ySelectionCaret":{position:"relative",borderLeft:"1px solid black",borderRight:"1px solid black",marginLeft:"-1px",marginRight:"-1px",boxSizing:"border-box",display:"inline"},".cm-ySelectionCaretDot":{borderRadius:"50%",position:"absolute",width:".4em",height:".4em",top:"-.2em",left:"-.2em",backgroundColor:"inherit",transition:"transform .3s ease-in-out",boxSizing:"border-box"},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:"bottom center",transform:"scale(0)"},".cm-ySelectionInfo":{position:"absolute",top:"-1.05em",left:"-1px",fontSize:".75em",fontFamily:"serif",fontStyle:"normal",fontWeight:"normal",lineHeight:"normal",userSelect:"none",color:"white",paddingLeft:"2px",paddingRight:"2px",zIndex:101,transition:"opacity .3s ease-in-out",backgroundColor:"inherit",opacity:0,transitionDelay:"0s",whiteSpace:"nowrap"},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:"0s"}}),SL=yc.Annotation.define(),Ep=class extends br.WidgetType{constructor(e,t){super(),this.color=e,this.name=t}toDOM(e){return bi("span",[or("class","cm-ySelectionCaret"),or("style",`background-color: ${this.color}; border-color: ${this.color}`)],[xs("\u2060"),bi("div",[or("class","cm-ySelectionCaretDot")]),xs("\u2060"),bi("div",[or("class","cm-ySelectionInfo")],[xs(this.name)]),xs("\u2060")])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},Pp=class{constructor(e){this.destroyed=!1;var i,a;this.editor=e,this.decorations=yc.RangeSet.of([]),this.connectionManager=this.editor.state.field(Lo);let t=this.editor.dom.closest(".markdown-source-view"),r=this.editor.dom.closest(".relay-live-editor"),s=t==null?void 0:t.classList.contains("mod-inside-iframe");if(!r&&!s){this.destroyed=!0;return}if(this.view=(i=this.connectionManager)==null?void 0:i.findView(e),this.view&&this.view instanceof In){let l=(a=this.view.document)==null?void 0:a._provider;this._listener=({added:c,updated:u,removed:f},d,p)=>{c.concat(u).concat(f).findIndex(y=>{var g;return y!==((g=this._awareness)==null?void 0:g.doc.clientID)})>=0&&e.dispatch({annotations:[SL.of([])]})},l&&(this._awareness=l.awareness,this._awareness.on("change",this._listener))}}getDocument(){var r,o,s,i;let t=this.editor.state.field(qb.editorInfoField).file;if(t){if(((r=this.document)==null?void 0:r._tfile)===t)return this.document;let a=(o=this.connectionManager)==null?void 0:o.sharedFolders.lookup(t.path);if(a)return this.document=a.proxy.getDoc(t.path),this.document}return this.view=(s=this.connectionManager)==null?void 0:s.findView(this.editor),(i=this.view)==null?void 0:i.document}destroy(){var e;this.destroyed=!0,this._listener&&((e=this._awareness)==null||e.off("change",this._listener),this._listener=void 0),this.connectionManager=null,this.view=null,this.editor=null}update(e){var c;if(this.destroyed)return;let t=e.view;this.document=this.getDocument();let r=(c=this.document)==null?void 0:c.ytext;if(!(this.document&&r&&r.doc))return;let o=this.document._provider;if(!o)return;this._awareness=o.awareness;let s=this._awareness,i=r.doc,a=[],l=this._awareness.getLocalState();if(l!=null){let u=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),f=u?e.state.selection.main:null,d=l.cursor==null?null:af(l.cursor.anchor),p=l.cursor==null?null:af(l.cursor.head);if(f!=null){let m=lf(r,f.anchor),y=lf(r,f.head);(l.cursor==null||!uf(d,m)||!uf(p,y))&&s.setLocalStateField("cursor",{anchor:m,head:y})}else l.cursor!=null&&u&&s.setLocalStateField("cursor",null)}s.getStates().forEach((u,f)=>{if(f===s.doc.clientID)return;let d=u.cursor;if(d==null||d.anchor==null||d.head==null)return;let p=cf(d.anchor,i),m=cf(d.head,i);if(p==null||m==null||p.type!==r||m.type!==r)return;if(p.index>e.state.doc.length||m.index>e.state.doc.length){Te("[RemoteSelections]","warn")(`cursor positions (${p.index}, ${m.index}) out of range of document length: ${e.state.doc.length}`),this.decorations=br.Decoration.none;return}let{color:y="#30bced",name:g="Anonymous"}=u.user||{},I=u.user&&u.user.colorLight||y+"33",L=nn(p.index,m.index),C=Jr(p.index,m.index),S=e.view.state.doc.lineAt(L),M=e.view.state.doc.lineAt(C);if(S.number===M.number)a.push({from:L,to:C,value:br.Decoration.mark({attributes:{style:`background-color: ${I}`},class:"cm-ySelection"})});else{a.push({from:L,to:S.from+S.length,value:br.Decoration.mark({attributes:{style:`background-color: ${I}`},class:"cm-ySelection"})}),a.push({from:M.from,to:C,value:br.Decoration.mark({attributes:{style:`background-color: ${I}`},class:"cm-ySelection"})});for(let E=S.number+1;E<M.number;E++){let U=e.view.state.doc.line(E).from;a.push({from:U,to:U,value:br.Decoration.line({attributes:{style:`background-color: ${I}`,class:"cm-yLineSelection"}})})}}a.push({from:m.index,to:m.index,value:br.Decoration.widget({side:m.index-p.index>0?-1:1,block:!1,widget:new Ep(y,g)})})}),this.decorations=br.Decoration.set(a,!0)}},zb=br.ViewPlugin.fromClass(Pp,{decorations:n=>n.decorations});var bc=require("@codemirror/state"),Qo=require("@codemirror/view"),Wb=require("@codemirror/view"),mz=require("obsidian");var xz=bc.Annotation.define(),Rp=class extends Wb.WidgetType{toDOM(){let e=document.createElement("span");return e.style.display="inline-flex",e.addClass("invalid-link"),e.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-file-warning"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',e.title="This link points outside the shared folder and may not be accessible to other users.",e}},Dp=bc.StateEffect.define(),Up=class{constructor(e){this.log=e=>{};var t;if(this.editor=e,this.connectionManager=this.editor.state.field(Lo),this.decorations=Qo.Decoration.none,this.decorationAnchors=[],this.metadata=new Map,this.cb=(r,o)=>{this.updateFromMetadata(o),this.editor.dispatch({effects:Dp.of(null)})},!this.connectionManager){Te("[InvalidLinkPluginValue]","warn")("ConnectionManager not found in InvalidLinkPlugin");return}this.app=this.connectionManager.app,this.view=this.connectionManager.findView(e),this.view&&(this.log=Te(`[InvalidLinkPluginValue][${(t=this.view.view.file)==null?void 0:t.path}]`,"debug"),this.log("created"),this.view.document&&this.view.document.whenSynced().then(()=>{var o,s;let r=(s=(o=this.view)==null?void 0:o.document)==null?void 0:s.getTFile();if(this.connectionManager&&this.app&&r){this.connectionManager.onMeta(r,this.cb);let i=this.app.metadataCache.getFileCache(r);i&&(this.updateFromMetadata(i),this.editor.dispatch({effects:Dp.of(null)}))}else this.log("unable to subscribe to metadata updates")}))}findInternalLinks(e){let t=[];return e.state.facet(Qo.EditorView.decorations).forEach(o=>{(typeof o=="function"?o(e):o).between(0,e.state.doc.length,(i,a,l)=>{var f;(((f=l.spec)==null?void 0:f.class)||"").contains("cm-formatting-link-end")&&t.push({from:i,to:a})})}),t}updateFromMetadata(e){var r,o,s,i;if(this.connectionManager&&(this.view=this.connectionManager.findView(this.editor)),!this.view||!this.view.document||!this.app||!((o=(r=this.view)==null?void 0:r.document)!=null&&o.sharedFolder)||!((i=(s=this.view)==null?void 0:s.document)!=null&&i.tfile))return;let t=new Map;for(let a of(e==null?void 0:e.links)||[]){let l=this.app.metadataCache.getFirstLinkpathDest(a.link,this.view.document.path);l&&!this.view.document.sharedFolder.checkPath(l.path)&&t.set(a.position.start.offset,{from:a.position.start.offset,to:a.position.end.offset,link:a.link,original:a.original})}for(let a of(e==null?void 0:e.embeds)||[]){let l=this.app.metadataCache.getFirstLinkpathDest(a.link,this.view.document.path);l&&!this.view.document.sharedFolder.checkPath(l.path)&&t.set(a.position.start.offset,{from:a.position.start.offset,to:a.position.end.offset,link:a.link,original:a.original})}this.metadata=t}updateMetadataPositions(e){for(let[t,r]of this.metadata)try{this.metadata.set(t,{from:e.changes.mapPos(r.from),to:e.changes.mapPos(r.to),link:r.link,original:r.original})}catch(o){this.metadata.delete(t)}}updateFromEditor(e){var s,i,a,l;if(this.connectionManager&&(this.view=this.connectionManager.findView(this.editor)),!this.view||!this.view.document||!this.app||!((i=(s=this.view)==null?void 0:s.document)!=null&&i.sharedFolder)||!((l=(a=this.view)==null?void 0:a.document)!=null&&l.tfile))return;let t=[],r=new Map(this.metadata),o=this.findInternalLinks(this.editor);for(let c of o){let u=null;for(let[p,m]of r)if(c.from<=m.to&&c.to>=m.from){u=m,r.delete(p);break}if(!u)continue;let f=this.app.metadataCache.getFirstLinkpathDest(u.link,this.view.document.path);f&&!this.view.document.sharedFolder.checkPath(f.path)&&t.push(c.from)}t.filter(c=>c<=e.state.doc.length),this.decorationAnchors=t}updateDecorations(){this.decorationAnchors.sort();let e=this.decorationAnchors.map(t=>Qo.Decoration.widget({widget:new Rp,side:1}).range(t));e.length>0?this.decorations=Qo.Decoration.set(e,!0):this.decorations=Qo.Decoration.none}update(e){let t=!1;return e.transactions.forEach(r=>{r.effects.some(o=>o.is(Dp))&&(t=!0)}),(e.docChanged||e.viewportChanged||t)&&(t||this.updateMetadataPositions(e),this.updateFromEditor(e),this.updateDecorations()),this.decorations}destroy(){var e,t;this.connectionManager&&((t=(e=this.view)==null?void 0:e.document)!=null&&t.tfile)&&this.connectionManager.offMeta(this.view.document.tfile),this.connectionManager=null,this.view=void 0,this.metadata.clear(),this.metadata=null,this.editor=null}},Kb=Qo.ViewPlugin.fromClass(Up,{decorations:n=>n.decorations});function Zo(){}Zo.prototype={diff:function(e,t){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=o.callback;typeof o=="function"&&(s=o,o={}),this.options=o;var i=this;function a(S){return s?(setTimeout(function(){s(void 0,S)},0),!0):S}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var l=t.length,c=e.length,u=1,f=l+c;o.maxEditLength&&(f=Math.min(f,o.maxEditLength));var d=(r=o.timeout)!==null&&r!==void 0?r:1/0,p=Date.now()+d,m=[{oldPos:-1,lastComponent:void 0}],y=this.extractCommon(m[0],t,e,0);if(m[0].oldPos+1>=c&&y+1>=l)return a([{value:this.join(t),count:t.length}]);var g=-1/0,I=1/0;function L(){for(var S=Math.max(g,-u);S<=Math.min(I,u);S+=2){var M=void 0,E=m[S-1],U=m[S+1];E&&(m[S-1]=void 0);var K=!1;if(U){var R=U.oldPos-S;K=U&&0<=R&&R<l}var O=E&&E.oldPos+1<c;if(!K&&!O){m[S]=void 0;continue}if(!O||K&&E.oldPos+1<U.oldPos?M=i.addToPath(U,!0,void 0,0):M=i.addToPath(E,void 0,!0,1),y=i.extractCommon(M,t,e,S),M.oldPos+1>=c&&y+1>=l)return a(kL(i,M.lastComponent,t,e,i.useLongestToken));m[S]=M,M.oldPos+1>=c&&(I=Math.min(I,S-1)),y+1>=l&&(g=Math.max(g,S+1))}u++}if(s)(function S(){setTimeout(function(){if(u>f||Date.now()>p)return s();L()||S()},0)})();else for(;u<=f&&Date.now()<=p;){var C=L();if(C)return C}},addToPath:function(e,t,r,o){var s=e.lastComponent;return s&&s.added===t&&s.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:s.count+1,added:t,removed:r,previousComponent:s.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:r,previousComponent:s}}},extractCommon:function(e,t,r,o){for(var s=t.length,i=r.length,a=e.oldPos,l=a-o,c=0;l+1<s&&a+1<i&&this.equals(t[l+1],r[a+1]);)l++,a++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=a,l},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function kL(n,e,t,r,o){for(var s=[],i;e;)s.push(e),i=e.previousComponent,delete e.previousComponent,e=i;s.reverse();for(var a=0,l=s.length,c=0,u=0;a<l;a++){var f=s[a];if(f.removed){if(f.value=n.join(r.slice(u,u+f.count)),u+=f.count,a&&s[a-1].added){var p=s[a-1];s[a-1]=s[a],s[a]=p}}else{if(!f.added&&o){var d=t.slice(c,c+f.count);d=d.map(function(y,g){var I=r[u+g];return I.length>y.length?I:y}),f.value=n.join(d)}else f.value=n.join(t.slice(c,c+f.count));c+=f.count,f.added||(u+=f.count)}}var m=s[l-1];return l>1&&typeof m.value=="string"&&(m.added||m.removed)&&n.equals("",m.value)&&(s[l-2].value+=m.value,s.pop()),s}var _z=new Zo;function IL(n,e){if(typeof n=="function")e.callback=n;else if(n)for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e}var Gb=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Jb=/\S/,Vp=new Zo;Vp.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!Jb.test(n)&&!Jb.test(e)};Vp.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<e.length-1;t++)!e[t+1]&&e[t+2]&&Gb.test(e[t])&&Gb.test(e[t+2])&&(e[t]+=e[t+2],e.splice(t+1,2),t--);return e};function Yb(n,e,t){return t=IL(t,{ignoreWhitespace:!0}),Vp.diff(n,e,t)}var Hp=new Zo;Hp.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
|
|
`));var e=[],t=n.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var r=0;r<t.length;r++){var o=t[r];r%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};function CL(n,e,t){return Hp.diff(n,e,t)}var LL=new Zo;LL.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var ML=new Zo;ML.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function vc(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?vc=function(e){return typeof e}:vc=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vc(n)}function Op(n){return TL(n)||AL(n)||FL(n)||EL()}function TL(n){if(Array.isArray(n))return $p(n)}function AL(n){if(typeof Symbol!="undefined"&&Symbol.iterator in Object(n))return Array.from(n)}function FL(n,e){if(n){if(typeof n=="string")return $p(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return $p(n,e)}}function $p(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function EL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var PL=Object.prototype.toString,la=new Zo;la.useLongestToken=!0;la.tokenize=Hp.tokenize;la.castInput=function(n){var e=this.options,t=e.undefinedReplacement,r=e.stringifyReplacer,o=r===void 0?function(s,i){return typeof i=="undefined"?t:i}:r;return typeof n=="string"?n:JSON.stringify(Np(n,null,null,o),o," ")};la.equals=function(n,e){return Zo.prototype.equals.call(la,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function Np(n,e,t,r,o){e=e||[],t=t||[],r&&(n=r(o,n));var s;for(s=0;s<e.length;s+=1)if(e[s]===n)return t[s];var i;if(PL.call(n)==="[object Array]"){for(e.push(n),i=new Array(n.length),t.push(i),s=0;s<n.length;s+=1)i[s]=Np(n[s],e,t,r,o);return e.pop(),t.pop(),i}if(n&&n.toJSON&&(n=n.toJSON()),vc(n)==="object"&&n!==null){e.push(n),i={},t.push(i);var a=[],l;for(l in n)n.hasOwnProperty(l)&&a.push(l);for(a.sort(),s=0;s<a.length;s+=1)l=a[s],i[l]=Np(n[l],e,t,r,l);e.pop(),t.pop()}else i=n;return i}var Bp=new Zo;Bp.tokenize=function(n){return n.slice()};Bp.join=Bp.removeEmpty=function(n){return n};function Qb(n,e,t,r,o,s,i){i||(i={}),typeof i.context=="undefined"&&(i.context=4);var a=CL(t,r,i);if(!a)return;a.push({value:"",lines:[]});function l(I){return I.map(function(L){return" "+L})}for(var c=[],u=0,f=0,d=[],p=1,m=1,y=function(L){var C=a[L],S=C.lines||C.value.replace(/\n$/,"").split(`
|
|
`);if(C.lines=S,C.added||C.removed){var M;if(!u){var E=a[L-1];u=p,f=m,E&&(d=i.context>0?l(E.lines.slice(-i.context)):[],u-=d.length,f-=d.length)}(M=d).push.apply(M,Op(S.map(function(ce){return(C.added?"+":"-")+ce}))),C.added?m+=S.length:p+=S.length}else{if(u)if(S.length<=i.context*2&&L<a.length-2){var U;(U=d).push.apply(U,Op(l(S)))}else{var K,R=Math.min(S.length,i.context);(K=d).push.apply(K,Op(l(S.slice(0,R))));var O={oldStart:u,oldLines:p-u+R,newStart:f,newLines:m-f+R,lines:d};if(L>=a.length-2&&S.length<=i.context){var q=/\n$/.test(t),H=/\n$/.test(r),G=S.length==0&&d.length>O.oldLines;!q&&G&&t.length>0&&d.splice(O.oldLines,0,"\\ No newline at end of file"),(!q&&!G||!H)&&d.push("\\ No newline at end of file")}c.push(O),u=0,f=0,d=[]}p+=S.length,m+=S.length}},g=0;g<a.length;g++)y(g);return{oldFileName:n,newFileName:e,oldHeader:o,newHeader:s,hunks:c}}var Zb=require("obsidian");var xc=class{constructor(e){this.file1Start=e.file1Start,this.file2Start=e.file2Start,this.file1Lines=e.file1Lines,this.file2Lines=e.file2Lines}};var wc=class{constructor(e){this.file1Name=e.file1Name,this.file2Name=e.file2Name,this.differences=e.differences}static fromParsedDiff(e){let t=[];return e.hunks.forEach(r=>{let o=0,s=0;for(let i=0;i<r.lines.length;i+=1){let a=r.lines[i];if(a.startsWith("+")||a.startsWith("-")){let l=i,c=l;for(;c<r.lines.length-1&&(r.lines[c+1].startsWith("+")||r.lines[c+1].startsWith("-"));)c+=1;let u=r.lines.slice(l,c+1).filter(d=>d.startsWith("-")).map(d=>d.slice(1)),f=r.lines.slice(l,c+1).filter(d=>d.startsWith("+")).map(d=>d.slice(1));t.push(new xc({file1Start:r.oldStart+l-s-1,file2Start:r.newStart+l-o-1,file1Lines:u,file2Lines:f})),o+=u.length,s+=f.length,i+=c-l}}}),new this({file1Name:e.oldFileName,file2Name:e.newFileName,differences:t})}};function qp(n){let e=n.fullText.split(`
|
|
`);return e.splice(n.position,0,n.newLine),e.join(`
|
|
`)}function ca(n){let e=n.fullText.split(`
|
|
`);return n.newLine===""?e.splice(n.position,n.linesToReplace):e.splice(n.position,n.linesToReplace,n.newLine),e.join(`
|
|
`)}function ua(n){let e=n.fullText.split(`
|
|
`);return e.splice(n.position,n.count),e.join(`
|
|
`)}function ei(n){return n!==""?n:"\u200E"}var Fz=require("obsidian");var vr=class{constructor(e){this.text=e.text,this.onClick=e.onClick}build(e){e.createEl("a",{text:this.text,cls:"no-decoration text-xxs file-diff__action-line"}).onClickEvent(this.onClick)}};var Mo=class{static build(e){e.createEl("span",{text:"|",cls:"text-xxs file-diff__action-line"})}};var _c=class{constructor(e,t){this.app=e;this.difference=t.difference,this.file1=t.file1,this.file2=t.file2,this.file1Content=t.file1Content,this.file2Content=t.file2Content,this.triggerRebuild=t.triggerRebuild}async modify(e,t){if(e instanceof Mt){no(e.ydoc,t,e);return}else if(e instanceof Ko){e.contents=t;return}await this.app.vault.modify(e,t)}build(e){let t=e.createDiv({cls:"flex flex-row gap-1 py-0-5"}),r=this.difference.file1Lines.length>0,o=this.difference.file2Lines.length>0;o&&r?(new vr({text:"Accept Top (Editor)",onClick:s=>this.acceptTopClick(s,this.difference)}).build(t),Mo.build(t),new vr({text:"Accept Bottom (Local Disk)",onClick:s=>this.acceptBottomClick(s,this.difference)}).build(t),Mo.build(t),new vr({text:"Accept All",onClick:s=>this.acceptAllClick(s,this.difference)}).build(t),Mo.build(t),new vr({text:"Accept None",onClick:s=>this.acceptNoneClick(s,this.difference)}).build(t)):r?(new vr({text:"Keep in Editor",onClick:s=>this.insertFile1Difference(s,this.difference)}).build(t),Mo.build(t),new vr({text:"Discard in Editor",onClick:s=>this.discardFile1Difference(s,this.difference)}).build(t)):o&&(new vr({text:"Accept from Local Disk",onClick:s=>this.insertFile2Difference(s,this.difference)}).build(t),Mo.build(t),new vr({text:"Discard on Disk",onClick:s=>this.discardFile2Difference(s,this.difference)}).build(t))}async acceptTopClick(e,t){e.preventDefault();let r=t.file1Lines.join(`
|
|
`),o=ca({fullText:this.file2Content,newLine:r,position:t.file2Start,linesToReplace:t.file2Lines.length});await this.modify(this.file2,o),this.triggerRebuild()}async acceptBottomClick(e,t){e.preventDefault();let r=t.file2Lines.join(`
|
|
`),o=ca({fullText:this.file1Content,newLine:r,position:t.file1Start,linesToReplace:t.file1Lines.length});await this.modify(this.file1,o),this.triggerRebuild()}async acceptAllClick(e,t){e.preventDefault();let r=[...t.file1Lines,...t.file2Lines].join(`
|
|
`),o=ca({fullText:this.file1Content,newLine:r,position:t.file1Start,linesToReplace:t.file1Lines.length});await this.modify(this.file1,o);let s=ca({fullText:this.file2Content,newLine:r,position:t.file2Start,linesToReplace:t.file2Lines.length});await this.modify(this.file2,s),this.triggerRebuild()}async acceptNoneClick(e,t){e.preventDefault();let r=ua({fullText:this.file1Content,position:t.file1Start,count:t.file1Lines.length});await this.modify(this.file1,r);let o=ua({fullText:this.file2Content,position:t.file2Start,count:t.file2Lines.length});await this.modify(this.file2,o),this.triggerRebuild()}async insertFile1Difference(e,t){e.preventDefault();let r=t.file1Lines.join(`
|
|
`),o=qp({fullText:this.file2Content,newLine:r,position:t.file2Start});await this.modify(this.file2,o),this.triggerRebuild()}async insertFile2Difference(e,t){e.preventDefault();let r=t.file2Lines.join(`
|
|
`),o=qp({fullText:this.file1Content,newLine:r,position:t.file1Start});await this.modify(this.file1,o),this.triggerRebuild()}async discardFile1Difference(e,t){e.preventDefault();let r=ua({fullText:this.file1Content,position:t.file1Start,count:t.file1Lines.length});await this.modify(this.file1,r),this.triggerRebuild()}async discardFile2Difference(e,t){e.preventDefault();let r=ua({fullText:this.file2Content,position:t.file2Start,count:t.file2Lines.length});await this.modify(this.file2,r),this.triggerRebuild()}};var ti="system3-differences-view";async function Xb(n,e){e.originalLeaf||(e.originalLeaf=n.activeLeaf||void 0),n.detachLeavesOfType(ti);let t=n.getLeaf(!0);t.setViewState({type:ti,active:!0,state:e}),n.revealLeaf(t)}var Sc=class extends Zb.ItemView{constructor(t){super(t);this.file1Lines=[];this.file2Lines=[];let r=this.constructor.name;this.log=Te(`[${r}]`,"log")}async getContent(t){return t instanceof Mt?t.text:t instanceof Ko?t.contents:await this.app.vault.read(t)}getViewType(){return ti}getDisplayText(){var t,r;return(t=this.state)!=null&&t.file1&&((r=this.state)!=null&&r.file2)?`File Diff: ${this.state.file1.name} and ${this.state.file2.name}`:"File Diff"}async setState(t,r){super.setState(t,r),this.state=t,await this.updateState(),this.build()}async onunload(){var t,r;(r=(t=this.state)==null?void 0:t.onResolve)==null||r.call(t)}closeAndReturnToOriginal(){var t;(t=this.state)!=null&&t.originalLeaf&&this.state.originalLeaf.parent&&this.app.workspace.setActiveLeaf(this.state.originalLeaf,{focus:!0}),this.leaf.detach()}async updateState(){var r,o;if(((r=this.state)==null?void 0:r.file1)==null||((o=this.state)==null?void 0:o.file2)==null)return;this.file1Content=await this.getContent(this.state.file1),this.file2Content=await this.getContent(this.state.file2),this.file1Lines=this.file1Content.concat(`
|
|
`).split(`
|
|
`).map(s=>s.trimEnd()),this.file2Lines=this.file2Content.concat(`
|
|
`).split(`
|
|
`).map(s=>s.trimEnd());let t=Qb(this.state.file1.path,this.state.file2.path,this.file1Lines.join(`
|
|
`),this.file2Lines.join(`
|
|
`));if(this.fileDifferences=wc.fromParsedDiff(t),this.fileDifferences.differences.length===0){if(this.file1Content!==this.file2Content){if(this.log("byte level difference with differ equivalence",this.file1Content.length,this.file2Content.length),He().enableDeltaLogging){let s=this.file1Content||"",i=this.file2Content||"",a=Math.max(s.length,i.length);for(let l=0;l<a;l++){let c=l<s.length?s.charCodeAt(l):void 0,u=l<i.length?i.charCodeAt(l):void 0;if(c!==u){let f=c!==void 0?`0x${c.toString(16).padStart(2,"0")}`:"EOF",d=u!==void 0?`0x${u.toString(16).padStart(2,"0")}`:"EOF";this.log(`Byte difference at position ${l}: file1=${c} (${f}), file2=${u} (${d})`)}}}await this.modify(this.state.file2,this.file1Content||"")}this.closeAndReturnToOriginal()}}build(){this.contentEl.empty();let t=this.contentEl.createDiv({cls:"file-diff__container"});this.buildHeader(t),this.buildLines(t),this.scrollToFirstDifference()}update(){let t=this.contentEl.scrollTop;this.contentEl.empty();let r=this.contentEl.createDiv({cls:"file-diff__container"});this.buildHeader(r),this.buildLines(r),this.contentEl.scrollTop=t}buildHeader(t){let r=t.createDiv({cls:"flex flex-row gap-1 py-0-5"});new vr({text:"Keep Editor Contents",onClick:async o=>{o.preventDefault(),await this.acceptAllFromLeft()}}).build(r),Mo.build(r),new vr({text:"Accept All from Local Disk",onClick:async o=>{o.preventDefault(),await this.acceptAllFromRight()}}).build(r)}async modify(t,r){if(t instanceof Mt){no(t.ydoc,r,this);return}else if(t instanceof Ko){t.contents=r;return}await this.app.vault.modify(t,r)}async acceptAllFromLeft(){var t,r;!this.state||!this.fileDifferences||(await this.modify(this.state.file2,this.file1Content||""),await((r=(t=this.state).onResolve)==null?void 0:r.call(t)),this.closeAndReturnToOriginal())}async acceptAllFromRight(){var t,r;!this.state||!this.fileDifferences||(await this.modify(this.state.file1,this.file2Content||""),await((r=(t=this.state).onResolve)==null?void 0:r.call(t)),this.closeAndReturnToOriginal())}buildLines(t){var i,a,l;let r=0,o=0,s=Math.max(((i=this.file1Lines)==null?void 0:i.length)||0,((a=this.file2Lines)==null?void 0:a.length)||0);for(;r<=s||o<=s;){let c=(l=this.fileDifferences)==null?void 0:l.differences.find(u=>u.file1Start===r&&u.file2Start===o);if(c!=null){let u=t.createDiv({cls:"difference"});this.buildDifferenceVisualizer(u,c),r+=c.file1Lines.length,o+=c.file2Lines.length}else{let u=r<=o?this.file1Lines[r]:this.file2Lines[o];t.createDiv({text:ei(u),cls:"file-diff__line"}),r+=1,o+=1}}}buildDifferenceVisualizer(t,r){var o;(o=this.state)!=null&&o.showMergeOption&&new _c(this.app,{difference:r,file1:this.state.file1,file2:this.state.file2,file1Content:this.file1Content||"",file2Content:this.file2Content||"",triggerRebuild:async()=>{await this.updateState(),this.update()}}).build(t);for(let s=0;s<r.file1Lines.length;s+=1){let i=r.file1Lines[s],a=r.file2Lines[s],l=t.createDiv({cls:"file-diff__line file-diff__top-line__bg"}),c=this.buildDiffLine(i,a,"file-diff_top-line__character");(s<r.file1Lines.length-1||r.file2Lines.length!==0)&&l.classList.add("file-diff__no-bottom-border"),s!==0&&l.classList.add("file-diff__no-top-border"),l.appendChild(c)}for(let s=0;s<r.file2Lines.length;s+=1){let i=r.file1Lines[s],a=r.file2Lines[s],l=t.createDiv({cls:"file-diff__line file-diff__bottom-line__bg"}),c=this.buildDiffLine(a,i,"file-diff_bottom-line__character");(s==0&&r.file1Lines.length>0||s>0)&&l.classList.add("file-diff__no-top-border"),s<r.file2Lines.length-1&&l.classList.add("file-diff__no-bottom-border"),l.appendChild(c)}}buildDiffLine(t,r,o){let s=document.createElement("div");if(t!=null&&t.length===0)s.textContent=ei(t);else if(t!=null&&r!=null){let i=Yb(r,t);for(let a of i){if(a.removed)continue;let l=document.createElement("span");l.textContent=ei(a.value),a.added&&l.classList.add(o),s.appendChild(l)}}else if(t!=null&&r==null){let i=document.createElement("span");i.textContent=ei(t),i.classList.add(o),s.appendChild(i)}else s.textContent=ei(t);return s}scrollToFirstDifference(){var o;if(((o=this.fileDifferences)==null?void 0:o.differences.length)===0)return;let t=this.contentEl.getElementsByClassName("file-diff__container")[0].getBoundingClientRect(),r=this.contentEl.getElementsByClassName("difference")[0].getBoundingClientRect();this.contentEl.scrollTo({top:r.top-t.top-100,behavior:"smooth"})}};var kc=class extends Ze{constructor(t,r){super();this.connectionManager=t;if(this.view=r.view,this.canvas=r.view.canvas,this.relayCanvas=r.canvas,this.unsubscribes=[],this.relayCanvasView=r,this.observedTextNodes=new Set,this.trackedEmbedViews=new Set,this.install(),He().enableLiveEmbeds)for(let o of this.getEmbedViews())o.file&&this.connectEmbedView(o)}destroy(){this.canvas&&(this.unsubscribes.forEach(t=>t()),this.unsubscribes=[]),this.relayCanvasView.tracking=!1,this.canvas=null,this.relayCanvas=null,this.relayCanvasView=null,this.unsubscribes.length=0}observeNode(t){if(!this.observedTextNodes.has(t.id)&&t.type==="text"){let r=this.relayCanvas.textNode(t),o=t.id,s=i=>{let a=this.canvas.nodes.get(o);a&&(a.setText(r.toString()),this.canvas.markDirty(a))};r.observe(s),this.unsubscribes.push(()=>{this.relayCanvas.textNode(t).unobserve(s),this.observedTextNodes.delete(o)})}}getEmbedViews(){return[...this.canvas.nodes.values()].map(t=>t.child).filter(t=>!!t)}markDirty(t){let r=this.canvas.nodes.get(t.id);r&&this.canvas.markDirty(r)}isEmbedAlreadyTracked(t){return this.trackedEmbedViews.has(t)}connectEmbedView(t){t.file&&(this.trackedEmbedViews.add(t),this.unsubscribes.push((()=>{let r=new kn(t,this.relayCanvas.sharedFolder.proxy.getDoc(t.file.path));return r.initialize().catch(o=>{this.error("Error initializing ViewHookPlugin for canvas embed:",o)}),()=>{this.trackedEmbedViews.delete(t),r.destroy()}})()))}install(){var c;if(!this.canvas)return;this.debug("connecting canvas view to canvas",(c=this.view.file)==null?void 0:c.path,this.relayCanvas.path);let t=this,r=Vt.exportCanvasData(this.relayCanvas.ydoc),o=r.nodes.length>0||r.edges.length>0;this.relayCanvas.hasLocalDB()&&o&&this.canvas.importData(r,!0),this.unsubscribes.push(yr().patch(this.canvas,{requestSave(u){return function(){let f=u.call(this);try{t.relayCanvas.importFromView(t.view)}catch(d){t.log(d)}return f}},applyHistory(u){return function(f){let d=u.call(this,f);try{t.relayCanvas.importFromView(t.view)}catch(p){t.log(p)}return d}}}));let i=(u,f)=>{var m,y,g,I;let d="";if(d+=`Transaction origin: ${u.transaction.origin} ${(y=(m=u.transaction.origin)==null?void 0:m.constructor)==null?void 0:y.name}
|
|
`,this.relayCanvas||this.log("relay canvas is already destroyed"),!this.canvas){this.log("canvas is already destroyed");return}if(!((g=this.view.file)!=null&&g.path.endsWith(this.relayCanvas.path))){this.log("event is for another node");return}if(u.transaction.origin===this.relayCanvas)return;let p=Vt.exportCanvasData(this.relayCanvas.ydoc);for(let[L,C]of u.changes.keys)d+=`key: ${L} action: ${C.action}
|
|
|
|
`;this.debug(d),this.debug("importing data",(I=this.view.file)==null?void 0:I.path,this.relayCanvas.path,p),this.canvas.importData(p,!0),this.canvas.requestSave();for(let L of u.keysChanged){let C=f.get(L);if(C){if(this.canvas.nodes.has(C.id)&&(this.observeNode(C.getData()),He().enableLiveEmbeds)){let S=C.child;S!=null&&S.file&&!this.isEmbedAlreadyTracked(S)&&this.connectEmbedView(S)}this.canvas.markMoved(C),this.canvas.markDirty(C)}}},a=u=>i(u,this.canvas.nodes);this.relayCanvas.ynodes.observe(a),this.unsubscribes.push(()=>{this.relayCanvas.ynodes.unobserve(a)});for(let[,u]of this.relayCanvas.ynodes)this.observeNode(u);let l=u=>i(u,this.canvas.edges);this.relayCanvas.yedges.observe(l),this.unsubscribes.push(()=>{this.relayCanvas.yedges.unobserve(l)}),this.relayCanvasView.tracking=!0}};var Ic=require("@codemirror/state"),tv=require("@codemirror/view");var wW=Ic.Facet.define({combine(n){return n[n.length-1]}}),ev=Ic.Annotation.define(),jp=class{constructor(e){this.initialSet=!1;this.destroyed=!1;this.keyFrameCounter=0;this.debug=(...e)=>{};this.log=(...e)=>{};this.warn=(...e)=>{};this.embed=!1;var t,r,o,s;this.editor=e,this.connectionManager=this.editor.state.field(Lo),this.view=(t=this.connectionManager)==null?void 0:t.findCanvas(this.editor),this.node=this.getNode(),this._ytext=this.getYText(),this._ytext&&this.view&&(this.log=Te(`[LiveNodePluginValue][${this.view.canvas.path}#${(r=this.node)==null?void 0:r.id}]`,"log"),this.warn=Te(`[LiveNodePluginValue][${this.view.canvas.path}#${(o=this.node)==null?void 0:o.id}]`,"warn"),this.debug=Te(`[LiveNodePluginValue][${this.view.canvas.path}#${(s=this.node)==null?void 0:s.id}]`,"debug"),this.debug("created"),this._observer=async(i,a)=>{var l;if(this._ytext=this.getYText(),this.destroyed){this.debug("Recived yjs event but editor was destroyed");return}if(a.origin!==this){let c=i.delta,u=[],f=0;for(let d=0;d<c.length;d++){let p=c[d];p.insert!=null?u.push({from:f,to:f,insert:p.insert}):p.delete!=null?(u.push({from:f,to:f+p.delete,insert:""}),f+=p.delete):p.retain!=null&&(f+=p.retain)}(l=this.view)!=null&&l.canvas&&e.dispatch({changes:u,annotations:[ev.of(this.editor)]})}},this.observer=(i,a)=>{var l;try{(l=this._observer)==null||l.call(this,i,a)}catch(c){c instanceof RangeError&&console.warn("range errors!")}},this._ytext.observe(this.observer))}getNode(){let e=this.editor.state.values.find(t=>{if(t&&t.node)return t.node});if(e)return this.node=e.node,this.node}getYText(){var t,r,o,s,i;this.view=(t=this.connectionManager)==null?void 0:t.findCanvas(this.editor);let e=this.editor.state.values.find(a=>{if(a&&a.node)return a.node});if(!e){this.observer&&((r=this._ytext)==null||r.unobserve(this.observer));return}return e.node.id!==((o=this.node)==null?void 0:o.id)&&this.observer&&((s=this._ytext)==null||s.unobserve(this.observer)),this.node=e.node,(i=this.view)==null?void 0:i.canvas.textNode(e.node)}update(e){var r;if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(ev)===this.editor)return;let t=this.getYText();t&&((r=t.doc)==null||r.transact(()=>{let o=0;e.changes.iterChanges((s,i,a,l,c)=>{let u=c.sliceString(0,c.length,`
|
|
`);s!==i&&t.delete(s+o,i-s),u.length>0&&t.insert(s+o,u),o+=u.length-(i-s)})},this))}destroy(){var e;this.destroyed=!0,this.observer&&((e=this._ytext)==null||e.unobserve(this.observer)),this.connectionManager=null,this.view=void 0,this._ytext=void 0,this.editor=null}},rv=tv.ViewPlugin.fromClass(jp);var zW=require("obsidian");function RL(n){we(n,"svelte-18fffd7",".avatar.svelte-18fffd7.svelte-18fffd7{position:relative;border-radius:50%;overflow:hidden;display:flex;align-items:center;justify-content:center;background-color:var(--color-base-30)}.avatar.svelte-18fffd7>img.svelte-18fffd7{margin:0px}.initial.svelte-18fffd7.svelte-18fffd7{color:var(--text-on-accent)}img.svelte-18fffd7.svelte-18fffd7{width:100%;height:100%;object-fit:cover}")}function UL(n){let e,t;return{c(){e=x("span"),t=V(n[5]),h(e,"class","initial svelte-18fffd7"),se(e,"font-size",n[4])},m(r,o){_(r,e,o),b(e,t)},p(r,o){o&32&&J(t,r[5]),o&16&&se(e,"font-size",r[4])},d(r){r&&w(e)}}}function OL(n){let e,t,r,o;return{c(){e=x("img"),hr(e.src,t=n[0].picture)||h(e,"src",t),h(e,"alt",n[1]),h(e,"referrerpolicy","no-referrer"),h(e,"class","svelte-18fffd7")},m(s,i){_(s,e,i),r||(o=$(e,"error",n[6]),r=!0)},p(s,i){i&1&&!hr(e.src,t=s[0].picture)&&h(e,"src",t),i&2&&h(e,"alt",s[1])},d(s){s&&w(e),r=!1,o()}}}function $L(n){let e;function t(s,i){return!s[3]&&s[0].picture?OL:UL}let r=t(n,-1),o=r(n);return{c(){e=x("div"),o.c(),h(e,"class","avatar svelte-18fffd7"),se(e,"width",n[2]),se(e,"height",n[2])},m(s,i){_(s,e,i),o.m(e,null)},p(s,[i]){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e,null))),i&4&&se(e,"width",s[2]),i&4&&se(e,"height",s[2])},i:B,o:B,d(s){s&&w(e),o.d()}}}function NL(n){var e;return((e=n.match(/[a-z]+$/i))===null||e===void 0?void 0:e[0])||"px"}function BL(n,e,t){let r,o,s,{user:i}=e,{alt:a="Profile picture"}=e,{size:l="40px"}=e,c=!1;function u(){t(3,c=!0)}return n.$$set=f=>{"user"in f&&t(0,i=f.user),"alt"in f&&t(1,a=f.alt),"size"in f&&t(2,l=f.size)},n.$$.update=()=>{n.$$.dirty&1&&t(5,r=i.name?i.name.charAt(0).toUpperCase():"?"),n.$$.dirty&4&&t(7,o=NL(l)),n.$$.dirty&132&&t(4,s=`${parseFloat(l)/2}${o}`)},[i,a,l,c,s,r,u,o]}var zp=class extends z{constructor(e){super(),W(this,e,BL,$L,j,{user:0,alt:1,size:2},RL)}},fa=zp;var ri=[];function VL(n,e){return{subscribe:ge(n,e).subscribe}}function ge(n,e=B){let t,r=new Set;function o(a){if(j(n,a)&&(n=a,t)){let l=!ri.length;for(let c of r)c[1](),ri.push(c,n);if(l){for(let c=0;c<ri.length;c+=2)ri[c][0](ri[c+1]);ri.length=0}}}function s(a){o(a(n))}function i(a,l=B){let c=[a,l];return r.add(c),r.size===1&&(t=e(o,s)||B),a(n),()=>{r.delete(c),r.size===0&&t&&(t(),t=null)}}return{set:o,update:s,subscribe:i}}function et(n,e,t){let r=!Array.isArray(n),o=r?[n]:n;if(!o.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");let s=e.length<2;return VL(t,(i,a)=>{let l=!1,c=[],u=0,f=B,d=()=>{if(u)return;f();let m=e(r?c[0]:c,i,a);s?i(m):f=Je(m)?m:B},p=o.map((m,y)=>Dt(m,g=>{c[y]=g,u&=~(1<<y),l&&d()},()=>{u|=1<<y}));return l=!0,d(),function(){me(p),f(),l=!1}})}function HL(n){we(n,"svelte-6odmvu",'.user-awareness-container{position:absolute;top:0;right:0;display:flex;align-items:center;flex-shrink:0;z-index:10}.user-awareness.svelte-6odmvu.svelte-6odmvu{position:relative;display:flex;align-items:center}.avatar-stack.svelte-6odmvu.svelte-6odmvu{display:flex;align-items:center;cursor:pointer;position:relative;transition:width 0.2s ease;overflow:visible}.stacked-avatar.svelte-6odmvu.svelte-6odmvu{position:relative}.avatar-stack.multi-user.svelte-6odmvu .stacked-avatar.svelte-6odmvu{transition:margin-left 0.2s ease}@media(hover: hover) and (pointer: fine){.avatar-stack.multi-user.svelte-6odmvu:hover .stacked-avatar.svelte-6odmvu{margin-left:-10px !important;margin-right:2px;transition-delay:300ms}}.more-indicator.svelte-6odmvu.svelte-6odmvu{width:2em;height:2em;border-radius:50%;background-color:var(--background-modifier-border);border:2px solid var(--text-muted);display:flex;align-items:center;justify-content:center;font-size:0.6em;font-weight:600;color:var(--text-muted);position:relative}.user-popover.svelte-6odmvu.svelte-6odmvu{position:absolute;top:100%;right:0;margin-top:8px;background:var(--background-primary);border:1px solid var(--background-modifier-border);border-radius:8px;box-shadow:var(--shadow-s);min-width:200px;max-width:300px;z-index:1000}.user-popover.svelte-6odmvu.svelte-6odmvu::before{content:"";position:absolute;top:-8px;right:20px;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:8px solid var(--background-modifier-border)}.user-popover.svelte-6odmvu.svelte-6odmvu::after{content:"";position:absolute;top:-7px;right:20px;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:8px solid var(--background-secondary)}.popover-header.svelte-6odmvu.svelte-6odmvu{padding:12px 16px 8px 16px;font-size:12px;font-weight:600;color:var(--text-muted);border-bottom:1px solid var(--background-modifier-border);background:var(--background-secondary);border-radius:8px 8px 0 0}.user-list.svelte-6odmvu.svelte-6odmvu{padding:8px 0;max-height:200px;overflow-y:auto}.user-item.svelte-6odmvu.svelte-6odmvu{display:flex;align-items:center;gap:12px;padding:6px 16px;cursor:default}.user-item.svelte-6odmvu.svelte-6odmvu:hover{background-color:var(--background-modifier-hover)}.user-name.svelte-6odmvu.svelte-6odmvu{font-size:14px;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.avatar-with-border.svelte-6odmvu.svelte-6odmvu{border-radius:50%;border:2px solid;display:inline-block;overflow:hidden;flex-shrink:0;background:var(--background-primary);box-sizing:border-box;padding:1px}.user-avatar.svelte-6odmvu.svelte-6odmvu{width:2em;height:2em;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;position:relative}.user-initial.svelte-6odmvu.svelte-6odmvu{color:white;font-size:1em;font-weight:600}')}function ov(n,e,t){let r=n.slice();return r[16]=e[t],r[18]=t,r}function nv(n,e,t){let r=n.slice();return r[16]=e[t],r[18]=t,r}function sv(n){let e,t,r=[],o=new Map,s,i,a,l,c,u=he(n[4]),f=m=>m[16].id;for(let m=0;m<u.length;m+=1){let y=nv(n,u,m),g=f(y);o.set(g,r[m]=iv(g,y))}let d=n[3].length>Qn&&av(n),p=n[0]&&lv(n);return{c(){e=x("div"),t=x("div");for(let m=0;m<r.length;m+=1)r[m].c();s=T(),d&&d.c(),i=T(),p&&p.c(),h(t,"class","avatar-stack svelte-6odmvu"),h(t,"role","button"),h(t,"tabindex","-1"),_e(t,"multi-user",n[4].length>1),h(e,"class","user-awareness svelte-6odmvu")},m(m,y){_(m,e,y),b(e,t);for(let g=0;g<r.length;g+=1)r[g]&&r[g].m(t,null);b(t,s),d&&d.m(t,null),n[11](t),b(e,i),p&&p.m(e,null),n[13](e),a=!0,l||(c=[$(t,"click",n[7]),$(t,"keydown",n[12])],l=!0)},p(m,y){y&16&&(u=he(m[4]),ee(),r=qr(r,y,f,1,m,u,o,t,Gn,iv,s,nv),te()),m[3].length>Qn?d?d.p(m,y):(d=av(m),d.c(),d.m(t,null)):d&&(d.d(1),d=null),(!a||y&16)&&_e(t,"multi-user",m[4].length>1),m[0]?p?(p.p(m,y),y&1&&v(p,1)):(p=lv(m),p.c(),v(p,1),p.m(e,null)):p&&(ee(),k(p,1,1,()=>{p=null}),te())},i(m){if(!a){for(let y=0;y<u.length;y+=1)v(r[y]);v(p),a=!0}},o(m){for(let y=0;y<r.length;y+=1)k(r[y]);k(p),a=!1},d(m){m&&w(e);for(let y=0;y<r.length;y+=1)r[y].d();d&&d.d(),n[11](null),p&&p.d(),n[13](null),l=!1,me(c)}}}function qL(n){let e,t,r,o=n[16].name.charAt(0).toUpperCase()+"",s;return{c(){e=x("div"),t=x("div"),r=x("span"),s=V(o),h(r,"class","user-initial svelte-6odmvu"),h(t,"class","user-avatar svelte-6odmvu"),se(t,"background-color",n[16].color),h(e,"class","avatar-with-border svelte-6odmvu"),se(e,"border-color",n[16].color)},m(i,a){_(i,e,a),b(e,t),b(t,r),b(r,s)},p(i,a){a&16&&o!==(o=i[16].name.charAt(0).toUpperCase()+"")&&J(s,o),a&16&&se(t,"background-color",i[16].color),a&16&&se(e,"border-color",i[16].color)},i:B,o:B,d(i){i&&w(e)}}}function jL(n){let e,t,r;return t=new fa({props:{user:n[16].relayUser,size:"2em",alt:n[16].name}}),{c(){e=x("div"),P(t.$$.fragment),h(e,"class","avatar-with-border svelte-6odmvu"),se(e,"border-color",n[16].color)},m(o,s){_(o,e,s),A(t,e,null),r=!0},p(o,s){let i={};s&16&&(i.user=o[16].relayUser),s&16&&(i.alt=o[16].name),t.$set(i),(!r||s&16)&&se(e,"border-color",o[16].color)},i(o){r||(v(t.$$.fragment,o),r=!0)},o(o){k(t.$$.fragment,o),r=!1},d(o){o&&w(e),F(t)}}}function iv(n,e){let t,r,o,s,i,a=[jL,qL],l=[];function c(u,f){return u[16].relayUser?0:1}return r=c(e,-1),o=l[r]=a[r](e),{key:n,first:null,c(){t=x("div"),o.c(),h(t,"class","stacked-avatar svelte-6odmvu"),se(t,"z-index",10-e[18]),se(t,"margin-left",uv(e[18])),se(t,"transition","all 0.2s ease"),h(t,"aria-label",s=e[16].name),this.first=t},m(u,f){_(u,t,f),l[r].m(t,null),i=!0},p(u,f){e=u;let d=r;r=c(e,f),r===d?l[r].p(e,f):(ee(),k(l[d],1,1,()=>{l[d]=null}),te(),o=l[r],o?o.p(e,f):(o=l[r]=a[r](e),o.c()),v(o,1),o.m(t,null)),(!i||f&16)&&se(t,"z-index",10-e[18]),(!i||f&16)&&se(t,"margin-left",uv(e[18])),(!i||f&16&&s!==(s=e[16].name))&&h(t,"aria-label",s)},i(u){i||(v(o),i=!0)},o(u){k(o),i=!1},d(u){u&&w(t),l[r].d()}}}function av(n){let e,t,r=n[3].length-Qn+"",o;return{c(){e=x("div"),t=V("+"),o=V(r),h(e,"class","more-indicator svelte-6odmvu"),se(e,"z-index","11"),se(e,"margin-top","1em"),se(e,"margin-left","-1em"),se(e,"transition","all 0.2s ease")},m(s,i){_(s,e,i),b(e,t),b(e,o)},p(s,i){i&8&&r!==(r=s[3].length-Qn+"")&&J(o,r)},d(s){s&&w(e)}}}function lv(n){let e,t,r,o=n[3].length+"",s,i,a,l,c=[],u=new Map,f,d=he(n[3]),p=m=>m[16].id;for(let m=0;m<d.length;m+=1){let y=ov(n,d,m),g=p(y);u.set(g,c[m]=cv(g,y))}return{c(){e=x("div"),t=x("div"),r=V("Active Users ("),s=V(o),i=V(")"),a=T(),l=x("div");for(let m=0;m<c.length;m+=1)c[m].c();h(t,"class","popover-header svelte-6odmvu"),h(l,"class","user-list svelte-6odmvu"),h(e,"class","user-popover svelte-6odmvu")},m(m,y){_(m,e,y),b(e,t),b(t,r),b(t,s),b(t,i),b(e,a),b(e,l);for(let g=0;g<c.length;g+=1)c[g]&&c[g].m(l,null);f=!0},p(m,y){(!f||y&8)&&o!==(o=m[3].length+"")&&J(s,o),y&8&&(d=he(m[3]),ee(),c=qr(c,y,p,1,m,d,u,l,Gn,cv,null,ov),te())},i(m){if(!f){for(let y=0;y<d.length;y+=1)v(c[y]);f=!0}},o(m){for(let y=0;y<c.length;y+=1)k(c[y]);f=!1},d(m){m&&w(e);for(let y=0;y<c.length;y+=1)c[y].d()}}}function zL(n){let e,t,r,o=n[16].name.charAt(0).toUpperCase()+"",s;return{c(){e=x("div"),t=x("div"),r=x("span"),s=V(o),h(r,"class","user-initial svelte-6odmvu"),h(t,"class","user-avatar svelte-6odmvu"),se(t,"background-color",n[16].color),se(t,"width","20px"),se(t,"height","20px"),h(e,"class","avatar-with-border svelte-6odmvu"),se(e,"border-color",n[16].color)},m(i,a){_(i,e,a),b(e,t),b(t,r),b(r,s)},p(i,a){a&8&&o!==(o=i[16].name.charAt(0).toUpperCase()+"")&&J(s,o),a&8&&se(t,"background-color",i[16].color),a&8&&se(e,"border-color",i[16].color)},i:B,o:B,d(i){i&&w(e)}}}function WL(n){let e,t,r;return t=new fa({props:{user:n[16].relayUser,size:"20px",alt:n[16].name}}),{c(){e=x("div"),P(t.$$.fragment),h(e,"class","avatar-with-border svelte-6odmvu"),se(e,"border-color",n[16].color)},m(o,s){_(o,e,s),A(t,e,null),r=!0},p(o,s){let i={};s&8&&(i.user=o[16].relayUser),s&8&&(i.alt=o[16].name),t.$set(i),(!r||s&8)&&se(e,"border-color",o[16].color)},i(o){r||(v(t.$$.fragment,o),r=!0)},o(o){k(t.$$.fragment,o),r=!1},d(o){o&&w(e),F(t)}}}function cv(n,e){let t,r,o,s,i,a=e[16].name+"",l,c=e[18]===0?" (You)":"",u,f,d,p=[WL,zL],m=[];function y(g,I){return g[16].relayUser?0:1}return r=y(e,-1),o=m[r]=p[r](e),{key:n,first:null,c(){t=x("div"),o.c(),s=T(),i=x("span"),l=V(a),u=V(c),f=T(),h(i,"class","user-name svelte-6odmvu"),h(t,"class","user-item svelte-6odmvu"),_e(t,"current-user",e[18]===0),this.first=t},m(g,I){_(g,t,I),m[r].m(t,null),b(t,s),b(t,i),b(i,l),b(i,u),b(t,f),d=!0},p(g,I){e=g;let L=r;r=y(e,I),r===L?m[r].p(e,I):(ee(),k(m[L],1,1,()=>{m[L]=null}),te(),o=m[r],o?o.p(e,I):(o=m[r]=p[r](e),o.c()),v(o,1),o.m(t,s)),(!d||I&8)&&a!==(a=e[16].name+"")&&J(l,a),(!d||I&8)&&c!==(c=e[18]===0?" (You)":"")&&J(u,c),(!d||I&8)&&_e(t,"current-user",e[18]===0)},i(g){d||(v(o),d=!0)},o(g){k(o),d=!1},d(g){g&&w(t),m[r].d()}}}function KL(n){let e,t,r=n[3].length>0&&sv(n);return{c(){r&&r.c(),e=ue()},m(o,s){r&&r.m(o,s),_(o,e,s),t=!0},p(o,[s]){o[3].length>0?r?(r.p(o,s),s&8&&v(r,1)):(r=sv(o),r.c(),v(r,1),r.m(e.parentNode,e)):r&&(ee(),k(r,1,1,()=>{r=null}),te())},i(o){t||(v(r),t=!0)},o(o){k(r),t=!1},d(o){o&&w(e),r&&r.d(o)}}}var Qn=4;function uv(n){return n===0?"0":n===1?"-1em":n===2?"-1.4em":"-1.8em"}function GL(n,e,t){let r,o,{awareness:s}=e,{relayUsers:i}=e,a=!1,l,c,u=ge(0),f=null,d=et([i,u],([C,S])=>{if(!s||!C)return[];let M=s.getStates(),E=[];return M.forEach((R,O)=>{let q=R.user;if(q&&q.name&&q.id){let H=C.get(q.id);E.push({name:q.name,id:q.id,color:q.color||"#30bced",colorLight:q.colorLight||q.color+"33"||"#30bced33",relayUser:H})}}),[...E.filter((R,O,q)=>q.findIndex(H=>H.id===R.id)===O).sort((R,O)=>{var q;let H=s.getLocalState(),G=(q=H==null?void 0:H.user)===null||q===void 0?void 0:q.id;return R.id===G?-1:O.id===G?1:R.relayUser&&!O.relayUser?-1:!R.relayUser&&O.relayUser?1:0})]});ne(n,d,C=>t(3,r=C));let p=et([d],([C])=>{var S;if(C.length===0)return[];let M=s==null?void 0:s.getLocalState(),E=(S=M==null?void 0:M.user)===null||S===void 0?void 0:S.id,U=C.find(R=>R.id===E),K=C.filter(R=>R.id!==E);return U?C.length<=Qn?[...K,U]:[...K.slice(0,Qn-1),U]:K.slice(0,Qn)});ne(n,p,C=>t(4,o=C));function m(){t(0,a=!a)}function y(C){l&&!l.contains(C.target)&&t(0,a=!1)}st(()=>(document.addEventListener("click",y),()=>{document.removeEventListener("click",y)})),Go(()=>{f&&f(),document.removeEventListener("click",y)});function g(C){pt[C?"unshift":"push"](()=>{c=C,t(2,c)})}let I=C=>C.key==="Enter"&&m();function L(C){pt[C?"unshift":"push"](()=>{l=C,t(1,l)})}return n.$$set=C=>{"awareness"in C&&t(8,s=C.awareness),"relayUsers"in C&&t(9,i=C.relayUsers)},n.$$.update=()=>{if(n.$$.dirty&1280&&s){f&&f();let C=()=>{u.update(S=>S+1)};s.on("change",C),u.set(0),t(10,f=()=>{s.off("change",C)})}},[a,l,c,r,o,d,p,m,s,i,f,g,I,L]}var Wp=class extends z{constructor(e){super(),W(this,e,GL,KL,j,{awareness:8,relayUsers:9},HL)}},fv=Wp;var Cc=class extends Ze{constructor(t,r){super();this.destroyed=!1;this.view=t,this.doc=t.document,this.relayUsersStore=r,this.setLoggers(`[AwarenessView](${this.doc.path})`),this.install()}async install(){var t;!this.view||this.destroyed||(this.log("Installing awareness component for",(t=this.view.view.file)==null?void 0:t.path),this.wrapTitle(),await this.doc.whenReady(),!this.destroyed&&this.mountAwarenessComponent())}wrapTitle(){if(!this.view.view.containerEl||this.destroyed||this.awarenessElement)return;let t=this.view.view.containerEl.querySelector(".inline-title");if(!t){this.warn("Could not find inline-title element to position awareness component");return}this.awarenessElement=document.createElement("div"),this.awarenessElement.className="user-awareness-container",t.insertAdjacentElement("afterend",this.awarenessElement);let r=t.parentElement;r&&(r.style.position="relative")}mountAwarenessComponent(){if(!this.awarenessElement||this.destroyed)return;let t=this.doc._provider;if(!(t!=null&&t.awareness)){this.warn("No awareness provider available");return}try{this.awarenessComponent=new fv({target:this.awarenessElement,props:{awareness:t.awareness,relayUsers:this.relayUsersStore}}),this.log("Awareness component successfully mounted")}catch(r){this.warn("Failed to create awareness component:",r)}}destroy(){if(this.destroyed=!0,this.awarenessComponent)try{this.awarenessComponent.$destroy(),this.awarenessComponent=void 0,this.log("Awareness component destroyed")}catch(t){this.warn("Error destroying awareness component:",t)}this.awarenessElement&&(this.awarenessElement.remove(),this.awarenessElement=void 0),this.view=null,this.doc=null}};var dv=require("obsidian");var Lc=class extends Ze{constructor(t){var s,i,a;super();this.destroyed=!1;this.saving=!1;this.view=t,this.doc=t.document,this.unsubscribes=[],this.saving=!1;let r=this.doc._tfile,o=(s=this.view.view)==null?void 0:s.file;if(r!==o){this.error("[TextViewPlugin] CRITICAL: Document TFile mismatch!",{documentPath:this.doc.path,documentTFilePath:r==null?void 0:r.path,viewFilePath:o==null?void 0:o.path,viewType:(a=(i=this.view.view)==null?void 0:i.getViewType)==null?void 0:a.call(i),documentGuid:this.doc.guid,tFilesSame:r===o});let l=this.getDocument();l&&(this.doc=l,this.warn("[TextViewPlugin] Switched to correct document:",{newDocPath:this.doc.path,newDocGuid:this.doc.guid}))}this.view.view instanceof dv.MarkdownView&&(this.viewHookPlugin=new kn(this.view.view,this.doc)),this.install()}getDocument(){var r,o,s,i,a;let t=this.view.view.file;if(t){if(((r=this.doc)==null?void 0:r._tfile)===t)return this.doc;this.warn("[TextViewPlugin] getDocument() lookup:",{filePath:t.path,currentDocPath:(o=this.doc)==null?void 0:o.path,currentDocTFile:(i=(s=this.doc)==null?void 0:s._tfile)==null?void 0:i.path});let l=this.view.connectionManager.sharedFolders.lookup(t.path);if(l){let c=l.proxy.getDoc(t.path);return this.warn("[TextViewPlugin] getDocument() found:",{newDocPath:c.path,newDocGuid:c.guid,newDocTFile:(a=c._tfile)==null?void 0:a.path}),this.doc=c,this.doc}}if(this.view.document)return this.warn("[TextViewPlugin] getDocument() using fallback:",{fallbackDocPath:this.view.document.path,fallbackDocGuid:this.view.document.guid}),this.view.document}async resync(){var t,r,o,s;if(Zn(this.view)&&!this.view.tracking&&!this.destroyed&&this.view.view.file){if(this.doc=this.getDocument(),!this.doc){this.warn("resync() - no document available");return}if(await this.doc.whenSynced(),this.doc.text===this.view.view.getViewData()){this.view.tracking=!0,this.warn("resync() - content matches, setting tracking=true");return}else this.warn("diff in resync - DETAILED DEBUG:",{documentPath:this.doc.path,documentTFilePath:(t=this.doc._tfile)==null?void 0:t.path,viewFilePath:(r=this.view.view.file)==null?void 0:r.path,documentText:this.doc.text,viewData:this.view.view.getViewData(),documentGuid:this.doc.guid,tFilesMatching:this.doc._tfile===this.view.view.file,documentTextLength:((o=this.doc.text)==null?void 0:o.length)||0,viewDataLength:((s=this.view.view.getViewData())==null?void 0:s.length)||0});if(!this.doc.hasLocalDB()&&this.doc.text===""){this.warn("local db missing, not setting buffer");return}await this.doc.checkStale()&&this.view?(this.warn("Document is stale - showing merge banner"),this.view.checkStale().then(async a=>{a||await this.syncViewToCRDT()})):(this.warn("Document is authoritative - syncing view to CRDT state"),await this.syncViewToCRDT())}}async syncViewToCRDT(){Zn(this.view)&&!this.destroyed&&this.doc&&this.view.view.file&&(this.warn("Syncing view to CRDT - setViewData"),this.saving=!0,this.view.view.setViewData(this.doc.text,!1),this.doc.save(),this.saving=!1,this.view.tracking=!0)}install(){var r;if(!this.view)return;if(!this.view.view.file){this.warn("view file not ready, deferring install"),setTimeout(()=>{var o,s;!this.destroyed&&((s=(o=this.view)==null?void 0:o.view)!=null&&s.file)&&this.install()},100);return}this.warn("connecting textfile view",(r=this.view.view.file)==null?void 0:r.path,this.view.document.path);let t=this;this.unsubscribes.push(yr().patch(this.view.view,{setViewData(o){return function(s,i){if(t.warn("instance hook: setViewData",this.getViewType()),!t.view.view.file)return t.warn("setViewData called before file loaded, deferring to original"),o.call(this,s,i);i&&Zn(t.view)&&t.doc&&t.view.view.file===t.doc.tfile&&t.view.document.text===s&&(t.view.tracking=!0);let a=o.call(this,s,i);return i&&t.resync(),a}},requestSave(o){return function(){if(t.warn("instance hook: requestSave called",this.getViewType()),Zn(t.view)&&!t.saving&&t.doc)if(t.view.tracking&&!t.saving){t.warn("tracking - applying diff"),no(t.doc.ydoc,t.view.view.getViewData(),t.doc),t.doc.save();return}else t.warn("not tracking - resync"),t.resync();return o.call(this)}}})),this.observer=(o,s)=>{if(this.doc=this.getDocument(),!this.doc){this.debug("observer - no document available");return}if(!Zn(this.view)){this.debug("Recived yjs event against a non-live view");return}if(this.destroyed){this.debug("Recived yjs event but editor was destroyed");return}s.origin!==this.doc&&(this.view.tracking||(this.warn("resync from update, not tracking"),this.resync()),this.warn("setting view data"),this.saving=!0,this.view.view.setViewData(this.doc.text,!1),this.view.view.requestSave(),this.saving=!1,this.view.tracking=!0)},this.resync(),this.doc=this.getDocument(),this.doc&&(this._ytext=this.doc.ytext,this._ytext.observe(this.observer)),this.viewHookPlugin&&this.viewHookPlugin.initialize().catch(o=>{this.error("Error initializing ViewHookPlugin:",o)})}destroy(){var t,r;this.warn("destroying view"),this.destroyed=!0,this.observer&&((t=this._ytext)==null||t.unobserve(this.observer)),this.unsubscribes.forEach(o=>o()),this.unsubscribes.length=0,(r=this.viewHookPlugin)==null||r.destroy(),this.observer=null,this._ytext=null,this.view=null,this.doc=null}};var JL=3;function Kp(n,e){n.iterateAllLeaves(t=>{t.view.getViewType()==="canvas"&&e(t.view)})}function Gp(n,e){let t=["markdown"];He().enableKanbanView&&t.push("kanban");let r=[];n.iterateAllLeaves(o=>{var s,i,a,l;r.push({viewType:((i=(s=o.view)==null?void 0:s.getViewType)==null?void 0:i.call(s))||"unknown",filePath:((l=(a=o.view)==null?void 0:a.file)==null?void 0:l.path)||"no-file",isTextFileView:o.view instanceof Ht.TextFileView,leafType:o.view.constructor.name})}),n.iterateAllLeaves(o=>{if(o.view instanceof Ht.TextFileView){let s=o.view.getViewType();if(s==="canvas")return;t.contains(s)&&e(o.view)}})}function YL(n,e){var t,r,o,s;if(n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(((t=n[i].view.file)==null?void 0:t.path)!==((r=e[i].view.file)==null?void 0:r.path)||((o=n[i].document)==null?void 0:o.path)!==((s=e[i].document)==null?void 0:s.path))return!1;return!0}var Mc=class{constructor(e,t,r){this.document=null;this.canConnect=!1;this._parent=e,this.view=t,this.login=r}setLoginIcon(){let e=this.view.containerEl.querySelector(".view-header"),t=this.view.containerEl.querySelector(".view-header-left");if(e&&t){this.clearLoginButton();let r=document.createElement("button");r.className="view-header-left system3-login-button",r.textContent="Login to enable Live edits",r.setAttribute("aria-label","Login to enable Live edits"),r.setAttribute("tabindex","0"),r.addEventListener("click",async()=>{await this.login()}),t.insertAdjacentElement("afterend",r)}}clearLoginButton(){let e=this.view.containerEl.querySelector(".system3-login-button");e&&e.remove()}attach(){return Ht.Platform.isMobile&&(0,Ht.requireApiVersion)("1.11.0")?this.setLoginIcon():this.banner=new Yn(this.view,"Login to enable Live edits",async()=>await this.login()),Promise.resolve(this)}release(){var e;(e=this.banner)==null||e.destroy(),this.clearLoginButton()}destroy(){var e;this.release(),(e=this.banner)==null||e.destroy(),this.banner=void 0,this.clearLoginButton(),this.view=null}};function jr(n){return n instanceof In&&n.view instanceof Ht.MarkdownView&&n.document!==void 0&&n.document.text!==void 0}function Zn(n){return n instanceof In&&n.document!==void 0&&n.document.text!==void 0}function QL(n){return n instanceof Tc&&n.document!==void 0}var Tc=class{constructor(e,t,r,o=!0,s=!0){this._parent=e,this.view=t,this.canvas=r,this.document=r,this.tracking=!1,this.shouldConnect=o,this.canConnect=s,e.networkStatus.online||this.offlineBanner()}toggleConnection(){this.shouldConnect=!this.shouldConnect,this.shouldConnect?this.canvas.connect().then(e=>{e||(this.shouldConnect=!1)}):this.canvas.disconnect()}offlineBanner(){if(this.shouldConnect){let e=new Yn(this.view,"You're offline -- click to reconnect",async()=>(this._parent.networkStatus.checkStatus(),this.connect(),this._parent.networkStatus.online));this._parent.networkStatus.onceOnline(()=>{this.connect(),e.destroy()})}return()=>{}}setConnectionDot(){let e=this.view.containerEl.querySelector(".view-actions");e&&e.firstChild&&(this._viewActions||(this.clearViewActions(),this.offConnectionStatusSubscription&&this.offConnectionStatusSubscription(),this._viewActions=new Tp({target:e,anchor:e.firstChild,props:{view:this,state:this.canvas.state,remote:this.canvas.sharedFolder.remote}}),this.offConnectionStatusSubscription=this.canvas.subscribe(e,t=>{var r;(r=this._viewActions)==null||r.$set({view:this,state:t,remote:this.canvas.sharedFolder.remote})})),this._viewActions.$set({view:this,state:this.canvas.state,remote:this.canvas.sharedFolder.remote}))}clearViewActions(){let e=this.view.containerEl.querySelector(".view-actions");if(e&&e.firstChild){let t=this.view.containerEl.querySelectorAll(".system3-view-action");t.length>0&&t.forEach(r=>{r.remove()})}}attach(){return this.canvas.userLock=!0,this.view.containerEl.addClass("relay-live-editor"),this.setConnectionDot(),this.plugin||(this.plugin=new kc(this._parent,this)),new Promise(e=>this.canvas.whenReady().then(t=>{this._parent.networkStatus.online&&this.canvas.sharedFolder.shouldConnect&&this.shouldConnect&&this.canConnect?this.connect():this.canvas.disconnect(),e(this)}).catch(()=>{this.offlineBanner()}))}connect(){this.canvas.connect()}release(){var e,t,r;this.view.containerEl.removeClass("relay-live-editor"),(e=this.plugin)==null||e.destroy(),this.plugin=void 0,(t=this._viewActions)==null||t.$destroy(),this._viewActions=void 0,(r=this._banner)==null||r.destroy(),this._banner=void 0,this.offConnectionStatusSubscription&&(this.offConnectionStatusSubscription(),this.offConnectionStatusSubscription=void 0),this.canvas.disconnect(),this.canvas.userLock=!1}destroy(){var e,t,r;(e=this.plugin)==null||e.destroy(),this.plugin=null,this.release(),this.clearViewActions(),(r=(t=this.view.leaf).rebuildView)==null||r.call(t),this._parent=null,this.view=null,this.canvas=null}},In=class extends Ze{constructor(e,t,r,o=!0,s=!0){super(),this._parent=e,this.view=t,this.document=r,this._tracking=!1,this.shouldConnect=o,this.canConnect=s,e.networkStatus.online||this.offlineBanner()}toggleConnection(){this.shouldConnect=!this.shouldConnect,this.shouldConnect?this.document.connect().then(e=>{e||(this.shouldConnect=!1)}):this.document.disconnect()}get tracking(){return this._tracking}set tracking(e){let t=this._tracking;this._tracking=e,this._tracking!==t&&this.attach()}get ytext(){return this.document.ytext}get connectionManager(){return this._parent}async syncViewToCRDT(){this._plugin&&typeof this._plugin.syncViewToCRDT=="function"&&await this._plugin.syncViewToCRDT()}setMergeButton(){let e=this.view.containerEl.querySelector(".view-header"),t=this.view.containerEl.querySelector(".view-header-left");if(e&&t){this.clearMergeButton();let r=document.createElement("button");r.className="view-header-left system3-merge-button",r.textContent="Merge conflict",r.setAttribute("aria-label","Merge conflict -- click to resolve"),r.setAttribute("tabindex","0"),r.addEventListener("click",async()=>{let o=await this.document.diskBuffer();if(!await this.document.checkStale()){this.clearMergeButton();return}this._parent.openDiffView({file1:this.document,file2:o,showMergeOption:!0,onResolve:async()=>{this.document.clearDiskBuffer(),this.clearMergeButton(),this._plugin&&typeof this._plugin.syncViewToCRDT=="function"&&await this._plugin.syncViewToCRDT()}})}),t.insertAdjacentElement("afterend",r)}}clearMergeButton(){let e=this.view.containerEl.querySelector(".system3-merge-button");e&&e.remove()}mergeBanner(){return Ht.Platform.isMobile&&(0,Ht.requireApiVersion)("1.11.0")?this.setMergeButton():this._banner=new Yn(this.view,"Merge conflict -- click to resolve",async()=>{let e=await this.document.diskBuffer();return await this.document.checkStale()&&this._parent.openDiffView({file1:this.document,file2:e,showMergeOption:!0,onResolve:async()=>{this.document.clearDiskBuffer(),this._plugin&&typeof this._plugin.syncViewToCRDT=="function"&&await this._plugin.syncViewToCRDT()}}),!0}),()=>{}}offlineBanner(){if(this.shouldConnect){let e=new Yn(this.view,"You're offline -- click to reconnect",async()=>(this._parent.networkStatus.checkStatus(),this.connect(),this._parent.networkStatus.online));this._parent.networkStatus.onceOnline(()=>{this.connect(),e.destroy()})}return()=>{}}setConnectionDot(){let e=this.view.containerEl.querySelector(".view-actions");e&&e.firstChild&&(this._viewActions||(this.clearViewActions(),this.offConnectionStatusSubscription&&this.offConnectionStatusSubscription(),this._viewActions=new Tp({target:e,anchor:e.firstChild,props:{view:this,state:this.document.state,remote:this.document.sharedFolder.remote}}),this.offConnectionStatusSubscription=this.document.subscribe(e,t=>{var r;(r=this._viewActions)==null||r.$set({view:this,state:t,remote:this.document.sharedFolder.remote})})),this._viewActions.$set({view:this,state:this.document.state,remote:this.document.sharedFolder.remote}))}clearViewActions(){let e=this.view.containerEl.querySelector(".view-actions");if(e&&e.firstChild){let t=this.view.containerEl.querySelectorAll(".system3-view-action");t.length>0&&t.forEach(r=>{r.remove()})}}async checkStale(){var t,r;if(this.view instanceof Ht.MarkdownView&&this.view.getMode()==="preview")return!1;let e=await this.document.checkStale();return e&&((t=this.document._diskBuffer)!=null&&t.contents)?this.mergeBanner():((r=this._banner)==null||r.destroy(),this._banner=void 0),e}attach(){var e,t,r;return this.document.userLock=!0,this.view instanceof Ht.MarkdownView&&this.view.containerEl.addClass("relay-live-editor"),this.view instanceof Ht.MarkdownView||this._plugin||(this.warn("[LiveView] Creating TextFileViewPlugin in attach() for:",{path:this.document.path,viewType:(t=(e=this.view).getViewType)==null?void 0:t.call(e),viewFilePath:(r=this.view.file)==null?void 0:r.path}),this._plugin=new Lc(this)),this.setConnectionDot(),jr(this)&&!this._awarenessPlugin&&He().enablePresenceAvatars&&(this._awarenessPlugin=new Cc(this,this._parent.sharedFolders.manager.users)),new Promise(o=>this.document.whenReady().then(s=>{this._parent.networkStatus.online&&this.document.sharedFolder.shouldConnect&&this.shouldConnect&&this.canConnect?this.connect():this.document.disconnect(),o(this)}).catch(()=>{this.offlineBanner()}))}connect(){this.document.connect()}release(){var e,t,r,o;this.view instanceof Ht.MarkdownView&&this.view.containerEl.removeClass("relay-live-editor"),(e=this._viewActions)==null||e.$destroy(),this._viewActions=void 0,(t=this._banner)==null||t.destroy(),this._banner=void 0,this.clearMergeButton(),this.offConnectionStatusSubscription&&(this.offConnectionStatusSubscription(),this.offConnectionStatusSubscription=void 0),(r=this._awarenessPlugin)==null||r.destroy(),this._awarenessPlugin=void 0,(o=this._plugin)==null||o.destroy(),this._plugin=void 0,this.document.disconnect(),this.document.userLock=!1}destroy(){var e,t;this.release(),this.clearViewActions(),this.clearMergeButton(),(t=(e=this.view.leaf).rebuildView)==null||t.call(e),this._parent=null,this.view=null,this.document=null,this._plugin=null}},Ac=class{constructor(e,t,r,o){this.app=e;this.destroyed=!1;this.offListeners=[];this.folderListeners=new Map;this.workspace=e.workspace,this.sharedFolders=t,this.views=[],this.extensions=[],this._activePromise=null,this.loginManager=r,this.networkStatus=o,this.refreshQueue=[],this._compartment=new Fc.Compartment,this.log=Te("[LiveViews]","log"),this.warn=Te("[LiveViews]","warn"),this.metadataListeners=new Map;let s=(l,c,u)=>{let f=this.metadataListeners.get(l);f==null||f(c,u)},i=this.app.metadataCache.on("changed",s);this.offListeners.push(()=>{this.app.metadataCache.offref(i)}),this.offListeners.push(this.loginManager.on(()=>{this.refresh("[LoginManager]")}));let a=l=>(l.ready||(async()=>l.whenReady().then(()=>{this.refresh("[Shared Folder Ready]")}).catch(c=>{this.views.forEach(u=>{var f,d;((f=u.document)==null?void 0:f.sharedFolder)===l&&((d=u.offlineBanner)==null||d.call(u))})}))(),l.fset.on(()=>{this.refresh("[Docset]")}));this.offListeners.push(this.sharedFolders.subscribe(()=>{this.refresh("[Shared Folders]"),this.folderListeners.forEach((l,c)=>{this.sharedFolders.has(c)||(l(),this.folderListeners.delete(c))}),this.sharedFolders.forEach(l=>{this.folderListeners.has(l)||this.folderListeners.set(l,a(l))})})),Bt.set(this,"LiveViewManager")}reconfigure(e){e.dispatch({effects:this._compartment.reconfigure([Lo.init(()=>this)])})}onMeta(e,t){this.metadataListeners.set(e,t)}offMeta(e){this.metadataListeners.delete(e)}openDiffView(e){Xb(this.workspace,e)}goOffline(){this.log("[System 3][Relay][Live Views] going offline"),this.views.forEach(e=>{var t;return(t=e.document)==null?void 0:t.disconnect()}),this.refresh("[NetworkStatus]")}goOnline(){this.log("[System 3][Relay][Live Views] going online"),this.refresh("[NetworkStatus]"),this.sharedFolders.items().forEach(e=>{e.connect()}),this.viewsAttachedWithConnectionPool(this.views)}docIsOpen(e){return this.views.some(t=>t.document===e)}releaseViews(e){e.forEach(t=>{t.release()})}findFolders(){let e=new Set;return Gp(this.workspace,t=>{var s;let r=(s=t.file)==null?void 0:s.path;if(!r)return;let o=this.sharedFolders.lookup(r);o&&e.add(o)}),Kp(this.workspace,t=>{var s;let r=(s=t.file)==null?void 0:s.path;if(!r)return;let o=this.sharedFolders.lookup(r);o&&e.add(o)}),e.size==0?[]:[...e]}async foldersReady(){let e=new Set;if(Gp(this.workspace,r=>{var i;let o=(i=r.file)==null?void 0:i.path;if(!o)return;let s=this.sharedFolders.lookup(o);s&&e.add(s)}),Kp(this.workspace,r=>{var i;let o=(i=r.file)==null?void 0:i.path;if(!o)return;let s=this.sharedFolders.lookup(o);s&&e.add(s)}),e.size===0)return[];let t=[...e].map(r=>r.whenReady());return Promise.all(t)}async getViews(){let e=[];return Gp(this.workspace,async t=>{var s;let r=(s=t.file)==null?void 0:s.path;if(!r)return;let o=this.sharedFolders.lookup(r);if(o)if(this.loginManager.loggedIn)if(o.ready){let i=o.proxy.getDoc(r),a=new In(this,t,i);e.push(a)}else this.log(`Folder not ready, skipping views. folder=${o.path}`);else{let i=new Mc(this,t,()=>this.loginManager.openLoginPage());e.push(i)}}),Kp(this.workspace,t=>{var s;let r=(s=t.file)==null?void 0:s.path;if(!r)return;let o=this.sharedFolders.lookup(r);if(o&&t.file){let i=o.getFile(t.file);if(io(i))if(this.loginManager.loggedIn)if(o.ready){let a=new Tc(this,t,i);e.push(a)}else this.log(`Folder not ready, skipping views. folder=${o.path}`);else{let a=new Mc(this,t,()=>this.loginManager.openLoginPage());e.push(a)}else this.log(`Skipping canvas view connection for ${r}`)}}),e}findView(e){return this.views.filter(jr).find(t=>t.view.editor.cm===e)}findCanvas(e){let t=e.state.values.find(r=>{if(r&&r.node)return r.node});if(t)return this.views.filter(QL).find(r=>r.view.canvas===t.node.canvas)}async viewsReady(e){return await Promise.all(e.filter(Zn).map(async t=>t.document.whenReady().then(r=>t)))}async viewsAttachedWithConnectionPool(e,t=JL){let r=this.workspace.getActiveViewOfType(Ht.TextFileView),o=0,s=e.sort((a,l)=>l.view.leaf.activeTime-a.view.leaf.activeTime),i=new Set;for(let a of s)a instanceof In&&(a.view===r||i.has(a.document)?(a.canConnect=!0,i.add(a.document)):o<t?(a.canConnect=!0,i.add(a.document),o++):a.canConnect=!1);return o>t&&this.warn(`[System 3][Relay][Live Views] connection pool (max ${t}): rejected connections for ${o-t} views`),this.viewsAttached(e)}async viewsAttached(e){return await Promise.all(e.map(async t=>t.attach()))}deduplicate(e){let t=[],r=[];return this.views.forEach(o=>{let s=e.find(i=>{if(o.document==i.document&&o.view==i.view)return!0});s?(r.push(o),e.remove(s)):t.push(o)}),e.forEach(o=>{r.push(o)}),[r,t]}async _refreshViews(e,t){let r=`[LiveViews][${e}]`,o=Te(r,"debug"),s=(f,d)=>{o(f,d.map(p=>{var m;return{type:p.constructor.name,file:(m=p.document)==null?void 0:m.path,canConnect:p.canConnect}}))};if(o("Refresh"),this.destroyed)return!1;await this.foldersReady();let i=[];try{i=await this.getViews()}catch(f){return this.warn("[System 3][Relay][Live Views] error getting views",f),!1}let a=this.findFolders();if(a.length===0&&i.length===0)return this.extensions.length!==0&&(o("Unexpected plugins loaded."),this.wipe()),s("Releasing Views",this.views),this.releaseViews(this.views),this.views=[],!0;this.loginManager.loggedIn&&this.networkStatus.online?a.forEach(f=>{f.connect()}):this.sharedFolders.forEach(f=>{f.disconnect()});let[l,c]=this.deduplicate(i);if(s("Releasing Views",c),this.releaseViews(c),c.length===0&&YL(l,this.views)){let f=await this.viewsAttachedWithConnectionPool(this.views);s("Attached Views",f)}else{let f=await this.viewsReady(l);s("Ready Views",f);let d=await this.viewsAttachedWithConnectionPool(f);s("Attached Views",d),this.views=l}o("loading plugins"),this.load();let u=Ht.moment.utc();return o(`refresh completed in ${u.diff(t)}ms`,r),!0}async refresh(e){if(this.destroyed)return!1;let t=Te(e,"warn"),r=Ht.moment.utc();if(this.refreshQueue.push(()=>this._refreshViews(e,r)),this._activePromise!==null)return!1;for(;this.refreshQueue.length>0;){if(this.destroyed)return!1;this.refreshQueue.length>2&&t("refreshQueue size:",this.refreshQueue.length);let o=this.refreshQueue.pop();this.refreshQueue.length=0,this._activePromise=o().finally(()=>{this._activePromise=null}),await this._activePromise}return!0}wipe(){this.extensions.length=0,this.workspace.updateOptions()}load(){this.wipe(),this.views.length>0&&(this.extensions.push([this._compartment.of(Lo.init(()=>this)),Hb,rv,jb,zb,Kb]),this.workspace.updateOptions())}destroy(){this.destroyed=!0,this.releaseViews(this.views),this.offListeners.forEach(e=>e()),this.offListeners.length=0,this.metadataListeners.clear(),this.metadataListeners=null,this.folderListeners.forEach(e=>e()),this.folderListeners.clear(),this.folderListeners=null,this.views.forEach(e=>e.destroy()),this.views=[],this.wipe(),this.sharedFolders=null,this.refreshQueue=null,this.networkStatus=null,this._activePromise=null,this.loginManager=null,this.app=null,this.workspace=null}},Lo=Fc.StateField.define({create(n){},update(n,e){return n}});var oi=require("obsidian");function ZL(n){we(n,"svelte-1siabfk",".system3-folder-icons.svelte-1siabfk{display:inline-flex;align-items:center;vertical-align:middle;border-radius:var(--radius-m);transition:width 0.3s ease;margin-right:0.6em;padding-left:0.2em;padding-right:0.2em;background-color:var(--color-base-05);position:relative}.system3-icon.svelte-1siabfk{margin-right:0.2em;margin-left:0.2em;width:1em;display:flex;transition:display 0.3s ease}span.system3-connected.svelte-1siabfk{color:var(--color-accent)}span.system3-disconnected.svelte-1siabfk{color:var(--color-base-40)}span.notebook.svelte-1siabfk{color:var(--color-accent)}span.hidden.svelte-1siabfk{display:none}.system3-progress-text.svelte-1siabfk{margin-right:0.4em;font-size:0.8em;color:var(--color-accent);opacity:1;transition:opacity 0.3s ease}.system3-progress-text.completed.svelte-1siabfk{animation:svelte-1siabfk-fadeOutDelay 0.3s ease forwards}.system3-progress-text.failed.svelte-1siabfk{color:var(--color-red)}@keyframes svelte-1siabfk-fadeOutDelay{0%,50%{opacity:1}100%{opacity:0;display:none}}")}function pv(n){let e,t,r,o;return{c(){e=x("span"),t=V(n[3]),r=V("%"),h(e,"class",o="system3-progress-text system3-"+n[4]+" svelte-1siabfk"),se(e,"opacity","1")},m(s,i){_(s,e,i),b(e,t),b(e,r)},p(s,i){i&8&&J(t,s[3]),i&16&&o!==(o="system3-progress-text system3-"+s[4]+" svelte-1siabfk")&&h(e,"class",o)},d(s){s&&w(e)}}}function XL(n){let e,t,r;return t=new lo({props:{class:"inline-icon",style:"width: 0.8em"}}),{c(){e=x("span"),P(t.$$.fragment),h(e,"class","notebook system3-icon svelte-1siabfk"),h(e,"aria-label","Tracking Changes")},m(o,s){_(o,e,s),A(t,e,null),r=!0},p:B,i(o){r||(v(t.$$.fragment,o),r=!0)},o(o){k(t.$$.fragment,o),r=!1},d(o){o&&w(e),F(t)}}}function e2(n){let e,t,r,o,s,i,a,l;return t=new lo({props:{class:"inline-icon",style:"width: 0.8em"}}),s=new Yo({props:{class:"inline-icon"}}),{c(){var c;e=x("span"),P(t.$$.fragment),r=T(),o=x("span"),P(s.$$.fragment),h(e,"class","notebook system3-icon hidden svelte-1siabfk"),h(e,"aria-label","Tracking Changes"),h(o,"class",i="satellite system3-icon system3-"+n[0]+" svelte-1siabfk"),h(o,"aria-label",a=`${((c=n[2])==null?void 0:c.relay.name)||"Relay Server"} (${n[0]})`)},m(c,u){_(c,e,u),A(t,e,null),_(c,r,u),_(c,o,u),A(s,o,null),l=!0},p(c,u){var f;(!l||u&1&&i!==(i="satellite system3-icon system3-"+c[0]+" svelte-1siabfk"))&&h(o,"class",i),(!l||u&5&&a!==(a=`${((f=c[2])==null?void 0:f.relay.name)||"Relay Server"} (${c[0]})`))&&h(o,"aria-label",a)},i(c){l||(v(t.$$.fragment,c),v(s.$$.fragment,c),l=!0)},o(c){k(t.$$.fragment,c),k(s.$$.fragment,c),l=!1},d(c){c&&(w(e),w(r),w(o)),F(t),F(s)}}}function t2(n){let e,t,r,o,s,i=n[5]&&pv(n),a=[e2,XL],l=[];function c(u,f){return u[1]?0:1}return r=c(n,-1),o=l[r]=a[r](n),{c(){e=x("div"),i&&i.c(),t=T(),o.c(),h(e,"class","system3-folder-icons svelte-1siabfk")},m(u,f){_(u,e,f),i&&i.m(e,null),b(e,t),l[r].m(e,null),s=!0},p(u,[f]){u[5]?i?i.p(u,f):(i=pv(u),i.c(),i.m(e,t)):i&&(i.d(1),i=null);let d=r;r=c(u,f),r===d?l[r].p(u,f):(ee(),k(l[d],1,1,()=>{l[d]=null}),te(),o=l[r],o?o.p(u,f):(o=l[r]=a[r](u),o.c()),v(o,1),o.m(e,null))},i(u){s||(v(o),s=!0)},o(u){k(o),s=!1},d(u){u&&w(e),i&&i.d(),l[r].d()}}}function r2(n,e,t){let r,{status:o="disconnected"}=e,{relayId:s}=e,{remote:i}=e,{progress:a=0}=e,{syncStatus:l="pending"}=e;return n.$$set=c=>{"status"in c&&t(0,o=c.status),"relayId"in c&&t(1,s=c.relayId),"remote"in c&&t(2,i=c.remote),"progress"in c&&t(3,a=c.progress),"syncStatus"in c&&t(4,l=c.syncStatus)},n.$$.update=()=>{n.$$.dirty&24&&t(5,r=(l!=="completed"||a<100)&&a>0)},[o,s,i,a,l,r]}var Jp=class extends z{constructor(e){super(),W(this,e,r2,t2,j,{status:0,relayId:1,remote:2,progress:3,syncStatus:4},ZL)}},mv=Jp;function o2(n){we(n,"svelte-1swndfj",".system3-filepill.svelte-1swndfj{text-wrap:nowrap}")}function n2(n){let e,t,r;return{c(){e=x("div"),t=x("span"),r=V(n[0]),h(e,"class","nav-file-tag system3-filepill svelte-1swndfj"),h(e,"aria-label",n[1])},m(o,s){_(o,e,s),b(e,t),b(t,r)},p(o,[s]){s&1&&J(r,o[0]),s&2&&h(e,"aria-label",o[1])},i:B,o:B,d(o){o&&w(e)}}}function s2(n,e,t){let{text:r}=e,{label:o}=e;return n.$$set=s=>{"text"in s&&t(0,r=s.text),"label"in s&&t(1,o=s.label)},[r,o]}var Yp=class extends z{constructor(e){super(),W(this,e,s2,n2,j,{text:0,label:1},o2)}},hv=Yp;function i2(n){we(n,"svelte-1ljf67u",".system3-uploadpill.svelte-1ljf67u{text-wrap:nowrap}")}function a2(n){let e,t,r,o;return{c(){e=x("div"),t=x("span"),r=V(n[0]),h(e,"class","nav-file-tag system3-uploadpill svelte-1ljf67u"),h(e,"aria-label",n[1]),h(e,"style",o=n[2]?`color:${n[2]}`:"")},m(s,i){_(s,e,i),b(e,t),b(t,r)},p(s,[i]){i&1&&J(r,s[0]),i&2&&h(e,"aria-label",s[1]),i&4&&o!==(o=s[2]?`color:${s[2]}`:"")&&h(e,"style",o)},i:B,o:B,d(s){s&&w(e)}}}function l2(n,e,t){let{text:r}=e,{label:o}=e,{color:s}=e;return n.$$set=i=>{"text"in i&&t(0,r=i.text),"label"in i&&t(1,o=i.label),"color"in i&&t(2,s=i.color)},[r,o,s]}var Qp=class extends z{constructor(e){super(),W(this,e,l2,a2,j,{text:0,label:1,color:2},i2)}},gv=Qp;var Zp=class{constructor(e,t){this.el=e,this.mutationObserver=new MutationObserver((r,o)=>{for(let s of r)s.type==="childList"&&e.nextSibling&&(t(e),o.disconnect())}),this.mutationObserver.observe(e.parentElement,{childList:!0,subtree:!0})}destroy(){var e;(e=this.mutationObserver)==null||e.disconnect(),this.mutationObserver=null}},Cn=class{visitFolder(e,t,r,o){return null}visitFile(e,t,r,o){return null}},Xp=class{constructor(e,t){this.el=e,this.sharedFolder=t,this.siblingWatcher=new Zp(this.el,r=>{this.add()}),this.add()}add(){var e;(e=this.el.nextSibling)==null||e.addClass("system3-live")}remove(){var e;(e=this.el.nextSibling)==null||e.removeClass("system3-live")}destroy(){this.siblingWatcher.destroy(),this.remove()}},em=class extends Cn{visitFolder(e,t,r,o){return o&&o.path===e.path?r||new Xp(t.selfEl,o):(r&&r.destroy(),null)}},tm=class{constructor(e,t){this.sharedFolder=t;let r=e.querySelectorAll(".system3-folder-icons");r.length>1&&(r==null||r.forEach(s=>{s.remove()})),this.el=e,this.el.addClass("system3-pill"),this.pill=new mv({target:this.el,props:{status:this.sharedFolder.state.status,relayId:this.sharedFolder.relayId,remote:this.sharedFolder.remote,progress:0,syncStatus:"pending"}});let o=[];o.push(this.sharedFolder.subscribe(this.el,s=>{this.pill.$set({status:s.status,relayId:this.sharedFolder.relayId,remote:this.sharedFolder.remote})})),o.push(this.sharedFolder.backgroundSync.subscribeToGroupProgress(this.sharedFolder,s=>{s&&this.pill.$set({progress:s.percent,syncStatus:s.status})})),this.unsubscribe=()=>o.forEach(s=>s())}destroy(){this.pill.$destroy(),this.unsubscribe(),this.el.removeClass("system3-pill")}},rm=class extends Cn{visitFolder(e,t,r,o){return o&&o.path===e.path?r||new tm(t.selfEl,o):(r&&r.destroy(),null)}},om=class{constructor(e,t,r,o){this.el=e;this.path=t;this.activeSync=r;this.activeDownloads=o;this.unsubscribers=[];this.titleEl=e.querySelector(".nav-file-title")||e,this.unsubscribers.push(this.activeSync.subscribe(()=>this.checkStatus()),this.activeDownloads.subscribe(()=>this.checkStatus())),this.checkStatus()}checkStatus(){let e=this.activeSync.some(r=>r.path===this.path),t=this.activeDownloads.some(r=>r.path===this.path);e?this.titleEl.addClass("system3-syncing"):this.titleEl.removeClass("system3-syncing"),t?this.titleEl.addClass("system3-downloading"):this.titleEl.removeClass("system3-downloading")}destroy(){this.titleEl.removeClass("system3-uploading"),this.titleEl.removeClass("system3-downloading"),this.unsubscribers.forEach(e=>e())}},nm=class extends Cn{constructor(t,r){super();this.activeSync=t;this.activeDownloads=r}visitFile(t,r,o,s){return s&&s.ready&&s.checkPath(t.path)&&Mt.checkExtension(t.path)?o||new om(r.el,t.path,this.activeSync,this.activeDownloads):(o&&o.destroy(),null)}},sm=class{constructor(e,t){this.el=e;this.file=t;this.unsubscribes=[];this.el.querySelectorAll(".system3-uploadpill").forEach(r=>{r.remove()}),this.unsubscribes.push(this.file.subscribe(()=>{this.setText()}))}setText(){var e;if(this.file){if(this.file.inMeta){(e=this.pill)==null||e.$destroy();return}this.pill?this.pill.$set({text:this.file.tag}):this.pill=new gv({target:this.el,props:{text:this.file.tag}})}}destroy(){var e;this.unsubscribes.forEach(t=>t()),this.el.querySelectorAll(".system3-uploadpill").forEach(t=>{t.remove()}),(e=this.pill)==null||e.$destroy(),this.file=null}},im=class extends Cn{visitFile(e,t,r,o){if(o&&!Mt.checkExtension(e.path)&&!Vt.checkExtension(e.path)&&o.isSyncableTFile(e)&&o.ready&&o.connected)try{let s=o.proxy.viewSyncFile(e.path);if(s&&mr(s))return r&&r.file===s?r:new sm(t.selfEl,s)}catch(s){Te("FilePillVisitor.visitFile","error")(s)}return r&&r.destroy(),null}},am=class{constructor(e){this.el=e;this.el.querySelectorAll(".system3-filepill").forEach(t=>{t.remove()}),this.pill=new hv({target:this.el,props:{text:"NOT SYNCED",label:"Syncing this file type is disabled"}})}destroy(){this.pill.$destroy(),this.el.querySelectorAll(".system3-filepill").forEach(e=>{e.remove()})}},lm=class extends Cn{visitFile(e,t,r,o){return o&&o.checkPath(e.path)&&!o.isSyncableTFile(e)?r||new am(t.selfEl):(r&&r.destroy(),null)}},cm=class{constructor(e,t,r){this.el=e,this.document=t,this.document.subscribe(e,o=>{this.docStatus(o)}),this.docStatus(this.document.state)}docStatus(e){(e==null?void 0:e.status)==="connected"?(this.el.removeClass("system3-connecting"),this.el.addClass("system3-connected"),this.el.addClass("system3-live")):(e==null?void 0:e.status)==="connecting"?(this.el.removeClass("system3-connected"),this.el.addClass("system3-connecting"),this.el.addClass("system3-live")):(e==null?void 0:e.status)==="disconnected"?(this.el.addClass("system3-live"),this.el.removeClass("system3-connected"),this.el.removeClass("system3-connecting")):(this.el.removeClass("system3-connected"),this.el.removeClass("system3-connecting"),this.el.removeClass("system3-live"))}destroy(){var e;(e=this.document)==null||e.unsubscribe(this.el),this.docStatus()}},um=class extends Cn{visitFile(e,t,r,o){if(o)try{let s=o.getVirtualPath(e.path),i=o.syncStore.get(s);if(!i)return null;let a=o.files.get(i);return!(a instanceof Mt)||!a?null:r||new cm(t.el,a,e)}catch(s){return null}return r&&r.destroy(),null}},Ec=class{constructor(e,t,r){this.fileExplorer=e,this.sharedFolders=t,this.visitors=r,this.storage=new Map;for(let o of this.visitors)this.storage.set(o,new Map)}_getFileExplorerItem(e){try{return this.fileExplorer.view.fileItems[e]}catch(t){return null}}getFileExplorerItem(e,t){return typeof t=="string"?this._getFileExplorerItem(t):this._getFileExplorerItem(t.path)}walk(e,t){if(this.fileExplorer.view.getViewType()!=="file-explorer")return;let r=this.sharedFolders.find(s=>s.path===e.path)||t,o=this.getFileExplorerItem(this.fileExplorer,e);o&&this.storage.forEach((s,i)=>{let a=s.get(o),l=i.visitFolder(e,o,a,r);a&&!l?s.delete(o):l&&s.set(o,l)}),e.children.forEach(s=>{if(s instanceof oi.TFolder)this.walk(s,r);else if(s instanceof oi.TFile){let i=this.getFileExplorerItem(this.fileExplorer,s);if(!i)return;this.storage.forEach((a,l)=>{let c=a.get(i),u=l.visitFile(s,i,c,r);c&&!u?a.delete(i):u&&a.set(i,u)})}})}destroy(){this.storage.forEach(e=>{e.forEach(t=>{t.destroy()})})}},Pc=class{constructor(e,t,r,o){this.layoutReady=!1;this.vault=e,this.workspace=t,this.sharedFolders=r,this.backgroundSync=o,this.treeState=new Map,this.workspace.onLayoutReady(()=>{this.layoutReady=!0,this.refresh()}),this.unsubscribes=[],this.unsubscribes.push(o.activeSync.subscribe(()=>this.quickRefresh()),o.activeDownloads.subscribe(()=>this.quickRefresh()),o.syncGroups.subscribe(()=>this.quickRefresh())),this.offDocumentListeners=new Map,this.offFolderListener=this.sharedFolders.subscribe(()=>{this.sharedFolders.forEach(s=>{Py([Vo.enableDocumentStatus],()=>{this.offDocumentListeners.get(s)||this.offDocumentListeners.set(s,s.fset.on(()=>{this.refresh()}))}),s.whenReady().then(()=>{this.refresh()}),this.unsubscribes.push(s.syncSettingsManager.subscribe(i=>{this.quickRefresh()})),this.unsubscribes.push(s.subscribe(this,()=>{this.quickRefresh()})),this.unsubscribes.push(s.syncStore.subscribe(i=>{this.quickRefresh()}))}),this.refresh()}),this.offLayoutChange=(()=>{let s=this.workspace.on("layout-change",()=>this.quickRefresh());return()=>{this.workspace.offref(s)}})()}makeVisitors(){let e=[];return e.push(new em),e.push(new rm),mn(Vo.enableDocumentStatus,()=>{e.push(new um),e.push(new nm(this.backgroundSync.activeSync,this.backgroundSync.activeDownloads))}),e.push(new im),e.push(new lm),e}getFileExplorers(){let e=[];return this.workspace.iterateAllLeaves(t=>{t.view.getViewType()==="file-explorer"&&(e.includes(t)||e.push(t))}),e}quickRefresh(){if(!this.layoutReady)return;let e=this.getFileExplorers(),t=this.sharedFolders.map(r=>r.path);for(let r of e){let o=this.treeState.get(r)||new Ec(r,this.sharedFolders,this.makeVisitors());this.treeState.set(r,o);for(let s of t){let i=this.vault.getAbstractFileByPath(s);i instanceof oi.TFolder&&o.walk(i)}}}refresh(){if(!this.layoutReady)return;let e=this.getFileExplorers();for(let t of e){let r=this.treeState.get(t)||new Ec(t,this.sharedFolders,this.makeVisitors());this.treeState.set(t,r);let o=this.vault.getAbstractFileByPath("/");o instanceof oi.TFolder&&r.walk(o)}}destroy(){var e;(e=this.offFolderListener)==null||e.call(this),this.offDocumentListeners.forEach(t=>t()),this.offDocumentListeners.clear(),this.unsubscribes.forEach(t=>t()),this.unsubscribes.length=0,this.treeState.forEach(t=>{t.destroy()}),this.treeState.clear(),this.offLayoutChange(),this.vault=null,this.workspace=null,this.sharedFolders=null,this.backgroundSync=null,this.offFolderListener=null}};var o_=require("obsidian");var Ar=require("obsidian");function c2(n){let e,t,r;return{c(){e=Qt("svg"),t=Qt("g"),r=Qt("path"),h(r,"d","M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z"),h(r,"fill","#5865F2"),h(r,"fill-rule","nonzero"),h(e,"width",n[0]),h(e,"height",n[0]),h(e,"viewBox","0 -28.5 256 256"),h(e,"version","1.1"),h(e,"xmlns","http://www.w3.org/2000/svg"),h(e,"xmlns:xlink","http://www.w3.org/1999/xlink"),h(e,"preserveAspectRatio","xMidYMid")},m(o,s){_(o,e,s),b(e,t),b(t,r)},p(o,[s]){s&1&&h(e,"width",o[0]),s&1&&h(e,"height",o[0])},i:B,o:B,d(o){o&&w(e)}}}function u2(n,e,t){let{size:r="1em"}=e;return n.$$set=o=>{"size"in o&&t(0,r=o.size)},[r]}var fm=class extends z{constructor(e){super(),W(this,e,u2,c2,j,{size:0})}},Dc=fm;function f2(n){we(n,"svelte-4t8k3t",`.menu-container.svelte-4t8k3t{display:inline-block;position:relative}.menu-button.svelte-4t8k3t{box-shadow:none;padding:8px;border:none;background:transparent;color:var(--text-muted)}.menu-button.svelte-4t8k3t:hover{color:var(--icon-color-hover)}.menu-button.svelte-4t8k3t:focus{color:var(--icon-color-focus)}.menu-dropdown.svelte-4t8k3t{position:absolute;right:0;margin-top:8px;width:224px;background:var(--color-base-10);border-radius:6px;box-shadow:0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
|
0 2px 4px -1px rgba(0, 0, 0, 0.06);border:1px solid rgba(0, 0, 0, 0.1)}.arrow.svelte-4t8k3t{position:absolute;top:-5px;right:12px;width:10px;height:10px;background:var(--color-base-10);border-left:1px solid rgba(0, 0, 0, 0.1);border-top:1px solid rgba(0, 0, 0, 0.1);transform:rotate(45deg)}.menu-content.svelte-4t8k3t{display:flex;flex-direction:column;gap:8px;padding:8px}.menu-item.svelte-4t8k3t{display:flex;width:100%;align-items:center;gap:12px;padding:8px;border-radius:4px;text-decoration:none;color:var(--text-muted);transition:background-color 0.2s;font-size:14px}.menu-item.svelte-4t8k3t:hover{background-color:var(--background-modifier-hover)}.menu-item.svelte-4t8k3t:focus{background-color:var(--background-modifier-hover)}`)}function yv(n){let e,t,r,o,s,i,a,l,c,u,f,d,p;return a=new Dc({props:{size:20}}),{c(){e=x("div"),t=x("div"),r=T(),o=x("div"),s=x("span"),i=x("a"),P(a.$$.fragment),l=T(),c=x("span"),c.textContent="Join the community",h(t,"class","arrow svelte-4t8k3t"),h(i,"href","https://discord.system3.md"),h(i,"target","_blank"),h(i,"rel","noopener noreferrer"),h(i,"class","menu-item svelte-4t8k3t"),se(s,"text-align","center"),se(s,"display","flex"),h(o,"class","menu-content svelte-4t8k3t"),h(e,"class","menu-dropdown svelte-4t8k3t")},m(m,y){_(m,e,y),b(e,t),b(e,r),b(e,o),b(o,s),b(s,i),A(a,i,null),b(i,l),b(i,c),f=!0,d||(p=zn(u=n[1].call(null,e)),d=!0)},i(m){f||(v(a.$$.fragment,m),f=!0)},o(m){k(a.$$.fragment,m),f=!1},d(m){m&&w(e),F(a),d=!1,p()}}}function d2(n){let e,t,r,o,s,i,a;r=new bp({props:{size:"20px"}});let l=n[0]&&yv(n);return{c(){e=x("div"),t=x("button"),P(r.$$.fragment),o=T(),l&&l.c(),h(t,"class","menu-button svelte-4t8k3t"),h(e,"class","menu-container svelte-4t8k3t")},m(c,u){_(c,e,u),b(e,t),A(r,t,null),b(e,o),l&&l.m(e,null),s=!0,i||(a=$(t,"click",rc(n[2])),i=!0)},p(c,[u]){c[0]?l?u&1&&v(l,1):(l=yv(c),l.c(),v(l,1),l.m(e,null)):l&&(ee(),k(l,1,1,()=>{l=null}),te())},i(c){s||(v(r.$$.fragment,c),v(l),s=!0)},o(c){k(r.$$.fragment,c),k(l),s=!1},d(c){c&&w(e),F(r),l&&l.d(),i=!1,a()}}}function p2(n,e,t){let r=!1;function o(i){let a=l=>{let c=document.querySelector(".menu-button");!i.contains(l.target)&&l.target!==c&&!(c!=null&&c.contains(l.target))&&t(0,r=!1)};return setTimeout(()=>{document.addEventListener("click",a)},0),{destroy(){document.removeEventListener("click",a)}}}function s(i){i.stopPropagation(),t(0,r=!r)}return[r,o,s]}var dm=class extends z{constructor(e){super(),W(this,e,p2,d2,j,{},f2)}},bv=dm;function m2(n){we(n,"svelte-ycfe1d",".relay-text.svelte-ycfe1d{fill:var(--text-normal)}")}function h2(n){let e,t;return{c(){e=Qt("svg"),t=Qt("path"),h(t,"d","m112.88679 65.94517c-1.8219-.6498-2.8316-1.9996-2.8205-3.7707.019-2.9692 4.2679-9.1564 8.5532-12.4538.8896-.6846 3.2865-2.0796 5.3264-3.1002l3.7089-1.8555 1.1034-2.1157c.6069-1.1636 1.0788-2.1403 1.0487-2.1704-.03-.03-.7517.2969-1.6037.7266-1.7893.9026-3.4923 1.0179-5.6348.3816-1.2664-.376-2.6971-1.5724-3.0511-2.5512-.1036-.2865-.2262-.2926-.6259-.031-1.6133 1.0551-3.9805 2.2931-5.3124 2.7783-3.2045 1.1672-7.1579.5507-8.5509-1.3335l-.5903-.7983-1.2238.7491c-3.1246 1.9126-7.5052 2.5576-9.6905 1.4268-1.3209-.6835-2.1336-1.8529-2.3663-3.405-.099-.6587-.2706-1.1976-.3819-1.1976-.1112 0-.4909.3082-.8437.685-1.1393 1.2168-4.3891 3.211-6.2437 3.8314-4.3168 1.4441-8.0424.1949-8.8532-2.9684-.1823-.7114-.3977-1.2593-.4786-1.2177-8.2088 4.2188-13.1666 5.5617-17.3451 4.6983-7.2318-1.4943-8.5363-7.633-3.2721-15.3969 3.43-5.0586 8.1226-8.1393 12.5368-8.2303 4.2661-.088 6.1851 2.8612 4.6067 7.0798-1.4639 3.9129-6.6553 7.7738-11.3995 8.4781l-1.2322.183-.173.9219c-.2449 1.3054.055 2.3726.8414 2.9909 1.4773 1.162 5.3481.4499 9.169-1.6869 4.0877-2.286 9.2494-6.7459 10.2254-8.8353 2.1729-4.6512 10.3391-19.4528 12.6199-22.8741 1.9649-2.9472 2.9544-3.913 4.6877-4.575 2.2454-.8575 3.8556.1204 3.8556 2.3418 0 1.0627-.8749 2.8756-5.2398 10.8581-4.5459 8.3134-10.5554 20.346-10.9601 21.9446-.372 1.4696-.093 1.8547 1.0954 1.5137 3.1691-.9088 8.5727-5.615 10.728-9.3431 3.192-5.5215 7.5241-8.5901 12.516-8.8657 1.3396-.074 2.6532.01 3.3914.2166 1.585.4437 3.5318 2.2009 3.7762 3.4083.1003.4954.3584.9822.5736 1.0817 1.6112.7453 1.9862 1.0047 2.0682 1.4307.051.2665-.9529 2.6236-2.2318 5.238-1.8799 3.8432-2.328 4.9899-2.3404 5.9886l-.015 1.2352.9261.077c1.132.094 3.2883-1.1349 5.6894-3.243 2.3304-2.0459 3.4794-3.659 6.2257-8.7403 1.3371-2.4739 2.6529-4.8096 2.924-5.1906.7068-.9931 1.8337-1.3742 3.6712-1.2413 1.7839.1291 2.6563.7039 2.6563 1.7502 0 .3631-1.6536 3.8273-3.6747 7.698-3.6147 6.9231-4.2241 8.2285-3.8408 8.2285.3864 0 2.6593-1.4351 4.2082-2.6571 2.9724-2.3449 4.1289-3.8334 6.7129-8.64 3.2167-5.9836 4.0513-6.6961 7.4599-6.3685 1.5037.1444 2.3637.7781 2.3637 1.7416 0 .6971-3.7642 8.1283-7.3844 14.5783-1.1774 2.0975-2.1406 3.9288-2.1406 4.0695 0 1.0032 6.4569-2.0079 10.373-4.8373 1.75083-1.265 2.80833-1.8553 3.32363-1.8553.8396 0 1.9138.8456 1.9138 1.5065 0 1.6136-6.83683 5.3607-15.31743 8.3952l-3.0144 1.0785-3.1147 4.959c-6.6125 10.5277-11.2414 15.4863-16.0267 17.1682-1.6492.5797-2.5036.6042-3.8855.1114zm3.4676-4.0874c2.3533-1.2035 5.0029-4.3759 7.0335-8.4211 1.4729-2.9341 1.2858-3.2801-1.0497-1.9405-2.6054 1.4944-6.0792 5.1835-7.6115 8.0833-1.3391 2.5343-.6792 3.458 1.6277 2.2783zm-13.7433-25.7067c2.0798-1.3888 2.707-2.2251 5.1929-6.9235 1.1337-2.1427 2.4702-4.3736 2.9701-4.9576.4999-.5839.8343-1.1823.7432-1.3297-.3028-.49-1.5733-.2724-2.9201.5001-3.9 2.237-10.6318 12.1845-9.2087 13.6076.4489.4489 1.7491.087 3.2226-.8969zm-39.6413-6.7383c1.4951-.7532 3.4914-2.3885 4.373-3.5822.8778-1.1886.8303-2.7169-.089-2.8472-.9504-.1348-2.84 1.147-4.3353 2.9408-1.4368 1.7237-2.8652 3.8321-2.8652 4.2293 0 .3431 1.5421-.048 2.916-.7407zm-15.7519 34.9397c-7.7618-1.6901-14.6809-7.6649-17.3519-14.9834-1.0082-2.7626-2.5946-8.8926-3.6898-14.2584-.7621-3.7334-1.4567-5.8195-2.0623-6.1938-.1258-.078-.173.4384-.1049 1.147l.1238 1.2883-2.6916 5.648c-3.9954 8.3841-5.3958 10.566-7.4555 11.6168-1.4222.7256-3.7417.6896-5.2712-.082-1.0729-.541-1.1779-.6797-1.1514-1.5213.017-.5465.8143-2.6067 1.945-5.0271 3.1568-6.7568 12.4018-25.1754 13.3068-26.5105 1.1089-1.6358 2.3136-2.186 4.3772-1.9989 1.8988.1722 3.7575 1.0556 3.7575 1.7858 0 .685-.9801 3.23-2.4839 6.4499-.6712 1.437-1.2203 2.6574-1.2203 2.712 0 .2508 2.423.059 3.8048-.3005 2.1083-.5492 3.5885-1.4764 5.2895-3.3138 2.9831-3.2221 3.5133-7.5609 1.1835-9.6842-3.8351-3.4952-12.7275-2.9971-21.5226 1.2055-6.4797 3.0962-10.7971 8.141-11.8606 13.8587-.5183 2.7868-1.354 3.618-2.8384 2.8236-2.234-1.1956-1.5337-5.997 1.651-11.3196 5.1483-8.6044 15.656-14.9768 26.6996-16.192 9.3582-1.0298 17.2345 3.5198 17.8697 10.322.3469 3.7147-1.5827 8.0493-5.1855 11.6487-2.6104 2.6078-4.969 3.9861-7.9877 4.6679l-1.94.4381.8512.2875c1.5709.5307 1.8619 1.0923 3.1019 5.988 2.5245 9.9665 4.9471 14.9264 9.4592 19.3659 6.055 5.9576 14.0611 6.1192 19.4354.3922.7131-.7598 2.2084-2.7055 3.323-4.3238 1.1145-1.6182 2.2218-3.0172 2.4606-3.1088 2.1176-.8126 2.9615 1.5236 1.6137 4.4675-2.2327 4.877-6.6161 9.1629-11.4944 11.2387-4.1481 1.7652-9.8251 2.3621-13.9414 1.4657z"),h(e,"class","relay-text svelte-ycfe1d"),h(e,"width",n[0]),h(e,"height",n[1]),h(e,"viewBox","0 0 154.24573 66.293579"),h(e,"xmlns","http://www.w3.org/2000/svg")},m(r,o){_(r,e,o),b(e,t)},p:B,i:B,o:B,d(r){r&&w(e)}}}function g2(n,e,t){let{size:r=64}=e,o=r,s=r/2;return n.$$set=i=>{"size"in i&&t(2,r=i.size)},[o,s,r]}var pm=class extends z{constructor(e){super(),W(this,e,g2,h2,j,{size:2},m2)}},Rc=pm;function y2(n){we(n,"svelte-120r7kg",".subtitle.svelte-120r7kg{color:var(--text-muted);font-size:1.25rem;margin:0}.description.svelte-120r7kg{color:var(--text-muted);font-size:1rem;max-width:480px;margin:0}")}function b2(n){let e,t,r,o,s,i;return e=new Rc({props:{size:140}}),{c(){P(e.$$.fragment),t=T(),r=x("p"),r.textContent="Real-time collaboration in Obsidian",o=T(),s=x("p"),s.textContent=`Share folders with your team, edit together in real time, and keep your
|
|
knowledge library exactly how you want it.`,h(r,"class","subtitle svelte-120r7kg"),h(s,"class","description svelte-120r7kg")},m(a,l){A(e,a,l),_(a,t,l),_(a,r,l),_(a,o,l),_(a,s,l),i=!0},p:B,i(a){i||(v(e.$$.fragment,a),i=!0)},o(a){k(e.$$.fragment,a),i=!1},d(a){a&&(w(t),w(r),w(o),w(s)),F(e,a)}}}var mm=class extends z{constructor(e){super(),W(this,e,null,b2,j,{},y2)}},vv=mm;var Uc=require("obsidian");function v2(n){we(n,"svelte-1rfjxfa",`.help-section.svelte-1rfjxfa{width:100%;padding:0 2rem;margin-bottom:2rem}.footer.svelte-1rfjxfa{padding:0 2rem;margin-bottom:2rem;text-align:center}.help-container.svelte-1rfjxfa{position:relative;max-width:640px;margin:0 auto}.why-signin.svelte-1rfjxfa:hover{background-color:transparent !important;box-shadow:none;color:var(--text-modifier-hover)}.why-signin.svelte-1rfjxfa{outline:0;color:var(--text-muted);font-size:0.875rem;margin:0;background-color:transparent !important;box-shadow:none;text-decoration-line:var(--link-decoration);padding:0;border:none;cursor:pointer;width:100%;text-align:left}.why-signin.svelte-1rfjxfa:hover{color:var(--text-normal)}.help-content.svelte-1rfjxfa{margin-top:8px;padding:12px 16px;background:var(--color-base-05);border-radius:4px;font-size:0.9em;color:var(--text-muted);box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.1);text-align:left}.popover.svelte-1rfjxfa{position:absolute;z-index:50;width:256px;padding-left:1em;padding-right:1em;font-size:0.875rem;background-color:var(--background-primary);border:1px solid var(--background-modifier-border);border-radius:4px;box-shadow:var(--shadow-s);top:calc(100% + 8px);text-align:left;left:50%;transform:translateX(-50%);opacity:0;visibility:hidden;transition:opacity 0.3s ease,
|
|
visibility 0.3s ease;transition-delay:0.1s}.popover.visible.svelte-1rfjxfa{opacity:1;visibility:visible}.popover.svelte-1rfjxfa:not(.visible){transition-delay:0s}.arrow.svelte-1rfjxfa{position:absolute;width:8px;height:8px;background-color:var(--background-primary);border-top:1px solid var(--background-modifier-border);border-left:1px solid var(--background-modifier-border);transform:rotate(45deg);top:-5px;right:40px}.discord-link.svelte-1rfjxfa{display:inline-flex;align-items:center;justify-content:center;gap:0.5rem;color:var(--text-muted);font-size:0.875rem;margin:0}`)}function x2(n){let e,t,r,o;return{c(){e=x("div"),t=x("div"),r=T(),o=x("p"),o.textContent=`${wv}`,h(t,"class","arrow svelte-1rfjxfa"),h(e,"class","popover svelte-1rfjxfa"),_e(e,"visible",n[0])},m(s,i){_(s,e,i),b(e,t),b(e,r),b(e,o),n[9](e)},p(s,i){i&1&&_e(e,"visible",s[0])},d(s){s&&w(e),n[9](null)}}}function w2(n){let e,t=n[0]&&xv(n);return{c(){t&&t.c(),e=ue()},m(r,o){t&&t.m(r,o),_(r,e,o)},p(r,o){r[0]?t?t.p(r,o):(t=xv(r),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},d(r){r&&w(e),t&&t.d(r)}}}function xv(n){let e,t;return{c(){e=x("div"),t=x("p"),t.textContent=`${wv}`,h(e,"class","help-content svelte-1rfjxfa")},m(r,o){_(r,e,o),b(e,t)},p:B,d(r){r&&w(e)}}}function _2(n){let e,t,r,o,s,i,a,l,c,u,f,d;function p(g,I){return g[1]?w2:x2}let m=p(n,-1),y=m(n);return l=new Dc({}),{c(){e=x("div"),t=x("div"),r=x("button"),r.textContent="Why do I need to sign in?",o=T(),y.c(),s=T(),i=x("div"),a=x("a"),P(l.$$.fragment),c=V(`
|
|
Join the project on Discord`),h(r,"class","why-signin svelte-1rfjxfa"),_e(r,"mobile",n[1]),h(t,"class","help-container svelte-1rfjxfa"),h(e,"class","help-section svelte-1rfjxfa"),h(a,"href","https://discord.system3.md"),h(a,"class","discord-link svelte-1rfjxfa"),h(i,"class","footer svelte-1rfjxfa")},m(g,I){_(g,e,I),b(e,t),b(t,r),n[8](r),b(t,o),y.m(t,null),_(g,s,I),_(g,i,I),b(i,a),A(l,a,null),b(a,c),u=!0,f||(d=[$(r,"mouseenter",n[4]),$(r,"mouseleave",n[5]),$(r,"click",n[6])],f=!0)},p(g,[I]){(!u||I&2)&&_e(r,"mobile",g[1]),m===(m=p(g,I))&&y?y.p(g,I):(y.d(1),y=m(g),y&&(y.c(),y.m(t,null)))},i(g){u||(v(l.$$.fragment,g),u=!0)},o(g){k(l.$$.fragment,g),u=!1},d(g){g&&(w(e),w(s),w(i)),n[8](null),y.d(),F(l),f=!1,me(d)}}}var wv="We require sign-in because your vault needs to communicate securely with Relay servers for syncing. Using an identity provider helps to prevent spam accounts and ensures secure authentication.";function S2(n,e,t){var r;let o=!1,s=!1,i,a;function l(){s||t(0,o=!0)}function c(){s||t(0,o=!1)}function u(){s&&t(0,o=!o)}function f(p){pt[p?"unshift":"push"](()=>{i=p,t(2,i)})}function d(p){pt[p?"unshift":"push"](()=>{a=p,t(3,a)})}return n.$$.update=()=>{n.$$.dirty&128&&t(1,s=t(7,r=Uc.Platform===null||Uc.Platform===void 0?void 0:Uc.Platform.isMobile)!==null&&r!==void 0?r:!1)},[o,s,i,a,l,c,u,r,f,d]}var hm=class extends z{constructor(e){super(),W(this,e,S2,_2,j,{},v2)}},_v=hm;var $G=require("obsidian");function k2(n){we(n,"svelte-zlums1",".setting-item-control.svelte-zlums1{width:unset !important;margin-top:unset !important}.setting-item.svelte-zlums1{flex-direction:unset !important;align-items:flex-start}.setting-item-info.svelte-zlums1{min-width:0;margin-top:auto;margin-bottom:auto}")}function I2(n){let e,t,r,o,s,i=(n[0].name||"")+"",a,l,c,u,f=(n[0].email||"")+"",d,p,m,y;t=new fa({props:{size:"2.5em",user:n[0]}});let g=n[2].default,I=ye(g,n,n[1],null);return{c(){e=x("div"),P(t.$$.fragment),r=T(),o=x("div"),s=x("div"),a=V(i),l=T(),c=x("br"),u=T(),d=V(f),p=T(),m=x("div"),I&&I.c(),h(s,"class","setting-item-description"),h(o,"class","setting-item-info svelte-zlums1"),se(o,"display","grid"),h(m,"class","setting-item-control svelte-zlums1"),h(e,"class","setting-item svelte-zlums1")},m(L,C){_(L,e,C),A(t,e,null),b(e,r),b(e,o),b(o,s),b(s,a),b(s,l),b(s,c),b(s,u),b(s,d),b(e,p),b(e,m),I&&I.m(m,null),y=!0},p(L,[C]){let S={};C&1&&(S.user=L[0]),t.$set(S),(!y||C&1)&&i!==(i=(L[0].name||"")+"")&&J(a,i),(!y||C&1)&&f!==(f=(L[0].email||"")+"")&&J(d,f),I&&I.p&&(!y||C&2)&&ve(I,g,L,L[1],y?be(g,L[1],C,null):xe(L[1]),null)},i(L){y||(v(t.$$.fragment,L),v(I,L),y=!0)},o(L){k(t.$$.fragment,L),k(I,L),y=!1},d(L){L&&w(e),F(t),I&&I.d(L)}}}function C2(n,e,t){let{$$slots:r={},$$scope:o}=e,{user:s}=e;return n.$$set=i=>{"user"in i&&t(0,s=i.user),"$$scope"in i&&t(1,o=i.$$scope)},[s,o,r]}var gm=class extends z{constructor(e){super(),W(this,e,C2,I2,j,{user:0},k2)}},ni=gm;var Oc=require("obsidian");function L2(n){we(n,"svelte-1da9go9",".help-container.svelte-1da9go9.svelte-1da9go9{position:relative;display:inline-block}button.svelte-1da9go9.svelte-1da9go9{display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:2px;margin:0;background:transparent;border:none;color:var(--text-muted);box-shadow:none;border-radius:50%}button.svelte-1da9go9.svelte-1da9go9:hover{box-shadow:none;color:var(--icon-color-hover);opacity:var(--icon-opacity-hover);background-color:transparent;border-radius:0}button.svelte-1da9go9.svelte-1da9go9:focus{outline:none;box-shadow:none;color:var(--icon-color-focus)}.help-container.svelte-1da9go9>.popover.svelte-1da9go9{position:absolute;z-index:70;width:256px;padding:8px;font-size:0.875rem;background-color:var(--background-primary);border:1px solid var(--background-modifier-border);border-radius:4px;box-shadow:var(--shadow-s);top:32px;transition-delay:0.1s}.help-container.svelte-1da9go9>.popover.left.svelte-1da9go9{right:100%;margin-right:8px}.help-container.svelte-1da9go9>.popover.right.svelte-1da9go9{left:0}.arrow.svelte-1da9go9.svelte-1da9go9{position:absolute;width:8px;height:8px;background-color:var(--background-primary);border-top:1px solid var(--background-modifier-border);border-left:1px solid var(--background-modifier-border);transform:rotate(45deg);top:-5px}.arrow.left.svelte-1da9go9.svelte-1da9go9{right:8px}.arrow.right.svelte-1da9go9.svelte-1da9go9{left:8px}p.svelte-1da9go9.svelte-1da9go9{margin:0;color:var(--text-normal)}")}function Sv(n){let e,t,r,o,s;return{c(){e=x("div"),t=x("div"),r=T(),o=x("p"),s=V(n[0]),h(t,"class","arrow svelte-1da9go9"),_e(t,"left",n[4]==="left"),_e(t,"right",n[4]==="right"),h(o,"class","svelte-1da9go9"),h(e,"class","popover svelte-1da9go9"),_e(e,"left",n[4]==="left"),_e(e,"right",n[4]==="right")},m(i,a){_(i,e,a),b(e,t),b(e,r),b(e,o),b(o,s),n[9](e)},p(i,a){a&16&&_e(t,"left",i[4]==="left"),a&16&&_e(t,"right",i[4]==="right"),a&1&&J(s,i[0]),a&16&&_e(e,"left",i[4]==="left"),a&16&&_e(e,"right",i[4]==="right")},d(i){i&&w(e),n[9](null)}}}function M2(n){let e,t,r,o,s,i,a;r=new sa({props:{size:16}});let l=n[1]&&Sv(n);return{c(){e=x("div"),t=x("button"),P(r.$$.fragment),o=T(),l&&l.c(),h(t,"type","button"),h(t,"class","svelte-1da9go9"),h(e,"class","help-container svelte-1da9go9")},m(c,u){_(c,e,u),b(e,t),A(r,t,null),n[8](t),b(e,o),l&&l.m(e,null),s=!0,i||(a=[$(t,"mouseenter",n[5]),$(t,"mouseleave",n[6]),$(t,"click",n[7])],i=!0)},p(c,[u]){c[1]?l?l.p(c,u):(l=Sv(c),l.c(),l.m(e,null)):l&&(l.d(1),l=null)},i(c){s||(v(r.$$.fragment,c),s=!0)},o(c){k(r.$$.fragment,c),s=!1},d(c){c&&w(e),F(r),n[8](null),l&&l.d(),i=!1,me(a)}}}function T2(n,e,t){let{helpText:r}=e,o=!1,s="right",i,a;function l(){t(1,o=!0)}function c(){t(1,o=!1)}function u(){t(1,o=!o)}function f(p){pt[p?"unshift":"push"](()=>{i=p,t(2,i)})}function d(p){pt[p?"unshift":"push"](()=>{a=p,t(3,a)})}return n.$$set=p=>{"helpText"in p&&t(0,r=p.helpText)},n.$$.update=()=>{if(n.$$.dirty&14&&o&&i&&a){let p=i.getBoundingClientRect(),m=a.getBoundingClientRect(),y=window.innerWidth;t(4,s=p.right+m.width>y-20?"left":"right")}},[r,o,i,a,s,l,c,u,f,d]}var ym=class extends z{constructor(e){super(),W(this,e,T2,M2,j,{helpText:0},L2)}},kv=ym;function A2(n){we(n,"svelte-5o4y9d",".setting-item-name.svelte-5o4y9d{display:flex;align-items:center;gap:8px;overflow:unset}.help-button.svelte-5o4y9d{display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:2px !important;margin:0;background:transparent;border:none;color:var(--text-muted);border-radius:50%;-webkit-tap-highlight-color:transparent}@media(hover: hover){.help-button.svelte-5o4y9d:hover{box-shadow:none;color:var(--text-normal);background:transparent;border-radius:0}}.help-button.svelte-5o4y9d:active{color:var(--text-normal)}.help-content.svelte-5o4y9d{margin-top:8px;padding:12px 16px;background:var(--color-base-05);border-radius:4px;font-size:0.9em;color:var(--text-muted);box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.1)}p.svelte-5o4y9d{margin:0}")}var F2=n=>({}),Iv=n=>({}),E2=n=>({}),Cv=n=>({}),P2=n=>({}),Lv=n=>({});function D2(n){let e;return{c(){e=V(n[0])},m(t,r){_(t,e,r)},p(t,r){r&1&&J(e,t[0])},d(t){t&&w(e)}}}function Mv(n){let e,t,r,o,s=[U2,R2],i=[];function a(l,c){return l[3]?0:1}return e=a(n,-1),t=i[e]=s[e](n),{c(){t.c(),r=ue()},m(l,c){i[e].m(l,c),_(l,r,c),o=!0},p(l,c){let u=e;e=a(l,c),e===u?i[e].p(l,c):(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),t=i[e],t?t.p(l,c):(t=i[e]=s[e](l),t.c()),v(t,1),t.m(r.parentNode,r))},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),i[e].d(l)}}}function R2(n){let e,t;return e=new kv({props:{helpText:n[1]}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&2&&(s.helpText=r[1]),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 U2(n){let e,t,r,o,s;return t=new sa({props:{size:16}}),{c(){e=x("button"),P(t.$$.fragment),h(e,"class","help-button svelte-5o4y9d"),h(e,"aria-expanded",n[2])},m(i,a){_(i,e,a),A(t,e,null),r=!0,o||(s=$(e,"click",n[4]),o=!0)},p(i,a){(!r||a&4)&&h(e,"aria-expanded",i[2])},i(i){r||(v(t.$$.fragment,i),r=!0)},o(i){k(t.$$.fragment,i),r=!1},d(i){i&&w(e),F(t),o=!1,s()}}}function O2(n){let e,t,r=n[7].description,o=ye(r,n,n[6],Iv);return{c(){e=x("div"),o&&o.c(),h(e,"class","setting-item-description")},m(s,i){_(s,e,i),o&&o.m(e,null),t=!0},p(s,i){o&&o.p&&(!t||i&64)&&ve(o,r,s,s[6],t?be(r,s[6],i,F2):xe(s[6]),Iv)},i(s){t||(v(o,s),t=!0)},o(s){k(o,s),t=!1},d(s){s&&w(e),o&&o.d(s)}}}function Tv(n){let e,t,r;return{c(){e=x("div"),t=x("p"),r=V(n[1]),h(t,"class","svelte-5o4y9d"),h(e,"class","help-content svelte-5o4y9d"),_e(e,"expanded",n[2])},m(o,s){_(o,e,s),b(e,t),b(t,r)},p(o,s){s&2&&J(r,o[1]),s&4&&_e(e,"expanded",o[2])},d(o){o&&w(e)}}}function $2(n){let e,t,r,o,s,i,a,l,c,u=n[7].name,f=ye(u,n,n[6],Lv),d=f||D2(n),p=n[1]&&Mv(n),m=n[7].description,y=ye(m,n,n[6],Cv),g=y||O2(n),I=n[1]&&n[2]&&n[3]&&Tv(n),L=n[7].default,C=ye(L,n,n[6],null);return{c(){e=x("div"),t=x("div"),r=x("div"),d&&d.c(),o=T(),p&&p.c(),s=T(),g&&g.c(),i=T(),I&&I.c(),a=T(),l=x("div"),C&&C.c(),h(r,"class","setting-item-name svelte-5o4y9d"),h(t,"class","setting-item-info"),h(l,"class","setting-item-control"),h(e,"class","setting-item setting-item-heading mod-list-item")},m(S,M){_(S,e,M),b(e,t),b(t,r),d&&d.m(r,null),b(r,o),p&&p.m(r,null),b(t,s),g&&g.m(t,null),b(t,i),I&&I.m(t,null),b(e,a),b(e,l),C&&C.m(l,null),c=!0},p(S,[M]){f?f.p&&(!c||M&64)&&ve(f,u,S,S[6],c?be(u,S[6],M,P2):xe(S[6]),Lv):d&&d.p&&(!c||M&1)&&d.p(S,c?M:-1),S[1]?p?(p.p(S,M),M&2&&v(p,1)):(p=Mv(S),p.c(),v(p,1),p.m(r,null)):p&&(ee(),k(p,1,1,()=>{p=null}),te()),y?y.p&&(!c||M&64)&&ve(y,m,S,S[6],c?be(m,S[6],M,E2):xe(S[6]),Cv):g&&g.p&&(!c||M&64)&&g.p(S,c?M:-1),S[1]&&S[2]&&S[3]?I?I.p(S,M):(I=Tv(S),I.c(),I.m(t,null)):I&&(I.d(1),I=null),C&&C.p&&(!c||M&64)&&ve(C,L,S,S[6],c?be(L,S[6],M,null):xe(S[6]),null)},i(S){c||(v(d,S),v(p),v(g,S),v(C,S),c=!0)},o(S){k(d,S),k(p),k(g,S),k(C,S),c=!1},d(S){S&&w(e),d&&d.d(S),p&&p.d(),g&&g.d(S),I&&I.d(),C&&C.d(S)}}}function N2(n,e,t){let{$$slots:r={},$$scope:o}=e;var s;let{name:i=""}=e,{helpText:a=void 0}=e,l=!1,c=!1;function u(){c&&t(2,l=!l)}return n.$$set=f=>{"name"in f&&t(0,i=f.name),"helpText"in f&&t(1,a=f.helpText),"$$scope"in f&&t(6,o=f.$$scope)},n.$$.update=()=>{n.$$.dirty&32&&t(3,c=t(5,s=Oc.Platform===null||Oc.Platform===void 0?void 0:Oc.Platform.isMobile)!==null&&s!==void 0?s:!1)},[i,a,l,c,u,s,o,r]}var bm=class extends z{constructor(e){super(),W(this,e,N2,$2,j,{name:0,helpText:1},A2)}},Qe=bm;function B2(n){we(n,"svelte-11qoyvs",".callout.svelte-11qoyvs{mix-blend-mode:normal !important}")}function V2(n){let e,t,r,o,s,i,a,l,c,u,f=n[2].default,d=ye(f,n,n[1],null);return{c(){e=x("div"),t=x("div"),r=x("div"),r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-pencil"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"></path><path d="m15 5 4 4"></path></svg>',o=T(),s=x("div"),i=V(n[0]),a=T(),l=x("div"),c=x("p"),d&&d.c(),h(r,"class","callout-icon"),h(r,"dir","auto"),h(s,"class","callout-title-inner"),h(s,"dir","auto"),h(t,"class","callout-title"),h(t,"dir","auto"),h(c,"dir","auto"),h(l,"class","callout-content"),h(l,"dir","auto"),h(e,"data-callout-metadata",""),h(e,"data-callout-fold",""),h(e,"data-callout","callout"),h(e,"class","callout svelte-11qoyvs"),h(e,"dir","auto")},m(p,m){_(p,e,m),b(e,t),b(t,r),b(t,o),b(t,s),b(s,i),b(e,a),b(e,l),b(l,c),d&&d.m(c,null),u=!0},p(p,[m]){(!u||m&1)&&J(i,p[0]),d&&d.p&&(!u||m&2)&&ve(d,f,p,p[1],u?be(f,p[1],m,null):xe(p[1]),null)},i(p){u||(v(d,p),u=!0)},o(p){k(d,p),u=!1},d(p){p&&w(e),d&&d.d(p)}}}function H2(n,e,t){let{$$slots:r={},$$scope:o}=e,{title:s}=e;return n.$$set=i=>{"title"in i&&t(0,s=i.title),"$$scope"in i&&t(1,o=i.$$scope)},[s,o,r]}var vm=class extends z{constructor(e){super(),W(this,e,H2,V2,j,{title:0},B2)}},xm=vm;function q2(n){let e=[],t="",r=0;for(;r<n.length;)n[r]==="*"&&r+1<n.length&&n[r+1]==="*"?(t&&(e.push({type:"TEXT",value:t}),t=""),e.push({type:"DOUBLE_STAR"}),r+=2):n[r]==="*"?(t&&(e.push({type:"TEXT",value:t}),t=""),e.push({type:"STAR"}),r++):(t+=n[r],r++);return t&&e.push({type:"TEXT",value:t}),e}function j2(n){let e="",t="NORMAL",r=0;for(;r<n.length;){let o=n[r];switch(t){case"NORMAL":o.type==="TEXT"?e+=o.value:o.type==="STAR"?(t="EMPHASIS",e+="<u>"):o.type==="DOUBLE_STAR"&&(t="BOLD",e+="<strong>");break;case"EMPHASIS":o.type==="TEXT"?e+=o.value:o.type==="STAR"?(t="NORMAL",e+="</u>"):o.type==="DOUBLE_STAR"&&(t="BOLD",e+="</u><strong>");break;case"BOLD":o.type==="TEXT"?e+=o.value:o.type==="STAR"?e+="*":o.type==="DOUBLE_STAR"&&(t="NORMAL",e+="</strong>");break}r++}return t==="EMPHASIS"?e+="</u>":t==="BOLD"&&(e+="</strong>"),e}function Ln(n){let e=q2(n);return j2(e)}function Av(n){let e,t,r,o,s=n[0].networkStatus.status&&Fv(n);return{c(){e=x("div"),t=x("span"),s&&s.c(),h(t,"class","system3-announcement"),se(t,"color",n[0].networkStatus.status.color?n[0].networkStatus.status.color:"var(--text-on-accent)",1),h(e,"class","modal-setting-nav-bar system3-announcement-banner"),h(e,"role","button"),h(e,"tabindex","0"),se(e,"background-color",n[0].networkStatus.status.backgroundColor?n[0].networkStatus.status.backgroundColor:"var(--color-accent)",1)},m(i,a){_(i,e,a),b(e,t),s&&s.m(t,null),r||(o=[$(e,"click",n[2]),$(e,"keypress",n[3])],r=!0)},p(i,a){i[0].networkStatus.status?s?s.p(i,a):(s=Fv(i),s.c(),s.m(t,null)):s&&(s.d(1),s=null),a&1&&se(t,"color",i[0].networkStatus.status.color?i[0].networkStatus.status.color:"var(--text-on-accent)",1),a&1&&se(e,"background-color",i[0].networkStatus.status.backgroundColor?i[0].networkStatus.status.backgroundColor:"var(--color-accent)",1)},d(i){i&&w(e),s&&s.d(),r=!1,me(o)}}}function Fv(n){let e,t=Ln(n[0].networkStatus.status.status)+"",r;return{c(){e=new wn(!1),r=ue(),e.a=r},m(o,s){e.m(t,o,s),_(o,r,s)},p(o,s){s&1&&t!==(t=Ln(o[0].networkStatus.status.status)+"")&&e.p(t)},d(o){o&&(w(r),e.d())}}}function z2(n){let e,t=n[0].networkStatus.status&&Av(n);return{c(){t&&t.c(),e=ue()},m(r,o){t&&t.m(r,o),_(r,e,o)},p(r,[o]){r[0].networkStatus.status?t?t.p(r,o):(t=Av(r),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:B,o:B,d(r){r&&w(e),t&&t.d(r)}}}function W2(n,e,t){let{plugin:r}=e;function o(){var a;!((a=r.networkStatus.status)===null||a===void 0)&&a.versions&&(r.releaseSettings.get().channel==="stable"?r.installVersion(r.networkStatus.status.versions.stable):r.releaseSettings.get().channel==="beta"&&r.installVersion(r.networkStatus.status.versions.beta))}let s=()=>{var a,l;(a=r.networkStatus.status)!=null&&a.versions?o():(l=r.networkStatus.status)!=null&&l.link&&window.open(r.networkStatus.status.link)},i=()=>{var a,l;(a=r.networkStatus.status)!=null&&a.versions?o():(l=r.networkStatus.status)!=null&&l.link&&window.open(r.networkStatus.status.link)};return n.$$set=a=>{"plugin"in a&&t(0,r=a.plugin)},[r,o,s,i]}var wm=class extends z{constructor(e){super(),W(this,e,W2,z2,j,{plugin:0})}},$c=wm;function Ev(n){let e=n-1;return e*e*e+1}function Xn(n){return--n*n*n*n*n+1}function es(n,{delay:e=0,duration:t=400,easing:r=Ev,axis:o="y"}={}){let s=getComputedStyle(n),i=+s.opacity,a=o==="y"?"height":"width",l=parseFloat(s[a]),c=o==="y"?["top","bottom"]:["left","right"],u=c.map(I=>`${I[0].toUpperCase()}${I.slice(1)}`),f=parseFloat(s[`padding${u[0]}`]),d=parseFloat(s[`padding${u[1]}`]),p=parseFloat(s[`margin${u[0]}`]),m=parseFloat(s[`margin${u[1]}`]),y=parseFloat(s[`border${u[0]}Width`]),g=parseFloat(s[`border${u[1]}Width`]);return{delay:e,duration:t,easing:r,css:I=>`overflow: hidden;opacity: ${Math.min(I*20,1)*i};${a}: ${I*l}px;padding-${c[0]}: ${I*f}px;padding-${c[1]}: ${I*d}px;margin-${c[0]}: ${I*p}px;margin-${c[1]}: ${I*m}px;border-${c[0]}-width: ${I*y}px;border-${c[1]}-width: ${I*g}px;`}}function K2(n){we(n,"svelte-1pi7qud",`.continue.svelte-1pi7qud{font-weight:600;font-size:larger;margin-top:0;margin-bottom:0px}.link.svelte-1pi7qud{color:var(--text-muted)}.link.svelte-1pi7qud:hover{color:var(--text-normal)}.not-working.svelte-1pi7qud{margin-top:0px;margin-bottom:0px;color:var(--text-faint);font-size:0.75em}.link-button.svelte-1pi7qud{box-shadow:none;background:none;border:none;padding:0;font:inherit;text-decoration:underline}button.link-button.svelte-1pi7qud:hover{box-shadow:none;color:var(--text-normal)}button.link.link-button.svelte-1pi7qud{height:auto;padding:0}.welcome.svelte-1pi7qud{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:10vh 2rem 1rem 2rem;max-width:640px;margin:0 auto;gap:2rem}.google-sign-in-button.svelte-1pi7qud{width:100%;height:unset;padding:12px 16px 12px 42px !important;border:none;border-radius:3px;box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25);color:var(--text-color);font-size:14px;font-weight:500;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
|
Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTcuNiA5LjJsLS4xLTEuOEg5djMuNGg0LjhDMTMuNiAxMiAxMyAxMyAxMiAxMy42djIuMmgzYTguOCA4LjggMCAwIDAgMi42LTYuNnoiIGZpbGw9IiM0Mjg1RjQiIGZpbGwtcnVsZT0ibm9uemVybyIvPjxwYXRoIGQ9Ik05IDE4YzIuNCAwIDQuNS0uOCA2LTIuMmwtMy0yLjJhNS40IDUuNCAwIDAgMS04LTIuOUgxVjEzYTkgOSAwIDAgMCA4IDV6IiBmaWxsPSIjMzRBODUzIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48cGF0aCBkPSJNNCAxMC43YTUuNCA1LjQgMCAwIDEgMC0zLjRWNUgxYTkgOSAwIDAgMCAwIDhsMy0yLjN6IiBmaWxsPSIjRkJCQzA1IiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48cGF0aCBkPSJNOSAzLjZjMS4zIDAgMi41LjQgMy40IDEuM0wxNSAyLjNBOSA5IDAgMCAwIDEgNWwzIDIuNGE1LjQgNS40IDAgMCAxIDUtMy43eiIgZmlsbD0iI0VBNDMzNSIgZmlsbC1ydWxlPSJub256ZXJvIi8+PHBhdGggZD0iTTAgMGgxOHYxOEgweiIvPjwvZz48L3N2Zz4=);background-color:var(--background-secondary);background-repeat:no-repeat;background-position:12px 11px}.google-sign-in-button.svelte-1pi7qud:hover{box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 2px 4px rgba(0, 0, 0, 0.25)}.google-sign-in-button.svelte-1pi7qud:disabled{cursor:unset;filter:grayscale(100%);box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25)}.discord-sign-in-button.svelte-1pi7qud{width:100%;height:unset;padding:12px 16px 12px 42px !important;border:none;border-radius:3px;box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25);color:var(--text-color);font-size:14px;font-weight:500;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
|
Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyAgIHdpZHRoPSIxOCIgICBoZWlnaHQ9IjE4IiAgIHZpZXdCb3g9Ii0xNSAtMTUgMjg2IDI4NiIgICBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCIgICB2ZXJzaW9uPSIxLjEiICAgaWQ9InN2ZzYiICAgc29kaXBvZGk6ZG9jbmFtZT0iZGlzY29yZC5zdmciICAgaW5rc2NhcGU6dmVyc2lvbj0iMS4xLjIgKDBhMDBjZjUzMzksIDIwMjItMDItMDQpIiAgIHhtbG5zOmlua3NjYXBlPSJodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy9uYW1lc3BhY2VzL2lua3NjYXBlIiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIgICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+ICA8ZGVmcyAgICAgaWQ9ImRlZnMxMCIgLz4gIDxzb2RpcG9kaTpuYW1lZHZpZXcgICAgIGlkPSJuYW1lZHZpZXc4IiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiICAgICBib3JkZXJvcGFjaXR5PSIxLjAiICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIiAgICAgaW5rc2NhcGU6cGFnZW9wYWNpdHk9IjAuMCIgICAgIGlua3NjYXBlOnBhZ2VjaGVja2VyYm9hcmQ9IjAiICAgICBzaG93Z3JpZD0iZmFsc2UiICAgICBpbmtzY2FwZTp6b29tPSIyNC4yNSIgICAgIGlua3NjYXBlOmN4PSI0LjM3MTEzNCIgICAgIGlua3NjYXBlOmN5PSIxNC40NTM2MDgiICAgICBpbmtzY2FwZTp3aW5kb3ctd2lkdGg9IjE4OTAiICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSIxMDY0IiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjE4OTAiICAgICBpbmtzY2FwZTp3aW5kb3cteT0iMTA5NiIgICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJzdmc2IiAvPiAgPGcgICAgIGlkPSJnNCIgICAgIHRyYW5zZm9ybT0ibWF0cml4KDEuMDg4NzYxMiwwLDAsMS4wNDc4NTU0LC0xMC40NTgyNzYsMzMuNDI2NTI1KSI+ICAgIDxwYXRoICAgICAgIGQ9Ik0gMjE2Ljg1NjM0LDE2LjU5NjYwMyBDIDIwMC4yODUsOC44NDMyODY3IDE4Mi41NjYxNCwzLjIwODQ5ODggMTY0LjA0MTU2LDAgYyAtMi4yNzUwNCw0LjExMzE4MTEgLTQuOTMyOTQsOS42NDU0OTkxIC02Ljc2NTQ2LDE0LjA0NjQzOCAtMTkuNjkyMTEsLTIuOTYxNDQ4IC0zOS4yMDMxMywtMi45NjE0NDggLTU4LjUzMzA4NCwwIEMgOTYuOTEwODQyLDkuNjQ1NDk5MSA5NC4xOTI1ODQsNC4xMTMxODExIDkxLjg5NzE4OSwwIDczLjM1MjYwNywzLjIwODQ5ODggNTUuNjEzMzk1LDguODYzOTkxMiAzOS4wNDIwNTgsMTYuNjM3NjYxIDUuNjE3NTIyOSw2Ny4xNDY1MTQgLTMuNDQzMzE5MSwxMTYuNDAwODEgMS4wODcxMTA3LDE2NC45NTU3MiAyMy4yNTYwMiwxODEuNTEwOTEgNDQuNzQwMzYzLDE5MS41Njc3IDY1Ljg2MjEzMywxOTguMTQ4NTggYyA1LjIxNTA4MiwtNy4xNzc0NSA5Ljg2NjIzLC0xNC44MDcyNSAxMy44NzMwODEsLTIyLjg0ODMyIC03LjYzMTE5NSwtMi44OTk2OSAtMTQuOTQwMjQyLC02LjQ3ODA2IC0yMS44NDY0MjcsLTEwLjYzMjMgMS44MzIxNzQsLTEuMzU3MzcgMy42MjQzNDMsLTIuNzc2NTEgNS4zNTU4MDMsLTQuMjM2NyA0Mi4xMjI4MiwxOS43MDE5MyA4Ny44OTAzNCwxOS43MDE5MyAxMjkuNTA5OTMsMCAxLjc1MTgyLDEuNDYwMTkgMy41NDM2MywyLjg3OTMzIDUuMzU1ODEsNC4yMzY3IC02LjkyNjU0LDQuMTc0NiAtMTQuMjU1NTksNy43NTI5NyAtMjEuODg2NzksMTAuNjUzIDQuMDA2ODUsOC4wMjAzNyA4LjYzOCwxNS42NzA4NyAxMy44NzMwOCwyMi44NDc5NyAyMS4xNDIxMywtNi41ODA4OCA0Mi42NDY0LC0xNi42MzczMSA2NC44MTUzMywtMzMuMjEzMjEgNS4zMTU4LC01Ni4yODc1MiAtOS4wODA4NiwtMTA1LjA4OTQ3NyAtMzguMDU1NjEsLTE0OC4zNTkxMTcgeiBNIDg1LjQ3Mzg3NSwxMzUuMDk0ODkgYyAtMTIuNjQ0ODQ3LDAgLTIzLjAxNDY1MywtMTEuODA0NzMgLTIzLjAxNDY1MywtMjYuMTc5OTkgMCwtMTQuMzc1MjUzIDEwLjE0ODM3MywtMjYuMjAwMzQxIDIzLjAxNDY1MywtMjYuMjAwMzQxIDEyLjg2NjYzMSwwIDIzLjIzNjA4NSwxMS44MDQzODQgMjMuMDE0NjU1LDI2LjIwMDM0MSAwLjAyLDE0LjM3NTI2IC0xMC4xNDgwMjQsMjYuMTc5OTkgLTIzLjAxNDY1NSwyNi4xNzk5OSB6IG0gODUuMDUxMzY1LDAgYyAtMTIuNjQ0ODUsMCAtMjMuMDE0NjYsLTExLjgwNDczIC0yMy4wMTQ2NiwtMjYuMTc5OTkgMCwtMTQuMzc1MjUzIDEwLjE0ODAzLC0yNi4yMDAzNDEgMjMuMDE0NjYsLTI2LjIwMDM0MSAxMi44NjYyOCwwIDIzLjIzNjA4LDExLjgwNDM4NCAyMy4wMTQ2NSwyNi4yMDAzNDEgMCwxNC4zNzUyNiAtMTAuMTQ4MzcsMjYuMTc5OTkgLTIzLjAxNDY1LDI2LjE3OTk5IHoiICAgICAgIGZpbGw9IiM1ODY1ZjIiICAgICAgIGZpbGwtcnVsZT0ibm9uemVybyIgICAgICAgaWQ9InBhdGgyIiAvPiAgPC9nPjwvc3ZnPg==);background-color:var(--background-secondary);background-repeat:no-repeat;background-position:12px 11px}.discord-sign-in-button.svelte-1pi7qud:hover{box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 2px 4px rgba(0, 0, 0, 0.25)}.discord-sign-in-button.svelte-1pi7qud:disabled{cursor:unset;filter:grayscale(100%);box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25)}.microsoft-sign-in-button.svelte-1pi7qud{width:100%;height:unset;padding:12px 16px 12px 42px !important;border:none;border-radius:3px;box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25);color:var(--text-color);font-size:14px;font-weight:500;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
|
Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSIxOHB4IiBoZWlnaHQ9IjE4cHgiIHZpZXdCb3g9Ii0xNSAtMTUgMjg2IDI4NiIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj4gICAgPHRpdGxlPk1pY3Jvc29mdDwvdGl0bGU+ICAgIDxnPiAgICAgICAgPHBvbHlnb24gZmlsbD0iI0YxNTExQiIgcG9pbnRzPSIxMjEuNjY2MDk1IDEyMS42NjYwOTUgMCAxMjEuNjY2MDk1IDAgMCAxMjEuNjY2MDk1IDAiLz4gICAgICAgIDxwb2x5Z29uIGZpbGw9IiM4MENDMjgiIHBvaW50cz0iMjU2IDEyMS42NjYwOTUgMTM0LjMzNTM1NiAxMjEuNjY2MDk1IDEzNC4zMzUzNTYgMCAyNTYgMCIvPiAgICAgICAgPHBvbHlnb24gZmlsbD0iIzAwQURFRiIgcG9pbnRzPSIxMjEuNjYzMTk0IDI1Ni4wMDIxODggMCAyNTYuMDAyMTg4IDAgMTM0LjMzNjA5NSAxMjEuNjYzMTk0IDEzNC4zMzYwOTUiLz4gICAgICAgIDxwb2x5Z29uIGZpbGw9IiNGQkJDMDkiIHBvaW50cz0iMjU2IDI1Ni4wMDIxODggMTM0LjMzNTM1NiAyNTYuMDAyMTg4IDEzNC4zMzUzNTYgMTM0LjMzNjA5NSAyNTYgMTM0LjMzNjA5NSIvPiAgICA8L2c+PC9zdmc+);background-color:var(--background-secondary);background-repeat:no-repeat;background-position:12px 11px}.microsoft-sign-in-button.svelte-1pi7qud:hover{box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 2px 4px rgba(0, 0, 0, 0.25)}.microsoft-sign-in-button.svelte-1pi7qud:disabled{cursor:unset;filter:grayscale(100%);box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25)}.github-sign-in-button.svelte-1pi7qud{width:100%;height:unset;padding:12px 16px 12px 42px !important;border:none;border-radius:3px;box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25);color:var(--text-color);font-size:14px;font-weight:500;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
|
Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;background-color:var(--background-secondary);background-repeat:no-repeat;background-position:12px 11px;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgd2lkdGg9IjE2LjE5NjU4NSIKICAgaGVpZ2h0PSIxNS42NTQ3NjgiCiAgIGZpbGw9Im5vbmUiCiAgIHZlcnNpb249IjEuMSIKICAgaWQ9InN2ZzQiCiAgIHNvZGlwb2RpOmRvY25hbWU9ImdoLnN2ZyIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMS4xLjIgKDBhMDBjZjUzMzksIDIwMjItMDItMDQpIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzCiAgICAgaWQ9ImRlZnM4IiAvPgogIDxzb2RpcG9kaTpuYW1lZHZpZXcKICAgICBpZD0ibmFtZWR2aWV3NiIKICAgICBwYWdlY29sb3I9IiNmZmZmZmYiCiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiCiAgICAgYm9yZGVyb3BhY2l0eT0iMS4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6cGFnZW9wYWNpdHk9IjAuMCIKICAgICBpbmtzY2FwZTpwYWdlY2hlY2tlcmJvYXJkPSIwIgogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBmaXQtbWFyZ2luLXRvcD0iMCIKICAgICBmaXQtbWFyZ2luLWxlZnQ9IjAiCiAgICAgZml0LW1hcmdpbi1yaWdodD0iMCIKICAgICBmaXQtbWFyZ2luLWJvdHRvbT0iMCIKICAgICBpbmtzY2FwZTp6b29tPSI0OC41IgogICAgIGlua3NjYXBlOmN4PSI4IgogICAgIGlua3NjYXBlOmN5PSI4LjAxMDMwOTMiCiAgICAgaW5rc2NhcGU6d2luZG93LXdpZHRoPSIzNzY0IgogICAgIGlua3NjYXBlOndpbmRvdy1oZWlnaHQ9IjIxMTIiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjgiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjQwIgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0ic3ZnNCIgLz4KICA8cGF0aAogICAgIGZpbGwtcnVsZT0iZXZlbm9kZCIKICAgICBjbGlwLXJ1bGU9ImV2ZW5vZGQiCiAgICAgZD0ibSA4LjAwMTc3OTksMC4wMDIzNzIxNiBhIDgsOCAwIDAgMCAtMi41MywxNS41ODk5OTk4NCBjIDAuNCwwLjA3IDAuNTUsLTAuMTcgMC41NSwtMC4zOCB2IC0xLjMzIGMgLTIuMjIsMC40OCAtMi42OSwtMS4wNyAtMi42OSwtMS4wNyAtMC4zNiwtMC45MiAtMC44OCwtMS4xNyAtMC44OCwtMS4xNyAtMC43MywtMC40OSAwLjA1LC0wLjQ4IDAuMDUsLTAuNDggMC44LDAuMDYgMS4yMywwLjgzIDEuMjMsMC44MyAwLjcyLDEuMjMgMS44OCwwLjg3IDIuMzMsMC42NiAwLjA3LC0wLjUyIDAuMjgsLTAuODcgMC41MSwtMS4wNyAtMS43OCwtMC4yIC0zLjY1LC0wLjg5IC0zLjY1LC0zLjk0OTk5OTggMCwtMC44NyAwLjMxLC0xLjU4IDAuODIsLTIuMTQgLTAuMDgsLTAuMiAtMC4zNiwtMS4wMSAwLjA4LC0yLjEgMCwwIDAuNjcsLTAuMjIgMi4yLDAuODIgYSA3LjY1LDcuNjUgMCAwIDEgNC4wMDAwMDAxLDAgYyAxLjUzLC0xLjA0IDIuMiwtMC44MiAyLjIsLTAuODIgMC40NCwxLjA5IDAuMTYsMS45IDAuMDgsMi4xIDAuNTEsMC41NiAwLjgyLDEuMjcgMC44MiwyLjE0IDAsMy4wNjk5OTk4IC0xLjg3LDMuNzQ5OTk5OCAtMy42NTAwMDAxLDMuOTQ5OTk5OCAwLjI5LDAuMjUgMC41NDAwMDAxLDAuNzQgMC41NDAwMDAxLDEuNDggdiAyLjIgYyAwLDAuMjEgMC4xNSwwLjQ1IDAuNTUsMC4zOCBBIDgsOCAwIDAgMCA4LjAwMTc3OTksMC4wMDIzNzIxNiBaIgogICAgIGZpbGw9IiMyNDI5MmYiCiAgICAgaWQ9InBhdGgyIiAvPgo8L3N2Zz4K)}.theme-dark .github-sign-in-button.svelte-1pi7qud{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYuMTk2NTg1IiBoZWlnaHQ9IjE1LjY1NDc2OCIgZmlsbD0ibm9uZSIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJtIDguMDAxNzc5OSwwLjAwMjM3MjE2IGEgOCw4IDAgMCAwIC0yLjUzLDE1LjU4OTk5OTg0IGMgMC40LDAuMDcgMC41NSwtMC4xNyAwLjU1LC0wLjM4IHYgLTEuMzMgYyAtMi4yMiwwLjQ4IC0yLjY5LC0xLjA3IC0yLjY5LC0xLjA3IC0wLjM2LC0wLjkyIC0wLjg4LC0xLjE3IC0wLjg4LC0xLjE3IC0wLjczLC0wLjQ5IDAuMDUsLTAuNDggMC4wNSwtMC40OCAwLjgsMC4wNiAxLjIzLDAuODMgMS4yMywwLjgzIDAuNzIsMS4yMyAxLjg4LDAuODcgMi4zMywwLjY2IDAuMDcsLTAuNTIgMC4yOCwtMC44NyAwLjUxLC0xLjA3IC0xLjc4LC0wLjIgLTMuNjUsLTAuODkgLTMuNjUsLTMuOTQ5OTk5OCAwLC0wLjg3IDAuMzEsLTEuNTggMC44MiwtMi4xNCAtMC4wOCwtMC4yIC0wLjM2LC0xLjAxIDAuMDgsLTIuMSAwLDAgMC42NywtMC4yMiAyLjIsMC44MiBhIDcuNjUsNy42NSAwIDAgMSA0LjAwMDAwMDEsMCBjIDEuNTMsLTEuMDQgMi4yLC0wLjgyIDIuMiwtMC44MiAwLjQ0LDEuMDkgMC4xNiwxLjkgMC4wOCwyLjEgMC41MSwwLjU2IDAuODIsMS4yNyAwLjgyLDIuMTQgMCwzLjA2OTk5OTggLTEuODcsMy43NDk5OTk4IC0zLjY1MDAwMDEsMy45NDk5OTk4IDAuMjksMC4yNSAwLjU0MDAwMDEsMC43NCAwLjU0MDAwMDEsMS40OCB2IDIuMiBjIDAsMC4yMSAwLjE1LDAuNDUgMC41NSwwLjM4IEEgOCw4IDAgMCAwIDguMDAxNzc5OSwwLjAwMjM3MjE2IFoiIGZpbGw9IiNmZmZmZmYiIC8+Cjwvc3ZnPgo=)}.github-sign-in-button.svelte-1pi7qud:hover{box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 2px 4px rgba(0, 0, 0, 0.25)}.github-sign-in-button.svelte-1pi7qud:disabled{cursor:unset;filter:grayscale(100%);box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25)}.oidc-sign-in-button.svelte-1pi7qud{width:100%;height:unset;padding:12px 16px 12px 42px !important;border:none;border-radius:3px;box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25);color:var(--text-color);font-size:14px;font-weight:500;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
|
Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnoiIHN0cm9rZT0iIzYzNjM2MyIgc3Ryb2tlLXdpZHRoPSIyIi8+PHBhdGggZD0iTTggMTJoOE0xMiA4bDQgNC00IDQiIHN0cm9rZT0iIzYzNjM2MyIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=);background-color:var(--background-secondary);background-repeat:no-repeat;background-position:12px 11px}.oidc-sign-in-button.svelte-1pi7qud:hover{box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 2px 4px rgba(0, 0, 0, 0.25)}.oidc-sign-in-button.svelte-1pi7qud:disabled{cursor:unset;filter:grayscale(100%);box-shadow:0 -1px 0 rgba(0, 0, 0, 0.04),
|
|
0 1px 1px rgba(0, 0, 0, 0.25)}.login-buttons.svelte-1pi7qud{display:flex;flex-direction:column;gap:0.85rem;padding:1rem;background:var(--background-modifier-border-hover);border-radius:0.5rem}.choose-another.svelte-1pi7qud{text-align:center;margin-top:0.25rem;margin-bottom:1rem;font-size:0.85em;color:var(--text-normal)}`)}function Pv(n,e,t){let r=n.slice();return r[58]=e[t],r}function Dv(n,e,t){let r=n.slice();return r[58]=e[t],r}function G2(n){let e,t,r,o,s,i,a,l,c,u,f,d=Ar.Platform.isMobile&&Y2(n);r=new vv({});let p=[Z2,Q2],m=[];function y(S,M){return S[6]?0:1}s=y(n,[-1,-1,-1]),i=m[s]=p[s](n);function g(S,M){if(S[12])return rM;if(S[8])return tM}let I=g(n,[-1,-1,-1]),L=I&&I(n),C=n[4].provider&&!n[8]&&$v(n);return u=new _v({}),{c(){d&&d.c(),e=T(),t=x("div"),P(r.$$.fragment),o=T(),i.c(),a=T(),L&&L.c(),l=T(),C&&C.c(),c=T(),P(u.$$.fragment),h(t,"class","welcome svelte-1pi7qud")},m(S,M){d&&d.m(S,M),_(S,e,M),_(S,t,M),A(r,t,null),b(t,o),m[s].m(t,null),b(t,a),L&&L.m(t,null),_(S,l,M),C&&C.m(S,M),_(S,c,M),A(u,S,M),f=!0},p(S,M){Ar.Platform.isMobile&&d.p(S,M);let E=s;s=y(S,M),s===E?m[s].p(S,M):(ee(),k(m[E],1,1,()=>{m[E]=null}),te(),i=m[s],i?i.p(S,M):(i=m[s]=p[s](S),i.c()),v(i,1),i.m(t,a)),I===(I=g(S,M))&&L?L.p(S,M):(L&&L.d(1),L=I&&I(S),L&&(L.c(),L.m(t,null))),S[4].provider&&!S[8]?C?C.p(S,M):(C=$v(S),C.c(),C.m(c.parentNode,c)):C&&(C.d(1),C=null)},i(S){f||(v(d),v(r.$$.fragment,S),v(i),v(u.$$.fragment,S),f=!0)},o(S){k(d),k(r.$$.fragment,S),k(i),k(u.$$.fragment,S),f=!1},d(S){S&&(w(e),w(t),w(l),w(c)),d&&d.d(S),F(r),m[s].d(),L&&L.d(),C&&C.d(S),F(u,S)}}}function J2(n){let e,t,r,o,s,i,a;e=new Qe({props:{$$slots:{name:[nM],default:[oM]},$$scope:{ctx:n}}}),r=new Qe({props:{name:"Account"}}),s=new ni({props:{user:n[5].user,$$slots:{default:[sM]},$$scope:{ctx:n}}});let l=n[34].default,c=ye(l,n,n[42],null);return{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment),o=T(),P(s.$$.fragment),i=T(),c&&c.c()},m(u,f){A(e,u,f),_(u,t,f),A(r,u,f),_(u,o,f),A(s,u,f),_(u,i,f),c&&c.m(u,f),a=!0},p(u,f){let d={};f[1]&2048&&(d.$$scope={dirty:f,ctx:u}),e.$set(d);let p={};f[0]&32&&(p.user=u[5].user),f[1]&2048&&(p.$$scope={dirty:f,ctx:u}),s.$set(p),c&&c.p&&(!a||f[1]&2048)&&ve(c,l,u,u[42],a?be(l,u[42],f,null):xe(u[42]),null)},i(u){a||(v(e.$$.fragment,u),v(r.$$.fragment,u),v(s.$$.fragment,u),v(c,u),a=!0)},o(u){k(e.$$.fragment,u),k(r.$$.fragment,u),k(s.$$.fragment,u),k(c,u),a=!1},d(u){u&&(w(t),w(o),w(i)),F(e,u),F(r,u),F(s,u),c&&c.d(u)}}}function Y2(n){let e,t;return e=new $c({props:{plugin:n[0]}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&1&&(s.plugin=r[0]),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 Q2(n){let e,t=[],r=new Map,o=he(n[7]),s=i=>i[58];for(let i=0;i<o.length;i+=1){let a=Pv(n,o,i),l=s(a);r.set(l,t[i]=Rv(l,a))}return{c(){e=x("div");for(let i=0;i<t.length;i+=1)t[i].c();h(e,"class","login-buttons svelte-1pi7qud")},m(i,a){_(i,e,a);for(let l=0;l<t.length;l+=1)t[l]&&t[l].m(e,null)},p(i,a){a[0]&36228|a[1]&4&&(o=he(i[7]),t=qr(t,a,s,1,i,o,r,e,Zs,Rv,null,Pv))},i:B,o:B,d(i){i&&w(e);for(let a=0;a<t.length;a+=1)t[a].d()}}}function Z2(n){let e,t=[],r=new Map,o,s=he(n[7]),i=a=>a[58];for(let a=0;a<s.length;a+=1){let l=Dv(n,s,a),c=i(l);r.set(c,t[a]=Uv(c,l))}return{c(){e=x("div");for(let a=0;a<t.length;a+=1)t[a].c();h(e,"class","login-buttons svelte-1pi7qud")},m(a,l){_(a,e,l);for(let c=0;c<t.length;c+=1)t[c]&&t[c].m(e,null);o=!0},p(a,l){l[0]&36736|l[1]&1&&(s=he(a[7]),ee(),t=qr(t,l,i,1,a,s,r,e,Gn,Uv,null,Dv),te())},i(a){if(!o){for(let l=0;l<s.length;l+=1)v(t[l]);o=!0}},o(a){for(let l=0;l<t.length;l+=1)k(t[l]);o=!1},d(a){a&&w(e);for(let l=0;l<t.length;l+=1)t[l].d()}}}function X2(n){let e,t,r=(n[11][n[58]]||ts(n[58]))+"",o,s,i,a,l;return{c(){e=x("button"),t=V("Sign in with "),o=V(r),h(e,"class",s=Tt(`${n[58].startsWith("oidc")?"oidc":n[58]}-sign-in-button`)+" svelte-1pi7qud"),e.disabled=i=!0},m(c,u){_(c,e,u),b(e,t),b(e,o),l=!0},p(c,u){n=c,(!l||u[0]&2176)&&r!==(r=(n[11][n[58]]||ts(n[58]))+"")&&J(o,r),(!l||u[0]&128&&s!==(s=Tt(`${n[58].startsWith("oidc")?"oidc":n[58]}-sign-in-button`)+" svelte-1pi7qud"))&&h(e,"class",s)},i(c){l||(c&&ko(()=>{l&&(a||(a=Kn(e,es,{duration:n[10]?300:0,easing:Xn},!0)),a.run(1))}),l=!0)},o(c){c&&(a||(a=Kn(e,es,{duration:n[10]?300:0,easing:Xn},!1)),a.run(0)),l=!1},d(c){c&&w(e),c&&a&&a.end()}}}function eM(n){let e,t,r,o=(n[11][n[58]]||ts(n[58]))+"",s,i,a,l,c,u,f,d,p;function m(){return n[37](n[58])}return{c(){e=x("a"),t=x("button"),r=V("Sign in with "),s=V(o),c=T(),h(t,"class",i=Tt(`${n[58].startsWith("oidc")?"oidc":n[58]}-sign-in-button`)+" svelte-1pi7qud"),t.disabled=a=n[8]||!n[2][n[58]],h(e,"href",u=n[2][n[58]].fullAuthUrl),h(e,"target","_blank")},m(y,g){_(y,e,g),b(e,t),b(t,r),b(t,s),b(e,c),f=!0,d||(p=$(t,"click",m),d=!0)},p(y,g){n=y,(!f||g[0]&2176)&&o!==(o=(n[11][n[58]]||ts(n[58]))+"")&&J(s,o),(!f||g[0]&128&&i!==(i=Tt(`${n[58].startsWith("oidc")?"oidc":n[58]}-sign-in-button`)+" svelte-1pi7qud"))&&h(t,"class",i),(!f||g[0]&388&&a!==(a=n[8]||!n[2][n[58]]))&&(t.disabled=a),(!f||g[0]&132&&u!==(u=n[2][n[58]].fullAuthUrl))&&h(e,"href",u)},i(y){f||(y&&ko(()=>{f&&(l||(l=Kn(t,es,{duration:n[10]?300:0,easing:Xn},!0)),l.run(1))}),f=!0)},o(y){y&&(l||(l=Kn(t,es,{duration:n[10]?300:0,easing:Xn},!1)),l.run(0)),f=!1},d(y){y&&w(e),y&&l&&l.end(),d=!1,p()}}}function Rv(n,e){let t,r,o,s,i=[eM,X2],a=[];function l(c,u){return c[2][c[58]]?0:1}return r=l(e,[-1,-1,-1]),o=a[r]=i[r](e),{key:n,first:null,c(){t=ue(),o.c(),s=ue(),this.first=t},m(c,u){_(c,t,u),a[r].m(c,u),_(c,s,u)},p(c,u){e=c;let f=r;r=l(e,u),r===f?a[r].p(e,u):(ee(),k(a[f],1,1,()=>{a[f]=null}),te(),o=a[r],o?o.p(e,u):(o=a[r]=i[r](e),o.c()),v(o,1),o.m(s.parentNode,s))},d(c){c&&(w(t),w(s)),a[r].d(c)}}}function Uv(n,e){let t,r,o=(e[11][e[58]]||ts(e[58]))+"",s,i,a,l,c,u,f;function d(){return e[36](e[58])}return{key:n,first:null,c(){t=x("button"),r=V("Sign in with "),s=V(o),h(t,"class",i=Tt(`${e[58].startsWith("oidc")?"oidc":e[58]}-sign-in-button`)+" svelte-1pi7qud"),t.disabled=a=e[8]||!e[9].contains(e[58]),this.first=t},m(p,m){_(p,t,m),b(t,r),b(t,s),c=!0,u||(f=$(t,"click",function(){Je((0,Ar.debounce)(d))&&(0,Ar.debounce)(d).apply(this,arguments)}),u=!0)},p(p,m){e=p,(!c||m[0]&2176)&&o!==(o=(e[11][e[58]]||ts(e[58]))+"")&&J(s,o),(!c||m[0]&128&&i!==(i=Tt(`${e[58].startsWith("oidc")?"oidc":e[58]}-sign-in-button`)+" svelte-1pi7qud"))&&h(t,"class",i),(!c||m[0]&896&&a!==(a=e[8]||!e[9].contains(e[58])))&&(t.disabled=a)},i(p){c||(p&&ko(()=>{c&&(l||(l=Kn(t,es,{duration:e[10]?300:0,easing:Xn},!0)),l.run(1))}),c=!0)},o(p){p&&(l||(l=Kn(t,es,{duration:e[10]?300:0,easing:Xn},!1)),l.run(0)),c=!1},d(p){p&&w(t),p&&l&&l.end(),u=!1,f()}}}function tM(n){let e,t,r,o,s,i,a,l;return{c(){e=x("div"),t=x("p"),t.textContent="Continue in your browser...",r=T(),o=x("p"),s=V(`Not working?
|
|
`),i=x("button"),i.textContent="(try again)",h(t,"class","continue svelte-1pi7qud"),h(i,"class","link link-button svelte-1pi7qud"),h(o,"class","not-working svelte-1pi7qud")},m(c,u){_(c,e,u),b(e,t),b(e,r),b(e,o),b(o,s),b(o,i),a||(l=$(i,"click",n[40]),a=!0)},p:B,d(c){c&&w(e),a=!1,l()}}}function rM(n){let e,t,r,o,s,i,a,l,c,u,f,d=n[13]&&n[3]&&Ov(n);return{c(){e=x("p"),t=V(n[12]),r=V("."),o=x("br"),s=T(),d&&d.c(),i=T(),a=x("p"),l=V(`Not working?
|
|
`),c=x("button"),c.textContent="(try again)",h(c,"class","link link-button svelte-1pi7qud"),h(a,"class","not-working svelte-1pi7qud")},m(p,m){_(p,e,m),b(e,t),b(e,r),b(e,o),b(e,s),d&&d.m(e,null),_(p,i,m),_(p,a,m),b(a,l),b(a,c),u||(f=$(c,"click",n[39]),u=!0)},p(p,m){m[0]&4096&&J(t,p[12]),p[13]&&p[3]?d?d.p(p,m):(d=Ov(p),d.c(),d.m(e,null)):d&&(d.d(1),d=null)},d(p){p&&(w(e),w(i),w(a)),d&&d.d(),u=!1,f()}}}function Ov(n){let e,t,r,o;return{c(){e=V("Already logged in? "),t=x("button"),t.textContent="(click here)",h(t,"class","link link-button svelte-1pi7qud")},m(s,i){_(s,e,i),_(s,t,i),r||(o=$(t,"click",function(){Je((0,Ar.debounce)(n[38]))&&(0,Ar.debounce)(n[38]).apply(this,arguments)}),r=!0)},p(s,i){n=s},d(s){s&&(w(e),w(t)),r=!1,o()}}}function $v(n){let e,t,r,o;return{c(){e=x("p"),t=x("button"),t.textContent="(choose another provider)",h(t,"class","link link-button svelte-1pi7qud"),h(e,"class","choose-another svelte-1pi7qud")},m(s,i){_(s,e,i),b(e,t),r||(o=$(t,"click",(0,Ar.debounce)(n[41])),r=!0)},p:B,d(s){s&&w(e),r=!1,o()}}}function oM(n){let e,t;return e=new bv({}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function nM(n){let e,t;return e=new Rc({props:{slot:"name"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p:B,i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function sM(n){let e,t,r;return{c(){e=x("button"),e.textContent="Logout"},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,Ar.debounce)(n[35])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function iM(n){let e,t,r,o,s=[J2,G2],i=[];function a(l,c){return l[5].hasUser&&l[5].user?0:1}return e=a(n,[-1,-1,-1]),t=i[e]=s[e](n),{c(){t.c(),r=ue()},m(l,c){i[e].m(l,c),_(l,r,c),o=!0},p(l,c){let u=e;e=a(l,c),e===u?i[e].p(l,c):(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),t=i[e],t?t.p(l,c):(t=i[e]=s[e](l),t.c()),v(t,1),t.m(r.parentNode,r))},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),i[e].d(l)}}}var aM="system3-relay-auth-providers-";function ts(n){return n?n=="oidc"?"OIDC":n=="github"?"GitHub":n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():""}function lM(n,e,t){let r,o,s,i,a,l,c,u,f=B,d=()=>(f(),f=Dt(R,pe=>t(5,u=pe)),R),p,m,y,g,I,L,C,S;n.$$.on_destroy.push(()=>f());let{$$slots:M={},$$scope:E}=e,{plugin:U}=e,K=Te("LoggedIn.svelte","error"),R,O=ge(!Ar.Platform.isIosApp);ne(n,O,pe=>t(6,p=pe));let q=ge(!1);ne(n,q,pe=>t(8,y=pe)),d(R=U.loginManager);let H=ge(!1);ne(n,H,pe=>t(13,S=pe));let G=ge(!1),ce=ge(!0);ne(n,ce,pe=>t(44,s=pe));let N=ge("");ne(n,N,pe=>t(3,r=pe));let X=fr.getInstance();ne(n,X,pe=>t(45,i=pe));let Me={},Ie=ge(!1);ne(n,Ie,pe=>t(47,l=pe));let D=R.loginSettings;ne(n,D,pe=>t(4,c=pe));let Q=ge([]);ne(n,Q,pe=>t(46,a=pe));let de=ge(!1);ne(n,de,pe=>t(10,I=pe));function Le(){var pe;let qe=((pe=R.pb)===null||pe===void 0?void 0:pe.baseUrl)||"default";return`${aM}${qe}`}function Ae(){let pe=["github","google","microsoft"];return i.getFlag("enableDiscordLogin")&&pe.push("discord"),pe}function re(){try{let pe=Le(),qe=localStorage.getItem(pe);if(qe)return JSON.parse(qe)}catch(pe){K("Failed to load cached providers:",pe)}return Ae()}function Z(pe){try{let qe=Le();localStorage.setItem(qe,JSON.stringify(pe))}catch(qe){K("Failed to save cached providers:",qe)}}let Se=et([N,X],()=>{let pe=["github","google","microsoft","oidc"];return i.getFlag("enableDiscordLogin")&&pe.push("discord"),pe});ne(n,Se,pe=>t(43,o=pe));let ae=et([N,R.loginSettings,X,Ie,Q],()=>{if(c&&c.provider)return[c.provider];if(r!=="")return[r];if(l&&Object.keys(Me).length>0){let qe=Object.keys(Me),rt=[];qe.includes("google")&&rt.push("google"),qe.includes("microsoft")&&rt.push("microsoft"),qe.includes("discord")&&i.getFlag("enableDiscordLogin")&&rt.push("discord"),qe.includes("github")&&rt.push("github"),qe.forEach(rn=>{rn.startsWith("oidc")&&rt.push(rn)});let rr=JSON.stringify(rt.sort())!==JSON.stringify(a.sort());return de.set(rr),Z(rt),rt}if(a.length>0&&!l)return a;let pe=["github","google","microsoft"];return i.getFlag("enableDiscordLogin")&&pe.push("discord"),pe});ne(n,ae,pe=>t(7,m=pe));function Pe(){R.clearPreferredProvider(),N.set(""),Rt()}let De=et([N,U.loginSettings,X,Ie],()=>r?[r]:Object.keys(Me));ne(n,De,pe=>t(9,g=pe));let Ge=et([Ie],()=>{var pe;let qe={};for(let rt of Object.keys(Me)){let rr=Me[rt];!((pe=rr==null?void 0:rr.info)===null||pe===void 0)&&pe.displayName?qe[rt]=rr.info.displayName:qe[rt]=ts(rt)}return qe});ne(n,Ge,pe=>t(11,L=pe));let mt,_t=ge("");ne(n,_t,pe=>t(12,C=pe));function zr(){return Ce(this,void 0,void 0,function*(){U.loginManager.logout(),G.set(!1),q.set(!1),N.set(""),H.set(!1)})}function co(pe){return Ce(this,void 0,void 0,function*(){try{N.set(pe),(yield U.loginManager.login(pe))&&G.set(!0)}catch(qe){O.set(!1),G.set(!1);let rt=Me[pe];rt&&(window.open(rt.fullAuthUrl,"_blank"),It(pe))}})}let Fr=ge(U.loginManager.pb);function xr(){Fr.set(U.loginManager.pb)}function Rt(){try{let pe=s?at:fetch;R.initiateManualOAuth2CodeFlow(pe,o).then(qe=>{t(2,Me=qe),Ie.set(!0),R.updateWebviewIntercepts(qe)}).catch(qe=>{let rt=qe.message;throw rt=rt,_t.set(rt),G.set(!1),N.set(""),qe})}catch(pe){_t.set(pe.message)}}st(()=>{G.set(!1);let pe=re();Q.set(pe),Rt()});function It(pe){return Ce(this,void 0,void 0,function*(){let qe=Me[pe];if(qe)return N.set(pe),yield U.loginManager.poll(qe).then(rt=>{G.set(!0),q.set(!1),_t.set("")}).catch(rt=>{H.set(!0),q.set(!1),G.set(!1),_t.set(rt.message)})})}function Tn(pe){let qe=pe.target;qe.focus(),qe.select(),navigator.clipboard.writeText(qe.value).then(()=>new Ar.Notice("Invite link copied")).catch(rt=>{}),It(r)}let Xo=()=>{zr()},Po=async pe=>{q.set(!0),await co(pe)},en=pe=>{q.set(!0),It(pe)},Wr=()=>{It(r)},tn=()=>{q.set(!1),O.set(!1),_t.set(""),N.set(""),Ie.set(!1),Rt()},ns=()=>{q.set(!1),O.set(!1),_t.set(""),N.set("")},Er=()=>{Pe()};return n.$$set=pe=>{"plugin"in pe&&t(0,U=pe.plugin),"$$scope"in pe&&t(42,E=pe.$$scope)},[U,R,Me,r,c,u,p,m,y,g,I,L,C,S,O,q,H,ce,N,X,Ie,D,Q,de,Se,ae,Pe,De,Ge,_t,zr,co,Rt,It,M,Xo,Po,en,Wr,tn,ns,Er,E]}var _m=class extends z{constructor(e){super(),W(this,e,lM,iM,j,{plugin:0},K2,[-1,-1,-1])}},Nv=_m;function Bv(n,e,t){let r=n.slice();return r[5]=e[t],r}var cM=n=>({}),Vv=n=>({}),uM=n=>({}),Hv=n=>({});function fM(n){let e;return{c(){e=V(n[0])},m(t,r){_(t,e,r)},p(t,r){r&1&&J(e,t[0])},d(t){t&&w(e)}}}function dM(n){let e,t=he(n[1]),r=[];for(let o=0;o<t.length;o+=1)r[o]=qv(Bv(n,t,o));return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=ue()},m(o,s){for(let i=0;i<r.length;i+=1)r[i]&&r[i].m(o,s);_(o,e,s)},p(o,s){if(s&2){t=he(o[1]);let i;for(i=0;i<t.length;i+=1){let a=Bv(o,t,i);r[i]?r[i].p(a,s):(r[i]=qv(a),r[i].c(),r[i].m(e.parentNode,e))}for(;i<r.length;i+=1)r[i].d(1);r.length=t.length}},d(o){o&&w(e),ze(r,o)}}}function qv(n){let e;return{c(){e=x("div"),e.textContent=`${n[5]} `},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function pM(n){let e,t=n[1].length>0&&dM(n);return{c(){t&&t.c(),e=ue()},m(r,o){t&&t.m(r,o),_(r,e,o)},p(r,o){r[1].length>0&&t.p(r,o)},d(r){r&&w(e),t&&t.d(r)}}}function mM(n){let e,t,r,o,s,i,a,l,c=n[4].name,u=ye(c,n,n[3],Hv),f=u||fM(n),d=n[4].description,p=ye(d,n,n[3],Vv),m=p||pM(n),y=n[4].default,g=ye(y,n,n[3],null);return{c(){e=x("div"),t=x("div"),r=x("div"),f&&f.c(),o=T(),s=x("div"),m&&m.c(),i=T(),a=x("div"),g&&g.c(),h(r,"class","setting-item-name"),se(r,"display","grid"),se(r,"align-items","center"),h(s,"class","setting-item-description"),h(t,"class","setting-item-info"),se(t,"display","grid"),h(a,"class","setting-item-control"),h(e,"class","setting-item")},m(I,L){_(I,e,L),b(e,t),b(t,r),f&&f.m(r,null),b(t,o),b(t,s),m&&m.m(s,null),b(e,i),b(e,a),g&&g.m(a,null),l=!0},p(I,[L]){u?u.p&&(!l||L&8)&&ve(u,c,I,I[3],l?be(c,I[3],L,uM):xe(I[3]),Hv):f&&f.p&&(!l||L&1)&&f.p(I,l?L:-1),p&&p.p&&(!l||L&8)&&ve(p,d,I,I[3],l?be(d,I[3],L,cM):xe(I[3]),Vv),g&&g.p&&(!l||L&8)&&ve(g,y,I,I[3],l?be(y,I[3],L,null):xe(I[3]),null)},i(I){l||(v(f,I),v(m,I),v(g,I),l=!0)},o(I){k(f,I),k(m,I),k(g,I),l=!1},d(I){I&&w(e),f&&f.d(I),m&&m.d(I),g&&g.d(I)}}}function hM(n,e,t){let{$$slots:r={},$$scope:o}=e,{name:s=""}=e,{description:i}=e,a=i!==void 0?i.split(`
|
|
`):[];return n.$$set=l=>{"name"in l&&t(0,s=l.name),"description"in l&&t(2,i=l.description),"$$scope"in l&&t(3,o=l.$$scope)},[s,a,i,o,r]}var Sm=class extends z{constructor(e){super(),W(this,e,hM,mM,j,{name:0,description:2})}},Re=Sm;function gM(n){we(n,"svelte-11hpkul",".setting-item-control.svelte-11hpkul{width:unset !important;margin-top:unset !important}.setting-item.svelte-11hpkul{flex-direction:unset !important}.setting-item-info.svelte-11hpkul{min-width:0;margin-top:auto;margin-bottom:auto}.setting-item-name.svelte-11hpkul{min-width:0}.truncate.svelte-11hpkul *{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}")}var yM=n=>({}),jv=n=>({}),bM=n=>({}),zv=n=>({});function vM(n){let e;return{c(){e=V(n[0])},m(t,r){_(t,e,r)},p(t,r){r&1&&J(e,t[0])},d(t){t&&w(e)}}}function Wv(n){let e,t;return{c(){e=x("div"),t=V(n[1]),h(e,"class","setting-item-description")},m(r,o){_(r,e,o),b(e,t)},p(r,o){o&2&&J(t,r[1])},d(r){r&&w(e)}}}function xM(n){let e,t=n[1]&&Wv(n);return{c(){t&&t.c(),e=ue()},m(r,o){t&&t.m(r,o),_(r,e,o)},p(r,o){r[1]?t?t.p(r,o):(t=Wv(r),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},d(r){r&&w(e),t&&t.d(r)}}}function wM(n){let e,t,r,o,s,i,a,l=n[3].name,c=ye(l,n,n[2],zv),u=c||vM(n),f=n[3].description,d=ye(f,n,n[2],jv),p=d||xM(n),m=n[3].default,y=ye(m,n,n[2],null);return{c(){e=x("div"),t=x("div"),r=x("div"),u&&u.c(),o=T(),p&&p.c(),s=T(),i=x("div"),y&&y.c(),h(r,"class","setting-item-name truncate svelte-11hpkul"),h(t,"class","setting-item-info svelte-11hpkul"),h(i,"class","setting-item-control svelte-11hpkul"),h(e,"class","setting-item mod-list-item svelte-11hpkul")},m(g,I){_(g,e,I),b(e,t),b(t,r),u&&u.m(r,null),b(t,o),p&&p.m(t,null),b(e,s),b(e,i),y&&y.m(i,null),a=!0},p(g,[I]){c?c.p&&(!a||I&4)&&ve(c,l,g,g[2],a?be(l,g[2],I,bM):xe(g[2]),zv):u&&u.p&&(!a||I&1)&&u.p(g,a?I:-1),d?d.p&&(!a||I&4)&&ve(d,f,g,g[2],a?be(f,g[2],I,yM):xe(g[2]),jv):p&&p.p&&(!a||I&2)&&p.p(g,a?I:-1),y&&y.p&&(!a||I&4)&&ve(y,m,g,g[2],a?be(m,g[2],I,null):xe(g[2]),null)},i(g){a||(v(u,g),v(p,g),v(y,g),a=!0)},o(g){k(u,g),k(p,g),k(y,g),a=!1},d(g){g&&w(e),u&&u.d(g),p&&p.d(g),y&&y.d(g)}}}function _M(n,e,t){let{$$slots:r={},$$scope:o}=e,{name:s=""}=e,{description:i=""}=e;return n.$$set=a=>{"name"in a&&t(0,s=a.name),"description"in a&&t(1,i=a.description),"$$scope"in a&&t(2,o=a.$$scope)},[s,i,o,r]}var km=class extends z{constructor(e){super(),W(this,e,_M,wM,j,{name:0,description:1},gM)}},Gt=km;var Kv=require("obsidian");function SM(n){let e,t=n[2].default,r=ye(t,n,n[1],null);return{c(){r&&r.c()},m(o,s){r&&r.m(o,s),e=!0},p(o,s){r&&r.p&&(!e||s&2)&&ve(r,t,o,o[1],e?be(t,o[1],s,null):xe(o[1]),null)},i(o){e||(v(r,o),e=!0)},o(o){k(r,o),e=!1},d(o){r&&r.d(o)}}}function kM(n){let e,t,r,o=n[2].default,s=ye(o,n,n[1],null);return{c(){e=x("div"),t=x("div"),s&&s.c(),h(t,"class","setting-items"),h(e,"class","setting-group")},m(i,a){_(i,e,a),b(e,t),s&&s.m(t,null),r=!0},p(i,a){s&&s.p&&(!r||a&2)&&ve(s,o,i,i[1],r?be(o,i[1],a,null):xe(i[1]),null)},i(i){r||(v(s,i),r=!0)},o(i){k(s,i),r=!1},d(i){i&&w(e),s&&s.d(i)}}}function IM(n){let e,t,r,o,s=[kM,SM],i=[];function a(l,c){return l[0]?0:1}return e=a(n,-1),t=i[e]=s[e](n),{c(){t.c(),r=ue()},m(l,c){i[e].m(l,c),_(l,r,c),o=!0},p(l,[c]){t.p(l,c)},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),i[e].d(l)}}}function CM(n,e,t){let{$$slots:r={},$$scope:o}=e,s=(0,Kv.requireApiVersion)("1.11.0");return n.$$set=i=>{"$$scope"in i&&t(1,o=i.$$scope)},[s,o,r]}var Im=class extends z{constructor(e){super(),W(this,e,CM,IM,j,{})}},vt=Im;function LM(n){we(n,"svelte-y529x8",".extra-setting-button.svelte-y529x8:focus{outline:none;box-shadow:none;color:var(--icon-color-focus)}.extra-setting-button.svelte-y529x8:hover{box-shadow:none;opacity:var(--icon-opacity-hover);color:var(--icon-color-hover);background-color:var(--background-modifier-hover)}")}function MM(n){let e,t;return e=new wp({props:{class:"svg-icon lucide-settings",props:{class:"svg-icon lucide-settings"}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p:B,i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function TM(n){let e,t,r,o,s=n[3].default,i=ye(s,n,n[2],null),a=i||MM(n);return{c(){e=x("div"),a&&a.c(),h(e,"class","clickable-icon extra-setting-button svelte-y529x8"),h(e,"aria-label",n[0]),h(e,"role","button"),h(e,"tabindex","0")},m(l,c){_(l,e,c),a&&a.m(e,null),t=!0,r||(o=[$(e,"click",n[1]),$(e,"keydown",n[1])],r=!0)},p(l,[c]){i&&i.p&&(!t||c&4)&&ve(i,s,l,l[2],t?be(s,l[2],c,null):xe(l[2]),null),(!t||c&1)&&h(e,"aria-label",l[0])},i(l){t||(v(a,l),t=!0)},o(l){k(a,l),t=!1},d(l){l&&w(e),a&&a.d(l),r=!1,me(o)}}}function AM(n,e,t){let{$$slots:r={},$$scope:o}=e,s=Xe(),{label:i="Options"}=e;function a(l){(l instanceof MouseEvent||l instanceof KeyboardEvent&&(l.key==="Enter"||l.key===" "))&&s("settings")}return n.$$set=l=>{"label"in l&&t(0,i=l.label),"$$scope"in l&&t(2,o=l.$$scope)},[i,a,o,r]}var Cm=class extends z{constructor(e){super(),W(this,e,AM,TM,j,{label:0},LM)}},rs=Cm;function FM(n){let e,t,r,o,s,i;t=new Yo({props:{class:"svg-icon",style:"margin-right: .2em; flex-shrink: 0;"}});let a=n[3].default,l=ye(a,n,n[2],null);return{c(){e=x("span"),P(t.$$.fragment),r=T(),l&&l.c(),h(e,"role","button"),h(e,"tabindex","0"),se(e,"display","flex"),se(e,"align-items","center"),se(e,"width","100%")},m(c,u){_(c,e,u),A(t,e,null),b(e,r),l&&l.m(e,null),o=!0,s||(i=[$(e,"keypress",n[0]),$(e,"click",n[0])],s=!0)},p(c,[u]){l&&l.p&&(!o||u&4)&&ve(l,a,c,c[2],o?be(a,c[2],u,null):xe(c[2]),null)},i(c){o||(v(t.$$.fragment,c),v(l,c),o=!0)},o(c){k(t.$$.fragment,c),k(l,c),o=!1},d(c){c&&w(e),F(t),l&&l.d(c),s=!1,me(i)}}}function EM(n,e,t){let{$$slots:r={},$$scope:o}=e,{relay:s=void 0}=e,i=Xe();function a(){s&&i("manageRelay",{relay:s})}return n.$$set=l=>{"relay"in l&&t(1,s=l.relay),"$$scope"in l&&t(2,o=l.$$scope)},[a,s,o,r]}var Lm=class extends z{constructor(e){super(),W(this,e,EM,FM,j,{relay:1})}},da=Lm;function PM(n){let e,t,r,o,s,i;t=new Io({props:{class:"svg-icon",style:"margin-right: .2em; flex-shrink: 0"}});let a=n[4].default,l=ye(a,n,n[3],null);return{c(){e=x("span"),P(t.$$.fragment),r=T(),l&&l.c(),h(e,"role","button"),h(e,"tabindex","0"),se(e,"display","inline-flex"),se(e,"align-items","center"),se(e,"width","100%")},m(c,u){_(c,e,u),A(t,e,null),b(e,r),l&&l.m(e,null),o=!0,s||(i=[$(e,"keypress",n[0]),$(e,"click",n[0])],s=!0)},p(c,[u]){l&&l.p&&(!o||u&8)&&ve(l,a,c,c[3],o?be(a,c[3],u,null):xe(c[3]),null)},i(c){o||(v(t.$$.fragment,c),v(l,c),o=!0)},o(c){k(t.$$.fragment,c),k(l,c),o=!1},d(c){c&&w(e),F(t),l&&l.d(c),s=!1,me(i)}}}function DM(n,e,t){let{$$slots:r={},$$scope:o}=e,{folder:s=void 0}=e,{remoteFolder:i=void 0}=e,a=Xe();function l(){var c;s&&a("manageSharedFolder",{folder:s,relay:((c=s==null?void 0:s.remote)===null||c===void 0?void 0:c.relay)||(i==null?void 0:i.relay),remoteFolder:i})}return n.$$set=c=>{"folder"in c&&t(1,s=c.folder),"remoteFolder"in c&&t(2,i=c.remoteFolder),"$$scope"in c&&t(3,o=c.$$scope)},[l,s,i,o,r]}var Mm=class extends z{constructor(e){super(),W(this,e,DM,PM,j,{folder:1,remoteFolder:2})}},Gv=Mm;function RM(n){let e,t;return e=new Io({props:{class:"svg-icon",style:"margin-right: .2em; flex-shrink: 0"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function UM(n){let e,t;return e=new Jn({props:{class:"svg-icon",style:"margin-right: .2em; flex-shrink: 0"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function OM(n){let e,t,r,o,s,i,a,l=[UM,RM],c=[];function u(p,m){var y;return(y=p[0])!=null&&y.private?0:1}t=u(n,-1),r=c[t]=l[t](n);let f=n[3].default,d=ye(f,n,n[2],null);return{c(){e=x("span"),r.c(),o=T(),d&&d.c(),h(e,"role","button"),h(e,"tabindex","0"),se(e,"display","inline-flex"),se(e,"align-items","center"),se(e,"width","100%")},m(p,m){_(p,e,m),c[t].m(e,null),b(e,o),d&&d.m(e,null),s=!0,i||(a=[$(e,"keypress",n[1]),$(e,"click",n[1])],i=!0)},p(p,[m]){let y=t;t=u(p,m),t!==y&&(ee(),k(c[y],1,1,()=>{c[y]=null}),te(),r=c[t],r||(r=c[t]=l[t](p),r.c()),v(r,1),r.m(e,o)),d&&d.p&&(!s||m&4)&&ve(d,f,p,p[2],s?be(f,p[2],m,null):xe(p[2]),null)},i(p){s||(v(r),v(d,p),s=!0)},o(p){k(r),k(d,p),s=!1},d(p){p&&w(e),c[t].d(),d&&d.d(p),i=!1,me(a)}}}function $M(n,e,t){let{$$slots:r={},$$scope:o}=e,{remoteFolder:s}=e,i=Xe();function a(){i("manageRemoteFolder",{remoteFolder:s,relay:s==null?void 0:s.relay})}return n.$$set=l=>{"remoteFolder"in l&&t(0,s=l.remoteFolder),"$$scope"in l&&t(2,o=l.$$scope)},[s,a,o,r]}var Tm=class extends z{constructor(e){super(),W(this,e,$M,OM,j,{remoteFolder:0})}},Nc=Tm;function NM(n){let e,t;return e=new Gv({props:{folder:n[0],$$slots:{default:[VM]},$$scope:{ctx:n}}}),e.$on("manageSharedFolder",n[2]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.folder=r[0]),o&17&&(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 BM(n){let e,t;return e=new Nc({props:{remoteFolder:n[0].remote,$$slots:{default:[HM]},$$scope:{ctx:n}}}),e.$on("manageRemoteFolder",n[1]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.remoteFolder=r[0].remote),o&17&&(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 VM(n){let e,t=n[0].name+"",r;return{c(){e=x("span"),r=V(t),se(e,"overflow","hidden"),se(e,"text-overflow","ellipsis"),se(e,"white-space","nowrap")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s&1&&t!==(t=o[0].name+"")&&J(r,t)},d(o){o&&w(e)}}}function HM(n){let e,t=n[0].name+"",r;return{c(){e=x("span"),r=V(t),se(e,"flex","1"),se(e,"min-width","0"),se(e,"text-overflow","ellipsis"),se(e,"white-space","nowrap")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s&1&&t!==(t=o[0].name+"")&&J(r,t)},d(o){o&&w(e)}}}function Jv(n){let e,t,r,o,s;return t=new Wd({props:{size:16,class:"svg-icon"}}),o=new da({props:{relay:n[0].remote.relay,$$slots:{default:[qM]},$$scope:{ctx:n}}}),o.$on("manageRelay",n[3]),{c(){e=x("span"),P(t.$$.fragment),r=T(),P(o.$$.fragment),se(e,"width","16px"),se(e,"flex-shrink","0"),se(e,"display","flex"),se(e,"justify-content","center")},m(i,a){_(i,e,a),A(t,e,null),_(i,r,a),A(o,i,a),s=!0},p(i,a){let l={};a&1&&(l.relay=i[0].remote.relay),a&17&&(l.$$scope={dirty:a,ctx:i}),o.$set(l)},i(i){s||(v(t.$$.fragment,i),v(o.$$.fragment,i),s=!0)},o(i){k(t.$$.fragment,i),k(o.$$.fragment,i),s=!1},d(i){i&&(w(e),w(r)),F(t),F(o,i)}}}function qM(n){let e,t=n[0].remote.relay.name+"",r;return{c(){e=x("span"),r=V(t),se(e,"flex","1"),se(e,"min-width","0"),se(e,"text-overflow","ellipsis"),se(e,"white-space","nowrap")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s&1&&t!==(t=o[0].remote.relay.name+"")&&J(r,t)},d(o){o&&w(e)}}}function jM(n){let e,t,r,o,s,i,a=[BM,NM],l=[];function c(f,d){return f[0].remote?0:1}r=c(n,-1),o=l[r]=a[r](n);let u=n[0].remote&&Jv(n);return{c(){e=x("span"),t=x("span"),o.c(),s=T(),u&&u.c(),se(t,"display","inline-flex"),se(t,"align-items","center"),se(t,"width","200px"),se(t,"min-width","200px"),se(t,"flex-shrink","0"),se(e,"display","inline-flex"),se(e,"align-items","center"),se(e,"width","100%"),se(e,"gap","8px")},m(f,d){_(f,e,d),b(e,t),l[r].m(t,null),b(e,s),u&&u.m(e,null),i=!0},p(f,[d]){let p=r;r=c(f,d),r===p?l[r].p(f,d):(ee(),k(l[p],1,1,()=>{l[p]=null}),te(),o=l[r],o?o.p(f,d):(o=l[r]=a[r](f),o.c()),v(o,1),o.m(t,null)),f[0].remote?u?(u.p(f,d),d&1&&v(u,1)):(u=Jv(f),u.c(),v(u,1),u.m(e,null)):u&&(ee(),k(u,1,1,()=>{u=null}),te())},i(f){i||(v(o),v(u),i=!0)},o(f){k(o),k(u),i=!1},d(f){f&&w(e),l[r].d(),u&&u.d()}}}function zM(n,e,t){let{folder:r}=e;function o(a){gr.call(this,n,a)}function s(a){gr.call(this,n,a)}function i(a){gr.call(this,n,a)}return n.$$set=a=>{"folder"in a&&t(0,r=a.folder)},[r,o,s,i]}var Am=class extends z{constructor(e){super(),W(this,e,zM,jM,j,{folder:0})}},Yv=Am;var ar=require("obsidian");var To=require("obsidian");function WM(n){we(n,"svelte-1aquw0",".input-with-icon.svelte-1aquw0{position:relative;width:100%}.secret-text-toggle-icon.svelte-1aquw0{display:flex;align-items:center;justify-content:center;cursor:pointer;width:24px;height:24px;position:absolute;right:12px;top:50%;transform:translateY(-50%);border-radius:4px}.secret-text-toggle-icon.svelte-1aquw0:hover{background-color:var(--background-modifier-hover)}.system3-secret-text.svelte-1aquw0{padding-inline-end:28px !important;font-family:monospace !important}.system3-input-invalid.svelte-1aquw0{border:1px solid var(--color-red) !important}")}function KM(n){let e,t,r,o;return{c(){e=x("input"),e.value=n[0],h(e,"placeholder",n[2]),h(e,"type","password"),e.readOnly=n[3],h(e,"class",t=Tt(`system3-secret-text ${n[5]?"system3-input-invalid":""}`)+" svelte-1aquw0"),e.disabled=n[1]},m(s,i){_(s,e,i),r||(o=[$(e,"click",function(){Je(n[4]?(0,To.debounce)(n[12]):null)&&(n[4]?(0,To.debounce)(n[12]):null).apply(this,arguments)}),$(e,"input",n[15]),$(e,"keydown",n[10])],r=!0)},p(s,i){n=s,i&1&&e.value!==n[0]&&(e.value=n[0]),i&4&&h(e,"placeholder",n[2]),i&8&&(e.readOnly=n[3]),i&32&&t!==(t=Tt(`system3-secret-text ${n[5]?"system3-input-invalid":""}`)+" svelte-1aquw0")&&h(e,"class",t),i&2&&(e.disabled=n[1])},d(s){s&&w(e),r=!1,me(o)}}}function GM(n){let e,t,r,o;return{c(){e=x("input"),e.value=n[0],h(e,"placeholder",n[2]),h(e,"type","text"),e.readOnly=n[3],h(e,"class",t=Tt(`system3-secret-text ${n[5]?"system3-input-invalid":""}`)+" svelte-1aquw0"),e.disabled=n[1]},m(s,i){_(s,e,i),r||(o=[$(e,"click",function(){Je(n[4]?(0,To.debounce)(n[12]):null)&&(n[4]?(0,To.debounce)(n[12]):null).apply(this,arguments)}),$(e,"input",n[14]),$(e,"keydown",n[10])],r=!0)},p(s,i){n=s,i&1&&e.value!==n[0]&&(e.value=n[0]),i&4&&h(e,"placeholder",n[2]),i&8&&(e.readOnly=n[3]),i&32&&t!==(t=Tt(`system3-secret-text ${n[5]?"system3-input-invalid":""}`)+" svelte-1aquw0")&&h(e,"class",t),i&2&&(e.disabled=n[1])},d(s){s&&w(e),r=!1,me(o)}}}function JM(n){let e,t,r,o,s,i,a;function l(f,d){return f[6]?GM:KM}let c=l(n,-1),u=c(n);return{c(){e=x("div"),u.c(),t=T(),r=x("div"),h(r,"class","secret-text-toggle-icon svelte-1aquw0"),h(r,"role","button"),h(r,"tabindex","0"),h(r,"aria-label",o=n[6]?"Hide text":"Show text"),h(e,"class","input-with-icon svelte-1aquw0")},m(f,d){_(f,e,d),u.m(e,null),b(e,t),b(e,r),i||(a=[zn(s=n[11].call(null,r)),$(r,"click",n[16]),$(r,"keypress",n[17])],i=!0)},p(f,[d]){c===(c=l(f,d))&&u?u.p(f,d):(u.d(1),u=c(f),u&&(u.c(),u.m(e,t))),d&64&&o!==(o=f[6]?"Hide text":"Show text")&&h(r,"aria-label",o)},i:B,o:B,d(f){f&&w(e),u.d(),i=!1,me(a)}}}function YM(n,e,t){let r,o,s=Xe(),{value:i}=e,{disabled:a=!1}=e,{placeholder:l="please wait..."}=e,{readonly:c=!0}=e,{copyOnClick:u=!0}=e,{successMessage:f="Copied to clipboard"}=e,{invalid:d=!1}=e,p=ge(!1);ne(n,p,U=>t(6,r=U));let m=ge(!1);ne(n,m,U=>t(19,o=U));let y;function g(U){U.key==="Enter"&&!a&&s("enter")}function I(U){y=U;let K=()=>{o?((0,To.setIcon)(U,"clipboard-check"),U.addClass("mod-success")):((0,To.setIcon)(U,r?"eye-off":"eye"),U.removeClass("mod-success"))},R=p.subscribe(()=>{K()}),O=m.subscribe(()=>{K()});return K(),{destroy(){R(),O()}}}function L(U){!u||!i||a||navigator.clipboard.writeText(i).then(()=>{new To.Notice(f),m.set(!0),setTimeout(()=>{m.set(!1)},800)}).catch(K=>{console.error("Failed to copy: ",K)})}let C=U=>{t(0,i=U.currentTarget.value),s("input",U)},S=U=>{t(0,i=U.currentTarget.value),s("input",U)},M=()=>p.update(U=>!U),E=()=>p.update(U=>!U);return n.$$set=U=>{"value"in U&&t(0,i=U.value),"disabled"in U&&t(1,a=U.disabled),"placeholder"in U&&t(2,l=U.placeholder),"readonly"in U&&t(3,c=U.readonly),"copyOnClick"in U&&t(4,u=U.copyOnClick),"successMessage"in U&&t(13,f=U.successMessage),"invalid"in U&&t(5,d=U.invalid)},[i,a,l,c,u,d,r,s,p,m,g,I,L,f,C,S,M,E]}var Fm=class extends z{constructor(e){super(),W(this,e,YM,JM,j,{value:0,disabled:1,placeholder:2,readonly:3,copyOnClick:4,successMessage:13,invalid:5},WM)}},Bc=Fm;var Vm=require("obsidian");var xx=require("obsidian");var Nm=require("obsidian");var ex=require("obsidian");function QM(n){we(n,"svelte-1dpxzin",".folder-suggest-wrapper.svelte-1dpxzin{position:relative;width:100%}.folder-suggest-input.svelte-1dpxzin{width:100%;padding:8px 12px;border:1px solid var(--background-modifier-border);border-radius:4px;background:var(--background-primary);color:var(--text-normal)}.suggestion-container.svelte-1dpxzin{position:fixed;z-index:9999;box-sizing:border-box;background:var(--background-primary);border:1px solid var(--background-modifier-border);border-radius:6px;box-shadow:var(--shadow-s);overflow-y:auto;overflow-x:hidden}.suggestion.svelte-1dpxzin{overflow-y:auto;overflow-x:hidden;max-height:100%}.suggestion-note.svelte-1dpxzin{color:var(--text-muted);font-style:italic}")}function Qv(n,e,t){let r=n.slice();return r[32]=e[t],r[34]=t,r}function Zv(n){let e,t,r,o,s,i,a=he(n[3]),l=[];for(let c=0;c<a.length;c+=1)l[c]=Xv(Qv(n,a,c));return{c(){e=x("div"),t=x("div");for(let c=0;c<l.length;c+=1)l[c].c();h(t,"class","suggestion svelte-1dpxzin"),h(e,"class","suggestion-container svelte-1dpxzin")},m(c,u){_(c,e,u),b(e,t);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(t,null);s||(i=[zn(r=tT.call(null,e)),zn(o=n[7].call(null,e))],s=!0)},p(c,u){if(u[0]&4120){a=he(c[3]);let f;for(f=0;f<a.length;f+=1){let d=Qv(c,a,f);l[f]?l[f].p(d,u):(l[f]=Xv(d),l[f].c(),l[f].m(t,null))}for(;f<l.length;f+=1)l[f].d(1);l.length=a.length}},d(c){c&&w(e),ze(l,c),s=!1,me(i)}}}function ZM(n){let e=n[32]+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&8&&e!==(e=r[32]+"")&&J(t,e)},d(r){r&&w(t)}}}function XM(n){let e,t=n[32].substring(9)+"",r;return{c(){e=x("span"),e.textContent=`Create:
|
|
`,r=V(t),h(e,"class","suggestion-note svelte-1dpxzin")},m(o,s){_(o,e,s),_(o,r,s)},p(o,s){s[0]&8&&t!==(t=o[32].substring(9)+"")&&J(r,t)},d(o){o&&(w(e),w(r))}}}function Xv(n){let e,t,r,o,s,i,a,l,c,u;function f(I,L){return L[0]&8&&(o=null),o==null&&(o=!!I[32].startsWith("[Create] ")),o?XM:ZM}let d=f(n,[-1,-1]),p=d(n);function m(){return n[19](n[32])}function y(...I){return n[20](n[32],...I)}function g(){return n[21](n[34])}return{c(){e=x("div"),t=x("div"),r=x("div"),p.c(),s=T(),i=x("div"),i.innerHTML='<div class="suggestion-icon"></div>',a=T(),h(r,"class","suggestion-title"),h(t,"class","suggestion-content"),h(i,"class","suggestion-aux"),h(e,"class","suggestion-item mod-complex"),h(e,"role","option"),h(e,"aria-selected",l=n[34]===n[4]),h(e,"tabindex","-1"),_e(e,"is-selected",n[34]===n[4])},m(I,L){_(I,e,L),b(e,t),b(t,r),p.m(r,null),b(e,s),b(e,i),b(e,a),c||(u=[$(e,"mousedown",tc(n[16])),$(e,"click",m),$(e,"keydown",y),$(e,"mouseenter",g)],c=!0)},p(I,L){n=I,d===(d=f(n,L))&&p?p.p(n,L):(p.d(1),p=d(n),p&&(p.c(),p.m(r,null))),L[0]&16&&l!==(l=n[34]===n[4])&&h(e,"aria-selected",l),L[0]&16&&_e(e,"is-selected",n[34]===n[4])},d(I){I&&w(e),p.d(),c=!1,me(u)}}}function eT(n){let e,t,r,o,s,i,a=n[5]&&n[3].length>0&&Zv(n);return{c(){e=x("div"),t=x("input"),r=T(),a&&a.c(),o=ue(),h(t,"type","text"),h(t,"placeholder",n[0]),t.disabled=n[1],h(t,"class","folder-suggest-input svelte-1dpxzin"),h(e,"class","folder-suggest-wrapper svelte-1dpxzin")},m(l,c){_(l,e,c),b(e,t),n[17](t),Ye(t,n[6]),_(l,r,c),a&&a.m(l,c),_(l,o,c),s||(i=[$(t,"input",n[18]),$(t,"input",n[9]),$(t,"keydown",n[8]),$(t,"focus",n[10]),$(t,"blur",n[11])],s=!0)},p(l,c){c[0]&1&&h(t,"placeholder",l[0]),c[0]&2&&(t.disabled=l[1]),c[0]&64&&t.value!==l[6]&&Ye(t,l[6]),l[5]&&l[3].length>0?a?a.p(l,c):(a=Zv(l),a.c(),a.m(o.parentNode,o)):a&&(a.d(1),a=null)},i:B,o:B,d(l){l&&(w(e),w(r),w(o)),n[17](null),a&&a.d(l),s=!1,me(i)}}}function tT(n){return document.body.appendChild(n),{destroy(){n.remove()}}}function rT(n,e,t){function r(D){return setTimeout(()=>{f=D,S()},0),{destroy(){}}}let{app:o}=e,{value:s=""}=e,{placeholder:i="Choose or create folder..."}=e,{blockedPaths:a=new Set}=e,{disabled:l=!1}=e,c=Xe(),u,f,d=[],p=-1,m=!1,y=s||"/",g=!1;function I(D){let Q=D.toLowerCase(),de=[],Le=Z=>{if(a.has(Z.path)&&Z.path!=="/")return;let Se=Z.path.toLowerCase(),ae=(Z.path.startsWith("/")?Z.path:"/"+Z.path).toLowerCase();if((!Q||Se.includes(Q)||ae.includes(Q))&&!a.has(Z.path)){let De=Z.path.startsWith("/")?Z.path:"/"+Z.path;de.push(De)}for(let De of Z.children)De instanceof ex.TFolder&&Le(De)},Ae=o.vault.getRoot();Le(Ae);let re=D.trim();if(re&&!de.includes(re)){let Z=re.startsWith("/")?re:"/"+re;de.unshift(`[Create] ${Z}`)}return de.slice(0,100)}function L(){return Ce(this,void 0,void 0,function*(){t(3,d=I(y)),d.length>0?(t(5,m=!0),t(4,p=0),yield Nd()):C()})}function C(){t(5,m=!1),t(3,d=[]),t(4,p=-1)}function S(){if(!u||!f)return;let D=u.getBoundingClientRect(),Q=window.innerWidth,de=window.innerHeight;f.style.position="fixed",f.style.zIndex="9999";let Le=Q<768,Z=Math.min(d.length*40+8,Le?240:300);if(f.style.top="",f.style.bottom="",f.style.left="",f.style.right="",f.style.transform="",Le){let Se=de-D.bottom,ae=D.top;f.style.left="10px",f.style.right="10px",f.style.width="auto",Se<Z+10&&ae>Z+10?(f.style.bottom=`${de-D.top+2}px`,f.style.maxHeight=`${Z}px`,f.style.height=""):(f.style.bottom=`${de-D.bottom-2}px`,f.style.maxHeight=`${Math.min(Z,Se-10)}px`,f.style.height="",f.style.transform="translateY(-100%)")}else{let Se=Math.max(D.width,350),ae=Math.min(Se,Q-D.left-20);f.style.left=`${D.left}px`,f.style.top=`${D.bottom+2}px`,f.style.width=`${ae}px`,f.style.maxHeight=`${Z}px`,f.style.height=""}}function M(D){let Q=D;D.startsWith("[Create] ")&&(Q=D.substring(9)),t(6,y=Q),t(13,s=Q),c("select",{value:Q}),C(),u==null||u.blur()}function E(D){if(!m){(D.key==="Enter"&&y.trim()||D.key==="Tab"&&!D.shiftKey&&y.trim())&&(D.preventDefault(),M(y.trim()));return}switch(D.key){case"ArrowDown":D.preventDefault(),t(4,p=Math.min(p+1,d.length-1));break;case"ArrowUp":D.preventDefault(),t(4,p=Math.max(p-1,-1));break;case"Enter":D.preventDefault(),p>=0?M(d[p]):y.trim()&&M(y.trim());break;case"Escape":D.preventDefault(),C();break;case"Tab":D.shiftKey||(D.preventDefault(),p>=0?M(d[p]):d.length>0?M(d[0]):y.trim()&&M(y.trim()));break}}function U(){g=!0,t(13,s=y),c("input",{value:y}),L()}function K(){!g&&y==="/"&&(t(6,y=""),t(13,s="")),t(3,d=I(y||"")),d.length>0&&(t(5,m=!0),t(4,p=0))}function R(D){setTimeout(()=>{f!=null&&f.contains(document.activeElement)||C()},200)}function O(D){M(D)}function q(D){!(u!=null&&u.contains(D.target))&&!(f!=null&&f.contains(D.target))&&C()}function H(){m&&S()}st(()=>{document.addEventListener("click",q),window.addEventListener("resize",H)}),Go(()=>{document.removeEventListener("click",q),window.removeEventListener("resize",H)});function G(D){gr.call(this,n,D)}function ce(D){pt[D?"unshift":"push"](()=>{u=D,t(2,u)})}function N(){y=this.value,t(6,y)}let X=D=>O(D),Me=(D,Q)=>Q.key==="Enter"&&O(D),Ie=D=>t(4,p=D);return n.$$set=D=>{"app"in D&&t(14,o=D.app),"value"in D&&t(13,s=D.value),"placeholder"in D&&t(0,i=D.placeholder),"blockedPaths"in D&&t(15,a=D.blockedPaths),"disabled"in D&&t(1,l=D.disabled)},[i,l,u,d,p,m,y,r,E,U,K,R,O,s,o,a,G,ce,N,X,Me,Ie]}var Em=class extends z{constructor(e){super(),W(this,e,rT,eT,j,{app:14,value:13,placeholder:0,blockedPaths:15,disabled:1},QM,[-1,-1])}},tx=Em;function oT(n){let e,t,r,o;function s(a){n[9](a)}let i={app:n[0],placeholder:n[2],disabled:n[3],blockedPaths:n[5]()};return n[4]!==void 0&&(i.value=n[4]),t=new tx({props:i}),pt.push(()=>cc(t,"value",s)),t.$on("select",n[6]),{c(){e=x("div"),P(t.$$.fragment),h(e,"class","folder-select-input")},m(a,l){_(a,e,l),A(t,e,null),o=!0},p(a,[l]){let c={};l&1&&(c.app=a[0]),l&4&&(c.placeholder=a[2]),l&8&&(c.disabled=a[3]),!r&&l&16&&(r=!0,c.value=a[4],ic(()=>r=!1)),t.$set(c)},i(a){o||(v(t.$$.fragment,a),o=!0)},o(a){k(t.$$.fragment,a),o=!1},d(a){a&&w(e),F(t)}}}function nT(n,e,t){let r,o=B,s=()=>(o(),o=Dt(l,y=>t(8,r=y)),l);n.$$.on_destroy.push(()=>o());let{app:i}=e,{sharedFolders:a}=e,{selectedFolder:l}=e;s();let{placeholder:c="Choose or create folder..."}=e,{disabled:u=!1}=e,f="";function d(){return new Set(a.filter(y=>!!y.relayId).map(y=>y.path))}function p(y){let g=y.detail.value;t(4,f=g),l.set(g)}function m(y){f=y,t(4,f),t(8,r)}return n.$$set=y=>{"app"in y&&t(0,i=y.app),"sharedFolders"in y&&t(7,a=y.sharedFolders),"selectedFolder"in y&&s(t(1,l=y.selectedFolder)),"placeholder"in y&&t(2,c=y.placeholder),"disabled"in y&&t(3,u=y.disabled)},n.$$.update=()=>{n.$$.dirty&272&&r&&r!==f&&t(4,f=r)},[i,l,c,u,f,d,p,a,r,m]}var Pm=class extends z{constructor(e){super(),W(this,e,nT,oT,j,{app:0,sharedFolders:7,selectedFolder:1,placeholder:2,disabled:3})}},rx=Pm;function sT(n){we(n,"svelte-1cvg97u",".faint.svelte-1cvg97u.svelte-1cvg97u{color:var(--text-faint)}.breadcrumb-container.svelte-1cvg97u.svelte-1cvg97u{display:flex;align-items:center;gap:8px;overflow:hidden}.breadcrumb-item-wrapper.svelte-1cvg97u.svelte-1cvg97u{display:flex;align-items:center;gap:0.3em;min-width:0}.breadcrumb-item.svelte-1cvg97u.svelte-1cvg97u{display:flex;align-items:center;gap:0.3em;cursor:pointer;min-width:0}.breadcrumb-text.svelte-1cvg97u.svelte-1cvg97u{display:inline-block}@media(max-width: 768px){.breadcrumb-item-wrapper.svelte-1cvg97u.svelte-1cvg97u:last-child{flex:1;min-width:0;overflow:hidden}.middle-item.svelte-1cvg97u .breadcrumb-text.svelte-1cvg97u{display:none}.last-item.svelte-1cvg97u.svelte-1cvg97u{overflow:hidden}.last-item.svelte-1cvg97u .breadcrumb-text.svelte-1cvg97u{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}")}function ox(n,e,t){let r=n.slice();return r[6]=e[t],r[8]=t,r}function iT(n){let e,t;return e=new Xd({props:{size:16,class:"breadcrumb-separator"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function nx(n){let e,t,r;var o=n[2](n[6]);function s(i,a){return{props:{class:"svg-icon breadcrumb-icon"}}}return o&&(e=Gs(o,s(n))),{c(){e&&P(e.$$.fragment),t=ue()},m(i,a){e&&A(e,i,a),_(i,t,a),r=!0},p(i,a){if(a&1&&o!==(o=i[2](i[6]))){if(e){ee();let l=e;k(l.$$.fragment,1,0,()=>{F(l,1)}),te()}o?(e=Gs(o,s(i,a)),P(e.$$.fragment),v(e.$$.fragment,1),A(e,t.parentNode,t)):e=null}},i(i){r||(e&&v(e.$$.fragment,i),r=!0)},o(i){e&&k(e.$$.fragment,i),r=!1},d(i){i&&w(t),e&&F(e,i)}}}function aT(n){let e;function t(s,i){return s[6].remoteFolder.name?dT:fT}let r=t(n,-1),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function lT(n){let e=n[6].folder.name+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&1&&e!==(e=r[6].folder.name+"")&&J(t,e)},d(r){r&&w(t)}}}function cT(n){let e;function t(s,i){return s[6].relay.name?mT:pT}let r=t(n,-1),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function uT(n){let e=n[6].text+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&1&&e!==(e=r[6].text+"")&&J(t,e)},d(r){r&&w(t)}}}function fT(n){let e;return{c(){e=x("span"),e.textContent="(Untitled folder)",h(e,"class","faint svelte-1cvg97u")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function dT(n){let e=n[6].remoteFolder.name+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&1&&e!==(e=r[6].remoteFolder.name+"")&&J(t,e)},d(r){r&&w(t)}}}function pT(n){let e;return{c(){e=x("span"),e.textContent="(Untitled Relay Server)",h(e,"class","faint svelte-1cvg97u")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function mT(n){let e=n[6].relay.name+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&1&&e!==(e=r[6].relay.name+"")&&J(t,e)},d(r){r&&w(t)}}}function sx(n){let e,t,r,o=n[2](n[6]),s,i,a,l,c,u,f,d=n[8]>0&&iT(n),p=o&&nx(n);function m(C,S){if(C[6].type==="text")return uT;if(C[6].type==="relay")return cT;if(C[6].type==="folder")return lT;if(C[6].type==="remoteFolder")return aT}let y=m(n,-1),g=y&&y(n);function I(){return n[3](n[6])}function L(...C){return n[4](n[6],...C)}return{c(){d&&d.c(),e=T(),t=x("span"),r=x("span"),p&&p.c(),s=T(),i=x("span"),g&&g.c(),l=T(),h(i,"class","breadcrumb-text svelte-1cvg97u"),h(r,"tabindex","0"),h(r,"role","button"),h(r,"class",a="breadcrumb-item "+(n[8]===0?"first-item":"")+" "+(n[8]===n[0].length-1?"last-item":"")+" "+(n[8]>0&&n[8]<n[0].length-1?"middle-item":"")+" svelte-1cvg97u"),h(t,"class","breadcrumb-item-wrapper svelte-1cvg97u")},m(C,S){d&&d.m(C,S),_(C,e,S),_(C,t,S),b(t,r),p&&p.m(r,null),b(r,s),b(r,i),g&&g.m(i,null),b(t,l),c=!0,u||(f=[$(r,"click",I),$(r,"keypress",L)],u=!0)},p(C,S){n=C,S&1&&(o=n[2](n[6])),o?p?(p.p(n,S),S&1&&v(p,1)):(p=nx(n),p.c(),v(p,1),p.m(r,s)):p&&(ee(),k(p,1,1,()=>{p=null}),te()),y===(y=m(n,S))&&g?g.p(n,S):(g&&g.d(1),g=y&&y(n),g&&(g.c(),g.m(i,null))),(!c||S&1&&a!==(a="breadcrumb-item "+(n[8]===0?"first-item":"")+" "+(n[8]===n[0].length-1?"last-item":"")+" "+(n[8]>0&&n[8]<n[0].length-1?"middle-item":"")+" svelte-1cvg97u"))&&h(r,"class",a)},i(C){c||(v(d),v(p),c=!0)},o(C){k(d),k(p),c=!1},d(C){C&&(w(e),w(t)),d&&d.d(C),p&&p.d(),g&&g.d(),u=!1,me(f)}}}function Dm(n){let e,t,r=he(n[0]),o=[];for(let i=0;i<r.length;i+=1)o[i]=sx(ox(n,r,i));let s=i=>k(o[i],1,1,()=>{o[i]=null});return{c(){e=x(n[1]);for(let i=0;i<o.length;i+=1)o[i].c();Mb(n[1])(e,{class:"breadcrumb-container svelte-1cvg97u"})},m(i,a){_(i,e,a);for(let l=0;l<o.length;l+=1)o[l]&&o[l].m(e,null);t=!0},p(i,a){if(a&5){r=he(i[0]);let l;for(l=0;l<r.length;l+=1){let c=ox(i,r,l);o[l]?(o[l].p(c,a),v(o[l],1)):(o[l]=sx(c),o[l].c(),v(o[l],1),o[l].m(e,null))}for(ee(),l=r.length;l<o.length;l+=1)s(l);te()}},i(i){if(!t){for(let a=0;a<r.length;a+=1)v(o[a]);t=!0}},o(i){o=o.filter(Boolean);for(let a=0;a<o.length;a+=1)k(o[a]);t=!1},d(i){i&&w(e),ze(o,i)}}}function hT(n){let e=n[1],t,r,o=n[1]&&Dm(n);return{c(){o&&o.c(),t=ue()},m(s,i){o&&o.m(s,i),_(s,t,i)},p(s,[i]){s[1]?e?j(e,s[1])?(o.d(1),o=Dm(s),e=s[1],o.c(),o.m(t.parentNode,t)):o.p(s,i):(o=Dm(s),e=s[1],o.c(),o.m(t.parentNode,t)):e&&(o.d(1),o=null,e=s[1])},i:B,o(s){k(o,s),r=!1},d(s){s&&w(t),o&&o.d(s)}}}function ix(n){n.onClick&&n.onClick()}function gT(n,e,t){let{items:r}=e,{element:o="h4"}=e,s=Xe();function i(c){var u;switch(c.type){case"home":return fp;case"relay":return Yo;case"folder":return lo;case"remoteFolder":return!((u=c.remoteFolder)===null||u===void 0)&&u.private?Jn:Io;default:return null}}let a=c=>ix(c),l=(c,u)=>{(u.key==="Enter"||u.key===" ")&&ix(c)};return n.$$set=c=>{"items"in c&&t(0,r=c.items),"element"in c&&t(1,o=c.element)},[r,o,i,a,l]}var Rm=class extends z{constructor(e){super(),W(this,e,gT,hT,j,{items:0,element:1},sT)}},Ao=Rm;function yT(n){we(n,"svelte-1lplldj",".folder-transformation.svelte-1lplldj{display:flex;align-items:center;padding:8px 12px;background:var(--background-secondary);border:1px solid var(--background-modifier-border);border-radius:4px;gap:8px}.folder-transformation.readonly.svelte-1lplldj{background:var(--background-secondary);border:1px solid var(--background-modifier-border)}.folder-state.svelte-1lplldj{display:flex;align-items:center;gap:6px}.folder-name.svelte-1lplldj{font-weight:500;color:var(--text-normal);white-space:nowrap}.clear-button.svelte-1lplldj{background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:16px;padding:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center;border-radius:2px;margin-left:auto}.clear-button.svelte-1lplldj:hover{background:var(--background-modifier-hover);color:var(--text-normal)}.folder-select-button.svelte-1lplldj{width:100%;min-height:3em;text-align:left}.disabled-message.svelte-1lplldj{margin:8px 0 0 0;color:var(--text-warning);font-size:var(--font-ui-smaller)}")}function bT(n){let e;function t(s,i){return s[5]?wT:xT}let r=t(n,-1),o=r(n);return{c(){e=x("div"),o.c(),h(e,"class","folder-suggest-container")},m(s,i){_(s,e,i),o.m(e,null)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e,null)))},i:B,o:B,d(s){s&&w(e),o.d()}}}function vT(n){let e,t,r,o,s,i=[kT,ST,_T],a=[];function l(u,f){return u[8]?0:u[2]?1:2}t=l(n,-1),r=a[t]=i[t](n);let c=!n[4]&&lx(n);return{c(){e=x("div"),r.c(),o=T(),c&&c.c(),h(e,"class","folder-transformation svelte-1lplldj"),_e(e,"readonly",n[4])},m(u,f){_(u,e,f),a[t].m(e,null),b(e,o),c&&c.m(e,null),s=!0},p(u,f){let d=t;t=l(u,f),t===d?a[t].p(u,f):(ee(),k(a[d],1,1,()=>{a[d]=null}),te(),r=a[t],r?r.p(u,f):(r=a[t]=i[t](u),r.c()),v(r,1),r.m(e,o)),u[4]?c&&(c.d(1),c=null):c?c.p(u,f):(c=lx(u),c.c(),c.m(e,null)),(!s||f&16)&&_e(e,"readonly",u[4])},i(u){s||(v(r),s=!0)},o(u){k(r),s=!1},d(u){u&&w(e),a[t].d(),c&&c.d()}}}function xT(n){let e,t,r,o;return{c(){e=x("button"),t=V(n[3]),h(e,"class","mod-cta folder-select-button svelte-1lplldj")},m(s,i){_(s,e,i),b(e,t),r||(o=$(e,"click",n[10]),r=!0)},p(s,i){i&8&&J(t,s[3])},d(s){s&&w(e),r=!1,o()}}}function wT(n){let e,t,r,o,s=n[6]&&ax(n);return{c(){e=x("button"),t=V(n[3]),r=T(),s&&s.c(),o=ue(),h(e,"class","mod-cta folder-select-button svelte-1lplldj"),e.disabled=!0},m(i,a){_(i,e,a),b(e,t),_(i,r,a),s&&s.m(i,a),_(i,o,a)},p(i,a){a&8&&J(t,i[3]),i[6]?s?s.p(i,a):(s=ax(i),s.c(),s.m(o.parentNode,o)):s&&(s.d(1),s=null)},d(i){i&&(w(e),w(r),w(o)),s&&s.d(i)}}}function ax(n){let e,t;return{c(){e=x("p"),t=V(n[6]),h(e,"class","mod-warning disabled-message svelte-1lplldj")},m(r,o){_(r,e,o),b(e,t)},p(r,o){o&64&&J(t,r[6])},d(r){r&&w(e)}}}function _T(n){let e,t,r,o,s,i;return t=new Io({props:{class:"svg-icon folder-icon"}}),{c(){e=x("div"),P(t.$$.fragment),r=T(),o=x("span"),s=V(n[7]),h(o,"class","folder-name svelte-1lplldj"),h(e,"class","folder-state svelte-1lplldj")},m(a,l){_(a,e,l),A(t,e,null),b(e,r),b(e,o),b(o,s),i=!0},p(a,l){(!i||l&128)&&J(s,a[7])},i(a){i||(v(t.$$.fragment,a),i=!0)},o(a){k(t.$$.fragment,a),i=!1},d(a){a&&w(e),F(t)}}}function ST(n){let e,t,r,o,s,i,a,l,c,u,f,d,p,m,y;t=new lp({props:{class:"svg-icon folder-icon"}}),a=new Gd({props:{class:"svg-icon arrow-icon"}});let g=[CT,IT],I=[];function L(C,S){return C[1]?0:1}return u=L(n,-1),f=I[u]=g[u](n),{c(){e=x("div"),P(t.$$.fragment),r=T(),o=x("span"),s=V(n[7]),i=T(),P(a.$$.fragment),l=T(),c=x("div"),f.c(),d=T(),p=x("span"),m=V(n[7]),h(o,"class","folder-name svelte-1lplldj"),h(e,"class","folder-state svelte-1lplldj"),h(p,"class","folder-name svelte-1lplldj"),h(c,"class","folder-state svelte-1lplldj")},m(C,S){_(C,e,S),A(t,e,null),b(e,r),b(e,o),b(o,s),_(C,i,S),A(a,C,S),_(C,l,S),_(C,c,S),I[u].m(c,null),b(c,d),b(c,p),b(p,m),y=!0},p(C,S){(!y||S&128)&&J(s,C[7]);let M=u;u=L(C,S),u!==M&&(ee(),k(I[M],1,1,()=>{I[M]=null}),te(),f=I[u],f||(f=I[u]=g[u](C),f.c()),v(f,1),f.m(c,d)),(!y||S&128)&&J(m,C[7])},i(C){y||(v(t.$$.fragment,C),v(a.$$.fragment,C),v(f),y=!0)},o(C){k(t.$$.fragment,C),k(a.$$.fragment,C),k(f),y=!1},d(C){C&&(w(e),w(i),w(l),w(c)),F(t),F(a,C),I[u].d()}}}function kT(n){let e,t;return e=new Ao({props:{element:"div",items:[{type:"relay",relay:n[0].relay},{type:"remoteFolder",remoteFolder:n[0]}]}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.items=[{type:"relay",relay:r[0].relay},{type:"remoteFolder",remoteFolder:r[0]}]),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 IT(n){let e,t;return e=new Io({props:{class:"svg-icon folder-icon"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function CT(n){let e,t;return e=new Jn({props:{class:"svg-icon folder-icon"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function lx(n){let e,t,r;return{c(){e=x("button"),e.textContent="\xD7",h(e,"class","clear-button svelte-1lplldj")},m(o,s){_(o,e,s),t||(r=$(e,"click",n[9]),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function LT(n){let e,t,r,o,s=[vT,bT],i=[];function a(l,c){return l[0]?0:1}return t=a(n,-1),r=i[t]=s[t](n),{c(){e=x("div"),r.c(),h(e,"class","folder-selector")},m(l,c){_(l,e,c),i[t].m(e,null),o=!0},p(l,[c]){let u=t;t=a(l,c),t===u?i[t].p(l,c):(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),r=i[t],r?r.p(l,c):(r=i[t]=s[t](l),r.c()),v(r,1),r.m(e,null))},i(l){o||(v(r),o=!0)},o(l){k(r),o=!1},d(l){l&&w(e),i[t].d()}}}function MT(n,e,t){let r,o,s,{selectedItem:i=void 0}=e,{isPrivate:a=!1}=e,{showTransformation:l=!1}=e,{selectButtonText:c="Choose a folder..."}=e,{readonly:u=!1}=e,{disabled:f=!1}=e,{disabledMessage:d=""}=e,p=Xe();function m(){p("clear")}function y(){p("select")}return n.$$set=g=>{"selectedItem"in g&&t(0,i=g.selectedItem),"isPrivate"in g&&t(1,a=g.isPrivate),"showTransformation"in g&&t(2,l=g.showTransformation),"selectButtonText"in g&&t(3,c=g.selectButtonText),"readonly"in g&&t(4,u=g.readonly),"disabled"in g&&t(5,f=g.disabled),"disabledMessage"in g&&t(6,d=g.disabledMessage)},n.$$.update=()=>{n.$$.dirty&1&&t(8,r=i&&typeof i=="object"),n.$$.dirty&1&&t(11,o=typeof i=="string"?i:""),n.$$.dirty&2048&&t(7,s=o?o.split("/").pop()||o:"")},[i,a,l,c,u,f,d,s,r,m,y,o]}var Um=class extends z{constructor(e){super(),W(this,e,MT,LT,j,{selectedItem:0,isPrivate:1,showTransformation:2,selectButtonText:3,readonly:4,disabled:5,disabledMessage:6},yT)}},pa=Um;var aQ=require("obsidian");function cx(n,e,t){let r=n.slice();return r[23]=e[t],r}function ux(n,e,t){let r=n.slice();return r[26]=e[t],r[28]=t,r}var TT=n=>({item:n&8}),fx=n=>({item:n[26],index:n[28]}),AT=n=>({item:n&8}),dx=n=>({item:n[26],index:n[28]});function FT(n){let e=n[26]+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&8&&e!==(e=r[26]+"")&&J(t,e)},d(r){r&&w(t)}}}function ET(n){let e;return{c(){e=x("div"),h(e,"class","suggestion-icon")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function px(n){let e,t,r,o,s,i,a,l,c,u,f=n[13].suggestion,d=ye(f,n,n[12],dx),p=d||FT(n),m=n[13]["suggestion-aux"],y=ye(m,n,n[12],fx),g=y||ET(n);function I(){return n[17](n[26])}function L(...S){return n[18](n[26],...S)}function C(){return n[19](n[28])}return{c(){e=x("div"),t=x("div"),r=x("div"),p&&p.c(),o=T(),s=x("div"),g&&g.c(),i=T(),h(r,"class","suggestion-title"),h(t,"class","suggestion-content"),h(s,"class","suggestion-aux"),h(e,"class","suggestion-item mod-complex"),h(e,"role","option"),h(e,"aria-selected",a=n[28]===n[4]),h(e,"tabindex","-1"),_e(e,"is-selected",n[28]===n[4])},m(S,M){_(S,e,M),b(e,t),b(t,r),p&&p.m(r,null),b(e,o),b(e,s),g&&g.m(s,null),b(e,i),l=!0,c||(u=[$(e,"mousedown",tc(n[14])),$(e,"click",I),$(e,"keydown",L),$(e,"mouseenter",C)],c=!0)},p(S,M){n=S,d?d.p&&(!l||M&4104)&&ve(d,f,n,n[12],l?be(f,n[12],M,AT):xe(n[12]),dx):p&&p.p&&(!l||M&8)&&p.p(n,l?M:-1),y&&y.p&&(!l||M&4104)&&ve(y,m,n,n[12],l?be(m,n[12],M,TT):xe(n[12]),fx),(!l||M&16&&a!==(a=n[28]===n[4]))&&h(e,"aria-selected",a),(!l||M&16)&&_e(e,"is-selected",n[28]===n[4])},i(S){l||(v(p,S),v(g,S),l=!0)},o(S){k(p,S),k(g,S),l=!1},d(S){S&&w(e),p&&p.d(S),g&&g.d(S),c=!1,me(u)}}}function mx(n){let e,t,r=n[23].command+"",o,s,i,a=n[23].purpose+"",l,c;return{c(){e=x("div"),t=x("span"),o=V(r),s=T(),i=x("span"),l=V(a),c=T(),h(t,"class","prompt-instruction-command"),h(e,"class","prompt-instruction")},m(u,f){_(u,e,f),b(e,t),b(t,o),b(e,s),b(e,i),b(i,l),b(e,c)},p(u,f){f&2&&r!==(r=u[23].command+"")&&J(o,r),f&2&&a!==(a=u[23].purpose+"")&&J(l,a)},d(u){u&&w(e)}}}function PT(n){let e,t,r,o,s,i,a,l,c,u,f,d,p,m,y=he(n[3]),g=[];for(let S=0;S<y.length;S+=1)g[S]=px(ux(n,y,S));let I=S=>k(g[S],1,1,()=>{g[S]=null}),L=he(n[1]),C=[];for(let S=0;S<L.length;S+=1)C[S]=mx(cx(n,L,S));return{c(){e=x("div"),t=x("div"),r=x("input"),o=T(),s=x("div"),i=T(),a=x("div"),l=T(),c=x("div");for(let S=0;S<g.length;S+=1)g[S].c();u=T(),f=x("div");for(let S=0;S<C.length;S+=1)C[S].c();h(r,"type","text"),h(r,"placeholder",n[0]),h(r,"class","prompt-input"),h(r,"autocapitalize","off"),h(r,"spellcheck","false"),h(r,"enterkeyhint","done"),h(s,"class","prompt-input-cta"),h(a,"class","search-input-clear-button"),h(t,"class","prompt-input-container"),h(c,"class","prompt-results"),h(f,"class","prompt-instructions"),h(e,"class","prompt")},m(S,M){_(S,e,M),b(e,t),b(t,r),n[15](r),Ye(r,n[5]),b(t,o),b(t,s),b(t,i),b(t,a),b(e,l),b(e,c);for(let E=0;E<g.length;E+=1)g[E]&&g[E].m(c,null);b(e,u),b(e,f);for(let E=0;E<C.length;E+=1)C[E]&&C[E].m(f,null);d=!0,p||(m=[$(r,"input",n[16]),$(r,"input",n[7]),$(r,"keydown",n[6])],p=!0)},p(S,[M]){if((!d||M&1)&&h(r,"placeholder",S[0]),M&32&&r.value!==S[5]&&Ye(r,S[5]),M&4376){y=he(S[3]);let E;for(E=0;E<y.length;E+=1){let U=ux(S,y,E);g[E]?(g[E].p(U,M),v(g[E],1)):(g[E]=px(U),g[E].c(),v(g[E],1),g[E].m(c,null))}for(ee(),E=y.length;E<g.length;E+=1)I(E);te()}if(M&2){L=he(S[1]);let E;for(E=0;E<L.length;E+=1){let U=cx(S,L,E);C[E]?C[E].p(U,M):(C[E]=mx(U),C[E].c(),C[E].m(f,null))}for(;E<C.length;E+=1)C[E].d(1);C.length=L.length}},i(S){if(!d){for(let M=0;M<y.length;M+=1)v(g[M]);d=!0}},o(S){g=g.filter(Boolean);for(let M=0;M<g.length;M+=1)k(g[M]);d=!1},d(S){S&&w(e),n[15](null),ze(g,S),ze(C,S),p=!1,me(m)}}}function DT(n,e,t){let{$$slots:r={},$$scope:o}=e,{placeholder:s="Search..."}=e,{autofocus:i=!1}=e,{onSelect:a=()=>{}}=e,{getSuggestions:l=()=>[]}=e,{instructions:c=[{command:"\u2191/\u2193",purpose:"Navigate"},{command:"Enter",purpose:"Select"},{command:"Esc",purpose:"Cancel"}]}=e,u=Xe(),f,d=[],p=0,m="";function y(){t(3,d=l(m)),t(4,p=0)}function g(O){a(O),u("select",{item:O})}function I(O){switch(O.key){case"ArrowDown":O.preventDefault(),t(4,p=Math.min(p+1,d.length-1));break;case"ArrowUp":O.preventDefault(),t(4,p=Math.max(p-1,-1));break;case"Enter":O.preventDefault(),p>=0?g(d[p]):m.trim()&&d.length===0&&u("customInput",{value:m.trim()});break;case"Tab":O.shiftKey||(O.preventDefault(),p>=0?g(d[p]):d.length>0&&g(d[0]));break}}function L(){y(),u("input",{value:m})}function C(O){g(O)}st(()=>{i&&f&&setTimeout(()=>{f.focus()},10),y()});function S(O){gr.call(this,n,O)}function M(O){pt[O?"unshift":"push"](()=>{f=O,t(2,f)})}function E(){m=this.value,t(5,m)}let U=O=>C(O),K=(O,q)=>q.key==="Enter"&&C(O),R=O=>t(4,p=O);return n.$$set=O=>{"placeholder"in O&&t(0,s=O.placeholder),"autofocus"in O&&t(9,i=O.autofocus),"onSelect"in O&&t(10,a=O.onSelect),"getSuggestions"in O&&t(11,l=O.getSuggestions),"instructions"in O&&t(1,c=O.instructions),"$$scope"in O&&t(12,o=O.$$scope)},[s,c,f,d,p,m,I,L,C,i,a,l,o,r,S,M,E,U,K,R]}var Om=class extends z{constructor(e){super(),W(this,e,DT,PT,j,{placeholder:0,autofocus:9,onSelect:10,getSuggestions:11,instructions:1})}},Vc=Om;function RT(n){let e,t;return e=new Ao({props:{element:"div",items:[{type:"relay",relay:n[5].relay},{type:"remoteFolder",remoteFolder:n[5]}]}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&32&&(s.items=[{type:"relay",relay:r[5].relay},{type:"remoteFolder",remoteFolder:r[5]}]),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 UT(n){let e,t;return e=new Vc({props:{placeholder:n[0],autofocus:n[1],onSelect:n[2],getSuggestions:n[3],instructions:[{command:"\u2191/\u2193",purpose:"Navigate"},{command:"Enter",purpose:"Add folder to vault"},{command:"Esc",purpose:"Cancel"}],$$slots:{suggestion:[RT,({item:r})=>({5:r}),({item:r})=>r?32:0]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,[o]){let s={};o&1&&(s.placeholder=r[0]),o&2&&(s.autofocus=r[1]),o&4&&(s.onSelect=r[2]),o&96&&(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 OT(n,e,t){let{availableFolders:r}=e,{placeholder:o="Search folders..."}=e,{autofocus:s=!1}=e,{onSelect:i=()=>{}}=e;function a(l){let c=l.toLowerCase();return r.filter(f=>{var d;let p=(f.name||"").toLowerCase(),m=(((d=f.relay)===null||d===void 0?void 0:d.name)||"").toLowerCase();return!!f.relay.name&&f.name&&(p.includes(c)||m.includes(c))}).sort((f,d)=>{let p=`${f.relay.name} / ${f.name}`,m=`${d.relay.name} / ${d.name}`;return p.localeCompare(m)}).slice(0,100)}return n.$$set=l=>{"availableFolders"in l&&t(4,r=l.availableFolders),"placeholder"in l&&t(0,o=l.placeholder),"autofocus"in l&&t(1,s=l.autofocus),"onSelect"in l&&t(2,i=l.onSelect)},[o,s,i,a,r]}var $m=class extends z{constructor(e){super(),W(this,e,OT,UT,j,{availableFolders:4,placeholder:0,autofocus:1,onSelect:2})}},hx=$m;var gx=require("obsidian"),si=class extends gx.Modal{constructor(t,r,o,s){super(t);this.ComponentClass=r;this.componentProps=o;this.onSelect=s}onOpen(){let{modalEl:t}=this,r=t.closest(".modal-container");t.style.display="none";let o=r||t;this.component=new this.ComponentClass({target:o,props:{...this.componentProps,autofocus:!0,onSelect:s=>{this.onSelect(s),this.close()}}})}onClose(){var t;(t=this.component)==null||t.$destroy()}destroy(){this.onSelect=null,this.componentProps=null,this.ComponentClass=null}};var Hc=class extends si{constructor(e,t,r){super(e,hx,{availableFolders:t,placeholder:"Search folders..."},r)}};function $T(n){we(n,"svelte-djtxkf","span.error.svelte-djtxkf{flex:auto;align-content:center}.section.svelte-djtxkf{margin-bottom:24px}")}function yx(n){let e,t,r,o,s;return t=new Qe({props:{name:"Remote folder"}}),o=new pa({props:{selectedItem:n[6],selectButtonText:"Choose a folder...",disabled:n[2].length===0,disabledMessage:n[2].length===0?n[3]:""}}),o.$on("clear",n[13]),o.$on("select",n[14]),{c(){e=x("div"),P(t.$$.fragment),r=T(),P(o.$$.fragment),h(e,"class","section svelte-djtxkf")},m(i,a){_(i,e,a),A(t,e,null),b(e,r),A(o,e,null),s=!0},p(i,a){let l={};a&64&&(l.selectedItem=i[6]),a&4&&(l.disabled=i[2].length===0),a&12&&(l.disabledMessage=i[2].length===0?i[3]:""),o.$set(l)},i(i){s||(v(t.$$.fragment,i),v(o.$$.fragment,i),s=!0)},o(i){k(t.$$.fragment,i),k(o.$$.fragment,i),s=!1},d(i){i&&w(e),F(t),F(o)}}}function NT(n){let e,t,r,o;return{c(){e=x("input"),h(e,"type","text"),e.disabled=t=!n[6]},m(s,i){_(s,e,i),Ye(e,n[7]),r||(o=$(e,"input",n[15]),r=!0)},p(s,i){i&64&&t!==(t=!s[6])&&(e.disabled=t),i&128&&e.value!==s[7]&&Ye(e,s[7])},d(s){s&&w(e),r=!1,o()}}}function BT(n){let e,t;return e=new rx({props:{app:n[0],sharedFolders:n[4],selectedFolder:n[10],disabled:n[2].length===0}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.app=r[0]),o&16&&(s.sharedFolders=r[4]),o&4&&(s.disabled=r[2].length===0),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 bx(n){let e,t;return{c(){e=x("span"),t=V(n[8]),h(e,"class","mod-warning error svelte-djtxkf")},m(r,o){_(r,e,o),b(e,t)},p(r,o){o&256&&J(t,r[8])},d(r){r&&w(e)}}}function VT(n){let e,t,r,o,s,i,a,l,c,u,f,d,p,m,y,g,I=!n[1]&&yx(n);s=new Re({props:{name:"Folder name",description:"Set the name of the folder to be added.",$$slots:{default:[NT]},$$scope:{ctx:n}}}),a=new Re({props:{name:"Folder location",description:"Set the location in your vault.",$$slots:{default:[BT]},$$scope:{ctx:n}}});let L=n[8]&&bx(n);return{c(){e=x("div"),e.textContent="Add to vault",t=T(),r=x("div"),I&&I.c(),o=T(),P(s.$$.fragment),i=T(),P(a.$$.fragment),l=T(),c=x("div"),L&&L.c(),u=T(),f=x("button"),d=V("Confirm"),h(e,"class","modal-title"),h(f,"class","mod-cta"),f.disabled=p=!n[6]||!n[7].trim(),h(c,"class","modal-button-container"),h(r,"class","modal-content")},m(C,S){_(C,e,S),_(C,t,S),_(C,r,S),I&&I.m(r,null),b(r,o),A(s,r,null),b(r,i),A(a,r,null),b(r,l),b(r,c),L&&L.m(c,null),b(c,u),b(c,f),b(f,d),m=!0,y||(g=$(f,"click",function(){Je((0,Nm.debounce)(n[16]))&&(0,Nm.debounce)(n[16]).apply(this,arguments)}),y=!0)},p(C,[S]){n=C,n[1]?I&&(ee(),k(I,1,1,()=>{I=null}),te()):I?(I.p(n,S),S&2&&v(I,1)):(I=yx(n),I.c(),v(I,1),I.m(r,o));let M={};S&131264&&(M.$$scope={dirty:S,ctx:n}),s.$set(M);let E={};S&131093&&(E.$$scope={dirty:S,ctx:n}),a.$set(E),n[8]?L?L.p(n,S):(L=bx(n),L.c(),L.m(c,u)):L&&(L.d(1),L=null),(!m||S&192&&p!==(p=!n[6]||!n[7].trim()))&&(f.disabled=p)},i(C){m||(v(I),v(s.$$.fragment,C),v(a.$$.fragment,C),m=!0)},o(C){k(I),k(s.$$.fragment,C),k(a.$$.fragment,C),m=!1},d(C){C&&(w(e),w(t),w(r)),I&&I.d(),F(s),F(a),L&&L.d(),y=!1,g()}}}function HT(n,e,t){let r,{app:o}=e,{remoteFolder:s}=e,{availableFolders:i=[]}=e,{noFoldersMessage:a="No remote folders available to add."}=e,{sharedFolders:l}=e,{onConfirm:c}=e,u=s,f=(s==null?void 0:s.name)||"",d=ge("/");ne(n,d,S=>t(9,r=S));let p="",m=s,y=new Hc(o,i,S=>{t(6,u=S)});st(()=>{!s&&i.length>0&&setTimeout(()=>{y.open()},100)}),Go(()=>{y.close(),y.destroy()});let g=()=>{t(6,u=void 0),t(7,f="")},I=()=>{y.open()};function L(){f=this.value,t(7,f),t(6,u),t(12,m)}let C=async()=>{if(!u){t(8,p="Please select a remote folder");return}if(!f.trim()){t(8,p="Please enter a folder name");return}c(u,f,r||"/").catch(S=>{t(8,p=S.message)})};return n.$$set=S=>{"app"in S&&t(0,o=S.app),"remoteFolder"in S&&t(1,s=S.remoteFolder),"availableFolders"in S&&t(2,i=S.availableFolders),"noFoldersMessage"in S&&t(3,a=S.noFoldersMessage),"sharedFolders"in S&&t(4,l=S.sharedFolders),"onConfirm"in S&&t(5,c=S.onConfirm)},n.$$.update=()=>{n.$$.dirty&4160&&u!==m&&(u&&t(7,f=u.name||""),t(12,m=u))},[o,s,i,a,l,c,u,f,p,r,d,y,m,g,I,L,C]}var Bm=class extends z{constructor(e){super(),W(this,e,HT,VT,j,{app:0,remoteFolder:1,availableFolders:2,noFoldersMessage:3,sharedFolders:4,onConfirm:5},$T)}},vx=Bm;var Mn=class extends xx.Modal{constructor(t,r,o,s,i,a){super(t);this.sharedFolders=r;this.remoteFolder=o;this.availableFolders=s;this.onConfirm=i;this.noFoldersMessage=a;this.onConfirm=i}onOpen(){let{contentEl:t}=this;this.component=new vx({target:t,props:{remoteFolder:this.remoteFolder,availableFolders:this.availableFolders,sharedFolders:this.sharedFolders,noFoldersMessage:this.noFoldersMessage,onConfirm:async(r,o,s)=>{await this.onConfirm(r,o,s),this.close()},app:this.app}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy(),this.onConfirm=null,this.sharedFolders=null,this.remoteFolder=void 0,this.availableFolders.length=0}};var Fx=require("obsidian"),Ex=Do(An());function qT(n){we(n,"svelte-zmx7zz","span.faint.svelte-zmx7zz{color:var(--text-faint)}div.spacer.svelte-zmx7zz{height:3em}")}function wx(n,e,t){let r=n.slice();return r[33]=e[t],r[34]=e,r[35]=t,r}function _x(n,e,t){let r=n.slice();return r[36]=e[t],r}function Sx(n,e,t){let r=n.slice();return r[39]=e[t],r}function jT(n){let e,t,r,o,s,i,a,l;function c(f){n[18](f)}let u={disabled:n[5],placeholder:"Enter share key",readonly:!1,copyOnClick:!1,invalid:n[4]};return n[3]!==void 0&&(u.value=n[3]),e=new Bc({props:u}),pt.push(()=>cc(e,"value",c)),e.$on("input",n[14]),e.$on("enter",function(){Je((0,ar.debounce)(n[19]))&&(0,ar.debounce)(n[19]).apply(this,arguments)}),{c(){P(e.$$.fragment),r=T(),o=x("button"),s=V("Join"),h(o,"class","mod-cta system3-button"),o.disabled=n[5]},m(f,d){A(e,f,d),_(f,r,d),_(f,o,d),b(o,s),i=!0,a||(l=$(o,"click",function(){Je((0,ar.debounce)(n[20]))&&(0,ar.debounce)(n[20]).apply(this,arguments)}),a=!0)},p(f,d){n=f;let p={};d[0]&32&&(p.disabled=n[5]),d[0]&16&&(p.invalid=n[4]),!t&&d[0]&8&&(t=!0,p.value=n[3],ic(()=>t=!1)),e.$set(p),(!i||d[0]&32)&&(o.disabled=n[5])},i(f){i||(v(e.$$.fragment,f),i=!0)},o(f){k(e.$$.fragment,f),i=!1},d(f){f&&(w(r),w(o)),F(e,f),a=!1,l()}}}function zT(n){let e,t;return e=new Re({props:{name:"Share key",description:"Enter the code that was shared with you.",$$slots:{default:[jT]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&56|o[1]&2048&&(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 WT(n){let e;return{c(){e=x("span"),e.textContent="Relay Servers",h(e,"slot","name"),se(e,"display","inline-flex"),se(e,"align-items","center")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function KT(n){let e,t;function r(){return n[22](n[39])}return e=new rs({}),e.$on("settings",r),{c(){P(e.$$.fragment)},m(o,s){A(e,o,s),t=!0},p(o,s){n=o},i(o){t||(v(e.$$.fragment,o),t=!0)},o(o){k(e.$$.fragment,o),t=!1},d(o){F(e,o)}}}function GT(n){let e;return{c(){e=x("span"),e.textContent="(Untitled Relay Server)",h(e,"class","faint svelte-zmx7zz")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function JT(n){let e=n[39].name+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&128&&e!==(e=r[39].name+"")&&J(t,e)},d(r){r&&w(t)}}}function YT(n){let e;function t(s,i){return s[39].name?JT:GT}let r=t(n,[-1,-1]),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function QT(n){let e,t;return e=new da({props:{slot:"name",relay:n[39],$$slots:{default:[YT]},$$scope:{ctx:n}}}),e.$on("manageRelay",n[21]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&128&&(s.relay=r[39]),o[0]&128|o[1]&2048&&(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 kx(n){let e,t;return e=new Gt({props:{$$slots:{name:[QT],default:[KT]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&128|o[1]&2048&&(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 ZT(n){let e,t,r;return{c(){e=x("button"),e.textContent="Create",h(e,"class","mod-cta system3-button")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,ar.debounce)(n[23])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function XT(n){let e,t,r,o=he(n[7].values().filter(td).sort(Tx)),s=[];for(let a=0;a<o.length;a+=1)s[a]=kx(Sx(n,o,a));let i=a=>k(s[a],1,1,()=>{s[a]=null});return t=new Gt({props:{description:"",name:"",$$slots:{default:[ZT]},$$scope:{ctx:n}}}),{c(){for(let a=0;a<s.length;a+=1)s[a].c();e=T(),P(t.$$.fragment)},m(a,l){for(let c=0;c<s.length;c+=1)s[c]&&s[c].m(a,l);_(a,e,l),A(t,a,l),r=!0},p(a,l){if(l[0]&1152){o=he(a[7].values().filter(td).sort(Tx));let u;for(u=0;u<o.length;u+=1){let f=Sx(a,o,u);s[u]?(s[u].p(f,l),v(s[u],1)):(s[u]=kx(f),s[u].c(),v(s[u],1),s[u].m(e.parentNode,e))}for(ee(),u=o.length;u<s.length;u+=1)i(u);te()}let c={};l[1]&2048&&(c.$$scope={dirty:l,ctx:a}),t.$set(c)},i(a){if(!r){for(let l=0;l<o.length;l+=1)v(s[l]);v(t.$$.fragment,a),r=!0}},o(a){s=s.filter(Boolean);for(let l=0;l<s.length;l+=1)k(s[l]);k(t.$$.fragment,a),r=!1},d(a){a&&w(e),ze(s,a),F(t,a)}}}function Ix(n){let e,t;return e=new Re({props:{description:"No shared folders on this device. Share folders from a Relay Server's settings page to begin collaboration."}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function eA(n){let e,t;function r(){return n[28](n[36])}return e=new rs({}),e.$on("settings",function(){Je((0,ar.debounce)(r))&&(0,ar.debounce)(r).apply(this,arguments)}),{c(){P(e.$$.fragment)},m(o,s){A(e,o,s),t=!0},p(o,s){n=o},i(o){t||(v(e.$$.fragment,o),t=!0)},o(o){k(e.$$.fragment,o),t=!1},d(o){F(e,o)}}}function tA(n){let e,t;function r(){return n[27](n[36])}return e=new rs({}),e.$on("settings",function(){Je((0,ar.debounce)(r))&&(0,ar.debounce)(r).apply(this,arguments)}),{c(){P(e.$$.fragment)},m(o,s){A(e,o,s),t=!0},p(o,s){n=o},i(o){t||(v(e.$$.fragment,o),t=!0)},o(o){k(e.$$.fragment,o),t=!1},d(o){F(e,o)}}}function rA(n){let e,t,r,o,s=[tA,eA],i=[];function a(l,c){return l[36].remote?0:1}return e=a(n,[-1,-1]),t=i[e]=s[e](n),{c(){t.c(),r=ue()},m(l,c){i[e].m(l,c),_(l,r,c),o=!0},p(l,c){let u=e;e=a(l,c),e===u?i[e].p(l,c):(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),t=i[e],t?t.p(l,c):(t=i[e]=s[e](l),t.c()),v(t,1),t.m(r.parentNode,r))},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),i[e].d(l)}}}function oA(n){let e,t;return e=new Yv({props:{folder:n[36],slot:"name"}}),e.$on("manageSharedFolder",n[24]),e.$on("manageRemoteFolder",n[25]),e.$on("manageRelay",n[26]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&64&&(s.folder=r[36]),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 Cx(n){let e,t;return e=new Gt({props:{$$slots:{name:[oA],default:[rA]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&192|o[1]&2048&&(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 nA(n){let e,t,r;return{c(){e=x("button"),e.textContent="Add remote folder",h(e,"class","mod-cta system3-button"),h(e,"aria-label","Add remote folder to vault"),se(e,"max-width","11em")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,ar.debounce)(n[17])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function sA(n){let e=n[6].items().length===0,t,r,o,s,i=e&&Ix(n),a=he(n[6].items().sort(Ax)),l=[];for(let u=0;u<a.length;u+=1)l[u]=Cx(_x(n,a,u));let c=u=>k(l[u],1,1,()=>{l[u]=null});return o=new Gt({props:{name:"",$$slots:{default:[nA]},$$scope:{ctx:n}}}),{c(){i&&i.c(),t=T();for(let u=0;u<l.length;u+=1)l[u].c();r=T(),P(o.$$.fragment)},m(u,f){i&&i.m(u,f),_(u,t,f);for(let d=0;d<l.length;d+=1)l[d]&&l[d].m(u,f);_(u,r,f),A(o,u,f),s=!0},p(u,f){if(f[0]&64&&(e=u[6].items().length===0),e?i?f[0]&64&&v(i,1):(i=Ix(u),i.c(),v(i,1),i.m(t.parentNode,t)):i&&(ee(),k(i,1,1,()=>{i=null}),te()),f[0]&12480){a=he(u[6].items().sort(Ax));let p;for(p=0;p<a.length;p+=1){let m=_x(u,a,p);l[p]?(l[p].p(m,f),v(l[p],1)):(l[p]=Cx(m),l[p].c(),v(l[p],1),l[p].m(r.parentNode,r))}for(ee(),p=a.length;p<l.length;p+=1)c(p);te()}let d={};f[1]&2048&&(d.$$scope={dirty:f,ctx:u}),o.$set(d)},i(u){if(!s){v(i);for(let f=0;f<a.length;f+=1)v(l[f]);v(o.$$.fragment,u),s=!0}},o(u){k(i),l=l.filter(Boolean);for(let f=0;f<l.length;f+=1)k(l[f]);k(o.$$.fragment,u),s=!1},d(u){u&&(w(t),w(r)),i&&i.d(u),ze(l,u),F(o,u)}}}function Lx(n){let e,t,r,o,s,i;return r=new Qe({props:{name:"Subscriptions",helpText:"Subscriptions are tied to each Relay Server, not to your user account. Modify and cancel your subscription via our payment processor Stripe."}}),s=new vt({props:{$$slots:{default:[fA]},$$scope:{ctx:n}}}),{c(){e=x("div"),t=T(),P(r.$$.fragment),o=T(),P(s.$$.fragment),h(e,"class","spacer svelte-zmx7zz")},m(a,l){_(a,e,l),_(a,t,l),A(r,a,l),_(a,o,l),A(s,a,l),i=!0},p(a,l){let c={};l[0]&257|l[1]&2048&&(c.$$scope={dirty:l,ctx:a}),s.$set(c)},i(a){i||(v(r.$$.fragment,a),v(s.$$.fragment,a),i=!0)},o(a){k(r.$$.fragment,a),k(s.$$.fragment,a),i=!1},d(a){a&&(w(e),w(t),w(o)),F(r,a),F(s,a)}}}function iA(n){let e,t,r,o;function s(){return n[30](n[33],n[34],n[35])}return{c(){e=x("button"),e.textContent="Manage",t=T(),h(e,"class","mod-cta system3-button")},m(i,a){_(i,e,a),_(i,t,a),r||(o=$(e,"click",function(){Je((0,ar.debounce)(s))&&(0,ar.debounce)(s).apply(this,arguments)}),r=!0)},p(i,a){n=i},d(i){i&&(w(e),w(t)),r=!1,o()}}}function aA(n){let e;return{c(){e=x("span"),e.textContent="(Untitled Relay Server)",h(e,"class","faint svelte-zmx7zz")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function lA(n){let e=n[33].relay.name+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&256&&e!==(e=r[33].relay.name+"")&&J(t,e)},d(r){r&&w(t)}}}function cA(n){let e;function t(s,i){return s[33].relay.name?lA:aA}let r=t(n,[-1,-1]),o=r(n);return{c(){o.c(),e=T()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function uA(n){let e,t;return e=new da({props:{slot:"name",relay:n[33].relay,$$slots:{default:[cA]},$$scope:{ctx:n}}}),e.$on("manageRelay",n[29]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&256&&(s.relay=r[33].relay),o[0]&256|o[1]&2048&&(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 Mx(n){let e,t;return e=new Gt({props:{name:"",description:n[33].cancelAt?n[11](n[33].cancelAt):"",$$slots:{name:[uA],default:[iA]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&256&&(s.description=r[33].cancelAt?r[11](r[33].cancelAt):""),o[0]&257|o[1]&2048&&(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 fA(n){let e,t,r=he(n[8].values()),o=[];for(let i=0;i<r.length;i+=1)o[i]=Mx(wx(n,r,i));let s=i=>k(o[i],1,1,()=>{o[i]=null});return{c(){for(let i=0;i<o.length;i+=1)o[i].c();e=ue()},m(i,a){for(let l=0;l<o.length;l+=1)o[l]&&o[l].m(i,a);_(i,e,a),t=!0},p(i,a){if(a[0]&2305){r=he(i[8].values());let l;for(l=0;l<r.length;l+=1){let c=wx(i,r,l);o[l]?(o[l].p(c,a),v(o[l],1)):(o[l]=Mx(c),o[l].c(),v(o[l],1),o[l].m(e.parentNode,e))}for(ee(),l=r.length;l<o.length;l+=1)s(l);te()}},i(i){if(!t){for(let a=0;a<r.length;a+=1)v(o[a]);t=!0}},o(i){o=o.filter(Boolean);for(let a=0;a<o.length;a+=1)k(o[a]);t=!1},d(i){i&&w(e),ze(o,i)}}}function dA(n){let e,t,r,o,s,i,a,l,c,u,f,d,p=n[2].values().length>0,m,y;e=new Qe({props:{name:"Join a Relay Server"}}),r=new vt({props:{$$slots:{default:[zT]},$$scope:{ctx:n}}}),s=new Qe({props:{helpText:"A Relay Server coordinates real-time updates between collaborators. You can add collaborators and share folders on the Relay Server's settings page.",$$slots:{name:[WT]},$$scope:{ctx:n}}}),a=new vt({props:{$$slots:{default:[XT]},$$scope:{ctx:n}}}),c=new Qe({props:{name:"My vault",helpText:"The following Shared Folders have been added to your vault. You can see what Relay Server a Shared Folder is connected to below."}}),f=new vt({props:{$$slots:{default:[sA]},$$scope:{ctx:n}}});let g=p&&Lx(n);return{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment),o=T(),P(s.$$.fragment),i=T(),P(a.$$.fragment),l=T(),P(c.$$.fragment),u=T(),P(f.$$.fragment),d=T(),g&&g.c(),m=ue()},m(I,L){A(e,I,L),_(I,t,L),A(r,I,L),_(I,o,L),A(s,I,L),_(I,i,L),A(a,I,L),_(I,l,L),A(c,I,L),_(I,u,L),A(f,I,L),_(I,d,L),g&&g.m(I,L),_(I,m,L),y=!0},p(I,L){let C={};L[0]&56|L[1]&2048&&(C.$$scope={dirty:L,ctx:I}),r.$set(C);let S={};L[1]&2048&&(S.$$scope={dirty:L,ctx:I}),s.$set(S);let M={};L[0]&128|L[1]&2048&&(M.$$scope={dirty:L,ctx:I}),a.$set(M);let E={};L[0]&192|L[1]&2048&&(E.$$scope={dirty:L,ctx:I}),f.$set(E),L[0]&4&&(p=I[2].values().length>0),p?g?(g.p(I,L),L[0]&4&&v(g,1)):(g=Lx(I),g.c(),v(g,1),g.m(m.parentNode,m)):g&&(ee(),k(g,1,1,()=>{g=null}),te())},i(I){y||(v(e.$$.fragment,I),v(r.$$.fragment,I),v(s.$$.fragment,I),v(a.$$.fragment,I),v(c.$$.fragment,I),v(f.$$.fragment,I),v(g),y=!0)},o(I){k(e.$$.fragment,I),k(r.$$.fragment,I),k(s.$$.fragment,I),k(a.$$.fragment,I),k(c.$$.fragment,I),k(f.$$.fragment,I),k(g),y=!1},d(I){I&&(w(t),w(o),w(i),w(l),w(u),w(d),w(m)),F(e,I),F(r,I),F(s,I),F(a,I),F(c,I),F(f,I),g&&g.d(I)}}}function Tx(n,e){return n.owner&&!e.owner?-1:e.owner&&!n.owner||n.name>e.name?1:-1}function Ax(n,e){return n.remote&&!e.remote?-1:e.remote&&!n.remote||n.name>e.name?1:-1}function pA(n,e,t){let r,o,s=B,i=()=>(s(),s=Dt(f,re=>t(7,o=re)),f),a,l=B,c=()=>(l(),l=Dt(d,re=>t(8,a=re)),d);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l());let{plugin:u}=e,{relays:f}=e;i();let{subscriptions:d}=e;c();let p=u.sharedFolders;ne(n,p,re=>t(6,r=re));let m="",y=!1,g=!1,I=Xe();function L(re){re&&I("manageRelay",{relay:re})}function C(re){if(!re)return"Active";let Z=Vm.moment.utc(),Se=Vm.moment.utc(re),ae=Se.diff(Z,"days");return ae<=0?"Subscription has ended":ae===1?"Active for 1 more day":ae>31?`Ends on ${Se.format("YYYY-MM-DD")}`:`Active for ${ae} more days`}function S(re,Z){re&&I("manageSharedFolder",{folder:re,relay:Z})}function M(re){re&&I("manageRemoteFolder",{remoteFolder:re})}function E(){t(4,y=!1)}function U(re){return Ce(this,void 0,void 0,function*(){try{t(5,g=!0);let Z=yield u.relayManager.acceptInvitation(re).catch(Se=>{throw Se.status===429&&new ar.Notice("Slow down"),Se});t(5,g=!1),I("joinRelay",{relay:Z})}catch(Z){t(4,y=!0),t(5,g=!1)}})}function K(){I("createRelay")}function R(re,Z,Se){return Ce(this,void 0,void 0,function*(){let ae=(0,Fx.normalizePath)((0,Ex.join)(Se,Z));u.app.vault.getFolderByPath(ae)===null&&(yield u.app.vault.createFolder(ae));let Pe=u.sharedFolders.new(ae,re.guid,re.relay.guid);return Pe.remote=re,Pe})}function O(){let re=[],Z=0;o.values().forEach(Pe=>{Pe.folders&&Pe.folders.values().forEach(De=>{Z++,r.items().some(mt=>{var _t;return((_t=mt.remote)===null||_t===void 0?void 0:_t.id)===De.id})||re.push(De)})});let Se;re.length===0&&(Z===0?Se="Join a Relay Server, or add a Shared Folder on another device.":Se="All remote folders are already in your vault."),new Mn(u.app,u.sharedFolders,void 0,re,R,Se).open()}function q(re){m=re,t(3,m)}let H=()=>U(m),G=()=>U(m);function ce(re){gr.call(this,n,re)}let N=re=>{L(re)},X=()=>K();function Me(re){gr.call(this,n,re)}function Ie(re){gr.call(this,n,re)}function D(re){gr.call(this,n,re)}let Q=re=>{M(re.remote)},de=re=>{let Z=o.values().find(Se=>{var ae;return((ae=re.remote)==null?void 0:ae.relay.guid)===Se.guid});S(re,Z)};function Le(re){gr.call(this,n,re)}let Ae=async(re,Z,Se)=>{if(!re.token){let De=await u.relayManager.getSubscriptionToken(re);Ws(d,Z[Se].token=De,a)}let ae=re.id,Pe=re.token;window.open(u.buildApiUrl(`/subscriptions/${ae}/manage?token=${Pe}`),"_blank")};return n.$$set=re=>{"plugin"in re&&t(0,u=re.plugin),"relays"in re&&i(t(1,f=re.relays)),"subscriptions"in re&&c(t(2,d=re.subscriptions))},[u,f,d,m,y,g,r,o,a,p,L,C,S,M,E,U,K,O,q,H,G,ce,N,X,Me,Ie,D,Q,de,Le,Ae]}var Hm=class extends z{constructor(e){super(),W(this,e,pA,dA,j,{plugin:0,relays:1,subscriptions:2},qT,[-1,-1])}},Fo=Hm;var At=require("obsidian");var gw=Do(An());function mA(n){we(n,"svelte-15ov1wm",".lock-icon.svelte-15ov1wm{width:16px;height:16px;opacity:0.5;display:flex;align-items:center;justify-content:center}")}function hA(n){let e,t,r;return t=new gp({props:{class:"svg-icon"}}),{c(){e=x("span"),P(t.$$.fragment),h(e,"class","lock-icon svelte-15ov1wm")},m(o,s){_(o,e,s),A(t,e,null),r=!0},p:B,i(o){r||(v(t.$$.fragment,o),r=!0)},o(o){k(t.$$.fragment,o),r=!1},d(o){o&&w(e),F(t)}}}var qm=class extends z{constructor(e){super(),W(this,e,null,hA,j,{},mA)}},qc=qm;function gA(n){we(n,"svelte-1ezpbya",'.system3-disk-usage-container.svelte-1ezpbya{width:100%;background-color:var(--interactive-normal);overflow:hidden}.system3-disk-usage-bar.svelte-1ezpbya{height:0.5rem;background-color:var(--color-accent);transition:width 0.6s ease}.system3-disk-usage-report.svelte-1ezpbya{text-align:center}.system3-disk-usage-bar[data-state="warning"].svelte-1ezpbya{height:0.3rem;background-color:var(--red);transition:width 0.6s ease}')}function yA(n){let e,t,r,o,s,i;return{c(){e=x("div"),t=x("div"),o=T(),s=x("div"),i=V(n[1]),h(t,"class","system3-disk-usage-bar svelte-1ezpbya"),se(t,"width",n[0]+"%"),h(t,"data-state",r=n[0]>90?"warning":""),h(e,"class","system3-disk-usage-container svelte-1ezpbya"),h(s,"class","system3-disk-usage-report svelte-1ezpbya")},m(a,l){_(a,e,l),b(e,t),_(a,o,l),_(a,s,l),b(s,i)},p(a,[l]){l&1&&se(t,"width",a[0]+"%"),l&1&&r!==(r=a[0]>90?"warning":"")&&h(t,"data-state",r),l&2&&J(i,a[1])},i:B,o:B,d(a){a&&(w(e),w(o),w(s))}}}function bA(n,e,t){let{diskUsagePercentage:r=0}=e,{text:o=""}=e;return r=Math.max(0,r),r=Math.min(100,r),n.$$set=s=>{"diskUsagePercentage"in s&&t(0,r=s.diskUsagePercentage),"text"in s&&t(1,o=s.text)},[r,o]}var jm=class extends z{constructor(e){super(),W(this,e,bA,yA,j,{diskUsagePercentage:0,text:1},gA)}},Px=jm;var qx=require("obsidian");var nZ=require("obsidian");var Dx=require("obsidian");function vA(n){we(n,"svelte-pb1sr8",".suggestion-create-prefix.svelte-pb1sr8{color:var(--text-muted);font-style:italic}.suggestion-action.svelte-pb1sr8{color:var(--text-muted);font-size:var(--font-smaller)}.suggestion-icon.svelte-pb1sr8{display:flex;align-items:center}.system3-svg-icon{color:var(--text-muted);opacity:0.6}")}function xA(n){let e=n[10].path+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&1024&&e!==(e=r[10].path+"")&&J(t,e)},d(r){r&&w(t)}}}function wA(n){let e,t=n[10].path+"",r;return{c(){e=x("span"),e.textContent="Create: ",r=V(t),h(e,"class","suggestion-create-prefix svelte-pb1sr8")},m(o,s){_(o,e,s),_(o,r,s)},p(o,s){s&1024&&t!==(t=o[10].path+"")&&J(r,t)},d(o){o&&(w(e),w(r))}}}function _A(n){let e;function t(s,i){return s[10].isCreate?wA:xA}let r=t(n,-1),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function SA(n){let e;return{c(){e=x("div"),h(e,"class","suggestion-icon svelte-pb1sr8")},m(t,r){_(t,e,r)},i:B,o:B,d(t){t&&w(e)}}}function kA(n){let e,t,r;return t=new lo({props:{class:"system3-svg-icon",size:16}}),{c(){e=x("div"),P(t.$$.fragment),h(e,"class","suggestion-icon svelte-pb1sr8")},m(o,s){_(o,e,s),A(t,e,null),r=!0},i(o){r||(v(t.$$.fragment,o),r=!0)},o(o){k(t.$$.fragment,o),r=!1},d(o){o&&w(e),F(t)}}}function IA(n){let e;return{c(){e=x("span"),e.textContent="Enter to create",h(e,"class","suggestion-action svelte-pb1sr8")},m(t,r){_(t,e,r)},i:B,o:B,d(t){t&&w(e)}}}function CA(n){let e,t,r,o,s=[IA,kA,SA],i=[];function a(l,c){return l[10].isCreate?0:l[10].isShared&&!l[10].hasRelay?1:2}return e=a(n,-1),t=i[e]=s[e](n),{c(){t.c(),r=ue()},m(l,c){i[e].m(l,c),_(l,r,c),o=!0},p(l,c){let u=e;e=a(l,c),e!==u&&(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),t=i[e],t||(t=i[e]=s[e](l),t.c()),v(t,1),t.m(r.parentNode,r))},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),i[e].d(l)}}}function LA(n){let e,t;return e=new Vc({props:{placeholder:n[0],autofocus:n[1],onSelect:n[3],getSuggestions:n[2],instructions:[{command:"\u2191/\u2193",purpose:"Navigate"},{command:"Enter",purpose:"Choose and share folder"},{command:"Esc",purpose:"Cancel"}],$$slots:{"suggestion-aux":[CA,({item:r})=>({10:r}),({item:r})=>r?1024:0],suggestion:[_A,({item:r})=>({10:r}),({item:r})=>r?1024:0]},$$scope:{ctx:n}}}),e.$on("customInput",n[9]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,[o]){let s={};o&1&&(s.placeholder=r[0]),o&2&&(s.autofocus=r[1]),o&3072&&(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 MA(n,e,t){let{app:r}=e,{placeholder:o="Choose or create folder..."}=e,{blockedPaths:s=new Set}=e,{sharedFolders:i}=e,{autofocus:a=!1}=e,{onSelect:l=()=>{}}=e;function c(p){let m=new Map;i&&i.forEach(M=>{m.set(M.path,!!M.relayId)});let y=p.toLowerCase(),g=[],I=new Set,L=M=>{if(!(s.has(M.path)&&M.path!=="/")){if((!y||M.path.toLowerCase().includes(y))&&!s.has(M.path)){let E=m.has(M.path),U=m.get(M.path)||!1;g.push({path:M.path,isCreate:!1,isShared:E,hasRelay:U}),I.add(M.path.toLowerCase())}for(let E of M.children)E instanceof Dx.TFolder&&L(E)}},C=r.vault.getRoot();L(C);let S=p.trim();return S&&!I.has(S.toLowerCase())&&g.unshift({path:S,isCreate:!0,isShared:!1,hasRelay:!1}),g.sort((M,E)=>M.isCreate&&!E.isCreate?-1:!M.isCreate&&E.isCreate?1:M.isShared&&!M.hasRelay&&(!E.isShared||E.hasRelay)?-1:E.isShared&&!E.hasRelay&&(!M.isShared||M.hasRelay)?1:M.path.localeCompare(E.path)),g.slice(0,100)}function u(p){l(p.path)}function f(p){l(p)}let d=p=>f(p.detail.value);return n.$$set=p=>{"app"in p&&t(5,r=p.app),"placeholder"in p&&t(0,o=p.placeholder),"blockedPaths"in p&&t(6,s=p.blockedPaths),"sharedFolders"in p&&t(7,i=p.sharedFolders),"autofocus"in p&&t(1,a=p.autofocus),"onSelect"in p&&t(8,l=p.onSelect)},[o,a,c,u,f,r,s,i,l,d]}var zm=class extends z{constructor(e){super(),W(this,e,MA,LA,j,{app:5,placeholder:0,blockedPaths:6,sharedFolders:7,autofocus:1,onSelect:8},vA)}},Rx=zm;var ii=class extends si{constructor(e,t="Choose or create folder...",r=new Set,o,s){super(e,Rx,{app:e,placeholder:t,blockedPaths:r,sharedFolders:o},s)}};var zc=ge({});function TA(n,e,t,r="error",o,s="client"){zc.update(i=>({...i,[n]:{message:e,details:t,type:r,visible:!0,autoDismiss:o!=null?o:5e3,source:s}}))}function Ux(n){zc.update(e=>({...e,[n]:{...e[n],visible:!1}}))}function jc(n,e,t,r="error",o){TA(n,e,t,r,o,"server")}function tr(n,e="An error occurred"){var r,o,s;let t=`server-error-${Date.now()}`;if(n.status===403){let i=((r=n.body)==null?void 0:r.message)||n.message||"Permission denied",a=(o=n.body)==null?void 0:o.details;jc(t,i,a,"error",7e3)}else if(n.status>=400&&n.status<500){let i=((s=n.body)==null?void 0:s.message)||n.message||e;jc(t,i,void 0,"error",5e3)}else n.status>=500?jc(t,"Server error occurred",n.message,"error",8e3):jc(t,e,n.message,"error",5e3)}function AA(n){we(n,"svelte-y144a4",".share-folder-modal.svelte-y144a4.svelte-y144a4{min-width:500px;max-width:600px}@media(max-width: 768px){.share-folder-modal.svelte-y144a4.svelte-y144a4{min-width:100vw;max-width:100vw;margin:0;border-radius:0;height:100vh;max-height:100vh}}.section.svelte-y144a4.svelte-y144a4{margin-bottom:24px}.search-container.svelte-y144a4.svelte-y144a4{margin-bottom:12px}.search-input.svelte-y144a4.svelte-y144a4{width:100%;padding:8px 12px;border:1px solid var(--background-modifier-border);border-radius:4px;background:var(--background-primary);color:var(--text-normal)}.user-list.svelte-y144a4.svelte-y144a4{max-height:300px;overflow-y:auto;border:1px solid var(--background-modifier-border);border-radius:4px;background:var(--background-primary)}.user-item.svelte-y144a4.svelte-y144a4{display:flex;align-items:center;padding:12px;border-bottom:1px solid var(--background-modifier-border);gap:12px}.user-item.svelte-y144a4.svelte-y144a4:last-child{border-bottom:none}.user-item.svelte-y144a4.svelte-y144a4:hover:not(.is-current-user){background:var(--background-modifier-hover)}.user-item.is-current-user.svelte-y144a4.svelte-y144a4{opacity:0.6;cursor:not-allowed}.user-checkbox.svelte-y144a4.svelte-y144a4{margin:0;cursor:pointer}.user-avatar.svelte-y144a4.svelte-y144a4{width:32px;height:32px;border-radius:50%;background:var(--interactive-accent);display:flex;align-items:center;justify-content:center;color:white;font-size:12px;font-weight:500;flex-shrink:0}.user-avatar.svelte-y144a4 img.svelte-y144a4{width:100%;height:100%;border-radius:50%;object-fit:cover}.user-info.svelte-y144a4.svelte-y144a4{flex:1;min-width:0}.user-name.svelte-y144a4.svelte-y144a4{font-weight:500;margin-bottom:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-status.svelte-y144a4.svelte-y144a4{font-size:0.8em;color:var(--text-muted);font-style:italic;margin-left:auto}.no-users.svelte-y144a4.svelte-y144a4{text-align:center;padding:40px;color:var(--text-muted)}.modal-button-container.svelte-y144a4.svelte-y144a4{display:flex;justify-content:flex-end;align-items:center;margin-top:24px;gap:12px}.modal-button-container.users-step.svelte-y144a4.svelte-y144a4{justify-content:space-between}button.svelte-y144a4.svelte-y144a4:disabled{opacity:0.5;cursor:not-allowed}.checkbox-container.svelte-y144a4.svelte-y144a4{cursor:pointer}")}function Ox(n,e,t){let r=n.slice();return r[38]=e[t],r}function FA(n){let e,t,r,o,s,i,a,l,c,u,f,d,p,m,y,g,I,L,C,S,M,E,U,K;s=new Qe({props:{name:"Selected Folder"}}),a=new pa({props:{selectedItem:n[4],showTransformation:!0,isPrivate:n[2],readonly:!0}}),u=new Qe({props:{name:"Users"}});function R(H,G){return H[7].length===0?DA:PA}let O=R(n,[-1,-1]),q=O(n);return{c(){e=x("div"),e.textContent="Add Users to Folder",t=T(),r=x("div"),o=x("div"),P(s.$$.fragment),i=T(),P(a.$$.fragment),l=T(),c=x("div"),P(u.$$.fragment),f=T(),d=x("div"),p=x("input"),m=T(),y=x("div"),q.c(),g=T(),I=x("div"),L=x("button"),L.textContent="Back",C=T(),S=x("button"),S.textContent="Share",h(e,"class","modal-title"),h(o,"class","section svelte-y144a4"),h(p,"type","text"),h(p,"placeholder","Search users by name..."),h(p,"class","search-input svelte-y144a4"),h(d,"class","search-container svelte-y144a4"),h(y,"class","user-list svelte-y144a4"),h(c,"class","section svelte-y144a4"),h(L,"class","mod-muted svelte-y144a4"),h(S,"class","mod-cta svelte-y144a4"),S.disabled=M=!1,h(I,"class","modal-button-container users-step svelte-y144a4"),h(r,"class","modal-content share-folder-modal svelte-y144a4")},m(H,G){_(H,e,G),_(H,t,G),_(H,r,G),b(r,o),A(s,o,null),b(o,i),A(a,o,null),b(r,l),b(r,c),A(u,c,null),b(c,f),b(c,d),b(d,p),Ye(p,n[6]),b(c,m),b(c,y),q.m(y,null),b(r,g),b(r,I),b(I,L),b(I,C),b(I,S),n[28](r),E=!0,U||(K=[$(p,"input",n[25]),$(L,"click",n[15]),$(S,"click",n[14])],U=!0)},p(H,G){let ce={};G[0]&16&&(ce.selectedItem=H[4]),G[0]&4&&(ce.isPrivate=H[2]),a.$set(ce),G[0]&64&&p.value!==H[6]&&Ye(p,H[6]),O===(O=R(H,G))&&q?q.p(H,G):(q.d(1),q=O(H),q&&(q.c(),q.m(y,null)))},i(H){E||(v(s.$$.fragment,H),v(a.$$.fragment,H),v(u.$$.fragment,H),E=!0)},o(H){k(s.$$.fragment,H),k(a.$$.fragment,H),k(u.$$.fragment,H),E=!1},d(H){H&&(w(e),w(t),w(r)),F(s),F(a),F(u),q.d(),n[28](null),U=!1,me(K)}}}function EA(n){let e,t,r,o,s,i,a,l,c,u,f,d=n[2]?"Add Users":"Share",p,m,y,g,I;s=new Qe({props:{name:"Folder"}}),a=new pa({props:{selectedItem:n[4],showTransformation:!0,isPrivate:n[2],selectButtonText:"Choose or create folder..."}}),a.$on("clear",n[11]),a.$on("select",n[16]);let L=n[0].version>0&&Bx(n);return{c(){e=x("div"),e.textContent="Share local folder",t=T(),r=x("div"),o=x("div"),P(s.$$.fragment),i=T(),P(a.$$.fragment),l=T(),L&&L.c(),c=T(),u=x("div"),f=x("button"),p=V(d),h(e,"class","modal-title"),h(o,"class","section svelte-y144a4"),h(f,"class","mod-cta svelte-y144a4"),f.disabled=m=!n[4]&&!n[3].trim(),h(u,"class","modal-button-container svelte-y144a4"),h(r,"class","modal-content share-folder-modal svelte-y144a4")},m(C,S){_(C,e,S),_(C,t,S),_(C,r,S),b(r,o),A(s,o,null),b(o,i),A(a,o,null),b(r,l),L&&L.m(r,null),b(r,c),b(r,u),b(u,f),b(f,p),n[24](r),y=!0,g||(I=$(f,"click",n[12]),g=!0)},p(C,S){let M={};S[0]&16&&(M.selectedItem=C[4]),S[0]&4&&(M.isPrivate=C[2]),a.$set(M),C[0].version>0?L?(L.p(C,S),S[0]&1&&v(L,1)):(L=Bx(C),L.c(),v(L,1),L.m(r,c)):L&&(ee(),k(L,1,1,()=>{L=null}),te()),(!y||S[0]&4)&&d!==(d=C[2]?"Add Users":"Share")&&J(p,d),(!y||S[0]&24&&m!==(m=!C[4]&&!C[3].trim()))&&(f.disabled=m)},i(C){y||(v(s.$$.fragment,C),v(a.$$.fragment,C),v(L),y=!0)},o(C){k(s.$$.fragment,C),k(a.$$.fragment,C),k(L),y=!1},d(C){C&&(w(e),w(t),w(r)),F(s),F(a),L&&L.d(),n[24](null),g=!1,I()}}}function PA(n){let e,t=he(n[7]),r=[];for(let o=0;o<t.length;o+=1)r[o]=Nx(Ox(n,t,o));return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=ue()},m(o,s){for(let i=0;i<r.length;i+=1)r[i]&&r[i].m(o,s);_(o,e,s)},p(o,s){if(s[0]&8320){t=he(o[7]);let i;for(i=0;i<t.length;i+=1){let a=Ox(o,t,i);r[i]?r[i].p(a,s):(r[i]=Nx(a),r[i].c(),r[i].m(e.parentNode,e))}for(;i<r.length;i+=1)r[i].d(1);r.length=t.length}},d(o){o&&w(e),ze(r,o)}}}function DA(n){let e,t=n[6]?"No users found":"No users available",r;return{c(){e=x("div"),r=V(t),h(e,"class","no-users svelte-y144a4")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s[0]&64&&t!==(t=o[6]?"No users found":"No users available")&&J(r,t)},d(o){o&&w(e)}}}function RA(n){let e=Vx(n[38].user.name)+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&128&&e!==(e=Vx(r[38].user.name)+"")&&J(t,e)},d(r){r&&w(t)}}}function UA(n){let e,t,r;return{c(){e=x("img"),hr(e.src,t=n[38].user.picture)||h(e,"src",t),h(e,"alt",r=n[38].user.name),h(e,"class","svelte-y144a4")},m(o,s){_(o,e,s)},p(o,s){s[0]&128&&!hr(e.src,t=o[38].user.picture)&&h(e,"src",t),s[0]&128&&r!==(r=o[38].user.name)&&h(e,"alt",r)},d(o){o&&w(e)}}}function $x(n){let e;return{c(){e=x("div"),e.textContent="Required (You)",h(e,"class","user-status svelte-y144a4")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function Nx(n){let e,t,r,o,s,i,a,l,c,u=n[38].user.name+"",f,d,p,m,y;function g(E,U){return E[38].user.picture?UA:RA}let I=g(n,[-1,-1]),L=I(n),C=n[38].isCurrentUser&&$x(n);function S(){return n[26](n[38])}function M(...E){return n[27](n[38],...E)}return{c(){e=x("div"),t=x("input"),s=T(),i=x("div"),L.c(),a=T(),l=x("div"),c=x("div"),f=V(u),d=T(),C&&C.c(),p=T(),h(t,"type","checkbox"),t.checked=r=n[38].selected,t.disabled=o=n[38].isCurrentUser,h(t,"class","user-checkbox svelte-y144a4"),h(t,"tabindex","-1"),h(i,"class","user-avatar svelte-y144a4"),h(c,"class","user-name svelte-y144a4"),h(l,"class","user-info svelte-y144a4"),h(e,"class","user-item svelte-y144a4"),h(e,"role","button"),h(e,"tabindex","0"),_e(e,"is-current-user",n[38].isCurrentUser)},m(E,U){_(E,e,U),b(e,t),b(e,s),b(e,i),L.m(i,null),b(e,a),b(e,l),b(l,c),b(c,f),b(e,d),C&&C.m(e,null),b(e,p),m||(y=[$(e,"click",S),$(e,"keydown",M)],m=!0)},p(E,U){n=E,U[0]&128&&r!==(r=n[38].selected)&&(t.checked=r),U[0]&128&&o!==(o=n[38].isCurrentUser)&&(t.disabled=o),I===(I=g(n,U))&&L?L.p(n,U):(L.d(1),L=I(n),L&&(L.c(),L.m(i,null))),U[0]&128&&u!==(u=n[38].user.name+"")&&J(f,u),n[38].isCurrentUser?C||(C=$x(n),C.c(),C.m(e,p)):C&&(C.d(1),C=null),U[0]&128&&_e(e,"is-current-user",n[38].isCurrentUser)},d(E){E&&w(e),L.d(),C&&C.d(),m=!1,me(y)}}}function Bx(n){let e,t;return e=new Re({props:{name:"Private",description:"Only selected users can access this folder",$$slots:{default:[OA]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&4|o[1]&1024&&(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 OA(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"),h(t,"tabindex","-1"),h(o,"class","checkbox-toggle"),h(e,"role","checkbox"),h(e,"aria-checked",n[2]),h(e,"tabindex","0"),h(e,"class","checkbox-container svelte-y144a4"),_e(e,"is-enabled",n[2])},m(a,l){_(a,e,l),b(e,t),t.checked=n[2],b(e,r),b(e,o),s||(i=[$(t,"change",n[21]),$(e,"keypress",n[22]),$(e,"click",n[23])],s=!0)},p(a,l){l[0]&4&&(t.checked=a[2]),l[0]&4&&h(e,"aria-checked",a[2]),l[0]&4&&_e(e,"is-enabled",a[2])},d(a){a&&w(e),s=!1,me(i)}}}function $A(n){let e,t,r,o,s=[EA,FA],i=[];function a(l,c){return l[1]==="main"?0:l[1]==="users"?1:-1}return~(e=a(n,[-1,-1]))&&(t=i[e]=s[e](n)),{c(){t&&t.c(),r=ue()},m(l,c){~e&&i[e].m(l,c),_(l,r,c),o=!0},p(l,c){let u=e;e=a(l,c),e===u?~e&&i[e].p(l,c):(t&&(ee(),k(i[u],1,1,()=>{i[u]=null}),te()),~e?(t=i[e],t?t.p(l,c):(t=i[e]=s[e](l),t.c()),v(t,1),t.m(r.parentNode,r)):t=null)},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),~e&&i[e].d(l)}}}function Vx(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().substring(0,2)}function NA(n,e,t){let r,o,s;var i;let{app:a}=e,{relay:l}=e,{relayManager:c}=e,{sharedFolders:u}=e,{onConfirm:f}=e,d="main",p=!1,m="",y="",g=ge(new Set(!((i=c.user)===null||i===void 0)&&i.id?[c.user.id]:[]));ne(n,g,Z=>t(30,r=Z));let I=ge("");ne(n,I,Z=>t(6,o=Z));let L,C=()=>new Set(u.filter(Z=>!!Z.relayId).map(Z=>Z.path)).add("/"),S=et([c.relayRoles],([Z])=>Array.from(Z.values()).filter(Se=>Se.relayId===l.id).map(Se=>Se.user)),M=et([S,g],([Z,Se])=>{var ae;let Pe=(ae=c.user)===null||ae===void 0?void 0:ae.id;return Z.map(De=>{let Ge=Pe===De.id,mt=Se.has(De.id)||Ge;return{user:De,selected:mt,isCurrentUser:Ge}})}),E=et([M,I],([Z,Se])=>{if(!Se||Se.trim()==="")return Z;let ae=Se.toLowerCase().trim();return Z.filter(Pe=>Pe.user.name.toLowerCase().includes(ae))}),U=et([E],([Z])=>Z.sort((Se,ae)=>Se.user.name.localeCompare(ae.user.name)));ne(n,U,Z=>t(7,s=Z));function K(){t(4,y=""),t(3,m="")}function R(){!y&&m.trim()&&t(4,y=m.trim()),p?t(1,d="users"):q()}function O(Z){Z.isCurrentUser||g.update(Se=>{let ae=new Set(Se);return ae.has(Z.user.id)?ae.delete(Z.user.id):ae.add(Z.user.id),ae})}function q(){return Ce(this,void 0,void 0,function*(){var Z;!y&&m.trim()&&t(4,y=m.trim());try{let Se=(Z=c.user)===null||Z===void 0?void 0:Z.id,Pe=Array.from(r).filter(De=>De!==Se);yield f(y,y.split("/").pop()||"",p,Pe)}catch(Se){tr(Se,"Failed to share folder.")}})}function H(){t(1,d="main")}function G(Z){t(4,y=Z),t(3,m=Z)}function ce(){new ii(a,"Choose or create folder...",C(),u,G).open()}let N=Z=>{Z.key==="Tab"&&X(Z)};st(()=>(document.addEventListener("keydown",N),y||setTimeout(()=>{ce()},100),()=>{document.removeEventListener("keydown",N)}));function X(Z){if(!L)return;let Se=L.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),ae=Se[0],Pe=Se[Se.length-1];Z.shiftKey?document.activeElement===ae&&(Z.preventDefault(),Pe.focus()):document.activeElement===Pe&&(Z.preventDefault(),ae.focus())}function Me(){p=this.checked,t(2,p)}let Ie=()=>t(2,p=!p),D=()=>t(2,p=!p);function Q(Z){pt[Z?"unshift":"push"](()=>{L=Z,t(5,L)})}function de(){o=this.value,I.set(o)}let Le=Z=>O(Z),Ae=(Z,Se)=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),O(Z))};function re(Z){pt[Z?"unshift":"push"](()=>{L=Z,t(5,L)})}return n.$$set=Z=>{"app"in Z&&t(17,a=Z.app),"relay"in Z&&t(0,l=Z.relay),"relayManager"in Z&&t(18,c=Z.relayManager),"sharedFolders"in Z&&t(19,u=Z.sharedFolders),"onConfirm"in Z&&t(20,f=Z.onConfirm)},[l,d,p,m,y,L,o,s,g,I,U,K,R,O,q,H,ce,a,c,u,f,Me,Ie,D,Q,de,Le,Ae,re]}var Wm=class extends z{constructor(e){super(),W(this,e,NA,$A,j,{app:17,relay:0,relayManager:18,sharedFolders:19,onConfirm:20},AA,[-1,-1])}},Hx=Wm;var Wc=class extends qx.Modal{constructor(t,r,o,s,i){super(t);this.relay=r;this.sharedFolders=o;this.relayManager=s;this.onConfirm=i}onOpen(){let{contentEl:t}=this;this.component=new Hx({target:t,props:{app:this.app,relay:this.relay,relayManager:this.relayManager,sharedFolders:this.sharedFolders,onConfirm:async(r,o,s,i)=>{let a=await this.onConfirm(r,o,s,i);return this.close(),a}}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}destroy(){this.relay=null,this.sharedFolders=null,this.relayManager=null,this.onConfirm=null}};function BA(n){we(n,"svelte-1r0liue",`.el-pre.svelte-1r0liue.svelte-1r0liue{position:relative;margin:1em 0}pre.language-toml.svelte-1r0liue.svelte-1r0liue{position:relative;background:var(--code-background);border-radius:var(--radius-s);padding:1em;overflow-x:auto;font-family:var(--font-monospace);font-size:var(--code-size);line-height:var(--line-height-normal);tab-size:4;border:1px solid var(--background-modifier-border)}code.language-toml.svelte-1r0liue.svelte-1r0liue{display:block;color:var(--code-normal);white-space:pre-wrap;word-wrap:break-word;word-break:break-all;font-family:inherit;user-select:text;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text}.copy-code-button.svelte-1r0liue.svelte-1r0liue{position:absolute;top:0.5em;right:0.5em;padding:0.25em;background:transparent;border:none;color:var(--text-muted);cursor:pointer;opacity:0;transition:opacity 0.2s ease,
|
|
color 0.2s ease;display:flex;align-items:center;justify-content:center;box-shadow:none !important}.el-pre.svelte-1r0liue:hover .copy-code-button.svelte-1r0liue{opacity:0.7;box-shadow:none}.copy-code-button.svelte-1r0liue.svelte-1r0liue:hover{opacity:1 !important;color:var(--text-normal);background:transparent;border:none;box-shadow:none !important}.copy-code-button.svelte-1r0liue.svelte-1r0liue:focus{outline:none;border:none;opacity:1;color:var(--interactive-accent);background:transparent;box-shadow:none !important}.svg-icon.svelte-1r0liue.svelte-1r0liue{width:16px;height:16px}.error-message.svelte-1r0liue.svelte-1r0liue{background:var(--background-secondary);color:var(--text-error);border:1px solid var(--text-error);border-radius:var(--radius-s);padding:12px;margin:16px 0;font-size:0.9em}`)}function VA(n){let e;return{c(){e=x("div"),e.textContent="No configuration available",h(e,"class","error-message svelte-1r0liue")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function HA(n){let e,t,r,o,s,i,a,l,c;function u(p,m){return p[1]?jA:qA}let f=u(n,-1),d=f(n);return{c(){e=x("div"),t=x("pre"),r=x("code"),o=x("button"),s=V(`
|
|
`),d.c(),i=V(`
|
|
`),h(r,"class","language-toml is-loaded svelte-1r0liue"),h(o,"class","copy-code-button svelte-1r0liue"),h(o,"aria-label",a=n[1]?"Copied to clipboard":"Copy"),h(t,"class","language-toml svelte-1r0liue"),h(e,"class","el-pre svelte-1r0liue")},m(p,m){_(p,e,m),b(e,t),b(t,r),r.innerHTML=n[2],b(t,o),b(o,s),d.m(o,null),b(o,i),l||(c=[$(o,"click",n[3]),$(o,"keydown",n[4])],l=!0)},p(p,m){m&4&&(r.innerHTML=p[2]),f!==(f=u(p,m))&&(d.d(1),d=f(p),d&&(d.c(),d.m(o,i))),m&2&&a!==(a=p[1]?"Copied to clipboard":"Copy")&&h(o,"aria-label",a)},d(p){p&&w(e),d.d(),l=!1,me(c)}}}function qA(n){let e,t,r;return{c(){e=Qt("svg"),t=Qt("rect"),r=Qt("path"),h(t,"x","8"),h(t,"y","8"),h(t,"width","14"),h(t,"height","14"),h(t,"rx","2"),h(t,"ry","2"),h(r,"d","M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),h(e,"xmlns","http://www.w3.org/2000/svg"),h(e,"width","24"),h(e,"height","24"),h(e,"viewBox","0 0 24 24"),h(e,"fill","none"),h(e,"stroke","currentColor"),h(e,"stroke-width","2"),h(e,"stroke-linecap","round"),h(e,"stroke-linejoin","round"),h(e,"class","svg-icon lucide-copy svelte-1r0liue")},m(o,s){_(o,e,s),b(e,t),b(e,r)},d(o){o&&w(e)}}}function jA(n){let e,t;return{c(){e=Qt("svg"),t=Qt("polyline"),h(t,"points","20,6 9,17 4,12"),h(e,"xmlns","http://www.w3.org/2000/svg"),h(e,"width","24"),h(e,"height","24"),h(e,"viewBox","0 0 24 24"),h(e,"fill","none"),h(e,"stroke","currentColor"),h(e,"stroke-width","2"),h(e,"stroke-linecap","round"),h(e,"stroke-linejoin","round"),h(e,"class","svg-icon lucide-check svelte-1r0liue")},m(r,o){_(r,e,o),b(e,t)},d(r){r&&w(e)}}}function zA(n){let e;function t(s,i){return s[0]?HA:VA}let r=t(n,-1),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,[i]){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},i:B,o:B,d(s){s&&w(e),o.d(s)}}}function WA(n){let e=[],t=n.split(`
|
|
`);for(let r of t){let o=r.trim();if(o==="")e.push({type:"newline",value:r});else if(o.startsWith("#"))e.push({type:"comment",value:r});else if(o.startsWith("[[")&&o.endsWith("]]")){let s=r.match(/^(\s*)\[\[([^\]]+)\]\](\s*)$/);if(s){let[,i,a,l]=s;e.push({type:"array-table",value:r,parts:{leading:i,tableName:a,trailing:l}})}else e.push({type:"text",value:r})}else if(o.startsWith("[")&&o.endsWith("]")){let s=r.match(/^(\s*)\[([^\]]+)\](\s*)$/);if(s){let[,i,a,l]=s;e.push({type:"table",value:r,parts:{leading:i,tableName:a,trailing:l}})}else e.push({type:"text",value:r})}else if(o.includes("=")){let s=r.match(/^(\s*)([^=]+?)\s*=\s*(.+)(\s*)$/);if(s){let[,i,a,l,c]=s;e.push({type:"key-value",value:r,parts:{leading:i,key:a.trim(),value:l.trim(),trailing:c}})}else e.push({type:"text",value:r})}else e.push({type:"text",value:r})}return e}function KA(n){return n.map(e=>{switch(e.type){case"comment":return`<span class="token comment">${e.value}</span>`;case"newline":return e.value;case"table":let{leading:t,tableName:r,trailing:o}=e.parts;return`${t}<span class="token punctuation">[</span><span class="token table class-name">${r}</span><span class="token punctuation">]</span>${o}`;case"array-table":let{leading:s,tableName:i,trailing:a}=e.parts;return`${s}<span class="token punctuation">[[</span><span class="token table class-name">${i}</span><span class="token punctuation">]]</span>${a}`;case"key-value":let{leading:l,key:c,value:u,trailing:f}=e.parts,d=u;return u.startsWith('"')&&u.endsWith('"')?d=`<span class="token string">${u}</span>`:/^\d+$/.test(u)?d=`<span class="token number">${u}</span>`:d=`<span class="token string">${u}</span>`,`${l}<span class="token key property">${c}</span> <span class="token punctuation">=</span> ${d}${f}`;default:return e.value}}).join(`
|
|
`)}function GA(n,e,t){let r,{toml:o=""}=e,s=!1;function i(){return Ce(this,void 0,void 0,function*(){try{yield navigator.clipboard.writeText(o),t(1,s=!0),setTimeout(()=>{t(1,s=!1)},2e3)}catch(l){console.error("Failed to copy text: ",l)}})}function a(l){l.key==="Enter"&&(l.preventDefault(),i())}return n.$$set=l=>{"toml"in l&&t(0,o=l.toml)},n.$$.update=()=>{n.$$.dirty&1&&t(2,r=o?KA(WA(o)):"")},[o,s,r,i,a]}var Km=class extends z{constructor(e){super(),W(this,e,GA,zA,j,{toml:0},BA)}},Kc=Km;var Gm=require("obsidian");function JA(n){we(n,"svelte-3znnov",`div.spacer.svelte-3znnov{height:3em}.faint.svelte-3znnov{color:var(--text-faint) !important}.edit-members-button.svelte-3znnov{display:flex;cursor:pointer;padding:4px;margin-bottom:-4px;border-radius:var(--radius-s);color:var(--icon-color);transition:color 0.15s ease-in-out,
|
|
background-color 0.15s ease-in-out}.edit-members-button.svelte-3znnov:hover{color:var(--icon-color-hover);background-color:var(--background-modifier-hover)}.edit-members-button.svelte-3znnov:focus{outline:none;color:var(--icon-color-focus)}.share-key-container.svelte-3znnov{width:100%}.share-key-disabled-notice.svelte-3znnov{color:var(--text-error) !important;font-size:0.85em !important}.relay-host-check.svelte-3znnov{text-align:right}input.system3-updating.svelte-3znnov{border:1px solid var(--color-accent) !important}input.system3-input-invalid.svelte-3znnov{border:1px solid var(--color-red) !important}.admin-toggle-btn.svelte-3znnov{background:none;border:none;box-shadow:none;color:var(--text-muted);font-size:0.9em;cursor:pointer;padding:0;margin-left:8px}.admin-toggle-btn.svelte-3znnov:hover{color:var(--text-normal);text-decoration:underline}.relay-auth-section.svelte-3znnov{margin:16px 0}.loading-message.svelte-3znnov{background:var(--background-secondary);color:var(--text-muted);border:1px solid var(--background-modifier-border);border-radius:var(--radius-s);padding:12px;margin:16px 0;font-size:0.9em;text-align:center}.error-message.svelte-3znnov{background:var(--background-secondary);color:var(--text-error);border:1px solid var(--text-error);border-radius:var(--radius-s);padding:12px;margin:16px 0;font-size:0.9em}.hint-callout-wrapper.svelte-3znnov{position:relative;margin-bottom:16px}.hint-callout-wrapper.svelte-3znnov .hint-icon{display:inline;vertical-align:middle;width:16px;height:16px}.hint-dismiss.svelte-3znnov{position:absolute;top:8px;right:8px;background:none;border:none;box-shadow:none;padding:4px;cursor:pointer;color:var(--text-muted);border-radius:var(--radius-s)}.hint-dismiss.svelte-3znnov:hover{color:var(--text-normal);background-color:var(--background-modifier-hover)}`)}function jx(n,e,t){let r=n.slice();return r[94]=e[t],r}function zx(n,e,t){let r=n.slice();return r[97]=e[t],r}function Wx(n,e,t){let r=n.slice();return r[100]=e[t],r}function Kx(n){let e,t,r,o,s,i,a=[QA,YA],l=[];function c(u,f){return f[0]&409600&&(e=null),f[0]&147456&&(t=null),e==null&&(e=u[17].values().length>0&&!u[18]&&!u[14].owner),e?0:(t==null&&(t=!!(u[17].values().length===0&&u[14].owner)),t?1:-1)}return~(r=c(n,[-1,-1,-1,-1]))&&(o=l[r]=a[r](n)),{c(){o&&o.c(),s=ue()},m(u,f){~r&&l[r].m(u,f),_(u,s,f),i=!0},p(u,f){let d=r;r=c(u,f),r===d?~r&&l[r].p(u,f):(o&&(ee(),k(l[d],1,1,()=>{l[d]=null}),te()),~r?(o=l[r],o?o.p(u,f):(o=l[r]=a[r](u),o.c()),v(o,1),o.m(s.parentNode,s)):o=null)},i(u){i||(v(o),i=!0)},o(u){k(o),i=!1},d(u){u&&w(s),~r&&l[r].d(u)}}}function YA(n){let e,t,r,o,s,i,a,l;return t=new xm({props:{title:"Hint",$$slots:{default:[ZA]},$$scope:{ctx:n}}}),s=new Xs({props:{class:"svg-icon"}}),{c(){e=x("div"),P(t.$$.fragment),r=T(),o=x("button"),P(s.$$.fragment),h(o,"class","hint-dismiss svelte-3znnov"),h(o,"aria-label","Dismiss hint"),h(e,"class","hint-callout-wrapper svelte-3znnov")},m(c,u){_(c,e,u),A(t,e,null),b(e,r),b(e,o),A(s,o,null),i=!0,a||(l=$(o,"click",n[73]),a=!0)},p(c,u){let f={};u[3]&1024&&(f.$$scope={dirty:u,ctx:c}),t.$set(f)},i(c){i||(v(t.$$.fragment,c),v(s.$$.fragment,c),i=!0)},o(c){k(t.$$.fragment,c),k(s.$$.fragment,c),i=!1},d(c){c&&w(e),F(t),F(s),a=!1,l()}}}function QA(n){let e,t,r,o,s,i,a,l;return t=new xm({props:{title:"Hint",$$slots:{default:[XA]},$$scope:{ctx:n}}}),s=new Xs({props:{class:"svg-icon"}}),{c(){e=x("div"),P(t.$$.fragment),r=T(),o=x("button"),P(s.$$.fragment),h(o,"class","hint-dismiss svelte-3znnov"),h(o,"aria-label","Dismiss hint"),h(e,"class","hint-callout-wrapper svelte-3znnov")},m(c,u){_(c,e,u),A(t,e,null),b(e,r),b(e,o),A(s,o,null),i=!0,a||(l=$(o,"click",n[72]),a=!0)},p(c,u){let f={};u[3]&1024&&(f.$$scope={dirty:u,ctx:c}),t.$set(f)},i(c){i||(v(t.$$.fragment,c),v(s.$$.fragment,c),i=!0)},o(c){k(t.$$.fragment,c),k(s.$$.fragment,c),i=!1},d(c){c&&w(e),F(t),F(s),a=!1,l()}}}function ZA(n){let e;return{c(){e=V("Add a Shared Folder to this Relay.")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function XA(n){let e,t,r,o;return t=new uc({props:{class:"svg-icon hint-icon"}}),{c(){e=V("Click the "),P(t.$$.fragment),r=V(" button below to add a Shared Folder to your vault and start collaborating.")},m(s,i){_(s,e,i),A(t,s,i),_(s,r,i),o=!0},p:B,i(s){o||(v(t.$$.fragment,s),o=!0)},o(s){k(t.$$.fragment,s),o=!1},d(s){s&&(w(e),w(r)),F(t,s)}}}function Gx(n){let e,t;return e=new Re({props:{name:"Name",description:"Set the Relay Server's name.",$$slots:{default:[eF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&1049729|o[3]&1024&&(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 eF(n){let e,t,r,o;return{c(){e=x("input"),h(e,"type","text"),h(e,"spellcheck","false"),h(e,"placeholder","Example: Shared Notes"),h(e,"class",t=Tt((n[20]?"system3-updating":"")+(n[10]?"":" system3-input-invalid"))+" svelte-3znnov")},m(s,i){_(s,e,i),Ye(e,n[0].name),n[75](e),r||(o=[$(e,"input",n[74]),$(e,"input",n[56])],r=!0)},p(s,i){i[0]&1049600&&t!==(t=Tt((s[20]?"system3-updating":"")+(s[10]?"":" system3-input-invalid"))+" svelte-3znnov")&&h(e,"class",t),i[0]&1&&e.value!==s[0].name&&Ye(e,s[0].name)},d(s){s&&w(e),n[75](null),r=!1,me(o)}}}function Jx(n){let e,t=n[23]?"View as member":"View as admin",r,o,s;return{c(){e=x("button"),r=V(t),h(e,"class","admin-toggle-btn svelte-3znnov")},m(i,a){_(i,e,a),b(e,r),o||(s=$(e,"click",n[76]),o=!0)},p(i,a){a[0]&8388608&&t!==(t=i[23]?"View as member":"View as admin")&&J(r,t)},d(i){i&&w(e),o=!1,s()}}}function tF(n){let e,t=n[21]&&n[22]&&Jx(n);return{c(){t&&t.c(),e=ue()},m(r,o){t&&t.m(r,o),_(r,e,o)},p(r,o){r[21]&&r[22]?t?t.p(r,o):(t=Jx(r),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},d(r){r&&w(e),t&&t.d(r)}}}function Yx(n){let e,t;return e=new Gt({props:{$$slots:{name:[sF],default:[oF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&16908290|o[3]&1024&&(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 Qx(n){let e,t;function r(){return n[78](n[100])}return e=new rs({props:{label:"Add to vault",$$slots:{default:[rF]},$$scope:{ctx:n}}}),e.$on("settings",function(){Je((0,At.debounce)(r))&&(0,At.debounce)(r).apply(this,arguments)}),{c(){P(e.$$.fragment)},m(o,s){A(e,o,s),t=!0},p(o,s){n=o;let i={};s[3]&1024&&(i.$$scope={dirty:s,ctx:n}),e.$set(i)},i(o){t||(v(e.$$.fragment,o),t=!0)},o(o){k(e.$$.fragment,o),t=!1},d(o){F(e,o)}}}function rF(n){let e,t;return e=new uc({props:{class:"svg-icon lucide-settings",props:{class:"svg-icon lucide-settings"}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p:B,i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function oF(n){let e=!n[24].some(s)&&ao(n[1].relayManager.userCan(["folder","read_content"],n[100])),t,r,o;function s(...l){return n[70](n[100],...l)}let i=e&&Qx(n);function a(){return n[79](n[100])}return r=new rs({}),r.$on("settings",function(){Je((0,At.debounce)(a))&&(0,At.debounce)(a).apply(this,arguments)}),{c(){i&&i.c(),t=T(),P(r.$$.fragment)},m(l,c){i&&i.m(l,c),_(l,t,c),A(r,l,c),o=!0},p(l,c){n=l,c[0]&16908290&&(e=!n[24].some(s)&&ao(n[1].relayManager.userCan(["folder","read_content"],n[100]))),e?i?(i.p(n,c),c[0]&16908290&&v(i,1)):(i=Qx(n),i.c(),v(i,1),i.m(t.parentNode,t)):i&&(ee(),k(i,1,1,()=>{i=null}),te())},i(l){o||(v(i),v(r.$$.fragment,l),o=!0)},o(l){k(i),k(r.$$.fragment,l),o=!1},d(l){l&&w(t),i&&i.d(l),F(r,l)}}}function nF(n){let e=n[100].name+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&131072&&e!==(e=r[100].name+"")&&J(t,e)},d(r){r&&w(t)}}}function sF(n){let e,t;function r(){return n[77](n[100])}return e=new Nc({props:{remoteFolder:n[100],slot:"name",$$slots:{default:[nF]},$$scope:{ctx:n}}}),e.$on("manageRemoteFolder",r),{c(){P(e.$$.fragment)},m(o,s){A(e,o,s),t=!0},p(o,s){n=o;let i={};s[0]&131072&&(i.remoteFolder=n[100]),s[0]&131072|s[3]&1024&&(i.$$scope={dirty:s,ctx:n}),e.$set(i)},i(o){t||(v(e.$$.fragment,o),t=!0)},o(o){k(e.$$.fragment,o),t=!1},d(o){F(e,o)}}}function Zx(n){let e=n[23]?ao(n[1].relayManager.userCan(["folder","manage_users"],n[100])):ao(n[1].relayManager.userCan(["folder","read_content"],n[100])),t,r,o=e&&Yx(n);return{c(){o&&o.c(),t=ue()},m(s,i){o&&o.m(s,i),_(s,t,i),r=!0},p(s,i){i[0]&8519682&&(e=s[23]?ao(s[1].relayManager.userCan(["folder","manage_users"],s[100])):ao(s[1].relayManager.userCan(["folder","read_content"],s[100]))),e?o?(o.p(s,i),i[0]&8519682&&v(o,1)):(o=Yx(s),o.c(),v(o,1),o.m(t.parentNode,t)):o&&(ee(),k(o,1,1,()=>{o=null}),te())},i(s){r||(v(o),r=!0)},o(s){k(o),r=!1},d(s){s&&w(t),o&&o.d(s)}}}function iF(n){let e,t,r;return{c(){e=x("button"),e.textContent="Share local folder",h(e,"class","mod-cta"),h(e,"aria-label","Select a folder to share it with this Relay Server")},m(o,s){_(o,e,s),t||(r=$(e,"click",function(){Je((0,At.debounce)(n[80]))&&(0,At.debounce)(n[80]).apply(this,arguments)}),t=!0)},p(o,s){n=o},d(o){o&&w(e),t=!1,r()}}}function aF(n){let e,t,r,o=he(n[17].values()),s=[];for(let a=0;a<o.length;a+=1)s[a]=Zx(Wx(n,o,a));let i=a=>k(s[a],1,1,()=>{s[a]=null});return t=new Re({props:{description:"",name:"",$$slots:{default:[iF]},$$scope:{ctx:n}}}),{c(){for(let a=0;a<s.length;a+=1)s[a].c();e=T(),P(t.$$.fragment)},m(a,l){for(let c=0;c<s.length;c+=1)s[c]&&s[c].m(a,l);_(a,e,l),A(t,a,l),r=!0},p(a,l){if(l[0]&25296898|l[1]&32768|l[2]&64){o=he(a[17].values());let u;for(u=0;u<o.length;u+=1){let f=Wx(a,o,u);s[u]?(s[u].p(f,l),v(s[u],1)):(s[u]=Zx(f),s[u].c(),v(s[u],1),s[u].m(e.parentNode,e))}for(ee(),u=o.length;u<s.length;u+=1)i(u);te()}let c={};l[0]&7|l[3]&1024&&(c.$$scope={dirty:l,ctx:a}),t.$set(c)},i(a){if(!r){for(let l=0;l<o.length;l+=1)v(s[l]);v(t.$$.fragment,a),r=!0}},o(a){s=s.filter(Boolean);for(let l=0;l<s.length;l+=1)k(s[l]);k(t.$$.fragment,a),r=!1},d(a){a&&w(e),ze(s,a),F(t,a)}}}function Xx(n){let e,t,r,o,s,i,a,l=[cF,lF],c=[];function u(f,d){return f[25]?0:1}return t=u(n,[-1,-1,-1,-1]),r=c[t]=l[t](n),{c(){e=x("div"),r.c(),h(e,"class","edit-members-button svelte-3znnov"),h(e,"role","button"),h(e,"tabindex","0"),h(e,"aria-label",o=n[25]?"Done editing":"Edit members")},m(f,d){_(f,e,d),c[t].m(e,null),s=!0,i||(a=[$(e,"click",n[60]),$(e,"keypress",n[60])],i=!0)},p(f,d){let p=t;t=u(f,d),t!==p&&(ee(),k(c[p],1,1,()=>{c[p]=null}),te(),r=c[t],r||(r=c[t]=l[t](f),r.c()),v(r,1),r.m(e,null)),(!s||d[0]&33554432&&o!==(o=f[25]?"Done editing":"Edit members"))&&h(e,"aria-label",o)},i(f){s||(v(r),s=!0)},o(f){k(r),s=!1},d(f){f&&w(e),c[t].d(),i=!1,me(a)}}}function lF(n){let e,t;return e=new ia({props:{class:"svg-icon"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function cF(n){let e,t;return e=new na({props:{class:"svg-icon"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function uF(n){let e,t,r=n[21]&&Xx(n);return{c(){r&&r.c(),e=ue()},m(o,s){r&&r.m(o,s),_(o,e,s),t=!0},p(o,s){o[21]?r?(r.p(o,s),s[0]&2097152&&v(r,1)):(r=Xx(o),r.c(),v(r,1),r.m(e.parentNode,e)):r&&(ee(),k(r,1,1,()=>{r=null}),te())},i(o){t||(v(r),t=!0)},o(o){k(r),t=!1},d(o){o&&w(e),r&&r.d(o)}}}function fF(n){let e,t=n[94].role+"",r;return{c(){e=x("span"),r=V(t),h(e,"class","role-label")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s[0]&512&&t!==(t=o[94].role+"")&&J(r,t)},d(o){o&&w(e)}}}function dF(n){let e;function t(s,i){return s[25]?mF:pF}let r=t(n,[-1,-1,-1,-1]),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function pF(n){let e,t,r,o,s,i,a,l,c=he(n[26]),u=[];for(let f=0;f<c.length;f+=1)u[f]=ew(zx(n,c,f));return{c(){var f,d;e=x("div"),t=x("select");for(let p=0;p<u.length;p+=1)u[p].c();h(t,"class","dropdown"),t.disabled=r=n[94].userId===((f=n[1].loginManager.user)==null?void 0:f.id),h(t,"aria-label",o=n[94].userId===((d=n[1].loginManager.user)==null?void 0:d.id)?"Cannot modify your own role":void 0),h(t,"data-role-id",i=n[94].id),se(e,"display","flex"),se(e,"gap","8px"),se(e,"align-items","center")},m(f,d){_(f,e,d),b(e,t);for(let p=0;p<u.length;p+=1)u[p]&&u[p].m(t,null);_n(t,n[94].role),a||(l=$(t,"change",n[59]),a=!0)},p(f,d){var p,m;if(d[0]&67108864){c=he(f[26]);let y;for(y=0;y<c.length;y+=1){let g=zx(f,c,y);u[y]?u[y].p(g,d):(u[y]=ew(g),u[y].c(),u[y].m(t,null))}for(;y<u.length;y+=1)u[y].d(1);u.length=c.length}d[0]&67109378&&r!==(r=f[94].userId===((p=f[1].loginManager.user)==null?void 0:p.id))&&(t.disabled=r),d[0]&67109378&&o!==(o=f[94].userId===((m=f[1].loginManager.user)==null?void 0:m.id)?"Cannot modify your own role":void 0)&&h(t,"aria-label",o),d[0]&67109376&&s!==(s=f[94].role)&&_n(t,f[94].role),d[0]&67109376&&i!==(i=f[94].id)&&h(t,"data-role-id",i)},d(f){f&&w(e),ze(u,f),a=!1,l()}}}function mF(n){var r;let e,t=n[94].userId!==((r=n[1].loginManager.user)==null?void 0:r.id)&&tw(n);return{c(){t&&t.c(),e=ue()},m(o,s){t&&t.m(o,s),_(o,e,s)},p(o,s){var i;o[94].userId!==((i=o[1].loginManager.user)==null?void 0:i.id)?t?t.p(o,s):(t=tw(o),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},d(o){o&&w(e),t&&t.d(o)}}}function ew(n){let e,t=n[97].name+"",r,o;return{c(){e=x("option"),r=V(t),e.__value=o=n[97].name,Ye(e,e.__value)},m(s,i){_(s,e,i),b(e,r)},p(s,i){i[0]&67108864&&t!==(t=s[97].name+"")&&J(r,t),i[0]&67108864&&o!==(o=s[97].name)&&(e.__value=o,Ye(e,e.__value))},d(s){s&&w(e)}}}function tw(n){let e,t,r;function o(){return n[81](n[94])}return{c(){e=x("button"),e.textContent="Kick",h(e,"class","mod-destructive")},m(s,i){_(s,e,i),t||(r=$(e,"click",function(){Je((0,At.debounce)(o))&&(0,At.debounce)(o).apply(this,arguments)}),t=!0)},p(s,i){n=s},d(s){s&&w(e),t=!1,r()}}}function hF(n){let e;function t(s,i){return s[21]?dF:fF}let r=t(n,[-1,-1,-1,-1]),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function rw(n){let e,t;return e=new ni({props:{user:n[94].user,$$slots:{default:[hF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&512&&(s.user=r[94].user),o[0]&102760962|o[3]&1024&&(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 gF(n){let e,t=n[9].values().length+"",r,o,s=n[14].userLimit+"",i,a;return{c(){e=x("span"),r=V(t),o=V(" of "),i=V(s),a=V(" seats used"),h(e,"class","faint svelte-3znnov")},m(l,c){_(l,e,c),b(e,r),b(e,o),b(e,i),b(e,a)},p(l,c){c[0]&512&&t!==(t=l[9].values().length+"")&&J(r,t),c[0]&16384&&s!==(s=l[14].userLimit+"")&&J(i,s)},d(l){l&&w(e)}}}function yF(n){let e,t,r,o=he(n[9].values().sort(n[39])),s=[];for(let a=0;a<o.length;a+=1)s[a]=rw(jx(n,o,a));let i=a=>k(s[a],1,1,()=>{s[a]=null});return t=new Re({props:{description:"",name:"",$$slots:{default:[gF]},$$scope:{ctx:n}}}),{c(){for(let a=0;a<s.length;a+=1)s[a].c();e=T(),P(t.$$.fragment)},m(a,l){for(let c=0;c<s.length;c+=1)s[c]&&s[c].m(a,l);_(a,e,l),A(t,a,l),r=!0},p(a,l){if(l[0]&102760962|l[1]&402653440){o=he(a[9].values().sort(a[39]));let u;for(u=0;u<o.length;u+=1){let f=jx(a,o,u);s[u]?(s[u].p(f,l),v(s[u],1)):(s[u]=rw(f),s[u].c(),v(s[u],1),s[u].m(e.parentNode,e))}for(ee(),u=o.length;u<s.length;u+=1)i(u);te()}let c={};l[0]&16896|l[3]&1024&&(c.$$scope={dirty:l,ctx:a}),t.$set(c)},i(a){if(!r){for(let l=0;l<o.length;l+=1)v(s[l]);v(t.$$.fragment,a),r=!0}},o(a){s=s.filter(Boolean);for(let l=0;l<s.length;l+=1)k(s[l]);k(t.$$.fragment,a),r=!1},d(a){a&&w(e),ze(s,a),F(t,a)}}}function ow(n){let e,t;return e=new qc({}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function bF(n){let e,t,r,o,s,i,a,l,c,u,f,d=!n[12]&&ow(n);return{c(){e=x("div"),d&&d.c(),t=T(),r=x("div"),o=x("input"),i=T(),a=x("div"),h(o,"type","checkbox"),o.checked=n[11],o.disabled=s=!n[12],h(a,"class","checkbox-toggle"),h(r,"role","checkbox"),h(r,"aria-checked",n[11]),h(r,"tabindex","0"),h(r,"class",l=n[12]?"checkbox-container":"checkbox-container checkbox-locked"),_e(r,"is-enabled",n[11]),h(e,"class","setting-item-control")},m(p,m){_(p,e,m),d&&d.m(e,null),b(e,t),b(e,r),b(r,o),b(r,i),b(r,a),c=!0,u||(f=[$(o,"change",n[82]),$(r,"keypress",n[83]),$(r,"click",n[84])],u=!0)},p(p,m){p[12]?d&&(ee(),k(d,1,1,()=>{d=null}),te()):d?m[0]&4096&&v(d,1):(d=ow(p),d.c(),v(d,1),d.m(e,t)),(!c||m[0]&2048)&&(o.checked=p[11]),(!c||m[0]&4096&&s!==(s=!p[12]))&&(o.disabled=s),(!c||m[0]&2048)&&h(r,"aria-checked",p[11]),(!c||m[0]&4096&&l!==(l=p[12]?"checkbox-container":"checkbox-container checkbox-locked"))&&h(r,"class",l),(!c||m[0]&6144)&&_e(r,"is-enabled",p[11])},i(p){c||(v(d),c=!0)},o(p){k(d),c=!1},d(p){p&&w(e),d&&d.d(),u=!1,me(f)}}}function vF(n){let e;return{c(){e=x("div"),e.textContent="The owner of this Relay Server has disabled key sharing.",h(e,"class","setting-item-description mod-warning")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function xF(n){let e;return{c(){e=x("div"),e.textContent="The owner of this Relay Server has enabled key sharing.",h(e,"class","setting-item-description")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function wF(n){let e;return{c(){e=x("div"),e.textContent="Allow others to join this Relay Server with a Share Key.",h(e,"class","setting-item-description")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function _F(n){let e;function t(s,i){return s[12]?wF:s[11]?xF:vF}let r=t(n,[-1,-1,-1,-1]),o=r(n);return{c(){e=x("fragment"),o.c(),h(e,"slot","description")},m(s,i){_(s,e,i),o.m(e,null)},p(s,i){r!==(r=t(s,i))&&(o.d(1),o=r(s),o&&(o.c(),o.m(e,null)))},d(s){s&&w(e),o.d()}}}function nw(n){let e,t,r,o;e=new Re({props:{name:"Share Key",description:"Share this key with your collaborators.",$$slots:{default:[IF]},$$scope:{ctx:n}}});let s=n[12]&&sw(n);return{c(){P(e.$$.fragment),t=T(),s&&s.c(),r=ue()},m(i,a){A(e,i,a),_(i,t,a),s&&s.m(i,a),_(i,r,a),o=!0},p(i,a){let l={};a[0]&2304|a[3]&1024&&(l.$$scope={dirty:a,ctx:i}),e.$set(l),i[12]?s?(s.p(i,a),a[0]&4096&&v(s,1)):(s=sw(i),s.c(),v(s,1),s.m(r.parentNode,r)):s&&(ee(),k(s,1,1,()=>{s=null}),te())},i(i){o||(v(e.$$.fragment,i),v(s),o=!0)},o(i){k(e.$$.fragment,i),k(s),o=!1},d(i){i&&(w(t),w(r)),F(e,i),s&&s.d(i)}}}function SF(n){let e,t;return e=new Bc({props:{value:n[8]?n[8].key:"please wait...",disabled:!n[11],placeholder:"please wait...",readonly:!0,copyOnClick:!0,successMessage:"Invite link copied"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&256&&(s.value=r[8]?r[8].key:"please wait..."),o[0]&2048&&(s.disabled=!r[11]),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 kF(n){let e;return{c(){e=x("span"),e.textContent="Share key is currently disabled",h(e,"role","button"),h(e,"tabindex","0"),h(e,"class","input-like share-key-disabled-notice svelte-3znnov")},m(t,r){_(t,e,r)},p:B,i:B,o:B,d(t){t&&w(e)}}}function IF(n){let e,t,r,o,s=[kF,SF],i=[];function a(l,c){return l[11]?1:0}return t=a(n,[-1,-1,-1,-1]),r=i[t]=s[t](n),{c(){e=x("div"),r.c(),h(e,"class","share-key-container svelte-3znnov")},m(l,c){_(l,e,c),i[t].m(e,null),o=!0},p(l,c){let u=t;t=a(l,c),t===u?i[t].p(l,c):(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),r=i[t],r?r.p(l,c):(r=i[t]=s[t](l),r.c()),v(r,1),r.m(e,null))},i(l){o||(v(r),o=!0)},o(l){k(r),o=!1},d(l){l&&w(e),i[t].d()}}}function sw(n){let e,t;return e=new Re({props:{name:"Rotate key",description:"Create a new share key. The old key will no longer work.",$$slots:{default:[CF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[3]&1024&&(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 CF(n){let e,t,r;return{c(){e=x("button"),e.textContent="Rotate key",h(e,"class","mod-destructive")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,At.debounce)(n[54])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function LF(n){let e,t,r,o;e=new Gt({props:{name:n[12]?"Enable key sharing":"Key sharing",$$slots:{description:[_F],default:[bF]},$$scope:{ctx:n}}});let s=n[11]&&nw(n);return{c(){P(e.$$.fragment),t=T(),s&&s.c(),r=ue()},m(i,a){A(e,i,a),_(i,t,a),s&&s.m(i,a),_(i,r,a),o=!0},p(i,a){let l={};a[0]&4096&&(l.name=i[12]?"Enable key sharing":"Key sharing"),a[0]&6144|a[3]&1024&&(l.$$scope={dirty:a,ctx:i}),e.$set(l),i[11]?s?(s.p(i,a),a[0]&2048&&v(s,1)):(s=nw(i),s.c(),v(s,1),s.m(r.parentNode,r)):s&&(ee(),k(s,1,1,()=>{s=null}),te())},i(i){o||(v(e.$$.fragment,i),v(s),o=!0)},o(i){k(e.$$.fragment,i),k(s),o=!1},d(i){i&&(w(t),w(r)),F(e,i),s&&s.d(i)}}}function iw(n){let e,t,r,o,s,i,a;e=new Qe({props:{name:"Plan"}}),r=new vt({props:{$$slots:{default:[RF]},$$scope:{ctx:n}}});let l=n[29]&&n[29].quota>0&&cw(n),c=n[0].provider&&n[0].provider.selfHosted&&uw(n);return{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment),o=T(),l&&l.c(),s=T(),c&&c.c(),i=ue()},m(u,f){A(e,u,f),_(u,t,f),A(r,u,f),_(u,o,f),l&&l.m(u,f),_(u,s,f),c&&c.m(u,f),_(u,i,f),a=!0},p(u,f){let d={};f[0]&268484608|f[3]&1024&&(d.$$scope={dirty:f,ctx:u}),r.$set(d),u[29]&&u[29].quota>0?l?(l.p(u,f),f[0]&536870912&&v(l,1)):(l=cw(u),l.c(),v(l,1),l.m(s.parentNode,s)):l&&(ee(),k(l,1,1,()=>{l=null}),te()),u[0].provider&&u[0].provider.selfHosted?c?(c.p(u,f),f[0]&1&&v(c,1)):(c=uw(u),c.c(),v(c,1),c.m(i.parentNode,i)):c&&(ee(),k(c,1,1,()=>{c=null}),te())},i(u){a||(v(e.$$.fragment,u),v(r.$$.fragment,u),v(l),v(c),a=!0)},o(u){k(e.$$.fragment,u),k(r.$$.fragment,u),k(l),k(c),a=!1},d(u){u&&(w(t),w(o),w(s),w(i)),F(e,u),F(r,u),l&&l.d(u),c&&c.d(u)}}}function MF(n){let e,t;return e=new Re({props:{name:`Plan: ${n[14].plan}`,description:n[14].cta||"Thanks for supporting Relay development",$$slots:{default:[AF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&16384&&(s.name=`Plan: ${r[14].plan}`),o[0]&16384&&(s.description=r[14].cta||"Thanks for supporting Relay development"),o[0]&16384|o[3]&1024&&(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 TF(n){let e,t,r=!n[15].values()[0].active||n[15].values()[0].cancelAt,o,s;e=new Re({props:{name:`Plan: ${n[14].plan}`,description:"",$$slots:{description:[EF],default:[FF]},$$scope:{ctx:n}}});let i=r&&lw(n);return{c(){P(e.$$.fragment),t=T(),i&&i.c(),o=ue()},m(a,l){A(e,a,l),_(a,t,l),i&&i.m(a,l),_(a,o,l),s=!0},p(a,l){let c={};l[0]&16384&&(c.name=`Plan: ${a[14].plan}`),l[0]&268484608|l[3]&1024&&(c.$$scope={dirty:l,ctx:a}),e.$set(c),l[0]&32768&&(r=!a[15].values()[0].active||a[15].values()[0].cancelAt),r?i?(i.p(a,l),l[0]&32768&&v(i,1)):(i=lw(a),i.c(),v(i,1),i.m(o.parentNode,o)):i&&(ee(),k(i,1,1,()=>{i=null}),te())},i(a){s||(v(e.$$.fragment,a),v(i),s=!0)},o(a){k(e.$$.fragment,a),k(i),s=!1},d(a){a&&(w(t),w(o)),F(e,a),i&&i.d(a)}}}function AF(n){let e,t,r;return{c(){e=x("button"),e.textContent="Upgrade",h(e,"class","mod-cta")},m(o,s){_(o,e,s),t||(r=$(e,"click",function(){Je((0,At.debounce)(n[87]))&&(0,At.debounce)(n[87]).apply(this,arguments)}),t=!0)},p(o,s){n=o},d(o){o&&w(e),t=!1,r()}}}function aw(n){let e,t,r;return{c(){e=x("button"),e.textContent="Cancel",h(e,"class","mod-destructive")},m(o,s){_(o,e,s),t||(r=$(e,"click",function(){Je((0,At.debounce)(n[86]))&&(0,At.debounce)(n[86]).apply(this,arguments)}),t=!0)},p(o,s){n=o},d(o){o&&w(e),t=!1,r()}}}function FF(n){let e,t,r=n[15].values()[0].active&&!n[15].values()[0].cancelAt,o,s,i,a=r&&aw(n);return{c(){e=x("button"),e.textContent="Manage",t=T(),a&&a.c(),o=ue()},m(l,c){_(l,e,c),_(l,t,c),a&&a.m(l,c),_(l,o,c),s||(i=$(e,"click",function(){Je((0,At.debounce)(n[85]))&&(0,At.debounce)(n[85]).apply(this,arguments)}),s=!0)},p(l,c){n=l,c[0]&32768&&(r=n[15].values()[0].active&&!n[15].values()[0].cancelAt),r?a?a.p(n,c):(a=aw(n),a.c(),a.m(o.parentNode,o)):a&&(a.d(1),a=null)},d(l){l&&(w(e),w(t),w(o)),a&&a.d(l),s=!1,i()}}}function EF(n){let e,t=n[14].cta+"",r;return{c(){e=x("fragment"),r=V(t),h(e,"slot","description")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s[0]&16384&&t!==(t=o[14].cta+"")&&J(r,t)},d(o){o&&w(e)}}}function lw(n){let e,t;return e=new Re({props:{description:"",$$slots:{name:[DF],default:[PF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&32768|o[3]&1024&&(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 PF(n){let e=n[38](n[15].values()[0].cancelAt)+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&32768&&e!==(e=r[38](r[15].values()[0].cancelAt)+"")&&J(t,e)},d(r){r&&w(t)}}}function DF(n){let e;return{c(){e=x("span"),e.textContent="Status: Cancelled",h(e,"slot","name"),h(e,"class","mod-warning")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function RF(n){let e,t,r,o,s=[TF,MF],i=[];function a(l,c){return l[28]?0:1}return e=a(n,[-1,-1,-1,-1]),t=i[e]=s[e](n),{c(){t.c(),r=ue()},m(l,c){i[e].m(l,c),_(l,r,c),o=!0},p(l,c){let u=e;e=a(l,c),e===u?i[e].p(l,c):(ee(),k(i[u],1,1,()=>{i[u]=null}),te(),t=i[e],t?t.p(l,c):(t=i[e]=s[e](l),t.c()),v(t,1),t.m(r.parentNode,r))},i(l){o||(v(t),o=!0)},o(l){k(t),o=!1},d(l){l&&w(r),i[e].d(l)}}}function cw(n){let e,t,r,o;return e=new Qe({props:{name:"Storage"}}),r=new vt({props:{$$slots:{default:[HF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i[0]&536870912|i[3]&1024&&(a.$$scope={dirty:i,ctx:s}),r.$set(a)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function UF(n){let e,t;return e=new Gt({props:{name:"Total storage",description:"Total available storage.",$$slots:{default:[$F]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[3]&1024&&(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 OF(n){let e,t,r,o,s,i;return e=new Px({props:{diskUsagePercentage:Math.round(n[29].usage*100/n[29].quota)}}),r=new Gt({props:{name:"Usage",description:"Storage for images, audio, video, etc",$$slots:{default:[NF]},$$scope:{ctx:n}}}),s=new Gt({props:{name:"Total storage",description:"Total available storage.",$$slots:{default:[BF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment),o=T(),P(s.$$.fragment)},m(a,l){A(e,a,l),_(a,t,l),A(r,a,l),_(a,o,l),A(s,a,l),i=!0},p(a,l){let c={};l[0]&536870912&&(c.diskUsagePercentage=Math.round(a[29].usage*100/a[29].quota)),e.$set(c);let u={};l[0]&536870912|l[3]&1024&&(u.$$scope={dirty:l,ctx:a}),r.$set(u);let f={};l[0]&536870912|l[3]&1024&&(f.$$scope={dirty:l,ctx:a}),s.$set(f)},i(a){i||(v(e.$$.fragment,a),v(r.$$.fragment,a),v(s.$$.fragment,a),i=!0)},o(a){k(e.$$.fragment,a),k(r.$$.fragment,a),k(s.$$.fragment,a),i=!1},d(a){a&&(w(t),w(o)),F(e,a),F(r,a),F(s,a)}}}function $F(n){let e;return{c(){e=V("Unmetered by Relay")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function NF(n){let e=ai(n[29].usage)+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&536870912&&e!==(e=ai(r[29].usage)+"")&&J(t,e)},d(r){r&&w(t)}}}function BF(n){let e=ai(n[29].quota)+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&536870912&&e!==(e=ai(r[29].quota)+"")&&J(t,e)},d(r){r&&w(t)}}}function VF(n){let e=ai(n[29].maxFileSize)+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&536870912&&e!==(e=ai(r[29].maxFileSize)+"")&&J(t,e)},d(r){r&&w(t)}}}function HF(n){let e,t,r,o,s,i=[OF,UF],a=[];function l(c,u){return c[29].metered?0:1}return e=l(n,[-1,-1,-1,-1]),t=a[e]=i[e](n),o=new Gt({props:{name:"File size limit",description:"Maximum supported file size.",$$slots:{default:[VF]},$$scope:{ctx:n}}}),{c(){t.c(),r=T(),P(o.$$.fragment)},m(c,u){a[e].m(c,u),_(c,r,u),A(o,c,u),s=!0},p(c,u){let f=e;e=l(c,u),e===f?a[e].p(c,u):(ee(),k(a[f],1,1,()=>{a[f]=null}),te(),t=a[e],t?t.p(c,u):(t=a[e]=i[e](c),t.c()),v(t,1),t.m(r.parentNode,r));let d={};u[0]&536870912|u[3]&1024&&(d.$$scope={dirty:u,ctx:c}),o.$set(d)},i(c){s||(v(t),v(o.$$.fragment,c),s=!0)},o(c){k(t),k(o.$$.fragment,c),s=!1},d(c){c&&w(r),a[e].d(c),F(o,c)}}}function uw(n){let e,t,r,o;return e=new Qe({props:{name:"Host"}}),r=new vt({props:{$$slots:{default:[ZF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i[0]&113|i[3]&1024&&(a.$$scope={dirty:i,ctx:s}),r.$set(a)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function qF(n){let e=n[0].provider.url+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o[0]&1&&e!==(e=r[0].provider.url+"")&&J(t,e)},d(r){r&&w(t)}}}function jF(n){return{c:B,m:B,p:B,i:B,o:B,d:B}}function zF(n){let e,t,r=n[93].level==="warning"&&fw(n);return{c(){r&&r.c(),e=ue()},m(o,s){r&&r.m(o,s),_(o,e,s),t=!0},p(o,s){o[93].level==="warning"?r?(r.p(o,s),s[0]&1&&v(r,1)):(r=fw(o),r.c(),v(r,1),r.m(e.parentNode,e)):r&&(ee(),k(r,1,1,()=>{r=null}),te())},i(o){t||(v(r),t=!0)},o(o){k(r),t=!1},d(o){o&&w(e),r&&r.d(o)}}}function fw(n){let e,t;return e=new Re({props:{name:"Status",description:"",$$slots:{default:[WF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&1|o[3]&1024&&(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 dw(n){let e,t,r,o=Ln(n[93].link.text)+"",s;return{c(){e=x("br"),t=T(),r=x("a"),h(r,"href",s=n[93].link.url)},m(i,a){_(i,e,a),_(i,t,a),_(i,r,a),r.innerHTML=o},p(i,a){a[0]&1&&o!==(o=Ln(i[93].link.text)+"")&&(r.innerHTML=o),a[0]&1&&s!==(s=i[93].link.url)&&h(r,"href",s)},d(i){i&&(w(e),w(t),w(r))}}}function WF(n){let e,t,r=Ln(n[93].status)+"",o,s=n[93].link&&dw(n);return{c(){e=x("p"),t=new wn(!1),o=T(),s&&s.c(),t.a=o,h(e,"class","mod-warning relay-host-check svelte-3znnov")},m(i,a){_(i,e,a),t.m(r,e),b(e,o),s&&s.m(e,null)},p(i,a){a[0]&1&&r!==(r=Ln(i[93].status)+"")&&t.p(r),i[93].link?s?s.p(i,a):(s=dw(i),s.c(),s.m(e,null)):s&&(s.d(1),s=null)},d(i){i&&w(e),s&&s.d()}}}function KF(n){return{c:B,m:B,p:B,i:B,o:B,d:B}}function pw(n){let e,t,r,o,s,i,a,l,c=[QF,YF,JF,GF],u=[];function f(d,p){return d[4]?0:d[5]?1:d[6]?2:3}return i=f(n,[-1,-1,-1,-1]),a=u[i]=c[i](n),{c(){e=x("div"),t=x("div"),t.textContent="Relay Server Configuration",r=T(),o=x("div"),o.textContent="Copy this configuration to your Relay Server's TOML file.",s=T(),a.c(),h(t,"class","setting-item-name"),h(o,"class","setting-item-description"),h(e,"class","relay-auth-section svelte-3znnov")},m(d,p){_(d,e,p),b(e,t),b(e,r),b(e,o),b(e,s),u[i].m(e,null),l=!0},p(d,p){let m=i;i=f(d,p),i===m?u[i].p(d,p):(ee(),k(u[m],1,1,()=>{u[m]=null}),te(),a=u[i],a?a.p(d,p):(a=u[i]=c[i](d),a.c()),v(a,1),a.m(e,null))},i(d){l||(v(a),l=!0)},o(d){k(a),l=!1},d(d){d&&w(e),u[i].d()}}}function GF(n){let e;return{c(){e=x("div"),e.textContent="No configuration available",h(e,"class","error-message svelte-3znnov")},m(t,r){_(t,e,r)},p:B,i:B,o:B,d(t){t&&w(e)}}}function JF(n){let e,t;return e=new Kc({props:{toml:n[6]}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&64&&(s.toml=r[6]),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 YF(n){let e,t;return{c(){e=x("div"),t=V(n[5]),h(e,"class","error-message svelte-3znnov")},m(r,o){_(r,e,o),b(e,t)},p(r,o){o[0]&32&&J(t,r[5])},i:B,o:B,d(r){r&&w(e)}}}function QF(n){let e;return{c(){e=x("div"),e.textContent="Loading configuration...",h(e,"class","loading-message svelte-3znnov")},m(t,r){_(t,e,r)},p:B,i:B,o:B,d(t){t&&w(e)}}}function ZF(n){let e,t,r,o,s,i;e=new Re({props:{name:"URL",description:"",$$slots:{default:[qF]},$$scope:{ctx:n}}});let a={ctx:n,current:null,token:null,hasCatch:!1,pending:KF,then:zF,catch:jF,value:93,blocks:[,,,]};Qs(r=n[37](n[0]),a);let l=n[0].provider.publicKey&&pw(n);return{c(){P(e.$$.fragment),t=T(),a.block.c(),o=T(),l&&l.c(),s=ue()},m(c,u){A(e,c,u),_(c,t,u),a.block.m(c,a.anchor=u),a.mount=()=>o.parentNode,a.anchor=o,_(c,o,u),l&&l.m(c,u),_(c,s,u),i=!0},p(c,u){n=c;let f={};u[0]&1|u[3]&1024&&(f.$$scope={dirty:u,ctx:n}),e.$set(f),a.ctx=n,u[0]&1&&r!==(r=n[37](n[0]))&&Qs(r,a)||lc(a,n,u),n[0].provider.publicKey?l?(l.p(n,u),u[0]&1&&v(l,1)):(l=pw(n),l.c(),v(l,1),l.m(s.parentNode,s)):l&&(ee(),k(l,1,1,()=>{l=null}),te())},i(c){i||(v(e.$$.fragment,c),v(a.block),v(l),i=!0)},o(c){k(e.$$.fragment,c);for(let u=0;u<3;u+=1){let f=a.blocks[u];k(f)}k(l),i=!1},d(c){c&&(w(t),w(o),w(s)),F(e,c),a.block.d(c),a.token=null,a=null,l&&l.d(c)}}}function mw(n){let e,t,r,o;return e=new Qe({props:{name:"Membership"}}),r=new vt({props:{$$slots:{default:[eE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i[3]&1024&&(a.$$scope={dirty:i,ctx:s}),r.$set(a)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function XF(n){let e,t,r;return{c(){e=x("button"),e.textContent="Leave",h(e,"class","mod-warning")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,At.debounce)(n[88])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function eE(n){let e,t;return e=new Re({props:{name:"Leave Relay Server",description:"Leave the Relay Server. Local data is preserved.",$$slots:{default:[XF]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[3]&1024&&(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 hw(n){let e,t,r,o;return e=new Qe({props:{name:"Danger zone"}}),r=new vt({props:{$$slots:{default:[nE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i[0]&32768|i[3]&1024&&(a.$$scope={dirty:i,ctx:s}),r.$set(a)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function tE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Destroy",h(e,"class","mod-warning")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,At.debounce)(n[57])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function rE(n){let e,t;return{c(){e=x("button"),e.textContent="Destroy",e.disabled=t=!0,h(e,"class","mod-warning"),h(e,"aria-label","Cancel subscription to destroy Relay Server.")},m(r,o){_(r,e,o)},p:B,d(r){r&&w(e)}}}function oE(n){let e,t;function r(i,a){return a[0]&32768&&(e=null),e==null&&(e=i[15].values().length>0&&!i[15].values()[0].cancelAt),e?rE:tE}let o=r(n,[-1,-1,-1,-1]),s=o(n);return{c(){s.c(),t=ue()},m(i,a){s.m(i,a),_(i,t,a)},p(i,a){o===(o=r(i,a))&&s?s.p(i,a):(s.d(1),s=o(i),s&&(s.c(),s.m(t.parentNode,t)))},d(i){i&&w(t),s.d(i)}}}function nE(n){let e,t;return e=new Re({props:{name:"Destroy Relay Server",description:"This will destroy the Relay Server (deleting all data on the server). Local data is preserved.",$$slots:{default:[oE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&32768|o[3]&1024&&(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 sE(n){let e,t,r=!n[16]&&n[36]()&&n[0].name,o,s,i,a,l,c,u,f,d,p,m,y,g,I,L,C,S,M,E=!n[14].owner||n[13].filter(n[69]).values().length>1,U,K,R;e=new Ao({props:{items:[{type:"home",onClick:n[71]},{type:"relay",relay:n[0]}]}});let O=r&&Kx(n),q=n[19]&&Gx(n);i=new Qe({props:{name:"Shared Folders on this Relay Server",$$slots:{default:[tF]},$$scope:{ctx:n}}}),l=new vt({props:{$$slots:{default:[aF]},$$scope:{ctx:n}}}),p=new Qe({props:{name:"Users",$$slots:{default:[uF]},$$scope:{ctx:n}}}),y=new vt({props:{$$slots:{default:[yF]},$$scope:{ctx:n}}}),I=new Qe({props:{name:"Sharing",helpText:"Share keys can be shared with collaborators so that they can join the Relay Server. Once you have added all of your collaborators, you can disable the share key to prevent anyone from joining, even if they have the key."}}),C=new vt({props:{$$slots:{default:[LF]},$$scope:{ctx:n}}});let H=n[27]&&iw(n),G=E&&mw(n),ce=n[30]&&hw(n);return{c(){P(e.$$.fragment),t=T(),O&&O.c(),o=T(),q&&q.c(),s=T(),P(i.$$.fragment),a=T(),P(l.$$.fragment),c=T(),u=x("div"),f=T(),d=x("div"),P(p.$$.fragment),m=T(),P(y.$$.fragment),g=T(),P(I.$$.fragment),L=T(),P(C.$$.fragment),S=T(),H&&H.c(),M=T(),G&&G.c(),U=T(),ce&&ce.c(),K=ue(),h(u,"class","spacer svelte-3znnov"),h(d,"class","users-header")},m(N,X){A(e,N,X),_(N,t,X),O&&O.m(N,X),_(N,o,X),q&&q.m(N,X),_(N,s,X),A(i,N,X),_(N,a,X),A(l,N,X),_(N,c,X),_(N,u,X),_(N,f,X),_(N,d,X),A(p,d,null),_(N,m,X),A(y,N,X),_(N,g,X),A(I,N,X),_(N,L,X),A(C,N,X),_(N,S,X),H&&H.m(N,X),_(N,M,X),G&&G.m(N,X),_(N,U,X),ce&&ce.m(N,X),_(N,K,X),R=!0},p(N,X){let Me={};X[0]&1&&(Me.items=[{type:"home",onClick:N[71]},{type:"relay",relay:N[0]}]),e.$set(Me),X[0]&65537&&(r=!N[16]&&N[36]()&&N[0].name),r?O?(O.p(N,X),X[0]&65537&&v(O,1)):(O=Kx(N),O.c(),v(O,1),O.m(o.parentNode,o)):O&&(ee(),k(O,1,1,()=>{O=null}),te()),N[19]?q?(q.p(N,X),X[0]&524288&&v(q,1)):(q=Gx(N),q.c(),v(q,1),q.m(s.parentNode,s)):q&&(ee(),k(q,1,1,()=>{q=null}),te());let Ie={};X[0]&14680064|X[3]&1024&&(Ie.$$scope={dirty:X,ctx:N}),i.$set(Ie);let D={};X[0]&25296903|X[3]&1024&&(D.$$scope={dirty:X,ctx:N}),l.$set(D);let Q={};X[0]&35651584|X[3]&1024&&(Q.$$scope={dirty:X,ctx:N}),p.$set(Q);let de={};X[0]&102777346|X[3]&1024&&(de.$$scope={dirty:X,ctx:N}),y.$set(de);let Le={};X[0]&6400|X[3]&1024&&(Le.$$scope={dirty:X,ctx:N}),C.$set(Le),N[27]?H?(H.p(N,X),X[0]&134217728&&v(H,1)):(H=iw(N),H.c(),v(H,1),H.m(M.parentNode,M)):H&&(ee(),k(H,1,1,()=>{H=null}),te()),X[0]&24577&&(E=!N[14].owner||N[13].filter(N[69]).values().length>1),E?G?(G.p(N,X),X[0]&24577&&v(G,1)):(G=mw(N),G.c(),v(G,1),G.m(U.parentNode,U)):G&&(ee(),k(G,1,1,()=>{G=null}),te()),N[30]?ce?(ce.p(N,X),X[0]&1073741824&&v(ce,1)):(ce=hw(N),ce.c(),v(ce,1),ce.m(K.parentNode,K)):ce&&(ee(),k(ce,1,1,()=>{ce=null}),te())},i(N){R||(v(e.$$.fragment,N),v(O),v(q),v(i.$$.fragment,N),v(l.$$.fragment,N),v(p.$$.fragment,N),v(y.$$.fragment,N),v(I.$$.fragment,N),v(C.$$.fragment,N),v(H),v(G),v(ce),R=!0)},o(N){k(e.$$.fragment,N),k(O),k(q),k(i.$$.fragment,N),k(l.$$.fragment,N),k(p.$$.fragment,N),k(y.$$.fragment,N),k(I.$$.fragment,N),k(C.$$.fragment,N),k(H),k(G),k(ce),R=!1},d(N){N&&(w(t),w(o),w(s),w(a),w(c),w(u),w(f),w(d),w(m),w(g),w(L),w(S),w(M),w(U),w(K)),F(e,N),O&&O.d(N),q&&q.d(N),F(i,N),F(l,N),F(p),F(y,N),F(I,N),F(C,N),H&&H.d(N),G&&G.d(N),ce&&ce.d(N)}}}function ai(n,e=2){if(n===0)return"0 MB";let t=1024,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(n)/Math.log(t));return(n/Math.pow(t,o)).toFixed(e)+" "+r[o]}function iE(n,e){var t,r;let o={Owner:0,Member:1,Reader:2};return((t=o[n.name])!==null&&t!==void 0?t:999)-((r=o[e.name])!==null&&r!==void 0?r:999)}function aE(n){if(/[\\:*?"<>|]/.test(n))return!1;let t=n.split("/");for(let r of t)if(r===""||r==="."||r==="..")return!1;return!0}function lE(n,e,t){let r,o,s,i,a,l=B,c=()=>(l(),l=Dt(ae,Y=>t(13,a=Y)),ae),u,f=B,d=()=>(f(),f=Dt(N,Y=>t(14,u=Y)),N),p,m,y,g,I,L,C,S,M,E,U=B,K=()=>(U(),U=Dt(re,Y=>t(24,E=Y)),re),R,O,q,H,G,ce;n.$$.on_destroy.push(()=>l()),n.$$.on_destroy.push(()=>f()),n.$$.on_destroy.push(()=>U());let{relay:N}=e;d();let X=N.folders;ne(n,X,Y=>t(17,y=Y));let Me=ge(!1);ne(n,Me,Y=>t(23,M=Y));let Ie=ge(!1);ne(n,Ie,Y=>t(16,m=Y));let{plugin:D}=e,Q=!1,de=null,Le="",Ae=et([X,D.relayManager.relayRoles,D.relayManager.folderRoles],([Y,Ee,Ke])=>{let ct=Array.from(Y.values()),_r=ct.filter(Kr=>ao(D.relayManager.userCan(["folder","read_content"],Kr))),Sr=ct.filter(Kr=>ao(D.relayManager.userCan(["folder","manage_users"],Kr)));return _r.length!==Sr.length});ne(n,Ae,Y=>t(22,S=Y));let{sharedFolders:re}=e;K();let Z=et([X,re,D.relayManager.folderRoles],([Y,Ee])=>Array.from(Y.values()).filter(ct=>ao(D.relayManager.userCan(["folder","read_content"],ct))).some(ct=>Ee.some(_r=>_r.guid===ct.guid)));ne(n,Z,Y=>t(18,g=Y));function Se(){var Y;let Ee=(Y=D.loginManager.pb.authStore.model)===null||Y===void 0?void 0:Y.created;if(!Ee)return!1;let Ke=new Date(Ee),ct=new Date(Date.now()-1440*60*1e3);return Ke>ct}let{relayRoles:ae}=e;c(),D.relayManager.refreshRelay(N);function Pe(Y){return Ce(this,void 0,void 0,function*(){let Ee=yield D.loginManager.checkRelayHost(Y.guid);if(Ee.status===200)return Ee.json})}function De(Y){if(!Y)return"Active";let Ee=Gm.moment.utc(),Ke=Gm.moment.utc(Y),ct=Ke.diff(Ee,"days");return ct<=0?"Subscription has ended":ct===1?"Active for 1 more day":ct>31?`Ends on ${Ke.format("YYYY-MM-DD")}`:`Active for ${ct} more days`}function Ge(Y,Ee){var Ke;return Y.role==="Owner"&&Ee.role==="Owner"?Y.userId===((Ke=D.loginManager.user)===null||Ke===void 0?void 0:Ke.id)?-1:1:Y.role==="Owner"&&Ee.role!=="Owner"?-1:Y.role!=="Owner"&&Ee.role==="Owner"||Y.user.name>Ee.user.name?1:-1}let mt=et([D.relayManager.roles],([Y])=>Y.values().sort(iE));ne(n,mt,Y=>t(26,O=Y));let _t=u.subscriptions;ne(n,_t,Y=>t(15,p=Y));let zr=et(p,Y=>{if(Y.values().length===0)return;let Ee=Y.values()[0];return Ee.token||D.relayManager.getSubscriptionToken(Ee).then(Ke=>{Ee.token=Ke}),Ee});ne(n,zr,Y=>t(28,H=Y));let co=u.storageQuota;ne(n,co,Y=>t(29,G=Y));let Fr=a.filter(Y=>Y.relayId===N.id);ne(n,Fr,Y=>t(9,r=Y));let xr=ge(!0);ne(n,xr,Y=>t(10,o=Y));let Rt;st(()=>{Rt&&Rt.value===""&&Rt.focus()});let It=Xe();function Tn(){return Ce(this,void 0,void 0,function*(){var Y,Ee;if(!(!((Y=D.relayManager)===null||Y===void 0)&&Y.pb)){t(5,de="Not connected to relay service");return}t(4,Q=!0),t(5,de=null);try{let Ke=D.relayManager.pb.baseUrl+`/api/collections/relays/records/${N.id}/relay.toml`,_r=yield(yield at(Ke,{method:"GET",headers:{Authorization:D.relayManager.pb.authStore.token?`Bearer ${D.relayManager.pb.authStore.token}`:""}})).text();t(6,Le=_r.replace(/\{url\}/g,((Ee=N.provider)===null||Ee===void 0?void 0:Ee.url)||""))}catch(Ke){t(5,de=Ke instanceof Error?Ke.message:"Failed to fetch relay configuration")}finally{t(4,Q=!1)}})}st(()=>{var Y;Rt&&Rt.value===""&&Rt.focus(),!((Y=N.provider)===null||Y===void 0)&&Y.selfHosted&&Tn()});function Xo(Y){return Ce(this,void 0,void 0,function*(){var Ee;if(!(!((Ee=D.loginManager)===null||Ee===void 0)&&Ee.user))return;let Ke={relay:Y.id,quantity:10,user_email:D.loginManager.user.email},ct=btoa(JSON.stringify(Ke)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");window.open(D.buildApiUrl(`/subscribe/${ct}`),"_blank")})}function Po(Y){return Ce(this,void 0,void 0,function*(){let Ee=Y.token,Ke=Y.id;window.open(D.buildApiUrl(`/subscriptions/${Ke}/manage?token=${Ee}`),"_blank")})}function en(Y){return Ce(this,void 0,void 0,function*(){let Ee=Y.token,Ke=Y.id;window.open(D.buildApiUrl(`/subscriptions/${Ke}/cancel?token=${Ee}`),"_blank")})}function Wr(Y){i&&(pe.set(Y),D.relayManager.toggleRelayInvitation(Er,s).then(Ee=>{pe.set(Ee.enabled)}).catch(Ee=>{pe.set(!Y),tr(Ee,"Failed to toggle share key")}))}function tn(){return Ce(this,void 0,void 0,function*(){D.relayManager.leaveRelay(N),It("goBack",{clear:!0})})}function ns(){return Ce(this,void 0,void 0,function*(){It("goBack",{clear:!0})})}let Er,pe=ge(!0);ne(n,pe,Y=>t(11,s=Y));let qe=ge(!1);ne(n,qe,Y=>t(25,R=Y)),D.relayManager.getRelayInvitation(N).then(Y=>{Y&&(t(8,Er=Y),pe.set(Y.enabled))});function rt(){return Ce(this,void 0,void 0,function*(){if(Er)try{t(8,Er=yield D.relayManager.rotateKey(Er))}catch(Y){tr(Y,"Failed to rotate key.")}})}let rr=ge(!1);ne(n,rr,Y=>t(20,L=Y));let rn=D.timeProvider.debounce(()=>{D.relayManager.updateRelay(N).then(()=>{rr.set(!1)})},500);function oe(){xr.set(aE(Rt.value)),o&&Rt.value!==""&&(rr.set(!0),rn())}function Ue(){D.relayManager.destroyRelay(N),It("goBack",{})}function ht(Y){D.relayManager.kick(Y).catch(Ee=>{tr(Ee,"Failed to remove user")})}function uo(Y,Ee){return Ce(this,void 0,void 0,function*(){try{yield D.relayManager.updateRelayRole(Y,Ee)}catch(Ke){throw tr(Ke,"Failed to change user role."),Ke}})}function wr(Y){return Ce(this,void 0,void 0,function*(){let Ee=Y.target,Ke=r.get(Ee.dataset.roleId);if(Ke){let ct=Ke.role;try{yield uo(Ke,Ee.value)}catch(_r){Ee.value=ct}}})}function lu(Y){(Y instanceof MouseEvent||Y instanceof KeyboardEvent&&(Y.key==="Enter"||Y.key===" "))&&qe.update(Ee=>!Ee)}let ha=D.relayManager.userCan(["relay","manage_users"],N);ne(n,ha,Y=>t(21,C=Y));let ie=D.relayManager.userCan(["relay","manage_sharing"],N);ne(n,ie,Y=>t(12,i=Y));let Ne=D.relayManager.userCan(["relay","rename"],N);ne(n,Ne,Y=>t(19,I=Y));let gt=D.relayManager.userCan(["relay","delete"],N);ne(n,gt,Y=>t(30,ce=Y));let xt=D.relayManager.userCan(["subscription","manage"],N);ne(n,xt,Y=>t(27,q=Y));function Zt(Y,Ee,Ke,ct){return Ce(this,void 0,void 0,function*(){let _r=(0,At.normalizePath)(Y),Sr=re.find(ci=>ci.path==_r);if(D.vault.getFolderByPath(_r)===null&&(yield D.vault.createFolder(_r)),Sr)Sr.relayId=N.guid;else{let ci=ys();Sr=re.new(_r,ci,N.guid,!0)}let Kr=yield D.relayManager.createRemoteFolder(Sr,N,Ke!=null?Ke:!1,Ee);if(Ke&&ct&&ct.length>0)for(let ci of ct)yield D.relayManager.addFolderRole(Kr,ci,"Member");return Sr.remote=Kr,Sr.connect(),D.sharedFolders.notifyListeners(),ct&&ct.length>0&&setTimeout(()=>{It("manageRemoteFolder",{remoteFolder:Kr})},100),Sr})}let Pr=new Wc(D.app,N,re,D.relayManager,Zt);function ss(Y){return Ce(this,void 0,void 0,function*(){function Ee(Ke,ct,_r){return Ce(this,void 0,void 0,function*(){let Sr=(0,At.normalizePath)((0,gw.join)(_r,ct));D.vault.getFolderByPath(Sr)===null&&(yield D.vault.createFolder(Sr));let Kr=D.sharedFolders.new(Sr,Ke.guid,Ke.relay.guid,!0);return Kr.remote=Ke,D.sharedFolders.notifyListeners(),It("manageRemoteFolder",{remoteFolder:Kr.remote}),Kr})}new Mn(D.app,D.sharedFolders,Y,[],Ee).open()})}Go(()=>{Pr==null||Pr.destroy()});let k1=Y=>Y.role==="Owner"&&Y.relayId===N.id,I1=(Y,Ee)=>Ee.guid===Y.guid,C1=()=>It("goBack",{clear:!0}),L1=()=>Ie.set(!0),M1=()=>Ie.set(!0);function T1(){N.name=this.value,d(t(0,N))}function A1(Y){pt[Y?"unshift":"push"](()=>{Rt=Y,t(7,Rt)})}let F1=()=>Me.update(Y=>!Y),E1=Y=>{It("manageRemoteFolder",{remoteFolder:Y})},P1=Y=>{ss(Y)},D1=Y=>{It("manageRemoteFolder",{remoteFolder:Y})},R1=()=>{N.version===0?new ii(D.app,"Choose or create folder...",new Set(re.filter(Ee=>!!Ee.relayId).map(Ee=>Ee.path)).add("/"),re,Zt).open():Pr.open()},U1=Y=>{ht(Y)},O1=Y=>Wr(Y.currentTarget.checked),$1=()=>Wr(!s),N1=()=>Wr(!s),B1=()=>{Po(H)},V1=()=>{en(H)},H1=()=>{Xo(u)},q1=()=>{tn()};return n.$$set=Y=>{"relay"in Y&&d(t(0,N=Y.relay)),"plugin"in Y&&t(1,D=Y.plugin),"sharedFolders"in Y&&K(t(2,re=Y.sharedFolders)),"relayRoles"in Y&&c(t(3,ae=Y.relayRoles))},[N,D,re,ae,Q,de,Le,Rt,Er,r,o,s,i,a,u,p,m,y,g,I,L,C,S,M,E,R,O,q,H,G,ce,X,Me,Ie,Ae,Z,Se,Pe,De,Ge,mt,_t,zr,co,Fr,xr,It,Xo,Po,en,Wr,tn,pe,qe,rt,rr,oe,Ue,ht,wr,lu,ha,ie,Ne,gt,xt,Zt,Pr,ss,k1,I1,C1,L1,M1,T1,A1,F1,E1,P1,D1,R1,U1,O1,$1,N1,B1,V1,H1,q1]}var Jm=class extends z{constructor(e){super(),W(this,e,lE,sE,j,{relay:0,plugin:1,sharedFolders:2,relayRoles:3},JA,[-1,-1,-1,-1])}},li=Jm;function cE(n){let e,t,r,o,s,i;return r=new Qd({}),{c(){e=x("div"),t=x("div"),P(r.$$.fragment),h(t,"class","clickable-icon"),h(t,"aria-label","Back"),h(t,"tabindex","0"),h(t,"role","button"),h(e,"class","modal-setting-nav-bar")},m(a,l){_(a,e,l),b(e,t),A(r,t,null),o=!0,s||(i=[$(t,"click",n[0]),$(t,"keypress",n[1])],s=!0)},p:B,i(a){o||(v(r.$$.fragment,a),o=!0)},o(a){k(r.$$.fragment,a),o=!1},d(a){a&&w(e),F(r),s=!1,me(i)}}}function uE(n){let e=Xe();function t(){e("goBack",{})}function r(o){o.key==="Escape"&&(e("goBack",{}),o.stopPropagation())}return[t,r]}var Ym=class extends z{constructor(e){super(),W(this,e,uE,cE,j,{})}},yw=Ym;var Zm=require("obsidian");function bw(n){let e,t,r,o;return e=new Qe({props:{name:"Danger zone"}}),r=new vt({props:{$$slots:{default:[pE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i&256&&(a.$$scope={dirty:i,ctx:s}),r.$set(a)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function fE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Delete metadata",h(e,"class","mod-destructive")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,Zm.debounce)(n[6])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function dE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Move to trash",h(e,"class","mod-warning")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,Zm.debounce)(n[7])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function pE(n){let e,t,r,o;return e=new Re({props:{name:"Delete metadata",description:"Deletes edit history and disables change tracking.",$$slots:{default:[fE]},$$scope:{ctx:n}}}),r=new Re({props:{name:"Delete from vault",description:"Delete the local Shared Folder and all of its contents.",$$slots:{default:[dE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i&256&&(a.$$scope={dirty:i,ctx:s}),e.$set(a);let l={};i&256&&(l.$$scope={dirty:i,ctx:s}),r.$set(l)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function mE(n){let e,t,r,o,s,i;e=new Ao({props:{items:[{type:"home",onClick:n[5]},{type:"folder",folder:n[0]}]}});let a=n[0]&&bw(n);return{c(){P(e.$$.fragment),t=T(),r=x("div"),r.innerHTML=`<p style="margin: 1em; text-align: center">This Shared Folder is not on a Relay Server, or else you do not have
|
|
permission to access it.</p>`,o=T(),a&&a.c(),s=ue(),se(r,"padding","1em"),se(r,"margin","1em"),se(r,"background","var(--background-secondary)")},m(l,c){A(e,l,c),_(l,t,c),_(l,r,c),_(l,o,c),a&&a.m(l,c),_(l,s,c),i=!0},p(l,[c]){let u={};c&1&&(u.items=[{type:"home",onClick:l[5]},{type:"folder",folder:l[0]}]),e.$set(u),l[0]?a?(a.p(l,c),c&1&&v(a,1)):(a=bw(l),a.c(),v(a,1),a.m(s.parentNode,s)):a&&(ee(),k(a,1,1,()=>{a=null}),te())},i(l){i||(v(e.$$.fragment,l),v(a),i=!0)},o(l){k(e.$$.fragment,l),k(a),i=!1},d(l){l&&(w(t),w(r),w(o),w(s)),F(e,l),a&&a.d(l)}}}function hE(n,e,t){let{plugin:r}=e,{sharedFolder:o}=e,s=Xe();function i(){return Ce(this,void 0,void 0,function*(){o&&r.sharedFolders.delete(o),s("goBack",{clear:!0})})}function a(){if(o){let f=r.vault.getFolderByPath(o.path);f&&r.app.vault.trash(f,!1)}s("goBack",{})}let l=()=>s("goBack",{clear:!0}),c=()=>{i()},u=()=>{a()};return n.$$set=f=>{"plugin"in f&&t(4,r=f.plugin),"sharedFolder"in f&&t(0,o=f.sharedFolder)},[o,s,i,a,r,l,c,u]}var Qm=class extends z{constructor(e){super(),W(this,e,hE,mE,j,{plugin:4,sharedFolder:0})}},Gc=Qm;var Eo=require("obsidian");var Kw=require("obsidian"),Gw=Do(An());var Sw=require("obsidian");function gE(n){we(n,"svelte-1iq1qoa",".search-container.svelte-1iq1qoa.svelte-1iq1qoa{margin-bottom:16px}.search-input.svelte-1iq1qoa.svelte-1iq1qoa{width:100%;padding:8px 12px;border:1px solid var(--background-modifier-border);border-radius:4px;background:var(--background-primary);color:var(--text-normal)}.user-list.svelte-1iq1qoa.svelte-1iq1qoa{flex:1;max-height:400px;overflow-y:auto;border:1px solid var(--background-modifier-border);border-radius:4px;background:var(--background-primary);margin-bottom:16px}.user-item.svelte-1iq1qoa.svelte-1iq1qoa{display:flex;align-items:center;padding:12px;border-bottom:1px solid var(--background-modifier-border);cursor:pointer;gap:12px}.user-item.svelte-1iq1qoa.svelte-1iq1qoa:last-child{border-bottom:none}.user-item.svelte-1iq1qoa.svelte-1iq1qoa:hover:not(.has-access){background:var(--background-modifier-hover)}.user-item.has-access.svelte-1iq1qoa.svelte-1iq1qoa{opacity:0.6;cursor:not-allowed}.user-checkbox.svelte-1iq1qoa.svelte-1iq1qoa{margin:0;cursor:pointer}.user-avatar.svelte-1iq1qoa.svelte-1iq1qoa{width:32px;height:32px;border-radius:50%;background:var(--interactive-accent);display:flex;align-items:center;justify-content:center;color:white;font-size:12px;font-weight:500;flex-shrink:0}.user-avatar.svelte-1iq1qoa img.svelte-1iq1qoa{width:100%;height:100%;border-radius:50%;object-fit:cover}.user-info.svelte-1iq1qoa.svelte-1iq1qoa{flex:1;min-width:0}.user-name.svelte-1iq1qoa.svelte-1iq1qoa{font-weight:500;margin-bottom:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-status.svelte-1iq1qoa.svelte-1iq1qoa{font-size:0.8em;color:var(--text-muted);font-style:italic}.no-users.svelte-1iq1qoa.svelte-1iq1qoa{text-align:center;padding:40px;color:var(--text-muted)}.modal-button-container.svelte-1iq1qoa.svelte-1iq1qoa{display:flex;justify-content:space-between;align-items:center;margin-top:16px}.selection-count.svelte-1iq1qoa.svelte-1iq1qoa{color:var(--text-muted);font-size:0.9em}button.svelte-1iq1qoa.svelte-1iq1qoa:disabled{opacity:0.5;cursor:not-allowed}")}function vw(n,e,t){let r=n.slice();return r[22]=e[t],r}function yE(n){let e,t=he(n[1]),r=[];for(let o=0;o<t.length;o+=1)r[o]=xw(vw(n,t,o));return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=ue()},m(o,s){for(let i=0;i<r.length;i+=1)r[i]&&r[i].m(o,s);_(o,e,s)},p(o,s){if(s&130){t=he(o[1]);let i;for(i=0;i<t.length;i+=1){let a=vw(o,t,i);r[i]?r[i].p(a,s):(r[i]=xw(a),r[i].c(),r[i].m(e.parentNode,e))}for(;i<r.length;i+=1)r[i].d(1);r.length=t.length}},d(o){o&&w(e),ze(r,o)}}}function bE(n){let e,t=n[0]?"No users found":"No users available",r;return{c(){e=x("div"),r=V(t),h(e,"class","no-users svelte-1iq1qoa")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s&1&&t!==(t=o[0]?"No users found":"No users available")&&J(r,t)},d(o){o&&w(e)}}}function vE(n){let e=ww(n[22].user.name)+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&2&&e!==(e=ww(r[22].user.name)+"")&&J(t,e)},d(r){r&&w(t)}}}function xE(n){let e,t,r;return{c(){e=x("img"),hr(e.src,t=n[22].user.picture)||h(e,"src",t),h(e,"alt",r=n[22].user.name),h(e,"class","svelte-1iq1qoa")},m(o,s){_(o,e,s)},p(o,s){s&2&&!hr(e.src,t=o[22].user.picture)&&h(e,"src",t),s&2&&r!==(r=o[22].user.name)&&h(e,"alt",r)},d(o){o&&w(e)}}}function wE(n){let e;return{c(){e=x("div"),e.textContent="(You)",h(e,"class","user-status svelte-1iq1qoa")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function _E(n){let e;return{c(){e=x("div"),e.textContent="Already has access",h(e,"class","user-status svelte-1iq1qoa")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function xw(n){let e,t,r,o,s,i,a,l,c,u=n[22].user.name+"",f,d,p,m,y;function g(...R){return n[14](n[22],...R)}function I(R,O){return R[22].user.picture?xE:vE}let L=I(n,-1),C=L(n);function S(R,O){if(R[22].hasAccess)return _E;if(R[22].isCurrentUser)return wE}let M=S(n,-1),E=M&&M(n);function U(){return n[15](n[22])}function K(...R){return n[16](n[22],...R)}return{c(){e=x("div"),t=x("input"),s=T(),i=x("div"),C.c(),a=T(),l=x("div"),c=x("div"),f=V(u),d=T(),E&&E.c(),p=T(),h(t,"type","checkbox"),t.checked=r=n[22].selected,t.disabled=o=n[22].hasAccess,h(t,"class","user-checkbox svelte-1iq1qoa"),h(i,"class","user-avatar svelte-1iq1qoa"),h(c,"class","user-name svelte-1iq1qoa"),h(l,"class","user-info svelte-1iq1qoa"),h(e,"class","user-item svelte-1iq1qoa"),h(e,"role","button"),h(e,"tabindex","0"),_e(e,"has-access",n[22].hasAccess),_e(e,"is-owner",n[22].isOwner),_e(e,"is-current-user",n[22].isCurrentUser)},m(R,O){_(R,e,O),b(e,t),b(e,s),b(e,i),C.m(i,null),b(e,a),b(e,l),b(l,c),b(c,f),b(e,d),E&&E.m(e,null),b(e,p),m||(y=[$(t,"click",g),$(e,"click",U),$(e,"keydown",K)],m=!0)},p(R,O){n=R,O&2&&r!==(r=n[22].selected)&&(t.checked=r),O&2&&o!==(o=n[22].hasAccess)&&(t.disabled=o),L===(L=I(n,O))&&C?C.p(n,O):(C.d(1),C=L(n),C&&(C.c(),C.m(i,null))),O&2&&u!==(u=n[22].user.name+"")&&J(f,u),M!==(M=S(n,O))&&(E&&E.d(1),E=M&&M(n),E&&(E.c(),E.m(e,p))),O&2&&_e(e,"has-access",n[22].hasAccess),O&2&&_e(e,"is-owner",n[22].isOwner),O&2&&_e(e,"is-current-user",n[22].isCurrentUser)},d(R){R&&w(e),C.d(),E&&E.d(),m=!1,me(y)}}}function SE(n){let e,t,r,o,s,i,a,l,c,u,f=n[2]===0?"No users selected":`${n[2]} user${n[2]===1?"":"s"} selected`,d,p,m,y,g,I,L;function C(E,U){return E[1].length===0?bE:yE}let S=C(n,-1),M=S(n);return{c(){e=x("div"),e.textContent="Invite users to this folder",t=T(),r=x("div"),o=x("div"),s=x("input"),i=T(),a=x("div"),M.c(),l=T(),c=x("div"),u=x("span"),d=V(f),p=T(),m=x("button"),y=V("Add Users"),h(e,"class","modal-title"),h(s,"type","text"),h(s,"placeholder","Search users by name..."),h(s,"class","search-input svelte-1iq1qoa"),h(o,"class","search-container svelte-1iq1qoa"),h(a,"class","user-list svelte-1iq1qoa"),h(u,"class","selection-count svelte-1iq1qoa"),h(m,"class","mod-cta svelte-1iq1qoa"),m.disabled=g=n[2]===0,h(c,"class","modal-button-container svelte-1iq1qoa"),h(r,"class","modal-content user-select-modal")},m(E,U){_(E,e,U),_(E,t,U),_(E,r,U),b(r,o),b(o,s),Ye(s,n[0]),b(r,i),b(r,a),M.m(a,null),b(r,l),b(r,c),b(c,u),b(u,d),b(c,p),b(c,m),b(m,y),I||(L=[$(s,"input",n[13]),$(m,"click",n[8])],I=!0)},p(E,[U]){U&1&&s.value!==E[0]&&Ye(s,E[0]),S===(S=C(E,U))&&M?M.p(E,U):(M.d(1),M=S(E),M&&(M.c(),M.m(a,null))),U&4&&f!==(f=E[2]===0?"No users selected":`${E[2]} user${E[2]===1?"":"s"} selected`)&&J(d,f),U&4&&g!==(g=E[2]===0)&&(m.disabled=g)},i:B,o:B,d(E){E&&(w(e),w(t),w(r)),M.d(),I=!1,me(L)}}}function ww(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().substring(0,2)}function kE(n,e,t){let r,o,s,i,{relayManager:a}=e,{folder:l}=e,{onAdd:c}=e,{preSelectedUserIds:u=[]}=e,f=ge(new Set([...u]));ne(n,f,R=>t(17,r=R));let d=ge("");ne(n,d,R=>t(0,o=R));let p=et([a.relayRoles],([R])=>R.values().filter(O=>O.relayId===l.relayId).map(O=>O.user)),m=et([a.folderRoles],([R])=>R.values().filter(O=>O.sharedFolderId===l.id)),y=et([p,m,f],([R,O,q])=>{var H;let G=new Set(O.map(X=>X.userId)),ce=new Set(O.filter(X=>X.role==="Owner").map(X=>X.userId)),N=(H=a.user)===null||H===void 0?void 0:H.id;return R.map(X=>{let Me=ce.has(X.id),Ie=N===X.id,D=q.has(X.id);return{user:X,hasAccess:G.has(X.id),selected:D,isOwner:Me,isCurrentUser:Ie}})}),g=et([y,d],([R,O])=>{if(!O)return R;let q=O.toLowerCase();return R.filter(H=>H.user.name.toLowerCase().includes(q))}),I=et([g],([R])=>R.sort((O,q)=>O.hasAccess&&!q.hasAccess?1:!O.hasAccess&&q.hasAccess?-1:O.user.name.localeCompare(q.user.name)));ne(n,I,R=>t(1,s=R));let L=et([f],([R])=>R.size);ne(n,L,R=>t(2,i=R));function C(R){R.hasAccess||f.update(O=>{let q=new Set(O);return q.has(R.user.id)?q.delete(R.user.id):q.add(R.user.id),q})}function S(){return Ce(this,void 0,void 0,function*(){let R=r;if(R.size!==0)try{yield c(Array.from(R),"Member")}catch(O){tr(O)}})}function M(){o=this.value,d.set(o)}let E=(R,O)=>{O.stopPropagation(),C(R)},U=R=>C(R),K=(R,O)=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),C(R))};return n.$$set=R=>{"relayManager"in R&&t(9,a=R.relayManager),"folder"in R&&t(10,l=R.folder),"onAdd"in R&&t(11,c=R.onAdd),"preSelectedUserIds"in R&&t(12,u=R.preSelectedUserIds)},[o,s,i,f,d,I,L,C,S,a,l,c,u,M,E,U,K]}var Xm=class extends z{constructor(e){super(),W(this,e,kE,SE,j,{relayManager:9,folder:10,onAdd:11,preSelectedUserIds:12},gE)}},_w=Xm;var Jc=class extends Sw.Modal{constructor(t,r,o,s,i){super(t);this.relayManager=r;this.folder=o;this.onAdd=s;this.preSelectedUserIds=i}onOpen(){let{contentEl:t}=this;this.component=new _w({target:t,props:{relayManager:this.relayManager,folder:this.folder,preSelectedUserIds:this.preSelectedUserIds,onAdd:async(r,o)=>{await this.onAdd(r,o),this.close()}}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};function IE(n){we(n,"svelte-fmnezc",`div.spacer.svelte-fmnezc{height:3em}.local-settings.svelte-fmnezc{margin-left:-1em;padding-left:1em;border-left:1px solid var(--color-accent)}.system3-input-invalid.svelte-fmnezc{border:1px solid var(--color-red) !important}input.system3-updating.svelte-fmnezc{border:1px solid var(--color-accent) !important}.edit-members-button.svelte-fmnezc{display:flex;cursor:pointer;padding:4px;margin-bottom:-4px;border-radius:var(--radius-s);color:var(--icon-color);transition:color 0.15s ease-in-out,
|
|
background-color 0.15s ease-in-out}.edit-members-button.svelte-fmnezc:hover{color:var(--icon-color-hover);background-color:var(--background-modifier-hover)}.edit-members-button.svelte-fmnezc:focus{outline:none;color:var(--icon-color-focus)}select.dropdown.svelte-fmnezc:disabled{opacity:1 !important;color:var(--text-muted) !important;-webkit-text-fill-color:var(--text-muted) !important}`)}function kw(n,e,t){let r=n.slice();return r[68]=e[t][0],r[69]=e[t][1],r}function Iw(n,e,t){let r=n.slice();return r[72]=e[t],r}function Cw(n,e,t){let r=n.slice();return r[72]=e[t],r}function Lw(n){let e;return{c(){e=x("div"),e.innerHTML=`<p style="margin: 1em; text-align: center">As Relay Server owner, you can manage this Shared Folder but cannot access
|
|
its contents. You must be added to the Shared Folder in order to
|
|
collaborate.</p>`,se(e,"padding","1em"),se(e,"margin","1em"),se(e,"background","var(--background-secondary)")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function Mw(n){let e,t;return e=new Re({props:{name:"Name",description:"Set the Shared Folder's default name. A Shared Folder can always be renamed locally.",$$slots:{default:[CE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&33048|o[2]&32768&&(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 CE(n){let e,t,r,o;return{c(){e=x("input"),h(e,"type","text"),h(e,"spellcheck","false"),h(e,"placeholder","Example: Shared Notes"),h(e,"class",t=Tt((n[15]?"system3-updating":"")+(n[8]?"":" system3-input-invalid"))+" svelte-fmnezc")},m(s,i){_(s,e,i),Ye(e,n[3]),n[56](e),r||(o=[$(e,"input",n[55]),$(e,"input",n[48])],r=!0)},p(s,i){i[0]&33024&&t!==(t=Tt((s[15]?"system3-updating":"")+(s[8]?"":" system3-input-invalid"))+" svelte-fmnezc")&&h(e,"class",t),i[0]&8&&e.value!==s[3]&&Ye(e,s[3])},d(s){s&&w(e),n[56](null),r=!1,me(o)}}}function Tw(n){let e,t,r,o;return e=new Qe({props:{name:"Add to vault"}}),r=new vt({props:{$$slots:{default:[ME]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i[2]&32768&&(a.$$scope={dirty:i,ctx:s}),r.$set(a)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function LE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Add to vault",h(e,"class","mod-cta system3-button")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,Eo.debounce)(n[47])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function ME(n){let e,t;return e=new Re({props:{name:"Add this folder to your vault",description:"Download and sync this folder to your local device",$$slots:{default:[LE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[2]&32768&&(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 Aw(n){let e,t,r,o;return e=new Qe({props:{name:"Users with access",helpText:n[7]?"":"This folder is accessible to everyone on this Relay Server.",$$slots:{default:[FE]},$$scope:{ctx:n}}}),r=new vt({props:{$$slots:{default:[OE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i[0]&128&&(a.helpText=s[7]?"":"This folder is accessible to everyone on this Relay Server."),i[0]&135172|i[2]&32768&&(a.$$scope={dirty:i,ctx:s}),e.$set(a);let l={};i[0]&397952|i[2]&32768&&(l.$$scope={dirty:i,ctx:s}),r.$set(l)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function Fw(n){let e,t,r,o,s,i,a,l=[AE,TE],c=[];function u(f,d){return f[17]?0:1}return t=u(n,[-1,-1,-1]),r=c[t]=l[t](n),{c(){e=x("div"),r.c(),h(e,"class","edit-members-button svelte-fmnezc"),h(e,"role","button"),h(e,"tabindex","0"),h(e,"aria-label",o=n[17]?"Cancel editing users":"Edit users")},m(f,d){_(f,e,d),c[t].m(e,null),s=!0,i||(a=[$(e,"click",n[42]),$(e,"keypress",n[42])],i=!0)},p(f,d){let p=t;t=u(f,d),t!==p&&(ee(),k(c[p],1,1,()=>{c[p]=null}),te(),r=c[t],r||(r=c[t]=l[t](f),r.c()),v(r,1),r.m(e,null)),(!s||d[0]&131072&&o!==(o=f[17]?"Cancel editing users":"Edit users"))&&h(e,"aria-label",o)},i(f){s||(v(r),s=!0)},o(f){k(r),s=!1},d(f){f&&w(e),c[t].d(),i=!1,me(a)}}}function TE(n){let e,t;return e=new ia({props:{class:"svg-icon"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function AE(n){let e,t;return e=new na({props:{class:"svg-icon"}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function FE(n){let e,t,r=n[2].private&&n[12]&&Fw(n);return{c(){r&&r.c(),e=ue()},m(o,s){r&&r.m(o,s),_(o,e,s),t=!0},p(o,s){o[2].private&&o[12]?r?(r.p(o,s),s[0]&4100&&v(r,1)):(r=Fw(o),r.c(),v(r,1),r.m(e.parentNode,e)):r&&(ee(),k(r,1,1,()=>{r=null}),te())},i(o){t||(v(r),t=!0)},o(o){k(r),t=!1},d(o){o&&w(e),r&&r.d(o)}}}function Ew(n){let e;function t(s,i){return s[17]?DE:s[12]?PE:EE}let r=t(n,[-1,-1,-1]),o=r(n);return{c(){o.c(),e=ue()},m(s,i){o.m(s,i),_(s,e,i)},p(s,i){r===(r=t(s,i))&&o?o.p(s,i):(o.d(1),o=r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o.d(s)}}}function EE(n){let e,t=n[72].role+"",r;return{c(){e=x("span"),r=V(t),h(e,"class","role-label")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s[0]&512&&t!==(t=o[72].role+"")&&J(r,t)},d(o){o&&w(e)}}}function PE(n){let e,t,r,o,s,i,a=he(n[18]),l=[];for(let c=0;c<a.length;c+=1)l[c]=Pw(Cw(n,a,c));return{c(){e=x("div"),t=x("select");for(let c=0;c<l.length;c+=1)l[c].c();h(t,"class","dropdown svelte-fmnezc"),h(t,"data-role-id",o=n[72].id),se(e,"display","flex"),se(e,"gap","8px"),se(e,"align-items","center")},m(c,u){_(c,e,u),b(e,t);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(t,null);_n(t,n[72].role),s||(i=$(t,"change",n[46]),s=!0)},p(c,u){if(u[0]&262144){a=he(c[18]);let f;for(f=0;f<a.length;f+=1){let d=Cw(c,a,f);l[f]?l[f].p(d,u):(l[f]=Pw(d),l[f].c(),l[f].m(t,null))}for(;f<l.length;f+=1)l[f].d(1);l.length=a.length}u[0]&262656&&r!==(r=c[72].role)&&_n(t,c[72].role),u[0]&262656&&o!==(o=c[72].id)&&h(t,"data-role-id",o)},d(c){c&&w(e),ze(l,c),s=!1,i()}}}function DE(n){let e,t,r;function o(){return n[57](n[72])}return{c(){e=x("button"),e.textContent="Remove",h(e,"class","mod-destructive")},m(s,i){_(s,e,i),t||(r=$(e,"click",function(){Je((0,Eo.debounce)(o))&&(0,Eo.debounce)(o).apply(this,arguments)}),t=!0)},p(s,i){n=s},d(s){s&&w(e),t=!1,r()}}}function Pw(n){let e,t=n[72].name+"",r,o;return{c(){e=x("option"),r=V(t),e.__value=o=n[72].name,Ye(e,e.__value)},m(s,i){_(s,e,i),b(e,r)},p(s,i){i[0]&262144&&t!==(t=s[72].name+"")&&J(r,t),i[0]&262144&&o!==(o=s[72].name)&&(e.__value=o,Ye(e,e.__value))},d(s){s&&w(e)}}}function RE(n){let e,t=n[7]&&Ew(n);return{c(){t&&t.c(),e=ue()},m(r,o){t&&t.m(r,o),_(r,e,o)},p(r,o){r[7]?t?t.p(r,o):(t=Ew(r),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},d(r){r&&w(e),t&&t.d(r)}}}function Dw(n){let e,t;return e=new ni({props:{user:n[72].user,$$slots:{default:[RE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&512&&(s.user=r[72].user),o[0]&397952|o[2]&32768&&(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 Rw(n){let e,t;return e=new Re({props:{description:"",name:"",$$slots:{default:[UE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&131072|o[2]&32768&&(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 UE(n){let e,t,r,o;return{c(){e=x("button"),t=V("Add User"),h(e,"class","mod-cta"),h(e,"aria-label","Add user to private folder"),e.disabled=n[17]},m(s,i){_(s,e,i),b(e,t),r||(o=$(e,"click",(0,Eo.debounce)(n[45])),r=!0)},p(s,i){i[0]&131072&&(e.disabled=s[17])},d(s){s&&w(e),r=!1,o()}}}function OE(n){let e,t,r,o=he(n[9]),s=[];for(let l=0;l<o.length;l+=1)s[l]=Dw(Iw(n,o,l));let i=l=>k(s[l],1,1,()=>{s[l]=null}),a=n[7]&&n[12]&&Rw(n);return{c(){for(let l=0;l<s.length;l+=1)s[l].c();e=T(),a&&a.c(),t=ue()},m(l,c){for(let u=0;u<s.length;u+=1)s[u]&&s[u].m(l,c);_(l,e,c),a&&a.m(l,c),_(l,t,c),r=!0},p(l,c){if(c[0]&397952|c[1]&36864){o=he(l[9]);let u;for(u=0;u<o.length;u+=1){let f=Iw(l,o,u);s[u]?(s[u].p(f,c),v(s[u],1)):(s[u]=Dw(f),s[u].c(),v(s[u],1),s[u].m(e.parentNode,e))}for(ee(),u=o.length;u<s.length;u+=1)i(u);te()}l[7]&&l[12]?a?(a.p(l,c),c[0]&4224&&v(a,1)):(a=Rw(l),a.c(),v(a,1),a.m(t.parentNode,t)):a&&(ee(),k(a,1,1,()=>{a=null}),te())},i(l){if(!r){for(let c=0;c<o.length;c+=1)v(s[c]);v(a),r=!0}},o(l){s=s.filter(Boolean);for(let c=0;c<s.length;c+=1)k(s[c]);k(a),r=!1},d(l){l&&(w(e),w(t)),ze(s,l),a&&a.d(l)}}}function Uw(n){let e,t,r,o,s;return t=new Qe({props:{name:"Sync settings for this device",helpText:"You must have attachment storage available in order to sync attachments."}}),o=new vt({props:{$$slots:{default:[VE]},$$scope:{ctx:n}}}),{c(){e=x("div"),P(t.$$.fragment),r=T(),P(o.$$.fragment),h(e,"class","local-settings svelte-fmnezc")},m(i,a){_(i,e,a),A(t,e,null),b(e,r),A(o,e,null),s=!0},p(i,a){let l={};a[0]&593e3|a[2]&32768&&(l.$$scope={dirty:a,ctx:i}),o.$set(l)},i(i){s||(v(t.$$.fragment,i),v(o.$$.fragment,i),s=!0)},o(i){k(t.$$.fragment,i),k(o.$$.fragment,i),s=!1},d(i){i&&w(e),F(t),F(o)}}}function Ow(n){let e,t;return e=new Re({props:{name:"Local path",description:"This folder has a different name in your Vault",$$slots:{default:[$E]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&1024|o[2]&32768&&(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 $E(n){let e,t=n[10].path+"",r;return{c(){e=V("/"),r=V(t)},m(o,s){_(o,e,s),_(o,r,s)},p(o,s){s[0]&1024&&t!==(t=o[10].path+"")&&J(r,t)},d(o){o&&(w(e),w(r))}}}function $w(n){let e,t;return e=new qc({}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function NE(n){let e,t,r,o,s,i,a,l,c,u,f,d=n[11]&&$w(n);function p(...g){return n[58](n[68],...g)}function m(){return n[59](n[68])}function y(){return n[60](n[68])}return{c(){e=x("div"),d&&d.c(),t=T(),r=x("div"),o=x("input"),i=T(),a=x("div"),h(o,"type","checkbox"),o.checked=s=n[19][n[68]]&&!n[11],o.disabled=n[5],h(a,"class","checkbox-toggle"),h(r,"role","checkbox"),h(r,"aria-checked",l=n[19][n[68]]&&!n[11]),h(r,"tabindex","0"),h(r,"class","checkbox-container"),_e(r,"is-enabled",n[19][n[68]]&&!n[11]),h(e,"class","setting-item-control")},m(g,I){_(g,e,I),d&&d.m(e,null),b(e,t),b(e,r),b(r,o),b(r,i),b(r,a),c=!0,u||(f=[$(o,"change",p),$(r,"keypress",m),$(r,"click",y)],u=!0)},p(g,I){n=g,n[11]?d?I[0]&2048&&v(d,1):(d=$w(n),d.c(),v(d,1),d.m(e,t)):d&&(ee(),k(d,1,1,()=>{d=null}),te()),(!c||I[0]&526400&&s!==(s=n[19][n[68]]&&!n[11]))&&(o.checked=s),(!c||I[0]&32)&&(o.disabled=n[5]),(!c||I[0]&526400&&l!==(l=n[19][n[68]]&&!n[11]))&&h(r,"aria-checked",l),(!c||I[0]&526400)&&_e(r,"is-enabled",n[19][n[68]]&&!n[11])},i(g){c||(v(d),c=!0)},o(g){k(d),c=!1},d(g){g&&w(e),d&&d.d(),u=!1,me(f)}}}function Nw(n){let e,t;return e=new Gt({props:{name:n[69].name,description:n[69].description,$$slots:{default:[NE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&64&&(s.name=r[69].name),o[0]&64&&(s.description=r[69].description),o[0]&526432|o[2]&32768&&(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 Bw(n){let e,t;return e=new Gt({props:{name:"",$$slots:{default:[BE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&65536|o[2]&32768&&(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 BE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Buy storage",h(e,"class","mod-cta")},m(o,s){_(o,e,s),t||(r=$(e,"click",function(){Je((0,Eo.debounce)(n[61]))&&(0,Eo.debounce)(n[61]).apply(this,arguments)}),t=!0)},p(o,s){n=o},d(o){o&&w(e),t=!1,r()}}}function VE(n){let e,t,r,o,s=n[3]!==n[10].name&&Ow(n),i=he(n[6]),a=[];for(let u=0;u<i.length;u+=1)a[u]=Nw(kw(n,i,u));let l=u=>k(a[u],1,1,()=>{a[u]=null}),c=n[11]&&n[16]&&Bw(n);return{c(){s&&s.c(),e=T();for(let u=0;u<a.length;u+=1)a[u].c();t=T(),c&&c.c(),r=ue()},m(u,f){s&&s.m(u,f),_(u,e,f);for(let d=0;d<a.length;d+=1)a[d]&&a[d].m(u,f);_(u,t,f),c&&c.m(u,f),_(u,r,f),o=!0},p(u,f){if(u[3]!==u[10].name?s?(s.p(u,f),f[0]&1032&&v(s,1)):(s=Ow(u),s.c(),v(s,1),s.m(e.parentNode,e)):s&&(ee(),k(s,1,1,()=>{s=null}),te()),f[0]&526432|f[1]&2){i=he(u[6]);let d;for(d=0;d<i.length;d+=1){let p=kw(u,i,d);a[d]?(a[d].p(p,f),v(a[d],1)):(a[d]=Nw(p),a[d].c(),v(a[d],1),a[d].m(t.parentNode,t))}for(ee(),d=i.length;d<a.length;d+=1)l(d);te()}u[11]&&u[16]?c?(c.p(u,f),f[0]&67584&&v(c,1)):(c=Bw(u),c.c(),v(c,1),c.m(r.parentNode,r)):c&&(ee(),k(c,1,1,()=>{c=null}),te())},i(u){if(!o){v(s);for(let f=0;f<i.length;f+=1)v(a[f]);v(c),o=!0}},o(u){k(s),a=a.filter(Boolean);for(let f=0;f<a.length;f+=1)k(a[f]);k(c),o=!1},d(u){u&&(w(e),w(t),w(r)),s&&s.d(u),ze(a,u),c&&c.d(u)}}}function Vw(n){let e,t,r,o;return e=new Qe({props:{name:"Danger zone"}}),r=new vt({props:{$$slots:{default:[zE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment)},m(s,i){A(e,s,i),_(s,t,i),A(r,s,i),o=!0},p(s,i){let a={};i[0]&3212289|i[2]&32768&&(a.$$scope={dirty:i,ctx:s}),r.$set(a)},i(s){o||(v(e.$$.fragment,s),v(r.$$.fragment,s),o=!0)},o(s){k(e.$$.fragment,s),k(r.$$.fragment,s),o=!1},d(s){s&&w(t),F(e,s),F(r,s)}}}function Hw(n){let e,t,r,o=n[21]&&qw(n),s=n[20]&&zw(n);return{c(){o&&o.c(),e=T(),s&&s.c(),t=ue()},m(i,a){o&&o.m(i,a),_(i,e,a),s&&s.m(i,a),_(i,t,a),r=!0},p(i,a){i[21]?o?(o.p(i,a),a[0]&2097152&&v(o,1)):(o=qw(i),o.c(),v(o,1),o.m(e.parentNode,e)):o&&(ee(),k(o,1,1,()=>{o=null}),te()),i[20]?s?(s.p(i,a),a[0]&1048576&&v(s,1)):(s=zw(i),s.c(),v(s,1),s.m(t.parentNode,t)):s&&(ee(),k(s,1,1,()=>{s=null}),te())},i(i){r||(v(o),v(s),r=!0)},o(i){k(o),k(s),r=!1},d(i){i&&(w(e),w(t)),o&&o.d(i),s&&s.d(i)}}}function qw(n){var o,s;let e,t,r=!((o=n[0])!=null&&o.private)&&((s=n[0])==null?void 0:s.relay.version)>0&&jw(n);return{c(){r&&r.c(),e=ue()},m(i,a){r&&r.m(i,a),_(i,e,a),t=!0},p(i,a){var l,c;!((l=i[0])!=null&&l.private)&&((c=i[0])==null?void 0:c.relay.version)>0?r?(r.p(i,a),a[0]&1&&v(r,1)):(r=jw(i),r.c(),v(r,1),r.m(e.parentNode,e)):r&&(ee(),k(r,1,1,()=>{r=null}),te())},i(i){t||(v(r),t=!0)},o(i){k(r),t=!1},d(i){i&&w(e),r&&r.d(i)}}}function jw(n){let e,t;return e=new Re({props:{name:"Make private",description:"Convert this folder to a private folder and manage access",$$slots:{default:[HE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[2]&32768&&(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 HE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Make private",h(e,"class","mod-destructive")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,Eo.debounce)(n[44])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function zw(n){let e,t;return e=new Re({props:{name:"Remove from Relay Server",description:"Deletes the remote folder from the Relay Server. Local files will be preserved.",$$slots:{default:[qE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[2]&32768&&(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 qE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Delete from Relay Server",h(e,"class","mod-destructive")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,Eo.debounce)(n[41])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function Ww(n){let e,t;return e=new Re({props:{name:"Delete from vault",description:"Delete the local Shared Folder and all of its contents.",$$slots:{default:[jE]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[2]&32768&&(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 jE(n){let e,t,r;return{c(){e=x("button"),e.textContent="Move to trash",h(e,"class","mod-warning")},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,Eo.debounce)(n[62])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function zE(n){let e,t,r,o=n[16]&&Hw(n),s=n[10]&&Ww(n);return{c(){o&&o.c(),e=T(),s&&s.c(),t=ue()},m(i,a){o&&o.m(i,a),_(i,e,a),s&&s.m(i,a),_(i,t,a),r=!0},p(i,a){i[16]?o?(o.p(i,a),a[0]&65536&&v(o,1)):(o=Hw(i),o.c(),v(o,1),o.m(e.parentNode,e)):o&&(ee(),k(o,1,1,()=>{o=null}),te()),i[10]?s?(s.p(i,a),a[0]&1024&&v(s,1)):(s=Ww(i),s.c(),v(s,1),s.m(t.parentNode,t)):s&&(ee(),k(s,1,1,()=>{s=null}),te())},i(i){r||(v(o),v(s),r=!0)},o(i){k(o),k(s),r=!1},d(i){i&&(w(e),w(t)),o&&o.d(i),s&&s.d(i)}}}function WE(n){let e,t,r,o,s,i,a,l,c,u,f,d,p;e=new Ao({props:{items:[{type:"home",onClick:n[53]},{type:"relay",relay:n[2].relay,onClick:n[54]},{type:"remoteFolder",remoteFolder:{...n[2],name:n[3],private:n[7]}}]}});let m=n[12]&&!n[13]&&Lw(n),y=n[14]&&Mw(n),g=!n[10]&&n[13]&&Tw(n),I=n[16]&&Aw(n),L=n[10]&&n[19]&&n[16]&&Uw(n),C=(n[20]||n[21]||n[10])&&Vw(n);return{c(){P(e.$$.fragment),t=T(),m&&m.c(),r=T(),y&&y.c(),o=T(),g&&g.c(),s=T(),I&&I.c(),i=T(),a=x("div"),l=T(),L&&L.c(),c=T(),u=x("div"),f=T(),C&&C.c(),d=ue(),h(a,"class","spacer svelte-fmnezc"),h(u,"class","spacer svelte-fmnezc")},m(S,M){A(e,S,M),_(S,t,M),m&&m.m(S,M),_(S,r,M),y&&y.m(S,M),_(S,o,M),g&&g.m(S,M),_(S,s,M),I&&I.m(S,M),_(S,i,M),_(S,a,M),_(S,l,M),L&&L.m(S,M),_(S,c,M),_(S,u,M),_(S,f,M),C&&C.m(S,M),_(S,d,M),p=!0},p(S,M){let E={};M[0]&140&&(E.items=[{type:"home",onClick:S[53]},{type:"relay",relay:S[2].relay,onClick:S[54]},{type:"remoteFolder",remoteFolder:{...S[2],name:S[3],private:S[7]}}]),e.$set(E),S[12]&&!S[13]?m||(m=Lw(S),m.c(),m.m(r.parentNode,r)):m&&(m.d(1),m=null),S[14]?y?(y.p(S,M),M[0]&16384&&v(y,1)):(y=Mw(S),y.c(),v(y,1),y.m(o.parentNode,o)):y&&(ee(),k(y,1,1,()=>{y=null}),te()),!S[10]&&S[13]?g?(g.p(S,M),M[0]&9216&&v(g,1)):(g=Tw(S),g.c(),v(g,1),g.m(s.parentNode,s)):g&&(ee(),k(g,1,1,()=>{g=null}),te()),S[16]?I?(I.p(S,M),M[0]&65536&&v(I,1)):(I=Aw(S),I.c(),v(I,1),I.m(i.parentNode,i)):I&&(ee(),k(I,1,1,()=>{I=null}),te()),S[10]&&S[19]&&S[16]?L?(L.p(S,M),M[0]&590848&&v(L,1)):(L=Uw(S),L.c(),v(L,1),L.m(c.parentNode,c)):L&&(ee(),k(L,1,1,()=>{L=null}),te()),S[20]||S[21]||S[10]?C?(C.p(S,M),M[0]&3146752&&v(C,1)):(C=Vw(S),C.c(),v(C,1),C.m(d.parentNode,d)):C&&(ee(),k(C,1,1,()=>{C=null}),te())},i(S){p||(v(e.$$.fragment,S),v(y),v(g),v(I),v(L),v(C),p=!0)},o(S){k(e.$$.fragment,S),k(y),k(g),k(I),k(L),k(C),p=!1},d(S){S&&(w(t),w(r),w(o),w(s),w(i),w(a),w(l),w(c),w(u),w(f),w(d)),F(e,S),m&&m.d(S),y&&y.d(S),g&&g.d(S),I&&I.d(S),L&&L.d(S),C&&C.d(S)}}}function KE(n,e){var t,r;let o={Owner:0,Member:1,Reader:2};return((t=o[n.name])!==null&&t!==void 0?t:999)-((r=o[e.name])!==null&&r!==void 0?r:999)}function GE(n){if(/[\\:*?"<>|]/.test(n))return!1;let t=n.split("/");for(let r of t)if(r===""||r==="."||r==="..")return!1;return!0}function JE(n,e,t){let r,o,s,i,a,l,c,u=B,f=()=>(u(),u=Dt(O,ie=>t(2,c=ie)),O),d,p=B,m=()=>(p(),p=Dt(q,ie=>t(64,d=ie)),q),y,g,I,L,C,S,M,E,U,K;n.$$.on_destroy.push(()=>u()),n.$$.on_destroy.push(()=>p());let{plugin:R}=e,{remoteFolder:O}=e;f();let{sharedFolders:q}=e;m();let{relayRoles:H}=e,{folderRoles:G}=e,ce=O.name,{errorLog:N=Te("ManageRemoveFolder.svelte","error")}=e;R.relayManager.refreshRemoteFolder(O);let X=et([H],([ie])=>{var Ne;return(Ne=ie.find(gt=>gt.relayId===c.relayId))===null||Ne===void 0?void 0:Ne.relay});ne(n,X,ie=>t(16,C=ie));let Me=et(d,ie=>ie.items().find(Ne=>Ne.guid===O.guid));ne(n,Me,ie=>t(10,a=ie));let Ie=et([R.relayManager.roles],([ie])=>ie.values().sort(KE));ne(n,Ie,ie=>t(18,M=ie));let D=et([G,H],([ie,Ne])=>{if(c.private){let xt=[];for(let Zt of ie.values())Zt.sharedFolderId===c.id&&Ne.some(Pr=>Pr.userId===Zt.userId)&&xt.push(Zt);return xt}let gt=[];for(let xt of Ne.values())xt.relayId===c.relayId&>.push(xt);return gt});ne(n,D,ie=>t(9,i=ie));let Q=ge(!1);ne(n,Q,ie=>t(17,S=ie));let de=ge(!0);ne(n,de,ie=>t(8,s=ie));let Le,Ae=ge(!1);ne(n,Ae,ie=>t(15,L=ie));let re=O.name;st(()=>{Le&&Le.value===""&&Le.focus()});function Z(ie){return Ce(this,void 0,void 0,function*(){var Ne;if(!(!((Ne=R.loginManager)===null||Ne===void 0)&&Ne.user))return;let gt={relay:ie.id,quantity:10,user_email:R.loginManager.user.email},xt=btoa(JSON.stringify(gt)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");window.open(R.buildApiUrl(`/subscribe/${xt}?action="buy_storage"`),"_blank")})}let Se=a==null?void 0:a.syncSettingsManager;ne(n,Se,ie=>t(19,E=ie));let ae=et([Me,H],([ie,Ne])=>{var gt,xt,Zt;return((Zt=(xt=(gt=Ne.find(Pr=>{var ss;return Pr.relay===((ss=ie==null?void 0:ie.remote)===null||ss===void 0?void 0:ss.relay)}))===null||gt===void 0?void 0:gt.relay)===null||xt===void 0?void 0:xt.storageQuota)===null||Zt===void 0?void 0:Zt.quota)===0});ne(n,ae,ie=>t(11,l=ie));let Pe=!1;function De(ie,Ne){return Ce(this,void 0,void 0,function*(){if(!Pe&&!l&&Se){t(5,Pe=!0);try{yield Se.toggleCategory(ie,Ne),t(6,o=Object.entries(Se.getCategories()))}catch(gt){}finally{t(5,Pe=!1)}}})}let Ge=Xe(),mt=R.relayManager.userCan(["folder","read_content"],O);ne(n,mt,ie=>t(13,g=ie));let _t=R.relayManager.userCan(["folder","rename"],O);ne(n,_t,ie=>t(14,I=ie));let zr=R.relayManager.userCan(["folder","delete"],O);ne(n,zr,ie=>t(20,U=ie));let co=R.relayManager.userCan(["folder","manage_users"],O);ne(n,co,ie=>t(12,y=ie));let Fr=R.relayManager.userCan(["folder","make_private"],O);ne(n,Fr,ie=>t(21,K=ie));function xr(ie){ie&&Ge("manageRelay",{relay:ie})}function Rt(){return Ce(this,void 0,void 0,function*(){a&&R.sharedFolders.delete(a),Ge("goBack",{clear:!0})})}function It(){if(a){let ie=R.vault.getFolderByPath(a.path);ie&&R.app.vault.trash(ie,!1)}}function Tn(){return Ce(this,void 0,void 0,function*(){try{if(yield R.relayManager.deleteRemote(O),a){Ws(Me,a.remote=void 0,a),R.sharedFolders.notifyListeners(),Ge("manageSharedFolder",{folder:a});return}}catch(ie){N("Failed to delete remote folder:",ie)}Ge("goBack",{})})}function Xo(ie){(ie instanceof MouseEvent||ie instanceof KeyboardEvent&&(ie.key==="Enter"||ie.key===" "))&&Q.update(Ne=>!Ne)}function Po(ie){return Ce(this,void 0,void 0,function*(){try{yield R.relayManager.removeFolderRole(ie)}catch(Ne){tr(Ne,"Failed to remove user from folder.")}})}function en(){return Ce(this,void 0,void 0,function*(){try{let ie=yield R.relayManager.updateFolderPrivacy(O,!0);Wr()}catch(ie){tr(ie,"Failed to make folder private. Permission denied.")}})}function Wr(){new Jc(R.app,R.relayManager,O,(Ne,gt)=>Ce(this,void 0,void 0,function*(){try{for(let xt of Ne)yield R.relayManager.addFolderRole(O,xt,gt)}catch(xt){tr(xt,"Failed to add users to folder.")}})).open()}function tn(ie,Ne){return Ce(this,void 0,void 0,function*(){try{yield R.relayManager.updateFolderRole(ie,Ne)}catch(gt){throw tr(gt,"Failed to change user role."),gt}})}function ns(ie){return Ce(this,void 0,void 0,function*(){let Ne=ie.target,gt=i.find(xt=>xt.id===Ne.dataset.roleId);if(gt){let xt=gt.role;try{yield tn(gt,Ne.value)}catch(Zt){Ne.value=xt}}})}function Er(){return Ce(this,void 0,void 0,function*(){function ie(Ne,gt,xt){return Ce(this,void 0,void 0,function*(){let Zt=(0,Kw.normalizePath)((0,Gw.join)(xt,gt));R.vault.getFolderByPath(Zt)===null&&(yield R.vault.createFolder(Zt));let Pr=R.sharedFolders.new(Zt,Ne.guid,Ne.relay.guid,!0);return Pr.remote=Ne,R.sharedFolders.notifyListeners(),Ge("manageRemoteFolder",{remoteFolder:Ne}),Pr})}new Mn(R.app,R.sharedFolders,O,[],ie).open()})}let pe=R.timeProvider.debounce(ie=>Ce(void 0,void 0,void 0,function*(){try{let Ne=yield R.relayManager.updateRemoteFolder(O,{name:ie});re=Ne.name,t(3,ce=Ne.name),Ae.set(!1)}catch(Ne){N("Failed to update folder name:",Ne),(Ne==null?void 0:Ne.status)===400&&de.set(!1),Ae.set(!1)}}),500);function qe(){de.set(GE(Le.value));let ie=Le.value.trim();s&&ie!==""&&ie!==re&&(Ae.set(!0),pe(ie))}let rt=()=>Ge("goBack",{clear:!0}),rr=()=>xr(c.relay);function rn(){ce=this.value,t(3,ce)}function oe(ie){pt[ie?"unshift":"push"](()=>{Le=ie,t(4,Le)})}let Ue=ie=>{"sharedFolder"in ie&&Po(ie)},ht=(ie,Ne)=>De(ie,Ne.currentTarget.checked),uo=ie=>De(ie,!E[ie]),wr=ie=>De(ie,!E[ie]),lu=()=>{Z(C)},ha=()=>{It()};return n.$$set=ie=>{"plugin"in ie&&t(49,R=ie.plugin),"remoteFolder"in ie&&f(t(0,O=ie.remoteFolder)),"sharedFolders"in ie&&m(t(1,q=ie.sharedFolders)),"relayRoles"in ie&&t(50,H=ie.relayRoles),"folderRoles"in ie&&t(51,G=ie.folderRoles),"errorLog"in ie&&t(52,N=ie.errorLog)},n.$$.update=()=>{n.$$.dirty[0]&4&&t(7,r=(c==null?void 0:c.private)||!1)},t(6,o=Se?Object.entries(Se.getCategories()):[]),[O,q,c,ce,Le,Pe,o,r,s,i,a,l,y,g,I,L,C,S,M,E,U,K,X,Me,Ie,D,Q,de,Ae,Z,Se,ae,De,Ge,mt,_t,zr,co,Fr,xr,It,Tn,Xo,Po,en,Wr,ns,Er,qe,R,H,G,N,rt,rr,rn,oe,Ue,ht,uo,wr,lu,ha]}var eh=class extends z{constructor(e){super(),W(this,e,JE,WE,j,{plugin:49,remoteFolder:0,sharedFolders:1,relayRoles:50,folderRoles:51,errorLog:52},IE,[-1,-1,-1])}},Yc=eh;function YE(n){we(n,"svelte-gjlxvj",".toast.svelte-gjlxvj.svelte-gjlxvj{position:absolute;top:20px;left:50%;transform:translateX(-50%);display:flex;align-items:flex-start;gap:12px;padding:12px 16px;border-radius:8px;border:1px solid;background:var(--background-primary);color:var(--text-normal);box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);min-height:48px;max-width:500px;min-width:300px;width:max-content;animation:svelte-gjlxvj-slideDown 0.3s ease-out;pointer-events:auto}.toast-error.svelte-gjlxvj.svelte-gjlxvj{border-color:var(--text-error)}.toast-warning.svelte-gjlxvj.svelte-gjlxvj{border-color:var(--text-warning)}.toast-success.svelte-gjlxvj.svelte-gjlxvj{border-color:var(--text-success, #4caf50)}.toast-info.svelte-gjlxvj.svelte-gjlxvj{border-color:var(--interactive-accent)}@keyframes svelte-gjlxvj-slideDown{from{opacity:0;transform:translateX(-50%) translateY(-10px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}.toast-icon.svelte-gjlxvj.svelte-gjlxvj{display:flex;align-items:center;flex-shrink:0;margin-top:1px}.toast-error.svelte-gjlxvj .toast-icon.svelte-gjlxvj{color:var(--text-error)}.toast-warning.svelte-gjlxvj .toast-icon.svelte-gjlxvj{color:var(--text-warning)}.toast-success.svelte-gjlxvj .toast-icon.svelte-gjlxvj{color:var(--text-success, #4caf50)}.toast-info.svelte-gjlxvj .toast-icon.svelte-gjlxvj{color:var(--interactive-accent)}.toast-content.svelte-gjlxvj.svelte-gjlxvj{flex:1;min-width:0}.toast-message.svelte-gjlxvj.svelte-gjlxvj{font-weight:500;margin-bottom:2px;line-height:1.4;color:var(--text-normal)}.toast-details.svelte-gjlxvj.svelte-gjlxvj{font-size:0.9em;color:var(--text-muted);line-height:1.3}.toast-dismiss.svelte-gjlxvj.svelte-gjlxvj{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border:none;background:transparent;border-radius:4px;cursor:pointer;color:var(--text-muted);transition:all 0.15s ease-in-out;padding:0;flex-shrink:0}.toast-dismiss.svelte-gjlxvj.svelte-gjlxvj:hover{background:var(--background-modifier-hover);color:var(--text-error)}.toast-dismiss.svelte-gjlxvj.svelte-gjlxvj:focus{outline:2px solid var(--interactive-accent);outline-offset:1px}")}function Jw(n){let e,t;return{c(){e=x("div"),t=V(n[1]),h(e,"class","toast-details svelte-gjlxvj")},m(r,o){_(r,e,o),b(e,t)},p(r,o){o&2&&J(t,r[1])},d(r){r&&w(e)}}}function QE(n){let e,t,r,o,s,i,a,l,c,u,f,d,p,m,y;var g=n[3];function I(C,S){return{props:{class:"svg-icon"}}}g&&(r=Gs(g,I(n)));let L=n[1]&&Jw(n);return f=new Xs({props:{class:"svg-icon"}}),{c(){e=x("div"),t=x("div"),r&&P(r.$$.fragment),o=T(),s=x("div"),i=x("div"),a=V(n[0]),l=T(),L&&L.c(),c=T(),u=x("button"),P(f.$$.fragment),h(t,"class","toast-icon svelte-gjlxvj"),h(i,"class","toast-message svelte-gjlxvj"),h(s,"class","toast-content svelte-gjlxvj"),h(u,"class","toast-dismiss svelte-gjlxvj"),h(u,"aria-label","Dismiss error"),h(e,"class",d=Tt(n[2])+" svelte-gjlxvj"),h(e,"role","alert"),h(e,"aria-live","polite")},m(C,S){_(C,e,S),b(e,t),r&&A(r,t,null),b(e,o),b(e,s),b(s,i),b(i,a),b(s,l),L&&L.m(s,null),b(e,c),b(e,u),A(f,u,null),p=!0,m||(y=$(u,"click",n[4]),m=!0)},p(C,[S]){if(S&8&&g!==(g=C[3])){if(r){ee();let M=r;k(M.$$.fragment,1,0,()=>{F(M,1)}),te()}g?(r=Gs(g,I(C,S)),P(r.$$.fragment),v(r.$$.fragment,1),A(r,t,null)):r=null}(!p||S&1)&&J(a,C[0]),C[1]?L?L.p(C,S):(L=Jw(C),L.c(),L.m(s,null)):L&&(L.d(1),L=null),(!p||S&4&&d!==(d=Tt(C[2])+" svelte-gjlxvj"))&&h(e,"class",d)},i(C){p||(r&&v(r.$$.fragment,C),v(f.$$.fragment,C),p=!0)},o(C){r&&k(r.$$.fragment,C),k(f.$$.fragment,C),p=!1},d(C){C&&w(e),r&&F(r),L&&L.d(),F(f),m=!1,y()}}}function ZE(n,e,t){let r,o,{message:s}=e,{details:i=""}=e,{type:a="error"}=e,{autoDismiss:l=5e3}=e,c=Xe(),u;st(()=>(l>0&&(u=window.setTimeout(()=>{c("dismiss")},l)),()=>{u&&clearTimeout(u)}));function f(){u&&clearTimeout(u),c("dismiss")}return n.$$set=d=>{"message"in d&&t(0,s=d.message),"details"in d&&t(1,i=d.details),"type"in d&&t(5,a=d.type),"autoDismiss"in d&&t(6,l=d.autoDismiss)},n.$$.update=()=>{n.$$.dirty&32&&t(3,r=a==="error"?kp:a==="warning"?tp:a==="success"?op:pp),n.$$.dirty&32&&t(2,o=`toast toast-${a}`)},[s,i,o,r,f,a,l]}var th=class extends z{constructor(e){super(),W(this,e,ZE,QE,j,{message:0,details:1,type:5,autoDismiss:6},YE)}},Yw=th;function XE(n){we(n,"svelte-ml1z9c",".toast-container.svelte-ml1z9c{position:fixed;top:0;left:0;width:100vw;height:0;pointer-events:none;z-index:1000}")}function Qw(n,e,t){let r=n.slice();return r[3]=e[t][0],r[4]=e[t][1],r}function Zw(n,e){let t,r,o;function s(){return e[2](e[3])}return r=new Yw({props:{message:e[4].message,details:e[4].details,type:e[4].type,autoDismiss:e[4].autoDismiss,source:e[4].source}}),r.$on("dismiss",s),{key:n,first:null,c(){t=ue(),P(r.$$.fragment),this.first=t},m(i,a){_(i,t,a),A(r,i,a),o=!0},p(i,a){e=i;let l={};a&1&&(l.message=e[4].message),a&1&&(l.details=e[4].details),a&1&&(l.type=e[4].type),a&1&&(l.autoDismiss=e[4].autoDismiss),a&1&&(l.source=e[4].source),r.$set(l)},i(i){o||(v(r.$$.fragment,i),o=!0)},o(i){k(r.$$.fragment,i),o=!1},d(i){i&&w(t),F(r,i)}}}function eP(n){let e,t=[],r=new Map,o,s=he(n[0]),i=a=>a[3];for(let a=0;a<s.length;a+=1){let l=Qw(n,s,a),c=i(l);r.set(c,t[a]=Zw(c,l))}return{c(){e=x("div");for(let a=0;a<t.length;a+=1)t[a].c();h(e,"class","toast-container svelte-ml1z9c")},m(a,l){_(a,e,l);for(let c=0;c<t.length;c+=1)t[c]&&t[c].m(e,null);o=!0},p(a,[l]){l&1&&(s=he(a[0]),ee(),t=qr(t,l,i,1,a,s,r,e,Gn,Zw,null,Qw),te())},i(a){if(!o){for(let l=0;l<s.length;l+=1)v(t[l]);o=!0}},o(a){for(let l=0;l<t.length;l+=1)k(t[l]);o=!1},d(a){a&&w(e);for(let l=0;l<t.length;l+=1)t[l].d()}}}function tP(n,e,t){let r,o;ne(n,zc,i=>t(1,o=i));let s=i=>Ux(i);return n.$$.update=()=>{n.$$.dirty&2&&t(0,r=Object.entries(o).filter(([i,a])=>a.visible))},[r,o,s]}var rh=class extends z{constructor(e){super(),W(this,e,tP,eP,j,{},XE)}},Xw=rh;var t_=require("obsidian");function rP(n){we(n,"svelte-d22j3",".relay-version.svelte-d22j3{user-select:auto;background:var(--color-base-10);color:var(--text-faint);position:absolute;bottom:0;right:0;font-size:xx-small;padding-right:1em;padding-top:0.3em;padding-left:1em;border-top-left-radius:1em}.vertical-tab-content.svelte-d22j3{max-height:var(--modal-max-height);position:relative}")}function oP(n){let e,t;return e=new $c({props:{plugin:n[0]}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.plugin=r[0]),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 nP(n){let e,t;return e=new yw({}),e.$on("goBack",n[14]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p:B,i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function sP(n){let e,t;return e=new Nv({props:{plugin:n[0],$$slots:{default:[cP]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.plugin=r[0]),o&16777217&&(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 iP(n){let e,t;return e=new li({props:{plugin:n[0],relayRoles:n[5],relay:n[2],sharedFolders:n[9]}}),e.$on("goBack",n[14]),e.$on("close",n[15]),e.$on("manageSharedFolder",n[11]),e.$on("manageRemoteFolder",n[12]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.plugin=r[0]),o&4&&(s.relay=r[2]),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 aP(n){let e,t;return e=new Gc({props:{plugin:n[0],sharedFolder:n[1]}}),e.$on("goBack",n[14]),e.$on("close",n[15]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.plugin=r[0]),o&2&&(s.sharedFolder=r[1]),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 lP(n){let e,t;return e=new Yc({props:{plugin:n[0],remoteFolder:n[3],sharedFolders:n[9],relayRoles:n[5],folderRoles:n[4].folderRoles}}),e.$on("goBack",n[14]),e.$on("close",n[15]),e.$on("manageRelay",n[10]),e.$on("manageSharedFolder",n[11]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.plugin=r[0]),o&8&&(s.remoteFolder=r[3]),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 cP(n){let e,t;return e=new Fo({props:{relays:n[6],subscriptions:n[7],providers:n[8],plugin:n[0]}}),e.$on("manageRelay",n[10]),e.$on("manageSharedFolder",n[11]),e.$on("manageRemoteFolder",n[12]),e.$on("createRelay",n[13]),e.$on("joinRelay",n[16]),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&1&&(s.plugin=r[0]),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 uP(n){let e,t;return e=new Xw({}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},i(r){t||(v(e.$$.fragment,r),t=!0)},o(r){k(e.$$.fragment,r),t=!1},d(r){F(e,r)}}}function e_(n){let e,t=n[0].version+"",r;return{c(){e=x("span"),r=V(t),h(e,"class","relay-version svelte-d22j3")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s&1&&t!==(t=o[0].version+"")&&J(r,t)},d(o){o&&w(e)}}}function fP(n){let e,t,r,o,s,i,a,l=He().enableToasts,c,u,f,d=[nP,oP],p=[];function m(S,M){return S[2]||S[1]||S[3]?0:t_.Platform.isMobile?-1:1}~(e=m(n,-1))&&(t=p[e]=d[e](n));let y=[lP,aP,iP,sP],g=[];function I(S,M){return S[3]?0:S[1]?1:S[2]?2:3}s=I(n,-1),i=g[s]=y[s](n);let L=l&&uP(n),C=n[0].manifest.version!==n[0].version&&e_(n);return{c(){t&&t.c(),r=T(),o=x("div"),i.c(),a=T(),L&&L.c(),c=T(),C&&C.c(),u=ue(),h(o,"class","vertical-tab-content svelte-d22j3")},m(S,M){~e&&p[e].m(S,M),_(S,r,M),_(S,o,M),g[s].m(o,null),_(S,a,M),L&&L.m(S,M),_(S,c,M),C&&C.m(S,M),_(S,u,M),f=!0},p(S,[M]){let E=e;e=m(S,M),e===E?~e&&p[e].p(S,M):(t&&(ee(),k(p[E],1,1,()=>{p[E]=null}),te()),~e?(t=p[e],t?t.p(S,M):(t=p[e]=d[e](S),t.c()),v(t,1),t.m(r.parentNode,r)):t=null);let U=s;s=I(S,M),s===U?g[s].p(S,M):(ee(),k(g[U],1,1,()=>{g[U]=null}),te(),i=g[s],i?i.p(S,M):(i=g[s]=y[s](S),i.c()),v(i,1),i.m(o,null)),S[0].manifest.version!==S[0].version?C?C.p(S,M):(C=e_(S),C.c(),C.m(u.parentNode,u)):C&&(C.d(1),C=null)},i(S){f||(v(t),v(i),v(L),f=!0)},o(S){k(t),k(i),k(L),f=!1},d(S){S&&(w(r),w(o),w(a),w(c),w(u)),~e&&p[e].d(S),g[s].d(),L&&L.d(S),C&&C.d(S)}}}function dP(n,e,t){let r,{plugin:o}=e,{path:s=void 0}=e,i=o.app,a=o.relayManager,l=a.relayRoles,c=a.relays;ne(n,c,q=>t(20,r=q));let u=a.subscriptions,f=a.providers,d=o.sharedFolders,p,m=Fo,y,g,I=[{component:Fo}],{close:L}=e;function C(q){if(t(2,y=void 0),t(1,p=void 0),t(3,g=void 0),q==="/"){t(19,m=Fo);return}let H=new URLSearchParams(q.split("?")[1]||""),G=H.get("id");if(q.startsWith("/relays")){G?(t(2,y=a.relays.find(ce=>ce.guid===G||ce.id===G)),t(19,m=li)):t(19,m=Fo);return}if(q.startsWith("/shared-folders")){if(G){t(1,p=d.find(N=>N.guid===G));let ce=H.get("relay");ce&&t(2,y=a.relays.find(N=>N.guid===ce||N.id===ce)),p!=null&&p.remote?(t(3,g=p.remote),t(2,y=p.remote.relay),t(19,m=Yc)):t(19,m=Gc)}return}}function S(q){I.push({currentRelay:y,sharedFolder:p,remoteFolder:g,component:m}),t(2,y=q.detail.relay),t(1,p=void 0),t(3,g=void 0),t(19,m=li)}function M(q){I.push({currentRelay:y,sharedFolder:p,remoteFolder:g,component:m}),t(1,p=q.detail.folder),t(3,g=q.detail.remoteFolder),t(2,y=q.detail.relay),t(19,m=Gc)}function E(q){I.push({currentRelay:y,sharedFolder:p,remoteFolder:g,component:m}),t(1,p=void 0),t(3,g=q.detail.remoteFolder),t(2,y=q.detail.relay),t(19,m=Yc)}function U(q){return Ce(this,void 0,void 0,function*(){try{I.push({currentRelay:y,sharedFolder:p,remoteFolder:g,component:m}),t(2,y=yield o.relayManager.createRelay("")),t(19,m=li)}catch(H){tr(H,"Failed to create relay")}})}function K(q){if(q.detail.clear){I.length=0,t(2,y=void 0),t(1,p=void 0),t(3,g=void 0),t(19,m=Fo);return}let H=I.pop();if(H)for(;H;){if(!H.currentRelay&&!H.sharedFolder&&!H.remoteFolder)t(2,y=H.currentRelay),t(1,p=H.sharedFolder),t(3,g=H.remoteFolder),t(19,m=H.component);else if(H.sharedFolder&&d.has(H.sharedFolder)){t(2,y=H.currentRelay),t(1,p=H.sharedFolder),t(3,g=H.remoteFolder),t(19,m=H.component);break}else if(H.remoteFolder){t(2,y=H.currentRelay),t(1,p=H.sharedFolder),t(3,g=H.remoteFolder),t(19,m=H.component);break}else if(H.currentRelay&&a.relays.get(H.currentRelay.id)){t(2,y=H.currentRelay),t(1,p=H.sharedFolder),t(3,g=H.remoteFolder),t(19,m=H.component);break}H=I.pop()}else t(2,y=void 0),t(1,p=void 0),t(3,g=void 0),t(19,m=Fo)}function R(q){I.length=0,L()}function O(q){t(2,y=q.detail.relay),t(19,m=li)}return n.$$set=q=>{"plugin"in q&&t(0,o=q.plugin),"path"in q&&t(17,s=q.path),"close"in q&&t(18,L=q.close)},n.$$.update=()=>{n.$$.dirty&131072&&s&&C(s),n.$$.dirty&1048580&&y&&!r.has(y.id)&&(t(2,y=void 0),t(19,m=Fo)),n.$$.dirty&2&&p&&!d.has(p)&&(t(1,p=void 0),t(3,g=void 0),t(19,m=Fo)),n.$$.dirty&524302&&(m||y||p||g)&&setTimeout(()=>{let q=document.querySelector(".vertical-tab-content");q&&(q.scrollTop=0)},0)},[o,p,y,g,a,l,c,u,f,d,S,M,E,U,K,R,O,s,L,m,r]}var oh=class extends z{constructor(e){super(),W(this,e,dP,fP,j,{plugin:0,path:17,close:18},rP)}},r_=oh;var Qc=class extends o_.PluginSettingTab{constructor(e,t){super(e,t),this.plugin=t}display(){let{containerEl:e}=this;this.targetEl=e.parentElement,this.targetEl.empty(),this.plugin.relayManager.update(),this.component=new r_({target:this.targetEl,props:{plugin:this.plugin,close:()=>{this.setting.close()}}})}navigateTo(e){var t;(t=this.component)==null||t.$set({path:e})}hide(){var e;try{(e=this.component)==null||e.$destroy()}catch(t){console.warn(t)}}destroy(){this.hide(),this.plugin=null}};var f_=require("obsidian");function pP(n){we(n,"svelte-74c8lg",".endpoint-config-modal.svelte-74c8lg.svelte-74c8lg{padding:0}.tenant-list-section.svelte-74c8lg.svelte-74c8lg{margin:16px 0}.tenant-card.svelte-74c8lg.svelte-74c8lg{display:flex;align-items:center;justify-content:space-between;padding:12px;margin:8px 0;border:1px solid var(--background-modifier-border);border-radius:var(--radius-s);background:var(--background-primary);cursor:pointer;transition:all 0.2s ease}.tenant-card.svelte-74c8lg.svelte-74c8lg:hover{background:var(--background-modifier-hover)}.tenant-card.active.svelte-74c8lg.svelte-74c8lg{border-color:var(--interactive-accent);background:var(--background-modifier-hover)}.tenant-info.svelte-74c8lg.svelte-74c8lg{display:flex;align-items:center;gap:12px;flex:1}.tenant-logo.svelte-74c8lg.svelte-74c8lg{width:4em;height:4em;object-fit:contain;border-radius:4px;background:var(--background-secondary);padding:4px}.tenant-details.svelte-74c8lg.svelte-74c8lg{flex:1}.tenant-name.svelte-74c8lg.svelte-74c8lg{font-weight:500;color:var(--text-normal);margin-bottom:2px}.tenant-url.svelte-74c8lg.svelte-74c8lg{font-size:0.85em;color:var(--text-muted);font-family:var(--font-monospace)}.tenant-env.svelte-74c8lg.svelte-74c8lg{font-size:0.8em;color:var(--text-faint);text-transform:capitalize}.tenant-actions.svelte-74c8lg.svelte-74c8lg{display:flex;align-items:center;gap:8px}.add-tenant-container.svelte-74c8lg.svelte-74c8lg{display:flex;gap:8px;align-items:center}.endpoint-url-input.svelte-74c8lg.svelte-74c8lg{flex:1;padding:6px 12px;border:1px solid var(--background-modifier-border);border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-normal)}.endpoint-input-invalid.svelte-74c8lg.svelte-74c8lg{border-color:var(--text-error) !important;box-shadow:0 0 0 1px var(--text-error) !important;transition:border-color 0.3s ease, box-shadow 0.3s ease}.endpoint-input-invalid.svelte-74c8lg.svelte-74c8lg:focus{border-color:var(--text-error) !important;box-shadow:0 0 0 2px var(--text-error) !important}.add-tenant-container.svelte-74c8lg button.mod-cta.svelte-74c8lg{background:var(--interactive-accent);color:var(--text-on-accent);padding:6px 12px;white-space:nowrap}.error-banner.svelte-74c8lg.svelte-74c8lg{display:flex;align-items:flex-start;justify-content:space-between;margin:12px 0;padding:10px 12px;background-color:rgba(255, 0, 0, 0.1);color:var(--text-normal);border:1px solid rgba(255, 0, 0, 0.3);border-radius:var(--radius-s);animation:svelte-74c8lg-error-slide-in 0.3s ease-out}.error-content.svelte-74c8lg.svelte-74c8lg{display:flex;align-items:flex-start;gap:8px;flex:1}.error-icon.svelte-74c8lg.svelte-74c8lg{font-size:1em;line-height:1.2;margin-top:2px}.error-text.svelte-74c8lg.svelte-74c8lg{font-size:0.85em;line-height:1.4;color:var(--text-normal)}.error-dismiss.svelte-74c8lg.svelte-74c8lg{background:none;border:none;color:var(--text-muted);font-size:1.2em;font-weight:normal;cursor:pointer;padding:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center;transition:opacity 0.2s ease;opacity:0.6}.error-dismiss.svelte-74c8lg.svelte-74c8lg:hover{opacity:1}@keyframes svelte-74c8lg-error-slide-in{0%{opacity:0;transform:translateY(-10px)}100%{opacity:1;transform:translateY(0)}}.apply-section.svelte-74c8lg.svelte-74c8lg{display:flex;justify-content:flex-end;margin-top:20px;padding-top:16px;border-top:1px solid var(--background-modifier-border)}.apply-btn.svelte-74c8lg.svelte-74c8lg{padding:8px 20px;font-size:0.9em}")}function n_(n,e,t){let r=n.slice();return r[32]=e[t],r}function mP(n){let e,t,r,o,s,i=n[5]?"Adding...":"Add Tenant",a,l,c,u;return{c(){e=x("div"),t=x("input"),o=T(),s=x("button"),a=V(i),h(t,"type","text"),h(t,"placeholder","https://auth.example.com"),h(t,"class","endpoint-url-input svelte-74c8lg"),h(t,"title",r=n[6].error),_e(t,"endpoint-input-invalid",!n[6].isValid||n[2]),h(s,"class","mod-cta svelte-74c8lg"),s.disabled=l=n[5]||!n[0].trim()||!n[6].isValid,h(e,"class","add-tenant-container svelte-74c8lg")},m(f,d){_(f,e,d),b(e,t),Ye(t,n[0]),b(e,o),b(e,s),b(s,a),c||(u=[$(t,"input",n[20]),$(s,"click",n[12])],c=!0)},p(f,d){d[0]&64&&r!==(r=f[6].error)&&h(t,"title",r),d[0]&1&&t.value!==f[0]&&Ye(t,f[0]),d[0]&68&&_e(t,"endpoint-input-invalid",!f[6].isValid||f[2]),d[0]&32&&i!==(i=f[5]?"Adding...":"Add Tenant")&&J(a,i),d[0]&97&&l!==(l=f[5]||!f[0].trim()||!f[6].isValid)&&(s.disabled=l)},d(f){f&&w(e),c=!1,me(u)}}}function s_(n){let e,t,r,o,s,i,a,l,c,u;return{c(){e=x("div"),t=x("div"),r=x("span"),r.textContent="\u26A0\uFE0F",o=T(),s=x("span"),i=V(n[1]),a=T(),l=x("button"),l.textContent="\xD7",h(r,"class","error-icon svelte-74c8lg"),h(s,"class","error-text svelte-74c8lg"),h(t,"class","error-content svelte-74c8lg"),h(l,"class","error-dismiss svelte-74c8lg"),h(l,"title","Dismiss error"),h(e,"class","error-banner svelte-74c8lg")},m(f,d){_(f,e,d),b(e,t),b(t,r),b(t,o),b(t,s),b(s,i),b(e,a),b(e,l),c||(u=$(l,"click",n[11]),c=!0)},p(f,d){d[0]&2&&J(i,f[1])},d(f){f&&w(e),c=!1,u()}}}function i_(n){let e,t,r;return{c(){e=x("img"),hr(e.src,t=n[8].logo)||h(e,"src",t),h(e,"alt",r=n[8].customer||"Default Tenant"),h(e,"class","tenant-logo svelte-74c8lg")},m(o,s){_(o,e,s)},p(o,s){s[0]&256&&!hr(e.src,t=o[8].logo)&&h(e,"src",t),s[0]&256&&r!==(r=o[8].customer||"Default Tenant")&&h(e,"alt",r)},d(o){o&&w(e)}}}function a_(n){let e,t,r;return{c(){e=x("img"),hr(e.src,t=n[32].logo)||h(e,"src",t),h(e,"alt",r=n[32].name),h(e,"class","tenant-logo svelte-74c8lg")},m(o,s){_(o,e,s)},p(o,s){s[0]&16&&!hr(e.src,t=o[32].logo)&&h(e,"src",t),s[0]&16&&r!==(r=o[32].name)&&h(e,"alt",r)},d(o){o&&w(e)}}}function l_(n){let e,t=n[32].environment+"",r;return{c(){e=x("div"),r=V(t),h(e,"class","tenant-env svelte-74c8lg")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s[0]&16&&t!==(t=o[32].environment+"")&&J(r,t)},d(o){o&&w(e)}}}function c_(n,e){let t,r,o,s,i,a=e[32].name+"",l,c,u,f=e[32].tenantUrl+"",d,p,m,y,g,I,L,C,S=e[32].logo&&a_(e),M=e[32].environment&&l_(e);function E(){return e[22](e[32])}function U(){return e[23](e[32])}function K(...R){return e[24](e[32],...R)}return{key:n,first:null,c(){t=x("div"),r=x("div"),S&&S.c(),o=T(),s=x("div"),i=x("div"),l=V(a),c=T(),u=x("div"),d=V(f),p=T(),M&&M.c(),m=T(),y=x("div"),g=x("button"),g.textContent="Remove",I=T(),h(i,"class","tenant-name svelte-74c8lg"),h(u,"class","tenant-url svelte-74c8lg"),h(s,"class","tenant-details svelte-74c8lg"),h(r,"class","tenant-info svelte-74c8lg"),h(g,"class","mod-destructive"),h(g,"title","Remove this tenant"),h(y,"class","tenant-actions svelte-74c8lg"),h(t,"class","tenant-card svelte-74c8lg"),h(t,"role","button"),h(t,"tabindex","0"),h(t,"title","Click to switch to this tenant"),_e(t,"active",e[32].id===e[3]),this.first=t},m(R,O){_(R,t,O),b(t,r),S&&S.m(r,null),b(r,o),b(r,s),b(s,i),b(i,l),b(s,c),b(s,u),b(u,d),b(s,p),M&&M.m(s,null),b(t,m),b(t,y),b(y,g),b(t,I),L||(C=[$(g,"click",rc(E)),$(t,"click",U),$(t,"keydown",K)],L=!0)},p(R,O){e=R,e[32].logo?S?S.p(e,O):(S=a_(e),S.c(),S.m(r,o)):S&&(S.d(1),S=null),O[0]&16&&a!==(a=e[32].name+"")&&J(l,a),O[0]&16&&f!==(f=e[32].tenantUrl+"")&&J(d,f),e[32].environment?M?M.p(e,O):(M=l_(e),M.c(),M.m(s,null)):M&&(M.d(1),M=null),O[0]&24&&_e(t,"active",e[32].id===e[3])},d(R){R&&w(t),S&&S.d(),M&&M.d(),L=!1,me(C)}}}function hP(n){var re,Z,Se;let e,t,r,o,s,i=n[1]&&n[1].trim(),a,l,c,u,f,d,p,m,y,g,I=(((re=n[8])==null?void 0:re.customer)||"Default Tenant")+"",L,C,S,M,E,U=(((Z=n[8])==null?void 0:Z.environment)||n[10].environment)+"",K,R,O,q,H=[],G=new Map,ce,N,X,Me,Ie,D;o=new Re({props:{name:"Add Enterprise Tenant",description:"Enter your organization's tenant URL",$$slots:{default:[mP]},$$scope:{ctx:n}}});let Q=i&&s_(n),de=((Se=n[8])==null?void 0:Se.logo)&&i_(n),Le=he(n[4]),Ae=ae=>ae[32].id;for(let ae=0;ae<Le.length;ae+=1){let Pe=n_(n,Le,ae),De=Ae(Pe);G.set(De,H[ae]=c_(De,Pe))}return{c(){e=x("div"),t=x("div"),t.innerHTML="<p>Manage your organization's enterprise Relay tenants. Add tenants to switch between different enterprise deployments.</p>",r=T(),P(o.$$.fragment),s=T(),Q&&Q.c(),a=T(),l=x("div"),c=x("div"),c.textContent="Available Tenants",u=T(),f=x("div"),d=x("div"),p=x("div"),de&&de.c(),m=T(),y=x("div"),g=x("div"),L=V(I),C=T(),S=x("div"),S.textContent=`${n[10].authUrl}`,M=T(),E=x("div"),K=V(U),R=T(),O=x("div"),O.innerHTML="",q=T();for(let ae=0;ae<H.length;ae+=1)H[ae].c();ce=T(),N=x("div"),X=x("button"),X.textContent="Apply",h(t,"class","setting-item-description"),se(t,"margin-bottom","16px"),h(c,"class","setting-item-name"),h(g,"class","tenant-name svelte-74c8lg"),h(S,"class","tenant-url svelte-74c8lg"),h(E,"class","tenant-env svelte-74c8lg"),h(y,"class","tenant-details svelte-74c8lg"),h(p,"class","tenant-info svelte-74c8lg"),h(O,"class","tenant-actions svelte-74c8lg"),h(d,"class","tenant-card svelte-74c8lg"),h(d,"role","button"),h(d,"tabindex","0"),h(d,"title","Click to use default tenant"),_e(d,"active",!n[3]),h(f,"class","tenant-list"),h(l,"class","tenant-list-section svelte-74c8lg"),h(X,"class","mod-cta apply-btn svelte-74c8lg"),h(N,"class","apply-section svelte-74c8lg"),h(e,"class","endpoint-config-modal svelte-74c8lg")},m(ae,Pe){_(ae,e,Pe),b(e,t),b(e,r),A(o,e,null),b(e,s),Q&&Q.m(e,null),b(e,a),b(e,l),b(l,c),b(l,u),b(l,f),b(f,d),b(d,p),de&&de.m(p,null),b(p,m),b(p,y),b(y,g),b(g,L),b(y,C),b(y,S),b(y,M),b(y,E),b(E,K),b(d,R),b(d,O),b(f,q);for(let De=0;De<H.length;De+=1)H[De]&&H[De].m(f,null);b(e,ce),b(e,N),b(N,X),Me=!0,Ie||(D=[$(d,"click",n[15]),$(d,"keydown",n[21]),$(X,"click",n[25])],Ie=!0)},p(ae,Pe){var Ge,mt,_t;let De={};Pe[0]&101|Pe[1]&16&&(De.$$scope={dirty:Pe,ctx:ae}),o.$set(De),Pe[0]&2&&(i=ae[1]&&ae[1].trim()),i?Q?Q.p(ae,Pe):(Q=s_(ae),Q.c(),Q.m(e,a)):Q&&(Q.d(1),Q=null),(Ge=ae[8])!=null&&Ge.logo?de?de.p(ae,Pe):(de=i_(ae),de.c(),de.m(p,m)):de&&(de.d(1),de=null),(!Me||Pe[0]&256)&&I!==(I=(((mt=ae[8])==null?void 0:mt.customer)||"Default Tenant")+"")&&J(L,I),(!Me||Pe[0]&256)&&U!==(U=(((_t=ae[8])==null?void 0:_t.environment)||ae[10].environment)+"")&&J(K,U),(!Me||Pe[0]&8)&&_e(d,"active",!ae[3]),Pe[0]&24600&&(Le=he(ae[4]),H=qr(H,Pe,Ae,1,ae,Le,G,f,Zs,c_,null,n_))},i(ae){Me||(v(o.$$.fragment,ae),Me=!0)},o(ae){k(o.$$.fragment,ae),Me=!1},d(ae){ae&&w(e),F(o),Q&&Q.d(),de&&de.d();for(let Pe=0;Pe<H.length;Pe+=1)H[Pe].d();Ie=!1,me(D)}}}function gP(n,e,t){let r,o,s,i,a,{plugin:l}=e,c=Xe(),u="",f=!1,d={isValid:!0,error:""},p="",m=!1,y="",g=!1,I=0,L=l.loginManager.getEndpointManager().getDefaultUrls(),C=null;function S(){t(18,I++,I)}function M(){t(1,p=""),t(2,m=!1)}function E(D){if(!D.trim())return{isValid:!0,error:""};try{let Q=new URL(D);if(l.loginManager.getEndpointManager().isStaging()){if(Q.protocol!=="https:"&&Q.protocol!=="http:")return{isValid:!1,error:"Only HTTP and HTTPS URLs are allowed in development"}}else if(Q.protocol!=="https:")return{isValid:!1,error:"Only HTTPS URLs are allowed in production"};return Q.hostname.length<3?{isValid:!1,error:"Invalid hostname"}:{isValid:!0,error:""}}catch(Q){return{isValid:!1,error:"Invalid URL format"}}}function U(){return Ce(this,void 0,void 0,function*(){if(u.trim()&&d.isValid){t(5,f=!0);try{let D=yield l.loginManager.getEndpointManager().addTenant(u);D.success?(t(0,u=""),t(1,p=""),t(2,m=!1),S(),t(7,g=!0),D.tenantId&&(yield K(D.tenantId))):(console.log("Add tenant failed with error:",D.error),t(1,p=D.error||"Failed to add tenant"),t(2,m=!0),S())}catch(D){let Q=D instanceof Error?D.message:"Unknown error occurred";t(1,p=`Error adding tenant: ${Q}`),t(2,m=!0)}finally{t(5,f=!1)}}})}function K(D){return Ce(this,void 0,void 0,function*(){try{let Q=yield l.loginManager.getEndpointManager().switchToTenant(D);Q.success?(t(7,g=!0),S()):t(1,p=Q.error||"Failed to switch tenant")}catch(Q){let de=Q instanceof Error?Q.message:"Unknown error occurred";t(1,p=`Error switching tenant: ${de}`)}})}function R(D){return Ce(this,void 0,void 0,function*(){try{(yield l.loginManager.getEndpointManager().removeTenant(D))?(t(7,g=!0),S()):t(1,p="Failed to remove tenant")}catch(Q){let de=Q instanceof Error?Q.message:"Unknown error occurred";t(1,p=`Error removing tenant: ${de}`)}})}function O(){return Ce(this,void 0,void 0,function*(){yield l.endpointSettings.update(D=>Object.assign(Object.assign({},D),{activeTenantId:void 0})),l.loginManager.getEndpointManager().clearValidatedEndpoints(),t(7,g=!0),S()})}function q(){return Ce(this,void 0,void 0,function*(){try{return yield l.loginManager.getEndpointManager().getCustomerInfo()}catch(D){return null}})}function H(){return Ce(this,void 0,void 0,function*(){try{let D=l.loginManager.getEndpointManager();t(8,C=yield D.getDefaultTenantInfo())}catch(D){console.log("Failed to load default tenant info:",D),t(8,C=null)}})}st(()=>{H()});function G(){u=this.value,t(0,u)}let ce=D=>D.key==="Enter"||D.key===" "?O():null,N=D=>R(D.id),X=D=>K(D.id),Me=(D,Q)=>Q.key==="Enter"||Q.key===" "?K(D.id):null,Ie=()=>{c(g?"apply":"close")};return n.$$set=D=>{"plugin"in D&&t(16,l=D.plugin)},n.$$.update=()=>{n.$$.dirty[0]&327680&&t(19,r=l.endpointSettings.get()),n.$$.dirty[0]&524288&&t(4,o=r.tenants||[]),n.$$.dirty[0]&524288&&t(3,s=r.activeTenantId),n.$$.dirty[0]&24&&(i=o.find(D=>D.id===s)),n.$$.dirty[0]&65536&&(a=l.loginManager.getEndpointManager().hasValidatedEndpoints()),n.$$.dirty[0]&131079&&(t(6,d=E(u)),u!==y&&y!==""&&(m&&t(2,m=!1),p&&t(1,p="")),t(17,y=u))},[u,p,m,s,o,f,d,g,C,c,L,M,U,K,R,O,l,y,I,r,G,ce,N,X,Me,Ie]}var nh=class extends z{constructor(e){super(),W(this,e,gP,hP,j,{plugin:16},pP,[-1,-1])}},u_=nh;var Zc=class extends f_.Modal{constructor(t,r,o){super(t);this.plugin=r;this.reload=o;this.setTitle("Enterprise Tenant Configuration")}onOpen(){let{contentEl:t}=this;this.component=new u_({target:t,props:{plugin:this.plugin,reload:this.reload}}),this.component.$on("close",()=>{this.close()}),this.component.$on("apply",()=>{this.close(),setTimeout(()=>{this.reload()},100)})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};var S1=require("obsidian");var g_=require("obsidian");var m_=require("obsidian");function yP(n){we(n,"svelte-4kkvmr",".feature-flag-toggle-modal.svelte-4kkvmr{padding:1rem}.feature-flag-item.svelte-4kkvmr{display:flex;justify-content:space-between;align-items:center;padding:0.5rem 0;border-top:1px solid var(--background-modifier-border)}.checkbox-container.svelte-4kkvmr{cursor:pointer}")}function d_(n,e,t){let r=n.slice();return r[8]=e[t][0],r[9]=e[t][1],r}function p_(n){let e,t,r,o=n[8]+"",s,i,a,l,c=n[8]+"",u,f,d,p,m,y,g,I,L,C,S,M;function E(){return n[6](n[8])}function U(){return n[7](n[8])}return{c(){e=x("div"),t=x("div"),r=x("div"),s=V(o),i=T(),a=x("div"),l=V("Toggle "),u=V(c),f=V(" on or off"),d=T(),p=x("div"),m=x("div"),y=x("input"),I=T(),L=x("div"),h(r,"class","setting-item-name"),h(a,"class","setting-item-description"),h(t,"class","setting-item-info"),h(y,"type","checkbox"),h(y,"tabindex","-1"),y.checked=g=n[9],h(L,"class","checkbox-toggle"),h(m,"role","checkbox"),h(m,"aria-checked",C=n[9]),h(m,"tabindex","0"),h(m,"class","checkbox-container svelte-4kkvmr"),_e(m,"is-enabled",n[9]),h(p,"class","setting-item-control"),h(e,"class","feature-flag-item setting-item svelte-4kkvmr")},m(K,R){_(K,e,R),b(e,t),b(t,r),b(r,s),b(t,i),b(t,a),b(a,l),b(a,u),b(a,f),b(e,d),b(e,p),b(p,m),b(m,y),b(m,I),b(m,L),S||(M=[$(m,"keypress",E),$(m,"click",U)],S=!0)},p(K,R){n=K,R&2&&o!==(o=n[8]+"")&&J(s,o),R&2&&c!==(c=n[8]+"")&&J(u,c),R&2&&g!==(g=n[9])&&(y.checked=g),R&2&&C!==(C=n[9])&&h(m,"aria-checked",C),R&2&&_e(m,"is-enabled",n[9])},d(K){K&&w(e),S=!1,me(M)}}}function bP(n){let e,t,r,o,s,i,a,l,c,u=he(Object.entries(n[1]).filter(n[5]).sort()),f=[];for(let d=0;d<u.length;d+=1)f[d]=p_(d_(n,u,d));return{c(){e=x("div"),t=x("h2"),t.textContent="Feature Flags",r=T();for(let d=0;d<f.length;d+=1)f[d].c();o=T(),s=x("div"),i=x("div"),a=x("button"),a.textContent="Apply",h(a,"aria-label","apply flag settings"),h(a,"tabindex","0"),h(i,"class","setting-item-control"),h(s,"class","setting-item"),h(e,"class","feature-flag-toggle-modal svelte-4kkvmr")},m(d,p){_(d,e,p),b(e,t),b(e,r);for(let m=0;m<f.length;m+=1)f[m]&&f[m].m(e,null);b(e,o),b(e,s),b(s,i),b(i,a),l||(c=[$(a,"click",function(){Je(n[0])&&n[0].apply(this,arguments)}),$(a,"keypress",function(){Je(n[0])&&n[0].apply(this,arguments)})],l=!0)},p(d,[p]){if(n=d,p&10){u=he(Object.entries(n[1]).filter(n[5]).sort());let m;for(m=0;m<u.length;m+=1){let y=d_(n,u,m);f[m]?f[m].p(y,p):(f[m]=p_(y),f[m].c(),f[m].m(e,o))}for(;m<f.length;m+=1)f[m].d(1);f.length=u.length}},i:B,o:B,d(d){d&&w(e),ze(f,d),l=!1,me(c)}}}function vP(n,e,t){let r,o,{reload:s}=e,i=fr.getInstance();ne(n,i,f=>t(4,o=f));function a(f){let d=!r[f];t(1,r[f]=d,r),i.setFlag(f,r[f])}st(()=>{Object.keys(r).forEach(f=>{let d=document.getElementById(`toggle-${f}`);d&&(0,m_.setIcon)(d,"check")})});let l=([f,d])=>fl(f),c=f=>{if(!fl(f))throw new Error("Unexpected feature flag!");a(f)},u=f=>{if(!fl(f))throw new Error("Unexpected feature flag!");a(f)};return n.$$set=f=>{"reload"in f&&t(0,s=f.reload)},n.$$.update=()=>{n.$$.dirty&16&&t(1,r=Object.assign({},o.flags))},[s,r,i,a,o,l,c,u]}var sh=class extends z{constructor(e){super(),W(this,e,vP,bP,j,{reload:0},yP)}},h_=sh;var Xc=class extends g_.Modal{constructor(t,r){super(t);this.reload=r}onOpen(){let{contentEl:t}=this;this.component=new h_({target:t,props:{reload:this.reload}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};var C_=require("obsidian");var k_=require("obsidian");function y_(n,e,t){let r=n.slice();return r[13]=e[t],r}function b_(n,e,t){let r=n.slice();return r[16]=e[t],r}function xP(n){let e,t,r;return{c(){e=x("button"),e.textContent="Refresh"},m(o,s){_(o,e,s),t||(r=$(e,"click",(0,k_.debounce)(n[12])),t=!0)},p:B,d(o){o&&w(e),t=!1,r()}}}function wP(n){let e=navigator.userAgent+"",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p:B,d(r){r&&w(t)}}}function _P(n){let e;return{c(){e=V(n[1])},m(t,r){_(t,e,r)},p(t,r){r&2&&J(e,t[1])},d(t){t&&w(e)}}}function SP(n){let e;return{c(){e=V(n[2])},m(t,r){_(t,e,r)},p(t,r){r&4&&J(e,t[2])},d(t){t&&w(e)}}}function kP(n){let e;return{c(){e=V(n[3])},m(t,r){_(t,e,r)},p(t,r){r&8&&J(e,t[3])},d(t){t&&w(e)}}}function IP(n){let e=n[0].loadTime?`${n[0].loadTime}ms`:"unknown",t;return{c(){t=V(e)},m(r,o){_(r,t,o)},p(r,o){o&1&&e!==(e=r[0].loadTime?`${r[0].loadTime}ms`:"unknown")&&J(t,e)},d(r){r&&w(t)}}}function CP(n){let e,t,r,o,s,i,a,l,c,u;return e=new Re({props:{name:"User Agent",description:"",$$slots:{default:[wP]},$$scope:{ctx:n}}}),r=new Re({props:{name:"Fetch",description:"",$$slots:{default:[_P]},$$scope:{ctx:n}}}),s=new Re({props:{name:"Response",description:"",$$slots:{default:[SP]},$$scope:{ctx:n}}}),a=new Re({props:{name:"Blink Fetch",description:"",$$slots:{default:[kP]},$$scope:{ctx:n}}}),c=new Re({props:{name:"Startup Time",description:"",$$slots:{default:[IP]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment),t=T(),P(r.$$.fragment),o=T(),P(s.$$.fragment),i=T(),P(a.$$.fragment),l=T(),P(c.$$.fragment)},m(f,d){A(e,f,d),_(f,t,d),A(r,f,d),_(f,o,d),A(s,f,d),_(f,i,d),A(a,f,d),_(f,l,d),A(c,f,d),u=!0},p(f,d){let p={};d&524288&&(p.$$scope={dirty:d,ctx:f}),e.$set(p);let m={};d&524290&&(m.$$scope={dirty:d,ctx:f}),r.$set(m);let y={};d&524292&&(y.$$scope={dirty:d,ctx:f}),s.$set(y);let g={};d&524296&&(g.$$scope={dirty:d,ctx:f}),a.$set(g);let I={};d&524289&&(I.$$scope={dirty:d,ctx:f}),c.$set(I)},i(f){u||(v(e.$$.fragment,f),v(r.$$.fragment,f),v(s.$$.fragment,f),v(a.$$.fragment,f),v(c.$$.fragment,f),u=!0)},o(f){k(e.$$.fragment,f),k(r.$$.fragment,f),k(s.$$.fragment,f),k(a.$$.fragment,f),k(c.$$.fragment,f),u=!1},d(f){f&&(w(t),w(o),w(i),w(l)),F(e,f),F(r,f),F(s,f),F(a,f),F(c,f)}}}function v_(n){let e,t=`${n[16]}`,r,o;return{c(){e=x("div"),r=V(t),o=T()},m(s,i){_(s,e,i),b(e,r),b(e,o)},p(s,i){i&16&&t!==(t=`${s[16]}`)&&J(r,t)},d(s){s&&w(e)}}}function LP(n){let e,t=he(Object.keys(n[4].cancelControllers)),r=[];for(let o=0;o<t.length;o+=1)r[o]=v_(b_(n,t,o));return{c(){e=x("div");for(let o=0;o<r.length;o+=1)r[o].c();h(e,"slot","description")},m(o,s){_(o,e,s);for(let i=0;i<r.length;i+=1)r[i]&&r[i].m(e,null)},p(o,s){if(s&16){t=he(Object.keys(o[4].cancelControllers));let i;for(i=0;i<t.length;i+=1){let a=b_(o,t,i);r[i]?r[i].p(a,s):(r[i]=v_(a),r[i].c(),r[i].m(e,null))}for(;i<r.length;i+=1)r[i].d(1);r.length=t.length}},d(o){o&&w(e),ze(r,o)}}}function MP(n){let e,t;return e=new Re({props:{name:"",description:"",$$slots:{description:[LP]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&524304&&(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 x_(n){let e,t=`${n[13]}`,r,o;return{c(){e=x("div"),r=V(t),o=T()},m(s,i){_(s,e,i),b(e,r),b(e,o)},p(s,i){i&32&&t!==(t=`${s[13]}`)&&J(r,t)},d(s){s&&w(e)}}}function TP(n){let e,t=he(n[5]),r=[];for(let o=0;o<t.length;o+=1)r[o]=x_(y_(n,t,o));return{c(){e=x("div");for(let o=0;o<r.length;o+=1)r[o].c();h(e,"slot","description")},m(o,s){_(o,e,s);for(let i=0;i<r.length;i+=1)r[i]&&r[i].m(e,null)},p(o,s){if(s&32){t=he(o[5]);let i;for(i=0;i<t.length;i+=1){let a=y_(o,t,i);r[i]?r[i].p(a,s):(r[i]=x_(a),r[i].c(),r[i].m(e,null))}for(;i<r.length;i+=1)r[i].d(1);r.length=t.length}},d(o){o&&w(e),ze(r,o)}}}function AP(n){let e,t;return e=new Re({props:{name:"",description:"",$$slots:{description:[TP]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&524320&&(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 FP(n){let e,t,r,o,s,i,a,l,c,u,f,d,p,m,y;return o=new Qe({props:{name:"Environment",$$slots:{default:[xP]},$$scope:{ctx:n}}}),i=new vt({props:{$$slots:{default:[CP]},$$scope:{ctx:n}}}),l=new Qe({props:{name:"Connections"}}),u=new vt({props:{$$slots:{default:[MP]},$$scope:{ctx:n}}}),d=new Qe({props:{name:"Log Files"}}),m=new vt({props:{$$slots:{default:[AP]},$$scope:{ctx:n}}}),{c(){e=x("div"),e.textContent="Debug Info",t=T(),r=x("div"),P(o.$$.fragment),s=T(),P(i.$$.fragment),a=T(),P(l.$$.fragment),c=T(),P(u.$$.fragment),f=T(),P(d.$$.fragment),p=T(),P(m.$$.fragment),h(e,"class","modal-title"),h(r,"class","modal-content")},m(g,I){_(g,e,I),_(g,t,I),_(g,r,I),A(o,r,null),b(r,s),A(i,r,null),b(r,a),A(l,r,null),b(r,c),A(u,r,null),b(r,f),A(d,r,null),b(r,p),A(m,r,null),y=!0},p(g,[I]){let L={};I&524288&&(L.$$scope={dirty:I,ctx:g}),o.$set(L);let C={};I&524303&&(C.$$scope={dirty:I,ctx:g}),i.$set(C);let S={};I&524304&&(S.$$scope={dirty:I,ctx:g}),u.$set(S);let M={};I&524320&&(M.$$scope={dirty:I,ctx:g}),m.$set(M)},i(g){y||(v(o.$$.fragment,g),v(i.$$.fragment,g),v(l.$$.fragment,g),v(u.$$.fragment,g),v(d.$$.fragment,g),v(m.$$.fragment,g),y=!0)},o(g){k(o.$$.fragment,g),k(i.$$.fragment,g),k(l.$$.fragment,g),k(u.$$.fragment,g),k(d.$$.fragment,g),k(m.$$.fragment,g),y=!1},d(g){g&&(w(e),w(t),w(r)),F(o),F(i),F(l),F(u),F(d),F(m)}}}function w_(){try{return Response.toString()}catch(n){return"undefined"}}function __(){try{return fetch.toString()}catch(n){return"undefined"}}function S_(){try{return(globalThis==null?void 0:globalThis.blinkfetch)!==void 0?"Yes":"No"}catch(n){return"No"}}function EP(n,e,t){let r,o,s,i,a,{plugin:l}=e,c=ge(w_());ne(n,c,g=>t(2,o=g));let u=ge(__());ne(n,u,g=>t(1,r=g));let f=ge(S_());ne(n,f,g=>t(3,s=g));let d=ge(l.loginManager.pb);ne(n,d,g=>t(4,i=g));let p=ge([]);ne(n,p,g=>t(5,a=g)),al().then(g=>{p.set(g)});function m(){c.set(w_()),u.set(__()),f.set(S_()),d.set(l.loginManager.pb)}let y=()=>{m()};return n.$$set=g=>{"plugin"in g&&t(0,l=g.plugin)},[l,r,o,s,i,a,c,u,f,d,p,m,y]}var ih=class extends z{constructor(e){super(),W(this,e,EP,FP,j,{plugin:0})}},I_=ih;var eu=class extends C_.Modal{constructor(t,r){super(t);this.plugin=r}onOpen(){let{contentEl:t}=this;this.component=new I_({target:t,props:{plugin:this.plugin}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};var L_=require("obsidian"),tu=class{notify(e){new L_.Notice(e)}},ru=class{constructor(e){this.vault=e}async append(e,t){return this.vault.adapter.append(e,t)}async stat(e){return this.vault.adapter.stat(e)}async exists(e){return this.vault.adapter.exists(e)}async remove(e){return this.vault.adapter.remove(e)}async rename(e,t){return this.vault.adapter.rename(e,t)}async write(e,t){return this.vault.adapter.write(e,t)}async read(e){return this.vault.adapter.read(e)}};var U_=require("obsidian");var D_=require("obsidian");function PP(n){we(n,"svelte-jmqfac",".system3-bug-report.svelte-jmqfac{display:flex;flex-direction:column;height:100%;min-height:30em}.report-container.svelte-jmqfac{display:flex;flex-direction:column;flex:1}.form-content.svelte-jmqfac{flex:1;overflow-y:auto}textarea.svelte-jmqfac{width:100%;height:300px;resize:vertical}.centered-message.svelte-jmqfac{display:flex;flex:1;align-items:center;justify-content:center;padding-bottom:5em}")}function M_(n,e,t){let r=n.slice();return r[21]=e[t],r}function DP(n){let e,t,r,o,s,i,a,l,c,u,f,d,p;r=new Re({props:{name:"Description",description:"Please describe what went wrong and what you were trying to do."}}),a=new Re({props:{name:"Include Logs",description:"Send logs to the Relay developers to help them debug the issue.",$$slots:{default:[OP]},$$scope:{ctx:n}}});let m=n[4]&&T_(n);return u=new Re({props:{name:"",description:"",$$slots:{default:[NP]},$$scope:{ctx:n}}}),{c(){e=x("div"),t=x("div"),P(r.$$.fragment),o=T(),s=x("textarea"),i=T(),P(a.$$.fragment),l=T(),m&&m.c(),c=T(),P(u.$$.fragment),h(s,"placeholder","Describe the issue here..."),h(s,"class","svelte-jmqfac"),h(t,"class","form-content svelte-jmqfac"),h(e,"class","report-container svelte-jmqfac")},m(y,g){_(y,e,g),b(e,t),A(r,t,null),b(t,o),b(t,s),Ye(s,n[3]),b(t,i),A(a,t,null),b(t,l),m&&m.m(t,null),b(e,c),A(u,e,null),f=!0,d||(p=$(s,"input",n[13]),d=!0)},p(y,g){g&8&&Ye(s,y[3]);let I={};g&16777232&&(I.$$scope={dirty:g,ctx:y}),a.$set(I),y[4]?m?(m.p(y,g),g&16&&v(m,1)):(m=T_(y),m.c(),v(m,1),m.m(t,null)):m&&(ee(),k(m,1,1,()=>{m=null}),te());let L={};g&16777293&&(L.$$scope={dirty:g,ctx:y}),u.$set(L)},i(y){f||(v(r.$$.fragment,y),v(a.$$.fragment,y),v(m),v(u.$$.fragment,y),f=!0)},o(y){k(r.$$.fragment,y),k(a.$$.fragment,y),k(m),k(u.$$.fragment,y),f=!1},d(y){y&&w(e),F(r),F(a),m&&m.d(),F(u),d=!1,p()}}}function RP(n){let e;return{c(){e=x("div"),e.innerHTML='<div id="spinner" class="d-flex align-items-center"><strong>Sending Bug Report...</strong> <div class="spinner-border ms-auto" role="status" aria-hidden="true"></div></div>',h(e,"class","centered-message svelte-jmqfac")},m(t,r){_(t,e,r)},p:B,i:B,o:B,d(t){t&&w(e)}}}function UP(n){let e,t,r;return t=new Re({props:{name:"Thank you!",description:"Your bug report will help us improve Relay."}}),{c(){e=x("div"),P(t.$$.fragment),h(e,"class","centered-message svelte-jmqfac")},m(o,s){_(o,e,s),A(t,e,null),r=!0},p:B,i(o){r||(v(t.$$.fragment,o),r=!0)},o(o){k(t.$$.fragment,o),r=!1},d(o){o&&w(e),F(t)}}}function OP(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"),h(t,"tabindex","-1"),t.checked=n[4],h(o,"class","checkbox-toggle"),h(e,"role","checkbox"),h(e,"aria-checked",n[4]),h(e,"tabindex","0"),h(e,"class","checkbox-container"),_e(e,"is-enabled",n[4])},m(a,l){_(a,e,l),b(e,t),b(e,r),b(e,o),s||(i=[$(e,"keypress",VP),$(e,"click",n[14])],s=!0)},p(a,l){l&16&&(t.checked=a[4]),l&16&&h(e,"aria-checked",a[4]),l&16&&_e(e,"is-enabled",a[4])},d(a){a&&w(e),s=!1,me(i)}}}function T_(n){let e,t;return e=new Re({props:{name:"Logs",description:"",$$slots:{description:[$P]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&16777248&&(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 A_(n){let e,t=`${n[21]}
|
|
`,r,o;return{c(){e=x("div"),r=V(t),o=T()},m(s,i){_(s,e,i),b(e,r),b(e,o)},p(s,i){i&32&&t!==(t=`${s[21]}
|
|
`)&&J(r,t)},d(s){s&&w(e)}}}function $P(n){let e,t=he(n[5]),r=[];for(let o=0;o<t.length;o+=1)r[o]=A_(M_(n,t,o));return{c(){e=x("div");for(let o=0;o<r.length;o+=1)r[o].c();h(e,"slot","description")},m(o,s){_(o,e,s);for(let i=0;i<r.length;i+=1)r[i]&&r[i].m(e,null)},p(o,s){if(s&32){t=he(o[5]);let i;for(i=0;i<t.length;i+=1){let a=M_(o,t,i);r[i]?r[i].p(a,s):(r[i]=A_(a),r[i].c(),r[i].m(e,null))}for(;i<r.length;i+=1)r[i].d(1);r.length=t.length}},d(o){o&&w(e),ze(r,o)}}}function NP(n){let e,t,r,o;return{c(){e=x("button"),t=V("Send"),e.disabled=n[2]},m(s,i){_(s,e,i),b(e,t),r||(o=$(e,"click",n[15]),r=!0)},p(s,i){i&4&&(e.disabled=s[2])},d(s){s&&w(e),r=!1,o()}}}function BP(n){let e,t,r,o,s,i,a=[UP,RP,DP],l=[];function c(u,f){return u[1]?0:u[2]&&!u[1]?1:2}return o=c(n,-1),s=l[o]=a[o](n),{c(){e=x("div"),e.textContent="Send Bug Report",t=T(),r=x("div"),s.c(),h(e,"class","modal-title"),h(r,"class","modal-content system3-bug-report svelte-jmqfac")},m(u,f){_(u,e,f),_(u,t,f),_(u,r,f),l[o].m(r,null),i=!0},p(u,[f]){let d=o;o=c(u,f),o===d?l[o].p(u,f):(ee(),k(l[d],1,1,()=>{l[d]=null}),te(),s=l[o],s?s.p(u,f):(s=l[o]=a[o](u),s.c()),v(s,1),s.m(r,null))},i(u){i||(v(s),i=!0)},o(u){k(s),i=!1},d(u){u&&(w(e),w(t),w(r)),l[o].d()}}}function F_(){try{return Response.toString()}catch(n){return"undefined"}}function E_(){try{return fetch.toString()}catch(n){return"undefined"}}function P_(){try{return(globalThis==null?void 0:globalThis.blinkfetch)!==void 0?"Yes":"No"}catch(n){return"No"}}var VP=()=>{};function HP(n,e,t){let r,o,s,i,a,l,{plugin:c}=e,u=ge(F_()),f=ge(E_()),d=ge(P_()),p=ge("");ne(n,p,K=>t(3,s=K));let m=ge(!1);ne(n,m,K=>t(4,i=K));let y=ge(!1),g=ge(!1);ne(n,g,K=>t(2,o=K));let I=ge(!1);ne(n,I,K=>t(1,r=K));let L=ge(c.loginManager.pb);ne(n,L,K=>t(6,l=K));let C=ge([]);ne(n,C,K=>t(5,a=K)),al().then(K=>{C.set(K)});function S(){u.set(F_()),f.set(E_()),d.set(P_()),L.set(c.loginManager.pb)}function M(){s=this.value,p.set(s)}let E=()=>{let K=!i;m.set(K)},U=async()=>{var R;let K=`Bug Report
|
|
|
|
`;if(K+=JSON.stringify({userAgent:navigator.userAgent,manifest:c.manifest,user:(R=l==null?void 0:l.authStore.model)==null?void 0:R.id,loadTime:c.loadTime,description:s},null,2),K+=`
|
|
|
|
`,m){let O=await Iy();K+=O}(0,D_.requestUrl)({url:"https://bug-reports.system3.dev",method:"PUT",body:K,headers:{"Content-Type":"text/plain"}}).then(()=>{I.set(!0)}),g.set(!0)};return n.$$set=K=>{"plugin"in K&&t(0,c=K.plugin)},[c,r,o,s,i,a,l,p,m,g,I,L,C,M,E,U]}var ah=class extends z{constructor(e){super(),W(this,e,HP,BP,j,{plugin:0},PP)}},R_=ah;var ou=class extends U_.Modal{constructor(t,r){super(t);this.plugin=r}onOpen(){let{contentEl:t}=this;this.component=new R_({target:t,props:{plugin:this.plugin}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};var z_=require("obsidian");async function O_(n){let{appId:e,filterByAppId:t,onProgress:r}=n,o=await window.indexedDB.databases(),s=o.length,i=[],a=0,l=0,c=0,u=0;for(let f of o)if(f.name){try{let d=await new Promise((p,m)=>{let y=indexedDB.open(f.name);y.onerror=()=>m(y.error),y.onsuccess=g=>p(g.target.result)});try{let p=Array.from(d.objectStoreNames);if(!p.includes("updates")||!p.includes("custom"))continue;let m=d.transaction(["updates","custom"],"readonly"),y=m.objectStore("updates"),g=m.objectStore("custom"),I=await new Promise(C=>{let S=g.get("appId");S.onsuccess=()=>C(S.result||"")});a++;let L=await new Promise((C,S)=>{let M=y.count();M.onsuccess=()=>C(M.result),M.onerror=()=>S(M.error)});if(l+=L,L>0){let C=0;if(await new Promise((S,M)=>{let E=y.openCursor();E.onsuccess=U=>{let K=U.target.result;if(K){let R=K.value instanceof Uint8Array?K.value.byteLength:JSON.stringify(K.value).length;C+=R,K.continue()}else S()},E.onerror=()=>M(E.error)}),c+=C,C>1024*1024&&(!t||I===e)){let S=await new Promise(U=>{let K=g.get("path");K.onsuccess=()=>U(K.result||"")}),M=await new Promise(U=>{let K=g.get("relay");K.onsuccess=()=>U(K.result||"")}),E=!f.name.startsWith(`${e}-relay`);i.push({slug:`${f.name}/${y.name}`,path:S,relay:M,appId:I||"unknown",count:L,estimatedSizeMB:Math.round(C/(1024*1024)*100)/100,isLegacy:E})}}}finally{d.close()}}catch(d){console.error(`Error processing database ${f.name}:`,d);continue}u++,r&&r(u/o.length*100)}return{totalStores:a,totalItems:l,totalSizeMB:Math.round(c/(1024*1024)*100)/100,databaseCount:s,largeStores:i.sort((f,d)=>d.estimatedSizeMB-f.estimatedSizeMB)}}async function $_(n){let[e,t]=n.split("/"),r=await new Promise((o,s)=>{let i=indexedDB.open(e);i.onerror=()=>s(i.error),i.onsuccess=()=>o(i.result)});try{let s=r.transaction(t,"readwrite").objectStore(t);await new Promise((i,a)=>{let l=s.clear();l.onsuccess=()=>i(),l.onerror=()=>a(l.error)})}catch(o){console.error(`Error deleting store: ${n}`,o)}finally{r.close()}}var Ote=require("obsidian");function qP(n){we(n,"svelte-1n3w4sk",".system3-dangerous.svelte-1n3w4sk:enabled{background-color:var(--background-modifier-error)}.system3-indexeddb-analysis.svelte-1n3w4sk{padding:1rem;max-height:500px;overflow-y:auto}.system3-loading-container.svelte-1n3w4sk{display:flex;flex-direction:column;align-items:center;justify-content:center;height:200px;gap:1rem}.system3-loading-spinner.svelte-1n3w4sk{border:4px solid var(--background-modifier-border);border-top:4px solid var(--interactive-accent);border-radius:50%;width:40px;height:40px;animation:svelte-1n3w4sk-spin 1s linear infinite}.system3-progress-bar.svelte-1n3w4sk{width:80%;height:8px;border-radius:4px;background-color:var(--background-secondary);overflow:hidden;margin:0 auto}.system3-progress-fill.svelte-1n3w4sk{height:100%;background-color:var(--color-accent);border-radius:4px;transition:width 0.3s ease;min-width:0%;max-width:100%}.system3-error-message.svelte-1n3w4sk{color:var(--text-error);padding:1rem;background-color:var(--mod-error);border-radius:4px}.system3-actions.svelte-1n3w4sk{display:flex;gap:0.5rem}.system3-summary-stats.svelte-1n3w4sk{display:grid;grid-template-columns:repeat(3, 1fr);gap:1rem;margin-bottom:2rem;padding:1rem;background-color:var(--background-secondary);border-radius:4px}.system3-stat-item.svelte-1n3w4sk{text-align:center}.system3-global-count.svelte-1n3w4sk{grid-column:1 / -1;padding-top:0.5rem;margin-top:0.5rem;border-bottom:1px solid var(--background-modifier-border)}.system3-warning.svelte-1n3w4sk{color:var(--text-warning)}.system3-critical.svelte-1n3w4sk{color:var(--text-error)}.system3-warning-text.svelte-1n3w4sk{font-size:0.8em;margin-top:0.5rem;color:var(--text-warning);line-height:1.4}.system3-warning-text.system3-critical.svelte-1n3w4sk{color:var(--text-error);font-weight:bold}.system3-stat-label.svelte-1n3w4sk{font-size:0.9em;color:var(--text-muted);margin-bottom:0.5rem}.system3-stat-value.svelte-1n3w4sk{font-size:1.2em;font-weight:bold}@keyframes svelte-1n3w4sk-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}")}function N_(n,e,t){let r=n.slice();return r[18]=e[t][0],r[19]=e[t][1],r}function B_(n,e,t){let r=n.slice();return r[22]=e[t],r}function jP(n){let e,t,r,o,s,i=n[0].databaseCount.toLocaleString()+"",a,l,c,u,f,d,p,m,y=n[0].totalStores+"",g,I,L,C,S,M,E=n[0].totalItems.toLocaleString()+"",U,K,R,O,q,H,G=n[0].totalSizeMB.toFixed(2)+"",ce,N,X,Me,Ie;function D(Ae,re){if(Ae[0].databaseCount>45e3)return GP;if(Ae[0].databaseCount>4e4)return KP}let Q=D(n,-1),de=Q&&Q(n),Le=n[0].largeStores.length>0&&V_(n);return{c(){e=x("div"),t=x("div"),r=x("div"),r.textContent="Global Database Limit",o=T(),s=x("div"),a=V(i),l=V(" / 50,000"),c=T(),de&&de.c(),u=T(),f=x("div"),d=x("div"),d.textContent="Relay Databases",p=T(),m=x("div"),g=V(y),I=T(),L=x("div"),C=x("div"),C.textContent="Document Updates",S=T(),M=x("div"),U=V(E),K=T(),R=x("div"),O=x("div"),O.textContent="Total Size",q=T(),H=x("div"),ce=V(G),N=V(" MB"),X=T(),Le&&Le.c(),Me=ue(),h(r,"class","system3-stat-label svelte-1n3w4sk"),h(s,"class","system3-stat-value svelte-1n3w4sk"),_e(s,"system3-warning",n[0].databaseCount>4e4),_e(s,"system3-critical",n[0].databaseCount>45e3),h(t,"class","system3-stat-item system3-global-count svelte-1n3w4sk"),h(d,"class","system3-stat-label svelte-1n3w4sk"),h(m,"class","system3-stat-value svelte-1n3w4sk"),h(f,"class","system3-stat-item svelte-1n3w4sk"),h(C,"class","system3-stat-label svelte-1n3w4sk"),h(M,"class","system3-stat-value svelte-1n3w4sk"),h(L,"class","system3-stat-item svelte-1n3w4sk"),h(O,"class","system3-stat-label svelte-1n3w4sk"),h(H,"class","system3-stat-value svelte-1n3w4sk"),h(R,"class","system3-stat-item svelte-1n3w4sk"),h(e,"class","system3-summary-stats svelte-1n3w4sk")},m(Ae,re){_(Ae,e,re),b(e,t),b(t,r),b(t,o),b(t,s),b(s,a),b(s,l),b(t,c),de&&de.m(t,null),b(e,u),b(e,f),b(f,d),b(f,p),b(f,m),b(m,g),b(e,I),b(e,L),b(L,C),b(L,S),b(L,M),b(M,U),b(e,K),b(e,R),b(R,O),b(R,q),b(R,H),b(H,ce),b(H,N),_(Ae,X,re),Le&&Le.m(Ae,re),_(Ae,Me,re),Ie=!0},p(Ae,re){(!Ie||re&1)&&i!==(i=Ae[0].databaseCount.toLocaleString()+"")&&J(a,i),(!Ie||re&1)&&_e(s,"system3-warning",Ae[0].databaseCount>4e4),(!Ie||re&1)&&_e(s,"system3-critical",Ae[0].databaseCount>45e3),Q!==(Q=D(Ae,re))&&(de&&de.d(1),de=Q&&Q(Ae),de&&(de.c(),de.m(t,null))),(!Ie||re&1)&&y!==(y=Ae[0].totalStores+"")&&J(g,y),(!Ie||re&1)&&E!==(E=Ae[0].totalItems.toLocaleString()+"")&&J(U,E),(!Ie||re&1)&&G!==(G=Ae[0].totalSizeMB.toFixed(2)+"")&&J(ce,G),Ae[0].largeStores.length>0?Le?(Le.p(Ae,re),re&1&&v(Le,1)):(Le=V_(Ae),Le.c(),v(Le,1),Le.m(Me.parentNode,Me)):Le&&(ee(),k(Le,1,1,()=>{Le=null}),te())},i(Ae){Ie||(v(Le),Ie=!0)},o(Ae){k(Le),Ie=!1},d(Ae){Ae&&(w(e),w(X),w(Me)),de&&de.d(),Le&&Le.d(Ae)}}}function zP(n){let e,t;return{c(){e=x("div"),t=V(n[5]),h(e,"class","system3-error-message svelte-1n3w4sk")},m(r,o){_(r,e,o),b(e,t)},p(r,o){o&32&&J(t,r[5])},i:B,o:B,d(r){r&&w(e)}}}function WP(n){let e,t,r,o,s,i,a;return{c(){e=x("div"),t=x("div"),r=T(),o=x("div"),o.textContent="Analyzing Databases...",s=T(),i=x("div"),a=x("div"),h(t,"class","system3-loading-spinner svelte-1n3w4sk"),h(o,"class","loading-text"),h(a,"class","system3-progress-fill svelte-1n3w4sk"),se(a,"width",n[4]+"%"),h(i,"class","system3-progress-bar svelte-1n3w4sk"),h(e,"class","system3-loading-container svelte-1n3w4sk")},m(l,c){_(l,e,c),b(e,t),b(e,r),b(e,o),b(e,s),b(e,i),b(i,a)},p(l,c){c&16&&se(a,"width",l[4]+"%")},i:B,o:B,d(l){l&&w(e)}}}function KP(n){let e;return{c(){e=x("div"),e.innerHTML=`Warning: high number of databases.<br/>
|
|
Consider cleaning up unused databases.`,h(e,"class","system3-warning-text svelte-1n3w4sk")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function GP(n){let e;return{c(){e=x("div"),e.innerHTML=`Critical: approaching IndexedDB database limit!<br/>
|
|
Your browser may start deleting old databases soon.`,h(e,"class","system3-warning-text system3-critical svelte-1n3w4sk")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function V_(n){let e,t,r,o;e=new Qe({props:{name:"Large Stores (>1MB)"}});let s=he(n[2]),i=[];for(let l=0;l<s.length;l+=1)i[l]=q_(N_(n,s,l));let a=l=>k(i[l],1,1,()=>{i[l]=null});return{c(){P(e.$$.fragment),t=T();for(let l=0;l<i.length;l+=1)i[l].c();r=ue()},m(l,c){A(e,l,c),_(l,t,c);for(let u=0;u<i.length;u+=1)i[u]&&i[u].m(l,c);_(l,r,c),o=!0},p(l,c){if(c&2052){s=he(l[2]);let u;for(u=0;u<s.length;u+=1){let f=N_(l,s,u);i[u]?(i[u].p(f,c),v(i[u],1)):(i[u]=q_(f),i[u].c(),v(i[u],1),i[u].m(r.parentNode,r))}for(ee(),u=s.length;u<i.length;u+=1)a(u);te()}},i(l){if(!o){v(e.$$.fragment,l);for(let c=0;c<s.length;c+=1)v(i[c]);o=!0}},o(l){k(e.$$.fragment,l),i=i.filter(Boolean);for(let c=0;c<i.length;c+=1)k(i[c]);o=!1},d(l){l&&(w(t),w(r)),F(e,l),ze(i,l)}}}function JP(n){let e,t,r,o,s;function i(){return n[17](n[22])}return{c(){e=x("div"),t=x("button"),t.textContent="Delete",r=T(),h(t,"class","mod-warning"),h(t,"title","Delete all data in this store"),h(e,"class","system3-actions svelte-1n3w4sk")},m(a,l){_(a,e,l),b(e,t),_(a,r,l),o||(s=$(t,"click",i),o=!0)},p(a,l){n=a},d(a){a&&(w(e),w(r)),o=!1,s()}}}function H_(n){let e,t;return e=new Re({props:{name:n[22].path||n[22].slug,description:"Size: "+n[22].estimatedSizeMB+"MB, Items: "+n[22].count,$$slots:{default:[JP]},$$scope:{ctx:n}}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o&4&&(s.name=r[22].path||r[22].slug),o&4&&(s.description="Size: "+r[22].estimatedSizeMB+"MB, Items: "+r[22].count),o&33554436&&(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 q_(n){let e,t,r,o;e=new Qe({props:{name:n[18]==="local"?"Tracked Documents":`Relay: ${n[18]}`}});let s=he(n[19]),i=[];for(let l=0;l<s.length;l+=1)i[l]=H_(B_(n,s,l));let a=l=>k(i[l],1,1,()=>{i[l]=null});return{c(){P(e.$$.fragment),t=T();for(let l=0;l<i.length;l+=1)i[l].c();r=ue()},m(l,c){A(e,l,c),_(l,t,c);for(let u=0;u<i.length;u+=1)i[u]&&i[u].m(l,c);_(l,r,c),o=!0},p(l,c){let u={};if(c&4&&(u.name=l[18]==="local"?"Tracked Documents":`Relay: ${l[18]}`),e.$set(u),c&2052){s=he(l[19]);let f;for(f=0;f<s.length;f+=1){let d=B_(l,s,f);i[f]?(i[f].p(d,c),v(i[f],1)):(i[f]=H_(d),i[f].c(),v(i[f],1),i[f].m(r.parentNode,r))}for(ee(),f=s.length;f<i.length;f+=1)a(f);te()}},i(l){if(!o){v(e.$$.fragment,l);for(let c=0;c<s.length;c+=1)v(i[c]);o=!0}},o(l){k(e.$$.fragment,l),i=i.filter(Boolean);for(let c=0;c<i.length;c+=1)k(i[c]);o=!1},d(l){l&&(w(t),w(r)),F(e,l),ze(i,l)}}}function YP(n){let e,t,r,o,s,i,a,l,c,u,f,d,p,m,y,g,I,L=[WP,zP,jP],C=[];function S(M,E){return M[3]?0:M[5]?1:M[0]?2:-1}return~(p=S(n,-1))&&(m=C[p]=L[p](n)),{c(){e=x("div"),e.textContent="Relay database analysis",t=T(),r=x("div"),o=x("div"),s=x("div"),s.innerHTML=`<div class="setting-item-name">Search across vaults</div> <div class="setting-item-description"><div class="mod-warning">Warning: This is a dangerous setting. It allows you to delete relay
|
|
databases from other vaults.</div></div>`,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<t.length;o+=1)r[o]=X_(W_(n,t,o));return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=ue()},m(o,s){for(let i=0;i<r.length;i+=1)r[i]&&r[i].m(o,s);_(o,e,s)},p(o,s){if(s[0]&268436736|s[1]&17){t=he(o[8]);let i;for(i=0;i<t.length;i+=1){let a=W_(o,t,i);r[i]?r[i].p(a,s):(r[i]=X_(a),r[i].c(),r[i].m(e.parentNode,e))}for(;i<r.length;i+=1)r[i].d(1);r.length=t.length}},d(o){o&&w(e),ze(r,o)}}}function X_(n){let e,t,r=n[66].tag_name+"",o,s,i,a,l,c;function u(){return n[49](n[66])}function f(...d){return n[50](n[66],...d)}return{c(){e=x("div"),t=x("div"),o=V(r),s=T(),h(t,"class","tag-name svelte-12doke6"),h(e,"class",i="release-tag-item "+(n[28](n[66].tag_name)?"current-version":"")+" "+(i1(n[66])?"pre-release":"")+" svelte-12doke6"),h(e,"role","tab"),h(e,"aria-selected",a=n[10]===n[66].tag_name),h(e,"tabindex","0")},m(d,p){_(d,e,p),b(e,t),b(t,o),b(e,s),l||(c=[$(e,"click",u),$(e,"keydown",f)],l=!0)},p(d,p){n=d,p[0]&256&&r!==(r=n[66].tag_name+"")&&J(o,r),p[0]&256&&i!==(i="release-tag-item "+(n[28](n[66].tag_name)?"current-version":"")+" "+(i1(n[66])?"pre-release":"")+" svelte-12doke6")&&h(e,"class",i),p[0]&1280&&a!==(a=n[10]===n[66].tag_name)&&h(e,"aria-selected",a)},d(d){d&&w(e),l=!1,me(c)}}}function iD(n){let e,t,r,o,s,i,a;return{c(){e=x("div"),t=x("div"),r=V(n[16]),o=T(),s=x("button"),s.textContent="Close",h(t,"class","manifest-error-message svelte-12doke6"),h(s,"class","manifest-close-btn svelte-12doke6"),h(e,"class","manifest-error svelte-12doke6")},m(l,c){_(l,e,c),b(e,t),b(t,r),b(e,o),b(e,s),i||(a=$(s,"click",n[37]),i=!0)},p(l,c){c[0]&65536&&J(r,l[16])},d(l){l&&w(e),i=!1,a()}}}function aD(n){var H;let e,t,r,o,s,i,a=(H=n[38](n[10]))==null?void 0:H.prerelease,l,c,u,f,d,p,m,y,g,I,L=a&&e1(n),C=n[12][n[10]]==="beta-alias"&&t1(n),S=n[12][n[10]]==="stable-alias"&&r1(n);function M(G,ce){if(ce[0]&9216&&(d=null),ce[0]&1024&&(p=null),d==null&&(d=!!((G[38](G[10])||G[13][G[10]]==="stable-alias"||G[13][G[10]]==="beta-alias")&&!G[28](G[10]))),d)return cD;if(p==null&&(p=!!G[28](G[10])),p)return lD}let E=M(n,[-1,-1,-1]),U=E&&E(n);function K(G,ce){return G[13][G[10]]==="stable-alias"||G[13][G[10]]==="beta-alias"||G[9]==="development"?mD:G[10]?pD:dD}let R=K(n,[-1,-1,-1]),O=R(n),q=n[15]&&o1(n);return{c(){e=x("div"),t=x("div"),r=x("h3"),o=V("Release Details: "),s=V(n[10]),i=T(),L&&L.c(),l=T(),C&&C.c(),c=T(),S&&S.c(),u=T(),f=x("div"),U&&U.c(),m=T(),y=x("div"),g=x("div"),O.c(),I=T(),q&&q.c(),h(r,"class","svelte-12doke6"),h(f,"class","manifest-header-actions svelte-12doke6"),h(t,"class","manifest-header svelte-12doke6"),h(g,"class","release-changelog-content svelte-12doke6"),h(y,"class","release-changelog svelte-12doke6"),h(e,"class","manifest-container svelte-12doke6")},m(G,ce){_(G,e,ce),b(e,t),b(t,r),b(r,o),b(r,s),b(r,i),L&&L.m(r,null),b(r,l),C&&C.m(r,null),b(r,c),S&&S.m(r,null),b(t,u),b(t,f),U&&U.m(f,null),b(e,m),b(e,y),b(y,g),O.m(g,null),b(e,I),q&&q.m(e,null)},p(G,ce){var N;ce[0]&1024&&J(s,G[10]),ce[0]&1024&&(a=(N=G[38](G[10]))==null?void 0:N.prerelease),a?L||(L=e1(G),L.c(),L.m(r,l)):L&&(L.d(1),L=null),G[12][G[10]]==="beta-alias"?C||(C=t1(G),C.c(),C.m(r,c)):C&&(C.d(1),C=null),G[12][G[10]]==="stable-alias"?S||(S=r1(G),S.c(),S.m(r,null)):S&&(S.d(1),S=null),E===(E=M(G,ce))&&U?U.p(G,ce):(U&&U.d(1),U=E&&E(G),U&&(U.c(),U.m(f,null))),R===(R=K(G,ce))&&O?O.p(G,ce):(O.d(1),O=R(G),O&&(O.c(),O.m(g,null))),G[15]?q?q.p(G,ce):(q=o1(G),q.c(),q.m(e,null)):q&&(q.d(1),q=null)},d(G){G&&w(e),L&&L.d(),C&&C.d(),S&&S.d(),U&&U.d(),O.d(),q&&q.d()}}}function e1(n){let e;return{c(){e=x("span"),e.textContent="Pre-release",h(e,"class","prerelease-badge svelte-12doke6")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function t1(n){let e;return{c(){e=x("span"),e.textContent="Beta",h(e,"class","channel-badge beta-badge svelte-12doke6")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function r1(n){let e;return{c(){e=x("span"),e.textContent="Stable",h(e,"class","channel-badge stable-badge svelte-12doke6")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function lD(n){let e;return{c(){e=x("span"),e.textContent="Installed",h(e,"class","currently-installed svelte-12doke6")},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function cD(n){let e,t,r,o;function s(l,c){return l[14]===l[10]?fD:uD}let i=s(n,[-1,-1,-1]),a=i(n);return{c(){e=x("button"),a.c(),h(e,"class","install-version-btn mod-cta svelte-12doke6"),e.disabled=t=n[14]===n[10]||n[2]},m(l,c){_(l,e,c),a.m(e,null),r||(o=$(e,"click",n[51]),r=!0)},p(l,c){i!==(i=s(l,c))&&(a.d(1),a=i(l),a&&(a.c(),a.m(e,null))),c[0]&17412&&t!==(t=l[14]===l[10]||l[2])&&(e.disabled=t)},d(l){l&&w(e),a.d(),r=!1,o()}}}function uD(n){let e;return{c(){e=V("Install")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function fD(n){let e;return{c(){e=V("Installing...")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function dD(n){let e;return{c(){e=V('"No changelog available"')},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function pD(n){var o;let e,t,r={ctx:n,current:null,token:null,hasCatch:!1,pending:yD,then:gD,catch:hD,value:65};return Qs(t=n[34](((o=n[38](n[10]))==null?void 0:o.body)||"No changelog available"),r),{c(){e=ue(),r.block.c()},m(s,i){_(s,e,i),r.block.m(s,r.anchor=i),r.mount=()=>e.parentNode,r.anchor=e},p(s,i){var a;n=s,r.ctx=n,i[0]&1024&&t!==(t=n[34](((a=n[38](n[10]))==null?void 0:a.body)||"No changelog available"))&&Qs(t,r)||lc(r,n,i)},d(s){s&&w(e),r.block.d(s),r.token=null,r=null}}}function mD(n){let e;function t(s,i){if(s[13][s[10]]==="stable-alias")return xD;if(s[13][s[10]]==="beta-alias")return vD;if(s[10]===s[0].version)return bD}let r=t(n,[-1,-1,-1]),o=r&&r(n);return{c(){o&&o.c(),e=ue()},m(s,i){o&&o.m(s,i),_(s,e,i)},p(s,i){r!==(r=t(s,i))&&(o&&o.d(1),o=r&&r(s),o&&(o.c(),o.m(e.parentNode,e)))},d(s){s&&w(e),o&&o.d(s)}}}function hD(n){return{c:B,m:B,p:B,d:B}}function gD(n){let e,t=n[65]+"",r;return{c(){e=new wn(!1),r=ue(),e.a=r},m(o,s){e.m(t,o,s),_(o,r,s)},p(o,s){s[0]&1024&&t!==(t=o[65]+"")&&e.p(t)},d(o){o&&(w(r),e.d())}}}function yD(n){let e;return{c(){e=V('"loading..."')},m(t,r){_(t,e,r)},p:B,d(t){t&&w(e)}}}function bD(n){let e;return{c(){e=x("p"),e.textContent="Current development version"},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function vD(n){let e;return{c(){e=x("p"),e.textContent="Current beta release from main branch manifest-beta.json"},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function xD(n){let e;return{c(){e=x("p"),e.textContent="Current stable release from main branch manifest.json"},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function o1(n){let e,t,r,o,s,i=n[11].version+"",a,l,c=n[10]!==n[11].version&&!n[10].startsWith("v"+n[11].version),u,f,d,p,m,y=n[11].name+"",g,I,L,C,S,M,E=n[11].author+"",U,K,R,O,q,H,G=n[11].description+"",ce,N,X,Me,Ie,D,Q=n[11].isDesktopOnly?"Yes":"No",de,Le,Ae,re,Z,Se,ae=n[11].minAppVersion+"",Pe,De=c&&n1(n);return{c(){e=x("div"),t=x("div"),r=x("span"),r.textContent="Version:",o=T(),s=x("span"),a=V(i),l=T(),De&&De.c(),u=T(),f=x("div"),d=x("span"),d.textContent="Name:",p=T(),m=x("span"),g=V(y),I=T(),L=x("div"),C=x("span"),C.textContent="Author:",S=T(),M=x("span"),U=V(E),K=T(),R=x("div"),O=x("span"),O.textContent="Description:",q=T(),H=x("span"),ce=V(G),N=T(),X=x("div"),Me=x("span"),Me.textContent="isDesktopOnly:",Ie=T(),D=x("span"),de=V(Q),Le=T(),Ae=x("div"),re=x("span"),re.textContent="minAppVersion:",Z=T(),Se=x("span"),Pe=V(ae),h(r,"class","manifest-label svelte-12doke6"),h(s,"class","manifest-value svelte-12doke6"),h(t,"class","manifest-field svelte-12doke6"),h(d,"class","manifest-label svelte-12doke6"),h(m,"class","manifest-value svelte-12doke6"),h(f,"class","manifest-field svelte-12doke6"),h(C,"class","manifest-label svelte-12doke6"),h(M,"class","manifest-value svelte-12doke6"),h(L,"class","manifest-field svelte-12doke6"),h(O,"class","manifest-label svelte-12doke6"),h(H,"class","manifest-value svelte-12doke6"),h(R,"class","manifest-field svelte-12doke6"),h(Me,"class","manifest-label svelte-12doke6"),h(D,"class","manifest-value svelte-12doke6"),h(X,"class","manifest-field svelte-12doke6"),h(re,"class","manifest-label svelte-12doke6"),h(Se,"class","manifest-value svelte-12doke6"),h(Ae,"class","manifest-field svelte-12doke6"),h(e,"class","manifest-content svelte-12doke6")},m(Ge,mt){_(Ge,e,mt),b(e,t),b(t,r),b(t,o),b(t,s),b(s,a),b(t,l),De&&De.m(t,null),b(e,u),b(e,f),b(f,d),b(f,p),b(f,m),b(m,g),b(e,I),b(e,L),b(L,C),b(L,S),b(L,M),b(M,U),b(e,K),b(e,R),b(R,O),b(R,q),b(R,H),b(H,ce),b(e,N),b(e,X),b(X,Me),b(X,Ie),b(X,D),b(D,de),b(e,Le),b(e,Ae),b(Ae,re),b(Ae,Z),b(Ae,Se),b(Se,Pe)},p(Ge,mt){mt[0]&2048&&i!==(i=Ge[11].version+"")&&J(a,i),mt[0]&3072&&(c=Ge[10]!==Ge[11].version&&!Ge[10].startsWith("v"+Ge[11].version)),c?De||(De=n1(Ge),De.c(),De.m(t,null)):De&&(De.d(1),De=null),mt[0]&2048&&y!==(y=Ge[11].name+"")&&J(g,y),mt[0]&2048&&E!==(E=Ge[11].author+"")&&J(U,E),mt[0]&2048&&G!==(G=Ge[11].description+"")&&J(ce,G),mt[0]&2048&&Q!==(Q=Ge[11].isDesktopOnly?"Yes":"No")&&J(de,Q),mt[0]&2048&&ae!==(ae=Ge[11].minAppVersion+"")&&J(Pe,ae)},d(Ge){Ge&&w(e),De&&De.d()}}}function n1(n){let e;return{c(){e=x("span"),e.innerHTML=`<span class="manifest-version-mismatch-icon svelte-12doke6">\u26A0\uFE0F</span>
|
|
Version mismatch`,h(e,"class","manifest-version-mismatch svelte-12doke6")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function wD(n){let e,t=n[1]?"Relay installer":"Relay releases",r,o,s,i,a,l,c,u,f=!n[1]&&K_(n);function d(y,g){return y[7]?sD:y[3].length===0?nD:y[8].length===0?oD:rD}let p=d(n,[-1,-1,-1]),m=p(n);return{c(){e=x("div"),r=V(t),o=T(),s=x("div"),i=x("div"),a=T(),l=x("div"),f&&f.c(),c=T(),m.c(),h(e,"class","modal-title"),h(i,"class","settings-spacer svelte-12doke6"),h(l,"class","settings-container svelte-12doke6"),h(s,"class","modal-content svelte-12doke6")},m(y,g){_(y,e,g),b(e,r),_(y,o,g),_(y,s,g),b(s,i),b(s,a),b(s,l),f&&f.m(l,null),b(s,c),m.m(s,null),u=!0},p(y,g){(!u||g[0]&2)&&t!==(t=y[1]?"Relay installer":"Relay releases")&&J(r,t),y[1]?f&&(ee(),k(f,1,1,()=>{f=null}),te()):f?(f.p(y,g),g[0]&2&&v(f,1)):(f=K_(y),f.c(),v(f,1),f.m(l,null)),p===(p=d(y,g))&&m?m.p(y,g):(m.d(1),m=p(y),m&&(m.c(),m.m(s,null)))},i(y){u||(v(f),u=!0)},o(y){k(f),u=!1},d(y){y&&(w(e),w(o),w(s)),f&&f.d(),m.d()}}}var s1="system3-relay";function os(n){return n.startsWith("v")?n.substring(1):n}function i1(n){return(n==null?void 0:n.prerelease)===!0}function _D(n,e,t){let r,o,s,i,a,l,c,u,f,d,p,m,y,g,I,L,{plugin:C}=e,{version:S}=e,M=ge(C.manifest.version),E=ge(!1),U=ge(""),K=ge(""),R=ge(!1);ne(n,R,oe=>t(7,c=oe));let O=ge(!1);ne(n,O,oe=>t(6,l=oe));let q=ge(null);ne(n,q,oe=>t(11,p=oe));let H=ge("");ne(n,H,oe=>t(10,d=oe));let G=ge(null),ce=ge(null);ne(n,ce,oe=>t(16,L=oe));let N=ge(!1);ne(n,N,oe=>t(15,I=oe));let X=ge(null);ne(n,X,oe=>t(5,s=oe));let Me=ge(null);ne(n,Me,oe=>t(4,o=oe));let Ie=ge(null);ne(n,Ie,oe=>t(53,a=oe));let D=ge(null);ne(n,D,oe=>t(52,i=oe));let Q=ge(!1),de=!1,Le=ge(null);ne(n,Le,oe=>t(14,g=oe));let Ae=C.app;function re(oe){let Ue=os(oe),ht=os(C.version);return Ue===ht}let Z=ge({});ne(n,Z,oe=>t(13,y=oe));let Se=ge({});ne(n,Se,oe=>t(12,m=oe));let ae=ge(C.releaseSettings.get().channel);ne(n,ae,oe=>t(9,f=oe)),st(()=>{mt(),Pe(),!S&&!r.some(oe=>{oe.tag_name,C.version})?ae.set(null):ae.set(C.releaseSettings.get().channel),q.set({version:S||C.version,name:C.manifest.name,author:C.manifest.author,description:C.manifest.description,isDesktopOnly:C.manifest.isDesktopOnly,minAppVersion:C.manifest.minAppVersion}),H.set(S||C.version)});function Pe(){return Ce(this,void 0,void 0,function*(){Q.set(!0);try{let oe=yield C.updateManager.fetchRepoManifest("manifest.json");oe&&(X.set(oe),Ie.set(oe.version));let Ue=yield C.updateManager.fetchRepoManifest("manifest-beta.json");Ue&&(Me.set(Ue),D.set(Ue.version))}catch(oe){C.error("Error fetching main branch manifests:",oe)}finally{Q.set(!1)}})}let De=et(C.updateManager,()=>C.updateManager.releases);ne(n,De,oe=>t(3,r=oe));let Ge=et([De,O],()=>r&&r.length>0?zr(l).sort():[]);ne(n,Ge,oe=>t(8,u=oe)),r.forEach(oe=>Ce(void 0,void 0,void 0,function*(){try{let Ue=yield C.updateManager.fetchReleaseManifest(oe);Ue&&Z.update(ht=>Object.assign(Object.assign({},ht),{[oe.tag_name]:Ue.version}))}catch(Ue){}}));function mt(){return Ce(this,void 0,void 0,function*(){R.set(!0);try{yield C.updateManager.getReleases(),zr(l)}catch(oe){C.error("Error refreshing GitHub releases:",oe)}finally{R.set(!1)}})}function _t(oe){return Ce(this,void 0,void 0,function*(){let Ue=document.createElement("div");return yield a1.MarkdownRenderer.render(C.app,oe,Ue,"",C),Ue.innerHTML})}function zr(oe){return oe?r:S?r.filter(Ue=>S===os(Ue.tag_name)):r.filter(Ue=>{let ht=Ue.tag_name;return co(Ue)})}function co(oe){if(oe.prerelease||oe.draft)return!1;if(oe.latest||os(oe.tag_name)===a||os(oe.tag_name)===i)return!0;let Ue=new Date(oe.created_at),ht=new Date;return ht.setMonth(ht.getMonth()-3),Ue>ht}function Fr(oe){return Ce(this,void 0,void 0,function*(){ce.set(null),G.set(oe);try{let Ue=It(oe);if(!Ue){ce.set(`Could not find release for ${oe}`);return}let ht=yield C.updateManager.fetchReleaseManifest(Ue);ht?(q.set(ht),H.set(oe),N.set(!1),Z.update(uo=>Object.assign(Object.assign({},uo),{[oe]:ht.version}))):ce.set(`Could not find manifest for ${oe}`)}catch(Ue){C.error("Error fetching manifest:",Ue),ce.set(`Error fetching manifest: ${Ue.message||"Unknown error"}`)}finally{G.set(null)}})}function xr(oe){let Ue=oe==="stable"?s:o;if(Ue){let ht=Ue.version;ae.set(oe);let uo=[...r.values()].find(wr=>os(wr.tag_name)===os(ht));uo?(oe==="stable"?Se.update(wr=>Object.assign(Object.assign({},wr),{[uo.tag_name]:"stable-alias"})):Se.update(wr=>Object.assign(Object.assign({},wr),{[uo.tag_name]:"beta-alias"})),Fr(uo.tag_name)):(q.set(Ue),H.set(ht),oe==="stable"?Se.update(wr=>Object.assign(Object.assign({},wr),{[ht]:"stable-alias"})):Se.update(wr=>Object.assign(Object.assign({},wr),{[ht]:"beta-alias"})),N.set(!1))}else ce.set(`Could not find ${oe} manifest`)}function Rt(){q.set(null),H.set(""),ce.set(null)}function It(oe){return[...r.values()].find(Ue=>Ue.tag_name===oe)}function Tn(oe){return Ce(this,void 0,void 0,function*(){try{Le.set(oe);let Ue=It(oe);if(!Ue)throw new Error(`Could not find release for ${oe}`);let ht=yield C.updateManager.fetchReleaseManifest(Ue);if(!ht)throw new Error(`Could not find manifest for ${oe}`);t(2,de=!0),yield Ae.plugins.installPlugin(C.repo,oe,ht),yield Ae.plugins.disablePlugin(s1),yield Ae.plugins.enablePlugin(s1)}catch(Ue){console.error(`Error installing version ${oe}:`,Ue),C&&C.error(`Error installing version ${oe}:`,Ue)}finally{C&&(t(2,de=!1),Le.set(null))}})}let Xo=oe=>re(oe.tag_name),Po=()=>{O.update(oe=>!oe)},en=oe=>{(oe.key==="Enter"||oe.key===" ")&&O.update(Ue=>!Ue)},Wr=()=>{C.releaseSettings.update(oe=>({...oe,channel:"stable"})),ae.set("stable"),xr("stable")},tn=oe=>{(oe.key==="Enter"||oe.key===" ")&&(C.releaseSettings.update(Ue=>({...Ue,channel:"stable"})),ae.set("stable"),xr("stable"))},ns=()=>{C.releaseSettings.update(oe=>({...oe,channel:"beta"})),ae.set("beta"),xr("beta")},Er=oe=>{(oe.key==="Enter"||oe.key===" ")&&(C.releaseSettings.update(Ue=>({...Ue,channel:"beta"})),ae.set("beta"),xr("beta"))},pe=()=>{ae.set(null),q.set({version:C.manifest.version,name:C.manifest.name,author:C.manifest.author,description:C.manifest.description,isDesktopOnly:C.manifest.isDesktopOnly,minAppVersion:C.manifest.minAppVersion}),H.set(C.version),N.set(!1)},qe=oe=>{(oe.key==="Enter"||oe.key===" ")&&(ae.set(null),q.set({version:C.manifest.version,name:C.manifest.name,author:C.manifest.author,description:C.manifest.description,isDesktopOnly:C.manifest.isDesktopOnly,minAppVersion:C.manifest.minAppVersion}),H.set(C.version),N.set(!1))},rt=oe=>{ae.set(null),Fr(oe.tag_name)},rr=(oe,Ue)=>{(Ue.key==="Enter"||Ue.key===" ")&&(ae.set(null),Fr(oe.tag_name))},rn=async()=>{Tn(d)};return n.$$set=oe=>{"plugin"in oe&&t(0,C=oe.plugin),"version"in oe&&t(1,S=oe.version)},[C,S,de,r,o,s,l,c,u,f,d,p,m,y,g,I,L,R,O,q,H,ce,N,X,Me,Ie,D,Le,re,Z,Se,ae,De,Ge,_t,Fr,xr,Rt,It,Tn,Xo,Po,en,Wr,tn,ns,Er,pe,qe,rt,rr,rn]}var uh=class extends z{constructor(e){super(),W(this,e,_D,wD,j,{plugin:0,version:1},eD,[-1,-1,-1])}},l1=uh;var ma=class extends c1.Modal{constructor(t,r,o){super(t);this.plugin=r;this.version=o}onOpen(){let{contentEl:t}=this;this.component=new l1({target:t,props:{plugin:this.plugin,version:this.version}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};var x1=require("obsidian");function SD(n){we(n,"svelte-1yric5k",".self-host-modal.svelte-1yric5k{padding:0 0 20px 0}.host-list-section.svelte-1yric5k{margin:16px 0}.public-key-section.svelte-1yric5k{margin:16px 0}.loading-message.svelte-1yric5k{background:var(--background-secondary);color:var(--text-muted);border:1px solid var(--background-modifier-border);border-radius:var(--radius-s);padding:12px;margin:16px 0;font-size:0.9em;text-align:center}.host-list.svelte-1yric5k{display:flex;flex-direction:column;margin-top:8px}.host-card.svelte-1yric5k{display:flex;align-items:center;padding:12px;margin:8px 0;border:1px solid var(--background-modifier-border);border-radius:var(--radius-s);background:var(--background-primary);cursor:pointer;transition:all 0.2s ease}.host-card.svelte-1yric5k:hover{background:var(--background-modifier-hover)}.host-card.active.svelte-1yric5k{border-color:var(--interactive-accent);background:var(--background-modifier-hover)}.host-info.svelte-1yric5k{display:flex;flex-direction:column;gap:4px;flex:1}.host-url.svelte-1yric5k{font-size:0.85em;color:var(--text-muted);font-family:var(--font-monospace)}.host-key-indicator.svelte-1yric5k{font-size:0.8em;color:var(--text-faint)}.add-host-card.svelte-1yric5k{border-style:dashed;opacity:0.8}.add-host-card.svelte-1yric5k:hover{opacity:1}.host-url-input.svelte-1yric5k{width:100%;border:none;background:transparent;color:var(--text-muted);font-size:0.85em;font-family:var(--font-monospace);padding:0;outline:none}.host-url-input.svelte-1yric5k:focus{color:var(--text-normal)}.host-url-input.svelte-1yric5k::placeholder{color:var(--text-faint);opacity:0.8}.host-input-invalid.svelte-1yric5k{color:var(--text-error) !important}.error-message.svelte-1yric5k{background:var(--background-secondary);color:var(--text-error);border:1px solid var(--text-error);border-radius:var(--radius-s);padding:12px;margin:16px 0;font-size:0.9em}.modal-button-container.svelte-1yric5k{display:flex;justify-content:flex-end;align-items:center;margin-top:24px;gap:12px}.loading-message.svelte-1yric5k{background:var(--background-secondary);color:var(--text-muted);border:1px solid var(--background-modifier-border);border-radius:var(--radius-s);padding:12px;margin:16px 0;font-size:0.9em;text-align:center}.error-message.svelte-1yric5k{background:var(--background-secondary);color:var(--text-error);border:1px solid var(--text-error);border-radius:var(--radius-s);padding:12px;margin:16px 0;font-size:0.9em}")}function u1(n,e,t){let r=n.slice();return r[30]=e[t],r}function f1(n,e,t){let r=n.slice();return r[33]=e[t],r}function d1(n){let e,t=n[0].user.name+"",r,o;return{c(){e=x("option"),r=V(t),o=V(" (Personal)"),e.__value="user",Ye(e,e.__value)},m(s,i){_(s,e,i),b(e,r),b(e,o)},p(s,i){i[0]&1&&t!==(t=s[0].user.name+"")&&J(r,t)},d(s){s&&w(e)}}}function p1(n){let e,t=n[33].name+"",r,o;return{c(){e=x("option"),r=V(t),e.__value=o=n[33].id,Ye(e,e.__value)},m(s,i){_(s,e,i),b(e,r)},p(s,i){i[0]&8&&t!==(t=s[33].name+"")&&J(r,t),i[0]&8&&o!==(o=s[33].id)&&(e.__value=o,Ye(e,e.__value))},d(s){s&&w(e)}}}function kD(n){let e,t,r,o,s,i,a=n[0].user&&d1(n),l=he(n[3]),c=[];for(let u=0;u<l.length;u+=1)c[u]=p1(f1(n,l,u));return{c(){e=x("select"),a&&a.c(),t=ue();for(let u=0;u<c.length;u+=1)c[u].c();h(e,"class","owner-select"),e.disabled=o=n[8]<=1},m(u,f){_(u,e,f),a&&a.m(e,null),b(e,t);for(let d=0;d<c.length;d+=1)c[d]&&c[d].m(e,null);_n(e,n[16]()),s||(i=$(e,"change",n[15]),s=!0)},p(u,f){if(u[0].user?a?a.p(u,f):(a=d1(u),a.c(),a.m(e,t)):a&&(a.d(1),a=null),f[0]&8){l=he(u[3]);let d;for(d=0;d<l.length;d+=1){let p=f1(u,l,d);c[d]?c[d].p(p,f):(c[d]=p1(p),c[d].c(),c[d].m(e,null))}for(;d<c.length;d+=1)c[d].d(1);c.length=l.length}f[0]&256&&o!==(o=u[8]<=1)&&(e.disabled=o)},d(u){u&&w(e),a&&a.d(),ze(c,u),s=!1,i()}}}function m1(n){let e,t=n[2].submit+"",r;return{c(){e=x("div"),r=V(t),h(e,"class","error-message svelte-1yric5k")},m(o,s){_(o,e,s),b(e,r)},p(o,s){s[0]&4&&t!==(t=o[2].submit+"")&&J(r,t)},d(o){o&&w(e)}}}function h1(n){let e;return{c(){e=x("div"),e.textContent="Legacy host",h(e,"class","host-key-indicator svelte-1yric5k")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function g1(n,e){let t,r,o,s=e[30].url+"",i,a,l,c,u,f=e[30].keyType==="legacy"&&h1(e);function d(){return e[22](e[30])}function p(...m){return e[23](e[30],...m)}return{key:n,first:null,c(){var m;t=x("div"),r=x("div"),o=x("div"),i=V(s),a=T(),f&&f.c(),l=T(),h(o,"class","host-url svelte-1yric5k"),h(r,"class","host-info svelte-1yric5k"),h(t,"class","host-card svelte-1yric5k"),h(t,"role","button"),h(t,"tabindex","0"),h(t,"title","Click to select this host"),_e(t,"active",((m=e[10])==null?void 0:m.id)===e[30].id),this.first=t},m(m,y){_(m,t,y),b(t,r),b(r,o),b(o,i),b(r,a),f&&f.m(r,null),b(t,l),c||(u=[$(t,"click",d),$(t,"keydown",p)],c=!0)},p(m,y){var g;e=m,y[0]&2049&&s!==(s=e[30].url+"")&&J(i,s),e[30].keyType==="legacy"?f||(f=h1(e),f.c(),f.m(r,null)):f&&(f.d(1),f=null),y[0]&3073&&_e(t,"active",((g=e[10])==null?void 0:g.id)===e[30].id)},d(m){m&&w(t),f&&f.d(),c=!1,me(u)}}}function y1(n){let e,t,r,o,s,i,a,l,c=[MD,LD,CD,ID],u=[];function f(d,p){return d[5]?0:d[6]?1:d[7]?2:3}return i=f(n,[-1,-1]),a=u[i]=c[i](n),{c(){e=x("div"),t=x("div"),t.textContent="Relay Server Configuration",r=T(),o=x("div"),o.textContent="Copy this configuration to your Relay Server's TOML file.",s=T(),a.c(),h(t,"class","setting-item-name"),h(o,"class","setting-item-description"),h(e,"class","public-key-section svelte-1yric5k")},m(d,p){_(d,e,p),b(e,t),b(e,r),b(e,o),b(e,s),u[i].m(e,null),l=!0},p(d,p){let m=i;i=f(d,p),i===m?u[i].p(d,p):(ee(),k(u[m],1,1,()=>{u[m]=null}),te(),a=u[i],a?a.p(d,p):(a=u[i]=c[i](d),a.c()),v(a,1),a.m(e,null))},i(d){l||(v(a),l=!0)},o(d){k(a),l=!1},d(d){d&&w(e),u[i].d()}}}function ID(n){let e;return{c(){e=x("div"),e.textContent="No configuration available",h(e,"class","error-message svelte-1yric5k")},m(t,r){_(t,e,r)},p:B,i:B,o:B,d(t){t&&w(e)}}}function CD(n){let e,t;return e=new Kc({props:{toml:n[7]}}),{c(){P(e.$$.fragment)},m(r,o){A(e,r,o),t=!0},p(r,o){let s={};o[0]&128&&(s.toml=r[7]),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 LD(n){let e,t;return{c(){e=x("div"),t=V(n[6]),h(e,"class","error-message svelte-1yric5k")},m(r,o){_(r,e,o),b(e,t)},p(r,o){o[0]&64&&J(t,r[6])},i:B,o:B,d(r){r&&w(e)}}}function MD(n){let e;return{c(){e=x("div"),e.textContent="Loading configuration...",h(e,"class","loading-message svelte-1yric5k")},m(t,r){_(t,e,r)},p:B,i:B,o:B,d(t){t&&w(e)}}}function TD(n){let e;return{c(){e=V("Create Relay Server")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function AD(n){let e;return{c(){e=V("Creating...")},m(t,r){_(t,e,r)},d(t){t&&w(e)}}}function FD(n){let e,t,r,o,s,i,a,l,c,u,f,d,p=[],m=new Map,y,g,I,L,C,S,M,E,U,K,R,O,q;o=new Re({props:{name:"Owner",description:"Select who will own this self-hosted relay server.",$$slots:{default:[kD]},$$scope:{ctx:n}}});let H=n[2].submit&&m1(n),G=he(n[11].values().filter(n[21])),ce=D=>D[30].id;for(let D=0;D<G.length;D+=1){let Q=u1(n,G,D),de=ce(Q);m.set(de,p[D]=g1(de,Q))}let N=!n[10]&&y1(n);function X(D,Q){return D[4]?AD:TD}let Me=X(n,[-1,-1]),Ie=Me(n);return{c(){e=x("div"),t=x("div"),t.innerHTML=`<p>Create a new self-hosted Relay Server. Select an existing host or add a
|
|
new one.</p>`,r=T(),P(o.$$.fragment),s=T(),H&&H.c(),i=T(),a=x("div"),l=x("div"),l.textContent="Relay Server URL",c=T(),u=x("div"),u.textContent=`This should be accessible to users within your private network, but not
|
|
exposed to the public internet.`,f=T(),d=x("div");for(let D=0;D<p.length;D+=1)p[D].c();y=T(),g=x("div"),I=x("div"),L=x("input"),S=T(),N&&N.c(),M=T(),E=x("div"),U=x("button"),Ie.c(),h(t,"class","setting-item-description"),se(t,"margin-bottom","16px"),h(l,"class","setting-item-name"),h(u,"class","setting-item-description"),h(L,"type","url"),h(L,"placeholder","https://relay.my-corp.ts.net"),h(L,"class","host-url-input svelte-1yric5k"),h(L,"title",C=n[2].url),_e(L,"host-input-invalid",n[2].url),h(I,"class","host-info svelte-1yric5k"),h(g,"class","host-card add-host-card svelte-1yric5k"),h(d,"class","host-list svelte-1yric5k"),h(a,"class","host-list-section svelte-1yric5k"),h(U,"class","mod-cta"),U.disabled=K=n[4]||!n[10]&&(!n[1].trim()||!!n[2].url),h(E,"class","modal-button-container svelte-1yric5k"),h(e,"class","self-host-modal svelte-1yric5k")},m(D,Q){_(D,e,Q),b(e,t),b(e,r),A(o,e,null),b(e,s),H&&H.m(e,null),b(e,i),b(e,a),b(a,l),b(a,c),b(a,u),b(a,f),b(a,d);for(let de=0;de<p.length;de+=1)p[de]&&p[de].m(d,null);b(d,y),b(d,g),b(g,I),b(I,L),Ye(L,n[1]),b(e,S),N&&N.m(e,null),b(e,M),b(e,E),b(E,U),Ie.m(U,null),R=!0,O||(q=[$(L,"click",n[24]),$(L,"input",n[25]),$(U,"click",n[14])],O=!0)},p(D,Q){let de={};Q[0]&265|Q[1]&32&&(de.$$scope={dirty:Q,ctx:D}),o.$set(de),D[2].submit?H?H.p(D,Q):(H=m1(D),H.c(),H.m(e,i)):H&&(H.d(1),H=null),Q[0]&11265&&(G=he(D[11].values().filter(D[21])),p=qr(p,Q,ce,1,D,G,m,d,Zs,g1,y,u1)),(!R||Q[0]&4&&C!==(C=D[2].url))&&h(L,"title",C),Q[0]&2&&L.value!==D[1]&&Ye(L,D[1]),(!R||Q[0]&4)&&_e(L,"host-input-invalid",D[2].url),D[10]?N&&(ee(),k(N,1,1,()=>{N=null}),te()):N?(N.p(D,Q),Q[0]&1024&&v(N,1)):(N=y1(D),N.c(),v(N,1),N.m(e,M)),Me!==(Me=X(D,Q))&&(Ie.d(1),Ie=Me(D),Ie&&(Ie.c(),Ie.m(U,null))),(!R||Q[0]&1046&&K!==(K=D[4]||!D[10]&&(!D[1].trim()||!!D[2].url)))&&(U.disabled=K)},i(D){R||(v(o.$$.fragment,D),v(N),R=!0)},o(D){k(o.$$.fragment,D),k(N),R=!1},d(D){D&&w(e),F(o),H&&H.d();for(let Q=0;Q<p.length;Q+=1)p[Q].d();N&&N.d(),Ie.d(),O=!1,me(q)}}}function b1(n){if(!n.trim())return"URL is required";try{let e=new URL(n);return["http:","https:"].includes(e.protocol)?void 0:"URL must use http or https protocol"}catch(e){return"Please enter a valid URL"}}function ED(n,e,t){let r,o,s,i,a,l=B,c=()=>(l(),l=Dt(r,D=>t(11,a=D)),r);n.$$.on_destroy.push(()=>l());let{onConfirm:u}=e,{relayManager:f}=e,d="",p=!1,m={},y=ge(null);ne(n,y,D=>t(10,i=D));let g=null,I=!1,L=!1,C=null,S="",M="",E=null;function U(){t(2,m={});let D=b1(d);return D&&t(2,m.url=D,m),Object.keys(m).length===0}function K(D){y.set(D)}function R(){y.set(null),t(1,d=""),t(2,m={})}function O(){return Ce(this,void 0,void 0,function*(){m.submit&&(delete m.submit,t(2,m),t(1,d),t(18,g));let D=(E==null?void 0:E.type)==="org"?E.org.id:void 0;if(i){t(4,p=!0);try{yield u(void 0,i.id,D)}catch(Q){t(2,m.submit=Q instanceof Error?Q.message:"Failed to create relay: Unknown error",m),t(2,m),t(1,d),t(18,g)}finally{t(4,p=!1)}}else{if(!U()||p)return;t(4,p=!0);try{yield u(d.trim(),void 0,D)}catch(Q){t(2,m.submit=Q instanceof Error?Q.message:"Failed to create relay: Unknown error",m),t(2,m),t(1,d),t(18,g)}finally{t(4,p=!1)}}})}function q(D){D.target.value==="user"&&f.user&&t(20,E={type:"user",user:f.user})}function H(){return E?E.type==="user"?"user":E.org.id:""}function G(){return Ce(this,void 0,void 0,function*(){if(!(f!=null&&f.pb)){t(6,C="Not connected to relay service");return}t(5,L=!0),t(6,C=null);try{let D=f.pb.baseUrl+"/templates/relay.toml",Q=yield at(D,{method:"GET",headers:{Authorization:f.pb.authStore.token?`Bearer ${f.pb.authStore.token}`:""}});t(19,M=yield Q.text())}catch(D){t(6,C=D instanceof Error?D.message:"Failed to fetch configuration")}finally{t(5,L=!1)}})}st(()=>{G();let D=f.providers.values().filter(Q=>Q.selfHosted&&f.relays.some((de,Le)=>de.providerId===Q.id));D.length>0&&y.set(D[0])});let ce=D=>D.selfHosted&&f.relays.some((Q,de)=>Q.providerId===D.id),N=D=>K(D),X=(D,Q)=>Q.key==="Enter"||Q.key===" "?K(D):null,Me=()=>K(null);function Ie(){d=this.value,t(1,d)}return n.$$set=D=>{"onConfirm"in D&&t(17,u=D.onConfirm),"relayManager"in D&&t(0,f=D.relayManager)},n.$$.update=()=>{n.$$.dirty[0]&1&&c(t(9,r=f.providers)),n.$$.dirty[0]&1048577&&!E&&f.user&&t(20,E={type:"user",user:f.user}),n.$$.dirty[0]&9&&t(8,s=(f.user?1:0)+o.length),n.$$.dirty[0]&262150&&(d.trim()?(I=!0,g&&clearTimeout(g),t(18,g=setTimeout(()=>{let D=b1(d);D?t(2,m.url=D,m):m.url&&(delete m.url,t(2,m),t(1,d),t(18,g))},500))):(m.url&&(delete m.url,t(2,m),t(1,d),t(18,g)),I=!1)),n.$$.dirty[0]&524290&&t(7,S=M?M.replace(/\{url\}/g,d||""):"")},t(3,o=[]),[f,d,m,o,p,L,C,S,s,r,i,a,y,K,O,q,H,u,g,M,E,ce,N,X,Me,Ie]}var fh=class extends z{constructor(e){super(),W(this,e,ED,FD,j,{onConfirm:17,relayManager:0},SD,[-1,-1])}},v1=fh;var iu=class extends x1.Modal{constructor(t,r,o){super(t);this.relayManager=r;this.onSuccess=o;this.setTitle("Self Host Relay Server")}onOpen(){let{contentEl:t}=this;this.component=new v1({target:t,props:{relayManager:this.relayManager,onConfirm:async(r,o,s)=>{let i=await this.relayManager.createSelfHostedRelay(r,o,s);this.close(),this.onSuccess(i)}}})}onClose(){var r;let{contentEl:t}=this;t.empty(),(r=this.component)==null||r.$destroy()}};var PD={debugging:!1},DD={release:{channel:"stable"},sharedFolders:[],endpoints:{},...Bi,...PD},au=class extends S1.Plugin{constructor(){super(...arguments);this.webviewerPatched=!1;this.openModals=[];this.interceptedUrls=[];this.fileDiffMergeWarningKey="file-diff-merge-warning";this.version="0.7.4";this.repo="No-Instructions/Relay"}enableDebugging(t){il(!0),console.warn("RelayInstances",Bt),t&&this.debugSettings.update(r=>({...r,debugging:!0}))}disableDebugging(t){il(!1),t&&this.debugSettings.update(r=>({...r,debugging:!1}))}toggleDebugging(t){let r=!this.debugSettings.get().debugging;return il(r),t&&this.debugSettings.update(o=>({...o,debugging:r})),r}buildApiUrl(t){return this.loginManager.getEndpointManager().getApiUrl()+t}openEndpointConfigurationModal(){new Zc(this.app,this,()=>{this.reload()}).open()}async validateAndApplyEndpoints(){var o;let t=this.endpointSettings.get();if(!t.activeTenantId||!((o=t.tenants)!=null&&o.length)){new tt.Notice("Please configure an enterprise tenant first",4e3);return}let r=new tt.Notice("Validating endpoints...",0);try{let s=await this.loginManager.validateAndApplyEndpoints();r.hide(),s.success?(await this.endpointSettings.update(i=>({...i,_lastValidationError:void 0,_lastValidationAttempt:void 0})),new tt.Notice("\u2713 Endpoints validated and applied successfully!",5e3),s.licenseInfo&&this.log("License validation successful:",s.licenseInfo)):(await this.endpointSettings.update(i=>({...i,_lastValidationError:s.error,_lastValidationAttempt:Date.now()})),new tt.Notice(`\u274C Validation failed: ${s.error}`,8e3))}catch(s){r.hide();let i=s instanceof Error?s.message:"Unknown error";await this.endpointSettings.update(a=>({...a,_lastValidationError:i,_lastValidationAttempt:Date.now()})),new tt.Notice(`\u274C Validation error: ${i}`,8e3)}}resetToDefaultEndpoints(){this.loginManager.getEndpointManager().clearValidatedEndpoints(),this.endpointSettings.update(()=>({})),new tt.Notice("Reset to default endpoints",3e3)}async validateEndpointsOnStartup(t){var s;let r=this.endpointSettings.get();if(!r.activeTenantId||!((s=r.tenants)!=null&&s.length)){this.log("No active enterprise tenant configured, using defaults");return}let o=r.tenants.find(i=>i.id===r.activeTenantId);if(!o){this.log("Active tenant not found, using defaults");return}this.log("Enterprise tenant configured, validating on startup...",{tenantId:o.id,tenantUrl:o.tenantUrl,tenantName:o.name});try{let i=await t.validateAndSetEndpoints(5e3);i.success?(await this.endpointSettings.update(a=>({...a,_lastValidationError:void 0,_lastValidationAttempt:void 0})),this.log("\u2713 Enterprise tenant validated and applied on startup",{licenseInfo:i.licenseInfo})):(this.error("\u274C Enterprise tenant validation failed on startup",i.error),await this.endpointSettings.update(a=>({...a,_lastValidationError:i.error,_lastValidationAttempt:Date.now()})),new tt.Notice(`\u274C Custom endpoints failed validation: ${i.error}`,8e3))}catch(i){let a=i instanceof Error?i.message:"Unknown error";this.error("Startup endpoint validation error:",a),await this.endpointSettings.update(l=>({...l,_lastValidationError:a,_lastValidationAttempt:Date.now()})),new tt.Notice(`\u274C Endpoint validation error: ${a}`,8e3)}}async onload(){this.appId=this.app.appId;let t=tt.moment.now();Bt.set(this,"plugin"),this.timeProvider=new Ds,this.register(()=>{this.timeProvider.destroy()});let r=(0,tt.normalizePath)(`${this.app.vault.configDir}/plugins/${this.manifest.id}/relay.log`);ky(new ru(this.app.vault),this.timeProvider,r,{maxFileSize:5*1024*1024,maxBackups:3,disableConsole:!1}),this.notifier=new tu,this.debug=Te("[System 3][Relay]","debug"),this.log=Te("[System 3][Relay]","log"),this.warn=Te("[System 3][Relay]","warn"),this.error=Te("[System 3][Relay]","error"),this.log("Plugin started",{version:this.manifest.version}),this.settings=new Bl(this,DD),await this.settings.load(),this.featureSettings=new Hr(this.settings,"(enable*)"),this.debugSettings=new Hr(this.settings,"(debugging)"),this.folderSettings=new Hr(this.settings,"sharedFolders"),this.releaseSettings=new Hr(this.settings,"release"),this.loginSettings=new Hr(this.settings,"login"),this.endpointSettings=new Hr(this.settings,"endpoints"),fr.getInstance().setSettings(this.featureSettings),this.settingsTab=new Qc(this.app,this),this.addRibbonIcon("satellite","Relay",()=>{this.openSettings()}),this.updateManager=new su(this,this.timeProvider,this.releaseSettings),this.register(this.debugSettings.subscribe(l=>{l.debugging?(this.enableDebugging(),this.removeCommand("enable-debugging"),this.addCommand({id:"toggle-feature-flags",name:"Show feature flags",callback:()=>{let c=new Xc(this.app,()=>{this.reload()});this.openModals.push(c),c.open()}}),this.addCommand({id:"send-bug-report",name:"Send bug report",callback:()=>{let c=new ou(this.app,this);this.openModals.push(c),c.open()}}),this.addCommand({id:"show-debug-info",name:"Show debug info",callback:()=>{let c=new eu(this.app,this);this.openModals.push(c),c.open()}}),this.addCommand({id:"show-release-manager",name:"Show releases",callback:()=>{let c=new ma(this.app,this);this.openModals.push(c),c.open()}}),this.addCommand({id:"analyze-indexeddb",name:"Analyze database",callback:()=>{let c=new nu(this.app,this);this.openModals.push(c),c.open()}}),this.addCommand({id:"disable-debugging",name:"Disable debugging",callback:()=>{this.disableDebugging(!0)}})):(this.removeCommand("toggle-feature-flags"),this.removeCommand("send-bug-report"),this.removeCommand("show-debug-info"),this.removeCommand("show-release-manager"),this.removeCommand("disable-debugging"),this.addCommand({id:"enable-debugging",name:"Enable debugging",callback:()=>{this.enableDebugging(!0)}}))}));let s=`async function() {
|
|
const app = window.app;
|
|
await app.plugins.disablePlugin("system3-relay");
|
|
await app.plugins.enablePlugin("system3-relay");
|
|
}`;this.app.reloadRelay=new Function("return "+s),this.addCommand({id:"reload",name:"Reload Relay",callback:this.app.reloadRelay()}),this.addCommand({id:"open-settings",name:"Open settings",callback:()=>{this.openSettings()}}),this.addCommand({id:"configure-endpoints",name:"Configure enterprise tenant",callback:()=>{this.openEndpointConfigurationModal()}}),He().enableSelfManageHosts&&this.addCommand({id:"register-host",name:"Register self-hosted Relay Server",callback:()=>{let l=new iu(this.app,this.relayManager,c=>{this.openSettings(`/relays?id=${c.id}`)});this.openModals.push(l),l.open()}}),this.register(this.updateManager.subscribe(()=>{let l=this.updateManager.getNewRelease();l?(this.removeCommand("update-plugin"),this.addCommand({id:"update-plugin",name:`Update Plugin (${this.version} \u2192 ${l.tag_name})`,callback:async()=>{await this.updateManager.installUpdate(l)}}),this.log(`Update available: v${this.version} \u2192 ${l.tag_name}`)):this.removeCommand("update-plugin")})),this.vault=this.app.vault;let i=this.vault.getName();this.fileManager=this.app.fileManager,this.hashStore=new zl(this.appId);let a=new Ml(this.endpointSettings);await this.validateEndpointsOnStartup(a),this.loginManager=new Al(this.vault.getName(),this.openSettings.bind(this),this.timeProvider,this.patchWebviewer.bind(this),this.loginSettings,a),this.relayManager=new Nl(this.loginManager),this.sharedFolders=new Yl(this.relayManager,this.vault,this._createSharedFolder.bind(this),this.folderSettings),this.tokenStore=new El(this.loginManager,this.timeProvider,i,3),this.networkStatus=new Ub(this.timeProvider,"https://api.system3.md/health?version=0.7.4"),this.backgroundSync=new Wl(this.loginManager,this.timeProvider,this.sharedFolders),this.loginManager.setup()||new tt.Notice("Please sign in to use relay"),this.app.workspace.onLayoutReady(()=>{this.sharedFolders.load(),this._liveViews=new Ac(this.app,this.sharedFolders,this.loginManager,this.networkStatus),this.registerEditorExtension(this._liveViews.extensions),this.register(this.loginManager.on(()=>{this.loginManager.loggedIn?this._onLogin():this._onLogout()})),this.tokenStore.start(),w1.Platform.isIosApp||(this.networkStatus.addEventListener("offline",()=>{this.tokenStore.stop(),this.sharedFolders.forEach(l=>l.disconnect()),this._liveViews.goOffline()}),this.networkStatus.addEventListener("online",()=>{this.tokenStore.start(),this.relayManager.subscribe(),this.relayManager.update(),this._liveViews.goOnline()}),this.networkStatus.start()),this.registerView(ti,l=>new Sc(l)),this.registerEvent(this.app.workspace.on("file-menu",(l,c)=>{if(c instanceof tt.TFolder){let u=this.sharedFolders.find(f=>f.path===c.path);if(!u)return;u.relayId?(l.addItem(f=>{f.setTitle("Relay: Relay settings").setIcon("gear").onClick(()=>{this.openSettings(`/relays?id=${u.relayId}`)})}),l.addItem(f=>{f.setTitle("Relay: Local folder settings").setIcon("gear").onClick(()=>{this.openSettings(`/shared-folders?id=${u.guid}`)})}),l.addItem(f=>{f.setTitle(u.connected?"Relay: Disconnect":"Relay: Connect").setIcon("satellite").onClick(()=>{u.connected?(u.shouldConnect=!1,u.disconnect()):(u.shouldConnect=!0,u.connect()),this._liveViews.refresh("folder connection toggle")})})):l.addItem(f=>{f.setTitle("Relay: Local folder settings").setIcon("gear").onClick(()=>{this.openSettings(`/shared-folders?id=${u.guid}`)})}),u.relayId&&u.connected&&l.addItem(f=>{f.setTitle("Relay: Sync").setIcon("folder-sync").onClick(()=>{u.netSync()})})}else if(c instanceof tt.TFile){let u=this.sharedFolders.lookup(c.path),f=u==null?void 0:u.getFile(c);f&&mr(f)&&(l.addItem(d=>{d.setTitle("Relay: Download").setIcon("cloud-download").onClick(async()=>{await f.pull(),new tt.Notice(`Download complete: ${f.name}`)})}),this.debugSettings.get().debugging&&l.addItem(d=>{d.setTitle("Relay: Verify upload").setIcon("search-check").onClick(async()=>{let p=await f.verifyUpload();new tt.Notice(`${f.name} ${p?"on server":"missing from server"}`)})}),l.addItem(d=>{d.setTitle("Relay: Upload").setIcon("cloud-upload").onClick(async()=>{await f.push(!0);let p=await f.verifyUpload();new tt.Notice(`${p?"File uploaded:":"File upload failed:"} ${f.name}`)})}))}})),this.setup(),this._liveViews.refresh("init"),this.loadTime=tt.moment.now()-t})}async reload(){this.app.reloadRelay()()}_createSharedFolder(t,r,o,s){let i=new Hr(this.settings,`sharedFolders/[guid=${r}]`),a={guid:r,path:t};return o&&(a.relay=o),i.update(c=>({...c,path:t,guid:r,...o?{relay:o}:{},sync:c.sync?c.sync:js.defaultFlags}),!0),new Jl(this.appId,r,t,this.loginManager,this.vault,this.fileManager,this.tokenStore,this.relayManager,this.hashStore,this.backgroundSync,i,o,s)}_onLogout(){var t,r;(t=this.tokenStore)==null||t.clear(),(r=this.relayManager)==null||r.logout(),this._liveViews.refresh("logout")}_onLogin(){var t;this.sharedFolders.load(),(t=this.relayManager)==null||t.login(),this._liveViews.refresh("login")}async openSettings(t="/"){let r=this.app.setting;await r.open(),await r.openTabById("system3-relay"),this.settingsTab.navigateTo(t)}patchWebviewer(){var r,o,s;let t=this;try{if(this.webviewerPatched)return;let i=(o=(r=this.app.internalPlugins)==null?void 0:r.plugins)==null?void 0:o.webviewer;if(!((s=i==null?void 0:i.instance)!=null&&s.options)||!i.enabled){this.warn("Webviewer plugin not found or not initialized");return}let a=i.instance.options,l=Object.getOwnPropertyDescriptor(a,"openExternalURLs");if(!l){this.warn("Could not find openExternalURLs property");return}Object.defineProperty(a,"openExternalURLs",{get(){var p;let d=window.event;if((d==null?void 0:d.type)==="open-url"&&((p=d==null?void 0:d.detail)!=null&&p.url)){let m=d.detail.url;for(let y of t.interceptedUrls)if(typeof y=="string"&&m.startsWith(y)||y instanceof RegExp&&y.test(m))return t.log("Intercepted webviewer, opening in default browser",d.detail.url),!1}return l.value},set(d){l.value=d},configurable:!0}),this.register(()=>{Object.defineProperty(a,"openExternalURLs",l)}),this.loginManager.getWebviewIntercepts().forEach(d=>{this.debug("Intercepting Webviewer for URL pattern",d.source),this.interceptedUrls.push(d)});let u=this.loginManager.getEndpointManager().getApiUrl(),f=new RegExp(u.replace("/","\\/")+".*");this.debug("Intercepting Webviewer for URL pattern",f.source),this.interceptedUrls.push(f),this.webviewerPatched=!0,this.debug("patched webviewer options")}catch(i){this.error("Failed to patch webviewer:",i)}}setup(){this.folderNavDecorations=new Pc(this.vault,this.app.workspace,this.sharedFolders,this.backgroundSync),this.folderNavDecorations.refresh(),this.addSettingTab(this.settingsTab);let t=Te("[Live][Workspace]","log");this.registerEvent(this.app.workspace.on("file-open",a=>{t("file-open"),i._liveViews.refresh("file-open")})),this.registerEvent(this.app.workspace.on("layout-change",()=>{t("layout-change"),this._liveViews.refresh("layout-change")}));let r=Te("[System 3][Relay][Vault]","log"),o=a=>{},s=a=>o(a);window.addEventListener("unhandledrejection",s,!0),this.register(()=>window.removeEventListener("unhandledrejection",s,!0)),this.registerEvent(this.app.vault.on("create",a=>{let l=this.sharedFolders.lookup(a.path);l&&(l.placeHold([a]).length>0?l.uploadFile(a):l.whenReady().then(u=>{u.getFile(a)}))})),this.registerEvent(this.app.vault.on("delete",a=>{if(a instanceof tt.TFolder){let c=this.sharedFolders.find(u=>u.path===a.path);if(c){this.sharedFolders.delete(c);return}}let l=this.sharedFolders.lookup(a.path);if(l){r("Delete",a.path);let c=l.getVirtualPath(a.path);l.markPendingDelete(c),l.whenReady().then(u=>{u.proxy.deleteFile(a.path)}).finally(()=>{l.clearPendingDelete(c)})}})),this.registerEvent(this.app.vault.on("rename",(a,l)=>{if(a instanceof tt.TFolder){let d=this.sharedFolders.find(p=>p.path==l);if(d){d.move(a.path),this.sharedFolders.update();return}}let c=this.sharedFolders.lookup(l),u=this.sharedFolders.lookup(a.path),f=c||u;c&&u?(r("Rename",a.path,l),c.renameFile(a,l),u.renameFile(a,l),this._liveViews.refresh("rename"),this.folderNavDecorations.quickRefresh()):f&&(r("Rename",a.path,l),f.renameFile(a,l),this._liveViews.refresh("rename"),this.folderNavDecorations.refresh())})),this.registerEvent(this.app.vault.on("modify",a=>{let l=this.sharedFolders.lookup(a.path);if(l){r("Modify",a.path);let c=l.proxy.getFile(a);c&&mr(c)&&c.sync(),this.timeProvider.setTimeout(()=>{this.app.metadataCache.trigger("resolve",c)},10)}}));let i=this;yr().patch(tt.MarkdownView.prototype,{onUnloadFile(a){return function(l){return i._liveViews.wipe(),a.call(this,l)}}}),yr().patch(this.app.vault,{process(a){return function(l,c,u){try{let f=i.sharedFolders.lookup(l.path);if(f){let d=f.proxy.getFile(l);l instanceof tt.TFile&&d&&so(d)&&d.process(c)}}catch(f){i.log(f)}return a.call(this,l,c,u)}}}),this.patchWebviewer(),mn(Vo.enableNewLinkFormat,()=>{yr().patch(tt.MetadataCache.prototype,{fileToLinktext(a){return function(l,c,u){if(i.sharedFolders.lookup(l.path)){u===void 0&&(u=!0);let d=l.extension==="md"&&u?l.basename:l.name,p=(0,tt.normalizePath)(l.name),m=i.app.metadataCache.uniqueFileLookup.get(p.toLowerCase());if(m&&m.length===1&&m[0]===l)return d;{let y=l.extension==="md"&&u?l.path.slice(0,l.path.length-3):l.path,g=(0,_1.relative)(c,y);return g==="../"+d?"./"+d:g}}return a.call(this,l,c,u)}}})}),this.registerObsidianProtocolHandler("relay/settings/relays",async a=>{let l=a,c=new URLSearchParams({...l}).toString(),u=`/${l.action.split("/").slice(-1)}?${c}`;this.openSettings(u)}),this.registerObsidianProtocolHandler("relay/settings/shared-folders",async a=>{let l=a,c=new URLSearchParams({...l}).toString(),u=`/${l.action.split("/").slice(-1)}?${c}`;this.openSettings(u)}),this.registerObsidianProtocolHandler("relay/upgrade",async a=>{var u;let c=(u=a.version)==null?void 0:u.trim();this.installVersion(c)}),this.backgroundSync.start(),this.updateManager.start()}installVersion(t){let r=new ma(this.app,this,t);this.app.setting.close(),this.openModals.push(r),r.open()}removeCommand(t){if((0,tt.requireApiVersion)("1.7.2"))super.removeCommand(t);else{let r=this.app,o=r.commands,s=`system3-relay:${t}`;(o.commands.hasOwnProperty(s)||r.hotkeyManager.removeDefaultHotkeys(s))&&(delete o.commands[s],delete o.editorCommands[s])}}onunload(){var t,r,o,s,i,a,l,c,u,f,d,p,m,y;aa.destroy(),(t=this.timeProvider)==null||t.destroy(),(r=this.folderNavDecorations)==null||r.destroy(),this.app.workspace.detachLeavesOfType(ti),this.updateManager&&(this.updateManager.destroy(),this.updateManager=null),(o=this._liveViews)==null||o.destroy(),this._liveViews=null,(s=this.relayManager)==null||s.destroy(),this.relayManager=null,(i=this.tokenStore)==null||i.stop(),(a=this.tokenStore)==null||a.clearState(),(l=this.tokenStore)==null||l.destroy(),this.tokenStore=null,(c=this.networkStatus)==null||c.stop(),(u=this.networkStatus)==null||u.destroy(),this.networkStatus=null,this.openModals.forEach(g=>{g.close()}),this.openModals.length=0,(f=this.sharedFolders)==null||f.destroy(),this.sharedFolders=null,(d=this.settingsTab)==null||d.destroy(),this.settingsTab=null,(p=this.loginManager)==null||p.destroy(),this.loginManager=null,(m=this.backgroundSync)==null||m.destroy(),this.backgroundSync=null,this.hashStore.destroy(),this.hashStore=null,(y=this.app)==null||y.workspace.updateOptions(),this.app.reloadRelay=void 0,this.app=null,this.fileManager=null,this.manifest=null,this.vault=null,this.debugSettings.destroy(),this.debugSettings=null,this.folderSettings.destroy(),this.folderSettings=null,fr.destroy(),this.featureSettings.destroy(),this.featureSettings=null,this.releaseSettings.destroy(),this.releaseSettings=null,this.loginSettings.destroy(),this.loginSettings=null,this.endpointSettings.destroy(),this.endpointSettings=null,this.interceptedUrls.length=0,Xr.destroy(),this.notifier=null,Ey(),If()}async loadSettings(){this.settings.load()}async saveSettings(){await this.settings.save()}};
|
|
/*! Bundled license information:
|
|
|
|
lucide-svelte/dist/defaultAttributes.js:
|
|
lucide-svelte/dist/icons/arrow-right-left.svelte:
|
|
lucide-svelte/dist/icons/arrow-right.svelte:
|
|
lucide-svelte/dist/icons/check.svelte:
|
|
lucide-svelte/dist/icons/chevron-left.svelte:
|
|
lucide-svelte/dist/icons/chevron-right.svelte:
|
|
lucide-svelte/dist/icons/circle-alert.svelte:
|
|
lucide-svelte/dist/icons/circle-check-big.svelte:
|
|
lucide-svelte/dist/icons/circle-help.svelte:
|
|
lucide-svelte/dist/icons/download.svelte:
|
|
lucide-svelte/dist/icons/folder-lock.svelte:
|
|
lucide-svelte/dist/icons/folder-open.svelte:
|
|
lucide-svelte/dist/icons/folder.svelte:
|
|
lucide-svelte/dist/icons/home.svelte:
|
|
lucide-svelte/dist/icons/info.svelte:
|
|
lucide-svelte/dist/icons/layers.svelte:
|
|
lucide-svelte/dist/icons/lock.svelte:
|
|
lucide-svelte/dist/icons/message-square-heart.svelte:
|
|
lucide-svelte/dist/icons/satellite.svelte:
|
|
lucide-svelte/dist/icons/settings.svelte:
|
|
lucide-svelte/dist/icons/square-pen.svelte:
|
|
lucide-svelte/dist/icons/triangle-alert.svelte:
|
|
lucide-svelte/dist/icons/user-round-x.svelte:
|
|
lucide-svelte/dist/icons/x.svelte:
|
|
lucide-svelte/dist/icons/index.js:
|
|
lucide-svelte/dist/aliases.js:
|
|
(**
|
|
* @license lucide-svelte v0.377.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*)
|
|
*/
|
|
|
|
/* nosourcemap */ |