videobook 0.3.0 → 0.3.2
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.
- package/CHANGELOG.md +135 -0
- package/dist/asset-media-projection.js +161 -0
- package/dist/command-reference.js +3 -1
- package/dist/diagnostics.js +10 -4
- package/dist/generation-reference-mentions.js +19 -0
- package/dist/goal-plan-v3.js +21 -6
- package/dist/goal-plan.js +1 -1
- package/dist/goal-store.js +2 -2
- package/dist/har-capture.js +36 -3
- package/dist/jobs/_image-edit-adapter.js +2 -0
- package/dist/jobs/_kie-upload.js +3 -1
- package/dist/jobs/assess-media-probes.js +94 -0
- package/dist/jobs/complete-provider-task.js +2 -5
- package/dist/jobs/generate-media.js +22 -12
- package/dist/jobs/image-subjects.js +2 -0
- package/dist/jobs/kie-paygate.js +3 -3
- package/dist/jobs/register-all.js +2 -0
- package/dist/jobs/run-notebook.js +16 -1
- package/dist/library-asset-projection.js +141 -0
- package/dist/lightning-defaults.js +4 -4
- package/dist/media/catalog.js +12 -6
- package/dist/media/descriptor.js +16 -7
- package/dist/media/frontier-gaps.js +0 -1
- package/dist/media/har-endpoint.js +25 -0
- package/dist/media/json-schema.js +3 -0
- package/dist/media/listing.js +26 -4
- package/dist/media/preferred-defaults.js +161 -0
- package/dist/media/prompt-dialects.js +9 -1
- package/dist/media-library.js +158 -153
- package/dist/notebook-sticky-settings.js +60 -0
- package/dist/provider-usage.js +24 -9
- package/dist/tools/estimate-cost.js +9 -4
- package/dist/tools/reconcile-project-work.js +37 -184
- package/dist/tools/videobook-domain.js +16 -1
- package/dist/usage-providers.js +3 -3
- package/package.json +15 -15
- package/ui/assets/{alive-captions-Cj8C1tCN.js → alive-captions-BWk_4aX0.js} +1 -1
- package/ui/assets/confirm-bodies-CNW9vLsi.js +1 -0
- package/ui/assets/{fullscreen-DyEncSdm.js → fullscreen-ND_H86Ih.js} +1 -1
- package/ui/assets/{goal-ui-BdFeoSWh.js → goal-ui-CCTD4lxi.js} +1 -1
- package/ui/assets/index-CTPstLYq.css +1 -0
- package/ui/assets/index-D0ftggO4.js +37 -0
- package/ui/assets/inspector-BZnbKsEZ.js +1 -0
- package/ui/assets/{jobs-ui-BudI4w0r.js → jobs-ui-BNK0IPSl.js} +1 -1
- package/ui/assets/{music-video-CT4C55ok.js → music-video-CoOI0cgW.js} +1 -1
- package/ui/assets/{ui-mq0uIS5P.css → ui-BBM3YCY6.css} +1 -1
- package/ui/assets/ui-koLWlu0t.js +2 -0
- package/ui/assets/vendor-Ca2-b3hB.js +19 -0
- package/ui/assets/{vendor-flow-nqTFQmTh.js → vendor-flow-C2NYBYCL.js} +1 -1
- package/ui/assets/vendor-icons-D3KrGMJY.js +1 -0
- package/ui/assets/{vendor-mcp-D_C3EZPv.js → vendor-mcp-9gUvOX4H.js} +2 -2
- package/ui/assets/videobook-B8dYNQrG.js +21 -0
- package/ui/index.html +14 -14
- package/ui/assets/confirm-bodies-BxWXwDf0.js +0 -1
- package/ui/assets/index-DWfR79lA.css +0 -1
- package/ui/assets/index-QZ8lbemN.js +0 -37
- package/ui/assets/inspector-BC6xWkJU.js +0 -1
- package/ui/assets/ui-z5r-p0K9.js +0 -2
- package/ui/assets/vendor-D8XcMav4.js +0 -19
- package/ui/assets/vendor-icons-CGqhCIXV.js +0 -1
- package/ui/assets/videobook-CsW453sb.js +0 -21
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as C,j as t,c as W,d as pa,b as gs}from"./vendor-react-Dj7D1fD4.js";import{b as Wt,E as us,F as al,G as ha,H as rl,I as ba,J as ol,K as xa,L as ga,n as ti,O as ya,P as ja,Q as ms,R as cl,U as va,V as ka}from"./vendor-Ca2-b3hB.js";import{x as Sa,p as wa,u as Na,a as Ca,i as $a,b as Ia,P as pn,c as Ra,m as hn,d as dl,h as Rn,e as Ma,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 Pa,w as Aa,y as Da,z as Ta,A as Ea,B as Fa,C as Xt,D as _a,E as La,F as za,G as Oa,H as Ba,I as Ua,J as hl,K as Ha,L as Ka,M as Va,N as bl,O as bn,Q as qa,R as Wa,S as Ga,T as xn,U as Xa,V as Ya,W as Ja,X as Qa,Y as xl,Z as Za,_ as er,$ as tr,a0 as sr,a1 as nr,a2 as lr,a3 as ir,a4 as ar,a5 as rr,a6 as Mn,a7 as or,a8 as He,a9 as On,aa as Hs,ab as cr,ac as dr,ad as Kt,ae as ri,af as ur,ag as mr,ah as fr,ai as pr,aj as hr,ak as br,al as oi,am as xr,an as gr,ao as yr,ap as jr,aq as ci,ar as vr,as as kr,at as di,au as Sr,av as wr,aw as Nr,ax as Cr,ay as $r,az as Ir,aA as Rr,aB as Mr,aC as Pr,aD as Ar,aE as ui,aF as gl,aG as Dr,aH as Tr,aI as yl,aJ as Er,aK as Fr,aL as _r,aM as Lr,aN as zr,aO as Or,aP as jl,aQ as Br,aR as Ur,aS as Hr,aT as Kr,aU as gn,aV as vl,aW as fs,aX as Vr,aY as qr,aZ as $s,a_ as yn,a$ as mi,b0 as fi,b1 as Wr,b2 as pi,b3 as Gr,b4 as Xr,b5 as Yr,b6 as Jr,b7 as Qr,b8 as hi,b9 as Zr,ba as eo,bb as as,bc as Pn,bd as Ss,be as bi,bf as to,bg as so,bh as no,bi as xi,bj as lo,bk as io,bl as ao,bm as gi,bn as ro,bo as oo,bp as co,bq as yi,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 ji,bH as Sl,bI as ps,bJ as No,bK as Co,bL as vi,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 Ks,b_ as Cl,b$ as Lo,c0 as bs,c1 as zo}from"./videobook-B8dYNQrG.js";import{X as mt,A as Oo,a as ss,F as St,I as Zt,B as Ms,b as Bn,V as Bo,L as ki,C as Is,M as Si,c as Qt,T as $l,W as wi,d as Uo,S as Ho,e as en,E as Ko,D as Ps,R as Un,f as rs,g as tn,h as As,H as Hn,P as Vo,i as Ni,j as qo,k as Ci,l as $i,m as es,n as Kn,o as Wo,p as Ii,N as Go,q as Xo,U as Yo,r as Ri,s as Jo,t as Mi,u as Qo,v as Zo,w as Vn,x as Pi,Z as ec,y as sn,z as nn,G as Il,J as Ns,K as tc,O as Rl,Q as jn,Y as qn,_ as Ds,$ as Ai,a0 as sc,a1 as Rs,a2 as nc,a3 as os,a4 as lc,a5 as ic,a6 as Di,a7 as Ti,a8 as Ei,a9 as Fi,aa as ac,ab as _i,ac as rc,ad as oc,ae as An,af as cc,ag as dc}from"./vendor-icons-D3KrGMJY.js";import{u as uc,B as mc,V as Li,P as Cs,a as fc,H as vn}from"./vendor-flow-C2NYBYCL.js";import{S as Dn,u as pc,i as Ml,I as hc,A as Wn,V as bc,b as xc,P as gc}from"./vendor-remotion-CH1HXrlc.js";const yc={tiktok:"https://www.tiktok.com/@account/video/…",instagram:"https://www.instagram.com/reel/…",youtube:"https://youtube.com/shorts/…",x:"https://x.com/account/status/…",other:"https://…"};function jc(l){return l instanceof Error?l.message:String(l)}function vc({post:l,disabled:e,className:s,onLink:n}){const[i,a]=C.useState(""),[r,o]=C.useState(()=>Sa(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(jc(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:wa(l)}),t.jsx("label",{htmlFor:`${g}-url`,children:"Post URL"}),t.jsx("input",{id:`${g}-url`,type:"url",value:i,disabled:m,spellCheck:!1,placeholder:yc[l.definition.platform],onChange:h=>a(h.target.value),onKeyDown: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 uf(l){const e=W.c(186),{post:s,cells:n,asset:i,bookId:a,call:r,onRefresh:o,onSelectCell:c,onDeliver:d,onReviewX:u,onDelete:f}=l,m=Na(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,y=p.caption??s.definition.caption,x=p.credits??s.definition.credits,j=p.account??s.definition.account,v=p.notes??s.definition.notes,[k,w]=C.useState(""),[S,R]=C.useState(Pl);let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N={},e[1]=N):N=e[1];const[M,A]=C.useState(N),[D,T]=C.useState(null);Ca(!!s.runtime.icloud?.completedAt,r,a,s.id,T);const I=D?.phase??null,E=D?.error;let F;e[2]!==I||e[3]!==E?(F=$a(I,E),e[2]=I,e[3]=E,e[4]=F):F=e[4];const $=F,P=!!(s.runtime.outbound||s.runtime.url||s.runtime.status==="scheduled");let L,_,z,O,U,q,H,K,te,ae,V,oe,G,se;if(e[5]!==j||e[6]!==m||e[7]!==i||e[8]!==a||e[9]!==r||e[10]!==y||e[11]!==n||e[12]!==x||e[13]!==p||e[14]!==$||e[15]!==P||e[16]!==M||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 Q;e[40]!==s.definition.source?.cellId?(Q=ve=>ve.id===s.definition.source?.cellId,e[40]=s.definition.source?.cellId,e[41]=Q):Q=e[41];const de=n.find(Q),fe=s.runtime.metrics.at(-1),ue=h!==s.definition.platform||y!==s.definition.caption||x!==s.definition.credits||j!==s.definition.account;let pe;e[42]!==m||e[43]!==s.id?(pe=(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 me=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 X;e[52]!==s.address?(X=t.jsxs("h2",{children:[s.address," · Post"]}),e[52]=s.address,e[53]=X):X=e[53];let ie;e[54]!==ce||e[55]!==X?(ie=t.jsxs("div",{children:[ce,X]}),e[54]=ce,e[55]=X,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 $e;e[59]!==he||e[60]!==ke?($e=t.jsx("span",{className:he,children:ke}),e[59]=he,e[60]=ke,e[61]=$e):$e=e[61],e[62]!==ie||e[63]!==$e?(G=t.jsxs("div",{className:"post-heading",children:[ie,$e]}),e[62]=ie,e[63]=$e,e[64]=G):G=e[64],e[65]!==i?(se=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]=se):se=e[66];const De=de?t.jsxs("button",{type:"button",onClick:()=>c(de.id),children:["Source ",Wt(de.slot)," · ",de.label??de.type]}):s.definition.source?t.jsx("span",{children:"Source cell no longer on this canvas"}):t.jsx("span",{children:"Choose the finished clip this publication will represent."});let Ie;e[67]!==s.definition.createdAt||e[68]!==s.definition.source?(Ie=s.definition.source&&t.jsx("small",{children:s.definition.source.revision?`Clip version saved ${new Date(s.definition.createdAt).toLocaleString()}`:"Historical media version unknown"}),e[67]=s.definition.createdAt,e[68]=s.definition.source,e[69]=Ie):Ie=e[69],e[70]!==De||e[71]!==Ie?(L=t.jsxs("div",{className:"post-source",children:[De,Ie]}),e[70]=De,e[71]=Ie,e[72]=L):L=e[72],e[73]!==m.busy||e[74]!==n||e[75]!==s.definition.source||e[76]!==me||e[77]!==k?(_=!s.definition.source&&t.jsxs("form",{onSubmit:ve=>{ve.preventDefault(),me("update_post",{source_cell_id:k})},children:[t.jsxs("label",{children:["Source clip",t.jsxs("select",{"aria-label":"Source clip",value:k,onChange:ve=>w(ve.target.value),required:!0,children:[t.jsx("option",{value:"",children:"Choose a finished image or video"}),n.filter($c).map(Cc)]})]}),t.jsx("button",{disabled:m.busy||!k,children:"Save source version"})]}),e[73]=m.busy,e[74]=n,e[75]=s.definition.source,e[76]=me,e[77]=k,e[78]=_):_=e[78];let Te;e[79]!==j||e[80]!==y||e[81]!==x||e[82]!==P||e[83]!==v||e[84]!==h||e[85]!==me?(Te=ve=>{ve.preventDefault(),me("update_post",P?{notes:v}:{platform:h,caption:y,credits:x,account:j,notes:v}).then(Qe=>{Qe&&g({})})},e[79]=j,e[80]=y,e[81]=x,e[82]=P,e[83]=v,e[84]=h,e[85]=me,e[86]=Te):Te=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=Ra.map(Nc),e[89]=et):et=e[89];let Ye;e[90]!==P||e[91]!==h||e[92]!==Fe?(Ye=t.jsxs("label",{children:["Platform",t.jsx("select",{"aria-label":"Platform",disabled:P,value:h,onChange:Fe,children:et})]}),e[90]=P,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]!==j||e[97]!==P||e[98]!==Ke?(Ve=t.jsxs("label",{children:["Account",t.jsx("input",{value:j,disabled:P,placeholder:"@account",onChange:Ke})]}),e[96]=j,e[97]=P,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 Ae;e[103]!==p?(Ae=ve=>g({...p,caption:ve.target.value}),e[103]=p,e[104]=Ae):Ae=e[104];let We;e[105]!==y||e[106]!==P||e[107]!==Ae?(We=t.jsxs("label",{children:["Caption",t.jsx("textarea",{value:y,disabled:P,rows:4,onChange:Ae,placeholder:"What will this post say?"})]}),e[105]=y,e[106]=P,e[107]=Ae,e[108]=We):We=e[108];let Ge;e[109]!==p?(Ge=ve=>g({...p,credits:ve.target.value}),e[109]=p,e[110]=Ge):Ge=e[110];let Je;e[111]!==x||e[112]!==P||e[113]!==Ge?(Je=t.jsxs("label",{children:["Credits",t.jsx("textarea",{value:x,disabled:P,rows:2,onChange:Ge,placeholder:"Creator and source credits"})]}),e[111]=x,e[112]=P,e[113]=Ge,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 Ce;e[117]!==v||e[118]!==tt?(Ce=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]=Ce):Ce=e[119];const Ee=m.busy||!r,qe=P?"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]!==Te||e[124]!==lt||e[125]!==We||e[126]!==Je||e[127]!==Ce||e[128]!==_e?(z=t.jsxs("form",{onSubmit:Te,children:[lt,We,Je,Ce,_e]}),e[123]=Te,e[124]=lt,e[125]=We,e[126]=Je,e[127]=Ce,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]!==y||e[136]!==ue||e[137]!==d||e[138]!==u||e[139]!==s||e[140]!==me?(q=!s.runtime.url&&t.jsxs("div",{className:"post-delivery",children:[t.jsx("h3",{children:"Deliver"}),t.jsx("p",{children:"Review the clip and caption, then save them where you will publish."}),t.jsx("button",{type:"button","aria-pressed":s.definition.delivery==="icloud",onClick:()=>d("icloud"),children:"Save to iPhone"}),t.jsx("button",{type:"button","aria-pressed":s.definition.delivery==="dropbox",onClick:()=>d("dropbox"),children:"Upload to Dropbox"}),s.definition.platform==="x"&&!s.runtime.xRequest&&!["scheduled","needs_reconciliation","posting"].includes(s.runtime.status)&&t.jsx("button",{type:"button",disabled:m.busy||!s.definition.source?.snapshotArtifactId||!y.trim()||ue,onClick:()=>{u(s)},children:"Review X post…"}),s.definition.platform==="x"&&s.runtime.xRequest&&s.runtime.status==="failed"&&t.jsx("button",{type:"button",disabled:m.busy,onClick:()=>{me("post")},children:"Retry saved X post"}),ue&&t.jsx("small",{children:"Save your draft before delivering."}),s.runtime.scheduledFor&&t.jsxs("p",{children:["Scheduled for ",new Date(s.runtime.scheduledFor).toLocaleString()]})]}),e[134]=m.busy,e[135]=y,e[136]=ue,e[137]=d,e[138]=u,e[139]=s,e[140]=me,e[141]=q):q=e[141],e[142]!==$||e[143]!==s.runtime.icloud?(H=s.runtime.icloud?.completedAt&&t.jsxs("div",{className:"post-receipt",children:[t.jsx("strong",{children:Ia(s.runtime.icloud.folder)}),$&&t.jsx("small",{children:$})]}),e[142]=$,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]!==ue||e[150]!==ye||e[151]!==s?(te=s.runtime.url?t.jsxs("div",{className:"post-receipt",children:[t.jsx("a",{href:s.runtime.url,target:"_blank",rel:"noreferrer",children:"Open published post ↗"}),t.jsx("span",{children:s.runtime.postedAt?new Date(s.runtime.postedAt).toLocaleString():"Publication time unknown"}),s.runtime.x?.replies.map(wc)]}):t.jsx(vc,{post:s,disabled:m.busy||!r||ue,className:"post-delivery post-link-field",onLink:ye}),e[147]=m.busy,e[148]=r,e[149]=ue,e[150]=ye,e[151]=s,e[152]=te):te=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:pn.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:()=>{me("refresh_post_metrics")},children:"Refresh now"}),t.jsx("small",{children:s.runtime.nextMetricAt?`Next check ${new Date(s.runtime.nextMetricAt).toLocaleString()}`:s.runtime.metricsPaused?"Automatic checks paused; reconnect X and refresh.":"Scheduled observations complete."}),s.runtime.metricsError&&t.jsx("p",{className:"post-error",children:s.runtime.metricsError})]}),t.jsxs("details",{onToggle:ve=>{ve.currentTarget.open&&R(Pl())},children:[t.jsx("summary",{children:"Add manual observation"}),t.jsxs("form",{onSubmit:ve=>{ve.preventDefault();const Qe={};for(const nt of pn)M[nt]?.trim()&&(Qe[nt]=Number(M[nt]));me("record_post_metrics",{observed_at:new Date(S).toISOString(),values:Qe})},children:[t.jsxs("label",{children:["Observed at",t.jsx("input",{type:"datetime-local",step:"0.001",required:!0,value:S,onChange:ve=>R(ve.target.value)})]}),t.jsx("div",{className:"post-metric-inputs",children:pn.map(ve=>t.jsxs("label",{children:[ve,t.jsx("input",{type:"number",min:"0",step:"1",placeholder:"Unknown",value:M[ve]??"",onChange:Qe=>A({...M,[ve]:Qe.target.value})})]},ve))}),t.jsx("button",{disabled:m.busy||!Object.values(M).some(Boolean),children:"Save observation"})]})]}),s.runtime.metrics.length>0&&t.jsxs("details",{children:[t.jsxs("summary",{children:["Observation history (",s.runtime.metrics.length,")"]}),t.jsx("div",{className:"post-history",children:[...s.runtime.metrics].reverse().map(kc)})]})]}),e[5]=j,e[6]=m,e[7]=i,e[8]=a,e[9]=r,e[10]=y,e[11]=n,e[12]=x,e[13]=p,e[14]=$,e[15]=P,e[16]=M,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]=te,e[35]=ae,e[36]=V,e[37]=oe,e[38]=G,e[39]=se}else L=e[26],_=e[27],z=e[28],O=e[29],U=e[30],q=e[31],H=e[32],K=e[33],te=e[34],ae=e[35],V=e[36],oe=e[37],G=e[38],se=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 Q;e[159]!==n||e[160]!==c?(Q=de=>{const fe=n.find(ue=>ue.id===de.cellId);return t.jsxs("div",{children:[fe?t.jsxs("button",{type:"button",onClick:()=>c(fe.id),children:[Wt(fe.slot)," · ",de.label??de.type]}):t.jsx("strong",{children:de.label??de.type}),de.prompt&&t.jsx("p",{children:de.prompt})]},de.cellId)},e[159]=n,e[160]=c,e[161]=Q):Q=e[161],Y=s.definition.lineage.map(Q),e[155]=n,e[156]=c,e[157]=s.definition.lineage,e[158]=Y}else Y=e[158];let Z;e[162]!==Y?(Z=t.jsx("div",{className:"post-lineage",children:Y}),e[162]=Y,e[163]=Z):Z=e[163];let J;e[164]!==le||e[165]!==Z?(J=t.jsxs("details",{children:[le,Z]}),e[164]=le,e[165]=Z,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 ee;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]!==te||e[178]!==ae||e[179]!==J||e[180]!==re||e[181]!==V||e[182]!==oe||e[183]!==G||e[184]!==se?(ee=t.jsxs("section",{className:V,"aria-label":oe,children:[G,se,L,_,z,O,U,q,H,K,te,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]=te,e[178]=ae,e[179]=J,e[180]=re,e[181]=V,e[182]=oe,e[183]=G,e[184]=se,e[185]=ee):ee=e[185],ee}function kc(l){return t.jsxs("p",{children:[t.jsxs("strong",{children:[new Date(l.observedAt).toLocaleString()," · ",l.source]}),t.jsx("span",{children:Object.entries(l.values).map(Sc).join(" · ")})]},l.id??`${l.observedAt}-${l.source}`)}function Sc(l){const[e,s]=l;return`${e}: ${s?.toLocaleString()??"—"}`}function wc(l){return t.jsx("a",{href:l.tweet_url,target:"_blank",rel:"noreferrer",children:"Open reply ↗"},l.tweet_id)}function Nc(l){return t.jsx("option",{value:l,children:l==="x"?"X":l},l)}function Cc(l){return t.jsxs("option",{value:l.id,children:[Wt(l.slot)," · ",l.label??l.type]},l.id)}function $c(l){return l.type!=="post"&&l.outputArtifactId&&["image","video","generate_image","generate_video","concat","splice","split_video"].includes(l.type)}const zi=C.createContext(null);function Ic(l){const e=W.c(17),{label:s,shortcut:n,divider:i}=l,a=i===void 0?!0:i,r=C.useContext(zi);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 Oi(l){const e=W.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 A=d.current?.closest(n);if(!A)return;const D=()=>{const I=parseFloat(getComputedStyle(A).maxHeight),E=c>0&&A.parentElement?A.parentElement.clientHeight-c:window.innerHeight,F=Math.max(0,Math.min(Number.isFinite(I)?I:E,E)),$={height:Math.round(A.getBoundingClientRect().height),min:Math.min(a,F),max:Math.round(F)};b(P=>P.height===$.height&&P.min===$.min&&P.max===$.max?P:$)},T=new ResizeObserver(D);return T.observe(A),A.parentElement&&T.observe(A.parentElement),D(),()=>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=A=>o(Math.round(Math.max(m.min,Math.min(m.max,A)))),e[7]=o,e[8]=m.max,e[9]=m.min,e[10]=h):h=e[10];const y=h,x=i==="top"?-1:1,j=`pane-resize-handle pane-resize-handle-${i}`,v=`${m.height} pixels`;let k;e[11]!==m.height||e[12]!==n?(k=A=>{if(A.button!==0)return;A.preventDefault(),A.currentTarget.focus({preventScroll:!0}),A.currentTarget.setPointerCapture(A.pointerId);const D=d.current?.closest(n);u.current={y:A.clientY,height:D?Math.round(D.getBoundingClientRect().height):m.height}},e[11]=m.height,e[12]=n,e[13]=k):k=e[13];let w;e[14]!==x||e[15]!==y?(w=A=>{const D=u.current;D&&y(D.height+x*(A.clientY-D.y))},e[14]=x,e[15]=y,e[16]=w):w=e[16];let S,R;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{u.current=null,A.currentTarget.hasPointerCapture(A.pointerId)&&A.currentTarget.releasePointerCapture(A.pointerId)},R=()=>{u.current=null},e[17]=S,e[18]=R):(S=e[17],R=e[18]);let N;e[19]!==x||e[20]!==y||e[21]!==m.height||e[22]!==m.max||e[23]!==m.min?(N=A=>{["ArrowUp","ArrowDown","Home","End"].includes(A.key)&&(A.preventDefault(),A.stopPropagation(),A.key==="Home"?y(m.min):A.key==="End"?y(m.max):y(m.height+x*(A.key==="ArrowUp"?-24:24)))},e[19]=x,e[20]=y,e[21]=m.height,e[22]=m.max,e[23]=m.min,e[24]=N):N=e[24];let M;return e[25]!==s||e[26]!==m.height||e[27]!==m.max||e[28]!==m.min||e[29]!==N||e[30]!==j||e[31]!==v||e[32]!==k||e[33]!==w?(M=t.jsx("div",{ref:d,className:j,role:"separator","aria-label":s,"aria-orientation":"horizontal","aria-valuemin":m.min,"aria-valuemax":m.max,"aria-valuenow":m.height,"aria-valuetext":v,tabIndex:0,"data-composer-focus":"preserve",onPointerDown:k,onPointerMove:w,onPointerUp:S,onLostPointerCapture:R,onKeyDown:N}),e[25]=s,e[26]=m.height,e[27]=m.max,e[28]=m.min,e[29]=N,e[30]=j,e[31]=v,e[32]=k,e[33]=w,e[34]=M):M=e[34],M}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=W.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 te=new ResizeObserver(K);te.observe(H);const ae=H.closest(".composer-history");return ae&&te.observe(ae),window.addEventListener("resize",K),window.addEventListener("scroll",K,!0),()=>{te.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=hn(s.tool),e[5]=s.tool,e[6]=g):g=e[6];let h;e[7]!==g?(h=t.jsx("span",{className:"composer-history-text mcp-call-name",children:g}),e[7]=g,e[8]=h):h=e[8];let y;e[9]!==s.phase?(y=s.phase==="running"&&t.jsxs("span",{className:"mcp-call-signal","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),e[9]=s.phase,e[10]=y):y=e[10];let x;e[11]!==s?(x=dl(s),e[11]=s,e[12]=x):x=e[12];let j;e[13]!==x?(j=t.jsx("span",{className:"mcp-call-state",children:x}),e[13]=x,e[14]=j):j=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Oo,{className:"mcp-call-details-icon",size:14,"aria-hidden":"true"}),e[15]=v):v=e[15];let k;e[16]!==y||e[17]!==j?(k=t.jsxs("span",{className:"mcp-call-trail",children:[y,j,v]}),e[16]=y,e[17]=j,e[18]=k):k=e[18];let w;e[19]!==s.expanded||e[20]!==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=hn(s.tool),e[24]=s.tool,e[25]=S):S=e[25];const R=`${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 M;e[27]!==s.expanded||e[28]!==s.id||e[29]!==i?(M=q=>{q.newState==="open"!==s.expanded&&i(s.id)},e[27]=s.expanded,e[28]=s.id,e[29]=i,e[30]=M):M=e[30];let A;e[31]!==s.tool?(A=hn(s.tool),e[31]=s.tool,e[32]=A):A=e[32];let D;e[33]!==A?(D=t.jsx("span",{children:A}),e[33]=A,e[34]=D):D=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 I;e[36]!==r?(I=t.jsx("button",{type:"button",popoverTarget:r,popoverTargetAction:"hide","aria-label":"Close action details",autoFocus:!0,children:T}),e[36]=r,e[37]=I):I=e[37];let E;e[38]!==D||e[39]!==I?(E=t.jsxs("header",{className:"mcp-call-popover-head",children:[D,I]}),e[38]=D,e[39]=I,e[40]=E):E=e[40];const F=s.tool;let $;e[41]!==s?($=dl(s),e[41]=s,e[42]=$):$=e[42];let P;e[43]!==s.tool||e[44]!==$?(P=t.jsxs("p",{className:"mcp-call-what",children:[F," · ",$]}),e[43]=s.tool,e[44]=$,e[45]=P):P=e[45];let L;e[46]!==s.args?(L=s.args.length>0&&t.jsx("dl",{className:"mcp-call-args",children:s.args.map(Rc)}),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]!==P||e[51]!==L||e[52]!==_?(z=t.jsxs("div",{className:"mcp-call-body",children:[P,L,_]}),e[50]=P,e[51]=L,e[52]=_,e[53]=z):z=e[53];let O;e[54]!==r||e[55]!==R||e[56]!==M||e[57]!==E||e[58]!==z?(O=t.jsxs("div",{ref:c,id:r,className:"mcp-call-popover",popover:"auto",role:"dialog","aria-label":R,onBeforeToggle:N,onToggle:M,onKeyDown:Mc,children:[E,z]}),e[54]=r,e[55]=R,e[56]=M,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 Rc(l){return t.jsxs(C.Fragment,{children:[t.jsx("dt",{children:l.name}),t.jsx("dd",{children:l.value})]},l.name)}function Mc(l){l.key==="Escape"&&l.stopPropagation()}const Bi=C.createContext(null),Tl=28;function Pc(l){const e=W.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(Bi)?.captionId??f,p=C.useRef(null),g=C.useRef(!0),h=C.useRef(void 0),[y,x]=C.useState(!1);let j;e[0]!==d||e[1]!==n||e[2]!==s||e[3]!==i?(j=!d&&Rn(n,s.length,i),e[0]=d,e[1]=n,e[2]=s,e[3]=i,e[4]=j):j=e[4];const v=j;let k;e[5]!==v||e[6]!==c||e[7]!==a||e[8]!==s?(k=()=>{const I=p.current;if(c?.(a&&!!I?.querySelector(".chat-turn-details[open]")),v||!I||!a)return;const E=s.filter(Dc).at(-1)?.sequence;E!==h.current&&(g.current=!0),h.current=E,g.current&&(I.scrollTop=I.scrollHeight);const F=I.scrollHeight-I.scrollTop-I.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",R=!a;let N;e[16]!==s.length?(N=I=>{const E=I.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 M;e[18]!==d||e[19]!==u||e[20]!==c||e[21]!==r||e[22]!==a||e[23]!==n||e[24]!==s?(M=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:Ma(n??"off")})]}):s.map(I=>t.jsx(Ec,{row:I,active:a,connected:u,onToggleCall:r,onDetailsChange:()=>c?.(!!p.current?.querySelector(".chat-turn-details[open]"))},Tc(I))),e[18]=d,e[19]=u,e[20]=c,e[21]=r,e[22]=a,e[23]=n,e[24]=s,e[25]=M):M=e[25];let A;e[26]!==b||e[27]!==d||e[28]!==R||e[29]!==N||e[30]!==M?(A=t.jsxs("div",{ref:p,id:b,className:"composer-history voice-captions","data-testid":"composer-history",hidden:R,"aria-label":"Message log",role:"log","aria-live":"off",onScroll:N,children:[M,d]}),e[26]=b,e[27]=d,e[28]=R,e[29]=N,e[30]=M,e[31]=A):A=e[31];let D;e[32]!==a||e[33]!==y?(D=a&&y&&t.jsx("button",{type:"button",className:"voice-captions-latest",onMouseDown:Ac,onClick:()=>{g.current=!0,x(!1);const I=p.current;I&&(I.scrollTop=I.scrollHeight)},children:"Latest"}),e[32]=a,e[33]=y,e[34]=D):D=e[34];let T;return e[35]!==D||e[36]!==S||e[37]!==A?(T=t.jsxs("div",{className:"composer-history-panel","data-history-open":S,children:[A,D]}),e[35]=D,e[36]=S,e[37]=A,e[38]=T):T=e[38],T}function Ac(l){return l.preventDefault()}function Dc(l){return l.kind==="caption"&&l.turn}function Tc(l){return l.kind==="status"?`status:${l.sequence}`:l.kind==="caption"?`caption:${l.caption.id}`:`call:${l.call.id}`}function Ec(l){const e=W.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,y=p.id,x=p.status;let j;e[13]!==p.text?(j=t.jsx("p",{className:"chat-bubble chat-bubble-user","aria-label":"Your message",children:p.text}),e[13]=p.text,e[14]=j):j=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 R;e[23]!==S?(R=t.jsx("span",{children:S}),e[23]=S,e[24]=R):R=e[24];let N;e[25]!==w||e[26]!==R?(N=t.jsxs("span",{className:"chat-turn-status",role:"status","aria-live":"polite",children:[w,R]}),e[25]=w,e[26]=R,e[27]=N):N=e[27];let M;e[28]!==N||e[29]!==k?(M=t.jsx("summary",{"aria-label":k,children:N}),e[28]=N,e[29]=k,e[30]=M):M=e[30];let A;e[31]!==p.work?(A=p.work.map(Fc),e[31]=p.work,e[32]=A):A=e[32];let D;e[33]!==n||e[34]!==i||e[35]!==s.calls?(D=s.calls?.map($=>t.jsx(Dl,{call:$,active:n,onToggle:i},$.id)),e[33]=n,e[34]=i,e[35]=s.calls,e[36]=D):D=e[36];let T;e[37]!==A||e[38]!==D?(T=t.jsxs("div",{className:"chat-turn-work",children:[A,D]}),e[37]=A,e[38]=D,e[39]=T):T=e[39];let I;e[40]!==r||e[41]!==M||e[42]!==T?(I=t.jsxs("details",{className:"chat-turn-details",onToggle:r,children:[M,T]}),e[40]=r,e[41]=M,e[42]=T,e[43]=I):I=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]!==I||e[47]!==E||e[48]!==j||e[49]!==p.id||e[50]!==p.status?(F=t.jsxs("article",{className:"chat-turn","data-turn-id":y,"data-status":x,children:[j,I,E]}),e[46]=I,e[47]=E,e[48]=j,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 Fc(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=W.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=W.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 _c(l){const e=W.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 Vs(l){return ni(l.state.doc,l.state.selection.anchor,l.state.selection.head)}function Fl(l){return{class:"command-rich-input",role:"combobox","aria-label":"Videobook command input","aria-autocomplete":"list","aria-expanded":String(l.expanded),"aria-disabled":String(l.disabled),"data-workspace-action-surface":"slash","data-placeholder":l.placeholder,"data-empty":String(l.value.length===0),tabindex:l.disabled?"-1":"0",spellcheck:"false",autocapitalize:"none",...l.controls?{"aria-controls":l.controls}:{},...l.activeDescendant?{"aria-activedescendant":l.activeDescendant}:{}}}function Lc({ref:l,...e}){const[s]=C.useState({value:e.value,disabled:e.disabled}),n=C.useRef(null),i=C.useRef(null),a=C.useRef(e),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?Vs(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<Vs(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:[ha(),rl({"Mod-z":xa,"Mod-Shift-z":ol,"Mod-y":ol}),rl(ga)]});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 j=String(x.attrs.token);const v=document.createElement("span");v.className="composer-reference-chip",v.contentEditable="false",v.setAttribute("role","img");const k=pa.createRoot(v),w=()=>{const S=a.current.references.get(j.toLowerCase()),R=S?li(S):"Unavailable reference",N=[j,S?.label,R].filter(Boolean).join(" · ");v.dataset.reference=j,v.setAttribute("aria-label",N),v.title=N,k.render(t.jsx(_c,{token:j,reference:S}))};return w(),d.current.add(w),{dom:v,update(S){return S.type!==x.type?!1:(j=String(S.attrs.token),w(),!0)},ignoreMutation:S=>S.type!=="selection",destroy(){d.current.delete(w),queueMicrotask(()=>k.unmount())}}},g=x=>{const j=i.current;if(!j)return;if(!j.composing&&!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=j.state;j.updateState(v.apply(x)),a.current.sessions.set(r.current,j.state);const k=Vs(j);v.doc.eq(j.state.doc)?v.selection.eq(j.state.selection)||a.current.onSelectionChange(k):a.current.onChange(is(j.state.doc),k)},h=(x,j,v)=>!j.clipboardData||x.state.selection.empty?!1:(j.preventDefault(),j.clipboardData.clearData(),j.clipboardData.setData("text/plain",is(x.state.doc,x.state.selection.from,x.state.selection.to)),v&&!a.current.disabled&&x.dispatch(us(x.state.tr.deleteSelection())),!0),y=new ba({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,"",j=>String(j.attrs.token??"")),handleKeyDown:(x,j)=>{if(j.isComposing||j.altKey||j.ctrlKey||j.metaKey||j.shiftKey||!x.state.selection.empty)return!1;const{$from:v}=x.state.selection,k=j.key==="Backspace";if(!k&&j.key!=="Delete")return!1;const w=k?v.nodeBefore:v.nodeAfter;if(w?.type.name!=="reference")return!1;const S=k?v.pos-w.nodeSize:v.pos;return x.dispatch(us(x.state.tr.delete(S,S+w.nodeSize)).scrollIntoView()),!0},handlePaste:(x,j)=>{if(!j.clipboardData)return!1;j.preventDefault();const v=j.clipboardData.getData("text/plain").replace(/\r\n?/gu,`
|
|
2
|
+
`);return x.dispatch(us(x.state.tr.insertText(v)).scrollIntoView()),!0},handleDOMEvents:{focus:()=>(a.current.onFocus(),!1),keydown:(x,j)=>(a.current.onKeyDown(j),j.defaultPrevented),copy:(x,j)=>h(x,j,!1),cut:(x,j)=>h(x,j,!0),compositionstart:()=>(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=y,()=>{window.cancelAnimationFrame(c.current),a.current.sessions.set(r.current,y.state),i.current=null,y.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(Vs(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 zc(l){const e=W.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(Bc),e[4]=n,e[5]=h):h=e[5];let y;e[6]!==i||e[7]!==p||e[8]!==h?(y=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]=y):y=e[9];const x=r?"Loading actions…":`${s.length} actions`;let j;e[10]!==x?(j=t.jsx("span",{role:"status",children:x}),e[10]=x,e[11]=j):j=e[11];let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(mt,{size:15}),e[12]=v):v=e[12];let k;e[13]!==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]!==y||e[16]!==j||e[17]!==k?(w=t.jsxs("header",{children:[b,y,j,k]}),e[15]=y,e[16]=j,e[17]=k,e[18]=w):w=e[18];let S;e[19]!==o?(S=o&&t.jsx("p",{role:"alert",children:o}),e[19]=o,e[20]=S):S=e[20];let R;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=(I,E)=>{const F=ii(I,a);return t.jsxs("button",{type:"button",role:"option",id:`${c}-option-${E}`,"aria-selected":E===d,className:E===d?"active":"","data-action-id":I.id,"data-command":I.command,onMouseDown:Oc,onClick:()=>m(I),children:[t.jsxs("span",{children:[t.jsx("strong",{children:I.title}),t.jsx("code",{children:I.command})]}),t.jsx("small",{children:I.description}),F&&t.jsx("small",{className:"composer-action-unavailable",children:F})]},I.id)},e[27]=a,e[28]=c,e[29]=m,e[30]=d,e[31]=T):T=e[31],R=s.map(T),e[21]=s,e[22]=a,e[23]=c,e[24]=m,e[25]=d,e[26]=R}else R=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 M;e[35]!==c||e[36]!==R||e[37]!==N?(M=t.jsxs("div",{id:c,role:"listbox","aria-label":"Available actions",className:"workspace-actions-list",children:[R,N]}),e[35]=c,e[36]=R,e[37]=N,e[38]=M):M=e[38];let A;e[39]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("p",{className:"composer-actions-help",children:"Choose an action to prepare its command. Submit when ready."}),e[39]=A):A=e[39];let D;return e[40]!==w||e[41]!==S||e[42]!==M?(D=t.jsxs("section",{className:"command-suggestions composer-actions-panel","aria-label":"Actions","data-workspace-action-surface":"launcher",children:[w,S,M,A]}),e[40]=w,e[41]=S,e[42]=M,e[43]=D):D=e[43],D}function Oc(l){return l.preventDefault()}function Bc(l){return t.jsx("option",{children:l},l)}function ut(l){const e=W.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(Bn,{size:n})}),e[0]=n,e[1]=i):i=e[1],i}const Ui=C.createContext(null);function Uc(l){const e=W.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:Kc,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:Hc,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 Hc(l){return l.preventDefault()}function Kc(l){return l.preventDefault()}function Vc(l){const e=W.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=R=>R.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 y;e[10]!==o||e[11]!==f||e[12]!==h?(y=t.jsx("button",{type:"button",className:"speak-preview-refresh",disabled:o,onMouseDown:qc,onClick:f,children:h}),e[10]=o,e[11]=f,e[12]=h,e[13]=y):y=e[13];let x;e[14]!==d||e[15]!==u||e[16]!==i||e[17]!==n||e[18]!==s?(x=t.jsx(Uc,{voices:s,selectedVoiceId:n,playingVoiceId:i,onSelect:d,onTogglePreview:u}),e[14]=d,e[15]=u,e[16]=i,e[17]=n,e[18]=s,e[19]=x):x=e[19];let j;e[20]!==a||e[21]!==r?(j=(r||a==="fallback")&&r&&t.jsx("p",{className:"speak-preview-warning",children:r}),e[20]=a,e[21]=r,e[22]=j):j=e[22];const v=b?` · ${b.name}`:"";let k;e[23]!==v?(k=t.jsxs("p",{className:"speak-preview-hint",children:["↑↓ voice · tab select · ctrl+space preview · enter speak · esc close",v]}),e[23]=v,e[24]=k):k=e[24];let w;return e[25]!==p||e[26]!==g||e[27]!==y||e[28]!==x||e[29]!==j||e[30]!==k?(w=t.jsxs("div",{className:"command-suggestions speak-preview",role:"listbox","aria-label":"ElevenLabs voices","data-testid":"speak-command-preview",children:[p,g,y,x,j,k]}),e[25]=p,e[26]=g,e[27]=y,e[28]=x,e[29]=j,e[30]=k,e[31]=w):w=e[31],w}function qc(l){return l.preventDefault()}function Wc(l){const e=W.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 Xc(l){return Array.from(l?.querySelectorAll(Gc)??[])}function Yc(){const l=W.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("span",{className:"composer-mode-meter","aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),l[0]=e):e=l[0],e}function Jc(l){const e=W.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(),y=o?.meterRef,x=!!o?.active,j=o?.phase,v=!!o?.disabled,k=o?.message,w=o?.retrying,S=o?.pendingReview;let R;e[0]!==k||e[1]!==w||e[2]!==S||e[3]!==j?(R=ai({sending:!1,mcpRunning:0,voicePhase:j,voiceMessage:k,retrying:w,pendingReview:S}),e[0]=k,e[1]=w,e[2]=S,e[3]=j,e[4]=R):R=e[4];const N=R,M=o?.provider??o?.mode??"auto";let A;e[5]!==M?(A=Ea(M),e[5]=M,e[6]=A):A=e[6];const D=A,T=o?.fallbackReason;let I;e[7]!==T||e[8]!==D||e[9]!==N.label?(I=[N.label,D,T].filter(Boolean),e[7]=T,e[8]=D,e[9]=N.label,e[10]=I):I=e[10];const E=I.join(" · "),F=Pa({chatModels:s,selectedModel:n,modelSelectable:!r,voiceMode:o?.mode??null}),$=Aa(F),P=$.length===0||i||a;let L;e[11]!==s||e[12]!==n?(L=s.find(ee=>ee.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=ee=>{b(!1),U()};let H;e[14]!==m?(H=[m],e[14]=m,e[15]=H):H=e[15],C.useEffect(()=>{if(!m)return;const ee=u.current,Q=fe=>{ee?.contains(fe.target)||b(!1)},de=fe=>{fe.key!=="Escape"||fe.defaultPrevented||(fe.preventDefault(),fe.stopPropagation(),b(!1),ee?.querySelector(_l)?.focus())};return document.addEventListener("pointerdown",Q),document.addEventListener("focusin",Q),document.addEventListener("keydown",de,!0),()=>{document.removeEventListener("pointerdown",Q),document.removeEventListener("focusin",Q),document.removeEventListener("keydown",de,!0)}},H);const K=()=>{if(m){q();return}g(Da($)),b(!0)},te=ee=>{ee.kind==="model"?c(ee.model):o?.selectMode(ee.mode),q()},ae=ee=>{const Q=Ta($,p,ee.key);Q!==null&&(ee.preventDefault(),g(Q),Xc(f.current)[Q]?.focus())},V={"aria-haspopup":"menu","aria-expanded":m,className:"composer-mode-cell composer-mode-cell-live",disabled:P,onClick:K},oe="composer-mode-switch",G="group",se="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(wi,{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}),!P&&t.jsx(Is,{size:11,"aria-hidden":"true"})]}),Y=o&&(x?t.jsxs("button",{...V,ref:y,type:"button","data-voice-phase":j,"aria-label":"Voice provider","aria-describedby":h,"aria-busy":j==="connecting",title:E,children:[j==="connecting"?t.jsx(ki,{className:"composer-mode-connecting",size:14,"aria-hidden":"true"}):t.jsx(Yc,{}),t.jsx("span",{className:"composer-mode-name",children:"VOICE"}),t.jsx("span",{className:"composer-mode-divider","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"composer-mode-engine",children:j==="connecting"?N.label:D}),!P&&t.jsx(Is,{size:11,"aria-hidden":"true"})]}):t.jsx("button",{ref:y,type:"button",className:"composer-mode-cell composer-mode-cell-idle","data-voice-phase":j,"aria-label":"Start voice conversation","aria-describedby":h,"aria-pressed":!1,disabled:v||a,title:"Voice input + spoken replies",onClick:d,children:t.jsx(Si,{size:15,"aria-hidden":"true"})}));let Z;e[16]!==o||e[17]!==N.label||e[18]!==h?(Z=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]=Z):Z=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(ee=>[t.jsx("li",{role:"presentation",className:"composer-engine-group",children:ee.label},`${ee.id}-label`),...ee.items.map(Q=>{const de=`${Q.id.replace(":","-")}-note`;return t.jsx("li",{role:"none",children:t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":Q.checked,"aria-label":Q.label,"aria-describedby":Q.note?de:void 0,autoFocus:Q.position===p,tabIndex:Q.position===p?0:-1,className:"composer-engine-item",onClick:()=>te(Q.choice),children:[t.jsx("span",{className:"composer-engine-check","aria-hidden":"true",children:Q.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:Q.label}),Q.detail&&t.jsx("small",{children:Q.detail})]}),Q.note&&t.jsx("small",{id:de,className:"composer-engine-note",children:Q.note})]})]})},Q.id)})])});let re;return e[20]!==u||e[21]!==le||e[22]!==Y||e[23]!==Z||e[24]!==J?(re=t.jsxs("div",{ref:u,className:oe,role:G,"aria-label":se,children:[le,Y,Z,J]}),e[20]=u,e[21]=le,e[22]=Y,e[23]=Z,e[24]=J,e[25]=re):re=e[25],re}const Ll="videobook-command-composer-form",Qc=250;function mf({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:y,contextualContent:x=null,contextualHasHeader:j=!1,goalStatus:v=null,bookId:k,callTool:w,chatModels:S,disabled:R,hidden:N=!1,modelSelectionDisabled:M,connectionLabel:A,mcpCalls:D,mcpFlash:T,onToggleMcpCall:I,selectedModel:E,context:F=null,mentionAssets:$=[],inputSession:P=null,placeholder:L,portalTarget:_=null,pendingInput:z,replacePendingInput:O=!1,notice:U,outcomeSlot:q="composer",onEnsureCatalog:H,onDismissNotice:K,onDismissPanel:te,onExecute:ae,onModelChange:V,onStartVoice:oe,onSendingChange:G,onCommandRowHeightChange:se,onHeightChange:le,onSuccessfulExecute:Y,voiceCatalog:Z,voice:J}){const[re,ee]=C.useState(Fa),[Q,de]=C.useState(()=>z??re.get(P)??""),[fe,ue]=C.useState(0),[pe,me]=C.useState(()=>z!==void 0&&!Xt(z)),[be,ye]=C.useState(()=>_a()??""),ce=La(),[X,ie]=C.useState(!1),he=C.useRef(0),ke=C.useRef(!1),[$e,De]=C.useState(!1),[Ie,Te]=C.useState(null),[Fe,et]=C.useState(z),[Ye,Ke]=C.useState(!1),[Ve,lt]=C.useState(P),Ae=C.useRef(null),We=C.useRef(null),Ge=C.useRef(null),[Je,tt]=C.useState(null);C.useLayoutEffect(()=>{const B=Ge.current,ge=We.current;if(N||_||!B||!ge||!se&&!le)return;const Se=()=>{const qt=getComputedStyle(ge);se?.(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,se,le,_]);const[Ce,Ee]=C.useState(!1),qe=h??Ce,_e=C.useRef(qe),ve=B=>{h===void 0&&Ee(B),y?.(B)},[Qe]=C.useState(()=>new Map),[nt,At]=C.useState({start:Q.length,end:Q.length}),[wt,Dt]=C.useState(u?.query??""),[Ze,ne]=C.useState(""),[xe,Re]=C.useState(u?.key),[Xe,at]=C.useState(null),Nt=C.useId(),Ct=C.useId(),ft=C.useRef(P),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(()=>za(J?.captions??[],D,l,e),[l,e,D,J?.captions]),ht=Oa(ot),Ft=Ba(ot),It=Ua(J),yt=q==="composer"&&U&&!l.some(B=>B.reply===U.message)?U:null,ct=q==="composer"&&Ie&&Ie.message!==U?.message?Ie:null,Me=!!(It||yt||ct),we=JSON.stringify([It,yt,ct]),Le=ai({sending:X,mcpRunning:hl(D),voicePhase:J?.phase,voiceMessage:J?.message,retrying:J?.retrying,pendingReview:J?.pendingReview}),Ue=Le.busy&&Le.kind!=="connecting"&&Le.kind!=="permission",Pe=!Ue&&T==="success",Ne=!Ue&&T==="error",kt=Ha({runningCalls:hl(D),voicePhase:J?.phase})||D.calls.some(B=>B.expanded)||l.some(si)||$e||!!(It?.error||It?.playbackBlocked)||yt?.tone==="error"||ct?.ok===!1,_t=C.useRef(ht),Ut=C.useRef(we);if(C.useLayoutEffect(()=>{ft.current=P},[P]),C.useEffect(()=>{Ka(re,P,Q===z?"":Q)},[Q,re,P,z]),C.useEffect(()=>{(ht>_t.current||Me&&we!==Ut.current)&>(!0),_t.current=ht,Ut.current=we},[we,Me,ht]),C.useEffect(()=>Va({open:xt,held:kt,onClose:()=>gt(!1)}),[xt,kt,Ft,we]),C.useLayoutEffect(()=>{Et&&(rt.current="")},[Et]),C.useEffect(()=>{window.clearTimeout($t.current)},[P]),P!==Ve){const B=new Map(re);B.set(Ve,Q===Fe?"":Q),ee(B),lt(P),et(z),Ke(!1),de(z??B.get(P)??""),Te(null),at(null),me(z!==void 0&&!Xt(z))}else if(z!==Fe){const B=O||!Q.trim()||Q===Fe;et(z),J?.pendingReview||Ye?Ke(z!==void 0):B&&de(z??""),me(z!==void 0&&!Xt(z))}u?.key!==xe&&(Re(u?.key),Dt(u?.query??""),ne(""),ue(0));const Lt=!u&&!F&&!pe&&Xt(Q),je=J?.active&&!x&&!a&&!U&&!Ie&&!u&&!Lt&&ht<=Vt&&!(xt&&ot.length>0)&&!J.playbackBlocked&&!Me,dt=qe&&!je,Ht=Z?.voices??[],Ts=bl(Ht,be),Es=ce.stop;C.useEffect(()=>{Lt||Es()},[Lt,Es]);const cs=()=>{Z&&Z.ensureLoaded().catch(()=>{})},ns=B=>{!F&&Xt(B)&&cs()},Fs=()=>{Z&&Z.refresh().catch(()=>{})},Gt=(B=!1)=>{xn(()=>Ae.current?.element()??null,()=>{B&&Ae.current?.select()})()},_s=()=>{me(!0),u&&p(!1),Ja({setOpen:ve,stopVoice:J?.stop,pauseMedia:()=>bn(We.current)}),Gt()},st=()=>{if(J){if(J.active){J.stop(),Gt();return}J.disabled||X||(ce.stop(),bn(We.current),de(""),At({start:0,end:0}),Ke(!1),at(null),Te(null),me(!0),gt(!1),Bt(ht),it.current=-1,pt.current="",u&&p(!1),K?.(),oe?.(),ve(!0),J.toggle(),Gt())}};C.useEffect(()=>{const B=_e.current;_e.current=qe,!(!B||qe)&&(ce.stop(),J?.stop(),bn(We.current))},[qe,ce,J]);const Rt=C.useMemo(()=>({outcome:Ie,notice:U??null,dismissOutcome:()=>Te(null),dismissNotice:()=>K?.()}),[U,K,Ie]),Be=C.useMemo(()=>{if(u||pe||Xt(Q))return[];if(z&&/^\/(?:apply|cancel)(?:\s|$)/iu.test(Q))return[];const B=Q.match(/^\/([\w-]*)$/);if(B&&!F){const Se=B[1].toLowerCase();return qa(r,Se).map(Oe=>({value:`${Oe.command} `,label:Oe.command,description:Oe.description,aliases:Oe.aliases,type:"command"}))}const ge=F?new Set($.map(Se=>Se.artifactId)):void 0;return Wa(o,Q,nt.start,nt.end,ge).map(Se=>({value:Se.token,label:Se.token,description:li(Se),type:"cell",reference:Se}))},[u,r,F,pe,Q,$,z,o,nt]),zt=C.useMemo(()=>Ga(c,wt).filter(B=>!Ze||B.group===Ze),[Ze,wt,c]),Zi=C.useMemo(()=>[...new Set(c.map(B=>B.group))].sort(),[c]),ts=Math.min(fe,Math.max(0,zt.length-1)),Ls=`${Nt}-actions`,ln=Xe?.action.command===Q.trim().split(/\s/u)[0]&&Xe?.action.scope==="global"?m:R;C.useLayoutEffect(()=>{u&&xn(()=>Ae.current?.element()??null)()},[u,_]);const Zn=B=>{window.clearTimeout($t.current),Te(B),B.ok&&($t.current=window.setTimeout(()=>Te(null),3200))},ea=async B=>{const ge=[];let Se=0;for(;;){const Oe=await w("list_prompt_history",{book_id:B,surface:"chat",limit:Qc,offset:Se}),qt=ar(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}},an=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 ea(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)},ta=()=>{F||(vt.current!==k&&(vt.current=k,H().catch(()=>{vt.current===k&&(vt.current=null)})),an()),Lt&&cs()},sa=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??Q).trim();if(!Se||ke.current||ln||u||ze.current)return;ve(!0),ge||Ke(!1);const Oe=Xe?.action.command===Se.split(/\s/u)[0]?Xe:null,qt=P,Mt=i?.(Se),ds=()=>Mt?Mt.isInScope():ft.current===qt,ma=he.current,il=()=>he.current===ma&&ft.current===qt;ke.current=!0,ie(!0),gt(!0),Te(null),ge||de(""),me(!0),G?.(!0);let un=!1,mn=!1;const fa=xn(()=>Ae.current?.element()??null,()=>{mn&&Ae.current?.select()});try{if(!F||Oe){if(await an(),!ds())return;await sa(Se,Mt)}if(!ds())return;const ys=!F&&Xt(Se)?await Z?.ensureLoaded():null;if(!ds())return;const Bs=bl(ys?.voices??Ht,be),fn=sr(Se,Bs);fn?.speakVoiceId&&xl(fn.speakVoiceId);const Us=await ae(Se,{chat:Mt,...fn,...Oe?{action:{id:Oe.action.id,values:Oe.values}}:{}});if(un=!0,!ds()||Mt&&!Mt.isCurrent())return;at(null),(!Mt||!Us.ok&&q==="sheet")&&Zn(Us);const js=nr(Us,z);js&&!ge&&il()&&(de(js.value),me(!Xt(js.value)),ns(js.value),mn=js.select),Us.ok&&Y()}catch(ys){const Bs={ok:!1,message:ys instanceof Error?ys.message:String(ys)};if(Mt?.finish(Bs),un=!0,!ds())return;Mt||Zn(Bs),z!==void 0&&!ge&&il()&&(de(z),me(!0),mn=!0)}finally{un||Mt?.finish({ok:!0,status:"cancelled",message:"Workspace changed before the command was sent."}),ke.current=!1,ie(!1),G?.(!1),ds()&&(!Mt||Mt.isCurrent())&&fa()}},rn=B=>{if(B.type==="command")Ae.current?.replace(B.value),me(!Xt(B.value)),ns(B.value);else{const ge=Ae.current?.selection()??nt,Se=Za(Q,B.value,ge.start,ge.end);if(!Se)return;Ae.current?.replace(Se.value,{start:Se.caret,end:Se.caret}),me(!0)}it.current=-1,Gt()},on=B=>{at({action:B,values:u?.values}),de(`${B.command} `),me(!0),ue(0),p(!0),Gt()},zs=()=>{p(!1),g||Gt()},tl=B=>{ye(B),xl(B),ce.playingVoiceId&&ce.playingVoiceId!==B&&ce.stop()},na=()=>{const B=Ht.find(ge=>ge.voiceId===Ts);B?.previewUrl&&ce.toggle(B.voiceId,B.previewUrl)},Os=async B=>{const ge=P;if(await an(),ge!==ft.current)return;const Se=ir({values:jt.current,cursor:it.current,draft:pt.current,current:Q,direction:B});Se&&(it.current=Se.cursor,pt.current=Se.draft,de(Se.value),me(!0),ns(Se.value))},sl=(B,ge=Q)=>{const Se=Ae.current?.selection()??nt,Oe=lr({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?Ae.current?.setSelection({start:Oe.selectionStart,end:Oe.selectionEnd}):Ae.current?.replace(Oe.value,{start:Oe.selectionStart,end:Oe.selectionEnd}),ns(Oe.value),Oe.killedText!==void 0&&(Tt.current=Oe.killedText),!0):!1},la=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(),zs();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);ue(Math.max(0,ge)),document.getElementById(`${Ls}-option-${ge}`)?.scrollIntoView({block:"nearest"})}else(B.key==="Enter"||B.key==="Tab"&&!B.shiftKey)&&zt[ts]?(B.preventDefault(),on(zt[ts])):sl(B,wt);return}if(Lt){const ge=er(B,Ht,Ts);if(ge.type!=="ignore"&&B.preventDefault(),ge.type==="select"){tl(ge.voiceId);return}if(ge.type==="toggle"){na();return}if(ge.type==="dismiss"){ce.stop(),me(!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;ue(ge),document.getElementById(`${Nt}-option-${ge}`)?.scrollIntoView({block:"nearest"});return}if(B.key==="Tab"&&!B.shiftKey){B.preventDefault(),rn(Be[Math.min(fe,Be.length-1)]);return}if(B.key==="Enter"&&!tr(Q,Be)){B.preventDefault(),rn(Be[Math.min(fe,Be.length-1)]);return}if(B.key==="Escape"){B.preventDefault(),me(!0);return}}if(B.key==="Escape"&&dt&&dn&&xt&&!Rn(J?.phase,ot.length,!!J)){B.preventDefault(),gt(!1);return}if(B.key==="Escape"&&(te||g)){B.preventDefault(),te?te():g?.();return}if(!F&&B.ctrlKey&&B.key.toLowerCase()==="p"){B.preventDefault(),Os(-1);return}if(!F&&B.ctrlKey&&B.key.toLowerCase()==="n"){B.preventDefault(),Os(1);return}if(!F&&B.key==="ArrowUp"){B.preventDefault(),Os(-1);return}if(!F&&B.key==="ArrowDown"){B.preventDefault(),Os(1);return}sl(B)||B.key==="Enter"&&(B.preventDefault(),el())},ls=Ya(!!a),cn=l.at(-1),nl=cn!==void 0&&cn.id===s,dn=!x||ls||nl,ia=dn||Me,aa=dn?x&&!ls&&nl?ot.filter(B=>B.kind==="caption"&&B.turn?.id===cn.id):ot:[],ra=Qa({dockOpen:dt,panelHasHeader:j,reviewPriority:ls}),oa=!Me&&Rn(J?.phase,ot.length,!!J),ca={captionId:Ct},da={hide:_s,hideLabel:Xa},ua=Me?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:()=>Te(null)}),It&&J&&t.jsx(Wc,{feedback:It,onResumePlayback:J.resumePlayback})]}):null,ll=t.jsx(Ui.Provider,{value:Rt,children:t.jsx(zi.Provider,{value:da,children:t.jsx(Bi.Provider,{value:ca,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(),zs())},children:[ls&&dt&&t.jsx(Oi,{label:"Resize review pane",targetSelector:".command-composer",edge:"top",minimum:280,onResize:tt}),dt&&!ra&&t.jsxs("div",{className:"command-composer-dock-bar",children:[oa&&t.jsx("span",{className:"command-composer-dock-title",children:"chat"}),t.jsx(Ic,{})]}),t.jsxs("div",{className:"command-composer-dock-body",hidden:!dt,inert:dt?void 0:!0,children:[x&&t.jsx("div",{className:"command-composer-contextual",hidden:ls,inert:ls?!0:void 0,children:x}),!N&&!F&&a,u&&t.jsx(zc,{actions:zt,groups:Zi,group:Ze,context:d,loading:f.loading,error:f.error,listId:Ls,selectedIndex:ts,onGroupChange:B=>{ne(B),ue(0),Gt()},onClose:zs,onSelect:on}),!N&&ia&&t.jsx(Pc,{rows:aa,connected:n,onDetailsChange:De,phase:J?.phase,voicePresent:!!J,open:xt&&dt,onToggleCall:I,children:ua})]}),t.jsxs("form",{ref:Ge,id:Ll,className:`command-line-shell ${Ue?"command-line-shell-transmitting":""} ${Pe?"command-line-shell-success":""} ${Ne?"command-line-shell-error":""}`,"aria-busy":Ue,onSubmit:B=>{if(B.preventDefault(),u&&zt[ts])on(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(Q);el(Oe?z:void 0)}},children:[Lt&&t.jsx(Vc,{voices:Ht,selectedVoiceId:Ts,playingVoiceId:ce.playingVoiceId,status:Z?.status??"fallback",warning:Z?.warning??null,loading:Z?.loading??!1,error:Z?.error??null,onSelect:tl,onTogglePreview:(B,ge)=>{J?.stop(),ce.toggle(B,ge)},onRefresh:Fs}),!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:()=>rn(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||X,onClick:u?zs:b,children:t.jsx(Uo,{size:14,"aria-hidden":"true"})})}),t.jsx(Lc,{ref:Ae,value:u?wt:Q,session:`${P??"chat"}:${u?`actions-${u.key}`:"draft"}`,sessions:Qe,references:o,disabled:u?m:ln,rich:!u,placeholder:u?"Search actions by name, operation or alias…":R?A:L??"Type a message or /command…",expanded:!!u||!Lt&&Be.length>0,controls:u?Ls:!Lt&&Be.length>0?`${Nt}-list`:void 0,activeDescendant:u&&zt[ts]?`${Ls}-option-${ts}`:!Lt&&Be[fe]?`${Nt}-option-${fe}`:void 0,onFocus:ta,onCompositionChange:B=>{ze.current=B},onSelectionChange:At,onChange:(B,ge)=>{if(At(ge),ue(0),u){Dt(B);return}he.current+=1,de(B),me(!1),it.current=-1,ns(B)},onKeyDown:la}),v,t.jsx(Jc,{chatModels:S,selectedModel:E,modelSelectionDisabled:M,sending:X,context:F,voice:J,onModelChange:V,onToggleVoice:st}),t.jsx("button",{type:"submit",className:"command-send",disabled:u?m||zt.length===0||f.loading:ln||X||!Q.trim(),"aria-label":u?"Prepare action":"Send command",children:X?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 Zc(l){const e=W.c(12),{task:s}=l,[n,i]=C.useState(null);let a;e[0]!==s.model||e[1]!==s.provider?(a=rr(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 ed(l,e){return l===e?!0:!l||!e?!1:l.sourceLeftX===e.sourceLeftX&&l.sourceRightX===e.sourceRightX&&l.sourceBottomY===e.sourceBottomY&&l.targetCenterX===e.targetCenterX&&l.targetLeftX===e.targetLeftX&&l.targetTopY===e.targetTopY&&l.targetHeight===e.targetHeight}const ff=C.memo(function(e){const s=W.c(20),{source:n,sourceX:i,sourceY:a,target:r,data:o}=e;let c;s[0]!==n||s[1]!==r?(c=x=>{const j=x.nodeLookup.get(n),v=x.nodeLookup.get(r);if(!j||!v)return null;const k=j.internals?.positionAbsolute??j.position,w=v.internals?.positionAbsolute??v.position,S=j.measured?.width??He.squareSize,R=j.measured?.height??He.squareSize,N=v.measured?.width??He.squareSize,M=v.measured?.height??He.squareSize;return{sourceLeftX:k.x,sourceRightX:k.x+S,sourceBottomY:k.y+R,targetCenterX:w.x+N/2,targetLeftX:w.x,targetTopY:w.y,targetHeight:M}},s[0]=n,s[1]=r,s[2]=c):c=s[2];const d=uc(c,ed);if(!o||!d)return null;const u=Mn[o.targetPortIndex]??Mn[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=or({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(mc,{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 y;return s[17]!==g||s[18]!==h?(y=t.jsxs(t.Fragment,{children:[g,h]}),s[17]=g,s[18]=h,s[19]=y):y=s[19],y}),qs=10;function td(l){const e=He.columnCount*He.columnPitch-He.gap,s=l.rowCount*He.rowPitch-He.gap,n=He.originX-qs,i=He.originY+l.startRow*He.rowPitch-qs;return{width:e+qs*2,height:s+qs*2,transform:`translate(${n}px, ${i}px)`}}function pf(l){const e=W.c(33),{sections:s,metrics:n,occupiedSlots:i,previewSlot:a,mediaDropActive:r,mediaDropSlot:o,reviewRoles:c}=l;let d;e[0]!==a?(d=a?On(a):null,e[0]=a,e[1]=d):d=e[1];const u=d;let f;e[2]!==i?(f=new Set(i.map(Hs)),e[2]=i,e[3]=f):f=e[3];const m=f;let b;e[4]!==o?(b=o?Hs(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(sd),e[9]=s,e[10]=h):h=e[10];let y;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,R)=>{const N=n.minColumn+R,M={row:w,column:N},A=Hs(M),D=m.has(A),T=r&&!D,I=T&&A===p,E=D?void 0:c.get(ti(M)),$=`notebook-grid-square${!D&&(R===0||m.has(Hs({row:w,column:N-1})))?" notebook-grid-square-run-start":""}${T?" notebook-grid-square-dropzone":""}${I?" notebook-grid-square-drop-target":""}${E?` notebook-grid-square-review notebook-review-${E}`:""}`;return t.jsx("span",{className:$,style:{width:He.squareSize,height:He.squareSize,transform:`translate(${He.originX+R*He.columnPitch}px, ${He.originY+w*He.rowPitch}px)`},children:t.jsx("span",{className:"notebook-grid-square-label",children:Wt(M)})},A)}),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],y=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]=y}else y=e[18];let x;e[26]!==u?(x=u&&t.jsx("div",{className:"notebook-grid-preview",style:{width:He.squareSize,height:He.squareSize,transform:`translate(${u.x}px, ${u.y}px)`}}),e[26]=u,e[27]=x):x=e[27];let j;return e[28]!==g||e[29]!==h||e[30]!==y||e[31]!==x?(j=t.jsx(Li,{children:t.jsxs("div",{className:"notebook-grid-board",style:g,children:[h,y,x]})}),e[28]=g,e[29]=h,e[30]=y,e[31]=x,e[32]=j):j=e[32],j}function sd(l){const e=l.family??"mixed";return t.jsx("div",{className:`notebook-lane notebook-lane-${e}${l.kind==="starter"?" notebook-lane-starter":""}${l.kind==="mixed"?" notebook-lane-mixed":""}`,"data-lane-caption":l.caption,"data-lane-family":e,"data-lane-kind":l.kind,"data-lane-row-count":l.rowCount,"data-lane-start-row":l.startRow,style:td(l)},`lane-${l.startRow}-${e}`)}const Ot={width:240,height:156,pitch:4,minimumBarHeight:4};function nd(l){const e=W.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=cr(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(Hi,{}),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 Hi(){const l=W.c(2);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=dr(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 ld(l){const e=W.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 y=!!(b&&!a),x=m&&!!s.mediaUrl&&!y;let j,v;if(e[0]!==i||e[1]!==x||e[2]!==d?(j=()=>{if(!x||d)return;if(i||typeof IntersectionObserver>"u"){const M=window.requestAnimationFrame(()=>u(!0));return()=>window.cancelAnimationFrame(M)}const R=f.current;if(!R)return;const N=new IntersectionObserver(M=>{M.some(id)&&(u(!0),N.disconnect())},{root:R.closest(".media-library-results"),rootMargin:"96px 0px"});return N.observe(R),()=>N.disconnect()},v=[i,x,d],e[0]=i,e[1]=x,e[2]=d,e[3]=j,e[4]=v):(j=e[3],v=e[4]),C.useEffect(j,v),y&&b){let R;e[5]===Symbol.for("react.memo_cache_sentinel")?(R=()=>r(!0),e[5]=R):R=e[5];let N;return e[6]!==b?(N=t.jsx("img",{src:b,alt:"",loading:"lazy",decoding:"async",onError:R}),e[6]=b,e[7]=N):N=e[7],N}if(m&&s.mediaUrl){let R;return e[8]!==s.duration||e[9]!==s.mediaUrl||e[10]!==d||e[11]!==o?(R=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]=R):R=e[12],R}let k;e[13]!==s.type?(k=s.type==="audio"?t.jsx(ss,{size:28}):t.jsx(St,{size:28}),e[13]=s.type,e[14]=k):k=e[14];let w;e[15]!==s.duration?(w=s.duration!==null&&t.jsx("small",{children:Kt(s.duration)}),e[15]=s.duration,e[16]=w):w=e[16];let S;return e[17]!==k||e[18]!==w?(S=t.jsxs("span",{className:"media-library-asset-placeholder",children:[k,w]}),e[17]=k,e[18]=w,e[19]=S):S=e[19],S}function id(l){return l.isIntersecting}function kn(l){return l!==null&&Number.isFinite(l)&&l>0}function ad(l){const e=W.c(11),{className:s,width:n,height:i,durationSeconds:a,fallbackLabel:r}=l,o=kn(n)&&kn(i)?`${n}×${i}`:r??null;let c;e[0]!==a?(c=kn(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 rd=/("(?:\\.|[^"\\])*")(?=\s*:)|("(?:\\.|[^"\\])*")|\b(true|false)\b|\b(null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function od(l){const e=JSON.stringify(l,null,2)??"null",s=[];let n=0;for(const i of e.matchAll(rd)){const a=i.index;a>n&&s.push({kind:"punctuation",value:e.slice(n,a)}),s.push({kind:i[1]?"key":i[2]?"string":i[3]?"boolean":i[4]?"null":"number",value:i[0]}),n=a+i[0].length}return n<e.length&&s.push({kind:"punctuation",value:e.slice(n)}),s}function cd(l){if(!l.startsWith('"')||!l.endsWith('"')||l.length<2)return null;try{const e=JSON.parse(l);return typeof e=="string"?e:null}catch{return null}}function dd(l){const e=W.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(),R=w.right+S.width<=window.innerWidth-12?w.right:Math.max(12,w.left-S.width);v.style.left=`${R}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 y;e[12]!==s.thumbnailUrl||e[13]!==s.type||e[14]!==o||e[15]!==r?(y=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]=y):y=e[16];let x;e[17]!==n||e[18]!==y?(x=t.jsx("span",{id:n,ref:i,popover:"auto",className:"json-media-popover",onToggle:ud,children:y}),e[17]=n,e[18]=y,e[19]=x):x=e[19];let j;return e[20]!==h||e[21]!==x?(j=t.jsxs("span",{className:"json-media-preview",onMouseEnter:d,onMouseLeave:m,onFocus:d,onBlur:b,children:[h,x]}),e[20]=h,e[21]=x,e[22]=j):j=e[22],j}function ud(l){l.newState==="closed"&&l.currentTarget.querySelectorAll("video, audio").forEach(md)}function md(l){l instanceof HTMLMediaElement&&l.pause()}const fd=/\.(?:png|jpe?g|webp|gif|avif)$/i,pd=/\.(?:mp4|mov|webm|m4v)$/i;function hd(l){if(!/^https?:\/\//i.test(l))return;let e;try{e=new URL(l).pathname}catch{return}const s=fd.test(e)?"image":pd.test(e)?"video":null;return s?{artifactId:l,type:s,mediaUrl:l}:void 0}function Gn(l){const e=W.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=od(s);u="inspector-source-json",f=o;let g;e[8]!==i||e[9]!==c||e[10]!==d?(g=(h,y)=>{const x=h.kind==="string"?cd(h.value):null,j=x?i?.get(x)??(d?hd(x):void 0):void 0;return t.jsxs("span",{className:`json-${h.kind}`,children:[h.value,j&&(c==="preview"?t.jsx(dd,{asset:j}):t.jsx(xs,{asset:j}))]},`${y}-${h.value}`)},e[8]=i,e[9]=c,e[10]=d,e[11]=g):g=e[11],m=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 bd(l){const e=W.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(ad,{className:"inspector-dolt-artifact-metadata",width:s.width,height:s.height,durationSeconds:s.duration}),e[6]=s.duration,e[7]=s.height,e[8]=s.width,e[9]=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 xd(l){const e=W.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(j=>{const v=new Set(j);return v.has(x)?v.delete(x):v.add(x),v})},e[1]=d):d=e[1];const u=d,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 j=ur(x);if(j.kind==="json")return t.jsxs(C.Fragment,{children:[t.jsxs("tr",{className:"inspector-dolt-json-meta",children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsx("code",{className:"dolt-json-kind",children:"JSON"})})]}),t.jsx("tr",{className:"inspector-dolt-json-value",children:t.jsx("td",{colSpan:3,children:t.jsx(Gn,{value:j.value,ariaLabel:`${x.column} JSON`,artifactAssets:i})})})]},x.column);const v=j.kind==="raw"&&typeof j.value=="string"?i.get(j.value):void 0;if(v){const k=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(bd,{asset:v})})})]},x.column)}return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsx("code",{className:j.kind==="null"?"dolt-null":void 0,children:j.kind==="null"?"NULL":String(j.value)})})]},x.column)},e[3]=i,e[4]=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 y;return e[8]!==b||e[9]!==h?(y=t.jsxs("table",{className:f,"aria-label":m,children:[b,h]}),e[8]=b,e[9]=h,e[10]=y):y=e[10],y}function hf(l){const e=W.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(xd,{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 gd(l){const e=W.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 y;e[7]!==f||e[8]!==p||e[9]!==d.phase?(y=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]=y):y=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 j;e[14]!==d.message||e[15]!==d.phase?(j=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]=j):j=e[16];let v;return e[17]!==y||e[18]!==x||e[19]!==j?(v=t.jsxs("span",{className:"generation-har-actions",children:[y,x,j]}),e[17]=y,e[18]=x,e[19]=j,e[20]=v):v=e[20],v}const zl=new WeakMap;function yd(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 Ki(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 Sn(l){return l.length>14?`${l.slice(0,8)}…${l.slice(-4)}`:l}function Vi(l){const e=W.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 jd(l){const e=W.c(12),{step:s,submittedAt:n}=l,i=hr(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:Ki(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 vd(l){const e=W.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=fr({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(jd,{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 kd(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:Sn(i.taskId),title:i.taskId,copy:i.taskId}:null,l.runId?{label:"Run",value:Sn(l.runId),title:l.runId,copy:l.runId}:null,l.jobNumber!==null?{label:"Job",value:`#${l.jobNumber}`}:null,l.providerArtifactId?{label:"Request artifact",value:Sn(l.providerArtifactId),title:l.providerArtifactId,copy:l.providerArtifactId}:null].filter(r=>r!==null)}function Sd(l){const e=W.c(8),{facts:s,inspection:n}=l;let i;if(e[0]!==s||e[1]!==n){const a=pr(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=kd(s,n).map(Nd);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(Zc,{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(wd)})]}),e[0]=s,e[1]=n,e[2]=i}else i=e[2];return i}function wd(l){return t.jsxs("li",{children:[t.jsx("span",{children:l.key.replace(/_/g," ")})," ",l.value]},l.key)}function Nd(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(Vi,{text:l.copy,label:`Copy ${l.label.toLowerCase()}`})]})]},l.label)}function Cd(l){const e=W.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 $d(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 Id(l){const e=W.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=Ki(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 y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("span",{className:"inspector-generating-spacer"}),e[7]=y):y=e[7];const x=d?.har;let j;e[8]!==s.providerArtifactId||e[9]!==o||e[10]!==c||e[11]!==x?(j=t.jsx(gd,{generationId:s.providerArtifactId,status:x,onDownload:o,onOpenSettings:c}),e[8]=s.providerArtifactId,e[9]=o,e[10]=c,e[11]=x,e[12]=j):j=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(Un,{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(Vi,{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]!==j||e[22]!==v?(w=t.jsxs("header",{className:"inspector-generating-payload-head",children:[p,g,h,y,j,v,k]}),e[18]=k,e[19]=g,e[20]=h,e[21]=j,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(Gn,{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…":$d(s,n)}),e[24]=a,e[25]=s,e[26]=i,e[27]=n,e[28]=u,e[29]=S):S=e[29];let R;return e[30]!==i||e[31]!==w||e[32]!==S?(R=t.jsxs("aside",{className:"inspector-generating-payload","aria-busy":i,children:[w,S]}),e[30]=i,e[31]=w,e[32]=S,e[33]=R):R=e[33],R}function Tn(l){const e=W.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(vd,{facts:s,inspection:f}),b=t.jsx(Sd,{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=mr(g),e[4]=g,e[5]=h):h=e[5];let y;e[6]!==s.writtenPrompt||e[7]!==h?(y=t.jsx(Cd,{written:p,sent:h}),e[6]=s.writtenPrompt,e[7]=h,e[8]=y):y=e[8];let x;e[9]!==i||e[10]!==n||e[11]!==m||e[12]!==b||e[13]!==y?(x=t.jsxs("div",{className:"inspector-media-generating-summary",children:[n,m,b,y,i]}),e[9]=i,e[10]=n,e[11]=m,e[12]=b,e[13]=y,e[14]=x):x=e[14];let j;e[15]!==a||e[16]!==s||e[17]!==o||e[18]!==d||e[19]!==u||e[20]!==c||e[21]!==r?(j=t.jsx(Id,{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]=j):j=e[22];let v;return e[23]!==x||e[24]!==j?(v=t.jsxs(t.Fragment,{children:[x,j]}),e[23]=x,e[24]=j,e[25]=v):v=e[25],v}function Rd(l){const e=W.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(Tn,{...n,outcome:i,loading:!1}),e[3]=i,e[4]=n,e[5]=a):a=e[5],a}function bf(l){const e=W.c(12),{inspect:s,...n}=l,[i,a]=C.useState(0),r=n.facts.providerArtifactId;if(!s||!r)return t.jsx(Tn,{...n,outcome:null,loading:!1});const o=yd(s,r,`${r}:${n.facts.runKind}:${i}`);let c;e[0]!==a?(c=()=>C.startTransition(()=>a(Md)),e[0]=a,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==n?(u=t.jsx(Tn,{...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(Rd,{...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 Md(l){return l+1}function Zs(l){return`${typeof l}:${String(l)}`}function xf(l){const e=W.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=br(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 R=S,N=u&&R,M=p===!0;let A;e[5]!==r?(A=E=>r(E.target.checked),e[5]=r,e[6]=A):A=e[6];let D;e[7]!==i||e[8]!==a||e[9]!==M||e[10]!==A?(D=t.jsx("input",{type:"checkbox",role:"switch",checked:M,disabled:i,onFocus:a,onChange:A}),e[7]=i,e[8]=a,e[9]=M,e[10]=A,e[11]=D):D=e[11];const T=!u&&R;let I;return e[12]!==s.description||e[13]!==N||e[14]!==D||e[15]!==T||e[16]!==o?(I=t.jsxs("label",{className:o,title:s.description,children:[N,D,T]}),e[12]=s.description,e[13]=N,e[14]=D,e[15]=T,e[16]=o,e[17]=I):I=e[17],I}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 R=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 M=N,A=s.description,D=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 I=s.defaultValue===void 0?s.required?"Select…":"Auto":`Default · ${String(s.defaultValue)}`;let E;e[29]!==I?(E=t.jsx("option",{value:"",children:I}),e[29]=I,e[30]=E):E=e[30];let F;e[31]!==R||e[32]!==m||e[33]!==M?(F=M&&t.jsxs("option",{value:R,children:[String(m)," · incompatible"]}),e[31]=R,e[32]=m,e[33]=M,e[34]=F):F=e[34];let $;e[35]!==s.options?($=s.options.map(Pd),e[35]=s.options,e[36]=$):$=e[36];let P;e[37]!==i||e[38]!==s.label||e[39]!==R||e[40]!==a||e[41]!==E||e[42]!==F||e[43]!==$||e[44]!==T?(P=t.jsxs("select",{"aria-label":D,value:R,disabled:i,onFocus:a,onChange:T,children:[E,F,$]}),e[37]=i,e[38]=s.label,e[39]=R,e[40]=a,e[41]=E,e[42]=F,e[43]=$,e[44]=T,e[45]=P):P=e[45];let L;return e[46]!==s.description||e[47]!==h||e[48]!==P?(L=t.jsxs("label",{title:A,children:[h,P]}),e[46]=s.description,e[47]=h,e[48]=P,e[49]=L):L=e[49],L}const y=s.kind==="number"?"number":"text",x=s.kind==="number"?"any":void 0,j=p===void 0?"":String(p);let v;e[50]!==s.kind||e[51]!==r?(v=S=>{const R=S.target.value;if(!R){r(void 0);return}const N=Number(R);r(s.kind==="number"?Number.isFinite(N)?N:void 0:R)},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]!==y||e[59]!==x||e[60]!==j||e[61]!==v?(k=t.jsx("input",{type:y,"aria-label":s.label,min:s.minimum,max:s.maximum,step:x,value:j,disabled:i,onFocus:a,onChange:v}),e[53]=i,e[54]=s.label,e[55]=s.maximum,e[56]=s.minimum,e[57]=a,e[58]=y,e[59]=x,e[60]=j,e[61]=v,e[62]=k):k=e[62];let w;return e[63]!==s.description||e[64]!==h||e[65]!==k?(w=t.jsxs("label",{title:s.description,children:[h,k]}),e[63]=s.description,e[64]=h,e[65]=k,e[66]=w):w=e[66],w}function Pd(l){return t.jsx("option",{value:Zs(l),children:String(l)},Zs(l))}const qi=[{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 Ws(l,e){const s=l[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0}function hs(l){const e=W.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 gf(l){const e=W.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(Ad,{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 Ad(l){const e=W.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=Ws(n,"start_time"),h=Ws(n,"resume_time"),y=Ws(n,"duration")??Number(i.find(Td)?.defaultValue??5);let x;if(e[0]!==i||e[1]!==n||e[2]!==s){const ee=i.flatMap(Dd);x=xr("fal:minimax/h3-max/insert-video",n,s)??gr(ee,n),e[0]=i,e[1]=n,e[2]=s,e[3]=x}else x=e[3];const j=x,v=!j&&g!==void 0&&h!==void 0,k=v?g+y+p-h:null,w=Math.max(p,k??0);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=ee=>{!c.current||!Number.isFinite(c.current.duration)||(c.current.currentTime=Math.max(0,Math.min(ee,c.current.duration)))},e[4]=S):S=e[4];const R=S;let N;e[5]!==r?(N=(ee,Q)=>{r(ee,Q),Q!==void 0&&ee!=="duration"&&R(Q)},e[5]=r,e[6]=N):N=e[6];const M=N,A="insert-video-editor",D="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 I=o?`Original @${o.address} · ${p>0?bt(p):"duration unavailable"}`:"Choose an original video";let E;e[8]!==I?(E=t.jsxs("header",{children:[T,t.jsx("span",{children:I})]}),e[8]=I,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 $=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:ee=>u(ee.currentTarget.currentTime),onError:()=>m(!0)}),t.jsxs("div",{className:"insert-video-playhead",children:[t.jsxs("span",{children:["Scrub to a cut point · ",bt(d)]}),t.jsx("button",{type:"button",disabled:a||f||d<1.625||d>60||d>=p,onClick:()=>M("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:()=>M("resume_time",Number(d.toFixed(3))),children:"Resume from here"})]})]});let P;e[11]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx("strong",{children:"Original"}),e[11]=P):P=e[11];const L=p>0?bt(p):"—";let _;e[12]!==L?(_=t.jsxs("div",{className:"insert-video-track-heading",children:[P,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 te=k===null?"Result preview unavailable until timing is valid":`Result: ${g}s original opening, ${y}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:y,title:`New scene · ${bt(y)}`}),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]!==te||e[23]!==ae?(V=t.jsx("div",{className:"insert-video-track",role:"img","aria-label":te,children:ae}),e[22]=te,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 G;e[26]!==_||e[27]!==U||e[28]!==K||e[29]!==V?(G=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]=G):G=e[30];let se;e[31]!==$||e[32]!==G?(se=t.jsxs("div",{className:"insert-video-visuals",children:[$,G]}),e[31]=$,e[32]=G,e[33]=se):se=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=qi.map(ee=>{const Q=i.find(ue=>ue.name===ee.name),de=Ws(n,ee.name)??(ee.name==="duration"?y:void 0),fe=ee.name==="duration"?13:Math.min(60,p||60);return t.jsxs("div",{className:"insert-video-field",children:[t.jsx("label",{htmlFor:`${b}-${ee.name}`,children:t.jsxs("span",{children:[ee.label," ",t.jsx("small",{children:"(seconds)"})]})}),t.jsxs("div",{className:"insert-video-time-input",children:[t.jsx("input",{id:`${b}-${ee.name}`,type:"number",step:"any",min:Q?.minimum,max:fe,value:de??"",disabled:a,"aria-describedby":j?b:void 0,"aria-invalid":!!j,onChange:ue=>M(ee.name,ue.target.value===""?void 0:ue.target.valueAsNumber)}),ee.name!=="duration"&&t.jsx("button",{type:"button","aria-label":`View ${ee.label.toLowerCase()} cut point`,disabled:a||de===void 0||de>p||f||!o?.asset?.mediaUrl,onClick:()=>R(de),children:"View"})]}),t.jsx("input",{type:"range","aria-label":`${ee.label} slider`,min:ee.name==="duration"?5:1.625,max:Math.max(ee.name==="duration"?5:1.625,fe),step:"0.001",value:Math.min(fe,Math.max(ee.name==="duration"?5:1.625,de??1.625)),disabled:a||ee.name!=="duration"&&p<=1.625,onChange:ue=>M(ee.name,ue.target.valueAsNumber)}),t.jsx("small",{children:ee.hint})]},ee.name)});let Z;e[36]!==Y?(Z=t.jsx("div",{className:"insert-video-fields",children:Y}),e[36]=Y,e[37]=Z):Z=e[37];const J=j?t.jsx("p",{className:"insert-video-error",id:b,role:"alert",children:j}):v&&t.jsxs("p",{className:"insert-video-summary",role:"status",children:["Replace ",bt(g),"–",bt(h)," of @",o?.address," with ",bt(y)," of new footage. Result: ",bt(k),"."]});let re;return e[38]!==se||e[39]!==le||e[40]!==Z||e[41]!==J||e[42]!==E||e[43]!==F?(re=t.jsxs("section",{className:A,"aria-label":D,children:[E,F,se,le,Z,J]}),e[38]=se,e[39]=le,e[40]=Z,e[41]=J,e[42]=E,e[43]=F,e[44]=re):re=e[44],re}function Dd(l){const e=qi.find(s=>s.name===l.name);return e?[{...l,label:e.label}]:[]}function Td(l){return l.name==="duration"}function Gs(l){const e=W.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 Ed(l){const e=W.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=vr(n.createdAt,i),e[11]=n.createdAt,e[12]=i,e[13]=g):g=e[13];let h;e[14]!==g?(h=t.jsx("span",{className:"prompt-history-faint",children:g}),e[14]=g,e[15]=h):h=e[15];let y;e[16]!==m||e[17]!==b||e[18]!==p||e[19]!==h?(y=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]=y):y=e[20];let x;e[21]!==c||e[22]!==u||e[23]!==y?(x=t.jsxs("button",{type:"button",className:"prompt-history-use",title:"Use this prompt",onClick:c,children:[u,y]}),e[21]=c,e[22]=u,e[23]=y,e[24]=x):x=e[24];const j=a?"Unpin prompt":"Pin prompt",v=a?"Unpin prompt":"Pin prompt";let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(Vo,{size:11,"aria-hidden":"true"}),e[25]=k):k=e[25];let w;e[26]!==o||e[27]!==a||e[28]!==j||e[29]!==v?(w=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-pressed":a,"aria-label":j,title:v,onClick:o,children:k}),e[26]=o,e[27]=a,e[28]=j,e[29]=v,e[30]=w):w=e[30];let S;return e[31]!==d||e[32]!==x||e[33]!==w?(S=t.jsxs("li",{className:"prompt-history-row","data-active":d,children:[x,w]}),e[31]=d,e[32]=x,e[33]=w,e[34]=S):S=e[34],S}function Fd(l){const e=W.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=yr(jr(s.entries??[],s.query),s.pins);const N=Math.min(n,Math.max(0,b.length-1)),M=s.loadedAt;let A;e[11]!==s.surface?(A=ci(s.surface),e[11]=s.surface,e[12]=A):A=e[12];const D=A,T=re=>{if(re.key==="Escape"){re.preventDefault(),re.stopPropagation(),s.close();return}if(re.key==="ArrowDown"||re.key==="ArrowUp"){re.preventDefault();const ee=re.key==="ArrowDown"?1:-1;i(Math.min(Math.max(N+ee,0),Math.max(0,b.length-1)));return}if(re.key==="Enter"&&re.target instanceof HTMLInputElement){const ee=b[N];if(!ee)return;re.preventDefault(),re.stopPropagation(),s.use(ee.prompt)}};c="prompt-history-popover",d="dialog",u="Prompt history",f=T;let I,E;e[13]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("span",{className:"confirm-section-label",children:"Prompt history"}),E=t.jsx("span",{className:"prompt-history-faint",children:"newest first"}),e[13]=I,e[14]=E):(I=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 $;e[16]!==s.close?($=t.jsxs("div",{className:"prompt-history-title",children:[I,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]=$):$=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(rs,{size:11,"aria-hidden":"true"}),e[18]=P):P=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:[P,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(Gs,{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(Gs,{active:q,label:"All books",onClick:H}),e[31]=q,e[32]=H,e[33]=K):K=e[33];let te;e[34]!==U||e[35]!==K?(te=t.jsxs("span",{className:"prompt-history-segments",role:"group","aria-label":"Scope",children:[U,K]}),e[34]=U,e[35]=K,e[36]=te):te=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]!==D||e[40]!==ae||e[41]!==V?(oe=t.jsx(Gs,{active:ae,label:D,onClick:V}),e[39]=D,e[40]=ae,e[41]=V,e[42]=oe):oe=e[42];const G=s.surfaceFilter==="all";let se;e[43]!==s?(se=()=>s.setSurfaceFilter("all"),e[43]=s,e[44]=se):se=e[44];let le;e[45]!==G||e[46]!==se?(le=t.jsx(Gs,{active:G,label:"All surfaces",onClick:se}),e[45]=G,e[46]=se,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 Z;e[51]!==_||e[52]!==te||e[53]!==Y?(Z=t.jsxs("div",{className:"prompt-history-filters",children:[_,te,Y]}),e[51]=_,e[52]=te,e[53]=Y,e[54]=Z):Z=e[54],e[55]!==$||e[56]!==Z?(m=t.jsxs("div",{className:"prompt-history-head",children:[$,Z]}),e[55]=$,e[56]=Z,e[57]=m):m=e[57],a="prompt-history-list",r=s.loading;let J;e[58]!==N||e[59]!==s||e[60]!==M?(J=(re,ee)=>t.jsx(Ed,{active:ee===N,entry:re,now:M,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]=M,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,y;e[72]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("kbd",{children:"↑"}),y=t.jsx("kbd",{children:"↓"}),e[72]=h,e[73]=y):(h=e[72],y=e[73]);let x;e[74]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("kbd",{children:"↵"}),e[74]=x):x=e[74];let j,v;e[75]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("kbd",{children:"⌥↑"}),v=t.jsx("kbd",{children:"⌥↓"}),e[75]=j,e[76]=v):(j=e[75],v=e[76]);let k;e[77]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsxs("span",{children:[h,y," move · ",x," use · ",j,v," step in the prompt · ",t.jsx("kbd",{children:"esc"})," close"]}),e[77]=k):k=e[77];const w=s.entries?.length??0;let S;e[78]!==w||e[79]!==b.length?(S=t.jsxs("div",{className:"prompt-history-foot",children:[k,t.jsxs("span",{children:[b.length," of ",w]})]}),e[78]=w,e[79]=b.length,e[80]=S):S=e[80];let R;return e[81]!==g||e[82]!==S||e[83]!==c||e[84]!==d||e[85]!==u||e[86]!==f||e[87]!==m?(R=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]=R):R=e[88],R}function yf(l){const e=W.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(As,{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,y;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Hn,{size:11,"aria-hidden":"true"}),y=t.jsx("span",{children:"History"}),e[16]=h,e[17]=y):(h=e[16],y=e[17]);let x;e[18]!==s.entries?(x=s.entries&&t.jsx("span",{className:"prompt-history-count",children:s.entries.length}),e[18]=s.entries,e[19]=x):x=e[19];let j;e[20]!==s.open||e[21]!==s.toggleOpen||e[22]!==a||e[23]!==x?(j=t.jsxs("button",{type:"button",className:"prompt-history-toggle","aria-expanded":s.open,"aria-haspopup":"dialog",disabled:a,onClick:s.toggleOpen,children:[h,y,x]}),e[20]=s.open,e[21]=s.toggleOpen,e[22]=a,e[23]=x,e[24]=j):j=e[24];let v;e[25]!==s?(v=s.open&&t.jsx(Fd,{history:s}),e[25]=s,e[26]=v):v=e[26];let k;return e[27]!==o||e[28]!==g||e[29]!==j||e[30]!==v||e[31]!==c?(k=t.jsxs("div",{className:"prompt-history-controls",onBlur:o,children:[c,g,j,v]}),e[27]=o,e[28]=g,e[29]=j,e[30]=v,e[31]=c,e[32]=k):k=e[32],k}function _d(l){return l instanceof HTMLElement?{tagName:l.tagName,type:l instanceof HTMLInputElement?l.type:null}:null}function Ld(l){const e=W.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 zd(l){const e=W.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=kr({key:p.key,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,defaultPrevented:p.defaultPrevented,target:_d(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 Xn(l){const e=W.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:Od,children:n}),e[0]=n,e[1]=s,e[2]=i):i=e[2],i}function Od(l){return l.stopPropagation()}function Bd(l){const e=W.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(Xn,{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 Ud(l){const e=W.c(7),{inputs:s}=l;let n;e[0]!==s?(n=di(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i)return null;let a;e[2]!==i?(a=t.jsx(Bd,{presentation:i}),e[2]=i,e[3]=a):a=e[3];let 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 jf(l){const e=W.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(Xn,{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(Hd)}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 Hd(l,e){return t.jsxs("p",{children:[t.jsxs("span",{children:["Reply ",e+1]}),t.jsx(Xn,{href:l.tweetUrl,children:l.tweetUrl})]},l.tweetId)}function Kd(l){return l==="copied"?"Copied":l==="failed"?"Retry":"Copy"}function Vd(l){const e=W.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 qd(l){const e=W.c(6),{label:s,running:n,disabled:i,onClick:a}=l;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ci,{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 Wd(l){const e=W.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=W.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,y]=C.useState(null),[x,j]=C.useState(null),[v,k]=C.useState(!1);let w,S,R,N,M,A,D,T,I;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){I=Pr(i,u);let me;e[17]!==i?(me=Nr(i),e[17]=i,e[18]=me):me=e[18],N=me,A=s==="elevenlabs",T=s==="elevenlabs"?o:void 0;let be;e[19]!==A||e[20]!==i?(be=A&&Cr(i),e[19]=A,e[20]=i,e[21]=be):be=e[21],S=be,w=$r({source:s,transcript:i,view:I,jsonText:p}),M=Ir({transcript:i,view:I,jsonFile:h}),R=Rr({source:s,transcript:i,view:I,jsonText:p}),D=Mr({source:s,transcript:i,view:I,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]=R,e[11]=N,e[12]=M,e[13]=A,e[14]=D,e[15]=T,e[16]=I}else w=e[8],S=e[9],R=e[10],N=e[11],M=e[12],A=e[13],D=e[14],T=e[15],I=e[16];const E=D,F=!!i,$=!!R;let P;e[22]!==R?(P=async()=>{if(R)try{await navigator.clipboard.writeText(R),b("copied")}catch{b("failed")}},e[22]=R,e[23]=P):P=e[23];const L=P;let _;e[24]!==F||e[25]!==v||e[26]!==p||e[27]!==c||e[28]!==s?(_=me=>{me==="json"&&!F||(f(me),!(me!=="json"||p!==null||v||!c)&&(k(!0),j(null),c(s).then(be=>{g(be.text),y(be.file)}).catch(be=>{j(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]!==$||e[33]!==L||e[34]!==m||e[35]!==n?(U=$&&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:Kd(m)})]}),e[32]=$,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]!==A?(q=A&&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]=A,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(qd,{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 te;e[51]!==O||e[52]!==K?(te=t.jsxs("header",{className:"inspector-insight-header",children:[O,K]}),e[51]=O,e[52]=K,e[53]=te):te=e[53];const ae=`${n} view`,V=I==="text",oe=I==="text"?"inspector-transcript-tab active":"inspector-transcript-tab";let G;e[54]!==z?(G=()=>z("text"),e[54]=z,e[55]=G):G=e[55];let se;e[56]!==V||e[57]!==oe||e[58]!==G?(se=t.jsx("button",{type:"button",role:"tab","aria-selected":V,className:oe,onClick:G,children:"TEXT"}),e[56]=V,e[57]=oe,e[58]=G,e[59]=se):se=e[59];const le=I==="json",Y=!F,Z=!F,J=F?"JSON":s==="plain"?"No GPT-4o translation":"No ElevenLabs transcript",re=I==="json"?"inspector-transcript-tab active":"inspector-transcript-tab";let ee;e[60]!==z?(ee=()=>z("json"),e[60]=z,e[61]=ee):ee=e[61];let Q;e[62]!==le||e[63]!==Y||e[64]!==Z||e[65]!==J||e[66]!==re||e[67]!==ee?(Q=t.jsx("button",{type:"button",role:"tab","aria-selected":le,"aria-disabled":Y,disabled:Z,title:J,className:re,onClick:ee,children:"JSON"}),e[62]=le,e[63]=Y,e[64]=Z,e[65]=J,e[66]=re,e[67]=ee,e[68]=Q):Q=e[68];let de;e[69]!==ae||e[70]!==se||e[71]!==Q?(de=t.jsxs("div",{className:"inspector-transcript-tabs",role:"tablist","aria-label":ae,children:[se,Q]}),e[69]=ae,e[70]=se,e[71]=Q,e[72]=de):de=e[72];let fe;e[73]!==M?(fe=M&&t.jsx("p",{className:"inspector-insight-meta",children:M}),e[73]=M,e[74]=fe):fe=e[74];let ue;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]!==I?(ue=w&&!E?t.jsx(Vd,{text:w,label:`${n} ${I}`}):t.jsxs("div",{className:"inspector-insight-empty",children:[t.jsx("p",{children:E??"No transcript yet."}),T&&!N&&t.jsx(Wd,{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]=I,e[84]=ue):ue=e[84];let pe;return e[85]!==de||e[86]!==fe||e[87]!==ue||e[88]!==te||e[89]!==n?(pe=t.jsxs("section",{className:"inspector-insight-block","aria-label":n,children:[te,de,fe,ue]}),e[85]=de,e[86]=fe,e[87]=ue,e[88]=te,e[89]=n,e[90]=pe):pe=e[90],pe}function vf(l){const e=W.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:Sr,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:wr,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(Ni,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:r})]}),e[13]=r,e[14]=h):h=e[14];let y;return e[15]!==m||e[16]!==g||e[17]!==h?(y=t.jsxs("div",{className:"inspector-media-insights",children:[m,g,h]}),e[15]=m,e[16]=g,e[17]=h,e[18]=y):y=e[18],y}function kf(l){const e=W.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}=Ar(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($i,{size:13,"aria-hidden":"true"}),e[6]=g):g=e[6];const h=f&&c.action==="copy"?"Copying…":`Copy ${i}`;let y;e[7]!==m||e[8]!==b||e[9]!==p||e[10]!==h?(y=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":b,title:"Copy the original media file to the clipboard",onClick:p,children:[g,h]}),e[7]=m,e[8]=b,e[9]=p,e[10]=h,e[11]=y):y=e[11];const x=f&&c.action==="download";let j;e[12]!==u?(j=()=>{u("download")},e[12]=u,e[13]=j):j=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(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]!==j?(w=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":x,title:"Save the original media file to Downloads",onClick:j,children:[v,k]}),e[15]=m,e[16]=k,e[17]=x,e[18]=j,e[19]=w):w=e[19];let S;e[20]!==w||e[21]!==y?(S=t.jsxs("div",{className:"inspector-media-file-buttons",children:[y,w]}),e[20]=w,e[21]=y,e[22]=S):S=e[22];let R;e[23]!==c.message||e[24]!==c.phase?(R=c.phase==="done"&&t.jsx("p",{role:"status",children:c.message}),e[23]=c.message,e[24]=c.phase,e[25]=R):R=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 M;return e[29]!==S||e[30]!==R||e[31]!==N?(M=t.jsxs("section",{className:"inspector-media-file-actions","aria-label":"Media file actions",children:[S,R,N]}),e[29]=S,e[30]=R,e[31]=N,e[32]=M):M=e[32],M}const Gd={people:"People",places:"Places",editing:"Editing",custom:"Custom"};function Sf(l){const e=W.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 y;e[0]!==s?.effective?(y=s?.effective??[],e[0]=s?.effective,e[1]=y):y=e[1];let x;e[2]!==y?(x=ui(y),e[2]=y,e[3]=x):x=e[3];const j=x;let v;e[4]!==s?.dismissed?(v=s?.dismissed??[],e[4]=s?.dismissed,e[5]=v):v=e[5];const k=v;let w;e[6]!==a||e[7]!==b||e[8]!==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 R;e[11]!==S||e[12]!==b||e[13]!==u?(R=function(_){if(_.key==="Enter"){_.preventDefault(),S();return}_.key==="Escape"&&b&&(_.preventDefault(),p(""),u(""))},e[11]=S,e[12]=b,e[13]=u,e[14]=R):R=e[14];const N=R;let M;if(e[15]!==a||e[16]!==j||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],M=j.map(L),e[15]=a,e[16]=j,e[17]=c,e[18]=M}else M=e[18];let A;e[22]!==j.length||e[23]!==f?(A=j.length===0?t.jsx("span",{className:"asset-tag-empty",children:f??"No tags yet"}):null,e[22]=j.length,e[23]=f,e[24]=A):A=e[24];let D;e[25]!==M||e[26]!==A?(D=t.jsxs("div",{className:"asset-tag-chips",role:"list",children:[M,A]}),e[25]=M,e[26]=A,e[27]=D):D=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(Xd)}),t.jsx("button",{type:"button",className:"asset-tag-add",onClick:S,disabled:!b.trim(),"aria-label":"Add tag",children:t.jsx(es,{size:12})})]}):null,e[28]=a,e[29]=S,e[30]=b,e[31]=N,e[32]=h,e[33]=u,e[34]=r,e[35]=T):T=e[35];let I;e[36]!==D||e[37]!==T?(I=t.jsxs("div",{className:"asset-tag-row",children:[D,T]}),e[36]=D,e[37]=T,e[38]=I):I=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(Un,{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 $;e[46]!==n?($=n?t.jsx("span",{className:"sr-only",role:"status",children:"Saving tags"}):null,e[46]=n,e[47]=$):$=e[47];let P;return e[48]!==I||e[49]!==E||e[50]!==F||e[51]!==$?(P=t.jsxs("section",{className:"asset-tag-editor","aria-label":"Asset tags",children:[I,E,F,$]}),e[48]=I,e[49]=E,e[50]=F,e[51]=$,e[52]=P):P=e[52],P}function Xd(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 ya(ja(l))}const Yd={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 Jd(l){const e=W.c(5),{value:s,colorScheme:n}=l,i=Yd[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 Qd={Zap:ec,Sparkles:Pi,Scissors:Vn,Mic:Si,Check:Qt,Clapperboard:Zo,Mailbox:Qo,ClipboardCopy:$i,Columns3:Mi,FolderOpen:Jo,History:Hn,Eye:Ri,Users:Yo,Archive:Xo,NotebookPen:Go,Rows3:Ii,Stethoscope:Wo,Images:Kn};function Zd(l){return Qd[l]}const Yt=8,En=320,Bl=80,wn=2,eu=460;function tu(l,e,s,n){const i=l.top-Yt*2,a=e.height-l.bottom-Yt*2,r=s?i>=Math.min(En,a)||i>a:a<Bl+wn&&i>a,c=Math.max(Bl,Math.min(En,(r?i:a)-wn)),d=c+wn,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 su(l){return l?.closest("dialog[open]")??document.body}function nu(l,e,s){const n=l.getBoundingClientRect();return tu({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 lu(l){const e=W.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 wf(l){const e=W.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,y]=C.useState(g),x=r!=null;let j,v;e[1]!==n?(j=()=>{u.current?.querySelector(`[data-option-index="${n}"]`)?.scrollIntoView({block:"nearest"})},v=[n],e[1]=n,e[2]=j,e[3]=v):(j=e[2],v=e[3]),C.useEffect(j,v);let k;e[4]!==r||e[5]!==d||e[6]!==x||e[7]!==c?(k=()=>{if(!x||!r)return;const H=()=>{const K=r.current;K&&(m(nu(K,d,c)),p(su(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",R=x&&f?.placeAbove&&"origin-bottom",N=x&&f&&!f.placeAbove&&"origin-top";let M;e[15]!==S||e[16]!==R||e[17]!==N?(M=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,R,N),e[15]=S,e[16]=R,e[17]=N,e[18]=M):M=e[18];const A=M;let D;e[19]!==f||e[20]!==x?(D=x&&f?{position:"fixed",top:f.top,left:f.left,width:f.width,zIndex:eu}:void 0,e[19]=f,e[20]=x,e[21]=D):D=e[21];const T=D;let I,E,F,$,P,L,_,z;if(e[22]!==h||e[23]!==s||e[24]!==A||e[25]!==T||e[26]!==a||e[27]!==i||e[28]!==f?.maxHeight||e[29]!==n){const H=s.map(ou),K=H.filter(ru),te=H.filter(au);L=A,_=T,z=iu,I=u,E="overflow-y-auto";const ae=f?.maxHeight??En;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:G,index:se}=oe,le=G.icon?Zd(G.icon):void 0,Y=G.thumbnailSrc&&!h.includes(G.thumbnailSrc)?G.thumbnailSrc:null,Z=G.type==="mention",J=Y!==null||G.mediaKind!==void 0;return t.jsxs("button",{type:"button","data-option-index":se,className:Qs("w-full h-10 px-3 text-left text-sm transition-colors flex items-center gap-3",se===n?"bg-primary/20 text-primary shadow-[inset_2px_0_0_var(--color-primary)]":"text-foreground hover:bg-white/5"),onClick:()=>i(G),onMouseEnter:()=>a(se),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:()=>y(re=>re.includes(Y)?re:[...re,Y])}):t.jsx(lu,{kind:G.mediaKind})}),t.jsx(Jd,{value:G.label,colorScheme:G.colorScheme}),G.example&&G.example!==G.value?t.jsx("span",{className:"text-muted-foreground/50 text-xs font-mono min-w-0 flex-1 truncate",children:G.example.replace(G.value,"").trimStart()}):Z?t.jsx("span",{className:"text-xs min-w-0 flex-1 truncate text-[#cde8da]",children:G.caption}):t.jsx("span",{className:"text-muted-foreground text-xs min-w-0 flex-1 truncate",children:G.description}),Z&&G.description&&t.jsx("span",{className:"shrink-0 text-[10px] tracking-[0.1em] text-[#8fb9a1]",children:G.description}),le&&!J&&t.jsx(le,{className:"size-3 shrink-0 opacity-50"})]},`${G.value}-${se}`)},e[40]=h,e[41]=a,e[42]=i,e[43]=n,e[44]=V):V=e[44],$=K.map(V),P=te.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"}),te.map(oe=>{const{item:G,index:se}=oe;return t.jsx("button",{type:"button","data-option-index":se,title:G.description,className:Qs("shrink-0 rounded-sm border border-dashed px-1.5 py-0.5 font-mono text-xs font-bold transition-colors",se===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(G),onMouseEnter:()=>a(se),children:G.label},`${G.value}-${se}`)})]}),e[22]=h,e[23]=s,e[24]=A,e[25]=T,e[26]=a,e[27]=i,e[28]=f?.maxHeight,e[29]=n,e[30]=I,e[31]=E,e[32]=F,e[33]=$,e[34]=P,e[35]=L,e[36]=_,e[37]=z}else I=e[30],E=e[31],F=e[32],$=e[33],P=e[34],L=e[35],_=e[36],z=e[37];let O;e[45]!==I||e[46]!==E||e[47]!==F||e[48]!==$||e[49]!==P?(O=t.jsxs("div",{ref:I,className:E,style:F,children:[$,P]}),e[45]=I,e[46]=E,e[47]=F,e[48]=$,e[49]=P,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 iu(l){return l.preventDefault()}function au(l){const{item:e}=l;return e.empty}function ru(l){const{item:e}=l;return!e.empty}function ou(l,e){return{item:l,index:e}}function cu(l){const e=W.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 y=h.slice(0,r);o=h.length-y.length;const x=new Set(g.map(du));c="asset-tag-summary",d="list",u="Tags";let j;e[10]!==x||e[11]!==i?(j=v=>{const k=`${v.facet}/${v.key}`,w=x.has(k);return i?t.jsx("button",{type:"button",role:"listitem",className:"asset-tag-summary-chip asset-tag-summary-chip-action","aria-pressed":w,title:w?`Remove filter ${v.label}`:`Filter by ${v.label}`,onClick:()=>i(Dr(v)),children:v.label},k):t.jsx("span",{className:"asset-tag-summary-chip",role:"listitem",children:v.label},k)},e[10]=x,e[11]=i,e[12]=j):j=e[12],f=y.map(j)}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 du(l){return`${l.facet}/${l.key}`}function uu(l){const e=W.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=Tr(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,y=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 j=x;let v;e[7]!==j?(v=O=>{O.preventDefault(),O.stopPropagation(),j([...O.dataTransfer.files])},e[7]=j,e[8]=v):v=e[8];const k=v;let w;e[9]!==p||e[10]!==j?(w=O=>{const U=[...O.clipboardData.files],q=U.length>0?U:[...O.clipboardData.items].flatMap(fu);q.some(H=>yl(H,p))&&(O.preventDefault(),O.stopPropagation(),j(q))},e[9]=p,e[10]=j,e[11]=w):w=e[11];const S=w;let R;e[12]!==h||e[13]!==p||e[14]!==i||e[15]!==n?(R=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]=R):R=e[16];const N=i?`Preparing ${p}…`:n?n.name:`Drop or paste ${g}`;let M;e[17]!==N?(M=t.jsx("strong",{children:N}),e[17]=N,e[18]=M):M=e[18];const A=n?"Temporary search reference":`Choose ${g} file, drag it here, or paste from the clipboard`;let D;e[19]!==A?(D=t.jsx("span",{children:A}),e[19]=A,e[20]=D):D=e[20];let T;e[21]!==M||e[22]!==D?(T=t.jsxs("div",{children:[M,D]}),e[21]=M,e[22]=D,e[23]=T):T=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(sn,{size:14}),e[24]=I):I=e[24];const 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 $;e[27]!==y||e[28]!==E||e[29]!==F?($=t.jsxs("label",{className:"reverse-search-upload",children:[I,"Choose file",t.jsx("input",{type:"file",accept:y,disabled:E,onChange:F})]}),e[27]=y,e[28]=E,e[29]=F,e[30]=$):$=e[30];let P;e[31]!==a||e[32]!==u||e[33]!==i||e[34]!==n?(P=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]=P):P=e[35];let L;e[36]!==T||e[37]!==$||e[38]!==P||e[39]!==R?(L=t.jsxs("div",{className:"reverse-search-dropzone",tabIndex:0,autoFocus:!0,children:[R,T,$,P]}),e[36]=T,e[37]=$,e[38]=P,e[39]=R,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:mu,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 mu(l){l.dataTransfer.types.includes("Files")&&l.preventDefault()}function fu(l){const e=l.kind==="file"?l.getAsFile():null;return e?[e]:[]}const pu=[{id:"text",label:"Text",icon:rs},{id:"image-reverse",label:"Image reverse",icon:Zt},{id:"video-reverse",label:"Vid reverse",icon:St}];function Fn(l){return l==="all"?"media":l==="audio"?"audio":`${l}s`}function hu(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 bu(l){return l.mode!=="text"?"Most similar":l.query.trim()?"Best match":"Recently used"}function xu(l){return l.type==="image"||l.type==="video"||l.type==="final"}function gu(l){const e=W.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=hu(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(ld,{asset:s}),e[5]=s,e[6]=g):g=e[6];let h;e[7]!==m?(h=t.jsx("strong",{children:m}),e[7]=m,e[8]=h):h=e[8];const y=s.owningBookId===i?" · this book":" · copy";let x;e[9]!==s.owningBookName||e[10]!==y?(x=t.jsxs("small",{children:[s.owningBookName,y]}),e[9]=s.owningBookName,e[10]=y,e[11]=x):x=e[11];let j;e[12]!==h||e[13]!==x?(j=t.jsxs("span",{className:"media-library-asset-copy",children:[h,x]}),e[12]=h,e[13]=x,e[14]=j):j=e[14];let v;e[15]!==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(cu,{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=xu(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 R=`Use ${m} from ${s.owningBookName}`,N=`Use ${m}`;let M;e[27]!==s||e[28]!==o?(M=()=>o(s),e[27]=s,e[28]=o,e[29]=M):M=e[29];let A;e[30]!==a||e[31]!==R||e[32]!==N||e[33]!==M?(A=t.jsx("button",{type:"button",className:"media-library-asset-use",disabled:a,"aria-label":R,title:N,onClick:M}),e[30]=a,e[31]=R,e[32]=N,e[33]=M,e[34]=A):A=e[34];let D;e[35]!==S||e[36]!==A?(D=t.jsxs("span",{className:"media-library-asset-actions",children:[S,A]}),e[35]=S,e[36]=A,e[37]=D):D=e[37];let T;return e[38]!==w||e[39]!==D||e[40]!==g||e[41]!==j||e[42]!==v||e[43]!==k?(T=t.jsxs("article",{className:"media-library-asset",children:[g,j,v,k,w,D]}),e[38]=w,e[39]=D,e[40]=g,e[41]=j,e[42]=v,e[43]=k,e[44]=T):T=e[44],T}function yu(l){const e=W.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 y=s.tagSuggestions.find(x=>x.label.toLowerCase()===h.toLowerCase());y&&(n({facet:y.facet,key:y.key,label:y.label}),g.currentTarget.value="")},e[3]=n,e[4]=s.tagSuggestions,e[5]=c):c=e[5];let d;e[6]!==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(ju),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 ju(l){return t.jsx("option",{value:l.label,children:`${l.facet} · ${l.assets}`},`${l.facet}/${l.key}`)}function vu(l){const e=W.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 ku(l){const e=W.c(10),{state:s,kind:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(nn,{size:22}),e[0]=i):i=e[0];let a;e[1]!==n?(a=Fn(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 Nf(l){const e=W.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,[y]=C.useState(Su);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 j=x,v=n==="all"?"Choose library media":`Choose ${n} media`;let k;e[3]!==h||e[4]!==n||e[5]!==c||e[6]!==d||e[7]!==s.draftQuery||e[8]!==s.mode?(k=s.mode==="text"?t.jsxs("form",{className:"media-library-search",role:"search",onSubmit:V=>{V.preventDefault(),h||d()},children:[t.jsx(rs,{size:14,"aria-hidden":"true"}),t.jsx("input",{type:"search",value:s.draftQuery,"aria-label":"Search library",placeholder:`Search ${Fn(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:pu.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(yu,{...l}),e[15]=l,e[16]=S):S=e[16];let R;e[17]===Symbol.for("react.memo_cache_sentinel")?(R=()=>g.current?.click(),e[17]=R):R=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 M=s.uploading?"Uploading…":"Upload";let A;e[20]!==h||e[21]!==N||e[22]!==M?(A=t.jsxs("button",{type:"button",className:"media-library-upload",disabled:h,onClick:R,children:[N,M]}),e[20]=h,e[21]=N,e[22]=M,e[23]=A):A=e[23];let D;e[24]!==m?(D=V=>{const oe=V.target.files?.[0];V.target.value="",oe&&m(oe)},e[24]=m,e[25]=D):D=e[25];let T;e[26]!==i||e[27]!==D?(T=t.jsx("input",{ref:g,className:"media-library-upload-input",type:"file",accept:i,tabIndex:-1,"aria-hidden":"true",onChange:D}),e[26]=i,e[27]=D,e[28]=T):T=e[28];let I;e[29]!==T||e[30]!==k||e[31]!==w||e[32]!==S||e[33]!==A?(I=t.jsxs("div",{className:"media-library-toolbar",children:[k,w,S,A,T]}),e[29]=T,e[30]=k,e[31]=w,e[32]=S,e[33]=A,e[34]=I):I=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(uu,{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 $;e[49]!==h||e[50]!==l.onRepairIndexes||e[51]!==s?($=t.jsx(vu,{state:s,busy:h,onRepairIndexes:l.onRepairIndexes}),e[49]=h,e[50]=l.onRepairIndexes,e[51]=s,e[52]=$):$=e[52];let P;e[53]!==h||e[54]!==n||e[55]!==y||e[56]!==f||e[57]!==b||e[58]!==p||e[59]!==s||e[60]!==a?(P=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(ku,{state:s,kind:n}):t.jsx("div",{className:"media-library-grid",children:s.assets.map(V=>t.jsx(gu,{asset:V,state:s,targetBookId:a,busy:h,now:y,onAttach:f,onSimilar:b,onToggleTagFilter:p},`${V.owningBookId}:${V.artifactId}`))}),e[53]=h,e[54]=n,e[55]=y,e[56]=f,e[57]=b,e[58]=p,e[59]=s,e[60]=a,e[61]=P):P=e[61];let L;e[62]!==F||e[63]!==$||e[64]!==P?(L=t.jsxs("div",{className:"media-library-results","aria-busy":F,children:[$,P]}),e[62]=F,e[63]=$,e[64]=P,e[65]=L):L=e[65];let _;e[66]!==s?(_=bu(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=Fn(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 te;e[83]!==H||e[84]!==K?(te=t.jsxs("footer",{className:"media-library-footer",children:[H,K]}),e[83]=H,e[84]=K,e[85]=te):te=e[85];let ae;return e[86]!==j||e[87]!==v||e[88]!==I||e[89]!==E||e[90]!==L||e[91]!==te?(ae=t.jsxs("section",{className:"media-library-panel","aria-label":v,onKeyDown:j,children:[I,E,L,te]}),e[86]=j,e[87]=v,e[88]=I,e[89]=E,e[90]=L,e[91]=te,e[92]=ae):ae=e[92],ae}function Su(){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 wu(l){return l instanceof Error?l.message:String(l)}function Nu(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 Cu(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 Nn(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 Kr(l.clientX,l.clientY,n.getBoundingClientRect())}function $u(l){const e=W.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:y,onPointerMove:x,onPointerUp:j,onCancelDraw:v}=l;let k;e[0]!==a?.subjects?(k=a?.subjects??[],e[0]=a?.subjects,e[1]=k):k=e[1];const w=k;if(n<=0||i<=0){let $;return e[2]!==s?($=t.jsx("img",{src:s,alt:""}),e[2]=s,e[3]=$):$=e[3],$}const S=`notebook-subject-stage-svg${u?" drawing":""}`,R=`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 M;e[8]!==u||e[9]!==i||e[10]!==n?(M=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]=M):M=e[11];let A;if(e[12]!==i||e[13]!==w||e[14]!==n){let $;e[16]!==i||e[17]!==n?($=(P,L)=>P.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:P.layerUrl,width:n,height:i,preserveAspectRatio:"none"})},P.id):null,e[16]=i,e[17]=n,e[18]=$):$=e[18],A=w.map($),e[12]=i,e[13]=w,e[14]=n,e[15]=A}else A=e[15];let D;e[19]!==A?(D=t.jsx("defs",{children:A}),e[19]=A,e[20]=D):D=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 $;e[30]!==u||e[31]!==i||e[32]!==o||e[33]!==p||e[34]!==b||e[35]!==r||e[36]!==n?($=(P,L)=>{if(o.has(P.id))return null;const _=Nu(P,n,i),z=r.has(P.id);return t.jsxs("g",{className:`notebook-subject-overlay${z?" selected":""}`,onClick:O=>{u||(O.stopPropagation(),p(P.id))},onKeyDown:O=>{u||O.key!=="Enter"&&O.key!==" "||(O.preventDefault(),p(P.id))},role:"button",tabIndex:u?-1:0,"aria-label":`${z?"Deselect":"Select"} ${P.label}`,"aria-pressed":z,children:[t.jsx("title",{children:P.label}),P.layerUrl?t.jsx("rect",{width:n,height:i,fill:P.color,fillOpacity:z?Math.min(.9,b+.18):b,mask:`url(#notebook-subject-mask-${L})`,pointerEvents:"none"}):_?t.jsx("rect",{..._,fill:P.color,fillOpacity:z?Math.min(.72,b+.14):b,pointerEvents:"none"}):null,_&&t.jsx("rect",{..._,className:"notebook-subject-outline",fill:"none",stroke:z?"#ffffff":P.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"})]},P.id)},e[30]=u,e[31]=i,e[32]=o,e[33]=p,e[34]=b,e[35]=r,e[36]=n,e[37]=$):$=e[37],T=w.map($),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 I;if(e[38]!==u||e[39]!==i||e[40]!==h||e[41]!==g||e[42]!==c||e[43]!==d||e[44]!==m||e[45]!==n){let $;e[47]!==u||e[48]!==i||e[49]!==h||e[50]!==g||e[51]!==d||e[52]!==m||e[53]!==n?($=(P,L)=>{const _=Cu(P,n,i),z=d.has(P.id);return t.jsxs("g",{className:`notebook-subject-overlay notebook-region-overlay${z?" selected":""}`,onClick:O=>{u||(O.stopPropagation(),g(P.id))},onPointerEnter:()=>h(P.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:P.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===P.id&&t.jsx("title",{children:"Snap to nearby subject available"})]},P.id)},e[47]=u,e[48]=i,e[49]=h,e[50]=g,e[51]=d,e[52]=m,e[53]=n,e[54]=$):$=e[54],I=c.map($),e[38]=u,e[39]=i,e[40]=h,e[41]=g,e[42]=c,e[43]=d,e[44]=m,e[45]=n,e[46]=I}else I=e[46];let 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]!==y||e[61]!==x||e[62]!==j||e[63]!==E||e[64]!==S||e[65]!==R||e[66]!==N||e[67]!==M||e[68]!==D||e[69]!==T||e[70]!==I?(F=t.jsxs("svg",{className:S,viewBox:R,preserveAspectRatio:"xMidYMid meet",role:"group","aria-label":"Image with detected subject overlays",onPointerDown:y,onPointerMove:x,onPointerUp:j,onPointerCancel:v,onLostPointerCapture:v,children:[N,M,D,T,I,E]}),e[59]=v,e[60]=y,e[61]=x,e[62]=j,e[63]=E,e[64]=S,e[65]=R,e[66]=N,e[67]=M,e[68]=D,e[69]=T,e[70]=I,e[71]=F):F=e[71],F}function Iu(l){const e=W.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 Ru(l){const e=W.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 y;e[8]!==h?(y=t.jsx("p",{children:h}),e[8]=h,e[9]=y):y=e[9];let x;return e[10]!==m||e[11]!==p||e[12]!==y?(x=t.jsxs("div",{className:m,children:[p,g,y]}),e[10]=m,e[11]=p,e[12]=y,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(jn,{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 y;e[17]!==h?(y=t.jsx("p",{children:h}),e[17]=h,e[18]=y):y=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 j;e[21]!==f?(j=()=>f(),e[21]=f,e[22]=j):j=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(jn,{size:13}),e[23]=v):v=e[23];let k;e[24]!==j?(k=t.jsxs("button",{type:"button",onClick:j,children:[v,"Retry"]}),e[24]=j,e[25]=k):k=e[25];let w;return e[26]!==m||e[27]!==k||e[28]!==p||e[29]!==y||e[30]!==x?(w=t.jsxs("div",{className:m,children:[p,g,y,x,k]}),e[26]=m,e[27]=k,e[28]=p,e[29]=y,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(jn,{size:13}),e[37]=h):h=e[37];let y;return e[38]!==g?(y=t.jsxs("div",{className:"notebook-subject-state empty",children:[m,b,p,t.jsxs("button",{type:"button",onClick:g,children:[h,"Analyze again"]})]}),e[38]=g,e[39]=y):y=e[39],y}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 Mu(l){const e=W.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 Cf({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:y,onEditingChange:x,onEditSubjects:j,onSubmitInstruction:v,onBack:k,onClose:w}){const S=C.useId(),R=C.useId(),N=C.useId(),M=C.useRef(!1),A=C.useRef(null),[D,T]=C.useState(()=>new Set),[I,E]=C.useState(()=>new Set),[F,$]=C.useState(()=>[...c??[]]),[P,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,te]=C.useState({}),[ae,V]=C.useState(!1),[oe,G]=C.useState(!1),[se,le]=C.useState(.42),[Y,Z]=C.useState(null),[J,re]=C.useState(null),[ee,Q]=C.useState(null),[de,fe]=C.useState(null),ue=a?.status==="ready",pe=C.useMemo(()=>a?.subjects??[],[a]),me=C.useMemo(()=>pe.filter(ne=>D.has(ne.id)),[D,pe]),be=C.useMemo(()=>F.filter(ne=>P.has(ne.id)),[F,P]),ye=C.useMemo(()=>Er(be,me,F),[F,be,me]),ce=Fr(ye,K),X=_r(d).length>0||ye.some(ne=>!!K[ne.key]),ie=X?"replace":"edit",he=ee??g??b?.[0]?.id??null,ke=ne=>ne.capabilities[X?"regionReplace":"semantic"],$e=ne=>{h&&h(ne,ie).then(xe=>{M.current&&fe(xe)}).catch(()=>{M.current&&fe(null)})},De=F.find(ne=>ne.id===q)??null,Ie=De?Lr(De.box,pe):null,Te=r&&a?.status!=="analyzing"&&Y!=="analyze",Fe=a?.status==="analyzing"||Y==="analyze",et=a?.status==="failed",Ye=!!(o||!y||Y&&Y!=="analyze"||Te||Fe),Ke=F.length>0||ue&&pe.length>0,Ve=zr(me,ye,X),lt=!X&&ye.length===0,Ae=d.trim(),We=!!v&&Y===null&&(Ae.length>0?Ve!==null||lt:ce),Ge=X?"Replace with image":"Apply edit";C.useEffect(()=>(M.current=!0,()=>{M.current=!1}),[]);const Je=async(ne,xe)=>{if(!Y){Z(ne),re(null),ne!=="analyze"&&x?.(!0);try{const Re=await xe();M.current&&Re&&re({tone:"success",text:Re})}catch(Re){M.current&&re({tone:"error",text:wu(Re)})}finally{M.current&&(Z(null),ne!=="analyze"&&x?.(!1))}}},tt=(ne=!1)=>{if(ue&&!ne){G(!1),V(xe=>!xe);return}y&&Je("analyze",async()=>(await y(ne),null))},Ce=()=>{!j||ye.length===0||Je("remove",async()=>await j({operation:"remove",subjectIds:me.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={...Hr(me.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(Ae,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=()=>{A.current=null,U(null)},ve=()=>{_e(),z(ne=>!ne),G(!1),V(!1)},Qe=ne=>{$(xe=>xe.filter(Re=>Re.id!==ne)),L(xe=>{const Re=new Set(xe);return Re.delete(ne),Re}),te(xe=>{const Re={...xe};return delete Re[ne],Re})},nt=()=>{De&&$(ne=>ne.map(xe=>xe.id===De.id?Ur(xe,pe):xe))},At=ne=>{!_||ne.button!==0||(ne.preventDefault(),ne.currentTarget.setPointerCapture(ne.pointerId),A.current=Nn(ne,s,n),U(null))},wt=ne=>{!_||!A.current||U(jl(A.current,Nn(ne,s,n)))},Dt=ne=>{if(!_||!A.current)return;const xe=jl(A.current,Nn(ne,s,n));if(_e(),!xe)return;const Re={id:Br(F),box:xe};$(Xe=>[...Xe,Re]),L(Xe=>new Set([...Xe,Re.id])),V(!1),G(!1)},Ze=Te?"Loading…":Fe?"Analyzing…":ue?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:ue&&!ae?"active":"","aria-pressed":ue?!ae:void 0,disabled:Ye,title:Ze,onClick:()=>tt(),children:[Te||Fe?t.jsx(ut,{size:18}):ue&&!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"})]}),ue&&a?.baseUrl&&t.jsxs("button",{type:"button",className:oe?"active":"","aria-pressed":oe,disabled:me.length===0||be.length>0||Y!==null,title:"Preview removal",onClick:()=>{G(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:[ue&&a&&oe?t.jsx(Iu,{mediaUrl:e,subjectMap:a,selectedIds:D}):t.jsx($u,{mediaUrl:e,width:s,height:n,subjectMap:ae?null:a,selectedIds:D,hiddenIds:I,regions:ae?[]:F,selectedRegionIds:P,drawMode:_,draftBox:O,snapRegionId:Ie?q:null,opacity:se,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"}),Ie&&De&&!_&&t.jsxs("button",{type:"button",className:"notebook-region-snap",onClick:nt,children:["Snap to ",pe.find(ne=>ne.id===Ie.subjectId)?.label??"subject"]})]}),t.jsxs("aside",{className:"notebook-subject-panel","aria-label":"Subject editor",children:[t.jsxs("form",{className:"image-editor-instructions","aria-label":`Edit instructions for @${l}`,onSubmit:ne=>{ne.preventDefault(),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":R,placeholder:Or(me,ye,X),disabled:!v,autoFocus:!0,onChange:ne=>u(ne.target.value),onKeyDown:qe}),t.jsxs("p",{id:R,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=>{Q(ne.target.value),fe(null),$e(ne.target.value)},onFocus:()=>{he&&de===null&&$e(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(wi,{size:14}),Ge,t.jsx("kbd",{"aria-hidden":"true",children:"⌘↵"})]}),t.jsxs("button",{type:"button",className:"remove",disabled:ye.length===0||Y!==null||!j,onClick:Ce,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(Ru,{analysisUnavailableReason:o,checkingCache:Te,analyzing:Fe,analysisFailed:et&&!Fe,ready:ue,hasTargets:Ke,subjectCount:pe.length,regionCount:F.length,error:a?.error??null,onAnalyze:tt}),Ke&&t.jsxs("div",{className:"notebook-subject-list",children:[t.jsxs("div",{className:"notebook-subject-list-actions",children:[t.jsxs("span",{children:[me.length+P.size," selected"]}),ue&&pe.length>0&&t.jsxs("label",{className:"notebook-subject-opacity",children:[t.jsx("span",{children:"Overlay"}),t.jsx("input",{type:"range",min:"0.15",max:"0.8",step:"0.05",value:se,onChange:ne=>le(Number(ne.target.value))})]}),ue&&pe.length>0&&t.jsx("button",{type:"button",onClick:()=>T(new Set(me.length===pe.length?[]:pe.map(ne=>ne.id))),children:me.length===pe.length?"Clear":"Select all"})]}),F.map((ne,xe)=>{const Re=P.has(ne.id),Xe=pe.find(at=>at.id===ne.matchedSubjectId);return t.jsxs("div",{className:`notebook-subject-row${Re?" selected":""}`,children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:Re,"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:Xe?`Region · ${Xe.label}`:`Region ${xe+1}`}),t.jsxs("small",{children:[ne.box.width.toFixed(2)," × ",ne.box.height.toFixed(2)]})]})]}),t.jsx("button",{type:"button",className:"notebook-subject-visibility","aria-label":`Remove region ${xe+1}`,onClick:()=>Qe(ne.id),children:t.jsx(mt,{size:14})})]},ne.id)}),ue&&pe.map(ne=>{const xe=D.has(ne.id),Re=I.has(ne.id);return t.jsxs("div",{className:`notebook-subject-row${xe?" selected":""}`,children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:xe,onChange:()=>T(Xe=>ks(Xe,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":`${Re?"Show":"Hide"} ${ne.label} overlay`,"aria-pressed":!Re,onClick:()=>E(Xe=>ks(Xe,ne.id)),children:Re?t.jsx(Il,{size:14}):t.jsx(Ri,{size:14})})]},ne.id)}),ye.length>0&&t.jsx(Mu,{targets:ye,candidates:f,replacements:K,onPick:(ne,xe)=>te(Re=>({...Re,[ne]:xe}))})]})]})]})]})}const Pu={"arrange-column":Mi,"arrange-row":Ii,duplicate:en,download:Ps,"extract-frame":nc,"generate-image":Zt,"generate-video":Rs,generations:Hn,"group-images":Kn,inspect:sc,library:nn,media:Ai,run:Ds,source:Ms,split:Vn,upload:sn,more:qn};function Ul(l){return[...l.querySelectorAll('[role="menuitem"]')].filter(e=>!e.disabled)}function $f(l){const e=W.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 P=p.current;if(!P)return;const L=()=>{const z=Math.max(8,Math.min(c.x,window.innerWidth-P.offsetWidth-8-1)),O=Math.max(8,Math.min(c.y,window.innerHeight-P.offsetHeight-8-1));P.style.left=`${z}px`,P.style.top=`${O}px`};L();const _=new ResizeObserver(L);return _.observe(P),Ul(P)[0]?.focus({preventScroll:!0}),()=>_.disconnect()},h=[c.x,c.y],e[0]=c.x,e[1]=c.y,e[2]=g,e[3]=h):(g=e[2],h=e[3]),C.useLayoutEffect(g,h);let y,x;e[4]!==f?(y=()=>{const P=_=>{const z=_.target;!(z instanceof Node)||p.current?.contains(z)||f()},L=()=>f();return document.addEventListener("pointerdown",P,!0),window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{document.removeEventListener("pointerdown",P,!0),window.removeEventListener("blur",L),window.removeEventListener("resize",L)}},x=[f],e[4]=f,e[5]=y,e[6]=x):(y=e[5],x=e[6]),C.useEffect(y,x);let j;e[7]!==f||e[8]!==d?(j=()=>{f(),d?.isConnected&&d.focus({preventScroll:!0})},e[7]=f,e[8]=d,e[9]=j):j=e[9];const v=j;let k;e[10]!==u||e[11]!==f?(k=P=>{f(),u(P)},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=P=>{const L=p.current;if(!L)return;if(P.key==="Escape"){P.preventDefault(),P.stopPropagation(),v();return}if(P.key==="Tab"){f();return}if(m&&!b&&(P.key==="Delete"||P.key==="Backspace")){P.preventDefault(),P.stopPropagation(),f(),m();return}if(P.key!=="ArrowDown"&&P.key!=="ArrowUp"&&P.key!=="Home"&&P.key!=="End")return;P.preventDefault(),P.stopPropagation();const _=Ul(L);if(_.length===0)return;const z=_.findIndex(Du),O=P.key==="Home"?0:P.key==="End"?_.length-1:P.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 R=S,N=o??`Cell actions for ${n}`;let M;e[18]!==c.x||e[19]!==c.y?(M={left:c.x,top:c.y},e[18]=c.x,e[19]=c.y,e[20]=M):M=e[20];let A;e[21]!==n?(A=t.jsx("strong",{children:n}),e[21]=n,e[22]=A):A=e[22];let D;e[23]!==i?(D=t.jsx("span",{children:i}),e[23]=i,e[24]=D):D=e[24];let T;e[25]!==A||e[26]!==D?(T=t.jsxs("div",{className:"cell-context-menu-heading","aria-hidden":"true",children:[A,D]}),e[25]=A,e[26]=D,e[27]=T):T=e[27];let I;if(e[28]!==s||e[29]!==w){let P;e[31]!==w?(P=L=>{const _=Pu[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]=P):P=e[32],I=s.map(P),e[28]=s,e[29]=w,e[30]=I}else I=e[30];let E;e[33]!==I?(E=t.jsx("div",{className:"cell-context-menu-actions",role:"presentation",children:I}),e[33]=I,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 $;if(e[39]!==R||e[40]!==r||e[41]!==M||e[42]!==T||e[43]!==E||e[44]!==F||e[45]!==N){const P=t.jsxs("div",{ref:p,id:r,className:"cell-context-menu","data-composer-focus":"return",role:"menu","aria-label":N,style:M,onContextMenu:Au,onKeyDown:R,children:[T,E,F]});$=typeof document>"u"?P:gs.createPortal(P,document.body),e[39]=R,e[40]=r,e[41]=M,e[42]=T,e[43]=E,e[44]=F,e[45]=N,e[46]=$}else $=e[46];return $}function Au(l){return l.preventDefault()}function Du(l){return l===document.activeElement}function If(l){const e=W.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[y,x]=C.useState(h),[j,v]=C.useState(""),[k,w]=C.useState(""),[S,R]=C.useState(null),[N,M]=C.useState(null),A=y.kind==="rename"?y.bookId:null,D=y.kind==="create",T=y.kind==="delete"?y.bookId:null;let I;e[1]===Symbol.for("react.memo_cache_sentinel")?(I=X=>{X!==void 0&&X&&g.current?.focus(),x({kind:"idle"}),v(""),w(""),M(null)},e[1]=I):I=e[1];const E=I;let F;e[2]!==y||e[3]!==u||e[4]!==S?(F=X=>{const ie=X===void 0?!1:X;fs(y,{kind:"close"},S!==null).closeMenu&&(E(ie),u(!1))},e[2]=y,e[3]=u,e[4]=S,e[5]=F):F=e[5];const $=F;let P,L;e[6]!==$||e[7]!==y||e[8]!==u||e[9]!==o||e[10]!==S?(P=()=>{if(!o)return;const X=he=>{p.current?.contains(he.target)||$()},ie=he=>{if(he.key!=="Escape")return;const ke=fs(y,{kind:"escape"},S!==null);if(ke.closeMenu){he.preventDefault(),E(!0),u(!1);return}ke.mode!==y&&(he.preventDefault(),E(!0))};return document.addEventListener("pointerdown",X),document.addEventListener("focusin",X),document.addEventListener("keydown",ie),()=>{document.removeEventListener("pointerdown",X),document.removeEventListener("focusin",X),document.removeEventListener("keydown",ie)}},L=[$,y,u,o,S,E],e[6]=$,e[7]=y,e[8]=u,e[9]=o,e[10]=S,e[11]=P,e[12]=L):(P=e[11],L=e[12]),C.useEffect(P,L);let _;e[13]!==y||e[14]!==S?(_=()=>{const X=fs(y,{kind:"begin-create"},S!==null);X.mode!==y&&(x(X.mode),v(""),M(null))},e[13]=y,e[14]=S,e[15]=_):_=e[15];const z=_;let O;e[16]!==y||e[17]!==S?(O=X=>{const ie=fs(y,{kind:"begin-rename",bookId:X.bookId},S!==null);ie.mode!==y&&(x(ie.mode),w(""),M(null),v(X.name))},e[16]=y,e[17]=S,e[18]=O):O=e[18];const U=O;let q;e[19]!==n||e[20]!==y||e[21]!==S?(q=X=>{if(n.length<2)return;const ie=fs(y,{kind:"begin-delete",bookId:X},S!==null);ie.mode!==y&&(x(ie.mode),v(""),w(""),M(null))},e[19]=n,e[20]=y,e[21]=S,e[22]=q):q=e[22];const H=q;let K;e[23]!==y||e[24]!==S?(K=()=>{fs(y,{kind:"cancel"},S!==null).mode!==y&&E(!0)},e[23]=y,e[24]=S,e[25]=K):K=e[25];const te=K;let ae;e[26]!==s?.bookId||e[27]!==$||e[28]!==i||e[29]!==b||e[30]!==S?(ae=async X=>{if(i||S||X===s?.bookId){X===s?.bookId&&$(!0);return}M(null),R({kind:"select",bookId:X});const ie=await b(X);if(R(null),!ie.ok){M(ie.error);return}$(!0)},e[26]=s?.bookId,e[27]=$,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]!==te||e[34]!==j||e[35]!==A||e[36]!==m||e[37]!==S?(oe=async X=>{if(X?.preventDefault(),!A||S)return;const ie=ms(j),he=n.find($e=>$e.bookId===A);if(!ie){M(cl);return}if(ie===he?.name){te();return}M(null),R({kind:"rename",bookId:A});const ke=await m(A,ie);if(R(null),!ke.ok){M(ke.error);return}te()},e[32]=n,e[33]=te,e[34]=j,e[35]=A,e[36]=m,e[37]=S,e[38]=oe):oe=e[38];const G=oe;let se;e[39]!==k||e[40]!==c||e[41]!==u||e[42]!==S?(se=async X=>{if(X?.preventDefault(),S)return;const ie=ms(k);if(!ie){M(cl);return}M(null),R({kind:"create"});const he=await c(ie);if(R(null),!he.ok){M(he.error);return}E(!0),u(!1)},e[39]=k,e[40]=c,e[41]=u,e[42]=S,e[43]=se):se=e[43];const le=se;let Y;e[44]!==n||e[45]!==d||e[46]!==S?(Y=async X=>{if(S||n.length<2)return;M(null),R({kind:"delete",bookId:X.bookId});const ie=await d(X.bookId,X.name);if(R(null),!ie.ok){M(ie.error);return}E(!0)},e[44]=n,e[45]=d,e[46]=S,e[47]=Y):Y=e[47];const Z=Y;let J;e[48]!==$||e[49]!==u||e[50]!==o?(J=()=>{if(o){$();return}u(!0)},e[48]=$,e[49]=u,e[50]=o,e[51]=J):J=e[51];const re=J;let ee;e[52]!==s?(ee=s?gn(s.artifactCount):"No active project",e[52]=s,e[53]=ee):ee=e[53];const Q=ee,de=i||S!==null,fe=s?.name??"select-project";let ue;e[54]!==fe?(ue=t.jsx("strong",{children:fe}),e[54]=fe,e[55]=ue):ue=e[55];let pe;e[56]!==Q||e[57]!==s?(pe=s&&t.jsx("span",{className:"book-project-active-count",title:Q,children:s.artifactCount}),e[56]=Q,e[57]=s,e[58]=pe):pe=e[58];let me;e[59]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsx(Is,{size:14}),e[59]=me):me=e[59];let be;e[60]!==o||e[61]!==ue||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:[ue,pe,me]}),e[60]=o,e[61]=ue,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]!==te||e[71]!==Z||e[72]!==k||e[73]!==D||e[74]!==T||e[75]!==j||e[76]!==A||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]!==G?(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&&!A&&!D&&!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(X=>{const ie=X.bookId===s?.bookId,he=X.bookId===A,ke=X.bookId===T,$e=S&&"bookId"in S?S.bookId===X.bookId:!1,De=n.length>1;return he?t.jsxs("form",{className:"book-project-form",onSubmit:G,children:[t.jsx("input",{autoFocus:!0,"aria-label":`New name for ${X.name}`,autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,disabled:S!==null,value:j,onChange:Ie=>v(Ie.target.value)}),t.jsxs("div",{className:"book-project-form-actions",children:[t.jsx("button",{type:"submit",disabled:S!==null,title:"Save project name","aria-label":"Save project name",children:S?.kind==="rename"?t.jsx(ut,{size:14}):t.jsx(Qt,{size:14})}),t.jsx("button",{type:"button",disabled:S!==null,title:"Cancel rename","aria-label":"Cancel rename",onClick:te,children:t.jsx(mt,{size:14})})]}),j&&ms(j)!==j&&t.jsxs("small",{className:"book-project-form-hint",children:["Slug: ",ms(j)||"Enter letters or numbers"]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]},X.bookId):ke?t.jsxs("div",{className:"book-project-delete",role:"group","aria-label":`Delete ${X.name}`,children:[t.jsx(os,{size:15}),t.jsxs("div",{children:[t.jsxs("strong",{children:["Delete ",X.name,"?"]}),t.jsxs("small",{children:[gn(X.artifactCount)," and"," ",vl(X.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 ${X.name}`,"aria-label":`Confirm deletion of ${X.name}`,onClick:()=>{Z(X)},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:te,children:t.jsx(mt,{size:14})})]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]},X.bookId):t.jsxs("div",{className:`book-project-row ${ie?"active":""}`,"aria-busy":$e,children:[t.jsxs("button",{type:"button",className:"book-project-select",role:"menuitem","aria-current":ie?"true":void 0,disabled:de,onClick:()=>{V(X.bookId)},children:[t.jsx("span",{className:"book-project-marker"}),t.jsxs("span",{className:"book-project-copy",children:[t.jsx("strong",{children:X.name}),t.jsx("small",{children:vl(X.notebookCount)})]}),t.jsx("span",{className:`book-project-artifact-count ${X.artifactCount===0?"empty":""}`,title:gn(X.artifactCount),children:$e?t.jsx(ut,{size:12}):X.artifactCount})]}),t.jsxs("div",{className:"book-project-actions",children:[t.jsx("button",{type:"button",disabled:de,title:`Rename ${X.name}`,"aria-label":`Rename ${X.name}`,onClick:()=>U(X),children:t.jsx(lc,{size:13})}),t.jsx("button",{type:"button",disabled:de||!De,title:De?`Delete ${X.name}`:"Create another project before deleting this one","aria-label":`Delete ${X.name}`,onClick:()=>H(X.bookId),children:t.jsx(os,{size:13})})]})]},X.bookId)})]}),t.jsx("footer",{className:"book-project-menu-footer",children:D?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:X=>w(X.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:te,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]=te,e[71]=Z,e[72]=k,e[73]=D,e[74]=T,e[75]=j,e[76]=A,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]=G,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 Tu(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:{}}function _n(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 Ln(l){const e=W.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=Vr(n),[p,g]=C.useState(null),h=p===null?qr(n,i):{...n,...b[p]},y=n.title??$s(s),x=o[c??s];let j;e[0]!==x?(j=x?[...new Set(x.map(Lu))]:[],e[0]=x,e[1]=j):j=e[1];const v=j,k=h.type==="object"||h.type==="array",w=b.findIndex(I=>_n(I)===_n(h)),S=h.enum??(h.type==="boolean"?[!0,!1]:void 0),R=Tu(i),N=Array.isArray(i)?i:[];if("const"in h){const I=String(h.const);let E;return e[2]!==I?(E=t.jsx("strong",{children:I}),e[2]=I,e[3]=E):E=e[3],t.jsxs("div",{className:"workspace-action-fixed",children:[t.jsx("span",{children:y}),E]})}const M=()=>{if(S)return t.jsxs("select",{id:m,required:u,disabled:f,value:i===void 0?"":String(S.indexOf(i)),onChange:$=>d($.target.value===""?void 0:S[Number($.target.value)]),children:[t.jsx("option",{value:"",children:u?`Choose ${y.toLowerCase()}`:"Use default"}),S.map(_u)]});if(x)return t.jsxs("select",{id:m,required:u,disabled:f,value:typeof i=="string"?i:"",onChange:$=>d($.target.value||void 0),children:[t.jsx("option",{value:"",children:x.length?`Choose ${y.toLowerCase()}`:`No ${y.toLowerCase()} available`}),v.map($=>{const P=x.filter(L=>(L.group??"")===$).map(Fu);return $?t.jsx("optgroup",{label:$,children:P},$):P})]});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 I=h.type==="number"||h.type==="integer",E=h.format==="password"||/secret|password|api_key|access_token/u.test(s);return!I&&/prompt|text|description|markdown|content|script/u.test(s)?t.jsx("textarea",{id:m,value:typeof i=="string"?i:"",disabled:f,required:u,minLength:h.minLength,maxLength:h.maxLength,rows:4,onChange:$=>d($.target.value)}):t.jsx("input",{id:m,type:I?"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:$=>d(I?$.target.value===""?void 0:Number($.target.value):$.target.value)})};let A;e[4]!==u?(A=u&&t.jsx("span",{"aria-hidden":"true",children:" *"}),e[4]=u,e[5]=A):A=e[5];let D;e[6]!==n.description?(D=n.description&&t.jsx("p",{className:"workspace-action-hint",children:n.description}),e[6]=n.description,e[7]=D):D=e[7];let T;return e[8]!==f||e[9]!==y||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 ",y.toLowerCase()]}),e[8]=f,e[9]=y,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:[y,A]}),D,b.length>1&&t.jsx("select",{"aria-label":`${y} format`,disabled:f,value:Math.max(0,w),onChange:I=>{const E=Number(I.target.value);g(E),d(yn(b[E],!0))},children:b.map(Eu)}),k&&!u&&i===void 0?t.jsxs("button",{type:"button",disabled:f,onClick:()=>d(yn(h,!0)),children:["Add ",y.toLowerCase()]}):h.type==="object"?Object.keys(h.properties??{}).length?t.jsx("fieldset",{id:m,disabled:f,"aria-label":y,children:Object.entries(h.properties??{}).map(I=>{const[E,F]=I;return t.jsx(Ln,{name:E,schema:F,value:R[E],choices:o,required:h.required?.includes(E),disabled:f,onChange:$=>d({...R,[E]:$})},E)})}):t.jsx(Hl,{id:m,value:i,disabled:f,onChange:d}):h.type==="array"?t.jsxs("fieldset",{id:m,disabled:f,"aria-label":y,children:[N.map((I,E)=>t.jsxs("div",{className:"workspace-action-array-row",children:[t.jsx(Ln,{name:`${s} ${E+1}`,schema:h.items??{},value:I,required:!0,choices:o,choiceName:c??s,disabled:f,onChange:F=>d(N.map(($,P)=>P===E?F:$))}),t.jsx("button",{type:"button",disabled:f||N.length<=(h.minItems??0),"aria-label":`Remove ${y.toLowerCase()} ${E+1}`,onClick:()=>d(N.filter((F,$)=>$!==E)),children:"Remove"})]},E)),t.jsx("button",{type:"button",disabled:f||h.maxItems!==void 0&&N.length>=h.maxItems,onClick:()=>d([...N,yn(h.items??{},!0)]),children:"Add item"})]}):M(),T]})}function Eu(l,e){return t.jsx("option",{value:e,children:_n(l)},e)}function Fu(l){return t.jsxs("option",{value:l.value,disabled:l.available===!1,children:[l.label,l.detail?` · ${l.detail}`:""]},l.value)}function _u(l,e){return t.jsx("option",{value:e,children:typeof l=="boolean"?l?"Yes":"No":String(l)},e)}function Lu(l){return l.group??""}function Kl(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:null}function Ys(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 zu(l){const e=W.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=Ys(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=Ys(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=Ys(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=Ys(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 Ou(l){const e=W.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}%`,y=`${f*100}%`;let x;e[2]!==p||e[3]!==g||e[4]!==h||e[5]!==y?(x={left:p,top:g,width:h,height:y},e[2]=p,e[3]=g,e[4]=h,e[5]=y,e[6]=x):x=e[6];const j=x;let v;e[7]!==i||e[8]!==s.height||e[9]!==s.width||e[10]!==a?(v=H=>{i||a(mi(H,s.width,s.height))},e[7]=i,e[8]=s.height,e[9]=s.width,e[10]=a,e[11]=v):v=e[11];const k=v;if(!s.url){let H;return e[12]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx("p",{children:"Preview unavailable for this media."}),e[12]=H):H=e[12],H}const w=n.ratio==="16:9";let S;e[13]!==k?(S=()=>k("16:9"),e[13]=k,e[14]=S):S=e[14];let R;e[15]!==i||e[16]!==w||e[17]!==S?(R=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]=R):R=e[18];const N=n.ratio==="9:16";let M;e[19]!==k?(M=()=>k("9:16"),e[19]=k,e[20]=M):M=e[20];let A;e[21]!==i||e[22]!==N||e[23]!==M?(A=t.jsx("button",{type:"button",disabled:i,"aria-pressed":N,onClick:M,children:"Portrait 9:16"}),e[21]=i,e[22]=N,e[23]=M,e[24]=A):A=e[24];const D=n.ratio==="1:1";let T;e[25]!==k?(T=()=>k("1:1"),e[25]=k,e[26]=T):T=e[26];let I;e[27]!==i||e[28]!==D||e[29]!==T?(I=t.jsx("button",{type:"button",disabled:i,"aria-pressed":D,onClick:T,children:"Square 1:1"}),e[27]=i,e[28]=D,e[29]=T,e[30]=I):I=e[30];let E;e[31]!==R||e[32]!==A||e[33]!==I?(E=t.jsxs("div",{className:"workspace-crop-ratios",role:"group","aria-label":"Crop aspect ratio",children:[R,A,I]}),e[31]=R,e[32]=A,e[33]=I,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 $;e[39]!==i||e[40]!==f||e[41]!==a||e[42]!==u?($=H=>{const K=r.current;if(i||!K||H.pointerId!==K.pointerId)return;const te=H.currentTarget.getBoundingClientRect();a({x:Math.max(0,Math.min(1-u,K.originX+(H.clientX-K.x)/te.width)),y:Math.max(0,Math.min(1-f,K.originY+(H.clientY-K.y)/te.height))})},e[39]=i,e[40]=f,e[41]=a,e[42]=u,e[43]=$):$=e[43];let P,L;e[44]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{r.current=null},L=()=>{r.current=null},e[44]=P,e[45]=L):(P=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]!==j?(z=t.jsx("div",{className:"workspace-crop-region",style:j}),e[49]=j,e[50]=z):z=e[50];let O;e[51]!==b||e[52]!==F||e[53]!==$||e[54]!==_||e[55]!==z?(O=t.jsxs("div",{className:"workspace-crop-frame",style:b,onPointerDown:F,onPointerMove:$,onPointerUp:P,onPointerCancel:L,children:[_,z]}),e[51]=b,e[52]=F,e[53]=$,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=W.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(Bu)}),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 Bu(l){const[e,s]=l;return t.jsxs("div",{children:[t.jsx("dt",{children:$s(e)}),t.jsx("dd",{children:t.jsx(Yn,{value:s,name:$s(e)})})]},e)}function Uu({action:l,context:e,initialValues:s,initialResult:n,variants:i,onExecute:a,onReview:r,onBack:o,onOpenAction:c}){const[d,u]=C.useState(()=>({...Wr(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(P=>typeof P=="string"):e.assetIds,cellIds:Array.isArray(s?.cell_ids)?s.cell_ids.filter(P=>typeof P=="string"):e.cellIds}),...Object.fromEntries(Object.entries(s??{}).filter(([P])=>P in(l.inputSchema.properties??{})&&(P!=="_provider"||!l.generation)))})),f=l.generation&&typeof d.model=="string"?pi(d.model,d):void 0,m=Gr(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,y]=C.useState(null),[x,j]=C.useState(null),[v,k]=C.useState(n??null),w=new Set(l.inputSchema.required??[]),S=new Set(["book_id","actor","source_surface"]);l.generation&&S.add("_provider");const R=Object.entries(l.inputSchema.properties??{}).filter(([$])=>!S.has($)),N=l.handler.kind==="tool"&&l.handler.tool==="update_entity",M=b.entity&&typeof b.entity=="object"&&"id"in b.entity?String(b.entity.id):"",A=ii(l,e),D=["commit_hash","filename","subject_id","subject_ids"].some($=>$ 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,I=l.target.argument&&l.target.mediaKinds?{...e.choices,[l.target.argument]:(e.choices[l.target.argument]??e.choices.asset_id??[]).filter($=>l.target.mediaKinds?.some(P=>P===$.detail))}:e.choices,E=l.generation&&I.model?{...I,model:Xr(I.model,l.generation.mediaType,b)}:I,F=async()=>{if(!(p||A)){g(!0),y(null);try{l.confirmation!=="none"&&!x?j(await r(l,b)):(k(await a(l,b)),j(null))}catch($){y($ instanceof Error?$.message:String($))}finally{g(!1)}}};return t.jsxs("form",{className:"workspace-action-form","data-action-id":l.id,onSubmit:$=>{$.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:$=>c($.target.value,b),children:i.map($=>t.jsxs("option",{value:$.id,children:[$.generation?.provider," · ",$.title]},$.id))})]})]}),t.jsxs("div",{className:"workspace-action-fields",children:[T&&t.jsx(Ou,{media:T,values:b,disabled:p,onChange:$=>{u(P=>({...P,...$})),j(null),k(null)}}),N&&t.jsxs("label",{className:"workspace-action-field",children:["Saved item",t.jsxs("select",{"aria-label":"Saved item",required:!0,value:M,disabled:p,onChange:$=>{u(P=>({...P,entity:structuredClone(e.entities?.[$.target.value])})),k(null),j(null)},children:[t.jsx("option",{value:"",children:"Choose a saved item"}),(e.choices.entity_id??[]).map($=>t.jsx("option",{value:$.value,children:$.label},$.value))]})]}),R.map(([$,P])=>t.jsx(Ln,{name:$,schema:N&&$==="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}}}:P,value:b[$],choices:E,required:w.has($),disabled:p||$==="aspect_ratio"&&!!f,onChange:L=>{u(_=>({..._,[$]:L,...T&&$==="ratio"&&typeof L=="string"?mi(L,T.width,T.height):{},...$===l.target.argument&&typeof L=="string"&&l.inputSchema.properties?.object_hash?{object_hash:e.media?.[L]?.objectHash??""}:{}})),j(null),k(null)}},N&&$==="entity"?`${$}:${M}`:$))]}),m&&t.jsx("p",{role:"status",children:Yr}),f&&t.jsx("p",{role:"status",children:Jr}),D&&t.jsx("button",{type:"button",disabled:p,onClick:()=>c(l.id,b),children:"Refresh available choices"}),A&&t.jsx("p",{role:"status",children:A}),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}),Qr(l)?t.jsx(zu,{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||!!A,children:[p?t.jsx(ut,{size:15}):t.jsx(Ds,{size:15}),p?"Working…":x?"Confirm and run":l.confirmation!=="none"?"Review action":"Run action"]}),x&&t.jsx("button",{type:"button",onClick:()=>j(null),disabled:p,children:"Cancel review"})]})]})}function Rf({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 y=()=>{const x=fi(a);c(),x()};return gs.createPortal(t.jsxs("dialog",{ref:b,className:"workspace-actions-dialog","aria-label":"Workspace actions",onKeyDown:x=>{x.key!=="Escape"||x.nativeEvent.isComposing||(x.preventDefault(),x.stopPropagation(),y())},onCancel:x=>{x.preventDefault(),y()},children:[t.jsxs("header",{children:[t.jsx("h2",{children:"Actions"}),t.jsx("button",{type:"button","aria-label":"Close actions",onClick:y,children:t.jsx(mt,{size:18})})]}),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(Uu,{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 Wi(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*Wi(l)))}function Gi(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*Wi(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 Hu(l){const e=W.c(40),{sequence:s,clip:n,src:i,defaultFit:a}=l,r=pc(),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})`,y=`rotate(${o?.rotationDegrees??0}deg)`;let x;e[9]!==g||e[10]!==h||e[11]!==y?(x=[g,h,y],e[9]=g,e[10]=h,e[11]=y,e[12]=x):x=e[12];const j=x.join(" "),v=`${(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]!==j?(w={width:"100%",height:"100%",objectFit:b,objectPosition:"center",opacity:p,transform:j,transformOrigin:v,clipPath:k},e[13]=v,e[14]=k,e[15]=b,e[16]=p,e[17]=j,e[18]=w):w=e[18];const S=w;if(n.source.kind==="still"){let I;return e[19]!==i||e[20]!==S?(I=t.jsx(hc,{src:i,style:S}),e[19]=i,e[20]=S,e[21]=I):I=e[21],I}const R=n;if(R.reverse){let I;e[22]!==S?(I={...S,display:"grid",placeItems:"center",background:"#07120c"},e[22]=S,e[23]=I):I=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]!==I?(F=t.jsx(Wn,{style:I,children:E}),e[25]=I,e[26]=F):F=e[26],F}let N;e[27]!==s||e[28]!==R?(N=Jn(s,R),e[27]=s,e[28]=R,e[29]=N):N=e[29];let M;e[30]!==s||e[31]!==R?(M=Gi(s,R),e[30]=s,e[31]=R,e[32]=M):M=e[32];const A=R.speed.numerator/R.speed.denominator,D=R.audioPolicy==="mute";let T;return e[33]!==i||e[34]!==S||e[35]!==N||e[36]!==M||e[37]!==A||e[38]!==D?(T=t.jsx(bc,{src:i,startFrom:N,endAt:M,playbackRate:A,muted:D,style:S}),e[33]=i,e[34]=S,e[35]=N,e[36]=M,e[37]=A,e[38]=D,e[39]=T):T=e[39],T}function Ku(l){const e=W.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),y=Math.max(1,a?.fadeInFrames??0,o.incoming?.durationFrames??0),x=Math.max(1,a?.fadeOutFrames??0,o.outgoing?.durationFrames??0);return y>0&&g<y?h*g/y:x>0&&g>n.durationFrames-x?h*Math.max(0,n.durationFrames-g)/x:h},e[3]=a?.fadeInFrames,e[4]=a?.fadeOutFrames,e[5]=a?.gainDb,e[6]=a?.muted,e[7]=n.durationFrames,e[8]=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=Gi(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(xc,{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 Vu(l){const e=W.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 qu(l){const e=W.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(Yu)),b=new Map(s.tracks.map(Xu));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)}),y=s.clips.flatMap(v=>{const k=b.get(v.trackId);return!v.enabled||v.source.kind!=="timed"||!k?.enabled||k.kind!=="audio"||k.muted||g&&!k.solo?[]:[v]});r=Wn;let x;e[9]!==s.backgroundRgba?(x=s.backgroundRgba.join(","),e[9]=s.backgroundRgba,e[10]=x):x=e[10];const j=`rgba(${x})`;e[11]!==j?(o={backgroundColor:j},e[11]=j,e[12]=o):o=e[12],c=h.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(Dn,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(Hu,{sequence:s,clip:v,src:k.mediaUrl,defaultFit:a})},v.clipId)}),d=y.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(Dn,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(Ku,{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(Wu),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 Wu(l){return t.jsx(Dn,{from:l.timelineStartFrame,durationInFrames:l.durationFrames,children:t.jsx(Vu,{text:l.text,styleId:l.styleId})},l.cueId)}function Gu(l){return l.kind==="audio"&&l.solo}function Xu(l){return[l.trackId,l]}function Yu(l){return[l.artifactId,l]}const Ju={width:"100%",maxHeight:520},Qu={width:"100%",height:"100%"},Zu=({playing:l,isBuffering:e})=>e?t.jsx(ki,{size:16,className:"timeline-preview-buffering"}):l?t.jsx(Di,{size:16}):t.jsx(Ds,{size:16});function em(l){return Math.max(1,...l.clips.map(e=>e.timelineStartFrame+e.durationFrames),...l.captions.map(e=>e.timelineStartFrame+e.durationFrames))}function tm(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 sm=C.forwardRef(function(e,s){const n=W.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),y=C.useRef(null),x=i.frameRate.numerator/i.frameRate.denominator,j=em(i);let v;n[0]!==g?(v=Math.round(g),n[0]=g,n[1]=v):v=n[1];const k=Math.max(0,Math.min(j-1,v)),w=C.useRef(k),[S,R]=C.useState(k),N=b==="preview";let M;n[2]!==a||n[3]!==i?(M={sequence:i,assets:a,defaultFit:"fit"},n[2]=a,n[3]=i,n[4]=M):M=n[4];const A=M;let D;n[5]!==j||n[6]!==m||n[7]!==x||n[8]!==o?(D=Y=>{if(Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229)return;const Z=Y.target;if(["INPUT","TEXTAREA","SELECT"].includes(Z.tagName))return;const J=h.current;if(!J)return;const re=w.current,ee=Y.key.toLowerCase();if(ee===" "||ee==="k"){Y.preventDefault(),J.isPlaying()?J.pause():J.play();return}if(ee==="j"||Y.key==="ArrowLeft"){Y.preventDefault(),J.seekTo(Math.max(0,re-(ee==="j"?Math.round(x):1)));return}if(ee==="l"||Y.key==="ArrowRight"){Y.preventDefault(),J.seekTo(Math.min(j-1,re+(ee==="l"?Math.round(x):1)));return}if(!m)return;const Q=tm(Y);Q&&(Y.preventDefault(),o(Q,re))},n[5]=j,n[6]=m,n[7]=x,n[8]=o,n[9]=D):D=n[9];const T=D;let I,E;n[10]!==j||n[11]!==T||n[12]!==r?(I=()=>({pause:()=>h.current?.pause(),togglePlay:()=>{const Y=h.current;Y&&(Y.isPlaying()?Y.pause():Y.play())},seekTo:Y=>{const Z=Math.max(0,Math.min(j-1,Math.round(Y)));w.current=Z,R(Z),r(Z),h.current?.seekTo(Z)},focus:()=>y.current?.focus(),handleKeyDown:T}),E=[j,T,r],n[10]=j,n[11]=T,n[12]=r,n[13]=I,n[14]=E):(I=n[13],E=n[14]),C.useImperativeHandle(s,I,E);let F,$;n[15]!==r?(F=()=>{const Y=h.current;if(!Y)return;const Z=J=>{w.current=J.detail.frame,R(J.detail.frame),r(J.detail.frame)};return Y.addEventListener("frameupdate",Z),()=>Y.removeEventListener("frameupdate",Z)},$=[r],n[15]=r,n[16]=F,n[17]=$):(F=n[16],$=n[17]),C.useEffect(F,$);const P=N?!1:void 0,L=N?"timeline-preview-screen":void 0,_=N?Qu:Ju,z=N?Zu:void 0;let O;n[18]!==p||n[19]!==j||n[20]!==k||n[21]!==x||n[22]!==A||n[23]!==N||n[24]!==i.height||n[25]!==i.width||n[26]!==P||n[27]!==L||n[28]!==_||n[29]!==z?(O=t.jsx(gc,{ref:h,component:qu,inputProps:A,durationInFrames:j,fps:x,compositionWidth:i.width,compositionHeight:i.height,initialFrame:k,controls:!0,spaceKeyToPlayOrPause:P,allowFullscreen:p,alwaysShowControls:N,className:L,style:_,renderPlayPauseButton:z}),n[18]=p,n[19]=j,n[20]=k,n[21]=x,n[22]=A,n[23]=N,n[24]=i.height,n[25]=i.width,n[26]=P,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 te=S/x;let ae;n[36]!==te?(ae=te.toFixed(2),n[36]=te,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 G;n[40]!==oe?(G=t.jsx("span",{className:"canonical-player-shortcuts",children:oe}),n[40]=oe,n[41]=G):G=n[41];let se;n[42]!==K||n[43]!==V||n[44]!==G?(se=t.jsxs("footer",{children:[K,V,G]}),n[42]=K,n[43]=V,n[44]=G,n[45]=se):se=n[45];let le;return n[46]!==T||n[47]!==q||n[48]!==H||n[49]!==se?(le=t.jsxs("section",{className:q,ref:y,tabIndex:0,onKeyDown:T,"aria-label":"Canonical sequence player",children:[H,se]}),n[46]=T,n[47]=q,n[48]=H,n[49]=se,n[50]=le):le=n[50],le});function Mf(l){const e=W.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 y,x;if(e[0]!==g||e[1]!==s?.files||e[2]!==s?.type||e[3]!==s?.url){const K=s?.files.find(te=>te.name===g);x=K?.url??s?.url,y=K?/\.(?:mp4|webm|mov)$/iu.test(K.name)?"video":/\.(?:wav|mp3|m4a|weba|ogg)$/iu.test(K.name)?"audio":/\.(?:png|jpg|jpeg|webp|gif)$/iu.test(K.name)?"image":"file":s?.type,e[0]=g,e[1]=s?.files,e[2]=s?.type,e[3]=s?.url,e[4]=y,e[5]=x}else y=e[4],x=e[5];const j=y;let v;e[6]!==c||e[7]!==a?(v=()=>{const K=fi(a);c(),K()},e[6]=c,e[7]=a,e[8]=v):v=e[8];const k=v;let w,S;e[9]!==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 R=s?.label??"Sequence preview";let N;e[12]!==k?(N=K=>{K.preventDefault(),k()},e[12]=k,e[13]=N):N=e[13];const M=s?.label??"Sequence preview";let A;e[14]!==M?(A=t.jsx("h2",{children:M}),e[14]=M,e[15]=A):A=e[15];let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(mt,{size:18}),e[16]=D):D=e[16];let T;e[17]!==k?(T=t.jsx("button",{type:"button","aria-label":"Close preview",onClick:k,children:D}),e[17]=k,e[18]=T):T=e[18];let I;e[19]!==A||e[20]!==T?(I=t.jsxs("header",{children:[A,T]}),e[19]=A,e[20]=T,e[21]=I):I=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(im)]})]}),e[22]=g,e[23]=s,e[24]=E):E=e[24];let F;e[25]!==i||e[26]!==n?(F=n&&t.jsx(sm,{ref:p,sequence:n,assets:i,editingEnabled:!1,onFrameUpdate:lm,onKeyboardAction:nm}),e[25]=i,e[26]=n,e[27]=F):F=e[27];let $;e[28]!==s||e[29]!==x?($=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]=$):$=e[30];let P;e[31]!==s?.label||e[32]!==j||e[33]!==x?(P=x&&j==="image"&&t.jsx("img",{src:x,alt:s?.label??"Media preview"}),e[31]=s?.label,e[32]=j,e[33]=x,e[34]=P):P=e[34];let L;e[35]!==s?.thumbnailUrl||e[36]!==j||e[37]!==x?(L=x&&(j==="video"||j==="final")&&t.jsx("video",{src:x,poster:s?.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"metadata"}),e[35]=s?.thumbnailUrl,e[36]=j,e[37]=x,e[38]=L):L=e[38];let _;e[39]!==j||e[40]!==x?(_=x&&j==="audio"&&t.jsx("audio",{src:x,controls:!0,preload:"metadata"}),e[39]=j,e[40]=x,e[41]=_):_=e[41];let 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]!==$||e[49]!==P||e[50]!==L||e[51]!==_||e[52]!==z||e[53]!==O?(U=t.jsxs("div",{className:"workspace-preview-content",children:[E,F,$,P,L,_,z,O]}),e[46]=E,e[47]=F,e[48]=$,e[49]=P,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]!==I||e[59]!==U||e[60]!==q||e[61]!==R||e[62]!==N?(H=gs.createPortal(t.jsxs("dialog",{ref:b,className:"workspace-actions-dialog workspace-preview-dialog","aria-label":R,onCancel:N,children:[I,U,q]}),document.body),e[58]=I,e[59]=U,e[60]=q,e[61]=R,e[62]=N,e[63]=H):H=e[63],H}function nm(){}function lm(){}function im(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}},am={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 Js(l){const e=On(l);return{width:He.squareSize,height:He.squareSize,transform:`translate(${e.x}px, ${e.y}px)`}}const rm={image:Js(Jt.image),video:Js(Jt.video),download:Js(Jt.download),library:Js(Jt.library)},Vl=On(Jt.library),om={width:Vl.x+He.squareSize,height:Vl.y+He.squareSize};function Qn(l){const e=W.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=rm[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=W.c(35),{kind:s,busy:n,onUpload:i,onPick:a}=l,r=C.useRef(null),o=am[s],c=Jt[s];let d;e[0]!==i||e[1]!==c?(d=R=>{const N=R.target.files?.[0];R.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 y=`${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 j;e[17]!==n||e[18]!==y||e[19]!==x?(j=t.jsx("button",{type:"button",className:"notebook-start-tile-secondary","aria-label":y,disabled:n,onClick:x,children:"From library"}),e[17]=n,e[18]=y,e[19]=x,e[20]=j):j=e[20];let v;e[21]!==j||e[22]!==h?(v=t.jsxs("div",{className:"notebook-start-tile-actions",children:[h,j]}),e[21]=j,e[22]=h,e[23]=v):v=e[23];const k=hi[s];let w;e[24]!==u||e[25]!==n||e[26]!==k?(w=t.jsx("input",{ref: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 cm({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:Ti,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 dm(l){const e=W.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:nn,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 Pf(l){const e=W.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(cm,{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(dm,{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(Li,{children:t.jsxs("div",{className:"notebook-start-tiles nodrag nopan",style:om,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 um={post:St,audio:ss,image:Zt,video:Rs,character:Fi,prompt:Ei,analyze:Bn,generate_video:Rs,generate_image:Zt,generate_audio:ss,extract_audio:ss,split_video:St,concat:St,splice:St,timeline:St};function mm(l){const e=W.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=Zr(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 y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=_=>{_.key!=="Escape"||!o.current?.open||(_.preventDefault(),_.stopPropagation(),m(!0))},e[4]=y):y=e[4];const x=y;let j;e[5]!==n?(j=_=>{m(!0),n(_)},e[5]=n,e[6]=j):j=e[6];const v=j;let k;e[7]!==i?(k=()=>{i(),m(!1)},e[7]=i,e[8]=k):k=e[8];const w=k,S="canvas-add-menu";let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=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]=R):R=e[9];const N="canvas-add-popover";let M;e[10]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(rs,{size:14,"aria-hidden":"true"}),e[10]=M):M=e[10];let A;e[11]===Symbol.for("react.memo_cache_sentinel")?(A=_=>r(_.target.value),e[11]=A):A=e[11];let D;e[12]!==a?(D=t.jsxs("label",{className:"canvas-add-search",children:[M,t.jsx("input",{ref:c,type:"search",value:a,"aria-label":"Search cell types",placeholder:"Search cell types",onChange:A})]}),e[12]=a,e[13]=D):D=e[13];const T="canvas-add-results",I="polite",E=eo.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=um[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 $;e[16]!==E||e[17]!==F?($=t.jsxs("div",{className:T,"aria-live":I,children:[E,F]}),e[16]=E,e[17]=F,e[18]=$):$=e[18];let P;e[19]!==D||e[20]!==$?(P=t.jsxs("div",{className:N,children:[D,$]}),e[19]=D,e[20]=$,e[21]=P):P=e[21];let L;return e[22]!==x||e[23]!==h||e[24]!==P||e[25]!==R?(L=t.jsxs("details",{ref:o,className:S,onToggle:h,onKeyDown:x,children:[R,P]}),e[22]=x,e[23]=h,e[24]=P,e[25]=R,e[26]=L):L=e[26],L}function Af(l){const e=W.c(49),{busy:s,arrangeDisabled:n,selectedCount:i,activeAddress:a,onAdd:r,onAddDragEnd:o,onArrange:c,assetsOpen:d,assetsDisabled:u,onAssets:f,onDeleteSelection:m,onClearSelection:b,onSelectionActions:p}=l,g=`Delete ${i} selected ${i===1?"cell":"cells"}`;let h;e[0]!==s||e[1]!==r||e[2]!==o?(h=t.jsx(mm,{disabled:s,onAdd:r,onDragEnd:o}),e[0]=s,e[1]=r,e[2]=o,e[3]=h):h=e[3];let y;e[4]!==r?(y=()=>{r("image")},e[4]=r,e[5]=y):y=e[5];let x,j;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(es,{size:15}),j=t.jsx("span",{children:"Image"}),e[6]=x,e[7]=j):(x=e[6],j=e[7]);let v;e[8]!==s||e[9]!==y?(v=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:y,children:[x,j]}),e[8]=s,e[9]=y,e[10]=v):v=e[10];let k;e[11]!==r?(k=()=>{r("video")},e[11]=r,e[12]=k):k=e[12];let w,S;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(es,{size:15}),S=t.jsx("span",{children:"Video"}),e[13]=w,e[14]=S):(w=e[13],S=e[14]);let R;e[15]!==s||e[16]!==k?(R=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:k,children:[w,S]}),e[15]=s,e[16]=k,e[17]=R):R=e[17];let N;e[18]!==c?(N=()=>{c()},e[18]=c,e[19]=N):N=e[19];let M,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(ac,{size:15}),A=t.jsx("span",{children:"Clean"}),e[20]=M,e[21]=A):(M=e[20],A=e[21]);let D;e[22]!==n||e[23]!==N?(D=t.jsxs("button",{type:"button",className:"canvas-auto-arrange",title:"Clean up cells by workflow and media type","aria-label":"Clean up notebook",disabled:n,onClick:N,children:[M,A]}),e[22]=n,e[23]=N,e[24]=D):D=e[24];const T=d?"canvas-auto-arrange active":"canvas-auto-arrange";let I,E;e[25]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(nn,{size:15}),E=t.jsx("span",{children:"Assets"}),e[25]=I,e[26]=E):(I=e[25],E=e[26]);let F;e[27]!==u||e[28]!==d||e[29]!==f||e[30]!==T?(F=t.jsxs("button",{type:"button",className:T,title:"Assets","aria-label":"Open Assets","aria-expanded":d,disabled:u,onClick:f,children:[I,E]}),e[27]=u,e[28]=d,e[29]=f,e[30]=T,e[31]=F):F=e[31];let $;e[32]!==h||e[33]!==D||e[34]!==F||e[35]!==v||e[36]!==R?($=t.jsxs("div",{className:"canvas-primary-actions",role:"group","aria-label":"Notebook editing tools",children:[h,v,R,D,F]}),e[32]=h,e[33]=D,e[34]=F,e[35]=v,e[36]=R,e[37]=$):$=e[37];let P;e[38]!==a||e[39]!==s||e[40]!==g||e[41]!==b||e[42]!==m||e[43]!==p||e[44]!==i?(P=i>0&&t.jsxs("div",{className:"canvas-selection-actions",role:"group","aria-label":"Notebook selection actions",children:[t.jsxs("span",{className:"canvas-selection-count",title:"Shift-click cells or drag across the canvas to select more",children:[t.jsx("strong",{children:i}),t.jsx("span",{children:" selected"})]}),i>1&&a&&t.jsxs("code",{children:[a," active"]}),p&&t.jsx("button",{type:"button",className:"canvas-clear-selection",title:"Selection actions","aria-label":"Selection actions","data-workspace-action-surface":"selection-menu",onClick:p,children:t.jsx(qn,{size:14})}),t.jsxs("button",{type:"button",className:"canvas-delete-selection",title:g,"aria-label":g,"aria-keyshortcuts":"Delete Backspace",disabled:s,onClick:()=>{m()},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:b,children:t.jsx(mt,{size:14})})]}),e[38]=a,e[39]=s,e[40]=g,e[41]=b,e[42]=m,e[43]=p,e[44]=i,e[45]=P):P=e[45];let L;return e[46]!==$||e[47]!==P?(L=t.jsxs("div",{className:"canvas-toolbar","data-composer-focus":"return",role:"group","aria-label":"Notebook canvas controls",children:[$,P]}),e[46]=$,e[47]=P,e[48]=L):L=e[48],L}function fm(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 pm(){const l=W.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 Df(l){const e=W.c(51),{bookName:s,enabled:n,snapshot:i,stale:a,onRetry:r}=l,{id:o,buttonRef:c,panelRef:d,position:u}=pm(),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?Pn(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 y;e[4]!==i?.groups?(y=new Set(i?.groups.map(jm)??[]),e[4]=i?.groups,e[5]=y):y=e[5];let x;e[6]!==y?(x=[...y],e[6]=y,e[7]=x):x=e[7];const j=x,v=!n,k=`Book usage: ${b} tokens, ${g}${a?", stale":h?", incomplete":""}`;let w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("small",{children:" tokens"}),e[8]=w):w=e[8];let S;e[9]!==b?(S=t.jsxs("span",{children:[b,w]}),e[9]=b,e[10]=S):S=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("span",{className:"book-usage-divider","aria-hidden":"true",children:"·"}),e[11]=R):R=e[11];let N;e[12]!==g?(N=t.jsx("span",{children:g}),e[12]=g,e[13]=N):N=e[13];let M;e[14]!==h||e[15]!==a?(M=(a||h)&&t.jsx("span",{className:"book-usage-indicator","aria-hidden":"true"}),e[14]=h,e[15]=a,e[16]=M):M=e[16];let A;e[17]!==c||e[18]!==o||e[19]!==N||e[20]!==M||e[21]!==v||e[22]!==k||e[23]!==S?(A=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,R,N,M]}),e[17]=c,e[18]=o,e[19]=N,e[20]=M,e[21]=v,e[22]=k,e[23]=S,e[24]=A):A=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("h2",{children:"Book usage"}),e[25]=D):D=e[25];let T;e[26]!==s?(T=t.jsxs("div",{children:[D,t.jsx("p",{children:s})]}),e[26]=s,e[27]=T):T=e[27];let I;e[28]!==o?(I=t.jsx("button",{type:"button",popoverTarget:o,popoverTargetAction:"hide","aria-label":"Close book usage",children:"×"}),e[28]=o,e[29]=I):I=e[29];let E;e[30]!==T||e[31]!==I?(E=t.jsxs("header",{children:[T,I]}),e[30]=T,e[31]=I,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 $;e[36]!==j||e[37]!==h||e[38]!==i||e[39]!==a?($=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:Pn(i.totals)})]})]}),t.jsxs("dl",{className:"book-usage-facts",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Input / output"}),t.jsxs("dd",{children:[as(i.totals.inputTokens,!0)," / ",as(i.totals.outputTokens,!0)]})]}),t.jsxs("div",{children:[t.jsxs("dt",{children:["Cached input ",t.jsx("small",{children:"(included)"})]}),t.jsx("dd",{children:as(i.totals.cachedTokens,!0)})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Reported charges"}),t.jsx("dd",{children:Ss(i.totals.reportedUsd)})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Estimated charges"}),t.jsx("dd",{children:Ss(i.totals.estimatedUsd)})]})]}),h&&t.jsxs("p",{className:"book-usage-notice",children:[i.totals.unpriced>0&&`${i.totals.unpriced} ${i.totals.unpriced===1?"request has an unavailable price":"requests have unavailable prices"}. `,i.totals.missingTokens>0&&`${i.totals.missingTokens} ${i.totals.missingTokens===1?"request has":"requests have"} missing token counts. `,i.incomplete&&"Some usage could not be recorded."]}),i.totals.pendingCount>0&&t.jsxs("p",{className:"book-usage-pending",children:[i.totals.pendingCount," in progress · ",Ss(i.totals.pendingUsd)," estimated, excluded from total"]}),t.jsx("section",{"aria-label":"Usage by activity",className:"book-usage-breakdown",children:j.map(_=>{const z=i.groups.filter(H=>H.activity===_),O=z.reduce(ym,0),U=z.reduce(gm,0),q=z.some(xm);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(bm)]},_)})}),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(hm)]}):t.jsx("p",{className:"book-usage-empty",children:"New AI activity will appear here."}),t.jsxs("footer",{children:["Tracked since ",new Date(i.trackedSince).toLocaleString([],{dateStyle:"medium",timeStyle:"short"}),".",t.jsx("br",{}),"Estimates use recorded provider rates. Earlier usage is not included."]})]}):t.jsx("p",{className:"book-usage-empty",children:a?"Usage is unavailable.":"Loading usage…"}),e[36]=j,e[37]=h,e[38]=i,e[39]=a,e[40]=$):$=e[40];let P;e[41]!==o||e[42]!==d||e[43]!==u||e[44]!==E||e[45]!==F||e[46]!==$?(P=t.jsxs("div",{ref:d,id:o,popover:"auto",role:"dialog","aria-label":"Book usage",className:"book-usage-popover",onToggle:u,children:[E,F,$]}),e[41]=o,e[42]=d,e[43]=u,e[44]=E,e[45]=F,e[46]=$,e[47]=P):P=e[47];let L;return e[48]!==A||e[49]!==P?(L=t.jsxs("div",{className:"book-usage","data-composer-focus":"preserve",children:[A,P]}),e[48]=A,e[49]=P,e[50]=L):L=e[50],L}function hm(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":fm(l)})]},l.id)}function bm(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:Pn(l)})]},`${l.provider}:${l.model}`)}function xm(l){return l.estimatedUsd>0}function gm(l,e){return l+e.unpriced}function ym(l,e){return l+e.reportedUsd+e.estimatedUsd}function jm(l){return l.activity}function vm(l){const e=W.c(18),{call:s}=l,{settings:n,busy:i,error:a,update:r}=to(s);let o,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"settings-section-heading",children:t.jsx("h2",{id:"settings-diagnostics-heading",children:"Diagnostics"})}),c=t.jsx("p",{className:"settings-note",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-section","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 km({call:l}){const[e,s]=C.useState(null),[n,i]=C.useState(!1),[a,r]=C.useState(null),o=async d=>{if(!l)return;const u=d?window.open("about:blank","_blank"):null;i(!0),r(null);try{if(d){const f=await l("connect_service",{service:"dropbox"});u?u.location.href=f.authorize_url:window.open(f.authorize_url,"_blank","noopener,noreferrer")}s(await l("service_status",{service:"dropbox"}))}catch(f){u?.close(),r(f instanceof Error?f.message:String(f))}finally{i(!1)}},c=e?.connected?"Connected · offline access enabled":e?.pending?"Approve access in Dropbox, then check the connection.":"Not connected";return t.jsxs("article",{className:"settings-row settings-dropbox-connection","aria-label":"Dropbox",children:[t.jsxs("div",{className:"settings-row-main",children:[t.jsxs("div",{className:"settings-row-copy",children:[t.jsx("strong",{children:"Dropbox"}),t.jsx("span",{className:"settings-row-detail",children:c})]}),t.jsx("button",{type:"button",className:"settings-quiet","aria-label":"Check Dropbox connection",disabled:n||!l,onClick:()=>{o(!1)},children:"Check"}),t.jsx("button",{type:"button","aria-label":e?.connected?"Reconnect Dropbox":"Connect Dropbox",disabled:n||!l,onClick:()=>{o(!0)},children:e?.connected?"Reconnect":"Connect"})]}),(a||e?.error)&&t.jsx("p",{role:"alert",className:"settings-error",children:a??e?.error})]})}function Sm(l){const e=W.c(25),{busy:s,connection:n,onConnect:i}=l;let a;e[0]!==n.connecting||e[1]!==n.status?(a=so(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=`settings-row x-connection-card x-connection-${r.tone}`;let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("strong",{children:"X"}),e[3]=d):d=e[3];let u;e[4]!==r.detail||e[5]!==r.label?(u=t.jsxs("div",{className:"settings-row-copy",children:[d,t.jsxs("span",{className:"settings-row-detail",children:[r.label," · ",r.detail]})]}),e[4]=r.detail,e[5]=r.label,e[6]=u):u=e[6];const f=n.connecting?"Waiting…":r.actionLabel??"Connect X";let m;e[7]!==o||e[8]!==i||e[9]!==f?(m=t.jsx("button",{type:"button",disabled:o,onClick:i,children:f}),e[7]=o,e[8]=i,e[9]=f,e[10]=m):m=e[10];let b;e[11]!==u||e[12]!==m?(b=t.jsxs("div",{className:"settings-row-main",children:[u,m]}),e[11]=u,e[12]=m,e[13]=b):b=e[13];let p;e[14]!==n.authorizeUrl||e[15]!==n.connecting?(p=n.connecting&&n.authorizeUrl&&t.jsxs("p",{className:"settings-note",children:[t.jsx("a",{href:n.authorizeUrl,target:"_blank",rel:"noopener noreferrer",children:"Open the X authorization page"})," ","if no browser tab appeared."]}),e[14]=n.authorizeUrl,e[15]=n.connecting,e[16]=p):p=e[16];let g;e[17]!==n.connecting||e[18]!==n.error?(g=n.error&&!n.connecting&&t.jsx("p",{className:"settings-error x-connection-error",role:"alert",children:n.error}),e[17]=n.connecting,e[18]=n.error,e[19]=g):g=e[19];let h;return e[20]!==c||e[21]!==b||e[22]!==p||e[23]!==g?(h=t.jsxs("article",{className:c,"aria-label":"X account",children:[b,p,g]}),e[20]=c,e[21]=b,e[22]=p,e[23]=g,e[24]=h):h=e[24],h}const wm=["x","b2","dropbox"];function Nm(l){return l==="configured"?"Set":l==="placeholder"?"Placeholder":"Missing"}function Cm(l){const e=l.source==="1password"?"Managed in 1Password":l.editable?null:"Read only";return[l.maskedKey,e].filter(Boolean).join(" · ")||"Not set"}function $m(l){return l.keyStatus==="configured"?"Edit":l.secret?"Set key":"Set value"}function Im(l){const e=W.c(37),{provider:s,editor:n,busy:i}=l;let a;e[0]!==s?(a=xi(s),e[0]=s,e[1]=a):a=e[1];const r=a,o=`Edit ${r}`;let c;e[2]!==n||e[3]!==s?(c=S=>{S.preventDefault(),n.save(s)},e[2]=n,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==n?(d=S=>{S.key!=="Escape"||S.nativeEvent.isComposing||n.saving||(S.preventDefault(),S.stopPropagation(),n.close())},e[5]=n,e[6]=d):d=e[6];const u=`setting-${s.envKey}`;let f;e[7]!==r||e[8]!==u?(f=t.jsx("label",{className:"settings-visually-hidden",htmlFor:u,children:r}),e[7]=r,e[8]=u,e[9]=f):f=e[9];const m=`setting-${s.envKey}`,b=s.secret?"password":"text",p=n.draft?.value??"",g=i||n.saving;let h;e[10]!==n?(h=S=>n.change(S.target.value),e[10]=n,e[11]=h):h=e[11];let y;e[12]!==s.envKey||e[13]!==g||e[14]!==h||e[15]!==m||e[16]!==b||e[17]!==p?(y=t.jsx("input",{id:m,autoFocus:!0,type:b,value:p,autoComplete:"off",spellCheck:!1,placeholder:s.envKey,disabled:g,onChange:h}),e[12]=s.envKey,e[13]=g,e[14]=h,e[15]=m,e[16]=b,e[17]=p,e[18]=y):y=e[18];let x;e[19]!==i||e[20]!==n.draft?.value||e[21]!==n.saving?(x=i||n.saving||!n.draft?.value.trim(),e[19]=i,e[20]=n.draft?.value,e[21]=n.saving,e[22]=x):x=e[22];const j=n.saving?"Saving…":"Save";let v;e[23]!==x||e[24]!==j?(v=t.jsx("button",{type:"submit",className:"settings-primary",disabled:x,children:j}),e[23]=x,e[24]=j,e[25]=v):v=e[25];let k;e[26]!==n.close||e[27]!==n.saving?(k=t.jsx("button",{type:"button",disabled:n.saving,onClick:n.close,children:"Cancel"}),e[26]=n.close,e[27]=n.saving,e[28]=k):k=e[28];let w;return e[29]!==y||e[30]!==v||e[31]!==k||e[32]!==o||e[33]!==c||e[34]!==d||e[35]!==f?(w=t.jsxs("form",{className:"settings-key-editor","aria-label":o,onSubmit:c,onKeyDown:d,children:[f,y,v,k]}),e[29]=y,e[30]=v,e[31]=k,e[32]=o,e[33]=c,e[34]=d,e[35]=f,e[36]=w):w=e[36],w}function Rm(l){const e=W.c(38),{provider:s,editor:n,busy:i}=l;let a;e[0]!==s?(a=xi(s),e[0]=s,e[1]=a):a=e[1];const r=a,o=n.draft?.key===s.envKey&&s.editable,c=n.message?.key===s.envKey?n.message:null,d=`${r} setting`;let u;e[2]!==r?(u=t.jsx("strong",{children:r}),e[2]=r,e[3]=u):u=e[3];let f;e[4]!==s?(f=Cm(s),e[4]=s,e[5]=f):f=e[5];let m;e[6]!==f?(m=t.jsx("span",{className:"settings-row-detail",children:f}),e[6]=f,e[7]=m):m=e[7];let b;e[8]!==u||e[9]!==m?(b=t.jsxs("div",{className:"settings-row-copy",children:[u,m]}),e[8]=u,e[9]=m,e[10]=b):b=e[10];const p=`settings-status settings-key-${s.keyStatus}`;let g;e[11]!==s.keyStatus?(g=Nm(s.keyStatus),e[11]=s.keyStatus,e[12]=g):g=e[12];let h;e[13]!==p||e[14]!==g?(h=t.jsx("span",{className:p,children:g}),e[13]=p,e[14]=g,e[15]=h):h=e[15];let y;e[16]!==i||e[17]!==o||e[18]!==n||e[19]!==r||e[20]!==s?(y=s.editable?t.jsxs("button",{type:"button",className:"settings-quiet","aria-label":`Edit ${r}`,"aria-expanded":o,disabled:i||n.saving,onClick:w=>n.edit(s,w.currentTarget),children:[t.jsx("span",{className:"settings-edit-text",children:$m(s)}),t.jsx(As,{className:"settings-edit-chevron",size:16,"aria-hidden":"true"})]}):t.jsx("span",{className:"settings-row-spacer"}),e[16]=i,e[17]=o,e[18]=n,e[19]=r,e[20]=s,e[21]=y):y=e[21];let x;e[22]!==y||e[23]!==b||e[24]!==h?(x=t.jsxs("div",{className:"settings-row-main",children:[b,h,y]}),e[22]=y,e[23]=b,e[24]=h,e[25]=x):x=e[25];let j;e[26]!==i||e[27]!==o||e[28]!==n||e[29]!==s?(j=o&&t.jsx(Im,{provider:s,editor:n,busy:i}),e[26]=i,e[27]=o,e[28]=n,e[29]=s,e[30]=j):j=e[30];let v;e[31]!==c?(v=c&&t.jsx("p",{className:c.error?"settings-error":"settings-feedback",role:c.error?"alert":"status",children:c.text}),e[31]=c,e[32]=v):v=e[32];let k;return e[33]!==x||e[34]!==j||e[35]!==v||e[36]!==d?(k=t.jsxs("article",{className:"settings-credential settings-row","aria-label":d,children:[x,j,v]}),e[33]=x,e[34]=j,e[35]=v,e[36]=d,e[37]=k):k=e[37],k}function Cn(l){const e=W.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=>t.jsx(Rm,{provider:c,editor:n,busy:i},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 settings-list",children:a}),e[7]=a,e[8]=r):r=e[8],r}function zn(l){const e=W.c(8),{summary:s,children:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(As,{size:14,"aria-hidden":"true"}),e[0]=i):i=e[0];let a;e[1]!==s?(a=t.jsxs("summary",{children:[i,s]}),e[1]=s,e[2]=a):a=e[2];let r;e[3]!==n?(r=t.jsx("div",{className:"settings-details-body",children:n}),e[3]=n,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=t.jsxs("details",{className:"settings-details",children:[a,r]}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o}const Mm=[{id:"settings-providers-heading",label:"Providers"},{id:"settings-accounts-heading",label:"Accounts"},{id:"settings-storage-heading",label:"Storage"},{id:"settings-diagnostics-heading",label:"Diagnostics"}];function Pm(l){document.getElementById(l)?.scrollIntoView({block:"start",behavior:"smooth"})}function Am(){const l=W.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("nav",{className:"settings-jump","aria-label":"Settings sections",children:Mm.map(Dm)}),l[0]=e):e=l[0],e}function Dm(l){return t.jsx("button",{type:"button",onClick:()=>Pm(l.id),children:l.label},l.id)}function Tm(l){return`${l.filter(s=>s.keyStatus==="configured").length} of ${l.length} set`}function Em(l){const e=W.c(26),{storage:s,bookId:n,loading:i}=l,a=s?.bookId===n?s:null;if(!n){let y;return e[0]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("p",{className:"settings-note",children:"Select a project to inspect its storage."}),e[0]=y):y=e[0],y}if(a?.status==="error"){let y;return e[1]!==a.error?(y=t.jsx("p",{role:"alert",className:"settings-error",children:a.error}),e[1]=a.error,e[2]=y):y=e[2],y}if(a?.status!=="ready"){const y=i?"Loading storage…":"Refresh to inspect storage.";let x;return e[3]!==y?(x=t.jsx("p",{className:"settings-note",role:"status",children:y}),e[3]=y,e[4]=x):x=e[4],x}const r=a.value;let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("dt",{children:"Backup"}),e[5]=o):o=e[5];let c;e[6]!==r.state?(c=r.state.replaceAll("_"," "),e[6]=r.state,e[7]=c):c=e[7];let d;e[8]!==c?(d=t.jsxs("div",{className:"settings-row",children:[o,t.jsx("dd",{children:c})]}),e[8]=c,e[9]=d):d=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("dt",{children:"Pending objects"}),e[10]=u):u=e[10];let f;e[11]!==r.pendingObjects?(f=t.jsxs("div",{className:"settings-row",children:[u,t.jsx("dd",{children:r.pendingObjects})]}),e[11]=r.pendingObjects,e[12]=f):f=e[12];let m;e[13]!==d||e[14]!==f?(m=t.jsxs("dl",{className:"settings-storage-summary settings-list",children:[d,f]}),e[13]=d,e[14]=f,e[15]=m):m=e[15];let b;e[16]!==r.lastError?(b=r.lastError&&t.jsx("p",{role:"alert",className:"settings-error",children:r.lastError}),e[16]=r.lastError,e[17]=b):b=e[17];let p;e[18]!==r?(p=JSON.stringify(r,null,2),e[18]=r,e[19]=p):p=e[19];let g;e[20]!==p?(g=t.jsx(zn,{summary:"Technical details",children:t.jsx("pre",{children:p})}),e[20]=p,e[21]=g):g=e[21];let h;return e[22]!==m||e[23]!==b||e[24]!==g?(h=t.jsxs(t.Fragment,{children:[m,b,g]}),e[22]=m,e[23]=b,e[24]=g,e[25]=h):h=e[25],h}function Tf(l){const e=W.c(117),{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=no(b);let h,y,x,j,v,k,w,S,R,N,M,A,D,T,I,E;if(e[0]!==f||e[1]!==a||e[2]!==i||e[3]!==m||e[4]!==n||e[5]!==r){y=n.filter(Lm);let fe;e[22]!==n?(fe=n.filter(_m),e[22]=n,e[23]=fe):fe=e[23],h=fe;let ue;e[24]!==n?(ue=n.filter(Fm),e[24]=n,e[25]=ue):ue=e[25],x=ue,w="workspace-screen settings-screen",S="Settings",I="settings-page";let pe;e[26]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsxs("div",{children:[t.jsx("h1",{children:"Settings"}),t.jsx("p",{children:"API keys, accounts and storage. Keys are saved on this computer."})]}),e[26]=pe):pe=e[26];const me=i?"Refreshing…":r?"Up to date":"";let be;e[27]!==me?(be=t.jsx("span",{role:"status",children:me}),e[27]=me,e[28]=be):be=e[28];const ye=f||i;let ce;e[29]!==m?(ce=()=>{m()},e[29]=m,e[30]=ce):ce=e[30];let X,ie;e[31]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(Ci,{size:15,"aria-hidden":"true"}),ie=t.jsx("span",{className:"settings-refresh-label",children:"Refresh"}),e[31]=X,e[32]=ie):(X=e[31],ie=e[32]);let he;e[33]!==ye||e[34]!==ce?(he=t.jsxs("button",{type:"button",disabled:ye,onClick:ce,children:[X,ie]}),e[33]=ye,e[34]=ce,e[35]=he):he=e[35],e[36]!==be||e[37]!==he?(E=t.jsxs("header",{children:[pe,t.jsxs("div",{className:"settings-refresh",children:[be,he]})]}),e[36]=be,e[37]=he,e[38]=E):E=e[38],e[39]!==a?(v=a&&t.jsx("p",{role:"alert",className:"settings-error",children:a}),e[39]=a,e[40]=v):v=e[40],e[41]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(Am,{}),e[41]=k):k=e[41],T="settings-columns",D="settings-column",M="settings-section settings-providers",A="settings-providers-heading",j="settings-section-heading",e[42]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("h2",{id:"settings-providers-heading",children:"AI providers"}),e[42]=R):R=e[42],N=y.length>0&&t.jsx("span",{children:Tm(y)}),e[0]=f,e[1]=a,e[2]=i,e[3]=m,e[4]=n,e[5]=r,e[6]=h,e[7]=y,e[8]=x,e[9]=j,e[10]=v,e[11]=k,e[12]=w,e[13]=S,e[14]=R,e[15]=N,e[16]=M,e[17]=A,e[18]=D,e[19]=T,e[20]=I,e[21]=E}else h=e[6],y=e[7],x=e[8],j=e[9],v=e[10],k=e[11],w=e[12],S=e[13],R=e[14],N=e[15],M=e[16],A=e[17],D=e[18],T=e[19],I=e[20],E=e[21];let F;e[43]!==j||e[44]!==R||e[45]!==N?(F=t.jsxs("div",{className:j,children:[R,N]}),e[43]=j,e[44]=R,e[45]=N,e[46]=F):F=e[46];let $;e[47]!==y||e[48]!==f||e[49]!==g||e[50]!==i?($=y.length?t.jsx(Cn,{providers:y,editor:g,busy:f}):t.jsx("p",{className:"settings-note",children:i?"Loading providers…":"Refresh to load provider settings."}),e[47]=y,e[48]=f,e[49]=g,e[50]=i,e[51]=$):$=e[51];let P;e[52]!==F||e[53]!==$||e[54]!==M||e[55]!==A?(P=t.jsxs("section",{className:M,"aria-labelledby":A,children:[F,$]}),e[52]=F,e[53]=$,e[54]=M,e[55]=A,e[56]=P):P=e[56];let L;e[57]!==P||e[58]!==D?(L=t.jsx("div",{className:D,children:P}),e[57]=P,e[58]=D,e[59]=L):L=e[59];let _;e[60]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx("div",{className:"settings-section-heading",children:t.jsx("h2",{id:"settings-accounts-heading",children:"Accounts"})}),e[60]=_):_=e[60];let z;e[61]!==f||e[62]!==u||e[63]!==p?(z=t.jsx(Sm,{busy:f,connection:u,onConnect:p}),e[61]=f,e[62]=u,e[63]=p,e[64]=z):z=e[64];let O;e[65]!==s?(O=t.jsx(km,{call:s}),e[65]=s,e[66]=O):O=e[66];let U;e[67]!==z||e[68]!==O?(U=t.jsxs("div",{className:"settings-list",children:[z,O]}),e[67]=z,e[68]=O,e[69]=U):U=e[69];let q;e[70]!==h||e[71]!==f||e[72]!==g?(q=t.jsx(Cn,{providers:h,editor:g,busy:f}),e[70]=h,e[71]=f,e[72]=g,e[73]=q):q=e[73];let H;e[74]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx("p",{className:"settings-note",children:"Dropbox redirect: http://127.0.0.1:8766/callback"}),e[74]=H):H=e[74];let K;e[75]!==q?(K=t.jsxs(zn,{summary:"App credentials",children:[q,H]}),e[75]=q,e[76]=K):K=e[76];let te;e[77]!==U||e[78]!==K?(te=t.jsxs("section",{className:"settings-section","aria-labelledby":"settings-accounts-heading",children:[_,U,K]}),e[77]=U,e[78]=K,e[79]=te):te=e[79];let ae;e[80]===Symbol.for("react.memo_cache_sentinel")?(ae=t.jsx("h2",{id:"settings-storage-heading",children:"Storage"}),e[80]=ae):ae=e[80];const V=d??"No project selected";let oe;e[81]!==V?(oe=t.jsxs("div",{className:"settings-section-heading",children:[ae,t.jsx("span",{children:V})]}),e[81]=V,e[82]=oe):oe=e[82];let G;e[83]!==c||e[84]!==i||e[85]!==o?(G=t.jsx(Em,{storage:o,bookId:c,loading:i}),e[83]=c,e[84]=i,e[85]=o,e[86]=G):G=e[86];let se;e[87]===Symbol.for("react.memo_cache_sentinel")?(se=t.jsx("p",{className:"settings-note",children:"Shared by all projects."}),e[87]=se):se=e[87];let le;e[88]!==f||e[89]!==g||e[90]!==x?(le=t.jsxs(zn,{summary:"Backblaze configuration",children:[se,t.jsx(Cn,{providers:x,editor:g,busy:f})]}),e[88]=f,e[89]=g,e[90]=x,e[91]=le):le=e[91];let Y;e[92]!==oe||e[93]!==G||e[94]!==le?(Y=t.jsxs("section",{className:"settings-section","aria-labelledby":"settings-storage-heading",children:[oe,G,le]}),e[92]=oe,e[93]=G,e[94]=le,e[95]=Y):Y=e[95];let Z;e[96]!==s?(Z=t.jsx(vm,{call:s}),e[96]=s,e[97]=Z):Z=e[97];let J;e[98]!==te||e[99]!==Y||e[100]!==Z?(J=t.jsxs("div",{className:"settings-column",children:[te,Y,Z]}),e[98]=te,e[99]=Y,e[100]=Z,e[101]=J):J=e[101];let re;e[102]!==L||e[103]!==J||e[104]!==T?(re=t.jsxs("div",{className:T,children:[L,J]}),e[102]=L,e[103]=J,e[104]=T,e[105]=re):re=e[105];let ee;e[106]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsxs("p",{className:"settings-version",children:["videobook-engine ",va.version," · schema ",ka]}),e[106]=ee):ee=e[106];let Q;e[107]!==v||e[108]!==k||e[109]!==re||e[110]!==I||e[111]!==E?(Q=t.jsxs("div",{className:I,children:[E,v,k,re,ee]}),e[107]=v,e[108]=k,e[109]=re,e[110]=I,e[111]=E,e[112]=Q):Q=e[112];let de;return e[113]!==w||e[114]!==S||e[115]!==Q?(de=t.jsx("section",{className:w,"aria-label":S,children:Q}),e[113]=w,e[114]=S,e[115]=Q,e[116]=de):de=e[116],de}function Fm(l){return l.provider==="b2"}function _m(l){return l.provider==="x"||l.provider==="dropbox"}function Lm(l){return!wm.includes(l.provider)}function zm(l){const e=W.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 Yi(){const l=W.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 Om(l){const e=W.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(_i,{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 Bm(l){const e=W.c(4),{state:s}=l;if(s==="blocking"){let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(rc,{size:14,"aria-hidden":"true"}),e[0]=n):n=e[0],n}if(s==="failed"){let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(Ni,{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(_i,{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 Um(l){const e=W.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(Bm,{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(Yi,{}):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 y;return e[19]!==c||e[20]!==g||e[21]!==h?(y=t.jsxs("footer",{className:c,children:[g,h]}),e[19]=c,e[20]=g,e[21]=h,e[22]=y):y=e[22],y}function Hm(l){const e=W.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(Om,{effect:i}),e[11]=i,e[12]=g):g=e[12];let h;e[13]!==s||e[14]!==g?(h=t.jsxs("div",{className:"confirm-sheet-decisions",children:[g,s]}),e[13]=s,e[14]=g,e[15]=h):h=e[15];let y;return e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==p||e[20]!==h?(y=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]=y):y=e[21],y}function Ji(){return typeof window>"u"||typeof window.matchMedia!="function"?null:window.matchMedia(lo)}function Km(l){const e=Ji();return e?(e.addEventListener("change",l),()=>e.removeEventListener("change",l)):()=>{}}function Vm(){return Ji()?.matches??!0}function qm(){return C.useSyncExternalStore(Km,Vm,Wm)}function Wm(){return!0}function Ef(l){const e=W.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,y=s===void 0?null:s,x=i===void 0?"Apply":i,j=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(),R=`${S}-title`,N=`${S}-status`,M=C.useContext(Ui),[A,D]=C.useState(null);let T;e[0]!==M?.outcome?(T=()=>M?.outcome??null,e[0]=M?.outcome,e[1]=T):T=e[1];const[I]=C.useState(T);let E;e[2]!==M?.notice?(E=()=>M?.notice??null,e[2]=M?.notice,e[3]=E):E=e[3];const[F]=C.useState(E),$=M&&M.outcome!==I?M.outcome:null,P=M&&M.notice!==F?M.notice:null,L=io({busy:r,busyLabel:j,validation:h,outcome:$,notice:P}),_=qm(),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}=zd(U);let K;e[9]!==M||e[10]!==P||e[11]!==$?(K=()=>{$?M?.dismissOutcome():P&&M?.dismissNotice()},e[9]=M,e[10]=P,e[11]=$,e[12]=K):K=e[12];const te=K,ae=`confirm-sheet confirm-sheet-${f}`;let V;e[13]!==A?(V=A===null?void 0:{"--confirm-review-height":`${A}px`},e[13]=A,e[14]=V):V=e[14];const oe=L.message??j,G=L.state==="failed";let se;e[15]!==O||e[16]!==n||e[17]!==x||e[18]!==r||e[19]!==m||e[20]!==oe||e[21]!==G?(se=t.jsx(zm,{applyDisabled:O,applyFormId:n,applyLabel:x,busy:r,busyLabel:oe,failed:G,onCancel:m}),e[15]=O,e[16]=n,e[17]=x,e[18]=r,e[19]=m,e[20]=oe,e[21]=G,e[22]=se):se=e[22];let le;e[23]!==k||e[24]!==z?(le=z?k??t.jsx(Yi,{}):null,e[23]=k,e[24]=z,e[25]=le):le=e[25];const Y=z?N:void 0;let Z;e[26]!==y||e[27]!==v||e[28]!==se||e[29]!==le||e[30]!==Y||e[31]!==p||e[32]!==g||e[33]!==R?(Z=t.jsx(Hm,{actions:se,address:y,effect:v,hints:le,hintsId:Y,tag:p,title:g,titleId:R}),e[26]=y,e[27]=v,e[28]=se,e[29]=le,e[30]=Y,e[31]=p,e[32]=g,e[33]=R,e[34]=Z):Z=e[34];let J;e[35]!==q?(J=t.jsx(Ld,{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 ee;e[40]!==te||e[41]!==k||e[42]!==z||e[43]!==w||e[44]!==L||e[45]!==N?(ee=!z&&t.jsx(Um,{hints:k,onDismissStatus:te,secondaryActions:w,status:L,statusId:N}),e[40]=te,e[41]=k,e[42]=z,e[43]=w,e[44]=L,e[45]=N,e[46]=ee):ee=e[46];let Q;e[47]===Symbol.for("react.memo_cache_sentinel")?(Q=t.jsx(Oi,{label:"Resize review and log",targetSelector:".confirm-sheet",edge:"bottom",minimum:180,reserve:36,onResize:D}),e[47]=Q):Q=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]!==Z||e[55]!==re||e[56]!==ee?(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:[Z,re,ee,Q]}),e[48]=a,e[49]=H,e[50]=q,e[51]=N,e[52]=ae,e[53]=V,e[54]=Z,e[55]=re,e[56]=ee,e[57]=de):de=e[57],de}function Gm(l){const e=W.c(13),{post:s,source:n}=l;let i;e[0]!==s||e[1]!==n?(i=t.jsx(Xm,{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(Jm,{caption:a}),e[3]=a,e[4]=r):r=e[4];let o;e[5]!==s?(o=s?t.jsx(Qm,{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 Xm(l){const e=W.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?gi(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(Ym)}),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 Ym(l){return t.jsxs("span",{className:"post-badge",children:[t.jsx(Qt,{size:10,strokeWidth:2.6,"aria-hidden":"true"}),l]},l)}function Jm(l){const e=W.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 Qm(l){const e=W.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(e1,{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(Zm)});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 Zm(l){return t.jsxs("span",{children:[t.jsx("strong",{children:l.value})," ",l.label]},l.label)}function e1(l){const e=W.c(8),{post:s,text:n}=l;let i;e[0]!==s?(i=gi(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(Ti,{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 t1=C.createContext({ready:!1,states:{},onFile:()=>{},onFileError:()=>{},onOpenLibrary:()=>{}}),s1=C.createContext(async()=>{}),n1=C.createContext({ready:!1,deleteCell:async()=>{},repairCell:async()=>{},retryCell:async()=>{}}),l1=C.createContext(null),i1=C.createContext(new Map),a1=C.createContext({openCellId:null,open:()=>{}});function r1(l){return`cell-context-menu-${l}`}const o1=C.createContext(null),Ff=C.createContext(new Map),_f=C.createContext(new Map),c1=C.createContext(new Map);function d1(l){const e=W.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 y=s?.shots.slice(0,3)??[];u=Math.max(0,o-y.length),d=s?.outputJson,f="cell-copy cell-copy-analysis";const x=o>0?`${o} shots`:"Analysis pending";let j;e[9]!==x?(j=t.jsx("strong",{children:x}),e[9]=x,e[10]=j):j=e[10];let v;e[11]!==c?(v=c!==null&&t.jsx("span",{children:Kt(c)}),e[11]=c,e[12]=v):v=e[12],e[13]!==j||e[14]!==v?(m=t.jsxs("div",{className:"analysis-cell-summary",children:[j,v]}),e[13]=j,e[14]=v,e[15]=m):m=e[15],b=y.length>0&&t.jsx("ol",{className:"analysis-cell-shots",children:y.map(u1)}),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(Gn,{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 u1(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 m1(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=W.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),[y,x]=C.useState(!1),[j,v]=C.useState(0),[k,w]=C.useState(0),S=C.useRef(null),R=C.useRef(!1),N=r!==null&&a!==null,M=i!==null,A=M?i.length===0:n===null;let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=Y=>{S.current=Y,!(!Y||!R.current)&&(R.current=!1,Y.play().catch(()=>x(!1)))},e[0]=D):D=e[0];const T=D;let I;e[1]!==y?(I=Y=>{Y.preventDefault();const Z=S.current;if(y){Z?.pause();return}if(!Z){R.current=!0,h(!0);return}Z.play().catch(()=>x(!1))},e[1]=y,e[2]=I):I=e[2];const E=I;let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=Y=>{const Z=Y.currentTarget;v(m1(Z)),w(Z.currentTime)},e[3]=F):F=e[3];const $=F;let P;e[4]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{x(!1),v(0),w(0)},e[4]=P):P=e[4];const L=P;let _;e[5]!==k||e[6]!==u||e[7]!==y?(_=u&&y?`${Kt(Math.floor(k))} / ${u.label}`:u?.label??null,e[5]=k,e[6]=u,e[7]=y,e[8]=_):_=e[8];const z=_,O=`cell-media${y?" cell-media-playing":""}`;let U;e[9]===Symbol.for("react.memo_cache_sentinel")?(U=()=>h(!0),e[9]=U):U=e[9];let q;e[10]!==y?(q=()=>{y||h(!1)},e[10]=y,e[11]=q):q=e[11];let H;e[12]===Symbol.for("react.memo_cache_sentinel")?(H=()=>h(!0),e[12]=H):H=e[12];let K;e[13]!==o||e[14]!==g||e[15]!==M||e[16]!==a||e[17]!==r||e[18]!==y||e[19]!==n||e[20]!==j||e[21]!==i?(K=M?i.length>0?t.jsx(nd,{peaks:i,progress:j}):t.jsx(Hi,{}):g&&a&&r==="video"?t.jsx("video",{ref:T,src:a,poster:n??void 0,muted:!y,playsInline:!0,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:$,onEnded:L}):n?t.jsx("img",{src:n,alt:o,loading:"lazy",decoding:"async"}):null,e[13]=o,e[14]=g,e[15]=M,e[16]=a,e[17]=r,e[18]=y,e[19]=n,e[20]=j,e[21]=i,e[22]=K):K=e[22];let te;e[23]!==g||e[24]!==M||e[25]!==a?(te=M&&g&&a&&t.jsx("audio",{ref:T,src:a,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:$,onEnded:L}),e[23]=g,e[24]=M,e[25]=a,e[26]=te):te=e[26];let ae;e[27]!==A||e[28]!==b||e[29]!==m||e[30]!==y?(ae=A&&!y&&t.jsxs("span",{className:"cell-media-pending-face","aria-hidden":"true",children:[b,t.jsx("span",{children:m})]}),e[27]=A,e[28]=b,e[29]=m,e[30]=y,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(p1)}),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 G;e[38]!==s||e[39]!==N||e[40]!==y||e[41]!==E?(G=N&&t.jsx("button",{type:"button",className:"cell-media-play nodrag","aria-label":`${y?"Pause":"Play"} ${s}`,onClick:E,onPointerDown:f1,children:y?t.jsx(Di,{size:13,strokeWidth:2,"aria-hidden":"true"}):t.jsx(Ds,{size:13,fill:"currentColor",strokeWidth:0,"aria-hidden":"true"})}),e[38]=s,e[39]=N,e[40]=y,e[41]=E,e[42]=G):G=e[42];let se;e[43]!==N||e[44]!==j?(se=N&&t.jsx("span",{className:"cell-media-progress","aria-hidden":"true",children:t.jsx("span",{style:{width:`${j*100}%`}})}),e[43]=N,e[44]=j,e[45]=se):se=e[45];let le;return e[46]!==p||e[47]!==K||e[48]!==te||e[49]!==ae||e[50]!==V||e[51]!==oe||e[52]!==G||e[53]!==se||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,te,ae,V,oe,G,se,p]}),e[46]=p,e[47]=K,e[48]=te,e[49]=ae,e[50]=V,e[51]=oe,e[52]=G,e[53]=se,e[54]=O,e[55]=q,e[56]=c,e[57]=le):le=e[57],le}function f1(l){return l.stopPropagation()}function p1(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 h1=[{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 b1(l){const e=W.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:h1.map(x1)}),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 x1(l){return t.jsx("span",{className:"cell-state-streak",style:{left:l.left,animationDelay:`${l.delay}s`,animationDuration:`${l.duration}s`}},l.left)}const g1=1e3,y1=Array.from({length:yi},(l,e)=>e+1);function j1(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 v1(l,e){return l<e?"done":l===e?"active":"pending"}function k1(l){const e=W.c(14),{phase:s}=l;let n;e[0]!==s.step?(n=y1.map(d=>t.jsx("span",{className:"cell-state-phase-step","data-status":v1(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,"/",yi]}),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 S1(l){const e=W.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(N1),m=a??f,[b,p]=C.useState(w1);let g,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const F=setInterval(()=>p(Date.now()),g1);return()=>clearInterval(F)},h=[],e[0]=g,e[1]=h):(g=e[0],h=e[1]),C.useEffect(g,h);const y=Math.max(0,b-m);let x;e[2]!==y?(x=j1(y),e[2]=y,e[3]=x):x=e[3];const j=x;let v;e[4]!==n?(v=n.toLowerCase(),e[4]=n,e[5]=v):v=e[5];const k=`@${i} ${v}`;let w;e[6]!==r?(w=t.jsx(b1,{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 R;e[10]!==n?(R=t.jsx("strong",{children:n}),e[10]=n,e[11]=R):R=e[11];let N;e[12]!==j?(N=t.jsx("span",{className:"cell-state-timer","aria-hidden":"true",children:j}),e[12]=j,e[13]=N):N=e[13];let M;e[14]!==R||e[15]!==N?(M=t.jsxs("div",{className:"cell-state-overlay-copy",children:[R,N]}),e[14]=R,e[15]=N,e[16]=M):M=e[16];let A;e[17]!==S||e[18]!==M?(A=t.jsxs("div",{className:"cell-state-clock-row",children:[S,M]}),e[17]=S,e[18]=M,e[19]=A):A=e[19];let D;e[20]!==d?(D=d&&t.jsx("span",{className:"cell-state-meta",title:d,children:d}),e[20]=d,e[21]=D):D=e[21];let T;e[22]!==u?(T=u&&t.jsx(k1,{phase:u}),e[22]=u,e[23]=T):T=e[23];let I;e[24]!==A||e[25]!==D||e[26]!==T?(I=t.jsxs("div",{className:"cell-state-overlay-body cell-state-clock-body",children:[A,D,T]}),e[24]=A,e[25]=D,e[26]=T,e[27]=I):I=e[27];let E;return e[28]!==I||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,I]}),e[28]=I,e[29]=k,e[30]=w,e[31]=E):E=e[31],E}function w1(){return Date.now()}function N1(){return Date.now()}function $n(l){l.stopPropagation()}function C1(l){const e=W.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=$1;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 y;e[4]!==n?(y=t.jsx("strong",{children:n}),e[4]=n,e[5]=y):y=e[5];let x;e[6]!==s?(x=t.jsx("p",{className:"cell-state-failed-message",children:s}),e[6]=s,e[7]=x):x=e[7];let j;e[8]!==u?(j=u&&t.jsx("span",{className:"cell-state-meta",title:u,children:u}),e[8]=u,e[9]=j):j=e[9];let v;e[10]!==i||e[11]!==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:$n,onClick:m(o),children:[t.jsx(Un,{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:$n,onClick:m(r),children:[t.jsx(oc,{size:10,"aria-hidden":"true"}),"REPAIR"]}),c&&t.jsxs("button",{type:"button",className:"cell-state-action cell-state-delete nodrag","aria-label":`Delete @${i}`,title:"Delete this cell now",onPointerDown:$n,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]!==y||e[18]!==x||e[19]!==j?(k=t.jsxs("div",{className:"cell-state-overlay-body cell-state-failed-body",children:[y,x,j,v]}),e[16]=v,e[17]=y,e[18]=x,e[19]=j,e[20]=k):k=e[20];let w;return e[21]!==s||e[22]!==k||e[23]!==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 $1(l){return e=>{e.stopPropagation(),l()}}function I1(l){const e=W.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 y=uo(s,i,{error:r??null,startedAt:a??null});if(y.overlay==="clock"&&y.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(S1,{icon:o,label:y.label,address:n,startedAt:y.startedAt,variant:i==="downloading"?"stream":"rise",meta:p,phase:x});break e}if(y.overlay==="failed"&&y.error){const x=fo(y.error),j=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]!==y||e[21]!==j||e[22]!==v||e[23]!==k?(w=t.jsx(C1,{error:y.error,label:j,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]=y,e[21]=j,e[22]=v,e[23]=k,e[24]=w):w=e[24],h=w;break e}}e[0]=n,e[1]=b,e[2]=g,e[3]=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 Qi=He.columnCount*He.columnPitch-He.gap,Gl=200,R1=36,Xl=120,M1={width:Qi,height:He.squareSize};function P1(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 In(l){return`${Math.floor(l/60)}:${Math.floor(l%60).toString().padStart(2,"0")}`}function A1(l){const e=W.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 D=document.activeElement,T=n.current;return T?.showModal(),T?.querySelector("input")?.focus(),()=>{T?.close(),xo(D instanceof HTMLElement?D: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,y,x,j,v,k;if(e[2]!==s||e[3]!==c.items||e[4]!==c.trackId||e[5]!==i){let D;e[19]!==i?(D=$=>$.label.toLowerCase().includes(i.toLowerCase()),e[19]=i,e[20]=D):D=e[20],d=c.items.filter(D),p=gs.createPortal,y=n,x="timeline-source-picker",j="Add a timeline clip",v="preserve",e[21]!==s?(k=$=>{$.preventDefault(),s.closePicker()},e[21]=s,e[22]=k):k=e[22],e[23]!==s.closePicker?(u=$=>{$.stopPropagation(),go($,{busy:!1,container:$.currentTarget,onClose:s.closePicker})},e[23]=s.closePicker,e[24]=u):u=e[24],e[25]!==s?(f=$=>{$.target===$.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 I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(mt,{size:16}),e[28]=I):I=e[28],e[29]!==s.closePicker?(m=t.jsxs("header",{children:[T,t.jsx("button",{type:"button",onClick:s.closePicker,"aria-label":"Close clip picker",children:I})]}),e[29]=s.closePicker,e[30]=m):m=e[30];let E;e[31]===Symbol.for("react.memo_cache_sentinel")?(E=$=>a($.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=$=>t.jsxs("button",{type:"button",disabled:s.busy,onClick:()=>{s.append(c.trackId,$.artifactId)},children:[$.thumbnailUrl?t.jsx("img",{src:$.thumbnailUrl,alt:"",loading:"lazy"}):t.jsx(St,{size:24}),t.jsx("span",{children:$.label}),t.jsx(es,{size:16})]},$.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]=y,e[15]=x,e[16]=j,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],y=e[14],x=e[15],j=e[16],v=e[17],k=e[18];let w;e[37]!==d.length?(w=d.length===0&&t.jsx("p",{children:"No matching media on this page."}),e[37]=d.length,e[38]=w):w=e[38];let S;e[39]!==w||e[40]!==g||e[41]!==h?(S=t.jsxs("div",{className:g,children:[h,w]}),e[39]=w,e[40]=g,e[41]=h,e[42]=S):S=e[42];let R;e[43]!==s.error?(R=s.error&&t.jsx("p",{role:"alert",children:s.error}),e[43]=s.error,e[44]=R):R=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 M;e[48]!==u||e[49]!==f||e[50]!==m||e[51]!==b||e[52]!==S||e[53]!==R||e[54]!==N||e[55]!==y||e[56]!==x||e[57]!==j||e[58]!==v||e[59]!==k?(M=t.jsxs("dialog",{ref:y,className:x,"aria-label":j,"data-composer-focus":v,onCancel:k,onKeyDown:u,onClick:f,children:[m,b,S,R,N]}),e[48]=u,e[49]=f,e[50]=m,e[51]=b,e[52]=S,e[53]=R,e[54]=N,e[55]=y,e[56]=x,e[57]=j,e[58]=v,e[59]=k,e[60]=M):M=e[60];let A;return e[61]!==p||e[62]!==M?(A=p(M,document.body),e[61]=p,e[62]=M,e[63]=A):A=e[63],A}function D1(l){const e=W.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:y,trimBounds:x,rhythm:j}=l,v=m===void 0?"canvas":m,[k,w]=C.useState(v==="preview"?"fit":48),[S,R]=C.useState(0),[N,M]=C.useState(0),A=i.selectedClipId,[D,T]=C.useState(null),I=C.useRef(!1),[E,F]=C.useState(null),$=C.useRef(null),P=C.useRef(null),[L,_]=C.useState(120),[z,O]=C.useState(Qi-Gl),U=s?s.frameRate.numerator/s.frameRate.denominator:30;let q;if(e[0]!==s?.captions||e[1]!==s?.clips){const Ce=s?.clips.reduce(z1,0)??0;q=s?.captions.reduce(L1,Ce)??Ce,e[0]=s?.captions,e[1]=s?.clips,e[2]=q}else q=e[2];const H=q,K=H/U,te=v==="preview"?Math.min(Xl,z/10):Xl,ae=Math.max(1,z-te)/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+te),G=Math.min(S,oe-z);let se;e[3]!==s?.tracks?(se=s?.tracks.reduce(_1,void 0),e[3]=s?.tracks,e[4]=se):se=e[4];const le=se;le?.trackId;let Y;e[5]!==le?.trackId||e[6]!==s?(Y=s?.tracks.filter(Ce=>Ce.kind==="audio"||Ce.kind==="video"&&Ce.trackId!==le?.trackId&&s.clips.some(Ee=>Ee.trackId===Ce.trackId))??[],e[5]=le?.trackId,e[6]=s,e[7]=Y):Y=e[7];const Z=Y;let J;if(e[8]!==s?.clips){J=new Map;for(const Ce of s?.clips??[]){const Ee=J.get(Ce.trackId)??[];Ee.push(Ce),J.set(Ce.trackId,Ee)}e[8]=s?.clips,e[9]=J}else J=e[9];const re=J;let ee;e[10]!==n?(ee=new Map(n.map(F1)),e[10]=n,e[11]=ee):ee=e[11];const Q=ee;let de,fe;e[12]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{const Ce=$.current,Ee=P.current;if(!Ce||!Ee)return;const qe=new ResizeObserver(()=>{_(Ce.clientHeight);const _e=Number.parseFloat(getComputedStyle(Ee).marginLeft)||Gl;O(Math.max(1,Math.min(Ee.clientWidth,Ce.clientWidth-_e)))});return qe.observe(Ce),qe.observe(Ee),()=>qe.disconnect()},fe=[],e[12]=de,e[13]=fe):(de=e[12],fe=e[13]),C.useEffect(de,fe);const ue=v==="preview"?64:R1,pe=Math.max(0,Math.min(Math.floor(N/ue),Z.length-1)-1);let me,be,ye,ce,X,ie,he,ke,$e,De,Ie,Te,Fe,et,Ye,Ke;if(e[14]!==o||e[15]!==i||e[16]!==Q||e[17]!==L||e[18]!==G||e[19]!==re||e[20]!==a||e[21]!==D||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]!==y||e[38]!==V||e[39]!==v||e[40]!==j||e[41]!==A||e[42]!==s||e[43]!==b||e[44]!==ue||e[45]!==Z||e[46]!==E||e[47]!==x||e[48]!==k){const Ce=Z.slice(pe,pe+Math.ceil(L/ue)+3),Ee=a||i.busy;let qe;e[65]!==A||e[66]!==s?.clips?(qe=s?.clips.find(Pe=>Pe.clipId===A),e[65]=A,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(Pe=>Pe.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(G/V/At),Dt=Array.from({length:Math.ceil(z/V/At)+2},(Pe,Ne)=>(wt+Ne)*At);j?.markers;let Ze;if(e[71]!==G||e[72]!==U||e[73]!==z||e[74]!==V||e[75]!==j?.markers){Ze=[];for(const Pe of j?.markers??[]){const Ne=Pe.frame/U*V-G,kt=Ze[Ze.length-1],_t=kt?kt.frame/U*V-G:-1/0;if(!(Ne<0||Ne>z)){if(Ne-_t<(Pe.bar?8:14)){Pe.bar&&kt&&!kt.bar&&(Ze[Ze.length-1]=Pe);continue}Ze.push(Pe)}}e[71]=G,e[72]=U,e[73]=z,e[74]=V,e[75]=j?.markers,e[76]=Ze}else Ze=e[76];const ne=Ze;let xe;e[77]!==G||e[78]!==H||e[79]!==U||e[80]!==c||e[81]!==V?(xe=function(Ne,kt){const _t=kt.getBoundingClientRect(),Ut=(Ne-_t.left)*kt.clientWidth/_t.width;c(Math.max(0,Math.min(H-1,Math.round((Ut+G)/V*U))))},e[77]=G,e[78]=H,e[79]=U,e[80]=c,e[81]=V,e[82]=xe):xe=e[82];const Re=xe,Xe=function(Ne,kt){const _t=re.get(Ne.trackId)??[],Ut=Ne.kind==="video"&&Ne.trackId!==le?.trackId,Lt=_t.filter(je=>{const dt=je.timelineStartFrame/U*V;return dt+je.durationFrames/U*V>=G-100&&dt<=G+z+100});return t.jsxs("div",{className:`timeline-track timeline-track-${Ne.kind}`,"data-track-id":Ne.trackId,style:kt,children:[t.jsxs("div",{className:"timeline-track-label",children:[t.jsx("span",{title:Ne.name,children:Ut?`${Ne.name} · read only`:Ne.name}),!Ut&&t.jsx("button",{type:"button",disabled:Ee||Ne.locked,onClick:()=>{i.openPicker(Ne.trackId)},"aria-label":`Add clip to ${Ne.name}`,children:t.jsx(es,{size:14})}),Ne.kind==="audio"&&_t.length===0&&Z.filter(E1).length>1&&t.jsx("button",{type:"button",disabled:Ee||Ne.locked,onClick:()=>{i.removeTrack(Ne.trackId)},"aria-label":`Remove ${Ne.name}`,children:t.jsx(mt,{size:12})})]}),t.jsxs("div",{className:"timeline-track-lane",onClick:je=>Re(je.clientX,je.currentTarget),children:[Lt.map(je=>{const dt=Q.get(je.source.artifactId),Ht=E?.clipId===je.clipId?E:null,Es=(Ht?Ht.start:D?.clipId===je.clipId?D.frame:je.timelineStartFrame)/U*V-G,cs=(Ht?Ht.end-Ht.start:je.durationFrames)/U*V,ns=!!(y&&x&&A===je.clipId&&Ne.kind==="video"&&!Ut&&!Ne.locked&&!Ee),Fs=j?.analysis?.artifactId===je.source.artifactId?j.analysis:null,Gt=Ne.kind==="audio"?ho(je,Fs?.waveform??dt?.waveform??[],Fs?.durationSeconds??dt?.duration??0,U,Math.min(2048,Math.max(32,Math.ceil(cs/2)))):[],_s=bo(Gt);return t.jsxs("button",{className:`timeline-clip${A===je.clipId?" selected":""}${j?.masterClipId===je.clipId?" timeline-master":""}`,type:"button","data-clip-id":je.clipId,"aria-pressed":A===je.clipId,title:`${dt?.label??"Clip"} · ${(je.durationFrames/U).toFixed(2)}s`,style:{left:Es,width:Math.max(2,cs)},onPointerDown:st=>{!g||Ut||Ne.kind!=="video"||Ne.locked||Ee||st.button!==0||(I.current=!1,st.currentTarget.setPointerCapture(st.pointerId),T({clipId:je.clipId,clientX:st.clientX,start:je.timelineStartFrame,frame:je.timelineStartFrame}))},onPointerMove:st=>{if(!D||D.clipId!==je.clipId)return;Math.abs(st.clientX-D.clientX)>4&&(I.current=!0);const Rt=Math.max(0,D.start+(st.clientX-D.clientX)/V*U),Be=st.altKey?Math.round(Rt):kl(Rt,j?.markers??[],j?.snap??"off",12/V*U);T({...D,frame:Be})},onPointerUp:()=>{D?.clipId===je.clipId&&I.current&&D.frame!==je.timelineStartFrame&&g?.(je,D.frame),T(null)},onPointerCancel:()=>{I.current=!1,T(null)},onKeyDown:st=>{st.key==="Escape"&&D&&(st.stopPropagation(),I.current=!1,T(null))},onClick:st=>{if(st.stopPropagation(),I.current){I.current=!1;return}i.selectClip(je.clipId),p?.(je),c(je.timelineStartFrame)},children:[_s&&t.jsx("svg",{className:"timeline-waveform",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:t.jsx("path",{d:_s})}),dt?.thumbnailUrl&&Ne.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:T1,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,j?.markers??[],j?.snap??"off",12/V*U);F({...E,...P1(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||y?.(je,st,Be.start,Be.end))},onPointerCancel:()=>F(null)},st))]},je.clipId)}),_t.length===0&&t.jsxs("span",{className:"timeline-empty-lane",children:["Add ",Ne.kind," to begin"]}),ne.map(je=>t.jsx("i",{className:`timeline-beat${je.bar?" bar":""}${je.manual?" manual":""}`,style:{left:je.frame/U*V-G},"aria-hidden":"true"},je.frame)),t.jsx("i",{className:"timeline-playhead",style:{left:r/U*V-G}})]})]},Ne.trackId)};$e=`notebook-timeline${v==="preview"?" notebook-timeline-preview":""}`,De=v==="canvas"?M1:void 0,Ie=`Timeline ${o}`,Te="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=In(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"),R(0),P.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],X="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=In(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 Me;e[144]!==Re?(Me=Pe=>Re(Pe.clientX,Pe.currentTarget),e[144]=Re,e[145]=Me):Me=e[145];const we=Dt.map(Pe=>t.jsx("span",{style:{left:Pe*V-G},children:In(Pe)},Pe));let Le;e[146]!==Me||e[147]!==we?(Le=t.jsx("div",{className:"timeline-ruler","aria-label":"Timeline ruler",onClick:Me,children:we}),e[146]=Me,e[147]=we,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&&Xe(le),be="timeline-audio-viewport",ye=$,e[152]===Symbol.for("react.memo_cache_sentinel")?(ce=Pe=>M(Pe.currentTarget.scrollTop),e[152]=ce):ce=e[152],Ye="timeline-audio-content";const Ue=Z.length*ue;e[153]!==Ue?(Ke={height:Ue},e[153]=Ue,e[154]=Ke):Ke=e[154],me=Ce.map((Pe,Ne)=>Xe(Pe,{position:"absolute",top:(pe+Ne)*ue,height:ue,width:"100%"})),e[14]=o,e[15]=i,e[16]=Q,e[17]=L,e[18]=G,e[19]=re,e[20]=a,e[21]=D,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]=y,e[38]=V,e[39]=v,e[40]=j,e[41]=A,e[42]=s,e[43]=b,e[44]=ue,e[45]=Z,e[46]=E,e[47]=x,e[48]=k,e[49]=me,e[50]=be,e[51]=ye,e[52]=ce,e[53]=X,e[54]=ie,e[55]=he,e[56]=ke,e[57]=$e,e[58]=De,e[59]=Ie,e[60]=Te,e[61]=Fe,e[62]=et,e[63]=Ye,e[64]=Ke}else me=e[49],be=e[50],ye=e[51],ce=e[52],X=e[53],ie=e[54],he=e[55],ke=e[56],$e=e[57],De=e[58],Ie=e[59],Te=e[60],Fe=e[61],et=e[62],Ye=e[63],Ke=e[64];let Ve;e[155]!==me||e[156]!==Ye||e[157]!==Ke?(Ve=t.jsx("div",{className:Ye,style:Ke,children:me}),e[155]=me,e[156]=Ye,e[157]=Ke,e[158]=Ve):Ve=e[158];let lt;e[159]!==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 Ae;e[164]===Symbol.for("react.memo_cache_sentinel")?(Ae=Ce=>R(Ce.currentTarget.scrollLeft),e[164]=Ae):Ae=e[164];let We;e[165]!==oe?(We=t.jsx("div",{className:"timeline-horizontal",ref:P,onScroll:Ae,children:t.jsx("div",{style:{width:oe,height:1}})}),e[165]=oe,e[166]=We):We=e[166];let Ge;e[167]!==X||e[168]!==ie||e[169]!==he||e[170]!==ke||e[171]!==lt||e[172]!==We?(Ge=t.jsxs("div",{className:X,children:[ie,he,ke,lt,We]}),e[167]=X,e[168]=ie,e[169]=he,e[170]=ke,e[171]=lt,e[172]=We,e[173]=Ge):Ge=e[173];let Je;e[174]!==i?(Je=i.picker&&t.jsx(A1,{assembly:i}),e[174]=i,e[175]=Je):Je=e[175];let tt;return e[176]!==$e||e[177]!==De||e[178]!==Ie||e[179]!==Te||e[180]!==Fe||e[181]!==et||e[182]!==Ge||e[183]!==Je?(tt=t.jsxs("section",{className:$e,style:De,"aria-label":Ie,"data-composer-focus":Te,children:[Fe,et,Ge,Je]}),e[176]=$e,e[177]=De,e[178]=Ie,e[179]=Te,e[180]=Fe,e[181]=et,e[182]=Ge,e[183]=Je,e[184]=tt):tt=e[184],tt}function T1(l){return l.stopPropagation()}function E1(l){return l.kind==="audio"}function F1(l){return[l.artifactId,l]}function _1(l,e){return e.kind==="video"&&(!l||e.ordinal<l.ordinal)?e:l}function L1(l,e){return Math.max(l,e.timelineStartFrame+e.durationFrames)}function z1(l,e){return Math.max(l,e.timelineStartFrame+e.durationFrames)}function Yl(l){const e=W.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(Ei,{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(Bn,{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(Fi,{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(An,{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(An,{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 O1(l){return l==="generate_video"?"GEN VID":l==="generate_image"?"GEN IMG":l==="generate_audio"?"GEN AUD":vi(l)}function Jl(l){return ji(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 B1(l){return l?.thumbnailUrl??l?.mediaUrl??null}function Ql(l){const e=W.c(18),{asset:s,artifactId:n,label:i,time:a}=l;let r;e[0]!==s?(r=B1(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 U1(l){const e=W.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 H1(l){const e=W.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 y,x;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=O=>{Ks(O.dataTransfer)&&(O.preventDefault(),O.stopPropagation(),f(!0))},x=O=>{Ks(O.dataTransfer)&&(O.preventDefault(),O.stopPropagation(),f(!1))},e[6]=y,e[7]=x):(y=e[6],x=e[7]);let j;e[8]!==m||e[9]!==i?(j=O=>{Ks(O.dataTransfer)&&(O.preventDefault(),O.stopPropagation(),O.dataTransfer.dropEffect=i&&!m?"copy":"none")},e[8]=m,e[9]=i,e[10]=j):j=e[10];let v;e[11]!==p||e[12]!==m?(v=O=>{Ks(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(Kn,{size:22}),e[17]=m,e[18]=S):S=e[18];const R=m?"Attaching media…":`Add ${n}`;let N;e[19]!==R?(N=t.jsx("strong",{children:R}),e[19]=R,e[20]=N):N=e[20];let M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx("span",{children:"Recent media or drop a file"}),e[21]=M):M=e[21];let A;e[22]!==S||e[23]!==N||e[24]!==k||e[25]!==w?(A=t.jsxs("button",{type:"button",className:"cell-media-slot-library",disabled:k,onClick:w,children:[S,N,M]}),e[22]=S,e[23]=N,e[24]=k,e[25]=w,e[26]=A):A=e[26];const D=m||!i;let T,I;e[27]===Symbol.for("react.memo_cache_sentinel")?(T=O=>{O.stopPropagation(),d.current?.click()},I=t.jsx(sn,{size:13}),e[27]=T,e[28]=I):(T=e[27],I=e[28]);let E;e[29]!==D?(E=t.jsxs("button",{type:"button",className:"cell-media-slot-upload",disabled:D,onClick:T,children:[I,"Upload file"]}),e[29]=D,e[30]=E):E=e[30];const F=hi[n],$=m||!i;let P;e[31]!==p?(P=O=>{p(O.target.files),O.target.value=""},e[31]=p,e[32]=P):P=e[32];let L;e[33]!==F||e[34]!==$||e[35]!==P?(L=t.jsx("input",{ref:d,className:"cell-media-slot-input",type:"file",accept:F,disabled:$,onChange:P}),e[33]=F,e[34]=$,e[35]=P,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]!==A||e[40]!==E||e[41]!==g||e[42]!==L||e[43]!==_||e[44]!==h||e[45]!==j||e[46]!==v?(z=t.jsxs("section",{className:g,"aria-label":h,onDragEnter:y,onDragLeave:x,onDragOver:j,onDrop:v,children:[A,E,L,_]}),e[39]=A,e[40]=E,e[41]=g,e[42]=L,e[43]=_,e[44]=h,e[45]=j,e[46]=v,e[47]=z):z=e[47],z}const K1=["left","right","bottom"],V1=K1.flatMap(l=>Mn.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 q1(l){const e=W.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 Lf({id:l,data:e,selected:s}){const n=C.useContext(t1),i=C.useContext(s1),a=C.useContext(n1),r=C.useContext(l1),o=C.useContext(i1),c=C.useContext(a1),d=C.useContext(c1).get(l)??null,u=fc(),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??{},y=jo(e.kind),x=y!==null&&vo(e.kind,e.outputArtifactId,g),j=e.asset?.type==="video"||e.asset?.type==="final",v=e.asset?.type==="audio",k=e.kind==="audio"||e.kind==="extract_audio",w=e.kind==="video"||e.kind==="image",S=!j&&e.kind==="image",R=e.kind==="prompt"||e.kind==="analyze",N=e.slot.row===0,M=[N?"top":"lower",...p,"|",...e.sourcePorts??[]].join("\0");C.useEffect(()=>{u(l)},[M,l,u]);const A=ko({type:e.kind,model:e.model,operation:e.operation,outputArtifactId:e.outputArtifactId,tool:e.tool},e.status),D=e.post?So(e.post):wo(e.kind,e.status),T=ji(e.kind),I=T||Sl({type:e.kind,inputs:e.inputs}),E=I&&[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,$=T?F??e.model??e.tool??null:null,P=T?ps(e.inputs?.generationMode):null,L=P&&/^[a-z]2[a-z]$/i.test(P)?P.toUpperCase():null,_=$?(()=>{const ce=No($);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=vi(e.kind),H=T&&U!==null&&O!==null,K=H?O1(e.kind):q,te=ps(e.prompt)||ps(e.inputs?.resolvedPrompt),ae=S?te??e.asset?.prompt??null:null,V=S&&e.model?o.get(e.model)??null:null,oe=R||T&&!!e.prompt,G=Wt(e.slot),se=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,Z=w&&!!(m||b),J=Y?$o(le):[],re=Y?Io(le):null,ee=Z?S?Ro({width:e.asset?.width??null,height:e.asset?.height??null,tool:V,model:e.model??e.tool??null,provenance:se}):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:se}):[],Q=Z&&j?Po(e.videoDurationSeconds??e.asset?.duration??null):null,de=Ao(e.status),fe=e.status==="error",ue=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}))&&ue.length>1,me=Math.max(1,ue.indexOf(e.outputArtifactId??"")+1),be=r1(l),ye=(ce,X,ie)=>{c.open(l,{x:ce,y:X},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":ue.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 X=ce.currentTarget.getBoundingClientRect();ye(X.left+Math.min(X.width-12,40),X.top+40,document.activeElement instanceof HTMLElement?document.activeElement:null)},children:[p.map((ce,X)=>t.jsx(vn,{type:"target",position:Cs.Top,id:ce,className:`cell-target-handle${N?" cell-target-handle-top-row":""}`,style:{left:`${(X+1)/(p.length+1)*100}%`}},ce)),p.map((ce,X)=>{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:`${(X+1)/(p.length+1)*100}%`},children:ie},`${ce}-count`)}),V1.map(ce=>t.jsx(vn,{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(An,{size:9,"aria-hidden":"true"}),d.split(" · ")[0]]})]}),A&&!T&&t.jsx("button",{type:"button",className:"cell-run-button nodrag",disabled:A.disabled,onClick:ce=>{ce.stopPropagation(),i(l)},children:A.label}),!A&&pe&&t.jsxs("span",{className:"cell-version-count","aria-label":`Current output version ${me} of ${ue.length}`,title:`Current output · version ${me} of ${ue.length}`,children:[t.jsx(Ns,{size:12,"aria-hidden":"true"}),"v",me,"/",ue.length]})]}),t.jsxs("div",{className:"cell-node-body",children:[e.kind==="post"?t.jsx(Gm,{post:e.post,source:e.postSource}):x&&y?t.jsx(H1,{cellId:l,kind:y,ready:n.ready,state:n.states[l],onFile:n.onFile,onFileError:n.onFileError,onOpenLibrary:n.onOpenLibrary}):e.kind==="split_video"?t.jsx(U1,{data:e}):e.kind==="analysis"?t.jsx(d1,{analysisInfo:e.asset?.analysisInfo??null,fallbackShotCount:wl(e.inputs?.shotCount),fallbackSourceDurationSeconds:wl(e.inputs?.sourceDurationSeconds)}):Y?t.jsx(Wl,{address:G,posterUrl:null,waveform:e.asset?.waveform??[],mediaUrl:m??null,playbackKind:m?"audio":null,alt:e.label??G,badges:J,meter:re,metadataLabel:Nl(q,J,re,null),pendingLabel:"Waveform pending",pendingIcon:t.jsx(ss,{size:26,"aria-hidden":"true"})}):Z?t.jsx(Wl,{address:G,posterUrl:b??(j?null:m??null),waveform:null,mediaUrl:m??null,playbackKind:j&&m?"video":null,alt:e.label??G,title:ae??void 0,badges:ee,meter:Q,metadataLabel:Nl(q,ee,Q,ae),pendingLabel:"Poster pending",pendingIcon:t.jsx(St,{size:26,"aria-hidden":"true"}),children:t.jsx(Ud,{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(Pi,{size:28}),!oe&&t.jsx("span",{children:_?"Add a prompt":Jl(e)})]}),t.jsx(I1,{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:I,onRepair:I?()=>{a.repairCell(l)}:void 0,onRetry:e.inputs?.producerCellId?()=>{a.retryCell(l)}:void 0,disabled:!a.ready,onDelete:()=>{a.deleteCell(l)}})]}),t.jsxs("footer",{className:"cell-node-footer",children:[t.jsx("strong",{children:Wt(e.slot)}),t.jsxs("span",{className:"cell-node-footer-actions",children:[t.jsx(q1,{status:D}),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 X=ce.currentTarget.getBoundingClientRect();ye(X.right-4,X.bottom+4,ce.currentTarget)},children:t.jsx(qn,{size:16,"aria-hidden":"true"})})]})]})]}),t.jsx(vn,{type:"source",position:Cs.Bottom,id:"output",className:"cell-connect-handle"})]})}function zf(l){const e=W.c(13),{id:s,data:n}=l,i=C.useContext(o1);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(D1,{...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 Of(l){const e=W.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,y=s.status==="queued"||s.status==="analyzing",x=n.frameRate.numerator/n.frameRate.denominator;let j;e[1]!==n.tracks?(j=new Set(n.tracks.filter(Y1).map(X1)),e[1]=n.tracks,e[2]=j):j=e[2];const v=j;let k,w,S,R,N,M,A,D,T,I,E,F,$,P,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=Me=>v.has(Me.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 Me;e[39]!==a?(Me=(we,Le)=>!we||Math.abs(Le.frame-a)<Math.abs(we.frame-a)?Le:we,e[39]=a,e[40]=Me):Me=e[40],$t=s.mapped.reduce(Me,null),e[36]=a,e[37]=s.mapped,e[38]=$t}else $t=e[38];D=$t,R=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(G1),e[41]=s.mapped,e[42]=xt):xt=e[42],w=xt.length,M=s.analysis?.barSource==="estimated"&&!s.rhythm.settings.correction;let gt;e[43]!==h||e[44]!==n.tracks?(gt=h&&!n.tracks.find(Me=>Me.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]!==R||e[48]!==h||e[49]!==s?(Vt=function(we,Le,Ue){const Pe=Le===void 0?R??null:Le,Ne=Ue===void 0?S:Ue;h&&(g(""),s.save({masterClipId:h.clipId,correction:{objectHash:h.source.range.objectHash,analysisId:s.analysis?.analysisId??null,markers:we,bpm:Pe,beatsPerBar:Ne}}))},e[46]=S,e[47]=R,e[48]=h,e[49]=s,e[50]=Vt):Vt=e[50],I=Vt;let Bt;e[51]===Symbol.for("react.memo_cache_sentinel")?(Bt=function(){const we=performance.now(),Le=d.current[d.current.length-1];if(d.current=Le===void 0||we-Le>3e3?[we]:[...d.current.slice(-7),we],d.current.length>1){const Ue=d.current.slice(1).map((Pe,Ne)=>Pe-d.current[Ne]).sort(W1);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]!==R||e[53]!==x||e[54]!==a||e[55]!==h||e[56]!==m||e[57]!==I||e[58]!==u?(ot=function(){if(!h)return;const we=Number(u||R),Le=m?Number(m):null;if(!(we>=20&&we<=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,Pe=Ue.timeBase.numerator/Ue.timeBase.denominator,Ne=(Ue.startTick+Ue.durationTicks)*Pe;if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead inside the soundtrack.");return}const kt=Math.min(Ne-Pe,Cl(h,a,x)),_t=h.reverse?Math.floor((kt-Ue.startTick*Pe)/(60/we))+1:Math.ceil((Ne-kt)/(60/we)),Ut=Array.from({length:Math.max(0,_t)},(Lt,je)=>({id:`grid-${je}`,timeSeconds:kt+(h.reverse?-1:1)*je*60/we,bar:Le!==null&&je%Le===0,manual:!0}));I(Ut,we,Le)},e[52]=R,e[53]=x,e[54]=a,e[55]=h,e[56]=m,e[57]=I,e[58]=u,e[59]=ot):ot=e[59],A=ot;let ht;e[60]!==x||e[61]!==a||e[62]!==h||e[63]!==s.markers||e[64]!==I?(ht=function(){if(!h)return;const we=h.source.range,Le=(we.startTick+we.durationTicks-1)*we.timeBase.numerator/we.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(Pe=>Math.abs(Pe.timeSeconds-Ue)<.5/x)||I([...s.markers,{id:crypto.randomUUID(),timeSeconds:Ue,bar:!1,manual:!0}])},e[60]=x,e[61]=a,e[62]=h,e[63]=s.markers,e[64]=I,e[65]=ht):ht=e[65],k=ht;let Ft;e[66]!==S||e[67]!==R||e[68]!==a||e[69]!==h||e[70]!==m||e[71]!==D||e[72]!==s.markers||e[73]!==I?(Ft=function(){if(!h||!D)return;const we=m?Number(m):S;if(we===null||!Number.isInteger(we)||we<1||we>16){g("Enter 1–16 beats per bar.");return}if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead at the first beat of a bar inside the soundtrack.");return}I(Lo(s.markers,D.id,we,R??null),R??null,we)},e[66]=S,e[67]=R,e[68]=a,e[69]=h,e[70]=m,e[71]=D,e[72]=s.markers,e[73]=I,e[74]=Ft):Ft=e[74],E=Ft;let It;e[75]!==x||e[76]!==h||e[77]!==D||e[78]!==s.markers||e[79]!==I?(It=function(we){if(!h||!D)return;const Le=D.timeSeconds+we/x*h.speed.numerator/h.speed.denominator*(h.reverse?-1:1);Le<0||I(s.markers.map(Ue=>Ue.id===D.id?{...Ue,timeSeconds:Le,manual:!0}:Ue))},e[75]=x,e[76]=h,e[77]=D,e[78]=s.markers,e[79]=I,e[80]=It):It=e[80],T=It,$="music-rhythm-controls",F="music-rhythm-row",q="Soundtrack",P="Master soundtrack",L=h?.clipId??"",_=s.busy,e[81]!==s?(z=Me=>{s.save({masterClipId:Me.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=Me=>t.jsxs("option",{value:Me.clipId,children:[i.find(we=>we.artifactId===Me.source.artifactId)?.label??"Audio"," · ",(Me.timelineStartFrame/x).toFixed(1),"s"]},Me.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]=R,e[17]=N,e[18]=M,e[19]=A,e[20]=D,e[21]=T,e[22]=I,e[23]=E,e[24]=F,e[25]=$,e[26]=P,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],R=e[16],N=e[17],M=e[18],A=e[19],D=e[20],T=e[21],I=e[22],E=e[23],F=e[24],$=e[25],P=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]!==P||e[89]!==L||e[90]!==_||e[91]!==z||e[92]!==O||e[93]!==U?(K=t.jsxs("select",{"aria-label":P,value:L,disabled:_,onChange:z,children:[O,U]}),e[88]=P,e[89]=L,e[90]=_,e[91]=z,e[92]=O,e[93]=U,e[94]=K):K=e[94];let te;e[95]!==K||e[96]!==q?(te=t.jsxs("label",{children:[q,K]}),e[95]=K,e[96]=q,e[97]=te):te=e[97];const ae=!h||s.busy||y;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 G;e[100]!==ae||e[101]!==V||e[102]!==oe?(G=t.jsx("button",{type:"button",disabled:ae,onClick:V,children:oe}),e[100]=ae,e[101]=V,e[102]=oe,e[103]=G):G=e[103];let se;e[104]!==y||e[105]!==s?(se=y&&t.jsx("button",{type:"button",disabled:s.busy,onClick:()=>{s.cancel()},children:"Cancel analysis"}),e[104]=y,e[105]=s,e[106]=se):se=e[106];let le;e[107]!==R||e[108]!==y||e[109]!==s.mapped.length||e[110]!==s.status?(le=y?"Analyzing soundtrack…":s.status==="no-beats"?"Analysis complete. No reliable beats found. Set a grid below.":R?`${R.toFixed(1)} BPM · ${s.mapped.length} beats`:"Analyze the song or set a beat grid.",e[107]=R,e[108]=y,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 Z;e[114]!==s?(Z=()=>{s.load()},e[114]=s,e[115]=Z):Z=e[115];let J;e[116]!==s.busy||e[117]!==Z?(J=t.jsx("button",{type:"button",disabled:s.busy,onClick:Z,children:"Reload beats"}),e[116]=s.busy,e[117]=Z,e[118]=J):J=e[118];let re;e[119]!==F||e[120]!==te||e[121]!==G||e[122]!==se||e[123]!==Y||e[124]!==J?(re=t.jsxs("div",{className:F,children:[te,G,se,Y,J]}),e[119]=F,e[120]=te,e[121]=G,e[122]=se,e[123]=Y,e[124]=J,e[125]=re):re=e[125];let ee;e[126]!==h||e[127]!==n.tracks?(ee=h&&(!h.enabled||h.audio?.muted||h.audioPolicy==="mute"||n.tracks.some(ze=>ze.trackId===h.trackId&&(!ze.enabled||ze.kind==="audio"&&ze.muted)))&&t.jsx("p",{children:"Soundtrack is muted or disabled. Its beat map is a timing guide."}),e[126]=h,e[127]=n.tracks,e[128]=ee):ee=e[128];let Q;e[129]!==h?.reverse?(Q=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]=Q):Q=e[130];let de;e[131]!==s.analysis?.lowConfidence||e[132]!==s.mapped.length||e[133]!==s.rhythm.settings.correction?(de=s.analysis?.lowConfidence&&s.mapped.length>0&&!s.rhythm.settings.correction&&t.jsx("p",{children:"Beat timing is uncertain. Listen and adjust the markers."}),e[131]=s.analysis?.lowConfidence,e[132]=s.mapped.length,e[133]=s.rhythm.settings.correction,e[134]=de):de=e[134];let fe;e[135]!==s.rhythm.settings.correction?(fe=s.rhythm.settings.correction&&t.jsx("p",{children:"Using your corrected beat map. Reanalysis preserves this map."}),e[135]=s.rhythm.settings.correction,e[136]=fe):fe=e[136];const ue=w?`${w} ${M?"estimated bar starts":"bar starts"} · ${S??"Unknown"} beats per bar`:"Set bar starts";let pe;e[137]!==ue?(pe=t.jsx("strong",{children:ue}),e[137]=ue,e[138]=pe):pe=e[138];let me;e[139]!==M?(me=M&&t.jsx("p",{children:"Bars start at the first detected beat. Adjust them below if needed."}),e[139]=M,e[140]=me):me=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 X;e[145]!==m||e[146]!==ye?(X=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]=X):X=e[147];const ie=!N||!D||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]!==X||e[152]!==he?(ke=t.jsxs("div",{className:"music-rhythm-row",children:[X,he]}),e[151]=X,e[152]=he,e[153]=ke):ke=e[153];let $e;e[154]!==x||e[155]!==D?($e=D&&t.jsxs("small",{children:["Use the beat at ",(D.frame/x).toFixed(3),"s as a bar start."]}),e[154]=x,e[155]=D,e[156]=$e):$e=e[156];let De;e[157]!==pe||e[158]!==me||e[159]!==ke||e[160]!==$e?(De=t.jsxs("section",{className:"music-bar-setup","aria-label":"Bar setup",children:[pe,me,be,ke,$e]}),e[157]=pe,e[158]=me,e[159]=ke,e[160]=$e,e[161]=De):De=e[161];let Ie;e[162]!==o?(Ie=ze=>o(ze.currentTarget.open),e[162]=o,e[163]=Ie):Ie=e[163];let Te;e[164]===Symbol.for("react.memo_cache_sentinel")?(Te=t.jsx("summary",{children:"Correct the beat grid"}),e[164]=Te):Te=e[164];let Fe;e[165]!==R?(Fe=R?.toFixed(1)??"120",e[165]=R,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 Ae;e[174]!==A||e[175]!==lt?(Ae=t.jsx("button",{type:"button",disabled:lt,onClick:A,children:"Set grid from playhead"}),e[174]=A,e[175]=lt,e[176]=Ae):Ae=e[176];const We=!N||s.busy;let Ge;e[177]!==k||e[178]!==We?(Ge=t.jsx("button",{type:"button",disabled:We,onClick:k,children:"Add beat at playhead"}),e[177]=k,e[178]=We,e[179]=Ge):Ge=e[179];const Je=!N||!D||s.busy;let tt;e[180]!==D?.id||e[181]!==s.markers||e[182]!==I?(tt=()=>I(s.markers.filter(ze=>ze.id!==D?.id)),e[180]=D?.id,e[181]=s.markers,e[182]=I,e[183]=tt):tt=e[183];let Ce;e[184]!==Je||e[185]!==tt?(Ce=t.jsx("button",{type:"button",disabled:Je,onClick:tt,children:"Remove nearest beat"}),e[184]=Je,e[185]=tt,e[186]=Ce):Ce=e[186];const Ee=!N||!D||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||!D||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||!D||s.busy;let wt;e[197]!==D?.id||e[198]!==s.markers||e[199]!==I?(wt=()=>I(s.markers.map(ze=>ze.id===D?.id?{...ze,bar:!ze.bar,manual:!0}:ze)),e[197]=D?.id,e[198]=s.markers,e[199]=I,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]!==Ae||e[207]!==Ge||e[208]!==Ce||e[209]!==_e||e[210]!==nt||e[211]!==Dt?(Ze=t.jsxs("div",{className:"music-rhythm-row",children:[Ye,Ve,Ae,Ge,Ce,_e,nt,Dt]}),e[204]=Ye,e[205]=Ve,e[206]=Ae,e[207]=Ge,e[208]=Ce,e[209]=_e,e[210]=nt,e[211]=Dt,e[212]=Ze):Ze=e[212];let ne;e[213]!==x||e[214]!==D?(ne=D&&t.jsxs("span",{children:["Nearest beat · ",(D.frame/x).toFixed(3),"s",D.manual?" · adjusted":""]}),e[213]=x,e[214]=D,e[215]=ne):ne=e[215];let xe;e[216]!==N||e[217]!==s.analysis?.beats.length||e[218]!==s.busy||e[219]!==s.markers||e[220]!==s.rhythm.settings.correction||e[221]!==I?(xe=s.analysis?.beats.length&&!s.rhythm.settings.correction?t.jsx("button",{type:"button",disabled:!N||s.busy,onClick:()=>I(s.markers),children:"Confirm detected beats"}):null,e[216]=N,e[217]=s.analysis?.beats.length,e[218]=s.busy,e[219]=s.markers,e[220]=s.rhythm.settings.correction,e[221]=I,e[222]=xe):xe=e[222];const Re=!s.rhythm.canUndo||s.busy;let Xe;e[223]!==s?(Xe=()=>{s.save("undo")},e[223]=s,e[224]=Xe):Xe=e[224];let at;e[225]!==Re||e[226]!==Xe?(at=t.jsx("button",{type:"button",disabled:Re,onClick:Xe,children:"Undo beat change"}),e[225]=Re,e[226]=Xe,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]!==Ie||e[246]!==Ze||e[247]!==pt?(rt=t.jsxs("details",{className:"music-rhythm-fixes",open:r,onToggle:Ie,children:[Te,Ze,pt]}),e[244]=r,e[245]=Ie,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]!==$||e[253]!==re||e[254]!==ee||e[255]!==Q||e[256]!==de||e[257]!==fe||e[258]!==De||e[259]!==rt||e[260]!==Et?(vt=t.jsxs("div",{className:$,children:[re,ee,Q,de,fe,De,rt,Et]}),e[252]=$,e[253]=re,e[254]=ee,e[255]=Q,e[256]=de,e[257]=fe,e[258]=De,e[259]=rt,e[260]=Et,e[261]=vt):vt=e[261],vt}function W1(l,e){return l-e}function G1(l){return l.bar}function X1(l){return l.trackId}function Y1(l){return l.kind==="audio"}function Bf(l){const e=W.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,y]=C.useState(4),[x,j]=C.useState("beats"),[v,k]=C.useState("0.25"),[w,S]=C.useState(!0),[R,N]=C.useState(!1),[M,A]=C.useState(!1);let D;e[0]!==f||e[1]!==s?(D=function(he,ke){const $e=s.map(ef),De=he+ke;if(De<0||De>=$e.length)return;const[Ie,Te]=[$e[De],$e[he]];$e[he]=Ie,$e[De]=Te,f($e)},e[0]=f,e[1]=s,e[2]=D):D=e[2];const T=D;let I;e[3]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("p",{children:"Cut the selected footage to the music. You review the draft before anything changes."}),e[3]=I):I=e[3];let E;e[4]!==p||e[5]!==a||e[6]!==r||e[7]!==h||e[8]!==v||e[9]!==u||e[10]!==w||e[11]!==M||e[12]!==R||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(Z1),interval:h,unit:x,minimum_shot_frames:Math.max(1,Math.round(Number(v)*r)),preserve_existing:w,preserve_clip_ids:[],reuse_sources:R,allow_retiming:M,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]=M,e[12]=R,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 $;e[19]!==F?($=F.toFixed(2),e[19]=F,e[20]=$):$=e[20];let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=ie=>b(ie.target.value),e[21]=P):P=e[21];let L;e[22]!==m||e[23]!==$?(L=t.jsxs("label",{children:["From (s)",t.jsx("input",{"aria-label":"Draft start seconds",type:"number",min:"0",step:"any",placeholder:$,value:m,onChange:P})]}),e[22]=m,e[23]=$,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=>y(Number(ie.target.value)),H=[1,2,4,8].map(Q1),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 te,ae;e[35]===Symbol.for("react.memo_cache_sentinel")?(te=ie=>j(ie.target.value),ae=t.jsx("option",{value:"beats",children:"beats"}),e[35]=te,e[36]=ae):(te=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 G;e[39]!==oe||e[40]!==x?(G=t.jsxs("select",{"aria-label":"Draft interval unit",value:x,onChange:te,children:[ae,oe]}),e[39]=oe,e[40]=x,e[41]=G):G=e[41];let se;e[42]===Symbol.for("react.memo_cache_sentinel")?(se=ie=>k(ie.target.value),e[42]=se):se=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:se})]}),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 Z;e[46]!==w?(Z=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:w,onChange:Y}),"Keep existing clips"]}),e[46]=w,e[47]=Z):Z=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]!==R?(re=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:R,onChange:J}),"Allow repeated footage"]}),e[49]=R,e[50]=re):re=e[50];let ee;e[51]===Symbol.for("react.memo_cache_sentinel")?(ee=ie=>A(ie.target.checked),e[51]=ee):ee=e[51];let Q;e[52]!==M?(Q=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:M,onChange:ee}),"Allow speed changes"]}),e[52]=M,e[53]=Q):Q=e[53];const de=c||!n||s.length===0;let fe;e[54]!==de?(fe=t.jsx("button",{type:"submit",disabled:de,children:"Preview draft"}),e[54]=de,e[55]=fe):fe=e[55];let ue;e[56]!==U||e[57]!==K||e[58]!==G||e[59]!==le||e[60]!==Z||e[61]!==re||e[62]!==Q||e[63]!==fe||e[64]!==L?(ue=t.jsxs("div",{className:"music-rhythm-row",children:[L,U,K,G,le,Z,re,Q,fe]}),e[56]=U,e[57]=K,e[58]=G,e[59]=le,e[60]=Z,e[61]=re,e[62]=Q,e[63]=fe,e[64]=L,e[65]=ue):ue=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 me;e[74]!==pe?(me=t.jsx("ol",{className:"music-draft-order","aria-label":"Draft source order",children:pe}),e[74]=pe,e[75]=me):me=e[75];let 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]!==ue||e[80]!==me||e[81]!==be?(ye=t.jsxs("form",{onSubmit:E,children:[ue,me,be]}),e[78]=E,e[79]=ue,e[80]=me,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(J1),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 X;return e[87]!==ye||e[88]!==ce?(X=t.jsxs("section",{className:"music-draft-controls","aria-label":"Auto-cut to music",children:[I,ye,ce]}),e[87]=ye,e[88]=ce,e[89]=X):X=e[89],X}function J1(l){return t.jsx("p",{children:l},l)}function Q1(l){return t.jsx("option",{value:l,children:l},l)}function Z1(l){return{artifact_id:l.artifactId}}function ef(l){return l.artifactId}function Zl(l){const e=W.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=W.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 y=h;let x;e[14]!==s?(x=t.jsx("span",{children:s}),e[14]=s,e[15]=x):x=e[15];let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=w=>f(w.target.value),e[16]=j):j=e[16];let v;e[17]!==g||e[18]!==o||e[19]!==m||e[20]!==y||e[21]!==u?(v=t.jsx("input",{value:u,disabled:o,"aria-invalid":m,spellCheck:!1,onChange:j,onBlur:g,onKeyDown:y}),e[17]=g,e[18]=o,e[19]=m,e[20]=y,e[21]=u,e[22]=v):v=e[22];let k;return e[23]!==x||e[24]!==v?(k=t.jsxs("label",{className:"mv-field",children:[x,v]}),e[23]=x,e[24]=v,e[25]=k):k=e[25],k}function Uf(l){const e=W.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(cc,{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 y;e[16]!==c||e[17]!==a?(y=()=>{a!==null&&c(a)},e[16]=c,e[17]=a,e[18]=y):y=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(tn,{size:18}),e[19]=x):x=e[19];let j;e[20]!==h||e[21]!==y?(j=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Previous beat",title:"Previous beat",disabled:h,onClick:y,children:x}),e[20]=h,e[21]=y,e[22]=j):j=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Ds,{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 R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(As,{size:18}),e[29]=R):R=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:R}),e[30]=w,e[31]=S,e[32]=N):N=e[32];let M;e[33]!==n||e[34]!==c?(M=()=>c(n-1),e[33]=n,e[34]=c,e[35]=M):M=e[35];let A;e[36]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(dc,{size:17}),e[36]=A):A=e[36];let D;e[37]!==M?(D=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Go to end",onClick:M,children:A}),e[37]=M,e[38]=D):D=e[38];let T;e[39]!==j||e[40]!==k||e[41]!==N||e[42]!==D||e[43]!==g?(T=t.jsxs("div",{className:"mv-transport-buttons",children:[g,j,k,N,D]}),e[39]=j,e[40]=k,e[41]=N,e[42]=D,e[43]=g,e[44]=T):T=e[44];let I;e[45]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("span",{className:"mv-transport-spacer"}),e[45]=I):I=e[45];let E;return e[46]!==T||e[47]!==m?(E=t.jsxs("div",{className:"mv-transport",role:"toolbar","aria-label":"Transport",children:[m,T,I]}),e[46]=T,e[47]=m,e[48]=E):E=e[48],E}const tf=[{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 Hf(l){const e=W.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 y=`in-${s.clipId}-${i}`,x=a-1;let j;e[17]!==l||e[18]!==a?(j=Z=>l.onTrim("start",Z,a),e[17]=l,e[18]=a,e[19]=j):j=e[19];let v;e[20]!==r||e[21]!==n||e[22]!==l.trimMin||e[23]!==x||e[24]!==j||e[25]!==y||e[26]!==i?(v=t.jsx(ei,{label:"In point",frame:i,fps:n,min:l.trimMin,max:x,disabled:r,onCommit:j},y),e[20]=r,e[21]=n,e[22]=l.trimMin,e[23]=x,e[24]=j,e[25]=y,e[26]=i,e[27]=v):v=e[27];const k=`out-${s.clipId}-${a}`,w=i+1;let S;e[28]!==l||e[29]!==i?(S=Z=>l.onTrim("end",i,Z),e[28]=l,e[29]=i,e[30]=S):S=e[30];let R;e[31]!==r||e[32]!==n||e[33]!==l.trimMax||e[34]!==k||e[35]!==w||e[36]!==S||e[37]!==a?(R=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]=R):R=e[38];let N;e[39]!==v||e[40]!==R?(N=t.jsxs("div",{className:"mv-field-pair",children:[v,R]}),e[39]=v,e[40]=R,e[41]=N):N=e[41];let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M=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]=M):M=e[42];let A;e[43]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("span",{children:"Speed"}),e[43]=A):A=e[43];const D=r||!l.retimable;let T;e[44]!==l.onSpeed||e[45]!==l.speed||e[46]!==l.speedOptions||e[47]!==D?(T=t.jsxs("div",{className:"mv-control",children:[A,t.jsx(Zl,{label:"Clip speed",options:l.speedOptions,value:l.speed,disabled:D,stretch:!0,onChange:l.onSpeed})]}),e[44]=l.onSpeed,e[45]=l.speed,e[46]=l.speedOptions,e[47]=D,e[48]=T):T=e[48];let I;e[49]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("span",{children:"Frame"}),e[49]=I):I=e[49];const 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:[I,t.jsx(Zl,{label:"Clip frame fit",options:tf,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 $;e[54]!==N||e[55]!==T||e[56]!==F?($=t.jsxs("div",{className:"mv-clip-body",children:[N,M,T,F]}),e[54]=N,e[55]=T,e[56]=F,e[57]=$):$=e[57];let P;e[58]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(Vn,{size:15}),e[58]=P):P=e[58];let L;e[59]!==r||e[60]!==l.onSplit?(L=t.jsxs("button",{type:"button",disabled:r,onClick:l.onSplit,children:[P," 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(Ai,{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 te=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(As,{size:15}),e[74]=V):V=e[74];let oe;e[75]!==te||e[76]!==ae?(oe=t.jsxs("button",{type:"button","aria-label":"Move later",disabled:te,onClick:ae,children:["Later ",V]}),e[75]=te,e[76]=ae,e[77]=oe):oe=e[77];let G;e[78]===Symbol.for("react.memo_cache_sentinel")?(G=t.jsx(os,{size:15}),e[78]=G):G=e[78];let se;e[79]!==o||e[80]!==l.onDelete?(se=t.jsxs("button",{type:"button",className:"danger-button wide",disabled:o,onClick:l.onDelete,children:[G," Delete clip"]}),e[79]=o,e[80]=l.onDelete,e[81]=se):se=e[81];let le;e[82]!==L||e[83]!==O||e[84]!==K||e[85]!==oe||e[86]!==se?(le=t.jsxs("footer",{className:"mv-clip-actions",children:[L,O,K,oe,se]}),e[82]=L,e[83]=O,e[84]=K,e[85]=oe,e[86]=se,e[87]=le):le=e[87];let Y;return e[88]!==$||e[89]!==le||e[90]!==h?(Y=t.jsxs("div",{className:"mv-clip-inspector",children:[h,$,le]}),e[88]=$,e[89]=le,e[90]=h,e[91]=Y):Y=e[91],Y}export{Lf as $,xs as A,ut as B,zi as C,hf as D,Ll as E,Nf as F,xf as G,Yl as H,gf as I,uf as J,If as K,Af as L,ld as M,ad as N,Df as O,vc as P,t1 as Q,Gn as R,Zl as S,o1 as T,s1 as U,Uc as V,n1 as W,i1 as X,c1 as Y,ff as Z,zf as _,yf as a,pf as a0,Pf as a1,Tf as a2,$f as a3,Mf as a4,Rf as a5,mf as a6,Zc as b,gd as c,vf as d,kf as e,jf as f,wf as g,nd as h,Hi as i,Sf as j,bf as k,Cf as l,Ff as m,_f as n,l1 as o,a1 as p,r1 as q,Ic as r,Of as s,Bf as t,zd as u,sm as v,Uf as w,Hf as x,D1 as y,Ef as z};
|