import{s as D}from"./chunk-LvLJmgfZ.js";import{i as m,n as u}from"./useEvent-D91BmmQi.js";import{E as p,_ as h,y as I}from"./cells-CJLUCcQg.js";import{t as y}from"./compiler-runtime-B3qBwwSJ.js";import{t as _}from"./useEventListener-C0195JsF.js";import{t as v}from"./jsx-runtime-Blw4afVn.js";import{t as x}from"./button-DDGiD1NW.js";import{r as C}from"./requests-9-v2bhoi.js";import{t as j}from"./createLucideIcon-w-Qo9n0R.js";import{t as b}from"./use-toast-BwJoaaDM.js";import{n as w}from"./renderShortcut-Bl8_FVn8.js";var z=j("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),K=y(),d=D(v(),1);const f=e=>{let t=(0,K.c)(7),l;t[0]===e?l=t[1]:(l=i=>{var s;(i.ctrlKey||i.metaKey)&&i.key==="z"&&(i.preventDefault(),i.stopPropagation(),(s=e.onClick)==null||s.call(e,i))},t[0]=e,t[1]=l);let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r={capture:!0},t[2]=r):r=t[2],_(window,"keydown",l,r);let o=e.children??"Undo",n;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,d.jsx)(w,{className:"ml-2",shortcut:"cmd-z"}),t[3]=n):n=t[3];let a;return t[4]!==o||t[5]!==e?(a=(0,d.jsxs)(x,{"data-testid":"undo-button",size:"sm",variant:"outline",...e,children:[o," ",n]}),t[4]=o,t[5]=e,t[6]=a):a=t[6],a};var k=y();function S(){let e=(0,k.c)(4),{deleteCell:t,undoDeleteCell:l}=p(),{sendDeleteCell:r}=C(),o;return e[0]!==t||e[1]!==r||e[2]!==l?(o=n=>{var s;if(m.get(h))return;let{cellId:a}=n,i=(((s=m.get(I).cellData[a])==null?void 0:s.code)??"").trim()==="";if(t({cellId:a}),r({cellId:a}).catch(()=>{l()}),!i){let{dismiss:c}=b({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:(0,d.jsx)(f,{"data-testid":"undo-delete-button",onClick:()=>{l(),g()}})}),g=c}},e[0]=t,e[1]=r,e[2]=l,e[3]=o):o=e[3],u(o)}function A(){let e=(0,k.c)(4),{deleteCell:t,undoDeleteCell:l}=p(),{sendDeleteCell:r}=C(),o;return e[0]!==t||e[1]!==r||e[2]!==l?(o=async n=>{if(m.get(h))return;let{cellIds:a}=n;for(let c of a)await r({cellId:c}).then(()=>{t({cellId:c})});let{dismiss:i}=b({title:"Cells deleted",action:(0,d.jsx)(f,{"data-testid":"undo-delete-button",onClick:()=>{for(let c of a)l();s()}})}),s=i},e[0]=t,e[1]=r,e[2]=l,e[3]=o):o=e[3],u(o)}export{z as i,A as n,f as r,S as t};
