diff --git a/apps/money/0.3.0/ui.js b/apps/money/0.3.0/ui.js new file mode 100644 index 000000000..5ec7ef8b9 --- /dev/null +++ b/apps/money/0.3.0/ui.js @@ -0,0 +1,11 @@ +var Y=class extends Error{code;data;constructor(e,n,r){super(n),this.name="StatementError",this.code=e,this.data=r}},C=(t,e,n)=>new Y(t,e,n);function Yt(t){return t instanceof Y}function bt(t,e=!1){if(!/^\d{1,15},\d{0,5}$/.test(t))throw new Error("Invalid MT940 amount");let[n,r=""]=t.split(","),i=`${n.replace(/^0+(?=\d)/,"")}${r.replace(/0+$/,"")?"."+r.replace(/0+$/,""):""}`;return e&&i!=="0"?"-"+i:i}function G(t){let e=t.startsWith("-"),[n,r=""]=t.replace(/^-/,"").split(".");return BigInt(n+r.padEnd(5,"0"))*(e?-1n:1n)}function Mt(t){let e=Number(t.slice(0,2)),r=`${e>=70?1900+e:2e3+e}-${t.slice(2,4)}-${t.slice(4,6)}`,i=new Date(r+"T00:00:00Z");if(!/^\d{6}$/.test(t)||!Number.isFinite(i.getTime())||i.toISOString().slice(0,10)!==r)throw new Error("Invalid MT940 date");return r}function It(t){let e=t.match(/^([CD])(\d{6})([A-Z]{3})(\d+,\d*)$/);if(!e)throw new Error("Invalid MT940 balance");return{date:Mt(e[2]),currency:e[3],amount:bt(e[4],e[1]==="D")}}function on(t){let[e,...n]=t.split(` +`),r=e.match(/^(\d{6})(\d{4})?(RC|RD|C|D)([A-Z])?(\d+,\d*)([NSF][A-Z0-9]{3})(.*)$/);if(!r)throw new Error("Unsupported MT940 transaction line");let i=Mt(r[1]),a=i;if(r[2]){let p=Number(i.slice(0,4)),d=Number(r[2].slice(0,2)),m=Number(i.slice(5,7)),g=p+(d-m>6?-1:m-d>6?1:0);a=Mt(String(g%100).padStart(2,"0")+r[2])}let[c,l="",...s]=r[7].split("//");if(!c||s.length)throw new Error("Invalid MT940 transaction reference");return{date:i,bookingDate:a,amount:bt(r[5],r[3]==="D"||r[3]==="RC"),code:r[6],reference:c,bankReference:l,description:n.join(` +`)}}function Zt(t){if(typeof t!="string"||t.length>512e3)throw C("FILE_TOO_LARGE","Choose an MT940 file smaller than 512 KB",{limit:512e3,format:"mt940"});let e=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,` +`).trim(),n=[];for(let[d,m]of e.split(` +`).entries()){if(/^(?:\{1:.*\{4:|\{4:| -\}|-\}|\{5:.*\})$/.test(m))continue;let g=m.match(/^:(\d{2}[A-Z]?):(.*)$/);if(g)n.push({tag:g[1],value:g[2],line:d+1});else if(m.trim()){let b=n[n.length-1];if(!b||!["61","86"].includes(b.tag))throw C("INVALID_FIELD","Unsupported MT940 header or field continuation",{tag:b?.tag??"header",line:d+1});b.value+=` +`+m}}let r=[],i="",a="",c,l=!0,s=0;for(let{tag:d,value:m,line:g}of n)try{p(d,m)}catch(b){throw b instanceof Y||!(b instanceof Error)?b:C("INVALID_FIELD",b.message,{tag:d,line:g})}function p(d,m){switch(d){case"20":if(!l)throw C("MISSING_BALANCE","Statement is missing its closing balance",{statement:a});i="",a="",c=void 0;break;case"21":break;case"25":if(!l)throw new Error("Unexpected account inside a statement");if(i=m.trim(),!i)throw new Error("Missing bank account");break;case"28":case"28C":if(!l)throw new Error("Unexpected statement number");a=m.trim();break;case"60F":case"60M":{if(!l||!i||!a)throw new Error("Missing or out-of-order MT940 statement fields");let g=It(m);c={account:i,number:a,currency:g.currency,opening:g.amount,closing:"",start:g.date,end:"",transactions:[]},r.push(c),l=!1;break}case"61":if(!c||l)throw new Error("Transaction outside an open statement");if(++s>500)throw C("TOO_MANY_ENTRIES","Import at most 500 transactions at a time; export a shorter period",{limit:500});c.transactions.push(on(m));break;case"86":{if(!c||l)throw new Error("Unsupported statement-level narrative");let g=c.transactions[c.transactions.length-1];if(!g)throw new Error("Narrative without a transaction");g.description=[g.description,m].filter(Boolean).join(` +`);break}case"62F":case"62M":{if(!c||l)throw new Error("Closing balance without an open statement");let g=It(m);if(g.currency!==c.currency||g.datea+G(c.amount),0n),i=G(t.opening)+r;if(i!==G(e))throw C("BALANCE_MISMATCH","Statement balance does not reconcile; no transactions will be imported",{statement:t.number,account:t.account,currency:t.currency,opening:t.opening,entries:t.transactions.length,entriesSum:Xt(r),expectedClosing:Xt(i),closing:e,start:t.start,end:n})}function Rt(t){let e=0;for(let n of t)for(let r of n.transactions){let i=r.description.trim();if(i.startsWith("[")||i.startsWith("{")){let a;try{a=JSON.parse(i)}catch{continue}a&&typeof a=="object"&&e++}}if(e)throw C("JSON_NARRATIVE","JSON-shaped bank narratives are not supported yet; the statement was not imported",{count:e})}function Dt(t,e){try{return e()}catch(n){throw n instanceof Y||!(n instanceof Error)?n:C("INVALID_FIELD",n.message,{tag:t})}}var pt=5e6,Ft=t=>t.replace(/^[^:]*:/,"");function Qt(t){return t.replace(/&(amp|lt|gt|quot|apos|#\d+|#x[0-9a-fA-F]+);/g,(e,n)=>{switch(n){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";default:return String.fromCodePoint(n[1]==="x"?parseInt(n.slice(2),16):Number(n.slice(1)))}})}function an(t){let e={};for(let n of t.matchAll(/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[Ft(n[1])]=Qt(n[2]??n[3]??"");return e}function sn(t){let e={name:"",attrs:{},children:[],text:""},n=[e],r=/||<\?[\s\S]*?\?>|]*>|<\/([^\s>]+)\s*>|<([^\s/>]+)((?:\s+[^\s=/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>|([^<]+)/y,i=0;for(;it?.children.filter(n=>n.name===e)??[];function B(t,...e){let n=t;for(let r of e)n=tt(n,r)[0];return n}var E=(t,...e)=>B(t,...e)?.text.trim()??"";function $t(t){let e=t.slice(0,10),n=new Date(e+"T00:00:00Z");if(!/^\d{4}-\d{2}-\d{2}(?:$|T)/.test(t)||!Number.isFinite(n.getTime())||n.toISOString().slice(0,10)!==e)throw new Error("Invalid camt.053 date");return e}function te(t,e,n){let r=t?.text.trim()??"";if(!t||!/^\d{1,15}(?:\.\d{0,5})?$/.test(r))throw new Error("Invalid camt.053 amount");if(t.attrs.Ccy&&t.attrs.Ccy!==e)throw new Error("camt.053 entry currency differs from the account currency");return bt(r.includes(".")?r.replace(".",","):r+",",n)}function ee(t){let e=E(t,"CdtDbtInd");if(e!=="CRDT"&&e!=="DBIT")throw new Error("Invalid camt.053 credit/debit indicator");return e==="DBIT"}var Pt=(t,...e)=>E(t,...e,"Dt")||E(t,...e,"DtTm");function cn(t,e){let n=E(t,"Tp","CdOrPrtry","Cd"),r=Pt(t,"Dt");if(!r)throw new Error("camt.053 balance is missing its date");return{type:n,date:$t(r),amount:te(B(t,"Amt"),e,ee(t))}}var ln=t=>E(t,"Nm")||E(t,"Pty","Nm"),ne=t=>E(t,"Id","IBAN")||E(t,"Id","Othr","Id");function pn(t){let e=B(t,"BkTxCd","Domn"),n=[E(e,"Cd"),E(e,"Fmly","Cd"),E(e,"Fmly","SubFmlyCd")].filter(Boolean);return n.length?n.join("/"):E(t,"BkTxCd","Prtry","Cd")}function dn(t,e){let n=ee(t),r=Pt(t,"BookgDt"),i=Pt(t,"ValDt");if(!r&&!i)throw new Error("camt.053 entry has no booking or value date");let a=tt(B(t,"NtryDtls"),"TxDtls"),c=a.map(d=>B(d,"Refs")),l=c.map(d=>E(d,"EndToEndId")).find(d=>d&&d!=="NOTPROVIDED"),s=[],p=d=>{d&&!s.includes(d)&&s.push(d)};for(let d of a){let m=B(d,"RltdPties"),g=n?"Cdtr":"Dbtr";p([ln(B(m,g)),ne(B(m,`${g}Acct`))].filter(Boolean).join(" "));let b=B(d,"RmtInf");for(let v of tt(b,"Ustrd"))p(v.text.trim());for(let v of tt(b,"Strd"))p(E(v,"CdtrRefInf","Ref"));p(E(d,"AddtlTxInf"))}return p(E(t,"AddtlNtryInf")),{date:$t(i||r),bookingDate:$t(r||i),amount:te(B(t,"Amt"),e,n),code:pn(t),reference:l||E(t,"NtryRef")||"NONREF",bankReference:E(t,"AcctSvcrRef")||c.map(d=>E(d,"AcctSvcrRef")).find(Boolean)||"",description:s.join(` +`)}}function re(t){if(typeof t!="string"||t.length>pt)throw C("FILE_TOO_LARGE","Choose a camt.053 file smaller than 5 MB",{limit:pt,format:"camt053"});let e=Dt("xml",()=>sn(t.replace(/^/,""))),n=B(e,"Document","BkToCstmrStmt");if(!n)throw C("NOT_A_STATEMENT","Not a camt.053 bank statement: expected a Document with BkToCstmrStmt",{});let r=[],i=0;for(let c of tt(n,"Stmt"))Dt("Stmt",()=>a(c));function a(c){let l=B(c,"Acct"),s=ne(l);if(!s)throw new Error("Missing bank account");let p=tt(c,"Bal"),d=E(l,"Ccy")||p.map(h=>B(h,"Amt")?.attrs.Ccy).find(Boolean)||"";if(!/^[A-Z]{3}$/.test(d))throw new Error("Missing camt.053 account currency");let m=p.map(h=>cn(h,d)),g=m.find(h=>h.type==="OPBD")??m.find(h=>h.type==="PRCD"),b=m.find(h=>h.type==="CLBD");if(!g||!b)throw C("MISSING_BALANCE","camt.053 statement needs an opening (OPBD) and closing (CLBD) booked balance",{statement:E(c,"Id")||void 0});if(b.date500)throw C("TOO_MANY_ENTRIES","Import at most 500 transactions at a time; export a shorter period",{limit:500});v.push(Dt("Ntry",()=>dn(h,d)))}}let F={account:s,number:E(c,"Id")||E(c,"ElctrncSeqNb"),currency:d,opening:g.amount,closing:b.amount,start:g.date,end:b.date,transactions:v};Lt(F,b.amount,b.date),r.push(F)}if(!r.length)throw C("NOT_A_STATEMENT","camt.053 file contains no statements",{});return Rt(r),r}function oe(t,e){let n=[],r=new Map;for(let i of e){let a=JSON.stringify([i.number,i.start,i.end,i.opening,i.closing]);for(let[c,l]of i.transactions.entries()){let s=`${t}-content:`+JSON.stringify([i.account,i.currency,l.date,l.bookingDate,l.amount,l.code,l.reference,l.description]),p=l.bankReference&&l.bankReference!=="NONREF"?l.bankReference:"",d=JSON.stringify([t,i.account,i.currency,p?["bank",p]:["statement",a,c]]);if(r.has(d))throw r.get(d)!==s?C("CONFLICTING_REFERENCE","Conflicting bank transaction references in this file",{reference:p}):C("REPEATED_REFERENCE","Repeated bank transaction reference in this file; export non-overlapping statements",{reference:p});r.set(d,s),n.push({statement:i,row:l,index:c,identity:d,fingerprint:s,reference:p})}}return n}var ae="This statement overlaps an earlier import without unique bank references. Use the original statement or export a non-overlapping period.";function Ot(t){return t.replace(/^/,"").trimStart().startsWith("<")?"camt053":"mt940"}function ie(t){if(typeof t!="string")throw C("NOT_A_STATEMENT","Choose a bank statement file",{});let e=Ot(t);return{format:e,statements:e==="camt053"?re(t):Zt(t)}}var mn=["CHANGED_TRANSACTION","OVERLAP_WITHOUT_REFERENCES","REPEATED_REFERENCE","CONFLICTING_REFERENCE","FILE_TOO_LARGE","TOO_MANY_ENTRIES","JSON_NARRATIVE"],se=t=>mn.includes(t.code);function ce(t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return new TextDecoder("windows-1252").decode(t)}}function le(t){if(!(t<=pt))return{code:"FILE_TOO_LARGE",message:"Choose a camt.053 file smaller than 5 MB",data:{limit:pt,format:"camt053"}}}var pe=t=>Ot(t);function xt(t){return Yt(t)?{code:t.code,message:t.message,data:t.data}:{code:"UNKNOWN",message:t instanceof Error?t.message:String(t)}}var un=({statement:t,row:e})=>({date:e.bookingDate,account:t.account,currency:t.currency,amount:e.amount,description:e.description,reference:e.bankReference||e.reference});function de(t){try{return{ok:!0,...ie(t)}}catch(e){return{ok:!1,problem:xt(e)}}}function me(t,e,n){let r;try{r=oe(t,e)}catch(m){return{ok:!1,problem:xt(m)}}let i=new Map(n.map(m=>[m.sourceId,m])),a=new Map(n.map(m=>[m.fingerprint,m])),c=[],l=[],s=[],p=0;for(let m of r){m.reference||p++;let g=i.get(m.identity),b=un(m);if(g){!g.fingerprint||g.fingerprint===m.fingerprint?l.push(b):s.push({mine:g,file:b,fields:fn(g,b)});continue}let v=m.reference?void 0:a.get(m.fingerprint);if(v)return{ok:!1,problem:{code:"OVERLAP_WITHOUT_REFERENCES",message:ae,data:{statement:m.statement.number,account:m.statement.account,thisPeriod:{start:m.statement.start,end:m.statement.end},overlappingDate:v.valueDate}}};c.push(b)}if(s.length)return{ok:!1,problem:{code:"CHANGED_TRANSACTION",message:`${s.length} imported transaction(s) differ from this file`,changed:s[0],count:s.length}};let d=(m,g)=>m.dateg.date?-1:0;return{ok:!0,preview:{format:t,statements:e,fresh:c.sort(d),already:l.sort(d),withoutReference:p}}}function fn(t,e){let n=[];return t.bookingDate!==e.date&&n.push("date"),t.amount!==e.amount&&n.push("amount"),t.description!==e.description&&n.push("description"),t.account!==e.account&&n.push("account"),n}var gn="\u2212",Bt=5;function ot(t){let e=t<0n,n=(e?-t:t).toString().padStart(Bt+1,"0"),r=n.slice(0,-Bt),i=n.slice(-Bt).replace(/0+$/,""),a=i?`${r}.${i}`:r;return e&&a!=="0"?`-${a}`:a}var wt=t=>G(t)<0n,ue=t=>ot(-G(t)),fe=t=>ot(t.reduce((e,n)=>e+G(n),0n));function ge(t){try{return new Intl.NumberFormat("en",{style:"currency",currency:t}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}var yt;function hn(){if(yt===void 0)try{yt=new Intl.NumberFormat("en-US",{maximumFractionDigits:0,useGrouping:!1}).format("9007199254740993")==="9007199254740993"}catch{yt=!1}return yt}function he(t){let e=/^(-?)(\d+)(?:\.(\d*))?$/.exec(t.trim());if(!e)throw new RangeError(`Not a decimal amount: ${t}`);let n=e[2].replace(/^0+(?=\d)/,""),r=(e[3]??"").replace(/0+$/,"");return{negative:e[1]==="-"&&(/[1-9]/.test(n)||r!==""),whole:n,fraction:r}}function R(t,e,n,{sign:r="always",symbol:i=!0,exact:a="auto"}={}){let c=he(t),l=c.negative?gn:r==="always"?"+":"",s=ge(e),p={...i?{style:"currency",currency:e}:{},minimumFractionDigits:s,maximumFractionDigits:xn(s,c.fraction.length)},d=c.fraction?`${c.whole}.${c.fraction}`:c.whole;try{let m=a==="intl"||a==="auto"&&hn();return l+(m?new Intl.NumberFormat(n,p).format(d):bn(c,p,n))}catch{return`${l}${d} ${e}`}}function bn({whole:t,fraction:e},n,r){let i=n.minimumFractionDigits??0,a=e.padEnd(i,"0"),c=new Intl.NumberFormat(r,{...n,minimumFractionDigits:0,maximumFractionDigits:0}).formatToParts(BigInt(t)),l=new Intl.NumberFormat(r,{minimumFractionDigits:1}).formatToParts(BigInt(0)).find(d=>d.type==="decimal")?.value??".",s=-1;c.forEach((d,m)=>{(d.type==="integer"||d.type==="group")&&(s=m)});let p=c.map(d=>d.value);return a&&p.splice(s+1,0,l+a),p.join("")}function xn(t,e){return t>e?t:e}function be(t,e,n="en"){let{negative:r,whole:i,fraction:a}=he(t),c=r?"minus":"plus",l=e;try{l=new Intl.DisplayNames(n,{type:"currency"}).of(e)??e}catch{}l=l.toLowerCase();let s=new Intl.NumberFormat(n).format(BigInt(i)),p=ge(e);return a?a.length>p?`${c} ${s}.${a} ${l}`:`${c} ${s} ${l} ${BigInt(a.padEnd(p,"0")).toString()}`:`${c} ${s} ${l}`}function vt(t){let e=new Map;for(let n of t){let r=`${n.account}\0${n.currency}`,i=e.get(r);i||(i={account:n.account,currency:n.currency,in:0n,out:0n,count:0},e.set(r,i));let a=G(n.amount);a<0n?i.out+=a:i.in+=a,i.count++}return[...e.values()].map(n=>({account:n.account,currency:n.currency,in:ot(n.in),out:ot(n.out),net:ot(n.in+n.out),count:n.count}))}function yn(t){let e=new Map;for(let n of t)e.set(n.currency,(e.get(n.currency)??0n)+G(n.amount));return[...e.entries()].sort(([n],[r])=>nr?1:0).map(([n,r])=>({currency:n,amount:ot(r)}))}function _t(t){let e=new Map;for(let n of t){let r=e.get(n.bookingDate);r?r.push(n):e.set(n.bookingDate,[n])}return[...e.entries()].sort(([n],[r])=>nr?-1:0).map(([n,r])=>({date:n,rows:r,net:yn(r)}))}var at=200,dt=(t,e)=>JSON.stringify([t,e]),wn=(t,e)=>t.account===e.account&&t.currency===e.currency&&t.statement===e.statement&&(e.format===void 0||t.format===e.format),kt=t=>String(t).padStart(2,"0");function Et(t,e){let n=+e.slice(0,4),r=+e.slice(5,7);switch(t.kind){case"all":return{};case"this-month":return{from:`${n}-${kt(r)}-01`,to:`${n}-${kt(r)}-31`};case"last-month":{let i=r===1?n-1:n,a=r===1?12:r-1;return{from:`${i}-${kt(a)}-01`,to:`${i}-${kt(a)}-31`}}case"this-year":return{from:`${n}-01-01`,to:`${n}-12-31`};case"custom":return{from:t.from||void 0,to:t.to||void 0}}}var xe=(t,e,n)=>{let{from:r,to:i}=Et(e,n);return(!r||t.bookingDate>=r)&&(!i||t.bookingDate<=i)},vn=(t,e)=>{let n=e.trim().toLowerCase();return!n||t.description.toLowerCase().includes(n)||t.reference.toLowerCase().includes(n)},kn=(t,e)=>e==="all"||e==="out"===wt(t.amount);function Ht(t,e,n){return t.filter(r=>xe(r,e.period,n)&&vn(r,e.query)&&kn(r,e.direction)&&(!e.uncategorised||!r.category)&&(!e.statement||wn(r,e.statement)))}function jt(t,e,n){return Ht(t,e,n).filter(r=>!e.account||dt(r.account,r.currency)===e.account)}function ye(t){return t.map((e,n)=>({row:e,index:n})).sort((e,n)=>e.row.bookingDate===n.row.bookingDate?e.index-n.index:e.row.bookingDatee)}function St(t){let e=new Map;for(let n of t){let r=dt(n.account,n.currency),i=e.get(r);i?i.count++:e.set(r,{key:r,account:n.account,currency:n.currency,count:1})}return[...e.values()].sort((n,r)=>r.count-n.count)}function zt(t,e){let n={kind:"this-month"};return t.some(r=>xe(r,n,e))?n:{kind:"all"}}var mt=t=>({account:"",query:"",period:t,direction:"all",uncategorised:!1});var we=t=>t.reduce((e,n)=>n.bookingDate>e?n.bookingDate:e,"");function ve(t){let e=new Map;for(let n of t)n.category&&e.set(n.category,(e.get(n.category)??0)+1);return[...e.entries()].sort((n,r)=>r[1]-n[1]||(n[0]n)}function Tt(t){let e=new Map;for(let n of t){let r=JSON.stringify([n.format??"",n.account,n.currency,n.statement]),i=e.get(r);i||(i={key:{account:n.account,currency:n.currency,statement:n.statement,format:n.format},entries:0,start:n.bookingDate,end:n.bookingDate,rows:[]},e.set(r,i)),i.entries++,i.rows.push(n),n.bookingDatei.end&&(i.end=n.bookingDate)}return[...e.values()].sort((n,r)=>n.end===r.end?n.key.accountc||(!l||s.end>l.date)&&(l={amount:s.closing,date:s.end});return l}var z={parent:"https://atomicdata.dev/properties/parent",isA:"https://atomicdata.dev/properties/isA",shortname:"https://atomicdata.dev/properties/shortname",name:"https://atomicdata.dev/properties/name",requires:"https://atomicdata.dev/properties/requires",recommends:"https://atomicdata.dev/properties/recommends",classtype:"https://atomicdata.dev/properties/classtype",propertyClass:"https://atomicdata.dev/classes/Property"},En=["bank-account","bank-currency","bank-amount","bank-value-date","bank-booking-date","bank-description","bank-reference","bank-transaction-code","bank-statement","bank-source-id","bank-fingerprint"],Sn=["bank-period-start","bank-period-end","bank-opening-balance","bank-closing-balance","bank-entry-count","bank-format","bank-imported-date"],Tn=["money-category","money-note"],An=new Set([...En,...Tn,...Sn]);function Se(t,e){let n=s=>{let p=e[s],d=p?t.get(p):void 0;return typeof d=="string"?d:""},r=n("bank-account"),i=n("bank-currency"),a=n("bank-period-end"),c=n("bank-closing-balance");if(!r||!i||!a||!c)return;let l=n("bank-format");return{subject:t.subject,account:r,currency:i,number:n("bank-statement"),start:n("bank-period-start"),end:a,opening:n("bank-opening-balance"),closing:c,entries:n("bank-entry-count"),format:l==="mt940"||l==="camt053"?l:void 0,imported:n("bank-imported-date")}}var Ee=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[];async function Vt(t,e){let n=await t.getResource(e),r=[...new Set([...Ee(n.get(z.requires)),...Ee(n.get(z.recommends))])],i={},a=await Promise.all(r.map(l=>t.getResource(l).catch(()=>{})));for(let l of a){let s=l?.get(z.shortname);typeof s=="string"&&An.has(s)&&(i[s]??=l.subject)}let c=n.get(z.parent);for(let l of Cn){if(i[l])continue;let s=await t.query({property:z.shortname,value:l}).catch(()=>[]);if(!s.length)continue;let p=await Promise.all(s.map(m=>t.getResource(m).catch(()=>{}))),d=p.find(m=>m&&m.get(z.parent)===c)??p.find(Boolean);d&&(i[l]=d.subject)}return i}var Cn=["bank-fingerprint","bank-source-id"],Nn=["bank-account","bank-currency","bank-amount","bank-value-date"],Te=t=>Nn.every(e=>t[e]),X=t=>!!(t["money-category"]&&t["money-note"]);function In(t){try{let e=JSON.parse(t),n=Array.isArray(e)?e[0]:void 0;return n==="mt940"||n==="camt053"?n:void 0}catch{return}}function Mn(t,e){let n=s=>{let p=e[s],d=p?t.get(p):void 0;return typeof d=="string"?d:""},r=n("bank-amount"),i=n("bank-account"),a=n("bank-currency"),c=n("bank-value-date");if(!r||!i||!a||!c)return;let l=n("bank-source-id");return{subject:t.subject,account:i,currency:a,amount:r,valueDate:c,bookingDate:n("bank-booking-date")||c,description:n("bank-description"),reference:n("bank-reference"),code:n("bank-transaction-code"),statement:n("bank-statement"),sourceId:l,fingerprint:n("bank-fingerprint"),format:In(l),category:n("money-category"),note:n("money-note")}}async function qt(t,e,n,r,i=16){return Gt(t,e,a=>Mn(a,n),r,i)}async function Gt(t,e,n,r,i=16){let a=new Array(e.length),c=0,l=t.getMany?.bind(t);if(l){let s=[];for(let m=0;m{for(;p[])).forEach((b,v)=>{a[m+v]="error"in b&&b.error!==void 0?void 0:n(b)}),c+=Math.min(100,e.length-m),r?.(c)}};await Promise.all(Array.from({length:Math.min(4,s.length)},d))}else{let s=0,p=async()=>{for(;s{});a[d]=m?n(m):void 0,r?.(++c)}};await Promise.all(Array.from({length:Math.min(i,e.length)},p))}return a.filter(s=>s!==void 0)}function Ln(t){let e=t.importer;if(e)return{apply:(n,r)=>e.run({file:{name:r.name,mediaType:r.format==="camt053"?"application/xml":"text/plain",text:n}})}}var Ae="This app shows a Bank transactions table. Open it from the app tab of the table the Bank statements importer created.";function Rn(){let t=new Date;return[t.getFullYear(),String(t.getMonth()+1).padStart(2,"0"),String(t.getDate()).padStart(2,"0")].join("-")}function Ce(t,e,{today:n=Rn,importer:r,tick:i=()=>new Promise(a=>setTimeout(a,0))}={}){let a={view:{kind:"loading",loaded:0},tab:"transactions",rows:[],fields:{},filters:mt({kind:"all"}),limit:at,edits:{},drafts:{},canApply:!1,rowAccess:"unknown"},c=r??Ln(t);a.canApply=!!c;let l,s={},p,d=0,m,g,b,v,F=!1,h=f=>{a={...a,...f},e(a)},J=f=>f.length?{kind:"populated",count:f.length}:{kind:"empty"},lt=async()=>{if(!g)return;let f=await t.query({property:z.parent,value:g}),k=new Set(a.rows.map(T=>T.subject)),x=f.filter(T=>!k.has(T)),I=await qt(t,x,a.fields),$=new Set(f),M=a.rows.length===0,N=[...a.rows.filter(T=>$.has(T.subject)),...I];h({rows:N,view:J(N),...I.length?{arrived:{count:I.length}}:{},...M&&N.length?{filters:mt(zt(N,n()))}:{}})},nt=()=>{if(v){F=!0;return}v=lt().catch(()=>{}).finally(()=>{v=void 0,F&&(F=!1,nt())})},w=async()=>{if(!l)return;let f=await t.query({property:z.parent,value:l}),k=await Gt(t,f,x=>Se(x,s));h({statements:k})},u=async()=>{if(!t.requestRowAccess)return!1;let f=await t.requestRowAccess();return f.status==="granted"?(h({rowAccess:"granted",rowAccessReason:void 0}),!0):(h({rowAccess:"denied",rowAccessReason:f.reason}),!1)},A={category:"money-category",note:"money-note"},L=(f,k)=>h({edits:{...a.edits,[f]:k}}),V=f=>h({view:{kind:"error",message:f}});return{state:()=>a,async load(){h({view:{kind:"loading",loaded:0}});try{let f=await t.getData();if(!f?.rowClass)return V(Ae);let k=await Vt(t,f.rowClass);if(!Te(k))return V(Ae);g=f.table;let x=t.openResource?await t.getResource(g).then(N=>N.get(z.parent)).catch(()=>{}):void 0;typeof x=="string"&&h({importer:x});let I=await t.query({property:z.parent,value:g});h({fields:k,view:{kind:"loading",loaded:0,total:I.length}});let $=f.tables?.statements;if($&&(l=$.table,s=await Vt(t,$.rowClass),await w().catch(()=>{}),p?.(),p=t.subscribe(l,()=>{w().catch(()=>{})})),t.rowAccess){let N=await t.rowAccess().catch(()=>{});N&&h({rowAccess:N.status})}let M=await qt(t,I,k,N=>{N%50===0&&h({view:{kind:"loading",loaded:N,total:I.length}})});h({rows:M,view:J(M),filters:mt(zt(M,n())),limit:at,arrived:void 0}),b?.(),b=t.subscribe(g,nt)}catch(f){V(f instanceof Error?f.message:String(f))}},setTab(f){h({tab:f})},setFilters(f){h({filters:{...a.filters,...f},limit:at,arrived:void 0})},clearFilters(){h({filters:mt({kind:"all"}),limit:at})},showMore(){h({limit:a.limit+at})},select(f){f!==a.selected&&h({selected:f,edits:{},drafts:{}})},draft(f,k){a.drafts={...a.drafts,[f]:k}},async saveNote(f,k){let x=a.selected,I=a.rows.find(T=>T.subject===x),$=a.fields[A[f]];if(!x||!I||!$||!X(a.fields))return;let M=f==="note"?k:k.trim(),N=a.edits[f];if(!(M===I[f]&&N?.status!=="error")){if(t.rowAccess&&a.rowAccess!=="granted"&&(L(f,{value:M,status:"asking"}),!await u().catch(()=>!1))){a.selected===x&&L(f,{value:M,status:"error",message:"You didn't allow Money to edit this table, so it wasn't saved. Your text is kept here.",details:a.rowAccessReason});return}L(f,{value:M,status:"saving"});try{let T=await t.getResource(x);M?T.set($,M):T.remove($),await T.save();let W=a.rows.map(j=>j.subject===x?{...j,[f]:M}:j);if(a.selected===x){let j={...a.drafts};delete j[f],h({rows:W,drafts:j,edits:{...a.edits,[f]:{value:M,status:"saved"}}})}else h({rows:W})}catch(T){let W=T instanceof Error?T.message:String(T);a.selected===x&&L(f,{value:M,status:"error",message:Dn(W),details:W})}}},async importFile(f){let k=++d,x={name:f.name,size:f.size},I=()=>k!==d,$=rt=>h({importing:{step:se(rt)?"blocked":"error",file:x,problem:rt}});h({importing:{step:"checking",file:x,lines:["now","todo","todo"]}});let M=le(f.size);if(M)return $(M);let N;try{N=await f.text()}catch(rt){I()||$(xt(rt));return}if(I()||(x.format=pe(N),h({importing:{step:"checking",file:x,lines:["now","todo","todo"]}}),await i(),I()))return;let T=de(N);if(!T.ok)return $(T.problem);let W={statements:T.statements.length,entries:T.statements.reduce((rt,rn)=>rt+rn.transactions.length,0)};if(h({importing:{step:"checking",file:x,lines:["done","now","todo"],counts:W}}),await i(),I()||(h({importing:{step:"checking",file:x,lines:["done","done","now"],counts:W}}),await i(),I()))return;let j=me(T.format,T.statements,a.rows);if(!j.ok)return $(j.problem);m=N,h({importing:{step:"preview",file:x,preview:j.preview,tab:j.preview.fresh.length?"new":"already"}})},setPreviewTab(f){a.importing?.step==="preview"&&h({importing:{...a.importing,tab:f}})},async applyImport(){let f=a.importing;if(f?.step!=="preview"||!c||!m)return;let k=d;h({importing:{...f,applying:!0,failure:void 0}});try{let x=await c.apply(m,f.file);if(k!==d)return;if(x.status==="applied"||x.status==="nothing"){if(m=void 0,h({importing:void 0}),x.status==="applied")for(let I of[0,1e3,4e3])setTimeout(()=>{nt(),w().catch(()=>{})},I)}else x.status==="cancelled"?h({importing:{...f,applying:!1}}):h({importing:{...f,applying:!1,failure:("errors"in x?x.errors?.join(` +`):"")||"The importer blocked this file."}})}catch(x){k===d&&h({importing:{...f,applying:!1,failure:x instanceof Error?x.message:String(x)}})}},closeImport(){d++,m=void 0,a.importing&&h({importing:void 0})},async openImporter(){if(!(!a.importer||!t.openResource))try{await t.openResource(a.importer)}catch(f){h({openFailure:f instanceof Error?f.message:String(f)})}},async allowEditing(){return u().catch(()=>!1)},toggleHelp(f=!a.help){h({help:f})},today:n,dispose(){p?.(),b?.(),b=void 0}}}function Dn(t){return/only write its own data/i.test(t)?"This app isn't allowed to write to the importer's table yet. Your text is kept here.":/did not answer|timed? ?out|network/i.test(t)?"Your server didn't respond.":"Your server refused the change."}var Ne='.pl-app{margin:0}.m-amt{font-variant-numeric:tabular-nums;white-space:nowrap;font-weight:600}.m-amt[data-dir=in]{color:var(--pl-pos)}.m-amt small{font-weight:500;color:var(--pl-muted);margin-left:3px;font-size:11.5px}.m-switcher{appearance:none;border:1px solid var(--pl-border);border-radius:8px;padding:5px 30px 5px 10px;background-color:var(--pl-surface);background-image:linear-gradient(45deg,transparent 50%,var(--pl-muted) 50%),linear-gradient(135deg,var(--pl-muted) 50%,transparent 50%);background-position:right 15px center,right 10px center;background-size:5px 5px,5px 5px;background-repeat:no-repeat;cursor:pointer;max-width:100%;min-height:34px}@container pl-app (max-width: 559px){.m-switcher{width:100%;min-height:40px}}.m-strip{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(220px,1fr);border-bottom:1px solid var(--pl-hair);overflow-x:auto;overscroll-behavior-x:contain}.m-seg{all:unset;box-sizing:border-box;cursor:pointer;padding:14px 20px;display:grid;gap:2px;align-content:start;border-right:1px solid var(--pl-border)}.m-seg:last-child{border-right:0}.m-seg:focus-visible{outline:2px solid var(--pl-accent);outline-offset:-2px}.m-seg[aria-pressed=true]{background:var(--pl-accent-soft);box-shadow:inset 0 -2px 0 var(--pl-accent)}.m-seg .m-acct{font-size:12.5px;color:var(--pl-muted)}.m-seg .m-net{font-family:var(--pl-font-header);font-size:1.35rem;font-weight:600;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.m-seg .m-net small{font-family:var(--pl-font);font-size:12px;font-weight:500;color:var(--pl-muted);margin-left:6px;letter-spacing:0}.m-seg .m-flow{display:flex;gap:14px;font-size:12.5px;flex-wrap:wrap}@container pl-app (max-width: 559px){.m-strip{grid-auto-columns:78%}.m-seg{padding:12px 14px}}.m-filters{display:flex;gap:8px;padding:12px 20px;align-items:center;flex-wrap:wrap}.m-search{display:flex;align-items:center;gap:6px;border:1px solid var(--pl-border);border-radius:8px;padding:0 10px;min-height:34px;flex:1 1 200px;max-width:320px;background:var(--pl-surface);color:var(--pl-muted)}.m-search:focus-within{border-color:var(--pl-accent)}.m-search input{border:0;background:transparent;outline:none;flex:1;min-width:0;padding:6px 0;color:var(--pl-text)}.m-search kbd{font:11px ui-monospace,monospace;border:1px solid var(--pl-border);border-radius:4px;padding:0 4px;color:var(--pl-muted)}.m-chiprow{display:flex;gap:8px;align-items:center;flex-wrap:wrap;min-width:0}.m-sep{width:1px;align-self:stretch;background:var(--pl-border);margin:4px 2px}.m-custom{display:flex;gap:8px;align-items:center;flex-wrap:wrap;font-size:12.5px}.m-custom input{border:1px solid var(--pl-border);border-radius:8px;padding:4px 8px;background:var(--pl-surface);color-scheme:light dark}@container pl-app (max-width: 559px){.m-filters{padding:10px 12px}.m-search{max-width:none;flex-basis:100%;min-height:40px}.m-search kbd,.m-sep{display:none}.m-chiprow{flex-wrap:nowrap;overflow-x:auto;flex:1 1 100%;padding-bottom:2px}.m-chiprow .pl-chips{flex-wrap:nowrap}}.m-ledger{width:100%;border-collapse:collapse}.m-ledger caption{text-align:left;padding:0 20px 6px;font-size:12px;color:var(--pl-muted)}.m-ledger thead th{text-align:left;font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--pl-muted);padding:6px 12px;border-bottom:1px solid var(--pl-hair)}.m-ledger th:first-child,.m-ledger td:first-child{padding-left:20px}.m-ledger th:last-child,.m-ledger td:last-child{padding-right:20px;text-align:right}.m-ledger .m-day th{text-align:left;padding:14px 20px 6px;font-size:12.5px;font-weight:650;border-bottom:1px solid var(--pl-hair)}.m-ledger .m-day th span{float:right;font-weight:500;color:var(--pl-muted)}.m-ledger td{padding:9px 12px;border-bottom:1px solid var(--pl-hair);vertical-align:top}.m-ledger tr.m-row{cursor:pointer}.m-ledger tr.m-row:hover td{background:var(--pl-tint)}.m-ledger tr.m-row[aria-selected=true] td{background:var(--pl-accent-soft)}.m-ledger tr.m-row[aria-selected=true] td:first-child{box-shadow:inset 3px 0 0 var(--pl-accent)}.m-rowbtn{all:unset;box-sizing:border-box;display:block;width:100%;cursor:pointer;border-radius:4px}.m-rowbtn:focus-visible{outline:2px solid var(--pl-accent);outline-offset:3px}.m-desc b{font-weight:600;display:block;overflow-wrap:anywhere}.m-desc .m-rest{color:var(--pl-muted);font-size:12.5px;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:46ch}.m-cat{display:inline-block;font-size:12px;padding:1px 8px;border-radius:6px;background:var(--pl-tint);border:1px solid var(--pl-border);white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis}.m-cat[data-none]{color:var(--pl-muted);border-style:dashed;background:transparent}.m-acctcell{color:var(--pl-muted);font-size:12.5px;white-space:nowrap;font-variant-numeric:tabular-nums}.m-more{padding:14px 20px;display:flex;gap:12px;align-items:center;flex-wrap:wrap}.m-list,.m-list ul{list-style:none;margin:0;padding:0}.m-list h3{margin:0}.m-list .m-dayh{display:flex;justify-content:space-between;padding:12px 12px 4px;font-size:12.5px;font-weight:650;border-bottom:1px solid var(--pl-hair)}.m-list .m-dayh span{font-weight:500;color:var(--pl-muted)}.m-list .m-item{all:unset;box-sizing:border-box;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px 10px;width:100%;padding:10px 12px;min-height:52px;border-bottom:1px solid var(--pl-hair);cursor:pointer}.m-list .m-item:focus-visible{outline:2px solid var(--pl-accent);outline-offset:-2px}.m-list .m-item[aria-current=true]{background:var(--pl-accent-soft)}.m-list .m-t{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.m-list .m-s{grid-column:1 / -1;font-size:12.5px;color:var(--pl-muted);display:flex;gap:6px;align-items:center;min-width:0}.m-list .m-s .m-cat{flex:none}.m-list .m-s>span:last-child:not(.m-cat){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.m-split{display:grid;grid-template-columns:minmax(0,1fr) 360px}.m-main{min-width:0}.m-loading{padding:28px 20px;color:var(--pl-muted)}.m-pad{padding:12px 20px}.m-panel-head{display:flex;align-items:flex-start;gap:8px;padding:14px 16px 10px}.m-grow{flex:1;display:grid;gap:2px;min-width:0}.m-big .m-amt{font-family:var(--pl-font-header);font-size:1.6rem;font-weight:600;letter-spacing:-.01em}.m-small{font-size:12.5px}.pl-panel section{padding:12px 16px;border-top:1px solid var(--pl-border);display:grid;gap:10px}.pl-panel h3{margin:0;font-size:11.5px;text-transform:uppercase;letter-spacing:.06em;color:var(--pl-muted);font-weight:650}.m-kv{display:grid;grid-template-columns:110px minmax(0,1fr);gap:6px 10px;margin:0;font-size:13px}.m-kv dt{color:var(--pl-muted)}.m-kv dd{margin:0;overflow-wrap:anywhere}.m-narr{margin:0;background:var(--pl-tint);border:1px solid var(--pl-border);border-radius:8px;padding:8px 10px}.m-field{display:grid;gap:4px}.m-field label{font-size:12.5px;font-weight:600}.m-input{border:1px solid var(--pl-border);border-radius:8px;padding:7px 10px;background:var(--pl-surface);width:100%}.m-input[aria-invalid=true]{border-color:var(--pl-neg)}textarea.m-input{min-height:64px;resize:vertical}.m-panel-foot{margin-top:auto;padding:10px 16px;border-top:1px solid var(--pl-border);font-size:12.5px;display:flex;gap:8px;align-items:center;min-height:48px}.m-saved:before{content:"\\2713 ";color:var(--pl-pos)}.m-sheetbar{display:flex;align-items:center;gap:6px;padding:6px;border-bottom:1px solid var(--pl-hair)}.m-sheetbar strong{flex:1;font-size:14px}.pl-panel[data-mode=side]{position:sticky;top:0;align-self:start;min-height:0;max-height:100vh;overflow-y:auto}.pl-panel .pl-banner{padding:8px 10px}.m-sheet-scrim{z-index:29}.m-dialog{position:fixed;z-index:30;top:28px;left:50%;transform:translate(-50%);width:min(820px,calc(100% - 32px));max-height:calc(100% - 56px);display:flex;flex-direction:column;background:var(--pl-surface);border-radius:12px;box-shadow:0 24px 60px -20px #00000073,0 0 0 1px var(--pl-border)}.m-dialog>header{display:flex;align-items:center;gap:10px;padding:10px 12px 10px 18px;border-bottom:1px solid var(--pl-hair)}.m-dialog>header h2{margin:0;font-size:1rem;font-weight:650;flex:1}.m-steps{font-size:12px;color:var(--pl-muted)}.m-body{padding:16px 18px;display:grid;gap:14px;overflow-y:auto;min-height:0}.m-dialog>footer{display:flex;gap:8px;justify-content:flex-end;align-items:center;padding:12px 18px;border-top:1px solid var(--pl-border);flex-wrap:wrap}.m-dialog>footer .m-grow{flex:1 1 200px;font-size:12.5px;color:var(--pl-muted)}@container pl-app (max-width: 559px){.m-dialog{top:0;width:100%;max-height:100%;height:100%;border-radius:0}.m-body{padding:14px 12px}.m-dialog>footer{padding:10px 12px}.m-hide-narrow{display:none}}.m-file{display:flex;gap:10px;align-items:center}.m-doc{width:34px;height:40px;border-radius:4px;border:1px solid var(--pl-border);background:var(--pl-tint);display:grid;place-items:end center;font-size:9px;font-weight:700;padding-bottom:4px;color:var(--pl-muted);flex:none}.m-checklist{list-style:none;margin:0;padding:0;display:grid;gap:8px}.m-checklist li{display:flex;gap:10px;align-items:center}.m-st{width:18px;height:18px;border-radius:50%;border:1.5px solid var(--pl-border);display:grid;place-items:center;font-size:11px;flex:none}.m-checklist [data-status=done] .m-st{background:var(--pl-pos);border-color:var(--pl-pos);color:var(--pl-surface)}.m-checklist [data-status=now] .m-st{border-color:var(--pl-accent);border-top-color:transparent;animation:m-spin .9s linear infinite}.m-checklist [data-status=todo]{color:var(--pl-muted)}@keyframes m-spin{to{transform:rotate(360deg)}}.m-recon{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:10px}.m-stmt{border:1px solid var(--pl-border);border-radius:var(--pl-radius);padding:12px 14px;display:grid;gap:6px}.m-stmt .m-top{display:flex;justify-content:space-between;gap:8px;font-size:12.5px;color:var(--pl-muted);flex-wrap:wrap}.m-flowline{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap;font-weight:600}.m-arrow{color:var(--pl-muted);font-weight:400}.m-ok{font-size:12.5px;color:var(--pl-pos);font-weight:600}.m-ok:before{content:"\\2713 "}.m-subtabs{display:flex;gap:4px;border-bottom:1px solid var(--pl-hair);overflow-x:auto;position:sticky;top:-16px;z-index:1;background:var(--pl-surface);padding-top:4px}.m-subtabs button{border:0;background:none;cursor:pointer;padding:6px 10px 7px;font-size:13px;font-weight:600;color:var(--pl-muted);border-bottom:2px solid transparent;white-space:nowrap}.m-subtabs button[aria-selected=true]{color:var(--pl-text);border-bottom-color:var(--pl-accent)}.m-preview td:first-child,.m-preview th:first-child{padding-left:0}.m-preview td:last-child,.m-preview th:last-child{padding-right:0}.m-nowrap{white-space:nowrap}.m-nothing{margin:0;font-weight:600}.m-figs{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%}.m-figs td{padding:3px 0}.m-figs td:last-child{text-align:right;padding-left:28px;white-space:nowrap}.m-figs tr.m-total td{border-top:1px solid var(--pl-border);padding-top:6px;font-weight:650}.m-figs tr.m-bad td{color:color-mix(in oklab,var(--pl-neg) 60%,var(--pl-text));font-weight:700}.m-compare{display:grid;border:1px solid var(--pl-border);border-radius:8px;overflow:hidden;font-size:13px}.m-compare-row{display:grid;grid-template-columns:110px 1fr 1fr}.m-compare-row>div{white-space:pre-line;padding:7px 10px;border-bottom:1px solid var(--pl-hair);overflow-wrap:anywhere}.m-compare-row:last-child>div{border-bottom:0}.m-compare .m-h{font-size:11.5px;text-transform:uppercase;letter-spacing:.05em;color:var(--pl-muted);font-weight:650;background:var(--pl-subtle)}.m-compare .m-k{color:var(--pl-muted);overflow-wrap:normal}.m-compare .m-chg{background:var(--pl-warn-soft);font-weight:600}@container pl-app (max-width: 559px){.m-compare-row{grid-template-columns:92px 1fr 1fr}.m-compare-row>div{padding:7px 8px}}.m-hint{margin:0;font-size:13px}@media(prefers-reduced-motion:reduce){.m-checklist [data-status=now] .m-st{animation:none;border-top-color:var(--pl-accent)}}.m-imports caption{padding-top:12px}.m-line{display:block;white-space:nowrap}.m-strong{font-weight:600}.m-popover{position:fixed;z-index:35;top:60px;right:16px;width:min(320px,calc(100% - 32px));padding:12px;border-radius:var(--pl-radius);border:1px solid var(--pl-border);background:var(--pl-surface);box-shadow:0 10px 24px -12px #00000059;display:grid;gap:8px}.m-popover-head{display:flex;align-items:center;gap:8px}.m-popover h2{margin:0;font-size:14px;flex:1}.m-keys{display:grid;grid-template-columns:auto 1fr;gap:6px 12px;margin:0;font-size:13px}.m-keys dd{margin:0}.m-keys kbd,.m-search kbd{font:11px ui-monospace,monospace;border:1px solid var(--pl-border);border-radius:4px;padding:1px 5px;color:var(--pl-muted)}.m-drop{justify-self:stretch;justify-items:center;border:1.5px dashed color-mix(in oklab,var(--pl-accent) 45%,var(--pl-surface));border-radius:var(--pl-radius);padding:22px;display:grid;gap:10px;background:color-mix(in oklab,var(--pl-accent) 4%,var(--pl-surface))}.m-drop .m-formats{font-size:12.5px;color:var(--pl-muted)}details.m-help{font-size:13px;text-align:left;justify-self:stretch}details.m-help summary{cursor:pointer;color:var(--pl-accent);font-weight:600}details.m-help ul{margin:8px 0 0;padding-left:18px;display:grid;gap:4px}.m-sources-mini{justify-self:stretch;text-align:left;display:grid;gap:8px;margin-top:8px}.m-src{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--pl-border);border-radius:var(--pl-radius);flex-wrap:wrap}.m-src .m-name{font-weight:600}.m-src .m-grow{flex:1;min-width:160px}.m-src .m-why{font-size:12.5px;color:var(--pl-muted);display:block}.m-logo{width:28px;height:28px;border-radius:7px;display:grid;place-items:center;font-weight:700;font-size:12px;background:var(--pl-tint);border:1px solid var(--pl-border);flex:none}.m-tag{display:inline-block;font-size:11px;padding:0 6px;border-radius:4px;border:1px solid var(--pl-border);color:var(--pl-muted);margin-left:6px;vertical-align:1px;font-weight:500}.m-sources{padding:16px 20px;display:grid;gap:10px}.m-dropping:after{content:"Drop to check this statement";position:fixed;inset:8px;z-index:40;display:grid;place-items:center;border:2px dashed var(--pl-accent);border-radius:var(--pl-radius);background:color-mix(in oklab,var(--pl-accent-soft) 88%,transparent);color:var(--pl-accent-ink);font-weight:650;font-size:15px}';function Me(t,e){if(!(e===!1||e===null||e===void 0)){if(Array.isArray(e)){for(let n of e)Me(t,n);return}t.appendChild(typeof e=="string"?document.createTextNode(e):e)}}function o(t,e={},...n){let r=document.createElement(t);for(let[i,a]of Object.entries(e))if(!(a==null||a===!1)){if(typeof a=="function"){r.addEventListener(i.slice(2).toLowerCase(),a);continue}if(i==="value"&&"value"in r){r.value=String(a);continue}r.setAttribute(i,a===!0?"":String(a))}return Me(r,n),r}var Ie="http://www.w3.org/2000/svg";function At(t,e="pl-ico"){let n=document.createElementNS(Ie,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("aria-hidden","true"),n.setAttribute("class",e);for(let r of t){let i=document.createElementNS(Ie,"path");i.setAttribute("d",r),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.6"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),n.appendChild(i)}return n}var P={upload:()=>At(["M8 11V2.5M4.5 6 8 2.5 11.5 6M2.5 10.5v2a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1v-2"]),search:()=>At(["M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z","m10.5 10.5 3 3"]),close:()=>At(["m4 4 8 8M12 4l-8 8"]),back:()=>At(["M10 3 5 8l5 5"])};var Le='.pl-app{--pl-bg: var(--t-color-bg-body, #fafafa);--pl-surface: var(--t-color-bg, #ffffff);--pl-subtle: var(--t-color-bg-1, #f2f2f2);--pl-border: var(--t-color-bg-2, #cccccc);--pl-text: var(--t-color-text, #000000);--pl-muted: var(--t-color-text-light, #666666);--pl-accent: var(--t-color-main, #1b50d8);--pl-accent-soft: var(--t-color-main-selected-bg, #f1f4fd);--pl-accent-ink: var(--t-color-main-selected-fg, #0f2d7a);--pl-on-accent: var(--t-color-bg, #ffffff);--pl-neg: var(--t-color-alert, #cf5b5b);--pl-warn: var(--t-color-warning, #f5a623);--pl-pos: var(--t-color-success, color-mix(in oklab, #2f8f5b 75%, var(--pl-text)));--pl-radius: var(--t-radius, 9px);--pl-font: var(--t-font-family, system-ui, sans-serif);--pl-font-header: var(--t-font-family-header, var(--pl-font));--pl-tint: color-mix(in oklab, var(--pl-text) 4%, var(--pl-surface));--pl-hair: color-mix(in oklab, var(--pl-text) 12%, var(--pl-surface));--pl-neg-soft: color-mix(in oklab, var(--pl-neg) 10%, var(--pl-surface));--pl-warn-soft: color-mix(in oklab, var(--pl-warn) 14%, var(--pl-surface));--pl-pos-soft: color-mix(in oklab, var(--pl-pos) 12%, var(--pl-surface));container:pl-app / inline-size;background:var(--pl-surface);color:var(--pl-text);font-family:var(--pl-font);font-size:14px;line-height:1.45;position:relative;min-height:100vh;box-sizing:border-box}.pl-app[data-color-scheme=light]{color-scheme:light}.pl-app[data-color-scheme=dark]{color-scheme:dark}.pl-app *,.pl-app *:before,.pl-app *:after{box-sizing:border-box}.pl-app button,.pl-app input,.pl-app select,.pl-app textarea{font:inherit;color:inherit}.pl-app :focus-visible{outline:2px solid var(--pl-accent);outline-offset:2px}.pl-app [hidden]{display:none!important}.pl-sr{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.pl-num{font-variant-numeric:tabular-nums}.pl-muted{color:var(--pl-muted)}.pl-mono{font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:12.5px;white-space:pre-wrap;overflow-wrap:anywhere}.pl-ico{width:16px;height:16px;flex:none}.pl-header{display:flex;align-items:center;gap:12px;padding:10px 20px;min-height:56px;border-bottom:1px solid var(--pl-hair);flex-wrap:wrap}.pl-header h1{margin:0;font-family:var(--pl-font-header);font-size:1.125rem;font-weight:600;letter-spacing:-.01em}.pl-spacer{flex:1}@container pl-app (max-width: 559px){.pl-header{padding:8px 12px;gap:8px}.pl-header .pl-context{order:5;flex:1 1 100%}}.pl-pill{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 10px;border-radius:999px;font-size:12.5px;background:var(--pl-tint);white-space:nowrap}.pl-pill:before{content:"";width:7px;height:7px;border-radius:50%;background:var(--pl-dot, var(--pl-muted))}.pl-pill[data-state=syncing]{--pl-dot: var(--pl-accent);background:var(--pl-accent-soft);color:var(--pl-accent-ink)}.pl-pill[data-state=syncing]:before{animation:pl-pulse 1.2s ease-in-out infinite}.pl-pill[data-state=synced]{--pl-dot: var(--pl-pos);background:var(--pl-pos-soft)}.pl-pill[data-state=paused],.pl-pill[data-state=reauth]{--pl-dot: var(--pl-warn);background:var(--pl-warn-soft)}.pl-pill[data-state=error]{--pl-dot: var(--pl-neg);background:var(--pl-neg-soft)}@keyframes pl-pulse{50%{opacity:.25}}.pl-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:34px;padding:0 14px;border-radius:8px;border:1px solid var(--pl-border);background:var(--pl-surface);cursor:pointer;font-weight:600;font-size:13.5px;white-space:nowrap;text-decoration:none}.pl-btn[data-variant=primary]{background:var(--pl-accent);border-color:var(--pl-accent);color:var(--pl-on-accent)}.pl-btn[data-variant=ghost]{border-color:transparent;background:transparent;color:var(--pl-accent);padding-inline:6px}.pl-btn[data-icon-only]{width:40px;min-height:40px;padding:0}.pl-btn:disabled{opacity:.45;cursor:not-allowed}@container pl-app (max-width: 559px){.pl-btn{min-height:40px}}.pl-chips{display:flex;gap:6px;flex-wrap:wrap}.pl-chip{border:1px solid var(--pl-border);border-radius:999px;padding:4px 11px;font-size:12.5px;background:var(--pl-surface);cursor:pointer;white-space:nowrap}.pl-chip[aria-pressed=true]{background:var(--pl-accent-soft);color:var(--pl-accent-ink);border-color:color-mix(in oklab,var(--pl-accent) 40%,var(--pl-surface));font-weight:600}@container pl-app (max-width: 559px){.pl-chip{min-height:40px;padding-inline:13px}}.pl-tabs{display:flex;gap:2px;padding:0 16px;border-bottom:1px solid var(--pl-hair);overflow-x:auto}.pl-tabs button{border:0;background:none;cursor:pointer;padding:10px 10px 9px;color:var(--pl-muted);border-bottom:2px solid transparent;font-weight:600;font-size:13.5px;white-space:nowrap}.pl-tabs button[aria-selected=true]{color:var(--pl-text);border-bottom-color:var(--pl-accent)}.pl-tabs .pl-count{font-weight:500;color:var(--pl-muted);margin-left:4px}@container pl-app (max-width: 559px){.pl-tabs{padding:0 6px}.pl-tabs button{min-height:40px}}.pl-conn{display:flex;align-items:center;gap:10px;min-height:40px;padding:6px 20px;background:var(--pl-subtle);font-size:13px;flex-wrap:wrap}.pl-conn[data-tone=warn]{background:var(--pl-warn-soft)}.pl-empty{padding:36px 24px 32px;display:grid;gap:12px;max-width:560px;margin:0 auto;text-align:center;justify-items:center}.pl-empty h2{margin:0;font-family:var(--pl-font-header);font-size:1.35rem;font-weight:600;letter-spacing:-.01em;text-wrap:balance}.pl-empty p{margin:0;max-width:58ch}.pl-empty .pl-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}.pl-banner{border-left:3px solid var(--pl-neg);background:var(--pl-neg-soft);border-radius:0 8px 8px 0;padding:12px 14px;display:grid;gap:8px}.pl-banner[data-tone=warn]{border-left-color:var(--pl-warn);background:var(--pl-warn-soft)}.pl-banner[data-tone=info]{border-left-color:var(--pl-accent);background:var(--pl-accent-soft)}.pl-banner h3{margin:0;font-size:14.5px;font-weight:650}.pl-banner h3:focus{outline:none}.pl-banner p{margin:0}.pl-banner details summary{cursor:pointer;font-size:12.5px;color:var(--pl-muted)}.pl-banner details p{margin-top:6px}.pl-panel{background:var(--pl-surface);border-left:1px solid var(--pl-border);display:flex;flex-direction:column;min-height:100%}.pl-panel[data-mode=drawer]{position:fixed;inset:0 0 0 auto;width:min(420px,90vw);z-index:20;overflow-y:auto;box-shadow:-18px 0 40px -24px #00000073;animation:pl-slide .18s ease-out}.pl-panel[data-mode=sheet]{position:fixed;inset:0;z-index:20;border-left:0;overflow-y:auto}.pl-scrim{position:fixed;inset:0;z-index:19;background:color-mix(in oklab,var(--pl-text) 28%,transparent)}@keyframes pl-slide{0%{transform:translate(24px);opacity:.6}}@media(prefers-reduced-motion:reduce){.pl-pill[data-state=syncing]:before{animation:none}.pl-panel[data-mode=drawer]{animation:none}}';function Re(t,e,n){if(t.getElementById(e))return;let r=t.createElement("style");r.id=e,r.textContent=Le+n,(t.head??t.documentElement).appendChild(r)}function y(t,{variant:e,onClick:n,ariaLabel:r,disabled:i,iconOnly:a,key:c,...l}={}){return o("button",{type:"button",class:"pl-btn","data-variant":e,"data-icon-only":a,"aria-label":r,"data-key":c,disabled:i,onclick:n,...l},t)}function ut(t,e,n,r){return o("button",{type:"button",class:"pl-chip","aria-pressed":String(e),"data-key":r,onclick:n},t)}function ft(t,e){return o("span",{class:"pl-pill","data-state":t,role:"status"},e)}function De({title:t,context:e,status:n,action:r}){return o("header",{class:"pl-header"},o("h1",{},t),e?o("div",{class:"pl-context"},e):void 0,o("span",{class:"pl-spacer"}),n,r)}function gt({heading:t,text:e,action:n,secondary:r,extra:i}){return o("div",{class:"pl-empty"},t?o("h2",{},t):void 0,o("p",{},e),n||r?o("div",{class:"pl-actions"},n,r):void 0,i)}function H({tone:t,title:e,text:n,body:r,action:i,details:a}){return o("div",{class:"pl-banner","data-tone":t,role:t==="info"?"note":"alert"},e?o("h3",{tabindex:"-1"},e):void 0,o("p",{},n),r,i?o("div",{},i):void 0,a?o("details",{},o("summary",{},"Technical details"),o("p",{class:"pl-mono"},a)):void 0)}function Fe(t,e,n,r){return o("nav",{class:"pl-tabs",role:"tablist","aria-label":r},t.map(i=>o("button",{type:"button",role:"tab","aria-selected":String(i.id===e),"data-key":`tab-${i.id}`,onclick:()=>n(i.id)},i.label,i.count!==void 0?o("span",{class:"pl-count pl-num"},i.count):void 0)))}function $e(t,e,...n){return o("aside",t==="side"?{class:"pl-panel","data-mode":t,role:"region","aria-label":e}:{class:"pl-panel","data-mode":t,role:"dialog","aria-modal":"true","aria-label":e},n)}var Pe=t=>t>=900?"side":t>=560?"drawer":"sheet";var Fn='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function $n(t){let e=t.ownerDocument.activeElement,n=e&&t.contains(e)?e.dataset.key:void 0,r=new Map;for(let c of t.querySelectorAll("[data-scroll-key]"))r.set(c.dataset.scrollKey,{top:c.scrollTop,left:c.scrollLeft});let i=e,a=i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA");return{key:n,start:a?Ut(()=>i.selectionStart):void 0,end:a?Ut(()=>i.selectionEnd):void 0,scroll:r}}function Ut(t){try{return t()}catch{return}}function Pn(t,e){for(let[r,i]of e.scroll){let a=t.querySelector(`[data-scroll-key="${CSS.escape(r)}"]`);a&&(a.scrollTop=i.top,a.scrollLeft=i.left)}if(!e.key)return;let n=t.querySelector(`[data-key="${CSS.escape(e.key)}"]`);!n||n===t.ownerDocument.activeElement||(n.focus({preventScroll:!0}),(n.tagName==="INPUT"||n.tagName==="TEXTAREA")&&typeof e.start=="number"&&Ut(()=>n.setSelectionRange(e.start,e.end??e.start)))}function Oe(t,e){let n=$n(t);t.replaceChildren(...e),Pn(t,n)}function Be(t,e){if(e.key!=="Tab")return;let n=[...t.querySelectorAll(Fn)].filter(c=>!c.closest("[hidden]"));if(!n.length)return;let r=n[0],i=n[n.length-1],a=t.ownerDocument.activeElement;e.shiftKey&&(a===r||!t.contains(a))?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())}function _e(t){let e=t.target;return e?e.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(e.tagName):!1}var et=t=>new Date(Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10))),it=(t,e)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...e}),Jt=(t,e)=>it(e,{weekday:"short",day:"numeric",month:"short"}).format(et(t)),Z=(t,e)=>it(e,{day:"numeric",month:"short"}).format(et(t)),K=(t,e)=>it(e,{day:"numeric",month:"short",year:"numeric"}).format(et(t)),Ct=(t,e)=>it(e,{weekday:"short",day:"numeric",month:"short",year:"numeric"}).format(et(t));function Q(t,e,n){return t===e?K(t,n):it(n,{day:"numeric",month:"short",year:"numeric"}).formatRange(et(t),et(e))}function Nt(t,e,n){switch(t.kind){case"all":return"all periods";case"this-month":case"last-month":{let{from:r}=Et(t,e);return it(n,{month:"long",year:"numeric"}).format(et(r))}case"this-year":return e.slice(0,4);case"custom":return t.from&&t.to?Q(t.from,t.to,n):t.from?`from ${K(t.from,n)}`:t.to?`until ${K(t.to,n)}`:"all periods"}}var He=/^[A-Z]{2}\d{2}[A-Z0-9]{8,30}$/,On={BUNQ:"bunq",RABO:"Rabo",INGB:"ING",ABNA:"ABN AMRO",KNAB:"Knab",TRIO:"Triodos",ASNB:"ASN",SNSB:"SNS",RBRB:"RegioBank"},Bn=t=>t.replace(/(.{4})(?=.)/g,"$1 ");function D(t){let e=t.replace(/\s+/g,"");return He.test(e)?Bn(e):t}function _(t){let e=t.replace(/\s+/g,"");if(e.length<=10)return t;let n=e.slice(-6),r=`\u2026${n.slice(0,4)} ${n.slice(4)}`;if(!He.test(e))return r;let i=e.slice(4,8),a=On[i]??(/^[A-Z]{4}$/.test(i)?i:"");return a?`${a} ${r}`:r}var U=t=>t==="camt053"?"camt.053":t==="mt940"?"MT940":"",Wt=t=>t<1024?`${t} bytes`:t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,S=(t,e)=>new Intl.NumberFormat(e).format(t),O=(t,e,n,r)=>`${S(t,r)} ${t===1?e:n}`;var je={category:"Category",note:"Note"};function ze(t,e,n,r){let{state:i}=t,a=i.edits[n],c=i.drafts[n]??a?.value??e[n],l=`money-${n}`,s={id:l,class:"m-input","data-key":`note-${n}-${e.subject}`,value:c,"aria-invalid":a?.status==="error"?"true":void 0,"aria-describedby":a?.status==="error"?`${l}-error`:void 0,oninput:m=>r.draft(n,m.target.value),onchange:m=>r.saveNote(n,m.target.value)},p=n==="category"?o("input",{...s,type:"text",list:"money-categories",autocomplete:"off",placeholder:"Uncategorised"}):o("textarea",{...s,placeholder:"Add a note",rows:"3"});n==="note"&&(p.textContent=c);let d=[o("div",{class:"m-field"},o("label",{for:l},je[n]),p)];return a?.status==="error"&&d.push(o("div",{id:`${l}-error`},H({tone:"neg",text:`Couldn't save the ${je[n].toLowerCase()}. ${a.message??""}`.trim(),action:y(t.state.rowAccess==="denied"?"Ask again":"Retry",{onClick:()=>r.saveNote(n,a.value),key:`retry-${n}`}),details:a.details}))),d}function _n(t,e){let{rowAccess:n,rowAccessReason:r}=t.state,i=y("Allow editing",{onClick:e.allowEditing,key:"allow-editing"});if(n==="none")return H({tone:"info",text:"Money can show this table. To save categories and notes on its rows, allow it to edit them.",action:i});if(n==="denied")return H({tone:"warn",text:`Editing isn't allowed${r?`: ${r}`:""}. Categories and notes you type are kept here but not saved.`,action:y("Ask again",{onClick:e.allowEditing,key:"allow-editing"})});if(n==="unavailable")return H({tone:"info",text:"Categories and notes can be saved when Money is open as a view of your Bank transactions table."})}function Hn(t,e,n){let r=Object.values(t.state.edits),i=r.some(l=>l?.status==="asking"),a=r.some(l=>l?.status==="saving"),c=!a&&!i&&r.some(l=>l?.status==="saved");return o("footer",{class:"m-panel-foot"},o("span",{class:c?"m-saved":"pl-muted","aria-live":"polite"},i?"Waiting for you to allow editing\u2026":a?"Saving\u2026":c?"Saved":""),o("span",{class:"pl-spacer"}),e.statement?y(`Show statement ${e.statement}`,{variant:"ghost",key:"show-statement",onClick:()=>n.showStatement({account:e.account,currency:e.currency,statement:e.statement,format:e.format})}):void 0)}function Ke(t,e,n){let{state:r,locale:i}=t,a=Pe(t.width),{title:c}=st(e),l=()=>n.select(void 0),s=(g,b,v=!1)=>[o("dt",{},g),o("dd",v?{class:"pl-mono"}:{},b||"\u2014")],p=[e.statement,U(e.format)].filter(Boolean).join(" \xB7 "),d=ve(r.rows),m=$e(a,"Transaction details",a==="sheet"?o("div",{class:"m-sheetbar"},y(P.back(),{variant:"ghost",iconOnly:!0,ariaLabel:"Back to transactions",onClick:l,key:"detail-close"}),o("strong",{},"Transaction")):void 0,o("div",{class:"m-panel-head"},o("div",{class:"m-grow"},o("span",{class:"pl-muted m-small"},`${Ct(e.bookingDate,i)} \xB7 ${_(e.account)}`),o("span",{class:"m-big"},ct(e.amount,e.currency,i)),o("b",{},c)),a==="sheet"?void 0:y(P.close(),{variant:"ghost",iconOnly:!0,ariaLabel:"Close details",onClick:l,key:"detail-close"})),o("section",{"aria-labelledby":"money-notes-h"},o("h3",{id:"money-notes-h"},"Your notes"),X(r.fields)?[_n(t,n),...ze(t,e,"category",n),...ze(t,e,"note",n),o("datalist",{id:"money-categories"},d.map(g=>o("option",{value:g})))]:o("p",{class:"pl-muted m-small"},"Category and note need the newer Bank statements schema. Run Set up again on the importer to add them.")),o("section",{"aria-labelledby":"money-bank-h"},o("h3",{id:"money-bank-h"},"From your bank"),o("dl",{class:"m-kv pl-num"},s("Value date",Ct(e.valueDate,i)),s("Booking date",Ct(e.bookingDate,i)),s("Account",`${D(e.account)} \xB7 ${e.currency}`),s("Reference",e.reference,!0),s("Code",e.code,!0),s("Statement",p)),e.description?o("pre",{class:"m-narr pl-mono","aria-label":"Original bank narrative"},e.description):void 0),Hn(t,e,n));return{mode:a,nodes:a==="side"?[m]:[o("div",{class:"pl-scrim",onclick:l}),m]}}var q=t=>t<560;function jn(t,e){let n=Ht(t.rows,t.filters,e),r=ye(jt(t.rows,t.filters,e)),i=new Map(vt(n).map(l=>[dt(l.account,l.currency),l])),a=St(t.rows).map(l=>i.get(l.key)??{account:l.account,currency:l.currency,in:"0",out:"0",net:"0",count:0}),c=jt(t.rows,{...t.filters,uncategorised:!1},e).filter(l=>!l.category).length;return{filtered:r,visible:r.slice(0,t.limit),strip:a,uncategorised:c}}function st(t){let e=t.description.split(` +`).map(n=>n.trim()).filter(Boolean);return{title:e[0]||t.reference||"Transaction",rest:e.slice(1).join(" ")}}function ct(t,e,n,{symbol:r=!0,suffix:i=!1,sign:a="always"}={}){return o("span",{class:"m-amt","data-dir":wt(t)?"out":"in","aria-label":be(t,e,n??"en")},R(t,e,n,{symbol:r,sign:a}),i?o("small",{},e):void 0)}var qe=(t,e)=>t.map(n=>R(n.amount,n.currency,e)).join(" \xB7 ");function Ge(t,e){return gt({heading:"Bring in your bank transactions",text:"Export a statement from your bank as MT940 or camt.053 and drop it here. The file is checked in your browser and stored only in this Atomic Server.",extra:[o("div",{class:"m-drop"},y([P.upload(),"Choose statement file"],{variant:"primary",onClick:e.chooseFile,key:"first-run-choose"}),o("span",{class:"m-formats"},"or drop it here \xB7 MT940 up to 512 KB \xB7 camt.053 XML up to 5 MB \xB7 up to 500 transactions")),zn(),o("div",{class:"m-sources-mini"},ht({logo:"MB",name:"Moneybird",why:"Read your financial mutations alongside bank statements. Not available yet.",action:y("Connect",{disabled:!0})}))]})}function zn(){return o("details",{class:"m-help"},o("summary",{},"How do I export a statement?"),o("ul",{},o("li",{},o("b",{},"bunq"),": account \u2192 Settings \u2192 Export statement \u2192 MT940."),o("li",{},o("b",{},"ING, Rabobank, ABN AMRO"),": download transactions \u2192 choose MT940 or camt.053. Menu names differ per bank.")))}function ht({logo:t,name:e,tag:n,why:r,action:i}){return o("div",{class:"m-src"},o("span",{class:"m-logo","aria-hidden":"true"},t),o("span",{class:"m-grow"},o("span",{class:"m-name"},e,n?o("span",{class:"m-tag"},n):void 0),o("span",{class:"m-why"},r)),i)}function Ue(t,e){let n=St(t.state.rows),r=q(t.width);return o("select",{class:"m-switcher","aria-label":"Account","data-key":"account",onchange:i=>e.setFilters({account:i.target.value})},o("option",{value:"",selected:t.state.filters.account===""},`All accounts \xB7 ${n.length}`),n.map(i=>o("option",{value:i.key,selected:t.state.filters.account===i.key},`${r?_(i.account):D(i.account)} \xB7 ${i.currency}`)))}function Kn(t,e){let{state:n,locale:r,today:i}=t,a=n.statements?ke(n.statements,e.account,e.currency,n.filters.period,i):void 0;return a?o("span",{class:"m-net"},R(a.amount,e.currency,r,{sign:"negative"}),o("small",{},`on ${Z(a.date,r)}`)):o("span",{class:"m-net"},R(e.net,e.currency,r),o("small",{},"net"))}function Vn(t,e,n){let{state:r,locale:i,today:a}=t,c=q(t.width),l=Nt(r.filters.period,a,i);return o("div",{class:"m-strip",role:"group","aria-label":`Accounts, ${l}`,"data-scroll-key":"strip"},e.strip.map(s=>{let p=dt(s.account,s.currency),d=r.filters.account===p;return o("button",{type:"button",class:"m-seg","aria-pressed":String(d),"data-key":`seg-${p}`,onclick:()=>n.setFilters({account:d?"":p})},o("span",{class:"m-acct pl-num"},`${c?_(s.account):D(s.account)} \xB7 ${s.currency}`),Kn(t,s),o("span",{class:"m-flow pl-num"},o("span",{class:"m-amt","data-dir":"in"},`${R(s.in,s.currency,i)} in`),o("span",{},`${R(s.out,s.currency,i,{sign:"negative"})} out`)))}))}var qn=[["this-month","This month"],["last-month","Last month"],["this-year","This year"],["custom","Custom\u2026"]];function Ve(t,e,n){let{state:r}=t,i=r.filters,a=i.period;return o("div",{class:"m-filters"},o("label",{class:"m-search"},P.search(),o("input",{type:"search",placeholder:q(t.width)?"Search":"Search description or reference","aria-label":"Search transactions","aria-keyshortcuts":"/",value:i.query,"data-key":"search",oninput:c=>n.setFilters({query:c.target.value})}),o("kbd",{"aria-hidden":"true"},"/")),o("div",{class:"m-chiprow","data-scroll-key":"chips"},o("div",{class:"pl-chips",role:"group","aria-label":"Period"},qn.map(([c,l])=>ut(l,a.kind===c,()=>n.setFilters({period:a.kind===c?{kind:"all"}:c==="custom"?{kind:c,from:"",to:""}:{kind:c}}),`period-${c}`))),a.kind==="custom"?o("div",{class:"m-custom"},o("label",{},"From ",o("input",{type:"date",value:a.from??"","data-key":"custom-from",onchange:c=>n.setFilters({period:{...a,from:c.target.value}})})),o("label",{},"to ",o("input",{type:"date",value:a.to??"","data-key":"custom-to",onchange:c=>n.setFilters({period:{...a,to:c.target.value}})}))):void 0,o("span",{class:"m-sep","aria-hidden":"true"}),o("div",{class:"pl-chips",role:"group","aria-label":"Direction"},[["all","All"],["in","In"],["out","Out"]].map(([c,l])=>ut(l,i.direction===c,()=>n.setFilters({direction:c}),`direction-${c}`))),X(r.fields)?ut(`Uncategorised \xB7 ${S(e.uncategorised,t.locale)}`,i.uncategorised,()=>n.setFilters({uncategorised:!i.uncategorised}),"uncategorised"):void 0,i.statement?ut(`Statement ${i.statement.statement} \u2715`,!0,()=>n.setFilters({statement:void 0}),"statement"):void 0))}function Je(t,e){let{state:n,locale:r,today:i}=t,a=n.filters.account?St(n.rows).find(c=>c.key===n.filters.account):void 0;return[a?`${D(a.account)} \xB7 ${a.currency}`:"All accounts",Nt(n.filters.period,i,r).replace(/^all/,"All"),O(e.filtered.length,"transaction","transactions",r)].join(" \xB7 ")}function Gn(t,e){let{filters:n}=t.state,r=Nt(n.period,t.today,t.locale),i=n.period.kind==="all"?"":` in ${r}`,a=n.query.trim()?`No transactions match \u201C${n.query.trim()}\u201D${i}.`:`No transactions${i} for these filters.`;return gt({text:a,action:y("Clear filters",{onClick:e.clearFilters,key:"clear-filters"}),secondary:n.period.kind!=="all"?y("Search all periods",{variant:"ghost",onClick:()=>e.setFilters({period:{kind:"all"}}),key:"all-periods"}):void 0})}function Un(t,e,n){let{state:r,locale:i}=t,a=X(r.fields),c=_t(e.visible),l=a?4:3,s=e.visible.find(p=>p.subject===r.selected)?.subject??e.visible[0]?.subject;return o("table",{class:"m-ledger"},o("caption",{},Je(t,e)),o("thead",{},o("tr",{},o("th",{scope:"col",style:"width: 44%"},"Description"),a?o("th",{scope:"col"},"Category"):void 0,o("th",{scope:"col"},"Account"),o("th",{scope:"col"},"Amount"))),c.map(p=>o("tbody",{},o("tr",{class:"m-day"},o("th",{colspan:String(l),scope:"rowgroup"},Jt(p.date,i),o("span",{class:"pl-num"},qe(p.net,i)))),p.rows.map(d=>{let{title:m,rest:g}=st(d),b=d.subject===r.selected;return o("tr",{class:"m-row","aria-selected":String(b),onclick:()=>n.select(d.subject)},o("td",{class:"m-desc"},o("button",{type:"button",class:"m-rowbtn","data-key":`row-${d.subject}`,"data-row":d.subject,tabindex:d.subject===s?"0":"-1","aria-expanded":String(b)},o("b",{},m),g?o("span",{class:"m-rest"},g):void 0)),a?o("td",{},We(d.category)):void 0,o("td",{class:"m-acctcell"},_(d.account)),o("td",{},ct(d.amount,d.currency,i)))}))))}var We=t=>t?o("span",{class:"m-cat"},t):o("span",{class:"m-cat","data-none":!0},"Uncategorised");function Jn(t,e,n){let{state:r,locale:i}=t,a=X(r.fields),c=e.visible.find(l=>l.subject===r.selected)?.subject??e.visible[0]?.subject;return o("div",{class:"m-list",role:"region","aria-label":Je(t,e)},_t(e.visible).map(l=>{let s=`money-day-${l.date}`;return[o("h3",{class:"m-dayh",id:s},Jt(l.date,i),o("span",{class:"pl-num"},qe(l.net,i))),o("ul",{"aria-labelledby":s},l.rows.map(p=>{let{title:d}=st(p);return o("li",{},o("button",{type:"button",class:"m-item","data-key":`row-${p.subject}`,"data-row":p.subject,tabindex:p.subject===c?"0":"-1","aria-current":p.subject===r.selected?"true":void 0,onclick:()=>n.select(p.subject)},o("span",{class:"m-t"},d),ct(p.amount,p.currency,i,{symbol:!1,suffix:!0}),o("span",{class:"m-s"},a?We(p.category):void 0,p.note?o("span",{},p.note.split(` +`)[0]):a?void 0:o("span",{},_(p.account)))))}))]}))}function Ye(t,e){let n=Wn(t,e),r=t.state.rows.find(a=>a.subject===t.state.selected);if(!r)return n;let i=Ke(t,r,e);return i.mode==="side"?[o("div",{class:"m-split"},o("div",{class:"m-main"},n),i.nodes)]:[...n,...i.nodes]}function Wn(t,e){let n=jn(t.state,t.today),r=n.filtered.length-n.visible.length,i=n.filtered.length?[Vn(t,n,e),Ve(t,n,e)]:[Ve(t,n,e)];return n.filtered.length?(i.push(q(t.width)?Jn(t,n,e):Un(t,n,e)),r>0&&i.push(o("div",{class:"m-more"},y("Show earlier transactions",{onClick:e.showMore,key:"show-more"}),o("span",{class:"pl-muted"},`${S(n.visible.length,t.locale)} of ${S(n.filtered.length,t.locale)} shown`)))):i.push(Gn(t,e)),i}var Xe=t=>{let{file:e}=t,n=e.format?`${U(e.format)}${e.format==="camt053"?" XML":""}`:"";return o("div",{class:"m-file"},o("span",{class:"m-doc","aria-hidden":"true"},e.format==="camt053"?"XML":e.format==="mt940"?"940":""),o("div",{},o("b",{},e.name),o("div",{class:"pl-muted pl-num m-small"},[Wt(e.size),n,t.step==="checking"&&n?"detected from contents":""].filter(Boolean).join(" \xB7 "))))};function Yn(t,e){let{locale:n}=t,r=[e.counts?`Read file \xB7 ${O(e.counts.statements,"statement","statements",n)}, ${O(e.counts.entries,"entry","entries",n)}`:"Read file","Check balances",`Compare with ${O(t.state.rows.length,"existing transaction","existing transactions",n)}`];return o("ul",{class:"m-checklist"},r.map((i,a)=>o("li",{"data-status":e.lines[a]},o("span",{class:"m-st","aria-hidden":"true"},e.lines[a]==="done"?"\u2713":""),i,o("span",{class:"pl-sr"},e.lines[a]==="done"?", done":e.lines[a]==="now"?", in progress":", to do"))))}function Xn(t,e){let{locale:n}=t,r=i=>R(i,e.currency,n,{sign:"negative"});return o("div",{class:"m-stmt"},o("div",{class:"m-top"},o("span",{class:"pl-num"},`${D(e.account)} \xB7 ${e.currency}`),o("span",{},`Statement ${e.number}`)),o("div",{class:"pl-muted pl-num m-small"},`${Q(e.start,e.end,n)} \xB7 ${O(e.transactions.length,"entry","entries",n)}`),o("div",{class:"m-flowline pl-num"},o("span",{},r(e.opening)),o("span",{class:"m-arrow","aria-label":"to"},"\u2192"),o("span",{},r(e.closing))),o("div",{class:"m-ok"},"Balances match"))}function Zn(t,e,n){let{locale:r}=t,i=[...new Set(e.map(l=>l.currency))],a=i.length===1?i[0]:void 0,c=e.slice(0,200);return o("div",{class:"m-scroll","data-scroll-key":"preview-rows"},o("table",{class:"m-ledger m-preview"},o("caption",{class:"pl-sr"},n),o("thead",{},o("tr",{},o("th",{scope:"col"},"Date"),o("th",{scope:"col"},"Description"),o("th",{scope:"col",class:"m-hide-narrow"},"Account"),o("th",{scope:"col"},a?`Amount (${a})`:"Amount"))),o("tbody",{},c.map(l=>{let{title:s,rest:p}=st(l);return o("tr",{},o("td",{class:"pl-num m-nowrap"},Z(l.date,r)),o("td",{class:"m-desc"},o("b",{},s),p?o("span",{class:"m-rest"},p):void 0),o("td",{class:"m-acctcell m-hide-narrow"},_(l.account).replace(/^\S+ (?=…)/,"")),o("td",{},ct(l.amount,l.currency,r,{symbol:!a})))}))),e.length>c.length?o("p",{class:"pl-muted m-small"},`${S(e.length-c.length,r)} more not listed.`):void 0)}function Qn(t,e,n){let{locale:r,state:i}=t,{fresh:a,already:c,statements:l,withoutReference:s}=e.preview,p=a.length+c.length,d=[["new","New",a.length],["already","Already imported",c.length],["blocked","Blocked",0]],m=e.tab==="new"?a:e.tab==="already"?c:[],g=[o("div",{class:"m-recon"},l.map(v=>Xn(t,v)))];a.length?g.push(o("div",{class:"m-subtabs",role:"tablist","aria-label":"Transactions in this file"},d.map(([v,F,h])=>o("button",{type:"button",role:"tab","aria-selected":String(e.tab===v),"data-key":`preview-tab-${v}`,onclick:()=>n.setPreviewTab(v)},`${F} `,o("b",{class:"pl-num"},S(h,r))))),m.length?Zn(t,m,`${O(m.length,"transaction","transactions",r)}, newest first`):o("p",{class:"pl-muted"},e.tab==="blocked"?"Nothing in this file is blocked.":"None.")):g.push(o("p",{class:"m-nothing"},`Nothing new in this file. ${p===1?"Its one transaction was":`All ${S(p,r)} transactions were`} imported before.`)),s&&g.push(H({tone:"info",text:`${O(s,"transaction has","transactions have",r)} no unique bank reference. Importing this same file again is safe; an overlapping export of a different period would be blocked.`})),a.length&&!i.canApply&&g.push(o("div",{id:"money-apply-note"},H({tone:"info",title:"Import this file from the Bank statements importer",text:`Apps can't run the importer yet, so this check changes nothing. Open the importer's Import tab and choose ${e.file.name} there: it proposes the same ${O(a.length,"new transaction","new transactions",r)}.`,action:i.importer?y("Open the importer",{onClick:n.openImporter,key:"open-importer"}):void 0,details:i.openFailure}))),e.failure&&g.push(H({tone:"neg",title:"The import didn't go through",text:"Nothing was saved. Try again, or import the file from the importer\u2019s page.",details:e.failure}));let b=o("span",{class:"m-grow pl-num"},a.length?`${S(a.length,r)} new \xB7 ${S(c.length,r)} already imported, skipped`:"");return{body:g,footer:a.length?[b,y("Cancel",{onClick:n.closeImport,key:"import-cancel"}),y(e.applying?"Importing\u2026":`Import ${O(a.length,"transaction","transactions",r)}`,{variant:"primary",disabled:!i.canApply||e.applying,onClick:n.applyImport,key:"import-apply","aria-describedby":i.canApply?void 0:"money-apply-note"})]:[b,y("Close",{variant:"primary",onClick:n.closeImport,key:"import-close-footer"})]}}function tr(t,e,n){let{locale:r}=e,i="Export a shorter period from your bank, then choose it here.";switch(t.code){case"BALANCE_MISMATCH":{let a=t.data;return{title:"Balances in this statement don't add up",text:`Statement ${a.statement} for ${D(a.account)} ends on a different balance than its entries produce. The file may be cut off or edited. Nothing was imported.`,hint:"Download the statement from your bank again, then choose it here."}}case"CHANGED_TRANSACTION":{let a=t.changed,c=(t.count??1)>1?` ${O((t.count??1)-1,"other transaction differs","other transactions differ",r)} too.`:"";return{title:"This file changes a transaction you already have",text:`Bank reference ${a.mine.reference||a.file.reference} was imported on ${K(a.mine.bookingDate,r)} with different details. To protect your records, nothing in this file was imported.${c}`,hint:"Usually this means the bank corrected a booking, or the file was edited after download. Export the original statement again, or ask your bank which version is right."}}case"OVERLAP_WITHOUT_REFERENCES":{let a=t.data;return{title:"This statement overlaps an earlier import",text:`Statement ${a.statement} (${Q(a.thisPeriod.start,a.thisPeriod.end,r)}) has transactions without bank references that match ones you already imported${a.overlappingDate?`, from ${K(a.overlappingDate,r)}`:""}. Nothing was imported.`,hint:"Export a non-overlapping period, or use the original statement."}}case"REPEATED_REFERENCE":return{title:"The same transaction appears twice in this file",text:`Bank reference ${t.data.reference} is in this file twice. Nothing was imported.`,hint:"Export statements that don\u2019t overlap, then choose one here."};case"CONFLICTING_REFERENCE":return{title:"Two transactions in this file share a bank reference",text:`Bank reference ${t.data.reference} is used by two different transactions. Nothing was imported.`,hint:"Export the statement from your bank again, then choose it here."};case"FILE_TOO_LARGE":return{title:t.data.format==="mt940"?"This statement is larger than 512 KB":"This statement is larger than 5 MB",text:`The file is ${Wt(n)}. Nothing was imported.`,hint:i};case"TOO_MANY_ENTRIES":return{title:"This statement has more than 500 transactions",text:"One import takes at most 500. Nothing was imported.",hint:i};case"JSON_NARRATIVE":{let a=t.data;return{title:"This statement has descriptions we can't store safely yet",text:`${O(a.count,"description looks","descriptions look",r)} like JSON, which this server would not keep as plain text. Nothing was imported.`,hint:"This is a known gap in the importer; there is no workaround yet."}}case"MISSING_BALANCE":return{title:"This statement has no opening or closing balance",text:"Without both, its balances can't be checked, so nothing was imported.",hint:"Export the full statement from your bank again."};case"INVALID_FIELD":{let a=t.data;return{title:"This file couldn't be read as a bank statement",text:`${a.line?`Line ${S(a.line,r)} (field :${a.tag}:)`:a.tag==="xml"?"The XML":`A ${a.tag} element`} isn't in a form the reader knows. Nothing was imported.`,hint:"Choose an MT940 or camt.053 export straight from your bank."}}default:return{title:"This isn't a bank statement we can read",text:"Choose an MT940 or camt.053 (ISO 20022 XML) export from your bank. Nothing was imported.",hint:"Most banks offer MT940 or camt.053 under their download or export options."}}}function er(t,e){let{locale:n}=t,r=(c,l="negative")=>R(c,e.currency,n,{sign:l}),i=fe([e.closing,ue(e.expectedClosing)]),a=(c,l,s)=>o("tr",s?{class:s}:{},o("td",{},c),o("td",{},l));return o("table",{class:"m-figs"},o("tbody",{},a(`Opening balance, ${Z(e.start,n)}`,r(e.opening)),a(O(e.entries,"entry","entries",n),r(e.entriesSum,"always")),a("Expected closing",r(e.expectedClosing),"m-total"),a(`Closing in file, ${Z(e.end,n)}`,r(e.closing)),a("Difference",r(i),"m-bad")))}function nr(t,e){let n=e.changed;if(!n)return;let{locale:r}=t,{mine:i,file:a}=n,c=(l,s,p,d)=>{let m=n.fields.includes(s);return[o("div",{class:"m-k",role:"rowheader"},l),o("div",{role:"cell"},p),o("div",{role:"cell",class:m?"m-chg":void 0},d,m?o("span",{class:"pl-sr"}," (changed)"):void 0)]};return o("div",{class:"m-compare",role:"table","aria-label":"Differences"},o("div",{role:"row",class:"m-compare-row"},o("div",{class:"m-h",role:"columnheader"}),o("div",{class:"m-h",role:"columnheader"},"In your table"),o("div",{class:"m-h",role:"columnheader"},"In this file")),o("div",{role:"row",class:"m-compare-row"},c("Date","date",K(i.bookingDate,r),K(a.date,r))),o("div",{role:"row",class:"m-compare-row"},c("Amount","amount",R(i.amount,i.currency,r,{sign:"negative"}),R(a.amount,a.currency,r,{sign:"negative"}))),o("div",{role:"row",class:"m-compare-row"},c("Description","description",i.description,a.description)),o("div",{role:"row",class:"m-compare-row"},c("Account","account",D(i.account),D(a.account))))}function rr(t,e,n){let{problem:r}=e,i=tr(r,t,e.file.size),a=e.step==="blocked";return{body:[...r.code==="CHANGED_TRANSACTION"?[]:[Xe(e)],H({tone:a?"warn":"neg",title:i.title,text:i.text,body:r.code==="BALANCE_MISMATCH"?er(t,r.data):void 0,details:r.message}),...r.code==="CHANGED_TRANSACTION"?[nr(t,r),o("p",{class:"pl-muted m-hint"},i.hint)]:[]],footer:[o("span",{class:"m-grow"},r.code==="CHANGED_TRANSACTION"?"":i.hint),y(a?"Cancel import":"Close",{onClick:n.closeImport,key:"import-cancel"}),y("Choose another file",{variant:"primary",onClick:n.chooseFile,key:"import-again"})]}}function Ze(t,e,n){let r=e.step==="checking"?{body:[Xe(e),Yn(t,e)],footer:[o("span",{class:"m-grow"},"Nothing is saved until you confirm."),y("Cancel",{onClick:n.closeImport,key:"import-cancel"})]}:e.step==="preview"?Qn(t,e,n):rr(t,e,n),i=e.step==="checking"?o("span",{class:"m-steps"},"Step 1 of 2 \xB7 Check"):e.step==="preview"?o("span",{class:"m-steps"},"Step 2 of 2 \xB7 Review"):e.step==="error"?ft("error","Import failed"):ft("paused","Blocked");return[o("div",{class:"pl-scrim m-sheet-scrim"}),o("div",{class:"m-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"money-import-title","data-step":e.step},o("header",{},o("h2",{id:"money-import-title"},"Import statement"),i,y(P.close(),{variant:"ghost",iconOnly:!0,ariaLabel:"Close",onClick:n.closeImport,key:"import-close"})),o("div",{class:"m-body","data-scroll-key":"import-body"},r.body),o("footer",{},r.footer))]}function Qe(t){let e=t.importing;if(e){if(e.step==="checking")return{state:"syncing",text:e.lines[0]!=="done"?"Reading file\u2026":e.lines[1]!=="done"?"Checking balances\u2026":"Comparing\u2026"};if(e.step==="error")return{state:"error",text:"Import failed"};if(e.step==="blocked")return{state:"paused",text:"Blocked"}}}function tn(t,e){let{state:n,locale:r}=t;if(n.statements?.length)return or(t,e);let i=Tt(n.rows);if(!i.length)return[gt({heading:"No imports yet",text:"Each statement you import shows up here, with its account, period and number of transactions.",action:y([P.upload(),"Import statement"],{variant:"primary",onClick:e.chooseFile,key:"imports-choose"})})];let a=q(t.width),c=p=>{let[d]=vt(p);return[o("span",{class:"m-line"},`${R(d.in,d.currency,r)} in`),o("span",{class:"m-line"},`${R(d.out,d.currency,r,{sign:"negative"})} out`)]},l=p=>`${t.width<900?_(p.account):D(p.account)} \xB7 ${p.currency}`,s=o("p",{class:"pl-muted m-small m-pad"},"Built from the imported transactions. Opening and closing balances and import dates are not stored yet.");return a?[o("ul",{class:"m-list m-flat","aria-label":"Imported statements"},i.map(p=>o("li",{},o("button",{type:"button",class:"m-item","data-key":`import-${JSON.stringify(p.key)}`,onclick:()=>e.showStatement(p.key)},o("span",{class:"m-t"},`${_(p.key.account)} \xB7 ${p.key.currency}`),o("span",{class:"pl-muted pl-num"},`Statement ${p.key.statement||"\u2014"}`),o("span",{class:"m-s pl-num"},o("span",{},`${Q(p.start,p.end,r)} \xB7 ${S(p.entries,r)} \xB7 ${U(p.key.format)}`)))))),s]:[o("table",{class:"m-ledger m-imports"},o("caption",{},`${S(i.length,r)} imported statements, newest first`),o("thead",{},o("tr",{},o("th",{scope:"col"},"Account"),o("th",{scope:"col"},"Period"),o("th",{scope:"col"},"Statement"),o("th",{scope:"col"},"Format"),o("th",{scope:"col"},"In \xB7 out"),o("th",{scope:"col"},"Entries"))),o("tbody",{},i.map(p=>o("tr",{class:"m-row",onclick:()=>e.showStatement(p.key)},o("td",{},o("button",{type:"button",class:"m-rowbtn","data-key":`import-${JSON.stringify(p.key)}`,"aria-label":`Show the transactions of statement ${p.key.statement||"without a number"} for ${D(p.key.account)} ${p.key.currency}`},o("b",{},l(p.key)))),o("td",{class:"pl-num m-nowrap"},Q(p.start,p.end,r)),o("td",{class:"pl-num"},p.key.statement||"\u2014"),o("td",{},U(p.key.format)||"\u2014"),o("td",{class:"pl-num m-small"},c(p.rows)),o("td",{class:"pl-num"},S(p.entries,r)))))),s]}function or(t,e){let{locale:n}=t,r=[...t.state.statements].sort((s,p)=>s.end===p.end?s.account({account:s.account,currency:s.currency,statement:s.number,format:s.format}),a=s=>`${q(t.width)||t.width<900?_(s.account):D(s.account)} \xB7 ${s.currency}`,c=(s,p)=>R(p,s.currency,n,{sign:"negative"}),l=s=>s.start?Q(s.start,s.end,n):K(s.end,n);return q(t.width)?[o("ul",{class:"m-list m-flat","aria-label":"Imported statements"},r.map(s=>o("li",{},o("button",{type:"button",class:"m-item","data-key":`import-${s.subject}`,onclick:()=>e.showStatement(i(s))},o("span",{class:"m-t"},a(s)),o("span",{class:"pl-num m-strong"},c(s,s.closing)),o("span",{class:"m-s pl-num"},o("span",{},`Statement ${s.number||"\u2014"} \xB7 ${l(s)} \xB7 ${U(s.format)}`))))))]:[o("table",{class:"m-ledger m-imports"},o("caption",{},`${S(r.length,n)} imported statements, newest first`),o("thead",{},o("tr",{},o("th",{scope:"col"},"Account"),o("th",{scope:"col"},"Period"),o("th",{scope:"col"},"Statement"),o("th",{scope:"col"},"Opening \u2192 closing"),o("th",{scope:"col"},"Entries"),o("th",{scope:"col"},"Imported"))),o("tbody",{},r.map(s=>o("tr",{class:"m-row",onclick:()=>e.showStatement(i(s))},o("td",{},o("button",{type:"button",class:"m-rowbtn","data-key":`import-${s.subject}`,"aria-label":`Show the transactions of statement ${s.number||"without a number"} for ${D(s.account)} ${s.currency}`},o("b",{},a(s)),o("span",{class:"m-line pl-muted m-small"},U(s.format)))),o("td",{class:"pl-num m-nowrap"},l(s)),o("td",{class:"pl-num"},s.number||"\u2014"),o("td",{class:"pl-num"},o("span",{class:"m-line"},`${c(s,s.opening)} \u2192`),o("b",{class:"m-line"},c(s,s.closing))),o("td",{class:"pl-num"},s.entries||"\u2014"),o("td",{class:"pl-num m-nowrap"},s.imported?K(s.imported,n):"\u2014")))))]}function ar(t){let{state:e,locale:n}=t,r=e.view,i=Qe(e);if(i)return i;switch(r.kind){case"loading":return{state:"syncing",text:r.total?`Loading ${S(r.loaded,n)} of ${S(r.total,n)}`:"Loading\u2026"};case"error":return{state:"error",text:"Couldn't load"};case"empty":return{state:"idle",text:"No transactions yet"};case"populated":return e.arrived?{state:"synced",text:`Imported ${S(e.arrived.count,n)} \xB7 just now`}:{state:"idle",text:`Latest entry \xB7 ${Z(we(e.rows),n)}`}}}function ir(t,e){return q(t.width)?y(P.upload(),{variant:"primary",iconOnly:!0,ariaLabel:"Import statement",onClick:e.chooseFile,key:"import","aria-keyshortcuts":"i"}):y([P.upload(),"Import statement"],{variant:"primary",onClick:e.chooseFile,key:"import","aria-keyshortcuts":"i"})}function sr(t,e){return o("div",{class:"m-sources"},ht({logo:"940",name:"Statement files",why:`MT940 and camt.053 \xB7 ${t.state.rows.length?`${S(t.state.rows.length,t.locale)} transactions`:"nothing imported yet"}`,action:y("Import statement",{onClick:e.chooseFile})}),ht({logo:"MB",name:"Moneybird",tag:"read-only",why:"Financial mutations alongside your bank statements. Not available yet.",action:y("Connect",{disabled:!0})}),ht({logo:"QB",name:"QuickBooks",why:"Planned. Not available yet."}))}function cr(t,e){let{state:n}=t,r=n.view;return r.kind==="error"?[o("div",{class:"m-pad"},H({tone:"neg",title:"The transactions couldn't be loaded",text:r.message,action:y("Try again",{onClick:e.reload})}))]:n.tab==="sources"?[sr(t,e)]:r.kind==="loading"?[o("p",{class:"m-loading","aria-busy":"true"},"Loading transactions\u2026")]:n.tab==="imports"?tn(t,e):r.kind==="empty"?[Ge(t,e)]:Ye(t,e)}function en(t,e){let{state:n,locale:r}=t,i=ar(t),a=n.view.kind==="populated";return[De({title:"Money",context:a?Ue(t,e):void 0,status:ft(i.state,i.text),action:n.view.kind==="error"?void 0:ir(t,e)}),Fe([{id:"transactions",label:"Transactions",count:a?S(n.rows.length,r):void 0},{id:"imports",label:"Imports",count:a?S(n.statements?.length||Tt(n.rows).length,r):void 0},{id:"sources",label:"Sources"}],n.tab,e.setTab,"Money views"),...cr(t,e),...n.importing?Ze(t,n.importing,e):[],...n.help?[pr(e)]:[]]}var lr=[["/","Search"],["\u2191 \u2193","Move between transactions"],["Enter","Open the transaction"],["Esc","Close details or the import"],["i","Import a statement"],["?","Show or hide these shortcuts"]];function pr(t){return o("div",{class:"m-popover",role:"dialog","aria-labelledby":"money-shortcuts-h"},o("div",{class:"m-popover-head"},o("h2",{id:"money-shortcuts-h"},"Keyboard shortcuts"),y(P.close(),{variant:"ghost",iconOnly:!0,ariaLabel:"Close shortcuts",onClick:()=>t.toggleHelp(!1),key:"help-close"})),o("dl",{class:"m-keys"},lr.map(([e,n])=>[o("dt",{},o("kbd",{},e)),o("dd",{},n)])),o("p",{class:"pl-muted m-small"},"Shortcuts are off while you type in a field."))}async function nn(t,e,n={}){let r=t.ownerDocument,i=r.defaultView??window;Re(r,"money-app-styles",Ne),t.classList.add("pl-app");let a=u=>{u&&(t.dataset.colorScheme=u.colorScheme)};a(e.getTheme?.()),e.onThemeChange?.(a);let c=n.locale??i.navigator?.language,l=n.width??(t.clientWidth||i.innerWidth||1024),s,p,d=r.createElement("input");d.type="file",d.accept=".mt940,.sta,.940,.txt,.xml,.camt,.053",d.hidden=!0;let m={setTab:u=>w.setTab(u),reload:()=>{w.load()},setFilters:u=>w.setFilters(u),clearFilters:()=>w.clearFilters(),showMore:()=>w.showMore(),select:u=>{u===void 0?nt():w.select(u)},draft:(u,A)=>w.draft(u,A),saveNote:(u,A)=>{w.saveNote(u,A)},showStatement:u=>{w.select(void 0),w.setTab("transactions"),w.setFilters({statement:u,account:"",period:{kind:"all"}})},chooseFile:()=>{d.value="",d.click()},closeImport:()=>{w.closeImport(),b?.focus()},setPreviewTab:u=>w.setPreviewTab(u),applyImport:()=>{w.applyImport()},openImporter:()=>{w.openImporter()},allowEditing:()=>{w.allowEditing()},toggleHelp:u=>{w.toggleHelp(u),w.state().help||g?.focus()}},g,b,v=u=>{let A=r.activeElement;!s?.importing&&A&&t.contains(A)&&(b=A),w.importFile({name:u.name,size:u.size,text:async()=>ce(new Uint8Array(await u.arrayBuffer()))})};d.addEventListener("change",()=>{let u=d.files?.[0];u&&v(u)});let F=0,h=u=>[...u.dataTransfer?.types??[]].includes("Files");r.addEventListener("dragenter",u=>{h(u)&&(u.preventDefault(),F++,t.classList.add("m-dropping"))}),r.addEventListener("dragover",u=>{h(u)&&u.preventDefault()}),r.addEventListener("dragleave",()=>{F=Math.max(0,F-1),F||t.classList.remove("m-dropping")}),r.addEventListener("drop",u=>{if(!h(u))return;u.preventDefault(),F=0,t.classList.remove("m-dropping");let A=u.dataTransfer?.files?.[0];A&&v(A)});let J=()=>t.querySelector('[role="dialog"][aria-modal="true"]'),lt=u=>{let A=u.selected&&u.selected!==s?.selected,L=u.importing,V=s?.importing,f=L&&!V,k=L&&(L.step==="error"||L.step==="blocked")&&V?.step!==L.step;s=u,Oe(t,[...en({state:u,width:l,locale:c,today:w.today()},m),d]),A&&J()?.querySelector('[data-key="detail-close"]')?.focus(),k?t.querySelector(".m-dialog .pl-banner h3")?.focus():f&&t.querySelector('[data-key="import-close"]')?.focus()},nt=()=>{let u=s?.selected;u&&(w.select(void 0),t.querySelector(`[data-row="${CSS.escape(u)}"]`)?.focus())},w=Ce(e,lt,{today:n.today,importer:n.importer,tick:n.tick});n.width===void 0&&typeof ResizeObserver<"u"&&new ResizeObserver(()=>{let u=t.clientWidth,A=u<560?"narrow":u<900?"medium":"wide";u&&A!==p?(p=A,l=u,s&<(s)):l=u||l}).observe(t),r.addEventListener("keydown",u=>{if(u.defaultPrevented||u.metaKey||u.ctrlKey)return;let A=J();if(A&&Be(A,u),u.key==="Escape"&&s?.help){u.preventDefault(),m.toggleHelp(!1);return}if(u.key==="Escape"&&s?.importing){u.preventDefault(),m.closeImport();return}if(u.key==="Escape"&&s?.selected){u.preventDefault(),nt();return}if(u.key==="ArrowDown"||u.key==="ArrowUp"){let L=u.target;if(!L.dataset?.row)return;let V=[...t.querySelectorAll("[data-row]")],f=V.indexOf(L),k=V[f+(u.key==="ArrowDown"?1:-1)];if(k){u.preventDefault();for(let x of V)x.tabIndex=x===k?0:-1;k.focus()}return}if(!_e(u))if(u.key==="/"){let L=t.querySelector('[data-key="search"]');L&&(u.preventDefault(),L.focus())}else u.key==="?"&&!A?(u.preventDefault(),s?.help||(g=r.activeElement),m.toggleHelp(),s?.help&&t.querySelector('[data-key="help-close"]')?.focus()):u.key==="i"&&!A&&(u.preventDefault(),m.chooseFile())}),lt(w.state()),await w.load()}async function _o({root:t,store:e}){await nn(t,e)}export{_o as view}; diff --git a/integrations/READINESS.md b/integrations/READINESS.md index 46b649f5a..88ecd87a0 100644 --- a/integrations/READINESS.md +++ b/integrations/READINESS.md @@ -74,19 +74,20 @@ read from the atomic-server source at the pin. ## Matrix -| Plugin (catalog id) | Runtime of the current code | Install entry point at the pin | Import / write scope (declared) | Evidence | Open blockers | -| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Pets, drive app (`pets`) | Drive app `pets/app/`: iframe, `syncables/browser` over `store.proxy` | Integrations → Show experimental plugins → Drive apps → Install (`pets` 0.1.1, from GitHub Pages, integrity-checked). The host E2E installs this way, then updates from an older recorded version | Read-only. Pets from the mock `pets` platform into the app's own table | Unit; **Host E2E** (`pets` lane: catalog install and update, connect, 5 rows, datatypes) | None filed | -| Pets, static demo (`pets`) | Sandbox `pets/plugin.js`, no network | None. Its setup dialog was removed in `4bab16ee6` | Five static pets into a Pets table | Unit; `certify.mjs --layer js`. Historical: Rust sandbox test (removed from atomic-server in `4bab16ee6`) | None filed; the catalog card still describes this demo, not the drive app | -| Notion, drive app (`notion`) | Drive app `notion/app/`: iframe, `syncables/browser` + Devonian `AtomicLens` over `store.proxy`; the #89 UI (table, board and list views, side peek, sync details, Disconnect) | Published (`notion` 0.1.0 on GitHub Pages) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | Read-only. Every shared data source into one table; plain fields and select/status/multi-select options only | Unit; **Host E2E** (`notion` lane: catalog install, connect, 3 rows, column datatypes, formatted-text warning, the #89 states against the fixture's scenarios). No live run | [#97](https://github.com/ontola/atomic-plugins/issues/97) local edits, [#8](https://github.com/ontola/atomic-plugins/issues/8) write | -| Notion, two-way pilot (no card; shares `notion`'s version) | Sandbox `notion/plugin.js` | None. `ConnectNotion` was removed in `4bab16ee6`. The `notion` catalog card now describes the drive app | Two-way on one data source: plain fields, property names, table/board view subset (`package.json` capabilities) | Unit; `certify.mjs --layer js`; `live` tier runs the installer against the pinned server with Notion stubbed. Historical: live UI import and title edits via `ConnectNotion` | Retire once a drive-app write bridge has live evidence ([#8](https://github.com/ontola/atomic-plugins/issues/8)) | -| Clockify (`timesheets`) | Drive app `timesheets/app/`: iframe, own Clockify client over `store.proxy.request`. The #89 UI (week grid, entries, projects, read-only drawer, settings) over the #123 M1 observation log and M2 timeline | Published (`timesheets` 0.1.0 on GitHub Pages) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | Read-only. The user's own entries in one workspace, rolling 7- or 30-day look-back; completed entries as rows. Conflicts and not-loaded time shown read-only. No writes to Clockify yet | Unit (fake store; #123 M1 scenarios and fold property tests, M2 timeline incl. DST days); **Host E2E** (`timesheets` lane: catalog install, connect, setup, import, reload, changed entry, 7 → 30 days, 503 recovery, an M2 conflict and unknown time). The mock's Clockify endpoints follow API behaviour checked against a live account on 2026-09-24 (#123); the app itself has no live run | [#123](https://github.com/ontola/atomic-plugins/issues/123) M3/M4 (writes, resolving conflicts), [#97](https://github.com/ontola/atomic-plugins/issues/97) | -| Bank statements (`money`) | Sandbox `money/plugin.js`, file handed over as `ctx.upload`, no network | Draft from a published release (Integrations → Community plugins → Create draft), then Set up and Import on the plugin page (atomic-server#1653's `accepts`/`destination`, in the pin). Publishing the bundle to a server is manual (#94) | Import only. MT940 ≤ 512 KB, camt.053 ≤ 5 MB, ≤ 500 transactions | Unit; `certify.mjs --layer js`; host E2E `money/e2e/money.spec.ts` (synthetic MT940/camt.053: import, reload, reimport, local edit, conflict, refused files). Historical: a real 272-transaction bunq MT940 export through `ImportMT940` (2026-09-11) | [#94](https://github.com/ontola/atomic-plugins/issues/94) | -| Willow drop (`willow-drop`) | Sandbox `willow-drop/plugin.js`, drop file handed over as `ctx.upload` text and turned back into bytes, no network | As for Bank statements: draft from a published release, then Set up and Import on the plugin page. Publishing is manual (#94) | Import only. Willow'25 drops up to 5,000,000 bytes and 1,000 entries (declared); no delegated capabilities, no partial payloads | Unit (fixtures written by willow25 0.7.9); host E2E `willow-drop/e2e/willow-drop.spec.ts` (raw and base64 upload, reimport, refused drops) | [#139](https://github.com/ontola/atomic-plugins/issues/139) follow-ups: delegations, partial payloads | -| Google Calendar (`calendar`) | Drive app `calendar/app/`: iframe, `calendar/adapter.ts` through `app/relay.ts` over `store.proxy`. The #89 UI (agenda, week, drawer, review sheet; Month hands off to the table's Calendar view, which spans all-day ranges because rows use the host's `atomic-calendar-*` field names) | Published (`calendar` 0.1.1 on GitHub Pages; 0.1.0 wrote `day`/`all-day` and no end day) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | One calendar's single non-recurring events in (≤ 25,000 per scan); reviewed edits of five fields out with If-Match and `sendUpdates=none`; no creates or deletes in Google | Unit; **Host E2E** (`calendar` lane: catalog install, connect, import, refresh after a Google-side edit, review and send, 412 conflict, lost response, links/Month/Disconnect through the host, the host Calendar view spanning a three-day all-day event and placing a timed one, responsive and theme). Historical: live import (2026-09-09, proxy v39) through the retired LocalThought snapshot importer. No live run of the drive app | [#101](https://github.com/ontola/atomic-plugins/issues/101) live verification | -| Todoist (`devonian-todoist`) | Library only: `issue-tracker/todoist.ts` projection | None. Its host hook was removed in `f3efedf65` | Declared: read-only, active tasks and projects | Unit. Recorded-fixture tests skip until a recording exists | [#99](https://github.com/ontola/atomic-plugins/issues/99), [#46](https://github.com/ontola/atomic-plugins/issues/46) | -| GitHub issues (`issue-tracker`) | Drive app `issue-tracker/app/`: iframe, the Devonian bridge from `issue-tracker/devonian/github-issues/` (npm `devonian` 0.8.0) over `store.proxy`. The #89 board/list UI. The lens's sandbox `plugin.ts` has no host | Published (`issue-tracker` 0.1.1 on GitHub Pages; #206) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | Two-way for one repository: title, body, Todo/Doing/Done status, comments. Every GitHub write is held for review before send. An issue gone from GitHub: "Keep here only" or "Remove from board". An uncertain create has no in-app way out yet | Unit (incl. state 13); **Host E2E** (`issue-tracker` lane: catalog install, connect, repository picker, import, reload, reviewed status update, conflict review, keyboard move, comment). Opt-in lens `*.live.test.ts` (need `GITHUB_TOKEN`; not run in CI). Historical: live GitHub read (2026-09-09, proxy v38) via the retired server flow. No live run of the drive app | [#156](https://github.com/ontola/atomic-plugins/issues/156) "It landed", [#100](https://github.com/ontola/atomic-plugins/issues/100) | -| Moneybird (`moneybird`) | None: catalog entry and `overlays/moneybird.com/` only | None | Declared: read-only bookkeeping collections | None | [#102](https://github.com/ontola/atomic-plugins/issues/102) | +| Plugin (catalog id) | Runtime of the current code | Install entry point at the pin | Import / write scope (declared) | Evidence | Open blockers | +| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Pets, drive app (`pets`) | Drive app `pets/app/`: iframe, `syncables/browser` over `store.proxy` | Integrations → Show experimental plugins → Drive apps → Install (`pets` 0.1.1, from GitHub Pages, integrity-checked). The host E2E installs this way, then updates from an older recorded version | Read-only. Pets from the mock `pets` platform into the app's own table | Unit; **Host E2E** (`pets` lane: catalog install and update, connect, 5 rows, datatypes) | None filed | +| Pets, static demo (`pets`) | Sandbox `pets/plugin.js`, no network | None. Its setup dialog was removed in `4bab16ee6` | Five static pets into a Pets table | Unit; `certify.mjs --layer js`. Historical: Rust sandbox test (removed from atomic-server in `4bab16ee6`) | None filed; the catalog card still describes this demo, not the drive app | +| Notion, drive app (`notion`) | Drive app `notion/app/`: iframe, `syncables/browser` + Devonian `AtomicLens` over `store.proxy`; the #89 UI (table, board and list views, side peek, sync details, Disconnect) | Published (`notion` 0.1.0 on GitHub Pages) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | Read-only. Every shared data source into one table; plain fields and select/status/multi-select options only | Unit; **Host E2E** (`notion` lane: catalog install, connect, 3 rows, column datatypes, formatted-text warning, the #89 states against the fixture's scenarios). No live run | [#97](https://github.com/ontola/atomic-plugins/issues/97) local edits, [#8](https://github.com/ontola/atomic-plugins/issues/8) write | +| Notion, two-way pilot (no card; shares `notion`'s version) | Sandbox `notion/plugin.js` | None. `ConnectNotion` was removed in `4bab16ee6`. The `notion` catalog card now describes the drive app | Two-way on one data source: plain fields, property names, table/board view subset (`package.json` capabilities) | Unit; `certify.mjs --layer js`; `live` tier runs the installer against the pinned server with Notion stubbed. Historical: live UI import and title edits via `ConnectNotion` | Retire once a drive-app write bridge has live evidence ([#8](https://github.com/ontola/atomic-plugins/issues/8)) | +| Clockify (`timesheets`) | Drive app `timesheets/app/`: iframe, own Clockify client over `store.proxy.request`. The #89 UI (week grid, entries, projects, read-only drawer, settings) over the #123 M1 observation log and M2 timeline | Published (`timesheets` 0.1.0 on GitHub Pages) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | Read-only. The user's own entries in one workspace, rolling 7- or 30-day look-back; completed entries as rows. Conflicts and not-loaded time shown read-only. No writes to Clockify yet | Unit (fake store; #123 M1 scenarios and fold property tests, M2 timeline incl. DST days); **Host E2E** (`timesheets` lane: catalog install, connect, setup, import, reload, changed entry, 7 → 30 days, 503 recovery, an M2 conflict and unknown time). The mock's Clockify endpoints follow API behaviour checked against a live account on 2026-09-24 (#123); the app itself has no live run | [#123](https://github.com/ontola/atomic-plugins/issues/123) M3/M4 (writes, resolving conflicts), [#97](https://github.com/ontola/atomic-plugins/issues/97) | +| Bank statements, importer (`money`) | Sandbox `money/plugin.js` (0.3.0), file handed over as `ctx.upload`, no network | Draft from a published release (Integrations → Community plugins → Create draft), then Set up and Import on the plugin page (atomic-server#1653's `accepts`/`destination`, in the pin). Publishing the bundle to a server is manual (#94). An importer set up before 0.3.0's `tables` pauses until Set up runs again | Import only. MT940 ≤ 512 KB, camt.053 ≤ 5 MB, ≤ 500 transactions per file, into Bank transactions plus one Imported statements row per statement (`destination.tables`, atomic-server#1768) | Unit; `certify.mjs --layer js`; host E2E `money/e2e/money.spec.ts` (synthetic MT940/camt.053: import with its statement row, reload, reimport, local edit, conflict, refused files). Historical: a real 272-transaction bunq MT940 export through `ImportMT940` (2026-09-11) | [#94](https://github.com/ontola/atomic-plugins/issues/94) | +| Money, drive app (`money`) | Drive app `money/app/`: iframe, a view of the importer's table (`store.getData()`), no `store.proxy`; imports through the importer (`store.importer.run`, atomic-server#1774) | Published (`money` 0.3.0 on GitHub Pages) but `enabled: false`. A catalog Install would not give a working app yet: it gets its own empty table with no importer, and the importer's table offers under Add view only apps rendering its class. The host E2E installs test-side and adds the Bank transaction class to the app's `renders` | Reads the importer's Bank transactions and Imported statements tables. Writes only `money-category` and `money-note` on a row, after the person allows row editing (atomic-server#1788) | Unit (fake store modelling a current and an older host); axe and screenshots (`app/harness/`); **Host E2E** (`money` lane, second test: Add view, import through the host's review, closing balance, category after Allow editing, in-app check). At pin `2567fc30b` the second test could fail on atomic-server#1846 ('New app' missing); fixed at pin `1432e244a`, where both tests passed once on 2026-09-29 | Install path above; [#179](https://github.com/ontola/atomic-plugins/pull/179) pin | +| Willow drop (`willow-drop`) | Sandbox `willow-drop/plugin.js`, drop file handed over as `ctx.upload` text and turned back into bytes, no network | As for Bank statements: draft from a published release, then Set up and Import on the plugin page. Publishing is manual (#94) | Import only. Willow'25 drops up to 5,000,000 bytes and 1,000 entries (declared); no delegated capabilities, no partial payloads | Unit (fixtures written by willow25 0.7.9); host E2E `willow-drop/e2e/willow-drop.spec.ts` (raw and base64 upload, reimport, refused drops) | [#139](https://github.com/ontola/atomic-plugins/issues/139) follow-ups: delegations, partial payloads | +| Google Calendar (`calendar`) | Drive app `calendar/app/`: iframe, `calendar/adapter.ts` through `app/relay.ts` over `store.proxy`. The #89 UI (agenda, week, drawer, review sheet; Month hands off to the table's Calendar view, which spans all-day ranges because rows use the host's `atomic-calendar-*` field names) | Published (`calendar` 0.1.1 on GitHub Pages; 0.1.0 wrote `day`/`all-day` and no end day) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | One calendar's single non-recurring events in (≤ 25,000 per scan); reviewed edits of five fields out with If-Match and `sendUpdates=none`; no creates or deletes in Google | Unit; **Host E2E** (`calendar` lane: catalog install, connect, import, refresh after a Google-side edit, review and send, 412 conflict, lost response, links/Month/Disconnect through the host, the host Calendar view spanning a three-day all-day event and placing a timed one, responsive and theme). Historical: live import (2026-09-09, proxy v39) through the retired LocalThought snapshot importer. No live run of the drive app | [#101](https://github.com/ontola/atomic-plugins/issues/101) live verification | +| Todoist (`devonian-todoist`) | Library only: `issue-tracker/todoist.ts` projection | None. Its host hook was removed in `f3efedf65` | Declared: read-only, active tasks and projects | Unit. Recorded-fixture tests skip until a recording exists | [#99](https://github.com/ontola/atomic-plugins/issues/99), [#46](https://github.com/ontola/atomic-plugins/issues/46) | +| GitHub issues (`issue-tracker`) | Drive app `issue-tracker/app/`: iframe, the Devonian bridge from `issue-tracker/devonian/github-issues/` (npm `devonian` 0.8.0) over `store.proxy`. The #89 board/list UI. The lens's sandbox `plugin.ts` has no host | Published (`issue-tracker` 0.1.1 on GitHub Pages; #206) but `enabled: false` pending launch, so Drive apps does not offer it. The host E2E installs it through Drive apps, with the lanes' dev-server serving the entry enabled | Two-way for one repository: title, body, Todo/Doing/Done status, comments. Every GitHub write is held for review before send. An issue gone from GitHub: "Keep here only" or "Remove from board". An uncertain create has no in-app way out yet | Unit (incl. state 13); **Host E2E** (`issue-tracker` lane: catalog install, connect, repository picker, import, reload, reviewed status update, conflict review, keyboard move, comment). Opt-in lens `*.live.test.ts` (need `GITHUB_TOKEN`; not run in CI). Historical: live GitHub read (2026-09-09, proxy v38) via the retired server flow. No live run of the drive app | [#156](https://github.com/ontola/atomic-plugins/issues/156) "It landed", [#100](https://github.com/ontola/atomic-plugins/issues/100) | +| Moneybird (`moneybird`) | None: catalog entry and `overlays/moneybird.com/` only | None | Declared: read-only bookkeeping collections | None | [#102](https://github.com/ontola/atomic-plugins/issues/102) | `integrations/localthought/` is shared tooling, not a user-facing plugin: the shared mock proxy every E2E lane uses (`mock-proxy.mjs`, which speaks diff --git a/integrations/catalog.json b/integrations/catalog.json index 62046fb5c..c4b3e31fe 100644 --- a/integrations/catalog.json +++ b/integrations/catalog.json @@ -201,12 +201,16 @@ "https://atomicdata.dev/integrations/properties/enabled": false, "https://atomicdata.dev/properties/name": "Bank statements", "https://atomicdata.dev/properties/emoji": "🏦", - "https://atomicdata.dev/properties/description": "Import bank transactions from MT940 and camt.053 statement exports.", - "https://atomicdata.dev/integrations/properties/capabilities": "Preview exact amounts, dates, account references and original descriptions in a Bank transactions table.", - "https://atomicdata.dev/integrations/properties/events": "Upload an MT940 or camt.053 statement when you need it. No bank token required.", - "https://atomicdata.dev/integrations/properties/limitation": "MT940 (up to 512 KB) and camt.053 XML (up to 5 MB) files only, up to 500 transactions. No payment initiation or live bank sync. Bank-specific formats may need additional support.", + "https://atomicdata.dev/properties/description": "Import bank transactions from MT940 and camt.053 statement exports, and read them as a ledger in the Money drive app.", + "https://atomicdata.dev/integrations/properties/capabilities": "The importer checks that each statement's opening balance, transactions and closing balance add up, previews which transactions are new or already imported with exact amounts, dates, references and the bank's own descriptions, and writes nothing until you apply the host's review. It writes a Bank transactions table and an Imported statements table (one row per statement, with its opening and closing balance). The Money app shows the Bank transactions table as a ledger per account and currency, with the latest closing balance from a stored statement, search, period and direction filters, your own category and note per transaction, and an import from inside the app through the same review.", + "https://atomicdata.dev/integrations/properties/events": "Upload an MT940 or camt.053 statement when you need it, on the importer's Import tab or from the Money app. No bank token and no live bank connection; nothing runs in the background.", + "https://atomicdata.dev/integrations/properties/limitation": "MT940 (up to 512 KB) and camt.053 XML (up to 5 MB) files only, up to 500 transactions per file. No CSV or PDF, no payment initiation or live bank sync; bank-specific formats may need additional support. Saving a category or note needs you to allow the app to edit the table. The Money app works only as a view of the importer's Bank transactions table: installed from Drive apps it gets an empty table of its own with no importer, and the importer's table does not offer it under Add view, so installing it from here does not yet give a working Money app. Declared, and tested with synthetic statement files only at this version.", "https://atomicdata.dev/integrations/properties/keywords": "bank bunq banking finance accounting statement mt940 camt camt.053 iso20022 xml sepa import swift", - "https://atomicdata.dev/integrations/properties/version": "0.2.0" + "https://atomicdata.dev/integrations/properties/version": "0.3.0", + "https://atomicdata.dev/integrations/properties/app-row-name": "Bank transaction", + "https://atomicdata.dev/integrations/properties/app-row-name-plural": "Bank transactions", + "https://atomicdata.dev/integrations/properties/app-module": "https://ontola.github.io/atomic-plugins/apps/money/0.3.0/ui.js", + "https://atomicdata.dev/integrations/properties/app-module-integrity": "sha384-0hyIn/cvSZBd4KDoIKEoNSR8gcaMayybwO8p5tn6e1tHwI5c7EVVf74tTgipigvv" }, { "https://atomicdata.dev/properties/localId": "moneybird", diff --git a/integrations/lanes.json b/integrations/lanes.json index 9793f8f50..61b461663 100644 --- a/integrations/lanes.json +++ b/integrations/lanes.json @@ -67,7 +67,7 @@ "index": 3, "platforms": ["moneybird"], "tiers": ["e2e"], - "note": "e2e drives the Bank statements importer through the host's generic file entry point (atomic-server#1653: manifest accepts/destination, PluginPage Import tab): publish, discover, set up, MT940 and camt.053 import, reload, reimport, local edit, conflict and refused files. The pin includes that change (atomic-server#1691); against an older host, publishing the bundle fails on the unknown manifest field. No typecheck/unit tier: money has an atomicCertification block, so the unsharded certification step in shared-checks already runs exactly its typecheck (tsconfig.json) and unit (vitest.config.ts) on every integrations/** change, plus bundle reproducibility. moneybird is listed for a future Moneybird fixture in integrations/money/fixtures/moneybird/ (plugin-specific files stay in the plugin folder); integrations/money/ has no Moneybird runtime code.", + "note": "e2e drives the Bank statements importer through the host's generic file entry point (atomic-server#1653: manifest accepts/destination, PluginPage Import tab): publish, discover, set up, MT940 and camt.053 import, reload, reimport, local edit, conflict and refused files. A second test installs the Money drive app (integrations/money/app/) test-side as an app rendering the Bank transaction class, adds it through the table's Add view as a read-only view, imports an MT940 from inside the app through the host's review (store.importer.run, atomic-server#1774), and saves a category after the host's Allow editing (atomic-server#1788). The pin includes that change (atomic-server#1691); against an older host, publishing the bundle fails on the unknown manifest field. Host bug atomic-server#1846, fixed at pin 1432e244a (atomic-server#1847, atomic-plugins #179): at pin 2567fc30b Add view read the drive's apps once on mount, so when the app's save synced in after navigating, 'New app' never appeared and the second test failed. No typecheck/unit tier: money has an atomicCertification block, so the unsharded certification step in shared-checks already runs exactly its typecheck (tsconfig.json) and unit (vitest.config.ts) on every integrations/** change, plus bundle reproducibility. moneybird is listed for a future Moneybird fixture in integrations/money/fixtures/moneybird/ (plugin-specific files stay in the plugin folder); integrations/money/ has no Moneybird runtime code.", "e2e": ["integrations/money/e2e/money.spec.ts"] }, { diff --git a/integrations/money/README.md b/integrations/money/README.md index 17a8a5112..df04e4271 100644 --- a/integrations/money/README.md +++ b/integrations/money/README.md @@ -184,7 +184,19 @@ read-only view through Add view, imports the synthetic MT940 from inside the app through the host's review, checks the strip's closing balance and the Imports tab, saves a category after clicking the host's "Allow editing", and checks the in-app check (nothing new; a changed transaction -blocks). Not yet: installing from the catalog (no catalog entry). +blocks). + +Catalog: the `money` entry in `integrations/catalog.json` carries the app +(`app-module` `apps/money//ui.js`, the same version as this +package; see [Publishing a drive app](../README.md#publishing-a-drive-app)) +with `enabled: false`, so the Integrations page does not offer it. Not yet +a working install path, and not tested: at pin `2567fc30b` a catalog +Install creates the app with a row class and table of its own +(`createApp`), the importer's table offers under Add view only apps whose +`renders` lists its row class (`useDriveApps.ts` `appsForClass`), and +`store.importer.run` refuses an app that is not a view of an importer's +table (`hostStore.ts`). The E2E adds the Bank transaction class to the +app's `renders` test-side instead. Build: `node integrations/money/app/build.mjs` (writes `app/dist/ui.js`, minified, one module). Screenshots, axe and the render budget: @@ -198,7 +210,13 @@ minified, one module). Screenshots, axe and the render budget: the change for atomic-server#1653), with this package at version 0.2.0 (`plugin.js` sha256 `a8f84cd07899984529b505d2719e83b1ec4bed805c9e2459e895c0956f784efe`, the bundle with the annotations, structured errors and the statements -table). The +table). Version 0.3.0 is that bundle with only the manifest's `version` +changed (#148 changed the importer's behaviour at 0.2.0: the statements +table and `tables` in `config.required`). At 0.3.0 (`plugin.js` sha256 +`5d5ab941d41734d088e7be6da528b3decbfbf3db81e56cfae59e69558054733b`) both +E2E tests passed once on 2026-09-29 against pin `2567fc30b` and once +against pin `1432e244a`, which fixes atomic-server#1846 (both the published +e2e image). The spec picks the release it just published by its id, so it also passes on a lane store kept from earlier runs (checked twice in a row). It covers these steps, all with the synthetic files in `fixtures/` and generated variants: diff --git a/integrations/money/package.json b/integrations/money/package.json index 83b7f6d47..b6b3cd449 100644 --- a/integrations/money/package.json +++ b/integrations/money/package.json @@ -1,7 +1,7 @@ { "name": "@atomic-integrations/money", "private": true, - "version": "0.2.0", + "version": "0.3.0", "type": "module", "atomicCertification": { "owner": "Ontola", diff --git a/integrations/money/plugin.js b/integrations/money/plugin.js index 07a039e85..d4025ea3f 100644 --- a/integrations/money/plugin.js +++ b/integrations/money/plugin.js @@ -975,7 +975,7 @@ var manifest = { schemaVersion: 2, name: "bank-statements", namespace: "atomic-plugins", - version: "0.2.0", + version: "0.3.0", description: "Import bank transactions from MT940 and camt.053 statement exports.", operations: [], secrets: [], diff --git a/integrations/money/plugin.ts b/integrations/money/plugin.ts index 53df1d896..af7b5e87c 100644 --- a/integrations/money/plugin.ts +++ b/integrations/money/plugin.ts @@ -13,7 +13,7 @@ export const manifest = { schemaVersion: 2, name: 'bank-statements', namespace: 'atomic-plugins', - version: '0.2.0', + version: '0.3.0', description: 'Import bank transactions from MT940 and camt.053 statement exports.', operations: [],