@nice2dev/ui 1.4.15 → 1.4.17
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.
- package/CHANGELOG.md +41 -0
- package/dist/NiceAlert-RVTgQxCE.cjs +1 -0
- package/dist/NiceDataGrid-DpSADM9L.cjs +10 -0
- package/dist/NiceForm-CzH9IPmZ.cjs +1 -0
- package/dist/{NiceHtmlEditor-By7R1wRo.cjs → NiceHtmlEditor-BEWNA_UI.cjs} +1 -1
- package/dist/NiceLoginForm-Bkm5j80r.cjs +1 -0
- package/dist/{NiceMention-i7n2BoMw.cjs → NiceMention-CrJJtDJx.cjs} +1 -1
- package/dist/{NiceModuleLifecyclePanel-DVHQuhc-.cjs → NiceModuleLifecyclePanel-CxVQOIIA.cjs} +1 -1
- package/dist/{NicePagination-D9JguOl0.cjs → NicePagination-CnKYyKI5.cjs} +1 -1
- package/dist/{NicePivotGrid-B_7iQJys.cjs → NicePivotGrid-BshofJh1.cjs} +1 -1
- package/dist/NiceSavedQueryPanel-C40zmo8O.cjs +587 -0
- package/dist/{NiceScheduler-B2DamQ_L.cjs → NiceScheduler-CSWtLS5G.cjs} +1 -1
- package/dist/{core-lazy-ChKRuEPb.cjs → core-lazy-DUKT6R8d.cjs} +1 -1
- package/dist/data/NiceRowEditDialog.mjs +42 -35
- package/dist/data/NiceTreeGrid.mjs +512 -474
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +30 -3
- package/dist/editors/forms/NiceForm.mjs +55 -52
- package/dist/editors/inputs/NiceRadioGroup.mjs +12 -12
- package/dist/editors/inputs/NiceSelect.mjs +51 -51
- package/dist/editors.cjs +1 -1
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +101 -101
- package/dist/index.d.ts +31 -4
- package/dist/lazy.cjs +1 -1
- package/dist/navigation.cjs +1 -1
- package/dist/{no-code-CN_q6TcB.cjs → no-code-DPc82kyy.cjs} +11 -11
- package/dist/no-code.cjs +1 -1
- package/package.json +4 -4
- package/dist/NiceDataGrid-B1AOjgjm.cjs +0 -10
- package/dist/NiceForm-fmePSeA9.cjs +0 -1
- package/dist/NiceLoginForm-C2-WgRn0.cjs +0 -1
- package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +0 -587
|
@@ -1,587 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),Qi=require("@nice2dev/i18n"),N=require("@nice2dev/ui-core"),n=require("react"),Kn=require("./NiceDataGrid-B1AOjgjm.cjs"),qi=require("react-dom"),qe=require("./NiceButton-DzCqkG5a.cjs"),Yi=require("./NiceForm-fmePSeA9.cjs"),Hi=require("./NiceModal-BRVzjuUN.cjs"),Xi=require("./core-lBFqvT0V.cjs"),Ln=require("./no-code-CN_q6TcB.cjs"),gi=require("./NiceColorPicker-79rkvaSk.cjs"),Zi=[];function Ji(t,a){return t.filter(s=>a.every(c=>{const l=s[c.field],d=c.value;switch(c.operator){case"eq":return l===d;case"ne":return l!==d;case"gt":return typeof l=="number"&&typeof d=="number"&&l>d;case"gte":return typeof l=="number"&&typeof d=="number"&&l>=d;case"lt":return typeof l=="number"&&typeof d=="number"&&l<d;case"lte":return typeof l=="number"&&typeof d=="number"&&l<=d;case"contains":return String(l).toLowerCase().includes(String(d).toLowerCase());case"startsWith":return String(l).toLowerCase().startsWith(String(d).toLowerCase());case"endsWith":return String(l).toLowerCase().endsWith(String(d).toLowerCase());default:return!0}}))}function ea(t){return t.map(a=>({field:a.field,type:a.dataType||"string",label:typeof a.header=="string"?a.header:a.field}))}function ta(t,a){const{enableAI:s=!0,aiModel:c,enableNLSearch:l=!0,enableInsights:d=!0,nlPlaceholder:u,onAIFilter:o,onInsights:g,showAISearchBar:f=!0,exampleQueries:S=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:E=Zi,data:$,...z}=t,[b,D]=n.useState(""),[p,y]=n.useState([]),[I,x]=n.useState([]),[L,M]=n.useState(!1),[F,H]=n.useState(null),xe=n.useRef(null),{t:se}=Qi.useNiceTranslation(),_e=N.useNiceAI(),{parseFilter:De,isLoading:te}=N.useNaturalLanguageFilter(),Re=s&&_e.isConfigured,K=p.length>0?Ji($||[],p):$,Qe=n.useCallback(async w=>{if(!Re||!l||!w.trim())return;H(w);const v=ea(E);try{const de=await De(w,v);y(de),o?.(w,de)}catch{y([])}},[Re,l,E,De,o]),ze=n.useCallback(()=>{y([]),H(null),D("")},[]),$e=n.useCallback(()=>p,[p]),ce=n.useCallback(async()=>{if(!Re||!d||!$?.length)return[];try{const w=await _e.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${$.length} total rows): ${JSON.stringify($.slice(0,20))}
|
|
2
|
-
|
|
3
|
-
Columns: ${E.map(v=>v.field).join(", ")}
|
|
4
|
-
|
|
5
|
-
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const v=JSON.parse(w.content),de=Array.isArray(v)?v:[];return x(de),g?.(de),de}catch{return[]}}catch{return[]}},[Re,d,$,E,_e,g]),O=w=>{w.preventDefault(),b.trim()&&Qe(b)},G=w=>{D(w),Qe(w)};return n.useImperativeHandle(a,()=>({applyNLFilter:Qe,clearAIFilters:ze,getAIFilters:$e,generateInsights:ce})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":t["data-testid"],children:[f&&Re&&l&&e.jsxs("div",{className:"nice-data-grid-ai__search-bar",children:[e.jsx("div",{className:"nice-data-grid-ai__search-left",children:e.jsx("span",{className:"nice-data-grid-ai__badge",children:se("dataGridAI.ai","AI")})}),e.jsxs("form",{onSubmit:O,className:"nice-data-grid-ai__search-form",children:[e.jsxs("div",{className:"nice-data-grid-ai__input-wrapper",children:[e.jsx("span",{className:"nice-data-grid-ai__search-icon",children:e.jsx(N.NiceIcon,{name:"search",size:14})}),e.jsx("input",{ref:xe,type:"text",value:b,onChange:w=>D(w.target.value),placeholder:u||se("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:te}),te&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),b&&!te&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>D(""),"aria-label":se("dataGridAI.clearInput","Clear"),children:e.jsx(N.NiceIcon,{name:"close",size:14})})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:te||!b.trim(),children:te?se("dataGridAI.searching","Searching..."):se("dataGridAI.search","Search")})]}),d&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{ce(),M(!0)},disabled:te||!$?.length,title:se("dataGridAI.generateInsights","Generate AI Insights"),children:[e.jsx(N.NiceIcon,{name:"lightbulb",size:14})," ",se("dataGridAI.insights","Insights")]})]}),f&&Re&&l&&!F&&S.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:se("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:S.slice(0,4).map((w,v)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>G(w),children:['"',w,'"']},v))})]}),F&&p.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__active-filter",children:[e.jsxs("div",{className:"nice-data-grid-ai__filter-info",children:[e.jsx("span",{className:"nice-data-grid-ai__filter-icon",children:e.jsx(N.NiceIcon,{name:"target",size:14})}),e.jsxs("span",{className:"nice-data-grid-ai__filter-query",children:['"',F,'"']}),e.jsxs("span",{className:"nice-data-grid-ai__filter-count",children:["(",K?.length||0," ",se("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:p.map((w,v)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[w.field," ",w.operator," ",String(w.value)]},v))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:ze,children:[e.jsx(N.NiceIcon,{name:"close",size:14})," ",se("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx(Kn.NiceDataGrid,{columns:E,data:K,...z})}),L&&e.jsxs("div",{className:"nice-data-grid-ai__insights-panel",children:[e.jsxs("div",{className:"nice-data-grid-ai__insights-header",children:[e.jsxs("h4",{children:[e.jsx(N.NiceIcon,{name:"lightbulb",size:14})," ",se("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>M(!1),"aria-label":se("dataGridAI.closeInsights","Close"),children:e.jsx(N.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:te?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:se("dataGridAI.analyzing","Analyzing data...")}):I.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:I.map((w,v)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),w]},v))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:se("dataGridAI.noInsights","Click to generate insights from your data")})}),e.jsx("div",{className:"nice-data-grid-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-data-grid-ai__refresh-insights",onClick:()=>ce(),disabled:te,children:[e.jsx(N.NiceIcon,{name:"refresh",size:14})," ",se("dataGridAI.refresh","Refresh")]})})]})]})}const na=n.forwardRef(ta);function ia(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Bn=({text:t,query:a,highlightTag:s="mark",highlightClassName:c="",caseSensitive:l=!1,className:d="",style:u,testId:o,"data-testid":g})=>{const f=(Array.isArray(a)?a:[a]).map(z=>(z??"").trim()).filter(Boolean).map(ia);if(f.length===0||!t)return e.jsx("span",{className:`nice-highlight ${d}`,style:u,"data-testid":g??o,children:t});const S=l?"g":"gi",E=new RegExp(`(${f.join("|")})`,S),$=t.split(E);return e.jsx("span",{className:`nice-highlight ${d}`,style:u,"data-testid":g??o,children:$.map((z,b)=>b%2===1?e.jsx(s,{className:`nice-highlight__mark ${c}`.trim(),children:z},b):e.jsx(n.Fragment,{children:z},b))})};process.env.NODE_ENV!=="production"&&(Bn.displayName="NiceHighlight");function aa(t,a,s,c=0){const l=new Map,d=[];t.forEach(o=>l.set(String(o[a]),{data:o,children:[],key:String(o[a]),depth:0})),t.forEach(o=>{const g=o[s],f=l.get(String(o[a]));if(g!=null&&g!==""&&l.has(String(g))){const S=l.get(String(g));f.depth=S.depth+1,S.children.push(f)}else d.push(f)});const u=(o,g)=>{o.forEach(f=>{f.depth=g,u(f.children,g+1)})};return u(d,c),d}function ra(t,a,s){const c=l=>l.map(d=>{const u=d.children.length===0?a.get(d.key):void 0,o=u?s(u,d.depth+1):d.children;return o.length>0?{...d,children:c(o)}:d});return c(t)}function sa(t,a){const s=[],c=l=>{a(l)&&s.push(l.key),l.children.forEach(c)};return c(t),s}function wi(t,a,s,c=0){return t.map(l=>({data:l,key:String(l[s]),depth:c,children:Array.isArray(l[a])?wi(l[a],a,s,c+1):[]}))}function Pn(t){const a=[],s=c=>{c.forEach(l=>{l.children.length>0&&(a.push(l.key),s(l.children))})};return s(t),a}function ca(t){const a=[],s=c=>{c.forEach(l=>{a.push(l.key),s(l.children)})};return s(t),a}function Ni(t,a,s){return!a||!s?t:[...t].sort((l,d)=>{const u=l.data[a]??"",o=d.data[a]??"",g=typeof u=="number"&&typeof o=="number"?u-o:String(u).localeCompare(String(o));return s==="desc"?-g:g}).map(l=>({...l,children:Ni(l.children,a,s)}))}function oa(t,a,s){const c=new Set,l=new Set,d=u=>u.reduce((o,g)=>{const f=d(g.children),S=a(g);return S&&l.add(g.key),f.length>0&&c.add(g.key),S&&s?o.push(g):(S||f.length>0)&&o.push({...g,children:f}),o},[]);return{tree:d(t),expand:c,matched:l}}function la(t,a){const s=(c,l)=>c.reduce((d,u)=>{if(l)return d.push({...u,children:s(u.children,!0)}),d;if(a.isCheckable(u.key)){const g=a.state(u.key);if(g!=="unchecked"){const f=a.isLeaf(u.key)&&g==="checked";d.push({...u,children:s(u.children,f)})}return d}const o=s(u.children,!1);return o.length>0&&d.push({...u,children:o}),d},[]);return s(t,!1)}function da(t,a,s){const c=[],l=(d,u)=>{d.forEach((o,g)=>{if(c.push({node:o,level:u,posInSet:g+1,setSize:d.length}),o.children.length>0)a(o.key)&&l(o.children,u+1);else if(s&&a(o.key)){const f=s(o);f&&c.push({node:o,level:u+1,posInSet:1,setSize:1,placeholder:f})}})};return l(t,1),c}function Un(t,a,s={}){const{getKey:c,getChildren:l,isCheckable:d,isDisabled:u}=a,o=s.inheritDisabled!==!1,g=[],f=[],S=[],E=new Map,$=(b,D,p,y)=>{const I=c(b);if(E.has(I))return;const x=d?d(b):!0,L=(u?u(b):!1)||o&&y,M={pos:g.length,subtreeEnd:0,leafStart:f.length,leafEnd:0,checkable:x,leaf:!1,disabled:L,parent:p};E.set(I,M),g.push(I);const F=l(b,D);if(F)for(const H of F)$(H,D+1,I,L);x&&f.length===M.leafStart&&(M.leaf=!0,f.push(I),S.push(L)),M.leafEnd=f.length,M.subtreeEnd=g.length};for(const b of t)$(b,0,void 0,!1);const z=new Int32Array(f.length+1);for(let b=0;b<f.length;b++)z[b+1]=z[b]+(S[b]?1:0);return{keys:g,leaves:f,records:E,lockedBefore:z,has:b=>E.has(b),isCheckable:b=>E.get(b)?.checkable??!1,isLeaf:b=>E.get(b)?.leaf??!1,isLocked:b=>{const D=E.get(b);if(!D)return!1;const p=D.leafEnd-D.leafStart;return D.disabled||p===0?D.disabled:z[D.leafEnd]-z[D.leafStart]===p},leavesOf:b=>{const D=E.get(b);return D?f.slice(D.leafStart,D.leafEnd):[]},parentOf:b=>E.get(b)?.parent}}function Gn(t,a){const s=new Set,c=[];if(!a)return{leaves:s,unknown:c};const l=new Set;for(const d of a){const u=t.records.get(d);if(!u){l.has(d)||(l.add(d),c.push(d));continue}if(u.checkable)for(let o=u.leafStart;o<u.leafEnd;o++)s.add(t.leaves[o])}return{leaves:s,unknown:c}}function bn(t,a){const s=new Int32Array(t.leaves.length+1);for(let u=0;u<t.leaves.length;u++)s[u+1]=s[u]+(a.has(t.leaves[u])?1:0);const c=u=>{const o=t.records.get(u);return o?{checked:s[o.leafEnd]-s[o.leafStart],total:o.leafEnd-o.leafStart}:{checked:0,total:0}},l=u=>{const{checked:o,total:g}=c(u);return o===0||g===0?"unchecked":o===g?"checked":"indeterminate"},d=[];for(const u of t.keys){const o=t.records.get(u);o.checkable&&!o.leaf&&l(u)==="indeterminate"&&d.push(u)}return{state:l,count:c,total:{checked:s[t.leaves.length],total:t.leaves.length},halfChecked:d}}function Wn(t,a,s,c){const l=t.records.get(s);if(!l||!l.checkable)return a;const d=[];for(let o=l.leafStart;o<l.leafEnd;o++)t.lockedBefore[o+1]===t.lockedBefore[o]&&d.push(t.leaves[o]);if(d.length===0)return a;const u=!d.every(o=>a.has(o));return ji(a,d,u)}function _i(t,a,s,c){const l=[];for(const d of s){const u=t.records.get(d);u?.leaf&&!u.disabled&&l.push(d)}return l.length===0?a:ji(a,l,c)}function ji(t,a,s){const c=new Set(t);for(const l of a)s?c.add(l):c.delete(l);return c}function an(t,a,s,c=[]){const l=[];if(s==="leaves")for(const d of t.leaves)a.has(d)&&l.push(d);else{const d=new Int32Array(t.leaves.length+1);for(let o=0;o<t.leaves.length;o++)d[o+1]=d[o]+(a.has(t.leaves[o])?1:0);const u=o=>o.leafEnd>o.leafStart&&d[o.leafEnd]-d[o.leafStart]===o.leafEnd-o.leafStart;for(let o=0;o<t.keys.length;){const g=t.keys[o],f=t.records.get(g);if(f.checkable&&u(f)&&(l.push(g),s==="parents")){o=f.subtreeEnd;continue}o++}}for(const d of c)l.push(d);return l}const ua=600,Si="application/x-nice-tree-row";function Vn(t,a,s=!0){const c=(t-a.top)/Math.max(1,a.height);return s?c<.25?"before":c>.75?"after":"inside":c<.5?"before":"after"}function Qn(t,a=!1){if(!(t.ctrlKey||t.metaKey)||!t.shiftKey||t.altKey)return null;switch(t.key){case"ArrowUp":return"up";case"ArrowDown":return"down";case"ArrowRight":return a?"out":"in";case"ArrowLeft":return a?"in":"out";default:return null}}function qn(t,a,s,c){const l=c.indexOf(a);if(l<0)return null;switch(t){case"up":return l>0?{key:c[l-1],position:"before"}:null;case"down":return l<c.length-1?{key:c[l+1],position:"after"}:null;case"in":return l>0?{key:c[l-1],position:"inside"}:null;case"out":return s!==null?{key:s,position:"after"}:null}}function Yn(t){const a=n.useRef(t);a.current=t;const[s,c]=n.useState(null),[l,d]=n.useState(null),u=n.useRef({drag:null,target:null}),o=n.useRef({key:null,timer:void 0}),g=n.useCallback(()=>{clearTimeout(o.current.timer),o.current={key:null,timer:void 0}},[]),f=n.useCallback(b=>{const D=u.current.target;if(D?.key===b?.key&&D?.position===b?.position)return;u.current.target=b,d(b);const p=b?.position==="inside"?b.key:null;p!==o.current.key&&(g(),p!==null&&a.current.onHoverOpen&&(o.current={key:p,timer:setTimeout(()=>a.current.onHoverOpen?.(p),ua)}))},[g]),S=n.useCallback(()=>{g(),u.current={drag:null,target:null},c(null),d(null)},[g]);n.useEffect(()=>g,[g]);const E=b=>{const D=b.target?.closest?.(a.current.rowSelector);return D&&b.currentTarget.contains(D)?D:null},$=b=>{const D=a.current,p=u.current.drag,y=E(b),I=y?.dataset.key;if(!y||I===void 0||p===null||D.isWithin(I,p))return null;const x=(D.rectOf?.(y)??y).getBoundingClientRect(),L=D.canNest?D.canNest(I):!0,M=H=>D.canDrop?D.canDrop(p,I,H):!0,F=Vn(b.clientY,x,L);if(M(F))return{key:I,position:F};if(F==="inside"){const H=Vn(b.clientY,x,!1);return M(H)?{key:I,position:H}:null}return null};return{dragKey:s,target:l,handlers:{onDragStart:b=>{const D=a.current,p=E(b)?.dataset.key;if(!(!D.enabled||p===void 0)){if(D.canDrag&&!D.canDrag(p)){b.preventDefault();return}b.stopPropagation();try{b.dataTransfer.setData(Si,p),b.dataTransfer.setData("text/plain",p),b.dataTransfer.effectAllowed="move"}catch{}u.current={drag:p,target:null},c(p)}},onDragOver:b=>{if(u.current.drag===null)return;const D=$(b);if(f(D),D){b.preventDefault();try{b.dataTransfer.dropEffect="move"}catch{}}},onDragLeave:b=>{const D=b.relatedTarget;(!D||!b.currentTarget.contains(D))&&f(null)},onDrop:b=>{const D=u.current.drag;if(D===null)return;const p=$(b)??u.current.target;b.preventDefault(),b.stopPropagation(),S(),p&&a.current.onDrop?.(D,p.key,p.position)},onDragEnd:S}}}const ha=[],ma=[],On=[],fa=new Set,pa=new Map,ga=[],_a=new Map,ba=new Map,bi=["expandAll","collapseAll","onlyChecked","clearChecked"],xi=10;function xa({node:t,level:a,posInSet:s,setSize:c,rowIndex:l,ariaRowIndex:d,columns:u,highlight:o,query:g,expandable:f,expanded:S,busy:E,expandLabel:$,collapseLabel:z,subtreeAction:b,subtreeLabel:D,checkMode:p,hasCheckbox:y,checkState:I,checkLabel:x,locked:L,countChecked:M,countTotal:F,countTitle:H,selectColumn:xe,selected:se,selectLabel:_e,readOnly:De,className:te,clickable:Re,height:K,draggable:Qe,drop:ze,dragging:$e,handlers:ce}){const O=y?e.jsx("input",{type:"checkbox",className:"nice-treegrid__check-input",checked:I==="checked",ref:w=>{w&&(w.indeterminate=I==="indeterminate")},disabled:L||De,tabIndex:-1,"aria-label":x,onClick:w=>w.stopPropagation(),onChange:w=>{ce.toggleCheck(t.key),w.currentTarget.closest("tr")?.focus({preventScroll:!0})}}):null,G=["nice-treegrid__row",p!=="none"&&!y?"nice-treegrid__row--info":"",L?"nice-treegrid__row--disabled":"",y&&I==="checked"?"nice-treegrid__row--checked":"",se?"nice-datagrid__row--selected":"",ze?`nice-treegrid__row--drop-${ze}`:"",$e?"nice-treegrid__row--dragging":"",te??""].filter(Boolean).join(" ");return e.jsxs("tr",{className:G,"data-key":t.key,draggable:Qe||void 0,tabIndex:-1,"aria-level":a,"aria-posinset":s,"aria-setsize":c,"aria-rowindex":d,"aria-expanded":f?S:void 0,"aria-selected":se,"aria-disabled":L||void 0,"aria-busy":E||void 0,onClick:()=>ce.rowClick(t),style:Re||K!==void 0?{cursor:Re?"pointer":void 0,height:K}:void 0,children:[p==="column"&&e.jsx("td",{className:"nice-datagrid__checkbox nice-treegrid__check-cell",children:O}),xe&&e.jsx("td",{className:"nice-datagrid__checkbox",children:e.jsx("input",{type:"checkbox",checked:!!se,onChange:()=>ce.toggleSelected(t.key),onClick:w=>w.stopPropagation(),disabled:De,tabIndex:-1,"aria-label":_e})}),u.map((w,v)=>{const de=t.data[w.field];return e.jsxs("td",{style:{textAlign:w.align},children:[v===0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-treegrid__indent",style:{width:(a-1)*20}}),e.jsx("button",{type:"button",className:`nice-treegrid__toggle ${f?"":"nice-treegrid__toggle--leaf"}`,onClick:re=>{re.stopPropagation(),f&&ce.toggleExpand(t.key,re.altKey||re.shiftKey)},tabIndex:-1,"aria-hidden":f?void 0:!0,"aria-label":f?S?z:$:void 0,children:f?e.jsx(N.NiceIcon,{name:S?"chevron-down":"chevron-right",size:12}):""}),p==="tree"&&e.jsx("span",{className:`nice-treegrid__check${y?"":" nice-treegrid__check--none"}`,children:O})]}),w.render?w.render(de,t.data,l):o[v]&&g?e.jsx(Bn,{text:String(de??""),query:g,highlightClassName:"nice-treegrid__match"}):String(de??""),v===0&&F>0&&e.jsxs("span",{className:`nice-treegrid__count${M===F?" nice-treegrid__count--full":""}`,title:H,children:[M,"/",F]}),v===0&&b&&e.jsx("button",{type:"button",className:"nice-treegrid__row-action",tabIndex:-1,"aria-label":D,title:D,onClick:re=>{re.stopPropagation(),ce.setSubtreeExpanded(t.key,b==="expand")},children:e.jsx(N.NiceIcon,{name:b==="expand"?"expand":"collapse",size:12})})]},w.field)})]})}const ya=n.memo(xa);function va({columns:t=ha,data:a=ma,keyField:s="id",parentKeyField:c="parentId",nested:l=!1,childrenField:d="children",expandedKeys:u,defaultExpandedKeys:o,onExpandedChange:g,hasChildren:f,loadChildren:S,rowActions:E,defaultExpandAll:$=!1,sortable:z=!0,sortField:b,sortDirection:D,onSort:p,selectable:y,selectedKeys:I,onSelectionChange:x,checkable:L,checkedKeys:M,defaultCheckedKeys:F,onCheckedChange:H,checkStrategy:xe="all",isRowCheckable:se,isRowDisabled:_e,checkboxPlacement:De="tree",checkOnRowClick:te,showCheckedCount:Re,checkedSummary:K,showSelectAll:Qe=!0,showOnlyChecked:ze,defaultShowOnlyChecked:$e,onShowOnlyCheckedChange:ce,toolbarActions:O,searchable:G,searchPlaceholder:w,searchText:v,defaultSearchText:de,onSearchChange:re,searchFields:j,searchFilter:he,searchKeepDescendants:fe=!1,searchAutoExpand:ye=!0,highlightMatches:A=!0,rowClassName:oe,getRowLabel:pe,virtualScroll:Be,rowHeight:ue=36,height:Ae,striped:ke,compact:Ke,size:Ue="md",loading:it,disabled:at,readOnly:rt,error:je,emptyText:W,toolbar:be,onRowClick:we,contextMenuItems:Te,rowDraggable:Oe,canDrop:le,onRowDrop:X,editMode:bt,formItems:mt,formColumns:Ne=2,editFormTitle:jt,formProps:et,onRowEdit:st,className:xt,style:r,id:C,testId:Q,"data-testid":J,accessMode:Le,"aria-label":Y,"aria-labelledby":me}){const{t:ne}=N.useNiceTranslation(),tt=N.useNiceAccessMode(Le,C),Fe=!!at||tt==="disabled",Ve=!!rt||tt==="readOnly",St=n.useCallback((i,_)=>l?wi(i,d,s,_):aa(i,s,c,_),[s,c,l,d]),Me=n.useMemo(()=>St(a,0),[St,a]),[Rt,Ht]=n.useState(_a),[Tt,Bt]=n.useState(ba),dt=n.useMemo(()=>Rt.size>0?ra(Me,Rt,St):Me,[Me,Rt,St]),Se=n.useMemo(()=>{const i=new Map,_=T=>T.forEach(U=>{i.set(U.key,U),_(U.children)});return _(dt),i},[dt]),Xe=!!f||!!S,ct=n.useCallback(i=>{if(!Xe)return!1;const _=Se.get(i);return!!_&&_.children.length===0&&!Rt.has(i)&&(f?f(_.data):!0)},[Xe,Se,Rt,f]),Ot=n.useRef(new Set),ot=n.useRef(!0);n.useEffect(()=>(ot.current=!0,()=>{ot.current=!1}),[]);const At=n.useCallback(i=>{const _=Se.get(i);if(!S||!_||Ot.current.has(i))return;Ot.current.add(i);const T=U=>{Ot.current.delete(i),ot.current&&(U&&Ht(Ee=>new Map(Ee).set(i,U)),Bt(Ee=>{const ve=new Map(Ee);return U?ve.delete(i):ve.set(i,"error"),ve}))};Bt(U=>new Map(U).set(i,"loading")),S(_.data).then(U=>T(Array.isArray(U)?U:[]),()=>T(null))},[S,Se]),ft=n.useCallback(i=>{Bt(_=>{const T=new Map(_);return T.delete(i),T})},[]),ut=n.useMemo(()=>t.filter(i=>!i.hidden),[t]),m=n.useMemo(()=>Pn(dt),[dt]),[h,R]=n.useState(null),B=n.useMemo(()=>{if(u)return new Set(u);if(h)return h;const i=new Set(o??On);return $&&m.forEach(_=>i.add(_)),i},[u,h,o,$,m]),q=n.useRef(B);q.current=B;const P=n.useCallback(i=>{q.current=i,u||R(i),g?.([...i])},[u,g]),[V,ie]=n.useState({field:"",dir:null}),ee=b??V.field,Ie=D??V.dir,Ge=n.useCallback(i=>{const _=ee===i?Ie==="asc"?"desc":Ie==="desc"?null:"asc":"asc";p?p(i,_):ie({field:i,dir:_})},[ee,Ie,p]),[Ye,lt]=N.useControllableState({value:I,fallbackValue:fa,onChange:x,componentName:"NiceTreeGrid"}),Ct=n.useCallback(i=>{lt(_=>{const T=new Set(_);return T.has(i)?T.delete(i):T.add(i),T})},[lt]),Z=n.useMemo(()=>L?Un(dt,{getKey:i=>i.key,getChildren:i=>i.children,isCheckable:se?i=>se(i.data):void 0,isDisabled:_e?i=>_e(i.data):void 0}):null,[L,dt,se,_e]),[zt,Ft]=N.useControllableState({value:M,defaultValue:F,fallbackValue:On,componentName:"NiceTreeGrid"}),We=n.useMemo(()=>Z?Gn(Z,zt):null,[Z,zt]),nt=n.useMemo(()=>Z&&We?bn(Z,We.leaves):null,[Z,We]),Ut=n.useMemo(()=>{if(typeof K!="function"||!Z||!We||!nt)return null;const i=an(Z,We.leaves,"leaves"),_=[];return i.forEach(T=>{const U=Se.get(T);U&&_.push(U.data)}),{checked:nt.total.checked,total:nt.total.total,leafKeys:i,rows:_}},[K,Z,We,nt,Se]),$t=n.useCallback((i,_)=>{if(!Z||!We||i===We.leaves)return;const T=an(Z,i,xe,We.unknown);Ft(T),H?.(T,{..._,leafKeys:an(Z,i,"leaves"),halfCheckedKeys:[...bn(Z,i).halfChecked]})},[Z,We,xe,Ft,H]),Gt=n.useCallback(i=>{if(!Z||!We)return;const _=Wn(Z,We.leaves,i);$t(_,{source:"row",checked:_.size>We.leaves.size,key:i,row:Se.get(i)?.data})},[Z,We,$t,Se]),[Lt,Xt]=N.useControllableState({value:v,defaultValue:de,fallbackValue:"",onChange:re,componentName:"NiceTreeGrid"}),yt=Lt.trim(),Kt=n.useMemo(()=>j??ut.map(i=>i.field),[j,ut]),vt=n.useMemo(()=>{if(!yt)return null;const i=yt.toLowerCase();return oa(dt,he?T=>he(T.data,yt):T=>Kt.some(U=>String(T.data[U]??"").toLowerCase().includes(i)),fe)},[dt,yt,he,Kt,fe]),Pt=vt?.tree??dt,[Zt,yn]=N.useControllableState({value:ze,defaultValue:$e,fallbackValue:!1,onChange:ce,componentName:"NiceTreeGrid"}),k=!!L&&Zt&&nt!==null,ae=n.useMemo(()=>k&&nt&&Z?la(Pt,{state:nt.state,isCheckable:Z.isCheckable,isLeaf:Z.isLeaf}):Pt,[k,nt,Z,Pt]),ge=yt!==""||k,Ce=`${yt}
|
|
6
|
-
${k?1:0}`,[pt,Dt]=n.useState(()=>({key:"",map:new Map})),Mt=pt.key===Ce?pt.map:pa,ht=n.useMemo(()=>{const i=new Set;return vt&&ye&&vt.expand.forEach(_=>i.add(_)),k&&Z&&Pn(ae).forEach(_=>{Z.isLeaf(_)||i.add(_)}),i},[vt,ye,k,Z,ae]),kt=n.useCallback(i=>ge?Mt.get(i)??(B.has(i)||ht.has(i)):B.has(i),[ge,Mt,B,ht]),sn=n.useCallback((i,_)=>{const T=q.current;if(i.some(U=>T.has(U)!==_)){const U=new Set(T);i.forEach(Ee=>_?U.add(Ee):U.delete(Ee)),P(U)}ge&&Dt(U=>{const Ee=new Map(U.key===Ce?U.map:void 0);return i.forEach(ve=>Ee.set(ve,_)),{key:Ce,map:Ee}})},[P,ge,Ce]),Hn=n.useCallback(i=>i.children.length>0||ct(i.key),[ct]),Jt=n.useRef(new Set),cn=n.useCallback((i,_)=>{const T=i.flatMap(U=>sa(U,Hn));T.forEach(U=>{_?ct(U)&&Jt.current.add(U):Jt.current.delete(U)}),sn(T,_)},[Hn,ct,sn]),en=n.useCallback((i,_)=>{const T=Se.get(i);T&&cn([T],_)},[Se,cn]),on=n.useCallback((i,_)=>{const T=!kt(i);_?en(i,T):sn([i],T)},[kt,en,sn]),Xn=n.useRef({nodeByKey:Se,isPending:ct,setSubtreesExpanded:cn});Xn.current={nodeByKey:Se,isPending:ct,setSubtreesExpanded:cn},n.useEffect(()=>{const{nodeByKey:i,isPending:_,setSubtreesExpanded:T}=Xn.current,U=[];for(const Ee of[...Jt.current]){const ve=i.get(Ee);(!ve||ve.children.length>0||!_(Ee))&&(Jt.current.delete(Ee),U.push(...ve?.children??[]))}U.length>0&&T(U,!0)},[dt]);const Ei=n.useCallback(i=>{i||Jt.current.clear(),P(i?new Set(m):new Set),ge&&Dt({key:Ce,map:new Map(Pn(ae).map(_=>[_,i]))})},[P,m,ge,Ce,ae]),ln=n.useMemo(()=>Ni(ae,ee,Ie),[ae,ee,Ie]),Zn=n.useCallback(i=>ct(i.key)?Tt.get(i.key)==="error"?"error":"loading":null,[ct,Tt]),wt=n.useMemo(()=>da(ln,kt,Xe?Zn:void 0),[ln,kt,Xe,Zn]),vn=E===!0||Array.isArray(E)&&E.includes("expandSubtree"),Ri=n.useMemo(()=>{const i=new Set;if(!vn)return i;const _=T=>{if(T.children.length===0)return!ct(T.key);let U=kt(T.key);return T.children.forEach(Ee=>{_(Ee)||(U=!1)}),U&&i.add(T.key),U};return dt.forEach(_),i},[vn,dt,ct,kt]);n.useEffect(()=>{S&&wt.forEach(i=>{i.placeholder==="loading"&&At(i.node.key)})},[wt,S,At]);const Wt=n.useMemo(()=>Z?yt?ca(Pt).filter(i=>Z.isLeaf(i)):Z.leaves:On,[Z,yt,Pt]),Jn=n.useMemo(()=>{if(!We||Wt.length===0)return"unchecked";let i=0;for(const _ of Wt)We.leaves.has(_)&&i++;return i===0?"unchecked":i===Wt.length?"checked":"indeterminate"},[We,Wt]),Ai=n.useCallback(()=>{if(!Z||!We)return;const i=Wt.filter(T=>!Z.isLocked(T)),_=!i.every(T=>We.leaves.has(T));$t(_i(Z,We.leaves,i,_),{source:"selectAll",checked:_})},[Z,We,Wt,$t]),Ti=n.useCallback(()=>{Z&&We&&$t(_i(Z,We.leaves,Z.leaves,!1),{source:"clear",checked:!1})},[Z,We,$t]),ei=i=>{Ve||Fe||(L&&te&&Z?.isCheckable(i.key)?Gt(i.key):L&&y&&Ct(i.key),we?.(i.data))},Qt=n.useRef({toggleExpand:on,setSubtreeExpanded:en,toggleCheck:Gt,toggleSelected:Ct,rowClick:ei});Qt.current={toggleExpand:on,setSubtreeExpanded:en,toggleCheck:Gt,toggleSelected:Ct,rowClick:ei};const ti=n.useMemo(()=>({toggleExpand:(i,_)=>Qt.current.toggleExpand(i,_),setSubtreeExpanded:(i,_)=>Qt.current.setSubtreeExpanded(i,_),toggleCheck:i=>Qt.current.toggleCheck(i),toggleSelected:i=>Qt.current.toggleSelected(i),rowClick:i=>Qt.current.rowClick(i)}),[]),Vt=!!Oe&&!!X&&!Ve&&!Fe,kn=n.useMemo(()=>{const i=new Map;if(!Vt)return i;const _=(T,U)=>{const Ee=T.map(ve=>ve.key);T.forEach(ve=>{i.set(ve.key,{parent:U,siblings:Ee}),_(ve.children,ve.key)})};return _(ln,null),i},[Vt,ln]),ni=n.useCallback((i,_)=>{const T=new Set;for(let U=i;U!=null&&!T.has(U);U=kn.get(U)?.parent){if(U===_)return!0;T.add(U)}return!1},[kn]),wn=i=>{const _=Se.get(i);return!!_&&(typeof Oe=="function"?Oe(_.data):!0)},ii=(i,_,T)=>{const U=Se.get(i),Ee=Se.get(_);return!U||!Ee||ni(_,i)?!1:le?le(U.data,Ee.data,T):!0},dn=Yn({enabled:Vt,rowSelector:"tr.nice-treegrid__row",canDrag:wn,isWithin:ni,canDrop:ii,onDrop:(i,_,T)=>X?.(i,_,T),onHoverOpen:i=>{const _=Se.get(i);_&&(_.children.length>0||ct(i))&&!kt(i)&&on(i)}}),[zi,ai]=n.useState(""),Nn=bt==="popup"&&!!st&&!Ve&&!Fe,[un,hn]=n.useState(null),ri=i=>{const _=i===void 0?void 0:Se.get(i);Nn&&_&&hn({key:_.key,data:{..._.data}})},gt=!!Be,mn=n.useRef(null),[si,$i]=n.useState(typeof Ae=="number"?Ae:480);n.useEffect(()=>{const i=mn.current;if(!gt||!i||typeof ResizeObserver>"u")return;const _=new ResizeObserver(()=>{i.clientHeight>0&&$i(i.clientHeight)});return _.observe(i),()=>_.disconnect()},[gt]);const jn=N.useVirtualScroll({itemCount:gt?wt.length:0,itemHeight:ue,containerHeight:si,overscan:8}),Sn=gt?jn.startIndex:0,Cn=gt?jn.endIndex:wt.length,Dn=n.useRef(null),ci=n.useRef(kt);ci.current=kt,N.useTreeFocus(Dn,{itemSelector:"tr.nice-treegrid__row",enabled:!Fe,onToggle:(i,_)=>{const T=i.dataset.key;T!==void 0&&i.hasAttribute("aria-expanded")&&ci.current(T)!==_&&ti.toggleExpand(T)}});const Li=n.useContext(N.NiceThemeContext),Mn=n.useRef(null),[qt,oi]=n.useState(null),In=n.useCallback(()=>oi(null),[]);N.useOverlayFocus(Mn,{open:!!qt,modal:!1,initialFocus:'[role="menuitem"]:not([disabled])',onClose:In}),N.useRovingFocus(Mn,{orientation:"vertical",itemSelector:'[role="menuitem"]'});const li=(i,_,T)=>{const U=Te?Se.get(i):void 0,Ee=U?Te?.(U.data):void 0;return Ee?.some(ve=>!ve.divider)?(oi({key:i,x:_,y:T,items:Ee}),!0):!1},En=n.useCallback(i=>[...Dn.current?.querySelectorAll("tr.nice-treegrid__row")??[]].find(_=>_.dataset.key===i),[]),[Rn,An]=n.useState(null);n.useEffect(()=>{if(Rn===null)return;const i=En(Rn);i&&(i.focus(),An(null))},[Rn,Sn,Cn,En]);const Pi=i=>{const _=wt[i]?.placeholder?i-1:i,T=wt[_]?.node.key;if(T===void 0)return;const U=En(T);U?U.focus():gt&&mn.current&&(mn.current.scrollTop=Math.max(0,_*ue-si/2),An(T))},Oi=i=>{const _=i.target;if(i.altKey||i.ctrlKey||i.metaKey||!_.matches?.("tr.nice-treegrid__row"))return;const T=_.dataset.key??"";if(i.shiftKey&&(i.key==="ArrowRight"||i.key==="ArrowLeft")){if(_.hasAttribute("aria-expanded")){i.preventDefault();const ve=getComputedStyle(_).direction==="rtl";en(T,i.key==="ArrowRight"!==ve)}return}if(i.key===" "){if(Ve)return;L&&Z?.isCheckable(T)?(i.preventDefault(),Gt(T)):y&&(i.preventDefault(),Ct(T));return}if(!(i.key==="PageDown"||i.key==="PageUp")&&!(gt&&(i.key==="Home"||i.key==="End")))return;const Ee=wt.findIndex(ve=>ve.node.key===T);Ee<0||(i.preventDefault(),Pi(i.key==="PageDown"?Math.min(wt.length-1,Ee+xi):i.key==="PageUp"?Math.max(0,Ee-xi):i.key==="Home"?0:wt.length-1))},Fi=ne("controls.expand","Expand"),Ki=ne("controls.collapse","Collapse"),di=ut[0]?.field,fn=i=>pe?pe(i.data):String((di!=null?i.data[di]:void 0)??i.key),ui=(i,_)=>ne("treeGrid.checkedSummary","{checked} of {total} selected").replace("{checked}",String(i)).replace("{total}",String(_)),Vi=i=>{const _=i.target;if(!Vt||!_.matches?.("tr.nice-treegrid__row"))return!1;const T=Qn(i,getComputedStyle(_).direction==="rtl");if(!T)return!1;i.preventDefault();const U=_.dataset.key??"",Ee=kn.get(U),ve=Ee?qn(T,U,Ee.parent,Ee.siblings):null,He=Se.get(U),Yt=ve?Se.get(ve.key):void 0;if(!ve||!He||!Yt||!wn(U)||!ii(U,ve.key,ve.position))return ai(ne("treeDrop.cannotMove","Cannot move {label} there").replace("{label}",He?fn(He):U)),!0;ve.position==="inside"&&!kt(ve.key)&&on(ve.key),X?.(U,ve.key,ve.position),An(U);const _n=ve.position==="before"?ne("treeDrop.movedBefore","{label} moved before {target}"):ve.position==="after"?ne("treeDrop.movedAfter","{label} moved after {target}"):ne("treeDrop.movedInside","{label} moved into {target}");return ai(_n.replace("{label}",fn(He)).replace("{target}",fn(Yt))),!0},Bi=n.useMemo(()=>{const i=new Set(Kt);return ut.map(_=>A&&!he&&i.has(_.field))},[ut,Kt,A,he]),Tn=O===!0?L?bi:bi.slice(0,2):Array.isArray(O)?O.filter(i=>L||i==="expandAll"||i==="collapseAll"):ga,pn=L?De==="column"?"column":"tree":"none",gn=!!y&&!L,tn=ut.length+(pn==="column"||gn?1:0),hi=[["checked",!nt||K===!1?null:Ut&&typeof K=="function"?K(Ut):ui(nt.total.checked,nt.total.total)],["matches",vt?ne("treeGrid.matchCount","{count} matching rows").replace("{count}",String(vt.matched.size)):null]].filter(([,i])=>i!=null&&i!==!1&&i!=="");if(tt==="hidden")return null;const zn=L&&Qe&&Z&&Z.leaves.length>0?e.jsx("input",{type:"checkbox",className:"nice-treegrid__check-input nice-treegrid__select-all",checked:Jn==="checked",ref:i=>{i&&(i.indeterminate=Jn==="indeterminate")},disabled:Ve||Fe,"aria-label":yt?ne("treeGrid.selectAllResults","Select all results"):ne("controls.selectAll","Select all"),onClick:i=>i.stopPropagation(),onChange:Ai}):null,Ui=i=>{const _={expandAll:{icon:"expand",label:ne("treeGrid.expandAll","Expand all")},collapseAll:{icon:"collapse",label:ne("treeGrid.collapseAll","Collapse all")},onlyChecked:{icon:"filter",label:ne("treeGrid.showOnlyChecked","Show selected only")},clearChecked:{icon:"eraser",label:ne("treeGrid.clearChecked","Clear selection")}}[i];return e.jsxs("button",{type:"button",className:`nice-btn nice-btn--sm nice-btn--ghost nice-treegrid__action${i==="onlyChecked"&&k?" nice-treegrid__action--active":""}`,"aria-pressed":i==="onlyChecked"?k:void 0,disabled:Fe||i==="clearChecked"&&(Ve||!nt||nt.total.checked===0),onClick:()=>{i==="expandAll"||i==="collapseAll"?Ei(i==="expandAll"):i==="onlyChecked"?yn(!Zt):Ti()},children:[e.jsx(N.NiceIcon,{name:_.icon,size:14}),e.jsx("span",{children:_.label})]},i)},Gi=i=>{const{node:_,level:T,posInSet:U,setSize:Ee,placeholder:ve}=wt[i],He=_.key;if(ve)return e.jsx("tr",{className:`nice-treegrid__placeholder nice-treegrid__placeholder--${ve}`,"aria-level":T,style:gt?{height:ue}:void 0,children:e.jsxs("td",{colSpan:tn,children:[e.jsx("span",{className:"nice-treegrid__indent",style:{width:(T-1)*20}}),e.jsx("span",{className:"nice-treegrid__toggle nice-treegrid__toggle--leaf","aria-hidden":"true"}),ve==="loading"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-spinner nice-spinner--sm","aria-hidden":"true"}),e.jsx("span",{role:"status",children:ne("treeGrid.loading","Loading…")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"alert",children:ne("treeGrid.loadError","Could not load the rows.")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--sm nice-btn--ghost",onClick:()=>ft(He),children:ne("treeGrid.retry","Retry")})]})]})},`${He}\0${ve}`);const Yt=_.children.length>0||ct(He),_n=Yt&&kt(He),$n=vn&&Yt?Ri.has(He)?"collapse":"expand":null,pi=!!Z?.isCheckable(He),nn=Re&&nt&&Z&&!Z.isLeaf(He)?nt.count(He):null,Wi=fn(_);return e.jsx(ya,{node:_,level:T,posInSet:U,setSize:Ee,rowIndex:i,ariaRowIndex:gt?i+2:void 0,columns:ut,highlight:Bi,query:yt,expandable:Yt,expanded:_n,busy:_n&&Tt.get(He)==="loading",expandLabel:Fi,collapseLabel:Ki,subtreeAction:$n,subtreeLabel:$n==="expand"?ne("treeGrid.expandSubtree","Expand all below"):$n==="collapse"?ne("treeGrid.collapseSubtree","Collapse all below"):"",checkMode:pn,hasCheckbox:pi,checkState:nt?nt.state(He):"unchecked",checkLabel:pi?ne("treeGrid.checkRow","Select {label}").replace("{label}",Wi):"",locked:!!Z?.isLocked(He),countChecked:nn?.checked??0,countTotal:nn?.total??0,countTitle:nn?ui(nn.checked,nn.total):"",selectColumn:gn,selected:y?Ye.has(He):void 0,selectLabel:gn?ne("controls.selectRow","Select row {key}").replace("{key}",He):"",readOnly:Ve,className:typeof oe=="function"?oe(_.data,i):oe,clickable:!Ve&&(!!we||!!te||!!L&&!!y),height:gt?ue:void 0,draggable:Vt&&wn(He),drop:dn.target?.key===He?dn.target.position:null,dragging:dn.dragKey===He,handlers:ti},He)},mi=[];for(let i=Sn;i<Cn;i++)mi.push(Gi(i));const fi=(i,_)=>i>0?e.jsx("tr",{className:"nice-treegrid__spacer","aria-hidden":"true",children:e.jsx("td",{colSpan:tn,style:{height:i*ue}})},_):null;return e.jsxs("div",{id:C,"data-testid":J??Q,className:`nice-treegrid nice-datagrid ${Fe?"nice-treegrid--disabled":""} ${Ve?"nice-treegrid--readonly":""} ${je?"nice-treegrid--error":""} ${gt?"nice-treegrid--virtual":""} ${xt||""}`,style:r,"aria-disabled":Fe||void 0,"aria-busy":it||void 0,"aria-invalid":!!je||void 0,children:[(G||be||Tn.length>0)&&e.jsxs("div",{className:"nice-datagrid__toolbar nice-treegrid__toolbar",children:[G&&e.jsxs("div",{className:"nice-datagrid__search nice-treegrid__search",children:[e.jsx("input",{type:"search",value:Lt,onChange:i=>Xt(i.target.value),onKeyDown:i=>{i.key==="Escape"&&Lt&&(i.preventDefault(),Xt(""))},placeholder:w||ne("controls.search","Search..."),"aria-label":w||ne("controls.search","Search...")}),Lt&&e.jsx("button",{type:"button",className:"nice-treegrid__search-clear",onClick:()=>Xt(""),"aria-label":ne("treeGrid.clearSearch","Clear search"),children:e.jsx(N.NiceIcon,{name:"close",size:12})})]}),Tn.length>0&&e.jsx("div",{className:"nice-treegrid__actions",children:Tn.map(Ui)}),be,hi.length>0&&e.jsx("span",{className:"nice-treegrid__summary",role:"status",children:hi.map(([i,_],T)=>e.jsxs(n.Fragment,{children:[T>0&&" · ",_]},i))})]}),e.jsx("div",{ref:mn,className:"nice-datagrid__table-wrap",style:gt?{height:Ae??480,overflow:"auto"}:void 0,onScroll:gt?jn.onScroll:void 0,children:e.jsxs("table",{ref:Dn,role:"treegrid","aria-label":Y,"aria-labelledby":me,"aria-multiselectable":y||L||void 0,"aria-rowcount":gt?wt.length+1:void 0,className:`nice-table nice-table--${Ue} ${ke?"nice-table--striped":""} ${Ke?"nice-table--compact":""}`,onKeyDownCapture:i=>{if(Te&&(i.key==="ContextMenu"||i.key==="F10"&&i.shiftKey)){const _=i.target.closest("tr.nice-treegrid__row"),T=_?.getBoundingClientRect();if(_?.dataset.key!==void 0&&T&&li(_.dataset.key,T.left+24,T.bottom)){i.preventDefault(),i.stopPropagation();return}}if(!Vi(i)){if(Nn&&i.key==="F2"){const _=i.target.closest("tr.nice-treegrid__row");if(_){i.preventDefault(),ri(_.dataset.key);return}}Oi(i)}},onContextMenu:Te?i=>{const _=i.target.closest("tr.nice-treegrid__row");_?.dataset.key!==void 0&&li(_.dataset.key,i.clientX,i.clientY)&&i.preventDefault()}:void 0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[pn==="column"&&e.jsx("th",{className:"nice-datagrid__checkbox nice-treegrid__th-check",children:zn}),gn&&e.jsx("th",{className:"nice-datagrid__checkbox",style:{width:36}}),ut.map((i,_)=>e.jsxs("th",{style:{width:i.width,minWidth:i.minWidth,textAlign:i.align},className:z&&i.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>z&&i.sortable!==!1&&Ge(i.field),children:[_===0&&pn==="tree"&&zn&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-treegrid__toggle nice-treegrid__toggle--leaf","aria-hidden":"true"}),e.jsx("span",{className:"nice-treegrid__check",children:zn})]}),i.header,z&&i.sortable!==!1&&e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:ee===i.field&&Ie?void 0:.3},children:e.jsx(N.NiceIcon,{name:ee===i.field&&Ie?Ie==="asc"?"sort-asc":"sort-desc":"sort",size:12})})]},i.field))]})}),e.jsx("tbody",{...Vt?dn.handlers:void 0,onDoubleClick:Nn?i=>ri(i.target.closest("tr.nice-treegrid__row")?.dataset.key):void 0,children:it?e.jsx("tr",{children:e.jsx("td",{colSpan:tn,className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):je?e.jsx("tr",{children:e.jsx("td",{colSpan:tn,className:"nice-datagrid__empty nice-treegrid__error",role:"alert",children:je})}):wt.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:tn,className:"nice-datagrid__empty",children:yt?ne("controls.noResults","No results"):W||ne("controls.noData","No data available")})}):e.jsxs(e.Fragment,{children:[fi(Sn,"top"),mi,fi(wt.length-Cn,"bottom")]})})]})}),qt&&typeof document<"u"&&qi.createPortal(e.jsx("div",{ref:Mn,className:"nice-treegrid__menu",role:"menu","aria-label":ne("treeGrid.rowMenu","Row actions"),style:{position:"fixed",left:qt.x,top:qt.y},children:qt.items.map(i=>i.divider?e.jsx("div",{className:"nice-treegrid__menu-divider",role:"separator"},i.id):e.jsxs("button",{type:"button",role:"menuitem",className:`nice-treegrid__menu-item${i.danger?" nice-treegrid__menu-item--danger":""}`,disabled:i.disabled,onClick:()=>{In(),i.onSelect?.()},children:[i.icon&&e.jsx(N.NiceIcon,{name:i.icon,size:14}),i.label]},i.id))}),Li?.portalTarget??document.body),un&&e.jsx(Kn.NiceRowEditDialog,{title:jt,items:mt??Kn.rowEditFormItems(t,s),data:un.data,columns:Ne,formProps:et,onClose:()=>hn(null),onFieldChange:(i,_)=>hn(T=>T&&{...T,data:{...T.data,[i]:_}}),onSubmit:i=>{st?.(un.key,{...un.data,...i}),hn(null)}}),Vt&&e.jsx("span",{className:"nice-sr-only",role:"status","aria-live":"polite",children:zi}),qt&&e.jsx("div",{className:"nice-treegrid__menu-backdrop","aria-hidden":"true",onMouseDown:In})]})}const ka=[],wa=[],Na=[];function ja(t,a,s){const c=[],l=(o,g)=>{o.forEach(f=>{c.push({item:f,parent:f[s]??g}),Array.isArray(f.children)&&f.children.length>0&&l(f.children,f[a])})};l(t,null);const d=new Map,u=[];return c.forEach(({item:o})=>{const g={...o,children:[]};d.set(String(g[a]),g)}),c.forEach(({item:o,parent:g})=>{g!=null&&d.has(String(g))?d.get(String(g)).children.push(d.get(String(o[a]))):u.push(d.get(String(o[a])))}),u}function Sa({columns:t=ka,data:a=wa,keyField:s="key",parentKeyField:c="parentKey",expandedKeys:l,onExpandedChange:d,selectedKeys:u=Na,onSelectionChange:o,selectable:g,sortable:f,loading:S,emptyText:E,className:$,style:z,accessMode:b,id:D,"data-testid":p}){const I=N.useNiceAccessMode(b,D)==="hidden",{t:x}=N.useNiceTranslation(),[L,M]=n.useState([]),F=l??L,[H,xe]=n.useState(u),se=o?u:H,_e=n.useMemo(()=>ja(a,s,c),[a,s,c]),De=n.useMemo(()=>t.filter(j=>!j.hidden),[t]),[te,Re]=n.useState(null),K=n.useCallback(j=>{Re(he=>he?.field===j?he.dir==="asc"?{field:j,dir:"desc"}:null:{field:j,dir:"asc"})},[]),Qe=n.useCallback(j=>te?[...j].sort((fe,ye)=>{const A=fe[te.field]??"",oe=ye[te.field]??"",pe=typeof A=="number"?A-oe:String(A).localeCompare(String(oe));return te.dir==="desc"?-pe:pe}).map(fe=>fe.children&&fe.children.length?{...fe,children:Qe(fe.children)}:fe):j,[te]),ze=n.useMemo(()=>Qe(_e),[_e,Qe]),$e=n.useCallback(j=>{const he=F.includes(j)?F.filter(fe=>fe!==j):[...F,j];d?d(he):M(he)},[F,d]),ce=n.useMemo(()=>Un(_e,{getKey:j=>String(j[s]),getChildren:j=>j.children}),[_e,s]),O=n.useMemo(()=>Gn(ce,se),[ce,se]),G=n.useMemo(()=>bn(ce,O.leaves),[ce,O]),w=n.useCallback(j=>{const he=Wn(ce,O.leaves,j),fe=an(ce,he,"all",O.unknown);o?o(fe):xe(fe)},[ce,O,o]),v=De[0]?.field;let de=0;const re=(j,he)=>{const fe=String(j[s]),ye=de++,A=!!(j.children&&j.children.length>0),oe=F.includes(fe),pe=G.state(fe),Be=pe==="checked",ue=pe==="indeterminate",Ae=v!=null?String(j[v]??fe):fe;return e.jsxs(n.Fragment,{children:[e.jsxs("tr",{className:Be?"nice-treelist__row--selected":"",children:[g&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:Be,ref:ke=>{ke&&(ke.indeterminate=ue)},onChange:()=>w(fe),"aria-label":x("controls.selectRow","Select row {key}").replace("{key}",Ae)})}),De.map((ke,Ke)=>e.jsxs("td",{style:{textAlign:ke.align},children:[Ke===0&&e.jsx("span",{style:{display:"inline-block",width:he*20}}),Ke===0&&e.jsx("span",{role:A?"button":void 0,tabIndex:A?0:void 0,"aria-expanded":A?oe:void 0,"aria-label":A?x(oe?"controls.collapse":"controls.expand",oe?"Collapse":"Expand"):void 0,onKeyDown:A?N.clickOnActivationKey:void 0,className:"nice-treelist__toggle",onClick:()=>A&&$e(fe),style:{cursor:A?"pointer":"default",width:20,display:"inline-block"},children:A?e.jsx(N.NiceIcon,{name:oe?"chevron-down":"chevron-right",size:12}):""}),ke.render?ke.render(j[ke.field],j,ye):String(j[ke.field]??"")]},ke.field))]}),A&&oe&&j.children.map(ke=>re(ke,he+1))]},fe)};return I?null:e.jsx("div",{className:`nice-treelist ${$||""}`,style:z,"data-testid":p,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[g&&e.jsx("th",{className:"nice-treelist__checkbox"}),De.map(j=>{const he=!!f&&!!j.sortable;return e.jsxs("th",{style:{width:j.width,minWidth:j.minWidth,textAlign:j.align},className:he?"nice-treelist__th--sortable":void 0,onClick:()=>he&&K(j.field),scope:"col","aria-sort":he?te?.field===j.field?te.dir==="asc"?"ascending":"descending":"none":void 0,children:[j.header,he&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(N.NiceIcon,{name:te?.field===j.field?te.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},j.field)})]})}),e.jsx("tbody",{children:S?e.jsx("tr",{children:e.jsx("td",{colSpan:De.length+(g?1:0),className:"nice-treelist__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):_e.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:De.length+(g?1:0),className:"nice-treelist__empty",children:E||x("controls.noData","No data available")})}):ze.map(j=>re(j,0))})]})})}function Ci(t,a=[]){for(const s of t)s.expanded&&a.push(s.key),s.children&&Ci(s.children,a);return a}const Fn=[],Ca=[],Da=({nodes:t=Fn,header:a,selectedKeys:s=Ca,expandedKeys:c,onSelectionChange:l,onExpandedChange:d,selectionMode:u="none",showCheckboxes:o,searchable:g,searchPlaceholder:f,onNodeClick:S,renderNode:E,showLines:$,loading:z,className:b,style:D,accessMode:p,id:y,draggable:I,onNodeDrop:x,canDrop:L,onLoadChildren:M,contextMenuItems:F,onContextMenuAction:H,editable:xe,onNodeEdit:se,maxDepth:_e,"data-testid":De})=>{const Re=N.useNiceAccessMode(p,y)==="hidden",{t:K}=N.useNiceTranslation(),[Qe,ze]=n.useState(()=>Ci(t)),[$e,ce]=n.useState(""),[O,G]=n.useState(new Set),[w,v]=n.useState(new Map),[de,re]=n.useState(null),[j,he]=n.useState(null),[fe,ye]=n.useState(""),A=n.useRef(null),oe=c??Qe,pe=n.useRef(oe);pe.current=oe;const Be=n.useMemo(()=>new Set(s),[s]),ue=typeof _e=="number"?Math.min(10,Math.max(1,_e)):1/0,Ae=!!o&&u==="multiple",ke=n.useMemo(()=>Ae?Un(t,{getKey:r=>r.key,getChildren:(r,C)=>C+1>=ue?null:w.get(r.key)??r.children,isDisabled:r=>!!r.disabled},{inheritDisabled:!1}):null,[Ae,t,w,ue]),Ke=n.useMemo(()=>ke?Gn(ke,s):null,[ke,s]),Ue=n.useMemo(()=>ke&&Ke?bn(ke,Ke.leaves):null,[ke,Ke]),it=n.useCallback(async(r,C)=>{const Q=pe.current,J=!Q.includes(r),Le=J?[...Q,r]:Q.filter(Y=>Y!==r);if(pe.current=Le,d?d(Le):ze(Le),J&&M&&!C.children?.length&&C.leaf!==!0&&!w.has(r)){G(me=>new Set(me).add(r));const Y=await M(C);v(me=>new Map(me).set(r,Y)),G(me=>{const ne=new Set(me);return ne.delete(r),ne})}},[d,M,w]),at=n.useCallback(r=>{if(l){if(u==="single")l(s.includes(r)?[]:[r]);else if(u==="multiple")if(ke&&Ke){const C=Wn(ke,Ke.leaves,r);C!==Ke.leaves&&l(an(ke,C,"all",Ke.unknown))}else l(s.includes(r)?s.filter(C=>C!==r):[...s,r])}},[s,u,l,ke,Ke]),rt=n.useCallback(r=>{if(!$e)return!0;const C=$e.toLowerCase();return r.text.toLowerCase().includes(C)?!0:(w.get(r.key)??r.children)?.some(J=>rt(J))??!1},[$e,w]),je=n.useCallback((r,C)=>{F?.length&&(r.preventDefault(),re({x:r.clientX,y:r.clientY,node:C}))},[F]),W=n.useCallback(()=>{j&&se&&se(j,fe),he(null)},[j,fe,se]),be=n.useRef(null),we=(r,C=t)=>{for(const Q of C){const J=Q.key===r?Q:we(r,w.get(Q.key)??Q.children??Fn);if(J)return J}},Te=!!I&&!!x,Oe=n.useMemo(()=>{const r=new Map;if(!Te)return r;const C=(Q,J)=>{const Le=Q.map(Y=>Y.key);Q.forEach(Y=>{r.set(Y.key,{parent:J,siblings:Le}),C(w.get(Y.key)??Y.children??Fn,Y.key)})};return C(t,null),r},[Te,t,w]),le=(r,C)=>{const Q=new Set;for(let J=r;J!=null&&!Q.has(J);J=Oe.get(J)?.parent){if(J===C)return!0;Q.add(J)}return!1},X=(r,C,Q)=>!le(C,r)&&(Q!=="inside"||we(C)?.leaf!==!0)&&(L?L(r,C,Q):!0),bt=Yn({enabled:Te,rowSelector:'[role="treeitem"]',rectOf:r=>[...r.children].find(C=>C.classList.contains("nice-tree__row"))??r,canDrag:r=>!we(r)?.disabled,canNest:r=>we(r)?.leaf!==!0,isWithin:le,canDrop:X,onDrop:(r,C,Q)=>x?.(r,C,Q),onHoverOpen:r=>{const C=we(r);C&&!pe.current.includes(r)&&it(r,C)}}),[mt,Ne]=n.useState(""),jt=r=>{const C=r.target.closest?.('[role="treeitem"]'),Q=Te&&C&&j===null?Qn(r,getComputedStyle(C).direction==="rtl"):null;if(!C||!Q)return;r.preventDefault(),r.stopPropagation();const J=C.dataset.key??"",Le=Oe.get(J),Y=Le?qn(Q,J,Le.parent,Le.siblings):null,me=we(J),ne=Y?we(Y.key):void 0;if(!Y||!me||!ne||me.disabled||!X(J,Y.key,Y.position)){Ne(K("treeDrop.cannotMove","Cannot move {label} there").replace("{label}",me?.text??J));return}Y.position==="inside"&&!pe.current.includes(Y.key)&&it(Y.key,ne),x?.(J,Y.key,Y.position),et.current=J;const tt=Y.position==="before"?K("treeDrop.movedBefore","{label} moved before {target}"):Y.position==="after"?K("treeDrop.movedAfter","{label} moved after {target}"):K("treeDrop.movedInside","{label} moved into {target}");Ne(tt.replace("{label}",me.text).replace("{target}",ne.text))};N.useTreeFocus(be,{rowSelector:".nice-tree__row",onToggle:(r,C)=>{const Q=r.dataset.key===void 0?void 0:we(r.dataset.key);Q&&pe.current.includes(Q.key)!==C&&it(Q.key,Q)}});const et=n.useRef(null);n.useEffect(()=>{if(j!==null||et.current===null)return;const r=et.current;et.current=null,[...be.current?.querySelectorAll('[role="treeitem"]')??[]].find(C=>C.dataset.key===r)?.focus()},[j]);const st=n.useRef(null);N.useRovingFocus(st,{orientation:"vertical",wrap:!0,typeahead:!0}),N.useOverlayFocus(st,{open:!!de,modal:!1,onClose:()=>re(null)});const xt=(r,C)=>{if($e&&!rt(r))return null;const Q=C+1>=ue,J=Q?void 0:w.get(r.key)??r.children,Le=!Q&&(J&&J.length>0||r.leaf!==!0&&M&&!J?.length),Y=oe.includes(r.key),me=Ue?Ue.state(r.key):Be.has(r.key)?"checked":"unchecked",ne=Ue?me==="checked":Be.has(r.key),tt=!!r.disabled||!!ke?.isLocked(r.key),Fe=O.has(r.key),Ve=Math.min(C+1,10),St={paddingLeft:C*20+4,"--nice-row-bg":`var(--nice-tree-level-${Ve}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${Ve}-text, inherit)`,"--nice-row-border":`var(--nice-tree-level-${Ve}-border, transparent)`,"--nice-row-hover-bg":`var(--nice-tree-level-${Ve}-hover-bg, var(--nice-hover-bg, color-mix(in srgb, var(--nice-text-primary) 6%, transparent)))`,"--nice-row-active-bg":`var(--nice-tree-level-${Ve}-active-bg, color-mix(in srgb, var(--nice-color-primary) 14%, transparent))`};return e.jsxs("li",{className:"nice-tree__node",role:"treeitem","aria-label":r.text,"aria-expanded":Le?Y:void 0,"aria-selected":u!=="none"?ne:void 0,"aria-disabled":r.disabled||void 0,"data-key":r.key,"data-nice-depth":Ve,onKeyDown:xe&&!r.disabled?Me=>{Me.key==="F2"&&Me.target===Me.currentTarget&&(Me.preventDefault(),he(r.key),ye(r.text))}:void 0,draggable:Te&&!r.disabled||void 0,children:[e.jsxs("div",{role:"presentation",className:`nice-tree__row ${ne?"nice-tree__row--selected":""} ${r.disabled?"nice-tree__row--disabled":""} ${bt.dragKey===r.key?"nice-tree__row--dragging":""} ${bt.target?.key===r.key?`nice-tree__row--drop-${bt.target.position}`:""}`,style:St,onClick:()=>{r.disabled||(at(r.key),S?.(r))},onContextMenu:Me=>je(Me,r),onDoubleClick:xe&&!r.disabled?()=>{he(r.key),ye(r.text)}:void 0,children:[e.jsx("span",{role:"presentation",className:`nice-tree__toggle ${Le?Y?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:Me=>{Me.stopPropagation(),Le&&it(r.key,r)},children:Fe?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):Le?Y?e.jsx(N.NiceIcon,{name:"chevron-down",size:12}):e.jsx(N.NiceIcon,{name:"chevron-right",size:12}):""}),o&&u!=="none"&&e.jsx("input",{type:"checkbox",checked:me==="checked",ref:Me=>{Me&&(Me.indeterminate=me==="indeterminate")},onChange:()=>at(r.key),onClick:Me=>Me.stopPropagation(),disabled:tt,tabIndex:-1,"aria-label":r.text,className:"nice-tree__checkbox"}),j===r.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:fe,onChange:Me=>ye(Me.target.value),onBlur:W,onKeyDown:Me=>{Me.key==="Enter"&&(et.current=r.key,W()),Me.key==="Escape"&&(Me.preventDefault(),et.current=r.key,he(null))},autoFocus:!0,onClick:Me=>Me.stopPropagation()}):E?E(r):e.jsxs(e.Fragment,{children:[r.icon&&e.jsx("span",{className:"nice-tree__icon",children:r.icon}),e.jsx("span",{className:"nice-tree__text",children:r.text})]})]}),J&&J.length>0&&Y&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:J.map(Me=>xt(Me,C+1))})]},r.key)};return Re?null:e.jsxs("div",{role:"presentation",className:`nice-tree ${$?"nice-tree--lines":""} ${b||""}`,style:D,ref:A,"data-testid":De,onClick:()=>re(null),children:[a!=null&&a!==!1&&e.jsx("div",{className:"nice-tree__header",children:a}),g&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:$e,onChange:r=>ce(r.target.value),placeholder:f||K("controls.search","Search..."),"aria-label":f||K("controls.search","Search tree")})}),z?e.jsx("div",{className:"nice-tree__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):e.jsx("ul",{ref:be,className:"nice-tree__root",role:"tree","aria-multiselectable":u==="multiple"||void 0,onKeyDownCapture:Te?jt:void 0,...Te?bt.handlers:void 0,children:t.map(r=>xt(r,0))}),Te&&e.jsx("span",{className:"nice-sr-only",role:"status","aria-live":"polite",children:mt}),de&&F&&e.jsx("div",{ref:st,className:"nice-tree__context-menu",role:"menu","aria-label":de.node.text,style:{position:"fixed",top:de.y,left:de.x,zIndex:9999},children:F.map(r=>e.jsxs("button",{type:"button",role:"menuitem",disabled:r.disabled,className:`nice-tree__context-item ${r.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{r.disabled||(H?.(r.key,de.node),re(null))},children:[r.icon&&e.jsx("span",{children:r.icon}),r.label]},r.key))})]})},Ma=[],Ia=({items:t=Ma,selectedKeys:a=[],onSelectionChange:s,selectionMode:c="none",searchable:l,searchPlaceholder:d,grouped:u,groupField:o="group",reorderable:g,onReorder:f,onItemClick:S,renderItem:E,showCheckboxes:$,loading:z,emptyText:b,size:D="md",header:p,disabled:y,readOnly:I,error:x,bordered:L=!0,swipeActions:M,className:F,style:H,accessMode:xe,id:se,"data-testid":_e})=>{const te=N.useNiceAccessMode(xe,se)==="hidden",{t:Re}=N.useNiceTranslation(),[K,Qe]=n.useState(""),[ze,$e]=n.useState(null),[ce,O]=n.useState(null),G=n.useRef(null),w=n.useMemo(()=>{if(!K)return t;const A=K.toLowerCase();return t.filter(oe=>oe.text.toLowerCase().includes(A))},[t,K]),v=n.useMemo(()=>{if(!u)return null;const A=new Map;return w.forEach(oe=>{const pe=String(oe[o]??"");A.has(pe)||A.set(pe,[]),A.get(pe).push(oe)}),A},[w,u,o]),de=n.useCallback(A=>{s&&(c==="single"?s(a.includes(A)?[]:[A]):c==="multiple"&&s(a.includes(A)?a.filter(oe=>oe!==A):[...a,A]))},[a,c,s]),re=n.useCallback(A=>{ze!==null&&ze!==A&&f&&f(ze,A),$e(null)},[ze,f]),j=n.useRef(null),he=n.useCallback(A=>{j.current=A},[]);N.useRovingFocus(j,{orientation:"vertical",itemSelector:".nice-list__item",typeahead:!0,pageSize:10});const fe=A=>{!A.disabled&&!y&&!I&&(de(A.key),S?.(A))},ye=(A,oe)=>{const pe=a.includes(A.key),Be=ce===A.key;return e.jsxs("li",{className:`nice-list__item ${pe?"nice-list__item--selected":""} ${A.disabled?"nice-list__item--disabled":""} ${Be?"nice-list__item--swiped":""}`,onClick:()=>fe(A),onKeyDown:ue=>{ue.target===ue.currentTarget&&(ue.key==="Enter"||ue.key===" ")&&(ue.preventDefault(),fe(A))},draggable:g&&!y&&!I,onDragStart:()=>$e(oe),onDragOver:ue=>ue.preventDefault(),onDrop:()=>re(oe),onTouchStart:M?.length?ue=>{G.current={x:ue.touches[0].clientX,key:A.key}}:void 0,onTouchEnd:M?.length?ue=>{if(!G.current)return;const Ae=ue.changedTouches[0].clientX-G.current.x;Ae<-50&&G.current.key===A.key?O(A.key):Ae>50&&O(null),G.current=null}:void 0,role:"option","aria-selected":c!=="none"?pe:void 0,"aria-disabled":A.disabled||void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[$&&c!=="none"&&e.jsx("input",{type:"checkbox",checked:pe,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),E?E(A):e.jsxs(e.Fragment,{children:[A.icon&&e.jsx("span",{className:"nice-list__icon",children:A.icon}),e.jsx("span",{className:"nice-list__text",children:A.text}),A.badge&&e.jsx("span",{className:"nice-list__badge",children:A.badge})]})]}),M&&Be&&e.jsx("div",{className:"nice-list__swipe-actions",children:M.map(ue=>e.jsx("button",{className:"nice-list__swipe-btn",style:ue.color?{backgroundColor:ue.color}:void 0,onClick:Ae=>{Ae.stopPropagation(),ue.onClick(A),O(null)},children:ue.label},ue.key))})]},A.key)};return te?null:e.jsxs("div",{className:`nice-list nice-list--${D} ${L?"nice-list--bordered":""} ${y?"nice-list--disabled":""} ${I?"nice-list--readonly":""} ${x?"nice-list--error":""} ${F||""}`,style:H,"data-testid":_e,"aria-disabled":y||void 0,"aria-busy":z||void 0,children:[p&&e.jsx("div",{className:"nice-list__header",children:p}),l&&!z&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:K,onChange:A=>Qe(A.target.value),placeholder:d||Re("controls.search","Search...")})}),z?e.jsx("div",{className:"nice-list__loading",role:"status","aria-live":"polite",children:e.jsx("div",{className:`nice-spinner nice-spinner--${D}`})}):x?e.jsx("div",{className:"nice-list__error",role:"alert",children:x}):w.length===0?e.jsx("div",{className:"nice-list__empty",children:b||Re("controls.noData","No data available")}):e.jsx("div",{role:"listbox",ref:he,"aria-multiselectable":c==="multiple"||void 0,children:v?Array.from(v.entries()).map(([A,oe])=>e.jsxs("div",{className:"nice-list__group",role:"group","aria-label":A,children:[e.jsx("div",{className:"nice-list__group-header","aria-hidden":"true",children:A}),e.jsx("ul",{className:"nice-list__items",role:"presentation",children:oe.map((pe,Be)=>ye(pe,Be))})]},A)):e.jsx("ul",{className:"nice-list__items",role:"presentation",children:w.map((A,oe)=>ye(A,oe))})})]})},Ea=[],Ra=[];function Aa({columns:t=Ea,data:a=Ra,striped:s,compact:c,size:l="md",emptyText:d,className:u,style:o,accessMode:g,id:f,displayStyle:S}){const{t:E}=N.useNiceTranslation(),$=N.normalizeSize(l),b=N.useNiceAccessMode(g,f)==="hidden",D=N.useComponentDisplayStyle("table",S),p=N.useComponentDisplayClass("table",S),[y,I]=n.useState(null),x=n.useMemo(()=>y?[...a].sort((M,F)=>{const H=M[y.field]??"",xe=F[y.field]??"",se=typeof H=="number"?H-xe:String(H).localeCompare(String(xe));return y.dir==="desc"?-se:se}):a,[a,y]),L=M=>{I(F=>F?.field===M?F.dir==="asc"?{field:M,dir:"desc"}:null:{field:M,dir:"asc"})};return b?null:e.jsx("div",{className:`nice-table-wrapper ${u||""}`,style:{...D,...o},children:e.jsxs("table",{className:`nice-table nice-table--ds-${p} nice-table--${$} ${s?"nice-table--striped":""} ${c?"nice-table--compact":""}`,"aria-rowcount":x.length,"aria-colcount":t.length,children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(M=>{const F=M.sortable?y?.field===M.field?y.dir==="asc"?"ascending":"descending":"none":void 0;return e.jsxs("th",{style:{width:M.width,textAlign:M.align},className:M.sortable?"th--sortable":void 0,onClick:()=>M.sortable&&L(M.field),scope:"col","aria-sort":F,children:[M.header,M.sortable&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(N.NiceIcon,{name:y?.field===M.field?y.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},M.field)})})}),e.jsx("tbody",{children:x.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"nice-table__empty",children:d||E("table.noData","No data")})}):x.map((M,F)=>e.jsx("tr",{children:t.map(H=>e.jsx("td",{style:{textAlign:H.align},children:H.render?H.render(M[H.field],M):String(M[H.field]??"")},H.field))},F))})]})})}const Ta=[];function za({items:t=Ta,tileWidth:a=180,tileHeight:s=180,direction:c="horizontal",renderTile:l,onTileClick:d,loading:u,emptyText:o,className:g,style:f,"data-testid":S}){const{t:E}=N.useNiceTranslation();return e.jsx("div",{className:`nice-tileview nice-tileview--${c} ${g||""}`,style:f,"data-testid":S,children:u?e.jsx("div",{className:"nice-tileview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):t.length===0?e.jsx("div",{className:"nice-tileview__empty",children:o||E("controls.noData","No data available")}):e.jsx("div",{className:"nice-tileview__container",style:{display:"flex",flexWrap:"wrap",gap:8,flexDirection:c==="vertical"?"column":"row"},children:t.map($=>e.jsx("div",{role:d?"button":void 0,tabIndex:d?0:void 0,onKeyDown:d?N.clickOnActivationKey:void 0,className:"nice-tileview__tile",style:{width:a,height:s,cursor:d?"pointer":void 0},onClick:()=>d?.($),children:l?l($):e.jsxs(e.Fragment,{children:[$.image&&e.jsx("img",{src:$.image,alt:$.text||"",className:"nice-tileview__image"}),$.text&&e.jsx("div",{className:"nice-tileview__label",children:$.text})]})},$.key))})})}const $a=[],La=[];function Pa({open:t}){return e.jsx(N.NiceIcon,{name:"chevron-down",size:14,style:{transition:"transform 160ms ease",transform:t?"rotate(0deg)":"rotate(-90deg)"}})}function Oa(){return e.jsx(N.NiceIcon,{name:"plus",size:14})}const Fa=[{target:".nice-kanban",titleKey:"tutorial.kanbanBoard.intro.title",title:"Kanban board",contentKey:"tutorial.kanbanBoard.intro.content",content:'Drag cards between columns to change their status, add cards with the "+" button, and click a card to edit its details.',placement:"auto"}],Ka=Object.assign(n.forwardRef(({columns:t=$a,cards:a=La,onCardMove:s,onCardClick:c,renderCard:l,onAddCard:d,disabled:u=!1,size:o="md",collapsible:g=!1,collapseDirection:f="vertical",layoutMode:S="scroll",viewMode:E,onViewModeChange:$,collapsedColumns:z,onCollapsedColumnsChange:b,formItems:D,formColumns:p=1,formProps:y,editCardTitle:I,newCardTitle:x,onCardEdit:L,onCardCreate:M,onCardDelete:F,tutorial:H,cookies:xe=!1,localStorage:se=!0,sessionStorage:_e=!1,storageMode:De,storageKey:te,className:Re,style:K,id:Qe,...ze},$e)=>{const{t:ce}=N.useNiceTranslation(),[O,G]=n.useState(null),[w,v]=n.useState(null),[de,re]=n.useState(null),j=!!D&&(!!L||!!M),he=n.useCallback(W=>{if(j&&L){re({key:W.key,data:{...W},column:W.column});return}c?.(W)},[j,c,L]),fe=j&&!!L||!!c,ye=n.useCallback(W=>{if(j&&M){re({key:null,data:{title:"",description:""},column:W});return}d?.(W)},[j,d,M]),A=Xi.useStorageAdapter(te??"nice-kanban"),[oe,pe]=n.useState(()=>A.get("state")??{collapsedColumns:[],viewMode:"default"}),Be=n.useMemo(()=>z??oe.collapsedColumns??[],[z,oe.collapsedColumns]),ue=E??oe.viewMode??"default",Ae=n.useCallback(W=>{pe(be=>{const we={...be,...W};return A.set("state",we),we})},[A]),ke=n.useCallback(W=>{const be=Be.includes(W)?Be.filter(we=>we!==W):[...Be,W];b?b(be):Ae({collapsedColumns:be})},[Be,b,Ae]);n.useCallback(W=>{$?$(W):Ae({viewMode:W})},[$,Ae]);const Ke=n.useCallback(W=>a.filter(be=>be.column===W).sort((be,we)=>(be.order??0)-(we.order??0)),[a]),Ue=n.useCallback((W,be)=>{u||(W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("text/plain",String(be.key)),G({cardKey:be.key,fromColumn:be.column}))},[u]),it=n.useCallback((W,be)=>{W.preventDefault(),W.dataTransfer.dropEffect="move",v({column:be})},[]),at=n.useCallback(()=>{v(null)},[]),rt=n.useCallback((W,be)=>{if(W.preventDefault(),v(null),!O||u)return;const we=Ke(be);s?.(O.cardKey,be,we.length),G(null)},[O,u,Ke,s]),je=n.useCallback(()=>{G(null),v(null)},[]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:$e,id:Qe,className:`nice-kanban nice-kanban--${o} nice-kanban--${ue} nice-kanban--layout-${S} ${u?"nice-kanban--disabled":""} ${Re||""}`,style:{position:"relative",...K},...ze,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(N.NiceTutorialButton,{steps:N.resolveTutorial(H,Fa)})}),t.map(W=>{const be=Ke(W.key),we=w?.column===W.key,Te=W.limit!=null&&be.length>=W.limit,Oe=g&&Be.includes(W.key);return e.jsxs("div",{className:`nice-kanban__column ${we?"nice-kanban__column--dragover":""} ${Oe?`nice-kanban__column--collapsed nice-kanban__column--collapse-${f}`:""}`,onDragOver:le=>!Oe&&it(le,W.key),onDragLeave:at,onDrop:le=>!Oe&&rt(le,W.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:W.color?{borderTopColor:W.color}:void 0,onClick:g?()=>ke(W.key):void 0,role:g?"button":void 0,tabIndex:g?0:void 0,onKeyDown:g?le=>{(le.key==="Enter"||le.key===" ")&&ke(W.key)}:void 0,children:[g&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:e.jsx(Pa,{open:!Oe})}),e.jsx("span",{className:"nice-kanban__column-title",children:W.title}),e.jsx("span",{className:"nice-kanban__column-count",children:W.limit!=null?e.jsxs("span",{className:"nice-kanban__count-frac",children:[e.jsx("span",{className:"nice-kanban__count-num",children:be.length}),e.jsx("span",{className:"nice-kanban__count-slash",children:"/"}),e.jsx("span",{className:"nice-kanban__count-den",children:W.limit})]}):be.length})]}),!Oe&&e.jsxs("div",{className:"nice-kanban__column-body",children:[be.map(le=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${ue} ${O?.cardKey===le.key?"nice-kanban__card--dragging":""}`,draggable:!u,onDragStart:X=>Ue(X,le),onDragEnd:je,onClick:()=>he(le),role:fe?"button":"article",tabIndex:fe?0:void 0,onKeyDown:fe?N.clickOnActivationKey:void 0,children:l?l(le):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:le.title}),ue!=="compact"&&le.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:le.description})]})},le.key)),be.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:ce("kanban.empty","No cards")})]}),!Oe&&(d||j&&M)&&!Te&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>ye(W.key),disabled:u,children:[e.jsx(Oa,{})," ",ce("kanban.addCard","Add card")]})]},W.key)})]}),j&&de&&e.jsxs(Hi.NiceModal,{open:!0,onClose:()=>re(null),title:de.key==null?x||ce("kanban.newCard","New card"):I||ce("kanban.editCard","Edit card"),children:[e.jsx(Yi.NiceForm,{items:D,data:de.data,columns:p,...y,onFieldChange:(W,be)=>re(we=>we&&{...we,data:{...we.data,[W]:be}})}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,flexWrap:"wrap"},children:[de.key!=null&&F&&e.jsx(qe.NiceButton,{type:"button",size:"sm",variant:"error",style:{marginRight:"auto"},onClick:()=>{F(de.key),re(null)},children:ce("controls.delete","Delete")}),e.jsx(qe.NiceButton,{type:"button",size:"sm",variant:"secondary",onClick:()=>re(null),children:ce("controls.cancel","Cancel")}),e.jsx(qe.NiceButton,{type:"button",size:"sm",variant:"primary",onClick:()=>{if(de.key==null){const W={key:`card-${Date.now()}`,title:"",column:de.column,...de.data};M?.(W)}else L?.(de.key,{...de.data,key:de.key,column:de.column});re(null)},children:ce("controls.save","Save")})]})]})]})}),{displayName:"NiceKanbanBoard"}),Va=[];function Et(...t){return t.filter(Boolean).map(a=>typeof a=="object"?Object.entries(a).filter(([,s])=>s).map(([s])=>s).join(" "):a).join(" ")}const Ba=50,Ua=[10,25,50,100,200],Ga=40,Wa={compact:32,normal:Ga,comfortable:48},Qa=10,qa=768,Ya=500,Ha=10;function Nt(t,a){return a.split(".").reduce((s,c)=>s?.[c],t)}function Di(t){return t.width==="auto"?{flex:"1 1 0",minWidth:t.minWidth??80,maxWidth:t.maxWidth}:{width:t.width||150,minWidth:t.minWidth,maxWidth:t.maxWidth}}function rn(t,a,s="pl-PL"){if(t==null)return"—";switch(a.type){case"number":return new Intl.NumberFormat(s,{minimumFractionDigits:a.format?.includes(".")?a.format.split(".")[1].length:0}).format(t);case"currency":return new Intl.NumberFormat(s,{style:"currency",currency:a.currencyCode||"PLN"}).format(t);case"percent":return new Intl.NumberFormat(s,{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2}).format(t/100);case"date":return new Intl.DateTimeFormat(s,{dateStyle:"short"}).format(new Date(t));case"datetime":return new Intl.DateTimeFormat(s,{dateStyle:"short",timeStyle:"short"}).format(new Date(t));case"boolean":return t?e.jsx(N.NiceIcon,{name:"check",size:14}):e.jsx(N.NiceIcon,{name:"close",size:14});case"enum":return a.enumOptions?.find(l=>l.value===t)?.label||String(t);default:return String(t)}}function Xa(t,a,s,c){const[l,d]=n.useState(0),{startIndex:u,endIndex:o,totalHeight:g,offsetY:f}=n.useMemo(()=>{const $=t.length*s,z=Math.ceil(a/s),b=Math.max(0,Math.floor(l/s)-c),D=Math.min(t.length,Math.ceil(l/s)+z+c),p=b*s;return{startIndex:b,endIndex:D,totalHeight:$,offsetY:p}},[t.length,a,s,l,c]),S=n.useMemo(()=>t.slice(u,o),[t,u,o]),E=n.useCallback($=>{d($.currentTarget.scrollTop)},[]);return{visibleData:S,totalHeight:g,offsetY:f,handleScroll:E,startIndex:u}}function Za(t,a){const[s,c]=n.useState(()=>{if(t&&typeof window<"u"){const d=localStorage.getItem(`nice-module-grid-${t}`);if(d)return JSON.parse(d)}return a||{}}),l=n.useCallback(d=>{c(u=>{const o={...u,...d};return t&&typeof window<"u"&&localStorage.setItem(`nice-module-grid-${t}`,JSON.stringify(o)),o})},[t]);return[s,l]}function Ja(t){const[a,s]=n.useState(typeof window<"u"&&window.innerWidth<t);return n.useEffect(()=>{if(typeof window>"u")return;const c=()=>s(window.innerWidth<t);return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[t]),a}function er({column:t,sort:a,onSort:s,onResize:c,resizable:l,t:d}){const u=n.useRef(null),[o,g]=n.useState(!1),f=n.useCallback($=>{if(!l||!c)return;$.preventDefault(),g(!0);const z=$.clientX,b=t.width||150,D=y=>{const I=y.clientX-z,x=Math.max(t.minWidth||50,b+I);c(t.field,Math.min(x,t.maxWidth||1/0))},p=()=>{g(!1),document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",D),document.addEventListener("mouseup",p)},[t,l,c]),S=a?.direction,E=S==="asc"?e.jsx(N.NiceIcon,{name:"sort-asc",size:12}):S==="desc"?e.jsx(N.NiceIcon,{name:"sort-desc",size:12}):null;return e.jsxs("div",{className:Et("nice-module-grid__header-cell",t.sortable&&"nice-module-grid__header-cell--sortable",o&&"nice-module-grid__header-cell--resizing"),style:{...Di(t),textAlign:t.align},onClick:()=>t.sortable&&s?.(t.field),role:"columnheader","aria-sort":S==="asc"?"ascending":S==="desc"?"descending":"none",title:t.headerTooltip,children:[e.jsx("span",{className:"nice-module-grid__header-text",children:t.header}),E&&e.jsx("span",{className:"nice-module-grid__sort-indicator",children:E}),l&&e.jsx("div",{ref:u,className:"nice-module-grid__resize-handle",onMouseDown:f})]})}function tr({column:t,row:a,rowIndex:s,value:c,locale:l="pl-PL",onClick:d}){const{t:u}=N.useNiceTranslation(),o=N.useAccessibleClick({onClick:d}),g=d?o:{},f={...Di(t),textAlign:t.align};if(t.render)return e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:t.render(c,a,s)});if((t.type==="enum"||t.type==="badge")&&t.enumOptions){const S=t.enumOptions.find(E=>E.value===c);if(S)return e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:e.jsxs("span",{className:Et("nice-module-grid__badge",`nice-module-grid__badge--${S.color||"default"}`),children:[S.icon&&e.jsx("span",{className:"nice-module-grid__badge-icon",children:S.icon}),S.label]})})}if(t.type==="progress"){const S=Math.min(100,Math.max(0,Number(c)||0));return e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:e.jsxs("div",{className:"nice-module-grid__progress",children:[e.jsx("div",{className:"nice-module-grid__progress-bar",children:e.jsx("div",{className:Et("nice-module-grid__progress-fill",`nice-module-grid__progress-fill--${t.progressColor||"primary"}`),style:{width:`${S}%`}})}),e.jsxs("span",{className:"nice-module-grid__progress-text",children:[S,"%"]})]})})}if(t.type==="rating"){const S=t.maxRating||5,E=Number(c)||0;return e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:e.jsx("span",{className:"nice-module-grid__rating","aria-label":u("pagination.outOfStars","{rating} out of {max} stars").replace("{rating}",String(E)).replace("{max}",String(S)),children:Array.from({length:S},($,z)=>e.jsx("span",{className:Et("nice-module-grid__rating-star",z<E&&"nice-module-grid__rating-star--filled"),children:e.jsx(N.NiceIcon,{name:"star",size:14})},z))})})}if(t.type==="link"&&t.linkTemplate){const S=t.linkTemplate.replace(/\{\{(\w+)\}\}/g,(E,$)=>String(Nt(a,$)??""));return e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:e.jsx("a",{href:S,target:t.linkNewTab?"_blank":void 0,rel:t.linkNewTab?"noopener noreferrer":void 0,className:"nice-module-grid__link",children:rn(c,t,l)})})}if(t.type==="image"){const E={xs:24,sm:32,md:48,lg:64}[t.imageSize||"sm"];return e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:c?e.jsx("img",{src:String(c),alt:"",className:"nice-module-grid__image",style:{width:E,height:E}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:E,height:E}})})}return t.type==="avatar"?e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:c?e.jsx("img",{src:String(c),alt:"",className:"nice-module-grid__avatar"}):e.jsx("div",{className:"nice-module-grid__avatar-placeholder",children:"?"})}):t.type==="color"?e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:e.jsx("span",{className:"nice-module-grid__color-swatch",style:{backgroundColor:c||"transparent"},title:c})}):t.type==="boolean"?e.jsx("div",{className:"nice-module-grid__cell",style:{...f,textAlign:t.align||"center"},role:"gridcell",...g,children:e.jsx("span",{className:Et("nice-module-grid__boolean",!!c&&"nice-module-grid__boolean--true"),children:e.jsx(N.NiceIcon,{name:c?"check":"close",size:14})})}):e.jsx("div",{className:"nice-module-grid__cell",style:f,role:"gridcell",...g,children:rn(c,t,l)})}function nr({row:t,index:a,columns:s,primaryField:c,secondaryField:l,customRender:d,selected:u,onClick:o,locale:g="pl-PL",t:f}){const S={role:"option","aria-selected":!!u,onClick:o,onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),o?.())}};if(d)return e.jsx("div",{className:Et("nice-module-grid__mobile-card",u&&"nice-module-grid__mobile-card--selected"),...S,children:d(t,a)});const E=s.find(z=>z.field===c)||s[0],$=s.find(z=>z.field===l)||s[1];return e.jsxs("div",{className:Et("nice-module-grid__mobile-card",u&&"nice-module-grid__mobile-card--selected"),...S,children:[e.jsxs("div",{className:"nice-module-grid__mobile-card-header",children:[e.jsx("div",{className:"nice-module-grid__mobile-card-title",children:rn(Nt(t,E?.field||""),E,g)}),$&&e.jsx("div",{className:"nice-module-grid__mobile-card-subtitle",children:rn(Nt(t,$.field),$,g)})]}),e.jsx("div",{className:"nice-module-grid__mobile-card-body",children:s.filter(z=>!z.hidden&&z.field!==c&&z.field!==l).slice(0,4).map(z=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:z.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:rn(Nt(t,z.field),z,g)})]},z.field))})]})}function ir({page:t,pageSize:a,totalRows:s,pageSizeOptions:c,onPageChange:l,t:d}){const u=Math.ceil(s/a),o=(t-1)*a+1,g=Math.min(t*a,s);return e.jsxs("div",{className:"nice-module-grid__pagination",role:"navigation","aria-label":d("pagination.ariaLabel","Pagination"),children:[e.jsxs("div",{className:"nice-module-grid__pagination-info",children:[d("pagination.showing","Showing")," ",o,"–",g," ",d("pagination.of","of")," ",s]}),e.jsxs("div",{className:"nice-module-grid__pagination-controls",children:[e.jsx("select",{className:"nice-module-grid__page-size-select",value:a,onChange:f=>l(1,Number(f.target.value)),"aria-label":d("pagination.rowsPerPage","Rows per page"),children:c.map(f=>e.jsx("option",{value:f,children:f},f))}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(1,a),disabled:t===1,"aria-label":d("pagination.first","First"),children:e.jsx(N.NiceIcon,{name:"skip-back",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(t-1,a),disabled:t===1,"aria-label":d("pagination.previous","Previous"),children:e.jsx(N.NiceIcon,{name:"chevron-left",size:14})}),e.jsxs("span",{className:"nice-module-grid__pagination-page",children:[t," / ",u]}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(t+1,a),disabled:t>=u,"aria-label":d("pagination.next","Next"),children:e.jsx(N.NiceIcon,{name:"chevron-right",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(u,a),disabled:t>=u,"aria-label":d("pagination.last","Last"),children:e.jsx(N.NiceIcon,{name:"skip-forward",size:14})})]})]})}function ar({columns:t}){return e.jsx("div",{className:"nice-module-grid__row nice-module-grid__row--skeleton",role:"row",children:t.filter(a=>!a.hidden).map(a=>e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--skeleton",style:{width:a.width==="auto"?"auto":a.width||150},children:e.jsx("div",{className:"nice-module-grid__skeleton-bar"})},a.field))})}function rr(t,a){const{columns:s=Va,data:c,keyField:l="id",dataSource:d,onFetch:u,sortable:o=!0,sort:g,onSortChange:f,multiSort:S=!1,filter:E,searchText:$,onSearchChange:z,searchPlaceholder:b,pagination:D=!0,page:p,pageSize:y,pageSizeOptions:I=Ua,totalRows:x,onPageChange:L,virtualScroll:M=!0,rowHeight:F,overscan:H=Qa,selectionMode:xe="none",selectedKeys:se,onSelectionChange:_e,columnResize:De=!0,onColumnWidthChange:te,contextMenuItems:Re,onContextMenuAction:K,exportable:Qe=!0,exportFormats:ze=["csv","excel"],onExport:$e,preferencesKey:ce,initialPreferences:O,density:G="normal",striped:w=!0,bordered:v=!1,hoverable:de=!0,loading:re=!1,emptyState:j,toolbar:he,onRowClick:fe,onRowDoubleClick:ye,rowClassName:A,rowStyle:oe,mobileCardView:pe=!0,mobileBreakpoint:Be=qa,mobileCardRender:ue,mobilePrimaryField:Ae,mobileSecondaryField:ke,size:Ke="medium",skeletonLoading:Ue=!0,skeletonRows:it=Ha,"aria-label":at,"aria-labelledby":rt,"aria-describedby":je,className:W,style:be,id:we,testId:Te}=t,Oe=F??Wa[G],{t:le,lang:X}=N.useNiceTranslation();N.useNiceAccessMode(),N.useComponentDisplayStyle("table");const bt=Ja(Be),[mt,Ne]=Za(ce,O),jt=n.useRef(null),et=n.useRef(null),[st,xt]=n.useState([]),[r,C]=n.useState(),[Q,J]=n.useState(""),[Le,Y]=n.useState(1),[me,ne]=n.useState(y||Ba),[tt,Fe]=n.useState(new Set),[Ve,St]=n.useState([]),[Me,Rt]=n.useState(0),[Ht,Tt]=n.useState(!1),[Bt,dt]=n.useState(new Set),[Se,Xe]=n.useState(null),[ct,Ot]=n.useState({}),ot=g??st,At=E??r,ft=$??Q,ut=p??Le,m=y??me,h=se??tt,R=!!(u||d),B=x??(R?Me:c?.length??0),q=n.useMemo(()=>{const k=new Set(mt.hiddenColumns||[]);return s.filter(ae=>!ae.hidden&&!k.has(ae.field))},[s,mt.hiddenColumns]),P=n.useMemo(()=>{if(R)return Ve;if(!c)return[];let k=[...c];if(ft){const ae=ft.toLowerCase(),ge=s.filter(Ce=>Ce.searchable!==!1).map(Ce=>Ce.field);k=k.filter(Ce=>ge.some(pt=>{const Dt=Nt(Ce,pt);return String(Dt??"").toLowerCase().includes(ae)}))}return ot.length>0&&k.sort((ae,ge)=>{for(const Ce of ot){const pt=Nt(ae,Ce.field),Dt=Nt(ge,Ce.field),Mt=pt<Dt?-1:pt>Dt?1:0;if(Mt!==0)return Ce.direction==="asc"?Mt:-Mt}return 0}),k},[R,Ve,c,ft,ot,s]),V=n.useMemo(()=>{if(R||!D)return P;const k=(ut-1)*m;return P.slice(k,k+m)},[R,P,D,ut,m]),ie=jt.current?.clientHeight||400,ee=M&&V.length>Ya,{visibleData:Ie,totalHeight:Ge,offsetY:Ye,handleScroll:lt,startIndex:Ct}=Xa(V,ie,Oe,H),Z=ee?Ie:V,zt=n.useCallback(async()=>{if(u){Tt(!0);try{const ae=await u({page:ut,pageSize:m,sort:ot,filter:At,search:ft});St(ae.data),Rt(ae.total)}catch(k){console.error("NiceModuleGrid fetch error:",k)}finally{Tt(!1)}}},[u,ut,m,ot,At,ft]);n.useEffect(()=>{R&&zt()},[R,zt]);const Ft=n.useCallback(k=>{const ae=ot.find(Ce=>Ce.field===k);let ge;ae?ae.direction==="asc"?ge=ot.map(Ce=>Ce.field===k?{...Ce,direction:"desc"}:Ce):ge=ot.filter(Ce=>Ce.field!==k):ge=S?[...ot,{field:k,direction:"asc"}]:[{field:k,direction:"asc"}],f?f(ge):xt(ge)},[ot,S,f]),We=n.useCallback((k,ae)=>{L?L(k,ae):(Y(k),ne(ae))},[L]),nt=n.useCallback(k=>{z?z(k):J(k),L||Y(1)},[z,L]),Ut=n.useCallback((k,ae)=>{const ge=new Set(h);if(xe==="single"?(ge.clear(),ge.add(k)):(xe==="multiple"||xe==="checkbox")&&(ge.has(k)?ge.delete(k):ge.add(k)),_e){const Ce=V.filter(pt=>ge.has(String(Nt(pt,l))));_e(ge,Ce)}else Fe(ge)},[h,xe,_e,V,l]),$t=n.useCallback((k,ae)=>{Ot(ge=>({...ge,[k]:ae})),te?.(k,ae),Ne({columnWidths:{...mt.columnWidths,[k]:ae}})},[te,Ne,mt.columnWidths]),Gt=n.useCallback((k,ae)=>{if(Re?.length)if(k.preventDefault(),k.clientX===0&&k.clientY===0){const ge=k.currentTarget.getBoundingClientRect();Xe({x:ge.left,y:ge.bottom,row:ae})}else Xe({x:k.clientX,y:k.clientY,row:ae})},[Re]),Lt=n.useRef(null);N.useOverlayFocus(Lt,{open:Se!=null,modal:!1,onClose:()=>Xe(null)}),N.useRovingFocus(Lt,{orientation:"vertical",wrap:!0,typeahead:!0});const Xt=n.useCallback(k=>{Se&&K?.(k,Se.row),Xe(null)},[Se,K]),yt=n.useCallback(async k=>{if($e)await $e(k,{selectedOnly:h.size>0,columns:q.map(ae=>ae.field)});else if(k==="csv"){const ae=q.map(ht=>ht.header).join(","),ge=V.map(ht=>q.map(kt=>JSON.stringify(Nt(ht,kt.field)??"")).join(",")),Ce=[ae,...ge].join(`
|
|
7
|
-
`),pt=new Blob([Ce],{type:"text/csv;charset=utf-8;"}),Dt=URL.createObjectURL(pt),Mt=document.createElement("a");Mt.href=Dt,Mt.download=`export-${new Date().toISOString().slice(0,10)}.csv`,Mt.click(),URL.revokeObjectURL(Dt)}},[$e,h,q,V]);n.useEffect(()=>{if(!Se)return;const k=()=>Xe(null);return document.addEventListener("click",k),()=>document.removeEventListener("click",k)},[Se]),N.useGridFocus(et,{pageSize:10});const Kt=n.useRef(null);N.useRovingFocus(Kt,{orientation:"vertical",pageSize:10});const vt=re||Ht,Pt=!vt&&Z.length===0,Zt=bt&&pe,yn=Et("nice-module-grid",`nice-module-grid--${G}`,`nice-module-grid--${Ke}`,w&&"nice-module-grid--striped",v&&"nice-module-grid--bordered",de&&"nice-module-grid--hoverable",vt&&"nice-module-grid--loading",Zt&&"nice-module-grid--mobile",W);return e.jsxs("div",{ref:a,id:we,"data-testid":Te,className:yn,style:be,"aria-busy":vt,children:[e.jsxs("div",{className:"nice-module-grid__toolbar",children:[e.jsx("div",{className:"nice-module-grid__toolbar-search",children:e.jsx("input",{type:"search",className:"nice-module-grid__search-input",placeholder:b??le("moduleGrid.searchPlaceholder","Search…"),value:ft,onChange:k=>nt(k.target.value),"aria-label":le("moduleGrid.searchAriaLabel","Search")})}),he,Qe&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:ze.map(k=>e.jsx("button",{className:"nice-module-grid__export-btn",onClick:()=>yt(k),"aria-label":le(`moduleGrid.export.${k}`,`Export to ${k.toUpperCase()}`),children:k.toUpperCase()},k))})]}),e.jsx("div",{ref:jt,className:"nice-module-grid__container",onScroll:ee?lt:void 0,children:Zt?e.jsx("div",{ref:Kt,className:"nice-module-grid__mobile-list",role:"listbox","aria-label":at,"aria-labelledby":rt,"aria-describedby":je,"aria-multiselectable":xe==="checkbox"||void 0,children:vt&&Ue?Array.from({length:it},(k,ae)=>e.jsxs("div",{className:"nice-module-grid__mobile-card nice-module-grid__mobile-card--skeleton",children:[e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"60%",height:20}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"40%",height:14}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"80%",height:14}})]},ae)):Pt?e.jsxs("div",{className:"nice-module-grid__empty",children:[j?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:j.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:j?.title||le("moduleGrid.noData","No data")}),j?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:j.description}),j?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:j.action.onClick,children:[j.action.icon,j.action.label]})]}):Z.map((k,ae)=>{const ge=String(Nt(k,l));return e.jsx(nr,{row:k,index:Ct+ae,columns:q,primaryField:Ae,secondaryField:ke,customRender:ue,selected:h.has(ge),locale:X,onClick:()=>{xe!=="none"&&Ut(ge,k),fe?.(k,Ct+ae)},t:le},ge)})}):e.jsxs("div",{ref:et,className:"nice-module-grid__table",role:"grid","aria-label":at,"aria-labelledby":rt,"aria-describedby":je,"aria-rowcount":B,"aria-colcount":q.length,children:[e.jsxs("div",{className:"nice-module-grid__header",role:"row",children:[xe==="checkbox"&&e.jsx("div",{className:"nice-module-grid__header-cell nice-module-grid__header-cell--checkbox",role:"columnheader",children:e.jsx("input",{type:"checkbox",checked:h.size>0&&h.size===Z.length,onChange:()=>{if(h.size===Z.length)_e?.(new Set,[]),Fe(new Set);else{const k=new Set(Z.map(ae=>String(Nt(ae,l))));_e?.(k,Z),Fe(k)}},"aria-label":le("moduleGrid.selectAll","Select all")})}),q.map(k=>e.jsx(er,{column:{...k,width:ct[k.field]||k.width},sort:ot.find(ae=>ae.field===k.field),onSort:o?Ft:void 0,onResize:De?$t:void 0,resizable:De,t:le},k.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:ee?{height:Ge,position:"relative"}:void 0,children:vt&&Ue?Array.from({length:it},(k,ae)=>e.jsx(ar,{columns:q},ae)):Pt?e.jsxs("div",{className:"nice-module-grid__empty",children:[j?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:j.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:j?.title||le("moduleGrid.noData","No data")}),j?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:j.description}),j?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:j.action.onClick,children:[j.action.icon,j.action.label]})]}):e.jsx("div",{style:ee?{transform:`translateY(${Ye}px)`}:void 0,children:Z.map((k,ae)=>{const ge=String(Nt(k,l)),Ce=Ct+ae,pt=h.has(ge),Dt=typeof A=="function"?A(k,Ce):A,Mt=typeof oe=="function"?oe(k,Ce):oe;return e.jsxs("div",{className:Et("nice-module-grid__row",pt&&"nice-module-grid__row--selected",Dt),style:{...Mt,height:Oe},role:"row","aria-rowindex":Ce+1,"aria-selected":pt,onClick:()=>{xe!=="none"&&Ut(ge,k),fe?.(k,Ce)},onDoubleClick:()=>ye?.(k,Ce),onContextMenu:ht=>Gt(ht,k),children:[xe==="checkbox"&&e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--checkbox",role:"gridcell",children:e.jsx("input",{type:"checkbox",checked:pt,onChange:()=>Ut(ge,k),onClick:ht=>ht.stopPropagation(),"aria-label":le("moduleGrid.selectRow","Select row")})}),q.map(ht=>e.jsx(tr,{column:{...ht,width:ct[ht.field]||ht.width},row:k,rowIndex:Ce,value:Nt(k,ht.field),locale:X},ht.field))]},ge)})})})]})}),D&&B>0&&e.jsx(ir,{page:ut,pageSize:m,totalRows:R?Me:P.length,pageSizeOptions:I,onPageChange:We,t:le}),Se&&Re&&e.jsx("div",{ref:Lt,className:"nice-module-grid__context-menu",style:{left:Se.x,top:Se.y},role:"menu",children:Re.filter(k=>typeof k.hidden=="function"?!k.hidden(Se.row):!k.hidden).map(k=>{if(k.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},k.key);const ae=typeof k.disabled=="function"?k.disabled(Se.row):k.disabled;return e.jsxs("button",{className:Et("nice-module-grid__context-menu-item",k.danger&&"nice-module-grid__context-menu-item--danger",ae&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{ae||(k.onClick?.(Se.row),Xt(k.key))},disabled:ae,role:"menuitem",children:[k.icon&&e.jsx("span",{className:"nice-module-grid__context-menu-icon",children:k.icon}),k.label]},k.key)})}),vt&&!Ue&&e.jsx("div",{className:"nice-module-grid__loading-overlay",children:e.jsx("div",{className:"nice-module-grid__spinner","aria-label":le("moduleGrid.loading","Loading")})})]})}const sr=n.forwardRef(rr),_t={width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},cr=()=>e.jsxs("svg",{..._t,children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13"})]}),or=()=>e.jsxs("svg",{..._t,children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 0 1 15-6.7L21 13"})]}),lr=()=>e.jsxs("svg",{..._t,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]}),dr=()=>e.jsxs("svg",{..._t,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),ur=()=>e.jsxs("svg",{..._t,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]}),hr=()=>e.jsxs("svg",{..._t,children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1"}),e.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"13"})]}),mr=()=>e.jsxs("svg",{..._t,children:[e.jsx("rect",{x:"4",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("line",{x1:"11",y1:"12",x2:"13",y2:"12"})]}),fr=()=>e.jsxs("svg",{..._t,children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1"}),e.jsx("line",{x1:"6",y1:"17",x2:"18",y2:"17"})]}),pr=()=>e.jsxs("svg",{..._t,children:[e.jsx("rect",{x:"4",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"})]}),gr=()=>e.jsx("svg",{..._t,children:e.jsx("polyline",{points:"6 9 12 4 18 9"})}),_r=()=>e.jsx("svg",{..._t,children:e.jsx("polyline",{points:"6 15 12 20 18 15"})}),br=()=>e.jsxs("svg",{..._t,style:{opacity:.55},children:[e.jsx("polyline",{points:"6 9 12 4 18 9"}),e.jsx("polyline",{points:"6 15 12 20 18 15"})]}),xr=()=>e.jsxs("svg",{..._t,children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),yr=()=>e.jsxs("svg",{..._t,children:[e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e.jsx("line",{x1:"6",y1:"18",x2:"18",y2:"6"})]});function Mi(t){let a="",s=t;for(;s>=0;)a=String.fromCharCode(65+s%26)+a,s=Math.floor(s/26)-1;return a}function Pe(t,a){return`${Mi(a)}${t+1}`}function Je(t){const a=t.match(/^([A-Z]+)(\d+)$/);if(!a)return null;let s=0;for(let c=0;c<a[1].length;c++)s=s*26+(a[1].charCodeAt(c)-64);return{row:parseInt(a[2],10)-1,col:s-1}}function vr(t,a,s=new Set){const c=t.startsWith("=")?t.slice(1).trim():t,l=(p,y)=>{if(!p||!y)return[];const I=[];for(let x=p.row;x<=y.row;x++)for(let L=p.col;L<=y.col;L++){const M=Ze(Pe(x,L),a,new Set(s));typeof M=="number"&&I.push(M)}return I},d=(p,y)=>{if(!p||!y)return[];const I=[];for(let x=p.row;x<=y.row;x++)for(let L=p.col;L<=y.col;L++)I.push(Ze(Pe(x,L),a,new Set(s)));return I},u=c.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(u){const p=u[1].toUpperCase(),y=Je(u[2].toUpperCase()),I=Je(u[3].toUpperCase());switch(p){case"SUM":return l(y,I).reduce((L,M)=>L+M,0);case"AVG":case"AVERAGE":{const x=l(y,I);return x.length>0?x.reduce((L,M)=>L+M,0)/x.length:0}case"COUNT":return l(y,I).length;case"COUNTA":return d(y,I).filter(x=>x!==null&&x!=="").length;case"COUNTBLANK":return d(y,I).filter(x=>x===null||x==="").length;case"MIN":{const x=l(y,I);return x.length?Math.min(...x):0}case"MAX":{const x=l(y,I);return x.length?Math.max(...x):0}case"MEDIAN":{const x=l(y,I).sort((M,F)=>M-F);if(!x.length)return 0;const L=Math.floor(x.length/2);return x.length%2?x[L]:(x[L-1]+x[L])/2}case"STDEV":{const x=l(y,I);if(x.length<2)return 0;const L=x.reduce((M,F)=>M+F,0)/x.length;return Math.sqrt(x.reduce((M,F)=>M+(F-L)**2,0)/(x.length-1))}case"PRODUCT":{const x=l(y,I);return x.length?x.reduce((L,M)=>L*M,1):0}}}const o=c.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(o){const p=o[1].toUpperCase(),y=Je(o[2].toUpperCase()),I=Je(o[3].toUpperCase()),x=o[4];if(y&&I){let L=0;for(let M=y.row;M<=I.row;M++)for(let F=y.col;F<=I.col;F++){const H=Ze(Pe(M,F),a,new Set(s));(x.startsWith(">")?Number(H)>Number(x.slice(1)):x.startsWith("<")?Number(H)<Number(x.slice(1)):String(H)===x||typeof H=="number"&&H===Number(x))&&(L+=p==="SUMIF"?typeof H=="number"?H:0:1)}return L}}const g=c.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(g){const p=g[1].trim(),y=g[2].trim(),I=g[3].trim(),x=p.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let L=!1;if(x){const H=Ze(x[1].toUpperCase(),a,new Set(s)),xe=isNaN(Number(x[3]))?x[3].replace(/^"|"$/g,""):Number(x[3]),se=x[2],_e=typeof H=="number"?H:Number(H)||0,De=typeof xe=="number"?xe:Number(xe)||0;switch(se){case">":L=_e>De;break;case"<":L=_e<De;break;case">=":L=_e>=De;break;case"<=":L=_e<=De;break;case"=":case"==":L=_e===De;break;case"<>":case"!=":L=_e!==De;break}}const M=L?y:I;if(Je(M.toUpperCase()))return Ze(M.toUpperCase(),a,new Set(s));const F=Number(M);return isNaN(F)?M.replace(/^"|"$/g,""):F}const f=c.match(/^CONCAT\((.+)\)$/i);if(f)return f[1].split(",").map(y=>y.trim()).map(y=>{if(y.startsWith('"')&&y.endsWith('"'))return y.slice(1,-1);if(Je(y.toUpperCase())){const x=Ze(y.toUpperCase(),a,new Set(s));return x!==null?String(x):""}return y}).join("");const S=c.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if(S){let p;Je(S[1].trim().toUpperCase())?p=Ze(S[1].trim().toUpperCase(),a,new Set(s)):p=isNaN(Number(S[1]))?S[1].replace(/^"|"$/g,""):Number(S[1]);const I=Je(S[2].toUpperCase()),x=Je(S[3].toUpperCase()),L=parseInt(S[4])-1;if(I&&x)for(let M=I.row;M<=x.row;M++){const F=Ze(Pe(M,I.col),a,new Set(s));if(String(F)===String(p))return Ze(Pe(M,I.col+L),a,new Set(s))}return null}const E=c.match(/^(ABS|ROUND|FLOOR|CEIL|CEILING|SQRT|LEN|UPPER|LOWER|TRIM|INT)\(([^)]+)\)$/i);if(E){const p=E[1].toUpperCase(),y=E[2].trim();let I;switch(Je(y.toUpperCase())?I=Ze(y.toUpperCase(),a,new Set(s)):I=isNaN(Number(y))?y.replace(/^"|"$/g,""):Number(y),p){case"ABS":return Math.abs(Number(I)||0);case"ROUND":return Math.round(Number(I)||0);case"FLOOR":return Math.floor(Number(I)||0);case"CEIL":case"CEILING":return Math.ceil(Number(I)||0);case"SQRT":return Math.sqrt(Number(I)||0);case"INT":return Math.trunc(Number(I)||0);case"LEN":return String(I??"").length;case"UPPER":return String(I??"").toUpperCase();case"LOWER":return String(I??"").toLowerCase();case"TRIM":return String(I??"").trim()}}const $=c.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if($){const p=Number(Je($[1].trim().toUpperCase())?Ze($[1].trim().toUpperCase(),a,new Set(s)):$[1].trim())||0,y=Number(Je($[2].trim().toUpperCase())?Ze($[2].trim().toUpperCase(),a,new Set(s)):$[2].trim())||0;return Math.pow(p,y)}if(/^NOW\(\)$/i.test(c))return new Date().toISOString();if(/^TODAY\(\)$/i.test(c))return new Date().toISOString().split("T")[0];if(/^PI\(\)$/i.test(c))return Math.PI;const z=c.match(/^([A-Z]+\d+)$/i);if(z)return Ze(z[1].toUpperCase(),a,s);const b=c.match(/^([A-Z]+\d+)\s*([+\-*/])\s*([A-Z]+\d+|\d+\.?\d*)$/i);if(b){const p=b[1].toUpperCase(),y=b[2],I=b[3],x=Ze(p,a,s),M=Je(I.toUpperCase())?Ze(I.toUpperCase(),a,s):parseFloat(I),F=typeof x=="number"?x:0,H=typeof M=="number"?M:0;switch(y){case"+":return F+H;case"-":return F-H;case"*":return F*H;case"/":return H!==0?F/H:null}}const D=parseFloat(c);return isNaN(D)?c:D}function Ze(t,a,s){if(s.has(t))return null;s.add(t);const c=a[t];return c?c.formula?vr(c.formula,a,s):c.value:null}function yi(t,a){return t==null?"":a==="percent"&&typeof t=="number"?`${(t*100).toFixed(1)}%`:a==="currency"&&typeof t=="number"?`$${t.toFixed(2)}`:String(t)}function vi(t){return{name:t,data:{}}}const kr=Object.assign(n.forwardRef(({sheets:t,activeSheet:a,rows:s=50,cols:c=26,showToolbar:l=!0,showFormulaBar:d=!0,showSheetTabs:u=!0,readOnly:o=!1,disabled:g=!1,loading:f=!1,error:S,size:E="md",onChange:$,onActiveSheetChange:z,onCellSelect:b,onCopy:D,onPaste:p,onInsert:y,onRemove:I,maxUndo:x=50,sortable:L=!1,filterable:M=!1,rangeSelection:F=!0,className:H,style:xe,id:se,..._e},De)=>{const te=o||g,Re=N.useControlId(se),{t:K}=N.useNiceTranslation(),[Qe,ze]=n.useState(()=>t??[vi(K("spreadsheet.sheet","Sheet")+" 1")]),[$e,ce]=n.useState(0),O=t??Qe,G=a??$e,w=O[G]??O[0],[v,de]=n.useState(null),[re,j]=n.useState(null),[he,fe]=n.useState(!1),[ye,A]=n.useState(null),[oe,pe]=n.useState(""),Be=n.useRef(null),ue=n.useRef(null),[Ae,ke]=n.useState([]),[Ke,Ue]=n.useState([]),[it,at]=n.useState(null),rt=n.useRef({x:0,width:80}),[je,W]=n.useState(null),[be,we]=n.useState(null),Te=n.useRef(null);N.useRovingFocus(Te,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const[Oe,le]=n.useState("");n.useEffect(()=>{ye&&Be.current&&Be.current.focus()},[ye]);const X=n.useMemo(()=>{if(!v)return null;const m=re??v;return{startRow:Math.min(v.row,m.row),startCol:Math.min(v.col,m.col),endRow:Math.max(v.row,m.row),endCol:Math.max(v.col,m.col)}},[v,re]),bt=n.useCallback((m,h)=>X?m>=X.startRow&&m<=X.endRow&&h>=X.startCol&&h<=X.endCol:!1,[X]),mt=n.useCallback(m=>{ke(h=>{const R=[...h,m.map(B=>({...B,data:{...B.data}}))];return R.length>x?R.slice(-x):R}),Ue([])},[x]),Ne=n.useCallback((m,h=!0)=>{h&&mt(O);const R=m(O);t||ze(R),$?.(R)},[O,t,$,mt]),jt=n.useCallback(()=>{if(Ae.length===0)return;const m=Ae[Ae.length-1];Ue(h=>[...h,O.map(R=>({...R,data:{...R.data}}))]),ke(h=>h.slice(0,-1)),t||ze(m),$?.(m)},[Ae,O,t,$]),et=n.useCallback(()=>{if(Ke.length===0)return;const m=Ke[Ke.length-1];ke(h=>[...h,O.map(R=>({...R,data:{...R.data}}))]),Ue(h=>h.slice(0,-1)),t||ze(m),$?.(m)},[Ke,O,t,$]),st=n.useCallback(m=>{a||ce(m),z?.(m),de(null),j(null),A(null)},[a,z]),xt=n.useCallback((m,h,R)=>{const B=Pe(m,h);Ne(q=>{const P=q.map((ie,ee)=>ee===G?{...ie,data:{...ie.data}}:ie),V=R.startsWith("=");return P[G].data[B]={...P[G].data[B]??{value:null},formula:V?R:void 0,value:V?null:isNaN(Number(R))?R:Number(R)},P})},[G,Ne]),r=n.useCallback((m,h,R)=>{R?.shiftKey&&F&&v?j({row:m,col:h}):(de({row:m,col:h}),j(null)),A(null),b?.(G,m,h)},[G,b,F,v]),C=n.useCallback((m,h,R)=>{R.button===0&&(r(m,h,R),F&&!R.shiftKey&&fe(!0))},[r,F]),Q=n.useCallback((m,h)=>{he&&j({row:m,col:h})},[he]);n.useEffect(()=>{if(!he)return;const m=()=>fe(!1);return document.addEventListener("mouseup",m),()=>document.removeEventListener("mouseup",m)},[he]);const J=n.useCallback((m,h)=>{if(te)return;const R=Pe(m,h),B=w.data[R];B?.readOnly||(A({row:m,col:h}),pe(B?.formula??(B?.value!=null?String(B.value):"")))},[te,w.data]),Le=n.useCallback(()=>{ye&&(xt(ye.row,ye.col,oe),A(null))},[ye,oe,xt]),Y=n.useCallback(m=>{if(m.key==="Enter")Le();else if(m.key==="Escape")A(null);else if(m.key==="Tab"&&ye&&(m.preventDefault(),Le(),v)){const h=m.shiftKey?Math.max(0,v.col-1):Math.min(c-1,v.col+1);de({row:v.row,col:h})}},[Le,v,c,ye]),me=n.useCallback((m,h)=>{if(!v)return;const R=X??{startRow:v.row,startCol:v.col,endRow:v.row,endCol:v.col};Ne(B=>{const q=B.map((P,V)=>V===G?{...P,data:{...P.data}}:P);for(let P=R.startRow;P<=R.endRow;P++)for(let V=R.startCol;V<=R.endCol;V++){const ie=Pe(P,V);q[G].data[ie]={...q[G].data[ie]??{value:null},[m]:h}}return q})},[v,X,G,Ne]),ne=n.useCallback(m=>{if(!X||D?.(X)===!1)return;const{startRow:h,startCol:R,endRow:B,endCol:q}=X,P=[];for(let V=h;V<=B;V++){const ie=[];for(let ee=R;ee<=q;ee++){const Ie=Pe(V,ee),Ge=w.data[Ie],Ye=Ge?Ze(Ie,w.data,new Set):null;ie.push(yi(Ye,Ge?.format))}P.push(ie.join(" "))}m.clipboardData.setData("text/plain",P.join(`
|
|
8
|
-
`)),m.preventDefault()},[X,w.data,D]),tt=n.useCallback(m=>{if(te||!v)return;const h=m.clipboardData.getData("text/plain");if(!h)return;const R=h.split(`
|
|
9
|
-
`).map(B=>B.split(" "));p?.(R,v.row,v.col)!==!1&&(Ne(B=>{const q=B.map((P,V)=>V===G?{...P,data:{...P.data}}:P);return R.forEach((P,V)=>{P.forEach((ie,ee)=>{const Ie=Pe(v.row+V,v.col+ee),Ge=ie.startsWith("=");q[G].data[Ie]={...q[G].data[Ie]??{value:null},formula:Ge?ie:void 0,value:Ge?null:isNaN(Number(ie))?ie:Number(ie)}})}),q}),m.preventDefault())},[te,v,G,Ne,p]),Fe=n.useCallback(m=>{Ne(h=>h.map((B,q)=>{if(q!==G)return B;const P={};for(const[V,ie]of Object.entries(B.data)){const ee=Je(V);ee&&(ee.row>m?P[Pe(ee.row+1,ee.col)]=ie:P[V]=ie)}return{...B,data:P}})),y?.("row",m)},[G,Ne,y]),Ve=n.useCallback(m=>{Ne(h=>h.map((B,q)=>{if(q!==G)return B;const P={};for(const[V,ie]of Object.entries(B.data)){const ee=Je(V);ee&&(ee.col>m?P[Pe(ee.row,ee.col+1)]=ie:P[V]=ie)}return{...B,data:P}})),y?.("column",m)},[G,Ne,y]),St=n.useCallback(m=>{Ne(h=>h.map((B,q)=>{if(q!==G)return B;const P={};for(const[V,ie]of Object.entries(B.data)){const ee=Je(V);ee&&ee.row!==m&&(ee.row>m?P[Pe(ee.row-1,ee.col)]=ie:P[V]=ie)}return{...B,data:P}})),I?.("row",m)},[G,Ne,I]),Me=n.useCallback(m=>{Ne(h=>h.map((B,q)=>{if(q!==G)return B;const P={};for(const[V,ie]of Object.entries(B.data)){const ee=Je(V);ee&&ee.col!==m&&(ee.col>m?P[Pe(ee.row,ee.col-1)]=ie:P[V]=ie)}return{...B,data:P}})),I?.("column",m)},[G,Ne,I]),Rt=n.useCallback((m,h)=>{Ne(R=>R.map((q,P)=>{if(P!==G)return q;const V=new Map;for(const[Ie,Ge]of Object.entries(q.data)){const Ye=Je(Ie);Ye&&(V.has(Ye.row)||V.set(Ye.row,{}),V.get(Ye.row)[Ye.col]=Ge)}const ie=Array.from(V.entries()).sort((Ie,Ge)=>{const Ye=Ze(Pe(Ie[0],m),q.data,new Set),lt=Ze(Pe(Ge[0],m),q.data,new Set),Ct=typeof Ye=="number"?Ye:Number(Ye),Z=typeof lt=="number"?lt:Number(lt);if(!isNaN(Ct)&&!isNaN(Z))return h==="asc"?Ct-Z:Z-Ct;const zt=String(Ye??""),Ft=String(lt??"");return h==="asc"?zt.localeCompare(Ft):Ft.localeCompare(zt)}),ee={};return ie.forEach(([,Ie],Ge)=>{for(const[Ye,lt]of Object.entries(Ie))ee[Pe(Ge,Number(Ye))]=lt}),{...q,data:ee,sortColumn:m,sortDirection:h}}))},[G,Ne]),Ht=n.useCallback((m,h)=>{const R=w.conditionalFormats;if(!R?.length)return;const B=Pe(m,h),q=Ze(B,w.data,new Set),P=typeof q=="number"?q:Number(q);for(const V of R){const ie=V.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!ie)continue;const ee=Je(ie[1].toUpperCase()),Ie=Je(ie[2].toUpperCase());if(!ee||!Ie||m<ee.row||m>Ie.row||h<ee.col||h>Ie.col)continue;let Ge=!1;switch(V.type){case"greaterThan":Ge=!isNaN(P)&&P>Number(V.value);break;case"lessThan":Ge=!isNaN(P)&&P<Number(V.value);break;case"equalTo":Ge=String(q)===String(V.value);break;case"between":Ge=!isNaN(P)&&P>=Number(V.value)&&P<=Number(V.value2);break;case"textContains":Ge=String(q).includes(String(V.value));break;case"isEmpty":Ge=q===null||q==="";break;case"isNotEmpty":Ge=q!==null&&q!=="";break}if(Ge)return{backgroundColor:V.style.bgColor,color:V.style.color,fontWeight:V.style.bold?"bold":void 0,fontStyle:V.style.italic?"italic":void 0}}},[w.conditionalFormats,w.data]),Tt=n.useCallback(()=>{const m=`${K("spreadsheet.sheet","Sheet")} ${O.length+1}`;Ne(h=>[...h,vi(m)]),st(O.length)},[O.length,Ne,st,K]),Bt=n.useCallback(()=>{O.length<=1||(Ne(m=>m.filter((h,R)=>R!==G)),st(Math.max(0,G-1)))},[O.length,G,Ne,st]),dt=n.useCallback((m,h)=>{h.trim()&&(Ne(R=>R.map((B,q)=>q===m?{...B,name:h.trim()}:B),!1),we(null))},[Ne]),Se=n.useMemo(()=>{if(!v)return"";const m=Pe(v.row,v.col),h=w.data[m];return h?.formula??(h?.value!=null?String(h.value):"")},[v,w.data]),Xe=n.useMemo(()=>{if(!X)return null;const{startRow:m,startCol:h,endRow:R,endCol:B}=X;if(m===R&&h===B)return null;const q=[];let P=0;for(let V=m;V<=R;V++)for(let ie=h;ie<=B;ie++){const ee=Pe(V,ie),Ie=Ze(ee,w.data,new Set);Ie!==null&&Ie!==""&&P++,typeof Ie=="number"&&q.push(Ie)}return q.length===0?{count:P}:{count:P,sum:q.reduce((V,ie)=>V+ie,0),avg:q.reduce((V,ie)=>V+ie,0)/q.length,min:Math.min(...q),max:Math.max(...q)}},[X,w.data]),ct=n.useCallback((m,h)=>{h.preventDefault(),h.stopPropagation(),at(m),rt.current={x:h.clientX,width:w.colWidths?.[m]??80}},[w.colWidths]);n.useEffect(()=>{if(it===null)return;const m=R=>{const B=R.clientX-rt.current.x,q=Math.max(30,rt.current.width+B);Ne(P=>P.map((ie,ee)=>ee===G?{...ie,colWidths:{...ie.colWidths,[it]:q}}:ie),!1)},h=()=>at(null);return document.addEventListener("mousemove",m),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",h)}},[it,G,Ne]);const Ot=n.useCallback((m,h,R)=>{m.preventDefault(),de({row:h,col:R}),W({x:m.clientX,y:m.clientY})},[]);n.useEffect(()=>{if(!je)return;const m=()=>W(null);return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[je]);const ot=n.useCallback(m=>{if((m.ctrlKey||m.metaKey)&&!ye){if(m.key==="z"){m.preventDefault(),jt();return}if(m.key==="y"){m.preventDefault(),et();return}}if(ye||!v)return;let{row:h,col:R}=v;switch(m.key){case"ArrowUp":h=Math.max(0,h-1);break;case"ArrowDown":h=Math.min(s-1,h+1);break;case"ArrowLeft":R=Math.max(0,R-1);break;case"ArrowRight":R=Math.min(c-1,R+1);break;case"Home":R=0,h=m.ctrlKey||m.metaKey?0:h;break;case"End":R=c-1,h=m.ctrlKey||m.metaKey?s-1:h;break;case"PageUp":h=Math.max(0,h-10);break;case"PageDown":h=Math.min(s-1,h+10);break;case"Enter":J(h,R);return;case"Delete":case"Backspace":te||(X&&(X.startRow!==X.endRow||X.startCol!==X.endCol)?Ne(B=>{const q=B.map((P,V)=>V===G?{...P,data:{...P.data}}:P);for(let P=X.startRow;P<=X.endRow;P++)for(let V=X.startCol;V<=X.endCol;V++)delete q[G].data[Pe(P,V)];return q}):xt(h,R,""));return;default:if(m.key.length===1&&!m.ctrlKey&&!m.metaKey&&!te){A({row:h,col:R}),pe(m.key);return}return}m.preventDefault(),m.shiftKey&&F?j({row:h,col:R}):(de({row:h,col:R}),j(null)),b?.(G,h,R)},[ye,v,s,c,te,J,xt,G,b,jt,et,X,Ne,F]),At=w.frozenRows??0,ft=w.frozenCols??0,ut=[{value:"text",label:K("spreadsheet.formatText","Text")},{value:"number",label:K("spreadsheet.formatNumber","Number")},{value:"percent",label:K("spreadsheet.formatPercent","Percent")},{value:"currency",label:K("spreadsheet.formatCurrency","Currency")},{value:"date",label:K("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:De,id:Re,className:`nice-spreadsheet nice-spreadsheet--${E} ${o&&!g?"nice-spreadsheet--readonly":""} ${g?"nice-spreadsheet--disabled":""} ${f?"nice-spreadsheet--loading":""} ${S?"nice-spreadsheet--error":""} ${H??""}`,style:{...xe,position:f?"relative":xe?.position},onKeyDown:ot,onCopy:ne,onPaste:tt,tabIndex:g?-1:0,role:"application","aria-label":K("spreadsheet.label","Spreadsheet"),"aria-disabled":g||void 0,"aria-busy":f||void 0,..._e,children:[S&&e.jsx("div",{className:"nice-spreadsheet__error",role:"alert",children:S}),f&&e.jsx("span",{className:"nice-spreadsheet__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),l&&!te&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:jt,disabled:Ae.length===0,title:K("spreadsheet.undo","Undo"),children:e.jsx(cr,{})}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:et,disabled:Ke.length===0,title:K("spreadsheet.redo","Redo"),children:e.jsx(or,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(qe.NiceButton,{variant:w.data[v?Pe(v.row,v.col):""]?.bold?"primary":"ghost",size:"sm",onClick:()=>me("bold",!w.data[v?Pe(v.row,v.col):""]?.bold),title:K("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(qe.NiceButton,{variant:w.data[v?Pe(v.row,v.col):""]?.italic?"primary":"ghost",size:"sm",onClick:()=>me("italic",!w.data[v?Pe(v.row,v.col):""]?.italic),title:K("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>me("align","left"),title:K("spreadsheet.alignLeft","Align left"),children:e.jsx(lr,{})}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>me("align","center"),title:K("spreadsheet.alignCenter","Center"),children:e.jsx(dr,{})}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>me("align","right"),title:K("spreadsheet.alignRight","Align right"),children:e.jsx(ur,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(gi.NiceColorPicker,{value:w.data[v?Pe(v.row,v.col):""]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:m=>me("bgColor",m),title:K("spreadsheet.bgColor","Background color"),showInput:!1,showRandom:!1}),e.jsx(gi.NiceColorPicker,{value:w.data[v?Pe(v.row,v.col):""]?.color??"var(--nice-text-primary, #000000)",onChange:m=>me("color",m),title:K("spreadsheet.textColor","Text color"),showInput:!1,showRandom:!1}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(Ln.NiceSelect,{size:"sm",value:w.data[v?Pe(v.row,v.col):""]?.format??"text",onChange:m=>me("format",m),options:ut,"aria-label":K("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>v&&Fe(v.row),title:K("spreadsheet.insertRow","Insert row"),children:e.jsx(hr,{})}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>v&&Ve(v.col),title:K("spreadsheet.insertCol","Insert column"),children:e.jsx(mr,{})}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>v&&St(v.row),title:K("spreadsheet.deleteRow","Delete row"),children:e.jsx(fr,{})}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>v&&Me(v.col),title:K("spreadsheet.deleteCol","Delete column"),children:e.jsx(pr,{})})]}),d&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[v?Pe(v.row,v.col):"",X&&X.startRow!==X.endRow||X&&X.startCol!==X.endCol?`:${Pe(X.endRow,X.endCol)}`:""]}),e.jsx(Ln.NiceTextInput,{className:"nice-spreadsheet__formula-input",value:ye?oe:Se,onChange:m=>{ye?pe(m):v&&(A(v),pe(m))},onKeyDown:Y,readOnly:te,"aria-label":K("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:ue,children:e.jsxs("table",{role:"grid","aria-label":w.name,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-spreadsheet__corner"}),Array.from({length:c},(m,h)=>e.jsxs("th",{className:`nice-spreadsheet__col-header ${h<ft?"nice-spreadsheet__col-header--frozen":""}`,style:{width:w.colWidths?.[h]??80,position:h<ft?"sticky":void 0,left:h<ft?h*80+40:void 0,zIndex:h<ft?3:void 0},children:[e.jsx("span",{children:Mi(h)}),L&&e.jsx("span",{role:"button",tabIndex:0,onKeyDown:N.clickOnActivationKey,className:"nice-spreadsheet__sort-trigger",onClick:()=>Rt(h,w.sortColumn===h&&w.sortDirection==="asc"?"desc":"asc"),title:K("spreadsheet.sort","Sort"),children:w.sortColumn===h?w.sortDirection==="asc"?e.jsx(gr,{}):e.jsx(_r,{}):e.jsx(br,{})}),!te&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:R=>ct(h,R)})]},h))]})}),e.jsx("tbody",{children:Array.from({length:s},(m,h)=>e.jsxs("tr",{className:h<At?"nice-spreadsheet__row--frozen":"",style:h<At?{position:"sticky",top:h*24,zIndex:2}:void 0,children:[e.jsx("td",{className:"nice-spreadsheet__row-header",children:h+1}),Array.from({length:c},(R,B)=>{const q=Pe(h,B),P=w.data[q];if(P?.mergedInto)return null;const V=v?.row===h&&v?.col===B,ie=bt(h,B),ee=ye?.row===h&&ye?.col===B,Ie=P?Ze(q,w.data,new Set):null,Ge=Ht(h,B),Ye=h<At||B<ft;return e.jsxs("td",{className:`nice-spreadsheet__cell ${V?"nice-spreadsheet__cell--selected":""} ${ie&&!V?"nice-spreadsheet__cell--in-range":""} ${P?.readOnly?"nice-spreadsheet__cell--readonly":""} ${Ye?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:P?.align,fontWeight:P?.bold?"bold":void 0,fontStyle:P?.italic?"italic":void 0,backgroundColor:Ge?.backgroundColor??P?.bgColor,color:Ge?.color??P?.color,width:w.colWidths?.[B],height:w.rowHeights?.[h],position:Ye?"sticky":void 0,left:B<ft?B*80+40:void 0,zIndex:Ye?1:void 0,...Ge},colSpan:P?.colSpan,rowSpan:P?.rowSpan,onMouseDown:lt=>C(h,B,lt),onMouseEnter:()=>Q(h,B),onDoubleClick:()=>J(h,B),onContextMenu:lt=>Ot(lt,h,B),role:"gridcell","aria-selected":V,title:P?.comment,children:[P?.comment&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),ee?e.jsx("input",{ref:Be,className:"nice-spreadsheet__cell-editor",value:oe,onChange:lt=>pe(lt.target.value),onKeyDown:Y,onBlur:Le}):yi(Ie,P?.format)]},B)})]},h))})]})}),je&&!te&&v&&e.jsxs("div",{className:"nice-spreadsheet__context-menu",style:{position:"fixed",left:je.x,top:je.y,zIndex:1e3},children:[e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Fe(v.row),W(null)},children:K("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Fe(v.row+1),W(null)},children:K("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ve(v.col),W(null)},children:K("spreadsheet.insertColLeft","Insert column left")}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ve(v.col+1),W(null)},children:K("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{St(v.row),W(null)},children:K("spreadsheet.deleteRow","Delete row")}),e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Me(v.col),W(null)},children:K("spreadsheet.deleteCol","Delete column")})]}),Xe&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[K("spreadsheet.count","Count"),": ",Xe.count]}),Xe.sum!==void 0&&e.jsxs("span",{children:[K("spreadsheet.sum","Sum"),": ",Xe.sum.toFixed(2)]}),Xe.avg!==void 0&&e.jsxs("span",{children:[K("spreadsheet.avg","Avg"),": ",Xe.avg.toFixed(2)]}),Xe.min!==void 0&&e.jsxs("span",{children:[K("spreadsheet.min","Min"),": ",Xe.min]}),Xe.max!==void 0&&e.jsxs("span",{children:[K("spreadsheet.max","Max"),": ",Xe.max]})]}),u&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",ref:Te,children:[O.map((m,h)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:be===h?e.jsx(Ln.NiceTextInput,{className:"nice-spreadsheet__tab-rename",value:Oe,onChange:R=>le(R),onBlur:()=>dt(h,Oe),onKeyDown:R=>{R.key==="Enter"&&dt(h,Oe),R.key==="Escape"&&we(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{te||(we(h),le(m.name))},children:e.jsx(qe.NiceButton,{variant:h===G?"primary":"ghost",size:"sm",role:"tab","aria-selected":h===G,onClick:()=>st(h),onKeyDown:R=>{R.key==="F2"&&!te&&(R.preventDefault(),we(h),le(m.name))},children:m.name})})},h)),!te&&e.jsxs(e.Fragment,{children:[e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:Tt,title:K("spreadsheet.addSheet","Add sheet"),children:e.jsx(xr,{})}),O.length>1&&e.jsx(qe.NiceButton,{variant:"ghost",size:"sm",onClick:Bt,title:K("spreadsheet.removeSheet","Remove sheet"),children:e.jsx(yr,{})})]})]})]})}),{displayName:"NiceSpreadsheet"}),wr=`
|
|
10
|
-
.nice-reconciliation {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
height: 100%;
|
|
14
|
-
background: var(--nice-bg-primary, #ffffff);
|
|
15
|
-
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
16
|
-
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.nice-reconciliation__toolbar {
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
gap: 0.75rem;
|
|
24
|
-
padding: 0.75rem 1rem;
|
|
25
|
-
background: var(--nice-bg-secondary, #f9fafb);
|
|
26
|
-
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
27
|
-
flex-wrap: wrap;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.nice-reconciliation__toolbar-group {
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: center;
|
|
33
|
-
gap: 0.5rem;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.nice-reconciliation__toolbar-group--end {
|
|
37
|
-
margin-inline-start: auto;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.nice-reconciliation__btn {
|
|
41
|
-
display: inline-flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
gap: 0.375rem;
|
|
44
|
-
padding: 0.375rem 0.75rem;
|
|
45
|
-
font-size: 0.8125rem;
|
|
46
|
-
font-weight: 500;
|
|
47
|
-
border-radius: var(--nice-radius-md, 0.375rem);
|
|
48
|
-
cursor: pointer;
|
|
49
|
-
transition: all 0.15s ease;
|
|
50
|
-
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
51
|
-
background: var(--nice-bg-primary, #ffffff);
|
|
52
|
-
color: var(--nice-text-primary);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.nice-reconciliation__btn:hover {
|
|
56
|
-
background: var(--nice-bg-hover, #f3f4f6);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.nice-reconciliation__btn--primary {
|
|
60
|
-
background: var(--nice-primary, #3b82f6);
|
|
61
|
-
border-color: var(--nice-primary, #3b82f6);
|
|
62
|
-
color: white;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.nice-reconciliation__btn--primary:hover {
|
|
66
|
-
background: var(--nice-primary-dark, #2563eb);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.nice-reconciliation__btn--success {
|
|
70
|
-
background: var(--nice-success, #10b981);
|
|
71
|
-
border-color: var(--nice-success, #10b981);
|
|
72
|
-
color: white;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.nice-reconciliation__btn:disabled {
|
|
76
|
-
opacity: 0.5;
|
|
77
|
-
cursor: not-allowed;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.nice-reconciliation__content {
|
|
81
|
-
display: flex;
|
|
82
|
-
flex: 1;
|
|
83
|
-
overflow: hidden;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.nice-reconciliation--vertical .nice-reconciliation__content {
|
|
87
|
-
flex-direction: column;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.nice-reconciliation__panel {
|
|
91
|
-
flex: 1;
|
|
92
|
-
display: flex;
|
|
93
|
-
flex-direction: column;
|
|
94
|
-
min-width: 0;
|
|
95
|
-
min-height: 0;
|
|
96
|
-
overflow: hidden;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.nice-reconciliation__panel--statements {
|
|
100
|
-
border-inline-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.nice-reconciliation--vertical .nice-reconciliation__panel--statements {
|
|
104
|
-
border-inline-end: none;
|
|
105
|
-
border-block-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.nice-reconciliation__panel-header {
|
|
109
|
-
display: flex;
|
|
110
|
-
align-items: center;
|
|
111
|
-
justify-content: space-between;
|
|
112
|
-
padding: 0.75rem 1rem;
|
|
113
|
-
background: var(--nice-bg-secondary, #f9fafb);
|
|
114
|
-
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.nice-reconciliation__panel-title {
|
|
118
|
-
font-weight: 600;
|
|
119
|
-
font-size: 0.875rem;
|
|
120
|
-
color: var(--nice-text-primary);
|
|
121
|
-
display: flex;
|
|
122
|
-
align-items: center;
|
|
123
|
-
gap: 0.5rem;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.nice-reconciliation__panel-badge {
|
|
127
|
-
font-size: 0.75rem;
|
|
128
|
-
font-weight: 500;
|
|
129
|
-
padding: 0.125rem 0.5rem;
|
|
130
|
-
border-radius: var(--nice-radius-full, 9999px);
|
|
131
|
-
background: var(--nice-bg-tertiary, #e5e7eb);
|
|
132
|
-
color: var(--nice-text-secondary);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.nice-reconciliation__panel-content {
|
|
136
|
-
flex: 1;
|
|
137
|
-
overflow: auto;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.nice-reconciliation__row {
|
|
141
|
-
display: flex;
|
|
142
|
-
align-items: center;
|
|
143
|
-
gap: 0.75rem;
|
|
144
|
-
padding: 0.625rem 1rem;
|
|
145
|
-
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
146
|
-
cursor: pointer;
|
|
147
|
-
user-select: none;
|
|
148
|
-
transition: background 0.1s ease;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.nice-reconciliation__row:hover {
|
|
152
|
-
background: var(--nice-bg-hover, rgba(0, 0, 0, 0.02));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.nice-reconciliation__row--selected {
|
|
156
|
-
background: var(--nice-primary-light, rgba(59, 130, 246, 0.1));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.nice-reconciliation__row--dragging {
|
|
160
|
-
opacity: 0.6;
|
|
161
|
-
background: var(--nice-primary-light, rgba(59, 130, 246, 0.15));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.nice-reconciliation__row--drop-target {
|
|
165
|
-
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
166
|
-
box-shadow: inset 0 0 0 2px var(--nice-success, #10b981);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.nice-reconciliation__row--matched {
|
|
170
|
-
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.nice-reconciliation__row--partial {
|
|
174
|
-
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.08));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.nice-reconciliation__row--unmatched {
|
|
178
|
-
background: transparent;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.nice-reconciliation__row--excluded {
|
|
182
|
-
opacity: 0.5;
|
|
183
|
-
background: var(--nice-bg-tertiary, #f3f4f6);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.nice-reconciliation__status {
|
|
187
|
-
width: 0.5rem;
|
|
188
|
-
height: 0.5rem;
|
|
189
|
-
border-radius: var(--nice-radius-full, 50%);
|
|
190
|
-
flex-shrink: 0;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.nice-reconciliation__status--matched {
|
|
194
|
-
background: var(--nice-success, #10b981);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.nice-reconciliation__status--partial {
|
|
198
|
-
background: var(--nice-warning, #f59e0b);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.nice-reconciliation__status--unmatched {
|
|
202
|
-
background: var(--nice-danger, #ef4444);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.nice-reconciliation__status--excluded {
|
|
206
|
-
background: var(--nice-text-disabled, #9ca3af);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.nice-reconciliation__row-main {
|
|
210
|
-
flex: 1;
|
|
211
|
-
min-width: 0;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.nice-reconciliation__row-date {
|
|
215
|
-
font-size: 0.75rem;
|
|
216
|
-
color: var(--nice-text-secondary);
|
|
217
|
-
margin-bottom: 0.125rem;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.nice-reconciliation__row-description {
|
|
221
|
-
font-size: 0.8125rem;
|
|
222
|
-
color: var(--nice-text-primary);
|
|
223
|
-
white-space: nowrap;
|
|
224
|
-
overflow: hidden;
|
|
225
|
-
text-overflow: ellipsis;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.nice-reconciliation__row-counterparty {
|
|
229
|
-
font-size: 0.75rem;
|
|
230
|
-
color: var(--nice-text-tertiary);
|
|
231
|
-
white-space: nowrap;
|
|
232
|
-
overflow: hidden;
|
|
233
|
-
text-overflow: ellipsis;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.nice-reconciliation__row-amount {
|
|
237
|
-
font-size: 0.875rem;
|
|
238
|
-
font-weight: 600;
|
|
239
|
-
font-variant-numeric: tabular-nums;
|
|
240
|
-
white-space: nowrap;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.nice-reconciliation__row-amount--positive {
|
|
244
|
-
color: var(--nice-success, #10b981);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.nice-reconciliation__row-amount--negative {
|
|
248
|
-
color: var(--nice-danger, #ef4444);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.nice-reconciliation__confidence {
|
|
252
|
-
display: flex;
|
|
253
|
-
align-items: center;
|
|
254
|
-
gap: 0.25rem;
|
|
255
|
-
font-size: 0.6875rem;
|
|
256
|
-
padding: 0.125rem 0.375rem;
|
|
257
|
-
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.nice-reconciliation__confidence--high {
|
|
261
|
-
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
262
|
-
color: var(--nice-success-dark, #059669);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.nice-reconciliation__confidence--medium {
|
|
266
|
-
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.15));
|
|
267
|
-
color: var(--nice-warning-dark, #d97706);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.nice-reconciliation__confidence--low {
|
|
271
|
-
background: var(--nice-danger-bg, rgba(239, 68, 68, 0.15));
|
|
272
|
-
color: var(--nice-danger-dark, #dc2626);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.nice-reconciliation__empty {
|
|
276
|
-
display: flex;
|
|
277
|
-
flex-direction: column;
|
|
278
|
-
align-items: center;
|
|
279
|
-
justify-content: center;
|
|
280
|
-
padding: 3rem 1rem;
|
|
281
|
-
color: var(--nice-text-secondary);
|
|
282
|
-
text-align: center;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.nice-reconciliation__empty-icon {
|
|
286
|
-
font-size: 2.5rem;
|
|
287
|
-
margin-bottom: 0.75rem;
|
|
288
|
-
opacity: 0.5;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
.nice-reconciliation__summary {
|
|
292
|
-
display: flex;
|
|
293
|
-
align-items: center;
|
|
294
|
-
gap: 1.5rem;
|
|
295
|
-
padding: 0.75rem 1rem;
|
|
296
|
-
background: var(--nice-bg-secondary, #f9fafb);
|
|
297
|
-
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
298
|
-
font-size: 0.8125rem;
|
|
299
|
-
flex-wrap: wrap;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
.nice-reconciliation__summary-item {
|
|
303
|
-
display: flex;
|
|
304
|
-
align-items: center;
|
|
305
|
-
gap: 0.375rem;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.nice-reconciliation__summary-label {
|
|
309
|
-
color: var(--nice-text-secondary);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
.nice-reconciliation__summary-value {
|
|
313
|
-
font-weight: 600;
|
|
314
|
-
color: var(--nice-text-primary);
|
|
315
|
-
font-variant-numeric: tabular-nums;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.nice-reconciliation__summary-value--success {
|
|
319
|
-
color: var(--nice-success, #10b981);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
.nice-reconciliation__summary-value--warning {
|
|
323
|
-
color: var(--nice-warning, #f59e0b);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
.nice-reconciliation__summary-value--danger {
|
|
327
|
-
color: var(--nice-danger, #ef4444);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
.nice-reconciliation__resizer {
|
|
331
|
-
width: 4px;
|
|
332
|
-
background: var(--nice-border-color, #e5e7eb);
|
|
333
|
-
cursor: col-resize;
|
|
334
|
-
transition: background 0.15s ease;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
.nice-reconciliation__resizer:hover {
|
|
338
|
-
background: var(--nice-primary, #3b82f6);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.nice-reconciliation--vertical .nice-reconciliation__resizer {
|
|
342
|
-
width: 100%;
|
|
343
|
-
height: 4px;
|
|
344
|
-
cursor: row-resize;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.nice-reconciliation__suggestions {
|
|
348
|
-
padding: 0.75rem 1rem;
|
|
349
|
-
background: var(--nice-info-bg, rgba(59, 130, 246, 0.08));
|
|
350
|
-
border-bottom: 1px solid var(--nice-info, #3b82f6);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
.nice-reconciliation__suggestion {
|
|
354
|
-
display: flex;
|
|
355
|
-
align-items: center;
|
|
356
|
-
gap: 0.75rem;
|
|
357
|
-
padding: 0.5rem;
|
|
358
|
-
background: var(--nice-bg-primary, #ffffff);
|
|
359
|
-
border-radius: var(--nice-radius-md, 0.375rem);
|
|
360
|
-
margin-bottom: 0.5rem;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
.nice-reconciliation__suggestion:last-child {
|
|
364
|
-
margin-bottom: 0;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/* Dark mode */
|
|
368
|
-
.dark .nice-reconciliation {
|
|
369
|
-
background: var(--nice-bg-primary-dark, #111827);
|
|
370
|
-
border-color: var(--nice-border-color-dark, #374151);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
.dark .nice-reconciliation__toolbar,
|
|
374
|
-
.dark .nice-reconciliation__panel-header,
|
|
375
|
-
.dark .nice-reconciliation__summary {
|
|
376
|
-
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
377
|
-
border-color: var(--nice-border-color-dark, #374151);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
.dark .nice-reconciliation__row--selected {
|
|
381
|
-
background: var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2));
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/* RTL support */
|
|
385
|
-
[dir="rtl"] .nice-reconciliation__row-amount {
|
|
386
|
-
direction: ltr;
|
|
387
|
-
text-align: left;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/* Detail Panel */
|
|
391
|
-
.nice-reconciliation__detail-panel {
|
|
392
|
-
position: fixed;
|
|
393
|
-
inset-inline-end: 0;
|
|
394
|
-
top: 0;
|
|
395
|
-
bottom: 0;
|
|
396
|
-
width: 420px;
|
|
397
|
-
max-width: 90vw;
|
|
398
|
-
background: var(--nice-bg-primary, #ffffff);
|
|
399
|
-
box-shadow: -4px 0 24px var(--nice-overlay-15, rgba(0, 0, 0, 0.15));
|
|
400
|
-
z-index: 1000;
|
|
401
|
-
display: flex;
|
|
402
|
-
flex-direction: column;
|
|
403
|
-
transform: translateX(100%);
|
|
404
|
-
transition: transform 0.25s ease-out;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
.nice-reconciliation__detail-panel--open {
|
|
408
|
-
transform: translateX(0);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
.nice-reconciliation__detail-header {
|
|
412
|
-
display: flex;
|
|
413
|
-
align-items: center;
|
|
414
|
-
justify-content: space-between;
|
|
415
|
-
padding: 1rem;
|
|
416
|
-
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
417
|
-
background: var(--nice-bg-secondary, #f9fafb);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
.nice-reconciliation__detail-title {
|
|
421
|
-
font-weight: 600;
|
|
422
|
-
font-size: 1rem;
|
|
423
|
-
color: var(--nice-text-primary);
|
|
424
|
-
display: flex;
|
|
425
|
-
align-items: center;
|
|
426
|
-
gap: 0.5rem;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
.nice-reconciliation__detail-close {
|
|
430
|
-
width: 2rem;
|
|
431
|
-
height: 2rem;
|
|
432
|
-
display: flex;
|
|
433
|
-
align-items: center;
|
|
434
|
-
justify-content: center;
|
|
435
|
-
background: transparent;
|
|
436
|
-
border: none;
|
|
437
|
-
cursor: pointer;
|
|
438
|
-
font-size: 1.25rem;
|
|
439
|
-
color: var(--nice-text-secondary);
|
|
440
|
-
border-radius: var(--nice-radius-md, 0.375rem);
|
|
441
|
-
transition: all 0.15s ease;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
.nice-reconciliation__detail-close:hover {
|
|
445
|
-
background: var(--nice-bg-hover, #f3f4f6);
|
|
446
|
-
color: var(--nice-text-primary);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
.nice-reconciliation__detail-content {
|
|
450
|
-
flex: 1;
|
|
451
|
-
overflow: auto;
|
|
452
|
-
padding: 1rem;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
.nice-reconciliation__detail-section {
|
|
456
|
-
margin-bottom: 1.5rem;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
.nice-reconciliation__detail-section-title {
|
|
460
|
-
font-weight: 600;
|
|
461
|
-
font-size: 0.875rem;
|
|
462
|
-
color: var(--nice-text-primary);
|
|
463
|
-
margin-bottom: 0.75rem;
|
|
464
|
-
display: flex;
|
|
465
|
-
align-items: center;
|
|
466
|
-
gap: 0.375rem;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
.nice-reconciliation__detail-row {
|
|
470
|
-
display: flex;
|
|
471
|
-
justify-content: space-between;
|
|
472
|
-
align-items: flex-start;
|
|
473
|
-
padding: 0.5rem 0;
|
|
474
|
-
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
.nice-reconciliation__detail-row:last-child {
|
|
478
|
-
border-bottom: none;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
.nice-reconciliation__detail-label {
|
|
482
|
-
font-size: 0.8125rem;
|
|
483
|
-
color: var(--nice-text-secondary);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
.nice-reconciliation__detail-value {
|
|
487
|
-
font-size: 0.8125rem;
|
|
488
|
-
font-weight: 500;
|
|
489
|
-
color: var(--nice-text-primary);
|
|
490
|
-
text-align: end;
|
|
491
|
-
max-width: 60%;
|
|
492
|
-
word-break: break-word;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
.nice-reconciliation__detail-divider {
|
|
496
|
-
height: 1px;
|
|
497
|
-
background: var(--nice-border-color, #e5e7eb);
|
|
498
|
-
margin: 1rem 0;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
.nice-reconciliation__detail-match-info {
|
|
502
|
-
padding: 0.75rem;
|
|
503
|
-
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
504
|
-
border-radius: var(--nice-radius-md, 0.375rem);
|
|
505
|
-
margin-bottom: 1rem;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
.nice-reconciliation__detail-match-header {
|
|
509
|
-
display: flex;
|
|
510
|
-
align-items: center;
|
|
511
|
-
gap: 0.5rem;
|
|
512
|
-
font-weight: 600;
|
|
513
|
-
font-size: 0.8125rem;
|
|
514
|
-
color: var(--nice-success-dark, #059669);
|
|
515
|
-
margin-bottom: 0.5rem;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
.nice-reconciliation__detail-match-detail {
|
|
519
|
-
font-size: 0.75rem;
|
|
520
|
-
color: var(--nice-text-secondary);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
.nice-reconciliation__detail-side-by-side {
|
|
524
|
-
display: grid;
|
|
525
|
-
grid-template-columns: 1fr 1fr;
|
|
526
|
-
gap: 1rem;
|
|
527
|
-
padding: 0.75rem;
|
|
528
|
-
background: var(--nice-bg-secondary, #f9fafb);
|
|
529
|
-
border-radius: var(--nice-radius-md, 0.375rem);
|
|
530
|
-
margin-top: 0.75rem;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
.nice-reconciliation__detail-side-item {
|
|
534
|
-
padding: 0.5rem;
|
|
535
|
-
background: var(--nice-bg-primary, #ffffff);
|
|
536
|
-
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
537
|
-
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
.nice-reconciliation__detail-side-label {
|
|
541
|
-
font-size: 0.6875rem;
|
|
542
|
-
font-weight: 500;
|
|
543
|
-
text-transform: uppercase;
|
|
544
|
-
color: var(--nice-text-tertiary);
|
|
545
|
-
margin-bottom: 0.375rem;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
.nice-reconciliation__detail-side-amount {
|
|
549
|
-
font-size: 1.125rem;
|
|
550
|
-
font-weight: 600;
|
|
551
|
-
font-variant-numeric: tabular-nums;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
.nice-reconciliation__detail-backdrop {
|
|
555
|
-
position: fixed;
|
|
556
|
-
inset: 0;
|
|
557
|
-
background: var(--nice-overlay-30, rgba(0, 0, 0, 0.3));
|
|
558
|
-
z-index: 999;
|
|
559
|
-
opacity: 0;
|
|
560
|
-
pointer-events: none;
|
|
561
|
-
transition: opacity 0.2s ease;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
.nice-reconciliation__detail-backdrop--visible {
|
|
565
|
-
opacity: 1;
|
|
566
|
-
pointer-events: auto;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
.dark .nice-reconciliation__detail-panel {
|
|
570
|
-
background: var(--nice-bg-primary-dark, #111827);
|
|
571
|
-
box-shadow: -4px 0 24px var(--nice-overlay-40, rgba(0, 0, 0, 0.4));
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
.dark .nice-reconciliation__detail-header {
|
|
575
|
-
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
576
|
-
border-color: var(--nice-border-color-dark, #374151);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
.dark .nice-reconciliation__detail-side-by-side {
|
|
580
|
-
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
.dark .nice-reconciliation__detail-side-item {
|
|
584
|
-
background: var(--nice-bg-primary-dark, #111827);
|
|
585
|
-
border-color: var(--nice-border-color-dark, #374151);
|
|
586
|
-
}
|
|
587
|
-
`;function It(t,a="PLN",s="pl-PL"){return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}function xn(t,a="pl-PL"){return t?(typeof t=="string"?new Date(t):t).toLocaleDateString(a,{year:"numeric",month:"2-digit",day:"2-digit"}):"-"}function Nr(t){return t>=80?"high":t>=50?"medium":"low"}function jr(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function ki(t){t?.querySelector('[role="option"][tabindex="0"]')?.focus()}function Ii(t,a,s){t.target===t.currentTarget&&(t.key===" "||t.key==="Enter"&&!s?(t.preventDefault(),a()):t.key==="Enter"&&s&&(t.preventDefault(),s()))}function Sr({item:t,isSelected:a,isDragging:s,isDropTarget:c,suggestion:l,currency:d,locale:u,onSelect:o,onDoubleClick:g,onDragStart:f,onDragEnd:S,onDrop:E,disabled:$}){const z=t.status??"unmatched",b=l?.confidence??t.confidence,D=y=>{y.dataTransfer.setData("text/plain",t.id),y.dataTransfer.setData("source","statement"),y.dataTransfer.effectAllowed="move",f()},p=y=>{y.dataTransfer.types.includes("source")&&y.dataTransfer.getData("source")!=="statement"&&y.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${z} ${a?"nice-reconciliation__row--selected":""} ${s?"nice-reconciliation__row--dragging":""} ${c?"nice-reconciliation__row--drop-target":""}`,draggable:!$&&z!=="matched",onDragStart:D,onDragEnd:S,onDragOver:p,onDrop:E,onClick:o,onDoubleClick:g,onKeyDown:y=>Ii(y,o,g),role:"option","aria-selected":a,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${z}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsx("div",{className:"nice-reconciliation__row-date",children:xn(t.date,u)}),e.jsx("div",{className:"nice-reconciliation__row-description",title:t.description,children:t.description}),t.counterparty&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:t.counterparty})]}),b!=null&&e.jsxs("span",{className:`nice-reconciliation__confidence nice-reconciliation__confidence--${Nr(b)}`,children:[b,"%"]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${t.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:It(t.amount,d,u)})]})}function Cr({item:t,isSelected:a,isDragging:s,isDropTarget:c,currency:l,locale:d,onSelect:u,onDoubleClick:o,onDragStart:g,onDragEnd:f,onDrop:S,disabled:E}){const $=t.status??"unmatched",z=D=>{D.dataTransfer.setData("text/plain",t.id),D.dataTransfer.setData("source","entry"),D.dataTransfer.effectAllowed="move",g()},b=D=>{D.dataTransfer.types.includes("source")&&D.dataTransfer.getData("source")!=="entry"&&D.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${$} ${a?"nice-reconciliation__row--selected":""} ${s?"nice-reconciliation__row--dragging":""} ${c?"nice-reconciliation__row--drop-target":""}`,draggable:!E&&$!=="matched",onDragStart:z,onDragEnd:f,onDragOver:b,onDrop:S,onClick:u,onDoubleClick:o,onKeyDown:D=>Ii(D,u,o),role:"option","aria-selected":a,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${$}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsxs("div",{className:"nice-reconciliation__row-date",children:[xn(t.date,d),t.documentNumber&&e.jsxs("span",{children:[" · ",t.documentNumber]})]}),e.jsx("div",{className:"nice-reconciliation__row-description",title:t.description,children:t.description}),t.partyName&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:t.partyName})]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${t.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:It(t.amount,l,d)})]})}const Dr=n.forwardRef(function(a,s){const{t:c}=N.useNiceTranslation(),{statements:l,bankTransactions:d,entries:u,accountingEntries:o,matches:g,defaultMatches:f=[],suggestions:S=[],config:E={},currency:$,showConfidence:z,statementPanelConfig:b,entryPanelConfig:D,onMatch:p,onAutoMatch:y,onUnmatch:I,onBatchAction:x,onFilterChange:L,onRequestSuggestions:M,onSelectionChange:F,onComplete:H,size:xe="medium",showToolbar:se=!0,showFilters:_e=!0,showSummary:De=!0,showSuggestions:te=!0,layout:Re="horizontal",enableDragDrop:K=!0,enableKeyboard:Qe=!0,enableDetailPanel:ze=!0,loading:$e=!1,disabled:ce=!1,readOnly:O=!1,locale:G="pl-PL",labels:w={},className:v,style:de}=a,re=n.useMemo(()=>l??d??[],[l,d]),j=n.useMemo(()=>u??o??[],[u,o]),he=$??E.currency??"PLN",[fe,ye]=n.useState(f),[A,oe]=n.useState(new Set),[pe,Be]=n.useState(new Set),[ue,Ae]=n.useState(null),[ke,Ke]=n.useState(null),[Ue,it]=n.useState({}),[at,rt]=n.useState(null),je=g??fe,W=n.useRef(null),be=n.useRef(null),we={orientation:"vertical",pageSize:10};N.useRovingFocus(W,we),N.useRovingFocus(be,we),n.useEffect(()=>{const r="nice-reconciliation-styles";if(!document.getElementById(r)){const C=document.createElement("style");C.id=r,C.textContent=wr,document.head.appendChild(C)}},[]);const Te=n.useMemo(()=>{const r=new Set;return je.forEach(C=>C.statementIds.forEach(Q=>r.add(Q))),r},[je]),Oe=n.useMemo(()=>{const r=new Set;return je.forEach(C=>C.entryIds.forEach(Q=>r.add(Q))),r},[je]),le=n.useMemo(()=>{const r=re.filter(Y=>!Te.has(Y.id)),C=j.filter(Y=>!Oe.has(Y.id)),Q=re.reduce((Y,me)=>Y+me.amount,0),J=j.reduce((Y,me)=>Y+me.amount,0),Le=re.filter(Y=>Te.has(Y.id)).reduce((Y,me)=>Y+me.amount,0);return{totalStatements:re.length,totalEntries:j.length,matchedStatements:re.length-r.length,matchedEntries:j.length-C.length,unmatchedStatements:r.length,unmatchedEntries:C.length,statementTotal:Q,entryTotal:J,matchedAmount:Le,unmatchedStatementAmount:r.reduce((Y,me)=>Y+me.amount,0),unmatchedEntryAmount:C.reduce((Y,me)=>Y+me.amount,0),difference:Q-J,matchPercentage:re.length>0?Math.round((re.length-r.length)/re.length*100):0,matchCount:je.length,partialMatchCount:je.filter(Y=>Y.status==="partial").length,pendingSuggestions:S.length}},[re,j,je,S,Te,Oe]),X=n.useCallback((r,C)=>{const Q=re.filter(Fe=>r.includes(Fe.id)),J=j.filter(Fe=>C.includes(Fe.id));if(Q.length===0||J.length===0)return null;const Le=Q.reduce((Fe,Ve)=>Fe+Ve.amount,0),Y=J.reduce((Fe,Ve)=>Fe+Ve.amount,0),me=Math.abs(Le-Y),ne=E.amountTolerance??.01,tt={id:jr(),statementIds:r,entryIds:C,status:me<=ne?"matched":"partial",statementTotal:Le,entryTotal:Y,difference:me,confidence:me<=ne?100:Math.max(0,100-me/Math.max(Math.abs(Le),1)*100),matchedBy:"user",matchedAt:new Date};return g||ye(Fe=>[...Fe,tt]),p?.(tt,Q,J),oe(new Set),Be(new Set),tt},[re,j,E.amountTolerance,g,p]),bt=n.useCallback(r=>{const C=je.find(Q=>Q.id===r);C&&(g||ye(Q=>Q.filter(J=>J.id!==r)),I?.(r,C.statementIds,C.entryIds))},[je,g,I]),mt=n.useCallback(async()=>{const r=[],C=new Set(Te),Q=new Set(Oe),J=E.amountTolerance??.01,Le=E.dateTolerance??3;for(const Y of re){if(C.has(Y.id))continue;const me=j.filter(ne=>{if(Q.has(ne.id)||Math.abs(Y.amount-ne.amount)>J)return!1;const Fe=new Date(Y.date),Ve=new Date(ne.date);return!(Math.abs(Fe.getTime()-Ve.getTime())/(1e3*60*60*24)>Le)});if(me.length===1){const ne=me[0],tt=X([Y.id],[ne.id]);tt&&(r.push(tt),C.add(Y.id),Q.add(ne.id))}}return x?.("autoMatch",r),r},[re,j,Te,Oe,E,X,x]),Ne=n.useCallback((r,C,Q,J)=>{J!==C&&(J==="statement"?X([Q],[r]):X([r],[Q]),Ae(null),Ke(null))},[X]),jt=n.useCallback(()=>{const r=Array.from(A),C=Array.from(pe);r.length>0&&C.length>0&&X(r,C)},[A,pe,X]);n.useEffect(()=>{F?.(Array.from(A),Array.from(pe))},[A,pe,F]),n.useImperativeHandle(s,()=>({getMatches:()=>je,getUnmatchedStatements:()=>re.filter(r=>!Te.has(r.id)),getUnmatchedEntries:()=>j.filter(r=>!Oe.has(r.id)),createMatch:X,removeMatch:bt,autoMatch:mt,getSuggestions:async r=>M?M(r??re.filter(C=>!Te.has(C.id)).map(C=>C.id)):[],applySuggestion:r=>X([r.statementId],r.entryIds),approveAll:()=>{x?.("approveAll",je)},clearAll:()=>{g||ye([]),x?.("clearAll",[])},exportMatched:r=>{x?.("exportMatched",je)},getSummary:()=>le,reset:()=>{g||ye([]),oe(new Set),Be(new Set),it({})},focusStatements:()=>ki(W.current),focusEntries:()=>ki(be.current)}),[je,re,j,Te,Oe,X,bt,mt,M,x,g,le]);const et=n.useMemo(()=>re.filter(r=>{if(Ue.status&&Ue.status.length>0){const C=Te.has(r.id)?"matched":"unmatched";if(!Ue.status.includes(C))return!1}if(Ue.searchText){const C=Ue.searchText.toLowerCase();if(!r.description?.toLowerCase().includes(C)&&!r.counterparty?.toLowerCase().includes(C))return!1}return!0}),[re,Ue,Te]),st=n.useMemo(()=>j.filter(r=>{if(Ue.status&&Ue.status.length>0){const C=Oe.has(r.id)?"matched":"unmatched";if(!Ue.status.includes(C))return!1}if(Ue.searchText){const C=Ue.searchText.toLowerCase();if(!r.description?.toLowerCase().includes(C)&&!r.partyName?.toLowerCase().includes(C))return!1}return!0}),[j,Ue,Oe]),xt=A.size>0&&pe.size>0&&!O&&!ce;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${Re} ${v??""}`,style:de,children:[se&&e.jsxs("div",{className:"nice-reconciliation__toolbar",children:[e.jsxs("div",{className:"nice-reconciliation__toolbar-group",children:[e.jsxs("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--primary",onClick:mt,disabled:ce||O||$e,children:[e.jsx(N.NiceIcon,{name:"zap",size:14})," ",w.autoMatch??c("reconciliationView.autoMatch","Auto-match")]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:jt,disabled:!xt||$e,children:[e.jsx(N.NiceIcon,{name:"link",size:14})," ",c("reconciliationView.matchSelected","Match Selected")]})]}),e.jsxs("div",{className:"nice-reconciliation__toolbar-group nice-reconciliation__toolbar-group--end",children:[e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>x?.("approveAll",je),disabled:je.length===0||ce||$e,children:[e.jsx(N.NiceIcon,{name:"check",size:14})," ",w.approveAll??c("reconciliationView.approveAll","Approve All")]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{g||ye([]),x?.("clearAll",[])},disabled:je.length===0||ce||O||$e,children:[e.jsx(N.NiceIcon,{name:"close",size:14})," ",w.clearAll??c("reconciliationView.clearAll","Clear All")]})]})]}),e.jsxs("div",{className:"nice-reconciliation__content",children:[e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--statements",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:[e.jsx(N.NiceIcon,{name:"file",size:14})," ",w.statementPanelTitle??c("reconciliationView.bankStatement","Bank Statement"),e.jsx("span",{className:"nice-reconciliation__panel-badge",children:et.length})]})}),e.jsx("div",{ref:W,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:et.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(N.NiceIcon,{name:"clipboard",size:32})}),w.noStatements??c("reconciliationView.noStatementItems","No statement items")]}):et.map(r=>e.jsx(Sr,{item:{...r,status:Te.has(r.id)?"matched":"unmatched"},isSelected:A.has(r.id),isDragging:ue===r.id,isDropTarget:ke===r.id,suggestion:S.find(C=>C.statementId===r.id),currency:he,locale:G,onSelect:()=>{ce||oe(C=>{const Q=new Set(C);return Q.has(r.id)?Q.delete(r.id):Q.add(r.id),Q})},onDoubleClick:ze?()=>rt({type:"statement",id:r.id}):void 0,onDragStart:()=>Ae(r.id),onDragEnd:()=>{Ae(null),Ke(null)},onDrop:()=>{ue&&ue!==r.id&&Ne(r.id,"statement",ue,"entry")},disabled:ce||O||!K},r.id))})]}),e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--entries",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:[e.jsx(N.NiceIcon,{name:"book",size:14})," ",w.entryPanelTitle??c("reconciliationView.bookEntries","Book Entries"),e.jsx("span",{className:"nice-reconciliation__panel-badge",children:st.length})]})}),e.jsx("div",{ref:be,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:st.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(N.NiceIcon,{name:"book",size:32})}),w.noEntries??c("reconciliationView.noBookEntries","No book entries")]}):st.map(r=>e.jsx(Cr,{item:{...r,status:Oe.has(r.id)?"matched":"unmatched"},isSelected:pe.has(r.id),isDragging:ue===r.id,isDropTarget:ke===r.id,currency:he,locale:G,onSelect:()=>{ce||Be(C=>{const Q=new Set(C);return Q.has(r.id)?Q.delete(r.id):Q.add(r.id),Q})},onDoubleClick:ze?()=>rt({type:"entry",id:r.id}):void 0,onDragStart:()=>Ae(r.id),onDragEnd:()=>{Ae(null),Ke(null)},onDrop:()=>{ue&&ue!==r.id&&Ne(r.id,"entry",ue,"statement")},disabled:ce||O||!K},r.id))})]})]}),De&&e.jsxs("div",{className:"nice-reconciliation__summary",children:[e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:c("reconciliationView.matched","Matched:")}),e.jsxs("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--success",children:[le.matchedStatements,"/",le.totalStatements," (",le.matchPercentage,"%)"]})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:c("reconciliationView.matchedAmount","Matched Amount:")}),e.jsx("span",{className:"nice-reconciliation__summary-value",children:It(le.matchedAmount,he,G)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:c("reconciliationView.unmatched","Unmatched:")}),e.jsx("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--warning",children:It(le.unmatchedStatementAmount,he,G)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:c("reconciliationView.difference","Difference:")}),e.jsx("span",{className:`nice-reconciliation__summary-value ${Math.abs(le.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:It(le.difference,he,G)})]})]}),ze&&e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:`nice-reconciliation__detail-backdrop ${at?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>rt(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${at?"nice-reconciliation__detail-panel--open":""}`,children:at&&e.jsx(Mr,{type:at.type,id:at.id,statements:re,entries:j,matches:je,currency:he,locale:G,labels:w,onClose:()=>rt(null)})})]})]})});function Mr({type:t,id:a,statements:s,entries:c,matches:l,currency:d,locale:u,labels:o,onClose:g}){const{t:f}=N.useNiceTranslation(),S=t==="statement"?s.find(p=>p.id===a):c.find(p=>p.id===a),E=t==="statement"?l.find(p=>p.statementIds.includes(a)):l.find(p=>p.entryIds.includes(a)),$=E?t==="statement"?c.filter(p=>E.entryIds.includes(p.id)):s.filter(p=>E.statementIds.includes(p.id)):[];if(!S)return null;const z=t==="statement",b=z?S:null,D=z?null:S;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-reconciliation__detail-header",children:[e.jsxs("span",{className:"nice-reconciliation__detail-title",children:[e.jsx(N.NiceIcon,{name:z?"file":"book",size:14})," ",z?o.statementDetails??f("reconciliationView.transactionDetails","Transaction Details"):o.entryDetails??f("reconciliationView.entryDetails","Entry Details")]}),e.jsx("button",{type:"button",className:"nice-reconciliation__detail-close",onClick:g,"aria-label":f("reconciliationView.close","Close"),children:e.jsx(N.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-reconciliation__detail-content",children:[E&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:[e.jsx(N.NiceIcon,{name:"check",size:14})," ",f("reconciliationView.matchedConfidence","{label} ({confidence}% confidence)").replace("{label}",o.matchedWith??f("reconciliationView.matched2","Matched")).replace("{confidence}",String(E.confidence?.toFixed(0)??100))]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:E.matchedBy==="ai"?o.matchedByAI??f("reconciliationView.matchedAutomaticallyByAi","Matched automatically by AI"):o.matchedManually??f("reconciliationView.matchedManually","Matched manually")}),e.jsxs("div",{className:"nice-reconciliation__detail-side-by-side",children:[e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:o.statementTotal??f("reconciliationView.statement","Statement")}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${E.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:It(E.statementTotal,d,u)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:o.entryTotal??f("reconciliationView.bookEntry","Book Entry")}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${E.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:It(E.entryTotal,d,u)})]})]}),E.difference>.01&&e.jsxs("div",{className:"nice-reconciliation__detail-row",style:{marginTop:"0.5rem",borderBottom:"none"},children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.difference??f("reconciliationView.difference2","Difference"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{color:"var(--nice-warning, #f59e0b)"},children:It(E.difference,d,u)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(N.NiceIcon,{name:"clipboard",size:14})," ",z?o.transactionInfo??f("reconciliationView.transactionInformation","Transaction Information"):o.entryInfo??f("reconciliationView.entryInformation","Entry Information")]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.date??f("reconciliationView.date","Date"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:xn(S.date,u)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.description??f("reconciliationView.description","Description"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:S.description})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.amount??f("reconciliationView.amount","Amount"),":"]}),e.jsx("span",{className:`nice-reconciliation__detail-value ${S.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:It(S.amount,d,u)})]}),z&&b?.counterparty&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.counterparty??f("reconciliationView.counterparty","Counterparty"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:b.counterparty})]}),z&&b?.counterpartyAccount&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.accountNumber??f("reconciliationView.account","Account"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:b.counterpartyAccount})]}),!z&&D?.partyName&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.party??f("reconciliationView.party","Party"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:D.partyName})]}),!z&&D?.documentNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.documentRef??f("reconciliationView.documentRef","Document Ref"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:D.documentNumber})]}),z&&b?.referenceNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.reference??f("reconciliationView.reference","Reference"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:b.referenceNumber})]})]}),$.length>0&&e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(N.NiceIcon,{name:"link",size:14})," ",z?o.matchedEntries??f("reconciliationView.matchedEntries","Matched Entries"):o.matchedStatements??f("reconciliationView.matchedStatements","Matched Statements")]}),$.map(p=>e.jsxs("div",{style:{padding:"0.5rem",background:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.25rem",marginBottom:"0.5rem",fontSize:"0.8125rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.25rem"},children:p.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:xn(p.date,u)}),e.jsx("span",{style:{fontWeight:600,color:p.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:It(p.amount,d,u)})]})]},p.id))]})]})]})}const Ir=[],Er=({queries:t=Ir,currentFilter:a,currentColumns:s,currentSort:c,onLoad:l,onSave:d,onUpdate:u,onDelete:o,onShare:g,onSetDefault:f,allowSharing:S=!0,allowPinning:E=!0,position:$="dropdown",className:z,style:b,"data-testid":D})=>{const{t:p}=N.useNiceTranslation(),[y,I]=n.useState(!1),[x,L]=n.useState(""),[M,F]=n.useState(!1),[H,xe]=n.useState(""),[se,_e]=n.useState(""),[De,te]=n.useState(!1),Re=n.useRef(null);N.useOverlayFocus(Re,{open:y,modal:!1,onClose:()=>I(!1)});const K=t.filter(O=>O.name.toLowerCase().includes(x.toLowerCase())),Qe=K.filter(O=>!O.isShared),ze=K.filter(O=>O.isShared),$e=async()=>{if(H.trim()){F(!0);try{await d({name:H,description:se||void 0,filter:a??{},columns:s,sort:c}),te(!1),xe(""),_e("")}finally{F(!1)}}},ce=O=>e.jsxs("div",{className:"nice-saved-query__item",children:[O.icon&&e.jsx("span",{className:"nice-saved-query__icon","aria-hidden":"true",children:O.icon}),e.jsx("span",{className:"nice-saved-query__name",children:O.name}),O.isDefault&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--default",children:p("savedQuery.default","default")}),O.isShared&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--shared",children:p("savedQuery.shared","shared")}),O.isPinned&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--pinned",children:p("savedQuery.pinned","pinned")}),e.jsxs("div",{className:"nice-saved-query__actions",children:[e.jsx("button",{onClick:()=>{l(O),I(!1)},type:"button",children:p("savedQuery.load","Load")}),f&&e.jsx("button",{onClick:()=>f(O.id),type:"button",title:p("savedQuery.setDefault","Set as default"),"aria-label":p("savedQuery.setDefault","Set as default"),children:e.jsx(N.NiceIcon,{name:"star",size:14})}),S&&g&&e.jsx("button",{onClick:()=>g(O.id,[]),type:"button",title:p("savedQuery.share","Share"),"aria-label":p("savedQuery.share","Share"),children:e.jsx(N.NiceIcon,{name:"external-link",size:14})}),E&&e.jsx("button",{onClick:()=>u(O.id,{...O}),type:"button",title:p("savedQuery.pin","Pin"),"aria-label":p("savedQuery.pin","Pin"),children:e.jsx(N.NiceIcon,{name:"map-pin",size:14})}),e.jsx("button",{onClick:()=>o(O.id),type:"button",title:p("savedQuery.remove","Remove"),"aria-label":`${p("savedQuery.removeQuery","Remove query")} ${O.name}`,children:e.jsx(N.NiceIcon,{name:"close",size:14})})]})]},O.id);return e.jsxs("div",{className:`nice-saved-query nice-saved-query--${$} ${y?"nice-saved-query--open":""} ${z??""}`,style:b,"data-testid":D,children:[e.jsx("button",{className:"nice-saved-query__trigger",onClick:()=>I(O=>!O),"aria-expanded":y,"aria-haspopup":"dialog",type:"button",children:p("savedQuery.trigger","Views and queries")}),y&&e.jsxs("div",{ref:Re,className:"nice-saved-query__panel",role:"dialog","aria-label":p("savedQuery.manage","Manage saved queries"),children:[e.jsxs("div",{className:"nice-saved-query__search-row",children:[e.jsx("input",{type:"search",placeholder:p("savedQuery.searchPlaceholder","Search queries…"),value:x,onChange:O=>L(O.target.value),"aria-label":p("savedQuery.search","Search queries")}),e.jsxs("button",{onClick:()=>te(O=>!O),type:"button",children:[e.jsx(N.NiceIcon,{name:"plus",size:12})," ",p("savedQuery.saveCurrent","Save current view")]})]}),De&&e.jsxs("div",{className:"nice-saved-query__save-form",children:[e.jsx("input",{type:"text",placeholder:p("savedQuery.name","Query name"),value:H,onChange:O=>xe(O.target.value),"aria-label":p("savedQuery.name","Query name")}),e.jsx("input",{type:"text",placeholder:p("savedQuery.descriptionPlaceholder","Description (optional)"),value:se,onChange:O=>_e(O.target.value),"aria-label":p("savedQuery.description","Query description")}),e.jsx("button",{onClick:$e,disabled:M||!H.trim(),type:"button",children:M?p("savedQuery.saving","Saving…"):p("savedQuery.save","Save")}),e.jsx("button",{onClick:()=>te(!1),type:"button",children:p("savedQuery.cancel","Cancel")})]}),Qe.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-mine",children:[e.jsx("h3",{id:"nice-saved-query-mine",className:"nice-saved-query__group-title",children:p("savedQuery.mine","Mine")}),Qe.map(ce)]}),ze.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-shared",children:[e.jsx("h3",{id:"nice-saved-query-shared",className:"nice-saved-query__group-title",children:p("savedQuery.sharedSection","Shared")}),ze.map(ce)]}),K.length===0&&e.jsx("p",{className:"nice-saved-query__empty",children:p("savedQuery.empty","No saved queries")})]})]})};exports.NICE_TREE_ROW_MIME=Si;exports.NiceDataGridAI=na;exports.NiceHighlight=Bn;exports.NiceKanbanBoard=Ka;exports.NiceList=Ia;exports.NiceModuleGrid=sr;exports.NiceReconciliationView=Dr;exports.NiceSavedQueryPanel=Er;exports.NiceSpreadsheet=kr;exports.NiceTable=Aa;exports.NiceTileView=za;exports.NiceTreeGrid=va;exports.NiceTreeList=Sa;exports.NiceTreeView=Da;exports.treeDropPosition=Vn;exports.treeKeyboardMove=Qn;exports.treeKeyboardTarget=qn;exports.useTreeRowDrop=Yn;
|