ownledger 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/AGENTS.md +24 -8
  2. package/CHANGELOG.md +33 -0
  3. package/README.md +5 -2
  4. package/assets/index.html +10 -10
  5. package/assets/static/{Account-sw3qGLbB.js → Account-CYrXDU9Z.js} +1 -1
  6. package/assets/static/{Accounts-DWyzX3qB.js → Accounts-BXleOwUO.js} +1 -1
  7. package/assets/static/{Attention-DxV-4qdY.js → Attention-Ci3luOdE.js} +1 -1
  8. package/assets/static/{ByCategory-B4P3ikmE.js → ByCategory-cLVOyjwd.js} +1 -1
  9. package/assets/static/{CardDetail-CayBXBm-.js → CardDetail-BxXfAcMp.js} +1 -1
  10. package/assets/static/{Cards-CVuOP8Bt.js → Cards-DNtITMnA.js} +1 -1
  11. package/assets/static/{Cards-XUBdWxyo.js → Cards-DnIsAWPD.js} +1 -1
  12. package/assets/static/{CardsValue-EoW2jG_0.js → CardsValue-V1-fYMLf.js} +1 -1
  13. package/assets/static/{Cashback-BibVYHf_.js → Cashback-B8lqwRnb.js} +1 -1
  14. package/assets/static/{CategoryIcon-HfjYhH1l.js → CategoryIcon-D4Cdb_ZP.js} +1 -1
  15. package/assets/static/{CategoryPicker-BkmvzX2I.js → CategoryPicker-54vkuxVh.js} +1 -1
  16. package/assets/static/{ChartWidget-u09-whUU.js → ChartWidget-S5F4Ze91.js} +1 -1
  17. package/assets/static/{Combobox-xXeyjGgK.js → Combobox-BvX68J3o.js} +1 -1
  18. package/assets/static/{Deposits-CLAda4dj.js → Deposits-Ct5HhCEc.js} +1 -1
  19. package/assets/static/{DrillLink-Bvfam9FA.js → DrillLink-CZyI-y0-.js} +1 -1
  20. package/assets/static/{Field-tKFmKDEF.js → Field-DYmqEAlI.js} +1 -1
  21. package/assets/static/{HomeEditor-4vxj5LMD.js → HomeEditor-Dv-h_ql-.js} +1 -1
  22. package/assets/static/{Import-DwaaFpRJ.js → Import-B2uhVnEm.js} +1 -1
  23. package/assets/static/{IncomeSpending-RVDSxAK4.js → IncomeSpending-DNT2CWH9.js} +1 -1
  24. package/assets/static/{KV-DMA1AlP-.js → KV-CKWaJkRK.js} +1 -1
  25. package/assets/static/{Left-C_4gTGSX.js → Left-BefXZztB.js} +1 -1
  26. package/assets/static/{Money-PfFNNDOw.js → Money-BwLucm7P.js} +1 -1
  27. package/assets/static/{NetWorth-BSoseczC.js → NetWorth-DeLSapZ2.js} +1 -1
  28. package/assets/static/{Pace-B8p-9174.js → Pace-D6gilOBZ.js} +1 -1
  29. package/assets/static/{Panel-BnfWrw9R.js → Panel-CSe25x0N.js} +1 -1
  30. package/assets/static/{PinDialog-BqAU9Vh4.js → PinDialog-CHiLIKEs.js} +1 -1
  31. package/assets/static/{Plans-2KuQH2_I.js → Plans-D7rJ1yHU.js} +1 -1
  32. package/assets/static/{Recent-Ccmb34bq.js → Recent-Dcqb2yko.js} +1 -1
  33. package/assets/static/{Reports-Dd-dhclr.js → Reports--PDAEnQM.js} +1 -1
  34. package/assets/static/{Settings-BR8WBlen.js → Settings-Bd0oglWl.js} +1 -1
  35. package/assets/static/{Transactions-BAuQ-6Eb.js → Transactions-CQ1yQ1UU.js} +1 -1
  36. package/assets/static/{TxRow-EKIIMQKa.js → TxRow-BGfpKo2m.js} +1 -1
  37. package/assets/static/{Unusual-CwFp8aA5.js → Unusual-DGB4ZOA2.js} +1 -1
  38. package/assets/static/{Upcoming-B28roT9r.js → Upcoming-B0HwBqmG.js} +1 -1
  39. package/assets/static/{WhichCard-B3kLc842.js → WhichCard-BefFKS2q.js} +1 -1
  40. package/assets/static/{arrow-up-D3gxUKLo.js → arrow-up-CRgLRKET.js} +1 -1
  41. package/assets/static/{bits-Dr2E0ObC.js → bits-D34d9IBm.js} +1 -1
  42. package/assets/static/{button-rfwMVz0i.js → button-BKhMn8jX.js} +1 -1
  43. package/assets/static/{cards-Bb5zjzRG.js → cards-Ct0jh73r.js} +1 -1
  44. package/assets/static/{charts-BqP7HKwP.js → charts-D-1glV8L.js} +1 -1
  45. package/assets/static/chevron-down-BWoQwA6m.js +1 -0
  46. package/assets/static/chevron-right-D7Sgw1v1.js +1 -0
  47. package/assets/static/{createLucideIcon-flJrJK2p.js → createLucideIcon-XZ28znwT.js} +1 -1
  48. package/assets/static/{dialog-BuRqO4sc.js → dialog-Bx-cd-2e.js} +1 -1
  49. package/assets/static/{dist-B4_eGtNj.js → dist--HKr0kfV.js} +1 -1
  50. package/assets/static/{dist-B7PR2b0C.js → dist-BFPyD74_.js} +1 -1
  51. package/assets/static/{dist-BDn7ydjn.js → dist-CmbuesVk.js} +1 -1
  52. package/assets/static/{dist-Dl-m8cc2.js → dist-vgyaCpaL.js} +1 -1
  53. package/assets/static/{es2015-DJh4h8NX.js → es2015-DqY4UvQc.js} +1 -1
  54. package/assets/static/{index-eR1GkdC_.js → index-DBHFdsYB.js} +4 -4
  55. package/assets/static/{queries-DZIMMe4i.js → queries-BcMmmb36.js} +1 -1
  56. package/assets/static/{react-dom-wK_7mEjs.js → react-dom-5dgiSOdd.js} +1 -1
  57. package/assets/static/{select-eaSi9K-d.js → select-B5P2TaPX.js} +1 -1
  58. package/assets/static/{shared-Box7on3B.js → shared-BgU6fc7z.js} +1 -1
  59. package/assets/static/{triangle-exclamation-point-CuL0XSJl.js → triangle-exclamation-point-CMy18kC0.js} +1 -1
  60. package/assets/static/{useMutation-_Lw8xXWa.js → useMutation-aC3Z1p9y.js} +1 -1
  61. package/dist/cli/statements.js +153 -5
  62. package/dist/engine/actions.d.ts +28 -0
  63. package/dist/engine/actions.js +109 -3
  64. package/dist/modules/cards/files.d.ts +1 -1
  65. package/dist/modules/cards/files.js +1 -1
  66. package/dist/modules/cards/terms.d.ts +2 -0
  67. package/dist/modules/cards/terms.js +7 -0
  68. package/dist/node/reconcile.d.ts +100 -0
  69. package/dist/node/reconcile.js +176 -0
  70. package/dist/node/statement-rows.d.ts +77 -0
  71. package/dist/node/statement-rows.js +245 -0
  72. package/dist/node/statements.d.ts +2 -1
  73. package/dist/worker/api.js +32 -5
  74. package/dist/worker/github.d.ts +18 -1
  75. package/dist/worker/github.js +53 -6
  76. package/dist/worker/mcp.js +32 -7
  77. package/dist/worker/store.js +1 -1
  78. package/dist/worker/version.d.ts +1 -1
  79. package/dist/worker/version.js +1 -1
  80. package/package.json +1 -1
  81. package/assets/static/chevron-down-Co1w7ApZ.js +0 -1
  82. package/assets/static/chevron-right-Dqh3vs9Y.js +0 -1
  83. package/dist/worker/tar.d.ts +0 -3
  84. package/dist/worker/tar.js +0 -65
@@ -1 +1 @@
1
- import{I as e,R as t}from"./queries-DZIMMe4i.js";var n=t((t=>{var n=e();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,t.browser=function(e){return{$$typeof:s,_reason:e}},t.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return l(e,t,null,n)},t.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},t.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},t.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},t.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},t.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},t.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},t.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},t.requestFormReset=function(e){a.d.r(e)},t.unstable_batchedUpdates=function(e,t){return e(t)},t.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},t.useFormStatus=function(){return u.H.useHostTransitionStatus()},t.version=`19.3.1`})),r=t(((e,t)=>{function r(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}r(),t.exports=n()}));export{r as t};
1
+ import{I as e,R as t}from"./queries-BcMmmb36.js";var n=t((t=>{var n=e();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,t.browser=function(e){return{$$typeof:s,_reason:e}},t.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return l(e,t,null,n)},t.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},t.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},t.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},t.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},t.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},t.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},t.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},t.requestFormReset=function(e){a.d.r(e)},t.unstable_batchedUpdates=function(e,t){return e(t)},t.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},t.useFormStatus=function(){return u.H.useHostTransitionStatus()},t.version=`19.3.1`})),r=t(((e,t)=>{function r(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}r(),t.exports=n()}));export{r as t};
@@ -1 +1 @@
1
- import{B as e,I as t,L as n,T as r}from"./queries-DZIMMe4i.js";import{t as i}from"./react-dom-wK_7mEjs.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-BDn7ydjn.js";import{n as f,t as p}from"./dist-Dl-m8cc2.js";import{i as m,s as h}from"./button-rfwMVz0i.js";import{a as g,i as _,l as v,n as y,r as b,t as x}from"./es2015-DJh4h8NX.js";import{_t as S,at as C,ct as w,ot as T,st as E,tt as D}from"./index-eR1GkdC_.js";import{t as O}from"./dist-B7PR2b0C.js";import{t as k}from"./chevron-down-Co1w7ApZ.js";import{t as A}from"./createLucideIcon-flJrJK2p.js";var j=e(t(),1),M=e(i(),1),N=Object.defineProperty,P=(e,t)=>N(e,`name`,{value:t,configurable:!0});function F(e,[t,n]){return Math.min(n,Math.max(t,e))}P(F,`clamp`);var I=n(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),ee={ItemAligned:`item-aligned`,Popper:`popper`},z={LTR:`ltr`,RTL:`rtl`},te=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=f(V),[G,K]=c(V,[W,w]),q=w(),[ne,J]=G(V),[re,Y]=G(V);function ie(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:d,name:f,autoComplete:m,disabled:h,required:g,form:_,internal_do_not_use_render:v}=e,y=q(t),[b,x]=j.useState(null),[S,w]=j.useState(null),[T,E]=j.useState(!1),D=p(d),[O,k]=l({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,M]=l({prop:o,defaultProp:c,onChange:u,caller:V}),N=j.useRef(null),P=j.useRef(!1),[F,L]=j.useState(null),ee=R(e=>{L({value:e,hasConsumerStoppedPropagation:P.current}),M(e)},`handleUserSelect`),z=j.useRef(A);j.useEffect(()=>{let e=_?b?.ownerDocument.getElementById(_):b?.form;if(e instanceof HTMLFormElement){let t=R(()=>M(z.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[_,b,M]);let te=!b||!!_||!!b.closest(`form`),[B,U]=j.useState(new Set),W=s(),G=Array.from(B).map(e=>e.props.value).join(`;`),K=j.useCallback(e=>{U(t=>new Set(t).add(e))},[]),J=j.useCallback(e=>{U(t=>{let n=new Set(t);return n.delete(e),n})},[]),Y={required:g,trigger:b,onTriggerChange:x,valueNode:S,onValueNodeChange:w,valueNodeHasChildren:T,onValueNodeHasChildrenChange:E,contentId:W,value:A,onValueChange:M,hasConsumerStoppedPropagationRef:P,userSelection:F,onUserSelect:ee,open:O,onOpenChange:k,dir:D,triggerPointerDownPosRef:N,disabled:h,name:f,autoComplete:m,form:_,nativeOptions:B,nativeSelectKey:G,isFormControl:te};return(0,I.jsx)(C,{...y,children:(0,I.jsx)(ne,{scope:t,...Y,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:K,onNativeOptionRemove:J,children:He(v)?v(Y):n})})})})}R(ie,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(ie,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Ve,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=j.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=q(n),s=J(oe,n),c=s.disabled||r,l=h(t,s.onTriggerChange),d=U(n),f=j.useRef(`touch`),[p,m,g]=Ue(e=>{let t=d().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onUserSelect(n.value)}),_=R(e=>{c||(s.onOpenChange(!0),g()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(T,{asChild:!0,...a,children:(0,I.jsx)(u.button,{type:`button`,role:`combobox`,"aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":$(s.value)?``:void 0,...i,ref:l,onClick:o(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&_(e)}),onPointerDown:o(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:o(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),m(e.key)),t&&e.key===` `||te.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:o,placeholder:s=``,...c}=e,l=J(ce,n),{onValueNodeHasChildrenChange:d}=l,f=o!==void 0,p=h(t,l.onValueNodeChange);a(()=>{d(f)},[d,f]);let m=$(l.value);return(0,I.jsx)(u.span,{...c,asChild:!m&&c.asChild,ref:p,style:{pointerEvents:`none`},children:(0,I.jsx)(j.Fragment,{children:m?s:o},m?`placeholder`:`value`)})},`SelectValue`)),ue=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(u.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(_,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,me=j.forwardRef(R(function(e,t){let n=fe(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,o=J(X,e.__scopeSelect),[s,c]=j.useState();return a(()=>{c(new DocumentFragment)},[]),(0,I.jsx)(O,{present:r||o.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:s})})},`SelectContent`)),he=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[ge,Q]=G(X),_e=m(`SelectContent.RemoveScroll`),ve=j.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=ee.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=J(X,n),[E,D]=j.useState(null),[O,k]=j.useState(null),A=h(t,D),[M,N]=j.useState(null),[P,F]=j.useState(null),L=U(n),[z,te]=j.useState(!1),B=j.useRef(!1),V=j.useRef(!1),H=j.useRef(!1);j.useEffect(()=>{if(E)return x(E)},[E]),b();let W=j.useCallback(e=>{let[t,...n]=L().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[L,O]),G=j.useCallback(()=>W([M,E]),[W,M,E]);j.useEffect(()=>{z&&G()},[z,G]);let{onOpenChange:K,triggerPointerDownPosRef:q}=T;j.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(q.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||K(!1),document.removeEventListener(`pointermove`,t),q.current=null},`handlePointerUp`);return q.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,K,q]),j.useEffect(()=>{let e=R(()=>K(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[K]);let[ne,re]=Ue(e=>{let t=L().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),Y=j.useCallback((e,t,n)=>{let r=!V.current;r&&(V.current=!0);let i=!B.current&&!n;T.value!==void 0&&T.value===t||i?(N(e),i&&(B.current=!0)):r&&N(e)},[T.value]),ie=j.useCallback(()=>E?.focus(),[E]),ae=j.useCallback((e,t,n)=>{if(!e)return;let r=!H.current;r&&(H.current=!0);let i=!B.current&&!n;(T.value!==void 0&&T.value===t||i||r)&&F(e)},[T.value]),oe=r===ee.Popper?be:ye,se=oe===be?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:Y,selectedItem:M,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:G,selectedItemText:P,position:r,isPositioned:z,searchRef:ne,children:(0,I.jsx)(y,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(g,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:o(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(v,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(oe,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...se,onPlaced:()=>te(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:o(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=L().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>W(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,o=J(X,n),s=Q(X,n),[c,l]=j.useState(null),[d,f]=j.useState(null),p=h(t,f),m=U(n),g=j.useRef(!1),_=j.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=s,S=j.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&d&&v&&y&&b){let e=o.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(o.dir!==z.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let a=m(),s=window.innerHeight-Z*2,l=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),h=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+l+_+h,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Z,D=s-E,O=y.offsetHeight/2,k=y.offsetTop+O,A=f+p+k,j=x-A;if(A<=E){let e=a.length>0&&y===a[a.length-1].ref.current;c.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+h);c.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+v.offsetTop+(e?w:0)+O)+j;c.style.height=t+`px`,v.scrollTop=A-E+v.offsetTop}c.style.margin=`${Z}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[m,o.trigger,o.valueNode,c,d,v,y,b,o.dir,r]);a(()=>S(),[S]);let[C,w]=j.useState();a(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let T=j.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,I.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(u.div,{...i,ref:p,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=j.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=q(n);return(0,I.jsx)(E,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(X,{}),Ce=`SelectViewport`,we=j.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(Ce,n),s=Se(Ce,n),c=h(t,a.onViewportChange),l=j.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(u.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:o(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=j.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...c}=e,l=J(De,n),f=Q(De,n),p=l.value===r,[m,g]=j.useState(a??``),[_,v]=j.useState(!1),y=d(e=>f.itemRefCallback?.(e,r,i)),b=h(t,y),x=s(),S=j.useRef(`touch`);function C(e){l.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),l.onUserSelect(r),l.onOpenChange(!1)}return R(C,`handleSelect`),(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:x,isSelected:p,onItemTextChange:j.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:m,children:(0,I.jsx)(u.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":p&&_,"data-state":p?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:b,onFocus:o(c.onFocus,()=>v(!0)),onBlur:o(c.onBlur,()=>v(!1)),onClick:o(c.onClick,e=>{i||S.current!==`mouse`&&C(e)}),onPointerUp:o(c.onPointerUp,e=>{i||S.current===`mouse`&&C(e)}),onPointerDown:o(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:o(c.onPointerMove,e=>{S.current=e.pointerType,i?f.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:o(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:o(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(f.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),je=`SelectItemText`,Me=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...o}=e,s=J(je,n),c=Q(je,n),l=ke(je,n),f=Y(je,n),[p,m]=j.useState(null),g=d(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),_=h(t,m,l.onItemTextChange,g),v=p?.textContent,y=j.useMemo(()=>(0,I.jsx)(`option`,{value:l.value,disabled:l.disabled,children:v},l.value),[l.disabled,l.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=f;return a(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u.span,{id:l.textId,...o,ref:_}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren&&!$(s.value)?M.createPortal(o.children,s.valueNode):null]})},`SelectItemText`)),Ne=`SelectItemIndicator`,Pe=j.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Ne,n).isSelected?(0,I.jsx)(u.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Fe=`SelectScrollUpButton`,Ie=j.forwardRef(R(function(e,t){let n=Q(Fe,e.__scopeSelect),r=Se(Fe,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Le=`SelectScrollDownButton`,Re=j.forwardRef(R(function(e,t){let n=Q(Le,e.__scopeSelect),r=Se(Le,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),ze=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,s=Q(`SelectScrollButton`,n),c=j.useRef(null),l=U(n),d=j.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return j.useEffect(()=>()=>d(),[d]),a(()=>{l().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[l]),(0,I.jsx)(u.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:o(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(r,50))}),onPointerMove:o(i.onPointerMove,()=>{s.onItemLeave?.(),c.current===null&&(c.current=window.setInterval(r,50))}),onPointerLeave:o(i.onPointerLeave,()=>{d()})})},`SelectScrollButtonImpl`)),Be=`SelectBubbleInput`,Ve=j.forwardRef(R(function({__scopeSelect:e,...t},n){let r=J(Be,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:d,userSelection:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,g=j.useRef(null),_=h(n,g),v=i??``,y=j.useRef(v),b=j.useRef(f),x=j.useRef(!1),C=Array.from(p).some(e=>(e.props.value??``)===``);return j.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=f!==null&&f!==b.current;b.current=f;let i=y.current!==v;y.current=v;let a=r&&i;if(r&&!i&&f.value!==v&&!f.hasConsumerStoppedPropagation&&n){x.current=!0;try{n.call(e,f.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{x.current=!1,n.call(e,v)}return}let o=a&&!f.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,v),e.dispatchEvent(t)}},[v,f]),(0,I.jsxs)(u.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:d,onChange:e=>{x.current||a(e.target.value)},...t,style:{...S,...t.style},ref:_,defaultValue:v,children:[$(i)&&!C?(0,I.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function He(e){return typeof e==`function`}R(He,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function Ue(e){let t=d(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}R(a,`updateSearch`),a(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(Ue,`useTypeaheadSearch`);function We(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ge(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(We,`findNextItem`);function Ge(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(Ge,`wrapArray`);var Ke={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};Ke.node;var qe=A(Ke);function Je({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ye({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function Xe({className:e,size:t=`default`,children:n,...i}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:r(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...i,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(k,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Ze({className:e,children:t,position:n=`item-aligned`,align:i=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:r(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:i,...a,children:[(0,I.jsx)($e,{}),(0,I.jsx)(we,{"data-position":n,className:r(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(et,{})]})})}function Qe({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:r(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(Pe,{children:(0,I.jsx)(D,{className:`pointer-events-none`})})}),(0,I.jsx)(Me,{children:t})]})}function $e({className:e,...t}){return(0,I.jsx)(Ie,{"data-slot":`select-scroll-up-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(qe,{})})}function et({className:e,...t}){return(0,I.jsx)(Re,{"data-slot":`select-scroll-down-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(k,{})})}export{Ye as a,Xe as i,Ze as n,Qe as r,Je as t};
1
+ import{B as e,I as t,L as n,T as r}from"./queries-BcMmmb36.js";import{t as i}from"./react-dom-5dgiSOdd.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist-CmbuesVk.js";import{n as f,t as p}from"./dist-vgyaCpaL.js";import{i as m,s as h}from"./button-BKhMn8jX.js";import{a as g,i as _,l as v,n as y,r as b,t as x}from"./es2015-DqY4UvQc.js";import{_t as S,at as C,ct as w,ot as T,st as E,tt as D}from"./index-DBHFdsYB.js";import{t as O}from"./dist-BFPyD74_.js";import{t as k}from"./chevron-down-BWoQwA6m.js";import{t as A}from"./createLucideIcon-XZ28znwT.js";var j=e(t(),1),M=e(i(),1),N=Object.defineProperty,P=(e,t)=>N(e,`name`,{value:t,configurable:!0});function F(e,[t,n]){return Math.min(n,Math.max(t,e))}P(F,`clamp`);var I=n(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),ee={ItemAligned:`item-aligned`,Popper:`popper`},z={LTR:`ltr`,RTL:`rtl`},te=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=f(V),[G,K]=c(V,[W,w]),q=w(),[ne,J]=G(V),[re,Y]=G(V);function ie(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:d,name:f,autoComplete:m,disabled:h,required:g,form:_,internal_do_not_use_render:v}=e,y=q(t),[b,x]=j.useState(null),[S,w]=j.useState(null),[T,E]=j.useState(!1),D=p(d),[O,k]=l({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,M]=l({prop:o,defaultProp:c,onChange:u,caller:V}),N=j.useRef(null),P=j.useRef(!1),[F,L]=j.useState(null),ee=R(e=>{L({value:e,hasConsumerStoppedPropagation:P.current}),M(e)},`handleUserSelect`),z=j.useRef(A);j.useEffect(()=>{let e=_?b?.ownerDocument.getElementById(_):b?.form;if(e instanceof HTMLFormElement){let t=R(()=>M(z.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[_,b,M]);let te=!b||!!_||!!b.closest(`form`),[B,U]=j.useState(new Set),W=s(),G=Array.from(B).map(e=>e.props.value).join(`;`),K=j.useCallback(e=>{U(t=>new Set(t).add(e))},[]),J=j.useCallback(e=>{U(t=>{let n=new Set(t);return n.delete(e),n})},[]),Y={required:g,trigger:b,onTriggerChange:x,valueNode:S,onValueNodeChange:w,valueNodeHasChildren:T,onValueNodeHasChildrenChange:E,contentId:W,value:A,onValueChange:M,hasConsumerStoppedPropagationRef:P,userSelection:F,onUserSelect:ee,open:O,onOpenChange:k,dir:D,triggerPointerDownPosRef:N,disabled:h,name:f,autoComplete:m,form:_,nativeOptions:B,nativeSelectKey:G,isFormControl:te};return(0,I.jsx)(C,{...y,children:(0,I.jsx)(ne,{scope:t,...Y,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:K,onNativeOptionRemove:J,children:He(v)?v(Y):n})})})})}R(ie,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(ie,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Ve,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=j.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=q(n),s=J(oe,n),c=s.disabled||r,l=h(t,s.onTriggerChange),d=U(n),f=j.useRef(`touch`),[p,m,g]=Ue(e=>{let t=d().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onUserSelect(n.value)}),_=R(e=>{c||(s.onOpenChange(!0),g()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(T,{asChild:!0,...a,children:(0,I.jsx)(u.button,{type:`button`,role:`combobox`,"aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":$(s.value)?``:void 0,...i,ref:l,onClick:o(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&_(e)}),onPointerDown:o(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:o(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),m(e.key)),t&&e.key===` `||te.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:o,placeholder:s=``,...c}=e,l=J(ce,n),{onValueNodeHasChildrenChange:d}=l,f=o!==void 0,p=h(t,l.onValueNodeChange);a(()=>{d(f)},[d,f]);let m=$(l.value);return(0,I.jsx)(u.span,{...c,asChild:!m&&c.asChild,ref:p,style:{pointerEvents:`none`},children:(0,I.jsx)(j.Fragment,{children:m?s:o},m?`placeholder`:`value`)})},`SelectValue`)),ue=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(u.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(_,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,me=j.forwardRef(R(function(e,t){let n=fe(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,o=J(X,e.__scopeSelect),[s,c]=j.useState();return a(()=>{c(new DocumentFragment)},[]),(0,I.jsx)(O,{present:r||o.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:s})})},`SelectContent`)),he=j.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[ge,Q]=G(X),_e=m(`SelectContent.RemoveScroll`),ve=j.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=ee.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=J(X,n),[E,D]=j.useState(null),[O,k]=j.useState(null),A=h(t,D),[M,N]=j.useState(null),[P,F]=j.useState(null),L=U(n),[z,te]=j.useState(!1),B=j.useRef(!1),V=j.useRef(!1),H=j.useRef(!1);j.useEffect(()=>{if(E)return x(E)},[E]),b();let W=j.useCallback(e=>{let[t,...n]=L().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[L,O]),G=j.useCallback(()=>W([M,E]),[W,M,E]);j.useEffect(()=>{z&&G()},[z,G]);let{onOpenChange:K,triggerPointerDownPosRef:q}=T;j.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(q.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(q.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||K(!1),document.removeEventListener(`pointermove`,t),q.current=null},`handlePointerUp`);return q.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,K,q]),j.useEffect(()=>{let e=R(()=>K(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[K]);let[ne,re]=Ue(e=>{let t=L().filter(e=>!e.disabled),n=We(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),Y=j.useCallback((e,t,n)=>{let r=!V.current;r&&(V.current=!0);let i=!B.current&&!n;T.value!==void 0&&T.value===t||i?(N(e),i&&(B.current=!0)):r&&N(e)},[T.value]),ie=j.useCallback(()=>E?.focus(),[E]),ae=j.useCallback((e,t,n)=>{if(!e)return;let r=!H.current;r&&(H.current=!0);let i=!B.current&&!n;(T.value!==void 0&&T.value===t||i||r)&&F(e)},[T.value]),oe=r===ee.Popper?be:ye,se=oe===be?{side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:S,avoidCollisions:C}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:Y,selectedItem:M,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:G,selectedItemText:P,position:r,isPositioned:z,searchRef:ne,children:(0,I.jsx)(y,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(g,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:o(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(v,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(oe,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...se,onPlaced:()=>te(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:o(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=L().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>W(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,o=J(X,n),s=Q(X,n),[c,l]=j.useState(null),[d,f]=j.useState(null),p=h(t,f),m=U(n),g=j.useRef(!1),_=j.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=s,S=j.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&d&&v&&y&&b){let e=o.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(o.dir!==z.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-Z,d=F(a,[Z,Math.max(Z,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let a=m(),s=window.innerHeight-Z*2,l=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),h=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+l+_+h,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Z,D=s-E,O=y.offsetHeight/2,k=y.offsetTop+O,A=f+p+k,j=x-A;if(A<=E){let e=a.length>0&&y===a[a.length-1].ref.current;c.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+h);c.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+v.offsetTop+(e?w:0)+O)+j;c.style.height=t+`px`,v.scrollTop=A-E+v.offsetTop}c.style.margin=`${Z}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[m,o.trigger,o.valueNode,c,d,v,y,b,o.dir,r]);a(()=>S(),[S]);let[C,w]=j.useState();a(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let T=j.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,I.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(u.div,{...i,ref:p,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=j.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=q(n);return(0,I.jsx)(E,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(X,{}),Ce=`SelectViewport`,we=j.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(Ce,n),s=Se(Ce,n),c=h(t,a.onViewportChange),l=j.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(u.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:o(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=j.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...c}=e,l=J(De,n),f=Q(De,n),p=l.value===r,[m,g]=j.useState(a??``),[_,v]=j.useState(!1),y=d(e=>f.itemRefCallback?.(e,r,i)),b=h(t,y),x=s(),S=j.useRef(`touch`);function C(e){l.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),l.onUserSelect(r),l.onOpenChange(!1)}return R(C,`handleSelect`),(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:x,isSelected:p,onItemTextChange:j.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:m,children:(0,I.jsx)(u.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":p&&_,"data-state":p?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:b,onFocus:o(c.onFocus,()=>v(!0)),onBlur:o(c.onBlur,()=>v(!1)),onClick:o(c.onClick,e=>{i||S.current!==`mouse`&&C(e)}),onPointerUp:o(c.onPointerUp,e=>{i||S.current===`mouse`&&C(e)}),onPointerDown:o(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:o(c.onPointerMove,e=>{S.current=e.pointerType,i?f.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:o(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:o(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(f.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),je=`SelectItemText`,Me=j.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...o}=e,s=J(je,n),c=Q(je,n),l=ke(je,n),f=Y(je,n),[p,m]=j.useState(null),g=d(e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),_=h(t,m,l.onItemTextChange,g),v=p?.textContent,y=j.useMemo(()=>(0,I.jsx)(`option`,{value:l.value,disabled:l.disabled,children:v},l.value),[l.disabled,l.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=f;return a(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u.span,{id:l.textId,...o,ref:_}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren&&!$(s.value)?M.createPortal(o.children,s.valueNode):null]})},`SelectItemText`)),Ne=`SelectItemIndicator`,Pe=j.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Ne,n).isSelected?(0,I.jsx)(u.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Fe=`SelectScrollUpButton`,Ie=j.forwardRef(R(function(e,t){let n=Q(Fe,e.__scopeSelect),r=Se(Fe,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Le=`SelectScrollDownButton`,Re=j.forwardRef(R(function(e,t){let n=Q(Le,e.__scopeSelect),r=Se(Le,e.__scopeSelect),[i,o]=j.useState(!1),s=h(t,r.onScrollButtonChange);return a(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(ze,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),ze=j.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,s=Q(`SelectScrollButton`,n),c=j.useRef(null),l=U(n),d=j.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return j.useEffect(()=>()=>d(),[d]),a(()=>{l().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[l]),(0,I.jsx)(u.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:o(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(r,50))}),onPointerMove:o(i.onPointerMove,()=>{s.onItemLeave?.(),c.current===null&&(c.current=window.setInterval(r,50))}),onPointerLeave:o(i.onPointerLeave,()=>{d()})})},`SelectScrollButtonImpl`)),Be=`SelectBubbleInput`,Ve=j.forwardRef(R(function({__scopeSelect:e,...t},n){let r=J(Be,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:d,userSelection:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,g=j.useRef(null),_=h(n,g),v=i??``,y=j.useRef(v),b=j.useRef(f),x=j.useRef(!1),C=Array.from(p).some(e=>(e.props.value??``)===``);return j.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=f!==null&&f!==b.current;b.current=f;let i=y.current!==v;y.current=v;let a=r&&i;if(r&&!i&&f.value!==v&&!f.hasConsumerStoppedPropagation&&n){x.current=!0;try{n.call(e,f.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{x.current=!1,n.call(e,v)}return}let o=a&&!f.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,v),e.dispatchEvent(t)}},[v,f]),(0,I.jsxs)(u.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:d,onChange:e=>{x.current||a(e.target.value)},...t,style:{...S,...t.style},ref:_,defaultValue:v,children:[$(i)&&!C?(0,I.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function He(e){return typeof e==`function`}R(He,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function Ue(e){let t=d(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}R(a,`updateSearch`),a(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(Ue,`useTypeaheadSearch`);function We(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ge(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(We,`findNextItem`);function Ge(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(Ge,`wrapArray`);var Ke={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};Ke.node;var qe=A(Ke);function Je({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ye({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function Xe({className:e,size:t=`default`,children:n,...i}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:r(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...i,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(k,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Ze({className:e,children:t,position:n=`item-aligned`,align:i=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:r(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:i,...a,children:[(0,I.jsx)($e,{}),(0,I.jsx)(we,{"data-position":n,className:r(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,I.jsx)(et,{})]})})}function Qe({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:r(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,I.jsx)(Pe,{children:(0,I.jsx)(D,{className:`pointer-events-none`})})}),(0,I.jsx)(Me,{children:t})]})}function $e({className:e,...t}){return(0,I.jsx)(Ie,{"data-slot":`select-scroll-up-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(qe,{})})}function et({className:e,...t}){return(0,I.jsx)(Re,{"data-slot":`select-scroll-down-button`,className:r(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,I.jsx)(k,{})})}export{Ye as a,Xe as i,Ze as n,Qe as r,Je as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./arrow-up-D3gxUKLo.js";import{L as n,T as r,w as i}from"./queries-DZIMMe4i.js";var a=n();function o(e,t){let{t:n}=i();return e.title?.trim()||n(t)}function s({pct:n,goodWhenDown:o=!0,className:s}){let{t:c}=i(),l=n>0,u=l!==o,d=l?t:e;return(0,a.jsxs)(`span`,{className:r(`inline-flex items-center gap-0.5 whitespace-nowrap text-sm font-medium tabular-nums`,n===0?`text-muted-foreground`:u?`text-positive`:`text-critical`,s),children:[n!==0&&(0,a.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),(0,a.jsx)(`span`,{className:`sr-only`,children:l?c(`delta.up`):n<0?c(`delta.down`):``}),Math.abs(Math.round(n)),`%`]})}export{o as n,s as t};
1
+ import{n as e,t}from"./arrow-up-CRgLRKET.js";import{L as n,T as r,w as i}from"./queries-BcMmmb36.js";var a=n();function o(e,t){let{t:n}=i();return e.title?.trim()||n(t)}function s({pct:n,goodWhenDown:o=!0,className:s}){let{t:c}=i(),l=n>0,u=l!==o,d=l?t:e;return(0,a.jsxs)(`span`,{className:r(`inline-flex items-center gap-0.5 whitespace-nowrap text-sm font-medium tabular-nums`,n===0?`text-muted-foreground`:u?`text-positive`:`text-critical`,s),children:[n!==0&&(0,a.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),(0,a.jsx)(`span`,{className:`sr-only`,children:l?c(`delta.up`):n<0?c(`delta.down`):``}),Math.abs(Math.round(n)),`%`]})}export{o as n,s as t};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-flJrJK2p.js";var t={name:`triangle-exclamation-point`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`,`triangle-alert`]};t.node;var n=e(t);export{n as t};
1
+ import{t as e}from"./createLucideIcon-XZ28znwT.js";var t={name:`triangle-exclamation-point`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`,`triangle-alert`]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{A as e,B as t,D as n,F as r,I as i,M as a,N as o,O as s,j as c,k as l}from"./queries-DZIMMe4i.js";var u=class extends o{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),c(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&l(t.mutationKey)!==l(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??n();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){s.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},d=t(i(),1);function f(t,n){let i=r(n),[o]=d.useState(()=>new u(i,t));d.useEffect(()=>{o.setOptions(t)},[o,t]);let c=d.useSyncExternalStore(d.useCallback(e=>o.subscribe(s.batchCalls(e)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),l=d.useCallback((...t)=>{o.mutate(t[0],t[1]).catch(e)},[o]);if(c.error&&a(o.options.throwOnError,[c.error]))throw c.error;return{...c,mutate:l,mutateAsync:c.mutate}}export{f as t};
1
+ import{A as e,B as t,D as n,F as r,I as i,M as a,N as o,O as s,j as c,k as l}from"./queries-BcMmmb36.js";var u=class extends o{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),c(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&l(t.mutationKey)!==l(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??n();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){s.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},d=t(i(),1);function f(t,n){let i=r(n),[o]=d.useState(()=>new u(i,t));d.useEffect(()=>{o.setOptions(t)},[o,t]);let c=d.useSyncExternalStore(d.useCallback(e=>o.subscribe(s.batchCalls(e)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),l=d.useCallback((...t)=>{o.mutate(t[0],t[1]).catch(e)},[o]);if(c.error&&a(o.options.throwOnError,[c.error]))throw c.error;return{...c,mutate:l,mutateAsync:c.mutate}}export{f as t};
@@ -6,6 +6,11 @@ import { loadLedger } from "../engine/load.js";
6
6
  import { statements } from "../modules/cards/statements.js";
7
7
  import { recordFor, termsOf } from "../modules/cards/terms.js";
8
8
  import { readDataDir } from "../node/files.js";
9
+ import { plan } from "../engine/actions.js";
10
+ import { yamlText } from "../engine/write.js";
11
+ import { STATEMENTS_FILE, withBankAmounts } from "../modules/cards/terms.js";
12
+ import { reconcile } from "../node/reconcile.js";
13
+ import { linesText, parseStatement, pdfLines } from "../node/statement-rows.js";
9
14
  import { ENV_FILE, missingMonths, monthFromText, passwordVars, PdfPasswordError, pdfText, readEnvFile, readSources, scanStatements, STATEMENTS_DIR, unlockPdf, } from "../node/statements.js";
10
15
  const USAGE = `Usage:
11
16
  ownledger statements add <account-id> <file.pdf>... [--month YYYY-MM] [--dir <repo>] [--yes] [--no-commit]
@@ -14,12 +19,17 @@ const USAGE = `Usage:
14
19
  ownledger statements list [<account-id>] [--dir <repo>]
15
20
  Which months each card has, and which are missing between the first and the last.
16
21
  ownledger statements check <account-id> <YYYY-MM> [--dir <repo>] [--json]
17
- The statement's text next to ownledger's figures and transactions for the same period, to compare.`;
22
+ One statement's rows and text (columns kept) next to ownledger's figures and transactions for the same period.
23
+ ownledger statements reconcile <account-id> [--from YYYY-MM] [--to YYYY-MM] [--dir <repo>] [--json] [--save-bank-amounts [--yes]]
24
+ Every filed statement of the card against the ledger: the bank's closing figure next to ownledger's per month,
25
+ rows missing on the ledger, ledger rows on no statement, typos, rows on the wrong account, balance adjustments.
26
+ Reports only. --json is shaped for one \`batch\` call. --save-bank-amounts saves each month's bank figure
27
+ (data/cards/statements.yaml): preview unless --yes.`;
18
28
  function opt(args, name) {
19
29
  const i = args.indexOf(name);
20
30
  return i >= 0 ? args[i + 1] : args.find((a) => a.startsWith(name + "="))?.slice(name.length + 1);
21
31
  }
22
- const positional = (args) => args.filter((a, i) => !a.startsWith("-") && !["--month", "--dir"].includes(args[i - 1] ?? ""));
32
+ const positional = (args) => args.filter((a, i) => !a.startsWith("-") && !["--month", "--dir", "--from", "--to"].includes(args[i - 1] ?? ""));
23
33
  function ledgerAt(root) {
24
34
  return loadLedger(readDataDir(root)).ledger;
25
35
  }
@@ -37,6 +47,8 @@ export async function cmdStatements(args) {
37
47
  return list(root, positional(rest)[0]);
38
48
  if (sub === "check")
39
49
  return check(root, rest);
50
+ if (sub === "reconcile")
51
+ return reconcileCmd(root, rest);
40
52
  console.log(USAGE);
41
53
  return 2;
42
54
  }
@@ -203,15 +215,19 @@ async function check(root, args) {
203
215
  })
204
216
  : [];
205
217
  let text;
218
+ let parsed = null;
206
219
  try {
207
- text = await pdfText(new Uint8Array(readFileSync(join(root, rel))));
220
+ const lines = await pdfLines(new Uint8Array(readFileSync(join(root, rel))));
221
+ text = linesText(lines);
222
+ if (stmt)
223
+ parsed = parseStatement(lines, stmt, readSources(root)[account], l.meta.base);
208
224
  }
209
225
  catch (e) {
210
226
  console.error(`${rel}: can't read the PDF's text (${e instanceof Error ? e.message : e}). Is it still locked? File it with \`ownledger statements add\`.`);
211
227
  return 1;
212
228
  }
213
229
  if (args.includes("--json")) {
214
- console.log(JSON.stringify({ account, month, file: rel, statement: stmt ?? null, transactions: txs, text }, null, 2));
230
+ console.log(JSON.stringify({ account, month, file: rel, statement: stmt ?? null, transactions: txs, bank_closing: parsed?.closing ?? null, rows: parsed?.rows ?? [], text }, null, 2));
215
231
  return 0;
216
232
  }
217
233
  console.log(`# ${account} statement ${month} (${rel})\n`);
@@ -226,6 +242,138 @@ async function check(root, args) {
226
242
  for (const t of txs)
227
243
  console.log(`| ${t.date} | ${fmt(t.amount)} | ${t.note.replace(/\|/g, "/")} | ${t.against} | ${t.id} |`);
228
244
  }
229
- console.log(`\n## Statement text (as extracted from the PDF)\n\n${text}`);
245
+ if (parsed) {
246
+ console.log(`\n## Rows read from the statement (${parsed.rows.length}; same signs as above)${parsed.closing !== null ? `, bank's closing figure ${fmt(parsed.closing)} ("${parsed.closingLabel}")` : ", no closing figure found (set closing_label in sources.yaml)"}\n`);
247
+ console.log("| date | amount | description |\n|---|---|---|");
248
+ for (const r of parsed.rows)
249
+ console.log(`| ${r.date} | ${fmt(r.amount)} | ${r.description.replace(/\|/g, "/")} |`);
250
+ }
251
+ console.log(`\n## Statement text (columns kept)\n\n${text}`);
252
+ console.log(`\nTo check every statement of the card at once: ownledger statements reconcile ${account}`);
253
+ return 0;
254
+ }
255
+ /* ------------------------------------------------------------------ reconcile */
256
+ async function reconcileCmd(root, args) {
257
+ const [account] = positional(args);
258
+ const fromM = opt(args, "--from");
259
+ const toM = opt(args, "--to");
260
+ if (!account || [fromM, toM].some((m) => m !== undefined && !/^\d{4}-(0[1-9]|1[0-2])$/.test(m))) {
261
+ console.log(USAGE);
262
+ return 2;
263
+ }
264
+ const files = readDataDir(root);
265
+ const l = loadLedger(files).ledger;
266
+ if (!l.accounts.some((a) => a.id === account)) {
267
+ console.error(`No account "${account}" in data/accounts.yaml.`);
268
+ return 1;
269
+ }
270
+ if (!statementDayOf(l, account)) {
271
+ console.error(`${account} has no statement_day: set it (edit_account details.statement_day) so statement periods are known.`);
272
+ return 1;
273
+ }
274
+ const asOf = todayIn();
275
+ const periods = new Map(statements(l, account, asOf).filter((s) => !s.open).map((s) => [s.close.slice(0, 7), s]));
276
+ const layout = readSources(root)[account];
277
+ const list = scanStatements(root, new Set([account])).files.filter((f) => f.account === account && (!fromM || f.month >= fromM) && (!toM || f.month <= toM));
278
+ if (!list.length) {
279
+ console.error(`No statements filed for ${account}${fromM || toM ? " in that range" : ""} (${STATEMENTS_DIR}/${account}/<YYYY-MM>.pdf). File them with \`ownledger statements add\`.`);
280
+ return 1;
281
+ }
282
+ const filed = [];
283
+ for (const f of list) {
284
+ const p = periods.get(f.month);
285
+ try {
286
+ const lines = await pdfLines(new Uint8Array(readFileSync(join(root, f.path))));
287
+ const parsed = p ? parseStatement(lines, p, layout, l.meta.base) : { rows: [], closing: null };
288
+ filed.push({ month: f.month, path: f.path, rows: parsed.rows, closing: parsed.closing });
289
+ }
290
+ catch (e) {
291
+ filed.push({ month: f.month, path: f.path, rows: [], closing: null, error: `can't read the PDF (${e instanceof Error ? e.message : e}); still locked? file it with \`ownledger statements add\`` });
292
+ }
293
+ }
294
+ const r = reconcile(l, account, filed, asOf);
295
+ if (args.includes("--json"))
296
+ console.log(JSON.stringify(r, null, 2));
297
+ else
298
+ printReconcile(r);
299
+ if (args.includes("--save-bank-amounts"))
300
+ return saveBankAmounts(root, files, l, r, args.includes("--yes"));
301
+ return 0;
302
+ }
303
+ function printReconcile(r) {
304
+ const sign = (n) => (n === null ? "—" : n > 0 ? `+${fmt(n)}` : fmt(n));
305
+ console.log(`# ${r.account}: ${r.months.length} statement(s), ${r.from} … ${r.to}\n`);
306
+ console.log("Amounts on the card like the ledger: negative = spent, positive = paid back / refunded / cashback. Gap = ownledger − bank.\n");
307
+ console.log("| month | period | rows | bank | ownledger | gap | of which timing | change | missing | |\n|---|---|---|---|---|---|---|---|---|---|");
308
+ for (const m of r.months) {
309
+ const note = m.error ?? (m.diff && m.timing === m.diff ? "timing only: rows on the other side of the close date" : m.bankFrom === "saved" ? "bank figure from data/cards/statements.yaml" : m.bank === null ? "no closing figure found: set closing_label in sources.yaml" : "");
310
+ console.log(`| ${m.month} | ${m.from ? `${m.from} … ${m.close}` : ""} | ${m.rows} | ${m.bank === null ? "—" : fmt(m.bank)} | ${m.ledger === null ? "—" : fmt(m.ledger)} | ${m.diff ? sign(m.diff) : m.diff === 0 ? "✓" : "—"} | ${m.timing ? sign(m.timing) : ""} | ${m.change ? sign(m.change) : ""} | ${m.missing || ""} | ${note} |`);
311
+ }
312
+ console.log(`\nMatched ${r.matched} row(s).`);
313
+ const row = (x) => `${x.date} ${fmt(x.amount).padStart(12)} ${(x.description ?? x.note ?? "").slice(0, 70)}`;
314
+ if (r.missing.length) {
315
+ console.log(`\n## On a statement, not on the ledger (${r.missing.length}, total ${fmt(r.missing.reduce((s, x) => s + x.amount, 0))})\n`);
316
+ for (const x of r.missing)
317
+ console.log(`- ${row(x)} (${x.month})`);
318
+ }
319
+ if (r.amountDiffs.length) {
320
+ console.log(`\n## Different amount (${r.amountDiffs.length}): statement → ledger\n`);
321
+ for (const x of r.amountDiffs)
322
+ console.log(`- ${x.statement.date} ${fmt(x.statement.amount)} → ledger ${x.ledger.date} ${fmt(x.ledger.amount)} "${x.ledger.note}" (${x.ledger.id})`);
323
+ }
324
+ if (r.otherAccount.length) {
325
+ console.log(`\n## Probably booked on another account (${r.otherAccount.length})\n`);
326
+ for (const x of r.otherAccount)
327
+ console.log(`- ${row(x.statement)} → on ${x.ledger.account}: ${x.ledger.date} "${x.ledger.note}" (${x.ledger.id})`);
328
+ }
329
+ if (r.notOnStatement.length) {
330
+ console.log(`\n## On the ledger, on no statement (${r.notOnStatement.length}, total ${fmt(r.notOnStatement.reduce((s, x) => s + x.amount, 0))})\n`);
331
+ for (const x of r.notOnStatement)
332
+ console.log(`- ${row(x)} [${x.against}] (${x.id})`);
333
+ }
334
+ if (r.adjustments.length) {
335
+ console.log(`\n## Balance adjustments covering a gap (${r.adjustments.length}): replace them with the real rows above\n`);
336
+ for (const x of r.adjustments)
337
+ console.log(`- ${row(x)} (${x.id})`);
338
+ }
339
+ if (r.joined.length) {
340
+ console.log(`\n## Matched as a sum (${r.joined.length}): fine, shown so you know\n`);
341
+ for (const j of r.joined)
342
+ console.log(`- statement ${j.statement.map((x) => `${x.date} ${fmt(x.amount)}`).join(" + ")} = ledger ${j.ledger.map((x) => `${x.date} ${fmt(x.amount)}`).join(" + ")}`);
343
+ }
344
+ if (r.netZero.length) {
345
+ console.log(`\n## Missing but net 0 (${r.netZero.length}): a purchase and its refund/cashback, both not on the ledger\n`);
346
+ for (const z of r.netZero)
347
+ console.log(`- ${z.map((x) => `${x.date} ${fmt(x.amount)} ${x.description.slice(0, 40)}`).join(" + ")}`);
348
+ }
349
+ const clean = !r.missing.length && !r.amountDiffs.length && !r.otherAccount.length && !r.notOnStatement.length && !r.adjustments.length && r.months.every((m) => !m.diff || m.diff === m.timing);
350
+ console.log(clean ? "\n✓ Every statement agrees with the ledger." : "\nNext: propose the fixes to the owner as ONE batch (connector `batch`, or --json for the hints). Never add a balance adjustment to cover a gap.");
351
+ }
352
+ function saveBankAmounts(root, files, l, r, yes) {
353
+ const set = r.months.filter((m) => m.bank !== null && m.bankFrom === "pdf" && m.close).map((m) => ({ account: r.account, statement_date: m.close, amount: m.bank }));
354
+ const had = new Map(withBankAmounts(l, []).map((x) => [`${x.account}|${x.statement_date}`, x.amount]));
355
+ const changes = set.filter((x) => had.get(`${x.account}|${x.statement_date}`) !== x.amount);
356
+ if (!changes.length) {
357
+ console.log("\nBank amounts: nothing new to save.");
358
+ return 0;
359
+ }
360
+ const p = plan(files, { putFiles: { [STATEMENTS_FILE]: yamlText(withBankAmounts(l, changes)) } }, `Card statements: ${r.account} bank amounts ${changes.map((x) => x.statement_date.slice(0, 7)).join(", ")}`);
361
+ console.log(`\nBank amounts to save in ${STATEMENTS_FILE} (${changes.length}):`);
362
+ for (const x of changes)
363
+ console.log(`- ${x.statement_date}: ${fmt(x.amount)}${had.has(`${x.account}|${x.statement_date}`) ? ` (was ${fmt(had.get(`${x.account}|${x.statement_date}`))})` : ""}`);
364
+ if (!yes) {
365
+ console.log("\nPreview only: nothing written. Run again with --save-bank-amounts --yes after the owner's go.");
366
+ return 0;
367
+ }
368
+ for (const [path, content] of Object.entries(p.files)) {
369
+ mkdirSync(dirname(join(root, path)), { recursive: true });
370
+ writeFileSync(join(root, path), content);
371
+ }
372
+ console.log(`✓ Saved ${STATEMENTS_FILE}`);
373
+ if (existsSync(join(root, ".git"))) {
374
+ execFileSync("git", ["add", ...Object.keys(p.files)], { cwd: root });
375
+ execFileSync("git", ["commit", "-q", "-m", p.message], { cwd: root, stdio: "inherit" });
376
+ console.log(`✓ Committed: ${p.message.split("\n")[0]}`);
377
+ }
230
378
  return 0;
231
379
  }
@@ -44,6 +44,34 @@ export declare function linesOf(t: SimpleTx): Line[];
44
44
  export declare function addTransaction(files: FileMap, t: SimpleTx, meta?: WriteMeta): Planned;
45
45
  export declare function editTransaction(files: FileMap, id: string, patch: Partial<SimpleTx>, meta?: WriteMeta): Planned;
46
46
  export declare function voidTransaction(files: FileMap, id: string, reason?: string, meta?: WriteMeta): Planned;
47
+ export type BatchOp = ({
48
+ op: "add";
49
+ reason?: string;
50
+ } & SimpleTx) | ({
51
+ op: "edit";
52
+ id: string;
53
+ reason?: string;
54
+ } & Partial<SimpleTx>) | {
55
+ op: "void";
56
+ id: string;
57
+ reason?: string;
58
+ };
59
+ export declare const BATCH_MAX = 200;
60
+ export interface BatchPlanned extends Planned {
61
+ /** Change in each account's balance (base currency) over the whole batch. */
62
+ balanceChange: Record<string, number>;
63
+ counts: {
64
+ add: number;
65
+ edit: number;
66
+ void: number;
67
+ };
68
+ }
69
+ /**
70
+ * Many adds, edits and voids as one change: the ops run one after another on the evolving files
71
+ * (an op can edit or void a row an earlier op added), check runs once on the result, one commit.
72
+ * Any op failing refuses the whole batch, naming the op.
73
+ */
74
+ export declare function batch(files: FileMap, ops: BatchOp[], meta?: WriteMeta): BatchPlanned;
47
75
  /** The ledger of a set of files, for actions that read it before building a change. */
48
76
  export declare function loadForAction(files: FileMap): {
49
77
  ledger: import("./types.js").Ledger;
@@ -67,6 +67,10 @@ export function linesOf(t) {
67
67
  : [{ account: t.account, amount: -a }, { category: t.category, amount: a }];
68
68
  }
69
69
  export function addTransaction(files, t, meta) {
70
+ const b = buildAdd(t, meta);
71
+ return plan(files, b.change, b.message);
72
+ }
73
+ function buildAdd(t, meta) {
70
74
  if (!isDate(t.date))
71
75
  throw new ActionError("date must be yyyy-mm-dd");
72
76
  const tx = {
@@ -80,7 +84,8 @@ export function addTransaction(files, t, meta) {
80
84
  ...(t.plan ? { plan: t.plan } : {}),
81
85
  lines: linesOf(t),
82
86
  };
83
- return plan(files, { addTransactions: [trailed(tx, "add", meta)] }, withMeta(`Add: ${t.date} ${t.note ?? ""}`.trim(), meta));
87
+ const done = trailed(tx, "add", meta);
88
+ return { change: { addTransactions: [done] }, message: withMeta(`Add: ${t.date} ${t.note ?? ""}`.trim(), meta), tx: done };
84
89
  }
85
90
  function findTx(files, id) {
86
91
  for (const [p, text] of Object.entries(files)) {
@@ -93,6 +98,10 @@ function findTx(files, id) {
93
98
  throw new ActionError(`no transaction ${id}`);
94
99
  }
95
100
  export function editTransaction(files, id, patch, meta) {
101
+ const b = buildEdit(files, id, patch, meta);
102
+ return plan(files, b.change, b.message);
103
+ }
104
+ function buildEdit(files, id, patch, meta) {
96
105
  const old = findTx(files, id);
97
106
  const next = { ...old };
98
107
  for (const k of ["date", "time", "note", "who", "event", "tags", "plan"]) {
@@ -104,7 +113,8 @@ export function editTransaction(files, id, patch, meta) {
104
113
  }
105
114
  if (!isDate(next.date))
106
115
  throw new ActionError("date must be yyyy-mm-dd");
107
- return plan(files, { replaceTransactions: [trailed(next, "edit", meta)] }, withMeta(`Edit: ${next.date} ${next.note ?? ""}`.trim(), meta));
116
+ const done = trailed(next, "edit", meta);
117
+ return { change: { replaceTransactions: [done] }, message: withMeta(`Edit: ${next.date} ${next.note ?? ""}`.trim(), meta), tx: done, old };
108
118
  }
109
119
  /** Best-effort simple view of a transaction (to let an edit change just one field). */
110
120
  function simpleOf(t) {
@@ -122,11 +132,107 @@ function simpleOf(t) {
122
132
  return { lines: t.lines };
123
133
  }
124
134
  export function voidTransaction(files, id, reason, meta) {
135
+ const b = buildVoid(files, id, reason, meta);
136
+ return plan(files, b.change, b.message);
137
+ }
138
+ function buildVoid(files, id, reason, meta) {
125
139
  const old = findTx(files, id);
126
140
  if (old.void)
127
141
  throw new ActionError(`${id} is already void`);
128
142
  const next = { ...old, void: true, ...(reason ? { void_reason: reason } : {}) };
129
- return plan(files, { replaceTransactions: [trailed(next, "void", meta)] }, withMeta(`Void: ${old.date} ${old.note ?? ""}`.trim(), meta));
143
+ const done = trailed(next, "void", meta);
144
+ return { change: { replaceTransactions: [done] }, message: withMeta(`Void: ${old.date} ${old.note ?? ""}`.trim(), meta), tx: done, old };
145
+ }
146
+ export const BATCH_MAX = 200;
147
+ function joinReason(batch, own) {
148
+ const r = [batch?.trim(), own?.trim()].filter(Boolean).join("; ").replace(/\s+/g, " ");
149
+ if (!r)
150
+ return undefined;
151
+ return r.length > REASON_MAX ? r.slice(0, REASON_MAX - 1) + "…" : r;
152
+ }
153
+ /**
154
+ * Many adds, edits and voids as one change: the ops run one after another on the evolving files
155
+ * (an op can edit or void a row an earlier op added), check runs once on the result, one commit.
156
+ * Any op failing refuses the whole batch, naming the op.
157
+ */
158
+ export function batch(files, ops, meta) {
159
+ if (!ops.length)
160
+ throw new ActionError("batch: no ops");
161
+ if (ops.length > BATCH_MAX)
162
+ throw new ActionError(`batch: at most ${BATCH_MAX} ops (got ${ops.length})`);
163
+ let cur = files;
164
+ const changed = new Set();
165
+ const finals = new Map(); // id -> final version
166
+ const originals = new Map(); // id -> version before the batch (null: added here)
167
+ const counts = { add: 0, edit: 0, void: 0 };
168
+ ops.forEach((o, i) => {
169
+ const m = meta ? { ...meta, reason: joinReason(meta.reason, o.reason) } : undefined;
170
+ let b;
171
+ try {
172
+ if (o.op === "add") {
173
+ const { op: _op, reason: _r, ...t } = o;
174
+ b = buildAdd(t, m);
175
+ }
176
+ else if (o.op === "edit") {
177
+ const { op: _op, reason: _r, id, ...patch } = o;
178
+ b = buildEdit(cur, id, patch, m);
179
+ }
180
+ else if (o.op === "void") {
181
+ b = buildVoid(cur, o.id, o.reason ?? meta?.reason, m);
182
+ }
183
+ else
184
+ throw new ActionError(`unknown op "${o.op}"`);
185
+ }
186
+ catch (e) {
187
+ throw new ActionError(`batch refused: op ${i + 1} (${o.op}${"id" in o && o.id ? ` ${o.id}` : ""}) failed: ${e.message}`);
188
+ }
189
+ counts[o.op]++;
190
+ if (!originals.has(b.tx.id))
191
+ originals.set(b.tx.id, b.old ?? null);
192
+ finals.set(b.tx.id, b.tx);
193
+ const out = applyChange(cur, b.change);
194
+ for (const p of Object.keys(out))
195
+ changed.add(p);
196
+ cur = { ...cur, ...out };
197
+ });
198
+ const r = checkFiles(cur);
199
+ if (!r.ok)
200
+ throw new ActionError(`batch refused, the result would not pass check:\n${r.errors.slice(0, 10).map((e) => `- ${e.where ? `[${e.where}] ` : ""}${e.message}`).join("\n")}`);
201
+ const before = new Set(checkFiles(files).warnings.map((w) => `${w.file}|${w.where}|${w.message}`));
202
+ const out = {};
203
+ for (const p of changed)
204
+ if (cur[p] !== files[p])
205
+ out[p] = cur[p];
206
+ const add = [];
207
+ const rep = [];
208
+ const balanceChange = {};
209
+ const bump = (t, sign) => {
210
+ if (!t || t.void)
211
+ return;
212
+ for (const l of t.lines)
213
+ if (l.account)
214
+ balanceChange[l.account] = (balanceChange[l.account] ?? 0) + sign * l.amount;
215
+ };
216
+ for (const [id, t] of finals) {
217
+ const old = originals.get(id) ?? null;
218
+ (old ? rep : add).push(t);
219
+ bump(t, 1);
220
+ bump(old, -1);
221
+ }
222
+ for (const [k, v] of Object.entries(balanceChange))
223
+ if (v === 0)
224
+ delete balanceChange[k];
225
+ const parts = [counts.add && `${counts.add} add${counts.add > 1 ? "s" : ""}`, counts.edit && `${counts.edit} edit${counts.edit > 1 ? "s" : ""}`, counts.void && `${counts.void} void${counts.void > 1 ? "s" : ""}`].filter(Boolean);
226
+ const change = { ...(add.length ? { addTransactions: add } : {}), ...(rep.length ? { replaceTransactions: rep } : {}) };
227
+ return {
228
+ change,
229
+ files: out,
230
+ summary: [`batch: ${parts.join(", ")}`, ...describeChange(change)],
231
+ message: withMeta(`Batch: ${parts.join(", ")}`, meta),
232
+ warnings: r.warnings.filter((w) => !before.has(`${w.file}|${w.where}|${w.message}`)),
233
+ balanceChange,
234
+ counts,
235
+ };
130
236
  }
131
237
  /** The ledger of a set of files, for actions that read it before building a change. */
132
238
  export function loadForAction(files) {
@@ -1,7 +1,7 @@
1
1
  import type { FileMap } from "../../engine/load.js";
2
2
  /**
3
3
  * Bank statement PDFs (plan 004): imports/statements/<account-id>/<YYYY-MM>.pdf, YYYY-MM = the month of the close date.
4
- * The Worker only knows their paths (from the tarball, contents not read) and streams one to the signed-in dashboard;
4
+ * The Worker only knows their paths (from the file tree, contents never downloaded) and streams one to the signed-in dashboard;
5
5
  * it never parses them. Reading them is the CLI's job, on the user's computer.
6
6
  */
7
7
  export declare const STATEMENTS_DIR = "imports/statements";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Bank statement PDFs (plan 004): imports/statements/<account-id>/<YYYY-MM>.pdf, YYYY-MM = the month of the close date.
3
- * The Worker only knows their paths (from the tarball, contents not read) and streams one to the signed-in dashboard;
3
+ * The Worker only knows their paths (from the file tree, contents never downloaded) and streams one to the signed-in dashboard;
4
4
  * it never parses them. Reading them is the CLI's job, on the user's computer.
5
5
  */
6
6
  export const STATEMENTS_DIR = "imports/statements";
@@ -84,6 +84,8 @@ export interface CardsData {
84
84
  }
85
85
  /** The cards module's data, loaded with the ledger (see ModuleDef.load). */
86
86
  export declare function cardsData(l: Ledger): CardsData;
87
+ /** data/cards/statements.yaml with these bank amounts set (one per account + statement date), sorted. */
88
+ export declare function withBankAmounts(l: Ledger, set: BankStatement[]): BankStatement[];
87
89
  export declare function recordFor(l: Ledger, account: string): CardRecord | undefined;
88
90
  /** Category emoji → category path. The owner's mapping can add its own (mapping key `card_emoji`). */
89
91
  export declare const DEFAULT_CARD_EMOJI: Record<string, string>;
@@ -70,6 +70,13 @@ export const STATEMENTS_FILE = "data/cards/statements.yaml";
70
70
  export function cardsData(l) {
71
71
  return l.ext?.cards ?? { records: [], statements: [] };
72
72
  }
73
+ /** data/cards/statements.yaml with these bank amounts set (one per account + statement date), sorted. */
74
+ export function withBankAmounts(l, set) {
75
+ const key = (x) => `${x.account}|${x.statement_date}`;
76
+ const keys = new Set(set.map(key));
77
+ const list = [...cardsData(l).statements.filter((x) => !keys.has(key(x))), ...set];
78
+ return list.sort((x, y) => (x.statement_date < y.statement_date ? -1 : x.statement_date > y.statement_date ? 1 : x.account < y.account ? -1 : 1));
79
+ }
73
80
  export function recordFor(l, account) {
74
81
  return cardsData(l).records.find((r) => r.account === account);
75
82
  }