"use strict";varn4=Object.defineProperty;varr4=(e,t,n)=>tine?n4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;varme=(e,t,n)=>(r4(e,typeoft!="symbol"?t+"":t,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});constC=require("obsidian"),b0=require("@codemirror/language"),ep=require("@codemirror/state"),Ci=require("@codemirror/view");varJn=typeofglobalThis<"u"?globalThis:typeofwindow<"u"?window:typeofglobal<"u"?global:typeofself<"u"?self:{};functioner(e){returne&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}varcI={exports:{}},Nh={},dI={exports:{}},kt={},Hb;functiona4(){if(Hb)returnkt;Hb=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"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.iterator;functionv(Z){returnZ===null||typeofZ!="object"?null:(Z=g&&Z[g]||Z["@@iterator"],typeofZ=="function"?Z:null)}varD={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,T={};functionE(Z,G,te){this.props=Z,this.context=G,this.refs=T,this.updater=te||D}E.prototype.isReactComponent={},E.prototype.setState=function(Z,G){if(typeofZ!="object"&&typeofZ!="function"&&Z!=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,Z,G,"setState")},E.prototype.forceUpdate=function(Z){this.updater.enqueueForceUpdate(this,Z,"forceUpdate")};functionO(){}O.prototype=E.prototype;functionk(Z,G,te){this.props=Z,this.context=G,this.refs=T,this.updater=te||D}varj=k.prototype=newO;j.constructor=k,S(j,E.prototype),j.isPureReactComponent=!0;varF=Array.isArray,B=Object.prototype.hasOwnProperty,R={current:null},z={key:!0,ref:!0,__self:!0,__source:!0};functionH(Z,G,te){varge,Ie={},De=null,ke=null;if(G!=null)for(geinG.ref!==void0&&(ke=G.ref),G.key!==void0&&(De=""+G.key),G)B.call(G,ge)&&!z.hasOwnProperty(ge)&&(Ie[ge]=G[ge]);varYe=arguments.length-2;if(Ye===1)Ie.children=te;elseif(1<Ye){for(varRe=Array(Ye),rt=0;rt<Ye;rt++)Re[rt]=arguments[rt+2];Ie.children=Re}if(Z&&Z.defaultProps)for(geinYe=Z.defaultProps,Ye)Ie[ge]===void0&&(Ie[ge]=Ye[ge]);return{$$typeof:e,type:Z,key:De,ref:ke,props:Ie,_owner:R.current}}functionY(Z,G){return{$$typeof:e,type:Z.type,key:G,ref:Z.ref,props:Z.props,_owner:Z._owner}}functionU(Z){returntypeofZ=="object"&&Z!==null&&Z.$$typeof===e}functionJ(Z){varG={"=":"=0",":":"=2"};return"$"+Z.replace(/[=:]/g,function(te){returnG[te]})}varQ=/\/+/g;functionle(Z,G){returntypeofZ=="object"&&Z!==null&&Z.key!=null?J(""+Z.key):G.toString(36)}functionpe(Z,G,te,ge,Ie){varDe=typeofZ;(De==="undefined"||De==="boolean")&&(Z=null);varke=!1;if(Z===null)ke=!0;elseswitch(De){case"string":case"number":ke=!0;break;case"object":switch(Z.$$typeof){casee:caset:ke=!0}}if(ke)returnke=Z,Ie=Ie(ke),Z=ge===""?"."+le(ke,0):ge,F(Ie)?(te="",Z!=null&&(te=Z.replace(Q,"$&/")+"/"),pe(Ie,G,te,"",function(rt){returnrt})):Ie!=null&&(U(Ie)&&(Ie=Y(Ie,te+(!Ie.key||ke&&ke.key===Ie.key?"":(""+Ie.key).replace(Q,"$&/")+"/")+Z)),G.push(Ie)),1;if(ke=0,ge=ge===""?".":ge+":",F(Z))for(varYe=0;Ye<Z.length;Ye++){De=Z[Ye];varRe=ge+le(De,Ye);ke+=pe(De,G,te,Re,Ie)}elseif(Re=v(Z),typeofRe=="function")for(Z=Re.call(Z),Ye=0;!(De=Z.next()).done;)De=De.value,Re=ge+le(De,Ye++),ke+=pe(De,G,te,Re,Ie);elseif(De==="object")throwG=String(Z),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(Z).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.");returnke}functionie(Z,G,te){if(Z==null)returnZ;varge=[],Ie=0;returnpe(Z,ge,"","",function(De){returnG.call(te,De,Ie++)}),ge}functionse(Z){if(Z._status===-1){var
`),startLine:s}:{content:e,startLine:0}}function jN(e){const t=e.split(/\r?\n/),n=[];for(let r=0;r<t.length;r++)new RegExp(bN).test(t[r])&&n.push({line:t[r],index:r+1});return n}async function LN(e,t){let n=t.vault.getAbstractFileByPath(e);return n||(new C.Notice(N("File not found for the given thino path, is creating a new file")),n=await t.vault.create(e,'{"nodes": [], "edges": []}'),Qe.setChangedByMemos(!0)),n}async function RN(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 BN(e){const t=e.split(/\r?\n/),n=[];let r="",a=[],o=0;for(let s=0;s<t.length;s++){const c=t[s];c.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 nk({content:e,isList:t}){const n=Ee.getState().dailyNotesState.settings,r=C.moment(),a=Ue.randomId(16),o=(n==null?void 0:n.MemoOtherSaveLocation.MemoDefaultMultiFilePath)||"Thino",s=`${o}/${r.format("YYYYMMDD")}-${a}.md`,c={id:a,content:e,deletedAt:"",path:s,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:"MULTI"},d=Xe.getState().app,{vault:p,fileManager:m}=d,g=p.getAbstractFileByPath(o);(!g||!(g instanceof C.TFolder))&&(new C.Notice(N("Folder not found for the given thino path, is creating a new folder")),await p.createFolder(o)),Qe.setChangedByMemos(!0);const v=await p.create(s,e);return await m.processFrontMatter(v,D=>{D.id=a,D.createdAt=r.format("YYYY/MM/DD HH:mm:ss"),D.updatedAt=r.format("YYYY/MM/DD HH:mm:ss"),D.thinoType=t?"JOURNAL":"TASK-TODO",D.pinned=!1,D.visibility="PUBLIC",D.rowStatus="NORMAL"}),c}async function rk({content:e,isList:t}){const n=Ee.getState().dailyNotesState.settings,r=C.moment(),a=Ue.randomId(16),o=(n==null?void 0:n.MemoOtherSaveLocation.MemoDefaultSingleFilePath)||"basic.thino.md",s={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"},c=Xe.getState().app,{vault:d}=c;let p=d.getAbstractFileByPath(o);(!p||!(p instanceof C.TFile))&&(new C.Notice(N("File not found for the given thino path, is creating a new file")),p=await d.create(o,""));let m="";try{m=await d.read(p)||await d.cachedRead(p)}catch(O){console.error(O),new C.Notice(N("Failed to read current daily note, check if it exists."))}const g=m.indexOf(`#${r.format("YYYY-MM-DD")}`);let v=m.indexOf(`
${m.substring(v)}`}else E=`${m.substring(0,v)}${T}${m.substring(v)}`;return setTimeout(async()=>{Qe.setChangedByMemos(!0),await d.modify(p,E)},200),s}async function qb(e){const t=Ee.getState().dailyNotesState.settings,n=C.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},s=Xe.getState().app,{vault:c}=s;let d=c.getAbstractFileByPath(a);(!d||!(d instanceof C.TFile))&&(new C.Notice(N("File not found for the given thino path, is creating a new file")),d=await c.create(a,""));let p="";try{p=await c.read(d)||await c.cachedRead(d)}catch(E){console.error(E),new C.Notice(N("Failed to read current daily note, check if it exists."))}const m=p.indexOf(`#${n.format("YYYY-MM-DD")}`);let g=p.indexOf(`
`:"")+s}`,posNum:n}}constLI=e=>e.split(/\r?\n/);asyncfunctionik(e){constt=Ee.getState().dailyNotesState.app,n=t.vault.getAbstractFileByPath(e.path);if(!(ninstanceofC.TFile)){newC.Notice(N("File not found for the given thino path"));return}awaitt.vault.delete(n)}asyncfunctionsk(e){constt=Ee.getState().dailyNotesState.app,n=t.vault.getAbstractFileByPath(e.path);if(!(ninstanceofC.TFile)){newC.Notice(N("File not found for the given thino path"));return}consta=(awaitt.vault.read(n)).split(`
`),o=a.findIndex(d=>d.includes(e.id));if(o===-1){new C.Notice(N("Thino not found"));return}const s=a.findIndex((d,p)=>p>o&&d.trim()==="");s===-1?a.splice(o,a.length-o):a.splice(o,s-o);const c=a.join(`
`);if(!c){new C.Notice(N("Thino not found"));return}Qe.setChangedByMemos(!0),await t.vault.modify(n,c)}async function lk(e){const t=Ee.getState().dailyNotesState.app,n=t.metadataCache.getFirstLinkpathDest("",e.path);if(!n){new C.Notice(N("File not found for the given thino path"));return}const r=await t.vault.read(n),a=JSON.parse(r),o=a.nodes,s=o.findIndex(m=>m.id===e.id);if(s===-1){new C.Notice(N("Thino not found"));return}o.splice(s,1);const c=a.edges;c.filter(m=>m.fromNode===e.id||m.toNode===e.id).forEach(m=>{const g=c.findIndex(v=>v.id===m.id);g!==-1&&c.splice(g,1)}),Qe.setChangedByMemos(!0);const p=JSON.stringify(a,null,2);await t.vault.modify(n,p)}async function uk(e){OI()||new C.Notice(N("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}=Ee.getState().dailyNotesState.app,n=e.id.toString().slice(0,14),r=C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(C.moment(n,"YYYYMMDDHHmmss"))?C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss"):C.moment(n,"YYYYMMDDHHmmss"),a=C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(r,"day"),o=e.path,s=t.getAbstractFileByPath(o);if(!s){new C.Notice(N("Please check your daily note plugin OR periodic notes plugin settings"));return}const c=await t.read(s),d=c.split(`
`),p=a?C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").format("HH:mm"):(parseInt(e.id.toString().slice(10,12))+24).toString()+":"+e.id.toString().slice(12,14),m=d.findIndex(S=>S.includes(e.content.replace(/\n/g,"<br>").trim())&&S.includes(p)),g=parseInt(e.id.slice(14));let v=m;m===-1&&(v=g-1);const D=d[m]||d[g-1];if(!c){new C.Notice(N("Thino not found"));return}if(D===d[v]){Qe.setChangedByMemos(!0),d.splice(v,1),await t.modify(s,d.join(`
`);return await n.modify(r,E),Qe.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:e.updatedAt,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 Si(e,t){if(!e.sourceType||e.sourceType!=="CANVAS")return e;const{vault:n}=Ee.getState().dailyNotesState.app,r=n.getAbstractFileByPath(e.path);if(!r)return e;const a=await n.read(r),o=JSON.parse(a),s=o.nodes.find(p=>p.id===e.id);if(!s)return e;t.content&&(s.text=t.content),t.thinoType&&(s.thinoType=t.thinoType),t.rowStatus&&(s.rowStatus=t.rowStatus),t.visibility&&(s.visibility=t.visibility),t.pinned!==void 0&&(s.pinned=t.pinned),t.webId&&(s.webId=t.webId);const c=C.moment();t.deleted!==void 0&&(s.deletedAt=t.deleted?c.format("YYYY/MM/DD HH:mm:ss"):""),s.updatedAt=c.format("YYYY/MM/DD HH:mm:ss");const d=JSON.stringify(o,null,2);return await n.modify(r,d),Qe.setChangedByMemos(!0),{...e,thinoType:t.thinoType||e.thinoType,createdAt:e.createdAt,updatedAt:e.updatedAt,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?c.format("YYYY/MM/DD HH:mm:ss"):t.deleted===!1?"":e.deletedAt?e.deletedAt:""}}async function Ii(e,t){OI()||new C.Notice(N("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}=Ee.getState().dailyNotesState.app,{settings:r}=Ee.getState().dailyNotesState,a=e.id.toString().slice(0,14),o=C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(C.moment(a,"YYYYMMDDHHmmss"))?C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss"):C.moment(a,"YYYYMMDDHHmmss"),s=C.moment(e.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(o,"day"),c=e.path,d=n.getAbstractFileByPath(c)||n.getAbstractFileByPath(e.path);if(!d)return new C.Notice(N("Please check your daily note plugin OR periodic notes plugin settings")),e;const m=(await n.read(d)).split(`
`].join("");var ye}function Re(W){return W.flags!==void 0?W.flags:[W.global?"g":"",W.ignoreCase?"i":"",W.multiline?"m":"",W.unicode?"u":"",W.sticky?"y":""].join("")}function rt(){for(var W=[].slice.call(arguments),re=W.length,ye=0;ye<re;ye+=1)Q(W[ye]);return o(function(xe,je){for(var _e,ze=new Array(re),gt=0;gt<re;gt+=1){if(!(_e=Y(W[gt]._(xe,je),_e)).status)return _e;ze[gt]=_e.value,je=_e.index}return Y(z(je,ze),_e)})}function Ht(){var W=[].slice.call(arguments);if(W.length===0)throw new Error("seqMap needs at least one argument");var re=W.pop();return ie(re),rt.apply(null,W).map(function(ye){return re.apply(null,ye)})}function Se(){var W=[].slice.call(arguments),re=W.length;if(re===0)return Dt("zero alternates");for(var ye=0;ye<re;ye+=1)Q(W[ye]);return o(function(xe,je){for(var _e,ze=0;ze<W.length;ze+=1)if((_e=Y(W[ze]._(xe,je),_e)).status)return _e;return _e})}function Ze(W,re){return Ke(W,re).or(ft([]))}function Ke(W,re){return Q(W),Q(re),Ht(W,re.then(W).many(),function(ye,xe){return[ye].concat(xe)})}function Je(W){se(W);var re="'"+W+"'";return o(function(ye,xe){var je=xe+W.length,_e=ye.slice(xe,je);return _e===W?z(je,_e):H(xe,re)})}function lt(W,re){(function(je){if(!(je instanceof RegExp))throw new Error("not a regexp: "+je);for(var _e=Re(je),ze=0;ze<_e.length;ze++){var gt=_e.charAt(ze);if(gt!=="i"&>!=="m"&>!=="u"&>!=="s")throw new Error('unsupported regexp flag "'+gt+'": '+je)}})(W),arguments.length>=2?pe(re):re=0;var ye=function(je){return RegExp("^(?:"+je.source+")",Re(je))}(W),xe=""+W;return o(function(je,_e){var ze=ye.exec(je.slice(_e));if(ze){if(0<=re&&re<=ze.length){var gt=ze[0],Vt=ze[re];return z(_e+gt.length,Vt)}return H(_e,"valid match group (0 to "+ze.length+") in "+xe)}return H(_e,xe)})}function ft(W){return o(function(re,ye){return z(ye,W)})}function Dt(W){return o(function(re,ye){return H(ye,W)})}function Ct(W){if(F(W))return o(function(re,ye){var xe=W._(re,ye);return xe.index=ye,xe.value="",xe});if(typeof W=="string")return Ct(Je(W));if(W instanceof RegExp)return Ct(lt(W));throw new Error("not a string, regexp, or parser: "+W)}function un(W){return Q(W),o(function(re,ye){var xe=W._(re,ye),je=re.slice(ye,xe.index);return xe.status?H(ye,'not "'+je+'"'):z(ye,null)})}function Ft(W){return ie(W),o(function(re,ye){var xe=le(re,ye);return ye<re.length&&W(xe)?z(ye+1,xe):H(ye,"a character/byte matching "+W)})}function Ot(W,re){arguments.length<2&&(re=W,W=void 0);var ye=o(function(xe,je){return ye._=re()._,ye._(xe,je)});return W?ye.desc(W):ye}function an(){return Dt("fantasy-land/empty")}s.parse=function(W){if(typeof W!="string"&&!R(W))throw new Error(".parse must be called with a string or Buffer as its argument");var re,ye=this.skip(Ia)._(W,0);return re=ye.status?{status:!0,value:ye.value}:{status:!1,index:J(W,ye.furthest),expected:ye.expected},delete U[W],re},s.tryParse=function(W){var re=this.parse(W);if(re.status)return re.value;var ye=Ye(W,re),xe=new Error(ye);throw xe.type="ParsimmonError",xe.result=re,xe},s.assert=function(W,re){return this.chain(function(ye){return W(ye)?ft(ye):Dt(re)})},s.or=function(W){return Se(this,W)},s.trim=function(W){return this.wrap(W,W)},s.wrap=function(W,re){return Ht(W,this,re,function(ye,xe){return xe})},s.thru=function(W){return W(this)},s.then=function(W){return Q(W),rt(this,W).map(function(re){return re[1]})},s.many=function(){var W=this;return o(function(re,ye){for(var xe=[],je=void 0;;){if(!(je=Y(W._(re,ye),je)).status)return Y(z(ye,xe),je);if(ye===je.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");ye=je.index,xe.push(je.value)}})},s.tieWith=function(W){return se(W),this.map(function(re){if(function(je){if(!B(je))throw new Error("not an array: "+je)}(re),re.length){se(re[0]);for(var ye=re[0],xe=1;xe<re.length;xe++)se(re[xe]),ye+=W+re[xe];return ye}return""})},s.tie=function(){return this.tieWith("")},s.times=function(W,re){var ye=this;return arguments.length<2&&(re=W),pe(W),pe(re),o(function(xe,je){for(var _e=[],ze=void 0,gt=void 0,Vt=0;Vt<W;Vt+=1){if(gt=Y(ze=
`),Ts=Je(`\r
`),Ho=Se(Ts,ji,Pi).desc("newline"),Li=Se(Ho,Ia);o.all=vr,o.alt=Se,o.any=Tn,o.cr=Pi,o.createLanguage=function(W){var re={};for(var ye in W)({}).hasOwnProperty.call(W,ye)&&function(xe){re[xe]=Ot(function(){return W[xe](re)})}(ye);return re},o.crlf=Ts,o.custom=function(W){return o(W(z,H))},o.digit=tr,o.digits=Nr,o.empty=an,o.end=Li,o.eof=Ia,o.fail=Dt,o.formatError=Ye,o.index=wn,o.isParser=F,o.lazy=Ot,o.letter=Is,o.letters=ho,o.lf=ji,o.lookahead=Ct,o.makeFailure=H,o.makeSuccess=z,o.newline=Ho,o.noneOf=function(W){return Ft(function(re){return W.indexOf(re)<0}).desc("none of '"+W+"'")},o.notFollowedBy=un,o.of=ft,o.oneOf=function(W){for(var re=W.split(""),ye=0;ye<re.length;ye++)re[ye]="'"+re[ye]+"'";return Ft(function(xe){return W.indexOf(xe)>=0}).desc(re)},o.optWhitespace=po,o.Parser=o,o.range=function(W,re){return Ft(function(ye){return W<=ye&&ye<=re}).desc(W+"-"+re)},o.regex=lt,o.regexp=lt,o.sepBy=Ze,o.sepBy1=Ke,o.seq=rt,o.seqMap=Ht,o.seqObj=function(){for(var W,re={},ye=0,xe=(W=arguments,Array.prototype.slice.call(W)),je=xe.length,_e=0;_e<je;_e+=1){var ze=xe[_e];if(!F(ze)){if(B(ze)&&ze.length===2&&typeof ze[0]=="string"&&F(ze[1])){var gt=ze[0];if(Object.prototype.hasOwnProperty.call(re,gt))throw new Error("seqObj: duplicate key "+gt);re[gt]=!0,ye++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(ye===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(Vt,On){for(var bn,na={},Pn=0;Pn<je;Pn+=1){var wr,ra;if(B(xe[Pn])?(wr=xe[Pn][0],ra=xe[Pn][1]):(wr=null,ra=xe[Pn]),!(bn=Y(ra._(Vt,On),bn)).status)return bn;wr&&(na[wr]=bn.value),On=bn.index}return Y(z(On,na),bn)})},o.string=Je,o.succeed=ft,o.takeWhile=function(W){return ie(W),o(function(re,ye){for(var xe=ye;xe<re.length&&W(le(re,xe));)xe++;return z(xe,re.slice(ye,xe))})},o.test=Ft,o.whitespace=Nl,o["fantasy-land/empty"]=an,o["fantasy-land/of"]=ft,o.Binary={bitSeq:D,bitSeqObj:function(W){v();var re={},ye=0,xe=p(function(_e){if(B(_e)){var ze=_e;if(ze.length!==2)throw new Error("["+ze.join(", ")+"] should be length 2, got length "+ze.length);if(se(ze[0]),pe(ze[1]),Object.prototype.hasOwnProperty.call(re,ze[0]))throw new Error("duplicate key in bitSeqObj: "+ze[0]);return re[ze[0]]=!0,ye++,ze}return pe(_e),[null,_e]},W);if(ye<1)throw new Error("bitSeqObj expects at least one named pair, got ["+W.join(", ")+"]");var je=p(function(_e){return _e[0]},xe);return D(p(function(_e){return _e[1]},xe)).map(function(_e){return d(function(ze,gt){return gt[0]!==null&&(ze[gt[0]]=gt[1]),ze},{},p(function(ze,gt){return[ze,_e[gt]]},je))})},byte:function(W){if(v(),pe(W),W>255)throw new Error("Value specified to byte constructor ("+W+"=0x"+W.toString(16)+") is larger in value than a single byte.");var re=(W>15?"0x":"0x0")+W.toString(16);return o(function(ye,xe){var je=le(ye,xe);return je===W?z(xe+1,je):H(xe,re)})},buffer:function(W){return S("buffer",W).map(function(re){return Buffer.from(re)})},encodedString:function(W,re){return S("string",re).map(function(ye){return ye.toString(W)})},uintBE:E,uint8BE:E(1),uint16BE:E(2),uint32BE:E(4),uintLE:O,uint8LE:O(1),uint16LE:O(2),uint32LE:O(4),intBE:k,int8BE:k(1),int16BE:k(2),int32BE:k(4),intLE:j,int8LE:j(1),int16LE:j(2),int32LE:j(4),floatBE:S("floatBE",4).map(function(W){return W.readFloatBE(0)}),floatLE:S("floatLE",4).map(function(W){return W.readFloatLE(0)}),doubleBE:S("doubleBE",8).map(function(W){return W.readDoubleBE(0)}),doubleLE:S("doubleLE",8).map(function(W){return W.readDoubleLE(0)})},n.exports=o}])})})(X);var g1=()=>/(?:[#*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\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\
${o}`,posNum:n}}function _6(e,t,n){var a;const r=t.workspace.getLeavesOfType("markdown");for(const o of r){const s=o.view;if(((a=s==null?void 0:s.file)==null?void 0:a.path)===e){t.workspace.revealLeaf(o);try{return o.view.setEphemeralState({line:n}),!0}catch(c){return console.error(c),!1}}}return!1}const v1=async e=>{var o;const t=Xe.getState().app,n=t.workspace.getLeavesOfType("markdown");for(const s of n){const c=s.view;if(((o=c==null?void 0:c.file)==null?void 0:o.path)===e){t.workspace.revealLeaf(s);return}}const r=t.metadataCache.getFirstLinkpathDest("",e);if(!r){new C.Notice(N("File not found for the given thino path"));return}await t.workspace.getLeaf(!0).openFile(r)},w1=async(e,t)=>{const{app:n}=Xe.getState(),r=parseInt(e.slice(14));if(_6(t,n,r))return;const a=n.metadataCache.getFirstLinkpathDest("",t);if(!C.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}})}},b1=async(e,t)=>{var p,m,g;const n=Xe.getState().app,r=n.metadataCache.getFirstLinkpathDest("",t);if(!r){new C.Notice(N("File not found for the given thino path"));return}let a="";try{a=await n.vault.read(r)}catch(v){console.error(v),a=await n.vault.cachedRead(r)}const s=a.split(/\r?\n/).findIndex(v=>v.contains(e)),c=n.workspace.getLeavesOfType("markdown");for(const v of c){const D=v.view;if(((p=D==null?void 0:D.file)==null?void 0:p.path)===r.path){n.workspace.revealLeaf(v);try{(m=v.view.editor)==null||m.setCursor({line:s,ch:1});return}catch(S){console.error(S)}}}const d=n.workspace.getLeaf(!0);await d.openFile(r,{eState:{line:s}});try{(g=d.view.editor)==null||g.setCursor({line:s,ch:1})}catch(v){console.error(v)}},D1=async(e,t)=>{var c;const n=Xe.getState().app,r=(d,p)=>{var g;const m=(g=Array.from(d.nodes.values()))==null?void 0:g.find(v=>v.id===p);return m?(d.selectOnly(m),d.zoomToSelection(),!0):!1},a=n.workspace.getLeavesOfType("canvas");for(const d of a){const p=d.view;if(((c=p==null?void 0:p.file)==null?void 0:c.path)===t&&(n.workspace.revealLeaf(d),r(p.canvas,e)))return}const o=n.metadataCache.getFirstLinkpathDest("",t);if(!o){new C.Notice(N("File not found for the given thino path"));return}const s=n.workspace.getLeaf(!0);await s.openFile(o),setTimeout(()=>{var d;r((d=s.view)==null?void 0:d.canvas,e)},10)},H6="https://api.thino.pkmer.cn/test",Vd=H6,Y6="unknown",z6=/!\[(?<content>[^\]]+)\]\((?<link>[^)]+)\)/g;function U6(e){return e.substring(e.lastIndexOf(".")+1)}function V6(e){return{id:e.id,createdAt:Date.now().toString(),filename:e.id,type:`${U6(e.id)}`,size:e.size.toString()}}function Z6(e){const t=e==null?void 0:e.matchAll(z6);return t?Array.from(t).map(n=>{var r;return V6({url:(r=n.groups)==null?void 0:r.link,id:Y6,size:0,mtime:""})}).filter(n=>n.type!="html"):[]}function kp(e){var t;return{id:e.id,createdAt:C.moment(e.ctime.toString(),"x").format("YYYY/MM/DD HH:mm:ss"),updatedAt:C.moment(e.mtime.toString(),"x").format("YYYY/MM/DD HH:mm:ss"),deletedAt:(t=e.ttime)!=null&&t.toString()?C.moment(e.ttime.toString(),"x").format("YYYY-MM-DD HH:mm:ss"):"",rowStatus:e.rowStatus,content:e.content,pinned:e.pinned,resourceList:Z6(e.content),creatorName:"thino",sourceType:(e==null?void 0:e.thinoType)||"FILE",visibility:"PUBLIC",localId:e.originalId,deleted:!!e.dtime}}async function W6(e){const n={url:`${Vd}/thino/getThinos${e?`?since=${e}&includeDeleted=true`:""}`,method:"GET",headers:{Authorization:`Bearer${Zd()}`}};return C.requestUrl(n).then(r=>{r.status>=400&&console.error(`Failedtofetchmemos:${r.status}`);try{return r.json.payload.map(o=>kp(o))}catch(a){console.error(`Errorprocessingmemoresponse:${a}`)}}).catch(r=>(console.error(r),[]))}function Zd(){const e=Ee.getState().dailyNotesState.app||app;return(e==null?void 0:e.loadLocalStorage("tokenForSync"))||""}async function RT(e){const t=`${Vd}/thino/createThino`,n={content:e.content,thinoType:(e==null?void 0:e.thinoType)||"FILE",pinned:!1,rowStatus:"NORMAL",encrypted:!1},r={url:t,method:"POST",contentType:"application/json",body:JSON.stringify(n),headers:{Auth
Checkthedocumentationorcreateissueifyouthinkit's bug. https://github.com/webscopeio/react-textarea-autocomplete/issues`))},H8=[".","^","$","*","+","-","?","(",")","[","]","{","}","\\","|"],Ag=function(t){return j8(t).map(function(n){return H8.includes(n)?"\\".concat(n):n}).join("")},Y8=function(e){Yy(t,e);function t(){return Op(this,t),Hy(this,Nd(t).apply(this,arguments))}return _y(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,s=this.props.left||0,c=[],d=[],p=0,m=0,g=this.containerElem.getBoundingClientRect(),v=this.ref.getBoundingClientRect(),D=this.props.textareaRef.getBoundingClientRect(),S=window.getComputedStyle(this.ref),T=parseInt(S.getPropertyValue("margin-top"),10),E=parseInt(S.getPropertyValue("margin-bottom"),10),O=parseInt(S.getPropertyValue("margin-left"),10),k=parseInt(S.getPropertyValue("margin-right"),10),j=T+E+D.top+o+v.height,F=O+k+D.left+s+v.width;F>g.right&&D.left+s>v.width?(m=s-v.width,c.push(dl.X.LEFT),d.push(dl.X.RIGHT)):(m=s,c.push(dl.X.RIGHT),d.push(dl.X.LEFT)),j>g.bottom&&D.top+o>v.height?(p=o-v.height,c.push(dl.Y.TOP),d.push(dl.Y.BOTTOM)):(p=o,c.push(dl.Y.BOTTOM),d.push(dl.Y.TOP)),this.props.renderToBody&&(p+=D.top,m+=D.left),this.ref.style.top="".concat(p,"px"),this.ref.style.left="".concat(m,"px"),(r=this.ref.classList).remove.apply(r,d),(a=this.ref.classList).add.apply(a,c)}},{key:"render",value:function(){var r=this,a=this.props,o=a.style,s=a.className,c=a.innerRef,d=a.children,p=a.renderToBody,m=document.body,g=$.createElement("div",{ref:function(D){r.ref=D,c(D)},className:"rta__autocomplete ".concat(s||""),style:o},d);return p&&m!==null?T1.createPortal(g,m):g}}]),t}($.Component),WT=function(e){Yy(t,e);function t(n){var r;Op(this,t),r=Hy(this,Nd(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=Eu.add(Ha.ESC,r._closeAutocomplete))},r.escListenerDestroy=function(){r.escListener&&(Eu.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 d=r.textareaRef,p=d.selectionStart,m=d.selectionEnd;return p===m?null:r.state.value.substr(p,m-p)},r.setCaretPosition=function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;r.textareaRef&&(r.textareaRef.focus(),r.textareaRef.setSelectionRange(d,d))},r.getCaretPosition=function(){if(!r.textareaRef)return 0;var d=r.textareaRef.selectionEnd;return d},r._handleCaretChange=function(d){var p=function(){var v=r.getCaretPosition()-1;r.lastTrigger=r.lastTrigger?v:0};if(d.type==="keydown"){var m=d.keyCode||d.which;switch(m){case Ha.UP:case Ha.DOWN:r._isAutocompleteOpen()||p();break;case Ha.LEFT:case Ha.RIGHT:p();break}return}p()},r._onSelect=function(d){var p=r.state,m=p.selectionEnd,g=p.currentTrigger,v=p.value,D=r.props.onItemSelected;if(g){var S=r._getTextToReplace(g);if(!S){r._closeAutocomplete();return}var T=S(d);if(!T){r._closeAutocomplete();return}D&&D({currentTrigger:g,item:d});var E=function(U,J,Q){switch(U){case"start":return Q;case"next":case"end":return Q+J.length;default:if(!Number.isInteger(U))throw new Error('RTA:caretPositionshouldbe"start","next","end"ornumber.');returnU}},O=v.slice(0,m),k=Ag(g),j=O.length-O.lastIndexOf(g),F=O.search(newRegExp("(?!".concat(k,")$")))
`));if(v===null)return null;if(typeof v=="string")return{text:v,caretPosition:PD};if(!v.text&&typeof v.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(d,`"
`));if(!v.caretPosition)throw new Error('Output "caretPosition" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(d,`"
`));return v}if(typeof g!="string")throw new Error(`Outputitemshouldbestring
`);return{text:"".concat(d).concat(g).concat(d),caretPosition:PD}}},r._getCurrentTriggerSettings=function(){var d=r.state.currentTrigger;return d?r.props.trigger[d]:null},r._getValuesFromProvider=function(){var d=r.state,p=d.currentTrigger,m=d.actualToken,g=r._getCurrentTriggerSettings();if(!(!p||!g)){var v=g.dataProvider,D=g.component;if(typeof v!="function")throw new Error("Trigger provider has to be a function!");r.setState({dataLoading:!0});var S=v(m);S instanceof Promise||(S=Promise.resolve(S)),S.then(function(T){if(!Array.isArray(T))throw new Error("Trigger provider has to provide an array!");if(typeof D!="function")throw new Error("Component should be defined!");if(p===r.state.currentTrigger){if(!T.length){r._closeAutocomplete();return}r.setState({dataLoading:!1,data:T,component:D})}}).catch(function(T){return jD(T.message)})}},r._getSuggestions=function(){var d=r.state,p=d.currentTrigger,m=d.data;return!p||!m||m&&!m.length?null:m},r._createRegExp=function(){var d=r.props.trigger;r.tokenRegExp=new RegExp("(".concat(Object.keys(d).sort(function(p,m){return p<m?1:p>m?-1:0}).map(function(p){return Ag(p)}).join("|"),")((?:(?!\\1)[^\\s])*$)")),r.tokenRegExpEnding=new RegExp("(".concat(Object.keys(d).sort(function(p,m){return p<m?1:p>m?-1:0}).map(function(p){return Ag(p)}).join("|"),")$"))},r._closeAutocomplete=function(){var d=r.state.currentTrigger;r.escListenerDestroy(),r.setState({data:null,dataLoading:!1,currentTrigger:null},function(){d&&r._onItemHighlightedHandler(null)})},r._cleanUpProps=function(){var d=k8({},r.props),p=["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 m in d)p.includes(m)&&delete d[m];return d},r._changeHandler=function(d){var p=r.props,m=p.trigger,g=p.onChange,v=p.minChar,D=p.onCaretPositionChange,S=p.movePopupAsYouType,T=r.state,E=T.top,O=T.left,k=d;k||(k=new M8("change",{bubbles:!0}),r.textareaRef.dispatchEvent(k));var j=k.target||r.textareaRef,F=j.selectionEnd,B=j.value;if(r.lastValueBubbledEvent=B,g&&k&&(k.persist&&k.persist(),g(new Proxy(k,{get:function(Z,G,te){return G==="target"?j:Reflect.get(Z,G,te)}}))),D){var R=r.getCaretPosition();D(R)}r.setState({value:B});var z=function(){var Z=E8(j,F),G=Z.top,te=Z.left;r.setState({top:G-r.textareaRef.scrollTop||0,left:te})},H=function(Z){r.lastTrigger=F-Z,r._closeAutocomplete(),z()};if(F<=r.lastTrigger){var Y=B.slice(0,F),U=r.tokenRegExp.exec(Y);H(U?U[0].length:0)}var J=B.slice(r.lastTrigger,F),Q=r.tokenRegExp.exec(J),le=Q&&Q[0],pe=Q&&Q[1]||null,ie=pe?pe.length-1:0,se=r.tokenRegExpEnding.exec(J);if(se?H(se[0].length):r._isAutocompleteOpen()||r._closeAutocomplete(),(!le||le.length<=v+ie)&&(r.state.currentTrigger&&!m[r.state.currentTrigger].allowWhitespace||!r.state.currentTrigger)){r._closeAutocomplete();return}if(pe&&m[pe].afterWhitespace&&!/\s/.test(B[F-le.length-1])&&B[F-le.length-1]!==void 0){r._closeAutocomplete();return}if(r.state.currentTrigger&&m[r.state.currentTrigger].allowWhitespace){if(Q=new RegExp("".concat(Ag(r.state.currentTrigger),".*$")).exec(B.slice(0,F)),le=Q&&Q[0],!le){r._closeAutocomplete();return}pe=Object.keys(m).find(function(we){return we.slice(0,ie+1)===le.slice(0,ie+1)})||null}var fe=le.slice(1);if(pe){(S||E===null&&O===null||r.state.currentTrigger!==pe)&&z(),r.escListenerInit();var oe=r._getTextToReplace(pe);r.setState({selectionEnd:F,currentTrigger:pe,textToReplace:oe,actualToken:fe},function(){try{r._getValuesFromProvider()}catch(we){jD(we.message)}})}},r._selectHandler=function(d){var p=r.props,m=p.onCaretPositionChange,g=p.onSelect;if(m){var v=r.getCaretPosition();m(v)}g&&(d.persist(),g(d))},r._shouldStayOpen=function(d){var p=d.relatedTarget;return p===null&&(p=document.activeElement),!!(r.dropdownRef&&p instanceof Node&&r.dropdow
`,o.current,t.path,E);const k=(j=o.current)==null?void 0:j.querySelectorAll(".internal-link");k==null||k.forEach(F=>{const B=F,R=B.getAttribute("data-href");if(!R)return;r.app.metadataCache.getFirstLinkpathDest(R,t.path)||F.classList.add("is-unresolved"),B.addEventListener("mouseover",H=>{H.stopPropagation(),r.app.workspace.trigger("hover-link",{event:H,source:"thino",hoverParent:E.containerEl,targetEl:B,linktext:R,sourcePath:B.href})})})}O()},[t.content,s]);const v=async()=>{if(p)try{await Te.deleteMemoById(a.id),n(a.id)}catch(E){new C.Notice(E.message)}else m()},D=async()=>{switch(a.sourceType){case"DAILY":await w1(a.id,a.path);break;case"CANVAS":await D1(a.id,a.path);break;case"MULTI":await v1(a.path);break;case"FILE":await b1(a.id,a.path);break}},S=async()=>{try{const E=await Te.restoreMemoById(a.id),O=r.app,k=O==null?void 0:O.loadLocalStorage("tokenForSync");E&&E.webId&&k&&r.settings.startSync&&await BT(E.webId),E&&Te.editMemo(E),n(a.id),new C.Notice(N("RESTORE SUCCEED"))}catch(E){new C.Notice(E.message)}},T=()=>{p&&m(!1)};return w.jsxs("div",{ref:s,className:`memo-wrapper${"memos-"+a.id}`,onMouseLeave:T,children:[w.jsxs("div",{className:"memo-top-wrapper",children:[w.jsxs("span",{className:"time-text",children:[N("DELETE AT")," ",a.deletedAtStr]}),w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{ref:E=>{E&&C.setIcon(E,"more-horizontal")},className:"btn more-action-btn"}),w.jsx("div",{className:"more-action-btns-wrapper",children:w.jsxs("div",{className:"more-action-btns-container",children:[w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:g.restore,className:"more-action-item-icon"}),w.jsx("span",{className:"btn restore-btn",onClick:S,children:N("RESTORE")})]}),w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:g.source,className:"more-action-item-icon"}),w.jsx("span",{className:"btn",onClick:D,children:N("SOURCE")})]}),w.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[w.jsx("span",{ref:g.delete,className:"more-action-item-icon"}),w.jsx("span",{className:`btndelete-btn${p?"final-confirm":""}`,onClick:v,children:N(p?"CONFIRM!":"DELETE")})]})]})})]})]}),w.jsx("div",{ref:o,className:"memo-content-text",onContextMenu:E=>{E.preventDefault(),E.stopPropagation()}})]})},eK=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:s,filter:c}=t,d=Et.getQueryById(c);return!!(r||a&&a.from<a.to||o||s||d)||d||n?e.filter(m=>{let g=!0;if(m.thinoType!==void 0&&n&&m.thinoType==="TASK-DONE"&&(g=!1),m.content.contains("comment:")&&(g=!1),d){const v=JSON.parse(d.querystring);Array.isArray(v)&&(g=Wd(m,v))}if(r){const v=new Set;for(const D of Array.from(m.content.match(Fn)||[])){const T=D.replace(Fn,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match($n)||[])){const T=D.replace($n,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match(mr)||[])){const T=D.replace(mr,"$2").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}v.has(r)||(g=!1)}return a&&a.from<a.to&&(Ue.getTimeStampByDate(m.createdAt)<a.from||Ue.getTimeStampByDate(m.createdAt)>a.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(m.content.match(Fn)!==null||m.content.match(mr)!==null||m.content.match($n)!==null)||o==="LINKED"&&m.content.match(Bu)===null||o==="IMAGED"&&m.content.match(_u)===null||o==="CONNECTED"&&m.content.match(Il)===null)&&(g=!1),s&&!m.content.toLowerCase().includes(s.toLowerCase())&&(g=!1),g}):e.filter(m=>!m.content.contains("comment:"))},tK=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=A.useContext(mt),r=af(),[a,o]=A.useState([]),s=$.useRef(null);A.useEffect(()=>{const p=eK({memos:n.filter(m=>m.deletedAt!==""&&m.deletedAt),query:e,HideDoneTasks:!1});o(p),r.setFinish()},[n,s.current,e]);const c=A.useCallback(p=>{o(m=>m.filter(g=>g.id!==p))},[]),d=A.useCallback(()=>{Qe.setShowSiderbarInMobileView(!0)},[]);return w.jsxs("div",{className:"memo-trash-wrapper",ref:s,children:[w.jsxs("div",{classNam
`,s.current,a.path,r);const j=(B=s.current)==null?void 0:B.querySelectorAll(".internal-link");j==null||j.forEach(R=>{const z=R,H=z.getAttribute("data-href");if(!H)return;t.metadataCache.getFirstLinkpathDest(H,a.path)||R.classList.add("is-unresolved"),z.addEventListener("mouseover",U=>{U.stopPropagation(),t.workspace.trigger("hover-link",{event:U,source:"thino",hoverParent:r.containerEl,targetEl:z,linktext:H,sourcePath:z.href})})})}k()},[a.content,c]);const S=async()=>{switch(m.sourceType){case"DAILY":await w1(m.id,m.path);break;case"CANVAS":await D1(m.id,m.path);break;case"MULTI":await v1(m.path);break;case"FILE":await b1(m.id,m.path);break}},T=async()=>{if(g)try{if(n.DeleteThinoDirectly)await Te.deleteMemoById(m.id);else{const k=await Te.hideMemoById(m.id);k&&Te.editMemo(k)}}catch(k){new C.Notice(k.message)}else v()},E=async()=>{try{const k=await Te.unarchiveMemo(m);k&&Te.editMemo(k),o(m.id),new C.Notice(N("RESTORE SUCCEED"))}catch(k){new C.Notice(k.message)}},O=()=>{g&&v(!1)};return w.jsxs("div",{ref:c,className:`memo-wrapper${"memos-"+m.id}`,onMouseLeave:O,children:[w.jsxs("div",{className:"memo-top-wrapper",children:[w.jsxs("span",{className:"time-text",children:[N("ARCHIVED AT")," ",m.updatedAt]}),w.jsxs("div",{className:"btns-container",children:[w.jsx("span",{ref:k=>{k&&C.setIcon(k,"more-horizontal")},className:"btn more-action-btn"}),w.jsx("div",{className:"more-action-btns-wrapper",children:w.jsxs("div",{className:"more-action-btns-container",children:[w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:D.restore,className:"more-action-item-icon"}),w.jsx("span",{className:"btn restore-btn",onClick:E,children:N("RESTORE")})]}),w.jsxs("div",{className:"more-action-menu-item",children:[w.jsx("span",{ref:D.source,className:"more-action-item-icon"}),w.jsx("span",{className:"btn",onClick:S,children:N("SOURCE")})]}),w.jsxs("div",{className:"more-action-menu-item delete-menu-item",children:[w.jsx("span",{ref:D.delete,className:"more-action-item-icon"}),w.jsx("span",{className:`btndelete-btn${g?"final-confirm":""}`,onClick:T,children:N(g?"CONFIRM!":"DELETE")})]})]})})]})]}),w.jsx("div",{ref:s,className:"memo-content-text"})]})},oK=({memos:e,query:t,HideDoneTasks:n})=>{const{tag:r,duration:a,type:o,text:s,filter:c}=t,d=Et.getQueryById(c);return!!(r||a&&a.from<a.to||o||s||d)||d||n?e.filter(m=>{let g=!0;if(m.thinoType!==void 0&&n&&m.thinoType==="TASK-DONE"&&(g=!1),m.content.contains("comment:")&&(g=!1),d){const v=JSON.parse(d.querystring);Array.isArray(v)&&(g=Wd(m,v))}if(r){const v=new Set;for(const D of Array.from(m.content.match(Fn)||[])){const T=D.replace(Fn,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match($n)||[])){const T=D.replace($n,"$1").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}for(const D of Array.from(m.content.match(mr)||[])){const T=D.replace(mr,"$2").trim().split("/");let E="";for(const O of T)E+=O,v.add(E),E+="/"}v.has(r)||(g=!1)}return a&&a.from<a.to&&(Ue.getTimeStampByDate(m.createdAt)<a.from||Ue.getTimeStampByDate(m.createdAt)>a.to)&&(g=!1),o&&(o==="NOT_TAGGED"&&(m.content.match(Fn)!==null||m.content.match(mr)!==null||m.content.match($n)!==null)||o==="LINKED"&&m.content.match(Bu)===null||o==="IMAGED"&&m.content.match(_u)===null||o==="CONNECTED"&&m.content.match(Il)===null)&&(g=!1),s&&!m.content.toLowerCase().includes(s.toLowerCase())&&(g=!1),g}):e.filter(m=>!m.content.contains("comment:"))},iK=()=>{const{locationState:{query:e},globalState:{isMobileView:t},memoState:{memos:n}}=A.useContext(mt),r=af(),[a,o]=A.useState([]),s=$.useRef(null);A.useEffect(()=>{const m=oK({memos:n.filter(g=>g.rowStatus==="ARCHIVED"&&g.deletedAt===""),query:e,HideDoneTasks:!1});o(m),r.setFinish()},[n,s.current,e]);const c=A.useCallback(m=>{o(g=>g.filter(v=>v.id!==m))},[]),d=A.useCallback(m=>{o(g=>g.filter(v=>v.id!==m))},[]),p=A.useCallback(()=>{Qe.setShowSiderbarInMobileView(!0)},[]);return w.jsxs("div",{className:"memo-trash-wrapper",ref:s,children:[w.jsxs("div",{className:"section-header-container",children:[w.jsx
${k}`}}}const T=await Te.createThino({content:g,isList:d,type:p});T&&(Te.pushMemo(T),He.clearQuery()),r.statusCode=200,r.setHeader("Content-Type","application/json"),r.end(JSON.stringify({status:"success",thino:T,link:`obsidian://thino?openId=${T.id}`}))})}else if(a.pathname==="/search"&&n.method==="GET"){const o=a.query,{keyword:s}=o,c=Te.getThinoViaKeyword(s);r.statusCode=200,r.setHeader("Content-Type","application/json");const d=JSON.stringify({status:"success",thinos:c});r.end(d)}else r.statusCode=404,r.end()}}catch(a){console.error(a),r.statusCode=500,r.end({status:"error",message:a.message})}});return{listen(n,r){try{t.listen({port:parseInt(r),host:n})}catch(a){console.error(a),new C.Notice(N("Thino - Failed to start HTTP server, please check the port is available."))}new C.Notice(`${N("Thino - Started HTTP server on port")} ${r}`)},close(){t.close(),new C.Notice(N("Thino - Terminated HTTP server"))}}}const{clipboard:gn}=C.Platform.isDesktop?require("electron"):"";class BQ{constructor(){me(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]){const r=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)})}}const Dd=new BQ;let Hh=null,eI=gn==null?void 0:gn.readText(),tI=gn==null?void 0:gn.readImage();gn&&(gn.on=(e,t)=>(Dd.on(e,t),gn),gn.once=(e,t)=>(Dd.once(e,t),gn),gn.off=(e,t)=>(t?Dd.removeListener(e,t):Dd.removeAllListeners(e),gn),gn.startWatching=()=>(Hh||(Hh=setInterval(()=>{_Q(eI,eI=gn==null?void 0:gn.readText())&&Dd.emit("text-changed"),HQ(tI,tI=gn==null?void 0:gn.readImage())&&Dd.emit("image-changed")},500)),gn),gn.stopWatching=()=>(Hh&&clearInterval(Hh),Hh=null,gn));function _Q(e,t){return t&&e!==t}function HQ(e,t){return!t.isEmpty()&&e.toDataURL()!==t.toDataURL()}var sI;const sw=(sI=require("electron"))==null?void 0:sI.remote;var lI,uI;const nI=(uI=(lI=require("electron"))==null?void 0:lI.remote)==null?void 0:uI.screen;class YQ{constructor(t,n){me(this,"isRegisted");me(this,"leaf");me(this,"clipboard");me(this,"isScreenTop",!1);me(this,"currentSplitWindow");me(this,"intervalNum");me(this,"allowsCopy",!1);me(this,"plugin");me(this,"actionEl",null);this.app=t,this.plugin=n,this.isRegisted=!1,this.leaf=null,this.clipboard=gn}async onload(){C.Platform.isDesktop&&(this.initGlobalCopyEvents(),await this.registerAllShortcuts(),this.registerEvents())}registerEvents(){this.plugin.registerEvent(this.app.workspace.on("quit",()=>{sw.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally)}))}initGlobalCopyEvents(){this.plugin.addCommand({id:"init-global-copy-events",name:N("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",()=>{var t;this.allowsCopy=!1,this.clipboard.stopWatching(),(t=this.actionEl)==null||t.remove()}))}})}onunload(){this.isRegisted&&(sw.globalShortcut.unregister(this.plugin.settings.CaptureKey.OpenThinoGlobally),this.clipboard.off("text-changed"),this.clipboard.off("image-changed"),this.clipboard.stopWatching(),this.leaf&&this.leaf.detach())}getCurrentLeaf(){var n;return this.leaf?this.app.workspace.getLeavesOfType("thino_view").length>0&&!!this.app.workspace.getLeafById(this.leaf.id)?!0:((n=this.leaf)==null||n.detach(),this.currentSplitWindow.close(),this.currentSplitWindow=null,this.leaf=null,this.isScreenTop=!1,!1):!1}async registerAllShortcuts(){sw.globalShortcut.register(this.plugin.settings.CaptureKey.OpenThinoGlobally,()=>{this.getCurrentLeaf()?this.showThinoView():this.openThinoView()}),this.isRegisted=!0}showThinoView(){var r,a,o,s;const t=nI.getCursorScreenPoint(),n
\`\`\``),newC.Notice(N("Debug info copied to clipboard"))}catch(n){console.error(n)}}}),this.addCommand({id:"insert-editor",name:N("Insert editor"),checkCallback:n=>{constr=this.app.workspace.getActiveViewOfType(C.MarkdownView);if(r&&r.getViewType()==="markdown")returnn||r.editor.replaceSelection("\n```thino\n{\n editor: false\n}\n```\n"),!0}}),this.addCommand({id:"toggle-minimal-thino",name:N("Toggle minimal mode"),callback:()=>{constn=document.body.hasClass("minimal-thino");document.body.toggleClass("minimal-thino",!n)}}),this.addCommand({id:"focus-on-thino-editor",name:N("Focus on thino editor"),callback:()=>this.focusOnEditor(),hotkeys:[]}),this.addCommand({id:"reinit-thino-sync",name:N("ReSync web thinos to local"),callback:()=>{HJ(this.app)}}),this.addCommand({id:"init-thino-sync",name:N("Sync local thinos to web"),callback:async()=>{varr;if(!((r=this.app)==null?void0:r.loadLocalStorage("tokenForSync"))){newC.Notice(N("Please input token first"));return}if(!this.settings.startSync){newC.Notice(N("Please enable sync first"));return}try{awaitTe.initSync()}catch(a){console.error(a),newC.Notice(N("Init Failed"))}}}),this.addCommand({id:"show-daily-thino",name:N("Show daily thino"),callback:()=>this.openDailyMemo(),hotkeys:[]}),this.addCommand({id:"focus-on-search-bar",name:N("Focus on search bar"),callback:()=>this.searchIt(),hotkeys:[]}),this.addCommand({id:"show-thino-in-popover",name:N("Show-thino in popover(Hover editor)"),callback:()=>this.showInPopover(),hotkeys:[]})}asynconLayoutReady(){this.initApp(),awaitthis.initServer(),this.initGlobalManifest(),awaitthis.initMemos(),this.autoOpenMemos(),this.registerThinoWidget(),awaitthis.registerToolbarCheck(),awaitthis.initCaptureService(),Xe.setPlugin(this);constn=this.app.workspace.editorSuggest.suggests.findIndex(r=>r.type==="customTag");n!==-1?(this.app.workspace.editorSuggest.suggests.splice(n,1),this.app.workspace.editorSuggest.suggests.unshift(newrI(this.app,this))):this.app.workspace.editorSuggest.suggests.unshift(newrI(this.app,this))}asyncinitMemos(){try{awaitthis.initDailyNotes()}catch(n){console.error(n)}Xe.getState(),Te.getState(),awaitTe.fetchAllMemos()}asyncinitDailyNotes(){this.settings.EnabledLocationList.find(n=>n.value==="DAILY")&&awaitXe.fechLocalDailyNotes()}registerCanvasNodeMemos(){if(!C.requireApiVersion("1.2.0")||!this.settings.EnabledLocationList.find(o=>o.value==="CANVAS"))return;constn=o=>{clearTimeout(this.debounceTimer),this.debounceTimer=window.setTimeout(()=>{setTimeout(async()=>{consts=o.canvas.getData(),c=s.nodes.find(d=>d.id===o.id);if(c&&(r(c),o.canvas.setData(s),Te.getMemoById(o.id))){constp=awaitTe.updateMemo(o.id,c.text,c.thinoType);Te.editMemo(p)}o.canvas.requestSave(!0)},0)},800)},r=o=>{o.createdAt||(o.createdAt=C.moment().format("YYYY-MM-DD HH:mm:ss")),o.updatedAt=C.moment().format("YYYY-MM-DD HH:mm:ss"),o.deletedAt=o.deletedAt?o.deletedAt:"",o.pinned=o.pinned?o.pinned:!1,o.visibility=o.visibility?o.visibility:"PUBLIC",o.rowStatus=o.rowStatus?o.rowStatus:"NORMAL",o.thinoType=o.thinoType?o.thinoType:"JOURNAL",o.hasId=o.hasId?o.hasId:"",o.linkId=o.linkId?o.linkId:"",o.resourceList=[]},a=()=>{varv,D;consto=(v=this.app.workspace.getLeavesOfType("canvas").first())==null?void0:v.view;if(!o||!(o==null?void0:o.canvas))return!1;constc=((D=this.app.workspace.getLeavesOfType("canvas").first())==null?void0:D.view).canvas.nodes.values(),p=Array.from(c).filter(S=>S.text!==void0);if(!p||p.length===0)return!1;constm=p[0].child;if(!m)return!1;constg=qh(m.constructor.prototype,{save:S=>function(...T){S.call(this,...T),this.node.isEditing&&n(this.node)}});returnthis.register(g),!0};this.app.workspace.onLayoutReady(()=>{if(!a()){consto=this.app.workspace.on("layout-change",()=>{a()&&this.app.workspace.offref(o)});this.registerEvent(o)}})}registerLinkOpen(){qh(C.Workspace.prototype,{openLinkText:n=>asyncfunction(r,a,o,s,...c){constd=Te.getState().memos;if(d.find(p=>p.id===r||p.id===a)){constp=d.find(m=>m.id===r||m.id===a);$d(p);return}n.call(this,r,a,o,s,...c)}})}registerHoverEvent(){this.registerHoverLinkSo