@ishibashi0112/spreadsheet-grid 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useFilterPopoverController.d.ts +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1754 -1684
- package/dist/logic/dateFilterCondition.d.ts +4 -3
- package/dist/logic/dateFilterPresets.d.ts +13 -0
- package/dist/logic/filterPopoverLayout.d.ts +17 -0
- package/dist/logic/filterSummary.d.ts +2 -1
- package/dist/logic/filtering.d.ts +4 -3
- package/dist/model/gridTypes.d.ts +12 -1
- package/dist/style.css +1 -1
- package/dist/view/ColumnFilterPopover.d.ts +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("@tanstack/react-virtual"),n=require("react/jsx-runtime"),r=require("react-dom");function i(...e){return e.filter(Boolean).join(` `)}var a={activateCell:e=>({type:`cell/activate`,cell:e}),startSelection:e=>({type:`selection/start`,cell:e}),updateSelection:e=>({type:`selection/update`,cell:e}),startRowSelection:e=>({type:`rowSelection/start`,row:e}),updateRowSelection:e=>({type:`rowSelection/update`,row:e}),startColumnSelection:e=>({type:`columnSelection/start`,col:e}),updateColumnSelection:e=>({type:`columnSelection/update`,col:e}),endSelection:()=>({type:`selection/end`}),clearSelection:()=>({type:`selection/clear`}),startEdit:e=>({type:`edit/start`,cell:e}),stopEdit:()=>({type:`edit/stop`}),startColumnResize:(e,t,n,r,i)=>({type:`column/resizeStart`,columnKey:e,startX:t,startWidth:n,minWidth:r,maxWidth:i}),updateColumnResize:e=>({type:`column/resizeUpdate`,clientX:e}),endColumnResize:()=>({type:`column/resizeEnd`}),syncColumnWidths:e=>({type:`columnWidths/sync`,widths:e}),resetColumnWidths:e=>({type:`columnWidths/reset`,widths:e}),setGlobalFilter:e=>({type:`filter/setGlobal`,value:e}),setColumnFilter:(e,t)=>({type:`filter/setColumn`,columnKey:e,value:t}),clearColumnFilter:e=>({type:`filter/clearColumn`,columnKey:e}),resetAllFilters:()=>({type:`filter/resetAll`}),setAllFilters:e=>({type:`filter/setAll`,filters:e}),setSort:e=>({type:`sort/set`,entries:e}),clearSort:()=>({type:`sort/clear`}),setRowSelectionState:e=>({type:`rowSelect/set`,state:e}),toggleGroupCollapsed:e=>({type:`group/toggleCollapsed`,groupKey:e}),setGroupCollapsed:(e,t)=>({type:`group/setCollapsed`,groupKey:e,collapsed:t}),setCollapsedGroupKeys:e=>({type:`group/setCollapsedKeys`,keys:e})},o=(e,t,n)=>Math.min(Math.max(e,t),n),s=(e,t)=>{let n=0;return e.map((e,r)=>{let i=t[e.key]??e.width,a={index:r,column:e,start:n,size:i,end:n+i};return n+=i,a})},c=e=>e.pinned===`left`?`left`:e.pinned===`right`?`right`:`center`,l=e=>{let t=[],n=[],r=[];for(let i of e){let e=c(i);e===`left`?t.push(i):e===`right`?r.push(i):n.push(i)}return[...t,...n,...r]},u=e=>{let t={left:[],center:[],right:[]};return e.forEach((e,n)=>{let r=c(e);t[r].push({column:e,logicalIndex:n})}),t},d=(e,t)=>e.map(({column:e})=>t[e.key]??e.width),f=(e,t)=>d(e,t).join(`,`),p=e=>e===``?[]:e.split(`,`).map(Number),m=(e,t,n)=>{let r=0;return{pane:e,entries:t.map(({column:e,logicalIndex:t},i)=>{let a=n[i]??e.width,o={column:e,logicalIndex:t,paneLocalStart:r,paneLocalSize:a,paneLocalEnd:r+a};return r+=a,o}),totalWidth:r}},h=(e,t,n)=>m(e,t,p(n)),g=(e,t)=>{let n=[[`left`,e.left],[`center`,e.center],[`right`,e.right]];for(let[e,r]of n){let n=r.entries.find(e=>e.logicalIndex===t);if(n)return{pane:e,entry:n}}return null},_=(e,t)=>{let{entries:n}=e;if(n.length===0)return-1;if(t<=0)return n[0].logicalIndex;let r=0,i=n.length-1;for(;r<=i;){let e=Math.floor((r+i)/2),a=n[e];if(t<a.paneLocalStart){i=e-1;continue}if(t>=a.paneLocalEnd){r=e+1;continue}return a.logicalIndex}return n[Math.max(0,Math.min(r,n.length-1))].logicalIndex},v=(e,t)=>{let{entries:n}=e;for(let e=0;e<n.length;e+=1){let r=n[e];if(t<r.paneLocalStart+r.paneLocalSize/2)return e}return n.length},y=(e,t)=>{let{entries:n,totalWidth:r}=e;return n.length===0?0:t<=0?n[0].paneLocalStart:t>=n.length?r:n[t].paneLocalStart},b=(e,t,n)=>{let r=Math.min(t,n),i=Math.max(t,n),a=1/0,o=-1/0,s=!1;for(let t of e.entries)t.logicalIndex<r||t.logicalIndex>i||(s=!0,t.paneLocalStart<a&&(a=t.paneLocalStart),t.paneLocalEnd>o&&(o=t.paneLocalEnd));return s?{start:a,end:o,width:o-a}:null},x=(e,t,n)=>({left:b(e.left,t,n),center:b(e.center,t,n),right:b(e.right,t,n)}),S=e=>{let t=e=>e.entries.length===0?null:{start:0,end:e.totalWidth,width:e.totalWidth};return{left:t(e.left),center:t(e.center),right:t(e.right)}},C=(e,t)=>{let n=g(e,t);if(!n)return null;let{pane:r,entry:i}=n;return{pane:r,extent:{start:i.paneLocalStart,end:i.paneLocalEnd,width:i.paneLocalSize}}},w=e=>e.flex!=null&&e.flex>0&&c(e)===`center`,T=(e,t)=>{let n=new Map,r=e,i=t;for(;;){let e=r.reduce((e,t)=>e+t.flex,0);if(r.length===0||e<=0)break;let t=null;for(let a of r){let r=i*a.flex/e;if(r<a.min){n.set(a.key,a.min),i-=a.min,t=a.key;break}if(r>a.max){n.set(a.key,a.max),i-=a.max,t=a.key;break}}if(t!==null){r=r.filter(e=>e.key!==t);continue}let a=0;r.forEach((t,o)=>{if(o===r.length-1)n.set(t.key,i-a);else{let r=i*t.flex/e;n.set(t.key,r),a+=r}});break}return n},E=(e,t,n)=>{let r=[],i=0;for(let n of e){let e=t[n.key];if(e!=null){i+=e;continue}let a=n.flex;if(a!=null&&a>0&&c(n)===`center`){r.push({key:n.key,flex:a,min:n.minWidth??50,max:n.maxWidth??1/0});continue}i+=n.width}if(r.length===0)return{};let a=n-i;return Object.fromEntries(T(r,a))},D=()=>({mode:`include`,keys:new Set}),O=(e,t)=>e.mode===`exclude`?!e.keys.has(t):e.keys.has(t),k=(e,t)=>{let n=new Set(e.keys);return n.has(t)?n.delete(t):n.add(t),{mode:e.mode,keys:n}},A=e=>({mode:`include`,keys:new Set([e])}),j=e=>({mode:`include`,keys:new Set(e)}),M=()=>({mode:`exclude`,keys:new Set}),ee=()=>D(),N=(e,t)=>e.mode===`exclude`?Math.max(0,t-e.keys.size):e.keys.size,P=(e,t)=>{let n=N(e,t);return n<=0?`none`:t>0&&n>=t?`all`:`some`},F=e=>({type:e.mode,rowKeys:Array.from(e.keys)}),I=e=>({mode:e.type,keys:new Set(e.rowKeys)}),te=(e,t)=>{if(e.mode!==t.mode||e.keys.size!==t.keys.size)return!1;for(let n of e.keys)if(!t.keys.has(n))return!1;return!0},ne=60,re=(e,t,n)=>Math.min(Math.max(e,t),n),ie=e=>e.reduce((e,t)=>(w(t)||(e[t.key]=t.width),e),{}),ae=e=>({activeCell:null,selection:null,rowSelection:D(),editingCell:null,dragState:null,columnWidths:ie(e),filters:{globalText:``,columnFilters:{}},sort:[],collapsedGroupKeys:new Set}),oe=(e,t)=>{switch(t.type){case`cell/activate`:return{...e,activeCell:t.cell};case`selection/start`:return{...e,activeCell:t.cell,selection:{type:`cell`,range:{start:t.cell,end:t.cell}},dragState:{type:`selection`,selectionKind:`cell`,anchor:t.cell}};case`rowSelection/start`:return{...e,activeCell:{row:t.row,col:e.activeCell?.col??0},selection:{type:`row`,startRow:t.row,endRow:t.row},dragState:{type:`selection`,selectionKind:`row`,anchorRow:t.row}};case`rowSelection/update`:return e.dragState?.type!==`selection`||e.dragState.selectionKind!==`row`||e.selection?.type===`row`&&e.selection.endRow===t.row?e:{...e,selection:{type:`row`,startRow:e.dragState.anchorRow,endRow:t.row}};case`selection/update`:return e.dragState?.type!==`selection`||e.dragState.selectionKind!==`cell`||e.selection?.type===`cell`&&e.selection.range.end.row===t.cell.row&&e.selection.range.end.col===t.cell.col?e:{...e,selection:{type:`cell`,range:{start:e.dragState.anchor,end:t.cell}}};case`columnSelection/start`:return{...e,activeCell:{row:e.activeCell?.row??0,col:t.col},selection:{type:`col`,startCol:t.col,endCol:t.col},dragState:{type:`selection`,selectionKind:`col`,anchorCol:t.col}};case`columnSelection/update`:return e.dragState?.type!==`selection`||e.dragState.selectionKind!==`col`||e.selection?.type===`col`&&e.selection.endCol===t.col?e:{...e,selection:{type:`col`,startCol:e.dragState.anchorCol,endCol:t.col}};case`selection/end`:return e.dragState?.type===`selection`?{...e,dragState:null}:e;case`selection/clear`:return{...e,selection:null,dragState:null};case`edit/start`:return{...e,editingCell:t.cell,activeCell:t.cell};case`edit/stop`:return{...e,editingCell:null};case`column/resizeStart`:return{...e,dragState:{type:`columnResize`,columnKey:t.columnKey,startX:t.startX,startWidth:t.startWidth,minWidth:t.minWidth||ne,maxWidth:t.maxWidth??1/0}};case`column/resizeUpdate`:{if(e.dragState?.type!==`columnResize`)return e;let n=re(e.dragState.startWidth+(t.clientX-e.dragState.startX),e.dragState.minWidth,e.dragState.maxWidth);return e.columnWidths[e.dragState.columnKey]===n?e:{...e,columnWidths:{...e.columnWidths,[e.dragState.columnKey]:n}}}case`column/resizeEnd`:return e.dragState?.type===`columnResize`?{...e,dragState:null}:e;case`columnWidths/sync`:return{...e,columnWidths:{...e.columnWidths,...t.widths}};case`columnWidths/reset`:return{...e,columnWidths:t.widths};case`filter/setGlobal`:return{...e,filters:{...e.filters,globalText:t.value}};case`filter/setColumn`:return{...e,filters:{...e.filters,columnFilters:{...e.filters.columnFilters,[t.columnKey]:t.value}}};case`filter/clearColumn`:{let n={...e.filters.columnFilters};return delete n[t.columnKey],{...e,filters:{...e.filters,columnFilters:n}}}case`filter/resetAll`:return{...e,filters:{globalText:``,columnFilters:{}}};case`filter/setAll`:return{...e,filters:t.filters};case`sort/set`:return{...e,sort:t.entries};case`sort/clear`:return{...e,sort:[]};case`rowSelect/set`:return te(e.rowSelection,t.state)?e:{...e,rowSelection:t.state};case`group/toggleCollapsed`:{let n=new Set(e.collapsedGroupKeys);return n.has(t.groupKey)?n.delete(t.groupKey):n.add(t.groupKey),{...e,collapsedGroupKeys:n}}case`group/setCollapsed`:{if(e.collapsedGroupKeys.has(t.groupKey)===t.collapsed)return e;let n=new Set(e.collapsedGroupKeys);return t.collapsed?n.add(t.groupKey):n.delete(t.groupKey),{...e,collapsedGroupKeys:n}}case`group/setCollapsedKeys`:return t.keys===e.collapsedGroupKeys||t.keys.size===0&&e.collapsedGroupKeys.size===0?e:{...e,collapsedGroupKeys:t.keys};default:return e}},se=e=>({start:{row:Math.min(e.start.row,e.end.row),col:Math.min(e.start.col,e.end.col)},end:{row:Math.max(e.start.row,e.end.row),col:Math.max(e.start.col,e.end.col)}}),ce=(e,t)=>({startRow:Math.min(e,t),endRow:Math.max(e,t)}),le=(e,t)=>({startCol:Math.min(e,t),endCol:Math.max(e,t)}),ue=e=>e.filters.globalText,de=e=>{if(!e)return{kind:`none`};if(e.type===`cell`){let t=se(e.range);return{kind:`cell`,startRow:t.start.row,endRow:t.end.row,startCol:t.start.col,endCol:t.end.col}}if(e.type===`row`){let t=ce(e.startRow,e.endRow);return{kind:`row`,startRow:t.startRow,endRow:t.endRow}}let t=le(e.startCol,e.endCol);return{kind:`col`,startCol:t.startCol,endCol:t.endCol}};function fe({rect:e,headerHeight:t,leadingWidth:r,baseOffset:i=0}){return e?(0,n.jsx)(`div`,{className:`ssg-selection-overlay`,style:{position:`absolute`,left:r+e.left,top:t+e.top-i,width:e.width,height:e.height}}):null}function pe({rect:e,headerHeight:t,leadingWidth:r,baseOffset:i=0}){return e?(0,n.jsx)(`div`,{className:`ssg-active-cell-overlay`,style:{position:`absolute`,left:r+e.left,top:t+e.top-i,width:e.width,height:e.height}}):null}var me=e=>{let t=e??`down`;return t===`none`?void 0:t},he=({value:e,onCommit:t,onCancel:n,onRejected:r,enterMove:i})=>a=>{if(a.nativeEvent.isComposing)return;let o=n=>{let i=t(e,n);i&&i.status===`rejected`&&r?.(i.message)};if(a.key===`Enter`){a.preventDefault(),o(me(i));return}if(a.key===`Escape`){a.preventDefault(),n();return}a.key===`Tab`&&(a.preventDefault(),o(a.shiftKey?`left`:`right`))};function ge({message:t}){let[r,a]=(0,e.useState)(!1);return(0,n.jsx)(`div`,{ref:(0,e.useCallback)(e=>{e&&a(e.getBoundingClientRect().bottom>window.innerHeight-4)},[]),role:`alert`,className:i(`ssg-cell-editor-error`,r&&`ssg-cell-editor-error--above`),children:t})}function _e({initialValue:t,onCommit:r,onCancel:a,align:o,enterMove:s}){let c=(0,e.useRef)(null),[l,u]=(0,e.useState)(t),[d,f]=(0,e.useState)(null);return(0,e.useEffect)(()=>{let e=c.current;if(!e)return;e.focus();let t=e.value.length;e.setSelectionRange(t,t)},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:c,type:`text`,value:l,onChange:e=>{u(e.target.value),f(null)},onKeyDown:he({value:l,onCommit:r,onCancel:a,onRejected:f,enterMove:s}),onBlur:()=>{let e=r(l);e&&e.status===`rejected`&&a()},className:i(`ssg-cell-editor-input`,d!==null&&`ssg-cell-editor-input--invalid`),style:o?{textAlign:o}:void 0}),d===null?null:(0,n.jsx)(ge,{message:d})]})}function L({initialValue:t,min:r,max:a,step:o,onCommit:s,onCancel:c,align:l,enterMove:u}){let d=(0,e.useRef)(null),[f,p]=(0,e.useState)(t),[m,h]=(0,e.useState)(null);return(0,e.useEffect)(()=>{d.current?.focus()},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:d,type:`number`,value:f,min:r,max:a,step:o,onChange:e=>{p(e.target.value),h(null)},onKeyDown:he({value:f,onCommit:s,onCancel:c,onRejected:h,enterMove:u}),onBlur:()=>{let e=s(f);e&&e.status===`rejected`&&c()},className:i(`ssg-cell-editor-input`,m!==null&&`ssg-cell-editor-input--invalid`),style:l?{textAlign:l}:void 0}),m===null?null:(0,n.jsx)(ge,{message:m})]})}var ve=8,ye=8,be=2,xe=(e,t)=>{let n=String(t??``),r=e.findIndex(e=>e.value===n);return r>=0?r:0},Se=(e,t,n)=>{if(n<=0)return 0;let r=e+t;return r<0?0:r>n-1?n-1:r},Ce=()=>({buffer:``,lastInputTime:0}),we=(e,t,n,r)=>{let i=(n-e.lastInputTime>700?``:e.buffer)+t.toLocaleLowerCase(),a=r.findIndex(e=>e.label.toLocaleLowerCase().startsWith(i));return{state:{buffer:i,lastInputTime:n},index:a>=0?a:null}},Te=(e,t,n,r)=>{let i=Math.max(e.width,180),a=Math.max(ye,n-i-ye),o=Math.min(Math.max(e.left,ye),a),s=Math.min(Math.max(t,1),ve)*28+8,c=e.bottom+be;return{left:o,top:c+s<=r-ye?c:Math.max(ye,e.top-be-s),width:i,maxHeight:s}};function Ee({options:t,value:a,onCommit:o,onCancel:s,align:c,themeClassName:l,enterMove:u}){let d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=(0,e.useRef)(Ce()),[m,h]=(0,e.useState)(()=>xe(t,a)),[g,_]=(0,e.useState)(null),[v,y]=(0,e.useState)(null),b=(0,e.useCallback)(e=>{d.current=e,e&&(e.focus(),_(Te(e.getBoundingClientRect(),t.length,window.innerWidth,window.innerHeight)))},[t.length]);(0,e.useEffect)(()=>{let e=()=>{let e=d.current;e&&_(Te(e.getBoundingClientRect(),t.length,window.innerWidth,window.innerHeight))};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[t.length]),(0,e.useEffect)(()=>{let e=f.current;e&&e.children[m]?.scrollIntoView?.({block:`nearest`})},[m]);let x=(e,t)=>{let n=o(e,t);n&&n.status===`rejected`&&y(n.message)},S=e=>{let n=t[m];if(!n){s();return}x(n.value,e)},C=e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;h(e=>Se(e,n,t.length)),y(null);return}if(e.key===`Enter`){e.preventDefault(),S(me(u));return}if(e.key===`Escape`){e.preventDefault(),s();return}if(e.key===`Tab`){e.preventDefault(),S(e.shiftKey?`left`:`right`);return}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault();let n=we(p.current,e.key,Date.now(),t);p.current=n.state,n.index!==null&&(h(n.index),y(null))}}},w=t[m];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:b,type:`text`,readOnly:!0,value:w?.label??String(a??``),onKeyDown:C,onBlur:()=>s(),className:i(`ssg-cell-editor-input ssg-cell-editor-input--select`,v!==null&&`ssg-cell-editor-input--invalid`),style:c?{textAlign:c}:void 0}),v===null?null:(0,n.jsx)(ge,{message:v}),g?(0,r.createPortal)((0,n.jsx)(`div`,{ref:f,role:`listbox`,className:i(`ssg-select-editor-popover`,l),style:{left:g.left,top:g.top,width:g.width,maxHeight:g.maxHeight},onPointerDown:e=>e.preventDefault(),children:t.length===0?(0,n.jsx)(`div`,{className:`ssg-select-editor-empty`,children:`候補がありません`}):t.map((e,t)=>(0,n.jsx)(`div`,{role:`option`,"aria-selected":t===m,className:i(`ssg-select-editor-option`,t===m&&`ssg-select-editor-option--highlighted`),onClick:()=>x(e.value),onPointerEnter:()=>h(t),children:e.label},`${e.value}-${t}`))}),document.body):null]})}function De({initialValue:t,onCommit:r,onCancel:a,align:o,enterMove:s}){let c=(0,e.useRef)(null),[l,u]=(0,e.useState)(t),[d,f]=(0,e.useState)(null);return(0,e.useEffect)(()=>{c.current?.focus()},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:c,type:`date`,value:l,onChange:e=>{u(e.target.value),f(null)},onKeyDown:he({value:l,onCommit:r,onCancel:a,onRejected:f,enterMove:s}),onBlur:()=>{let e=r(l);e&&e.status===`rejected`&&a()},className:i(`ssg-cell-editor-input`,d!==null&&`ssg-cell-editor-input--invalid`),style:o?{textAlign:o}:void 0}),d===null?null:(0,n.jsx)(ge,{message:d})]})}function Oe({render:e,context:t}){return(0,n.jsx)(n.Fragment,{children:e(t)})}var ke=(e,t,n,r,i)=>e.readOnly||i.readOnly||i.editable===!1?!1:e.canEditCell?e.canEditCell(t,n,r,i):!0,R=(e,t)=>t.getValue?t.getValue(e):e[t.key],Ae=(e,t,n)=>t.setValue?t.setValue(e,n):{...e,[t.key]:n},je=e=>({checkedValue:e.checkedValue??!0,uncheckedValue:e.uncheckedValue??!1}),Me=(e,t)=>Object.is(e,je(t).checkedValue),Ne=(e,t)=>{let{checkedValue:n,uncheckedValue:r}=je(t);return Object.is(e,n)?r:n},Pe=(e,t)=>{let{checkedValue:n,uncheckedValue:r}=je(t);if(e===``)return r;if(e===String(n))return n;if(e===String(r))return r;let i=e.toLowerCase();return i===`true`||i===`1`?n:r},Fe=e=>{if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:e},Ie=e=>`${String(e.getFullYear()).padStart(4,`0`)}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Le=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?``:Ie(e);if(typeof e==`string`&&e.trim()!==``){let t=/^(\d{4}-\d{2}-\d{2})/.exec(e);if(t)return t[1];let n=new Date(e);if(!Number.isNaN(n.getTime()))return Ie(n)}return``},Re=e=>{if(e===``)return null;let t=Le(e);return t===``?e:t},ze=e=>{if(e.parseClipboardValue)return e.parseClipboardValue;if(e.editor?.type===`number`)return Fe;if(e.editor?.type===`date`)return Re;if(e.editor?.type===`checkbox`){let t=e.editor;return e=>Pe(e,t)}return e=>e},Be=(e,t,n)=>typeof t==`string`?ze(e)(t,n):t,Ve=(e,t,n,r)=>e.map((e,i)=>i===t?Ae(e,n,r):e);function He({rect:t,headerHeight:r,leadingWidth:i,baseOffset:a=0,initialValue:o,editor:s,editorSession:c,themeClassName:l,onCommit:u,onCancel:d,align:f,enterMove:p}){let m=t!==null,[h,g]=(0,e.useState)(!1),[_,v]=(0,e.useState)(0);if(m!==h&&(g(m),m&&v(_+1)),!t)return null;let y={position:`absolute`,left:i+t.left,top:r+t.top-a,width:t.width,height:t.height},b;return b=s?.type===`number`?(0,n.jsx)(L,{enterMove:p,initialValue:o,min:s.min,max:s.max,step:s.step,onCommit:u,onCancel:d,align:f},_):s?.type===`date`?(0,n.jsx)(De,{enterMove:p,initialValue:Le(c?c.value:o),onCommit:u,onCancel:d,align:f},_):s?.type===`custom`?c?(0,n.jsx)(Oe,{render:s.render,context:{row:c.row,rowIndex:c.rowIndex,sourceRowIndex:c.sourceRowIndex,rowKey:c.rowKey,colIndex:c.colIndex,column:c.column,value:c.value,initialText:o,align:f,commit:(e,t)=>u(e,t)??{status:`noop`},cancel:d}},_):null:s?.type===`select`?(0,n.jsx)(Ee,{enterMove:p,options:typeof s.options==`function`?c?s.options(c.row):[]:s.options,value:c?.value,onCommit:u,onCancel:d,align:f,themeClassName:l},_):(0,n.jsx)(_e,{enterMove:p,initialValue:o,onCommit:u,onCancel:d,align:f},_),(0,n.jsx)(`div`,{className:`ssg-cell-editor`,style:y,children:b})}var Ue=e=>{let t=new Int32Array(e);for(let n=0;n<e;n+=1)t[n]=n;return t},We=e=>e?.kind===`set`,Ge=e=>e?.kind===`numberSet`,Ke=e=>e?.kind===`textSet`,qe=e=>e?.kind===`dateSet`,Je=e=>e==null||String(e).trim()===``,Ye=e=>{if(!e)return!1;switch(e.kind){case`set`:case`number`:case`custom`:return!0;case`numberSet`:case`textSet`:case`dateSet`:return e.condition!==null||e.set!==null;case`select`:return e.value.length>0;case`text`:case`date`:return e.value.trim().length>0}},Xe=e=>e==null||typeof e==`string`&&e.trim()===``?NaN:Number(e),Ze=(e,t)=>{if(e.mode===`blank`||e.mode===`notBlank`)return Je(t)===(e.mode===`blank`);let n=Xe(t);if(!Number.isFinite(n))return!1;if(e.mode===`range`)return n>=e.min&&n<=e.max;switch(e.operator){case`>`:return n>e.value;case`>=`:return n>=e.value;case`<`:return n<e.value;case`<=`:return n<=e.value;case`!=`:return n!==e.value;default:return n===e.value}},Qe=(e,t)=>{if(e.mode===`blank`||e.mode===`notBlank`)return Je(t)===(e.mode===`blank`);let n=String(t??``).toLowerCase(),r=e.value.toLowerCase();switch(e.mode){case`equals`:return n===r;case`startsWith`:return n.startsWith(r);case`endsWith`:return n.endsWith(r);default:return n.includes(r)}},$e=e=>String(e).padStart(2,`0`),et=e=>`${e.getFullYear()}-${$e(e.getMonth()+1)}-${$e(e.getDate())}`,tt=e=>{if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:et(e);let t=String(e).trim();if(!t)return null;let n=t.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})(?:[T ].*)?$/);if(!n)return null;let r=Number(n[2]),i=Number(n[3]);return r<1||r>12||i<1||i>31?null:`${n[1]}-${$e(r)}-${$e(i)}`},nt=e=>{let t=tt(e);return t===null?Je(e)?``:String(e):t},rt=(e,t)=>{let n=et(t);switch(e){case`today`:return{from:n,to:n};case`thisMonth`:{let e=new Date(t.getFullYear(),t.getMonth(),1),n=new Date(t.getFullYear(),t.getMonth()+1,0);return{from:et(e),to:et(n)}}default:return{from:et(new Date(t.getFullYear(),t.getMonth(),t.getDate()-29)),to:n}}},it=(e,t)=>e.mode===`preset`?{mode:`range`,...rt(e.preset,t)}:e,at=(e,t,n)=>{let r=it(e,n);if(r.mode===`blank`||r.mode===`notBlank`)return Je(t)===(r.mode===`blank`);let i=tt(t);if(i===null)return!1;switch(r.mode){case`range`:return i>=r.from&&i<=r.to;case`onOrAfter`:return i>=r.value;case`onOrBefore`:return i<=r.value;case`notEquals`:return i!==r.value;default:return i===r.value}},ot=e=>{let t=e?.kind===`number`?e.parsed:e?.kind===`numberSet`?e.condition:null;return t?.mode===`comparison`||t?.mode===`range`},st=e=>e?.kind===`number`,ct=e=>{if(!e)return``;switch(e.kind){case`number`:return e.raw;case`text`:case`date`:case`select`:return e.value;case`set`:case`numberSet`:case`textSet`:case`dateSet`:case`custom`:return``}},lt=(e,t,n)=>{if(e.mode===`blank`||e.mode===`notBlank`){let n=e.mode===`blank`;return e=>Je(R(e,t))===n}if(e.mode===`range`){let{min:r,max:i}=e;return(e,a)=>{let o=n?n[a]:Xe(R(e,t));return Number.isFinite(o)&&o>=r&&o<=i}}let{operator:r,value:i}=e;return(e,a)=>{let o=n?n[a]:Xe(R(e,t));if(!Number.isFinite(o))return!1;switch(r){case`>`:return o>i;case`>=`:return o>=i;case`<`:return o<i;case`<=`:return o<=i;case`!=`:return o!==i;default:return o===i}}},ut=(e,t)=>{if(e.mode===`blank`||e.mode===`notBlank`){let n=e.mode===`blank`;return e=>Je(R(e,t))===n}let n=e.value.toLowerCase(),r=e.mode;return e=>{let i=String(R(e,t)??``).toLowerCase();switch(r){case`equals`:return i===n;case`startsWith`:return i.startsWith(n);case`endsWith`:return i.endsWith(n);default:return i.includes(n)}}},dt=(e,t,n)=>{let r=new Set(t);return e===`exclude`?e=>!r.has(String(R(e,n)??``)):e=>r.has(String(R(e,n)??``))},ft=(e,t,n)=>{let r=new Set(t);return e===`exclude`?e=>!r.has(nt(R(e,n))):e=>r.has(nt(R(e,n)))},pt=(e,t,n)=>{let r=it(e,n);if(r.mode===`blank`||r.mode===`notBlank`){let e=r.mode===`blank`;return n=>Je(R(n,t))===e}if(r.mode===`range`){let{from:e,to:n}=r;return r=>{let i=tt(R(r,t));return i!==null&&i>=e&&i<=n}}let{mode:i,value:a}=r;return e=>{let n=tt(R(e,t));if(n===null)return!1;switch(i){case`onOrAfter`:return n>=a;case`onOrBefore`:return n<=a;case`notEquals`:return n!==a;default:return n===a}}},mt=(e,t,n,r)=>{if(!Ye(t))return null;let i=t;if(e.filterFn){let t=e.filterFn;return e=>t(e,i)}switch(i.kind){case`set`:return dt(i.mode,i.values,e);case`number`:{let t=i.parsed;if(t===null){let t=i.raw.toLowerCase();return n=>String(R(n,e)??``).toLowerCase().includes(t)}return lt(t,e,n)}case`numberSet`:case`textSet`:case`dateSet`:{let t=i.kind===`numberSet`?i.condition?lt(i.condition,e,n):null:i.kind===`textSet`?i.condition?ut(i.condition,e):null:i.condition?pt(i.condition,e,r??new Date):null,a=i.set?i.kind===`dateSet`?ft(i.set.mode,i.set.values,e):dt(i.set.mode,i.set.values,e):null;return t&&a?(e,n)=>t(e,n)&&a(e,n):t??a}case`select`:{let t=i.value;return n=>String(R(n,e)??``)===t}case`text`:case`date`:{let t=i.value.trim().toLowerCase();return n=>String(R(n,e)??``).toLowerCase().includes(t)}case`custom`:{let t=String(i.value??``).trim().toLowerCase();return n=>String(R(n,e)??``).toLowerCase().includes(t)}}},ht=(e,t,n)=>{let r=t.length;for(let i=0;i<r;i+=1){let r=R(e,t[i]);if(String(r??``).toLowerCase().includes(n))return!0}return!1},gt=(e,t,n,r)=>{let i=r.trim().toLowerCase();if(!i)return t;let a=t.length,o=new Int32Array(a),s=0;for(let r=0;r<a;r+=1){let a=t[r];ht(e[a],n,i)&&(o[s]=a,s+=1)}return s===a?t:o.slice(0,s)},_t=(e,t,n,r,i,a)=>{let o=[],s=a??new Date;for(let e of n){let t=mt(e,r[e.key],i?.get(e.key),s);t&&o.push(t)}if(o.length===0)return t;let c=t.length,l=o.length,u=new Int32Array(c),d=0;for(let n=0;n<c;n+=1){let r=t[n],i=e[r],a=!0;for(let e=0;e<l;e+=1)if(!o[e](i,r)){a=!1;break}a&&(u[d]=r,d+=1)}return d===c?t:u.slice(0,d)},vt={operator:`gte`,value1:``,value2:``},z=[{value:`gte`,label:`以上`},{value:`gt`,label:`より大きい`},{value:`lte`,label:`以下`},{value:`lt`,label:`未満`},{value:`eq`,label:`に等しい`},{value:`ne`,label:`に等しくない`},{value:`between`,label:`範囲`},{value:`blank`,label:`空白`},{value:`notBlank`,label:`空白でない`}],yt=e=>e===`blank`||e===`notBlank`?0:e===`between`?2:1,bt=e=>{let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null},xt={gte:`>=`,gt:`>`,lte:`<=`,lt:`<`,eq:`=`,ne:`!=`},St=e=>{if(e.operator===`blank`||e.operator===`notBlank`)return{mode:e.operator};if(e.operator===`between`){let t=bt(e.value1),n=bt(e.value2);return t!==null&&n!==null?{mode:`range`,min:Math.min(t,n),max:Math.max(t,n)}:t===null?n===null?null:{mode:`comparison`,operator:`<=`,value:n}:{mode:`comparison`,operator:`>=`,value:t}}let t=bt(e.value1);return t===null?null:{mode:`comparison`,operator:xt[e.operator],value:t}},Ct=e=>{switch(e.mode){case`comparison`:switch(e.operator){case`>=`:return`${e.value} 以上`;case`>`:return`${e.value} より大きい`;case`<=`:return`${e.value} 以下`;case`<`:return`${e.value} 未満`;case`!=`:return`${e.value} に等しくない`;default:return`${e.value} に等しい`}case`range`:return`${e.min} 〜 ${e.max}`;case`blank`:return`(空白)`;case`notBlank`:return`(空白でない)`}},wt=e=>{let t=St(e);return t===null?null:{kind:`number`,raw:Ct(t),parsed:t}},Tt=(e,t)=>t?e.filter(e=>Ze(t,e.value)):e,Et={">=":`gte`,">":`gt`,"<=":`lte`,"<":`lt`,"=":`eq`,"!=":`ne`},Dt=e=>{if(!e)return vt;switch(e.mode){case`comparison`:return{operator:Et[e.operator],value1:String(e.value),value2:``};case`range`:return{operator:`between`,value1:String(e.min),value2:String(e.max)};case`blank`:case`notBlank`:return{operator:e.mode,value1:``,value2:``}}},Ot=e=>Dt(e?.parsed),kt={operator:`contains`,value:``},B=[{value:`contains`,label:`を含む`},{value:`equals`,label:`に等しい`},{value:`startsWith`,label:`で始まる`},{value:`endsWith`,label:`で終わる`},{value:`blank`,label:`空白`},{value:`notBlank`,label:`空白でない`}],At=e=>e===`blank`||e===`notBlank`?0:1,jt=e=>{if(e.operator===`blank`||e.operator===`notBlank`)return{mode:e.operator};let t=e.value.trim();return t?{mode:e.operator,value:t}:null},Mt=e=>{switch(e.mode){case`contains`:return`"${e.value}" を含む`;case`equals`:return`"${e.value}" に等しい`;case`startsWith`:return`"${e.value}" で始まる`;case`endsWith`:return`"${e.value}" で終わる`;case`blank`:return`(空白)`;case`notBlank`:return`(空白でない)`}},Nt=e=>e?e.mode===`blank`||e.mode===`notBlank`?{operator:e.mode,value:``}:{operator:e.mode,value:e.value}:kt,Pt=(e,t)=>t?e.filter(e=>Qe(t,e.value)):e,Ft={operator:`range`,value1:``,value2:``,preset:null},It=[{value:`range`,label:`範囲`},{value:`onOrAfter`,label:`以降`},{value:`onOrBefore`,label:`以前`},{value:`equals`,label:`に等しい`},{value:`notEquals`,label:`に等しくない`},{value:`blank`,label:`空白`},{value:`notBlank`,label:`空白でない`}],Lt=[{value:`today`,label:`今日`},{value:`thisMonth`,label:`今月`},{value:`last30days`,label:`過去 30 日`}],Rt=e=>e===`blank`||e===`notBlank`?0:e===`range`?2:1,zt=e=>{let t=e.trim();return/^\d{4}-\d{2}-\d{2}$/.test(t)?t:null},Bt=e=>{if(e.preset!==null)return{mode:`preset`,preset:e.preset};if(e.operator===`blank`||e.operator===`notBlank`)return{mode:e.operator};if(e.operator===`range`){let t=zt(e.value1),n=zt(e.value2);return t!==null&&n!==null?t<=n?{mode:`range`,from:t,to:n}:{mode:`range`,from:n,to:t}:t===null?n===null?null:{mode:`onOrBefore`,value:n}:{mode:`onOrAfter`,value:t}}let t=zt(e.value1);return t===null?null:{mode:e.operator,value:t}},Vt=e=>{switch(e.mode){case`range`:return`${e.from} 〜 ${e.to}`;case`onOrAfter`:return`${e.value} 以降`;case`onOrBefore`:return`${e.value} 以前`;case`equals`:return`${e.value} に等しい`;case`notEquals`:return`${e.value} に等しくない`;case`blank`:return`(空白)`;case`notBlank`:return`(空白でない)`;case`preset`:return Lt.find(t=>t.value===e.preset)?.label??e.preset}},Ht=e=>{if(!e)return Ft;switch(e.mode){case`preset`:return{...Ft,preset:e.preset};case`range`:return{operator:`range`,value1:e.from,value2:e.to,preset:null};case`blank`:case`notBlank`:return{operator:e.mode,value1:``,value2:``,preset:null};default:return{operator:e.mode,value1:e.value,value2:``,preset:null}}},Ut=(e,t,n)=>t?e.filter(e=>at(t,e.value,n)):e,Wt=240,Gt=8,Kt=8,qt=260,Jt=400,Yt=470,Xt=({visibleColumns:t,columnFilterValues:n,enableColumnFilter:r,gridRootRef:i,resolveColumnFilterType:a})=>{let[o,s]=(0,e.useState)(null),[c,l]=(0,e.useState)(null),u=(0,e.useRef)(null),d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=(0,e.useRef)(null),m=o!==null,h=o?.columnKey??null,g=o?.filterType??null,_=(0,e.useMemo)(()=>{if(!h)return null;let e=t.find(e=>e.key===h)??null;return!e||!g||e.filterType===g?e:{...e,filterType:g}},[h,t,g]),v=(0,e.useCallback)(()=>{if(!h||!d.current){l(null);return}let e=d.current.getBoundingClientRect(),t=_?.filterType===`numberSet`||_?.filterType===`textSet`||_?.filterType===`dateSet`?Yt:_?.filterType===`set`?Jt:qt,n=e.right-Wt;n=Math.max(Gt,n),n=Math.min(n,window.innerWidth-Wt-Gt);let r=e.bottom+Kt;r+t>window.innerHeight-Gt&&(r=e.top-t-Kt),r=Math.max(Gt,r),l(e=>e&&e.top===r&&e.left===n&&e.width===Wt?e:{top:r,left:n,width:Wt})},[h,_]),y=(0,e.useCallback)(e=>{if(!r)return;document.activeElement instanceof HTMLElement&&document.activeElement.blur(),i.current?.blur();let t=i.current?.querySelectorAll(`[data-ssg-col-key]`),o=t?Array.from(t).find(t=>t.dataset.ssgColKey===e.key)??null:null;d.current=o;let c=e.filterType===`auto`&&a?a(e):e.filterType??`text`,l=n[e.key],u=c===`number`?Ot(st(l)?l:void 0):c===`numberSet`?Dt(Ge(l)?l.condition:void 0):null,f=c===`textSet`?Nt(Ke(l)?l.condition:void 0):null,p=c===`dateSet`?Ht(qe(l)?l.condition:void 0):null;s({columnKey:e.key,filterType:c,draftValue:ct(l),numberDraft:u,textDraft:f,dateDraft:p})},[n,r,i,a]),b=(0,e.useCallback)(()=>{s(null),l(null),d.current=null,f.current=null,p.current=null,requestAnimationFrame(()=>{i.current?.focus()})},[i]),x=(0,e.useCallback)(e=>{s(t=>t&&{...t,draftValue:e})},[]),S=(0,e.useCallback)(e=>{s(t=>t&&{...t,numberDraft:e})},[]),C=(0,e.useCallback)(e=>{s(t=>t&&{...t,textDraft:e})},[]),w=(0,e.useCallback)(e=>{s(t=>t&&{...t,dateDraft:e})},[]);return(0,e.useEffect)(()=>{if(!h)return;v();let e=()=>{v()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[h,v]),(0,e.useEffect)(()=>{if(!_||!c)return;let e=_.filterType??`text`,t=0,n=0;return t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{if(e===`select`){p.current?.focus();return}let t=f.current;if(t&&(t.focus(),t.type===`text`)){let e=t.value.length;t.setSelectionRange(e,e)}})}),()=>{cancelAnimationFrame(t),cancelAnimationFrame(n)}},[_,c?.top,c?.left,c?.width]),(0,e.useEffect)(()=>{if(!m)return;let e=e=>{let t=e.target;t&&(u.current?.contains(t)||b())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[b,m]),{filterPopoverState:o,filterPopoverLayout:c,filterPopoverRef:u,filterTextInputRef:f,filterSelectRef:p,isFilterPopoverOpen:m,openedFilterColumn:_,openedFilterType:g,openColumnFilterPopover:y,closeColumnFilterPopover:b,updateFilterPopoverDraft:x,updateFilterPopoverNumberDraft:S,updateFilterPopoverTextDraft:C,updateFilterPopoverDateDraft:w}},Zt=`入力値が不正です`,Qt=e=>e===!0?{valid:!0,message:``}:e===!1?{valid:!1,message:Zt}:typeof e==`string`?{valid:!1,message:e||`入力値が不正です`}:{valid:!1,message:e.message||`入力値が不正です`},$t=(e,t,n)=>{if(!e.validate)return null;let r=Qt(e.validate({value:n,row:t,column:e}));return r.valid?null:r.message},en=(e,t,n)=>{if((e.validationMode??`mark`)!==`reject`)return{action:`write`};let r=$t(e,t,n);return r===null?{action:`write`}:{action:`reject`,message:r}},tn=(e,t,n)=>{let r=t.filter(e=>e.validate);if(r.length===0)return[];let i=[];return e.forEach((e,t)=>{for(let a of r){let r=$t(a,e,R(e,a));r!==null&&i.push({rowKey:n(e,t)??t,sourceRowIndex:t,columnKey:a.key,message:r})}}),i},nn=e=>{let t=e.replace(/\r\n/g,`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("@tanstack/react-virtual"),n=require("react/jsx-runtime"),r=require("react-dom");function i(...e){return e.filter(Boolean).join(` `)}var a={activateCell:e=>({type:`cell/activate`,cell:e}),startSelection:e=>({type:`selection/start`,cell:e}),updateSelection:e=>({type:`selection/update`,cell:e}),startRowSelection:e=>({type:`rowSelection/start`,row:e}),updateRowSelection:e=>({type:`rowSelection/update`,row:e}),startColumnSelection:e=>({type:`columnSelection/start`,col:e}),updateColumnSelection:e=>({type:`columnSelection/update`,col:e}),endSelection:()=>({type:`selection/end`}),clearSelection:()=>({type:`selection/clear`}),startEdit:e=>({type:`edit/start`,cell:e}),stopEdit:()=>({type:`edit/stop`}),startColumnResize:(e,t,n,r,i)=>({type:`column/resizeStart`,columnKey:e,startX:t,startWidth:n,minWidth:r,maxWidth:i}),updateColumnResize:e=>({type:`column/resizeUpdate`,clientX:e}),endColumnResize:()=>({type:`column/resizeEnd`}),syncColumnWidths:e=>({type:`columnWidths/sync`,widths:e}),resetColumnWidths:e=>({type:`columnWidths/reset`,widths:e}),setGlobalFilter:e=>({type:`filter/setGlobal`,value:e}),setColumnFilter:(e,t)=>({type:`filter/setColumn`,columnKey:e,value:t}),clearColumnFilter:e=>({type:`filter/clearColumn`,columnKey:e}),resetAllFilters:()=>({type:`filter/resetAll`}),setAllFilters:e=>({type:`filter/setAll`,filters:e}),setSort:e=>({type:`sort/set`,entries:e}),clearSort:()=>({type:`sort/clear`}),setRowSelectionState:e=>({type:`rowSelect/set`,state:e}),toggleGroupCollapsed:e=>({type:`group/toggleCollapsed`,groupKey:e}),setGroupCollapsed:(e,t)=>({type:`group/setCollapsed`,groupKey:e,collapsed:t}),setCollapsedGroupKeys:e=>({type:`group/setCollapsedKeys`,keys:e})},o=(e,t,n)=>Math.min(Math.max(e,t),n),s=(e,t)=>{let n=0;return e.map((e,r)=>{let i=t[e.key]??e.width,a={index:r,column:e,start:n,size:i,end:n+i};return n+=i,a})},c=e=>e.pinned===`left`?`left`:e.pinned===`right`?`right`:`center`,l=e=>{let t=[],n=[],r=[];for(let i of e){let e=c(i);e===`left`?t.push(i):e===`right`?r.push(i):n.push(i)}return[...t,...n,...r]},u=e=>{let t={left:[],center:[],right:[]};return e.forEach((e,n)=>{let r=c(e);t[r].push({column:e,logicalIndex:n})}),t},d=(e,t)=>e.map(({column:e})=>t[e.key]??e.width),f=(e,t)=>d(e,t).join(`,`),p=e=>e===``?[]:e.split(`,`).map(Number),m=(e,t,n)=>{let r=0;return{pane:e,entries:t.map(({column:e,logicalIndex:t},i)=>{let a=n[i]??e.width,o={column:e,logicalIndex:t,paneLocalStart:r,paneLocalSize:a,paneLocalEnd:r+a};return r+=a,o}),totalWidth:r}},h=(e,t,n)=>m(e,t,p(n)),g=(e,t)=>{let n=[[`left`,e.left],[`center`,e.center],[`right`,e.right]];for(let[e,r]of n){let n=r.entries.find(e=>e.logicalIndex===t);if(n)return{pane:e,entry:n}}return null},_=(e,t)=>{let{entries:n}=e;if(n.length===0)return-1;if(t<=0)return n[0].logicalIndex;let r=0,i=n.length-1;for(;r<=i;){let e=Math.floor((r+i)/2),a=n[e];if(t<a.paneLocalStart){i=e-1;continue}if(t>=a.paneLocalEnd){r=e+1;continue}return a.logicalIndex}return n[Math.max(0,Math.min(r,n.length-1))].logicalIndex},v=(e,t)=>{let{entries:n}=e;for(let e=0;e<n.length;e+=1){let r=n[e];if(t<r.paneLocalStart+r.paneLocalSize/2)return e}return n.length},y=(e,t)=>{let{entries:n,totalWidth:r}=e;return n.length===0?0:t<=0?n[0].paneLocalStart:t>=n.length?r:n[t].paneLocalStart},b=(e,t,n)=>{let r=Math.min(t,n),i=Math.max(t,n),a=1/0,o=-1/0,s=!1;for(let t of e.entries)t.logicalIndex<r||t.logicalIndex>i||(s=!0,t.paneLocalStart<a&&(a=t.paneLocalStart),t.paneLocalEnd>o&&(o=t.paneLocalEnd));return s?{start:a,end:o,width:o-a}:null},x=(e,t,n)=>({left:b(e.left,t,n),center:b(e.center,t,n),right:b(e.right,t,n)}),S=e=>{let t=e=>e.entries.length===0?null:{start:0,end:e.totalWidth,width:e.totalWidth};return{left:t(e.left),center:t(e.center),right:t(e.right)}},C=(e,t)=>{let n=g(e,t);if(!n)return null;let{pane:r,entry:i}=n;return{pane:r,extent:{start:i.paneLocalStart,end:i.paneLocalEnd,width:i.paneLocalSize}}},w=e=>e.flex!=null&&e.flex>0&&c(e)===`center`,T=(e,t)=>{let n=new Map,r=e,i=t;for(;;){let e=r.reduce((e,t)=>e+t.flex,0);if(r.length===0||e<=0)break;let t=null;for(let a of r){let r=i*a.flex/e;if(r<a.min){n.set(a.key,a.min),i-=a.min,t=a.key;break}if(r>a.max){n.set(a.key,a.max),i-=a.max,t=a.key;break}}if(t!==null){r=r.filter(e=>e.key!==t);continue}let a=0;r.forEach((t,o)=>{if(o===r.length-1)n.set(t.key,i-a);else{let r=i*t.flex/e;n.set(t.key,r),a+=r}});break}return n},E=(e,t,n)=>{let r=[],i=0;for(let n of e){let e=t[n.key];if(e!=null){i+=e;continue}let a=n.flex;if(a!=null&&a>0&&c(n)===`center`){r.push({key:n.key,flex:a,min:n.minWidth??50,max:n.maxWidth??1/0});continue}i+=n.width}if(r.length===0)return{};let a=n-i;return Object.fromEntries(T(r,a))},D=()=>({mode:`include`,keys:new Set}),O=(e,t)=>e.mode===`exclude`?!e.keys.has(t):e.keys.has(t),k=(e,t)=>{let n=new Set(e.keys);return n.has(t)?n.delete(t):n.add(t),{mode:e.mode,keys:n}},A=e=>({mode:`include`,keys:new Set([e])}),j=e=>({mode:`include`,keys:new Set(e)}),M=()=>({mode:`exclude`,keys:new Set}),ee=()=>D(),N=(e,t)=>e.mode===`exclude`?Math.max(0,t-e.keys.size):e.keys.size,P=(e,t)=>{let n=N(e,t);return n<=0?`none`:t>0&&n>=t?`all`:`some`},F=e=>({type:e.mode,rowKeys:Array.from(e.keys)}),I=e=>({mode:e.type,keys:new Set(e.rowKeys)}),te=(e,t)=>{if(e.mode!==t.mode||e.keys.size!==t.keys.size)return!1;for(let n of e.keys)if(!t.keys.has(n))return!1;return!0},ne=60,re=(e,t,n)=>Math.min(Math.max(e,t),n),ie=e=>e.reduce((e,t)=>(w(t)||(e[t.key]=t.width),e),{}),ae=e=>({activeCell:null,selection:null,rowSelection:D(),editingCell:null,dragState:null,columnWidths:ie(e),filters:{globalText:``,columnFilters:{}},sort:[],collapsedGroupKeys:new Set}),oe=(e,t)=>{switch(t.type){case`cell/activate`:return{...e,activeCell:t.cell};case`selection/start`:return{...e,activeCell:t.cell,selection:{type:`cell`,range:{start:t.cell,end:t.cell}},dragState:{type:`selection`,selectionKind:`cell`,anchor:t.cell}};case`rowSelection/start`:return{...e,activeCell:{row:t.row,col:e.activeCell?.col??0},selection:{type:`row`,startRow:t.row,endRow:t.row},dragState:{type:`selection`,selectionKind:`row`,anchorRow:t.row}};case`rowSelection/update`:return e.dragState?.type!==`selection`||e.dragState.selectionKind!==`row`||e.selection?.type===`row`&&e.selection.endRow===t.row?e:{...e,selection:{type:`row`,startRow:e.dragState.anchorRow,endRow:t.row}};case`selection/update`:return e.dragState?.type!==`selection`||e.dragState.selectionKind!==`cell`||e.selection?.type===`cell`&&e.selection.range.end.row===t.cell.row&&e.selection.range.end.col===t.cell.col?e:{...e,selection:{type:`cell`,range:{start:e.dragState.anchor,end:t.cell}}};case`columnSelection/start`:return{...e,activeCell:{row:e.activeCell?.row??0,col:t.col},selection:{type:`col`,startCol:t.col,endCol:t.col},dragState:{type:`selection`,selectionKind:`col`,anchorCol:t.col}};case`columnSelection/update`:return e.dragState?.type!==`selection`||e.dragState.selectionKind!==`col`||e.selection?.type===`col`&&e.selection.endCol===t.col?e:{...e,selection:{type:`col`,startCol:e.dragState.anchorCol,endCol:t.col}};case`selection/end`:return e.dragState?.type===`selection`?{...e,dragState:null}:e;case`selection/clear`:return{...e,selection:null,dragState:null};case`edit/start`:return{...e,editingCell:t.cell,activeCell:t.cell};case`edit/stop`:return{...e,editingCell:null};case`column/resizeStart`:return{...e,dragState:{type:`columnResize`,columnKey:t.columnKey,startX:t.startX,startWidth:t.startWidth,minWidth:t.minWidth||ne,maxWidth:t.maxWidth??1/0}};case`column/resizeUpdate`:{if(e.dragState?.type!==`columnResize`)return e;let n=re(e.dragState.startWidth+(t.clientX-e.dragState.startX),e.dragState.minWidth,e.dragState.maxWidth);return e.columnWidths[e.dragState.columnKey]===n?e:{...e,columnWidths:{...e.columnWidths,[e.dragState.columnKey]:n}}}case`column/resizeEnd`:return e.dragState?.type===`columnResize`?{...e,dragState:null}:e;case`columnWidths/sync`:return{...e,columnWidths:{...e.columnWidths,...t.widths}};case`columnWidths/reset`:return{...e,columnWidths:t.widths};case`filter/setGlobal`:return{...e,filters:{...e.filters,globalText:t.value}};case`filter/setColumn`:return{...e,filters:{...e.filters,columnFilters:{...e.filters.columnFilters,[t.columnKey]:t.value}}};case`filter/clearColumn`:{let n={...e.filters.columnFilters};return delete n[t.columnKey],{...e,filters:{...e.filters,columnFilters:n}}}case`filter/resetAll`:return{...e,filters:{globalText:``,columnFilters:{}}};case`filter/setAll`:return{...e,filters:t.filters};case`sort/set`:return{...e,sort:t.entries};case`sort/clear`:return{...e,sort:[]};case`rowSelect/set`:return te(e.rowSelection,t.state)?e:{...e,rowSelection:t.state};case`group/toggleCollapsed`:{let n=new Set(e.collapsedGroupKeys);return n.has(t.groupKey)?n.delete(t.groupKey):n.add(t.groupKey),{...e,collapsedGroupKeys:n}}case`group/setCollapsed`:{if(e.collapsedGroupKeys.has(t.groupKey)===t.collapsed)return e;let n=new Set(e.collapsedGroupKeys);return t.collapsed?n.add(t.groupKey):n.delete(t.groupKey),{...e,collapsedGroupKeys:n}}case`group/setCollapsedKeys`:return t.keys===e.collapsedGroupKeys||t.keys.size===0&&e.collapsedGroupKeys.size===0?e:{...e,collapsedGroupKeys:t.keys};default:return e}},se=e=>({start:{row:Math.min(e.start.row,e.end.row),col:Math.min(e.start.col,e.end.col)},end:{row:Math.max(e.start.row,e.end.row),col:Math.max(e.start.col,e.end.col)}}),ce=(e,t)=>({startRow:Math.min(e,t),endRow:Math.max(e,t)}),le=(e,t)=>({startCol:Math.min(e,t),endCol:Math.max(e,t)}),ue=e=>e.filters.globalText,de=e=>{if(!e)return{kind:`none`};if(e.type===`cell`){let t=se(e.range);return{kind:`cell`,startRow:t.start.row,endRow:t.end.row,startCol:t.start.col,endCol:t.end.col}}if(e.type===`row`){let t=ce(e.startRow,e.endRow);return{kind:`row`,startRow:t.startRow,endRow:t.endRow}}let t=le(e.startCol,e.endCol);return{kind:`col`,startCol:t.startCol,endCol:t.endCol}};function fe({rect:e,headerHeight:t,leadingWidth:r,baseOffset:i=0}){return e?(0,n.jsx)(`div`,{className:`ssg-selection-overlay`,style:{position:`absolute`,left:r+e.left,top:t+e.top-i,width:e.width,height:e.height}}):null}function pe({rect:e,headerHeight:t,leadingWidth:r,baseOffset:i=0}){return e?(0,n.jsx)(`div`,{className:`ssg-active-cell-overlay`,style:{position:`absolute`,left:r+e.left,top:t+e.top-i,width:e.width,height:e.height}}):null}var me=e=>{let t=e??`down`;return t===`none`?void 0:t},he=({value:e,onCommit:t,onCancel:n,onRejected:r,enterMove:i})=>a=>{if(a.nativeEvent.isComposing)return;let o=n=>{let i=t(e,n);i&&i.status===`rejected`&&r?.(i.message)};if(a.key===`Enter`){a.preventDefault(),o(me(i));return}if(a.key===`Escape`){a.preventDefault(),n();return}a.key===`Tab`&&(a.preventDefault(),o(a.shiftKey?`left`:`right`))};function ge({message:t}){let[r,a]=(0,e.useState)(!1);return(0,n.jsx)(`div`,{ref:(0,e.useCallback)(e=>{e&&a(e.getBoundingClientRect().bottom>window.innerHeight-4)},[]),role:`alert`,className:i(`ssg-cell-editor-error`,r&&`ssg-cell-editor-error--above`),children:t})}function _e({initialValue:t,onCommit:r,onCancel:a,align:o,enterMove:s}){let c=(0,e.useRef)(null),[l,u]=(0,e.useState)(t),[d,f]=(0,e.useState)(null);return(0,e.useEffect)(()=>{let e=c.current;if(!e)return;e.focus();let t=e.value.length;e.setSelectionRange(t,t)},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:c,type:`text`,value:l,onChange:e=>{u(e.target.value),f(null)},onKeyDown:he({value:l,onCommit:r,onCancel:a,onRejected:f,enterMove:s}),onBlur:()=>{let e=r(l);e&&e.status===`rejected`&&a()},className:i(`ssg-cell-editor-input`,d!==null&&`ssg-cell-editor-input--invalid`),style:o?{textAlign:o}:void 0}),d===null?null:(0,n.jsx)(ge,{message:d})]})}function ve({initialValue:t,min:r,max:a,step:o,onCommit:s,onCancel:c,align:l,enterMove:u}){let d=(0,e.useRef)(null),[f,p]=(0,e.useState)(t),[m,h]=(0,e.useState)(null);return(0,e.useEffect)(()=>{d.current?.focus()},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:d,type:`number`,value:f,min:r,max:a,step:o,onChange:e=>{p(e.target.value),h(null)},onKeyDown:he({value:f,onCommit:s,onCancel:c,onRejected:h,enterMove:u}),onBlur:()=>{let e=s(f);e&&e.status===`rejected`&&c()},className:i(`ssg-cell-editor-input`,m!==null&&`ssg-cell-editor-input--invalid`),style:l?{textAlign:l}:void 0}),m===null?null:(0,n.jsx)(ge,{message:m})]})}var ye=8,be=8,xe=2,Se=(e,t)=>{let n=String(t??``),r=e.findIndex(e=>e.value===n);return r>=0?r:0},Ce=(e,t,n)=>{if(n<=0)return 0;let r=e+t;return r<0?0:r>n-1?n-1:r},we=()=>({buffer:``,lastInputTime:0}),Te=(e,t,n,r)=>{let i=(n-e.lastInputTime>700?``:e.buffer)+t.toLocaleLowerCase(),a=r.findIndex(e=>e.label.toLocaleLowerCase().startsWith(i));return{state:{buffer:i,lastInputTime:n},index:a>=0?a:null}},Ee=(e,t,n,r)=>{let i=Math.max(e.width,180),a=Math.max(be,n-i-be),o=Math.min(Math.max(e.left,be),a),s=Math.min(Math.max(t,1),ye)*28+8,c=e.bottom+xe;return{left:o,top:c+s<=r-be?c:Math.max(be,e.top-xe-s),width:i,maxHeight:s}};function De({options:t,value:a,onCommit:o,onCancel:s,align:c,themeClassName:l,enterMove:u}){let d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=(0,e.useRef)(we()),[m,h]=(0,e.useState)(()=>Se(t,a)),[g,_]=(0,e.useState)(null),[v,y]=(0,e.useState)(null),b=(0,e.useCallback)(e=>{d.current=e,e&&(e.focus(),_(Ee(e.getBoundingClientRect(),t.length,window.innerWidth,window.innerHeight)))},[t.length]);(0,e.useEffect)(()=>{let e=()=>{let e=d.current;e&&_(Ee(e.getBoundingClientRect(),t.length,window.innerWidth,window.innerHeight))};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[t.length]),(0,e.useEffect)(()=>{let e=f.current;e&&e.children[m]?.scrollIntoView?.({block:`nearest`})},[m]);let x=(e,t)=>{let n=o(e,t);n&&n.status===`rejected`&&y(n.message)},S=e=>{let n=t[m];if(!n){s();return}x(n.value,e)},C=e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;h(e=>Ce(e,n,t.length)),y(null);return}if(e.key===`Enter`){e.preventDefault(),S(me(u));return}if(e.key===`Escape`){e.preventDefault(),s();return}if(e.key===`Tab`){e.preventDefault(),S(e.shiftKey?`left`:`right`);return}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault();let n=Te(p.current,e.key,Date.now(),t);p.current=n.state,n.index!==null&&(h(n.index),y(null))}}},w=t[m];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:b,type:`text`,readOnly:!0,value:w?.label??String(a??``),onKeyDown:C,onBlur:()=>s(),className:i(`ssg-cell-editor-input ssg-cell-editor-input--select`,v!==null&&`ssg-cell-editor-input--invalid`),style:c?{textAlign:c}:void 0}),v===null?null:(0,n.jsx)(ge,{message:v}),g?(0,r.createPortal)((0,n.jsx)(`div`,{ref:f,role:`listbox`,className:i(`ssg-select-editor-popover`,l),style:{left:g.left,top:g.top,width:g.width,maxHeight:g.maxHeight},onPointerDown:e=>e.preventDefault(),children:t.length===0?(0,n.jsx)(`div`,{className:`ssg-select-editor-empty`,children:`候補がありません`}):t.map((e,t)=>(0,n.jsx)(`div`,{role:`option`,"aria-selected":t===m,className:i(`ssg-select-editor-option`,t===m&&`ssg-select-editor-option--highlighted`),onClick:()=>x(e.value),onPointerEnter:()=>h(t),children:e.label},`${e.value}-${t}`))}),document.body):null]})}function Oe({initialValue:t,onCommit:r,onCancel:a,align:o,enterMove:s}){let c=(0,e.useRef)(null),[l,u]=(0,e.useState)(t),[d,f]=(0,e.useState)(null);return(0,e.useEffect)(()=>{c.current?.focus()},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:c,type:`date`,value:l,onChange:e=>{u(e.target.value),f(null)},onKeyDown:he({value:l,onCommit:r,onCancel:a,onRejected:f,enterMove:s}),onBlur:()=>{let e=r(l);e&&e.status===`rejected`&&a()},className:i(`ssg-cell-editor-input`,d!==null&&`ssg-cell-editor-input--invalid`),style:o?{textAlign:o}:void 0}),d===null?null:(0,n.jsx)(ge,{message:d})]})}function ke({render:e,context:t}){return(0,n.jsx)(n.Fragment,{children:e(t)})}var Ae=(e,t,n,r,i)=>e.readOnly||i.readOnly||i.editable===!1?!1:e.canEditCell?e.canEditCell(t,n,r,i):!0,L=(e,t)=>t.getValue?t.getValue(e):e[t.key],je=(e,t,n)=>t.setValue?t.setValue(e,n):{...e,[t.key]:n},Me=e=>({checkedValue:e.checkedValue??!0,uncheckedValue:e.uncheckedValue??!1}),Ne=(e,t)=>Object.is(e,Me(t).checkedValue),Pe=(e,t)=>{let{checkedValue:n,uncheckedValue:r}=Me(t);return Object.is(e,n)?r:n},Fe=(e,t)=>{let{checkedValue:n,uncheckedValue:r}=Me(t);if(e===``)return r;if(e===String(n))return n;if(e===String(r))return r;let i=e.toLowerCase();return i===`true`||i===`1`?n:r},Ie=e=>{if(e===``)return null;let t=Number(e);return Number.isFinite(t)?t:e},Le=e=>`${String(e.getFullYear()).padStart(4,`0`)}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Re=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?``:Le(e);if(typeof e==`string`&&e.trim()!==``){let t=/^(\d{4}-\d{2}-\d{2})/.exec(e);if(t)return t[1];let n=new Date(e);if(!Number.isNaN(n.getTime()))return Le(n)}return``},ze=e=>{if(e===``)return null;let t=Re(e);return t===``?e:t},Be=e=>{if(e.parseClipboardValue)return e.parseClipboardValue;if(e.editor?.type===`number`)return Ie;if(e.editor?.type===`date`)return ze;if(e.editor?.type===`checkbox`){let t=e.editor;return e=>Fe(e,t)}return e=>e},Ve=(e,t,n)=>typeof t==`string`?Be(e)(t,n):t,He=(e,t,n,r)=>e.map((e,i)=>i===t?je(e,n,r):e);function Ue({rect:t,headerHeight:r,leadingWidth:i,baseOffset:a=0,initialValue:o,editor:s,editorSession:c,themeClassName:l,onCommit:u,onCancel:d,align:f,enterMove:p}){let m=t!==null,[h,g]=(0,e.useState)(!1),[_,v]=(0,e.useState)(0);if(m!==h&&(g(m),m&&v(_+1)),!t)return null;let y={position:`absolute`,left:i+t.left,top:r+t.top-a,width:t.width,height:t.height},b;return b=s?.type===`number`?(0,n.jsx)(ve,{enterMove:p,initialValue:o,min:s.min,max:s.max,step:s.step,onCommit:u,onCancel:d,align:f},_):s?.type===`date`?(0,n.jsx)(Oe,{enterMove:p,initialValue:Re(c?c.value:o),onCommit:u,onCancel:d,align:f},_):s?.type===`custom`?c?(0,n.jsx)(ke,{render:s.render,context:{row:c.row,rowIndex:c.rowIndex,sourceRowIndex:c.sourceRowIndex,rowKey:c.rowKey,colIndex:c.colIndex,column:c.column,value:c.value,initialText:o,align:f,commit:(e,t)=>u(e,t)??{status:`noop`},cancel:d}},_):null:s?.type===`select`?(0,n.jsx)(De,{enterMove:p,options:typeof s.options==`function`?c?s.options(c.row):[]:s.options,value:c?.value,onCommit:u,onCancel:d,align:f,themeClassName:l},_):(0,n.jsx)(_e,{enterMove:p,initialValue:o,onCommit:u,onCancel:d,align:f},_),(0,n.jsx)(`div`,{className:`ssg-cell-editor`,style:y,children:b})}var We=[{value:`today`,label:`今日`},{value:`thisMonth`,label:`今月`},{value:`last30days`,label:`過去 30 日`}],Ge=e=>We.some(t=>t.value===e),Ke=e=>We.find(t=>t.value===e)?.label??e,qe=e=>e===!1?[]:e===void 0?We.map(({value:e,label:t})=>({id:e,label:t})):e.map(e=>typeof e==`string`?{id:e,label:Ke(e)}:{id:e.id,label:e.label,resolve:e.resolve}),Je=(e,t)=>{let n=t?.find(t=>t.id===e)?.label;return n===void 0?Ge(e)?Ke(e):e:n},Ye=e=>{let t=new Int32Array(e);for(let n=0;n<e;n+=1)t[n]=n;return t},Xe=e=>e?.kind===`set`,Ze=e=>e?.kind===`numberSet`,Qe=e=>e?.kind===`textSet`,$e=e=>e?.kind===`dateSet`,et=e=>e==null||String(e).trim()===``,tt=e=>{if(!e)return!1;switch(e.kind){case`set`:case`number`:case`custom`:return!0;case`numberSet`:case`textSet`:case`dateSet`:return e.condition!==null||e.set!==null;case`select`:return e.value.length>0;case`text`:case`date`:return e.value.trim().length>0}},nt=e=>e==null||typeof e==`string`&&e.trim()===``?NaN:Number(e),rt=(e,t)=>{if(e.mode===`blank`||e.mode===`notBlank`)return et(t)===(e.mode===`blank`);let n=nt(t);if(!Number.isFinite(n))return!1;if(e.mode===`range`)return n>=e.min&&n<=e.max;switch(e.operator){case`>`:return n>e.value;case`>=`:return n>=e.value;case`<`:return n<e.value;case`<=`:return n<=e.value;case`!=`:return n!==e.value;default:return n===e.value}},it=(e,t)=>{if(e.mode===`blank`||e.mode===`notBlank`)return et(t)===(e.mode===`blank`);let n=String(t??``).toLowerCase(),r=e.value.toLowerCase();switch(e.mode){case`equals`:return n===r;case`startsWith`:return n.startsWith(r);case`endsWith`:return n.endsWith(r);default:return n.includes(r)}},at=e=>String(e).padStart(2,`0`),ot=e=>`${e.getFullYear()}-${at(e.getMonth()+1)}-${at(e.getDate())}`,st=e=>{if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:ot(e);let t=String(e).trim();if(!t)return null;let n=t.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})(?:[T ].*)?$/);if(!n)return null;let r=Number(n[2]),i=Number(n[3]);return r<1||r>12||i<1||i>31?null:`${n[1]}-${at(r)}-${at(i)}`},ct=e=>{let t=st(e);return t===null?et(e)?``:String(e):t},lt=(e,t)=>{let n=ot(t);switch(e){case`today`:return{from:n,to:n};case`thisMonth`:{let e=new Date(t.getFullYear(),t.getMonth(),1),n=new Date(t.getFullYear(),t.getMonth()+1,0);return{from:ot(e),to:ot(n)}}default:return{from:ot(new Date(t.getFullYear(),t.getMonth(),t.getDate()-29)),to:n}}},ut=e=>e===void 0?null:st(e),dt=(e,t,n)=>{if(e.mode!==`preset`)return e;let r=n?.find(t=>t.id===e.preset);if(r?.resolve){let e=r.resolve(t),n=ut(e.from),i=ut(e.to);return n!==null&&i!==null?n<=i?{mode:`range`,from:n,to:i}:{mode:`range`,from:i,to:n}:n===null?i===null?null:{mode:`onOrBefore`,value:i}:{mode:`onOrAfter`,value:n}}return Ge(e.preset)?{mode:`range`,...lt(e.preset,t)}:null},ft=(e,t,n,r)=>{let i=dt(e,n,r);if(i===null)return!0;if(i.mode===`blank`||i.mode===`notBlank`)return et(t)===(i.mode===`blank`);let a=st(t);if(a===null)return!1;switch(i.mode){case`range`:return a>=i.from&&a<=i.to;case`onOrAfter`:return a>=i.value;case`onOrBefore`:return a<=i.value;case`notEquals`:return a!==i.value;default:return a===i.value}},pt=e=>{let t=e?.kind===`number`?e.parsed:e?.kind===`numberSet`?e.condition:null;return t?.mode===`comparison`||t?.mode===`range`},mt=e=>e?.kind===`number`,ht=e=>{if(!e)return``;switch(e.kind){case`number`:return e.raw;case`text`:case`date`:case`select`:return e.value;case`set`:case`numberSet`:case`textSet`:case`dateSet`:case`custom`:return``}},gt=(e,t,n)=>{if(e.mode===`blank`||e.mode===`notBlank`){let n=e.mode===`blank`;return e=>et(L(e,t))===n}if(e.mode===`range`){let{min:r,max:i}=e;return(e,a)=>{let o=n?n[a]:nt(L(e,t));return Number.isFinite(o)&&o>=r&&o<=i}}let{operator:r,value:i}=e;return(e,a)=>{let o=n?n[a]:nt(L(e,t));if(!Number.isFinite(o))return!1;switch(r){case`>`:return o>i;case`>=`:return o>=i;case`<`:return o<i;case`<=`:return o<=i;case`!=`:return o!==i;default:return o===i}}},_t=(e,t)=>{if(e.mode===`blank`||e.mode===`notBlank`){let n=e.mode===`blank`;return e=>et(L(e,t))===n}let n=e.value.toLowerCase(),r=e.mode;return e=>{let i=String(L(e,t)??``).toLowerCase();switch(r){case`equals`:return i===n;case`startsWith`:return i.startsWith(n);case`endsWith`:return i.endsWith(n);default:return i.includes(n)}}},vt=(e,t,n)=>{let r=new Set(t);return e===`exclude`?e=>!r.has(String(L(e,n)??``)):e=>r.has(String(L(e,n)??``))},R=(e,t,n)=>{let r=new Set(t);return e===`exclude`?e=>!r.has(ct(L(e,n))):e=>r.has(ct(L(e,n)))},yt=(e,t,n)=>{let r=dt(e,n,qe(t.dateFilterPresets));if(r===null)return()=>!0;if(r.mode===`blank`||r.mode===`notBlank`){let e=r.mode===`blank`;return n=>et(L(n,t))===e}if(r.mode===`range`){let{from:e,to:n}=r;return r=>{let i=st(L(r,t));return i!==null&&i>=e&&i<=n}}let{mode:i,value:a}=r;return e=>{let n=st(L(e,t));if(n===null)return!1;switch(i){case`onOrAfter`:return n>=a;case`onOrBefore`:return n<=a;case`notEquals`:return n!==a;default:return n===a}}},bt=(e,t,n,r)=>{if(!tt(t))return null;let i=t;if(e.filterFn){let t=e.filterFn;return e=>t(e,i)}switch(i.kind){case`set`:return vt(i.mode,i.values,e);case`number`:{let t=i.parsed;if(t===null){let t=i.raw.toLowerCase();return n=>String(L(n,e)??``).toLowerCase().includes(t)}return gt(t,e,n)}case`numberSet`:case`textSet`:case`dateSet`:{let t=i.kind===`numberSet`?i.condition?gt(i.condition,e,n):null:i.kind===`textSet`?i.condition?_t(i.condition,e):null:i.condition?yt(i.condition,e,r??new Date):null,a=i.set?i.kind===`dateSet`?R(i.set.mode,i.set.values,e):vt(i.set.mode,i.set.values,e):null;return t&&a?(e,n)=>t(e,n)&&a(e,n):t??a}case`select`:{let t=i.value;return n=>String(L(n,e)??``)===t}case`text`:case`date`:{let t=i.value.trim().toLowerCase();return n=>String(L(n,e)??``).toLowerCase().includes(t)}case`custom`:{let t=String(i.value??``).trim().toLowerCase();return n=>String(L(n,e)??``).toLowerCase().includes(t)}}},xt=(e,t,n)=>{let r=t.length;for(let i=0;i<r;i+=1){let r=L(e,t[i]);if(String(r??``).toLowerCase().includes(n))return!0}return!1},St=(e,t,n,r)=>{let i=r.trim().toLowerCase();if(!i)return t;let a=t.length,o=new Int32Array(a),s=0;for(let r=0;r<a;r+=1){let a=t[r];xt(e[a],n,i)&&(o[s]=a,s+=1)}return s===a?t:o.slice(0,s)},Ct=(e,t,n,r,i,a)=>{let o=[],s=a??new Date;for(let e of n){let t=bt(e,r[e.key],i?.get(e.key),s);t&&o.push(t)}if(o.length===0)return t;let c=t.length,l=o.length,u=new Int32Array(c),d=0;for(let n=0;n<c;n+=1){let r=t[n],i=e[r],a=!0;for(let e=0;e<l;e+=1)if(!o[e](i,r)){a=!1;break}a&&(u[d]=r,d+=1)}return d===c?t:u.slice(0,d)},wt={operator:`gte`,value1:``,value2:``},Tt=[{value:`gte`,label:`以上`},{value:`gt`,label:`より大きい`},{value:`lte`,label:`以下`},{value:`lt`,label:`未満`},{value:`eq`,label:`に等しい`},{value:`ne`,label:`に等しくない`},{value:`between`,label:`範囲`},{value:`blank`,label:`空白`},{value:`notBlank`,label:`空白でない`}],Et=e=>e===`blank`||e===`notBlank`?0:e===`between`?2:1,Dt=e=>{let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null},Ot={gte:`>=`,gt:`>`,lte:`<=`,lt:`<`,eq:`=`,ne:`!=`},kt=e=>{if(e.operator===`blank`||e.operator===`notBlank`)return{mode:e.operator};if(e.operator===`between`){let t=Dt(e.value1),n=Dt(e.value2);return t!==null&&n!==null?{mode:`range`,min:Math.min(t,n),max:Math.max(t,n)}:t===null?n===null?null:{mode:`comparison`,operator:`<=`,value:n}:{mode:`comparison`,operator:`>=`,value:t}}let t=Dt(e.value1);return t===null?null:{mode:`comparison`,operator:Ot[e.operator],value:t}},z=e=>{switch(e.mode){case`comparison`:switch(e.operator){case`>=`:return`${e.value} 以上`;case`>`:return`${e.value} より大きい`;case`<=`:return`${e.value} 以下`;case`<`:return`${e.value} 未満`;case`!=`:return`${e.value} に等しくない`;default:return`${e.value} に等しい`}case`range`:return`${e.min} 〜 ${e.max}`;case`blank`:return`(空白)`;case`notBlank`:return`(空白でない)`}},At=e=>{let t=kt(e);return t===null?null:{kind:`number`,raw:z(t),parsed:t}},jt=(e,t)=>t?e.filter(e=>rt(t,e.value)):e,Mt={">=":`gte`,">":`gt`,"<=":`lte`,"<":`lt`,"=":`eq`,"!=":`ne`},Nt=e=>{if(!e)return wt;switch(e.mode){case`comparison`:return{operator:Mt[e.operator],value1:String(e.value),value2:``};case`range`:return{operator:`between`,value1:String(e.min),value2:String(e.max)};case`blank`:case`notBlank`:return{operator:e.mode,value1:``,value2:``}}},Pt=e=>Nt(e?.parsed),Ft={operator:`contains`,value:``},It=[{value:`contains`,label:`を含む`},{value:`equals`,label:`に等しい`},{value:`startsWith`,label:`で始まる`},{value:`endsWith`,label:`で終わる`},{value:`blank`,label:`空白`},{value:`notBlank`,label:`空白でない`}],Lt=e=>e===`blank`||e===`notBlank`?0:1,Rt=e=>{if(e.operator===`blank`||e.operator===`notBlank`)return{mode:e.operator};let t=e.value.trim();return t?{mode:e.operator,value:t}:null},zt=e=>{switch(e.mode){case`contains`:return`"${e.value}" を含む`;case`equals`:return`"${e.value}" に等しい`;case`startsWith`:return`"${e.value}" で始まる`;case`endsWith`:return`"${e.value}" で終わる`;case`blank`:return`(空白)`;case`notBlank`:return`(空白でない)`}},Bt=e=>e?e.mode===`blank`||e.mode===`notBlank`?{operator:e.mode,value:``}:{operator:e.mode,value:e.value}:Ft,Vt=(e,t)=>t?e.filter(e=>it(t,e.value)):e,Ht={operator:`range`,value1:``,value2:``,preset:null},Ut=[{value:`range`,label:`範囲`},{value:`onOrAfter`,label:`以降`},{value:`onOrBefore`,label:`以前`},{value:`equals`,label:`に等しい`},{value:`notEquals`,label:`に等しくない`},{value:`blank`,label:`空白`},{value:`notBlank`,label:`空白でない`}],Wt=e=>e===`blank`||e===`notBlank`?0:e===`range`?2:1,Gt=e=>{let t=e.trim();return/^\d{4}-\d{2}-\d{2}$/.test(t)?t:null},Kt=e=>{if(e.preset!==null)return{mode:`preset`,preset:e.preset};if(e.operator===`blank`||e.operator===`notBlank`)return{mode:e.operator};if(e.operator===`range`){let t=Gt(e.value1),n=Gt(e.value2);return t!==null&&n!==null?t<=n?{mode:`range`,from:t,to:n}:{mode:`range`,from:n,to:t}:t===null?n===null?null:{mode:`onOrBefore`,value:n}:{mode:`onOrAfter`,value:t}}let t=Gt(e.value1);return t===null?null:{mode:e.operator,value:t}},qt=(e,t)=>{switch(e.mode){case`range`:return`${e.from} 〜 ${e.to}`;case`onOrAfter`:return`${e.value} 以降`;case`onOrBefore`:return`${e.value} 以前`;case`equals`:return`${e.value} に等しい`;case`notEquals`:return`${e.value} に等しくない`;case`blank`:return`(空白)`;case`notBlank`:return`(空白でない)`;case`preset`:return Je(e.preset,t)}},Jt=e=>{if(!e)return Ht;switch(e.mode){case`preset`:return{...Ht,preset:e.preset};case`range`:return{operator:`range`,value1:e.from,value2:e.to,preset:null};case`blank`:case`notBlank`:return{operator:e.mode,value1:``,value2:``,preset:null};default:return{operator:e.mode,value1:e.value,value2:``,preset:null}}},Yt=(e,t,n,r)=>t?e.filter(e=>ft(t,e.value,n,r)):e,Xt=({anchorTop:e,anchorBottom:t,anchorRight:n,viewportWidth:r,viewportHeight:i,popupWidth:a,popupHeight:o,offsetY:s,viewportMargin:c})=>{let l=Math.max(0,i-c*2),u=Math.min(o,l),d=n-a;d=Math.max(c,d),d=Math.min(d,r-a-c);let f=t+s;return f+u>i-c&&(f=e-u-s),f=Math.min(f,i-c-u),f=Math.max(c,f),{top:f,left:d,maxHeight:l}},Zt=240,Qt=8,$t=8,en=230,tn=340,B=480,nn=({visibleColumns:t,columnFilterValues:n,enableColumnFilter:r,gridRootRef:i,resolveColumnFilterType:a})=>{let[o,s]=(0,e.useState)(null),[c,l]=(0,e.useState)(null),u=(0,e.useRef)(null),d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=(0,e.useRef)(null),m=(0,e.useRef)(null),h=o!==null,g=o?.columnKey??null,_=o?.filterType??null,v=(0,e.useMemo)(()=>{if(!g)return null;let e=t.find(e=>e.key===g)??null;return!e||!_||e.filterType===_?e:{...e,filterType:_}},[g,t,_]),y=(0,e.useCallback)(()=>{if(!g||!d.current){l(null);return}let e=d.current.getBoundingClientRect(),t=v?.filterType===`numberSet`||v?.filterType===`textSet`||v?.filterType===`dateSet`?B:v?.filterType===`set`?tn:en,{top:n,left:r,maxHeight:i}=Xt({anchorTop:e.top,anchorBottom:e.bottom,anchorRight:e.right,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,popupWidth:Zt,popupHeight:m.current??t,offsetY:$t,viewportMargin:Qt});l(e=>e&&e.top===n&&e.left===r&&e.width===Zt&&e.maxHeight===i?e:{top:n,left:r,width:Zt,maxHeight:i})},[g,v]),b=(0,e.useCallback)(e=>{if(!r)return;document.activeElement instanceof HTMLElement&&document.activeElement.blur(),i.current?.blur();let t=i.current?.querySelectorAll(`[data-ssg-col-key]`),o=t?Array.from(t).find(t=>t.dataset.ssgColKey===e.key)??null:null;d.current=o;let c=e.filterType===`auto`&&a?a(e):e.filterType??`text`,l=n[e.key],u=c===`number`?Pt(mt(l)?l:void 0):c===`numberSet`?Nt(Ze(l)?l.condition:void 0):null,f=c===`textSet`?Bt(Qe(l)?l.condition:void 0):null,p=c===`dateSet`?Jt($e(l)?l.condition:void 0):null;s({columnKey:e.key,filterType:c,draftValue:ht(l),numberDraft:u,textDraft:f,dateDraft:p})},[n,r,i,a]),x=(0,e.useCallback)(()=>{s(null),l(null),d.current=null,f.current=null,p.current=null,m.current=null,requestAnimationFrame(()=>{i.current?.focus()})},[i]),S=(0,e.useCallback)(e=>{s(t=>t&&{...t,draftValue:e})},[]),C=(0,e.useCallback)(e=>{s(t=>t&&{...t,numberDraft:e})},[]),w=(0,e.useCallback)(e=>{s(t=>t&&{...t,textDraft:e})},[]),T=(0,e.useCallback)(e=>{s(t=>t&&{...t,dateDraft:e})},[]);(0,e.useEffect)(()=>{if(!g)return;y();let e=()=>{y()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[g,y]);let E=c!==null;return(0,e.useEffect)(()=>{let e=u.current;if(!E||!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let e=u.current?.getBoundingClientRect().height??null;e===null||e===m.current||(m.current=e,y())});return t.observe(e),()=>{t.disconnect()}},[E,y]),(0,e.useEffect)(()=>{if(!v||!c)return;let e=v.filterType??`text`,t=0,n=0;return t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{if(e===`select`){p.current?.focus();return}let t=f.current;if(t&&(t.focus(),t.type===`text`)){let e=t.value.length;t.setSelectionRange(e,e)}})}),()=>{cancelAnimationFrame(t),cancelAnimationFrame(n)}},[v,c?.top,c?.left,c?.width]),(0,e.useEffect)(()=>{if(!h)return;let e=e=>{let t=e.target;t&&(u.current?.contains(t)||x())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[x,h]),{filterPopoverState:o,filterPopoverLayout:c,filterPopoverRef:u,filterTextInputRef:f,filterSelectRef:p,isFilterPopoverOpen:h,openedFilterColumn:v,openedFilterType:_,openColumnFilterPopover:b,closeColumnFilterPopover:x,updateFilterPopoverDraft:S,updateFilterPopoverNumberDraft:C,updateFilterPopoverTextDraft:w,updateFilterPopoverDateDraft:T}},V=`入力値が不正です`,rn=e=>e===!0?{valid:!0,message:``}:e===!1?{valid:!1,message:V}:typeof e==`string`?{valid:!1,message:e||`入力値が不正です`}:{valid:!1,message:e.message||`入力値が不正です`},H=(e,t,n)=>{if(!e.validate)return null;let r=rn(e.validate({value:n,row:t,column:e}));return r.valid?null:r.message},an=(e,t,n)=>{if((e.validationMode??`mark`)!==`reject`)return{action:`write`};let r=H(e,t,n);return r===null?{action:`write`}:{action:`reject`,message:r}},on=(e,t,n)=>{let r=t.filter(e=>e.validate);if(r.length===0)return[];let i=[];return e.forEach((e,t)=>{for(let a of r){let r=H(a,e,L(e,a));r!==null&&i.push({rowKey:n(e,t)??t,sourceRowIndex:t,columnKey:a.key,message:r})}}),i},sn=e=>{let t=e.replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`);return t?t.split(`
|
|
4
|
-
`).filter(e=>e.length>0).map(e=>e.split(` `)):[]},
|
|
5
|
-
`)}if(r.type===`row`){let t=ce(r.startRow,r.endRow);for(let r=t.startRow;r<=t.endRow;r+=1){let t=e(r);if(!t)continue;let a=n.map(e=>{let n=
|
|
6
|
-
`)}let a=le(r.startCol,r.endCol);for(let r=0;r<t;r+=1){let t=e(r);if(!t)continue;let o=[];for(let e=a.startCol;e<=a.endCol;e+=1){let r=n[e];if(!r)continue;let i=
|
|
7
|
-
`)},
|
|
8
|
-
`)},[n,r]);return{isWholeGridSelected:g,handleCopy:(0,e.useCallback)(async()=>{let e=g?_():V(n.getRow,n.getRowCount(),r,i.selection);e&&await an(e)},[g,n,_,i.selection,r]),handlePaste:(0,e.useCallback)(e=>{if(s||!d&&!p||!i.activeCell)return;let h=e.clipboardData.getData(`text/plain`);if(!h)return;e.preventDefault();let g=nn(h);if(g.length===0)return;let _=g.reduce((e,t)=>Math.max(e,t.length),0);if(_===0)return;let v=i.activeCell.row,y=i.activeCell.col;if(p){let e=rn(e=>n.getRow(e),r,g,v,y,(e,t,n,r)=>ke({readOnly:s,canEditCell:c},e,t,n,r));e.length>0&&p(e);let t=o(i.activeCell.row+Math.max(g.length-1,0),0,Math.max(n.getRowCount()-1,0)),l=o(i.activeCell.col+Math.max(_-1,0),0,Math.max(r.length-1,0));m(a.startSelection(i.activeCell)),m(a.updateSelection({row:t,col:l})),m(a.endSelection()),m(a.activateCell(i.activeCell));return}if(!d)return;let b=n.getSourceIndex(v);if(b===void 0)return;let x=i.activeCell.col,S=[...t],C=[...r],w=n.getRowCount(),T=S.length,E=e=>e<w?n.getSourceIndex(e):T+(e-w),D=b+g.length;if(D>S.length&&l)for(;S.length<D;)S.push(l());let O=x+_;if(O>C.length&&f&&u){for(;C.length<O;)C.push(u(C.length));f(C)}let k=H(S,E,C,g,v,x,(e,t,n,r)=>ke({readOnly:s,canEditCell:c},e,t,n,r)),A=o(i.activeCell.row+Math.max(g.length-1,0),0,Math.max(Math.max(n.getRowCount()-1,0),v+g.length-1)),j=o(i.activeCell.col+Math.max((g[0]?.length??1)-1,0),0,Math.max(Math.max(C.length-1,0),x+_-1));d(k),m(a.startSelection(i.activeCell)),m(a.updateSelection({row:A,col:j})),m(a.endSelection()),m(a.activateCell(i.activeCell))},[p,c,u,l,m,f,d,s,n,t,i.activeCell,r])}},sn=e=>{if(e<0)return``;let t=e,n=``;for(;t>=0;)n=String.fromCharCode(t%26+65)+n,t=Math.floor(t/26)-1;return n},cn=(e,t,n)=>e?e(t):n,ln=(e,t=16)=>e.length<=t?e:`${e.slice(0,t)}…`,W=e=>e?`${sn(e.col)}${e.row+1}`:`なし`,G=e=>{if(!e)return`なし`;if(e.type===`cell`){let t=Math.min(e.range.start.row,e.range.end.row),n=Math.max(e.range.start.row,e.range.end.row),r=Math.min(e.range.start.col,e.range.end.col),i=Math.max(e.range.start.col,e.range.end.col);return`${sn(r)}${t+1} - ${sn(i)}${n+1}`}if(e.type===`row`){let t=Math.min(e.startRow,e.endRow),n=Math.max(e.startRow,e.endRow);return`Row ${t+1} - ${n+1}`}let t=Math.min(e.startCol,e.endCol),n=Math.max(e.startCol,e.endCol);return`Col ${sn(t)} - ${sn(n)}`},un=(e,t)=>`Rows: ${t} / ${e.rows.length}`,dn=e=>`Columns: ${e.visibleColumns.length} / ${e.columns.length}`,fn=(e,t)=>{let n=e.selection;if(!n)return{selectedCellCount:0,selectedRowCount:0,selectedColumnCount:0};if(n.type===`cell`){let e=Math.min(n.range.start.row,n.range.end.row),t=Math.max(n.range.start.row,n.range.end.row),r=Math.min(n.range.start.col,n.range.end.col),i=Math.max(n.range.start.col,n.range.end.col),a=t-e+1,o=i-r+1;return{selectedCellCount:a*o,selectedRowCount:a,selectedColumnCount:o}}if(n.type===`row`){let t=Math.min(n.startRow,n.endRow),r=Math.max(n.startRow,n.endRow)-t+1,i=e.visibleColumns.length;return{selectedCellCount:r*i,selectedRowCount:r,selectedColumnCount:i}}let r=Math.min(n.startCol,n.endCol),i=Math.max(n.startCol,n.endCol)-r+1,a=t;return{selectedCellCount:a*i,selectedRowCount:a,selectedColumnCount:i}},pn=(e,t)=>{let n=fn(e,t);return`Cells: ${n.selectedCellCount} / Rows: ${n.selectedRowCount}`},mn=e=>Object.values(e).filter(e=>Ye(e)).length,hn=e=>{let t=e.globalFilterText.trim().length>0,n=t?ln(e.globalFilterText.trim()):null,r=mn(e.columnFilterValues);return!t&&r===0?`Filter: なし`:t&&r===0?`Filter: Global("${n}")`:!t&&r>0?`Filter: ${r}列`:`Filter: Global("${n}") + ${r}列`},gn=(e,t)=>{let n=e.find(e=>e.key===t);return n?.title||n?.key||t},_n=e=>e.sortState.length===0?`Sort: なし`:`Sort: ${e.sortState.map(t=>`${gn(e.columns,t.columnKey)} (${t.direction===`asc`?`昇順`:`降順`})`).join(`, `)}`,vn=(e,t)=>{let n=fn(e,t),r=e.globalFilterText.trim().length>0,i=r?ln(e.globalFilterText.trim()):null,a=mn(e.columnFilterValues),o=r||a>0,s=e.sortState.length>0,c=s?gn(e.columns,e.sortState[0].columnKey):null;return{rowSummaryText:un(e,t),columnSummaryText:dn(e),filterSummaryText:hn(e),sortSummaryText:_n(e),activeCellLabel:W(e.activeCell),selectionLabel:G(e.selection),selectionStatsText:pn(e,t),selectionStats:n,hasGlobalFilter:r,globalFilterPreview:i,activeColumnFilterCount:a,hasAnyFilter:o,hasSorting:s,sortedColumnLabel:c}},yn=({rows:t,viewRowCount:n,getFilteredRows:r,columns:i,visibleColumns:a,uiState:o,setGlobalFilterText:s,globalFilterStatus:c,globalFilterProgress:l})=>{let u=ue(o),d=o.filters.columnFilters,f=o.sort,p=o.activeCell,m=o.selection,h=(0,e.useMemo)(()=>({rows:t,columns:i,visibleColumns:a,globalFilterText:u,columnFilterValues:d,sortState:f,activeCell:p,selection:m}),[t,i,a,u,d,f,p,m]),g=(0,e.useMemo)(()=>vn(h,n),[h,n]);return{slotContextBase:h,derivedSummary:g,slotContext:(0,e.useMemo)(()=>({...h,get filteredRows(){return r()},setGlobalFilterText:s,derivedSummary:g,globalFilterStatus:c,globalFilterProgress:l}),[g,r,s,h,c,l])}},bn=({uiState:t,rows:n,visibleColumns:r,rowModel:i,setEditorInitialValue:s,onRowsChange:c,applyServerSideCellEdits:l,dispatch:u,gridRootRef:d,editorActionGuardRef:f})=>{let p=(0,e.useRef)({rowCount:0,colCount:0});(0,e.useEffect)(()=>{p.current={rowCount:i.getRowCount(),colCount:r.length}});let m=(0,e.useCallback)(e=>{u(a.startSelection(e)),u(a.endSelection()),u(a.activateCell(e))},[u]);return{activateSingleCell:m,startEditWithValue:(0,e.useCallback)((e,t)=>{s(t),u(a.startEdit(e))},[u,s]),commitEdit:(0,e.useCallback)((e,s)=>{if(f.current||!t.editingCell)return{status:`noop`};let h=t.editingCell,g=s===`down`?{row:h.row+1,col:h.col}:s===`up`?{row:h.row-1,col:h.col}:s===`right`?{row:h.row,col:h.col+1}:s===`left`?{row:h.row,col:h.col-1}:h,_=r[h.col],v=i.getSourceIndex(h.row),y=l?i.getRow(h.row):n[v];if(!_||!y)return u(a.stopEdit()),{status:`noop`};if(l){let t=Be(_,e,y),n=en(_,y,t);if(n.action===`reject`)return{status:`rejected`,message:n.message};l([{viewIndex:h.row,column:_,value:t}])}else if(c){let t=Be(_,e,y),r=en(_,y,t);if(r.action===`reject`)return{status:`rejected`,message:r.message};c(Ve(n,v,_,t))}return f.current=!0,requestAnimationFrame(()=>{d.current?.focus();let{rowCount:e,colCount:t}=p.current;m({row:o(g.row,0,Math.max(e-1,0)),col:o(g.col,0,Math.max(t-1,0))}),f.current=!1}),u(a.stopEdit()),{status:`committed`}},[m,l,u,f,i,d,c,n,t.editingCell,r]),cancelEdit:(0,e.useCallback)(()=>{f.current||(f.current=!0,u(a.stopEdit()),requestAnimationFrame(()=>{d.current?.focus(),f.current=!1}))},[u,f,d])}},xn=()=>({past:[],future:[]}),Sn=e=>e.past.length>0,Cn=e=>e.future.length>0,wn=(e,t,n)=>{if(n<=0)return e;let r=[...e.past,t];return{past:r.length>n?r.slice(r.length-n):r,future:[]}},Tn=(e,t)=>{if(e.past.length===0)return null;let n=e.past[e.past.length-1];return{stack:{past:e.past.slice(0,-1),future:[...e.future,t]},snapshot:n}},En=(e,t)=>{if(e.future.length===0)return null;let n=e.future[e.future.length-1];return{stack:{past:[...e.past,t],future:e.future.slice(0,-1)},snapshot:n}},Dn=({rows:t,selection:n,activeCell:r,onRowsChange:i,dispatch:o,enabled:s,limit:c,onUndoRedoStateChange:l,onAfterRestore:u})=>{let d=(0,e.useRef)(xn()),f=(0,e.useRef)(null),p=(0,e.useRef)(t),m=(0,e.useRef)({canUndo:!1,canRedo:!1}),h=(0,e.useCallback)(()=>{let e={canUndo:s&&i!=null&&Sn(d.current),canRedo:s&&i!=null&&Cn(d.current)};e.canUndo===m.current.canUndo&&e.canRedo===m.current.canRedo||(m.current=e,l?.(e))},[s,i,l]);(0,e.useEffect)(()=>{h()},[h]),(0,e.useEffect)(()=>{if(t!==p.current){if(p.current=t,f.current===t){f.current=null;return}f.current=null,d.current=xn(),h()}},[t,h]);let g=(0,e.useCallback)(e=>{let t=e.selection;t?.type===`cell`?(o(a.startSelection(t.range.start)),o(a.updateSelection(t.range.end)),o(a.endSelection())):t?.type===`row`?(o(a.startRowSelection(t.startRow)),o(a.updateRowSelection(t.endRow)),o(a.endSelection())):t?.type===`col`?(o(a.startColumnSelection(t.startCol)),o(a.updateColumnSelection(t.endCol)),o(a.endSelection())):o(a.clearSelection()),o(a.activateCell(e.activeCell))},[o]);return{handleRowsChange:(0,e.useMemo)(()=>{if(i)return e=>{s&&(d.current=wn(d.current,{rows:t,selection:n,activeCell:r},c),f.current=e,h()),i(e)}},[r,s,c,h,i,t,n]),undo:(0,e.useCallback)(()=>{if(!s||!i)return;let e=Tn(d.current,{rows:t,selection:n,activeCell:r});e&&(d.current=e.stack,f.current=e.snapshot.rows,i(e.snapshot.rows),g(e.snapshot),u?.(e.snapshot.activeCell),h())},[r,s,h,u,i,g,t,n]),redo:(0,e.useCallback)(()=>{if(!s||!i)return;let e=En(d.current,{rows:t,selection:n,activeCell:r});e&&(d.current=e.stack,f.current=e.snapshot.rows,i(e.snapshot.rows),g(e.snapshot),u?.(e.snapshot.activeCell),h())},[r,s,h,u,i,g,t,n]),canUndo:(0,e.useCallback)(()=>s&&i!=null&&Sn(d.current),[s,i]),canRedo:(0,e.useCallback)(()=>s&&i!=null&&Cn(d.current),[s,i]),clearHistory:(0,e.useCallback)(()=>{d.current=xn(),h()},[h])}},On=e=>e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey,kn=e=>e instanceof HTMLElement?e.closest(`input, textarea, select, button, [contenteditable="true"]`)!==null:!1,An=({uiState:t,rowModel:n,visibleColumns:r,readOnly:i,canEditCell:s,setEditorInitialValue:c,dispatch:l,handleCopy:u,handleCellDoubleClick:d,isWholeGridSelected:f,selectEntireGrid:p,onUndo:m,onRedo:h,onClearSelection:g,enableClearOnDelete:_,onToggleCheckboxCell:v,onToggleGroup:y})=>{let b=n.getRowCount(),x=(0,e.useCallback)((e,n,i)=>{if(b===0||r.length===0)return;let s=t.activeCell??{row:0,col:0},c={row:o(s.row+e,0,b-1),col:o(s.col+n,0,r.length-1)};if(i){let e=t.selection?.type===`cell`?t.selection.range.start:s;l(a.startSelection(e)),l(a.updateSelection(c)),l(a.endSelection()),l(a.activateCell(c));return}l(a.startSelection(c)),l(a.endSelection()),l(a.activateCell(c))},[l,b,t.activeCell,t.selection,r.length]);return{handleKeyDown:(0,e.useCallback)(async e=>{if(!kn(e.target)&&!t.editingCell){if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`c`){e.preventDefault(),await u();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`){if(e.preventDefault(),f){l(a.clearSelection()),l(a.activateCell(null));return}p();return}if((e.ctrlKey||e.metaKey)&&!e.nativeEvent.isComposing){if(e.key.toLowerCase()===`z`){e.preventDefault(),e.shiftKey?h():m();return}if(e.key.toLowerCase()===`y`&&!e.shiftKey){e.preventDefault(),h();return}}if(e.key===`ArrowUp`){e.preventDefault(),x(-1,0,e.shiftKey);return}if(e.key===`ArrowDown`){e.preventDefault(),x(1,0,e.shiftKey);return}if(e.key===`ArrowLeft`){e.preventDefault(),x(0,-1,e.shiftKey);return}if(e.key===`ArrowRight`){e.preventDefault(),x(0,1,e.shiftKey);return}if(e.key===`Tab`){e.preventDefault(),x(0,e.shiftKey?-1:1,!1);return}if(e.key===`Escape`){e.preventDefault(),l(a.clearSelection());return}if((e.key===`Delete`||e.key===`Backspace`)&&_){e.preventDefault(),g();return}if((e.key===`Enter`||e.key===` `)&&t.activeCell){let r=n.getGroupRow?.(t.activeCell.row);if(r){e.preventDefault(),y(r.groupKey);return}}if(e.key===`Enter`||e.key===`F2`){e.preventDefault(),t.activeCell&&d(t.activeCell);return}if(On(e)&&t.activeCell){let o=n.getRow(t.activeCell.row),u=r[t.activeCell.col];if(!o||!u||!ke({readOnly:i,canEditCell:s},t.activeCell.row,t.activeCell.col,o,u))return;if(u.editor?.type===`checkbox`){e.preventDefault(),e.key===` `&&v(t.activeCell);return}e.preventDefault(),c(e.key),l(a.startEdit(t.activeCell))}}},[s,l,n,d,u,f,x,g,_,h,v,y,m,i,p,c,t.activeCell,t.editingCell,r])}},jn=new Intl.Collator(`ja`,{numeric:!0,sensitivity:`base`}),Mn=(e,t)=>{let n=Number(e),r=Number(t);return Number.isFinite(n)&&Number.isFinite(r)?n-r:jn.compare(String(e??``),String(t??``))},Nn=(e,t,n,r)=>{if(!r)return e.length===1&&e[0].columnKey===t&&e[0].direction===n?[]:[{columnKey:t,direction:n}];let i=e.findIndex(e=>e.columnKey===t);return i===-1?[...e,{columnKey:t,direction:n}]:e[i].direction===n?e.filter((e,t)=>t!==i):e.map((e,r)=>r===i?{columnKey:t,direction:n}:e)},Pn=(e,t,n)=>e.some(e=>e.columnKey===t)?e:[...e,{columnKey:t,direction:n}],Fn=(e,t,n)=>t<0||t>=e.length||e[t].direction===n?e:e.map((e,r)=>r===t?{...e,direction:n}:e),In=(e,t,n)=>t<0||t>=e.length||e[t].columnKey===n?e:e.map((e,r)=>r===t?{...e,columnKey:n}:e).filter((e,r)=>r===t||e.columnKey!==n),Ln=(e,t)=>t<0||t>=e.length?e:e.filter((e,n)=>n!==t),Rn=(e,t,n)=>{if(t<0||t>=e.length||n<0||n>=e.length||t===n)return e;let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r},zn=(e,t,n,r)=>{if(r.length===0)return t;let i=r.map(e=>{let t=n.find(t=>t.key===e.columnKey);return t?{column:t,multiplier:e.direction===`asc`?1:-1}:null}).filter(e=>e!==null);if(i.length===0)return t;let a=t.length,o=i.length,s=i.map(e=>e.multiplier),c=Array(o),l=!0;for(let n=0;n<o;n+=1){let r=i[n].column,o=new Float64Array(a),s=!0;for(let n=0;n<a;n+=1){let i=Number(R(e[t[n]],r));if(!Number.isFinite(i)){s=!1;break}o[n]=i}if(!s){l=!1;break}c[n]=o}let u=Array(a);for(let e=0;e<a;e+=1)u[e]=e;if(l)if(o===1){let e=c[0],n=s[0];u.sort((r,i)=>{let a=e[r]-e[i];return a===0?t[r]-t[i]:a*n})}else u.sort((e,n)=>{for(let t=0;t<o;t+=1){let r=c[t][e]-c[t][n];if(r!==0)return r*s[t]}return t[e]-t[n]});else{let n=i.map(({column:n})=>{let r=Array(a);for(let i=0;i<a;i+=1)r[i]=R(e[t[i]],n);return r});u.sort((e,r)=>{for(let t=0;t<o;t+=1){let i=Mn(n[t][e],n[t][r]);if(i!==0)return i*s[t]}return t[e]-t[r]})}let d=new Int32Array(a);for(let e=0;e<a;e+=1)d[e]=t[u[e]];return d},Bn=[`sum`,`min`,`max`,`avg`,`count`],Vn=e=>typeof e==`string`&&Bn.includes(e),Hn=()=>({count:0,numericCount:0,sum:0,min:1/0,max:-1/0}),Un=(e,t)=>{if(e.count+=1,t==null||t===``)return;let n=Number(t);Number.isFinite(n)&&(e.numericCount+=1,e.sum+=n,n<e.min&&(e.min=n),n>e.max&&(e.max=n))},K=(e,t)=>{switch(e){case`count`:return t.count;case`sum`:return t.numericCount>0?t.sum:void 0;case`avg`:return t.numericCount>0?t.sum/t.numericCount:void 0;case`min`:return t.numericCount>0?t.min:void 0;case`max`:return t.numericCount>0?t.max:void 0}},Wn=`(空白)`,Gn=`__ssg-group__:`,Kn=`__ssg_group__`,qn=e=>Gn+e.groupKey,Jn=e=>e<0,Yn=e=>-e-1,Xn=e=>{if(e==null||e===``)return`e`;let t=typeof e;return`${t===`number`?`n`:t===`boolean`?`b`:t===`string`?`s`:`o`}:${String(e)}`},Zn=e=>({groupColumns:e.filter(e=>e.rowGroup===!0),aggColumns:e.filter(e=>e.aggFunc!=null)}),Qn=(e,t,n,r)=>{let i=n.length,a=r.length,o=r.map(e=>typeof e.aggFunc==`function`),s=o.includes(!0),c=[],l=new Map,u=0,d=(e,t,n,i,a)=>{let s=`${t.key}\u0001${n}`,c=n===`e`;return u+=1,{groupRow:{kind:`group`,groupKey:e===null?s:`${e}\u0000${s}`,columnKey:t.key,value:c?null:i,label:c?Wn:String(i),level:a,leafCount:0,aggregates:{}},children:[],childIndex:new Map,leafSourceIndexes:[],accumulators:r.map(()=>Hn()),customValues:o.map(e=>e?[]:null),customRows:[]}},f=t.length;for(let o=0;o<f;o+=1){let u=t[o],f=e[u],p=null;if(a>0){p=Array(a);for(let e=0;e<a;e+=1)p[e]=R(f,r[e])}let m=c,h=l,g=null;for(let e=0;e<i;e+=1){let t=n[e],r=R(f,t),o=Xn(r),c=h.get(o);if(c||(c=d(g,t,o,r,e),m.push(c),h.set(o,c)),c.groupRow.leafCount+=1,p!==null){for(let e=0;e<a;e+=1){Un(c.accumulators[e],p[e]);let t=c.customValues[e];t!==null&&t.push(p[e])}s&&c.customRows.push(f)}e===i-1&&c.leafSourceIndexes.push(u),m=c.children,h=c.childIndex,g=c.groupRow.groupKey}}let p=e=>{for(let t=0;t<a;t+=1){let n=r[t];o[t]?e.groupRow.aggregates[n.key]=n.aggFunc({values:e.customValues[t]??[],rows:e.customRows,column:n}):Vn(n.aggFunc)&&(e.groupRow.aggregates[n.key]=K(n.aggFunc,e.accumulators[t]))}for(let t of e.children)p(t)};for(let e of c)p(e);return{roots:c,groupCount:u}},$n=(e,t)=>{let n=[],r=[],i=e=>{if(r.push(e.groupRow),n.push(-r.length),!t.has(e.groupRow.groupKey)){if(e.children.length>0){for(let t of e.children)i(t);return}for(let t of e.leafSourceIndexes)n.push(t)}};for(let t of e.roots)i(t);return{displayOrder:Int32Array.from(n),groups:r}},er=e=>{let t=[],n=e=>{t.push(e.groupRow);for(let t of e.children)n(t)};for(let t of e.roots)n(t);return t},tr=e=>er(e).map(e=>e.groupKey),nr=15e6,rr=(e,t,n,r)=>e&&t&&n>0&&n<=r,ir=1<<20,ar=(e,t)=>({rowCount:e,rowTop:e=>e*t,rowsHeight:(e,n)=>(n-e+1)*t,totalBodyHeight:e*t,rowAtContentY:n=>Math.min(Math.max(Math.floor(n/t),0),Math.max(e-1,0))}),or=(e,t,n,r)=>{if(r<n)return null;let i=Math.max(e,n),a=Math.min(t,r);return i>a?null:{start:i,end:a}},sr=(e,t)=>e*t,cr=(e,t)=>t===1?e:e/t,lr=(e,t,n,r)=>{let i=t*(1-n);return r.rowAtContentY(e-i)},ur=({rowCount:e,rowHeight:t,headerHeight:n,viewportHeight:r,scrollTop:i,overscan:a,maxBodyPx:o})=>{let s=e*t,c=Math.min(s,o),l=Math.max(n+s-r,0),u=Math.max(n+c-r,0),d=u>0&&s>c?l/u:1,f=Math.min(Math.max(i,0),u),p=f*d,m=Math.ceil(r/t)+1,h=Math.floor(p/t),g=Math.max(h-a,0),_=Math.min(h+m+a,e),v=d===1?0:Math.floor(g*t/ir)*ir,y=f-p+v,b=[],x=new Set;for(let e=g;e<_;e+=1)b.push({index:e,start:n+e*t-v}),x.add(e);return{physicalBodyHeight:c,logicalBodyHeight:s,scaleFactor:d,translateY:y,windowBaseOffsetPx:v,rows:b,rowIndexSet:x}},dr=({headerHeight:e,viewportHeight:t,scrollTop:n,overscan:r},i)=>{let a=i.rowCount,o=i.totalBodyHeight,s=o,c=Math.max(e+o-t,0),l=Math.min(Math.max(n,0),c),u=i.rowAtContentY(l),d=i.rowAtContentY(l+t),f=Math.max(u-r,0),p=Math.min(d+r+1,a),m=[],h=new Set;for(let t=f;t<p;t+=1)m.push({index:t,start:e+i.rowTop(t),size:i.rowsHeight(t,t)}),h.add(t);return{physicalBodyHeight:s,logicalBodyHeight:o,scaleFactor:1,translateY:0,windowBaseOffsetPx:0,rows:m,rowIndexSet:h}},fr=({rectLeft:e,rectTop:t,clientLeft:n,clientTop:r,clientWidth:i,clientHeight:a})=>{let o=e+n,s=t+r;return{left:o,top:s,right:o+i,bottom:s+a}},pr=(e,t,n,r)=>e<t+r?-1:+(e>n-r),mr=(e,t,n,r)=>{if(t===0)return e;let i=Math.max(r,0),a=e+t*n;return a<0?0:a>i?i:a},hr=(e,t,n)=>{let r=t.x-e.x,i=t.y-e.y;return r*r+i*i>=n*n},gr=({gridRootRef:t,bodyScrollRef:n,scrollContainerRef:r,leftPaneScrollRef:i,rightPaneScrollRef:s,pointerClientRef:c,autoScrollFrameRef:l,uiState:u,dispatch:d,enableRangeSelection:f,enableSorting:p,orderedColumns:m,filteredRowsLength:h,visibleColumnsLength:g,paneLayout:v,leftLeadingWidth:y,centerLeadingWidth:b,rightLeadingWidth:x,headerHeight:S,rowMetrics:C,verticalScaleFactor:w,setHoveredRowIndex:T,setHoveredColumnIndex:E,enableRowHover:D,enableColumnHeaderHover:O,enableRowSelection:k,onGutterRowSelect:A,onGutterRowSelectDrag:j})=>{let M=(0,e.useRef)(u.dragState);M.current=u.dragState;let ee=(0,e.useRef)(!1),N=(0,e.useRef)(null),P=(0,e.useRef)(null),F=(0,e.useRef)(!1),I=(0,e.useRef)(u.sort);I.current=u.sort;let te=(0,e.useRef)(m);te.current=m;let ne=(0,e.useRef)(p);ne.current=p;let re=u.dragState?.type??null,ie=(0,e.useCallback)((e,t)=>{let a=n.current;if(!a||h===0||g===0)return null;let c=a.getBoundingClientRect(),l=lr(a.scrollTop+t-c.top-S,r.current?.scrollTop??0,w,C),u=null,d=i.current;if(u===null&&d&&v.left.entries.length>0){let t=d.getBoundingClientRect();if(e<t.right){let n=e-t.left-y;u=_(v.left,n)}}let f=s.current;if(u===null&&f&&v.right.entries.length>0){let t=f.getBoundingClientRect();if(e>=t.left){let n=e-t.left-x;u=_(v.right,n)}}if(u===null&&v.center.entries.length>0){let t=a.scrollLeft+e-c.left-b;u=_(v.center,Math.max(t,0))}return u===null?null:{row:l,col:o(u,0,g-1)}},[n,i,s,r,h,g,v,y,b,x,S,C,w]),ae=(0,e.useRef)(ie);(0,e.useEffect)(()=>{ae.current=ie},[ie]);let oe=(0,e.useCallback)((e,t)=>{let n=M.current;if(!n||n.type!==`selection`)return;let r=ie(e,t);if(r){if(n.selectionKind===`cell`){d(a.updateSelection(r));return}if(n.selectionKind===`row`){d(a.updateRowSelection(r.row));return}n.selectionKind===`col`&&d(a.updateColumnSelection(r.col))}},[d,ie]);(0,e.useEffect)(()=>{let e=e=>{c.current={x:e.clientX,y:e.clientY},re===`columnResize`&&d(a.updateColumnResize(e.clientX))},t=()=>{ee.current=!1,d(a.endSelection()),d(a.endColumnResize())};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[d,c,re]),(0,e.useEffect)(()=>{if(re!==`selection`){l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);return}let e=()=>{let t=r.current,n=c.current;if(!t||!n){l.current=requestAnimationFrame(e);return}if(!F.current){let t=P.current;if(t&&!hr(t,n,6)){l.current=requestAnimationFrame(e);return}F.current=!0}let i=t.getBoundingClientRect(),a=fr({rectLeft:i.left,rectTop:i.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight}),o=M.current?.type===`selection`&&M.current.selectionKind===`col`,s=M.current?.type===`selection`&&M.current.selectionKind===`row`,u=o?0:pr(n.y,a.top,a.bottom,24),d=s?0:pr(n.x,a.left,a.right,24),f=mr(t.scrollTop,u,18,t.scrollHeight-t.clientHeight),p=mr(t.scrollLeft,d,18,t.scrollWidth-t.clientWidth);(f!==t.scrollTop||p!==t.scrollLeft)&&(t.scrollTo({top:f,left:p,behavior:`auto`}),oe(n.x,n.y)),l.current=requestAnimationFrame(e)};return l.current=requestAnimationFrame(e),()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[l,r,c,re,oe]);let se=(0,e.useCallback)((e,n)=>{n.preventDefault(),n.button===0&&(t.current?.focus(),c.current={x:n.clientX,y:n.clientY},P.current={x:n.clientX,y:n.clientY},F.current=!1,d(a.activateCell(e)),f&&d(a.startSelection(e)))},[d,f,t,c]),ce=(0,e.useCallback)((e,t)=>{if(D&&T(e.row),!f)return;let n=M.current;n?.type!==`selection`||n.selectionKind!==`cell`||(c.current={x:t.clientX,y:t.clientY},d(a.updateSelection(e)))},[d,f,c,T,D]),le=(0,e.useCallback)(e=>{e.preventDefault()},[]),ue=(0,e.useCallback)(()=>{if(N.current!==null)return;let e=()=>{if(!ee.current){N.current=null;return}let t=r.current,n=c.current;if(!t||!n){N.current=requestAnimationFrame(e);return}if(!F.current){let t=P.current;if(t&&!hr(t,n,6)){N.current=requestAnimationFrame(e);return}F.current=!0}let i=t.getBoundingClientRect(),a=fr({rectLeft:i.left,rectTop:i.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight}),o=pr(n.y,a.top,a.bottom,24),s=mr(t.scrollTop,o,18,t.scrollHeight-t.clientHeight);if(s!==t.scrollTop){t.scrollTo({top:s,left:t.scrollLeft,behavior:`auto`});let e=ae.current(n.x,n.y);e&&j(e.row)}N.current=requestAnimationFrame(e)};N.current=requestAnimationFrame(e)},[r,c,j]);return(0,e.useEffect)(()=>()=>{N.current!==null&&(cancelAnimationFrame(N.current),N.current=null)},[]),{updateSelectionFromPointer:oe,handleCellPointerDown:se,handleCellPointerEnter:ce,handleNativeDragStart:le,handleRowHeaderPointerDown:(0,e.useCallback)((e,n)=>{if(n.preventDefault(),n.button===0){if(t.current?.focus(),c.current={x:n.clientX,y:n.clientY},P.current={x:n.clientX,y:n.clientY},F.current=!1,k){ee.current=!0,A(e,{shiftKey:n.shiftKey}),ue();return}d(a.startRowSelection(e))}},[d,t,k,A,ue,c]),handleRowHeaderPointerEnter:(0,e.useCallback)((e,t)=>{if(D&&T(e),ee.current){c.current={x:t.clientX,y:t.clientY},j(e);return}let n=M.current;n?.type!==`selection`||n.selectionKind!==`row`||(c.current={x:t.clientX,y:t.clientY},d(a.updateRowSelection(e)))},[d,c,T,D,j]),handleColumnHeaderPointerDown:(0,e.useCallback)((e,n)=>{if(n.preventDefault(),n.button===0){if(t.current?.focus(),c.current={x:n.clientX,y:n.clientY},P.current={x:n.clientX,y:n.clientY},F.current=!1,n.shiftKey&&ne.current){let t=te.current[e];if(t&&t.key!==`__ssg_group__`){let e=I.current,n=e.find(e=>e.columnKey===t.key)?.direction?`desc`:`asc`,r=Nn(e,t.key,n,!0);d(r.length===0?a.clearSort():a.setSort(r))}return}d(a.startColumnSelection(e))}},[d,t,c]),handleColumnHeaderPointerEnter:(0,e.useCallback)((e,t)=>{T(null),O&&E(e);let n=M.current;n?.type!==`selection`||n.selectionKind!==`col`||(c.current={x:t.clientX,y:t.clientY},d(a.updateColumnSelection(e)))},[d,c,T,E,O])}},_r=({scrollRef:t,columnVirtualizer:n,columnMeasurements:r,totalScrollWidth:i,physicalBodyHeight:a,headerHeight:o,leftPaneWidth:s,rightPaneWidth:c,centerLeadingWidth:l,activeCellRect:u,activeCell:d,verticalScaleFactor:f})=>{(0,e.useEffect)(()=>{n.measure()},[n,r]),(0,e.useEffect)(()=>{if(!t.current)return;let e=t.current,n=Math.max(i-e.clientWidth,0),r=Math.max(o+a-e.clientHeight,0);e.scrollLeft>n&&(e.scrollLeft=n),e.scrollTop>r&&(e.scrollTop=r)},[t,i,a,o]);let p=(0,e.useRef)(null);(0,e.useEffect)(()=>{let e=p.current,n=e!==null&&d!==null&&e.row===d.row&&e.col===d.col;if(p.current=d,n||!t.current||!u)return;let r=t.current,i=o+u.top,a=i+u.height,m=s+l+u.left,h=m+u.width,g=sr(r.scrollTop,f),_=r.scrollLeft,v=r.clientHeight,y=r.clientWidth,b=g,x=_,S=g+o,C=g+v;i<S?b=Math.max(i-o,0):a>C&&(b=Math.max(a-v,0));let w=_+s,T=_+y-c;m<w?x=Math.max(m-s,0):h>T&&(x=Math.max(h-y+c,0)),(b!==g||x!==_)&&r.scrollTo({top:cr(b,f),left:x,behavior:`auto`})},[t,u,d,o,s,c,l,f])};function vr(e){let{targetRect:t,tipWidth:n,tipHeight:r,viewportWidth:i}=e,a=t.left+t.width/2,o=Math.max(8,Math.min(Math.round(a-n/2),i-n-8)),s=Math.round(t.top-r-7);return s<8?{top:Math.round(t.bottom+7),left:o,below:!0}:{top:s,left:o,below:!1}}var yr=`data-ssg-tooltip`,q=`[${yr}], [data-ssg-tooltip-overflow]`,br=350,xr=800,Sr=0,Cr=null,wr=null,Tr=0,J=null;function Er(){if(Cr!==null)return Cr;let e=document.createElement(`div`);return e.className=`ssg-tooltip`,e.setAttribute(`aria-hidden`,`true`),document.body.appendChild(e),Cr=e,e}function Dr(){wr!==null&&(window.clearTimeout(wr),wr=null)}function Or(){Dr(),J!==null&&(Tr=Date.now()+xr),J=null,Cr!==null&&Cr.classList.remove(`ssg-tooltip--visible`)}function kr(e){let t=e.getAttribute(yr),n=t!==null&&t!==``?t:(e.textContent??``).trim();if(n===``)return;let r=Er();r.classList.toggle(`ssg-theme-dark`,e.closest(`.ssg-theme-dark`)!==null),r.textContent=n,r.style.left=`0px`,r.style.top=`0px`;let i=vr({targetRect:e.getBoundingClientRect(),tipWidth:r.offsetWidth,tipHeight:r.offsetHeight,viewportWidth:window.innerWidth});r.style.left=`${i.left}px`,r.style.top=`${i.top}px`,r.classList.add(`ssg-tooltip--visible`),J=e}function Ar(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(q);if(n===null||n===J||!n.hasAttribute(yr)&&n.scrollWidth<=n.clientWidth+1)return;let r=J!==null;Or(),r||Date.now()<Tr?kr(n):wr=window.setTimeout(()=>{wr=null,kr(n)},br)}function jr(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(q);if(n===null)return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||Or()}function Mr(){Or()}function Nr(e){e.key===`Escape`&&Or()}function Pr(){window.addEventListener(`pointerover`,Ar,!0),window.addEventListener(`pointerout`,jr,!0),window.addEventListener(`focusin`,Ar,!0),window.addEventListener(`focusout`,jr,!0),window.addEventListener(`pointerdown`,Mr,!0),window.addEventListener(`scroll`,Mr,!0),window.addEventListener(`keydown`,Nr,!0)}function Fr(){window.removeEventListener(`pointerover`,Ar,!0),window.removeEventListener(`pointerout`,jr,!0),window.removeEventListener(`focusin`,Ar,!0),window.removeEventListener(`focusout`,jr,!0),window.removeEventListener(`pointerdown`,Mr,!0),window.removeEventListener(`scroll`,Mr,!0),window.removeEventListener(`keydown`,Nr,!0)}function Ir(){(0,e.useEffect)(()=>(Sr+=1,Sr===1&&Pr(),()=>{--Sr,Sr===0&&(Fr(),Dr(),J=null,Cr!==null&&(Cr.remove(),Cr=null))}),[])}var Lr=`(prefers-color-scheme: dark)`;function Rr(e){if(typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(Lr);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}}function zr(){return typeof window.matchMedia==`function`?window.matchMedia(Lr).matches:!1}function Y(){return!1}function Br(t){let n=(0,e.useSyncExternalStore)(Rr,zr,Y);return t===`dark`||t===`auto`&&n?`dark`:`light`}function Vr(e,t,n,r){let i=e.find(e=>e.key===t);if(!i)return null;let a=c(i),o={left:[],center:[],right:[]},s=new Map;for(let t of e)o[c(t)].push(t.key),s.set(t.key,t.visible!==!1);let l=o[n].filter(e=>s.get(e)).indexOf(t),u=o[a].indexOf(t);if(u<0)return null;o[a].splice(u,1);let d=r;a===n&&l>=0&&d>l&&--d;let f=o[n].filter(e=>s.get(e));if(d=Math.max(0,Math.min(d,f.length)),a===n&&l>=0&&d===l)return null;let p;return p=d>=f.length?o[n].length:o[n].indexOf(f[d]),o[n].splice(p,0,t),[...o.left,...o.center,...o.right]}var Hr=32,Ur=2,Wr=14,Gr=12,Kr=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,qr=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/></svg>`,Jr=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,Yr=`0.5`,Xr=200,Zr=`cubic-bezier(0.2, 0.7, 0.3, 1)`,Qr=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,$r=e=>{if(!e)return null;let t=new Map;return e.querySelectorAll(`[data-ssg-col-key]`).forEach(e=>{let n=e.dataset.ssgColKey;n&&!t.has(n)&&t.set(n,e.getBoundingClientRect().left)}),t},ei=t=>{let n=(0,e.useRef)(t);n.current=t;let r=(0,e.useRef)(null),i=(0,e.useRef)(null),a=(0,e.useRef)(null),o=(0,e.useRef)(null),s=(0,e.useRef)(null),l=(0,e.useRef)(null),u=(0,e.useRef)({x:0,y:0}),d=(0,e.useRef)(null),f=(0,e.useRef)(!1),p=(0,e.useRef)(null),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useRef)(null),_=(0,e.useRef)(null),b=(0,e.useCallback)(()=>{for(let e of[r,i,a])e.current&&(e.current.style.display=`none`)},[]),x=(0,e.useCallback)(e=>{if(h.current)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),n.current.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`);let r=document.createElement(`span`);r.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let i=document.createElement(`span`);i.textContent=e,t.appendChild(r),t.appendChild(i),document.body.appendChild(t),h.current=t,g.current=r,_.current=null},[]),S=(0,e.useCallback)(e=>{let t=h.current;if(!t)return;let{x:n,y:r}=u.current;t.style.transform=`translate(`+(n+Wr)+`px,`+(r+Gr)+`px)`;let i=e??`out`;if(_.current===i)return;_.current=i;let a=g.current;i===`out`?(t.style.opacity=Yr,a&&(a.innerHTML=Jr)):(t.style.opacity=`1`,a&&(a.innerHTML=i===`center`?Kr:qr))},[]),C=(0,e.useCallback)(()=>{let e=h.current;e&&e.parentNode&&e.parentNode.removeChild(e),h.current=null,g.current=null,_.current=null},[]),w=(0,e.useCallback)((e,t)=>{let{paneLayout:r,leftPaneScrollRef:i,rightPaneScrollRef:a,bodyScrollRef:o,scrollContainerRef:s,leftLeadingWidth:c,centerLeadingWidth:l,rightLeadingWidth:u}=n.current,d=s.current;if(d){let n=d.getBoundingClientRect();if(e<n.left||e>n.right||t<n.top||t>n.bottom)return null}let f=i.current,p=a.current;if(f&&r.left.entries.length===0&&e<=f.getBoundingClientRect().left+Hr)return{pane:`left`,slot:0,leftPx:Ur};if(f&&r.left.entries.length>0){let t=f.getBoundingClientRect();if(e<t.right){let n=e-t.left-c,i=v(r.left,n);return{pane:`left`,slot:i,leftPx:c+y(r.left,i)}}}if(p&&r.right.entries.length===0&&e>=p.getBoundingClientRect().left-Hr)return{pane:`right`,slot:0,leftPx:-2};if(p&&r.right.entries.length>0){let t=p.getBoundingClientRect();if(e>=t.left){let n=e-t.left-u,i=v(r.right,n);return{pane:`right`,slot:i,leftPx:u+y(r.right,i)}}}let m=o.current;if(m&&r.center.entries.length>0){let t=m.getBoundingClientRect(),n=m.scrollLeft+e-t.left-l,i=v(r.center,Math.max(n,0));return{pane:`center`,slot:i,leftPx:l+y(r.center,i)}}return null},[]),T=(0,e.useCallback)(()=>{let e=w(u.current.x,u.current.y);if(S(e?e.pane:null),!e){s.current=null,b();return}s.current={pane:e.pane,slot:e.slot};let t={left:r.current,center:i.current,right:a.current};for(let n of[`left`,`center`,`right`]){let r=t[n];r&&(n===e.pane?(r.style.left=`${e.leftPx}px`,r.style.display=`block`):r.style.display=`none`)}},[w,b,S]),E=(0,e.useRef)(()=>{});E.current=(0,e.useCallback)(()=>{if(o.current===null){m.current=null;return}let e=n.current.scrollContainerRef.current;if(e){let t=u.current;if(!f.current){let e=d.current;(!e||hr(e,t,6))&&(f.current=!0)}if(f.current){let n=e.getBoundingClientRect(),r=fr({rectLeft:n.left,rectTop:n.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=pr(t.x,r.left,r.right,24),a=mr(e.scrollLeft,i,18,e.scrollWidth-e.clientWidth);a!==e.scrollLeft&&e.scrollTo({left:a,behavior:`auto`})}}T(),m.current=requestAnimationFrame(E.current)},[T]);let D=(0,e.useCallback)(e=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),document.body.style.cursor=``,b(),C();let t=o.current,r=s.current;if(o.current=null,s.current=null,!e||!t||!r)return;let{columns:i,applyColumnOrderAndPin:a,scrollContainerRef:u}=n.current,d=Vr(i,t,r.pane,r.slot);if(!d)return;let f=i.find(e=>e.key===t),p=f?c(f):null,h=p!==null&&p===r.pane;l.current=h&&!Qr()?$r(u.current):null,a(d,new Map([[t,r.pane===`center`?void 0:r.pane]]))},[b,C]),O=(0,e.useCallback)(()=>{let e=l.current;if(l.current=null,!e)return;let t=n.current.scrollContainerRef.current;if(!t)return;let r=new Map,i=new Map;t.querySelectorAll(`[data-ssg-col-key]`).forEach(t=>{let n=t.dataset.ssgColKey;if(!n||!e.has(n))return;let a=r.get(n);a?a.push(t):(r.set(n,[t]),i.set(n,t.getBoundingClientRect().left))});let a=[];if(r.forEach((t,n)=>{let r=e.get(n),o=i.get(n);if(r===void 0||o===void 0)return;let s=r-o;if(!(Math.abs(s)<.5))for(let e of t)e.style.transition=`none`,e.style.transform=`translateX(${s}px)`,e.style.willChange=`transform`,a.push(e)}),a.length!==0){t.getBoundingClientRect();for(let e of a)e.style.transition=`transform ${Xr}ms ${Zr}`,e.style.transform=`translateX(0)`;window.setTimeout(()=>{for(let e of a)e.style.transition=``,e.style.transform=``,e.style.willChange=``},280)}},[]),k=(0,e.useCallback)((e,t)=>{if(!n.current.enabled||t.button!==0)return;t.stopPropagation(),t.preventDefault(),o.current=e.key,u.current={x:t.clientX,y:t.clientY},d.current={x:t.clientX,y:t.clientY},f.current=!1,document.body.style.cursor=`grabbing`,x(e.title||e.key);let r=t.currentTarget,i=t.pointerId;try{r.setPointerCapture(i)}catch{}let a=e=>{e.pointerId===i&&(u.current={x:e.clientX,y:e.clientY},T())};function s(e){e.pointerId===i&&(l(),D(!0))}function c(e){e.pointerId===i&&(l(),D(!1))}let l=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),p.current=null;try{r.releasePointerCapture(i)}catch{}};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),p.current=l,T(),m.current=requestAnimationFrame(E.current)},[T,D,x]);return(0,e.useEffect)(()=>()=>{p.current?.(),p.current=null,m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),document.body.style.cursor=``;let e=h.current;e&&e.parentNode&&e.parentNode.removeChild(e),h.current=null,g.current=null,_.current=null},[]),{onColumnDragHandlePointerDown:k,leftIndicatorRef:r,centerIndicatorRef:i,rightIndicatorRef:a,applyReorderSettle:O}},ti=e=>e===``?`(空白)`:`"${e}"`,ni=(e,t)=>(e??`include`)===`exclude`?`${t.length} 件を除外`:t.length>0&&t.length<=2?t.map(ti).join(`, `):`${t.length} 件を選択`,ri=e=>{switch(e.kind){case`text`:case`date`:return`"${e.value.trim()}" を含む`;case`select`:return`"${e.value}" に一致`;case`number`:return e.raw;case`set`:return ni(e.mode,e.values);case`numberSet`:case`textSet`:case`dateSet`:{let t=e.condition?e.kind===`numberSet`?Ct(e.condition):e.kind===`textSet`?Mt(e.condition):Vt(e.condition):null,n=e.set?ni(e.set.mode,e.set.values):null;return t&&n?`${t} かつ ${n}`:t??n??`フィルターなし`}case`custom`:return typeof e.value==`string`&&e.value.trim().length>0?`"${e.value.trim()}"`:`カスタム条件`}},ii=/^\d{4}-\d{2}-\d{2}$/,ai=e=>{let t=new Set;for(let n of e)t.add(nt(n.value));let n=[],r=[],i=!1;for(let e of t)e===``?i=!0:ii.test(e)?n.push(e):r.push(e);n.sort(),r.sort();let a=n.map(e=>({label:e,value:e}));for(let e of r)a.push({label:e,value:e});return i&&a.push({label:`(空白)`,value:``}),a},oi=(e,t)=>{let n=new Map,r=[];for(let t of e){if(!ii.test(t.value)){r.push(t);continue}let e=t.value.slice(0,4),i=t.value.slice(0,7),a=n.get(e);a||(a=new Map,n.set(e,a));let o=a.get(i);o||(o=[],a.set(i,o)),o.push(t.value)}let i=[];for(let[e,r]of n){let n=`y:${e}`,a=[];for(let e of r.values())a.push(...e);let o=t.has(n);if(i.push({type:`group`,key:n,label:`${e} 年`,depth:0,leafKeys:a,expanded:o}),o)for(let[e,n]of r){let r=`m:${e}`,a=t.has(r);if(i.push({type:`group`,key:r,label:`${Number(e.slice(5,7))} 月`,depth:1,leafKeys:[...n],expanded:a}),a)for(let e of n)i.push({type:`leaf`,key:e,label:`${Number(e.slice(8,10))} 日`,depth:2,leafKeys:[e],expanded:!1})}}for(let e of r)i.push({type:`leaf`,key:e.value,label:e.label,depth:0,leafKeys:[e.value],expanded:!1});return i},si=1e3,ci=2e4,li=e=>{if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`string`)return!1;let t=e.trim();return!t||/^-?0\d/.test(t)?!1:Number.isFinite(Number(t))},ui=e=>tt(e)!==null,di=({editorType:e,isServerSide:t=!1,rowCount:n,getRawValueAt:r,sampleLimit:i=si,scanLimit:a=ci})=>{if(e===`number`)return{filterType:`numberSet`,source:`editor`,conclusive:!0};if(e===`date`)return{filterType:`dateSet`,source:`editor`,conclusive:!0};if(t)return{filterType:`text`,source:`fallback`,conclusive:!0};let o=Math.min(n,a),s=0,c=0,l=0;for(let e=0;e<o&&s<i;e+=1){let t=r(e);if(!Je(t)){if(s+=1,ui(t)){c+=1;continue}li(t)&&(l+=1)}}return s===0?{filterType:`textSet`,source:`fallback`,conclusive:!1}:c===s?{filterType:`dateSet`,source:`values`,conclusive:!0}:l===s?{filterType:`numberSet`,source:`values`,conclusive:!0}:{filterType:`textSet`,source:`values`,conclusive:!0}},fi=(e,t,n,r)=>{if(n===0||r===0)return null;let i=n-1,a=r-1;if(e?.type===`cell`){let t=se(e.range);return{startRow:o(t.start.row,0,i),endRow:o(t.end.row,0,i),startCol:o(t.start.col,0,a),endCol:o(t.end.col,0,a)}}if(e?.type===`row`){let t=ce(e.startRow,e.endRow);return{startRow:o(t.startRow,0,i),endRow:o(t.endRow,0,i),startCol:0,endCol:a}}if(e?.type===`col`){let t=le(e.startCol,e.endCol);return{startRow:0,endRow:i,startCol:o(t.startCol,0,a),endCol:o(t.endCol,0,a)}}return t?t.row>i||t.col>a?null:{startRow:t.row,endRow:t.row,startCol:t.col,endCol:t.col}:null},pi=({rows:e,resolveSourceIndex:t,columns:n,selection:r,activeCell:i,viewRowCount:a,canWriteCell:o})=>{let s=fi(r,i,a,n.length);if(!s)return{nextRows:e,changed:!1};let c=[...e],l=!1;for(let e=s.startRow;e<=s.endRow;e+=1){let r=t(e);if(r===void 0)continue;let i=c[r];if(!i)continue;let a=i,u=!1;for(let e=s.startCol;e<=s.endCol;e+=1){let t=n[e];if(!t||!o(r,e,i,t))continue;let s=ze(t)(``,i);Object.is(R(a,t),s)||en(t,i,s).action!==`reject`&&(a=Ae(a,t,s),u=!0)}u&&(c[r]=a,l=!0)}return l?{nextRows:c,changed:l}:{nextRows:e,changed:!1}},mi=({getRow:e,columns:t,selection:n,activeCell:r,viewRowCount:i,canWriteCell:a})=>{let o=fi(n,r,i,t.length);if(!o)return[];let s=[];for(let n=o.startRow;n<=o.endRow;n+=1){let r=e(n);if(r)for(let e=o.startCol;e<=o.endCol;e+=1){let i=t[e];if(!i||!a(n,e,r,i))continue;let o=ze(i)(``,r);Object.is(R(r,i),o)||en(i,r,o).action!==`reject`&&s.push({viewIndex:n,column:i,value:o})}}return s},hi=e=>{let{mode:t,isServerSide:n,rowCount:r,hasAutoSizedOnMount:i}=e;return t===!1||n||r===0?{shouldRun:!1,nextHasAutoSizedOnMount:i}:t===`onMount`?i?{shouldRun:!1,nextHasAutoSizedOnMount:!0}:{shouldRun:!0,nextHasAutoSizedOnMount:!0}:{shouldRun:!0,nextHasAutoSizedOnMount:i}},gi=(e,t,n)=>{let r=!1,i=e.map(e=>{let i=n[e.key]??e.width,a=t.get(e.key);if(!a)return i===e.width?e:{...e,width:i};let o=a.pinned??void 0,s=i!==a.width,c=(e.pinned??void 0)!==o,l=e.visible!==!1!=(a.visible!==!1);return(s||c||l)&&(r=!0),{...e,width:a.width,pinned:a.pinned,visible:a.visible}}),a=new Map(i.map(e=>[e.key,e])),o=[];for(let e of t.keys()){let t=a.get(e);t&&o.push(t)}let s=i.filter(e=>!t.has(e.key)),c=[...o,...s],l=c.some((t,n)=>e[n].key!==t.key);return!r&&!l?null:c},_i=(e,t)=>e.includes(t)||e.includes(`"`)||e.includes(`
|
|
9
|
-
`)||e.includes(`\r`)?`"${e.replace(/"/g,`""`)}"`:e,
|
|
10
|
-
`);return o?`\uFEFF${c}`:c},bi=({getRow:e,startRow:t,endRow:n,columns:r})=>{let i=r.map(e=>({key:e.key,title:e.title??e.key})),a=[];for(let i=t;i<n;i+=1){let t=e(i);t&&a.push(r.map(e=>{let n=R(t,e);return{value:n,text:e.formatClipboardValue?e.formatClipboardValue(n,t):String(n??``)}}))}return{columns:i,rows:a}},xi=e=>e===`all`?`view`:e===`visible`?`rendered`:e,Si=e=>{switch(e.kind){case`set`:return{...e,values:[...e.values]};case`number`:return{...e,parsed:e.parsed?{...e.parsed}:null};case`numberSet`:return{...e,condition:e.condition?{...e.condition}:null,set:e.set?{...e.set,values:[...e.set.values]}:null};case`textSet`:return{...e,condition:e.condition?{...e.condition}:null,set:e.set?{...e.set,values:[...e.set.values]}:null};case`dateSet`:return{...e,condition:e.condition?{...e.condition}:null,set:e.set?{...e.set,values:[...e.set.values]}:null};case`text`:case`date`:case`select`:return{...e};case`custom`:return{...e}}},Ci=e=>{let t={};for(let n of Object.keys(e))t[n]=Si(e[n]);return t},wi=e=>{let t={key:e.key};return e.visible!==void 0&&(t.visible=e.visible),e.pinned!==void 0&&(t.pinned=e.pinned),t},Ti=e=>e.map(e=>{let t={key:e.key};return e.visible!==void 0&&(t.visible=e.visible),e.pinned!==void 0&&(t.pinned=e.pinned),t}),Ei=(e,t,n,r=[],i=2)=>({version:i,columnWidths:{...e},filters:{globalText:t.globalText,columnFilters:Ci(t.columnFilters)},sort:n.map(e=>({...e})),columns:r.map(wi)}),Di=e=>{let t=e&&typeof e==`object`?e:{},n={},r=t.columnWidths;if(r&&typeof r==`object`){let e=r;for(let t of Object.keys(e)){let r=e[t];typeof r==`number`&&Number.isFinite(r)&&(n[t]=r)}}let i=t.filters&&typeof t.filters==`object`?t.filters:{},a=typeof i.globalText==`string`?i.globalText:``,o={},s=i.columnFilters;if(s&&typeof s==`object`){let e=s;for(let t of Object.keys(e)){let n=e[t];n&&typeof n==`object`&&`kind`in n&&(o[t]=Si(n))}}let c=[],l=t.sort;if(Array.isArray(l)){for(let e of l)if(e&&typeof e==`object`){let t=e;typeof t.columnKey==`string`&&(t.direction===`asc`||t.direction===`desc`)&&c.push({columnKey:t.columnKey,direction:t.direction})}}let u,d=t.columns;if(Array.isArray(d)){let e=[];for(let t of d){if(!t||typeof t!=`object`)continue;let n=t;if(typeof n.key!=`string`)continue;let r={key:n.key};typeof n.visible==`boolean`&&(r.visible=n.visible),(n.pinned===`left`||n.pinned===`right`)&&(r.pinned=n.pinned),e.push(r)}u=e}return{version:2,columnWidths:n,filters:{globalText:a,columnFilters:o},sort:c,columns:u}},Oi=(e,t,n)=>{let r=new Map(e.map(e=>[e.key,e])),i=new Set,a=(e,t)=>{let r=n[e.key],i=typeof r==`number`;if(!t&&!i)return e;let a={...e};return t&&(a.visible=t.visible,a.pinned=t.pinned),i&&(a.width=r),a},o=[];for(let e of t){let t=r.get(e.key);t&&(i.add(e.key),o.push(a(t,e)))}for(let t of e)i.has(t.key)||o.push(a(t,void 0));return l(o)},ki=(e,t)=>e===null||t===null?e===t:e.mode===`blank`||e.mode===`notBlank`||t.mode===`blank`||t.mode===`notBlank`?e.mode===t.mode:e.mode===t.mode&&e.value===t.value,Ai=(e,t)=>e===null||t===null?e===t:e.mode===t.mode?e.mode===`range`&&t.mode===`range`?e.from===t.from&&e.to===t.to:e.mode===`preset`&&t.mode===`preset`?e.preset===t.preset:e.mode===`blank`||e.mode===`notBlank`?!0:`value`in e&&`value`in t&&e.value===t.value:!1,ji=(e,t)=>e===null||t===null?e===t:(e.mode??`include`)===(t.mode??`include`)&&e.values.length===t.values.length&&e.values.every((e,n)=>e===t.values[n]),Mi=(e,t)=>e===null||t===null?e===t:e.mode===`comparison`&&t.mode===`comparison`?e.operator===t.operator&&e.value===t.value:e.mode===`range`&&t.mode===`range`?e.min===t.min&&e.max===t.max:e.mode===`blank`||e.mode===`notBlank`?e.mode===t.mode:!1,Ni=(e,t)=>{switch(e.kind){case`set`:return t.kind===`set`&&(e.mode??`include`)===(t.mode??`include`)&&e.values.length===t.values.length&&e.values.every((e,n)=>e===t.values[n]);case`number`:return t.kind===`number`&&e.raw===t.raw&&Mi(e.parsed,t.parsed);case`numberSet`:return t.kind===`numberSet`&&Mi(e.condition,t.condition)&&ji(e.set,t.set);case`textSet`:return t.kind===`textSet`&&ki(e.condition,t.condition)&&ji(e.set,t.set);case`dateSet`:return t.kind===`dateSet`&&Ai(e.condition,t.condition)&&ji(e.set,t.set);case`text`:return t.kind===`text`&&e.value===t.value;case`date`:return t.kind===`date`&&e.value===t.value;case`select`:return t.kind===`select`&&e.value===t.value;case`custom`:return t.kind===`custom`&&Object.is(e.value,t.value)}},Pi=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!(r in t)||e[r]!==t[r])return!1;return!0},Fi=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!(r in t)||!Ni(e[r],t[r]))return!1;return!0},X=(e,t)=>{if(e===void 0||t===void 0)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n].key!==t[n].key||e[n].visible!==t[n].visible||e[n].pinned!==t[n].pinned)return!1;return!0},Ii=(e,t)=>{if(e.version!==t.version||!Pi(e.columnWidths,t.columnWidths)||e.filters.globalText!==t.filters.globalText||!Fi(e.filters.columnFilters,t.filters.columnFilters)||e.sort.length!==t.sort.length)return!1;for(let n=0;n<e.sort.length;n+=1)if(e.sort[n].columnKey!==t.sort[n].columnKey||e.sort[n].direction!==t.sort[n].direction)return!1;return!!X(e.columns,t.columns)},Li=(e,t,n)=>n?{emit:!1,nextLast:e}:e===null||Ii(e,t)?{emit:!1,nextLast:t}:{emit:!0,nextLast:t},Ri=({rowTop:e,rowHeight:t,headerHeight:n,viewportHeight:r,currentScrollTop:i,align:a,maxScrollTop:o})=>{let s=n+e,c=s+t,l;if(a===`start`)l=s-n;else if(a===`end`)l=c-r;else if(a===`center`)l=(s+c)/2-(n+r)/2;else{let e=i+n,t=i+r;l=s>=e&&c<=t?i:s<e?s-n:c-r}return Math.min(Math.max(l,0),Math.max(o??1/0,0))},zi=({cellLeft:e,cellWidth:t,leftPaneWidth:n,rightPaneWidth:r,viewportWidth:i,currentScrollLeft:a,align:o,maxScrollLeft:s})=>{let c=e+t,l=i-n-r,u;if(o===`start`)u=e-n;else if(o===`end`)u=c-i+r;else if(o===`center`)u=(e+c)/2-n-l/2;else{let t=a+n,o=a+i-r;u=e>=t&&c<=o?a:e<t?e-n:c-i+r}return Math.min(Math.max(u,0),Math.max(s??1/0,0))},Bi=(e,t)=>{let{heights:n,prefix:r,rowCount:i}=e,a=Math.max(t,0);for(let e=a;e<i;e+=1)r[e+1]=r[e]+n[e]},Vi=(e,t,n,r)=>{let i=r??new Map,a=Math.max(e,0),o=new Float64Array(a);for(let e=0;e<a;e+=1){let r=i.get(n(e));o[e]=r===void 0?t:r}let s={rowCount:a,estimate:t,heights:o,prefix:new Float64Array(a+1),measured:i};return Bi(s,0),s},Hi=(e,t,n,r)=>t<0||t>=e.rowCount||(e.measured.set(n,r),e.heights[t]===r)?!1:(e.heights[t]=r,!0),Ui=(e,t,n)=>{if(t<=0||n<=0)return 0;if(n>=e[t])return t-1;let r=0,i=t;for(;r<i;){let t=r+i+1>>1;e[t]<=n?r=t:i=t-1}return Math.min(Math.max(r,0),t-1)},Wi=e=>{let{prefix:t,rowCount:n}=e;return{rowCount:n,rowTop:e=>t[Math.min(Math.max(e,0),n)],rowsHeight:(e,r)=>t[Math.min(Math.max(r+1,0),n)]-t[Math.min(Math.max(e,0),n)],totalBodyHeight:t[n],rowAtContentY:e=>Ui(t,n,e)}},Gi=21,Ki=4,qi=41,Z=13,Ji=600,Yi=60,Xi=16,Zi=null,Qi=()=>Zi||(typeof document>`u`?null:(Zi=document.createElement(`canvas`).getContext(`2d`),Zi)),$i=`system-ui, sans-serif`,ea=e=>{let t=$i,n=13,r=`400`;if(e&&typeof window<`u`){let i=window.getComputedStyle(e);i.fontFamily&&(t=i.fontFamily);let a=Number.parseFloat(i.fontSize);Number.isFinite(a)&&a>0&&(n=a),i.fontWeight&&(r=i.fontWeight)}return{cellFont:`${r} ${n}px ${t}`,headerFont:`${Ji} ${Z}px ${t}`}},ta=(e,t,n)=>Math.min(Math.max(e,t),n),Q=e=>e>=4352&&e<=4447||e>=11904&&e<=12350||e>=12353&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=40960&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=129791||e>=131072&&e<=262141,na=e=>{let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=Q(e)?2:1}return t},ra=(e,t)=>{let n=R(e,t);return t.valueFormatter?t.valueFormatter({value:n,row:e,column:t}):String(n??``)},ia=e=>{if(!e||typeof document>`u`)return null;let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;top:-99999px;left:-99999px;visibility:hidden;pointer-events:none;width:auto;height:auto;contain:layout style;`,e.appendChild(t),t},aa=e=>{let t=document.createElement(`div`);return t.className=`ssg-body-cell`,t.style.cssText=`display:inline-block;position:static;top:auto;left:auto;width:auto;height:auto;white-space:nowrap;overflow:visible;`,t.textContent=e,t},oa=e=>e.suppressAutoSize===!0||e.autoHeight===!0;function sa(e){let t=e.map(()=>[]),n=e.map(()=>[]),r=e.map(()=>1/0),i=e.map(()=>0);return{collect:a=>{for(let o=0;o<e.length;o+=1){if(oa(e[o]))continue;let s=e[o].estimateCellWidth;if(s){let t=s(a,e[o]);t>i[o]&&(i[o]=t);continue}let c=String(R(a,e[o])??``);if(c===``)continue;let l=t[o],u=n[o];if(l.length===Xi&&2*c.length<=r[o])continue;let d=na(c);if(l.length<Xi){if(l.push(a),u.push(d),l.length===Xi){let e=u[0];for(let t=1;t<Xi;t+=1)u[t]<e&&(e=u[t]);r[o]=e}continue}if(d<=r[o])continue;let f=0;for(let e=1;e<Xi;e+=1)u[e]<u[f]&&(f=e);l[f]=a,u[f]=d;let p=u[0];for(let e=1;e<Xi;e+=1)u[e]<p&&(p=u[e]);r[o]=p}},finalize:({gridRoot:n,currentWidths:r})=>{let a=Qi();if(!a||e.length===0)return{};let{cellFont:o,headerFont:s}=ea(n),c={},l=ia(n);try{let n=null;if(l){let r=[];for(let n=0;n<e.length;n+=1){if(oa(e[n])){r.push([]);continue}if(e[n].estimateCellWidth){r.push([]);continue}let i=t[n],a=[];for(let t=0;t<i.length;t+=1){let r=ra(i[t],e[n]);if(r===``)continue;let o=aa(r);l.appendChild(o),a.push(o)}r.push(a)}n=r.map(e=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e[n].offsetWidth;r>t&&(t=r)}return t})}for(let l=0;l<e.length;l+=1){let u=e[l];if(oa(u))continue;a.font=s;let d=u.title||u.key,f=a.measureText(d).width+Ki+qi,p;if(u.estimateCellWidth)p=i[l]>0?i[l]+Gi:0;else if(n)p=n[l];else{a.font=o;let e=0,n=t[l];for(let t=0;t<n.length;t+=1){let r=ra(n[t],u);if(r===``)continue;let i=a.measureText(r).width;i>e&&(e=i)}p=e>0?e+Ki+Gi:0}let m=Math.ceil(ta(Math.max(f,p),u.minWidth??Yi,u.maxWidth??1/0));r[u.key]!==m&&(c[u.key]=m)}}finally{l&&l.parentNode&&l.parentNode.removeChild(l)}return c}}}function ca(){return Qi()!==null}var la=()=>new Promise(e=>{if(typeof MessageChannel>`u`){setTimeout(e,0);return}let t=new MessageChannel;t.port1.onmessage=()=>{t.port1.close(),e()},t.port2.postMessage(null)}),ua=10,da=180,fa=()=>typeof performance<`u`?performance.now():Date.now(),pa=({rowModelRef:t,gridRootRef:n,columnWidthsRef:r,dispatch:i})=>{let[o,s]=(0,e.useState)(!1),c=(0,e.useRef)(0),l=(0,e.useRef)(null),u=()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)};return(0,e.useEffect)(()=>()=>{c.current+=1,u()},[]),{isAutosizing:o,runAutosize:(0,e.useCallback)(async e=>{if(e.length===0||!ca())return;let o=c.current+=1;u();let d=t.current,f=d.getRowCount(),p=n.current,m=r.current,h=sa(e);l.current=setTimeout(()=>{c.current===o&&s(!0)},da);try{let e=0;for(;e<f;){let n=fa();for(;e<f&&fa()-n<ua;){let t=d.getRow(e);t&&h.collect(t),e+=1}if(e<f&&(await la(),c.current!==o||t.current!==d))return}let n=h.finalize({gridRoot:p,currentWidths:m});Object.keys(n).length>0&&i(a.syncColumnWidths(n))}finally{c.current===o&&(u(),s(!1))}},[r,i,n,t])}},ma=()=>{let e=new Set,t=[];return{collect(n){let r=String(n??``);e.has(r)||(e.add(r),t.push({value:r,label:r||`(空白)`}))},finalize(){return t.sort((e,t)=>jn.compare(e.label,t.label))}}},ha=(e,t)=>{let n=ma();for(let r=0;r<e;r+=1)n.collect(t(r));return n.finalize()},ga=10,_a=()=>typeof performance<`u`?performance.now():Date.now(),va=[],ya=new Set,ba={status:`idle`,options:va,allValues:ya,progress:0},xa={status:`collecting`,options:va,allValues:ya,progress:0},Sa=e=>new Set(e.map(e=>e.value)),Ca={source:null,rowCount:0,result:ba},wa=({column:t,rowCount:n,getRawValueAt:r})=>{let i=t?.filterType??null,a=i===`select`||i===`set`||i===`numberSet`||i===`textSet`||i===`dateSet`,o=t?.filterOptions&&t.filterOptions.length>0?t.filterOptions:null,s=a&&o===null&&n>5e4,c=(0,e.useMemo)(()=>{if(!t||!a)return ba;if(o){let e=o;return{status:`ready`,options:e,allValues:Sa(e),progress:1}}if(!s){let e=ha(n,r);return{status:`ready`,options:e,allValues:Sa(e),progress:1}}return null},[t,a,o,s,n,r]),[l,u]=(0,e.useState)(Ca);(0,e.useEffect)(()=>{if(c!==null)return;let e=r,t=n,i=ma(),a=!1;return(async()=>{let n=0;for(;n<t;){let r=_a();for(;n<t&&_a()-r<ga;)i.collect(e(n)),n+=1;if(n<t){if(await la(),a)return;u({source:e,rowCount:t,result:{status:`collecting`,options:va,allValues:ya,progress:n/t}})}}if(a)return;let r=i.finalize();u({source:e,rowCount:t,result:{status:`ready`,options:r,allValues:Sa(r),progress:1}})})(),()=>{a=!0}},[c,n,r]);let d=l.source===r&&l.rowCount===n?l.result:xa;return c??d},Ta=10,Ea=()=>typeof performance<`u`?performance.now():Date.now(),Da=({rows:t,baseOrder:n,columns:r,globalText:i,enabled:a})=>{let o=(0,e.useDeferredValue)(i),s=o.trim().toLowerCase(),c=a&&s.length>0,l=c&&t.length>5e4,u=(0,e.useMemo)(()=>c?l?null:{order:gt(t,n,r,o),status:`ready`,progress:1}:{order:n,status:`idle`,progress:1},[c,l,t,n,r,o]),[d,f]=(0,e.useState)(null),[p,m]=(0,e.useState)(null);(0,e.useEffect)(()=>{if(!l)return;let e=t,i=n,a=r,o=s,c=i.length,u=new Int32Array(c),d=!1;return(async()=>{let t=0,n=0;for(;n<c;){let r=Ea();for(;n<c&&Ea()-r<Ta;){let r=i[n];ht(e[r],a,o)&&(u[t]=r,t+=1),n+=1}if(n<c){if(await la(),d)return;m({rows:e,baseOrder:i,columns:a,needle:o,progress:n/c})}}if(d)return;let r=t===c?i:u.slice(0,t);f({rows:e,baseOrder:i,columns:a,needle:o,order:r,rowsLength:e.length})})(),()=>{d=!0}},[l,t,n,r,s]);let h;return h=u||(d!==null&&d.rows===t&&d.baseOrder===n&&d.columns===r&&d.needle===s?{order:d.order,status:`ready`,progress:1}:{order:d!==null&&d.rowsLength===t.length?d.order:n,status:`filtering`,progress:p!==null&&p.rows===t&&p.baseOrder===n&&p.columns===r&&p.needle===s?p.progress:0}),h};function Oa(e){let t=e.blockSize,n=e.maxBlocks,r=new Map,i=e=>{let t=r.get(e);t!==void 0&&(r.delete(e),r.set(e,t))},a=()=>{for(;r.size>n;){let e=r.keys().next().value;if(e===void 0)break;r.delete(e)}};return{getRow:e=>{if(t<=0||e<0)return;let n=Math.floor(e/t),i=r.get(n);if(i!==void 0)return i[e-n*t]},hasBlock:e=>r.has(e),setBlock:(e,t)=>{r.has(e)&&r.delete(e),r.set(e,t),a()},updateRow:(e,n)=>{if(t<=0||e<0)return!1;let i=Math.floor(e/t),a=r.get(i);if(a===void 0)return!1;let o=e-i*t;if(o>=a.length)return!1;let s=a.slice();return s[o]=n,r.set(i,s),!0},touchBlocks:e=>{for(let t of e)i(t)},clear:()=>{r.clear()},loadedBlockIndexes:()=>Array.from(r.keys())}}function ka(e,t){return Math.floor(e/t)}function Aa(e,t,n,r){if(n<=0||r<=0)return[];let i=Math.max(0,Math.floor(e)),a=Math.min(r,Math.floor(t));if(a<=i)return[];let o=ka(i,n),s=ka(a-1,n),c=[];for(let e=o;e<=s;e+=1)c.push(e);return c}var ja=()=>{let e=new Map,t=1,n=t=>e.get(t)?.row,r=(n,r)=>{let i=t;return t+=1,e.set(n,{row:r,writeId:i}),i},i=(t,n)=>e.get(t)?.writeId===n;return{getRow:n,beginWrite:r,isLatestWrite:i,settleWrite:(t,n)=>{i(t,n)&&e.delete(t)},clear:()=>{e.clear()},pendingCount:()=>e.size}},Ma=(e,t,n)=>{let r=new Map;for(let i of e){let e=r.get(i.viewIndex);if(e===void 0){let a=t(i.viewIndex);if(a===void 0)continue;e={rowKey:n(a,i.viewIndex),rowIndex:i.viewIndex,row:a,previousRow:a,changes:[]},r.set(i.viewIndex,e)}e.changes.push({columnKey:i.column.key,previousValue:R(e.row,i.column),newValue:i.value}),e.row=Ae(e.row,i.column,i.value)}return Array.from(r.values())},Na=100,Pa=64,Fa=120;function Ia(t){let{dataSource:n,rowKeyGetter:r,query:i,queryKey:a,refreshToken:o,onLoadError:s,onWriteError:c}=t,l=n?.blockSize??Na,u=n?.maxCachedBlocks??Pa,d=t.debounceMs??Fa,[f]=(0,e.useState)(()=>Oa({blockSize:l,maxBlocks:u})),[p,m]=(0,e.useState)(n?.initialRowCount??0),[h,g]=(0,e.useState)(0),_=(0,e.useRef)(p),v=(0,e.useRef)(!1),y=(0,e.useRef)(new Map),b=(0,e.useRef)(new Set),[x,S]=(0,e.useState)(null),C=(0,e.useRef)(s);(0,e.useEffect)(()=>{C.current=s},[s]);let[w]=(0,e.useState)(()=>ja()),T=(0,e.useRef)(0),[E,D]=(0,e.useState)(null),O=(0,e.useRef)(c);(0,e.useEffect)(()=>{O.current=c},[c]);let k=(0,e.useCallback)(e=>w.getRow(e)??f.getRow(e),[f,w]),A=(0,e.useCallback)(()=>{T.current+=1,w.clear(),D(null)},[w]),j=(0,e.useCallback)(()=>{let e=b.current.size;S(t=>e===0?t===null?t:null:{failedBlockCount:e})},[]),M=(0,e.useRef)(null),ee=(0,e.useRef)({start:0,end:0}),N=(0,e.useCallback)(e=>{if(n==null||f.hasBlock(e)||y.current.has(e))return;let t=new AbortController;y.current.set(e,t);let r=e*l,a=r+l;n.getRows({startIndex:r,endIndex:a,query:i,signal:t.signal}).then(n=>{t.signal.aborted||y.current.get(e)===t&&(y.current.delete(e),f.setBlock(e,n.rows),b.current.delete(e)&&j(),n.totalRowCount!==_.current&&(_.current=n.totalRowCount,m(n.totalRowCount)),g(e=>e+1))}).catch(n=>{t.signal.aborted||y.current.get(e)===t&&(y.current.delete(e),b.current.add(e),j(),C.current?.(n,{startIndex:r,endIndex:a}))})},[f,l,n,i,j]),P=(0,e.useCallback)(()=>{let{start:e,end:t}=ee.current,n=Aa(e,t,l,_.current),r=new Set(n);for(let[e,t]of y.current)r.has(e)||(t.abort(),y.current.delete(e));for(let e of n)N(e)},[l,N]),F=(0,e.useCallback)(()=>{M.current!==null&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=null,P()},d)},[d,P]),I=(0,e.useCallback)((e,t)=>{n!=null&&(ee.current={start:e,end:t},f.touchBlocks(Aa(e,t,l,_.current)),F())},[f,l,n,F]);(0,e.useEffect)(()=>{if(n==null)return;for(let[,e]of y.current)e.abort();y.current.clear(),M.current!==null&&(clearTimeout(M.current),M.current=null),f.clear(),b.current.clear(),j(),A();let e=!v.current;v.current=!0,g(e=>e+1),e?(n.initialRowCount??0)<=0&&N(0):N(0)},[a]);let te=(0,e.useCallback)(()=>{if(n==null)return;for(let[,e]of y.current)e.abort();y.current.clear(),M.current!==null&&(clearTimeout(M.current),M.current=null),f.clear(),b.current.clear(),j(),A(),g(e=>e+1);let{start:e,end:t}=ee.current;if(Aa(e,t,l,_.current).length===0){N(0);return}P()},[f,n,l,N,P,j,A]),ne=(0,e.useCallback)(()=>{if(n==null||b.current.size===0)return;let e=Array.from(b.current);b.current.clear(),j();for(let t of e)N(t)},[n,N,j]),re=(0,e.useCallback)(e=>{let t=n?.updateRows;if(t===void 0||e.length===0)return 0;let i=Ma(e,k,r);if(i.length===0)return 0;let a=T.current,o=i.map(e=>({viewIndex:e.rowIndex,row:e.row,writeId:w.beginWrite(e.rowIndex,e.row)}));return g(e=>e+1),t({updates:i}).then(e=>{if(T.current!==a)return;let t=e===void 0?void 0:e.rows;o.forEach((e,n)=>{f.updateRow(e.viewIndex,t?.[n]??e.row),w.settleWrite(e.viewIndex,e.writeId)}),g(e=>e+1)}).catch(e=>{if(T.current===a){for(let e of o)w.settleWrite(e.viewIndex,e.writeId);D({failedRowCount:i.length}),O.current?.(e,{updates:i}),g(e=>e+1)}}),i.length},[f,n,k,w,r]),ie=(0,e.useRef)(o);(0,e.useEffect)(()=>{if(n==null||o===void 0){ie.current=o;return}if(ie.current===void 0){ie.current=o;return}ie.current!==o&&(ie.current=o,te())},[o]),(0,e.useEffect)(()=>{let e=y.current,t=M,n=T;return()=>{for(let[,t]of e)t.abort();e.clear(),t.current!==null&&(clearTimeout(t.current),t.current=null),n.current+=1,w.clear()}},[w]);let ae=(0,e.useCallback)(e=>k(e)!==void 0,[k]);return{rowModel:(0,e.useMemo)(()=>({getRowCount:()=>_.current,getRow:e=>k(e),getSourceIndex:e=>e,getRowKey:e=>{let t=k(e);return t===void 0?e:r(t,e)}}),[k,r,h]),rowCount:p,isRowLoaded:ae,requestRange:I,refresh:te,loadError:x,retryFailedBlocks:ne,canUpdateRows:n?.updateRows!==void 0,applyCellEdits:re,writeError:E}}var La=e=>{let t={},n=e.globalText.trim();n.length>0&&(t.globalText=n);let r={},i=!1;for(let t of Object.keys(e.columnFilters)){let n=e.columnFilters[t];Ye(n)&&(r[t]=n,i=!0)}return i&&(t.columnFilters=r),e.sort.length>0&&(t.sort=e.sort),t},Ra=e=>{let t=e.columnFilters??{},n=Object.keys(t).sort().map(e=>[e,t[e]]),r=e.sort??[];return JSON.stringify({g:e.globalText??``,s:r.map(e=>[e.columnKey,e.direction]),c:n})};function za({state:e,disabled:t=!1}){return(0,n.jsx)(`span`,{"aria-hidden":`true`,className:`ssg-row-checkbox`,"data-state":e,"data-disabled":t?`true`:void 0})}var Ba=(0,e.memo)(za);function Va({checked:e,readOnly:t,onToggle:r}){return(0,n.jsx)(`span`,{role:`checkbox`,"aria-checked":e,"aria-disabled":t||void 0,className:`ssg-cell-checkbox`,onClick:()=>{t||r()},children:(0,n.jsx)(Ba,{state:e?`checked`:`unchecked`,disabled:t})})}var Ha=(e,t)=>{let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)):e},Ua=(e,t)=>{if(!t.trim())return{kind:`close`};let n=Ha(e,t);return n.length===0?{kind:`none`}:{kind:`replace`,values:n.map(e=>e.value)}},Wa=(e,t)=>e===null?!0:e.mode===`include`?e.values.has(t):!e.values.has(t),Ga=28;function Ka({options:r,setSelection:i,searchInputRef:a,onValueToggle:o,onSelectAllChange:s,onReplaceSelection:c,onRequestClose:l,isServerSide:u,selectAllUsesExplicitScope:d=!1}){let[f,p]=(0,e.useState)(``),m=(0,e.useDeferredValue)(f),h=(0,e.useMemo)(()=>Ha(r,m),[r,m]),g=m.trim().length>0,_=(0,e.useRef)(null),v=(0,t.useVirtualizer)({count:h.length,getScrollElement:()=>_.current,estimateSize:()=>Ga,overscan:10}),y=(0,e.useMemo)(()=>{if(i===null)return h.length;let e=0;for(let t of h)Wa(i,t.value)&&(e+=1);return e},[i,h]),b=h.length>0&&y===h.length,x=y>0&&!b,S=(0,e.useMemo)(()=>new Set(r.map(e=>e.value)),[r]),C=(0,e.useMemo)(()=>{if(i===null)return r.length;let e=0;for(let t of i.values)S.has(t)&&(e+=1);return i.mode===`include`?e:r.length-e},[i,S,r.length]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:a,type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),l()),e.key===`Enter`){if(e.nativeEvent.isComposing)return;e.preventDefault();let t=Ua(r,f);if(t.kind===`none`)return;t.kind===`replace`&&c(t.values),l()}},placeholder:`検索(Enter で確定)`,className:`ssg-filter-input`}),(0,n.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:b,ref:e=>{e&&(e.indeterminate=x)},onChange:()=>{s(g||d?h.map(e=>e.value):`all`,!b)}}),(0,n.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:g?`(検索結果をすべて選択)`:`(すべて選択)`})]}),(0,n.jsx)(`div`,{ref:_,className:`ssg-filter-list`,children:h.length===0?(0,n.jsx)(`div`,{className:`ssg-filter-empty`,children:r.length===0?u?`候補が未指定です(serverSide では列に filterOptions などの候補供給が必要)`:`候補がありません`:`一致する候補がありません`}):(0,n.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:v.getTotalSize()},children:v.getVirtualItems().map(e=>{let t=h[e.index];if(!t)return null;let r=Wa(i,t.value);return(0,n.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>o(t.value)}),(0,n.jsx)(`span`,{className:`ssg-filter-option-label`,children:t.label})]},t.value)})})}),(0,n.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`選択中: `,C,` / `,r.length,` 件`,g?`(表示中 ${h.length} 件)`:``]})]})}function qa({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:i}){let a=yt(e.operator);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value}),onKeyDown:i,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:z.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a>0?(0,n.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[(0,n.jsx)(`input`,{ref:t,type:`text`,inputMode:`decimal`,value:e.value1,onChange:t=>r({...e,value1:t.target.value}),onKeyDown:i,placeholder:a===2?`下限`:`値`,className:`ssg-filter-input`,"aria-label":a===2?`下限`:`条件の値`}),a===2&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:`〜`}),(0,n.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:e.value2,onChange:t=>r({...e,value2:t.target.value}),onKeyDown:i,placeholder:`上限`,className:`ssg-filter-input`,"aria-label":`上限`})]})]}):(0,n.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`})]})}function Ja({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:i}){let a=At(e.operator);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value}),onKeyDown:i,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:B.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a>0?(0,n.jsx)(`div`,{className:`ssg-filter-cond-values`,children:(0,n.jsx)(`input`,{ref:t,type:`text`,value:e.value,onChange:t=>r({...e,value:t.target.value}),onKeyDown:i,placeholder:`値`,className:`ssg-filter-input`,"aria-label":`条件の値`})}):(0,n.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`})]})}function Ya({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:a}){let o=e.preset===null?Rt(e.operator):0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:It.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))}),o>0?(0,n.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[(0,n.jsx)(`input`,{ref:t,type:`date`,value:e.value1,onChange:t=>r({...e,value1:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-input`,"aria-label":o===2?`開始日`:`条件の日付`}),o===2&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:`〜`}),(0,n.jsx)(`input`,{type:`date`,value:e.value2,onChange:t=>r({...e,value2:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-input`,"aria-label":`終了日`})]})]}):e.preset===null?(0,n.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`}):null,(0,n.jsx)(`div`,{className:`ssg-filter-presets`,children:Lt.map(t=>(0,n.jsx)(`button`,{type:`button`,onPointerDown:n=>{n.preventDefault(),n.stopPropagation(),r({...e,preset:e.preset===t.value?null:t.value})},onKeyDown:e=>{e.stopPropagation()},className:i(`ssg-filter-preset-chip`,e.preset===t.value&&`ssg-filter-preset-chip--active`),children:t.label},t.value))})]})}function Xa({options:r,setSelection:i,searchInputRef:a,onValueToggle:o,onSelectAllChange:s,onReplaceSelection:c,onRequestClose:l,isServerSide:u}){let[d,f]=(0,e.useState)(``),p=(0,e.useDeferredValue)(d),[m,h]=(0,e.useState)(()=>new Set),g=p.trim().length>0,_=(0,e.useMemo)(()=>Ha(r,p),[r,p]),v=(0,e.useMemo)(()=>oi(r,m),[r,m]),y=(0,e.useRef)(null),b=g?_.length:v.length,x=(0,t.useVirtualizer)({count:b,getScrollElement:()=>y.current,estimateSize:()=>Ga,overscan:10}),S=(0,e.useMemo)(()=>(g?_:r).map(e=>e.value),[g,_,r]),C=(0,e.useMemo)(()=>{let e=0;for(let t of S)Wa(i,t)&&(e+=1);return e},[S,i]),w=S.length>0&&C===S.length,T=C>0&&!w,E=(0,e.useMemo)(()=>new Set(r.map(e=>e.value)),[r]),D=(0,e.useMemo)(()=>{if(i===null)return r.length;let e=0;for(let t of i.values)E.has(t)&&(e+=1);return i.mode===`include`?e:r.length-e},[i,E,r.length]),O=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},k=e=>{let t=0;for(let n of e)Wa(i,n)&&(t+=1);return t},A=e=>{let t=k(e.leafKeys),r=e.leafKeys.length>0&&t===e.leafKeys.length,i=t>0&&!r;return(0,n.jsxs)(n.Fragment,{children:[e.type===`group`?(0,n.jsx)(`button`,{type:`button`,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),O(e.key)},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-tree-toggle`,"aria-label":e.expanded?`折りたたむ`:`展開する`,children:e.expanded?`▾`:`▸`}):(0,n.jsx)(`span`,{className:`ssg-filter-tree-toggle ssg-filter-tree-toggle--placeholder`}),(0,n.jsx)(`input`,{type:`checkbox`,checked:r,ref:e=>{e&&(e.indeterminate=i)},onChange:()=>{if(e.type===`leaf`){o(e.key);return}s(e.leafKeys,!r)}}),(0,n.jsx)(`span`,{className:`ssg-filter-option-label`,children:e.label})]})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:a,type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),l()),e.key===`Enter`){if(e.nativeEvent.isComposing)return;e.preventDefault();let t=Ua(r,d);if(t.kind===`none`)return;t.kind===`replace`&&c(t.values),l()}},placeholder:`検索(Enter で確定)`,className:`ssg-filter-input`}),(0,n.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:w,ref:e=>{e&&(e.indeterminate=T)},onChange:()=>s(S,!w)}),(0,n.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:g?`(検索結果をすべて選択)`:`(すべて選択)`})]}),(0,n.jsx)(`div`,{ref:y,className:`ssg-filter-list`,children:b===0?(0,n.jsx)(`div`,{className:`ssg-filter-empty`,children:r.length===0?u?`候補が未指定です(serverSide では列に filterOptions などの候補供給が必要)`:`候補がありません`:`一致する候補がありません`}):(0,n.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:x.getTotalSize()},children:x.getVirtualItems().map(e=>{if(g){let t=_[e.index];return t?(0,n.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:Wa(i,t.value),onChange:()=>o(t.value)}),(0,n.jsx)(`span`,{className:`ssg-filter-option-label`,children:t.label})]},t.value):null}let t=v[e.index];return t?(0,n.jsx)(`div`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size,paddingLeft:8+t.depth*16},children:A(t)},t.key):null})})}),(0,n.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`選択中: `,D,` / `,r.length,` 件`,g?`(表示中 ${_.length} 件)`:``]})]})}function Za({conditionEditor:e,conditionActive:t,onConditionClear:r,options:i,setSelection:a,onSelectionClear:o,summaryText:s,children:c}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-sec-label`,children:`条件`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),r()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-sec-clear`,disabled:!t,children:`クリア`})]}),e,(0,n.jsx)(`div`,{className:`ssg-filter-sep`}),(0,n.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-sec-label`,children:`値`}),(0,n.jsx)(`span`,{className:`ssg-filter-sec-meta`,children:t?`一致 ${i.length} 件`:`全 ${i.length} 件`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),o()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-sec-clear`,disabled:a===null,children:`クリア`})]}),c,(0,n.jsxs)(`div`,{className:`ssg-filter-summary`,children:[`🔽 `,s]})]})}function Qa({isOpen:t,themeClassName:a,title:o,filterType:s,draftValue:c,numberConditionDraft:l,onNumberConditionDraftChange:u,textConditionDraft:d,onTextConditionDraftChange:f,dateConditionDraft:p,onDateConditionDraftChange:m,onComboConditionClear:h,onComboSelectionClear:g,comboSummaryText:_,currentValueText:v,layout:y,selectOptions:b,optionsStatus:x,optionsProgress:S,setSelection:C,popoverRef:w,textInputRef:T,selectRef:E,onRequestClose:D,onDraftChange:O,onApply:k,onClear:A,onSetValueToggle:j,onSetSelectAllChange:M,onSetClear:ee,onSetReplaceSelection:N,isServerSide:P=!1}){let F=(0,e.useRef)(null),[I]=(0,e.useState)(()=>new Date);if(typeof document>`u`||!t||!y)return null;let te={top:y.top,left:y.left,width:y.width},ne=e=>{e.stopPropagation()},re=e=>{e.stopPropagation()},ie=s===`set`,ae=s===`numberSet`,oe=s===`textSet`,se=s===`dateSet`,ce=ae||oe||se,le=ie||ce,ue=l??vt,de=d??kt,fe=p??Ft,pe=ae?St(ue):null,me=oe?jt(de):null,he=se?Bt(fe):null,ge=pe!==null||me!==null||he!==null,_e=ae?Tt(b,pe):oe?Pt(b,me):se?Ut(b,he,I):b,L=e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),k();return}e.key===`Escape`&&(e.preventDefault(),D())};return(0,r.createPortal)((0,n.jsxs)(`div`,{ref:w,onPointerDown:re,onKeyDown:ne,onPasteCapture:e=>{e.stopPropagation()},className:i(`ssg-filter-popover`,a),style:te,children:[(0,n.jsxs)(`div`,{className:`ssg-filter-title`,children:[`列フィルター: `,o]}),(le||s===`select`)&&x===`collecting`?(0,n.jsxs)(`div`,{className:`ssg-filter-collecting`,children:[`候補を収集中… `,Math.round(S*100),`%`]}):ce?(0,n.jsx)(Za,{conditionEditor:ae?(0,n.jsx)(qa,{draft:ue,valueInputRef:T,onDraftChange:u,onKeyDown:L}):oe?(0,n.jsx)(Ja,{draft:de,valueInputRef:T,onDraftChange:f,onKeyDown:L}):(0,n.jsx)(Ya,{draft:fe,valueInputRef:T,onDraftChange:m,onKeyDown:L}),conditionActive:ge,onConditionClear:h,options:_e,setSelection:C,onSelectionClear:g,summaryText:_,children:se?(0,n.jsx)(Xa,{options:_e,setSelection:C,searchInputRef:F,onValueToggle:j,onSelectAllChange:M,onReplaceSelection:N,onRequestClose:D,isServerSide:P}):(0,n.jsx)(Ka,{options:_e,setSelection:C,searchInputRef:F,onValueToggle:j,onSelectAllChange:M,onReplaceSelection:N,onRequestClose:D,isServerSide:P,selectAllUsesExplicitScope:!0})}):ie?(0,n.jsx)(Ka,{options:b,setSelection:C,searchInputRef:T,onValueToggle:j,onSelectAllChange:M,onReplaceSelection:N,onRequestClose:D,isServerSide:P}):s===`number`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`ssg-filter-hint`,children:`フィルター種別: number`}),(0,n.jsx)(qa,{draft:ue,valueInputRef:T,onDraftChange:u,onKeyDown:L})]}):s===`select`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`ssg-filter-hint`,children:`フィルター種別: select`}),(0,n.jsxs)(`select`,{ref:E,value:c,onChange:e=>O(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),k();return}e.key===`Escape`&&(e.preventDefault(),D())},className:`ssg-filter-select`,children:[(0,n.jsx)(`option`,{value:``,children:`(すべて)`}),b.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},`${o}-${e.value}`))]}),(0,n.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`候補数: `,b.length]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{className:`ssg-filter-hint`,children:[`フィルター種別: `,s]}),(0,n.jsx)(`input`,{ref:T,type:`text`,value:c,onChange:e=>O(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),k();return}e.key===`Escape`&&(e.preventDefault(),D())},placeholder:`部分一致で絞り込み`,className:`ssg-filter-input`}),(0,n.jsx)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:`部分一致検索です`})]}),!le&&(0,n.jsxs)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:[`現在値: `,v]}),(0,n.jsx)(`div`,{className:`ssg-filter-footer`,children:le?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),ee()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-secondary`,children:`クリア`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),D()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-primary`,children:`閉じる`})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),A()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-secondary`,children:`クリア`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),k()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-primary`,children:`適用`})]})})]}),document.body)}function $a({context:e,showCounts:t=!0}){let{derivedSummary:r}=e;return(0,n.jsx)(`div`,{className:`ssg-bar--bottom`,children:(0,n.jsxs)(`div`,{className:`ssg-bar-container`,children:[t?(0,n.jsxs)(`div`,{className:`ssg-bar-group`,children:[(0,n.jsx)(`span`,{className:`ssg-bar-chip`,children:r.rowSummaryText}),(0,n.jsx)(`span`,{className:`ssg-bar-chip`,children:r.columnSummaryText})]}):null,(0,n.jsxs)(`div`,{className:`ssg-bar-group`,children:[(0,n.jsxs)(`span`,{className:`ssg-bar-chip`,children:[`Active: `,r.activeCellLabel]}),(0,n.jsxs)(`span`,{className:`ssg-bar-chip`,children:[`Selection: `,r.selectionLabel]}),(0,n.jsx)(`span`,{className:`ssg-bar-chip`,children:r.selectionStatsText}),(0,n.jsxs)(`span`,{className:`ssg-bar-chip`,children:[`Cols: `,r.selectionStats.selectedColumnCount]})]})]})})}var eo=(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,n.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,n.jsx)(`line`,{x1:`10.6`,y1:`10.6`,x2:`14.5`,y2:`14.5`})]}),to=(0,n.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,n.jsx)(`line`,{x1:`4`,y1:`4`,x2:`12`,y2:`12`}),(0,n.jsx)(`line`,{x1:`12`,y1:`4`,x2:`4`,y2:`12`})]});function no({context:e,showSummary:t=!0,showFilter:r=!0,showCounts:i=!0,globalFilterPlaceholder:a=`グローバルフィルター`,globalFilterIcon:o,onFilterSummaryClick:s}){let{derivedSummary:c}=e,l=o===void 0?eo:o,u=e.globalFilterText.trim().length>0;return(0,n.jsx)(`div`,{className:`ssg-bar--top`,children:(0,n.jsxs)(`div`,{className:`ssg-bar-container`,children:[t?(0,n.jsxs)(`div`,{className:`ssg-bar-group ssg-bar-leading`,children:[(0,n.jsx)(`span`,{className:`ssg-bar-title`,children:`Toolbar`}),i?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.rowSummaryText}),(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.columnSummaryText})]}):null,s?(0,n.jsx)(`button`,{type:`button`,className:`ssg-bar-chip ssg-bar-chip--emphasis ssg-bar-chip--action`,onPointerDown:e=>{e.stopPropagation()},onClick:s,"data-ssg-tooltip":`フィルター管理パネルを開閉`,"aria-label":`フィルター管理パネルを開閉`,children:c.filterSummaryText}):(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.filterSummaryText}),(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.sortSummaryText})]}):null,r?(0,n.jsxs)(`div`,{className:`ssg-bar-input-group`,children:[l?(0,n.jsx)(`span`,{className:`ssg-bar-input-icon`,"aria-hidden":`true`,children:l}):null,(0,n.jsx)(`input`,{type:`text`,value:e.globalFilterText,onChange:t=>e.setGlobalFilterText(t.target.value),placeholder:a,className:`ssg-bar-input`}),u?(0,n.jsx)(`button`,{type:`button`,onClick:()=>e.setGlobalFilterText(``),className:`ssg-bar-input-clear`,"aria-label":`フィルターをクリア`,"data-ssg-tooltip":`クリア`,children:to}):null]}):null]})})}var ro=e=>e.enabled&&!e.isAutoHeightCell&&!e.hasRenderCell;function io({pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:a,rowKey:o,sourceRowIndex:s,row:c,top:l,renderEntries:u,rowHeight:d,autoHeight:f,showCellOverflowTooltip:p,showValidationMarks:m,autoHeightMinHeight:h,rowHeaderCellStyle:g,isRowHovered:_,isWholeGridSelected:v,isRowSelected:y,showRowCheckbox:b,isRowChecked:x,activeColInRow:S,editingColInRow:C,selectedColStart:w,selectedColEnd:T,readOnly:E,canEditCell:D,onRowHeaderPointerDown:O,onRowHeaderPointerEnter:k,onRowHeaderPointerLeave:A,onCellPointerDown:j,onCellPointerEnter:M,onCellDoubleClick:ee,renderCellContent:N,rowClassName:P,bodyCellClassName:F,bodyRowClassName:I,rowHeaderCellClassName:te}){return(0,n.jsxs)(`div`,{"data-pane":e,"data-row-index":a,className:i(`ssg-body-row`,x&&`ssg-body-row--checked`,P,I),style:{height:d,transform:`translateY(${l}px)`},children:[t&&(0,n.jsx)(`div`,{role:b?`checkbox`:void 0,"aria-checked":b?x:void 0,onPointerDown:e=>O(a,e),onPointerEnter:e=>k(a,e),onPointerLeave:()=>A(a),className:i(`ssg-header-cell`,`ssg-row-header-cell`,b&&`ssg-row-header-cell--checkbox`,(v||y)&&`ssg-header-cell--selected`,_&&`ssg-header-cell--hovered`,P,te),style:{...g,height:d},children:b?(0,n.jsx)(Ba,{state:x?`checked`:`unchecked`}):a+1}),u.map(e=>{if(!e)return null;let t=e.logicalIndex,l=e.column,u=r+e.paneLocalStart,g=e.paneLocalSize,v=t===S,b=t===C,x=y||w>=0&&t>=w&&t<=T,O=!ke({readOnly:E,canEditCell:D},a,t,c,l),k=f&&l.autoHeight===!0,A,I=l.cellClassName;I&&(A=typeof I==`function`?I({row:c,rowIndex:a,sourceRowIndex:s,rowKey:o,colIndex:t,value:R(c,l),column:l,isActive:v,isSelected:x,isEditing:b,readOnly:O}):I);let te=m&&l.validate?$t(l,c,R(c,l)):null,ne=i(`ssg-body-cell`,l.align===`center`&&`ssg-body-cell--align-center`,l.align===`right`&&`ssg-body-cell--align-right`,k&&`ssg-body-cell--autoheight`,O&&!x&&`ssg-body-cell--readonly`,te!==null&&`ssg-body-cell--invalid`,_&&`ssg-body-cell--row-hovered`,P,A,F),re={};l.wordBreak!==void 0&&(re.wordBreak=l.wordBreak),l.lineBreak!==void 0&&(re.lineBreak=l.lineBreak);let ie=ro({enabled:p,isAutoHeightCell:k,hasRenderCell:l.renderCell!==void 0});return(0,n.jsx)(`div`,{"data-ssg-col-key":l.key,"data-autoheight-cell":k?``:void 0,"data-ssg-tooltip":te??void 0,"data-ssg-tooltip-overflow":ie?``:void 0,className:ne,onPointerDown:e=>j({row:a,col:t},e),onPointerEnter:e=>M({row:a,col:t},e),onDoubleClick:()=>ee({row:a,col:t}),style:{left:u,width:g,minWidth:g,...k?{minHeight:h}:{height:d},...re,zIndex:v?3:1},children:N(c,a,l,t,{isActive:v,isSelected:x,isEditing:b,readOnly:O})},`${String(o)}-${l.key}`)})]})}var ao=(0,e.memo)(io),oo=[`62%`,`46%`,`78%`,`54%`];function so({pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:a,top:o,rowHeight:s,renderEntries:c,rowHeaderCellStyle:l,isRowHovered:u,showRowCheckbox:d,onRowHeaderPointerDown:f,onRowHeaderPointerEnter:p,onRowHeaderPointerLeave:m,onCellPointerDown:h,onCellPointerEnter:g,bodyCellClassName:_,bodyRowClassName:v,rowHeaderCellClassName:y}){return(0,n.jsxs)(`div`,{"data-pane":e,"data-row-index":a,"data-skeleton-row":``,className:i(`ssg-body-row`,v),style:{height:s,transform:`translateY(${o}px)`},children:[t&&(0,n.jsx)(`div`,{onPointerDown:e=>f(a,e),onPointerEnter:e=>p(a,e),onPointerLeave:()=>m(a),className:i(`ssg-header-cell`,`ssg-row-header-cell`,`ssg-skeleton-rowheader`,d&&`ssg-row-header-cell--checkbox`,u&&`ssg-header-cell--hovered`,y),style:{...l,height:s},children:d?(0,n.jsx)(Ba,{state:`unchecked`,disabled:!0}):a+1}),c.map(t=>{if(!t)return null;let o=t.logicalIndex,c=r+t.paneLocalStart,l=t.paneLocalSize,d=oo[o%oo.length];return(0,n.jsx)(`div`,{className:i(`ssg-body-cell`,u&&`ssg-body-cell--row-hovered`,_),onPointerDown:e=>h({row:a,col:o},e),onPointerEnter:e=>g({row:a,col:o},e),style:{left:c,width:l,minWidth:l,height:s,zIndex:1},children:(0,n.jsx)(`div`,{"aria-hidden":`true`,className:`ssg-skeleton-bar`,style:{width:d}})},`skeleton-${e}-${o}`)})]})}var co=(0,e.memo)(so),lo=(e,t)=>t==null?``:e.valueFormatter?e.valueFormatter({value:t,row:void 0,column:e}):String(t),uo=16;function fo({pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:a,top:o,rowHeight:s,renderEntries:c,rowHeaderCellStyle:l,isRowHovered:u,showRowCheckbox:d,groupRow:f,isCollapsed:p,onGroupToggle:m,onRowHeaderPointerEnter:h,onRowHeaderPointerLeave:g,bodyCellClassName:_,bodyRowClassName:v,rowHeaderCellClassName:y}){return(0,n.jsxs)(`div`,{"data-pane":e,"data-row-index":a,"data-ssg-group-row":``,className:i(`ssg-body-row`,v),style:{height:s,transform:`translateY(${o}px)`},onDoubleClick:()=>m(f.groupKey),children:[t&&(0,n.jsx)(`div`,{onPointerEnter:e=>h(a,e),onPointerLeave:()=>g(a),className:i(`ssg-header-cell`,`ssg-row-header-cell`,d&&`ssg-row-header-cell--checkbox`,u&&`ssg-header-cell--hovered`,y),style:{...l,height:s},children:d?null:a+1}),c.map(t=>{if(!t)return null;let a=t.column,o=r+t.paneLocalStart,c=t.paneLocalSize,l=a.key===Kn,d=!l&&Object.prototype.hasOwnProperty.call(f.aggregates,a.key)?lo(a,f.aggregates[a.key]):null;return(0,n.jsx)(`div`,{"data-ssg-col-key":a.key,className:i(`ssg-body-cell`,`ssg-group-cell`,a.align===`center`&&`ssg-body-cell--align-center`,a.align===`right`&&`ssg-body-cell--align-right`,u&&`ssg-body-cell--row-hovered`,_),style:{left:o,width:c,minWidth:c,height:s,zIndex:1},children:l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{"aria-hidden":`true`,className:`ssg-group-indent`,style:{width:f.level*uo}}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-group-toggle`,"aria-expanded":!p,"aria-label":`${f.label} を${p?`展開`:`折りたたみ`}`,onClick:()=>m(f.groupKey),onDoubleClick:e=>e.stopPropagation(),children:p?`▸`:`▾`}),(0,n.jsx)(`span`,{className:`ssg-group-label`,children:f.label}),(0,n.jsxs)(`span`,{className:`ssg-group-count`,children:[`(`,f.leafCount,`件)`]})]}):d},`group-${e}-${a.key}`)})]})}var po=(0,e.memo)(fo);function mo({pane:e,ownsRowHeader:t,leadingWidth:r,rowModel:i,virtualRows:a,virtualRowIndexes:o,renderEntries:s,rowHeight:c,autoHeight:l=!1,showCellOverflowTooltip:u=!1,showValidationMarks:d=!0,isServerSide:f=!1,collapsedGroupKeys:p,onGroupToggle:m,rowHeaderCellStyle:h,hoveredRowIndex:g,isWholeGridSelected:_,enableRowSelection:v,rowSelectionState:y,activeCell:b,editingCell:x,selectionSnapshot:S,readOnly:C,canEditCell:w,onRowHeaderPointerDown:T,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,onCellPointerDown:k,onCellPointerEnter:A,onCellDoubleClick:j,renderCellContent:M,getRowClassName:ee,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F}){return(0,n.jsx)(n.Fragment,{children:a.map(a=>{let I=a.index;if(!o.has(I))return null;let te=a.size??c,ne=i.getGroupRow?.(I);if(ne&&m)return(0,n.jsx)(po,{pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:I,top:a.start,rowHeight:te,renderEntries:s,rowHeaderCellStyle:h,isRowHovered:g===I,showRowCheckbox:v,groupRow:ne,isCollapsed:p?.has(ne.groupKey)===!0,onGroupToggle:m,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F},String(qn(ne)));let re=i.getRow(I);if(!re){if(!f)return null;let o=i.getRowKey(I)??I;return(0,n.jsx)(co,{pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:I,top:a.start,rowHeight:te,renderEntries:s,rowHeaderCellStyle:h,isRowHovered:g===I,showRowCheckbox:v,onRowHeaderPointerDown:T,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,onCellPointerDown:k,onCellPointerEnter:A,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F},String(o))}let ie=i.getRowKey(I)??I,ae=i.getSourceIndex(I)??I,oe=v?O(y,ie):!1,se=S.kind===`row`&&I>=S.startRow&&I<=S.endRow,ce=S.kind===`cell`&&I>=S.startRow&&I<=S.endRow,le=S.kind===`col`||ce?S.startCol:-1,ue=S.kind===`col`||ce?S.endCol:-1,de=b&&b.row===I?b.col:-1,fe=x&&x.row===I?x.col:-1,pe=ee?.(re,I);return(0,n.jsx)(ao,{pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:I,rowKey:ie,sourceRowIndex:ae,row:re,top:a.start,renderEntries:s,rowHeight:te,autoHeight:l,showCellOverflowTooltip:u,showValidationMarks:d,autoHeightMinHeight:c,rowHeaderCellStyle:h,isRowHovered:g===I,isWholeGridSelected:_,isRowSelected:se,showRowCheckbox:v,isRowChecked:oe,activeColInRow:de,editingColInRow:fe,selectedColStart:le,selectedColEnd:ue,readOnly:C,canEditCell:w,onRowHeaderPointerDown:T,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,onCellPointerDown:k,onCellPointerEnter:A,onCellDoubleClick:j,renderCellContent:M,rowClassName:pe,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F},String(ie))})})}function ho({isActive:e,title:t,className:r,onPointerDown:a,children:o}){return(0,n.jsx)(`button`,{type:`button`,"data-ssg-tooltip":t,"aria-label":t,onPointerDown:a,className:i(`ssg-icon-btn`,e&&`ssg-icon-btn--active`,r),children:o})}function go({pane:e,ownsRowHeader:t,leadingWidth:r,headerHeight:a,rowHeaderCellStyle:o,headerRowClassName:s,headerCellClassName:c,rowHeaderCellClassName:l,isCornerHovered:u,isWholeGridSelected:d,showSelectAllCheckbox:f,selectAllState:p,filteredRowsLength:m,visibleColumnsLength:h,renderEntries:g,hoveredColumnIndex:_,selectionSnapshot:v,columnFilterValues:y,sortState:b,iconButtonClassName:x,onCornerPointerDown:S,onCornerPointerEnter:C,onCornerPointerLeave:w,onColumnHeaderPointerDown:T,onColumnHeaderPointerEnter:E,onColumnHeaderPointerLeave:D,onColumnResizePointerDown:O,enableColumnResize:k,enableColumnMenu:A,openedMenuColumnKey:j,onColumnMenuButtonPointerDown:M,onColumnHeaderContextMenu:ee,onColumnDragHandlePointerDown:N}){return(0,n.jsxs)(`div`,{"data-pane":e,className:i(`ssg-header-row`,s),style:{height:a},children:[t&&(0,n.jsx)(`div`,{role:f?`checkbox`:void 0,"aria-checked":f?p===`all`?!0:p===`some`?`mixed`:!1:void 0,onPointerDown:S,onPointerEnter:C,onPointerLeave:w,className:i(`ssg-header-cell`,`ssg-corner-cell`,f&&`ssg-corner-cell--checkbox`,d&&`ssg-header-cell--selected`,u&&`ssg-header-cell--hovered`,l),style:{...o,height:a,cursor:m>0&&h>0?`pointer`:`default`},children:f?(0,n.jsx)(Ba,{state:p===`all`?`checked`:p===`some`?`indeterminate`:`unchecked`}):`#`}),g.map(e=>{if(!e)return null;let t=e.logicalIndex,o=e.column,s=r+e.paneLocalStart,l=e.paneLocalSize,u=Ye(y[o.key]),f=v.kind===`col`&&t>=v.startCol&&t<=v.endCol,p=b.findIndex(e=>e.columnKey===o.key),m=p===-1?null:b[p],h=j===o.key,g=o.key===Kn,S=A&&!g;return(0,n.jsxs)(`div`,{"data-ssg-col-key":o.key,onPointerDown:e=>T(t,e),onPointerEnter:e=>E(t,e),onPointerLeave:()=>D(t),onContextMenu:e=>{if(g){e.preventDefault();return}ee(o,e)},className:i(`ssg-header-cell`,(d||f)&&`ssg-header-cell--selected`,_===t&&`ssg-header-cell--hovered`,c),style:{left:s,width:l,minWidth:l,height:a},children:[(0,n.jsx)(`div`,{className:i(`ssg-header-label`,u&&`ssg-header-label--filtered`),"data-ssg-tooltip":o.renderHeader?void 0:o.title||o.key,children:o.renderHeader?o.renderHeader({colIndex:t,width:l,column:o,filterValue:y[o.key],isFiltered:u}):o.title||o.key}),(0,n.jsxs)(`div`,{className:`ssg-header-status`,children:[m&&(0,n.jsxs)(`span`,{"aria-hidden":`true`,"data-ssg-tooltip":(m.direction===`asc`?`昇順で並び替え中`:`降順で並び替え中`)+(b.length>1?` (優先度 ${p+1})`:``),className:`ssg-header-sort`,children:[m.direction===`asc`?`↑`:`↓`,b.length>1&&(0,n.jsx)(`span`,{className:`ssg-header-sort-priority`,children:p+1})]}),u&&(0,n.jsx)(`span`,{"aria-hidden":`true`,"data-ssg-tooltip":`フィルター適用中`,className:`ssg-header-filtered-mark`,children:(0,n.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,n.jsx)(`path`,{d:`M2 4 L14 4 L9.2 9.2 L9.2 13 L6.8 13 L6.8 9.2 Z`})})})]}),(0,n.jsxs)(`div`,{className:`ssg-header-actions`,children:[N&&!g&&(0,n.jsx)(`span`,{onPointerDown:e=>N(o,e),"data-ssg-tooltip":`ドラッグで列を移動`,"aria-hidden":`true`,className:`ssg-header-grip`,children:(0,n.jsxs)(`svg`,{width:`8`,height:`14`,viewBox:`0 0 8 14`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:[(0,n.jsx)(`circle`,{cx:`2`,cy:`3`,r:`1`}),(0,n.jsx)(`circle`,{cx:`6`,cy:`3`,r:`1`}),(0,n.jsx)(`circle`,{cx:`2`,cy:`7`,r:`1`}),(0,n.jsx)(`circle`,{cx:`6`,cy:`7`,r:`1`}),(0,n.jsx)(`circle`,{cx:`2`,cy:`11`,r:`1`}),(0,n.jsx)(`circle`,{cx:`6`,cy:`11`,r:`1`})]})}),S&&(0,n.jsx)(ho,{title:`列メニュー`,isActive:h,className:x,onPointerDown:e=>M(o,e),children:`⋮`})]}),(o.resizable??k)&&(0,n.jsx)(`div`,{onPointerDown:e=>O(o,e),className:`ssg-header-resize`})]},o.key)})]})}var _o=(0,e.memo)(go),vo=200,yo=8,bo=6,xo=289,So=({visibleColumns:t,enableColumnMenu:n,gridRootRef:r})=>{let[i,a]=(0,e.useState)(null),[o,s]=(0,e.useState)(null),c=(0,e.useRef)(null),l=(0,e.useRef)(null),u=(0,e.useRef)(null),d=(0,e.useRef)(i);d.current=i;let f=i!==null,p=i?.columnKey??null,m=(0,e.useMemo)(()=>p?t.find(e=>e.key===p)??null:null,[p,t]),h=(0,e.useCallback)(()=>{if(!p){s(null);return}let e,t,n,r=l.current,i=u.current;if(r){if(!r.isConnected){s(null),a(null),l.current=null;return}let i=r.getBoundingClientRect();t=i.right-vo,e=i.bottom+bo,n=i.top-xo-bo}else if(i)t=i.x,e=i.y,n=i.y-xo;else{s(null);return}t=Math.max(yo,t),t=Math.min(t,window.innerWidth-vo-yo),e+xo>window.innerHeight-yo&&(e=n),e=Math.max(yo,e),s(n=>n&&n.top===e&&n.left===t&&n.width===vo?n:{top:e,left:t,width:vo})},[p]),g=(0,e.useCallback)(()=>{a(null),s(null),l.current=null,u.current=null,requestAnimationFrame(()=>{r.current?.focus()})},[r]),_=(0,e.useCallback)((e,t)=>{if(t.preventDefault(),t.stopPropagation(),!n||t.button!==0)return;let i=t.currentTarget;if(d.current?.columnKey===e.key&&l.current===i){g();return}document.activeElement instanceof HTMLElement&&document.activeElement.blur(),r.current?.blur(),l.current=i,u.current=null,a({columnKey:e.key})},[g,n,r]),v=(0,e.useCallback)((e,t)=>{n&&(t.preventDefault(),t.stopPropagation(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),r.current?.blur(),l.current=null,u.current={x:t.clientX,y:t.clientY},a({columnKey:e.key}),h())},[n,r,h]);return(0,e.useEffect)(()=>{if(!p)return;h();let e=()=>{h()},t=()=>{if(u.current){g();return}h()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0)}},[p,h,g]),(0,e.useEffect)(()=>{if(!f)return;let e=e=>{let t=e.target;t&&(c.current?.contains(t)||l.current?.contains(t)||g())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[g,f]),(0,e.useEffect)(()=>{if(!f)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),g())};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[g,f]),{columnMenuLayout:o,columnMenuRef:c,isColumnMenuOpen:f,openedMenuColumnKey:p,openedMenuColumn:m,openColumnMenuFromButton:_,openColumnMenuFromContextMenu:v,closeColumnMenu:g}},Co=[{value:void 0,label:`固定しない`},{value:`left`,label:`左に固定`},{value:`right`,label:`右に固定`}],wo=180,To=4,Eo=8,Do=`pin`;function Oo({isOpen:t,themeClassName:a,title:o,columnKey:s,canFilter:c,onOpenFilter:l,canSort:u,sortDirection:d,onSortChange:f,onOpenSortManager:p,canManageFilters:m,onOpenFilterManager:h,pinned:g,canChangePinned:_,layout:v,popoverRef:y,onPinnedChange:b,onAutosizeColumn:x,onAutosizeAllColumns:S,onOpenColumnChooser:C,canResetColumns:w,onResetColumns:T,onRequestClose:E}){let[D,O]=(0,e.useState)(null);if((0,e.useEffect)(()=>{O(null)},[s,t]),!t||!v)return null;let k=D===Do,A=v.left+v.width+To+wo>window.innerWidth-Eo,j={position:`fixed`,top:v.top,left:v.left,width:v.width,zIndex:1e3},M={position:`absolute`,top:-9,...A?{right:`calc(100% + ${To}px)`}:{left:`calc(100% + ${To}px)`},width:wo,zIndex:1};return(0,r.createPortal)((0,n.jsxs)(`div`,{ref:y,onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{e.stopPropagation()},onContextMenu:e=>{e.preventDefault()},className:i(`ssg-menu-panel`,a),style:j,children:[(0,n.jsx)(`div`,{className:`ssg-menu-title`,children:o}),c&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{l()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`フィルター…`})]}),(0,n.jsx)(`div`,{className:`ssg-menu-separator`})]}),u&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{f(`asc`)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:i(`ssg-menu-sort-icon`,d===`asc`&&`ssg-menu-sort-icon--active`),children:d===`asc`?`✓`:`↑`}),(0,n.jsx)(`span`,{className:i(`ssg-menu-label`,d===`asc`&&`ssg-menu-label--sorted`),children:`昇順で並び替え`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{f(`desc`)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:i(`ssg-menu-sort-icon`,d===`desc`&&`ssg-menu-sort-icon--active`),children:d===`desc`?`✓`:`↓`}),(0,n.jsx)(`span`,{className:i(`ssg-menu-label`,d===`desc`&&`ssg-menu-label--sorted`),children:`降順で並び替え`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{p()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`並び替えを管理…`})]})]}),m&&(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{h()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`フィルターを管理…`})]}),(u||m)&&(0,n.jsx)(`div`,{className:`ssg-menu-separator`}),(0,n.jsxs)(`div`,{className:`ssg-menu-submenu-anchor`,children:[(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(Do)},onClick:()=>{O(e=>e===Do?null:Do)},className:i(`ssg-menu-item`,k&&`ssg-menu-item--active`),children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`列の固定`}),(0,n.jsx)(`span`,{className:`ssg-menu-caret`,children:`›`})]}),k&&(0,n.jsxs)(`div`,{className:i(`ssg-menu-panel`,a),style:M,children:[Co.map(e=>{let t=g===e.value;return(0,n.jsxs)(`button`,{type:`button`,disabled:!_,onClick:()=>{_&&b(s,e.value)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:i(`ssg-menu-check`,!t&&`ssg-menu-check--hidden`),children:`✓`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:e.label})]},e.label)}),!_&&(0,n.jsx)(`div`,{className:`ssg-menu-note`,children:`onColumnsChange 未指定のため固定状態を変更できません`})]})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{x(s)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`この列の幅を自動調整`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{S()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`すべての列の幅を自動調整`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{C()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`列の表示`})]}),(0,n.jsxs)(`button`,{type:`button`,"aria-disabled":!w,tabIndex:w?0:-1,"data-ssg-tooltip":w?`すべての列の幅・固定・表示・並び順を初期状態に戻します`:`onColumnsChange 未指定のため列をリセットできません`,onPointerEnter:()=>{O(null)},onClick:()=>{w&&T()},className:i(`ssg-menu-item`,!w&&`ssg-menu-item--disabled`),children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`列のリセット`})]}),(0,n.jsx)(`div`,{className:`ssg-menu-footer`,children:(0,n.jsx)(`button`,{type:`button`,onClick:E,className:`ssg-menu-close-btn`,children:`閉じる`})})]}),document.body)}var ko=({top:e,left:t,panelWidth:n,viewportWidth:r,viewportHeight:i})=>{let a=Math.max(8,Math.min(t,r-n-8));return{top:Math.max(8,Math.min(e,i-40)),left:a}},Ao=360,jo=8,Mo=12,No=[`filter`,`columns`,`sort`],Po=({canUseFilterTab:t,canUseColumnsTab:n,canUseSortTab:r,gridRootRef:i,alliedRef:a,suppressEscape:o=!1,onSuppressedEscape:s})=>{let[c,l]=(0,e.useState)(null),[u,d]=(0,e.useState)(null),[f,p]=(0,e.useState)(0),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useMemo)(()=>{let e={filter:t,columns:n,sort:r};return No.filter(t=>e[t])},[t,n,r]),_=c===null?null:g.includes(c)?c:g[0]??null,v=_!==null,y=(0,e.useCallback)(()=>{let e=h.current;if(e){let t=ko({top:e.top,left:e.left,panelWidth:Ao,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});d(e=>e&&e.top===t.top&&e.left===t.left&&e.width===Ao?e:{top:t.top,left:t.left,width:Ao});return}let t=i.current;if(!t){d(null);return}let n=t.getBoundingClientRect(),r=n.right-Ao-Mo,a=n.top+Mo;r=Math.max(jo,r),r=Math.min(r,window.innerWidth-Ao-jo),a=Math.max(jo,a),d(e=>e&&e.top===a&&e.left===r&&e.width===Ao?e:{top:a,left:r,width:Ao})},[i]),b=(0,e.useCallback)(e=>{({filter:t,columns:n,sort:r})[e]&&(c!==null&&p(e=>e+1),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),i.current?.blur(),l(e))},[t,n,r,i,c]),x=(0,e.useCallback)(()=>{l(null),d(null),requestAnimationFrame(()=>{i.current?.focus()})},[i]),S=(0,e.useCallback)((e,t)=>{let n=ko({top:e,left:t,panelWidth:Ao,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});h.current=n,d({top:n.top,left:n.left,width:Ao})},[]);return(0,e.useEffect)(()=>{if(!v)return;y();let e=()=>{y()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[v,y]),(0,e.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;t&&(m.current?.contains(t)||a?.current?.contains(t)||x())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[a,x,v]),(0,e.useEffect)(()=>{if(!v)return;let e=e=>{if(e.key===`Escape`){if(o){s?.();return}e.preventDefault(),x()}};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[x,v,s,o]),{activeToolPanelTab:_,availableToolPanelTabs:g,toolPanelLayout:u,toolPanelFlashTick:f,toolPanelRef:m,openToolPanel:b,closeToolPanel:x,moveToolPanel:S}},Fo=({layout:t,onPanelMove:n})=>{let r=(0,e.useRef)(null);return(0,e.useEffect)(()=>()=>{r.current?.()},[]),{handleHeaderPointerDown:(0,e.useCallback)(e=>{if(e.button!==0||!t||e.target?.closest(`button, input, select, textarea`)||r.current)return;e.preventDefault();let i={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTop:t.top,startLeft:t.left};function a(e){e.pointerId===i.pointerId&&n(i.startTop+(e.clientY-i.startY),i.startLeft+(e.clientX-i.startX))}function o(e){e.pointerId===i.pointerId&&s()}function s(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),r.current=null}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),r.current=s},[t,n])}};function Io({themeClassName:t,activeTab:a,flashTick:o,tabs:s,layout:c,panelRef:l,onSelectTab:u,onRequestClose:d,onPanelMove:f,children:p}){let{handleHeaderPointerDown:m}=Fo({layout:c,onPanelMove:f});if((0,e.useEffect)(()=>{let e=l.current;if(!e||o===0)return;e.classList.remove(`ssg-toolpanel--flash`),e.offsetWidth,e.classList.add(`ssg-toolpanel--flash`);let t=()=>{e.classList.remove(`ssg-toolpanel--flash`)};return e.addEventListener(`animationend`,t),()=>{e.removeEventListener(`animationend`,t)}},[o,l]),a===null||!c)return null;let h=Math.max(0,s.findIndex(e=>e.tab===a)),g={top:c.top,left:c.left,width:c.width},_=e=>{e.stopPropagation()},v=e=>{e.stopPropagation()},y={"--ssg-seg-count":s.length,"--ssg-seg-index":h};return(0,r.createPortal)((0,n.jsxs)(`div`,{ref:l,onPointerDown:_,onKeyDown:v,onContextMenu:e=>{e.preventDefault()},className:i(`ssg-popover`,`ssg-toolpanel`,t),style:g,children:[(0,n.jsxs)(`div`,{className:`ssg-toolpanel-header ssg-popover-header--draggable`,onPointerDown:m,children:[(0,n.jsxs)(`div`,{className:`ssg-toolpanel-seg`,role:`tablist`,style:y,children:[(0,n.jsx)(`span`,{className:`ssg-toolpanel-seg-indicator`,"aria-hidden":!0}),s.map(e=>{let t=e.tab===a;return(0,n.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:()=>{t||u(e.tab)},className:i(`ssg-toolpanel-seg-btn`,t&&`ssg-toolpanel-seg-btn--active`),children:[e.label,e.badge?(0,n.jsx)(`span`,{className:`ssg-toolpanel-seg-badge`,children:e.badge}):null]},e.tab)})]}),(0,n.jsx)(`button`,{type:`button`,onClick:d,"aria-label":`閉じる`,className:`ssg-popover-close`,children:`×`})]}),(0,n.jsx)(`div`,{className:`ssg-toolpanel-body`,children:p})]}),document.body)}var Lo=28,Ro=12,zo=[`left`,`center`,`right`],Bo={left:`左固定`,center:`固定なし`,right:`右固定`};function Vo(e,t,n){let r=e.find(e=>e.key===t);if(!r)return null;let i=r.pane,a={left:[],center:[],right:[]};for(let t of e)a[t.pane].push(t.key);let o=a[i],s=o.indexOf(t);if(s<0)return null;let c=n;if(c>s&&--c,c=Math.max(0,Math.min(c,o.length-1)),c===s)return null;let[l]=o.splice(s,1);return o.splice(c,0,l),[...a.left,...a.center,...a.right]}function Ho({state:e,disabled:t}){return(0,n.jsxs)(`span`,{className:i(`ssg-checkbox`,(e===`checked`||e===`indeterminate`)&&`ssg-checkbox--filled`,t&&`ssg-checkbox--disabled`),"aria-hidden":!0,children:[e===`checked`&&(0,n.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 12 12`,fill:`none`,children:(0,n.jsx)(`path`,{d:`M2.5 6.2 4.7 8.4 9.5 3.6`,style:{stroke:`var(--ssg-panel-accent-contrast)`},strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),e===`indeterminate`&&(0,n.jsx)(`span`,{className:`ssg-checkbox-dash`})]})}function Uo({disabled:e}){return(0,n.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,style:{fill:e?`var(--ssg-panel-text-disabled)`:`var(--ssg-panel-text-faint)`},"aria-hidden":!0,children:[3,8,13].map(e=>[3,7].map(t=>(0,n.jsx)(`circle`,{cx:t,cy:e,r:`1.2`},`${t}-${e}`)))})}function Wo({items:t,canToggle:r,onToggleColumnVisibility:a,onShowAllColumns:o,onHideAllColumns:s,onResetColumns:c,onReorderColumns:l}){let[u,d]=(0,e.useState)(``),f=(0,e.useRef)(null);(0,e.useEffect)(()=>{let e=requestAnimationFrame(()=>{f.current?.focus()});return()=>cancelAnimationFrame(e)},[]);let p=(0,e.useMemo)(()=>t.filter(e=>e.visible).length,[t]),m=p===t.length&&t.length>0,h=m?`checked`:`indeterminate`,g=m?`すべての列を非表示(先頭の列は残ります)`:`すべての列を表示`,_=(0,e.useMemo)(()=>{let e=u.trim().toLowerCase();return e?t.filter(t=>t.title.toLowerCase().includes(e)):t},[t,u]),v=(0,e.useMemo)(()=>{let e={left:[],center:[],right:[]};for(let t of _)e[t.pane].push(t);return zo.map(t=>({pane:t,items:e[t]})).filter(e=>e.items.length>0)},[_]),y=v.length>=2,b=r&&u.trim()===``,x=(0,e.useRef)(null),[S,C]=(0,e.useState)(null),w=(0,e.useRef)(!1),T=(0,e.useRef)(null),[E,D]=(0,e.useState)(null),O=(0,e.useRef)(0),k=(0,e.useRef)(null),A=(0,e.useCallback)(()=>{let e=x.current,t=T.current;if(!e||!t)return;let n=e.querySelectorAll(`[data-chooser-row][data-chooser-pane="${t}"]`),r=O.current,i=n.length;for(let e=0;e<n.length;e+=1){let t=n[e].getBoundingClientRect();if(r<t.top+t.height/2){i=e;break}}D(i)},[]),j=(0,e.useCallback)(function e(){let t=x.current;if(!t||!w.current){k.current=null;return}let n=t.getBoundingClientRect(),r=O.current,i=0;if(r<n.top+Lo?i=-12:r>n.bottom-Lo&&(i=Ro),i!==0){let e=t.scrollTop;t.scrollTop+=i,t.scrollTop!==e&&A()}k.current=requestAnimationFrame(e)},[A]),M=(0,e.useCallback)(e=>{k.current!==null&&(cancelAnimationFrame(k.current),k.current=null);let n=S,r=E;if(w.current=!1,T.current=null,C(null),D(null),e&&n!==null&&r!==null){let e=Vo(t,n,r);e&&l(e)}},[S,E,t,l]),ee=(0,e.useCallback)((e,t,n)=>{b&&(n.preventDefault(),n.stopPropagation(),n.currentTarget.setPointerCapture(n.pointerId),w.current=!0,T.current=t,O.current=n.clientY,C(e),A(),k.current===null&&(k.current=requestAnimationFrame(j)))},[b,A,j]),N=(0,e.useCallback)(e=>{w.current&&(O.current=e.clientY,A())},[A]),P=(0,e.useCallback)(()=>{w.current&&M(!0)},[M]),F=(0,e.useCallback)(()=>{w.current&&M(!1)},[M]);(0,e.useEffect)(()=>()=>{k.current!==null&&(cancelAnimationFrame(k.current),k.current=null)},[]);let I=()=>{r&&(m?s():o())},te=S===null?null:t.find(e=>e.key===S)?.pane??null,ne=(e,t,o)=>{let s=e.visible&&p===1,c=!r||s,l=S===e.key;return(0,n.jsxs)(`div`,{"data-chooser-row":``,"data-chooser-pane":o,className:i(`ssg-chooser-row`,S!==null&&te===o&&E===t&&`ssg-chooser-row--drop-before`,l&&`ssg-chooser-row--dragging`),children:[(0,n.jsx)(`span`,{role:`button`,"aria-label":`ドラッグして並べ替え`,"data-ssg-tooltip":r?u.trim()===``?`ドラッグして並べ替え(同じセクション内のみ)`:`検索中は並べ替えできません`:`onColumnsChange 未指定のため並べ替えできません`,onPointerDown:t=>ee(e.key,o,t),onPointerMove:N,onPointerUp:P,onPointerCancel:F,className:i(`ssg-chooser-handle`,!b&&`ssg-chooser-handle--disabled`,l&&`ssg-chooser-handle--dragging`),children:(0,n.jsx)(Uo,{disabled:!b})}),(0,n.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>{c||a(e.key,!e.visible)},className:`ssg-chooser-toggle`,children:[(0,n.jsx)(Ho,{state:e.visible?`checked`:`unchecked`,disabled:c}),(0,n.jsx)(`span`,{className:i(`ssg-chooser-label`,c&&!e.visible&&`ssg-chooser-label--muted`),children:e.title})]})]},e.key)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{className:`ssg-chooser-search-row`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!r,onClick:I,"aria-label":g,"data-ssg-tooltip":g,className:`ssg-chooser-master-btn`,children:(0,n.jsx)(Ho,{state:h,disabled:!r})}),(0,n.jsxs)(`div`,{className:`ssg-chooser-search-field`,children:[(0,n.jsx)(`span`,{"aria-hidden":!0,className:`ssg-chooser-search-icon`,children:`⌕`}),(0,n.jsx)(`input`,{ref:f,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`検索...`,className:`ssg-chooser-search-input`})]})]}),(0,n.jsx)(`div`,{ref:x,className:`ssg-chooser-list`,children:_.length===0?(0,n.jsx)(`div`,{className:`ssg-chooser-empty`,children:`該当する列がありません`}):v.map(e=>(0,n.jsxs)(`div`,{"data-chooser-section":e.pane,children:[y&&(0,n.jsx)(`div`,{className:`ssg-chooser-section-heading`,children:Bo[e.pane]}),e.items.map((t,n)=>ne(t,n,e.pane)),S!==null&&te===e.pane&&E===e.items.length&&(0,n.jsx)(`div`,{className:`ssg-chooser-drop-end`})]},e.pane))}),(0,n.jsxs)(`div`,{className:`ssg-chooser-footer`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>{r&&c()},"data-ssg-tooltip":`すべての列の幅・固定・表示・並び順を初期状態に戻します`,className:`ssg-chooser-reset-btn`,children:`すべての列を初期状態に戻す`}),!r&&(0,n.jsx)(`div`,{className:`ssg-chooser-note`,children:`onColumnsChange 未指定のため表示/非表示・リセットを変更できません`})]})]})}function Go({disabled:e}){return(0,n.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,style:{fill:e?`var(--ssg-panel-text-disabled)`:`var(--ssg-panel-text-faint)`},"aria-hidden":!0,children:[3,8,13].map(e=>[3,7].map(t=>(0,n.jsx)(`circle`,{cx:t,cy:e,r:`1.2`},`${t}-${e}`)))})}function Ko({entries:t,columns:r,canSort:a,onAddLevel:o,onChangeDirection:s,onChangeColumn:c,onRemoveLevel:l,onClearAll:u,onMove:d}){let f=(0,e.useMemo)(()=>new Set(t.map(e=>e.columnKey)),[t]),p=(0,e.useMemo)(()=>r.find(e=>!f.has(e.key))??null,[r,f]),m=e=>r.find(t=>t.key===e)?.title??e,h=a&&t.length>=2,g=(0,e.useRef)(null),[_,v]=(0,e.useState)(null),y=(0,e.useRef)(!1),[b,x]=(0,e.useState)(null),S=(0,e.useRef)(0),C=(0,e.useCallback)(()=>{let e=g.current;if(!e)return;let t=e.querySelectorAll(`[data-sort-level]`),n=S.current,r=t.length;for(let e=0;e<t.length;e+=1){let i=t[e].getBoundingClientRect();if(n<i.top+i.height/2){r=e;break}}x(r)},[]),w=(0,e.useCallback)(e=>{let t=_,n=b;if(y.current=!1,v(null),x(null),e&&t!==null&&n!==null){let e=n;e>t&&--e,d(t,e)}},[_,b,d]),T=(0,e.useCallback)((e,t)=>{h&&(t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),y.current=!0,S.current=t.clientY,v(e),C())},[h,C]),E=(0,e.useCallback)(e=>{y.current&&(S.current=e.clientY,C())},[C]),D=(0,e.useCallback)(()=>{y.current&&w(!0)},[w]),O=(0,e.useCallback)(()=>{y.current&&w(!1)},[w]),k=a&&p!==null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{ref:g,className:`ssg-sort-list`,children:[t.length===0?(0,n.jsx)(`div`,{className:`ssg-sort-empty`,children:`並び替えは設定されていません`}):t.map((e,o)=>{let u=r.filter(t=>t.key===e.columnKey||!f.has(t.key)),d=u.some(t=>t.key===e.columnKey)?u:[{key:e.columnKey,title:m(e.columnKey)},...u],p=_===o;return(0,n.jsxs)(`div`,{"data-sort-level":``,className:i(`ssg-sort-level`,_!==null&&b===o&&`ssg-sort-level--drop-before`,p&&`ssg-sort-level--dragging`),children:[(0,n.jsx)(`span`,{role:`button`,"aria-label":`ドラッグして優先順位を変更`,"data-ssg-tooltip":a?t.length<2?`レベルが 2 件以上のとき並べ替えできます`:`ドラッグして優先順位を変更`:`並び替えが無効です`,onPointerDown:e=>T(o,e),onPointerMove:E,onPointerUp:D,onPointerCancel:O,className:i(`ssg-sort-handle`,!h&&`ssg-sort-handle--disabled`,p&&`ssg-sort-handle--dragging`),children:(0,n.jsx)(Go,{disabled:!h})}),(0,n.jsx)(`span`,{"aria-hidden":!0,className:`ssg-sort-badge`,children:o+1}),(0,n.jsx)(`select`,{value:e.columnKey,disabled:!a,onChange:e=>c(o,e.target.value),className:`ssg-sort-select`,children:d.map(e=>(0,n.jsx)(`option`,{value:e.key,children:e.title},e.key))}),(0,n.jsxs)(`div`,{className:`ssg-sort-dir-group`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>s(o,`asc`),"data-ssg-tooltip":`昇順`,className:i(`ssg-sort-dir-btn`,e.direction===`asc`&&`ssg-sort-dir-btn--active`),children:`↑ 昇順`}),(0,n.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>s(o,`desc`),"data-ssg-tooltip":`降順`,className:i(`ssg-sort-dir-btn`,e.direction===`desc`&&`ssg-sort-dir-btn--active`),children:`↓ 降順`})]}),(0,n.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>l(o),"aria-label":`このレベルを削除`,"data-ssg-tooltip":`このレベルを削除`,className:`ssg-sort-delete`,children:`×`})]},e.columnKey)}),_!==null&&b===t.length&&(0,n.jsx)(`div`,{className:`ssg-sort-drop-end`})]}),(0,n.jsxs)(`div`,{className:`ssg-popover-footer`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!k,onClick:()=>{!k||!p||o(p.key,`asc`)},"data-ssg-tooltip":a?p===null?`すべての列が並び替えに使われています`:`並び替えの基準を追加します`:`並び替えが無効です`,className:`ssg-sort-footer-btn ssg-sort-footer-btn--add`,children:`+ 基準を追加`}),(0,n.jsx)(`button`,{type:`button`,disabled:!a||t.length===0,onClick:()=>{!a||t.length===0||u()},"data-ssg-tooltip":`すべての並び替えを解除します`,className:`ssg-sort-footer-btn ssg-sort-footer-btn--clear`,children:`すべてクリア`})]}),!a&&(0,n.jsx)(`div`,{className:`ssg-sort-note`,children:`並び替えが無効のため編集できません`})]})}function qo(){return(0,n.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,n.jsx)(`path`,{d:`M2 4 L14 4 L9.2 9.2 L9.2 13 L6.8 13 L6.8 9.2 Z`})})}function Jo(){return(0,n.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,"aria-hidden":`true`,focusable:`false`,children:[(0,n.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,n.jsx)(`path`,{d:`m20 20-3.5-3.5`})]})}function Yo({entries:e,addableColumns:t,showGlobalFilterRow:r,globalFilterText:i,canFilter:a,onEditFilter:o,onAddFilter:s,onClearFilter:c,onClearAllFilters:l,onClearGlobalFilter:u}){let d=a&&e.length>0,f=a&&t.length>0;return(0,n.jsxs)(n.Fragment,{children:[r&&(0,n.jsxs)(`div`,{className:`ssg-filter-manage-row ssg-filter-manage-row--global`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-manage-glyph ssg-filter-manage-glyph--global`,"aria-hidden":`true`,children:(0,n.jsx)(Jo,{})}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-main`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-manage-name`,children:`グローバルフィルター`}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-summary`,"data-ssg-tooltip":i,children:[`"`,i,`" を含む行`]})]}),(0,n.jsx)(`span`,{className:`ssg-filter-manage-actions`,children:(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-icon-btn ssg-filter-manage-icon-btn--danger`,disabled:!a,"data-ssg-tooltip":`グローバルフィルターをクリア`,"aria-label":`グローバルフィルターをクリア`,onClick:u,children:`×`})})]}),(0,n.jsx)(`div`,{className:`ssg-filter-manage-list`,children:e.length===0?(0,n.jsx)(`div`,{className:`ssg-filter-manage-empty`,children:`適用中の列フィルターはありません`}):e.map(e=>(0,n.jsxs)(`div`,{className:`ssg-filter-manage-row`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-manage-glyph`,"aria-hidden":`true`,children:(0,n.jsx)(qo,{})}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-main`,children:[(0,n.jsxs)(`span`,{className:`ssg-filter-manage-name`,children:[e.title,e.isHidden&&(0,n.jsx)(`span`,{className:`ssg-filter-manage-hidden-note`,children:`(非表示列)`})]}),(0,n.jsx)(`span`,{className:`ssg-filter-manage-summary`,"data-ssg-tooltip":e.summaryText,children:e.summaryText})]}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-actions`,children:[(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-icon-btn`,disabled:!a||e.isHidden,"data-ssg-tooltip":e.isHidden?`非表示列のためジャンプ編集できません(× でクリアは可能)`:`この列へジャンプして編集`,"aria-label":`${e.title} のフィルターを編集`,onClick:()=>{o(e.columnKey)},children:`✎`}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-icon-btn ssg-filter-manage-icon-btn--danger`,disabled:!a,"data-ssg-tooltip":`この列のフィルターをクリア`,"aria-label":`${e.title} のフィルターをクリア`,onClick:()=>{c(e.columnKey)},children:`×`})]})]},e.columnKey))}),(0,n.jsxs)(`div`,{className:`ssg-popover-footer`,children:[(0,n.jsxs)(`select`,{className:`ssg-filter-manage-add`,value:``,disabled:!f,"aria-label":`フィルターを追加する列を選択`,onChange:e=>{let t=e.target.value;t&&s(t)},children:[(0,n.jsx)(`option`,{value:``,children:f?`+ フィルターを追加…`:`+ 追加できる列がありません`}),t.map(e=>(0,n.jsx)(`option`,{value:e.key,children:e.title},e.key))]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-clear-all`,disabled:!d,onClick:l,children:`すべてクリア`})]})]})}function Xo({entries:e,canFilter:t,onEditFilter:r,onClearFilter:i,onClearAllFilters:a}){return e.length===0?null:(0,n.jsxs)(`div`,{className:`ssg-filter-chip-bar`,children:[e.map(e=>(0,n.jsxs)(`div`,{className:e.isHidden?`ssg-filter-chip ssg-filter-chip--hidden`:`ssg-filter-chip`,children:[(0,n.jsxs)(`button`,{type:`button`,className:`ssg-filter-chip-label`,disabled:!t||e.isHidden,"data-ssg-tooltip":e.isHidden?`非表示列のためジャンプ編集できません(× でクリアは可能)`:`この列へジャンプして編集`,"aria-label":`${e.title} のフィルターを編集`,onClick:()=>{r(e.columnKey)},children:[(0,n.jsxs)(`span`,{className:`ssg-filter-chip-name`,children:[e.title,e.isHidden?`(非表示列)`:``]}),(0,n.jsx)(`span`,{className:`ssg-filter-chip-summary`,children:e.summaryText})]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-chip-clear`,disabled:!t,"data-ssg-tooltip":`この列のフィルターをクリア`,"aria-label":`${e.title} のフィルターをクリア`,onClick:()=>{i(e.columnKey)},children:`×`})]},e.columnKey)),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-chip-bar-clear-all`,disabled:!t,onClick:a,children:`すべてクリア`})]})}var Zo=e=>{if(e===void 0||e===!1)return null;let t=e===!0?{}:e,n=t.bubble??!0,r=t.ruler??!0,i=t.scrollbar??!0;return!n&&!r&&!i?null:{bubble:n,ruler:r,scrollbar:i,trigger:t.trigger??`scroll`,minRows:t.minRows??0,hintColumn:t.hintColumn,renderHint:t.renderHint}},Qo=({scrollTop:e,contentHeight:t,viewportHeight:n,trackHeight:r=n})=>{let i=t-n;if(n<=0||r<=0||i<=0)return null;let a=Math.min(Math.max(r*n/t,30),r),o=Math.min(Math.max(e,0),i)/i*(r-a);return{maxScroll:i,thumbTop:o,thumbHeight:a,centerY:o+a/2}},$o=e=>{let t=Math.max(e,1),n=10**Math.floor(Math.log10(t)),r=n<10?[1,2,5,10]:[1,2,2.5,5,10];for(let e of r){let r=n*e;if(r>=t)return r}return n*10},es=(e,t=e>=1e4&&e%1e4==0)=>e!==0&&t?`${(e/1e4).toLocaleString()}万`:e.toLocaleString(),ts=({rowCount:e,rulerHeight:t,minTickSpacingPx:n=44})=>{if(e<=0||t<=0)return[];let r=$o(e/Math.max(Math.floor(t/n),2)),i=r%1e4==0,a=[];for(let n=0;n<=e;n+=r)a.push({row:n,y:n/e*t,label:es(n,i)});return a},ns=(e,t,n)=>{let r=n-t.thumbHeight;return r<=0?0:Math.min(Math.max((e-t.thumbHeight/2)/r,0),1)*t.maxScroll},rs=(e,t)=>{if(e.renderHint!==void 0){let n=e.renderHint(t);return n==null||n===!1?null:n}if(e.hintColumn!==void 0&&t.rowData!==void 0){let n=t.rowData[e.hintColumn];return n==null||n===``?null:String(n)}return null},is=1e3,as=8,os=18,ss=28;function cs({options:t,scrollContainerRef:r,scrollTop:a,viewportHeight:o,headerHeight:s,physicalBodyHeight:c,verticalScaleFactor:l,rowMetrics:u,rowModel:d}){let[f,p]=(0,e.useState)(!1),[m,h]=(0,e.useState)(!1),[g,_]=(0,e.useState)(0),[v,y]=(0,e.useState)(null),[b,x]=(0,e.useState)(!1),S=(0,e.useRef)(null),C=(0,e.useRef)(null),w=(0,e.useRef)(null),T=t.scrollbar?s:0,E=Math.max(t.scrollbar?o-s:o,0),D=Qo({scrollTop:a,contentHeight:s+c,viewportHeight:o,trackHeight:E}),O=D!==null&&u.rowCount>0;(0,e.useEffect)(()=>{let e=r.current;if(!e)return;let n=()=>{p(!0),S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{S.current=null,p(!1)},is)},i=()=>h(!0),a=()=>{h(!1),y(null)},o=t=>{let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=e.offsetWidth-Math.max(e.offsetWidth-e.clientWidth,0)-os;y(r>=i?t.clientY-n.top:null)},s=new ResizeObserver(()=>{_(Math.max(e.offsetWidth-e.clientWidth,0))});return e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`pointerenter`,i),e.addEventListener(`pointerleave`,a),t.scrollbar||e.addEventListener(`pointermove`,o,{passive:!0}),s.observe(e),()=>{e.removeEventListener(`scroll`,n),e.removeEventListener(`pointerenter`,i),e.removeEventListener(`pointerleave`,a),e.removeEventListener(`pointermove`,o),s.disconnect(),S.current!==null&&(window.clearTimeout(S.current),S.current=null)}},[r,t.scrollbar]),(0,e.useEffect)(()=>{if(!t.scrollbar||!O)return;let e=w.current,n=r.current;if(!e||!n)return;let i=e=>{e.preventDefault(),n.scrollTop+=e.deltaY};return e.addEventListener(`wheel`,i,{passive:!1}),()=>{e.removeEventListener(`wheel`,i)}},[r,t.scrollbar,O]);let k=Math.max(o-s,0),A=(0,e.useMemo)(()=>t.ruler?ts({rowCount:u.rowCount,rulerHeight:k}):[],[t.ruler,u.rowCount,k]);if(D===null||u.rowCount<=0)return null;let j=t.trigger===`always`||f||t.trigger===`hover`&&m,M=j||v!==null,ee=t.scrollbar?14:g,N=sr(Math.min(Math.max(a,0),D.maxScroll),l),P=u.rowAtContentY(N),F=rs(t,{rowIndex:P,rowData:d.getRow(P)}),I=null;if(t.ruler&&v!==null&&!b){let e=ns(v,D,E),n=u.rowAtContentY(sr(e,l));I={lineY:Math.min(Math.max(T+v,s),o),rowIndex:n,detail:rs(t,{rowIndex:n,rowData:d.getRow(n)})}}let te=e=>{let t=w.current;return t===null?0:e.clientY-t.getBoundingClientRect().top},ne=(e,t)=>{let n=r.current;if(n===null)return;let i=E-D.thumbHeight;i<=0||(n.scrollTop=Math.min(Math.max((e-t)/i,0),1)*D.maxScroll)};return(0,n.jsxs)(`div`,{className:`ssg-scroll-hint`,"aria-hidden":`true`,children:[t.ruler&&A.length>0&&(0,n.jsx)(`div`,{className:i(`ssg-scroll-hint-ruler`,M&&`ssg-scroll-hint-ruler--visible`),style:{top:s,right:ee},children:A.map(e=>(0,n.jsx)(`div`,{className:`ssg-scroll-hint-ruler-tick`,style:{top:Math.min(Math.max(e.y,6),Math.max(k-6,6))},children:(0,n.jsx)(`span`,{className:`ssg-scroll-hint-ruler-label`,children:e.label})},e.row))}),I!==null&&(0,n.jsx)(`div`,{className:`ssg-scroll-hint-jumpline`,style:{top:I.lineY,right:ee},children:(0,n.jsxs)(`span`,{className:i(`ssg-scroll-hint-jumpline-label`,I.lineY<s+ss&&`ssg-scroll-hint-jumpline-label--below`),children:[`行 `,(I.rowIndex+1).toLocaleString(),` へ`,I.detail!==null&&(0,n.jsxs)(`span`,{className:`ssg-scroll-hint-jumpline-detail`,children:[` `,`・ `,I.detail]})]})}),t.bubble&&(0,n.jsxs)(`div`,{className:i(`ssg-scroll-hint-bubble`,j&&`ssg-scroll-hint-bubble--visible`),style:{top:T+D.centerY,right:ee+as},children:[(0,n.jsxs)(`span`,{className:`ssg-scroll-hint-bubble-main`,children:[`行 `,(P+1).toLocaleString(),(0,n.jsxs)(`span`,{className:`ssg-scroll-hint-bubble-total`,children:[` `,`/ `,u.rowCount.toLocaleString()]})]}),F!==null&&(0,n.jsx)(`span`,{className:`ssg-scroll-hint-bubble-detail`,children:F})]}),t.scrollbar&&(0,n.jsx)(`div`,{ref:w,className:i(`ssg-scroll-hint-scrollbar`,b&&`ssg-scroll-hint-scrollbar--dragging`),style:{top:s,height:E,width:14},onPointerDown:e=>{e.preventDefault();let t=te(e),n=t>=D.thumbTop&&t<=D.thumbTop+D.thumbHeight?t-D.thumbTop:D.thumbHeight/2;C.current=n,x(!0),y(null),w.current?.setPointerCapture(e.pointerId),ne(t,n)},onPointerMove:e=>{let t=te(e);if(C.current!==null){ne(t,C.current);return}y(t)},onPointerUp:e=>{C.current=null,x(!1),w.current?.releasePointerCapture(e.pointerId)},onPointerEnter:()=>h(!0),onPointerLeave:()=>{h(!1),C.current===null&&y(null)},children:(0,n.jsx)(`div`,{className:`ssg-scroll-hint-scrollbar-thumb`,style:{top:D.thumbTop,height:D.thumbHeight}})})]})}var ls=(e,t)=>e.findIndex(e=>e.key===t),us=(e,t,n)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`col`)return n>=e.startCol&&n<=e.endCol;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.max(r.row,i.row),s=Math.min(r.col,i.col),c=Math.max(r.col,i.col);return t>=a&&t<=o&&n>=s&&n<=c},ds=(e,t)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`cell`){let{start:n,end:r}=e.range,i=Math.min(n.row,r.row),a=Math.max(n.row,r.row);return t>=i&&t<=a}return!1},fs=220,ps=8,ms=34,hs=16,gs=({gridRootRef:t})=>{let[n,r]=(0,e.useState)(null),[i,a]=(0,e.useState)(null),o=(0,e.useRef)(null),s=(0,e.useRef)(null),c=(0,e.useRef)(0),l=n!==null,u=(0,e.useCallback)(()=>{let e=s.current;if(!e){a(null);return}let t=c.current*ms+hs,n=e.x,r=e.y,i=e.y-t;n=Math.max(ps,n),n=Math.min(n,window.innerWidth-fs-ps),r+t>window.innerHeight-ps&&(r=i),r=Math.max(ps,r),a(e=>e&&e.top===r&&e.left===n&&e.width===fs?e:{top:r,left:n,width:fs})},[]),d=(0,e.useCallback)(()=>{r(null),a(null),s.current=null,c.current=0,requestAnimationFrame(()=>{t.current?.focus()})},[t]),f=(0,e.useCallback)((e,n)=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),t.current?.blur(),s.current={x:e.clientX,y:e.clientY},c.current=n.length,r({params:e,items:n}),u()},[t,u]);return(0,e.useEffect)(()=>{if(!l)return;u();let e=()=>{u()},t=()=>{d()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0)}},[l,u,d]),(0,e.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;t&&(o.current?.contains(t)||d())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[l,d]),(0,e.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),d())};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[l,d]),{contextMenuState:n,contextMenuLayout:i,contextMenuRef:o,isContextMenuOpen:l,openContextMenu:f,closeContextMenu:d}};function _s({isOpen:e,themeClassName:t,items:a,layout:o,popoverRef:s,onRequestClose:c}){if(!e||!o)return null;let l={position:`fixed`,top:o.top,left:o.left,width:o.width,zIndex:1e3};return(0,r.createPortal)((0,n.jsx)(`div`,{ref:s,role:`menu`,onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{e.stopPropagation()},onContextMenu:e=>{e.preventDefault()},className:i(`ssg-menu-panel`,t),style:l,children:a.map((e,t)=>e.kind===`separator`?(0,n.jsx)(`div`,{className:`ssg-menu-separator`},e.id??`sep-${t}`):e.kind===`label`?(0,n.jsx)(`div`,{className:`ssg-menu-section-label`,role:`presentation`,children:e.label},e.id??`label-${t}`):e.kind===`custom`?(0,n.jsx)(`div`,{role:`none`,children:e.render({close:c})},e.id??`custom-${t}`):(0,n.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,onClick:()=>{e.onSelect(),c()},className:i(`ssg-menu-item`,e.danger&&`ssg-menu-item--danger`,e.disabled&&`ssg-menu-item--disabled`),children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`,children:e.icon}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:e.label})]},e.id??`action-${t}`))}),document.body)}var vs=(e,t)=>{let n=new Set(e);return n.add(t),n},ys=(e,t)=>{let n=new Set(e);return n.delete(t),n},bs=(e,t)=>{let n=new Set(e);for(let e of t)n.add(e);return n},xs=(e,t)=>{let n=new Set(e);for(let e of t)n.delete(e);return n},Ss=[],Cs={},ws={},Ts=[],Es={compact:{rowHeight:28,headerHeight:32},standard:{rowHeight:36,headerHeight:40},comfortable:{rowHeight:44,headerHeight:48}},Ds={},Os=[],ks=300,As=4,js=300;function Ms({rows:r=Ss,dataSource:o,serverSideRefreshToken:d,onServerSideLoadError:p,onServerSideWriteError:m,columns:g,onRowsChange:_,onColumnsChange:v,rowKeyGetter:y,createRow:b,createOverflowColumn:T,rowHeight:D,autoHeight:ne=!1,estimateRowHeight:re,headerHeight:ie,density:ue=`standard`,theme:me=`light`,rowHeaderWidth:he=56,height:ge,maxHeight:_e,readOnly:L=!1,dimReadOnlyCells:ve=!1,canEditCell:ye,enableUndoRedo:be=!0,enableClearOnDelete:xe=!0,editorEnterMove:Se=`down`,undoHistoryLimit:Ce=100,onUndoRedoStateChange:we,enableRangeSelection:Te=!0,enableRowSelection:Ee=!1,rowSelectionMode:De=`multiple`,enableSelectAllRows:Oe,rowSelection:Ae,selectedRowKeys:je,onRowSelectionChange:Pe,enableGlobalFilter:Fe=!0,enableColumnFilter:Ie=!0,enableSorting:Le=!0,enableColumnResize:Re=!0,autoSizeColumns:ze=!1,showCellOverflowTooltip:Be=!1,showValidationMarks:Je=!0,enableRowHover:Ze=!0,enableColumnHeaderHover:Qe=!0,enableColumnMenu:$e=!0,noMatchingRowsText:et=`一致する行がありません`,noRowsText:tt=`表示する行がありません`,showTopBar:nt=!0,showBottomBar:rt=!0,showTopBarSummary:it=!0,showTopBarFilter:at=!0,globalFilterPlaceholder:lt,globalFilterIcon:ut,showTopBarCounts:dt=!0,showBottomBarCounts:ft=!0,showFilterChipBar:pt=!1,renderTopBar:mt,renderBottomBar:ht,className:gt,classNames:z,getRowClassName:yt,enableContextMenu:bt=!1,getContextMenuItems:xt,onContextMenuOpen:Ct,scrollHint:Tt,ref:Et,onStateChange:Dt}){let Ot=D??Es[ue].rowHeight,B=ie??Es[ue].headerHeight,At=(0,e.useMemo)(()=>Zo(Tt),[Tt]),Mt=(0,e.useRef)(null),Nt=(0,e.useRef)(null),Pt=(0,e.useRef)(null),It=(0,e.useRef)(null),Lt=(0,e.useRef)(!1),Rt=(0,e.useRef)(null),zt=(0,e.useRef)(null),Vt=(0,e.useRef)(null),[Ht,Ut]=(0,e.useState)(``),[Wt,Gt]=(0,e.useState)(!1),[Kt,qt]=(0,e.useState)(null),[Jt,Yt]=(0,e.useState)(null),{groupColumns:Zt,aggColumns:Qt}=(0,e.useMemo)(()=>Zn(g),[g]),$t=o==null&&Zt.length>0,nn=(0,e.useMemo)(()=>$t?[{key:Kn,title:Zt.map(e=>e.title||e.key).join(` › `),width:240,minWidth:120,readOnly:!0,suppressAutoSize:!0},...g.filter(e=>e.rowGroup!==!0)]:g,[$t,g,Zt]),V=(0,e.useMemo)(()=>nn.filter(e=>e.visible!==!1),[nn]),H=(0,e.useMemo)(()=>l(V),[V]),rn=(0,e.useMemo)(()=>y??((e,t)=>t),[y]),U=o!=null,an=Le,sn=Ie,ln=Fe,[W,G]=(0,e.useReducer)(oe,V,ae),un=(0,e.useRef)(W.columnWidths),dn=(0,e.useRef)(null),fn=(0,e.useRef)(null);fn.current===null&&(fn.current=new Map(g.map(e=>[e.key,{width:e.width,pinned:e.pinned,visible:e.visible}])));let pn=(0,e.useMemo)(()=>de(W.selection),[W.selection]),mn=(0,e.useMemo)(()=>u(H),[H]),[hn,gn]=(0,e.useState)(0),_n=mn.left.reduce((e,{column:t})=>e+(W.columnWidths[t.key]??t.width),0),vn=mn.right.reduce((e,{column:t})=>e+(W.columnWidths[t.key]??t.width),0),xn=mn.left.length>0,Sn=xn?he+_n:0,Cn=xn?0:he,wn=(0,e.useMemo)(()=>mn.center.map(({column:e})=>e),[mn.center]),Tn=(0,e.useMemo)(()=>wn.some(w),[wn]),En=hn-Sn-vn-Cn,On=(0,e.useMemo)(()=>!Tn||hn<=0?Ds:E(wn,W.columnWidths,En),[Tn,hn,wn,W.columnWidths,En]),kn=(0,e.useMemo)(()=>On===Ds?W.columnWidths:{...On,...W.columnWidths},[On,W.columnWidths]);un.current=kn;let jn=f(mn.left,W.columnWidths),Mn=f(mn.center,kn),Bn=f(mn.right,W.columnWidths),Vn=(0,e.useMemo)(()=>h(`left`,mn.left,jn),[mn.left,jn]),Hn=(0,e.useMemo)(()=>h(`center`,mn.center,Mn),[mn.center,Mn]),Un=(0,e.useMemo)(()=>h(`right`,mn.right,Bn),[mn.right,Bn]),K=(0,e.useMemo)(()=>({left:Vn,center:Hn,right:Un}),[Vn,Hn,Un]),Wn=K.left.entries.length>0,Gn=K.right.entries.length>0,Xn=!Wn,ir=he,lr=Xn?he:0,fr=Wn?ir+K.left.totalWidth:0,pr=K.right.totalWidth,mr=lr+K.center.totalWidth,hr=fr+mr+pr,vr=(0,e.useRef)(new Map),yr=(0,e.useCallback)(e=>{let t=W.filters.columnFilters[e.key];if(t?.kind===`numberSet`||t?.kind===`textSet`||t?.kind===`dateSet`||t?.kind===`text`)return t.kind;let n=vr.current.get(e.key);if(n)return n;let i=di({editorType:e.editor?.type,isServerSide:U,rowCount:r.length,getRawValueAt:t=>R(r[t],e)});return i.conclusive&&vr.current.set(e.key,i.filterType),i.filterType},[W.filters.columnFilters,U,r]),{filterPopoverState:q,filterPopoverLayout:br,filterPopoverRef:xr,filterTextInputRef:Sr,filterSelectRef:Cr,isFilterPopoverOpen:wr,openedFilterColumn:Tr,openedFilterType:J,openColumnFilterPopover:Er,closeColumnFilterPopover:Dr,updateFilterPopoverDraft:Or,updateFilterPopoverNumberDraft:kr,updateFilterPopoverTextDraft:Ar,updateFilterPopoverDateDraft:jr}=Xt({visibleColumns:V,columnFilterValues:W.filters.columnFilters,enableColumnFilter:sn,gridRootRef:Mt,resolveColumnFilterType:yr}),{columnMenuLayout:Mr,columnMenuRef:Nr,isColumnMenuOpen:Pr,openedMenuColumnKey:Fr,openedMenuColumn:Lr,openColumnMenuFromButton:Rr,openColumnMenuFromContextMenu:zr,closeColumnMenu:Y}=So({visibleColumns:V,enableColumnMenu:$e,gridRootRef:Mt}),{activeToolPanelTab:Vr,availableToolPanelTabs:Hr,toolPanelLayout:Ur,toolPanelFlashTick:Wr,toolPanelRef:Gr,openToolPanel:Kr,closeToolPanel:qr,moveToolPanel:Jr}=Po({canUseFilterTab:sn,canUseColumnsTab:$e,canUseSortTab:an,gridRootRef:Mt,alliedRef:xr,suppressEscape:wr,onSuppressedEscape:Dr}),{contextMenuState:Yr,contextMenuLayout:Xr,contextMenuRef:Zr,isContextMenuOpen:Qr,openContextMenu:$r,closeContextMenu:ti}=gs({gridRootRef:Mt});(0,e.useEffect)(()=>{let e=V.reduce((e,t)=>(w(t)||(e[t.key]=t.width),e),{});G(a.resetColumnWidths(e))},[V]);let ni=W.filters.globalText,ii=W.filters.columnFilters,oi=(0,e.useDeferredValue)(ii),{order:si,status:ci,progress:li}=Da({rows:r,baseOrder:(0,e.useMemo)(()=>Ue(r.length),[r.length]),columns:V,globalText:ni,enabled:ln}),ui=(0,e.useMemo)(()=>{let e=[];for(let t of V)ot(oi[t.key])&&e.push(t.key);return e.join(`\0`)},[V,oi]),fi=(0,e.useMemo)(()=>{let e=new Map;if(ui.length===0)return e;let t=new Set(ui.split(`\0`)),n=r.length;for(let i of V){if(!t.has(i.key))continue;let a=new Float64Array(n);for(let e=0;e<n;e+=1)a[e]=Xe(R(r[e],i));e.set(i.key,a)}return e},[r,V,ui]),_i=(0,e.useMemo)(()=>_t(r,si,V,oi,fi),[r,si,V,oi,fi]),vi=(0,e.useMemo)(()=>zn(r,_i,V,W.sort),[r,_i,V,W.sort]);(0,e.useEffect)(()=>{},[U,Zt.length]);let Si=(0,e.useMemo)(()=>$t?Qn(r,vi,Zt,Qt):null,[$t,r,vi,Zt,Qt]),Ci=(0,e.useMemo)(()=>Si?$n(Si,W.collapsedGroupKeys):null,[Si,W.collapsedGroupKeys]),wi=(0,e.useCallback)(e=>{G(a.toggleGroupCollapsed(e))},[G]),ki=(0,e.useMemo)(()=>{if(Ci){let{displayOrder:e,groups:t}=Ci;return{getRowCount:()=>e.length,getRow:t=>r[e[t]],getSourceIndex:t=>{let n=e[t];return n>=0?n:void 0},getRowKey:n=>{let i=e[n];return Jn(i)?qn(t[Yn(i)]):rn(r[i],i)},getGroupRow:n=>{let r=e[n];return Jn(r)?t[Yn(r)]:void 0}}}return{getRowCount:()=>vi.length,getRow:e=>r[vi[e]],getSourceIndex:e=>vi[e],getRowKey:e=>rn(r[vi[e]],vi[e])}},[Ci,vi,r,rn]),Ai=(0,e.useMemo)(()=>U?La({globalText:ln?ni:``,columnFilters:sn?ii:ws,sort:an?W.sort:Ts}):Cs,[U,ln,ni,sn,ii,an,W.sort]),ji=(0,e.useMemo)(()=>U?Ra(Ai):``,[U,Ai]),[Mi,Ni]=(0,e.useState)(Ai),[Pi,Fi]=(0,e.useState)(ji);(0,e.useEffect)(()=>{if(!U)return;let e=setTimeout(()=>{Ni(Ai),Fi(ji)},js);return()=>clearTimeout(e)},[U,ji,Ai]);let X=Ia({dataSource:o,rowKeyGetter:rn,query:Mi,queryKey:Pi,refreshToken:d,onLoadError:p,onWriteError:m}),[Ii,Ui]=(0,e.useState)(null),[Gi,Ki]=(0,e.useState)(null),qi=X.requestRange,Z=U?X.rowModel:ki,Ji=(0,e.useMemo)(()=>U&&!X.canUpdateRows?()=>!1:ye,[U,X.canUpdateRows,ye]),Yi=U&&X.canUpdateRows?X.applyCellEdits:void 0,Xi=(0,e.useRef)(Z);Xi.current=Z;let Zi=(0,e.useCallback)(e=>{if(!bt||!xt)return;let t=e.target;if(!t)return;let n=t.closest(`[data-row-index]`);if(!n)return;let r=n.dataset.rowIndex;if(r===void 0)return;let i=Number(r);if(!Number.isInteger(i))return;let a=Z.getRow(i);if(!a)return;let o=Z.getRowKey(i)??i,s,c,l=t.closest(`[data-ssg-col-key]`),u=l?.dataset.ssgColKey;if(l&&u!==void 0){let e=ls(H,u);if(e<0)return;let t=H[e];s={type:`cell`,rowIndex:i,colIndex:e,rowKey:o,row:a,column:t,value:R(a,t)},c=us(W.selection,i,e)}else s={type:`rowHeader`,rowIndex:i,rowKey:o,row:a},c=ds(W.selection,i);let d={target:s,clientX:e.clientX,clientY:e.clientY,selection:W.selection,activeCell:W.activeCell,isTargetSelected:c},f=xt(d);!f||f.length===0||(e.preventDefault(),Ct?.(d),$r(d,f))},[bt,xt,Ct,Z,H,W.selection,W.activeCell,$r]),{isAutosizing:Qi,runAutosize:$i}=pa({rowModelRef:Xi,gridRootRef:Mt,columnWidthsRef:un,dispatch:G}),ea=(0,e.useRef)(V);ea.current=V;let ta=(0,e.useRef)(!1);(0,e.useEffect)(()=>{let{shouldRun:e,nextHasAutoSizedOnMount:t}=hi({mode:ze,isServerSide:U,rowCount:r.length,hasAutoSizedOnMount:ta.current});ta.current=t,e&&$i(ea.current)},[ze,r,U,$i]);let Q=Z.getRowCount(),na=Ci?vi.length:Q,ra=At!==null&&Q>=At.minRows?At:null,ia=(0,e.useMemo)(()=>{let e=null;return()=>e??=Array.from(vi,e=>r[e])},[vi,r]),aa=(0,e.useMemo)(()=>s(V,kn),[V,kn]),[oa,sa]=(0,e.useState)(0),[ca,la]=(0,e.useState)(0);(0,e.useEffect)(()=>{let e=Rt.current;if(!e)return;sa(e.scrollTop),la(e.clientHeight),gn(e.clientWidth);let t=()=>sa(e.scrollTop);e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(()=>{la(e.clientHeight),gn(e.clientWidth)});return n.observe(e),()=>{e.removeEventListener(`scroll`,t),n.disconnect()}},[]);let ua=K.center.entries,da=(0,t.useVirtualizer)({horizontal:!0,count:ua.length,getScrollElement:()=>Rt.current,estimateSize:e=>ua[e]?.paneLocalSize??ua[e]?.column.width??120,overscan:8,useFlushSync:!1,scrollMargin:fr}),fa=da.getVirtualItems(),ma=re??Ot,ha=(0,e.useMemo)(()=>V.some(e=>e.autoHeight===!0),[V]),ga=!U&&rr(ne,ha,Q,5e4);(0,e.useEffect)(()=>{},[ne,ha,Q,U]);let _a=(0,e.useRef)(new Map),[va,ya]=(0,e.useState)(0),[ba,xa]=(0,e.useState)(0),Sa=(0,e.useRef)(null),Ca=(0,e.useRef)(new Set),Ta=(0,e.useMemo)(()=>ga?Vi(Q,ma,Z.getRowKey,_a.current):null,[ga,Q,ma,Z]),Ea=(0,e.useMemo)(()=>ga&&Ta?Wi(Ta):ar(Q,Ot),[ga,Ta,va,Q,Ot]),Oa=(0,e.useMemo)(()=>ga?dr({headerHeight:B,viewportHeight:ca,scrollTop:oa,overscan:20},Ea):ur({rowCount:Q,rowHeight:Ot,headerHeight:B,viewportHeight:ca,scrollTop:oa,overscan:20,maxBodyPx:nr}),[ga,Ea,Q,Ot,B,ca,oa]),ka=Oa.rows,Aa=Oa.rowIndexSet,ja=ka.length>0?ka[0].index:0,Ma=ka.length>0?ka[ka.length-1].index:-1;(0,e.useEffect)(()=>{if(!U)return;let e=Rt.current;e&&(e.scrollTop=0),sa(0)},[U,Pi]),(0,e.useEffect)(()=>{U&&(Ma<ja||qi(ja,Ma+1))},[U,ja,Ma,qi,Pi]);let Na=Oa.physicalBodyHeight,Pa=Oa.translateY===0?void 0:`translateY(${Oa.translateY}px)`,Fa=Oa.scaleFactor,za=Oa.windowBaseOffsetPx;(0,e.useLayoutEffect)(()=>{if(!ga||!Ta){Sa.current?.disconnect(),Sa.current=null,Ca.current.clear();return}let e=Rt.current;if(!e)return;let t=e.querySelectorAll(`[data-autoheight-cell]`);if(t.length>0){let n=new Map;t.forEach(e=>{let t=e.closest(`[data-row-index]`);if(!t)return;let r=Number(t.dataset.rowIndex);if(!Number.isFinite(r))return;let i=Math.ceil(e.getBoundingClientRect().height),a=n.get(r);(a===void 0||i>a)&&n.set(r,i)});let r=!1,i=1/0;if(n.forEach((e,t)=>{let n=Z.getRowKey(t)??t;Hi(Ta,t,n,e)&&(r=!0,t<i&&(i=t))}),r){let t=e.scrollTop,n=Ea.rowAtContentY(t),r=t-Ea.rowTop(n);Bi(Ta,i),e.scrollTop=Ta.prefix[n]+r,ya(e=>e+1)}}let n=Sa.current??new ResizeObserver(()=>xa(e=>e+1));Sa.current=n;let r=Ca.current,i=new Set;t.forEach(e=>{i.add(e),r.has(e)||(n.observe(e),r.add(e))});let a=[];r.forEach(e=>{i.has(e)||a.push(e)}),a.forEach(e=>{n.unobserve(e),r.delete(e)})},[ga,Ta,Ea,Z,ka,ca,va,ba]),(0,e.useEffect)(()=>{let e=Ca.current;return()=>{Sa.current?.disconnect(),Sa.current=null,e.clear()}},[]);let Ba=(0,e.useMemo)(()=>fa.map(e=>ua[e.index]).filter(e=>!!e),[fa,ua]),Ha=K.left.entries,Ua=K.right.entries,Ga=(0,e.useMemo)(()=>{if(!W.activeCell)return null;let{row:e,col:t}=W.activeCell;if(e<0||e>=Q)return null;let n=C(K,t);return n?{pane:n.pane,rect:{left:n.extent.start,top:Ea.rowTop(e),width:n.extent.width,height:Ea.rowsHeight(e,e)}}:null},[W.activeCell,Q,K,Ea]),Ka=(0,e.useMemo)(()=>Ga&&Ga.pane===`center`?Ga.rect:null,[Ga]),qa=(0,e.useCallback)(e=>Ga&&Ga.pane===e?Ga.rect:null,[Ga]),Ja=(0,e.useCallback)(e=>W.editingCell?qa(e):null,[W.editingCell,qa]),Ya=Br(me)===`dark`?`ssg-theme-dark`:void 0;Ir(),_r({scrollRef:Rt,columnVirtualizer:da,columnMeasurements:aa,totalScrollWidth:hr,physicalBodyHeight:Na,headerHeight:B,leftPaneWidth:fr,rightPaneWidth:pr,centerLeadingWidth:lr,activeCellRect:Ka,activeCell:W.activeCell,verticalScaleFactor:Fa});let Xa=(0,e.useMemo)(()=>{if(Ae!==void 0)return Ae;if(je!==void 0)return{type:`include`,rowKeys:je}},[Ae,je]),Za=Xa!==void 0,eo=Oe??(Ee&&De===`multiple`),to=W.rowSelection,ro=P(to,na),io=(0,e.useRef)(to);io.current=to;let ao=(0,e.useRef)(De);ao.current=De;let oo=(0,e.useRef)(Pe);oo.current=Pe;let so=(0,e.useRef)(Za);so.current=Za;let co=(0,e.useRef)(null),lo=(0,e.useCallback)(e=>{te(io.current,e)||oo.current?.(F(e)),so.current||G(a.setRowSelectionState(e))},[G]),uo=(0,e.useRef)(lo);uo.current=lo;let fo=(0,e.useCallback)((e,t)=>{let n=Xi.current,r=Math.min(e,t),i=Math.max(e,t),a=[];for(let e=r;e<=i;e+=1)n.getRow(e)&&a.push(n.getRowKey(e)??e);return a},[]),po=(0,e.useCallback)((e,t)=>{let n=Xi.current;if(!n.getRow(e))return;let r=n.getRowKey(e)??e;if(ao.current===`single`){co.current=e,lo(A(r));return}if(t.shiftKey&&co.current!==null){lo(j(fo(co.current,e)));return}co.current=e,lo(k(io.current,r))},[lo,fo]),ho=(0,e.useCallback)(e=>{let t=Xi.current;if(t.getRow(e)){if(ao.current===`single`){lo(A(t.getRowKey(e)??e));return}co.current!==null&&lo(j(fo(co.current,e)))}},[lo,fo]),go=(0,e.useCallback)(()=>{let e=P(io.current,na);lo(e===`all`?ee():M())},[lo,na]);(0,e.useEffect)(()=>{if(!Za||!Xa)return;let e=I(Xa);te(io.current,e)||G(a.setRowSelectionState(e))},[Za,Xa,G]);let{updateSelectionFromPointer:vo,handleCellPointerDown:yo,handleCellPointerEnter:bo,handleNativeDragStart:xo,handleRowHeaderPointerDown:Co,handleRowHeaderPointerEnter:wo,handleColumnHeaderPointerDown:To,handleColumnHeaderPointerEnter:Eo}=gr({gridRootRef:Mt,bodyScrollRef:It,scrollContainerRef:Rt,leftPaneScrollRef:zt,rightPaneScrollRef:Vt,pointerClientRef:Nt,autoScrollFrameRef:Pt,uiState:W,dispatch:G,enableRangeSelection:Te,enableSorting:an,orderedColumns:H,filteredRowsLength:Q,visibleColumnsLength:V.length,paneLayout:K,leftLeadingWidth:ir,centerLeadingWidth:lr,rightLeadingWidth:0,headerHeight:B,rowMetrics:Ea,verticalScaleFactor:Fa,setHoveredRowIndex:qt,setHoveredColumnIndex:Yt,enableRowHover:Ze,enableColumnHeaderHover:Qe,enableRowSelection:Ee,onGutterRowSelect:po,onGutterRowSelectDrag:ho}),Do=(0,e.useRef)(()=>{}),ko=(0,e.useCallback)(e=>{e&&requestAnimationFrame(()=>{Do.current(e.row,e.col,`auto`)})},[]),Ao=be&&!L&&!U,{handleRowsChange:jo,undo:Mo,redo:No,canUndo:Fo,canRedo:Lo,clearHistory:Ro}=Dn({rows:r,selection:W.selection,activeCell:W.activeCell,onRowsChange:_,dispatch:G,enabled:Ao,limit:Ce,onUndoRedoStateChange:we,onAfterRestore:ko}),zo=(0,e.useCallback)(()=>{if(Yi){let e=mi({getRow:e=>Z.getRow(e),columns:H,selection:W.selection,activeCell:W.activeCell,viewRowCount:Q,canWriteCell:(e,t,n,r)=>ke({readOnly:L,canEditCell:Ji},e,t,n,r)});e.length>0&&Yi(e);return}if(!jo)return;let{nextRows:e,changed:t}=pi({rows:r,resolveSourceIndex:e=>Z.getSourceIndex(e),columns:H,selection:W.selection,activeCell:W.activeCell,viewRowCount:Q,canWriteCell:(e,t,n,r)=>ke({readOnly:L,canEditCell:Ji},e,t,n,r)});t&&jo(e)},[Yi,Ji,jo,H,L,Z,r,W.activeCell,W.selection,Q]),{isWholeGridSelected:Bo,handleCopy:Vo,handlePaste:Ho}=on({rows:r,rowModel:Z,visibleColumns:H,uiState:W,readOnly:L,canEditCell:Ji,createRow:b,createOverflowColumn:T,onRowsChange:jo,onColumnsChange:v,applyServerSideCellEdits:Yi,dispatch:G}),Uo=(0,e.useCallback)(()=>{if(Q===0||V.length===0)return;let e={row:0,col:0},t={row:Q-1,col:V.length-1};G(a.startSelection(e)),G(a.updateSelection(t)),G(a.endSelection()),G(a.activateCell(e))},[G,Q,V.length]),Go=(0,e.useCallback)(e=>{let t=Z.getRow(e.row),n=H[e.col];if(!t||!n||!ke({readOnly:L,canEditCell:Ji},e.row,e.col,t,n)||n.editor?.type===`checkbox`)return;let r=R(t,n);Ut(String(r??``)),G(a.startEdit(e))},[Ji,G,Z,L,H]),qo=(0,e.useCallback)(e=>{if(!jo&&!Yi)return;let t=Z.getRow(e.row),n=H[e.col];if(!t||!n||n.editor?.type!==`checkbox`||!ke({readOnly:L,canEditCell:Ji},e.row,e.col,t,n))return;let i=Ne(R(t,n),n.editor);if(en(n,t,i).action===`reject`)return;if(Yi){Yi([{viewIndex:e.row,column:n,value:i}]);return}if(!jo)return;let a=Z.getSourceIndex(e.row);a!==void 0&&jo(Ve(r,a,n,i))},[Yi,Ji,jo,H,L,Z,r]),{handleKeyDown:Jo}=An({uiState:W,rowModel:Z,visibleColumns:H,readOnly:L,canEditCell:Ji,setEditorInitialValue:Ut,dispatch:G,handleCopy:Vo,handleCellDoubleClick:Go,isWholeGridSelected:Bo,selectEntireGrid:Uo,onUndo:Mo,onRedo:No,onClearSelection:zo,enableClearOnDelete:xe,onToggleCheckboxCell:qo,onToggleGroup:wi}),{startEditWithValue:Qo,commitEdit:$o,cancelEdit:es}=bn({uiState:W,rows:r,visibleColumns:H,rowModel:Z,setEditorInitialValue:Ut,onRowsChange:jo,applyServerSideCellEdits:Yi,dispatch:G,gridRootRef:Mt,editorActionGuardRef:Lt}),ts=W.editingCell?H[W.editingCell.col]:void 0,ns=W.editingCell?Z.getRow(W.editingCell.row):void 0,rs=W.editingCell&&ts&&ns?{row:ns,rowIndex:W.editingCell.row,sourceRowIndex:Z.getSourceIndex(W.editingCell.row)??W.editingCell.row,rowKey:Z.getRowKey(W.editingCell.row)??W.editingCell.row,colIndex:W.editingCell.col,column:ts,value:R(ns,ts)}:null,is=(0,e.useCallback)(e=>{let t=Z.getRow(e.row),n=H[e.col];if(!t||!n||!ke({readOnly:L,canEditCell:Ji},e.row,e.col,t,n)||n.editor?.type===`checkbox`)return;let r=R(t,n);Qo(e,String(r??``))},[Ji,Z,L,Qo,H]),as=(0,e.useMemo)(()=>{if(!W.selection)return null;if(W.selection.type===`cell`){let e=se(W.selection.range);return{extents:x(K,e.start.col,e.end.col),startRow:e.start.row,endRow:e.end.row}}if(W.selection.type===`row`){let e=ce(W.selection.startRow,W.selection.endRow);return{extents:S(K),startRow:e.startRow,endRow:e.endRow}}let e=le(W.selection.startCol,W.selection.endCol);return{extents:x(K,e.startCol,e.endCol),startRow:0,endRow:Math.max(Q-1,0)}},[W.selection,K,Q]),os=(0,e.useMemo)(()=>{if(!as)return null;let e=or(as.startRow,as.endRow,ja,Ma);return e?{top:Ea.rowTop(e.start),height:Ea.rowsHeight(e.start,e.end)}:null},[as,Ea,ja,Ma]),ss=(0,e.useCallback)(e=>{if(!as||!os)return null;let t=as.extents[e];return t?{left:t.start,top:os.top,width:t.width,height:os.height}:null},[as,os]),fs=(0,e.useCallback)(e=>{if(e.preventDefault(),e.button===0&&!(Q===0||V.length===0)){if(Mt.current?.focus(),eo){go();return}if(Bo){G(a.clearSelection()),G(a.activateCell(null));return}Uo()}},[G,Q,Bo,Uo,V.length,eo,go]),ps=(0,e.useCallback)(e=>{qt(t=>t===e?null:t)},[]),ms=(0,e.useCallback)(e=>{Yt(t=>t===e?null:t)},[]),hs=(0,e.useCallback)(()=>{Gt(!0)},[]),Ms=(0,e.useCallback)(()=>{Gt(!1)},[]),Ns=(0,e.useCallback)((e,t)=>{t.preventDefault(),t.stopPropagation();let n=t.timeStamp,r=dn.current;if(r&&r.key===e.key&&n-r.time<ks&&Math.abs(t.clientX-r.x)<As){dn.current=null,$i([e]);return}dn.current={key:e.key,time:n,x:t.clientX},G(a.startColumnResize(e.key,t.clientX,un.current[e.key]??e.width,e.minWidth??60,e.maxWidth))},[G,$i]),Ps=(0,e.useCallback)((e,t)=>{if(Y(),!v)return;let n=g.find(t=>t.key===e);n&&(n.pinned??void 0)!==t&&(v(g.map(n=>{let r=un.current[n.key]??n.width;return n.key===e?{...n,width:r,pinned:t}:r===n.width?n:{...n,width:r}})),G(a.stopEdit()),G(a.clearSelection()),G(a.activateCell(null)))},[Y,g,G,v]),Fs=(0,e.useCallback)(e=>{Y();let t=V.find(t=>t.key===e);t&&$i([t])},[Y,$i,V]),Is=(0,e.useCallback)(()=>{Y(),$i(V)},[Y,$i,V]),Ls=(0,e.useMemo)(()=>g.map(e=>({key:e.key,title:e.title??e.key,visible:e.visible!==!1,pane:c(e)})),[g]),Rs=(0,e.useCallback)(()=>{Y(),Kr(`columns`)},[Y,Kr]),zs=(0,e.useMemo)(()=>V.map(e=>({key:e.key,title:e.title??e.key})),[V]),Bs=(0,e.useCallback)(()=>{Y(),Kr(`sort`)},[Y,Kr]),Vs=(0,e.useCallback)(e=>{Y(),Er(e)},[Y,Er]),Hs=(0,e.useMemo)(()=>{let e=[],t=(t,n)=>{let r=ii[t.key];!r||!Ye(r)||e.push({columnKey:t.key,title:t.title||t.key,summaryText:ri(r),isHidden:n})};for(let e of H)t(e,!1);for(let e of g)e.visible===!1&&t(e,!0);return e},[ii,g,H]),Us=(0,e.useMemo)(()=>V.filter(e=>!!e.filterType&&!Ye(ii[e.key])).map(e=>({key:e.key,title:e.title||e.key})),[ii,V]),Ws=(0,e.useCallback)(()=>{Y(),Kr(`filter`)},[Y,Kr]),Gs=(0,e.useCallback)(()=>{Vr===`filter`?qr():Kr(`filter`)},[Vr,qr,Kr]),Ks=(0,e.useCallback)(e=>{let t=$.current,n=Rt.current;if(!t)return;let r=t.orderedColumns.findIndex(t=>t.key===e);if(r<0)return;let i=t.orderedColumns[r];if(n){let e=C(t.paneLayout,r);if(e&&e.pane===`center`){let r=zi({cellLeft:t.leftPaneTotalWidth+t.centerLeadingWidth+e.extent.start,cellWidth:e.extent.width,leftPaneWidth:t.leftPaneTotalWidth,rightPaneWidth:t.rightPaneTotalWidth,viewportWidth:n.clientWidth,currentScrollLeft:n.scrollLeft,align:`auto`,maxScrollLeft:n.scrollWidth-n.clientWidth});r!==n.scrollLeft&&n.scrollTo({left:r,behavior:`auto`})}}let a=()=>{let t=Mt.current?.querySelectorAll(`[data-ssg-col-key]`);return t?Array.from(t).find(t=>t.dataset.ssgColKey===e)??null:null},o=e=>{if(!Mt.current)return;let t=a();if(t===null){e<8&&requestAnimationFrame(()=>o(e+1));return}Er(i),t.classList.remove(`ssg-header-cell--jump-flash`),t.offsetWidth,t.classList.add(`ssg-header-cell--jump-flash`),t.addEventListener(`animationend`,()=>{t.classList.remove(`ssg-header-cell--jump-flash`)},{once:!0})};requestAnimationFrame(()=>{o(0)})},[Mt,Er]),qs=(0,e.useCallback)(e=>{G(a.clearColumnFilter(e))},[G]),Js=(0,e.useCallback)(()=>{G(a.setAllFilters({globalText:W.filters.globalText,columnFilters:{}}))},[G,W.filters.globalText]),Ys=(0,e.useCallback)(()=>{G(a.setGlobalFilter(``))},[G]),Xs=(0,e.useCallback)((e,t)=>{if(!v)return;let n=g.find(t=>t.key===e);n&&n.visible!==!1!==t&&(!t&&g.filter(e=>e.visible!==!1).length<=1||(v(g.map(n=>{let r=un.current[n.key]??n.width;return n.key===e?{...n,width:r,visible:t}:r===n.width?n:{...n,width:r}})),G(a.stopEdit()),G(a.clearSelection()),G(a.activateCell(null))))},[g,G,v]),Zs=(0,e.useCallback)(()=>{v&&g.some(e=>e.visible===!1)&&(v(g.map(e=>{let t=un.current[e.key]??e.width,n=t!==e.width,r=e.visible===!1;return!n&&!r?e:r?{...e,width:t,visible:!0}:{...e,width:t}})),G(a.stopEdit()),G(a.clearSelection()),G(a.activateCell(null)))},[g,G,v]),Qs=(0,e.useCallback)(()=>{if(!v)return;let e=H[0]?.key;e!==void 0&&g.some(t=>t.visible!==!1&&t.key!==e)&&(v(g.map(t=>{let n=un.current[t.key]??t.width,r=n!==t.width,i=t.visible!==!1&&t.key!==e;return!r&&!i?t:i?{...t,width:n,visible:!1}:{...t,width:n}})),G(a.stopEdit()),G(a.clearSelection()),G(a.activateCell(null)))},[g,G,v,H]),$s=(0,e.useCallback)((e,t)=>{if(!v||e.length!==g.length)return;let n=new Map(g.map(e=>[e.key,e]));if(!e.every(e=>n.has(e)))return;let r=l(e.map(e=>{let r=n.get(e),i=un.current[r.key]??r.width,a=t?.has(e)?t.get(e):r.pinned,o=i!==r.width,s=(r.pinned??void 0)!==(a??void 0);return o||s?{...r,width:i,pinned:a}:r}));r.length===g.length&&r.every((e,t)=>{let n=g[t];return!!n&&n.key===e.key&&n.width===e.width&&(n.pinned??void 0)===(e.pinned??void 0)})||(v(r),G(a.stopEdit()),G(a.clearSelection()),G(a.activateCell(null)))},[g,G,v]),ec=(0,e.useCallback)(e=>{$s(e)},[$s]),{onColumnDragHandlePointerDown:tc,leftIndicatorRef:nc,centerIndicatorRef:rc,rightIndicatorRef:ic,applyReorderSettle:ac}=ei({enabled:!!v,columns:g,paneLayout:K,leftPaneScrollRef:zt,rightPaneScrollRef:Vt,bodyScrollRef:It,scrollContainerRef:Rt,leftLeadingWidth:ir,centerLeadingWidth:lr,rightLeadingWidth:0,applyColumnOrderAndPin:$s});(0,e.useLayoutEffect)(()=>{ac()},[K,ac]);let oc=v?tc:void 0,sc={position:`absolute`,top:0,height:B+Na,transform:`translateX(-1px)`,pointerEvents:`none`,zIndex:8,display:`none`},cc=(0,e.useCallback)(()=>{if(!v)return;let e=fn.current;if(!e)return;let t=gi(g,e,un.current);t!==null&&(v(t),G(a.stopEdit()),G(a.clearSelection()),G(a.activateCell(null)))},[g,G,v]),lc=(0,e.useCallback)(()=>{Y(),cc()},[Y,cc]),uc=(0,e.useCallback)(e=>Tr?R(r[e],Tr):void 0,[r,Tr]),{options:dc,allValues:fc,status:pc,progress:mc}=wa({column:Tr,rowCount:r.length,getRawValueAt:uc}),hc=J===`dateSet`,gc=(0,e.useMemo)(()=>hc?ai(dc):dc,[hc,dc]),_c=(0,e.useMemo)(()=>hc?new Set(gc.map(e=>e.value)):fc,[hc,gc,fc]),vc=Tr?W.filters.columnFilters[Tr.key]:void 0,yc=(0,e.useMemo)(()=>{let e=We(vc)?vc:Ge(vc)||Ke(vc)||qe(vc)?vc.set:null;return e?{mode:e.mode===`exclude`?`exclude`:`include`,values:new Set(e.values)}:null},[vc]),bc=!(Tr?.filterOptions&&Tr.filterOptions.length>0),xc=(0,e.useCallback)((e,t)=>{let n=Tr?.key===e?J:void 0,r=W.filters.columnFilters[e];if(n===`numberSet`){let e=Ge(r)?r.condition:null;return!e&&!t?null:{kind:`numberSet`,condition:e,set:t}}if(n===`textSet`){let e=Ke(r)?r.condition:null;return!e&&!t?null:{kind:`textSet`,condition:e,set:t}}if(n===`dateSet`){let e=qe(r)?r.condition:null;return!e&&!t?null:{kind:`dateSet`,condition:e,set:t}}return null},[Tr,W.filters.columnFilters,J]),Sc=J===`numberSet`||J===`textSet`||J===`dateSet`,Cc=(0,e.useCallback)((e,t,n)=>{let r=Tr?.key===e&&Sc,i=t.mode===`include`?t.values.size:n-t.values.size;if(i>=n){if(r){let t=xc(e,null);if(t){G(a.setColumnFilter(e,t));return}}G(a.clearColumnFilter(e));return}let o=i<=0?{mode:`include`,values:[]}:{mode:t.mode,values:Array.from(t.values)};if(r){let t=xc(e,o);if(t){G(a.setColumnFilter(e,t));return}}let s={kind:`set`,...o};G(a.setColumnFilter(e,s))},[G,Tr,Sc,xc]),wc=(0,e.useCallback)(e=>{if(!q)return;let t=gc.length,n=yc,r;r=Wa(n,e)?n===null?bc?{mode:`exclude`,values:new Set([e])}:{mode:`include`,values:ys(_c,e)}:n.mode===`include`?{mode:`include`,values:ys(n.values,e)}:{mode:`exclude`,values:vs(n.values,e)}:n.mode===`include`?{mode:`include`,values:vs(n.values,e)}:{mode:`exclude`,values:ys(n.values,e)},Cc(q.columnKey,r,t)},[q,yc,bc,_c,gc,Cc]),Tc=(0,e.useCallback)((e,t)=>{if(!q)return;let n=q.columnKey,r=gc.length;if(e===`all`){Cc(n,t?{mode:`exclude`,values:new Set}:{mode:`include`,values:new Set},r);return}let i=yc,a;if(t){if(i===null){Cc(n,{mode:`exclude`,values:new Set},r);return}a=i.mode===`include`?{mode:`include`,values:bs(i.values,e)}:{mode:`exclude`,values:xs(i.values,e)}}else a=i===null?bc?{mode:`exclude`,values:new Set(e)}:{mode:`include`,values:xs(_c,e)}:i.mode===`include`?{mode:`include`,values:xs(i.values,e)}:{mode:`exclude`,values:bs(i.values,e)};Cc(n,a,r)},[q,yc,bc,_c,gc,Cc]),Ec=(0,e.useCallback)(e=>{q&&Cc(q.columnKey,{mode:`include`,values:new Set(e)},gc.length)},[q,Cc,gc]),Dc=(0,e.useCallback)(()=>{q&&(G(a.clearColumnFilter(q.columnKey)),J===`numberSet`&&kr(vt),J===`textSet`&&Ar(kt),J===`dateSet`&&jr(Ft))},[G,q,kr,Ar,jr,J]),Oc=(0,e.useCallback)(e=>{let t=W.filters.columnFilters[e];return Ge(t)||Ke(t)||qe(t)?t.set:We(t)?{mode:t.mode,values:t.values}:null},[W.filters.columnFilters]),kc=(0,e.useCallback)(e=>{if(kr(e),!q||J!==`numberSet`)return;let t=q.columnKey,n=St(e),r=Oc(t);if(!n&&!r){W.filters.columnFilters[t]&&G(a.clearColumnFilter(t));return}G(a.setColumnFilter(t,{kind:`numberSet`,condition:n,set:r}))},[kr,q,Oc,W.filters.columnFilters,G,J]),Ac=(0,e.useCallback)(e=>{if(Ar(e),!q||J!==`textSet`)return;let t=q.columnKey,n=jt(e),r=Oc(t);if(!n&&!r){W.filters.columnFilters[t]&&G(a.clearColumnFilter(t));return}G(a.setColumnFilter(t,{kind:`textSet`,condition:n,set:r}))},[Ar,q,Oc,W.filters.columnFilters,G,J]),jc=(0,e.useCallback)(e=>{if(jr(e),!q||J!==`dateSet`)return;let t=q.columnKey,n=Bt(e),r=Oc(t);if(!n&&!r){W.filters.columnFilters[t]&&G(a.clearColumnFilter(t));return}G(a.setColumnFilter(t,{kind:`dateSet`,condition:n,set:r}))},[jr,q,Oc,W.filters.columnFilters,G,J]),Mc=(0,e.useCallback)(()=>{if(J===`textSet`){Ac(kt);return}if(J===`dateSet`){jc(Ft);return}kc(vt)},[Ac,jc,kc,J]),Nc=(0,e.useCallback)(()=>{if(!q)return;let e=q.columnKey,t=xc(e,null);if(t){G(a.setColumnFilter(e,t));return}G(a.clearColumnFilter(e))},[q,xc,G]),Pc=(0,e.useCallback)(()=>{if(!q)return;let e=J??`text`;if(e===`set`||e===`numberSet`||e===`textSet`||e===`dateSet`){Dr();return}if(e===`number`){let e=q.numberDraft?wt(q.numberDraft):null;if(!e){G(a.clearColumnFilter(q.columnKey)),Dr();return}G(a.setColumnFilter(q.columnKey,e)),Dr();return}let t=e===`select`?q.draftValue:q.draftValue.trim();if(!t){G(a.clearColumnFilter(q.columnKey)),Dr();return}let n=e===`select`?{kind:`select`,value:t}:e===`date`?{kind:`date`,value:t}:e===`custom`?{kind:`custom`,value:t}:{kind:`text`,value:t};G(a.setColumnFilter(q.columnKey,n)),Dr()},[Dr,G,q,J]),Fc=(0,e.useCallback)(()=>{q&&(G(a.clearColumnFilter(q.columnKey)),Dr())},[Dr,G,q]),Ic=(0,e.useCallback)((e,t)=>{if(Y(),!Le)return;let n=Nn(W.sort,e,t,!1);G(n.length===0?a.clearSort():a.setSort(n))},[Y,G,Le,W.sort]),Lc=(0,e.useCallback)((e,t)=>{if(!Le)return;let n=Pn(W.sort,e,t);G(a.setSort(n))},[G,Le,W.sort]),Rc=(0,e.useCallback)((e,t)=>{if(!Le)return;let n=Fn(W.sort,e,t);G(a.setSort(n))},[G,Le,W.sort]),zc=(0,e.useCallback)((e,t)=>{if(!Le)return;let n=In(W.sort,e,t);G(a.setSort(n))},[G,Le,W.sort]),Bc=(0,e.useCallback)(e=>{if(!Le)return;let t=Ln(W.sort,e);G(t.length===0?a.clearSort():a.setSort(t))},[G,Le,W.sort]),Vc=(0,e.useCallback)(()=>{Le&&G(a.clearSort())},[G,Le]),Hc=(0,e.useCallback)((e,t)=>{if(!Le)return;let n=Rn(W.sort,e,t);G(a.setSort(n))},[G,Le,W.sort]),Uc=(0,e.useCallback)((e,t,i,a,o)=>{let s=R(e,i);if(i.renderCell){let n=Z.getSourceIndex(t)??t;return i.renderCell({row:e,rowIndex:t,sourceRowIndex:n,rowKey:Z.getRowKey(t)??t,colIndex:a,value:s,column:i,isActive:o.isActive,isSelected:o.isSelected,isEditing:o.isEditing,readOnly:o.readOnly,setValue:n=>{if(en(i,e,n).action===`reject`)return;if(Yi){Yi([{viewIndex:t,column:i,value:n}]);return}if(!jo)return;let a=Z.getSourceIndex(t);if(a===void 0)return;let o=Ve(r,a,i,n);jo(o)}})}return i.editor?.type===`checkbox`?(0,n.jsx)(Va,{checked:Me(s,i.editor),readOnly:o.readOnly,onToggle:()=>qo({row:t,col:a})}):(0,n.jsx)(`span`,{children:i.valueFormatter?i.valueFormatter({value:s,row:e,column:i}):String(s??``)})},[Z,jo,r,qo,Yi]),{slotContext:Wc}=yn({rows:r,viewRowCount:na,getFilteredRows:ia,columns:g,visibleColumns:V,uiState:W,setGlobalFilterText:(0,e.useCallback)(e=>{G(a.setGlobalFilter(e))},[G]),globalFilterStatus:ci,globalFilterProgress:li}),Gc=(0,e.useMemo)(()=>({width:he,minWidth:he}),[he]),Kc=Q===0,qc=(e,t,n)=>({position:`sticky`,...e===`left`?{left:0}:{right:0},width:t,minWidth:t,flexShrink:0,alignSelf:`stretch`,zIndex:2,...n?e===`left`?{borderRight:`1px solid var(--ssg-pane-border)`,boxShadow:`var(--ssg-pane-shadow-left)`}:{borderLeft:`1px solid var(--ssg-pane-border)`,boxShadow:`var(--ssg-pane-shadow-right)`}:{}}),Jc=(()=>{if(!Tr)return`(なし)`;let e=W.filters.columnFilters[Tr.key];if(We(e))return e.mode===`exclude`?`${e.values.length}件を除外中`:`${e.values.length}件を選択中`;if(st(e))return e.raw;let t=ct(e);return t.trim()?t:`(なし)`})(),Yc=vc&&Ye(vc)?ri(vc):`フィルターなし`,Xc=Tr?(0,n.jsx)(Qa,{themeClassName:Ya,isOpen:!!q,title:Tr.title||Tr.key,filterType:J??`text`,isServerSide:U,draftValue:q?.draftValue??``,numberConditionDraft:q?.numberDraft??null,onNumberConditionDraftChange:kc,textConditionDraft:q?.textDraft??null,onTextConditionDraftChange:Ac,dateConditionDraft:q?.dateDraft??null,onDateConditionDraftChange:jc,onComboConditionClear:Mc,onComboSelectionClear:Nc,comboSummaryText:Yc,currentValueText:Jc,layout:br,selectOptions:gc,setSelection:yc,optionsStatus:pc,optionsProgress:mc,popoverRef:xr,textInputRef:Sr,selectRef:Cr,onRequestClose:Dr,onDraftChange:Or,onApply:Pc,onClear:Fc,onSetValueToggle:wc,onSetSelectAllChange:Tc,onSetClear:Dc,onSetReplaceSelection:Ec}):null,Zc=Lr?(0,n.jsx)(Oo,{themeClassName:Ya,isOpen:Pr,title:Lr.title||Lr.key,columnKey:Lr.key,canFilter:sn&&!!Lr.filterType,onOpenFilter:()=>Vs(Lr),canSort:an,sortDirection:W.sort.find(e=>e.columnKey===Lr.key)?.direction??null,onSortChange:e=>Ic(Lr.key,e),onOpenSortManager:Bs,canManageFilters:sn,onOpenFilterManager:Ws,pinned:Lr.pinned,canChangePinned:!!v,layout:Mr,popoverRef:Nr,onPinnedChange:Ps,onAutosizeColumn:Fs,onAutosizeAllColumns:Is,onOpenColumnChooser:Rs,canResetColumns:!!v,onResetColumns:lc,onRequestClose:Y}):null,Qc=ln&&ni.trim().length>0,$c=Hs.length+ +!!Qc,el=(0,n.jsx)(Io,{themeClassName:Ya,activeTab:Vr,flashTick:Wr,tabs:Hr.map(e=>e===`filter`?{tab:e,label:`フィルター`,badge:$c}:e===`sort`?{tab:e,label:`並び替え`,badge:W.sort.length}:{tab:e,label:`列`}),layout:Ur,panelRef:Gr,onSelectTab:Kr,onRequestClose:qr,onPanelMove:Jr,children:Vr===null?null:{filter:()=>(0,n.jsx)(Yo,{entries:Hs,addableColumns:Us,showGlobalFilterRow:Qc,globalFilterText:ni,canFilter:sn,onEditFilter:Ks,onAddFilter:Ks,onClearFilter:qs,onClearAllFilters:Js,onClearGlobalFilter:Ys}),columns:()=>(0,n.jsx)(Wo,{items:Ls,canToggle:!!v,onToggleColumnVisibility:Xs,onShowAllColumns:Zs,onHideAllColumns:Qs,onResetColumns:cc,onReorderColumns:ec}),sort:()=>(0,n.jsx)(Ko,{entries:W.sort,columns:zs,canSort:an,onAddLevel:Lc,onChangeDirection:Rc,onChangeColumn:zc,onRemoveLevel:Bc,onClearAll:Vc,onMove:Hc})}[Vr]()}),tl=(0,n.jsx)(_s,{themeClassName:Ya,isOpen:Qr,items:Yr?.items??Os,layout:Xr,popoverRef:Zr,onRequestClose:ti}),nl=wr||Pr||Vr!==null||Qr,rl=it,il=at&&ln,al=nt?cn(mt,Wc,rl||il?(0,n.jsx)(no,{context:Wc,showSummary:rl,showFilter:il,showCounts:dt,globalFilterPlaceholder:lt,globalFilterIcon:ut,onFilterSummaryClick:sn?Gs:void 0}):null):null,ol=rt?cn(ht,Wc,(0,n.jsx)($a,{context:Wc,showCounts:ft})):null,sl=ge===void 0&&_e===void 0?void 0:{...ge===void 0?{}:{height:ge},maxHeight:_e??(ge===void 0?void 0:`none`)},$=(0,e.useRef)(null);$.current={dispatch:G,rowModel:Z,viewRowCount:Q,leafRowCount:na,groupTree:Si,rowMetrics:Ea,paneLayout:K,orderedColumns:H,columns:g,onColumnsChange:v,uiState:W,headerHeight:B,verticalScaleFactor:Fa,leftPaneTotalWidth:fr,rightPaneTotalWidth:pr,centerLeadingWidth:lr,windowFirstRow:ja,windowLastRow:Ma,physicalBodyHeight:Na,rows:r,isServerSide:U,serverSideRefresh:X.refresh,resolvedRowKeyGetter:rn,openFilterManager:()=>{Kr(`filter`)},closeFilterManager:()=>{Vr===`filter`&&qr()},undoRows:Mo,redoRows:No,canUndoRows:Fo,canRedoRows:Lo,clearUndoHistory:Ro};let cl=(0,e.useCallback)((e,t)=>{let n=Rt.current,r=$.current;!n||!r||n.scrollTo({top:e===null?n.scrollTop:cr(e,r.verticalScaleFactor),left:t===null?n.scrollLeft:t,behavior:`auto`})},[]),ll=(0,e.useCallback)((e,t)=>{let n=Rt.current,r=$.current;if(!n||!r||r.viewRowCount===0)return null;let i=Math.min(Math.max(e,0),r.viewRowCount-1);return Ri({rowTop:r.rowMetrics.rowTop(i),rowHeight:r.rowMetrics.rowsHeight(i,i),headerHeight:r.headerHeight,viewportHeight:n.clientHeight,currentScrollTop:sr(n.scrollTop,r.verticalScaleFactor),align:t})},[]),ul=(0,e.useCallback)((e,t)=>{let n=Rt.current,r=$.current;if(!n||!r)return null;let i=C(r.paneLayout,e);return!i||i.pane!==`center`?null:zi({cellLeft:r.leftPaneTotalWidth+r.centerLeadingWidth+i.extent.start,cellWidth:i.extent.width,leftPaneWidth:r.leftPaneTotalWidth,rightPaneWidth:r.rightPaneTotalWidth,viewportWidth:n.clientWidth,currentScrollLeft:n.scrollLeft,align:t})},[]),dl=(0,e.useCallback)((e,t,n)=>{cl(ll(e,n),ul(t,n))},[cl,ul,ll]);(0,e.useEffect)(()=>{Do.current=dl},[dl]),(0,e.useImperativeHandle)(Et,()=>{let e=e=>{let t=$.current;if(!t)return null;let n=e=>t.rowModel.getRow(e),r=xi(e);if(r===`raw`)return t.isServerSide?(console.warn(`SpreadsheetGrid: scope 'raw' は serverSide では未ロード行を取得できないため、'view'(ロード済みビュー行)として扱います。全件エクスポートはサーバ側での実施を推奨します。`),{getRow:n,startRow:0,endRow:t.viewRowCount,columns:t.orderedColumns}):{getRow:e=>t.rows[e],startRow:0,endRow:t.rows.length,columns:t.orderedColumns};if(r===`rendered`)return{getRow:n,startRow:t.windowFirstRow,endRow:t.windowLastRow>=t.windowFirstRow?t.windowLastRow+1:t.windowFirstRow,columns:t.orderedColumns};if(r===`selection`){let e=t.uiState.selection;if(!e)return null;if(e.type===`cell`){let r=se(e.range);return{getRow:n,startRow:r.start.row,endRow:r.end.row+1,columns:t.orderedColumns.slice(r.start.col,r.end.col+1)}}if(e.type===`row`){let r=ce(e.startRow,e.endRow);return{getRow:n,startRow:r.startRow,endRow:r.endRow+1,columns:t.orderedColumns}}let r=le(e.startCol,e.endCol);return{getRow:n,startRow:0,endRow:t.viewRowCount,columns:t.orderedColumns.slice(r.startCol,r.endCol+1)}}return{getRow:n,startRow:0,endRow:t.viewRowCount,columns:t.orderedColumns}},t=e=>e.filter(e=>e.key!==Kn),n=n=>{let r=e(n?.scope??`view`);return r?yi({getRow:r.getRow,startRow:r.startRow,endRow:r.endRow,columns:t(r.columns),delimiter:n?.delimiter,includeHeaders:n?.includeHeaders,bom:n?.bom}):n?.bom?``:``},r=n=>{let r=e(n?.scope??`view`);return r?bi({getRow:r.getRow,startRow:r.startRow,endRow:r.endRow,columns:t(r.columns)}):{columns:[],rows:[]}};return{scrollToRow:(e,t)=>cl(ll(e,t?.align??`auto`),null),scrollToCell:(e,t,n)=>dl(e,t,n?.align??`auto`),scrollToTop:()=>{Rt.current?.scrollTo({top:0,behavior:`auto`})},scrollToBottom:()=>{let e=Rt.current,t=$.current;!e||!t||e.scrollTo({top:Math.max(t.headerHeight+t.physicalBodyHeight-e.clientHeight,0),behavior:`auto`})},getVisibleRowRange:()=>{let e=$.current;return!e||e.windowLastRow<e.windowFirstRow?null:{startIndex:e.windowFirstRow,endIndex:e.windowLastRow+1}},getActiveCell:()=>{let e=$.current?.uiState.activeCell;return e?{row:e.row,col:e.col}:null},setActiveCell:(e,t)=>{let n=$.current;n&&(n.dispatch(a.activateCell(e)),e&&t?.scrollIntoView&&dl(e.row,e.col,`auto`))},getSelection:()=>$.current?.uiState.selection??null,selectCell:(e,t,n)=>{let r=$.current;if(!r)return;let i={row:e,col:t};r.dispatch(a.startSelection(i)),r.dispatch(a.endSelection()),n?.scrollIntoView&&dl(e,t,`auto`)},selectRange:(e,t)=>{let n=$.current;n&&(n.dispatch(a.startSelection(e.start)),n.dispatch(a.updateSelection(e.end)),n.dispatch(a.endSelection()),t?.scrollIntoView&&dl(e.end.row,e.end.col,`auto`))},clearSelection:()=>{$.current?.dispatch(a.clearSelection())},getSelectedRows:()=>{let e=$.current;if(!e)return[];let t=e.uiState.selection;if(!t)return[];let n=[],r=t=>{let r=e.rowModel.getRow(t);r&&n.push(r)};if(t.type===`cell`){let e=se(t.range);for(let t=e.start.row;t<=e.end.row;t+=1)r(t)}else if(t.type===`row`){let e=ce(t.startRow,t.endRow);for(let t=e.startRow;t<=e.endRow;t+=1)r(t)}else for(let t=0;t<e.viewRowCount;t+=1)r(t);return n},exportCsv:e=>n(e),downloadCsv:(e,t)=>{if(typeof document>`u`)return;let r=n({...t,bom:t?.bom??!0}),i=new Blob([r],{type:`text/csv;charset=utf-8;`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e??`export.csv`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},getExportData:e=>r(e),getState:()=>{let e=$.current;return e?Ei(e.uiState.columnWidths,e.uiState.filters,e.uiState.sort,Ti(e.columns)):Ei({},{globalText:``,columnFilters:{}},[],[])},applyState:e=>{let t=$.current;if(!t)return;let n=Di(e);t.onColumnsChange&&n.columns&&t.onColumnsChange(Oi(t.columns,n.columns,n.columnWidths)),t.dispatch(a.resetColumnWidths(n.columnWidths)),t.dispatch(a.setAllFilters(n.filters)),t.dispatch(a.setSort(n.sort))},getRowSelection:()=>{let e=$.current;return e?F(e.uiState.rowSelection):{type:`include`,rowKeys:[]}},setRowSelection:e=>{uo.current(I(e))},getSelectedRowKeys:()=>{let e=$.current;if(!e)return[];let t=e.uiState.rowSelection;if(t.mode===`include`)return Array.from(t.keys);let n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){if(!e.rowModel.getRow(i))continue;let r=e.rowModel.getRowKey(i)??i;t.keys.has(r)||n.push(r)}return n},getSelectedRowData:()=>{let e=$.current;if(!e)return[];let t=e.uiState.rowSelection,n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){let r=e.rowModel.getRow(i);r&&O(t,e.rowModel.getRowKey(i)??i)&&n.push(r)}return n},getSelectedRowCount:()=>{let e=$.current;return e?N(e.uiState.rowSelection,e.leafRowCount):0},isRowSelected:e=>{let t=$.current;return t?O(t.uiState.rowSelection,e):!1},selectAllRows:()=>{uo.current(M())},clearRowSelection:()=>{uo.current(ee())},undo:()=>{$.current?.undoRows()},redo:()=>{$.current?.redoRows()},canUndo:()=>$.current?.canUndoRows()??!1,canRedo:()=>$.current?.canRedoRows()??!1,clearUndoHistory:()=>{$.current?.clearUndoHistory()},setGroupCollapsed:(e,t)=>{$.current?.dispatch(a.setGroupCollapsed(e,t))},expandAllGroups:()=>{$.current?.dispatch(a.setCollapsedGroupKeys(new Set))},collapseAllGroups:()=>{let e=$.current;!e||!e.groupTree||e.dispatch(a.setCollapsedGroupKeys(new Set(tr(e.groupTree))))},getGroupRows:()=>{let e=$.current;return e?.groupTree?er(e.groupTree):[]},getInvalidCells:()=>{let e=$.current;return e?e.isServerSide?(console.warn(`[SpreadsheetGrid] getInvalidCells は serverSide モードでは利用できません(空配列を返します)。`),[]):tn(e.rows,e.columns,e.resolvedRowKeyGetter):[]},refreshServerSide:()=>{let e=$.current;if(e){if(!e.isServerSide){console.warn(`[SpreadsheetGrid] refreshServerSide は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。`);return}e.serverSideRefresh()}},openFilterManager:()=>{$.current?.openFilterManager()},closeFilterManager:()=>{$.current?.closeFilterManager()}}},[cl,dl,ll]);let fl=(0,e.useRef)(Dt);fl.current=Dt;let pl=(0,e.useRef)(null);return(0,e.useEffect)(()=>{if(!fl.current)return;let e=Ei(W.columnWidths,W.filters,W.sort,Ti(g)),t=Li(pl.current,e,W.dragState!==null);pl.current=t.nextLast,t.emit&&fl.current(e)},[W.columnWidths,W.filters,W.sort,W.dragState,g]),(0,n.jsxs)(`div`,{className:i(`ssg-root`,ue!==`standard`&&`ssg-root--density-${ue}`,Ya,ve&&`ssg-root--dim-readonly`,gt,z?.root),children:[al,pt&&(0,n.jsx)(Xo,{entries:Hs,canFilter:sn,onEditFilter:Ks,onClearFilter:qs,onClearAllFilters:Js}),(0,n.jsxs)(`div`,{ref:Mt,className:`ssg-shell`,style:{cursor:Qi?`progress`:void 0},onDragStart:xo,onPointerLeave:()=>qt(null),onPointerMoveCapture:e=>{Nt.current={x:e.clientX,y:e.clientY},vo(e.clientX,e.clientY)},tabIndex:nl?-1:0,onKeyDown:nl?void 0:Jo,onPaste:nl?void 0:Ho,onContextMenu:Zi,children:[(0,n.jsxs)(`div`,{ref:Rt,className:i(`ssg-scroll-container`,ra?.scrollbar===!0&&`ssg-scroll-container--custom-scrollbar`),style:sl,children:[(0,n.jsxs)(`div`,{className:`ssg-inner-row`,style:{width:hr,minWidth:hr,height:B+Na},children:[(0,n.jsxs)(`div`,{ref:zt,style:qc(`left`,fr,Wn),children:[Wn&&(0,n.jsxs)(`div`,{style:{position:`relative`,overflow:`clip`,width:fr,minWidth:fr,height:B+Na},children:[(0,n.jsx)(_o,{pane:`left`,ownsRowHeader:!0,leadingWidth:ir,headerHeight:B,rowHeaderCellStyle:Gc,headerRowClassName:z?.headerRow,headerCellClassName:z?.headerCell,rowHeaderCellClassName:z?.rowHeaderCell,isCornerHovered:Wt,isWholeGridSelected:Bo,showSelectAllCheckbox:eo,selectAllState:ro,filteredRowsLength:Q,visibleColumnsLength:V.length,renderEntries:Ha,hoveredColumnIndex:Jt,selectionSnapshot:pn,columnFilterValues:W.filters.columnFilters,sortState:W.sort,iconButtonClassName:z?.iconButton,onCornerPointerDown:fs,onCornerPointerEnter:hs,onCornerPointerLeave:Ms,onColumnHeaderPointerDown:To,onColumnHeaderPointerEnter:Eo,onColumnHeaderPointerLeave:ms,onColumnResizePointerDown:Ns,enableColumnMenu:$e,enableColumnResize:Re,openedMenuColumnKey:Fr,onColumnMenuButtonPointerDown:Rr,onColumnHeaderContextMenu:zr,onColumnDragHandlePointerDown:oc}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,width:fr,height:B+Na,transform:Pa},children:[(0,n.jsx)(fe,{rect:ss(`left`),headerHeight:B,baseOffset:za,leadingWidth:ir}),(0,n.jsx)(pe,{rect:qa(`left`),headerHeight:B,baseOffset:za,leadingWidth:ir}),(0,n.jsx)(He,{rect:Ja(`left`),headerHeight:B,baseOffset:za,leadingWidth:ir,initialValue:Ht,editor:ts?.editor,editorSession:rs,themeClassName:Ya,onCommit:$o,onCancel:es,align:ts?.align,enterMove:Se}),(0,n.jsx)(mo,{pane:`left`,ownsRowHeader:!0,leadingWidth:ir,rowModel:Z,virtualRows:ka,virtualRowIndexes:Aa,renderEntries:Ha,rowHeight:Ot,autoHeight:ga,showCellOverflowTooltip:Be,showValidationMarks:Je,isServerSide:U,collapsedGroupKeys:W.collapsedGroupKeys,onGroupToggle:wi,rowHeaderCellStyle:Gc,hoveredRowIndex:Kt,isWholeGridSelected:Bo,enableRowSelection:Ee,rowSelectionState:to,activeCell:W.activeCell,editingCell:W.editingCell,selectionSnapshot:pn,readOnly:L,canEditCell:Ji,onRowHeaderPointerDown:Co,onRowHeaderPointerEnter:wo,onRowHeaderPointerLeave:ps,onCellPointerDown:yo,onCellPointerEnter:bo,onCellDoubleClick:is,renderCellContent:Uc,getRowClassName:yt,bodyCellClassName:z?.bodyCell,bodyRowClassName:z?.bodyRow,rowHeaderCellClassName:z?.rowHeaderCell})]})]}),(0,n.jsx)(`div`,{ref:nc,className:`ssg-col-drop-indicator`,style:sc})]}),(0,n.jsx)(`div`,{ref:It,className:`ssg-center-pane`,style:{width:mr,minWidth:mr},children:(0,n.jsxs)(`div`,{style:{position:`relative`,overflow:`clip`,width:mr,minWidth:mr,height:B+Na},children:[(0,n.jsx)(_o,{pane:`center`,ownsRowHeader:Xn,leadingWidth:lr,headerHeight:B,rowHeaderCellStyle:Gc,headerRowClassName:z?.headerRow,headerCellClassName:z?.headerCell,rowHeaderCellClassName:z?.rowHeaderCell,isCornerHovered:Wt,isWholeGridSelected:Bo,showSelectAllCheckbox:eo,selectAllState:ro,filteredRowsLength:Q,visibleColumnsLength:V.length,renderEntries:Ba,hoveredColumnIndex:Jt,selectionSnapshot:pn,columnFilterValues:W.filters.columnFilters,sortState:W.sort,iconButtonClassName:z?.iconButton,onCornerPointerDown:fs,onCornerPointerEnter:hs,onCornerPointerLeave:Ms,onColumnHeaderPointerDown:To,onColumnHeaderPointerEnter:Eo,onColumnHeaderPointerLeave:ms,onColumnResizePointerDown:Ns,enableColumnMenu:$e,enableColumnResize:Re,openedMenuColumnKey:Fr,onColumnMenuButtonPointerDown:Rr,onColumnHeaderContextMenu:zr,onColumnDragHandlePointerDown:oc}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,width:mr,height:B+Na,transform:Pa},children:[(0,n.jsx)(fe,{rect:ss(`center`),headerHeight:B,baseOffset:za,leadingWidth:lr}),(0,n.jsx)(pe,{rect:qa(`center`),headerHeight:B,baseOffset:za,leadingWidth:lr}),(0,n.jsx)(He,{rect:Ja(`center`),headerHeight:B,baseOffset:za,leadingWidth:lr,initialValue:Ht,editor:ts?.editor,editorSession:rs,themeClassName:Ya,onCommit:$o,onCancel:es,align:ts?.align,enterMove:Se}),(0,n.jsx)(mo,{pane:`center`,ownsRowHeader:Xn,leadingWidth:lr,rowModel:Z,virtualRows:ka,virtualRowIndexes:Aa,renderEntries:Ba,rowHeight:Ot,autoHeight:ga,showCellOverflowTooltip:Be,showValidationMarks:Je,isServerSide:U,collapsedGroupKeys:W.collapsedGroupKeys,onGroupToggle:wi,rowHeaderCellStyle:Gc,hoveredRowIndex:Kt,isWholeGridSelected:Bo,enableRowSelection:Ee,rowSelectionState:to,activeCell:W.activeCell,editingCell:W.editingCell,selectionSnapshot:pn,readOnly:L,canEditCell:Ji,onRowHeaderPointerDown:Co,onRowHeaderPointerEnter:wo,onRowHeaderPointerLeave:ps,onCellPointerDown:yo,onCellPointerEnter:bo,onCellDoubleClick:is,renderCellContent:Uc,getRowClassName:yt,bodyCellClassName:z?.bodyCell,bodyRowClassName:z?.bodyRow,rowHeaderCellClassName:z?.rowHeaderCell})]}),(0,n.jsx)(`div`,{ref:rc,className:`ssg-col-drop-indicator`,style:sc})]})}),(0,n.jsxs)(`div`,{ref:Vt,style:qc(`right`,pr,Gn),children:[Gn&&(0,n.jsxs)(`div`,{style:{position:`relative`,overflow:`clip`,width:pr,minWidth:pr,height:B+Na},children:[(0,n.jsx)(_o,{pane:`right`,ownsRowHeader:!1,leadingWidth:0,headerHeight:B,rowHeaderCellStyle:Gc,headerRowClassName:z?.headerRow,headerCellClassName:z?.headerCell,rowHeaderCellClassName:z?.rowHeaderCell,isCornerHovered:Wt,isWholeGridSelected:Bo,showSelectAllCheckbox:eo,selectAllState:ro,filteredRowsLength:Q,visibleColumnsLength:V.length,renderEntries:Ua,hoveredColumnIndex:Jt,selectionSnapshot:pn,columnFilterValues:W.filters.columnFilters,sortState:W.sort,iconButtonClassName:z?.iconButton,onCornerPointerDown:fs,onCornerPointerEnter:hs,onCornerPointerLeave:Ms,onColumnHeaderPointerDown:To,onColumnHeaderPointerEnter:Eo,onColumnHeaderPointerLeave:ms,onColumnResizePointerDown:Ns,enableColumnMenu:$e,enableColumnResize:Re,openedMenuColumnKey:Fr,onColumnMenuButtonPointerDown:Rr,onColumnHeaderContextMenu:zr,onColumnDragHandlePointerDown:oc}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,width:pr,height:B+Na,transform:Pa},children:[(0,n.jsx)(fe,{rect:ss(`right`),headerHeight:B,baseOffset:za,leadingWidth:0}),(0,n.jsx)(pe,{rect:qa(`right`),headerHeight:B,baseOffset:za,leadingWidth:0}),(0,n.jsx)(He,{rect:Ja(`right`),headerHeight:B,baseOffset:za,leadingWidth:0,initialValue:Ht,editor:ts?.editor,editorSession:rs,themeClassName:Ya,onCommit:$o,onCancel:es,align:ts?.align,enterMove:Se}),(0,n.jsx)(mo,{pane:`right`,ownsRowHeader:!1,leadingWidth:0,rowModel:Z,virtualRows:ka,virtualRowIndexes:Aa,renderEntries:Ua,rowHeight:Ot,autoHeight:ga,showCellOverflowTooltip:Be,showValidationMarks:Je,isServerSide:U,collapsedGroupKeys:W.collapsedGroupKeys,onGroupToggle:wi,rowHeaderCellStyle:Gc,hoveredRowIndex:Kt,isWholeGridSelected:Bo,enableRowSelection:Ee,rowSelectionState:to,activeCell:W.activeCell,editingCell:W.editingCell,selectionSnapshot:pn,readOnly:L,canEditCell:Ji,onRowHeaderPointerDown:Co,onRowHeaderPointerEnter:wo,onRowHeaderPointerLeave:ps,onCellPointerDown:yo,onCellPointerEnter:bo,onCellDoubleClick:is,renderCellContent:Uc,getRowClassName:yt,bodyCellClassName:z?.bodyCell,bodyRowClassName:z?.bodyRow,rowHeaderCellClassName:z?.rowHeaderCell})]})]}),(0,n.jsx)(`div`,{ref:ic,className:`ssg-col-drop-indicator`,style:sc})]})]}),Kc&&(0,n.jsx)(`div`,{className:`ssg-empty-state`,children:r.length===0?tt:et})]}),ra!==null&&(0,n.jsx)(cs,{options:ra,scrollContainerRef:Rt,scrollTop:oa,viewportHeight:ca,headerHeight:B,physicalBodyHeight:Na,verticalScaleFactor:Fa,rowMetrics:Ea,rowModel:Z}),Qi&&(0,n.jsx)(`div`,{className:`ssg-autosize-overlay`,children:(0,n.jsx)(`span`,{className:`ssg-autosize-pill`,children:`列幅を計算中…`})}),ci===`filtering`&&(0,n.jsx)(`div`,{className:`ssg-filter-overlay`,children:(0,n.jsxs)(`span`,{className:`ssg-filter-overlay-chip`,role:`status`,"aria-live":`polite`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-spinner`,"aria-hidden":`true`}),(0,n.jsxs)(`span`,{className:`ssg-filter-overlay-text`,children:[`適用中 `,Math.round(li*100),`%`]})]})}),U&&(X.loadError!==null&&X.loadError!==Ii||X.writeError!==null&&X.writeError!==Gi)&&(0,n.jsxs)(`div`,{className:`ssg-ssrm-error-bars`,children:[X.loadError!==null&&X.loadError!==Ii&&(0,n.jsxs)(`div`,{className:`ssg-ssrm-error-bar`,role:`alert`,children:[(0,n.jsx)(`span`,{className:`ssg-ssrm-error-bar-dot`,"aria-hidden":`true`}),(0,n.jsxs)(`span`,{className:`ssg-ssrm-error-bar-msg`,children:[`行の取得に失敗しました(`,X.loadError.failedBlockCount,` ブロック)`]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-ssrm-error-bar-retry`,onClick:X.retryFailedBlocks,children:`再試行`}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-ssrm-error-bar-close`,"aria-label":`エラー通知を閉じる`,onClick:()=>Ui(X.loadError),children:`×`})]}),X.writeError!==null&&X.writeError!==Gi&&(0,n.jsxs)(`div`,{className:`ssg-ssrm-error-bar`,role:`alert`,children:[(0,n.jsx)(`span`,{className:`ssg-ssrm-error-bar-dot`,"aria-hidden":`true`}),(0,n.jsxs)(`span`,{className:`ssg-ssrm-error-bar-msg`,children:[`変更の保存に失敗しました(`,X.writeError.failedRowCount,` 行)。値を元に戻しました`]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-ssrm-error-bar-close`,"aria-label":`保存エラー通知を閉じる`,onClick:()=>Ki(X.writeError),children:`×`})]})]})]}),ol,Xc,Zc,el,tl]})}function Ns(e={}){let{locale:t,useGrouping:n=!0,minimumFractionDigits:r,maximumFractionDigits:i,emptyText:a=``}=e;return({value:e})=>{if(e==null||e===``)return a;let o=typeof e==`number`?e:Number(e);if(!Number.isFinite(o))return String(e);let s=Math.abs(o).toString(),c=s.indexOf(`.`),l=c===-1?0:s.length-c-1,u=r??0,d=Math.max(u,i??Math.min(l,20));return new Intl.NumberFormat(t,{useGrouping:n,minimumFractionDigits:u,maximumFractionDigits:d}).format(o)}}exports.SpreadsheetGrid=Ms,exports.numberFormatter=Ns;
|
|
4
|
+
`).filter(e=>e.length>0).map(e=>e.split(` `)):[]},cn=(e,t,n,r)=>{if(!r)return``;let i=[];if(r.type===`cell`){let t=se(r.range);for(let r=t.start.row;r<=t.end.row;r+=1){let a=e(r);if(!a)continue;let o=[];for(let e=t.start.col;e<=t.end.col;e+=1){let t=n[e];if(!t)continue;let r=L(a,t),i=t.formatClipboardValue?t.formatClipboardValue(r,a):String(r??``);o.push(i)}i.push(o.join(` `))}return i.join(`
|
|
5
|
+
`)}if(r.type===`row`){let t=ce(r.startRow,r.endRow);for(let r=t.startRow;r<=t.endRow;r+=1){let t=e(r);if(!t)continue;let a=n.map(e=>{let n=L(t,e);return e.formatClipboardValue?e.formatClipboardValue(n,t):String(n??``)});i.push(a.join(` `))}return i.join(`
|
|
6
|
+
`)}let a=le(r.startCol,r.endCol);for(let r=0;r<t;r+=1){let t=e(r);if(!t)continue;let o=[];for(let e=a.startCol;e<=a.endCol;e+=1){let r=n[e];if(!r)continue;let i=L(t,r),a=r.formatClipboardValue?r.formatClipboardValue(i,t):String(i??``);o.push(a)}i.push(o.join(` `))}return i.join(`
|
|
7
|
+
`)},ln=(e,t,n,r,i,a,o)=>{if(r.length===0)return e;let s=[...e];for(let e=0;e<r.length;e+=1){let c=t(i+e);if(c===void 0)continue;let l=s[c];if(!l)continue;let u=l,d=!1;for(let t=0;t<r[e].length;t+=1){let i=a+t,s=n[i];if(!s||!o(c,i,l,s))continue;let f=r[e][t],p=Be(s)(f,l);an(s,l,p).action!==`reject`&&(u=je(u,s,p),d=!0)}d&&(s[c]=u)}return s},U=(e,t,n,r,i,a)=>{let o=[];for(let s=0;s<n.length;s+=1){let c=r+s,l=e(c);if(l)for(let e=0;e<n[s].length;e+=1){let r=i+e,u=t[r];if(!u||!a(c,r,l,u))continue;let d=Be(u)(n[s][e],l);an(u,l,d).action!==`reject`&&o.push({viewIndex:c,column:u,value:d})}}return o},W=e=>{let{body:t,activeElement:n}=document;if(!t)return!1;let r=document.createElement(`textarea`);r.value=e,r.setAttribute(`readonly`,``),r.style.position=`fixed`,r.style.top=`0`,r.style.left=`-9999px`,r.style.opacity=`0`,t.appendChild(r);let i;try{r.select(),i=document.execCommand(`copy`)}catch{i=!1}finally{t.removeChild(r),n instanceof HTMLElement&&n.focus()}return i},un=async e=>{if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}return W(e)?!0:(console.warn(`[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。`),!1)},dn=({rows:t,rowModel:n,visibleColumns:r,uiState:i,readOnly:s,canEditCell:c,createRow:l,createOverflowColumn:u,onRowsChange:d,onColumnsChange:f,applyServerSideCellEdits:p,dispatch:m})=>{let h=n.getRowCount(),g=h>0&&r.length>0&&i.selection?.type===`cell`&&(()=>{let e=i.selection.range.start,t=i.selection.range.end,n=Math.min(e.row,t.row),a=Math.min(e.col,t.col),o=Math.max(e.row,t.row),s=Math.max(e.col,t.col);return n===0&&a===0&&o===h-1&&s===r.length-1})(),_=(0,e.useCallback)(()=>{let e=n.getRowCount();if(e===0||r.length===0)return``;let t=[];for(let i=0;i<e;i+=1){let e=n.getRow(i);if(!e)continue;let a=r.map(t=>{let n=L(e,t);return t.formatClipboardValue?t.formatClipboardValue(n,e):String(n??``)});t.push(a.join(` `))}return t.join(`
|
|
8
|
+
`)},[n,r]);return{isWholeGridSelected:g,handleCopy:(0,e.useCallback)(async()=>{let e=g?_():cn(n.getRow,n.getRowCount(),r,i.selection);e&&await un(e)},[g,n,_,i.selection,r]),handlePaste:(0,e.useCallback)(e=>{if(s||!d&&!p||!i.activeCell)return;let h=e.clipboardData.getData(`text/plain`);if(!h)return;e.preventDefault();let g=sn(h);if(g.length===0)return;let _=g.reduce((e,t)=>Math.max(e,t.length),0);if(_===0)return;let v=i.activeCell.row,y=i.activeCell.col;if(p){let e=U(e=>n.getRow(e),r,g,v,y,(e,t,n,r)=>Ae({readOnly:s,canEditCell:c},e,t,n,r));e.length>0&&p(e);let t=o(i.activeCell.row+Math.max(g.length-1,0),0,Math.max(n.getRowCount()-1,0)),l=o(i.activeCell.col+Math.max(_-1,0),0,Math.max(r.length-1,0));m(a.startSelection(i.activeCell)),m(a.updateSelection({row:t,col:l})),m(a.endSelection()),m(a.activateCell(i.activeCell));return}if(!d)return;let b=n.getSourceIndex(v);if(b===void 0)return;let x=i.activeCell.col,S=[...t],C=[...r],w=n.getRowCount(),T=S.length,E=e=>e<w?n.getSourceIndex(e):T+(e-w),D=b+g.length;if(D>S.length&&l)for(;S.length<D;)S.push(l());let O=x+_;if(O>C.length&&f&&u){for(;C.length<O;)C.push(u(C.length));f(C)}let k=ln(S,E,C,g,v,x,(e,t,n,r)=>Ae({readOnly:s,canEditCell:c},e,t,n,r)),A=o(i.activeCell.row+Math.max(g.length-1,0),0,Math.max(Math.max(n.getRowCount()-1,0),v+g.length-1)),j=o(i.activeCell.col+Math.max((g[0]?.length??1)-1,0),0,Math.max(Math.max(C.length-1,0),x+_-1));d(k),m(a.startSelection(i.activeCell)),m(a.updateSelection({row:A,col:j})),m(a.endSelection()),m(a.activateCell(i.activeCell))},[p,c,u,l,m,f,d,s,n,t,i.activeCell,r])}},fn=e=>{if(e<0)return``;let t=e,n=``;for(;t>=0;)n=String.fromCharCode(t%26+65)+n,t=Math.floor(t/26)-1;return n},pn=(e,t,n)=>e?e(t):n,mn=(e,t=16)=>e.length<=t?e:`${e.slice(0,t)}…`,hn=e=>e?`${fn(e.col)}${e.row+1}`:`なし`,gn=e=>{if(!e)return`なし`;if(e.type===`cell`){let t=Math.min(e.range.start.row,e.range.end.row),n=Math.max(e.range.start.row,e.range.end.row),r=Math.min(e.range.start.col,e.range.end.col),i=Math.max(e.range.start.col,e.range.end.col);return`${fn(r)}${t+1} - ${fn(i)}${n+1}`}if(e.type===`row`){let t=Math.min(e.startRow,e.endRow),n=Math.max(e.startRow,e.endRow);return`Row ${t+1} - ${n+1}`}let t=Math.min(e.startCol,e.endCol),n=Math.max(e.startCol,e.endCol);return`Col ${fn(t)} - ${fn(n)}`},_n=(e,t)=>`Rows: ${t} / ${e.rows.length}`,vn=e=>`Columns: ${e.visibleColumns.length} / ${e.columns.length}`,yn=(e,t)=>{let n=e.selection;if(!n)return{selectedCellCount:0,selectedRowCount:0,selectedColumnCount:0};if(n.type===`cell`){let e=Math.min(n.range.start.row,n.range.end.row),t=Math.max(n.range.start.row,n.range.end.row),r=Math.min(n.range.start.col,n.range.end.col),i=Math.max(n.range.start.col,n.range.end.col),a=t-e+1,o=i-r+1;return{selectedCellCount:a*o,selectedRowCount:a,selectedColumnCount:o}}if(n.type===`row`){let t=Math.min(n.startRow,n.endRow),r=Math.max(n.startRow,n.endRow)-t+1,i=e.visibleColumns.length;return{selectedCellCount:r*i,selectedRowCount:r,selectedColumnCount:i}}let r=Math.min(n.startCol,n.endCol),i=Math.max(n.startCol,n.endCol)-r+1,a=t;return{selectedCellCount:a*i,selectedRowCount:a,selectedColumnCount:i}},bn=(e,t)=>{let n=yn(e,t);return`Cells: ${n.selectedCellCount} / Rows: ${n.selectedRowCount}`},xn=e=>Object.values(e).filter(e=>tt(e)).length,Sn=e=>{let t=e.globalFilterText.trim().length>0,n=t?mn(e.globalFilterText.trim()):null,r=xn(e.columnFilterValues);return!t&&r===0?`Filter: なし`:t&&r===0?`Filter: Global("${n}")`:!t&&r>0?`Filter: ${r}列`:`Filter: Global("${n}") + ${r}列`},Cn=(e,t)=>{let n=e.find(e=>e.key===t);return n?.title||n?.key||t},wn=e=>e.sortState.length===0?`Sort: なし`:`Sort: ${e.sortState.map(t=>`${Cn(e.columns,t.columnKey)} (${t.direction===`asc`?`昇順`:`降順`})`).join(`, `)}`,Tn=(e,t)=>{let n=yn(e,t),r=e.globalFilterText.trim().length>0,i=r?mn(e.globalFilterText.trim()):null,a=xn(e.columnFilterValues),o=r||a>0,s=e.sortState.length>0,c=s?Cn(e.columns,e.sortState[0].columnKey):null;return{rowSummaryText:_n(e,t),columnSummaryText:vn(e),filterSummaryText:Sn(e),sortSummaryText:wn(e),activeCellLabel:hn(e.activeCell),selectionLabel:gn(e.selection),selectionStatsText:bn(e,t),selectionStats:n,hasGlobalFilter:r,globalFilterPreview:i,activeColumnFilterCount:a,hasAnyFilter:o,hasSorting:s,sortedColumnLabel:c}},En=({rows:t,viewRowCount:n,getFilteredRows:r,columns:i,visibleColumns:a,uiState:o,setGlobalFilterText:s,globalFilterStatus:c,globalFilterProgress:l})=>{let u=ue(o),d=o.filters.columnFilters,f=o.sort,p=o.activeCell,m=o.selection,h=(0,e.useMemo)(()=>({rows:t,columns:i,visibleColumns:a,globalFilterText:u,columnFilterValues:d,sortState:f,activeCell:p,selection:m}),[t,i,a,u,d,f,p,m]),g=(0,e.useMemo)(()=>Tn(h,n),[h,n]);return{slotContextBase:h,derivedSummary:g,slotContext:(0,e.useMemo)(()=>({...h,get filteredRows(){return r()},setGlobalFilterText:s,derivedSummary:g,globalFilterStatus:c,globalFilterProgress:l}),[g,r,s,h,c,l])}},Dn=({uiState:t,rows:n,visibleColumns:r,rowModel:i,setEditorInitialValue:s,onRowsChange:c,applyServerSideCellEdits:l,dispatch:u,gridRootRef:d,editorActionGuardRef:f})=>{let p=(0,e.useRef)({rowCount:0,colCount:0});(0,e.useEffect)(()=>{p.current={rowCount:i.getRowCount(),colCount:r.length}});let m=(0,e.useCallback)(e=>{u(a.startSelection(e)),u(a.endSelection()),u(a.activateCell(e))},[u]);return{activateSingleCell:m,startEditWithValue:(0,e.useCallback)((e,t)=>{s(t),u(a.startEdit(e))},[u,s]),commitEdit:(0,e.useCallback)((e,s)=>{if(f.current||!t.editingCell)return{status:`noop`};let h=t.editingCell,g=s===`down`?{row:h.row+1,col:h.col}:s===`up`?{row:h.row-1,col:h.col}:s===`right`?{row:h.row,col:h.col+1}:s===`left`?{row:h.row,col:h.col-1}:h,_=r[h.col],v=i.getSourceIndex(h.row),y=l?i.getRow(h.row):n[v];if(!_||!y)return u(a.stopEdit()),{status:`noop`};if(l){let t=Ve(_,e,y),n=an(_,y,t);if(n.action===`reject`)return{status:`rejected`,message:n.message};l([{viewIndex:h.row,column:_,value:t}])}else if(c){let t=Ve(_,e,y),r=an(_,y,t);if(r.action===`reject`)return{status:`rejected`,message:r.message};c(He(n,v,_,t))}return f.current=!0,requestAnimationFrame(()=>{d.current?.focus();let{rowCount:e,colCount:t}=p.current;m({row:o(g.row,0,Math.max(e-1,0)),col:o(g.col,0,Math.max(t-1,0))}),f.current=!1}),u(a.stopEdit()),{status:`committed`}},[m,l,u,f,i,d,c,n,t.editingCell,r]),cancelEdit:(0,e.useCallback)(()=>{f.current||(f.current=!0,u(a.stopEdit()),requestAnimationFrame(()=>{d.current?.focus(),f.current=!1}))},[u,f,d])}},On=()=>({past:[],future:[]}),kn=e=>e.past.length>0,An=e=>e.future.length>0,jn=(e,t,n)=>{if(n<=0)return e;let r=[...e.past,t];return{past:r.length>n?r.slice(r.length-n):r,future:[]}},Mn=(e,t)=>{if(e.past.length===0)return null;let n=e.past[e.past.length-1];return{stack:{past:e.past.slice(0,-1),future:[...e.future,t]},snapshot:n}},Nn=(e,t)=>{if(e.future.length===0)return null;let n=e.future[e.future.length-1];return{stack:{past:[...e.past,t],future:e.future.slice(0,-1)},snapshot:n}},Pn=({rows:t,selection:n,activeCell:r,onRowsChange:i,dispatch:o,enabled:s,limit:c,onUndoRedoStateChange:l,onAfterRestore:u})=>{let d=(0,e.useRef)(On()),f=(0,e.useRef)(null),p=(0,e.useRef)(t),m=(0,e.useRef)({canUndo:!1,canRedo:!1}),h=(0,e.useCallback)(()=>{let e={canUndo:s&&i!=null&&kn(d.current),canRedo:s&&i!=null&&An(d.current)};e.canUndo===m.current.canUndo&&e.canRedo===m.current.canRedo||(m.current=e,l?.(e))},[s,i,l]);(0,e.useEffect)(()=>{h()},[h]),(0,e.useEffect)(()=>{if(t!==p.current){if(p.current=t,f.current===t){f.current=null;return}f.current=null,d.current=On(),h()}},[t,h]);let g=(0,e.useCallback)(e=>{let t=e.selection;t?.type===`cell`?(o(a.startSelection(t.range.start)),o(a.updateSelection(t.range.end)),o(a.endSelection())):t?.type===`row`?(o(a.startRowSelection(t.startRow)),o(a.updateRowSelection(t.endRow)),o(a.endSelection())):t?.type===`col`?(o(a.startColumnSelection(t.startCol)),o(a.updateColumnSelection(t.endCol)),o(a.endSelection())):o(a.clearSelection()),o(a.activateCell(e.activeCell))},[o]);return{handleRowsChange:(0,e.useMemo)(()=>{if(i)return e=>{s&&(d.current=jn(d.current,{rows:t,selection:n,activeCell:r},c),f.current=e,h()),i(e)}},[r,s,c,h,i,t,n]),undo:(0,e.useCallback)(()=>{if(!s||!i)return;let e=Mn(d.current,{rows:t,selection:n,activeCell:r});e&&(d.current=e.stack,f.current=e.snapshot.rows,i(e.snapshot.rows),g(e.snapshot),u?.(e.snapshot.activeCell),h())},[r,s,h,u,i,g,t,n]),redo:(0,e.useCallback)(()=>{if(!s||!i)return;let e=Nn(d.current,{rows:t,selection:n,activeCell:r});e&&(d.current=e.stack,f.current=e.snapshot.rows,i(e.snapshot.rows),g(e.snapshot),u?.(e.snapshot.activeCell),h())},[r,s,h,u,i,g,t,n]),canUndo:(0,e.useCallback)(()=>s&&i!=null&&kn(d.current),[s,i]),canRedo:(0,e.useCallback)(()=>s&&i!=null&&An(d.current),[s,i]),clearHistory:(0,e.useCallback)(()=>{d.current=On(),h()},[h])}},Fn=e=>e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey,In=e=>e instanceof HTMLElement?e.closest(`input, textarea, select, button, [contenteditable="true"]`)!==null:!1,Ln=({uiState:t,rowModel:n,visibleColumns:r,readOnly:i,canEditCell:s,setEditorInitialValue:c,dispatch:l,handleCopy:u,handleCellDoubleClick:d,isWholeGridSelected:f,selectEntireGrid:p,onUndo:m,onRedo:h,onClearSelection:g,enableClearOnDelete:_,onToggleCheckboxCell:v,onToggleGroup:y})=>{let b=n.getRowCount(),x=(0,e.useCallback)((e,n,i)=>{if(b===0||r.length===0)return;let s=t.activeCell??{row:0,col:0},c={row:o(s.row+e,0,b-1),col:o(s.col+n,0,r.length-1)};if(i){let e=t.selection?.type===`cell`?t.selection.range.start:s;l(a.startSelection(e)),l(a.updateSelection(c)),l(a.endSelection()),l(a.activateCell(c));return}l(a.startSelection(c)),l(a.endSelection()),l(a.activateCell(c))},[l,b,t.activeCell,t.selection,r.length]);return{handleKeyDown:(0,e.useCallback)(async e=>{if(!In(e.target)&&!t.editingCell){if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`c`){e.preventDefault(),await u();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`){if(e.preventDefault(),f){l(a.clearSelection()),l(a.activateCell(null));return}p();return}if((e.ctrlKey||e.metaKey)&&!e.nativeEvent.isComposing){if(e.key.toLowerCase()===`z`){e.preventDefault(),e.shiftKey?h():m();return}if(e.key.toLowerCase()===`y`&&!e.shiftKey){e.preventDefault(),h();return}}if(e.key===`ArrowUp`){e.preventDefault(),x(-1,0,e.shiftKey);return}if(e.key===`ArrowDown`){e.preventDefault(),x(1,0,e.shiftKey);return}if(e.key===`ArrowLeft`){e.preventDefault(),x(0,-1,e.shiftKey);return}if(e.key===`ArrowRight`){e.preventDefault(),x(0,1,e.shiftKey);return}if(e.key===`Tab`){e.preventDefault(),x(0,e.shiftKey?-1:1,!1);return}if(e.key===`Escape`){e.preventDefault(),l(a.clearSelection());return}if((e.key===`Delete`||e.key===`Backspace`)&&_){e.preventDefault(),g();return}if((e.key===`Enter`||e.key===` `)&&t.activeCell){let r=n.getGroupRow?.(t.activeCell.row);if(r){e.preventDefault(),y(r.groupKey);return}}if(e.key===`Enter`||e.key===`F2`){e.preventDefault(),t.activeCell&&d(t.activeCell);return}if(Fn(e)&&t.activeCell){let o=n.getRow(t.activeCell.row),u=r[t.activeCell.col];if(!o||!u||!Ae({readOnly:i,canEditCell:s},t.activeCell.row,t.activeCell.col,o,u))return;if(u.editor?.type===`checkbox`){e.preventDefault(),e.key===` `&&v(t.activeCell);return}e.preventDefault(),c(e.key),l(a.startEdit(t.activeCell))}}},[s,l,n,d,u,f,x,g,_,h,v,y,m,i,p,c,t.activeCell,t.editingCell,r])}},Rn=new Intl.Collator(`ja`,{numeric:!0,sensitivity:`base`}),G=(e,t)=>{let n=Number(e),r=Number(t);return Number.isFinite(n)&&Number.isFinite(r)?n-r:Rn.compare(String(e??``),String(t??``))},zn=(e,t,n,r)=>{if(!r)return e.length===1&&e[0].columnKey===t&&e[0].direction===n?[]:[{columnKey:t,direction:n}];let i=e.findIndex(e=>e.columnKey===t);return i===-1?[...e,{columnKey:t,direction:n}]:e[i].direction===n?e.filter((e,t)=>t!==i):e.map((e,r)=>r===i?{columnKey:t,direction:n}:e)},Bn=(e,t,n)=>e.some(e=>e.columnKey===t)?e:[...e,{columnKey:t,direction:n}],Vn=(e,t,n)=>t<0||t>=e.length||e[t].direction===n?e:e.map((e,r)=>r===t?{...e,direction:n}:e),Hn=(e,t,n)=>t<0||t>=e.length||e[t].columnKey===n?e:e.map((e,r)=>r===t?{...e,columnKey:n}:e).filter((e,r)=>r===t||e.columnKey!==n),Un=(e,t)=>t<0||t>=e.length?e:e.filter((e,n)=>n!==t),Wn=(e,t,n)=>{if(t<0||t>=e.length||n<0||n>=e.length||t===n)return e;let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r},Gn=(e,t,n,r)=>{if(r.length===0)return t;let i=r.map(e=>{let t=n.find(t=>t.key===e.columnKey);return t?{column:t,multiplier:e.direction===`asc`?1:-1}:null}).filter(e=>e!==null);if(i.length===0)return t;let a=t.length,o=i.length,s=i.map(e=>e.multiplier),c=Array(o),l=!0;for(let n=0;n<o;n+=1){let r=i[n].column,o=new Float64Array(a),s=!0;for(let n=0;n<a;n+=1){let i=Number(L(e[t[n]],r));if(!Number.isFinite(i)){s=!1;break}o[n]=i}if(!s){l=!1;break}c[n]=o}let u=Array(a);for(let e=0;e<a;e+=1)u[e]=e;if(l)if(o===1){let e=c[0],n=s[0];u.sort((r,i)=>{let a=e[r]-e[i];return a===0?t[r]-t[i]:a*n})}else u.sort((e,n)=>{for(let t=0;t<o;t+=1){let r=c[t][e]-c[t][n];if(r!==0)return r*s[t]}return t[e]-t[n]});else{let n=i.map(({column:n})=>{let r=Array(a);for(let i=0;i<a;i+=1)r[i]=L(e[t[i]],n);return r});u.sort((e,r)=>{for(let t=0;t<o;t+=1){let i=G(n[t][e],n[t][r]);if(i!==0)return i*s[t]}return t[e]-t[r]})}let d=new Int32Array(a);for(let e=0;e<a;e+=1)d[e]=t[u[e]];return d},Kn=[`sum`,`min`,`max`,`avg`,`count`],qn=e=>typeof e==`string`&&Kn.includes(e),Jn=()=>({count:0,numericCount:0,sum:0,min:1/0,max:-1/0}),Yn=(e,t)=>{if(e.count+=1,t==null||t===``)return;let n=Number(t);Number.isFinite(n)&&(e.numericCount+=1,e.sum+=n,n<e.min&&(e.min=n),n>e.max&&(e.max=n))},Xn=(e,t)=>{switch(e){case`count`:return t.count;case`sum`:return t.numericCount>0?t.sum:void 0;case`avg`:return t.numericCount>0?t.sum/t.numericCount:void 0;case`min`:return t.numericCount>0?t.min:void 0;case`max`:return t.numericCount>0?t.max:void 0}},Zn=`(空白)`,Qn=`__ssg-group__:`,$n=`__ssg_group__`,er=e=>Qn+e.groupKey,tr=e=>e<0,nr=e=>-e-1,rr=e=>{if(e==null||e===``)return`e`;let t=typeof e;return`${t===`number`?`n`:t===`boolean`?`b`:t===`string`?`s`:`o`}:${String(e)}`},ir=e=>({groupColumns:e.filter(e=>e.rowGroup===!0),aggColumns:e.filter(e=>e.aggFunc!=null)}),ar=(e,t,n,r)=>{let i=n.length,a=r.length,o=r.map(e=>typeof e.aggFunc==`function`),s=o.includes(!0),c=[],l=new Map,u=0,d=(e,t,n,i,a)=>{let s=`${t.key}\u0001${n}`,c=n===`e`;return u+=1,{groupRow:{kind:`group`,groupKey:e===null?s:`${e}\u0000${s}`,columnKey:t.key,value:c?null:i,label:c?Zn:String(i),level:a,leafCount:0,aggregates:{}},children:[],childIndex:new Map,leafSourceIndexes:[],accumulators:r.map(()=>Jn()),customValues:o.map(e=>e?[]:null),customRows:[]}},f=t.length;for(let o=0;o<f;o+=1){let u=t[o],f=e[u],p=null;if(a>0){p=Array(a);for(let e=0;e<a;e+=1)p[e]=L(f,r[e])}let m=c,h=l,g=null;for(let e=0;e<i;e+=1){let t=n[e],r=L(f,t),o=rr(r),c=h.get(o);if(c||(c=d(g,t,o,r,e),m.push(c),h.set(o,c)),c.groupRow.leafCount+=1,p!==null){for(let e=0;e<a;e+=1){Yn(c.accumulators[e],p[e]);let t=c.customValues[e];t!==null&&t.push(p[e])}s&&c.customRows.push(f)}e===i-1&&c.leafSourceIndexes.push(u),m=c.children,h=c.childIndex,g=c.groupRow.groupKey}}let p=e=>{for(let t=0;t<a;t+=1){let n=r[t];o[t]?e.groupRow.aggregates[n.key]=n.aggFunc({values:e.customValues[t]??[],rows:e.customRows,column:n}):qn(n.aggFunc)&&(e.groupRow.aggregates[n.key]=Xn(n.aggFunc,e.accumulators[t]))}for(let t of e.children)p(t)};for(let e of c)p(e);return{roots:c,groupCount:u}},or=(e,t)=>{let n=[],r=[],i=e=>{if(r.push(e.groupRow),n.push(-r.length),!t.has(e.groupRow.groupKey)){if(e.children.length>0){for(let t of e.children)i(t);return}for(let t of e.leafSourceIndexes)n.push(t)}};for(let t of e.roots)i(t);return{displayOrder:Int32Array.from(n),groups:r}},sr=e=>{let t=[],n=e=>{t.push(e.groupRow);for(let t of e.children)n(t)};for(let t of e.roots)n(t);return t},cr=e=>sr(e).map(e=>e.groupKey),lr=15e6,ur=(e,t,n,r)=>e&&t&&n>0&&n<=r,dr=1<<20,fr=(e,t)=>({rowCount:e,rowTop:e=>e*t,rowsHeight:(e,n)=>(n-e+1)*t,totalBodyHeight:e*t,rowAtContentY:n=>Math.min(Math.max(Math.floor(n/t),0),Math.max(e-1,0))}),pr=(e,t,n,r)=>{if(r<n)return null;let i=Math.max(e,n),a=Math.min(t,r);return i>a?null:{start:i,end:a}},mr=(e,t)=>e*t,hr=(e,t)=>t===1?e:e/t,gr=(e,t,n,r)=>{let i=t*(1-n);return r.rowAtContentY(e-i)},_r=({rowCount:e,rowHeight:t,headerHeight:n,viewportHeight:r,scrollTop:i,overscan:a,maxBodyPx:o})=>{let s=e*t,c=Math.min(s,o),l=Math.max(n+s-r,0),u=Math.max(n+c-r,0),d=u>0&&s>c?l/u:1,f=Math.min(Math.max(i,0),u),p=f*d,m=Math.ceil(r/t)+1,h=Math.floor(p/t),g=Math.max(h-a,0),_=Math.min(h+m+a,e),v=d===1?0:Math.floor(g*t/dr)*dr,y=f-p+v,b=[],x=new Set;for(let e=g;e<_;e+=1)b.push({index:e,start:n+e*t-v}),x.add(e);return{physicalBodyHeight:c,logicalBodyHeight:s,scaleFactor:d,translateY:y,windowBaseOffsetPx:v,rows:b,rowIndexSet:x}},vr=({headerHeight:e,viewportHeight:t,scrollTop:n,overscan:r},i)=>{let a=i.rowCount,o=i.totalBodyHeight,s=o,c=Math.max(e+o-t,0),l=Math.min(Math.max(n,0),c),u=i.rowAtContentY(l),d=i.rowAtContentY(l+t),f=Math.max(u-r,0),p=Math.min(d+r+1,a),m=[],h=new Set;for(let t=f;t<p;t+=1)m.push({index:t,start:e+i.rowTop(t),size:i.rowsHeight(t,t)}),h.add(t);return{physicalBodyHeight:s,logicalBodyHeight:o,scaleFactor:1,translateY:0,windowBaseOffsetPx:0,rows:m,rowIndexSet:h}},yr=({rectLeft:e,rectTop:t,clientLeft:n,clientTop:r,clientWidth:i,clientHeight:a})=>{let o=e+n,s=t+r;return{left:o,top:s,right:o+i,bottom:s+a}},K=(e,t,n,r)=>e<t+r?-1:+(e>n-r),br=(e,t,n,r)=>{if(t===0)return e;let i=Math.max(r,0),a=e+t*n;return a<0?0:a>i?i:a},xr=(e,t,n)=>{let r=t.x-e.x,i=t.y-e.y;return r*r+i*i>=n*n},Sr=({gridRootRef:t,bodyScrollRef:n,scrollContainerRef:r,leftPaneScrollRef:i,rightPaneScrollRef:s,pointerClientRef:c,autoScrollFrameRef:l,uiState:u,dispatch:d,enableRangeSelection:f,enableSorting:p,orderedColumns:m,filteredRowsLength:h,visibleColumnsLength:g,paneLayout:v,leftLeadingWidth:y,centerLeadingWidth:b,rightLeadingWidth:x,headerHeight:S,rowMetrics:C,verticalScaleFactor:w,setHoveredRowIndex:T,setHoveredColumnIndex:E,enableRowHover:D,enableColumnHeaderHover:O,enableRowSelection:k,onGutterRowSelect:A,onGutterRowSelectDrag:j})=>{let M=(0,e.useRef)(u.dragState);M.current=u.dragState;let ee=(0,e.useRef)(!1),N=(0,e.useRef)(null),P=(0,e.useRef)(null),F=(0,e.useRef)(!1),I=(0,e.useRef)(u.sort);I.current=u.sort;let te=(0,e.useRef)(m);te.current=m;let ne=(0,e.useRef)(p);ne.current=p;let re=u.dragState?.type??null,ie=(0,e.useCallback)((e,t)=>{let a=n.current;if(!a||h===0||g===0)return null;let c=a.getBoundingClientRect(),l=gr(a.scrollTop+t-c.top-S,r.current?.scrollTop??0,w,C),u=null,d=i.current;if(u===null&&d&&v.left.entries.length>0){let t=d.getBoundingClientRect();if(e<t.right){let n=e-t.left-y;u=_(v.left,n)}}let f=s.current;if(u===null&&f&&v.right.entries.length>0){let t=f.getBoundingClientRect();if(e>=t.left){let n=e-t.left-x;u=_(v.right,n)}}if(u===null&&v.center.entries.length>0){let t=a.scrollLeft+e-c.left-b;u=_(v.center,Math.max(t,0))}return u===null?null:{row:l,col:o(u,0,g-1)}},[n,i,s,r,h,g,v,y,b,x,S,C,w]),ae=(0,e.useRef)(ie);(0,e.useEffect)(()=>{ae.current=ie},[ie]);let oe=(0,e.useCallback)((e,t)=>{let n=M.current;if(!n||n.type!==`selection`)return;let r=ie(e,t);if(r){if(n.selectionKind===`cell`){d(a.updateSelection(r));return}if(n.selectionKind===`row`){d(a.updateRowSelection(r.row));return}n.selectionKind===`col`&&d(a.updateColumnSelection(r.col))}},[d,ie]);(0,e.useEffect)(()=>{let e=e=>{c.current={x:e.clientX,y:e.clientY},re===`columnResize`&&d(a.updateColumnResize(e.clientX))},t=()=>{ee.current=!1,d(a.endSelection()),d(a.endColumnResize())};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[d,c,re]),(0,e.useEffect)(()=>{if(re!==`selection`){l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);return}let e=()=>{let t=r.current,n=c.current;if(!t||!n){l.current=requestAnimationFrame(e);return}if(!F.current){let t=P.current;if(t&&!xr(t,n,6)){l.current=requestAnimationFrame(e);return}F.current=!0}let i=t.getBoundingClientRect(),a=yr({rectLeft:i.left,rectTop:i.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight}),o=M.current?.type===`selection`&&M.current.selectionKind===`col`,s=M.current?.type===`selection`&&M.current.selectionKind===`row`,u=o?0:K(n.y,a.top,a.bottom,24),d=s?0:K(n.x,a.left,a.right,24),f=br(t.scrollTop,u,18,t.scrollHeight-t.clientHeight),p=br(t.scrollLeft,d,18,t.scrollWidth-t.clientWidth);(f!==t.scrollTop||p!==t.scrollLeft)&&(t.scrollTo({top:f,left:p,behavior:`auto`}),oe(n.x,n.y)),l.current=requestAnimationFrame(e)};return l.current=requestAnimationFrame(e),()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[l,r,c,re,oe]);let se=(0,e.useCallback)((e,n)=>{n.preventDefault(),n.button===0&&(t.current?.focus(),c.current={x:n.clientX,y:n.clientY},P.current={x:n.clientX,y:n.clientY},F.current=!1,d(a.activateCell(e)),f&&d(a.startSelection(e)))},[d,f,t,c]),ce=(0,e.useCallback)((e,t)=>{if(D&&T(e.row),!f)return;let n=M.current;n?.type!==`selection`||n.selectionKind!==`cell`||(c.current={x:t.clientX,y:t.clientY},d(a.updateSelection(e)))},[d,f,c,T,D]),le=(0,e.useCallback)(e=>{e.preventDefault()},[]),ue=(0,e.useCallback)(()=>{if(N.current!==null)return;let e=()=>{if(!ee.current){N.current=null;return}let t=r.current,n=c.current;if(!t||!n){N.current=requestAnimationFrame(e);return}if(!F.current){let t=P.current;if(t&&!xr(t,n,6)){N.current=requestAnimationFrame(e);return}F.current=!0}let i=t.getBoundingClientRect(),a=yr({rectLeft:i.left,rectTop:i.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight}),o=K(n.y,a.top,a.bottom,24),s=br(t.scrollTop,o,18,t.scrollHeight-t.clientHeight);if(s!==t.scrollTop){t.scrollTo({top:s,left:t.scrollLeft,behavior:`auto`});let e=ae.current(n.x,n.y);e&&j(e.row)}N.current=requestAnimationFrame(e)};N.current=requestAnimationFrame(e)},[r,c,j]);return(0,e.useEffect)(()=>()=>{N.current!==null&&(cancelAnimationFrame(N.current),N.current=null)},[]),{updateSelectionFromPointer:oe,handleCellPointerDown:se,handleCellPointerEnter:ce,handleNativeDragStart:le,handleRowHeaderPointerDown:(0,e.useCallback)((e,n)=>{if(n.preventDefault(),n.button===0){if(t.current?.focus(),c.current={x:n.clientX,y:n.clientY},P.current={x:n.clientX,y:n.clientY},F.current=!1,k){ee.current=!0,A(e,{shiftKey:n.shiftKey}),ue();return}d(a.startRowSelection(e))}},[d,t,k,A,ue,c]),handleRowHeaderPointerEnter:(0,e.useCallback)((e,t)=>{if(D&&T(e),ee.current){c.current={x:t.clientX,y:t.clientY},j(e);return}let n=M.current;n?.type!==`selection`||n.selectionKind!==`row`||(c.current={x:t.clientX,y:t.clientY},d(a.updateRowSelection(e)))},[d,c,T,D,j]),handleColumnHeaderPointerDown:(0,e.useCallback)((e,n)=>{if(n.preventDefault(),n.button===0){if(t.current?.focus(),c.current={x:n.clientX,y:n.clientY},P.current={x:n.clientX,y:n.clientY},F.current=!1,n.shiftKey&&ne.current){let t=te.current[e];if(t&&t.key!==`__ssg_group__`){let e=I.current,n=e.find(e=>e.columnKey===t.key)?.direction?`desc`:`asc`,r=zn(e,t.key,n,!0);d(r.length===0?a.clearSort():a.setSort(r))}return}d(a.startColumnSelection(e))}},[d,t,c]),handleColumnHeaderPointerEnter:(0,e.useCallback)((e,t)=>{T(null),O&&E(e);let n=M.current;n?.type!==`selection`||n.selectionKind!==`col`||(c.current={x:t.clientX,y:t.clientY},d(a.updateColumnSelection(e)))},[d,c,T,E,O])}},Cr=({scrollRef:t,columnVirtualizer:n,columnMeasurements:r,totalScrollWidth:i,physicalBodyHeight:a,headerHeight:o,leftPaneWidth:s,rightPaneWidth:c,centerLeadingWidth:l,activeCellRect:u,activeCell:d,verticalScaleFactor:f})=>{(0,e.useEffect)(()=>{n.measure()},[n,r]),(0,e.useEffect)(()=>{if(!t.current)return;let e=t.current,n=Math.max(i-e.clientWidth,0),r=Math.max(o+a-e.clientHeight,0);e.scrollLeft>n&&(e.scrollLeft=n),e.scrollTop>r&&(e.scrollTop=r)},[t,i,a,o]);let p=(0,e.useRef)(null);(0,e.useEffect)(()=>{let e=p.current,n=e!==null&&d!==null&&e.row===d.row&&e.col===d.col;if(p.current=d,n||!t.current||!u)return;let r=t.current,i=o+u.top,a=i+u.height,m=s+l+u.left,h=m+u.width,g=mr(r.scrollTop,f),_=r.scrollLeft,v=r.clientHeight,y=r.clientWidth,b=g,x=_,S=g+o,C=g+v;i<S?b=Math.max(i-o,0):a>C&&(b=Math.max(a-v,0));let w=_+s,T=_+y-c;m<w?x=Math.max(m-s,0):h>T&&(x=Math.max(h-y+c,0)),(b!==g||x!==_)&&r.scrollTo({top:hr(b,f),left:x,behavior:`auto`})},[t,u,d,o,s,c,l,f])};function wr(e){let{targetRect:t,tipWidth:n,tipHeight:r,viewportWidth:i}=e,a=t.left+t.width/2,o=Math.max(8,Math.min(Math.round(a-n/2),i-n-8)),s=Math.round(t.top-r-7);return s<8?{top:Math.round(t.bottom+7),left:o,below:!0}:{top:s,left:o,below:!1}}var Tr=`data-ssg-tooltip`,Er=`[${Tr}], [data-ssg-tooltip-overflow]`,q=350,J=800,Dr=0,Or=null,kr=null,Ar=0,jr=null;function Mr(){if(Or!==null)return Or;let e=document.createElement(`div`);return e.className=`ssg-tooltip`,e.setAttribute(`aria-hidden`,`true`),document.body.appendChild(e),Or=e,e}function Nr(){kr!==null&&(window.clearTimeout(kr),kr=null)}function Pr(){Nr(),jr!==null&&(Ar=Date.now()+J),jr=null,Or!==null&&Or.classList.remove(`ssg-tooltip--visible`)}function Fr(e){let t=e.getAttribute(Tr),n=t!==null&&t!==``?t:(e.textContent??``).trim();if(n===``)return;let r=Mr();r.classList.toggle(`ssg-theme-dark`,e.closest(`.ssg-theme-dark`)!==null),r.textContent=n,r.style.left=`0px`,r.style.top=`0px`;let i=wr({targetRect:e.getBoundingClientRect(),tipWidth:r.offsetWidth,tipHeight:r.offsetHeight,viewportWidth:window.innerWidth});r.style.left=`${i.left}px`,r.style.top=`${i.top}px`,r.classList.add(`ssg-tooltip--visible`),jr=e}function Ir(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(Er);if(n===null||n===jr||!n.hasAttribute(Tr)&&n.scrollWidth<=n.clientWidth+1)return;let r=jr!==null;Pr(),r||Date.now()<Ar?Fr(n):kr=window.setTimeout(()=>{kr=null,Fr(n)},q)}function Lr(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(Er);if(n===null)return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||Pr()}function Rr(){Pr()}function zr(e){e.key===`Escape`&&Pr()}function Y(){window.addEventListener(`pointerover`,Ir,!0),window.addEventListener(`pointerout`,Lr,!0),window.addEventListener(`focusin`,Ir,!0),window.addEventListener(`focusout`,Lr,!0),window.addEventListener(`pointerdown`,Rr,!0),window.addEventListener(`scroll`,Rr,!0),window.addEventListener(`keydown`,zr,!0)}function Br(){window.removeEventListener(`pointerover`,Ir,!0),window.removeEventListener(`pointerout`,Lr,!0),window.removeEventListener(`focusin`,Ir,!0),window.removeEventListener(`focusout`,Lr,!0),window.removeEventListener(`pointerdown`,Rr,!0),window.removeEventListener(`scroll`,Rr,!0),window.removeEventListener(`keydown`,zr,!0)}function Vr(){(0,e.useEffect)(()=>(Dr+=1,Dr===1&&Y(),()=>{--Dr,Dr===0&&(Br(),Nr(),jr=null,Or!==null&&(Or.remove(),Or=null))}),[])}var Hr=`(prefers-color-scheme: dark)`;function Ur(e){if(typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(Hr);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}}function Wr(){return typeof window.matchMedia==`function`?window.matchMedia(Hr).matches:!1}function Gr(){return!1}function Kr(t){let n=(0,e.useSyncExternalStore)(Ur,Wr,Gr);return t===`dark`||t===`auto`&&n?`dark`:`light`}function qr(e,t,n,r){let i=e.find(e=>e.key===t);if(!i)return null;let a=c(i),o={left:[],center:[],right:[]},s=new Map;for(let t of e)o[c(t)].push(t.key),s.set(t.key,t.visible!==!1);let l=o[n].filter(e=>s.get(e)).indexOf(t),u=o[a].indexOf(t);if(u<0)return null;o[a].splice(u,1);let d=r;a===n&&l>=0&&d>l&&--d;let f=o[n].filter(e=>s.get(e));if(d=Math.max(0,Math.min(d,f.length)),a===n&&l>=0&&d===l)return null;let p;return p=d>=f.length?o[n].length:o[n].indexOf(f[d]),o[n].splice(p,0,t),[...o.left,...o.center,...o.right]}var Jr=32,Yr=2,Xr=14,Zr=12,Qr=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,$r=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/></svg>`,ei=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,ti=`0.5`,ni=200,ri=`cubic-bezier(0.2, 0.7, 0.3, 1)`,ii=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,ai=e=>{if(!e)return null;let t=new Map;return e.querySelectorAll(`[data-ssg-col-key]`).forEach(e=>{let n=e.dataset.ssgColKey;n&&!t.has(n)&&t.set(n,e.getBoundingClientRect().left)}),t},oi=t=>{let n=(0,e.useRef)(t);n.current=t;let r=(0,e.useRef)(null),i=(0,e.useRef)(null),a=(0,e.useRef)(null),o=(0,e.useRef)(null),s=(0,e.useRef)(null),l=(0,e.useRef)(null),u=(0,e.useRef)({x:0,y:0}),d=(0,e.useRef)(null),f=(0,e.useRef)(!1),p=(0,e.useRef)(null),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useRef)(null),_=(0,e.useRef)(null),b=(0,e.useCallback)(()=>{for(let e of[r,i,a])e.current&&(e.current.style.display=`none`)},[]),x=(0,e.useCallback)(e=>{if(h.current)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),n.current.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`);let r=document.createElement(`span`);r.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let i=document.createElement(`span`);i.textContent=e,t.appendChild(r),t.appendChild(i),document.body.appendChild(t),h.current=t,g.current=r,_.current=null},[]),S=(0,e.useCallback)(e=>{let t=h.current;if(!t)return;let{x:n,y:r}=u.current;t.style.transform=`translate(`+(n+Xr)+`px,`+(r+Zr)+`px)`;let i=e??`out`;if(_.current===i)return;_.current=i;let a=g.current;i===`out`?(t.style.opacity=ti,a&&(a.innerHTML=ei)):(t.style.opacity=`1`,a&&(a.innerHTML=i===`center`?Qr:$r))},[]),C=(0,e.useCallback)(()=>{let e=h.current;e&&e.parentNode&&e.parentNode.removeChild(e),h.current=null,g.current=null,_.current=null},[]),w=(0,e.useCallback)((e,t)=>{let{paneLayout:r,leftPaneScrollRef:i,rightPaneScrollRef:a,bodyScrollRef:o,scrollContainerRef:s,leftLeadingWidth:c,centerLeadingWidth:l,rightLeadingWidth:u}=n.current,d=s.current;if(d){let n=d.getBoundingClientRect();if(e<n.left||e>n.right||t<n.top||t>n.bottom)return null}let f=i.current,p=a.current;if(f&&r.left.entries.length===0&&e<=f.getBoundingClientRect().left+Jr)return{pane:`left`,slot:0,leftPx:Yr};if(f&&r.left.entries.length>0){let t=f.getBoundingClientRect();if(e<t.right){let n=e-t.left-c,i=v(r.left,n);return{pane:`left`,slot:i,leftPx:c+y(r.left,i)}}}if(p&&r.right.entries.length===0&&e>=p.getBoundingClientRect().left-Jr)return{pane:`right`,slot:0,leftPx:-2};if(p&&r.right.entries.length>0){let t=p.getBoundingClientRect();if(e>=t.left){let n=e-t.left-u,i=v(r.right,n);return{pane:`right`,slot:i,leftPx:u+y(r.right,i)}}}let m=o.current;if(m&&r.center.entries.length>0){let t=m.getBoundingClientRect(),n=m.scrollLeft+e-t.left-l,i=v(r.center,Math.max(n,0));return{pane:`center`,slot:i,leftPx:l+y(r.center,i)}}return null},[]),T=(0,e.useCallback)(()=>{let e=w(u.current.x,u.current.y);if(S(e?e.pane:null),!e){s.current=null,b();return}s.current={pane:e.pane,slot:e.slot};let t={left:r.current,center:i.current,right:a.current};for(let n of[`left`,`center`,`right`]){let r=t[n];r&&(n===e.pane?(r.style.left=`${e.leftPx}px`,r.style.display=`block`):r.style.display=`none`)}},[w,b,S]),E=(0,e.useRef)(()=>{});E.current=(0,e.useCallback)(()=>{if(o.current===null){m.current=null;return}let e=n.current.scrollContainerRef.current;if(e){let t=u.current;if(!f.current){let e=d.current;(!e||xr(e,t,6))&&(f.current=!0)}if(f.current){let n=e.getBoundingClientRect(),r=yr({rectLeft:n.left,rectTop:n.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=K(t.x,r.left,r.right,24),a=br(e.scrollLeft,i,18,e.scrollWidth-e.clientWidth);a!==e.scrollLeft&&e.scrollTo({left:a,behavior:`auto`})}}T(),m.current=requestAnimationFrame(E.current)},[T]);let D=(0,e.useCallback)(e=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),document.body.style.cursor=``,b(),C();let t=o.current,r=s.current;if(o.current=null,s.current=null,!e||!t||!r)return;let{columns:i,applyColumnOrderAndPin:a,scrollContainerRef:u}=n.current,d=qr(i,t,r.pane,r.slot);if(!d)return;let f=i.find(e=>e.key===t),p=f?c(f):null,h=p!==null&&p===r.pane;l.current=h&&!ii()?ai(u.current):null,a(d,new Map([[t,r.pane===`center`?void 0:r.pane]]))},[b,C]),O=(0,e.useCallback)(()=>{let e=l.current;if(l.current=null,!e)return;let t=n.current.scrollContainerRef.current;if(!t)return;let r=new Map,i=new Map;t.querySelectorAll(`[data-ssg-col-key]`).forEach(t=>{let n=t.dataset.ssgColKey;if(!n||!e.has(n))return;let a=r.get(n);a?a.push(t):(r.set(n,[t]),i.set(n,t.getBoundingClientRect().left))});let a=[];if(r.forEach((t,n)=>{let r=e.get(n),o=i.get(n);if(r===void 0||o===void 0)return;let s=r-o;if(!(Math.abs(s)<.5))for(let e of t)e.style.transition=`none`,e.style.transform=`translateX(${s}px)`,e.style.willChange=`transform`,a.push(e)}),a.length!==0){t.getBoundingClientRect();for(let e of a)e.style.transition=`transform ${ni}ms ${ri}`,e.style.transform=`translateX(0)`;window.setTimeout(()=>{for(let e of a)e.style.transition=``,e.style.transform=``,e.style.willChange=``},280)}},[]),k=(0,e.useCallback)((e,t)=>{if(!n.current.enabled||t.button!==0)return;t.stopPropagation(),t.preventDefault(),o.current=e.key,u.current={x:t.clientX,y:t.clientY},d.current={x:t.clientX,y:t.clientY},f.current=!1,document.body.style.cursor=`grabbing`,x(e.title||e.key);let r=t.currentTarget,i=t.pointerId;try{r.setPointerCapture(i)}catch{}let a=e=>{e.pointerId===i&&(u.current={x:e.clientX,y:e.clientY},T())};function s(e){e.pointerId===i&&(l(),D(!0))}function c(e){e.pointerId===i&&(l(),D(!1))}let l=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),p.current=null;try{r.releasePointerCapture(i)}catch{}};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),p.current=l,T(),m.current=requestAnimationFrame(E.current)},[T,D,x]);return(0,e.useEffect)(()=>()=>{p.current?.(),p.current=null,m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),document.body.style.cursor=``;let e=h.current;e&&e.parentNode&&e.parentNode.removeChild(e),h.current=null,g.current=null,_.current=null},[]),{onColumnDragHandlePointerDown:k,leftIndicatorRef:r,centerIndicatorRef:i,rightIndicatorRef:a,applyReorderSettle:O}},si=e=>e===``?`(空白)`:`"${e}"`,ci=(e,t)=>(e??`include`)===`exclude`?`${t.length} 件を除外`:t.length>0&&t.length<=2?t.map(si).join(`, `):`${t.length} 件を選択`,li=(e,t)=>{switch(e.kind){case`text`:case`date`:return`"${e.value.trim()}" を含む`;case`select`:return`"${e.value}" に一致`;case`number`:return e.raw;case`set`:return ci(e.mode,e.values);case`numberSet`:case`textSet`:case`dateSet`:{let n=e.condition?e.kind===`numberSet`?z(e.condition):e.kind===`textSet`?zt(e.condition):qt(e.condition,t):null,r=e.set?ci(e.set.mode,e.set.values):null;return n&&r?`${n} かつ ${r}`:n??r??`フィルターなし`}case`custom`:return typeof e.value==`string`&&e.value.trim().length>0?`"${e.value.trim()}"`:`カスタム条件`}},ui=/^\d{4}-\d{2}-\d{2}$/,di=e=>{let t=new Set;for(let n of e)t.add(ct(n.value));let n=[],r=[],i=!1;for(let e of t)e===``?i=!0:ui.test(e)?n.push(e):r.push(e);n.sort(),r.sort();let a=n.map(e=>({label:e,value:e}));for(let e of r)a.push({label:e,value:e});return i&&a.push({label:`(空白)`,value:``}),a},fi=(e,t)=>{let n=new Map,r=[];for(let t of e){if(!ui.test(t.value)){r.push(t);continue}let e=t.value.slice(0,4),i=t.value.slice(0,7),a=n.get(e);a||(a=new Map,n.set(e,a));let o=a.get(i);o||(o=[],a.set(i,o)),o.push(t.value)}let i=[];for(let[e,r]of n){let n=`y:${e}`,a=[];for(let e of r.values())a.push(...e);let o=t.has(n);if(i.push({type:`group`,key:n,label:`${e} 年`,depth:0,leafKeys:a,expanded:o}),o)for(let[e,n]of r){let r=`m:${e}`,a=t.has(r);if(i.push({type:`group`,key:r,label:`${Number(e.slice(5,7))} 月`,depth:1,leafKeys:[...n],expanded:a}),a)for(let e of n)i.push({type:`leaf`,key:e,label:`${Number(e.slice(8,10))} 日`,depth:2,leafKeys:[e],expanded:!1})}}for(let e of r)i.push({type:`leaf`,key:e.value,label:e.label,depth:0,leafKeys:[e.value],expanded:!1});return i},pi=1e3,mi=2e4,hi=e=>{if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`string`)return!1;let t=e.trim();return!t||/^-?0\d/.test(t)?!1:Number.isFinite(Number(t))},gi=e=>st(e)!==null,_i=({editorType:e,isServerSide:t=!1,rowCount:n,getRawValueAt:r,sampleLimit:i=pi,scanLimit:a=mi})=>{if(e===`number`)return{filterType:`numberSet`,source:`editor`,conclusive:!0};if(e===`date`)return{filterType:`dateSet`,source:`editor`,conclusive:!0};if(t)return{filterType:`text`,source:`fallback`,conclusive:!0};let o=Math.min(n,a),s=0,c=0,l=0;for(let e=0;e<o&&s<i;e+=1){let t=r(e);if(!et(t)){if(s+=1,gi(t)){c+=1;continue}hi(t)&&(l+=1)}}return s===0?{filterType:`textSet`,source:`fallback`,conclusive:!1}:c===s?{filterType:`dateSet`,source:`values`,conclusive:!0}:l===s?{filterType:`numberSet`,source:`values`,conclusive:!0}:{filterType:`textSet`,source:`values`,conclusive:!0}},vi=(e,t,n,r)=>{if(n===0||r===0)return null;let i=n-1,a=r-1;if(e?.type===`cell`){let t=se(e.range);return{startRow:o(t.start.row,0,i),endRow:o(t.end.row,0,i),startCol:o(t.start.col,0,a),endCol:o(t.end.col,0,a)}}if(e?.type===`row`){let t=ce(e.startRow,e.endRow);return{startRow:o(t.startRow,0,i),endRow:o(t.endRow,0,i),startCol:0,endCol:a}}if(e?.type===`col`){let t=le(e.startCol,e.endCol);return{startRow:0,endRow:i,startCol:o(t.startCol,0,a),endCol:o(t.endCol,0,a)}}return t?t.row>i||t.col>a?null:{startRow:t.row,endRow:t.row,startCol:t.col,endCol:t.col}:null},yi=({rows:e,resolveSourceIndex:t,columns:n,selection:r,activeCell:i,viewRowCount:a,canWriteCell:o})=>{let s=vi(r,i,a,n.length);if(!s)return{nextRows:e,changed:!1};let c=[...e],l=!1;for(let e=s.startRow;e<=s.endRow;e+=1){let r=t(e);if(r===void 0)continue;let i=c[r];if(!i)continue;let a=i,u=!1;for(let e=s.startCol;e<=s.endCol;e+=1){let t=n[e];if(!t||!o(r,e,i,t))continue;let s=Be(t)(``,i);Object.is(L(a,t),s)||an(t,i,s).action!==`reject`&&(a=je(a,t,s),u=!0)}u&&(c[r]=a,l=!0)}return l?{nextRows:c,changed:l}:{nextRows:e,changed:!1}},bi=({getRow:e,columns:t,selection:n,activeCell:r,viewRowCount:i,canWriteCell:a})=>{let o=vi(n,r,i,t.length);if(!o)return[];let s=[];for(let n=o.startRow;n<=o.endRow;n+=1){let r=e(n);if(r)for(let e=o.startCol;e<=o.endCol;e+=1){let i=t[e];if(!i||!a(n,e,r,i))continue;let o=Be(i)(``,r);Object.is(L(r,i),o)||an(i,r,o).action!==`reject`&&s.push({viewIndex:n,column:i,value:o})}}return s},xi=e=>{let{mode:t,isServerSide:n,rowCount:r,hasAutoSizedOnMount:i}=e;return t===!1||n||r===0?{shouldRun:!1,nextHasAutoSizedOnMount:i}:t===`onMount`?i?{shouldRun:!1,nextHasAutoSizedOnMount:!0}:{shouldRun:!0,nextHasAutoSizedOnMount:!0}:{shouldRun:!0,nextHasAutoSizedOnMount:i}},Si=(e,t,n)=>{let r=!1,i=e.map(e=>{let i=n[e.key]??e.width,a=t.get(e.key);if(!a)return i===e.width?e:{...e,width:i};let o=a.pinned??void 0,s=i!==a.width,c=(e.pinned??void 0)!==o,l=e.visible!==!1!=(a.visible!==!1);return(s||c||l)&&(r=!0),{...e,width:a.width,pinned:a.pinned,visible:a.visible}}),a=new Map(i.map(e=>[e.key,e])),o=[];for(let e of t.keys()){let t=a.get(e);t&&o.push(t)}let s=i.filter(e=>!t.has(e.key)),c=[...o,...s],l=c.some((t,n)=>e[n].key!==t.key);return!r&&!l?null:c},Ci=(e,t)=>e.includes(t)||e.includes(`"`)||e.includes(`
|
|
9
|
+
`)||e.includes(`\r`)?`"${e.replace(/"/g,`""`)}"`:e,wi=(e,t)=>{let n=L(e,t);return t.formatClipboardValue?t.formatClipboardValue(n,e):String(n??``)},Ti=({getRow:e,startRow:t,endRow:n,columns:r,delimiter:i=`,`,includeHeaders:a=!0,bom:o=!1})=>{let s=[];a&&s.push(r.map(e=>Ci(e.title??e.key,i)).join(i));for(let a=t;a<n;a+=1){let t=e(a);if(!t)continue;let n=r.map(e=>Ci(wi(t,e),i));s.push(n.join(i))}let c=s.join(`\r
|
|
10
|
+
`);return o?`\uFEFF${c}`:c},Ei=({getRow:e,startRow:t,endRow:n,columns:r})=>{let i=r.map(e=>({key:e.key,title:e.title??e.key})),a=[];for(let i=t;i<n;i+=1){let t=e(i);t&&a.push(r.map(e=>{let n=L(t,e);return{value:n,text:e.formatClipboardValue?e.formatClipboardValue(n,t):String(n??``)}}))}return{columns:i,rows:a}},Di=e=>e===`all`?`view`:e===`visible`?`rendered`:e,Oi=e=>{switch(e.kind){case`set`:return{...e,values:[...e.values]};case`number`:return{...e,parsed:e.parsed?{...e.parsed}:null};case`numberSet`:return{...e,condition:e.condition?{...e.condition}:null,set:e.set?{...e.set,values:[...e.set.values]}:null};case`textSet`:return{...e,condition:e.condition?{...e.condition}:null,set:e.set?{...e.set,values:[...e.set.values]}:null};case`dateSet`:return{...e,condition:e.condition?{...e.condition}:null,set:e.set?{...e.set,values:[...e.set.values]}:null};case`text`:case`date`:case`select`:return{...e};case`custom`:return{...e}}},ki=e=>{let t={};for(let n of Object.keys(e))t[n]=Oi(e[n]);return t},Ai=e=>{let t={key:e.key};return e.visible!==void 0&&(t.visible=e.visible),e.pinned!==void 0&&(t.pinned=e.pinned),t},ji=e=>e.map(e=>{let t={key:e.key};return e.visible!==void 0&&(t.visible=e.visible),e.pinned!==void 0&&(t.pinned=e.pinned),t}),Mi=(e,t,n,r=[],i=2)=>({version:i,columnWidths:{...e},filters:{globalText:t.globalText,columnFilters:ki(t.columnFilters)},sort:n.map(e=>({...e})),columns:r.map(Ai)}),Ni=e=>{let t=e&&typeof e==`object`?e:{},n={},r=t.columnWidths;if(r&&typeof r==`object`){let e=r;for(let t of Object.keys(e)){let r=e[t];typeof r==`number`&&Number.isFinite(r)&&(n[t]=r)}}let i=t.filters&&typeof t.filters==`object`?t.filters:{},a=typeof i.globalText==`string`?i.globalText:``,o={},s=i.columnFilters;if(s&&typeof s==`object`){let e=s;for(let t of Object.keys(e)){let n=e[t];n&&typeof n==`object`&&`kind`in n&&(o[t]=Oi(n))}}let c=[],l=t.sort;if(Array.isArray(l)){for(let e of l)if(e&&typeof e==`object`){let t=e;typeof t.columnKey==`string`&&(t.direction===`asc`||t.direction===`desc`)&&c.push({columnKey:t.columnKey,direction:t.direction})}}let u,d=t.columns;if(Array.isArray(d)){let e=[];for(let t of d){if(!t||typeof t!=`object`)continue;let n=t;if(typeof n.key!=`string`)continue;let r={key:n.key};typeof n.visible==`boolean`&&(r.visible=n.visible),(n.pinned===`left`||n.pinned===`right`)&&(r.pinned=n.pinned),e.push(r)}u=e}return{version:2,columnWidths:n,filters:{globalText:a,columnFilters:o},sort:c,columns:u}},Pi=(e,t,n)=>{let r=new Map(e.map(e=>[e.key,e])),i=new Set,a=(e,t)=>{let r=n[e.key],i=typeof r==`number`;if(!t&&!i)return e;let a={...e};return t&&(a.visible=t.visible,a.pinned=t.pinned),i&&(a.width=r),a},o=[];for(let e of t){let t=r.get(e.key);t&&(i.add(e.key),o.push(a(t,e)))}for(let t of e)i.has(t.key)||o.push(a(t,void 0));return l(o)},Fi=(e,t)=>e===null||t===null?e===t:e.mode===`blank`||e.mode===`notBlank`||t.mode===`blank`||t.mode===`notBlank`?e.mode===t.mode:e.mode===t.mode&&e.value===t.value,Ii=(e,t)=>e===null||t===null?e===t:e.mode===t.mode?e.mode===`range`&&t.mode===`range`?e.from===t.from&&e.to===t.to:e.mode===`preset`&&t.mode===`preset`?e.preset===t.preset:e.mode===`blank`||e.mode===`notBlank`?!0:`value`in e&&`value`in t&&e.value===t.value:!1,X=(e,t)=>e===null||t===null?e===t:(e.mode??`include`)===(t.mode??`include`)&&e.values.length===t.values.length&&e.values.every((e,n)=>e===t.values[n]),Li=(e,t)=>e===null||t===null?e===t:e.mode===`comparison`&&t.mode===`comparison`?e.operator===t.operator&&e.value===t.value:e.mode===`range`&&t.mode===`range`?e.min===t.min&&e.max===t.max:e.mode===`blank`||e.mode===`notBlank`?e.mode===t.mode:!1,Ri=(e,t)=>{switch(e.kind){case`set`:return t.kind===`set`&&(e.mode??`include`)===(t.mode??`include`)&&e.values.length===t.values.length&&e.values.every((e,n)=>e===t.values[n]);case`number`:return t.kind===`number`&&e.raw===t.raw&&Li(e.parsed,t.parsed);case`numberSet`:return t.kind===`numberSet`&&Li(e.condition,t.condition)&&X(e.set,t.set);case`textSet`:return t.kind===`textSet`&&Fi(e.condition,t.condition)&&X(e.set,t.set);case`dateSet`:return t.kind===`dateSet`&&Ii(e.condition,t.condition)&&X(e.set,t.set);case`text`:return t.kind===`text`&&e.value===t.value;case`date`:return t.kind===`date`&&e.value===t.value;case`select`:return t.kind===`select`&&e.value===t.value;case`custom`:return t.kind===`custom`&&Object.is(e.value,t.value)}},zi=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!(r in t)||e[r]!==t[r])return!1;return!0},Bi=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!(r in t)||!Ri(e[r],t[r]))return!1;return!0},Vi=(e,t)=>{if(e===void 0||t===void 0)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n].key!==t[n].key||e[n].visible!==t[n].visible||e[n].pinned!==t[n].pinned)return!1;return!0},Z=(e,t)=>{if(e.version!==t.version||!zi(e.columnWidths,t.columnWidths)||e.filters.globalText!==t.filters.globalText||!Bi(e.filters.columnFilters,t.filters.columnFilters)||e.sort.length!==t.sort.length)return!1;for(let n=0;n<e.sort.length;n+=1)if(e.sort[n].columnKey!==t.sort[n].columnKey||e.sort[n].direction!==t.sort[n].direction)return!1;return!!Vi(e.columns,t.columns)},Hi=(e,t,n)=>n?{emit:!1,nextLast:e}:e===null||Z(e,t)?{emit:!1,nextLast:t}:{emit:!0,nextLast:t},Ui=({rowTop:e,rowHeight:t,headerHeight:n,viewportHeight:r,currentScrollTop:i,align:a,maxScrollTop:o})=>{let s=n+e,c=s+t,l;if(a===`start`)l=s-n;else if(a===`end`)l=c-r;else if(a===`center`)l=(s+c)/2-(n+r)/2;else{let e=i+n,t=i+r;l=s>=e&&c<=t?i:s<e?s-n:c-r}return Math.min(Math.max(l,0),Math.max(o??1/0,0))},Wi=({cellLeft:e,cellWidth:t,leftPaneWidth:n,rightPaneWidth:r,viewportWidth:i,currentScrollLeft:a,align:o,maxScrollLeft:s})=>{let c=e+t,l=i-n-r,u;if(o===`start`)u=e-n;else if(o===`end`)u=c-i+r;else if(o===`center`)u=(e+c)/2-n-l/2;else{let t=a+n,o=a+i-r;u=e>=t&&c<=o?a:e<t?e-n:c-i+r}return Math.min(Math.max(u,0),Math.max(s??1/0,0))},Gi=(e,t)=>{let{heights:n,prefix:r,rowCount:i}=e,a=Math.max(t,0);for(let e=a;e<i;e+=1)r[e+1]=r[e]+n[e]},Ki=(e,t,n,r)=>{let i=r??new Map,a=Math.max(e,0),o=new Float64Array(a);for(let e=0;e<a;e+=1){let r=i.get(n(e));o[e]=r===void 0?t:r}let s={rowCount:a,estimate:t,heights:o,prefix:new Float64Array(a+1),measured:i};return Gi(s,0),s},qi=(e,t,n,r)=>t<0||t>=e.rowCount||(e.measured.set(n,r),e.heights[t]===r)?!1:(e.heights[t]=r,!0),Ji=(e,t,n)=>{if(t<=0||n<=0)return 0;if(n>=e[t])return t-1;let r=0,i=t;for(;r<i;){let t=r+i+1>>1;e[t]<=n?r=t:i=t-1}return Math.min(Math.max(r,0),t-1)},Yi=e=>{let{prefix:t,rowCount:n}=e;return{rowCount:n,rowTop:e=>t[Math.min(Math.max(e,0),n)],rowsHeight:(e,r)=>t[Math.min(Math.max(r+1,0),n)]-t[Math.min(Math.max(e,0),n)],totalBodyHeight:t[n],rowAtContentY:e=>Ji(t,n,e)}},Xi=21,Zi=4,Qi=41,$i=13,ea=600,ta=60,na=16,Q=null,ra=()=>Q||(typeof document>`u`?null:(Q=document.createElement(`canvas`).getContext(`2d`),Q)),ia=`system-ui, sans-serif`,aa=e=>{let t=ia,n=13,r=`400`;if(e&&typeof window<`u`){let i=window.getComputedStyle(e);i.fontFamily&&(t=i.fontFamily);let a=Number.parseFloat(i.fontSize);Number.isFinite(a)&&a>0&&(n=a),i.fontWeight&&(r=i.fontWeight)}return{cellFont:`${r} ${n}px ${t}`,headerFont:`${ea} ${$i}px ${t}`}},oa=(e,t,n)=>Math.min(Math.max(e,t),n),sa=e=>e>=4352&&e<=4447||e>=11904&&e<=12350||e>=12353&&e<=13311||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=40960&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=129791||e>=131072&&e<=262141,ca=e=>{let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=sa(e)?2:1}return t},la=(e,t)=>{let n=L(e,t);return t.valueFormatter?t.valueFormatter({value:n,row:e,column:t}):String(n??``)},ua=e=>{if(!e||typeof document>`u`)return null;let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;top:-99999px;left:-99999px;visibility:hidden;pointer-events:none;width:auto;height:auto;contain:layout style;`,e.appendChild(t),t},da=e=>{let t=document.createElement(`div`);return t.className=`ssg-body-cell`,t.style.cssText=`display:inline-block;position:static;top:auto;left:auto;width:auto;height:auto;white-space:nowrap;overflow:visible;`,t.textContent=e,t},fa=e=>e.suppressAutoSize===!0||e.autoHeight===!0;function pa(e){let t=e.map(()=>[]),n=e.map(()=>[]),r=e.map(()=>1/0),i=e.map(()=>0);return{collect:a=>{for(let o=0;o<e.length;o+=1){if(fa(e[o]))continue;let s=e[o].estimateCellWidth;if(s){let t=s(a,e[o]);t>i[o]&&(i[o]=t);continue}let c=String(L(a,e[o])??``);if(c===``)continue;let l=t[o],u=n[o];if(l.length===na&&2*c.length<=r[o])continue;let d=ca(c);if(l.length<na){if(l.push(a),u.push(d),l.length===na){let e=u[0];for(let t=1;t<na;t+=1)u[t]<e&&(e=u[t]);r[o]=e}continue}if(d<=r[o])continue;let f=0;for(let e=1;e<na;e+=1)u[e]<u[f]&&(f=e);l[f]=a,u[f]=d;let p=u[0];for(let e=1;e<na;e+=1)u[e]<p&&(p=u[e]);r[o]=p}},finalize:({gridRoot:n,currentWidths:r})=>{let a=ra();if(!a||e.length===0)return{};let{cellFont:o,headerFont:s}=aa(n),c={},l=ua(n);try{let n=null;if(l){let r=[];for(let n=0;n<e.length;n+=1){if(fa(e[n])){r.push([]);continue}if(e[n].estimateCellWidth){r.push([]);continue}let i=t[n],a=[];for(let t=0;t<i.length;t+=1){let r=la(i[t],e[n]);if(r===``)continue;let o=da(r);l.appendChild(o),a.push(o)}r.push(a)}n=r.map(e=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e[n].offsetWidth;r>t&&(t=r)}return t})}for(let l=0;l<e.length;l+=1){let u=e[l];if(fa(u))continue;a.font=s;let d=u.title||u.key,f=a.measureText(d).width+Zi+Qi,p;if(u.estimateCellWidth)p=i[l]>0?i[l]+Xi:0;else if(n)p=n[l];else{a.font=o;let e=0,n=t[l];for(let t=0;t<n.length;t+=1){let r=la(n[t],u);if(r===``)continue;let i=a.measureText(r).width;i>e&&(e=i)}p=e>0?e+Zi+Xi:0}let m=Math.ceil(oa(Math.max(f,p),u.minWidth??ta,u.maxWidth??1/0));r[u.key]!==m&&(c[u.key]=m)}}finally{l&&l.parentNode&&l.parentNode.removeChild(l)}return c}}}function ma(){return ra()!==null}var ha=()=>new Promise(e=>{if(typeof MessageChannel>`u`){setTimeout(e,0);return}let t=new MessageChannel;t.port1.onmessage=()=>{t.port1.close(),e()},t.port2.postMessage(null)}),ga=10,_a=180,va=()=>typeof performance<`u`?performance.now():Date.now(),ya=({rowModelRef:t,gridRootRef:n,columnWidthsRef:r,dispatch:i})=>{let[o,s]=(0,e.useState)(!1),c=(0,e.useRef)(0),l=(0,e.useRef)(null),u=()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)};return(0,e.useEffect)(()=>()=>{c.current+=1,u()},[]),{isAutosizing:o,runAutosize:(0,e.useCallback)(async e=>{if(e.length===0||!ma())return;let o=c.current+=1;u();let d=t.current,f=d.getRowCount(),p=n.current,m=r.current,h=pa(e);l.current=setTimeout(()=>{c.current===o&&s(!0)},_a);try{let e=0;for(;e<f;){let n=va();for(;e<f&&va()-n<ga;){let t=d.getRow(e);t&&h.collect(t),e+=1}if(e<f&&(await ha(),c.current!==o||t.current!==d))return}let n=h.finalize({gridRoot:p,currentWidths:m});Object.keys(n).length>0&&i(a.syncColumnWidths(n))}finally{c.current===o&&(u(),s(!1))}},[r,i,n,t])}},ba=()=>{let e=new Set,t=[];return{collect(n){let r=String(n??``);e.has(r)||(e.add(r),t.push({value:r,label:r||`(空白)`}))},finalize(){return t.sort((e,t)=>Rn.compare(e.label,t.label))}}},xa=(e,t)=>{let n=ba();for(let r=0;r<e;r+=1)n.collect(t(r));return n.finalize()},Sa=10,Ca=()=>typeof performance<`u`?performance.now():Date.now(),wa=[],Ta=new Set,Ea={status:`idle`,options:wa,allValues:Ta,progress:0},Da={status:`collecting`,options:wa,allValues:Ta,progress:0},Oa=e=>new Set(e.map(e=>e.value)),ka={source:null,rowCount:0,result:Ea},Aa=({column:t,rowCount:n,getRawValueAt:r})=>{let i=t?.filterType??null,a=i===`select`||i===`set`||i===`numberSet`||i===`textSet`||i===`dateSet`,o=t?.filterOptions&&t.filterOptions.length>0?t.filterOptions:null,s=a&&o===null&&n>5e4,c=(0,e.useMemo)(()=>{if(!t||!a)return Ea;if(o){let e=o;return{status:`ready`,options:e,allValues:Oa(e),progress:1}}if(!s){let e=xa(n,r);return{status:`ready`,options:e,allValues:Oa(e),progress:1}}return null},[t,a,o,s,n,r]),[l,u]=(0,e.useState)(ka);(0,e.useEffect)(()=>{if(c!==null)return;let e=r,t=n,i=ba(),a=!1;return(async()=>{let n=0;for(;n<t;){let r=Ca();for(;n<t&&Ca()-r<Sa;)i.collect(e(n)),n+=1;if(n<t){if(await ha(),a)return;u({source:e,rowCount:t,result:{status:`collecting`,options:wa,allValues:Ta,progress:n/t}})}}if(a)return;let r=i.finalize();u({source:e,rowCount:t,result:{status:`ready`,options:r,allValues:Oa(r),progress:1}})})(),()=>{a=!0}},[c,n,r]);let d=l.source===r&&l.rowCount===n?l.result:Da;return c??d},ja=10,Ma=()=>typeof performance<`u`?performance.now():Date.now(),Na=({rows:t,baseOrder:n,columns:r,globalText:i,enabled:a})=>{let o=(0,e.useDeferredValue)(i),s=o.trim().toLowerCase(),c=a&&s.length>0,l=c&&t.length>5e4,u=(0,e.useMemo)(()=>c?l?null:{order:St(t,n,r,o),status:`ready`,progress:1}:{order:n,status:`idle`,progress:1},[c,l,t,n,r,o]),[d,f]=(0,e.useState)(null),[p,m]=(0,e.useState)(null);(0,e.useEffect)(()=>{if(!l)return;let e=t,i=n,a=r,o=s,c=i.length,u=new Int32Array(c),d=!1;return(async()=>{let t=0,n=0;for(;n<c;){let r=Ma();for(;n<c&&Ma()-r<ja;){let r=i[n];xt(e[r],a,o)&&(u[t]=r,t+=1),n+=1}if(n<c){if(await ha(),d)return;m({rows:e,baseOrder:i,columns:a,needle:o,progress:n/c})}}if(d)return;let r=t===c?i:u.slice(0,t);f({rows:e,baseOrder:i,columns:a,needle:o,order:r,rowsLength:e.length})})(),()=>{d=!0}},[l,t,n,r,s]);let h;return h=u||(d!==null&&d.rows===t&&d.baseOrder===n&&d.columns===r&&d.needle===s?{order:d.order,status:`ready`,progress:1}:{order:d!==null&&d.rowsLength===t.length?d.order:n,status:`filtering`,progress:p!==null&&p.rows===t&&p.baseOrder===n&&p.columns===r&&p.needle===s?p.progress:0}),h};function Pa(e){let t=e.blockSize,n=e.maxBlocks,r=new Map,i=e=>{let t=r.get(e);t!==void 0&&(r.delete(e),r.set(e,t))},a=()=>{for(;r.size>n;){let e=r.keys().next().value;if(e===void 0)break;r.delete(e)}};return{getRow:e=>{if(t<=0||e<0)return;let n=Math.floor(e/t),i=r.get(n);if(i!==void 0)return i[e-n*t]},hasBlock:e=>r.has(e),setBlock:(e,t)=>{r.has(e)&&r.delete(e),r.set(e,t),a()},updateRow:(e,n)=>{if(t<=0||e<0)return!1;let i=Math.floor(e/t),a=r.get(i);if(a===void 0)return!1;let o=e-i*t;if(o>=a.length)return!1;let s=a.slice();return s[o]=n,r.set(i,s),!0},touchBlocks:e=>{for(let t of e)i(t)},clear:()=>{r.clear()},loadedBlockIndexes:()=>Array.from(r.keys())}}function Fa(e,t){return Math.floor(e/t)}function Ia(e,t,n,r){if(n<=0||r<=0)return[];let i=Math.max(0,Math.floor(e)),a=Math.min(r,Math.floor(t));if(a<=i)return[];let o=Fa(i,n),s=Fa(a-1,n),c=[];for(let e=o;e<=s;e+=1)c.push(e);return c}var La=()=>{let e=new Map,t=1,n=t=>e.get(t)?.row,r=(n,r)=>{let i=t;return t+=1,e.set(n,{row:r,writeId:i}),i},i=(t,n)=>e.get(t)?.writeId===n;return{getRow:n,beginWrite:r,isLatestWrite:i,settleWrite:(t,n)=>{i(t,n)&&e.delete(t)},clear:()=>{e.clear()},pendingCount:()=>e.size}},Ra=(e,t,n)=>{let r=new Map;for(let i of e){let e=r.get(i.viewIndex);if(e===void 0){let a=t(i.viewIndex);if(a===void 0)continue;e={rowKey:n(a,i.viewIndex),rowIndex:i.viewIndex,row:a,previousRow:a,changes:[]},r.set(i.viewIndex,e)}e.changes.push({columnKey:i.column.key,previousValue:L(e.row,i.column),newValue:i.value}),e.row=je(e.row,i.column,i.value)}return Array.from(r.values())},za=100,Ba=64,Va=120;function Ha(t){let{dataSource:n,rowKeyGetter:r,query:i,queryKey:a,refreshToken:o,onLoadError:s,onWriteError:c}=t,l=n?.blockSize??za,u=n?.maxCachedBlocks??Ba,d=t.debounceMs??Va,[f]=(0,e.useState)(()=>Pa({blockSize:l,maxBlocks:u})),[p,m]=(0,e.useState)(n?.initialRowCount??0),[h,g]=(0,e.useState)(0),_=(0,e.useRef)(p),v=(0,e.useRef)(!1),y=(0,e.useRef)(new Map),b=(0,e.useRef)(new Set),[x,S]=(0,e.useState)(null),C=(0,e.useRef)(s);(0,e.useEffect)(()=>{C.current=s},[s]);let[w]=(0,e.useState)(()=>La()),T=(0,e.useRef)(0),[E,D]=(0,e.useState)(null),O=(0,e.useRef)(c);(0,e.useEffect)(()=>{O.current=c},[c]);let k=(0,e.useCallback)(e=>w.getRow(e)??f.getRow(e),[f,w]),A=(0,e.useCallback)(()=>{T.current+=1,w.clear(),D(null)},[w]),j=(0,e.useCallback)(()=>{let e=b.current.size;S(t=>e===0?t===null?t:null:{failedBlockCount:e})},[]),M=(0,e.useRef)(null),ee=(0,e.useRef)({start:0,end:0}),N=(0,e.useCallback)(e=>{if(n==null||f.hasBlock(e)||y.current.has(e))return;let t=new AbortController;y.current.set(e,t);let r=e*l,a=r+l;n.getRows({startIndex:r,endIndex:a,query:i,signal:t.signal}).then(n=>{t.signal.aborted||y.current.get(e)===t&&(y.current.delete(e),f.setBlock(e,n.rows),b.current.delete(e)&&j(),n.totalRowCount!==_.current&&(_.current=n.totalRowCount,m(n.totalRowCount)),g(e=>e+1))}).catch(n=>{t.signal.aborted||y.current.get(e)===t&&(y.current.delete(e),b.current.add(e),j(),C.current?.(n,{startIndex:r,endIndex:a}))})},[f,l,n,i,j]),P=(0,e.useCallback)(()=>{let{start:e,end:t}=ee.current,n=Ia(e,t,l,_.current),r=new Set(n);for(let[e,t]of y.current)r.has(e)||(t.abort(),y.current.delete(e));for(let e of n)N(e)},[l,N]),F=(0,e.useCallback)(()=>{M.current!==null&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=null,P()},d)},[d,P]),I=(0,e.useCallback)((e,t)=>{n!=null&&(ee.current={start:e,end:t},f.touchBlocks(Ia(e,t,l,_.current)),F())},[f,l,n,F]);(0,e.useEffect)(()=>{if(n==null)return;for(let[,e]of y.current)e.abort();y.current.clear(),M.current!==null&&(clearTimeout(M.current),M.current=null),f.clear(),b.current.clear(),j(),A();let e=!v.current;v.current=!0,g(e=>e+1),e?(n.initialRowCount??0)<=0&&N(0):N(0)},[a]);let te=(0,e.useCallback)(()=>{if(n==null)return;for(let[,e]of y.current)e.abort();y.current.clear(),M.current!==null&&(clearTimeout(M.current),M.current=null),f.clear(),b.current.clear(),j(),A(),g(e=>e+1);let{start:e,end:t}=ee.current;if(Ia(e,t,l,_.current).length===0){N(0);return}P()},[f,n,l,N,P,j,A]),ne=(0,e.useCallback)(()=>{if(n==null||b.current.size===0)return;let e=Array.from(b.current);b.current.clear(),j();for(let t of e)N(t)},[n,N,j]),re=(0,e.useCallback)(e=>{let t=n?.updateRows;if(t===void 0||e.length===0)return 0;let i=Ra(e,k,r);if(i.length===0)return 0;let a=T.current,o=i.map(e=>({viewIndex:e.rowIndex,row:e.row,writeId:w.beginWrite(e.rowIndex,e.row)}));return g(e=>e+1),t({updates:i}).then(e=>{if(T.current!==a)return;let t=e===void 0?void 0:e.rows;o.forEach((e,n)=>{f.updateRow(e.viewIndex,t?.[n]??e.row),w.settleWrite(e.viewIndex,e.writeId)}),g(e=>e+1)}).catch(e=>{if(T.current===a){for(let e of o)w.settleWrite(e.viewIndex,e.writeId);D({failedRowCount:i.length}),O.current?.(e,{updates:i}),g(e=>e+1)}}),i.length},[f,n,k,w,r]),ie=(0,e.useRef)(o);(0,e.useEffect)(()=>{if(n==null||o===void 0){ie.current=o;return}if(ie.current===void 0){ie.current=o;return}ie.current!==o&&(ie.current=o,te())},[o]),(0,e.useEffect)(()=>{let e=y.current,t=M,n=T;return()=>{for(let[,t]of e)t.abort();e.clear(),t.current!==null&&(clearTimeout(t.current),t.current=null),n.current+=1,w.clear()}},[w]);let ae=(0,e.useCallback)(e=>k(e)!==void 0,[k]);return{rowModel:(0,e.useMemo)(()=>({getRowCount:()=>_.current,getRow:e=>k(e),getSourceIndex:e=>e,getRowKey:e=>{let t=k(e);return t===void 0?e:r(t,e)}}),[k,r,h]),rowCount:p,isRowLoaded:ae,requestRange:I,refresh:te,loadError:x,retryFailedBlocks:ne,canUpdateRows:n?.updateRows!==void 0,applyCellEdits:re,writeError:E}}var Ua=e=>{let t={},n=e.globalText.trim();n.length>0&&(t.globalText=n);let r={},i=!1;for(let t of Object.keys(e.columnFilters)){let n=e.columnFilters[t];tt(n)&&(r[t]=n,i=!0)}return i&&(t.columnFilters=r),e.sort.length>0&&(t.sort=e.sort),t},Wa=e=>{let t=e.columnFilters??{},n=Object.keys(t).sort().map(e=>[e,t[e]]),r=e.sort??[];return JSON.stringify({g:e.globalText??``,s:r.map(e=>[e.columnKey,e.direction]),c:n})};function Ga({state:e,disabled:t=!1}){return(0,n.jsx)(`span`,{"aria-hidden":`true`,className:`ssg-row-checkbox`,"data-state":e,"data-disabled":t?`true`:void 0})}var Ka=(0,e.memo)(Ga);function qa({checked:e,readOnly:t,onToggle:r}){return(0,n.jsx)(`span`,{role:`checkbox`,"aria-checked":e,"aria-disabled":t||void 0,className:`ssg-cell-checkbox`,onClick:()=>{t||r()},children:(0,n.jsx)(Ka,{state:e?`checked`:`unchecked`,disabled:t})})}var Ja=(e,t)=>{let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)):e},Ya=(e,t)=>{if(!t.trim())return{kind:`close`};let n=Ja(e,t);return n.length===0?{kind:`none`}:{kind:`replace`,values:n.map(e=>e.value)}},Xa=(e,t)=>e===null?!0:e.mode===`include`?e.values.has(t):!e.values.has(t),Za=24;function Qa({options:r,setSelection:i,searchInputRef:a,onValueToggle:o,onSelectAllChange:s,onReplaceSelection:c,onRequestClose:l,isServerSide:u,selectAllUsesExplicitScope:d=!1}){let[f,p]=(0,e.useState)(``),m=(0,e.useDeferredValue)(f),h=(0,e.useMemo)(()=>Ja(r,m),[r,m]),g=m.trim().length>0,_=(0,e.useRef)(null),v=(0,t.useVirtualizer)({count:h.length,getScrollElement:()=>_.current,estimateSize:()=>Za,overscan:10}),y=(0,e.useMemo)(()=>{if(i===null)return h.length;let e=0;for(let t of h)Xa(i,t.value)&&(e+=1);return e},[i,h]),b=h.length>0&&y===h.length,x=y>0&&!b,S=(0,e.useMemo)(()=>new Set(r.map(e=>e.value)),[r]),C=(0,e.useMemo)(()=>{if(i===null)return r.length;let e=0;for(let t of i.values)S.has(t)&&(e+=1);return i.mode===`include`?e:r.length-e},[i,S,r.length]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:a,type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),l()),e.key===`Enter`){if(e.nativeEvent.isComposing)return;e.preventDefault();let t=Ya(r,f);if(t.kind===`none`)return;t.kind===`replace`&&c(t.values),l()}},placeholder:`検索(Enter で確定)`,className:`ssg-filter-input`}),(0,n.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:b,ref:e=>{e&&(e.indeterminate=x)},onChange:()=>{s(g||d?h.map(e=>e.value):`all`,!b)}}),(0,n.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:g?`(検索結果をすべて選択)`:`(すべて選択)`})]}),(0,n.jsx)(`div`,{ref:_,className:`ssg-filter-list`,children:h.length===0?(0,n.jsx)(`div`,{className:`ssg-filter-empty`,children:r.length===0?u?`候補が未指定です(serverSide では列に filterOptions などの候補供給が必要)`:`候補がありません`:`一致する候補がありません`}):(0,n.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:v.getTotalSize()},children:v.getVirtualItems().map(e=>{let t=h[e.index];if(!t)return null;let r=Xa(i,t.value);return(0,n.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>o(t.value)}),(0,n.jsx)(`span`,{className:`ssg-filter-option-label`,children:t.label})]},t.value)})})}),(0,n.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`選択中: `,C,` / `,r.length,` 件`,g?`(表示中 ${h.length} 件)`:``]})]})}function $a({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:i}){let a=Et(e.operator);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value}),onKeyDown:i,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:Tt.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a>0?(0,n.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[(0,n.jsx)(`input`,{ref:t,type:`text`,inputMode:`decimal`,value:e.value1,onChange:t=>r({...e,value1:t.target.value}),onKeyDown:i,placeholder:a===2?`下限`:`値`,className:`ssg-filter-input`,"aria-label":a===2?`下限`:`条件の値`}),a===2&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:`〜`}),(0,n.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:e.value2,onChange:t=>r({...e,value2:t.target.value}),onKeyDown:i,placeholder:`上限`,className:`ssg-filter-input`,"aria-label":`上限`})]})]}):(0,n.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`})]})}function eo({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:i}){let a=Lt(e.operator);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value}),onKeyDown:i,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:It.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))}),a>0?(0,n.jsx)(`div`,{className:`ssg-filter-cond-values`,children:(0,n.jsx)(`input`,{ref:t,type:`text`,value:e.value,onChange:t=>r({...e,value:t.target.value}),onKeyDown:i,placeholder:`値`,className:`ssg-filter-input`,"aria-label":`条件の値`})}):(0,n.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`})]})}function to({draft:e,valueInputRef:t,onDraftChange:r,onKeyDown:a,presets:o}){let s=e.preset===null?Wt(e.operator):0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`select`,{value:e.operator,onChange:t=>r({...e,operator:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-select`,"aria-label":`条件の演算子`,children:Ut.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},e.value))}),s>0?(0,n.jsxs)(`div`,{className:`ssg-filter-cond-values`,children:[(0,n.jsx)(`input`,{ref:t,type:`date`,value:e.value1,onChange:t=>r({...e,value1:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-input`,"aria-label":s===2?`開始日`:`条件の日付`}),s===2&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{className:`ssg-filter-cond-tilde`,children:`〜`}),(0,n.jsx)(`input`,{type:`date`,value:e.value2,onChange:t=>r({...e,value2:t.target.value,preset:null}),onKeyDown:a,className:`ssg-filter-input`,"aria-label":`終了日`})]})]}):e.preset===null?(0,n.jsx)(`div`,{className:`ssg-filter-meta`,children:`この演算子は値入力を使いません`}):null,o.length>0&&(0,n.jsx)(`div`,{className:`ssg-filter-presets`,children:o.map(t=>(0,n.jsx)(`button`,{type:`button`,onPointerDown:n=>{n.preventDefault(),n.stopPropagation(),r({...e,preset:e.preset===t.id?null:t.id})},onKeyDown:e=>{e.stopPropagation()},className:i(`ssg-filter-preset-chip`,e.preset===t.id&&`ssg-filter-preset-chip--active`),children:t.label},t.id))})]})}function no({options:r,setSelection:i,searchInputRef:a,onValueToggle:o,onSelectAllChange:s,onReplaceSelection:c,onRequestClose:l,isServerSide:u}){let[d,f]=(0,e.useState)(``),p=(0,e.useDeferredValue)(d),[m,h]=(0,e.useState)(()=>new Set),g=p.trim().length>0,_=(0,e.useMemo)(()=>Ja(r,p),[r,p]),v=(0,e.useMemo)(()=>fi(r,m),[r,m]),y=(0,e.useRef)(null),b=g?_.length:v.length,x=(0,t.useVirtualizer)({count:b,getScrollElement:()=>y.current,estimateSize:()=>Za,overscan:10}),S=(0,e.useMemo)(()=>(g?_:r).map(e=>e.value),[g,_,r]),C=(0,e.useMemo)(()=>{let e=0;for(let t of S)Xa(i,t)&&(e+=1);return e},[S,i]),w=S.length>0&&C===S.length,T=C>0&&!w,E=(0,e.useMemo)(()=>new Set(r.map(e=>e.value)),[r]),D=(0,e.useMemo)(()=>{if(i===null)return r.length;let e=0;for(let t of i.values)E.has(t)&&(e+=1);return i.mode===`include`?e:r.length-e},[i,E,r.length]),O=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},k=e=>{let t=0;for(let n of e)Xa(i,n)&&(t+=1);return t},A=e=>{let t=k(e.leafKeys),r=e.leafKeys.length>0&&t===e.leafKeys.length,i=t>0&&!r;return(0,n.jsxs)(n.Fragment,{children:[e.type===`group`?(0,n.jsx)(`button`,{type:`button`,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),O(e.key)},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-tree-toggle`,"aria-label":e.expanded?`折りたたむ`:`展開する`,children:e.expanded?`▾`:`▸`}):(0,n.jsx)(`span`,{className:`ssg-filter-tree-toggle ssg-filter-tree-toggle--placeholder`}),(0,n.jsx)(`input`,{type:`checkbox`,checked:r,ref:e=>{e&&(e.indeterminate=i)},onChange:()=>{if(e.type===`leaf`){o(e.key);return}s(e.leafKeys,!r)}}),(0,n.jsx)(`span`,{className:`ssg-filter-option-label`,children:e.label})]})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`input`,{ref:a,type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`&&(e.preventDefault(),l()),e.key===`Enter`){if(e.nativeEvent.isComposing)return;e.preventDefault();let t=Ya(r,d);if(t.kind===`none`)return;t.kind===`replace`&&c(t.values),l()}},placeholder:`検索(Enter で確定)`,className:`ssg-filter-input`}),(0,n.jsxs)(`label`,{className:`ssg-filter-selectall`,children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:w,ref:e=>{e&&(e.indeterminate=T)},onChange:()=>s(S,!w)}),(0,n.jsx)(`span`,{className:`ssg-filter-selectall-label`,children:g?`(検索結果をすべて選択)`:`(すべて選択)`})]}),(0,n.jsx)(`div`,{ref:y,className:`ssg-filter-list`,children:b===0?(0,n.jsx)(`div`,{className:`ssg-filter-empty`,children:r.length===0?u?`候補が未指定です(serverSide では列に filterOptions などの候補供給が必要)`:`候補がありません`:`一致する候補がありません`}):(0,n.jsx)(`div`,{className:`ssg-filter-virt`,style:{height:x.getTotalSize()},children:x.getVirtualItems().map(e=>{if(g){let t=_[e.index];return t?(0,n.jsxs)(`label`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size},children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:Xa(i,t.value),onChange:()=>o(t.value)}),(0,n.jsx)(`span`,{className:`ssg-filter-option-label`,children:t.label})]},t.value):null}let t=v[e.index];return t?(0,n.jsx)(`div`,{className:`ssg-filter-option`,style:{transform:`translateY(${e.start}px)`,height:e.size,paddingLeft:8+t.depth*16},children:A(t)},t.key):null})})}),(0,n.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`選択中: `,D,` / `,r.length,` 件`,g?`(表示中 ${_.length} 件)`:``]})]})}function ro({conditionEditor:e,conditionActive:t,onConditionClear:r,options:i,setSelection:a,onSelectionClear:o,summaryText:s,children:c}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-sec-label`,children:`条件`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),r()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-sec-clear`,disabled:!t,children:`クリア`})]}),e,(0,n.jsx)(`div`,{className:`ssg-filter-sep`}),(0,n.jsxs)(`div`,{className:`ssg-filter-sec-head`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-sec-label`,children:`値`}),(0,n.jsx)(`span`,{className:`ssg-filter-sec-meta`,children:t?`一致 ${i.length} 件`:`全 ${i.length} 件`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),o()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-sec-clear`,disabled:a===null,children:`クリア`})]}),c,(0,n.jsxs)(`div`,{className:`ssg-filter-summary`,children:[`🔽 `,s]})]})}function io({isOpen:t,themeClassName:a,title:o,filterType:s,draftValue:c,numberConditionDraft:l,onNumberConditionDraftChange:u,textConditionDraft:d,onTextConditionDraftChange:f,dateConditionDraft:p,onDateConditionDraftChange:m,datePresets:h,onComboConditionClear:g,onComboSelectionClear:_,comboSummaryText:v,currentValueText:y,layout:b,selectOptions:x,optionsStatus:S,optionsProgress:C,setSelection:w,popoverRef:T,textInputRef:E,selectRef:D,onRequestClose:O,onDraftChange:k,onApply:A,onClear:j,onSetValueToggle:M,onSetSelectAllChange:ee,onSetClear:N,onSetReplaceSelection:P,isServerSide:F=!1}){let I=(0,e.useRef)(null),[te]=(0,e.useState)(()=>new Date);if(typeof document>`u`||!t||!b)return null;let ne={top:b.top,left:b.left,width:b.width,maxHeight:b.maxHeight},re=e=>{e.stopPropagation()},ie=e=>{e.stopPropagation()},ae=s===`set`,oe=s===`numberSet`,se=s===`textSet`,ce=s===`dateSet`,le=oe||se||ce,ue=ae||le,de=l??wt,fe=d??Ft,pe=p??Ht,me=h??qe(void 0),he=oe?kt(de):null,ge=se?Rt(fe):null,_e=ce?Kt(pe):null,ve=he!==null||ge!==null||_e!==null,ye=oe?jt(x,he):se?Vt(x,ge):ce?Yt(x,_e,te,me):x,be=e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),A();return}e.key===`Escape`&&(e.preventDefault(),O())};return(0,r.createPortal)((0,n.jsxs)(`div`,{ref:T,onPointerDown:ie,onKeyDown:re,onPasteCapture:e=>{e.stopPropagation()},className:i(`ssg-filter-popover`,a),style:ne,children:[(0,n.jsxs)(`div`,{className:`ssg-filter-title`,children:[`列フィルター: `,o]}),(ue||s===`select`)&&S===`collecting`?(0,n.jsxs)(`div`,{className:`ssg-filter-collecting`,children:[`候補を収集中… `,Math.round(C*100),`%`]}):le?(0,n.jsx)(ro,{conditionEditor:oe?(0,n.jsx)($a,{draft:de,valueInputRef:E,onDraftChange:u,onKeyDown:be}):se?(0,n.jsx)(eo,{draft:fe,valueInputRef:E,onDraftChange:f,onKeyDown:be}):(0,n.jsx)(to,{draft:pe,valueInputRef:E,onDraftChange:m,onKeyDown:be,presets:me}),conditionActive:ve,onConditionClear:g,options:ye,setSelection:w,onSelectionClear:_,summaryText:v,children:ce?(0,n.jsx)(no,{options:ye,setSelection:w,searchInputRef:I,onValueToggle:M,onSelectAllChange:ee,onReplaceSelection:P,onRequestClose:O,isServerSide:F}):(0,n.jsx)(Qa,{options:ye,setSelection:w,searchInputRef:I,onValueToggle:M,onSelectAllChange:ee,onReplaceSelection:P,onRequestClose:O,isServerSide:F,selectAllUsesExplicitScope:!0})}):ae?(0,n.jsx)(Qa,{options:x,setSelection:w,searchInputRef:E,onValueToggle:M,onSelectAllChange:ee,onReplaceSelection:P,onRequestClose:O,isServerSide:F}):s===`number`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`ssg-filter-hint`,children:`フィルター種別: number`}),(0,n.jsx)($a,{draft:de,valueInputRef:E,onDraftChange:u,onKeyDown:be})]}):s===`select`?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`ssg-filter-hint`,children:`フィルター種別: select`}),(0,n.jsxs)(`select`,{ref:D,value:c,onChange:e=>k(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),A();return}e.key===`Escape`&&(e.preventDefault(),O())},className:`ssg-filter-select`,children:[(0,n.jsx)(`option`,{value:``,children:`(すべて)`}),x.map(e=>(0,n.jsx)(`option`,{value:e.value,children:e.label},`${o}-${e.value}`))]}),(0,n.jsxs)(`div`,{className:`ssg-filter-meta`,children:[`候補数: `,x.length]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{className:`ssg-filter-hint`,children:[`フィルター種別: `,s]}),(0,n.jsx)(`input`,{ref:E,type:`text`,value:c,onChange:e=>k(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),A();return}e.key===`Escape`&&(e.preventDefault(),O())},placeholder:`部分一致で絞り込み`,className:`ssg-filter-input`}),(0,n.jsx)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:`部分一致検索です`})]}),!ue&&(0,n.jsxs)(`div`,{className:`ssg-filter-meta ssg-filter-meta--ellipsis`,children:[`現在値: `,y]}),(0,n.jsx)(`div`,{className:`ssg-filter-footer`,children:ue?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),N()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-secondary`,children:`クリア`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),O()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-primary`,children:`閉じる`})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),j()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-secondary`,children:`クリア`}),(0,n.jsx)(`button`,{type:`button`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),A()},onKeyDown:e=>{e.stopPropagation()},className:`ssg-filter-btn-primary`,children:`適用`})]})})]}),document.body)}function ao({context:e,showCounts:t=!0}){let{derivedSummary:r}=e;return(0,n.jsx)(`div`,{className:`ssg-bar--bottom`,children:(0,n.jsxs)(`div`,{className:`ssg-bar-container`,children:[t?(0,n.jsxs)(`div`,{className:`ssg-bar-group`,children:[(0,n.jsx)(`span`,{className:`ssg-bar-chip`,children:r.rowSummaryText}),(0,n.jsx)(`span`,{className:`ssg-bar-chip`,children:r.columnSummaryText})]}):null,(0,n.jsxs)(`div`,{className:`ssg-bar-group`,children:[(0,n.jsxs)(`span`,{className:`ssg-bar-chip`,children:[`Active: `,r.activeCellLabel]}),(0,n.jsxs)(`span`,{className:`ssg-bar-chip`,children:[`Selection: `,r.selectionLabel]}),(0,n.jsx)(`span`,{className:`ssg-bar-chip`,children:r.selectionStatsText}),(0,n.jsxs)(`span`,{className:`ssg-bar-chip`,children:[`Cols: `,r.selectionStats.selectedColumnCount]})]})]})})}var oo=(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,n.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,n.jsx)(`line`,{x1:`10.6`,y1:`10.6`,x2:`14.5`,y2:`14.5`})]}),so=(0,n.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,n.jsx)(`line`,{x1:`4`,y1:`4`,x2:`12`,y2:`12`}),(0,n.jsx)(`line`,{x1:`12`,y1:`4`,x2:`4`,y2:`12`})]});function co({context:e,showSummary:t=!0,showFilter:r=!0,showCounts:i=!0,globalFilterPlaceholder:a=`グローバルフィルター`,globalFilterIcon:o,onFilterSummaryClick:s}){let{derivedSummary:c}=e,l=o===void 0?oo:o,u=e.globalFilterText.trim().length>0;return(0,n.jsx)(`div`,{className:`ssg-bar--top`,children:(0,n.jsxs)(`div`,{className:`ssg-bar-container`,children:[t?(0,n.jsxs)(`div`,{className:`ssg-bar-group ssg-bar-leading`,children:[(0,n.jsx)(`span`,{className:`ssg-bar-title`,children:`Toolbar`}),i?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.rowSummaryText}),(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.columnSummaryText})]}):null,s?(0,n.jsx)(`button`,{type:`button`,className:`ssg-bar-chip ssg-bar-chip--emphasis ssg-bar-chip--action`,onPointerDown:e=>{e.stopPropagation()},onClick:s,"data-ssg-tooltip":`フィルター管理パネルを開閉`,"aria-label":`フィルター管理パネルを開閉`,children:c.filterSummaryText}):(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.filterSummaryText}),(0,n.jsx)(`span`,{className:`ssg-bar-chip ssg-bar-chip--emphasis`,children:c.sortSummaryText})]}):null,r?(0,n.jsxs)(`div`,{className:`ssg-bar-input-group`,children:[l?(0,n.jsx)(`span`,{className:`ssg-bar-input-icon`,"aria-hidden":`true`,children:l}):null,(0,n.jsx)(`input`,{type:`text`,value:e.globalFilterText,onChange:t=>e.setGlobalFilterText(t.target.value),placeholder:a,className:`ssg-bar-input`}),u?(0,n.jsx)(`button`,{type:`button`,onClick:()=>e.setGlobalFilterText(``),className:`ssg-bar-input-clear`,"aria-label":`フィルターをクリア`,"data-ssg-tooltip":`クリア`,children:so}):null]}):null]})})}var lo=e=>e.enabled&&!e.isAutoHeightCell&&!e.hasRenderCell;function uo({pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:a,rowKey:o,sourceRowIndex:s,row:c,top:l,renderEntries:u,rowHeight:d,autoHeight:f,showCellOverflowTooltip:p,showValidationMarks:m,autoHeightMinHeight:h,rowHeaderCellStyle:g,isRowHovered:_,isWholeGridSelected:v,isRowSelected:y,showRowCheckbox:b,isRowChecked:x,activeColInRow:S,editingColInRow:C,selectedColStart:w,selectedColEnd:T,readOnly:E,canEditCell:D,onRowHeaderPointerDown:O,onRowHeaderPointerEnter:k,onRowHeaderPointerLeave:A,onCellPointerDown:j,onCellPointerEnter:M,onCellDoubleClick:ee,renderCellContent:N,rowClassName:P,bodyCellClassName:F,bodyRowClassName:I,rowHeaderCellClassName:te}){return(0,n.jsxs)(`div`,{"data-pane":e,"data-row-index":a,className:i(`ssg-body-row`,x&&`ssg-body-row--checked`,P,I),style:{height:d,transform:`translateY(${l}px)`},children:[t&&(0,n.jsx)(`div`,{role:b?`checkbox`:void 0,"aria-checked":b?x:void 0,onPointerDown:e=>O(a,e),onPointerEnter:e=>k(a,e),onPointerLeave:()=>A(a),className:i(`ssg-header-cell`,`ssg-row-header-cell`,b&&`ssg-row-header-cell--checkbox`,(v||y)&&`ssg-header-cell--selected`,_&&`ssg-header-cell--hovered`,P,te),style:{...g,height:d},children:b?(0,n.jsx)(Ka,{state:x?`checked`:`unchecked`}):a+1}),u.map(e=>{if(!e)return null;let t=e.logicalIndex,l=e.column,u=r+e.paneLocalStart,g=e.paneLocalSize,v=t===S,b=t===C,x=y||w>=0&&t>=w&&t<=T,O=!Ae({readOnly:E,canEditCell:D},a,t,c,l),k=f&&l.autoHeight===!0,A,I=l.cellClassName;I&&(A=typeof I==`function`?I({row:c,rowIndex:a,sourceRowIndex:s,rowKey:o,colIndex:t,value:L(c,l),column:l,isActive:v,isSelected:x,isEditing:b,readOnly:O}):I);let te=m&&l.validate?H(l,c,L(c,l)):null,ne=i(`ssg-body-cell`,l.align===`center`&&`ssg-body-cell--align-center`,l.align===`right`&&`ssg-body-cell--align-right`,k&&`ssg-body-cell--autoheight`,O&&!x&&`ssg-body-cell--readonly`,te!==null&&`ssg-body-cell--invalid`,_&&`ssg-body-cell--row-hovered`,P,A,F),re={};l.wordBreak!==void 0&&(re.wordBreak=l.wordBreak),l.lineBreak!==void 0&&(re.lineBreak=l.lineBreak);let ie=lo({enabled:p,isAutoHeightCell:k,hasRenderCell:l.renderCell!==void 0});return(0,n.jsx)(`div`,{"data-ssg-col-key":l.key,"data-autoheight-cell":k?``:void 0,"data-ssg-tooltip":te??void 0,"data-ssg-tooltip-overflow":ie?``:void 0,className:ne,onPointerDown:e=>j({row:a,col:t},e),onPointerEnter:e=>M({row:a,col:t},e),onDoubleClick:()=>ee({row:a,col:t}),style:{left:u,width:g,minWidth:g,...k?{minHeight:h}:{height:d},...re,zIndex:v?3:1},children:N(c,a,l,t,{isActive:v,isSelected:x,isEditing:b,readOnly:O})},`${String(o)}-${l.key}`)})]})}var fo=(0,e.memo)(uo),po=[`62%`,`46%`,`78%`,`54%`];function mo({pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:a,top:o,rowHeight:s,renderEntries:c,rowHeaderCellStyle:l,isRowHovered:u,showRowCheckbox:d,onRowHeaderPointerDown:f,onRowHeaderPointerEnter:p,onRowHeaderPointerLeave:m,onCellPointerDown:h,onCellPointerEnter:g,bodyCellClassName:_,bodyRowClassName:v,rowHeaderCellClassName:y}){return(0,n.jsxs)(`div`,{"data-pane":e,"data-row-index":a,"data-skeleton-row":``,className:i(`ssg-body-row`,v),style:{height:s,transform:`translateY(${o}px)`},children:[t&&(0,n.jsx)(`div`,{onPointerDown:e=>f(a,e),onPointerEnter:e=>p(a,e),onPointerLeave:()=>m(a),className:i(`ssg-header-cell`,`ssg-row-header-cell`,`ssg-skeleton-rowheader`,d&&`ssg-row-header-cell--checkbox`,u&&`ssg-header-cell--hovered`,y),style:{...l,height:s},children:d?(0,n.jsx)(Ka,{state:`unchecked`,disabled:!0}):a+1}),c.map(t=>{if(!t)return null;let o=t.logicalIndex,c=r+t.paneLocalStart,l=t.paneLocalSize,d=po[o%po.length];return(0,n.jsx)(`div`,{className:i(`ssg-body-cell`,u&&`ssg-body-cell--row-hovered`,_),onPointerDown:e=>h({row:a,col:o},e),onPointerEnter:e=>g({row:a,col:o},e),style:{left:c,width:l,minWidth:l,height:s,zIndex:1},children:(0,n.jsx)(`div`,{"aria-hidden":`true`,className:`ssg-skeleton-bar`,style:{width:d}})},`skeleton-${e}-${o}`)})]})}var ho=(0,e.memo)(mo),go=(e,t)=>t==null?``:e.valueFormatter?e.valueFormatter({value:t,row:void 0,column:e}):String(t),_o=16;function vo({pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:a,top:o,rowHeight:s,renderEntries:c,rowHeaderCellStyle:l,isRowHovered:u,showRowCheckbox:d,groupRow:f,isCollapsed:p,onGroupToggle:m,onRowHeaderPointerEnter:h,onRowHeaderPointerLeave:g,bodyCellClassName:_,bodyRowClassName:v,rowHeaderCellClassName:y}){return(0,n.jsxs)(`div`,{"data-pane":e,"data-row-index":a,"data-ssg-group-row":``,className:i(`ssg-body-row`,v),style:{height:s,transform:`translateY(${o}px)`},onDoubleClick:()=>m(f.groupKey),children:[t&&(0,n.jsx)(`div`,{onPointerEnter:e=>h(a,e),onPointerLeave:()=>g(a),className:i(`ssg-header-cell`,`ssg-row-header-cell`,d&&`ssg-row-header-cell--checkbox`,u&&`ssg-header-cell--hovered`,y),style:{...l,height:s},children:d?null:a+1}),c.map(t=>{if(!t)return null;let a=t.column,o=r+t.paneLocalStart,c=t.paneLocalSize,l=a.key===$n,d=!l&&Object.prototype.hasOwnProperty.call(f.aggregates,a.key)?go(a,f.aggregates[a.key]):null;return(0,n.jsx)(`div`,{"data-ssg-col-key":a.key,className:i(`ssg-body-cell`,`ssg-group-cell`,a.align===`center`&&`ssg-body-cell--align-center`,a.align===`right`&&`ssg-body-cell--align-right`,u&&`ssg-body-cell--row-hovered`,_),style:{left:o,width:c,minWidth:c,height:s,zIndex:1},children:l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`span`,{"aria-hidden":`true`,className:`ssg-group-indent`,style:{width:f.level*_o}}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-group-toggle`,"aria-expanded":!p,"aria-label":`${f.label} を${p?`展開`:`折りたたみ`}`,onClick:()=>m(f.groupKey),onDoubleClick:e=>e.stopPropagation(),children:p?`▸`:`▾`}),(0,n.jsx)(`span`,{className:`ssg-group-label`,children:f.label}),(0,n.jsxs)(`span`,{className:`ssg-group-count`,children:[`(`,f.leafCount,`件)`]})]}):d},`group-${e}-${a.key}`)})]})}var yo=(0,e.memo)(vo);function bo({pane:e,ownsRowHeader:t,leadingWidth:r,rowModel:i,virtualRows:a,virtualRowIndexes:o,renderEntries:s,rowHeight:c,autoHeight:l=!1,showCellOverflowTooltip:u=!1,showValidationMarks:d=!0,isServerSide:f=!1,collapsedGroupKeys:p,onGroupToggle:m,rowHeaderCellStyle:h,hoveredRowIndex:g,isWholeGridSelected:_,enableRowSelection:v,rowSelectionState:y,activeCell:b,editingCell:x,selectionSnapshot:S,readOnly:C,canEditCell:w,onRowHeaderPointerDown:T,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,onCellPointerDown:k,onCellPointerEnter:A,onCellDoubleClick:j,renderCellContent:M,getRowClassName:ee,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F}){return(0,n.jsx)(n.Fragment,{children:a.map(a=>{let I=a.index;if(!o.has(I))return null;let te=a.size??c,ne=i.getGroupRow?.(I);if(ne&&m)return(0,n.jsx)(yo,{pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:I,top:a.start,rowHeight:te,renderEntries:s,rowHeaderCellStyle:h,isRowHovered:g===I,showRowCheckbox:v,groupRow:ne,isCollapsed:p?.has(ne.groupKey)===!0,onGroupToggle:m,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F},String(er(ne)));let re=i.getRow(I);if(!re){if(!f)return null;let o=i.getRowKey(I)??I;return(0,n.jsx)(ho,{pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:I,top:a.start,rowHeight:te,renderEntries:s,rowHeaderCellStyle:h,isRowHovered:g===I,showRowCheckbox:v,onRowHeaderPointerDown:T,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,onCellPointerDown:k,onCellPointerEnter:A,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F},String(o))}let ie=i.getRowKey(I)??I,ae=i.getSourceIndex(I)??I,oe=v?O(y,ie):!1,se=S.kind===`row`&&I>=S.startRow&&I<=S.endRow,ce=S.kind===`cell`&&I>=S.startRow&&I<=S.endRow,le=S.kind===`col`||ce?S.startCol:-1,ue=S.kind===`col`||ce?S.endCol:-1,de=b&&b.row===I?b.col:-1,fe=x&&x.row===I?x.col:-1,pe=ee?.(re,I);return(0,n.jsx)(fo,{pane:e,ownsRowHeader:t,leadingWidth:r,rowIndex:I,rowKey:ie,sourceRowIndex:ae,row:re,top:a.start,renderEntries:s,rowHeight:te,autoHeight:l,showCellOverflowTooltip:u,showValidationMarks:d,autoHeightMinHeight:c,rowHeaderCellStyle:h,isRowHovered:g===I,isWholeGridSelected:_,isRowSelected:se,showRowCheckbox:v,isRowChecked:oe,activeColInRow:de,editingColInRow:fe,selectedColStart:le,selectedColEnd:ue,readOnly:C,canEditCell:w,onRowHeaderPointerDown:T,onRowHeaderPointerEnter:E,onRowHeaderPointerLeave:D,onCellPointerDown:k,onCellPointerEnter:A,onCellDoubleClick:j,renderCellContent:M,rowClassName:pe,bodyCellClassName:N,bodyRowClassName:P,rowHeaderCellClassName:F},String(ie))})})}function xo({isActive:e,title:t,className:r,onPointerDown:a,children:o}){return(0,n.jsx)(`button`,{type:`button`,"data-ssg-tooltip":t,"aria-label":t,onPointerDown:a,className:i(`ssg-icon-btn`,e&&`ssg-icon-btn--active`,r),children:o})}function So({pane:e,ownsRowHeader:t,leadingWidth:r,headerHeight:a,rowHeaderCellStyle:o,headerRowClassName:s,headerCellClassName:c,rowHeaderCellClassName:l,isCornerHovered:u,isWholeGridSelected:d,showSelectAllCheckbox:f,selectAllState:p,filteredRowsLength:m,visibleColumnsLength:h,renderEntries:g,hoveredColumnIndex:_,selectionSnapshot:v,columnFilterValues:y,sortState:b,iconButtonClassName:x,onCornerPointerDown:S,onCornerPointerEnter:C,onCornerPointerLeave:w,onColumnHeaderPointerDown:T,onColumnHeaderPointerEnter:E,onColumnHeaderPointerLeave:D,onColumnResizePointerDown:O,enableColumnResize:k,enableColumnMenu:A,openedMenuColumnKey:j,onColumnMenuButtonPointerDown:M,onColumnHeaderContextMenu:ee,onColumnDragHandlePointerDown:N}){return(0,n.jsxs)(`div`,{"data-pane":e,className:i(`ssg-header-row`,s),style:{height:a},children:[t&&(0,n.jsx)(`div`,{role:f?`checkbox`:void 0,"aria-checked":f?p===`all`?!0:p===`some`?`mixed`:!1:void 0,onPointerDown:S,onPointerEnter:C,onPointerLeave:w,className:i(`ssg-header-cell`,`ssg-corner-cell`,f&&`ssg-corner-cell--checkbox`,d&&`ssg-header-cell--selected`,u&&`ssg-header-cell--hovered`,l),style:{...o,height:a,cursor:m>0&&h>0?`pointer`:`default`},children:f?(0,n.jsx)(Ka,{state:p===`all`?`checked`:p===`some`?`indeterminate`:`unchecked`}):`#`}),g.map(e=>{if(!e)return null;let t=e.logicalIndex,o=e.column,s=r+e.paneLocalStart,l=e.paneLocalSize,u=tt(y[o.key]),f=v.kind===`col`&&t>=v.startCol&&t<=v.endCol,p=b.findIndex(e=>e.columnKey===o.key),m=p===-1?null:b[p],h=j===o.key,g=o.key===$n,S=A&&!g;return(0,n.jsxs)(`div`,{"data-ssg-col-key":o.key,onPointerDown:e=>T(t,e),onPointerEnter:e=>E(t,e),onPointerLeave:()=>D(t),onContextMenu:e=>{if(g){e.preventDefault();return}ee(o,e)},className:i(`ssg-header-cell`,(d||f)&&`ssg-header-cell--selected`,_===t&&`ssg-header-cell--hovered`,c),style:{left:s,width:l,minWidth:l,height:a},children:[(0,n.jsx)(`div`,{className:i(`ssg-header-label`,u&&`ssg-header-label--filtered`),"data-ssg-tooltip":o.renderHeader?void 0:o.title||o.key,children:o.renderHeader?o.renderHeader({colIndex:t,width:l,column:o,filterValue:y[o.key],isFiltered:u}):o.title||o.key}),(0,n.jsxs)(`div`,{className:`ssg-header-status`,children:[m&&(0,n.jsxs)(`span`,{"aria-hidden":`true`,"data-ssg-tooltip":(m.direction===`asc`?`昇順で並び替え中`:`降順で並び替え中`)+(b.length>1?` (優先度 ${p+1})`:``),className:`ssg-header-sort`,children:[m.direction===`asc`?`↑`:`↓`,b.length>1&&(0,n.jsx)(`span`,{className:`ssg-header-sort-priority`,children:p+1})]}),u&&(0,n.jsx)(`span`,{"aria-hidden":`true`,"data-ssg-tooltip":`フィルター適用中`,className:`ssg-header-filtered-mark`,children:(0,n.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,n.jsx)(`path`,{d:`M2 4 L14 4 L9.2 9.2 L9.2 13 L6.8 13 L6.8 9.2 Z`})})})]}),(0,n.jsxs)(`div`,{className:`ssg-header-actions`,children:[N&&!g&&(0,n.jsx)(`span`,{onPointerDown:e=>N(o,e),"data-ssg-tooltip":`ドラッグで列を移動`,"aria-hidden":`true`,className:`ssg-header-grip`,children:(0,n.jsxs)(`svg`,{width:`8`,height:`14`,viewBox:`0 0 8 14`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:[(0,n.jsx)(`circle`,{cx:`2`,cy:`3`,r:`1`}),(0,n.jsx)(`circle`,{cx:`6`,cy:`3`,r:`1`}),(0,n.jsx)(`circle`,{cx:`2`,cy:`7`,r:`1`}),(0,n.jsx)(`circle`,{cx:`6`,cy:`7`,r:`1`}),(0,n.jsx)(`circle`,{cx:`2`,cy:`11`,r:`1`}),(0,n.jsx)(`circle`,{cx:`6`,cy:`11`,r:`1`})]})}),S&&(0,n.jsx)(xo,{title:`列メニュー`,isActive:h,className:x,onPointerDown:e=>M(o,e),children:`⋮`})]}),(o.resizable??k)&&(0,n.jsx)(`div`,{onPointerDown:e=>O(o,e),className:`ssg-header-resize`})]},o.key)})]})}var Co=(0,e.memo)(So),wo=200,To=8,Eo=6,Do=289,Oo=({visibleColumns:t,enableColumnMenu:n,gridRootRef:r})=>{let[i,a]=(0,e.useState)(null),[o,s]=(0,e.useState)(null),c=(0,e.useRef)(null),l=(0,e.useRef)(null),u=(0,e.useRef)(null),d=(0,e.useRef)(i);d.current=i;let f=i!==null,p=i?.columnKey??null,m=(0,e.useMemo)(()=>p?t.find(e=>e.key===p)??null:null,[p,t]),h=(0,e.useCallback)(()=>{if(!p){s(null);return}let e,t,n,r=l.current,i=u.current;if(r){if(!r.isConnected){s(null),a(null),l.current=null;return}let i=r.getBoundingClientRect();t=i.right-wo,e=i.bottom+Eo,n=i.top-Do-Eo}else if(i)t=i.x,e=i.y,n=i.y-Do;else{s(null);return}t=Math.max(To,t),t=Math.min(t,window.innerWidth-wo-To),e+Do>window.innerHeight-To&&(e=n),e=Math.max(To,e),s(n=>n&&n.top===e&&n.left===t&&n.width===wo?n:{top:e,left:t,width:wo})},[p]),g=(0,e.useCallback)(()=>{a(null),s(null),l.current=null,u.current=null,requestAnimationFrame(()=>{r.current?.focus()})},[r]),_=(0,e.useCallback)((e,t)=>{if(t.preventDefault(),t.stopPropagation(),!n||t.button!==0)return;let i=t.currentTarget;if(d.current?.columnKey===e.key&&l.current===i){g();return}document.activeElement instanceof HTMLElement&&document.activeElement.blur(),r.current?.blur(),l.current=i,u.current=null,a({columnKey:e.key})},[g,n,r]),v=(0,e.useCallback)((e,t)=>{n&&(t.preventDefault(),t.stopPropagation(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),r.current?.blur(),l.current=null,u.current={x:t.clientX,y:t.clientY},a({columnKey:e.key}),h())},[n,r,h]);return(0,e.useEffect)(()=>{if(!p)return;h();let e=()=>{h()},t=()=>{if(u.current){g();return}h()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0)}},[p,h,g]),(0,e.useEffect)(()=>{if(!f)return;let e=e=>{let t=e.target;t&&(c.current?.contains(t)||l.current?.contains(t)||g())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[g,f]),(0,e.useEffect)(()=>{if(!f)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),g())};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[g,f]),{columnMenuLayout:o,columnMenuRef:c,isColumnMenuOpen:f,openedMenuColumnKey:p,openedMenuColumn:m,openColumnMenuFromButton:_,openColumnMenuFromContextMenu:v,closeColumnMenu:g}},ko=[{value:void 0,label:`固定しない`},{value:`left`,label:`左に固定`},{value:`right`,label:`右に固定`}],Ao=180,jo=4,Mo=8,No=`pin`;function Po({isOpen:t,themeClassName:a,title:o,columnKey:s,canFilter:c,onOpenFilter:l,canSort:u,sortDirection:d,onSortChange:f,onOpenSortManager:p,canManageFilters:m,onOpenFilterManager:h,pinned:g,canChangePinned:_,layout:v,popoverRef:y,onPinnedChange:b,onAutosizeColumn:x,onAutosizeAllColumns:S,onOpenColumnChooser:C,canResetColumns:w,onResetColumns:T,onRequestClose:E}){let[D,O]=(0,e.useState)(null);if((0,e.useEffect)(()=>{O(null)},[s,t]),!t||!v)return null;let k=D===No,A=v.left+v.width+jo+Ao>window.innerWidth-Mo,j={position:`fixed`,top:v.top,left:v.left,width:v.width,zIndex:1e3},M={position:`absolute`,top:-9,...A?{right:`calc(100% + ${jo}px)`}:{left:`calc(100% + ${jo}px)`},width:Ao,zIndex:1};return(0,r.createPortal)((0,n.jsxs)(`div`,{ref:y,onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{e.stopPropagation()},onContextMenu:e=>{e.preventDefault()},className:i(`ssg-menu-panel`,a),style:j,children:[(0,n.jsx)(`div`,{className:`ssg-menu-title`,children:o}),c&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{l()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`フィルター…`})]}),(0,n.jsx)(`div`,{className:`ssg-menu-separator`})]}),u&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{f(`asc`)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:i(`ssg-menu-sort-icon`,d===`asc`&&`ssg-menu-sort-icon--active`),children:d===`asc`?`✓`:`↑`}),(0,n.jsx)(`span`,{className:i(`ssg-menu-label`,d===`asc`&&`ssg-menu-label--sorted`),children:`昇順で並び替え`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{f(`desc`)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:i(`ssg-menu-sort-icon`,d===`desc`&&`ssg-menu-sort-icon--active`),children:d===`desc`?`✓`:`↓`}),(0,n.jsx)(`span`,{className:i(`ssg-menu-label`,d===`desc`&&`ssg-menu-label--sorted`),children:`降順で並び替え`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{p()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`並び替えを管理…`})]})]}),m&&(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{h()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`フィルターを管理…`})]}),(u||m)&&(0,n.jsx)(`div`,{className:`ssg-menu-separator`}),(0,n.jsxs)(`div`,{className:`ssg-menu-submenu-anchor`,children:[(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(No)},onClick:()=>{O(e=>e===No?null:No)},className:i(`ssg-menu-item`,k&&`ssg-menu-item--active`),children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`列の固定`}),(0,n.jsx)(`span`,{className:`ssg-menu-caret`,children:`›`})]}),k&&(0,n.jsxs)(`div`,{className:i(`ssg-menu-panel`,a),style:M,children:[ko.map(e=>{let t=g===e.value;return(0,n.jsxs)(`button`,{type:`button`,disabled:!_,onClick:()=>{_&&b(s,e.value)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:i(`ssg-menu-check`,!t&&`ssg-menu-check--hidden`),children:`✓`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:e.label})]},e.label)}),!_&&(0,n.jsx)(`div`,{className:`ssg-menu-note`,children:`onColumnsChange 未指定のため固定状態を変更できません`})]})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{x(s)},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`この列の幅を自動調整`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{S()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`すべての列の幅を自動調整`})]}),(0,n.jsxs)(`button`,{type:`button`,onPointerEnter:()=>{O(null)},onClick:()=>{C()},className:`ssg-menu-item`,children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`列の表示`})]}),(0,n.jsxs)(`button`,{type:`button`,"aria-disabled":!w,tabIndex:w?0:-1,"data-ssg-tooltip":w?`すべての列の幅・固定・表示・並び順を初期状態に戻します`:`onColumnsChange 未指定のため列をリセットできません`,onPointerEnter:()=>{O(null)},onClick:()=>{w&&T()},className:i(`ssg-menu-item`,!w&&`ssg-menu-item--disabled`),children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:`列のリセット`})]}),(0,n.jsx)(`div`,{className:`ssg-menu-footer`,children:(0,n.jsx)(`button`,{type:`button`,onClick:E,className:`ssg-menu-close-btn`,children:`閉じる`})})]}),document.body)}var Fo=({top:e,left:t,panelWidth:n,viewportWidth:r,viewportHeight:i})=>{let a=Math.max(8,Math.min(t,r-n-8));return{top:Math.max(8,Math.min(e,i-40)),left:a}},Io=360,Lo=8,Ro=12,zo=[`filter`,`columns`,`sort`],Bo=({canUseFilterTab:t,canUseColumnsTab:n,canUseSortTab:r,gridRootRef:i,alliedRef:a,suppressEscape:o=!1,onSuppressedEscape:s})=>{let[c,l]=(0,e.useState)(null),[u,d]=(0,e.useState)(null),[f,p]=(0,e.useState)(0),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useMemo)(()=>{let e={filter:t,columns:n,sort:r};return zo.filter(t=>e[t])},[t,n,r]),_=c===null?null:g.includes(c)?c:g[0]??null,v=_!==null,y=(0,e.useCallback)(()=>{let e=h.current;if(e){let t=Fo({top:e.top,left:e.left,panelWidth:Io,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});d(e=>e&&e.top===t.top&&e.left===t.left&&e.width===Io?e:{top:t.top,left:t.left,width:Io});return}let t=i.current;if(!t){d(null);return}let n=t.getBoundingClientRect(),r=n.right-Io-Ro,a=n.top+Ro;r=Math.max(Lo,r),r=Math.min(r,window.innerWidth-Io-Lo),a=Math.max(Lo,a),d(e=>e&&e.top===a&&e.left===r&&e.width===Io?e:{top:a,left:r,width:Io})},[i]),b=(0,e.useCallback)(e=>{({filter:t,columns:n,sort:r})[e]&&(c!==null&&p(e=>e+1),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),i.current?.blur(),l(e))},[t,n,r,i,c]),x=(0,e.useCallback)(()=>{l(null),d(null),requestAnimationFrame(()=>{i.current?.focus()})},[i]),S=(0,e.useCallback)((e,t)=>{let n=Fo({top:e,left:t,panelWidth:Io,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});h.current=n,d({top:n.top,left:n.left,width:Io})},[]);return(0,e.useEffect)(()=>{if(!v)return;y();let e=()=>{y()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[v,y]),(0,e.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;t&&(m.current?.contains(t)||a?.current?.contains(t)||x())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[a,x,v]),(0,e.useEffect)(()=>{if(!v)return;let e=e=>{if(e.key===`Escape`){if(o){s?.();return}e.preventDefault(),x()}};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[x,v,s,o]),{activeToolPanelTab:_,availableToolPanelTabs:g,toolPanelLayout:u,toolPanelFlashTick:f,toolPanelRef:m,openToolPanel:b,closeToolPanel:x,moveToolPanel:S}},Vo=({layout:t,onPanelMove:n})=>{let r=(0,e.useRef)(null);return(0,e.useEffect)(()=>()=>{r.current?.()},[]),{handleHeaderPointerDown:(0,e.useCallback)(e=>{if(e.button!==0||!t||e.target?.closest(`button, input, select, textarea`)||r.current)return;e.preventDefault();let i={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTop:t.top,startLeft:t.left};function a(e){e.pointerId===i.pointerId&&n(i.startTop+(e.clientY-i.startY),i.startLeft+(e.clientX-i.startX))}function o(e){e.pointerId===i.pointerId&&s()}function s(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),r.current=null}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),r.current=s},[t,n])}};function Ho({themeClassName:t,activeTab:a,flashTick:o,tabs:s,layout:c,panelRef:l,onSelectTab:u,onRequestClose:d,onPanelMove:f,children:p}){let{handleHeaderPointerDown:m}=Vo({layout:c,onPanelMove:f});if((0,e.useEffect)(()=>{let e=l.current;if(!e||o===0)return;e.classList.remove(`ssg-toolpanel--flash`),e.offsetWidth,e.classList.add(`ssg-toolpanel--flash`);let t=()=>{e.classList.remove(`ssg-toolpanel--flash`)};return e.addEventListener(`animationend`,t),()=>{e.removeEventListener(`animationend`,t)}},[o,l]),a===null||!c)return null;let h=Math.max(0,s.findIndex(e=>e.tab===a)),g={top:c.top,left:c.left,width:c.width},_=e=>{e.stopPropagation()},v=e=>{e.stopPropagation()},y={"--ssg-seg-count":s.length,"--ssg-seg-index":h};return(0,r.createPortal)((0,n.jsxs)(`div`,{ref:l,onPointerDown:_,onKeyDown:v,onContextMenu:e=>{e.preventDefault()},className:i(`ssg-popover`,`ssg-toolpanel`,t),style:g,children:[(0,n.jsxs)(`div`,{className:`ssg-toolpanel-header ssg-popover-header--draggable`,onPointerDown:m,children:[(0,n.jsxs)(`div`,{className:`ssg-toolpanel-seg`,role:`tablist`,style:y,children:[(0,n.jsx)(`span`,{className:`ssg-toolpanel-seg-indicator`,"aria-hidden":!0}),s.map(e=>{let t=e.tab===a;return(0,n.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:()=>{t||u(e.tab)},className:i(`ssg-toolpanel-seg-btn`,t&&`ssg-toolpanel-seg-btn--active`),children:[e.label,e.badge?(0,n.jsx)(`span`,{className:`ssg-toolpanel-seg-badge`,children:e.badge}):null]},e.tab)})]}),(0,n.jsx)(`button`,{type:`button`,onClick:d,"aria-label":`閉じる`,className:`ssg-popover-close`,children:`×`})]}),(0,n.jsx)(`div`,{className:`ssg-toolpanel-body`,children:p})]}),document.body)}var Uo=28,Wo=12,Go=[`left`,`center`,`right`],Ko={left:`左固定`,center:`固定なし`,right:`右固定`};function qo(e,t,n){let r=e.find(e=>e.key===t);if(!r)return null;let i=r.pane,a={left:[],center:[],right:[]};for(let t of e)a[t.pane].push(t.key);let o=a[i],s=o.indexOf(t);if(s<0)return null;let c=n;if(c>s&&--c,c=Math.max(0,Math.min(c,o.length-1)),c===s)return null;let[l]=o.splice(s,1);return o.splice(c,0,l),[...a.left,...a.center,...a.right]}function Jo({state:e,disabled:t}){return(0,n.jsxs)(`span`,{className:i(`ssg-checkbox`,(e===`checked`||e===`indeterminate`)&&`ssg-checkbox--filled`,t&&`ssg-checkbox--disabled`),"aria-hidden":!0,children:[e===`checked`&&(0,n.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 12 12`,fill:`none`,children:(0,n.jsx)(`path`,{d:`M2.5 6.2 4.7 8.4 9.5 3.6`,style:{stroke:`var(--ssg-panel-accent-contrast)`},strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),e===`indeterminate`&&(0,n.jsx)(`span`,{className:`ssg-checkbox-dash`})]})}function Yo({disabled:e}){return(0,n.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,style:{fill:e?`var(--ssg-panel-text-disabled)`:`var(--ssg-panel-text-faint)`},"aria-hidden":!0,children:[3,8,13].map(e=>[3,7].map(t=>(0,n.jsx)(`circle`,{cx:t,cy:e,r:`1.2`},`${t}-${e}`)))})}function Xo({items:t,canToggle:r,onToggleColumnVisibility:a,onShowAllColumns:o,onHideAllColumns:s,onResetColumns:c,onReorderColumns:l}){let[u,d]=(0,e.useState)(``),f=(0,e.useRef)(null);(0,e.useEffect)(()=>{let e=requestAnimationFrame(()=>{f.current?.focus()});return()=>cancelAnimationFrame(e)},[]);let p=(0,e.useMemo)(()=>t.filter(e=>e.visible).length,[t]),m=p===t.length&&t.length>0,h=m?`checked`:`indeterminate`,g=m?`すべての列を非表示(先頭の列は残ります)`:`すべての列を表示`,_=(0,e.useMemo)(()=>{let e=u.trim().toLowerCase();return e?t.filter(t=>t.title.toLowerCase().includes(e)):t},[t,u]),v=(0,e.useMemo)(()=>{let e={left:[],center:[],right:[]};for(let t of _)e[t.pane].push(t);return Go.map(t=>({pane:t,items:e[t]})).filter(e=>e.items.length>0)},[_]),y=v.length>=2,b=r&&u.trim()===``,x=(0,e.useRef)(null),[S,C]=(0,e.useState)(null),w=(0,e.useRef)(!1),T=(0,e.useRef)(null),[E,D]=(0,e.useState)(null),O=(0,e.useRef)(0),k=(0,e.useRef)(null),A=(0,e.useCallback)(()=>{let e=x.current,t=T.current;if(!e||!t)return;let n=e.querySelectorAll(`[data-chooser-row][data-chooser-pane="${t}"]`),r=O.current,i=n.length;for(let e=0;e<n.length;e+=1){let t=n[e].getBoundingClientRect();if(r<t.top+t.height/2){i=e;break}}D(i)},[]),j=(0,e.useCallback)(function e(){let t=x.current;if(!t||!w.current){k.current=null;return}let n=t.getBoundingClientRect(),r=O.current,i=0;if(r<n.top+Uo?i=-12:r>n.bottom-Uo&&(i=Wo),i!==0){let e=t.scrollTop;t.scrollTop+=i,t.scrollTop!==e&&A()}k.current=requestAnimationFrame(e)},[A]),M=(0,e.useCallback)(e=>{k.current!==null&&(cancelAnimationFrame(k.current),k.current=null);let n=S,r=E;if(w.current=!1,T.current=null,C(null),D(null),e&&n!==null&&r!==null){let e=qo(t,n,r);e&&l(e)}},[S,E,t,l]),ee=(0,e.useCallback)((e,t,n)=>{b&&(n.preventDefault(),n.stopPropagation(),n.currentTarget.setPointerCapture(n.pointerId),w.current=!0,T.current=t,O.current=n.clientY,C(e),A(),k.current===null&&(k.current=requestAnimationFrame(j)))},[b,A,j]),N=(0,e.useCallback)(e=>{w.current&&(O.current=e.clientY,A())},[A]),P=(0,e.useCallback)(()=>{w.current&&M(!0)},[M]),F=(0,e.useCallback)(()=>{w.current&&M(!1)},[M]);(0,e.useEffect)(()=>()=>{k.current!==null&&(cancelAnimationFrame(k.current),k.current=null)},[]);let I=()=>{r&&(m?s():o())},te=S===null?null:t.find(e=>e.key===S)?.pane??null,ne=(e,t,o)=>{let s=e.visible&&p===1,c=!r||s,l=S===e.key;return(0,n.jsxs)(`div`,{"data-chooser-row":``,"data-chooser-pane":o,className:i(`ssg-chooser-row`,S!==null&&te===o&&E===t&&`ssg-chooser-row--drop-before`,l&&`ssg-chooser-row--dragging`),children:[(0,n.jsx)(`span`,{role:`button`,"aria-label":`ドラッグして並べ替え`,"data-ssg-tooltip":r?u.trim()===``?`ドラッグして並べ替え(同じセクション内のみ)`:`検索中は並べ替えできません`:`onColumnsChange 未指定のため並べ替えできません`,onPointerDown:t=>ee(e.key,o,t),onPointerMove:N,onPointerUp:P,onPointerCancel:F,className:i(`ssg-chooser-handle`,!b&&`ssg-chooser-handle--disabled`,l&&`ssg-chooser-handle--dragging`),children:(0,n.jsx)(Yo,{disabled:!b})}),(0,n.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>{c||a(e.key,!e.visible)},className:`ssg-chooser-toggle`,children:[(0,n.jsx)(Jo,{state:e.visible?`checked`:`unchecked`,disabled:c}),(0,n.jsx)(`span`,{className:i(`ssg-chooser-label`,c&&!e.visible&&`ssg-chooser-label--muted`),children:e.title})]})]},e.key)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{className:`ssg-chooser-search-row`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!r,onClick:I,"aria-label":g,"data-ssg-tooltip":g,className:`ssg-chooser-master-btn`,children:(0,n.jsx)(Jo,{state:h,disabled:!r})}),(0,n.jsxs)(`div`,{className:`ssg-chooser-search-field`,children:[(0,n.jsx)(`span`,{"aria-hidden":!0,className:`ssg-chooser-search-icon`,children:`⌕`}),(0,n.jsx)(`input`,{ref:f,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`検索...`,className:`ssg-chooser-search-input`})]})]}),(0,n.jsx)(`div`,{ref:x,className:`ssg-chooser-list`,children:_.length===0?(0,n.jsx)(`div`,{className:`ssg-chooser-empty`,children:`該当する列がありません`}):v.map(e=>(0,n.jsxs)(`div`,{"data-chooser-section":e.pane,children:[y&&(0,n.jsx)(`div`,{className:`ssg-chooser-section-heading`,children:Ko[e.pane]}),e.items.map((t,n)=>ne(t,n,e.pane)),S!==null&&te===e.pane&&E===e.items.length&&(0,n.jsx)(`div`,{className:`ssg-chooser-drop-end`})]},e.pane))}),(0,n.jsxs)(`div`,{className:`ssg-chooser-footer`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>{r&&c()},"data-ssg-tooltip":`すべての列の幅・固定・表示・並び順を初期状態に戻します`,className:`ssg-chooser-reset-btn`,children:`すべての列を初期状態に戻す`}),!r&&(0,n.jsx)(`div`,{className:`ssg-chooser-note`,children:`onColumnsChange 未指定のため表示/非表示・リセットを変更できません`})]})]})}function Zo({disabled:e}){return(0,n.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,style:{fill:e?`var(--ssg-panel-text-disabled)`:`var(--ssg-panel-text-faint)`},"aria-hidden":!0,children:[3,8,13].map(e=>[3,7].map(t=>(0,n.jsx)(`circle`,{cx:t,cy:e,r:`1.2`},`${t}-${e}`)))})}function Qo({entries:t,columns:r,canSort:a,onAddLevel:o,onChangeDirection:s,onChangeColumn:c,onRemoveLevel:l,onClearAll:u,onMove:d}){let f=(0,e.useMemo)(()=>new Set(t.map(e=>e.columnKey)),[t]),p=(0,e.useMemo)(()=>r.find(e=>!f.has(e.key))??null,[r,f]),m=e=>r.find(t=>t.key===e)?.title??e,h=a&&t.length>=2,g=(0,e.useRef)(null),[_,v]=(0,e.useState)(null),y=(0,e.useRef)(!1),[b,x]=(0,e.useState)(null),S=(0,e.useRef)(0),C=(0,e.useCallback)(()=>{let e=g.current;if(!e)return;let t=e.querySelectorAll(`[data-sort-level]`),n=S.current,r=t.length;for(let e=0;e<t.length;e+=1){let i=t[e].getBoundingClientRect();if(n<i.top+i.height/2){r=e;break}}x(r)},[]),w=(0,e.useCallback)(e=>{let t=_,n=b;if(y.current=!1,v(null),x(null),e&&t!==null&&n!==null){let e=n;e>t&&--e,d(t,e)}},[_,b,d]),T=(0,e.useCallback)((e,t)=>{h&&(t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),y.current=!0,S.current=t.clientY,v(e),C())},[h,C]),E=(0,e.useCallback)(e=>{y.current&&(S.current=e.clientY,C())},[C]),D=(0,e.useCallback)(()=>{y.current&&w(!0)},[w]),O=(0,e.useCallback)(()=>{y.current&&w(!1)},[w]),k=a&&p!==null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`div`,{ref:g,className:`ssg-sort-list`,children:[t.length===0?(0,n.jsx)(`div`,{className:`ssg-sort-empty`,children:`並び替えは設定されていません`}):t.map((e,o)=>{let u=r.filter(t=>t.key===e.columnKey||!f.has(t.key)),d=u.some(t=>t.key===e.columnKey)?u:[{key:e.columnKey,title:m(e.columnKey)},...u],p=_===o;return(0,n.jsxs)(`div`,{"data-sort-level":``,className:i(`ssg-sort-level`,_!==null&&b===o&&`ssg-sort-level--drop-before`,p&&`ssg-sort-level--dragging`),children:[(0,n.jsx)(`span`,{role:`button`,"aria-label":`ドラッグして優先順位を変更`,"data-ssg-tooltip":a?t.length<2?`レベルが 2 件以上のとき並べ替えできます`:`ドラッグして優先順位を変更`:`並び替えが無効です`,onPointerDown:e=>T(o,e),onPointerMove:E,onPointerUp:D,onPointerCancel:O,className:i(`ssg-sort-handle`,!h&&`ssg-sort-handle--disabled`,p&&`ssg-sort-handle--dragging`),children:(0,n.jsx)(Zo,{disabled:!h})}),(0,n.jsx)(`span`,{"aria-hidden":!0,className:`ssg-sort-badge`,children:o+1}),(0,n.jsx)(`select`,{value:e.columnKey,disabled:!a,onChange:e=>c(o,e.target.value),className:`ssg-sort-select`,children:d.map(e=>(0,n.jsx)(`option`,{value:e.key,children:e.title},e.key))}),(0,n.jsxs)(`div`,{className:`ssg-sort-dir-group`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>s(o,`asc`),"data-ssg-tooltip":`昇順`,className:i(`ssg-sort-dir-btn`,e.direction===`asc`&&`ssg-sort-dir-btn--active`),children:`↑ 昇順`}),(0,n.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>s(o,`desc`),"data-ssg-tooltip":`降順`,className:i(`ssg-sort-dir-btn`,e.direction===`desc`&&`ssg-sort-dir-btn--active`),children:`↓ 降順`})]}),(0,n.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>l(o),"aria-label":`このレベルを削除`,"data-ssg-tooltip":`このレベルを削除`,className:`ssg-sort-delete`,children:`×`})]},e.columnKey)}),_!==null&&b===t.length&&(0,n.jsx)(`div`,{className:`ssg-sort-drop-end`})]}),(0,n.jsxs)(`div`,{className:`ssg-popover-footer`,children:[(0,n.jsx)(`button`,{type:`button`,disabled:!k,onClick:()=>{!k||!p||o(p.key,`asc`)},"data-ssg-tooltip":a?p===null?`すべての列が並び替えに使われています`:`並び替えの基準を追加します`:`並び替えが無効です`,className:`ssg-sort-footer-btn ssg-sort-footer-btn--add`,children:`+ 基準を追加`}),(0,n.jsx)(`button`,{type:`button`,disabled:!a||t.length===0,onClick:()=>{!a||t.length===0||u()},"data-ssg-tooltip":`すべての並び替えを解除します`,className:`ssg-sort-footer-btn ssg-sort-footer-btn--clear`,children:`すべてクリア`})]}),!a&&(0,n.jsx)(`div`,{className:`ssg-sort-note`,children:`並び替えが無効のため編集できません`})]})}function $o(){return(0,n.jsx)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,n.jsx)(`path`,{d:`M2 4 L14 4 L9.2 9.2 L9.2 13 L6.8 13 L6.8 9.2 Z`})})}function es(){return(0,n.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,"aria-hidden":`true`,focusable:`false`,children:[(0,n.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,n.jsx)(`path`,{d:`m20 20-3.5-3.5`})]})}function ts({entries:e,addableColumns:t,showGlobalFilterRow:r,globalFilterText:i,canFilter:a,onEditFilter:o,onAddFilter:s,onClearFilter:c,onClearAllFilters:l,onClearGlobalFilter:u}){let d=a&&e.length>0,f=a&&t.length>0;return(0,n.jsxs)(n.Fragment,{children:[r&&(0,n.jsxs)(`div`,{className:`ssg-filter-manage-row ssg-filter-manage-row--global`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-manage-glyph ssg-filter-manage-glyph--global`,"aria-hidden":`true`,children:(0,n.jsx)(es,{})}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-main`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-manage-name`,children:`グローバルフィルター`}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-summary`,"data-ssg-tooltip":i,children:[`"`,i,`" を含む行`]})]}),(0,n.jsx)(`span`,{className:`ssg-filter-manage-actions`,children:(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-icon-btn ssg-filter-manage-icon-btn--danger`,disabled:!a,"data-ssg-tooltip":`グローバルフィルターをクリア`,"aria-label":`グローバルフィルターをクリア`,onClick:u,children:`×`})})]}),(0,n.jsx)(`div`,{className:`ssg-filter-manage-list`,children:e.length===0?(0,n.jsx)(`div`,{className:`ssg-filter-manage-empty`,children:`適用中の列フィルターはありません`}):e.map(e=>(0,n.jsxs)(`div`,{className:`ssg-filter-manage-row`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-manage-glyph`,"aria-hidden":`true`,children:(0,n.jsx)($o,{})}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-main`,children:[(0,n.jsxs)(`span`,{className:`ssg-filter-manage-name`,children:[e.title,e.isHidden&&(0,n.jsx)(`span`,{className:`ssg-filter-manage-hidden-note`,children:`(非表示列)`})]}),(0,n.jsx)(`span`,{className:`ssg-filter-manage-summary`,"data-ssg-tooltip":e.summaryText,children:e.summaryText})]}),(0,n.jsxs)(`span`,{className:`ssg-filter-manage-actions`,children:[(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-icon-btn`,disabled:!a||e.isHidden,"data-ssg-tooltip":e.isHidden?`非表示列のためジャンプ編集できません(× でクリアは可能)`:`この列へジャンプして編集`,"aria-label":`${e.title} のフィルターを編集`,onClick:()=>{o(e.columnKey)},children:`✎`}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-icon-btn ssg-filter-manage-icon-btn--danger`,disabled:!a,"data-ssg-tooltip":`この列のフィルターをクリア`,"aria-label":`${e.title} のフィルターをクリア`,onClick:()=>{c(e.columnKey)},children:`×`})]})]},e.columnKey))}),(0,n.jsxs)(`div`,{className:`ssg-popover-footer`,children:[(0,n.jsxs)(`select`,{className:`ssg-filter-manage-add`,value:``,disabled:!f,"aria-label":`フィルターを追加する列を選択`,onChange:e=>{let t=e.target.value;t&&s(t)},children:[(0,n.jsx)(`option`,{value:``,children:f?`+ フィルターを追加…`:`+ 追加できる列がありません`}),t.map(e=>(0,n.jsx)(`option`,{value:e.key,children:e.title},e.key))]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-manage-clear-all`,disabled:!d,onClick:l,children:`すべてクリア`})]})]})}function ns({entries:e,canFilter:t,onEditFilter:r,onClearFilter:i,onClearAllFilters:a}){return e.length===0?null:(0,n.jsxs)(`div`,{className:`ssg-filter-chip-bar`,children:[e.map(e=>(0,n.jsxs)(`div`,{className:e.isHidden?`ssg-filter-chip ssg-filter-chip--hidden`:`ssg-filter-chip`,children:[(0,n.jsxs)(`button`,{type:`button`,className:`ssg-filter-chip-label`,disabled:!t||e.isHidden,"data-ssg-tooltip":e.isHidden?`非表示列のためジャンプ編集できません(× でクリアは可能)`:`この列へジャンプして編集`,"aria-label":`${e.title} のフィルターを編集`,onClick:()=>{r(e.columnKey)},children:[(0,n.jsxs)(`span`,{className:`ssg-filter-chip-name`,children:[e.title,e.isHidden?`(非表示列)`:``]}),(0,n.jsx)(`span`,{className:`ssg-filter-chip-summary`,children:e.summaryText})]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-chip-clear`,disabled:!t,"data-ssg-tooltip":`この列のフィルターをクリア`,"aria-label":`${e.title} のフィルターをクリア`,onClick:()=>{i(e.columnKey)},children:`×`})]},e.columnKey)),(0,n.jsx)(`button`,{type:`button`,className:`ssg-filter-chip-bar-clear-all`,disabled:!t,onClick:a,children:`すべてクリア`})]})}var rs=e=>{if(e===void 0||e===!1)return null;let t=e===!0?{}:e,n=t.bubble??!0,r=t.ruler??!0,i=t.scrollbar??!0;return!n&&!r&&!i?null:{bubble:n,ruler:r,scrollbar:i,trigger:t.trigger??`scroll`,minRows:t.minRows??0,hintColumn:t.hintColumn,renderHint:t.renderHint}},is=({scrollTop:e,contentHeight:t,viewportHeight:n,trackHeight:r=n})=>{let i=t-n;if(n<=0||r<=0||i<=0)return null;let a=Math.min(Math.max(r*n/t,30),r),o=Math.min(Math.max(e,0),i)/i*(r-a);return{maxScroll:i,thumbTop:o,thumbHeight:a,centerY:o+a/2}},as=e=>{let t=Math.max(e,1),n=10**Math.floor(Math.log10(t)),r=n<10?[1,2,5,10]:[1,2,2.5,5,10];for(let e of r){let r=n*e;if(r>=t)return r}return n*10},os=(e,t=e>=1e4&&e%1e4==0)=>e!==0&&t?`${(e/1e4).toLocaleString()}万`:e.toLocaleString(),ss=({rowCount:e,rulerHeight:t,minTickSpacingPx:n=44})=>{if(e<=0||t<=0)return[];let r=as(e/Math.max(Math.floor(t/n),2)),i=r%1e4==0,a=[];for(let n=0;n<=e;n+=r)a.push({row:n,y:n/e*t,label:os(n,i)});return a},cs=(e,t,n)=>{let r=n-t.thumbHeight;return r<=0?0:Math.min(Math.max((e-t.thumbHeight/2)/r,0),1)*t.maxScroll},ls=(e,t)=>{if(e.renderHint!==void 0){let n=e.renderHint(t);return n==null||n===!1?null:n}if(e.hintColumn!==void 0&&t.rowData!==void 0){let n=t.rowData[e.hintColumn];return n==null||n===``?null:String(n)}return null},us=1e3,ds=8,fs=18,ps=28;function ms({options:t,scrollContainerRef:r,scrollTop:a,viewportHeight:o,headerHeight:s,physicalBodyHeight:c,verticalScaleFactor:l,rowMetrics:u,rowModel:d}){let[f,p]=(0,e.useState)(!1),[m,h]=(0,e.useState)(!1),[g,_]=(0,e.useState)(0),[v,y]=(0,e.useState)(null),[b,x]=(0,e.useState)(!1),S=(0,e.useRef)(null),C=(0,e.useRef)(null),w=(0,e.useRef)(null),T=t.scrollbar?s:0,E=Math.max(t.scrollbar?o-s:o,0),D=is({scrollTop:a,contentHeight:s+c,viewportHeight:o,trackHeight:E}),O=D!==null&&u.rowCount>0;(0,e.useEffect)(()=>{let e=r.current;if(!e)return;let n=()=>{p(!0),S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{S.current=null,p(!1)},us)},i=()=>h(!0),a=()=>{h(!1),y(null)},o=t=>{let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=e.offsetWidth-Math.max(e.offsetWidth-e.clientWidth,0)-fs;y(r>=i?t.clientY-n.top:null)},s=new ResizeObserver(()=>{_(Math.max(e.offsetWidth-e.clientWidth,0))});return e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`pointerenter`,i),e.addEventListener(`pointerleave`,a),t.scrollbar||e.addEventListener(`pointermove`,o,{passive:!0}),s.observe(e),()=>{e.removeEventListener(`scroll`,n),e.removeEventListener(`pointerenter`,i),e.removeEventListener(`pointerleave`,a),e.removeEventListener(`pointermove`,o),s.disconnect(),S.current!==null&&(window.clearTimeout(S.current),S.current=null)}},[r,t.scrollbar]),(0,e.useEffect)(()=>{if(!t.scrollbar||!O)return;let e=w.current,n=r.current;if(!e||!n)return;let i=e=>{e.preventDefault(),n.scrollTop+=e.deltaY};return e.addEventListener(`wheel`,i,{passive:!1}),()=>{e.removeEventListener(`wheel`,i)}},[r,t.scrollbar,O]);let k=Math.max(o-s,0),A=(0,e.useMemo)(()=>t.ruler?ss({rowCount:u.rowCount,rulerHeight:k}):[],[t.ruler,u.rowCount,k]);if(D===null||u.rowCount<=0)return null;let j=t.trigger===`always`||f||t.trigger===`hover`&&m,M=j||v!==null,ee=t.scrollbar?14:g,N=mr(Math.min(Math.max(a,0),D.maxScroll),l),P=u.rowAtContentY(N),F=ls(t,{rowIndex:P,rowData:d.getRow(P)}),I=null;if(t.ruler&&v!==null&&!b){let e=cs(v,D,E),n=u.rowAtContentY(mr(e,l));I={lineY:Math.min(Math.max(T+v,s),o),rowIndex:n,detail:ls(t,{rowIndex:n,rowData:d.getRow(n)})}}let te=e=>{let t=w.current;return t===null?0:e.clientY-t.getBoundingClientRect().top},ne=(e,t)=>{let n=r.current;if(n===null)return;let i=E-D.thumbHeight;i<=0||(n.scrollTop=Math.min(Math.max((e-t)/i,0),1)*D.maxScroll)};return(0,n.jsxs)(`div`,{className:`ssg-scroll-hint`,"aria-hidden":`true`,children:[t.ruler&&A.length>0&&(0,n.jsx)(`div`,{className:i(`ssg-scroll-hint-ruler`,M&&`ssg-scroll-hint-ruler--visible`),style:{top:s,right:ee},children:A.map(e=>(0,n.jsx)(`div`,{className:`ssg-scroll-hint-ruler-tick`,style:{top:Math.min(Math.max(e.y,6),Math.max(k-6,6))},children:(0,n.jsx)(`span`,{className:`ssg-scroll-hint-ruler-label`,children:e.label})},e.row))}),I!==null&&(0,n.jsx)(`div`,{className:`ssg-scroll-hint-jumpline`,style:{top:I.lineY,right:ee},children:(0,n.jsxs)(`span`,{className:i(`ssg-scroll-hint-jumpline-label`,I.lineY<s+ps&&`ssg-scroll-hint-jumpline-label--below`),children:[`行 `,(I.rowIndex+1).toLocaleString(),` へ`,I.detail!==null&&(0,n.jsxs)(`span`,{className:`ssg-scroll-hint-jumpline-detail`,children:[` `,`・ `,I.detail]})]})}),t.bubble&&(0,n.jsxs)(`div`,{className:i(`ssg-scroll-hint-bubble`,j&&`ssg-scroll-hint-bubble--visible`),style:{top:T+D.centerY,right:ee+ds},children:[(0,n.jsxs)(`span`,{className:`ssg-scroll-hint-bubble-main`,children:[`行 `,(P+1).toLocaleString(),(0,n.jsxs)(`span`,{className:`ssg-scroll-hint-bubble-total`,children:[` `,`/ `,u.rowCount.toLocaleString()]})]}),F!==null&&(0,n.jsx)(`span`,{className:`ssg-scroll-hint-bubble-detail`,children:F})]}),t.scrollbar&&(0,n.jsx)(`div`,{ref:w,className:i(`ssg-scroll-hint-scrollbar`,b&&`ssg-scroll-hint-scrollbar--dragging`),style:{top:s,height:E,width:14},onPointerDown:e=>{e.preventDefault();let t=te(e),n=t>=D.thumbTop&&t<=D.thumbTop+D.thumbHeight?t-D.thumbTop:D.thumbHeight/2;C.current=n,x(!0),y(null),w.current?.setPointerCapture(e.pointerId),ne(t,n)},onPointerMove:e=>{let t=te(e);if(C.current!==null){ne(t,C.current);return}y(t)},onPointerUp:e=>{C.current=null,x(!1),w.current?.releasePointerCapture(e.pointerId)},onPointerEnter:()=>h(!0),onPointerLeave:()=>{h(!1),C.current===null&&y(null)},children:(0,n.jsx)(`div`,{className:`ssg-scroll-hint-scrollbar-thumb`,style:{top:D.thumbTop,height:D.thumbHeight}})})]})}var hs=(e,t)=>e.findIndex(e=>e.key===t),gs=(e,t,n)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`col`)return n>=e.startCol&&n<=e.endCol;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.max(r.row,i.row),s=Math.min(r.col,i.col),c=Math.max(r.col,i.col);return t>=a&&t<=o&&n>=s&&n<=c},_s=(e,t)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`cell`){let{start:n,end:r}=e.range,i=Math.min(n.row,r.row),a=Math.max(n.row,r.row);return t>=i&&t<=a}return!1},vs=220,ys=8,bs=34,xs=16,Ss=({gridRootRef:t})=>{let[n,r]=(0,e.useState)(null),[i,a]=(0,e.useState)(null),o=(0,e.useRef)(null),s=(0,e.useRef)(null),c=(0,e.useRef)(0),l=n!==null,u=(0,e.useCallback)(()=>{let e=s.current;if(!e){a(null);return}let t=c.current*bs+xs,n=e.x,r=e.y,i=e.y-t;n=Math.max(ys,n),n=Math.min(n,window.innerWidth-vs-ys),r+t>window.innerHeight-ys&&(r=i),r=Math.max(ys,r),a(e=>e&&e.top===r&&e.left===n&&e.width===vs?e:{top:r,left:n,width:vs})},[]),d=(0,e.useCallback)(()=>{r(null),a(null),s.current=null,c.current=0,requestAnimationFrame(()=>{t.current?.focus()})},[t]),f=(0,e.useCallback)((e,n)=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),t.current?.blur(),s.current={x:e.clientX,y:e.clientY},c.current=n.length,r({params:e,items:n}),u()},[t,u]);return(0,e.useEffect)(()=>{if(!l)return;u();let e=()=>{u()},t=()=>{d()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0)}},[l,u,d]),(0,e.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;t&&(o.current?.contains(t)||d())};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[l,d]),(0,e.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),d())};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[l,d]),{contextMenuState:n,contextMenuLayout:i,contextMenuRef:o,isContextMenuOpen:l,openContextMenu:f,closeContextMenu:d}};function Cs({isOpen:e,themeClassName:t,items:a,layout:o,popoverRef:s,onRequestClose:c}){if(!e||!o)return null;let l={position:`fixed`,top:o.top,left:o.left,width:o.width,zIndex:1e3};return(0,r.createPortal)((0,n.jsx)(`div`,{ref:s,role:`menu`,onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{e.stopPropagation()},onContextMenu:e=>{e.preventDefault()},className:i(`ssg-menu-panel`,t),style:l,children:a.map((e,t)=>e.kind===`separator`?(0,n.jsx)(`div`,{className:`ssg-menu-separator`},e.id??`sep-${t}`):e.kind===`label`?(0,n.jsx)(`div`,{className:`ssg-menu-section-label`,role:`presentation`,children:e.label},e.id??`label-${t}`):e.kind===`custom`?(0,n.jsx)(`div`,{role:`none`,children:e.render({close:c})},e.id??`custom-${t}`):(0,n.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,onClick:()=>{e.onSelect(),c()},className:i(`ssg-menu-item`,e.danger&&`ssg-menu-item--danger`,e.disabled&&`ssg-menu-item--disabled`),children:[(0,n.jsx)(`span`,{className:`ssg-menu-icon`,children:e.icon}),(0,n.jsx)(`span`,{className:`ssg-menu-label`,children:e.label})]},e.id??`action-${t}`))}),document.body)}var ws=(e,t)=>{let n=new Set(e);return n.add(t),n},Ts=(e,t)=>{let n=new Set(e);return n.delete(t),n},Es=(e,t)=>{let n=new Set(e);for(let e of t)n.add(e);return n},Ds=(e,t)=>{let n=new Set(e);for(let e of t)n.delete(e);return n},Os=[],ks={},As={},js=[],Ms={compact:{rowHeight:28,headerHeight:32},standard:{rowHeight:36,headerHeight:40},comfortable:{rowHeight:44,headerHeight:48}},Ns={},Ps=[],Fs=300,Is=4,Ls=300;function Rs({rows:r=Os,dataSource:o,serverSideRefreshToken:d,onServerSideLoadError:p,onServerSideWriteError:m,columns:g,onRowsChange:_,onColumnsChange:v,rowKeyGetter:y,createRow:b,createOverflowColumn:T,rowHeight:D,autoHeight:ne=!1,estimateRowHeight:re,headerHeight:ie,density:ue=`standard`,theme:me=`light`,rowHeaderWidth:he=56,height:ge,maxHeight:_e,readOnly:ve=!1,dimReadOnlyCells:ye=!1,canEditCell:be,enableUndoRedo:xe=!0,enableClearOnDelete:Se=!0,editorEnterMove:Ce=`down`,undoHistoryLimit:we=100,onUndoRedoStateChange:Te,enableRangeSelection:Ee=!0,enableRowSelection:De=!1,rowSelectionMode:Oe=`multiple`,enableSelectAllRows:ke,rowSelection:je,selectedRowKeys:Me,onRowSelectionChange:Fe,enableGlobalFilter:Ie=!0,enableColumnFilter:Le=!0,enableSorting:Re=!0,enableColumnResize:ze=!0,autoSizeColumns:Be=!1,showCellOverflowTooltip:Ve=!1,showValidationMarks:We=!0,enableRowHover:Ge=!0,enableColumnHeaderHover:Ke=!0,enableColumnMenu:Je=!0,noMatchingRowsText:et=`一致する行がありません`,noRowsText:rt=`表示する行がありません`,showTopBar:it=!0,showBottomBar:at=!0,showTopBarSummary:ot=!0,showTopBarFilter:st=!0,globalFilterPlaceholder:ct,globalFilterIcon:lt,showTopBarCounts:ut=!0,showBottomBarCounts:dt=!0,showFilterChipBar:ft=!1,renderTopBar:gt,renderBottomBar:_t,className:vt,classNames:R,getRowClassName:yt,enableContextMenu:bt=!1,getContextMenuItems:xt,onContextMenuOpen:St,scrollHint:Tt,ref:Et,onStateChange:Dt}){let Ot=D??Ms[ue].rowHeight,z=ie??Ms[ue].headerHeight,jt=(0,e.useMemo)(()=>rs(Tt),[Tt]),Mt=(0,e.useRef)(null),Nt=(0,e.useRef)(null),Pt=(0,e.useRef)(null),It=(0,e.useRef)(null),Lt=(0,e.useRef)(!1),zt=(0,e.useRef)(null),Bt=(0,e.useRef)(null),Vt=(0,e.useRef)(null),[Ut,Wt]=(0,e.useState)(``),[Gt,qt]=(0,e.useState)(!1),[Jt,Yt]=(0,e.useState)(null),[Xt,Zt]=(0,e.useState)(null),{groupColumns:Qt,aggColumns:$t}=(0,e.useMemo)(()=>ir(g),[g]),en=o==null&&Qt.length>0,tn=(0,e.useMemo)(()=>en?[{key:$n,title:Qt.map(e=>e.title||e.key).join(` › `),width:240,minWidth:120,readOnly:!0,suppressAutoSize:!0},...g.filter(e=>e.rowGroup!==!0)]:g,[en,g,Qt]),B=(0,e.useMemo)(()=>tn.filter(e=>e.visible!==!1),[tn]),V=(0,e.useMemo)(()=>l(B),[B]),rn=(0,e.useMemo)(()=>y??((e,t)=>t),[y]),H=o!=null,sn=Re,cn=Le,ln=Ie,[U,W]=(0,e.useReducer)(oe,B,ae),un=(0,e.useRef)(U.columnWidths),fn=(0,e.useRef)(null),mn=(0,e.useRef)(null);mn.current===null&&(mn.current=new Map(g.map(e=>[e.key,{width:e.width,pinned:e.pinned,visible:e.visible}])));let hn=(0,e.useMemo)(()=>de(U.selection),[U.selection]),gn=(0,e.useMemo)(()=>u(V),[V]),[_n,vn]=(0,e.useState)(0),yn=gn.left.reduce((e,{column:t})=>e+(U.columnWidths[t.key]??t.width),0),bn=gn.right.reduce((e,{column:t})=>e+(U.columnWidths[t.key]??t.width),0),xn=gn.left.length>0,Sn=xn?he+yn:0,Cn=xn?0:he,wn=(0,e.useMemo)(()=>gn.center.map(({column:e})=>e),[gn.center]),Tn=(0,e.useMemo)(()=>wn.some(w),[wn]),On=_n-Sn-bn-Cn,kn=(0,e.useMemo)(()=>!Tn||_n<=0?Ns:E(wn,U.columnWidths,On),[Tn,_n,wn,U.columnWidths,On]),An=(0,e.useMemo)(()=>kn===Ns?U.columnWidths:{...kn,...U.columnWidths},[kn,U.columnWidths]);un.current=An;let jn=f(gn.left,U.columnWidths),Mn=f(gn.center,An),Nn=f(gn.right,U.columnWidths),Fn=(0,e.useMemo)(()=>h(`left`,gn.left,jn),[gn.left,jn]),In=(0,e.useMemo)(()=>h(`center`,gn.center,Mn),[gn.center,Mn]),Rn=(0,e.useMemo)(()=>h(`right`,gn.right,Nn),[gn.right,Nn]),G=(0,e.useMemo)(()=>({left:Fn,center:In,right:Rn}),[Fn,In,Rn]),Kn=G.left.entries.length>0,qn=G.right.entries.length>0,Jn=!Kn,Yn=he,Xn=Jn?he:0,Zn=Kn?Yn+G.left.totalWidth:0,Qn=G.right.totalWidth,rr=Xn+G.center.totalWidth,dr=Zn+rr+Qn,gr=(0,e.useRef)(new Map),yr=(0,e.useCallback)(e=>{let t=U.filters.columnFilters[e.key];if(t?.kind===`numberSet`||t?.kind===`textSet`||t?.kind===`dateSet`||t?.kind===`text`)return t.kind;let n=gr.current.get(e.key);if(n)return n;let i=_i({editorType:e.editor?.type,isServerSide:H,rowCount:r.length,getRawValueAt:t=>L(r[t],e)});return i.conclusive&&gr.current.set(e.key,i.filterType),i.filterType},[U.filters.columnFilters,H,r]),{filterPopoverState:K,filterPopoverLayout:br,filterPopoverRef:xr,filterTextInputRef:wr,filterSelectRef:Tr,isFilterPopoverOpen:Er,openedFilterColumn:q,openedFilterType:J,openColumnFilterPopover:Dr,closeColumnFilterPopover:Or,updateFilterPopoverDraft:kr,updateFilterPopoverNumberDraft:Ar,updateFilterPopoverTextDraft:jr,updateFilterPopoverDateDraft:Mr}=nn({visibleColumns:B,columnFilterValues:U.filters.columnFilters,enableColumnFilter:cn,gridRootRef:Mt,resolveColumnFilterType:yr}),{columnMenuLayout:Nr,columnMenuRef:Pr,isColumnMenuOpen:Fr,openedMenuColumnKey:Ir,openedMenuColumn:Lr,openColumnMenuFromButton:Rr,openColumnMenuFromContextMenu:zr,closeColumnMenu:Y}=Oo({visibleColumns:B,enableColumnMenu:Je,gridRootRef:Mt}),{activeToolPanelTab:Br,availableToolPanelTabs:Hr,toolPanelLayout:Ur,toolPanelFlashTick:Wr,toolPanelRef:Gr,openToolPanel:qr,closeToolPanel:Jr,moveToolPanel:Yr}=Bo({canUseFilterTab:cn,canUseColumnsTab:Je,canUseSortTab:sn,gridRootRef:Mt,alliedRef:xr,suppressEscape:Er,onSuppressedEscape:Or}),{contextMenuState:Xr,contextMenuLayout:Zr,contextMenuRef:Qr,isContextMenuOpen:$r,openContextMenu:ei,closeContextMenu:ti}=Ss({gridRootRef:Mt});(0,e.useEffect)(()=>{let e=B.reduce((e,t)=>(w(t)||(e[t.key]=t.width),e),{});W(a.resetColumnWidths(e))},[B]);let ni=U.filters.globalText,ri=U.filters.columnFilters,ii=(0,e.useDeferredValue)(ri),{order:ai,status:si,progress:ci}=Na({rows:r,baseOrder:(0,e.useMemo)(()=>Ye(r.length),[r.length]),columns:B,globalText:ni,enabled:ln}),ui=(0,e.useMemo)(()=>{let e=[];for(let t of B)pt(ii[t.key])&&e.push(t.key);return e.join(`\0`)},[B,ii]),fi=(0,e.useMemo)(()=>{let e=new Map;if(ui.length===0)return e;let t=new Set(ui.split(`\0`)),n=r.length;for(let i of B){if(!t.has(i.key))continue;let a=new Float64Array(n);for(let e=0;e<n;e+=1)a[e]=nt(L(r[e],i));e.set(i.key,a)}return e},[r,B,ui]),pi=(0,e.useMemo)(()=>Ct(r,ai,B,ii,fi),[r,ai,B,ii,fi]),mi=(0,e.useMemo)(()=>Gn(r,pi,B,U.sort),[r,pi,B,U.sort]);(0,e.useEffect)(()=>{},[H,Qt.length]);let hi=(0,e.useMemo)(()=>en?ar(r,mi,Qt,$t):null,[en,r,mi,Qt,$t]),gi=(0,e.useMemo)(()=>hi?or(hi,U.collapsedGroupKeys):null,[hi,U.collapsedGroupKeys]),vi=(0,e.useCallback)(e=>{W(a.toggleGroupCollapsed(e))},[W]),Ci=(0,e.useMemo)(()=>{if(gi){let{displayOrder:e,groups:t}=gi;return{getRowCount:()=>e.length,getRow:t=>r[e[t]],getSourceIndex:t=>{let n=e[t];return n>=0?n:void 0},getRowKey:n=>{let i=e[n];return tr(i)?er(t[nr(i)]):rn(r[i],i)},getGroupRow:n=>{let r=e[n];return tr(r)?t[nr(r)]:void 0}}}return{getRowCount:()=>mi.length,getRow:e=>r[mi[e]],getSourceIndex:e=>mi[e],getRowKey:e=>rn(r[mi[e]],mi[e])}},[gi,mi,r,rn]),wi=(0,e.useMemo)(()=>H?Ua({globalText:ln?ni:``,columnFilters:cn?ri:As,sort:sn?U.sort:js}):ks,[H,ln,ni,cn,ri,sn,U.sort]),Oi=(0,e.useMemo)(()=>H?Wa(wi):``,[H,wi]),[ki,Ai]=(0,e.useState)(wi),[Fi,Ii]=(0,e.useState)(Oi);(0,e.useEffect)(()=>{if(!H)return;let e=setTimeout(()=>{Ai(wi),Ii(Oi)},Ls);return()=>clearTimeout(e)},[H,Oi,wi]);let X=Ha({dataSource:o,rowKeyGetter:rn,query:ki,queryKey:Fi,refreshToken:d,onLoadError:p,onWriteError:m}),[Li,Ri]=(0,e.useState)(null),[zi,Bi]=(0,e.useState)(null),Vi=X.requestRange,Z=H?X.rowModel:Ci,Ji=(0,e.useMemo)(()=>H&&!X.canUpdateRows?()=>!1:be,[H,X.canUpdateRows,be]),Xi=H&&X.canUpdateRows?X.applyCellEdits:void 0,Zi=(0,e.useRef)(Z);Zi.current=Z;let Qi=(0,e.useCallback)(e=>{if(!bt||!xt)return;let t=e.target;if(!t)return;let n=t.closest(`[data-row-index]`);if(!n)return;let r=n.dataset.rowIndex;if(r===void 0)return;let i=Number(r);if(!Number.isInteger(i))return;let a=Z.getRow(i);if(!a)return;let o=Z.getRowKey(i)??i,s,c,l=t.closest(`[data-ssg-col-key]`),u=l?.dataset.ssgColKey;if(l&&u!==void 0){let e=hs(V,u);if(e<0)return;let t=V[e];s={type:`cell`,rowIndex:i,colIndex:e,rowKey:o,row:a,column:t,value:L(a,t)},c=gs(U.selection,i,e)}else s={type:`rowHeader`,rowIndex:i,rowKey:o,row:a},c=_s(U.selection,i);let d={target:s,clientX:e.clientX,clientY:e.clientY,selection:U.selection,activeCell:U.activeCell,isTargetSelected:c},f=xt(d);!f||f.length===0||(e.preventDefault(),St?.(d),ei(d,f))},[bt,xt,St,Z,V,U.selection,U.activeCell,ei]),{isAutosizing:$i,runAutosize:ea}=ya({rowModelRef:Zi,gridRootRef:Mt,columnWidthsRef:un,dispatch:W}),ta=(0,e.useRef)(B);ta.current=B;let na=(0,e.useRef)(!1);(0,e.useEffect)(()=>{let{shouldRun:e,nextHasAutoSizedOnMount:t}=xi({mode:Be,isServerSide:H,rowCount:r.length,hasAutoSizedOnMount:na.current});na.current=t,e&&ea(ta.current)},[Be,r,H,ea]);let Q=Z.getRowCount(),ra=gi?mi.length:Q,ia=jt!==null&&Q>=jt.minRows?jt:null,aa=(0,e.useMemo)(()=>{let e=null;return()=>e??=Array.from(mi,e=>r[e])},[mi,r]),oa=(0,e.useMemo)(()=>s(B,An),[B,An]),[sa,ca]=(0,e.useState)(0),[la,ua]=(0,e.useState)(0);(0,e.useEffect)(()=>{let e=zt.current;if(!e)return;ca(e.scrollTop),ua(e.clientHeight),vn(e.clientWidth);let t=()=>ca(e.scrollTop);e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(()=>{ua(e.clientHeight),vn(e.clientWidth)});return n.observe(e),()=>{e.removeEventListener(`scroll`,t),n.disconnect()}},[]);let da=G.center.entries,fa=(0,t.useVirtualizer)({horizontal:!0,count:da.length,getScrollElement:()=>zt.current,estimateSize:e=>da[e]?.paneLocalSize??da[e]?.column.width??120,overscan:8,useFlushSync:!1,scrollMargin:Zn}),pa=fa.getVirtualItems(),ma=re??Ot,ha=(0,e.useMemo)(()=>B.some(e=>e.autoHeight===!0),[B]),ga=!H&&ur(ne,ha,Q,5e4);(0,e.useEffect)(()=>{},[ne,ha,Q,H]);let _a=(0,e.useRef)(new Map),[va,ba]=(0,e.useState)(0),[xa,Sa]=(0,e.useState)(0),Ca=(0,e.useRef)(null),wa=(0,e.useRef)(new Set),Ta=(0,e.useMemo)(()=>ga?Ki(Q,ma,Z.getRowKey,_a.current):null,[ga,Q,ma,Z]),Ea=(0,e.useMemo)(()=>ga&&Ta?Yi(Ta):fr(Q,Ot),[ga,Ta,va,Q,Ot]),Da=(0,e.useMemo)(()=>ga?vr({headerHeight:z,viewportHeight:la,scrollTop:sa,overscan:20},Ea):_r({rowCount:Q,rowHeight:Ot,headerHeight:z,viewportHeight:la,scrollTop:sa,overscan:20,maxBodyPx:lr}),[ga,Ea,Q,Ot,z,la,sa]),Oa=Da.rows,ka=Da.rowIndexSet,ja=Oa.length>0?Oa[0].index:0,Ma=Oa.length>0?Oa[Oa.length-1].index:-1;(0,e.useEffect)(()=>{if(!H)return;let e=zt.current;e&&(e.scrollTop=0),ca(0)},[H,Fi]),(0,e.useEffect)(()=>{H&&(Ma<ja||Vi(ja,Ma+1))},[H,ja,Ma,Vi,Fi]);let Pa=Da.physicalBodyHeight,Fa=Da.translateY===0?void 0:`translateY(${Da.translateY}px)`,Ia=Da.scaleFactor,La=Da.windowBaseOffsetPx;(0,e.useLayoutEffect)(()=>{if(!ga||!Ta){Ca.current?.disconnect(),Ca.current=null,wa.current.clear();return}let e=zt.current;if(!e)return;let t=e.querySelectorAll(`[data-autoheight-cell]`);if(t.length>0){let n=new Map;t.forEach(e=>{let t=e.closest(`[data-row-index]`);if(!t)return;let r=Number(t.dataset.rowIndex);if(!Number.isFinite(r))return;let i=Math.ceil(e.getBoundingClientRect().height),a=n.get(r);(a===void 0||i>a)&&n.set(r,i)});let r=!1,i=1/0;if(n.forEach((e,t)=>{let n=Z.getRowKey(t)??t;qi(Ta,t,n,e)&&(r=!0,t<i&&(i=t))}),r){let t=e.scrollTop,n=Ea.rowAtContentY(t),r=t-Ea.rowTop(n);Gi(Ta,i),e.scrollTop=Ta.prefix[n]+r,ba(e=>e+1)}}let n=Ca.current??new ResizeObserver(()=>Sa(e=>e+1));Ca.current=n;let r=wa.current,i=new Set;t.forEach(e=>{i.add(e),r.has(e)||(n.observe(e),r.add(e))});let a=[];r.forEach(e=>{i.has(e)||a.push(e)}),a.forEach(e=>{n.unobserve(e),r.delete(e)})},[ga,Ta,Ea,Z,Oa,la,va,xa]),(0,e.useEffect)(()=>{let e=wa.current;return()=>{Ca.current?.disconnect(),Ca.current=null,e.clear()}},[]);let Ra=(0,e.useMemo)(()=>pa.map(e=>da[e.index]).filter(e=>!!e),[pa,da]),za=G.left.entries,Ba=G.right.entries,Va=(0,e.useMemo)(()=>{if(!U.activeCell)return null;let{row:e,col:t}=U.activeCell;if(e<0||e>=Q)return null;let n=C(G,t);return n?{pane:n.pane,rect:{left:n.extent.start,top:Ea.rowTop(e),width:n.extent.width,height:Ea.rowsHeight(e,e)}}:null},[U.activeCell,Q,G,Ea]),Ga=(0,e.useMemo)(()=>Va&&Va.pane===`center`?Va.rect:null,[Va]),Ka=(0,e.useCallback)(e=>Va&&Va.pane===e?Va.rect:null,[Va]),Ja=(0,e.useCallback)(e=>U.editingCell?Ka(e):null,[U.editingCell,Ka]),Ya=Kr(me)===`dark`?`ssg-theme-dark`:void 0;Vr(),Cr({scrollRef:zt,columnVirtualizer:fa,columnMeasurements:oa,totalScrollWidth:dr,physicalBodyHeight:Pa,headerHeight:z,leftPaneWidth:Zn,rightPaneWidth:Qn,centerLeadingWidth:Xn,activeCellRect:Ga,activeCell:U.activeCell,verticalScaleFactor:Ia});let Za=(0,e.useMemo)(()=>{if(je!==void 0)return je;if(Me!==void 0)return{type:`include`,rowKeys:Me}},[je,Me]),Qa=Za!==void 0,$a=ke??(De&&Oe===`multiple`),eo=U.rowSelection,to=P(eo,ra),no=(0,e.useRef)(eo);no.current=eo;let ro=(0,e.useRef)(Oe);ro.current=Oe;let oo=(0,e.useRef)(Fe);oo.current=Fe;let so=(0,e.useRef)(Qa);so.current=Qa;let lo=(0,e.useRef)(null),uo=(0,e.useCallback)(e=>{te(no.current,e)||oo.current?.(F(e)),so.current||W(a.setRowSelectionState(e))},[W]),fo=(0,e.useRef)(uo);fo.current=uo;let po=(0,e.useCallback)((e,t)=>{let n=Zi.current,r=Math.min(e,t),i=Math.max(e,t),a=[];for(let e=r;e<=i;e+=1)n.getRow(e)&&a.push(n.getRowKey(e)??e);return a},[]),mo=(0,e.useCallback)((e,t)=>{let n=Zi.current;if(!n.getRow(e))return;let r=n.getRowKey(e)??e;if(ro.current===`single`){lo.current=e,uo(A(r));return}if(t.shiftKey&&lo.current!==null){uo(j(po(lo.current,e)));return}lo.current=e,uo(k(no.current,r))},[uo,po]),ho=(0,e.useCallback)(e=>{let t=Zi.current;if(t.getRow(e)){if(ro.current===`single`){uo(A(t.getRowKey(e)??e));return}lo.current!==null&&uo(j(po(lo.current,e)))}},[uo,po]),go=(0,e.useCallback)(()=>{let e=P(no.current,ra);uo(e===`all`?ee():M())},[uo,ra]);(0,e.useEffect)(()=>{if(!Qa||!Za)return;let e=I(Za);te(no.current,e)||W(a.setRowSelectionState(e))},[Qa,Za,W]);let{updateSelectionFromPointer:_o,handleCellPointerDown:vo,handleCellPointerEnter:yo,handleNativeDragStart:xo,handleRowHeaderPointerDown:So,handleRowHeaderPointerEnter:wo,handleColumnHeaderPointerDown:To,handleColumnHeaderPointerEnter:Eo}=Sr({gridRootRef:Mt,bodyScrollRef:It,scrollContainerRef:zt,leftPaneScrollRef:Bt,rightPaneScrollRef:Vt,pointerClientRef:Nt,autoScrollFrameRef:Pt,uiState:U,dispatch:W,enableRangeSelection:Ee,enableSorting:sn,orderedColumns:V,filteredRowsLength:Q,visibleColumnsLength:B.length,paneLayout:G,leftLeadingWidth:Yn,centerLeadingWidth:Xn,rightLeadingWidth:0,headerHeight:z,rowMetrics:Ea,verticalScaleFactor:Ia,setHoveredRowIndex:Yt,setHoveredColumnIndex:Zt,enableRowHover:Ge,enableColumnHeaderHover:Ke,enableRowSelection:De,onGutterRowSelect:mo,onGutterRowSelectDrag:ho}),Do=(0,e.useRef)(()=>{}),ko=(0,e.useCallback)(e=>{e&&requestAnimationFrame(()=>{Do.current(e.row,e.col,`auto`)})},[]),Ao=xe&&!ve&&!H,{handleRowsChange:jo,undo:Mo,redo:No,canUndo:Fo,canRedo:Io,clearHistory:Lo}=Pn({rows:r,selection:U.selection,activeCell:U.activeCell,onRowsChange:_,dispatch:W,enabled:Ao,limit:we,onUndoRedoStateChange:Te,onAfterRestore:ko}),Ro=(0,e.useCallback)(()=>{if(Xi){let e=bi({getRow:e=>Z.getRow(e),columns:V,selection:U.selection,activeCell:U.activeCell,viewRowCount:Q,canWriteCell:(e,t,n,r)=>Ae({readOnly:ve,canEditCell:Ji},e,t,n,r)});e.length>0&&Xi(e);return}if(!jo)return;let{nextRows:e,changed:t}=yi({rows:r,resolveSourceIndex:e=>Z.getSourceIndex(e),columns:V,selection:U.selection,activeCell:U.activeCell,viewRowCount:Q,canWriteCell:(e,t,n,r)=>Ae({readOnly:ve,canEditCell:Ji},e,t,n,r)});t&&jo(e)},[Xi,Ji,jo,V,ve,Z,r,U.activeCell,U.selection,Q]),{isWholeGridSelected:zo,handleCopy:Vo,handlePaste:Uo}=dn({rows:r,rowModel:Z,visibleColumns:V,uiState:U,readOnly:ve,canEditCell:Ji,createRow:b,createOverflowColumn:T,onRowsChange:jo,onColumnsChange:v,applyServerSideCellEdits:Xi,dispatch:W}),Wo=(0,e.useCallback)(()=>{if(Q===0||B.length===0)return;let e={row:0,col:0},t={row:Q-1,col:B.length-1};W(a.startSelection(e)),W(a.updateSelection(t)),W(a.endSelection()),W(a.activateCell(e))},[W,Q,B.length]),Go=(0,e.useCallback)(e=>{let t=Z.getRow(e.row),n=V[e.col];if(!t||!n||!Ae({readOnly:ve,canEditCell:Ji},e.row,e.col,t,n)||n.editor?.type===`checkbox`)return;let r=L(t,n);Wt(String(r??``)),W(a.startEdit(e))},[Ji,W,Z,ve,V]),Ko=(0,e.useCallback)(e=>{if(!jo&&!Xi)return;let t=Z.getRow(e.row),n=V[e.col];if(!t||!n||n.editor?.type!==`checkbox`||!Ae({readOnly:ve,canEditCell:Ji},e.row,e.col,t,n))return;let i=Pe(L(t,n),n.editor);if(an(n,t,i).action===`reject`)return;if(Xi){Xi([{viewIndex:e.row,column:n,value:i}]);return}if(!jo)return;let a=Z.getSourceIndex(e.row);a!==void 0&&jo(He(r,a,n,i))},[Xi,Ji,jo,V,ve,Z,r]),{handleKeyDown:qo}=Ln({uiState:U,rowModel:Z,visibleColumns:V,readOnly:ve,canEditCell:Ji,setEditorInitialValue:Wt,dispatch:W,handleCopy:Vo,handleCellDoubleClick:Go,isWholeGridSelected:zo,selectEntireGrid:Wo,onUndo:Mo,onRedo:No,onClearSelection:Ro,enableClearOnDelete:Se,onToggleCheckboxCell:Ko,onToggleGroup:vi}),{startEditWithValue:Jo,commitEdit:Yo,cancelEdit:Zo}=Dn({uiState:U,rows:r,visibleColumns:V,rowModel:Z,setEditorInitialValue:Wt,onRowsChange:jo,applyServerSideCellEdits:Xi,dispatch:W,gridRootRef:Mt,editorActionGuardRef:Lt}),$o=U.editingCell?V[U.editingCell.col]:void 0,es=U.editingCell?Z.getRow(U.editingCell.row):void 0,is=U.editingCell&&$o&&es?{row:es,rowIndex:U.editingCell.row,sourceRowIndex:Z.getSourceIndex(U.editingCell.row)??U.editingCell.row,rowKey:Z.getRowKey(U.editingCell.row)??U.editingCell.row,colIndex:U.editingCell.col,column:$o,value:L(es,$o)}:null,as=(0,e.useCallback)(e=>{let t=Z.getRow(e.row),n=V[e.col];if(!t||!n||!Ae({readOnly:ve,canEditCell:Ji},e.row,e.col,t,n)||n.editor?.type===`checkbox`)return;let r=L(t,n);Jo(e,String(r??``))},[Ji,Z,ve,Jo,V]),os=(0,e.useMemo)(()=>{if(!U.selection)return null;if(U.selection.type===`cell`){let e=se(U.selection.range);return{extents:x(G,e.start.col,e.end.col),startRow:e.start.row,endRow:e.end.row}}if(U.selection.type===`row`){let e=ce(U.selection.startRow,U.selection.endRow);return{extents:S(G),startRow:e.startRow,endRow:e.endRow}}let e=le(U.selection.startCol,U.selection.endCol);return{extents:x(G,e.startCol,e.endCol),startRow:0,endRow:Math.max(Q-1,0)}},[U.selection,G,Q]),ss=(0,e.useMemo)(()=>{if(!os)return null;let e=pr(os.startRow,os.endRow,ja,Ma);return e?{top:Ea.rowTop(e.start),height:Ea.rowsHeight(e.start,e.end)}:null},[os,Ea,ja,Ma]),cs=(0,e.useCallback)(e=>{if(!os||!ss)return null;let t=os.extents[e];return t?{left:t.start,top:ss.top,width:t.width,height:ss.height}:null},[os,ss]),ls=(0,e.useCallback)(e=>{if(e.preventDefault(),e.button===0&&!(Q===0||B.length===0)){if(Mt.current?.focus(),$a){go();return}if(zo){W(a.clearSelection()),W(a.activateCell(null));return}Wo()}},[W,Q,zo,Wo,B.length,$a,go]),us=(0,e.useCallback)(e=>{Yt(t=>t===e?null:t)},[]),ds=(0,e.useCallback)(e=>{Zt(t=>t===e?null:t)},[]),fs=(0,e.useCallback)(()=>{qt(!0)},[]),ps=(0,e.useCallback)(()=>{qt(!1)},[]),vs=(0,e.useCallback)((e,t)=>{t.preventDefault(),t.stopPropagation();let n=t.timeStamp,r=fn.current;if(r&&r.key===e.key&&n-r.time<Fs&&Math.abs(t.clientX-r.x)<Is){fn.current=null,ea([e]);return}fn.current={key:e.key,time:n,x:t.clientX},W(a.startColumnResize(e.key,t.clientX,un.current[e.key]??e.width,e.minWidth??60,e.maxWidth))},[W,ea]),ys=(0,e.useCallback)((e,t)=>{if(Y(),!v)return;let n=g.find(t=>t.key===e);n&&(n.pinned??void 0)!==t&&(v(g.map(n=>{let r=un.current[n.key]??n.width;return n.key===e?{...n,width:r,pinned:t}:r===n.width?n:{...n,width:r}})),W(a.stopEdit()),W(a.clearSelection()),W(a.activateCell(null)))},[Y,g,W,v]),bs=(0,e.useCallback)(e=>{Y();let t=B.find(t=>t.key===e);t&&ea([t])},[Y,ea,B]),xs=(0,e.useCallback)(()=>{Y(),ea(B)},[Y,ea,B]),Rs=(0,e.useMemo)(()=>g.map(e=>({key:e.key,title:e.title??e.key,visible:e.visible!==!1,pane:c(e)})),[g]),zs=(0,e.useCallback)(()=>{Y(),qr(`columns`)},[Y,qr]),Bs=(0,e.useMemo)(()=>B.map(e=>({key:e.key,title:e.title??e.key})),[B]),Vs=(0,e.useCallback)(()=>{Y(),qr(`sort`)},[Y,qr]),Hs=(0,e.useCallback)(e=>{Y(),Dr(e)},[Y,Dr]),Us=(0,e.useMemo)(()=>{let e=[],t=(t,n)=>{let r=ri[t.key];!r||!tt(r)||e.push({columnKey:t.key,title:t.title||t.key,summaryText:li(r,r.kind===`dateSet`?qe(t.dateFilterPresets):void 0),isHidden:n})};for(let e of V)t(e,!1);for(let e of g)e.visible===!1&&t(e,!0);return e},[ri,g,V]),Ws=(0,e.useMemo)(()=>B.filter(e=>!!e.filterType&&!tt(ri[e.key])).map(e=>({key:e.key,title:e.title||e.key})),[ri,B]),Gs=(0,e.useCallback)(()=>{Y(),qr(`filter`)},[Y,qr]),Ks=(0,e.useCallback)(()=>{Br===`filter`?Jr():qr(`filter`)},[Br,Jr,qr]),qs=(0,e.useCallback)(e=>{let t=$.current,n=zt.current;if(!t)return;let r=t.orderedColumns.findIndex(t=>t.key===e);if(r<0)return;let i=t.orderedColumns[r];if(n){let e=C(t.paneLayout,r);if(e&&e.pane===`center`){let r=Wi({cellLeft:t.leftPaneTotalWidth+t.centerLeadingWidth+e.extent.start,cellWidth:e.extent.width,leftPaneWidth:t.leftPaneTotalWidth,rightPaneWidth:t.rightPaneTotalWidth,viewportWidth:n.clientWidth,currentScrollLeft:n.scrollLeft,align:`auto`,maxScrollLeft:n.scrollWidth-n.clientWidth});r!==n.scrollLeft&&n.scrollTo({left:r,behavior:`auto`})}}let a=()=>{let t=Mt.current?.querySelectorAll(`[data-ssg-col-key]`);return t?Array.from(t).find(t=>t.dataset.ssgColKey===e)??null:null},o=e=>{if(!Mt.current)return;let t=a();if(t===null){e<8&&requestAnimationFrame(()=>o(e+1));return}Dr(i),t.classList.remove(`ssg-header-cell--jump-flash`),t.offsetWidth,t.classList.add(`ssg-header-cell--jump-flash`),t.addEventListener(`animationend`,()=>{t.classList.remove(`ssg-header-cell--jump-flash`)},{once:!0})};requestAnimationFrame(()=>{o(0)})},[Mt,Dr]),Js=(0,e.useCallback)(e=>{W(a.clearColumnFilter(e))},[W]),Ys=(0,e.useCallback)(()=>{W(a.setAllFilters({globalText:U.filters.globalText,columnFilters:{}}))},[W,U.filters.globalText]),Xs=(0,e.useCallback)(()=>{W(a.setGlobalFilter(``))},[W]),Zs=(0,e.useCallback)((e,t)=>{if(!v)return;let n=g.find(t=>t.key===e);n&&n.visible!==!1!==t&&(!t&&g.filter(e=>e.visible!==!1).length<=1||(v(g.map(n=>{let r=un.current[n.key]??n.width;return n.key===e?{...n,width:r,visible:t}:r===n.width?n:{...n,width:r}})),W(a.stopEdit()),W(a.clearSelection()),W(a.activateCell(null))))},[g,W,v]),Qs=(0,e.useCallback)(()=>{v&&g.some(e=>e.visible===!1)&&(v(g.map(e=>{let t=un.current[e.key]??e.width,n=t!==e.width,r=e.visible===!1;return!n&&!r?e:r?{...e,width:t,visible:!0}:{...e,width:t}})),W(a.stopEdit()),W(a.clearSelection()),W(a.activateCell(null)))},[g,W,v]),$s=(0,e.useCallback)(()=>{if(!v)return;let e=V[0]?.key;e!==void 0&&g.some(t=>t.visible!==!1&&t.key!==e)&&(v(g.map(t=>{let n=un.current[t.key]??t.width,r=n!==t.width,i=t.visible!==!1&&t.key!==e;return!r&&!i?t:i?{...t,width:n,visible:!1}:{...t,width:n}})),W(a.stopEdit()),W(a.clearSelection()),W(a.activateCell(null)))},[g,W,v,V]),ec=(0,e.useCallback)((e,t)=>{if(!v||e.length!==g.length)return;let n=new Map(g.map(e=>[e.key,e]));if(!e.every(e=>n.has(e)))return;let r=l(e.map(e=>{let r=n.get(e),i=un.current[r.key]??r.width,a=t?.has(e)?t.get(e):r.pinned,o=i!==r.width,s=(r.pinned??void 0)!==(a??void 0);return o||s?{...r,width:i,pinned:a}:r}));r.length===g.length&&r.every((e,t)=>{let n=g[t];return!!n&&n.key===e.key&&n.width===e.width&&(n.pinned??void 0)===(e.pinned??void 0)})||(v(r),W(a.stopEdit()),W(a.clearSelection()),W(a.activateCell(null)))},[g,W,v]),tc=(0,e.useCallback)(e=>{ec(e)},[ec]),{onColumnDragHandlePointerDown:nc,leftIndicatorRef:rc,centerIndicatorRef:ic,rightIndicatorRef:ac,applyReorderSettle:oc}=oi({enabled:!!v,columns:g,paneLayout:G,leftPaneScrollRef:Bt,rightPaneScrollRef:Vt,bodyScrollRef:It,scrollContainerRef:zt,leftLeadingWidth:Yn,centerLeadingWidth:Xn,rightLeadingWidth:0,applyColumnOrderAndPin:ec});(0,e.useLayoutEffect)(()=>{oc()},[G,oc]);let sc=v?nc:void 0,cc={position:`absolute`,top:0,height:z+Pa,transform:`translateX(-1px)`,pointerEvents:`none`,zIndex:8,display:`none`},lc=(0,e.useCallback)(()=>{if(!v)return;let e=mn.current;if(!e)return;let t=Si(g,e,un.current);t!==null&&(v(t),W(a.stopEdit()),W(a.clearSelection()),W(a.activateCell(null)))},[g,W,v]),uc=(0,e.useCallback)(()=>{Y(),lc()},[Y,lc]),dc=(0,e.useCallback)(e=>q?L(r[e],q):void 0,[r,q]),{options:fc,allValues:pc,status:mc,progress:hc}=Aa({column:q,rowCount:r.length,getRawValueAt:dc}),gc=J===`dateSet`,_c=(0,e.useMemo)(()=>gc?di(fc):fc,[gc,fc]),vc=(0,e.useMemo)(()=>gc?new Set(_c.map(e=>e.value)):pc,[gc,_c,pc]),yc=q?U.filters.columnFilters[q.key]:void 0,bc=(0,e.useMemo)(()=>{let e=Xe(yc)?yc:Ze(yc)||Qe(yc)||$e(yc)?yc.set:null;return e?{mode:e.mode===`exclude`?`exclude`:`include`,values:new Set(e.values)}:null},[yc]),xc=!(q?.filterOptions&&q.filterOptions.length>0),Sc=(0,e.useCallback)((e,t)=>{let n=q?.key===e?J:void 0,r=U.filters.columnFilters[e];if(n===`numberSet`){let e=Ze(r)?r.condition:null;return!e&&!t?null:{kind:`numberSet`,condition:e,set:t}}if(n===`textSet`){let e=Qe(r)?r.condition:null;return!e&&!t?null:{kind:`textSet`,condition:e,set:t}}if(n===`dateSet`){let e=$e(r)?r.condition:null;return!e&&!t?null:{kind:`dateSet`,condition:e,set:t}}return null},[q,U.filters.columnFilters,J]),Cc=J===`numberSet`||J===`textSet`||J===`dateSet`,wc=(0,e.useCallback)((e,t,n)=>{let r=q?.key===e&&Cc,i=t.mode===`include`?t.values.size:n-t.values.size;if(i>=n){if(r){let t=Sc(e,null);if(t){W(a.setColumnFilter(e,t));return}}W(a.clearColumnFilter(e));return}let o=i<=0?{mode:`include`,values:[]}:{mode:t.mode,values:Array.from(t.values)};if(r){let t=Sc(e,o);if(t){W(a.setColumnFilter(e,t));return}}let s={kind:`set`,...o};W(a.setColumnFilter(e,s))},[W,q,Cc,Sc]),Tc=(0,e.useCallback)(e=>{if(!K)return;let t=_c.length,n=bc,r;r=Xa(n,e)?n===null?xc?{mode:`exclude`,values:new Set([e])}:{mode:`include`,values:Ts(vc,e)}:n.mode===`include`?{mode:`include`,values:Ts(n.values,e)}:{mode:`exclude`,values:ws(n.values,e)}:n.mode===`include`?{mode:`include`,values:ws(n.values,e)}:{mode:`exclude`,values:Ts(n.values,e)},wc(K.columnKey,r,t)},[K,bc,xc,vc,_c,wc]),Ec=(0,e.useCallback)((e,t)=>{if(!K)return;let n=K.columnKey,r=_c.length;if(e===`all`){wc(n,t?{mode:`exclude`,values:new Set}:{mode:`include`,values:new Set},r);return}let i=bc,a;if(t){if(i===null){wc(n,{mode:`exclude`,values:new Set},r);return}a=i.mode===`include`?{mode:`include`,values:Es(i.values,e)}:{mode:`exclude`,values:Ds(i.values,e)}}else a=i===null?xc?{mode:`exclude`,values:new Set(e)}:{mode:`include`,values:Ds(vc,e)}:i.mode===`include`?{mode:`include`,values:Ds(i.values,e)}:{mode:`exclude`,values:Es(i.values,e)};wc(n,a,r)},[K,bc,xc,vc,_c,wc]),Dc=(0,e.useCallback)(e=>{K&&wc(K.columnKey,{mode:`include`,values:new Set(e)},_c.length)},[K,wc,_c]),Oc=(0,e.useCallback)(()=>{K&&(W(a.clearColumnFilter(K.columnKey)),J===`numberSet`&&Ar(wt),J===`textSet`&&jr(Ft),J===`dateSet`&&Mr(Ht))},[W,K,Ar,jr,Mr,J]),kc=(0,e.useCallback)(e=>{let t=U.filters.columnFilters[e];return Ze(t)||Qe(t)||$e(t)?t.set:Xe(t)?{mode:t.mode,values:t.values}:null},[U.filters.columnFilters]),Ac=(0,e.useCallback)(e=>{if(Ar(e),!K||J!==`numberSet`)return;let t=K.columnKey,n=kt(e),r=kc(t);if(!n&&!r){U.filters.columnFilters[t]&&W(a.clearColumnFilter(t));return}W(a.setColumnFilter(t,{kind:`numberSet`,condition:n,set:r}))},[Ar,K,kc,U.filters.columnFilters,W,J]),jc=(0,e.useCallback)(e=>{if(jr(e),!K||J!==`textSet`)return;let t=K.columnKey,n=Rt(e),r=kc(t);if(!n&&!r){U.filters.columnFilters[t]&&W(a.clearColumnFilter(t));return}W(a.setColumnFilter(t,{kind:`textSet`,condition:n,set:r}))},[jr,K,kc,U.filters.columnFilters,W,J]),Mc=(0,e.useCallback)(e=>{if(Mr(e),!K||J!==`dateSet`)return;let t=K.columnKey,n=Kt(e),r=kc(t);if(!n&&!r){U.filters.columnFilters[t]&&W(a.clearColumnFilter(t));return}W(a.setColumnFilter(t,{kind:`dateSet`,condition:n,set:r}))},[Mr,K,kc,U.filters.columnFilters,W,J]),Nc=(0,e.useCallback)(()=>{if(J===`textSet`){jc(Ft);return}if(J===`dateSet`){Mc(Ht);return}Ac(wt)},[jc,Mc,Ac,J]),Pc=(0,e.useCallback)(()=>{if(!K)return;let e=K.columnKey,t=Sc(e,null);if(t){W(a.setColumnFilter(e,t));return}W(a.clearColumnFilter(e))},[K,Sc,W]),Fc=(0,e.useCallback)(()=>{if(!K)return;let e=J??`text`;if(e===`set`||e===`numberSet`||e===`textSet`||e===`dateSet`){Or();return}if(e===`number`){let e=K.numberDraft?At(K.numberDraft):null;if(!e){W(a.clearColumnFilter(K.columnKey)),Or();return}W(a.setColumnFilter(K.columnKey,e)),Or();return}let t=e===`select`?K.draftValue:K.draftValue.trim();if(!t){W(a.clearColumnFilter(K.columnKey)),Or();return}let n=e===`select`?{kind:`select`,value:t}:e===`date`?{kind:`date`,value:t}:e===`custom`?{kind:`custom`,value:t}:{kind:`text`,value:t};W(a.setColumnFilter(K.columnKey,n)),Or()},[Or,W,K,J]),Ic=(0,e.useCallback)(()=>{K&&(W(a.clearColumnFilter(K.columnKey)),Or())},[Or,W,K]),Lc=(0,e.useCallback)((e,t)=>{if(Y(),!Re)return;let n=zn(U.sort,e,t,!1);W(n.length===0?a.clearSort():a.setSort(n))},[Y,W,Re,U.sort]),Rc=(0,e.useCallback)((e,t)=>{if(!Re)return;let n=Bn(U.sort,e,t);W(a.setSort(n))},[W,Re,U.sort]),zc=(0,e.useCallback)((e,t)=>{if(!Re)return;let n=Vn(U.sort,e,t);W(a.setSort(n))},[W,Re,U.sort]),Bc=(0,e.useCallback)((e,t)=>{if(!Re)return;let n=Hn(U.sort,e,t);W(a.setSort(n))},[W,Re,U.sort]),Vc=(0,e.useCallback)(e=>{if(!Re)return;let t=Un(U.sort,e);W(t.length===0?a.clearSort():a.setSort(t))},[W,Re,U.sort]),Hc=(0,e.useCallback)(()=>{Re&&W(a.clearSort())},[W,Re]),Uc=(0,e.useCallback)((e,t)=>{if(!Re)return;let n=Wn(U.sort,e,t);W(a.setSort(n))},[W,Re,U.sort]),Wc=(0,e.useCallback)((e,t,i,a,o)=>{let s=L(e,i);if(i.renderCell){let n=Z.getSourceIndex(t)??t;return i.renderCell({row:e,rowIndex:t,sourceRowIndex:n,rowKey:Z.getRowKey(t)??t,colIndex:a,value:s,column:i,isActive:o.isActive,isSelected:o.isSelected,isEditing:o.isEditing,readOnly:o.readOnly,setValue:n=>{if(an(i,e,n).action===`reject`)return;if(Xi){Xi([{viewIndex:t,column:i,value:n}]);return}if(!jo)return;let a=Z.getSourceIndex(t);if(a===void 0)return;let o=He(r,a,i,n);jo(o)}})}return i.editor?.type===`checkbox`?(0,n.jsx)(qa,{checked:Ne(s,i.editor),readOnly:o.readOnly,onToggle:()=>Ko({row:t,col:a})}):(0,n.jsx)(`span`,{children:i.valueFormatter?i.valueFormatter({value:s,row:e,column:i}):String(s??``)})},[Z,jo,r,Ko,Xi]),{slotContext:Gc}=En({rows:r,viewRowCount:ra,getFilteredRows:aa,columns:g,visibleColumns:B,uiState:U,setGlobalFilterText:(0,e.useCallback)(e=>{W(a.setGlobalFilter(e))},[W]),globalFilterStatus:si,globalFilterProgress:ci}),Kc=(0,e.useMemo)(()=>({width:he,minWidth:he}),[he]),qc=Q===0,Jc=(e,t,n)=>({position:`sticky`,...e===`left`?{left:0}:{right:0},width:t,minWidth:t,flexShrink:0,alignSelf:`stretch`,zIndex:2,...n?e===`left`?{borderRight:`1px solid var(--ssg-pane-border)`,boxShadow:`var(--ssg-pane-shadow-left)`}:{borderLeft:`1px solid var(--ssg-pane-border)`,boxShadow:`var(--ssg-pane-shadow-right)`}:{}}),Yc=(()=>{if(!q)return`(なし)`;let e=U.filters.columnFilters[q.key];if(Xe(e))return e.mode===`exclude`?`${e.values.length}件を除外中`:`${e.values.length}件を選択中`;if(mt(e))return e.raw;let t=ht(e);return t.trim()?t:`(なし)`})(),Xc=q?qe(q.dateFilterPresets):void 0,Zc=yc&&tt(yc)?li(yc,Xc):`フィルターなし`,Qc=q?(0,n.jsx)(io,{themeClassName:Ya,isOpen:!!K,title:q.title||q.key,filterType:J??`text`,isServerSide:H,draftValue:K?.draftValue??``,numberConditionDraft:K?.numberDraft??null,onNumberConditionDraftChange:Ac,textConditionDraft:K?.textDraft??null,onTextConditionDraftChange:jc,dateConditionDraft:K?.dateDraft??null,onDateConditionDraftChange:Mc,datePresets:Xc,onComboConditionClear:Nc,onComboSelectionClear:Pc,comboSummaryText:Zc,currentValueText:Yc,layout:br,selectOptions:_c,setSelection:bc,optionsStatus:mc,optionsProgress:hc,popoverRef:xr,textInputRef:wr,selectRef:Tr,onRequestClose:Or,onDraftChange:kr,onApply:Fc,onClear:Ic,onSetValueToggle:Tc,onSetSelectAllChange:Ec,onSetClear:Oc,onSetReplaceSelection:Dc}):null,$c=Lr?(0,n.jsx)(Po,{themeClassName:Ya,isOpen:Fr,title:Lr.title||Lr.key,columnKey:Lr.key,canFilter:cn&&!!Lr.filterType,onOpenFilter:()=>Hs(Lr),canSort:sn,sortDirection:U.sort.find(e=>e.columnKey===Lr.key)?.direction??null,onSortChange:e=>Lc(Lr.key,e),onOpenSortManager:Vs,canManageFilters:cn,onOpenFilterManager:Gs,pinned:Lr.pinned,canChangePinned:!!v,layout:Nr,popoverRef:Pr,onPinnedChange:ys,onAutosizeColumn:bs,onAutosizeAllColumns:xs,onOpenColumnChooser:zs,canResetColumns:!!v,onResetColumns:uc,onRequestClose:Y}):null,el=ln&&ni.trim().length>0,tl=Us.length+ +!!el,nl=(0,n.jsx)(Ho,{themeClassName:Ya,activeTab:Br,flashTick:Wr,tabs:Hr.map(e=>e===`filter`?{tab:e,label:`フィルター`,badge:tl}:e===`sort`?{tab:e,label:`並び替え`,badge:U.sort.length}:{tab:e,label:`列`}),layout:Ur,panelRef:Gr,onSelectTab:qr,onRequestClose:Jr,onPanelMove:Yr,children:Br===null?null:{filter:()=>(0,n.jsx)(ts,{entries:Us,addableColumns:Ws,showGlobalFilterRow:el,globalFilterText:ni,canFilter:cn,onEditFilter:qs,onAddFilter:qs,onClearFilter:Js,onClearAllFilters:Ys,onClearGlobalFilter:Xs}),columns:()=>(0,n.jsx)(Xo,{items:Rs,canToggle:!!v,onToggleColumnVisibility:Zs,onShowAllColumns:Qs,onHideAllColumns:$s,onResetColumns:lc,onReorderColumns:tc}),sort:()=>(0,n.jsx)(Qo,{entries:U.sort,columns:Bs,canSort:sn,onAddLevel:Rc,onChangeDirection:zc,onChangeColumn:Bc,onRemoveLevel:Vc,onClearAll:Hc,onMove:Uc})}[Br]()}),rl=(0,n.jsx)(Cs,{themeClassName:Ya,isOpen:$r,items:Xr?.items??Ps,layout:Zr,popoverRef:Qr,onRequestClose:ti}),il=Er||Fr||Br!==null||$r,al=ot,ol=st&&ln,sl=it?pn(gt,Gc,al||ol?(0,n.jsx)(co,{context:Gc,showSummary:al,showFilter:ol,showCounts:ut,globalFilterPlaceholder:ct,globalFilterIcon:lt,onFilterSummaryClick:cn?Ks:void 0}):null):null,cl=at?pn(_t,Gc,(0,n.jsx)(ao,{context:Gc,showCounts:dt})):null,ll=ge===void 0&&_e===void 0?void 0:{...ge===void 0?{}:{height:ge},maxHeight:_e??(ge===void 0?void 0:`none`)},$=(0,e.useRef)(null);$.current={dispatch:W,rowModel:Z,viewRowCount:Q,leafRowCount:ra,groupTree:hi,rowMetrics:Ea,paneLayout:G,orderedColumns:V,columns:g,onColumnsChange:v,uiState:U,headerHeight:z,verticalScaleFactor:Ia,leftPaneTotalWidth:Zn,rightPaneTotalWidth:Qn,centerLeadingWidth:Xn,windowFirstRow:ja,windowLastRow:Ma,physicalBodyHeight:Pa,rows:r,isServerSide:H,serverSideRefresh:X.refresh,resolvedRowKeyGetter:rn,openFilterManager:()=>{qr(`filter`)},closeFilterManager:()=>{Br===`filter`&&Jr()},undoRows:Mo,redoRows:No,canUndoRows:Fo,canRedoRows:Io,clearUndoHistory:Lo};let ul=(0,e.useCallback)((e,t)=>{let n=zt.current,r=$.current;!n||!r||n.scrollTo({top:e===null?n.scrollTop:hr(e,r.verticalScaleFactor),left:t===null?n.scrollLeft:t,behavior:`auto`})},[]),dl=(0,e.useCallback)((e,t)=>{let n=zt.current,r=$.current;if(!n||!r||r.viewRowCount===0)return null;let i=Math.min(Math.max(e,0),r.viewRowCount-1);return Ui({rowTop:r.rowMetrics.rowTop(i),rowHeight:r.rowMetrics.rowsHeight(i,i),headerHeight:r.headerHeight,viewportHeight:n.clientHeight,currentScrollTop:mr(n.scrollTop,r.verticalScaleFactor),align:t})},[]),fl=(0,e.useCallback)((e,t)=>{let n=zt.current,r=$.current;if(!n||!r)return null;let i=C(r.paneLayout,e);return!i||i.pane!==`center`?null:Wi({cellLeft:r.leftPaneTotalWidth+r.centerLeadingWidth+i.extent.start,cellWidth:i.extent.width,leftPaneWidth:r.leftPaneTotalWidth,rightPaneWidth:r.rightPaneTotalWidth,viewportWidth:n.clientWidth,currentScrollLeft:n.scrollLeft,align:t})},[]),pl=(0,e.useCallback)((e,t,n)=>{ul(dl(e,n),fl(t,n))},[ul,fl,dl]);(0,e.useEffect)(()=>{Do.current=pl},[pl]),(0,e.useImperativeHandle)(Et,()=>{let e=e=>{let t=$.current;if(!t)return null;let n=e=>t.rowModel.getRow(e),r=Di(e);if(r===`raw`)return t.isServerSide?(console.warn(`SpreadsheetGrid: scope 'raw' は serverSide では未ロード行を取得できないため、'view'(ロード済みビュー行)として扱います。全件エクスポートはサーバ側での実施を推奨します。`),{getRow:n,startRow:0,endRow:t.viewRowCount,columns:t.orderedColumns}):{getRow:e=>t.rows[e],startRow:0,endRow:t.rows.length,columns:t.orderedColumns};if(r===`rendered`)return{getRow:n,startRow:t.windowFirstRow,endRow:t.windowLastRow>=t.windowFirstRow?t.windowLastRow+1:t.windowFirstRow,columns:t.orderedColumns};if(r===`selection`){let e=t.uiState.selection;if(!e)return null;if(e.type===`cell`){let r=se(e.range);return{getRow:n,startRow:r.start.row,endRow:r.end.row+1,columns:t.orderedColumns.slice(r.start.col,r.end.col+1)}}if(e.type===`row`){let r=ce(e.startRow,e.endRow);return{getRow:n,startRow:r.startRow,endRow:r.endRow+1,columns:t.orderedColumns}}let r=le(e.startCol,e.endCol);return{getRow:n,startRow:0,endRow:t.viewRowCount,columns:t.orderedColumns.slice(r.startCol,r.endCol+1)}}return{getRow:n,startRow:0,endRow:t.viewRowCount,columns:t.orderedColumns}},t=e=>e.filter(e=>e.key!==$n),n=n=>{let r=e(n?.scope??`view`);return r?Ti({getRow:r.getRow,startRow:r.startRow,endRow:r.endRow,columns:t(r.columns),delimiter:n?.delimiter,includeHeaders:n?.includeHeaders,bom:n?.bom}):n?.bom?``:``},r=n=>{let r=e(n?.scope??`view`);return r?Ei({getRow:r.getRow,startRow:r.startRow,endRow:r.endRow,columns:t(r.columns)}):{columns:[],rows:[]}};return{scrollToRow:(e,t)=>ul(dl(e,t?.align??`auto`),null),scrollToCell:(e,t,n)=>pl(e,t,n?.align??`auto`),scrollToTop:()=>{zt.current?.scrollTo({top:0,behavior:`auto`})},scrollToBottom:()=>{let e=zt.current,t=$.current;!e||!t||e.scrollTo({top:Math.max(t.headerHeight+t.physicalBodyHeight-e.clientHeight,0),behavior:`auto`})},getVisibleRowRange:()=>{let e=$.current;return!e||e.windowLastRow<e.windowFirstRow?null:{startIndex:e.windowFirstRow,endIndex:e.windowLastRow+1}},getActiveCell:()=>{let e=$.current?.uiState.activeCell;return e?{row:e.row,col:e.col}:null},setActiveCell:(e,t)=>{let n=$.current;n&&(n.dispatch(a.activateCell(e)),e&&t?.scrollIntoView&&pl(e.row,e.col,`auto`))},getSelection:()=>$.current?.uiState.selection??null,selectCell:(e,t,n)=>{let r=$.current;if(!r)return;let i={row:e,col:t};r.dispatch(a.startSelection(i)),r.dispatch(a.endSelection()),n?.scrollIntoView&&pl(e,t,`auto`)},selectRange:(e,t)=>{let n=$.current;n&&(n.dispatch(a.startSelection(e.start)),n.dispatch(a.updateSelection(e.end)),n.dispatch(a.endSelection()),t?.scrollIntoView&&pl(e.end.row,e.end.col,`auto`))},clearSelection:()=>{$.current?.dispatch(a.clearSelection())},getSelectedRows:()=>{let e=$.current;if(!e)return[];let t=e.uiState.selection;if(!t)return[];let n=[],r=t=>{let r=e.rowModel.getRow(t);r&&n.push(r)};if(t.type===`cell`){let e=se(t.range);for(let t=e.start.row;t<=e.end.row;t+=1)r(t)}else if(t.type===`row`){let e=ce(t.startRow,t.endRow);for(let t=e.startRow;t<=e.endRow;t+=1)r(t)}else for(let t=0;t<e.viewRowCount;t+=1)r(t);return n},exportCsv:e=>n(e),downloadCsv:(e,t)=>{if(typeof document>`u`)return;let r=n({...t,bom:t?.bom??!0}),i=new Blob([r],{type:`text/csv;charset=utf-8;`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e??`export.csv`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},getExportData:e=>r(e),getState:()=>{let e=$.current;return e?Mi(e.uiState.columnWidths,e.uiState.filters,e.uiState.sort,ji(e.columns)):Mi({},{globalText:``,columnFilters:{}},[],[])},applyState:e=>{let t=$.current;if(!t)return;let n=Ni(e);t.onColumnsChange&&n.columns&&t.onColumnsChange(Pi(t.columns,n.columns,n.columnWidths)),t.dispatch(a.resetColumnWidths(n.columnWidths)),t.dispatch(a.setAllFilters(n.filters)),t.dispatch(a.setSort(n.sort))},getRowSelection:()=>{let e=$.current;return e?F(e.uiState.rowSelection):{type:`include`,rowKeys:[]}},setRowSelection:e=>{fo.current(I(e))},getSelectedRowKeys:()=>{let e=$.current;if(!e)return[];let t=e.uiState.rowSelection;if(t.mode===`include`)return Array.from(t.keys);let n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){if(!e.rowModel.getRow(i))continue;let r=e.rowModel.getRowKey(i)??i;t.keys.has(r)||n.push(r)}return n},getSelectedRowData:()=>{let e=$.current;if(!e)return[];let t=e.uiState.rowSelection,n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){let r=e.rowModel.getRow(i);r&&O(t,e.rowModel.getRowKey(i)??i)&&n.push(r)}return n},getSelectedRowCount:()=>{let e=$.current;return e?N(e.uiState.rowSelection,e.leafRowCount):0},isRowSelected:e=>{let t=$.current;return t?O(t.uiState.rowSelection,e):!1},selectAllRows:()=>{fo.current(M())},clearRowSelection:()=>{fo.current(ee())},undo:()=>{$.current?.undoRows()},redo:()=>{$.current?.redoRows()},canUndo:()=>$.current?.canUndoRows()??!1,canRedo:()=>$.current?.canRedoRows()??!1,clearUndoHistory:()=>{$.current?.clearUndoHistory()},setGroupCollapsed:(e,t)=>{$.current?.dispatch(a.setGroupCollapsed(e,t))},expandAllGroups:()=>{$.current?.dispatch(a.setCollapsedGroupKeys(new Set))},collapseAllGroups:()=>{let e=$.current;!e||!e.groupTree||e.dispatch(a.setCollapsedGroupKeys(new Set(cr(e.groupTree))))},getGroupRows:()=>{let e=$.current;return e?.groupTree?sr(e.groupTree):[]},getInvalidCells:()=>{let e=$.current;return e?e.isServerSide?(console.warn(`[SpreadsheetGrid] getInvalidCells は serverSide モードでは利用できません(空配列を返します)。`),[]):on(e.rows,e.columns,e.resolvedRowKeyGetter):[]},refreshServerSide:()=>{let e=$.current;if(e){if(!e.isServerSide){console.warn(`[SpreadsheetGrid] refreshServerSide は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。`);return}e.serverSideRefresh()}},openFilterManager:()=>{$.current?.openFilterManager()},closeFilterManager:()=>{$.current?.closeFilterManager()}}},[ul,pl,dl]);let ml=(0,e.useRef)(Dt);ml.current=Dt;let hl=(0,e.useRef)(null);return(0,e.useEffect)(()=>{if(!ml.current)return;let e=Mi(U.columnWidths,U.filters,U.sort,ji(g)),t=Hi(hl.current,e,U.dragState!==null);hl.current=t.nextLast,t.emit&&ml.current(e)},[U.columnWidths,U.filters,U.sort,U.dragState,g]),(0,n.jsxs)(`div`,{className:i(`ssg-root`,ue!==`standard`&&`ssg-root--density-${ue}`,Ya,ye&&`ssg-root--dim-readonly`,vt,R?.root),children:[sl,ft&&(0,n.jsx)(ns,{entries:Us,canFilter:cn,onEditFilter:qs,onClearFilter:Js,onClearAllFilters:Ys}),(0,n.jsxs)(`div`,{ref:Mt,className:`ssg-shell`,style:{cursor:$i?`progress`:void 0},onDragStart:xo,onPointerLeave:()=>Yt(null),onPointerMoveCapture:e=>{Nt.current={x:e.clientX,y:e.clientY},_o(e.clientX,e.clientY)},tabIndex:il?-1:0,onKeyDown:il?void 0:qo,onPaste:il?void 0:Uo,onContextMenu:Qi,children:[(0,n.jsxs)(`div`,{ref:zt,className:i(`ssg-scroll-container`,ia?.scrollbar===!0&&`ssg-scroll-container--custom-scrollbar`),style:ll,children:[(0,n.jsxs)(`div`,{className:`ssg-inner-row`,style:{width:dr,minWidth:dr,height:z+Pa},children:[(0,n.jsxs)(`div`,{ref:Bt,style:Jc(`left`,Zn,Kn),children:[Kn&&(0,n.jsxs)(`div`,{style:{position:`relative`,overflow:`clip`,width:Zn,minWidth:Zn,height:z+Pa},children:[(0,n.jsx)(Co,{pane:`left`,ownsRowHeader:!0,leadingWidth:Yn,headerHeight:z,rowHeaderCellStyle:Kc,headerRowClassName:R?.headerRow,headerCellClassName:R?.headerCell,rowHeaderCellClassName:R?.rowHeaderCell,isCornerHovered:Gt,isWholeGridSelected:zo,showSelectAllCheckbox:$a,selectAllState:to,filteredRowsLength:Q,visibleColumnsLength:B.length,renderEntries:za,hoveredColumnIndex:Xt,selectionSnapshot:hn,columnFilterValues:U.filters.columnFilters,sortState:U.sort,iconButtonClassName:R?.iconButton,onCornerPointerDown:ls,onCornerPointerEnter:fs,onCornerPointerLeave:ps,onColumnHeaderPointerDown:To,onColumnHeaderPointerEnter:Eo,onColumnHeaderPointerLeave:ds,onColumnResizePointerDown:vs,enableColumnMenu:Je,enableColumnResize:ze,openedMenuColumnKey:Ir,onColumnMenuButtonPointerDown:Rr,onColumnHeaderContextMenu:zr,onColumnDragHandlePointerDown:sc}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,width:Zn,height:z+Pa,transform:Fa},children:[(0,n.jsx)(fe,{rect:cs(`left`),headerHeight:z,baseOffset:La,leadingWidth:Yn}),(0,n.jsx)(pe,{rect:Ka(`left`),headerHeight:z,baseOffset:La,leadingWidth:Yn}),(0,n.jsx)(Ue,{rect:Ja(`left`),headerHeight:z,baseOffset:La,leadingWidth:Yn,initialValue:Ut,editor:$o?.editor,editorSession:is,themeClassName:Ya,onCommit:Yo,onCancel:Zo,align:$o?.align,enterMove:Ce}),(0,n.jsx)(bo,{pane:`left`,ownsRowHeader:!0,leadingWidth:Yn,rowModel:Z,virtualRows:Oa,virtualRowIndexes:ka,renderEntries:za,rowHeight:Ot,autoHeight:ga,showCellOverflowTooltip:Ve,showValidationMarks:We,isServerSide:H,collapsedGroupKeys:U.collapsedGroupKeys,onGroupToggle:vi,rowHeaderCellStyle:Kc,hoveredRowIndex:Jt,isWholeGridSelected:zo,enableRowSelection:De,rowSelectionState:eo,activeCell:U.activeCell,editingCell:U.editingCell,selectionSnapshot:hn,readOnly:ve,canEditCell:Ji,onRowHeaderPointerDown:So,onRowHeaderPointerEnter:wo,onRowHeaderPointerLeave:us,onCellPointerDown:vo,onCellPointerEnter:yo,onCellDoubleClick:as,renderCellContent:Wc,getRowClassName:yt,bodyCellClassName:R?.bodyCell,bodyRowClassName:R?.bodyRow,rowHeaderCellClassName:R?.rowHeaderCell})]})]}),(0,n.jsx)(`div`,{ref:rc,className:`ssg-col-drop-indicator`,style:cc})]}),(0,n.jsx)(`div`,{ref:It,className:`ssg-center-pane`,style:{width:rr,minWidth:rr},children:(0,n.jsxs)(`div`,{style:{position:`relative`,overflow:`clip`,width:rr,minWidth:rr,height:z+Pa},children:[(0,n.jsx)(Co,{pane:`center`,ownsRowHeader:Jn,leadingWidth:Xn,headerHeight:z,rowHeaderCellStyle:Kc,headerRowClassName:R?.headerRow,headerCellClassName:R?.headerCell,rowHeaderCellClassName:R?.rowHeaderCell,isCornerHovered:Gt,isWholeGridSelected:zo,showSelectAllCheckbox:$a,selectAllState:to,filteredRowsLength:Q,visibleColumnsLength:B.length,renderEntries:Ra,hoveredColumnIndex:Xt,selectionSnapshot:hn,columnFilterValues:U.filters.columnFilters,sortState:U.sort,iconButtonClassName:R?.iconButton,onCornerPointerDown:ls,onCornerPointerEnter:fs,onCornerPointerLeave:ps,onColumnHeaderPointerDown:To,onColumnHeaderPointerEnter:Eo,onColumnHeaderPointerLeave:ds,onColumnResizePointerDown:vs,enableColumnMenu:Je,enableColumnResize:ze,openedMenuColumnKey:Ir,onColumnMenuButtonPointerDown:Rr,onColumnHeaderContextMenu:zr,onColumnDragHandlePointerDown:sc}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,width:rr,height:z+Pa,transform:Fa},children:[(0,n.jsx)(fe,{rect:cs(`center`),headerHeight:z,baseOffset:La,leadingWidth:Xn}),(0,n.jsx)(pe,{rect:Ka(`center`),headerHeight:z,baseOffset:La,leadingWidth:Xn}),(0,n.jsx)(Ue,{rect:Ja(`center`),headerHeight:z,baseOffset:La,leadingWidth:Xn,initialValue:Ut,editor:$o?.editor,editorSession:is,themeClassName:Ya,onCommit:Yo,onCancel:Zo,align:$o?.align,enterMove:Ce}),(0,n.jsx)(bo,{pane:`center`,ownsRowHeader:Jn,leadingWidth:Xn,rowModel:Z,virtualRows:Oa,virtualRowIndexes:ka,renderEntries:Ra,rowHeight:Ot,autoHeight:ga,showCellOverflowTooltip:Ve,showValidationMarks:We,isServerSide:H,collapsedGroupKeys:U.collapsedGroupKeys,onGroupToggle:vi,rowHeaderCellStyle:Kc,hoveredRowIndex:Jt,isWholeGridSelected:zo,enableRowSelection:De,rowSelectionState:eo,activeCell:U.activeCell,editingCell:U.editingCell,selectionSnapshot:hn,readOnly:ve,canEditCell:Ji,onRowHeaderPointerDown:So,onRowHeaderPointerEnter:wo,onRowHeaderPointerLeave:us,onCellPointerDown:vo,onCellPointerEnter:yo,onCellDoubleClick:as,renderCellContent:Wc,getRowClassName:yt,bodyCellClassName:R?.bodyCell,bodyRowClassName:R?.bodyRow,rowHeaderCellClassName:R?.rowHeaderCell})]}),(0,n.jsx)(`div`,{ref:ic,className:`ssg-col-drop-indicator`,style:cc})]})}),(0,n.jsxs)(`div`,{ref:Vt,style:Jc(`right`,Qn,qn),children:[qn&&(0,n.jsxs)(`div`,{style:{position:`relative`,overflow:`clip`,width:Qn,minWidth:Qn,height:z+Pa},children:[(0,n.jsx)(Co,{pane:`right`,ownsRowHeader:!1,leadingWidth:0,headerHeight:z,rowHeaderCellStyle:Kc,headerRowClassName:R?.headerRow,headerCellClassName:R?.headerCell,rowHeaderCellClassName:R?.rowHeaderCell,isCornerHovered:Gt,isWholeGridSelected:zo,showSelectAllCheckbox:$a,selectAllState:to,filteredRowsLength:Q,visibleColumnsLength:B.length,renderEntries:Ba,hoveredColumnIndex:Xt,selectionSnapshot:hn,columnFilterValues:U.filters.columnFilters,sortState:U.sort,iconButtonClassName:R?.iconButton,onCornerPointerDown:ls,onCornerPointerEnter:fs,onCornerPointerLeave:ps,onColumnHeaderPointerDown:To,onColumnHeaderPointerEnter:Eo,onColumnHeaderPointerLeave:ds,onColumnResizePointerDown:vs,enableColumnMenu:Je,enableColumnResize:ze,openedMenuColumnKey:Ir,onColumnMenuButtonPointerDown:Rr,onColumnHeaderContextMenu:zr,onColumnDragHandlePointerDown:sc}),(0,n.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,width:Qn,height:z+Pa,transform:Fa},children:[(0,n.jsx)(fe,{rect:cs(`right`),headerHeight:z,baseOffset:La,leadingWidth:0}),(0,n.jsx)(pe,{rect:Ka(`right`),headerHeight:z,baseOffset:La,leadingWidth:0}),(0,n.jsx)(Ue,{rect:Ja(`right`),headerHeight:z,baseOffset:La,leadingWidth:0,initialValue:Ut,editor:$o?.editor,editorSession:is,themeClassName:Ya,onCommit:Yo,onCancel:Zo,align:$o?.align,enterMove:Ce}),(0,n.jsx)(bo,{pane:`right`,ownsRowHeader:!1,leadingWidth:0,rowModel:Z,virtualRows:Oa,virtualRowIndexes:ka,renderEntries:Ba,rowHeight:Ot,autoHeight:ga,showCellOverflowTooltip:Ve,showValidationMarks:We,isServerSide:H,collapsedGroupKeys:U.collapsedGroupKeys,onGroupToggle:vi,rowHeaderCellStyle:Kc,hoveredRowIndex:Jt,isWholeGridSelected:zo,enableRowSelection:De,rowSelectionState:eo,activeCell:U.activeCell,editingCell:U.editingCell,selectionSnapshot:hn,readOnly:ve,canEditCell:Ji,onRowHeaderPointerDown:So,onRowHeaderPointerEnter:wo,onRowHeaderPointerLeave:us,onCellPointerDown:vo,onCellPointerEnter:yo,onCellDoubleClick:as,renderCellContent:Wc,getRowClassName:yt,bodyCellClassName:R?.bodyCell,bodyRowClassName:R?.bodyRow,rowHeaderCellClassName:R?.rowHeaderCell})]})]}),(0,n.jsx)(`div`,{ref:ac,className:`ssg-col-drop-indicator`,style:cc})]})]}),qc&&(0,n.jsx)(`div`,{className:`ssg-empty-state`,children:r.length===0?rt:et})]}),ia!==null&&(0,n.jsx)(ms,{options:ia,scrollContainerRef:zt,scrollTop:sa,viewportHeight:la,headerHeight:z,physicalBodyHeight:Pa,verticalScaleFactor:Ia,rowMetrics:Ea,rowModel:Z}),$i&&(0,n.jsx)(`div`,{className:`ssg-autosize-overlay`,children:(0,n.jsx)(`span`,{className:`ssg-autosize-pill`,children:`列幅を計算中…`})}),si===`filtering`&&(0,n.jsx)(`div`,{className:`ssg-filter-overlay`,children:(0,n.jsxs)(`span`,{className:`ssg-filter-overlay-chip`,role:`status`,"aria-live":`polite`,children:[(0,n.jsx)(`span`,{className:`ssg-filter-spinner`,"aria-hidden":`true`}),(0,n.jsxs)(`span`,{className:`ssg-filter-overlay-text`,children:[`適用中 `,Math.round(ci*100),`%`]})]})}),H&&(X.loadError!==null&&X.loadError!==Li||X.writeError!==null&&X.writeError!==zi)&&(0,n.jsxs)(`div`,{className:`ssg-ssrm-error-bars`,children:[X.loadError!==null&&X.loadError!==Li&&(0,n.jsxs)(`div`,{className:`ssg-ssrm-error-bar`,role:`alert`,children:[(0,n.jsx)(`span`,{className:`ssg-ssrm-error-bar-dot`,"aria-hidden":`true`}),(0,n.jsxs)(`span`,{className:`ssg-ssrm-error-bar-msg`,children:[`行の取得に失敗しました(`,X.loadError.failedBlockCount,` ブロック)`]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-ssrm-error-bar-retry`,onClick:X.retryFailedBlocks,children:`再試行`}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-ssrm-error-bar-close`,"aria-label":`エラー通知を閉じる`,onClick:()=>Ri(X.loadError),children:`×`})]}),X.writeError!==null&&X.writeError!==zi&&(0,n.jsxs)(`div`,{className:`ssg-ssrm-error-bar`,role:`alert`,children:[(0,n.jsx)(`span`,{className:`ssg-ssrm-error-bar-dot`,"aria-hidden":`true`}),(0,n.jsxs)(`span`,{className:`ssg-ssrm-error-bar-msg`,children:[`変更の保存に失敗しました(`,X.writeError.failedRowCount,` 行)。値を元に戻しました`]}),(0,n.jsx)(`button`,{type:`button`,className:`ssg-ssrm-error-bar-close`,"aria-label":`保存エラー通知を閉じる`,onClick:()=>Bi(X.writeError),children:`×`})]})]})]}),cl,Qc,$c,nl,rl]})}function zs(e={}){let{locale:t,useGrouping:n=!0,minimumFractionDigits:r,maximumFractionDigits:i,emptyText:a=``}=e;return({value:e})=>{if(e==null||e===``)return a;let o=typeof e==`number`?e:Number(e);if(!Number.isFinite(o))return String(e);let s=Math.abs(o).toString(),c=s.indexOf(`.`),l=c===-1?0:s.length-c-1,u=r??0,d=Math.max(u,i??Math.min(l,20));return new Intl.NumberFormat(t,{useGrouping:n,minimumFractionDigits:u,maximumFractionDigits:d}).format(o)}}exports.SpreadsheetGrid=Rs,exports.numberFormatter=zs;
|