videobook 0.2.2 → 0.2.4

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +10 -10
  3. package/dist/book-manager.js +40 -2
  4. package/dist/command-reference.js +16 -2
  5. package/dist/env-secrets.js +7 -4
  6. package/dist/image-edit-models.js +1 -0
  7. package/dist/jobs/complete-provider-task.js +7 -1
  8. package/dist/jobs/generate-media.js +4 -0
  9. package/dist/jobs/render-project.js +124 -31
  10. package/dist/media/adapters/index.js +4 -0
  11. package/dist/media/adapters/machgen.js +48 -0
  12. package/dist/media/adapters/types.js +1 -0
  13. package/dist/media/catalog.js +83 -0
  14. package/dist/media/complete.js +1 -1
  15. package/dist/media/cost.js +79 -6
  16. package/dist/media/frontier-gaps.js +49 -0
  17. package/dist/media/frontier.js +30 -0
  18. package/dist/media/json-schema.js +7 -0
  19. package/dist/media/listing.js +9 -2
  20. package/dist/media/machgen.js +261 -0
  21. package/dist/media/model-id.js +1 -1
  22. package/dist/media/preview.js +2 -0
  23. package/dist/media/prompt-dialects.js +2 -0
  24. package/dist/media/ref-fields.js +11 -3
  25. package/dist/media/request.js +49 -0
  26. package/dist/media/seedance-draft.js +48 -0
  27. package/dist/media/wire.js +3 -0
  28. package/dist/notebook-action-catalog.js +5 -0
  29. package/dist/one-password.js +13 -7
  30. package/dist/provider-status-link.js +1 -1
  31. package/dist/provider-task-status.js +6 -3
  32. package/dist/provider-usage.js +24 -10
  33. package/dist/queue.js +3 -0
  34. package/dist/tools/commands.js +1 -1
  35. package/dist/tools/estimate-cost.js +7 -5
  36. package/dist/tools/provider-key-status.js +4 -0
  37. package/dist/tools/reconcile-project-work.js +69 -1
  38. package/dist/usage-providers.js +4 -0
  39. package/dist/workspace-action-catalog.js +1 -1
  40. package/package.json +14 -13
  41. package/ui/assets/{alive-captions-C48o6dfv.js → alive-captions-Bp6dxosy.js} +1 -1
  42. package/ui/assets/confirm-bodies-Ds1HtaGc.js +1 -0
  43. package/ui/assets/{fullscreen-4m0qtZ7w.js → fullscreen-BCeVHjvY.js} +1 -1
  44. package/ui/assets/{goal-ui-2pUWP_B2.js → goal-ui-DbAGwgMN.js} +2 -2
  45. package/ui/assets/index-D1d-F1y9.js +37 -0
  46. package/ui/assets/index-DWfR79lA.css +1 -0
  47. package/ui/assets/{inspector-CnKySYc5.js → inspector-BJTC0luH.js} +1 -1
  48. package/ui/assets/{jobs-ui-lRoS1MbL.js → jobs-ui-C1cbw-xG.js} +1 -1
  49. package/ui/assets/{music-video-BQnnPp-X.js → music-video-CWtxPlxq.js} +1 -1
  50. package/ui/assets/ui-CXDi5Omq.js +2 -0
  51. package/ui/assets/vendor-BFupLz37.js +19 -0
  52. package/ui/assets/{vendor-flow-zBavaNEW.js → vendor-flow-CKiuzaeM.js} +1 -1
  53. package/ui/assets/{vendor-mcp-DQ7EusT9.js → vendor-mcp-DQEeVZH0.js} +1 -1
  54. package/ui/assets/videobook-J-j9bSjM.js +20 -0
  55. package/ui/index.html +12 -12
  56. package/ui/assets/confirm-bodies-aq6Az8Md.js +0 -1
  57. package/ui/assets/index-DmDH4gYr.js +0 -37
  58. package/ui/assets/index-DzPAnCUj.css +0 -1
  59. package/ui/assets/ui-OHFUngrc.js +0 -2
  60. package/ui/assets/vendor-yctIZ9Dz.js +0 -19
  61. package/ui/assets/videobook-DZ58pKW5.js +0 -20
@@ -0,0 +1,2 @@
1
+ import{a as C,j as t,c as X,d as fa,b as gs}from"./vendor-react-Dj7D1fD4.js";import{b as Wt,E as us,F as al,G as pa,H as rl,I as ha,J as ol,K as ba,L as xa,n as ti,O as ga,P as ya,Q as ms,R as cl,U as ja,V as va}from"./vendor-BFupLz37.js";import{x as ka,p as Sa,u as wa,a as Na,i as Ca,b as $a,P as fn,c as Ia,m as pn,d as dl,h as In,e as Ra,f as si,g as ul,r as vs,s as ml,j as is,k as fl,l as pl,n as ni,o as li,q as ii,t as ai,v as Ma,w as Pa,y as Ta,z as Ea,A as Aa,B as Da,C as Gt,D as Fa,E as _a,F as La,G as za,H as Ba,I as Oa,J as hl,K as Ua,L as Ha,M as Ka,N as bl,O as hn,Q as Va,R as qa,S as Wa,T as bn,U as Xa,V as Ga,W as Ya,X as Ja,Y as xl,Z as Qa,_ as Za,$ as er,a0 as tr,a1 as sr,a2 as nr,a3 as lr,a4 as ir,a5 as ar,a6 as Rn,a7 as rr,a8 as He,a9 as Ln,aa as Os,ab as or,ac as cr,ad as Kt,ae as ri,af as dr,ag as ur,ah as mr,ai as fr,aj as pr,ak as hr,al as oi,am as br,an as xr,ao as gr,ap as yr,aq as ci,ar as jr,as as vr,at as di,au as kr,av as Sr,aw as wr,ax as Nr,ay as Cr,az as $r,aA as Ir,aB as Rr,aC as Mr,aD as Pr,aE as ui,aF as gl,aG as Tr,aH as Er,aI as yl,aJ as Ar,aK as Dr,aL as Fr,aM as _r,aN as Lr,aO as zr,aP as jl,aQ as Br,aR as Or,aS as Ur,aT as Hr,aU as xn,aV as vl,aW as fs,aX as Kr,aY as Vr,aZ as $s,a_ as gn,a$ as mi,b0 as fi,b1 as qr,b2 as pi,b3 as Wr,b4 as Xr,b5 as Gr,b6 as Yr,b7 as Jr,b8 as hi,b9 as Qr,ba as Zr,bb as as,bc as Mn,bd as Ss,be as bi,bf as eo,bg as to,bh as so,bi as no,bj as lo,bk as io,bl as xi,bm as ao,bn as ro,bo as oo,bp as gi,bq as co,br as uo,bs as mo,bt as fo,bu as po,bv as ho,bw as kl,bx as bo,by as xo,bz as go,bA as yo,bB as jo,bC as vo,bD as ko,bE as So,bF as yi,bG as Sl,bH as ps,bI as wo,bJ as No,bK as ji,bL as Co,bM as $o,bN as Io,bO as Ro,bP as Mo,bQ as Po,bR as To,bS as Eo,bT as wl,bU as Nl,bV as Ao,bW as Do,bX as Fo,bY as Us,bZ as Cl,b_ as _o,b$ as bs,c0 as Lo}from"./videobook-J-j9bSjM.js";import{X as mt,A as zo,a as ss,F as St,I as Zt,B as Ms,b as zn,V as Bo,L as vi,C as Is,M as ki,c as Qt,T as $l,W as Si,d as Oo,S as Uo,e as Zs,E as Ho,R as Bn,f as rs,g as en,h as On,H as Un,P as Ko,i as wi,D as tn,j as Vo,k as Ni,l as Ci,m as es,n as Hn,o as qo,p as $i,N as Wo,q as Xo,U as Go,r as Ii,s as Yo,t as Ri,u as Jo,v as Qo,w as Kn,x as Mi,Z as Zo,y as sn,z as Vn,G as Il,J as Ns,K as ec,O as Rl,Q as yn,Y as qn,_ as Ps,$ as Pi,a0 as tc,a1 as Rs,a2 as sc,a3 as os,a4 as nc,a5 as lc,a6 as Ti,a7 as Ei,a8 as Ai,a9 as Di,aa as ic,ab as ac,ac as Fi,ad as rc,ae as oc,af as Pn,ag as cc,ah as dc}from"./vendor-icons-CGqhCIXV.js";import{u as uc,B as mc,V as _i,P as Cs,a as fc,H as jn}from"./vendor-flow-CKiuzaeM.js";import{S as Tn,u as pc,i as Ml,I as hc,A as Wn,V as bc,b as xc,P as gc}from"./vendor-remotion-CH1HXrlc.js";const yc={tiktok:"https://www.tiktok.com/@account/video/…",instagram:"https://www.instagram.com/reel/…",youtube:"https://youtube.com/shorts/…",x:"https://x.com/account/status/…",other:"https://…"};function jc(l){return l instanceof Error?l.message:String(l)}function vc({post:l,disabled:e,className:s,onLink:n}){const[i,a]=C.useState(""),[o,r]=C.useState(()=>ka(new Date().toISOString())),[c,d]=C.useState(!1),[u,p]=C.useState(null),m=e||c||!l.definition.source,b=async()=>{if(!(m||!i.trim()||!o)){d(!0),p(null);try{await n({url:i.trim(),posted_at:new Date(o).toISOString()})}catch(h){p(jc(h))}finally{d(!1)}}},f=h=>{h.key==="Enter"&&(h.preventDefault(),h.stopPropagation(),b())},g=`post-link-${l.id}`;return t.jsxs("div",{className:s??"post-link-field",role:"group","aria-labelledby":`${g}-heading`,children:[t.jsx("h3",{id:`${g}-heading`,children:Sa(l)}),t.jsx("label",{htmlFor:`${g}-url`,children:"Post URL"}),t.jsx("input",{id:`${g}-url`,type:"url",value:i,disabled:m,spellCheck:!1,placeholder:yc[l.definition.platform],onChange:h=>a(h.target.value),onKeyDown:f}),t.jsx("label",{htmlFor:`${g}-at`,children:"Published at"}),t.jsx("input",{id:`${g}-at`,type:"datetime-local",value:o,disabled:m,onChange:h=>r(h.target.value),onKeyDown:f}),t.jsx("button",{type:"button",disabled:m||!i.trim()||!o,onClick:()=>{b()},children:c?"Saving link…":"Save published link"}),u&&t.jsx("small",{role:"alert",className:"post-error",children:u}),t.jsx("small",{children:"Locks the clip and caption to this publication. Add views and likes under Results afterwards."})]})}function Pl(){const l=new Date;return new Date(l.getTime()-l.getTimezoneOffset()*6e4).toISOString().slice(0,23)}function J1(l){const e=X.c(186),{post:s,cells:n,asset:i,bookId:a,call:o,onRefresh:r,onSelectCell:c,onDeliver:d,onReviewX:u,onDelete:p}=l,m=wa(o,a,r);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[f,g]=C.useState(b),h=f.platform??s.definition.platform,y=f.caption??s.definition.caption,x=f.credits??s.definition.credits,j=f.account??s.definition.account,v=f.notes??s.definition.notes,[k,w]=C.useState(""),[S,M]=C.useState(Pl);let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N={},e[1]=N):N=e[1];const[$,P]=C.useState(N),[T,A]=C.useState(null);Na(!!s.runtime.icloud?.completedAt,o,a,s.id,A);const I=T?.phase??null,D=T?.error;let F;e[2]!==I||e[3]!==D?(F=Ca(I,D),e[2]=I,e[3]=D,e[4]=F):F=e[4];const R=F,E=!!(s.runtime.outbound||s.runtime.url||s.runtime.status==="scheduled");let z,_,L,B,U,q,H,K,se,ie,V,ce,W,te;if(e[5]!==j||e[6]!==m||e[7]!==i||e[8]!==a||e[9]!==o||e[10]!==y||e[11]!==n||e[12]!==x||e[13]!==f||e[14]!==R||e[15]!==E||e[16]!==$||e[17]!==v||e[18]!==S||e[19]!==d||e[20]!==r||e[21]!==u||e[22]!==c||e[23]!==h||e[24]!==s||e[25]!==k){let J;e[40]!==s.definition.source?.cellId?(J=ke=>ke.id===s.definition.source?.cellId,e[40]=s.definition.source?.cellId,e[41]=J):J=e[41];const de=n.find(J),fe=s.runtime.metrics.at(-1),ue=h!==s.definition.platform||y!==s.definition.caption||x!==s.definition.credits||j!==s.definition.account;let pe;e[42]!==m||e[43]!==s.id?(pe=(ke,Qe)=>{const nt=Qe===void 0?{}:Qe;return m.run(ke,{post_cell_id:s.id,...nt})},e[42]=m,e[43]=s.id,e[44]=pe):pe=e[44];const me=pe;let he;e[45]!==a||e[46]!==o||e[47]!==r||e[48]!==s.id?(he=async ke=>{o&&(await o("link_post",{book_id:a,post_cell_id:s.id,...ke}),await r())},e[45]=a,e[46]=o,e[47]=r,e[48]=s.id,e[49]=he):he=e[49];const ye=he;V="post-inspector",ce="Post details";let oe;e[50]!==s.definition.platform?(oe=t.jsxs("span",{className:"post-eyebrow",children:[s.definition.platform," publication"]}),e[50]=s.definition.platform,e[51]=oe):oe=e[51];let G;e[52]!==s.address?(G=t.jsxs("h2",{children:[s.address," · Post"]}),e[52]=s.address,e[53]=G):G=e[53];let le;e[54]!==oe||e[55]!==G?(le=t.jsxs("div",{children:[oe,G]}),e[54]=oe,e[55]=G,e[56]=le):le=e[56];const be=`post-status post-status-${s.runtime.status}`;let je;e[57]!==s.runtime.status?(je=s.runtime.status.replaceAll("_"," "),e[57]=s.runtime.status,e[58]=je):je=e[58];let we;e[59]!==be||e[60]!==je?(we=t.jsx("span",{className:be,children:je}),e[59]=be,e[60]=je,e[61]=we):we=e[61],e[62]!==le||e[63]!==we?(W=t.jsxs("div",{className:"post-heading",children:[le,we]}),e[62]=le,e[63]=we,e[64]=W):W=e[64],e[65]!==i?(te=i?.mediaUrl&&(i.type==="image"?t.jsx("img",{className:"post-media",src:i.mediaUrl,alt:"Frozen publication media"}):t.jsx("video",{className:"post-media",src:i.mediaUrl,controls:!0,preload:"metadata",poster:i.thumbnailUrl??void 0})),e[65]=i,e[66]=te):te=e[66];const $e=de?t.jsxs("button",{type:"button",onClick:()=>c(de.id),children:["Source ",Wt(de.slot)," · ",de.label??de.type]}):s.definition.source?t.jsx("span",{children:"Source cell no longer on this canvas"}):t.jsx("span",{children:"Choose the finished clip this publication will represent."});let Ie;e[67]!==s.definition.createdAt||e[68]!==s.definition.source?(Ie=s.definition.source&&t.jsx("small",{children:s.definition.source.revision?`Clip version saved ${new Date(s.definition.createdAt).toLocaleString()}`:"Historical media version unknown"}),e[67]=s.definition.createdAt,e[68]=s.definition.source,e[69]=Ie):Ie=e[69],e[70]!==$e||e[71]!==Ie?(z=t.jsxs("div",{className:"post-source",children:[$e,Ie]}),e[70]=$e,e[71]=Ie,e[72]=z):z=e[72],e[73]!==m.busy||e[74]!==n||e[75]!==s.definition.source||e[76]!==me||e[77]!==k?(_=!s.definition.source&&t.jsxs("form",{onSubmit:ke=>{ke.preventDefault(),me("update_post",{source_cell_id:k})},children:[t.jsxs("label",{children:["Source clip",t.jsxs("select",{"aria-label":"Source clip",value:k,onChange:ke=>w(ke.target.value),required:!0,children:[t.jsx("option",{value:"",children:"Choose a finished image or video"}),n.filter($c).map(Cc)]})]}),t.jsx("button",{disabled:m.busy||!k,children:"Save source version"})]}),e[73]=m.busy,e[74]=n,e[75]=s.definition.source,e[76]=me,e[77]=k,e[78]=_):_=e[78];let Ae;e[79]!==j||e[80]!==y||e[81]!==x||e[82]!==E||e[83]!==v||e[84]!==h||e[85]!==me?(Ae=ke=>{ke.preventDefault(),me("update_post",E?{notes:v}:{platform:h,caption:y,credits:x,account:j,notes:v}).then(Qe=>{Qe&&g({})})},e[79]=j,e[80]=y,e[81]=x,e[82]=E,e[83]=v,e[84]=h,e[85]=me,e[86]=Ae):Ae=e[86];let Fe;e[87]!==f?(Fe=ke=>g({...f,platform:ke.target.value}),e[87]=f,e[88]=Fe):Fe=e[88];let et;e[89]===Symbol.for("react.memo_cache_sentinel")?(et=Ia.map(Nc),e[89]=et):et=e[89];let Ye;e[90]!==E||e[91]!==h||e[92]!==Fe?(Ye=t.jsxs("label",{children:["Platform",t.jsx("select",{"aria-label":"Platform",disabled:E,value:h,onChange:Fe,children:et})]}),e[90]=E,e[91]=h,e[92]=Fe,e[93]=Ye):Ye=e[93];let Ke;e[94]!==f?(Ke=ke=>g({...f,account:ke.target.value}),e[94]=f,e[95]=Ke):Ke=e[95];let Ve;e[96]!==j||e[97]!==E||e[98]!==Ke?(Ve=t.jsxs("label",{children:["Account",t.jsx("input",{value:j,disabled:E,placeholder:"@account",onChange:Ke})]}),e[96]=j,e[97]=E,e[98]=Ke,e[99]=Ve):Ve=e[99];let lt;e[100]!==Ye||e[101]!==Ve?(lt=t.jsxs("div",{className:"post-fields",children:[Ye,Ve]}),e[100]=Ye,e[101]=Ve,e[102]=lt):lt=e[102];let Ee;e[103]!==f?(Ee=ke=>g({...f,caption:ke.target.value}),e[103]=f,e[104]=Ee):Ee=e[104];let We;e[105]!==y||e[106]!==E||e[107]!==Ee?(We=t.jsxs("label",{children:["Caption",t.jsx("textarea",{value:y,disabled:E,rows:4,onChange:Ee,placeholder:"What will this post say?"})]}),e[105]=y,e[106]=E,e[107]=Ee,e[108]=We):We=e[108];let Xe;e[109]!==f?(Xe=ke=>g({...f,credits:ke.target.value}),e[109]=f,e[110]=Xe):Xe=e[110];let Je;e[111]!==x||e[112]!==E||e[113]!==Xe?(Je=t.jsxs("label",{children:["Credits",t.jsx("textarea",{value:x,disabled:E,rows:2,onChange:Xe,placeholder:"Creator and source credits"})]}),e[111]=x,e[112]=E,e[113]=Xe,e[114]=Je):Je=e[114];let tt;e[115]!==f?(tt=ke=>g({...f,notes:ke.target.value}),e[115]=f,e[116]=tt):tt=e[116];let Re;e[117]!==v||e[118]!==tt?(Re=t.jsxs("label",{children:["Notes",t.jsx("textarea",{value:v,rows:2,onChange:tt,placeholder:"What worked? What would you change?"})]}),e[117]=v,e[118]=tt,e[119]=Re):Re=e[119];const De=m.busy||!o,qe=E?"Save notes":"Save draft";let _e;e[120]!==De||e[121]!==qe?(_e=t.jsx("button",{disabled:De,children:qe}),e[120]=De,e[121]=qe,e[122]=_e):_e=e[122],e[123]!==Ae||e[124]!==lt||e[125]!==We||e[126]!==Je||e[127]!==Re||e[128]!==_e?(L=t.jsxs("form",{onSubmit:Ae,children:[lt,We,Je,Re,_e]}),e[123]=Ae,e[124]=lt,e[125]=We,e[126]=Je,e[127]=Re,e[128]=_e,e[129]=L):L=e[129],e[130]!==m.error?(B=m.error&&t.jsx("p",{role:"alert",className:"post-error",children:m.error}),e[130]=m.error,e[131]=B):B=e[131],e[132]!==s.runtime.error?(U=s.runtime.error&&t.jsx("p",{role:"alert",className:"post-error",children:s.runtime.error}),e[132]=s.runtime.error,e[133]=U):U=e[133],e[134]!==m.busy||e[135]!==y||e[136]!==ue||e[137]!==d||e[138]!==u||e[139]!==s||e[140]!==me?(q=!s.runtime.url&&t.jsxs("div",{className:"post-delivery",children:[t.jsx("h3",{children:"Deliver"}),t.jsx("p",{children:"Review the clip and caption, then save them where you will publish."}),t.jsx("button",{type:"button","aria-pressed":s.definition.delivery==="icloud",onClick:()=>d("icloud"),children:"Save to iPhone"}),t.jsx("button",{type:"button","aria-pressed":s.definition.delivery==="dropbox",onClick:()=>d("dropbox"),children:"Upload to Dropbox"}),s.definition.platform==="x"&&!s.runtime.xRequest&&!["scheduled","needs_reconciliation","posting"].includes(s.runtime.status)&&t.jsx("button",{type:"button",disabled:m.busy||!s.definition.source?.snapshotArtifactId||!y.trim()||ue,onClick:()=>{u(s)},children:"Review X post…"}),s.definition.platform==="x"&&s.runtime.xRequest&&s.runtime.status==="failed"&&t.jsx("button",{type:"button",disabled:m.busy,onClick:()=>{me("post")},children:"Retry saved X post"}),ue&&t.jsx("small",{children:"Save your draft before delivering."}),s.runtime.scheduledFor&&t.jsxs("p",{children:["Scheduled for ",new Date(s.runtime.scheduledFor).toLocaleString()]})]}),e[134]=m.busy,e[135]=y,e[136]=ue,e[137]=d,e[138]=u,e[139]=s,e[140]=me,e[141]=q):q=e[141],e[142]!==R||e[143]!==s.runtime.icloud?(H=s.runtime.icloud?.completedAt&&t.jsxs("div",{className:"post-receipt",children:[t.jsx("strong",{children:$a(s.runtime.icloud.folder)}),R&&t.jsx("small",{children:R})]}),e[142]=R,e[143]=s.runtime.icloud,e[144]=H):H=e[144],e[145]!==s.runtime.dropbox?(K=s.runtime.dropbox&&t.jsxs("div",{className:"post-receipt",children:[t.jsx("strong",{children:s.runtime.dropbox.completedAt?"Dropbox files ready":"Dropbox upload saved"}),t.jsx("span",{children:s.runtime.dropbox.folder}),t.jsxs("small",{children:["Clip: ",s.runtime.dropbox.video.rev?"uploaded":`${s.runtime.dropbox.video.offset.toLocaleString()} bytes saved`," · Caption: ",s.runtime.dropbox.caption.rev?"uploaded":"pending"]})]}),e[145]=s.runtime.dropbox,e[146]=K):K=e[146],e[147]!==m.busy||e[148]!==o||e[149]!==ue||e[150]!==ye||e[151]!==s?(se=s.runtime.url?t.jsxs("div",{className:"post-receipt",children:[t.jsx("a",{href:s.runtime.url,target:"_blank",rel:"noreferrer",children:"Open published post ↗"}),t.jsx("span",{children:s.runtime.postedAt?new Date(s.runtime.postedAt).toLocaleString():"Publication time unknown"}),s.runtime.x?.replies.map(wc)]}):t.jsx(vc,{post:s,disabled:m.busy||!o||ue,className:"post-delivery post-link-field",onLink:ye}),e[147]=m.busy,e[148]=o,e[149]=ue,e[150]=ye,e[151]=s,e[152]=se):se=e[152],ie=s.runtime.url&&t.jsxs("div",{className:"post-results",children:[t.jsx("h3",{children:"Results"}),fe?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"post-metric-grid",children:fn.map(ke=>t.jsxs("div",{children:[t.jsx("strong",{children:fe.values[ke]?.toLocaleString()??"—"}),t.jsx("span",{children:ke})]},ke))}),t.jsxs("small",{children:["Observed ",new Date(fe.observedAt).toLocaleString()," · ",fe.source]}),fe.mediaViews!==void 0&&t.jsxs("p",{children:[fe.mediaViews.toLocaleString()," X media views · shared across posts using this media"]})]}):t.jsx("p",{children:"No observations yet. Unknown metrics appear as —."}),s.definition.platform==="x"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",disabled:m.busy,onClick:()=>{me("refresh_post_metrics")},children:"Refresh now"}),t.jsx("small",{children:s.runtime.nextMetricAt?`Next check ${new Date(s.runtime.nextMetricAt).toLocaleString()}`:s.runtime.metricsPaused?"Automatic checks paused; reconnect X and refresh.":"Scheduled observations complete."}),s.runtime.metricsError&&t.jsx("p",{className:"post-error",children:s.runtime.metricsError})]}),t.jsxs("details",{onToggle:ke=>{ke.currentTarget.open&&M(Pl())},children:[t.jsx("summary",{children:"Add manual observation"}),t.jsxs("form",{onSubmit:ke=>{ke.preventDefault();const Qe={};for(const nt of fn)$[nt]?.trim()&&(Qe[nt]=Number($[nt]));me("record_post_metrics",{observed_at:new Date(S).toISOString(),values:Qe})},children:[t.jsxs("label",{children:["Observed at",t.jsx("input",{type:"datetime-local",step:"0.001",required:!0,value:S,onChange:ke=>M(ke.target.value)})]}),t.jsx("div",{className:"post-metric-inputs",children:fn.map(ke=>t.jsxs("label",{children:[ke,t.jsx("input",{type:"number",min:"0",step:"1",placeholder:"Unknown",value:$[ke]??"",onChange:Qe=>P({...$,[ke]:Qe.target.value})})]},ke))}),t.jsx("button",{disabled:m.busy||!Object.values($).some(Boolean),children:"Save observation"})]})]}),s.runtime.metrics.length>0&&t.jsxs("details",{children:[t.jsxs("summary",{children:["Observation history (",s.runtime.metrics.length,")"]}),t.jsx("div",{className:"post-history",children:[...s.runtime.metrics].reverse().map(kc)})]})]}),e[5]=j,e[6]=m,e[7]=i,e[8]=a,e[9]=o,e[10]=y,e[11]=n,e[12]=x,e[13]=f,e[14]=R,e[15]=E,e[16]=$,e[17]=v,e[18]=S,e[19]=d,e[20]=r,e[21]=u,e[22]=c,e[23]=h,e[24]=s,e[25]=k,e[26]=z,e[27]=_,e[28]=L,e[29]=B,e[30]=U,e[31]=q,e[32]=H,e[33]=K,e[34]=se,e[35]=ie,e[36]=V,e[37]=ce,e[38]=W,e[39]=te}else z=e[26],_=e[27],L=e[28],B=e[29],U=e[30],q=e[31],H=e[32],K=e[33],se=e[34],ie=e[35],V=e[36],ce=e[37],W=e[38],te=e[39];let ae;e[153]!==s.definition.lineage.length?(ae=t.jsxs("summary",{children:["Idea → clip → post (",s.definition.lineage.length," source cells)"]}),e[153]=s.definition.lineage.length,e[154]=ae):ae=e[154];let Y;if(e[155]!==n||e[156]!==c||e[157]!==s.definition.lineage){let J;e[159]!==n||e[160]!==c?(J=de=>{const fe=n.find(ue=>ue.id===de.cellId);return t.jsxs("div",{children:[fe?t.jsxs("button",{type:"button",onClick:()=>c(fe.id),children:[Wt(fe.slot)," · ",de.label??de.type]}):t.jsx("strong",{children:de.label??de.type}),de.prompt&&t.jsx("p",{children:de.prompt})]},de.cellId)},e[159]=n,e[160]=c,e[161]=J):J=e[161],Y=s.definition.lineage.map(J),e[155]=n,e[156]=c,e[157]=s.definition.lineage,e[158]=Y}else Y=e[158];let Q;e[162]!==Y?(Q=t.jsx("div",{className:"post-lineage",children:Y}),e[162]=Y,e[163]=Q):Q=e[163];let Z;e[164]!==ae||e[165]!==Q?(Z=t.jsxs("details",{children:[ae,Q]}),e[164]=ae,e[165]=Q,e[166]=Z):Z=e[166];let re;e[167]!==p?(re=t.jsx("button",{type:"button",className:"post-delete",onClick:p,children:"Remove Post cell"}),e[167]=p,e[168]=re):re=e[168];let ee;return e[169]!==z||e[170]!==_||e[171]!==L||e[172]!==B||e[173]!==U||e[174]!==q||e[175]!==H||e[176]!==K||e[177]!==se||e[178]!==ie||e[179]!==Z||e[180]!==re||e[181]!==V||e[182]!==ce||e[183]!==W||e[184]!==te?(ee=t.jsxs("section",{className:V,"aria-label":ce,children:[W,te,z,_,L,B,U,q,H,K,se,ie,Z,re]}),e[169]=z,e[170]=_,e[171]=L,e[172]=B,e[173]=U,e[174]=q,e[175]=H,e[176]=K,e[177]=se,e[178]=ie,e[179]=Z,e[180]=re,e[181]=V,e[182]=ce,e[183]=W,e[184]=te,e[185]=ee):ee=e[185],ee}function kc(l){return t.jsxs("p",{children:[t.jsxs("strong",{children:[new Date(l.observedAt).toLocaleString()," · ",l.source]}),t.jsx("span",{children:Object.entries(l.values).map(Sc).join(" · ")})]},l.id??`${l.observedAt}-${l.source}`)}function Sc(l){const[e,s]=l;return`${e}: ${s?.toLocaleString()??"—"}`}function wc(l){return t.jsx("a",{href:l.tweet_url,target:"_blank",rel:"noreferrer",children:"Open reply ↗"},l.tweet_id)}function Nc(l){return t.jsx("option",{value:l,children:l==="x"?"X":l},l)}function Cc(l){return t.jsxs("option",{value:l.id,children:[Wt(l.slot)," · ",l.label??l.type]},l.id)}function $c(l){return l.type!=="post"&&l.outputArtifactId&&["image","video","generate_image","generate_video","concat","splice","split_video"].includes(l.type)}const Li=C.createContext(null);function Ic(l){const e=X.c(17),{label:s,shortcut:n,divider:i}=l,a=i===void 0?!0:i,o=C.useContext(Li);if(!o)return null;let r;e[0]!==a?(r=a&&t.jsx("span",{className:"composer-dock-close-divider","aria-hidden":"true"}),e[0]=a,e[1]=r):r=e[1];const c=s?"composer-dock-close composer-dock-close-labeled":"composer-dock-close",d=s??o.hideLabel,u=n?"Escape":void 0,p=`${s??o.hideLabel}${n?" (Esc)":""}`;let m;e[2]!==s?(m=s??t.jsx(mt,{size:14}),e[2]=s,e[3]=m):m=e[3];let b;e[4]!==n?(b=n&&t.jsx("kbd",{"aria-hidden":"true",children:"Esc"}),e[4]=n,e[5]=b):b=e[5];let f;e[6]!==o.hide||e[7]!==c||e[8]!==d||e[9]!==u||e[10]!==p||e[11]!==m||e[12]!==b?(f=t.jsxs("button",{type:"button",className:c,"data-composer-dock-hide":"","aria-label":d,"aria-keyshortcuts":u,title:p,onClick:o.hide,children:[m,b]}),e[6]=o.hide,e[7]=c,e[8]=d,e[9]=u,e[10]=p,e[11]=m,e[12]=b,e[13]=f):f=e[13];let g;return e[14]!==r||e[15]!==f?(g=t.jsxs(t.Fragment,{children:[r,f]}),e[14]=r,e[15]=f,e[16]=g):g=e[16],g}function zi(l){const e=X.c(35),{label:s,targetSelector:n,edge:i,minimum:a,reserve:o,onResize:r}=l,c=o===void 0?0:o,d=C.useRef(null),u=C.useRef(null);let p;e[0]!==a?(p={height:a,min:a,max:a},e[0]=a,e[1]=p):p=e[1];const[m,b]=C.useState(p);let f,g;e[2]!==a||e[3]!==c||e[4]!==n?(f=()=>{const P=d.current?.closest(n);if(!P)return;const T=()=>{const I=parseFloat(getComputedStyle(P).maxHeight),D=c>0&&P.parentElement?P.parentElement.clientHeight-c:window.innerHeight,F=Math.max(0,Math.min(Number.isFinite(I)?I:D,D)),R={height:Math.round(P.getBoundingClientRect().height),min:Math.min(a,F),max:Math.round(F)};b(E=>E.height===R.height&&E.min===R.min&&E.max===R.max?E:R)},A=new ResizeObserver(T);return A.observe(P),P.parentElement&&A.observe(P.parentElement),T(),()=>A.disconnect()},g=[a,c,n],e[2]=a,e[3]=c,e[4]=n,e[5]=f,e[6]=g):(f=e[5],g=e[6]),C.useLayoutEffect(f,g);let h;e[7]!==r||e[8]!==m.max||e[9]!==m.min?(h=P=>r(Math.round(Math.max(m.min,Math.min(m.max,P)))),e[7]=r,e[8]=m.max,e[9]=m.min,e[10]=h):h=e[10];const y=h,x=i==="top"?-1:1,j=`pane-resize-handle pane-resize-handle-${i}`,v=`${m.height} pixels`;let k;e[11]!==m.height||e[12]!==n?(k=P=>{if(P.button!==0)return;P.preventDefault(),P.currentTarget.focus({preventScroll:!0}),P.currentTarget.setPointerCapture(P.pointerId);const T=d.current?.closest(n);u.current={y:P.clientY,height:T?Math.round(T.getBoundingClientRect().height):m.height}},e[11]=m.height,e[12]=n,e[13]=k):k=e[13];let w;e[14]!==x||e[15]!==y?(w=P=>{const T=u.current;T&&y(T.height+x*(P.clientY-T.y))},e[14]=x,e[15]=y,e[16]=w):w=e[16];let S,M;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=P=>{u.current=null,P.currentTarget.hasPointerCapture(P.pointerId)&&P.currentTarget.releasePointerCapture(P.pointerId)},M=()=>{u.current=null},e[17]=S,e[18]=M):(S=e[17],M=e[18]);let N;e[19]!==x||e[20]!==y||e[21]!==m.height||e[22]!==m.max||e[23]!==m.min?(N=P=>{["ArrowUp","ArrowDown","Home","End"].includes(P.key)&&(P.preventDefault(),P.stopPropagation(),P.key==="Home"?y(m.min):P.key==="End"?y(m.max):y(m.height+x*(P.key==="ArrowUp"?-24:24)))},e[19]=x,e[20]=y,e[21]=m.height,e[22]=m.max,e[23]=m.min,e[24]=N):N=e[24];let $;return e[25]!==s||e[26]!==m.height||e[27]!==m.max||e[28]!==m.min||e[29]!==N||e[30]!==j||e[31]!==v||e[32]!==k||e[33]!==w?($=t.jsx("div",{ref:d,className:j,role:"separator","aria-label":s,"aria-orientation":"horizontal","aria-valuemin":m.min,"aria-valuemax":m.max,"aria-valuenow":m.height,"aria-valuetext":v,tabIndex:0,"data-composer-focus":"preserve",onPointerDown:k,onPointerMove:w,onPointerUp:S,onLostPointerCapture:M,onKeyDown:N}),e[25]=s,e[26]=m.height,e[27]=m.max,e[28]=m.min,e[29]=N,e[30]=j,e[31]=v,e[32]=k,e[33]=w,e[34]=$):$=e[34],$}function Tl(l,e){const s=e.getBoundingClientRect(),n=12,i=s.top>window.innerHeight-s.bottom,a=Math.min(560,window.innerWidth-n*2);l.style.left=`${Math.max(n,Math.min(s.left,window.innerWidth-a-n))}px`,l.style.top=i?"auto":`${s.bottom+8}px`,l.style.bottom=i?`${window.innerHeight-s.top+8}px`:"auto",l.style.maxHeight=`${Math.max(0,(i?s.top:window.innerHeight-s.bottom)-n-8)}px`}function El(l){const e=X.c(65),{call:s,active:n,onToggle:i}=l,a=n===void 0?!0:n,o=C.useId(),r=C.useRef(null),c=C.useRef(null);let d,u;e[0]!==a||e[1]!==s.expanded?(d=()=>{const q=c.current,H=r.current;if(!q||!H)return;if(!a){q.hidePopover();return}if(!s.expanded)return;const K=()=>Tl(q,H);K();const se=new ResizeObserver(K);se.observe(H);const ie=H.closest(".composer-history");return ie&&se.observe(ie),window.addEventListener("resize",K),window.addEventListener("scroll",K,!0),()=>{se.disconnect(),window.removeEventListener("resize",K),window.removeEventListener("scroll",K,!0)}},u=[a,s.expanded],e[0]=a,e[1]=s.expanded,e[2]=d,e[3]=u):(d=e[2],u=e[3]),C.useLayoutEffect(d,u);const p=`mcp-call mcp-call-${s.phase}`,m=s.tool,b=s.expanded;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{className:"composer-history-kind mcp-call-channel",children:"ACTION"}),e[4]=f):f=e[4];let g;e[5]!==s.tool?(g=pn(s.tool),e[5]=s.tool,e[6]=g):g=e[6];let h;e[7]!==g?(h=t.jsx("span",{className:"composer-history-text mcp-call-name",children:g}),e[7]=g,e[8]=h):h=e[8];let y;e[9]!==s.phase?(y=s.phase==="running"&&t.jsxs("span",{className:"mcp-call-signal","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),e[9]=s.phase,e[10]=y):y=e[10];let x;e[11]!==s?(x=dl(s),e[11]=s,e[12]=x):x=e[12];let j;e[13]!==x?(j=t.jsx("span",{className:"mcp-call-state",children:x}),e[13]=x,e[14]=j):j=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(zo,{className:"mcp-call-details-icon",size:14,"aria-hidden":"true"}),e[15]=v):v=e[15];let k;e[16]!==y||e[17]!==j?(k=t.jsxs("span",{className:"mcp-call-trail",children:[y,j,v]}),e[16]=y,e[17]=j,e[18]=k):k=e[18];let w;e[19]!==s.expanded||e[20]!==o||e[21]!==k||e[22]!==h?(w=t.jsxs("button",{ref:r,type:"button",className:"composer-history-entry mcp-call-head",popoverTarget:o,"aria-haspopup":"dialog","aria-controls":o,"aria-expanded":b,children:[f,h,k]}),e[19]=s.expanded,e[20]=o,e[21]=k,e[22]=h,e[23]=w):w=e[23];let S;e[24]!==s.tool?(S=pn(s.tool),e[24]=s.tool,e[25]=S):S=e[25];const M=`${S} details`;let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=q=>{q.newState==="open"&&r.current&&Tl(q.currentTarget,r.current)},e[26]=N):N=e[26];let $;e[27]!==s.expanded||e[28]!==s.id||e[29]!==i?($=q=>{q.newState==="open"!==s.expanded&&i(s.id)},e[27]=s.expanded,e[28]=s.id,e[29]=i,e[30]=$):$=e[30];let P;e[31]!==s.tool?(P=pn(s.tool),e[31]=s.tool,e[32]=P):P=e[32];let T;e[33]!==P?(T=t.jsx("span",{children:P}),e[33]=P,e[34]=T):T=e[34];let A;e[35]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(mt,{size:14,"aria-hidden":"true"}),e[35]=A):A=e[35];let I;e[36]!==o?(I=t.jsx("button",{type:"button",popoverTarget:o,popoverTargetAction:"hide","aria-label":"Close action details",autoFocus:!0,children:A}),e[36]=o,e[37]=I):I=e[37];let D;e[38]!==T||e[39]!==I?(D=t.jsxs("header",{className:"mcp-call-popover-head",children:[T,I]}),e[38]=T,e[39]=I,e[40]=D):D=e[40];const F=s.tool;let R;e[41]!==s?(R=dl(s),e[41]=s,e[42]=R):R=e[42];let E;e[43]!==s.tool||e[44]!==R?(E=t.jsxs("p",{className:"mcp-call-what",children:[F," · ",R]}),e[43]=s.tool,e[44]=R,e[45]=E):E=e[45];let z;e[46]!==s.args?(z=s.args.length>0&&t.jsx("dl",{className:"mcp-call-args",children:s.args.map(Rc)}),e[46]=s.args,e[47]=z):z=e[47];let _;e[48]!==s.detail?(_=s.detail&&t.jsxs("p",{className:"mcp-call-out",children:[t.jsx("b",{"aria-hidden":"true",children:"→"}),t.jsx("span",{children:s.detail})]}),e[48]=s.detail,e[49]=_):_=e[49];let L;e[50]!==E||e[51]!==z||e[52]!==_?(L=t.jsxs("div",{className:"mcp-call-body",children:[E,z,_]}),e[50]=E,e[51]=z,e[52]=_,e[53]=L):L=e[53];let B;e[54]!==o||e[55]!==M||e[56]!==$||e[57]!==D||e[58]!==L?(B=t.jsxs("div",{ref:c,id:o,className:"mcp-call-popover",popover:"auto",role:"dialog","aria-label":M,onBeforeToggle:N,onToggle:$,onKeyDown:Mc,children:[D,L]}),e[54]=o,e[55]=M,e[56]=$,e[57]=D,e[58]=L,e[59]=B):B=e[59];let U;return e[60]!==s.tool||e[61]!==w||e[62]!==B||e[63]!==p?(U=t.jsxs("div",{className:p,"data-tool":m,children:[w,B]}),e[60]=s.tool,e[61]=w,e[62]=B,e[63]=p,e[64]=U):U=e[64],U}function Rc(l){return t.jsxs(C.Fragment,{children:[t.jsx("dt",{children:l.name}),t.jsx("dd",{children:l.value})]},l.name)}function Mc(l){l.key==="Escape"&&l.stopPropagation()}const Bi=C.createContext(null),Al=28;function Pc(l){const e=X.c(39),{rows:s,phase:n,voicePresent:i,open:a,onToggleCall:o,connected:r,onDetailsChange:c,children:d}=l,u=r===void 0?!0:r,p=C.useId(),b=C.useContext(Bi)?.captionId??p,f=C.useRef(null),g=C.useRef(!0),h=C.useRef(void 0),[y,x]=C.useState(!1);let j;e[0]!==d||e[1]!==n||e[2]!==s||e[3]!==i?(j=!d&&In(n,s.length,i),e[0]=d,e[1]=n,e[2]=s,e[3]=i,e[4]=j):j=e[4];const v=j;let k;e[5]!==v||e[6]!==c||e[7]!==a||e[8]!==s?(k=()=>{const I=f.current;if(c?.(a&&!!I?.querySelector(".chat-turn-details[open]")),v||!I||!a)return;const D=s.filter(Ec).at(-1)?.sequence;D!==h.current&&(g.current=!0),h.current=D,g.current&&(I.scrollTop=I.scrollHeight);const F=I.scrollHeight-I.scrollTop-I.clientHeight<Al;g.current=F,x(!F&&s.length>0)},e[5]=v,e[6]=c,e[7]=a,e[8]=s,e[9]=k):k=e[9];let w;if(e[10]!==d||e[11]!==v||e[12]!==c||e[13]!==a||e[14]!==s?(w=[d,v,c,a,s],e[10]=d,e[11]=v,e[12]=c,e[13]=a,e[14]=s,e[15]=w):w=e[15],C.useLayoutEffect(k,w),v)return null;const S=a?"true":"false",M=!a;let N;e[16]!==s.length?(N=I=>{const D=I.currentTarget,F=D.scrollHeight-D.scrollTop-D.clientHeight<Al;g.current=F,x(!F&&s.length>0)},e[16]=s.length,e[17]=N):N=e[17];let $;e[18]!==d||e[19]!==u||e[20]!==c||e[21]!==o||e[22]!==a||e[23]!==n||e[24]!==s?($=s.length===0&&!d?t.jsxs("p",{className:"composer-history-entry voice-captions-empty",children:[t.jsx("span",{className:"composer-history-kind",children:"STATUS"}),t.jsx("span",{children:Ra(n??"off")})]}):s.map(I=>t.jsx(Dc,{row:I,active:a,connected:u,onToggleCall:o,onDetailsChange:()=>c?.(!!f.current?.querySelector(".chat-turn-details[open]"))},Ac(I))),e[18]=d,e[19]=u,e[20]=c,e[21]=o,e[22]=a,e[23]=n,e[24]=s,e[25]=$):$=e[25];let P;e[26]!==b||e[27]!==d||e[28]!==M||e[29]!==N||e[30]!==$?(P=t.jsxs("div",{ref:f,id:b,className:"composer-history voice-captions","data-testid":"composer-history",hidden:M,"aria-label":"Message log",role:"log","aria-live":"off",onScroll:N,children:[$,d]}),e[26]=b,e[27]=d,e[28]=M,e[29]=N,e[30]=$,e[31]=P):P=e[31];let T;e[32]!==a||e[33]!==y?(T=a&&y&&t.jsx("button",{type:"button",className:"voice-captions-latest",onMouseDown:Tc,onClick:()=>{g.current=!0,x(!1);const I=f.current;I&&(I.scrollTop=I.scrollHeight)},children:"Latest"}),e[32]=a,e[33]=y,e[34]=T):T=e[34];let A;return e[35]!==T||e[36]!==S||e[37]!==P?(A=t.jsxs("div",{className:"composer-history-panel","data-history-open":S,children:[P,T]}),e[35]=T,e[36]=S,e[37]=P,e[38]=A):A=e[38],A}function Tc(l){return l.preventDefault()}function Ec(l){return l.kind==="caption"&&l.turn}function Ac(l){return l.kind==="status"?`status:${l.sequence}`:l.kind==="caption"?`caption:${l.caption.id}`:`call:${l.call.id}`}function Dc(l){const e=X.c(65),{row:s,active:n,onToggleCall:i,connected:a,onDetailsChange:o}=l;if(s.kind==="call"){let f;return e[0]!==n||e[1]!==i||e[2]!==s.call?(f=t.jsx(El,{call:s.call,active:n,onToggle:i}),e[0]=n,e[1]=i,e[2]=s.call,e[3]=f):f=e[3],f}if(s.kind==="status"){let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{className:"composer-history-kind",children:"STATUS"}),e[4]=f):f=e[4];let g;e[5]!==s.text?(g=t.jsx("span",{className:"composer-history-text",children:s.text}),e[5]=s.text,e[6]=g):g=e[6];let h;return e[7]!==s.goalId||e[8]!==g?(h=t.jsxs("p",{className:"composer-history-entry","data-role":"status","data-goal-id":s.goalId,children:[f,g]}),e[7]=s.goalId,e[8]=g,e[9]=h):h=e[9],h}const r=s.caption;if(s.turn){const f=s.turn;let g;e[10]!==a||e[11]!==f?(g=a&&si(f)&&f.status!=="review",e[10]=a,e[11]=f,e[12]=g):g=e[12];const h=g,y=f.id,x=f.status;let j;e[13]!==f.text?(j=t.jsx("p",{className:"chat-bubble chat-bubble-user","aria-label":"Your message",children:f.text}),e[13]=f.text,e[14]=j):j=e[14];let v;e[15]!==a||e[16]!==f?(v=ul(f,a),e[15]=a,e[16]=f,e[17]=v):v=e[17];const k=`Message activity: ${v}`;let w;e[18]!==h?(w=h&&t.jsxs("span",{className:"chat-working-dots","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),e[18]=h,e[19]=w):w=e[19];let S;e[20]!==a||e[21]!==f?(S=ul(f,a),e[20]=a,e[21]=f,e[22]=S):S=e[22];let M;e[23]!==S?(M=t.jsx("span",{children:S}),e[23]=S,e[24]=M):M=e[24];let N;e[25]!==w||e[26]!==M?(N=t.jsxs("span",{className:"chat-turn-status",role:"status","aria-live":"polite",children:[w,M]}),e[25]=w,e[26]=M,e[27]=N):N=e[27];let $;e[28]!==N||e[29]!==k?($=t.jsx("summary",{"aria-label":k,children:N}),e[28]=N,e[29]=k,e[30]=$):$=e[30];let P;e[31]!==f.work?(P=f.work.map(Fc),e[31]=f.work,e[32]=P):P=e[32];let T;e[33]!==n||e[34]!==i||e[35]!==s.calls?(T=s.calls?.map(R=>t.jsx(El,{call:R,active:n,onToggle:i},R.id)),e[33]=n,e[34]=i,e[35]=s.calls,e[36]=T):T=e[36];let A;e[37]!==P||e[38]!==T?(A=t.jsxs("div",{className:"chat-turn-work",children:[P,T]}),e[37]=P,e[38]=T,e[39]=A):A=e[39];let I;e[40]!==o||e[41]!==$||e[42]!==A?(I=t.jsxs("details",{className:"chat-turn-details",onToggle:o,children:[$,A]}),e[40]=o,e[41]=$,e[42]=A,e[43]=I):I=e[43];let D;e[44]!==f.reply?(D=f.reply&&t.jsx("p",{className:"chat-bubble chat-bubble-assistant","aria-label":"Copilot reply",children:f.reply}),e[44]=f.reply,e[45]=D):D=e[45];let F;return e[46]!==I||e[47]!==D||e[48]!==j||e[49]!==f.id||e[50]!==f.status?(F=t.jsxs("article",{className:"chat-turn","data-turn-id":y,"data-status":x,children:[j,I,D]}),e[46]=I,e[47]=D,e[48]=j,e[49]=f.id,e[50]=f.status,e[51]=F):F=e[51],F}const c=`composer-history-entry chat-bubble chat-bubble-${r.role}`,d=r.role==="user"?"YOU":"COPILOT";let u;e[52]!==d?(u=t.jsx("span",{className:"composer-history-kind",children:d}),e[52]=d,e[53]=u):u=e[53];let p;e[54]!==r.interrupted?(p=r.interrupted&&t.jsx("em",{children:" · interrupted"}),e[54]=r.interrupted,e[55]=p):p=e[55];let m;e[56]!==r.text||e[57]!==p?(m=t.jsxs("span",{className:"composer-history-text",children:[r.text,p]}),e[56]=r.text,e[57]=p,e[58]=m):m=e[58];let b;return e[59]!==r.final||e[60]!==r.role||e[61]!==c||e[62]!==u||e[63]!==m?(b=t.jsxs("p",{className:c,"data-final":r.final,"data-role":r.role,children:[u,m]}),e[59]=r.final,e[60]=r.role,e[61]=c,e[62]=u,e[63]=m,e[64]=b):b=e[64],b}function Fc(l){return t.jsxs("p",{children:[t.jsx("span",{children:l.label}),t.jsx("span",{children:l.detail??l.state})]},l.key)}function Dl(l){const e=X.c(15),{dismissLabel:s,message:n,onDismiss:i,tone:a}=l,o=a==="error",r=`chat-bubble chat-bubble-assistant chat-feedback command-result ${o?"command-result-error":"command-result-ok"}`,c=o?"alert":"status",d=o?"ERROR":"STATUS";let u;e[0]!==d?(u=t.jsx("span",{className:"composer-history-kind",children:d}),e[0]=d,e[1]=u):u=e[1];let p;e[2]!==n?(p=t.jsx("span",{children:n}),e[2]=n,e[3]=p):p=e[3];let m;e[4]!==u||e[5]!==p?(m=t.jsxs("div",{className:"chat-feedback-content",children:[u,p]}),e[4]=u,e[5]=p,e[6]=m):m=e[6];let b;e[7]!==s||e[8]!==i?(b=i&&t.jsx("button",{type:"button",className:"command-result-dismiss","aria-label":s,onClick:i,children:t.jsx(mt,{size:12,"aria-hidden":"true"})}),e[7]=s,e[8]=i,e[9]=b):b=e[9];let f;return e[10]!==r||e[11]!==c||e[12]!==m||e[13]!==b?(f=t.jsxs("div",{className:r,role:c,"aria-live":"polite",children:[m,b]}),e[10]=r,e[11]=c,e[12]=m,e[13]=b,e[14]=f):f=e[14],f}function xs(l){const e=X.c(7),{asset:s,kindHint:n,videoFrame:i}=l,a=i===void 0?!1:i,[o,r]=C.useState(null),c=s?.thumbnailUrl??(s?.type==="image"?s.mediaUrl:null),d=s?.type??n??"unknown",u=d==="audio"||n==="generate_audio"||n==="extract_audio",p=d==="video"||d==="final"||n==="generate_video"||n==="split_video"||n==="concat"||n==="splice",m=d==="image"||n==="generate_image",b=a&&p&&!c?s?.mediaUrl:null;let f;return e[0]!==u||e[1]!==o||e[2]!==b||e[3]!==m||e[4]!==c||e[5]!==p?(f=t.jsx("span",{className:"inspector-source-thumb","aria-hidden":"true",children:c&&c!==o?t.jsx("img",{src:c,alt:"",loading:"lazy",decoding:"async",onError:()=>r(c)}):b&&b!==o?t.jsx("video",{src:`${b}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata",onError:()=>r(b)}):u?t.jsx(ss,{size:16}):p?t.jsx(St,{size:16}):m?t.jsx(Zt,{size:16}):t.jsx(Ms,{size:15})}),e[0]=u,e[1]=o,e[2]=b,e[3]=m,e[4]=c,e[5]=p,e[6]=f):f=e[6],f}function _c(l){const e=X.c(8),{token:s,reference:n}=l,i=n?.asset,a=n?.type;let o;e[0]!==i||e[1]!==a?(o=t.jsx(xs,{asset:i,kindHint:a}),e[0]=i,e[1]=a,e[2]=o):o=e[2];let r;e[3]!==s?(r=t.jsx("span",{className:"composer-reference-address",children:s}),e[3]=s,e[4]=r):r=e[4];let c;return e[5]!==o||e[6]!==r?(c=t.jsxs(t.Fragment,{children:[o,r]}),e[5]=o,e[6]=r,e[7]=c):c=e[7],c}function Hs(l){return ni(l.state.doc,l.state.selection.anchor,l.state.selection.head)}function Fl(l){return{class:"command-rich-input",role:"combobox","aria-label":"Videobook command input","aria-autocomplete":"list","aria-expanded":String(l.expanded),"aria-disabled":String(l.disabled),"data-workspace-action-surface":"slash","data-placeholder":l.placeholder,"data-empty":String(l.value.length===0),tabindex:l.disabled?"-1":"0",spellcheck:"false",autocapitalize:"none",...l.controls?{"aria-controls":l.controls}:{},...l.activeDescendant?{"aria-activedescendant":l.activeDescendant}:{}}}function Lc({ref:l,...e}){const[s]=C.useState({value:e.value,disabled:e.disabled}),n=C.useRef(null),i=C.useRef(null),a=C.useRef(e),o=C.useRef(e.session),r=C.useRef(!1),c=C.useRef(0),d=C.useRef(new Set);return C.useImperativeHandle(l,()=>({element:()=>i.current?.dom??null,selection:()=>i.current?Hs(i.current):{start:0,end:0},select:()=>{const u=i.current;u&&u.dispatch(ml(u.state.tr,{start:0,end:is(u.state.doc).length}))},setSelection:u=>{const p=i.current;if(!p)return;const m=u.start<Hs(p).start?-1:1;p.dispatch(ml(p.state.tr,u,m).scrollIntoView())},replace:(u,p={start:u.length,end:u.length})=>{const m=i.current;m&&m.dispatch(us(vs(m.state.tr,u,p,a.current.rich!==!1)).scrollIntoView())}}),[]),C.useLayoutEffect(()=>{const u=n.current;if(!u)return;const p=a.current;let b=p.sessions.get(p.session)??al.create({schema:fl,doc:pl(p.value,p.rich!==!1),plugins:[pa(),rl({"Mod-z":ba,"Mod-Shift-z":ol,"Mod-y":ol}),rl(xa)]});is(b.doc)!==p.value&&(b=b.apply(us(vs(b.tr,p.value,{start:p.value.length,end:p.value.length},p.rich!==!1))));const f=x=>{let j=String(x.attrs.token);const v=document.createElement("span");v.className="composer-reference-chip",v.contentEditable="false",v.setAttribute("role","img");const k=fa.createRoot(v),w=()=>{const S=a.current.references.get(j.toLowerCase()),M=S?li(S):"Unavailable reference",N=[j,S?.label,M].filter(Boolean).join(" · ");v.dataset.reference=j,v.setAttribute("aria-label",N),v.title=N,k.render(t.jsx(_c,{token:j,reference:S}))};return w(),d.current.add(w),{dom:v,update(S){return S.type!==x.type?!1:(j=String(S.attrs.token),w(),!0)},ignoreMutation:S=>S.type!=="selection",destroy(){d.current.delete(w),queueMicrotask(()=>k.unmount())}}},g=x=>{const j=i.current;if(!j)return;if(!j.composing&&!r.current&&(x.docChanged||x.getMeta("normalizeReferences"))){const w=ni(x.doc,x.selection.anchor,x.selection.head);vs(x,is(x.doc),w,a.current.rich!==!1)}const v=j.state;j.updateState(v.apply(x)),a.current.sessions.set(o.current,j.state);const k=Hs(j);v.doc.eq(j.state.doc)?v.selection.eq(j.state.selection)||a.current.onSelectionChange(k):a.current.onChange(is(j.state.doc),k)},h=(x,j,v)=>!j.clipboardData||x.state.selection.empty?!1:(j.preventDefault(),j.clipboardData.clearData(),j.clipboardData.setData("text/plain",is(x.state.doc,x.state.selection.from,x.state.selection.to)),v&&!a.current.disabled&&x.dispatch(us(x.state.tr.deleteSelection())),!0),y=new ha({mount:u},{state:b,editable:()=>!a.current.disabled,attributes:Fl(p),dispatchTransaction:g,nodeViews:{reference:f},clipboardTextSerializer:x=>x.content.textBetween(0,x.content.size,"",j=>String(j.attrs.token??"")),handleKeyDown:(x,j)=>{if(j.isComposing||j.altKey||j.ctrlKey||j.metaKey||j.shiftKey||!x.state.selection.empty)return!1;const{$from:v}=x.state.selection,k=j.key==="Backspace";if(!k&&j.key!=="Delete")return!1;const w=k?v.nodeBefore:v.nodeAfter;if(w?.type.name!=="reference")return!1;const S=k?v.pos-w.nodeSize:v.pos;return x.dispatch(us(x.state.tr.delete(S,S+w.nodeSize)).scrollIntoView()),!0},handlePaste:(x,j)=>{if(!j.clipboardData)return!1;j.preventDefault();const v=j.clipboardData.getData("text/plain").replace(/\r\n?/gu,`
2
+ `);return x.dispatch(us(x.state.tr.insertText(v)).scrollIntoView()),!0},handleDOMEvents:{focus:()=>(a.current.onFocus(),!1),keydown:(x,j)=>(a.current.onKeyDown(j),j.defaultPrevented),copy:(x,j)=>h(x,j,!1),cut:(x,j)=>h(x,j,!0),compositionstart:()=>(r.current=!0,a.current.onCompositionChange(!0),!1),compositionend:()=>(r.current=!1,a.current.onCompositionChange(!1),window.cancelAnimationFrame(c.current),c.current=window.requestAnimationFrame(()=>{const x=i.current;x&&!x.composing&&x.dispatch(x.state.tr.setMeta("normalizeReferences",!0))}),!1)}});return i.current=y,()=>{window.cancelAnimationFrame(c.current),a.current.sessions.set(o.current,y.state),i.current=null,y.destroy()}},[]),C.useLayoutEffect(()=>{const u=i.current,p=a.current.references;if(a.current=e,!u)return;const m=o.current!==e.session;if(m){o.current.includes(":actions-")?e.sessions.delete(o.current):e.sessions.set(o.current,u.state);let f=e.sessions.get(e.session)??al.create({schema:fl,doc:pl(e.value,e.rich!==!1),plugins:u.state.plugins});is(f.doc)!==e.value&&(f=f.apply(us(vs(f.tr,e.value,{start:e.value.length,end:e.value.length},e.rich!==!1)))),o.current=e.session,r.current=!1,u.updateState(f)}else if(!u.composing&&is(u.state.doc)!==e.value){const b={start:e.value.length,end:e.value.length};u.updateState(u.state.apply(vs(u.state.tr,e.value,b,e.rich!==!1).setMeta("addToHistory",!1)))}if(u.setProps({attributes:Fl(e),editable:()=>!a.current.disabled}),m&&e.onSelectionChange(Hs(u)),p!==e.references)for(const b of d.current)b()},[e]),t.jsx("div",{className:"command-editor-mount",children:t.jsx("div",{ref:n,role:"combobox","aria-label":"Videobook command input","aria-disabled":s.disabled,contentEditable:!s.disabled,suppressContentEditableWarning:!0,children:s.value})})}function zc(l){const e=X.c(44),{actions:s,groups:n,group:i,context:a,loading:o,error:r,listId:c,selectedIndex:d,onGroupChange:u,onClose:p,onSelect:m}=l;let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("strong",{children:"Actions"}),e[0]=b):b=e[0];let f;e[1]!==u?(f=A=>u(A.target.value),e[1]=u,e[2]=f):f=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("option",{value:"",children:"All categories"}),e[3]=g):g=e[3];let h;e[4]!==n?(h=n.map(Oc),e[4]=n,e[5]=h):h=e[5];let y;e[6]!==i||e[7]!==f||e[8]!==h?(y=t.jsxs("label",{children:["Category",t.jsxs("select",{"aria-label":"Action category",value:i,onChange:f,children:[g,h]})]}),e[6]=i,e[7]=f,e[8]=h,e[9]=y):y=e[9];const x=o?"Loading actions…":`${s.length} actions`;let j;e[10]!==x?(j=t.jsx("span",{role:"status",children:x}),e[10]=x,e[11]=j):j=e[11];let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(mt,{size:15}),e[12]=v):v=e[12];let k;e[13]!==p?(k=t.jsx("button",{type:"button","aria-label":"Close action search",onClick:p,children:v}),e[13]=p,e[14]=k):k=e[14];let w;e[15]!==y||e[16]!==j||e[17]!==k?(w=t.jsxs("header",{children:[b,y,j,k]}),e[15]=y,e[16]=j,e[17]=k,e[18]=w):w=e[18];let S;e[19]!==r?(S=r&&t.jsx("p",{role:"alert",children:r}),e[19]=r,e[20]=S):S=e[20];let M;if(e[21]!==s||e[22]!==a||e[23]!==c||e[24]!==m||e[25]!==d){let A;e[27]!==a||e[28]!==c||e[29]!==m||e[30]!==d?(A=(I,D)=>{const F=ii(I,a);return t.jsxs("button",{type:"button",role:"option",id:`${c}-option-${D}`,"aria-selected":D===d,className:D===d?"active":"","data-action-id":I.id,"data-command":I.command,onMouseDown:Bc,onClick:()=>m(I),children:[t.jsxs("span",{children:[t.jsx("strong",{children:I.title}),t.jsx("code",{children:I.command})]}),t.jsx("small",{children:I.description}),F&&t.jsx("small",{className:"composer-action-unavailable",children:F})]},I.id)},e[27]=a,e[28]=c,e[29]=m,e[30]=d,e[31]=A):A=e[31],M=s.map(A),e[21]=s,e[22]=a,e[23]=c,e[24]=m,e[25]=d,e[26]=M}else M=e[26];let N;e[32]!==s.length||e[33]!==o?(N=!o&&!s.length&&t.jsx("p",{children:"No matching actions. Try an operation, media type or command alias."}),e[32]=s.length,e[33]=o,e[34]=N):N=e[34];let $;e[35]!==c||e[36]!==M||e[37]!==N?($=t.jsxs("div",{id:c,role:"listbox","aria-label":"Available actions",className:"workspace-actions-list",children:[M,N]}),e[35]=c,e[36]=M,e[37]=N,e[38]=$):$=e[38];let P;e[39]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx("p",{className:"composer-actions-help",children:"Choose an action to prepare its command. Submit when ready."}),e[39]=P):P=e[39];let T;return e[40]!==w||e[41]!==S||e[42]!==$?(T=t.jsxs("section",{className:"command-suggestions composer-actions-panel","aria-label":"Actions","data-workspace-action-surface":"launcher",children:[w,S,$,P]}),e[40]=w,e[41]=S,e[42]=$,e[43]=T):T=e[43],T}function Bc(l){return l.preventDefault()}function Oc(l){return t.jsx("option",{children:l},l)}function ut(l){const e=X.c(2),{size:s}=l,n=s===void 0?16:s;let i;return e[0]!==n?(i=t.jsx("span",{className:"busy-indicator","aria-hidden":"true",children:t.jsx(zn,{size:n})}),e[0]=n,e[1]=i):i=e[1],i}const Oi=C.createContext(null);function Uc(l){const e=X.c(15),{voices:s,selectedVoiceId:n,playingVoiceId:i,disabled:a,onSelect:o,onTogglePreview:r}=l,c=a===void 0?!1:a;let d;if(e[0]!==c||e[1]!==o||e[2]!==r||e[3]!==i||e[4]!==n||e[5]!==s){let p;e[7]!==c||e[8]!==o||e[9]!==r||e[10]!==i||e[11]!==n?(p=m=>{const b=m.voiceId===n;return t.jsxs("div",{className:b?"speak-preview-voice selected":"speak-preview-voice",role:"option","aria-selected":b,"data-voice-id":m.voiceId,children:[t.jsxs("button",{type:"button",className:b?"active speak-preview-select":"speak-preview-select",disabled:c,onMouseDown:Kc,onClick:()=>o(m.voiceId),children:[t.jsx("strong",{children:m.name}),t.jsxs("span",{className:"speak-preview-badge",children:[m.source,m.category?` · ${m.category}`:""]})]}),m.previewUrl&&t.jsx("button",{type:"button",className:"speak-preview-play",disabled:c,onMouseDown:Hc,onClick:()=>r(m.voiceId,m.previewUrl),children:i===m.voiceId?"Pause":"Preview"})]},m.voiceId)},e[7]=c,e[8]=o,e[9]=r,e[10]=i,e[11]=n,e[12]=p):p=e[12],d=s.map(p),e[0]=c,e[1]=o,e[2]=r,e[3]=i,e[4]=n,e[5]=s,e[6]=d}else d=e[6];let u;return e[13]!==d?(u=t.jsx(t.Fragment,{children:d}),e[13]=d,e[14]=u):u=e[14],u}function Hc(l){return l.preventDefault()}function Kc(l){return l.preventDefault()}function Vc(l){const e=X.c(32),{voices:s,selectedVoiceId:n,playingVoiceId:i,status:a,warning:o,loading:r,error:c,onSelect:d,onTogglePreview:u,onRefresh:p}=l;let m;if(e[0]!==n||e[1]!==s){let S;e[3]!==n?(S=M=>M.voiceId===n,e[3]=n,e[4]=S):S=e[4],m=s.find(S),e[0]=n,e[1]=s,e[2]=m}else m=e[2];const b=m;let f;e[5]!==r||e[6]!==s.length?(f=r&&s.length===0&&t.jsx("p",{className:"speak-preview-status",children:"Loading voices…"}),e[5]=r,e[6]=s.length,e[7]=f):f=e[7];let g;e[8]!==c?(g=c&&t.jsx("p",{className:"speak-preview-error",role:"alert",children:c}),e[8]=c,e[9]=g):g=e[9];const h=r?"Loading voices…":c?"Retry voices":s.length===0?"Load voices":"Refresh voices";let y;e[10]!==r||e[11]!==p||e[12]!==h?(y=t.jsx("button",{type:"button",className:"speak-preview-refresh",disabled:r,onMouseDown:qc,onClick:p,children:h}),e[10]=r,e[11]=p,e[12]=h,e[13]=y):y=e[13];let x;e[14]!==d||e[15]!==u||e[16]!==i||e[17]!==n||e[18]!==s?(x=t.jsx(Uc,{voices:s,selectedVoiceId:n,playingVoiceId:i,onSelect:d,onTogglePreview:u}),e[14]=d,e[15]=u,e[16]=i,e[17]=n,e[18]=s,e[19]=x):x=e[19];let j;e[20]!==a||e[21]!==o?(j=(o||a==="fallback")&&o&&t.jsx("p",{className:"speak-preview-warning",children:o}),e[20]=a,e[21]=o,e[22]=j):j=e[22];const v=b?` · ${b.name}`:"";let k;e[23]!==v?(k=t.jsxs("p",{className:"speak-preview-hint",children:["↑↓ voice · tab select · ctrl+space preview · enter speak · esc close",v]}),e[23]=v,e[24]=k):k=e[24];let w;return e[25]!==f||e[26]!==g||e[27]!==y||e[28]!==x||e[29]!==j||e[30]!==k?(w=t.jsxs("div",{className:"command-suggestions speak-preview",role:"listbox","aria-label":"ElevenLabs voices","data-testid":"speak-command-preview",children:[f,g,y,x,j,k]}),e[25]=f,e[26]=g,e[27]=y,e[28]=x,e[29]=j,e[30]=k,e[31]=w):w=e[31],w}function qc(l){return l.preventDefault()}function Wc(l){const e=X.c(15),{feedback:s,onResumePlayback:n}=l,i=`chat-bubble chat-bubble-assistant chat-voice-activity${s.error?" chat-voice-error":""}`;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("span",{className:"composer-history-kind",children:"VOICE"}),e[0]=a):a=e[0];let o;e[1]!==s.busy||e[2]!==s.error||e[3]!==s.message?(o=s.message&&t.jsxs("p",{className:"chat-turn-status",role:s.error?"alert":"status",children:[s.busy&&t.jsxs("span",{className:"chat-working-dots","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),t.jsx("span",{children:s.message})]}),e[1]=s.busy,e[2]=s.error,e[3]=s.message,e[4]=o):o=e[4];let r;e[5]!==s.fallbackReason?(r=s.fallbackReason&&t.jsxs("details",{className:"voice-fallback",children:[t.jsx("summary",{children:"Using xAI · OpenAI unavailable"}),t.jsx("p",{children:s.fallbackReason})]}),e[5]=s.fallbackReason,e[6]=r):r=e[6];let c;e[7]!==s.playbackBlocked||e[8]!==n?(c=s.playbackBlocked&&t.jsxs("button",{className:"voice-resume",type:"button",onClick:n,children:[t.jsx(Bo,{size:14,"aria-hidden":"true"}),"Enable spoken replies"]}),e[7]=s.playbackBlocked,e[8]=n,e[9]=c):c=e[9];let d;return e[10]!==i||e[11]!==o||e[12]!==r||e[13]!==c?(d=t.jsxs("div",{className:i,"aria-label":"Voice activity",children:[a,o,r,c]}),e[10]=i,e[11]=o,e[12]=r,e[13]=c,e[14]=d):d=e[14],d}const Xc='button[role="menuitemradio"]',_l=".composer-mode-cell-live";function Gc(l){return Array.from(l?.querySelectorAll(Xc)??[])}function Yc(){const l=X.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("span",{className:"composer-mode-meter","aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),l[0]=e):e=l[0],e}function Jc(l){const e=X.c(26),{chatModels:s,selectedModel:n,modelSelectionDisabled:i,sending:a,context:o,voice:r,onModelChange:c,onToggleVoice:d}=l,u=C.useRef(null),p=C.useRef(null),[m,b]=C.useState(!1),[f,g]=C.useState(0),h=C.useId(),y=r?.meterRef,x=!!r?.active,j=r?.phase,v=!!r?.disabled,k=r?.message,w=r?.retrying,S=r?.pendingReview;let M;e[0]!==k||e[1]!==w||e[2]!==S||e[3]!==j?(M=ai({sending:!1,mcpRunning:0,voicePhase:j,voiceMessage:k,retrying:w,pendingReview:S}),e[0]=k,e[1]=w,e[2]=S,e[3]=j,e[4]=M):M=e[4];const N=M,$=r?.provider??r?.mode??"auto";let P;e[5]!==$?(P=Aa($),e[5]=$,e[6]=P):P=e[6];const T=P,A=r?.fallbackReason;let I;e[7]!==A||e[8]!==T||e[9]!==N.label?(I=[N.label,T,A].filter(Boolean),e[7]=A,e[8]=T,e[9]=N.label,e[10]=I):I=e[10];const D=I.join(" · "),F=Ma({chatModels:s,selectedModel:n,modelSelectable:!o,voiceMode:r?.mode??null}),R=Pa(F),E=R.length===0||i||a;let z;e[11]!==s||e[12]!==n?(z=s.find(ee=>ee.id===n)??s[0],e[11]=s,e[12]=n,e[13]=z):z=e[13];const _=z,L=o?o.label:_?.label??n,B=o?o.description:_?.description,U=()=>{u.current?.querySelector(_l)?.focus()},q=ee=>{b(!1),U()};let H;e[14]!==m?(H=[m],e[14]=m,e[15]=H):H=e[15],C.useEffect(()=>{if(!m)return;const ee=u.current,J=fe=>{ee?.contains(fe.target)||b(!1)},de=fe=>{fe.key!=="Escape"||fe.defaultPrevented||(fe.preventDefault(),fe.stopPropagation(),b(!1),ee?.querySelector(_l)?.focus())};return document.addEventListener("pointerdown",J),document.addEventListener("focusin",J),document.addEventListener("keydown",de,!0),()=>{document.removeEventListener("pointerdown",J),document.removeEventListener("focusin",J),document.removeEventListener("keydown",de,!0)}},H);const K=()=>{if(m){q();return}g(Ta(R)),b(!0)},se=ee=>{ee.kind==="model"?c(ee.model):r?.selectMode(ee.mode),q()},ie=ee=>{const J=Ea(R,f,ee.key);J!==null&&(ee.preventDefault(),g(J),Gc(p.current)[J]?.focus())},V={"aria-haspopup":"menu","aria-expanded":m,className:"composer-mode-cell composer-mode-cell-live",disabled:E,onClick:K},ce="composer-mode-switch",W="group",te="Input mode",ae=x?t.jsx("button",{type:"button",className:"composer-mode-cell composer-mode-cell-idle","aria-label":"Stop voice conversation","aria-pressed":!0,title:"Stop microphone and spoken replies",onClick:d,children:t.jsx($l,{size:14,"aria-hidden":"true"})}):t.jsxs("button",{...V,type:"button","aria-label":o?"Composer context":"Chat model",title:B,children:[o?t.jsx(Si,{size:13,"aria-hidden":"true"}):t.jsx($l,{size:14,"aria-hidden":"true"}),t.jsx("span",{className:"composer-mode-name",children:"TEXT"}),t.jsx("span",{className:"composer-mode-divider","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"composer-mode-engine",children:L}),!E&&t.jsx(Is,{size:11,"aria-hidden":"true"})]}),Y=r&&(x?t.jsxs("button",{...V,ref:y,type:"button","data-voice-phase":j,"aria-label":"Voice provider","aria-describedby":h,"aria-busy":j==="connecting",title:D,children:[j==="connecting"?t.jsx(vi,{className:"composer-mode-connecting",size:14,"aria-hidden":"true"}):t.jsx(Yc,{}),t.jsx("span",{className:"composer-mode-name",children:"VOICE"}),t.jsx("span",{className:"composer-mode-divider","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"composer-mode-engine",children:j==="connecting"?N.label:T}),!E&&t.jsx(Is,{size:11,"aria-hidden":"true"})]}):t.jsx("button",{ref:y,type:"button",className:"composer-mode-cell composer-mode-cell-idle","data-voice-phase":j,"aria-label":"Start voice conversation","aria-describedby":h,"aria-pressed":!1,disabled:v||a,title:"Voice input + spoken replies",onClick:d,children:t.jsx(ki,{size:15,"aria-hidden":"true"})}));let Q;e[16]!==r||e[17]!==N.label||e[18]!==h?(Q=r&&t.jsx("span",{id:h,className:"sr-only",role:"status",children:N.label}),e[16]=r,e[17]=N.label,e[18]=h,e[19]=Q):Q=e[19];const Z=m&&t.jsx("ul",{ref:p,className:"composer-engine-menu",role:"menu","aria-label":"Chat model and voice provider",onKeyDown:ie,children:F.map(ee=>[t.jsx("li",{role:"presentation",className:"composer-engine-group",children:ee.label},`${ee.id}-label`),...ee.items.map(J=>{const de=`${J.id.replace(":","-")}-note`;return t.jsx("li",{role:"none",children:t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":J.checked,"aria-label":J.label,"aria-describedby":J.note?de:void 0,autoFocus:J.position===f,tabIndex:J.position===f?0:-1,className:"composer-engine-item",onClick:()=>se(J.choice),children:[t.jsx("span",{className:"composer-engine-check","aria-hidden":"true",children:J.checked&&t.jsx(Qt,{size:13})}),t.jsxs("span",{className:"composer-engine-copy",children:[t.jsxs("span",{className:"composer-engine-head",children:[t.jsx("strong",{children:J.label}),J.detail&&t.jsx("small",{children:J.detail})]}),J.note&&t.jsx("small",{id:de,className:"composer-engine-note",children:J.note})]})]})},J.id)})])});let re;return e[20]!==u||e[21]!==ae||e[22]!==Y||e[23]!==Q||e[24]!==Z?(re=t.jsxs("div",{ref:u,className:ce,role:W,"aria-label":te,children:[ae,Y,Q,Z]}),e[20]=u,e[21]=ae,e[22]=Y,e[23]=Q,e[24]=Z,e[25]=re):re=e[25],re}const Ll="videobook-command-composer-form",Qc=250;function Q1({chatTurns:l=[],goalEvents:e=[],previewTurnId:s=null,connected:n=!0,onBeginTurn:i,children:a,commands:o,references:r,actions:c,actionContext:d,actionDiscovery:u,actionStatus:p,actionsDisabled:m,onOpenActions:b,onCloseActionSearch:f,onDismissComposer:g,dockOpen:h,onDockOpenChange:y,contextualContent:x=null,contextualHasHeader:j=!1,goalStatus:v=null,bookId:k,callTool:w,chatModels:S,disabled:M,hidden:N=!1,modelSelectionDisabled:$,connectionLabel:P,mcpCalls:T,mcpFlash:A,onToggleMcpCall:I,selectedModel:D,context:F=null,mentionAssets:R=[],inputSession:E=null,placeholder:z,portalTarget:_=null,pendingInput:L,replacePendingInput:B=!1,notice:U,outcomeSlot:q="composer",onEnsureCatalog:H,onDismissNotice:K,onDismissPanel:se,onExecute:ie,onModelChange:V,onStartVoice:ce,onSendingChange:W,onCommandRowHeightChange:te,onHeightChange:ae,onSuccessfulExecute:Y,voiceCatalog:Q,voice:Z}){const[re,ee]=C.useState(Da),[J,de]=C.useState(()=>L??re.get(E)??""),[fe,ue]=C.useState(0),[pe,me]=C.useState(()=>L!==void 0&&!Gt(L)),[he,ye]=C.useState(()=>Fa()??""),oe=_a(),[G,le]=C.useState(!1),be=C.useRef(0),je=C.useRef(!1),[we,$e]=C.useState(!1),[Ie,Ae]=C.useState(null),[Fe,et]=C.useState(L),[Ye,Ke]=C.useState(!1),[Ve,lt]=C.useState(E),Ee=C.useRef(null),We=C.useRef(null),Xe=C.useRef(null),[Je,tt]=C.useState(null);C.useLayoutEffect(()=>{const O=Xe.current,ge=We.current;if(N||_||!O||!ge||!te&&!ae)return;const Se=()=>{const qt=getComputedStyle(ge);te?.(O.getBoundingClientRect().height+parseFloat(qt.borderTopWidth)+parseFloat(qt.borderBottomWidth)),ae?.(ge.getBoundingClientRect().height)};Se();const Be=new ResizeObserver(Se);return Be.observe(O),Be.observe(ge),()=>Be.disconnect()},[N,te,ae,_]);const[Re,De]=C.useState(!1),qe=h??Re,_e=C.useRef(qe),ke=O=>{h===void 0&&De(O),y?.(O)},[Qe]=C.useState(()=>new Map),[nt,Tt]=C.useState({start:J.length,end:J.length}),[wt,Et]=C.useState(u?.query??""),[Ze,ne]=C.useState(""),[xe,Me]=C.useState(u?.key),[Ge,at]=C.useState(null),Nt=C.useId(),Ct=C.useId(),ft=C.useRef(E),At=C.useRef(""),jt=C.useRef([]),it=C.useRef(-1),pt=C.useRef(""),rt=C.useRef(""),Dt=Z?.captions.filter(O=>O.role==="user"&&O.final).at(-1)?.id,vt=C.useRef(null),ze=C.useRef(!1),Pt=C.useRef(null),$t=C.useRef(0),[xt,gt]=C.useState(!0),[Vt,Ot]=C.useState(0),ot=C.useMemo(()=>La(Z?.captions??[],T,l,e),[l,e,T,Z?.captions]),ht=za(ot),Ft=Ba(ot),It=Oa(Z),yt=q==="composer"&&U&&!l.some(O=>O.reply===U.message)?U:null,ct=q==="composer"&&Ie&&Ie.message!==U?.message?Ie:null,Pe=!!(It||yt||ct),Ne=JSON.stringify([It,yt,ct]),Le=ai({sending:G,mcpRunning:hl(T),voicePhase:Z?.phase,voiceMessage:Z?.message,retrying:Z?.retrying,pendingReview:Z?.pendingReview}),Ue=Le.busy&&Le.kind!=="connecting"&&Le.kind!=="permission",Te=!Ue&&A==="success",Ce=!Ue&&A==="error",kt=Ua({runningCalls:hl(T),voicePhase:Z?.phase})||T.calls.some(O=>O.expanded)||l.some(si)||we||!!(It?.error||It?.playbackBlocked)||yt?.tone==="error"||ct?.ok===!1,_t=C.useRef(ht),Ut=C.useRef(Ne);if(C.useLayoutEffect(()=>{ft.current=E},[E]),C.useEffect(()=>{Ha(re,E,J===L?"":J)},[J,re,E,L]),C.useEffect(()=>{(ht>_t.current||Pe&&Ne!==Ut.current)&&gt(!0),_t.current=ht,Ut.current=Ne},[Ne,Pe,ht]),C.useEffect(()=>Ka({open:xt,held:kt,onClose:()=>gt(!1)}),[xt,kt,Ft,Ne]),C.useLayoutEffect(()=>{Dt&&(rt.current="")},[Dt]),C.useEffect(()=>{window.clearTimeout($t.current)},[E]),E!==Ve){const O=new Map(re);O.set(Ve,J===Fe?"":J),ee(O),lt(E),et(L),Ke(!1),de(L??O.get(E)??""),Ae(null),at(null),me(L!==void 0&&!Gt(L))}else if(L!==Fe){const O=B||!J.trim()||J===Fe;et(L),Z?.pendingReview||Ye?Ke(L!==void 0):O&&de(L??""),me(L!==void 0&&!Gt(L))}u?.key!==xe&&(Me(u?.key),Et(u?.query??""),ne(""),ue(0));const Lt=!u&&!F&&!pe&&Gt(J),ve=Z?.active&&!x&&!a&&!U&&!Ie&&!u&&!Lt&&ht<=Vt&&!(xt&&ot.length>0)&&!Z.playbackBlocked&&!Pe,dt=qe&&!ve,Ht=Q?.voices??[],Ts=bl(Ht,he),Es=oe.stop;C.useEffect(()=>{Lt||Es()},[Lt,Es]);const cs=()=>{Q&&Q.ensureLoaded().catch(()=>{})},ns=O=>{!F&&Gt(O)&&cs()},As=()=>{Q&&Q.refresh().catch(()=>{})},Xt=(O=!1)=>{bn(()=>Ee.current?.element()??null,()=>{O&&Ee.current?.select()})()},Ds=()=>{me(!0),u&&f(!1),Ya({setOpen:ke,stopVoice:Z?.stop,pauseMedia:()=>hn(We.current)}),Xt()},st=()=>{if(Z){if(Z.active){Z.stop(),Xt();return}Z.disabled||G||(oe.stop(),hn(We.current),de(""),Tt({start:0,end:0}),Ke(!1),at(null),Ae(null),me(!0),gt(!1),Ot(ht),it.current=-1,pt.current="",u&&f(!1),K?.(),ce?.(),ke(!0),Z.toggle(),Xt())}};C.useEffect(()=>{const O=_e.current;_e.current=qe,!(!O||qe)&&(oe.stop(),Z?.stop(),hn(We.current))},[qe,oe,Z]);const Rt=C.useMemo(()=>({outcome:Ie,notice:U??null,dismissOutcome:()=>Ae(null),dismissNotice:()=>K?.()}),[U,K,Ie]),Oe=C.useMemo(()=>{if(u||pe||Gt(J))return[];if(L&&/^\/(?:apply|cancel)(?:\s|$)/iu.test(J))return[];const O=J.match(/^\/([\w-]*)$/);if(O&&!F){const Se=O[1].toLowerCase();return Va(o,Se).map(Be=>({value:`${Be.command} `,label:Be.command,description:Be.description,aliases:Be.aliases,type:"command"}))}const ge=F?new Set(R.map(Se=>Se.artifactId)):void 0;return qa(r,J,nt.start,nt.end,ge).map(Se=>({value:Se.token,label:Se.token,description:li(Se),type:"cell",reference:Se}))},[u,o,F,pe,J,R,L,r,nt]),zt=C.useMemo(()=>Wa(c,wt).filter(O=>!Ze||O.group===Ze),[Ze,wt,c]),Qi=C.useMemo(()=>[...new Set(c.map(O=>O.group))].sort(),[c]),ts=Math.min(fe,Math.max(0,zt.length-1)),Fs=`${Nt}-actions`,nn=Ge?.action.command===J.trim().split(/\s/u)[0]&&Ge?.action.scope==="global"?m:M;C.useLayoutEffect(()=>{u&&bn(()=>Ee.current?.element()??null)()},[u,_]);const Zn=O=>{window.clearTimeout($t.current),Ae(O),O.ok&&($t.current=window.setTimeout(()=>Ae(null),3200))},Zi=async O=>{const ge=[];let Se=0;for(;;){const Be=await w("list_prompt_history",{book_id:O,surface:"chat",limit:Qc,offset:Se}),qt=ir(Be);if(ge.push(...qt.values),!qt.hasMore)return ge.reverse();const Mt=qt.offset+qt.values.length;if(Mt<=Se)throw new Error("Prompt history pagination did not advance");Se=Mt}},ln=async()=>{const O=k;if(!O)return;const ge=Pt.current;if(ge?.bookId===O){await ge.promise;return}if(rt.current===O)return;rt.current=O,jt.current=[],it.current=-1,pt.current="";const Se=(async()=>{try{const Be=await Zi(O);rt.current===O&&(jt.current=Be)}catch{rt.current===O&&(rt.current="")}})();Pt.current={bookId:O,promise:Se},await Se,Pt.current?.promise===Se&&(Pt.current=null)},ea=()=>{F||(vt.current!==k&&(vt.current=k,H().catch(()=>{vt.current===k&&(vt.current=null)})),ln()),Lt&&cs()},ta=async(O,ge)=>{jt.current=[...jt.current,O],it.current=-1,k&&await w("record_prompt",{book_id:k,surface:"chat",prompt:O,params:{model:D}},{chat:ge}).catch(()=>{})},el=async O=>{const ge=O!==void 0,Se=(O??J).trim();if(!Se||je.current||nn||u||ze.current)return;ke(!0),ge||Ke(!1);const Be=Ge?.action.command===Se.split(/\s/u)[0]?Ge:null,qt=E,Mt=i?.(Se),ds=()=>Mt?Mt.isInScope():ft.current===qt,ua=be.current,il=()=>be.current===ua&&ft.current===qt;je.current=!0,le(!0),gt(!0),Ae(null),ge||de(""),me(!0),W?.(!0);let dn=!1,un=!1;const ma=bn(()=>Ee.current?.element()??null,()=>{un&&Ee.current?.select()});try{if(!F||Be){if(await ln(),!ds())return;await ta(Se,Mt)}if(!ds())return;const ys=!F&&Gt(Se)?await Q?.ensureLoaded():null;if(!ds())return;const zs=bl(ys?.voices??Ht,he),mn=tr(Se,zs);mn?.speakVoiceId&&xl(mn.speakVoiceId);const Bs=await ie(Se,{chat:Mt,...mn,...Be?{action:{id:Be.action.id,values:Be.values}}:{}});if(dn=!0,!ds()||Mt&&!Mt.isCurrent())return;at(null),(!Mt||!Bs.ok&&q==="sheet")&&Zn(Bs);const js=sr(Bs,L);js&&!ge&&il()&&(de(js.value),me(!Gt(js.value)),ns(js.value),un=js.select),Bs.ok&&Y()}catch(ys){const zs={ok:!1,message:ys instanceof Error?ys.message:String(ys)};if(Mt?.finish(zs),dn=!0,!ds())return;Mt||Zn(zs),L!==void 0&&!ge&&il()&&(de(L),me(!0),un=!0)}finally{dn||Mt?.finish({ok:!0,status:"cancelled",message:"Workspace changed before the command was sent."}),je.current=!1,le(!1),W?.(!1),ds()&&(!Mt||Mt.isCurrent())&&ma()}},an=O=>{if(O.type==="command")Ee.current?.replace(O.value),me(!Gt(O.value)),ns(O.value);else{const ge=Ee.current?.selection()??nt,Se=Qa(J,O.value,ge.start,ge.end);if(!Se)return;Ee.current?.replace(Se.value,{start:Se.caret,end:Se.caret}),me(!0)}it.current=-1,Xt()},rn=O=>{at({action:O,values:u?.values}),de(`${O.command} `),me(!0),ue(0),f(!0),Xt()},_s=()=>{f(!1),g||Xt()},tl=O=>{ye(O),xl(O),oe.playingVoiceId&&oe.playingVoiceId!==O&&oe.stop()},sa=()=>{const O=Ht.find(ge=>ge.voiceId===Ts);O?.previewUrl&&oe.toggle(O.voiceId,O.previewUrl)},Ls=async O=>{const ge=E;if(await ln(),ge!==ft.current)return;const Se=lr({values:jt.current,cursor:it.current,draft:pt.current,current:J,direction:O});Se&&(it.current=Se.cursor,pt.current=Se.draft,de(Se.value),me(!0),ns(Se.value))},sl=(O,ge=J)=>{const Se=Ee.current?.selection()??nt,Be=nr({value:ge,selectionStart:Se.start,selectionEnd:Se.end,key:O.key,ctrlKey:O.ctrlKey,altKey:O.altKey,yankText:At.current});return Be?(O.preventDefault(),Be.value===ge?Ee.current?.setSelection({start:Be.selectionStart,end:Be.selectionEnd}):Ee.current?.replace(Be.value,{start:Be.selectionStart,end:Be.selectionEnd}),ns(Be.value),Be.killedText!==void 0&&(At.current=Be.killedText),!0):!1},na=O=>{if(O.key==="Escape"){const ge=document.querySelector(".mcp-call-popover:popover-open");if(ge){O.preventDefault(),O.stopPropagation(),ge.hidePopover();return}}if(ze.current||O.isComposing||O.keyCode===229){O.key==="Enter"&&O.preventDefault();return}if(u){if(O.key==="Escape")O.preventDefault(),O.stopPropagation(),_s();else if(["ArrowDown","ArrowUp","Home","End"].includes(O.key)){O.preventDefault();const ge=O.key==="Home"?0:O.key==="End"?zt.length-1:(ts+(O.key==="ArrowDown"?1:-1)+zt.length)%Math.max(1,zt.length);ue(Math.max(0,ge)),document.getElementById(`${Fs}-option-${ge}`)?.scrollIntoView({block:"nearest"})}else(O.key==="Enter"||O.key==="Tab"&&!O.shiftKey)&&zt[ts]?(O.preventDefault(),rn(zt[ts])):sl(O,wt);return}if(Lt){const ge=Za(O,Ht,Ts);if(ge.type!=="ignore"&&O.preventDefault(),ge.type==="select"){tl(ge.voiceId);return}if(ge.type==="toggle"){sa();return}if(ge.type==="dismiss"){oe.stop(),me(!0);return}}if(Oe.length>0){if(["ArrowDown","ArrowUp","Home","End"].includes(O.key)){O.preventDefault();const ge=O.key==="Home"?0:O.key==="End"?Oe.length-1:(fe+(O.key==="ArrowDown"?1:-1)+Oe.length)%Oe.length;ue(ge),document.getElementById(`${Nt}-option-${ge}`)?.scrollIntoView({block:"nearest"});return}if(O.key==="Tab"&&!O.shiftKey){O.preventDefault(),an(Oe[Math.min(fe,Oe.length-1)]);return}if(O.key==="Enter"&&!er(J,Oe)){O.preventDefault(),an(Oe[Math.min(fe,Oe.length-1)]);return}if(O.key==="Escape"){O.preventDefault(),me(!0);return}}if(O.key==="Escape"&&dt&&cn&&xt&&!In(Z?.phase,ot.length,!!Z)){O.preventDefault(),gt(!1);return}if(O.key==="Escape"&&(se||g)){O.preventDefault(),se?se():g?.();return}if(!F&&O.ctrlKey&&O.key.toLowerCase()==="p"){O.preventDefault(),Ls(-1);return}if(!F&&O.ctrlKey&&O.key.toLowerCase()==="n"){O.preventDefault(),Ls(1);return}if(!F&&O.key==="ArrowUp"){O.preventDefault(),Ls(-1);return}if(!F&&O.key==="ArrowDown"){O.preventDefault(),Ls(1);return}sl(O)||O.key==="Enter"&&(O.preventDefault(),el())},ls=Ga(!!a),on=l.at(-1),nl=on!==void 0&&on.id===s,cn=!x||ls||nl,la=cn||Pe,ia=cn?x&&!ls&&nl?ot.filter(O=>O.kind==="caption"&&O.turn?.id===on.id):ot:[],aa=Ja({dockOpen:dt,panelHasHeader:j,reviewPriority:ls}),ra=!Pe&&In(Z?.phase,ot.length,!!Z),oa={captionId:Ct},ca={hide:Ds,hideLabel:Xa},da=Pe?t.jsxs(t.Fragment,{children:[yt&&t.jsx(Dl,{message:yt.message,tone:yt.tone,dismissLabel:"Dismiss notice",onDismiss:K}),ct&&t.jsx(Dl,{message:ct.message,tone:ct.ok?"info":"error",dismissLabel:"Dismiss error",onDismiss:ct.ok?void 0:()=>Ae(null)}),It&&Z&&t.jsx(Wc,{feedback:It,onResumePlayback:Z.resumePlayback})]}):null,ll=t.jsx(Oi.Provider,{value:Rt,children:t.jsx(Li.Provider,{value:ca,children:t.jsx(Bi.Provider,{value:oa,children:t.jsxs("section",{ref:We,className:"command-composer","data-composer-focus":"return","data-dock-open":dt?"true":"false","data-resizable-review":ls&&dt?"true":void 0,style:Je===null?void 0:{"--composer-review-height":`${Je}px`},"data-voice-phase":Z?.phase,hidden:N,onKeyDown:O=>{!u||O.key!=="Escape"||O.defaultPrevented||O.nativeEvent.isComposing||(O.preventDefault(),O.stopPropagation(),_s())},children:[ls&&dt&&t.jsx(zi,{label:"Resize review pane",targetSelector:".command-composer",edge:"top",minimum:280,onResize:tt}),dt&&!aa&&t.jsxs("div",{className:"command-composer-dock-bar",children:[ra&&t.jsx("span",{className:"command-composer-dock-title",children:"chat"}),t.jsx(Ic,{})]}),t.jsxs("div",{className:"command-composer-dock-body",hidden:!dt,inert:dt?void 0:!0,children:[x&&t.jsx("div",{className:"command-composer-contextual",hidden:ls,inert:ls?!0:void 0,children:x}),!N&&!F&&a,u&&t.jsx(zc,{actions:zt,groups:Qi,group:Ze,context:d,loading:p.loading,error:p.error,listId:Fs,selectedIndex:ts,onGroupChange:O=>{ne(O),ue(0),Xt()},onClose:_s,onSelect:rn}),!N&&la&&t.jsx(Pc,{rows:ia,connected:n,onDetailsChange:$e,phase:Z?.phase,voicePresent:!!Z,open:xt&&dt,onToggleCall:I,children:da})]}),t.jsxs("form",{ref:Xe,id:Ll,className:`command-line-shell ${Ue?"command-line-shell-transmitting":""} ${Te?"command-line-shell-success":""} ${Ce?"command-line-shell-error":""}`,"aria-busy":Ue,onSubmit:O=>{if(O.preventDefault(),u&&zt[ts])rn(zt[ts]);else{const ge=O.nativeEvent.submitter,Se=ge?.getAttribute("form")===Ll||!ge&&document.activeElement?.closest(".confirm-sheet"),Be=L!==void 0&&Se&&!/^\/apply(?:\s|$)/iu.test(J);el(Be?L:void 0)}},children:[Lt&&t.jsx(Vc,{voices:Ht,selectedVoiceId:Ts,playingVoiceId:oe.playingVoiceId,status:Q?.status??"fallback",warning:Q?.warning??null,loading:Q?.loading??!1,error:Q?.error??null,onSelect:tl,onTogglePreview:(O,ge)=>{Z?.stop(),oe.toggle(O,ge)},onRefresh:As}),!Lt&&Oe.length>0&&t.jsx("div",{className:"command-suggestions",id:`${Nt}-list`,role:"listbox","aria-label":"Command suggestions",children:Oe.map((O,ge)=>t.jsx("button",{type:"button",role:"option",id:`${Nt}-option-${ge}`,"aria-selected":ge===fe,className:`${ge===fe?"active ":""}${O.type==="cell"?"composer-reference-suggestion":"command-command-suggestion"}`,onMouseDown:Se=>Se.preventDefault(),onClick:()=>an(O),children:O.type==="cell"?t.jsxs(t.Fragment,{children:[t.jsx(xs,{asset:O.reference.asset,kindHint:O.reference.type}),t.jsxs("span",{className:"composer-reference-copy",children:[t.jsx("strong",{children:O.label}),O.reference.label&&t.jsx("span",{children:O.reference.label}),t.jsx("small",{children:O.description})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("strong",{children:O.label}),t.jsx("span",{children:O.description})]})},`${O.type}:${O.label}`))}),t.jsx("div",{className:"command-actions-controls",children:t.jsx("button",{type:"button",className:"command-actions-toggle","aria-label":"Open actions","aria-expanded":!!u,"data-workspace-action-surface":"button","aria-keyshortcuts":"Control+Shift+K Meta+Shift+K",disabled:m||G,onClick:u?_s:b,children:t.jsx(Oo,{size:14,"aria-hidden":"true"})})}),t.jsx(Lc,{ref:Ee,value:u?wt:J,session:`${E??"chat"}:${u?`actions-${u.key}`:"draft"}`,sessions:Qe,references:r,disabled:u?m:nn,rich:!u,placeholder:u?"Search actions by name, operation or alias…":M?P:z??"Type a message or /command…",expanded:!!u||!Lt&&Oe.length>0,controls:u?Fs:!Lt&&Oe.length>0?`${Nt}-list`:void 0,activeDescendant:u&&zt[ts]?`${Fs}-option-${ts}`:!Lt&&Oe[fe]?`${Nt}-option-${fe}`:void 0,onFocus:ea,onCompositionChange:O=>{ze.current=O},onSelectionChange:Tt,onChange:(O,ge)=>{if(Tt(ge),ue(0),u){Et(O);return}be.current+=1,de(O),me(!1),it.current=-1,ns(O)},onKeyDown:na}),v,t.jsx(Jc,{chatModels:S,selectedModel:D,modelSelectionDisabled:$,sending:G,context:F,voice:Z,onModelChange:V,onToggleVoice:st}),t.jsx("button",{type:"submit",className:"command-send",disabled:u?m||zt.length===0||p.loading:nn||G||!J.trim(),"aria-label":u?"Prepare action":"Send command",children:G?t.jsx(ut,{size:14}):t.jsx(Uo,{size:14})}),Ue&&t.jsx("span",{className:"command-transmit-scan","aria-hidden":"true"})]})]})})})});return _?gs.createPortal(ll,_):ll}function Zc(l){const e=X.c(12),{task:s}=l,[n,i]=C.useState(null);let a;e[0]!==s.model||e[1]!==s.provider?(a=ar(s.provider,s.model),e[0]=s.model,e[1]=s.provider,e[2]=a):a=e[2];const o=a;if(!o&&(s.provider!=="machgen"||!s.taskId))return null;const r=s.provider==="fal"?"fal requests":s.provider==="machgen"?"MachGen task":"Kie logs";let c;e[3]!==r||e[4]!==o?(c=o?t.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:[r,t.jsx(Ho,{size:12,"aria-hidden":"true"})]}):t.jsx("span",{children:r}),e[3]=r,e[4]=o,e[5]=c):c=e[5];let d;e[6]!==n||e[7]!==s.taskId?(d=s.taskId&&t.jsxs(t.Fragment,{children:[t.jsx("code",{title:s.taskId,children:s.taskId}),t.jsx("button",{type:"button","aria-label":"Copy provider request ID",title:"Copy provider request ID",onClick:async()=>{try{await navigator.clipboard.writeText(s.taskId),i(s.taskId)}catch{i(null)}},children:n===s.taskId?"Copied":t.jsx(Zs,{size:12,"aria-hidden":"true"})})]}),e[6]=n,e[7]=s.taskId,e[8]=d):d=e[8];let u;return e[9]!==c||e[10]!==d?(u=t.jsxs("div",{className:"provider-task-link",children:[c,d]}),e[9]=c,e[10]=d,e[11]=u):u=e[11],u}function ed(l,e){return l===e?!0:!l||!e?!1:l.sourceLeftX===e.sourceLeftX&&l.sourceRightX===e.sourceRightX&&l.sourceBottomY===e.sourceBottomY&&l.targetCenterX===e.targetCenterX&&l.targetLeftX===e.targetLeftX&&l.targetTopY===e.targetTopY&&l.targetHeight===e.targetHeight}const Z1=C.memo(function(e){const s=X.c(20),{source:n,sourceX:i,sourceY:a,target:o,data:r}=e;let c;s[0]!==n||s[1]!==o?(c=x=>{const j=x.nodeLookup.get(n),v=x.nodeLookup.get(o);if(!j||!v)return null;const k=j.internals?.positionAbsolute??j.position,w=v.internals?.positionAbsolute??v.position,S=j.measured?.width??He.squareSize,M=j.measured?.height??He.squareSize,N=v.measured?.width??He.squareSize,$=v.measured?.height??He.squareSize;return{sourceLeftX:k.x,sourceRightX:k.x+S,sourceBottomY:k.y+M,targetCenterX:w.x+N/2,targetLeftX:w.x,targetTopY:w.y,targetHeight:$}},s[0]=n,s[1]=o,s[2]=c):c=s[2];const d=uc(c,ed);if(!r||!d)return null;const u=Rn[r.targetPortIndex]??Rn[1],p=r.targetSide==="left"?d.targetLeftX:d.targetCenterX,m=r.targetSide==="left"?d.targetTopY+d.targetHeight*u:d.targetTopY;let b;s[3]!==d||s[4]!==r||s[5]!==i||s[6]!==a||s[7]!==p||s[8]!==m?(b=rr({sourceX:i,sourceY:a,targetX:p,targetY:m,...d},r),s[3]=d,s[4]=r,s[5]=i,s[6]=a,s[7]=p,s[8]=m,s[9]=b):b=s[9];const f=b;let g;s[10]!==f||s[11]!==e.id||s[12]!==e.style?(g=t.jsx(mc,{id:e.id,path:f,interactionWidth:18,style:e.style}),s[10]=f,s[11]=e.id,s[12]=e.style,s[13]=g):g=s[13];let h;s[14]!==p||s[15]!==m?(h=t.jsx("circle",{className:"bus-river-entry-dot",cx:p,cy:m,r:2.5}),s[14]=p,s[15]=m,s[16]=h):h=s[16];let y;return s[17]!==g||s[18]!==h?(y=t.jsxs(t.Fragment,{children:[g,h]}),s[17]=g,s[18]=h,s[19]=y):y=s[19],y}),Ks=10;function td(l){const e=He.columnCount*He.columnPitch-He.gap,s=l.rowCount*He.rowPitch-He.gap,n=He.originX-Ks,i=He.originY+l.startRow*He.rowPitch-Ks;return{width:e+Ks*2,height:s+Ks*2,transform:`translate(${n}px, ${i}px)`}}function ef(l){const e=X.c(33),{sections:s,metrics:n,occupiedSlots:i,previewSlot:a,mediaDropActive:o,mediaDropSlot:r,reviewRoles:c}=l;let d;e[0]!==a?(d=a?Ln(a):null,e[0]=a,e[1]=d):d=e[1];const u=d;let p;e[2]!==i?(p=new Set(i.map(Os)),e[2]=i,e[3]=p):p=e[3];const m=p;let b;e[4]!==r?(b=r?Os(r):null,e[4]=r,e[5]=b):b=e[5];const f=b;let g;e[6]!==n.height||e[7]!==n.width?(g={width:n.width,height:n.height},e[6]=n.height,e[7]=n.width,e[8]=g):g=e[8];let h;e[9]!==s?(h=s.map(sd),e[9]=s,e[10]=h):h=e[10];let y;if(e[11]!==o||e[12]!==f||e[13]!==n.columnCount||e[14]!==n.minColumn||e[15]!==n.rowCount||e[16]!==m||e[17]!==c){let v;e[19]!==o||e[20]!==f||e[21]!==n.columnCount||e[22]!==n.minColumn||e[23]!==m||e[24]!==c?(v=(k,w)=>Array.from({length:n.columnCount},(S,M)=>{const N=n.minColumn+M,$={row:w,column:N},P=Os($),T=m.has(P),A=o&&!T,I=A&&P===f,D=T?void 0:c.get(ti($)),R=`notebook-grid-square${!T&&(M===0||m.has(Os({row:w,column:N-1})))?" notebook-grid-square-run-start":""}${A?" notebook-grid-square-dropzone":""}${I?" notebook-grid-square-drop-target":""}${D?` notebook-grid-square-review notebook-review-${D}`:""}`;return t.jsx("span",{className:R,style:{width:He.squareSize,height:He.squareSize,transform:`translate(${He.originX+M*He.columnPitch}px, ${He.originY+w*He.rowPitch}px)`},children:t.jsx("span",{className:"notebook-grid-square-label",children:Wt($)})},P)}),e[19]=o,e[20]=f,e[21]=n.columnCount,e[22]=n.minColumn,e[23]=m,e[24]=c,e[25]=v):v=e[25],y=Array.from({length:n.rowCount},v),e[11]=o,e[12]=f,e[13]=n.columnCount,e[14]=n.minColumn,e[15]=n.rowCount,e[16]=m,e[17]=c,e[18]=y}else y=e[18];let x;e[26]!==u?(x=u&&t.jsx("div",{className:"notebook-grid-preview",style:{width:He.squareSize,height:He.squareSize,transform:`translate(${u.x}px, ${u.y}px)`}}),e[26]=u,e[27]=x):x=e[27];let j;return e[28]!==g||e[29]!==h||e[30]!==y||e[31]!==x?(j=t.jsx(_i,{children:t.jsxs("div",{className:"notebook-grid-board",style:g,children:[h,y,x]})}),e[28]=g,e[29]=h,e[30]=y,e[31]=x,e[32]=j):j=e[32],j}function sd(l){const e=l.family??"mixed";return t.jsx("div",{className:`notebook-lane notebook-lane-${e}${l.kind==="starter"?" notebook-lane-starter":""}${l.kind==="mixed"?" notebook-lane-mixed":""}`,"data-lane-caption":l.caption,"data-lane-family":e,"data-lane-kind":l.kind,"data-lane-row-count":l.rowCount,"data-lane-start-row":l.startRow,style:td(l)},`lane-${l.startRow}-${e}`)}const Bt={width:240,height:156,pitch:4,minimumBarHeight:4};function nd(l){const e=X.c(17),{peaks:s,progress:n}=l,i=C.useId();let a;if(e[0]!==i){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=/[^a-zA-Z0-9]/g,e[2]=g):g=e[2],a=i.replace(g,""),e[0]=i,e[1]=a}else a=e[1];const o=`played${a}`;let r;e[3]!==s?(r=or(s,Bt),e[3]=s,e[4]=r):r=e[4];const c=r,d=Math.min(1,Math.max(0,n)),u=Bt.width*d;if(!c){let g;return e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Ui,{}),e[5]=g):g=e[5],g}let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("path",{className:"cell-waveform-midline",d:`M0 ${Bt.height/2}h${Bt.width}`}),e[6]=p):p=e[6];let m;e[7]!==c?(m=t.jsx("path",{className:"cell-waveform-bars",d:c}),e[7]=c,e[8]=m):m=e[8];let b;e[9]!==o||e[10]!==c||e[11]!==d||e[12]!==u?(b=d>0&&t.jsxs(t.Fragment,{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:o,children:t.jsx("rect",{x:"0",y:"0",width:u,height:Bt.height})})}),t.jsx("g",{clipPath:`url(#${o})`,children:t.jsx("path",{className:"cell-waveform-played",d:c})}),t.jsx("path",{className:"cell-waveform-playhead",d:`M${u} 8V${Bt.height-8}`})]}),e[9]=o,e[10]=c,e[11]=d,e[12]=u,e[13]=b):b=e[13];let f;return e[14]!==m||e[15]!==b?(f=t.jsxs("svg",{className:"cell-waveform",viewBox:`0 0 ${Bt.width} ${Bt.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:[p,m,b]}),e[14]=m,e[15]=b,e[16]=f):f=e[16],f}function Ui(){const l=X.c(2);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=cr(Bt),l[0]=e):e=l[0];const s=e;let n;return l[1]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsxs("svg",{className:"cell-waveform cell-waveform-pending",viewBox:`0 0 ${Bt.width} ${Bt.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:[t.jsx("path",{className:"cell-waveform-midline",d:`M0 ${Bt.height/2}h${Bt.width}`}),t.jsx("path",{className:"cell-waveform-bars",d:s})]}),l[1]=n):n=l[1],n}function ld(l){const e=X.c(20),{asset:s,eager:n}=l,i=n===void 0?!1:n,[a,o]=C.useState(!1),[r,c]=C.useState(!1),[d,u]=C.useState(i),p=C.useRef(null),m=s.type==="video"||s.type==="final",b=s.thumbnailUrl??(s.type==="image"?s.mediaUrl:null),f=`${b??""}:${s.mediaUrl??""}:${s.type}:${i}`,[g,h]=C.useState(f);g!==f&&(h(f),o(!1),c(!1),u(i));const y=!!(b&&!a),x=m&&!!s.mediaUrl&&!y;let j,v;if(e[0]!==i||e[1]!==x||e[2]!==d?(j=()=>{if(!x||d)return;if(i||typeof IntersectionObserver>"u"){const $=window.requestAnimationFrame(()=>u(!0));return()=>window.cancelAnimationFrame($)}const M=p.current;if(!M)return;const N=new IntersectionObserver($=>{$.some(id)&&(u(!0),N.disconnect())},{root:M.closest(".media-library-results"),rootMargin:"96px 0px"});return N.observe(M),()=>N.disconnect()},v=[i,x,d],e[0]=i,e[1]=x,e[2]=d,e[3]=j,e[4]=v):(j=e[3],v=e[4]),C.useEffect(j,v),y&&b){let M;e[5]===Symbol.for("react.memo_cache_sentinel")?(M=()=>o(!0),e[5]=M):M=e[5];let N;return e[6]!==b?(N=t.jsx("img",{src:b,alt:"",loading:"lazy",decoding:"async",onError:M}),e[6]=b,e[7]=N):N=e[7],N}if(m&&s.mediaUrl){let M;return e[8]!==s.duration||e[9]!==s.mediaUrl||e[10]!==d||e[11]!==r?(M=t.jsx("span",{ref:p,className:"media-library-asset-preview",children:d&&!r?t.jsx("video",{src:s.mediaUrl,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true",onError:()=>c(!0)}):t.jsxs(t.Fragment,{children:[t.jsx(St,{size:28}),s.duration!==null&&t.jsx("small",{children:Kt(s.duration)})]})}),e[8]=s.duration,e[9]=s.mediaUrl,e[10]=d,e[11]=r,e[12]=M):M=e[12],M}let k;e[13]!==s.type?(k=s.type==="audio"?t.jsx(ss,{size:28}):t.jsx(St,{size:28}),e[13]=s.type,e[14]=k):k=e[14];let w;e[15]!==s.duration?(w=s.duration!==null&&t.jsx("small",{children:Kt(s.duration)}),e[15]=s.duration,e[16]=w):w=e[16];let S;return e[17]!==k||e[18]!==w?(S=t.jsxs("span",{className:"media-library-asset-placeholder",children:[k,w]}),e[17]=k,e[18]=w,e[19]=S):S=e[19],S}function id(l){return l.isIntersecting}function vn(l){return l!==null&&Number.isFinite(l)&&l>0}function ad(l){const e=X.c(11),{className:s,width:n,height:i,durationSeconds:a,fallbackLabel:o}=l,r=vn(n)&&vn(i)?`${n}×${i}`:o??null;let c;e[0]!==a?(c=vn(a)?Kt(a):null,e[0]=a,e[1]=c):c=e[1];const d=c;if(!r&&!d)return null;const u=`notebook-media-metadata ${s}`;let p;e[2]!==r?(p=r&&t.jsx("span",{children:r}),e[2]=r,e[3]=p):p=e[3];let m;e[4]!==d||e[5]!==a?(m=d&&t.jsx("time",{dateTime:`PT${a}S`,"aria-label":`Duration ${d}`,children:d}),e[4]=d,e[5]=a,e[6]=m):m=e[6];let b;return e[7]!==u||e[8]!==p||e[9]!==m?(b=t.jsxs("span",{className:u,children:[p,m]}),e[7]=u,e[8]=p,e[9]=m,e[10]=b):b=e[10],b}const rd=/("(?:\\.|[^"\\])*")(?=\s*:)|("(?:\\.|[^"\\])*")|\b(true|false)\b|\b(null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function od(l){const e=JSON.stringify(l,null,2)??"null",s=[];let n=0;for(const i of e.matchAll(rd)){const a=i.index;a>n&&s.push({kind:"punctuation",value:e.slice(n,a)}),s.push({kind:i[1]?"key":i[2]?"string":i[3]?"boolean":i[4]?"null":"number",value:i[0]}),n=a+i[0].length}return n<e.length&&s.push({kind:"punctuation",value:e.slice(n)}),s}function cd(l){if(!l.startsWith('"')||!l.endsWith('"')||l.length<2)return null;try{const e=JSON.parse(l);return typeof e=="string"?e:null}catch{return null}}function dd(l){const e=X.c(23),{asset:s}=l,n=C.useId(),i=C.useRef(null),a=C.useRef(null),o=s.type==="video"||s.type==="final",r=s.mediaUrl??(s.type==="image"?s.thumbnailUrl:null);if(!r||!o&&s.type!=="image"&&s.type!=="audio"){let v;return e[0]!==s?(v=t.jsx(xs,{asset:s}),e[0]=s,e[1]=v):v=e[1],v}let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{const v=i.current,k=a.current;if(!v||!k)return;v.showPopover();const w=k.getBoundingClientRect(),S=v.getBoundingClientRect(),M=w.right+S.width<=window.innerWidth-12?w.right:Math.max(12,w.left-S.width);v.style.left=`${M}px`,v.style.top=`${Math.max(12,Math.min(w.top,window.innerHeight-S.height-12))}px`},e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.hidePopover(),e[3]=u):u=e[3];const p=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=v=>{v.currentTarget.contains(document.activeElement)||p()},e[4]=m):m=e[4];let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=v=>{v.currentTarget.contains(v.relatedTarget)||p()},e[5]=b):b=e[5];const f=`Preview source ${o?"video":s.type}`;let g;e[6]!==s?(g=t.jsx(xs,{asset:s,videoFrame:!0}),e[6]=s,e[7]=g):g=e[7];let h;e[8]!==n||e[9]!==f||e[10]!==g?(h=t.jsx("button",{ref:a,type:"button",className:"json-media-trigger","aria-label":f,"aria-controls":n,onClick:d,children:g}),e[8]=n,e[9]=f,e[10]=g,e[11]=h):h=e[11];let y;e[12]!==s.thumbnailUrl||e[13]!==s.type||e[14]!==r||e[15]!==o?(y=s.type==="image"?t.jsx("img",{src:r,alt:"Source image preview",loading:"lazy",decoding:"async"}):o?t.jsx("video",{src:r,poster:s.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"none","aria-label":"Source video"}):t.jsx("audio",{src:r,controls:!0,preload:"none","aria-label":"Source audio"}),e[12]=s.thumbnailUrl,e[13]=s.type,e[14]=r,e[15]=o,e[16]=y):y=e[16];let x;e[17]!==n||e[18]!==y?(x=t.jsx("span",{id:n,ref:i,popover:"auto",className:"json-media-popover",onToggle:ud,children:y}),e[17]=n,e[18]=y,e[19]=x):x=e[19];let j;return e[20]!==h||e[21]!==x?(j=t.jsxs("span",{className:"json-media-preview",onMouseEnter:d,onMouseLeave:m,onFocus:d,onBlur:b,children:[h,x]}),e[20]=h,e[21]=x,e[22]=j):j=e[22],j}function ud(l){l.newState==="closed"&&l.currentTarget.querySelectorAll("video, audio").forEach(md)}function md(l){l instanceof HTMLMediaElement&&l.pause()}const fd=/\.(?:png|jpe?g|webp|gif|avif)$/i,pd=/\.(?:mp4|mov|webm|m4v)$/i;function hd(l){if(!/^https?:\/\//i.test(l))return;let e;try{e=new URL(l).pathname}catch{return}const s=fd.test(e)?"image":pd.test(e)?"video":null;return s?{artifactId:l,type:s,mediaUrl:l}:void 0}function Xn(l){const e=X.c(16),{value:s,ariaLabel:n,artifactAssets:i,mediaDisplay:a,remoteMedia:o}=l,r=n===void 0?"Formatted action source":n,c=a===void 0?"thumbnail":a,d=o===void 0?!1:o;let u,p,m;if(e[0]!==r||e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==s){const f=od(s);u="inspector-source-json",p=r;let g;e[8]!==i||e[9]!==c||e[10]!==d?(g=(h,y)=>{const x=h.kind==="string"?cd(h.value):null,j=x?i?.get(x)??(d?hd(x):void 0):void 0;return t.jsxs("span",{className:`json-${h.kind}`,children:[h.value,j&&(c==="preview"?t.jsx(dd,{asset:j}):t.jsx(xs,{asset:j}))]},`${y}-${h.value}`)},e[8]=i,e[9]=c,e[10]=d,e[11]=g):g=e[11],m=f.map(g),e[0]=r,e[1]=i,e[2]=c,e[3]=d,e[4]=s,e[5]=u,e[6]=p,e[7]=m}else u=e[5],p=e[6],m=e[7];let b;return e[12]!==u||e[13]!==p||e[14]!==m?(b=t.jsx("pre",{className:u,"aria-label":p,children:m}),e[12]=u,e[13]=p,e[14]=m,e[15]=b):b=e[15],b}function bd(l){const e=X.c(19),{asset:s}=l;let n;e[0]!==s?(n=t.jsx(xs,{asset:s}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==s.type?(i=s.type.replaceAll("_"," ").toUpperCase(),e[2]=s.type,e[3]=i):i=e[3];let a;e[4]!==i?(a=t.jsx("strong",{children:i}),e[4]=i,e[5]=a):a=e[5];let o;e[6]!==s.duration||e[7]!==s.height||e[8]!==s.width?(o=t.jsx(ad,{className:"inspector-dolt-artifact-metadata",width:s.width,height:s.height,durationSeconds:s.duration}),e[6]=s.duration,e[7]=s.height,e[8]=s.width,e[9]=o):o=e[9];let r;e[10]!==a||e[11]!==o?(r=t.jsxs("div",{className:"inspector-dolt-artifact-facts",children:[a,o]}),e[10]=a,e[11]=o,e[12]=r):r=e[12];let c;e[13]!==s.mediaUrl?(c=s.mediaUrl&&t.jsx("a",{href:s.mediaUrl,target:"_blank",rel:"noreferrer",children:"Open media"}),e[13]=s.mediaUrl,e[14]=c):c=e[14];let d;return e[15]!==n||e[16]!==r||e[17]!==c?(d=t.jsxs("div",{className:"inspector-dolt-artifact",children:[n,r,c]}),e[15]=n,e[16]=r,e[17]=c,e[18]=d):d=e[18],d}function xd(l){const e=X.c(11),{notebookId:s,cell:n,artifactAssets:i}=l,a=ri(s,n);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[0]=o):o=e[0];const[r,c]=C.useState(o);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=x=>{c(j=>{const v=new Set(j);return v.has(x)?v.delete(x):v.add(x),v})},e[1]=d):d=e[1];const u=d,p="inspector-dolt-table",m="Raw Dolt cells row";let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Column"}),t.jsx("th",{children:"Type"}),t.jsx("th",{children:"Raw value"})]})}),e[2]=b):b=e[2];let f;e[3]!==i||e[4]!==r?(f=x=>{const j=dr(x);if(j.kind==="json")return t.jsxs(C.Fragment,{children:[t.jsxs("tr",{className:"inspector-dolt-json-meta",children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsx("code",{className:"dolt-json-kind",children:"JSON"})})]}),t.jsx("tr",{className:"inspector-dolt-json-value",children:t.jsx("td",{colSpan:3,children:t.jsx(Xn,{value:j.value,ariaLabel:`${x.column} JSON`,artifactAssets:i})})})]},x.column);const v=j.kind==="raw"&&typeof j.value=="string"?i.get(j.value):void 0;if(v){const k=r.has(x.column);return t.jsxs(C.Fragment,{children:[t.jsxs("tr",{className:k?"inspector-dolt-artifact-meta":void 0,children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsxs("button",{type:"button",className:"inspector-dolt-artifact-toggle","aria-expanded":k,onClick:()=>u(x.column),children:[t.jsx("code",{children:v.artifactId}),t.jsx(Is,{size:12,"aria-hidden":"true"})]})})]}),k&&t.jsx("tr",{className:"inspector-dolt-artifact-value",children:t.jsx("td",{colSpan:3,children:t.jsx(bd,{asset:v})})})]},x.column)}return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsx("code",{className:j.kind==="null"?"dolt-null":void 0,children:j.kind==="null"?"NULL":String(j.value)})})]},x.column)},e[3]=i,e[4]=r,e[5]=f):f=e[5];const g=a.map(f);let h;e[6]!==g?(h=t.jsx("tbody",{children:g}),e[6]=g,e[7]=h):h=e[7];let y;return e[8]!==b||e[9]!==h?(y=t.jsxs("table",{className:p,"aria-label":m,children:[b,h]}),e[8]=b,e[9]=h,e[10]=y):y=e[10],y}function tf(l){const e=X.c(13),{notebookId:s,cell:n,artifactAssets:i,heading:a}=l,o=a===void 0?!0:a;let r;e[0]!==i||e[1]!==n||e[2]!==s?(r=t.jsx(xd,{notebookId:s,cell:n,artifactAssets:i}),e[0]=i,e[1]=n,e[2]=s,e[3]=r):r=e[3];const c=r;if(!o)return c;let d;e[4]!==n||e[5]!==s?(d=ri(s,n),e[4]=n,e[5]=s,e[6]=d):d=e[6];const u=d.length;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{children:"Dolt source"}),e[7]=p):p=e[7];let m;e[8]!==u?(m=t.jsxs("header",{className:"inspector-source-meta",children:[p,t.jsxs("code",{children:["cells · ",u," columns"]})]}),e[8]=u,e[9]=m):m=e[9];let b;return e[10]!==m||e[11]!==c?(b=t.jsxs("section",{className:"inspector-source inspector-dolt-source",children:[m,c]}),e[10]=m,e[11]=c,e[12]=b):b=e[12],b}const zl=new WeakMap;function gd(l,e,s){const n=zl.get(l)??new Map;zl.set(l,n);const i=n.get(s);if(i)return i;const a=l(e).then(o=>({ok:!0,inspection:o}),o=>({ok:!1,message:o instanceof Error?o.message:String(o)}));return n.set(s,a),a}function Hi(l){if(!l)return null;const e=Date.parse(l);return Number.isFinite(e)?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):null}function kn(l){return l.length>14?`${l.slice(0,8)}…${l.slice(-4)}`:l}function Ki(l){const e=X.c(8),{text:s,label:n}=l,[i,a]=C.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s).then(()=>{a(!0),window.setTimeout(()=>a(!1),1500)})},e[0]=s,e[1]=o):o=e[1];let r;e[2]!==i?(r=i?t.jsx(Qt,{size:12,"aria-hidden":"true"}):t.jsx(Zs,{size:12,"aria-hidden":"true"}),e[2]=i,e[3]=r):r=e[3];let c;return e[4]!==n||e[5]!==o||e[6]!==r?(c=t.jsx("button",{type:"button",className:"inspector-generating-copy","aria-label":n,title:n,onClick:o,children:r}),e[4]=n,e[5]=o,e[6]=r,e[7]=c):c=e[7],c}function yd(l){const e=X.c(12),{step:s,submittedAt:n}=l,i=pr(s.id==="generating"&&s.status==="active"?n:null);if(i!==null){let d;e[0]!==i?(d=Kt(i),e[0]=i,e[1]=d):d=e[1];let u;return e[2]!==d?(u=t.jsxs("span",{children:[d," so far"]}),e[2]=d,e[3]=u):u=e[3],u}let a;e[4]!==s.at||e[5]!==s.id?(a=s.id==="generating"?null:Hi(s.at),e[4]=s.at,e[5]=s.id,e[6]=a):a=e[6];const o=a;if(o){const d=s.at??void 0;let u;return e[7]!==d||e[8]!==o?(u=t.jsx("time",{dateTime:d,children:o}),e[7]=d,e[8]=o,e[9]=u):u=e[9],u}const r=s.status==="pending"?"pending":s.status;let c;return e[10]!==r?(c=t.jsx("span",{children:r}),e[10]=r,e[11]=c):c=e[11],c}function jd(l){const e=X.c(17),{facts:s,inspection:n}=l;let i,a,o,r;if(e[0]!==s.runKind||e[1]!==s.startedAt||e[2]!==n?.task){const u=mr({runKind:s.runKind,startedAt:s.startedAt,task:n?.task??null});o="inspector-generating-section",e[7]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("span",{className:"inspector-media-field-label",children:"Timeline"}),e[7]=r):r=e[7],i="inspector-generating-timeline";let p;e[8]!==n?.task?.submittedAt?(p=m=>t.jsxs("li",{"data-status":m.status,children:[t.jsx("span",{className:"inspector-generating-timeline-bar","aria-hidden":"true"}),t.jsx("strong",{children:m.label}),t.jsx(yd,{step:m,submittedAt:n?.task?.submittedAt??null})]},m.id),e[8]=n?.task?.submittedAt,e[9]=p):p=e[9],a=u.map(p),e[0]=s.runKind,e[1]=s.startedAt,e[2]=n?.task,e[3]=i,e[4]=a,e[5]=o,e[6]=r}else i=e[3],a=e[4],o=e[5],r=e[6];let c;e[10]!==i||e[11]!==a?(c=t.jsx("ol",{className:i,children:a}),e[10]=i,e[11]=a,e[12]=c):c=e[12];let d;return e[13]!==o||e[14]!==r||e[15]!==c?(d=t.jsxs("div",{className:o,children:[r,c]}),e[13]=o,e[14]=r,e[15]=c,e[16]=d):d=e[16],d}function vd(l,e){const n=(e?.payload&&typeof e.payload=="object"&&typeof e.payload.model=="string"?e.payload.model:null)??l.model,i=e?.task??null;return[{label:"Provider · model",value:[l.provider,n].filter(Boolean).join(" · ")||"—"},e?.taskType?{label:"Task type",value:e.taskType}:null,i&&!e?.providerTask?{label:"Provider task",value:kn(i.taskId),title:i.taskId,copy:i.taskId}:null,l.runId?{label:"Run",value:kn(l.runId),title:l.runId,copy:l.runId}:null,l.jobNumber!==null?{label:"Job",value:`#${l.jobNumber}`}:null,l.providerArtifactId?{label:"Request artifact",value:kn(l.providerArtifactId),title:l.providerArtifactId,copy:l.providerArtifactId}:null].filter(o=>o!==null)}function kd(l){const e=X.c(8),{facts:s,inspection:n}=l;let i;if(e[0]!==s||e[1]!==n){const a=fr(n?.payload??null);let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"inspector-media-field-label",children:"Run"}),e[3]=o):o=e[3];const r=vd(s,n).map(wd);let c;e[4]!==r?(c=t.jsx("dl",{className:"inspector-generating-facts",children:r}),e[4]=r,e[5]=c):c=e[5];let d;e[6]!==n?(d=n?.providerTask&&t.jsx(Zc,{task:n.providerTask}),e[6]=n,e[7]=d):d=e[7],i=t.jsxs("div",{className:"inspector-generating-section",children:[o,c,d,a.length>0&&t.jsx("ul",{className:"inspector-generating-settings","aria-label":"Request settings",children:a.map(Sd)})]}),e[0]=s,e[1]=n,e[2]=i}else i=e[2];return i}function Sd(l){return t.jsxs("li",{children:[t.jsx("span",{children:l.key.replace(/_/g," ")})," ",l.value]},l.key)}function wd(l){return t.jsxs("div",{children:[t.jsx("dt",{children:l.label}),t.jsxs("dd",{title:l.title,children:[t.jsx("span",{children:l.value}),l.copy&&t.jsx(Ki,{text:l.copy,label:`Copy ${l.label.toLowerCase()}`})]})]},l.label)}function Nd(l){const e=X.c(11),{written:s,sent:n}=l,[i,a]=C.useState(!1),o=!!(s&&n&&s!==n),r=(i&&o?n:s??n)??"";if(!r)return null;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("span",{className:"inspector-media-field-label",children:"Prompt"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==i?(d=o&&t.jsxs("div",{className:"inspector-generating-toggle",role:"group","aria-label":"Prompt version",children:[t.jsx("button",{type:"button","aria-pressed":!i,onClick:()=>a(!1),children:"As written"}),t.jsx("button",{type:"button","aria-pressed":i,onClick:()=>a(!0),children:"As sent"})]}),e[1]=o,e[2]=i,e[3]=d):d=e[3];let u;e[4]!==d?(u=t.jsxs("div",{className:"inspector-generating-prompt-head",children:[c,d]}),e[4]=d,e[5]=u):u=e[5];let p;e[6]!==r?(p=t.jsx("blockquote",{children:r}),e[6]=r,e[7]=p):p=e[7];let m;return e[8]!==u||e[9]!==p?(m=t.jsxs("div",{className:"inspector-generating-section inspector-media-generating-prompt",children:[u,p]}),e[8]=u,e[9]=p,e[10]=m):m=e[10],m}function Cd(l,e){return e&&!e.ok?e.message:e?.ok&&e.inspection.errorMessage?e.inspection.errorMessage:l.runKind==="queued"?"The request is recorded once the run submits it to the provider.":"No provider request was recorded for this run."}function $d(l){const e=X.c(28),{facts:s,outcome:n,loading:i,artifactAssets:a,onRefresh:o}=l,r=n?.ok?n.inspection:null,c=r?.payload??null,d=r?.task?.submittedAt??null;let u;e[0]!==d?(u=Hi(d),e[0]=d,e[1]=u):u=e[1];const p=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("span",{className:"inspector-media-field-label",children:"Request payload"}),e[2]=m):m=e[2];let b;e[3]!==r?(b=r?.taskType&&t.jsx("code",{children:r.taskType}),e[3]=r,e[4]=b):b=e[4];let f;e[5]!==p?(f=p&&t.jsxs("span",{className:"inspector-generating-muted",children:["sent ",p]}),e[5]=p,e[6]=f):f=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("span",{className:"inspector-generating-spacer"}),e[7]=g):g=e[7];let h;e[8]!==i||e[9]!==o?(h=o&&t.jsx("button",{type:"button",className:"inspector-generating-copy","aria-label":"Reload request payload",title:"Reload request payload",disabled:i,onClick:o,children:t.jsx(Bn,{size:12,"aria-hidden":"true"})}),e[8]=i,e[9]=o,e[10]=h):h=e[10];let y;e[11]!==c?(y=c!==null&&t.jsx(Ki,{text:JSON.stringify(c,null,2),label:"Copy request JSON"}),e[11]=c,e[12]=y):y=e[12];let x;e[13]!==b||e[14]!==f||e[15]!==h||e[16]!==y?(x=t.jsxs("header",{className:"inspector-generating-payload-head",children:[m,b,f,g,h,y]}),e[13]=b,e[14]=f,e[15]=h,e[16]=y,e[17]=x):x=e[17];let j;e[18]!==a||e[19]!==s||e[20]!==i||e[21]!==n||e[22]!==c?(j=c!==null?t.jsx("div",{className:"inspector-generating-payload-scroll",tabIndex:0,children:t.jsx(Xn,{value:c,ariaLabel:"Provider request payload",artifactAssets:a,mediaDisplay:"preview",remoteMedia:!0})}):t.jsx("p",{className:"inspector-analysis-json-status",role:"status",children:i?"Loading request payload…":Cd(s,n)}),e[18]=a,e[19]=s,e[20]=i,e[21]=n,e[22]=c,e[23]=j):j=e[23];let v;return e[24]!==i||e[25]!==j||e[26]!==x?(v=t.jsxs("aside",{className:"inspector-generating-payload","aria-busy":i,children:[x,j]}),e[24]=i,e[25]=j,e[26]=x,e[27]=v):v=e[27],v}function En(l){const e=X.c(24),{facts:s,header:n,footer:i,artifactAssets:a,outcome:o,loading:r,onRefresh:c}=l,d=o?.ok?o.inspection:null;let u,p;e[0]!==s||e[1]!==d?(u=t.jsx(jd,{facts:s,inspection:d}),p=t.jsx(kd,{facts:s,inspection:d}),e[0]=s,e[1]=d,e[2]=u,e[3]=p):(u=e[2],p=e[3]);const m=s.writtenPrompt,b=d?.payload??null;let f;e[4]!==b?(f=ur(b),e[4]=b,e[5]=f):f=e[5];let g;e[6]!==s.writtenPrompt||e[7]!==f?(g=t.jsx(Nd,{written:m,sent:f}),e[6]=s.writtenPrompt,e[7]=f,e[8]=g):g=e[8];let h;e[9]!==i||e[10]!==n||e[11]!==u||e[12]!==p||e[13]!==g?(h=t.jsxs("div",{className:"inspector-media-generating-summary",children:[n,u,p,g,i]}),e[9]=i,e[10]=n,e[11]=u,e[12]=p,e[13]=g,e[14]=h):h=e[14];let y;e[15]!==a||e[16]!==s||e[17]!==r||e[18]!==c||e[19]!==o?(y=t.jsx($d,{facts:s,outcome:o,loading:r,artifactAssets:a,onRefresh:c}),e[15]=a,e[16]=s,e[17]=r,e[18]=c,e[19]=o,e[20]=y):y=e[20];let x;return e[21]!==h||e[22]!==y?(x=t.jsxs(t.Fragment,{children:[h,y]}),e[21]=h,e[22]=y,e[23]=x):x=e[23],x}function Id(l){const e=X.c(6);let s,n;e[0]!==l?({promise:s,...n}=l,e[0]=l,e[1]=s,e[2]=n):(s=e[1],n=e[2]);const i=C.use(s);let a;return e[3]!==i||e[4]!==n?(a=t.jsx(En,{...n,outcome:i,loading:!1}),e[3]=i,e[4]=n,e[5]=a):a=e[5],a}function sf(l){const e=X.c(12),{inspect:s,...n}=l,[i,a]=C.useState(0),o=n.facts.providerArtifactId;if(!s||!o)return t.jsx(En,{...n,outcome:null,loading:!1});const r=gd(s,o,`${o}:${n.facts.runKind}:${i}`);let c;e[0]!==a?(c=()=>C.startTransition(()=>a(Rd)),e[0]=a,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==n?(u=t.jsx(En,{...n,outcome:null,loading:!0,onRefresh:d}),e[2]=d,e[3]=n,e[4]=u):u=e[4];let p;e[5]!==d||e[6]!==r||e[7]!==n?(p=t.jsx(Id,{...n,promise:r,onRefresh:d}),e[5]=d,e[6]=r,e[7]=n,e[8]=p):p=e[8];let m;return e[9]!==u||e[10]!==p?(m=t.jsx(C.Suspense,{fallback:u,children:p}),e[9]=u,e[10]=p,e[11]=m):m=e[11],m}function Rd(l){return l+1}function Qs(l){return`${typeof l}:${String(l)}`}function nf(l){const e=X.c(67),{control:s,settings:n,busy:i,onFocus:a,onChange:o,toggleClassName:r,booleanLabelFirst:c,labelAsSpan:d}=l,u=c===void 0?!0:c,p=d===void 0?!0:d,m=n[s.name];let b;e[0]!==s||e[1]!==n?(b=hr(s,n),e[0]=s,e[1]=n,e[2]=b):b=e[2];const f=b;if(s.kind==="boolean"){let S;e[3]!==s.label?(S=t.jsx("span",{children:s.label}),e[3]=s.label,e[4]=S):S=e[4];const M=S,N=u&&M,$=f===!0;let P;e[5]!==o?(P=D=>o(D.target.checked),e[5]=o,e[6]=P):P=e[6];let T;e[7]!==i||e[8]!==a||e[9]!==$||e[10]!==P?(T=t.jsx("input",{type:"checkbox",role:"switch",checked:$,disabled:i,onFocus:a,onChange:P}),e[7]=i,e[8]=a,e[9]=$,e[10]=P,e[11]=T):T=e[11];const A=!u&&M;let I;return e[12]!==s.description||e[13]!==N||e[14]!==T||e[15]!==A||e[16]!==r?(I=t.jsxs("label",{className:r,title:s.description,children:[N,T,A]}),e[12]=s.description,e[13]=N,e[14]=T,e[15]=A,e[16]=r,e[17]=I):I=e[17],I}let g;e[18]!==s.label||e[19]!==p?(g=p?t.jsx("span",{children:s.label}):s.label,e[18]=s.label,e[19]=p,e[20]=g):g=e[20];const h=g;if(s.kind==="select"){let S;e[21]!==m?(S=m===void 0?"":Qs(m),e[21]=m,e[22]=S):S=e[22];const M=S;let N;e[23]!==s.options||e[24]!==m?(N=m!==void 0&&!s.options.some(_=>_===m),e[23]=s.options,e[24]=m,e[25]=N):N=e[25];const $=N,P=s.description,T=s.label;let A;e[26]!==s.options||e[27]!==o?(A=_=>{const L=s.options.find(B=>Qs(B)===_.target.value);o(L)},e[26]=s.options,e[27]=o,e[28]=A):A=e[28];const I=s.defaultValue===void 0?s.required?"Select…":"Auto":`Default · ${String(s.defaultValue)}`;let D;e[29]!==I?(D=t.jsx("option",{value:"",children:I}),e[29]=I,e[30]=D):D=e[30];let F;e[31]!==M||e[32]!==m||e[33]!==$?(F=$&&t.jsxs("option",{value:M,children:[String(m)," · incompatible"]}),e[31]=M,e[32]=m,e[33]=$,e[34]=F):F=e[34];let R;e[35]!==s.options?(R=s.options.map(Md),e[35]=s.options,e[36]=R):R=e[36];let E;e[37]!==i||e[38]!==s.label||e[39]!==M||e[40]!==a||e[41]!==D||e[42]!==F||e[43]!==R||e[44]!==A?(E=t.jsxs("select",{"aria-label":T,value:M,disabled:i,onFocus:a,onChange:A,children:[D,F,R]}),e[37]=i,e[38]=s.label,e[39]=M,e[40]=a,e[41]=D,e[42]=F,e[43]=R,e[44]=A,e[45]=E):E=e[45];let z;return e[46]!==s.description||e[47]!==h||e[48]!==E?(z=t.jsxs("label",{title:P,children:[h,E]}),e[46]=s.description,e[47]=h,e[48]=E,e[49]=z):z=e[49],z}const y=s.kind==="number"?"number":"text",x=s.kind==="number"?"any":void 0,j=f===void 0?"":String(f);let v;e[50]!==s.kind||e[51]!==o?(v=S=>{const M=S.target.value;if(!M){o(void 0);return}const N=Number(M);o(s.kind==="number"?Number.isFinite(N)?N:void 0:M)},e[50]=s.kind,e[51]=o,e[52]=v):v=e[52];let k;e[53]!==i||e[54]!==s.label||e[55]!==s.maximum||e[56]!==s.minimum||e[57]!==a||e[58]!==y||e[59]!==x||e[60]!==j||e[61]!==v?(k=t.jsx("input",{type:y,"aria-label":s.label,min:s.minimum,max:s.maximum,step:x,value:j,disabled:i,onFocus:a,onChange:v}),e[53]=i,e[54]=s.label,e[55]=s.maximum,e[56]=s.minimum,e[57]=a,e[58]=y,e[59]=x,e[60]=j,e[61]=v,e[62]=k):k=e[62];let w;return e[63]!==s.description||e[64]!==h||e[65]!==k?(w=t.jsxs("label",{title:s.description,children:[h,k]}),e[63]=s.description,e[64]=h,e[65]=k,e[66]=w):w=e[66],w}function Md(l){return t.jsx("option",{value:Qs(l),children:String(l)},Qs(l))}const Vi=[{name:"start_time",label:"Replace from",hint:"Keep the original before this point."},{name:"resume_time",label:"Resume original at",hint:"Keep the original after this point."},{name:"duration",label:"New scene length",hint:"Generate 5–13 seconds of new footage."}];function bt(l){return`${Number(l.toFixed(3))}s`}function Vs(l,e){const s=l[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0}function hs(l){const e=X.c(12),{length:s,title:n,kind:i}=l;if(s<=0)return null;const a=`insert-video-segment ${i}`;let o;e[0]!==s?(o={flexGrow:s},e[0]=s,e[1]=o):o=e[1];let r;e[2]!==i||e[3]!==s?(r=i==="new"?`New · ${bt(s)}`:bt(s),e[2]=i,e[3]=s,e[4]=r):r=e[4];let c;e[5]!==r?(c=t.jsx("span",{children:r}),e[5]=r,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==o||e[9]!==c||e[10]!==n?(d=t.jsx("span",{className:a,style:o,title:n,children:c}),e[7]=a,e[8]=o,e[9]=c,e[10]=n,e[11]=d):d=e[11],d}function lf(l){const e=X.c(9),{sources:s,settings:n,controls:i,busy:a,onChange:o}=l;let r;e[0]!==s?(r=oi(s),e[0]=s,e[1]=r):r=e[1];const c=r,d=c?.asset?.mediaUrl??c?.cellId??"empty";let u;return e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n||e[6]!==s||e[7]!==d?(u=t.jsx(Pd,{sources:s,settings:n,controls:i,busy:a,onChange:o},d),e[2]=a,e[3]=i,e[4]=o,e[5]=n,e[6]=s,e[7]=d,e[8]=u):u=e[8],u}function Pd(l){const e=X.c(45),{sources:s,settings:n,controls:i,busy:a,onChange:o}=l,r=oi(s),c=C.useRef(null),[d,u]=C.useState(0),[p,m]=C.useState(!1),b=C.useId(),f=r?.asset?.duration??0,g=Vs(n,"start_time"),h=Vs(n,"resume_time"),y=Vs(n,"duration")??Number(i.find(Ed)?.defaultValue??5);let x;if(e[0]!==i||e[1]!==n||e[2]!==s){const ee=i.flatMap(Td);x=br("fal:minimax/h3-max/insert-video",n,s)??xr(ee,n),e[0]=i,e[1]=n,e[2]=s,e[3]=x}else x=e[3];const j=x,v=!j&&g!==void 0&&h!==void 0,k=v?g+y+f-h:null,w=Math.max(f,k??0);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=ee=>{!c.current||!Number.isFinite(c.current.duration)||(c.current.currentTime=Math.max(0,Math.min(ee,c.current.duration)))},e[4]=S):S=e[4];const M=S;let N;e[5]!==o?(N=(ee,J)=>{o(ee,J),J!==void 0&&ee!=="duration"&&M(J)},e[5]=o,e[6]=N):N=e[6];const $=N,P="insert-video-editor",T="Insert scene timing";let A;e[7]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("strong",{children:"Insert a new scene"}),e[7]=A):A=e[7];const I=r?`Original @${r.address} · ${f>0?bt(f):"duration unavailable"}`:"Choose an original video";let D;e[8]!==I?(D=t.jsxs("header",{children:[A,t.jsx("span",{children:I})]}),e[8]=I,e[9]=D):D=e[9];let F;e[10]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx("p",{children:"Replace a section while keeping the original footage before and after it."}),e[10]=F):F=e[10];const R=r?.asset?.mediaUrl&&t.jsxs("div",{className:"insert-video-monitor",children:[t.jsx("video",{ref:c,src:r.asset.mediaUrl,poster:r.asset.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"metadata","aria-label":"Original video for insert",onTimeUpdate:ee=>u(ee.currentTarget.currentTime),onError:()=>m(!0)}),t.jsxs("div",{className:"insert-video-playhead",children:[t.jsxs("span",{children:["Scrub to a cut point · ",bt(d)]}),t.jsx("button",{type:"button",disabled:a||p||d<1.625||d>60||d>=f,onClick:()=>$("start_time",Number(d.toFixed(3))),children:"Replace from here"}),t.jsx("button",{type:"button",disabled:a||p||d<=(g??1.625)||d>60,onClick:()=>$("resume_time",Number(d.toFixed(3))),children:"Resume from here"})]})]});let E;e[11]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("strong",{children:"Original"}),e[11]=E):E=e[11];const z=f>0?bt(f):"—";let _;e[12]!==z?(_=t.jsxs("div",{className:"insert-video-track-heading",children:[E,t.jsxs("span",{children:["0s → ",z]})]}),e[12]=z,e[13]=_):_=e[13];const L=v?`Original: keep 0 to ${g}s, replace ${g} to ${h}s, keep ${h} to ${f}s`:"Original video: choose a valid replacement range",B=v?t.jsxs("div",{className:"insert-video-track-content",style:{width:`${f/w*100}%`},children:[t.jsx(hs,{kind:"kept",length:g,title:`Keep · ${bt(g)}`}),t.jsx(hs,{kind:"removed",length:h-g,title:`Replace · ${bt(h-g)}`}),t.jsx(hs,{kind:"kept",length:f-h,title:`Keep · ${bt(f-h)}`})]}):t.jsx("span",{className:"insert-video-track-empty",children:"Set the two cut points below"});let U;e[14]!==L||e[15]!==B?(U=t.jsx("div",{className:"insert-video-track",role:"img","aria-label":L,children:B}),e[14]=L,e[15]=B,e[16]=U):U=e[16];let q;e[17]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("strong",{children:"Result"}),e[17]=q):q=e[17];let H;e[18]!==k?(H=k===null?"Choose a valid range":`${bt(k)} total`,e[18]=k,e[19]=H):H=e[19];let K;e[20]!==H?(K=t.jsxs("div",{className:"insert-video-track-heading",children:[q,t.jsx("span",{children:H})]}),e[20]=H,e[21]=K):K=e[21];const se=k===null?"Result preview unavailable until timing is valid":`Result: ${g}s original opening, ${y}s new scene, ${bt(f-h)} original ending, ${bt(k)} total`,ie=v?t.jsxs("div",{className:"insert-video-track-content",style:{width:`${k/w*100}%`},children:[t.jsx(hs,{kind:"kept",length:g,title:`Opening · ${bt(g)}`}),t.jsx(hs,{kind:"new",length:y,title:`New scene · ${bt(y)}`}),t.jsx(hs,{kind:"kept",length:f-h,title:`Ending · ${bt(f-h)}`})]}):t.jsx("span",{className:"insert-video-track-empty",children:"Original opening → new scene → original ending"});let V;e[22]!==se||e[23]!==ie?(V=t.jsx("div",{className:"insert-video-track",role:"img","aria-label":se,children:ie}),e[22]=se,e[23]=ie,e[24]=V):V=e[24];let ce;e[25]===Symbol.for("react.memo_cache_sentinel")?(ce=t.jsxs("div",{className:"insert-video-legend",children:[t.jsx("span",{className:"kept",children:"Original footage"}),t.jsx("span",{className:"removed",children:"Replaced section"}),t.jsx("span",{className:"new",children:"Generated scene"})]}),e[25]=ce):ce=e[25];let W;e[26]!==_||e[27]!==U||e[28]!==K||e[29]!==V?(W=t.jsxs("div",{className:"insert-video-tracks",children:[_,U,K,V,ce]}),e[26]=_,e[27]=U,e[28]=K,e[29]=V,e[30]=W):W=e[30];let te;e[31]!==R||e[32]!==W?(te=t.jsxs("div",{className:"insert-video-visuals",children:[R,W]}),e[31]=R,e[32]=W,e[33]=te):te=e[33];let ae;e[34]!==p?(ae=p&&t.jsx("p",{role:"status",children:"Source playback is unavailable. You can still set the cut points below."}),e[34]=p,e[35]=ae):ae=e[35];const Y=Vi.map(ee=>{const J=i.find(ue=>ue.name===ee.name),de=Vs(n,ee.name)??(ee.name==="duration"?y:void 0),fe=ee.name==="duration"?13:Math.min(60,f||60);return t.jsxs("div",{className:"insert-video-field",children:[t.jsx("label",{htmlFor:`${b}-${ee.name}`,children:t.jsxs("span",{children:[ee.label," ",t.jsx("small",{children:"(seconds)"})]})}),t.jsxs("div",{className:"insert-video-time-input",children:[t.jsx("input",{id:`${b}-${ee.name}`,type:"number",step:"any",min:J?.minimum,max:fe,value:de??"",disabled:a,"aria-describedby":j?b:void 0,"aria-invalid":!!j,onChange:ue=>$(ee.name,ue.target.value===""?void 0:ue.target.valueAsNumber)}),ee.name!=="duration"&&t.jsx("button",{type:"button","aria-label":`View ${ee.label.toLowerCase()} cut point`,disabled:a||de===void 0||de>f||p||!r?.asset?.mediaUrl,onClick:()=>M(de),children:"View"})]}),t.jsx("input",{type:"range","aria-label":`${ee.label} slider`,min:ee.name==="duration"?5:1.625,max:Math.max(ee.name==="duration"?5:1.625,fe),step:"0.001",value:Math.min(fe,Math.max(ee.name==="duration"?5:1.625,de??1.625)),disabled:a||ee.name!=="duration"&&f<=1.625,onChange:ue=>$(ee.name,ue.target.valueAsNumber)}),t.jsx("small",{children:ee.hint})]},ee.name)});let Q;e[36]!==Y?(Q=t.jsx("div",{className:"insert-video-fields",children:Y}),e[36]=Y,e[37]=Q):Q=e[37];const Z=j?t.jsx("p",{className:"insert-video-error",id:b,role:"alert",children:j}):v&&t.jsxs("p",{className:"insert-video-summary",role:"status",children:["Replace ",bt(g),"–",bt(h)," of @",r?.address," with ",bt(y)," of new footage. Result: ",bt(k),"."]});let re;return e[38]!==te||e[39]!==ae||e[40]!==Q||e[41]!==Z||e[42]!==D||e[43]!==F?(re=t.jsxs("section",{className:P,"aria-label":T,children:[D,F,te,ae,Q,Z]}),e[38]=te,e[39]=ae,e[40]=Q,e[41]=Z,e[42]=D,e[43]=F,e[44]=re):re=e[44],re}function Td(l){const e=Vi.find(s=>s.name===l.name);return e?[{...l,label:e.label}]:[]}function Ed(l){return l.name==="duration"}function qs(l){const e=X.c(4),{active:s,label:n,onClick:i}=l;let a;return e[0]!==s||e[1]!==n||e[2]!==i?(a=t.jsx("button",{type:"button",className:"prompt-history-segment","aria-pressed":s,onClick:i,children:n}),e[0]=s,e[1]=n,e[2]=i,e[3]=a):a=e[3],a}function Ad(l){const e=X.c(35),{active:s,entry:n,now:i,pinned:a,showBook:o,onPin:r,onUse:c}=l,d=s||void 0;let u;e[0]!==n.prompt?(u=t.jsx("span",{className:"prompt-history-text",children:n.prompt}),e[0]=n.prompt,e[1]=u):u=e[1];let p;e[2]!==n.surface?(p=ci(n.surface),e[2]=n.surface,e[3]=p):p=e[3];let m;e[4]!==p?(m=t.jsx("span",{className:"prompt-history-surface",children:p}),e[4]=p,e[5]=m):m=e[5];let b;e[6]!==n.model?(b=n.model&&t.jsx("span",{children:n.model}),e[6]=n.model,e[7]=b):b=e[7];let f;e[8]!==n.book||e[9]!==o?(f=o&&n.book&&t.jsx("span",{className:"prompt-history-faint",children:n.book}),e[8]=n.book,e[9]=o,e[10]=f):f=e[10];let g;e[11]!==n.createdAt||e[12]!==i?(g=jr(n.createdAt,i),e[11]=n.createdAt,e[12]=i,e[13]=g):g=e[13];let h;e[14]!==g?(h=t.jsx("span",{className:"prompt-history-faint",children:g}),e[14]=g,e[15]=h):h=e[15];let y;e[16]!==m||e[17]!==b||e[18]!==f||e[19]!==h?(y=t.jsxs("span",{className:"prompt-history-meta",children:[m,b,f,h]}),e[16]=m,e[17]=b,e[18]=f,e[19]=h,e[20]=y):y=e[20];let x;e[21]!==c||e[22]!==u||e[23]!==y?(x=t.jsxs("button",{type:"button",className:"prompt-history-use",title:"Use this prompt",onClick:c,children:[u,y]}),e[21]=c,e[22]=u,e[23]=y,e[24]=x):x=e[24];const j=a?"Unpin prompt":"Pin prompt",v=a?"Unpin prompt":"Pin prompt";let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(Ko,{size:11,"aria-hidden":"true"}),e[25]=k):k=e[25];let w;e[26]!==r||e[27]!==a||e[28]!==j||e[29]!==v?(w=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-pressed":a,"aria-label":j,title:v,onClick:r,children:k}),e[26]=r,e[27]=a,e[28]=j,e[29]=v,e[30]=w):w=e[30];let S;return e[31]!==d||e[32]!==x||e[33]!==w?(S=t.jsxs("li",{className:"prompt-history-row","data-active":d,children:[x,w]}),e[31]=d,e[32]=x,e[33]=w,e[34]=S):S=e[34],S}function Dd(l){const e=X.c(89),{history:s}=l,[n,i]=C.useState(0);let a,o,r,c,d,u,p,m,b;if(e[0]!==n||e[1]!==s){b=gr(yr(s.entries??[],s.query),s.pins);const N=Math.min(n,Math.max(0,b.length-1)),$=s.loadedAt;let P;e[11]!==s.surface?(P=ci(s.surface),e[11]=s.surface,e[12]=P):P=e[12];const T=P,A=re=>{if(re.key==="Escape"){re.preventDefault(),re.stopPropagation(),s.close();return}if(re.key==="ArrowDown"||re.key==="ArrowUp"){re.preventDefault();const ee=re.key==="ArrowDown"?1:-1;i(Math.min(Math.max(N+ee,0),Math.max(0,b.length-1)));return}if(re.key==="Enter"&&re.target instanceof HTMLInputElement){const ee=b[N];if(!ee)return;re.preventDefault(),re.stopPropagation(),s.use(ee.prompt)}};c="prompt-history-popover",d="dialog",u="Prompt history",p=A;let I,D;e[13]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("span",{className:"confirm-section-label",children:"Prompt history"}),D=t.jsx("span",{className:"prompt-history-faint",children:"newest first"}),e[13]=I,e[14]=D):(I=e[13],D=e[14]);let F;e[15]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(mt,{size:10,"aria-hidden":"true"}),e[15]=F):F=e[15];let R;e[16]!==s.close?(R=t.jsxs("div",{className:"prompt-history-title",children:[I,D,t.jsx("button",{type:"button",className:"prompt-history-icon","aria-label":"Close history",onClick:s.close,children:F})]}),e[16]=s.close,e[17]=R):R=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(rs,{size:11,"aria-hidden":"true"}),e[18]=E):E=e[18];let z;e[19]!==s?(z=re=>{s.setQuery(re.target.value),i(0)},e[19]=s,e[20]=z):z=e[20];let _;e[21]!==s.query||e[22]!==z?(_=t.jsxs("label",{className:"prompt-history-search",children:[E,t.jsx("input",{type:"search","aria-label":"Search prompts",placeholder:"Search prompts…",autoFocus:!0,value:s.query,onChange:z})]}),e[21]=s.query,e[22]=z,e[23]=_):_=e[23];const L=s.scope==="book";let B;e[24]!==s?(B=()=>s.setScope("book"),e[24]=s,e[25]=B):B=e[25];let U;e[26]!==L||e[27]!==B?(U=t.jsx(qs,{active:L,label:"This book",onClick:B}),e[26]=L,e[27]=B,e[28]=U):U=e[28];const q=s.scope==="library";let H;e[29]!==s?(H=()=>s.setScope("library"),e[29]=s,e[30]=H):H=e[30];let K;e[31]!==q||e[32]!==H?(K=t.jsx(qs,{active:q,label:"All books",onClick:H}),e[31]=q,e[32]=H,e[33]=K):K=e[33];let se;e[34]!==U||e[35]!==K?(se=t.jsxs("span",{className:"prompt-history-segments",role:"group","aria-label":"Scope",children:[U,K]}),e[34]=U,e[35]=K,e[36]=se):se=e[36];const ie=s.surfaceFilter==="surface";let V;e[37]!==s?(V=()=>s.setSurfaceFilter("surface"),e[37]=s,e[38]=V):V=e[38];let ce;e[39]!==T||e[40]!==ie||e[41]!==V?(ce=t.jsx(qs,{active:ie,label:T,onClick:V}),e[39]=T,e[40]=ie,e[41]=V,e[42]=ce):ce=e[42];const W=s.surfaceFilter==="all";let te;e[43]!==s?(te=()=>s.setSurfaceFilter("all"),e[43]=s,e[44]=te):te=e[44];let ae;e[45]!==W||e[46]!==te?(ae=t.jsx(qs,{active:W,label:"All surfaces",onClick:te}),e[45]=W,e[46]=te,e[47]=ae):ae=e[47];let Y;e[48]!==ce||e[49]!==ae?(Y=t.jsxs("span",{className:"prompt-history-segments",role:"group","aria-label":"Surface",children:[ce,ae]}),e[48]=ce,e[49]=ae,e[50]=Y):Y=e[50];let Q;e[51]!==_||e[52]!==se||e[53]!==Y?(Q=t.jsxs("div",{className:"prompt-history-filters",children:[_,se,Y]}),e[51]=_,e[52]=se,e[53]=Y,e[54]=Q):Q=e[54],e[55]!==R||e[56]!==Q?(m=t.jsxs("div",{className:"prompt-history-head",children:[R,Q]}),e[55]=R,e[56]=Q,e[57]=m):m=e[57],a="prompt-history-list",o=s.loading;let Z;e[58]!==N||e[59]!==s||e[60]!==$?(Z=(re,ee)=>t.jsx(Ad,{active:ee===N,entry:re,now:$,pinned:s.pins.has(re.prompt),showBook:s.scope==="library",onPin:()=>s.togglePin(re.prompt),onUse:()=>s.use(re.prompt)},`${re.book}:${re.id}`),e[58]=N,e[59]=s,e[60]=$,e[61]=Z):Z=e[61],r=b.map(Z),e[0]=n,e[1]=s,e[2]=a,e[3]=o,e[4]=r,e[5]=c,e[6]=d,e[7]=u,e[8]=p,e[9]=m,e[10]=b}else a=e[2],o=e[3],r=e[4],c=e[5],d=e[6],u=e[7],p=e[8],m=e[9],b=e[10];let f;e[62]!==s.entries?.length||e[63]!==s.error||e[64]!==s.loading||e[65]!==b.length?(f=b.length===0&&t.jsx("li",{className:"prompt-history-empty",role:s.error?"alert":"status",children:s.error??(s.loading?"Loading prompts…":s.entries?.length?"No prompts match. Clear the search.":"No prompts yet. Widen the scope or generate something.")}),e[62]=s.entries?.length,e[63]=s.error,e[64]=s.loading,e[65]=b.length,e[66]=f):f=e[66];let g;e[67]!==a||e[68]!==o||e[69]!==r||e[70]!==f?(g=t.jsxs("ul",{className:a,"aria-busy":o,children:[r,f]}),e[67]=a,e[68]=o,e[69]=r,e[70]=f,e[71]=g):g=e[71];let h,y;e[72]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("kbd",{children:"↑"}),y=t.jsx("kbd",{children:"↓"}),e[72]=h,e[73]=y):(h=e[72],y=e[73]);let x;e[74]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("kbd",{children:"↵"}),e[74]=x):x=e[74];let j,v;e[75]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("kbd",{children:"⌥↑"}),v=t.jsx("kbd",{children:"⌥↓"}),e[75]=j,e[76]=v):(j=e[75],v=e[76]);let k;e[77]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsxs("span",{children:[h,y," move · ",x," use · ",j,v," step in the prompt · ",t.jsx("kbd",{children:"esc"})," close"]}),e[77]=k):k=e[77];const w=s.entries?.length??0;let S;e[78]!==w||e[79]!==b.length?(S=t.jsxs("div",{className:"prompt-history-foot",children:[k,t.jsxs("span",{children:[b.length," of ",w]})]}),e[78]=w,e[79]=b.length,e[80]=S):S=e[80];let M;return e[81]!==g||e[82]!==S||e[83]!==c||e[84]!==d||e[85]!==u||e[86]!==p||e[87]!==m?(M=t.jsxs("div",{className:c,role:d,"aria-label":u,onKeyDown:p,children:[m,g,S]}),e[81]=g,e[82]=S,e[83]=c,e[84]=d,e[85]=u,e[86]=p,e[87]=m,e[88]=M):M=e[88],M}function af(l){const e=X.c(33),{history:s,disabled:n}=l,a=(n===void 0?!1:n)||!s.available;let o;e[0]!==s?(o=w=>{if(!s.open)return;const S=w.relatedTarget;S instanceof Node&&w.currentTarget.contains(S)||s.close()},e[0]=s,e[1]=o):o=e[1];const r=o;let c;e[2]!==s.position||e[3]!==s.stepping?(c=s.stepping&&t.jsxs("span",{className:"prompt-history-status",role:"status",children:["History ",s.position," · esc restores draft"]}),e[2]=s.position,e[3]=s.stepping,e[4]=c):c=e[4];const d=a||!s.canOlder;let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(en,{size:12,"aria-hidden":"true"}),e[5]=u):u=e[5];let p;e[6]!==s.older||e[7]!==d?(p=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-label":"Older prompt",title:"Older prompt (⌥↑)","aria-keyshortcuts":"Alt+ArrowUp",disabled:d,onClick:s.older,children:u}),e[6]=s.older,e[7]=d,e[8]=p):p=e[8];const m=a||!s.canNewer;let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(On,{size:12,"aria-hidden":"true"}),e[9]=b):b=e[9];let f;e[10]!==s.newer||e[11]!==m?(f=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-label":"Newer prompt",title:"Newer prompt (⌥↓)","aria-keyshortcuts":"Alt+ArrowDown",disabled:m,onClick:s.newer,children:b}),e[10]=s.newer,e[11]=m,e[12]=f):f=e[12];let g;e[13]!==p||e[14]!==f?(g=t.jsxs("span",{className:"prompt-history-steppers",children:[p,f]}),e[13]=p,e[14]=f,e[15]=g):g=e[15];let h,y;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Un,{size:11,"aria-hidden":"true"}),y=t.jsx("span",{children:"History"}),e[16]=h,e[17]=y):(h=e[16],y=e[17]);let x;e[18]!==s.entries?(x=s.entries&&t.jsx("span",{className:"prompt-history-count",children:s.entries.length}),e[18]=s.entries,e[19]=x):x=e[19];let j;e[20]!==s.open||e[21]!==s.toggleOpen||e[22]!==a||e[23]!==x?(j=t.jsxs("button",{type:"button",className:"prompt-history-toggle","aria-expanded":s.open,"aria-haspopup":"dialog",disabled:a,onClick:s.toggleOpen,children:[h,y,x]}),e[20]=s.open,e[21]=s.toggleOpen,e[22]=a,e[23]=x,e[24]=j):j=e[24];let v;e[25]!==s?(v=s.open&&t.jsx(Dd,{history:s}),e[25]=s,e[26]=v):v=e[26];let k;return e[27]!==r||e[28]!==g||e[29]!==j||e[30]!==v||e[31]!==c?(k=t.jsxs("div",{className:"prompt-history-controls",onBlur:r,children:[c,g,j,v]}),e[27]=r,e[28]=g,e[29]=j,e[30]=v,e[31]=c,e[32]=k):k=e[32],k}function Fd(l){return l instanceof HTMLElement?{tagName:l.tagName,type:l instanceof HTMLInputElement?l.type:null}:null}function _d(l){const e=X.c(3),{sheetRef:s}=l;let n,i;return e[0]!==s?(n=()=>{s.current?.querySelector('[aria-invalid="true"]:not(:disabled)')?.focus({preventScroll:!0})},i=[s],e[0]=s,e[1]=n,e[2]=i):(n=e[1],i=e[2]),C.useLayoutEffect(n,i),null}function Ld(l){const e=X.c(11),s=C.useRef(null),{applyDisabled:n,applyFormId:i,applyScopeSelector:a,busy:o,enabled:r,onCancel:c}=l,d=r===void 0?!0:r;let u,p;e[0]!==n||e[1]!==i||e[2]!==a||e[3]!==o||e[4]!==d||e[5]!==c?(u=()=>{if(!d)return;const b=f=>{if(f.defaultPrevented||f.isComposing||o||document.querySelector('dialog[open], :popover-open, [aria-modal="true"], [role="menu"], details.canvas-add-menu[open]'))return;const g=f.target;if(a&&f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&!f.altKey){const h=document.getElementById(i);if(!(h instanceof HTMLFormElement)||!(g instanceof Node)||!h.closest(a)?.contains(g))return;f.preventDefault(),n||h.requestSubmit();return}f.key==="Escape"&&(g!==document.body&&(!(g instanceof Element)||!g.closest(".command-composer"))||g instanceof Element&&g.closest('input, textarea, select, [contenteditable="true"]')||(f.preventDefault(),c()))};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},p=[n,i,a,o,d,c],e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=d,e[5]=c,e[6]=u,e[7]=p):(u=e[6],p=e[7]),C.useLayoutEffect(u,p);let m;return e[8]!==d||e[9]!==l?(m={sheetRef:s,onKeyDown:f=>{if(!d||f.nativeEvent.isComposing||document.querySelector(":popover-open"))return;const g=vr({key:f.key,metaKey:f.metaKey,ctrlKey:f.ctrlKey,altKey:f.altKey,defaultPrevented:f.defaultPrevented,target:Fd(f.target)},{busy:l.busy});if(g==="none")return;if(f.preventDefault(),f.stopPropagation(),g==="cancel"){l.onCancel();return}if(l.applyDisabled)return;const h=document.getElementById(l.applyFormId);h instanceof HTMLFormElement&&h.requestSubmit()}},e[8]=d,e[9]=l,e[10]=m):m=e[10],m}function Gn(l){const e=X.c(3),{href:s,children:n}=l;let i;return e[0]!==n||e[1]!==s?(i=t.jsx("a",{className:"published-post-link nodrag nopan",href:s,target:"_blank",rel:"noopener noreferrer",onClick:zd,children:n}),e[0]=n,e[1]=s,e[2]=i):i=e[2],i}function zd(l){return l.stopPropagation()}function Bd(l){const e=X.c(14),{presentation:s}=l;let n;e[0]!==s.badge?(n=t.jsx("span",{className:"published-post-badge",children:s.badge}),e[0]=s.badge,e[1]=n):n=e[1];let i;e[2]!==s.tweetUrl?(i=t.jsx(Gn,{href:s.tweetUrl,children:s.tweetUrl}),e[2]=s.tweetUrl,e[3]=i):i=e[3];let a;e[4]!==s.postedAt||e[5]!==s.postedAtLabel?(a=t.jsx("time",{dateTime:s.postedAt,children:s.postedAtLabel}),e[4]=s.postedAt,e[5]=s.postedAtLabel,e[6]=a):a=e[6];let o;e[7]!==s.replyLabel?(o=t.jsx("span",{children:s.replyLabel}),e[7]=s.replyLabel,e[8]=o):o=e[8];let r;return e[9]!==n||e[10]!==i||e[11]!==a||e[12]!==o?(r=t.jsxs(t.Fragment,{children:[n,i,a,o]}),e[9]=n,e[10]=i,e[11]=a,e[12]=o,e[13]=r):r=e[13],r}function Od(l){const e=X.c(7),{inputs:s}=l;let n;e[0]!==s?(n=di(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i)return null;let a;e[2]!==i?(a=t.jsx(Bd,{presentation:i}),e[2]=i,e[3]=a):a=e[3];let o;return e[4]!==i.badge||e[5]!==a?(o=t.jsx("div",{className:"cell-published-post",role:"group","aria-label":i.badge,children:a}),e[4]=i.badge,e[5]=a,e[6]=o):o=e[6],o}function rf(l){const e=X.c(24),{inputs:s}=l;let n,i,a,o,r,c,d,u,p;if(e[0]!==s){p=Symbol.for("react.early_return_sentinel");e:{if(n=di(s),!n){p=null;break e}i="inspector-published-post",a=n.badge,o=t.jsx("span",{className:"inspector-media-field-label",children:n.badge});let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{children:"Root"}),e[10]=f):f=e[10],r=t.jsxs("p",{children:[f,t.jsx(Gn,{href:n.tweetUrl,children:n.tweetUrl})]});let g;e[11]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("span",{children:"Posted"}),e[11]=g):g=e[11],c=t.jsxs("p",{children:[g,t.jsx("time",{dateTime:n.postedAt,children:n.postedAtLabel})]});let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("span",{children:"Replies"}),e[12]=h):h=e[12],d=t.jsxs("p",{children:[h,t.jsx("span",{children:n.replyLabel})]}),u=n.replies.map(Ud)}e[0]=s,e[1]=n,e[2]=i,e[3]=a,e[4]=o,e[5]=r,e[6]=c,e[7]=d,e[8]=u,e[9]=p}else n=e[1],i=e[2],a=e[3],o=e[4],r=e[5],c=e[6],d=e[7],u=e[8],p=e[9];if(p!==Symbol.for("react.early_return_sentinel"))return p;let m;e[13]!==n.followupError?(m=n.followupError&&t.jsxs("p",{className:"inspector-published-post-error",children:["Follow-up ",n.followupError.replyNumber," failed: ",n.followupError.message]}),e[13]=n.followupError,e[14]=m):m=e[14];let b;return e[15]!==i||e[16]!==a||e[17]!==o||e[18]!==r||e[19]!==c||e[20]!==d||e[21]!==u||e[22]!==m?(b=t.jsxs("section",{className:i,"aria-label":a,children:[o,r,c,d,u,m]}),e[15]=i,e[16]=a,e[17]=o,e[18]=r,e[19]=c,e[20]=d,e[21]=u,e[22]=m,e[23]=b):b=e[23],b}function Ud(l,e){return t.jsxs("p",{children:[t.jsxs("span",{children:["Reply ",e+1]}),t.jsx(Gn,{href:l.tweetUrl,children:l.tweetUrl})]},l.tweetId)}function Hd(l){return l==="copied"?"Copied":l==="failed"?"Retry":"Copy"}function Kd(l){const e=X.c(3),{text:s,label:n}=l;let i;return e[0]!==n||e[1]!==s?(i=t.jsx("pre",{className:"inspector-transcript-text",tabIndex:0,"aria-label":n,children:s}),e[0]=n,e[1]=s,e[2]=i):i=e[2],i}function Vd(l){const e=X.c(6),{label:s,running:n,disabled:i,onClick:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Ni,{size:12,"aria-hidden":"true"}),e[0]=o):o=e[0];let r;return e[1]!==i||e[2]!==s||e[3]!==a||e[4]!==n?(r=t.jsx("button",{type:"button",className:"inspector-insight-rerun","aria-label":s,title:s,"aria-busy":n,disabled:i,onClick:a,children:o}),e[1]=i,e[2]=s,e[3]=a,e[4]=n,e[5]=r):r=e[5],r}function qd(l){const e=X.c(8),{icon:s,label:n,runningLabel:i,running:a,disabled:o,onClick:r}=l,c=a?i:n;let d;e[0]!==c?(d=t.jsx("span",{children:c}),e[0]=c,e[1]=d):d=e[1];let u;return e[2]!==o||e[3]!==s||e[4]!==r||e[5]!==a||e[6]!==d?(u=t.jsxs("button",{type:"button",className:"inspector-insight-action","aria-busy":a,disabled:o,onClick:r,children:[s,d]}),e[2]=o,e[3]=s,e[4]=r,e[5]=a,e[6]=d,e[7]=u):u=e[7],u}function Bl(l){const e=X.c(91),{source:s,title:n,transcript:i,busy:a,transcribing:o,onTranscribe:r,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d}=l,[u,p]=C.useState(null),[m,b]=C.useState("idle"),[f,g]=C.useState(null),[h,y]=C.useState(null),[x,j]=C.useState(null),[v,k]=C.useState(!1);let w,S,M,N,$,P,T,A,I;if(e[0]!==x||e[1]!==h||e[2]!==v||e[3]!==f||e[4]!==r||e[5]!==u||e[6]!==s||e[7]!==i){I=Mr(i,u);let me;e[17]!==i?(me=wr(i),e[17]=i,e[18]=me):me=e[18],N=me,P=s==="elevenlabs",A=s==="elevenlabs"?r:void 0;let he;e[19]!==P||e[20]!==i?(he=P&&Nr(i),e[19]=P,e[20]=i,e[21]=he):he=e[21],S=he,w=Cr({source:s,transcript:i,view:I,jsonText:f}),$=$r({transcript:i,view:I,jsonFile:h}),M=Ir({source:s,transcript:i,view:I,jsonText:f}),T=Rr({source:s,transcript:i,view:I,jsonLoading:v,jsonError:x,body:w}),e[0]=x,e[1]=h,e[2]=v,e[3]=f,e[4]=r,e[5]=u,e[6]=s,e[7]=i,e[8]=w,e[9]=S,e[10]=M,e[11]=N,e[12]=$,e[13]=P,e[14]=T,e[15]=A,e[16]=I}else w=e[8],S=e[9],M=e[10],N=e[11],$=e[12],P=e[13],T=e[14],A=e[15],I=e[16];const D=T,F=!!i,R=!!M;let E;e[22]!==M?(E=async()=>{if(M)try{await navigator.clipboard.writeText(M),b("copied")}catch{b("failed")}},e[22]=M,e[23]=E):E=e[23];const z=E;let _;e[24]!==F||e[25]!==v||e[26]!==f||e[27]!==c||e[28]!==s?(_=me=>{me==="json"&&!F||(p(me),!(me!=="json"||f!==null||v||!c)&&(k(!0),j(null),c(s).then(he=>{g(he.text),y(he.file)}).catch(he=>{j(he instanceof Error?he.message:String(he))}).finally(()=>{k(!1)})))},e[24]=F,e[25]=v,e[26]=f,e[27]=c,e[28]=s,e[29]=_):_=e[29];const L=_;let B;e[30]!==n?(B=t.jsx("span",{className:"inspector-media-field-label",children:n}),e[30]=n,e[31]=B):B=e[31];let U;e[32]!==R||e[33]!==z||e[34]!==m||e[35]!==n?(U=R&&t.jsxs("button",{type:"button",className:`inspector-prompt-copy${m==="copied"?" copied":""}`,"aria-label":m==="copied"?`${n} copied`:`Copy ${n}`,title:m==="copied"?`${n} copied`:`Copy ${n}`,onClick:()=>{z()},children:[m==="copied"?t.jsx(Qt,{size:12,"aria-hidden":"true"}):t.jsx(Zs,{size:12,"aria-hidden":"true"}),t.jsx("span",{"aria-live":"polite",children:Hd(m)})]}),e[32]=R,e[33]=z,e[34]=m,e[35]=n,e[36]=U):U=e[36];let q;e[37]!==a||e[38]!==S||e[39]!==d||e[40]!==P?(q=P&&t.jsxs("button",{type:"button",className:"inspector-prompt-copy","aria-label":S?"Download SRT":"Download SRT unavailable",title:S?"Download SRT":"No word-timed ElevenLabs transcript",disabled:!S||a||!d,onClick:()=>d?.(),children:[t.jsx(tn,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:"SRT"})]}),e[37]=a,e[38]=S,e[39]=d,e[40]=P,e[41]=q):q=e[41];let H;e[42]!==a||e[43]!==N||e[44]!==A||e[45]!==o?(H=A&&N&&t.jsx(Vd,{label:"Transcribe again",running:!!o,disabled:a||!!o,onClick:A}),e[42]=a,e[43]=N,e[44]=A,e[45]=o,e[46]=H):H=e[46];let K;e[47]!==U||e[48]!==q||e[49]!==H?(K=t.jsxs("div",{className:"inspector-insight-header-actions",children:[U,q,H]}),e[47]=U,e[48]=q,e[49]=H,e[50]=K):K=e[50];let se;e[51]!==B||e[52]!==K?(se=t.jsxs("header",{className:"inspector-insight-header",children:[B,K]}),e[51]=B,e[52]=K,e[53]=se):se=e[53];const ie=`${n} view`,V=I==="text",ce=I==="text"?"inspector-transcript-tab active":"inspector-transcript-tab";let W;e[54]!==L?(W=()=>L("text"),e[54]=L,e[55]=W):W=e[55];let te;e[56]!==V||e[57]!==ce||e[58]!==W?(te=t.jsx("button",{type:"button",role:"tab","aria-selected":V,className:ce,onClick:W,children:"TEXT"}),e[56]=V,e[57]=ce,e[58]=W,e[59]=te):te=e[59];const ae=I==="json",Y=!F,Q=!F,Z=F?"JSON":s==="plain"?"No GPT-4o translation":"No ElevenLabs transcript",re=I==="json"?"inspector-transcript-tab active":"inspector-transcript-tab";let ee;e[60]!==L?(ee=()=>L("json"),e[60]=L,e[61]=ee):ee=e[61];let J;e[62]!==ae||e[63]!==Y||e[64]!==Q||e[65]!==Z||e[66]!==re||e[67]!==ee?(J=t.jsx("button",{type:"button",role:"tab","aria-selected":ae,"aria-disabled":Y,disabled:Q,title:Z,className:re,onClick:ee,children:"JSON"}),e[62]=ae,e[63]=Y,e[64]=Q,e[65]=Z,e[66]=re,e[67]=ee,e[68]=J):J=e[68];let de;e[69]!==ie||e[70]!==te||e[71]!==J?(de=t.jsxs("div",{className:"inspector-transcript-tabs",role:"tablist","aria-label":ie,children:[te,J]}),e[69]=ie,e[70]=te,e[71]=J,e[72]=de):de=e[72];let fe;e[73]!==$?(fe=$&&t.jsx("p",{className:"inspector-insight-meta",children:$}),e[73]=$,e[74]=fe):fe=e[74];let ue;e[75]!==w||e[76]!==a||e[77]!==D||e[78]!==N||e[79]!==n||e[80]!==A||e[81]!==o||e[82]!==i||e[83]!==I?(ue=w&&!D?t.jsx(Kd,{text:w,label:`${n} ${I}`}):t.jsxs("div",{className:"inspector-insight-empty",children:[t.jsx("p",{children:D??"No transcript yet."}),A&&!N&&t.jsx(qd,{icon:t.jsx(Vo,{size:13,"aria-hidden":"true"}),label:i?"Transcribe again":"Transcribe",runningLabel:"Transcribing…",running:!!o,disabled:a||!!o,onClick:A})]}),e[75]=w,e[76]=a,e[77]=D,e[78]=N,e[79]=n,e[80]=A,e[81]=o,e[82]=i,e[83]=I,e[84]=ue):ue=e[84];let pe;return e[85]!==de||e[86]!==fe||e[87]!==ue||e[88]!==se||e[89]!==n?(pe=t.jsxs("section",{className:"inspector-insight-block","aria-label":n,children:[se,de,fe,ue]}),e[85]=de,e[86]=fe,e[87]=ue,e[88]=se,e[89]=n,e[90]=pe):pe=e[90],pe}function of(l){const e=X.c(19),{artifactId:s,transcript:n,busy:i,transcribing:a,error:o,onTranscribe:r,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d}=l,u=`${s}:plain`,p=n?.plain??null;let m;e[0]!==i||e[1]!==c||e[2]!==u||e[3]!==p?(m=t.jsx(Bl,{source:"plain",title:kr,transcript:p,busy:i,onLoadTranscriptJson:c},u),e[0]=i,e[1]=c,e[2]=u,e[3]=p,e[4]=m):m=e[4];const b=`${s}:elevenlabs`,f=n?.elevenlabs??null;let g;e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==r||e[9]!==b||e[10]!==f||e[11]!==a?(g=t.jsx(Bl,{source:"elevenlabs",title:Sr,transcript:f,busy:i,transcribing:a,onTranscribe:r,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d},b),e[5]=i,e[6]=d,e[7]=c,e[8]=r,e[9]=b,e[10]=f,e[11]=a,e[12]=g):g=e[12];let h;e[13]!==o?(h=o&&t.jsxs("p",{className:"inspector-insight-error",role:"alert",children:[t.jsx(wi,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:o})]}),e[13]=o,e[14]=h):h=e[14];let y;return e[15]!==m||e[16]!==g||e[17]!==h?(y=t.jsxs("div",{className:"inspector-media-insights",children:[m,g,h]}),e[15]=m,e[16]=g,e[17]=h,e[18]=y):y=e[18],y}function cf(l){const e=X.c(33),{bookId:s,artifactId:n,kind:i,busy:a,call:o}=l;let r;e[0]!==n||e[1]!==s||e[2]!==o?(r={call:o,bookId:s,artifactId:n},e[0]=n,e[1]=s,e[2]=o,e[3]=r):r=e[3];const{state:c,available:d,run:u}=Pr(r),p=c.phase==="running",m=a||!d||p,b=p&&c.action==="copy";let f;e[4]!==u?(f=()=>{u("copy")},e[4]=u,e[5]=f):f=e[5];let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Ci,{size:13,"aria-hidden":"true"}),e[6]=g):g=e[6];const h=p&&c.action==="copy"?"Copying…":`Copy ${i}`;let y;e[7]!==m||e[8]!==b||e[9]!==f||e[10]!==h?(y=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":b,title:"Copy the original media file to the clipboard",onClick:f,children:[g,h]}),e[7]=m,e[8]=b,e[9]=f,e[10]=h,e[11]=y):y=e[11];const x=p&&c.action==="download";let j;e[12]!==u?(j=()=>{u("download")},e[12]=u,e[13]=j):j=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(tn,{size:13,"aria-hidden":"true"}),e[14]=v):v=e[14];const k=p&&c.action==="download"?"Downloading…":`Download ${i}`;let w;e[15]!==m||e[16]!==k||e[17]!==x||e[18]!==j?(w=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":x,title:"Save the original media file to Downloads",onClick:j,children:[v,k]}),e[15]=m,e[16]=k,e[17]=x,e[18]=j,e[19]=w):w=e[19];let S;e[20]!==w||e[21]!==y?(S=t.jsxs("div",{className:"inspector-media-file-buttons",children:[y,w]}),e[20]=w,e[21]=y,e[22]=S):S=e[22];let M;e[23]!==c.message||e[24]!==c.phase?(M=c.phase==="done"&&t.jsx("p",{role:"status",children:c.message}),e[23]=c.message,e[24]=c.phase,e[25]=M):M=e[25];let N;e[26]!==c.message||e[27]!==c.phase?(N=c.phase==="failed"&&t.jsx("p",{className:"inspector-insight-error",role:"alert",children:c.message}),e[26]=c.message,e[27]=c.phase,e[28]=N):N=e[28];let $;return e[29]!==S||e[30]!==M||e[31]!==N?($=t.jsxs("section",{className:"inspector-media-file-actions","aria-label":"Media file actions",children:[S,M,N]}),e[29]=S,e[30]=M,e[31]=N,e[32]=$):$=e[32],$}const Wd={people:"People",places:"Places",editing:"Editing",custom:"Custom"};function df(l){const e=X.c(53),{tags:s,busy:n,error:i,canEdit:a,suggestions:o,onAdd:r,onRemove:c,onRestore:d,onQueryChange:u,status:p,onRetry:m}=l,[b,f]=C.useState(""),g=C.useRef(null),h=C.useId();let y;e[0]!==s?.effective?(y=s?.effective??[],e[0]=s?.effective,e[1]=y):y=e[1];let x;e[2]!==y?(x=ui(y),e[2]=y,e[3]=x):x=e[3];const j=x;let v;e[4]!==s?.dismissed?(v=s?.dismissed??[],e[4]=s?.dismissed,e[5]=v):v=e[5];const k=v;let w;e[6]!==a||e[7]!==b||e[8]!==r||e[9]!==u?(w=function(){const _=b.trim();!_||!a||(r({label:_}),f(""),u(""),g.current?.focus())},e[6]=a,e[7]=b,e[8]=r,e[9]=u,e[10]=w):w=e[10];const S=w;let M;e[11]!==S||e[12]!==b||e[13]!==u?(M=function(_){if(_.key==="Enter"){_.preventDefault(),S();return}_.key==="Escape"&&b&&(_.preventDefault(),f(""),u(""))},e[11]=S,e[12]=b,e[13]=u,e[14]=M):M=e[14];const N=M;let $;if(e[15]!==a||e[16]!==j||e[17]!==c){let z;e[19]!==a||e[20]!==c?(z=_=>t.jsxs("span",{className:`asset-tag-chip asset-tag-chip-${_.origin}`,role:"listitem",children:[t.jsx("span",{className:"asset-tag-chip-label",children:_.label}),a?t.jsx("button",{type:"button",className:"asset-tag-chip-remove",onClick:()=>c({facet:_.facet,label:_.label}),"aria-label":`Remove tag ${_.label} (${gl(_)})`,title:gl(_),children:t.jsx(mt,{size:11})}):null]},`${_.facet}/${_.key}`),e[19]=a,e[20]=c,e[21]=z):z=e[21],$=j.map(z),e[15]=a,e[16]=j,e[17]=c,e[18]=$}else $=e[18];let P;e[22]!==j.length||e[23]!==p?(P=j.length===0?t.jsx("span",{className:"asset-tag-empty",children:p??"No tags yet"}):null,e[22]=j.length,e[23]=p,e[24]=P):P=e[24];let T;e[25]!==$||e[26]!==P?(T=t.jsxs("div",{className:"asset-tag-chips",role:"list",children:[$,P]}),e[25]=$,e[26]=P,e[27]=T):T=e[27];let A;e[28]!==a||e[29]!==S||e[30]!==b||e[31]!==N||e[32]!==h||e[33]!==u||e[34]!==o?(A=a?t.jsxs("div",{className:"asset-tag-input-row",children:[t.jsx("input",{ref:g,className:"asset-tag-input",value:b,list:h,placeholder:"Add a tag","aria-label":"Add a tag",autoComplete:"off",onChange:z=>{f(z.target.value),u(z.target.value)},onKeyDown:N}),t.jsx("datalist",{id:h,children:o.map(Xd)}),t.jsx("button",{type:"button",className:"asset-tag-add",onClick:S,disabled:!b.trim(),"aria-label":"Add tag",children:t.jsx(es,{size:12})})]}):null,e[28]=a,e[29]=S,e[30]=b,e[31]=N,e[32]=h,e[33]=u,e[34]=o,e[35]=A):A=e[35];let I;e[36]!==T||e[37]!==A?(I=t.jsxs("div",{className:"asset-tag-row",children:[T,A]}),e[36]=T,e[37]=A,e[38]=I):I=e[38];let D;e[39]!==a||e[40]!==k||e[41]!==d?(D=k.length>0?t.jsxs("div",{className:"asset-tag-dismissed",children:[t.jsx("span",{className:"asset-tag-dismissed-label",children:"Removed"}),t.jsx("div",{className:"asset-tag-chips",role:"list",children:k.map(z=>t.jsxs("span",{className:"asset-tag-chip asset-tag-chip-dismissed",role:"listitem",children:[t.jsx("span",{className:"asset-tag-chip-label",children:z.label}),a?t.jsx("button",{type:"button",className:"asset-tag-chip-restore",onClick:()=>d({facet:z.facet,label:z.label}),"aria-label":`Restore tag ${z.label}`,title:"Restore this tag",children:t.jsx(Bn,{size:11})}):null]},`dismissed-${z.facet}/${z.key}`))})]}):null,e[39]=a,e[40]=k,e[41]=d,e[42]=D):D=e[42];let F;e[43]!==i||e[44]!==m?(F=i?t.jsxs("p",{className:"asset-tag-error",role:"status",children:[i,m?t.jsx("button",{type:"button",className:"asset-tag-retry",onClick:m,children:"Retry"}):null]}):null,e[43]=i,e[44]=m,e[45]=F):F=e[45];let R;e[46]!==n?(R=n?t.jsx("span",{className:"sr-only",role:"status",children:"Saving tags"}):null,e[46]=n,e[47]=R):R=e[47];let E;return e[48]!==I||e[49]!==D||e[50]!==F||e[51]!==R?(E=t.jsxs("section",{className:"asset-tag-editor","aria-label":"Asset tags",children:[I,D,F,R]}),e[48]=I,e[49]=D,e[50]=F,e[51]=R,e[52]=E):E=e[52],E}function Xd(l){return t.jsx("option",{value:l.label,children:`${Wd[l.facet]} · ${l.assets} asset${l.assets===1?"":"s"}`},`${l.facet}/${l.key}`)}function Js(...l){return ga(ya(l))}const Gd={cyan:"text-primary border-primary/30 bg-primary/10",amber:"text-amber-400 border-amber-400/30 bg-amber-400/10",violet:"text-violet-400 border-violet-400/30 bg-violet-400/10"};function Yd(l){const e=X.c(5),{value:s,colorScheme:n}=l,i=Gd[n];let a;e[0]!==i?(a=Js("inline-flex items-center px-1.5 py-0.5 rounded font-mono text-xs font-bold border",i),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==a||e[3]!==s?(o=t.jsx("span",{className:a,children:s}),e[2]=a,e[3]=s,e[4]=o):o=e[4],o}const Jd={Zap:Zo,Sparkles:Mi,Scissors:Kn,Mic:ki,Check:Qt,Clapperboard:Qo,Mailbox:Jo,ClipboardCopy:Ci,Columns3:Ri,FolderOpen:Yo,History:Un,Eye:Ii,Users:Go,Archive:Xo,NotebookPen:Wo,Rows3:$i,Stethoscope:qo,Images:Hn};function Qd(l){return Jd[l]}const Yt=8,An=320,Ol=80,Sn=2,Zd=460;function eu(l,e,s,n){const i=l.top-Yt*2,a=e.height-l.bottom-Yt*2,o=s?i>=Math.min(An,a)||i>a:a<Ol+Sn&&i>a,c=Math.max(Ol,Math.min(An,(o?i:a)-Sn)),d=c+Sn,u=o?Math.max(Yt,l.top-Yt-d):Math.max(Yt,Math.min(l.bottom+Yt,e.height-Yt-d)),p=n??Math.max(l.width,200),m=Math.min(Math.max(Yt,l.left),e.width-p-Yt);return{top:u,left:m,width:p,maxHeight:c,placeAbove:o}}function tu(l){return l?.closest("dialog[open]")??document.body}function su(l,e,s){const n=l.getBoundingClientRect();return eu({top:n.top,bottom:n.bottom,left:n.left,width:n.width},{width:window.innerWidth,height:window.innerHeight},e,s)}const Ws={size:13,"aria-hidden":!0};function nu(l){const e=X.c(4),{kind:s}=l;if(s==="audio"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ss,{...Ws}),e[0]=i):i=e[0],i}if(s==="image"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Zt,{...Ws}),e[1]=i):i=e[1],i}if(s==="video"||s==="final"){let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(St,{...Ws}),e[2]=i):i=e[2],i}let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(Ms,{...Ws}),e[3]=n):n=e[3],n}function uf(l){const e=X.c(59),{items:s,selectedIndex:n,onSelect:i,onHover:a,anchorRef:o,preferAbove:r,widthPx:c}=l,d=r===void 0?!0:r,u=C.useRef(null),[p,m]=C.useState(null),[b,f]=C.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=[],e[0]=g):g=e[0];const[h,y]=C.useState(g),x=o!=null;let j,v;e[1]!==n?(j=()=>{u.current?.querySelector(`[data-option-index="${n}"]`)?.scrollIntoView({block:"nearest"})},v=[n],e[1]=n,e[2]=j,e[3]=v):(j=e[2],v=e[3]),C.useEffect(j,v);let k;e[4]!==o||e[5]!==d||e[6]!==x||e[7]!==c?(k=()=>{if(!x||!o)return;const H=()=>{const K=o.current;K&&(m(su(K,d,c)),f(tu(K)))};return H(),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},e[4]=o,e[5]=d,e[6]=x,e[7]=c,e[8]=k):k=e[8];let w;e[9]!==o||e[10]!==s.length||e[11]!==d||e[12]!==x||e[13]!==c?(w=[x,o,d,c,s.length],e[9]=o,e[10]=s.length,e[11]=d,e[12]=x,e[13]=c,e[14]=w):w=e[14],C.useLayoutEffect(k,w);const S=!x&&"absolute bottom-full left-0 right-0 mb-2 z-50 origin-bottom",M=x&&p?.placeAbove&&"origin-bottom",N=x&&p&&!p.placeAbove&&"origin-top";let $;e[15]!==S||e[16]!==M||e[17]!==N?($=Js("bg-background border border-primary/30 rounded-sm shadow-[0_18px_48px_rgba(0,0,0,0.62)] overflow-hidden","animate-in fade-in-0 zoom-in-95 duration-150",S,M,N),e[15]=S,e[16]=M,e[17]=N,e[18]=$):$=e[18];const P=$;let T;e[19]!==p||e[20]!==x?(T=x&&p?{position:"fixed",top:p.top,left:p.left,width:p.width,zIndex:Zd}:void 0,e[19]=p,e[20]=x,e[21]=T):T=e[21];const A=T;let I,D,F,R,E,z,_,L;if(e[22]!==h||e[23]!==s||e[24]!==P||e[25]!==A||e[26]!==a||e[27]!==i||e[28]!==p?.maxHeight||e[29]!==n){const H=s.map(ru),K=H.filter(au),se=H.filter(iu);z=P,_=A,L=lu,I=u,D="overflow-y-auto";const ie=p?.maxHeight??An;e[38]!==ie?(F={maxHeight:ie},e[38]=ie,e[39]=F):F=e[39];let V;e[40]!==h||e[41]!==a||e[42]!==i||e[43]!==n?(V=ce=>{const{item:W,index:te}=ce,ae=W.icon?Qd(W.icon):void 0,Y=W.thumbnailSrc&&!h.includes(W.thumbnailSrc)?W.thumbnailSrc:null,Q=W.type==="mention",Z=Y!==null||W.mediaKind!==void 0;return t.jsxs("button",{type:"button","data-option-index":te,className:Js("w-full h-10 px-3 text-left text-sm transition-colors flex items-center gap-3",te===n?"bg-primary/20 text-primary shadow-[inset_2px_0_0_var(--color-primary)]":"text-foreground hover:bg-white/5"),onClick:()=>i(W),onMouseEnter:()=>a(te),children:[Z&&t.jsx("span",{className:"flex h-[30px] w-[52px] shrink-0 items-center justify-center overflow-hidden rounded-sm border border-primary/20 bg-[#07150e] text-primary/60",children:Y?t.jsx("img",{src:Y,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover",onError:()=>y(re=>re.includes(Y)?re:[...re,Y])}):t.jsx(nu,{kind:W.mediaKind})}),t.jsx(Yd,{value:W.label,colorScheme:W.colorScheme}),W.example&&W.example!==W.value?t.jsx("span",{className:"text-muted-foreground/50 text-xs font-mono min-w-0 flex-1 truncate",children:W.example.replace(W.value,"").trimStart()}):Q?t.jsx("span",{className:"text-xs min-w-0 flex-1 truncate text-[#cde8da]",children:W.caption}):t.jsx("span",{className:"text-muted-foreground text-xs min-w-0 flex-1 truncate",children:W.description}),Q&&W.description&&t.jsx("span",{className:"shrink-0 text-[10px] tracking-[0.1em] text-[#8fb9a1]",children:W.description}),ae&&!Z&&t.jsx(ae,{className:"size-3 shrink-0 opacity-50"})]},`${W.value}-${te}`)},e[40]=h,e[41]=a,e[42]=i,e[43]=n,e[44]=V):V=e[44],R=K.map(V),E=se.length>0&&t.jsxs("div",{className:"flex h-9 items-center gap-2 overflow-x-auto border-t border-primary/10 px-3",children:[t.jsx("span",{className:"shrink-0 text-[10px] tracking-[0.14em] text-[#6f9a82]",children:"EMPTY"}),se.map(ce=>{const{item:W,index:te}=ce;return t.jsx("button",{type:"button","data-option-index":te,title:W.description,className:Js("shrink-0 rounded-sm border border-dashed px-1.5 py-0.5 font-mono text-xs font-bold transition-colors",te===n?"border-primary/60 bg-primary/20 text-amber-300":"border-primary/25 text-amber-400/80 hover:border-primary/50 hover:text-amber-300"),onClick:()=>i(W),onMouseEnter:()=>a(te),children:W.label},`${W.value}-${te}`)})]}),e[22]=h,e[23]=s,e[24]=P,e[25]=A,e[26]=a,e[27]=i,e[28]=p?.maxHeight,e[29]=n,e[30]=I,e[31]=D,e[32]=F,e[33]=R,e[34]=E,e[35]=z,e[36]=_,e[37]=L}else I=e[30],D=e[31],F=e[32],R=e[33],E=e[34],z=e[35],_=e[36],L=e[37];let B;e[45]!==I||e[46]!==D||e[47]!==F||e[48]!==R||e[49]!==E?(B=t.jsxs("div",{ref:I,className:D,style:F,children:[R,E]}),e[45]=I,e[46]=D,e[47]=F,e[48]=R,e[49]=E,e[50]=B):B=e[50];let U;e[51]!==z||e[52]!==_||e[53]!==L||e[54]!==B?(U=t.jsx("div",{className:z,style:_,onMouseDown:L,children:B}),e[51]=z,e[52]=_,e[53]=L,e[54]=B,e[55]=U):U=e[55];const q=U;if(x){if(!p||!b||typeof document>"u")return null;let H;return e[56]!==b||e[57]!==q?(H=gs.createPortal(q,b),e[56]=b,e[57]=q,e[58]=H):H=e[58],H}return q}function lu(l){return l.preventDefault()}function iu(l){const{item:e}=l;return e.empty}function au(l){const{item:e}=l;return!e.empty}function ru(l,e){return{item:l,index:e}}function ou(l){const e=X.c(21),{tags:s,limit:n,onFilter:i,activeTerms:a}=l,o=n===void 0?4:n;let r,c,d,u,p,m;if(e[0]!==o||e[1]!==i||e[2]!==a||e[3]!==s?.effective){m=Symbol.for("react.early_return_sentinel");e:{const g=a===void 0?[]:a,h=ui(s?.effective??[]);if(h.length===0){m=null;break e}const y=h.slice(0,o);r=h.length-y.length;const x=new Set(g.map(cu));c="asset-tag-summary",d="list",u="Tags";let j;e[10]!==x||e[11]!==i?(j=v=>{const k=`${v.facet}/${v.key}`,w=x.has(k);return i?t.jsx("button",{type:"button",role:"listitem",className:"asset-tag-summary-chip asset-tag-summary-chip-action","aria-pressed":w,title:w?`Remove filter ${v.label}`:`Filter by ${v.label}`,onClick:()=>i(Tr(v)),children:v.label},k):t.jsx("span",{className:"asset-tag-summary-chip",role:"listitem",children:v.label},k)},e[10]=x,e[11]=i,e[12]=j):j=e[12],p=y.map(j)}e[0]=o,e[1]=i,e[2]=a,e[3]=s?.effective,e[4]=r,e[5]=c,e[6]=d,e[7]=u,e[8]=p,e[9]=m}else r=e[4],c=e[5],d=e[6],u=e[7],p=e[8],m=e[9];if(m!==Symbol.for("react.early_return_sentinel"))return m;let b;e[13]!==r?(b=r>0?t.jsx("span",{className:"asset-tag-summary-more",role:"listitem",children:`+${r}`}):null,e[13]=r,e[14]=b):b=e[14];let f;return e[15]!==c||e[16]!==d||e[17]!==u||e[18]!==p||e[19]!==b?(f=t.jsxs("div",{className:c,role:d,"aria-label":u,children:[p,b]}),e[15]=c,e[16]=d,e[17]=u,e[18]=p,e[19]=b,e[20]=f):f=e[20],f}function cu(l){return`${l.facet}/${l.key}`}function du(l){const e=X.c(54),{mode:s,reference:n,preparing:i,disabled:a,startSeconds:o,durationSeconds:r,children:c,onFile:d,onClear:u,onStartSeconds:p,onDurationSeconds:m}=l;let b;e[0]!==s?(b=Er(s),e[0]=s,e[1]=b):b=e[1];const f=b,g=f==="image"?"an image":"a video",h=f==="image"?Zt:St,y=f==="image"?"image/*,.heic,.heif":"video/*";let x;e[2]!==a||e[3]!==f||e[4]!==d||e[5]!==i?(x=B=>{if(a||i)return;const U=B.find(q=>yl(q,f));U&&d(U)},e[2]=a,e[3]=f,e[4]=d,e[5]=i,e[6]=x):x=e[6];const j=x;let v;e[7]!==j?(v=B=>{B.preventDefault(),B.stopPropagation(),j([...B.dataTransfer.files])},e[7]=j,e[8]=v):v=e[8];const k=v;let w;e[9]!==f||e[10]!==j?(w=B=>{const U=[...B.clipboardData.files],q=U.length>0?U:[...B.clipboardData.items].flatMap(mu);q.some(H=>yl(H,f))&&(B.preventDefault(),B.stopPropagation(),j(q))},e[9]=f,e[10]=j,e[11]=w):w=e[11];const S=w;let M;e[12]!==h||e[13]!==f||e[14]!==i||e[15]!==n?(M=i?t.jsx(ut,{size:24}):n?.previewUrl?f==="image"?t.jsx("img",{src:n.previewUrl,alt:""}):t.jsx("video",{src:n.previewUrl,controls:!0,playsInline:!0,preload:"metadata"}):t.jsx(h,{size:26}),e[12]=h,e[13]=f,e[14]=i,e[15]=n,e[16]=M):M=e[16];const N=i?`Preparing ${f}…`:n?n.name:`Drop or paste ${g}`;let $;e[17]!==N?($=t.jsx("strong",{children:N}),e[17]=N,e[18]=$):$=e[18];const P=n?"Temporary search reference":`Choose ${g} file, drag it here, or paste from the clipboard`;let T;e[19]!==P?(T=t.jsx("span",{children:P}),e[19]=P,e[20]=T):T=e[20];let A;e[21]!==$||e[22]!==T?(A=t.jsxs("div",{children:[$,T]}),e[21]=$,e[22]=T,e[23]=A):A=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(sn,{size:14}),e[24]=I):I=e[24];const D=a||i;let F;e[25]!==d?(F=B=>{const U=B.target.files?.[0];U&&d(U),B.target.value=""},e[25]=d,e[26]=F):F=e[26];let R;e[27]!==y||e[28]!==D||e[29]!==F?(R=t.jsxs("label",{className:"reverse-search-upload",children:[I,"Choose file",t.jsx("input",{type:"file",accept:y,disabled:D,onChange:F})]}),e[27]=y,e[28]=D,e[29]=F,e[30]=R):R=e[30];let E;e[31]!==a||e[32]!==u||e[33]!==i||e[34]!==n?(E=n&&t.jsxs("button",{type:"button",className:"reverse-search-clear",disabled:a||i,"aria-label":"Clear search reference",onClick:u,children:[t.jsx(mt,{size:14}),"Clear"]}),e[31]=a,e[32]=u,e[33]=i,e[34]=n,e[35]=E):E=e[35];let z;e[36]!==A||e[37]!==R||e[38]!==E||e[39]!==M?(z=t.jsxs("div",{className:"reverse-search-dropzone",tabIndex:0,autoFocus:!0,children:[M,A,R,E]}),e[36]=A,e[37]=R,e[38]=E,e[39]=M,e[40]=z):z=e[40];let _;e[41]!==r||e[42]!==f||e[43]!==m||e[44]!==p||e[45]!==n||e[46]!==o?(_=f==="video"&&n&&t.jsxs("div",{className:"reverse-search-range",children:[t.jsxs("label",{children:["Start seconds",t.jsx("input",{type:"number",min:"0",step:"0.1",value:o,onChange:B=>p(B.target.value)})]}),t.jsxs("label",{children:["Duration seconds",t.jsx("input",{type:"number",min:"0.1",step:"0.1",value:r,placeholder:"Whole remaining video",onChange:B=>m(B.target.value)})]}),n.durationMs!==void 0&&t.jsxs("span",{children:[(n.durationMs/1e3).toFixed(1),"s available"]})]}),e[41]=r,e[42]=f,e[43]=m,e[44]=p,e[45]=n,e[46]=o,e[47]=_):_=e[47];let L;return e[48]!==c||e[49]!==k||e[50]!==S||e[51]!==z||e[52]!==_?(L=t.jsxs("section",{className:"reverse-search-reference",onDragOver:uu,onDrop:k,onPaste:S,children:[z,c,_]}),e[48]=c,e[49]=k,e[50]=S,e[51]=z,e[52]=_,e[53]=L):L=e[53],L}function uu(l){l.dataTransfer.types.includes("Files")&&l.preventDefault()}function mu(l){const e=l.kind==="file"?l.getAsFile():null;return e?[e]:[]}const fu=[{id:"text",label:"Text",icon:rs},{id:"image-reverse",label:"Image reverse",icon:Zt},{id:"video-reverse",label:"Vid reverse",icon:St}];function Dn(l){return l==="all"?"media":l==="audio"?"audio":`${l}s`}function pu(l,e){if(!l)return null;const s=Date.parse(l);if(!Number.isFinite(s))return null;const n=Math.max(0,Math.round((e-s)/6e4));if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.round(n/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function hu(l){return l.mode!=="text"?"Most similar":l.query.trim()?"Best match":"Recently used"}function bu(l){return l.type==="image"||l.type==="video"||l.type==="final"}function xu(l){const e=X.c(45),{asset:s,state:n,targetBookId:i,busy:a,now:o,onAttach:r,onSimilar:c,onToggleTagFilter:d}=l,u=n.activeArtifactId===s.artifactId;let p;e[0]!==s.label?(p=s.label.trim()||"Untitled media",e[0]=s.label,e[1]=p):p=e[1];const m=p;let b;e[2]!==s.lastUsedAt||e[3]!==o?(b=pu(s.lastUsedAt,o),e[2]=s.lastUsedAt,e[3]=o,e[4]=b):b=e[4];const f=b;let g;e[5]!==s?(g=t.jsx(ld,{asset:s}),e[5]=s,e[6]=g):g=e[6];let h;e[7]!==m?(h=t.jsx("strong",{children:m}),e[7]=m,e[8]=h):h=e[8];const y=s.owningBookId===i?" · this book":" · copy";let x;e[9]!==s.owningBookName||e[10]!==y?(x=t.jsxs("small",{children:[s.owningBookName,y]}),e[9]=s.owningBookName,e[10]=y,e[11]=x):x=e[11];let j;e[12]!==h||e[13]!==x?(j=t.jsxs("span",{className:"media-library-asset-copy",children:[h,x]}),e[12]=h,e[13]=x,e[14]=j):j=e[14];let v;e[15]!==f?(v=f&&t.jsxs("span",{className:"media-library-asset-used",children:["Used ",f]}),e[15]=f,e[16]=v):v=e[16];let k;e[17]!==s.tags||e[18]!==d||e[19]!==n.tagFilters?(k=t.jsx(ou,{tags:s.tags,limit:2,onFilter:d,activeTerms:n.tagFilters}),e[17]=s.tags,e[18]=d,e[19]=n.tagFilters,e[20]=k):k=e[20];let w;e[21]!==u?(w=u&&t.jsxs("span",{className:"media-library-asset-busy",children:[t.jsx(ut,{size:16}),"Attaching…"]}),e[21]=u,e[22]=w):w=e[22];let S;e[23]!==s||e[24]!==a||e[25]!==c?(S=bu(s)&&t.jsxs("button",{type:"button",className:"media-library-asset-similar",disabled:a,title:"Find similar media",onClick:()=>c(s),children:[t.jsx(rs,{size:12}),"Similar"]}),e[23]=s,e[24]=a,e[25]=c,e[26]=S):S=e[26];const M=`Use ${m} from ${s.owningBookName}`,N=`Use ${m}`;let $;e[27]!==s||e[28]!==r?($=()=>r(s),e[27]=s,e[28]=r,e[29]=$):$=e[29];let P;e[30]!==a||e[31]!==M||e[32]!==N||e[33]!==$?(P=t.jsx("button",{type:"button",className:"media-library-asset-use",disabled:a,"aria-label":M,title:N,onClick:$}),e[30]=a,e[31]=M,e[32]=N,e[33]=$,e[34]=P):P=e[34];let T;e[35]!==S||e[36]!==P?(T=t.jsxs("span",{className:"media-library-asset-actions",children:[S,P]}),e[35]=S,e[36]=P,e[37]=T):T=e[37];let A;return e[38]!==w||e[39]!==T||e[40]!==g||e[41]!==j||e[42]!==v||e[43]!==k?(A=t.jsxs("article",{className:"media-library-asset",children:[g,j,v,k,w,T]}),e[38]=w,e[39]=T,e[40]=g,e[41]=j,e[42]=v,e[43]=k,e[44]=A):A=e[44],A}function gu(l){const e=X.c(26),{state:s,onToggleTagFilter:n,onClearTagFilters:i,onTagQuery:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"sr-only",children:"Filter by tag"}),e[0]=o):o=e[0];let r;e[1]!==a?(r=g=>a(g.target.value),e[1]=a,e[2]=r):r=e[2];let c;e[3]!==n||e[4]!==s.tagSuggestions?(c=g=>{if(g.key!=="Enter")return;g.preventDefault();const h=g.currentTarget.value.trim();if(!h)return;const y=s.tagSuggestions.find(x=>x.label.toLowerCase()===h.toLowerCase());y&&(n({facet:y.facet,key:y.key,label:y.label}),g.currentTarget.value="")},e[3]=n,e[4]=s.tagSuggestions,e[5]=c):c=e[5];let d;e[6]!==r||e[7]!==c?(d=t.jsxs("label",{className:"media-library-tag-input-label",children:[o,t.jsx("input",{className:"media-library-tag-input",list:"media-library-tag-suggestions",placeholder:"Filter by tag","aria-label":"Filter by tag",autoComplete:"off",onChange:r,onKeyDown:c})]}),e[6]=r,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==s.tagSuggestions?(u=s.tagSuggestions.map(yu),e[9]=s.tagSuggestions,e[10]=u):u=e[10];let p;e[11]!==u?(p=t.jsx("datalist",{id:"media-library-tag-suggestions",children:u}),e[11]=u,e[12]=p):p=e[12];let m;if(e[13]!==n||e[14]!==s.tagFilters){let g;e[16]!==n?(g=h=>t.jsxs("button",{type:"button",className:"media-library-tag-filter","aria-label":`Remove tag filter ${h.label}`,onClick:()=>n(h),children:[h.label,t.jsx(mt,{size:11})]},`${h.facet}/${h.key}`),e[16]=n,e[17]=g):g=e[17],m=s.tagFilters.map(g),e[13]=n,e[14]=s.tagFilters,e[15]=m}else m=e[15];let b;e[18]!==i||e[19]!==s.tagFilters.length?(b=s.tagFilters.length>0&&t.jsx("button",{type:"button",className:"media-library-tag-clear",onClick:i,children:"Clear tags"}),e[18]=i,e[19]=s.tagFilters.length,e[20]=b):b=e[20];let f;return e[21]!==d||e[22]!==p||e[23]!==m||e[24]!==b?(f=t.jsxs("div",{className:"media-library-tag-filters",children:[d,p,m,b]}),e[21]=d,e[22]=p,e[23]=m,e[24]=b,e[25]=f):f=e[25],f}function yu(l){return t.jsx("option",{value:l.label,children:`${l.facet} · ${l.assets}`},`${l.facet}/${l.key}`)}function ju(l){const e=X.c(14),{state:s,busy:n,onRepairIndexes:i}=l;let a;e[0]!==s.error?(a=s.error&&t.jsx("p",{className:"media-library-error",role:"alert",children:s.error}),e[0]=s.error,e[1]=a):a=e[1];let o;e[2]!==n||e[3]!==i||e[4]!==s.loading||e[5]!==s.preparingIndex||e[6]!==s.unindexedVisualAssets?(o=s.unindexedVisualAssets>0&&t.jsxs("div",{className:"media-library-warning",role:"status",children:[s.unindexedVisualAssets," media ",s.unindexedVisualAssets===1?"asset is":"assets are"," missing from Similar search."," ",t.jsx("button",{type:"button",disabled:n||s.loading||s.preparingIndex,onClick:i,children:s.preparingIndex?"Indexing…":"Index missing media"})]}),e[2]=n,e[3]=i,e[4]=s.loading,e[5]=s.preparingIndex,e[6]=s.unindexedVisualAssets,e[7]=o):o=e[7];let r;e[8]!==s.booksWithErrors.length?(r=s.booksWithErrors.length>0&&t.jsxs("p",{className:"media-library-warning",role:"status",children:[s.booksWithErrors.length," book",s.booksWithErrors.length===1?"":"s"," could not be searched."]}),e[8]=s.booksWithErrors.length,e[9]=r):r=e[9];let c;return e[10]!==a||e[11]!==o||e[12]!==r?(c=t.jsxs(t.Fragment,{children:[a,o,r]}),e[10]=a,e[11]=o,e[12]=r,e[13]=c):c=e[13],c}function vu(l){const e=X.c(10),{state:s,kind:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Vn,{size:22}),e[0]=i):i=e[0];let a;e[1]!==n?(a=Dn(n),e[1]=n,e[2]=a):a=e[2];let o;e[3]!==a?(o=t.jsxs("strong",{children:["No ",a," found"]}),e[3]=a,e[4]=o):o=e[4];const r=s.tagFilters.length>0?"No media carries every selected tag. Clear a tag or try another search.":"Try another search, upload a file, or drop one onto the cell.";let c;e[5]!==r?(c=t.jsx("span",{children:r}),e[5]=r,e[6]=c):c=e[6];let d;return e[7]!==o||e[8]!==c?(d=t.jsxs("div",{className:"media-library-empty",children:[i,o,c]}),e[7]=o,e[8]=c,e[9]=d):d=e[9],d}function mf(l){const e=X.c(93),{state:s,kind:n,accept:i,targetBookId:a,onClose:o,onMode:r,onDraftQuery:c,onSearch:d,onLoadMore:u,onAttach:p,onUpload:m,onSimilar:b,onToggleTagFilter:f}=l,g=C.useRef(null),h=l.disabled||s.activeArtifactId!==null||s.preparingReference||s.uploading,[y]=C.useState(ku);let x;e[0]!==h||e[1]!==o?(x=V=>{V.key!=="Escape"||h||V.nativeEvent.isComposing||(V.preventDefault(),V.stopPropagation(),o())},e[0]=h,e[1]=o,e[2]=x):x=e[2];const j=x,v=n==="all"?"Choose library media":`Choose ${n} media`;let k;e[3]!==h||e[4]!==n||e[5]!==c||e[6]!==d||e[7]!==s.draftQuery||e[8]!==s.mode?(k=s.mode==="text"?t.jsxs("form",{className:"media-library-search",role:"search",onSubmit:V=>{V.preventDefault(),h||d()},children:[t.jsx(rs,{size:14,"aria-hidden":"true"}),t.jsx("input",{type:"search",value:s.draftQuery,"aria-label":"Search library",placeholder:`Search ${Dn(n)} in every book`,autoFocus:!0,disabled:h,onChange:V=>c(V.target.value)})]}):t.jsxs("span",{className:"media-library-search media-library-search-reverse",children:[t.jsx(rs,{size:14,"aria-hidden":"true"}),"Reverse search across every book"]}),e[3]=h,e[4]=n,e[5]=c,e[6]=d,e[7]=s.draftQuery,e[8]=s.mode,e[9]=k):k=e[9];let w;e[10]!==h||e[11]!==n||e[12]!==r||e[13]!==s.mode?(w=n!=="audio"&&t.jsx("div",{className:"media-library-modes",role:"tablist","aria-label":"Search mode",children:fu.map(V=>{const ce=V.icon;return t.jsxs("button",{type:"button",role:"tab","aria-selected":s.mode===V.id,className:s.mode===V.id?"active":"",disabled:h,onClick:()=>r(V.id),children:[t.jsx(ce,{size:13}),V.label]},V.id)})}),e[10]=h,e[11]=n,e[12]=r,e[13]=s.mode,e[14]=w):w=e[14];let S;e[15]!==l?(S=t.jsx(gu,{...l}),e[15]=l,e[16]=S):S=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=()=>g.current?.click(),e[17]=M):M=e[17];let N;e[18]!==s.uploading?(N=s.uploading?t.jsx(ut,{size:13}):t.jsx(sn,{size:13}),e[18]=s.uploading,e[19]=N):N=e[19];const $=s.uploading?"Uploading…":"Upload";let P;e[20]!==h||e[21]!==N||e[22]!==$?(P=t.jsxs("button",{type:"button",className:"media-library-upload",disabled:h,onClick:M,children:[N,$]}),e[20]=h,e[21]=N,e[22]=$,e[23]=P):P=e[23];let T;e[24]!==m?(T=V=>{const ce=V.target.files?.[0];V.target.value="",ce&&m(ce)},e[24]=m,e[25]=T):T=e[25];let A;e[26]!==i||e[27]!==T?(A=t.jsx("input",{ref:g,className:"media-library-upload-input",type:"file",accept:i,tabIndex:-1,"aria-hidden":"true",onChange:T}),e[26]=i,e[27]=T,e[28]=A):A=e[28];let I;e[29]!==A||e[30]!==k||e[31]!==w||e[32]!==S||e[33]!==P?(I=t.jsxs("div",{className:"media-library-toolbar",children:[k,w,S,P,A]}),e[29]=A,e[30]=k,e[31]=w,e[32]=S,e[33]=P,e[34]=I):I=e[34];let D;e[35]!==h||e[36]!==d||e[37]!==l.onClearReference||e[38]!==l.onReferenceDuration||e[39]!==l.onReferenceFile||e[40]!==l.onReferenceStart||e[41]!==s.activeArtifactId||e[42]!==s.loading||e[43]!==s.mode||e[44]!==s.preparingReference||e[45]!==s.reference||e[46]!==s.referenceDurationSeconds||e[47]!==s.referenceStartSeconds?(D=s.mode!=="text"&&t.jsxs("div",{className:"media-library-search-panel",children:[t.jsx(du,{mode:s.mode,reference:s.reference,preparing:s.preparingReference,disabled:s.activeArtifactId!==null,startSeconds:s.referenceStartSeconds,durationSeconds:s.referenceDurationSeconds,onFile:l.onReferenceFile,onClear:l.onClearReference,onStartSeconds:l.onReferenceStart,onDurationSeconds:l.onReferenceDuration,children:t.jsx("p",{className:"media-library-similar-hint",children:"Or choose Similar on any result below."})}),s.reference&&t.jsxs("button",{type:"button",className:"media-library-reverse-submit",disabled:h||s.loading,onClick:d,children:[t.jsx(rs,{size:14}),"Search similar media"]})]}),e[35]=h,e[36]=d,e[37]=l.onClearReference,e[38]=l.onReferenceDuration,e[39]=l.onReferenceFile,e[40]=l.onReferenceStart,e[41]=s.activeArtifactId,e[42]=s.loading,e[43]=s.mode,e[44]=s.preparingReference,e[45]=s.reference,e[46]=s.referenceDurationSeconds,e[47]=s.referenceStartSeconds,e[48]=D):D=e[48];const F=s.loading||s.loadingMore;let R;e[49]!==h||e[50]!==l.onRepairIndexes||e[51]!==s?(R=t.jsx(ju,{state:s,busy:h,onRepairIndexes:l.onRepairIndexes}),e[49]=h,e[50]=l.onRepairIndexes,e[51]=s,e[52]=R):R=e[52];let E;e[53]!==h||e[54]!==n||e[55]!==y||e[56]!==p||e[57]!==b||e[58]!==f||e[59]!==s||e[60]!==a?(E=s.loading&&s.assets.length===0?t.jsxs("div",{className:"media-library-loading",children:[t.jsx(ut,{size:22}),s.preparingIndex?"Preparing search…":"Loading recent media…"]}):s.assets.length===0?t.jsx(vu,{state:s,kind:n}):t.jsx("div",{className:"media-library-grid",children:s.assets.map(V=>t.jsx(xu,{asset:V,state:s,targetBookId:a,busy:h,now:y,onAttach:p,onSimilar:b,onToggleTagFilter:f},`${V.owningBookId}:${V.artifactId}`))}),e[53]=h,e[54]=n,e[55]=y,e[56]=p,e[57]=b,e[58]=f,e[59]=s,e[60]=a,e[61]=E):E=e[61];let z;e[62]!==F||e[63]!==R||e[64]!==E?(z=t.jsxs("div",{className:"media-library-results","aria-busy":F,children:[R,E]}),e[62]=F,e[63]=R,e[64]=E,e[65]=z):z=e[65];let _;e[66]!==s?(_=hu(s),e[66]=s,e[67]=_):_=e[67];let L;e[68]!==_?(L=t.jsx("strong",{children:_}),e[68]=_,e[69]=L):L=e[69];const B=s.assets.length,U=s.page.total;let q;e[70]!==n?(q=Dn(n),e[70]=n,e[71]=q):q=e[71];let H;e[72]!==s.assets.length||e[73]!==s.page.total||e[74]!==L||e[75]!==q?(H=t.jsxs("span",{children:[L," · ",B," of ",U," ",q]}),e[72]=s.assets.length,e[73]=s.page.total,e[74]=L,e[75]=q,e[76]=H):H=e[76];let K;e[77]!==h||e[78]!==u||e[79]!==s.loadingMore||e[80]!==s.page.hasMore||e[81]!==s.preparingIndex?(K=s.page.hasMore&&t.jsxs("button",{type:"button",disabled:h||s.loadingMore,onClick:u,children:[s.loadingMore?t.jsx(ut,{size:13}):t.jsx(es,{size:13}),s.preparingIndex?"Preparing search…":s.loadingMore?"Loading…":"Load more"]}),e[77]=h,e[78]=u,e[79]=s.loadingMore,e[80]=s.page.hasMore,e[81]=s.preparingIndex,e[82]=K):K=e[82];let se;e[83]!==H||e[84]!==K?(se=t.jsxs("footer",{className:"media-library-footer",children:[H,K]}),e[83]=H,e[84]=K,e[85]=se):se=e[85];let ie;return e[86]!==j||e[87]!==v||e[88]!==I||e[89]!==D||e[90]!==z||e[91]!==se?(ie=t.jsxs("section",{className:"media-library-panel","aria-label":v,onKeyDown:j,children:[I,D,z,se]}),e[86]=j,e[87]=v,e[88]=I,e[89]=D,e[90]=z,e[91]=se,e[92]=ie):ie=e[92],ie}function ku(){return Date.now()}const ws="#f5d76e";function ks(l,e){const s=new Set(l);return s.has(e)?s.delete(e):s.add(e),s}function Su(l){return l instanceof Error?l.message:String(l)}function wu(l,e,s){return l.box?{x:l.box.x*e,y:l.box.y*s,width:l.box.width*e,height:l.box.height*s}:null}function Nu(l,e,s){return{x:l.box.x*e,y:l.box.y*s,width:l.box.width*e,height:l.box.height*s}}function wn(l,e,s){const n=l.currentTarget,i=n.getScreenCTM();if(i&&"createSVGPoint"in n){const a=n.createSVGPoint();a.x=l.clientX,a.y=l.clientY;const o=a.matrixTransform(i.inverse());return{x:Math.min(1,Math.max(0,e>0?o.x/e:0)),y:Math.min(1,Math.max(0,s>0?o.y/s:0))}}return Hr(l.clientX,l.clientY,n.getBoundingClientRect())}function Cu(l){const e=X.c(72),{mediaUrl:s,width:n,height:i,subjectMap:a,selectedIds:o,hiddenIds:r,regions:c,selectedRegionIds:d,drawMode:u,draftBox:p,snapRegionId:m,opacity:b,onToggle:f,onToggleRegion:g,onHoverRegion:h,onPointerDown:y,onPointerMove:x,onPointerUp:j,onCancelDraw:v}=l;let k;e[0]!==a?.subjects?(k=a?.subjects??[],e[0]=a?.subjects,e[1]=k):k=e[1];const w=k;if(n<=0||i<=0){let R;return e[2]!==s?(R=t.jsx("img",{src:s,alt:""}),e[2]=s,e[3]=R):R=e[3],R}const S=`notebook-subject-stage-svg${u?" drawing":""}`,M=`0 0 ${n} ${i}`;let N;e[4]!==i||e[5]!==s||e[6]!==n?(N=t.jsx("image",{href:s,width:n,height:i,preserveAspectRatio:"xMidYMid meet"}),e[4]=i,e[5]=s,e[6]=n,e[7]=N):N=e[7];let $;e[8]!==u||e[9]!==i||e[10]!==n?($=u&&t.jsx("rect",{className:"notebook-region-draw-layer",width:n,height:i,fill:"transparent"}),e[8]=u,e[9]=i,e[10]=n,e[11]=$):$=e[11];let P;if(e[12]!==i||e[13]!==w||e[14]!==n){let R;e[16]!==i||e[17]!==n?(R=(E,z)=>E.layerUrl?t.jsx("mask",{id:`notebook-subject-mask-${z}`,className:"notebook-subject-mask",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:n,height:i,children:t.jsx("image",{href:E.layerUrl,width:n,height:i,preserveAspectRatio:"none"})},E.id):null,e[16]=i,e[17]=n,e[18]=R):R=e[18],P=w.map(R),e[12]=i,e[13]=w,e[14]=n,e[15]=P}else P=e[15];let T;e[19]!==P?(T=t.jsx("defs",{children:P}),e[19]=P,e[20]=T):T=e[20];let A;if(e[21]!==u||e[22]!==i||e[23]!==r||e[24]!==f||e[25]!==b||e[26]!==o||e[27]!==w||e[28]!==n){let R;e[30]!==u||e[31]!==i||e[32]!==r||e[33]!==f||e[34]!==b||e[35]!==o||e[36]!==n?(R=(E,z)=>{if(r.has(E.id))return null;const _=wu(E,n,i),L=o.has(E.id);return t.jsxs("g",{className:`notebook-subject-overlay${L?" selected":""}`,onClick:B=>{u||(B.stopPropagation(),f(E.id))},onKeyDown:B=>{u||B.key!=="Enter"&&B.key!==" "||(B.preventDefault(),f(E.id))},role:"button",tabIndex:u?-1:0,"aria-label":`${L?"Deselect":"Select"} ${E.label}`,"aria-pressed":L,children:[t.jsx("title",{children:E.label}),E.layerUrl?t.jsx("rect",{width:n,height:i,fill:E.color,fillOpacity:L?Math.min(.9,b+.18):b,mask:`url(#notebook-subject-mask-${z})`,pointerEvents:"none"}):_?t.jsx("rect",{..._,fill:E.color,fillOpacity:L?Math.min(.72,b+.14):b,pointerEvents:"none"}):null,_&&t.jsx("rect",{..._,className:"notebook-subject-outline",fill:"none",stroke:L?"#ffffff":E.color,strokeWidth:Math.max(2,n/480),strokeDasharray:L?`${n/100} ${n/180}`:void 0,vectorEffect:"non-scaling-stroke"}),_&&t.jsx("rect",{..._,className:"notebook-subject-hit",fill:"transparent",pointerEvents:u?"none":"all"})]},E.id)},e[30]=u,e[31]=i,e[32]=r,e[33]=f,e[34]=b,e[35]=o,e[36]=n,e[37]=R):R=e[37],A=w.map(R),e[21]=u,e[22]=i,e[23]=r,e[24]=f,e[25]=b,e[26]=o,e[27]=w,e[28]=n,e[29]=A}else A=e[29];let I;if(e[38]!==u||e[39]!==i||e[40]!==h||e[41]!==g||e[42]!==c||e[43]!==d||e[44]!==m||e[45]!==n){let R;e[47]!==u||e[48]!==i||e[49]!==h||e[50]!==g||e[51]!==d||e[52]!==m||e[53]!==n?(R=(E,z)=>{const _=Nu(E,n,i),L=d.has(E.id);return t.jsxs("g",{className:`notebook-subject-overlay notebook-region-overlay${L?" selected":""}`,onClick:B=>{u||(B.stopPropagation(),g(E.id))},onPointerEnter:()=>h(E.id),onPointerLeave:()=>h(null),role:"button",tabIndex:u?-1:0,"aria-label":`${L?"Deselect":"Select"} region ${z+1}`,"aria-pressed":L,children:[t.jsx("title",{children:E.matchedSubjectId?`Region ${z+1} snapped to subject`:`Drawn region ${z+1}`}),t.jsx("rect",{..._,fill:ws,fillOpacity:L?.28:.16,pointerEvents:"none"}),t.jsx("rect",{..._,className:"notebook-subject-outline",fill:"none",stroke:L?"#ffffff":ws,strokeWidth:Math.max(2,n/480),strokeDasharray:`${n/90} ${n/160}`,vectorEffect:"non-scaling-stroke"}),t.jsx("rect",{..._,className:"notebook-subject-hit",fill:"transparent",pointerEvents:u?"none":"all"}),m===E.id&&t.jsx("title",{children:"Snap to nearby subject available"})]},E.id)},e[47]=u,e[48]=i,e[49]=h,e[50]=g,e[51]=d,e[52]=m,e[53]=n,e[54]=R):R=e[54],I=c.map(R),e[38]=u,e[39]=i,e[40]=h,e[41]=g,e[42]=c,e[43]=d,e[44]=m,e[45]=n,e[46]=I}else I=e[46];let D;e[55]!==p||e[56]!==i||e[57]!==n?(D=p&&t.jsx("rect",{x:p.x*n,y:p.y*i,width:p.width*n,height:p.height*i,className:"notebook-region-draft",fill:ws,fillOpacity:.18,stroke:ws,strokeWidth:Math.max(2,n/480),strokeDasharray:`${n/80} ${n/140}`,pointerEvents:"none"}),e[55]=p,e[56]=i,e[57]=n,e[58]=D):D=e[58];let F;return e[59]!==v||e[60]!==y||e[61]!==x||e[62]!==j||e[63]!==D||e[64]!==S||e[65]!==M||e[66]!==N||e[67]!==$||e[68]!==T||e[69]!==A||e[70]!==I?(F=t.jsxs("svg",{className:S,viewBox:M,preserveAspectRatio:"xMidYMid meet",role:"group","aria-label":"Image with detected subject overlays",onPointerDown:y,onPointerMove:x,onPointerUp:j,onPointerCancel:v,onLostPointerCapture:v,children:[N,$,T,A,I,D]}),e[59]=v,e[60]=y,e[61]=x,e[62]=j,e[63]=D,e[64]=S,e[65]=M,e[66]=N,e[67]=$,e[68]=T,e[69]=A,e[70]=I,e[71]=F):F=e[71],F}function $u(l){const e=X.c(20),{mediaUrl:s,subjectMap:n,selectedIds:i}=l,a=n.width??0,o=n.height??0;if(!n.baseUrl||a<=0||o<=0){let m;return e[0]!==s?(m=t.jsx("img",{src:s,alt:""}),e[0]=s,e[1]=m):m=e[1],m}const r=`0 0 ${a} ${o}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("title",{children:"Removal preview"}),e[2]=c):c=e[2];let d;e[3]!==o||e[4]!==n.baseUrl||e[5]!==a?(d=t.jsx("image",{href:n.baseUrl,width:a,height:o,preserveAspectRatio:"xMidYMid meet"}),e[3]=o,e[4]=n.baseUrl,e[5]=a,e[6]=d):d=e[6];let u;if(e[7]!==o||e[8]!==i||e[9]!==n.subjects||e[10]!==a){let m;e[12]!==o||e[13]!==i||e[14]!==a?(m=b=>!i.has(b.id)&&b.layerUrl?t.jsx("image",{href:b.layerUrl,width:a,height:o,preserveAspectRatio:"none"},b.id):null,e[12]=o,e[13]=i,e[14]=a,e[15]=m):m=e[15],u=n.subjects.map(m),e[7]=o,e[8]=i,e[9]=n.subjects,e[10]=a,e[11]=u}else u=e[11];let p;return e[16]!==r||e[17]!==d||e[18]!==u?(p=t.jsxs("svg",{className:"notebook-subject-stage-svg",viewBox:r,preserveAspectRatio:"xMidYMid meet",role:"img","aria-label":"Preview with selected subjects removed",children:[c,d,u]}),e[16]=r,e[17]=d,e[18]=u,e[19]=p):p=e[19],p}function Iu(l){const e=X.c(41),{analysisUnavailableReason:s,checkingCache:n,analyzing:i,analysisFailed:a,ready:o,hasTargets:r,subjectCount:c,regionCount:d,error:u,onAnalyze:p}=l;if(s){let m,b;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ns,{size:18}),b=t.jsx("strong",{children:"Subject tools unavailable"}),e[0]=m,e[1]=b):(m=e[0],b=e[1]);let f;return e[2]!==s?(f=t.jsxs("div",{className:"notebook-subject-state unavailable",children:[m,b,t.jsx("p",{children:s})]}),e[2]=s,e[3]=f):f=e[3],f}if(n&&!r){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"notebook-subject-state loading",children:[t.jsx(ut,{size:18}),t.jsx("strong",{children:"Loading cached subjects"}),t.jsx("p",{children:"This does not start a new cloud analysis."})]}),e[4]=m):m=e[4],m}if(i){const m=`notebook-subject-state loading${r?" compact":""}`,b=r?14:18;let f;e[5]!==b?(f=t.jsx(ut,{size:b}),e[5]=b,e[6]=f):f=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("strong",{children:"Finding people and objects"}),e[7]=g):g=e[7];const h=r?"Analysis continues in the background.":"Analysis continues in the background. You can draw a region meanwhile.";let y;e[8]!==h?(y=t.jsx("p",{children:h}),e[8]=h,e[9]=y):y=e[9];let x;return e[10]!==m||e[11]!==f||e[12]!==y?(x=t.jsxs("div",{className:m,children:[f,g,y]}),e[10]=m,e[11]=f,e[12]=y,e[13]=x):x=e[13],x}if(a){const m=`notebook-subject-state error${r?" compact":""}`,b=r?14:18;let f;e[14]!==b?(f=t.jsx(yn,{size:b}),e[14]=b,e[15]=f):f=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("strong",{children:"Analysis did not finish"}),e[16]=g):g=e[16];const h=u??"The image could not be decomposed.";let y;e[17]!==h?(y=t.jsx("p",{children:h}),e[17]=h,e[18]=y):y=e[18];let x;e[19]!==r?(x=!r&&t.jsx("p",{children:"You can still draw a region to edit, replace, or remove."}),e[19]=r,e[20]=x):x=e[20];let j;e[21]!==p?(j=()=>p(),e[21]=p,e[22]=j):j=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(yn,{size:13}),e[23]=v):v=e[23];let k;e[24]!==j?(k=t.jsxs("button",{type:"button",onClick:j,children:[v,"Retry"]}),e[24]=j,e[25]=k):k=e[25];let w;return e[26]!==m||e[27]!==k||e[28]!==f||e[29]!==y||e[30]!==x?(w=t.jsxs("div",{className:m,children:[f,g,y,x,k]}),e[26]=m,e[27]=k,e[28]=f,e[29]=y,e[30]=x,e[31]=w):w=e[31],w}if(o&&c===0&&d===0){let m,b,f;e[32]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ns,{size:18}),b=t.jsx("strong",{children:"No editable subjects found"}),f=t.jsx("p",{children:"Draw a region or try analysis again if the image changed."}),e[32]=m,e[33]=b,e[34]=f):(m=e[32],b=e[33],f=e[34]);let g;e[35]!==p?(g=()=>p(!0),e[35]=p,e[36]=g):g=e[36];let h;e[37]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(yn,{size:13}),e[37]=h):h=e[37];let y;return e[38]!==g?(y=t.jsxs("div",{className:"notebook-subject-state empty",children:[m,b,f,t.jsxs("button",{type:"button",onClick:g,children:[h,"Analyze again"]})]}),e[38]=g,e[39]=y):y=e[39],y}if(!o&&!n&&!r){let m;return e[40]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"notebook-subject-state idle",children:[t.jsx(Ns,{size:18}),t.jsx("strong",{children:"Pick what to change"}),t.jsx("p",{children:"Find subjects detects people and objects you can select. Draw region marks any area by hand."})]}),e[40]=m):m=e[40],m}return null}function Ru(l){const e=X.c(8),{targets:s,candidates:n,replacements:i,onPick:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{children:"Replacement images"}),e[0]=o):o=e[0];let r;e[1]!==n||e[2]!==a||e[3]!==i||e[4]!==s?(r=n.length===0?t.jsx("p",{className:"notebook-replacement-empty",children:"Place another image on the grid, then pick it here or mention it as @address in the instructions."}):s.map(d=>t.jsxs("div",{className:"notebook-replacement-row",children:[t.jsx("strong",{children:d.label}),i[d.key]&&t.jsxs("button",{type:"button",onClick:()=>a(d.key,""),children:["Clear replacement for ",d.label]}),t.jsx("div",{className:"notebook-replacement-picker",role:"listbox","aria-label":`Replacement for ${d.label}`,children:n.map(u=>{const p=i[d.key]===u.artifactId;return t.jsxs("button",{type:"button",role:"option","aria-selected":p,className:`notebook-replacement-option${p?" selected":""}`,onClick:()=>a(d.key,u.artifactId),children:[u.thumbnailUrl?t.jsx("img",{src:u.thumbnailUrl,alt:""}):null,"@",u.address]},u.artifactId)})})]},d.key)),e[1]=n,e[2]=a,e[3]=i,e[4]=s,e[5]=r):r=e[5];let c;return e[6]!==r?(c=t.jsxs("div",{className:"notebook-replacement-list",children:[o,r]}),e[6]=r,e[7]=c):c=e[7],c}function ff({address:l,mediaUrl:e,width:s,height:n,details:i,subjectMap:a,subjectMapLoading:o,analysisUnavailableReason:r,initialRegions:c,instruction:d,onInstructionChange:u,replacementCandidates:p,closeRef:m,imageEditModels:b,imageEditModelsLoading:f,defaultImageEditModelId:g,onEstimateImageEditCost:h,onAnalyzeSubjects:y,onEditingChange:x,onEditSubjects:j,onSubmitInstruction:v,onBack:k,onClose:w}){const S=C.useId(),M=C.useId(),N=C.useId(),$=C.useRef(!1),P=C.useRef(null),[T,A]=C.useState(()=>new Set),[I,D]=C.useState(()=>new Set),[F,R]=C.useState(()=>[...c??[]]),[E,z]=C.useState(()=>new Set(c?.map(ne=>ne.id))),[_,L]=C.useState(!1),[B,U]=C.useState(null),[q,H]=C.useState(null),[K,se]=C.useState({}),[ie,V]=C.useState(!1),[ce,W]=C.useState(!1),[te,ae]=C.useState(.42),[Y,Q]=C.useState(null),[Z,re]=C.useState(null),[ee,J]=C.useState(null),[de,fe]=C.useState(null),ue=a?.status==="ready",pe=C.useMemo(()=>a?.subjects??[],[a]),me=C.useMemo(()=>pe.filter(ne=>T.has(ne.id)),[T,pe]),he=C.useMemo(()=>F.filter(ne=>E.has(ne.id)),[F,E]),ye=C.useMemo(()=>Ar(he,me,F),[F,he,me]),oe=Dr(ye,K),G=Fr(d).length>0||ye.some(ne=>!!K[ne.key]),le=G?"replace":"edit",be=ee??g??b?.[0]?.id??null,je=ne=>ne.capabilities[G?"regionReplace":"semantic"],we=ne=>{h&&h(ne,le).then(xe=>{$.current&&fe(xe)}).catch(()=>{$.current&&fe(null)})},$e=F.find(ne=>ne.id===q)??null,Ie=$e?_r($e.box,pe):null,Ae=o&&a?.status!=="analyzing"&&Y!=="analyze",Fe=a?.status==="analyzing"||Y==="analyze",et=a?.status==="failed",Ye=!!(r||!y||Y&&Y!=="analyze"||Ae||Fe),Ke=F.length>0||ue&&pe.length>0,Ve=Lr(me,ye,G),lt=!G&&ye.length===0,Ee=d.trim(),We=!!v&&Y===null&&(Ee.length>0?Ve!==null||lt:oe),Xe=G?"Replace with image":"Apply edit";C.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const Je=async(ne,xe)=>{if(!Y){Q(ne),re(null),ne!=="analyze"&&x?.(!0);try{const Me=await xe();$.current&&Me&&re({tone:"success",text:Me})}catch(Me){$.current&&re({tone:"error",text:Su(Me)})}finally{$.current&&(Q(null),ne!=="analyze"&&x?.(!1))}}},tt=(ne=!1)=>{if(ue&&!ne){W(!1),V(xe=>!xe);return}y&&Je("analyze",async()=>(await y(ne),null))},Re=()=>{!j||ye.length===0||Je("remove",async()=>await j({operation:"remove",subjectIds:me.map(xe=>xe.id),...he.length>0?{editRegions:he.map(xe=>xe.box),...be?{model:be}:{}}:{}})?"Removal queued as a new image.":null)},De=()=>{if(!v||!We)return;const ne={...Ur(me.map(xe=>xe.id),he,Object.fromEntries(ye.flatMap(xe=>K[xe.key]?[[xe.key,K[xe.key]]]:[]))),...be?{model:be}:{}};Je("apply",async()=>{const xe=await v(Ee,ne);if(!xe.ok)throw new Error(xe.message);return xe.message})},qe=ne=>{ne.key!=="Enter"||!(ne.metaKey||ne.ctrlKey)||(ne.preventDefault(),De())},_e=()=>{P.current=null,U(null)},ke=()=>{_e(),L(ne=>!ne),W(!1),V(!1)},Qe=ne=>{R(xe=>xe.filter(Me=>Me.id!==ne)),z(xe=>{const Me=new Set(xe);return Me.delete(ne),Me}),se(xe=>{const Me={...xe};return delete Me[ne],Me})},nt=()=>{$e&&R(ne=>ne.map(xe=>xe.id===$e.id?Or(xe,pe):xe))},Tt=ne=>{!_||ne.button!==0||(ne.preventDefault(),ne.currentTarget.setPointerCapture(ne.pointerId),P.current=wn(ne,s,n),U(null))},wt=ne=>{!_||!P.current||U(jl(P.current,wn(ne,s,n)))},Et=ne=>{if(!_||!P.current)return;const xe=jl(P.current,wn(ne,s,n));if(_e(),!xe)return;const Me={id:Br(F),box:xe};R(Ge=>[...Ge,Me]),z(Ge=>new Set([...Ge,Me.id])),V(!1),W(!1)},Ze=Ae?"Loading…":Fe?"Analyzing…":ue?ie?"Show subjects":"Hide subjects":"Find subjects";return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"image-editor-header",children:[t.jsx("button",{type:"button",className:"image-editor-icon-button","aria-label":"Back to fullscreen view",title:"Back to fullscreen view (Esc)",onClick:k,children:t.jsx(en,{size:18})}),i,t.jsx("button",{ref:m,type:"button",className:"image-editor-icon-button notebook-media-fullscreen-close","aria-label":"Close fullscreen preview","data-composer-focus":"return",onClick:w,children:t.jsx(mt,{size:18})})]}),t.jsxs("nav",{className:"image-editor-tools","aria-label":"Selection tools",children:[t.jsxs("button",{type:"button",className:ue&&!ie?"active":"","aria-pressed":ue?!ie:void 0,disabled:Ye,title:Ze,onClick:()=>tt(),children:[Ae||Fe?t.jsx(ut,{size:18}):ue&&!ie?t.jsx(Il,{size:18}):t.jsx(Ns,{size:18}),t.jsx("span",{children:Ze})]}),t.jsxs("button",{type:"button",className:_?"active":"","aria-pressed":_,disabled:Y!==null,title:"Draw region",onClick:ke,children:[t.jsx(ec,{size:18}),t.jsx("span",{children:"Draw region"})]}),ue&&a?.baseUrl&&t.jsxs("button",{type:"button",className:ce?"active":"","aria-pressed":ce,disabled:me.length===0||he.length>0||Y!==null,title:"Preview removal",onClick:()=>{W(ne=>!ne),V(!1),L(!1)},children:[t.jsx(Rl,{size:18}),t.jsx("span",{children:ce?"Show overlays":"Preview removal"})]})]}),t.jsxs("div",{className:"notebook-subject-stage",children:[ue&&a&&ce?t.jsx($u,{mediaUrl:e,subjectMap:a,selectedIds:T}):t.jsx(Cu,{mediaUrl:e,width:s,height:n,subjectMap:ie?null:a,selectedIds:T,hiddenIds:I,regions:ie?[]:F,selectedRegionIds:E,drawMode:_,draftBox:B,snapRegionId:Ie?q:null,opacity:te,onToggle:ne=>A(xe=>ks(xe,ne)),onToggleRegion:ne=>z(xe=>ks(xe,ne)),onHoverRegion:H,onPointerDown:Tt,onPointerMove:wt,onPointerUp:Et,onCancelDraw:_e}),_&&t.jsx("p",{className:"image-editor-stage-hint","aria-live":"polite",children:"Drag on the image to draw a region"}),Ie&&$e&&!_&&t.jsxs("button",{type:"button",className:"notebook-region-snap",onClick:nt,children:["Snap to ",pe.find(ne=>ne.id===Ie.subjectId)?.label??"subject"]})]}),t.jsxs("aside",{className:"notebook-subject-panel","aria-label":"Subject editor",children:[t.jsxs("form",{className:"image-editor-instructions","aria-label":`Edit instructions for @${l}`,onSubmit:ne=>{ne.preventDefault(),De()},children:[t.jsxs("div",{className:"image-editor-target",children:[t.jsx("span",{children:"Applies to"}),t.jsx("strong",{className:Ve?"":"empty",children:Ve??"Whole image"})]}),t.jsx("label",{htmlFor:S,children:"What should change?"}),t.jsx("textarea",{id:S,value:d,rows:5,"aria-describedby":M,placeholder:zr(me,ye,G),disabled:!v,autoFocus:!0,onChange:ne=>u(ne.target.value),onKeyDown:qe}),t.jsxs("p",{id:M,className:"image-editor-hint",children:["The result lands in a new cell next to @",l,"."]}),(b?.length??0)>0&&t.jsxs("div",{className:"image-editor-model",children:[t.jsx("label",{htmlFor:N,children:"Model"}),t.jsx("select",{id:N,value:be??"",disabled:f,onChange:ne=>{J(ne.target.value),fe(null),we(ne.target.value)},onFocus:()=>{be&&de===null&&we(be)},children:(b??[]).map(ne=>t.jsxs("option",{value:ne.id,disabled:!je(ne),children:[ne.label,je(ne)?"":" — cannot edit this target"]},ne.id))}),t.jsx("p",{className:"image-editor-cost",role:"status",children:f?"Loading models…":de===null?"Cost estimate unavailable":`Estimated provider cost ${de}`})]}),Z&&t.jsx("p",{className:`image-editor-status ${Z.tone}`,role:"status",children:Z.text}),t.jsxs("div",{className:"image-editor-submit",children:[t.jsxs("button",{type:"submit",className:"apply",disabled:!We,children:[Y==="apply"?t.jsx(ut,{size:14}):t.jsx(Si,{size:14}),Xe,t.jsx("kbd",{"aria-hidden":"true",children:"⌘↵"})]}),t.jsxs("button",{type:"button",className:"remove",disabled:ye.length===0||Y!==null||!j,onClick:Re,children:[Y==="remove"?t.jsx(ut,{size:14}):t.jsx(Rl,{size:14}),"Remove"]})]})]}),t.jsxs("div",{className:"notebook-subject-panel-body","aria-live":"polite",children:[t.jsx(Iu,{analysisUnavailableReason:r,checkingCache:Ae,analyzing:Fe,analysisFailed:et&&!Fe,ready:ue,hasTargets:Ke,subjectCount:pe.length,regionCount:F.length,error:a?.error??null,onAnalyze:tt}),Ke&&t.jsxs("div",{className:"notebook-subject-list",children:[t.jsxs("div",{className:"notebook-subject-list-actions",children:[t.jsxs("span",{children:[me.length+E.size," selected"]}),ue&&pe.length>0&&t.jsxs("label",{className:"notebook-subject-opacity",children:[t.jsx("span",{children:"Overlay"}),t.jsx("input",{type:"range",min:"0.15",max:"0.8",step:"0.05",value:te,onChange:ne=>ae(Number(ne.target.value))})]}),ue&&pe.length>0&&t.jsx("button",{type:"button",onClick:()=>A(new Set(me.length===pe.length?[]:pe.map(ne=>ne.id))),children:me.length===pe.length?"Clear":"Select all"})]}),F.map((ne,xe)=>{const Me=E.has(ne.id),Ge=pe.find(at=>at.id===ne.matchedSubjectId);return t.jsxs("div",{className:`notebook-subject-row${Me?" selected":""}`,children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:Me,"aria-label":`Select region ${xe+1}`,onChange:()=>z(at=>ks(at,ne.id))}),t.jsx("span",{className:"notebook-subject-swatch",style:{backgroundColor:ws},"aria-hidden":"true"}),t.jsxs("span",{className:"notebook-subject-copy",children:[t.jsx("strong",{children:Ge?`Region · ${Ge.label}`:`Region ${xe+1}`}),t.jsxs("small",{children:[ne.box.width.toFixed(2)," × ",ne.box.height.toFixed(2)]})]})]}),t.jsx("button",{type:"button",className:"notebook-subject-visibility","aria-label":`Remove region ${xe+1}`,onClick:()=>Qe(ne.id),children:t.jsx(mt,{size:14})})]},ne.id)}),ue&&pe.map(ne=>{const xe=T.has(ne.id),Me=I.has(ne.id);return t.jsxs("div",{className:`notebook-subject-row${xe?" selected":""}`,children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:xe,onChange:()=>A(Ge=>ks(Ge,ne.id))}),t.jsx("span",{className:"notebook-subject-swatch",style:{backgroundColor:ne.color},"aria-hidden":"true"}),t.jsxs("span",{className:"notebook-subject-copy",children:[t.jsx("strong",{children:ne.label}),t.jsx("small",{children:ne.description??(ne.exactEdit?"Exact mask available":"Editable layer")})]})]}),t.jsx("button",{type:"button",className:"notebook-subject-visibility","aria-label":`${Me?"Show":"Hide"} ${ne.label} overlay`,"aria-pressed":!Me,onClick:()=>D(Ge=>ks(Ge,ne.id)),children:Me?t.jsx(Il,{size:14}):t.jsx(Ii,{size:14})})]},ne.id)}),ye.length>0&&t.jsx(Ru,{targets:ye,candidates:p,replacements:K,onPick:(ne,xe)=>se(Me=>({...Me,[ne]:xe}))})]})]})]})]})}const Mu={"arrange-column":Ri,"arrange-row":$i,duplicate:Zs,download:tn,"extract-frame":sc,"generate-image":Zt,"generate-video":Rs,generations:Un,"group-images":Hn,inspect:tc,library:Vn,media:Pi,run:Ps,source:Ms,split:Kn,upload:sn,more:qn};function Ul(l){return[...l.querySelectorAll('[role="menuitem"]')].filter(e=>!e.disabled)}function pf(l){const e=X.c(47),{actions:s,address:n,cellType:i,deleteDisabled:a,menuId:o,menuLabel:r,position:c,returnFocus:d,onAction:u,onClose:p,onDelete:m}=l,b=a===void 0?!1:a,f=C.useRef(null);let g,h;e[0]!==c.x||e[1]!==c.y?(g=()=>{const E=f.current;if(!E)return;const z=()=>{const L=Math.max(8,Math.min(c.x,window.innerWidth-E.offsetWidth-8-1)),B=Math.max(8,Math.min(c.y,window.innerHeight-E.offsetHeight-8-1));E.style.left=`${L}px`,E.style.top=`${B}px`};z();const _=new ResizeObserver(z);return _.observe(E),Ul(E)[0]?.focus({preventScroll:!0}),()=>_.disconnect()},h=[c.x,c.y],e[0]=c.x,e[1]=c.y,e[2]=g,e[3]=h):(g=e[2],h=e[3]),C.useLayoutEffect(g,h);let y,x;e[4]!==p?(y=()=>{const E=_=>{const L=_.target;!(L instanceof Node)||f.current?.contains(L)||p()},z=()=>p();return document.addEventListener("pointerdown",E,!0),window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{document.removeEventListener("pointerdown",E,!0),window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},x=[p],e[4]=p,e[5]=y,e[6]=x):(y=e[5],x=e[6]),C.useEffect(y,x);let j;e[7]!==p||e[8]!==d?(j=()=>{p(),d?.isConnected&&d.focus({preventScroll:!0})},e[7]=p,e[8]=d,e[9]=j):j=e[9];const v=j;let k;e[10]!==u||e[11]!==p?(k=E=>{p(),u(E)},e[10]=u,e[11]=p,e[12]=k):k=e[12];const w=k;let S;e[13]!==b||e[14]!==p||e[15]!==m||e[16]!==v?(S=E=>{const z=f.current;if(!z)return;if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),v();return}if(E.key==="Tab"){p();return}if(m&&!b&&(E.key==="Delete"||E.key==="Backspace")){E.preventDefault(),E.stopPropagation(),p(),m();return}if(E.key!=="ArrowDown"&&E.key!=="ArrowUp"&&E.key!=="Home"&&E.key!=="End")return;E.preventDefault(),E.stopPropagation();const _=Ul(z);if(_.length===0)return;const L=_.findIndex(Tu),B=E.key==="Home"?0:E.key==="End"?_.length-1:E.key==="ArrowDown"?(L+1+_.length)%_.length:(L-1+_.length)%_.length;_[B]?.focus()},e[13]=b,e[14]=p,e[15]=m,e[16]=v,e[17]=S):S=e[17];const M=S,N=r??`Cell actions for ${n}`;let $;e[18]!==c.x||e[19]!==c.y?($={left:c.x,top:c.y},e[18]=c.x,e[19]=c.y,e[20]=$):$=e[20];let P;e[21]!==n?(P=t.jsx("strong",{children:n}),e[21]=n,e[22]=P):P=e[22];let T;e[23]!==i?(T=t.jsx("span",{children:i}),e[23]=i,e[24]=T):T=e[24];let A;e[25]!==P||e[26]!==T?(A=t.jsxs("div",{className:"cell-context-menu-heading","aria-hidden":"true",children:[P,T]}),e[25]=P,e[26]=T,e[27]=A):A=e[27];let I;if(e[28]!==s||e[29]!==w){let E;e[31]!==w?(E=z=>{const _=Mu[z.icon];return t.jsxs("button",{type:"button",role:"menuitem","data-cell-action":z.id,"data-workspace-action-surface":z.id==="more"?"cell-menu":void 0,disabled:z.disabled,onClick:()=>w(z.id),children:[t.jsx(_,{size:15,"aria-hidden":"true"}),t.jsx("span",{children:z.label})]},z.id)},e[31]=w,e[32]=E):E=e[32],I=s.map(E),e[28]=s,e[29]=w,e[30]=I}else I=e[30];let D;e[33]!==I?(D=t.jsx("div",{className:"cell-context-menu-actions",role:"presentation",children:I}),e[33]=I,e[34]=D):D=e[34];let F;e[35]!==b||e[36]!==p||e[37]!==m?(F=m&&t.jsx("div",{className:"cell-context-menu-danger",role:"presentation",children:t.jsxs("button",{type:"button",role:"menuitem","data-cell-action":"delete","aria-keyshortcuts":"Delete Backspace",disabled:b,onClick:()=>{p(),m()},children:[t.jsx(os,{size:15,"aria-hidden":"true"}),t.jsx("span",{children:"Delete cell"}),t.jsx("kbd",{children:"⌫"})]})}),e[35]=b,e[36]=p,e[37]=m,e[38]=F):F=e[38];let R;if(e[39]!==M||e[40]!==o||e[41]!==$||e[42]!==A||e[43]!==D||e[44]!==F||e[45]!==N){const E=t.jsxs("div",{ref:f,id:o,className:"cell-context-menu","data-composer-focus":"return",role:"menu","aria-label":N,style:$,onContextMenu:Pu,onKeyDown:M,children:[A,D,F]});R=typeof document>"u"?E:gs.createPortal(E,document.body),e[39]=M,e[40]=o,e[41]=$,e[42]=A,e[43]=D,e[44]=F,e[45]=N,e[46]=R}else R=e[46];return R}function Pu(l){return l.preventDefault()}function Tu(l){return l===document.activeElement}function hf(l){const e=X.c(91),{activeBook:s,books:n,disabled:i,error:a,loading:o,open:r,onCreate:c,onDelete:d,onOpenChange:u,onRefresh:p,onRename:m,onSelect:b}=l,f=C.useRef(null),g=C.useRef(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={kind:"idle"},e[0]=h):h=e[0];const[y,x]=C.useState(h),[j,v]=C.useState(""),[k,w]=C.useState(""),[S,M]=C.useState(null),[N,$]=C.useState(null),P=y.kind==="rename"?y.bookId:null,T=y.kind==="create",A=y.kind==="delete"?y.bookId:null;let I;e[1]===Symbol.for("react.memo_cache_sentinel")?(I=G=>{G!==void 0&&G&&g.current?.focus(),x({kind:"idle"}),v(""),w(""),$(null)},e[1]=I):I=e[1];const D=I;let F;e[2]!==y||e[3]!==u||e[4]!==S?(F=G=>{const le=G===void 0?!1:G;fs(y,{kind:"close"},S!==null).closeMenu&&(D(le),u(!1))},e[2]=y,e[3]=u,e[4]=S,e[5]=F):F=e[5];const R=F;let E,z;e[6]!==R||e[7]!==y||e[8]!==u||e[9]!==r||e[10]!==S?(E=()=>{if(!r)return;const G=be=>{f.current?.contains(be.target)||R()},le=be=>{if(be.key!=="Escape")return;const je=fs(y,{kind:"escape"},S!==null);if(je.closeMenu){be.preventDefault(),D(!0),u(!1);return}je.mode!==y&&(be.preventDefault(),D(!0))};return document.addEventListener("pointerdown",G),document.addEventListener("focusin",G),document.addEventListener("keydown",le),()=>{document.removeEventListener("pointerdown",G),document.removeEventListener("focusin",G),document.removeEventListener("keydown",le)}},z=[R,y,u,r,S,D],e[6]=R,e[7]=y,e[8]=u,e[9]=r,e[10]=S,e[11]=E,e[12]=z):(E=e[11],z=e[12]),C.useEffect(E,z);let _;e[13]!==y||e[14]!==S?(_=()=>{const G=fs(y,{kind:"begin-create"},S!==null);G.mode!==y&&(x(G.mode),v(""),$(null))},e[13]=y,e[14]=S,e[15]=_):_=e[15];const L=_;let B;e[16]!==y||e[17]!==S?(B=G=>{const le=fs(y,{kind:"begin-rename",bookId:G.bookId},S!==null);le.mode!==y&&(x(le.mode),w(""),$(null),v(G.name))},e[16]=y,e[17]=S,e[18]=B):B=e[18];const U=B;let q;e[19]!==n||e[20]!==y||e[21]!==S?(q=G=>{if(n.length<2)return;const le=fs(y,{kind:"begin-delete",bookId:G},S!==null);le.mode!==y&&(x(le.mode),v(""),w(""),$(null))},e[19]=n,e[20]=y,e[21]=S,e[22]=q):q=e[22];const H=q;let K;e[23]!==y||e[24]!==S?(K=()=>{fs(y,{kind:"cancel"},S!==null).mode!==y&&D(!0)},e[23]=y,e[24]=S,e[25]=K):K=e[25];const se=K;let ie;e[26]!==s?.bookId||e[27]!==R||e[28]!==i||e[29]!==b||e[30]!==S?(ie=async G=>{if(i||S||G===s?.bookId){G===s?.bookId&&R(!0);return}$(null),M({kind:"select",bookId:G});const le=await b(G);if(M(null),!le.ok){$(le.error);return}R(!0)},e[26]=s?.bookId,e[27]=R,e[28]=i,e[29]=b,e[30]=S,e[31]=ie):ie=e[31];const V=ie;let ce;e[32]!==n||e[33]!==se||e[34]!==j||e[35]!==P||e[36]!==m||e[37]!==S?(ce=async G=>{if(G?.preventDefault(),!P||S)return;const le=ms(j),be=n.find(we=>we.bookId===P);if(!le){$(cl);return}if(le===be?.name){se();return}$(null),M({kind:"rename",bookId:P});const je=await m(P,le);if(M(null),!je.ok){$(je.error);return}se()},e[32]=n,e[33]=se,e[34]=j,e[35]=P,e[36]=m,e[37]=S,e[38]=ce):ce=e[38];const W=ce;let te;e[39]!==k||e[40]!==c||e[41]!==u||e[42]!==S?(te=async G=>{if(G?.preventDefault(),S)return;const le=ms(k);if(!le){$(cl);return}$(null),M({kind:"create"});const be=await c(le);if(M(null),!be.ok){$(be.error);return}D(!0),u(!1)},e[39]=k,e[40]=c,e[41]=u,e[42]=S,e[43]=te):te=e[43];const ae=te;let Y;e[44]!==n||e[45]!==d||e[46]!==S?(Y=async G=>{if(S||n.length<2)return;$(null),M({kind:"delete",bookId:G.bookId});const le=await d(G.bookId,G.name);if(M(null),!le.ok){$(le.error);return}D(!0)},e[44]=n,e[45]=d,e[46]=S,e[47]=Y):Y=e[47];const Q=Y;let Z;e[48]!==R||e[49]!==u||e[50]!==r?(Z=()=>{if(r){R();return}u(!0)},e[48]=R,e[49]=u,e[50]=r,e[51]=Z):Z=e[51];const re=Z;let ee;e[52]!==s?(ee=s?xn(s.artifactCount):"No active project",e[52]=s,e[53]=ee):ee=e[53];const J=ee,de=i||S!==null,fe=s?.name??"select-project";let ue;e[54]!==fe?(ue=t.jsx("strong",{children:fe}),e[54]=fe,e[55]=ue):ue=e[55];let pe;e[56]!==J||e[57]!==s?(pe=s&&t.jsx("span",{className:"book-project-active-count",title:J,children:s.artifactCount}),e[56]=J,e[57]=s,e[58]=pe):pe=e[58];let me;e[59]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsx(Is,{size:14}),e[59]=me):me=e[59];let he;e[60]!==r||e[61]!==ue||e[62]!==pe||e[63]!==re?(he=t.jsxs("button",{ref:g,type:"button",className:"brand-project-menu-toggle","aria-controls":"book-project-menu","aria-expanded":r,"aria-haspopup":"menu",onClick:re,children:[ue,pe,me]}),e[60]=r,e[61]=ue,e[62]=pe,e[63]=re,e[64]=he):he=e[64];let ye;e[65]!==s?.bookId||e[66]!==L||e[67]!==H||e[68]!==U||e[69]!==n||e[70]!==se||e[71]!==Q||e[72]!==k||e[73]!==T||e[74]!==A||e[75]!==j||e[76]!==P||e[77]!==a||e[78]!==o||e[79]!==de||e[80]!==p||e[81]!==r||e[82]!==N||e[83]!==S||e[84]!==V||e[85]!==ae||e[86]!==W?(ye=r&&t.jsxs("div",{id:"book-project-menu",className:"book-project-menu",role:"menu","aria-label":"Videobook projects",children:[t.jsxs("header",{className:"book-project-menu-header",children:[t.jsxs("div",{children:[t.jsx("span",{children:"Projects"}),o&&t.jsx(ut,{size:13})]}),t.jsxs("small",{children:[n.length," total"]})]}),a&&t.jsxs("div",{className:"book-project-menu-message error",role:"alert",children:[t.jsx("span",{children:a}),t.jsx("button",{type:"button",disabled:o,onClick:p,children:"Retry"})]}),N&&!P&&!T&&!A&&t.jsx("div",{className:"book-project-menu-message error",role:"alert",children:t.jsx("span",{children:N})}),t.jsxs("div",{className:"book-project-menu-list",children:[o&&n.length===0&&t.jsxs("div",{className:"book-project-menu-empty",children:[t.jsx(ut,{size:15}),t.jsx("span",{children:"Loading projects"})]}),!o&&n.length===0&&t.jsx("div",{className:"book-project-menu-empty",children:"No projects available"}),n.map(G=>{const le=G.bookId===s?.bookId,be=G.bookId===P,je=G.bookId===A,we=S&&"bookId"in S?S.bookId===G.bookId:!1,$e=n.length>1;return be?t.jsxs("form",{className:"book-project-form",onSubmit:W,children:[t.jsx("input",{autoFocus:!0,"aria-label":`New name for ${G.name}`,autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,disabled:S!==null,value:j,onChange:Ie=>v(Ie.target.value)}),t.jsxs("div",{className:"book-project-form-actions",children:[t.jsx("button",{type:"submit",disabled:S!==null,title:"Save project name","aria-label":"Save project name",children:S?.kind==="rename"?t.jsx(ut,{size:14}):t.jsx(Qt,{size:14})}),t.jsx("button",{type:"button",disabled:S!==null,title:"Cancel rename","aria-label":"Cancel rename",onClick:se,children:t.jsx(mt,{size:14})})]}),j&&ms(j)!==j&&t.jsxs("small",{className:"book-project-form-hint",children:["Slug: ",ms(j)||"Enter letters or numbers"]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]},G.bookId):je?t.jsxs("div",{className:"book-project-delete",role:"group","aria-label":`Delete ${G.name}`,children:[t.jsx(os,{size:15}),t.jsxs("div",{children:[t.jsxs("strong",{children:["Delete ",G.name,"?"]}),t.jsxs("small",{children:[xn(G.artifactCount)," and"," ",vl(G.notebookCount)," will be removed"]})]}),t.jsxs("div",{className:"book-project-form-actions",children:[t.jsx("button",{type:"button",disabled:S!==null,title:`Confirm deletion of ${G.name}`,"aria-label":`Confirm deletion of ${G.name}`,onClick:()=>{Q(G)},children:S?.kind==="delete"?t.jsx(ut,{size:14}):t.jsx(Qt,{size:14})}),t.jsx("button",{type:"button",disabled:S!==null,title:"Cancel deletion","aria-label":"Cancel deletion",onClick:se,children:t.jsx(mt,{size:14})})]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]},G.bookId):t.jsxs("div",{className:`book-project-row ${le?"active":""}`,"aria-busy":we,children:[t.jsxs("button",{type:"button",className:"book-project-select",role:"menuitem","aria-current":le?"true":void 0,disabled:de,onClick:()=>{V(G.bookId)},children:[t.jsx("span",{className:"book-project-marker"}),t.jsxs("span",{className:"book-project-copy",children:[t.jsx("strong",{children:G.name}),t.jsx("small",{children:vl(G.notebookCount)})]}),t.jsx("span",{className:`book-project-artifact-count ${G.artifactCount===0?"empty":""}`,title:xn(G.artifactCount),children:we?t.jsx(ut,{size:12}):G.artifactCount})]}),t.jsxs("div",{className:"book-project-actions",children:[t.jsx("button",{type:"button",disabled:de,title:`Rename ${G.name}`,"aria-label":`Rename ${G.name}`,onClick:()=>U(G),children:t.jsx(nc,{size:13})}),t.jsx("button",{type:"button",disabled:de||!$e,title:$e?`Delete ${G.name}`:"Create another project before deleting this one","aria-label":`Delete ${G.name}`,onClick:()=>H(G.bookId),children:t.jsx(os,{size:13})})]})]},G.bookId)})]}),t.jsx("footer",{className:"book-project-menu-footer",children:T?t.jsxs("form",{className:"book-project-form",onSubmit:ae,children:[t.jsx("input",{autoFocus:!0,"aria-label":"New project slug",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,disabled:S!==null,placeholder:"my-project",value:k,onChange:G=>w(G.target.value)}),t.jsxs("div",{className:"book-project-form-actions",children:[t.jsx("button",{type:"submit",disabled:S!==null,title:"Create project","aria-label":"Create project",children:S?.kind==="create"?t.jsx(ut,{size:14}):t.jsx(Qt,{size:14})}),t.jsx("button",{type:"button",disabled:S!==null,title:"Cancel new project","aria-label":"Cancel new project",onClick:se,children:t.jsx(mt,{size:14})})]}),k&&ms(k)!==k&&t.jsxs("small",{className:"book-project-form-hint",children:["Slug: ",ms(k)||"Enter letters or numbers"]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]}):t.jsxs("button",{type:"button",className:"book-project-create",disabled:de,onClick:L,children:[t.jsx(es,{size:14}),t.jsx("span",{children:"New project"})]})})]}),e[65]=s?.bookId,e[66]=L,e[67]=H,e[68]=U,e[69]=n,e[70]=se,e[71]=Q,e[72]=k,e[73]=T,e[74]=A,e[75]=j,e[76]=P,e[77]=a,e[78]=o,e[79]=de,e[80]=p,e[81]=r,e[82]=N,e[83]=S,e[84]=V,e[85]=ae,e[86]=W,e[87]=ye):ye=e[87];let oe;return e[88]!==he||e[89]!==ye?(oe=t.jsxs("div",{className:"book-project-selector","data-composer-focus":"return",ref:f,children:[he,ye]}),e[88]=he,e[89]=ye,e[90]=oe):oe=e[90],oe}function Eu(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:{}}function Fn(l){const e=Object.values(l.properties??{}).find(s=>"const"in s);return l.title??(e?$s(String(e.const)):$s(String(l.type??"value")))}function Hl({id:l,value:e,disabled:s,onChange:n}){const[i,a]=C.useState(()=>JSON.stringify(e??{},null,2));return t.jsx("textarea",{id:l,value:i,disabled:s,rows:5,spellCheck:!1,onChange:o=>{const r=o.target.value;a(r);try{n(r.trim()?JSON.parse(r):void 0),o.target.setCustomValidity("")}catch{o.target.setCustomValidity("Enter valid JSON for these additional options.")}}})}function _n(l){const e=X.c(15),{name:s,schema:n,value:i,required:a,disabled:o,choices:r,choiceName:c,onChange:d}=l,u=a===void 0?!1:a,p=o===void 0?!1:o,m=C.useId(),b=Kr(n),[f,g]=C.useState(null),h=f===null?Vr(n,i):{...n,...b[f]},y=n.title??$s(s),x=r[c??s];let j;e[0]!==x?(j=x?[...new Set(x.map(_u))]:[],e[0]=x,e[1]=j):j=e[1];const v=j,k=h.type==="object"||h.type==="array",w=b.findIndex(I=>Fn(I)===Fn(h)),S=h.enum??(h.type==="boolean"?[!0,!1]:void 0),M=Eu(i),N=Array.isArray(i)?i:[];if("const"in h){const I=String(h.const);let D;return e[2]!==I?(D=t.jsx("strong",{children:I}),e[2]=I,e[3]=D):D=e[3],t.jsxs("div",{className:"workspace-action-fixed",children:[t.jsx("span",{children:y}),D]})}const $=()=>{if(S)return t.jsxs("select",{id:m,required:u,disabled:p,value:i===void 0?"":String(S.indexOf(i)),onChange:R=>d(R.target.value===""?void 0:S[Number(R.target.value)]),children:[t.jsx("option",{value:"",children:u?`Choose ${y.toLowerCase()}`:"Use default"}),S.map(Fu)]});if(x)return t.jsxs("select",{id:m,required:u,disabled:p,value:typeof i=="string"?i:"",onChange:R=>d(R.target.value||void 0),children:[t.jsx("option",{value:"",children:x.length?`Choose ${y.toLowerCase()}`:`No ${y.toLowerCase()} available`}),v.map(R=>{const E=x.filter(z=>(z.group??"")===R).map(Du);return R?t.jsx("optgroup",{label:R,children:E},R):E})]});if(!h.type)return t.jsx(Hl,{id:m,value:i,disabled:p,onChange:d});if(h.type==="null")return t.jsx("output",{id:m,children:"No value"});const I=h.type==="number"||h.type==="integer",D=h.format==="password"||/secret|password|api_key|access_token/u.test(s);return!I&&/prompt|text|description|markdown|content|script/u.test(s)?t.jsx("textarea",{id:m,value:typeof i=="string"?i:"",disabled:p,required:u,minLength:h.minLength,maxLength:h.maxLength,rows:4,onChange:R=>d(R.target.value)}):t.jsx("input",{id:m,type:I?"number":D?"password":"text",value:typeof i=="string"||typeof i=="number"?i:"",required:u,disabled:p,autoComplete:"off",step:h.type==="integer"?1:"any",min:h.minimum??(h.type==="integer"&&h.exclusiveMinimum!==void 0?h.exclusiveMinimum+1:void 0),max:h.maximum??(h.type==="integer"&&h.exclusiveMaximum!==void 0?h.exclusiveMaximum-1:void 0),minLength:h.minLength,maxLength:h.maxLength,onChange:R=>d(I?R.target.value===""?void 0:Number(R.target.value):R.target.value)})};let P;e[4]!==u?(P=u&&t.jsx("span",{"aria-hidden":"true",children:" *"}),e[4]=u,e[5]=P):P=e[5];let T;e[6]!==n.description?(T=n.description&&t.jsx("p",{className:"workspace-action-hint",children:n.description}),e[6]=n.description,e[7]=T):T=e[7];let A;return e[8]!==p||e[9]!==y||e[10]!==d||e[11]!==u||e[12]!==k||e[13]!==i?(A=k&&!u&&i!==void 0&&t.jsxs("button",{type:"button",disabled:p,onClick:()=>d(void 0),children:["Use default ",y.toLowerCase()]}),e[8]=p,e[9]=y,e[10]=d,e[11]=u,e[12]=k,e[13]=i,e[14]=A):A=e[14],t.jsxs("div",{className:`workspace-action-field${k?" workspace-action-structure":""}`,children:[t.jsxs("label",{htmlFor:m,children:[y,P]}),T,b.length>1&&t.jsx("select",{"aria-label":`${y} format`,disabled:p,value:Math.max(0,w),onChange:I=>{const D=Number(I.target.value);g(D),d(gn(b[D],!0))},children:b.map(Au)}),k&&!u&&i===void 0?t.jsxs("button",{type:"button",disabled:p,onClick:()=>d(gn(h,!0)),children:["Add ",y.toLowerCase()]}):h.type==="object"?Object.keys(h.properties??{}).length?t.jsx("fieldset",{id:m,disabled:p,"aria-label":y,children:Object.entries(h.properties??{}).map(I=>{const[D,F]=I;return t.jsx(_n,{name:D,schema:F,value:M[D],choices:r,required:h.required?.includes(D),disabled:p,onChange:R=>d({...M,[D]:R})},D)})}):t.jsx(Hl,{id:m,value:i,disabled:p,onChange:d}):h.type==="array"?t.jsxs("fieldset",{id:m,disabled:p,"aria-label":y,children:[N.map((I,D)=>t.jsxs("div",{className:"workspace-action-array-row",children:[t.jsx(_n,{name:`${s} ${D+1}`,schema:h.items??{},value:I,required:!0,choices:r,choiceName:c??s,disabled:p,onChange:F=>d(N.map((R,E)=>E===D?F:R))}),t.jsx("button",{type:"button",disabled:p||N.length<=(h.minItems??0),"aria-label":`Remove ${y.toLowerCase()} ${D+1}`,onClick:()=>d(N.filter((F,R)=>R!==D)),children:"Remove"})]},D)),t.jsx("button",{type:"button",disabled:p||h.maxItems!==void 0&&N.length>=h.maxItems,onClick:()=>d([...N,gn(h.items??{},!0)]),children:"Add item"})]}):$(),A]})}function Au(l,e){return t.jsx("option",{value:e,children:Fn(l)},e)}function Du(l){return t.jsxs("option",{value:l.value,disabled:l.available===!1,children:[l.label,l.detail?` · ${l.detail}`:""]},l.value)}function Fu(l,e){return t.jsx("option",{value:e,children:typeof l=="boolean"?l?"Yes":"No":String(l)},e)}function _u(l){return l.group??""}function Kl(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:null}function Xs(l,e){const s=Array.isArray(l)?l:Kl(l)?.[e];return Array.isArray(s)?s.flatMap(n=>{const i=Kl(n);return i?[i]:[]}):[]}function Lu(l){const e=X.c(32),{action:s,value:n,values:i,onOpen:a}=l;if(s.handler.kind!=="tool")return null;const o=s.handler.tool;if(o==="list_entities"){let r;if(e[0]!==a||e[1]!==n){let d;e[3]!==a?(d=u=>t.jsxs("li",{children:[t.jsx("strong",{children:String(u.name)}),t.jsx("span",{children:String(u.prompt??u.description??"")}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>a("tool.update_entity",{entity_id:u.id}),children:"Edit"}),t.jsx("button",{type:"button",onClick:()=>a("tool.delete_entity",{entity_id:u.id}),children:"Delete saved item"})]})]},String(u.id)),e[3]=a,e[4]=d):d=e[4],r=Xs(n,"entities").map(d),e[0]=a,e[1]=n,e[2]=r}else r=e[2];let c;return e[5]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[5]=r,e[6]=c):c=e[6],c}if(o==="list_notebooks"){let r;if(e[7]!==a||e[8]!==n){let d;e[10]!==a?(d=u=>t.jsxs("li",{children:[t.jsx("strong",{children:String(u.name)}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>a("tool.get_notebook",{notebook_id:u.id}),children:"Open notebook"}),t.jsx("button",{type:"button",onClick:()=>a("tool.rename_notebook",{notebook_id:u.id,name:u.name}),children:"Rename"}),t.jsx("button",{type:"button",onClick:()=>a("tool.delete_notebook",{notebook_id:u.id}),children:"Delete notebook"})]})]},String(u.id)),e[10]=a,e[11]=d):d=e[11],r=Xs(n,"notebooks").map(d),e[7]=a,e[8]=n,e[9]=r}else r=e[9];let c;return e[12]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[12]=r,e[13]=c):c=e[13],c}if(o==="asset_history"||o==="list_book_actions"){let r;if(e[14]!==a||e[15]!==o||e[16]!==n||e[17]!==i){let d;e[19]!==a||e[20]!==o||e[21]!==i?(d=(u,p)=>{const m=u.hash??u.revision;return t.jsxs("li",{children:[t.jsx("strong",{children:String(u.message??u.operation??"Revision")}),t.jsx("span",{children:String(u.date??u.createdAt??"")}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>a(o==="asset_history"?"tool.read_file_at_commit":"tool.get_history_action",{...i,commit_hash:m,action_id:u.actionId??u.id??m}),children:"Preview revision"}),t.jsx("button",{type:"button",onClick:()=>a(o==="asset_history"?"tool.restore_asset_version":"tool.restore_edit_action",{...i,commit_hash:m,target_revision:m}),children:"Restore revision"})]})]},String(m??p))},e[19]=a,e[20]=o,e[21]=i,e[22]=d):d=e[22],r=Xs(n,o==="asset_history"?"commits":"actions").map(d),e[14]=a,e[15]=o,e[16]=n,e[17]=i,e[18]=r}else r=e[18];let c;return e[23]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[23]=r,e[24]=c):c=e[24],c}if(o==="search_archive"){let r;if(e[25]!==a||e[26]!==n){let d;e[28]!==a?(d=u=>t.jsxs("li",{children:[t.jsx("strong",{children:String(u.title??u.archive_id)}),t.jsx("span",{children:String(u.transcript_excerpt??"")}),t.jsxs("div",{children:[typeof u.media_url=="string"&&t.jsx("a",{href:u.media_url,target:"_blank",rel:"noreferrer",children:"Preview media"}),t.jsx("button",{type:"button",onClick:()=>a("tool.restore_archive_clips",{archive_ids:[u.archive_id]}),children:"Restore to project"})]})]},String(u.archive_id)),e[28]=a,e[29]=d):d=e[29],r=Xs(n,"results").map(d),e[25]=a,e[26]=n,e[27]=r}else r=e[27];let c;return e[30]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[30]=r,e[31]=c):c=e[31],c}return null}function zu(l){const e=X.c(61),{media:s,values:n,disabled:i,onChange:a}=l,o=C.useRef(null),r=s.width&&s.height?s.width/s.height:1.7777777777777777,c=typeof n.x=="number"?n.x:0,d=typeof n.y=="number"?n.y:0,u=typeof n.w=="number"?n.w:1,p=typeof n.h=="number"?n.h:1;let m;e[0]!==r?(m={aspectRatio:r},e[0]=r,e[1]=m):m=e[1];const b=m,f=`${c*100}%`,g=`${d*100}%`,h=`${u*100}%`,y=`${p*100}%`;let x;e[2]!==f||e[3]!==g||e[4]!==h||e[5]!==y?(x={left:f,top:g,width:h,height:y},e[2]=f,e[3]=g,e[4]=h,e[5]=y,e[6]=x):x=e[6];const j=x;let v;e[7]!==i||e[8]!==s.height||e[9]!==s.width||e[10]!==a?(v=H=>{i||a(mi(H,s.width,s.height))},e[7]=i,e[8]=s.height,e[9]=s.width,e[10]=a,e[11]=v):v=e[11];const k=v;if(!s.url){let H;return e[12]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx("p",{children:"Preview unavailable for this media."}),e[12]=H):H=e[12],H}const w=n.ratio==="16:9";let S;e[13]!==k?(S=()=>k("16:9"),e[13]=k,e[14]=S):S=e[14];let M;e[15]!==i||e[16]!==w||e[17]!==S?(M=t.jsx("button",{type:"button",disabled:i,"aria-pressed":w,onClick:S,children:"Landscape 16:9"}),e[15]=i,e[16]=w,e[17]=S,e[18]=M):M=e[18];const N=n.ratio==="9:16";let $;e[19]!==k?($=()=>k("9:16"),e[19]=k,e[20]=$):$=e[20];let P;e[21]!==i||e[22]!==N||e[23]!==$?(P=t.jsx("button",{type:"button",disabled:i,"aria-pressed":N,onClick:$,children:"Portrait 9:16"}),e[21]=i,e[22]=N,e[23]=$,e[24]=P):P=e[24];const T=n.ratio==="1:1";let A;e[25]!==k?(A=()=>k("1:1"),e[25]=k,e[26]=A):A=e[26];let I;e[27]!==i||e[28]!==T||e[29]!==A?(I=t.jsx("button",{type:"button",disabled:i,"aria-pressed":T,onClick:A,children:"Square 1:1"}),e[27]=i,e[28]=T,e[29]=A,e[30]=I):I=e[30];let D;e[31]!==M||e[32]!==P||e[33]!==I?(D=t.jsxs("div",{className:"workspace-crop-ratios",role:"group","aria-label":"Crop aspect ratio",children:[M,P,I]}),e[31]=M,e[32]=P,e[33]=I,e[34]=D):D=e[34];let F;e[35]!==i||e[36]!==c||e[37]!==d?(F=H=>{i||H.button!==0||(H.preventDefault(),H.currentTarget.setPointerCapture(H.pointerId),o.current={pointerId:H.pointerId,x:H.clientX,y:H.clientY,originX:c,originY:d})},e[35]=i,e[36]=c,e[37]=d,e[38]=F):F=e[38];let R;e[39]!==i||e[40]!==p||e[41]!==a||e[42]!==u?(R=H=>{const K=o.current;if(i||!K||H.pointerId!==K.pointerId)return;const se=H.currentTarget.getBoundingClientRect();a({x:Math.max(0,Math.min(1-u,K.originX+(H.clientX-K.x)/se.width)),y:Math.max(0,Math.min(1-p,K.originY+(H.clientY-K.y)/se.height))})},e[39]=i,e[40]=p,e[41]=a,e[42]=u,e[43]=R):R=e[43];let E,z;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{o.current=null},z=()=>{o.current=null},e[44]=E,e[45]=z):(E=e[44],z=e[45]);let _;e[46]!==s.type||e[47]!==s.url?(_=s.type==="image"?t.jsx("img",{src:s.url,alt:"Source crop preview",draggable:!1}):t.jsx("video",{src:s.url,muted:!0,playsInline:!0,preload:"metadata"}),e[46]=s.type,e[47]=s.url,e[48]=_):_=e[48];let L;e[49]!==j?(L=t.jsx("div",{className:"workspace-crop-region",style:j}),e[49]=j,e[50]=L):L=e[50];let B;e[51]!==b||e[52]!==F||e[53]!==R||e[54]!==_||e[55]!==L?(B=t.jsxs("div",{className:"workspace-crop-frame",style:b,onPointerDown:F,onPointerMove:R,onPointerUp:E,onPointerCancel:z,children:[_,L]}),e[51]=b,e[52]=F,e[53]=R,e[54]=_,e[55]=L,e[56]=B):B=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{children:"Choose an aspect ratio, then drag the crop to position it. The numeric fields below also control its position and size."}),e[57]=U):U=e[57];let q;return e[58]!==D||e[59]!==B?(q=t.jsxs("section",{className:"workspace-crop-preview","aria-label":"Crop preview",children:[D,B,U]}),e[58]=D,e[59]=B,e[60]=q):q=e[60],q}function Yn(l){const e=X.c(12),{value:s,name:n}=l,i=n===void 0?"Result":n;if(s==null)return null;if(Array.isArray(s)){let r;if(e[0]!==i||e[1]!==s){let d;e[3]!==i?(d=(u,p)=>t.jsx("li",{children:t.jsx(Yn,{value:u,name:`${i} ${p+1}`})},p),e[3]=i,e[4]=d):d=e[4],r=s.map(d),e[0]=i,e[1]=s,e[2]=r}else r=e[2];let c;return e[5]!==i||e[6]!==r?(c=t.jsx("ol",{className:"workspace-action-result-list","aria-label":i,children:r}),e[5]=i,e[6]=r,e[7]=c):c=e[7],c}if(typeof s=="object"){let r;return e[8]!==s?(r=t.jsx("dl",{className:"workspace-action-result-fields",children:Object.entries(s).map(Bu)}),e[8]=s,e[9]=r):r=e[9],r}const a=typeof s=="boolean"?s?"Yes":"No":String(s);let o;return e[10]!==a?(o=t.jsx("span",{children:a}),e[10]=a,e[11]=o):o=e[11],o}function Bu(l){const[e,s]=l;return t.jsxs("div",{children:[t.jsx("dt",{children:$s(e)}),t.jsx("dd",{children:t.jsx(Yn,{value:s,name:$s(e)})})]},e)}function Ou({action:l,context:e,initialValues:s,initialResult:n,variants:i,onExecute:a,onReview:o,onBack:r,onOpenAction:c}){const[d,u]=C.useState(()=>({...qr(l,{...e,assetId:typeof s?.asset_id=="string"?s.asset_id:e.assetId,cellId:typeof s?.cell_id=="string"?s.cell_id:e.cellId,assetIds:Array.isArray(s?.artifact_ids)?s.artifact_ids.filter(E=>typeof E=="string"):e.assetIds,cellIds:Array.isArray(s?.cell_ids)?s.cell_ids.filter(E=>typeof E=="string"):e.cellIds}),...Object.fromEntries(Object.entries(s??{}).filter(([E])=>E in(l.inputSchema.properties??{})&&(E!=="_provider"||!l.generation)))})),p=l.generation&&typeof d.model=="string"?pi(d.model,d):void 0,m=Wr(String(d.model??""),d.mode),b=m?{...d,options:{...d.options&&typeof d.options=="object"?d.options:{},aspect_ratio:"adaptive",duration:-1}}:p?{...d,options:{...d.options&&typeof d.options=="object"?d.options:{},aspect_ratio:p}}:d,[f,g]=C.useState(!1),[h,y]=C.useState(null),[x,j]=C.useState(null),[v,k]=C.useState(n??null),w=new Set(l.inputSchema.required??[]),S=new Set(["book_id","actor","source_surface"]);l.generation&&S.add("_provider");const M=Object.entries(l.inputSchema.properties??{}).filter(([R])=>!S.has(R)),N=l.handler.kind==="tool"&&l.handler.tool==="update_entity",$=b.entity&&typeof b.entity=="object"&&"id"in b.entity?String(b.entity.id):"",P=ii(l,e),T=["commit_hash","filename","subject_id","subject_ids"].some(R=>R in(l.inputSchema.properties??{})),A=l.handler.kind==="tool"&&l.handler.tool==="crop_asset"&&typeof b.asset_id=="string"?e.media?.[b.asset_id]:void 0,I=l.target.argument&&l.target.mediaKinds?{...e.choices,[l.target.argument]:(e.choices[l.target.argument]??e.choices.asset_id??[]).filter(R=>l.target.mediaKinds?.some(E=>E===R.detail))}:e.choices,D=l.generation&&I.model?{...I,model:Xr(I.model,l.generation.mediaType,b)}:I,F=async()=>{if(!(f||P)){g(!0),y(null);try{l.confirmation!=="none"&&!x?j(await o(l,b)):(k(await a(l,b)),j(null))}catch(R){y(R instanceof Error?R.message:String(R))}finally{g(!1)}}};return t.jsxs("form",{className:"workspace-action-form","data-action-id":l.id,onSubmit:R=>{R.preventDefault(),F()},children:[t.jsxs("button",{type:"button",className:"workspace-actions-back",disabled:f,onClick:r,children:[t.jsx(lc,{size:15}),"All actions"]}),t.jsxs("div",{className:"workspace-action-heading",children:[t.jsx("h3",{children:l.title}),t.jsx("code",{children:l.command})]}),t.jsx("p",{children:l.description}),i.length>1&&t.jsxs("details",{className:"workspace-action-variants",children:[t.jsx("summary",{children:"Advanced provider and model"}),t.jsxs("label",{children:["Provider and model",t.jsx("select",{"aria-label":"Provider and model",value:l.id,disabled:f,onChange:R=>c(R.target.value,b),children:i.map(R=>t.jsxs("option",{value:R.id,children:[R.generation?.provider," · ",R.title]},R.id))})]})]}),t.jsxs("div",{className:"workspace-action-fields",children:[A&&t.jsx(zu,{media:A,values:b,disabled:f,onChange:R=>{u(E=>({...E,...R})),j(null),k(null)}}),N&&t.jsxs("label",{className:"workspace-action-field",children:["Saved item",t.jsxs("select",{"aria-label":"Saved item",required:!0,value:$,disabled:f,onChange:R=>{u(E=>({...E,entity:structuredClone(e.entities?.[R.target.value])})),k(null),j(null)},children:[t.jsx("option",{value:"",children:"Choose a saved item"}),(e.choices.entity_id??[]).map(R=>t.jsx("option",{value:R.value,children:R.label},R.value))]})]}),M.map(([R,E])=>t.jsx(_n,{name:R,schema:N&&R==="entity"?{type:"object",required:["name"],properties:{name:{type:"string",minLength:1},description:{type:"string"},prompt:{type:"string"},data:{type:"object",description:"Optional advanced saved-item data",additionalProperties:!0}}}:E,value:b[R],choices:D,required:w.has(R),disabled:f||R==="aspect_ratio"&&!!p,onChange:z=>{u(_=>({..._,[R]:z,...A&&R==="ratio"&&typeof z=="string"?mi(z,A.width,A.height):{},...R===l.target.argument&&typeof z=="string"&&l.inputSchema.properties?.object_hash?{object_hash:e.media?.[z]?.objectHash??""}:{}})),j(null),k(null)}},N&&R==="entity"?`${R}:${$}`:R))]}),m&&t.jsx("p",{role:"status",children:Gr}),p&&t.jsx("p",{role:"status",children:Yr}),T&&t.jsx("button",{type:"button",disabled:f,onClick:()=>c(l.id,b),children:"Refresh available choices"}),P&&t.jsx("p",{role:"status",children:P}),h&&t.jsx("p",{role:"alert",className:"workspace-action-error",children:h}),x&&t.jsxs("div",{className:"workspace-action-review",role:"status",children:[t.jsx("strong",{children:x.cost??"Review action"}),t.jsx("p",{children:x.message})]}),v&&t.jsxs("section",{className:"workspace-action-result","aria-label":"Action result",children:[t.jsx("p",{role:"status",children:v.message}),Jr(l)?t.jsx(Lu,{action:l,value:v.value,values:b,onOpen:c}):t.jsx(Yn,{value:v.value})]}),t.jsxs("footer",{children:[t.jsxs("button",{type:"submit",className:"workspace-action-submit",disabled:f||!!P,children:[f?t.jsx(ut,{size:15}):t.jsx(Ps,{size:15}),f?"Working…":x?"Confirm and run":l.confirmation!=="none"?"Review action":"Run action"]}),x&&t.jsx("button",{type:"button",onClick:()=>j(null),disabled:f,children:"Cancel review"})]})]})}function bf({actions:l,context:e,initialActionId:s,initialValues:n,initialResult:i,returnFocus:a,loading:o=!1,error:r,onClose:c,onBack:d,onOpenAction:u,onExecute:p,onReview:m}){const b=C.useRef(null),f=l.find(x=>x.id===s),g=f?.id,h=C.useMemo(()=>f?.generation?l.filter(x=>x.generation?.operation===f.generation?.operation&&x.generation?.mediaType===f.generation?.mediaType):[],[l,f]);C.useLayoutEffect(()=>{const x=b.current;if(x)return x.showModal(),()=>x.close()},[]),C.useLayoutEffect(()=>{o||b.current?.querySelector(".workspace-action-fields input, .workspace-action-fields textarea, .workspace-action-fields select")?.focus()},[g,o]);const y=()=>{const x=fi(a);c(),x()};return gs.createPortal(t.jsxs("dialog",{ref:b,className:"workspace-actions-dialog","aria-label":"Workspace actions",onKeyDown:x=>{x.key!=="Escape"||x.nativeEvent.isComposing||(x.preventDefault(),x.stopPropagation(),y())},onCancel:x=>{x.preventDefault(),y()},children:[t.jsxs("header",{children:[t.jsx("h2",{children:"Actions"}),t.jsx("button",{type:"button","aria-label":"Close actions",onClick:y,children:t.jsx(mt,{size:18})})]}),o&&t.jsx("p",{role:"status",children:"Loading action…"}),r&&t.jsx("p",{role:"alert",className:"workspace-action-error",children:r}),f&&!o&&t.jsx(Ou,{action:f,context:e,initialValues:n,initialResult:i,variants:h,onExecute:p,onReview:m,onBack:d,onOpenAction:u},f.id),!f&&!o&&t.jsxs("p",{role:"alert",children:["This action is no longer available. ",t.jsx("button",{type:"button",onClick:d,children:"All actions"})]})]}),document.body)}function qi(l){return l.frameRate.numerator/l.frameRate.denominator}function Jn(l,e){const s=e.source.range.startTick*e.source.range.timeBase.numerator/e.source.range.timeBase.denominator;return Math.max(0,Math.round(s*qi(l)))}function Wi(l,e){const s=(e.source.range.startTick+e.source.range.durationTicks)*e.source.range.timeBase.numerator/e.source.range.timeBase.denominator;return Math.max(Jn(l,e)+1,Math.ceil(s*qi(l)))}function Xi(l,e){return{incoming:e.find(s=>s.kind==="dissolve"&&s.incomingClipId===l.clipId),outgoing:e.find(s=>s.kind==="dissolve"&&s.outgoingClipId===l.clipId)}}function Uu(l){const e=X.c(40),{sequence:s,clip:n,src:i,defaultFit:a}=l,o=pc(),r=n.transform;let c,d;e[0]!==n||e[1]!==o||e[2]!==s.transitions?(d=Xi(n,s.transitions),c=d.incoming?Ml(o,[0,d.incoming.durationFrames],[0,1],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}):1,e[0]=n,e[1]=o,e[2]=s.transitions,e[3]=c,e[4]=d):(c=e[3],d=e[4]);const u=c;let p;e[5]!==n.durationFrames||e[6]!==o||e[7]!==d.outgoing?(p=d.outgoing?Ml(o,[Math.max(0,n.durationFrames-d.outgoing.durationFrames),n.durationFrames],[1,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}):1,e[5]=n.durationFrames,e[6]=o,e[7]=d.outgoing,e[8]=p):p=e[8];const m=p,b=(r?.fit??a)==="fit"?"contain":"cover",f=(r?.opacity??1)*u*m,g=`translate(${r?.positionX??0}px, ${r?.positionY??0}px)`,h=`scale(${r?.scaleX??1}, ${r?.scaleY??1})`,y=`rotate(${r?.rotationDegrees??0}deg)`;let x;e[9]!==g||e[10]!==h||e[11]!==y?(x=[g,h,y],e[9]=g,e[10]=h,e[11]=y,e[12]=x):x=e[12];const j=x.join(" "),v=`${(r?.anchorX??.5)*100}% ${(r?.anchorY??.5)*100}%`,k=r?`inset(${r.cropTop*100}% ${r.cropRight*100}% ${r.cropBottom*100}% ${r.cropLeft*100}%)`:void 0;let w;e[13]!==v||e[14]!==k||e[15]!==b||e[16]!==f||e[17]!==j?(w={width:"100%",height:"100%",objectFit:b,objectPosition:"center",opacity:f,transform:j,transformOrigin:v,clipPath:k},e[13]=v,e[14]=k,e[15]=b,e[16]=f,e[17]=j,e[18]=w):w=e[18];const S=w;if(n.source.kind==="still"){let I;return e[19]!==i||e[20]!==S?(I=t.jsx(hc,{src:i,style:S}),e[19]=i,e[20]=S,e[21]=I):I=e[21],I}const M=n;if(M.reverse){let I;e[22]!==S?(I={...S,display:"grid",placeItems:"center",background:"#07120c"},e[22]=S,e[23]=I):I=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("span",{style:{color:"#8fbaa0",fontFamily:"monospace",fontSize:24},children:"Reverse preview is available after render"}),e[24]=D):D=e[24];let F;return e[25]!==I?(F=t.jsx(Wn,{style:I,children:D}),e[25]=I,e[26]=F):F=e[26],F}let N;e[27]!==s||e[28]!==M?(N=Jn(s,M),e[27]=s,e[28]=M,e[29]=N):N=e[29];let $;e[30]!==s||e[31]!==M?($=Wi(s,M),e[30]=s,e[31]=M,e[32]=$):$=e[32];const P=M.speed.numerator/M.speed.denominator,T=M.audioPolicy==="mute";let A;return e[33]!==i||e[34]!==S||e[35]!==N||e[36]!==$||e[37]!==P||e[38]!==T?(A=t.jsx(bc,{src:i,startFrom:N,endAt:$,playbackRate:P,muted:T,style:S}),e[33]=i,e[34]=S,e[35]=N,e[36]=$,e[37]=P,e[38]=T,e[39]=A):A=e[39],A}function Hu(l){const e=X.c(24),{sequence:s,clip:n,src:i}=l,a=n.audio;let o;e[0]!==n||e[1]!==s.transitions?(o=Xi(n,s.transitions),e[0]=n,e[1]=s.transitions,e[2]=o):o=e[2];const r=o;let c;e[3]!==a?.fadeInFrames||e[4]!==a?.fadeOutFrames||e[5]!==a?.gainDb||e[6]!==a?.muted||e[7]!==n.durationFrames||e[8]!==r.incoming?.durationFrames||e[9]!==r.outgoing?.durationFrames?(c=g=>{if(a?.muted)return 0;const h=10**((a?.gainDb??0)/20),y=Math.max(1,a?.fadeInFrames??0,r.incoming?.durationFrames??0),x=Math.max(1,a?.fadeOutFrames??0,r.outgoing?.durationFrames??0);return y>0&&g<y?h*g/y:x>0&&g>n.durationFrames-x?h*Math.max(0,n.durationFrames-g)/x:h},e[3]=a?.fadeInFrames,e[4]=a?.fadeOutFrames,e[5]=a?.gainDb,e[6]=a?.muted,e[7]=n.durationFrames,e[8]=r.incoming?.durationFrames,e[9]=r.outgoing?.durationFrames,e[10]=c):c=e[10];const d=c;if(n.reverse)return null;let u;e[11]!==n||e[12]!==s?(u=Jn(s,n),e[11]=n,e[12]=s,e[13]=u):u=e[13];let p;e[14]!==n||e[15]!==s?(p=Wi(s,n),e[14]=n,e[15]=s,e[16]=p):p=e[16];const m=n.speed.numerator/n.speed.denominator,b=n.audioPolicy==="mute"||a?.muted;let f;return e[17]!==i||e[18]!==u||e[19]!==p||e[20]!==m||e[21]!==b||e[22]!==d?(f=t.jsx(xc,{src:i,startFrom:u,endAt:p,playbackRate:m,volume:d,muted:b}),e[17]=i,e[18]=u,e[19]=p,e[20]=m,e[21]=b,e[22]=d,e[23]=f):f=e[23],f}function Ku(l){const e=X.c(8),{text:s,styleId:n}=l;let i;e[0]!==n?(i=n==="bold"?{background:"#ffe500",color:"#090909",fontWeight:900}:n==="high-contrast"?{background:"#000",color:"#fff",fontWeight:800}:{background:"rgba(0, 0, 0, 0.78)",color:"#fff",fontWeight:700},e[0]=n,e[1]=i):i=e[1];const a=i;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={justifyContent:"flex-end",alignItems:"center",padding:"0 6% 7%"},e[2]=o):o=e[2];let r;e[3]!==a?(r={...a,maxWidth:"88%",padding:"0.3em 0.55em",fontFamily:"Inter, system-ui, sans-serif",fontSize:52,lineHeight:1.15,textAlign:"center"},e[3]=a,e[4]=r):r=e[4];let c;return e[5]!==r||e[6]!==s?(c=t.jsx(Wn,{style:o,children:t.jsx("span",{style:r,children:s})}),e[5]=r,e[6]=s,e[7]=c):c=e[7],c}function Vu(l){const e=X.c(21),{sequence:s,assets:n,defaultFit:i}=l,a=i===void 0?"fit":i;let o,r,c,d;if(e[0]!==n||e[1]!==a||e[2]!==s){const m=new Map(n.map(Gu)),b=new Map(s.tracks.map(Xu));let f;e[7]!==s.tracks?(f=s.tracks.some(Wu),e[7]=s.tracks,e[8]=f):f=e[8];const g=f,h=s.clips.filter(v=>{const k=b.get(v.trackId);return v.enabled&&k?.enabled&&k.kind==="video"}).sort((v,k)=>{const w=b.get(v.trackId),S=b.get(k.trackId);return(w?.ordinal??0)-(S?.ordinal??0)}),y=s.clips.flatMap(v=>{const k=b.get(v.trackId);return!v.enabled||v.source.kind!=="timed"||!k?.enabled||k.kind!=="audio"||k.muted||g&&!k.solo?[]:[v]});o=Wn;let x;e[9]!==s.backgroundRgba?(x=s.backgroundRgba.join(","),e[9]=s.backgroundRgba,e[10]=x):x=e[10];const j=`rgba(${x})`;e[11]!==j?(r={backgroundColor:j},e[11]=j,e[12]=r):r=e[12],c=h.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(Tn,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(Uu,{sequence:s,clip:v,src:k.mediaUrl,defaultFit:a})},v.clipId)}),d=y.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(Tn,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(Hu,{sequence:s,clip:v,src:k.mediaUrl})},`audio:${v.clipId}`)}),e[0]=n,e[1]=a,e[2]=s,e[3]=o,e[4]=r,e[5]=c,e[6]=d}else o=e[3],r=e[4],c=e[5],d=e[6];let u;e[13]!==s.captions?(u=s.captions.map(qu),e[13]=s.captions,e[14]=u):u=e[14];let p;return e[15]!==o||e[16]!==r||e[17]!==c||e[18]!==d||e[19]!==u?(p=t.jsxs(o,{style:r,children:[c,d,u]}),e[15]=o,e[16]=r,e[17]=c,e[18]=d,e[19]=u,e[20]=p):p=e[20],p}function qu(l){return t.jsx(Tn,{from:l.timelineStartFrame,durationInFrames:l.durationFrames,children:t.jsx(Ku,{text:l.text,styleId:l.styleId})},l.cueId)}function Wu(l){return l.kind==="audio"&&l.solo}function Xu(l){return[l.trackId,l]}function Gu(l){return[l.artifactId,l]}const Yu={width:"100%",maxHeight:520},Ju={width:"100%",height:"100%"},Qu=({playing:l,isBuffering:e})=>e?t.jsx(vi,{size:16,className:"timeline-preview-buffering"}):l?t.jsx(Ti,{size:16}):t.jsx(Ps,{size:16});function Zu(l){return Math.max(1,...l.clips.map(e=>e.timelineStartFrame+e.durationFrames),...l.captions.map(e=>e.timelineStartFrame+e.durationFrames))}function em(l){const e=l.key.toLowerCase();return e==="i"?"mark-in":e==="o"?"mark-out":e==="s"?"split":l.key==="Delete"||l.key==="Backspace"?"delete":(l.metaKey||l.ctrlKey)&&e==="z"?l.shiftKey?"redo":"undo":e==="f"?"search":e==="+"||e==="="?"zoom-in":e==="-"?"zoom-out":null}const tm=C.forwardRef(function(e,s){const n=X.c(51),{sequence:i,assets:a,onFrameUpdate:o,onKeyboardAction:r,editingEnabled:c,presentation:d,allowFullscreen:u,initialFrame:p}=e,m=c===void 0?!0:c,b=d===void 0?"default":d,f=u===void 0?!0:u,g=p===void 0?0:p,h=C.useRef(null),y=C.useRef(null),x=i.frameRate.numerator/i.frameRate.denominator,j=Zu(i);let v;n[0]!==g?(v=Math.round(g),n[0]=g,n[1]=v):v=n[1];const k=Math.max(0,Math.min(j-1,v)),w=C.useRef(k),[S,M]=C.useState(k),N=b==="preview";let $;n[2]!==a||n[3]!==i?($={sequence:i,assets:a,defaultFit:"fit"},n[2]=a,n[3]=i,n[4]=$):$=n[4];const P=$;let T;n[5]!==j||n[6]!==m||n[7]!==x||n[8]!==r?(T=Y=>{if(Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229)return;const Q=Y.target;if(["INPUT","TEXTAREA","SELECT"].includes(Q.tagName))return;const Z=h.current;if(!Z)return;const re=w.current,ee=Y.key.toLowerCase();if(ee===" "||ee==="k"){Y.preventDefault(),Z.isPlaying()?Z.pause():Z.play();return}if(ee==="j"||Y.key==="ArrowLeft"){Y.preventDefault(),Z.seekTo(Math.max(0,re-(ee==="j"?Math.round(x):1)));return}if(ee==="l"||Y.key==="ArrowRight"){Y.preventDefault(),Z.seekTo(Math.min(j-1,re+(ee==="l"?Math.round(x):1)));return}if(!m)return;const J=em(Y);J&&(Y.preventDefault(),r(J,re))},n[5]=j,n[6]=m,n[7]=x,n[8]=r,n[9]=T):T=n[9];const A=T;let I,D;n[10]!==j||n[11]!==A||n[12]!==o?(I=()=>({pause:()=>h.current?.pause(),togglePlay:()=>{const Y=h.current;Y&&(Y.isPlaying()?Y.pause():Y.play())},seekTo:Y=>{const Q=Math.max(0,Math.min(j-1,Math.round(Y)));w.current=Q,M(Q),o(Q),h.current?.seekTo(Q)},focus:()=>y.current?.focus(),handleKeyDown:A}),D=[j,A,o],n[10]=j,n[11]=A,n[12]=o,n[13]=I,n[14]=D):(I=n[13],D=n[14]),C.useImperativeHandle(s,I,D);let F,R;n[15]!==o?(F=()=>{const Y=h.current;if(!Y)return;const Q=Z=>{w.current=Z.detail.frame,M(Z.detail.frame),o(Z.detail.frame)};return Y.addEventListener("frameupdate",Q),()=>Y.removeEventListener("frameupdate",Q)},R=[o],n[15]=o,n[16]=F,n[17]=R):(F=n[16],R=n[17]),C.useEffect(F,R);const E=N?!1:void 0,z=N?"timeline-preview-screen":void 0,_=N?Ju:Yu,L=N?Qu:void 0;let B;n[18]!==f||n[19]!==j||n[20]!==k||n[21]!==x||n[22]!==P||n[23]!==N||n[24]!==i.height||n[25]!==i.width||n[26]!==E||n[27]!==z||n[28]!==_||n[29]!==L?(B=t.jsx(gc,{ref:h,component:Vu,inputProps:P,durationInFrames:j,fps:x,compositionWidth:i.width,compositionHeight:i.height,initialFrame:k,controls:!0,spaceKeyToPlayOrPause:E,allowFullscreen:f,alwaysShowControls:N,className:z,style:_,renderPlayPauseButton:L}),n[18]=f,n[19]=j,n[20]=k,n[21]=x,n[22]=P,n[23]=N,n[24]=i.height,n[25]=i.width,n[26]=E,n[27]=z,n[28]=_,n[29]=L,n[30]=B):B=n[30];const U=B,q=N?"canonical-player canonical-player-preview":"canonical-player";let H;n[31]!==N||n[32]!==U?(H=N?t.jsx("div",{className:"timeline-preview-stage",children:U}):U,n[31]=N,n[32]=U,n[33]=H):H=n[33];let K;n[34]!==S?(K=t.jsxs("span",{className:"canonical-player-frame",title:"Current frame",children:["F",S]}),n[34]=S,n[35]=K):K=n[35];const se=S/x;let ie;n[36]!==se?(ie=se.toFixed(2),n[36]=se,n[37]=ie):ie=n[37];let V;n[38]!==ie?(V=t.jsxs("span",{children:[ie,"s"]}),n[38]=ie,n[39]=V):V=n[39];const ce=m?"Space/K play · J/L shuttle · ←/→ frame · I/O marks · S split · Delete · ⌘Z/⇧⌘Z restore":"Space/K play · J/L shuttle · ←/→ frame";let W;n[40]!==ce?(W=t.jsx("span",{className:"canonical-player-shortcuts",children:ce}),n[40]=ce,n[41]=W):W=n[41];let te;n[42]!==K||n[43]!==V||n[44]!==W?(te=t.jsxs("footer",{children:[K,V,W]}),n[42]=K,n[43]=V,n[44]=W,n[45]=te):te=n[45];let ae;return n[46]!==A||n[47]!==q||n[48]!==H||n[49]!==te?(ae=t.jsxs("section",{className:q,ref:y,tabIndex:0,onKeyDown:A,"aria-label":"Canonical sequence player",children:[H,te]}),n[46]=A,n[47]=q,n[48]=H,n[49]=te,n[50]=ae):ae=n[50],ae});function xf(l){const e=X.c(64),{media:s,sequence:n,assets:i,opener:a,initialFrame:o,onActions:r,onClose:c,composerPortalRef:d,actionsOpen:u}=l,p=o===void 0?0:o,m=u===void 0?!1:u,b=C.useRef(null),f=C.useRef(null),[g,h]=C.useState(s?.initialFile??"");let y,x;if(e[0]!==g||e[1]!==s?.files||e[2]!==s?.type||e[3]!==s?.url){const K=s?.files.find(se=>se.name===g);x=K?.url??s?.url,y=K?/\.(?:mp4|webm|mov)$/iu.test(K.name)?"video":/\.(?:wav|mp3|m4a|weba|ogg)$/iu.test(K.name)?"audio":/\.(?:png|jpg|jpeg|webp|gif)$/iu.test(K.name)?"image":"file":s?.type,e[0]=g,e[1]=s?.files,e[2]=s?.type,e[3]=s?.url,e[4]=y,e[5]=x}else y=e[4],x=e[5];const j=y;let v;e[6]!==c||e[7]!==a?(v=()=>{const K=fi(a);c(),K()},e[6]=c,e[7]=a,e[8]=v):v=e[8];const k=v;let w,S;e[9]!==p?(w=()=>{const K=b.current;return K?.showModal(),f.current?.seekTo(p),()=>K?.close()},S=[p],e[9]=p,e[10]=w,e[11]=S):(w=e[10],S=e[11]),C.useLayoutEffect(w,S);const M=s?.label??"Sequence preview";let N;e[12]!==k?(N=K=>{K.preventDefault(),k()},e[12]=k,e[13]=N):N=e[13];const $=s?.label??"Sequence preview";let P;e[14]!==$?(P=t.jsx("h2",{children:$}),e[14]=$,e[15]=P):P=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(mt,{size:18}),e[16]=T):T=e[16];let A;e[17]!==k?(A=t.jsx("button",{type:"button","aria-label":"Close preview",onClick:k,children:T}),e[17]=k,e[18]=A):A=e[18];let I;e[19]!==P||e[20]!==A?(I=t.jsxs("header",{children:[P,A]}),e[19]=P,e[20]=A,e[21]=I):I=e[21];let D;e[22]!==g||e[23]!==s?(D=s&&t.jsxs("label",{children:["Version or file",t.jsxs("select",{value:g,onChange:K=>h(K.target.value),children:[t.jsx("option",{value:"",children:"Current media"}),s.files.map(lm)]})]}),e[22]=g,e[23]=s,e[24]=D):D=e[24];let F;e[25]!==i||e[26]!==n?(F=n&&t.jsx(tm,{ref:f,sequence:n,assets:i,editingEnabled:!1,onFrameUpdate:nm,onKeyboardAction:sm}),e[25]=i,e[26]=n,e[27]=F):F=e[27];let R;e[28]!==s||e[29]!==x?(R=s&&!x&&t.jsx("p",{role:"status",children:"This media has no playable file yet. Check its processing status in Jobs."}),e[28]=s,e[29]=x,e[30]=R):R=e[30];let E;e[31]!==s?.label||e[32]!==j||e[33]!==x?(E=x&&j==="image"&&t.jsx("img",{src:x,alt:s?.label??"Media preview"}),e[31]=s?.label,e[32]=j,e[33]=x,e[34]=E):E=e[34];let z;e[35]!==s?.thumbnailUrl||e[36]!==j||e[37]!==x?(z=x&&(j==="video"||j==="final")&&t.jsx("video",{src:x,poster:s?.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"metadata"}),e[35]=s?.thumbnailUrl,e[36]=j,e[37]=x,e[38]=z):z=e[38];let _;e[39]!==j||e[40]!==x?(_=x&&j==="audio"&&t.jsx("audio",{src:x,controls:!0,preload:"metadata"}),e[39]=j,e[40]=x,e[41]=_):_=e[41];let L;e[42]!==x?(L=x&&t.jsx("a",{href:x,target:"_blank",rel:"noreferrer",children:"Open current file"}),e[42]=x,e[43]=L):L=e[43];let B;e[44]!==r?(B=t.jsx("button",{type:"button",onClick:r,children:"More actions"}),e[44]=r,e[45]=B):B=e[45];let U;e[46]!==D||e[47]!==F||e[48]!==R||e[49]!==E||e[50]!==z||e[51]!==_||e[52]!==L||e[53]!==B?(U=t.jsxs("div",{className:"workspace-preview-content",children:[D,F,R,E,z,_,L,B]}),e[46]=D,e[47]=F,e[48]=R,e[49]=E,e[50]=z,e[51]=_,e[52]=L,e[53]=B,e[54]=U):U=e[54];let q;e[55]!==m||e[56]!==d?(q=m&&t.jsx("div",{className:"workspace-preview-composer-host",ref:d}),e[55]=m,e[56]=d,e[57]=q):q=e[57];let H;return e[58]!==I||e[59]!==U||e[60]!==q||e[61]!==M||e[62]!==N?(H=gs.createPortal(t.jsxs("dialog",{ref:b,className:"workspace-actions-dialog workspace-preview-dialog","aria-label":M,onCancel:N,children:[I,U,q]}),document.body),e[58]=I,e[59]=U,e[60]=q,e[61]=M,e[62]=N,e[63]=H):H=e[63],H}function sm(){}function nm(){}function lm(l){return t.jsx("option",{value:l.name,children:l.name},l.name)}const Jt={image:{row:0,column:0},video:{row:0,column:1},download:{row:0,column:2},library:{row:0,column:3}},im={image:{title:"Add a picture",hint:"png · jpg · webp · heic",label:"Image",icon:Zt},video:{title:"Add a video",hint:"mp4 · mov · webm",label:"Video",icon:Rs}};function Gs(l){const e=Ln(l);return{width:He.squareSize,height:He.squareSize,transform:`translate(${e.x}px, ${e.y}px)`}}const am={image:Gs(Jt.image),video:Gs(Jt.video),download:Gs(Jt.download),library:Gs(Jt.library)},Vl=Ln(Jt.library),rm={width:Vl.x+He.squareSize,height:Vl.y+He.squareSize};function Qn(l){const e=X.c(19),{kind:s,title:n,icon:i,children:a}=l,o=Jt[s];let r;e[0]!==o?(r=Wt(o),e[0]=o,e[1]=r):r=e[1];const c=r,d=`notebook-start-tile notebook-start-tile-${s}`,u=am[s],p=`${c} ${n}`;let m;e[2]!==c?(m=t.jsx("span",{children:c}),e[2]=c,e[3]=m):m=e[3];let b;e[4]!==i?(b=t.jsx(i,{"aria-hidden":"true"}),e[4]=i,e[5]=b):b=e[5];let f;e[6]!==m||e[7]!==b?(f=t.jsxs("div",{className:"notebook-start-tile-head",children:[m,b]}),e[6]=m,e[7]=b,e[8]=f):f=e[8];let g;e[9]!==n?(g=t.jsx("strong",{children:n}),e[9]=n,e[10]=g):g=e[10];let h;return e[11]!==c||e[12]!==a||e[13]!==d||e[14]!==u||e[15]!==p||e[16]!==f||e[17]!==g?(h=t.jsxs("section",{className:d,style:u,"aria-label":p,"data-start-address":c,children:[f,g,a]}),e[11]=c,e[12]=a,e[13]=d,e[14]=u,e[15]=p,e[16]=f,e[17]=g,e[18]=h):h=e[18],h}function ql(l){const e=X.c(35),{kind:s,busy:n,onUpload:i,onPick:a}=l,o=C.useRef(null),r=im[s],c=Jt[s];let d;e[0]!==i||e[1]!==c?(d=M=>{const N=M.target.files?.[0];M.target.value="",N&&i(c,N)},e[0]=i,e[1]=c,e[2]=d):d=e[2];const u=d;let p;e[3]!==r.hint?(p=t.jsx("span",{className:"notebook-start-tile-hint notebook-start-tile-hint-optional",children:r.hint}),e[3]=r.hint,e[4]=p):p=e[4];const m=`Upload ${s}`;let b,f;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=()=>o.current?.click(),f=t.jsx(es,{"aria-hidden":"true"}),e[5]=b,e[6]=f):(b=e[5],f=e[6]);let g;e[7]!==r.label?(g=t.jsx("span",{children:r.label}),e[7]=r.label,e[8]=g):g=e[8];let h;e[9]!==n||e[10]!==m||e[11]!==g?(h=t.jsxs("button",{type:"button",className:"notebook-start-tile-primary","aria-label":m,disabled:n,onClick:b,children:[f,g]}),e[9]=n,e[10]=m,e[11]=g,e[12]=h):h=e[12];const y=`${r.label} from library`;let x;e[13]!==s||e[14]!==a||e[15]!==c?(x=()=>a(s,c),e[13]=s,e[14]=a,e[15]=c,e[16]=x):x=e[16];let j;e[17]!==n||e[18]!==y||e[19]!==x?(j=t.jsx("button",{type:"button",className:"notebook-start-tile-secondary","aria-label":y,disabled:n,onClick:x,children:"From library"}),e[17]=n,e[18]=y,e[19]=x,e[20]=j):j=e[20];let v;e[21]!==j||e[22]!==h?(v=t.jsxs("div",{className:"notebook-start-tile-actions",children:[h,j]}),e[21]=j,e[22]=h,e[23]=v):v=e[23];const k=hi[s];let w;e[24]!==u||e[25]!==n||e[26]!==k?(w=t.jsx("input",{ref:o,type:"file",accept:k,hidden:!0,disabled:n,onChange:u}),e[24]=u,e[25]=n,e[26]=k,e[27]=w):w=e[27];let S;return e[28]!==r.icon||e[29]!==r.title||e[30]!==s||e[31]!==v||e[32]!==w||e[33]!==p?(S=t.jsxs(Qn,{kind:s,title:r.title,icon:r.icon,children:[p,v,w]}),e[28]=r.icon,e[29]=r.title,e[30]=s,e[31]=v,e[32]=w,e[33]=p,e[34]=S):S=e[34],S}function om({busy:l,onDownload:e}){const[s,n]=C.useState(""),[i,a]=C.useState(!1),o=s.trim(),r=l||i,c=async d=>{if(d.preventDefault(),!(r||!o)){a(!0);try{await e(o,Jt.download),n("")}finally{a(!1)}}};return t.jsx(Qn,{kind:"download",title:"Download a clip",icon:Ei,children:t.jsxs("form",{className:"notebook-start-tile-form",noValidate:!0,onSubmit:d=>{c(d)},children:[t.jsx("input",{type:"url",inputMode:"url","aria-label":"Clip link",placeholder:"Paste a link",value:s,disabled:r,onChange:d=>n(d.target.value)}),t.jsxs("button",{type:"submit",className:"notebook-start-tile-primary",disabled:r||!o,children:[t.jsx(tn,{"aria-hidden":"true"}),t.jsx("span",{children:i?"Queuing…":"Download"})]})]})})}function cm(l){const e=X.c(6),{busy:s,onBrowseLibrary:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("span",{className:"notebook-start-tile-hint",children:"From every book"}),e[0]=i):i=e[0];let a;e[1]!==n?(a=()=>n(Jt.library),e[1]=n,e[2]=a):a=e[2];let o;return e[3]!==s||e[4]!==a?(o=t.jsxs(Qn,{kind:"library",title:"Your library",icon:Vn,children:[i,t.jsx("div",{className:"notebook-start-tile-actions",children:t.jsx("button",{type:"button",className:"notebook-start-tile-secondary","aria-label":"Browse library",disabled:s,onClick:a,children:"Browse"})})]}),e[3]=s,e[4]=a,e[5]=o):o=e[5],o}function gf(l){const e=X.c(18),{busy:s,compact:n,dimmed:i,onUpload:a,onPick:o,onDownload:r,onBrowseLibrary:c}=l;let d,u;e[0]!==s||e[1]!==o||e[2]!==a?(d=t.jsx(ql,{kind:"image",busy:s,onUpload:a,onPick:o}),u=t.jsx(ql,{kind:"video",busy:s,onUpload:a,onPick:o}),e[0]=s,e[1]=o,e[2]=a,e[3]=d,e[4]=u):(d=e[3],u=e[4]);let p;e[5]!==s||e[6]!==r?(p=t.jsx(om,{busy:s,onDownload:r}),e[5]=s,e[6]=r,e[7]=p):p=e[7];let m;e[8]!==s||e[9]!==c?(m=t.jsx(cm,{busy:s,onBrowseLibrary:c}),e[8]=s,e[9]=c,e[10]=m):m=e[10];let b;return e[11]!==n||e[12]!==i||e[13]!==d||e[14]!==u||e[15]!==p||e[16]!==m?(b=t.jsx(_i,{children:t.jsxs("div",{className:"notebook-start-tiles nodrag nopan",style:rm,role:"group","aria-label":"Start this notebook","data-compact":n,"data-dimmed":i,children:[d,u,p,m]})}),e[11]=n,e[12]=i,e[13]=d,e[14]=u,e[15]=p,e[16]=m,e[17]=b):b=e[17],b}const dm={post:St,audio:ss,image:Zt,video:Rs,character:Di,prompt:Ai,analyze:zn,generate_video:Rs,generate_image:Zt,generate_audio:ss,extract_audio:ss,split_video:St,concat:St,splice:St,timeline:St};function um(l){const e=X.c(27),{disabled:s,onAdd:n,onDragEnd:i}=l,[a,o]=C.useState(""),r=C.useRef(null),c=C.useRef(null),d=C.useRef(null),u=Qr(a);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=_=>{r.current&&(r.current.open=!1),o(""),_&&d.current?.focus()},e[0]=p):p=e[0];const m=p;let b,f;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const _=L=>{const B=r.current;!B?.open||!(L.target instanceof Node)||B.contains(L.target)||m(!1)};return document.addEventListener("pointerdown",_,!0),document.addEventListener("focusin",_),()=>{document.removeEventListener("pointerdown",_,!0),document.removeEventListener("focusin",_)}},f=[m],e[1]=b,e[2]=f):(b=e[1],f=e[2]),C.useEffect(b,f);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=_=>{if(!_.currentTarget.open){o("");return}const L=document.activeElement;L!==d.current&&_.currentTarget.contains(L)||c.current?.focus()},e[3]=g):g=e[3];const h=g;let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=_=>{_.key!=="Escape"||!r.current?.open||(_.preventDefault(),_.stopPropagation(),m(!0))},e[4]=y):y=e[4];const x=y;let j;e[5]!==n?(j=_=>{m(!0),n(_)},e[5]=n,e[6]=j):j=e[6];const v=j;let k;e[7]!==i?(k=()=>{i(),m(!1)},e[7]=i,e[8]=k):k=e[8];const w=k,S="canvas-add-menu";let M;e[9]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsxs("summary",{ref:d,"aria-label":"Add cell",title:"Add cell",children:[t.jsx(es,{size:15}),t.jsx("span",{children:"Add cell"}),t.jsx(Is,{size:13})]}),e[9]=M):M=e[9];const N="canvas-add-popover";let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx(rs,{size:14,"aria-hidden":"true"}),e[10]=$):$=e[10];let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=_=>o(_.target.value),e[11]=P):P=e[11];let T;e[12]!==a?(T=t.jsxs("label",{className:"canvas-add-search",children:[$,t.jsx("input",{ref:c,type:"search",value:a,"aria-label":"Search cell types",placeholder:"Search cell types",onChange:P})]}),e[12]=a,e[13]=T):T=e[13];const A="canvas-add-results",I="polite",D=Zr.map(_=>{const L=u.filter(B=>B.group===_);return L.length===0?null:t.jsxs("section",{className:"canvas-add-group",children:[t.jsx("span",{children:_}),L.map(B=>{const U=dm[B.type];return t.jsxs("button",{type:"button",draggable:!0,disabled:s,onDragStart:q=>q.dataTransfer.setData("application/x-videobook-cell",B.type),onDragEnd:w,onClick:()=>v(B.type),children:[t.jsx(U,{size:15}),t.jsx("span",{children:B.label})]},B.type)})]},_)});let F;e[14]!==u.length?(F=u.length===0&&t.jsx("p",{className:"canvas-add-empty",children:"No cell types found"}),e[14]=u.length,e[15]=F):F=e[15];let R;e[16]!==D||e[17]!==F?(R=t.jsxs("div",{className:A,"aria-live":I,children:[D,F]}),e[16]=D,e[17]=F,e[18]=R):R=e[18];let E;e[19]!==T||e[20]!==R?(E=t.jsxs("div",{className:N,children:[T,R]}),e[19]=T,e[20]=R,e[21]=E):E=e[21];let z;return e[22]!==x||e[23]!==h||e[24]!==E||e[25]!==M?(z=t.jsxs("details",{ref:r,className:S,onToggle:h,onKeyDown:x,children:[M,E]}),e[22]=x,e[23]=h,e[24]=E,e[25]=M,e[26]=z):z=e[26],z}function yf(l){const e=X.c(41),{busy:s,arrangeDisabled:n,selectedCount:i,activeAddress:a,onAdd:o,onAddDragEnd:r,onArrange:c,onDeleteSelection:d,onClearSelection:u,onSelectionActions:p}=l,m=`Delete ${i} selected ${i===1?"cell":"cells"}`;let b;e[0]!==s||e[1]!==o||e[2]!==r?(b=t.jsx(um,{disabled:s,onAdd:o,onDragEnd:r}),e[0]=s,e[1]=o,e[2]=r,e[3]=b):b=e[3];let f;e[4]!==o?(f=()=>{o("image")},e[4]=o,e[5]=f):f=e[5];let g,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(es,{size:15}),h=t.jsx("span",{children:"Image"}),e[6]=g,e[7]=h):(g=e[6],h=e[7]);let y;e[8]!==s||e[9]!==f?(y=t.jsxs("button",{type:"button",className:"canvas-auto-arrange canvas-quick-add",title:"Add an image cell and pick from recent media","aria-label":"Add image",disabled:s,onClick:f,children:[g,h]}),e[8]=s,e[9]=f,e[10]=y):y=e[10];let x;e[11]!==o?(x=()=>{o("video")},e[11]=o,e[12]=x):x=e[12];let j,v;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(es,{size:15}),v=t.jsx("span",{children:"Video"}),e[13]=j,e[14]=v):(j=e[13],v=e[14]);let k;e[15]!==s||e[16]!==x?(k=t.jsxs("button",{type:"button",className:"canvas-auto-arrange canvas-quick-add",title:"Add a video cell and pick from recent media","aria-label":"Add video",disabled:s,onClick:x,children:[j,v]}),e[15]=s,e[16]=x,e[17]=k):k=e[17];let w;e[18]!==c?(w=()=>{c()},e[18]=c,e[19]=w):w=e[19];let S,M;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(ic,{size:15}),M=t.jsx("span",{children:"Arrange"}),e[20]=S,e[21]=M):(S=e[20],M=e[21]);let N;e[22]!==n||e[23]!==w?(N=t.jsxs("button",{type:"button",className:"canvas-auto-arrange",title:"Arrange cells by workflow and media type","aria-label":"Auto-arrange notebook",disabled:n,onClick:w,children:[S,M]}),e[22]=n,e[23]=w,e[24]=N):N=e[24];let $;e[25]!==b||e[26]!==N||e[27]!==y||e[28]!==k?($=t.jsxs("div",{className:"canvas-primary-actions",role:"group","aria-label":"Notebook editing tools",children:[b,y,k,N]}),e[25]=b,e[26]=N,e[27]=y,e[28]=k,e[29]=$):$=e[29];let P;e[30]!==a||e[31]!==s||e[32]!==m||e[33]!==u||e[34]!==d||e[35]!==p||e[36]!==i?(P=i>0&&t.jsxs("div",{className:"canvas-selection-actions",role:"group","aria-label":"Notebook selection actions",children:[t.jsxs("span",{className:"canvas-selection-count",title:"Shift-click cells or drag across the canvas to select more",children:[t.jsx("strong",{children:i}),t.jsx("span",{children:" selected"})]}),i>1&&a&&t.jsxs("code",{children:[a," active"]}),p&&t.jsx("button",{type:"button",className:"canvas-clear-selection",title:"Selection actions","aria-label":"Selection actions","data-workspace-action-surface":"selection-menu",onClick:p,children:t.jsx(qn,{size:14})}),t.jsxs("button",{type:"button",className:"canvas-delete-selection",title:m,"aria-label":m,"aria-keyshortcuts":"Delete Backspace",disabled:s,onClick:()=>{d()},children:[t.jsx(os,{size:14}),t.jsx("span",{children:"Delete"})]}),t.jsx("button",{type:"button",className:"canvas-clear-selection",title:"Clear selection","aria-label":"Clear selection",onClick:u,children:t.jsx(mt,{size:14})})]}),e[30]=a,e[31]=s,e[32]=m,e[33]=u,e[34]=d,e[35]=p,e[36]=i,e[37]=P):P=e[37];let T;return e[38]!==$||e[39]!==P?(T=t.jsxs("div",{className:"canvas-toolbar","data-composer-focus":"return",role:"group","aria-label":"Notebook canvas controls",children:[$,P]}),e[38]=$,e[39]=P,e[40]=T):T=e[40],T}function mm(l){return l.costUsd===null||l.status!=="completed"&&l.basis!=="reported"&&l.inputTokens===null&&l.outputTokens===null?"Unpriced":`${l.basis==="estimated"?"~":""}${Ss(l.costUsd)}`}function fm(){const l=X.c(5),e=C.useId(),s=C.useRef(null),n=C.useRef(null);let i;l[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{if(!s.current||!n.current)return;const d=s.current.getBoundingClientRect(),u=Math.min(d.bottom+8,window.innerHeight-100);n.current.style.top=`${u}px`,n.current.style.maxHeight=`${Math.max(80,window.innerHeight-u-12)}px`},l[0]=i):i=l[0];const a=i;let o,r;l[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)),r=[],l[1]=o,l[2]=r):(o=l[1],r=l[2]),C.useEffect(o,r);let c;return l[3]!==e?(c={id:e,buttonRef:s,panelRef:n,position:a},l[3]=e,l[4]=c):c=l[4],c}function jf(l){const e=X.c(51),{bookName:s,enabled:n,snapshot:i,stale:a,onRetry:o}=l,{id:r,buttonRef:c,panelRef:d,position:u}=fm(),p=i?.totals;let m;e[0]!==p?(m=p?as(p.inputTokens+p.outputTokens):"—",e[0]=p,e[1]=m):m=e[1];const b=m;let f;e[2]!==p?(f=p?Mn(p):"— cost",e[2]=p,e[3]=f):f=e[3];const g=f,h=!!p&&(p.unpriced>0||p.missingTokens>0||i?.incomplete);let y;e[4]!==i?.groups?(y=new Set(i?.groups.map(ym)??[]),e[4]=i?.groups,e[5]=y):y=e[5];let x;e[6]!==y?(x=[...y],e[6]=y,e[7]=x):x=e[7];const j=x,v=!n,k=`Book usage: ${b} tokens, ${g}${a?", stale":h?", incomplete":""}`;let w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("small",{children:" tokens"}),e[8]=w):w=e[8];let S;e[9]!==b?(S=t.jsxs("span",{children:[b,w]}),e[9]=b,e[10]=S):S=e[10];let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx("span",{className:"book-usage-divider","aria-hidden":"true",children:"·"}),e[11]=M):M=e[11];let N;e[12]!==g?(N=t.jsx("span",{children:g}),e[12]=g,e[13]=N):N=e[13];let $;e[14]!==h||e[15]!==a?($=(a||h)&&t.jsx("span",{className:"book-usage-indicator","aria-hidden":"true"}),e[14]=h,e[15]=a,e[16]=$):$=e[16];let P;e[17]!==c||e[18]!==r||e[19]!==N||e[20]!==$||e[21]!==v||e[22]!==k||e[23]!==S?(P=t.jsxs("button",{ref:c,type:"button",className:"book-usage-trigger",popoverTarget:r,disabled:v,"aria-label":k,title:"Tokens and cost for this book",children:[S,M,N,$]}),e[17]=c,e[18]=r,e[19]=N,e[20]=$,e[21]=v,e[22]=k,e[23]=S,e[24]=P):P=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("h2",{children:"Book usage"}),e[25]=T):T=e[25];let A;e[26]!==s?(A=t.jsxs("div",{children:[T,t.jsx("p",{children:s})]}),e[26]=s,e[27]=A):A=e[27];let I;e[28]!==r?(I=t.jsx("button",{type:"button",popoverTarget:r,popoverTargetAction:"hide","aria-label":"Close book usage",children:"×"}),e[28]=r,e[29]=I):I=e[29];let D;e[30]!==A||e[31]!==I?(D=t.jsxs("header",{children:[A,I]}),e[30]=A,e[31]=I,e[32]=D):D=e[32];let F;e[33]!==o||e[34]!==a?(F=a&&t.jsxs("p",{className:"book-usage-notice",children:["Usage may be out of date. ",t.jsx("button",{type:"button",onClick:o,children:"Retry"})]}),e[33]=o,e[34]=a,e[35]=F):F=e[35];let R;e[36]!==j||e[37]!==h||e[38]!==i||e[39]!==a?(R=i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"book-usage-totals",children:[t.jsxs("div",{children:[t.jsx("small",{children:"Reported tokens"}),t.jsx("strong",{children:as(i.totals.inputTokens+i.totals.outputTokens,!0)})]}),t.jsxs("div",{children:[t.jsx("small",{children:"Known cost · USD"}),t.jsx("strong",{children:Mn(i.totals)})]})]}),t.jsxs("dl",{className:"book-usage-facts",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Input / output"}),t.jsxs("dd",{children:[as(i.totals.inputTokens,!0)," / ",as(i.totals.outputTokens,!0)]})]}),t.jsxs("div",{children:[t.jsxs("dt",{children:["Cached input ",t.jsx("small",{children:"(included)"})]}),t.jsx("dd",{children:as(i.totals.cachedTokens,!0)})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Reported charges"}),t.jsx("dd",{children:Ss(i.totals.reportedUsd)})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Estimated charges"}),t.jsx("dd",{children:Ss(i.totals.estimatedUsd)})]})]}),h&&t.jsxs("p",{className:"book-usage-notice",children:[i.totals.unpriced>0&&`${i.totals.unpriced} ${i.totals.unpriced===1?"request has an unavailable price":"requests have unavailable prices"}. `,i.totals.missingTokens>0&&`${i.totals.missingTokens} ${i.totals.missingTokens===1?"request has":"requests have"} missing token counts. `,i.incomplete&&"Some usage could not be recorded."]}),i.totals.pendingCount>0&&t.jsxs("p",{className:"book-usage-pending",children:[i.totals.pendingCount," in progress · ",Ss(i.totals.pendingUsd)," estimated, excluded from total"]}),t.jsx("section",{"aria-label":"Usage by activity",className:"book-usage-breakdown",children:j.map(_=>{const L=i.groups.filter(H=>H.activity===_),B=L.reduce(gm,0),U=L.reduce(xm,0),q=L.some(bm);return t.jsxs("details",{children:[t.jsxs("summary",{children:[t.jsx("span",{children:bi[_]}),t.jsx("span",{children:B===0&&U?"Unpriced":`${q?"~":""}${Ss(B)}`})]}),L.map(hm)]},_)})}),i.recent.length>0?t.jsxs("section",{className:"book-usage-recent","aria-label":"Recent usage",children:[t.jsx("h3",{children:"Recent usage"}),i.recent.map(pm)]}):t.jsx("p",{className:"book-usage-empty",children:"New AI activity will appear here."}),t.jsxs("footer",{children:["Tracked since ",new Date(i.trackedSince).toLocaleString([],{dateStyle:"medium",timeStyle:"short"}),".",t.jsx("br",{}),"Estimates use recorded provider rates. Earlier usage is not included."]})]}):t.jsx("p",{className:"book-usage-empty",children:a?"Usage is unavailable.":"Loading usage…"}),e[36]=j,e[37]=h,e[38]=i,e[39]=a,e[40]=R):R=e[40];let E;e[41]!==r||e[42]!==d||e[43]!==u||e[44]!==D||e[45]!==F||e[46]!==R?(E=t.jsxs("div",{ref:d,id:r,popover:"auto",role:"dialog","aria-label":"Book usage",className:"book-usage-popover",onToggle:u,children:[D,F,R]}),e[41]=r,e[42]=d,e[43]=u,e[44]=D,e[45]=F,e[46]=R,e[47]=E):E=e[47];let z;return e[48]!==P||e[49]!==E?(z=t.jsxs("div",{className:"book-usage","data-composer-focus":"preserve",children:[P,E]}),e[48]=P,e[49]=E,e[50]=z):z=e[50],z}function pm(l){return t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.model}),t.jsxs("small",{children:[bi[l.activity]," · ",l.status," · ",new Date(l.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),l.units!==null&&l.unit&&` · ${as(l.units)} ${l.unit}`]})]}),t.jsx("span",{children:l.status==="pending"?"Pending":mm(l)})]},l.id)}function hm(l){return t.jsxs("div",{className:"book-usage-model",children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.model}),t.jsxs("small",{children:[l.provider," · ",l.count," requests · ",as(l.inputTokens+l.outputTokens)," tokens"]})]}),t.jsx("span",{children:Mn(l)})]},`${l.provider}:${l.model}`)}function bm(l){return l.estimatedUsd>0}function xm(l,e){return l+e.unpriced}function gm(l,e){return l+e.reportedUsd+e.estimatedUsd}function ym(l){return l.activity}function jm({call:l}){const[e,s]=C.useState(null),[n,i]=C.useState(!1),[a,o]=C.useState(null),r=async c=>{if(!l)return;const d=c?window.open("about:blank","_blank"):null;i(!0),o(null);try{if(c){const u=await l("connect_service",{service:"dropbox"});d?d.location.href=u.authorize_url:window.open(u.authorize_url,"_blank","noopener,noreferrer")}s(await l("service_status",{service:"dropbox"}))}catch(u){d?.close(),o(u instanceof Error?u.message:String(u))}finally{i(!1)}};return t.jsxs("article",{className:"settings-dropbox-connection",children:[t.jsxs("div",{className:"settings-credential-copy",children:[t.jsx("strong",{children:"Dropbox delivery"}),t.jsx("p",{children:e?.connected?"Connected · offline access enabled":e?.pending?"Approve access in Dropbox, then check connection.":"Deliver private clip files and captions for manual posting."}),t.jsx("small",{children:"App key: DROPBOX_CLIENT_ID · Redirect: http://127.0.0.1:8766/callback"})]}),t.jsx("button",{type:"button",disabled:n||!l,onClick:()=>{r(!0)},children:e?.connected?"Reconnect Dropbox":"Connect Dropbox"}),t.jsx("button",{type:"button",disabled:n||!l,onClick:()=>{r(!1)},children:"Check connection"}),(a||e?.error)&&t.jsx("p",{role:"alert",className:"settings-error",children:a??e?.error})]})}function vm(l){const e=X.c(27),{busy:s,connection:n,onConnect:i}=l;let a;e[0]!==n.connecting||e[1]!==n.status?(a=eo(n.status,{connecting:n.connecting}),e[0]=n.connecting,e[1]=n.status,e[2]=a):a=e[2];const o=a,r=s||n.connecting||o.actionLabel===null,c=`provider-card x-connection-card x-connection-${o.tone}`;let d,u;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"provider-dot","aria-hidden":"true"}),u=t.jsx("strong",{children:"X account"}),e[3]=d,e[4]=u):(d=e[3],u=e[4]);let p;e[5]!==o.detail||e[6]!==o.label?(p=t.jsxs("p",{children:[o.label," · ",o.detail]}),e[5]=o.detail,e[6]=o.label,e[7]=p):p=e[7];let m;e[8]!==n.authorizeUrl||e[9]!==n.connecting?(m=n.connecting&&n.authorizeUrl&&t.jsxs("p",{children:[t.jsx("a",{href:n.authorizeUrl,target:"_blank",rel:"noopener noreferrer",children:"Open the X authorization page"})," ","if no browser tab appeared."]}),e[8]=n.authorizeUrl,e[9]=n.connecting,e[10]=m):m=e[10];let b;e[11]!==n.connecting||e[12]!==n.error?(b=n.error&&!n.connecting&&t.jsx("p",{className:"x-connection-error",role:"alert",children:n.error}),e[11]=n.connecting,e[12]=n.error,e[13]=b):b=e[13];let f;e[14]!==p||e[15]!==m||e[16]!==b?(f=t.jsxs("div",{children:[u,p,m,b]}),e[14]=p,e[15]=m,e[16]=b,e[17]=f):f=e[17];let g;e[18]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(ac,{size:13,"aria-hidden":"true"}),e[18]=g):g=e[18];const h=n.connecting?"Waiting…":o.actionLabel??"Connect X";let y;e[19]!==r||e[20]!==i||e[21]!==h?(y=t.jsxs("button",{type:"button",disabled:r,onClick:i,children:[g,h]}),e[19]=r,e[20]=i,e[21]=h,e[22]=y):y=e[22];let x;return e[23]!==y||e[24]!==c||e[25]!==f?(x=t.jsxs("article",{className:c,"aria-label":"X account",children:[d,f,y]}),e[23]=y,e[24]=c,e[25]=f,e[26]=x):x=e[26],x}function Ys(l){const e=X.c(9),{providers:s,editor:n,busy:i}=l;let a;if(e[0]!==i||e[1]!==n||e[2]!==s){let r;e[4]!==i||e[5]!==n?(r=c=>{const d=so(c),u=n.draft?.key===c.envKey&&c.editable,p=n.message?.key===c.envKey?n.message:null;return t.jsxs("article",{className:"settings-credential","aria-label":`${d} setting`,children:[t.jsxs("div",{className:"settings-credential-summary",children:[t.jsx("span",{className:`settings-key-status settings-key-${c.keyStatus}`,"aria-hidden":"true"}),t.jsxs("div",{className:"settings-credential-copy",children:[t.jsx("strong",{children:d}),t.jsx("span",{className:"settings-key-caption",children:c.keyStatus==="configured"?"Configured":c.keyStatus==="placeholder"?"Placeholder key":"Not configured"}),c.maskedKey&&t.jsx("span",{className:"settings-key-value",children:c.maskedKey}),!c.editable&&t.jsx("span",{className:"settings-key-source",children:c.source==="1password"?"Managed in 1Password":"Read only"})]}),c.editable&&t.jsx("button",{type:"button","aria-label":`Edit ${d}`,"aria-expanded":u,disabled:i||n.saving,onClick:m=>n.edit(c,m.currentTarget),children:c.keyStatus==="configured"?"Edit":c.secret?"Set key":"Set value"})]}),u&&t.jsxs("form",{className:"settings-key-editor","aria-label":`Edit ${d}`,onSubmit:m=>{m.preventDefault(),n.save(c)},onKeyDown:m=>{m.key!=="Escape"||m.nativeEvent.isComposing||n.saving||(m.preventDefault(),m.stopPropagation(),n.close())},children:[t.jsx("label",{htmlFor:`setting-${c.envKey}`,children:d}),t.jsx("input",{id:`setting-${c.envKey}`,autoFocus:!0,type:c.secret?"password":"text",value:n.draft?.value??"",autoComplete:"off",spellCheck:!1,disabled:i||n.saving,onChange:m=>n.change(m.target.value)}),t.jsxs("small",{children:[c.envKey," · Saved locally"]}),t.jsxs("div",{className:"settings-key-actions",children:[t.jsx("button",{type:"submit",disabled:i||n.saving||!n.draft?.value.trim(),children:n.saving?"Saving…":"Save"}),t.jsx("button",{type:"button",disabled:n.saving,onClick:n.close,children:"Cancel"})]})]}),p&&t.jsx("p",{className:p.error?"settings-error":"settings-feedback",role:p.error?"alert":"status",children:p.text})]},c.envKey)},e[4]=i,e[5]=n,e[6]=r):r=e[6],a=s.map(r),e[0]=i,e[1]=n,e[2]=s,e[3]=a}else a=e[3];let o;return e[7]!==a?(o=t.jsx("div",{className:"settings-credentials",children:a}),e[7]=a,e[8]=o):o=e[8],o}function Nn(l){return`${l.filter(s=>s.keyStatus==="configured").length} of ${l.length} configured`}function vf(l){const e=X.c(129),{call:s,providers:n,loading:i,error:a,refreshed:o,storage:r,bookId:c,bookName:d,connection:u,busy:p,onRefresh:m,onSave:b,onConnect:f}=l,g=to(b);let h,y,x,j,v,k,w,S,M,N,$,P,T,A,I,D,F,R;if(e[0]!==c||e[1]!==d||e[2]!==p||e[3]!==s||e[4]!==u||e[5]!==g||e[6]!==a||e[7]!==i||e[8]!==f||e[9]!==m||e[10]!==n||e[11]!==o||e[12]!==r){const se=n.filter(Nm);let ie;e[31]!==n?(ie=n.filter(wm),e[31]=n,e[32]=ie):ie=e[32];const V=ie,ce=n.filter(Sm);h=n.filter(km);const W=r?.bookId===c?r:null,te=W?.status==="ready"?W.value:null;w="workspace-screen settings-screen",S="Settings";let ae;e[33]===Symbol.for("react.memo_cache_sentinel")?(ae=t.jsxs("div",{children:[t.jsx("h1",{children:"Settings"}),t.jsx("p",{children:"Providers, connected accounts and project storage."})]}),e[33]=ae):ae=e[33];const Y=i?"Refreshing…":o?"Up to date":"";let Q;e[34]!==Y?(Q=t.jsx("span",{role:"status",children:Y}),e[34]=Y,e[35]=Q):Q=e[35];const Z=p||i;let re;e[36]!==m?(re=()=>{m()},e[36]=m,e[37]=re):re=e[37];let ee;e[38]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(Ni,{size:15,"aria-hidden":"true"}),e[38]=ee):ee=e[38];let J;e[39]!==Z||e[40]!==re?(J=t.jsxs("button",{type:"button",disabled:Z,onClick:re,children:[ee,"Refresh"]}),e[39]=Z,e[40]=re,e[41]=J):J=e[41],e[42]!==Q||e[43]!==J?(M=t.jsxs("header",{children:[ae,t.jsxs("div",{className:"settings-refresh",children:[Q,J]})]}),e[42]=Q,e[43]=J,e[44]=M):M=e[44],e[45]!==a?(N=a&&t.jsx("p",{role:"alert",className:"settings-error",children:a}),e[45]=a,e[46]=N):N=e[46],v="settings-layout";let de;e[47]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-providers-heading",children:"Providers"}),t.jsx("span",{children:"Application"})]}),e[47]=de):de=e[47];const fe=se.length?Nn(se):i?"Loading providers…":"Refresh to load provider settings.";let ue;e[48]!==fe?(ue=t.jsx("p",{className:"settings-section-summary",children:fe}),e[48]=fe,e[49]=ue):ue=e[49];let pe;e[50]!==p||e[51]!==g||e[52]!==se?(pe=t.jsx(Ys,{providers:se,editor:g,busy:p}),e[50]=p,e[51]=g,e[52]=se,e[53]=pe):pe=e[53],e[54]!==ue||e[55]!==pe?(k=t.jsxs("section",{className:"settings-panel settings-providers","aria-labelledby":"settings-providers-heading",children:[de,ue,pe]}),e[54]=ue,e[55]=pe,e[56]=k):k=e[56],R="settings-secondary";let me;e[57]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-x-heading",children:"X account"}),t.jsx("span",{children:"Application"})]}),e[57]=me):me=e[57];let he;e[58]!==p||e[59]!==u||e[60]!==f?(he=t.jsx(vm,{busy:p,connection:u,onConnect:f}),e[58]=p,e[59]=u,e[60]=f,e[61]=he):he=e[61];const ye=Nn(ce);let oe;e[62]!==ye?(oe=t.jsxs("summary",{children:["X credentials ",t.jsx("span",{children:ye})]}),e[62]=ye,e[63]=oe):oe=e[63];let G;e[64]!==p||e[65]!==g||e[66]!==ce?(G=t.jsx(Ys,{providers:ce,editor:g,busy:p}),e[64]=p,e[65]=g,e[66]=ce,e[67]=G):G=e[67];let le;e[68]!==oe||e[69]!==G?(le=t.jsxs("details",{className:"settings-details",children:[oe,G]}),e[68]=oe,e[69]=G,e[70]=le):le=e[70],e[71]!==he||e[72]!==le?(x=t.jsxs("section",{className:"settings-panel","aria-labelledby":"settings-x-heading",children:[me,he,le]}),e[71]=he,e[72]=le,e[73]=x):x=e[73];let be;e[74]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-dropbox-heading",children:"Dropbox"}),t.jsx("span",{children:"Application"})]}),e[74]=be):be=e[74];let je;e[75]!==s?(je=t.jsx(jm,{call:s}),e[75]=s,e[76]=je):je=e[76];let we;e[77]===Symbol.for("react.memo_cache_sentinel")?(we=t.jsx("summary",{children:"Dropbox credentials"}),e[77]=we):we=e[77];let $e;e[78]!==p||e[79]!==V||e[80]!==g?($e=t.jsxs("details",{className:"settings-details",children:[we,t.jsx(Ys,{providers:V,editor:g,busy:p})]}),e[78]=p,e[79]=V,e[80]=g,e[81]=$e):$e=e[81],e[82]!==je||e[83]!==$e?(j=t.jsxs("section",{className:"settings-panel","aria-labelledby":"settings-dropbox-heading",children:[be,je,$e]}),e[82]=je,e[83]=$e,e[84]=j):j=e[84],T="settings-panel",A="settings-storage-heading",e[85]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-storage-heading",children:"Storage"}),t.jsx("span",{children:"Selected project"})]}),e[85]=I):I=e[85];const Ie=d??"No project selected";e[86]!==Ie?(D=t.jsx("p",{className:"settings-section-summary",children:Ie}),e[86]=Ie,e[87]=D):D=e[87],e[88]!==c||e[89]!==W||e[90]!==i||e[91]!==te?(F=c?W?.status==="error"?t.jsx("p",{role:"alert",className:"settings-error",children:W.error}):te?t.jsxs(t.Fragment,{children:[t.jsxs("dl",{className:"settings-storage-summary",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Backup"}),t.jsx("dd",{children:te.state.replaceAll("_"," ")})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Pending objects"}),t.jsx("dd",{children:te.pendingObjects})]})]}),te.lastError&&t.jsx("p",{role:"alert",className:"settings-error",children:te.lastError}),t.jsxs("details",{className:"settings-details",children:[t.jsx("summary",{children:"Technical details"}),t.jsxs("p",{children:["videobook-engine ",ja.version," · schema ",va]}),t.jsx("pre",{children:JSON.stringify(te,null,2)})]})]}):t.jsx("p",{role:"status",children:i?"Loading storage…":"Refresh to inspect storage."}):t.jsx("p",{children:"Select a project to inspect its storage."}),e[88]=c,e[89]=W,e[90]=i,e[91]=te,e[92]=F):F=e[92],P="settings-details",$="Backblaze configuration ",y=Nn(h),e[0]=c,e[1]=d,e[2]=p,e[3]=s,e[4]=u,e[5]=g,e[6]=a,e[7]=i,e[8]=f,e[9]=m,e[10]=n,e[11]=o,e[12]=r,e[13]=h,e[14]=y,e[15]=x,e[16]=j,e[17]=v,e[18]=k,e[19]=w,e[20]=S,e[21]=M,e[22]=N,e[23]=$,e[24]=P,e[25]=T,e[26]=A,e[27]=I,e[28]=D,e[29]=F,e[30]=R}else h=e[13],y=e[14],x=e[15],j=e[16],v=e[17],k=e[18],w=e[19],S=e[20],M=e[21],N=e[22],$=e[23],P=e[24],T=e[25],A=e[26],I=e[27],D=e[28],F=e[29],R=e[30];let E;e[93]!==y?(E=t.jsx("span",{children:y}),e[93]=y,e[94]=E):E=e[94];let z;e[95]!==E||e[96]!==$?(z=t.jsxs("summary",{children:[$,E]}),e[95]=E,e[96]=$,e[97]=z):z=e[97];let _;e[98]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx("p",{children:"Application · shared by all projects."}),e[98]=_):_=e[98];let L;e[99]!==p||e[100]!==g||e[101]!==h?(L=t.jsx(Ys,{providers:h,editor:g,busy:p}),e[99]=p,e[100]=g,e[101]=h,e[102]=L):L=e[102];let B;e[103]!==z||e[104]!==L||e[105]!==P?(B=t.jsxs("details",{className:P,children:[z,_,L]}),e[103]=z,e[104]=L,e[105]=P,e[106]=B):B=e[106];let U;e[107]!==B||e[108]!==T||e[109]!==A||e[110]!==I||e[111]!==D||e[112]!==F?(U=t.jsxs("section",{className:T,"aria-labelledby":A,children:[I,D,F,B]}),e[107]=B,e[108]=T,e[109]=A,e[110]=I,e[111]=D,e[112]=F,e[113]=U):U=e[113];let q;e[114]!==x||e[115]!==j||e[116]!==U||e[117]!==R?(q=t.jsxs("div",{className:R,children:[x,j,U]}),e[114]=x,e[115]=j,e[116]=U,e[117]=R,e[118]=q):q=e[118];let H;e[119]!==v||e[120]!==k||e[121]!==q?(H=t.jsxs("div",{className:v,children:[k,q]}),e[119]=v,e[120]=k,e[121]=q,e[122]=H):H=e[122];let K;return e[123]!==w||e[124]!==S||e[125]!==M||e[126]!==N||e[127]!==H?(K=t.jsxs("section",{className:w,"aria-label":S,children:[M,N,H]}),e[123]=w,e[124]=S,e[125]=M,e[126]=N,e[127]=H,e[128]=K):K=e[128],K}function km(l){return l.provider==="b2"}function Sm(l){return l.provider==="x"}function wm(l){return l.provider==="dropbox"}function Nm(l){return!["x","b2","dropbox"].includes(l.provider)}function Cm(l){const e=X.c(16),{applyDisabled:s,applyFormId:n,applyLabel:i,busy:a,busyLabel:o,failed:r,onCancel:c}=l,d=a||s;let u;e[0]!==i||e[1]!==a||e[2]!==o||e[3]!==r?(u=a?o:t.jsxs(t.Fragment,{children:[r?"Retry":i," ",t.jsx("kbd",{children:"↵"})]}),e[0]=i,e[1]=a,e[2]=o,e[3]=r,e[4]=u):u=e[4];let p;e[5]!==n||e[6]!==d||e[7]!==u?(p=t.jsx("button",{type:"submit",form:n,className:"confirm-sheet-apply",disabled:d,children:u}),e[5]=n,e[6]=d,e[7]=u,e[8]=p):p=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("kbd",{children:"Esc"}),e[9]=m):m=e[9];let b;e[10]!==a||e[11]!==c?(b=t.jsxs("button",{type:"button",disabled:a,onClick:c,children:["Cancel ",m]}),e[10]=a,e[11]=c,e[12]=b):b=e[12];let f;return e[13]!==p||e[14]!==b?(f=t.jsxs("div",{className:"confirm-sheet-actions",children:[p,b]}),e[13]=p,e[14]=b,e[15]=f):f=e[15],f}function Gi(){const l=X.c(4);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("kbd",{children:"↵"}),l[0]=e):e=l[0];let s;l[1]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("kbd",{children:"Esc"}),l[1]=s):s=l[1];let n;l[2]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx("kbd",{children:"⌘↵"}),l[2]=n):n=l[2];let i;return l[3]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("span",{children:[e," apply · ",s," cancel · ",n," apply from any field · ",t.jsx("kbd",{children:"Tab"})," moves through settings"]}),l[3]=i):i=l[3],i}function $m(l){const e=X.c(6),{effect:s}=l,n=`confirm-sheet-effect confirm-sheet-effect-${s.tone}`;let i;e[0]!==s.tone?(i=s.tone==="warning"&&t.jsx(Fi,{size:11,"aria-hidden":"true"}),e[0]=s.tone,e[1]=i):i=e[1];let a;return e[2]!==s.label||e[3]!==n||e[4]!==i?(a=t.jsxs("span",{className:n,children:[i,s.label]}),e[2]=s.label,e[3]=n,e[4]=i,e[5]=a):a=e[5],a}function Im(l){const e=X.c(4),{state:s}=l;if(s==="blocking"){let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(rc,{size:14,"aria-hidden":"true"}),e[0]=n):n=e[0],n}if(s==="failed"){let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(wi,{size:14,"aria-hidden":"true"}),e[1]=n):n=e[1],n}if(s==="notice"){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(Fi,{size:14,"aria-hidden":"true"}),e[2]=n):n=e[2],n}if(s==="busy"){let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsxs("span",{className:"confirm-sheet-signal","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),e[3]=n):n=e[3],n}return null}function Rm(l){const e=X.c(23),{hints:s,onDismissStatus:n,secondaryActions:i,status:a,statusId:o}=l,r=a.state==="blocking"||a.state==="failed",c=`confirm-sheet-foot confirm-sheet-foot-${a.state}`,d=`confirm-sheet-status confirm-sheet-status-${a.state}`,u=r?"alert":"status",p=r?"assertive":"polite";let m;e[0]!==a.state?(m=t.jsx(Im,{state:a.state}),e[0]=a.state,e[1]=m):m=e[1];let b;e[2]!==s||e[3]!==a.message||e[4]!==a.state?(b=a.state==="ready"?s??t.jsx(Gi,{}):t.jsxs("span",{children:[a.state==="blocking"&&t.jsx("strong",{children:"Can’t apply — "}),a.state==="failed"&&t.jsx("strong",{children:"Apply failed — "}),a.message]}),e[2]=s,e[3]=a.message,e[4]=a.state,e[5]=b):b=e[5];let f;e[6]!==n||e[7]!==a.dismissible?(f=a.dismissible&&t.jsx("button",{type:"button",className:"confirm-sheet-status-dismiss","aria-label":"Dismiss message",onClick:n,children:t.jsx(mt,{size:14,"aria-hidden":"true"})}),e[6]=n,e[7]=a.dismissible,e[8]=f):f=e[8];let g;e[9]!==o||e[10]!==d||e[11]!==u||e[12]!==p||e[13]!==m||e[14]!==b||e[15]!==f?(g=t.jsxs("div",{id:o,className:d,role:u,"aria-live":p,children:[m,b,f]}),e[9]=o,e[10]=d,e[11]=u,e[12]=p,e[13]=m,e[14]=b,e[15]=f,e[16]=g):g=e[16];let h;e[17]!==i?(h=i&&t.jsx("div",{className:"confirm-sheet-aside",children:i}),e[17]=i,e[18]=h):h=e[18];let y;return e[19]!==c||e[20]!==g||e[21]!==h?(y=t.jsxs("footer",{className:c,children:[g,h]}),e[19]=c,e[20]=g,e[21]=h,e[22]=y):y=e[22],y}function Mm(l){const e=X.c(22),{actions:s,address:n,effect:i,hints:a,hintsId:o,tag:r,title:c,titleId:d}=l;let u;e[0]!==r?(u=t.jsx("span",{className:"section-label",children:r}),e[0]=r,e[1]=u):u=e[1];let p;e[2]!==c||e[3]!==d?(p=t.jsx("h2",{id:d,children:c}),e[2]=c,e[3]=d,e[4]=p):p=e[4];let m;e[5]!==n?(m=n&&t.jsx("span",{className:"confirm-sheet-address",children:n}),e[5]=n,e[6]=m):m=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("span",{className:"confirm-sheet-spacer","aria-hidden":"true"}),e[7]=b):b=e[7];let f;e[8]!==a||e[9]!==o?(f=a&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"confirm-sheet-head-divider","aria-hidden":"true"}),t.jsx("span",{id:o,className:"confirm-sheet-head-hints",children:a})]}),e[8]=a,e[9]=o,e[10]=f):f=e[10];let g;e[11]!==i?(g=i&&t.jsx($m,{effect:i}),e[11]=i,e[12]=g):g=e[12];let h;e[13]!==s||e[14]!==g?(h=t.jsxs("div",{className:"confirm-sheet-decisions",children:[g,s]}),e[13]=s,e[14]=g,e[15]=h):h=e[15];let y;return e[16]!==u||e[17]!==p||e[18]!==m||e[19]!==f||e[20]!==h?(y=t.jsxs("header",{className:"confirm-sheet-head",children:[u,p,m,b,f,h]}),e[16]=u,e[17]=p,e[18]=m,e[19]=f,e[20]=h,e[21]=y):y=e[21],y}function Yi(){return typeof window>"u"||typeof window.matchMedia!="function"?null:window.matchMedia(no)}function Pm(l){const e=Yi();return e?(e.addEventListener("change",l),()=>e.removeEventListener("change",l)):()=>{}}function Tm(){return Yi()?.matches??!0}function Em(){return C.useSyncExternalStore(Pm,Tm,Am)}function Am(){return!0}function kf(l){const e=X.c(58),{address:s,applyFormId:n,applyLabel:i,ariaLabel:a,busy:o,busyLabel:r,children:c,effect:d,hints:u,kind:p,onCancel:m,secondaryActions:b,tag:f,title:g,validation:h}=l,y=s===void 0?null:s,x=i===void 0?"Apply":i,j=r===void 0?"Applying…":r,v=d===void 0?null:d,k=u===void 0?null:u,w=b===void 0?null:b,S=C.useId(),M=`${S}-title`,N=`${S}-status`,$=C.useContext(Oi),[P,T]=C.useState(null);let A;e[0]!==$?.outcome?(A=()=>$?.outcome??null,e[0]=$?.outcome,e[1]=A):A=e[1];const[I]=C.useState(A);let D;e[2]!==$?.notice?(D=()=>$?.notice??null,e[2]=$?.notice,e[3]=D):D=e[3];const[F]=C.useState(D),R=$&&$.outcome!==I?$.outcome:null,E=$&&$.notice!==F?$.notice:null,z=lo({busy:o,busyLabel:j,validation:h,outcome:R,notice:E}),_=Em(),L=io({state:z.state,hasSecondaryActions:!!w,wideEnough:_}),B=h.blocking!==null;let U;e[4]!==B||e[5]!==n||e[6]!==o||e[7]!==m?(U={applyFormId:n,applyDisabled:B,busy:o,onCancel:m},e[4]=B,e[5]=n,e[6]=o,e[7]=m,e[8]=U):U=e[8];const{sheetRef:q,onKeyDown:H}=Ld(U);let K;e[9]!==$||e[10]!==E||e[11]!==R?(K=()=>{R?$?.dismissOutcome():E&&$?.dismissNotice()},e[9]=$,e[10]=E,e[11]=R,e[12]=K):K=e[12];const se=K,ie=`confirm-sheet confirm-sheet-${p}`;let V;e[13]!==P?(V=P===null?void 0:{"--confirm-review-height":`${P}px`},e[13]=P,e[14]=V):V=e[14];const ce=z.message??j,W=z.state==="failed";let te;e[15]!==B||e[16]!==n||e[17]!==x||e[18]!==o||e[19]!==m||e[20]!==ce||e[21]!==W?(te=t.jsx(Cm,{applyDisabled:B,applyFormId:n,applyLabel:x,busy:o,busyLabel:ce,failed:W,onCancel:m}),e[15]=B,e[16]=n,e[17]=x,e[18]=o,e[19]=m,e[20]=ce,e[21]=W,e[22]=te):te=e[22];let ae;e[23]!==k||e[24]!==L?(ae=L?k??t.jsx(Gi,{}):null,e[23]=k,e[24]=L,e[25]=ae):ae=e[25];const Y=L?N:void 0;let Q;e[26]!==y||e[27]!==v||e[28]!==te||e[29]!==ae||e[30]!==Y||e[31]!==f||e[32]!==g||e[33]!==M?(Q=t.jsx(Mm,{actions:te,address:y,effect:v,hints:ae,hintsId:Y,tag:f,title:g,titleId:M}),e[26]=y,e[27]=v,e[28]=te,e[29]=ae,e[30]=Y,e[31]=f,e[32]=g,e[33]=M,e[34]=Q):Q=e[34];let Z;e[35]!==q?(Z=t.jsx(_d,{sheetRef:q}),e[35]=q,e[36]=Z):Z=e[36];let re;e[37]!==c||e[38]!==Z?(re=t.jsx("div",{className:"confirm-sheet-body",children:t.jsxs(C.Suspense,{fallback:null,children:[c,Z]})}),e[37]=c,e[38]=Z,e[39]=re):re=e[39];let ee;e[40]!==se||e[41]!==k||e[42]!==L||e[43]!==w||e[44]!==z||e[45]!==N?(ee=!L&&t.jsx(Rm,{hints:k,onDismissStatus:se,secondaryActions:w,status:z,statusId:N}),e[40]=se,e[41]=k,e[42]=L,e[43]=w,e[44]=z,e[45]=N,e[46]=ee):ee=e[46];let J;e[47]===Symbol.for("react.memo_cache_sentinel")?(J=t.jsx(zi,{label:"Resize review and log",targetSelector:".confirm-sheet",edge:"bottom",minimum:180,reserve:36,onResize:T}),e[47]=J):J=e[47];let de;return e[48]!==a||e[49]!==H||e[50]!==q||e[51]!==N||e[52]!==ie||e[53]!==V||e[54]!==Q||e[55]!==re||e[56]!==ee?(de=t.jsxs("aside",{ref:q,className:ie,style:V,role:"dialog","aria-label":a,"aria-describedby":N,"aria-keyshortcuts":"Escape Meta+Enter Control+Enter",onKeyDown:H,children:[Q,re,ee,J]}),e[48]=a,e[49]=H,e[50]=q,e[51]=N,e[52]=ie,e[53]=V,e[54]=Q,e[55]=re,e[56]=ee,e[57]=de):de=e[57],de}function Dm(l){const e=X.c(13),{post:s,source:n}=l;let i;e[0]!==s||e[1]!==n?(i=t.jsx(Fm,{post:s,source:n}),e[0]=s,e[1]=n,e[2]=i):i=e[2];const a=s?.definition.caption??"";let o;e[3]!==a?(o=t.jsx(Lm,{caption:a}),e[3]=a,e[4]=o):o=e[4];let r;e[5]!==s?(r=s?t.jsx(zm,{post:s}):t.jsx("span",{className:"post-tile-hint",children:"Choose a clip to post"}),e[5]=s,e[6]=r):r=e[6];let c;e[7]!==o||e[8]!==r?(c=t.jsxs("div",{className:"post-tile-body",children:[o,r]}),e[7]=o,e[8]=r,e[9]=c):c=e[9];let d;return e[10]!==i||e[11]!==c?(d=t.jsxs("div",{className:"post-tile",children:[i,c]}),e[10]=i,e[11]=c,e[12]=d):d=e[12],d}function Fm(l){const e=X.c(22),{post:s,source:n}=l,i=n?.asset,a=i?.type==="video",o=i?.thumbnailUrl??(a?null:i?.mediaUrl??null),r=o||!a?null:i?.mediaUrl??null,c=i?.duration??null;let d,u,p,m;if(e[0]!==s||e[1]!==o||e[2]!==r){const h=s?xi(s):[];d="post-tile-media",e[7]!==o?(u=o&&t.jsx("img",{src:o,alt:"",draggable:!1}),e[7]=o,e[8]=u):u=e[8],e[9]!==r?(p=r&&t.jsx("video",{src:`${r}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),e[9]=r,e[10]=p):p=e[10],m=h.length>0&&t.jsx("span",{className:"post-tile-overlay post-tile-overlay-top",children:h.map(_m)}),e[0]=s,e[1]=o,e[2]=r,e[3]=d,e[4]=u,e[5]=p,e[6]=m}else d=e[3],u=e[4],p=e[5],m=e[6];let b;e[11]!==n?(b=n?.address&&t.jsxs("span",{className:"post-tile-overlay post-tile-overlay-start",children:["from ",n.address]}),e[11]=n,e[12]=b):b=e[12];let f;e[13]!==c?(f=c!=null&&c>0&&t.jsx("span",{className:"post-tile-overlay post-tile-overlay-end",children:Kt(c)}),e[13]=c,e[14]=f):f=e[14];let g;return e[15]!==d||e[16]!==u||e[17]!==p||e[18]!==m||e[19]!==b||e[20]!==f?(g=t.jsxs("div",{className:d,children:[u,p,m,b,f]}),e[15]=d,e[16]=u,e[17]=p,e[18]=m,e[19]=b,e[20]=f,e[21]=g):g=e[21],g}function _m(l){return t.jsxs("span",{className:"post-badge",children:[t.jsx(Qt,{size:10,strokeWidth:2.6,"aria-hidden":"true"}),l]},l)}function Lm(l){const e=X.c(5),{caption:s}=l;let n;e[0]!==s?(n=s.trim(),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i){let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"post-tile-caption post-tile-caption-empty",children:"No caption yet"}),e[2]=o):o=e[2],o}let a;return e[3]!==i?(a=t.jsx("span",{className:"post-tile-caption",title:i,children:i}),e[3]=i,e[4]=a):a=e[4],a}function zm(l){const e=X.c(14),{post:s}=l;let n;e[0]!==s?(n=ao(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(i){let u;return e[2]!==i||e[3]!==s?(u=t.jsx(Om,{post:s,text:i}),e[2]=i,e[3]=s,e[4]=u):u=e[4],u}let a;if(e[5]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=ro(s);if(u.length>0){a=t.jsx("span",{className:"post-tile-stats",children:u.map(Bm)});break e}}e[5]=s,e[6]=a}else a=e[6];if(a!==Symbol.for("react.early_return_sentinel"))return a;let o;e[7]!==s?(o=oo(s)??"Posted",e[7]=s,e[8]=o):o=e[8];let r;e[9]!==o?(r=t.jsx("span",{children:o}),e[9]=o,e[10]=r):r=e[10];let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("span",{className:"post-tile-hint post-tile-hint-action",children:"Add results"}),e[11]=c):c=e[11];let d;return e[12]!==r?(d=t.jsxs("span",{className:"post-tile-stats",children:[r,c]}),e[12]=r,e[13]=d):d=e[13],d}function Bm(l){return t.jsxs("span",{children:[t.jsx("strong",{children:l.value})," ",l.label]},l.label)}function Om(l){const e=X.c(8),{post:s,text:n}=l;let i;e[0]!==s?(i=xi(s),e[0]=s,e[1]=i):i=e[1];const a=i.length>0,o=`post-tile-hint${a?" post-tile-hint-action":""}`;let r;e[2]!==a?(r=a&&t.jsx(Ei,{size:11,"aria-hidden":"true"}),e[2]=a,e[3]=r):r=e[3];let c;return e[4]!==o||e[5]!==r||e[6]!==n?(c=t.jsxs("span",{className:o,children:[r,n]}),e[4]=o,e[5]=r,e[6]=n,e[7]=c):c=e[7],c}const Um=C.createContext({ready:!1,states:{},onFile:()=>{},onFileError:()=>{},onOpenLibrary:()=>{}}),Hm=C.createContext(async()=>{}),Km=C.createContext({ready:!1,deleteCell:async()=>{},repairCell:async()=>{},retryCell:async()=>{}}),Vm=C.createContext(null),qm=C.createContext(new Map),Wm=C.createContext({openCellId:null,open:()=>{}});function Xm(l){return`cell-context-menu-${l}`}const Gm=C.createContext(null),Sf=C.createContext(new Map),wf=C.createContext(new Map),Ym=C.createContext(new Map);function Jm(l){const e=X.c(26),{analysisInfo:s,fallbackShotCount:n,fallbackSourceDurationSeconds:i}=l,a=n===void 0?null:n,o=i===void 0?null:i,r=s?.shots.length??a??0,c=s?.sourceDurationSeconds??o;let d,u,p,m,b;if(e[0]!==s?.outputJson||e[1]!==s?.shots||e[2]!==c||e[3]!==r){const y=s?.shots.slice(0,3)??[];u=Math.max(0,r-y.length),d=s?.outputJson,p="cell-copy cell-copy-analysis";const x=r>0?`${r} shots`:"Analysis pending";let j;e[9]!==x?(j=t.jsx("strong",{children:x}),e[9]=x,e[10]=j):j=e[10];let v;e[11]!==c?(v=c!==null&&t.jsx("span",{children:Kt(c)}),e[11]=c,e[12]=v):v=e[12],e[13]!==j||e[14]!==v?(m=t.jsxs("div",{className:"analysis-cell-summary",children:[j,v]}),e[13]=j,e[14]=v,e[15]=m):m=e[15],b=y.length>0&&t.jsx("ol",{className:"analysis-cell-shots",children:y.map(Qm)}),e[0]=s?.outputJson,e[1]=s?.shots,e[2]=c,e[3]=r,e[4]=d,e[5]=u,e[6]=p,e[7]=m,e[8]=b}else d=e[4],u=e[5],p=e[6],m=e[7],b=e[8];let f;e[16]!==u?(f=u>0&&t.jsxs("span",{className:"analysis-cell-overflow",children:["+",u," more"]}),e[16]=u,e[17]=f):f=e[17];let g;e[18]!==d?(g=d!=null&&t.jsxs("details",{className:"analysis-cell-output-json nodrag nowheel",children:[t.jsxs("summary",{children:[t.jsx(Ms,{size:11,"aria-hidden":"true"}),"Output JSON"]}),t.jsx("div",{className:"analysis-cell-output-json-scroll",tabIndex:0,children:t.jsx(Xn,{value:d,ariaLabel:"Analysis output JSON"})})]}),e[18]=d,e[19]=g):g=e[19];let h;return e[20]!==p||e[21]!==m||e[22]!==b||e[23]!==f||e[24]!==g?(h=t.jsxs("div",{className:p,children:[m,b,f,g]}),e[20]=p,e[21]=m,e[22]=b,e[23]=f,e[24]=g,e[25]=h):h=e[25],h}function Qm(l){return t.jsxs("li",{children:[t.jsx("span",{children:l.label}),t.jsxs("time",{children:[Kt(l.startSeconds),"–",Kt(l.endSeconds)]})]},l.ordinal)}function Zm(l){return Number.isFinite(l.duration)&&l.duration>0?Math.min(1,Math.max(0,l.currentTime/l.duration)):0}function Wl(l){const e=X.c(58),{address:s,posterUrl:n,waveform:i,mediaUrl:a,playbackKind:o,alt:r,title:c,badges:d,meter:u,metadataLabel:p,pendingLabel:m,pendingIcon:b,children:f}=l,[g,h]=C.useState(!1),[y,x]=C.useState(!1),[j,v]=C.useState(0),[k,w]=C.useState(0),S=C.useRef(null),M=C.useRef(!1),N=o!==null&&a!==null,$=i!==null,P=$?i.length===0:n===null;let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=Y=>{S.current=Y,!(!Y||!M.current)&&(M.current=!1,Y.play().catch(()=>x(!1)))},e[0]=T):T=e[0];const A=T;let I;e[1]!==y?(I=Y=>{Y.preventDefault();const Q=S.current;if(y){Q?.pause();return}if(!Q){M.current=!0,h(!0);return}Q.play().catch(()=>x(!1))},e[1]=y,e[2]=I):I=e[2];const D=I;let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=Y=>{const Q=Y.currentTarget;v(Zm(Q)),w(Q.currentTime)},e[3]=F):F=e[3];const R=F;let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{x(!1),v(0),w(0)},e[4]=E):E=e[4];const z=E;let _;e[5]!==k||e[6]!==u||e[7]!==y?(_=u&&y?`${Kt(Math.floor(k))} / ${u.label}`:u?.label??null,e[5]=k,e[6]=u,e[7]=y,e[8]=_):_=e[8];const L=_,B=`cell-media${y?" cell-media-playing":""}`;let U;e[9]===Symbol.for("react.memo_cache_sentinel")?(U=()=>h(!0),e[9]=U):U=e[9];let q;e[10]!==y?(q=()=>{y||h(!1)},e[10]=y,e[11]=q):q=e[11];let H;e[12]===Symbol.for("react.memo_cache_sentinel")?(H=()=>h(!0),e[12]=H):H=e[12];let K;e[13]!==r||e[14]!==g||e[15]!==$||e[16]!==a||e[17]!==o||e[18]!==y||e[19]!==n||e[20]!==j||e[21]!==i?(K=$?i.length>0?t.jsx(nd,{peaks:i,progress:j}):t.jsx(Ui,{}):g&&a&&o==="video"?t.jsx("video",{ref:A,src:a,poster:n??void 0,muted:!y,playsInline:!0,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:R,onEnded:z}):n?t.jsx("img",{src:n,alt:r,loading:"lazy",decoding:"async"}):null,e[13]=r,e[14]=g,e[15]=$,e[16]=a,e[17]=o,e[18]=y,e[19]=n,e[20]=j,e[21]=i,e[22]=K):K=e[22];let se;e[23]!==g||e[24]!==$||e[25]!==a?(se=$&&g&&a&&t.jsx("audio",{ref:A,src:a,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:R,onEnded:z}),e[23]=g,e[24]=$,e[25]=a,e[26]=se):se=e[26];let ie;e[27]!==P||e[28]!==b||e[29]!==m||e[30]!==y?(ie=P&&!y&&t.jsxs("span",{className:"cell-media-pending-face","aria-hidden":"true",children:[b,t.jsx("span",{children:m})]}),e[27]=P,e[28]=b,e[29]=m,e[30]=y,e[31]=ie):ie=e[31];let V;e[32]!==d||e[33]!==p?(V=d.length>0&&t.jsx("div",{className:"cell-media-rail",role:"group","aria-label":p,children:d.map(t1)}),e[32]=d,e[33]=p,e[34]=V):V=e[34];let ce;e[35]!==u||e[36]!==L?(ce=L&&u&&t.jsx("time",{className:"cell-media-meter",dateTime:`PT${u.seconds}S`,title:"Duration",children:L}),e[35]=u,e[36]=L,e[37]=ce):ce=e[37];let W;e[38]!==s||e[39]!==N||e[40]!==y||e[41]!==D?(W=N&&t.jsx("button",{type:"button",className:"cell-media-play nodrag","aria-label":`${y?"Pause":"Play"} ${s}`,onClick:D,onPointerDown:e1,children:y?t.jsx(Ti,{size:13,strokeWidth:2,"aria-hidden":"true"}):t.jsx(Ps,{size:13,fill:"currentColor",strokeWidth:0,"aria-hidden":"true"})}),e[38]=s,e[39]=N,e[40]=y,e[41]=D,e[42]=W):W=e[42];let te;e[43]!==N||e[44]!==j?(te=N&&t.jsx("span",{className:"cell-media-progress","aria-hidden":"true",children:t.jsx("span",{style:{width:`${j*100}%`}})}),e[43]=N,e[44]=j,e[45]=te):te=e[45];let ae;return e[46]!==f||e[47]!==K||e[48]!==se||e[49]!==ie||e[50]!==V||e[51]!==ce||e[52]!==W||e[53]!==te||e[54]!==B||e[55]!==q||e[56]!==c?(ae=t.jsxs("div",{className:B,title:c,onPointerEnter:U,onPointerLeave:q,onFocus:H,children:[K,se,ie,V,ce,W,te,f]}),e[46]=f,e[47]=K,e[48]=se,e[49]=ie,e[50]=V,e[51]=ce,e[52]=W,e[53]=te,e[54]=B,e[55]=q,e[56]=c,e[57]=ae):ae=e[57],ae}function e1(l){return l.stopPropagation()}function t1(l){return t.jsx("span",{className:`cell-media-badge${l.emphasis==="generator"?" cell-media-badge-wide":""}`,title:l.title,children:l.label},l.key)}const s1=[{left:"12%",delay:0,duration:1.6},{left:"32%",delay:.7,duration:2.2},{left:"50%",delay:.3,duration:1.8},{left:"70%",delay:1.1,duration:1.5},{left:"88%",delay:.5,duration:2}];function n1(l){const e=X.c(2),{variant:s}=l;if((s===void 0?"rise":s)==="stream"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("div",{className:"cell-state-streaks","aria-hidden":"true",children:s1.map(l1)}),e[0]=a):a=e[0],a}let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"cell-state-shimmer","aria-hidden":"true"}),e[1]=i):i=e[1],i}function l1(l){return t.jsx("span",{className:"cell-state-streak",style:{left:l.left,animationDelay:`${l.delay}s`,animationDuration:`${l.duration}s`}},l.left)}const i1=1e3,a1=Array.from({length:gi},(l,e)=>e+1);function r1(l){const e=Math.max(0,Math.floor(l/1e3)),s=Math.floor(e/3600),n=Math.floor(e%3600/60),i=e%60,a=o=>o.toString().padStart(2,"0");return s>0?`${s}:${a(n)}:${a(i)}`:`${n}:${a(i)}`}function o1(l,e){return l<e?"done":l===e?"active":"pending"}function c1(l){const e=X.c(14),{phase:s}=l;let n;e[0]!==s.step?(n=a1.map(d=>t.jsx("span",{className:"cell-state-phase-step","data-status":o1(d,s.step)},d)),e[0]=s.step,e[1]=n):n=e[1];let i;e[2]!==n?(i=t.jsx("div",{className:"cell-state-phase-rail","aria-hidden":"true",children:n}),e[2]=n,e[3]=i):i=e[3];let a;e[4]!==s.label?(a=t.jsx("span",{children:s.label}),e[4]=s.label,e[5]=a):a=e[5];let o;e[6]!==s.step?(o=t.jsxs("span",{children:[s.step,"/",gi]}),e[6]=s.step,e[7]=o):o=e[7];let r;e[8]!==a||e[9]!==o?(r=t.jsxs("div",{className:"cell-state-phase-label",children:[a,o]}),e[8]=a,e[9]=o,e[10]=r):r=e[10];let c;return e[11]!==i||e[12]!==r?(c=t.jsxs("div",{className:"cell-state-phase",children:[i,r]}),e[11]=i,e[12]=r,e[13]=c):c=e[13],c}function d1(l){const e=X.c(32),{icon:s,label:n,address:i,startedAt:a,variant:o,meta:r,phase:c}=l,d=r===void 0?null:r,u=c===void 0?null:c,[p]=C.useState(m1),m=a??p,[b,f]=C.useState(u1);let g,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const F=setInterval(()=>f(Date.now()),i1);return()=>clearInterval(F)},h=[],e[0]=g,e[1]=h):(g=e[0],h=e[1]),C.useEffect(g,h);const y=Math.max(0,b-m);let x;e[2]!==y?(x=r1(y),e[2]=y,e[3]=x):x=e[3];const j=x;let v;e[4]!==n?(v=n.toLowerCase(),e[4]=n,e[5]=v):v=e[5];const k=`@${i} ${v}`;let w;e[6]!==o?(w=t.jsx(n1,{variant:o}),e[6]=o,e[7]=w):w=e[7];let S;e[8]!==s?(S=t.jsx("span",{className:"cell-state-overlay-icon","aria-hidden":"true",children:s}),e[8]=s,e[9]=S):S=e[9];let M;e[10]!==n?(M=t.jsx("strong",{children:n}),e[10]=n,e[11]=M):M=e[11];let N;e[12]!==j?(N=t.jsx("span",{className:"cell-state-timer","aria-hidden":"true",children:j}),e[12]=j,e[13]=N):N=e[13];let $;e[14]!==M||e[15]!==N?($=t.jsxs("div",{className:"cell-state-overlay-copy",children:[M,N]}),e[14]=M,e[15]=N,e[16]=$):$=e[16];let P;e[17]!==S||e[18]!==$?(P=t.jsxs("div",{className:"cell-state-clock-row",children:[S,$]}),e[17]=S,e[18]=$,e[19]=P):P=e[19];let T;e[20]!==d?(T=d&&t.jsx("span",{className:"cell-state-meta",title:d,children:d}),e[20]=d,e[21]=T):T=e[21];let A;e[22]!==u?(A=u&&t.jsx(c1,{phase:u}),e[22]=u,e[23]=A):A=e[23];let I;e[24]!==P||e[25]!==T||e[26]!==A?(I=t.jsxs("div",{className:"cell-state-overlay-body cell-state-clock-body",children:[P,T,A]}),e[24]=P,e[25]=T,e[26]=A,e[27]=I):I=e[27];let D;return e[28]!==I||e[29]!==k||e[30]!==w?(D=t.jsxs("div",{className:"cell-state-overlay cell-state-overlay-clock",role:"status","aria-label":k,"aria-live":"polite",children:[w,I]}),e[28]=I,e[29]=k,e[30]=w,e[31]=D):D=e[31],D}function u1(){return Date.now()}function m1(){return Date.now()}function Cn(l){l.stopPropagation()}function f1(l){const e=X.c(25),{error:s,label:n,address:i,meta:a,onRepair:o,onRetry:r,onDelete:c,disabled:d}=l,u=a===void 0?null:a,p=d===void 0?!1:d,m=p1;let b;e[0]!==n?(b=n.toLowerCase(),e[0]=n,e[1]=b):b=e[1];const f=`@${i} ${b}`;let g,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{className:"cell-state-scanlines","aria-hidden":"true"}),h=t.jsx("div",{className:"cell-state-failed-wash","aria-hidden":"true"}),e[2]=g,e[3]=h):(g=e[2],h=e[3]);let y;e[4]!==n?(y=t.jsx("strong",{children:n}),e[4]=n,e[5]=y):y=e[5];let x;e[6]!==s?(x=t.jsx("p",{className:"cell-state-failed-message",children:s}),e[6]=s,e[7]=x):x=e[7];let j;e[8]!==u?(j=u&&t.jsx("span",{className:"cell-state-meta",title:u,children:u}),e[8]=u,e[9]=j):j=e[9];let v;e[10]!==i||e[11]!==p||e[12]!==c||e[13]!==o||e[14]!==r?(v=(o||r||c)&&t.jsxs("div",{className:"cell-state-actions",children:[r&&t.jsxs("button",{type:"button",className:"cell-state-action cell-state-retry nodrag","aria-label":`Retry @${i}`,title:"Delete this failed output and generate again with the saved settings",disabled:p,onPointerDown:Cn,onClick:m(r),children:[t.jsx(Bn,{size:10,"aria-hidden":"true"}),"RETRY"]}),o&&t.jsxs("button",{type:"button",className:"cell-state-action cell-state-repair nodrag","aria-label":`Repair @${i} in chat`,title:"Send this failure to chat for a corrected re-run",onPointerDown:Cn,onClick:m(o),children:[t.jsx(oc,{size:10,"aria-hidden":"true"}),"REPAIR"]}),c&&t.jsxs("button",{type:"button",className:"cell-state-action cell-state-delete nodrag","aria-label":`Delete @${i}`,title:"Delete this cell now",onPointerDown:Cn,onClick:m(c),children:[t.jsx(os,{size:10,"aria-hidden":"true"}),"DELETE"]})]}),e[10]=i,e[11]=p,e[12]=c,e[13]=o,e[14]=r,e[15]=v):v=e[15];let k;e[16]!==v||e[17]!==y||e[18]!==x||e[19]!==j?(k=t.jsxs("div",{className:"cell-state-overlay-body cell-state-failed-body",children:[y,x,j,v]}),e[16]=v,e[17]=y,e[18]=x,e[19]=j,e[20]=k):k=e[20];let w;return e[21]!==s||e[22]!==k||e[23]!==f?(w=t.jsxs("div",{className:"cell-state-overlay cell-state-overlay-failed",role:"alert","aria-label":f,title:s,children:[g,h,k]}),e[21]=s,e[22]=k,e[23]=f,e[24]=w):w=e[24],w}function p1(l){return e=>{e.stopPropagation(),l()}}function h1(l){const e=X.c(25),{kind:s,address:n,status:i,statusStartedAt:a,statusError:o,icon:r,generator:c,generation:d,onRepair:u,onRetry:p,onDelete:m,disabled:b}=l,f=c===void 0?null:c,g=d===void 0?!1:d;let h;if(e[0]!==n||e[1]!==b||e[2]!==g||e[3]!==f||e[4]!==r||e[5]!==s||e[6]!==m||e[7]!==u||e[8]!==p||e[9]!==i||e[10]!==o||e[11]!==a){h=Symbol.for("react.early_return_sentinel");e:{const y=co(s,i,{error:o??null,startedAt:a??null});if(y.overlay==="clock"&&y.label){let x;e[13]!==g||e[14]!==i?(x=g?uo(i):null,e[13]=g,e[14]=i,e[15]=x):x=e[15],h=t.jsx(d1,{icon:r,label:y.label,address:n,startedAt:y.startedAt,variant:i==="downloading"?"stream":"rise",meta:f,phase:x});break e}if(y.overlay==="failed"&&y.error){const x=mo(y.error),j=fo(s)?"MEDIA FAILED":"GENERATION FAILED",v=x?void 0:u,k=x?p:void 0;let w;e[16]!==n||e[17]!==b||e[18]!==f||e[19]!==m||e[20]!==y||e[21]!==j||e[22]!==v||e[23]!==k?(w=t.jsx(f1,{error:y.error,label:j,address:n,meta:f,onRepair:v,onRetry:k,onDelete:m,disabled:b}),e[16]=n,e[17]=b,e[18]=f,e[19]=m,e[20]=y,e[21]=j,e[22]=v,e[23]=k,e[24]=w):w=e[24],h=w;break e}}e[0]=n,e[1]=b,e[2]=g,e[3]=f,e[4]=r,e[5]=s,e[6]=m,e[7]=u,e[8]=p,e[9]=i,e[10]=o,e[11]=a,e[12]=h}else h=e[12];return h!==Symbol.for("react.early_return_sentinel")?h:null}const Ji=He.columnCount*He.columnPitch-He.gap,Xl=200,b1=36,Gl=120,x1={width:Ji,height:He.squareSize};function g1(l,e,s){return l.edge==="start"?{start:Math.max(s.min,Math.min(l.end-1,e)),end:l.end}:{start:l.start,end:Math.min(s.max,Math.max(l.start+1,e))}}function $n(l){return`${Math.floor(l/60)}:${Math.floor(l%60).toString().padStart(2,"0")}`}function y1(l){const e=X.c(64),{assembly:s}=l,n=C.useRef(null),[i,a]=C.useState("");let o,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const T=document.activeElement,A=n.current;return A?.showModal(),A?.querySelector("input")?.focus(),()=>{A?.close(),bo(T instanceof HTMLElement?T:null)}},r=[],e[0]=o,e[1]=r):(o=e[0],r=e[1]),C.useEffect(o,r);const c=s.picker;if(!c)return null;let d,u,p,m,b,f,g,h,y,x,j,v,k;if(e[2]!==s||e[3]!==c.items||e[4]!==c.trackId||e[5]!==i){let T;e[19]!==i?(T=R=>R.label.toLowerCase().includes(i.toLowerCase()),e[19]=i,e[20]=T):T=e[20],d=c.items.filter(T),f=gs.createPortal,y=n,x="timeline-source-picker",j="Add a timeline clip",v="preserve",e[21]!==s?(k=R=>{R.preventDefault(),s.closePicker()},e[21]=s,e[22]=k):k=e[22],e[23]!==s.closePicker?(u=R=>{R.stopPropagation(),xo(R,{busy:!1,container:R.currentTarget,onClose:s.closePicker})},e[23]=s.closePicker,e[24]=u):u=e[24],e[25]!==s?(p=R=>{R.target===R.currentTarget&&s.closePicker()},e[25]=s,e[26]=p):p=e[26];let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("strong",{children:"Add a clip"}),e[27]=A):A=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(mt,{size:16}),e[28]=I):I=e[28],e[29]!==s.closePicker?(m=t.jsxs("header",{children:[A,t.jsx("button",{type:"button",onClick:s.closePicker,"aria-label":"Close clip picker",children:I})]}),e[29]=s.closePicker,e[30]=m):m=e[30];let D;e[31]===Symbol.for("react.memo_cache_sentinel")?(D=R=>a(R.target.value),e[31]=D):D=e[31],e[32]!==i?(b=t.jsx("input",{autoFocus:!0,"aria-label":"Filter timeline sources",placeholder:"Filter media by name",value:i,onChange:D}),e[32]=i,e[33]=b):b=e[33],g="timeline-source-list";let F;e[34]!==s||e[35]!==c.trackId?(F=R=>t.jsxs("button",{type:"button",disabled:s.busy,onClick:()=>{s.append(c.trackId,R.artifactId)},children:[R.thumbnailUrl?t.jsx("img",{src:R.thumbnailUrl,alt:"",loading:"lazy"}):t.jsx(St,{size:24}),t.jsx("span",{children:R.label}),t.jsx(es,{size:16})]},R.artifactId),e[34]=s,e[35]=c.trackId,e[36]=F):F=e[36],h=d.map(F),e[2]=s,e[3]=c.items,e[4]=c.trackId,e[5]=i,e[6]=d,e[7]=u,e[8]=p,e[9]=m,e[10]=b,e[11]=f,e[12]=g,e[13]=h,e[14]=y,e[15]=x,e[16]=j,e[17]=v,e[18]=k}else d=e[6],u=e[7],p=e[8],m=e[9],b=e[10],f=e[11],g=e[12],h=e[13],y=e[14],x=e[15],j=e[16],v=e[17],k=e[18];let w;e[37]!==d.length?(w=d.length===0&&t.jsx("p",{children:"No matching media on this page."}),e[37]=d.length,e[38]=w):w=e[38];let S;e[39]!==w||e[40]!==g||e[41]!==h?(S=t.jsxs("div",{className:g,children:[h,w]}),e[39]=w,e[40]=g,e[41]=h,e[42]=S):S=e[42];let M;e[43]!==s.error?(M=s.error&&t.jsx("p",{role:"alert",children:s.error}),e[43]=s.error,e[44]=M):M=e[44];let N;e[45]!==s||e[46]!==c.offset?(N=c.offset!==null&&t.jsx("button",{type:"button",disabled:s.busy,onClick:()=>{s.loadMore()},children:"Load more media"}),e[45]=s,e[46]=c.offset,e[47]=N):N=e[47];let $;e[48]!==u||e[49]!==p||e[50]!==m||e[51]!==b||e[52]!==S||e[53]!==M||e[54]!==N||e[55]!==y||e[56]!==x||e[57]!==j||e[58]!==v||e[59]!==k?($=t.jsxs("dialog",{ref:y,className:x,"aria-label":j,"data-composer-focus":v,onCancel:k,onKeyDown:u,onClick:p,children:[m,b,S,M,N]}),e[48]=u,e[49]=p,e[50]=m,e[51]=b,e[52]=S,e[53]=M,e[54]=N,e[55]=y,e[56]=x,e[57]=j,e[58]=v,e[59]=k,e[60]=$):$=e[60];let P;return e[61]!==f||e[62]!==$?(P=f($,document.body),e[61]=f,e[62]=$,e[63]=P):P=e[63],P}function j1(l){const e=X.c(185),{sequence:s,assets:n,assembly:i,disabled:a,frame:o,address:r,onSeek:c,onPreview:d,onExport:u,onRemove:p,presentation:m,toolbar:b,onSelectClip:f,onMoveClip:g,onRemoveClip:h,onTrimClip:y,trimBounds:x,rhythm:j}=l,v=m===void 0?"canvas":m,[k,w]=C.useState(v==="preview"?"fit":48),[S,M]=C.useState(0),[N,$]=C.useState(0),P=i.selectedClipId,[T,A]=C.useState(null),I=C.useRef(!1),[D,F]=C.useState(null),R=C.useRef(null),E=C.useRef(null),[z,_]=C.useState(120),[L,B]=C.useState(Ji-Xl),U=s?s.frameRate.numerator/s.frameRate.denominator:30;let q;if(e[0]!==s?.captions||e[1]!==s?.clips){const Re=s?.clips.reduce(C1,0)??0;q=s?.captions.reduce(N1,Re)??Re,e[0]=s?.captions,e[1]=s?.clips,e[2]=q}else q=e[2];const H=q,K=H/U,se=v==="preview"?Math.min(Gl,L/10):Gl,ie=Math.max(1,L-se)/Math.max(1,K),V=Math.min(k==="fit"?ie:k,8e6/Math.max(1,K)),ce=k==="fit"?L:Math.max(L,K*V+se),W=Math.min(S,ce-L);let te;e[3]!==s?.tracks?(te=s?.tracks.reduce(w1,void 0),e[3]=s?.tracks,e[4]=te):te=e[4];const ae=te;ae?.trackId;let Y;e[5]!==ae?.trackId||e[6]!==s?(Y=s?.tracks.filter(Re=>Re.kind==="audio"||Re.kind==="video"&&Re.trackId!==ae?.trackId&&s.clips.some(De=>De.trackId===Re.trackId))??[],e[5]=ae?.trackId,e[6]=s,e[7]=Y):Y=e[7];const Q=Y;let Z;if(e[8]!==s?.clips){Z=new Map;for(const Re of s?.clips??[]){const De=Z.get(Re.trackId)??[];De.push(Re),Z.set(Re.trackId,De)}e[8]=s?.clips,e[9]=Z}else Z=e[9];const re=Z;let ee;e[10]!==n?(ee=new Map(n.map(S1)),e[10]=n,e[11]=ee):ee=e[11];const J=ee;let de,fe;e[12]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{const Re=R.current,De=E.current;if(!Re||!De)return;const qe=new ResizeObserver(()=>{_(Re.clientHeight);const _e=Number.parseFloat(getComputedStyle(De).marginLeft)||Xl;B(Math.max(1,Math.min(De.clientWidth,Re.clientWidth-_e)))});return qe.observe(Re),qe.observe(De),()=>qe.disconnect()},fe=[],e[12]=de,e[13]=fe):(de=e[12],fe=e[13]),C.useEffect(de,fe);const ue=v==="preview"?64:b1,pe=Math.max(0,Math.min(Math.floor(N/ue),Q.length-1)-1);let me,he,ye,oe,G,le,be,je,we,$e,Ie,Ae,Fe,et,Ye,Ke;if(e[14]!==r||e[15]!==i||e[16]!==J||e[17]!==z||e[18]!==W||e[19]!==re||e[20]!==a||e[21]!==T||e[22]!==K||e[23]!==H||e[24]!==pe||e[25]!==ie||e[26]!==U||e[27]!==o||e[28]!==L||e[29]!==ae||e[30]!==u||e[31]!==g||e[32]!==d||e[33]!==p||e[34]!==h||e[35]!==c||e[36]!==f||e[37]!==y||e[38]!==V||e[39]!==v||e[40]!==j||e[41]!==P||e[42]!==s||e[43]!==b||e[44]!==ue||e[45]!==Q||e[46]!==D||e[47]!==x||e[48]!==k){const Re=Q.slice(pe,pe+Math.ceil(z/ue)+3),De=a||i.busy;let qe;e[65]!==P||e[66]!==s?.clips?(qe=s?.clips.find(Te=>Te.clipId===P),e[65]=P,e[66]=s?.clips,e[67]=qe):qe=e[67];const _e=qe;let ke;e[68]!==_e?.trackId||e[69]!==s?.tracks?(ke=s?.tracks.find(Te=>Te.trackId===_e?.trackId),e[68]=_e?.trackId,e[69]=s?.tracks,e[70]=ke):ke=e[70];const Qe=ke,nt=_e&&!Qe?.locked&&(Qe?.kind==="audio"||Qe?.trackId===ae?.trackId),Tt=Math.max(1,2**Math.ceil(Math.log2(100/V))),wt=Math.floor(W/V/Tt),Et=Array.from({length:Math.ceil(L/V/Tt)+2},(Te,Ce)=>(wt+Ce)*Tt);j?.markers;let Ze;if(e[71]!==W||e[72]!==U||e[73]!==L||e[74]!==V||e[75]!==j?.markers){Ze=[];for(const Te of j?.markers??[]){const Ce=Te.frame/U*V-W,kt=Ze[Ze.length-1],_t=kt?kt.frame/U*V-W:-1/0;if(!(Ce<0||Ce>L)){if(Ce-_t<(Te.bar?8:14)){Te.bar&&kt&&!kt.bar&&(Ze[Ze.length-1]=Te);continue}Ze.push(Te)}}e[71]=W,e[72]=U,e[73]=L,e[74]=V,e[75]=j?.markers,e[76]=Ze}else Ze=e[76];const ne=Ze;let xe;e[77]!==W||e[78]!==H||e[79]!==U||e[80]!==c||e[81]!==V?(xe=function(Ce,kt){const _t=kt.getBoundingClientRect(),Ut=(Ce-_t.left)*kt.clientWidth/_t.width;c(Math.max(0,Math.min(H-1,Math.round((Ut+W)/V*U))))},e[77]=W,e[78]=H,e[79]=U,e[80]=c,e[81]=V,e[82]=xe):xe=e[82];const Me=xe,Ge=function(Ce,kt){const _t=re.get(Ce.trackId)??[],Ut=Ce.kind==="video"&&Ce.trackId!==ae?.trackId,Lt=_t.filter(ve=>{const dt=ve.timelineStartFrame/U*V;return dt+ve.durationFrames/U*V>=W-100&&dt<=W+L+100});return t.jsxs("div",{className:`timeline-track timeline-track-${Ce.kind}`,"data-track-id":Ce.trackId,style:kt,children:[t.jsxs("div",{className:"timeline-track-label",children:[t.jsx("span",{title:Ce.name,children:Ut?`${Ce.name} · read only`:Ce.name}),!Ut&&t.jsx("button",{type:"button",disabled:De||Ce.locked,onClick:()=>{i.openPicker(Ce.trackId)},"aria-label":`Add clip to ${Ce.name}`,children:t.jsx(es,{size:14})}),Ce.kind==="audio"&&_t.length===0&&Q.filter(k1).length>1&&t.jsx("button",{type:"button",disabled:De||Ce.locked,onClick:()=>{i.removeTrack(Ce.trackId)},"aria-label":`Remove ${Ce.name}`,children:t.jsx(mt,{size:12})})]}),t.jsxs("div",{className:"timeline-track-lane",onClick:ve=>Me(ve.clientX,ve.currentTarget),children:[Lt.map(ve=>{const dt=J.get(ve.source.artifactId),Ht=D?.clipId===ve.clipId?D:null,Es=(Ht?Ht.start:T?.clipId===ve.clipId?T.frame:ve.timelineStartFrame)/U*V-W,cs=(Ht?Ht.end-Ht.start:ve.durationFrames)/U*V,ns=!!(y&&x&&P===ve.clipId&&Ce.kind==="video"&&!Ut&&!Ce.locked&&!De),As=j?.analysis?.artifactId===ve.source.artifactId?j.analysis:null,Xt=Ce.kind==="audio"?po(ve,As?.waveform??dt?.waveform??[],As?.durationSeconds??dt?.duration??0,U,Math.min(2048,Math.max(32,Math.ceil(cs/2)))):[],Ds=ho(Xt);return t.jsxs("button",{className:`timeline-clip${P===ve.clipId?" selected":""}${j?.masterClipId===ve.clipId?" timeline-master":""}`,type:"button","data-clip-id":ve.clipId,"aria-pressed":P===ve.clipId,title:`${dt?.label??"Clip"} · ${(ve.durationFrames/U).toFixed(2)}s`,style:{left:Es,width:Math.max(2,cs)},onPointerDown:st=>{!g||Ut||Ce.kind!=="video"||Ce.locked||De||st.button!==0||(I.current=!1,st.currentTarget.setPointerCapture(st.pointerId),A({clipId:ve.clipId,clientX:st.clientX,start:ve.timelineStartFrame,frame:ve.timelineStartFrame}))},onPointerMove:st=>{if(!T||T.clipId!==ve.clipId)return;Math.abs(st.clientX-T.clientX)>4&&(I.current=!0);const Rt=Math.max(0,T.start+(st.clientX-T.clientX)/V*U),Oe=st.altKey?Math.round(Rt):kl(Rt,j?.markers??[],j?.snap??"off",12/V*U);A({...T,frame:Oe})},onPointerUp:()=>{T?.clipId===ve.clipId&&I.current&&T.frame!==ve.timelineStartFrame&&g?.(ve,T.frame),A(null)},onPointerCancel:()=>{I.current=!1,A(null)},onKeyDown:st=>{st.key==="Escape"&&T&&(st.stopPropagation(),I.current=!1,A(null))},onClick:st=>{if(st.stopPropagation(),I.current){I.current=!1;return}i.selectClip(ve.clipId),f?.(ve),c(ve.timelineStartFrame)},children:[Ds&&t.jsx("svg",{className:"timeline-waveform",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:t.jsx("path",{d:Ds})}),dt?.thumbnailUrl&&Ce.kind==="video"&&cs>55&&t.jsx("img",{src:dt.thumbnailUrl,alt:"",loading:"lazy"}),t.jsx("span",{children:dt?.label??"Clip"}),ns&&["start","end"].map(st=>t.jsx("i",{className:`timeline-trim-handle ${st}`,title:`Drag to trim the ${st==="start"?"in":"out"} point`,"aria-hidden":"true",onClick:v1,onPointerDown:Rt=>{if(Rt.button!==0)return;Rt.stopPropagation(),Rt.currentTarget.setPointerCapture(Rt.pointerId);const Oe=ve.timelineStartFrame+ve.durationFrames;F({clipId:ve.clipId,edge:st,clientX:Rt.clientX,start:ve.timelineStartFrame,end:Oe,origin:st==="start"?ve.timelineStartFrame:Oe})},onPointerMove:Rt=>{if(!D||D.clipId!==ve.clipId||D.edge!==st||!x)return;const Oe=D.origin+(Rt.clientX-D.clientX)/V*U,zt=Rt.altKey?Math.round(Oe):kl(Oe,j?.markers??[],j?.snap??"off",12/V*U);F({...D,...g1(D,zt,x)})},onPointerUp:Rt=>{Rt.stopPropagation();const Oe=D;F(null),!(!Oe||Oe.clipId!==ve.clipId)&&(Oe.start===ve.timelineStartFrame&&Oe.end===ve.timelineStartFrame+ve.durationFrames||y?.(ve,st,Oe.start,Oe.end))},onPointerCancel:()=>F(null)},st))]},ve.clipId)}),_t.length===0&&t.jsxs("span",{className:"timeline-empty-lane",children:["Add ",Ce.kind," to begin"]}),ne.map(ve=>t.jsx("i",{className:`timeline-beat${ve.bar?" bar":""}${ve.manual?" manual":""}`,style:{left:ve.frame/U*V-W},"aria-hidden":"true"},ve.frame)),t.jsx("i",{className:"timeline-playhead",style:{left:o/U*V-W}})]})]},Ce.trackId)};we=`notebook-timeline${v==="preview"?" notebook-timeline-preview":""}`,$e=v==="canvas"?x1:void 0,Ie=`Timeline ${r}`,Ae="preserve";let at,Nt;e[83]===Symbol.for("react.memo_cache_sentinel")?(at=t.jsx(St,{size:15}),Nt=t.jsx("strong",{children:"Timeline"}),e[83]=at,e[84]=Nt):(at=e[83],Nt=e[84]);let Ct;e[85]!==r?(Ct=t.jsx("code",{children:r}),e[85]=r,e[86]=Ct):Ct=e[86];let ft;e[87]!==K?(ft=$n(K),e[87]=K,e[88]=ft):ft=e[88];let At;e[89]!==ft?(At=t.jsx("span",{children:ft}),e[89]=ft,e[90]=At):At=e[90];const jt=De||!s;let it;e[91]!==i?(it=()=>{i.addTrack()},e[91]=i,e[92]=it):it=e[92];let pt;e[93]!==jt||e[94]!==it?(pt=t.jsx("button",{type:"button",disabled:jt,onClick:it,children:"+ Audio track"}),e[93]=jt,e[94]=it,e[95]=pt):pt=e[95];let rt;e[96]!==H||e[97]!==d||e[98]!==s?(rt=d&&t.jsx("button",{type:"button",disabled:!s||H===0,onClick:d,children:"Preview"}),e[96]=H,e[97]=d,e[98]=s,e[99]=rt):rt=e[99];const Dt=De||H===0;let vt;e[100]!==u||e[101]!==Dt?(vt=t.jsx("button",{type:"button",disabled:Dt,onClick:u,children:"Export"}),e[100]=u,e[101]=Dt,e[102]=vt):vt=e[102];const ze=De||!nt;let Pt;e[103]!==i||e[104]!==h||e[105]!==_e?(Pt=()=>{_e&&(h?h(_e):i.removeClip(_e.clipId))},e[103]=i,e[104]=h,e[105]=_e,e[106]=Pt):Pt=e[106];let $t;e[107]!==ze||e[108]!==Pt?($t=t.jsx("button",{type:"button",disabled:ze,onClick:Pt,children:"Remove clip"}),e[107]=ze,e[108]=Pt,e[109]=$t):$t=e[109];let xt;e[110]!==ie||e[111]!==V?(xt=t.jsx("button",{type:"button","aria-label":"Zoom timeline out",onClick:()=>w(Math.max(Math.min(.25,ie),V/2)),children:"−"}),e[110]=ie,e[111]=V,e[112]=xt):xt=e[112];let gt;e[113]!==ie||e[114]!==V?(gt=t.jsx("button",{type:"button","aria-label":"Zoom timeline in",onClick:()=>w(Math.min(Math.max(768,ie),V*2)),children:"+"}),e[113]=ie,e[114]=V,e[115]=gt):gt=e[115];const Vt=k==="fit";let Ot;e[116]===Symbol.for("react.memo_cache_sentinel")?(Ot=()=>{w("fit"),M(0),E.current?.scrollTo({left:0})},e[116]=Ot):Ot=e[116];let ot;e[117]!==Vt?(ot=t.jsx("button",{type:"button","aria-pressed":Vt,onClick:Ot,children:"Fit"}),e[117]=Vt,e[118]=ot):ot=e[118];let ht;e[119]!==De||e[120]!==p?(ht=p&&t.jsx("button",{type:"button",disabled:De,"aria-label":"Remove Timeline element",onClick:p,children:t.jsx(os,{size:14})}),e[119]=De,e[120]=p,e[121]=ht):ht=e[121];let Ft;e[122]!==pt||e[123]!==rt||e[124]!==vt||e[125]!==$t||e[126]!==xt||e[127]!==gt||e[128]!==ot||e[129]!==ht?(Ft=t.jsxs("div",{className:"timeline-toolbar nodrag nopan nowheel",children:[pt,rt,vt,$t,xt,gt,ot,ht]}),e[122]=pt,e[123]=rt,e[124]=vt,e[125]=$t,e[126]=xt,e[127]=gt,e[128]=ot,e[129]=ht,e[130]=Ft):Ft=e[130],e[131]!==Ct||e[132]!==At||e[133]!==Ft?(Fe=t.jsxs("header",{className:"notebook-timeline-header",children:[at,Nt,Ct,At,Ft]}),e[131]=Ct,e[132]=At,e[133]=Ft,e[134]=Fe):Fe=e[134],e[135]!==b?(et=b&&t.jsx("div",{className:"timeline-music-toolbar",children:b}),e[135]=b,e[136]=et):et=e[136],G="timeline-assembly nodrag nopan nowheel",e[137]!==i.error||e[138]!==i.picker?(le=i.error&&!i.picker&&t.jsx("div",{role:"alert",className:"timeline-error",children:i.error}),e[137]=i.error,e[138]=i.picker,e[139]=le):le=e[139];const It=o/U;let yt;e[140]!==It?(yt=$n(It),e[140]=It,e[141]=yt):yt=e[141];let ct;e[142]!==yt?(ct=t.jsx("span",{children:yt}),e[142]=yt,e[143]=ct):ct=e[143];let Pe;e[144]!==Me?(Pe=Te=>Me(Te.clientX,Te.currentTarget),e[144]=Me,e[145]=Pe):Pe=e[145];const Ne=Et.map(Te=>t.jsx("span",{style:{left:Te*V-W},children:$n(Te)},Te));let Le;e[146]!==Pe||e[147]!==Ne?(Le=t.jsx("div",{className:"timeline-ruler","aria-label":"Timeline ruler",onClick:Pe,children:Ne}),e[146]=Pe,e[147]=Ne,e[148]=Le):Le=e[148],e[149]!==ct||e[150]!==Le?(be=t.jsxs("div",{className:"timeline-ruler-row",children:[ct,Le]}),e[149]=ct,e[150]=Le,e[151]=be):be=e[151],je=ae&&Ge(ae),he="timeline-audio-viewport",ye=R,e[152]===Symbol.for("react.memo_cache_sentinel")?(oe=Te=>$(Te.currentTarget.scrollTop),e[152]=oe):oe=e[152],Ye="timeline-audio-content";const Ue=Q.length*ue;e[153]!==Ue?(Ke={height:Ue},e[153]=Ue,e[154]=Ke):Ke=e[154],me=Re.map((Te,Ce)=>Ge(Te,{position:"absolute",top:(pe+Ce)*ue,height:ue,width:"100%"})),e[14]=r,e[15]=i,e[16]=J,e[17]=z,e[18]=W,e[19]=re,e[20]=a,e[21]=T,e[22]=K,e[23]=H,e[24]=pe,e[25]=ie,e[26]=U,e[27]=o,e[28]=L,e[29]=ae,e[30]=u,e[31]=g,e[32]=d,e[33]=p,e[34]=h,e[35]=c,e[36]=f,e[37]=y,e[38]=V,e[39]=v,e[40]=j,e[41]=P,e[42]=s,e[43]=b,e[44]=ue,e[45]=Q,e[46]=D,e[47]=x,e[48]=k,e[49]=me,e[50]=he,e[51]=ye,e[52]=oe,e[53]=G,e[54]=le,e[55]=be,e[56]=je,e[57]=we,e[58]=$e,e[59]=Ie,e[60]=Ae,e[61]=Fe,e[62]=et,e[63]=Ye,e[64]=Ke}else me=e[49],he=e[50],ye=e[51],oe=e[52],G=e[53],le=e[54],be=e[55],je=e[56],we=e[57],$e=e[58],Ie=e[59],Ae=e[60],Fe=e[61],et=e[62],Ye=e[63],Ke=e[64];let Ve;e[155]!==me||e[156]!==Ye||e[157]!==Ke?(Ve=t.jsx("div",{className:Ye,style:Ke,children:me}),e[155]=me,e[156]=Ye,e[157]=Ke,e[158]=Ve):Ve=e[158];let lt;e[159]!==he||e[160]!==ye||e[161]!==oe||e[162]!==Ve?(lt=t.jsx("div",{className:he,ref:ye,onScroll:oe,children:Ve}),e[159]=he,e[160]=ye,e[161]=oe,e[162]=Ve,e[163]=lt):lt=e[163];let Ee;e[164]===Symbol.for("react.memo_cache_sentinel")?(Ee=Re=>M(Re.currentTarget.scrollLeft),e[164]=Ee):Ee=e[164];let We;e[165]!==ce?(We=t.jsx("div",{className:"timeline-horizontal",ref:E,onScroll:Ee,children:t.jsx("div",{style:{width:ce,height:1}})}),e[165]=ce,e[166]=We):We=e[166];let Xe;e[167]!==G||e[168]!==le||e[169]!==be||e[170]!==je||e[171]!==lt||e[172]!==We?(Xe=t.jsxs("div",{className:G,children:[le,be,je,lt,We]}),e[167]=G,e[168]=le,e[169]=be,e[170]=je,e[171]=lt,e[172]=We,e[173]=Xe):Xe=e[173];let Je;e[174]!==i?(Je=i.picker&&t.jsx(y1,{assembly:i}),e[174]=i,e[175]=Je):Je=e[175];let tt;return e[176]!==we||e[177]!==$e||e[178]!==Ie||e[179]!==Ae||e[180]!==Fe||e[181]!==et||e[182]!==Xe||e[183]!==Je?(tt=t.jsxs("section",{className:we,style:$e,"aria-label":Ie,"data-composer-focus":Ae,children:[Fe,et,Xe,Je]}),e[176]=we,e[177]=$e,e[178]=Ie,e[179]=Ae,e[180]=Fe,e[181]=et,e[182]=Xe,e[183]=Je,e[184]=tt):tt=e[184],tt}function v1(l){return l.stopPropagation()}function k1(l){return l.kind==="audio"}function S1(l){return[l.artifactId,l]}function w1(l,e){return e.kind==="video"&&(!l||e.ordinal<l.ordinal)?e:l}function N1(l,e){return Math.max(l,e.timelineStartFrame+e.durationFrames)}function C1(l,e){return Math.max(l,e.timelineStartFrame+e.durationFrames)}function Yl(l){const e=X.c(10),{kind:s}=l;if(s==="video"||s==="generate_video"||s==="split_video"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Rs,{size:14}),e[0]=i):i=e[0],i}if(s==="image"||s==="generate_image"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Zt,{size:14}),e[1]=i):i=e[1],i}if(s==="audio"||s==="extract_audio"||s==="generate_audio"){let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ss,{size:14}),e[2]=i):i=e[2],i}if(s==="prompt"){let i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Ai,{size:14}),e[3]=i):i=e[3],i}if(s==="analyze"){let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(zn,{size:14}),e[4]=i):i=e[4],i}if(s==="analysis"){let i;return e[5]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Ms,{size:14}),e[5]=i):i=e[5],i}if(s==="character"){let i;return e[6]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Di,{size:14}),e[6]=i):i=e[6],i}if(s==="post"){let i;return e[7]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Pn,{size:14}),e[7]=i):i=e[7],i}if(s==="goal"){let i;return e[8]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Pn,{size:14}),e[8]=i):i=e[8],i}let n;return e[9]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(St,{size:14}),e[9]=n):n=e[9],n}function $1(l){return l==="generate_video"?"GEN VID":l==="generate_image"?"GEN IMG":l==="generate_audio"?"GEN AUD":ji(l)}function Jl(l){return yi(l.kind)?l.tool??l.model??l.operation??"Choose a generation action":l.kind==="video"||l.kind==="image"||l.kind==="audio"?`Select ${l.kind} media`:l.kind==="character"?"Select a character":l.kind==="extract_audio"?"Connect a video to extract audio":l.kind==="analysis"?"Run the connected Analyze cell":l.kind==="split_video"?"Configure a video range":l.kind==="concat"?"Connect clip:0 and clip:1":l.kind==="splice"?"Connect first and second":l.prompt||Wt(l.slot)}function I1(l){return l?.thumbnailUrl??l?.mediaUrl??null}function Ql(l){const e=X.c(18),{asset:s,artifactId:n,label:i,time:a}=l;let o;e[0]!==s?(o=I1(s),e[0]=s,e[1]=o):o=e[1];const r=o,c=n??i;let d;e[2]!==i||e[3]!==r?(d=r?t.jsx("img",{src:r,alt:`${i} frame`}):t.jsx(St,{size:24,"aria-hidden":!0}),e[2]=i,e[3]=r,e[4]=d):d=e[4];let u;e[5]!==i?(u=t.jsx("strong",{children:i}),e[5]=i,e[6]=u):u=e[6];let p;e[7]!==a?(p=a===null?"Frame pending":Kt(a),e[7]=a,e[8]=p):p=e[8];let m;e[9]!==p?(m=t.jsx("span",{children:p}),e[9]=p,e[10]=m):m=e[10];let b;e[11]!==u||e[12]!==m?(b=t.jsxs("figcaption",{children:[u,m]}),e[11]=u,e[12]=m,e[13]=b):b=e[13];let f;return e[14]!==c||e[15]!==d||e[16]!==b?(f=t.jsxs("figure",{title:c,children:[d,b]}),e[14]=c,e[15]=d,e[16]=b,e[17]=f):f=e[17],f}function R1(l){const e=X.c(13),{data:s}=l;let n;e[0]!==s.inputs?(n=Fo(s.inputs),e[0]=s.inputs,e[1]=n):n=e[1];const i=n,a=s.splitFrames?.first.asset,o=s.splitFrames?.first.artifactId??null,r=i?.startSeconds??null;let c;e[2]!==a||e[3]!==o||e[4]!==r?(c=t.jsx(Ql,{asset:a,artifactId:o,label:"First",time:r}),e[2]=a,e[3]=o,e[4]=r,e[5]=c):c=e[5];const d=s.splitFrames?.last.asset,u=s.splitFrames?.last.artifactId??null,p=i?.endSeconds??null;let m;e[6]!==d||e[7]!==u||e[8]!==p?(m=t.jsx(Ql,{asset:d,artifactId:u,label:"Last",time:p}),e[6]=d,e[7]=u,e[8]=p,e[9]=m):m=e[9];let b;return e[10]!==c||e[11]!==m?(b=t.jsxs("div",{className:"cell-split-frames",children:[c,m]}),e[10]=c,e[11]=m,e[12]=b):b=e[12],b}function M1(l){const e=X.c(48),{cellId:s,kind:n,ready:i,state:a,onFile:o,onFileError:r,onOpenLibrary:c}=l,d=C.useRef(null),[u,p]=C.useState(!1),m=a?.operation!==null&&a?.operation!==void 0;let b;e[0]!==m||e[1]!==s||e[2]!==o||e[3]!==r||e[4]!==i?(b=B=>{if(m||!i)return;const U=B?[...B]:[];if(U.length!==1){r(s,"Choose one file for this media slot.");return}o(s,U[0])},e[0]=m,e[1]=s,e[2]=o,e[3]=r,e[4]=i,e[5]=b):b=e[5];const f=b,g=`cell-media-slot nodrag nowheel${u?" cell-media-slot-dragging":""}`,h=`Empty ${n} media slot`;let y,x;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=B=>{Us(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),p(!0))},x=B=>{Us(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),p(!1))},e[6]=y,e[7]=x):(y=e[6],x=e[7]);let j;e[8]!==m||e[9]!==i?(j=B=>{Us(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),B.dataTransfer.dropEffect=i&&!m?"copy":"none")},e[8]=m,e[9]=i,e[10]=j):j=e[10];let v;e[11]!==f||e[12]!==m?(v=B=>{Us(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),p(!1),m||f(B.dataTransfer.files))},e[11]=f,e[12]=m,e[13]=v):v=e[13];const k=m||!i;let w;e[14]!==s||e[15]!==c?(w=B=>{B.stopPropagation(),c(s)},e[14]=s,e[15]=c,e[16]=w):w=e[16];let S;e[17]!==m?(S=m?t.jsx(ut,{size:22}):t.jsx(Hn,{size:22}),e[17]=m,e[18]=S):S=e[18];const M=m?"Attaching media…":`Add ${n}`;let N;e[19]!==M?(N=t.jsx("strong",{children:M}),e[19]=M,e[20]=N):N=e[20];let $;e[21]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx("span",{children:"Recent media or drop a file"}),e[21]=$):$=e[21];let P;e[22]!==S||e[23]!==N||e[24]!==k||e[25]!==w?(P=t.jsxs("button",{type:"button",className:"cell-media-slot-library",disabled:k,onClick:w,children:[S,N,$]}),e[22]=S,e[23]=N,e[24]=k,e[25]=w,e[26]=P):P=e[26];const T=m||!i;let A,I;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=B=>{B.stopPropagation(),d.current?.click()},I=t.jsx(sn,{size:13}),e[27]=A,e[28]=I):(A=e[27],I=e[28]);let D;e[29]!==T?(D=t.jsxs("button",{type:"button",className:"cell-media-slot-upload",disabled:T,onClick:A,children:[I,"Upload file"]}),e[29]=T,e[30]=D):D=e[30];const F=hi[n],R=m||!i;let E;e[31]!==f?(E=B=>{f(B.target.files),B.target.value=""},e[31]=f,e[32]=E):E=e[32];let z;e[33]!==F||e[34]!==R||e[35]!==E?(z=t.jsx("input",{ref:d,className:"cell-media-slot-input",type:"file",accept:F,disabled:R,onChange:E}),e[33]=F,e[34]=R,e[35]=E,e[36]=z):z=e[36];let _;e[37]!==a?(_=a?.error&&t.jsx("span",{className:"cell-media-slot-error",role:"alert",children:a.error}),e[37]=a,e[38]=_):_=e[38];let L;return e[39]!==P||e[40]!==D||e[41]!==g||e[42]!==z||e[43]!==_||e[44]!==h||e[45]!==j||e[46]!==v?(L=t.jsxs("section",{className:g,"aria-label":h,onDragEnter:y,onDragLeave:x,onDragOver:j,onDrop:v,children:[P,D,z,_]}),e[39]=P,e[40]=D,e[41]=g,e[42]=z,e[43]=_,e[44]=h,e[45]=j,e[46]=v,e[47]=L):L=e[47],L}const P1=["left","right","bottom"],T1=P1.flatMap(l=>Rn.map((e,s)=>({id:go(l,s),position:l==="left"?Cs.Left:l==="right"?Cs.Right:Cs.Bottom,style:l==="bottom"?{left:`${e*100}%`}:{top:`${e*100}%`}})));function E1(l){const e=X.c(10),{status:s}=l;if(!s)return null;let n;e[0]!==s?(n=s.replaceAll("-"," ").replaceAll("_"," "),e[0]=s,e[1]=n):n=e[1];const i=n,a=`cell-status cell-status-${s}`,o=`Status: ${i}`;let r;e[2]!==i||e[3]!==s?(r=s==="completed"?t.jsx(Qt,{size:11,strokeWidth:2.4,"aria-hidden":"true"}):t.jsx("span",{children:i}),e[2]=i,e[3]=s,e[4]=r):r=e[4];let c;return e[5]!==i||e[6]!==a||e[7]!==o||e[8]!==r?(c=t.jsx("span",{className:a,"aria-label":o,title:i,children:r}),e[5]=i,e[6]=a,e[7]=o,e[8]=r,e[9]=c):c=e[9],c}function Nf({id:l,data:e,selected:s}){const n=C.useContext(Um),i=C.useContext(Hm),a=C.useContext(Km),o=C.useContext(Vm),r=C.useContext(qm),c=C.useContext(Wm),d=C.useContext(Ym).get(l)??null,u=fc(),p=s&&o===l,m=e.asset?.mediaUrl,b=e.asset?.thumbnailUrl,f=e.targetInputs?.length?e.targetInputs:["input"],g=e.targetConnectionCount??0,h=e.targetInputConnectionCounts??{},y=yo(e.kind),x=y!==null&&jo(e.kind,e.outputArtifactId,g),j=e.asset?.type==="video"||e.asset?.type==="final",v=e.asset?.type==="audio",k=e.kind==="audio"||e.kind==="extract_audio",w=e.kind==="video"||e.kind==="image",S=!j&&e.kind==="image",M=e.kind==="prompt"||e.kind==="analyze",N=e.slot.row===0,$=[N?"top":"lower",...f,"|",...e.sourcePorts??[]].join("\0");C.useEffect(()=>{u(l)},[$,l,u]);const P=vo({type:e.kind,model:e.model,operation:e.operation,outputArtifactId:e.outputArtifactId,tool:e.tool},e.status),T=e.post?ko(e.post):So(e.kind,e.status),A=yi(e.kind),I=A||Sl({type:e.kind,inputs:e.inputs}),D=I&&[e.provider??e.producerProvider,e.model??e.producerModel].filter(oe=>typeof oe=="string"&&oe.length>0).join(" · ")||null,F=A&&e.model?r.get(e.model)??null:null,R=A?F??e.model??e.tool??null:null,E=A?ps(e.inputs?.generationMode):null,z=E&&/^[a-z]2[a-z]$/i.test(E)?E.toUpperCase():null,_=R?(()=>{const oe=wo(R);return z&&!oe.toUpperCase().includes(z)?`${oe} · ${z}`:oe})():null,L=A?No(e.inputs?.generationSettings):null,B=pi(e.model??"",e.inputs??{})??(L?ps(L.aspect_ratio):null),U=L?ps(L.duration)??ps(L.duration_seconds)??(typeof L.duration=="number"?String(L.duration):null):null,q=ji(e.kind),H=A&&U!==null&&B!==null,K=H?$1(e.kind):q,se=ps(e.prompt)||ps(e.inputs?.resolvedPrompt),ie=S?se??e.asset?.prompt??null:null,V=S&&e.model?r.get(e.model)??null:null,ce=M||A&&!!e.prompt,W=Wt(e.slot),te=e.frameProvenance&&[e.frameProvenance.sourceAddress,e.frameProvenance.atSeconds===null?null:Kt(e.frameProvenance.atSeconds)].filter(Boolean).join(" · ")||null,ae={audioInfo:e.asset?.audioInfo??null,durationSeconds:e.asset?.duration??null,hasOutput:!!e.outputArtifactId,inputs:e.inputs},Y=k&&v,Q=w&&!!(m||b),Z=Y?Co(ae):[],re=Y?$o(ae):null,ee=Q?S?Io({width:e.asset?.width??null,height:e.asset?.height??null,tool:V,model:e.model??e.tool??null,provenance:te}):Ro({aspectRatio:e.videoAspectRatio??null,width:e.asset?.width??null,height:e.asset?.height??null,tool:e.model?r.get(e.model)??null:null,model:e.model??e.tool??null,provenance:te}):[],J=Q&&j?Mo(e.videoDurationSeconds??e.asset?.duration??null):null,de=Po(e.status),fe=e.status==="error",ue=To(e.inputs,e.outputArtifactId),pe=(e.kind==="audio"||e.kind==="analysis"||e.kind==="extract_audio"||(e.kind==="image"||e.kind==="video")&&!Sl({type:e.kind,inputs:e.inputs}))&&ue.length>1,me=Math.max(1,ue.indexOf(e.outputArtifactId??"")+1),he=Xm(l),ye=(oe,G,le)=>{c.open(l,{x:oe,y:G},le)};return t.jsxs("article",{className:["cell-node",`cell-kind-${e.kind}`,`cell-family-${Do(e.kind)}`,s?"cell-node-selected":"",p?"cell-node-primary":"",de?"cell-node-running":"",e.status==="queued"?"cell-node-queued":"",fe?"cell-node-error":"",pe?"cell-node-version-stack":"",e.deleting?"cell-node-deleting":"",e.revealing?"cell-node-created":"",e.highlighted?"cell-node-highlight":""].filter(Boolean).join(" "),"aria-busy":de,"data-lane-family":Ao(e.kind),"data-selection":p?"primary":s?"selected":void 0,"data-highlight":e.highlighted?"generated":void 0,"data-version-count":ue.length,"data-cell-status":e.status,"data-context-menu-open":c.openCellId===l?"true":void 0,onContextMenu:oe=>{oe.preventDefault(),oe.stopPropagation(),ye(oe.clientX,oe.clientY,document.activeElement instanceof HTMLElement?document.activeElement:null)},onKeyDown:oe=>{if(oe.key!=="ContextMenu"&&!(oe.shiftKey&&oe.key==="F10"))return;oe.preventDefault(),oe.stopPropagation();const G=oe.currentTarget.getBoundingClientRect();ye(G.left+Math.min(G.width-12,40),G.top+40,document.activeElement instanceof HTMLElement?document.activeElement:null)},children:[f.map((oe,G)=>t.jsx(jn,{type:"target",position:Cs.Top,id:oe,className:`cell-target-handle${N?" cell-target-handle-top-row":""}`,style:{left:`${(G+1)/(f.length+1)*100}%`}},oe)),f.map((oe,G)=>{const le=h[oe]??0;return le<2?null:t.jsx("span",{className:"cell-target-connection-count","aria-label":`${le} connections into ${oe}`,"data-connection-count":le,style:{left:`${(G+1)/(f.length+1)*100}%`},children:le},`${oe}-count`)}),T1.map(oe=>t.jsx(jn,{type:"source",position:oe.position,id:oe.id,isConnectable:!1,className:`cell-route-handle${e.sourcePorts?.includes(oe.id)?" cell-route-handle-active":""}`,style:oe.style},oe.id)),t.jsxs("section",{className:"cell-node-shell",children:[t.jsxs("header",{className:"cell-node-header",children:[t.jsxs("span",{className:"cell-node-type","aria-label":q,title:H?q:void 0,children:[t.jsx(Yl,{kind:e.kind}),t.jsx("span",{className:"cell-node-type-label","aria-hidden":"true",children:K})]}),e.post&&t.jsx("span",{className:"cell-generation-chips",children:t.jsx("span",{className:"cell-aspect-ratio",title:"Platform",children:Eo(e.post)})}),(A||d)&&t.jsxs("span",{className:"cell-generation-chips",children:[U&&t.jsxs("span",{className:"cell-aspect-ratio",title:"Duration",children:[U,/^\d+(\.\d+)?$/.test(U)?"s":""]}),B&&t.jsx("span",{className:"cell-aspect-ratio",title:"Aspect ratio",children:B}),d&&t.jsxs("span",{className:"cell-aspect-ratio cell-goal-mark",title:`Goal ${d}`,children:[t.jsx(Pn,{size:9,"aria-hidden":"true"}),d.split(" · ")[0]]})]}),P&&!A&&t.jsx("button",{type:"button",className:"cell-run-button nodrag",disabled:P.disabled,onClick:oe=>{oe.stopPropagation(),i(l)},children:P.label}),!P&&pe&&t.jsxs("span",{className:"cell-version-count","aria-label":`Current output version ${me} of ${ue.length}`,title:`Current output · version ${me} of ${ue.length}`,children:[t.jsx(Ns,{size:12,"aria-hidden":"true"}),"v",me,"/",ue.length]})]}),t.jsxs("div",{className:"cell-node-body",children:[e.kind==="post"?t.jsx(Dm,{post:e.post,source:e.postSource}):x&&y?t.jsx(M1,{cellId:l,kind:y,ready:n.ready,state:n.states[l],onFile:n.onFile,onFileError:n.onFileError,onOpenLibrary:n.onOpenLibrary}):e.kind==="split_video"?t.jsx(R1,{data:e}):e.kind==="analysis"?t.jsx(Jm,{analysisInfo:e.asset?.analysisInfo??null,fallbackShotCount:wl(e.inputs?.shotCount),fallbackSourceDurationSeconds:wl(e.inputs?.sourceDurationSeconds)}):Y?t.jsx(Wl,{address:W,posterUrl:null,waveform:e.asset?.waveform??[],mediaUrl:m??null,playbackKind:m?"audio":null,alt:e.label??W,badges:Z,meter:re,metadataLabel:Nl(q,Z,re,null),pendingLabel:"Waveform pending",pendingIcon:t.jsx(ss,{size:26,"aria-hidden":"true"})}):Q?t.jsx(Wl,{address:W,posterUrl:b??(j?null:m??null),waveform:null,mediaUrl:m??null,playbackKind:j&&m?"video":null,alt:e.label??W,title:ie??void 0,badges:ee,meter:J,metadataLabel:Nl(q,ee,J,ie),pendingLabel:"Poster pending",pendingIcon:t.jsx(St,{size:26,"aria-hidden":"true"}),children:t.jsx(Od,{inputs:e.inputs})}):t.jsxs("div",{className:`cell-copy ${ce?"cell-copy-text":""}`,children:[_&&t.jsx("span",{className:"cell-model-line",title:_,children:_}),ce?t.jsx("p",{title:e.prompt||void 0,children:e.prompt||Jl(e)}):t.jsx(Mi,{size:28}),!ce&&t.jsx("span",{children:_?"Add a prompt":Jl(e)})]}),t.jsx(h1,{kind:e.kind,address:ti(e.slot),status:e.status,statusStartedAt:e.statusStartedAt,statusError:e.statusError,icon:t.jsx(Yl,{kind:e.kind}),generator:D,generation:I,onRepair:I?()=>{a.repairCell(l)}:void 0,onRetry:e.inputs?.producerCellId?()=>{a.retryCell(l)}:void 0,disabled:!a.ready,onDelete:()=>{a.deleteCell(l)}})]}),t.jsxs("footer",{className:"cell-node-footer",children:[t.jsx("strong",{children:Wt(e.slot)}),t.jsxs("span",{className:"cell-node-footer-actions",children:[t.jsx(E1,{status:T}),t.jsx("button",{type:"button",className:"cell-context-menu-trigger nodrag","aria-label":`Open ${Wt(e.slot)} cell menu`,"aria-haspopup":"menu","aria-expanded":c.openCellId===l,"aria-controls":he,title:"Cell actions",onClick:oe=>{oe.preventDefault(),oe.stopPropagation();const G=oe.currentTarget.getBoundingClientRect();ye(G.right-4,G.bottom+4,oe.currentTarget)},children:t.jsx(qn,{size:16,"aria-hidden":"true"})})]})]})]}),t.jsx(jn,{type:"source",position:Cs.Bottom,id:"output",className:"cell-connect-handle"})]})}function Cf(l){const e=X.c(13),{id:s,data:n}=l,i=C.useContext(Gm);if(!i)return null;let a;e[0]!==n.slot?(a=Wt(n.slot),e[0]=n.slot,e[1]=a):a=e[1];let o,r,c;e[2]!==i||e[3]!==s?(o=u=>i.onSeek(s,u),r=()=>i.onPreview(s),c=()=>i.onRemove(s),e[2]=i,e[3]=s,e[4]=o,e[5]=r,e[6]=c):(o=e[4],r=e[5],c=e[6]);let d;return e[7]!==i||e[8]!==a||e[9]!==o||e[10]!==r||e[11]!==c?(d=t.jsx(j1,{...i,address:a,onSeek:o,onPreview:r,onRemove:c}),e[7]=i,e[8]=a,e[9]=o,e[10]=r,e[11]=c,e[12]=d):d=e[12],d}function $f(l){const e=X.c(262),{rhythm:s,sequence:n,assets:i,frame:a,correctionsOpen:o,onCorrectionsOpenChange:r}=l;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const d=C.useRef(c),[u,p]=C.useState(""),[m,b]=C.useState(""),[f,g]=C.useState(""),h=s.master,y=s.status==="queued"||s.status==="analyzing",x=n.frameRate.numerator/n.frameRate.denominator;let j;e[1]!==n.tracks?(j=new Set(n.tracks.filter(_1).map(F1)),e[1]=n.tracks,e[2]=j):j=e[2];const v=j;let k,w,S,M,N,$,P,T,A,I,D,F,R,E,z,_,L,B,U,q,H;if(e[3]!==i||e[4]!==v||e[5]!==x||e[6]!==a||e[7]!==h||e[8]!==m||e[9]!==s||e[10]!==n.clips||e[11]!==n.tracks||e[12]!==u){let ze;e[34]!==v?(ze=Pe=>v.has(Pe.trackId),e[34]=v,e[35]=ze):ze=e[35];const Pt=n.clips.filter(ze);let $t;if(e[36]!==a||e[37]!==s.mapped){let Pe;e[39]!==a?(Pe=(Ne,Le)=>!Ne||Math.abs(Le.frame-a)<Math.abs(Ne.frame-a)?Le:Ne,e[39]=a,e[40]=Pe):Pe=e[40],$t=s.mapped.reduce(Pe,null),e[36]=a,e[37]=s.mapped,e[38]=$t}else $t=e[38];T=$t,M=s.rhythm.settings.correction?.bpm??s.analysis?.bpm,S=s.rhythm.settings.correction?.beatsPerBar??s.analysis?.beatsPerBar??null;let xt;e[41]!==s.mapped?(xt=s.mapped.filter(D1),e[41]=s.mapped,e[42]=xt):xt=e[42],w=xt.length,$=s.analysis?.barSource==="estimated"&&!s.rhythm.settings.correction;let gt;e[43]!==h||e[44]!==n.tracks?(gt=h&&!n.tracks.find(Pe=>Pe.trackId===h.trackId)?.locked,e[43]=h,e[44]=n.tracks,e[45]=gt):gt=e[45],N=gt;let Vt;e[46]!==S||e[47]!==M||e[48]!==h||e[49]!==s?(Vt=function(Ne,Le,Ue){const Te=Le===void 0?M??null:Le,Ce=Ue===void 0?S:Ue;h&&(g(""),s.save({masterClipId:h.clipId,correction:{objectHash:h.source.range.objectHash,analysisId:s.analysis?.analysisId??null,markers:Ne,bpm:Te,beatsPerBar:Ce}}))},e[46]=S,e[47]=M,e[48]=h,e[49]=s,e[50]=Vt):Vt=e[50],I=Vt;let Ot;e[51]===Symbol.for("react.memo_cache_sentinel")?(Ot=function(){const Ne=performance.now(),Le=d.current[d.current.length-1];if(d.current=Le===void 0||Ne-Le>3e3?[Ne]:[...d.current.slice(-7),Ne],d.current.length>1){const Ue=d.current.slice(1).map((Te,Ce)=>Te-d.current[Ce]).sort(A1);p(Math.min(400,Math.max(20,6e4/Ue[Math.floor(Ue.length/2)])).toFixed(1))}g(`${d.current.length} taps. Use Set grid from playhead when ready.`)},e[51]=Ot):Ot=e[51],H=Ot;let ot;e[52]!==M||e[53]!==x||e[54]!==a||e[55]!==h||e[56]!==m||e[57]!==I||e[58]!==u?(ot=function(){if(!h)return;const Ne=Number(u||M),Le=m?Number(m):null;if(!(Ne>=20&&Ne<=400)||Le!==null&&(!Number.isInteger(Le)||Le<1||Le>16)){g("Enter 20–400 BPM and, optionally, 1–16 beats per bar.");return}const Ue=h.source.range,Te=Ue.timeBase.numerator/Ue.timeBase.denominator,Ce=(Ue.startTick+Ue.durationTicks)*Te;if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead inside the soundtrack.");return}const kt=Math.min(Ce-Te,Cl(h,a,x)),_t=h.reverse?Math.floor((kt-Ue.startTick*Te)/(60/Ne))+1:Math.ceil((Ce-kt)/(60/Ne)),Ut=Array.from({length:Math.max(0,_t)},(Lt,ve)=>({id:`grid-${ve}`,timeSeconds:kt+(h.reverse?-1:1)*ve*60/Ne,bar:Le!==null&&ve%Le===0,manual:!0}));I(Ut,Ne,Le)},e[52]=M,e[53]=x,e[54]=a,e[55]=h,e[56]=m,e[57]=I,e[58]=u,e[59]=ot):ot=e[59],P=ot;let ht;e[60]!==x||e[61]!==a||e[62]!==h||e[63]!==s.markers||e[64]!==I?(ht=function(){if(!h)return;const Ne=h.source.range,Le=(Ne.startTick+Ne.durationTicks-1)*Ne.timeBase.numerator/Ne.timeBase.denominator,Ue=Math.min(Le,Cl(h,a,x));if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead inside the soundtrack.");return}s.markers.some(Te=>Math.abs(Te.timeSeconds-Ue)<.5/x)||I([...s.markers,{id:crypto.randomUUID(),timeSeconds:Ue,bar:!1,manual:!0}])},e[60]=x,e[61]=a,e[62]=h,e[63]=s.markers,e[64]=I,e[65]=ht):ht=e[65],k=ht;let Ft;e[66]!==S||e[67]!==M||e[68]!==a||e[69]!==h||e[70]!==m||e[71]!==T||e[72]!==s.markers||e[73]!==I?(Ft=function(){if(!h||!T)return;const Ne=m?Number(m):S;if(Ne===null||!Number.isInteger(Ne)||Ne<1||Ne>16){g("Enter 1–16 beats per bar.");return}if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead at the first beat of a bar inside the soundtrack.");return}I(_o(s.markers,T.id,Ne,M??null),M??null,Ne)},e[66]=S,e[67]=M,e[68]=a,e[69]=h,e[70]=m,e[71]=T,e[72]=s.markers,e[73]=I,e[74]=Ft):Ft=e[74],D=Ft;let It;e[75]!==x||e[76]!==h||e[77]!==T||e[78]!==s.markers||e[79]!==I?(It=function(Ne){if(!h||!T)return;const Le=T.timeSeconds+Ne/x*h.speed.numerator/h.speed.denominator*(h.reverse?-1:1);Le<0||I(s.markers.map(Ue=>Ue.id===T.id?{...Ue,timeSeconds:Le,manual:!0}:Ue))},e[75]=x,e[76]=h,e[77]=T,e[78]=s.markers,e[79]=I,e[80]=It):It=e[80],A=It,R="music-rhythm-controls",F="music-rhythm-row",q="Soundtrack",E="Master soundtrack",z=h?.clipId??"",_=s.busy,e[81]!==s?(L=Pe=>{s.save({masterClipId:Pe.target.value||null,correction:null})},e[81]=s,e[82]=L):L=e[82];const yt=Pt.length?"Choose audio clip":"Add audio to the timeline";e[83]!==yt?(B=t.jsx("option",{value:"",children:yt}),e[83]=yt,e[84]=B):B=e[84];let ct;e[85]!==i||e[86]!==x?(ct=Pe=>t.jsxs("option",{value:Pe.clipId,children:[i.find(Ne=>Ne.artifactId===Pe.source.artifactId)?.label??"Audio"," · ",(Pe.timelineStartFrame/x).toFixed(1),"s"]},Pe.clipId),e[85]=i,e[86]=x,e[87]=ct):ct=e[87],U=Pt.map(ct),e[3]=i,e[4]=v,e[5]=x,e[6]=a,e[7]=h,e[8]=m,e[9]=s,e[10]=n.clips,e[11]=n.tracks,e[12]=u,e[13]=k,e[14]=w,e[15]=S,e[16]=M,e[17]=N,e[18]=$,e[19]=P,e[20]=T,e[21]=A,e[22]=I,e[23]=D,e[24]=F,e[25]=R,e[26]=E,e[27]=z,e[28]=_,e[29]=L,e[30]=B,e[31]=U,e[32]=q,e[33]=H}else k=e[13],w=e[14],S=e[15],M=e[16],N=e[17],$=e[18],P=e[19],T=e[20],A=e[21],I=e[22],D=e[23],F=e[24],R=e[25],E=e[26],z=e[27],_=e[28],L=e[29],B=e[30],U=e[31],q=e[32],H=e[33];let K;e[88]!==E||e[89]!==z||e[90]!==_||e[91]!==L||e[92]!==B||e[93]!==U?(K=t.jsxs("select",{"aria-label":E,value:z,disabled:_,onChange:L,children:[B,U]}),e[88]=E,e[89]=z,e[90]=_,e[91]=L,e[92]=B,e[93]=U,e[94]=K):K=e[94];let se;e[95]!==K||e[96]!==q?(se=t.jsxs("label",{children:[q,K]}),e[95]=K,e[96]=q,e[97]=se):se=e[97];const ie=!h||s.busy||y;let V;e[98]!==s?(V=()=>{s.analyze(!!s.analysis)},e[98]=s,e[99]=V):V=e[99];const ce=s.analysis?"Analyze again":"Analyze beats";let W;e[100]!==ie||e[101]!==V||e[102]!==ce?(W=t.jsx("button",{type:"button",disabled:ie,onClick:V,children:ce}),e[100]=ie,e[101]=V,e[102]=ce,e[103]=W):W=e[103];let te;e[104]!==y||e[105]!==s?(te=y&&t.jsx("button",{type:"button",disabled:s.busy,onClick:()=>{s.cancel()},children:"Cancel analysis"}),e[104]=y,e[105]=s,e[106]=te):te=e[106];let ae;e[107]!==M||e[108]!==y||e[109]!==s.mapped.length||e[110]!==s.status?(ae=y?"Analyzing soundtrack…":s.status==="no-beats"?"Analysis complete. No reliable beats found. Set a grid below.":M?`${M.toFixed(1)} BPM · ${s.mapped.length} beats`:"Analyze the song or set a beat grid.",e[107]=M,e[108]=y,e[109]=s.mapped.length,e[110]=s.status,e[111]=ae):ae=e[111];let Y;e[112]!==ae?(Y=t.jsx("span",{role:"status",children:ae}),e[112]=ae,e[113]=Y):Y=e[113];let Q;e[114]!==s?(Q=()=>{s.load()},e[114]=s,e[115]=Q):Q=e[115];let Z;e[116]!==s.busy||e[117]!==Q?(Z=t.jsx("button",{type:"button",disabled:s.busy,onClick:Q,children:"Reload beats"}),e[116]=s.busy,e[117]=Q,e[118]=Z):Z=e[118];let re;e[119]!==F||e[120]!==se||e[121]!==W||e[122]!==te||e[123]!==Y||e[124]!==Z?(re=t.jsxs("div",{className:F,children:[se,W,te,Y,Z]}),e[119]=F,e[120]=se,e[121]=W,e[122]=te,e[123]=Y,e[124]=Z,e[125]=re):re=e[125];let ee;e[126]!==h||e[127]!==n.tracks?(ee=h&&(!h.enabled||h.audio?.muted||h.audioPolicy==="mute"||n.tracks.some(ze=>ze.trackId===h.trackId&&(!ze.enabled||ze.kind==="audio"&&ze.muted)))&&t.jsx("p",{children:"Soundtrack is muted or disabled. Its beat map is a timing guide."}),e[126]=h,e[127]=n.tracks,e[128]=ee):ee=e[128];let J;e[129]!==h?.reverse?(J=h?.reverse&&t.jsx("p",{children:"Reversed audio is heard in the export. Render the reversed soundtrack to audition it in this preview."}),e[129]=h?.reverse,e[130]=J):J=e[130];let de;e[131]!==s.analysis?.lowConfidence||e[132]!==s.mapped.length||e[133]!==s.rhythm.settings.correction?(de=s.analysis?.lowConfidence&&s.mapped.length>0&&!s.rhythm.settings.correction&&t.jsx("p",{children:"Beat timing is uncertain. Listen and adjust the markers."}),e[131]=s.analysis?.lowConfidence,e[132]=s.mapped.length,e[133]=s.rhythm.settings.correction,e[134]=de):de=e[134];let fe;e[135]!==s.rhythm.settings.correction?(fe=s.rhythm.settings.correction&&t.jsx("p",{children:"Using your corrected beat map. Reanalysis preserves this map."}),e[135]=s.rhythm.settings.correction,e[136]=fe):fe=e[136];const ue=w?`${w} ${$?"estimated bar starts":"bar starts"} · ${S??"Unknown"} beats per bar`:"Set bar starts";let pe;e[137]!==ue?(pe=t.jsx("strong",{children:ue}),e[137]=ue,e[138]=pe):pe=e[138];let me;e[139]!==$?(me=$&&t.jsx("p",{children:"Bars start at the first detected beat. Adjust them below if needed."}),e[139]=$,e[140]=me):me=e[140];let he;e[141]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx("p",{children:"Place the playhead on the first beat of a bar, then enter the number of beats per bar."}),e[141]=he):he=e[141];let ye;e[142]!==S?(ye=S?.toString()??"e.g. 4",e[142]=S,e[143]=ye):ye=e[143];let oe;e[144]===Symbol.for("react.memo_cache_sentinel")?(oe=ze=>b(ze.target.value),e[144]=oe):oe=e[144];let G;e[145]!==m||e[146]!==ye?(G=t.jsxs("label",{children:["Beats per bar",t.jsx("input",{name:"beats-per-bar",type:"number",min:"1",max:"16",value:m,placeholder:ye,onChange:oe})]}),e[145]=m,e[146]=ye,e[147]=G):G=e[147];const le=!N||!T||s.busy;let be;e[148]!==D||e[149]!==le?(be=t.jsx("button",{type:"button",disabled:le,onClick:D,children:"Set bars from playhead"}),e[148]=D,e[149]=le,e[150]=be):be=e[150];let je;e[151]!==G||e[152]!==be?(je=t.jsxs("div",{className:"music-rhythm-row",children:[G,be]}),e[151]=G,e[152]=be,e[153]=je):je=e[153];let we;e[154]!==x||e[155]!==T?(we=T&&t.jsxs("small",{children:["Use the beat at ",(T.frame/x).toFixed(3),"s as a bar start."]}),e[154]=x,e[155]=T,e[156]=we):we=e[156];let $e;e[157]!==pe||e[158]!==me||e[159]!==je||e[160]!==we?($e=t.jsxs("section",{className:"music-bar-setup","aria-label":"Bar setup",children:[pe,me,he,je,we]}),e[157]=pe,e[158]=me,e[159]=je,e[160]=we,e[161]=$e):$e=e[161];let Ie;e[162]!==r?(Ie=ze=>r(ze.currentTarget.open),e[162]=r,e[163]=Ie):Ie=e[163];let Ae;e[164]===Symbol.for("react.memo_cache_sentinel")?(Ae=t.jsx("summary",{children:"Correct the beat grid"}),e[164]=Ae):Ae=e[164];let Fe;e[165]!==M?(Fe=M?.toFixed(1)??"120",e[165]=M,e[166]=Fe):Fe=e[166];let et;e[167]===Symbol.for("react.memo_cache_sentinel")?(et=ze=>p(ze.target.value),e[167]=et):et=e[167];let Ye;e[168]!==Fe||e[169]!==u?(Ye=t.jsxs("label",{children:["BPM",t.jsx("input",{type:"number",min:"20",max:"400",value:u,placeholder:Fe,onChange:et})]}),e[168]=Fe,e[169]=u,e[170]=Ye):Ye=e[170];const Ke=!N||s.busy;let Ve;e[171]!==Ke||e[172]!==H?(Ve=t.jsx("button",{type:"button",disabled:Ke,onClick:H,children:"Tap tempo"}),e[171]=Ke,e[172]=H,e[173]=Ve):Ve=e[173];const lt=!N||s.busy;let Ee;e[174]!==P||e[175]!==lt?(Ee=t.jsx("button",{type:"button",disabled:lt,onClick:P,children:"Set grid from playhead"}),e[174]=P,e[175]=lt,e[176]=Ee):Ee=e[176];const We=!N||s.busy;let Xe;e[177]!==k||e[178]!==We?(Xe=t.jsx("button",{type:"button",disabled:We,onClick:k,children:"Add beat at playhead"}),e[177]=k,e[178]=We,e[179]=Xe):Xe=e[179];const Je=!N||!T||s.busy;let tt;e[180]!==T?.id||e[181]!==s.markers||e[182]!==I?(tt=()=>I(s.markers.filter(ze=>ze.id!==T?.id)),e[180]=T?.id,e[181]=s.markers,e[182]=I,e[183]=tt):tt=e[183];let Re;e[184]!==Je||e[185]!==tt?(Re=t.jsx("button",{type:"button",disabled:Je,onClick:tt,children:"Remove nearest beat"}),e[184]=Je,e[185]=tt,e[186]=Re):Re=e[186];const De=!N||!T||s.busy;let qe;e[187]!==A?(qe=()=>A(-1),e[187]=A,e[188]=qe):qe=e[188];let _e;e[189]!==De||e[190]!==qe?(_e=t.jsx("button",{type:"button",disabled:De,onClick:qe,children:"Beat −1 frame"}),e[189]=De,e[190]=qe,e[191]=_e):_e=e[191];const ke=!N||!T||s.busy;let Qe;e[192]!==A?(Qe=()=>A(1),e[192]=A,e[193]=Qe):Qe=e[193];let nt;e[194]!==ke||e[195]!==Qe?(nt=t.jsx("button",{type:"button",disabled:ke,onClick:Qe,children:"Beat +1 frame"}),e[194]=ke,e[195]=Qe,e[196]=nt):nt=e[196];const Tt=!N||!T||s.busy;let wt;e[197]!==T?.id||e[198]!==s.markers||e[199]!==I?(wt=()=>I(s.markers.map(ze=>ze.id===T?.id?{...ze,bar:!ze.bar,manual:!0}:ze)),e[197]=T?.id,e[198]=s.markers,e[199]=I,e[200]=wt):wt=e[200];let Et;e[201]!==Tt||e[202]!==wt?(Et=t.jsx("button",{type:"button",disabled:Tt,onClick:wt,children:"Toggle bar start"}),e[201]=Tt,e[202]=wt,e[203]=Et):Et=e[203];let Ze;e[204]!==Ye||e[205]!==Ve||e[206]!==Ee||e[207]!==Xe||e[208]!==Re||e[209]!==_e||e[210]!==nt||e[211]!==Et?(Ze=t.jsxs("div",{className:"music-rhythm-row",children:[Ye,Ve,Ee,Xe,Re,_e,nt,Et]}),e[204]=Ye,e[205]=Ve,e[206]=Ee,e[207]=Xe,e[208]=Re,e[209]=_e,e[210]=nt,e[211]=Et,e[212]=Ze):Ze=e[212];let ne;e[213]!==x||e[214]!==T?(ne=T&&t.jsxs("span",{children:["Nearest beat · ",(T.frame/x).toFixed(3),"s",T.manual?" · adjusted":""]}),e[213]=x,e[214]=T,e[215]=ne):ne=e[215];let xe;e[216]!==N||e[217]!==s.analysis?.beats.length||e[218]!==s.busy||e[219]!==s.markers||e[220]!==s.rhythm.settings.correction||e[221]!==I?(xe=s.analysis?.beats.length&&!s.rhythm.settings.correction?t.jsx("button",{type:"button",disabled:!N||s.busy,onClick:()=>I(s.markers),children:"Confirm detected beats"}):null,e[216]=N,e[217]=s.analysis?.beats.length,e[218]=s.busy,e[219]=s.markers,e[220]=s.rhythm.settings.correction,e[221]=I,e[222]=xe):xe=e[222];const Me=!s.rhythm.canUndo||s.busy;let Ge;e[223]!==s?(Ge=()=>{s.save("undo")},e[223]=s,e[224]=Ge):Ge=e[224];let at;e[225]!==Me||e[226]!==Ge?(at=t.jsx("button",{type:"button",disabled:Me,onClick:Ge,children:"Undo beat change"}),e[225]=Me,e[226]=Ge,e[227]=at):at=e[227];const Nt=!s.rhythm.canRedo||s.busy;let Ct;e[228]!==s?(Ct=()=>{s.save("redo")},e[228]=s,e[229]=Ct):Ct=e[229];let ft;e[230]!==Nt||e[231]!==Ct?(ft=t.jsx("button",{type:"button",disabled:Nt,onClick:Ct,children:"Redo beat change"}),e[230]=Nt,e[231]=Ct,e[232]=ft):ft=e[232];const At=!s.rhythm.settings.correction||s.busy;let jt;e[233]!==s?(jt=()=>{s.save({...s.rhythm.settings,correction:null})},e[233]=s,e[234]=jt):jt=e[234];let it;e[235]!==At||e[236]!==jt?(it=t.jsx("button",{type:"button",disabled:At,onClick:jt,children:"Use detected beats"}),e[235]=At,e[236]=jt,e[237]=it):it=e[237];let pt;e[238]!==ne||e[239]!==xe||e[240]!==at||e[241]!==ft||e[242]!==it?(pt=t.jsxs("div",{className:"music-rhythm-row",children:[ne,xe,at,ft,it]}),e[238]=ne,e[239]=xe,e[240]=at,e[241]=ft,e[242]=it,e[243]=pt):pt=e[243];let rt;e[244]!==o||e[245]!==Ie||e[246]!==Ze||e[247]!==pt?(rt=t.jsxs("details",{className:"music-rhythm-fixes",open:o,onToggle:Ie,children:[Ae,Ze,pt]}),e[244]=o,e[245]=Ie,e[246]=Ze,e[247]=pt,e[248]=rt):rt=e[248];let Dt;e[249]!==f||e[250]!==s.error?(Dt=(f||s.error)&&t.jsx("p",{role:"alert",children:f||s.error}),e[249]=f,e[250]=s.error,e[251]=Dt):Dt=e[251];let vt;return e[252]!==R||e[253]!==re||e[254]!==ee||e[255]!==J||e[256]!==de||e[257]!==fe||e[258]!==$e||e[259]!==rt||e[260]!==Dt?(vt=t.jsxs("div",{className:R,children:[re,ee,J,de,fe,$e,rt,Dt]}),e[252]=R,e[253]=re,e[254]=ee,e[255]=J,e[256]=de,e[257]=fe,e[258]=$e,e[259]=rt,e[260]=Dt,e[261]=vt):vt=e[261],vt}function A1(l,e){return l-e}function D1(l){return l.bar}function F1(l){return l.trackId}function _1(l){return l.kind==="audio"}function If(l){const e=X.c(90),{sources:s,trackId:n,startFrame:i,endFrame:a,fps:o,hasBars:r,busy:c,draft:d,onPlan:u,onOrder:p}=l,[m,b]=C.useState(""),[f,g]=C.useState(""),[h,y]=C.useState(4),[x,j]=C.useState("beats"),[v,k]=C.useState("0.25"),[w,S]=C.useState(!0),[M,N]=C.useState(!1),[$,P]=C.useState(!1);let T;e[0]!==p||e[1]!==s?(T=function(be,je){const we=s.map(O1),$e=be+je;if($e<0||$e>=we.length)return;const[Ie,Ae]=[we[$e],we[be]];we[be]=Ie,we[$e]=Ae,p(we)},e[0]=p,e[1]=s,e[2]=T):T=e[2];const A=T;let I;e[3]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("p",{children:"Cut the selected footage to the music. You review the draft before anything changes."}),e[3]=I):I=e[3];let D;e[4]!==f||e[5]!==a||e[6]!==o||e[7]!==h||e[8]!==v||e[9]!==u||e[10]!==w||e[11]!==$||e[12]!==M||e[13]!==s||e[14]!==m||e[15]!==i||e[16]!==n||e[17]!==x?(D=le=>{le.preventDefault(),n&&u({track_id:n,start_frame:Math.round(Number(m||i/o)*o),end_frame:Math.round(Number(f||a/o)*o),sources:s.map(B1),interval:h,unit:x,minimum_shot_frames:Math.max(1,Math.round(Number(v)*o)),preserve_existing:w,preserve_clip_ids:[],reuse_sources:M,allow_retiming:$,strategy:"beat_interval"})},e[4]=f,e[5]=a,e[6]=o,e[7]=h,e[8]=v,e[9]=u,e[10]=w,e[11]=$,e[12]=M,e[13]=s,e[14]=m,e[15]=i,e[16]=n,e[17]=x,e[18]=D):D=e[18];const F=i/o;let R;e[19]!==F?(R=F.toFixed(2),e[19]=F,e[20]=R):R=e[20];let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=le=>b(le.target.value),e[21]=E):E=e[21];let z;e[22]!==m||e[23]!==R?(z=t.jsxs("label",{children:["From (s)",t.jsx("input",{"aria-label":"Draft start seconds",type:"number",min:"0",step:"any",placeholder:R,value:m,onChange:E})]}),e[22]=m,e[23]=R,e[24]=z):z=e[24];const _=a/o;let L;e[25]!==_?(L=_.toFixed(2),e[25]=_,e[26]=L):L=e[26];let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=le=>g(le.target.value),e[27]=B):B=e[27];let U;e[28]!==f||e[29]!==L?(U=t.jsxs("label",{children:["To (s)",t.jsx("input",{"aria-label":"Draft end seconds",type:"number",min:"0",step:"any",placeholder:L,value:f,onChange:B})]}),e[28]=f,e[29]=L,e[30]=U):U=e[30];let q,H;e[31]===Symbol.for("react.memo_cache_sentinel")?(q=le=>y(Number(le.target.value)),H=[1,2,4,8].map(z1),e[31]=q,e[32]=H):(q=e[31],H=e[32]);let K;e[33]!==h?(K=t.jsxs("label",{children:["Cut every",t.jsx("select",{"aria-label":"Draft cut interval",value:h,onChange:q,children:H})]}),e[33]=h,e[34]=K):K=e[34];let se,ie;e[35]===Symbol.for("react.memo_cache_sentinel")?(se=le=>j(le.target.value),ie=t.jsx("option",{value:"beats",children:"beats"}),e[35]=se,e[36]=ie):(se=e[35],ie=e[36]);const V=!r;let ce;e[37]!==V?(ce=t.jsx("option",{value:"bars",disabled:V,children:"bars"}),e[37]=V,e[38]=ce):ce=e[38];let W;e[39]!==ce||e[40]!==x?(W=t.jsxs("select",{"aria-label":"Draft interval unit",value:x,onChange:se,children:[ie,ce]}),e[39]=ce,e[40]=x,e[41]=W):W=e[41];let te;e[42]===Symbol.for("react.memo_cache_sentinel")?(te=le=>k(le.target.value),e[42]=te):te=e[42];let ae;e[43]!==v?(ae=t.jsxs("label",{children:["Minimum shot (s)",t.jsx("input",{"aria-label":"Minimum shot seconds",type:"number",min:"0.04",step:"0.01",value:v,onChange:te})]}),e[43]=v,e[44]=ae):ae=e[44];let Y;e[45]===Symbol.for("react.memo_cache_sentinel")?(Y=le=>S(le.target.checked),e[45]=Y):Y=e[45];let Q;e[46]!==w?(Q=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:w,onChange:Y}),"Keep existing clips"]}),e[46]=w,e[47]=Q):Q=e[47];let Z;e[48]===Symbol.for("react.memo_cache_sentinel")?(Z=le=>N(le.target.checked),e[48]=Z):Z=e[48];let re;e[49]!==M?(re=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:M,onChange:Z}),"Allow repeated footage"]}),e[49]=M,e[50]=re):re=e[50];let ee;e[51]===Symbol.for("react.memo_cache_sentinel")?(ee=le=>P(le.target.checked),e[51]=ee):ee=e[51];let J;e[52]!==$?(J=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:$,onChange:ee}),"Allow speed changes"]}),e[52]=$,e[53]=J):J=e[53];const de=c||!n||s.length===0;let fe;e[54]!==de?(fe=t.jsx("button",{type:"submit",disabled:de,children:"Preview draft"}),e[54]=de,e[55]=fe):fe=e[55];let ue;e[56]!==U||e[57]!==K||e[58]!==W||e[59]!==ae||e[60]!==Q||e[61]!==re||e[62]!==J||e[63]!==fe||e[64]!==z?(ue=t.jsxs("div",{className:"music-rhythm-row",children:[z,U,K,W,ae,Q,re,J,fe]}),e[56]=U,e[57]=K,e[58]=W,e[59]=ae,e[60]=Q,e[61]=re,e[62]=J,e[63]=fe,e[64]=z,e[65]=ue):ue=e[65];let pe;if(e[66]!==c||e[67]!==A||e[68]!==s){let le;e[70]!==c||e[71]!==A||e[72]!==s.length?(le=(be,je)=>t.jsxs("li",{children:[t.jsx("b",{children:je+1}),t.jsx("span",{children:be.label}),t.jsx("button",{type:"button","aria-label":`Move ${be.label} earlier`,disabled:c||je===0,onClick:()=>A(je,-1),children:"↑"}),t.jsx("button",{type:"button","aria-label":`Move ${be.label} later`,disabled:c||je===s.length-1,onClick:()=>A(je,1),children:"↓"})]},be.artifactId),e[70]=c,e[71]=A,e[72]=s.length,e[73]=le):le=e[73],pe=s.map(le),e[66]=c,e[67]=A,e[68]=s,e[69]=pe}else pe=e[69];let me;e[74]!==pe?(me=t.jsx("ol",{className:"music-draft-order","aria-label":"Draft source order",children:pe}),e[74]=pe,e[75]=me):me=e[75];let he;e[76]!==s.length?(he=!s.length&&t.jsx("p",{children:"Select footage in Media, in the order you want it to appear."}),e[76]=s.length,e[77]=he):he=e[77];let ye;e[78]!==D||e[79]!==ue||e[80]!==me||e[81]!==he?(ye=t.jsxs("form",{onSubmit:D,children:[ue,me,he]}),e[78]=D,e[79]=ue,e[80]=me,e[81]=he,e[82]=ye):ye=e[82];let oe;e[83]!==d||e[84]!==o||e[85]!==s?(oe=d&&t.jsxs("div",{className:"music-draft-review","aria-label":"Draft review",children:[t.jsxs("strong",{children:[d.plan.summary," · ",d.preview.diff.removedClipIds.length," clips replaced"]}),d.warnings.map(L1),d.uncovered.map(le=>t.jsxs("p",{children:["Uncovered: ",(le.startFrame/o).toFixed(2),"–",(le.endFrame/o).toFixed(2),"s"]},le.startFrame)),t.jsxs("table",{children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Shot"}),t.jsx("th",{children:"Timeline"}),t.jsx("th",{children:"Source range"}),t.jsx("th",{children:"Speed"})]})}),t.jsx("tbody",{children:d.shots.map((le,be)=>t.jsxs("tr",{children:[t.jsxs("td",{children:[be+1," · ",s.find(je=>je.artifactId===le.artifactId)?.label??"Source"]}),t.jsxs("td",{children:[(le.startFrame/o).toFixed(2),"–",(le.endFrame/o).toFixed(2),"s"]}),t.jsxs("td",{children:[le.sourceStartSeconds.toFixed(2),"–",le.sourceEndSeconds.toFixed(2),"s"]}),t.jsxs("td",{children:[le.speed.toFixed(2),"×"]})]},le.clipId))})]})]}),e[83]=d,e[84]=o,e[85]=s,e[86]=oe):oe=e[86];let G;return e[87]!==ye||e[88]!==oe?(G=t.jsxs("section",{className:"music-draft-controls","aria-label":"Auto-cut to music",children:[I,ye,oe]}),e[87]=ye,e[88]=oe,e[89]=G):G=e[89],G}function L1(l){return t.jsx("p",{children:l},l)}function z1(l){return t.jsx("option",{value:l,children:l},l)}function B1(l){return{artifact_id:l.artifactId}}function O1(l){return l.artifactId}function Zl(l){const e=X.c(13),{label:s,options:n,value:i,disabled:a,stretch:o,onChange:r}=l,c=a===void 0?!1:a,u=(o===void 0?!1:o)?"mv-segmented stretch":"mv-segmented";let p;if(e[0]!==c||e[1]!==r||e[2]!==n||e[3]!==i){let b;e[5]!==c||e[6]!==r||e[7]!==i?(b=f=>t.jsx("button",{type:"button","aria-pressed":f.value===i,title:f.title,disabled:c||f.disabled,onClick:()=>{f.value!==i&&r(f.value)},children:f.label},f.value),e[5]=c,e[6]=r,e[7]=i,e[8]=b):b=e[8],p=n.map(b),e[0]=c,e[1]=r,e[2]=n,e[3]=i,e[4]=p}else p=e[4];let m;return e[9]!==s||e[10]!==u||e[11]!==p?(m=t.jsx("div",{className:u,role:"group","aria-label":s,children:p}),e[9]=s,e[10]=u,e[11]=p,e[12]=m):m=e[12],m}function ei(l){const e=X.c(26),{label:s,frame:n,fps:i,min:a,max:o,disabled:r,onCommit:c}=l;let d;e[0]!==i||e[1]!==n?(d=()=>bs(n,i),e[0]=i,e[1]=n,e[2]=d):d=e[2];const[u,p]=C.useState(d),[m,b]=C.useState(!1);let f;e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==a||e[7]!==c||e[8]!==u?(f=()=>{const w=Lo(u,i);if(w===null){b(!0);return}const S=Math.max(a,Math.min(o,w));b(!1),p(bs(S,i)),S!==n&&c(S)},e[3]=i,e[4]=n,e[5]=o,e[6]=a,e[7]=c,e[8]=u,e[9]=f):f=e[9];const g=f;let h;e[10]!==g||e[11]!==i||e[12]!==n?(h=w=>{w.key==="Enter"&&g(),w.key==="Escape"&&(w.stopPropagation(),p(bs(n,i)),b(!1))},e[10]=g,e[11]=i,e[12]=n,e[13]=h):h=e[13];const y=h;let x;e[14]!==s?(x=t.jsx("span",{children:s}),e[14]=s,e[15]=x):x=e[15];let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=w=>p(w.target.value),e[16]=j):j=e[16];let v;e[17]!==g||e[18]!==r||e[19]!==m||e[20]!==y||e[21]!==u?(v=t.jsx("input",{value:u,disabled:r,"aria-invalid":m,spellCheck:!1,onChange:j,onBlur:g,onKeyDown:y}),e[17]=g,e[18]=r,e[19]=m,e[20]=y,e[21]=u,e[22]=v):v=e[22];let k;return e[23]!==x||e[24]!==v?(k=t.jsxs("label",{className:"mv-field",children:[x,v]}),e[23]=x,e[24]=v,e[25]=k):k=e[25],k}function Rf(l){const e=X.c(49),{frame:s,durationFrames:n,fps:i,previousBeat:a,nextBeat:o,onTogglePlay:r,onSeek:c}=l;let d;e[0]!==i||e[1]!==s?(d=bs(s,i),e[0]=i,e[1]=s,e[2]=d):d=e[2];let u;e[3]!==d?(u=t.jsx("strong",{children:d}),e[3]=d,e[4]=u):u=e[4];let p;e[5]!==n||e[6]!==i?(p=bs(n,i),e[5]=n,e[6]=i,e[7]=p):p=e[7];let m;e[8]!==u||e[9]!==p?(m=t.jsxs("span",{className:"mv-timecode",children:[u," / ",p]}),e[8]=u,e[9]=p,e[10]=m):m=e[10];let b;e[11]!==c?(b=()=>c(0),e[11]=c,e[12]=b):b=e[12];let f;e[13]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(cc,{size:17}),e[13]=f):f=e[13];let g;e[14]!==b?(g=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Go to start",onClick:b,children:f}),e[14]=b,e[15]=g):g=e[15];const h=a===null;let y;e[16]!==c||e[17]!==a?(y=()=>{a!==null&&c(a)},e[16]=c,e[17]=a,e[18]=y):y=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(en,{size:18}),e[19]=x):x=e[19];let j;e[20]!==h||e[21]!==y?(j=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Previous beat",title:"Previous beat",disabled:h,onClick:y,children:x}),e[20]=h,e[21]=y,e[22]=j):j=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Ps,{size:17}),e[23]=v):v=e[23];let k;e[24]!==r?(k=t.jsx("button",{type:"button",className:"mv-play","aria-label":"Play or pause",title:"Play or pause (Space)",onClick:r,children:v}),e[24]=r,e[25]=k):k=e[25];const w=o===null;let S;e[26]!==o||e[27]!==c?(S=()=>{o!==null&&c(o)},e[26]=o,e[27]=c,e[28]=S):S=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(On,{size:18}),e[29]=M):M=e[29];let N;e[30]!==w||e[31]!==S?(N=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Next beat",title:"Next beat",disabled:w,onClick:S,children:M}),e[30]=w,e[31]=S,e[32]=N):N=e[32];let $;e[33]!==n||e[34]!==c?($=()=>c(n-1),e[33]=n,e[34]=c,e[35]=$):$=e[35];let P;e[36]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(dc,{size:17}),e[36]=P):P=e[36];let T;e[37]!==$?(T=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Go to end",onClick:$,children:P}),e[37]=$,e[38]=T):T=e[38];let A;e[39]!==j||e[40]!==k||e[41]!==N||e[42]!==T||e[43]!==g?(A=t.jsxs("div",{className:"mv-transport-buttons",children:[g,j,k,N,T]}),e[39]=j,e[40]=k,e[41]=N,e[42]=T,e[43]=g,e[44]=A):A=e[44];let I;e[45]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("span",{className:"mv-transport-spacer"}),e[45]=I):I=e[45];let D;return e[46]!==A||e[47]!==m?(D=t.jsxs("div",{className:"mv-transport",role:"toolbar","aria-label":"Transport",children:[m,A,I]}),e[46]=A,e[47]=m,e[48]=D):D=e[48],D}const U1=[{value:"fit",label:"Fit",title:"Show the full frame"},{value:"fill",label:"Fill",title:"Fill the frame, cropping edges"},{value:"crop",label:"Crop",title:"Use the clip crop"}];function Mf(l){const e=X.c(92),{clip:s,fps:n,trimStart:i,trimEnd:a,busy:o,editsDisabled:r}=l;let c;e[0]!==l.thumbnailUrl?(c=l.thumbnailUrl?t.jsx("img",{src:l.thumbnailUrl,alt:""}):t.jsx("span",{className:"mv-clip-swatch"}),e[0]=l.thumbnailUrl,e[1]=c):c=e[1];let d;e[2]!==l.label?(d=t.jsx("strong",{title:l.label,children:l.label}),e[2]=l.label,e[3]=d):d=e[3];const u=l.index,p=l.count,m=a-i;let b;e[4]!==n||e[5]!==m?(b=bs(m,n),e[4]=n,e[5]=m,e[6]=b):b=e[6];let f;e[7]!==l.count||e[8]!==l.index||e[9]!==b?(f=t.jsxs("small",{children:["Clip ",u," of ",p," · ",b]}),e[7]=l.count,e[8]=l.index,e[9]=b,e[10]=f):f=e[10];let g;e[11]!==d||e[12]!==f?(g=t.jsxs("div",{children:[d,f]}),e[11]=d,e[12]=f,e[13]=g):g=e[13];let h;e[14]!==c||e[15]!==g?(h=t.jsxs("header",{children:[c,g]}),e[14]=c,e[15]=g,e[16]=h):h=e[16];const y=`in-${s.clipId}-${i}`,x=a-1;let j;e[17]!==l||e[18]!==a?(j=Q=>l.onTrim("start",Q,a),e[17]=l,e[18]=a,e[19]=j):j=e[19];let v;e[20]!==o||e[21]!==n||e[22]!==l.trimMin||e[23]!==x||e[24]!==j||e[25]!==y||e[26]!==i?(v=t.jsx(ei,{label:"In point",frame:i,fps:n,min:l.trimMin,max:x,disabled:o,onCommit:j},y),e[20]=o,e[21]=n,e[22]=l.trimMin,e[23]=x,e[24]=j,e[25]=y,e[26]=i,e[27]=v):v=e[27];const k=`out-${s.clipId}-${a}`,w=i+1;let S;e[28]!==l||e[29]!==i?(S=Q=>l.onTrim("end",i,Q),e[28]=l,e[29]=i,e[30]=S):S=e[30];let M;e[31]!==o||e[32]!==n||e[33]!==l.trimMax||e[34]!==k||e[35]!==w||e[36]!==S||e[37]!==a?(M=t.jsx(ei,{label:"Out point",frame:a,fps:n,min:w,max:l.trimMax,disabled:o,onCommit:S},k),e[31]=o,e[32]=n,e[33]=l.trimMax,e[34]=k,e[35]=w,e[36]=S,e[37]=a,e[38]=M):M=e[38];let N;e[39]!==v||e[40]!==M?(N=t.jsxs("div",{className:"mv-field-pair",children:[v,M]}),e[39]=v,e[40]=M,e[41]=N):N=e[41];let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx("p",{className:"mv-hint",children:"Or drag the clip edges on the timeline. I and O set them at the playhead."}),e[42]=$):$=e[42];let P;e[43]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx("span",{children:"Speed"}),e[43]=P):P=e[43];const T=o||!l.retimable;let A;e[44]!==l.onSpeed||e[45]!==l.speed||e[46]!==l.speedOptions||e[47]!==T?(A=t.jsxs("div",{className:"mv-control",children:[P,t.jsx(Zl,{label:"Clip speed",options:l.speedOptions,value:l.speed,disabled:T,stretch:!0,onChange:l.onSpeed})]}),e[44]=l.onSpeed,e[45]=l.speed,e[46]=l.speedOptions,e[47]=T,e[48]=A):A=e[48];let I;e[49]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("span",{children:"Frame"}),e[49]=I):I=e[49];const D=s.transform?.fit??"fit";let F;e[50]!==r||e[51]!==l.onFit||e[52]!==D?(F=t.jsxs("div",{className:"mv-control",children:[I,t.jsx(Zl,{label:"Clip frame fit",options:U1,value:D,disabled:r,stretch:!0,onChange:l.onFit})]}),e[50]=r,e[51]=l.onFit,e[52]=D,e[53]=F):F=e[53];let R;e[54]!==N||e[55]!==A||e[56]!==F?(R=t.jsxs("div",{className:"mv-clip-body",children:[N,$,A,F]}),e[54]=N,e[55]=A,e[56]=F,e[57]=R):R=e[57];let E;e[58]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Kn,{size:15}),e[58]=E):E=e[58];let z;e[59]!==o||e[60]!==l.onSplit?(z=t.jsxs("button",{type:"button",disabled:o,onClick:l.onSplit,children:[E," Split at playhead"]}),e[59]=o,e[60]=l.onSplit,e[61]=z):z=e[61];const _=r||!l.canStretch;let L;e[62]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(Pi,{size:15}),e[62]=L):L=e[62];let B;e[63]!==l.onStretch||e[64]!==_?(B=t.jsxs("button",{type:"button",disabled:_,title:"Extend to the next clip or the end",onClick:l.onStretch,children:[L," Fill to next"]}),e[63]=l.onStretch,e[64]=_,e[65]=B):B=e[65];const U=r||!l.canMoveEarlier;let q;e[66]!==l?(q=()=>l.onMove(-1),e[66]=l,e[67]=q):q=e[67];let H;e[68]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx(en,{size:15}),e[68]=H):H=e[68];let K;e[69]!==U||e[70]!==q?(K=t.jsxs("button",{type:"button","aria-label":"Move earlier",disabled:U,onClick:q,children:[H," Earlier"]}),e[69]=U,e[70]=q,e[71]=K):K=e[71];const se=r||!l.canMoveLater;let ie;e[72]!==l?(ie=()=>l.onMove(1),e[72]=l,e[73]=ie):ie=e[73];let V;e[74]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(On,{size:15}),e[74]=V):V=e[74];let ce;e[75]!==se||e[76]!==ie?(ce=t.jsxs("button",{type:"button","aria-label":"Move later",disabled:se,onClick:ie,children:["Later ",V]}),e[75]=se,e[76]=ie,e[77]=ce):ce=e[77];let W;e[78]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(os,{size:15}),e[78]=W):W=e[78];let te;e[79]!==r||e[80]!==l.onDelete?(te=t.jsxs("button",{type:"button",className:"danger-button wide",disabled:r,onClick:l.onDelete,children:[W," Delete clip"]}),e[79]=r,e[80]=l.onDelete,e[81]=te):te=e[81];let ae;e[82]!==z||e[83]!==B||e[84]!==K||e[85]!==ce||e[86]!==te?(ae=t.jsxs("footer",{className:"mv-clip-actions",children:[z,B,K,ce,te]}),e[82]=z,e[83]=B,e[84]=K,e[85]=ce,e[86]=te,e[87]=ae):ae=e[87];let Y;return e[88]!==R||e[89]!==ae||e[90]!==h?(Y=t.jsxs("div",{className:"mv-clip-inspector",children:[h,R,ae]}),e[88]=R,e[89]=ae,e[90]=h,e[91]=Y):Y=e[91],Y}export{ef as $,xs as A,ut as B,Li as C,tf as D,mf as E,Yl as F,nf as G,J1 as H,lf as I,hf as J,yf as K,jf as L,ld as M,ad as N,Um as O,vc as P,Hm as Q,Xn as R,Zl as S,Gm as T,Km as U,Uc as V,qm as W,Ym as X,Z1 as Y,Cf as Z,Nf as _,af as a,gf as a0,vf as a1,pf as a2,xf as a3,bf as a4,Q1 as a5,Zc as b,of as c,cf as d,rf as e,uf as f,nd as g,Ui as h,df as i,sf as j,ff as k,Sf as l,wf as m,Vm as n,Wm as o,Xm as p,Ic as q,$f as r,If as s,tm as t,Ld as u,Rf as v,Mf as w,j1 as x,kf as y,Ll as z};