import {c}from'./chunk-MGEN6GOE.mjs';import'./chunk-TAUMSKRE.mjs';import {useState,useEffect,useMemo,useCallback}from'react';import {jsx,jsxs}from'react/jsx-runtime';var E={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},M={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:360,maxWidth:440,width:"100%",margin:20},R={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},I={padding:"16px 20px",display:"flex",flexDirection:"column",gap:12},C={display:"flex",alignItems:"center",gap:12},h={width:88,fontSize:13,color:"var(--doc-text-muted)"},P={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13},b={fontSize:12,color:"var(--doc-text-muted)",lineHeight:1.5},K={...b,color:"var(--doc-error)"},W={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},w={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"};function B({isOpen:p,onClose:l,onApply:S,initialRows:c$1=1,initialCols:u=1,minRows:a=1,minCols:d=1}){let{t:e}=c(),[i,g]=useState(c$1),[n,m]=useState(u);useEffect(()=>{p&&(g(c$1),m(u));},[u,c$1,p]);let r=useMemo(()=>i<a||n<d?e("dialogs.splitCell.minValue",{rows:a,cols:d}):i===1&&n===1?e("dialogs.splitCell.notOneByOne"):null,[n,d,a,i,e]),y=useCallback(()=>{r||(S(i,n),l());},[n,S,l,i,r]),k=useCallback(t=>{t.key==="Escape"&&l(),t.key==="Enter"&&y();},[y,l]);return p?jsx("div",{style:E,onClick:l,onKeyDown:k,onMouseDown:t=>t.stopPropagation(),children:jsxs("div",{style:M,onClick:t=>t.stopPropagation(),role:"dialog","aria-label":e("dialogs.splitCell.title"),children:[jsx("div",{style:R,children:e("dialogs.splitCell.title")}),jsxs("div",{style:I,children:[jsx("div",{style:b,children:e("dialogs.splitCell.description")}),jsxs("div",{style:C,children:[jsx("label",{style:h,children:e("dialogs.splitCell.rowsLabel")}),jsx("input",{type:"number",style:P,min:a,step:1,value:i,onChange:t=>g(Math.max(0,Number(t.target.value)||0))})]}),jsxs("div",{style:C,children:[jsx("label",{style:h,children:e("dialogs.splitCell.columnsLabel")}),jsx("input",{type:"number",style:P,min:d,step:1,value:n,onChange:t=>m(Math.max(0,Number(t.target.value)||0))})]}),jsx("div",{style:r?K:b,children:r??e("dialogs.splitCell.currentMinimum",{rows:a,cols:d})})]}),jsxs("div",{style:W,children:[jsx("button",{type:"button",style:w,onClick:l,children:e("common.cancel")}),jsx("button",{type:"button",style:{...w,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)",opacity:r?.6:1,cursor:r?"not-allowed":"pointer"},disabled:!!r,onClick:y,children:e("common.apply")})]})]})}):null}var j=B;export{B as SplitCellDialog,j as default};