videobook 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +6 -2
  3. package/dist/archive-b2.js +1 -1
  4. package/dist/cli/args.js +42 -3
  5. package/dist/cli/config-command.js +17 -1
  6. package/dist/cli/doctor-command.js +15 -0
  7. package/dist/cli/har-command.js +86 -0
  8. package/dist/cli/main.js +13 -1
  9. package/dist/content-store.js +2 -1
  10. package/dist/diagnostics.js +1 -1
  11. package/dist/env-secrets.js +1 -0
  12. package/dist/generation-har.js +106 -0
  13. package/dist/har-capture.js +142 -0
  14. package/dist/har-export.js +238 -0
  15. package/dist/har-index.js +98 -0
  16. package/dist/har-retention.js +73 -0
  17. package/dist/har-settings.js +27 -0
  18. package/dist/jobs/_alibaba-upload.js +2 -4
  19. package/dist/jobs/_fal-upload.js +2 -4
  20. package/dist/jobs/_image-edit-adapter.js +1 -1
  21. package/dist/jobs/_kie-upload.js +2 -4
  22. package/dist/jobs/complete-provider-task.js +5 -2
  23. package/dist/jobs/generate-media.js +9 -1
  24. package/dist/jobs/image-subjects.js +1 -1
  25. package/dist/jobs/kie-paygate.js +10 -3
  26. package/dist/jobs/run-notebook.js +4 -1
  27. package/dist/jobs/xai-paygate.js +5 -2
  28. package/dist/media/adapters/kie.js +2 -1
  29. package/dist/media/cost.js +1 -1
  30. package/dist/package-version.js +18 -0
  31. package/dist/posts/dropbox-auth.js +1 -1
  32. package/dist/posts/post-metrics.js +2 -1
  33. package/dist/provider-usage.js +1 -18
  34. package/dist/queue.js +12 -1
  35. package/dist/serve.js +2 -0
  36. package/dist/tools/api-status.js +1 -1
  37. package/dist/tools/generate-media.js +3 -0
  38. package/dist/tools/generation-payload.js +17 -2
  39. package/dist/tools/get-generation-har.js +43 -0
  40. package/dist/tools/index.js +4 -0
  41. package/dist/tools/list-cell-generations.js +19 -0
  42. package/dist/tools/reconcile-project-work.js +18 -12
  43. package/dist/tools/set-har-capture.js +30 -0
  44. package/dist/upload.js +2 -1
  45. package/dist/usage-providers.js +48 -10
  46. package/dist/workspace-action-groups.js +2 -2
  47. package/dist/x/account.js +1 -1
  48. package/dist/x/authenticated-handle.js +1 -1
  49. package/dist/x/oauth-flow.js +1 -1
  50. package/dist/x/post-to-x.js +2 -1
  51. package/dist/x/x-tokens.js +2 -1
  52. package/package.json +15 -14
  53. package/ui/assets/{alive-captions-duTKsyll.js → alive-captions-Cj8C1tCN.js} +1 -1
  54. package/ui/assets/{confirm-bodies--2sc9DbH.js → confirm-bodies-BxWXwDf0.js} +1 -1
  55. package/ui/assets/{fullscreen-COrmiHPn.js → fullscreen-DyEncSdm.js} +1 -1
  56. package/ui/assets/{goal-ui-D5Xsm2EY.js → goal-ui-BdFeoSWh.js} +2 -2
  57. package/ui/assets/{index-DEKl00St.js → index-QZ8lbemN.js} +9 -9
  58. package/ui/assets/inspector-BC6xWkJU.js +1 -0
  59. package/ui/assets/{jobs-ui-DdP2Re41.js → jobs-ui-BudI4w0r.js} +1 -1
  60. package/ui/assets/{music-video-B709JZqa.js → music-video-CT4C55ok.js} +1 -1
  61. package/ui/assets/ui-mq0uIS5P.css +1 -0
  62. package/ui/assets/ui-z5r-p0K9.js +2 -0
  63. package/ui/assets/{vendor-BFupLz37.js → vendor-D8XcMav4.js} +2 -2
  64. package/ui/assets/{vendor-flow-CKiuzaeM.js → vendor-flow-nqTFQmTh.js} +1 -1
  65. package/ui/assets/vendor-mcp-D_C3EZPv.js +60 -0
  66. package/ui/assets/videobook-CsW453sb.js +21 -0
  67. package/ui/index.html +12 -12
  68. package/ui/assets/inspector-EBp3IhvH.js +0 -1
  69. package/ui/assets/ui-Oirr9VOf.css +0 -1
  70. package/ui/assets/ui-jRPWsNUw.js +0 -2
  71. package/ui/assets/vendor-mcp-DQEeVZH0.js +0 -67
  72. package/ui/assets/videobook-0DOLlhG2.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-D8XcMav4.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 Aa,z as Da,A as Ta,B as Ea,C as Gt,D as Fa,E as _a,F as La,G as za,H as Oa,I as Ba,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 Us,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 Ar,aH as Dr,aI as yl,aJ as Tr,aK as Er,aL as Fr,aM as _r,aN as Lr,aO as zr,aP as jl,aQ as Or,aR as Br,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 ao,bm as xi,bn as ro,bo as oo,bp as co,bq as gi,br as uo,bs as mo,bt as fo,bu as po,bv as ho,bw as bo,bx as kl,by as xo,bz as go,bA as yo,bB as jo,bC as vo,bD as ko,bE as So,bF as wo,bG as yi,bH as Sl,bI as ps,bJ as No,bK as Co,bL as ji,bM as $o,bN as Io,bO as Ro,bP as Mo,bQ as Po,bR as Ao,bS as Do,bT as To,bU as wl,bV as Nl,bW as Eo,bX as Fo,bY as _o,bZ as Hs,b_ as Cl,b$ as Lo,c0 as bs,c1 as zo}from"./videobook-CsW453sb.js";import{X as mt,A as Oo,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 Uo,S as Ho,e as en,E as Ko,D as Ps,R as On,f as rs,g as tn,h as Bn,H as Un,P as Vo,i as wi,j as qo,k as Ni,l as Ci,m as es,n as Hn,o as Wo,p as $i,N as Xo,q as Go,U as Yo,r as Ii,s as Jo,t as Ri,u as Qo,v as Zo,w as Kn,x as Mi,Z as ec,y as sn,z as Vn,G as Il,J as Ns,K as tc,O as Rl,Q as yn,Y as qn,_ as As,$ as Pi,a0 as sc,a1 as Rs,a2 as nc,a3 as os,a4 as lc,a5 as ic,a6 as Ai,a7 as Di,a8 as Ti,a9 as Ei,aa as ac,ab as rc,ac as Fi,ad as oc,ae as cc,af as Pn,ag as dc,ah as uc}from"./vendor-icons-CGqhCIXV.js";import{u as mc,B as fc,V as _i,P as Cs,a as pc,H as jn}from"./vendor-flow-nqTFQmTh.js";import{S as An,u as hc,i as Ml,I as bc,A as Wn,V as xc,b as gc,P as yc}from"./vendor-remotion-CH1HXrlc.js";const jc={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 vc(l){return l instanceof Error?l.message:String(l)}function kc({post:l,disabled:e,className:s,onLink:n}){const[i,a]=C.useState(""),[r,o]=C.useState(()=>ka(new Date().toISOString())),[c,d]=C.useState(!1),[u,f]=C.useState(null),m=e||c||!l.definition.source,b=async()=>{if(!(m||!i.trim()||!r)){d(!0),f(null);try{await n({url:i.trim(),posted_at:new Date(r).toISOString()})}catch(h){f(vc(h))}finally{d(!1)}}},p=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:jc[l.definition.platform],onChange:h=>a(h.target.value),onKeyDown:p}),t.jsx("label",{htmlFor:`${g}-at`,children:"Published at"}),t.jsx("input",{id:`${g}-at`,type:"datetime-local",value:r,disabled:m,onChange:h=>o(h.target.value),onKeyDown:p}),t.jsx("button",{type:"button",disabled:m||!i.trim()||!r,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 ef(l){const e=X.c(186),{post:s,cells:n,asset:i,bookId:a,call:r,onRefresh:o,onSelectCell:c,onDeliver:d,onReviewX:u,onDelete:f}=l,m=wa(r,a,o);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[p,g]=C.useState(b),h=p.platform??s.definition.platform,j=p.caption??s.definition.caption,x=p.credits??s.definition.credits,y=p.account??s.definition.account,v=p.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),[A,T]=C.useState(null);Na(!!s.runtime.icloud?.completedAt,r,a,s.id,T);const R=A?.phase??null,E=A?.error;let F;e[2]!==R||e[3]!==E?(F=Ca(R,E),e[2]=R,e[3]=E,e[4]=F):F=e[4];const I=F,D=!!(s.runtime.outbound||s.runtime.url||s.runtime.status==="scheduled");let L,_,z,O,U,q,H,K,se,ae,V,oe,W,te;if(e[5]!==y||e[6]!==m||e[7]!==i||e[8]!==a||e[9]!==r||e[10]!==j||e[11]!==n||e[12]!==x||e[13]!==p||e[14]!==I||e[15]!==D||e[16]!==$||e[17]!==v||e[18]!==S||e[19]!==d||e[20]!==o||e[21]!==u||e[22]!==c||e[23]!==h||e[24]!==s||e[25]!==k){let Z;e[40]!==s.definition.source?.cellId?(Z=ve=>ve.id===s.definition.source?.cellId,e[40]=s.definition.source?.cellId,e[41]=Z):Z=e[41];const de=n.find(Z),fe=s.runtime.metrics.at(-1),me=h!==s.definition.platform||j!==s.definition.caption||x!==s.definition.credits||y!==s.definition.account;let pe;e[42]!==m||e[43]!==s.id?(pe=(ve,Qe)=>{const nt=Qe===void 0?{}:Qe;return m.run(ve,{post_cell_id:s.id,...nt})},e[42]=m,e[43]=s.id,e[44]=pe):pe=e[44];const ue=pe;let be;e[45]!==a||e[46]!==r||e[47]!==o||e[48]!==s.id?(be=async ve=>{r&&(await r("link_post",{book_id:a,post_cell_id:s.id,...ve}),await o())},e[45]=a,e[46]=r,e[47]=o,e[48]=s.id,e[49]=be):be=e[49];const ye=be;V="post-inspector",oe="Post details";let ce;e[50]!==s.definition.platform?(ce=t.jsxs("span",{className:"post-eyebrow",children:[s.definition.platform," publication"]}),e[50]=s.definition.platform,e[51]=ce):ce=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 ie;e[54]!==ce||e[55]!==G?(ie=t.jsxs("div",{children:[ce,G]}),e[54]=ce,e[55]=G,e[56]=ie):ie=e[56];const he=`post-status post-status-${s.runtime.status}`;let ke;e[57]!==s.runtime.status?(ke=s.runtime.status.replaceAll("_"," "),e[57]=s.runtime.status,e[58]=ke):ke=e[58];let we;e[59]!==he||e[60]!==ke?(we=t.jsx("span",{className:he,children:ke}),e[59]=he,e[60]=ke,e[61]=we):we=e[61],e[62]!==ie||e[63]!==we?(W=t.jsxs("div",{className:"post-heading",children:[ie,we]}),e[62]=ie,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 Ie=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 Ne;e[67]!==s.definition.createdAt||e[68]!==s.definition.source?(Ne=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]=Ne):Ne=e[69],e[70]!==Ie||e[71]!==Ne?(L=t.jsxs("div",{className:"post-source",children:[Ie,Ne]}),e[70]=Ie,e[71]=Ne,e[72]=L):L=e[72],e[73]!==m.busy||e[74]!==n||e[75]!==s.definition.source||e[76]!==ue||e[77]!==k?(_=!s.definition.source&&t.jsxs("form",{onSubmit:ve=>{ve.preventDefault(),ue("update_post",{source_cell_id:k})},children:[t.jsxs("label",{children:["Source clip",t.jsxs("select",{"aria-label":"Source clip",value:k,onChange:ve=>w(ve.target.value),required:!0,children:[t.jsx("option",{value:"",children:"Choose a finished image or video"}),n.filter(Ic).map($c)]})]}),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]=ue,e[77]=k,e[78]=_):_=e[78];let Me;e[79]!==y||e[80]!==j||e[81]!==x||e[82]!==D||e[83]!==v||e[84]!==h||e[85]!==ue?(Me=ve=>{ve.preventDefault(),ue("update_post",D?{notes:v}:{platform:h,caption:j,credits:x,account:y,notes:v}).then(Qe=>{Qe&&g({})})},e[79]=y,e[80]=j,e[81]=x,e[82]=D,e[83]=v,e[84]=h,e[85]=ue,e[86]=Me):Me=e[86];let Fe;e[87]!==p?(Fe=ve=>g({...p,platform:ve.target.value}),e[87]=p,e[88]=Fe):Fe=e[88];let et;e[89]===Symbol.for("react.memo_cache_sentinel")?(et=Ia.map(Cc),e[89]=et):et=e[89];let Ye;e[90]!==D||e[91]!==h||e[92]!==Fe?(Ye=t.jsxs("label",{children:["Platform",t.jsx("select",{"aria-label":"Platform",disabled:D,value:h,onChange:Fe,children:et})]}),e[90]=D,e[91]=h,e[92]=Fe,e[93]=Ye):Ye=e[93];let Ke;e[94]!==p?(Ke=ve=>g({...p,account:ve.target.value}),e[94]=p,e[95]=Ke):Ke=e[95];let Ve;e[96]!==y||e[97]!==D||e[98]!==Ke?(Ve=t.jsxs("label",{children:["Account",t.jsx("input",{value:y,disabled:D,placeholder:"@account",onChange:Ke})]}),e[96]=y,e[97]=D,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 Te;e[103]!==p?(Te=ve=>g({...p,caption:ve.target.value}),e[103]=p,e[104]=Te):Te=e[104];let We;e[105]!==j||e[106]!==D||e[107]!==Te?(We=t.jsxs("label",{children:["Caption",t.jsx("textarea",{value:j,disabled:D,rows:4,onChange:Te,placeholder:"What will this post say?"})]}),e[105]=j,e[106]=D,e[107]=Te,e[108]=We):We=e[108];let Xe;e[109]!==p?(Xe=ve=>g({...p,credits:ve.target.value}),e[109]=p,e[110]=Xe):Xe=e[110];let Je;e[111]!==x||e[112]!==D||e[113]!==Xe?(Je=t.jsxs("label",{children:["Credits",t.jsx("textarea",{value:x,disabled:D,rows:2,onChange:Xe,placeholder:"Creator and source credits"})]}),e[111]=x,e[112]=D,e[113]=Xe,e[114]=Je):Je=e[114];let tt;e[115]!==p?(tt=ve=>g({...p,notes:ve.target.value}),e[115]=p,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 Ee=m.busy||!r,qe=D?"Save notes":"Save draft";let _e;e[120]!==Ee||e[121]!==qe?(_e=t.jsx("button",{disabled:Ee,children:qe}),e[120]=Ee,e[121]=qe,e[122]=_e):_e=e[122],e[123]!==Me||e[124]!==lt||e[125]!==We||e[126]!==Je||e[127]!==Re||e[128]!==_e?(z=t.jsxs("form",{onSubmit:Me,children:[lt,We,Je,Re,_e]}),e[123]=Me,e[124]=lt,e[125]=We,e[126]=Je,e[127]=Re,e[128]=_e,e[129]=z):z=e[129],e[130]!==m.error?(O=m.error&&t.jsx("p",{role:"alert",className:"post-error",children:m.error}),e[130]=m.error,e[131]=O):O=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]!==j||e[136]!==me||e[137]!==d||e[138]!==u||e[139]!==s||e[140]!==ue?(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||!j.trim()||me,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:()=>{ue("post")},children:"Retry saved X post"}),me&&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]=j,e[136]=me,e[137]=d,e[138]=u,e[139]=s,e[140]=ue,e[141]=q):q=e[141],e[142]!==I||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)}),I&&t.jsx("small",{children:I})]}),e[142]=I,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]!==r||e[149]!==me||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(Nc)]}):t.jsx(kc,{post:s,disabled:m.busy||!r||me,className:"post-delivery post-link-field",onLink:ye}),e[147]=m.busy,e[148]=r,e[149]=me,e[150]=ye,e[151]=s,e[152]=se):se=e[152],ae=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(ve=>t.jsxs("div",{children:[t.jsx("strong",{children:fe.values[ve]?.toLocaleString()??"—"}),t.jsx("span",{children:ve})]},ve))}),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:()=>{ue("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:ve=>{ve.currentTarget.open&&M(Pl())},children:[t.jsx("summary",{children:"Add manual observation"}),t.jsxs("form",{onSubmit:ve=>{ve.preventDefault();const Qe={};for(const nt of fn)$[nt]?.trim()&&(Qe[nt]=Number($[nt]));ue("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:ve=>M(ve.target.value)})]}),t.jsx("div",{className:"post-metric-inputs",children:fn.map(ve=>t.jsxs("label",{children:[ve,t.jsx("input",{type:"number",min:"0",step:"1",placeholder:"Unknown",value:$[ve]??"",onChange:Qe=>P({...$,[ve]:Qe.target.value})})]},ve))}),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(Sc)})]})]}),e[5]=y,e[6]=m,e[7]=i,e[8]=a,e[9]=r,e[10]=j,e[11]=n,e[12]=x,e[13]=p,e[14]=I,e[15]=D,e[16]=$,e[17]=v,e[18]=S,e[19]=d,e[20]=o,e[21]=u,e[22]=c,e[23]=h,e[24]=s,e[25]=k,e[26]=L,e[27]=_,e[28]=z,e[29]=O,e[30]=U,e[31]=q,e[32]=H,e[33]=K,e[34]=se,e[35]=ae,e[36]=V,e[37]=oe,e[38]=W,e[39]=te}else L=e[26],_=e[27],z=e[28],O=e[29],U=e[30],q=e[31],H=e[32],K=e[33],se=e[34],ae=e[35],V=e[36],oe=e[37],W=e[38],te=e[39];let le;e[153]!==s.definition.lineage.length?(le=t.jsxs("summary",{children:["Idea → clip → post (",s.definition.lineage.length," source cells)"]}),e[153]=s.definition.lineage.length,e[154]=le):le=e[154];let Y;if(e[155]!==n||e[156]!==c||e[157]!==s.definition.lineage){let Z;e[159]!==n||e[160]!==c?(Z=de=>{const fe=n.find(me=>me.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]=Z):Z=e[161],Y=s.definition.lineage.map(Z),e[155]=n,e[156]=c,e[157]=s.definition.lineage,e[158]=Y}else Y=e[158];let ee;e[162]!==Y?(ee=t.jsx("div",{className:"post-lineage",children:Y}),e[162]=Y,e[163]=ee):ee=e[163];let J;e[164]!==le||e[165]!==ee?(J=t.jsxs("details",{children:[le,ee]}),e[164]=le,e[165]=ee,e[166]=J):J=e[166];let re;e[167]!==f?(re=t.jsx("button",{type:"button",className:"post-delete",onClick:f,children:"Remove Post cell"}),e[167]=f,e[168]=re):re=e[168];let Q;return e[169]!==L||e[170]!==_||e[171]!==z||e[172]!==O||e[173]!==U||e[174]!==q||e[175]!==H||e[176]!==K||e[177]!==se||e[178]!==ae||e[179]!==J||e[180]!==re||e[181]!==V||e[182]!==oe||e[183]!==W||e[184]!==te?(Q=t.jsxs("section",{className:V,"aria-label":oe,children:[W,te,L,_,z,O,U,q,H,K,se,ae,J,re]}),e[169]=L,e[170]=_,e[171]=z,e[172]=O,e[173]=U,e[174]=q,e[175]=H,e[176]=K,e[177]=se,e[178]=ae,e[179]=J,e[180]=re,e[181]=V,e[182]=oe,e[183]=W,e[184]=te,e[185]=Q):Q=e[185],Q}function Sc(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(wc).join(" · ")})]},l.id??`${l.observedAt}-${l.source}`)}function wc(l){const[e,s]=l;return`${e}: ${s?.toLocaleString()??"—"}`}function Nc(l){return t.jsx("a",{href:l.tweet_url,target:"_blank",rel:"noreferrer",children:"Open reply ↗"},l.tweet_id)}function Cc(l){return t.jsx("option",{value:l,children:l==="x"?"X":l},l)}function $c(l){return t.jsxs("option",{value:l.id,children:[Wt(l.slot)," · ",l.label??l.type]},l.id)}function Ic(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 Rc(l){const e=X.c(17),{label:s,shortcut:n,divider:i}=l,a=i===void 0?!0:i,r=C.useContext(Li);if(!r)return null;let o;e[0]!==a?(o=a&&t.jsx("span",{className:"composer-dock-close-divider","aria-hidden":"true"}),e[0]=a,e[1]=o):o=e[1];const c=s?"composer-dock-close composer-dock-close-labeled":"composer-dock-close",d=s??r.hideLabel,u=n?"Escape":void 0,f=`${s??r.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 p;e[6]!==r.hide||e[7]!==c||e[8]!==d||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==b?(p=t.jsxs("button",{type:"button",className:c,"data-composer-dock-hide":"","aria-label":d,"aria-keyshortcuts":u,title:f,onClick:r.hide,children:[m,b]}),e[6]=r.hide,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=m,e[12]=b,e[13]=p):p=e[13];let g;return e[14]!==o||e[15]!==p?(g=t.jsxs(t.Fragment,{children:[o,p]}),e[14]=o,e[15]=p,e[16]=g):g=e[16],g}function zi(l){const e=X.c(35),{label:s,targetSelector:n,edge:i,minimum:a,reserve:r,onResize:o}=l,c=r===void 0?0:r,d=C.useRef(null),u=C.useRef(null);let f;e[0]!==a?(f={height:a,min:a,max:a},e[0]=a,e[1]=f):f=e[1];const[m,b]=C.useState(f);let p,g;e[2]!==a||e[3]!==c||e[4]!==n?(p=()=>{const P=d.current?.closest(n);if(!P)return;const A=()=>{const R=parseFloat(getComputedStyle(P).maxHeight),E=c>0&&P.parentElement?P.parentElement.clientHeight-c:window.innerHeight,F=Math.max(0,Math.min(Number.isFinite(R)?R:E,E)),I={height:Math.round(P.getBoundingClientRect().height),min:Math.min(a,F),max:Math.round(F)};b(D=>D.height===I.height&&D.min===I.min&&D.max===I.max?D:I)},T=new ResizeObserver(A);return T.observe(P),P.parentElement&&T.observe(P.parentElement),A(),()=>T.disconnect()},g=[a,c,n],e[2]=a,e[3]=c,e[4]=n,e[5]=p,e[6]=g):(p=e[5],g=e[6]),C.useLayoutEffect(p,g);let h;e[7]!==o||e[8]!==m.max||e[9]!==m.min?(h=P=>o(Math.round(Math.max(m.min,Math.min(m.max,P)))),e[7]=o,e[8]=m.max,e[9]=m.min,e[10]=h):h=e[10];const j=h,x=i==="top"?-1:1,y=`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 A=d.current?.closest(n);u.current={y:P.clientY,height:A?Math.round(A.getBoundingClientRect().height):m.height}},e[11]=m.height,e[12]=n,e[13]=k):k=e[13];let w;e[14]!==x||e[15]!==j?(w=P=>{const A=u.current;A&&j(A.height+x*(P.clientY-A.y))},e[14]=x,e[15]=j,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]!==j||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"?j(m.min):P.key==="End"?j(m.max):j(m.height+x*(P.key==="ArrowUp"?-24:24)))},e[19]=x,e[20]=j,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]!==y||e[31]!==v||e[32]!==k||e[33]!==w?($=t.jsx("div",{ref:d,className:y,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]=y,e[31]=v,e[32]=k,e[33]=w,e[34]=$):$=e[34],$}function Al(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 Dl(l){const e=X.c(65),{call:s,active:n,onToggle:i}=l,a=n===void 0?!0:n,r=C.useId(),o=C.useRef(null),c=C.useRef(null);let d,u;e[0]!==a||e[1]!==s.expanded?(d=()=>{const q=c.current,H=o.current;if(!q||!H)return;if(!a){q.hidePopover();return}if(!s.expanded)return;const K=()=>Al(q,H);K();const se=new ResizeObserver(K);se.observe(H);const ae=H.closest(".composer-history");return ae&&se.observe(ae),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 f=`mcp-call mcp-call-${s.phase}`,m=s.tool,b=s.expanded;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{className:"composer-history-kind mcp-call-channel",children:"ACTION"}),e[4]=p):p=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 j;e[9]!==s.phase?(j=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]=j):j=e[10];let x;e[11]!==s?(x=dl(s),e[11]=s,e[12]=x):x=e[12];let y;e[13]!==x?(y=t.jsx("span",{className:"mcp-call-state",children:x}),e[13]=x,e[14]=y):y=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Oo,{className:"mcp-call-details-icon",size:14,"aria-hidden":"true"}),e[15]=v):v=e[15];let k;e[16]!==j||e[17]!==y?(k=t.jsxs("span",{className:"mcp-call-trail",children:[j,y,v]}),e[16]=j,e[17]=y,e[18]=k):k=e[18];let w;e[19]!==s.expanded||e[20]!==r||e[21]!==k||e[22]!==h?(w=t.jsxs("button",{ref:o,type:"button",className:"composer-history-entry mcp-call-head",popoverTarget:r,"aria-haspopup":"dialog","aria-controls":r,"aria-expanded":b,children:[p,h,k]}),e[19]=s.expanded,e[20]=r,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"&&o.current&&Al(q.currentTarget,o.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 A;e[33]!==P?(A=t.jsx("span",{children:P}),e[33]=P,e[34]=A):A=e[34];let T;e[35]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(mt,{size:14,"aria-hidden":"true"}),e[35]=T):T=e[35];let R;e[36]!==r?(R=t.jsx("button",{type:"button",popoverTarget:r,popoverTargetAction:"hide","aria-label":"Close action details",autoFocus:!0,children:T}),e[36]=r,e[37]=R):R=e[37];let E;e[38]!==A||e[39]!==R?(E=t.jsxs("header",{className:"mcp-call-popover-head",children:[A,R]}),e[38]=A,e[39]=R,e[40]=E):E=e[40];const F=s.tool;let I;e[41]!==s?(I=dl(s),e[41]=s,e[42]=I):I=e[42];let D;e[43]!==s.tool||e[44]!==I?(D=t.jsxs("p",{className:"mcp-call-what",children:[F," · ",I]}),e[43]=s.tool,e[44]=I,e[45]=D):D=e[45];let L;e[46]!==s.args?(L=s.args.length>0&&t.jsx("dl",{className:"mcp-call-args",children:s.args.map(Mc)}),e[46]=s.args,e[47]=L):L=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 z;e[50]!==D||e[51]!==L||e[52]!==_?(z=t.jsxs("div",{className:"mcp-call-body",children:[D,L,_]}),e[50]=D,e[51]=L,e[52]=_,e[53]=z):z=e[53];let O;e[54]!==r||e[55]!==M||e[56]!==$||e[57]!==E||e[58]!==z?(O=t.jsxs("div",{ref:c,id:r,className:"mcp-call-popover",popover:"auto",role:"dialog","aria-label":M,onBeforeToggle:N,onToggle:$,onKeyDown:Pc,children:[E,z]}),e[54]=r,e[55]=M,e[56]=$,e[57]=E,e[58]=z,e[59]=O):O=e[59];let U;return e[60]!==s.tool||e[61]!==w||e[62]!==O||e[63]!==f?(U=t.jsxs("div",{className:f,"data-tool":m,children:[w,O]}),e[60]=s.tool,e[61]=w,e[62]=O,e[63]=f,e[64]=U):U=e[64],U}function Mc(l){return t.jsxs(C.Fragment,{children:[t.jsx("dt",{children:l.name}),t.jsx("dd",{children:l.value})]},l.name)}function Pc(l){l.key==="Escape"&&l.stopPropagation()}const Oi=C.createContext(null),Tl=28;function Ac(l){const e=X.c(39),{rows:s,phase:n,voicePresent:i,open:a,onToggleCall:r,connected:o,onDetailsChange:c,children:d}=l,u=o===void 0?!0:o,f=C.useId(),b=C.useContext(Oi)?.captionId??f,p=C.useRef(null),g=C.useRef(!0),h=C.useRef(void 0),[j,x]=C.useState(!1);let y;e[0]!==d||e[1]!==n||e[2]!==s||e[3]!==i?(y=!d&&In(n,s.length,i),e[0]=d,e[1]=n,e[2]=s,e[3]=i,e[4]=y):y=e[4];const v=y;let k;e[5]!==v||e[6]!==c||e[7]!==a||e[8]!==s?(k=()=>{const R=p.current;if(c?.(a&&!!R?.querySelector(".chat-turn-details[open]")),v||!R||!a)return;const E=s.filter(Tc).at(-1)?.sequence;E!==h.current&&(g.current=!0),h.current=E,g.current&&(R.scrollTop=R.scrollHeight);const F=R.scrollHeight-R.scrollTop-R.clientHeight<Tl;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=R=>{const E=R.currentTarget,F=E.scrollHeight-E.scrollTop-E.clientHeight<Tl;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]!==r||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(R=>t.jsx(Fc,{row:R,active:a,connected:u,onToggleCall:r,onDetailsChange:()=>c?.(!!p.current?.querySelector(".chat-turn-details[open]"))},Ec(R))),e[18]=d,e[19]=u,e[20]=c,e[21]=r,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:p,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 A;e[32]!==a||e[33]!==j?(A=a&&j&&t.jsx("button",{type:"button",className:"voice-captions-latest",onMouseDown:Dc,onClick:()=>{g.current=!0,x(!1);const R=p.current;R&&(R.scrollTop=R.scrollHeight)},children:"Latest"}),e[32]=a,e[33]=j,e[34]=A):A=e[34];let T;return e[35]!==A||e[36]!==S||e[37]!==P?(T=t.jsxs("div",{className:"composer-history-panel","data-history-open":S,children:[P,A]}),e[35]=A,e[36]=S,e[37]=P,e[38]=T):T=e[38],T}function Dc(l){return l.preventDefault()}function Tc(l){return l.kind==="caption"&&l.turn}function Ec(l){return l.kind==="status"?`status:${l.sequence}`:l.kind==="caption"?`caption:${l.caption.id}`:`call:${l.call.id}`}function Fc(l){const e=X.c(65),{row:s,active:n,onToggleCall:i,connected:a,onDetailsChange:r}=l;if(s.kind==="call"){let p;return e[0]!==n||e[1]!==i||e[2]!==s.call?(p=t.jsx(Dl,{call:s.call,active:n,onToggle:i}),e[0]=n,e[1]=i,e[2]=s.call,e[3]=p):p=e[3],p}if(s.kind==="status"){let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{className:"composer-history-kind",children:"STATUS"}),e[4]=p):p=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:[p,g]}),e[7]=s.goalId,e[8]=g,e[9]=h):h=e[9],h}const o=s.caption;if(s.turn){const p=s.turn;let g;e[10]!==a||e[11]!==p?(g=a&&si(p)&&p.status!=="review",e[10]=a,e[11]=p,e[12]=g):g=e[12];const h=g,j=p.id,x=p.status;let y;e[13]!==p.text?(y=t.jsx("p",{className:"chat-bubble chat-bubble-user","aria-label":"Your message",children:p.text}),e[13]=p.text,e[14]=y):y=e[14];let v;e[15]!==a||e[16]!==p?(v=ul(p,a),e[15]=a,e[16]=p,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]!==p?(S=ul(p,a),e[20]=a,e[21]=p,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]!==p.work?(P=p.work.map(_c),e[31]=p.work,e[32]=P):P=e[32];let A;e[33]!==n||e[34]!==i||e[35]!==s.calls?(A=s.calls?.map(I=>t.jsx(Dl,{call:I,active:n,onToggle:i},I.id)),e[33]=n,e[34]=i,e[35]=s.calls,e[36]=A):A=e[36];let T;e[37]!==P||e[38]!==A?(T=t.jsxs("div",{className:"chat-turn-work",children:[P,A]}),e[37]=P,e[38]=A,e[39]=T):T=e[39];let R;e[40]!==r||e[41]!==$||e[42]!==T?(R=t.jsxs("details",{className:"chat-turn-details",onToggle:r,children:[$,T]}),e[40]=r,e[41]=$,e[42]=T,e[43]=R):R=e[43];let E;e[44]!==p.reply?(E=p.reply&&t.jsx("p",{className:"chat-bubble chat-bubble-assistant","aria-label":"Copilot reply",children:p.reply}),e[44]=p.reply,e[45]=E):E=e[45];let F;return e[46]!==R||e[47]!==E||e[48]!==y||e[49]!==p.id||e[50]!==p.status?(F=t.jsxs("article",{className:"chat-turn","data-turn-id":j,"data-status":x,children:[y,R,E]}),e[46]=R,e[47]=E,e[48]=y,e[49]=p.id,e[50]=p.status,e[51]=F):F=e[51],F}const c=`composer-history-entry chat-bubble chat-bubble-${o.role}`,d=o.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 f;e[54]!==o.interrupted?(f=o.interrupted&&t.jsx("em",{children:" · interrupted"}),e[54]=o.interrupted,e[55]=f):f=e[55];let m;e[56]!==o.text||e[57]!==f?(m=t.jsxs("span",{className:"composer-history-text",children:[o.text,f]}),e[56]=o.text,e[57]=f,e[58]=m):m=e[58];let b;return e[59]!==o.final||e[60]!==o.role||e[61]!==c||e[62]!==u||e[63]!==m?(b=t.jsxs("p",{className:c,"data-final":o.final,"data-role":o.role,children:[u,m]}),e[59]=o.final,e[60]=o.role,e[61]=c,e[62]=u,e[63]=m,e[64]=b):b=e[64],b}function _c(l){return t.jsxs("p",{children:[t.jsx("span",{children:l.label}),t.jsx("span",{children:l.detail??l.state})]},l.key)}function El(l){const e=X.c(15),{dismissLabel:s,message:n,onDismiss:i,tone:a}=l,r=a==="error",o=`chat-bubble chat-bubble-assistant chat-feedback command-result ${r?"command-result-error":"command-result-ok"}`,c=r?"alert":"status",d=r?"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 f;e[2]!==n?(f=t.jsx("span",{children:n}),e[2]=n,e[3]=f):f=e[3];let m;e[4]!==u||e[5]!==f?(m=t.jsxs("div",{className:"chat-feedback-content",children:[u,f]}),e[4]=u,e[5]=f,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 p;return e[10]!==o||e[11]!==c||e[12]!==m||e[13]!==b?(p=t.jsxs("div",{className:o,role:c,"aria-live":"polite",children:[m,b]}),e[10]=o,e[11]=c,e[12]=m,e[13]=b,e[14]=p):p=e[14],p}function xs(l){const e=X.c(7),{asset:s,kindHint:n,videoFrame:i}=l,a=i===void 0?!1:i,[r,o]=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",f=d==="video"||d==="final"||n==="generate_video"||n==="split_video"||n==="concat"||n==="splice",m=d==="image"||n==="generate_image",b=a&&f&&!c?s?.mediaUrl:null;let p;return e[0]!==u||e[1]!==r||e[2]!==b||e[3]!==m||e[4]!==c||e[5]!==f?(p=t.jsx("span",{className:"inspector-source-thumb","aria-hidden":"true",children:c&&c!==r?t.jsx("img",{src:c,alt:"",loading:"lazy",decoding:"async",onError:()=>o(c)}):b&&b!==r?t.jsx("video",{src:`${b}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata",onError:()=>o(b)}):u?t.jsx(ss,{size:16}):f?t.jsx(St,{size:16}):m?t.jsx(Zt,{size:16}):t.jsx(Ms,{size:15})}),e[0]=u,e[1]=r,e[2]=b,e[3]=m,e[4]=c,e[5]=f,e[6]=p):p=e[6],p}function Lc(l){const e=X.c(8),{token:s,reference:n}=l,i=n?.asset,a=n?.type;let r;e[0]!==i||e[1]!==a?(r=t.jsx(xs,{asset:i,kindHint:a}),e[0]=i,e[1]=a,e[2]=r):r=e[2];let o;e[3]!==s?(o=t.jsx("span",{className:"composer-reference-address",children:s}),e[3]=s,e[4]=o):o=e[4];let c;return e[5]!==r||e[6]!==o?(c=t.jsxs(t.Fragment,{children:[r,o]}),e[5]=r,e[6]=o,e[7]=c):c=e[7],c}function Ks(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 zc({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),r=C.useRef(e.session),o=C.useRef(!1),c=C.useRef(0),d=C.useRef(new Set);return C.useImperativeHandle(l,()=>({element:()=>i.current?.dom??null,selection:()=>i.current?Ks(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 f=i.current;if(!f)return;const m=u.start<Ks(f).start?-1:1;f.dispatch(ml(f.state.tr,u,m).scrollIntoView())},replace:(u,f={start:u.length,end:u.length})=>{const m=i.current;m&&m.dispatch(us(vs(m.state.tr,u,f,a.current.rich!==!1)).scrollIntoView())}}),[]),C.useLayoutEffect(()=>{const u=n.current;if(!u)return;const f=a.current;let b=f.sessions.get(f.session)??al.create({schema:fl,doc:pl(f.value,f.rich!==!1),plugins:[pa(),rl({"Mod-z":ba,"Mod-Shift-z":ol,"Mod-y":ol}),rl(xa)]});is(b.doc)!==f.value&&(b=b.apply(us(vs(b.tr,f.value,{start:f.value.length,end:f.value.length},f.rich!==!1))));const p=x=>{let y=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(y.toLowerCase()),M=S?li(S):"Unavailable reference",N=[y,S?.label,M].filter(Boolean).join(" · ");v.dataset.reference=y,v.setAttribute("aria-label",N),v.title=N,k.render(t.jsx(Lc,{token:y,reference:S}))};return w(),d.current.add(w),{dom:v,update(S){return S.type!==x.type?!1:(y=String(S.attrs.token),w(),!0)},ignoreMutation:S=>S.type!=="selection",destroy(){d.current.delete(w),queueMicrotask(()=>k.unmount())}}},g=x=>{const y=i.current;if(!y)return;if(!y.composing&&!o.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=y.state;y.updateState(v.apply(x)),a.current.sessions.set(r.current,y.state);const k=Ks(y);v.doc.eq(y.state.doc)?v.selection.eq(y.state.selection)||a.current.onSelectionChange(k):a.current.onChange(is(y.state.doc),k)},h=(x,y,v)=>!y.clipboardData||x.state.selection.empty?!1:(y.preventDefault(),y.clipboardData.clearData(),y.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),j=new ha({mount:u},{state:b,editable:()=>!a.current.disabled,attributes:Fl(f),dispatchTransaction:g,nodeViews:{reference:p},clipboardTextSerializer:x=>x.content.textBetween(0,x.content.size,"",y=>String(y.attrs.token??"")),handleKeyDown:(x,y)=>{if(y.isComposing||y.altKey||y.ctrlKey||y.metaKey||y.shiftKey||!x.state.selection.empty)return!1;const{$from:v}=x.state.selection,k=y.key==="Backspace";if(!k&&y.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,y)=>{if(!y.clipboardData)return!1;y.preventDefault();const v=y.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,y)=>(a.current.onKeyDown(y),y.defaultPrevented),copy:(x,y)=>h(x,y,!1),cut:(x,y)=>h(x,y,!0),compositionstart:()=>(o.current=!0,a.current.onCompositionChange(!0),!1),compositionend:()=>(o.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=j,()=>{window.cancelAnimationFrame(c.current),a.current.sessions.set(r.current,j.state),i.current=null,j.destroy()}},[]),C.useLayoutEffect(()=>{const u=i.current,f=a.current.references;if(a.current=e,!u)return;const m=r.current!==e.session;if(m){r.current.includes(":actions-")?e.sessions.delete(r.current):e.sessions.set(r.current,u.state);let p=e.sessions.get(e.session)??al.create({schema:fl,doc:pl(e.value,e.rich!==!1),plugins:u.state.plugins});is(p.doc)!==e.value&&(p=p.apply(us(vs(p.tr,e.value,{start:e.value.length,end:e.value.length},e.rich!==!1)))),r.current=e.session,o.current=!1,u.updateState(p)}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(Ks(u)),f!==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 Oc(l){const e=X.c(44),{actions:s,groups:n,group:i,context:a,loading:r,error:o,listId:c,selectedIndex:d,onGroupChange:u,onClose:f,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 p;e[1]!==u?(p=T=>u(T.target.value),e[1]=u,e[2]=p):p=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(Uc),e[4]=n,e[5]=h):h=e[5];let j;e[6]!==i||e[7]!==p||e[8]!==h?(j=t.jsxs("label",{children:["Category",t.jsxs("select",{"aria-label":"Action category",value:i,onChange:p,children:[g,h]})]}),e[6]=i,e[7]=p,e[8]=h,e[9]=j):j=e[9];const x=r?"Loading actions…":`${s.length} actions`;let y;e[10]!==x?(y=t.jsx("span",{role:"status",children:x}),e[10]=x,e[11]=y):y=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]!==f?(k=t.jsx("button",{type:"button","aria-label":"Close action search",onClick:f,children:v}),e[13]=f,e[14]=k):k=e[14];let w;e[15]!==j||e[16]!==y||e[17]!==k?(w=t.jsxs("header",{children:[b,j,y,k]}),e[15]=j,e[16]=y,e[17]=k,e[18]=w):w=e[18];let S;e[19]!==o?(S=o&&t.jsx("p",{role:"alert",children:o}),e[19]=o,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 T;e[27]!==a||e[28]!==c||e[29]!==m||e[30]!==d?(T=(R,E)=>{const F=ii(R,a);return t.jsxs("button",{type:"button",role:"option",id:`${c}-option-${E}`,"aria-selected":E===d,className:E===d?"active":"","data-action-id":R.id,"data-command":R.command,onMouseDown:Bc,onClick:()=>m(R),children:[t.jsxs("span",{children:[t.jsx("strong",{children:R.title}),t.jsx("code",{children:R.command})]}),t.jsx("small",{children:R.description}),F&&t.jsx("small",{className:"composer-action-unavailable",children:F})]},R.id)},e[27]=a,e[28]=c,e[29]=m,e[30]=d,e[31]=T):T=e[31],M=s.map(T),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]!==r?(N=!r&&!s.length&&t.jsx("p",{children:"No matching actions. Try an operation, media type or command alias."}),e[32]=s.length,e[33]=r,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 A;return e[40]!==w||e[41]!==S||e[42]!==$?(A=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]=A):A=e[43],A}function Bc(l){return l.preventDefault()}function Uc(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 Bi=C.createContext(null);function Hc(l){const e=X.c(15),{voices:s,selectedVoiceId:n,playingVoiceId:i,disabled:a,onSelect:r,onTogglePreview:o}=l,c=a===void 0?!1:a;let d;if(e[0]!==c||e[1]!==r||e[2]!==o||e[3]!==i||e[4]!==n||e[5]!==s){let f;e[7]!==c||e[8]!==r||e[9]!==o||e[10]!==i||e[11]!==n?(f=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:Vc,onClick:()=>r(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:Kc,onClick:()=>o(m.voiceId,m.previewUrl),children:i===m.voiceId?"Pause":"Preview"})]},m.voiceId)},e[7]=c,e[8]=r,e[9]=o,e[10]=i,e[11]=n,e[12]=f):f=e[12],d=s.map(f),e[0]=c,e[1]=r,e[2]=o,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 Kc(l){return l.preventDefault()}function Vc(l){return l.preventDefault()}function qc(l){const e=X.c(32),{voices:s,selectedVoiceId:n,playingVoiceId:i,status:a,warning:r,loading:o,error:c,onSelect:d,onTogglePreview:u,onRefresh:f}=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 p;e[5]!==o||e[6]!==s.length?(p=o&&s.length===0&&t.jsx("p",{className:"speak-preview-status",children:"Loading voices…"}),e[5]=o,e[6]=s.length,e[7]=p):p=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=o?"Loading voices…":c?"Retry voices":s.length===0?"Load voices":"Refresh voices";let j;e[10]!==o||e[11]!==f||e[12]!==h?(j=t.jsx("button",{type:"button",className:"speak-preview-refresh",disabled:o,onMouseDown:Wc,onClick:f,children:h}),e[10]=o,e[11]=f,e[12]=h,e[13]=j):j=e[13];let x;e[14]!==d||e[15]!==u||e[16]!==i||e[17]!==n||e[18]!==s?(x=t.jsx(Hc,{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 y;e[20]!==a||e[21]!==r?(y=(r||a==="fallback")&&r&&t.jsx("p",{className:"speak-preview-warning",children:r}),e[20]=a,e[21]=r,e[22]=y):y=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]!==p||e[26]!==g||e[27]!==j||e[28]!==x||e[29]!==y||e[30]!==k?(w=t.jsxs("div",{className:"command-suggestions speak-preview",role:"listbox","aria-label":"ElevenLabs voices","data-testid":"speak-command-preview",children:[p,g,j,x,y,k]}),e[25]=p,e[26]=g,e[27]=j,e[28]=x,e[29]=y,e[30]=k,e[31]=w):w=e[31],w}function Wc(l){return l.preventDefault()}function Xc(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 r;e[1]!==s.busy||e[2]!==s.error||e[3]!==s.message?(r=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]=r):r=e[4];let o;e[5]!==s.fallbackReason?(o=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]=o):o=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]!==r||e[12]!==o||e[13]!==c?(d=t.jsxs("div",{className:i,"aria-label":"Voice activity",children:[a,r,o,c]}),e[10]=i,e[11]=r,e[12]=o,e[13]=c,e[14]=d):d=e[14],d}const Gc='button[role="menuitemradio"]',_l=".composer-mode-cell-live";function Yc(l){return Array.from(l?.querySelectorAll(Gc)??[])}function Jc(){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 Qc(l){const e=X.c(26),{chatModels:s,selectedModel:n,modelSelectionDisabled:i,sending:a,context:r,voice:o,onModelChange:c,onToggleVoice:d}=l,u=C.useRef(null),f=C.useRef(null),[m,b]=C.useState(!1),[p,g]=C.useState(0),h=C.useId(),j=o?.meterRef,x=!!o?.active,y=o?.phase,v=!!o?.disabled,k=o?.message,w=o?.retrying,S=o?.pendingReview;let M;e[0]!==k||e[1]!==w||e[2]!==S||e[3]!==y?(M=ai({sending:!1,mcpRunning:0,voicePhase:y,voiceMessage:k,retrying:w,pendingReview:S}),e[0]=k,e[1]=w,e[2]=S,e[3]=y,e[4]=M):M=e[4];const N=M,$=o?.provider??o?.mode??"auto";let P;e[5]!==$?(P=Ta($),e[5]=$,e[6]=P):P=e[6];const A=P,T=o?.fallbackReason;let R;e[7]!==T||e[8]!==A||e[9]!==N.label?(R=[N.label,A,T].filter(Boolean),e[7]=T,e[8]=A,e[9]=N.label,e[10]=R):R=e[10];const E=R.join(" · "),F=Ma({chatModels:s,selectedModel:n,modelSelectable:!r,voiceMode:o?.mode??null}),I=Pa(F),D=I.length===0||i||a;let L;e[11]!==s||e[12]!==n?(L=s.find(Q=>Q.id===n)??s[0],e[11]=s,e[12]=n,e[13]=L):L=e[13];const _=L,z=r?r.label:_?.label??n,O=r?r.description:_?.description,U=()=>{u.current?.querySelector(_l)?.focus()},q=Q=>{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 Q=u.current,Z=fe=>{Q?.contains(fe.target)||b(!1)},de=fe=>{fe.key!=="Escape"||fe.defaultPrevented||(fe.preventDefault(),fe.stopPropagation(),b(!1),Q?.querySelector(_l)?.focus())};return document.addEventListener("pointerdown",Z),document.addEventListener("focusin",Z),document.addEventListener("keydown",de,!0),()=>{document.removeEventListener("pointerdown",Z),document.removeEventListener("focusin",Z),document.removeEventListener("keydown",de,!0)}},H);const K=()=>{if(m){q();return}g(Aa(I)),b(!0)},se=Q=>{Q.kind==="model"?c(Q.model):o?.selectMode(Q.mode),q()},ae=Q=>{const Z=Da(I,p,Q.key);Z!==null&&(Q.preventDefault(),g(Z),Yc(f.current)[Z]?.focus())},V={"aria-haspopup":"menu","aria-expanded":m,className:"composer-mode-cell composer-mode-cell-live",disabled:D,onClick:K},oe="composer-mode-switch",W="group",te="Input mode",le=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":r?"Composer context":"Chat model",title:O,children:[r?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:z}),!D&&t.jsx(Is,{size:11,"aria-hidden":"true"})]}),Y=o&&(x?t.jsxs("button",{...V,ref:j,type:"button","data-voice-phase":y,"aria-label":"Voice provider","aria-describedby":h,"aria-busy":y==="connecting",title:E,children:[y==="connecting"?t.jsx(vi,{className:"composer-mode-connecting",size:14,"aria-hidden":"true"}):t.jsx(Jc,{}),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:y==="connecting"?N.label:A}),!D&&t.jsx(Is,{size:11,"aria-hidden":"true"})]}):t.jsx("button",{ref:j,type:"button",className:"composer-mode-cell composer-mode-cell-idle","data-voice-phase":y,"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 ee;e[16]!==o||e[17]!==N.label||e[18]!==h?(ee=o&&t.jsx("span",{id:h,className:"sr-only",role:"status",children:N.label}),e[16]=o,e[17]=N.label,e[18]=h,e[19]=ee):ee=e[19];const J=m&&t.jsx("ul",{ref:f,className:"composer-engine-menu",role:"menu","aria-label":"Chat model and voice provider",onKeyDown:ae,children:F.map(Q=>[t.jsx("li",{role:"presentation",className:"composer-engine-group",children:Q.label},`${Q.id}-label`),...Q.items.map(Z=>{const de=`${Z.id.replace(":","-")}-note`;return t.jsx("li",{role:"none",children:t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":Z.checked,"aria-label":Z.label,"aria-describedby":Z.note?de:void 0,autoFocus:Z.position===p,tabIndex:Z.position===p?0:-1,className:"composer-engine-item",onClick:()=>se(Z.choice),children:[t.jsx("span",{className:"composer-engine-check","aria-hidden":"true",children:Z.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:Z.label}),Z.detail&&t.jsx("small",{children:Z.detail})]}),Z.note&&t.jsx("small",{id:de,className:"composer-engine-note",children:Z.note})]})]})},Z.id)})])});let re;return e[20]!==u||e[21]!==le||e[22]!==Y||e[23]!==ee||e[24]!==J?(re=t.jsxs("div",{ref:u,className:oe,role:W,"aria-label":te,children:[le,Y,ee,J]}),e[20]=u,e[21]=le,e[22]=Y,e[23]=ee,e[24]=J,e[25]=re):re=e[25],re}const Ll="videobook-command-composer-form",Zc=250;function tf({chatTurns:l=[],goalEvents:e=[],previewTurnId:s=null,connected:n=!0,onBeginTurn:i,children:a,commands:r,references:o,actions:c,actionContext:d,actionDiscovery:u,actionStatus:f,actionsDisabled:m,onOpenActions:b,onCloseActionSearch:p,onDismissComposer:g,dockOpen:h,onDockOpenChange:j,contextualContent:x=null,contextualHasHeader:y=!1,goalStatus:v=null,bookId:k,callTool:w,chatModels:S,disabled:M,hidden:N=!1,modelSelectionDisabled:$,connectionLabel:P,mcpCalls:A,mcpFlash:T,onToggleMcpCall:R,selectedModel:E,context:F=null,mentionAssets:I=[],inputSession:D=null,placeholder:L,portalTarget:_=null,pendingInput:z,replacePendingInput:O=!1,notice:U,outcomeSlot:q="composer",onEnsureCatalog:H,onDismissNotice:K,onDismissPanel:se,onExecute:ae,onModelChange:V,onStartVoice:oe,onSendingChange:W,onCommandRowHeightChange:te,onHeightChange:le,onSuccessfulExecute:Y,voiceCatalog:ee,voice:J}){const[re,Q]=C.useState(Ea),[Z,de]=C.useState(()=>z??re.get(D)??""),[fe,me]=C.useState(0),[pe,ue]=C.useState(()=>z!==void 0&&!Gt(z)),[be,ye]=C.useState(()=>Fa()??""),ce=_a(),[G,ie]=C.useState(!1),he=C.useRef(0),ke=C.useRef(!1),[we,Ie]=C.useState(!1),[Ne,Me]=C.useState(null),[Fe,et]=C.useState(z),[Ye,Ke]=C.useState(!1),[Ve,lt]=C.useState(D),Te=C.useRef(null),We=C.useRef(null),Xe=C.useRef(null),[Je,tt]=C.useState(null);C.useLayoutEffect(()=>{const B=Xe.current,ge=We.current;if(N||_||!B||!ge||!te&&!le)return;const Se=()=>{const qt=getComputedStyle(ge);te?.(B.getBoundingClientRect().height+parseFloat(qt.borderTopWidth)+parseFloat(qt.borderBottomWidth)),le?.(ge.getBoundingClientRect().height)};Se();const Oe=new ResizeObserver(Se);return Oe.observe(B),Oe.observe(ge),()=>Oe.disconnect()},[N,te,le,_]);const[Re,Ee]=C.useState(!1),qe=h??Re,_e=C.useRef(qe),ve=B=>{h===void 0&&Ee(B),j?.(B)},[Qe]=C.useState(()=>new Map),[nt,At]=C.useState({start:Z.length,end:Z.length}),[wt,Dt]=C.useState(u?.query??""),[Ze,ne]=C.useState(""),[xe,Pe]=C.useState(u?.key),[Ge,at]=C.useState(null),Nt=C.useId(),Ct=C.useId(),ft=C.useRef(D),Tt=C.useRef(""),jt=C.useRef([]),it=C.useRef(-1),pt=C.useRef(""),rt=C.useRef(""),Et=J?.captions.filter(B=>B.role==="user"&&B.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,Bt]=C.useState(0),ot=C.useMemo(()=>La(J?.captions??[],A,l,e),[l,e,A,J?.captions]),ht=za(ot),Ft=Oa(ot),It=Ba(J),yt=q==="composer"&&U&&!l.some(B=>B.reply===U.message)?U:null,ct=q==="composer"&&Ne&&Ne.message!==U?.message?Ne:null,Ae=!!(It||yt||ct),Ce=JSON.stringify([It,yt,ct]),Le=ai({sending:G,mcpRunning:hl(A),voicePhase:J?.phase,voiceMessage:J?.message,retrying:J?.retrying,pendingReview:J?.pendingReview}),Ue=Le.busy&&Le.kind!=="connecting"&&Le.kind!=="permission",De=!Ue&&T==="success",$e=!Ue&&T==="error",kt=Ua({runningCalls:hl(A),voicePhase:J?.phase})||A.calls.some(B=>B.expanded)||l.some(si)||we||!!(It?.error||It?.playbackBlocked)||yt?.tone==="error"||ct?.ok===!1,_t=C.useRef(ht),Ut=C.useRef(Ce);if(C.useLayoutEffect(()=>{ft.current=D},[D]),C.useEffect(()=>{Ha(re,D,Z===z?"":Z)},[Z,re,D,z]),C.useEffect(()=>{(ht>_t.current||Ae&&Ce!==Ut.current)&&gt(!0),_t.current=ht,Ut.current=Ce},[Ce,Ae,ht]),C.useEffect(()=>Ka({open:xt,held:kt,onClose:()=>gt(!1)}),[xt,kt,Ft,Ce]),C.useLayoutEffect(()=>{Et&&(rt.current="")},[Et]),C.useEffect(()=>{window.clearTimeout($t.current)},[D]),D!==Ve){const B=new Map(re);B.set(Ve,Z===Fe?"":Z),Q(B),lt(D),et(z),Ke(!1),de(z??B.get(D)??""),Me(null),at(null),ue(z!==void 0&&!Gt(z))}else if(z!==Fe){const B=O||!Z.trim()||Z===Fe;et(z),J?.pendingReview||Ye?Ke(z!==void 0):B&&de(z??""),ue(z!==void 0&&!Gt(z))}u?.key!==xe&&(Pe(u?.key),Dt(u?.query??""),ne(""),me(0));const Lt=!u&&!F&&!pe&&Gt(Z),je=J?.active&&!x&&!a&&!U&&!Ne&&!u&&!Lt&&ht<=Vt&&!(xt&&ot.length>0)&&!J.playbackBlocked&&!Ae,dt=qe&&!je,Ht=ee?.voices??[],Ds=bl(Ht,be),Ts=ce.stop;C.useEffect(()=>{Lt||Ts()},[Lt,Ts]);const cs=()=>{ee&&ee.ensureLoaded().catch(()=>{})},ns=B=>{!F&&Gt(B)&&cs()},Es=()=>{ee&&ee.refresh().catch(()=>{})},Xt=(B=!1)=>{bn(()=>Te.current?.element()??null,()=>{B&&Te.current?.select()})()},Fs=()=>{ue(!0),u&&p(!1),Ya({setOpen:ve,stopVoice:J?.stop,pauseMedia:()=>hn(We.current)}),Xt()},st=()=>{if(J){if(J.active){J.stop(),Xt();return}J.disabled||G||(ce.stop(),hn(We.current),de(""),At({start:0,end:0}),Ke(!1),at(null),Me(null),ue(!0),gt(!1),Bt(ht),it.current=-1,pt.current="",u&&p(!1),K?.(),oe?.(),ve(!0),J.toggle(),Xt())}};C.useEffect(()=>{const B=_e.current;_e.current=qe,!(!B||qe)&&(ce.stop(),J?.stop(),hn(We.current))},[qe,ce,J]);const Rt=C.useMemo(()=>({outcome:Ne,notice:U??null,dismissOutcome:()=>Me(null),dismissNotice:()=>K?.()}),[U,K,Ne]),Be=C.useMemo(()=>{if(u||pe||Gt(Z))return[];if(z&&/^\/(?:apply|cancel)(?:\s|$)/iu.test(Z))return[];const B=Z.match(/^\/([\w-]*)$/);if(B&&!F){const Se=B[1].toLowerCase();return Va(r,Se).map(Oe=>({value:`${Oe.command} `,label:Oe.command,description:Oe.description,aliases:Oe.aliases,type:"command"}))}const ge=F?new Set(I.map(Se=>Se.artifactId)):void 0;return qa(o,Z,nt.start,nt.end,ge).map(Se=>({value:Se.token,label:Se.token,description:li(Se),type:"cell",reference:Se}))},[u,r,F,pe,Z,I,z,o,nt]),zt=C.useMemo(()=>Wa(c,wt).filter(B=>!Ze||B.group===Ze),[Ze,wt,c]),Qi=C.useMemo(()=>[...new Set(c.map(B=>B.group))].sort(),[c]),ts=Math.min(fe,Math.max(0,zt.length-1)),_s=`${Nt}-actions`,nn=Ge?.action.command===Z.trim().split(/\s/u)[0]&&Ge?.action.scope==="global"?m:M;C.useLayoutEffect(()=>{u&&bn(()=>Te.current?.element()??null)()},[u,_]);const Zn=B=>{window.clearTimeout($t.current),Me(B),B.ok&&($t.current=window.setTimeout(()=>Me(null),3200))},Zi=async B=>{const ge=[];let Se=0;for(;;){const Oe=await w("list_prompt_history",{book_id:B,surface:"chat",limit:Zc,offset:Se}),qt=ir(Oe);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 B=k;if(!B)return;const ge=Pt.current;if(ge?.bookId===B){await ge.promise;return}if(rt.current===B)return;rt.current=B,jt.current=[],it.current=-1,pt.current="";const Se=(async()=>{try{const Oe=await Zi(B);rt.current===B&&(jt.current=Oe)}catch{rt.current===B&&(rt.current="")}})();Pt.current={bookId:B,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(B,ge)=>{jt.current=[...jt.current,B],it.current=-1,k&&await w("record_prompt",{book_id:k,surface:"chat",prompt:B,params:{model:E}},{chat:ge}).catch(()=>{})},el=async B=>{const ge=B!==void 0,Se=(B??Z).trim();if(!Se||ke.current||nn||u||ze.current)return;ve(!0),ge||Ke(!1);const Oe=Ge?.action.command===Se.split(/\s/u)[0]?Ge:null,qt=D,Mt=i?.(Se),ds=()=>Mt?Mt.isInScope():ft.current===qt,ua=he.current,il=()=>he.current===ua&&ft.current===qt;ke.current=!0,ie(!0),gt(!0),Me(null),ge||de(""),ue(!0),W?.(!0);let dn=!1,un=!1;const ma=bn(()=>Te.current?.element()??null,()=>{un&&Te.current?.select()});try{if(!F||Oe){if(await ln(),!ds())return;await ta(Se,Mt)}if(!ds())return;const ys=!F&&Gt(Se)?await ee?.ensureLoaded():null;if(!ds())return;const Os=bl(ys?.voices??Ht,be),mn=tr(Se,Os);mn?.speakVoiceId&&xl(mn.speakVoiceId);const Bs=await ae(Se,{chat:Mt,...mn,...Oe?{action:{id:Oe.action.id,values:Oe.values}}:{}});if(dn=!0,!ds()||Mt&&!Mt.isCurrent())return;at(null),(!Mt||!Bs.ok&&q==="sheet")&&Zn(Bs);const js=sr(Bs,z);js&&!ge&&il()&&(de(js.value),ue(!Gt(js.value)),ns(js.value),un=js.select),Bs.ok&&Y()}catch(ys){const Os={ok:!1,message:ys instanceof Error?ys.message:String(ys)};if(Mt?.finish(Os),dn=!0,!ds())return;Mt||Zn(Os),z!==void 0&&!ge&&il()&&(de(z),ue(!0),un=!0)}finally{dn||Mt?.finish({ok:!0,status:"cancelled",message:"Workspace changed before the command was sent."}),ke.current=!1,ie(!1),W?.(!1),ds()&&(!Mt||Mt.isCurrent())&&ma()}},an=B=>{if(B.type==="command")Te.current?.replace(B.value),ue(!Gt(B.value)),ns(B.value);else{const ge=Te.current?.selection()??nt,Se=Qa(Z,B.value,ge.start,ge.end);if(!Se)return;Te.current?.replace(Se.value,{start:Se.caret,end:Se.caret}),ue(!0)}it.current=-1,Xt()},rn=B=>{at({action:B,values:u?.values}),de(`${B.command} `),ue(!0),me(0),p(!0),Xt()},Ls=()=>{p(!1),g||Xt()},tl=B=>{ye(B),xl(B),ce.playingVoiceId&&ce.playingVoiceId!==B&&ce.stop()},sa=()=>{const B=Ht.find(ge=>ge.voiceId===Ds);B?.previewUrl&&ce.toggle(B.voiceId,B.previewUrl)},zs=async B=>{const ge=D;if(await ln(),ge!==ft.current)return;const Se=lr({values:jt.current,cursor:it.current,draft:pt.current,current:Z,direction:B});Se&&(it.current=Se.cursor,pt.current=Se.draft,de(Se.value),ue(!0),ns(Se.value))},sl=(B,ge=Z)=>{const Se=Te.current?.selection()??nt,Oe=nr({value:ge,selectionStart:Se.start,selectionEnd:Se.end,key:B.key,ctrlKey:B.ctrlKey,altKey:B.altKey,yankText:Tt.current});return Oe?(B.preventDefault(),Oe.value===ge?Te.current?.setSelection({start:Oe.selectionStart,end:Oe.selectionEnd}):Te.current?.replace(Oe.value,{start:Oe.selectionStart,end:Oe.selectionEnd}),ns(Oe.value),Oe.killedText!==void 0&&(Tt.current=Oe.killedText),!0):!1},na=B=>{if(B.key==="Escape"){const ge=document.querySelector(".mcp-call-popover:popover-open");if(ge){B.preventDefault(),B.stopPropagation(),ge.hidePopover();return}}if(ze.current||B.isComposing||B.keyCode===229){B.key==="Enter"&&B.preventDefault();return}if(u){if(B.key==="Escape")B.preventDefault(),B.stopPropagation(),Ls();else if(["ArrowDown","ArrowUp","Home","End"].includes(B.key)){B.preventDefault();const ge=B.key==="Home"?0:B.key==="End"?zt.length-1:(ts+(B.key==="ArrowDown"?1:-1)+zt.length)%Math.max(1,zt.length);me(Math.max(0,ge)),document.getElementById(`${_s}-option-${ge}`)?.scrollIntoView({block:"nearest"})}else(B.key==="Enter"||B.key==="Tab"&&!B.shiftKey)&&zt[ts]?(B.preventDefault(),rn(zt[ts])):sl(B,wt);return}if(Lt){const ge=Za(B,Ht,Ds);if(ge.type!=="ignore"&&B.preventDefault(),ge.type==="select"){tl(ge.voiceId);return}if(ge.type==="toggle"){sa();return}if(ge.type==="dismiss"){ce.stop(),ue(!0);return}}if(Be.length>0){if(["ArrowDown","ArrowUp","Home","End"].includes(B.key)){B.preventDefault();const ge=B.key==="Home"?0:B.key==="End"?Be.length-1:(fe+(B.key==="ArrowDown"?1:-1)+Be.length)%Be.length;me(ge),document.getElementById(`${Nt}-option-${ge}`)?.scrollIntoView({block:"nearest"});return}if(B.key==="Tab"&&!B.shiftKey){B.preventDefault(),an(Be[Math.min(fe,Be.length-1)]);return}if(B.key==="Enter"&&!er(Z,Be)){B.preventDefault(),an(Be[Math.min(fe,Be.length-1)]);return}if(B.key==="Escape"){B.preventDefault(),ue(!0);return}}if(B.key==="Escape"&&dt&&cn&&xt&&!In(J?.phase,ot.length,!!J)){B.preventDefault(),gt(!1);return}if(B.key==="Escape"&&(se||g)){B.preventDefault(),se?se():g?.();return}if(!F&&B.ctrlKey&&B.key.toLowerCase()==="p"){B.preventDefault(),zs(-1);return}if(!F&&B.ctrlKey&&B.key.toLowerCase()==="n"){B.preventDefault(),zs(1);return}if(!F&&B.key==="ArrowUp"){B.preventDefault(),zs(-1);return}if(!F&&B.key==="ArrowDown"){B.preventDefault(),zs(1);return}sl(B)||B.key==="Enter"&&(B.preventDefault(),el())},ls=Ga(!!a),on=l.at(-1),nl=on!==void 0&&on.id===s,cn=!x||ls||nl,la=cn||Ae,ia=cn?x&&!ls&&nl?ot.filter(B=>B.kind==="caption"&&B.turn?.id===on.id):ot:[],aa=Ja({dockOpen:dt,panelHasHeader:y,reviewPriority:ls}),ra=!Ae&&In(J?.phase,ot.length,!!J),oa={captionId:Ct},ca={hide:Fs,hideLabel:Xa},da=Ae?t.jsxs(t.Fragment,{children:[yt&&t.jsx(El,{message:yt.message,tone:yt.tone,dismissLabel:"Dismiss notice",onDismiss:K}),ct&&t.jsx(El,{message:ct.message,tone:ct.ok?"info":"error",dismissLabel:"Dismiss error",onDismiss:ct.ok?void 0:()=>Me(null)}),It&&J&&t.jsx(Xc,{feedback:It,onResumePlayback:J.resumePlayback})]}):null,ll=t.jsx(Bi.Provider,{value:Rt,children:t.jsx(Li.Provider,{value:ca,children:t.jsx(Oi.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":J?.phase,hidden:N,onKeyDown:B=>{!u||B.key!=="Escape"||B.defaultPrevented||B.nativeEvent.isComposing||(B.preventDefault(),B.stopPropagation(),Ls())},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(Rc,{})]}),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(Oc,{actions:zt,groups:Qi,group:Ze,context:d,loading:f.loading,error:f.error,listId:_s,selectedIndex:ts,onGroupChange:B=>{ne(B),me(0),Xt()},onClose:Ls,onSelect:rn}),!N&&la&&t.jsx(Ac,{rows:ia,connected:n,onDetailsChange:Ie,phase:J?.phase,voicePresent:!!J,open:xt&&dt,onToggleCall:R,children:da})]}),t.jsxs("form",{ref:Xe,id:Ll,className:`command-line-shell ${Ue?"command-line-shell-transmitting":""} ${De?"command-line-shell-success":""} ${$e?"command-line-shell-error":""}`,"aria-busy":Ue,onSubmit:B=>{if(B.preventDefault(),u&&zt[ts])rn(zt[ts]);else{const ge=B.nativeEvent.submitter,Se=ge?.getAttribute("form")===Ll||!ge&&document.activeElement?.closest(".confirm-sheet"),Oe=z!==void 0&&Se&&!/^\/apply(?:\s|$)/iu.test(Z);el(Oe?z:void 0)}},children:[Lt&&t.jsx(qc,{voices:Ht,selectedVoiceId:Ds,playingVoiceId:ce.playingVoiceId,status:ee?.status??"fallback",warning:ee?.warning??null,loading:ee?.loading??!1,error:ee?.error??null,onSelect:tl,onTogglePreview:(B,ge)=>{J?.stop(),ce.toggle(B,ge)},onRefresh:Es}),!Lt&&Be.length>0&&t.jsx("div",{className:"command-suggestions",id:`${Nt}-list`,role:"listbox","aria-label":"Command suggestions",children:Be.map((B,ge)=>t.jsx("button",{type:"button",role:"option",id:`${Nt}-option-${ge}`,"aria-selected":ge===fe,className:`${ge===fe?"active ":""}${B.type==="cell"?"composer-reference-suggestion":"command-command-suggestion"}`,onMouseDown:Se=>Se.preventDefault(),onClick:()=>an(B),children:B.type==="cell"?t.jsxs(t.Fragment,{children:[t.jsx(xs,{asset:B.reference.asset,kindHint:B.reference.type}),t.jsxs("span",{className:"composer-reference-copy",children:[t.jsx("strong",{children:B.label}),B.reference.label&&t.jsx("span",{children:B.reference.label}),t.jsx("small",{children:B.description})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("strong",{children:B.label}),t.jsx("span",{children:B.description})]})},`${B.type}:${B.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?Ls:b,children:t.jsx(Uo,{size:14,"aria-hidden":"true"})})}),t.jsx(zc,{ref:Te,value:u?wt:Z,session:`${D??"chat"}:${u?`actions-${u.key}`:"draft"}`,sessions:Qe,references:o,disabled:u?m:nn,rich:!u,placeholder:u?"Search actions by name, operation or alias…":M?P:L??"Type a message or /command…",expanded:!!u||!Lt&&Be.length>0,controls:u?_s:!Lt&&Be.length>0?`${Nt}-list`:void 0,activeDescendant:u&&zt[ts]?`${_s}-option-${ts}`:!Lt&&Be[fe]?`${Nt}-option-${fe}`:void 0,onFocus:ea,onCompositionChange:B=>{ze.current=B},onSelectionChange:At,onChange:(B,ge)=>{if(At(ge),me(0),u){Dt(B);return}he.current+=1,de(B),ue(!1),it.current=-1,ns(B)},onKeyDown:na}),v,t.jsx(Qc,{chatModels:S,selectedModel:E,modelSelectionDisabled:$,sending:G,context:F,voice:J,onModelChange:V,onToggleVoice:st}),t.jsx("button",{type:"submit",className:"command-send",disabled:u?m||zt.length===0||f.loading:nn||G||!Z.trim(),"aria-label":u?"Prepare action":"Send command",children:G?t.jsx(ut,{size:14}):t.jsx(Ho,{size:14})}),Ue&&t.jsx("span",{className:"command-transmit-scan","aria-hidden":"true"})]})]})})})});return _?gs.createPortal(ll,_):ll}function ed(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 r=a;if(!r&&(s.provider!=="machgen"||!s.taskId))return null;const o=s.provider==="fal"?"fal requests":s.provider==="machgen"?"MachGen task":"Kie logs";let c;e[3]!==o||e[4]!==r?(c=r?t.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[o,t.jsx(Ko,{size:12,"aria-hidden":"true"})]}):t.jsx("span",{children:o}),e[3]=o,e[4]=r,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(en,{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 td(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 sf=C.memo(function(e){const s=X.c(20),{source:n,sourceX:i,sourceY:a,target:r,data:o}=e;let c;s[0]!==n||s[1]!==r?(c=x=>{const y=x.nodeLookup.get(n),v=x.nodeLookup.get(r);if(!y||!v)return null;const k=y.internals?.positionAbsolute??y.position,w=v.internals?.positionAbsolute??v.position,S=y.measured?.width??He.squareSize,M=y.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]=r,s[2]=c):c=s[2];const d=mc(c,td);if(!o||!d)return null;const u=Rn[o.targetPortIndex]??Rn[1],f=o.targetSide==="left"?d.targetLeftX:d.targetCenterX,m=o.targetSide==="left"?d.targetTopY+d.targetHeight*u:d.targetTopY;let b;s[3]!==d||s[4]!==o||s[5]!==i||s[6]!==a||s[7]!==f||s[8]!==m?(b=rr({sourceX:i,sourceY:a,targetX:f,targetY:m,...d},o),s[3]=d,s[4]=o,s[5]=i,s[6]=a,s[7]=f,s[8]=m,s[9]=b):b=s[9];const p=b;let g;s[10]!==p||s[11]!==e.id||s[12]!==e.style?(g=t.jsx(fc,{id:e.id,path:p,interactionWidth:18,style:e.style}),s[10]=p,s[11]=e.id,s[12]=e.style,s[13]=g):g=s[13];let h;s[14]!==f||s[15]!==m?(h=t.jsx("circle",{className:"bus-river-entry-dot",cx:f,cy:m,r:2.5}),s[14]=f,s[15]=m,s[16]=h):h=s[16];let j;return s[17]!==g||s[18]!==h?(j=t.jsxs(t.Fragment,{children:[g,h]}),s[17]=g,s[18]=h,s[19]=j):j=s[19],j}),Vs=10;function sd(l){const e=He.columnCount*He.columnPitch-He.gap,s=l.rowCount*He.rowPitch-He.gap,n=He.originX-Vs,i=He.originY+l.startRow*He.rowPitch-Vs;return{width:e+Vs*2,height:s+Vs*2,transform:`translate(${n}px, ${i}px)`}}function nf(l){const e=X.c(33),{sections:s,metrics:n,occupiedSlots:i,previewSlot:a,mediaDropActive:r,mediaDropSlot:o,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 f;e[2]!==i?(f=new Set(i.map(Us)),e[2]=i,e[3]=f):f=e[3];const m=f;let b;e[4]!==o?(b=o?Us(o):null,e[4]=o,e[5]=b):b=e[5];const p=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(nd),e[9]=s,e[10]=h):h=e[10];let j;if(e[11]!==r||e[12]!==p||e[13]!==n.columnCount||e[14]!==n.minColumn||e[15]!==n.rowCount||e[16]!==m||e[17]!==c){let v;e[19]!==r||e[20]!==p||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=Us($),A=m.has(P),T=r&&!A,R=T&&P===p,E=A?void 0:c.get(ti($)),I=`notebook-grid-square${!A&&(M===0||m.has(Us({row:w,column:N-1})))?" notebook-grid-square-run-start":""}${T?" notebook-grid-square-dropzone":""}${R?" notebook-grid-square-drop-target":""}${E?` notebook-grid-square-review notebook-review-${E}`:""}`;return t.jsx("span",{className:I,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]=r,e[20]=p,e[21]=n.columnCount,e[22]=n.minColumn,e[23]=m,e[24]=c,e[25]=v):v=e[25],j=Array.from({length:n.rowCount},v),e[11]=r,e[12]=p,e[13]=n.columnCount,e[14]=n.minColumn,e[15]=n.rowCount,e[16]=m,e[17]=c,e[18]=j}else j=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 y;return e[28]!==g||e[29]!==h||e[30]!==j||e[31]!==x?(y=t.jsx(_i,{children:t.jsxs("div",{className:"notebook-grid-board",style:g,children:[h,j,x]})}),e[28]=g,e[29]=h,e[30]=j,e[31]=x,e[32]=y):y=e[32],y}function nd(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:sd(l)},`lane-${l.startRow}-${e}`)}const Ot={width:240,height:156,pitch:4,minimumBarHeight:4};function ld(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 r=`played${a}`;let o;e[3]!==s?(o=or(s,Ot),e[3]=s,e[4]=o):o=e[4];const c=o,d=Math.min(1,Math.max(0,n)),u=Ot.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 f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("path",{className:"cell-waveform-midline",d:`M0 ${Ot.height/2}h${Ot.width}`}),e[6]=f):f=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]!==r||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:r,children:t.jsx("rect",{x:"0",y:"0",width:u,height:Ot.height})})}),t.jsx("g",{clipPath:`url(#${r})`,children:t.jsx("path",{className:"cell-waveform-played",d:c})}),t.jsx("path",{className:"cell-waveform-playhead",d:`M${u} 8V${Ot.height-8}`})]}),e[9]=r,e[10]=c,e[11]=d,e[12]=u,e[13]=b):b=e[13];let p;return e[14]!==m||e[15]!==b?(p=t.jsxs("svg",{className:"cell-waveform",viewBox:`0 0 ${Ot.width} ${Ot.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:[f,m,b]}),e[14]=m,e[15]=b,e[16]=p):p=e[16],p}function Ui(){const l=X.c(2);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=cr(Ot),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 ${Ot.width} ${Ot.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:[t.jsx("path",{className:"cell-waveform-midline",d:`M0 ${Ot.height/2}h${Ot.width}`}),t.jsx("path",{className:"cell-waveform-bars",d:s})]}),l[1]=n):n=l[1],n}function id(l){const e=X.c(20),{asset:s,eager:n}=l,i=n===void 0?!1:n,[a,r]=C.useState(!1),[o,c]=C.useState(!1),[d,u]=C.useState(i),f=C.useRef(null),m=s.type==="video"||s.type==="final",b=s.thumbnailUrl??(s.type==="image"?s.mediaUrl:null),p=`${b??""}:${s.mediaUrl??""}:${s.type}:${i}`,[g,h]=C.useState(p);g!==p&&(h(p),r(!1),c(!1),u(i));const j=!!(b&&!a),x=m&&!!s.mediaUrl&&!j;let y,v;if(e[0]!==i||e[1]!==x||e[2]!==d?(y=()=>{if(!x||d)return;if(i||typeof IntersectionObserver>"u"){const $=window.requestAnimationFrame(()=>u(!0));return()=>window.cancelAnimationFrame($)}const M=f.current;if(!M)return;const N=new IntersectionObserver($=>{$.some(ad)&&(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]=y,e[4]=v):(y=e[3],v=e[4]),C.useEffect(y,v),j&&b){let M;e[5]===Symbol.for("react.memo_cache_sentinel")?(M=()=>r(!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]!==o?(M=t.jsx("span",{ref:f,className:"media-library-asset-preview",children:d&&!o?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]=o,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 ad(l){return l.isIntersecting}function vn(l){return l!==null&&Number.isFinite(l)&&l>0}function rd(l){const e=X.c(11),{className:s,width:n,height:i,durationSeconds:a,fallbackLabel:r}=l,o=vn(n)&&vn(i)?`${n}×${i}`:r??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(!o&&!d)return null;const u=`notebook-media-metadata ${s}`;let f;e[2]!==o?(f=o&&t.jsx("span",{children:o}),e[2]=o,e[3]=f):f=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]!==f||e[9]!==m?(b=t.jsxs("span",{className:u,children:[f,m]}),e[7]=u,e[8]=f,e[9]=m,e[10]=b):b=e[10],b}const od=/("(?:\\.|[^"\\])*")(?=\s*:)|("(?:\\.|[^"\\])*")|\b(true|false)\b|\b(null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function cd(l){const e=JSON.stringify(l,null,2)??"null",s=[];let n=0;for(const i of e.matchAll(od)){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 dd(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 ud(l){const e=X.c(23),{asset:s}=l,n=C.useId(),i=C.useRef(null),a=C.useRef(null),r=s.type==="video"||s.type==="final",o=s.mediaUrl??(s.type==="image"?s.thumbnailUrl:null);if(!o||!r&&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 f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=v=>{v.currentTarget.contains(document.activeElement)||f()},e[4]=m):m=e[4];let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=v=>{v.currentTarget.contains(v.relatedTarget)||f()},e[5]=b):b=e[5];const p=`Preview source ${r?"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]!==p||e[10]!==g?(h=t.jsx("button",{ref:a,type:"button",className:"json-media-trigger","aria-label":p,"aria-controls":n,onClick:d,children:g}),e[8]=n,e[9]=p,e[10]=g,e[11]=h):h=e[11];let j;e[12]!==s.thumbnailUrl||e[13]!==s.type||e[14]!==o||e[15]!==r?(j=s.type==="image"?t.jsx("img",{src:o,alt:"Source image preview",loading:"lazy",decoding:"async"}):r?t.jsx("video",{src:o,poster:s.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"none","aria-label":"Source video"}):t.jsx("audio",{src:o,controls:!0,preload:"none","aria-label":"Source audio"}),e[12]=s.thumbnailUrl,e[13]=s.type,e[14]=o,e[15]=r,e[16]=j):j=e[16];let x;e[17]!==n||e[18]!==j?(x=t.jsx("span",{id:n,ref:i,popover:"auto",className:"json-media-popover",onToggle:md,children:j}),e[17]=n,e[18]=j,e[19]=x):x=e[19];let y;return e[20]!==h||e[21]!==x?(y=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]=y):y=e[22],y}function md(l){l.newState==="closed"&&l.currentTarget.querySelectorAll("video, audio").forEach(fd)}function fd(l){l instanceof HTMLMediaElement&&l.pause()}const pd=/\.(?:png|jpe?g|webp|gif|avif)$/i,hd=/\.(?:mp4|mov|webm|m4v)$/i;function bd(l){if(!/^https?:\/\//i.test(l))return;let e;try{e=new URL(l).pathname}catch{return}const s=pd.test(e)?"image":hd.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:r}=l,o=n===void 0?"Formatted action source":n,c=a===void 0?"thumbnail":a,d=r===void 0?!1:r;let u,f,m;if(e[0]!==o||e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==s){const p=cd(s);u="inspector-source-json",f=o;let g;e[8]!==i||e[9]!==c||e[10]!==d?(g=(h,j)=>{const x=h.kind==="string"?dd(h.value):null,y=x?i?.get(x)??(d?bd(x):void 0):void 0;return t.jsxs("span",{className:`json-${h.kind}`,children:[h.value,y&&(c==="preview"?t.jsx(ud,{asset:y}):t.jsx(xs,{asset:y}))]},`${j}-${h.value}`)},e[8]=i,e[9]=c,e[10]=d,e[11]=g):g=e[11],m=p.map(g),e[0]=o,e[1]=i,e[2]=c,e[3]=d,e[4]=s,e[5]=u,e[6]=f,e[7]=m}else u=e[5],f=e[6],m=e[7];let b;return e[12]!==u||e[13]!==f||e[14]!==m?(b=t.jsx("pre",{className:u,"aria-label":f,children:m}),e[12]=u,e[13]=f,e[14]=m,e[15]=b):b=e[15],b}function xd(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 r;e[6]!==s.duration||e[7]!==s.height||e[8]!==s.width?(r=t.jsx(rd,{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]=r):r=e[9];let o;e[10]!==a||e[11]!==r?(o=t.jsxs("div",{className:"inspector-dolt-artifact-facts",children:[a,r]}),e[10]=a,e[11]=r,e[12]=o):o=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]!==o||e[17]!==c?(d=t.jsxs("div",{className:"inspector-dolt-artifact",children:[n,o,c]}),e[15]=n,e[16]=o,e[17]=c,e[18]=d):d=e[18],d}function gd(l){const e=X.c(11),{notebookId:s,cell:n,artifactAssets:i}=l,a=ri(s,n);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,e[0]=r):r=e[0];const[o,c]=C.useState(r);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=x=>{c(y=>{const v=new Set(y);return v.has(x)?v.delete(x):v.add(x),v})},e[1]=d):d=e[1];const u=d,f="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 p;e[3]!==i||e[4]!==o?(p=x=>{const y=dr(x);if(y.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:y.value,ariaLabel:`${x.column} JSON`,artifactAssets:i})})})]},x.column);const v=y.kind==="raw"&&typeof y.value=="string"?i.get(y.value):void 0;if(v){const k=o.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(xd,{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:y.kind==="null"?"dolt-null":void 0,children:y.kind==="null"?"NULL":String(y.value)})})]},x.column)},e[3]=i,e[4]=o,e[5]=p):p=e[5];const g=a.map(p);let h;e[6]!==g?(h=t.jsx("tbody",{children:g}),e[6]=g,e[7]=h):h=e[7];let j;return e[8]!==b||e[9]!==h?(j=t.jsxs("table",{className:f,"aria-label":m,children:[b,h]}),e[8]=b,e[9]=h,e[10]=j):j=e[10],j}function lf(l){const e=X.c(13),{notebookId:s,cell:n,artifactAssets:i,heading:a}=l,r=a===void 0?!0:a;let o;e[0]!==i||e[1]!==n||e[2]!==s?(o=t.jsx(gd,{notebookId:s,cell:n,artifactAssets:i}),e[0]=i,e[1]=n,e[2]=s,e[3]=o):o=e[3];const c=o;if(!r)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 f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{children:"Dolt source"}),e[7]=f):f=e[7];let m;e[8]!==u?(m=t.jsxs("header",{className:"inspector-source-meta",children:[f,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}function yd(l){const e=X.c(21),{generationId:s,status:n,captureOffHint:i,onDownload:a,onOpenSettings:r}=l,o=i===void 0?!0:i;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={phase:"idle"},e[0]=c):c=e[0];const[d,u]=C.useState(c),f=!!(n?.hasCapture&&s&&a),m=o&&n?.mode==="off";if(!f&&!m)return null;let b;e[1]!==s||e[2]!==a||e[3]!==d.phase?(b=async function(){if(!(!s||!a||d.phase==="running")){u({phase:"running"});try{await a(s),u({phase:"idle"})}catch(w){const S=w;u({phase:"failed",message:S instanceof Error?S.message:String(S)})}}},e[1]=s,e[2]=a,e[3]=d.phase,e[4]=b):b=e[4];const p=b;let g;e[5]!==r?(g=function(w){r&&(w.preventDefault(),r())},e[5]=r,e[6]=g):g=e[6];const h=g;let j;e[7]!==f||e[8]!==p||e[9]!==d.phase?(j=f&&t.jsxs("button",{type:"button","aria-label":"Download HAR",title:"Download the scrubbed provider HAR capture",disabled:d.phase==="running",onClick:()=>{p()},children:[t.jsx(Ps,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:"HAR"})]}),e[7]=f,e[8]=p,e[9]=d.phase,e[10]=j):j=e[10];let x;e[11]!==m||e[12]!==h?(x=m&&t.jsx("a",{href:"/settings",title:"Provider HAR capture is off. Turn it on in Settings, Diagnostics.",onClick:h,children:"Capture off"}),e[11]=m,e[12]=h,e[13]=x):x=e[13];let y;e[14]!==d.message||e[15]!==d.phase?(y=d.phase==="failed"&&t.jsx("span",{className:"generation-har-error",role:"alert",children:d.message}),e[14]=d.message,e[15]=d.phase,e[16]=y):y=e[16];let v;return e[17]!==j||e[18]!==x||e[19]!==y?(v=t.jsxs("span",{className:"generation-har-actions",children:[j,x,y]}),e[17]=j,e[18]=x,e[19]=y,e[20]=v):v=e[20],v}const zl=new WeakMap;function jd(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(r=>({ok:!0,inspection:r}),r=>({ok:!1,message:r instanceof Error?r.message:String(r)}));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 r;e[0]!==s?(r=()=>{navigator.clipboard.writeText(s).then(()=>{a(!0),window.setTimeout(()=>a(!1),1500)})},e[0]=s,e[1]=r):r=e[1];let o;e[2]!==i?(o=i?t.jsx(Qt,{size:12,"aria-hidden":"true"}):t.jsx(en,{size:12,"aria-hidden":"true"}),e[2]=i,e[3]=o):o=e[3];let c;return e[4]!==n||e[5]!==r||e[6]!==o?(c=t.jsx("button",{type:"button",className:"inspector-generating-copy","aria-label":n,title:n,onClick:r,children:o}),e[4]=n,e[5]=r,e[6]=o,e[7]=c):c=e[7],c}function vd(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 r=a;if(r){const d=s.at??void 0;let u;return e[7]!==d||e[8]!==r?(u=t.jsx("time",{dateTime:d,children:r}),e[7]=d,e[8]=r,e[9]=u):u=e[9],u}const o=s.status==="pending"?"pending":s.status;let c;return e[10]!==o?(c=t.jsx("span",{children:o}),e[10]=o,e[11]=c):c=e[11],c}function kd(l){const e=X.c(17),{facts:s,inspection:n}=l;let i,a,r,o;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});r="inspector-generating-section",e[7]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"inspector-media-field-label",children:"Timeline"}),e[7]=o):o=e[7],i="inspector-generating-timeline";let f;e[8]!==n?.task?.submittedAt?(f=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(vd,{step:m,submittedAt:n?.task?.submittedAt??null})]},m.id),e[8]=n?.task?.submittedAt,e[9]=f):f=e[9],a=u.map(f),e[0]=s.runKind,e[1]=s.startedAt,e[2]=n?.task,e[3]=i,e[4]=a,e[5]=r,e[6]=o}else i=e[3],a=e[4],r=e[5],o=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]!==r||e[14]!==o||e[15]!==c?(d=t.jsxs("div",{className:r,children:[o,c]}),e[13]=r,e[14]=o,e[15]=c,e[16]=d):d=e[16],d}function Sd(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(r=>r!==null)}function wd(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 r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("span",{className:"inspector-media-field-label",children:"Run"}),e[3]=r):r=e[3];const o=Sd(s,n).map(Cd);let c;e[4]!==o?(c=t.jsx("dl",{className:"inspector-generating-facts",children:o}),e[4]=o,e[5]=c):c=e[5];let d;e[6]!==n?(d=n?.providerTask&&t.jsx(ed,{task:n.providerTask}),e[6]=n,e[7]=d):d=e[7],i=t.jsxs("div",{className:"inspector-generating-section",children:[r,c,d,a.length>0&&t.jsx("ul",{className:"inspector-generating-settings","aria-label":"Request settings",children:a.map(Nd)})]}),e[0]=s,e[1]=n,e[2]=i}else i=e[2];return i}function Nd(l){return t.jsxs("li",{children:[t.jsx("span",{children:l.key.replace(/_/g," ")})," ",l.value]},l.key)}function Cd(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 $d(l){const e=X.c(11),{written:s,sent:n}=l,[i,a]=C.useState(!1),r=!!(s&&n&&s!==n),o=(i&&r?n:s??n)??"";if(!o)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]!==r||e[2]!==i?(d=r&&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]=r,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 f;e[6]!==o?(f=t.jsx("blockquote",{children:o}),e[6]=o,e[7]=f):f=e[7];let m;return e[8]!==u||e[9]!==f?(m=t.jsxs("div",{className:"inspector-generating-section inspector-media-generating-prompt",children:[u,f]}),e[8]=u,e[9]=f,e[10]=m):m=e[10],m}function Id(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 Rd(l){const e=X.c(34),{facts:s,outcome:n,loading:i,artifactAssets:a,onRefresh:r,onDownloadHar:o,onOpenSettings:c}=l,d=n?.ok?n.inspection:null,u=d?.payload??null,f=d?.task?.submittedAt??null;let m;e[0]!==f?(m=Hi(f),e[0]=f,e[1]=m):m=e[1];const b=m;let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{className:"inspector-media-field-label",children:"Request payload"}),e[2]=p):p=e[2];let g;e[3]!==d?(g=d?.taskType&&t.jsx("code",{children:d.taskType}),e[3]=d,e[4]=g):g=e[4];let h;e[5]!==b?(h=b&&t.jsxs("span",{className:"inspector-generating-muted",children:["sent ",b]}),e[5]=b,e[6]=h):h=e[6];let j;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("span",{className:"inspector-generating-spacer"}),e[7]=j):j=e[7];const x=d?.har;let y;e[8]!==s.providerArtifactId||e[9]!==o||e[10]!==c||e[11]!==x?(y=t.jsx(yd,{generationId:s.providerArtifactId,status:x,onDownload:o,onOpenSettings:c}),e[8]=s.providerArtifactId,e[9]=o,e[10]=c,e[11]=x,e[12]=y):y=e[12];let v;e[13]!==i||e[14]!==r?(v=r&&t.jsx("button",{type:"button",className:"inspector-generating-copy","aria-label":"Reload request payload",title:"Reload request payload",disabled:i,onClick:r,children:t.jsx(On,{size:12,"aria-hidden":"true"})}),e[13]=i,e[14]=r,e[15]=v):v=e[15];let k;e[16]!==u?(k=u!==null&&t.jsx(Ki,{text:JSON.stringify(u,null,2),label:"Copy request JSON"}),e[16]=u,e[17]=k):k=e[17];let w;e[18]!==k||e[19]!==g||e[20]!==h||e[21]!==y||e[22]!==v?(w=t.jsxs("header",{className:"inspector-generating-payload-head",children:[p,g,h,j,y,v,k]}),e[18]=k,e[19]=g,e[20]=h,e[21]=y,e[22]=v,e[23]=w):w=e[23];let S;e[24]!==a||e[25]!==s||e[26]!==i||e[27]!==n||e[28]!==u?(S=u!==null?t.jsx("div",{className:"inspector-generating-payload-scroll",tabIndex:0,children:t.jsx(Xn,{value:u,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…":Id(s,n)}),e[24]=a,e[25]=s,e[26]=i,e[27]=n,e[28]=u,e[29]=S):S=e[29];let M;return e[30]!==i||e[31]!==w||e[32]!==S?(M=t.jsxs("aside",{className:"inspector-generating-payload","aria-busy":i,children:[w,S]}),e[30]=i,e[31]=w,e[32]=S,e[33]=M):M=e[33],M}function Dn(l){const e=X.c(26),{facts:s,header:n,footer:i,artifactAssets:a,outcome:r,loading:o,onRefresh:c,onDownloadHar:d,onOpenSettings:u}=l,f=r?.ok?r.inspection:null;let m,b;e[0]!==s||e[1]!==f?(m=t.jsx(kd,{facts:s,inspection:f}),b=t.jsx(wd,{facts:s,inspection:f}),e[0]=s,e[1]=f,e[2]=m,e[3]=b):(m=e[2],b=e[3]);const p=s.writtenPrompt,g=f?.payload??null;let h;e[4]!==g?(h=ur(g),e[4]=g,e[5]=h):h=e[5];let j;e[6]!==s.writtenPrompt||e[7]!==h?(j=t.jsx($d,{written:p,sent:h}),e[6]=s.writtenPrompt,e[7]=h,e[8]=j):j=e[8];let x;e[9]!==i||e[10]!==n||e[11]!==m||e[12]!==b||e[13]!==j?(x=t.jsxs("div",{className:"inspector-media-generating-summary",children:[n,m,b,j,i]}),e[9]=i,e[10]=n,e[11]=m,e[12]=b,e[13]=j,e[14]=x):x=e[14];let y;e[15]!==a||e[16]!==s||e[17]!==o||e[18]!==d||e[19]!==u||e[20]!==c||e[21]!==r?(y=t.jsx(Rd,{facts:s,outcome:r,loading:o,artifactAssets:a,onRefresh:c,onDownloadHar:d,onOpenSettings:u}),e[15]=a,e[16]=s,e[17]=o,e[18]=d,e[19]=u,e[20]=c,e[21]=r,e[22]=y):y=e[22];let v;return e[23]!==x||e[24]!==y?(v=t.jsxs(t.Fragment,{children:[x,y]}),e[23]=x,e[24]=y,e[25]=v):v=e[25],v}function Md(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(Dn,{...n,outcome:i,loading:!1}),e[3]=i,e[4]=n,e[5]=a):a=e[5],a}function af(l){const e=X.c(12),{inspect:s,...n}=l,[i,a]=C.useState(0),r=n.facts.providerArtifactId;if(!s||!r)return t.jsx(Dn,{...n,outcome:null,loading:!1});const o=jd(s,r,`${r}:${n.facts.runKind}:${i}`);let c;e[0]!==a?(c=()=>C.startTransition(()=>a(Pd)),e[0]=a,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==n?(u=t.jsx(Dn,{...n,outcome:null,loading:!0,onRefresh:d}),e[2]=d,e[3]=n,e[4]=u):u=e[4];let f;e[5]!==d||e[6]!==o||e[7]!==n?(f=t.jsx(Md,{...n,promise:o,onRefresh:d}),e[5]=d,e[6]=o,e[7]=n,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=t.jsx(C.Suspense,{fallback:u,children:f}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function Pd(l){return l+1}function Zs(l){return`${typeof l}:${String(l)}`}function rf(l){const e=X.c(67),{control:s,settings:n,busy:i,onFocus:a,onChange:r,toggleClassName:o,booleanLabelFirst:c,labelAsSpan:d}=l,u=c===void 0?!0:c,f=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 p=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,$=p===!0;let P;e[5]!==r?(P=E=>r(E.target.checked),e[5]=r,e[6]=P):P=e[6];let A;e[7]!==i||e[8]!==a||e[9]!==$||e[10]!==P?(A=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]=A):A=e[11];const T=!u&&M;let R;return e[12]!==s.description||e[13]!==N||e[14]!==A||e[15]!==T||e[16]!==o?(R=t.jsxs("label",{className:o,title:s.description,children:[N,A,T]}),e[12]=s.description,e[13]=N,e[14]=A,e[15]=T,e[16]=o,e[17]=R):R=e[17],R}let g;e[18]!==s.label||e[19]!==f?(g=f?t.jsx("span",{children:s.label}):s.label,e[18]=s.label,e[19]=f,e[20]=g):g=e[20];const h=g;if(s.kind==="select"){let S;e[21]!==m?(S=m===void 0?"":Zs(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,A=s.label;let T;e[26]!==s.options||e[27]!==r?(T=_=>{const z=s.options.find(O=>Zs(O)===_.target.value);r(z)},e[26]=s.options,e[27]=r,e[28]=T):T=e[28];const R=s.defaultValue===void 0?s.required?"Select…":"Auto":`Default · ${String(s.defaultValue)}`;let E;e[29]!==R?(E=t.jsx("option",{value:"",children:R}),e[29]=R,e[30]=E):E=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 I;e[35]!==s.options?(I=s.options.map(Ad),e[35]=s.options,e[36]=I):I=e[36];let D;e[37]!==i||e[38]!==s.label||e[39]!==M||e[40]!==a||e[41]!==E||e[42]!==F||e[43]!==I||e[44]!==T?(D=t.jsxs("select",{"aria-label":A,value:M,disabled:i,onFocus:a,onChange:T,children:[E,F,I]}),e[37]=i,e[38]=s.label,e[39]=M,e[40]=a,e[41]=E,e[42]=F,e[43]=I,e[44]=T,e[45]=D):D=e[45];let L;return e[46]!==s.description||e[47]!==h||e[48]!==D?(L=t.jsxs("label",{title:P,children:[h,D]}),e[46]=s.description,e[47]=h,e[48]=D,e[49]=L):L=e[49],L}const j=s.kind==="number"?"number":"text",x=s.kind==="number"?"any":void 0,y=p===void 0?"":String(p);let v;e[50]!==s.kind||e[51]!==r?(v=S=>{const M=S.target.value;if(!M){r(void 0);return}const N=Number(M);r(s.kind==="number"?Number.isFinite(N)?N:void 0:M)},e[50]=s.kind,e[51]=r,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]!==j||e[59]!==x||e[60]!==y||e[61]!==v?(k=t.jsx("input",{type:j,"aria-label":s.label,min:s.minimum,max:s.maximum,step:x,value:y,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]=j,e[59]=x,e[60]=y,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 Ad(l){return t.jsx("option",{value:Zs(l),children:String(l)},Zs(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 qs(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 r;e[0]!==s?(r={flexGrow:s},e[0]=s,e[1]=r):r=e[1];let o;e[2]!==i||e[3]!==s?(o=i==="new"?`New · ${bt(s)}`:bt(s),e[2]=i,e[3]=s,e[4]=o):o=e[4];let c;e[5]!==o?(c=t.jsx("span",{children:o}),e[5]=o,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==r||e[9]!==c||e[10]!==n?(d=t.jsx("span",{className:a,style:r,title:n,children:c}),e[7]=a,e[8]=r,e[9]=c,e[10]=n,e[11]=d):d=e[11],d}function of(l){const e=X.c(9),{sources:s,settings:n,controls:i,busy:a,onChange:r}=l;let o;e[0]!==s?(o=oi(s),e[0]=s,e[1]=o):o=e[1];const c=o,d=c?.asset?.mediaUrl??c?.cellId??"empty";let u;return e[2]!==a||e[3]!==i||e[4]!==r||e[5]!==n||e[6]!==s||e[7]!==d?(u=t.jsx(Dd,{sources:s,settings:n,controls:i,busy:a,onChange:r},d),e[2]=a,e[3]=i,e[4]=r,e[5]=n,e[6]=s,e[7]=d,e[8]=u):u=e[8],u}function Dd(l){const e=X.c(45),{sources:s,settings:n,controls:i,busy:a,onChange:r}=l,o=oi(s),c=C.useRef(null),[d,u]=C.useState(0),[f,m]=C.useState(!1),b=C.useId(),p=o?.asset?.duration??0,g=qs(n,"start_time"),h=qs(n,"resume_time"),j=qs(n,"duration")??Number(i.find(Ed)?.defaultValue??5);let x;if(e[0]!==i||e[1]!==n||e[2]!==s){const Q=i.flatMap(Td);x=br("fal:minimax/h3-max/insert-video",n,s)??xr(Q,n),e[0]=i,e[1]=n,e[2]=s,e[3]=x}else x=e[3];const y=x,v=!y&&g!==void 0&&h!==void 0,k=v?g+j+p-h:null,w=Math.max(p,k??0);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=Q=>{!c.current||!Number.isFinite(c.current.duration)||(c.current.currentTime=Math.max(0,Math.min(Q,c.current.duration)))},e[4]=S):S=e[4];const M=S;let N;e[5]!==r?(N=(Q,Z)=>{r(Q,Z),Z!==void 0&&Q!=="duration"&&M(Z)},e[5]=r,e[6]=N):N=e[6];const $=N,P="insert-video-editor",A="Insert scene timing";let T;e[7]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("strong",{children:"Insert a new scene"}),e[7]=T):T=e[7];const R=o?`Original @${o.address} · ${p>0?bt(p):"duration unavailable"}`:"Choose an original video";let E;e[8]!==R?(E=t.jsxs("header",{children:[T,t.jsx("span",{children:R})]}),e[8]=R,e[9]=E):E=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 I=o?.asset?.mediaUrl&&t.jsxs("div",{className:"insert-video-monitor",children:[t.jsx("video",{ref:c,src:o.asset.mediaUrl,poster:o.asset.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"metadata","aria-label":"Original video for insert",onTimeUpdate:Q=>u(Q.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||f||d<1.625||d>60||d>=p,onClick:()=>$("start_time",Number(d.toFixed(3))),children:"Replace from here"}),t.jsx("button",{type:"button",disabled:a||f||d<=(g??1.625)||d>60,onClick:()=>$("resume_time",Number(d.toFixed(3))),children:"Resume from here"})]})]});let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("strong",{children:"Original"}),e[11]=D):D=e[11];const L=p>0?bt(p):"—";let _;e[12]!==L?(_=t.jsxs("div",{className:"insert-video-track-heading",children:[D,t.jsxs("span",{children:["0s → ",L]})]}),e[12]=L,e[13]=_):_=e[13];const z=v?`Original: keep 0 to ${g}s, replace ${g} to ${h}s, keep ${h} to ${p}s`:"Original video: choose a valid replacement range",O=v?t.jsxs("div",{className:"insert-video-track-content",style:{width:`${p/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:p-h,title:`Keep · ${bt(p-h)}`})]}):t.jsx("span",{className:"insert-video-track-empty",children:"Set the two cut points below"});let U;e[14]!==z||e[15]!==O?(U=t.jsx("div",{className:"insert-video-track",role:"img","aria-label":z,children:O}),e[14]=z,e[15]=O,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, ${j}s new scene, ${bt(p-h)} original ending, ${bt(k)} total`,ae=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:j,title:`New scene · ${bt(j)}`}),t.jsx(hs,{kind:"kept",length:p-h,title:`Ending · ${bt(p-h)}`})]}):t.jsx("span",{className:"insert-video-track-empty",children:"Original opening → new scene → original ending"});let V;e[22]!==se||e[23]!==ae?(V=t.jsx("div",{className:"insert-video-track",role:"img","aria-label":se,children:ae}),e[22]=se,e[23]=ae,e[24]=V):V=e[24];let oe;e[25]===Symbol.for("react.memo_cache_sentinel")?(oe=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]=oe):oe=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,oe]}),e[26]=_,e[27]=U,e[28]=K,e[29]=V,e[30]=W):W=e[30];let te;e[31]!==I||e[32]!==W?(te=t.jsxs("div",{className:"insert-video-visuals",children:[I,W]}),e[31]=I,e[32]=W,e[33]=te):te=e[33];let le;e[34]!==f?(le=f&&t.jsx("p",{role:"status",children:"Source playback is unavailable. You can still set the cut points below."}),e[34]=f,e[35]=le):le=e[35];const Y=Vi.map(Q=>{const Z=i.find(me=>me.name===Q.name),de=qs(n,Q.name)??(Q.name==="duration"?j:void 0),fe=Q.name==="duration"?13:Math.min(60,p||60);return t.jsxs("div",{className:"insert-video-field",children:[t.jsx("label",{htmlFor:`${b}-${Q.name}`,children:t.jsxs("span",{children:[Q.label," ",t.jsx("small",{children:"(seconds)"})]})}),t.jsxs("div",{className:"insert-video-time-input",children:[t.jsx("input",{id:`${b}-${Q.name}`,type:"number",step:"any",min:Z?.minimum,max:fe,value:de??"",disabled:a,"aria-describedby":y?b:void 0,"aria-invalid":!!y,onChange:me=>$(Q.name,me.target.value===""?void 0:me.target.valueAsNumber)}),Q.name!=="duration"&&t.jsx("button",{type:"button","aria-label":`View ${Q.label.toLowerCase()} cut point`,disabled:a||de===void 0||de>p||f||!o?.asset?.mediaUrl,onClick:()=>M(de),children:"View"})]}),t.jsx("input",{type:"range","aria-label":`${Q.label} slider`,min:Q.name==="duration"?5:1.625,max:Math.max(Q.name==="duration"?5:1.625,fe),step:"0.001",value:Math.min(fe,Math.max(Q.name==="duration"?5:1.625,de??1.625)),disabled:a||Q.name!=="duration"&&p<=1.625,onChange:me=>$(Q.name,me.target.valueAsNumber)}),t.jsx("small",{children:Q.hint})]},Q.name)});let ee;e[36]!==Y?(ee=t.jsx("div",{className:"insert-video-fields",children:Y}),e[36]=Y,e[37]=ee):ee=e[37];const J=y?t.jsx("p",{className:"insert-video-error",id:b,role:"alert",children:y}):v&&t.jsxs("p",{className:"insert-video-summary",role:"status",children:["Replace ",bt(g),"–",bt(h)," of @",o?.address," with ",bt(j)," of new footage. Result: ",bt(k),"."]});let re;return e[38]!==te||e[39]!==le||e[40]!==ee||e[41]!==J||e[42]!==E||e[43]!==F?(re=t.jsxs("section",{className:P,"aria-label":A,children:[E,F,te,le,ee,J]}),e[38]=te,e[39]=le,e[40]=ee,e[41]=J,e[42]=E,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 Ws(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 Fd(l){const e=X.c(35),{active:s,entry:n,now:i,pinned:a,showBook:r,onPin:o,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 f;e[2]!==n.surface?(f=ci(n.surface),e[2]=n.surface,e[3]=f):f=e[3];let m;e[4]!==f?(m=t.jsx("span",{className:"prompt-history-surface",children:f}),e[4]=f,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 p;e[8]!==n.book||e[9]!==r?(p=r&&n.book&&t.jsx("span",{className:"prompt-history-faint",children:n.book}),e[8]=n.book,e[9]=r,e[10]=p):p=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 j;e[16]!==m||e[17]!==b||e[18]!==p||e[19]!==h?(j=t.jsxs("span",{className:"prompt-history-meta",children:[m,b,p,h]}),e[16]=m,e[17]=b,e[18]=p,e[19]=h,e[20]=j):j=e[20];let x;e[21]!==c||e[22]!==u||e[23]!==j?(x=t.jsxs("button",{type:"button",className:"prompt-history-use",title:"Use this prompt",onClick:c,children:[u,j]}),e[21]=c,e[22]=u,e[23]=j,e[24]=x):x=e[24];const y=a?"Unpin prompt":"Pin prompt",v=a?"Unpin prompt":"Pin prompt";let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(Vo,{size:11,"aria-hidden":"true"}),e[25]=k):k=e[25];let w;e[26]!==o||e[27]!==a||e[28]!==y||e[29]!==v?(w=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-pressed":a,"aria-label":y,title:v,onClick:o,children:k}),e[26]=o,e[27]=a,e[28]=y,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 _d(l){const e=X.c(89),{history:s}=l,[n,i]=C.useState(0);let a,r,o,c,d,u,f,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 A=P,T=re=>{if(re.key==="Escape"){re.preventDefault(),re.stopPropagation(),s.close();return}if(re.key==="ArrowDown"||re.key==="ArrowUp"){re.preventDefault();const Q=re.key==="ArrowDown"?1:-1;i(Math.min(Math.max(N+Q,0),Math.max(0,b.length-1)));return}if(re.key==="Enter"&&re.target instanceof HTMLInputElement){const Q=b[N];if(!Q)return;re.preventDefault(),re.stopPropagation(),s.use(Q.prompt)}};c="prompt-history-popover",d="dialog",u="Prompt history",f=T;let R,E;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("span",{className:"confirm-section-label",children:"Prompt history"}),E=t.jsx("span",{className:"prompt-history-faint",children:"newest first"}),e[13]=R,e[14]=E):(R=e[13],E=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 I;e[16]!==s.close?(I=t.jsxs("div",{className:"prompt-history-title",children:[R,E,t.jsx("button",{type:"button",className:"prompt-history-icon","aria-label":"Close history",onClick:s.close,children:F})]}),e[16]=s.close,e[17]=I):I=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(rs,{size:11,"aria-hidden":"true"}),e[18]=D):D=e[18];let L;e[19]!==s?(L=re=>{s.setQuery(re.target.value),i(0)},e[19]=s,e[20]=L):L=e[20];let _;e[21]!==s.query||e[22]!==L?(_=t.jsxs("label",{className:"prompt-history-search",children:[D,t.jsx("input",{type:"search","aria-label":"Search prompts",placeholder:"Search prompts…",autoFocus:!0,value:s.query,onChange:L})]}),e[21]=s.query,e[22]=L,e[23]=_):_=e[23];const z=s.scope==="book";let O;e[24]!==s?(O=()=>s.setScope("book"),e[24]=s,e[25]=O):O=e[25];let U;e[26]!==z||e[27]!==O?(U=t.jsx(Ws,{active:z,label:"This book",onClick:O}),e[26]=z,e[27]=O,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(Ws,{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 ae=s.surfaceFilter==="surface";let V;e[37]!==s?(V=()=>s.setSurfaceFilter("surface"),e[37]=s,e[38]=V):V=e[38];let oe;e[39]!==A||e[40]!==ae||e[41]!==V?(oe=t.jsx(Ws,{active:ae,label:A,onClick:V}),e[39]=A,e[40]=ae,e[41]=V,e[42]=oe):oe=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 le;e[45]!==W||e[46]!==te?(le=t.jsx(Ws,{active:W,label:"All surfaces",onClick:te}),e[45]=W,e[46]=te,e[47]=le):le=e[47];let Y;e[48]!==oe||e[49]!==le?(Y=t.jsxs("span",{className:"prompt-history-segments",role:"group","aria-label":"Surface",children:[oe,le]}),e[48]=oe,e[49]=le,e[50]=Y):Y=e[50];let ee;e[51]!==_||e[52]!==se||e[53]!==Y?(ee=t.jsxs("div",{className:"prompt-history-filters",children:[_,se,Y]}),e[51]=_,e[52]=se,e[53]=Y,e[54]=ee):ee=e[54],e[55]!==I||e[56]!==ee?(m=t.jsxs("div",{className:"prompt-history-head",children:[I,ee]}),e[55]=I,e[56]=ee,e[57]=m):m=e[57],a="prompt-history-list",r=s.loading;let J;e[58]!==N||e[59]!==s||e[60]!==$?(J=(re,Q)=>t.jsx(Fd,{active:Q===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]=J):J=e[61],o=b.map(J),e[0]=n,e[1]=s,e[2]=a,e[3]=r,e[4]=o,e[5]=c,e[6]=d,e[7]=u,e[8]=f,e[9]=m,e[10]=b}else a=e[2],r=e[3],o=e[4],c=e[5],d=e[6],u=e[7],f=e[8],m=e[9],b=e[10];let p;e[62]!==s.entries?.length||e[63]!==s.error||e[64]!==s.loading||e[65]!==b.length?(p=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]=p):p=e[66];let g;e[67]!==a||e[68]!==r||e[69]!==o||e[70]!==p?(g=t.jsxs("ul",{className:a,"aria-busy":r,children:[o,p]}),e[67]=a,e[68]=r,e[69]=o,e[70]=p,e[71]=g):g=e[71];let h,j;e[72]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("kbd",{children:"↑"}),j=t.jsx("kbd",{children:"↓"}),e[72]=h,e[73]=j):(h=e[72],j=e[73]);let x;e[74]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("kbd",{children:"↵"}),e[74]=x):x=e[74];let y,v;e[75]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("kbd",{children:"⌥↑"}),v=t.jsx("kbd",{children:"⌥↓"}),e[75]=y,e[76]=v):(y=e[75],v=e[76]);let k;e[77]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsxs("span",{children:[h,j," move · ",x," use · ",y,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]!==f||e[87]!==m?(M=t.jsxs("div",{className:c,role:d,"aria-label":u,onKeyDown:f,children:[m,g,S]}),e[81]=g,e[82]=S,e[83]=c,e[84]=d,e[85]=u,e[86]=f,e[87]=m,e[88]=M):M=e[88],M}function cf(l){const e=X.c(33),{history:s,disabled:n}=l,a=(n===void 0?!1:n)||!s.available;let r;e[0]!==s?(r=w=>{if(!s.open)return;const S=w.relatedTarget;S instanceof Node&&w.currentTarget.contains(S)||s.close()},e[0]=s,e[1]=r):r=e[1];const o=r;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(tn,{size:12,"aria-hidden":"true"}),e[5]=u):u=e[5];let f;e[6]!==s.older||e[7]!==d?(f=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]=f):f=e[8];const m=a||!s.canNewer;let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(Bn,{size:12,"aria-hidden":"true"}),e[9]=b):b=e[9];let p;e[10]!==s.newer||e[11]!==m?(p=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]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=t.jsxs("span",{className:"prompt-history-steppers",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let h,j;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Un,{size:11,"aria-hidden":"true"}),j=t.jsx("span",{children:"History"}),e[16]=h,e[17]=j):(h=e[16],j=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 y;e[20]!==s.open||e[21]!==s.toggleOpen||e[22]!==a||e[23]!==x?(y=t.jsxs("button",{type:"button",className:"prompt-history-toggle","aria-expanded":s.open,"aria-haspopup":"dialog",disabled:a,onClick:s.toggleOpen,children:[h,j,x]}),e[20]=s.open,e[21]=s.toggleOpen,e[22]=a,e[23]=x,e[24]=y):y=e[24];let v;e[25]!==s?(v=s.open&&t.jsx(_d,{history:s}),e[25]=s,e[26]=v):v=e[26];let k;return e[27]!==o||e[28]!==g||e[29]!==y||e[30]!==v||e[31]!==c?(k=t.jsxs("div",{className:"prompt-history-controls",onBlur:o,children:[c,g,y,v]}),e[27]=o,e[28]=g,e[29]=y,e[30]=v,e[31]=c,e[32]=k):k=e[32],k}function Ld(l){return l instanceof HTMLElement?{tagName:l.tagName,type:l instanceof HTMLInputElement?l.type:null}:null}function zd(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 Od(l){const e=X.c(11),s=C.useRef(null),{applyDisabled:n,applyFormId:i,applyScopeSelector:a,busy:r,enabled:o,onCancel:c}=l,d=o===void 0?!0:o;let u,f;e[0]!==n||e[1]!==i||e[2]!==a||e[3]!==r||e[4]!==d||e[5]!==c?(u=()=>{if(!d)return;const b=p=>{if(p.defaultPrevented||p.isComposing||r||document.querySelector('dialog[open], :popover-open, [aria-modal="true"], [role="menu"], details.canvas-add-menu[open]'))return;const g=p.target;if(a&&p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&!p.altKey){const h=document.getElementById(i);if(!(h instanceof HTMLFormElement)||!(g instanceof Node)||!h.closest(a)?.contains(g))return;p.preventDefault(),n||h.requestSubmit();return}p.key==="Escape"&&(g!==document.body&&(!(g instanceof Element)||!g.closest(".command-composer"))||g instanceof Element&&g.closest('input, textarea, select, [contenteditable="true"]')||(p.preventDefault(),c()))};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},f=[n,i,a,r,d,c],e[0]=n,e[1]=i,e[2]=a,e[3]=r,e[4]=d,e[5]=c,e[6]=u,e[7]=f):(u=e[6],f=e[7]),C.useLayoutEffect(u,f);let m;return e[8]!==d||e[9]!==l?(m={sheetRef:s,onKeyDown:p=>{if(!d||p.nativeEvent.isComposing||document.querySelector(":popover-open"))return;const g=vr({key:p.key,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,defaultPrevented:p.defaultPrevented,target:Ld(p.target)},{busy:l.busy});if(g==="none")return;if(p.preventDefault(),p.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:Bd,children:n}),e[0]=n,e[1]=s,e[2]=i):i=e[2],i}function Bd(l){return l.stopPropagation()}function Ud(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 r;e[7]!==s.replyLabel?(r=t.jsx("span",{children:s.replyLabel}),e[7]=s.replyLabel,e[8]=r):r=e[8];let o;return e[9]!==n||e[10]!==i||e[11]!==a||e[12]!==r?(o=t.jsxs(t.Fragment,{children:[n,i,a,r]}),e[9]=n,e[10]=i,e[11]=a,e[12]=r,e[13]=o):o=e[13],o}function Hd(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(Ud,{presentation:i}),e[2]=i,e[3]=a):a=e[3];let r;return e[4]!==i.badge||e[5]!==a?(r=t.jsx("div",{className:"cell-published-post",role:"group","aria-label":i.badge,children:a}),e[4]=i.badge,e[5]=a,e[6]=r):r=e[6],r}function df(l){const e=X.c(24),{inputs:s}=l;let n,i,a,r,o,c,d,u,f;if(e[0]!==s){f=Symbol.for("react.early_return_sentinel");e:{if(n=di(s),!n){f=null;break e}i="inspector-published-post",a=n.badge,r=t.jsx("span",{className:"inspector-media-field-label",children:n.badge});let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{children:"Root"}),e[10]=p):p=e[10],o=t.jsxs("p",{children:[p,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(Kd)}e[0]=s,e[1]=n,e[2]=i,e[3]=a,e[4]=r,e[5]=o,e[6]=c,e[7]=d,e[8]=u,e[9]=f}else n=e[1],i=e[2],a=e[3],r=e[4],o=e[5],c=e[6],d=e[7],u=e[8],f=e[9];if(f!==Symbol.for("react.early_return_sentinel"))return f;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]!==r||e[18]!==o||e[19]!==c||e[20]!==d||e[21]!==u||e[22]!==m?(b=t.jsxs("section",{className:i,"aria-label":a,children:[r,o,c,d,u,m]}),e[15]=i,e[16]=a,e[17]=r,e[18]=o,e[19]=c,e[20]=d,e[21]=u,e[22]=m,e[23]=b):b=e[23],b}function Kd(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 Vd(l){return l==="copied"?"Copied":l==="failed"?"Retry":"Copy"}function qd(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 Wd(l){const e=X.c(6),{label:s,running:n,disabled:i,onClick:a}=l;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ni,{size:12,"aria-hidden":"true"}),e[0]=r):r=e[0];let o;return e[1]!==i||e[2]!==s||e[3]!==a||e[4]!==n?(o=t.jsx("button",{type:"button",className:"inspector-insight-rerun","aria-label":s,title:s,"aria-busy":n,disabled:i,onClick:a,children:r}),e[1]=i,e[2]=s,e[3]=a,e[4]=n,e[5]=o):o=e[5],o}function Xd(l){const e=X.c(8),{icon:s,label:n,runningLabel:i,running:a,disabled:r,onClick:o}=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]!==r||e[3]!==s||e[4]!==o||e[5]!==a||e[6]!==d?(u=t.jsxs("button",{type:"button",className:"inspector-insight-action","aria-busy":a,disabled:r,onClick:o,children:[s,d]}),e[2]=r,e[3]=s,e[4]=o,e[5]=a,e[6]=d,e[7]=u):u=e[7],u}function Ol(l){const e=X.c(91),{source:s,title:n,transcript:i,busy:a,transcribing:r,onTranscribe:o,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d}=l,[u,f]=C.useState(null),[m,b]=C.useState("idle"),[p,g]=C.useState(null),[h,j]=C.useState(null),[x,y]=C.useState(null),[v,k]=C.useState(!1);let w,S,M,N,$,P,A,T,R;if(e[0]!==x||e[1]!==h||e[2]!==v||e[3]!==p||e[4]!==o||e[5]!==u||e[6]!==s||e[7]!==i){R=Mr(i,u);let ue;e[17]!==i?(ue=wr(i),e[17]=i,e[18]=ue):ue=e[18],N=ue,P=s==="elevenlabs",T=s==="elevenlabs"?o:void 0;let be;e[19]!==P||e[20]!==i?(be=P&&Nr(i),e[19]=P,e[20]=i,e[21]=be):be=e[21],S=be,w=Cr({source:s,transcript:i,view:R,jsonText:p}),$=$r({transcript:i,view:R,jsonFile:h}),M=Ir({source:s,transcript:i,view:R,jsonText:p}),A=Rr({source:s,transcript:i,view:R,jsonLoading:v,jsonError:x,body:w}),e[0]=x,e[1]=h,e[2]=v,e[3]=p,e[4]=o,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]=A,e[15]=T,e[16]=R}else w=e[8],S=e[9],M=e[10],N=e[11],$=e[12],P=e[13],A=e[14],T=e[15],R=e[16];const E=A,F=!!i,I=!!M;let D;e[22]!==M?(D=async()=>{if(M)try{await navigator.clipboard.writeText(M),b("copied")}catch{b("failed")}},e[22]=M,e[23]=D):D=e[23];const L=D;let _;e[24]!==F||e[25]!==v||e[26]!==p||e[27]!==c||e[28]!==s?(_=ue=>{ue==="json"&&!F||(f(ue),!(ue!=="json"||p!==null||v||!c)&&(k(!0),y(null),c(s).then(be=>{g(be.text),j(be.file)}).catch(be=>{y(be instanceof Error?be.message:String(be))}).finally(()=>{k(!1)})))},e[24]=F,e[25]=v,e[26]=p,e[27]=c,e[28]=s,e[29]=_):_=e[29];const z=_;let O;e[30]!==n?(O=t.jsx("span",{className:"inspector-media-field-label",children:n}),e[30]=n,e[31]=O):O=e[31];let U;e[32]!==I||e[33]!==L||e[34]!==m||e[35]!==n?(U=I&&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:()=>{L()},children:[m==="copied"?t.jsx(Qt,{size:12,"aria-hidden":"true"}):t.jsx(en,{size:12,"aria-hidden":"true"}),t.jsx("span",{"aria-live":"polite",children:Vd(m)})]}),e[32]=I,e[33]=L,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(Ps,{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]!==T||e[45]!==r?(H=T&&N&&t.jsx(Wd,{label:"Transcribe again",running:!!r,disabled:a||!!r,onClick:T}),e[42]=a,e[43]=N,e[44]=T,e[45]=r,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]!==O||e[52]!==K?(se=t.jsxs("header",{className:"inspector-insight-header",children:[O,K]}),e[51]=O,e[52]=K,e[53]=se):se=e[53];const ae=`${n} view`,V=R==="text",oe=R==="text"?"inspector-transcript-tab active":"inspector-transcript-tab";let W;e[54]!==z?(W=()=>z("text"),e[54]=z,e[55]=W):W=e[55];let te;e[56]!==V||e[57]!==oe||e[58]!==W?(te=t.jsx("button",{type:"button",role:"tab","aria-selected":V,className:oe,onClick:W,children:"TEXT"}),e[56]=V,e[57]=oe,e[58]=W,e[59]=te):te=e[59];const le=R==="json",Y=!F,ee=!F,J=F?"JSON":s==="plain"?"No GPT-4o translation":"No ElevenLabs transcript",re=R==="json"?"inspector-transcript-tab active":"inspector-transcript-tab";let Q;e[60]!==z?(Q=()=>z("json"),e[60]=z,e[61]=Q):Q=e[61];let Z;e[62]!==le||e[63]!==Y||e[64]!==ee||e[65]!==J||e[66]!==re||e[67]!==Q?(Z=t.jsx("button",{type:"button",role:"tab","aria-selected":le,"aria-disabled":Y,disabled:ee,title:J,className:re,onClick:Q,children:"JSON"}),e[62]=le,e[63]=Y,e[64]=ee,e[65]=J,e[66]=re,e[67]=Q,e[68]=Z):Z=e[68];let de;e[69]!==ae||e[70]!==te||e[71]!==Z?(de=t.jsxs("div",{className:"inspector-transcript-tabs",role:"tablist","aria-label":ae,children:[te,Z]}),e[69]=ae,e[70]=te,e[71]=Z,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 me;e[75]!==w||e[76]!==a||e[77]!==E||e[78]!==N||e[79]!==n||e[80]!==T||e[81]!==r||e[82]!==i||e[83]!==R?(me=w&&!E?t.jsx(qd,{text:w,label:`${n} ${R}`}):t.jsxs("div",{className:"inspector-insight-empty",children:[t.jsx("p",{children:E??"No transcript yet."}),T&&!N&&t.jsx(Xd,{icon:t.jsx(qo,{size:13,"aria-hidden":"true"}),label:i?"Transcribe again":"Transcribe",runningLabel:"Transcribing…",running:!!r,disabled:a||!!r,onClick:T})]}),e[75]=w,e[76]=a,e[77]=E,e[78]=N,e[79]=n,e[80]=T,e[81]=r,e[82]=i,e[83]=R,e[84]=me):me=e[84];let pe;return e[85]!==de||e[86]!==fe||e[87]!==me||e[88]!==se||e[89]!==n?(pe=t.jsxs("section",{className:"inspector-insight-block","aria-label":n,children:[se,de,fe,me]}),e[85]=de,e[86]=fe,e[87]=me,e[88]=se,e[89]=n,e[90]=pe):pe=e[90],pe}function uf(l){const e=X.c(19),{artifactId:s,transcript:n,busy:i,transcribing:a,error:r,onTranscribe:o,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d}=l,u=`${s}:plain`,f=n?.plain??null;let m;e[0]!==i||e[1]!==c||e[2]!==u||e[3]!==f?(m=t.jsx(Ol,{source:"plain",title:kr,transcript:f,busy:i,onLoadTranscriptJson:c},u),e[0]=i,e[1]=c,e[2]=u,e[3]=f,e[4]=m):m=e[4];const b=`${s}:elevenlabs`,p=n?.elevenlabs??null;let g;e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==o||e[9]!==b||e[10]!==p||e[11]!==a?(g=t.jsx(Ol,{source:"elevenlabs",title:Sr,transcript:p,busy:i,transcribing:a,onTranscribe:o,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d},b),e[5]=i,e[6]=d,e[7]=c,e[8]=o,e[9]=b,e[10]=p,e[11]=a,e[12]=g):g=e[12];let h;e[13]!==r?(h=r&&t.jsxs("p",{className:"inspector-insight-error",role:"alert",children:[t.jsx(wi,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:r})]}),e[13]=r,e[14]=h):h=e[14];let j;return e[15]!==m||e[16]!==g||e[17]!==h?(j=t.jsxs("div",{className:"inspector-media-insights",children:[m,g,h]}),e[15]=m,e[16]=g,e[17]=h,e[18]=j):j=e[18],j}function mf(l){const e=X.c(33),{bookId:s,artifactId:n,kind:i,busy:a,call:r}=l;let o;e[0]!==n||e[1]!==s||e[2]!==r?(o={call:r,bookId:s,artifactId:n},e[0]=n,e[1]=s,e[2]=r,e[3]=o):o=e[3];const{state:c,available:d,run:u}=Pr(o),f=c.phase==="running",m=a||!d||f,b=f&&c.action==="copy";let p;e[4]!==u?(p=()=>{u("copy")},e[4]=u,e[5]=p):p=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=f&&c.action==="copy"?"Copying…":`Copy ${i}`;let j;e[7]!==m||e[8]!==b||e[9]!==p||e[10]!==h?(j=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":b,title:"Copy the original media file to the clipboard",onClick:p,children:[g,h]}),e[7]=m,e[8]=b,e[9]=p,e[10]=h,e[11]=j):j=e[11];const x=f&&c.action==="download";let y;e[12]!==u?(y=()=>{u("download")},e[12]=u,e[13]=y):y=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Ps,{size:13,"aria-hidden":"true"}),e[14]=v):v=e[14];const k=f&&c.action==="download"?"Downloading…":`Download ${i}`;let w;e[15]!==m||e[16]!==k||e[17]!==x||e[18]!==y?(w=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":x,title:"Save the original media file to Downloads",onClick:y,children:[v,k]}),e[15]=m,e[16]=k,e[17]=x,e[18]=y,e[19]=w):w=e[19];let S;e[20]!==w||e[21]!==j?(S=t.jsxs("div",{className:"inspector-media-file-buttons",children:[j,w]}),e[20]=w,e[21]=j,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 Gd={people:"People",places:"Places",editing:"Editing",custom:"Custom"};function ff(l){const e=X.c(53),{tags:s,busy:n,error:i,canEdit:a,suggestions:r,onAdd:o,onRemove:c,onRestore:d,onQueryChange:u,status:f,onRetry:m}=l,[b,p]=C.useState(""),g=C.useRef(null),h=C.useId();let j;e[0]!==s?.effective?(j=s?.effective??[],e[0]=s?.effective,e[1]=j):j=e[1];let x;e[2]!==j?(x=ui(j),e[2]=j,e[3]=x):x=e[3];const y=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]!==o||e[9]!==u?(w=function(){const _=b.trim();!_||!a||(o({label:_}),p(""),u(""),g.current?.focus())},e[6]=a,e[7]=b,e[8]=o,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(),p(""),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]!==y||e[17]!==c){let L;e[19]!==a||e[20]!==c?(L=_=>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]=L):L=e[21],$=y.map(L),e[15]=a,e[16]=y,e[17]=c,e[18]=$}else $=e[18];let P;e[22]!==y.length||e[23]!==f?(P=y.length===0?t.jsx("span",{className:"asset-tag-empty",children:f??"No tags yet"}):null,e[22]=y.length,e[23]=f,e[24]=P):P=e[24];let A;e[25]!==$||e[26]!==P?(A=t.jsxs("div",{className:"asset-tag-chips",role:"list",children:[$,P]}),e[25]=$,e[26]=P,e[27]=A):A=e[27];let T;e[28]!==a||e[29]!==S||e[30]!==b||e[31]!==N||e[32]!==h||e[33]!==u||e[34]!==r?(T=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:L=>{p(L.target.value),u(L.target.value)},onKeyDown:N}),t.jsx("datalist",{id:h,children:r.map(Yd)}),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]=r,e[35]=T):T=e[35];let R;e[36]!==A||e[37]!==T?(R=t.jsxs("div",{className:"asset-tag-row",children:[A,T]}),e[36]=A,e[37]=T,e[38]=R):R=e[38];let E;e[39]!==a||e[40]!==k||e[41]!==d?(E=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(L=>t.jsxs("span",{className:"asset-tag-chip asset-tag-chip-dismissed",role:"listitem",children:[t.jsx("span",{className:"asset-tag-chip-label",children:L.label}),a?t.jsx("button",{type:"button",className:"asset-tag-chip-restore",onClick:()=>d({facet:L.facet,label:L.label}),"aria-label":`Restore tag ${L.label}`,title:"Restore this tag",children:t.jsx(On,{size:11})}):null]},`dismissed-${L.facet}/${L.key}`))})]}):null,e[39]=a,e[40]=k,e[41]=d,e[42]=E):E=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 I;e[46]!==n?(I=n?t.jsx("span",{className:"sr-only",role:"status",children:"Saving tags"}):null,e[46]=n,e[47]=I):I=e[47];let D;return e[48]!==R||e[49]!==E||e[50]!==F||e[51]!==I?(D=t.jsxs("section",{className:"asset-tag-editor","aria-label":"Asset tags",children:[R,E,F,I]}),e[48]=R,e[49]=E,e[50]=F,e[51]=I,e[52]=D):D=e[52],D}function Yd(l){return t.jsx("option",{value:l.label,children:`${Gd[l.facet]} · ${l.assets} asset${l.assets===1?"":"s"}`},`${l.facet}/${l.key}`)}function Qs(...l){return ga(ya(l))}const Jd={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 Qd(l){const e=X.c(5),{value:s,colorScheme:n}=l,i=Jd[n];let a;e[0]!==i?(a=Qs("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 r;return e[2]!==a||e[3]!==s?(r=t.jsx("span",{className:a,children:s}),e[2]=a,e[3]=s,e[4]=r):r=e[4],r}const Zd={Zap:ec,Sparkles:Mi,Scissors:Kn,Mic:ki,Check:Qt,Clapperboard:Zo,Mailbox:Qo,ClipboardCopy:Ci,Columns3:Ri,FolderOpen:Jo,History:Un,Eye:Ii,Users:Yo,Archive:Go,NotebookPen:Xo,Rows3:$i,Stethoscope:Wo,Images:Hn};function eu(l){return Zd[l]}const Yt=8,Tn=320,Bl=80,Sn=2,tu=460;function su(l,e,s,n){const i=l.top-Yt*2,a=e.height-l.bottom-Yt*2,r=s?i>=Math.min(Tn,a)||i>a:a<Bl+Sn&&i>a,c=Math.max(Bl,Math.min(Tn,(r?i:a)-Sn)),d=c+Sn,u=r?Math.max(Yt,l.top-Yt-d):Math.max(Yt,Math.min(l.bottom+Yt,e.height-Yt-d)),f=n??Math.max(l.width,200),m=Math.min(Math.max(Yt,l.left),e.width-f-Yt);return{top:u,left:m,width:f,maxHeight:c,placeAbove:r}}function nu(l){return l?.closest("dialog[open]")??document.body}function lu(l,e,s){const n=l.getBoundingClientRect();return su({top:n.top,bottom:n.bottom,left:n.left,width:n.width},{width:window.innerWidth,height:window.innerHeight},e,s)}const Xs={size:13,"aria-hidden":!0};function iu(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,{...Xs}),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,{...Xs}),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,{...Xs}),e[2]=i):i=e[2],i}let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(Ms,{...Xs}),e[3]=n):n=e[3],n}function pf(l){const e=X.c(59),{items:s,selectedIndex:n,onSelect:i,onHover:a,anchorRef:r,preferAbove:o,widthPx:c}=l,d=o===void 0?!0:o,u=C.useRef(null),[f,m]=C.useState(null),[b,p]=C.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=[],e[0]=g):g=e[0];const[h,j]=C.useState(g),x=r!=null;let y,v;e[1]!==n?(y=()=>{u.current?.querySelector(`[data-option-index="${n}"]`)?.scrollIntoView({block:"nearest"})},v=[n],e[1]=n,e[2]=y,e[3]=v):(y=e[2],v=e[3]),C.useEffect(y,v);let k;e[4]!==r||e[5]!==d||e[6]!==x||e[7]!==c?(k=()=>{if(!x||!r)return;const H=()=>{const K=r.current;K&&(m(lu(K,d,c)),p(nu(K)))};return H(),window.addEventListener("resize",H),window.addEventListener("scroll",H,!0),()=>{window.removeEventListener("resize",H),window.removeEventListener("scroll",H,!0)}},e[4]=r,e[5]=d,e[6]=x,e[7]=c,e[8]=k):k=e[8];let w;e[9]!==r||e[10]!==s.length||e[11]!==d||e[12]!==x||e[13]!==c?(w=[x,r,d,c,s.length],e[9]=r,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&&f?.placeAbove&&"origin-bottom",N=x&&f&&!f.placeAbove&&"origin-top";let $;e[15]!==S||e[16]!==M||e[17]!==N?($=Qs("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 A;e[19]!==f||e[20]!==x?(A=x&&f?{position:"fixed",top:f.top,left:f.left,width:f.width,zIndex:tu}:void 0,e[19]=f,e[20]=x,e[21]=A):A=e[21];const T=A;let R,E,F,I,D,L,_,z;if(e[22]!==h||e[23]!==s||e[24]!==P||e[25]!==T||e[26]!==a||e[27]!==i||e[28]!==f?.maxHeight||e[29]!==n){const H=s.map(cu),K=H.filter(ou),se=H.filter(ru);L=P,_=T,z=au,R=u,E="overflow-y-auto";const ae=f?.maxHeight??Tn;e[38]!==ae?(F={maxHeight:ae},e[38]=ae,e[39]=F):F=e[39];let V;e[40]!==h||e[41]!==a||e[42]!==i||e[43]!==n?(V=oe=>{const{item:W,index:te}=oe,le=W.icon?eu(W.icon):void 0,Y=W.thumbnailSrc&&!h.includes(W.thumbnailSrc)?W.thumbnailSrc:null,ee=W.type==="mention",J=Y!==null||W.mediaKind!==void 0;return t.jsxs("button",{type:"button","data-option-index":te,className:Qs("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:[J&&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:()=>j(re=>re.includes(Y)?re:[...re,Y])}):t.jsx(iu,{kind:W.mediaKind})}),t.jsx(Qd,{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()}):ee?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}),ee&&W.description&&t.jsx("span",{className:"shrink-0 text-[10px] tracking-[0.1em] text-[#8fb9a1]",children:W.description}),le&&!J&&t.jsx(le,{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],I=K.map(V),D=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(oe=>{const{item:W,index:te}=oe;return t.jsx("button",{type:"button","data-option-index":te,title:W.description,className:Qs("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]=T,e[26]=a,e[27]=i,e[28]=f?.maxHeight,e[29]=n,e[30]=R,e[31]=E,e[32]=F,e[33]=I,e[34]=D,e[35]=L,e[36]=_,e[37]=z}else R=e[30],E=e[31],F=e[32],I=e[33],D=e[34],L=e[35],_=e[36],z=e[37];let O;e[45]!==R||e[46]!==E||e[47]!==F||e[48]!==I||e[49]!==D?(O=t.jsxs("div",{ref:R,className:E,style:F,children:[I,D]}),e[45]=R,e[46]=E,e[47]=F,e[48]=I,e[49]=D,e[50]=O):O=e[50];let U;e[51]!==L||e[52]!==_||e[53]!==z||e[54]!==O?(U=t.jsx("div",{className:L,style:_,onMouseDown:z,children:O}),e[51]=L,e[52]=_,e[53]=z,e[54]=O,e[55]=U):U=e[55];const q=U;if(x){if(!f||!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 au(l){return l.preventDefault()}function ru(l){const{item:e}=l;return e.empty}function ou(l){const{item:e}=l;return!e.empty}function cu(l,e){return{item:l,index:e}}function du(l){const e=X.c(21),{tags:s,limit:n,onFilter:i,activeTerms:a}=l,r=n===void 0?4:n;let o,c,d,u,f,m;if(e[0]!==r||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 j=h.slice(0,r);o=h.length-j.length;const x=new Set(g.map(uu));c="asset-tag-summary",d="list",u="Tags";let y;e[10]!==x||e[11]!==i?(y=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(Ar(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]=y):y=e[12],f=j.map(y)}e[0]=r,e[1]=i,e[2]=a,e[3]=s?.effective,e[4]=o,e[5]=c,e[6]=d,e[7]=u,e[8]=f,e[9]=m}else o=e[4],c=e[5],d=e[6],u=e[7],f=e[8],m=e[9];if(m!==Symbol.for("react.early_return_sentinel"))return m;let b;e[13]!==o?(b=o>0?t.jsx("span",{className:"asset-tag-summary-more",role:"listitem",children:`+${o}`}):null,e[13]=o,e[14]=b):b=e[14];let p;return e[15]!==c||e[16]!==d||e[17]!==u||e[18]!==f||e[19]!==b?(p=t.jsxs("div",{className:c,role:d,"aria-label":u,children:[f,b]}),e[15]=c,e[16]=d,e[17]=u,e[18]=f,e[19]=b,e[20]=p):p=e[20],p}function uu(l){return`${l.facet}/${l.key}`}function mu(l){const e=X.c(54),{mode:s,reference:n,preparing:i,disabled:a,startSeconds:r,durationSeconds:o,children:c,onFile:d,onClear:u,onStartSeconds:f,onDurationSeconds:m}=l;let b;e[0]!==s?(b=Dr(s),e[0]=s,e[1]=b):b=e[1];const p=b,g=p==="image"?"an image":"a video",h=p==="image"?Zt:St,j=p==="image"?"image/*,.heic,.heif":"video/*";let x;e[2]!==a||e[3]!==p||e[4]!==d||e[5]!==i?(x=O=>{if(a||i)return;const U=O.find(q=>yl(q,p));U&&d(U)},e[2]=a,e[3]=p,e[4]=d,e[5]=i,e[6]=x):x=e[6];const y=x;let v;e[7]!==y?(v=O=>{O.preventDefault(),O.stopPropagation(),y([...O.dataTransfer.files])},e[7]=y,e[8]=v):v=e[8];const k=v;let w;e[9]!==p||e[10]!==y?(w=O=>{const U=[...O.clipboardData.files],q=U.length>0?U:[...O.clipboardData.items].flatMap(pu);q.some(H=>yl(H,p))&&(O.preventDefault(),O.stopPropagation(),y(q))},e[9]=p,e[10]=y,e[11]=w):w=e[11];const S=w;let M;e[12]!==h||e[13]!==p||e[14]!==i||e[15]!==n?(M=i?t.jsx(ut,{size:24}):n?.previewUrl?p==="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]=p,e[14]=i,e[15]=n,e[16]=M):M=e[16];const N=i?`Preparing ${p}…`: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 A;e[19]!==P?(A=t.jsx("span",{children:P}),e[19]=P,e[20]=A):A=e[20];let T;e[21]!==$||e[22]!==A?(T=t.jsxs("div",{children:[$,A]}),e[21]=$,e[22]=A,e[23]=T):T=e[23];let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(sn,{size:14}),e[24]=R):R=e[24];const E=a||i;let F;e[25]!==d?(F=O=>{const U=O.target.files?.[0];U&&d(U),O.target.value=""},e[25]=d,e[26]=F):F=e[26];let I;e[27]!==j||e[28]!==E||e[29]!==F?(I=t.jsxs("label",{className:"reverse-search-upload",children:[R,"Choose file",t.jsx("input",{type:"file",accept:j,disabled:E,onChange:F})]}),e[27]=j,e[28]=E,e[29]=F,e[30]=I):I=e[30];let D;e[31]!==a||e[32]!==u||e[33]!==i||e[34]!==n?(D=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]=D):D=e[35];let L;e[36]!==T||e[37]!==I||e[38]!==D||e[39]!==M?(L=t.jsxs("div",{className:"reverse-search-dropzone",tabIndex:0,autoFocus:!0,children:[M,T,I,D]}),e[36]=T,e[37]=I,e[38]=D,e[39]=M,e[40]=L):L=e[40];let _;e[41]!==o||e[42]!==p||e[43]!==m||e[44]!==f||e[45]!==n||e[46]!==r?(_=p==="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:r,onChange:O=>f(O.target.value)})]}),t.jsxs("label",{children:["Duration seconds",t.jsx("input",{type:"number",min:"0.1",step:"0.1",value:o,placeholder:"Whole remaining video",onChange:O=>m(O.target.value)})]}),n.durationMs!==void 0&&t.jsxs("span",{children:[(n.durationMs/1e3).toFixed(1),"s available"]})]}),e[41]=o,e[42]=p,e[43]=m,e[44]=f,e[45]=n,e[46]=r,e[47]=_):_=e[47];let z;return e[48]!==c||e[49]!==k||e[50]!==S||e[51]!==L||e[52]!==_?(z=t.jsxs("section",{className:"reverse-search-reference",onDragOver:fu,onDrop:k,onPaste:S,children:[L,c,_]}),e[48]=c,e[49]=k,e[50]=S,e[51]=L,e[52]=_,e[53]=z):z=e[53],z}function fu(l){l.dataTransfer.types.includes("Files")&&l.preventDefault()}function pu(l){const e=l.kind==="file"?l.getAsFile():null;return e?[e]:[]}const hu=[{id:"text",label:"Text",icon:rs},{id:"image-reverse",label:"Image reverse",icon:Zt},{id:"video-reverse",label:"Vid reverse",icon:St}];function En(l){return l==="all"?"media":l==="audio"?"audio":`${l}s`}function bu(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 xu(l){return l.mode!=="text"?"Most similar":l.query.trim()?"Best match":"Recently used"}function gu(l){return l.type==="image"||l.type==="video"||l.type==="final"}function yu(l){const e=X.c(45),{asset:s,state:n,targetBookId:i,busy:a,now:r,onAttach:o,onSimilar:c,onToggleTagFilter:d}=l,u=n.activeArtifactId===s.artifactId;let f;e[0]!==s.label?(f=s.label.trim()||"Untitled media",e[0]=s.label,e[1]=f):f=e[1];const m=f;let b;e[2]!==s.lastUsedAt||e[3]!==r?(b=bu(s.lastUsedAt,r),e[2]=s.lastUsedAt,e[3]=r,e[4]=b):b=e[4];const p=b;let g;e[5]!==s?(g=t.jsx(id,{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 j=s.owningBookId===i?" · this book":" · copy";let x;e[9]!==s.owningBookName||e[10]!==j?(x=t.jsxs("small",{children:[s.owningBookName,j]}),e[9]=s.owningBookName,e[10]=j,e[11]=x):x=e[11];let y;e[12]!==h||e[13]!==x?(y=t.jsxs("span",{className:"media-library-asset-copy",children:[h,x]}),e[12]=h,e[13]=x,e[14]=y):y=e[14];let v;e[15]!==p?(v=p&&t.jsxs("span",{className:"media-library-asset-used",children:["Used ",p]}),e[15]=p,e[16]=v):v=e[16];let k;e[17]!==s.tags||e[18]!==d||e[19]!==n.tagFilters?(k=t.jsx(du,{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=gu(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]!==o?($=()=>o(s),e[27]=s,e[28]=o,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 A;e[35]!==S||e[36]!==P?(A=t.jsxs("span",{className:"media-library-asset-actions",children:[S,P]}),e[35]=S,e[36]=P,e[37]=A):A=e[37];let T;return e[38]!==w||e[39]!==A||e[40]!==g||e[41]!==y||e[42]!==v||e[43]!==k?(T=t.jsxs("article",{className:"media-library-asset",children:[g,y,v,k,w,A]}),e[38]=w,e[39]=A,e[40]=g,e[41]=y,e[42]=v,e[43]=k,e[44]=T):T=e[44],T}function ju(l){const e=X.c(26),{state:s,onToggleTagFilter:n,onClearTagFilters:i,onTagQuery:a}=l;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("span",{className:"sr-only",children:"Filter by tag"}),e[0]=r):r=e[0];let o;e[1]!==a?(o=g=>a(g.target.value),e[1]=a,e[2]=o):o=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 j=s.tagSuggestions.find(x=>x.label.toLowerCase()===h.toLowerCase());j&&(n({facet:j.facet,key:j.key,label:j.label}),g.currentTarget.value="")},e[3]=n,e[4]=s.tagSuggestions,e[5]=c):c=e[5];let d;e[6]!==o||e[7]!==c?(d=t.jsxs("label",{className:"media-library-tag-input-label",children:[r,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:o,onKeyDown:c})]}),e[6]=o,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==s.tagSuggestions?(u=s.tagSuggestions.map(vu),e[9]=s.tagSuggestions,e[10]=u):u=e[10];let f;e[11]!==u?(f=t.jsx("datalist",{id:"media-library-tag-suggestions",children:u}),e[11]=u,e[12]=f):f=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 p;return e[21]!==d||e[22]!==f||e[23]!==m||e[24]!==b?(p=t.jsxs("div",{className:"media-library-tag-filters",children:[d,f,m,b]}),e[21]=d,e[22]=f,e[23]=m,e[24]=b,e[25]=p):p=e[25],p}function vu(l){return t.jsx("option",{value:l.label,children:`${l.facet} · ${l.assets}`},`${l.facet}/${l.key}`)}function ku(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 r;e[2]!==n||e[3]!==i||e[4]!==s.loading||e[5]!==s.preparingIndex||e[6]!==s.unindexedVisualAssets?(r=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]=r):r=e[7];let o;e[8]!==s.booksWithErrors.length?(o=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]=o):o=e[9];let c;return e[10]!==a||e[11]!==r||e[12]!==o?(c=t.jsxs(t.Fragment,{children:[a,r,o]}),e[10]=a,e[11]=r,e[12]=o,e[13]=c):c=e[13],c}function Su(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=En(n),e[1]=n,e[2]=a):a=e[2];let r;e[3]!==a?(r=t.jsxs("strong",{children:["No ",a," found"]}),e[3]=a,e[4]=r):r=e[4];const o=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]!==o?(c=t.jsx("span",{children:o}),e[5]=o,e[6]=c):c=e[6];let d;return e[7]!==r||e[8]!==c?(d=t.jsxs("div",{className:"media-library-empty",children:[i,r,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function hf(l){const e=X.c(93),{state:s,kind:n,accept:i,targetBookId:a,onClose:r,onMode:o,onDraftQuery:c,onSearch:d,onLoadMore:u,onAttach:f,onUpload:m,onSimilar:b,onToggleTagFilter:p}=l,g=C.useRef(null),h=l.disabled||s.activeArtifactId!==null||s.preparingReference||s.uploading,[j]=C.useState(wu);let x;e[0]!==h||e[1]!==r?(x=V=>{V.key!=="Escape"||h||V.nativeEvent.isComposing||(V.preventDefault(),V.stopPropagation(),r())},e[0]=h,e[1]=r,e[2]=x):x=e[2];const y=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 ${En(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]!==o||e[13]!==s.mode?(w=n!=="audio"&&t.jsx("div",{className:"media-library-modes",role:"tablist","aria-label":"Search mode",children:hu.map(V=>{const oe=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:()=>o(V.id),children:[t.jsx(oe,{size:13}),V.label]},V.id)})}),e[10]=h,e[11]=n,e[12]=o,e[13]=s.mode,e[14]=w):w=e[14];let S;e[15]!==l?(S=t.jsx(ju,{...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 A;e[24]!==m?(A=V=>{const oe=V.target.files?.[0];V.target.value="",oe&&m(oe)},e[24]=m,e[25]=A):A=e[25];let T;e[26]!==i||e[27]!==A?(T=t.jsx("input",{ref:g,className:"media-library-upload-input",type:"file",accept:i,tabIndex:-1,"aria-hidden":"true",onChange:A}),e[26]=i,e[27]=A,e[28]=T):T=e[28];let R;e[29]!==T||e[30]!==k||e[31]!==w||e[32]!==S||e[33]!==P?(R=t.jsxs("div",{className:"media-library-toolbar",children:[k,w,S,P,T]}),e[29]=T,e[30]=k,e[31]=w,e[32]=S,e[33]=P,e[34]=R):R=e[34];let E;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=s.mode!=="text"&&t.jsxs("div",{className:"media-library-search-panel",children:[t.jsx(mu,{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]=E):E=e[48];const F=s.loading||s.loadingMore;let I;e[49]!==h||e[50]!==l.onRepairIndexes||e[51]!==s?(I=t.jsx(ku,{state:s,busy:h,onRepairIndexes:l.onRepairIndexes}),e[49]=h,e[50]=l.onRepairIndexes,e[51]=s,e[52]=I):I=e[52];let D;e[53]!==h||e[54]!==n||e[55]!==j||e[56]!==f||e[57]!==b||e[58]!==p||e[59]!==s||e[60]!==a?(D=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(Su,{state:s,kind:n}):t.jsx("div",{className:"media-library-grid",children:s.assets.map(V=>t.jsx(yu,{asset:V,state:s,targetBookId:a,busy:h,now:j,onAttach:f,onSimilar:b,onToggleTagFilter:p},`${V.owningBookId}:${V.artifactId}`))}),e[53]=h,e[54]=n,e[55]=j,e[56]=f,e[57]=b,e[58]=p,e[59]=s,e[60]=a,e[61]=D):D=e[61];let L;e[62]!==F||e[63]!==I||e[64]!==D?(L=t.jsxs("div",{className:"media-library-results","aria-busy":F,children:[I,D]}),e[62]=F,e[63]=I,e[64]=D,e[65]=L):L=e[65];let _;e[66]!==s?(_=xu(s),e[66]=s,e[67]=_):_=e[67];let z;e[68]!==_?(z=t.jsx("strong",{children:_}),e[68]=_,e[69]=z):z=e[69];const O=s.assets.length,U=s.page.total;let q;e[70]!==n?(q=En(n),e[70]=n,e[71]=q):q=e[71];let H;e[72]!==s.assets.length||e[73]!==s.page.total||e[74]!==z||e[75]!==q?(H=t.jsxs("span",{children:[z," · ",O," of ",U," ",q]}),e[72]=s.assets.length,e[73]=s.page.total,e[74]=z,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 ae;return e[86]!==y||e[87]!==v||e[88]!==R||e[89]!==E||e[90]!==L||e[91]!==se?(ae=t.jsxs("section",{className:"media-library-panel","aria-label":v,onKeyDown:y,children:[R,E,L,se]}),e[86]=y,e[87]=v,e[88]=R,e[89]=E,e[90]=L,e[91]=se,e[92]=ae):ae=e[92],ae}function wu(){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 Nu(l){return l instanceof Error?l.message:String(l)}function Cu(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 $u(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 r=a.matrixTransform(i.inverse());return{x:Math.min(1,Math.max(0,e>0?r.x/e:0)),y:Math.min(1,Math.max(0,s>0?r.y/s:0))}}return Hr(l.clientX,l.clientY,n.getBoundingClientRect())}function Iu(l){const e=X.c(72),{mediaUrl:s,width:n,height:i,subjectMap:a,selectedIds:r,hiddenIds:o,regions:c,selectedRegionIds:d,drawMode:u,draftBox:f,snapRegionId:m,opacity:b,onToggle:p,onToggleRegion:g,onHoverRegion:h,onPointerDown:j,onPointerMove:x,onPointerUp:y,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 I;return e[2]!==s?(I=t.jsx("img",{src:s,alt:""}),e[2]=s,e[3]=I):I=e[3],I}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 I;e[16]!==i||e[17]!==n?(I=(D,L)=>D.layerUrl?t.jsx("mask",{id:`notebook-subject-mask-${L}`,className:"notebook-subject-mask",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:n,height:i,children:t.jsx("image",{href:D.layerUrl,width:n,height:i,preserveAspectRatio:"none"})},D.id):null,e[16]=i,e[17]=n,e[18]=I):I=e[18],P=w.map(I),e[12]=i,e[13]=w,e[14]=n,e[15]=P}else P=e[15];let A;e[19]!==P?(A=t.jsx("defs",{children:P}),e[19]=P,e[20]=A):A=e[20];let T;if(e[21]!==u||e[22]!==i||e[23]!==o||e[24]!==p||e[25]!==b||e[26]!==r||e[27]!==w||e[28]!==n){let I;e[30]!==u||e[31]!==i||e[32]!==o||e[33]!==p||e[34]!==b||e[35]!==r||e[36]!==n?(I=(D,L)=>{if(o.has(D.id))return null;const _=Cu(D,n,i),z=r.has(D.id);return t.jsxs("g",{className:`notebook-subject-overlay${z?" selected":""}`,onClick:O=>{u||(O.stopPropagation(),p(D.id))},onKeyDown:O=>{u||O.key!=="Enter"&&O.key!==" "||(O.preventDefault(),p(D.id))},role:"button",tabIndex:u?-1:0,"aria-label":`${z?"Deselect":"Select"} ${D.label}`,"aria-pressed":z,children:[t.jsx("title",{children:D.label}),D.layerUrl?t.jsx("rect",{width:n,height:i,fill:D.color,fillOpacity:z?Math.min(.9,b+.18):b,mask:`url(#notebook-subject-mask-${L})`,pointerEvents:"none"}):_?t.jsx("rect",{..._,fill:D.color,fillOpacity:z?Math.min(.72,b+.14):b,pointerEvents:"none"}):null,_&&t.jsx("rect",{..._,className:"notebook-subject-outline",fill:"none",stroke:z?"#ffffff":D.color,strokeWidth:Math.max(2,n/480),strokeDasharray:z?`${n/100} ${n/180}`:void 0,vectorEffect:"non-scaling-stroke"}),_&&t.jsx("rect",{..._,className:"notebook-subject-hit",fill:"transparent",pointerEvents:u?"none":"all"})]},D.id)},e[30]=u,e[31]=i,e[32]=o,e[33]=p,e[34]=b,e[35]=r,e[36]=n,e[37]=I):I=e[37],T=w.map(I),e[21]=u,e[22]=i,e[23]=o,e[24]=p,e[25]=b,e[26]=r,e[27]=w,e[28]=n,e[29]=T}else T=e[29];let R;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 I;e[47]!==u||e[48]!==i||e[49]!==h||e[50]!==g||e[51]!==d||e[52]!==m||e[53]!==n?(I=(D,L)=>{const _=$u(D,n,i),z=d.has(D.id);return t.jsxs("g",{className:`notebook-subject-overlay notebook-region-overlay${z?" selected":""}`,onClick:O=>{u||(O.stopPropagation(),g(D.id))},onPointerEnter:()=>h(D.id),onPointerLeave:()=>h(null),role:"button",tabIndex:u?-1:0,"aria-label":`${z?"Deselect":"Select"} region ${L+1}`,"aria-pressed":z,children:[t.jsx("title",{children:D.matchedSubjectId?`Region ${L+1} snapped to subject`:`Drawn region ${L+1}`}),t.jsx("rect",{..._,fill:ws,fillOpacity:z?.28:.16,pointerEvents:"none"}),t.jsx("rect",{..._,className:"notebook-subject-outline",fill:"none",stroke:z?"#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===D.id&&t.jsx("title",{children:"Snap to nearby subject available"})]},D.id)},e[47]=u,e[48]=i,e[49]=h,e[50]=g,e[51]=d,e[52]=m,e[53]=n,e[54]=I):I=e[54],R=c.map(I),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]=R}else R=e[46];let E;e[55]!==f||e[56]!==i||e[57]!==n?(E=f&&t.jsx("rect",{x:f.x*n,y:f.y*i,width:f.width*n,height:f.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]=f,e[56]=i,e[57]=n,e[58]=E):E=e[58];let F;return e[59]!==v||e[60]!==j||e[61]!==x||e[62]!==y||e[63]!==E||e[64]!==S||e[65]!==M||e[66]!==N||e[67]!==$||e[68]!==A||e[69]!==T||e[70]!==R?(F=t.jsxs("svg",{className:S,viewBox:M,preserveAspectRatio:"xMidYMid meet",role:"group","aria-label":"Image with detected subject overlays",onPointerDown:j,onPointerMove:x,onPointerUp:y,onPointerCancel:v,onLostPointerCapture:v,children:[N,$,A,T,R,E]}),e[59]=v,e[60]=j,e[61]=x,e[62]=y,e[63]=E,e[64]=S,e[65]=M,e[66]=N,e[67]=$,e[68]=A,e[69]=T,e[70]=R,e[71]=F):F=e[71],F}function Ru(l){const e=X.c(20),{mediaUrl:s,subjectMap:n,selectedIds:i}=l,a=n.width??0,r=n.height??0;if(!n.baseUrl||a<=0||r<=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 o=`0 0 ${a} ${r}`;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]!==r||e[4]!==n.baseUrl||e[5]!==a?(d=t.jsx("image",{href:n.baseUrl,width:a,height:r,preserveAspectRatio:"xMidYMid meet"}),e[3]=r,e[4]=n.baseUrl,e[5]=a,e[6]=d):d=e[6];let u;if(e[7]!==r||e[8]!==i||e[9]!==n.subjects||e[10]!==a){let m;e[12]!==r||e[13]!==i||e[14]!==a?(m=b=>!i.has(b.id)&&b.layerUrl?t.jsx("image",{href:b.layerUrl,width:a,height:r,preserveAspectRatio:"none"},b.id):null,e[12]=r,e[13]=i,e[14]=a,e[15]=m):m=e[15],u=n.subjects.map(m),e[7]=r,e[8]=i,e[9]=n.subjects,e[10]=a,e[11]=u}else u=e[11];let f;return e[16]!==o||e[17]!==d||e[18]!==u?(f=t.jsxs("svg",{className:"notebook-subject-stage-svg",viewBox:o,preserveAspectRatio:"xMidYMid meet",role:"img","aria-label":"Preview with selected subjects removed",children:[c,d,u]}),e[16]=o,e[17]=d,e[18]=u,e[19]=f):f=e[19],f}function Mu(l){const e=X.c(41),{analysisUnavailableReason:s,checkingCache:n,analyzing:i,analysisFailed:a,ready:r,hasTargets:o,subjectCount:c,regionCount:d,error:u,onAnalyze:f}=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 p;return e[2]!==s?(p=t.jsxs("div",{className:"notebook-subject-state unavailable",children:[m,b,t.jsx("p",{children:s})]}),e[2]=s,e[3]=p):p=e[3],p}if(n&&!o){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${o?" compact":""}`,b=o?14:18;let p;e[5]!==b?(p=t.jsx(ut,{size:b}),e[5]=b,e[6]=p):p=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=o?"Analysis continues in the background.":"Analysis continues in the background. You can draw a region meanwhile.";let j;e[8]!==h?(j=t.jsx("p",{children:h}),e[8]=h,e[9]=j):j=e[9];let x;return e[10]!==m||e[11]!==p||e[12]!==j?(x=t.jsxs("div",{className:m,children:[p,g,j]}),e[10]=m,e[11]=p,e[12]=j,e[13]=x):x=e[13],x}if(a){const m=`notebook-subject-state error${o?" compact":""}`,b=o?14:18;let p;e[14]!==b?(p=t.jsx(yn,{size:b}),e[14]=b,e[15]=p):p=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 j;e[17]!==h?(j=t.jsx("p",{children:h}),e[17]=h,e[18]=j):j=e[18];let x;e[19]!==o?(x=!o&&t.jsx("p",{children:"You can still draw a region to edit, replace, or remove."}),e[19]=o,e[20]=x):x=e[20];let y;e[21]!==f?(y=()=>f(),e[21]=f,e[22]=y):y=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]!==y?(k=t.jsxs("button",{type:"button",onClick:y,children:[v,"Retry"]}),e[24]=y,e[25]=k):k=e[25];let w;return e[26]!==m||e[27]!==k||e[28]!==p||e[29]!==j||e[30]!==x?(w=t.jsxs("div",{className:m,children:[p,g,j,x,k]}),e[26]=m,e[27]=k,e[28]=p,e[29]=j,e[30]=x,e[31]=w):w=e[31],w}if(r&&c===0&&d===0){let m,b,p;e[32]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ns,{size:18}),b=t.jsx("strong",{children:"No editable subjects found"}),p=t.jsx("p",{children:"Draw a region or try analysis again if the image changed."}),e[32]=m,e[33]=b,e[34]=p):(m=e[32],b=e[33],p=e[34]);let g;e[35]!==f?(g=()=>f(!0),e[35]=f,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 j;return e[38]!==g?(j=t.jsxs("div",{className:"notebook-subject-state empty",children:[m,b,p,t.jsxs("button",{type:"button",onClick:g,children:[h,"Analyze again"]})]}),e[38]=g,e[39]=j):j=e[39],j}if(!r&&!n&&!o){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 Pu(l){const e=X.c(8),{targets:s,candidates:n,replacements:i,onPick:a}=l;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("span",{children:"Replacement images"}),e[0]=r):r=e[0];let o;e[1]!==n||e[2]!==a||e[3]!==i||e[4]!==s?(o=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 f=i[d.key]===u.artifactId;return t.jsxs("button",{type:"button",role:"option","aria-selected":f,className:`notebook-replacement-option${f?" 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]=o):o=e[5];let c;return e[6]!==o?(c=t.jsxs("div",{className:"notebook-replacement-list",children:[r,o]}),e[6]=o,e[7]=c):c=e[7],c}function bf({address:l,mediaUrl:e,width:s,height:n,details:i,subjectMap:a,subjectMapLoading:r,analysisUnavailableReason:o,initialRegions:c,instruction:d,onInstructionChange:u,replacementCandidates:f,closeRef:m,imageEditModels:b,imageEditModelsLoading:p,defaultImageEditModelId:g,onEstimateImageEditCost:h,onAnalyzeSubjects:j,onEditingChange:x,onEditSubjects:y,onSubmitInstruction:v,onBack:k,onClose:w}){const S=C.useId(),M=C.useId(),N=C.useId(),$=C.useRef(!1),P=C.useRef(null),[A,T]=C.useState(()=>new Set),[R,E]=C.useState(()=>new Set),[F,I]=C.useState(()=>[...c??[]]),[D,L]=C.useState(()=>new Set(c?.map(ne=>ne.id))),[_,z]=C.useState(!1),[O,U]=C.useState(null),[q,H]=C.useState(null),[K,se]=C.useState({}),[ae,V]=C.useState(!1),[oe,W]=C.useState(!1),[te,le]=C.useState(.42),[Y,ee]=C.useState(null),[J,re]=C.useState(null),[Q,Z]=C.useState(null),[de,fe]=C.useState(null),me=a?.status==="ready",pe=C.useMemo(()=>a?.subjects??[],[a]),ue=C.useMemo(()=>pe.filter(ne=>A.has(ne.id)),[A,pe]),be=C.useMemo(()=>F.filter(ne=>D.has(ne.id)),[F,D]),ye=C.useMemo(()=>Tr(be,ue,F),[F,be,ue]),ce=Er(ye,K),G=Fr(d).length>0||ye.some(ne=>!!K[ne.key]),ie=G?"replace":"edit",he=Q??g??b?.[0]?.id??null,ke=ne=>ne.capabilities[G?"regionReplace":"semantic"],we=ne=>{h&&h(ne,ie).then(xe=>{$.current&&fe(xe)}).catch(()=>{$.current&&fe(null)})},Ie=F.find(ne=>ne.id===q)??null,Ne=Ie?_r(Ie.box,pe):null,Me=r&&a?.status!=="analyzing"&&Y!=="analyze",Fe=a?.status==="analyzing"||Y==="analyze",et=a?.status==="failed",Ye=!!(o||!j||Y&&Y!=="analyze"||Me||Fe),Ke=F.length>0||me&&pe.length>0,Ve=Lr(ue,ye,G),lt=!G&&ye.length===0,Te=d.trim(),We=!!v&&Y===null&&(Te.length>0?Ve!==null||lt:ce),Xe=G?"Replace with image":"Apply edit";C.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const Je=async(ne,xe)=>{if(!Y){ee(ne),re(null),ne!=="analyze"&&x?.(!0);try{const Pe=await xe();$.current&&Pe&&re({tone:"success",text:Pe})}catch(Pe){$.current&&re({tone:"error",text:Nu(Pe)})}finally{$.current&&(ee(null),ne!=="analyze"&&x?.(!1))}}},tt=(ne=!1)=>{if(me&&!ne){W(!1),V(xe=>!xe);return}j&&Je("analyze",async()=>(await j(ne),null))},Re=()=>{!y||ye.length===0||Je("remove",async()=>await y({operation:"remove",subjectIds:ue.map(xe=>xe.id),...be.length>0?{editRegions:be.map(xe=>xe.box),...he?{model:he}:{}}:{}})?"Removal queued as a new image.":null)},Ee=()=>{if(!v||!We)return;const ne={...Ur(ue.map(xe=>xe.id),be,Object.fromEntries(ye.flatMap(xe=>K[xe.key]?[[xe.key,K[xe.key]]]:[]))),...he?{model:he}:{}};Je("apply",async()=>{const xe=await v(Te,ne);if(!xe.ok)throw new Error(xe.message);return xe.message})},qe=ne=>{ne.key!=="Enter"||!(ne.metaKey||ne.ctrlKey)||(ne.preventDefault(),Ee())},_e=()=>{P.current=null,U(null)},ve=()=>{_e(),z(ne=>!ne),W(!1),V(!1)},Qe=ne=>{I(xe=>xe.filter(Pe=>Pe.id!==ne)),L(xe=>{const Pe=new Set(xe);return Pe.delete(ne),Pe}),se(xe=>{const Pe={...xe};return delete Pe[ne],Pe})},nt=()=>{Ie&&I(ne=>ne.map(xe=>xe.id===Ie.id?Br(xe,pe):xe))},At=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)))},Dt=ne=>{if(!_||!P.current)return;const xe=jl(P.current,wn(ne,s,n));if(_e(),!xe)return;const Pe={id:Or(F),box:xe};I(Ge=>[...Ge,Pe]),L(Ge=>new Set([...Ge,Pe.id])),V(!1),W(!1)},Ze=Me?"Loading…":Fe?"Analyzing…":me?ae?"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(tn,{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:me&&!ae?"active":"","aria-pressed":me?!ae:void 0,disabled:Ye,title:Ze,onClick:()=>tt(),children:[Me||Fe?t.jsx(ut,{size:18}):me&&!ae?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:ve,children:[t.jsx(tc,{size:18}),t.jsx("span",{children:"Draw region"})]}),me&&a?.baseUrl&&t.jsxs("button",{type:"button",className:oe?"active":"","aria-pressed":oe,disabled:ue.length===0||be.length>0||Y!==null,title:"Preview removal",onClick:()=>{W(ne=>!ne),V(!1),z(!1)},children:[t.jsx(Rl,{size:18}),t.jsx("span",{children:oe?"Show overlays":"Preview removal"})]})]}),t.jsxs("div",{className:"notebook-subject-stage",children:[me&&a&&oe?t.jsx(Ru,{mediaUrl:e,subjectMap:a,selectedIds:A}):t.jsx(Iu,{mediaUrl:e,width:s,height:n,subjectMap:ae?null:a,selectedIds:A,hiddenIds:R,regions:ae?[]:F,selectedRegionIds:D,drawMode:_,draftBox:O,snapRegionId:Ne?q:null,opacity:te,onToggle:ne=>T(xe=>ks(xe,ne)),onToggleRegion:ne=>L(xe=>ks(xe,ne)),onHoverRegion:H,onPointerDown:At,onPointerMove:wt,onPointerUp:Dt,onCancelDraw:_e}),_&&t.jsx("p",{className:"image-editor-stage-hint","aria-live":"polite",children:"Drag on the image to draw a region"}),Ne&&Ie&&!_&&t.jsxs("button",{type:"button",className:"notebook-region-snap",onClick:nt,children:["Snap to ",pe.find(ne=>ne.id===Ne.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(),Ee()},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(ue,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:he??"",disabled:p,onChange:ne=>{Z(ne.target.value),fe(null),we(ne.target.value)},onFocus:()=>{he&&de===null&&we(he)},children:(b??[]).map(ne=>t.jsxs("option",{value:ne.id,disabled:!ke(ne),children:[ne.label,ke(ne)?"":" — cannot edit this target"]},ne.id))}),t.jsx("p",{className:"image-editor-cost",role:"status",children:p?"Loading models…":de===null?"Cost estimate unavailable":`Estimated provider cost ${de}`})]}),J&&t.jsx("p",{className:`image-editor-status ${J.tone}`,role:"status",children:J.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||!y,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(Mu,{analysisUnavailableReason:o,checkingCache:Me,analyzing:Fe,analysisFailed:et&&!Fe,ready:me,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:[ue.length+D.size," selected"]}),me&&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=>le(Number(ne.target.value))})]}),me&&pe.length>0&&t.jsx("button",{type:"button",onClick:()=>T(new Set(ue.length===pe.length?[]:pe.map(ne=>ne.id))),children:ue.length===pe.length?"Clear":"Select all"})]}),F.map((ne,xe)=>{const Pe=D.has(ne.id),Ge=pe.find(at=>at.id===ne.matchedSubjectId);return t.jsxs("div",{className:`notebook-subject-row${Pe?" selected":""}`,children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:Pe,"aria-label":`Select region ${xe+1}`,onChange:()=>L(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)}),me&&pe.map(ne=>{const xe=A.has(ne.id),Pe=R.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:()=>T(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":`${Pe?"Show":"Hide"} ${ne.label} overlay`,"aria-pressed":!Pe,onClick:()=>E(Ge=>ks(Ge,ne.id)),children:Pe?t.jsx(Il,{size:14}):t.jsx(Ii,{size:14})})]},ne.id)}),ye.length>0&&t.jsx(Pu,{targets:ye,candidates:f,replacements:K,onPick:(ne,xe)=>se(Pe=>({...Pe,[ne]:xe}))})]})]})]})]})}const Au={"arrange-column":Ri,"arrange-row":$i,duplicate:en,download:Ps,"extract-frame":nc,"generate-image":Zt,"generate-video":Rs,generations:Un,"group-images":Hn,inspect:sc,library:Vn,media:Pi,run:As,source:Ms,split:Kn,upload:sn,more:qn};function Ul(l){return[...l.querySelectorAll('[role="menuitem"]')].filter(e=>!e.disabled)}function xf(l){const e=X.c(47),{actions:s,address:n,cellType:i,deleteDisabled:a,menuId:r,menuLabel:o,position:c,returnFocus:d,onAction:u,onClose:f,onDelete:m}=l,b=a===void 0?!1:a,p=C.useRef(null);let g,h;e[0]!==c.x||e[1]!==c.y?(g=()=>{const D=p.current;if(!D)return;const L=()=>{const z=Math.max(8,Math.min(c.x,window.innerWidth-D.offsetWidth-8-1)),O=Math.max(8,Math.min(c.y,window.innerHeight-D.offsetHeight-8-1));D.style.left=`${z}px`,D.style.top=`${O}px`};L();const _=new ResizeObserver(L);return _.observe(D),Ul(D)[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 j,x;e[4]!==f?(j=()=>{const D=_=>{const z=_.target;!(z instanceof Node)||p.current?.contains(z)||f()},L=()=>f();return document.addEventListener("pointerdown",D,!0),window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{document.removeEventListener("pointerdown",D,!0),window.removeEventListener("blur",L),window.removeEventListener("resize",L)}},x=[f],e[4]=f,e[5]=j,e[6]=x):(j=e[5],x=e[6]),C.useEffect(j,x);let y;e[7]!==f||e[8]!==d?(y=()=>{f(),d?.isConnected&&d.focus({preventScroll:!0})},e[7]=f,e[8]=d,e[9]=y):y=e[9];const v=y;let k;e[10]!==u||e[11]!==f?(k=D=>{f(),u(D)},e[10]=u,e[11]=f,e[12]=k):k=e[12];const w=k;let S;e[13]!==b||e[14]!==f||e[15]!==m||e[16]!==v?(S=D=>{const L=p.current;if(!L)return;if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),v();return}if(D.key==="Tab"){f();return}if(m&&!b&&(D.key==="Delete"||D.key==="Backspace")){D.preventDefault(),D.stopPropagation(),f(),m();return}if(D.key!=="ArrowDown"&&D.key!=="ArrowUp"&&D.key!=="Home"&&D.key!=="End")return;D.preventDefault(),D.stopPropagation();const _=Ul(L);if(_.length===0)return;const z=_.findIndex(Tu),O=D.key==="Home"?0:D.key==="End"?_.length-1:D.key==="ArrowDown"?(z+1+_.length)%_.length:(z-1+_.length)%_.length;_[O]?.focus()},e[13]=b,e[14]=f,e[15]=m,e[16]=v,e[17]=S):S=e[17];const M=S,N=o??`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 A;e[23]!==i?(A=t.jsx("span",{children:i}),e[23]=i,e[24]=A):A=e[24];let T;e[25]!==P||e[26]!==A?(T=t.jsxs("div",{className:"cell-context-menu-heading","aria-hidden":"true",children:[P,A]}),e[25]=P,e[26]=A,e[27]=T):T=e[27];let R;if(e[28]!==s||e[29]!==w){let D;e[31]!==w?(D=L=>{const _=Au[L.icon];return t.jsxs("button",{type:"button",role:"menuitem","data-cell-action":L.id,"data-workspace-action-surface":L.id==="more"?"cell-menu":void 0,disabled:L.disabled,onClick:()=>w(L.id),children:[t.jsx(_,{size:15,"aria-hidden":"true"}),t.jsx("span",{children:L.label})]},L.id)},e[31]=w,e[32]=D):D=e[32],R=s.map(D),e[28]=s,e[29]=w,e[30]=R}else R=e[30];let E;e[33]!==R?(E=t.jsx("div",{className:"cell-context-menu-actions",role:"presentation",children:R}),e[33]=R,e[34]=E):E=e[34];let F;e[35]!==b||e[36]!==f||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:()=>{f(),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]=f,e[37]=m,e[38]=F):F=e[38];let I;if(e[39]!==M||e[40]!==r||e[41]!==$||e[42]!==T||e[43]!==E||e[44]!==F||e[45]!==N){const D=t.jsxs("div",{ref:p,id:r,className:"cell-context-menu","data-composer-focus":"return",role:"menu","aria-label":N,style:$,onContextMenu:Du,onKeyDown:M,children:[T,E,F]});I=typeof document>"u"?D:gs.createPortal(D,document.body),e[39]=M,e[40]=r,e[41]=$,e[42]=T,e[43]=E,e[44]=F,e[45]=N,e[46]=I}else I=e[46];return I}function Du(l){return l.preventDefault()}function Tu(l){return l===document.activeElement}function gf(l){const e=X.c(91),{activeBook:s,books:n,disabled:i,error:a,loading:r,open:o,onCreate:c,onDelete:d,onOpenChange:u,onRefresh:f,onRename:m,onSelect:b}=l,p=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[j,x]=C.useState(h),[y,v]=C.useState(""),[k,w]=C.useState(""),[S,M]=C.useState(null),[N,$]=C.useState(null),P=j.kind==="rename"?j.bookId:null,A=j.kind==="create",T=j.kind==="delete"?j.bookId:null;let R;e[1]===Symbol.for("react.memo_cache_sentinel")?(R=G=>{G!==void 0&&G&&g.current?.focus(),x({kind:"idle"}),v(""),w(""),$(null)},e[1]=R):R=e[1];const E=R;let F;e[2]!==j||e[3]!==u||e[4]!==S?(F=G=>{const ie=G===void 0?!1:G;fs(j,{kind:"close"},S!==null).closeMenu&&(E(ie),u(!1))},e[2]=j,e[3]=u,e[4]=S,e[5]=F):F=e[5];const I=F;let D,L;e[6]!==I||e[7]!==j||e[8]!==u||e[9]!==o||e[10]!==S?(D=()=>{if(!o)return;const G=he=>{p.current?.contains(he.target)||I()},ie=he=>{if(he.key!=="Escape")return;const ke=fs(j,{kind:"escape"},S!==null);if(ke.closeMenu){he.preventDefault(),E(!0),u(!1);return}ke.mode!==j&&(he.preventDefault(),E(!0))};return document.addEventListener("pointerdown",G),document.addEventListener("focusin",G),document.addEventListener("keydown",ie),()=>{document.removeEventListener("pointerdown",G),document.removeEventListener("focusin",G),document.removeEventListener("keydown",ie)}},L=[I,j,u,o,S,E],e[6]=I,e[7]=j,e[8]=u,e[9]=o,e[10]=S,e[11]=D,e[12]=L):(D=e[11],L=e[12]),C.useEffect(D,L);let _;e[13]!==j||e[14]!==S?(_=()=>{const G=fs(j,{kind:"begin-create"},S!==null);G.mode!==j&&(x(G.mode),v(""),$(null))},e[13]=j,e[14]=S,e[15]=_):_=e[15];const z=_;let O;e[16]!==j||e[17]!==S?(O=G=>{const ie=fs(j,{kind:"begin-rename",bookId:G.bookId},S!==null);ie.mode!==j&&(x(ie.mode),w(""),$(null),v(G.name))},e[16]=j,e[17]=S,e[18]=O):O=e[18];const U=O;let q;e[19]!==n||e[20]!==j||e[21]!==S?(q=G=>{if(n.length<2)return;const ie=fs(j,{kind:"begin-delete",bookId:G},S!==null);ie.mode!==j&&(x(ie.mode),v(""),w(""),$(null))},e[19]=n,e[20]=j,e[21]=S,e[22]=q):q=e[22];const H=q;let K;e[23]!==j||e[24]!==S?(K=()=>{fs(j,{kind:"cancel"},S!==null).mode!==j&&E(!0)},e[23]=j,e[24]=S,e[25]=K):K=e[25];const se=K;let ae;e[26]!==s?.bookId||e[27]!==I||e[28]!==i||e[29]!==b||e[30]!==S?(ae=async G=>{if(i||S||G===s?.bookId){G===s?.bookId&&I(!0);return}$(null),M({kind:"select",bookId:G});const ie=await b(G);if(M(null),!ie.ok){$(ie.error);return}I(!0)},e[26]=s?.bookId,e[27]=I,e[28]=i,e[29]=b,e[30]=S,e[31]=ae):ae=e[31];const V=ae;let oe;e[32]!==n||e[33]!==se||e[34]!==y||e[35]!==P||e[36]!==m||e[37]!==S?(oe=async G=>{if(G?.preventDefault(),!P||S)return;const ie=ms(y),he=n.find(we=>we.bookId===P);if(!ie){$(cl);return}if(ie===he?.name){se();return}$(null),M({kind:"rename",bookId:P});const ke=await m(P,ie);if(M(null),!ke.ok){$(ke.error);return}se()},e[32]=n,e[33]=se,e[34]=y,e[35]=P,e[36]=m,e[37]=S,e[38]=oe):oe=e[38];const W=oe;let te;e[39]!==k||e[40]!==c||e[41]!==u||e[42]!==S?(te=async G=>{if(G?.preventDefault(),S)return;const ie=ms(k);if(!ie){$(cl);return}$(null),M({kind:"create"});const he=await c(ie);if(M(null),!he.ok){$(he.error);return}E(!0),u(!1)},e[39]=k,e[40]=c,e[41]=u,e[42]=S,e[43]=te):te=e[43];const le=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 ie=await d(G.bookId,G.name);if(M(null),!ie.ok){$(ie.error);return}E(!0)},e[44]=n,e[45]=d,e[46]=S,e[47]=Y):Y=e[47];const ee=Y;let J;e[48]!==I||e[49]!==u||e[50]!==o?(J=()=>{if(o){I();return}u(!0)},e[48]=I,e[49]=u,e[50]=o,e[51]=J):J=e[51];const re=J;let Q;e[52]!==s?(Q=s?xn(s.artifactCount):"No active project",e[52]=s,e[53]=Q):Q=e[53];const Z=Q,de=i||S!==null,fe=s?.name??"select-project";let me;e[54]!==fe?(me=t.jsx("strong",{children:fe}),e[54]=fe,e[55]=me):me=e[55];let pe;e[56]!==Z||e[57]!==s?(pe=s&&t.jsx("span",{className:"book-project-active-count",title:Z,children:s.artifactCount}),e[56]=Z,e[57]=s,e[58]=pe):pe=e[58];let ue;e[59]===Symbol.for("react.memo_cache_sentinel")?(ue=t.jsx(Is,{size:14}),e[59]=ue):ue=e[59];let be;e[60]!==o||e[61]!==me||e[62]!==pe||e[63]!==re?(be=t.jsxs("button",{ref:g,type:"button",className:"brand-project-menu-toggle","aria-controls":"book-project-menu","aria-expanded":o,"aria-haspopup":"menu",onClick:re,children:[me,pe,ue]}),e[60]=o,e[61]=me,e[62]=pe,e[63]=re,e[64]=be):be=e[64];let ye;e[65]!==s?.bookId||e[66]!==z||e[67]!==H||e[68]!==U||e[69]!==n||e[70]!==se||e[71]!==ee||e[72]!==k||e[73]!==A||e[74]!==T||e[75]!==y||e[76]!==P||e[77]!==a||e[78]!==r||e[79]!==de||e[80]!==f||e[81]!==o||e[82]!==N||e[83]!==S||e[84]!==V||e[85]!==le||e[86]!==W?(ye=o&&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"}),r&&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:r,onClick:f,children:"Retry"})]}),N&&!P&&!A&&!T&&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:[r&&n.length===0&&t.jsxs("div",{className:"book-project-menu-empty",children:[t.jsx(ut,{size:15}),t.jsx("span",{children:"Loading projects"})]}),!r&&n.length===0&&t.jsx("div",{className:"book-project-menu-empty",children:"No projects available"}),n.map(G=>{const ie=G.bookId===s?.bookId,he=G.bookId===P,ke=G.bookId===T,we=S&&"bookId"in S?S.bookId===G.bookId:!1,Ie=n.length>1;return he?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:y,onChange:Ne=>v(Ne.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})})]}),y&&ms(y)!==y&&t.jsxs("small",{className:"book-project-form-hint",children:["Slug: ",ms(y)||"Enter letters or numbers"]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]},G.bookId):ke?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:()=>{ee(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 ${ie?"active":""}`,"aria-busy":we,children:[t.jsxs("button",{type:"button",className:"book-project-select",role:"menuitem","aria-current":ie?"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(lc,{size:13})}),t.jsx("button",{type:"button",disabled:de||!Ie,title:Ie?`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:A?t.jsxs("form",{className:"book-project-form",onSubmit:le,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:z,children:[t.jsx(es,{size:14}),t.jsx("span",{children:"New project"})]})})]}),e[65]=s?.bookId,e[66]=z,e[67]=H,e[68]=U,e[69]=n,e[70]=se,e[71]=ee,e[72]=k,e[73]=A,e[74]=T,e[75]=y,e[76]=P,e[77]=a,e[78]=r,e[79]=de,e[80]=f,e[81]=o,e[82]=N,e[83]=S,e[84]=V,e[85]=le,e[86]=W,e[87]=ye):ye=e[87];let ce;return e[88]!==be||e[89]!==ye?(ce=t.jsxs("div",{className:"book-project-selector","data-composer-focus":"return",ref:p,children:[be,ye]}),e[88]=be,e[89]=ye,e[90]=ce):ce=e[90],ce}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:r=>{const o=r.target.value;a(o);try{n(o.trim()?JSON.parse(o):void 0),r.target.setCustomValidity("")}catch{r.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:r,choices:o,choiceName:c,onChange:d}=l,u=a===void 0?!1:a,f=r===void 0?!1:r,m=C.useId(),b=Kr(n),[p,g]=C.useState(null),h=p===null?Vr(n,i):{...n,...b[p]},j=n.title??$s(s),x=o[c??s];let y;e[0]!==x?(y=x?[...new Set(x.map(zu))]:[],e[0]=x,e[1]=y):y=e[1];const v=y,k=h.type==="object"||h.type==="array",w=b.findIndex(R=>Fn(R)===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 R=String(h.const);let E;return e[2]!==R?(E=t.jsx("strong",{children:R}),e[2]=R,e[3]=E):E=e[3],t.jsxs("div",{className:"workspace-action-fixed",children:[t.jsx("span",{children:j}),E]})}const $=()=>{if(S)return t.jsxs("select",{id:m,required:u,disabled:f,value:i===void 0?"":String(S.indexOf(i)),onChange:I=>d(I.target.value===""?void 0:S[Number(I.target.value)]),children:[t.jsx("option",{value:"",children:u?`Choose ${j.toLowerCase()}`:"Use default"}),S.map(Lu)]});if(x)return t.jsxs("select",{id:m,required:u,disabled:f,value:typeof i=="string"?i:"",onChange:I=>d(I.target.value||void 0),children:[t.jsx("option",{value:"",children:x.length?`Choose ${j.toLowerCase()}`:`No ${j.toLowerCase()} available`}),v.map(I=>{const D=x.filter(L=>(L.group??"")===I).map(_u);return I?t.jsx("optgroup",{label:I,children:D},I):D})]});if(!h.type)return t.jsx(Hl,{id:m,value:i,disabled:f,onChange:d});if(h.type==="null")return t.jsx("output",{id:m,children:"No value"});const R=h.type==="number"||h.type==="integer",E=h.format==="password"||/secret|password|api_key|access_token/u.test(s);return!R&&/prompt|text|description|markdown|content|script/u.test(s)?t.jsx("textarea",{id:m,value:typeof i=="string"?i:"",disabled:f,required:u,minLength:h.minLength,maxLength:h.maxLength,rows:4,onChange:I=>d(I.target.value)}):t.jsx("input",{id:m,type:R?"number":E?"password":"text",value:typeof i=="string"||typeof i=="number"?i:"",required:u,disabled:f,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:I=>d(R?I.target.value===""?void 0:Number(I.target.value):I.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 A;e[6]!==n.description?(A=n.description&&t.jsx("p",{className:"workspace-action-hint",children:n.description}),e[6]=n.description,e[7]=A):A=e[7];let T;return e[8]!==f||e[9]!==j||e[10]!==d||e[11]!==u||e[12]!==k||e[13]!==i?(T=k&&!u&&i!==void 0&&t.jsxs("button",{type:"button",disabled:f,onClick:()=>d(void 0),children:["Use default ",j.toLowerCase()]}),e[8]=f,e[9]=j,e[10]=d,e[11]=u,e[12]=k,e[13]=i,e[14]=T):T=e[14],t.jsxs("div",{className:`workspace-action-field${k?" workspace-action-structure":""}`,children:[t.jsxs("label",{htmlFor:m,children:[j,P]}),A,b.length>1&&t.jsx("select",{"aria-label":`${j} format`,disabled:f,value:Math.max(0,w),onChange:R=>{const E=Number(R.target.value);g(E),d(gn(b[E],!0))},children:b.map(Fu)}),k&&!u&&i===void 0?t.jsxs("button",{type:"button",disabled:f,onClick:()=>d(gn(h,!0)),children:["Add ",j.toLowerCase()]}):h.type==="object"?Object.keys(h.properties??{}).length?t.jsx("fieldset",{id:m,disabled:f,"aria-label":j,children:Object.entries(h.properties??{}).map(R=>{const[E,F]=R;return t.jsx(_n,{name:E,schema:F,value:M[E],choices:o,required:h.required?.includes(E),disabled:f,onChange:I=>d({...M,[E]:I})},E)})}):t.jsx(Hl,{id:m,value:i,disabled:f,onChange:d}):h.type==="array"?t.jsxs("fieldset",{id:m,disabled:f,"aria-label":j,children:[N.map((R,E)=>t.jsxs("div",{className:"workspace-action-array-row",children:[t.jsx(_n,{name:`${s} ${E+1}`,schema:h.items??{},value:R,required:!0,choices:o,choiceName:c??s,disabled:f,onChange:F=>d(N.map((I,D)=>D===E?F:I))}),t.jsx("button",{type:"button",disabled:f||N.length<=(h.minItems??0),"aria-label":`Remove ${j.toLowerCase()} ${E+1}`,onClick:()=>d(N.filter((F,I)=>I!==E)),children:"Remove"})]},E)),t.jsx("button",{type:"button",disabled:f||h.maxItems!==void 0&&N.length>=h.maxItems,onClick:()=>d([...N,gn(h.items??{},!0)]),children:"Add item"})]}):$(),T]})}function Fu(l,e){return t.jsx("option",{value:e,children:Fn(l)},e)}function _u(l){return t.jsxs("option",{value:l.value,disabled:l.available===!1,children:[l.label,l.detail?` · ${l.detail}`:""]},l.value)}function Lu(l,e){return t.jsx("option",{value:e,children:typeof l=="boolean"?l?"Yes":"No":String(l)},e)}function zu(l){return l.group??""}function Kl(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:null}function Gs(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 Ou(l){const e=X.c(32),{action:s,value:n,values:i,onOpen:a}=l;if(s.handler.kind!=="tool")return null;const r=s.handler.tool;if(r==="list_entities"){let o;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],o=Gs(n,"entities").map(d),e[0]=a,e[1]=n,e[2]=o}else o=e[2];let c;return e[5]!==o?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:o}),e[5]=o,e[6]=c):c=e[6],c}if(r==="list_notebooks"){let o;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],o=Gs(n,"notebooks").map(d),e[7]=a,e[8]=n,e[9]=o}else o=e[9];let c;return e[12]!==o?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:o}),e[12]=o,e[13]=c):c=e[13],c}if(r==="asset_history"||r==="list_book_actions"){let o;if(e[14]!==a||e[15]!==r||e[16]!==n||e[17]!==i){let d;e[19]!==a||e[20]!==r||e[21]!==i?(d=(u,f)=>{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(r==="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(r==="asset_history"?"tool.restore_asset_version":"tool.restore_edit_action",{...i,commit_hash:m,target_revision:m}),children:"Restore revision"})]})]},String(m??f))},e[19]=a,e[20]=r,e[21]=i,e[22]=d):d=e[22],o=Gs(n,r==="asset_history"?"commits":"actions").map(d),e[14]=a,e[15]=r,e[16]=n,e[17]=i,e[18]=o}else o=e[18];let c;return e[23]!==o?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:o}),e[23]=o,e[24]=c):c=e[24],c}if(r==="search_archive"){let o;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],o=Gs(n,"results").map(d),e[25]=a,e[26]=n,e[27]=o}else o=e[27];let c;return e[30]!==o?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:o}),e[30]=o,e[31]=c):c=e[31],c}return null}function Bu(l){const e=X.c(61),{media:s,values:n,disabled:i,onChange:a}=l,r=C.useRef(null),o=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,f=typeof n.h=="number"?n.h:1;let m;e[0]!==o?(m={aspectRatio:o},e[0]=o,e[1]=m):m=e[1];const b=m,p=`${c*100}%`,g=`${d*100}%`,h=`${u*100}%`,j=`${f*100}%`;let x;e[2]!==p||e[3]!==g||e[4]!==h||e[5]!==j?(x={left:p,top:g,width:h,height:j},e[2]=p,e[3]=g,e[4]=h,e[5]=j,e[6]=x):x=e[6];const y=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 A=n.ratio==="1:1";let T;e[25]!==k?(T=()=>k("1:1"),e[25]=k,e[26]=T):T=e[26];let R;e[27]!==i||e[28]!==A||e[29]!==T?(R=t.jsx("button",{type:"button",disabled:i,"aria-pressed":A,onClick:T,children:"Square 1:1"}),e[27]=i,e[28]=A,e[29]=T,e[30]=R):R=e[30];let E;e[31]!==M||e[32]!==P||e[33]!==R?(E=t.jsxs("div",{className:"workspace-crop-ratios",role:"group","aria-label":"Crop aspect ratio",children:[M,P,R]}),e[31]=M,e[32]=P,e[33]=R,e[34]=E):E=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),r.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 I;e[39]!==i||e[40]!==f||e[41]!==a||e[42]!==u?(I=H=>{const K=r.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-f,K.originY+(H.clientY-K.y)/se.height))})},e[39]=i,e[40]=f,e[41]=a,e[42]=u,e[43]=I):I=e[43];let D,L;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{r.current=null},L=()=>{r.current=null},e[44]=D,e[45]=L):(D=e[44],L=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 z;e[49]!==y?(z=t.jsx("div",{className:"workspace-crop-region",style:y}),e[49]=y,e[50]=z):z=e[50];let O;e[51]!==b||e[52]!==F||e[53]!==I||e[54]!==_||e[55]!==z?(O=t.jsxs("div",{className:"workspace-crop-frame",style:b,onPointerDown:F,onPointerMove:I,onPointerUp:D,onPointerCancel:L,children:[_,z]}),e[51]=b,e[52]=F,e[53]=I,e[54]=_,e[55]=z,e[56]=O):O=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]!==E||e[59]!==O?(q=t.jsxs("section",{className:"workspace-crop-preview","aria-label":"Crop preview",children:[E,O,U]}),e[58]=E,e[59]=O,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 o;if(e[0]!==i||e[1]!==s){let d;e[3]!==i?(d=(u,f)=>t.jsx("li",{children:t.jsx(Yn,{value:u,name:`${i} ${f+1}`})},f),e[3]=i,e[4]=d):d=e[4],o=s.map(d),e[0]=i,e[1]=s,e[2]=o}else o=e[2];let c;return e[5]!==i||e[6]!==o?(c=t.jsx("ol",{className:"workspace-action-result-list","aria-label":i,children:o}),e[5]=i,e[6]=o,e[7]=c):c=e[7],c}if(typeof s=="object"){let o;return e[8]!==s?(o=t.jsx("dl",{className:"workspace-action-result-fields",children:Object.entries(s).map(Uu)}),e[8]=s,e[9]=o):o=e[9],o}const a=typeof s=="boolean"?s?"Yes":"No":String(s);let r;return e[10]!==a?(r=t.jsx("span",{children:a}),e[10]=a,e[11]=r):r=e[11],r}function Uu(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 Hu({action:l,context:e,initialValues:s,initialResult:n,variants:i,onExecute:a,onReview:r,onBack:o,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(D=>typeof D=="string"):e.assetIds,cellIds:Array.isArray(s?.cell_ids)?s.cell_ids.filter(D=>typeof D=="string"):e.cellIds}),...Object.fromEntries(Object.entries(s??{}).filter(([D])=>D in(l.inputSchema.properties??{})&&(D!=="_provider"||!l.generation)))})),f=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}}:f?{...d,options:{...d.options&&typeof d.options=="object"?d.options:{},aspect_ratio:f}}:d,[p,g]=C.useState(!1),[h,j]=C.useState(null),[x,y]=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(([I])=>!S.has(I)),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),A=["commit_hash","filename","subject_id","subject_ids"].some(I=>I in(l.inputSchema.properties??{})),T=l.handler.kind==="tool"&&l.handler.tool==="crop_asset"&&typeof b.asset_id=="string"?e.media?.[b.asset_id]:void 0,R=l.target.argument&&l.target.mediaKinds?{...e.choices,[l.target.argument]:(e.choices[l.target.argument]??e.choices.asset_id??[]).filter(I=>l.target.mediaKinds?.some(D=>D===I.detail))}:e.choices,E=l.generation&&R.model?{...R,model:Xr(R.model,l.generation.mediaType,b)}:R,F=async()=>{if(!(p||P)){g(!0),j(null);try{l.confirmation!=="none"&&!x?y(await r(l,b)):(k(await a(l,b)),y(null))}catch(I){j(I instanceof Error?I.message:String(I))}finally{g(!1)}}};return t.jsxs("form",{className:"workspace-action-form","data-action-id":l.id,onSubmit:I=>{I.preventDefault(),F()},children:[t.jsxs("button",{type:"button",className:"workspace-actions-back",disabled:p,onClick:o,children:[t.jsx(ic,{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:p,onChange:I=>c(I.target.value,b),children:i.map(I=>t.jsxs("option",{value:I.id,children:[I.generation?.provider," · ",I.title]},I.id))})]})]}),t.jsxs("div",{className:"workspace-action-fields",children:[T&&t.jsx(Bu,{media:T,values:b,disabled:p,onChange:I=>{u(D=>({...D,...I})),y(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:p,onChange:I=>{u(D=>({...D,entity:structuredClone(e.entities?.[I.target.value])})),k(null),y(null)},children:[t.jsx("option",{value:"",children:"Choose a saved item"}),(e.choices.entity_id??[]).map(I=>t.jsx("option",{value:I.value,children:I.label},I.value))]})]}),M.map(([I,D])=>t.jsx(_n,{name:I,schema:N&&I==="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}}}:D,value:b[I],choices:E,required:w.has(I),disabled:p||I==="aspect_ratio"&&!!f,onChange:L=>{u(_=>({..._,[I]:L,...T&&I==="ratio"&&typeof L=="string"?mi(L,T.width,T.height):{},...I===l.target.argument&&typeof L=="string"&&l.inputSchema.properties?.object_hash?{object_hash:e.media?.[L]?.objectHash??""}:{}})),y(null),k(null)}},N&&I==="entity"?`${I}:${$}`:I))]}),m&&t.jsx("p",{role:"status",children:Gr}),f&&t.jsx("p",{role:"status",children:Yr}),A&&t.jsx("button",{type:"button",disabled:p,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(Ou,{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:p||!!P,children:[p?t.jsx(ut,{size:15}):t.jsx(As,{size:15}),p?"Working…":x?"Confirm and run":l.confirmation!=="none"?"Review action":"Run action"]}),x&&t.jsx("button",{type:"button",onClick:()=>y(null),disabled:p,children:"Cancel review"})]})]})}function yf({actions:l,context:e,initialActionId:s,initialValues:n,initialResult:i,returnFocus:a,loading:r=!1,error:o,onClose:c,onBack:d,onOpenAction:u,onExecute:f,onReview:m}){const b=C.useRef(null),p=l.find(x=>x.id===s),g=p?.id,h=C.useMemo(()=>p?.generation?l.filter(x=>x.generation?.operation===p.generation?.operation&&x.generation?.mediaType===p.generation?.mediaType):[],[l,p]);C.useLayoutEffect(()=>{const x=b.current;if(x)return x.showModal(),()=>x.close()},[]),C.useLayoutEffect(()=>{r||b.current?.querySelector(".workspace-action-fields input, .workspace-action-fields textarea, .workspace-action-fields select")?.focus()},[g,r]);const j=()=>{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(),j())},onCancel:x=>{x.preventDefault(),j()},children:[t.jsxs("header",{children:[t.jsx("h2",{children:"Actions"}),t.jsx("button",{type:"button","aria-label":"Close actions",onClick:j,children:t.jsx(mt,{size:18})})]}),r&&t.jsx("p",{role:"status",children:"Loading action…"}),o&&t.jsx("p",{role:"alert",className:"workspace-action-error",children:o}),p&&!r&&t.jsx(Hu,{action:p,context:e,initialValues:n,initialResult:i,variants:h,onExecute:f,onReview:m,onBack:d,onOpenAction:u},p.id),!p&&!r&&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 Ku(l){const e=X.c(40),{sequence:s,clip:n,src:i,defaultFit:a}=l,r=hc(),o=n.transform;let c,d;e[0]!==n||e[1]!==r||e[2]!==s.transitions?(d=Xi(n,s.transitions),c=d.incoming?Ml(r,[0,d.incoming.durationFrames],[0,1],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}):1,e[0]=n,e[1]=r,e[2]=s.transitions,e[3]=c,e[4]=d):(c=e[3],d=e[4]);const u=c;let f;e[5]!==n.durationFrames||e[6]!==r||e[7]!==d.outgoing?(f=d.outgoing?Ml(r,[Math.max(0,n.durationFrames-d.outgoing.durationFrames),n.durationFrames],[1,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}):1,e[5]=n.durationFrames,e[6]=r,e[7]=d.outgoing,e[8]=f):f=e[8];const m=f,b=(o?.fit??a)==="fit"?"contain":"cover",p=(o?.opacity??1)*u*m,g=`translate(${o?.positionX??0}px, ${o?.positionY??0}px)`,h=`scale(${o?.scaleX??1}, ${o?.scaleY??1})`,j=`rotate(${o?.rotationDegrees??0}deg)`;let x;e[9]!==g||e[10]!==h||e[11]!==j?(x=[g,h,j],e[9]=g,e[10]=h,e[11]=j,e[12]=x):x=e[12];const y=x.join(" "),v=`${(o?.anchorX??.5)*100}% ${(o?.anchorY??.5)*100}%`,k=o?`inset(${o.cropTop*100}% ${o.cropRight*100}% ${o.cropBottom*100}% ${o.cropLeft*100}%)`:void 0;let w;e[13]!==v||e[14]!==k||e[15]!==b||e[16]!==p||e[17]!==y?(w={width:"100%",height:"100%",objectFit:b,objectPosition:"center",opacity:p,transform:y,transformOrigin:v,clipPath:k},e[13]=v,e[14]=k,e[15]=b,e[16]=p,e[17]=y,e[18]=w):w=e[18];const S=w;if(n.source.kind==="still"){let R;return e[19]!==i||e[20]!==S?(R=t.jsx(bc,{src:i,style:S}),e[19]=i,e[20]=S,e[21]=R):R=e[21],R}const M=n;if(M.reverse){let R;e[22]!==S?(R={...S,display:"grid",placeItems:"center",background:"#07120c"},e[22]=S,e[23]=R):R=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("span",{style:{color:"#8fbaa0",fontFamily:"monospace",fontSize:24},children:"Reverse preview is available after render"}),e[24]=E):E=e[24];let F;return e[25]!==R?(F=t.jsx(Wn,{style:R,children:E}),e[25]=R,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,A=M.audioPolicy==="mute";let T;return e[33]!==i||e[34]!==S||e[35]!==N||e[36]!==$||e[37]!==P||e[38]!==A?(T=t.jsx(xc,{src:i,startFrom:N,endAt:$,playbackRate:P,muted:A,style:S}),e[33]=i,e[34]=S,e[35]=N,e[36]=$,e[37]=P,e[38]=A,e[39]=T):T=e[39],T}function Vu(l){const e=X.c(24),{sequence:s,clip:n,src:i}=l,a=n.audio;let r;e[0]!==n||e[1]!==s.transitions?(r=Xi(n,s.transitions),e[0]=n,e[1]=s.transitions,e[2]=r):r=e[2];const o=r;let c;e[3]!==a?.fadeInFrames||e[4]!==a?.fadeOutFrames||e[5]!==a?.gainDb||e[6]!==a?.muted||e[7]!==n.durationFrames||e[8]!==o.incoming?.durationFrames||e[9]!==o.outgoing?.durationFrames?(c=g=>{if(a?.muted)return 0;const h=10**((a?.gainDb??0)/20),j=Math.max(1,a?.fadeInFrames??0,o.incoming?.durationFrames??0),x=Math.max(1,a?.fadeOutFrames??0,o.outgoing?.durationFrames??0);return j>0&&g<j?h*g/j: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]=o.incoming?.durationFrames,e[9]=o.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 f;e[14]!==n||e[15]!==s?(f=Wi(s,n),e[14]=n,e[15]=s,e[16]=f):f=e[16];const m=n.speed.numerator/n.speed.denominator,b=n.audioPolicy==="mute"||a?.muted;let p;return e[17]!==i||e[18]!==u||e[19]!==f||e[20]!==m||e[21]!==b||e[22]!==d?(p=t.jsx(gc,{src:i,startFrom:u,endAt:f,playbackRate:m,volume:d,muted:b}),e[17]=i,e[18]=u,e[19]=f,e[20]=m,e[21]=b,e[22]=d,e[23]=p):p=e[23],p}function qu(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 r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r={justifyContent:"flex-end",alignItems:"center",padding:"0 6% 7%"},e[2]=r):r=e[2];let o;e[3]!==a?(o={...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]=o):o=e[4];let c;return e[5]!==o||e[6]!==s?(c=t.jsx(Wn,{style:r,children:t.jsx("span",{style:o,children:s})}),e[5]=o,e[6]=s,e[7]=c):c=e[7],c}function Wu(l){const e=X.c(21),{sequence:s,assets:n,defaultFit:i}=l,a=i===void 0?"fit":i;let r,o,c,d;if(e[0]!==n||e[1]!==a||e[2]!==s){const m=new Map(n.map(Ju)),b=new Map(s.tracks.map(Yu));let p;e[7]!==s.tracks?(p=s.tracks.some(Gu),e[7]=s.tracks,e[8]=p):p=e[8];const g=p,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)}),j=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]});r=Wn;let x;e[9]!==s.backgroundRgba?(x=s.backgroundRgba.join(","),e[9]=s.backgroundRgba,e[10]=x):x=e[10];const y=`rgba(${x})`;e[11]!==y?(o={backgroundColor:y},e[11]=y,e[12]=o):o=e[12],c=h.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(An,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(Ku,{sequence:s,clip:v,src:k.mediaUrl,defaultFit:a})},v.clipId)}),d=j.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(An,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(Vu,{sequence:s,clip:v,src:k.mediaUrl})},`audio:${v.clipId}`)}),e[0]=n,e[1]=a,e[2]=s,e[3]=r,e[4]=o,e[5]=c,e[6]=d}else r=e[3],o=e[4],c=e[5],d=e[6];let u;e[13]!==s.captions?(u=s.captions.map(Xu),e[13]=s.captions,e[14]=u):u=e[14];let f;return e[15]!==r||e[16]!==o||e[17]!==c||e[18]!==d||e[19]!==u?(f=t.jsxs(r,{style:o,children:[c,d,u]}),e[15]=r,e[16]=o,e[17]=c,e[18]=d,e[19]=u,e[20]=f):f=e[20],f}function Xu(l){return t.jsx(An,{from:l.timelineStartFrame,durationInFrames:l.durationFrames,children:t.jsx(qu,{text:l.text,styleId:l.styleId})},l.cueId)}function Gu(l){return l.kind==="audio"&&l.solo}function Yu(l){return[l.trackId,l]}function Ju(l){return[l.artifactId,l]}const Qu={width:"100%",maxHeight:520},Zu={width:"100%",height:"100%"},em=({playing:l,isBuffering:e})=>e?t.jsx(vi,{size:16,className:"timeline-preview-buffering"}):l?t.jsx(Ai,{size:16}):t.jsx(As,{size:16});function tm(l){return Math.max(1,...l.clips.map(e=>e.timelineStartFrame+e.durationFrames),...l.captions.map(e=>e.timelineStartFrame+e.durationFrames))}function sm(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 nm=C.forwardRef(function(e,s){const n=X.c(51),{sequence:i,assets:a,onFrameUpdate:r,onKeyboardAction:o,editingEnabled:c,presentation:d,allowFullscreen:u,initialFrame:f}=e,m=c===void 0?!0:c,b=d===void 0?"default":d,p=u===void 0?!0:u,g=f===void 0?0:f,h=C.useRef(null),j=C.useRef(null),x=i.frameRate.numerator/i.frameRate.denominator,y=tm(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(y-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 A;n[5]!==y||n[6]!==m||n[7]!==x||n[8]!==o?(A=Y=>{if(Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229)return;const ee=Y.target;if(["INPUT","TEXTAREA","SELECT"].includes(ee.tagName))return;const J=h.current;if(!J)return;const re=w.current,Q=Y.key.toLowerCase();if(Q===" "||Q==="k"){Y.preventDefault(),J.isPlaying()?J.pause():J.play();return}if(Q==="j"||Y.key==="ArrowLeft"){Y.preventDefault(),J.seekTo(Math.max(0,re-(Q==="j"?Math.round(x):1)));return}if(Q==="l"||Y.key==="ArrowRight"){Y.preventDefault(),J.seekTo(Math.min(y-1,re+(Q==="l"?Math.round(x):1)));return}if(!m)return;const Z=sm(Y);Z&&(Y.preventDefault(),o(Z,re))},n[5]=y,n[6]=m,n[7]=x,n[8]=o,n[9]=A):A=n[9];const T=A;let R,E;n[10]!==y||n[11]!==T||n[12]!==r?(R=()=>({pause:()=>h.current?.pause(),togglePlay:()=>{const Y=h.current;Y&&(Y.isPlaying()?Y.pause():Y.play())},seekTo:Y=>{const ee=Math.max(0,Math.min(y-1,Math.round(Y)));w.current=ee,M(ee),r(ee),h.current?.seekTo(ee)},focus:()=>j.current?.focus(),handleKeyDown:T}),E=[y,T,r],n[10]=y,n[11]=T,n[12]=r,n[13]=R,n[14]=E):(R=n[13],E=n[14]),C.useImperativeHandle(s,R,E);let F,I;n[15]!==r?(F=()=>{const Y=h.current;if(!Y)return;const ee=J=>{w.current=J.detail.frame,M(J.detail.frame),r(J.detail.frame)};return Y.addEventListener("frameupdate",ee),()=>Y.removeEventListener("frameupdate",ee)},I=[r],n[15]=r,n[16]=F,n[17]=I):(F=n[16],I=n[17]),C.useEffect(F,I);const D=N?!1:void 0,L=N?"timeline-preview-screen":void 0,_=N?Zu:Qu,z=N?em:void 0;let O;n[18]!==p||n[19]!==y||n[20]!==k||n[21]!==x||n[22]!==P||n[23]!==N||n[24]!==i.height||n[25]!==i.width||n[26]!==D||n[27]!==L||n[28]!==_||n[29]!==z?(O=t.jsx(yc,{ref:h,component:Wu,inputProps:P,durationInFrames:y,fps:x,compositionWidth:i.width,compositionHeight:i.height,initialFrame:k,controls:!0,spaceKeyToPlayOrPause:D,allowFullscreen:p,alwaysShowControls:N,className:L,style:_,renderPlayPauseButton:z}),n[18]=p,n[19]=y,n[20]=k,n[21]=x,n[22]=P,n[23]=N,n[24]=i.height,n[25]=i.width,n[26]=D,n[27]=L,n[28]=_,n[29]=z,n[30]=O):O=n[30];const U=O,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 ae;n[36]!==se?(ae=se.toFixed(2),n[36]=se,n[37]=ae):ae=n[37];let V;n[38]!==ae?(V=t.jsxs("span",{children:[ae,"s"]}),n[38]=ae,n[39]=V):V=n[39];const oe=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]!==oe?(W=t.jsx("span",{className:"canonical-player-shortcuts",children:oe}),n[40]=oe,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 le;return n[46]!==T||n[47]!==q||n[48]!==H||n[49]!==te?(le=t.jsxs("section",{className:q,ref:j,tabIndex:0,onKeyDown:T,"aria-label":"Canonical sequence player",children:[H,te]}),n[46]=T,n[47]=q,n[48]=H,n[49]=te,n[50]=le):le=n[50],le});function jf(l){const e=X.c(64),{media:s,sequence:n,assets:i,opener:a,initialFrame:r,onActions:o,onClose:c,composerPortalRef:d,actionsOpen:u}=l,f=r===void 0?0:r,m=u===void 0?!1:u,b=C.useRef(null),p=C.useRef(null),[g,h]=C.useState(s?.initialFile??"");let j,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,j=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]=j,e[5]=x}else j=e[4],x=e[5];const y=j;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]!==f?(w=()=>{const K=b.current;return K?.showModal(),p.current?.seekTo(f),()=>K?.close()},S=[f],e[9]=f,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 A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(mt,{size:18}),e[16]=A):A=e[16];let T;e[17]!==k?(T=t.jsx("button",{type:"button","aria-label":"Close preview",onClick:k,children:A}),e[17]=k,e[18]=T):T=e[18];let R;e[19]!==P||e[20]!==T?(R=t.jsxs("header",{children:[P,T]}),e[19]=P,e[20]=T,e[21]=R):R=e[21];let E;e[22]!==g||e[23]!==s?(E=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(am)]})]}),e[22]=g,e[23]=s,e[24]=E):E=e[24];let F;e[25]!==i||e[26]!==n?(F=n&&t.jsx(nm,{ref:p,sequence:n,assets:i,editingEnabled:!1,onFrameUpdate:im,onKeyboardAction:lm}),e[25]=i,e[26]=n,e[27]=F):F=e[27];let I;e[28]!==s||e[29]!==x?(I=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]=I):I=e[30];let D;e[31]!==s?.label||e[32]!==y||e[33]!==x?(D=x&&y==="image"&&t.jsx("img",{src:x,alt:s?.label??"Media preview"}),e[31]=s?.label,e[32]=y,e[33]=x,e[34]=D):D=e[34];let L;e[35]!==s?.thumbnailUrl||e[36]!==y||e[37]!==x?(L=x&&(y==="video"||y==="final")&&t.jsx("video",{src:x,poster:s?.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"metadata"}),e[35]=s?.thumbnailUrl,e[36]=y,e[37]=x,e[38]=L):L=e[38];let _;e[39]!==y||e[40]!==x?(_=x&&y==="audio"&&t.jsx("audio",{src:x,controls:!0,preload:"metadata"}),e[39]=y,e[40]=x,e[41]=_):_=e[41];let z;e[42]!==x?(z=x&&t.jsx("a",{href:x,target:"_blank",rel:"noreferrer",children:"Open current file"}),e[42]=x,e[43]=z):z=e[43];let O;e[44]!==o?(O=t.jsx("button",{type:"button",onClick:o,children:"More actions"}),e[44]=o,e[45]=O):O=e[45];let U;e[46]!==E||e[47]!==F||e[48]!==I||e[49]!==D||e[50]!==L||e[51]!==_||e[52]!==z||e[53]!==O?(U=t.jsxs("div",{className:"workspace-preview-content",children:[E,F,I,D,L,_,z,O]}),e[46]=E,e[47]=F,e[48]=I,e[49]=D,e[50]=L,e[51]=_,e[52]=z,e[53]=O,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]!==R||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:[R,U,q]}),document.body),e[58]=R,e[59]=U,e[60]=q,e[61]=M,e[62]=N,e[63]=H):H=e[63],H}function lm(){}function im(){}function am(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}},rm={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 Ys(l){const e=Ln(l);return{width:He.squareSize,height:He.squareSize,transform:`translate(${e.x}px, ${e.y}px)`}}const om={image:Ys(Jt.image),video:Ys(Jt.video),download:Ys(Jt.download),library:Ys(Jt.library)},Vl=Ln(Jt.library),cm={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,r=Jt[s];let o;e[0]!==r?(o=Wt(r),e[0]=r,e[1]=o):o=e[1];const c=o,d=`notebook-start-tile notebook-start-tile-${s}`,u=om[s],f=`${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 p;e[6]!==m||e[7]!==b?(p=t.jsxs("div",{className:"notebook-start-tile-head",children:[m,b]}),e[6]=m,e[7]=b,e[8]=p):p=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]!==f||e[16]!==p||e[17]!==g?(h=t.jsxs("section",{className:d,style:u,"aria-label":f,"data-start-address":c,children:[p,g,a]}),e[11]=c,e[12]=a,e[13]=d,e[14]=u,e[15]=f,e[16]=p,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,r=C.useRef(null),o=rm[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 f;e[3]!==o.hint?(f=t.jsx("span",{className:"notebook-start-tile-hint notebook-start-tile-hint-optional",children:o.hint}),e[3]=o.hint,e[4]=f):f=e[4];const m=`Upload ${s}`;let b,p;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=()=>r.current?.click(),p=t.jsx(es,{"aria-hidden":"true"}),e[5]=b,e[6]=p):(b=e[5],p=e[6]);let g;e[7]!==o.label?(g=t.jsx("span",{children:o.label}),e[7]=o.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:[p,g]}),e[9]=n,e[10]=m,e[11]=g,e[12]=h):h=e[12];const j=`${o.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 y;e[17]!==n||e[18]!==j||e[19]!==x?(y=t.jsx("button",{type:"button",className:"notebook-start-tile-secondary","aria-label":j,disabled:n,onClick:x,children:"From library"}),e[17]=n,e[18]=j,e[19]=x,e[20]=y):y=e[20];let v;e[21]!==y||e[22]!==h?(v=t.jsxs("div",{className:"notebook-start-tile-actions",children:[h,y]}),e[21]=y,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:r,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]!==o.icon||e[29]!==o.title||e[30]!==s||e[31]!==v||e[32]!==w||e[33]!==f?(S=t.jsxs(Qn,{kind:s,title:o.title,icon:o.icon,children:[f,v,w]}),e[28]=o.icon,e[29]=o.title,e[30]=s,e[31]=v,e[32]=w,e[33]=f,e[34]=S):S=e[34],S}function dm({busy:l,onDownload:e}){const[s,n]=C.useState(""),[i,a]=C.useState(!1),r=s.trim(),o=l||i,c=async d=>{if(d.preventDefault(),!(o||!r)){a(!0);try{await e(r,Jt.download),n("")}finally{a(!1)}}};return t.jsx(Qn,{kind:"download",title:"Download a clip",icon:Di,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:o,onChange:d=>n(d.target.value)}),t.jsxs("button",{type:"submit",className:"notebook-start-tile-primary",disabled:o||!r,children:[t.jsx(Ps,{"aria-hidden":"true"}),t.jsx("span",{children:i?"Queuing…":"Download"})]})]})})}function um(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 r;return e[3]!==s||e[4]!==a?(r=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]=r):r=e[5],r}function vf(l){const e=X.c(18),{busy:s,compact:n,dimmed:i,onUpload:a,onPick:r,onDownload:o,onBrowseLibrary:c}=l;let d,u;e[0]!==s||e[1]!==r||e[2]!==a?(d=t.jsx(ql,{kind:"image",busy:s,onUpload:a,onPick:r}),u=t.jsx(ql,{kind:"video",busy:s,onUpload:a,onPick:r}),e[0]=s,e[1]=r,e[2]=a,e[3]=d,e[4]=u):(d=e[3],u=e[4]);let f;e[5]!==s||e[6]!==o?(f=t.jsx(dm,{busy:s,onDownload:o}),e[5]=s,e[6]=o,e[7]=f):f=e[7];let m;e[8]!==s||e[9]!==c?(m=t.jsx(um,{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]!==f||e[16]!==m?(b=t.jsx(_i,{children:t.jsxs("div",{className:"notebook-start-tiles nodrag nopan",style:cm,role:"group","aria-label":"Start this notebook","data-compact":n,"data-dimmed":i,children:[d,u,f,m]})}),e[11]=n,e[12]=i,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=b):b=e[17],b}const mm={post:St,audio:ss,image:Zt,video:Rs,character:Ei,prompt:Ti,analyze:zn,generate_video:Rs,generate_image:Zt,generate_audio:ss,extract_audio:ss,split_video:St,concat:St,splice:St,timeline:St};function fm(l){const e=X.c(27),{disabled:s,onAdd:n,onDragEnd:i}=l,[a,r]=C.useState(""),o=C.useRef(null),c=C.useRef(null),d=C.useRef(null),u=Qr(a);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=_=>{o.current&&(o.current.open=!1),r(""),_&&d.current?.focus()},e[0]=f):f=e[0];const m=f;let b,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const _=z=>{const O=o.current;!O?.open||!(z.target instanceof Node)||O.contains(z.target)||m(!1)};return document.addEventListener("pointerdown",_,!0),document.addEventListener("focusin",_),()=>{document.removeEventListener("pointerdown",_,!0),document.removeEventListener("focusin",_)}},p=[m],e[1]=b,e[2]=p):(b=e[1],p=e[2]),C.useEffect(b,p);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=_=>{if(!_.currentTarget.open){r("");return}const z=document.activeElement;z!==d.current&&_.currentTarget.contains(z)||c.current?.focus()},e[3]=g):g=e[3];const h=g;let j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=_=>{_.key!=="Escape"||!o.current?.open||(_.preventDefault(),_.stopPropagation(),m(!0))},e[4]=j):j=e[4];const x=j;let y;e[5]!==n?(y=_=>{m(!0),n(_)},e[5]=n,e[6]=y):y=e[6];const v=y;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=_=>r(_.target.value),e[11]=P):P=e[11];let A;e[12]!==a?(A=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]=A):A=e[13];const T="canvas-add-results",R="polite",E=Zr.map(_=>{const z=u.filter(O=>O.group===_);return z.length===0?null:t.jsxs("section",{className:"canvas-add-group",children:[t.jsx("span",{children:_}),z.map(O=>{const U=mm[O.type];return t.jsxs("button",{type:"button",draggable:!0,disabled:s,onDragStart:q=>q.dataTransfer.setData("application/x-videobook-cell",O.type),onDragEnd:w,onClick:()=>v(O.type),children:[t.jsx(U,{size:15}),t.jsx("span",{children:O.label})]},O.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 I;e[16]!==E||e[17]!==F?(I=t.jsxs("div",{className:T,"aria-live":R,children:[E,F]}),e[16]=E,e[17]=F,e[18]=I):I=e[18];let D;e[19]!==A||e[20]!==I?(D=t.jsxs("div",{className:N,children:[A,I]}),e[19]=A,e[20]=I,e[21]=D):D=e[21];let L;return e[22]!==x||e[23]!==h||e[24]!==D||e[25]!==M?(L=t.jsxs("details",{ref:o,className:S,onToggle:h,onKeyDown:x,children:[M,D]}),e[22]=x,e[23]=h,e[24]=D,e[25]=M,e[26]=L):L=e[26],L}function kf(l){const e=X.c(41),{busy:s,arrangeDisabled:n,selectedCount:i,activeAddress:a,onAdd:r,onAddDragEnd:o,onArrange:c,onDeleteSelection:d,onClearSelection:u,onSelectionActions:f}=l,m=`Delete ${i} selected ${i===1?"cell":"cells"}`;let b;e[0]!==s||e[1]!==r||e[2]!==o?(b=t.jsx(fm,{disabled:s,onAdd:r,onDragEnd:o}),e[0]=s,e[1]=r,e[2]=o,e[3]=b):b=e[3];let p;e[4]!==r?(p=()=>{r("image")},e[4]=r,e[5]=p):p=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 j;e[8]!==s||e[9]!==p?(j=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:p,children:[g,h]}),e[8]=s,e[9]=p,e[10]=j):j=e[10];let x;e[11]!==r?(x=()=>{r("video")},e[11]=r,e[12]=x):x=e[12];let y,v;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(es,{size:15}),v=t.jsx("span",{children:"Video"}),e[13]=y,e[14]=v):(y=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:[y,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(ac,{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]!==j||e[28]!==k?($=t.jsxs("div",{className:"canvas-primary-actions",role:"group","aria-label":"Notebook editing tools",children:[b,j,k,N]}),e[25]=b,e[26]=N,e[27]=j,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]!==f||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"]}),f&&t.jsx("button",{type:"button",className:"canvas-clear-selection",title:"Selection actions","aria-label":"Selection actions","data-workspace-action-surface":"selection-menu",onClick:f,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]=f,e[36]=i,e[37]=P):P=e[37];let A;return e[38]!==$||e[39]!==P?(A=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]=A):A=e[40],A}function pm(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 hm(){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 r,o;l[1]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)),o=[],l[1]=r,l[2]=o):(r=l[1],o=l[2]),C.useEffect(r,o);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 Sf(l){const e=X.c(51),{bookName:s,enabled:n,snapshot:i,stale:a,onRetry:r}=l,{id:o,buttonRef:c,panelRef:d,position:u}=hm(),f=i?.totals;let m;e[0]!==f?(m=f?as(f.inputTokens+f.outputTokens):"—",e[0]=f,e[1]=m):m=e[1];const b=m;let p;e[2]!==f?(p=f?Mn(f):"— cost",e[2]=f,e[3]=p):p=e[3];const g=p,h=!!f&&(f.unpriced>0||f.missingTokens>0||i?.incomplete);let j;e[4]!==i?.groups?(j=new Set(i?.groups.map(vm)??[]),e[4]=i?.groups,e[5]=j):j=e[5];let x;e[6]!==j?(x=[...j],e[6]=j,e[7]=x):x=e[7];const y=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]!==o||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:o,disabled:v,"aria-label":k,title:"Tokens and cost for this book",children:[S,M,N,$]}),e[17]=c,e[18]=o,e[19]=N,e[20]=$,e[21]=v,e[22]=k,e[23]=S,e[24]=P):P=e[24];let A;e[25]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("h2",{children:"Book usage"}),e[25]=A):A=e[25];let T;e[26]!==s?(T=t.jsxs("div",{children:[A,t.jsx("p",{children:s})]}),e[26]=s,e[27]=T):T=e[27];let R;e[28]!==o?(R=t.jsx("button",{type:"button",popoverTarget:o,popoverTargetAction:"hide","aria-label":"Close book usage",children:"×"}),e[28]=o,e[29]=R):R=e[29];let E;e[30]!==T||e[31]!==R?(E=t.jsxs("header",{children:[T,R]}),e[30]=T,e[31]=R,e[32]=E):E=e[32];let F;e[33]!==r||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:r,children:"Retry"})]}),e[33]=r,e[34]=a,e[35]=F):F=e[35];let I;e[36]!==y||e[37]!==h||e[38]!==i||e[39]!==a?(I=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:y.map(_=>{const z=i.groups.filter(H=>H.activity===_),O=z.reduce(jm,0),U=z.reduce(ym,0),q=z.some(gm);return t.jsxs("details",{children:[t.jsxs("summary",{children:[t.jsx("span",{children:bi[_]}),t.jsx("span",{children:O===0&&U?"Unpriced":`${q?"~":""}${Ss(O)}`})]}),z.map(xm)]},_)})}),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(bm)]}):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]=y,e[37]=h,e[38]=i,e[39]=a,e[40]=I):I=e[40];let D;e[41]!==o||e[42]!==d||e[43]!==u||e[44]!==E||e[45]!==F||e[46]!==I?(D=t.jsxs("div",{ref:d,id:o,popover:"auto",role:"dialog","aria-label":"Book usage",className:"book-usage-popover",onToggle:u,children:[E,F,I]}),e[41]=o,e[42]=d,e[43]=u,e[44]=E,e[45]=F,e[46]=I,e[47]=D):D=e[47];let L;return e[48]!==P||e[49]!==D?(L=t.jsxs("div",{className:"book-usage","data-composer-focus":"preserve",children:[P,D]}),e[48]=P,e[49]=D,e[50]=L):L=e[50],L}function bm(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":pm(l)})]},l.id)}function xm(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 gm(l){return l.estimatedUsd>0}function ym(l,e){return l+e.unpriced}function jm(l,e){return l+e.reportedUsd+e.estimatedUsd}function vm(l){return l.activity}function km(l){const e=X.c(18),{call:s}=l,{settings:n,busy:i,error:a,update:r}=eo(s);let o,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-diagnostics-heading",children:"Diagnostics"}),t.jsx("span",{children:"Application"})]}),c=t.jsx("p",{children:"Provider request capture is off by default. Enabling it keeps prompts, media URLs, model parameters, provider responses and error text locally. Secrets, cookies and media bytes above the capture cap are not kept. Realtime WebSocket traffic is not captured."}),e[0]=o,e[1]=c):(o=e[0],c=e[1]);const d=i||!s;let u;e[2]!==r?(u=()=>{r()},e[2]=r,e[3]=u):u=e[3];let f;e[4]!==d||e[5]!==u?(f=t.jsx("button",{type:"button",disabled:d,onClick:u,children:"Check capture settings"}),e[4]=d,e[5]=u,e[6]=f):f=e[6];let m;e[7]!==i||e[8]!==s||e[9]!==n||e[10]!==r?(m=n&&t.jsxs(t.Fragment,{children:[t.jsx("label",{htmlFor:"har-capture-mode",children:"Provider capture"}),t.jsxs("select",{id:"har-capture-mode",value:n.mode,disabled:i||n.overridden||!s,onChange:g=>{r(g.target.value)},children:[t.jsx("option",{value:"off",children:"Off"}),t.jsx("option",{value:"failures",children:"Capture failed calls"}),t.jsx("option",{value:"all",children:"Capture all calls"})]}),t.jsxs("p",{children:["Retained for up to ",n.maxAgeDays," days and ",n.maxTotalMB," MiB."]}),n.overridden&&t.jsx("p",{children:"Capture mode is controlled by the server environment."})]}),e[7]=i,e[8]=s,e[9]=n,e[10]=r,e[11]=m):m=e[11];let b;e[12]!==a?(b=a&&t.jsx("p",{role:"alert",className:"settings-error",children:a}),e[12]=a,e[13]=b):b=e[13];let p;return e[14]!==f||e[15]!==m||e[16]!==b?(p=t.jsxs("section",{className:"settings-panel","aria-labelledby":"settings-diagnostics-heading",children:[o,c,f,m,b]}),e[14]=f,e[15]=m,e[16]=b,e[17]=p):p=e[17],p}function Sm({call:l}){const[e,s]=C.useState(null),[n,i]=C.useState(!1),[a,r]=C.useState(null),o=async c=>{if(!l)return;const d=c?window.open("about:blank","_blank"):null;i(!0),r(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(),r(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:()=>{o(!0)},children:e?.connected?"Reconnect Dropbox":"Connect Dropbox"}),t.jsx("button",{type:"button",disabled:n||!l,onClick:()=>{o(!1)},children:"Check connection"}),(a||e?.error)&&t.jsx("p",{role:"alert",className:"settings-error",children:a??e?.error})]})}function wm(l){const e=X.c(27),{busy:s,connection:n,onConnect:i}=l;let a;e[0]!==n.connecting||e[1]!==n.status?(a=to(n.status,{connecting:n.connecting}),e[0]=n.connecting,e[1]=n.status,e[2]=a):a=e[2];const r=a,o=s||n.connecting||r.actionLabel===null,c=`provider-card x-connection-card x-connection-${r.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 f;e[5]!==r.detail||e[6]!==r.label?(f=t.jsxs("p",{children:[r.label," · ",r.detail]}),e[5]=r.detail,e[6]=r.label,e[7]=f):f=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 p;e[14]!==f||e[15]!==m||e[16]!==b?(p=t.jsxs("div",{children:[u,f,m,b]}),e[14]=f,e[15]=m,e[16]=b,e[17]=p):p=e[17];let g;e[18]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(rc,{size:13,"aria-hidden":"true"}),e[18]=g):g=e[18];const h=n.connecting?"Waiting…":r.actionLabel??"Connect X";let j;e[19]!==o||e[20]!==i||e[21]!==h?(j=t.jsxs("button",{type:"button",disabled:o,onClick:i,children:[g,h]}),e[19]=o,e[20]=i,e[21]=h,e[22]=j):j=e[22];let x;return e[23]!==j||e[24]!==c||e[25]!==p?(x=t.jsxs("article",{className:c,"aria-label":"X account",children:[d,p,j]}),e[23]=j,e[24]=c,e[25]=p,e[26]=x):x=e[26],x}function Js(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 o;e[4]!==i||e[5]!==n?(o=c=>{const d=no(c),u=n.draft?.key===c.envKey&&c.editable,f=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"})]})]}),f&&t.jsx("p",{className:f.error?"settings-error":"settings-feedback",role:f.error?"alert":"status",children:f.text})]},c.envKey)},e[4]=i,e[5]=n,e[6]=o):o=e[6],a=s.map(o),e[0]=i,e[1]=n,e[2]=s,e[3]=a}else a=e[3];let r;return e[7]!==a?(r=t.jsx("div",{className:"settings-credentials",children:a}),e[7]=a,e[8]=r):r=e[8],r}function Nn(l){return`${l.filter(s=>s.keyStatus==="configured").length} of ${l.length} configured`}function wf(l){const e=X.c(133),{call:s,providers:n,loading:i,error:a,refreshed:r,storage:o,bookId:c,bookName:d,connection:u,busy:f,onRefresh:m,onSave:b,onConnect:p}=l,g=so(b);let h,j,x,y,v,k,w,S,M,N,$,P,A,T,R,E,F,I,D;if(e[0]!==c||e[1]!==d||e[2]!==f||e[3]!==s||e[4]!==u||e[5]!==g||e[6]!==a||e[7]!==i||e[8]!==p||e[9]!==m||e[10]!==n||e[11]!==r||e[12]!==o){const ae=n.filter(Im);let V;e[32]!==n?(V=n.filter($m),e[32]=n,e[33]=V):V=e[33];const oe=V,W=n.filter(Cm);h=n.filter(Nm);const te=o?.bookId===c?o:null,le=te?.status==="ready"?te.value:null;S="workspace-screen settings-screen",M="Settings";let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsxs("div",{children:[t.jsx("h1",{children:"Settings"}),t.jsx("p",{children:"Providers, connected accounts and project storage."})]}),e[34]=Y):Y=e[34];const ee=i?"Refreshing…":r?"Up to date":"";let J;e[35]!==ee?(J=t.jsx("span",{role:"status",children:ee}),e[35]=ee,e[36]=J):J=e[36];const re=f||i;let Q;e[37]!==m?(Q=()=>{m()},e[37]=m,e[38]=Q):Q=e[38];let Z;e[39]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(Ni,{size:15,"aria-hidden":"true"}),e[39]=Z):Z=e[39];let de;e[40]!==re||e[41]!==Q?(de=t.jsxs("button",{type:"button",disabled:re,onClick:Q,children:[Z,"Refresh"]}),e[40]=re,e[41]=Q,e[42]=de):de=e[42],e[43]!==J||e[44]!==de?(N=t.jsxs("header",{children:[Y,t.jsxs("div",{className:"settings-refresh",children:[J,de]})]}),e[43]=J,e[44]=de,e[45]=N):N=e[45],e[46]!==a?($=a&&t.jsx("p",{role:"alert",className:"settings-error",children:a}),e[46]=a,e[47]=$):$=e[47],k="settings-layout";let fe;e[48]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-providers-heading",children:"Providers"}),t.jsx("span",{children:"Application"})]}),e[48]=fe):fe=e[48];const me=ae.length?Nn(ae):i?"Loading providers…":"Refresh to load provider settings.";let pe;e[49]!==me?(pe=t.jsx("p",{className:"settings-section-summary",children:me}),e[49]=me,e[50]=pe):pe=e[50];let ue;e[51]!==f||e[52]!==g||e[53]!==ae?(ue=t.jsx(Js,{providers:ae,editor:g,busy:f}),e[51]=f,e[52]=g,e[53]=ae,e[54]=ue):ue=e[54],e[55]!==pe||e[56]!==ue?(w=t.jsxs("section",{className:"settings-panel settings-providers","aria-labelledby":"settings-providers-heading",children:[fe,pe,ue]}),e[55]=pe,e[56]=ue,e[57]=w):w=e[57],D="settings-secondary",e[58]!==s?(x=t.jsx(km,{call:s}),e[58]=s,e[59]=x):x=e[59];let be;e[60]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-x-heading",children:"X account"}),t.jsx("span",{children:"Application"})]}),e[60]=be):be=e[60];let ye;e[61]!==f||e[62]!==u||e[63]!==p?(ye=t.jsx(wm,{busy:f,connection:u,onConnect:p}),e[61]=f,e[62]=u,e[63]=p,e[64]=ye):ye=e[64];const ce=Nn(W);let G;e[65]!==ce?(G=t.jsxs("summary",{children:["X credentials ",t.jsx("span",{children:ce})]}),e[65]=ce,e[66]=G):G=e[66];let ie;e[67]!==f||e[68]!==g||e[69]!==W?(ie=t.jsx(Js,{providers:W,editor:g,busy:f}),e[67]=f,e[68]=g,e[69]=W,e[70]=ie):ie=e[70];let he;e[71]!==G||e[72]!==ie?(he=t.jsxs("details",{className:"settings-details",children:[G,ie]}),e[71]=G,e[72]=ie,e[73]=he):he=e[73],e[74]!==ye||e[75]!==he?(y=t.jsxs("section",{className:"settings-panel","aria-labelledby":"settings-x-heading",children:[be,ye,he]}),e[74]=ye,e[75]=he,e[76]=y):y=e[76];let ke;e[77]===Symbol.for("react.memo_cache_sentinel")?(ke=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-dropbox-heading",children:"Dropbox"}),t.jsx("span",{children:"Application"})]}),e[77]=ke):ke=e[77];let we;e[78]!==s?(we=t.jsx(Sm,{call:s}),e[78]=s,e[79]=we):we=e[79];let Ie;e[80]===Symbol.for("react.memo_cache_sentinel")?(Ie=t.jsx("summary",{children:"Dropbox credentials"}),e[80]=Ie):Ie=e[80];let Ne;e[81]!==f||e[82]!==oe||e[83]!==g?(Ne=t.jsxs("details",{className:"settings-details",children:[Ie,t.jsx(Js,{providers:oe,editor:g,busy:f})]}),e[81]=f,e[82]=oe,e[83]=g,e[84]=Ne):Ne=e[84],e[85]!==we||e[86]!==Ne?(v=t.jsxs("section",{className:"settings-panel","aria-labelledby":"settings-dropbox-heading",children:[ke,we,Ne]}),e[85]=we,e[86]=Ne,e[87]=v):v=e[87],T="settings-panel",R="settings-storage-heading",e[88]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-storage-heading",children:"Storage"}),t.jsx("span",{children:"Selected project"})]}),e[88]=E):E=e[88];const Me=d??"No project selected";e[89]!==Me?(F=t.jsx("p",{className:"settings-section-summary",children:Me}),e[89]=Me,e[90]=F):F=e[90],e[91]!==c||e[92]!==te||e[93]!==i||e[94]!==le?(I=c?te?.status==="error"?t.jsx("p",{role:"alert",className:"settings-error",children:te.error}):le?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:le.state.replaceAll("_"," ")})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Pending objects"}),t.jsx("dd",{children:le.pendingObjects})]})]}),le.lastError&&t.jsx("p",{role:"alert",className:"settings-error",children:le.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(le,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[91]=c,e[92]=te,e[93]=i,e[94]=le,e[95]=I):I=e[95],A="settings-details",P="Backblaze configuration ",j=Nn(h),e[0]=c,e[1]=d,e[2]=f,e[3]=s,e[4]=u,e[5]=g,e[6]=a,e[7]=i,e[8]=p,e[9]=m,e[10]=n,e[11]=r,e[12]=o,e[13]=h,e[14]=j,e[15]=x,e[16]=y,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]=A,e[26]=T,e[27]=R,e[28]=E,e[29]=F,e[30]=I,e[31]=D}else h=e[13],j=e[14],x=e[15],y=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],A=e[25],T=e[26],R=e[27],E=e[28],F=e[29],I=e[30],D=e[31];let L;e[96]!==j?(L=t.jsx("span",{children:j}),e[96]=j,e[97]=L):L=e[97];let _;e[98]!==L||e[99]!==P?(_=t.jsxs("summary",{children:[P,L]}),e[98]=L,e[99]=P,e[100]=_):_=e[100];let z;e[101]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("p",{children:"Application · shared by all projects."}),e[101]=z):z=e[101];let O;e[102]!==f||e[103]!==g||e[104]!==h?(O=t.jsx(Js,{providers:h,editor:g,busy:f}),e[102]=f,e[103]=g,e[104]=h,e[105]=O):O=e[105];let U;e[106]!==_||e[107]!==O||e[108]!==A?(U=t.jsxs("details",{className:A,children:[_,z,O]}),e[106]=_,e[107]=O,e[108]=A,e[109]=U):U=e[109];let q;e[110]!==U||e[111]!==T||e[112]!==R||e[113]!==E||e[114]!==F||e[115]!==I?(q=t.jsxs("section",{className:T,"aria-labelledby":R,children:[E,F,I,U]}),e[110]=U,e[111]=T,e[112]=R,e[113]=E,e[114]=F,e[115]=I,e[116]=q):q=e[116];let H;e[117]!==x||e[118]!==y||e[119]!==v||e[120]!==q||e[121]!==D?(H=t.jsxs("div",{className:D,children:[x,y,v,q]}),e[117]=x,e[118]=y,e[119]=v,e[120]=q,e[121]=D,e[122]=H):H=e[122];let K;e[123]!==k||e[124]!==w||e[125]!==H?(K=t.jsxs("div",{className:k,children:[w,H]}),e[123]=k,e[124]=w,e[125]=H,e[126]=K):K=e[126];let se;return e[127]!==S||e[128]!==M||e[129]!==N||e[130]!==$||e[131]!==K?(se=t.jsxs("section",{className:S,"aria-label":M,children:[N,$,K]}),e[127]=S,e[128]=M,e[129]=N,e[130]=$,e[131]=K,e[132]=se):se=e[132],se}function Nm(l){return l.provider==="b2"}function Cm(l){return l.provider==="x"}function $m(l){return l.provider==="dropbox"}function Im(l){return!["x","b2","dropbox"].includes(l.provider)}function Rm(l){const e=X.c(16),{applyDisabled:s,applyFormId:n,applyLabel:i,busy:a,busyLabel:r,failed:o,onCancel:c}=l,d=a||s;let u;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==o?(u=a?r:t.jsxs(t.Fragment,{children:[o?"Retry":i," ",t.jsx("kbd",{children:"↵"})]}),e[0]=i,e[1]=a,e[2]=r,e[3]=o,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==d||e[7]!==u?(f=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]=f):f=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 p;return e[13]!==f||e[14]!==b?(p=t.jsxs("div",{className:"confirm-sheet-actions",children:[f,b]}),e[13]=f,e[14]=b,e[15]=p):p=e[15],p}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 Mm(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 Pm(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(oc,{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 Am(l){const e=X.c(23),{hints:s,onDismissStatus:n,secondaryActions:i,status:a,statusId:r}=l,o=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=o?"alert":"status",f=o?"assertive":"polite";let m;e[0]!==a.state?(m=t.jsx(Pm,{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 p;e[6]!==n||e[7]!==a.dismissible?(p=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]=p):p=e[8];let g;e[9]!==r||e[10]!==d||e[11]!==u||e[12]!==f||e[13]!==m||e[14]!==b||e[15]!==p?(g=t.jsxs("div",{id:r,className:d,role:u,"aria-live":f,children:[m,b,p]}),e[9]=r,e[10]=d,e[11]=u,e[12]=f,e[13]=m,e[14]=b,e[15]=p,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 j;return e[19]!==c||e[20]!==g||e[21]!==h?(j=t.jsxs("footer",{className:c,children:[g,h]}),e[19]=c,e[20]=g,e[21]=h,e[22]=j):j=e[22],j}function Dm(l){const e=X.c(22),{actions:s,address:n,effect:i,hints:a,hintsId:r,tag:o,title:c,titleId:d}=l;let u;e[0]!==o?(u=t.jsx("span",{className:"section-label",children:o}),e[0]=o,e[1]=u):u=e[1];let f;e[2]!==c||e[3]!==d?(f=t.jsx("h2",{id:d,children:c}),e[2]=c,e[3]=d,e[4]=f):f=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 p;e[8]!==a||e[9]!==r?(p=a&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"confirm-sheet-head-divider","aria-hidden":"true"}),t.jsx("span",{id:r,className:"confirm-sheet-head-hints",children:a})]}),e[8]=a,e[9]=r,e[10]=p):p=e[10];let g;e[11]!==i?(g=i&&t.jsx(Mm,{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 j;return e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==p||e[20]!==h?(j=t.jsxs("header",{className:"confirm-sheet-head",children:[u,f,m,b,p,h]}),e[16]=u,e[17]=f,e[18]=m,e[19]=p,e[20]=h,e[21]=j):j=e[21],j}function Yi(){return typeof window>"u"||typeof window.matchMedia!="function"?null:window.matchMedia(lo)}function Tm(l){const e=Yi();return e?(e.addEventListener("change",l),()=>e.removeEventListener("change",l)):()=>{}}function Em(){return Yi()?.matches??!0}function Fm(){return C.useSyncExternalStore(Tm,Em,_m)}function _m(){return!0}function Nf(l){const e=X.c(58),{address:s,applyFormId:n,applyLabel:i,ariaLabel:a,busy:r,busyLabel:o,children:c,effect:d,hints:u,kind:f,onCancel:m,secondaryActions:b,tag:p,title:g,validation:h}=l,j=s===void 0?null:s,x=i===void 0?"Apply":i,y=o===void 0?"Applying…":o,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(Bi),[P,A]=C.useState(null);let T;e[0]!==$?.outcome?(T=()=>$?.outcome??null,e[0]=$?.outcome,e[1]=T):T=e[1];const[R]=C.useState(T);let E;e[2]!==$?.notice?(E=()=>$?.notice??null,e[2]=$?.notice,e[3]=E):E=e[3];const[F]=C.useState(E),I=$&&$.outcome!==R?$.outcome:null,D=$&&$.notice!==F?$.notice:null,L=io({busy:r,busyLabel:y,validation:h,outcome:I,notice:D}),_=Fm(),z=ao({state:L.state,hasSecondaryActions:!!w,wideEnough:_}),O=h.blocking!==null;let U;e[4]!==O||e[5]!==n||e[6]!==r||e[7]!==m?(U={applyFormId:n,applyDisabled:O,busy:r,onCancel:m},e[4]=O,e[5]=n,e[6]=r,e[7]=m,e[8]=U):U=e[8];const{sheetRef:q,onKeyDown:H}=Od(U);let K;e[9]!==$||e[10]!==D||e[11]!==I?(K=()=>{I?$?.dismissOutcome():D&&$?.dismissNotice()},e[9]=$,e[10]=D,e[11]=I,e[12]=K):K=e[12];const se=K,ae=`confirm-sheet confirm-sheet-${f}`;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 oe=L.message??y,W=L.state==="failed";let te;e[15]!==O||e[16]!==n||e[17]!==x||e[18]!==r||e[19]!==m||e[20]!==oe||e[21]!==W?(te=t.jsx(Rm,{applyDisabled:O,applyFormId:n,applyLabel:x,busy:r,busyLabel:oe,failed:W,onCancel:m}),e[15]=O,e[16]=n,e[17]=x,e[18]=r,e[19]=m,e[20]=oe,e[21]=W,e[22]=te):te=e[22];let le;e[23]!==k||e[24]!==z?(le=z?k??t.jsx(Gi,{}):null,e[23]=k,e[24]=z,e[25]=le):le=e[25];const Y=z?N:void 0;let ee;e[26]!==j||e[27]!==v||e[28]!==te||e[29]!==le||e[30]!==Y||e[31]!==p||e[32]!==g||e[33]!==M?(ee=t.jsx(Dm,{actions:te,address:j,effect:v,hints:le,hintsId:Y,tag:p,title:g,titleId:M}),e[26]=j,e[27]=v,e[28]=te,e[29]=le,e[30]=Y,e[31]=p,e[32]=g,e[33]=M,e[34]=ee):ee=e[34];let J;e[35]!==q?(J=t.jsx(zd,{sheetRef:q}),e[35]=q,e[36]=J):J=e[36];let re;e[37]!==c||e[38]!==J?(re=t.jsx("div",{className:"confirm-sheet-body",children:t.jsxs(C.Suspense,{fallback:null,children:[c,J]})}),e[37]=c,e[38]=J,e[39]=re):re=e[39];let Q;e[40]!==se||e[41]!==k||e[42]!==z||e[43]!==w||e[44]!==L||e[45]!==N?(Q=!z&&t.jsx(Am,{hints:k,onDismissStatus:se,secondaryActions:w,status:L,statusId:N}),e[40]=se,e[41]=k,e[42]=z,e[43]=w,e[44]=L,e[45]=N,e[46]=Q):Q=e[46];let Z;e[47]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(zi,{label:"Resize review and log",targetSelector:".confirm-sheet",edge:"bottom",minimum:180,reserve:36,onResize:A}),e[47]=Z):Z=e[47];let de;return e[48]!==a||e[49]!==H||e[50]!==q||e[51]!==N||e[52]!==ae||e[53]!==V||e[54]!==ee||e[55]!==re||e[56]!==Q?(de=t.jsxs("aside",{ref:q,className:ae,style:V,role:"dialog","aria-label":a,"aria-describedby":N,"aria-keyshortcuts":"Escape Meta+Enter Control+Enter",onKeyDown:H,children:[ee,re,Q,Z]}),e[48]=a,e[49]=H,e[50]=q,e[51]=N,e[52]=ae,e[53]=V,e[54]=ee,e[55]=re,e[56]=Q,e[57]=de):de=e[57],de}function Lm(l){const e=X.c(13),{post:s,source:n}=l;let i;e[0]!==s||e[1]!==n?(i=t.jsx(zm,{post:s,source:n}),e[0]=s,e[1]=n,e[2]=i):i=e[2];const a=s?.definition.caption??"";let r;e[3]!==a?(r=t.jsx(Bm,{caption:a}),e[3]=a,e[4]=r):r=e[4];let o;e[5]!==s?(o=s?t.jsx(Um,{post:s}):t.jsx("span",{className:"post-tile-hint",children:"Choose a clip to post"}),e[5]=s,e[6]=o):o=e[6];let c;e[7]!==r||e[8]!==o?(c=t.jsxs("div",{className:"post-tile-body",children:[r,o]}),e[7]=r,e[8]=o,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 zm(l){const e=X.c(22),{post:s,source:n}=l,i=n?.asset,a=i?.type==="video",r=i?.thumbnailUrl??(a?null:i?.mediaUrl??null),o=r||!a?null:i?.mediaUrl??null,c=i?.duration??null;let d,u,f,m;if(e[0]!==s||e[1]!==r||e[2]!==o){const h=s?xi(s):[];d="post-tile-media",e[7]!==r?(u=r&&t.jsx("img",{src:r,alt:"",draggable:!1}),e[7]=r,e[8]=u):u=e[8],e[9]!==o?(f=o&&t.jsx("video",{src:`${o}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),e[9]=o,e[10]=f):f=e[10],m=h.length>0&&t.jsx("span",{className:"post-tile-overlay post-tile-overlay-top",children:h.map(Om)}),e[0]=s,e[1]=r,e[2]=o,e[3]=d,e[4]=u,e[5]=f,e[6]=m}else d=e[3],u=e[4],f=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 p;e[13]!==c?(p=c!=null&&c>0&&t.jsx("span",{className:"post-tile-overlay post-tile-overlay-end",children:Kt(c)}),e[13]=c,e[14]=p):p=e[14];let g;return e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==b||e[20]!==p?(g=t.jsxs("div",{className:d,children:[u,f,m,b,p]}),e[15]=d,e[16]=u,e[17]=f,e[18]=m,e[19]=b,e[20]=p,e[21]=g):g=e[21],g}function Om(l){return t.jsxs("span",{className:"post-badge",children:[t.jsx(Qt,{size:10,strokeWidth:2.6,"aria-hidden":"true"}),l]},l)}function Bm(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 r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("span",{className:"post-tile-caption post-tile-caption-empty",children:"No caption yet"}),e[2]=r):r=e[2],r}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 Um(l){const e=X.c(14),{post:s}=l;let n;e[0]!==s?(n=ro(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(Km,{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=oo(s);if(u.length>0){a=t.jsx("span",{className:"post-tile-stats",children:u.map(Hm)});break e}}e[5]=s,e[6]=a}else a=e[6];if(a!==Symbol.for("react.early_return_sentinel"))return a;let r;e[7]!==s?(r=co(s)??"Posted",e[7]=s,e[8]=r):r=e[8];let o;e[9]!==r?(o=t.jsx("span",{children:r}),e[9]=r,e[10]=o):o=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]!==o?(d=t.jsxs("span",{className:"post-tile-stats",children:[o,c]}),e[12]=o,e[13]=d):d=e[13],d}function Hm(l){return t.jsxs("span",{children:[t.jsx("strong",{children:l.value})," ",l.label]},l.label)}function Km(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,r=`post-tile-hint${a?" post-tile-hint-action":""}`;let o;e[2]!==a?(o=a&&t.jsx(Di,{size:11,"aria-hidden":"true"}),e[2]=a,e[3]=o):o=e[3];let c;return e[4]!==r||e[5]!==o||e[6]!==n?(c=t.jsxs("span",{className:r,children:[o,n]}),e[4]=r,e[5]=o,e[6]=n,e[7]=c):c=e[7],c}const Vm=C.createContext({ready:!1,states:{},onFile:()=>{},onFileError:()=>{},onOpenLibrary:()=>{}}),qm=C.createContext(async()=>{}),Wm=C.createContext({ready:!1,deleteCell:async()=>{},repairCell:async()=>{},retryCell:async()=>{}}),Xm=C.createContext(null),Gm=C.createContext(new Map),Ym=C.createContext({openCellId:null,open:()=>{}});function Jm(l){return`cell-context-menu-${l}`}const Qm=C.createContext(null),Cf=C.createContext(new Map),$f=C.createContext(new Map),Zm=C.createContext(new Map);function e1(l){const e=X.c(26),{analysisInfo:s,fallbackShotCount:n,fallbackSourceDurationSeconds:i}=l,a=n===void 0?null:n,r=i===void 0?null:i,o=s?.shots.length??a??0,c=s?.sourceDurationSeconds??r;let d,u,f,m,b;if(e[0]!==s?.outputJson||e[1]!==s?.shots||e[2]!==c||e[3]!==o){const j=s?.shots.slice(0,3)??[];u=Math.max(0,o-j.length),d=s?.outputJson,f="cell-copy cell-copy-analysis";const x=o>0?`${o} shots`:"Analysis pending";let y;e[9]!==x?(y=t.jsx("strong",{children:x}),e[9]=x,e[10]=y):y=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]!==y||e[14]!==v?(m=t.jsxs("div",{className:"analysis-cell-summary",children:[y,v]}),e[13]=y,e[14]=v,e[15]=m):m=e[15],b=j.length>0&&t.jsx("ol",{className:"analysis-cell-shots",children:j.map(t1)}),e[0]=s?.outputJson,e[1]=s?.shots,e[2]=c,e[3]=o,e[4]=d,e[5]=u,e[6]=f,e[7]=m,e[8]=b}else d=e[4],u=e[5],f=e[6],m=e[7],b=e[8];let p;e[16]!==u?(p=u>0&&t.jsxs("span",{className:"analysis-cell-overflow",children:["+",u," more"]}),e[16]=u,e[17]=p):p=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]!==f||e[21]!==m||e[22]!==b||e[23]!==p||e[24]!==g?(h=t.jsxs("div",{className:f,children:[m,b,p,g]}),e[20]=f,e[21]=m,e[22]=b,e[23]=p,e[24]=g,e[25]=h):h=e[25],h}function t1(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 s1(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:r,alt:o,title:c,badges:d,meter:u,metadataLabel:f,pendingLabel:m,pendingIcon:b,children:p}=l,[g,h]=C.useState(!1),[j,x]=C.useState(!1),[y,v]=C.useState(0),[k,w]=C.useState(0),S=C.useRef(null),M=C.useRef(!1),N=r!==null&&a!==null,$=i!==null,P=$?i.length===0:n===null;let A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=Y=>{S.current=Y,!(!Y||!M.current)&&(M.current=!1,Y.play().catch(()=>x(!1)))},e[0]=A):A=e[0];const T=A;let R;e[1]!==j?(R=Y=>{Y.preventDefault();const ee=S.current;if(j){ee?.pause();return}if(!ee){M.current=!0,h(!0);return}ee.play().catch(()=>x(!1))},e[1]=j,e[2]=R):R=e[2];const E=R;let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=Y=>{const ee=Y.currentTarget;v(s1(ee)),w(ee.currentTime)},e[3]=F):F=e[3];const I=F;let D;e[4]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{x(!1),v(0),w(0)},e[4]=D):D=e[4];const L=D;let _;e[5]!==k||e[6]!==u||e[7]!==j?(_=u&&j?`${Kt(Math.floor(k))} / ${u.label}`:u?.label??null,e[5]=k,e[6]=u,e[7]=j,e[8]=_):_=e[8];const z=_,O=`cell-media${j?" 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]!==j?(q=()=>{j||h(!1)},e[10]=j,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]!==o||e[14]!==g||e[15]!==$||e[16]!==a||e[17]!==r||e[18]!==j||e[19]!==n||e[20]!==y||e[21]!==i?(K=$?i.length>0?t.jsx(ld,{peaks:i,progress:y}):t.jsx(Ui,{}):g&&a&&r==="video"?t.jsx("video",{ref:T,src:a,poster:n??void 0,muted:!j,playsInline:!0,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:I,onEnded:L}):n?t.jsx("img",{src:n,alt:o,loading:"lazy",decoding:"async"}):null,e[13]=o,e[14]=g,e[15]=$,e[16]=a,e[17]=r,e[18]=j,e[19]=n,e[20]=y,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:T,src:a,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:I,onEnded:L}),e[23]=g,e[24]=$,e[25]=a,e[26]=se):se=e[26];let ae;e[27]!==P||e[28]!==b||e[29]!==m||e[30]!==j?(ae=P&&!j&&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]=j,e[31]=ae):ae=e[31];let V;e[32]!==d||e[33]!==f?(V=d.length>0&&t.jsx("div",{className:"cell-media-rail",role:"group","aria-label":f,children:d.map(l1)}),e[32]=d,e[33]=f,e[34]=V):V=e[34];let oe;e[35]!==u||e[36]!==z?(oe=z&&u&&t.jsx("time",{className:"cell-media-meter",dateTime:`PT${u.seconds}S`,title:"Duration",children:z}),e[35]=u,e[36]=z,e[37]=oe):oe=e[37];let W;e[38]!==s||e[39]!==N||e[40]!==j||e[41]!==E?(W=N&&t.jsx("button",{type:"button",className:"cell-media-play nodrag","aria-label":`${j?"Pause":"Play"} ${s}`,onClick:E,onPointerDown:n1,children:j?t.jsx(Ai,{size:13,strokeWidth:2,"aria-hidden":"true"}):t.jsx(As,{size:13,fill:"currentColor",strokeWidth:0,"aria-hidden":"true"})}),e[38]=s,e[39]=N,e[40]=j,e[41]=E,e[42]=W):W=e[42];let te;e[43]!==N||e[44]!==y?(te=N&&t.jsx("span",{className:"cell-media-progress","aria-hidden":"true",children:t.jsx("span",{style:{width:`${y*100}%`}})}),e[43]=N,e[44]=y,e[45]=te):te=e[45];let le;return e[46]!==p||e[47]!==K||e[48]!==se||e[49]!==ae||e[50]!==V||e[51]!==oe||e[52]!==W||e[53]!==te||e[54]!==O||e[55]!==q||e[56]!==c?(le=t.jsxs("div",{className:O,title:c,onPointerEnter:U,onPointerLeave:q,onFocus:H,children:[K,se,ae,V,oe,W,te,p]}),e[46]=p,e[47]=K,e[48]=se,e[49]=ae,e[50]=V,e[51]=oe,e[52]=W,e[53]=te,e[54]=O,e[55]=q,e[56]=c,e[57]=le):le=e[57],le}function n1(l){return l.stopPropagation()}function l1(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 i1=[{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 a1(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:i1.map(r1)}),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 r1(l){return t.jsx("span",{className:"cell-state-streak",style:{left:l.left,animationDelay:`${l.delay}s`,animationDuration:`${l.duration}s`}},l.left)}const o1=1e3,c1=Array.from({length:gi},(l,e)=>e+1);function d1(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=r=>r.toString().padStart(2,"0");return s>0?`${s}:${a(n)}:${a(i)}`:`${n}:${a(i)}`}function u1(l,e){return l<e?"done":l===e?"active":"pending"}function m1(l){const e=X.c(14),{phase:s}=l;let n;e[0]!==s.step?(n=c1.map(d=>t.jsx("span",{className:"cell-state-phase-step","data-status":u1(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 r;e[6]!==s.step?(r=t.jsxs("span",{children:[s.step,"/",gi]}),e[6]=s.step,e[7]=r):r=e[7];let o;e[8]!==a||e[9]!==r?(o=t.jsxs("div",{className:"cell-state-phase-label",children:[a,r]}),e[8]=a,e[9]=r,e[10]=o):o=e[10];let c;return e[11]!==i||e[12]!==o?(c=t.jsxs("div",{className:"cell-state-phase",children:[i,o]}),e[11]=i,e[12]=o,e[13]=c):c=e[13],c}function f1(l){const e=X.c(32),{icon:s,label:n,address:i,startedAt:a,variant:r,meta:o,phase:c}=l,d=o===void 0?null:o,u=c===void 0?null:c,[f]=C.useState(h1),m=a??f,[b,p]=C.useState(p1);let g,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const F=setInterval(()=>p(Date.now()),o1);return()=>clearInterval(F)},h=[],e[0]=g,e[1]=h):(g=e[0],h=e[1]),C.useEffect(g,h);const j=Math.max(0,b-m);let x;e[2]!==j?(x=d1(j),e[2]=j,e[3]=x):x=e[3];const y=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]!==r?(w=t.jsx(a1,{variant:r}),e[6]=r,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]!==y?(N=t.jsx("span",{className:"cell-state-timer","aria-hidden":"true",children:y}),e[12]=y,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 A;e[20]!==d?(A=d&&t.jsx("span",{className:"cell-state-meta",title:d,children:d}),e[20]=d,e[21]=A):A=e[21];let T;e[22]!==u?(T=u&&t.jsx(m1,{phase:u}),e[22]=u,e[23]=T):T=e[23];let R;e[24]!==P||e[25]!==A||e[26]!==T?(R=t.jsxs("div",{className:"cell-state-overlay-body cell-state-clock-body",children:[P,A,T]}),e[24]=P,e[25]=A,e[26]=T,e[27]=R):R=e[27];let E;return e[28]!==R||e[29]!==k||e[30]!==w?(E=t.jsxs("div",{className:"cell-state-overlay cell-state-overlay-clock",role:"status","aria-label":k,"aria-live":"polite",children:[w,R]}),e[28]=R,e[29]=k,e[30]=w,e[31]=E):E=e[31],E}function p1(){return Date.now()}function h1(){return Date.now()}function Cn(l){l.stopPropagation()}function b1(l){const e=X.c(25),{error:s,label:n,address:i,meta:a,onRepair:r,onRetry:o,onDelete:c,disabled:d}=l,u=a===void 0?null:a,f=d===void 0?!1:d,m=x1;let b;e[0]!==n?(b=n.toLowerCase(),e[0]=n,e[1]=b):b=e[1];const p=`@${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 j;e[4]!==n?(j=t.jsx("strong",{children:n}),e[4]=n,e[5]=j):j=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 y;e[8]!==u?(y=u&&t.jsx("span",{className:"cell-state-meta",title:u,children:u}),e[8]=u,e[9]=y):y=e[9];let v;e[10]!==i||e[11]!==f||e[12]!==c||e[13]!==r||e[14]!==o?(v=(r||o||c)&&t.jsxs("div",{className:"cell-state-actions",children:[o&&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:f,onPointerDown:Cn,onClick:m(o),children:[t.jsx(On,{size:10,"aria-hidden":"true"}),"RETRY"]}),r&&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(r),children:[t.jsx(cc,{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]=f,e[12]=c,e[13]=r,e[14]=o,e[15]=v):v=e[15];let k;e[16]!==v||e[17]!==j||e[18]!==x||e[19]!==y?(k=t.jsxs("div",{className:"cell-state-overlay-body cell-state-failed-body",children:[j,x,y,v]}),e[16]=v,e[17]=j,e[18]=x,e[19]=y,e[20]=k):k=e[20];let w;return e[21]!==s||e[22]!==k||e[23]!==p?(w=t.jsxs("div",{className:"cell-state-overlay cell-state-overlay-failed",role:"alert","aria-label":p,title:s,children:[g,h,k]}),e[21]=s,e[22]=k,e[23]=p,e[24]=w):w=e[24],w}function x1(l){return e=>{e.stopPropagation(),l()}}function g1(l){const e=X.c(25),{kind:s,address:n,status:i,statusStartedAt:a,statusError:r,icon:o,generator:c,generation:d,onRepair:u,onRetry:f,onDelete:m,disabled:b}=l,p=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]!==p||e[4]!==o||e[5]!==s||e[6]!==m||e[7]!==u||e[8]!==f||e[9]!==i||e[10]!==r||e[11]!==a){h=Symbol.for("react.early_return_sentinel");e:{const j=uo(s,i,{error:r??null,startedAt:a??null});if(j.overlay==="clock"&&j.label){let x;e[13]!==g||e[14]!==i?(x=g?mo(i):null,e[13]=g,e[14]=i,e[15]=x):x=e[15],h=t.jsx(f1,{icon:o,label:j.label,address:n,startedAt:j.startedAt,variant:i==="downloading"?"stream":"rise",meta:p,phase:x});break e}if(j.overlay==="failed"&&j.error){const x=fo(j.error),y=po(s)?"MEDIA FAILED":"GENERATION FAILED",v=x?void 0:u,k=x?f:void 0;let w;e[16]!==n||e[17]!==b||e[18]!==p||e[19]!==m||e[20]!==j||e[21]!==y||e[22]!==v||e[23]!==k?(w=t.jsx(b1,{error:j.error,label:y,address:n,meta:p,onRepair:v,onRetry:k,onDelete:m,disabled:b}),e[16]=n,e[17]=b,e[18]=p,e[19]=m,e[20]=j,e[21]=y,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]=p,e[4]=o,e[5]=s,e[6]=m,e[7]=u,e[8]=f,e[9]=i,e[10]=r,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,y1=36,Gl=120,j1={width:Ji,height:He.squareSize};function v1(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 k1(l){const e=X.c(64),{assembly:s}=l,n=C.useRef(null),[i,a]=C.useState("");let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const A=document.activeElement,T=n.current;return T?.showModal(),T?.querySelector("input")?.focus(),()=>{T?.close(),xo(A instanceof HTMLElement?A:null)}},o=[],e[0]=r,e[1]=o):(r=e[0],o=e[1]),C.useEffect(r,o);const c=s.picker;if(!c)return null;let d,u,f,m,b,p,g,h,j,x,y,v,k;if(e[2]!==s||e[3]!==c.items||e[4]!==c.trackId||e[5]!==i){let A;e[19]!==i?(A=I=>I.label.toLowerCase().includes(i.toLowerCase()),e[19]=i,e[20]=A):A=e[20],d=c.items.filter(A),p=gs.createPortal,j=n,x="timeline-source-picker",y="Add a timeline clip",v="preserve",e[21]!==s?(k=I=>{I.preventDefault(),s.closePicker()},e[21]=s,e[22]=k):k=e[22],e[23]!==s.closePicker?(u=I=>{I.stopPropagation(),go(I,{busy:!1,container:I.currentTarget,onClose:s.closePicker})},e[23]=s.closePicker,e[24]=u):u=e[24],e[25]!==s?(f=I=>{I.target===I.currentTarget&&s.closePicker()},e[25]=s,e[26]=f):f=e[26];let T;e[27]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("strong",{children:"Add a clip"}),e[27]=T):T=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(mt,{size:16}),e[28]=R):R=e[28],e[29]!==s.closePicker?(m=t.jsxs("header",{children:[T,t.jsx("button",{type:"button",onClick:s.closePicker,"aria-label":"Close clip picker",children:R})]}),e[29]=s.closePicker,e[30]=m):m=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=I=>a(I.target.value),e[31]=E):E=e[31],e[32]!==i?(b=t.jsx("input",{autoFocus:!0,"aria-label":"Filter timeline sources",placeholder:"Filter media by name",value:i,onChange:E}),e[32]=i,e[33]=b):b=e[33],g="timeline-source-list";let F;e[34]!==s||e[35]!==c.trackId?(F=I=>t.jsxs("button",{type:"button",disabled:s.busy,onClick:()=>{s.append(c.trackId,I.artifactId)},children:[I.thumbnailUrl?t.jsx("img",{src:I.thumbnailUrl,alt:"",loading:"lazy"}):t.jsx(St,{size:24}),t.jsx("span",{children:I.label}),t.jsx(es,{size:16})]},I.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]=f,e[9]=m,e[10]=b,e[11]=p,e[12]=g,e[13]=h,e[14]=j,e[15]=x,e[16]=y,e[17]=v,e[18]=k}else d=e[6],u=e[7],f=e[8],m=e[9],b=e[10],p=e[11],g=e[12],h=e[13],j=e[14],x=e[15],y=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]!==f||e[50]!==m||e[51]!==b||e[52]!==S||e[53]!==M||e[54]!==N||e[55]!==j||e[56]!==x||e[57]!==y||e[58]!==v||e[59]!==k?($=t.jsxs("dialog",{ref:j,className:x,"aria-label":y,"data-composer-focus":v,onCancel:k,onKeyDown:u,onClick:f,children:[m,b,S,M,N]}),e[48]=u,e[49]=f,e[50]=m,e[51]=b,e[52]=S,e[53]=M,e[54]=N,e[55]=j,e[56]=x,e[57]=y,e[58]=v,e[59]=k,e[60]=$):$=e[60];let P;return e[61]!==p||e[62]!==$?(P=p($,document.body),e[61]=p,e[62]=$,e[63]=P):P=e[63],P}function S1(l){const e=X.c(185),{sequence:s,assets:n,assembly:i,disabled:a,frame:r,address:o,onSeek:c,onPreview:d,onExport:u,onRemove:f,presentation:m,toolbar:b,onSelectClip:p,onMoveClip:g,onRemoveClip:h,onTrimClip:j,trimBounds:x,rhythm:y}=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,[A,T]=C.useState(null),R=C.useRef(!1),[E,F]=C.useState(null),I=C.useRef(null),D=C.useRef(null),[L,_]=C.useState(120),[z,O]=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(R1,0)??0;q=s?.captions.reduce(I1,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,z/10):Gl,ae=Math.max(1,z-se)/Math.max(1,K),V=Math.min(k==="fit"?ae:k,8e6/Math.max(1,K)),oe=k==="fit"?z:Math.max(z,K*V+se),W=Math.min(S,oe-z);let te;e[3]!==s?.tracks?(te=s?.tracks.reduce($1,void 0),e[3]=s?.tracks,e[4]=te):te=e[4];const le=te;le?.trackId;let Y;e[5]!==le?.trackId||e[6]!==s?(Y=s?.tracks.filter(Re=>Re.kind==="audio"||Re.kind==="video"&&Re.trackId!==le?.trackId&&s.clips.some(Ee=>Ee.trackId===Re.trackId))??[],e[5]=le?.trackId,e[6]=s,e[7]=Y):Y=e[7];const ee=Y;let J;if(e[8]!==s?.clips){J=new Map;for(const Re of s?.clips??[]){const Ee=J.get(Re.trackId)??[];Ee.push(Re),J.set(Re.trackId,Ee)}e[8]=s?.clips,e[9]=J}else J=e[9];const re=J;let Q;e[10]!==n?(Q=new Map(n.map(C1)),e[10]=n,e[11]=Q):Q=e[11];const Z=Q;let de,fe;e[12]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{const Re=I.current,Ee=D.current;if(!Re||!Ee)return;const qe=new ResizeObserver(()=>{_(Re.clientHeight);const _e=Number.parseFloat(getComputedStyle(Ee).marginLeft)||Xl;O(Math.max(1,Math.min(Ee.clientWidth,Re.clientWidth-_e)))});return qe.observe(Re),qe.observe(Ee),()=>qe.disconnect()},fe=[],e[12]=de,e[13]=fe):(de=e[12],fe=e[13]),C.useEffect(de,fe);const me=v==="preview"?64:y1,pe=Math.max(0,Math.min(Math.floor(N/me),ee.length-1)-1);let ue,be,ye,ce,G,ie,he,ke,we,Ie,Ne,Me,Fe,et,Ye,Ke;if(e[14]!==o||e[15]!==i||e[16]!==Z||e[17]!==L||e[18]!==W||e[19]!==re||e[20]!==a||e[21]!==A||e[22]!==K||e[23]!==H||e[24]!==pe||e[25]!==ae||e[26]!==U||e[27]!==r||e[28]!==z||e[29]!==le||e[30]!==u||e[31]!==g||e[32]!==d||e[33]!==f||e[34]!==h||e[35]!==c||e[36]!==p||e[37]!==j||e[38]!==V||e[39]!==v||e[40]!==y||e[41]!==P||e[42]!==s||e[43]!==b||e[44]!==me||e[45]!==ee||e[46]!==E||e[47]!==x||e[48]!==k){const Re=ee.slice(pe,pe+Math.ceil(L/me)+3),Ee=a||i.busy;let qe;e[65]!==P||e[66]!==s?.clips?(qe=s?.clips.find(De=>De.clipId===P),e[65]=P,e[66]=s?.clips,e[67]=qe):qe=e[67];const _e=qe;let ve;e[68]!==_e?.trackId||e[69]!==s?.tracks?(ve=s?.tracks.find(De=>De.trackId===_e?.trackId),e[68]=_e?.trackId,e[69]=s?.tracks,e[70]=ve):ve=e[70];const Qe=ve,nt=_e&&!Qe?.locked&&(Qe?.kind==="audio"||Qe?.trackId===le?.trackId),At=Math.max(1,2**Math.ceil(Math.log2(100/V))),wt=Math.floor(W/V/At),Dt=Array.from({length:Math.ceil(z/V/At)+2},(De,$e)=>(wt+$e)*At);y?.markers;let Ze;if(e[71]!==W||e[72]!==U||e[73]!==z||e[74]!==V||e[75]!==y?.markers){Ze=[];for(const De of y?.markers??[]){const $e=De.frame/U*V-W,kt=Ze[Ze.length-1],_t=kt?kt.frame/U*V-W:-1/0;if(!($e<0||$e>z)){if($e-_t<(De.bar?8:14)){De.bar&&kt&&!kt.bar&&(Ze[Ze.length-1]=De);continue}Ze.push(De)}}e[71]=W,e[72]=U,e[73]=z,e[74]=V,e[75]=y?.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($e,kt){const _t=kt.getBoundingClientRect(),Ut=($e-_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 Pe=xe,Ge=function($e,kt){const _t=re.get($e.trackId)??[],Ut=$e.kind==="video"&&$e.trackId!==le?.trackId,Lt=_t.filter(je=>{const dt=je.timelineStartFrame/U*V;return dt+je.durationFrames/U*V>=W-100&&dt<=W+z+100});return t.jsxs("div",{className:`timeline-track timeline-track-${$e.kind}`,"data-track-id":$e.trackId,style:kt,children:[t.jsxs("div",{className:"timeline-track-label",children:[t.jsx("span",{title:$e.name,children:Ut?`${$e.name} · read only`:$e.name}),!Ut&&t.jsx("button",{type:"button",disabled:Ee||$e.locked,onClick:()=>{i.openPicker($e.trackId)},"aria-label":`Add clip to ${$e.name}`,children:t.jsx(es,{size:14})}),$e.kind==="audio"&&_t.length===0&&ee.filter(N1).length>1&&t.jsx("button",{type:"button",disabled:Ee||$e.locked,onClick:()=>{i.removeTrack($e.trackId)},"aria-label":`Remove ${$e.name}`,children:t.jsx(mt,{size:12})})]}),t.jsxs("div",{className:"timeline-track-lane",onClick:je=>Pe(je.clientX,je.currentTarget),children:[Lt.map(je=>{const dt=Z.get(je.source.artifactId),Ht=E?.clipId===je.clipId?E:null,Ts=(Ht?Ht.start:A?.clipId===je.clipId?A.frame:je.timelineStartFrame)/U*V-W,cs=(Ht?Ht.end-Ht.start:je.durationFrames)/U*V,ns=!!(j&&x&&P===je.clipId&&$e.kind==="video"&&!Ut&&!$e.locked&&!Ee),Es=y?.analysis?.artifactId===je.source.artifactId?y.analysis:null,Xt=$e.kind==="audio"?ho(je,Es?.waveform??dt?.waveform??[],Es?.durationSeconds??dt?.duration??0,U,Math.min(2048,Math.max(32,Math.ceil(cs/2)))):[],Fs=bo(Xt);return t.jsxs("button",{className:`timeline-clip${P===je.clipId?" selected":""}${y?.masterClipId===je.clipId?" timeline-master":""}`,type:"button","data-clip-id":je.clipId,"aria-pressed":P===je.clipId,title:`${dt?.label??"Clip"} · ${(je.durationFrames/U).toFixed(2)}s`,style:{left:Ts,width:Math.max(2,cs)},onPointerDown:st=>{!g||Ut||$e.kind!=="video"||$e.locked||Ee||st.button!==0||(R.current=!1,st.currentTarget.setPointerCapture(st.pointerId),T({clipId:je.clipId,clientX:st.clientX,start:je.timelineStartFrame,frame:je.timelineStartFrame}))},onPointerMove:st=>{if(!A||A.clipId!==je.clipId)return;Math.abs(st.clientX-A.clientX)>4&&(R.current=!0);const Rt=Math.max(0,A.start+(st.clientX-A.clientX)/V*U),Be=st.altKey?Math.round(Rt):kl(Rt,y?.markers??[],y?.snap??"off",12/V*U);T({...A,frame:Be})},onPointerUp:()=>{A?.clipId===je.clipId&&R.current&&A.frame!==je.timelineStartFrame&&g?.(je,A.frame),T(null)},onPointerCancel:()=>{R.current=!1,T(null)},onKeyDown:st=>{st.key==="Escape"&&A&&(st.stopPropagation(),R.current=!1,T(null))},onClick:st=>{if(st.stopPropagation(),R.current){R.current=!1;return}i.selectClip(je.clipId),p?.(je),c(je.timelineStartFrame)},children:[Fs&&t.jsx("svg",{className:"timeline-waveform",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:t.jsx("path",{d:Fs})}),dt?.thumbnailUrl&&$e.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:w1,onPointerDown:Rt=>{if(Rt.button!==0)return;Rt.stopPropagation(),Rt.currentTarget.setPointerCapture(Rt.pointerId);const Be=je.timelineStartFrame+je.durationFrames;F({clipId:je.clipId,edge:st,clientX:Rt.clientX,start:je.timelineStartFrame,end:Be,origin:st==="start"?je.timelineStartFrame:Be})},onPointerMove:Rt=>{if(!E||E.clipId!==je.clipId||E.edge!==st||!x)return;const Be=E.origin+(Rt.clientX-E.clientX)/V*U,zt=Rt.altKey?Math.round(Be):kl(Be,y?.markers??[],y?.snap??"off",12/V*U);F({...E,...v1(E,zt,x)})},onPointerUp:Rt=>{Rt.stopPropagation();const Be=E;F(null),!(!Be||Be.clipId!==je.clipId)&&(Be.start===je.timelineStartFrame&&Be.end===je.timelineStartFrame+je.durationFrames||j?.(je,st,Be.start,Be.end))},onPointerCancel:()=>F(null)},st))]},je.clipId)}),_t.length===0&&t.jsxs("span",{className:"timeline-empty-lane",children:["Add ",$e.kind," to begin"]}),ne.map(je=>t.jsx("i",{className:`timeline-beat${je.bar?" bar":""}${je.manual?" manual":""}`,style:{left:je.frame/U*V-W},"aria-hidden":"true"},je.frame)),t.jsx("i",{className:"timeline-playhead",style:{left:r/U*V-W}})]})]},$e.trackId)};we=`notebook-timeline${v==="preview"?" notebook-timeline-preview":""}`,Ie=v==="canvas"?j1:void 0,Ne=`Timeline ${o}`,Me="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]!==o?(Ct=t.jsx("code",{children:o}),e[85]=o,e[86]=Ct):Ct=e[86];let ft;e[87]!==K?(ft=$n(K),e[87]=K,e[88]=ft):ft=e[88];let Tt;e[89]!==ft?(Tt=t.jsx("span",{children:ft}),e[89]=ft,e[90]=Tt):Tt=e[90];const jt=Ee||!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 Et=Ee||H===0;let vt;e[100]!==u||e[101]!==Et?(vt=t.jsx("button",{type:"button",disabled:Et,onClick:u,children:"Export"}),e[100]=u,e[101]=Et,e[102]=vt):vt=e[102];const ze=Ee||!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]!==ae||e[111]!==V?(xt=t.jsx("button",{type:"button","aria-label":"Zoom timeline out",onClick:()=>w(Math.max(Math.min(.25,ae),V/2)),children:"−"}),e[110]=ae,e[111]=V,e[112]=xt):xt=e[112];let gt;e[113]!==ae||e[114]!==V?(gt=t.jsx("button",{type:"button","aria-label":"Zoom timeline in",onClick:()=>w(Math.min(Math.max(768,ae),V*2)),children:"+"}),e[113]=ae,e[114]=V,e[115]=gt):gt=e[115];const Vt=k==="fit";let Bt;e[116]===Symbol.for("react.memo_cache_sentinel")?(Bt=()=>{w("fit"),M(0),D.current?.scrollTo({left:0})},e[116]=Bt):Bt=e[116];let ot;e[117]!==Vt?(ot=t.jsx("button",{type:"button","aria-pressed":Vt,onClick:Bt,children:"Fit"}),e[117]=Vt,e[118]=ot):ot=e[118];let ht;e[119]!==Ee||e[120]!==f?(ht=f&&t.jsx("button",{type:"button",disabled:Ee,"aria-label":"Remove Timeline element",onClick:f,children:t.jsx(os,{size:14})}),e[119]=Ee,e[120]=f,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]!==Tt||e[133]!==Ft?(Fe=t.jsxs("header",{className:"notebook-timeline-header",children:[at,Nt,Ct,Tt,Ft]}),e[131]=Ct,e[132]=Tt,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?(ie=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]=ie):ie=e[139];const It=r/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 Ae;e[144]!==Pe?(Ae=De=>Pe(De.clientX,De.currentTarget),e[144]=Pe,e[145]=Ae):Ae=e[145];const Ce=Dt.map(De=>t.jsx("span",{style:{left:De*V-W},children:$n(De)},De));let Le;e[146]!==Ae||e[147]!==Ce?(Le=t.jsx("div",{className:"timeline-ruler","aria-label":"Timeline ruler",onClick:Ae,children:Ce}),e[146]=Ae,e[147]=Ce,e[148]=Le):Le=e[148],e[149]!==ct||e[150]!==Le?(he=t.jsxs("div",{className:"timeline-ruler-row",children:[ct,Le]}),e[149]=ct,e[150]=Le,e[151]=he):he=e[151],ke=le&&Ge(le),be="timeline-audio-viewport",ye=I,e[152]===Symbol.for("react.memo_cache_sentinel")?(ce=De=>$(De.currentTarget.scrollTop),e[152]=ce):ce=e[152],Ye="timeline-audio-content";const Ue=ee.length*me;e[153]!==Ue?(Ke={height:Ue},e[153]=Ue,e[154]=Ke):Ke=e[154],ue=Re.map((De,$e)=>Ge(De,{position:"absolute",top:(pe+$e)*me,height:me,width:"100%"})),e[14]=o,e[15]=i,e[16]=Z,e[17]=L,e[18]=W,e[19]=re,e[20]=a,e[21]=A,e[22]=K,e[23]=H,e[24]=pe,e[25]=ae,e[26]=U,e[27]=r,e[28]=z,e[29]=le,e[30]=u,e[31]=g,e[32]=d,e[33]=f,e[34]=h,e[35]=c,e[36]=p,e[37]=j,e[38]=V,e[39]=v,e[40]=y,e[41]=P,e[42]=s,e[43]=b,e[44]=me,e[45]=ee,e[46]=E,e[47]=x,e[48]=k,e[49]=ue,e[50]=be,e[51]=ye,e[52]=ce,e[53]=G,e[54]=ie,e[55]=he,e[56]=ke,e[57]=we,e[58]=Ie,e[59]=Ne,e[60]=Me,e[61]=Fe,e[62]=et,e[63]=Ye,e[64]=Ke}else ue=e[49],be=e[50],ye=e[51],ce=e[52],G=e[53],ie=e[54],he=e[55],ke=e[56],we=e[57],Ie=e[58],Ne=e[59],Me=e[60],Fe=e[61],et=e[62],Ye=e[63],Ke=e[64];let Ve;e[155]!==ue||e[156]!==Ye||e[157]!==Ke?(Ve=t.jsx("div",{className:Ye,style:Ke,children:ue}),e[155]=ue,e[156]=Ye,e[157]=Ke,e[158]=Ve):Ve=e[158];let lt;e[159]!==be||e[160]!==ye||e[161]!==ce||e[162]!==Ve?(lt=t.jsx("div",{className:be,ref:ye,onScroll:ce,children:Ve}),e[159]=be,e[160]=ye,e[161]=ce,e[162]=Ve,e[163]=lt):lt=e[163];let Te;e[164]===Symbol.for("react.memo_cache_sentinel")?(Te=Re=>M(Re.currentTarget.scrollLeft),e[164]=Te):Te=e[164];let We;e[165]!==oe?(We=t.jsx("div",{className:"timeline-horizontal",ref:D,onScroll:Te,children:t.jsx("div",{style:{width:oe,height:1}})}),e[165]=oe,e[166]=We):We=e[166];let Xe;e[167]!==G||e[168]!==ie||e[169]!==he||e[170]!==ke||e[171]!==lt||e[172]!==We?(Xe=t.jsxs("div",{className:G,children:[ie,he,ke,lt,We]}),e[167]=G,e[168]=ie,e[169]=he,e[170]=ke,e[171]=lt,e[172]=We,e[173]=Xe):Xe=e[173];let Je;e[174]!==i?(Je=i.picker&&t.jsx(k1,{assembly:i}),e[174]=i,e[175]=Je):Je=e[175];let tt;return e[176]!==we||e[177]!==Ie||e[178]!==Ne||e[179]!==Me||e[180]!==Fe||e[181]!==et||e[182]!==Xe||e[183]!==Je?(tt=t.jsxs("section",{className:we,style:Ie,"aria-label":Ne,"data-composer-focus":Me,children:[Fe,et,Xe,Je]}),e[176]=we,e[177]=Ie,e[178]=Ne,e[179]=Me,e[180]=Fe,e[181]=et,e[182]=Xe,e[183]=Je,e[184]=tt):tt=e[184],tt}function w1(l){return l.stopPropagation()}function N1(l){return l.kind==="audio"}function C1(l){return[l.artifactId,l]}function $1(l,e){return e.kind==="video"&&(!l||e.ordinal<l.ordinal)?e:l}function I1(l,e){return Math.max(l,e.timelineStartFrame+e.durationFrames)}function R1(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(Ti,{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(Ei,{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 M1(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 P1(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 r;e[0]!==s?(r=P1(s),e[0]=s,e[1]=r):r=e[1];const o=r,c=n??i;let d;e[2]!==i||e[3]!==o?(d=o?t.jsx("img",{src:o,alt:`${i} frame`}):t.jsx(St,{size:24,"aria-hidden":!0}),e[2]=i,e[3]=o,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 f;e[7]!==a?(f=a===null?"Frame pending":Kt(a),e[7]=a,e[8]=f):f=e[8];let m;e[9]!==f?(m=t.jsx("span",{children:f}),e[9]=f,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 p;return e[14]!==c||e[15]!==d||e[16]!==b?(p=t.jsxs("figure",{title:c,children:[d,b]}),e[14]=c,e[15]=d,e[16]=b,e[17]=p):p=e[17],p}function A1(l){const e=X.c(13),{data:s}=l;let n;e[0]!==s.inputs?(n=_o(s.inputs),e[0]=s.inputs,e[1]=n):n=e[1];const i=n,a=s.splitFrames?.first.asset,r=s.splitFrames?.first.artifactId??null,o=i?.startSeconds??null;let c;e[2]!==a||e[3]!==r||e[4]!==o?(c=t.jsx(Ql,{asset:a,artifactId:r,label:"First",time:o}),e[2]=a,e[3]=r,e[4]=o,e[5]=c):c=e[5];const d=s.splitFrames?.last.asset,u=s.splitFrames?.last.artifactId??null,f=i?.endSeconds??null;let m;e[6]!==d||e[7]!==u||e[8]!==f?(m=t.jsx(Ql,{asset:d,artifactId:u,label:"Last",time:f}),e[6]=d,e[7]=u,e[8]=f,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 D1(l){const e=X.c(48),{cellId:s,kind:n,ready:i,state:a,onFile:r,onFileError:o,onOpenLibrary:c}=l,d=C.useRef(null),[u,f]=C.useState(!1),m=a?.operation!==null&&a?.operation!==void 0;let b;e[0]!==m||e[1]!==s||e[2]!==r||e[3]!==o||e[4]!==i?(b=O=>{if(m||!i)return;const U=O?[...O]:[];if(U.length!==1){o(s,"Choose one file for this media slot.");return}r(s,U[0])},e[0]=m,e[1]=s,e[2]=r,e[3]=o,e[4]=i,e[5]=b):b=e[5];const p=b,g=`cell-media-slot nodrag nowheel${u?" cell-media-slot-dragging":""}`,h=`Empty ${n} media slot`;let j,x;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=O=>{Hs(O.dataTransfer)&&(O.preventDefault(),O.stopPropagation(),f(!0))},x=O=>{Hs(O.dataTransfer)&&(O.preventDefault(),O.stopPropagation(),f(!1))},e[6]=j,e[7]=x):(j=e[6],x=e[7]);let y;e[8]!==m||e[9]!==i?(y=O=>{Hs(O.dataTransfer)&&(O.preventDefault(),O.stopPropagation(),O.dataTransfer.dropEffect=i&&!m?"copy":"none")},e[8]=m,e[9]=i,e[10]=y):y=e[10];let v;e[11]!==p||e[12]!==m?(v=O=>{Hs(O.dataTransfer)&&(O.preventDefault(),O.stopPropagation(),f(!1),m||p(O.dataTransfer.files))},e[11]=p,e[12]=m,e[13]=v):v=e[13];const k=m||!i;let w;e[14]!==s||e[15]!==c?(w=O=>{O.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 A=m||!i;let T,R;e[27]===Symbol.for("react.memo_cache_sentinel")?(T=O=>{O.stopPropagation(),d.current?.click()},R=t.jsx(sn,{size:13}),e[27]=T,e[28]=R):(T=e[27],R=e[28]);let E;e[29]!==A?(E=t.jsxs("button",{type:"button",className:"cell-media-slot-upload",disabled:A,onClick:T,children:[R,"Upload file"]}),e[29]=A,e[30]=E):E=e[30];const F=hi[n],I=m||!i;let D;e[31]!==p?(D=O=>{p(O.target.files),O.target.value=""},e[31]=p,e[32]=D):D=e[32];let L;e[33]!==F||e[34]!==I||e[35]!==D?(L=t.jsx("input",{ref:d,className:"cell-media-slot-input",type:"file",accept:F,disabled:I,onChange:D}),e[33]=F,e[34]=I,e[35]=D,e[36]=L):L=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 z;return e[39]!==P||e[40]!==E||e[41]!==g||e[42]!==L||e[43]!==_||e[44]!==h||e[45]!==y||e[46]!==v?(z=t.jsxs("section",{className:g,"aria-label":h,onDragEnter:j,onDragLeave:x,onDragOver:y,onDrop:v,children:[P,E,L,_]}),e[39]=P,e[40]=E,e[41]=g,e[42]=L,e[43]=_,e[44]=h,e[45]=y,e[46]=v,e[47]=z):z=e[47],z}const T1=["left","right","bottom"],E1=T1.flatMap(l=>Rn.map((e,s)=>({id:yo(l,s),position:l==="left"?Cs.Left:l==="right"?Cs.Right:Cs.Bottom,style:l==="bottom"?{left:`${e*100}%`}:{top:`${e*100}%`}})));function F1(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}`,r=`Status: ${i}`;let o;e[2]!==i||e[3]!==s?(o=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]=o):o=e[4];let c;return e[5]!==i||e[6]!==a||e[7]!==r||e[8]!==o?(c=t.jsx("span",{className:a,"aria-label":r,title:i,children:o}),e[5]=i,e[6]=a,e[7]=r,e[8]=o,e[9]=c):c=e[9],c}function If({id:l,data:e,selected:s}){const n=C.useContext(Vm),i=C.useContext(qm),a=C.useContext(Wm),r=C.useContext(Xm),o=C.useContext(Gm),c=C.useContext(Ym),d=C.useContext(Zm).get(l)??null,u=pc(),f=s&&r===l,m=e.asset?.mediaUrl,b=e.asset?.thumbnailUrl,p=e.targetInputs?.length?e.targetInputs:["input"],g=e.targetConnectionCount??0,h=e.targetInputConnectionCounts??{},j=jo(e.kind),x=j!==null&&vo(e.kind,e.outputArtifactId,g),y=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=!y&&e.kind==="image",M=e.kind==="prompt"||e.kind==="analyze",N=e.slot.row===0,$=[N?"top":"lower",...p,"|",...e.sourcePorts??[]].join("\0");C.useEffect(()=>{u(l)},[$,l,u]);const P=ko({type:e.kind,model:e.model,operation:e.operation,outputArtifactId:e.outputArtifactId,tool:e.tool},e.status),A=e.post?So(e.post):wo(e.kind,e.status),T=yi(e.kind),R=T||Sl({type:e.kind,inputs:e.inputs}),E=R&&[e.provider??e.producerProvider,e.model??e.producerModel].filter(ce=>typeof ce=="string"&&ce.length>0).join(" · ")||null,F=T&&e.model?o.get(e.model)??null:null,I=T?F??e.model??e.tool??null:null,D=T?ps(e.inputs?.generationMode):null,L=D&&/^[a-z]2[a-z]$/i.test(D)?D.toUpperCase():null,_=I?(()=>{const ce=No(I);return L&&!ce.toUpperCase().includes(L)?`${ce} · ${L}`:ce})():null,z=T?Co(e.inputs?.generationSettings):null,O=pi(e.model??"",e.inputs??{})??(z?ps(z.aspect_ratio):null),U=z?ps(z.duration)??ps(z.duration_seconds)??(typeof z.duration=="number"?String(z.duration):null):null,q=ji(e.kind),H=T&&U!==null&&O!==null,K=H?M1(e.kind):q,se=ps(e.prompt)||ps(e.inputs?.resolvedPrompt),ae=S?se??e.asset?.prompt??null:null,V=S&&e.model?o.get(e.model)??null:null,oe=M||T&&!!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,le={audioInfo:e.asset?.audioInfo??null,durationSeconds:e.asset?.duration??null,hasOutput:!!e.outputArtifactId,inputs:e.inputs},Y=k&&v,ee=w&&!!(m||b),J=Y?$o(le):[],re=Y?Io(le):null,Q=ee?S?Ro({width:e.asset?.width??null,height:e.asset?.height??null,tool:V,model:e.model??e.tool??null,provenance:te}):Mo({aspectRatio:e.videoAspectRatio??null,width:e.asset?.width??null,height:e.asset?.height??null,tool:e.model?o.get(e.model)??null:null,model:e.model??e.tool??null,provenance:te}):[],Z=ee&&y?Po(e.videoDurationSeconds??e.asset?.duration??null):null,de=Ao(e.status),fe=e.status==="error",me=Do(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}))&&me.length>1,ue=Math.max(1,me.indexOf(e.outputArtifactId??"")+1),be=Jm(l),ye=(ce,G,ie)=>{c.open(l,{x:ce,y:G},ie)};return t.jsxs("article",{className:["cell-node",`cell-kind-${e.kind}`,`cell-family-${Fo(e.kind)}`,s?"cell-node-selected":"",f?"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":Eo(e.kind),"data-selection":f?"primary":s?"selected":void 0,"data-highlight":e.highlighted?"generated":void 0,"data-version-count":me.length,"data-cell-status":e.status,"data-context-menu-open":c.openCellId===l?"true":void 0,onContextMenu:ce=>{ce.preventDefault(),ce.stopPropagation(),ye(ce.clientX,ce.clientY,document.activeElement instanceof HTMLElement?document.activeElement:null)},onKeyDown:ce=>{if(ce.key!=="ContextMenu"&&!(ce.shiftKey&&ce.key==="F10"))return;ce.preventDefault(),ce.stopPropagation();const G=ce.currentTarget.getBoundingClientRect();ye(G.left+Math.min(G.width-12,40),G.top+40,document.activeElement instanceof HTMLElement?document.activeElement:null)},children:[p.map((ce,G)=>t.jsx(jn,{type:"target",position:Cs.Top,id:ce,className:`cell-target-handle${N?" cell-target-handle-top-row":""}`,style:{left:`${(G+1)/(p.length+1)*100}%`}},ce)),p.map((ce,G)=>{const ie=h[ce]??0;return ie<2?null:t.jsx("span",{className:"cell-target-connection-count","aria-label":`${ie} connections into ${ce}`,"data-connection-count":ie,style:{left:`${(G+1)/(p.length+1)*100}%`},children:ie},`${ce}-count`)}),E1.map(ce=>t.jsx(jn,{type:"source",position:ce.position,id:ce.id,isConnectable:!1,className:`cell-route-handle${e.sourcePorts?.includes(ce.id)?" cell-route-handle-active":""}`,style:ce.style},ce.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:To(e.post)})}),(T||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":""]}),O&&t.jsx("span",{className:"cell-aspect-ratio",title:"Aspect ratio",children:O}),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&&!T&&t.jsx("button",{type:"button",className:"cell-run-button nodrag",disabled:P.disabled,onClick:ce=>{ce.stopPropagation(),i(l)},children:P.label}),!P&&pe&&t.jsxs("span",{className:"cell-version-count","aria-label":`Current output version ${ue} of ${me.length}`,title:`Current output · version ${ue} of ${me.length}`,children:[t.jsx(Ns,{size:12,"aria-hidden":"true"}),"v",ue,"/",me.length]})]}),t.jsxs("div",{className:"cell-node-body",children:[e.kind==="post"?t.jsx(Lm,{post:e.post,source:e.postSource}):x&&j?t.jsx(D1,{cellId:l,kind:j,ready:n.ready,state:n.states[l],onFile:n.onFile,onFileError:n.onFileError,onOpenLibrary:n.onOpenLibrary}):e.kind==="split_video"?t.jsx(A1,{data:e}):e.kind==="analysis"?t.jsx(e1,{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:J,meter:re,metadataLabel:Nl(q,J,re,null),pendingLabel:"Waveform pending",pendingIcon:t.jsx(ss,{size:26,"aria-hidden":"true"})}):ee?t.jsx(Wl,{address:W,posterUrl:b??(y?null:m??null),waveform:null,mediaUrl:m??null,playbackKind:y&&m?"video":null,alt:e.label??W,title:ae??void 0,badges:Q,meter:Z,metadataLabel:Nl(q,Q,Z,ae),pendingLabel:"Poster pending",pendingIcon:t.jsx(St,{size:26,"aria-hidden":"true"}),children:t.jsx(Hd,{inputs:e.inputs})}):t.jsxs("div",{className:`cell-copy ${oe?"cell-copy-text":""}`,children:[_&&t.jsx("span",{className:"cell-model-line",title:_,children:_}),oe?t.jsx("p",{title:e.prompt||void 0,children:e.prompt||Jl(e)}):t.jsx(Mi,{size:28}),!oe&&t.jsx("span",{children:_?"Add a prompt":Jl(e)})]}),t.jsx(g1,{kind:e.kind,address:ti(e.slot),status:e.status,statusStartedAt:e.statusStartedAt,statusError:e.statusError,icon:t.jsx(Yl,{kind:e.kind}),generator:E,generation:R,onRepair:R?()=>{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(F1,{status:A}),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":be,title:"Cell actions",onClick:ce=>{ce.preventDefault(),ce.stopPropagation();const G=ce.currentTarget.getBoundingClientRect();ye(G.right-4,G.bottom+4,ce.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 Rf(l){const e=X.c(13),{id:s,data:n}=l,i=C.useContext(Qm);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 r,o,c;e[2]!==i||e[3]!==s?(r=u=>i.onSeek(s,u),o=()=>i.onPreview(s),c=()=>i.onRemove(s),e[2]=i,e[3]=s,e[4]=r,e[5]=o,e[6]=c):(r=e[4],o=e[5],c=e[6]);let d;return e[7]!==i||e[8]!==a||e[9]!==r||e[10]!==o||e[11]!==c?(d=t.jsx(S1,{...i,address:a,onSeek:r,onPreview:o,onRemove:c}),e[7]=i,e[8]=a,e[9]=r,e[10]=o,e[11]=c,e[12]=d):d=e[12],d}function Mf(l){const e=X.c(262),{rhythm:s,sequence:n,assets:i,frame:a,correctionsOpen:r,onCorrectionsOpenChange:o}=l;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const d=C.useRef(c),[u,f]=C.useState(""),[m,b]=C.useState(""),[p,g]=C.useState(""),h=s.master,j=s.status==="queued"||s.status==="analyzing",x=n.frameRate.numerator/n.frameRate.denominator;let y;e[1]!==n.tracks?(y=new Set(n.tracks.filter(O1).map(z1)),e[1]=n.tracks,e[2]=y):y=e[2];const v=y;let k,w,S,M,N,$,P,A,T,R,E,F,I,D,L,_,z,O,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=Ae=>v.has(Ae.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 Ae;e[39]!==a?(Ae=(Ce,Le)=>!Ce||Math.abs(Le.frame-a)<Math.abs(Ce.frame-a)?Le:Ce,e[39]=a,e[40]=Ae):Ae=e[40],$t=s.mapped.reduce(Ae,null),e[36]=a,e[37]=s.mapped,e[38]=$t}else $t=e[38];A=$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(L1),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(Ae=>Ae.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(Ce,Le,Ue){const De=Le===void 0?M??null:Le,$e=Ue===void 0?S:Ue;h&&(g(""),s.save({masterClipId:h.clipId,correction:{objectHash:h.source.range.objectHash,analysisId:s.analysis?.analysisId??null,markers:Ce,bpm:De,beatsPerBar:$e}}))},e[46]=S,e[47]=M,e[48]=h,e[49]=s,e[50]=Vt):Vt=e[50],R=Vt;let Bt;e[51]===Symbol.for("react.memo_cache_sentinel")?(Bt=function(){const Ce=performance.now(),Le=d.current[d.current.length-1];if(d.current=Le===void 0||Ce-Le>3e3?[Ce]:[...d.current.slice(-7),Ce],d.current.length>1){const Ue=d.current.slice(1).map((De,$e)=>De-d.current[$e]).sort(_1);f(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]=Bt):Bt=e[51],H=Bt;let ot;e[52]!==M||e[53]!==x||e[54]!==a||e[55]!==h||e[56]!==m||e[57]!==R||e[58]!==u?(ot=function(){if(!h)return;const Ce=Number(u||M),Le=m?Number(m):null;if(!(Ce>=20&&Ce<=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,De=Ue.timeBase.numerator/Ue.timeBase.denominator,$e=(Ue.startTick+Ue.durationTicks)*De;if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead inside the soundtrack.");return}const kt=Math.min($e-De,Cl(h,a,x)),_t=h.reverse?Math.floor((kt-Ue.startTick*De)/(60/Ce))+1:Math.ceil(($e-kt)/(60/Ce)),Ut=Array.from({length:Math.max(0,_t)},(Lt,je)=>({id:`grid-${je}`,timeSeconds:kt+(h.reverse?-1:1)*je*60/Ce,bar:Le!==null&&je%Le===0,manual:!0}));R(Ut,Ce,Le)},e[52]=M,e[53]=x,e[54]=a,e[55]=h,e[56]=m,e[57]=R,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]!==R?(ht=function(){if(!h)return;const Ce=h.source.range,Le=(Ce.startTick+Ce.durationTicks-1)*Ce.timeBase.numerator/Ce.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(De=>Math.abs(De.timeSeconds-Ue)<.5/x)||R([...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]=R,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]!==A||e[72]!==s.markers||e[73]!==R?(Ft=function(){if(!h||!A)return;const Ce=m?Number(m):S;if(Ce===null||!Number.isInteger(Ce)||Ce<1||Ce>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}R(Lo(s.markers,A.id,Ce,M??null),M??null,Ce)},e[66]=S,e[67]=M,e[68]=a,e[69]=h,e[70]=m,e[71]=A,e[72]=s.markers,e[73]=R,e[74]=Ft):Ft=e[74],E=Ft;let It;e[75]!==x||e[76]!==h||e[77]!==A||e[78]!==s.markers||e[79]!==R?(It=function(Ce){if(!h||!A)return;const Le=A.timeSeconds+Ce/x*h.speed.numerator/h.speed.denominator*(h.reverse?-1:1);Le<0||R(s.markers.map(Ue=>Ue.id===A.id?{...Ue,timeSeconds:Le,manual:!0}:Ue))},e[75]=x,e[76]=h,e[77]=A,e[78]=s.markers,e[79]=R,e[80]=It):It=e[80],T=It,I="music-rhythm-controls",F="music-rhythm-row",q="Soundtrack",D="Master soundtrack",L=h?.clipId??"",_=s.busy,e[81]!==s?(z=Ae=>{s.save({masterClipId:Ae.target.value||null,correction:null})},e[81]=s,e[82]=z):z=e[82];const yt=Pt.length?"Choose audio clip":"Add audio to the timeline";e[83]!==yt?(O=t.jsx("option",{value:"",children:yt}),e[83]=yt,e[84]=O):O=e[84];let ct;e[85]!==i||e[86]!==x?(ct=Ae=>t.jsxs("option",{value:Ae.clipId,children:[i.find(Ce=>Ce.artifactId===Ae.source.artifactId)?.label??"Audio"," · ",(Ae.timelineStartFrame/x).toFixed(1),"s"]},Ae.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]=A,e[21]=T,e[22]=R,e[23]=E,e[24]=F,e[25]=I,e[26]=D,e[27]=L,e[28]=_,e[29]=z,e[30]=O,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],A=e[20],T=e[21],R=e[22],E=e[23],F=e[24],I=e[25],D=e[26],L=e[27],_=e[28],z=e[29],O=e[30],U=e[31],q=e[32],H=e[33];let K;e[88]!==D||e[89]!==L||e[90]!==_||e[91]!==z||e[92]!==O||e[93]!==U?(K=t.jsxs("select",{"aria-label":D,value:L,disabled:_,onChange:z,children:[O,U]}),e[88]=D,e[89]=L,e[90]=_,e[91]=z,e[92]=O,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 ae=!h||s.busy||j;let V;e[98]!==s?(V=()=>{s.analyze(!!s.analysis)},e[98]=s,e[99]=V):V=e[99];const oe=s.analysis?"Analyze again":"Analyze beats";let W;e[100]!==ae||e[101]!==V||e[102]!==oe?(W=t.jsx("button",{type:"button",disabled:ae,onClick:V,children:oe}),e[100]=ae,e[101]=V,e[102]=oe,e[103]=W):W=e[103];let te;e[104]!==j||e[105]!==s?(te=j&&t.jsx("button",{type:"button",disabled:s.busy,onClick:()=>{s.cancel()},children:"Cancel analysis"}),e[104]=j,e[105]=s,e[106]=te):te=e[106];let le;e[107]!==M||e[108]!==j||e[109]!==s.mapped.length||e[110]!==s.status?(le=j?"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]=j,e[109]=s.mapped.length,e[110]=s.status,e[111]=le):le=e[111];let Y;e[112]!==le?(Y=t.jsx("span",{role:"status",children:le}),e[112]=le,e[113]=Y):Y=e[113];let ee;e[114]!==s?(ee=()=>{s.load()},e[114]=s,e[115]=ee):ee=e[115];let J;e[116]!==s.busy||e[117]!==ee?(J=t.jsx("button",{type:"button",disabled:s.busy,onClick:ee,children:"Reload beats"}),e[116]=s.busy,e[117]=ee,e[118]=J):J=e[118];let re;e[119]!==F||e[120]!==se||e[121]!==W||e[122]!==te||e[123]!==Y||e[124]!==J?(re=t.jsxs("div",{className:F,children:[se,W,te,Y,J]}),e[119]=F,e[120]=se,e[121]=W,e[122]=te,e[123]=Y,e[124]=J,e[125]=re):re=e[125];let Q;e[126]!==h||e[127]!==n.tracks?(Q=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]=Q):Q=e[128];let Z;e[129]!==h?.reverse?(Z=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]=Z):Z=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 me=w?`${w} ${$?"estimated bar starts":"bar starts"} · ${S??"Unknown"} beats per bar`:"Set bar starts";let pe;e[137]!==me?(pe=t.jsx("strong",{children:me}),e[137]=me,e[138]=pe):pe=e[138];let ue;e[139]!==$?(ue=$&&t.jsx("p",{children:"Bars start at the first detected beat. Adjust them below if needed."}),e[139]=$,e[140]=ue):ue=e[140];let be;e[141]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsx("p",{children:"Place the playhead on the first beat of a bar, then enter the number of beats per bar."}),e[141]=be):be=e[141];let ye;e[142]!==S?(ye=S?.toString()??"e.g. 4",e[142]=S,e[143]=ye):ye=e[143];let ce;e[144]===Symbol.for("react.memo_cache_sentinel")?(ce=ze=>b(ze.target.value),e[144]=ce):ce=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:ce})]}),e[145]=m,e[146]=ye,e[147]=G):G=e[147];const ie=!N||!A||s.busy;let he;e[148]!==E||e[149]!==ie?(he=t.jsx("button",{type:"button",disabled:ie,onClick:E,children:"Set bars from playhead"}),e[148]=E,e[149]=ie,e[150]=he):he=e[150];let ke;e[151]!==G||e[152]!==he?(ke=t.jsxs("div",{className:"music-rhythm-row",children:[G,he]}),e[151]=G,e[152]=he,e[153]=ke):ke=e[153];let we;e[154]!==x||e[155]!==A?(we=A&&t.jsxs("small",{children:["Use the beat at ",(A.frame/x).toFixed(3),"s as a bar start."]}),e[154]=x,e[155]=A,e[156]=we):we=e[156];let Ie;e[157]!==pe||e[158]!==ue||e[159]!==ke||e[160]!==we?(Ie=t.jsxs("section",{className:"music-bar-setup","aria-label":"Bar setup",children:[pe,ue,be,ke,we]}),e[157]=pe,e[158]=ue,e[159]=ke,e[160]=we,e[161]=Ie):Ie=e[161];let Ne;e[162]!==o?(Ne=ze=>o(ze.currentTarget.open),e[162]=o,e[163]=Ne):Ne=e[163];let Me;e[164]===Symbol.for("react.memo_cache_sentinel")?(Me=t.jsx("summary",{children:"Correct the beat grid"}),e[164]=Me):Me=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=>f(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 Te;e[174]!==P||e[175]!==lt?(Te=t.jsx("button",{type:"button",disabled:lt,onClick:P,children:"Set grid from playhead"}),e[174]=P,e[175]=lt,e[176]=Te):Te=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||!A||s.busy;let tt;e[180]!==A?.id||e[181]!==s.markers||e[182]!==R?(tt=()=>R(s.markers.filter(ze=>ze.id!==A?.id)),e[180]=A?.id,e[181]=s.markers,e[182]=R,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 Ee=!N||!A||s.busy;let qe;e[187]!==T?(qe=()=>T(-1),e[187]=T,e[188]=qe):qe=e[188];let _e;e[189]!==Ee||e[190]!==qe?(_e=t.jsx("button",{type:"button",disabled:Ee,onClick:qe,children:"Beat −1 frame"}),e[189]=Ee,e[190]=qe,e[191]=_e):_e=e[191];const ve=!N||!A||s.busy;let Qe;e[192]!==T?(Qe=()=>T(1),e[192]=T,e[193]=Qe):Qe=e[193];let nt;e[194]!==ve||e[195]!==Qe?(nt=t.jsx("button",{type:"button",disabled:ve,onClick:Qe,children:"Beat +1 frame"}),e[194]=ve,e[195]=Qe,e[196]=nt):nt=e[196];const At=!N||!A||s.busy;let wt;e[197]!==A?.id||e[198]!==s.markers||e[199]!==R?(wt=()=>R(s.markers.map(ze=>ze.id===A?.id?{...ze,bar:!ze.bar,manual:!0}:ze)),e[197]=A?.id,e[198]=s.markers,e[199]=R,e[200]=wt):wt=e[200];let Dt;e[201]!==At||e[202]!==wt?(Dt=t.jsx("button",{type:"button",disabled:At,onClick:wt,children:"Toggle bar start"}),e[201]=At,e[202]=wt,e[203]=Dt):Dt=e[203];let Ze;e[204]!==Ye||e[205]!==Ve||e[206]!==Te||e[207]!==Xe||e[208]!==Re||e[209]!==_e||e[210]!==nt||e[211]!==Dt?(Ze=t.jsxs("div",{className:"music-rhythm-row",children:[Ye,Ve,Te,Xe,Re,_e,nt,Dt]}),e[204]=Ye,e[205]=Ve,e[206]=Te,e[207]=Xe,e[208]=Re,e[209]=_e,e[210]=nt,e[211]=Dt,e[212]=Ze):Ze=e[212];let ne;e[213]!==x||e[214]!==A?(ne=A&&t.jsxs("span",{children:["Nearest beat · ",(A.frame/x).toFixed(3),"s",A.manual?" · adjusted":""]}),e[213]=x,e[214]=A,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]!==R?(xe=s.analysis?.beats.length&&!s.rhythm.settings.correction?t.jsx("button",{type:"button",disabled:!N||s.busy,onClick:()=>R(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]=R,e[222]=xe):xe=e[222];const Pe=!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]!==Pe||e[226]!==Ge?(at=t.jsx("button",{type:"button",disabled:Pe,onClick:Ge,children:"Undo beat change"}),e[225]=Pe,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 Tt=!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]!==Tt||e[236]!==jt?(it=t.jsx("button",{type:"button",disabled:Tt,onClick:jt,children:"Use detected beats"}),e[235]=Tt,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]!==r||e[245]!==Ne||e[246]!==Ze||e[247]!==pt?(rt=t.jsxs("details",{className:"music-rhythm-fixes",open:r,onToggle:Ne,children:[Me,Ze,pt]}),e[244]=r,e[245]=Ne,e[246]=Ze,e[247]=pt,e[248]=rt):rt=e[248];let Et;e[249]!==p||e[250]!==s.error?(Et=(p||s.error)&&t.jsx("p",{role:"alert",children:p||s.error}),e[249]=p,e[250]=s.error,e[251]=Et):Et=e[251];let vt;return e[252]!==I||e[253]!==re||e[254]!==Q||e[255]!==Z||e[256]!==de||e[257]!==fe||e[258]!==Ie||e[259]!==rt||e[260]!==Et?(vt=t.jsxs("div",{className:I,children:[re,Q,Z,de,fe,Ie,rt,Et]}),e[252]=I,e[253]=re,e[254]=Q,e[255]=Z,e[256]=de,e[257]=fe,e[258]=Ie,e[259]=rt,e[260]=Et,e[261]=vt):vt=e[261],vt}function _1(l,e){return l-e}function L1(l){return l.bar}function z1(l){return l.trackId}function O1(l){return l.kind==="audio"}function Pf(l){const e=X.c(90),{sources:s,trackId:n,startFrame:i,endFrame:a,fps:r,hasBars:o,busy:c,draft:d,onPlan:u,onOrder:f}=l,[m,b]=C.useState(""),[p,g]=C.useState(""),[h,j]=C.useState(4),[x,y]=C.useState("beats"),[v,k]=C.useState("0.25"),[w,S]=C.useState(!0),[M,N]=C.useState(!1),[$,P]=C.useState(!1);let A;e[0]!==f||e[1]!==s?(A=function(he,ke){const we=s.map(K1),Ie=he+ke;if(Ie<0||Ie>=we.length)return;const[Ne,Me]=[we[Ie],we[he]];we[he]=Ne,we[Ie]=Me,f(we)},e[0]=f,e[1]=s,e[2]=A):A=e[2];const T=A;let R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("p",{children:"Cut the selected footage to the music. You review the draft before anything changes."}),e[3]=R):R=e[3];let E;e[4]!==p||e[5]!==a||e[6]!==r||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=ie=>{ie.preventDefault(),n&&u({track_id:n,start_frame:Math.round(Number(m||i/r)*r),end_frame:Math.round(Number(p||a/r)*r),sources:s.map(H1),interval:h,unit:x,minimum_shot_frames:Math.max(1,Math.round(Number(v)*r)),preserve_existing:w,preserve_clip_ids:[],reuse_sources:M,allow_retiming:$,strategy:"beat_interval"})},e[4]=p,e[5]=a,e[6]=r,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]=E):E=e[18];const F=i/r;let I;e[19]!==F?(I=F.toFixed(2),e[19]=F,e[20]=I):I=e[20];let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=ie=>b(ie.target.value),e[21]=D):D=e[21];let L;e[22]!==m||e[23]!==I?(L=t.jsxs("label",{children:["From (s)",t.jsx("input",{"aria-label":"Draft start seconds",type:"number",min:"0",step:"any",placeholder:I,value:m,onChange:D})]}),e[22]=m,e[23]=I,e[24]=L):L=e[24];const _=a/r;let z;e[25]!==_?(z=_.toFixed(2),e[25]=_,e[26]=z):z=e[26];let O;e[27]===Symbol.for("react.memo_cache_sentinel")?(O=ie=>g(ie.target.value),e[27]=O):O=e[27];let U;e[28]!==p||e[29]!==z?(U=t.jsxs("label",{children:["To (s)",t.jsx("input",{"aria-label":"Draft end seconds",type:"number",min:"0",step:"any",placeholder:z,value:p,onChange:O})]}),e[28]=p,e[29]=z,e[30]=U):U=e[30];let q,H;e[31]===Symbol.for("react.memo_cache_sentinel")?(q=ie=>j(Number(ie.target.value)),H=[1,2,4,8].map(U1),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,ae;e[35]===Symbol.for("react.memo_cache_sentinel")?(se=ie=>y(ie.target.value),ae=t.jsx("option",{value:"beats",children:"beats"}),e[35]=se,e[36]=ae):(se=e[35],ae=e[36]);const V=!o;let oe;e[37]!==V?(oe=t.jsx("option",{value:"bars",disabled:V,children:"bars"}),e[37]=V,e[38]=oe):oe=e[38];let W;e[39]!==oe||e[40]!==x?(W=t.jsxs("select",{"aria-label":"Draft interval unit",value:x,onChange:se,children:[ae,oe]}),e[39]=oe,e[40]=x,e[41]=W):W=e[41];let te;e[42]===Symbol.for("react.memo_cache_sentinel")?(te=ie=>k(ie.target.value),e[42]=te):te=e[42];let le;e[43]!==v?(le=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]=le):le=e[44];let Y;e[45]===Symbol.for("react.memo_cache_sentinel")?(Y=ie=>S(ie.target.checked),e[45]=Y):Y=e[45];let ee;e[46]!==w?(ee=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:w,onChange:Y}),"Keep existing clips"]}),e[46]=w,e[47]=ee):ee=e[47];let J;e[48]===Symbol.for("react.memo_cache_sentinel")?(J=ie=>N(ie.target.checked),e[48]=J):J=e[48];let re;e[49]!==M?(re=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:M,onChange:J}),"Allow repeated footage"]}),e[49]=M,e[50]=re):re=e[50];let Q;e[51]===Symbol.for("react.memo_cache_sentinel")?(Q=ie=>P(ie.target.checked),e[51]=Q):Q=e[51];let Z;e[52]!==$?(Z=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:$,onChange:Q}),"Allow speed changes"]}),e[52]=$,e[53]=Z):Z=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 me;e[56]!==U||e[57]!==K||e[58]!==W||e[59]!==le||e[60]!==ee||e[61]!==re||e[62]!==Z||e[63]!==fe||e[64]!==L?(me=t.jsxs("div",{className:"music-rhythm-row",children:[L,U,K,W,le,ee,re,Z,fe]}),e[56]=U,e[57]=K,e[58]=W,e[59]=le,e[60]=ee,e[61]=re,e[62]=Z,e[63]=fe,e[64]=L,e[65]=me):me=e[65];let pe;if(e[66]!==c||e[67]!==T||e[68]!==s){let ie;e[70]!==c||e[71]!==T||e[72]!==s.length?(ie=(he,ke)=>t.jsxs("li",{children:[t.jsx("b",{children:ke+1}),t.jsx("span",{children:he.label}),t.jsx("button",{type:"button","aria-label":`Move ${he.label} earlier`,disabled:c||ke===0,onClick:()=>T(ke,-1),children:"↑"}),t.jsx("button",{type:"button","aria-label":`Move ${he.label} later`,disabled:c||ke===s.length-1,onClick:()=>T(ke,1),children:"↓"})]},he.artifactId),e[70]=c,e[71]=T,e[72]=s.length,e[73]=ie):ie=e[73],pe=s.map(ie),e[66]=c,e[67]=T,e[68]=s,e[69]=pe}else pe=e[69];let ue;e[74]!==pe?(ue=t.jsx("ol",{className:"music-draft-order","aria-label":"Draft source order",children:pe}),e[74]=pe,e[75]=ue):ue=e[75];let be;e[76]!==s.length?(be=!s.length&&t.jsx("p",{children:"Select footage in Media, in the order you want it to appear."}),e[76]=s.length,e[77]=be):be=e[77];let ye;e[78]!==E||e[79]!==me||e[80]!==ue||e[81]!==be?(ye=t.jsxs("form",{onSubmit:E,children:[me,ue,be]}),e[78]=E,e[79]=me,e[80]=ue,e[81]=be,e[82]=ye):ye=e[82];let ce;e[83]!==d||e[84]!==r||e[85]!==s?(ce=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(B1),d.uncovered.map(ie=>t.jsxs("p",{children:["Uncovered: ",(ie.startFrame/r).toFixed(2),"–",(ie.endFrame/r).toFixed(2),"s"]},ie.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((ie,he)=>t.jsxs("tr",{children:[t.jsxs("td",{children:[he+1," · ",s.find(ke=>ke.artifactId===ie.artifactId)?.label??"Source"]}),t.jsxs("td",{children:[(ie.startFrame/r).toFixed(2),"–",(ie.endFrame/r).toFixed(2),"s"]}),t.jsxs("td",{children:[ie.sourceStartSeconds.toFixed(2),"–",ie.sourceEndSeconds.toFixed(2),"s"]}),t.jsxs("td",{children:[ie.speed.toFixed(2),"×"]})]},ie.clipId))})]})]}),e[83]=d,e[84]=r,e[85]=s,e[86]=ce):ce=e[86];let G;return e[87]!==ye||e[88]!==ce?(G=t.jsxs("section",{className:"music-draft-controls","aria-label":"Auto-cut to music",children:[R,ye,ce]}),e[87]=ye,e[88]=ce,e[89]=G):G=e[89],G}function B1(l){return t.jsx("p",{children:l},l)}function U1(l){return t.jsx("option",{value:l,children:l},l)}function H1(l){return{artifact_id:l.artifactId}}function K1(l){return l.artifactId}function Zl(l){const e=X.c(13),{label:s,options:n,value:i,disabled:a,stretch:r,onChange:o}=l,c=a===void 0?!1:a,u=(r===void 0?!1:r)?"mv-segmented stretch":"mv-segmented";let f;if(e[0]!==c||e[1]!==o||e[2]!==n||e[3]!==i){let b;e[5]!==c||e[6]!==o||e[7]!==i?(b=p=>t.jsx("button",{type:"button","aria-pressed":p.value===i,title:p.title,disabled:c||p.disabled,onClick:()=>{p.value!==i&&o(p.value)},children:p.label},p.value),e[5]=c,e[6]=o,e[7]=i,e[8]=b):b=e[8],f=n.map(b),e[0]=c,e[1]=o,e[2]=n,e[3]=i,e[4]=f}else f=e[4];let m;return e[9]!==s||e[10]!==u||e[11]!==f?(m=t.jsx("div",{className:u,role:"group","aria-label":s,children:f}),e[9]=s,e[10]=u,e[11]=f,e[12]=m):m=e[12],m}function ei(l){const e=X.c(26),{label:s,frame:n,fps:i,min:a,max:r,disabled:o,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,f]=C.useState(d),[m,b]=C.useState(!1);let p;e[3]!==i||e[4]!==n||e[5]!==r||e[6]!==a||e[7]!==c||e[8]!==u?(p=()=>{const w=zo(u,i);if(w===null){b(!0);return}const S=Math.max(a,Math.min(r,w));b(!1),f(bs(S,i)),S!==n&&c(S)},e[3]=i,e[4]=n,e[5]=r,e[6]=a,e[7]=c,e[8]=u,e[9]=p):p=e[9];const g=p;let h;e[10]!==g||e[11]!==i||e[12]!==n?(h=w=>{w.key==="Enter"&&g(),w.key==="Escape"&&(w.stopPropagation(),f(bs(n,i)),b(!1))},e[10]=g,e[11]=i,e[12]=n,e[13]=h):h=e[13];const j=h;let x;e[14]!==s?(x=t.jsx("span",{children:s}),e[14]=s,e[15]=x):x=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=w=>f(w.target.value),e[16]=y):y=e[16];let v;e[17]!==g||e[18]!==o||e[19]!==m||e[20]!==j||e[21]!==u?(v=t.jsx("input",{value:u,disabled:o,"aria-invalid":m,spellCheck:!1,onChange:y,onBlur:g,onKeyDown:j}),e[17]=g,e[18]=o,e[19]=m,e[20]=j,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 Af(l){const e=X.c(49),{frame:s,durationFrames:n,fps:i,previousBeat:a,nextBeat:r,onTogglePlay:o,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 f;e[5]!==n||e[6]!==i?(f=bs(n,i),e[5]=n,e[6]=i,e[7]=f):f=e[7];let m;e[8]!==u||e[9]!==f?(m=t.jsxs("span",{className:"mv-timecode",children:[u," / ",f]}),e[8]=u,e[9]=f,e[10]=m):m=e[10];let b;e[11]!==c?(b=()=>c(0),e[11]=c,e[12]=b):b=e[12];let p;e[13]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(dc,{size:17}),e[13]=p):p=e[13];let g;e[14]!==b?(g=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Go to start",onClick:b,children:p}),e[14]=b,e[15]=g):g=e[15];const h=a===null;let j;e[16]!==c||e[17]!==a?(j=()=>{a!==null&&c(a)},e[16]=c,e[17]=a,e[18]=j):j=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(tn,{size:18}),e[19]=x):x=e[19];let y;e[20]!==h||e[21]!==j?(y=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Previous beat",title:"Previous beat",disabled:h,onClick:j,children:x}),e[20]=h,e[21]=j,e[22]=y):y=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(As,{size:17}),e[23]=v):v=e[23];let k;e[24]!==o?(k=t.jsx("button",{type:"button",className:"mv-play","aria-label":"Play or pause",title:"Play or pause (Space)",onClick:o,children:v}),e[24]=o,e[25]=k):k=e[25];const w=r===null;let S;e[26]!==r||e[27]!==c?(S=()=>{r!==null&&c(r)},e[26]=r,e[27]=c,e[28]=S):S=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(Bn,{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(uc,{size:17}),e[36]=P):P=e[36];let A;e[37]!==$?(A=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Go to end",onClick:$,children:P}),e[37]=$,e[38]=A):A=e[38];let T;e[39]!==y||e[40]!==k||e[41]!==N||e[42]!==A||e[43]!==g?(T=t.jsxs("div",{className:"mv-transport-buttons",children:[g,y,k,N,A]}),e[39]=y,e[40]=k,e[41]=N,e[42]=A,e[43]=g,e[44]=T):T=e[44];let R;e[45]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("span",{className:"mv-transport-spacer"}),e[45]=R):R=e[45];let E;return e[46]!==T||e[47]!==m?(E=t.jsxs("div",{className:"mv-transport",role:"toolbar","aria-label":"Transport",children:[m,T,R]}),e[46]=T,e[47]=m,e[48]=E):E=e[48],E}const V1=[{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 Df(l){const e=X.c(92),{clip:s,fps:n,trimStart:i,trimEnd:a,busy:r,editsDisabled:o}=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,f=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 p;e[7]!==l.count||e[8]!==l.index||e[9]!==b?(p=t.jsxs("small",{children:["Clip ",u," of ",f," · ",b]}),e[7]=l.count,e[8]=l.index,e[9]=b,e[10]=p):p=e[10];let g;e[11]!==d||e[12]!==p?(g=t.jsxs("div",{children:[d,p]}),e[11]=d,e[12]=p,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 j=`in-${s.clipId}-${i}`,x=a-1;let y;e[17]!==l||e[18]!==a?(y=ee=>l.onTrim("start",ee,a),e[17]=l,e[18]=a,e[19]=y):y=e[19];let v;e[20]!==r||e[21]!==n||e[22]!==l.trimMin||e[23]!==x||e[24]!==y||e[25]!==j||e[26]!==i?(v=t.jsx(ei,{label:"In point",frame:i,fps:n,min:l.trimMin,max:x,disabled:r,onCommit:y},j),e[20]=r,e[21]=n,e[22]=l.trimMin,e[23]=x,e[24]=y,e[25]=j,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=ee=>l.onTrim("end",i,ee),e[28]=l,e[29]=i,e[30]=S):S=e[30];let M;e[31]!==r||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:r,onCommit:S},k),e[31]=r,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 A=r||!l.retimable;let T;e[44]!==l.onSpeed||e[45]!==l.speed||e[46]!==l.speedOptions||e[47]!==A?(T=t.jsxs("div",{className:"mv-control",children:[P,t.jsx(Zl,{label:"Clip speed",options:l.speedOptions,value:l.speed,disabled:A,stretch:!0,onChange:l.onSpeed})]}),e[44]=l.onSpeed,e[45]=l.speed,e[46]=l.speedOptions,e[47]=A,e[48]=T):T=e[48];let R;e[49]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("span",{children:"Frame"}),e[49]=R):R=e[49];const E=s.transform?.fit??"fit";let F;e[50]!==o||e[51]!==l.onFit||e[52]!==E?(F=t.jsxs("div",{className:"mv-control",children:[R,t.jsx(Zl,{label:"Clip frame fit",options:V1,value:E,disabled:o,stretch:!0,onChange:l.onFit})]}),e[50]=o,e[51]=l.onFit,e[52]=E,e[53]=F):F=e[53];let I;e[54]!==N||e[55]!==T||e[56]!==F?(I=t.jsxs("div",{className:"mv-clip-body",children:[N,$,T,F]}),e[54]=N,e[55]=T,e[56]=F,e[57]=I):I=e[57];let D;e[58]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(Kn,{size:15}),e[58]=D):D=e[58];let L;e[59]!==r||e[60]!==l.onSplit?(L=t.jsxs("button",{type:"button",disabled:r,onClick:l.onSplit,children:[D," Split at playhead"]}),e[59]=r,e[60]=l.onSplit,e[61]=L):L=e[61];const _=o||!l.canStretch;let z;e[62]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(Pi,{size:15}),e[62]=z):z=e[62];let O;e[63]!==l.onStretch||e[64]!==_?(O=t.jsxs("button",{type:"button",disabled:_,title:"Extend to the next clip or the end",onClick:l.onStretch,children:[z," Fill to next"]}),e[63]=l.onStretch,e[64]=_,e[65]=O):O=e[65];const U=o||!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(tn,{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=o||!l.canMoveLater;let ae;e[72]!==l?(ae=()=>l.onMove(1),e[72]=l,e[73]=ae):ae=e[73];let V;e[74]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(Bn,{size:15}),e[74]=V):V=e[74];let oe;e[75]!==se||e[76]!==ae?(oe=t.jsxs("button",{type:"button","aria-label":"Move later",disabled:se,onClick:ae,children:["Later ",V]}),e[75]=se,e[76]=ae,e[77]=oe):oe=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]!==o||e[80]!==l.onDelete?(te=t.jsxs("button",{type:"button",className:"danger-button wide",disabled:o,onClick:l.onDelete,children:[W," Delete clip"]}),e[79]=o,e[80]=l.onDelete,e[81]=te):te=e[81];let le;e[82]!==L||e[83]!==O||e[84]!==K||e[85]!==oe||e[86]!==te?(le=t.jsxs("footer",{className:"mv-clip-actions",children:[L,O,K,oe,te]}),e[82]=L,e[83]=O,e[84]=K,e[85]=oe,e[86]=te,e[87]=le):le=e[87];let Y;return e[88]!==I||e[89]!==le||e[90]!==h?(Y=t.jsxs("div",{className:"mv-clip-inspector",children:[h,I,le]}),e[88]=I,e[89]=le,e[90]=h,e[91]=Y):Y=e[91],Y}export{If as $,xs as A,ut as B,Li as C,lf as D,Ll as E,hf as F,rf as G,Yl as H,of as I,ef as J,gf as K,kf as L,id as M,rd as N,Sf as O,kc as P,Vm as Q,Xn as R,Zl as S,Qm as T,qm as U,Hc as V,Wm as W,Gm as X,Zm as Y,sf as Z,Rf as _,cf as a,nf as a0,vf as a1,wf as a2,xf as a3,jf as a4,yf as a5,tf as a6,ed as b,yd as c,uf as d,mf as e,df as f,pf as g,ld as h,Ui as i,ff as j,af as k,bf as l,Cf as m,$f as n,Xm as o,Ym as p,Jm as q,Rc as r,Mf as s,Pf as t,Od as u,nm as v,Af as w,Df as x,S1 as y,Nf as z};