/* 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 Yn=Object.create;var Te=Object.defineProperty,jn=Object.defineProperties,Qn=Object.getOwnPropertyDescriptor,Xn=Object.getOwnPropertyDescriptors,Jn=Object.getOwnPropertyNames,Re=Object.getOwnPropertySymbols,Zn=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty,er=Object.prototype.propertyIsEnumerable;var Zt=(e,r,t)=>r in e?Te(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,X=(e,r)=>{for(var t in r||(r={}))st.call(r,t)&&Zt(e,t,r[t]);if(Re)for(var t of Re(r))er.call(r,t)&&Zt(e,t,r[t]);return e},ne=(e,r)=>jn(e,Xn(r));var Ne=(e,r)=>{var t={};for(var o in e)st.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&Re)for(var o of Re(e))r.indexOf(o)<0&&er.call(e,o)&&(t[o]=e[o]);return t};var ut=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),eo=(e,r)=>{for(var t in r)Te(e,t,{get:r[t],enumerable:!0})},tr=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Jn(r))!st.call(e,s)&&s!==t&&Te(e,s,{get:()=>r[s],enumerable:!(o=Qn(r,s))||o.enumerable});return e};var ct=(e,r,t)=>(t=e!=null?Yn(Zn(e)):{},tr(r||!e||!e.__esModule?Te(t,"default",{value:e,enumerable:!0}):t,e)),to=e=>tr(Te({},"__esModule",{value:!0}),e);var K=(e,r,t)=>new Promise((o,s)=>{var a=v=>{try{p(t.next(v))}catch(P){s(P)}},h=v=>{try{p(t.throw(v))}catch(P){s(P)}},p=v=>v.done?o(v.value):Promise.resolve(v.value).then(a,h);p((t=t.apply(e,r)).next())});var qe=ut((zr,Mt)=>{(function(e){if(typeof zr=="object"&&typeof Mt!="undefined")Mt.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var r;typeof window!="undefined"?r=window:typeof global!="undefined"?r=global:typeof self!="undefined"?r=self:r=this,r.localforage=e()}})(function(){var e,r,t;return function o(s,a,h){function p(x,f){if(!a[x]){if(!s[x]){var m=typeof require=="function"&&require;if(!f&&m)return m(x,!0);if(v)return v(x,!0);var y=new Error("Cannot find module '"+x+"'");throw y.code="MODULE_NOT_FOUND",y}var _=a[x]={exports:{}};s[x][0].call(_.exports,function(b){var S=s[x][1][b];return p(S||b)},_,_.exports,o,s,a,h)}return a[x].exports}for(var v=typeof require=="function"&&require,P=0;P=43)}}).catch(function(){return!1})}function L(n){return typeof M=="boolean"?m.resolve(M):A(n).then(function(u){return M=u,M})}function z(n){var u=N[n.name],i={};i.promise=new m(function(l,d){i.resolve=l,i.reject=d}),u.deferredOperations.push(i),u.dbReady?u.dbReady=u.dbReady.then(function(){return i.promise}):u.dbReady=i.promise}function $(n){var u=N[n.name],i=u.deferredOperations.pop();if(i)return i.resolve(),i.promise}function Y(n,u){var i=N[n.name],l=i.deferredOperations.pop();if(l)return l.reject(u),l.promise}function G(n,u){return new m(function(i,l){if(N[n.name]=N[n.name]||Nt(),n.db)if(u)z(n),n.db.close();else return i(n.db);var d=[n.name];u&&d.push(n.version);var c=P.open.apply(P,d);u&&(c.onupgradeneeded=function(g){var E=c.result;try{E.createObjectStore(n.storeName),g.oldVersion<=1&&E.createObjectStore(C)}catch(I){if(I.name==="ConstraintError")console.warn('The database "'+n.name+'" has been upgraded from version '+g.oldVersion+" to version "+g.newVersion+', but the storage "'+n.storeName+'" already exists.');else throw I}}),c.onerror=function(g){g.preventDefault(),l(c.error)},c.onsuccess=function(){var g=c.result;g.onversionchange=function(E){E.target.close()},i(g),$(n)}})}function Z(n){return G(n,!1)}function oe(n){return G(n,!0)}function ie(n,u){if(!n.db)return!0;var i=!n.db.objectStoreNames.contains(n.storeName),l=n.versionn.db.version;if(l&&(n.version!==u&&console.warn('The database "'+n.name+`" can't be downgraded from version `+n.db.version+" to version "+n.version+"."),n.version=n.db.version),d||i){if(i){var c=n.db.version+1;c>n.version&&(n.version=c)}return!0}return!1}function Xe(n){return new m(function(u,i){var l=new FileReader;l.onerror=i,l.onloadend=function(d){var c=btoa(d.target.result||"");u({__local_forage_encoded_blob:!0,data:c,type:n.type})},l.readAsBinaryString(n)})}function ye(n){var u=k(atob(n.data));return f([u],{type:n.type})}function Rt(n){return n&&n.__local_forage_encoded_blob}function Yr(n){var u=this,i=u._initReady().then(function(){var l=N[u._dbInfo.name];if(l&&l.dbReady)return l.dbReady});return _(i,n,n),i}function jr(n){z(n);for(var u=N[n.name],i=u.forages,l=0;l0&&(!n.db||c.name==="InvalidStateError"||c.name==="NotFoundError"))return m.resolve().then(function(){if(!n.db||c.name==="NotFoundError"&&!n.db.objectStoreNames.contains(n.storeName)&&n.version<=n.db.version)return n.db&&(n.version=n.db.version+1),oe(n)}).then(function(){return jr(n).then(function(){ae(n,u,i,l-1)})}).catch(i);i(c)}}function Nt(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Qr(n){var u=this,i={db:null};if(n)for(var l in n)i[l]=n[l];var d=N[i.name];d||(d=Nt(),N[i.name]=d),d.forages.push(u),u._initReady||(u._initReady=u.ready,u.ready=Yr);var c=[];function g(){return m.resolve()}for(var E=0;E>4,D[d++]=(g&15)<<4|E>>2,D[d++]=(E&3)<<6|I&63;return T}function tt(n){var u=new Uint8Array(n),i="",l;for(l=0;l>2],i+=le[(u[l]&3)<<4|u[l+1]>>4],i+=le[(u[l+1]&15)<<2|u[l+2]>>6],i+=le[u[l+2]&63];return u.length%3===2?i=i.substring(0,i.length-1)+"=":u.length%3===1&&(i=i.substring(0,i.length-2)+"=="),i}function ln(n,u){var i="";if(n&&(i=$t.call(n)),n&&(i==="[object ArrayBuffer]"||n.buffer&&$t.call(n.buffer)==="[object ArrayBuffer]")){var l,d=Me;n instanceof ArrayBuffer?(l=n,d+=Ze):(l=n.buffer,i==="[object Int8Array]"?d+=kt:i==="[object Uint8Array]"?d+=Ot:i==="[object Uint8ClampedArray]"?d+=Ft:i==="[object Int16Array]"?d+=Bt:i==="[object Uint16Array]"?d+=zt:i==="[object Int32Array]"?d+=Ht:i==="[object Uint32Array]"?d+=Ut:i==="[object Float32Array]"?d+=Wt:i==="[object Float64Array]"?d+=Vt:u(new Error("Failed to get type for BinaryArray"))),u(d+tt(l))}else if(i==="[object Blob]"){var c=new FileReader;c.onload=function(){var g=cn+n.type+"~"+tt(this.result);u(Me+et+g)},c.readAsArrayBuffer(n)}else try{u(JSON.stringify(n))}catch(g){console.error("Couldn't convert value into a JSON string: ",n),u(null,g)}}function fn(n){if(n.substring(0,Je)!==Me)return JSON.parse(n);var u=n.substring(Kt),i=n.substring(Je,Kt),l;if(i===et&&Lt.test(u)){var d=u.match(Lt);l=d[1],u=u.substring(d[0].length)}var c=qt(u);switch(i){case Ze:return c;case et:return f([c],{type:l});case kt:return new Int8Array(c);case Ot:return new Uint8Array(c);case Ft:return new Uint8ClampedArray(c);case Bt:return new Int16Array(c);case zt:return new Uint16Array(c);case Ht:return new Int32Array(c);case Ut:return new Uint32Array(c);case Wt:return new Float32Array(c);case Vt:return new Float64Array(c);default:throw new Error("Unkown type: "+i)}}var rt={serialize:ln,deserialize:fn,stringToBuffer:qt,bufferToString:tt};function Gt(n,u,i,l){n.executeSql("CREATE TABLE IF NOT EXISTS "+u.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],i,l)}function dn(n){var u=this,i={db:null};if(n)for(var l in n)i[l]=typeof n[l]!="string"?n[l].toString():n[l];var d=new m(function(c,g){try{i.db=openDatabase(i.name,String(i.version),i.description,i.size)}catch(E){return g(E)}i.db.transaction(function(E){Gt(E,i,function(){u._dbInfo=i,c()},function(I,T){g(T)})},g)});return i.serializer=rt,d}function fe(n,u,i,l,d,c){n.executeSql(i,l,d,function(g,E){E.code===E.SYNTAX_ERR?g.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[u.storeName],function(I,T){T.rows.length?c(I,E):Gt(I,u,function(){I.executeSql(i,l,d,c)},c)},c):c(g,E)},c)}function pn(n,u){var i=this;n=b(n);var l=new m(function(d,c){i.ready().then(function(){var g=i._dbInfo;g.db.transaction(function(E){fe(E,g,"SELECT * FROM "+g.storeName+" WHERE key = ? LIMIT 1",[n],function(I,T){var D=T.rows.length?T.rows.item(0).value:null;D&&(D=g.serializer.deserialize(D)),d(D)},function(I,T){c(T)})})}).catch(c)});return y(l,u),l}function hn(n,u){var i=this,l=new m(function(d,c){i.ready().then(function(){var g=i._dbInfo;g.db.transaction(function(E){fe(E,g,"SELECT * FROM "+g.storeName,[],function(I,T){for(var D=T.rows,R=D.length,U=0;U0){g(Yt.apply(d,[n,I,i,l-1]));return}E(U)}})})}).catch(E)});return y(c,i),c}function mn(n,u,i){return Yt.apply(this,[n,u,i,1])}function _n(n,u){var i=this;n=b(n);var l=new m(function(d,c){i.ready().then(function(){var g=i._dbInfo;g.db.transaction(function(E){fe(E,g,"DELETE FROM "+g.storeName+" WHERE key = ?",[n],function(){d()},function(I,T){c(T)})})}).catch(c)});return y(l,u),l}function vn(n){var u=this,i=new m(function(l,d){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(g){fe(g,c,"DELETE FROM "+c.storeName,[],function(){l()},function(E,I){d(I)})})}).catch(d)});return y(i,n),i}function yn(n){var u=this,i=new m(function(l,d){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(g){fe(g,c,"SELECT COUNT(key) as c FROM "+c.storeName,[],function(E,I){var T=I.rows.item(0).c;l(T)},function(E,I){d(I)})})}).catch(d)});return y(i,n),i}function gn(n,u){var i=this,l=new m(function(d,c){i.ready().then(function(){var g=i._dbInfo;g.db.transaction(function(E){fe(E,g,"SELECT key FROM "+g.storeName+" WHERE id = ? LIMIT 1",[n+1],function(I,T){var D=T.rows.length?T.rows.item(0).key:null;d(D)},function(I,T){c(T)})})}).catch(c)});return y(l,u),l}function bn(n){var u=this,i=new m(function(l,d){u.ready().then(function(){var c=u._dbInfo;c.db.transaction(function(g){fe(g,c,"SELECT key FROM "+c.storeName,[],function(E,I){for(var T=[],D=0;D '__WebKitDatabaseInfoTable__'",[],function(d,c){for(var g=[],E=0;E0}function Pn(n){var u=this,i={};if(n)for(var l in n)i[l]=n[l];return i.keyPrefix=jt(n,u._defaultConfig),Tn()?(u._dbInfo=i,i.serializer=rt,m.resolve()):m.reject()}function Dn(n){var u=this,i=u.ready().then(function(){for(var l=u._dbInfo.keyPrefix,d=localStorage.length-1;d>=0;d--){var c=localStorage.key(d);c.indexOf(l)===0&&localStorage.removeItem(c)}});return y(i,n),i}function xn(n,u){var i=this;n=b(n);var l=i.ready().then(function(){var d=i._dbInfo,c=localStorage.getItem(d.keyPrefix+n);return c&&(c=d.serializer.deserialize(c)),c});return y(l,u),l}function Mn(n,u){var i=this,l=i.ready().then(function(){for(var d=i._dbInfo,c=d.keyPrefix,g=c.length,E=localStorage.length,I=1,T=0;T=0;g--){var E=localStorage.key(g);E.indexOf(c)===0&&localStorage.removeItem(E)}}):d=m.reject("Invalid arguments"),y(d,u),d}var Fn={_driver:"localStorageWrapper",_initStorage:Pn,_support:Cn(),iterate:Mn,getItem:xn,setItem:kn,removeItem:Ln,clear:Dn,length:Nn,key:An,keys:Rn,dropInstance:On},Bn=function(u,i){return u===i||typeof u=="number"&&typeof i=="number"&&isNaN(u)&&isNaN(i)},Hn=function(u,i){for(var l=u.length,d=0;d{(function(e,r){typeof Ge=="object"&&typeof Ur!="undefined"?r(Ge,qe()):typeof define=="function"&&define.amd?define(["exports","localforage"],r):r(e.localforageGetItems=e.localforageGetItems||{},e.localforage)})(Ge,function(e,r){"use strict";r="default"in r?r.default:r;function t(_){return t.result?t.result:!_||typeof _.getSerializer!="function"?Promise.reject(new Error("localforage.getSerializer() was not available! localforage v1.4+ is required!")):(t.result=_.getSerializer(),t.result)}function o(_,b){return b&&_.then(function(S){b(null,S)},function(S){b(S)}),_}function s(_,b){var S=this,C=S.getItem(_).then(function(M){return{key:_,value:M}});return o(C,b),C}function a(_){var b=this,S=new Promise(function(C,M){for(var N=[],H=0,O=_.length;HN?1:0}var C=new Promise(function(M,N){b.ready().then(function(){var H=b._dbInfo,O=H.db.transaction(H.storeName,"readonly").objectStore(H.storeName),w=_.sort(S),k=v.bound(_[0],_[_.length-1],!1,!1),A=O.openCursor(k),L={},z=0;A.onsuccess=function(){var $=A.result;if(!$){M(L);return}for(var Y=$.key;Y>w[z];)if(z++,z===w.length){M(L);return}if(Y===w[z]){var G=$.value;G===void 0&&(G=null),L[Y]=G,$.continue()}else $.continue(w[z])},A.onerror=function(){N(A.error)}}).catch(N)});return C}function x(_){var b=this,S=new Promise(function(C,M){b.ready().then(function(){return t(b)}).then(function(N){var H=b._dbInfo;H.db.transaction(function(O){for(var w=new Array(_.length),k=0,A=_.length;k{(function(e,r){typeof Ye=="object"&&typeof Vr!="undefined"?r(Ye,qe()):typeof define=="function"&&define.amd?define(["exports","localforage"],r):r(e.localforageSetItems=e.localforageSetItems||{},e.localforage)})(Ye,function(e,r){"use strict";r="default"in r?r.default:r;function t(f){return t.result?t.result:!f||typeof f.getSerializer!="function"?Promise.reject(new Error("localforage.getSerializer() was not available! localforage v1.4+ is required!")):(t.result=f.getSerializer(),t.result)}function o(f,m){m&&f.then(function(y){m(null,y)},function(y){m(y)})}function s(f,m,y,_){function b(O,w){var k=O||w;return(!O||typeof O!="function")&&typeof k=="string"&&(O=function(L){return L[k]}),O}var S=[];if(Object.prototype.toString.call(f)==="[object Array]"){m=b(m,"key"),y=b(y,"value");for(var C=0,M=f.length;CQe,extractValue:()=>Gr});module.exports=to(Ao);function Le(e,r){let t=Object.keys(r).map(o=>ro(e,o,r[o]));return t.length===1?t[0]:function(){t.forEach(o=>o())}}function ro(e,r,t){let o=e[r],s=e.hasOwnProperty(r),a=t(o);return o&&Object.setPrototypeOf(a,o),Object.setPrototypeOf(h,a),e[r]=h,p;function h(...v){return a===o&&e[r]===h&&p(),a.apply(this,v)}function p(){e[r]===h&&(s?e[r]=o:delete e[r]),a!==o&&(a=o,Object.setPrototypeOf(h,o||Function))}}var ce=require("obsidian");var Hr=require("obsidian");var Be,F,ar,no,me,rr,sr,lt,ur,be={},cr=[],oo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,He=Array.isArray;function de(e,r){for(var t in r)e[t]=r[t];return e}function lr(e){var r=e.parentNode;r&&r.removeChild(e)}function pt(e,r,t){var o,s,a,h={};for(a in r)a=="key"?o=r[a]:a=="ref"?s=r[a]:h[a]=r[a];if(arguments.length>2&&(h.children=arguments.length>3?Be.call(arguments,2):t),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)h[a]===void 0&&(h[a]=e.defaultProps[a]);return ke(e,h,o,s,null)}function ke(e,r,t,o,s){var a={type:e,props:r,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:s==null?++ar:s,__i:-1};return s==null&&F.vnode!=null&&F.vnode(a),a}function fr(){return{current:null}}function se(e){return e.children}function Ee(e,r){this.props=e,this.context=r}function Pe(e,r){if(r==null)return e.__?Pe(e.__,e.__i+1):null;for(var t;rr&&me.sort(lt));Oe.__r=0}function pr(e,r,t,o,s,a,h,p,v,P,x){var f,m,y,_,b,S,C,M,N,H=0,O=o&&o.__k||cr,w=O.length,k=w,A=r.length;for(t.__k=[],f=0;f0?ke(_.type,_.props,_.key,_.ref?_.ref:null,_.__v):_)!=null?(_.__=t,_.__b=t.__b+1,_.__i=f,(M=io(_,O,C=f+H,k))===-1?y=be:(y=O[M]||be,O[M]=void 0,k--),mt(e,_,y,s,a,h,p,v,P,x),b=_.__e,(m=_.ref)&&y.ref!=m&&(y.ref&&_t(y.ref,null,_),x.push(m,_.__c||b,_)),S==null&&b!=null&&(S=b),(N=y===be||y.__v===null)?M==-1&&H--:M!==C&&(M===C+1?H++:M>C?k>A-C?H+=M-C:H--:H=M(v!=null?1:0))for(;h>=0||p=0){if((v=r[h])&&s==v.key&&a===v.type)return h;h--}if(p=t.__.length&&t.__.push({__V:ze}),t.__[e]}function J(e){return We=1,co(Dr,e)}function co(e,r,t){var o=De(_e++,2);if(o.t=e,!o.__c&&(o.__=[t?t(r):Dr(void 0,r),function(p){var v=o.__N?o.__N[0]:o.__[0],P=o.t(v,p);v!==P&&(o.__N=[P,o.__[1]],o.__c.setState({}))}],o.__c=q,!q.u)){var s=function(p,v,P){if(!o.__c.__H)return!0;var x=o.__c.__H.__.filter(function(m){return m.__c});if(x.every(function(m){return!m.__N}))return!a||a.call(this,p,v,P);var f=!1;return x.forEach(function(m){if(m.__N){var y=m.__[0];m.__=m.__N,m.__N=void 0,y!==m.__[0]&&(f=!0)}}),!(!f&&o.__c.props===p)&&(!a||a.call(this,p,v,P))};q.u=!0;var a=q.shouldComponentUpdate,h=q.componentWillUpdate;q.componentWillUpdate=function(p,v,P){if(this.__e){var x=a;a=void 0,s(p,v,P),a=x}h&&h.call(this,p,v,P)},q.shouldComponentUpdate=s}return o.__N||o.__}function pe(e,r){var t=De(_e++,3);!F.__s&&bt(t.__H,r)&&(t.__=e,t.i=r,q.__H.__h.push(t))}function Tr(e,r){var t=De(_e++,4);!F.__s&&bt(t.__H,r)&&(t.__=e,t.i=r,q.__h.push(t))}function ue(e){return We=5,lo(function(){return{current:e}},[])}function lo(e,r){var t=De(_e++,7);return bt(t.__H,r)?(t.__V=e(),t.i=r,t.__h=e,t.__V):t.__}function Pr(e){var r=q.context[e.__c],t=De(_e++,9);return t.c=e,r?(t.__==null&&(t.__=!0,r.sub(q)),r.props.value):e.__}function fo(){for(var e;e=Ir.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ue),e.__H.__h.forEach(gt),e.__H.__h=[]}catch(r){e.__H.__h=[],F.__e(r,e.__v)}}F.__b=function(e){q=null,gr&&gr(e)},F.__r=function(e){br&&br(e),_e=0;var r=(q=e.__c).__H;r&&(yt===q?(r.__h=[],q.__h=[],r.__.forEach(function(t){t.__N&&(t.__=t.__N),t.__V=ze,t.__N=t.i=void 0})):(r.__h.forEach(Ue),r.__h.forEach(gt),r.__h=[],_e=0)),yt=q},F.diffed=function(e){Er&&Er(e);var r=e.__c;r&&r.__H&&(r.__H.__h.length&&(Ir.push(r)!==1&&yr===F.requestAnimationFrame||((yr=F.requestAnimationFrame)||po)(fo)),r.__H.__.forEach(function(t){t.i&&(t.__H=t.i),t.__V!==ze&&(t.__=t.__V),t.i=void 0,t.__V=ze})),yt=q=null},F.__c=function(e,r){r.some(function(t){try{t.__h.forEach(Ue),t.__h=t.__h.filter(function(o){return!o.__||gt(o)})}catch(o){r.some(function(s){s.__h&&(s.__h=[])}),r=[],F.__e(o,t.__v)}}),wr&&wr(e,r)},F.unmount=function(e){Sr&&Sr(e);var r,t=e.__c;t&&t.__H&&(t.__H.__.forEach(function(o){try{Ue(o)}catch(s){r=s}}),t.__H=void 0,r&&F.__e(r,t.__v))};var Cr=typeof requestAnimationFrame=="function";function po(e){var r,t=function(){clearTimeout(o),Cr&&cancelAnimationFrame(r),setTimeout(e)},o=setTimeout(t,100);Cr&&(r=requestAnimationFrame(t))}function Ue(e){var r=q,t=e.__c;typeof t=="function"&&(e.__c=void 0,t()),q=r}function gt(e){var r=q;e.__c=e.__(),q=r}function bt(e,r){return!e||e.length!==r.length||r.some(function(t,o){return t!==e[o]})}function Dr(e,r){return typeof r=="function"?r(e):r}var ho=0;function B(e,r,t,o,s,a){var h,p,v={};for(p in r)p=="ref"?h=r[p]:v[p]=r[p];var P={type:e,props:v,key:t,ref:h,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--ho,__i:-1,__source:s,__self:a};if(typeof e=="function"&&(h=e.defaultProps))for(p in h)v[p]===void 0&&(v[p]=h[p]);return F.vnode&&F.vnode(P),P}var xr=vr(null),te=()=>{let e=Pr(xr);if(e===null)throw new Error("useAppMount() called without a in the tree.");return e};function Et(e){return B(xr.Provider,{value:X({},e),children:e.children})}var Or=require("obsidian");var wt=2,Ve=class extends Ee{constructor(t){super(t);this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this);let{breakpointCols:o}=t,s;typeof o=="number"?s=o:o&&o.hasOwnProperty("default")?s=o.default:s=wt,this.ref=fr(),this.resizeObserver=null,this.state={columnCount:s}}componentDidMount(){this.reCalculateColumnCount(),this.resizeObserver=new ResizeObserver(()=>{this.reCalculateColumnCountDebounce()});let t=this.ref.current;this.resizeObserver.observe(t)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect()}reCalculateColumnCountDebounce(){if(!window||!window.requestAnimationFrame){this.reCalculateColumnCount();return}window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})}reCalculateColumnCount(){let t=this.ref.current&&this.ref.current.offsetWidth||1/0,{breakpointCols:o}=this.props;if(t===1/0)return;typeof o=="number"&&(o={default:o||wt});let s=1/0,a=(o==null?void 0:o.default)||wt;for(let h in o){let p=parseInt(h);p>0&&t<=p&&ppt("div",ne(X({},v),{key:x}),P))}logDeprecated(t){console.error("[Masonry]",t)}render(){let x=this.props,{children:t,breakpointCols:o,columnClassName:s,columnAttrs:a,column:h,className:p}=x,v=Ne(x,["children","breakpointCols","columnClassName","columnAttrs","column","className"]),P=p;return typeof p!="string"&&(this.logDeprecated('The property "className" requires a string'),typeof p=="undefined"&&(P="my-masonry-grid")),B("div",ne(X({},v),{ref:this.ref,className:P,children:this.renderColumns()}))}};Ve.defaultProps={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0};var Mr=Ve;function we(e){let h=e,{file:r}=h,t=Ne(h,["file"]),{app:o,sourcePath:s}=te(),a=p=>{let v=p.altKey&&(p.ctrlKey||p.metaKey)?"split":p.ctrlKey||p.metaKey?"tab":!1;r&&o.workspace.openLinkText(r.path,s,v)};return B("div",ne(X({},t),{className:"note-card",onClick:a,children:e.children}))}var Nr=require("obsidian");var Se=require("obsidian");var St=(e,r)=>{e!==null&&r!==null&&(e&&!e.firstChild?e.appendChild(r):e.firstChild&&e.firstChild!==r&&e.replaceChild(r,e.firstChild))},mo=(e,r,t,o)=>K(void 0,null,function*(){let s=document.createElement("div");s.style.height="100%",s.style.width="100%";try{t instanceof Se.MarkdownRenderChild&&(yield Se.MarkdownRenderer.render(e,o,s,r,t))}catch(a){console.error(a)}return s}),_o=e=>{let r=new DOMParser,t=document.createElement("div"),o=r.parseFromString(e,"text/html"),s=Array.from(o.body.children);for(let a of s)t.appendChild(a);return t.style.height="100%",t.style.width="100%",t},Ar=(e,r)=>{let{app:t,db:o,component:s,sourcePath:a}=te(),h=ue(null),p=ue(null),[v,P]=J(!1),[x,f]=J(!0);return Tr(()=>{K(void 0,null,function*(){let m=null;if(e.rendered&&e.innerHTML)m=_o(e.innerHTML);else if(e.hasMarkdown&&e.markdown&&e.markdownMobile){let y=Se.Platform.isDesktopApp?e.markdown:e.markdownMobile;if(m=yield mo(t,a,s,y),!m.innerHTML.includes("pdf-embed")&&!m.innerHTML.includes("pdf-viewer")&&!m.innerHTML.includes("block-language-note-gallery")){let _=ne(X({},e),{rendered:!0,innerHTML:m.innerHTML});o.storeKey(r.path,_,r.stat.mtime,!1)}f(!1)}m&&m.innerHTML&&(p.current=m,h.current&&St(h.current,m),P(!0))})},[e,a]),{containerRef:h,renderRef:p,rendered:v,cached:x}},Rr=(e,r)=>e.vault.adapter.getResourcePath(r);function Ke(e,{threshold:r=0,root:t=null,rootMargin:o="0%",freezeOnceVisible:s=!1}){let[a,h]=J(),p=(a==null?void 0:a.isIntersecting)&&s,v=([P])=>{h(P)};return pe(()=>{let P=e==null?void 0:e.current;if(!!!window.IntersectionObserver||p||!P)return;let f={threshold:r,root:t,rootMargin:o},m=new IntersectionObserver(v,f);return m.observe(P),()=>m.disconnect()},[e,r,t,o,p]),a}function Ct(e){let{db:r,settings:t}=te(),{file:o}=e,s=r.getItem(o.path),{data:a}=s,{containerRef:h,renderRef:p,rendered:v,cached:P}=Ar(a,o),x=ue(null),f=Ke(x,{rootMargin:"33%",freezeOnceVisible:!0}),m=!!(f!=null&&f.isIntersecting);return B(se,{children:B("div",{ref:x,children:[t.showtitle&&B("hr",{style:{borderTop:P?"":"1px solid var(--interactive-accent)"}}),B("div",{style:{opacity:m?1:0,transition:"opacity ease-in 100ms"},className:"card-content-container",ref:y=>{a.hasMarkdown&&a.markdown!==""&&v&&m&&(h.current=y,St(y,p.current))},children:B("div",{style:{opacity:0,whiteSpace:"pre-wrap"},children:Nr.Platform.isDesktopApp?a.text:a.textMobile})})]})})}function It(e){let{settings:r}=te(),{file:t}=e;return B(se,{children:[r.showtitle&&B("div",{className:"inline-title",children:t.basename}),B("div",{className:"card-content",children:[B("div",{className:"card-content-wall"}),B(Ct,{file:t})]})]})}function Tt(e){let{hasMore:r,loadMore:t}=e,o=ue(null),s=Ke(o,{}),a=!!(s!=null&&s.isIntersecting);return pe(()=>{r&&a&&t()},[a,r,t]),B("div",{ref:o,children:r&&B(we,{children:[B("h1",{children:"Hold on a second..."}),B("h6",{children:"There are more files!"})]})})}var ve=require("obsidian");var vo=["jpeg","jpg","gif","png","webp","tiff","tif","md"],Lr=(e,r=!1)=>e.reduce((t,o)=>(r&&o instanceof ve.TFolder?t=t.concat(Lr(o.children,!0)):o instanceof ve.TFile&&t.push(o),t),[]),yo=(e,r)=>{let{vault:t}=e,o=t;return o.getAbstractFileByPathInsensitive?o.getAbstractFileByPathInsensitive(r):t.getAbstractFileByPath(r)},go=(e,r)=>{let t=null,o=yo(e,r.path);return o instanceof ve.TFolder?{files:Lr(o.children,r.recursive),error:t}:(r.path&&r.path!==""&&(t="The folder specified in `path` doesn't exist!"),{files:[],error:t})};function bo(e,r){let t=r;for(let o=0;o>>0}function Eo(e,r){return e.map(t=>({item:t,sortKey:bo(t.path,r)})).sort((t,o)=>t.sortKey-o.sortKey).map(({item:t})=>t)}var wo=(e,r,t,o,s=50)=>{let a=e.filter(p=>p.path!==t&&vo.includes(p.extension)).filter(p=>{if(p.extension!=="md")return!0;let v=r.getItem(p.path);if(!v)return!1;let{data:P}=v;return!P.markdown||!P.hasMarkdown?!1:!(P.markdown.contains("```note-gallery")||P.markdown.contains("~~~note-gallery"))}).sort((p,v)=>{let P=o.sortby==="name"?p.name.toUpperCase():p.stat[o.sortby],x=o.sortby==="name"?v.name.toUpperCase():v.stat[o.sortby],f=o.sort==="asc"?-1:1;return Px?f*-1:0}),h=o.sortrandom===!0?Eo(a,s):a;return o.limit===0?h:h.splice(0,o.limit)},So=e=>{switch(`${e.sortby}:${e.sort}`){case"mtime:desc":return"byModifiedTime";case"mtime:asc":return"byModifiedTimeReverse";case"ctime:desc":return"byCreatedTime";case"ctime:asc":return"byCreatedTimeReverse";case"name:desc":return"alphabeticalReverse";case"name:asc":return"alphabetical";default:return"byModifiedTime"}},Co=(e,r)=>{if(!!e){if(r.debugquery)e.el.style.maxHeight="300px",e.el.style.padding="10px",e.el.style.marginBottom="12px",e.el.style.border="1px solid var(--background-modifier-border)",e.el.style.borderRadius="5px";else{e.el.style.height="8px";let t=e.el.firstChild;t&&t.remove()}e.el.style.removeProperty("display")}},kr=()=>{let{app:e,db:r,sourcePath:t,settings:o,embeddedSearch:s}=te(),[a,h]=J(null),[p,v]=J([]),P=ue(Math.floor(Math.random()*1e5)),x=100;return pe(()=>{let f=()=>{let{files:S,error:C}=go(e,o);return C?(h(C),[]):S},m=S=>{let C=s==null?void 0:s.dom;if(!C||!C.parent)return[];if(!S||!S.parent)return[];if(!S.parent.sourcePath||S.parent.sourcePath!==C.parent.sourcePath)return[];let M=So(o);C.setSortOrder&&C.sortOrder!==M&&C.setSortOrder(M);let N=S!=null&&S.resultDomLookup?S.resultDomLookup:C==null?void 0:C.resultDomLookup;return N?Array.from(N.keys()):[]},y=(S,C)=>{C&&Co(S,o);let M=[...p,...f(),...m(S)],N=[...new Map(M.map(O=>[O.path,O])).values()],H=wo(N,r,t,o,P.current);H.length&&v(H)};p.length||y(s==null?void 0:s.dom,!0);let _=(0,ve.debounce)(y,x,!0),b=()=>_(s==null?void 0:s.dom,!0);return e.workspace.on("search:onChange",_),r.on("database-update",b),()=>{e.workspace.off("search:onChange",_),r.off("database-update",b)}}),{error:a,files:p}};var Io=({error:e})=>B("p",{style:{borderRadius:"4px",padding:"2px 16px",backgroundColor:"#e50914",color:"#fff",fontWeight:"bolder"},children:["(Error) Note Gallery: ",e]});function Pt(){let{app:e,settings:r}=te(),t=Or.Platform.isDesktopApp?100:10,{error:o,files:s}=kr(),[a,h]=J(!0),[p,v]=J(t),P=()=>{p>=s.length?h(!1):setTimeout(()=>{v(p+t)},100)},x=f=>{let m=[];for(let y=0;y0&&B(Mr,{breakpointCols:r.breakpoints,className:"masonry-grid",columnClassName:"masonry-grid_column",children:[x(s),B(Tt,{hasMore:a,loadMore:P})]})]})}function Dt({app:e,plugin:r,component:t,containerEl:o,searchEl:s,sourcePath:a,settings:h,db:p}){let[v,P]=J(!1),[x,f]=J(void 0);return pe(()=>{o.style.setProperty("--note-card-font-size",h.fontsize);let m=b=>{if(!x){let S=t.addChild(new b(e,s,h.query,a));f(S)}},y=()=>{v||P(!0),r.EmbeddedSearch&&m(r.EmbeddedSearch)},_=()=>{v&&P(!1)};return p.ready&&y(),p.on("database-update",y),p.on("database-drop",_),e.workspace.on("catchEmbeddedSearch",m),()=>{p.off("database-update",y),p.off("database-drop",_),e.workspace.off("catchEmbeddedSearch",m)}}),B(Et,{app:e,component:t,sourcePath:a,db:p,embeddedSearch:x,settings:h,children:[!v&&B("div",{children:B("h1",{children:"Note Gallery: Indexing Database..."})}),v&&B(Pt,{})]})}var $e=require("obsidian");var To=(e,r)=>{let t=e.createEl("div");t.createEl("p",{text:`(Error) Note Gallery: ${r}`}),t.style.borderRadius="var(--callout-radius)",t.style.padding="var(--callout-padding)",t.style.backgroundColor="var(--background-modifier-error)",t.style.color="var(--text-on-accent-inverted)",t.style.fontWeight="var(--font-bold)"},xt=To;var Po={path:"",query:"",limit:0,recursive:!0,sort:"desc",sortby:"mtime",sortrandom:!1,fontsize:"6pt",showtitle:!0,debugquery:!1,breakpoints:{default:4,1e5:10,3500:10,3100:9,2700:8,2300:7,1900:6,1500:5,1e3:4,700:3,400:2,200:1}},Fr=(e,r=!1)=>Object.keys(e).reduce((t,o)=>(t[o.toLowerCase()]=r&&typeof e[o]=="object"?Fr(e[o]):e[o],t),{}),Do=(e,r,t,o)=>{let s;try{s=(0,$e.parseYaml)(e)}catch(h){let p="Cannot parse YAML!";throw h instanceof Error&&(p=h.message),xt(t,p),h}if(s===void 0){let h="Cannot parse YAML!";throw xt(t,h),new Error(h)}s!==null&&(s=Fr(s));let a=X(X({},Po),s);if(s===null||!s.path&&!s.query){let h=r.vault.getAbstractFileByPath(o.sourcePath).parent;a.path=h.path}return a.path&&(a.path=(0,$e.normalizePath)(a.path)),a.path||(a.path=""),a.query||(a.query=""),a},Br=Do;var xe=class extends Hr.MarkdownRenderChild{constructor(t,o,s,a,h){super(s);this.plugin=t;this.src=o;this.containerEl=s;this.app=a;this.ctx=h;this.settings=Br(o,a,s,h)}onload(){return K(this,null,function*(){this.searchEl=this.containerEl.createEl("div"),this.reactEl=this.containerEl.createEl("div"),this.searchEl.style.display="none",this.searchEl.style.overflowY="scroll",this.plugin.EmbeddedSearch||(yield this.plugin.triggerEmbeddedSearchPatch()),vt(B(Dt,{app:this.app,plugin:this.plugin,component:this,containerEl:this.reactEl,searchEl:this.searchEl,sourcePath:this.ctx.sourcePath,settings:this.settings,db:this.plugin.db}),this.reactEl)})}onunload(){return K(this,null,function*(){vt(null,this.reactEl)})}};var he=ct(qe()),re=require("obsidian"),$r=ct(Wr()),qr=ct(Kr());(0,qr.extendPrototype)(he.default);(0,$r.extendPrototype)(he.default);var At=class extends re.Events{constructor(){super(...arguments);this._events=[]}onunload(){}unload(){for(;this._events.length>0;)this._events.pop()()}register(t){this._events.push(t)}registerEvent(t){this.register(()=>t.e.offref(t))}},je=class extends At{constructor(t,o,s,a,h,p,v,P=2,x=f=>f){super();this.plugin=t;this.name=o;this.title=s;this.version=a;this.description=h;this.defaultValue=p;this.extractValue=v;this.workers=P;this.loadValue=x;this.memory=new Map;this.deleted_keys=new Set;this.ready=!1;this.databaseUpdate=(0,re.debounce)(()=>{this.trigger("database-update",this.allEntries()),this.flushChanges()},100,!0);this.flushChanges=(0,re.debounce)(()=>K(this,null,function*(){yield this.persistMemory(),this.trigger("database-update",this.allEntries())}),1e3,!0);let f=this.plugin.app.loadLocalStorage(o+"-version"),m=f?parseInt(f):null;this.persist=he.default.createInstance({name:this.name+`/${this.plugin.app.appId}`,driver:he.default.INDEXEDDB,description:h,version:a}),this.plugin.app.workspace.onLayoutReady(()=>K(this,null,function*(){yield this.persist.ready(()=>K(this,null,function*(){yield this.loadDatabase(),this.trigger("database-update",this.allEntries());let y=m!==null&&mK(this,null,function*(){var C;if(S instanceof re.TFile&&S.extension==="md"){let M=this.plugin.app.workspace.activeEditor,N=M&&((C=M.file)==null?void 0:C.path)===S.path&&M.editor?M.editor.cm.state:void 0,H=yield this.plugin.app.vault.cachedRead(S);this.storeKey(S.path,yield this.extractValue(H,S,N),S.stat.mtime)}}))),this.registerEvent(this.plugin.app.vault.on("delete",S=>K(this,null,function*(){S instanceof re.TFile&&S.extension==="md"&&this.deleteKey(S.path)}))),this.registerEvent(this.plugin.app.vault.on("rename",(S,C)=>K(this,null,function*(){S instanceof re.TFile&&S.extension==="md"&&this.renameKey(C,S.path,S.stat.mtime)}))),this.registerEvent(this.plugin.app.vault.on("create",S=>K(this,null,function*(){S instanceof re.TFile&&S.extension==="md"&&this.storeKey(S.path,this.defaultValue(),S.stat.mtime)})))}))}))}on(t,o,s){return super.on(t,o,s)}loadDatabase(){return K(this,null,function*(){this.memory=new Map(Object.entries(yield this.persist.getItems()).map(([t,o])=>(o.data=this.loadValue(o.data),[t,o])))})}regularParseFiles(t,o){return K(this,null,function*(){for(let s=0;s{s.some(p=>p.path===h)||this.deleteKey(h)});let a=s.filter(h=>!this.memory.has(h.path)||this.memory.get(h.path).mtimeK(this,null,function*(){return yield this.persist.removeItem(o)}))),this.deleted_keys.clear()})}createNotice(t,o){let s=new DocumentFragment,a=s.createEl("div"),h=s.createEl("div",{cls:"commentator-progress-bar"}),p=new re.Notice(s,0),v=h.createEl("progress");return a.textContent=`${t} ${o} database...`,{progress_bar:v,notice:p}}initializeProgressBar(t,o){t.setAttribute("max",o.toString()),t.setAttribute("value","0")}storeKey(t,o,s,a=!0){this.memory.set(t,{data:o,mtime:s!=null?s:Date.now(),dirty:a}),this.databaseUpdate()}deleteKey(t){if(this.getItem(t)==null)throw new Error("Key does not exist");this.memory.delete(t),this.deleted_keys.add(t),this.databaseUpdate()}renameKey(t,o,s){let a=this.getItem(t);if(a==null)throw new Error("Key does not exist");this.storeKey(o,a.data,s),this.deleteKey(t),this.databaseUpdate()}allKeys(){return Array.from(this.memory.keys())}getValue(t){var o,s;return(s=(o=this.memory.get(t))==null?void 0:o.data)!=null?s:null}allValues(){return Array.from(this.memory.values()).map(t=>t.data)}getItem(t){var o;return(o=this.memory.get(t))!=null?o:null}allItems(){return Array.from(this.memory.values())}allEntries(){return Array.from(this.memory.entries())}dropDatabase(){return K(this,null,function*(){this.trigger("database-drop"),this.memory.clear(),yield he.default.dropInstance({name:this.name+`/${this.plugin.app.appId}`}),localStorage.removeItem(this.plugin.app.appId+"-"+this.name+"-version")})}reinitializeDatabase(){return K(this,null,function*(){yield this.dropDatabase(),this.persist=he.default.createInstance({name:this.name+`/${this.plugin.app.appId}`,driver:he.default.INDEXEDDB,version:this.version,description:this.description});let t="Initializing",{progress_bar:o,notice:s}=this.createNotice(t,this.title);yield this.rebuildDatabase(o,s),this.trigger("database-update",this.allEntries())})}clearDatabase(){return K(this,null,function*(){this.trigger("database-drop"),this.memory.clear(),yield this.persist.clear()})}isEmpty(){return this.memory.size===0}};var xo={text:null,textMobile:null,markdown:null,markdownMobile:null,innerHTML:null,hasMarkdown:!1,rendered:!1};function Gr(e,r,t){return K(this,null,function*(){let a="";if(e.startsWith("---")){let P=e.indexOf("---",3);a=e.slice(0,P+3).trim(),e=e.slice(P+3,e.length).trim()}let h=e.split(` `).slice(0,200).join(` `),p=e.split(` `).slice(0,30).join(` `);e=[a,h].join(` `).trim();let v=[a,p].join(` `).trim();return{text:h,textMobile:p,markdown:e,markdownMobile:v,hasMarkdown:!0,innerHTML:null,rendered:!1}})}function Mo(e){return(e.innerHTML||e.rendered)&&(e=ne(X({},e),{innerHTML:null,rendered:!1})),e}var Qe=class extends ce.Plugin{constructor(){super(...arguments);this.EmbeddedSearchLeafInitializer=null;this.EmbeddedSearch=null;this.isEmbeddedSearchPatched=!1}onload(){return K(this,null,function*(){this.db=this.registerDb(),this.patchCatchEmbeddedSearch(),this.registerMarkdownCodeBlockProcessor("note-gallery",(t,o,s)=>K(this,null,function*(){let a=new xe(this,t,o,this.app,s);s.addChild(a)})),this.addCommand({id:"drop-database",name:"Drop all cache and re-initialize database",callback:()=>{this.db.reinitializeDatabase()}})})}onunload(){return K(this,null,function*(){})}registerDb(){return new je(this,"render-store","Render Store",6,"Stores text and renderedHTML of a file to be rendered by the note gallery",()=>xo,Gr,2,Mo)}patchCatchEmbeddedSearch(){let t=this;t.register(Le(ce.Component.prototype,{addChild(o){return function(s,...a){try{if(s instanceof ce.Component&&s.hasOwnProperty("searchQuery")&&s.hasOwnProperty("sourcePath")&&s.hasOwnProperty("dom")){let p=s;t.EmbeddedSearch||(t.EmbeddedSearch=p.constructor,t.app.workspace.trigger("catchEmbeddedSearch",p.constructor)),t.EmbeddedSearchLeafInitializer&&setTimeout(()=>{var v;(v=t.EmbeddedSearchLeafInitializer)==null||v.detach(),t.EmbeddedSearchLeafInitializer=null},100),t.isEmbeddedSearchPatched||(t.patchEmbeddedSearch(p),t.isEmbeddedSearchPatched=!0)}}catch(p){console.log({type:"Patching CatchEmbeddedSearch Error",err:p})}return o.call(this,s,...a)}}}))}patchEmbeddedSearch(t){let o=this,s=t.dom.constructor;this.register(Le(t.constructor.prototype,{onload(a){return function(...h){try{this.dom&&(this.dom.parent=this)}catch(p){console.log({type:"Patching EmbeddedSearch Error",err:p})}return a.call(this,...h)}}})),o.patchEmbeddedSearchDOM(s)}patchEmbeddedSearchDOM(t){let o=this;o.register(Le(t.prototype,{startLoader(s){return function(...a){var h,p;try{!this.patched&&((h=this.el.parentElement)==null?void 0:h.hasClass("block-language-note-gallery"))&&((p=this.el)==null?void 0:p.closest(".block-language-note-gallery"))&&(this.patched=!0,this.setSortOrder=v=>{console.log(`Note Gallery: Setting native search sort order ${v}`),this.sortOrder=v,this.changed(),this.infinityScroll.invalidateAll()})}catch(v){console.log({type:"Patching EmbeddedSearchDOM.startLoader Error",err:v})}return s.call(this,...a)}},addResult(s){return function(a,h,p,...v){let P;return p.contains("note-gallery")?(P=s.call(this,a,h,p.replace("note-gallery","note-gallery".toUpperCase().replace("-","_")),...v),P):(P=s.call(this,a,h,p,...v),P)}},onChange(s){return function(...a){try{o.app.workspace.trigger("search:onChange",this)}catch(h){console.log({type:"Patching EmbeddedSearchDOM.onChange Error",err:h})}return s.call(this,...a)}}}))}triggerEmbeddedSearchPatch(){return K(this,null,function*(){let t=new ce.WorkspaceSplit(this.app.workspace,"vertical"),o=this.EmbeddedSearchLeafInitializer=this.attachLeaf(t),s=new ce.MarkdownView(o);s.setViewData("```query\n```",!0),yield o.open(s);let a=o.getViewState();a.state.source=!1,o.setViewState(a)})}attachLeaf(t){return t.getRoot=()=>this.app.workspace.rootSplit,t.getContainer=()=>this.app.workspace.rootSplit,this.app.workspace.createLeafInParent(t,0)}}; /*! localForage -- Offline Storage, Improved Version 1.10.0 https://localforage.github.io/localForage (c) 2013-2017 Mozilla, Apache License 2.0 */ /* nosourcemap */