import{s as I}from"./chunk-LvLJmgfZ.js";import{o as D,p as E}from"./useEvent-WUlsM6MC.js";import{t as F}from"./react-Bj1aDYRI.js";import{Ht as L,ir as V}from"./cells-CCtxWKxf.js";import{t as q}from"./compiler-runtime-B3qBwwSJ.js";import{t as G}from"./jsx-runtime-CP2fAiZX.js";import{r as J,t as W}from"./button-BmOH9agK.js";import{t as A}from"./cn-d_A4rA-x.js";import{at as M}from"./dist-DUY6xZX8.js";import{f as K}from"./dist-CEQIJ2pn.js";import{t as Q}from"./createLucideIcon-BvP5LBIs.js";import{t as U}from"./copy-CAR4dOiD.js";import{t as X}from"./eye-off-DgTL09j7.js";import{t as Y}from"./plus-B-s-VRHt.js";import{t as Z}from"./use-toast-BhMe50aT.js";import{r as $}from"./useTheme-CwdqVOYu.js";import{t as g}from"./tooltip-DOQlecCr.js";import{t as tt}from"./copy-DMCkK2TI.js";import{t as ot}from"./esm-BQUzYly2.js";import{t as et}from"./useAddCell-BRlAqdmq.js";var rt=Q("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const O=E({isInstantiated:!1,error:null});function at(){return D(O,o=>o.isInstantiated)}var w=q(),R=I(F(),1),s=I(G(),1),st=[L(),M.lineWrapping],it=[K(),M.lineWrapping];const T=(0,R.memo)(o=>{let t=(0,w.c)(41),{theme:a}=$(),e,r,i,l,c,u,C,j;t[0]===o?(e=t[1],r=t[2],i=t[3],l=t[4],c=t[5],u=t[6],C=t[7],j=t[8]):({code:r,className:e,initiallyHideCode:i,showHideCode:u,showCopyCode:C,insertNewCell:l,language:j,...c}=o,t[0]=o,t[1]=e,t[2]=r,t[3]=i,t[4]=l,t[5]=c,t[6]=u,t[7]=C,t[8]=j);let m=u===void 0?!0:u,b=C===void 0?!0:C,B=j===void 0?"python":j,[n,H]=(0,R.useState)(i),d;t[9]===e?d=t[10]:(d=A("relative hover-actions-parent w-full overflow-hidden",e),t[9]=e,t[10]=d);let p;t[11]!==n||t[12]!==m?(p=m&&n&&(0,s.jsx)(ct,{tooltip:"Show code",onClick:()=>H(!1)}),t[11]=n,t[12]=m,t[13]=p):p=t[13];let h;t[14]!==r||t[15]!==b?(h=b&&(0,s.jsx)(lt,{text:r}),t[14]=r,t[15]=b,t[16]=h):h=t[16];let f;t[17]!==r||t[18]!==l?(f=l&&(0,s.jsx)(mt,{code:r}),t[17]=r,t[18]=l,t[19]=f):f=t[19];let x;t[20]!==n||t[21]!==m?(x=m&&!n&&(0,s.jsx)(nt,{onClick:()=>H(!0)}),t[20]=n,t[21]=m,t[22]=x):x=t[22];let y;t[23]!==h||t[24]!==f||t[25]!==x?(y=(0,s.jsxs)("div",{className:"absolute top-0 right-0 my-1 mx-2 z-10 hover-action flex gap-2",children:[h,f,x]}),t[23]=h,t[24]=f,t[25]=x,t[26]=y):y=t[26];let z=n&&"opacity-20 h-8 overflow-hidden",v;t[27]===z?v=t[28]:(v=A("cm",z),t[27]=z,t[28]=v);let _=a==="dark"?"dark":"light",S=!n,P=B==="python"?st:it,k;t[29]!==r||t[30]!==c||t[31]!==v||t[32]!==_||t[33]!==S||t[34]!==P?(k=(0,s.jsx)(ot,{...c,className:v,theme:_,height:"100%",editable:S,extensions:P,value:r,readOnly:!0}),t[29]=r,t[30]=c,t[31]=v,t[32]=_,t[33]=S,t[34]=P,t[35]=k):k=t[35];let N;return t[36]!==k||t[37]!==d||t[38]!==p||t[39]!==y?(N=(0,s.jsxs)("div",{className:d,children:[p,y,k]}),t[36]=k,t[37]=d,t[38]=p,t[39]=y,t[40]=N):N=t[40],N});T.displayName="ReadonlyCode";var lt=o=>{let t=(0,w.c)(5),a;t[0]===o.text?a=t[1]:(a=J.stopPropagation(async()=>{await tt(o.text),Z({title:"Copied to clipboard"})}),t[0]=o.text,t[1]=a);let e=a,r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(U,{size:14,strokeWidth:1.5}),t[2]=r):r=t[2];let i;return t[3]===e?i=t[4]:(i=(0,s.jsx)(g,{content:"Copy code",usePortal:!1,children:(0,s.jsx)(W,{onClick:e,size:"xs",className:"py-0",variant:"secondary",children:r})}),t[3]=e,t[4]=i),i},nt=o=>{let t=(0,w.c)(3),a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(X,{size:14,strokeWidth:1.5}),t[0]=a):a=t[0];let e;return t[1]===o.onClick?e=t[2]:(e=(0,s.jsx)(g,{content:"Hide code",usePortal:!1,children:(0,s.jsx)(W,{onClick:o.onClick,size:"xs",className:"py-0",variant:"secondary",children:a})}),t[1]=o.onClick,t[2]=e),e};const ct=o=>{let t=(0,w.c)(7),a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(V,{className:"hover-action w-5 h-5 text-muted-foreground cursor-pointer absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2 opacity-80 hover:opacity-100 z-20"}),t[0]=a):a=t[0];let e;t[1]===o.tooltip?e=t[2]:(e=(0,s.jsx)(g,{usePortal:!1,content:o.tooltip,children:a}),t[1]=o.tooltip,t[2]=e);let r;return t[3]!==o.className||t[4]!==o.onClick||t[5]!==e?(r=(0,s.jsx)("div",{className:o.className,onClick:o.onClick,children:e}),t[3]=o.className,t[4]=o.onClick,t[5]=e,t[6]=r):r=t[6],r};var mt=o=>{let t=(0,w.c)(6),a=et(),e;t[0]!==a||t[1]!==o.code?(e=()=>{a(o.code)},t[0]=a,t[1]=o.code,t[2]=e):e=t[2];let r=e,i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(Y,{size:14,strokeWidth:1.5}),t[3]=i):i=t[3];let l;return t[4]===r?l=t[5]:(l=(0,s.jsx)(g,{content:"Add code to notebook",usePortal:!1,children:(0,s.jsx)(W,{onClick:r,size:"xs",className:"py-0",variant:"secondary",children:i})}),t[4]=r,t[5]=l),l};export{rt as i,O as n,at as r,T as t};
