vault backup: 2025-08-03 11:01:42
This commit is contained in:
1 parent
52c61d3ad8
commit
dc7b44d2ea
39 files changed
+679
-648
No files matched your search
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
"devMode": false,
|
||||
"templateFolderPath": "",
|
||||
"announceUpdates": true,
|
||||
"version": "1.17.0",
|
||||
"version": "1.18.1",
|
||||
"disableOnlineFeatures": true,
|
||||
"enableRibbonIcon": false,
|
||||
"ai": {
|
||||
|
||||
Vendored
+58
-58
@@ -3,86 +3,86 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
|
||||
var R4=Object.create;var T1=Object.defineProperty;var n4=Object.getOwnPropertyDescriptor;var X4=Object.getOwnPropertyNames;var p4=Object.getPrototypeOf,s4=Object.prototype.hasOwnProperty;var e4=(G,I,l)=>I in G?T1(G,I,{enumerable:!0,configurable:!0,writable:!0,value:l}):G[I]=l;var fa=(G,I)=>()=>(I||G((I={exports:{}}).exports,I),I.exports),t4=(G,I)=>{for(var l in I)T1(G,l,{get:I[l],enumerable:!0})},ja=(G,I,l,c)=>{if(I&&typeof I=="object"||typeof I=="function")for(let b of X4(I))!s4.call(G,b)&&b!==l&&T1(G,b,{get:()=>I[b],enumerable:!(c=n4(I,b))||c.enumerable});return G};var dW=(G,I,l)=>(l=G!=null?R4(p4(G)):{},ja(I||!G||!G.__esModule?T1(l,"default",{value:G,enumerable:!0}):l,G)),E4=G=>ja(T1({},"__esModule",{value:!0}),G);var oI=(G,I,l)=>(e4(G,typeof I!="symbol"?I+"":I,l),l);var UV=fa(cd=>{"use strict";cd.byteLength=HY;cd.toByteArray=nY;cd.fromByteArray=sY;var x2=[],c2=[],YY=typeof Uint8Array<"u"?Uint8Array:Array,o3="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(WG=0,xV=o3.length;WG<xV;++WG)x2[WG]=o3[WG],c2[o3.charCodeAt(WG)]=WG;var WG,xV;c2["-".charCodeAt(0)]=62;c2["_".charCodeAt(0)]=63;function kV(G){var I=G.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=G.indexOf("=");l===-1&&(l=I);var c=l===I?0:4-l%4;return[l,c]}function HY(G){var I=kV(G),l=I[0],c=I[1];return(l+c)*3/4-c}function RY(G,I,l){return(I+l)*3/4-l}function nY(G){var I,l=kV(G),c=l[0],b=l[1],Z=new YY(RY(G,c,b)),d=0,W=b>0?c-4:c,a;for(a=0;a<W;a+=4)I=c2[G.charCodeAt(a)]<<18|c2[G.charCodeAt(a+1)]<<12|c2[G.charCodeAt(a+2)]<<6|c2[G.charCodeAt(a+3)],Z[d++]=I>>16&255,Z[d++]=I>>8&255,Z[d++]=I&255;return b===2&&(I=c2[G.charCodeAt(a)]<<2|c2[G.charCodeAt(a+1)]>>4,Z[d++]=I&255),b===1&&(I=c2[G.charCodeAt(a)]<<10|c2[G.charCodeAt(a+1)]<<4|c2[G.charCodeAt(a+2)]>>2,Z[d++]=I>>8&255,Z[d++]=I&255),Z}function XY(G){return x2[G>>18&63]+x2[G>>12&63]+x2[G>>6&63]+x2[G&63]}function pY(G,I,l){for(var c,b=[],Z=I;Z<l;Z+=3)c=(G[Z]<<16&16711680)+(G[Z+1]<<8&65280)+(G[Z+2]&255),b.push(XY(c));return b.join("")}function sY(G){for(var I,l=G.length,c=l%3,b=[],Z=16383,d=0,W=l-c;d<W;d+=Z)b.push(pY(G,d,d+Z>W?W:d+Z));return c===1?(I=G[l-1],b.push(x2[I>>2]+x2[I<<4&63]+"==")):c===2&&(I=(G[l-2]<<8)+G[l-1],b.push(x2[I>>10]+x2[I>>4&63]+x2[I<<2&63]+"=")),b.join("")}});var A5=fa(j2=>{"use strict";Object.defineProperty(j2,"__esModule",{value:!0});require("obsidian");var dc=class extends Error{},S3=class extends dc{constructor(I){super(`Invalid DateTime: ${I.toMessage()}`)}},D3=class extends dc{constructor(I){super(`Invalid Interval: ${I.toMessage()}`)}},K3=class extends dc{constructor(I){super(`Invalid Duration: ${I.toMessage()}`)}},hG=class extends dc{},pd=class extends dc{constructor(I){super(`Invalid unit ${I}`)}},Al=class extends dc{},L2=class extends dc{constructor(){super("Zone is an abstract class")}},L="numeric",t2="short",jl="long",sd={year:L,month:L,day:L},AN={year:L,month:t2,day:L},jY={year:L,month:t2,day:L,weekday:t2},gN={year:L,month:jl,day:L},zN={year:L,month:jl,day:L,weekday:jl},xN={hour:L,minute:L},kN={hour:L,minute:L,second:L},UN={hour:L,minute:L,second:L,timeZoneName:t2},MN={hour:L,minute:L,second:L,timeZoneName:jl},BN={hour:L,minute:L,hourCycle:"h23"},LN={hour:L,minute:L,second:L,hourCycle:"h23"},fN={hour:L,minute:L,second:L,hourCycle:"h23",timeZoneName:t2},jN={hour:L,minute:L,second:L,hourCycle:"h23",timeZoneName:jl},TN={year:L,month:L,day:L,hour:L,minute:L},CN={year:L,month:L,day:L,hour:L,minute:L,second:L},SN={year:L,month:t2,day:L,hour:L,minute:L},DN={year:L,month:t2,day:L,hour:L,minute:L,second:L},TY={year:L,month:t2,day:L,weekday:t2,hour:L,minute:L},KN={year:L,month:jl,day:L,hour:L,minute:L,timeZoneName:t2},ON={year:L,month:jl,day:L,hour:L,minute:L,second:L,timeZoneName:t2},PN={year:L,month:jl,day:L,weekday:jl,hour:L,minute:L,timeZoneName:jl},qN={year:L,month:jl,day:L,weekday:jl,hour:L,minute:L,second:L,timeZoneName:jl},HG=class{get type(){throw new L2}get name(){throw new L2}get ianaName(){return this.name}get isUniversal(){throw new L2}offsetName(I,l){throw new L2}formatOffset(I,l){throw new L2}offset(I){throw new L2}equals(I){throw new L2}get isValid(){throw new L2}},U3=null,y1=class extends HG{static get instance(){return U3===null&&(U3=new y1),U3}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(I,{format:l,locale:c}){return $N(I,l,c)}formatOffset(I,l){return wb(this.offset(I),l)}offset(I){return-new Date(I).getTimezoneOffset()}equals(I){return I.type==="system"}get isValid(){return!0}},nd={};function CY(G){return nd[G]||(nd[G]=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:G,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"})),nd[G]}var SY={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function DY(G,I){let l=G.format(I).replace(/\u200E/g,""),c=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(l),[,b,Z,d,W,a,m,V]=c;return[d,b,Z,W,a,m,V]}function KY(G,Line truncated
|
||||
`||H.charAt(k)==="\r"&&H.charAt(k+1)!==`
|
||||
`)&&(A++,x===0&&(x=k+1)),k--}var II=o+A,tI=p-x;return u[p]={line:II,lineStart:x},{offset:p,line:II+1,column:tI+1}}function y(H){if(!Y(H))throw new Error("not a parser: "+H)}function cI(H,p){return typeof H=="string"?H.charAt(p):H[p]}function dI(H){if(typeof H!="number")throw new Error("not a number: "+H)}function YI(H){if(typeof H!="function")throw new Error("not a function: "+H)}function hI(H){if(typeof H!="string")throw new Error("not a string: "+H)}var uI=2,Sl=3,xI=8,W2=5*xI,dl=4*xI,nl=" ";function a2(H,p){return new Array(p+1).join(H)}function z(H,p,u){var o=p-H.length;return o<=0?H:a2(u,o)+H}function VI(H,p,u,o){return{from:H-p>0?H-p:0,to:H+u>o?o:H+u}}function pI(H,p){var u,o,A,x,k,II=p.index,tI=II.offset,tl=1;if(tI===H.length)return"Got the end of the input";if(Q(H)){var al=tI-tI%xI,D2=tI-al,zl=VI(al,W2,dl+xI,H.length),K2=m(function(SI){return m(function(uG){return z(uG.toString(16),2,"0")},SI)},function(SI,uG){var QG=SI.length,Ac=[],vG=0;if(QG<=uG)return[SI.slice()];for(var JG=0;JG<QG;JG++)Ac[vG]||Ac.push([]),Ac[vG].push(SI[JG]),(JG+1)%uG==0&&vG++;return Ac}(H.slice(zl.from,zl.to).toJSON().data,xI));x=function(SI){return SI.from===0&&SI.to===1?{from:SI.from,to:SI.to}:{from:SI.from/xI,to:Math.floor(SI.to/xI)}}(zl),o=al/xI,u=3*D2,D2>=4&&(u+=1),tl=2,A=m(function(SI){return SI.length<=4?SI.join(" "):SI.slice(0,4).join(" ")+" "+SI.slice(4).join(" ")},K2),(k=(8*(x.to>0?x.to-1:x.to)).toString(16).length)<2&&(k=2)}else{var EG=H.split(/\r\n|[\n\r\u2028\u2029]/);u=II.column-1,o=II.line-1,x=VI(o,uI,Sl,EG.length),A=EG.slice(x.from,x.to),k=x.to.toString().length}var H4=o-x.from;return Q(H)&&(k=(8*(x.to>0?x.to-1:x.to)).toString(16).length)<2&&(k=2),a(function(SI,uG,QG){var Ac,vG=QG===H4,JG=vG?"> ":nl;return Ac=Q(H)?z((8*(x.from+QG)).toString(16),k,"0"):z((x.from+QG+1).toString(),k," "),[].concat(SI,[JG+Ac+" | "+uG],vG?[nl+a2(" ",k)+" | "+z("",u," ")+a2("^",tl)]:[])},[],A).join(`
|
||||
`)}function Wl(H,p){return[`
|
||||
`,"-- PARSING FAILED "+a2("-",50),`
|
||||
var zR=Object.create;var Jc=Object.defineProperty;var xR=Object.getOwnPropertyDescriptor;var UR=Object.getOwnPropertyNames;var BR=Object.getPrototypeOf,rR=Object.prototype.hasOwnProperty;var OR=(l,I,G)=>I in l?Jc(l,I,{enumerable:!0,configurable:!0,writable:!0,value:G}):l[I]=G;var EV=(l,I)=>()=>(I||l((I={exports:{}}).exports,I),I.exports),MR=(l,I)=>{for(var G in I)Jc(l,G,{get:I[G],enumerable:!0})},JV=(l,I,G,b)=>{if(I&&typeof I=="object"||typeof I=="function")for(let Z of UR(I))!rR.call(l,Z)&&Z!==G&&Jc(l,Z,{get:()=>I[Z],enumerable:!(b=xR(I,Z))||b.enumerable});return l};var MN=(l,I,G)=>(G=l!=null?zR(BR(l)):{},JV(I||!l||!l.__esModule?Jc(G,"default",{value:l,enumerable:!0}):G,l)),jR=l=>JV(Jc({},"__esModule",{value:!0}),l);var sI=(l,I,G)=>OR(l,typeof I!="symbol"?I+"":I,G);var ca=EV(zd=>{"use strict";zd.byteLength=yH;zd.toByteArray=CH;zd.fromByteArray=LH;var El=[],TG=[],sH=typeof Uint8Array<"u"?Uint8Array:Array,VY="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(qb=0,ba=VY.length;qb<ba;++qb)El[qb]=VY[qb],TG[VY.charCodeAt(qb)]=qb;var qb,ba;TG[45]=62;TG[95]=63;function Za(l){var I=l.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var G=l.indexOf("=");G===-1&&(G=I);var b=G===I?0:4-G%4;return[G,b]}function yH(l){var I=Za(l),G=I[0],b=I[1];return(G+b)*3/4-b}function eH(l,I,G){return(I+G)*3/4-G}function CH(l){var I,G=Za(l),b=G[0],Z=G[1],c=new sH(eH(l,b,Z)),W=0,d=Z>0?b-4:b,N;for(N=0;N<d;N+=4)I=TG[l.charCodeAt(N)]<<18|TG[l.charCodeAt(N+1)]<<12|TG[l.charCodeAt(N+2)]<<6|TG[l.charCodeAt(N+3)],c[W++]=I>>16&255,c[W++]=I>>8&255,c[W++]=I&255;return Z===2&&(I=TG[l.charCodeAt(N)]<<2|TG[l.charCodeAt(N+1)]>>4,c[W++]=I&255),Z===1&&(I=TG[l.charCodeAt(N)]<<10|TG[l.charCodeAt(N+1)]<<4|TG[l.charCodeAt(N+2)]>>2,c[W++]=I>>8&255,c[W++]=I&255),c}function gH(l){return El[l>>18&63]+El[l>>12&63]+El[l>>6&63]+El[l&63]}function AH(l,I,G){for(var b,Z=[],c=I;c<G;c+=3)b=(l[c]<<16&16711680)+(l[c+1]<<8&65280)+(l[c+2]&255),Z.push(gH(b));return Z.join("")}function LH(l){for(var I,G=l.length,b=G%3,Z=[],c=16383,W=0,d=G-b;W<d;W+=c)Z.push(AH(l,W,W+c>d?d:W+c));return b===1?(I=l[G-1],Z.push(El[I>>2]+El[I<<4&63]+"==")):b===2&&(I=(l[G-2]<<8)+l[G-1],Z.push(El[I>>10]+El[I>>4&63]+El[I<<2&63]+"=")),Z.join("")}});var IR=EV(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});require("obsidian");var ql=class extends Error{},sY=class extends ql{constructor(I){super(`Invalid DateTime: ${I.toMessage()}`)}},yY=class extends ql{constructor(I){super(`Invalid Interval: ${I.toMessage()}`)}},eY=class extends ql{constructor(I){super(`Invalid Duration: ${I.toMessage()}`)}},$b=class extends ql{},IN=class extends ql{constructor(I){super(`Invalid unit ${I}`)}},JG=class extends ql{},Cl=class extends ql{constructor(){super("Zone is an abstract class")}},B="numeric",al="short",oG="long",GN={year:B,month:B,day:B},IF={year:B,month:al,day:B},bp={year:B,month:al,day:B,weekday:al},GF={year:B,month:oG,day:B},lF={year:B,month:oG,day:B,weekday:oG},bF={hour:B,minute:B},ZF={hour:B,minute:B,second:B},cF={hour:B,minute:B,second:B,timeZoneName:al},WF={hour:B,minute:B,second:B,timeZoneName:oG},dF={hour:B,minute:B,hourCycle:"h23"},NF={hour:B,minute:B,second:B,hourCycle:"h23"},mF={hour:B,minute:B,second:B,hourCycle:"h23",timeZoneName:al},YF={hour:B,minute:B,second:B,hourCycle:"h23",timeZoneName:oG},VF={year:B,month:B,day:B,hour:B,minute:B},hF={year:B,month:B,day:B,hour:B,minute:B,second:B},aF={year:B,month:al,day:B,hour:B,minute:B},FF={year:B,month:al,day:B,hour:B,minute:B,second:B},Zp={year:B,month:al,day:B,weekday:al,hour:B,minute:B},RF={year:B,month:oG,day:B,hour:B,minute:B,timeZoneName:al},XF={year:B,month:oG,day:B,hour:B,minute:B,second:B,timeZoneName:al},QF={year:B,month:oG,day:B,weekday:oG,hour:B,minute:B,timeZoneName:oG},HF={year:B,month:oG,day:B,weekday:oG,hour:B,minute:B,second:B,timeZoneName:oG},lZ=class{get type(){throw new Cl}get name(){throw new Cl}get ianaName(){return this.name}get isUniversal(){throw new Cl}offsetName(I,G){throw new Cl}formatOffset(I,G){throw new Cl}offset(I){throw new Cl}equals(I){throw new Cl}get isValid(){throw new Cl}},pY=null,lN=class l extends lZ{static get instance(){return pY===null&&(pY=new l),pY}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(I,{format:G,locale:b}){return uF(I,G,b)}formatOffset(I,G){return VW(this.offset(I),G)}offset(I){return-new Date(I).getTimezoneOffset()}equals(I){return I.type==="system"}get isValid(){return!0}},_d={};function cp(l){return _d[l]||(_d[l]=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:l,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"})),_d[l]}var Wp={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function dp(l,I){let G=l.format(I).replace(/\u200E/g,""),b=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(G),[,Z,c,W,d,N,m,Y]=b;return[W,Z,c,d,N,m,Y]}function Np(l,I){let G=l.formatToParts(I),b=[];Line truncated
|
||||
`||R.charAt(i)==="\r"&&R.charAt(i+1)!==`
|
||||
`)&&(L++,k===0&&(k=i+1)),i--}var f=e+L,nI=p-k;return E[p]={line:f,lineStart:k},{offset:p,line:f+1,column:nI+1}}function x(R){if(!F(R))throw new Error("not a parser: "+R)}function GI(R,p){return typeof R=="string"?R.charAt(p):R[p]}function lI(R){if(typeof R!="number")throw new Error("not a number: "+R)}function aI(R){if(typeof R!="function")throw new Error("not a function: "+R)}function hI(R){if(typeof R!="string")throw new Error("not a string: "+R)}var vI=2,zG=3,kI=8,$G=5*kI,lG=4*kI,YG=" ";function Il(R,p){return new Array(p+1).join(R)}function o(R,p,E){var e=p-R.length;return e<=0?R:Il(E,e)+R}function NI(R,p,E,e){return{from:R-p>0?R-p:0,to:R+E>e?e:R+E}}function QI(R,p){var E,e,L,k,i,f=p.index,nI=f.offset,XG=1;if(nI===R.length)return"Got the end of the input";if(y(R)){var ZG=nI-nI%kI,il=nI-ZG,sG=NI(ZG,$G,lG+kI,R.length),zl=m(function(KI){return m(function(mZ){return o(mZ.toString(16),2,"0")},KI)},function(KI,mZ){var YZ=KI.length,nb=[],VZ=0;if(YZ<=mZ)return[KI.slice()];for(var hZ=0;hZ<YZ;hZ++)nb[VZ]||nb.push([]),nb[VZ].push(KI[hZ]),(hZ+1)%mZ==0&&VZ++;return nb}(R.slice(sG.from,sG.to).toJSON().data,kI));k=function(KI){return KI.from===0&&KI.to===1?{from:KI.from,to:KI.to}:{from:KI.from/kI,to:Math.floor(KI.to/kI)}}(sG),e=ZG/kI,E=3*il,il>=4&&(E+=1),XG=2,L=m(function(KI){return KI.length<=4?KI.join(" "):KI.slice(0,4).join(" ")+" "+KI.slice(4).join(" ")},zl),(i=(8*(k.to>0?k.to-1:k.to)).toString(16).length)<2&&(i=2)}else{var NZ=R.split(/\r\n|[\n\r\u2028\u2029]/);E=f.column-1,e=f.line-1,k=NI(e,vI,zG,NZ.length),L=NZ.slice(k.from,k.to),i=k.to.toString().length}var iR=e-k.from;return y(R)&&(i=(8*(k.to>0?k.to-1:k.to)).toString(16).length)<2&&(i=2),N(function(KI,mZ,YZ){var nb,VZ=YZ===iR,hZ=VZ?"> ":YG;return nb=y(R)?o((8*(k.from+YZ)).toString(16),i,"0"):o((k.from+YZ+1).toString(),i," "),[].concat(KI,[hZ+nb+" | "+mZ],VZ?[YG+Il(" ",i)+" | "+o("",E," ")+Il("^",XG)]:[])},[],L).join(`
|
||||
`)}function bG(R,p){return[`
|
||||
`,"-- PARSING FAILED "+Il("-",50),`
|
||||
|
||||
`,pI(H,p),`
|
||||
`,QI(R,p),`
|
||||
|
||||
`,(u=p.expected,u.length===1?`Expected:
|
||||
`,(E=p.expected,E.length===1?`Expected:
|
||||
|
||||
`+u[0]:`Expected one of the following:
|
||||
`+E[0]:`Expected one of the following:
|
||||
|
||||
`+u.join(", ")),`
|
||||
`].join("");var u}function J2(H){return H.flags!==void 0?H.flags:[H.global?"g":"",H.ignoreCase?"i":"",H.multiline?"m":"",H.unicode?"u":"",H.sticky?"y":""].join("")}function Vc(){for(var H=[].slice.call(arguments),p=H.length,u=0;u<p;u+=1)y(H[u]);return Z(function(o,A){for(var x,k=new Array(p),II=0;II<p;II+=1){if(!(x=v(H[II]._(o,A),x)).status)return x;k[II]=x.value,A=x.index}return v(e(A,k),x)})}function S2(){var H=[].slice.call(arguments);if(H.length===0)throw new Error("seqMap needs at least one argument");var p=H.pop();return YI(p),Vc.apply(null,H).map(function(u){return p.apply(null,u)})}function Nc(){var H=[].slice.call(arguments),p=H.length;if(p===0)return ic("zero alternates");for(var u=0;u<p;u+=1)y(H[u]);return Z(function(o,A){for(var x,k=0;k<H.length;k+=1)if((x=v(H[k]._(o,A),x)).status)return x;return x})}function Cb(H,p){return pG(H,p).or(w2([]))}function pG(H,p){return y(H),y(p),S2(H,p.then(H).many(),function(u,o){return[u].concat(o)})}function oc(H){hI(H);var p="'"+H+"'";return Z(function(u,o){var A=o+H.length,x=u.slice(o,A);return x===H?e(A,x):w(o,p)})}function m2(H,p){(function(A){if(!(A instanceof RegExp))throw new Error("not a regexp: "+A);for(var x=J2(A),k=0;k<x.length;k++){var II=x.charAt(k);if(II!=="i"&&II!=="m"&&II!=="u"&&II!=="s")throw new Error('unsupported regexp flag "'+II+'": '+A)}})(H),arguments.length>=2?dI(p):p=0;var u=function(A){return RegExp("^(?:"+A.source+")",J2(A))}(H),o=""+H;return Z(function(A,x){var k=u.exec(A.slice(x));if(k){if(0<=p&&p<=k.length){var II=k[0],tI=k[p];return e(x+II.length,tI)}return w(x,"valid match group (0 to "+k.length+") in "+o)}return w(x,o)})}function w2(H){return Z(function(p,u){return e(u,H)})}function ic(H){return Z(function(p,u){return w(u,H)})}function sG(H){if(Y(H))return Z(function(p,u){var o=H._(p,u);return o.index=u,o.value="",o});if(typeof H=="string")return sG(oc(H));if(H instanceof RegExp)return sG(m2(H));throw new Error("not a string, regexp, or parser: "+H)}function Sb(H){return y(H),Z(function(p,u){var o=H._(p,u),A=p.slice(u,o.index);return o.status?w(u,'not "'+A+'"'):e(u,null)})}function Dl(H){return YI(H),Z(function(p,u){var o=cI(p,u);return u<p.length&&H(o)?e(u+1,o):w(u,"a character/byte matching "+H)})}function rc(H,p){arguments.length<2&&(p=H,H=void 0);var u=Z(function(o,A){return u._=p()._,u._(o,A)});return H?u.desc(H):u}function eG(){return ic("fantasy-land/empty")}d.parse=function(H){if(typeof H!="string"&&!Q(H))throw new Error(".parse must be called with a string or Buffer as its argument");var p,u=this.skip(tG)._(H,0);return p=u.status?{status:!0,value:u.value}:{status:!1,index:bI(H,u.furthest),expected:u.expected},delete T[H],p},d.tryParse=function(H){var p=this.parse(H);if(p.status)return p.value;var u=Wl(H,p),o=new Error(u);throw o.type="ParsimmonError",o.result=p,o},d.assert=function(H,p){return this.chain(function(u){return H(u)?w2(u):ic(p)})},d.or=function(H){return Nc(this,H)},d.trim=function(H){return this.wrap(H,H)},d.wrap=function(H,p){return S2(H,this,p,function(u,o){return o})},d.thru=function(H){return H(this)},d.then=function(H){return y(H),Vc(this,H).map(function(p){return p[1]})},d.many=function(){var H=this;return Z(function(p,u){for(var o=[],A=void 0;;){if(!(A=v(H._(p,u),A)).status)return v(e(u,o),A);if(u===A.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");u=A.index,o.push(A.value)}})},d.tieWith=function(H){return hI(H),this.map(function(p){if(function(A){if(!t(A))throw new Error("not an array: "+A)}(p),p.length){hI(p[0]);for(var u=p[0],o=1;o<p.length;o++)hI(p[o]),u+=H+p[o];return u}return""})},d.tie=function(){return this.tieWith("")},d.times=function(H,p){var u=this;return arguments.length<2&&(p=H),dI(H),dI(p),Z(function(o,A){for(var x=[],k=void 0,II=void 0,tI=0;tI<H;tI+=1){if(II=v(k=u._(o,A),II),!k.status)return II;A=k.index,x.push(k.value)}for(;tI<p&&(II=v(k=u._(o,A),II),k.status);tI+=1)A=k.index,x.push(k.value);return v(e(A,x),II)})},d.result=function(H){return this.map(function(){return H})},d.atMost=function(H){return this.times(0,H)},d.atLeast=function(H){return S2(this.times(H),this.many(),function(p,u){return p.concat(u)})},d.map=function(H){YI(H);var p=this;return Z(function(u,o){var A=p._(u,o);return A.status?v(e(A.index,H(A.value)),A):A})},d.contramap=function(H){YI(H);var p=this;return Z(function(u,o){var A=p.parse(H(u.slice(o)));return A.status?e(o+u.length,A.value):A})},d.promap=function(H,p){return YI(H),YI(p),this.contramap(H).map(p)},d.skip=function(H){return Vc(this,H).map(function(p){return p[0]})},d.mark=function(){return S2(hc,this,hc,function(H,p,u){return{start:H,value:p,end:u}})},d.node=function(H){return S2(hc,this,hc,function(p,u,o){return{name:H,value:u,start:p,end:o}})},d.sepBy=function(H){return Cb(this,H)},d.sepBy1=function(H){return pG(this,H)},d.lookahead=function(H){return this.skip(sG(H))},d.notFollowedBy=function(H){return this.skip(Sb(H))},d.desc=function(H){t(H)||(H=[
Line truncated
|
||||
`),Ba=oc(`\r
|
||||
`),La=Nc(Ba,Ma,Ua).desc("newline"),Y4=Nc(La,tG);Z.all=Db,Z.alt=Nc,Z.any=j1,Z.cr=Ua,Z.createLanguage=function(H){var p={};for(var u in H)({}).hasOwnProperty.call(H,u)&&function(o){p[o]=rc(function(){return H[o](p)})}(u);return p},Z.crlf=Ba,Z.custom=function(H){return Z(H(e,w))},Z.digit=Kb,Z.digits=Ob,Z.empty=eG,Z.end=Y4,Z.eof=tG,Z.fail=ic,Z.formatError=Wl,Z.index=hc,Z.isParser=Y,Z.lazy=rc,Z.letter=V4,Z.letters=N4,Z.lf=Ma,Z.lookahead=sG,Z.makeFailure=w,Z.makeSuccess=e,Z.newline=La,Z.noneOf=function(H){return Dl(function(p){return H.indexOf(p)<0}).desc("none of '"+H+"'")},Z.notFollowedBy=Sb,Z.of=w2,Z.oneOf=function(H){for(var p=H.split(""),u=0;u<p.length;u++)p[u]="'"+p[u]+"'";return Dl(function(o){return H.indexOf(o)>=0}).desc(p)},Z.optWhitespace=h4,Z.Parser=Z,Z.range=function(H,p){return Dl(function(u){return H<=u&&u<=p}).desc(H+"-"+p)},Z.regex=m2,Z.regexp=m2,Z.sepBy=Cb,Z.sepBy1=pG,Z.seq=Vc,Z.seqMap=S2,Z.seqObj=function(){for(var H,p={},u=0,o=(H=arguments,Array.prototype.slice.call(H)),A=o.length,x=0;x<A;x+=1){var k=o[x];if(!Y(k)){if(t(k)&&k.length===2&&typeof k[0]=="string"&&Y(k[1])){var II=k[0];if(Object.prototype.hasOwnProperty.call(p,II))throw new Error("seqObj: duplicate key "+II);p[II]=!0,u++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(u===0)throw new Error("seqObj expects at least one named parser, found zero");return Z(function(tI,tl){for(var al,D2={},zl=0;zl<A;zl+=1){var K2,EG;if(t(o[zl])?(K2=o[zl][0],EG=o[zl][1]):(K2=null,EG=o[zl]),!(al=v(EG._(tI,tl),al)).status)return al;K2&&(D2[K2]=al.value),tl=al.index}return v(e(tl,D2),al)})},Z.string=oc,Z.succeed=w2,Z.takeWhile=function(H){return YI(H),Z(function(p,u){for(var o=u;o<p.length&&H(cI(p,o));)o++;return e(o,p.slice(u,o))})},Z.test=Dl,Z.whitespace=F4,Z["fantasy-land/empty"]=eG,Z["fantasy-land/of"]=w2,Z.Binary={bitSeq:F,bitSeqObj:function(H){h();var p={},u=0,o=m(function(x){if(t(x)){var k=x;if(k.length!==2)throw new Error("["+k.join(", ")+"] should be length 2, got length "+k.length);if(hI(k[0]),dI(k[1]),Object.prototype.hasOwnProperty.call(p,k[0]))throw new Error("duplicate key in bitSeqObj: "+k[0]);return p[k[0]]=!0,u++,k}return dI(x),[null,x]},H);if(u<1)throw new Error("bitSeqObj expects at least one named pair, got ["+H.join(", ")+"]");var A=m(function(x){return x[0]},o);return F(m(function(x){return x[1]},o)).map(function(x){return a(function(k,II){return II[0]!==null&&(k[II[0]]=II[1]),k},{},m(function(k,II){return[k,x[II]]},A))})},byte:function(H){if(h(),dI(H),H>255)throw new Error("Value specified to byte constructor ("+H+"=0x"+H.toString(16)+") is larger in value than a single byte.");var p=(H>15?"0x":"0x0")+H.toString(16);return Z(function(u,o){var A=cI(u,o);return A===H?e(o+1,A):w(o,p)})},buffer:function(H){return R("buffer",H).map(function(p){return Buffer.from(p)})},encodedString:function(H,p){return R("string",p).map(function(u){return u.toString(H)})},uintBE:E,uint8BE:E(1),uint16BE:E(2),uint32BE:E(4),uintLE:s,uint8LE:s(1),uint16LE:s(2),uint32LE:s(4),intBE:J,int8BE:J(1),int16BE:J(2),int32BE:J(4),intLE:i,int8LE:i(1),int16LE:i(2),int32LE:i(4),floatBE:R("floatBE",4).map(function(H){return H.readFloatBE(0)}),floatLE:R("floatLE",4).map(function(H){return H.readFloatLE(0)}),doubleBE:R("doubleBE",8).map(function(H){return H.readDoubleBE(0)}),doubleLE:R("doubleLE",8).map(function(H){return H.readDoubleLE(0)})},l.exports=Z}])})})(Qd,Qd.exports);var n=Qd.exports,na=()=>/[#*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\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-
Line truncated
|
||||
`)[0];let c=l.substring(2).trim();return n.makeSuccess(I+l.length,c)}),namedField:G=>n.alt(G.explicitNamedField,LR(e2.field).map(([I,l])=>vd.named(fR(l),I))),sortField:G=>n.seqMap(e2.field.skip(n.optWhitespace),n.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(I,l)=>{let c=l.length==0?"ascending":l[0].toLowerCase();return c=="desc"&&(c="descending"),c=="asc"&&(c="ascending"),{field:I,direction:c}}),headerClause:G=>G.queryType.chain(I=>{switch(I){case"table":return rN(()=>({type:I,fields:[],showId:!0}),n.seqMap(n.regexp(/WITHOUT\s+ID/i).skip(n.optWhitespace).atMost(1),n.sepBy(G.namedField,n.string(",").trim(n.optWhitespace)),(l,c)=>({type:I,fields:c,showId:l.length==0})));case"list":return rN(()=>({type:I,format:void 0,showId:!0}),n.seqMap(n.regexp(/WITHOUT\s+ID/i).skip(n.optWhitespace).atMost(1),e2.field.atMost(1),(l,c)=>({type:I,format:c.length==1?c[0]:void 0,showId:l.length==0})));case"task":return n.succeed({type:I});case"calendar":return n.whitespace.then(n.seqMap(G.namedField,l=>({type:I,showId:!0,field:l})));default:return n.fail(`Unrecognized query type '${I}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:G=>n.seqMap(n.regexp(/FROM/i),n.whitespace,e2.source,(I,l,c)=>c),whereClause:G=>n.seqMap(n.regexp(/WHERE/i),n.whitespace,e2.field,(I,l,c)=>({type:"where",clause:c})).desc("WHERE <expression>"),sortByClause:G=>n.seqMap(n.regexp(/SORT/i),n.whitespace,G.sortField.sepBy1(n.string(",").trim(n.optWhitespace)),(I,l,c)=>({type:"sort",fields:c})).desc("SORT field [ASC/DESC]"),limitClause:G=>n.seqMap(n.regexp(/LIMIT/i),n.whitespace,e2.field,(I,l,c)=>({type:"limit",amount:c})).desc("LIMIT <value>"),flattenClause:G=>n.seqMap(n.regexp(/FLATTEN/i).skip(n.whitespace),G.namedField,(I,l)=>({type:"flatten",field:l})).desc("FLATTEN <value> [AS <name>]"),groupByClause:G=>n.seqMap(n.regexp(/GROUP BY/i).skip(n.whitespace),G.namedField,(I,l)=>({type:"group",field:l})).desc("GROUP BY <value> [AS <name>]"),clause:G=>n.alt(G.fromClause,G.whereClause,G.sortByClause,G.limitClause,G.groupByClause,G.flattenClause),query:G=>n.seqMap(G.headerClause.trim(C3),G.fromClause.trim(C3).atMost(1),G.clause.trim(C3).many(),(I,l,c)=>({header:I,source:l.length==0?f2.folder(""):l[0],operations:c,settings:Ra}))}),C3=n.alt(n.whitespace,r5.comment).many().map(G=>G.join("")),jR=G=>G?G.plugins.plugins.dataview?.api:window.DataviewAPI,TR=G=>G.plugins.enabledPlugins.has("dataview");j2.DATE_SHORTHANDS=aa;j2.DURATION_TYPES=Wa;j2.EXPRESSION=e2;j2.KEYWORDS=ma;j2.QUERY_LANGUAGE=r5;j2.getAPI=jR;j2.isPluginEnabled=TR;j2.parseField=BR});var zn={};t4(zn,{default:()=>nI});module.exports=E4(zn);var m4=require("obsidian");var Q2=require("obsidian");function Ql(){}function V2(G,I){for(let l in I)G[l]=I[l];return G}function VW(G){return G()}function Ta(){return Object.create(null)}function QI(G){G.forEach(VW)}function JI(G){return typeof G=="function"}function HI(G,I){return G!=G?I==I:G!==I||G&&typeof G=="object"||typeof G=="function"}function Ca(G){return Object.keys(G).length===0}function qb(G,I,l,c){if(G){let b=Sa(G,I,l,c);return G[0](b)}}function Sa(G,I,l,c){return G[1]&&c?V2(l.ctx.slice(),G[1](c(I))):l.ctx}function _b(G,I,l,c){if(G[2]&&c){let b=G[2](c(l));if(I.dirty===void 0)return b;if(typeof b=="object"){let Z=[],d=Math.max(I.dirty.length,b.length);for(let W=0;W<d;W+=1)Z[W]=I.dirty[W]|b[W];return Z}return I.dirty|b}return I.dirty}function $b(G,I,l,c,b,Z){if(b){let d=Sa(I,l,c,Z);G.p(d,b)}}function IZ(G){if(G.ctx.length>32){let I=[],l=G.ctx.length/32;for(let c=0;c<l;c++)I[c]=-1;return I}return-1}function lZ(G){let I={};for(let l in G)l[0]!=="$"&&(I[l]=G[l]);return I}function iG(G,I){let l={};I=new Set(I);for(let c in G)!I.has(c)&&c[0]!=="$"&&(l[c]=G[c]);return l}function cZ(G){return G&&JI(G.destroy)?G.destroy:Ql}var Da=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global,S1=class{constructor(I){this.options=I,this._listeners="WeakMap"in Da?new WeakMap:void 0}observe(I,l){return this._listeners.set(I,l),this._getObserver().observe(I,this.options),()=>{this._listeners.delete(I),this._observer.unobserve(I)}}_getObserver(){var I;return(I=this._observer)!==null&&I!==void 0?I:this._observer=new ResizeObserver(l=>{var c;for(let b of l)S1.entries.set(b.target,b),(c=this._listeners.get(b.target))===null||c===void 0||c(b)})}};S1.entries="WeakMap"in Da?new WeakMap:void 0;var Ka=!1;function u4(){Ka=!0}function Q4(){Ka=!1}function g(G,I){G.appendChild(I)}function qI(G,I,l){let c=v4(G);if(!c.getElementById(I)){let b=M("style");b.id=I,b.textContent=l,J4(c,b)}}function v4(G){if(!G)return document;let I=G.getRootNode?G.getRootNode():G.ownerDocument;return I&&I.host?I:G.ownerDocument}function J4(G,I){return g(G.head||G,I),I.sheet}function O(G,I,l){G.insertBefore(I,l||null)}function K(G){G.parentNode&&G.parentNode.removeChild(G)}function O1(G,I){for(let l=0;l<G.length;l+=1)G[l]&&G[l].d(I)}function M(G){return document.createElement(G)}function zc(G){return document.createElementNS("http://www.w3.org/2000/svg",G)}function Xl(G){return document.creat
Line truncated
|
||||
`+E.join(", ")),`
|
||||
`].join("");var E}function Xl(R){return R.flags!==void 0?R.flags:[R.global?"g":"",R.ignoreCase?"i":"",R.multiline?"m":"",R.unicode?"u":"",R.sticky?"y":""].join("")}function Ib(){for(var R=[].slice.call(arguments),p=R.length,E=0;E<p;E+=1)x(R[E]);return c(function(e,L){for(var k,i=new Array(p),f=0;f<p;f+=1){if(!(k=t(R[f]._(e,L),k)).status)return k;i[f]=k.value,L=k.index}return t(v(L,i),k)})}function kl(){var R=[].slice.call(arguments);if(R.length===0)throw new Error("seqMap needs at least one argument");var p=R.pop();return aI(p),Ib.apply(null,R).map(function(E){return p.apply(null,E)})}function Gb(){var R=[].slice.call(arguments),p=R.length;if(p===0)return pb("zero alternates");for(var E=0;E<p;E+=1)x(R[E]);return c(function(e,L){for(var k,i=0;i<R.length;i+=1)if((k=t(R[i]._(e,L),k)).status)return k;return k})}function CW(R,p){return ZZ(R,p).or(Ql([]))}function ZZ(R,p){return x(R),x(p),kl(R,p.then(R).many(),function(E,e){return[E].concat(e)})}function Hb(R){hI(R);var p="'"+R+"'";return c(function(E,e){var L=e+R.length,k=E.slice(e,L);return k===R?v(L,k):J(e,p)})}function Gl(R,p){(function(L){if(!(L instanceof RegExp))throw new Error("not a regexp: "+L);for(var k=Xl(L),i=0;i<k.length;i++){var f=k.charAt(i);if(f!=="i"&&f!=="m"&&f!=="u"&&f!=="s")throw new Error('unsupported regexp flag "'+f+'": '+L)}})(R),arguments.length>=2?lI(p):p=0;var E=function(L){return RegExp("^(?:"+L.source+")",Xl(L))}(R),e=""+R;return c(function(L,k){var i=E.exec(L.slice(k));if(i){if(0<=p&&p<=i.length){var f=i[0],nI=i[p];return v(k+f.length,nI)}return J(k,"valid match group (0 to "+i.length+") in "+e)}return J(k,e)})}function Ql(R){return c(function(p,E){return v(E,R)})}function pb(R){return c(function(p,E){return J(E,R)})}function cZ(R){if(F(R))return c(function(p,E){var e=R._(p,E);return e.index=E,e.value="",e});if(typeof R=="string")return cZ(Hb(R));if(R instanceof RegExp)return cZ(Gl(R));throw new Error("not a string, regexp, or parser: "+R)}function gW(R){return x(R),c(function(p,E){var e=R._(p,E),L=p.slice(E,e.index);return e.status?J(E,'not "'+L+'"'):v(E,null)})}function xG(R){return aI(R),c(function(p,E){var e=GI(p,E);return E<p.length&&R(e)?v(E+1,e):J(E,"a character/byte matching "+R)})}function ub(R,p){arguments.length<2&&(p=R,R=void 0);var E=c(function(e,L){return E._=p()._,E._(e,L)});return R?E.desc(R):E}function WZ(){return pb("fantasy-land/empty")}W.parse=function(R){if(typeof R!="string"&&!y(R))throw new Error(".parse must be called with a string or Buffer as its argument");var p,E=this.skip(dZ)._(R,0);return p=E.status?{status:!0,value:E.value}:{status:!1,index:S(R,E.furthest),expected:E.expected},delete O[R],p},W.tryParse=function(R){var p=this.parse(R);if(p.status)return p.value;var E=bG(R,p),e=new Error(E);throw e.type="ParsimmonError",e.result=p,e},W.assert=function(R,p){return this.chain(function(E){return R(E)?Ql(E):pb(p)})},W.or=function(R){return Gb(this,R)},W.trim=function(R){return this.wrap(R,R)},W.wrap=function(R,p){return kl(R,this,p,function(E,e){return e})},W.thru=function(R){return R(this)},W.then=function(R){return x(R),Ib(this,R).map(function(p){return p[1]})},W.many=function(){var R=this;return c(function(p,E){for(var e=[],L=void 0;;){if(!(L=t(R._(p,E),L)).status)return t(v(E,e),L);if(E===L.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");E=L.index,e.push(L.value)}})},W.tieWith=function(R){return hI(R),this.map(function(p){if(function(L){if(!n(L))throw new Error("not an array: "+L)}(p),p.length){hI(p[0]);for(var E=p[0],e=1;e<p.length;e++)hI(p[e]),E+=R+p[e];return E}return""})},W.tie=function(){return this.tieWith("")},W.times=function(R,p){var E=this;return arguments.length<2&&(p=R),lI(R),lI(p),c(function(e,L){for(var k=[],i=void 0,f=void 0,nI=0;nI<R;nI+=1){if(f=t(i=E._(e,L),f),!i.status)return f;L=i.index,k.push(i.value)}for(;nI<p&&(f=t(i=E._(e,L),f),i.status);nI+=1)L=i.index,k.push(i.value);return t(v(L,k),f)})},W.result=function(R){return this.map(function(){return R})},W.atMost=function(R){return this.times(0,R)},W.atLeast=function(R){return kl(this.times(R),this.many(),function(p,E){return p.concat(E)})},W.map=function(R){aI(R);var p=this;return c(function(E,e){var L=p._(E,e);return L.status?t(v(L.index,R(L.value)),L):L})},W.contramap=function(R){aI(R);var p=this;return c(function(E,e){var L=p.parse(R(E.slice(e)));return L.status?v(e+E.length,L.value):L})},W.promap=function(R,p){return aI(R),aI(p),this.contramap(R).map(p)},W.skip=function(R){return Ib(this,R).map(function(p){return p[0]})},W.mark=function(){return kl(lb,this,lb,function(R,p,E){return{start:R,value:p,end:E}})},W.node=function(R){return kl(lb,this,lb,function(p,E,e){return{name:R,value:E,start:p,end:e}})},W.sepBy=function(R){return CW(this,R)},W.sepBy1=function(R){return ZZ(this,R)},W.lookahead=function(R){return this.skip(cZ(R))},W.notFollowedBy=function(R){return this.skip(gW(R))},W.desc=function(R){n(R)||(R=[R]);var p=this;return
Line truncated
|
||||
`),vV=Hb(`\r
|
||||
`),tV=Gb(vV,wV,nV).desc("newline"),kR=Gb(tV,dZ);c.all=AW,c.alt=Gb,c.any=Ec,c.cr=nV,c.createLanguage=function(R){var p={};for(var E in R)({}).hasOwnProperty.call(R,E)&&function(e){p[e]=ub(function(){return R[e](p)})}(E);return p},c.crlf=vV,c.custom=function(R){return c(R(v,J))},c.digit=LW,c.digits=oW,c.empty=WZ,c.end=kR,c.eof=dZ,c.fail=pb,c.formatError=bG,c.index=lb,c.isParser=F,c.lazy=ub,c.letter=gR,c.letters=AR,c.lf=wV,c.lookahead=cZ,c.makeFailure=J,c.makeSuccess=v,c.newline=tV,c.noneOf=function(R){return xG(function(p){return R.indexOf(p)<0}).desc("none of '"+R+"'")},c.notFollowedBy=gW,c.of=Ql,c.oneOf=function(R){for(var p=R.split(""),E=0;E<p.length;E++)p[E]="'"+p[E]+"'";return xG(function(e){return R.indexOf(e)>=0}).desc(p)},c.optWhitespace=LR,c.Parser=c,c.range=function(R,p){return xG(function(E){return R<=E&&E<=p}).desc(R+"-"+p)},c.regex=Gl,c.regexp=Gl,c.sepBy=CW,c.sepBy1=ZZ,c.seq=Ib,c.seqMap=kl,c.seqObj=function(){for(var R,p={},E=0,e=(R=arguments,Array.prototype.slice.call(R)),L=e.length,k=0;k<L;k+=1){var i=e[k];if(!F(i)){if(n(i)&&i.length===2&&typeof i[0]=="string"&&F(i[1])){var f=i[0];if(Object.prototype.hasOwnProperty.call(p,f))throw new Error("seqObj: duplicate key "+f);p[f]=!0,E++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(E===0)throw new Error("seqObj expects at least one named parser, found zero");return c(function(nI,XG){for(var ZG,il={},sG=0;sG<L;sG+=1){var zl,NZ;if(n(e[sG])?(zl=e[sG][0],NZ=e[sG][1]):(zl=null,NZ=e[sG]),!(ZG=t(NZ._(nI,XG),ZG)).status)return ZG;zl&&(il[zl]=ZG.value),XG=ZG.index}return t(v(XG,il),ZG)})},c.string=Hb,c.succeed=Ql,c.takeWhile=function(R){return aI(R),c(function(p,E){for(var e=E;e<p.length&&R(GI(p,e));)e++;return v(e,p.slice(E,e))})},c.test=xG,c.whitespace=oR,c["fantasy-land/empty"]=WZ,c["fantasy-land/of"]=Ql,c.Binary={bitSeq:a,bitSeqObj:function(R){h();var p={},E=0,e=m(function(k){if(n(k)){var i=k;if(i.length!==2)throw new Error("["+i.join(", ")+"] should be length 2, got length "+i.length);if(hI(i[0]),lI(i[1]),Object.prototype.hasOwnProperty.call(p,i[0]))throw new Error("duplicate key in bitSeqObj: "+i[0]);return p[i[0]]=!0,E++,i}return lI(k),[null,k]},R);if(E<1)throw new Error("bitSeqObj expects at least one named pair, got ["+R.join(", ")+"]");var L=m(function(k){return k[0]},e);return a(m(function(k){return k[1]},e)).map(function(k){return N(function(i,f){return f[0]!==null&&(i[f[0]]=f[1]),i},{},m(function(i,f){return[i,k[f]]},L))})},byte:function(R){if(h(),lI(R),R>255)throw new Error("Value specified to byte constructor ("+R+"=0x"+R.toString(16)+") is larger in value than a single byte.");var p=(R>15?"0x":"0x0")+R.toString(16);return c(function(E,e){var L=GI(E,e);return L===R?v(e+1,L):J(e,p)})},buffer:function(R){return X("buffer",R).map(function(p){return Buffer.from(p)})},encodedString:function(R,p){return X("string",p).map(function(E){return E.toString(R)})},uintBE:w,uint8BE:w(1),uint16BE:w(2),uint32BE:w(4),uintLE:u,uint8LE:u(1),uint16LE:u(2),uint32LE:u(4),intBE:s,int8BE:s(1),int16BE:s(2),int32BE:s(4),intLE:C,int8LE:C(1),int16LE:C(2),int32LE:C(4),floatBE:X("floatBE",4).map(function(R){return R.readFloatBE(0)}),floatLE:X("floatLE",4).map(function(R){return R.readFloatLE(0)}),doubleBE:X("doubleBE",8).map(function(R){return R.readDoubleBE(0)}),doubleLE:X("doubleLE",8).map(function(R){return R.readDoubleLE(0)})},G.exports=c}])})})(dN,dN.exports);var Q=dN.exports,IV=()=>/[#*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\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF
Line truncated
|
||||
`)[0];let b=G.substring(2).trim();return Q.makeSuccess(I+G.length,b)}),namedField:l=>Q.alt(l.explicitNamedField,Gu(hl.field).map(([I,G])=>mN.named(lu(G),I))),sortField:l=>Q.seqMap(hl.field.skip(Q.optWhitespace),Q.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(I,G)=>{let b=G.length==0?"ascending":G[0].toLowerCase();return b=="desc"&&(b="descending"),b=="asc"&&(b="ascending"),{field:I,direction:b}}),headerClause:l=>l.queryType.chain(I=>{switch(I){case"table":return $a(()=>({type:I,fields:[],showId:!0}),Q.seqMap(Q.regexp(/WITHOUT\s+ID/i).skip(Q.optWhitespace).atMost(1),Q.sepBy(l.namedField,Q.string(",").trim(Q.optWhitespace)),(G,b)=>({type:I,fields:b,showId:G.length==0})));case"list":return $a(()=>({type:I,format:void 0,showId:!0}),Q.seqMap(Q.regexp(/WITHOUT\s+ID/i).skip(Q.optWhitespace).atMost(1),hl.field.atMost(1),(G,b)=>({type:I,format:b.length==1?b[0]:void 0,showId:G.length==0})));case"task":return Q.succeed({type:I});case"calendar":return Q.whitespace.then(Q.seqMap(l.namedField,G=>({type:I,showId:!0,field:G})));default:return Q.fail(`Unrecognized query type '${I}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:l=>Q.seqMap(Q.regexp(/FROM/i),Q.whitespace,hl.source,(I,G,b)=>b),whereClause:l=>Q.seqMap(Q.regexp(/WHERE/i),Q.whitespace,hl.field,(I,G,b)=>({type:"where",clause:b})).desc("WHERE <expression>"),sortByClause:l=>Q.seqMap(Q.regexp(/SORT/i),Q.whitespace,l.sortField.sepBy1(Q.string(",").trim(Q.optWhitespace)),(I,G,b)=>({type:"sort",fields:b})).desc("SORT field [ASC/DESC]"),limitClause:l=>Q.seqMap(Q.regexp(/LIMIT/i),Q.whitespace,hl.field,(I,G,b)=>({type:"limit",amount:b})).desc("LIMIT <value>"),flattenClause:l=>Q.seqMap(Q.regexp(/FLATTEN/i).skip(Q.whitespace),l.namedField,(I,G)=>({type:"flatten",field:G})).desc("FLATTEN <value> [AS <name>]"),groupByClause:l=>Q.seqMap(Q.regexp(/GROUP BY/i).skip(Q.whitespace),l.namedField,(I,G)=>({type:"group",field:G})).desc("GROUP BY <value> [AS <name>]"),clause:l=>Q.alt(l.fromClause,l.whereClause,l.sortByClause,l.limitClause,l.groupByClause,l.flattenClause),query:l=>Q.seqMap(l.headerClause.trim(JY),l.fromClause.trim(JY).atMost(1),l.clause.trim(JY).many(),(I,G,b)=>({header:I,source:G.length==0?gl.folder(""):G[0],operations:b,settings:$Y}))}),JY=Q.alt(Q.whitespace,$F.comment).many().map(l=>l.join("")),bu=l=>l?l.plugins.plugins.dataview?.api:window.DataviewAPI,Zu=l=>l.plugins.enabledPlugins.has("dataview");Al.DATE_SHORTHANDS=KY;Al.DURATION_TYPES=jY;Al.EXPRESSION=hl;Al.KEYWORDS=DY;Al.QUERY_LANGUAGE=$F;Al.getAPI=bu;Al.isPluginEnabled=Zu;Al.parseField=Iu});var Su={};MR(Su,{default:()=>XI});module.exports=jR(Su);var CR=require("obsidian");var Rl=require("obsidian");function QG(){}function SN(l){return l()}function sV(){return Object.create(null)}function tI(l){l.forEach(SN)}function EI(l){return typeof l=="function"}function HI(l,I){return l!=l?I==I:l!==I||l&&typeof l=="object"||typeof l=="function"}function yV(l){return Object.keys(l).length===0}function iW(l){return l&&EI(l.destroy)?l.destroy:QG}var eV=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global,KN=class l{constructor(I){this.options=I,this._listeners="WeakMap"in eV?new WeakMap:void 0}observe(I,G){return this._listeners.set(I,G),this._getObserver().observe(I,this.options),()=>{this._listeners.delete(I),this._observer.unobserve(I)}}_getObserver(){var I;return(I=this._observer)!==null&&I!==void 0?I:this._observer=new ResizeObserver(G=>{var b;for(let Z of G)l.entries.set(Z.target,Z),(b=this._listeners.get(Z.target))===null||b===void 0||b(Z)})}};KN.entries="WeakMap"in eV?new WeakMap:void 0;var CV=!1;function KR(){CV=!0}function DR(){CV=!1}function A(l,I){l.appendChild(I)}function fI(l,I,G){let b=TR(l);if(!b.getElementById(I)){let Z=z("style");Z.id=I,Z.textContent=G,SR(b,Z)}}function TR(l){if(!l)return document;let I=l.getRootNode?l.getRootNode():l.ownerDocument;return I&&I.host?I:l.ownerDocument}function SR(l,I){return A(l.head||l,I),I.sheet}function dI(l,I,G){l.insertBefore(I,G||null)}function bI(l){l.parentNode&&l.parentNode.removeChild(l)}function gV(l,I){for(let G=0;G<l.length;G+=1)l[G]&&l[G].d(I)}function z(l){return document.createElement(l)}function VG(l){return document.createTextNode(l)}function ZI(){return VG(" ")}function bb(){return VG("")}function D(l,I,G,b){return l.addEventListener(I,G,b),()=>l.removeEventListener(I,G,b)}function g(l,I,G){G==null?l.removeAttribute(I):l.getAttribute(I)!==G&&l.setAttribute(I,G)}function qN(l){return l===""?null:+l}function qR(l){return Array.from(l.childNodes)}function UG(l,I){I=""+I,l.data!==I&&(l.data=I)}function XZ(l,I){l.value=I??""}function QZ(l,I,G,b){G==null?l.style.removeProperty(I):l.style.setProperty(I,G,b?"important":"")}function fN(l,I,G){for(let b=0;b<l.options.length;b+=1){let Z=l.options[b];if(Z.__value===I){Z.selected=!0;return}}(!G||I!==void 0)&&(l.selectedIndex=-1)}function AV(l){let I=l.querySelector(":checked");return I&&I.__value}function fR(l,I,{bubbles:G=!1,cancelable:b=!1}={}){let Z=document.createEvent("CustomEvent");retur
Line truncated
|
||||
<div class="qa-suggestion-content">
|
||||
<span class="suggestion-main-text">${W}</span>
|
||||
<span class="suggestion-main-text">${d}</span>
|
||||
${m}
|
||||
</div>
|
||||
<span class="suggestion-sub-text">${a}</span>
|
||||
`,this.addHoverTooltip(c,b)}addHoverTooltip(l,c){let b,Z=()=>{clearTimeout(b),document.querySelector(".qa-file-tooltip")?.remove()};l.addEventListener("mouseenter",()=>{Z(),b=setTimeout(async()=>{let W=this.createTooltip(c);W&&(document.body.appendChild(W),this.positionTooltip(W,l))},200)}),l.addEventListener("mouseleave",Z),l.addEventListener("blur",Z);let d=()=>Z();document.addEventListener("scroll",d,{passive:!0}),l._tooltipCleanup=()=>{Z(),document.removeEventListener("scroll",d)}}createTooltip(l){let c=this.app.vault.getAbstractFileByPath(l.path);if(!c||!(c instanceof v3.TFile))return null;let b=document.createElement("div");return b.className="qa-file-tooltip",b.innerHTML=`
|
||||
<div class="qa-tooltip-header">${c.basename}</div>
|
||||
<span class="suggestion-sub-text">${N}</span>
|
||||
`,this.addHoverTooltip(b,Z)}addHoverTooltip(G,b){let Z,c=()=>{clearTimeout(Z),document.querySelector(".qa-file-tooltip")?.remove()};G.addEventListener("mouseenter",()=>{c(),Z=setTimeout(async()=>{let d=this.createTooltip(b);d&&(document.body.appendChild(d),this.positionTooltip(d,G))},200)}),G.addEventListener("mouseleave",c),G.addEventListener("blur",c);let W=()=>c();document.addEventListener("scroll",W,{passive:!0}),G._tooltipCleanup=()=>{c(),document.removeEventListener("scroll",W)}}createTooltip(G){let b=this.app.vault.getAbstractFileByPath(G.path);if(!b||!(b instanceof dY.TFile))return null;let Z=document.createElement("div");return Z.className="qa-file-tooltip",Z.innerHTML=`
|
||||
<div class="qa-tooltip-header">${b.basename}</div>
|
||||
<div class="qa-tooltip-content">
|
||||
<div>Path: ${c.path}</div>
|
||||
<div>Modified: ${new Date(c.stat.mtime).toLocaleDateString()}</div>
|
||||
<div>Path: ${b.path}</div>
|
||||
<div>Modified: ${new Date(b.stat.mtime).toLocaleDateString()}</div>
|
||||
</div>
|
||||
`,b}positionTooltip(l,c){let b=c.getBoundingClientRect();l.style.position="fixed",l.style.left=`${b.right+10}px`,l.style.top=`${b.top}px`,l.style.zIndex="1000"}close(){document.querySelectorAll(".qaFileSuggestionItem").forEach(b=>{b._tooltipCleanup&&b._tooltipCleanup()}),document.querySelectorAll(".qa-file-tooltip").forEach(b=>b.remove()),super.close()}async selectSuggestion(l){if(this.inputEl.selectionStart===null)return;let c=this.inputEl.selectionStart,b=this.lastInput.length,Z=this.inputEl.value,d=0,W=this.inputEl.value.slice(c-this.lastInput.length-3,c-this.lastInput.length)==="![[";if(l.matchType==="unresolved")d=this.makeLinkManually(Z,l.displayText.replace(/.md$/,""),c,b);else if(l.matchType==="heading"||l.matchType==="block"){let a=l.displayText;d=this.makeLinkManually(Z,a,c,b)}else if(W)d=this.makeLinkManually(Z,l.displayText,c,b);else{let a=this.app.vault.getAbstractFileByPath(l.file.path);if(a instanceof v3.TFile){let m=l.matchType==="alias"?l.displayText:void 0;d=this.makeLinkObsidianMethod(a,Z,c,b,m)}else d=this.makeLinkManually(Z,l.displayText,c,b)}this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(d,d)}makeLinkObsidianMethod(l,c,b,Z,d){let W=this.app.vault.getAbstractFileByPath(l.path),a=this.app.fileManager.generateMarkdownLink(W,"","",d??"");return this.inputEl.value=this.getNewInputValueForFileLink(c,a,b,Z),b-Z+a.length+2}makeLinkManually(l,c,b,Z){return this.inputEl.value=this.getNewInputValueForFileName(l,c,b,Z),b-Z+c.length+2}getNewInputValueForFileLink(l,c,b,Z){return`${l.substr(0,b-Z-2)}${c}${l.substr(b)}`}getNewInputValueForFileName(l,c,b,Z){return`${l.substr(0,b-Z)}${c}]]${l.substr(b)}`}};var b1=class extends yl{constructor(l,c){super(l,c);this.app=l;this.inputEl=c;this.lastInput="";this.lastInputStart=0;this.refreshTagIndex(),nI.instance.registerEvent(this.app.metadataCache.on("resolved",()=>this.refreshTagIndex()))}refreshTagIndex(){let l=this.app.metadataCache.getTags(),c=Object.keys(l);this.tagSet=new Set(c),this.sortedTags=c.sort((b,Z)=>b.length!==Z.length?b.length-Z.length:b.localeCompare(Z)),this.fuse=new ol(this.sortedTags,{threshold:.4,includeScore:!0,keys:[""]})}getSuggestions(l){if(this.inputEl.selectionStart===null)return[];let c=this.inputEl.selectionStart,b=l.slice(0,c),Z=Pm.exec(b);if(!Z)return[];let d=b.lastIndexOf("[[");if(d!==-1&&d<Z.index)return[];let W=Z[1];this.lastInput=W,this.lastInputStart=Z.index+1;let a=this.sortedTags.filter(h=>h.toLowerCase().startsWith(W.toLowerCase())).slice(0,5),m=this.fuse.search(W).filter(h=>h.score<.8).map(h=>h.item).slice(0,10),V=new Set(a),N=[...a];for(let h of m)!V.has(h)&&N.length<15&&(N.push(h),V.add(h));return N}renderSuggestion(l,c){let b=this.renderMatch(l,this.lastInput);c.innerHTML=b}selectSuggestion(l){if(this.inputEl.selectionStart===null)return;let c=this.inputEl.selectionStart,b=this.lastInputStart,Z=c;wZ(this.inputEl,b,Z,l),this.close()}};var vI=class extends Z1.Modal{constructor(l,c,b,Z){super(l);this.header=c;this.didSubmit=!1;this.submitClickCallback=l=>this.submit();this.cancelClickCallback=l=>this.cancel();this.submitEnterCallback=l=>{!l.isComposing&&l.key==="Enter"&&(l.preventDefault(),this.submit())};this.placeholder=b??"",this.input=Z??"",this.waitForClose=new Promise((d,W)=>{this.resolvePromise=d,this.rejectPromise=W}),this.display(),this.open(),this.fileSuggester=new G1(l,this.inputComponent.inputEl),this.tagSuggester=new b1(l,this.inputComponent.inputEl)}static Prompt(l,c,b,Z){return new vI(l,c,b,Z).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header;let l=this.contentEl.createDiv();this.inputComponent=this.createInputField(l,this.placeholder,this.input),this.createButtonBar(l)}createInputField(l,c,b){let Z=new Z1.TextComponent(l);return Z.inputEl.style.width="100%",Z.setPlaceholder(c??"").setValue(b??"").onChange(d=>this.input=d).inputEl.addEventListener("keydown",this.submitEnterCallback),Z}createButton(l,c,b){let Z=new Z1.ButtonComponent(l);return Z.setButtonText(c).onClick(b),Z}createButtonBar(l){let c=l.createDiv();this.createButton(c,"Ok",this.submitClickCallback).setCta().buttonEl.style.marginRight="0",this.createButton(c,"Cancel",this.cancelClickCallback),c.style.display="flex",c.style.flexDirection="row-reverse",c.style.justifyContent="flex-start",c.style.marginTop="1rem",c.style.gap="0.5rem"}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise("No input given.")}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback)}onOpen(){super.onOpen(),this.inputComponent.inputEl.focus(),this.inputComponent.inputEl.select()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListener()}};var d1=class{register(I){return d1.loggers.push(I),this}logError(I){let l=I instanceof Error?I.message:I,c=I instanceof Error?I.stack:void 0,b=I instanceof Error?
Line truncated
|
||||
})`)(c,Z,b);let a=b.default||Z.exports;if(!a)return;let m=a,{memberAccess:V}=eb(G.name);if(V&&V.length>0){let N;for(;N=V.shift();)m=m[N]}return m}}function wV(G,I){let l=structuredClone(G);for(let c of I)delete l[c];return l}function yV(G){let I=Z=>Z.type==="Template",l=Z=>Z.type==="Macro",c=Z=>Z.type==="Capture",b=Z=>Z.type==="Multi";return I(G)||l(G)||c(G)||b(G)}function oV(G,I){let l=G.vault.getAbstractFileByPath(I);return!!l&&l instanceof lc.TFolder}function m1(G,I){return G.vault.getMarkdownFiles().filter(l=>l.path.startsWith(I))}function mY(G){let I=G.frontmatter;if(!I)return[];let l=Object.entries(I);if(!l.length)return[];let c=l.filter(([Z,d])=>{let W=Z.toLowerCase();return W==="tags"||W==="tag"});return c?c.flatMap(([Z,d])=>{if(typeof d=="string")return d.split(/,|\s+/).map(W=>W.trim());if(Array.isArray(d))return d}).filter(Z=>!!Z):[]}function VY(G,I){let l=G.metadataCache.getFileCache(I);if(!l)return[];let c=[];return l.frontmatter&&c.push(...mY(l)),l.tags&&Array.isArray(l.tags)&&c.push(...l.tags.map(b=>b.tag.replace(/^\#/,""))),c}function iV(G,I){let l=I.replace(/^\#/,"");return G.vault.getMarkdownFiles().filter(c=>VY(G,c).includes(l))}var tc=class{constructor(){this.variables=new Map}replacer(I,l,c){return I.replace(l,function(){return c})}replaceDateInString(I){let l=I;for(;AZ.test(l);){let c=AZ.exec(l),b;if(c&&c[1]){let Z=c[1].replace("+","").trim();Z3.test(Z)&&(b=parseInt(Z))}l=this.replacer(l,AZ,cc({offset:b}))}for(;OG.test(l);){let c=OG.exec(l);if(!c)throw new Error(`Unable to parse date format. Invalid syntax in: "${l.substring(Math.max(0,l.search(OG)-10),Math.min(l.length,l.search(OG)+30))}..."`);let b=c[1],Z;if(c[2]){let d=c[2].replace("+","").trim();Z3.test(d)&&(Z=parseInt(d))}l=this.replacer(l,OG,cc({format:b,offset:Z}))}return l}replaceTimeInString(I){let l=I;for(;PG.test(l);){if(!PG.exec(l))throw new Error(`Unable to parse time format. Invalid syntax in: "${l.substring(Math.max(0,l.search(PG)-10),Math.min(l.length,l.search(PG)+30))}..."`);l=this.replacer(l,PG,cc({format:"HH:mm"}))}for(;qG.test(l);){let c=qG.exec(l);if(!c)throw new Error(`Unable to parse formatted time. Invalid syntax in: "${l.substring(Math.max(0,l.search(qG)-10),Math.min(l.length,l.search(qG)+30))}..."`);let b=c[1];l=this.replacer(l,qG,cc({format:b}))}return l}async replaceValueInString(I){let l=I;for(this.variables.has("value")&&(this.value=this.variables.get("value"));d3.test(l);)this.value||(this.value=await this.promptForValue()),l=this.replacer(l,d3,this.value);return l}async replaceSelectedInString(I){let l=I,c=await this.getSelectedText();for(;a3.test(l);)l=this.replacer(l,a3,c);return l}async replaceLinkToCurrentFileInString(I){let l=this.getCurrentFileLink(),c=I;if(!l&&gZ.test(c))throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");if(!l)return c;for(;gZ.test(c);)c=this.replacer(c,gZ,l);return c}async replaceVariableInString(I){let l=I;for(;_G.test(l);){let c=_G.exec(l);if(!c)throw new Error(`Unable to parse variable. Invalid syntax in: "${l.substring(Math.max(0,l.search(_G)-10),Math.min(l.length,l.search(_G)+30))}..."`);let b=c[1],Z="";if(b){let d=b.indexOf("|");if(d!==-1&&(Z=b.substring(d+1).trim(),b=b.substring(0,d).trim()),!this.getVariableValue(b)){let W=b.split(","),a="";W.length===1?a=await this.promptForVariable(b):a=await this.suggestForValue(W),!a&&Z&&(a=Z),this.variables.set(b,a)}l=this.replacer(l,_G,this.getVariableValue(b))}else break}return l}async replaceFieldVarInString(I){let l=I;for(;$G.test(l);){let c=$G.exec(l);if(!c)throw new Error(`Unable to parse field variable. Invalid syntax in: "${l.substring(Math.max(0,l.search($G)-10),Math.min(l.length,l.search($G)+30))}..."`);let b=c[1]+(c[2]||"");if(b)this.getVariableValue(b)||this.variables.set(b,await this.suggestForField(b)),l=this.replacer(l,$G,this.getVariableValue(b));else break}return l}async replaceMathValueInString(I){let l=I;for(;W3.test(l);){let c=await this.promptForMathValue();l=this.replacer(l,W3,c)}return l}async replaceMacrosInString(I){let l=I;for(;zZ.test(l);){let c=zZ.exec(l);if(!c||!c[1])continue;let b=c[1],Z=await this.getMacroValue(b);l=this.replacer(l,zZ,Z?Z.toString():"")}return l}async replaceDateVariableInString(I){let l=I;for(;lG.test(l);){let c=lG.exec(l);if(!c||!c[1]||!c[2])break;let b=c[1].trim(),Z=c[2].trim();if(!b||!Z)break;if(b&&Z){if(!this.variables.get(b)){let m=await this.promptForVariable(b);this.variables.set(b,m);let V=this.getNaturalLanguageDates();if(!V||!V.parseDate||typeof V.parseDate!="function")throw new Error(`VDATE variable "${b}" requires the Natural Language Dates plugin to be installed and enabled.`);let N=V.parseDate(m);if(N)this.variables.set(b,`@date:${N.moment.toISOString()}`);else throw new Error(`unable to parse date variable ${m}`)}let W="",a=this.variables.get(b);if(a&&a.startsWith("@date:")){let m=a.substring(6),V=this.getNaturalLanguageDates();if(V&&V.parseDate&&typeof V.parseDate=="function"){let N=window.moment(m);N&&N.isValid()&&(W=N.for
Line truncated
|
||||
`,c++):Z=="\\"?(l+="\\",c++):l+="\\":l+=b}return l}};var NY={title:"My Document Title",name:"Document Name",project:"Project Alpha",category:"Notes",author:"Your Name",status:"Draft",priority:"High",tag:"important",type:"meeting",client:"Acme Corp"},hY={clipboard:"clipboard_content",date:"formatted_date",time:"current_time",random:"random_value",uuid:"unique_id"},FY=[{pattern:/date|time/i,example:"2024-01-15"},{pattern:/title|name/i,example:"Example Title"},{pattern:/tag/i,example:"important"},{pattern:/category|type/i,example:"Notes"},{pattern:/author|user/i,example:"Your Name"},{pattern:/project/i,example:"Project Alpha"},{pattern:/status/i,example:"In Progress"},{pattern:/priority/i,example:"High"},{pattern:/number|count|id/i,example:"001"}];function DZ(G){let I=G.toLowerCase(),l=NY[I];return l||`${G}_example`}function KZ(G){return hY[G.toLowerCase()]||`${G}_output`}function OZ(G){for(let{pattern:I,example:l}of FY)if(I.test(G))return l;return`${G}_value`}function PZ(G){return G.length>0?`${G[0]} (${G.length} options)`:"suggestion_list"}function qZ(G){return G?.path?G.basename:"current_file"}var z2=class{static generate(I,l=new Date){let c=l.getFullYear(),b=(l.getMonth()+1).toString().padStart(2,"0"),Z=l.getDate().toString().padStart(2,"0"),d=l.getHours().toString().padStart(2,"0"),W=l.getMinutes().toString().padStart(2,"0"),a=l.getSeconds().toString().padStart(2,"0");return I.replace(/YYYY/g,c.toString()).replace(/YY/g,c.toString().slice(-2)).replace(/MMMM/g,this.MONTH_NAMES[l.getMonth()]).replace(/MMM/g,this.MONTH_NAMES_SHORT[l.getMonth()]).replace(/MM/g,b).replace(/M/g,(l.getMonth()+1).toString()).replace(/dddd/g,this.DAY_NAMES[l.getDay()]).replace(/ddd/g,this.DAY_NAMES_SHORT[l.getDay()]).replace(/DD/g,Z).replace(/D/g,l.getDate().toString()).replace(/HH/g,d).replace(/H/g,l.getHours().toString()).replace(/mm/g,W).replace(/m/g,l.getMinutes().toString()).replace(/ss/g,a).replace(/s/g,l.getSeconds().toString()).replace(/ww/g,this.getWeekNumber(l).toString().padStart(2,"0")).replace(/w/g,this.getWeekNumber(l).toString())}static getWeekNumber(I){let l=new Date(I.getFullYear(),0,1),c=(I.getTime()-l.getTime())/864e5;return Math.ceil((c+l.getDay()+1)/7)}};z2.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],z2.MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],z2.DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z2.DAY_NAMES_SHORT=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var V1=class extends tc{constructor(l){super();this.app=l}async format(l){let c=l;try{c=await this.replaceMacrosInString(c),c=this.replaceDateInString(c),c=this.replaceTimeInString(c),c=await this.replaceValueInString(c),c=await this.replaceDateVariableInString(c),c=await this.replaceVariableInString(c),c=await this.replaceFieldVarInString(c)}catch{return l}return`Preview: ${c}`}promptForValue(l){return l||"user input"}getVariableValue(l){return DZ(l)}getCurrentFileLink(){return qZ(this.app.workspace.getActiveFile())}getNaturalLanguageDates(){return g2(this.app)}suggestForValue(l){return PZ(l)}promptForMathValue(){return Promise.resolve("calculation_result")}getMacroValue(l){return KZ(l)}async promptForVariable(l){return OZ(l)}async getTemplateContent(l){return`[${l.split("/").pop()?.replace(".md","")||l} template content...]`}async getSelectedText(){return"selected_text"}suggestForField(l){return`${l}_field_value`}async replaceDateVariableInString(l){let c=l;return c=c.replace(new RegExp(lG.source,"gi"),(b,Z,d)=>{let W=Z?.trim(),a=d?.trim();if(!W||!a)return b;let m=new Date,V;try{V=z2.generate(a,m)}catch{V=`[${a}]`}return V}),c}};var ul=class extends yl{constructor(l,c,b,Z=!1){super(l,c);this.app=l;this.inputEl=c;this.plugin=b;this.suggestForFileNames=Z;this.lastInput="";this.lastInputStart=0;this.tokenDefinitions=[{regex:_m,token:1,suggestion:"{{DATE:}}",cursorOffset:2},{regex:qm,token:0,suggestion:G3},{regex:aV,token:10,suggestion:jm},{regex:$m,token:4,suggestion:b3},{regex:IV,token:3,suggestion:IG},{regex:dV,token:9,suggestion:Tm},{regex:WV,token:11,suggestion:Sm},{regex:lV,token:5,suggestion:"{{VALUE:}}",cursorOffset:2},{regex:cV,token:2,suggestion:"{{VDATE:}}",cursorOffset:2}];this.contextualTokens=[{regex:GV,token:6,suggestion:Cm},{regex:bV,token:8,suggestion:"{{TEMPLATE:"},{regex:ZV,token:7,suggestion:"{{MACRO:"}];this.macroNames=this.plugin.settings.macros.map(d=>d.name),this.templatePaths=this.plugin.getTemplateFiles().map(d=>d.path)}async getSuggestions(l){if(this.inputEl.selectionStart===null)return[];let c=this.inputEl.selectionStart,b=l.lastIndexOf("{{",c-1);if(b===-1)return[];let Z=l.slice(b,c);if(Z.includes("}}"))return[];if(Z.includes(":"))return[];let d=[],W=[...this.tokenDefinitions,...this.suggestForFileNames?[]:this.contextualTokens];for(let a of W){let m=a.regex.exec(Z);m&&m.index+m[0].length===Z.length&&(this.lastInput=m[0],this.lastInputType=a.token,this.lastInputStart=c-
Line truncated
|
||||
`).filter(Boolean).reduce((c,b)=>{let[Z,d,...W]=b.split(" "),a=Number.parseInt(d,10);return W.forEach((m,V)=>c[m]=a+V),c},{});for(let[c,b]of Object.entries(l)){let Z=MV.default.toByteArray(c);this.rankMap.set(Z.join(","),b),this.textMap.set(b,Z)}this.specialTokens={...G.special_tokens,...I},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((c,[b,Z])=>(c[Z]=this.textEncoder.encode(b),c),{})}encode(G,I=[],l="all"){let c=new RegExp(this.patStr,"ug"),b=i3.specialTokenRegex(Object.keys(this.specialTokens)),Z=[],d=new Set(I==="all"?Object.keys(this.specialTokens):I),W=new Set(l==="all"?Object.keys(this.specialTokens).filter(m=>!d.has(m)):l);if(W.size>0){let m=i3.specialTokenRegex([...W]),V=G.match(m);if(V!=null)throw new Error(`The text contains a special token that is not allowed: ${V[0]}`)}let a=0;for(;;){let m=null,V=a;for(;b.lastIndex=V,m=b.exec(G),!(m==null||d.has(m[0]));)V=m.index+1;let N=m?.index??G.length;for(let F of G.substring(a,N).matchAll(c)){let R=this.textEncoder.encode(F[0]),X=this.rankMap.get(R.join(","));if(X!=null){Z.push(X);continue}Z.push(...QY(R,this.rankMap))}if(m==null)break;let h=this.specialTokens[m[0]];Z.push(h),a=m.index+m[0].length}return Z}decode(G){let I=[],l=0;for(let Z=0;Z<G.length;++Z){let d=G[Z],W=this.textMap.get(d)??this.inverseSpecialTokens[d];W!=null&&(I.push(W),l+=W.length)}let c=new Uint8Array(l),b=0;for(let Z of I)c.set(Z,b),b+=Z.length;return this.textDecoder.decode(c)}},Ec=i3;EY(Ec,"specialTokenRegex",G=>new RegExp(G.map(I=>vY(I)).join("|"),"g"));function r3(G){switch(G){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":return"cl100k_base";default:throw new Error("Unknown model")}}var JY={explicit_n_vocab:50257,pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256},bpe_ranks:"! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ== yg== yw== zA== zQ== zg== zw== 0A== 0Q== 0g== 0w== 1A== 1Q== 1g== 1w== 2A== 2Q== 2g== 2w== 3A== 3Q== 3g== 3w== 4A== 4Q== 4g== 4w== 5A== 5Q== 5g== 5w== 6A== 6Q== 6g== 6w== 7A== 7Q== 7g== 7w== 8A== 8Q== 8g== 8w== 9A== 9Q== 9g== 9w== +A== +Q== +g== +w== /A== /Q== /g== /w== AA== AQ== Ag== Aw== BA== BQ== Bg== Bw== CA== CQ== Cg== Cw== DA== DQ== Dg== Dw== EA== EQ== Eg== Ew== FA== FQ== Fg== Fw== GA== GQ== Gg== Gw== HA== HQ== Hg== Hw== IA== fw== gA== gQ== gg== gw== hA== hQ== hg== hw== iA== iQ== ig== iw== jA== jQ== jg== jw== kA== kQ== kg== kw== lA== lQ== lg== lw== mA== mQ== mg== mw== nA== nQ== ng== nw== oA== rQ== IHQ= IGE= aGU= aW4= cmU= b24= IHRoZQ== ZXI= IHM= YXQ= IHc= IG8= ZW4= IGM= aXQ= aXM= YW4= b3I= ZXM= IGI= ZWQ= IGY= aW5n IHA= b3U= IGFu YWw= YXI= IHRv IG0= IG9m IGlu IGQ= IGg= IGFuZA== aWM= YXM= bGU= IHRo aW9u b20= bGw= ZW50 IG4= IGw= c3Q= IHJl dmU= IGU= cm8= bHk= IGJl IGc= IFQ= Y3Q= IFM= aWQ= b3Q= IEk= dXQ= ZXQ= IEE= IGlz IG9u aW0= YW0= b3c= YXk= YWQ= c2U= IHRoYXQ= IEM= aWc= IGZvcg== YWM= IHk= dmVy dXI= IHU= bGQ= IHN0 IE0= J3M= IGhl IGl0 YXRpb24= aXRo aXI= Y2U= IHlvdQ== aWw= IEI= IHdo b2w= IFA= IHdpdGg= IDE= dGVy Y2g= IGFz IHdl ICg= bmQ= aWxs IEQ= aWY= IDI= YWc= ZXJz a2U= I
Line truncated
|
||||
! 50257 ICA= ICAg ICAgIA== ICAgICA= ICAgICAg ICAgICAgIA== ICAgICAgICA= ICAgICAgICAg ICAgICAgICAgIA== ICAgICAgICAgICA= ICAgICAgICAgICAg ICAgICAgICAgICAgIA== ICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIA==`},yY={pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256,"<|fim_prefix|>":50281,"<|fim_middle|>":50282,"<|fim_suffix|>":50283},bpe_ranks:`! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ== yg== yw== zA== zQ== zg== zw== 0A== 0Q== 0g== 0w== 1A== 1Q== 1g== 1w== 2A== 2Q== 2g== 2w== 3A== 3Q== 3g== 3w== 4A== 4Q== 4g== 4w== 5A== 5Q== 5g== 5w== 6A== 6Q== 6g== 6w== 7A== 7Q== 7g== 7w== 8A== 8Q== 8g== 8w== 9A== 9Q== 9g== 9w== +A== +Q== +g== +w== /A== /Q== /g== /w== AA== AQ== Ag== Aw== BA== BQ== Bg== Bw== CA== CQ== Cg== Cw== DA== DQ== Dg== Dw== EA== EQ== Eg== Ew== FA== FQ== Fg== Fw== GA== GQ== Gg== Gw== HA== HQ== Hg== Hw== IA== fw== gA== gQ== gg== gw== hA== hQ== hg== hw== iA== iQ== ig== iw== jA== jQ== jg== jw== kA== kQ== kg== kw== lA== lQ== lg== lw== mA== mQ== mg== mw== nA== nQ== ng== nw== oA== rQ== IHQ= IGE= aGU= aW4= cmU= b24= IHRoZQ== ZXI= IHM= YXQ= IHc= IG8= ZW4= IGM= aXQ= aXM= YW4= b3I= ZXM= IGI= ZWQ= IGY= aW5n IHA= b3U= IGFu YWw= YXI= IHRv IG0= IG9m IGlu IGQ= IGg= IGFuZA== aWM= YXM= bGU= IHRo aW9u b20= bGw= ZW50 IG4= IGw= c3Q= IHJl dmU= IGU= cm8= bHk= IGJl IGc= IFQ= Y3Q= IFM= aWQ= b3Q= IEk= dXQ= ZXQ= IEE= IGlz IG9u aW0= YW0= b3c= YXk= YWQ= c2U= IHRoYXQ= IEM= aWc= IGZvcg== YWM= IHk= dmVy dXI= IHU= bGQ= IHN0 IE0= J3M= IGhl IGl0 YXRpb24= aXRo aXI= Y2U= IHlvdQ== aWw= IEI= IHdo b2w= IFA= IHdpdGg= IDE= dGVy Y2g= IGFz IHdl ICg= bmQ= aWxs IEQ= aWY= IDI= YWc= ZXJz a2U= ICI= IEg= ZW0= IGNvbg== IFc= IFI= aGVy IHdhcw== IHI= b2Q= IEY= dWw= YXRl IGF0 cmk= cHA= b3Jl IFRoZQ== IHNl dXM= IHBybw== IGhh dW0= IGFyZQ== IGRl YWlu YW5k IG9y aWdo ZXN0 aXN0 YWI= cm9t IE4= dGg= IGNvbQ== IEc= dW4= b3A= MDA= IEw= IG5vdA== ZXNz IGV4 IHY= cmVz IEU= ZXc= aXR5 YW50 IGJ5 ZWw= b3M= b3J0 b2M= cXU= IGZyb20= IGhhdmU= IHN1 aXZl b3VsZA== IHNo IHRoaXM= bnQ= cmE= cGU= aWdodA== YXJ0 bWVudA== IGFs dXN0 ZW5k LS0= YWxs IE8= YWNr IGNo IGxl aWVz cmVk YXJk 4oA= b3V0 IEo= IGFi ZWFy aXY= YWxseQ== b3Vy b3N0 Z2g= cHQ= IHBs YXN0 IGNhbg== YWs= b21l dWQ= VGhl IGhpcw== IGRv IGdv IGhhcw== Z2U= J3Q= IFU= cm91 IHNh IGo= IGJ1dA== IHdvcg== IGFsbA== ZWN0 IGs= YW1l IHdpbGw= b2s= IHdoZQ== IHRoZXk= aWRl MDE= ZmY= aWNo cGw= dGhlcg== IHRy Li4= IGludA== aWU= dXJl YWdl IG5l aWFs YXA= aW5l aWNl IG1l IG91dA== YW5z b25l b25n aW9ucw== IHdobw== IEs= IHVw IHRoZWly IGFk IDM= IHVz YXRlZA== b3Vz IG1vcmU= dWU= b2c= IFN0 aW5k aWtl IHNv aW1l cGVy LiI= YmVy aXo= YWN0 IG9uZQ== IHNhaWQ= IC0= YXJl IHlvdXI= Y2M= IFRo IGNs ZXA= YWtl YWJsZQ== aXA= IGNvbnQ= IHdoaWNo aWE= IGlt IGFib3V0 IHdlcmU= dmVyeQ== dWI= IGhhZA== IGVu IGNvbXA= LCI= IElu IHVu IGFn aXJl YWNl YXU= YXJ5 IHdvdWxk YXNz cnk= IOKA Y2w= b29r ZXJl c28= IFY= aWdu aWI= IG9mZg== IHRl dmVu IFk= aWxl b3Nl aXRl b3Jt IDIwMQ== IHJlcw== IG1hbg== IHBlcg== IG90aGVy b3Jk dWx0 IGJlZW4= IGxpa2U= YXNl YW5jZQ== a3M= YXlz b3du ZW5jZQ== IGRpcw== Y3Rpb24= IGFueQ== IGFwcA== IHNw aW50 cmVzcw== YXRpb25z YWls IDQ= aWNhbA== IHRoZW0= IGhlcg== b3VudA== IENo IGFy IGlm IHRoZXJl IHBl IHllYXI= YXY= IG15 IHNvbWU= IHdoZW4= b3VnaA== YWNo IHRoYW4= cnU= b25k aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vLine truncated
|
||||
! 50257 ICA= ICAg ICAgIA== ICAgICA= ICAgICAg ICAgICAgIA== ICAgICAgICA= ICAgICAgICAg ICAgICAgICAgIA== ICAgICAgICAgICA= ICAgICAgICAgICAg ICAgICAgICAgICAgIA== ICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIA==`},oY={explicit_n_vocab:50257,pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256},bpe_ranks:"! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ== yg== yw== zA== zQ== zg== zw== 0A== 0Q== 0g== 0w== 1A== 1Q== 1g== 1w== 2A== 2Q== 2g== 2w== 3A== 3Q== 3g== 3w== 4A== 4Q== 4g== 4w== 5A== 5Q== 5g== 5w== 6A== 6Q== 6g== 6w== 7A== 7Q== 7g== 7w== 8A== 8Q== 8g== 8w== 9A== 9Q== 9g== 9w== +A== +Q== +g== +w== /A== /Q== /g== /w== AA== AQ== Ag== Aw== BA== BQ== Bg== Bw== CA== CQ== Cg== Cw== DA== DQ== Dg== Dw== EA== EQ== Eg== Ew== FA== FQ== Fg== Fw== GA== GQ== Gg== Gw== HA== HQ== Hg== Hw== IA== fw== gA== gQ== gg== gw== hA== hQ== hg== hw== iA== iQ== ig== iw== jA== jQ== jg== jw== kA== kQ== kg== kw== lA== lQ== lg== lw== mA== mQ== mg== mw== nA== nQ== ng== nw== oA== rQ== IHQ= IGE= aGU= aW4= cmU= b24= IHRoZQ== ZXI= IHM= YXQ= IHc= IG8= ZW4= IGM= aXQ= aXM= YW4= b3I= ZXM= IGI= ZWQ= IGY= aW5n IHA= b3U= IGFu YWw= YXI= IHRv IG0= IG9m IGlu IGQ= IGg= IGFuZA== aWM= YXM= bGU= IHRo aW9u b20= bGw= ZW50 IG4= IGw= c3Q= IHJl dmU= IGU= cm8= bHk= IGJl IGc= IFQ= Y3Q= IFM= aWQ= b3Q= IEk= dXQ= ZXQ= IEE= IGlz IG9u aW0= YW0= b3c= YXk= YWQ= c2U= IHRoYXQ= IEM= aWc= IGZvcg== YWM= IHk= dmVy dXI= IHU= bGQ= IHN0 IE0= J3M= IGhl IGl0 YXRpb24= aXRo aXI= Y2U= IHlvdQ== aWw= IEI= IHdo b2w= IFA= IHdpdGg= IDE= dGVy Y2g= IGFz IHdl ICg= bmQ= aWxs IEQ= aWY= IDI= YWc= ZXJz a2U= ICI= IEg= ZW0= IGNvbg== IFc= IFI= aGVy IHdhcw== IHI= b2Q= IEY= dWw= YXRl IGF0 cmk= cHA= b3Jl IFRoZQ== IHNl dXM= IHBybw== IGhh dW0= IGFyZQ== IGRl YWlu YW5k IG9y aWdo ZXN0 aXN0 YWI= cm9t IE4= dGg= IGNvbQ== IEc= dW4= b3A= MDA= IEw= IG5vdA== ZXNz IGV4 IHY= cmVz IEU= ZXc= aXR5 YW50 IGJ5 ZWw= b3M= b3J0 b2M= cXU= IGZyb20= IGhhdmU= IHN1 aXZl b3VsZA== IHNo IHRoaXM= bnQ= cmE= cGU= aWdodA== YXJ0 bWVudA== IGFs dXN0 ZW5k LS0= YWxs IE8= YWNr IGNo IGxl aWVz cmVk YXJk 4oA= b3V0 IEo= IGFi ZWFy aXY= YWxseQ== b3Vy b3N0 Z2g= cHQ= IHBs YXN0 IGNhbg== YWs= b21l dWQ= VGhl IGhpcw== IGRv IGdv IGhhcw== Z2U= J3Q= IFU= cm91 IHNh IGo= IGJ1dA== IHdvcg== IGFsbA== ZWN0 IGs= YW1l IHdpbGw= b2s= IHdoZQ== IHRoZXk= aWRl MDE= ZmY= aWNo cGw= dGhlcg== IHRy Li4= IGludA== aWU= dXJl YWdl IG5l aWFs YXA= aW5l aWNl IG1l IG91dA== YW5z b25l b25n aW9ucw== IHdobw== IEs= IHVw IHRoZWly IGFk IDM= IHVz YXRlZA== b3Vz IG1vcmU= dWU= b2c= IFN0 aW5k aWtl IHNv aW1l cGVy LiI= YmVy aXo= YWN0 IG9uZQ== IHNhaWQ= IC0= YXJl IHlvdXI= Y2M= IFRo IGNs ZXA= YWtl YWJsZQ== aXA= IGNvbnQ= IHdoaWNo aWE= IGlt IGFib3V0 IHdlcmU= dmVyeQ== dWI= IGhhZA== IGVu IGNvbXA= LCI= IElu IHVu IGFn aXJl YWNl YXU= YXJ5 IHdvdWxk YXNz cnk= IOKA Y2w= b29r ZXJl c28= IFY= aWdu aWI= IG9mZg== IHRl dmVu IFk= aWxl b3Nl aXRl b3Jt IDIwMQ== IHJlcw== IG1hbg== IHBlcg== IG90aGVy b3Jk dWx0 IGJlZW4= IGxpa2U= YXNl YW5jZQ== a3M= YXlz b3du ZW5jZQ== IGRpcw== Y3Rpb24= IGFueQ== IGFwcA== IHNw aW50 cmVzcw== YXRpb25z YWls IDQ= aWNhbA== IHRoZW0= IGhlcg== b3VudA== IENo IGFy IGlm IHRoZXJl IHBl IHllYXI= YXY= IG15 IHNvbWU= IHdoZW4= b3VnaA== YWNo IHRoYW4= cnU= b25k aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vc3Q= IGRpZA== IGFkZA== amVjdA== IGluYw== Zm9yZ
Line truncated
|
||||
`,Z}positionTooltip(G,b){let Z=b.getBoundingClientRect();G.style.position="fixed",G.style.left=`${Z.right+10}px`,G.style.top=`${Z.top}px`,G.style.zIndex="1000"}close(){document.querySelectorAll(".qaFileSuggestionItem").forEach(Z=>{Z._tooltipCleanup&&Z._tooltipCleanup()}),document.querySelectorAll(".qa-file-tooltip").forEach(Z=>Z.remove()),super.close()}async selectSuggestion(G){if(this.inputEl.selectionStart===null)return;let b=this.inputEl.selectionStart,Z=this.lastInput.length,c=this.inputEl.value,W=0,d=this.inputEl.value.slice(b-this.lastInput.length-3,b-this.lastInput.length)==="![[";if(G.matchType==="unresolved")W=this.makeLinkManually(c,G.displayText.replace(/.md$/,""),b,Z);else if(G.matchType==="heading"||G.matchType==="block"){let N=G.displayText;W=this.makeLinkManually(c,N,b,Z)}else if(d)W=this.makeLinkManually(c,G.displayText,b,Z);else{let N=this.app.vault.getAbstractFileByPath(G.file.path);if(N instanceof dY.TFile){let m=G.matchType==="alias"?G.displayText:void 0;W=this.makeLinkObsidianMethod(N,c,b,Z,m)}else W=this.makeLinkManually(c,G.displayText,b,Z)}this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(W,W)}makeLinkObsidianMethod(G,b,Z,c,W){let d=this.app.vault.getAbstractFileByPath(G.path),N=this.app.fileManager.generateMarkdownLink(d,"","",W??"");return this.inputEl.value=this.getNewInputValueForFileLink(b,N,Z,c),Z-c+N.length+2}makeLinkManually(G,b,Z,c){return this.inputEl.value=this.getNewInputValueForFileName(G,b,Z,c),Z-c+b.length+2}getNewInputValueForFileLink(G,b,Z,c){return`${G.substr(0,Z-c-2)}${b}${G.substr(Z)}`}getNewInputValueForFileName(G,b,Z,c){return`${G.substr(0,Z-c)}${b}]]${G.substr(Z)}`}};var OZ=class extends vG{constructor(G,b){super(G,b);this.app=G;this.inputEl=b;this.lastInput="";this.lastInputStart=0;this.refreshTagIndex(),XI.instance.registerEvent(this.app.metadataCache.on("resolved",()=>this.refreshTagIndex()))}refreshTagIndex(){let G=this.app.metadataCache.getTags(),b=Object.keys(G);this.tagSet=new Set(b),this.sortedTags=b.sort((Z,c)=>Z.length!==c.length?Z.length-c.length:Z.localeCompare(c)),this.fuse=new tG(this.sortedTags,{threshold:.4,includeScore:!0,keys:[""]})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let b=this.inputEl.selectionStart,Z=G.slice(0,b),c=Q2.exec(Z);if(!c)return[];let W=Z.lastIndexOf("[[");if(W!==-1&&W<c.index)return[];let d=c[1];this.lastInput=d,this.lastInputStart=c.index;let N=this.sortedTags.filter(h=>h.toLowerCase().startsWith(d.toLowerCase())).slice(0,5),m=this.fuse.search(d).filter(h=>h.score<.8).map(h=>h.item).slice(0,10),Y=new Set(N),V=[...N];for(let h of m)!Y.has(h)&&V.length<15&&(V.push(h),Y.add(h));return V}renderSuggestion(G,b){let Z=this.renderMatch(G,this.lastInput);b.innerHTML=Z}selectSuggestion(G){let b=this.inputEl;if(b.selectionStart===null)return;let Z=b.selectionStart,W=b.value.lastIndexOf("#",Z-1);if(W===-1)return;let d=G.startsWith("#")?G:`#${G}`;Nd(b,W,Z,d,{dispatchInput:!1}),this.close()}};var yI=class l extends MZ.Modal{constructor(G,b,Z,c){super(G);this.header=b;this.didSubmit=!1;this.submitClickCallback=G=>this.submit();this.cancelClickCallback=G=>this.cancel();this.submitEnterCallback=G=>{!G.isComposing&&G.key==="Enter"&&(G.preventDefault(),this.submit())};this.placeholder=Z??"",this.input=c??"",this.waitForClose=new Promise((W,d)=>{this.resolvePromise=W,this.rejectPromise=d}),this.display(),this.open(),this.fileSuggester=new rZ(G,this.inputComponent.inputEl),this.tagSuggester=new OZ(G,this.inputComponent.inputEl)}static Prompt(G,b,Z,c){return new l(G,b,Z,c).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header;let G=this.contentEl.createDiv();this.inputComponent=this.createInputField(G,this.placeholder,this.input),this.createButtonBar(G)}createInputField(G,b,Z){let c=new MZ.TextComponent(G);return c.inputEl.style.width="100%",c.setPlaceholder(b??"").setValue(Z??"").onChange(W=>this.input=W).inputEl.addEventListener("keydown",this.submitEnterCallback),c}createButton(G,b,Z){let c=new MZ.ButtonComponent(G);return c.setButtonText(b).onClick(Z),c}createButtonBar(G){let b=G.createDiv();this.createButton(b,"Ok",this.submitClickCallback).setCta().buttonEl.style.marginRight="0",this.createButton(b,"Cancel",this.cancelClickCallback),b.style.display="flex",b.style.flexDirection="row-reverse",b.style.justifyContent="flex-start",b.style.marginTop="1rem",b.style.gap="0.5rem"}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise("No input given.")}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback)}onOpen(){super.onOpen(),this.inputComponent.inputEl.focus(),this.inputComponent.inputEl.select()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListener()}};var Tb=class Tb{register(I){return Tb.loggers.push(I),this}logError(I){let G=I instanceof Error?I.mess
Line truncated
|
||||
})`)(b,c,Z);let N=Z.default||c.exports;if(!N)return;let m=N,{memberAccess:Y}=GW(l.name);if(Y&&Y.length>0){let V;for(;V=Y.shift();)m=m[V]}return m}}function q2(l,I){let G=structuredClone(l);for(let b of I)delete G[b];return G}function f2(l){let I=c=>c.type==="Template",G=c=>c.type==="Macro",b=c=>c.type==="Capture",Z=c=>c.type==="Multi";return I(l)||G(l)||b(l)||Z(l)}function P2(l,I){let G=l.vault.getAbstractFileByPath(I);return!!G&&G instanceof Ml.TFolder}function KZ(l,I){return l.vault.getMarkdownFiles().filter(G=>G.path.startsWith(I))}function wH(l){let I=l.frontmatter;if(!I)return[];let G=Object.entries(I);if(!G.length)return[];let b=G.filter(([c,W])=>{let d=c.toLowerCase();return d==="tags"||d==="tag"});return b?b.flatMap(([c,W])=>{if(typeof W=="string")return W.split(/,|\s+/).map(d=>d.trim());if(Array.isArray(W))return W}).filter(c=>!!c):[]}function vH(l,I){let G=l.metadataCache.getFileCache(I);if(!G)return[];let b=[];return G.frontmatter&&b.push(...wH(G)),G.tags&&Array.isArray(G.tags)&&b.push(...G.tags.map(Z=>Z.tag.replace(/^\#/,""))),b}function _2(l,I){let G=I.replace(/^\#/,"");return l.vault.getMarkdownFiles().filter(b=>vH(l,b).includes(G))}var Vb=class{constructor(){this.variables=new Map}replacer(I,G,b){return I.replace(G,function(){return b})}replaceDateInString(I){let G=I;for(;ad.test(G);){let b=ad.exec(G),Z;if(b&&b[1]){let c=b[1].replace("+","").trim();Bm.test(c)&&(Z=parseInt(c))}G=this.replacer(G,ad,jl({offset:Z}))}for(;LZ.test(G);){let b=LZ.exec(G);if(!b)throw new Error(`Unable to parse date format. Invalid syntax in: "${G.substring(Math.max(0,G.search(LZ)-10),Math.min(G.length,G.search(LZ)+30))}..."`);let Z=b[1],c;if(b[2]){let W=b[2].replace("+","").trim();Bm.test(W)&&(c=parseInt(W))}G=this.replacer(G,LZ,jl({format:Z,offset:c}))}return G}replaceTimeInString(I){let G=I;for(;oZ.test(G);){if(!oZ.exec(G))throw new Error(`Unable to parse time format. Invalid syntax in: "${G.substring(Math.max(0,G.search(oZ)-10),Math.min(G.length,G.search(oZ)+30))}..."`);G=this.replacer(G,oZ,jl({format:"HH:mm"}))}for(;kZ.test(G);){let b=kZ.exec(G);if(!b)throw new Error(`Unable to parse formatted time. Invalid syntax in: "${G.substring(Math.max(0,G.search(kZ)-10),Math.min(G.length,G.search(kZ)+30))}..."`);let Z=b[1];G=this.replacer(G,kZ,jl({format:Z}))}return G}async replaceValueInString(I){let G=I;for(this.variables.has("value")&&(this.value=this.variables.get("value"));rm.test(G);)this.value||(this.value=await this.promptForValue()),G=this.replacer(G,rm,this.value);return G}async replaceSelectedInString(I){let G=I,b=await this.getSelectedText();for(;Mm.test(G);)G=this.replacer(G,Mm,b);return G}async replaceLinkToCurrentFileInString(I){let G=this.getCurrentFileLink(),b=I;if(!G&&Fd.test(b))throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");if(!G)return b;for(;Fd.test(b);)b=this.replacer(b,Fd,G);return b}async replaceVariableInString(I){let G=I;for(;iZ.test(G);){let b=iZ.exec(G);if(!b)throw new Error(`Unable to parse variable. Invalid syntax in: "${G.substring(Math.max(0,G.search(iZ)-10),Math.min(G.length,G.search(iZ)+30))}..."`);let Z=b[1],c="";if(Z){let W=Z.indexOf("|");if(W!==-1&&(c=Z.substring(W+1).trim(),Z=Z.substring(0,W).trim()),!this.getVariableValue(Z)){let d=Z.split(","),N="";d.length===1?N=await this.promptForVariable(Z):N=await this.suggestForValue(d),!N&&c&&(N=c),this.variables.set(Z,N)}G=this.replacer(G,iZ,this.getVariableValue(Z))}else break}return G}async replaceFieldVarInString(I){let G=I;for(;zZ.test(G);){let b=zZ.exec(G);if(!b)throw new Error(`Unable to parse field variable. Invalid syntax in: "${G.substring(Math.max(0,G.search(zZ)-10),Math.min(G.length,G.search(zZ)+30))}..."`);let Z=b[1]+(b[2]||"");if(Z)this.getVariableValue(Z)||this.variables.set(Z,await this.suggestForField(Z)),G=this.replacer(G,zZ,this.getVariableValue(Z));else break}return G}async replaceMathValueInString(I){let G=I;for(;Om.test(G);){let b=await this.promptForMathValue();G=this.replacer(G,Om,b)}return G}async replaceMacrosInString(I){let G=I;for(;Rd.test(G);){let b=Rd.exec(G);if(!b||!b[1])continue;let Z=b[1],c=await this.getMacroValue(Z);G=this.replacer(G,Rd,c?c.toString():"")}return G}async replaceDateVariableInString(I){let G=I;for(;Mb.test(G);){let b=Mb.exec(G);if(!b||!b[1]||!b[2])break;let Z=b[1].trim(),c=b[2].trim();if(!Z||!c)break;if(Z&&c){if(!this.variables.get(Z)){let m=await this.promptForVariable(Z);this.variables.set(Z,m);let Y=this.getNaturalLanguageDates();if(!Y||!Y.parseDate||typeof Y.parseDate!="function")throw new Error(`VDATE variable "${Z}" requires the Natural Language Dates plugin to be installed and enabled.`);let V=Y.parseDate(m);if(V)this.variables.set(Z,`@date:${V.moment.toISOString()}`);else throw new Error(`unable to parse date variable ${m}`)}let d="",N=this.variables.get(Z);if(N&&N.startsWith("@date:")){let m=N.substring(6),Y=this.getNaturalLanguageDates();if(Y&&Y.parseDate&&typeof Y.parseDate=="function"){let V=window.moment(m);V&&V.isValid()&&(d=V.for
Line truncated
|
||||
`,b++):c=="\\"?(G+="\\",b++):G+="\\":G+=Z}return G}};var tH={title:"My Document Title",name:"Document Name",project:"Project Alpha",category:"Notes",author:"Your Name",status:"Draft",priority:"High",tag:"important",type:"meeting",client:"Acme Corp"},EH={clipboard:"clipboard_content",date:"formatted_date",time:"current_time",random:"random_value",uuid:"unique_id"},JH=[{pattern:/date|time/i,example:"2024-01-15"},{pattern:/title|name/i,example:"Example Title"},{pattern:/tag/i,example:"important"},{pattern:/category|type/i,example:"Notes"},{pattern:/author|user/i,example:"Your Name"},{pattern:/project/i,example:"Project Alpha"},{pattern:/status/i,example:"In Progress"},{pattern:/priority/i,example:"High"},{pattern:/number|count|id/i,example:"001"}];function yd(l){let I=l.toLowerCase(),G=tH[I];return G||`${l}_example`}function ed(l){return EH[l.toLowerCase()]||`${l}_output`}function Cd(l){for(let{pattern:I,example:G}of JH)if(I.test(l))return G;return`${l}_value`}function gd(l){return l.length>0?`${l[0]} (${l.length} options)`:"suggestion_list"}function Ad(l){return l?.path?l.basename:"current_file"}var tl=class{static generate(I,G=new Date){let b=G.getFullYear(),Z=(G.getMonth()+1).toString().padStart(2,"0"),c=G.getDate().toString().padStart(2,"0"),W=G.getHours().toString().padStart(2,"0"),d=G.getMinutes().toString().padStart(2,"0"),N=G.getSeconds().toString().padStart(2,"0");return I.replace(/YYYY/g,b.toString()).replace(/YY/g,b.toString().slice(-2)).replace(/MMMM/g,this.MONTH_NAMES[G.getMonth()]).replace(/MMM/g,this.MONTH_NAMES_SHORT[G.getMonth()]).replace(/MM/g,Z).replace(/M/g,(G.getMonth()+1).toString()).replace(/dddd/g,this.DAY_NAMES[G.getDay()]).replace(/ddd/g,this.DAY_NAMES_SHORT[G.getDay()]).replace(/DD/g,c).replace(/D/g,G.getDate().toString()).replace(/HH/g,W).replace(/H/g,G.getHours().toString()).replace(/mm/g,d).replace(/m/g,G.getMinutes().toString()).replace(/ss/g,N).replace(/s/g,G.getSeconds().toString()).replace(/ww/g,this.getWeekNumber(G).toString().padStart(2,"0")).replace(/w/g,this.getWeekNumber(G).toString())}static getWeekNumber(I){let G=new Date(I.getFullYear(),0,1),b=(I.getTime()-G.getTime())/864e5;return Math.ceil((b+G.getDay()+1)/7)}};tl.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],tl.MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tl.DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],tl.DAY_NAMES_SHORT=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var DZ=class extends Vb{constructor(G){super();this.app=G}async format(G){let b=G;try{b=await this.replaceMacrosInString(b),b=this.replaceDateInString(b),b=this.replaceTimeInString(b),b=await this.replaceValueInString(b),b=await this.replaceDateVariableInString(b),b=await this.replaceVariableInString(b),b=await this.replaceFieldVarInString(b)}catch{return G}return`Preview: ${b}`}promptForValue(G){return G||"user input"}getVariableValue(G){return yd(G)}getCurrentFileLink(){return Ad(this.app.workspace.getActiveFile())}getNaturalLanguageDates(){return vl(this.app)}suggestForValue(G){return gd(G)}promptForMathValue(){return Promise.resolve("calculation_result")}getMacroValue(G){return ed(G)}async promptForVariable(G){return Cd(G)}async getTemplateContent(G){return`[${G.split("/").pop()?.replace(".md","")||G} template content...]`}async getSelectedText(){return"selected_text"}suggestForField(G){return`${G}_field_value`}async replaceDateVariableInString(G){let b=G;return b=b.replace(new RegExp(Mb.source,"gi"),(Z,c,W)=>{let d=c?.trim(),N=W?.trim();if(!d||!N)return Z;let m=new Date,Y;try{Y=tl.generate(N,m)}catch{Y=`[${N}]`}return Y}),b}};var pG=class extends vG{constructor(G,b,Z,c=!1){super(G,b);this.app=G;this.inputEl=b;this.plugin=Z;this.suggestForFileNames=c;this.lastInput="";this.lastInputStart=0;this.tokenDefinitions=[{regex:p2,token:1,suggestion:"{{DATE:}}",cursorOffset:2},{regex:H2,token:0,suggestion:xm},{regex:e2,token:10,suggestion:Y2},{regex:u2,token:4,suggestion:Um},{regex:n2,token:3,suggestion:Ob},{regex:s2,token:9,suggestion:V2},{regex:y2,token:11,suggestion:a2},{regex:w2,token:5,suggestion:"{{VALUE:}}",cursorOffset:2},{regex:v2,token:2,suggestion:"{{VDATE:}}",cursorOffset:2}];this.contextualTokens=[{regex:t2,token:6,suggestion:h2},{regex:E2,token:8,suggestion:"{{TEMPLATE:"},{regex:J2,token:7,suggestion:"{{MACRO:"}];this.macroNames=this.plugin.settings.macros.map(W=>W.name),this.templatePaths=this.plugin.getTemplateFiles().map(W=>W.path)}async getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let b=this.inputEl.selectionStart,Z=G.lastIndexOf("{{",b-1);if(Z===-1)return[];let c=G.slice(Z,b);if(c.includes("}}"))return[];if(c.includes(":"))return[];let W=[],d=[...this.tokenDefinitions,...this.suggestForFileNames?[]:this.contextualTokens];for(let N of d){let m=N.regex.exec(c);m&&m.index+m[0].length===c.length&&(this.lastInput=m[0],this.lastInputType=N.token,this.lastInputStart=b-
Line truncated
|
||||
`).filter(Boolean).reduce((b,Z)=>{let[c,W,...d]=Z.split(" "),N=Number.parseInt(W,10);return d.forEach((m,Y)=>b[m]=N+Y),b},{});for(let[b,Z]of Object.entries(G)){let c=Wa.default.toByteArray(b);this.rankMap.set(c.join(","),Z),this.textMap.set(Z,c)}this.specialTokens={...l.special_tokens,...I},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((b,[Z,c])=>(b[c]=this.textEncoder.encode(Z),b),{})}encode(l,I=[],G="all"){let b=new RegExp(this.patStr,"ug"),Z=hY.specialTokenRegex(Object.keys(this.specialTokens)),c=[],W=new Set(I==="all"?Object.keys(this.specialTokens):I),d=new Set(G==="all"?Object.keys(this.specialTokens).filter(m=>!W.has(m)):G);if(d.size>0){let m=hY.specialTokenRegex([...d]),Y=l.match(m);if(Y!=null)throw new Error(`The text contains a special token that is not allowed: ${Y[0]}`)}let N=0;for(;;){let m=null,Y=N;for(;Z.lastIndex=Y,m=Z.exec(l),!(m==null||W.has(m[0]));)Y=m.index+1;let V=m?.index??l.length;for(let a of l.substring(N,V).matchAll(b)){let X=this.textEncoder.encode(a[0]),H=this.rankMap.get(X.join(","));if(H!=null){c.push(H);continue}c.push(...xH(X,this.rankMap))}if(m==null)break;let h=this.specialTokens[m[0]];c.push(h),N=m.index+m[0].length}return c}decode(l){let I=[],G=0;for(let c=0;c<l.length;++c){let W=l[c],d=this.textMap.get(W)??this.inverseSpecialTokens[W];d!=null&&(I.push(d),G+=d.length)}let b=new Uint8Array(G),Z=0;for(let c of I)b.set(c,Z),Z+=c.length;return this.textDecoder.decode(b)}},Kl=hY;iH(Kl,"specialTokenRegex",l=>new RegExp(l.map(I=>UH(I)).join("|"),"g"));function aY(l){switch(l){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":return"o200k_base";default:throw new Error("Unknown model")}}var BH={explicit_n_vocab:50257,pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256},bpe_ranks:"! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ==
Line truncated
|
||||
! 50257 ICA= ICAg ICAgIA== ICAgICA= ICAgICAg ICAgICAgIA== ICAgICAgICA= ICAgICAgICAg ICAgICAgICAgIA== ICAgICAgICAgICA= ICAgICAgICAgICAg ICAgICAgICAgICAgIA== ICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIA==`},OH={pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256,"<|fim_prefix|>":50281,"<|fim_middle|>":50282,"<|fim_suffix|>":50283},bpe_ranks:`! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ== yg== yw== zA== zQ== zg== zw== 0A== 0Q== 0g== 0w== 1A== 1Q== 1g== 1w== 2A== 2Q== 2g== 2w== 3A== 3Q== 3g== 3w== 4A== 4Q== 4g== 4w== 5A== 5Q== 5g== 5w== 6A== 6Q== 6g== 6w== 7A== 7Q== 7g== 7w== 8A== 8Q== 8g== 8w== 9A== 9Q== 9g== 9w== +A== +Q== +g== +w== /A== /Q== /g== /w== AA== AQ== Ag== Aw== BA== BQ== Bg== Bw== CA== CQ== Cg== Cw== DA== DQ== Dg== Dw== EA== EQ== Eg== Ew== FA== FQ== Fg== Fw== GA== GQ== Gg== Gw== HA== HQ== Hg== Hw== IA== fw== gA== gQ== gg== gw== hA== hQ== hg== hw== iA== iQ== ig== iw== jA== jQ== jg== jw== kA== kQ== kg== kw== lA== lQ== lg== lw== mA== mQ== mg== mw== nA== nQ== ng== nw== oA== rQ== IHQ= IGE= aGU= aW4= cmU= b24= IHRoZQ== ZXI= IHM= YXQ= IHc= IG8= ZW4= IGM= aXQ= aXM= YW4= b3I= ZXM= IGI= ZWQ= IGY= aW5n IHA= b3U= IGFu YWw= YXI= IHRv IG0= IG9m IGlu IGQ= IGg= IGFuZA== aWM= YXM= bGU= IHRo aW9u b20= bGw= ZW50 IG4= IGw= c3Q= IHJl dmU= IGU= cm8= bHk= IGJl IGc= IFQ= Y3Q= IFM= aWQ= b3Q= IEk= dXQ= ZXQ= IEE= IGlz IG9u aW0= YW0= b3c= YXk= YWQ= c2U= IHRoYXQ= IEM= aWc= IGZvcg== YWM= IHk= dmVy dXI= IHU= bGQ= IHN0 IE0= J3M= IGhl IGl0 YXRpb24= aXRo aXI= Y2U= IHlvdQ== aWw= IEI= IHdo b2w= IFA= IHdpdGg= IDE= dGVy Y2g= IGFz IHdl ICg= bmQ= aWxs IEQ= aWY= IDI= YWc= ZXJz a2U= ICI= IEg= ZW0= IGNvbg== IFc= IFI= aGVy IHdhcw== IHI= b2Q= IEY= dWw= YXRl IGF0 cmk= cHA= b3Jl IFRoZQ== IHNl dXM= IHBybw== IGhh dW0= IGFyZQ== IGRl YWlu YW5k IG9y aWdo ZXN0 aXN0 YWI= cm9t IE4= dGg= IGNvbQ== IEc= dW4= b3A= MDA= IEw= IG5vdA== ZXNz IGV4 IHY= cmVz IEU= ZXc= aXR5 YW50 IGJ5 ZWw= b3M= b3J0 b2M= cXU= IGZyb20= IGhhdmU= IHN1 aXZl b3VsZA== IHNo IHRoaXM= bnQ= cmE= cGU= aWdodA== YXJ0 bWVudA== IGFs dXN0 ZW5k LS0= YWxs IE8= YWNr IGNo IGxl aWVz cmVk YXJk 4oA= b3V0 IEo= IGFi ZWFy aXY= YWxseQ== b3Vy b3N0 Z2g= cHQ= IHBs YXN0 IGNhbg== YWs= b21l dWQ= VGhl IGhpcw== IGRv IGdv IGhhcw== Z2U= J3Q= IFU= cm91 IHNh IGo= IGJ1dA== IHdvcg== IGFsbA== ZWN0 IGs= YW1l IHdpbGw= b2s= IHdoZQ== IHRoZXk= aWRl MDE= ZmY= aWNo cGw= dGhlcg== IHRy Li4= IGludA== aWU= dXJl YWdl IG5l aWFs YXA= aW5l aWNl IG1l IG91dA== YW5z b25l b25n aW9ucw== IHdobw== IEs= IHVw IHRoZWly IGFk IDM= IHVz YXRlZA== b3Vz IG1vcmU= dWU= b2c= IFN0 aW5k aWtl IHNv aW1l cGVy LiI= YmVy aXo= YWN0 IG9uZQ== IHNhaWQ= IC0= YXJl IHlvdXI= Y2M= IFRo IGNs ZXA= YWtl YWJsZQ== aXA= IGNvbnQ= IHdoaWNo aWE= IGlt IGFib3V0 IHdlcmU= dmVyeQ== dWI= IGhhZA== IGVu IGNvbXA= LCI= IElu IHVu IGFn aXJl YWNl YXU= YXJ5 IHdvdWxk YXNz cnk= IOKA Y2w= b29r ZXJl c28= IFY= aWdu aWI= IG9mZg== IHRl dmVu IFk= aWxl b3Nl aXRl b3Jt IDIwMQ== IHJlcw== IG1hbg== IHBlcg== IG90aGVy b3Jk dWx0 IGJlZW4= IGxpa2U= YXNl YW5jZQ== a3M= YXlz b3du ZW5jZQ== IGRpcw== Y3Rpb24= IGFueQ== IGFwcA== IHNw aW50 cmVzcw== YXRpb25z YWls IDQ= aWNhbA== IHRoZW0= IGhlcg== b3VudA== IENo IGFy IGlm IHRoZXJl IHBl IHllYXI= YXY= IG15 IHNvbWU= IHdoZW4= b3VnaA== YWNo IHRoYW4= cnU= b25k aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vLine truncated
|
||||
! 50257 ICA= ICAg ICAgIA== ICAgICA= ICAgICAg ICAgICAgIA== ICAgICAgICA= ICAgICAgICAg ICAgICAgICAgIA== ICAgICAgICAgICA= ICAgICAgICAgICAg ICAgICAgICAgICAgIA== ICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIA== ICAgICAgICAgICAgICAgICAgICAgICA= ICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIA==`},MH={explicit_n_vocab:50257,pat_str:"'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+",special_tokens:{"<|endoftext|>":50256},bpe_ranks:"! 0 IQ== Ig== Iw== JA== JQ== Jg== Jw== KA== KQ== Kg== Kw== LA== LQ== Lg== Lw== MA== MQ== Mg== Mw== NA== NQ== Ng== Nw== OA== OQ== Og== Ow== PA== PQ== Pg== Pw== QA== QQ== Qg== Qw== RA== RQ== Rg== Rw== SA== SQ== Sg== Sw== TA== TQ== Tg== Tw== UA== UQ== Ug== Uw== VA== VQ== Vg== Vw== WA== WQ== Wg== Ww== XA== XQ== Xg== Xw== YA== YQ== Yg== Yw== ZA== ZQ== Zg== Zw== aA== aQ== ag== aw== bA== bQ== bg== bw== cA== cQ== cg== cw== dA== dQ== dg== dw== eA== eQ== eg== ew== fA== fQ== fg== oQ== og== ow== pA== pQ== pg== pw== qA== qQ== qg== qw== rA== rg== rw== sA== sQ== sg== sw== tA== tQ== tg== tw== uA== uQ== ug== uw== vA== vQ== vg== vw== wA== wQ== wg== ww== xA== xQ== xg== xw== yA== yQ== yg== yw== zA== zQ== zg== zw== 0A== 0Q== 0g== 0w== 1A== 1Q== 1g== 1w== 2A== 2Q== 2g== 2w== 3A== 3Q== 3g== 3w== 4A== 4Q== 4g== 4w== 5A== 5Q== 5g== 5w== 6A== 6Q== 6g== 6w== 7A== 7Q== 7g== 7w== 8A== 8Q== 8g== 8w== 9A== 9Q== 9g== 9w== +A== +Q== +g== +w== /A== /Q== /g== /w== AA== AQ== Ag== Aw== BA== BQ== Bg== Bw== CA== CQ== Cg== Cw== DA== DQ== Dg== Dw== EA== EQ== Eg== Ew== FA== FQ== Fg== Fw== GA== GQ== Gg== Gw== HA== HQ== Hg== Hw== IA== fw== gA== gQ== gg== gw== hA== hQ== hg== hw== iA== iQ== ig== iw== jA== jQ== jg== jw== kA== kQ== kg== kw== lA== lQ== lg== lw== mA== mQ== mg== mw== nA== nQ== ng== nw== oA== rQ== IHQ= IGE= aGU= aW4= cmU= b24= IHRoZQ== ZXI= IHM= YXQ= IHc= IG8= ZW4= IGM= aXQ= aXM= YW4= b3I= ZXM= IGI= ZWQ= IGY= aW5n IHA= b3U= IGFu YWw= YXI= IHRv IG0= IG9m IGlu IGQ= IGg= IGFuZA== aWM= YXM= bGU= IHRo aW9u b20= bGw= ZW50 IG4= IGw= c3Q= IHJl dmU= IGU= cm8= bHk= IGJl IGc= IFQ= Y3Q= IFM= aWQ= b3Q= IEk= dXQ= ZXQ= IEE= IGlz IG9u aW0= YW0= b3c= YXk= YWQ= c2U= IHRoYXQ= IEM= aWc= IGZvcg== YWM= IHk= dmVy dXI= IHU= bGQ= IHN0 IE0= J3M= IGhl IGl0 YXRpb24= aXRo aXI= Y2U= IHlvdQ== aWw= IEI= IHdo b2w= IFA= IHdpdGg= IDE= dGVy Y2g= IGFz IHdl ICg= bmQ= aWxs IEQ= aWY= IDI= YWc= ZXJz a2U= ICI= IEg= ZW0= IGNvbg== IFc= IFI= aGVy IHdhcw== IHI= b2Q= IEY= dWw= YXRl IGF0 cmk= cHA= b3Jl IFRoZQ== IHNl dXM= IHBybw== IGhh dW0= IGFyZQ== IGRl YWlu YW5k IG9y aWdo ZXN0 aXN0 YWI= cm9t IE4= dGg= IGNvbQ== IEc= dW4= b3A= MDA= IEw= IG5vdA== ZXNz IGV4 IHY= cmVz IEU= ZXc= aXR5 YW50 IGJ5 ZWw= b3M= b3J0 b2M= cXU= IGZyb20= IGhhdmU= IHN1 aXZl b3VsZA== IHNo IHRoaXM= bnQ= cmE= cGU= aWdodA== YXJ0 bWVudA== IGFs dXN0 ZW5k LS0= YWxs IE8= YWNr IGNo IGxl aWVz cmVk YXJk 4oA= b3V0 IEo= IGFi ZWFy aXY= YWxseQ== b3Vy b3N0 Z2g= cHQ= IHBs YXN0 IGNhbg== YWs= b21l dWQ= VGhl IGhpcw== IGRv IGdv IGhhcw== Z2U= J3Q= IFU= cm91 IHNh IGo= IGJ1dA== IHdvcg== IGFsbA== ZWN0 IGs= YW1l IHdpbGw= b2s= IHdoZQ== IHRoZXk= aWRl MDE= ZmY= aWNo cGw= dGhlcg== IHRy Li4= IGludA== aWU= dXJl YWdl IG5l aWFs YXA= aW5l aWNl IG1l IG91dA== YW5z b25l b25n aW9ucw== IHdobw== IEs= IHVw IHRoZWly IGFk IDM= IHVz YXRlZA== b3Vz IG1vcmU= dWU= b2c= IFN0 aW5k aWtl IHNv aW1l cGVy LiI= YmVy aXo= YWN0 IG9uZQ== IHNhaWQ= IC0= YXJl IHlvdXI= Y2M= IFRo IGNs ZXA= YWtl YWJsZQ== aXA= IGNvbnQ= IHdoaWNo aWE= IGlt IGFib3V0 IHdlcmU= dmVyeQ== dWI= IGhhZA== IGVu IGNvbXA= LCI= IElu IHVu IGFn aXJl YWNl YXU= YXJ5 IHdvdWxk YXNz cnk= IOKA Y2w= b29r ZXJl c28= IFY= aWdu aWI= IG9mZg== IHRl dmVu IFk= aWxl b3Nl aXRl b3Jt IDIwMQ== IHJlcw== IG1hbg== IHBlcg== IG90aGVy b3Jk dWx0 IGJlZW4= IGxpa2U= YXNl YW5jZQ== a3M= YXlz b3du ZW5jZQ== IGRpcw== Y3Rpb24= IGFueQ== IGFwcA== IHNw aW50 cmVzcw== YXRpb25z YWls IDQ= aWNhbA== IHRoZW0= IGhlcg== b3VudA== IENo IGFy IGlm IHRoZXJl IHBl IHllYXI= YXY= IG15 IHNvbWU= IHdoZW4= b3VnaA== YWNo IHRoYW4= cnU= b25k aWNr IG92ZXI= dmVs IHF1 Cgo= IHNj cmVhdA== cmVl IEl0 b3VuZA== cG9ydA== IGFsc28= IHBhcnQ= ZnRlcg== IGtu IGJlYw== IHRpbWU= ZW5z IDU= b3BsZQ== IHdoYXQ= IG5v ZHU= bWVy YW5n IG5ldw== LS0tLQ== IGdldA== b3J5 aXRpb24= aW5ncw== IGp1c3Q= IGludG8= IDA= ZW50cw== b3Zl dGU= IHBlb3BsZQ== IHByZQ== IGl0cw== IHJlYw== IHR3 aWFu aXJzdA== YXJr b3Jz IHdvcms= YWRl b2I= IHNoZQ== IG91cg== d24= aW5r bGlj IDE5 IEhl aXNo bmRlcg== YXVzZQ== IGhpbQ== b25z IFs= IHJv Zm9ybQ== aWxk YXRlcw== dmVycw== IG9ubHk= b2xs IHNwZQ== Y2s= ZWxs YW1w IGFjYw== IGJs aW91cw== dXJu ZnQ= b29k IGhvdw== aGVk ICc= IGFmdGVy YXc= IGF0dA== b3Y= bmU= IHBsYXk= ZXJ2 aWN0 IGNvdWxk aXR0 IGFt IGZpcnN0 IDY= IGFjdA== ICQ= ZWM= aGluZw== dWFs dWxs IGNvbW0= b3k= b2xk Y2Vz YXRlcg== IGZl IGJldA== d2U= aWZm IHR3bw== b2Nr IGJhY2s= KS4= aWRlbnQ= IHVuZGVy cm91Z2g= c2Vs eHQ= IG1heQ== cm91bmQ= IHBv cGg= aXNz IGRlcw== IG1vc3Q= IGRpZA== IGFkZA== amVjdA== IGluYw== Zm9yZ
Line truncated
|
||||
|
||||
${I}`:""}`;function bd(G){if(G){let I=new TV.Notice(jV("starting",""),1e6);return{setMessage:(l,c)=>{I.setMessage(jV(l,c))},hide:()=>I.hide()}}return{setMessage:(I,l)=>{B.logMessage(`(${I}) ${l}`)},hide:()=>{}}}var Ll=(G,I)=>{let l=I.name==="gpt-3.5-turbo-16k"?"gpt-3.5-turbo":I.name;l=l==="gpt-4-1106-preview"?"gpt-4":l,l=l==="gpt-3.5-turbo-1106"?"gpt-3.5-turbo":l;try{return BV(l).encode(G).length}catch{return A3("cl100k_base").encode(G).length}};async function xY(G,I,l){if(typeof G!="function")throw new TypeError("Callback must be a function.");if(!(I instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof l!="number"||l<=0)throw new TypeError("Interval must be a positive number.");let c=!1;for(I.finally(()=>{c=!0});!c;)G(),await sleep(l)}async function kY(G,I,l){let c;if(I.enable)c=l.find(W=>W.path.endsWith(I.name));else{let W=l.map(a=>a.basename);c=await cl.Suggest(G,W,l)}Bl(c,"Prompt template does not exist");let b=c.path,Z=G.vault.getAbstractFileByPath(b);Bl(Z instanceof CV.TFile,`${b} is not a file`);let d=await G.vault.cachedRead(Z);return[c.basename,d]}async function SV(G,I,l){if(C.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let c=bd(I.showAssistantMessages);try{let{apiKey:b,model:Z,outputVariableName:d,promptTemplate:W,systemPrompt:a,promptTemplateFolder:m}=I,V=m1(G,m),[N,h]=await kY(G,W,V);c.setMessage("waiting","QuickAdd is formatting the prompt template.");let F=await l(h),R=["prompting",`Using prompt template "${N}".`];c.setMessage(R[0],R[1]);let E=Gd(G,b,Z,a,I.modelOptions)(F),J=(await x3(E,100,t=>{c.setMessage(R[0],`${R[1]} (${(t/1e3).toFixed(2)}s)`)},t=>{c.setMessage("finished",`Took ${(t/1e3).toFixed(2)}s.`)})).content,i=("> "+J).replace(/\n/g,`
|
||||
> `),Y={[d]:J,[`${d}-quoted`]:i};return setTimeout(()=>c.hide(),5e3),Y}catch(b){c.setMessage("dead",b.message),setTimeout(()=>c.hide(),5e3)}}async function x3(G,I,l,c){let b=Date.now();return await xY(()=>l(Date.now()-b),G,I),c(Date.now()-b),await G}async function DV(G,I,l){if(C.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let c=bd(I.showAssistantMessages);try{let{apiKey:b,model:Z,outputVariableName:d,systemPrompt:W,prompt:a,modelOptions:m}=I;c.setMessage("waiting","QuickAdd is formatting the prompt template.");let V=await l(a),N=["prompting","Using custom prompt."];c.setMessage(N[0],N[1]);let F=Gd(G,b,Z,W,m)(V),X=(await x3(F,100,J=>{c.setMessage(N[0],`${N[1]} (${(J/1e3).toFixed(2)}s)`)},J=>{c.setMessage("finished",`Took ${(J/1e3).toFixed(2)}s.`)})).content,E=("> "+X).replace(/\n/g,`
|
||||
> `),s={[d]:X,[`${d}-quoted`]:E};return setTimeout(()=>c.hide(),5e3),s}catch(b){c.setMessage("dead",b.message),setTimeout(()=>c.hide(),5e3)}}var z3=class{constructor(I,l){this.maxRequests=I;this.intervalMs=l;this.queue=[];this.pendingPromises=[]}add(I){return new Promise((l,c)=>{this.queue.push(async()=>{try{l(await I())}catch(b){c(b)}}),this.schedule()})}schedule(){if(this.queue.length===0||this.pendingPromises.length>=this.maxRequests)return;let I=this.queue.shift();if(!I)return;let l=I();this.pendingPromises.push(l),l.finally(()=>{this.pendingPromises=this.pendingPromises.filter(c=>c!==l),this.schedule()}),setTimeout(()=>this.schedule(),this.intervalMs)}};async function KV(G,I,l){if(C.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let c=bd(I.showAssistantMessages);try{let{apiKey:b,model:Z,outputVariableName:d,systemPrompt:W,promptTemplate:a,text:m,modelOptions:V}=I;c.setMessage("chunking","Creating prompt chunks with text and prompt template");let N=I.chunkSeparator||/\n/g,h=m.split(N),F=Ll(W,Z),R=await l(a,{chunk:" "}),X=Ll(R,Z),E=fV(Z.name)/2-F,s=I.shouldMerge??!0,J=[],i=E-X;if(s){let cI=[],dI="",YI=0;for(let hI of h){let uI=Ll(hI,Z)+1;if(uI>i)throw new Error(`The chunk "${hI.slice(0,25)}..." is too large to fit in a single prompt.`);YI+uI<i?(dI+=hI,YI+=uI):(cI.push(dI),dI=hI,YI=uI)}dI!==""&&cI.push(dI);for(let hI of cI){let uI=await l(a,{chunk:hI});J.push(uI)}}else for(let cI of h){let dI=Ll(cI,Z);if(dI>E)throw new Error(`Chunk size (${dI}) is larger than the maximum chunk size (${E}). Please check your chunk separator.`);let YI=await l(a,{chunk:cI});J.push(YI)}let Y=Gd(G,b,Z,W,V),t=["prompting",`${J.length} prompts being sent.`];c.setMessage(t[0],t[1]);let Q=new z3(5,1e3*30),e=Promise.all(J.map(cI=>Q.add(()=>Y(cI)))),T=(await x3(e,100,cI=>{c.setMessage(t[0],`${t[1]} (${(cI/1e3).toFixed(2)}s)`)},cI=>{c.setMessage("finished",`Took ${(cI/1e3).toFixed(2)}s.`)})).map(cI=>cI.content).join(I.resultJoiner),bI=("> "+T).replace(/\n/g,`
|
||||
> `),y={[d]:T,[`${d}-quoted`]:bI};return setTimeout(()=>c.hide(),5e3),y}catch(b){c.setMessage("dead",b.message),setTimeout(()=>c.hide(),5e3)}}var Zd=class{static filterFiles(I,l,c){return Object.keys(l).length===0?I:I.filter(b=>!(l.folder&&!this.matchesFolder(b,l.folder)||l.tags&&l.tags.length>0&&!this.matchesTags(b,l.tags,c)))}static matchesFolder(I,l){let c=this.normalizePath(l),b=this.normalizePath(I.path);return b.startsWith(c+"/")||b.substring(0,b.lastIndexOf("/"))===c}static matchesTags(I,l,c){let b=c(I);if(!b||!b.tags)return!1;let Z=b.tags.map(d=>d.tag.startsWith("#")?d.tag.substring(1):d.tag);return l.every(d=>Z.includes(d))}static normalizePath(I){return I.replace(/^\/+|\/+$/g,"")}};var dd=class{static parseInlineFields(I){let l=new Map,c=this.removeCodeBlocksAndFrontmatter(I),b;for(;(b=dd.INLINE_FIELD_REGEX.exec(c))!==null;){let Z=b[1].trim(),d=b[2].trim();d&&(l.has(Z)||l.set(Z,new Set),d.includes(",")?d.split(",").map(a=>a.trim()).filter(a=>a.length>0).forEach(a=>l.get(Z)?.add(a)):l.get(Z)?.add(d))}return dd.INLINE_FIELD_REGEX.lastIndex=0,l}static removeCodeBlocksAndFrontmatter(I){let l=/^---\n[\s\S]*?\n---\n/;I=I.replace(l,"");let c=/```[\s\S]*?```|`[^`]*`/g;return I=I.replace(c,""),I}static getFieldValues(I,l){return this.parseInlineFields(I).get(l)||new Set}},mG=dd;mG.INLINE_FIELD_REGEX=/(?:^|[\n\r])[ \t]*(?![-*+][ \t]+\[[ xX]\])([a-zA-Z0-9_\- ]+)::[ \t]*(.*)$/gm;var il=class{constructor(){this.cache=new Map;this.TTL=5*60*1e3;this.MAX_CACHE_ENTRIES=100;this.MAX_VALUES_PER_ENTRY=1e3;this.cleanupInterval=null}static getInstance(){return il.instance||(il.instance=new il),il.instance}startAutomaticCleanup(I){if(this.cleanupInterval===null&&typeof window<"u"){let l=window.setInterval(()=>{this.cleanExpired()},6e4);this.cleanupInterval=I(l)}}get(I,l){let c=this.makeKey(I,l),b=this.cache.get(c);return b?Date.now()-b.timestamp>this.TTL?(this.cache.delete(c),null):new Set(b.values):null}set(I,l,c){let b=this.makeKey(I,c),Z=new Set,d=0;for(let W of l){if(d>=this.MAX_VALUES_PER_ENTRY)break;Z.add(W),d++}this.cache.size>=this.MAX_CACHE_ENTRIES&&!this.cache.has(b)&&this.evictOldestEntries(1),this.cache.set(b,{values:Z,timestamp:Date.now()})}evictOldestEntries(I){let l=Array.from(this.cache.entries()).sort(([,c],[,b])=>c.timestamp-b.timestamp).slice(0,I);for(let[c]of l)this.cache.delete(c)}clear(I){if(I){let l=[];for(let c of this.cache.keys())(c.startsWith(`${I}:`)||c===I)&&l.push(c);for(let c of l)this.cache.delete(c)}else this.cache.clear()}cleanExpired(){let I=Date.now(),l=[];for(let[c,b]of this.cache.entries())I-b.timestamp>this.TTL&&l.push(c);for(let c of l)this.cache.delete(c)}getStats(){return{size:this.cache.size,maxSize:this.MAX_CACHE_ENTRIES,cleanupInterval:this.cleanupInterval}}destroy(){this.cleanupInterval=null,this.cache.clear()}makeKey(I,l){return l?`${I}:${l}`:I}};var H1=class{static GetApi(I,l,c){return{inputPrompt:(b,Z,d)=>this.inputPrompt(I,b,Z,d),wideInputPrompt:(b,Z,d)=>this.wideInputPrompt(I,b,Z,d),yesNoPrompt:(b,Z)=>this.yesNoPrompt(I,b,Z),infoDialog:(b,Z)=>this.infoDialog(I,b,Z),suggester:(b,Z)=>this.suggester(I,b,Z),checkboxPrompt:(b,Z)=>this.checkboxPrompt(I,b,Z),executeChoice:async(b,Z)=>{let d=l.getChoiceByName(b);d||EI(new Error(`Choice named '${b}' not found`),"API executeChoice error"),Z&&Object.keys(Z).forEach(W=>{c.variables.set(W,Z[W])}),await c.execute(d),c.variables.clear()},format:async(b,Z,d=!0)=>{Z&&Object.keys(Z).forEach(a=>{c.variables.set(a,Z[a])});let W=await new U2(I,l,c).formatFileContent(b);return d&&c.variables.clear(),W},ai:{prompt:async(b,Z,d)=>{let W=C.getState(),a=W.ai;if(W.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let m=this.GetApi(I,l,c).format,V;if(typeof Z=="string"){let F=X2(Z);if(!F)throw new Error(`Model '${Z}' not found.`);V=F}else V=Z;let N=aG(V.name);if(!N)throw new Error(`Model '${V.name}' not found in any provider`);let h=await DV(I,{model:V,prompt:b,apiKey:N.apiKey,modelOptions:d?.modelOptions??{},outputVariableName:d?.variableName??"output",showAssistantMessages:d?.showAssistantMessages??!0,systemPrompt:d?.systemPrompt??a.defaultSystemPrompt},(F,R)=>m(F,R,!1));return h?(d?.shouldAssignVariables&&Object.assign(c.variables,h),h):(EI(new Error("AI Assistant returned null"),"AI Prompt error"),{})},chunkedPrompt:async(b,Z,d,W,a)=>{let m=C.getState(),V=m.ai;if(m.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let N=this.GetApi(I,l,c).format,h;if(typeof d=="string"){let X=X2(d);if(!X)throw new Error(`Model ${d} not found.`);h=X}else h=d;let F=aG(h.name);if(!F)throw new Error(`Model '${h.name}' not found in any provider`);let R=await KV(I,{model:h,text:b,promptTemplate:Z,chunkSeparator:W?.chunkSeparator??/\n/,apiKey:F.apiKey,modelOptions:W?.modelOptions??{},outputVariableName:W?.variableName??"output",showAssistantMessages:W?.showAssistantMessages??!0,systemPrompt:W?.systemPromptLine truncated
|
||||
`,shouldMerge:W?.shouldMerge??!0},(X,E)=>{let s={...a,...E};return N(X,s,!1)});return R?(W?.shouldAssignVariables&&Object.assign(c.variables,R),R):(EI(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>k2(),getMaxTokens:b=>{let Z=X2(b);if(!Z)throw new Error(`Model ${b} not found.`);return Z.maxTokens},countTokens(b,Z){return Ll(b,Z)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async b=>await navigator.clipboard.writeText(b),getSelectedText:()=>{let b=I.workspace.getActiveViewOfType(OV.MarkdownView);if(!b){EI(new Error("No active view"),"Could not get selected text");return}if(!b.editor.somethingSelected()){EI(new Error("No text selected"),"Could not get selected text");return}return b.editor.getSelection()}},date:{now:(b,Z)=>cc({format:b,offset:Z}),tomorrow:b=>cc({format:b,offset:1}),yesterday:b=>cc({format:b,offset:-1})},fieldSuggestions:{getFieldValues:async(b,Z)=>{let d={folder:Z?.folder,tags:Z?.tags,inline:Z?.includeInline??!1},W=I.vault.getMarkdownFiles();W=Zd.filterFiles(W,d,m=>I.metadataCache.getFileCache(m));let a=new Set;for(let m of W){let N=I.metadataCache.getFileCache(m)?.frontmatter?.[b];if(N!=null){if(Array.isArray(N))N.forEach(h=>{let F=h.toString().trim();F&&a.add(F)});else if(typeof N!="object"){let h=N.toString().trim();h&&a.add(h)}}if(d.inline){let h=await I.vault.read(m);mG.getFieldValues(h,b).forEach(R=>a.add(R))}}return Array.from(a).sort()},clearCache:b=>{il.getInstance().clear(b)}}}}static async inputPrompt(I,l,c,b){try{return await vI.Prompt(I,l,c,b)}catch{return}}static async wideInputPrompt(I,l,c,b){try{return await Gc.Prompt(I,l,c,b)}catch{return}}static async yesNoPrompt(I,l,c){try{return await wl.Prompt(I,l,c)}catch{return}}static async infoDialog(I,l,c){try{return await ZG.Show(I,l,c)}catch{return}}static async suggester(I,l,c){try{let b;return typeof l=="function"?b=c.map(l):b=l,await cl.Suggest(I,b,c)}catch{return}}static async checkboxPrompt(I,l,c){try{return await dG.Open(I,l,c)}catch{return}}};var R1=class extends h1{};var sl=class{constructor(I,l){this.name=I,this.type=l,this.id=O2()}};var PV=require("obsidian");var Gl=class extends sl{constructor(l){super(l,"EditorCommand");this.editorCommandType=l}static getSelectedText(l){return this.getActiveMarkdownView(l).editor.getSelection()}static getActiveMarkdownView(l){let c=l.workspace.getActiveViewOfType(PV.MarkdownView);if(!c)throw B.logError("no active markdown view."),new Error("no active markdown view.");return c}};var n1=class extends Gl{constructor(){super("Cut")}static async run(I){let l=Gl.getSelectedText(I),c=Gl.getActiveMarkdownView(I);if(!l){B.logError("nothing selected.");return}await navigator.clipboard.writeText(l),c.editor.replaceSelection("")}};var p1=class extends Gl{constructor(){super("Copy")}static async run(I){let l=Gl.getSelectedText(I);await navigator.clipboard.writeText(l)}};var s1=class extends Gl{constructor(){super("Paste")}static async run(I){let l=await navigator.clipboard.readText(),c=Gl.getActiveMarkdownView(I);if(!c){B.logError("no active markdown view.");return}c.editor.replaceSelection(l)}};var e1=class extends Gl{constructor(){super("Select active line")}static run(I){let l=Gl.getActiveMarkdownView(I),{line:c}=l.editor.getCursor(),Z=l.editor.getLine(c).length;l.editor.setSelection({line:c,ch:0},{line:c,ch:Z})}};var t1=class extends Gl{constructor(){super("Select link on active line")}static run(I){let l=Gl.getActiveMarkdownView(I),{line:c}=l.editor.getCursor(),b=l.editor.getLine(c),Z=mV.exec(b);if(!Z){B.logError(`no internal link found on line ${c}.`);return}let d=Z.index,W=Z[0].length+d;l.editor.setSelection({line:c,ch:d},{line:c,ch:W})}};function qV(G){return new Promise(I=>setTimeout(I,G))}function k3(G){return G.split(`
|
||||
`)}function _V(G){return G.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}var M2=class extends R1{constructor(l,c,b,Z,d,W){super(l);this.choice=b,this.plugin=c,this.macros=Z,this.choiceExecutor=d,this.params={app:this.app,quickAddApi:H1.GetApi(l,c,d),variables:{},obsidian:UY},W?.forEach((a,m)=>{this.params.variables[m]=a})}async run(){let l=this.choice.macroId??this.choice?.macro?.id,c=this.macros.find(b=>b.id===l);if(!c||!c?.commands){B.logError(`No commands in the selected macro. Did you select a macro for '${this.choice.name}'?`);return}await this.executeCommands(c.commands)}async executeCommands(l){for(let c of l)c?.type==="Obsidian"&&this.executeObsidianCommand(c),c?.type==="UserScript"&&await this.executeUserScript(c),c?.type==="Choice"&&await this.executeChoice(c),c?.type==="Wait"&&await qV(c.time),c?.type==="NestedChoice"&&await this.executeNestedChoice(c),c?.type==="EditorCommand"&&await this.executeEditorCommand(c),c?.type==="AIAssistant"&&await this.executeAIAssistant(c),Object.keys(this.params.variables).forEach(b=>{this.choiceExecutor.variables.set(b,this.params.variables[b])})}async executeUserScript(l){let c=await SZ(l,this.app);if(!c){B.logError(`failed to load user script ${l.path}.`);return}c.settings&&(this.userScriptCommand=l);try{await this.userScriptDelegator(c)}catch(b){EI(b,`Failed to run user script ${l.name}`)}this.userScriptCommand&&(this.userScriptCommand=null)}async runScriptWithSettings(l,c){if(typeof l!="function"&&l.entry&&typeof l.entry=="function")return await this.onExportIsFunction(l.entry,c.settings);if(typeof l=="function")return await this.onExportIsFunction(l,c.settings)}async userScriptDelegator(l){switch(typeof l){case"function":this.userScriptCommand?await this.runScriptWithSettings(l,this.userScriptCommand):await this.onExportIsFunction(l);break;case"object":await this.onExportIsObject(l);break;case"bigint":case"boolean":case"number":case"string":this.output=l.toString();break;default:B.logError(`user script in macro for '${this.choice.name}' is invalid`)}}async onExportIsFunction(l,c){this.output=await l(this.params,c||{})}async onExportIsObject(l){if(Object.keys(l).length===0)throw new Error(`user script in macro for '${this.choice.name}' is an empty object`);if(this.userScriptCommand&&l.entry!==null){await this.runScriptWithSettings(l,this.userScriptCommand);return}try{let c=Object.keys(l),b=await cl.Suggest(this.app,c,c);await this.userScriptDelegator(l[b])}catch(c){EI(c,"Error in script object handling","LOG")}}executeObsidianCommand(l){this.app.commands.executeCommandById(l.commandId)}async executeChoice(l){let c=this.plugin.getChoiceById(l.choiceId);if(!c){B.logError("choice could not be found.");return}await this.choiceExecutor.execute(c)}async executeNestedChoice(l){let c=l.choice;if(!c){B.logError(`choice in ${l.name} is invalid`);return}await this.choiceExecutor.execute(c)}async executeEditorCommand(l){switch(l.editorCommandType){case"Cut":await n1.run(this.app);break;case"Copy":await p1.run(this.app);break;case"Paste":await s1.run(this.app);break;case"Select active line":e1.run(this.app);break;case"Select link on active line":t1.run(this.app);break}}async executeAIAssistant(l){if(C.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let c=C.getState().ai,b=k2(),Z=l.model==="Ask me"?await cl.Suggest(this.app,b,b):l.model,d=X2(Z);if(!d)throw new Error(`Model ${Z} not found with any provider.`);let W=new U2(this.app,nI.instance,this.choiceExecutor),a=aG(d.name);if(!a)throw new Error(`Model ${d.name} not found in the AI providers settings.`);let m=await SV(this.app,{apiKey:a.apiKey,model:d,outputVariableName:l.outputVariableName,promptTemplate:l.promptTemplate,promptTemplateFolder:c.promptTemplatesFolderPath,systemPrompt:l.systemPrompt,showAssistantMessages:c.showAssistant,modelOptions:l.modelParameters},async V=>W.formatFileContent(V));for(let V in m)this.choiceExecutor.variables.set(V,m[V])}};var Wd=class extends M2{constructor(l,c,b,Z,d){super(l,c,null,b,Z,d)}async runAndGetOutput(l){let{basename:c,memberAccess:b}=eb(l),Z=this.macros.find(d=>d.name===c);if(!Z)throw B.logError(`macro '${l}' does not exist.`),new Error(`macro '${l}' does not exist.`);return b&&b.length>0&&(this.memberAccess=b),await this.executeCommands(Z.commands),this.output}async onExportIsObject(l){if(!this.memberAccess)return await super.onExportIsObject(l);let c=l;this.memberAccess.forEach(b=>{c=c[b]}),await this.userScriptDelegator(c)}};var g5=require("obsidian");var ad=class extends M2{constructor(I,l,c,b){super(I,l,null,null,c,b)}async runAndGetOutput(I){let l=Object.getPrototypeOf(async function(){}).constructor;return await new l(I).bind(this.params,this).call()}};var rl=require("obsidian");var WI="\u261A",MY=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|",`^{${WI}}${WI}`,`[${WI}]${WI}`,"\\above","\\abovewithdelims","\\acute","\\aleph","\\alpha","\\amalg","\\And","\\angle","\\approx","\
Line truncated
|
||||
${WI}
|
||||
\\end{${G}}${WI}`}var $V=[...MY,...BY.map(LY)];var IN=require("obsidian");var fY=new RegExp(/\\([a-z{}A-Z0-9]*)$/),md=class extends yl{constructor(l){super(nI.instance.app,l);this.inputEl=l;this.lastInput="";this.symbols=Object.assign([],$V),this.elementsRendered=this.symbols.reduce((c,b)=>{try{c[b.toString()]=(0,IN.renderMath)(b,!0)}catch{}return c},{})}getSuggestions(l){if(this.inputEl.selectionStart===null)return[];let c=this.inputEl.selectionStart,b=l.substr(0,c),Z=b.lastIndexOf("\\"),d=b.substr(Z),W=fY.exec(d),a=[];return W&&(this.lastInput=W[1],a=this.symbols.filter(N=>N.toLowerCase().contains(this.lastInput))),new ol(a,{findAllMatches:!0,threshold:.8}).search(this.lastInput).map(N=>N.item)}renderSuggestion(l,c){l&&(c.setText(l),c.append(this.elementsRendered[l]))}selectSuggestion(l){if(this.inputEl.selectionStart===null)return;let c=this.inputEl.selectionStart,b=this.lastInput.length,Z=this.inputEl.value,d=0,W=l.replace(/\\\\/g,"\\");if(this.inputEl.value=`${Z.substr(0,c-b-1)}${W}${Z.substr(c)}`,d=c-b+l.length-1,this.inputEl.trigger("input"),this.close(),l.contains(WI)){let a=this.inputEl.value.indexOf(WI);this.inputEl.value=this.inputEl.value.replace(WI,""),this.inputEl.setSelectionRange(a,a)}else this.inputEl.setSelectionRange(d,d)}};var E1=class extends rl.Modal{constructor(){super(nI.instance.app);this.didSubmit=!1;this.keybindListener=l=>{l.ctrlKey&&l.key==="Enter"&&this.submit(),l.key==="Tab"&&(l.preventDefault(),this.cursorToGoTo())};this.submitClickCallback=l=>this.submit();this.cancelClickCallback=l=>this.cancel();this.open(),this.display(),this.waitForClose=new Promise((l,c)=>{this.resolvePromise=l,this.rejectPromise=c}),new md(this.inputEl),this.inputEl.focus(),this.inputEl.select()}static Prompt(){return new E1().waitForClose}display(){this.containerEl.addClass("quickAddModal","qaMathModal"),this.contentEl.empty();let l=this.contentEl.createDiv();l.className="math math-block is-loaded";let c=new rl.TextAreaComponent(this.contentEl);c.inputEl.style.width="100%",c.inputEl.style.height="10rem",this.inputEl=c.inputEl,c.onChange((0,rl.debounce)(async b=>await this.mathjaxLoop(l,b),50)),c.inputEl.addEventListener("keydown",this.keybindListener),this.createButtonBar(this.contentEl.createDiv())}async onOpen(){super.onOpen(),await(0,rl.loadMathJax)()}async mathjaxLoop(l,c){let b=(0,rl.renderMath)(c,!0);await(0,rl.finishRenderMath)(),l.empty(),l.append(b)}cursorToGoTo(){if(this.inputEl.value.contains(WI)){let l=this.inputEl.value.indexOf(WI);this.inputEl.value=this.inputEl.value.replace(WI,""),this.inputEl.setSelectionRange(l,l)}}createButton(l,c,b){let Z=new rl.ButtonComponent(l);return Z.setButtonText(c).onClick(b),Z}createButtonBar(l){let c=l.createDiv();this.createButton(c,"Ok",this.submitClickCallback).setCta().buttonEl.style.marginRight="0",this.createButton(c,"Cancel",this.cancelClickCallback),c.style.display="flex",c.style.flexDirection="row-reverse",c.style.justifyContent="flex-start",c.style.marginTop="1rem"}removeInputListeners(){this.inputEl.removeEventListener("keydown",this.keybindListener)}resolveInput(){let l=this.inputEl.value.replace("\\n","\\\\n").replace(new RegExp(WI,"g"),"");this.didSubmit?this.resolvePromise(l):this.rejectPromise("No input given.")}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListeners()}};var u1=class{factory(){return nI.instance.settings.inputPrompt==="multi-line"?Gc:vI}};var lN=require("obsidian"),B2=class extends lN.FuzzySuggestModal{constructor(l,c,b,Z={}){super(l);this.displayItems=c;this.items=b;this.promise=new Promise((d,W)=>{this.resolvePromise=d,this.rejectPromise=W}),this.inputEl.addEventListener("keydown",d=>{if(d.code!=="Tab"||!("chooser"in this))return;let{values:W,selectedItem:a}=this.chooser,{value:m}=this.inputEl;this.inputEl.value=W[a].item??m}),Z.placeholder&&this.setPlaceholder(Z.placeholder),Z.limit&&(this.limit=Z.limit),Z.emptyStateText&&(this.emptyStateText=Z.emptyStateText),this.open()}static Suggest(l,c,b,Z={}){return new B2(l,c,b,Z).promise}getItemText(l){return l===this.inputEl.value?l:this.displayItems[this.items.indexOf(l)]}getItems(){return this.inputEl.value===""?this.items:[this.inputEl.value,...this.items]}selectSuggestion(l,c){this.resolved=!0,super.selectSuggestion(l,c)}onChooseItem(l,c){this.resolved=!0,this.resolvePromise(l)}onClose(){super.onClose(),this.resolved||this.rejectPromise("no input given.")}};var Vd=class{static parse(I){let l=I.split("|").map(Z=>Z.trim()),c=l[0],b={};for(let Z=1;Z<l.length;Z++){let d=l[Z],W=d.indexOf(":");if(W===-1)continue;let a=d.substring(0,W).trim(),m=d.substring(W+1).trim();switch(a){case"folder":b.folder=m;break;case"tag":b.tags||(b.tags=[]);let V=m.startsWith("#")?m.substring(1):m;b.tags.push(V);break;case"inline":b.inline=m.toLowerCase()==="true";break;case"default":b.defaultValue=m;break;case"default-empty":b.defaultEmpty=m.toLowerCase()==="true";break;case"default-always":b.defaultAlways=m.toLowerCase()=
Line truncated
|
||||
${I}`:""}`;function Ud(l){if(l){let I=new Va.Notice(Ya("starting",""),1e6);return{setMessage:(G,b)=>{I.setMessage(Ya(G,b))},hide:()=>I.hide()}}return{setMessage:(I,G)=>{U.logMessage(`(${I}) ${G}`)},hide:()=>{}}}var gG=(l,I)=>{let G=I.name==="gpt-3.5-turbo-16k"?"gpt-3.5-turbo":I.name;G=G==="gpt-4-1106-preview"?"gpt-4":G,G=G==="gpt-3.5-turbo-1106"?"gpt-3.5-turbo":G;try{return da(G).encode(l).length}catch{return FY("cl100k_base").encode(l).length}};async function fH(l,I,G){if(typeof l!="function")throw new TypeError("Callback must be a function.");if(!(I instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof G!="number"||G<=0)throw new TypeError("Interval must be a positive number.");let b=!1;for(I.finally(()=>{b=!0});!b;)l(),await sleep(G)}async function PH(l,I,G){let b;if(I.enable)b=G.find(d=>d.path.endsWith(I.name));else{let d=G.map(N=>N.basename);b=await aG.Suggest(l,d,G)}CG(b,"Prompt template does not exist");let Z=b.path,c=l.vault.getAbstractFileByPath(Z);CG(c instanceof ha.TFile,`${Z} is not a file`);let W=await l.vault.cachedRead(c);return[b.basename,W]}async function aa(l,I,G){if(M.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let b=Ud(I.showAssistantMessages);try{let{apiKey:Z,model:c,outputVariableName:W,promptTemplate:d,systemPrompt:N,promptTemplateFolder:m}=I,Y=KZ(l,m),[V,h]=await PH(l,d,Y);b.setMessage("waiting","QuickAdd is formatting the prompt template.");let a=await G(h),X=["prompting",`Using prompt template "${V}".`];b.setMessage(X[0],X[1]);let w=xd(l,Z,c,N,I.modelOptions)(a),s=(await QY(w,100,n=>{b.setMessage(X[0],`${X[1]} (${(n/1e3).toFixed(2)}s)`)},n=>{b.setMessage("finished",`Took ${(n/1e3).toFixed(2)}s.`)})).content,C=("> "+s).replace(/\n/g,`
|
||||
> `),F={[W]:s,[`${W}-quoted`]:C};return setTimeout(()=>b.hide(),5e3),F}catch(Z){b.setMessage("dead",Z.message),setTimeout(()=>b.hide(),5e3)}}async function QY(l,I,G,b){let Z=Date.now();return await fH(()=>G(Date.now()-Z),l,I),b(Date.now()-Z),await l}async function Fa(l,I,G){if(M.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let b=Ud(I.showAssistantMessages);try{let{apiKey:Z,model:c,outputVariableName:W,systemPrompt:d,prompt:N,modelOptions:m}=I;b.setMessage("waiting","QuickAdd is formatting the prompt template.");let Y=await G(N),V=["prompting","Using custom prompt."];b.setMessage(V[0],V[1]);let a=xd(l,Z,c,d,m)(Y),H=(await QY(a,100,s=>{b.setMessage(V[0],`${V[1]} (${(s/1e3).toFixed(2)}s)`)},s=>{b.setMessage("finished",`Took ${(s/1e3).toFixed(2)}s.`)})).content,w=("> "+H).replace(/\n/g,`
|
||||
> `),u={[W]:H,[`${W}-quoted`]:w};return setTimeout(()=>b.hide(),5e3),u}catch(Z){b.setMessage("dead",Z.message),setTimeout(()=>b.hide(),5e3)}}var XY=class{constructor(I,G){this.maxRequests=I;this.intervalMs=G;this.queue=[];this.pendingPromises=[]}add(I){return new Promise((G,b)=>{this.queue.push(async()=>{try{G(await I())}catch(Z){b(Z)}}),this.schedule()})}schedule(){if(this.queue.length===0||this.pendingPromises.length>=this.maxRequests)return;let I=this.queue.shift();if(!I)return;let G=I();this.pendingPromises.push(G),G.finally(()=>{this.pendingPromises=this.pendingPromises.filter(b=>b!==G),this.schedule()}),setTimeout(()=>this.schedule(),this.intervalMs)}};async function Ra(l,I,G){if(M.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let b=Ud(I.showAssistantMessages);try{let{apiKey:Z,model:c,outputVariableName:W,systemPrompt:d,promptTemplate:N,text:m,modelOptions:Y}=I;b.setMessage("chunking","Creating prompt chunks with text and prompt template");let V=I.chunkSeparator||/\n/g,h=m.split(V),a=gG(d,c),X=await G(N,{chunk:" "}),H=gG(X,c),w=ma(c.name)/2-a,u=I.shouldMerge??!0,s=[],C=w-H;if(u){let GI=[],lI="",aI=0;for(let hI of h){let vI=gG(hI,c)+1;if(vI>C)throw new Error(`The chunk "${hI.slice(0,25)}..." is too large to fit in a single prompt.`);aI+vI<C?(lI+=hI,aI+=vI):(GI.push(lI),lI=hI,aI=vI)}lI!==""&&GI.push(lI);for(let hI of GI){let vI=await G(N,{chunk:hI});s.push(vI)}}else for(let GI of h){let lI=gG(GI,c);if(lI>w)throw new Error(`Chunk size (${lI}) is larger than the maximum chunk size (${w}). Please check your chunk separator.`);let aI=await G(N,{chunk:GI});s.push(aI)}let F=xd(l,Z,c,d,Y),n=["prompting",`${s.length} prompts being sent.`];b.setMessage(n[0],n[1]);let y=new XY(5,1e3*30),v=Promise.all(s.map(GI=>y.add(()=>F(GI)))),O=(await QY(v,100,GI=>{b.setMessage(n[0],`${n[1]} (${(GI/1e3).toFixed(2)}s)`)},GI=>{b.setMessage("finished",`Took ${(GI/1e3).toFixed(2)}s.`)})).map(GI=>GI.content).join(I.resultJoiner),S=("> "+O).replace(/\n/g,`
|
||||
> `),x={[W]:O,[`${W}-quoted`]:S};return setTimeout(()=>b.hide(),5e3),x}catch(Z){b.setMessage("dead",Z.message),setTimeout(()=>b.hide(),5e3)}}var Bd=class{static filterFiles(I,G,b){return Object.keys(G).length===0?I:I.filter(Z=>!(G.folder&&!this.matchesFolder(Z,G.folder)||G.tags&&G.tags.length>0&&!this.matchesTags(Z,G.tags,b)))}static matchesFolder(I,G){let b=this.normalizePath(G),Z=this.normalizePath(I.path);return Z.startsWith(b+"/")||Z.substring(0,Z.lastIndexOf("/"))===b}static matchesTags(I,G,b){let Z=b(I);if(!Z||!Z.tags)return!1;let c=Z.tags.map(W=>W.tag.startsWith("#")?W.tag.substring(1):W.tag);return G.every(W=>c.includes(W))}static normalizePath(I){return I.replace(/^\/+|\/+$/g,"")}};var cW=class cW{static parseInlineFields(I){let G=new Map,b=this.removeCodeBlocksAndFrontmatter(I),Z;for(;(Z=cW.INLINE_FIELD_REGEX.exec(b))!==null;){let c=Z[1].trim(),W=Z[2].trim();W&&(G.has(c)||G.set(c,new Set),W.includes(",")?W.split(",").map(N=>N.trim()).filter(N=>N.length>0).forEach(N=>G.get(c)?.add(N)):G.get(c)?.add(W))}return cW.INLINE_FIELD_REGEX.lastIndex=0,G}static removeCodeBlocksAndFrontmatter(I){let G=/^---\r?\n[\s\S]*?\r?\n---\r?\n/;I=I.replace(G,"");let b=/```[\s\S]*?```|`[^`]*`/g;return I=I.replace(b,""),I}static getFieldValues(I,G){return this.parseInlineFields(I).get(G)||new Set}};cW.INLINE_FIELD_REGEX=/(?:^|[\n\r])[ \t]*(?![-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu;var PZ=cW;var Dl=class l{constructor(){this.cache=new Map;this.TTL=5*60*1e3;this.MAX_CACHE_ENTRIES=100;this.MAX_VALUES_PER_ENTRY=1e3;this.cleanupInterval=null}static getInstance(){return l.instance||(l.instance=new l),l.instance}startAutomaticCleanup(I){if(this.cleanupInterval===null&&typeof window<"u"){let G=window.setInterval(()=>{this.cleanExpired()},6e4);this.cleanupInterval=I(G)}}get(I,G){let b=this.makeKey(I,G),Z=this.cache.get(b);return Z?Date.now()-Z.timestamp>this.TTL?(this.cache.delete(b),null):new Set(Z.values):null}set(I,G,b){let Z=this.makeKey(I,b),c=new Set,W=0;for(let d of G){if(W>=this.MAX_VALUES_PER_ENTRY)break;c.add(d),W++}this.cache.size>=this.MAX_CACHE_ENTRIES&&!this.cache.has(Z)&&this.evictOldestEntries(1),this.cache.set(Z,{values:c,timestamp:Date.now()})}evictOldestEntries(I){let G=Array.from(this.cache.entries()).sort(([,b],[,Z])=>b.timestamp-Z.timestamp).slice(0,I);for(let[b]of G)this.cache.delete(b)}clear(I){if(I){let G=[];for(let b of this.cache.keys())(b.startsWith(`${I}:`)||b===I)&&G.push(b);for(let b of G)this.cache.delete(b)}else this.cache.clear()}cleanExpired(){let I=Date.now(),G=[];for(let[b,Z]of this.cache.entries())I-Z.timestamp>this.TTL&&G.push(b);for(let b of G)this.cache.delete(b)}getStats(){return{size:this.cache.size,maxSize:this.MAX_CACHE_ENTRIES,cleanupInterval:this.cleanupInterval}}destroy(){this.cleanupInterval=null,this.cache.clear()}makeKey(I,G){return G?`${I}:${G}`:I}};var _Z=class{static GetApi(I,G,b){return{inputPrompt:(Z,c,W)=>this.inputPrompt(I,Z,c,W),wideInputPrompt:(Z,c,W)=>this.wideInputPrompt(I,Z,c,W),yesNoPrompt:(Z,c)=>this.yesNoPrompt(I,Z,c),infoDialog:(Z,c)=>this.infoDialog(I,Z,c),suggester:(Z,c)=>this.suggester(I,Z,c),checkboxPrompt:(Z,c)=>this.checkboxPrompt(I,Z,c),executeChoice:async(Z,c)=>{let W=G.getChoiceByName(Z);W||wI(new Error(`Choice named '${Z}' not found`),"API executeChoice error"),c&&Object.keys(c).forEach(d=>{b.variables.set(d,c[d])}),await b.execute(W),b.variables.clear()},format:async(Z,c,W=!0)=>{c&&Object.keys(c).forEach(N=>{b.variables.set(N,c[N])});let d=await new sl(I,G,b).formatFileContent(Z);return W&&b.variables.clear(),d},ai:{prompt:async(Z,c,W)=>{let d=M.getState(),N=d.ai;if(d.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let m=this.GetApi(I,G,b).format,Y;if(typeof c=="string"){let a=ml(c);if(!a)throw new Error(`Model '${c}' not found.`);Y=a}else Y=c;let V=fb(Y.name);if(!V)throw new Error(`Model '${Y.name}' not found in any provider`);let h=await Fa(I,{model:Y,prompt:Z,apiKey:V.apiKey,modelOptions:W?.modelOptions??{},outputVariableName:W?.variableName??"output",showAssistantMessages:W?.showAssistantMessages??!0,systemPrompt:W?.systemPrompt??N.defaultSystemPrompt},(a,X)=>m(a,X,!1));return h?(W?.shouldAssignVariables&&Object.assign(b.variables,h),h):(wI(new Error("AI Assistant returned null"),"AI Prompt error"),{})},chunkedPrompt:async(Z,c,W,d,N)=>{let m=M.getState(),Y=m.ai;if(m.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let V=this.GetApi(I,G,b).format,h;if(typeof W=="string"){let H=ml(W);if(!H)throw new Error(`Model ${W} not found.`);h=H}else h=W;let a=fb(h.name);if(!a)throw new Error(`Model '${h.name}' not found in any provider`);let X=await Ra(I,{model:h,text:Z,promptTemplate:c,chunkSeparator:d?.chunkSeparator??/\n/,apiKey:a.apiKey,modelOptions:d?.modelOptions??{},outputVariableName:d?.variableName??"output",showAssistantMessages:d?.showAssistantMessages??!0,systemPrompt:d?.systLine truncated
|
||||
`,shouldMerge:d?.shouldMerge??!0},(H,w)=>{let u={...N,...w};return V(H,u,!1)});return X?(d?.shouldAssignVariables&&Object.assign(b.variables,X),X):(wI(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>Jl(),getMaxTokens:Z=>{let c=ml(Z);if(!c)throw new Error(`Model ${Z} not found.`);return c.maxTokens},countTokens(Z,c){return gG(Z,c)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async Z=>await navigator.clipboard.writeText(Z),getSelectedText:()=>{let Z=I.workspace.getActiveViewOfType(Xa.MarkdownView);if(!Z){wI(new Error("No active view"),"Could not get selected text");return}if(!Z.editor.somethingSelected()){wI(new Error("No text selected"),"Could not get selected text");return}return Z.editor.getSelection()}},date:{now:(Z,c)=>jl({format:Z,offset:c}),tomorrow:Z=>jl({format:Z,offset:1}),yesterday:Z=>jl({format:Z,offset:-1})},fieldSuggestions:{getFieldValues:async(Z,c)=>{let W={folder:c?.folder,tags:c?.tags,inline:c?.includeInline??!1},d=I.vault.getMarkdownFiles();d=Bd.filterFiles(d,W,m=>I.metadataCache.getFileCache(m));let N=new Set;for(let m of d){let V=I.metadataCache.getFileCache(m)?.frontmatter?.[Z];if(V!=null){if(Array.isArray(V))V.forEach(h=>{let a=h.toString().trim();a&&N.add(a)});else if(typeof V!="object"){let h=V.toString().trim();h&&N.add(h)}}if(W.inline){let h=await I.vault.read(m);PZ.getFieldValues(h,Z).forEach(X=>N.add(X))}}return Array.from(N).sort()},clearCache:Z=>{Dl.getInstance().clear(Z)}}}}static async inputPrompt(I,G,b,Z){try{return await yI.Prompt(I,G,b,Z)}catch{return}}static async wideInputPrompt(I,G,b,Z){try{return await Sb.Prompt(I,G,b,Z)}catch{return}}static async yesNoPrompt(I,G,b){try{return await MG.Prompt(I,G,b)}catch{return}}static async infoDialog(I,G,b){try{return await bW.Show(I,G,b)}catch{return}}static async suggester(I,G,b){try{let Z;return typeof G=="function"?Z=b.map(G):Z=G,await aG.Suggest(I,Z,b)}catch{return}}static async checkboxPrompt(I,G,b){try{return await ZW.Open(I,G,b)}catch{return}}};var $Z=class extends SZ{};var FG=class{constructor(I,G){this.name=I,this.type=G,this.id=xl()}};var Qa=require("obsidian");var GG=class extends FG{constructor(I){super(I,"EditorCommand"),this.editorCommandType=I}static getSelectedText(I){return this.getActiveMarkdownView(I).editor.getSelection()}static getActiveMarkdownView(I){let G=I.workspace.getActiveViewOfType(Qa.MarkdownView);if(!G)throw U.logError("no active markdown view."),new Error("no active markdown view.");return G}};var Ic=class extends GG{constructor(){super("Cut")}static async run(I){let G=GG.getSelectedText(I),b=GG.getActiveMarkdownView(I);if(!G){U.logError("nothing selected.");return}await navigator.clipboard.writeText(G),b.editor.replaceSelection("")}};var lc=class extends GG{constructor(){super("Copy")}static async run(I){let G=GG.getSelectedText(I);await navigator.clipboard.writeText(G)}};var bc=class extends GG{constructor(){super("Paste")}static async run(I){let G=await navigator.clipboard.readText(),b=GG.getActiveMarkdownView(I);if(!b){U.logError("no active markdown view.");return}b.editor.replaceSelection(G)}};var Zc=class extends GG{constructor(){super("Select active line")}static run(I){let G=GG.getActiveMarkdownView(I),{line:b}=G.editor.getCursor(),c=G.editor.getLine(b).length;G.editor.setSelection({line:b,ch:0},{line:b,ch:c})}};var cc=class extends GG{constructor(){super("Select link on active line")}static run(I){let G=GG.getActiveMarkdownView(I),{line:b}=G.editor.getCursor(),Z=G.editor.getLine(b),c=C2.exec(Z);if(!c){U.logError(`no internal link found on line ${b}.`);return}let W=c.index,d=c[0].length+W;G.editor.setSelection({line:b,ch:W},{line:b,ch:d})}};function Ha(l){return new Promise(I=>setTimeout(I,l))}function HY(l){return l.split(`
|
||||
`)}function pa(l){return l.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}var yl=class extends $Z{constructor(I,G,b,Z,c,W){super(I),this.choice=b,this.plugin=G,this.macros=Z,this.choiceExecutor=c,this.params={app:this.app,quickAddApi:_Z.GetApi(I,G,c),variables:{},obsidian:_H},W?.forEach((d,N)=>{this.params.variables[N]=d})}async run(){let I=this.choice.macroId??this.choice?.macro?.id,G=this.macros.find(b=>b.id===I);if(!G||!G?.commands){U.logError(`No commands in the selected macro. Did you select a macro for '${this.choice.name}'?`);return}await this.executeCommands(G.commands)}async executeCommands(I){for(let G of I)G?.type==="Obsidian"&&this.executeObsidianCommand(G),G?.type==="UserScript"&&await this.executeUserScript(G),G?.type==="Choice"&&await this.executeChoice(G),G?.type==="Wait"&&await Ha(G.time),G?.type==="NestedChoice"&&await this.executeNestedChoice(G),G?.type==="EditorCommand"&&await this.executeEditorCommand(G),G?.type==="AIAssistant"&&await this.executeAIAssistant(G),Object.keys(this.params.variables).forEach(b=>{this.choiceExecutor.variables.set(b,this.params.variables[b])})}async executeUserScript(I){let G=await sd(I,this.app);if(!G){U.logError(`failed to load user script ${I.path}.`);return}G.settings&&(this.userScriptCommand=I);try{await this.userScriptDelegator(G)}catch(b){wI(b,`Failed to run user script ${I.name}`)}this.userScriptCommand&&(this.userScriptCommand=null)}async runScriptWithSettings(I,G){if(typeof I!="function"&&I.entry&&typeof I.entry=="function")return await this.onExportIsFunction(I.entry,G.settings);if(typeof I=="function")return await this.onExportIsFunction(I,G.settings)}async userScriptDelegator(I){switch(typeof I){case"function":this.userScriptCommand?await this.runScriptWithSettings(I,this.userScriptCommand):await this.onExportIsFunction(I);break;case"object":await this.onExportIsObject(I);break;case"bigint":case"boolean":case"number":case"string":this.output=I.toString();break;default:U.logError(`user script in macro for '${this.choice.name}' is invalid`)}}async onExportIsFunction(I,G){this.output=await I(this.params,G||{})}async onExportIsObject(I){if(Object.keys(I).length===0)throw new Error(`user script in macro for '${this.choice.name}' is an empty object`);if(this.userScriptCommand&&I.entry!==null){await this.runScriptWithSettings(I,this.userScriptCommand);return}try{let G=Object.keys(I),b=await aG.Suggest(this.app,G,G);await this.userScriptDelegator(I[b])}catch(G){wI(G,"Error in script object handling","LOG")}}executeObsidianCommand(I){this.app.commands.executeCommandById(I.commandId)}async executeChoice(I){let G=this.plugin.getChoiceById(I.choiceId);if(!G){U.logError("choice could not be found.");return}await this.choiceExecutor.execute(G)}async executeNestedChoice(I){let G=I.choice;if(!G){U.logError(`choice in ${I.name} is invalid`);return}await this.choiceExecutor.execute(G)}async executeEditorCommand(I){switch(I.editorCommandType){case"Cut":await Ic.run(this.app);break;case"Copy":await lc.run(this.app);break;case"Paste":await bc.run(this.app);break;case"Select active line":Zc.run(this.app);break;case"Select link on active line":cc.run(this.app);break}}async executeAIAssistant(I){if(M.getState().disableOnlineFeatures)throw new Error("Blocking request to OpenAI: Online features are disabled in settings.");let G=M.getState().ai,b=Jl(),Z=I.model==="Ask me"?await aG.Suggest(this.app,b,b):I.model,c=ml(Z);if(!c)throw new Error(`Model ${Z} not found with any provider.`);let W=new sl(this.app,XI.instance,this.choiceExecutor),d=fb(c.name);if(!d)throw new Error(`Model ${c.name} not found in the AI providers settings.`);let N=await aa(this.app,{apiKey:d.apiKey,model:c,outputVariableName:I.outputVariableName,promptTemplate:I.promptTemplate,promptTemplateFolder:G.promptTemplatesFolderPath,systemPrompt:I.systemPrompt,showAssistantMessages:G.showAssistant,modelOptions:I.modelParameters},async m=>W.formatFileContent(m));for(let m in N)this.choiceExecutor.variables.set(m,N[m])}};var rd=class extends yl{constructor(I,G,b,Z,c){super(I,G,null,b,Z,c)}async runAndGetOutput(I){let{basename:G,memberAccess:b}=GW(I),Z=this.macros.find(c=>c.name===G);if(!Z)throw U.logError(`macro '${I}' does not exist.`),new Error(`macro '${I}' does not exist.`);return b&&b.length>0&&(this.memberAccess=b),await this.executeCommands(Z.commands),this.output}async onExportIsObject(I){if(!this.memberAccess)return await super.onExportIsObject(I);let G=I;this.memberAccess.forEach(b=>{G=G[b]}),await this.userScriptDelegator(G)}};var GR=require("obsidian");var Od=class extends yl{constructor(I,G,b,Z){super(I,G,null,null,b,Z)}async runAndGetOutput(I){let G=Object.getPrototypeOf(async function(){}).constructor;return await new G(I).bind(this.params,this).call()}};var EG=require("obsidian");var cI="\u261A",$H=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|",`^{${cI}}${cI}`,`[${cI}]${cI}`,"\\above","\\abovewithdelims","\\acute","\\aleph","\\alpha","\\amalg","\\And","\\angle","\\approx","\
Line truncated
|
||||
${cI}
|
||||
\\end{${l}}${cI}`}var ua=[...$H,...Ip.map(Gp)];var na=require("obsidian");var lp=new RegExp(/\\([a-z{}A-Z0-9]*)$/),Md=class extends vG{constructor(G){super(XI.instance.app,G);this.inputEl=G;this.lastInput="";this.symbols=Object.assign([],ua),this.elementsRendered=this.symbols.reduce((b,Z)=>{try{b[Z.toString()]=(0,na.renderMath)(Z,!0)}catch{}return b},{})}getSuggestions(G){if(this.inputEl.selectionStart===null)return[];let b=this.inputEl.selectionStart,Z=G.substr(0,b),c=Z.lastIndexOf("\\"),W=Z.substr(c),d=lp.exec(W),N=[];return d&&(this.lastInput=d[1],N=this.symbols.filter(V=>V.toLowerCase().contains(this.lastInput))),new tG(N,{findAllMatches:!0,threshold:.8}).search(this.lastInput).map(V=>V.item)}renderSuggestion(G,b){G&&(b.setText(G),b.append(this.elementsRendered[G]))}selectSuggestion(G){if(this.inputEl.selectionStart===null)return;let b=this.inputEl.selectionStart,Z=this.lastInput.length,c=this.inputEl.value,W=0,d=G.replace(/\\\\/g,"\\");if(this.inputEl.value=`${c.substr(0,b-Z-1)}${d}${c.substr(b)}`,W=b-Z+G.length-1,this.inputEl.trigger("input"),this.close(),G.contains(cI)){let N=this.inputEl.value.indexOf(cI);this.inputEl.value=this.inputEl.value.replace(cI,""),this.inputEl.setSelectionRange(N,N)}else this.inputEl.setSelectionRange(W,W)}};var jd=class l extends EG.Modal{constructor(){super(XI.instance.app);this.didSubmit=!1;this.keybindListener=G=>{G.ctrlKey&&G.key==="Enter"&&this.submit(),G.key==="Tab"&&(G.preventDefault(),this.cursorToGoTo())};this.submitClickCallback=G=>this.submit();this.cancelClickCallback=G=>this.cancel();this.open(),this.display(),this.waitForClose=new Promise((G,b)=>{this.resolvePromise=G,this.rejectPromise=b}),new Md(this.inputEl),this.inputEl.focus(),this.inputEl.select()}static Prompt(){return new l().waitForClose}display(){this.containerEl.addClass("quickAddModal","qaMathModal"),this.contentEl.empty();let G=this.contentEl.createDiv();G.className="math math-block is-loaded";let b=new EG.TextAreaComponent(this.contentEl);b.inputEl.style.width="100%",b.inputEl.style.height="10rem",this.inputEl=b.inputEl,b.onChange((0,EG.debounce)(async Z=>await this.mathjaxLoop(G,Z),50)),b.inputEl.addEventListener("keydown",this.keybindListener),this.createButtonBar(this.contentEl.createDiv())}async onOpen(){super.onOpen(),await(0,EG.loadMathJax)()}async mathjaxLoop(G,b){let Z=(0,EG.renderMath)(b,!0);await(0,EG.finishRenderMath)(),G.empty(),G.append(Z)}cursorToGoTo(){if(this.inputEl.value.contains(cI)){let G=this.inputEl.value.indexOf(cI);this.inputEl.value=this.inputEl.value.replace(cI,""),this.inputEl.setSelectionRange(G,G)}}createButton(G,b,Z){let c=new EG.ButtonComponent(G);return c.setButtonText(b).onClick(Z),c}createButtonBar(G){let b=G.createDiv();this.createButton(b,"Ok",this.submitClickCallback).setCta().buttonEl.style.marginRight="0",this.createButton(b,"Cancel",this.cancelClickCallback),b.style.display="flex",b.style.flexDirection="row-reverse",b.style.justifyContent="flex-start",b.style.marginTop="1rem",b.style.gap="0.5rem"}removeInputListeners(){this.inputEl.removeEventListener("keydown",this.keybindListener)}resolveInput(){let G=this.inputEl.value.replace("\\n","\\\\n").replace(new RegExp(cI,"g"),"");this.didSubmit?this.resolvePromise(G):this.rejectPromise("No input given.")}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListeners()}};var Wc=class{factory(){return XI.instance.settings.inputPrompt==="multi-line"?Sb:yI}};var wa=require("obsidian"),el=class l extends wa.FuzzySuggestModal{constructor(G,b,Z,c={}){super(G);this.displayItems=b;this.items=Z;this.promise=new Promise((W,d)=>{this.resolvePromise=W,this.rejectPromise=d}),this.inputEl.addEventListener("keydown",W=>{if(W.code!=="Tab"||!("chooser"in this))return;let{values:d,selectedItem:N}=this.chooser,{value:m}=this.inputEl;this.inputEl.value=d[N].item??m}),c.placeholder&&this.setPlaceholder(c.placeholder),c.limit&&(this.limit=c.limit),c.emptyStateText&&(this.emptyStateText=c.emptyStateText),this.open()}static Suggest(G,b,Z,c={}){return new l(G,b,Z,c).promise}getItemText(G){return G===this.inputEl.value?G:this.displayItems[this.items.indexOf(G)]}getItems(){return this.inputEl.value===""?this.items:[this.inputEl.value,...this.items]}selectSuggestion(G,b){this.resolved=!0,super.selectSuggestion(G,b)}onChooseItem(G,b){this.resolved=!0,this.resolvePromise(G)}onClose(){super.onClose(),this.resolved||this.rejectPromise("no input given.")}};var Kd=class{static parse(I){let G=I.split("|").map(c=>c.trim()),b=G[0],Z={};for(let c=1;c<G.length;c++){let W=G[c],d=W.indexOf(":");if(d===-1)continue;let N=W.substring(0,d).trim(),m=W.substring(d+1).trim();switch(N){case"folder":Z.folder=m;break;case"tag":Z.tags||(Z.tags=[]);let Y=m.startsWith("#")?m.substring(1):m;Z.tags.push(Y);break;case"inline":Z.inline=m.toLowerCase()==="true";break;case"default":Z.defaultValue=m;break;case"default-empty":Z.defaultEmpty=m.toLowerCase()==="true";break;case"default-always":Z.default
Line truncated
|
||||
|
||||
Suggested values for ${c}: ${N.slice(0,3).join(", ")}`)}return await vI.Prompt(this.app,`Enter value for ${c}`,V)}let m=`Enter value for ${c}`;return a.hasDefaultValue&&(m=`Enter value for ${c} (default: ${b.defaultValue})`),await B2.Suggest(this.app,a.values,a.values,{placeholder:m})}}generateCacheKey(l){let c=[];return l.folder&&c.push(`folder:${l.folder}`),l.tags&&c.push(`tags:${l.tags.join(",")}`),l.inline&&c.push("inline:true"),l.caseSensitive&&c.push("case-sensitive:true"),l.excludeFolders&&c.push(`exclude-folders:${l.excludeFolders.join(",")}`),l.excludeTags&&c.push(`exclude-tags:${l.excludeTags.join(",")}`),l.excludeFiles&&c.push(`exclude-files:${l.excludeFiles.join(",")}`),l.defaultValue&&c.push(`default:${l.defaultValue}`),l.defaultEmpty&&c.push("default-empty:true"),l.defaultAlways&&c.push("default-always:true"),c.join("|")}async getMacroValue(l){let c=new Wd(this.app,this.plugin,this.plugin.settings.macros,this.choiceExecutor,this.variables),b=await c.runAndGetOutput(l)??"";return Object.keys(c.params.variables).forEach(Z=>{this.variables.set(Z,c.params.variables[Z])}),b}async getTemplateContent(l){return await new Jc(this.app,this.plugin,l,this.choiceExecutor).run()}async getSelectedText(){let l=this.app.workspace.getActiveViewOfType(g5.MarkdownView);return l?l.editor.getSelection():""}async replaceInlineJavascriptInString(l){let c=l;for(;Rb.test(c);){let Z=Rb.exec(c)?.at(1)?.trim();if(Z){let d=new ad(this.app,this.plugin,this.choiceExecutor,this.variables),W=await d.runAndGetOutput(Z);for(let a in d.params.variables)this.variables.set(a,d.params.variables[a]);c=typeof W=="string"?this.replacer(c,Rb,W):this.replacer(c,Rb,"")}}return c}};var z5=require("obsidian");var x1=class extends h1{constructor(l,c,b){super(l);this.plugin=c;this.templater=fZ(l),this.formatter=new U2(l,c,b)}async getOrCreateFolder(l){let c;if(l.length>1){if(c=await cl.Suggest(this.app,l,l),!c)throw new Error("No folder selected.")}else c=l[0];return c?await this.createFolder(c):c="",c}async getFormattedFilePath(l,c,b){let Z=await this.formatter.formatFileName(c,b);return this.normalizeMarkdownFilePath(l,Z)}getTemplateExtension(l){return Hb.test(l)?".canvas":".md"}normalizeTemplateFilePath(l,c,b){let Z=l?`${l}/`:"",d=this.getTemplateExtension(b),W=c.replace(Yb,"").replace(Hb,"");return`${Z}${W}${d}`}async incrementFileName(l){let c=oZ.exec(l),b=c&&typeof c.at=="function"?c?.at(1):void 0,Z=await this.app.vault.adapter.exists(l),d=l,W=Hb.test(l)?".canvas":".md";if(Z&&b){let m=parseInt(b);if(!m)throw new Error("detected numbers but couldn't get them.");d=d.replace(oZ,`${m+1}${W}`)}else Z&&(d=d.replace(oZ,`1${W}`));return await this.app.vault.adapter.exists(d)&&(d=await this.incrementFileName(d)),d}async createFileWithTemplate(l,c){try{let b=await this.getTemplateContent(c),Z=await this.formatter.formatFileContent(b),d=await this.createFileWithInput(l,Z);return await a1(this.app,d),d}catch(b){return EI(b,"Could not create file with template"),null}}async overwriteFileWithTemplate(l,c){try{let b=await this.getTemplateContent(c),Z=await this.formatter.formatFileContent(b);return await this.app.vault.modify(l,Z),await a1(this.app,l),l}catch(b){return EI(b,"Could not overwrite file with template"),null}}async appendToFileWithTemplate(l,c,b){try{let Z=await this.getTemplateContent(c),d=await this.formatter.formatFileContent(Z),W=await this.app.vault.cachedRead(l),a=b==="top"?`${d}
|
||||
${W}`:`${W}
|
||||
${d}`;return await this.app.vault.modify(l,a),await a1(this.app,l),l}catch(Z){return EI(Z,"Could not append to file with template"),null}}async getTemplateContent(l){let c=l;!Yb.test(l)&&!Hb.test(l)&&(c+=".md");let b=this.app.vault.getAbstractFileByPath(c);if(!(b instanceof z5.TFile))throw new Error(`Template file not found at path "${c}".`);return await this.app.vault.cachedRead(b)}};var Jc=class extends x1{constructor(l,c,b,Z){super(l,c,Z);this.templatePath=b}async run(){let l=await this.getTemplateContent(this.templatePath);return l||B.logError(`Template ${this.templatePath} not found.`),l=await this.formatter.formatFileContent(l),l}};var Tl=class extends tc{constructor(l,c){super();this.app=l;this.plugin=c}async format(l){let c=l;try{c=this.replaceDateInString(c),c=this.replaceTimeInString(c),c=await this.replaceValueInString(c),c=await this.replaceDateVariableInString(c),c=await this.replaceVariableInString(c),c=await this.replaceLinkToCurrentFileInString(c),c=await this.replaceMacrosInString(c),c=await this.replaceTemplateInString(c),c=await this.replaceFieldVarInString(c),c=this.replaceLinebreakInString(c)}catch{return l}return c}promptForValue(l){return l||"user input"}getVariableValue(l){return DZ(l)}getCurrentFileLink(){return qZ(this.app.workspace.getActiveFile())}getNaturalLanguageDates(){return g2(this.app)}suggestForValue(l){return PZ(l)}getMacroValue(l){return KZ(l)}promptForMathValue(){return Promise.resolve("calculation_result")}promptForVariable(l){return Promise.resolve(OZ(l))}async getTemplateContent(l){try{return await new Jc(this.app,this.plugin,l,void 0).run()}catch{return`Template (not found): ${l}`}}async getSelectedText(){return"selected_text"}async suggestForField(l){return Promise.resolve(`${l}_field_value`)}async replaceDateVariableInString(l){let c=l;return c=c.replace(new RegExp(lG.source,"gi"),(b,Z,d)=>{let W=Z?.trim(),a=d?.trim();if(!W||!a)return b;let m=new Date,V;try{V=z2.generate(a,m)}catch{V=`[${a} format]`}return V}),c}};var k1=class extends ec{constructor(l,c,b){super(l);this.plugin=b;this.choice=c,this.display()}display(){this.containerEl.addClass("captureChoiceBuilder"),this.contentEl.empty(),this.addCenteredChoiceNameHeader(this.choice),this.addCapturedToSetting(),this.choice?.captureToActiveFile||(this.addCreateIfNotExistsSetting(),this.choice?.createFileIfItDoesntExist?.enabled&&this.addCreateWithTemplateSetting()),this.addTaskSetting(),this.addPrependSetting(),this.addAppendLinkSetting(),this.addInsertAfterSetting(),this.choice.captureToActiveFile||(this.addOpenFileSetting(),this.choice.openFile&&this.addOpenFileInNewTabSetting()),this.addFormatSetting()}addCapturedToSetting(){let l;new iI.Setting(this.contentEl).setName("Capture To").setDesc("File to capture to. Supports some format syntax.");let c=this.contentEl.createDiv("captureToContainer"),b=c.createDiv("captureToActiveFileContainer"),Z=b.createEl("span");Z.textContent="Capture to active file";let d=new iI.ToggleComponent(b);if(d.setValue(this.choice?.captureToActiveFile),d.onChange(W=>{this.choice.captureToActiveFile=W,this.reload()}),!this.choice?.captureToActiveFile){let W=c.createDiv("captureToFileContainer"),a=W.createEl("span"),m=new V1(this.app);(async()=>a.textContent=await m.format(this.choice.captureTo))();let V=new iI.TextComponent(W);V.setPlaceholder("File name format"),l=V,V.inputEl.style.width="100%",V.inputEl.style.marginBottom="8px",V.setValue(this.choice.captureTo).setDisabled(this.choice?.captureToActiveFile).onChange(async h=>{this.choice.captureTo=h,a.textContent=await m.format(h)});let N=[...this.app.vault.getMarkdownFiles().map(h=>h.path),...Dm];new Hl(this.app,l.inputEl,N,50)}}addPrependSetting(){new iI.Setting(this.contentEl).setName("Write to bottom of file").setDesc(`Put value at the bottom of the file - otherwise at the ${this.choice?.captureToActiveFile?"active cursor location":"top"}.`).addToggle(c=>{c.setValue(this.choice.prepend),c.onChange(b=>{this.choice.prepend=b,this.choice.prepend&&this.choice.insertAfter.enabled&&(this.choice.insertAfter.enabled=!1,this.reload())})})}addTaskSetting(){new iI.Setting(this.contentEl).setName("Task").setDesc("Formats the value as a task.").addToggle(c=>{c.setValue(this.choice.task),c.onChange(b=>this.choice.task=b)})}addAppendLinkSetting(){new iI.Setting(this.contentEl).setName("Append link").setDesc("Add a link on your current cursor position, linking to the file you're capturing to.").addToggle(c=>{c.setValue(this.choice.appendLink),c.onChange(b=>this.choice.appendLink=b)})}addInsertAfterSetting(){let l;new iI.Setting(this.contentEl).setName("Insert after").setDesc("Insert capture after specified line. Accepts format syntax.").addToggle(d=>{d.setValue(this.choice.insertAfter.enabled),d.onChange(W=>{this.choice.insertAfter.enabled=W,l.setDisabled(!W),this.choice.insertAfter.enabled&&this.choice.prepend&&(this.choice.prepend=!1),this.reload()})});let b=this.contentEl.createEl("span"),Z=new Tl(this.app,this.plugin);(async()=>b.innerText=awai
Line truncated
|
||||
${e?"Deleting this choice will delete all ("+t.choices.length+") choices inside it!":""}
|
||||
${Q?"Deleting this choice will delete the macro associated with it!":""}
|
||||
`)&&(Q&&(l(9,b=b.filter(v=>v.id!==t.macroId)),d(b)),l(0,c=c.filter(v=>C5(t.id,v))),a.removeCommandForChoice(t),Z(c))}async function N(Y){let{choice:t}=Y.detail,Q;if(t.type==="Multi"){Q=t;let e=await vI.Prompt(W,`Rename ${t.name}`,"",t.name);if(!e)return;Q.name=e}else{let e=X(t);if(!e)throw new Error("Invalid choice type");Q=await e.waitForClose}Q&&(l(0,c=c.map(e=>va(e,Q))),a.removeCommandForChoice(t),a.addCommandForChoice(Q),Z(c))}async function h(Y){let{choice:t}=Y.detail,Q={...t,command:!t.command};Q.command?a.addCommandForChoice(Q):a.removeCommandForChoice(Q),l(0,c=c.map(e=>va(e,Q))),Z(c)}async function F(Y){let{choice:t}=Y.detail,Q=R(t);l(0,c=[...c,Q]),Z(c)}function R(Y){if(!yV(Y))throw new Error("Invalid choice type");let t;switch(Y.type){case"Template":t=new jc(`${Y.name} (copy)`);break;case"Capture":t=new Tc(`${Y.name} (copy)`);break;case"Macro":t=new Zb(`${Y.name} (copy)`);break;case"Multi":t=new Cc(`${Y.name} (copy)`);break}return Y.type!=="Multi"?Object.assign(t,wV(Y,["id","name"])):t.choices=Y.choices.map(Q=>R(Q)),t}function X(Y){switch(Y.type){case"Template":return new N1(W,Y,a);case"Capture":return new k1(W,Y,a);case"Macro":return new Bd(W,Y,b,C.getState().choices);case"Multi":default:break}}async function E(){let Y=await new Ld(W,a,b,c).waitForClose;Y&&(d(Y),l(9,b=Y))}async function s(){let Y=await new jd(W,C.getState().ai).waitForClose;Y&&C.setState(t=>({...t,ai:Y}))}function J(Y){c=Y,l(0,c)}let i=Y=>Z(Y.detail.choices);return G.$$set=Y=>{"choices"in Y&&l(0,c=Y.choices),"macros"in Y&&l(9,b=Y.macros),"saveChoices"in Y&&l(1,Z=Y.saveChoices),"saveMacros"in Y&&l(10,d=Y.saveMacros),"app"in Y&&l(11,W=Y.app),"plugin"in Y&&l(12,a=Y.plugin)},[c,Z,m,V,N,h,F,E,s,b,d,W,a,J,i]}var Ja=class extends FI{constructor(I){super(),RI(this,I,Hn,Yn,HI,{choices:0,macros:9,saveChoices:1,saveMacros:10,app:11,plugin:12},hn)}},S5=Ja;var Rn={name:"OpenAI",endpoint:"https://api.openai.com/v1",apiKey:"",models:[{name:"text-davinci-003",maxTokens:4096},{name:"gpt-3.5-turbo",maxTokens:4096},{name:"gpt-3.5-turbo-16k",maxTokens:16384},{name:"gpt-3.5-turbo-1106",maxTokens:16385},{name:"gpt-4",maxTokens:8192},{name:"gpt-4-32k",maxTokens:32768},{name:"gpt-4-1106-preview",maxTokens:128e3},{name:"gpt-4-turbo",maxTokens:128e3},{name:"gpt-4o",maxTokens:128e3},{name:"gpt-4o-mini",maxTokens:128e3}]},Td=[Rn];var ld={choices:[],macros:[],inputPrompt:"single-line",devMode:!1,templateFolderPath:"",announceUpdates:!0,version:"0.0.0",disableOnlineFeatures:!0,enableRibbonIcon:!1,ai:{defaultModel:"Ask me",defaultSystemPrompt:'As an AI assistant within Obsidian, your primary goal is to help users manage their ideas and knowledge more effectively. Format your responses using Markdown syntax. Please use the [[Obsidian]] link format. You can write aliases for the links by writing [[Obsidian|the alias after the pipe symbol]]. To use mathematical notation, use LaTeX syntax. LaTeX syntax for larger equations should be on separate lines, surrounded with double dollar signs ($$). You can also inline math expressions by wrapping it in $ symbols. For example, use $$w_{ij}^{ ext{new}}:=w_{ij}^{ ext{current}}+etacdotdelta_jcdot x_{ij}$$ on a separate line, but you can write "($eta$ = learning rate, $delta_j$ = error term, $x_{ij}$ = input)" inline.',promptTemplatesFolderPath:"",showAssistant:!0,providers:Td},migrations:{migrateToMacroIDFromEmbeddedMacro:!1,useQuickAddTemplateFolder:!1,incrementFileNameSettingMoveToDefaultBehavior:!1,mutualExclusionInsertAfterAndWriteToBottomOfFile:!1,setVersionAfterUpdateModalRelease:!1,addDefaultAIProviders:!1}},Cd=class extends Q2.PluginSettingTab{constructor(l,c){super(l,c);this.plugin=c}display(){let{containerEl:l}=this;l.empty(),l.createEl("h2",{text:"QuickAdd Settings"}),this.addChoicesSetting(),this.addUseMultiLineInputPromptSetting(),this.addTemplateFolderPathSetting(),this.addAnnounceUpdatesSetting(),this.addDisableOnlineFeaturesSetting(),this.addEnableRibbonIconSetting()}addAnnounceUpdatesSetting(){let l=new Q2.Setting(this.containerEl);l.setName("Announce Updates"),l.setDesc("Display release notes when a new version is installed. This includes new features, demo videos, and bug fixes."),l.addToggle(c=>{c.setValue(C.getState().announceUpdates),c.onChange(b=>{C.setState({announceUpdates:b})})})}hide(){this.choiceView&&this.choiceView.$destroy()}addChoicesSetting(){let l=new Q2.Setting(this.containerEl);l.infoEl.remove(),l.settingEl.style.display="block",this.choiceView=new S5({target:l.settingEl,props:{app:this.app,plugin:this.plugin,choices:C.getState().choices,saveChoices:c=>{C.setState({choices:c})},macros:C.getState().macros,saveMacros:c=>{C.setState({macros:c})}}})}addUseMultiLineInputPromptSetting(){new Q2.Setting(this.containerEl).setName("Use Multi-line Input Prompt").setDesc("Use multi-line input prompt instead of single-line input prompt").addToggle(l=>l.setValue(this.plugin.settings.inputPrompt==="multi-line").setTooltip("Use multi-line input prompt").onChange(c=>{c?C.setState({inputPrompt:
Line truncated
|
||||
`:""}${b}`}if(this.choice.insertAfter.enabled)return await this.insertAfterHandler(b);let d=this.file?this.getFrontmatterEndPosition(this.file):null;return d?this.insertTextAfterPositionInBody(b,this.fileContent,d):`${b}${this.fileContent}`}async formatContentOnly(l){let c=await super.formatFileContent(l);return c=this.replaceLinebreakInString(c),c.trim()===""?this.fileContent:c}async insertAfterHandler(l){let c=await this.format(this.choice.insertAfter.after),b=new RegExp(`\\s*${_V(c.replace("\\n",""))}\\s*`),Z=k3(this.fileContent),d=Z.findIndex(a=>b.test(a));if(d===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(l);EI(new Error("Unable to find insert after line in file"),"Insert After Error")}if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");d=Od(Z,d,!!this.choice.insertAfter.considerSubsections)??Z.length-1}return this.insertTextAfterPositionInBody(l,this.fileContent,d)}async createInsertAfterIfNotFound(l){let b=`${this.replaceLinebreakInString(await this.format(this.choice.insertAfter.after))}
|
||||
${l}`;if(this.choice.insertAfter?.createIfNotFoundLocation===Fb){let Z=this.file?this.getFrontmatterEndPosition(this.file):-1;return this.insertTextAfterPositionInBody(b,this.fileContent,Z)}if(this.choice.insertAfter?.createIfNotFoundLocation===iZ)return`${this.fileContent}
|
||||
${b}`;if(this.choice.insertAfter?.createIfNotFoundLocation===rZ)try{let Z=this.app.workspace.getActiveViewOfType(P5.MarkdownView);if(!Z)throw new Error("No active view.");let W=Z.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let m=k3(this.fileContent);W=Od(m,W,!!this.choice.insertAfter.considerSubsections)??m.length-1}return this.insertTextAfterPositionInBody(b,this.fileContent,W)}catch(Z){EI(Z,`Unable to insert line '${this.choice.insertAfter.after}' at cursor position`)}}getFrontmatterEndPosition(l){let c=this.app.metadataCache.getFileCache(l);return!c||!c.frontmatter?(B.logMessage("could not get frontmatter. Maybe there isn't any."),-1):c.frontmatterPosition?c.frontmatterPosition.end.line:-1}insertTextAfterPositionInBody(l,c,b){if(b===-1){let a=!this.choice.task;return`${l}${a?`
|
||||
`:""}${c}`}let Z=c.split(`
|
||||
`),d=Z.slice(0,b+1).join(`
|
||||
`),W=Z.slice(b+1).join(`
|
||||
`);return`${d}
|
||||
${l}${W}`}};var qd=class{isResolved(){return!this.hasConflicts}isConflicted(){return this.hasConflicts}},wc=class extends qd{constructor(I,l,c){super(),this.left=I,this.base=l,this.right=c,this.hasConflicts=!0}static create(I){return new wc(I.left,I.base,I.right)}apply(I){return wc.create({left:I(this.left),base:I(this.base),right:I(this.right)})}},gl=class extends qd{constructor(I){super(),this.hasConflicts=!1,this.result=I}combine(I){this.result=this.result.concat(I.result)}apply(I){return new gl(I(this.result))}};var d2=class{constructor(I,l){this.left=I,this.right=l}static executeDiff(I,l){if(!I.push)throw new Error("Argument is not an array");let c=d2.diff(I,l);return new oa(I,l,c).convertToTypedOutput()}static diff(I,l){return new d2(I,l).performDiff()}performDiff(){let I=this.identifyUniquePositions();I.sort((Z,d)=>d[0]-Z[0]);let[l,c]=this.findNextChange(),b=new _d(l,c,[]);return I.forEach(Z=>{b=this.getDifferences(b,Z)}),b.changeRanges}getDifferences(I,l){let[c,b]=[I.leftChangePos,I.rightChangePos],[Z,d]=l;if(Z<c||d<b)return I;{let[W,a,m,V]=this.findPrevChange(c,b,Z-1,d-1),[N,h]=this.findNextChange(Z+1,d+1),F=this.appendChangeRange(I.changeRanges,W,a,m,V);return new _d(N,h,F)}}findNextChange(I=0,l=0){let c=this.left.slice(I)||[],b=this.right.slice(l)||[],Z=this.mismatchOffset(c,b);return[I+Z,l+Z]}findPrevChange(I,l,c,b){if(I>c||l>b)return[I,c,l,b];{let Z=this.left.slice(I,c+1).reverse()||[],d=this.right.slice(l,b+1).reverse()||[],W=this.mismatchOffset(Z,d);return[I,c-W,l,b-W]}}mismatchOffset(I,l){let c=Math.max(I.length,l.length);for(let b=0;b<c;b++)if(I[b]!==l[b])return b;return Math.min(I.length,l.length)}identifyUniquePositions(){let I=this.findUnique(this.left),l=this.findUnique(this.right),c=new Set(...I.keys()),b=new Set(...l.keys()),d=[...new Set([...c].filter(W=>b.has(W)))].map(W=>[I.get(W),l.get(W)]);return d.unshift([this.left.length,this.right.length]),d}findUnique(I){let l=new Map;I.forEach((b,Z)=>{l.set(b,new ya(Z,!l.has(b)))});let c=new Map;for(let[b,Z]of l.entries())Z.unique&&c.set(b,Z.pos);return c}appendChangeRange(I,l,c,b,Z){return l<=c&&b<=Z?I.push(new Tb(C2.change,l+1,c+1,b+1,Z+1)):l<=c?I.push(new Tb(C2.remove,l+1,c+1,b+1,b)):b<=Z&&I.push(new Tb(C2.add,l+1,l,b+1,Z+1)),I}},ya=class{constructor(I,l){this.pos=I,this.unique=l}},B1=class{constructor(I,l){this.text=I,this.low=l}},oa=class{constructor(I,l,c){this.oldTextArray=I,this.newTextArray=l,this.chunks=c,this.oldText=[],this.newText=[]}convertToTypedOutput(){let I=new ia(0,0);return this.chunks.forEach(l=>{let[c,b]=this.setTextNodeIndexes(l,I.oldIndex,I.newIndex),[Z,d]=this.appendChanges(l,I.oldIndex+c,I.newIndex+b);I.oldIndex=Z,I.newIndex=d}),this.setTheRemainingTextNodeIndexes(I.oldIndex,I.newIndex),{oldText:this.oldText,newText:this.newText}}setTextNodeIndexes(I,l,c){let b=0;for(;l+b<I.leftLo-1;)this.oldText.push(new B1(this.oldTextArray[l+b],c+b)),b+=1;let Z=0;for(;c+Z<I.rightLo-1;)this.newText.push(new B1(this.newTextArray[c+Z],l+Z)),Z+=1;return[b,Z]}appendChanges(I,l,c){for(;l<=I.leftHi-1;)this.oldText.push(this.oldTextArray[l]),l+=1;for(;c<=I.rightHi-1;)this.newText.push(this.newTextArray[c]),c+=1;return[l,c]}setTheRemainingTextNodeIndexes(I,l){let c=0;for(;I+c<this.oldTextArray.length;)this.oldText.push(new B1(this.oldTextArray[I+c],l+c)),c+=1;for(;l+c<this.newTextArray.length;)this.newText.push(new B1(this.newTextArray[l+c],I+c)),c+=1}},ia=class{constructor(I,l){this.oldIndex=I,this.newIndex=l}},C2;(function(G){G.change="change",G.add="add",G.remove="remove"})(C2||(C2={}));var Tb=class{constructor(I,l,c,b,Z){this.action=I,this.leftLo=l,this.leftHi=c,this.rightLo=b,this.rightHi=Z}},_d=class{constructor(I,l,c){this.leftChangePos=I,this.rightChangePos=l,this.changeRanges=c}};var L1=class{constructor(I,l,c,b,Z){this.code=I,this.baseLo=l,this.baseHi=c,this.sideLo=b,this.sideHi=Z}static fromChangeRange(I){return new L1(I.action,I.leftLo,I.leftHi,I.rightLo,I.rightHi)}},yc=class{constructor(I,l,c){this.left=I,this.base=l,this.right=c}static executeDiff(I,l,c){return new yc(I,l,c).getDifferences()}getDifferences(){let I=d2.diff(this.base,this.left).map(c=>L1.fromChangeRange(c)),l=d2.diff(this.base,this.right).map(c=>L1.fromChangeRange(c));return this.collapseDifferences(new $d(I,l))}collapseDifferences(I,l=[]){if(I.isFinished())return l;{let c=new $d,b=I.chooseSide(),Z=I.dequeue();return c.enqueue(b,Z),I.switchSides(),this.buildResultQueue(I,Z.baseHi,c),l.push(this.determineDifference(c,b,I.switchSides())),this.collapseDifferences(I,l)}}buildResultQueue(I,l,c){if(this.queueIsFinished(I.peek(),l))return c;{let b=I.dequeue();return c.enqueue(I.currentSide,b),l<b.baseHi?(I.switchSides(),this.buildResultQueue(I,b.baseHi,c)):this.buildResultQueue(I,l,c)}}queueIsFinished(I,l){return I.length===0||I[0].baseLo>l+1}determineDifference(I,l,c){let b=I.get(l)[0].baseLo,Z=I.get(c),d=Z[Z.length-1].baseHi,[W,a]=this.diffableEndpoints(I.get(OI.left),b,d),[m,V]=this.diffableEndpoints(I.get(OI.right),b,d),N=this.left.slice(W-1,a),h=this.right.sli
Line truncated
|
||||
Suggested values for ${b}: ${V.slice(0,3).join(", ")}`)}return await yI.Prompt(this.app,`Enter value for ${b}`,Y)}let m=`Enter value for ${b}`;return N.hasDefaultValue&&(m=`Enter value for ${b} (default: ${Z.defaultValue})`),await el.Suggest(this.app,N.values,N.values,{placeholder:m})}generateCacheKey(G){let b=[];return G.folder&&b.push(`folder:${G.folder}`),G.tags&&b.push(`tags:${G.tags.join(",")}`),G.inline&&b.push("inline:true"),G.caseSensitive&&b.push("case-sensitive:true"),G.excludeFolders&&b.push(`exclude-folders:${G.excludeFolders.join(",")}`),G.excludeTags&&b.push(`exclude-tags:${G.excludeTags.join(",")}`),G.excludeFiles&&b.push(`exclude-files:${G.excludeFiles.join(",")}`),G.defaultValue&&b.push(`default:${G.defaultValue}`),G.defaultEmpty&&b.push("default-empty:true"),G.defaultAlways&&b.push("default-always:true"),b.join("|")}async getMacroValue(G){let b=new rd(this.app,this.plugin,this.plugin.settings.macros,this.choiceExecutor,this.variables),Z=await b.runAndGetOutput(G)??"";return Object.keys(b.params.variables).forEach(c=>{this.variables.set(c,b.params.variables[c])}),Z}async getTemplateContent(G){return await new Xb(this.app,this.plugin,G,this.choiceExecutor).run()}async getSelectedText(){let G=this.app.workspace.getActiveViewOfType(GR.MarkdownView);return G?G.editor.getSelection():""}async replaceInlineJavascriptInString(G){let b=G;for(;qc.test(b);){let c=qc.exec(b)?.at(1)?.trim();if(c){let W=new Od(this.app,this.plugin,this.choiceExecutor,this.variables),d=await W.runAndGetOutput(c);for(let N in W.params.variables)this.variables.set(N,W.params.variables[N]);b=typeof d=="string"?this.replacer(b,qc,d):this.replacer(b,qc,"")}}return b}async collectValuesManually(G,b){let Z=new Set,c=this.app.vault.getMarkdownFiles();c=FN.filterFiles(c,b,d=>this.app.metadataCache.getFileCache(d));let W=50;for(let d=0;d<c.length;d+=W){let m=c.slice(d,d+W).map(async V=>{let h=new Set;try{let X=this.app.metadataCache.getFileCache(V)?.frontmatter?.[G];if(X!=null){if(Array.isArray(X))X.forEach(H=>{let w=String(H).trim();w&&h.add(w)});else if(typeof X!="object"){let H=String(X).trim();H&&h.add(H)}}if(b.inline)try{let H=await this.app.vault.read(V);PZ.getFieldValues(H,G).forEach(u=>h.add(u))}catch(H){console.warn(`Could not read file ${V.path} for inline field parsing:`,H)}}catch(a){console.warn(`Could not process metadata for file ${V.path}:`,a)}return h}),Y=await Promise.all(m);for(let V of Y)for(let h of V)Z.add(h)}return Z}};var lR=require("obsidian");var Hc=class extends SZ{constructor(G,b,Z){super(G);this.plugin=b;this.templater=vd(G),this.formatter=new sl(G,b,Z)}async getOrCreateFolder(G){let b;if(G.length>1){if(b=await aG.Suggest(this.app,G,G),!b)throw new Error("No folder selected.")}else b=G[0];return b?await this.createFolder(b):b="",b}async getFormattedFilePath(G,b,Z){let c=await this.formatter.formatFileName(b,Z);return this.normalizeMarkdownFilePath(G,c)}getTemplateExtension(G){return Sc.test(G)?".canvas":".md"}normalizeTemplateFilePath(G,b,Z){let c=G?`${G}/`:"",W=this.getTemplateExtension(Z),d=b.replace(Tc,"").replace(Sc,"");return`${c}${d}${W}`}async incrementFileName(G){let b=Yd.exec(G),Z=b&&typeof b.at=="function"?b?.at(1):void 0,c=await this.app.vault.adapter.exists(G),W=G,d=Sc.test(G)?".canvas":".md";if(c&&Z){let m=parseInt(Z);if(!m)throw new Error("detected numbers but couldn't get them.");W=W.replace(Yd,`${m+1}${d}`)}else c&&(W=W.replace(Yd,`1${d}`));return await this.app.vault.adapter.exists(W)&&(W=await this.incrementFileName(W)),W}async createFileWithTemplate(G,b){try{let Z=await this.getTemplateContent(b),c=await this.formatter.formatFileContent(Z),W=await this.createFileWithInput(G,c);return await jZ(this.app,W),W}catch(Z){return wI(Z,"Could not create file with template"),null}}async overwriteFileWithTemplate(G,b){try{let Z=await this.getTemplateContent(b),c=await this.formatter.formatFileContent(Z);return await this.app.vault.modify(G,c),await jZ(this.app,G),G}catch(Z){return wI(Z,"Could not overwrite file with template"),null}}async appendToFileWithTemplate(G,b,Z){try{let c=await this.getTemplateContent(b),W=await this.formatter.formatFileContent(c),d=await this.app.vault.cachedRead(G),N=Z==="top"?`${W}
|
||||
${d}`:`${d}
|
||||
${W}`;return await this.app.vault.modify(G,N),await jZ(this.app,G),G}catch(c){return wI(c,"Could not append to file with template"),null}}async getTemplateContent(G){let b=G;!Tc.test(G)&&!Sc.test(G)&&(b+=".md");let Z=this.app.vault.getAbstractFileByPath(b);if(!(Z instanceof lR.TFile))throw new Error(`Template file not found at path "${b}".`);return await this.app.vault.cachedRead(Z)}};var Xb=class extends Hc{constructor(G,b,Z,c){super(G,b,c);this.templatePath=Z}async run(){let G=await this.getTemplateContent(this.templatePath);return G||U.logError(`Template ${this.templatePath} not found.`),G=await this.formatter.formatFileContent(G),G}};var kG=class extends Vb{constructor(G,b){super();this.app=G;this.plugin=b}async format(G){let b=G;try{b=this.replaceDateInString(b),b=this.replaceTimeInString(b),b=await this.replaceValueInString(b),b=await this.replaceDateVariableInString(b),b=await this.replaceVariableInString(b),b=await this.replaceLinkToCurrentFileInString(b),b=await this.replaceMacrosInString(b),b=await this.replaceTemplateInString(b),b=await this.replaceFieldVarInString(b),b=this.replaceLinebreakInString(b)}catch{return G}return b}promptForValue(G){return G||"user input"}getVariableValue(G){return yd(G)}getCurrentFileLink(){return Ad(this.app.workspace.getActiveFile())}getNaturalLanguageDates(){return vl(this.app)}suggestForValue(G){return gd(G)}getMacroValue(G){return ed(G)}promptForMathValue(){return Promise.resolve("calculation_result")}promptForVariable(G){return Promise.resolve(Cd(G))}async getTemplateContent(G){try{return await new Xb(this.app,this.plugin,G,void 0).run()}catch{return`Template (not found): ${G}`}}async getSelectedText(){return"selected_text"}async suggestForField(G){return Promise.resolve(`${G}_field_value`)}async replaceDateVariableInString(G){let b=G;return b=b.replace(new RegExp(Mb.source,"gi"),(Z,c,W)=>{let d=c?.trim(),N=W?.trim();if(!d||!N)return Z;let m=new Date,Y;try{Y=tl.generate(N,m)}catch{Y=`[${N} format]`}return Y}),b}};var pc=class extends Yb{constructor(G,b,Z){super(G);this.plugin=Z;this.choice=b,this.display()}display(){this.containerEl.addClass("captureChoiceBuilder"),this.contentEl.empty(),this.addCenteredChoiceNameHeader(this.choice),this.addCapturedToSetting(),this.choice?.captureToActiveFile||(this.addCreateIfNotExistsSetting(),this.choice?.createFileIfItDoesntExist?.enabled&&this.addCreateWithTemplateSetting()),this.addTaskSetting(),this.addPrependSetting(),this.addAppendLinkSetting(),this.addInsertAfterSetting(),this.choice.captureToActiveFile||(this.addOpenFileSetting(),this.choice.openFile&&this.addOpenFileInNewTabSetting()),this.addFormatSetting()}addCapturedToSetting(){let G;new eI.Setting(this.contentEl).setName("Capture To").setDesc("File to capture to. Supports some format syntax.");let b=this.contentEl.createDiv("captureToContainer"),Z=b.createDiv("captureToActiveFileContainer"),c=Z.createEl("span");c.textContent="Capture to active file";let W=new eI.ToggleComponent(Z);if(W.setValue(this.choice?.captureToActiveFile),W.onChange(d=>{this.choice.captureToActiveFile=d,this.reload()}),!this.choice?.captureToActiveFile){let d=b.createDiv("captureToFileContainer"),N=d.createEl("span"),m=new DZ(this.app);(async()=>N.textContent=await m.format(this.choice.captureTo))();let Y=new eI.TextComponent(d);Y.setPlaceholder("File name format"),G=Y,Y.inputEl.style.width="100%",Y.inputEl.style.marginBottom="8px",Y.setValue(this.choice.captureTo).setDisabled(this.choice?.captureToActiveFile).onChange(async h=>{this.choice.captureTo=h,N.textContent=await m.format(h)});let V=[...this.app.vault.getMarkdownFiles().map(h=>h.path),...F2];new mG(this.app,G.inputEl,V,50)}}addPrependSetting(){new eI.Setting(this.contentEl).setName("Write to bottom of file").setDesc(`Put value at the bottom of the file - otherwise at the ${this.choice?.captureToActiveFile?"active cursor location":"top"}.`).addToggle(b=>{b.setValue(this.choice.prepend),b.onChange(Z=>{this.choice.prepend=Z,this.choice.prepend&&this.choice.insertAfter.enabled&&(this.choice.insertAfter.enabled=!1,this.reload())})})}addTaskSetting(){new eI.Setting(this.contentEl).setName("Task").setDesc("Formats the value as a task.").addToggle(b=>{b.setValue(this.choice.task),b.onChange(Z=>this.choice.task=Z)})}addAppendLinkSetting(){new eI.Setting(this.contentEl).setName("Append link").setDesc("Add a link on your current cursor position, linking to the file you're capturing to.").addToggle(b=>{b.setValue(this.choice.appendLink),b.onChange(Z=>this.choice.appendLink=Z)})}addInsertAfterSetting(){let G;new eI.Setting(this.contentEl).setName("Insert after").setDesc("Insert capture after specified line. Accepts format syntax.").addToggle(W=>{W.setValue(this.choice.insertAfter.enabled),W.onChange(d=>{this.choice.insertAfter.enabled=d,G.setDisabled(!d),this.choice.insertAfter.enabled&&this.choice.prepend&&(this.choice.prepend=!1),this.reload()})});let Z=this.contentEl.createEl("span"),c=new kG(this.app,this.plugin);(async()=>Z.innerText=awai
Line truncated
|
||||
${v?"Deleting this choice will delete all ("+n.choices.length+") choices inside it!":""}
|
||||
${y?"Deleting this choice will delete the macro associated with it!":""}
|
||||
`)&&(y&&(G(9,Z=Z.filter(t=>t.id!==n.macroId)),W(Z)),G(0,b=b.filter(t=>hR(n.id,t))),N.removeCommandForChoice(n),c(b))}async function V(F){let{choice:n}=F.detail,y;if(n.type==="Multi"){y=n;let v=await yI.Prompt(d,`Rename ${n.name}`,"",n.name);if(!v)return;y.name=v}else{let v=H(n);if(!v)throw new Error("Invalid choice type");y=await v.waitForClose}y&&(G(0,b=b.map(v=>mV(v,y))),N.removeCommandForChoice(n),N.addCommandForChoice(y),c(b))}async function h(F){let{choice:n}=F.detail,y={...n,command:!n.command};y.command?N.addCommandForChoice(y):N.removeCommandForChoice(y),G(0,b=b.map(v=>mV(v,y))),c(b)}async function a(F){let{choice:n}=F.detail,y=X(n);G(0,b=[...b,y]),c(b)}function X(F){if(!f2(F))throw new Error("Invalid choice type");let n;switch(F.type){case"Template":n=new gb(`${F.name} (copy)`);break;case"Capture":n=new Ab(`${F.name} (copy)`);break;case"Macro":n=new xc(`${F.name} (copy)`);break;case"Multi":n=new Lb(`${F.name} (copy)`);break}return F.type!=="Multi"?Object.assign(n,q2(F,["id","name"])):n.choices=F.choices.map(y=>X(y)),n}function H(F){switch(F.type){case"Template":return new TZ(d,F,N);case"Capture":return new pc(d,F,N);case"Macro":return new wN(d,F,Z,M.getState().choices);case"Multi":default:break}}async function w(){let F=await new vN(d,N,Z,b).waitForClose;F&&(W(F),G(9,Z=F))}async function u(){let F=await new EN(d,M.getState().ai).waitForClose;F&&M.setState(n=>({...n,ai:F}))}function s(F){b=F,G(0,b)}let C=F=>c(F.detail.choices);return l.$$set=F=>{"choices"in F&&G(0,b=F.choices),"macros"in F&&G(9,Z=F.macros),"saveChoices"in F&&G(1,c=F.saveChoices),"saveMacros"in F&&G(10,W=F.saveMacros),"app"in F&&G(11,d=F.app),"plugin"in F&&G(12,N=F.plugin)},[b,c,m,Y,V,h,a,w,u,Z,W,d,N,s,C]}var YV=class extends RI{constructor(I){super(),pI(this,I,eu,yu,HI,{choices:0,macros:9,saveChoices:1,saveMacros:10,app:11,plugin:12},Ju)}},aR=YV;var Cu={name:"OpenAI",endpoint:"https://api.openai.com/v1",apiKey:"",models:[{name:"text-davinci-003",maxTokens:4096},{name:"gpt-3.5-turbo",maxTokens:4096},{name:"gpt-3.5-turbo-16k",maxTokens:16384},{name:"gpt-3.5-turbo-1106",maxTokens:16385},{name:"gpt-4",maxTokens:8192},{name:"gpt-4-32k",maxTokens:32768},{name:"gpt-4-1106-preview",maxTokens:128e3},{name:"gpt-4-turbo",maxTokens:128e3},{name:"gpt-4o",maxTokens:128e3},{name:"gpt-4o-mini",maxTokens:128e3}]},JN=[Cu];var id={choices:[],macros:[],inputPrompt:"single-line",devMode:!1,templateFolderPath:"",announceUpdates:!0,version:"0.0.0",disableOnlineFeatures:!0,enableRibbonIcon:!1,ai:{defaultModel:"Ask me",defaultSystemPrompt:'As an AI assistant within Obsidian, your primary goal is to help users manage their ideas and knowledge more effectively. Format your responses using Markdown syntax. Please use the [[Obsidian]] link format. You can write aliases for the links by writing [[Obsidian|the alias after the pipe symbol]]. To use mathematical notation, use LaTeX syntax. LaTeX syntax for larger equations should be on separate lines, surrounded with double dollar signs ($$). You can also inline math expressions by wrapping it in $ symbols. For example, use $$w_{ij}^{ ext{new}}:=w_{ij}^{ ext{current}}+etacdotdelta_jcdot x_{ij}$$ on a separate line, but you can write "($eta$ = learning rate, $delta_j$ = error term, $x_{ij}$ = input)" inline.',promptTemplatesFolderPath:"",showAssistant:!0,providers:JN},migrations:{migrateToMacroIDFromEmbeddedMacro:!1,useQuickAddTemplateFolder:!1,incrementFileNameSettingMoveToDefaultBehavior:!1,mutualExclusionInsertAfterAndWriteToBottomOfFile:!1,setVersionAfterUpdateModalRelease:!1,addDefaultAIProviders:!1}},sN=class extends Rl.PluginSettingTab{constructor(I,G){super(I,G),this.plugin=G}display(){let{containerEl:I}=this;I.empty(),I.createEl("h2",{text:"QuickAdd Settings"}),this.addChoicesSetting(),this.addUseMultiLineInputPromptSetting(),this.addTemplateFolderPathSetting(),this.addAnnounceUpdatesSetting(),this.addDisableOnlineFeaturesSetting(),this.addEnableRibbonIconSetting()}addAnnounceUpdatesSetting(){let I=new Rl.Setting(this.containerEl);I.setName("Announce Updates"),I.setDesc("Display release notes when a new version is installed. This includes new features, demo videos, and bug fixes."),I.addToggle(G=>{G.setValue(M.getState().announceUpdates),G.onChange(b=>{M.setState({announceUpdates:b})})})}hide(){this.choiceView&&this.choiceView.$destroy()}addChoicesSetting(){let I=new Rl.Setting(this.containerEl);I.infoEl.remove(),I.settingEl.style.display="block",this.choiceView=new aR({target:I.settingEl,props:{app:this.app,plugin:this.plugin,choices:M.getState().choices,saveChoices:G=>{M.setState({choices:G})},macros:M.getState().macros,saveMacros:G=>{M.setState({macros:G})}}})}addUseMultiLineInputPromptSetting(){new Rl.Setting(this.containerEl).setName("Use Multi-line Input Prompt").setDesc("Use multi-line input prompt instead of single-line input prompt").addToggle(I=>I.setValue(this.plugin.settings.inputPrompt==="multi-line").setTooltip("Use multi-line input prompt").onChange(G=>{G?M.setState({inputPrompt:
Line truncated
|
||||
`:""}${Z}`}if(this.choice.insertAfter.enabled)return await this.insertAfterHandler(Z);let W=this.file?this.getFrontmatterEndPosition(this.file):null;return W?this.insertTextAfterPositionInBody(Z,this.fileContent,W):`${Z}${this.fileContent}`}async formatContentOnly(G){let b=await super.formatFileContent(G);return b=this.replaceLinebreakInString(b),b.trim()===""?this.fileContent:b}async insertAfterHandler(G){let b=await this.format(this.choice.insertAfter.after),Z=new RegExp(`\\s*${pa(b.replace("\\n",""))}\\s*`),c=HY(this.fileContent),W=c.findIndex(N=>Z.test(N));if(W===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(G);wI(new Error("Unable to find insert after line in file"),"Insert After Error")}if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");W=gN(c,W,!!this.choice.insertAfter.considerSubsections)??c.length-1}return this.insertTextAfterPositionInBody(G,this.fileContent,W)}async createInsertAfterIfNotFound(G){let Z=`${this.replaceLinebreakInString(await this.format(this.choice.insertAfter.after))}
|
||||
${G}`;if(this.choice.insertAfter?.createIfNotFoundLocation===Dc){let c=this.file?this.getFrontmatterEndPosition(this.file):-1;return this.insertTextAfterPositionInBody(Z,this.fileContent,c)}if(this.choice.insertAfter?.createIfNotFoundLocation===Vd)return`${this.fileContent}
|
||||
${Z}`;if(this.choice.insertAfter?.createIfNotFoundLocation===hd)try{let c=this.app.workspace.getActiveViewOfType(QR.MarkdownView);if(!c)throw new Error("No active view.");let d=c.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let m=HY(this.fileContent);d=gN(m,d,!!this.choice.insertAfter.considerSubsections)??m.length-1}return this.insertTextAfterPositionInBody(Z,this.fileContent,d)}catch(c){wI(c,`Unable to insert line '${this.choice.insertAfter.after}' at cursor position`)}}getFrontmatterEndPosition(G){let b=this.app.metadataCache.getFileCache(G);return!b||!b.frontmatter?(U.logMessage("could not get frontmatter. Maybe there isn't any."),-1):b.frontmatterPosition?b.frontmatterPosition.end.line:-1}insertTextAfterPositionInBody(G,b,Z){if(Z===-1){let N=!this.choice.task;return`${G}${N?`
|
||||
`:""}${b}`}let c=b.split(`
|
||||
`),W=c.slice(0,Z+1).join(`
|
||||
`),d=c.slice(Z+1).join(`
|
||||
`);return`${W}
|
||||
${G}${d}`}};var LN=class{isResolved(){return!this.hasConflicts}isConflicted(){return this.hasConflicts}},JW=class l extends LN{constructor(I,G,b){super(),this.left=I,this.base=G,this.right=b,this.hasConflicts=!0}static create(I){return new l(I.left,I.base,I.right)}apply(I){return l.create({left:I(this.left),base:I(this.base),right:I(this.right)})}},_G=class l extends LN{constructor(I){super(),this.hasConflicts=!1,this.result=I}combine(I){this.result=this.result.concat(I.result)}apply(I){return new l(I(this.result))}};var Pl=class l{constructor(I,G){this.left=I,this.right=G}static executeDiff(I,G){if(!I.push)throw new Error("Argument is not an array");let b=l.diff(I,G);return new aV(I,G,b).convertToTypedOutput()}static diff(I,G){return new l(I,G).performDiff()}performDiff(){let I=this.identifyUniquePositions();I.sort((c,W)=>W[0]-c[0]);let[G,b]=this.findNextChange(),Z=new oN(G,b,[]);return I.forEach(c=>{Z=this.getDifferences(Z,c)}),Z.changeRanges}getDifferences(I,G){let[b,Z]=[I.leftChangePos,I.rightChangePos],[c,W]=G;if(c<b||W<Z)return I;{let[d,N,m,Y]=this.findPrevChange(b,Z,c-1,W-1),[V,h]=this.findNextChange(c+1,W+1),a=this.appendChangeRange(I.changeRanges,d,N,m,Y);return new oN(V,h,a)}}findNextChange(I=0,G=0){let b=this.left.slice(I)||[],Z=this.right.slice(G)||[],c=this.mismatchOffset(b,Z);return[I+c,G+c]}findPrevChange(I,G,b,Z){if(I>b||G>Z)return[I,b,G,Z];{let c=this.left.slice(I,b+1).reverse()||[],W=this.right.slice(G,Z+1).reverse()||[],d=this.mismatchOffset(c,W);return[I,b-d,G,Z-d]}}mismatchOffset(I,G){let b=Math.max(I.length,G.length);for(let Z=0;Z<b;Z++)if(I[Z]!==G[Z])return Z;return Math.min(I.length,G.length)}identifyUniquePositions(){let I=this.findUnique(this.left),G=this.findUnique(this.right),b=new Set(...I.keys()),Z=new Set(...G.keys()),W=[...new Set([...b].filter(d=>Z.has(d)))].map(d=>[I.get(d),G.get(d)]);return W.unshift([this.left.length,this.right.length]),W}findUnique(I){let G=new Map;I.forEach((Z,c)=>{G.set(Z,new hV(c,!G.has(Z)))});let b=new Map;for(let[Z,c]of G.entries())c.unique&&b.set(Z,c.pos);return b}appendChangeRange(I,G,b,Z,c){return G<=b&&Z<=c?I.push(new sW(ol.change,G+1,b+1,Z+1,c+1)):G<=b?I.push(new sW(ol.remove,G+1,b+1,Z+1,Z)):Z<=c&&I.push(new sW(ol.add,G+1,G,Z+1,c+1)),I}},hV=class{constructor(I,G){this.pos=I,this.unique=G}},wc=class{constructor(I,G){this.text=I,this.low=G}},aV=class{constructor(I,G,b){this.oldTextArray=I,this.newTextArray=G,this.chunks=b,this.oldText=[],this.newText=[]}convertToTypedOutput(){let I=new FV(0,0);return this.chunks.forEach(G=>{let[b,Z]=this.setTextNodeIndexes(G,I.oldIndex,I.newIndex),[c,W]=this.appendChanges(G,I.oldIndex+b,I.newIndex+Z);I.oldIndex=c,I.newIndex=W}),this.setTheRemainingTextNodeIndexes(I.oldIndex,I.newIndex),{oldText:this.oldText,newText:this.newText}}setTextNodeIndexes(I,G,b){let Z=0;for(;G+Z<I.leftLo-1;)this.oldText.push(new wc(this.oldTextArray[G+Z],b+Z)),Z+=1;let c=0;for(;b+c<I.rightLo-1;)this.newText.push(new wc(this.newTextArray[b+c],G+c)),c+=1;return[Z,c]}appendChanges(I,G,b){for(;G<=I.leftHi-1;)this.oldText.push(this.oldTextArray[G]),G+=1;for(;b<=I.rightHi-1;)this.newText.push(this.newTextArray[b]),b+=1;return[G,b]}setTheRemainingTextNodeIndexes(I,G){let b=0;for(;I+b<this.oldTextArray.length;)this.oldText.push(new wc(this.oldTextArray[I+b],G+b)),b+=1;for(;G+b<this.newTextArray.length;)this.newText.push(new wc(this.newTextArray[G+b],I+b)),b+=1}},FV=class{constructor(I,G){this.oldIndex=I,this.newIndex=G}},ol;(function(l){l.change="change",l.add="add",l.remove="remove"})(ol||(ol={}));var sW=class{constructor(I,G,b,Z,c){this.action=I,this.leftLo=G,this.leftHi=b,this.rightLo=Z,this.rightHi=c}},oN=class{constructor(I,G,b){this.leftChangePos=I,this.rightChangePos=G,this.changeRanges=b}};var kN=class l{constructor(I,G,b,Z,c){this.code=I,this.baseLo=G,this.baseHi=b,this.sideLo=Z,this.sideHi=c}static fromChangeRange(I){return new l(I.action,I.leftLo,I.leftHi,I.rightLo,I.rightHi)}},vc=class l{constructor(I,G,b){this.left=I,this.base=G,this.right=b}static executeDiff(I,G,b){return new l(I,G,b).getDifferences()}getDifferences(){let I=Pl.diff(this.base,this.left).map(b=>kN.fromChangeRange(b)),G=Pl.diff(this.base,this.right).map(b=>kN.fromChangeRange(b));return this.collapseDifferences(new iN(I,G))}collapseDifferences(I,G=[]){if(I.isFinished())return G;{let b=new iN,Z=I.chooseSide(),c=I.dequeue();return b.enqueue(Z,c),I.switchSides(),this.buildResultQueue(I,c.baseHi,b),G.push(this.determineDifference(b,Z,I.switchSides())),this.collapseDifferences(I,G)}}buildResultQueue(I,G,b){if(this.queueIsFinished(I.peek(),G))return b;{let Z=I.dequeue();return b.enqueue(I.currentSide,Z),G<Z.baseHi?(I.switchSides(),this.buildResultQueue(I,Z.baseHi,b)):this.buildResultQueue(I,G,b)}}queueIsFinished(I,G){return I.length===0||I[0].baseLo>G+1}determineDifference(I,G,b){let Z=I.get(G)[0].baseLo,c=I.get(b),W=c[c.length-1].baseHi,[d,N]=this.diffableEndpoints(I.get(SI.left),Z,W),[m,Y]=this.diffableEndpoints(I.get(SI.right),Z,W),V=this.left.slice(d-1,N),h=this.right.
Line truncated
|
||||
`)}}).join(`
|
||||
`)}}var _5=G=>G.join(""),tn=G=>G.split(/\b/),En=q5("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",_5),un={splitFunction:tn,joinFunction:_5,conflictFunction:En};function ga(G,I,l,c={}){c=Object.assign({},un,c);let[b,Z,d]=[G,I,l].map(m=>c.splitFunction.call(c,m)),W=RG.merge(b,Z,d);return XG.collateMerge(W,c.joinFunction,c.conflictFunction)}var $5=ga;var IW=class extends R1{constructor(l,c,b,Z){super(l);this.choiceExecutor=Z;this.choice=b,this.plugin=c,this.formatter=new Pd(l,c,Z)}async run(){try{let l=await this.getFormattedPathToCaptureTo(this.choice.captureToActiveFile),c=this.getCaptureContent(),b;if(await this.fileExists(l))b=this.onFileExists.bind(this);else if(this.choice?.createFileIfItDoesntExist?.enabled)b=this.onCreateFileIfItDoesntExist.bind(this);else{B.logWarning(`The file ${l} does not exist and "Create file if it doesn't exist" is disabled.`);return}let{file:Z,newFileContent:d,captureContent:W}=await b(l,c);if(this.choice.captureToActiveFile&&!this.choice.prepend&&!this.choice.insertAfter.enabled){let a=await jZ(this.app,W,Z);pb(a,this.app)}else await this.app.vault.modify(Z,d),await a1(this.app,Z);if(this.choice.appendLink){let a=this.app.fileManager.generateMarkdownLink(Z,"");pb(a,this.app)}this.choice.openFile&&Z&&(CZ(this.app,Z)||await TZ(this.app,Z,{openInNewTab:this.choice.openFileInNewTab.enabled,direction:this.choice.openFileInNewTab.direction,focus:this.choice.openFileInNewTab.focus,mode:this.choice.openFileInMode}))}catch(l){EI(l,`Error running capture choice "${this.choice.name}"`)}}getCaptureContent(){let l;return this.choice.format.enabled?l=this.choice.format.format:l=IG,this.choice.task&&(l=`- [ ] ${l}
|
||||
`),l}async getFormattedPathToCaptureTo(l){if(l){let m=this.app.workspace.getActiveFile();return Bl(m,"Cannot capture to active file - no active file."),m.path}let c=this.choice.captureTo,b=await this.formatFilePath(c),Z=b.replace(/^\/$|\/\.md$|^\.md$/,""),d=Z==="",W=d||oV(this.app,Z),a=b.startsWith("#");if(W)return this.selectFileInFolder(Z,d);if(a){let m=b.replace(/\.md$/,"");return this.selectFileWithTag(m)}return b}async selectFileInFolder(l,c){let b=l.endsWith("/")||c?l:`${l}/`,Z=m1(this.app,b);Bl(Z.length>0,`Folder ${b} is empty.`);let d=Z.map(m=>m.path),W=await B2.Suggest(this.app,d.map(m=>m.replace(b,"")),d);Bl(!!W&&W.length>0,"No file selected for capture.");let a=W.startsWith(`${b}`)?W:`${b}/${W}`;return await this.formatFilePath(a)}async selectFileWithTag(l){let c=l.startsWith("#")?l:`#${l}`,b=iV(this.app,c);Bl(b.length>0,`No files with tag ${l}.`);let Z=b.map(W=>W.path),d=await B2.Suggest(this.app,Z,Z);return Bl(!!d&&d.length>0,"No file selected for capture."),await this.formatFilePath(d)}async onFileExists(l,c){let b=this.getFileByPath(l);if(!b)throw new Error("File not found");let Z=await this.formatter.formatContentOnly(c),d=await this.app.vault.read(b),W=await this.formatter.formatContentWithFile(Z,this.choice,d,b),a=await this.app.vault.read(b),m=W;if(a!==d){let V=$5(a,d,W);Bl(!V.isSuccess,()=>`The file ${l} has been modified since the last read.
|
||||
`)}}var pR=l=>l.join(""),iu=l=>l.split(/\b/),zu=HR("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",pR),xu={splitFunction:iu,joinFunction:pR,conflictFunction:zu};function QV(l,I,G,b={}){b=Object.assign({},xu,b);let[Z,c,W]=[l,I,G].map(m=>b.splitFunction.call(b,m)),d=yW.merge(Z,c,W);return eW.collateMerge(d,b.joinFunction,b.conflictFunction)}var uR=QV;var zN=class extends $Z{constructor(G,b,Z,c){super(G);this.choiceExecutor=c;this.choice=Z,this.plugin=b,this.formatter=new AN(G,b,c)}async run(){try{let G=await this.getFormattedPathToCaptureTo(this.choice.captureToActiveFile),b=this.getCaptureContent(),Z;if(await this.fileExists(G))Z=this.onFileExists.bind(this);else if(this.choice?.createFileIfItDoesntExist?.enabled)Z=this.onCreateFileIfItDoesntExist.bind(this);else{U.logWarning(`The file ${G} does not exist and "Create file if it doesn't exist" is disabled.`);return}let{file:c,newFileContent:W,captureContent:d}=await Z(G,b);if(this.choice.captureToActiveFile&&!this.choice.prepend&&!this.choice.insertAfter.enabled){let N=await td(this.app,d,c);$c(N,this.app)}else await this.app.vault.modify(c,W),await jZ(this.app,c);if(this.choice.appendLink){let N=this.app.fileManager.generateMarkdownLink(c,"");$c(N,this.app)}this.choice.openFile&&c&&(Jd(this.app,c)||await Ed(this.app,c,{openInNewTab:this.choice.openFileInNewTab.enabled,direction:this.choice.openFileInNewTab.direction,focus:this.choice.openFileInNewTab.focus,mode:this.choice.openFileInMode}))}catch(G){wI(G,`Error running capture choice "${this.choice.name}"`)}}getCaptureContent(){let G;return this.choice.format.enabled?G=this.choice.format.format:G=Ob,this.choice.task&&(G=`- [ ] ${G}
|
||||
`),G}async getFormattedPathToCaptureTo(G){if(G){let m=this.app.workspace.getActiveFile();return CG(m,"Cannot capture to active file - no active file."),m.path}let b=this.choice.captureTo,Z=await this.formatFilePath(b),c=Z.replace(/^\/$|\/\.md$|^\.md$/,""),W=c==="",d=W||P2(this.app,c),N=Z.startsWith("#");if(d)return this.selectFileInFolder(c,W);if(N){let m=Z.replace(/\.md$/,"");return this.selectFileWithTag(m)}return Z}async selectFileInFolder(G,b){let Z=G.endsWith("/")||b?G:`${G}/`,c=KZ(this.app,Z);CG(c.length>0,`Folder ${Z} is empty.`);let W=c.map(m=>m.path),d=await el.Suggest(this.app,W.map(m=>m.replace(Z,"")),W);CG(!!d&&d.length>0,"No file selected for capture.");let N=d.startsWith(`${Z}`)?d:`${Z}/${d}`;return await this.formatFilePath(N)}async selectFileWithTag(G){let b=G.startsWith("#")?G:`#${G}`,Z=_2(this.app,b);CG(Z.length>0,`No files with tag ${G}.`);let c=Z.map(d=>d.path),W=await el.Suggest(this.app,c,c);return CG(!!W&&W.length>0,"No file selected for capture."),await this.formatFilePath(W)}async onFileExists(G,b){let Z=this.getFileByPath(G);if(!Z)throw new Error("File not found");let c=await this.formatter.formatContentOnly(b),W=await this.app.vault.read(Z),d=await this.formatter.formatContentWithFile(c,this.choice,W,Z),N=await this.app.vault.read(Z),m=d;if(N!==W){let Y=uR(N,W,d);CG(!Y.isSuccess,()=>`The file ${G} has been modified since the last read.
|
||||
QuickAdd could not merge the versions two without conflicts, and will not modify the file.
|
||||
This is in order to prevent data loss.`),m=V.joinedResults()}return{file:b,newFileContent:m,captureContent:Z}}async onCreateFileIfItDoesntExist(l,c){let b=await this.formatter.formatContentOnly(c),Z="";this.choice.createFileIfItDoesntExist.createWithTemplate&&(Z=await new Jc(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor).run());let d=await this.createFileWithInput(l,Z),W=await this.app.vault.cachedRead(d),a=await this.formatter.formatContentWithFile(b,this.choice,W,d);return{file:d,newFileContent:a,captureContent:b}}async formatFilePath(l){let c=await this.formatter.formatFileName(l,this.choice.name);return this.normalizeMarkdownFilePath("",c)}};var lW=require("obsidian");var v2=class extends lW.FuzzySuggestModal{constructor(l,c,b){super(l.app);this.plugin=l;this.choices=c;this.choiceExecutor=new mc(this.app,this.plugin);b&&(this.choiceExecutor=b)}static Open(l,c,b){new v2(l,c,b).open()}renderSuggestion(l,c){c.empty(),lW.MarkdownRenderer.renderMarkdown(l.item.name,c,"",this.plugin),c.classList.add("quickadd-choice-suggestion")}getItemText(l){return l.name}getItems(){return this.choices}async onChooseItem(l,c){l.type==="Multi"?this.onChooseMultiType(l):await this.choiceExecutor.execute(l)}onChooseMultiType(l){let c=[...l.choices];l.name!="\u2190 Back"&&c.push(new Cc("\u2190 Back").addChoices(this.choices)),v2.Open(this.plugin,c)}};var mc=class{constructor(I,l){this.app=I;this.plugin=l;this.variables=new Map}async execute(I){switch(I.type){case"Template":{let l=I;await this.onChooseTemplateType(l);break}case"Capture":{let l=I;await this.onChooseCaptureType(l);break}case"Macro":{let l=I;await this.onChooseMacroType(l);break}case"Multi":{let l=I;this.onChooseMultiType(l);break}default:break}}async onChooseTemplateType(I){await new Kd(this.app,this.plugin,I,this).run()}async onChooseCaptureType(I){await new IW(this.app,this.plugin,I,this).run()}async onChooseMacroType(I){let l=new M2(this.app,this.plugin,I,this.plugin.settings.macros,this,this.variables);await l.run(),Object.entries(l.params.variables).forEach(([c,b])=>{this.variables.set(c,b)})}onChooseMultiType(I){v2.Open(this.plugin,I.choices,this)}};var I4={description:"Migrate to macro ID from embedded macro in macro choices.",migrate:async G=>{function I(l){if(l.type==="Multi"){let b=l,Z=b.choices.map(I);return b={...b,choices:Z},b}if(l.type!=="Macro")return l;let c=l;return c.macro&&(c.macroId=c.macro.id,delete c.macro),c}G.settings.choices=G.settings.choices.map(I),await G.saveSettings()}};var l4={description:"Use QuickAdd template folder instead of Obsidian templates plugin folder / Templater templates folder.",migrate:async G=>{try{let I=G.app.plugins.plugins.templater,l=G.app.internalPlugins.plugins.templates;if(!I&&!l){B.logMessage("No template plugin found. Skipping migration.");return}if(l){let c=l.instance.options;c.folder&&(G.settings.templateFolderPath=c.folder,B.logMessage("Migrated template folder path to Obsidian Templates' setting."))}if(I){let c=I.settings;c.template_folder&&(G.settings.templateFolderPath=c.template_folder,B.logMessage("Migrated template folder path to Templaters setting."))}}catch(I){throw B.logError("Failed to migrate template folder path."),I}}};function cW(G){return G===null||typeof G!="object"||!("type"in G)||!("choices"in G)?!1:G.type==="Multi"&&G.choices!==void 0}function GW(G){return G===null||typeof G!="object"||!("choice"in G)?!1:G.choice!==void 0}function za(G){return typeof G!="object"||G===null?!1:"incrementFileName"in G}function c4(G){for(let I of G)cW(I)&&(I.choices=c4(I.choices)),za(I)&&(I.setFileExistsBehavior=!0,I.fileExistsMode="Increment the file name",delete I.incrementFileName);return G}function Qn(G){for(let I of G)if(Array.isArray(I.commands))for(let l of I.commands)GW(l)&&za(l.choice)&&(l.choice.setFileExistsBehavior=!0,l.choice.fileExistsMode="Increment the file name",delete l.choice.incrementFileName);return G}var vn={description:"'Increment file name' setting moved to 'Set default behavior if file already exists' setting",migrate:async G=>{let I=structuredClone(G.settings.choices),l=c4(I),c=structuredClone(G.settings.macros),b=Qn(c);G.settings.choices=structuredClone(l),G.settings.macros=structuredClone(b)}},G4=vn;function xa(G){return G.type==="Capture"}function b4(G){for(let I of G)cW(I)&&(I.choices=b4(I.choices)),xa(I)&&I.insertAfter.enabled&&I.prepend&&(I.prepend=!1);return G}function Jn(G){for(let I of G)if(Array.isArray(I.commands))for(let l of I.commands)GW(l)&&xa(l.choice)&&l.choice.insertAfter.enabled&&l.choice.prepend&&(l.choice.prepend=!1);return G}var wn={description:"Mutual exclusion of insertAfter and writeToBottomOfFile settings. If insertAfter is enabled, writeToBottomOfFile is disabled. To support changes in settings UI.",migrate:async G=>{let I=structuredClone(G.settings.choices),l=b4(I),c=structuredClone(G.settings.macros),b=Jn(c);G.settings.choices=l,G.settings.macros=b}},Z4=wn;var yn={description:"Set version to the current plugin ve
Line truncated
|
||||
This is in order to prevent data loss.`),m=Y.joinedResults()}return{file:Z,newFileContent:m,captureContent:c}}async onCreateFileIfItDoesntExist(G,b){let Z=await this.formatter.formatContentOnly(b),c="";this.choice.createFileIfItDoesntExist.createWithTemplate&&(c=await new Xb(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor).run());let W=await this.createFileWithInput(G,c),d=await this.app.vault.cachedRead(W),N=await this.formatter.formatContentWithFile(Z,this.choice,d,W);return{file:W,newFileContent:N,captureContent:Z}}async formatFilePath(G){let b=await this.formatter.formatFileName(G,this.choice.name);return this.normalizeMarkdownFilePath("",b)}};var xN=require("obsidian");var Qb=class l extends xN.FuzzySuggestModal{constructor(G,b,Z){super(G.app);this.plugin=G;this.choices=b;this.choiceExecutor=new $l(this.app,this.plugin);Z&&(this.choiceExecutor=Z)}static Open(G,b,Z){new l(G,b,Z).open()}renderSuggestion(G,b){b.empty(),xN.MarkdownRenderer.renderMarkdown(G.item.name,b,"",this.plugin),b.classList.add("quickadd-choice-suggestion")}getItemText(G){return G.name}getItems(){return this.choices}async onChooseItem(G,b){G.type==="Multi"?this.onChooseMultiType(G):await this.choiceExecutor.execute(G)}onChooseMultiType(G){let b=[...G.choices];G.name!="\u2190 Back"&&b.push(new Lb("\u2190 Back").addChoices(this.choices)),l.Open(this.plugin,b)}};var $l=class{constructor(I,G){this.app=I;this.plugin=G;this.variables=new Map}async execute(I){switch(I.type){case"Template":{let G=I;await this.onChooseTemplateType(G);break}case"Capture":{let G=I;await this.onChooseCaptureType(G);break}case"Macro":{let G=I;await this.onChooseMacroType(G);break}case"Multi":{let G=I;this.onChooseMultiType(G);break}default:break}}async onChooseTemplateType(I){await new CN(this.app,this.plugin,I,this).run()}async onChooseCaptureType(I){await new zN(this.app,this.plugin,I,this).run()}async onChooseMacroType(I){let G=new yl(this.app,this.plugin,I,this.plugin.settings.macros,this,this.variables);await G.run(),Object.entries(G.params.variables).forEach(([b,Z])=>{this.variables.set(b,Z)})}onChooseMultiType(I){Qb.Open(this.plugin,I.choices,this)}};var nR={description:"Migrate to macro ID from embedded macro in macro choices.",migrate:async l=>{function I(G){if(G.type==="Multi"){let Z=G,c=Z.choices.map(I);return Z={...Z,choices:c},Z}if(G.type!=="Macro")return G;let b=G;return b.macro&&(b.macroId=b.macro.id,delete b.macro),b}l.settings.choices=l.settings.choices.map(I),await l.saveSettings()}};var wR={description:"Use QuickAdd template folder instead of Obsidian templates plugin folder / Templater templates folder.",migrate:async l=>{try{let I=l.app.plugins.plugins.templater,G=l.app.internalPlugins.plugins.templates;if(!I&&!G){U.logMessage("No template plugin found. Skipping migration.");return}if(G){let b=G.instance.options;b.folder&&(l.settings.templateFolderPath=b.folder,U.logMessage("Migrated template folder path to Obsidian Templates' setting."))}if(I){let b=I.settings;b.template_folder&&(l.settings.templateFolderPath=b.template_folder,U.logMessage("Migrated template folder path to Templaters setting."))}}catch(I){throw U.logError("Failed to migrate template folder path."),I}}};function UN(l){return l===null||typeof l!="object"||!("type"in l)||!("choices"in l)?!1:l.type==="Multi"&&l.choices!==void 0}function BN(l){return l===null||typeof l!="object"||!("choice"in l)?!1:l.choice!==void 0}function HV(l){return typeof l!="object"||l===null?!1:"incrementFileName"in l}function vR(l){for(let I of l)UN(I)&&(I.choices=vR(I.choices)),HV(I)&&(I.setFileExistsBehavior=!0,I.fileExistsMode="Increment the file name",delete I.incrementFileName);return l}function Uu(l){for(let I of l)if(Array.isArray(I.commands))for(let G of I.commands)BN(G)&&HV(G.choice)&&(G.choice.setFileExistsBehavior=!0,G.choice.fileExistsMode="Increment the file name",delete G.choice.incrementFileName);return l}var Bu={description:"'Increment file name' setting moved to 'Set default behavior if file already exists' setting",migrate:async l=>{let I=structuredClone(l.settings.choices),G=vR(I),b=structuredClone(l.settings.macros),Z=Uu(b);l.settings.choices=structuredClone(G),l.settings.macros=structuredClone(Z)}},tR=Bu;function pV(l){return l.type==="Capture"}function ER(l){for(let I of l)UN(I)&&(I.choices=ER(I.choices)),pV(I)&&I.insertAfter.enabled&&I.prepend&&(I.prepend=!1);return l}function ru(l){for(let I of l)if(Array.isArray(I.commands))for(let G of I.commands)BN(G)&&pV(G.choice)&&G.choice.insertAfter.enabled&&G.choice.prepend&&(G.choice.prepend=!1);return l}var Ou={description:"Mutual exclusion of insertAfter and writeToBottomOfFile settings. If insertAfter is enabled, writeToBottomOfFile is disabled. To support changes in settings UI.",migrate:async l=>{let I=structuredClone(l.settings.choices),G=ER(I),b=structuredClone(l.settings.macros),Z=ru(b);l.settings.choices=G,l.settings.macros=Z}},JR=Ou;var Mu={description:"Set version to the current plugin ve
Line truncated
|
||||
|
||||
${b}
|
||||
${Z}
|
||||
|
||||
QuickAdd will now revert to backup.`),G.settings=c}}G.saveSettings()}var a4=rn;var f1=require("obsidian");async function An(G,I,l){let c=await fetch(`https://api.github.com/repos/${G}/${I}/releases`),b=await c.json();if(!c.ok&&"message"in b||!Array.isArray(b))throw new Error(`Failed to fetch releases: ${b.message??"Unknown error"}`);let Z=b.findIndex(d=>d.tag_name===l);if(Z===-1)throw new Error(`Could not find release with tag ${l}`);return b.slice(0,Z).filter(d=>!d.draft&&!d.prerelease)}function gn(G,I=1){let l=G.split(`
|
||||
`);for(let c=0;c<l.length;c++)l[c].startsWith("#")&&(l[c]="#".repeat(I)+l[c]);return l.join(`
|
||||
`)}var bW=class extends f1.Modal{constructor(l,c){super(l);this.previousVersion=c,this.releaseNotesPromise=An("chhoumann","quickadd",c),this.releaseNotesPromise.then(b=>{if(this.releases=b,this.releases.length===0){this.close();return}this.display()}).catch(b=>{B.logError(`Failed to fetch release notes: ${b}`)})}onOpen(){let{contentEl:l}=this;l.empty(),l.createEl("h1",{text:"Fetching release notes..."})}onClose(){let{contentEl:l}=this;l.empty()}display(){let{contentEl:l}=this;l.empty(),l.classList.add("quickadd-update-modal-container");let c=`### New in QuickAdd v${this.releases[0].tag_name}
|
||||
`,b="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",Z='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',d=l.createDiv("quickadd-update-modal"),W=this.releases.map(N=>N.body).join(`
|
||||
QuickAdd will now revert to backup.`),l.settings=b}}l.saveSettings()}var eR=Ku;var tc=require("obsidian");async function Du(l,I,G){let b=await fetch(`https://api.github.com/repos/${l}/${I}/releases`),Z=await b.json();if(!b.ok&&"message"in Z||!Array.isArray(Z))throw new Error(`Failed to fetch releases: ${Z.message??"Unknown error"}`);let c=Z.findIndex(W=>W.tag_name===G);if(c===-1)throw new Error(`Could not find release with tag ${G}`);return Z.slice(0,c).filter(W=>!W.draft&&!W.prerelease)}function Tu(l,I=1){let G=l.split(`
|
||||
`);for(let b=0;b<G.length;b++)G[b].startsWith("#")&&(G[b]="#".repeat(I)+G[b]);return G.join(`
|
||||
`)}var rN=class extends tc.Modal{constructor(I,G){super(I),this.previousVersion=G,this.releaseNotesPromise=Du("chhoumann","quickadd",G),this.releaseNotesPromise.then(b=>{if(this.releases=b,this.releases.length===0){this.close();return}this.display()}).catch(b=>{U.logError(`Failed to fetch release notes: ${b}`)})}onOpen(){let{contentEl:I}=this;I.empty(),I.createEl("h1",{text:"Fetching release notes..."})}onClose(){let{contentEl:I}=this;I.empty()}display(){let{contentEl:I}=this;I.empty(),I.classList.add("quickadd-update-modal-container");let G=`### New in QuickAdd v${this.releases[0].tag_name}
|
||||
`,b="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",Z='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',c=I.createDiv("quickadd-update-modal"),W=this.releases.map(Y=>Y.body).join(`
|
||||
---
|
||||
`),a=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,V=`${c}
|
||||
`),d=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,m=`${G}
|
||||
${b}
|
||||
${Z}
|
||||
I'd love to get your feedback on QuickAdd! Please fill out this <a href="https://forms.gle/WRq1ewcKK8qmkqps6">feedback form</a> to let me know what you think.
|
||||
|
||||
${a}
|
||||
${d}
|
||||
|
||||
---
|
||||
|
||||
${gn(W)}`;f1.MarkdownRenderer.renderMarkdown(V,d,this.app.vault.getRoot().path,new f1.Component)}};var PI=require("obsidian");var ZW=class extends PI.Modal{constructor(l,c){super(l);this.showAdvancedSettings=!1;this.settings=c,this.waitForClose=new Promise((b,Z)=>{this.rejectPromise=Z,this.resolvePromise=b}),this.open(),this.display()}get systemPromptTokenLength(){let l=X2(this.settings.model);return l?Ll(this.settings.systemPrompt,l):Number.POSITIVE_INFINITY}display(){this.contentEl.empty();let l=this.contentEl.createEl("h2",{text:`${this.settings.name} Settings`});l.style.textAlign="center",l.style.cursor="pointer",l.style.userSelect="none",l.addEventListener("click",async()=>{try{let c=await vI.Prompt(this.app,"New name",this.settings.name,this.settings.name);c&&c!==this.settings.name&&(this.settings.name=c,this.reload())}catch{}}),this.addResultJoinerSetting(this.contentEl),this.addChunkSeparatorSetting(this.contentEl),this.addMaxTokensSetting(this.contentEl),this.addMergeChunksSetting(this.contentEl),this.addModelSetting(this.contentEl),this.addOutputVariableNameSetting(this.contentEl),this.addShowAdvancedSettingsToggle(this.contentEl),this.showAdvancedSettings&&(this.settings.modelParameters||(this.settings.modelParameters={}),this.addTemperatureSetting(this.contentEl),this.addTopPSetting(this.contentEl),this.addFrequencyPenaltySetting(this.contentEl),this.addPresencePenaltySetting(this.contentEl)),this.addSystemPromptSetting(this.contentEl)}reload(){this.contentEl.empty(),this.display()}addModelSetting(l){new PI.Setting(l).setName("Model").setDesc("The model the AI Assistant will use").addDropdown(c=>{let b=k2();for(let Z of b)c.addOption(Z,Z);c.addOption("Ask me","Ask me"),c.setValue(this.settings.model),c.onChange(Z=>{this.settings.model=Z,this.reload()})})}addOutputVariableNameSetting(l){new PI.Setting(l).setName("Output variable name").setDesc("The name of the variable used to store the AI Assistant output, i.e. {{value:output}}.").addText(c=>{c.setValue(this.settings.outputVariableName).onChange(b=>{this.settings.outputVariableName=b})})}addSystemPromptSetting(l){new PI.Setting(l).setName("System Prompt").setDesc("The system prompt for the AI Assistant");let c=this.contentEl.createEl("div"),b=c.createEl("span");b.style.color="var(--text-muted-color)",c.appendChild(b);let Z=new PI.TextAreaComponent(l);Z.setValue(this.settings.systemPrompt).onChange(async m=>{this.settings.systemPrompt=m,W.innerText=await d.format(m),a()}),new ul(this.app,Z.inputEl,nI.instance);let d=new Tl(this.app,nI.instance);Z.inputEl.style.width="100%",Z.inputEl.style.height="100px",Z.inputEl.style.minHeight="100px",Z.inputEl.style.marginBottom="1em";let W=this.contentEl.createEl("span"),a=(0,PI.debounce)(()=>{b.innerText=`Token count: ${this.systemPromptTokenLength}`},50);a(),(async()=>W.innerText=await d.format(this.settings.systemPrompt??""))()}addShowAdvancedSettingsToggle(l){new PI.Setting(l).setName("Show advanced settings").setDesc("Show advanced settings such as temperature, top p, and frequency penalty.").addToggle(c=>{c.setValue(this.showAdvancedSettings),c.onChange(b=>{this.showAdvancedSettings=b,this.reload()})})}addTemperatureSetting(l){new PI.Setting(l).setName("Temperature").setDesc("Sampling temperature. Higher values like 0.8 makes the output more random, whereas lower values like 0.2 will make it more focused and deterministic. The default is 1.").addSlider(c=>{c.setLimits(0,1,.1),c.setDynamicTooltip(),c.setValue(this.settings.modelParameters.temperature??1),c.onChange(b=>{this.settings.modelParameters.temperature=b})})}addTopPSetting(l){new PI.Setting(l).setName("Top P").setDesc("Nucleus sampling - consider this an alternative to temperature. The model considers the results of the tokens with top_p probability mass. 0.1 means only tokens compromising the top 10% probability mass are considered. The default is 1.").addSlider(c=>{c.setLimits(0,1,.1),c.setDynamicTooltip(),c.setValue(this.settings.modelParameters.top_p??1),c.onChange(b=>{this.settings.modelParameters.top_p=b})})}addFrequencyPenaltySetting(l){new PI.Setting(l).setName("Frequency Penalty").setDesc("Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. The default is 0.").addSlider(c=>{c.setLimits(0,2,.1),c.setDynamicTooltip(),c.setValue(this.settings.modelParameters.frequency_penalty??0),c.onChange(b=>{this.settings.modelParameters.frequency_penalty=b})})}addPresencePenaltySetting(l){new PI.Setting(l).setName("Presence Penalty").setDesc("Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. The default is 0.").addSlider(c=>{c.setLimits(0,2,.1),c.setDynamicTooltip(),c.setValue(this.settings.modelParameters.presence_penalty??0),c.onChange(b=>{this.settings.modelParameters.presence_penalty=b})})}addResultJoinerSetting(l){new PI.Setting(l).setName("Result Jo
Line truncated
|
||||
${Tu(W)}`;tc.MarkdownRenderer.renderMarkdown(m,c,this.app.vault.getRoot().path,new tc.Component)}};var qI=require("obsidian");var ON=class extends qI.Modal{constructor(G,b){super(G);this.showAdvancedSettings=!1;this.settings=b,this.waitForClose=new Promise((Z,c)=>{this.rejectPromise=c,this.resolvePromise=Z}),this.open(),this.display()}get systemPromptTokenLength(){let G=ml(this.settings.model);return G?gG(this.settings.systemPrompt,G):Number.POSITIVE_INFINITY}display(){this.contentEl.empty();let G=this.contentEl.createEl("h2",{text:`${this.settings.name} Settings`});G.style.textAlign="center",G.style.cursor="pointer",G.style.userSelect="none",G.addEventListener("click",async()=>{try{let b=await yI.Prompt(this.app,"New name",this.settings.name,this.settings.name);b&&b!==this.settings.name&&(this.settings.name=b,this.reload())}catch{}}),this.addResultJoinerSetting(this.contentEl),this.addChunkSeparatorSetting(this.contentEl),this.addMaxTokensSetting(this.contentEl),this.addMergeChunksSetting(this.contentEl),this.addModelSetting(this.contentEl),this.addOutputVariableNameSetting(this.contentEl),this.addShowAdvancedSettingsToggle(this.contentEl),this.showAdvancedSettings&&(this.settings.modelParameters||(this.settings.modelParameters={}),this.addTemperatureSetting(this.contentEl),this.addTopPSetting(this.contentEl),this.addFrequencyPenaltySetting(this.contentEl),this.addPresencePenaltySetting(this.contentEl)),this.addSystemPromptSetting(this.contentEl)}reload(){this.contentEl.empty(),this.display()}addModelSetting(G){new qI.Setting(G).setName("Model").setDesc("The model the AI Assistant will use").addDropdown(b=>{let Z=Jl();for(let c of Z)b.addOption(c,c);b.addOption("Ask me","Ask me"),b.setValue(this.settings.model),b.onChange(c=>{this.settings.model=c,this.reload()})})}addOutputVariableNameSetting(G){new qI.Setting(G).setName("Output variable name").setDesc("The name of the variable used to store the AI Assistant output, i.e. {{value:output}}.").addText(b=>{b.setValue(this.settings.outputVariableName).onChange(Z=>{this.settings.outputVariableName=Z})})}addSystemPromptSetting(G){new qI.Setting(G).setName("System Prompt").setDesc("The system prompt for the AI Assistant");let b=this.contentEl.createEl("div"),Z=b.createEl("span");Z.style.color="var(--text-muted-color)",b.appendChild(Z);let c=new qI.TextAreaComponent(G);c.setValue(this.settings.systemPrompt).onChange(async m=>{this.settings.systemPrompt=m,d.innerText=await W.format(m),N()}),new pG(this.app,c.inputEl,XI.instance);let W=new kG(this.app,XI.instance);c.inputEl.style.width="100%",c.inputEl.style.height="100px",c.inputEl.style.minHeight="100px",c.inputEl.style.marginBottom="1em";let d=this.contentEl.createEl("span"),N=(0,qI.debounce)(()=>{Z.innerText=`Token count: ${this.systemPromptTokenLength}`},50);N(),(async()=>d.innerText=await W.format(this.settings.systemPrompt??""))()}addShowAdvancedSettingsToggle(G){new qI.Setting(G).setName("Show advanced settings").setDesc("Show advanced settings such as temperature, top p, and frequency penalty.").addToggle(b=>{b.setValue(this.showAdvancedSettings),b.onChange(Z=>{this.showAdvancedSettings=Z,this.reload()})})}addTemperatureSetting(G){new qI.Setting(G).setName("Temperature").setDesc("Sampling temperature. Higher values like 0.8 makes the output more random, whereas lower values like 0.2 will make it more focused and deterministic. The default is 1.").addSlider(b=>{b.setLimits(0,1,.1),b.setDynamicTooltip(),b.setValue(this.settings.modelParameters.temperature??1),b.onChange(Z=>{this.settings.modelParameters.temperature=Z})})}addTopPSetting(G){new qI.Setting(G).setName("Top P").setDesc("Nucleus sampling - consider this an alternative to temperature. The model considers the results of the tokens with top_p probability mass. 0.1 means only tokens compromising the top 10% probability mass are considered. The default is 1.").addSlider(b=>{b.setLimits(0,1,.1),b.setDynamicTooltip(),b.setValue(this.settings.modelParameters.top_p??1),b.onChange(Z=>{this.settings.modelParameters.top_p=Z})})}addFrequencyPenaltySetting(G){new qI.Setting(G).setName("Frequency Penalty").setDesc("Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. The default is 0.").addSlider(b=>{b.setLimits(0,2,.1),b.setDynamicTooltip(),b.setValue(this.settings.modelParameters.frequency_penalty??0),b.onChange(Z=>{this.settings.modelParameters.frequency_penalty=Z})})}addPresencePenaltySetting(G){new qI.Setting(G).setName("Presence Penalty").setDesc("Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. The default is 0.").addSlider(b=>{b.setLimits(0,2,.1),b.setDynamicTooltip(),b.setValue(this.settings.modelParameters.presence_penalty??0),b.onChange(Z=>{this.settings.modelParameters.presence_penalty=Z})})}addResultJoinerSetting(G){new qI.Setting(G).setName("Result Jo
Line truncated
|
||||
|
||||
/* nosourcemap */
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "quickadd",
|
||||
"name": "QuickAdd",
|
||||
"version": "1.17.0",
|
||||
"version": "1.18.1",
|
||||
"minAppVersion": "1.6.0",
|
||||
"description": "Quickly add new pages or content to your vault.",
|
||||
"author": "Christian B. B. Houmann",
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
.configureMacroDiv{display:grid;grid-template-rows:1fr;min-width:12rem}.configureMacroDivItem{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.configureMacroDivItemButton{display:flex;align-content:center;justify-content:center;margin-bottom:10px}.macroContainer{display:grid;grid-template-rows:repeat(auto-fill,120px);grid-gap:40px;overflow-y:auto;max-height:30em;padding:2em}@media screen and (max-width: 540px){.macroContainer1,.macroContainer2,.macroContainer3{grid-template-columns:repeat(1,1fr)}.wideInputPromptInputEl{width:20rem;max-width:100%;height:3rem;direction:inherit;text-align:inherit}}@media screen and (max-width: 540px) and (max-width: 780px){.macroContainer1{grid-template-columns:repeat(1,1fr)}.macroContainer2,.macroContainer3{grid-template-columns:repeat(2,1fr)}.wideInputPromptInputEl{width:30rem;max-width:100%;height:20rem;direction:inherit;text-align:inherit}}@media screen and (min-width: 781px){.macroContainer1{grid-template-columns:repeat(1,1fr)}.macroContainer2,.macroContainer3{grid-template-columns:repeat(2,1fr)}.wideInputPromptInputEl{width:40rem;max-width:100%;height:20rem;direction:inherit;text-align:inherit}}.addMacroBarContainer{display:flex;align-content:center;justify-content:space-around;margin-top:20px}.captureToActiveFileContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.choiceNameHeader{text-align:center}.choiceNameHeader:hover{cursor:pointer}.folderInputContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:8px;gap:4px}.selectMacroDropdownContainer{display:flex;align-content:center;justify-content:center}.quickAddModal .modal{min-width:35%;overflow-y:auto;max-height:70%}.checkboxRowContainer{margin:30px 0;display:grid;grid-template-rows:auto;align-content:center;gap:5px}.checkboxRow{display:flex;justify-content:space-between;align-content:center}.checkboxRow .checkbox-container{flex-shrink:0}.checkboxRow span{font-size:16px;word-break:break-all}.submitButtonContainer{display:flex;align-content:center;justify-content:center}.chooseFolderWhenCreatingNoteContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.chooseFolderFromSubfolderContainer{margin:20px 0 0}.clickable:hover{cursor:pointer}.quickAddCommandListItem{display:flex;flex:1 1 auto;align-items:center;justify-content:space-between}.quickCommandContainer{display:flex;justify-content:flex-end;align-content:center;margin-bottom:1em;gap:4px}.yesNoPromptButtonContainer{display:flex;align-items:center;justify-content:space-around;margin-top:2rem}.yesNoPromptParagraph{text-align:center}.suggestion-container{background-color:var(--modal-background);z-index:100000;overflow-y:auto}.qaFileSuggestionItem{display:flex;align-items:center;justify-content:space-between;padding:6px 12px;margin:1px 0;cursor:pointer;border-radius:3px;transition:all .12s cubic-bezier(.25,.46,.45,.94);position:relative;min-height:32px;font-size:13px;line-height:1.3;width:100%}.qaFileSuggestionItem:hover{background-color:var(--background-modifier-hover);transform:translate(2px)}.qaFileSuggestionItem.is-selected{background-color:var(--interactive-accent);color:var(--text-on-accent);box-shadow:0 2px 8px #0000001a}.qaFileSuggestionItem.is-selected .suggestion-sub-text{color:var(--text-on-accent-inverted);opacity:.8}.qa-suggest-exact:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--interactive-accent);border-radius:0 1px 1px 0}.qa-suggest-alias:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-orange, #ff8c00);border-radius:0 1px 1px 0}.qa-suggest-fuzzy:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--text-faint);border-radius:0 1px 1px 0}.qa-suggest-unresolved:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-red, #e74c3c);border-radius:0 1px 1px 0}.qa-suggest-heading:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-blue, #3498db);border-radius:0 1px 1px 0}.qa-suggest-block:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-purple, #9b59b6);border-radius:0 1px 1px 0}.qa-suggestion-content{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.qaFileSuggestionItem .suggestion-main-text{font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px}.qaFileSuggestionItem .suggestion-sub-text{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:150px;margin-left:auto;padding-left:8px;opacity:.7}.qa-suggestion-pill{display:inline-block;padding:1px 4px;border-radius:2px;font-size:9px;font-weight:600;text-transform:uppercase;letter-spacing:.3px;line-height:1;opacity:.8}.qa-alias-pill{background:var(--color-orange, #ff8c00);color:#fff}.qa-unresolved-pill{background:var(--color-red, Line truncated
|
||||
.modal-button-container{display:flex;flex-direction:row-reverse;justify-content:flex-start;margin-top:1rem;gap:.5rem}.configureMacroDiv{display:grid;grid-template-rows:1fr;min-width:12rem}.configureMacroDivItem{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.configureMacroDivItemButton{display:flex;align-content:center;justify-content:center;margin-bottom:10px}.macroContainer{display:grid;grid-template-rows:repeat(auto-fill,120px);grid-gap:40px;overflow-y:auto;max-height:30em;padding:2em}@media screen and (max-width: 540px){.macroContainer1,.macroContainer2,.macroContainer3{grid-template-columns:repeat(1,1fr)}.wideInputPromptInputEl{width:20rem;max-width:100%;height:3rem;direction:inherit;text-align:inherit}}@media screen and (max-width: 540px) and (max-width: 780px){.macroContainer1{grid-template-columns:repeat(1,1fr)}.macroContainer2,.macroContainer3{grid-template-columns:repeat(2,1fr)}.wideInputPromptInputEl{width:30rem;max-width:100%;height:20rem;direction:inherit;text-align:inherit}}@media screen and (min-width: 781px){.macroContainer1{grid-template-columns:repeat(1,1fr)}.macroContainer2,.macroContainer3{grid-template-columns:repeat(2,1fr)}.wideInputPromptInputEl{width:40rem;max-width:100%;height:20rem;direction:inherit;text-align:inherit}}.addMacroBarContainer{display:flex;align-content:center;justify-content:space-around;margin-top:20px}.captureToActiveFileContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.choiceNameHeader{text-align:center}.choiceNameHeader:hover{cursor:pointer}.folderInputContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:8px;gap:4px}.selectMacroDropdownContainer{display:flex;align-content:center;justify-content:center}.quickAddModal .modal{min-width:35%;overflow-y:auto;max-height:70%}.checkboxRowContainer{margin:30px 0;display:grid;grid-template-rows:auto;align-content:center;gap:5px}.checkboxRow{display:flex;justify-content:space-between;align-content:center}.checkboxRow .checkbox-container{flex-shrink:0}.checkboxRow span{font-size:16px;word-break:break-all}.submitButtonContainer{display:flex;align-content:center;justify-content:center;gap:.5rem}.chooseFolderWhenCreatingNoteContainer{display:flex;align-content:center;justify-content:space-between;margin-bottom:10px}.chooseFolderFromSubfolderContainer{margin:20px 0 0}.clickable:hover{cursor:pointer}.quickAddCommandListItem{display:flex;flex:1 1 auto;align-items:center;justify-content:space-between}.quickCommandContainer{display:flex;justify-content:flex-end;align-content:center;margin-bottom:1em;gap:4px}.yesNoPromptButtonContainer{display:flex;align-items:center;justify-content:space-around;margin-top:2rem;gap:.5rem}.yesNoPromptParagraph{text-align:center}.suggestion-container{background-color:var(--modal-background);z-index:100000;overflow-y:auto}.qaFileSuggestionItem{display:flex;align-items:center;justify-content:space-between;padding:6px 12px;margin:1px 0;cursor:pointer;border-radius:3px;transition:all .12s cubic-bezier(.25,.46,.45,.94);position:relative;min-height:32px;font-size:13px;line-height:1.3;width:100%}.qaFileSuggestionItem:hover{background-color:var(--background-modifier-hover);transform:translate(2px)}.qaFileSuggestionItem.is-selected{background-color:var(--interactive-accent);color:var(--text-on-accent);box-shadow:0 2px 8px #0000001a}.qaFileSuggestionItem.is-selected .suggestion-sub-text{color:var(--text-on-accent-inverted);opacity:.8}.qa-suggest-exact:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--interactive-accent);border-radius:0 1px 1px 0}.qa-suggest-alias:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-orange, #ff8c00);border-radius:0 1px 1px 0}.qa-suggest-fuzzy:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--text-faint);border-radius:0 1px 1px 0}.qa-suggest-unresolved:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-red, #e74c3c);border-radius:0 1px 1px 0}.qa-suggest-heading:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-blue, #3498db);border-radius:0 1px 1px 0}.qa-suggest-block:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--color-purple, #9b59b6);border-radius:0 1px 1px 0}.qa-suggestion-content{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.qaFileSuggestionItem .suggestion-main-text{font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px}.qaFileSuggestionItem .suggestion-sub-text{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:150px;margin-left:auto;padding-left:8px;opacity:.7}.qa-suggestion-pill{display:inline-block;padding:1px 4px;border-radius:2px;font-size:9px;font-weight:600;text-transform:uppercase;letter-spacing:.3px;liLine truncated
|
||||
Reference in new issue
Block a user