"use strict";varYL=Object.defineProperty;varUL=(e,t,n)=>tine?YL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;varSe=(e,t,n)=>(UL(e,typeoft!="symbol"?t+"":t,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});constx=require("obsidian"),vS=require("@codemirror/language"),Zg=require("@codemirror/state"),Wl=require("@codemirror/view");functionzL(e,t){for(varn=0;n<t.length;n++){constr=t[n];if(typeofr!="string"&&!Array.isArray(r)){for(constainr)if(a!=="default"&&!(aine)){consto=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}returnObject.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}vardr=typeofglobalThis<"u"?globalThis:typeofwindow<"u"?window:typeofglobal<"u"?global:typeofself<"u"?self:{};functionqt(e){returne&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}varYN={exports:{}},pg={},UN={exports:{}},gn={},EC;functionVL(){if(EC)returngn;EC=1;vare=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.iterator;functiony(X){returnX===null||typeofX!="object"?null:(X=g&&X[g]||X["@@iterator"],typeofX=="function"?X:null)}varw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,D={};functionI(X,ae,De){this.props=X,this.context=ae,this.refs=D,this.updater=De||w}I.prototype.isReactComponent={},I.prototype.setState=function(X,ae){if(typeofX!="object"&&typeofX!="function"&&X!=null)throwError("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,X,ae,"setState")},I.prototype.forceUpdate=function(X){this.updater.enqueueForceUpdate(this,X,"forceUpdate")};functionM(){}M.prototype=I.prototype;functionN(X,ae,De){this.props=X,this.context=ae,this.refs=D,this.updater=De||w}varR=N.prototype=newM;R.constructor=N,S(R,I.prototype),R.isPureReactComponent=!0;vark=Array.isArray,B=Object.prototype.hasOwnProperty,L={current:null},_={key:!0,ref:!0,__self:!0,__source:!0};functionV(X,ae,De){varje,Re={},Fe=null,Be=null;if(ae!=null)for(jeinae.ref!==void0&&(Be=ae.ref),ae.key!==void0&&(Fe=""+ae.key),ae)B.call(ae,je)&&!_.hasOwnProperty(je)&&(Re[je]=ae[je]);varXe=arguments.length-2;if(Xe===1)Re.children=De;elseif(1<Xe){for(varZe=Array(Xe),st=0;st<Xe;st++)Ze[st]=arguments[st+2];Re.children=Ze}if(X&&X.defaultProps)for(jeinXe=X.defaultProps,Xe)Re[je]===void0&&(Re[je]=Xe[je]);return{$$typeof:e,type:X,key:Fe,ref:Be,props:Re,_owner:L.current}}functionY(X,ae){return{$$typeof:e,type:X.type,key:ae,ref:X.ref,props:X.props,_owner:X._owner}}functionZ(X){returntypeofX=="object"&&X!==null&&X.$$typeof===e}functionQ(X){varae={"=":"=0",":":"=2"};return"$"+X.replace(/[=:]/g,function(De){returnae[De]})}varK=/\/+/g;functionse(X,ae){returntypeofX=="object"&&X!==null&&X.key!=null?Q(""+X.key):ae.toString(36)}functionle(X,ae,De,je,Re){varFe=typeofX;(Fe==="undefined"||Fe==="boolean")&&(X=null);varBe=!1;if(X===null)Be=!0;elseswitch(Fe){case"string":case"number":Be=!0;break;case"object":switch(X.$$typeof){casee:caset:Be=!0}}if(Be)returnBe=X,Re=Re(Be),X=je===""?"."+se(Be,0):je,k(Re)?(De="",X!=null&&(De=X.replace(K,"$&/")+"/"),le(Re,ae,De,"",function(st){returnst})):Re!=null&&(Z(Re)&&(Re=Y(Re,De+(!Re.key||Be&&Be.key===Re.key?"":(""+Re.key).replace(K,"$&/")+"/")+X)),ae.push(Re)),1;if(Be=0,je=je===""?".":je+":",k(X))for(varXe=0;Xe<X.length;Xe++){Fe=X[Xe];varZe=je+se(Fe,Xe);Be+=le(Fe,ae,De,Ze,Re)}elseif(Ze=y(X),typeofZe=="function")for(X=Ze.call(X),Xe=0;!(Fe=X.next()).done;)Fe=Fe.value,Ze=je+se(Fe,Xe++),Be+=le(Fe,ae,De,Ze,Re);elseif(Fe==="object")throwae=String(X),Error("O
`),f[w].blockId=y.id}}});const h=Object.keys(f).map(y=>({line:f[y].content,blockId:f[y].blockId||"",index:parseInt(y)}));return e.path.includes("2024-04-07"),h}async function ER(e,t){let n=t.vault.getAbstractFileByPath(e);return n||(new x.Notice(E("File not found for the given thino path, is creating a new file")),n=await t.vault.create(e,'{"nodes": [], "edges": []}'),dt.setChangedByMemos(!0)),n}async function CR(e,t){var a;let n;try{n=await t.vault.read(e)}catch(o){console.error(o),n=await t.vault.cachedRead(e)}const r=(a=t.metadataCache.getFileCache(e))==null?void 0:a.frontmatterPosition;return r?n.slice(r.end.offset+1):n}function xR(e){const t=e.split(/\r?\n/),n=[];let r="",a=[],o=0;for(let i=0;i<t.length;i++){const l=t[i];l.startsWith("#")?(r&&n.push({header:r,content:a.join(`
`);t.push(n.slice(0,r)),n=n.slice(r+1)}return t.push(n),t}async function e_({content:e,isList:t,name:n}){var N;const r=Le.getState().dailyNotesState.settings,a=x.moment(),o=ut.randomId(16),i=(r==null?void 0:r.MemoOtherSaveLocation.MemoDefaultMultiFilePath)||"Thino",l=n||`${a.format("YYYYMMDD")}-${o}`,c=`${i}/${l}.md`,f={id:o,content:e,deletedAt:"",path:c,createdAt:a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:a.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"MULTI",fileInfo:{tags:[],frontmatter:{}}},h=ft.getState().app||window.app,{vault:g,fileManager:y}=h,w=g.getAbstractFileByPath(i);(!w||!(w instanceof x.TFolder))&&(new x.Notice(E("Folder not found for the given thino path, is creating a new folder")),await g.createFolder(i)),dt.setChangedByMemos(!0);let S;const D=h.vault.getFileByPath(c);D?S=await g.create(`${i}/${a.format("YYYYMMDD")}-${o}.md`,e):S=await g.create(c,e),await y.processFrontMatter(S,R=>{R.id=o,R.createdAt=a.format("YYYY/MM/DD HH:mm:ss"),R.updatedAt=a.format("YYYY/MM/DD HH:mm:ss"),R.thinoType=t?"JOURNAL":"TASK-TODO"}),(!n||D)&&(r!=null&&r.SetFileNameAfterCreate)&&h.fileManager.promptForFileRename(S);const I=h.metadataCache.getFileCache(S),M={tags:((N=I==null?void 0:I.frontmatter)==null?void 0:N.tags)||[],frontmatter:(I==null?void 0:I.frontmatter)||{}};return{...f,fileInfo:M}}async function t_({content:e,isList:t}){var R;const n=Le.getState().dailyNotesState.settings,r=x.moment(),a=ut.randomId(16),o=(n==null?void 0:n.MemoOtherSaveLocation.MemoDefaultSingleFilePath)||"basic.thino.md",i={id:a,content:e,deletedAt:"",path:o,createdAt:r.format("YYYY/MM/DD HH:mm:ss"),updatedAt:r.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"FILE",fileInfo:{tags:[],frontmatter:{}}},l=ft.getState().app,{vault:c}=l;let f=c.getAbstractFileByPath(o);(!f||!(f instanceof x.TFile))&&(new x.Notice(E("File not found for the given thino path, is creating a new file")),f=await c.create(o,""));const h=l.metadataCache.getFileCache(f),g={tags:((R=h==null?void 0:h.frontmatter)==null?void 0:R.tags)||[],frontmatter:(h==null?void 0:h.frontmatter)||{}};let y="";try{y=await c.read(f)||await c.cachedRead(f)}catch(k){console.error(k),new x.Notice(E("Failed to read current daily note, check if it exists."))}const w=y.indexOf(`#${r.format("YYYY-MM-DD")}`);let S=y.indexOf(`
${y.substring(S)}`}else N=`${y.substring(0,S)}${M}${y.substring(S)}`;return setTimeout(async()=>{dt.setChangedByMemos(!0),await c.modify(f,N)},200),{...i,fileInfo:g}}async function PC(e){var N;const t=Le.getState().dailyNotesState.settings,n=x.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss"),r=e.id,a=(t==null?void 0:t.MemoOtherSaveLocation.MemoDefaultSingleFilePath)||"basic.thino.md",o={id:r,content:e.content,deletedAt:e.deletedAt||"",path:a,createdAt:n.format("YYYY/MM/DD HH:mm:ss"),updatedAt:n.format("YYYY/MM/DD HH:mm:ss"),thinoType:"JOURNAL",hasId:"",linkId:"",pinned:e.pinned,visibility:"PUBLIC",rowStatus:e.rowStatus||"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"FILE",webId:e.id,fileInfo:e==null?void 0:e.fileInfo},i=ft.getState().app,{vault:l}=i;let c=l.getAbstractFileByPath(a);(!c||!(c instanceof x.TFile))&&(new x.Notice(E("File not found for the given thino path, is creating a new file")),c=await l.create(a,""));let f="";try{f=await l.read(c)||await l.cachedRead(c)}catch(R){console.error(R),new x.Notice(E("Failed to read current daily note, check if it exists."))}const h=i.metadataCache.getFileCache(c),g={tags:((N=h==null?void 0:h.frontmatter)==null?void 0:N.tags)||[],frontmatter:(h==null?void 0:h.frontmatter)||{}},y=f.indexOf(`#${n.format("YYYY-MM-DD")}`);let w=f.indexOf(`
${f.substring(w)}`}else M=`${f.substring(0,w)}${I}${f.substring(w)}`;return dt.setChangedByMemos(!0),await l.modify(c,M),{...o,fileInfo:g}}async function n_({content:e,isList:t}){const n=Le.getState().dailyNotesState.settings,r=(n==null?void 0:n.MemoOtherSaveLocation.MemoDefaultCanvasPath)||"basic.thino.canvas",a=x.moment(),o=ut.randomId(16),i={id:o,content:e,deletedAt:"",path:r,createdAt:a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:a.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"CANVAS",fileInfo:{tags:[],frontmatter:{}}},l=ft.getState().app,{vault:c}=l,f=await ER(r,l);if(!f||!(f instanceof x.TFile)){new x.Notice(E("File not found for the given thino path, is creating a new file"));return}const h=await c.read(f),g=JSON.parse(h);if(g.nodes.find(I=>I.id===i.id))return;let w;g.nodes.length>0&&(w=[...g.nodes].reduce((I,M)=>{if(!I.createdAt)return M;const N=x.moment(I.createdAt,"YYYY/MM/DD HH:mm:ss"),R=x.moment(M.createdAt,"YYYY/MM/DD HH:mm:ss");return N.isAfter(R)?I:M}));const S=w?{x:w.x,y:w.y+100,width:w.width,height:w.height}:{x:0,y:0,width:200,height:100};g.nodes.push({...S,type:"text",id:o,text:e,deletedAt:"",createdAt:a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:a.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",hasId:"",linkId:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[]}),dt.setChangedByMemos(!0);const D=JSON.stringify(g,null,2);return await c.modify(f,D),i}async function bS(e,t,n){var fe,$;const{vault:r}=Le.getState().dailyNotesState.app||window.app,a=Le.getState().dailyNotesState.app||window.app,o=Le.getState().dailyNotesState.settings,i=a.vault.getConfig("useTab")===void 0||window.app.vault.getConfig("useTab")===!0,l=i?1:a.vault.getConfig("tabSize"),c=(i?" ":" ").repeat(l),f=e.split(`
`+c:" "}${M?`[webId::${M}]`:""}`,k=qu(),B=fb(h,k),L="fake"+ut.randomId(16);let_=!1;constV=a.plugins.getPlugin("templater-obsidian");letY;if(B?Y=B:(V!=null&&V.templater&&(V!=null&&V.settings.trigger_on_file_creation)&&(be.setWaitingForTemplater({origin:e,date:h,isList:t,id:L,type:"local"}),_=!0),Y=awaitut.createDailyNoteCheck(h)),!Y){newx.Notice(E("Failed to create daily note, check if it exists."));return}if(B||awaitft.fechLocalDailyNotes(),V&&(V!=null&&V.templater)&&(V!=null&&V.settings.trigger_on_file_creation)&&_)returndt.setChangedByMemos(!0),{id:L,content:e,deletedAt:"",createdAt:h.format("YYYY/MM/DD HH:mm:ss"),updatedAt:h.format("YYYY/MM/DD HH:mm:ss"),thinoType:t?"JOURNAL":"TASK-TODO",path:Y.path,hasId:"",linkId:"",webId:M,pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:{tags:[],frontmatter:{}}};letZ="";try{Z=awaitr.read(Y)||awaitr.cachedRead(Y)}catch(he){console.error(he),newx.Notice(E("Failed to read current daily note, check if it exists."))}constQ=a.metadataCache.getFileCache(Y),K={tags:(($=Q==null?void0:Q.frontmatter)==null?void0:$.tags)||[],frontmatter:(Q==null?void0:Q.frontmatter)||{}},se=awaitpA(D,R,Z);awaitr.modify(Y,se.content);constle=se.posNum===-1?mA(se.content).length-(R.split(`
`+w:" "}${f}`,R=qu(),k=fb(D,R),B="fake"+ut.randomId(16);letL=!1;const_=n.plugins.getPlugin("templater-obsidian");letV;if(k?V=k:(_!=null&&_.templater&&(_!=null&&_.settings.trigger_on_file_creation)&&(be.setWaitingForTemplater({origin:e.content,date:D,isList:e.thinoType&&e.thinoType==="JOURNAL",id:B,type:"web"}),L=!0),V=awaitut.createDailyNoteCheck(D)),!V){newx.Notice(E("Failed to create daily note, check if it exists.")),newx.Notice(E("Your content has been copied to clipboard, and inserted into the editor. Please try it again")),awaitnavigator.clipboard.writeText(e.content);const$=n.workspace.getLeavesOfType("thino_view").first();n.workspace.trigger("send-to-thino",e.content,$);return}if(k||awaitft.fechLocalDailyNotes(),_&&(_!=null&&_.templater)&&(_!=null&&_.settings.trigger_on_file_creation)&&L)returndt.setChangedByMemos(!0),{id:B,content:e.content,deletedAt:e.deletedAt??"",createdAt:D.format("YYYY/MM/DD HH:mm:ss"),updatedAt:D.format("YYYY/MM/DD HH:mm:ss"),thinoType:e.thinoType||"JOURNAL",path:V.path,hasId:"",linkId:"",pinned:e.pinned??!1,visibility:"PUBLIC",rowStatus:e.rowStatus??"NORMAL",webId:e.webId||e.id,creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:(e==null?void0:e.fileInfo)||{tags:[],frontmatter:{}}};constY=n.metadataCache.getFileCache(V),Z={tags:((fe=Y==null?void0:Y.frontmatter)==null?void0:fe.tags)||[],frontmatter:(Y==null?void0:Y.frontmatter)||{}};letQ="";try{Q=awaitt.read(V)||awaitt.cachedRead(V)}catch($){console.error($),newx.Notice(E("Failed to read current daily note, check if it exists."))}constK=c==="end"?"":e.thinoType&&i&&l||a,se=awaitpA(K,N,Q);awaitt.modify(V,se.content);constle=se.posNum===-1?mA(se.content).length-1:se.posNum+1;returndt.setChangedByMemos(!0),{id:D.format("YYYYMMDDHHmm")+"00"+le,content:e.content,deletedAt:e.deletedAt??"",createdAt:D.format("YYYY/MM/DD HH:mm:ss"),updatedAt:D.format("YYYY/MM/DD HH:mm:ss"),thinoType:e.thinoType||"JOURNAL",path:V.path,hasId:"",linkId:"",pinned:e.pinned??!1,visibility:"PUBLIC",rowStatus:e.rowStatus??"NORMAL",webId:e.id,creatorName:"Thino",resourceList:[],sourceType:"DAILY",fileInfo:Z}}asyncfunctionpA(e,t,n){constr=newRegExp(`(s*?)${awaitQR(e)}(s*?)`),a=XR(n),o=a.findIndex(f=>r.test(f)),i=(e==null?void0:e.trim())===""?!0:o===-1;i&&console.error("unable to find insert after line in file.");constl=a.slice(o+1).findIndex(f=>/(^#+|---|^\^[a-zA-Z0-9-]{2,}$)/.test(f)),c=l!==-1;if(c){letf;for(leth=l+o;h>o;h--)if(!/^[\s\n ]*$/.test(a[h])){f=h;break}returnf||(f=o),awaitLC(t,n,i?-1:f,c)}elsereturnawaitLC(t,n,a.length-1,c)}asyncfunctionLC(e,t,n,r){if(n<-1)thrownewError("Invalid position");if(n===-1)return{content:`${t}
`:"")+i}`,posNum:n}}constmA=e=>e.split(/\r?\n/);asyncfunctionr_(e){constt=Le.getState().dailyNotesState.app,n=t.vault.getAbstractFileByPath(e.path);if(!(ninstanceofx.TFile)){newx.Notice(E("File not found for the given thino path"));return}awaitt.vault.delete(n)}asyncfunctiona_(e){constt=Le.getState().dailyNotesState.app,n=t.vault.getAbstractFileByPath(e.path);if(!(ninstanceofx.TFile)){newx.Notice(E("File not found for the given thino path"));return}consta=(awaitt.vault.read(n)).split(`
`),o=a.findIndex(c=>c.includes(e.id));if(o===-1){new x.Notice(E("Thino not found"));return}const i=a.findIndex((c,f)=>f>o&&c.trim()==="");i===-1?a.splice(o,a.length-o):a.splice(o,i-o);const l=a.join(`
`);if(!l){new x.Notice(E("Thino not found"));return}dt.setChangedByMemos(!0),await t.vault.modify(n,l)}async function o_(e){const t=Le.getState().dailyNotesState.app,n=t.metadataCache.getFirstLinkpathDest("",e.path);if(!n){new x.Notice(E("File not found for the given thino path"));return}const r=await t.vault.read(n),a=JSON.parse(r),o=a.nodes,i=o.findIndex(h=>h.id===e.id);if(i===-1){new x.Notice(E("Thino not found"));return}o.splice(i,1);const l=a.edges;l.filter(h=>h.fromNode===e.id||h.toNode===e.id).forEach(h=>{const g=l.findIndex(y=>y.id===h.id);g!==-1&&l.splice(g,1)}),dt.setChangedByMemos(!0);const f=JSON.stringify(a,null,2);await t.vault.modify(n,f)}async function i_(e){cA()||new x.Notice(E("If you are disabling the daily note plugin, it would be possible that the thino will not be deleted or patched properly. Please enable the plugin and try again."),5e3);const{vault:t,metadataCache:n}=Le.getState().dailyNotesState.app,r=e.path,a=t.getAbstractFileByPath(r);if(!a){new x.Notice(E("Please check your daily note plugin OR periodic notes plugin settings"));return}const o=await t.read(a),i=o.split(`
`),l=n.getFileCache(a),c=(l==null?void 0:l.listItems)||[],f=parseInt(e.id.slice(14));let h=f;function g(D,I){const M=[];for(const N in I)I[N]===D&&M.push(parseInt(N),...g(parseInt(N),I));return M}const y=x2(c),w=c.find(D=>D.position.start.line===f),S=g(f,y);if(S.length>0){const D=S.map(I=>{const M=c.find(N=>N.position.start.line===I);return M?M.position.end.line:-1});h=Math.max(...D,w.position.end.line)}else h=w.position.end.line;if(!o){new x.Notice(E("Thino not found"));return}dt.setChangedByMemos(!0),i.splice(f,h-f+1),await t.modify(a,i.join(`
`);return await n.modify(r,I),dt.setChangedByMemos(!0),{...e,id:t.id||e.id,thinoType:t.thinoType||e.thinoType,createdAt:e.createdAt||a.format("YYYY/MM/DD HH:mm:ss"),updatedAt:x.moment().format("YYYY/MM/DD HH:mm:ss"),content:t.content||e.content,rowStatus:t.rowStatus||e.rowStatus,visibility:t.visibility||e.visibility,pinned:t.pinned!==void 0?t.pinned:e.pinned,webId:t.webId||e.webId,deletedAt:t.deleted?a.format("YYYY/MM/DD HH:mm:ss"):t.deleted===!1?"":e.deletedAt?e.deletedAt:""}}async function Rl(e,t){if(!e.sourceType||e.sourceType!=="CANVAS")return e;const{vault:n}=Le.getState().dailyNotesState.app,r=n.getAbstractFileByPath(e.path);if(!r)return e;const a=await n.read(r),o=JSON.parse(a),i=o.nodes.find(f=>f.id===e.id);if(!i)return e;t.content&&(i.text=t.content),t.thinoType&&(i.thinoType=t.thinoType),t.rowStatus&&(i.rowStatus=t.rowStatus),t.visibility&&(i.visibility=t.visibility),t.pinned!==void 0&&(i.pinned=t.pinned),t.webId&&(i.webId=t.webId);const l=x.moment();t.deleted!==void 0&&(i.deletedAt=t.deleted?l.format("YYYY/MM/DD HH:mm:ss"):""),i.updatedAt=l.format("YYYY/MM/DD HH:mm:ss");const c=JSON.stringify(o,null,2);return await n.modify(r,c),dt.setChangedByMemos(!0),{...e,thinoType:t.thinoType||e.thinoType,createdAt:e.createdAt,updatedAt:x.moment().format("YYYY/MM/DD HH:mm:ss"),content:t.content??e.content,rowStatus:t.rowStatus??e.rowStatus,visibility:t.visibility??e.visibility,pinned:t.pinned??e.pinned,webId:t.webId??e.webId,deletedAt:t.deleted?l.format("YYYY/MM/DD HH:mm:ss"):t.deleted===!1?"":e.deletedAt?e.deletedAt:""}}async function _l(e,t){var se;cA()||new x.Notice(E("If you are disabling the daily note plugin, it would be possible that the thino will not be deleted or patched properly. Please enable the plugin and try again."));const{vault:n,metadataCache:r}=Le.getState().dailyNotesState.app,a=Le.getState().dailyNotesState.app,{settings:o}=Le.getState().dailyNotesState,i=e.id.toString().slice(0,14),l=x.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(x.moment(i,"YYYYMMDDHHmmss"))?x.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss"):x.moment(i,"YYYYMMDDHHmmss"),c=x.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(l,"day"),f=e.path,h=n.getAbstractFileByPath(f)||n.getAbstractFileByPath(e.path);if(!h)return new x.Notice(E("Please check your daily note plugin OR periodic notes plugin settings")),e;const y=(await n.read(h)).split(`
`),w=r.getFileCache(h),S=(w==null?void 0:w.listItems)||[];if(S.length===0)return new x.Notice(E("Thino not found")),e;const D=parseInt(e.id.slice(14));let I=D;function M(le,fe){const $=[];for(const he in fe)fe[he]===le&&$.push(parseInt(he),...M(parseInt(he),fe));return $}const N=x2(S),R=S.find(le=>le.position.start.line===D);if(!R)return new x.Notice(E("Thino not found")),e;const k=M(D,N);if(k.length>0){const le=k.map(fe=>{const $=S.find(he=>he.position.start.line===fe);return $?$.position.end.line:-1});I=Math.max(...le,R.position.end.line)}else I=R.position.end.line;const B=y.slice(D,I+1);let L=B.join(`
`].join("");var xe}function Ze(te){return te.flags!==void 0?te.flags:[te.global?"g":"",te.ignoreCase?"i":"",te.multiline?"m":"",te.unicode?"u":"",te.sticky?"y":""].join("")}function st(){for(var te=[].slice.call(arguments),me=te.length,xe=0;xe<me;xe+=1)K(te[xe]);return o(function(Ye,He){for(var Qe,tt=new Array(me),kt=0;kt<me;kt+=1){if(!(Qe=Y(te[kt]._(Ye,He),Qe)).status)return Qe;tt[kt]=Qe.value,He=Qe.index}return Y(_(He,tt),Qe)})}function Ct(){var te=[].slice.call(arguments);if(te.length===0)throw new Error("seqMap needs at least one argument");var me=te.pop();return fe(me),st.apply(null,te).map(function(xe){return me.apply(null,xe)})}function tn(){var te=[].slice.call(arguments),me=te.length;if(me===0)return Tt("zero alternates");for(var xe=0;xe<me;xe+=1)K(te[xe]);return o(function(Ye,He){for(var Qe,tt=0;tt<te.length;tt+=1)if((Qe=Y(te[tt]._(Ye,He),Qe)).status)return Qe;return Qe})}function _e(te,me){return et(te,me).or(St([]))}function et(te,me){return K(te),K(me),Ct(te,me.then(te).many(),function(xe,Ye){return[xe].concat(Ye)})}function nt(te){$(te);var me="'"+te+"'";return o(function(xe,Ye){var He=Ye+te.length,Qe=xe.slice(Ye,He);return Qe===te?_(He,Qe):V(Ye,me)})}function ht(te,me){(function(He){if(!(He instanceof RegExp))throw new Error("not a regexp: "+He);for(var Qe=Ze(He),tt=0;tt<Qe.length;tt++){var kt=Qe.charAt(tt);if(kt!=="i"&&kt!=="m"&&kt!=="u"&&kt!=="s")throw new Error('unsupported regexp flag "'+kt+'": '+He)}})(te),arguments.length>=2?le(me):me=0;var xe=function(He){return RegExp("^(?:"+He.source+")",Ze(He))}(te),Ye=""+te;return o(function(He,Qe){var tt=xe.exec(He.slice(Qe));if(tt){if(0<=me&&me<=tt.length){var kt=tt[0],Yt=tt[me];return _(Qe+kt.length,Yt)}return V(Qe,"valid match group (0 to "+tt.length+") in "+Ye)}return V(Qe,Ye)})}function St(te){return o(function(me,xe){return _(xe,te)})}function Tt(te){return o(function(me,xe){return V(xe,te)})}function Gt(te){if(k(te))return o(function(me,xe){var Ye=te._(me,xe);return Ye.index=xe,Ye.value="",Ye});if(typeof te=="string")return Gt(nt(te));if(te instanceof RegExp)return Gt(ht(te));throw new Error("not a string, regexp, or parser: "+te)}function _t(te){return K(te),o(function(me,xe){var Ye=te._(me,xe),He=me.slice(xe,Ye.index);return Ye.status?V(xe,'not "'+He+'"'):_(xe,null)})}function Vt(te){return fe(te),o(function(me,xe){var Ye=se(me,xe);return xe<me.length&&te(Ye)?_(xe+1,Ye):V(xe,"a character/byte matching "+te)})}function Xt(te,me){arguments.length<2&&(me=te,te=void 0);var xe=o(function(Ye,He){return xe._=me()._,xe._(Ye,He)});return te?xe.desc(te):xe}function dn(){return Tt("fantasy-land/empty")}i.parse=function(te){if(typeof te!="string"&&!L(te))throw new Error(".parse must be called with a string or Buffer as its argument");var me,xe=this.skip(Er)._(te,0);return me=xe.status?{status:!0,value:xe.value}:{status:!1,index:Q(te,xe.furthest),expected:xe.expected},delete Z[te],me},i.tryParse=function(te){var me=this.parse(te);if(me.status)return me.value;var xe=Xe(te,me),Ye=new Error(xe);throw Ye.type="ParsimmonError",Ye.result=me,Ye},i.assert=function(te,me){return this.chain(function(xe){return te(xe)?St(xe):Tt(me)})},i.or=function(te){return tn(this,te)},i.trim=function(te){return this.wrap(te,te)},i.wrap=function(te,me){return Ct(te,this,me,function(xe,Ye){return Ye})},i.thru=function(te){return te(this)},i.then=function(te){return K(te),st(this,te).map(function(me){return me[1]})},i.many=function(){var te=this;return o(function(me,xe){for(var Ye=[],He=void 0;;){if(!(He=Y(te._(me,xe),He)).status)return Y(_(xe,Ye),He);if(xe===He.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");xe=He.index,Ye.push(He.value)}})},i.tieWith=function(te){return $(te),this.map(function(me){if(function(He){if(!B(He))throw new Error("not an array: "+He)}(me),me.length){$(me[0]);for(var xe=me[0],Ye=1;Ye<me.length;Ye++)$(me[Ye]),xe+=te+me[Ye];return xe}return""})},i.tie=function(){return this.tieWith("")},i.times=function(te,me){var xe=this;return arguments.length<2&&(me=te),le(te),
`),jr=nt(`\r
`),nr=tn(jr,ha,fr).desc("newline"),Lr=tn(nr,Er);o.all=kn,o.alt=tn,o.any=Zn,o.cr=fr,o.createLanguage=function(te){var me={};for(var xe in te)({}).hasOwnProperty.call(te,xe)&&function(Ye){me[Ye]=Xt(function(){return te[Ye](me)})}(xe);return me},o.crlf=jr,o.custom=function(te){return o(te(_,V))},o.digit=pt,o.digits=Mt,o.empty=dn,o.end=Lr,o.eof=Er,o.fail=Tt,o.formatError=Xe,o.index=en,o.isParser=k,o.lazy=Xt,o.letter=Jt,o.letters=sn,o.lf=ha,o.lookahead=Gt,o.makeFailure=V,o.makeSuccess=_,o.newline=nr,o.noneOf=function(te){return Vt(function(me){return te.indexOf(me)<0}).desc("none of '"+te+"'")},o.notFollowedBy=_t,o.of=St,o.oneOf=function(te){for(var me=te.split(""),xe=0;xe<me.length;xe++)me[xe]="'"+me[xe]+"'";return Vt(function(Ye){return te.indexOf(Ye)>=0}).desc(me)},o.optWhitespace=ln,o.Parser=o,o.range=function(te,me){return Vt(function(xe){return te<=xe&&xe<=me}).desc(te+"-"+me)},o.regex=ht,o.regexp=ht,o.sepBy=_e,o.sepBy1=et,o.seq=st,o.seqMap=Ct,o.seqObj=function(){for(var te,me={},xe=0,Ye=(te=arguments,Array.prototype.slice.call(te)),He=Ye.length,Qe=0;Qe<He;Qe+=1){var tt=Ye[Qe];if(!k(tt)){if(B(tt)&&tt.length===2&&typeof tt[0]=="string"&&k(tt[1])){var kt=tt[0];if(Object.prototype.hasOwnProperty.call(me,kt))throw new Error("seqObj: duplicate key "+kt);me[kt]=!0,xe++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(xe===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(Yt,On){for(var yn,Cr={},Jn=0;Jn<He;Jn+=1){var yr,ta;if(B(Ye[Jn])?(yr=Ye[Jn][0],ta=Ye[Jn][1]):(yr=null,ta=Ye[Jn]),!(yn=Y(ta._(Yt,On),yn)).status)return yn;yr&&(Cr[yr]=yn.value),On=yn.index}return Y(_(On,Cr),yn)})},o.string=nt,o.succeed=St,o.takeWhile=function(te){return fe(te),o(function(me,xe){for(var Ye=xe;Ye<me.length&&te(se(me,Ye));)Ye++;return _(Ye,me.slice(xe,Ye))})},o.test=Vt,o.whitespace=vr,o["fantasy-land/empty"]=dn,o["fantasy-land/of"]=St,o.Binary={bitSeq:w,bitSeqObj:function(te){y();var me={},xe=0,Ye=f(function(Qe){if(B(Qe)){var tt=Qe;if(tt.length!==2)throw new Error("["+tt.join(", ")+"] should be length 2, got length "+tt.length);if($(tt[0]),le(tt[1]),Object.prototype.hasOwnProperty.call(me,tt[0]))throw new Error("duplicate key in bitSeqObj: "+tt[0]);return me[tt[0]]=!0,xe++,tt}return le(Qe),[null,Qe]},te);if(xe<1)throw new Error("bitSeqObj expects at least one named pair, got ["+te.join(", ")+"]");var He=f(function(Qe){return Qe[0]},Ye);return w(f(function(Qe){return Qe[1]},Ye)).map(function(Qe){return c(function(tt,kt){return kt[0]!==null&&(tt[kt[0]]=kt[1]),tt},{},f(function(tt,kt){return[tt,Qe[kt]]},He))})},byte:function(te){if(y(),le(te),te>255)throw new Error("Value specified to byte constructor ("+te+"=0x"+te.toString(16)+") is larger in value than a single byte.");var me=(te>15?"0x":"0x0")+te.toString(16);return o(function(xe,Ye){var He=se(xe,Ye);return He===te?_(Ye+1,He):V(Ye,me)})},buffer:function(te){return S("buffer",te).map(function(me){return Buffer.from(me)})},encodedString:function(te,me){return S("string",me).map(function(xe){return xe.toString(te)})},uintBE:I,uint8BE:I(1),uint16BE:I(2),uint32BE:I(4),uintLE:M,uint8LE:M(1),uint16LE:M(2),uint32LE:M(4),intBE:N,int8BE:N(1),int16BE:N(2),int32BE:N(4),intLE:R,int8LE:R(1),int16LE:R(2),int32LE:R(4),floatBE:S("floatBE",4).map(function(te){return te.readFloatBE(0)}),floatLE:S("floatLE",4).map(function(te){return te.readFloatLE(0)}),doubleBE:S("doubleBE",8).map(function(te){return te.readDoubleBE(0)}),doubleLE:S("doubleLE",8).map(function(te){return te.readDoubleLE(0)})},n.exports=o}])})})(pe);var H2=()=>/(?:[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F
${o}`,posNum:n}}function RH(e,t,n){var a;const r=t.workspace.getLeavesOfType("markdown");for(const o of r){const i=o.view;if(((a=i==null?void 0:i.file)==null?void 0:a.path)===e){t.workspace.revealLeaf(o);try{return o.view.setEphemeralState({line:n}),!0}catch(l){return console.error(l),!1}}}return!1}const U2=async e=>{var o;const t=ft.getState().app,n=t.workspace.getLeavesOfType("markdown");for(const i of n){const l=i.view;if(((o=l==null?void 0:l.file)==null?void 0:o.path)===e){t.workspace.revealLeaf(i);return}}const r=t.metadataCache.getFirstLinkpathDest("",e);if(!r){new x.Notice(E("File not found for the given thino path"));return}await t.workspace.getLeaf(!0).openFile(r)},z2=async(e,t)=>{const{app:n}=ft.getState(),r=parseInt(e.slice(14));if(RH(t,n,r))return;const a=n.metadataCache.getFirstLinkpathDest("",t);if(!x.Platform.isMobile)await n.workspace.getLeaf(!0).openFile(a,{eState:{line:r}});else{let o=n.workspace.activeLeaf;o===null&&(o=n.workspace.getLeaf(!0)),await o.openFile(a,{eState:{line:r}})}},V2=async(e,t)=>{var f,h,g;const n=ft.getState().app,r=n.metadataCache.getFirstLinkpathDest("",t);if(!r){new x.Notice(E("File not found for the given thino path"));return}let a="";try{a=await n.vault.read(r)}catch(y){console.error(y),a=await n.vault.cachedRead(r)}const i=a.split(/\r?\n/).findIndex(y=>y.contains(e)),l=n.workspace.getLeavesOfType("markdown");for(const y of l){const w=y.view;if(((f=w==null?void 0:w.file)==null?void 0:f.path)===r.path){n.workspace.revealLeaf(y);try{(h=y.view.editor)==null||h.setCursor({line:i,ch:1});return}catch(S){console.error(S)}}}const c=n.workspace.getLeaf(!0);await c.openFile(r,{eState:{line:i}});try{(g=c.view.editor)==null||g.setCursor({line:i,ch:1})}catch(y){console.error(y)}},W2=async(e,t)=>{var l;const n=ft.getState().app,r=(c,f)=>{var g;const h=(g=Array.from(c.nodes.values()))==null?void 0:g.find(y=>y.id===f);return h?(c.selectOnly(h),c.zoomToSelection(),!0):!1},a=n.workspace.getLeavesOfType("canvas");for(const c of a){const f=c.view;if(((l=f==null?void 0:f.file)==null?void 0:l.path)===t&&(n.workspace.revealLeaf(c),r(f.canvas,e)))return}const o=n.metadataCache.getFirstLinkpathDest("",t);if(!o){new x.Notice(E("File not found for the given thino path"));return}const i=n.workspace.getLeaf(!0);await i.openFile(o),setTimeout(()=>{var c;r((c=i.view)==null?void 0:c.canvas,e)},10)};class _H{constructor(){Se(this,"initialized",!1)}getState(){return Le.getState().memoState}async fetchAllMemos(){const t=ft.getState().settings;ut.checkDailyInMulti(t);const n=await Ko.getMyMemos(t.EnabledLocationList.map(o=>o.value)),r=[...n.memos],a=[...n.commentMemos];return Le.dispatch({type:"SET_MEMOS",payload:{memos:r}}),Le.dispatch({type:"SET_COMMENT_MEMOS",payload:{commentMemos:a}}),this.initialized||(this.initialized=!0,dt.setLoaded(!0)),r}async updateTypeMemos(t){const n=await Ko.updateSpecificTypeMemo(t),r=this.getState().memos.filter(a=>a.sourceType!==t);Le.dispatch({type:"SET_MEMOS",payload:{memos:[...r,...n.memos]}})}async removeTypeMemos(t){const n=this.getState().memos.filter(r=>r.sourceType!==t);Le.dispatch({type:"SET_MEMOS",payload:{memos:[...n]}})}async fetchDeletedMemos(){const t=await Ko.getMyDeletedMemos();return t.sort((n,r)=>ut.getTimeStampByDate(r.deletedAt)-ut.getTimeStampByDate(n.deletedAt)),t}pushMemo(t){Le.dispatch({type:"INSERT_MEMO",payload:{memo:{...t}}})}pushCommentMemo(t){Le.dispatch({type:"INSERT_COMMENT_MEMO",payload:{memo:{...t}}})}getMemoById(t){for(const n of this.getState().memos)if(n.id===t)return n;return null}getCommentMemoById(t){for(const n of this.getState().commentMemos)if(n.id===t)return n;return null}getMemoByWebId(t){for(const n of this.getState().memos)if(n.webId===t||n.id===t)return n;return null}async finishWaitingForTemplaterThinos(){const t=this.getState().preparingUpdateMemo;if(t.length!==0)for(const n of t){const r=this.getMemoById(n.id),a=n.type==="local"?await bS(n.origin,n.isList,n.date):await jC(r);await this.replaceOldThinoWithNewThino(n.id,a),Le.dispatch({type:"REMOVE_PARTICULAR_PREPARE_UPDATE_THINO",payload:{id:n.id}})}}async replaceOldThinoWithNewThi
Checkthedocumentationorcreateissueifyouthinkit's bug. https://github.com/webscopeio/react-textarea-autocomplete/issues`))},MY=[".","^","$","*","+","-","?","(",")","[","]","{","}","\\","|"],I0=function(t){return TY(t).map(function(n){return MY.includes(n)?"\\".concat(n):n}).join("")},kY=function(e){Tb(t,e);function t(){return Lv(this,t),Db(this,yp(t).apply(this,arguments))}return Sb(t,[{key:"componentDidMount",value:function(){var r=this.props.boundariesElement;if(typeof r=="string"){var a=document.querySelector(r);if(!a)throw new Error("RTA: Invalid prop boundariesElement: it has to be string or HTMLElement.");this.containerElem=a}else if(r instanceof HTMLElement)this.containerElem=r;else throw new Error("RTA: Invalid prop boundariesElement: it has to be string or HTMLElement.");if(!this.containerElem||!this.containerElem.contains(this.ref))throw new Error("RTA: Invalid prop boundariesElement: it has to be one of the parents of the RTA.")}},{key:"componentDidUpdate",value:function(){var r,a,o=this.props.top||0,i=this.props.left||0,l=[],c=[],f=0,h=0,g=this.containerElem.getBoundingClientRect(),y=this.ref.getBoundingClientRect(),w=this.props.textareaRef.getBoundingClientRect(),S=window.getComputedStyle(this.ref),D=parseInt(S.getPropertyValue("margin-top"),10),I=parseInt(S.getPropertyValue("margin-bottom"),10),M=parseInt(S.getPropertyValue("margin-left"),10),N=parseInt(S.getPropertyValue("margin-right"),10),R=D+I+w.top+o+y.height,k=M+N+w.left+i+y.width;k>g.right&&w.left+i>y.width?(h=i-y.width,l.push(Yc.X.LEFT),c.push(Yc.X.RIGHT)):(h=i,l.push(Yc.X.RIGHT),c.push(Yc.X.LEFT)),R>g.bottom&&w.top+o>y.height?(f=o-y.height,l.push(Yc.Y.TOP),c.push(Yc.Y.BOTTOM)):(f=o,l.push(Yc.Y.BOTTOM),c.push(Yc.Y.TOP)),this.props.renderToBody&&(f+=w.top,h+=w.left),this.ref.style.top="".concat(f,"px"),this.ref.style.left="".concat(h,"px"),(r=this.ref.classList).remove.apply(r,c),(a=this.ref.classList).add.apply(a,l)}},{key:"render",value:function(){var r=this,a=this.props,o=a.style,i=a.className,l=a.innerRef,c=a.children,f=a.renderToBody,h=document.body,g=ne.createElement("div",{ref:function(w){r.ref=w,l(w)},className:"rta__autocomplete ".concat(i||""),style:o},c);return f&&h!==null?q2.createPortal(g,h):g}}]),t}(ne.Component),T6=function(e){Tb(t,e);function t(n){var r;Lv(this,t),r=Db(this,yp(t).call(this,n)),r.state={top:null,left:null,currentTrigger:null,actualToken:"",data:null,value:"",dataLoading:!1,selectionEnd:0,component:null,textToReplace:null},r.escListenerInit=function(){r.escListener||(r.escListener=uf.add(xi.ESC,r._closeAutocomplete))},r.escListenerDestroy=function(){r.escListener&&(uf.remove(r.escListener),r.escListener=null)},r.getSelectionPosition=function(){return r.textareaRef?{selectionStart:r.textareaRef.selectionStart,selectionEnd:r.textareaRef.selectionEnd}:null},r.getSelectedText=function(){if(!r.textareaRef)return null;var c=r.textareaRef,f=c.selectionStart,h=c.selectionEnd;return f===h?null:r.state.value.substr(f,h-f)},r.setCaretPosition=function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;r.textareaRef&&(r.textareaRef.focus(),r.textareaRef.setSelectionRange(c,c))},r.getCaretPosition=function(){if(!r.textareaRef)return 0;var c=r.textareaRef.selectionEnd;return c},r._handleCaretChange=function(c){var f=function(){var y=r.getCaretPosition()-1;r.lastTrigger=r.lastTrigger?y:0};if(c.type==="keydown"){var h=c.keyCode||c.which;switch(h){case xi.UP:case xi.DOWN:r._isAutocompleteOpen()||f();break;case xi.LEFT:case xi.RIGHT:f();break}return}f()},r._onSelect=function(c){var f=r.state,h=f.selectionEnd,g=f.currentTrigger,y=f.value,w=r.props.onItemSelected;if(g){var S=r._getTextToReplace(g);if(!S){r._closeAutocomplete();return}var D=S(c);if(!D){r._closeAutocomplete();return}w&&w({currentTrigger:g,item:c});var I=function(Z,Q,K){switch(Z){case"start":return K;case"next":case"end":return K+Q.length;default:if(!Number.isInteger(Z))throw new Error('RTA:caretPositionshouldbe"start","next","end"ornumber.');returnZ}},M=y.slice(0,h),N=I0(g),R=M.length-M.lastIndexOf(g),k=M.search(newRegExp("(?!".concat(N,")$")
`));if(y===null)return null;if(typeof y=="string")return{text:y,caretPosition:bx};if(!y.text&&typeof y.text!="string")throw new Error('Output "text" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(c,`"
`));if(!y.caretPosition)throw new Error('Output "caretPosition" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(c,`"
`));return y}if(typeof g!="string")throw new Error(`Outputitemshouldbestring
`);return{text:"".concat(c).concat(g).concat(c),caretPosition:bx}}},r._getCurrentTriggerSettings=function(){var c=r.state.currentTrigger;return c?r.props.trigger[c]:null},r._getValuesFromProvider=function(){var c=r.state,f=c.currentTrigger,h=c.actualToken,g=r._getCurrentTriggerSettings();if(!(!f||!g)){var y=g.dataProvider,w=g.component;if(typeof y!="function")throw new Error("Trigger provider has to be a function!");r.setState({dataLoading:!0});var S=y(h);S instanceof Promise||(S=Promise.resolve(S)),S.then(function(D){if(!Array.isArray(D))throw new Error("Trigger provider has to provide an array!");if(typeof w!="function")throw new Error("Component should be defined!");if(f===r.state.currentTrigger){if(!D.length){r._closeAutocomplete();return}r.setState({dataLoading:!1,data:D,component:w})}}).catch(function(D){return Sx(D.message)})}},r._getSuggestions=function(){var c=r.state,f=c.currentTrigger,h=c.data;return!f||!h||h&&!h.length?null:h},r._createRegExp=function(){var c=r.props.trigger;r.tokenRegExp=new RegExp("(".concat(Object.keys(c).sort(function(f,h){return f<h?1:f>h?-1:0}).map(function(f){return I0(f)}).join("|"),")((?:(?!\\1)[^\\s])*$)")),r.tokenRegExpEnding=new RegExp("(".concat(Object.keys(c).sort(function(f,h){return f<h?1:f>h?-1:0}).map(function(f){return I0(f)}).join("|"),")$"))},r._closeAutocomplete=function(){var c=r.state.currentTrigger;r.escListenerDestroy(),r.setState({data:null,dataLoading:!1,currentTrigger:null},function(){c&&r._onItemHighlightedHandler(null)})},r._cleanUpProps=function(){var c=yY({},r.props),f=["loadingComponent","boundariesElement","containerStyle","minChar","scrollToItem","ref","innerRef","onChange","onCaretPositionChange","className","value","trigger","listStyle","itemStyle","containerStyle","loaderStyle","className","containerClassName","listClassName","itemClassName","loaderClassName","dropdownStyle","dropdownClassName","movePopupAsYouType","textAreaComponent","renderToBody","onItemSelected","onItemHighlighted"];for(var h in c)f.includes(h)&&delete c[h];return c},r._changeHandler=function(c){var f=r.props,h=f.trigger,g=f.onChange,y=f.minChar,w=f.onCaretPositionChange,S=f.movePopupAsYouType,D=r.state,I=D.top,M=D.left,N=c;N||(N=new gY("change",{bubbles:!0}),r.textareaRef.dispatchEvent(N));var R=N.target||r.textareaRef,k=R.selectionEnd,B=R.value;if(r.lastValueBubbledEvent=B,g&&N&&(N.persist&&N.persist(),g(new Proxy(N,{get:function(X,ae,De){return ae==="target"?R:Reflect.get(X,ae,De)}}))),w){var L=r.getCaretPosition();w(L)}r.setState({value:B});var _=function(){var X=hY(R,k),ae=X.top,De=X.left;r.setState({top:ae-r.textareaRef.scrollTop||0,left:De})},V=function(X){r.lastTrigger=k-X,r._closeAutocomplete(),_()};if(k<=r.lastTrigger){var Y=B.slice(0,k),Z=r.tokenRegExp.exec(Y);V(Z?Z[0].length:0)}var Q=B.slice(r.lastTrigger,k),K=r.tokenRegExp.exec(Q),se=K&&K[0],le=K&&K[1]||null,fe=le?le.length-1:0,$=r.tokenRegExpEnding.exec(Q);if($?V($[0].length):r._isAutocompleteOpen()||r._closeAutocomplete(),(!se||se.length<=y+fe)&&(r.state.currentTrigger&&!h[r.state.currentTrigger].allowWhitespace||!r.state.currentTrigger)){r._closeAutocomplete();return}if(le&&h[le].afterWhitespace&&!/\s/.test(B[k-se.length-1])&&B[k-se.length-1]!==void 0){r._closeAutocomplete();return}if(r.state.currentTrigger&&h[r.state.currentTrigger].allowWhitespace){if(K=new RegExp("".concat(I0(r.state.currentTrigger),".*$")).exec(B.slice(0,k)),se=K&&K[0],!se){r._closeAutocomplete();return}le=Object.keys(h).find(function(ce){return ce.slice(0,fe+1)===se.slice(0,fe+1)})||null}var he=se.slice(1);if(le){(S||I===null&&M===null||r.state.currentTrigger!==le)&&_(),r.escListenerInit();var ie=r._getTextToReplace(le);r.setState({selectionEnd:k,currentTrigger:le,textToReplace:ie,actualToken:he},function(){try{r._getValuesFromProvider()}catch(ce){Sx(ce.message)}})}},r._selectHandler=function(c){var f=r.props,h=f.onCaretPositionChange,g=f.onSelect;if(h){var y=r.getCaretPosition();h(y)}g&&(c.persist(),g(c))},r._shouldStayOpen=function(c){var f=c.relatedTarget;return f===null&&(f=document.activeElement),!!(r.dropdownRef&&f instanceof Node&&r.dropd
`,Rue="\uFEFF",$F=e=>Object.assign({},jue,e);let _ue=class extends Error{constructor(t){super(t),this.name="CsvGenerationError"}},Bue=class extends Error{constructor(t){super(t),this.name="EmptyHeadersError"}};var Kv=e=>e,Us=e=>e,qb=Kv,Ep=Kv,Sk=Kv,Dk=Kv,Hue=function(e,t){return t=='"'&&e.indexOf('"')>-1?e.replace(/"/g,'""'):e},Yue=e=>Sk(typeof e=="object"?e.key:e),Uue=e=>Dk(typeof e=="object"?e.displayLabel:e),zue=(e,...t)=>t.reduce((n,r)=>r(n),e),Vue=e=>t=>e.useBom?qb(Us(t)+Rue):t,Wue=e=>t=>e.showTitle?BI(qb(Us(t)+e.title))(Ep("")):t,BI=e=>t=>qb(Us(e)+Us(t)+Lue),ZF=e=>(t,n)=>$ue(e)(Ep(t+n)),$ue=e=>t=>Kv(Us(t)+e.fieldSeparator),Zue=(e,t)=>n=>{if(!e.showColumnHeaders)return n;if(t.length<1)throw new Bue("Option to show headers but none supplied. Make sure there are keys in your collection or that you've supplied headers through the config options.");let r=Ep("");for(let a=0;a<t.length;a++){const o=Uue(t[a]);r=ZF(e)(r,qF(e,o))}return r=Ep(Us(r).slice(0,-1)),BI(n)(r)},que=(e,t,n)=>r=>{let a=r;for(var o=0;o<n.length;o++){let i=Ep("");for(let l=0;l<t.length;l++){const c=Yue(t[l]),f=typeof n[o][Us(c)]>"u"?e.replaceUndefinedWith:n[o][Us(c)];i=ZF(e)(i,qF(e,f))}i=Ep(Us(i).slice(0,-1)),a=BI(a)(i)}return a},Gue=Us,Tk=e=>+e===e&&(!isFinite(e)||!!(e%1)),qF=(e,t)=>{if(e.decimalSeparator==="locale"&&Tk(t))return t.toLocaleString();if(e.decimalSeparator!=="."&&Tk(t))return t.toString().replace(".",e.decimalSeparator);if(typeof t=="string"){let n=t;return(e.quoteStrings||e.fieldSeparator&&t.indexOf(e.fieldSeparator)>-1||e.quoteCharacter&&t.indexOf(e.quoteCharacter)>-1||t.indexOf(`
`)>-1||t.indexOf("\r")>-1)&&(n=e.quoteCharacter+Hue(t,e.quoteCharacter)+e.quoteCharacter),n}if(typeof t=="boolean"&&e.boolDisplay){const n=t?"true":"false";return e.boolDisplay[n]}return t},Jue=e=>t=>{const n=$F(e),r=n.useKeysAsHeaders?Object.keys(t[0]):n.columnHeaders;let a=zue(qb(""),Vue(n),Wue(n),Zue(n,r),que(n,r,t));if(Us(a).length<1)throw new _ue("Output is empty. Is your data formatted correctly?");return a};const Kue=({thino:e})=>{const t=P.useRef(null);P.useEffect(()=>(t.current&&x.setIcon(t.current,"pin"),()=>{t.current&&(t.current=null)}),[t]);const n=P.useCallback(async()=>{e.pinned?await be.unpinMemoById(e.id):await be.pinMemoById(e.id)},[e]);return v.jsx("span",{ref:t,className:ar("pinned-status",e.pinned?"pinned":"not-pinned"),onClick:n})},Que=({thino:e})=>{var r;const t=P.useRef(null);P.useEffect(()=>(t.current&&x.setIcon(t.current,e.thinoType==="JOURNAL"?"calendar":"check-square"),()=>{t.current&&(t.current=null)}),[t,e==null?void 0:e.thinoType]);const n=P.useCallback(async()=>{if(e.thinoType==="JOURNAL")return;const a=await be.updateMemo(e.id,e.content,e.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");a&&be.editMemo(a)},[e]);return v.jsx(v.Fragment,{children:e.thinoType!=="JOURNAL"?v.jsx("input",{className:ar("thino-type-status","task-list-item-checkbox"),type:"checkbox",checked:e.thinoType!=="TASK-TODO","data-task":e.thinoType==="TASK-TODO"?"":e.thinoType==="TASK-DONE"?"x":(r=e.thinoType)==null?void 0:r.slice(5),onClick:n}):v.jsx("span",{ref:t,className:"thino-type-status"})})},Xue=({id:e,path:t})=>{const n=P.useRef(null);P.useEffect(()=>(n.current&&x.setIcon(n.current,"link"),()=>{n.current&&(n.current=null)}),[]);const r=P.useCallback(()=>{!e||!t||be.openThinoByID(e)},[e,t]);return v.jsxs("span",{className:"source-thino",onClick:r,children:[v.jsx("span",{children:t}),v.jsx("span",{ref:n,className:"source-thino-icon"})]})},ece=({id:e,sourceType:t})=>{const n=P.useRef(null);P.useEffect(()=>{var a;return n.current&&x.setIcon(n.current,((a=Gg.find(o=>o.title===t))==null?void 0:a.icon)||"list"),()=>{n.current&&(n.current=null)}},[]);const r=P.useCallback(async()=>{e&&await be.openThinoByID(e)},[e]);return v.jsx("span",{ref:n,className:"source-type-icon",onClick:r})},Ik=(e,t,n,r)=>{const a=Mue(e.getValue(t),n);return r({itemRank:a}),a.passed},Ek=(e,t,n)=>{var a,o;let r=0;return e.columnFiltersMeta[n]&&(r=Aue((a=e.columnFiltersMeta[n])==null?void 0:a.itemRank,(o=t.columnFiltersMeta[n])==null?void 0:o.itemRank)),r===0?up.alphanumeric(e,t,n):r},tce=$F({fieldSeparator:",",decimalSeparator:".",useKeysAsHeaders:!0}),nce=e=>e+`
`,L.current,t.path,a||e.view)}he(),setTimeout(async()=>{await K()},oA)},[B,L,l,M]);const K=async()=>{B.current&&(await txe(B.current),await $E(B.current),nxe(M).then(he=>{he&&setTimeout(()=>{xb(B.current,{pixelRatio:window.devicePixelRatio*2}).then(ie=>{k(ie),f(!0)}).catch(()=>{})},600)}))},se=()=>{n()},le=P.useCallback(he=>{w(he)},[y]),fe=async()=>{const{vault:he}=Le.getState().dailyNotesState.app,ie=B.current.querySelector(".memo-shortcut-img");if(!ie)return;const ce=ie==null?void 0:ie.getAttribute("src").split("base64,")[1],X=nN(ce,"image/png");let ae;X.arrayBuffer().then(async De=>{const je="png",Re=qu();for(const Fe in Re)if(Re[Fe]instanceof x.TFile){ae=Re[Fe];break}if(ae!==void 0){const Fe=await he.getAvailablePathForAttachments(`PastedImage${x.moment().format("YYYYMMDDHHmmss")}`,je,ae);await he.createBinary(Fe,De),new x.Notice(E("Save image successfully"))}})},$=async()=>{le(!0);const he=B.current.querySelector(".memo-shortcut-img");if(!he)return;const ie=he==null?void 0:he.getAttribute("src").split("base64,")[1],ce=nN(ie,"image/png");if(!ce){new x.Notice(E("Copy to clipboard failed"));return}const X=new ClipboardItem({"image/png":ce});window.navigator.clipboard.write([X]).then(()=>{setTimeout(()=>{le(!1)},500)}),new x.Notice(E("Copy to clipboard successfully"))};return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:ar("dialog-header-container"),children:[v.jsxs("p",{className:"title-text",children:[v.jsx("span",{className:"icon-text",children:"🥰"}),E("Share Memo Image")]}),v.jsxs("div",{className:"btn-group",children:[x.Platform.isMobile&&v.jsx("button",{ref:I,className:"btn download-btn",onClick:fe}),v.jsx("button",{ref:S,className:"btn copy-btn",onClick:$}),v.jsx("button",{ref:D,className:"btn close-btn",onClick:se})]})]}),v.jsxs("div",{className:ar("dialog-content-container",M),children:[v.jsx("div",{className:`tip-words-container${R?"finish":"loading"}`,children:v.jsx("p",{className:"tip-text",children:E(R?"↗Click the button to save":"Image is generating...")})}),v.jsxs("div",{className:"setting-item",children:[v.jsxs("div",{className:"setting-item-info",children:[v.jsx("div",{className:"setting-item-name",children:E("Default sharing style")}),v.jsx("div",{className:"setting-item-description",children:E("Set the default style for sharing thino, 'Modern' by default.")})]}),v.jsx("div",{className:"setting-item-control",children:v.jsxs("select",{className:"dropdown",defaultValue:M,onChange:async he=>{he.currentTarget.value!==M&&(f(!1),k(""),N(he.currentTarget.value),(o||window.app).saveLocalStorage("memoShareDialogStyle",he.currentTarget.value),await K())},children:[v.jsx("option",{value:"modern",children:E("Modern")}),v.jsx("option",{value:"clean",children:E("Clean")}),v.jsx("option",{value:"minimal",children:E("Minimal")}),v.jsx("option",{value:"gradient",children:E("Gradient")})]})})]}),v.jsxs("div",{className:ar("memo-container",M),ref:B,children:[v.jsx(ts,{when:R!=="",children:v.jsx("img",{className:"memo-shortcut-img",onClick:$,src:R})}),v.jsxs("div",{className:"memo-background",children:[v.jsx("div",{className:"property-image",style:{backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"}}),v.jsx("span",{className:"background-container"}),v.jsxs("div",{className:"thino-user-header",children:[v.jsx("div",{className:"thino-user-icon",ref:he=>{if(i!=null&&i.MomentsIcon){he==null||he.empty();return}i!=null&&i.MomentsIcon||he&&x.setIcon(he,"Memos")},style:{backgroundImage:`url("${_}")`}}),v.jsxs("div",{className:"thino-user-info",children:[v.jsx("div",{className:"thino-user-name",children:i==null?void 0:i.UserName}),(i==null?void 0:i.MomentsQuote)&&v.jsx("div",{className:"thino-user-quote",children:i==null?void 0:i.MomentsQuote})]})]}),v.jsx("div",{ref:L,className:"memo-content-text",style:{minHeight:i.MinHeightForShare||"200px"}}),v.jsx("div",{className:"thino-time-footer",children:l.createdAt}),v.jsxs("div",{className:"watermark-container",children:[v.jsxs("span",{className:"normal-text footer-start",children:[v.jsx("div",{className:"property-social-icons"}),v.jsx("spa
`,i.current,a.path,r);const R=(B=i.current)==null?void 0:B.querySelectorAll(".internal-link");R==null||R.forEach(L=>{const _=L,V=_.getAttribute("data-href");if(!V)return;t.metadataCache.getFirstLinkpathDest(V,a.path)||L.classList.add("is-unresolved"),_.addEventListener("mouseover",Z=>{Z.stopPropagation(),t.workspace.trigger("hover-link",{event:Z,source:"thino",hoverParent:r.containerEl,targetEl:_,linktext:V,sourcePath:_.href})})})}N()},[a.content,l]);const S=async()=>{switch(h.sourceType){case"DAILY":await z2(h.id,h.path);break;case"CANVAS":await W2(h.id,h.path);break;case"MULTI":await U2(h.path);break;case"FILE":await V2(h.id,h.path);break}},D=async()=>{if(g)try{if(n.DeleteThinoDirectly)await be.deleteMemoById(h.id);else{const N=await be.hideMemoById(h.id);N&&be.editMemo(N)}}catch(N){new x.Notice(N.message)}else y()},I=async()=>{try{const N=await be.unarchiveMemo(h);N&&be.editMemo(N),o(h.id),new x.Notice(E("RESTORE SUCCEED"))}catch(N){new x.Notice(N.message)}},M=()=>{g&&y(!1)};return v.jsxs("div",{ref:l,className:`memo-wrapper${"memos-"+h.id}`,onMouseLeave:M,children:[v.jsxs("div",{className:"memo-top-wrapper",children:[v.jsxs("span",{className:"time-text",children:[E("ARCHIVED AT")," ",h.updatedAt]}),v.jsxs("div",{className:"btns-container",children:[v.jsx("span",{ref:N=>{N&&x.setIcon(N,"more-horizontal")},className:"btn more-action-btn"}),v.jsx("div",{className:"more-action-btns-wrapper",children:v.jsxs("div",{className:"more-action-btns-container",children:[v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:w.restore,className:"more-action-item-icon"}),v.jsx("span",{className:"btn restore-btn",onClick:I,children:E("RESTORE")})]}),v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:w.source,className:"more-action-item-icon"}),v.jsx("span",{className:"btn",onClick:S,children:E("SOURCE")})]}),v.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[v.jsx("span",{ref:w.delete,className:"more-action-item-icon"}),v.jsx("span",{className:`btndelete-btn${g?"final-confirm":""}`,onClick:D,children:E(g?"CONFIRM!":"DELETE")})]})]})})]})]}),v.jsx("div",{ref:i,className:"memo-content-text"})]})},Ru=e=>{var n;const t=new Map;for(const r of e){const a=r.path;t.has(a)||t.set(a,[]),(n=t.get(a))==null||n.push(r)}return Array.from(t).map(([r,a])=>({path:r,thinos:a}))},oxe=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:i,filter:l}=t,c=on.getQueryById(l);return!!(r||a&&a.from<a.to||o||i||c)||c||n?e.filter(h=>{let g=!0;if(h.thinoType!==void 0&&n&&h.thinoType==="TASK-DONE"&&(g=!1),h.content.contains("comment:")&&(g=!1),c){const y=JSON.parse(c.querystring);Array.isArray(y)&&(g=Yp(h,y))}if(r){const y=new Set;for(const w of Array.from(h.content.match($r)||[])){const D=w.replace($r,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(ua)||[])){const D=w.replace(ua,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(Wa)||[])){const D=w.replace(Wa,"$2").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}y.has(r)||(g=!1)}return a&&a.from<a.to&&(ut.getTimeStampByDate(h.createdAt)<a.from||ut.getTimeStampByDate(h.createdAt)>a.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(h.content.match($r)!==null||h.content.match(Wa)!==null||h.content.match(ua)!==null)||o==="LINKED"&&h.content.match(Mf)===null||o==="IMAGED"&&h.content.match(kf)===null||o==="CONNECTED"&&h.content.match(rd)===null)&&(g=!1),i&&!h.content.toLowerCase().includes(i.toLowerCase())&&(g=!1),g}):e.filter(h=>!h.content.contains("comment:"))},ixe=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=P.useContext(Lt),r=im(),[a,o]=P.useState([]),i=ne.useRef(null),l=ne.useRef(null);P.useEffect(()=>{l.current&&x.setIcon(l.current,"more-horizontal")},[l]),P.useEffect(()=>{const S=oxe({memos:n.filter(D=>D.rowStatus==="ARCHIVED"&&D.deletedAt===""),query:e,HideDoneTasks:!1});o(S),r.setFinish()},[n,i.current,e]);const c=P.useCallback(S=>{o(D=>D.filter(I=
`),Ie!==null&&A.push(S(""+Ie)),null;case"input":A.push(K("input")),ct=$t=it=Ie=null;for(Ue in J)if(n.call(J,Ue)&&(Ft=J[Ue],Ft!=null))switch(Ue){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,"input"));case"defaultChecked":ct=Ft;break;case"defaultValue":it=Ft;break;case"checked":$t=Ft;break;case"value":Ie=Ft;break;default:L(A,oe,Ue,Ft)}return $t!==null?L(A,oe,"checked",$t):ct!==null&&L(A,oe,"checked",ct),Ie!==null?L(A,oe,"value",Ie):it!==null&&L(A,oe,"value",it),A.push("/>"),null;case"menuitem":A.push(K("menuitem"));for(var Ga in J)if(n.call(J,Ga)&&(Ie=J[Ga],Ie!=null))switch(Ga){case"children":case"dangerouslySetInnerHTML":throw Error(t(400));default:L(A,oe,Ga,Ie)}return A.push(">"),null;case"title":A.push(K("title")),Ie=null;for(Pn in J)if(n.call(J,Pn)&&(Ue=J[Pn],Ue!=null))switch(Pn){case"children":Ie=Ue;break;case"dangerouslySetInnerHTML":throw Error(t(434));default:L(A,oe,Pn,Ue)}return A.push(">"),Ie;case"listing":case"pre":A.push(K(U)),Ue=Ie=null;for(ct in J)if(n.call(J,ct)&&(it=J[ct],it!=null))switch(ct){case"children":Ie=it;break;case"dangerouslySetInnerHTML":Ue=it;break;default:L(A,oe,ct,it)}if(A.push(">"),Ue!=null){if(Ie!=null)throw Error(t(60));if(typeof Ue!="object"||!("__html"in Ue))throw Error(t(61));J=Ue.__html,J!=null&&(typeof J=="string"&&0<J.length&&J[0]===`
`),Ie;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":A.push(K(U));for(var ja in J)if(n.call(J,ja)&&(Ie=J[ja],Ie!=null))switch(ja){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,U));default:L(A,oe,ja,Ie)}return A.push("/>"),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return Y(A,J,U,oe);case"html":return Ne.insertionMode===0&&A.push("<!DOCTYPE html>"),Y(A,J,U,oe);default:if(U.indexOf("-")===-1&&typeof J.is!="string")return Y(A,J,U,oe);A.push(K(U)),Ue=Ie=null;for(Ft in J)if(n.call(J,Ft)&&(it=J[Ft],it!=null))switch(Ft){case"children":Ie=it;break;case"dangerouslySetInnerHTML":Ue=it;break;case"style":B(A,oe,it);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:i(Ft)&&typeof it!="function"&&typeof it!="symbol"&&A.push(" ",Ft,'="',S(it),'"')}return A.push(">"),_(A,Ue,Ie),Ie}}function le(A,U,J){if(A.push('<!--$?--><template id="'),J===null)throw Error(t(395));return A.push(J),A.push('"></template>')}function fe(A,U,J,oe){switch(J.insertionMode){case 0:case 1:return A.push('<div hidden id="'),A.push(U.segmentPrefix),U=oe.toString(16),A.push(U),A.push('">');case 2:return A.push('<svg aria-hidden="true" style="display:none" id="'),A.push(U.segmentPrefix),U=oe.toString(16),A.push(U),A.push('">');case 3:return A.push('<math aria-hidden="true" style="display:none" id="'),A.push(U.segmentPrefix),U=oe.toString(16),A.push(U),A.push('">');case 4:return A.push('<table hidden id="'),A.push(U.segmentPrefix),U=oe.toString(16),A.push(U),A.push('">');case 5:return A.push('<table hidden><tbody id="'),A.push(U.segmentPrefix),U=oe.toString(16),A.push(U),A.push('">');case 6:return A.push('<table hidden><tr id="'),A.push(U.segmentPrefix),U=oe.toString(16),A.push(U),A.push('">');case 7:return A.push('<table hidden><colgroup id="'),A.push(U.segmentPrefix),U=oe.toString(16),A.push(U),A.push('">');default:throw Error(t(397))}}function $(A,U){switch(U.insertionMode){case 0:case 1:return A.push("</div>");case 2:return A.push("</svg>");case 3:return A.push("</math>");case 4:return A.push("</table>");case 5:return A.push("</tbody></table>");case 6:return A.push("</tr></table>");case 7:return A.push("</colgroup></table>");default:throw Error(t(397))}}var he=/[<\u2028\u2029]/g;function ie(A){return JSON.stringify(A).replace(he,function(U){switch(U){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}function ce(A,U){return U=U===void 0?"":U,{bootstrapChunks:[],startInlineScript:"<script>",placeholderPrefix:U+"P:",segmentPrefix:U+"S:",boundaryPrefix:U+"B:",idPrefix:U,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1,generateStaticMarkup:A}}function X(A,U,J,oe){return J.generateStaticMarkup?(A.push(S(U)),!1):(U===""?A=oe:(oe&&A.push("<!-- -->"),A.push(S(U)),A=!0),A)}var ae=Object.assign,De=Symbol.for("react.element"),je=Symbol.for("react.portal"),Re=Symbol.for("react.fragment"),Fe=Symbol.for("react.strict_mode"),Be=Symbol.for("react.profiler"),Xe=Symbol.for("react.provider"),Ze=Symbol.for("react.context"),st=Symbol.for("react.forward_ref"),Ct=Symbol.for("react.suspense"),tn=Symbol.for("react.suspense_list"),_e=Symbol.for("react.memo"),et=Symbol.for("react.lazy"),nt=Symbol.for("react.scope"),ht=Symbol.for("react.debug_trace_mode"),St=Symbol.for("react.legacy_hidden"),Tt=Symbol.for("react.default_value"),Gt=Symbol.iterator;function _t(A){if(A==null)return null;if(typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case Re:return"Fragment";case je:return"Portal";case Be:return"Profiler";case Fe:return"StrictMode";case Ct:return"Suspense";ca
`),Xt=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,dn=new Map;function en(F){var H=dn.get(F);if(H===void 0){if(!Xt.test(F))throw Error(t(65,F));H=f("<"+F),dn.set(F,H)}return H}var Zn=f("<!DOCTYPE html>");function kn(F,H,q,re,Ae){switch(H){case"select":F.push(en("select"));var Ee=null,Ve=null;for(Rt in q)if(g.call(q,Rt)){var ot=q[Rt];if(ot!=null)switch(Rt){case"children":Ee=ot;break;case"dangerouslySetInnerHTML":Ve=ot;break;case"defaultValue":case"value":break;default:et(F,re,Rt,ot)}}return F.push(nt),St(F,Ve,Ee),Ee;case"option":Ve=Ae.selectedValue,F.push(en("option"));var It=ot=null,Kt=null,Rt=null;for(Ee in q)if(g.call(q,Ee)){var Hn=q[Ee];if(Hn!=null)switch(Ee){case"children":ot=Hn;break;case"selected":Kt=Hn;break;case"dangerouslySetInnerHTML":Rt=Hn;break;case"value":It=Hn;default:et(F,re,Ee,Hn)}}if(Ve!=null)if(q=It!==null?""+It:Tt(ot),Z(Ve)){for(re=0;re<Ve.length;re++)if(""+Ve[re]===q){F.push(Gt);break}}else""+Ve===q&&F.push(Gt);else Kt&&F.push(Gt);return F.push(nt),St(F,Rt,ot),ot;case"textarea":F.push(en("textarea")),Rt=Ve=Ee=null;for(ot in q)if(g.call(q,ot)&&(It=q[ot],It!=null))switch(ot){case"children":Rt=It;break;case"value":Ee=It;break;case"defaultValue":Ve=It;break;case"dangerouslySetInnerHTML":throw Error(t(91));default:et(F,re,ot,It)}if(Ee===null&&Ve!==null&&(Ee=Ve),F.push(nt),Rt!=null){if(Ee!=null)throw Error(t(92));if(Z(Rt)&&1<Rt.length)throw Error(t(93));Ee=""+Rt}return typeof Ee=="string"&&Ee[0]===`
`&&F.push(Vt),Ee!==null&&F.push(c(_(""+Ee))),null;case"input":F.push(en("input")),It=Rt=ot=Ee=null;for(Ve in q)if(g.call(q,Ve)&&(Kt=q[Ve],Kt!=null))switch(Ve){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,"input"));case"defaultChecked":It=Kt;break;case"defaultValue":ot=Kt;break;case"checked":Rt=Kt;break;case"value":Ee=Kt;break;default:et(F,re,Ve,Kt)}return Rt!==null?et(F,re,"checked",Rt):It!==null&&et(F,re,"checked",It),Ee!==null?et(F,re,"value",Ee):ot!==null&&et(F,re,"value",ot),F.push(ht),null;case"menuitem":F.push(en("menuitem"));for(var oa in q)if(g.call(q,oa)&&(Ee=q[oa],Ee!=null))switch(oa){case"children":case"dangerouslySetInnerHTML":throw Error(t(400));default:et(F,re,oa,Ee)}return F.push(nt),null;case"title":F.push(en("title")),Ee=null;for(Hn in q)if(g.call(q,Hn)&&(Ve=q[Hn],Ve!=null))switch(Hn){case"children":Ee=Ve;break;case"dangerouslySetInnerHTML":throw Error(t(434));default:et(F,re,Hn,Ve)}return F.push(nt),Ee;case"listing":case"pre":F.push(en(H)),Ve=Ee=null;for(It in q)if(g.call(q,It)&&(ot=q[It],ot!=null))switch(It){case"children":Ee=ot;break;case"dangerouslySetInnerHTML":Ve=ot;break;default:et(F,re,It,ot)}if(F.push(nt),Ve!=null){if(Ee!=null)throw Error(t(60));if(typeof Ve!="object"||!("__html"in Ve))throw Error(t(61));q=Ve.__html,q!=null&&(typeof q=="string"&&0<q.length&&q[0]===`
`&&F.push(Vt),Ee;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":F.push(en(H));for(var Ka in q)if(g.call(q,Ka)&&(Ee=q[Ka],Ee!=null))switch(Ka){case"children":case"dangerouslySetInnerHTML":throw Error(t(399,H));default:et(F,re,Ka,Ee)}return F.push(ht),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return _t(F,q,H,re);case"html":return Ae.insertionMode===0&&F.push(Zn),_t(F,q,H,re);default:if(H.indexOf("-")===-1&&typeof q.is!="string")return _t(F,q,H,re);F.push(en(H)),Ve=Ee=null;for(Kt in q)if(g.call(q,Kt)&&(ot=q[Kt],ot!=null))switch(Kt){case"children":Ee=ot;break;case"dangerouslySetInnerHTML":Ve=ot;break;case"style":Ze(F,re,ot);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:D(Kt)&&typeof ot!="function"&&typeof ot!="symbol"&&F.push(st,c(Kt),Ct,c(_(ot)),tn)}return F.push(nt),St(F,Ve,Ee),Ee}}var Er=f("</"),pt=f(">"),Mt=f('<template id="'),Jt=f('"></template>'),sn=f("<!--$-->"),ln=f('<!--$?--><template id="'),vr=f('"></template>'),fr=f("<!--$!-->"),ha=f("<!--/$-->"),jr=f("<template"),nr=f('"'),Lr=f(' data-dgst="');f(' data-msg="'),f(' data-stck="');var te=f("></template>");function me(F,H,q){if(a(F,ln),q===null)throw Error(t(395));return a(F,q),o(F,vr)}var xe=f('<div hidden id="'),Ye=f('">'),He=f("</div>"),Qe=f('<svg aria-hidden="true" style="display:none" id="'),tt=f('">'),kt=f("</svg>"),Yt=f('<math aria-hidden="true" style="display:none" id="'),On=f('">'),yn=f("</math>"),Cr=f('<table hidden id="'),Jn=f('">'),yr=f("</table>"),ta=f('<table hidden><tbody id="'),Pi=f('">'),Nn=f("</tbody></table>"),Aa=f('<table hidden><tr id="'),Fa=f('">'),Zr=f("</tr></table>"),fo=f('<table hidden><colgroup id="'),Oa=f('">'),au=f("</colgroup></table>");function si(F,H,q,re){switch(q.insertionMode){case 0:case 1:return a(F,xe),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Ye);case 2:return a(F,Qe),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,tt);case 3:return a(F,Yt),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,On);case 4:return a(F,Cr),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Jn);case 5:return a(F,ta),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Pi);case 6:return a(F,Aa),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Fa);case 7:return a(F,fo),a(F,H.segmentPrefix),a(F,c(re.toString(16))),o(F,Oa);default:throw Error(t(397))}}function li(F,H){switch(H.insertionMode){case 0:case 1:return o(F,He);case 2:return o(F,kt);case 3:return o(F,yn);case 4:return o(F,yr);case 5:return o(F,Nn);case 6:return o(F,Zr);case 7:return o(F,au);default:throw Error(t(397))}}var ec=f('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),ou=f('$RS("'),us=f('","'),ji=f('")<\/script>'),cs=f('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'),iu=f('$RC("'),ds=f('","'),tc=f('")<\/script>'),An=f('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'),na=f('$RX("'),qs=f('"'),Gs=f(")<\/script>"),ui=f(","),su=/[<\u2028\u2029]/g;function Fo(F){return JSON.stringify(F).replace(su,function(H){switch(H){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no
`,o.current,t.path,I);const N=(R=o.current)==null?void 0:R.querySelectorAll(".internal-link");N==null||N.forEach(k=>{const B=k,L=B.getAttribute("data-href");if(!L)return;r.app.metadataCache.getFirstLinkpathDest(L,t.path)||k.classList.add("is-unresolved"),B.addEventListener("mouseover",V=>{V.stopPropagation(),r.app.workspace.trigger("hover-link",{event:V,source:"thino",hoverParent:I.containerEl,targetEl:B,linktext:L,sourcePath:B.href})})})}M()},[t.content,i]);const y=async()=>{if(f)try{await be.deleteMemoById(a.id),n(a.id)}catch(I){new x.Notice(I.message)}else h()},w=async()=>{switch(a.sourceType){case"DAILY":await z2(a.id,a.path);break;case"CANVAS":await W2(a.id,a.path);break;case"MULTI":await U2(a.path);break;case"FILE":await V2(a.id,a.path);break}},S=async()=>{try{const I=await be.restoreMemoById(a.id),M=r.app,N=M==null?void 0:M.loadLocalStorage("tokenForSync");I&&I.webId&&N&&r.settings.startSync&&await Jg(I.webId),I&&be.editMemo(I),n(a.id),new x.Notice(E("RESTORE SUCCEED"))}catch(I){new x.Notice(I.message)}},D=()=>{f&&h(!1)};return v.jsxs("div",{ref:i,className:`memo-wrapper${"memos-"+a.id}`,onMouseLeave:D,children:[v.jsxs("div",{className:"memo-top-wrapper",children:[v.jsxs("span",{className:"time-text",children:[E("DELETE AT")," ",a.deletedAtStr]}),v.jsxs("div",{className:"btns-container",children:[v.jsx("span",{ref:I=>{I&&x.setIcon(I,"more-horizontal")},className:"btn more-action-btn"}),v.jsx("div",{className:"more-action-btns-wrapper",children:v.jsxs("div",{className:"more-action-btns-container",children:[v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:g.restore,className:"more-action-item-icon"}),v.jsx("span",{className:"btn restore-btn",onClick:S,children:E("RESTORE")})]}),v.jsxs("div",{className:"more-action-menu-item",children:[v.jsx("span",{ref:g.source,className:"more-action-item-icon"}),v.jsx("span",{className:"btn",onClick:w,children:E("SOURCE")})]}),v.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[v.jsx("span",{ref:g.delete,className:"more-action-item-icon"}),v.jsx("span",{className:`btndelete-btn${f?"final-confirm":""}`,onClick:y,children:E(f?"CONFIRM!":"DELETE")})]})]})})]})]}),v.jsx("div",{ref:o,className:"memo-content-text",onContextMenu:I=>{I.preventDefault(),I.stopPropagation()}})]})},Bxe=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:i,filter:l}=t,c=on.getQueryById(l);return!!(r||a&&a.from<a.to||o||i||c)||c||n?e.filter(h=>{let g=!0;if(h.thinoType!==void 0&&n&&h.thinoType==="TASK-DONE"&&(g=!1),h.content.contains("comment:")&&(g=!1),c){const y=JSON.parse(c.querystring);Array.isArray(y)&&(g=Yp(h,y))}if(r){const y=new Set;for(const w of Array.from(h.content.match($r)||[])){const D=w.replace($r,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(ua)||[])){const D=w.replace(ua,"$1").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}for(const w of Array.from(h.content.match(Wa)||[])){const D=w.replace(Wa,"$2").trim().split("/");let I="";for(const M of D)I+=M,y.add(I),I+="/"}y.has(r)||(g=!1)}return a&&a.from<a.to&&(ut.getTimeStampByDate(h.createdAt)<a.from||ut.getTimeStampByDate(h.createdAt)>a.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(h.content.match($r)!==null||h.content.match(Wa)!==null||h.content.match(ua)!==null)||o==="LINKED"&&h.content.match(Mf)===null||o==="IMAGED"&&h.content.match(kf)===null||o==="CONNECTED"&&h.content.match(rd)===null)&&(g=!1),i&&!h.content.toLowerCase().includes(i.toLowerCase())&&(g=!1),g}):e.filter(h=>!h.content.contains("comment:"))},Hxe=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=P.useContext(Lt),r=im(),[a,o]=P.useState([]),i=ne.useRef(null),l=ne.useRef(null);P.useEffect(()=>{l.current&&x.setIcon(l.current,"more-horizontal")},[l]),P.useEffect(()=>{const w=Bxe({memos:n.filter(S=>S.deletedAt!==""&&S.deletedAt),query:e,HideDoneTasks:!1});o(w),r.setFinish()},[n,i.current,e]);const c=P.useCallback(w=>{o(S=>S.filter(D=>D.id!==w))},[]),f=P.useCallback(()=>{dt.setShowSiderbarInMobileView(!0)}
`:""}${t==null?void0:t.AppendViaServer}`);constN=awaitbe.createThino({content:w,isList:f,type:M});N&&(be.pushMemo(N),at.clearQuery()),a.statusCode=200,a.setHeader("Content-Type","application/json"),a.end(JSON.stringify({status:"success",thino:N,link:`obsidian://thino?openId=${N.id}`}))});break}case"/search":{if(r.method!=="GET"){a.statusCode=404,a.end();break}consti=o.query,{keyword:l}=i,c=be.getThinoViaKeyword(l);a.statusCode=200,a.setHeader("Content-Type","application/json");constf=JSON.stringify({status:"success",thinos:c});a.end(f);break}case"/list":{if(r.method!=="GET"){a.statusCode=404,a.end();break}const{count:i}=o.query,l=be.getState().memos.slice(0,parseInt(i));a.statusCode=200,a.setHeader("Content-Type","application/json"),a.end(JSON.stringify({status:"success",thinos:l}));break}case"/info":{if(r.method!=="GET"){a.statusCode=404,a.end();break}const{getSettings:i}=o.query;if(!i){a.statusCode=404,a.end();break}constl=ft.getState().settings;a.statusCode=200,a.setHeader("Content-Type","application/json");constc=JSON.stringify({status:"success",infoSettings:l});a.end(c);break}default:a.statusCode=404,a.end();break}}}catch(o){console.error(o),a.statusCode=500,a.end({status:"error",message:o.message})}});return{listen(r,a){try{n.listen({port:parseInt(a),host:r})}catch(o){console.error(o),newx.Notice(E("Thino - Failed to start HTTP server, please check the port is available."))}newx.Notice(`${E("Thino - Started HTTP server on port")}${a}`)},close(){n.close(),newx.Notice(E("Thino - Terminated HTTP server"))}}}const{clipboard:mr}=x.Platform.isDesktop?require("electron"):"";classDke{constructor(){Se(this,"eventListeners");this.eventListeners={}}on(t,n){this.eventListeners[t]=this.eventListeners[t]||[],this.eventListeners[t].push(n)}once(t,n){n.$emitOnce=!0,this.on(t,n)}removeListener(t,n){if(this.eventListeners[t]){constr=this.eventListeners[t].findIndex(a=>a===n);r>=0&&this.eventListeners[t].splice(r,1)}}removeAllListeners(t){this.eventListeners[t]&&(this.eventListeners[t].length=0)}emit(t,...n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r.call(this,...n),r.$emitOnce&&this.removeListener(t,r)})}}constsp=newDke;letFg=null,NN=mr==null?void0:mr.readText(),AN=mr==null?void0:mr.readImage();mr&&(mr.on=(e,t)=>(sp.on(e,t),mr),mr.once=(e,t)=>(sp.once(e,t),mr),mr.off=(e,t)=>(t?sp.removeListener(e,t):sp.removeAllListeners(e),mr),mr.startWatching=()=>(Fg||(Fg=setInterval(()=>{Tke(NN,NN=mr==null?void0:mr.readText())&&sp.emit("text-changed"),Ike(AN,AN=mr==null?void0:mr.readImage())&&sp.emit("image-changed")},500)),mr),mr.stopWatching=()=>(Fg&&clearInterval(Fg),Fg=null,mr));functionTke(e,t){returnt&&e!==t}functionIke(e,t){return!t.isEmpty()&&e.toDataURL()!==t.toDataURL()}var_N;constnT=(_N=require("electron"))==null?void0:_N.remote;varBN,HN;constFN=(HN=(BN=require("electron"))==null?void0:BN.remote)==null?void0:HN.screen;classEke{constructor(t,n){Se(this,"isRegisted");Se(this,"leaf");Se(this,"clipboard");Se(this,"isScreenTop",!1);Se(this,"currentSplitWindow");Se(this,"intervalNum");Se(this,"allowsCopy",!1);Se(this,"plugin");Se(this,"actionEl",null);this.app=t,this.plugin=n,this.isRegisted=!1,this.leaf=null,this.clipboard=mr}asynconload(){x.Platform.isDesktop&&(this.initGlobalCopyEvents(),awaitthis.registerAllShortcuts(),this.registerEvents())}registerEvents(){this.plugin.registerEvent(this.app.workspace.on("quit",()=>{nT.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally)}))}initGlobalCopyEvents(){this.plugin.addCommand({id:"init-global-copy-events",name:E("Global copy"),callback:()=>{this.allowsCopy=!this.allowsCopy,!this.allowsCopy&&this.clipboard.stopWatching(),this.allowsCopy&&this.clipboard.startWatching(),this.leaf&&this.allowsCopy&&(this.actionEl=this.leaf.view.addAction("clipboard-x","Stop global copying",()=>{vart;this.allowsCopy=!1,this.clipboard.stopWatching(),(t=this.actionEl)==null||t.remove()}))}})}onunload(){this.isRegisted&&(nT.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally),this.clipboard.off("text-changed"),this.cli
\`\`\``),newx.Notice(E("Debug info copied to clipboard"))}catch(t){console.error(t)}}classe3eextendsx.Plugin{constructor(){super(...arguments);Se(this,"settings");Se(this,"settingTab");Se(this,"triggerBySelf",!1);Se(this,"updatedID","");Se(this,"debounceTimer",0);Se(this,"apiHttpServer",null);Se(this,"captureService",null);Se(this,"loaded",!1);Se(this,"MarkdownEditor")}asynconload(){this.MarkdownEditor=Xke(this.app),ft.setPlugin(this),awaitthis.loadSettings(),rMe(),this.registerRibbon(),awaitthis.verify();try{this.settings.ShowUpdateMessage&&awaitthis.checkVersionAndShowChangeLog()}catch(n){console.error(n)}this.settingTab=newgMe(this.app,this),this.addSettingTab(this.settingTab),this.initApp(),this.initEditor(),this.initURIHandler(),this.registerMobileEvent(),this.registerCommands(),this.registerCanvasNodeMemos(),this.registerHoverEvent(),this.registerLinkOpen(),this.registerCodeBlocks(),x.Platform.isMobile&&this.registerMobileNavbar(),this.updateLayoutSettings(),this.registerEditorContextMenu(),this.registerEditorSuggest(neweMe(this.app,this)),this.registerEditorExtension([fke]),this.app.workspace.onLayoutReady(this.onLayoutReady.bind(this)),this.registerView(lo,n=>newvf(n,this))}asyncloadSettings(){this.settings=Object.assign({},Ei,awaitthis.loadData()),ft.setSettings(this.settings)}asyncsaveSettings(){awaitthis.saveData(this.settings),ft.setSettings(this.settings)}onunload(){varr,a;this.app.workspace.detachLeavesOfType(lo),be.clearMemos(),Le.dispatch({type:"CLEAR_MEMOS",payload:null}),Le.dispatch({type:"CLEAR_FILES",payload:null}),Le.dispatch({type:"CLEAR_VIEW",payload:null});constn=document.body.find(".dialog-wrapper");if(n&&((r=n.parentElement)==null||r.detach()),this.apiHttpServer&&(this.apiHttpServer.close(),this.apiHttpServer=null),this.captureService&&this.captureService.onunload(),x.Platform.isMobile){consto=this.app.mobileNavbar;o&&o.showThinoBtnEl&&((a=this.settings)!=null&&a.NavbarButton)&&(o.showThinoBtnEl.detach(),o.showThinoBtnEl=null)}newx.Notice(E("Close Memos Successfully"))}initEditor(){this.register(Dw(x.MetadataCache.prototype,{getFileCache:n=>function(r){return!(r!=null&&r.path)&&!r?null:n.call(this,r)}}))}initApp(){ft.setApp(this.app)}initURIHandler(){this.registerObsidianProtocolHandler("thino",asyncn=>{vari,l,c,f;if(!n)return;if(n.openSettings&&(this.app.setting.open(),this.app.setting.openTabById(this.manifest.id||"obsidian-memos")),n.userid)try{consth=n.userid;mke(h,this.app),gke(x.moment().add(30,"days").valueOf(),this.app),dt.setRefresh(!0)}catch(h){console.error(h),newx.Notice(E("Failed to verify"))}if(n.token)try{consth=n.token;(i=this.app)==null||i.saveLocalStorage("tokenForSync",h),setTimeout(()=>{this.app.setting.open(),this.app.setting.openTabById(this.manifest.id||"obsidian-memos"),this.settingTab.display()},200),newx.Notice(E("Saved sync token successfully"))}catch(h){console.error(h),newx.Notice(E("Failed to save"))}if(n.copyToken){this.app.setting.open(),this.app.setting.openTabById(this.manifest.id??"obsidian-memos");consth=awaitaP();awaitnavigator.clipboard.writeText(h),newx.Notice(E("Copied app id successfully"))}constr=(l=ft.getState())==null?void0:l.verifyState,a=!x.Platform.isDesktop&&await((f=(c=window.Capacitor)==null?void0:c.Plugins.Device)==null?void0:f.getId()),o=x.Platform.isDesktop?awaitcr():(a==null?void0:a.identifier)||(a==null?void0:a.uuid);if(!(!r||(r==null?void0:r.appId)!==o)){if(n.content){consth=n.type,g=decodeURI(n.content)!==n.content?decodeURI(n.content):n.content,y=n.task,w=awaitbe.createThino({content:g,type:h,isList:!!y});if(!w)return;be.pushMemo(w),at.clearQuery()}n.openId&&awaitbe.openThinoByID(n.openId)}})}initGlobalManifest(){dt.setPluginManifest(this.manifest)}stopServer(){this.apiHttpServer&&(this.apiHttpServer.close(),this.apiHttpServer=null)}asyncstopEnableList(){varo,i,l;constn=(o=ft.getState())==null?void0:o.verifyState,r=!x.Platform.isDesktop&&await((l=(i=window.Capacitor)==null?void0:i.Plugins.Device)==null?void0:l.getId()),a=x.Platform.isDesktop?awaitcr():(r==null?void0:r.identifier)||(r==null
`);try{await RN(this.app,this.settings,async(l,c)=>{i=l+i+c;const f=await be.createThino({content:i,type:this.settings.MemoSaveLocation||"DAILY",isList:!0});be.pushMemo(f)})}catch(l){console.error("Configuration failed:",l);return}})})})))}registerCommands(){ew.forEach(n=>{this.addCommand({id:n.id,name:n.name,callback:()=>this.openMemos(n.location,n.cb),hotkeys:[]})}),["Modern","Clean","Minimal","Gradient"].forEach(n=>{this.addCommand({id:`share-thino-via-${n.toLowerCase()}`,name:E("Share thino")+`[${E(n)}]`,editorCallback:(r,a)=>{const o=r.getSelection();if(o.length===0)return;const i={id:`temp-${Date.now()}`,content:o,createdAt:x.moment().format("YYYY-MM-DD HH:mm:ss"),updatedAt:x.moment().format("YYYY-MM-DD HH:mm:ss"),deletedAt:"",pinned:!1,visibility:"PUBLIC",rowStatus:"NORMAL",thinoType:"JOURNAL",hasId:"",linkId:"",resourceList:[],creatorName:"thino",sourceType:"DAILY",path:a.file.path,fileInfo:{tags:[],frontmatter:{}}};sf(i,n.toLowerCase(),a)}})}),this.addCommand({id:"focus-mode",name:"Focus mode",callback:()=>{const n=document.body.hasClass("thino-focus");document.body.toggleClass("thino-focus",!n)}}),this.addCommand({id:"hide-side-bar",name:E("Toggle sidebar visibility"),callback:()=>{const n=dt.getState().isMobileView,r=document.body.hasClass("thino-hide-side-bar");document.body.toggleClass("thino-hide-side-bar",n?!1:!r)}}),this.addCommand({id:"hide-tags",name:E("Toggle tags visibility"),callback:()=>{const n=document.body.hasClass("thino-hide-tags");document.body.toggleClass("thino-hide-tags",!n)}}),this.addCommand({id:"hide-query-list",name:E("Toggle query list visibility"),callback:()=>{const n=document.body.hasClass("thino-hide-query-list");document.body.toggleClass("thino-hide-query-list",!n)}}),this.addCommand({id:"insert-task",name:E("Insert task"),checkCallback:n=>{const r=this.app.plugins.getPlugin("obsidian-tasks-plugin"),a=this.app.workspace.getLeavesOfType("thino_view").first();if(r&&a)return n||this.app.plugins.plugins["obsidian-tasks-plugin"].apiV1.createTaskLineModal().then(i=>{var c;const l=this.app.workspace.activeEditor;l&&((c=l.editor)==null||c.insertText(i))}),!0}}),this.addCommand({id:"show-thino-editor",name:E("Show thino editor"),checkCallback:n=>{if(be.initialized&&ft.initialized){if(!n){if(!ft.getState().view){new x.Notice(E("Please open thino first"));return}new CT(this.app).open()}return!0}}}),this.addCommand({id:"lock-thino",name:E("Lock thino"),checkCallback:n=>{if(this.app.workspace.getActiveViewOfType(vf)&&this.settings.needVerify)return n||dt.setLocked(!0),!0}}),this.addCommand({id:"copy-debug-info",name:E("Copy debug info"),callback:async()=>{await oC(this)}}),this.addCommand({id:"insert-editor",name:E("Insert editor"),checkCallback:n=>{const r=this.app.workspace.getActiveViewOfType(x.MarkdownView);if(r&&r.getViewType()==="markdown")return n||r.editor.replaceSelection("\n```thino\n{\neditor:false\n}\n```\n"),!0}}),this.addCommand({id:"toggle-minimal-thino",name:E("Toggle minimal mode"),callback:()=>{const n=document.body.hasClass("minimal-thino");document.body.toggleClass("minimal-thino",!n)}}),this.addCommand({id:"focus-on-thino-editor",name:E("Focus on thino editor"),callback:()=>this.focusOnEditor(),hotkeys:[]}),this.addCommand({id:"reinit-thino-sync",name:E("ReSync web thinos to local"),callback:()=>{cxe(this.app)}}),this.addCommand({id:"init-thino-sync",name:E("Sync local thinos to web"),callback:async()=>{var r;if(!((r=this.app)==null?void 0:r.loadLocalStorage("tokenForSync"))){new x.Notice(E("Please input token first"));return}if(!this.settings.startSync){new x.Notice(E("Please enable sync first"));return}try{await be.initSync()}catch(a){console.error(a),new x.Notice(E("Init Failed"))}}}),this.addCommand({id:"show-daily-thino",name:E("Show daily thino"),callback:()=>this.openDailyMemo(),hotkeys:[]}),this.addCommand({id:"focus-on-search-bar",name:E("Focus on search bar"),callback:()=>this.searchIt(),hotkeys:[]}),this.addCommand({id:"show-thino-in-popover",name:E("Show-thino in popover(Hover editor)"),callback:()=>this.showInPopover(),hotkeys:[]})}async onLayoutReady(){a