conformtools 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +15 -10
  2. package/dist/{account-HDXVTS5T.js → account-DJTD3KYK.js} +1 -1
  3. package/dist/{bridge-D5KPIUSY.js → bridge-JQF4V3V2.js} +1 -1
  4. package/dist/browser/timeline_core_bg.wasm +0 -0
  5. package/dist/chunk-2BPR6LK6.js +3 -0
  6. package/dist/{chunk-VS3MKKJ5.js → chunk-3D3Z4TBR.js} +1 -1
  7. package/dist/{chunk-OJWIBQK4.js → chunk-55BKURYP.js} +167 -165
  8. package/dist/chunk-5WEZRGXG.js +39 -0
  9. package/dist/{chunk-P7OVDUA5.js → chunk-6V4OEOOX.js} +1 -1
  10. package/dist/{chunk-6ML26TIK.js → chunk-A7FNR3T5.js} +1 -1
  11. package/dist/chunk-AMRJXYL4.js +3 -0
  12. package/dist/{chunk-5SUGU2YR.js → chunk-D4WPRRBT.js} +1 -1
  13. package/dist/{chunk-UKKRZ574.js → chunk-EUBXH67N.js} +2 -2
  14. package/dist/{chunk-AS7IXHYM.js → chunk-GK4YYKJ6.js} +1 -1
  15. package/dist/{chunk-LFJLRLEP.js → chunk-GM6QKY7W.js} +1 -1
  16. package/dist/{chunk-HGDO3OED.js → chunk-J2JXLEAI.js} +1 -1
  17. package/dist/{chunk-5RSNFPED.js → chunk-NAFLOZER.js} +6 -5
  18. package/dist/{chunk-5JBUCVRI.js → chunk-P2LL3JMC.js} +1 -1
  19. package/dist/{chunk-3OCQA33E.js → chunk-PHAMF4JF.js} +2 -1
  20. package/dist/chunk-RGMTLNMF.js +3 -0
  21. package/dist/chunk-RJ6JA2LZ.js +3 -0
  22. package/dist/{chunk-RFIPLBQ4.js → chunk-S5JDS5PQ.js} +1 -1
  23. package/dist/{chunk-X53BNWNV.js → chunk-SGLQY53R.js} +1 -1
  24. package/dist/{chunk-EJGVNQ3E.js → chunk-SKFMOLUO.js} +1 -1
  25. package/dist/{chunk-SZD4C5MB.js → chunk-SNTAZJ5A.js} +1 -1
  26. package/dist/{chunk-3XD6NC4G.js → chunk-VIBEEWPC.js} +1 -1
  27. package/dist/{chunk-NQHQKEP5.js → chunk-WN53ARHJ.js} +1 -1
  28. package/dist/{chunk-OVUCL3YY.js → chunk-XLEINKFL.js} +1 -1
  29. package/dist/cli.js +3 -3
  30. package/dist/conformtools-analyze +0 -0
  31. package/dist/conformtools-decode +0 -0
  32. package/dist/{cr3-wasm-L2LFY3LM.js → cr3-wasm-HLJWEV2S.js} +1 -1
  33. package/dist/{dng-wasm-U6NC3MDK.js → dng-wasm-CQDLPM5V.js} +1 -1
  34. package/dist/{dpx-wasm-RMKEUKED.js → dpx-wasm-TLGMM7BO.js} +1 -1
  35. package/dist/{exr-wasm-LBAOMOZD.js → exr-wasm-2NPKPTVB.js} +1 -1
  36. package/dist/framing-SWOD4CWB.js +3 -0
  37. package/dist/gfx-worker.js +1 -1
  38. package/dist/{h264-3ESGVT6G.js → h264-JJMZSUWW.js} +1 -1
  39. package/dist/{h264-mxf-NPFS7NGH.js → h264-mxf-DCUOGLDU.js} +1 -1
  40. package/dist/{host-relink-D6CB2VOQ.js → host-relink-TWAF6WIG.js} +1 -1
  41. package/dist/hosts-Z666EF7V.js +3 -0
  42. package/dist/http.js +2 -2
  43. package/dist/{inspect-7ASUPU73.js → inspect-FJKYPEXL.js} +15 -15
  44. package/dist/{isobmff-SIOE67WL.js → isobmff-VJOWP4MH.js} +1 -1
  45. package/dist/mc-video-5MGGOQN4.js +3 -0
  46. package/dist/mcp.js +1 -1
  47. package/dist/{media-7AUNRKHF.js → media-NZYVREUF.js} +1 -1
  48. package/dist/media_core-YZ3PABEG.js +9 -0
  49. package/dist/{mxf-74TTDICM.js → mxf-FJSRFLJC.js} +1 -1
  50. package/dist/{ops-FSOOBXMV.js → ops-X7NAREC4.js} +1 -1
  51. package/dist/premiere-uxp/lib/probe.js +212 -1
  52. package/dist/{r3d-ZDJ3WURS.js → r3d-CXUNG6VS.js} +1 -1
  53. package/dist/{r3d-YTLOMC7C.js → r3d-T5O6IIZZ.js} +1 -1
  54. package/dist/{source-BDJAUQVR.js → source-QGWWLMME.js} +1 -1
  55. package/dist/still-P4JJNTEO.js +3 -0
  56. package/dist/still-wasm-DN5LPASS.js +3 -0
  57. package/dist/{store-ZHXLQCGN.js → store-7IOEBOZY.js} +1 -1
  58. package/dist/{tiff-wasm-D2FJ3L56.js → tiff-wasm-BPRDR6EB.js} +1 -1
  59. package/dist/{timeline-6DYFDVEH.js → timeline-DQG6TVPF.js} +1 -1
  60. package/dist/wasm/media_core_bg.wasm +0 -0
  61. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  62. package/dist/{wav-OWMUGQMM.js → wav-64SC6P7U.js} +1 -1
  63. package/package.json +1 -1
  64. package/dist/chunk-7MC7M2Y5.js +0 -3
  65. package/dist/chunk-BL6L5ZBP.js +0 -39
  66. package/dist/chunk-C5IX63YF.js +0 -3
  67. package/dist/chunk-UCMNH6Q6.js +0 -3
  68. package/dist/chunk-XNR7M4VX.js +0 -3
  69. package/dist/framing-SRCJKAYO.js +0 -3
  70. package/dist/hosts-W4AD2MYH.js +0 -3
  71. package/dist/media_core-Q2PIEV7D.js +0 -9
  72. package/dist/still-ZG2RUQAL.js +0 -3
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{M as D,N as F,O as N}from"./chunk-BL6L5ZBP.js";import{n as P}from"./chunk-5JBUCVRI.js";import{B as C,D as M,E as T,H as q,I,L as w,V as b,X as k,Y as _,_ as L,g as v,k as O,p as S,q as A,r as y,s as x,v as H,x as E,y as R}from"./chunk-PLRB2YXJ.js";var B=16e3,h=class extends Error{constructor(t,i){super(i);this.code=t}},j=class d{constructor(e,t=P,i=B){this.spec=e;this.bridge=t;this.waitMs=i;this.renders=new Map;this.host=e.host,e.items&&(this.items=n=>this.modelItems(n??{}))}async peer(){let e=await(await this.bridge()).waitFor(this.host,this.waitMs);if(!e)throw new h("not_connected",`${this.host}: the conform.tools plugin in ${this.spec.label} is not connected. ${this.spec.setup}`);return e}async needs(e){let t=await this.peer();if(!t.capabilities.includes(e))throw new h("panel_old",`${this.host}: the conform.tools plugin open in ${this.spec.label} ${t.version||""} has no ${e} (an older plugin); update it (${this.spec.setup})`);return t}async ask(e,t={},i){return await this.peer(),await(await this.bridge()).request(this.host,e,t,i)}static{this.announced=(e,t)=>e.optional_verbs.includes(t)}async support(){let e={ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"},t;try{t=await(await this.bridge()).waitFor(this.host,Math.min(3e3,this.waitMs))}catch(s){let a={ok:!1,reason:s instanceof Error?s.message:String(s)};return{export:a,open:a,render:a,markers:a,renderplugin:e}}if(!t){let s={ok:!1,reason:`the conform.tools plugin in ${this.spec.label} is not connected`,setup:this.spec.setup};return{export:s,open:s,render:s,markers:s,renderplugin:e}}let i=(s,a)=>s?{ok:!0}:{ok:!1,reason:`this plugin version has no ${a}`},n=t.capabilities;return{export:i(n.includes("timeline_read")||n.includes("timeline_write"),"timeline_read"),open:i(d.announced(t,"timeline_write.import_file"),"timeline_write.import_file"),render:i(n.includes("render"),"render"),markers:i(n.includes("markers"),"markers"),renderplugin:e}}async current(){let e=await this.ask("session.current_project");if(!e)return{project:"",timelines:[],timeline:""};let t=await this.ask("session.timeline_count",{project:e}),i=[];for(let s=1;s<=t;s++){let a=await this.ask("session.timeline_by_index",{project:e,index:s});a&&i.push(await this.ask("session.name",{handle:a}))}let n=await this.ask("session.current_timeline",{project:e});return{project:await this.ask("session.name",{handle:e}),timelines:i,timeline:n?await this.ask("session.name",{handle:n}):""}}async project(e={}){let t=await this.current();return{project:t.project,timeline:e.timeline??t.timeline,timelines:t.timelines,tracks:[],jobs:[],found:{},pool:{path:"",clips:0,folders:[]}}}async sequence(e){let t=await this.ask("session.current_project");if(!t)throw new h("no_project",`${this.host}: no project is open`);if(!e){let s=await this.ask("session.current_timeline",{project:t});if(!s)throw new h("no_timeline",`${this.host}: no timeline is active`);return{project:t,seq:s,name:await this.ask("session.name",{handle:s})}}let i=await this.ask("session.timeline_count",{project:t}),n=[];for(let s=1;s<=i;s++){let a=await this.ask("session.timeline_by_index",{project:t,index:s});if(!a)continue;let p=await this.ask("session.name",{handle:a});if(p===e)return{project:t,seq:a,name:p};n.push(p)}throw new h("not_found",`${this.host}: no timeline named "${e}" (have: ${n.join(", ")})`)}async model(e){let{project:t,seq:i}=await this.sequence(e);return await this.ask("timeline_read.model",{timeline:i,project:t},12e4)}async export(e){if(!e.out_path)throw new h("usage",`${this.host}: export needs out_path`);let t=await this.peer(),{project:i,seq:n,name:s}=await this.sequence(e.timeline),a=await this.ask("session.name",{handle:i}),p=r=>d.announced(t,r),m=e.out_path,l,c=[];if(p("timeline_write.export_otio")||p("timeline_write.export_xml")){let r=p("timeline_write.export_otio"),o=await this.ask(r?"timeline_write.export_otio":"timeline_write.export_xml",{project:i,timeline:n,path:e.out_path},12e4);if(l=o.format??(r?"otio":"xmeml"),o.ok===!1)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${e.out_path}${o.errors?.length?` (${o.errors.join("; ")})`:""}`);o.path&&o.path!==e.out_path&&(m=await this.adopt(o.path,e.out_path)),c=o.warnings??[]}else if(p("timeline_read.export_file")){let r=await this.ask("timeline_read.export_file",{timeline:n,fmt:"otio",path:e.out_path},12e4);if(!r)throw new h("export_failed",`${this.host}: ${this.spec.label} exported no OTIO`);l="otio",r!==e.out_path&&(m=await this.adopt(r,e.out_path))}else{await this.needs("timeline_read");let r=await this.ask("timeline_read.model",{timeline:n,project:i},12e4),o=J(r);await E(e.out_path,JSON.stringify(o.otio)),l="otio",c=o.notes}if(!D.includes(l))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${l}, which the engine does not read (${m})`);if(!await x(m)||(await A(m)).size===0)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${m}`);return{path:m,format:l,project:a,timeline:s,...c.length?{notes:c}:{}}}async adopt(e,t){let i=k(e)&&k(e)!==k(t)?t.slice(0,t.length-k(t).length)+k(e):t;if(await C(e,i),!F(i))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${b(e)}, which the engine does not read`);return i}async open(e){if(e.into==="scratch")throw new h("unsupported",`${this.host}: opening into a scratch project is not supported; the import lands in the open project`);let t=await this.peer();if(!d.announced(t,"timeline_write.import_file"))throw new h("unsupported",`${this.host}: this conform.tools plugin cannot import timelines (${this.spec.setup})`);let i=await this.ask("session.current_project");if(!i)throw new h("no_project",`${this.host}: no project is open`);let n=await this.ask("timeline_write.import_file",{project:i,path:e.path,sequences:null},3e5);if(!n.ok)throw new h("import_failed",`${this.host}: ${this.spec.label} did not import ${e.path}${n.issues?.length?` (${n.issues.join("; ")})`:""}`);let s=[...n.issues??[]];return n.imported.length>1&&s.push(`imported ${n.imported.length} timelines: ${n.imported.map(a=>a.name).join(", ")}`),e.name&&s.push(`${this.spec.label} names imported timelines after the file's own; name was not applied`),e.media_dirs?.length&&s.push(`${this.spec.label} links media from the paths in the file; media_dirs was not used (relink with timeline_relink before writing)`),{project:await this.ask("session.name",{handle:i}),timeline:n.imported[0]?.name??b(e.path),notes:s,restored:!e.stay,...n.bin?{folder:n.bin}:{}}}async modelItems(e){let t=await this.model(e.timeline),i=[...e.kind==="audio"?[]:t.items.map(n=>({kind:"video",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:n.handle?.$h??n.clip_id??"",name:n.name??"",color:n.color??"",flags:n.flags??[],enabled:n.enabled??!0,file:n.file_path})),...e.kind==="video"?[]:(t.audio_items??[]).map(n=>({kind:"audio",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:"",name:n.name??"",file:n.file_path??""}))].filter(n=>e.track===void 0||n.track===e.track);return{project:(await this.current()).project,timeline:t.timeline,start_frame:t.start_frame,fps:t.fps,items:i,color_groups:[],layers:1}}async apply(e){let{project:t,seq:i,name:n}=await this.sequence(e.timeline),s=[],a=[],p=l=>l.op.startsWith("marker_")&&!l.item;for(let l=0;l<e.ops.length;){let c=l;for(;c<e.ops.length&&p(e.ops[c])===p(e.ops[l]);)c++;let r=e.ops.slice(l,c),o=p(r[0])?await this.markerOps(i,r):await this.clipOps(i,r,e.timeline);s.push(...o.results),a.unshift(...o.undo),l=c}let m=s.filter(l=>l.ok).length;return{project:await this.ask("session.name",{handle:t}),timeline:n,results:s,undo:a,applied:m,failed:s.length-m}}async clipOps(e,t,i){let n=await this.peer();if(n.capabilities.includes("edit"))return await this.ask("edit.apply",{timeline:e,ops:t},6e4+t.length*500);let s=(c,r)=>({op:c.op,ok:!1,detail:r});if(!n.capabilities.includes("item_meta"))return{results:t.map(c=>s(c,`${this.host}: clip edits are not reachable over this plugin`)),undo:[]};let a=await this.model(i),p=c=>c?"id"in c?{$h:c.id}:(c.kind??"video")!=="video"?null:a.items.find(r=>r.track===c.track&&r.start-a.start_frame===c.start)?.handle??null:null,m=[],l=[];for(let c of t){let r=p(c.item);try{if(!r)m.push(s(c,`no video item at ${JSON.stringify(c.item??null)}`));else if(c.op==="clip_color"){let o=await this.ask("item_meta.color",{handle:r}),u=c.color?await this.ask("item_meta.set_color",{handle:r,color:c.color}):await this.ask("item_meta.clear_color",{handle:r});m.push({op:c.op,ok:u}),u&&l.unshift({op:"clip_color",item:c.item,color:o})}else if(c.op==="enabled"&&d.announced(n,"item_meta.set_enabled")){let o=a.items.find(f=>f.handle?.$h===r.$h)?.enabled??!0,u=await this.ask("item_meta.set_enabled",{item:r,enabled:!!c.on});m.push({op:c.op,ok:u}),u&&l.unshift({op:"enabled",item:c.item,on:o})}else m.push(s(c,`${this.host}: '${c.op}' is not reachable over this plugin`))}catch(o){m.push(s(c,o instanceof Error?o.message:String(o)))}}return{results:m,undo:l}}async markerOps(e,t){let i=await this.peer(),n=r=>d.announced(i,r),s=new Map((await this.ask("markers.list",{target:e})).map(r=>[r.frame,r])),a=[],p=[],m=async r=>{let o=await this.ask("markers.add",{target:e,frame:r.frame,color:r.color??"",name:r.name??"",note:r.note??"",duration:r.duration??1,custom_data:r.custom_data??""});return o&&s.set(r.frame,{color:"",name:"",note:"",duration:1,...r}),o},l=async r=>{let o=await this.ask("markers.delete_at",{target:e,frame:r});return o&&s.delete(r),o},c=r=>({op:"marker_add",frame:r.frame,color:r.color,name:r.name,note:r.note,duration:r.duration,...r.custom_data?{data:r.custom_data}:{}});for(let r of t){let o=Number(r.frame);try{if(r.op==="marker_add"){let u=s.get(o);u&&await l(o);let f=await m({frame:o,color:r.color,name:r.name,note:r.note,duration:Number(r.duration??1),custom_data:r.data});a.push({op:r.op,ok:f}),f&&p.unshift(...u?[c(u)]:[],{op:"marker_delete",frame:o})}else if(r.op==="marker_update"){let u=s.get(o);if(!u){a.push({op:r.op,ok:!1,detail:`no marker at frame ${o}`});continue}let f=r.to_frame!==void 0?Number(r.to_frame):o,$={...u,frame:f,...r.color!==void 0?{color:String(r.color)}:{},...r.name!==void 0?{name:String(r.name)}:{},...r.note!==void 0?{note:String(r.note)}:{}},g=!0;n("markers.set_color")&&n("markers.set_text")&&n("markers.move")?(r.color!==void 0&&(g=await this.ask("markers.set_color",{target:e,frame:o,color:r.color})&&g),(r.name!==void 0||r.note!==void 0)&&(g=await this.ask("markers.set_text",{target:e,frame:o,name:r.name,note:r.note})&&g),f!==o&&(g=await this.ask("markers.move",{target:e,frame:o,to_frame:f})&&g),s.delete(o),s.set(f,$)):g=await l(o)&&await m($),a.push({op:r.op,ok:g}),p.unshift({op:"marker_update",frame:f,color:u.color,name:u.name,note:u.note,...f!==o?{to_frame:o}:{}})}else if(r.op==="marker_delete"){let u=s.get(o),f=!!u&&await l(o);a.push({op:r.op,ok:f,...u?{}:{detail:`no marker at frame ${o}`}}),f&&u&&p.unshift(c(u))}else a.push({op:r.op,ok:!1,detail:`${this.host}: '${r.op}' is not reachable over this plugin`})}catch(u){a.push({op:r.op,ok:!1,detail:u instanceof Error?u.message:String(u)})}}return{results:a,undo:p}}async renderStart(e){if(await this.needs("render"),e.renderplugin)throw new h("unsupported","the renderplugin is a DaVinci Resolve plugin");if(e.disable_tracks?.length||e.audio_tracks?.length)throw new h("unsupported",`${this.host}: disable_tracks / audio_tracks are DaVinci Resolve's; pick a preset that renders what you need`);if(!e.preset)throw new h("usage",`${this.host}: preset is required: one of ${this.spec.label}'s export presets by name`);let{seq:t,name:i}=await this.sequence(e.timeline),n=e.name??i,s={purpose:"deliver",format:"preset",preset:e.preset,target_dir:e.target_dir,name:n,...e.range?{range:[e.range.in,e.range.out]}:{}},a=await this.ask("render.submit",{timeline:t,job:s});if(!a?.id)throw new h("render_refused",`${this.host}: ${a?.error??`${this.spec.label} refused the render`}`);if(!await this.ask("render.start",{job_ids:[a.id]}))throw new h("render_refused",`${this.host}: ${this.spec.label} did not start job ${a.id}`);return this.renders.set(a.id,{dir:e.target_dir,name:n}),{job_id:a.id,state:"queued",percent:0}}async renderStatus(e){let t=await this.ask("render.status",{job_id:e});if(!t)return{job_id:e,state:"failed",percent:0,error:`${this.host}: no render job ${e}`};let i={done:"complete",rendering:"rendering",queued:"queued",failed:"failed",cancelled:"cancelled"}[t.state]??"rendering",n={job_id:e,state:i,percent:Math.round(t.progress??(i==="complete"?100:0)),...t.error?{error:t.error}:{}};if(i==="complete"||i==="failed"||i==="cancelled"){let s=this.renders.get(e);i==="complete"&&s&&(n.outputs=await W(s.dir,s.name)),await this.ask("render.remove",{job_id:e}).catch(()=>!1),this.renders.delete(e)}return n}async renderCancel(e){return await this.ask("render.cancel",{job_id:e})?{job_id:e,state:"cancelled",percent:0}:{...await this.renderStatus(e),error:`${this.spec.label}'s running export cannot be cancelled from here; stop it in ${this.spec.label}`}}};async function W(d,e){let t=[];try{for await(let i of I(d))i.isFile&&i.name.startsWith(`${e}.`)&&t.push(_(d,i.name))}catch{}return t.sort()}function J(d){let e=(l,c)=>({OTIO_SCHEMA:"RationalTime.1",value:l,rate:c}),t=(l,c,r,o=r)=>({OTIO_SCHEMA:"TimeRange.1",start_time:e(l,r),duration:e(c,o)}),i=d.fps,n=d.tracks?.length?d.tracks:[...new Set(d.items.map(l=>l.track))].sort((l,c)=>l-c).map(l=>({index:l,enabled:!0,name:"",items:d.items.filter(c=>c.track===l)})),s=l=>(l.reversed?-1:1)*(l.speed||1)/(l.fps_factor||1),a=new Map;for(let l of d.items)if(l.file_path&&l.start_tc!=null&&l.src_abs_in!=null){let c=l.src_abs_in-l.start_tc+Math.ceil((l.end-l.start)*Math.abs(s(l))*(l.fps_factor||1));a.set(l.file_path,Math.max(a.get(l.file_path)??0,c))}let p=n.map(l=>{let c=d.start_frame,r=[];for(let o of[...l.items].sort((u,f)=>u.start-f.start)){if(o.start<c)continue;o.start>c&&r.push({OTIO_SCHEMA:"Gap.1",name:"",source_range:t(0,o.start-c,i)});let u=o.src_fps||i,f=o.start_tc!=null&&a.has(o.file_path)?o.start_tc:null,$=f!=null?o.src_abs_in:o.src_in??o.src_abs_in??0,g=s(o);r.push({OTIO_SCHEMA:"Clip.2",name:o.name??b(o.file_path||""),enabled:o.enabled!==!1,source_range:t($,o.end-o.start,u,i),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",name:b(o.file_path||""),target_url:o.file_path?`file://${o.file_path}`:"",...f!=null?{available_range:t(f,a.get(o.file_path),u)}:{},metadata:{}}},active_media_reference_key:"DEFAULT_MEDIA",effects:Math.abs(g-1)>1e-6?[{OTIO_SCHEMA:"LinearTimeWarp.1",name:"",effect_name:"LinearTimeWarp",time_scalar:g}]:[],markers:[],metadata:o.reel?{cmx_3600:{reel:o.reel}}:{}}),c=o.end}return{OTIO_SCHEMA:"Track.1",name:l.name||`V${l.index}`,kind:"Video",enabled:l.enabled!==!1,children:r,effects:[],markers:[],metadata:{}}}),m=[];return d.audio_items?.length&&m.push(`${d.audio_items.length} audio clip(s) not carried: the host's plugin reports no audio source times`),d.transitions?.length&&m.push(`${d.transitions.length} transition(s) not carried (cuts in their place)`),{otio:{OTIO_SCHEMA:"Timeline.1",name:d.timeline,global_start_time:e(d.start_frame,i),metadata:{},tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",children:p,effects:[],markers:[],metadata:{}}},notes:m}}var X=16e3;var G="Install the conform.tools panel (host_setup host=premiere action=install_panel), then in Premiere open Window > UXP Plugins > conform.tools. It connects by itself from then on.";var U=class extends j{constructor(t=P,i=X){super({host:"premiere",label:"Premiere Pro",setup:G},t,i);this.items=async(t={})=>{await this.needs("edit");let{seq:i}=await this.sequence(t.timeline),n=await this.ask("edit.items",{timeline:i,kind:t.kind,track:t.track},12e4),s=n.project_path?await K(n.project_path,n.timeline).catch(p=>({error:p instanceof Error?p.message:String(p)})):{error:"the project has never been saved"},a=0;if(!("error"in s))for(let p of n.items){let m=s.get(`${p.kind}:${p.track}:${p.start}:${Number(p.end)-Number(p.start)}`);m?Object.assign(p,m,{saved:!0}):(p.saved=!1,a++)}return{...n,color_groups:[],layers:1,..."error"in s?{saved_note:`saved project not read: ${s.error}`}:{unsaved_items:a}}};this.premiereRenders=new Map}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async model(t){return await super.model(t)}async projectClips(){return await this.needs("edit"),await this.ask("edit.project_clips",{},12e4)}async relinkClips(t){return await this.needs("edit"),await this.ask("edit.relink_clips",{items:t},6e4+t.length*2e3)}async cutIn(t,i){await this.needs("edit");let{seq:n}=await this.sequence(t);return await this.ask("edit.cut_in",{timeline:n,cuts:i},12e4+i.length*3e3)}async renderStart(t){if(t.range)throw new h("unsupported","premiere: a frame range is not supported yet; set in/out on the sequence in Premiere");if(!t.preset||!/\.epr$/i.test(t.preset))throw new h("usage","premiere: preset must be the path of a Media Encoder preset (.epr)");let{seq:i,name:n}=await this.sequence(t.timeline);await R(t.target_dir);let s=_(t.target_dir,`${t.name??n}.mov`),a=await this.ask("render.export_sequence",{timeline:i,output_path:s,preset_path:t.preset,queue:!1},6e4);if(!a.ok)throw new h("render_refused","premiere: Premiere refused the export");let p=a.job||`ppro-${Date.now()}`;return this.premiereRenders.set(p,s),{job_id:p,state:"rendering",percent:0}}async renderStatus(t){let i=await this.ask("render.progress"),n=i[t]??i.last,s=this.premiereRenders.get(t);return n?.event==="error"||n?.event==="onEncodeError"?{job_id:t,state:"failed",percent:0,error:String(n.data??"encode error")}:n?.event==="complete"||n?.event==="onEncodeComplete"||s&&await y(s)&&!n?{job_id:t,state:"complete",percent:100,...s?{outputs:[s]}:{}}:{job_id:t,state:"rendering",percent:typeof n?.data=="number"?Math.round(Number(n.data)*100):0}}async renderCancel(t){return{job_id:t,state:"cancelled",percent:0,error:"Premiere's export cannot be cancelled from here; cancel it in Premiere / Media Encoder"}}};async function K(d,e){let{session:t}=await N(d,"prproj"),i=t.timelines.find(s=>s.name===e),n=new Map;if(!i)throw new Error(`the saved project has no sequence "${e}" (saved before it was made?)`);for(let s of i.tracks)if(!(s.kind!=="Video"&&s.kind!=="Audio"))for(let a of s.items){if(a.kind==="gap"||a.kind==="transition")continue;let p=a;n.set(`${s.kind==="Video"?"video":"audio"}:${s.track_index}:${a.timeline_range.start.value}:${a.timeline_range.duration.value}`,{saved_id:a.id,...p.speed_factor!=null&&p.speed_factor!==1?{retime:p.speed_factor}:{},...p.speed_ramped?{ramped:!0}:{},...p.speed_reverse?{reversed:!0}:{},...a.kind==="nested"?{nested:!0}:{},...p.is_multicam?{multicam:!0}:{},...p.effects?.some(m=>/stabiliz/i.test(m.kind??""))?{stabilized:!0}:{},...p.effects?.length?{saved_effects:p.effects.map(m=>m.name??m.kind??"")}:{}})}return n}function z(d=v()){return d==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":d==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function V(){for(let d of["./uxp-plugin/","./premiere-uxp/"]){let e=S(new URL(d,import.meta.url));if(await x(_(e,"manifest.json")))return e}throw new Error("premiere: the conform.tools panel is missing from this install")}async function Q(){return JSON.parse(await H(_(await V(),"manifest.json"))).version}async function oe(d=v()){let e=z(d);if(!e||!await y(e))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let t=await w(e,d==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),i=t.stdout.split(`
3
+ import{M as D,N as F,O as N}from"./chunk-5WEZRGXG.js";import{n as P}from"./chunk-P2LL3JMC.js";import{B as C,D as M,E as T,H as q,I,L as w,V as b,X as k,Y as _,_ as L,g as v,k as O,p as S,q as A,r as y,s as x,v as H,x as E,y as R}from"./chunk-PLRB2YXJ.js";var B=16e3,h=class extends Error{constructor(t,i){super(i);this.code=t}},j=class d{constructor(e,t=P,i=B){this.spec=e;this.bridge=t;this.waitMs=i;this.renders=new Map;this.host=e.host,e.items&&(this.items=n=>this.modelItems(n??{}))}async peer(){let e=await(await this.bridge()).waitFor(this.host,this.waitMs);if(!e)throw new h("not_connected",`${this.host}: the conform.tools plugin in ${this.spec.label} is not connected. ${this.spec.setup}`);return e}async needs(e){let t=await this.peer();if(!t.capabilities.includes(e))throw new h("panel_old",`${this.host}: the conform.tools plugin open in ${this.spec.label} ${t.version||""} has no ${e} (an older plugin); update it (${this.spec.setup})`);return t}async ask(e,t={},i){return await this.peer(),await(await this.bridge()).request(this.host,e,t,i)}static{this.announced=(e,t)=>e.optional_verbs.includes(t)}async support(){let e={ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"},t;try{t=await(await this.bridge()).waitFor(this.host,Math.min(3e3,this.waitMs))}catch(s){let a={ok:!1,reason:s instanceof Error?s.message:String(s)};return{export:a,open:a,render:a,markers:a,renderplugin:e}}if(!t){let s={ok:!1,reason:`the conform.tools plugin in ${this.spec.label} is not connected`,setup:this.spec.setup};return{export:s,open:s,render:s,markers:s,renderplugin:e}}let i=(s,a)=>s?{ok:!0}:{ok:!1,reason:`this plugin version has no ${a}`},n=t.capabilities;return{export:i(n.includes("timeline_read")||n.includes("timeline_write"),"timeline_read"),open:i(d.announced(t,"timeline_write.import_file"),"timeline_write.import_file"),render:i(n.includes("render"),"render"),markers:i(n.includes("markers"),"markers"),renderplugin:e}}async current(){let e=await this.ask("session.current_project");if(!e)return{project:"",timelines:[],timeline:""};let t=await this.ask("session.timeline_count",{project:e}),i=[];for(let s=1;s<=t;s++){let a=await this.ask("session.timeline_by_index",{project:e,index:s});a&&i.push(await this.ask("session.name",{handle:a}))}let n=await this.ask("session.current_timeline",{project:e});return{project:await this.ask("session.name",{handle:e}),timelines:i,timeline:n?await this.ask("session.name",{handle:n}):""}}async project(e={}){let t=await this.current();return{project:t.project,timeline:e.timeline??t.timeline,timelines:t.timelines,tracks:[],jobs:[],found:{},pool:{path:"",clips:0,folders:[]}}}async sequence(e){let t=await this.ask("session.current_project");if(!t)throw new h("no_project",`${this.host}: no project is open`);if(!e){let s=await this.ask("session.current_timeline",{project:t});if(!s)throw new h("no_timeline",`${this.host}: no timeline is active`);return{project:t,seq:s,name:await this.ask("session.name",{handle:s})}}let i=await this.ask("session.timeline_count",{project:t}),n=[];for(let s=1;s<=i;s++){let a=await this.ask("session.timeline_by_index",{project:t,index:s});if(!a)continue;let p=await this.ask("session.name",{handle:a});if(p===e)return{project:t,seq:a,name:p};n.push(p)}throw new h("not_found",`${this.host}: no timeline named "${e}" (have: ${n.join(", ")})`)}async model(e){let{project:t,seq:i}=await this.sequence(e);return await this.ask("timeline_read.model",{timeline:i,project:t},12e4)}async export(e){if(!e.out_path)throw new h("usage",`${this.host}: export needs out_path`);let t=await this.peer(),{project:i,seq:n,name:s}=await this.sequence(e.timeline),a=await this.ask("session.name",{handle:i}),p=r=>d.announced(t,r),m=e.out_path,l,c=[];if(p("timeline_write.export_otio")||p("timeline_write.export_xml")){let r=p("timeline_write.export_otio"),o=await this.ask(r?"timeline_write.export_otio":"timeline_write.export_xml",{project:i,timeline:n,path:e.out_path},12e4);if(l=o.format??(r?"otio":"xmeml"),o.ok===!1)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${e.out_path}${o.errors?.length?` (${o.errors.join("; ")})`:""}`);o.path&&o.path!==e.out_path&&(m=await this.adopt(o.path,e.out_path)),c=o.warnings??[]}else if(p("timeline_read.export_file")){let r=await this.ask("timeline_read.export_file",{timeline:n,fmt:"otio",path:e.out_path},12e4);if(!r)throw new h("export_failed",`${this.host}: ${this.spec.label} exported no OTIO`);l="otio",r!==e.out_path&&(m=await this.adopt(r,e.out_path))}else{await this.needs("timeline_read");let r=await this.ask("timeline_read.model",{timeline:n,project:i},12e4),o=J(r);await E(e.out_path,JSON.stringify(o.otio)),l="otio",c=o.notes}if(!D.includes(l))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${l}, which the engine does not read (${m})`);if(!await x(m)||(await A(m)).size===0)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${m}`);return{path:m,format:l,project:a,timeline:s,...c.length?{notes:c}:{}}}async adopt(e,t){let i=k(e)&&k(e)!==k(t)?t.slice(0,t.length-k(t).length)+k(e):t;if(await C(e,i),!F(i))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${b(e)}, which the engine does not read`);return i}async open(e){if(e.into==="scratch")throw new h("unsupported",`${this.host}: opening into a scratch project is not supported; the import lands in the open project`);let t=await this.peer();if(!d.announced(t,"timeline_write.import_file"))throw new h("unsupported",`${this.host}: this conform.tools plugin cannot import timelines (${this.spec.setup})`);let i=await this.ask("session.current_project");if(!i)throw new h("no_project",`${this.host}: no project is open`);let n=await this.ask("timeline_write.import_file",{project:i,path:e.path,sequences:null},3e5);if(!n.ok)throw new h("import_failed",`${this.host}: ${this.spec.label} did not import ${e.path}${n.issues?.length?` (${n.issues.join("; ")})`:""}`);let s=[...n.issues??[]];return n.imported.length>1&&s.push(`imported ${n.imported.length} timelines: ${n.imported.map(a=>a.name).join(", ")}`),e.name&&s.push(`${this.spec.label} names imported timelines after the file's own; name was not applied`),e.media_dirs?.length&&s.push(`${this.spec.label} links media from the paths in the file; media_dirs was not used (relink with timeline_relink before writing)`),{project:await this.ask("session.name",{handle:i}),timeline:n.imported[0]?.name??b(e.path),notes:s,restored:!e.stay,...n.bin?{folder:n.bin}:{}}}async modelItems(e){let t=await this.model(e.timeline),i=[...e.kind==="audio"?[]:t.items.map(n=>({kind:"video",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:n.handle?.$h??n.clip_id??"",name:n.name??"",color:n.color??"",flags:n.flags??[],enabled:n.enabled??!0,file:n.file_path})),...e.kind==="video"?[]:(t.audio_items??[]).map(n=>({kind:"audio",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:"",name:n.name??"",file:n.file_path??""}))].filter(n=>e.track===void 0||n.track===e.track);return{project:(await this.current()).project,timeline:t.timeline,start_frame:t.start_frame,fps:t.fps,items:i,color_groups:[],layers:1}}async apply(e){let{project:t,seq:i,name:n}=await this.sequence(e.timeline),s=[],a=[],p=l=>l.op.startsWith("marker_")&&!l.item;for(let l=0;l<e.ops.length;){let c=l;for(;c<e.ops.length&&p(e.ops[c])===p(e.ops[l]);)c++;let r=e.ops.slice(l,c),o=p(r[0])?await this.markerOps(i,r):await this.clipOps(i,r,e.timeline);s.push(...o.results),a.unshift(...o.undo),l=c}let m=s.filter(l=>l.ok).length;return{project:await this.ask("session.name",{handle:t}),timeline:n,results:s,undo:a,applied:m,failed:s.length-m}}async clipOps(e,t,i){let n=await this.peer();if(n.capabilities.includes("edit"))return await this.ask("edit.apply",{timeline:e,ops:t},6e4+t.length*500);let s=(c,r)=>({op:c.op,ok:!1,detail:r});if(!n.capabilities.includes("item_meta"))return{results:t.map(c=>s(c,`${this.host}: clip edits are not reachable over this plugin`)),undo:[]};let a=await this.model(i),p=c=>c?"id"in c?{$h:c.id}:(c.kind??"video")!=="video"?null:a.items.find(r=>r.track===c.track&&r.start-a.start_frame===c.start)?.handle??null:null,m=[],l=[];for(let c of t){let r=p(c.item);try{if(!r)m.push(s(c,`no video item at ${JSON.stringify(c.item??null)}`));else if(c.op==="clip_color"){let o=await this.ask("item_meta.color",{handle:r}),u=c.color?await this.ask("item_meta.set_color",{handle:r,color:c.color}):await this.ask("item_meta.clear_color",{handle:r});m.push({op:c.op,ok:u}),u&&l.unshift({op:"clip_color",item:c.item,color:o})}else if(c.op==="enabled"&&d.announced(n,"item_meta.set_enabled")){let o=a.items.find(f=>f.handle?.$h===r.$h)?.enabled??!0,u=await this.ask("item_meta.set_enabled",{item:r,enabled:!!c.on});m.push({op:c.op,ok:u}),u&&l.unshift({op:"enabled",item:c.item,on:o})}else m.push(s(c,`${this.host}: '${c.op}' is not reachable over this plugin`))}catch(o){m.push(s(c,o instanceof Error?o.message:String(o)))}}return{results:m,undo:l}}async markerOps(e,t){let i=await this.peer(),n=r=>d.announced(i,r),s=new Map((await this.ask("markers.list",{target:e})).map(r=>[r.frame,r])),a=[],p=[],m=async r=>{let o=await this.ask("markers.add",{target:e,frame:r.frame,color:r.color??"",name:r.name??"",note:r.note??"",duration:r.duration??1,custom_data:r.custom_data??""});return o&&s.set(r.frame,{color:"",name:"",note:"",duration:1,...r}),o},l=async r=>{let o=await this.ask("markers.delete_at",{target:e,frame:r});return o&&s.delete(r),o},c=r=>({op:"marker_add",frame:r.frame,color:r.color,name:r.name,note:r.note,duration:r.duration,...r.custom_data?{data:r.custom_data}:{}});for(let r of t){let o=Number(r.frame);try{if(r.op==="marker_add"){let u=s.get(o);u&&await l(o);let f=await m({frame:o,color:r.color,name:r.name,note:r.note,duration:Number(r.duration??1),custom_data:r.data});a.push({op:r.op,ok:f}),f&&p.unshift(...u?[c(u)]:[],{op:"marker_delete",frame:o})}else if(r.op==="marker_update"){let u=s.get(o);if(!u){a.push({op:r.op,ok:!1,detail:`no marker at frame ${o}`});continue}let f=r.to_frame!==void 0?Number(r.to_frame):o,$={...u,frame:f,...r.color!==void 0?{color:String(r.color)}:{},...r.name!==void 0?{name:String(r.name)}:{},...r.note!==void 0?{note:String(r.note)}:{}},g=!0;n("markers.set_color")&&n("markers.set_text")&&n("markers.move")?(r.color!==void 0&&(g=await this.ask("markers.set_color",{target:e,frame:o,color:r.color})&&g),(r.name!==void 0||r.note!==void 0)&&(g=await this.ask("markers.set_text",{target:e,frame:o,name:r.name,note:r.note})&&g),f!==o&&(g=await this.ask("markers.move",{target:e,frame:o,to_frame:f})&&g),s.delete(o),s.set(f,$)):g=await l(o)&&await m($),a.push({op:r.op,ok:g}),p.unshift({op:"marker_update",frame:f,color:u.color,name:u.name,note:u.note,...f!==o?{to_frame:o}:{}})}else if(r.op==="marker_delete"){let u=s.get(o),f=!!u&&await l(o);a.push({op:r.op,ok:f,...u?{}:{detail:`no marker at frame ${o}`}}),f&&u&&p.unshift(c(u))}else a.push({op:r.op,ok:!1,detail:`${this.host}: '${r.op}' is not reachable over this plugin`})}catch(u){a.push({op:r.op,ok:!1,detail:u instanceof Error?u.message:String(u)})}}return{results:a,undo:p}}async renderStart(e){if(await this.needs("render"),e.renderplugin)throw new h("unsupported","the renderplugin is a DaVinci Resolve plugin");if(e.disable_tracks?.length||e.audio_tracks?.length)throw new h("unsupported",`${this.host}: disable_tracks / audio_tracks are DaVinci Resolve's; pick a preset that renders what you need`);if(!e.preset)throw new h("usage",`${this.host}: preset is required: one of ${this.spec.label}'s export presets by name`);let{seq:t,name:i}=await this.sequence(e.timeline),n=e.name??i,s={purpose:"deliver",format:"preset",preset:e.preset,target_dir:e.target_dir,name:n,...e.range?{range:[e.range.in,e.range.out]}:{}},a=await this.ask("render.submit",{timeline:t,job:s});if(!a?.id)throw new h("render_refused",`${this.host}: ${a?.error??`${this.spec.label} refused the render`}`);if(!await this.ask("render.start",{job_ids:[a.id]}))throw new h("render_refused",`${this.host}: ${this.spec.label} did not start job ${a.id}`);return this.renders.set(a.id,{dir:e.target_dir,name:n}),{job_id:a.id,state:"queued",percent:0}}async renderStatus(e){let t=await this.ask("render.status",{job_id:e});if(!t)return{job_id:e,state:"failed",percent:0,error:`${this.host}: no render job ${e}`};let i={done:"complete",rendering:"rendering",queued:"queued",failed:"failed",cancelled:"cancelled"}[t.state]??"rendering",n={job_id:e,state:i,percent:Math.round(t.progress??(i==="complete"?100:0)),...t.error?{error:t.error}:{}};if(i==="complete"||i==="failed"||i==="cancelled"){let s=this.renders.get(e);i==="complete"&&s&&(n.outputs=await W(s.dir,s.name)),await this.ask("render.remove",{job_id:e}).catch(()=>!1),this.renders.delete(e)}return n}async renderCancel(e){return await this.ask("render.cancel",{job_id:e})?{job_id:e,state:"cancelled",percent:0}:{...await this.renderStatus(e),error:`${this.spec.label}'s running export cannot be cancelled from here; stop it in ${this.spec.label}`}}};async function W(d,e){let t=[];try{for await(let i of I(d))i.isFile&&i.name.startsWith(`${e}.`)&&t.push(_(d,i.name))}catch{}return t.sort()}function J(d){let e=(l,c)=>({OTIO_SCHEMA:"RationalTime.1",value:l,rate:c}),t=(l,c,r,o=r)=>({OTIO_SCHEMA:"TimeRange.1",start_time:e(l,r),duration:e(c,o)}),i=d.fps,n=d.tracks?.length?d.tracks:[...new Set(d.items.map(l=>l.track))].sort((l,c)=>l-c).map(l=>({index:l,enabled:!0,name:"",items:d.items.filter(c=>c.track===l)})),s=l=>(l.reversed?-1:1)*(l.speed||1)/(l.fps_factor||1),a=new Map;for(let l of d.items)if(l.file_path&&l.start_tc!=null&&l.src_abs_in!=null){let c=l.src_abs_in-l.start_tc+Math.ceil((l.end-l.start)*Math.abs(s(l))*(l.fps_factor||1));a.set(l.file_path,Math.max(a.get(l.file_path)??0,c))}let p=n.map(l=>{let c=d.start_frame,r=[];for(let o of[...l.items].sort((u,f)=>u.start-f.start)){if(o.start<c)continue;o.start>c&&r.push({OTIO_SCHEMA:"Gap.1",name:"",source_range:t(0,o.start-c,i)});let u=o.src_fps||i,f=o.start_tc!=null&&a.has(o.file_path)?o.start_tc:null,$=f!=null?o.src_abs_in:o.src_in??o.src_abs_in??0,g=s(o);r.push({OTIO_SCHEMA:"Clip.2",name:o.name??b(o.file_path||""),enabled:o.enabled!==!1,source_range:t($,o.end-o.start,u,i),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",name:b(o.file_path||""),target_url:o.file_path?`file://${o.file_path}`:"",...f!=null?{available_range:t(f,a.get(o.file_path),u)}:{},metadata:{}}},active_media_reference_key:"DEFAULT_MEDIA",effects:Math.abs(g-1)>1e-6?[{OTIO_SCHEMA:"LinearTimeWarp.1",name:"",effect_name:"LinearTimeWarp",time_scalar:g}]:[],markers:[],metadata:o.reel?{cmx_3600:{reel:o.reel}}:{}}),c=o.end}return{OTIO_SCHEMA:"Track.1",name:l.name||`V${l.index}`,kind:"Video",enabled:l.enabled!==!1,children:r,effects:[],markers:[],metadata:{}}}),m=[];return d.audio_items?.length&&m.push(`${d.audio_items.length} audio clip(s) not carried: the host's plugin reports no audio source times`),d.transitions?.length&&m.push(`${d.transitions.length} transition(s) not carried (cuts in their place)`),{otio:{OTIO_SCHEMA:"Timeline.1",name:d.timeline,global_start_time:e(d.start_frame,i),metadata:{},tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",children:p,effects:[],markers:[],metadata:{}}},notes:m}}var X=16e3;var G="Install the conform.tools panel (host_setup host=premiere action=install_panel), then in Premiere open Window > UXP Plugins > conform.tools. It connects by itself from then on.";var U=class extends j{constructor(t=P,i=X){super({host:"premiere",label:"Premiere Pro",setup:G},t,i);this.items=async(t={})=>{await this.needs("edit");let{seq:i}=await this.sequence(t.timeline),n=await this.ask("edit.items",{timeline:i,kind:t.kind,track:t.track},12e4),s=n.project_path?await K(n.project_path,n.timeline).catch(p=>({error:p instanceof Error?p.message:String(p)})):{error:"the project has never been saved"},a=0;if(!("error"in s))for(let p of n.items){let m=s.get(`${p.kind}:${p.track}:${p.start}:${Number(p.end)-Number(p.start)}`);m?Object.assign(p,m,{saved:!0}):(p.saved=!1,a++)}return{...n,color_groups:[],layers:1,..."error"in s?{saved_note:`saved project not read: ${s.error}`}:{unsaved_items:a}}};this.premiereRenders=new Map}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async model(t){return await super.model(t)}async projectClips(){return await this.needs("edit"),await this.ask("edit.project_clips",{},12e4)}async relinkClips(t){return await this.needs("edit"),await this.ask("edit.relink_clips",{items:t},6e4+t.length*2e3)}async cutIn(t,i){await this.needs("edit");let{seq:n}=await this.sequence(t);return await this.ask("edit.cut_in",{timeline:n,cuts:i},12e4+i.length*3e3)}async renderStart(t){if(t.range)throw new h("unsupported","premiere: a frame range is not supported yet; set in/out on the sequence in Premiere");if(!t.preset||!/\.epr$/i.test(t.preset))throw new h("usage","premiere: preset must be the path of a Media Encoder preset (.epr)");let{seq:i,name:n}=await this.sequence(t.timeline);await R(t.target_dir);let s=_(t.target_dir,`${t.name??n}.mov`),a=await this.ask("render.export_sequence",{timeline:i,output_path:s,preset_path:t.preset,queue:!1},6e4);if(!a.ok)throw new h("render_refused","premiere: Premiere refused the export");let p=a.job||`ppro-${Date.now()}`;return this.premiereRenders.set(p,s),{job_id:p,state:"rendering",percent:0}}async renderStatus(t){let i=await this.ask("render.progress"),n=i[t]??i.last,s=this.premiereRenders.get(t);return n?.event==="error"||n?.event==="onEncodeError"?{job_id:t,state:"failed",percent:0,error:String(n.data??"encode error")}:n?.event==="complete"||n?.event==="onEncodeComplete"||s&&await y(s)&&!n?{job_id:t,state:"complete",percent:100,...s?{outputs:[s]}:{}}:{job_id:t,state:"rendering",percent:typeof n?.data=="number"?Math.round(Number(n.data)*100):0}}async renderCancel(t){return{job_id:t,state:"cancelled",percent:0,error:"Premiere's export cannot be cancelled from here; cancel it in Premiere / Media Encoder"}}};async function K(d,e){let{session:t}=await N(d,"prproj"),i=t.timelines.find(s=>s.name===e),n=new Map;if(!i)throw new Error(`the saved project has no sequence "${e}" (saved before it was made?)`);for(let s of i.tracks)if(!(s.kind!=="Video"&&s.kind!=="Audio"))for(let a of s.items){if(a.kind==="gap"||a.kind==="transition")continue;let p=a;n.set(`${s.kind==="Video"?"video":"audio"}:${s.track_index}:${a.timeline_range.start.value}:${a.timeline_range.duration.value}`,{saved_id:a.id,...p.speed_factor!=null&&p.speed_factor!==1?{retime:p.speed_factor}:{},...p.speed_ramped?{ramped:!0}:{},...p.speed_reverse?{reversed:!0}:{},...a.kind==="nested"?{nested:!0}:{},...p.is_multicam?{multicam:!0}:{},...p.effects?.some(m=>/stabiliz/i.test(m.kind??""))?{stabilized:!0}:{},...p.effects?.length?{saved_effects:p.effects.map(m=>m.name??m.kind??"")}:{}})}return n}function z(d=v()){return d==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":d==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function V(){for(let d of["./uxp-plugin/","./premiere-uxp/"]){let e=S(new URL(d,import.meta.url));if(await x(_(e,"manifest.json")))return e}throw new Error("premiere: the conform.tools panel is missing from this install")}async function Q(){return JSON.parse(await H(_(await V(),"manifest.json"))).version}async function oe(d=v()){let e=z(d);if(!e||!await y(e))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let t=await w(e,d==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),i=t.stdout.split(`
4
4
  `).find(n=>/CONFORM\.TOOLS|conformtools/i.test(n));return{installed:!!i&&/enabled|installed/i.test(i),version:i?.match(/(\d+\.\d+\.\d+)\s*$/)?.[1],listing:t.stdout.trim()}}async function ae(d=v()){let e=z(d);if(!e||!await y(e))throw new Error("premiere: Creative Cloud's plugin installer (UnifiedPluginInstallerAgent) is not on this machine; install Creative Cloud");let t=await V(),i=await Q(),n=await q("conform-ccx-");for(let c of["manifest.json","index.html","index.js","lib","icons"])await T(_(t,c),_(n,c));let s=_(O(),"premiere");await R(s);let a=L(_(s,`conformtools-premiere-${i}.ccx`));await M(a);let p=d==="darwin"?await w("sh",["-c",`cd '${n.replace(/'/g,"'\\''")}' && zip -r -q -X '${a.replace(/'/g,"'\\''")}' manifest.json index.html index.js lib icons`]):await w("powershell",["-NoProfile","-Command",`Compress-Archive -Path '${n}\\*' -DestinationPath '${a.replace(/\.ccx$/,".zip")}' -Force; Move-Item -Force '${a.replace(/\.ccx$/,".zip")}' '${a}'`]);if(await M(n),!p.success)throw new Error(`premiere: could not package the panel: ${p.stderr.trim()}`);await w(e,d==="win32"?["/remove","conform.tools"]:["--remove","conform.tools"],{timeoutMs:12e4});let m=await w(e,d==="win32"?["/install",a]:["--install",a],{timeoutMs:18e4}),l=`${m.stdout}
5
5
  ${m.stderr}`.trim();if(!m.success||!/Installation Successful/i.test(l))throw new Error(`premiere: Adobe's installer refused the panel: ${l.split(`
6
6
  `).pop()}`);return{version:i,ccx:a,output:l}}export{j as a,U as b,K as c,Q as d,oe as e,ae as f};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as M}from"./chunk-PFZVET7S.js";import{b as fe,c as pe,f as he}from"./chunk-P7OVDUA5.js";import{f as K,h as me}from"./chunk-7MC7M2Y5.js";import{a as de}from"./chunk-VS3MKKJ5.js";import{i as D}from"./chunk-XNR7M4VX.js";import{b as C,d as J,f as R}from"./chunk-NU3X7P4N.js";import{Ga as ue,da as oe,ea as ie,ia as se,na as ae,va as ce,wa as le}from"./chunk-C5IX63YF.js";import{a as ne}from"./chunk-3OCQA33E.js";import{C as W,I as v,J as A,K as re,N as te,V as b,W as y,X as L,Y as _,b as E,c as Z,d as Q,g as q,p as I,q as B,s as ee,t as O,w as H,y as j}from"./chunk-PLRB2YXJ.js";var V=!1;var F=8,Me=0,Fe=3,z=2;async function Pe(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),o=s=>String.fromCharCode(t[s],t[s+1],t[s+2],t[s+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(o(4)==="RED1"||o(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],i=o(4);return/^[A-Za-z0-9 ]{4}$/.test(i)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ee(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Oe(e){return async(t,o)=>new Uint8Array(await e.slice(t,Math.min(t+o,e.size)).arrayBuffer())}function be(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function nr(e){return await ue(),ge?ge.clip(e,V?"rec709":"",()=>we(e)):we(e)}var ge=null;async function we(e){let t=await Pe(e),o=[];if(t==="r3d"){let r=e,i=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],n=r.bases??[0],s=async(u,m,d)=>{let f=n[u]+m;return new Uint8Array(await e.slice(f,Math.min(f+d,n[u]+i[u].size)).arrayBuffer())},a=JSON.stringify(i.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await le(s,a)),l=JSON.parse(await se(s,a));return i.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&o.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:n[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:be(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Me},geometrySpec:{codec:"r3d",subbands:Fe},index:null,warnings:o}}if(t==="mxf"){let r=Oe(e),i=JSON.parse(await ce(r,e.size));if(!i)throw new Error(`${e.name}: MXF index unreadable`);let n=JSON.parse(await ae(r,e.size)),s=[];for(let f=0;f<n.frame_count;f++)s.push({offset:n.frames[f*2],size:n.frames[f*2+1]});let a=s.filter(f=>f.size===0).length;a&&o.push(`${a} frame(s) had no locatable picture KLV`);let c=i.width??0,l=i.height??0,u=(i.inner_codec??"").toLowerCase(),m=null,d="MXF";return u==="arriraw"?(m={codec:"arriraw",w:c,h:l,scale:F},d="ARRIRAW"):u==="xocn"?(m={codec:"xocn",scale:F,...V?{display:"rec709"}:{}},d="X-OCN"):await ie(r,e.size)?(m={codec:"vc3",scale:F},d="DNxHR"):await oe(r,e.size)?(m={codec:"prores"},d="ProRes"):o.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:m?s:[],w:c,h:l,fps:be(i),startFrame:i.timecode?.start_frame??0,dropFrame:i.timecode?.drop_frame??!1,label:d,spec:m,geometrySpec:m&&m.codec==="arriraw"?{...m,scale:z}:m&&m.codec==="xocn"?{codec:"xocn",scale:z,...V?{display:"rec709"}:{}}:m&&m.codec==="vc3"?{codec:"vc3",scale:z}:null,index:null,warnings:o}}if(t==="isobmff"){let r=await me(e),i=Ee(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:o};if(r.kind==="h264"||r.kind==="hevc")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:null,geometrySpec:null,index:r,warnings:o};let n=i==="braw"?{codec:"braw",scale:F}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:F}:null;return n||o.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:n?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:n?i==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:n,geometrySpec:n?{...n,scale:z}:null,index:r,warnings:o}}throw new Error(`${e.name}: unrecognised container`)}var Ae=Number(E("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(Q()/2),Math.floor(Z()/2**31))),X=0,_e=[],Ce=async(...e)=>{X>=Ae?await new Promise(t=>_e.push(t)):X++;try{return await te(...e)}finally{let t=_e.shift();t?t():X--}};async function De(){let e=q()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[E("CONFORM_NATIVE_DECODE"),I(new URL(`./${e}`,import.meta.url)),I(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let o of t)if(await ee(o))return o;return null}var $=class extends Error{constructor(o,r){super(r);this.why=o}};function Mr(e){let t=null;try{t=JSON.parse(e.trim().split(`
3
+ import{a as M}from"./chunk-PFZVET7S.js";import{b as fe,c as pe,f as he}from"./chunk-6V4OEOOX.js";import{f as K,h as me}from"./chunk-AMRJXYL4.js";import{a as de}from"./chunk-3D3Z4TBR.js";import{i as D}from"./chunk-2BPR6LK6.js";import{b as C,d as J,f as R}from"./chunk-NU3X7P4N.js";import{Ha as ue,da as oe,ea as ie,ia as se,na as ae,va as ce,wa as le}from"./chunk-RJ6JA2LZ.js";import{a as ne}from"./chunk-PHAMF4JF.js";import{C as W,I as v,J as A,K as re,N as te,V as b,W as y,X as L,Y as _,b as E,c as Z,d as Q,g as q,p as I,q as B,s as ee,t as O,w as H,y as j}from"./chunk-PLRB2YXJ.js";var V=!1;var F=8,Me=0,Fe=3,z=2;async function Pe(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),o=s=>String.fromCharCode(t[s],t[s+1],t[s+2],t[s+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(o(4)==="RED1"||o(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],i=o(4);return/^[A-Za-z0-9 ]{4}$/.test(i)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ee(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Oe(e){return async(t,o)=>new Uint8Array(await e.slice(t,Math.min(t+o,e.size)).arrayBuffer())}function be(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function nr(e){return await ue(),ge?ge.clip(e,V?"rec709":"",()=>we(e)):we(e)}var ge=null;async function we(e){let t=await Pe(e),o=[];if(t==="r3d"){let r=e,i=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],n=r.bases??[0],s=async(u,m,d)=>{let f=n[u]+m;return new Uint8Array(await e.slice(f,Math.min(f+d,n[u]+i[u].size)).arrayBuffer())},a=JSON.stringify(i.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await le(s,a)),l=JSON.parse(await se(s,a));return i.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&o.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:n[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:be(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Me},geometrySpec:{codec:"r3d",subbands:Fe},index:null,warnings:o}}if(t==="mxf"){let r=Oe(e),i=JSON.parse(await ce(r,e.size));if(!i)throw new Error(`${e.name}: MXF index unreadable`);let n=JSON.parse(await ae(r,e.size)),s=[];for(let f=0;f<n.frame_count;f++)s.push({offset:n.frames[f*2],size:n.frames[f*2+1]});let a=s.filter(f=>f.size===0).length;a&&o.push(`${a} frame(s) had no locatable picture KLV`);let c=i.width??0,l=i.height??0,u=(i.inner_codec??"").toLowerCase(),m=null,d="MXF";return u==="arriraw"?(m={codec:"arriraw",w:c,h:l,scale:F},d="ARRIRAW"):u==="xocn"?(m={codec:"xocn",scale:F,...V?{display:"rec709"}:{}},d="X-OCN"):await ie(r,e.size)?(m={codec:"vc3",scale:F},d="DNxHR"):await oe(r,e.size)?(m={codec:"prores"},d="ProRes"):o.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:m?s:[],w:c,h:l,fps:be(i),startFrame:i.timecode?.start_frame??0,dropFrame:i.timecode?.drop_frame??!1,label:d,spec:m,geometrySpec:m&&m.codec==="arriraw"?{...m,scale:z}:m&&m.codec==="xocn"?{codec:"xocn",scale:z,...V?{display:"rec709"}:{}}:m&&m.codec==="vc3"?{codec:"vc3",scale:z}:null,index:null,warnings:o}}if(t==="isobmff"){let r=await me(e),i=Ee(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:o};if(r.kind==="h264"||r.kind==="hevc")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:K(r.kind),spec:null,geometrySpec:null,index:r,warnings:o};let n=i==="braw"?{codec:"braw",scale:F}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:F}:null;return n||o.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:n?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:n?i==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:n,geometrySpec:n?{...n,scale:z}:null,index:r,warnings:o}}throw new Error(`${e.name}: unrecognised container`)}var Ae=Number(E("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(Q()/2),Math.floor(Z()/2**31))),X=0,_e=[],Ce=async(...e)=>{X>=Ae?await new Promise(t=>_e.push(t)):X++;try{return await te(...e)}finally{let t=_e.shift();t?t():X--}};async function De(){let e=q()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[E("CONFORM_NATIVE_DECODE"),I(new URL(`./${e}`,import.meta.url)),I(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let o of t)if(await ee(o))return o;return null}var $=class extends Error{constructor(o,r){super(r);this.why=o}};function Mr(e){let t=null;try{t=JSON.parse(e.trim().split(`
4
4
  `).pop())}catch{}if(t?.why==="not_entitled")throw new ne("not_entitled",t.detail??"this machine is not licensed");return t?.detail??e.trim()}function ze(e,t){try{let o=JSON.parse(e.trim().split(`
5
5
  `).pop()??"");return new $(o.why,o.detail)}catch{return new $("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Ne(e){let t=e.reduce((i,n)=>i+n.length,0),o=new Uint8Array(t),r=0;for(let i of e)o.set(i,r),r+=i.length;return o}async function ye(e,t,o,r,i){let n=await De();if(!n)throw new $("missing","the native decoder (conformtools-decode) is not installed");let s=null,a=[],c=0,l=d=>{let f=new Uint8Array(d),p=0;for(;p<d;){let h=a[0],g=Math.min(h.length,d-p);f.set(h.subarray(0,g),p),p+=g,g===h.length?a.shift():a[0]=h.subarray(g)}return c-=d,f},u=[e,t,"--width",String(i.width??32768)];i.from!=null&&u.push("--from",String(i.from)),i.count!=null&&u.push("--count",String(i.count)),i.range&&u.push("--range",i.range);let m=await Ce(n,u,d=>{if(a.push(d),c+=d.length,!s){let p=Ne(a.splice(0));a.push(p);let h=p.indexOf(10);if(h<0)return;s=JSON.parse(new TextDecoder().decode(p.subarray(0,h))),l(h+1),o(s)}let f=4+s.w*s.h*(s.bpp??(e==="rgb16"?6:4));for(;c>=f;){let p=l(f);r(new DataView(p.buffer).getUint32(0,!0),p.subarray(4))}},{signal:i.signal});if(m.code!==0||!s)throw ze(m.stderr,m.code)}function xe(e,t,o,r={}){return ye("bgra",e,t,o,r)}function $e(e,t,o,r={}){return ye("rgb16",e,t,(i,n)=>o(i,new Uint16Array(n.buffer,n.byteOffset,n.length>>1)),r)}var Te=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],N=e=>(e>>4)*10+(e&15);function Ue(e){let t=N(e&63),o=N(e>>>8&127),r=N(e>>>16&127),i=N(e>>>24&63),n=s=>String(s).padStart(2,"0");return`${n(i)}:${n(r)}:${n(o)}${e&64?";":":"}${n(t)}`}function ke(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let o={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,i=()=>{let s=r;for(;r<e.length&&e[r]!==0;)r++;let a=new TextDecoder().decode(e.subarray(s,r));return r++,a},n=s=>({width:t.getInt32(s+8,!0)-t.getInt32(s,!0)+1,height:t.getInt32(s+12,!0)-t.getInt32(s+4,!0)+1});for(;r<e.length;){let s=i();if(!s)break;let a=i();if(r+4>e.length)return null;let c=t.getInt32(r,!0);if(r+=4,c<0||r+c>e.length)return null;if(o.attributes.push(`${s}:${a}`),s==="framesPerSecond"&&a==="rational"&&c>=8){let l=t.getInt32(r,!0),u=t.getUint32(r+4,!0);o.fps=u?l/u:null}else s==="timeCode"&&a==="timecode"&&c>=8?o.timecode=Ue(t.getUint32(r,!0)):s==="dataWindow"&&a==="box2i"&&c>=16?{width:o.width,height:o.height}=n(r):s==="displayWindow"&&a==="box2i"&&c>=16?o.display=n(r):s==="compression"&&c>=1&&(o.compression=Te[e[r]]??`type ${e[r]}`);r+=c}return o}async function Ie(e){let t=e,o=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await O(e))o=/^(.*?)(\d+)(\.exr)$/i;else{t=y(e);let n=r?[null,r[1],r[2],r[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(b(e));if(!n)return{frames:[e],numbers:[]};let s=a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");o=new RegExp(`^${s(n[1])}(\\d{${n[2].length}})${s(n[3])}$`,"i")}let i=[];for await(let n of v(t)){let s=n.isFile?o.exec(n.name):null;s&&i.push({n:Number(s[s.length===4?2:1]),f:_(t,n.name)})}return i.sort((n,s)=>n.n-s.n),{frames:i.map(n=>n.f),numbers:i.map(n=>n.n)}}async function ve(e){let t=await Ie(e),o=t.frames[0];if(!o)throw new Error(`no .exr frames for '${b(e)}'`);let r=await A(o),i;try{i=ke(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!i)throw new Error(`'${b(o)}' is not an OpenEXR file`);let n=Math.max(1,t.frames.length),s=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,a=i.fps??0;return{id:b(o),kind:"external",target_url:o,local_path:o,content_kind:n>1?"video":"still",source_fps:i.fps??void 0,source_timecode:i.timecode??void 0,source_resolution_w:i.width,source_resolution_h:i.height,available_range:{start:{value:0,rate:a},duration:{value:n,rate:a}},streams:[{kind:"video",codec:"exr",width:i.width,height:i.height,rate:i.fps??void 0,codec_specific:{compression:i.compression}}],vendor_metadata:{exr:{frames:n,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:s,display_window:i.display,attributes:i.attributes,fps_source:i.fps!=null?"header framesPerSecond":"not in the header",timecode_source:i.timecode?"header timeCode (first frame)":"not in the header"}}}}var G=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function Be(e){let t=await A(e);return{path:e,file:t,size:t.size}}function He(e){return(t,o)=>e.file.readAt(t,o)}async function je(e){let t=M(b(e));if(!t)return[e];let o=y(e),r=[];for await(let i of v(o)){if(!i.isFile)continue;let n=M(i.name);n&&n.clipBase===t.clipBase&&r.push({n:n.partNumber,p:_(o,i.name)})}return r.sort((i,n)=>i.n-n.n).map(i=>i.p)}async function Y(e){if(await O(e)){let n=[];for await(let s of v(e))s.isFile&&M(s.name)&&n.push(_(e,s.name));if(!n.length)throw new Error(`'${b(e)}' is a folder with no .R3D parts`);e=n.sort()[0]}let t=pe(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...G].join(" ")})`);let o=await je(e),r=await Promise.all(o.map(Be));return{source:he(t,r.map(n=>fe(b(n.path),{fileSize:n.size,read:He(n)}))),parts:r,format:t,anchor:o[0],close:()=>r.forEach(n=>n.file.close())}}async function We(e,t,o,r){if(!/h264|avc|hevc|h265/.test(o)){let i=null,n=await Y(e);try{return await D(n.source,{verb:"decode",index:t,intent:"park"})}catch(s){i=s}finally{n.close()}try{return await Se(e,t,r)}catch(s){throw/no decoder/.test(String(i))?s:i instanceof Error?i:new Error(String(i))}}return Se(e,t,r)}async function kr(e,t,o,r={}){if(/\.mxf$/i.test(e)&&(!o||/h264|avc|mxf/.test(o))){let a=null,c=null;try{await $e(e,l=>{a=l},(l,u)=>{l===t&&(c=u.slice())},{from:t,count:1,range:r.range})}catch(l){if(!(l instanceof $)||!/unsupported|missing/.test(l.why))throw l}if(c&&a){let l=a;return{rgb:c,width:l.w,height:l.h,bits:l.bit_depth??16,decoder:"media-core",full_range:l.full_range??null}}}let i=await We(e,t,o),n=i.width*i.height,s=new Uint16Array(n*3);for(let a=0;a<n;a++)s[a*3]=i.rgba[a*4]*257,s[a*3+1]=i.rgba[a*4+1]*257,s[a*3+2]=i.rgba[a*4+2]*257;return{rgb:s,width:i.width,height:i.height,bits:8,decoder:"8-bit",full_range:null}}async function Se(e,t,o){t=Math.round(t);let r=0,i=0,n=null;if(await xe(e,a=>{r=a.w,i=a.h},(a,c)=>{a===t&&(n=c)},{from:t,count:1,width:o}),!n)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let s=n;for(let a=0;a<s.length;a+=4){let c=s[a];s[a]=s[a+2],s[a+2]=c}return{rgba:s,width:r,height:i}}async function P(e){if(/\.exr$/i.test(e))return ve(e);let t=await Y(e);try{let o=await D(t.source,{verb:"inspect"});if(!o)throw new Error(`could not read '${b(e)}' as ${t.format}`);return o.target_url=t.anchor,o.local_path=t.anchor,o.id=o.id||b(t.anchor),t.parts.length>1&&((o.vendor_metadata??={}).spanned_parts=t.parts.map(r=>b(r.path))),o.size_bytes=t.parts.reduce((r,i)=>r+i.size,0),o}finally{t.close()}}function Le(e,t,o,r){let i=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,n=Math.floor(e*i/t+1e-6);return{tc:C(n,r),frames:Math.round(o*i/t)}}var Je=e=>String(Math.round(e*1e3)/1e3);function Ir(e,t){let o=e.streams?.find(m=>m.kind==="video"),r=e.streams?.filter(m=>m.kind==="audio")??[],i=e.vendor_metadata?.bext;if(!o&&e.available_range&&r[0]?.rate){let m=r[0].rate,d=e.available_range.duration.value,p=(t?[t]:[24e3/1001,24]).map(h=>{let g=Le(i?.time_reference??0,i?.sample_rate||m,d,h);return`${i?`start TC ${g.tc}, `:""}${g.frames} frames @ ${Je(h)} fps`});return[e.target_url??"",`audio only; ${d} samples (${(d/m).toFixed(3)} s)${i?`; BWF time_reference ${i.time_reference}`:"; no BWF timecode"}`,...p,...t?[]:["(pass fps for the project's rate)"],...r.map((h,g)=>`audio ${r.length>1?`${g+1}: `:""}${h.codec??"pcm"} ${h.channels??"?"}ch ${h.rate} Hz ${h.bit_depth??"?"}-bit`)].join(`
6
6
  `)}let n=e.available_range?.duration?.value??e.declared_duration?.value??null,s=e.source_fps??o?.rate??null,a=e.size_bytes,c=e.vendor_metadata?.spanned_parts,l=o?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,o?.bit_depth?`${o.bit_depth}-bit`:null,l.colr?`colour ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", ");return[e.target_url??"",o?`${o.codec??"?"} ${o.width??"?"}x${o.height??"?"}${s?` @ ${Math.round(s*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",`start TC ${e.source_timecode??"none"}; ${n!=null?`${n} frames`:"length unknown"}${n!=null&&s?` (${(n/s).toFixed(2)} s)`:""}`,r.length?r.map((m,d)=>{let f=m.codec_specific?.channel_layout;return`audio ${r.length>1?`${d+1}: `:""}${m.codec??"pcm"} ${m.channels??"?"}ch${f?` (${f})`:""} ${m.rate??"?"} Hz ${m.bit_depth??"?"}-bit`}).join(`
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as m,b as l}from"./chunk-DKGGJM6Z.js";import{Ea as u,Ga as n,Z as c,r as s}from"./chunk-C5IX63YF.js";async function g(r){await n();let e=c(r);return e==="null"?null:JSON.parse(e)}async function d(r){await n();let e;try{e=s(r)}catch{return null}if(e.length<8)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),a=t.getUint32(0,!0),i=t.getUint32(4,!0),o=a*i*4;return e.length<8+o?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}async function y(r,e=8){await n();let t=l(u,"decode_exr_preview");if(!t)return d(r);try{return m(t(r,e))}catch{return null}}export{g as a,d as b,y as c};
3
+ import{a as m,b as l}from"./chunk-DKGGJM6Z.js";import{Fa as u,Ha as n,Z as c,r as s}from"./chunk-RJ6JA2LZ.js";async function g(r){await n();let e=c(r);return e==="null"?null:JSON.parse(e)}async function d(r){await n();let e;try{e=s(r)}catch{return null}if(e.length<8)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),a=t.getUint32(0,!0),i=t.getUint32(4,!0),o=a*i*4;return e.length<8+o?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}async function y(r,e=8){await n();let t=l(u,"decode_exr_preview");if(!t)return d(r);try{return m(t(r,e))}catch{return null}}export{g as a,d as b,y as c};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{V as ve,c as me}from"./chunk-BL6L5ZBP.js";import{b as ke,f as xe}from"./chunk-NU3X7P4N.js";import{b as ce}from"./chunk-5RSNFPED.js";import{a as ae}from"./chunk-3OCQA33E.js";function Q(e,n,t,i,s){let r=1-s;return r*r*r*e+3*r*r*s*n+3*r*s*s*t+s*s*s*i}function je(e,n,t){let i=0,s=1;for(let a=0;a<48;a++){let u=(i+s)/2;Q(n[0],n[1],n[2],n[3],u)<e?i=u:s=u}let r=(i+s)/2;return Q(t[0],t[1],t[2],t[3],r)}var le=e=>!!(e.sOutX||e.sOutY||e.sInX||e.sInY);function we(e){return e.some(n=>le(n)||n.interp==="bezier")}var $e=new WeakMap;function He(e,n){let t=$e.get(e);if(t&&t.to===n)return t;let i=e.x,s=e.y,r=n.x,a=n.y,u,f,m,l;le(e)||le(n)?(u=i+(e.sOutX??0),f=s+(e.sOutY??0),m=r+(n.sInX??0),l=a+(n.sInY??0)):(u=i+(r-i)/3,f=s+(a-s)/3,m=r-(r-i)/3,l=a-(a-s)/3);let p=[0],g=i,y=s;for(let h=1;h<=256;h++){let k=h/256,x=Q(i,u,m,r,k),w=Q(s,f,l,a,k);p.push(p[p.length-1]+Math.hypot(x-g,w-y)),g=x,y=w}let v={to:n,arc:p,ctrl:[i,u,m,r,s,f,l,a]};return $e.set(e,v),v}function Se(e,n,t){if(!e.length)return[0,0];let i=e[0],s=e[e.length-1];if(n<=i.time)return[i.x,i.y];if(n>=s.time)return[s.x,s.y];for(let r=0;r<e.length-1;r++){let a=e[r],u=e[r+1];if(!(n>=a.time&&n<u.time))continue;if(a.interp==="hold")return[a.x,a.y];let f=u.time-a.time;if(f<=0)return[u.x,u.y];let m=f/(t||24),{arc:l,ctrl:p}=He(a,u),g=l[l.length-1];if(!(g>1e-12))return[a.x,a.y];let y=m>0?g/m:0,v=a.interp==="bezier"&&a.outSpeed!=null?a.outSpeed:y,h=a.interp==="bezier"&&a.outInfluence!=null?a.outInfluence:1/3,k=u.interp==="bezier"&&u.inSpeed!=null?u.inSpeed:y,x=u.interp==="bezier"&&u.inInfluence!=null?u.inInfluence:1/3,w=1/6,A=(b,M)=>Math.abs(b-M)<1e-9,z=v===0&&A(h,1/3),B=k===0&&A(x,1/3);A(h,w)&&(v=y,h=B?.5:1/3),A(x,w)&&(k=y,x=z?.5:1/3);let j=(n-a.time)/(t||24),S=Math.min(Math.max(je(j,[0,h*m,m-x*m,m],[0,v*h*m,g-k*x*m,g]),0),g),I=1,Z=256;for(;I<Z;){let b=I+Z>>1;l[b]<S?I=b+1:Z=b}let X=l[I-1],c=l[I],_=c>X?(S-X)/(c-X):0,o=(I-1+_)/256;return[Q(p[0],p[1],p[2],p[3],o),Q(p[4],p[5],p[6],p[7],o)]}return[s.x,s.y]}function Me(e,n){if((n==="flip_horizontal"?e.flip_horizontal:e.flip_vertical)===!0)return!0;let i=e.effects;return Array.isArray(i)?i.some(s=>{let r=s;return r?.kind===n&&r.enabled!==!1}):!1}function L(e,n){return typeof e=="number"&&Number.isFinite(e)?e:Array.isArray(e)&&typeof e[n]=="number"?e[n]:null}function Ge(e,n,t,i,s){let r;Array.isArray(e.value)&&Array.isArray(n.value)?r=Math.hypot((L(n.value,0)??0)-(L(e.value,0)??0),(L(n.value,1)??0)-(L(e.value,1)??0)):r=(L(n.value,0)??0)-(L(e.value,0)??0);let a=i/t;if(r===0||!(s>0))return a;let u=k=>{let x=typeof k?.x=="number"?k.x:null,w=typeof k?.y=="number"?k.y:null;if(x===null||w===null)return null;let A=Math.min(Math.max(w,0),1)*t;return{dx:A,dy:x/s/r*A}},f=u(e.tout)??{dx:t/3,dy:t/3/t},m=u(n.tin)??{dx:t/3,dy:t/3/t},l=Math.min(Math.max(f.dx,0),t),p=f.dy,g=t-Math.min(Math.max(m.dx,0),t),y=1-m.dy,v=(k,x,w,A)=>{let z=1-A;return 3*k*A*z*z+3*x*A*A*z+w*A*A*A},h=a;for(let k=0;k<8;k++){let x=v(l,g,t,h)-i,w=1-h,A=3*(l*(w*w-2*h*w)+g*(2*h*w-h*h)+t*h*h);if(Math.abs(A)<1e-9)break;let z=h-x/A;if(!(z>=0&&z<=1))break;if(Math.abs(z-h)<1e-7){h=z;break}h=z}if(Math.abs(v(l,g,t,h)-i)>t*1e-4){let k=0,x=1;for(let w=0;w<40;w++)h=(k+x)/2,v(l,g,t,h)<i?k=h:x=h}return v(p,y,1,h)}function De(e,n,t,i=0,s=0){let a=(e.keyframes??[]).filter(m=>m.parameter_path===n&&typeof m.time?.value=="number").map(m=>({time:m.time.value,value:m.value,interp:m.interp??"linear",tin:m.tangent_in,tout:m.tangent_out,drt:!!m.raw_extraction?.drt_tangent})).sort((m,l)=>m.time-l.time);if(!a.length)return;let u=L(a[0].value,i)??0,f=L(a[a.length-1].value,i)??0;if(t<=a[0].time)return u;if(t>=a[a.length-1].time)return f;for(let m=0;m<a.length-1;m++){let l=a[m],p=a[m+1];if(t>=l.time&&t<=p.time){let g=L(l.value,i)??0,y=L(p.value,i)??0;if(l.interp==="hold")return g;let v=p.time-l.time||1,h=(l.tout||p.tin)&&!l.drt&&!p.drt?Ge(l,p,v,t-l.time,s):(t-l.time)/v;return g+(y-g)*h}}return f}function Ue(e){let n=e.keyframes??[];for(let t of n){if(t.parameter_path==="speed")continue;let i=t.time?.rate;if(typeof i=="number"&&i>0)return i}}function Te(e){let n=e.speed;return typeof n=="number"&&Number.isFinite(n)?Math.abs(n)/100:1}function Qe(e){let n=e,t=n.raw_extraction??void 0,i=f=>{let m=t?.[f];return typeof m=="number"&&Number.isFinite(m)?m:void 0};if(!(n.is_reinterpreted===!0||t?.isReinterpreted===!0))return 1;let r=n.original_fps??i("originalFps"),a=n.interpreted_fps??i("reinterpretedFps");if(r!=null&&a!=null&&r>0&&a>0)return a/r;let u=i("reinterpretationSpeedAdjustment");return u!=null&&u>0?u/100:1}function Ae(e,n){let i=(e.keyframes??[]).filter(a=>a.parameter_path==="speed"&&typeof a.time?.value=="number"&&typeof a.value=="number").map(a=>({x:a.time.value,y:a.value,tan:Array.isArray(a.raw_extraction?.drtNativeTangent)?a.raw_extraction.drtNativeTangent:null})).sort((a,u)=>a.x-u.x);if(i.length<2)return null;let s=(a,u)=>{let f=i[a].tan;if(f&&f.length>=4){if(u==="in"&&f[0])return f[1]/f[0];if(u==="out"&&f[2])return f[3]/f[2]}let m=u==="out"?Math.min(a+1,i.length-1):Math.max(a-1,0),l=Math.min(a,m),p=Math.max(a,m),g=i[p].x-i[l].x;return g>0?(i[p].y-i[l].y)/g:0},r=i.length-1;if(n<=i[0].x)return i[0].y+(n-i[0].x)*s(0,"out");if(n>=i[r].x)return i[r].y+(n-i[r].x)*s(r,"in");for(let a=0;a<r;a++){let u=i[a],f=i[a+1];if(n>f.x)continue;let m=f.x-u.x;if(m<=0)return f.y;let l=(n-u.x)/m,p=l*l,g=p*l,y=s(a,"out"),v=s(a+1,"in");return(2*g-3*p+1)*u.y+(g-2*p+l)*m*y+(-2*g+3*p)*f.y+(g-p)*m*v}return i[r].y}function We(e,n,t){let i=e.timeline_range?.start?.value??0,s=e.timeline_range?.start?.rate||t,r=(n-i)/s,a=e.source_range?.start,u=a&&typeof a.value=="number"&&a.rate?a.value/a.rate:0,f=Ae(e,r);if(f!=null)return(u+f)*t;let m=Te(e);if(e.speed_reverse){let l=e.source_range?.duration,p=l&&typeof l.value=="number"&&l.rate?Math.max(0,l.value-1)/l.rate:0;return(u+p-r*m)*t}return(u+r*m)*t}function Je(e,n){let t=e.timeline_range?.start,i=t?.value??0,s=t?.rate||24,r=e.source_range?.start,a=r?.value??0,u=r?.rate||s,f=Ae(e,(n-i)/s);if(f!=null)return a+f*u;let m=Te(e)*Qe(e),l=(n-i)*(u/s)*m;if(e.speed_reverse){let p=e.source_range?.duration?.value??0;return a+Math.max(0,p-1)-l}return a+l}function qe(e){let n=e.keyframes??[],t=[];for(let i of n){if(i.parameter_path!=="position"||typeof i.time?.value!="number")continue;let s=i.value,r=L(s,0),a=L(s,1);if(r==null||a==null)return null;let u=i.raw_extraction?.tangentPs??void 0,f=(m,l)=>{let p=m?.[l];return typeof p=="number"&&Number.isFinite(p)?p:void 0};t.push({time:i.time.value,x:r,y:a,interp:i.interp??"linear",outSpeed:i.tangent_out?.x??void 0,outInfluence:i.tangent_out?.y??void 0,inSpeed:i.tangent_in?.x??void 0,inInfluence:i.tangent_in?.y??void 0,sOutX:f(u,"spatialOutX"),sOutY:f(u,"spatialOutY"),sInX:f(u,"spatialInX"),sInY:f(u,"spatialInY")})}return t.length<2?null:(t.sort((i,s)=>i.time-s.time),we(t)?t:null)}function ze(e,n){let t=Ue(e)??e.timeline_range?.start?.rate??24,i=We(e,n,t),s=!1,r=(m,l=0)=>{let p=De(e,m,i,l,t);return p!==void 0&&(s=!0),p},a=m=>typeof m=="number"?m:null,u=qe(e);u&&(s=!0);let f=u?Se(u,i,t):null;return{scale:r("scale")??a(e.scale),scaleX:r("scale.x")??a(e.scale_x),scaleY:r("scale.y")??a(e.scale_y),posX:f?f[0]:r("position",0)??r("position.x")??a(e.position_x)??0,posY:f?f[1]:r("position",1)??r("position.y")??a(e.position_y)??0,rotation:r("rotation")??a(e.rotation)??0,anchorX:r("anchor",0)??r("anchor.x")??a(e.anchor_x)??0,anchorY:r("anchor",1)??r("anchor.y")??a(e.anchor_y)??0,opacity:r("opacity")??a(e.opacity),cropL:r("crop.left")??a(e.crop_left)??0,cropR:r("crop.right")??a(e.crop_right)??0,cropT:r("crop.top")??a(e.crop_top)??0,cropB:r("crop.bottom")??a(e.crop_bottom)??0,flipH:Me(e,"flip_horizontal"),flipV:Me(e,"flip_vertical"),animated:s}}function Ie(e,n){return Math.floor(Je(e,n)+1e-9)}var fe={strict:{tolerance_px:1,min_frames:1,gap_frames:0,black_threshold:16},standard:{tolerance_px:2,min_frames:2,gap_frames:1,black_threshold:10},relaxed:{tolerance_px:6,min_frames:4,gap_frames:3,black_threshold:6}},pe="strict",Re={tolerance_px:[0,512],min_frames:[1,600],gap_frames:[0,600],black_threshold:[0,255]};function Fe(e,n={}){let t=(e??pe).trim().toLowerCase(),i=fe[t]??fe[pe],s=fe[t]?t:t==="custom"?"custom":pe,r={...i};for(let a of Object.keys(Re)){let u=n[a];if(u===void 0||!Number.isFinite(Number(u)))continue;let[f,m]=Re[a],l=Math.max(f,Math.min(m,Math.round(Number(u))));l!==r[a]&&(s="custom"),r[a]=l}return{...r,preset:s}}function re(e,n){let t=Number(e),i=Number(n);return!Number.isFinite(t)||!Number.isFinite(i)?!1:t>0&&t>=i}function en(e,n,t){return!(e>0)||!(n>0)||!(t>0)?!1:Math.abs(n/t-e)/e>=.02}function nn(e,n,t,i,s){let r=Math.max(2,Number(s)||0);return Math.abs(e-n)<=r&&Math.abs(t-i)<=r}function rn(e,n,t,i,s,r){return!s||!(s.top>0||s.bottom>0||s.left>0||s.right>0)?!1:Math.abs(e-s.top)<=r&&Math.abs(n-s.bottom)<=r&&Math.abs(t-s.left)<=r&&Math.abs(i-s.right)<=r}var Oe=[["bt","ct"],["bb","cb"],["bl","cl"],["br","cr"]],se=e=>Math.max(0,Math.trunc(Number(e)||0)),ie=e=>Math.max(0,Math.min(1,Number(e)||0));function tn(e,n,t,i,s,r={}){let a=r.tolerance_px??4;i=Math.max(1,Math.trunc(i)),s=Math.max(1,Math.trunc(s));let u=[];for(let f of e??[]){let m=Math.trunc(Number(f.pts)||0),l=se(f.bt),p=se(f.bb),g=se(f.bl),y=se(f.br);if(!re(Math.max(l,p,g,y),a)||rn(l,p,g,y,r.declared_blanking,a))continue;let v=Number(r.expected_aspect_ratio)||0;if(v>0){let x=Math.max(1,i-g-y),w=Math.max(1,s-l-p),A=g<=a&&y<=a,z=l<=a&&p<=a;if((A||z)&&en(v,i,s)&&nn(l,p,g,y,a)&&Math.abs(x/w-v)/v<.02)continue}let h=t+m,k;for(let x of n??[])x.start<=h&&h<x.end&&(!k||x.track>k.track)&&(k=x);k&&u.push({frame_abs:h,bt:l,bb:p,bl:g,br:y,ct:ie(f.ct),cb:ie(f.cb),cl:ie(f.cl),cr:ie(f.cr),source:f.source??"pixels",clip:k})}return u.sort((f,m)=>f.frame_abs-m.frame_abs)}function an(e,n){let t=[];return re(e.bt,n)&&t.push("Top"),re(e.bb,n)&&t.push("Bottom"),re(e.bl,n)&&t.push("Left"),re(e.br,n)&&t.push("Right"),t}function Ce(e,n,t,i,s,r={}){let a=Math.max(1,Math.trunc(r.min_frames??1)),u=Math.max(0,Math.trunc(r.gap_frames??0)),f=r.tolerance_px??4,m=[],l;for(let p of tn(e,n,t,i,s,r)){(!l||l.clip!==p.clip||p.frame_abs-l.end_frame-1>u)&&(l={clip:p.clip,start_frame:p.frame_abs,end_frame:p.frame_abs,frame_count:0,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},sources:new Set},m.push(l)),l.end_frame=p.frame_abs,l.frame_count++,l.sources.add(p.source);for(let[g,y]of Oe)p[g]>=l.measured[g]&&(l.measured[g]=p[g],l.coverage[y]=p[y])}return m.filter(p=>p.frame_count>=a).map(p=>({...p,duration_frames:p.end_frame-p.start_frame+1,sources:[...p.sources].sort(),zones:an(p.measured,f)}))}function bn(e){let n=new Map;for(let i of e){let s=n.get(i.clip.id);s||(s={clip:i.clip,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},frames:0,first_frame_abs:i.start_frame,zones:[],sources:[],ranges:[]},n.set(i.clip.id,s)),s.frames+=i.frame_count,s.first_frame_abs=Math.min(s.first_frame_abs,i.start_frame);for(let[r,a]of Oe)i.measured[r]>=s.measured[r]&&(s.measured[r]=i.measured[r],s.coverage[a]=i.coverage[a]);s.sources=[...new Set([...s.sources,...i.sources])].sort(),s.ranges.push(i)}let t=["Top","Bottom","Left","Right"];return[...n.values()].map(i=>{let s=new Set(i.ranges.flatMap(r=>r.zones));return{...i,zones:t.filter(r=>s.has(r)),ranges:i.ranges.sort((r,a)=>r.start_frame-a.start_frame)}}).sort((i,s)=>i.clip.start-s.clip.start)}function _n(e,n=1){let t=Math.max(0,Math.trunc(n)),i=[];for(let s of[...e].sort((r,a)=>r.frame-a.frame)){let r=i.at(-1);if(r&&s.frame-r.end_frame<=t+1){r.end_frame=Math.max(r.end_frame,s.frame),r.frames++,r.darkest=Math.min(r.darkest,s.avg);continue}i.push({start_frame:s.frame,end_frame:s.frame,duration_frames:1,frames:1,darkest:s.avg})}for(let s of i)s.duration_frames=s.end_frame-s.start_frame+1;return i}function ge(e,n){let t=n?e.timelines.find(i=>i.id===n||i.name===n):e.timelines.find(i=>i.kind==="primary")??e.timelines[0];if(!t)throw new Error(n?`no timeline ${n} in this session`:"this session has no timeline");if(!t.resolution_w||!t.resolution_h)throw new Error(`${t.name}: the timeline has no raster (resolution) in the session`);return t}var sn=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,W=(e,n)=>ke((e.start_frame??0)+n,sn(e),!!e.is_drop_frame),on=e=>e.split(/[\\/]/).pop()??e,te=e=>e.tracks.filter(n=>n.kind==="Video").sort((n,t)=>n.track_index-t.track_index),K=e=>{let n=e.timeline_range.start.value;return[n,n+e.timeline_range.duration.value]},oe=e=>e.items.filter(n=>n.kind==="clip");function ee(e,n){let t=e.media_references.find(u=>u.id===n.media_reference_id),i=t?.local_path??t?.target_url?.replace(/^file:\/\//,"")??null,s=t?.source_resolution_w??0,r=t?.source_resolution_h??0,a=t?.source_pixel_aspect||1;return{path:i,w:s*a,h:r}}var q=(e,n)=>ze(e,n),be=(e,n)=>Ie(e,n);function Ne(e,n,t,i){if(!(t>0&&i>0))return[e,n];let s=Math.min(e/t,n/i);return[t*s,i*s]}function Le(e,n,t){let i=n-e,s=Math.max(1,Math.min(t,i));return[...new Set(Array.from({length:s},(r,a)=>e+Math.min(i-1,Math.floor((a+.5)*i/s))))]}var un=["fit","fill","crop","stretch"];function Ze(e,n,t){if(t)return t;let i=e.reframe_fit??n.mismatch_policy??"fit";return i==="none"?"crop":un.includes(i)?i:"fit"}function Ve(e,n,t,i,s){if(!(e>0&&n>0)||s==="fit")return[1,1];let r=t/e,a=i/n,u=[r,r],f=[a,a],m=r<=a?u:f,l=s==="crop"?[1,1]:s==="fill"?r>a?u:f:[r,a];return[l[0]/m[0],l[1]/m[1]]}var J=(e,n)=>Math.round(e*10**n)/10**n||0;function _e(e,n,t,i=[1,1]){return{Pan:J(e.position_x*n/i[0],3),Tilt:J(-e.position_y*t/i[1],3),ZoomX:J(e.scale_x/100/i[0],5),ZoomY:J(e.scale_y/100/i[1],5),RotationAngle:J(-e.rotation,3),FlipX:e.flip_h,FlipY:e.flip_v}}var Ke=e=>({scale_x:e.scaleX??e.scale??100,scale_y:e.scaleY??e.scale??100,position_x:e.posX,position_y:e.posY,rotation:e.rotation,flip_h:e.flipH,flip_v:e.flipV}),Ee=e=>(e.scale??100)===100&&(e.scaleX??100)===100&&(e.scaleY??100)===100&&!e.posX&&!e.posY&&!e.rotation&&!e.cropL&&!e.cropR&&!e.cropT&&!e.cropB&&!e.flipH&&!e.flipV,Sn=["edit","input","node"];function Be(e){let n=e.node,t=typeof n=="object"&&n?n:{layer:e.layer??1,node:n};return{...t.node!==void 0&&t.node!==""?{node:t.node}:{},...t.layer&&t.layer!==1?{layer:t.layer}:{}}}var cn={aligned:"Green",animated:"Yellow",no_match:"Red",refused:"Red"};async function mn(e,n){let t=n.offline_reference,i=me(n),s=i,r=Math.max(...n.tracks.flatMap(h=>h.items.map(k=>k.timeline_range.start.value+k.timeline_range.duration.value)),0),a=h=>({kind:"Video",track_index:Math.max(0,...te(n).map(k=>k.track_index))+1,name:"OFFLINE REFERENCE",enabled:!0,items:h});if(t?.session_id){let{getSession:h}=await import("./store-ZHXLQCGN.js"),k=(await h(t.session_id)).session,x=k.timelines.find(S=>S.kind==="primary")??k.timelines[0],w=(n.start_frame??0)+(t.frame_offset??0)-(x.start_frame??0),A=te(x).filter(S=>S.enabled!==!1).flatMap(S=>S.items.filter(I=>I.kind==="clip"&&I.enabled!==!1&&I.media_reference_id).map(I=>({i:I,top:S.track_index}))),z=[...new Set(A.flatMap(({i:S})=>[S.timeline_range.start.value,S.timeline_range.start.value+S.timeline_range.duration.value]))].sort((S,I)=>S-I),B=[];for(let S=0;S+1<z.length;S++){let[I,Z]=[z[S],z[S+1]],X=A.filter(({i:R})=>R.timeline_range.start.value<=I&&I<R.timeline_range.start.value+R.timeline_range.duration.value).sort((R,O)=>O.top-R.top)[0],[c,_]=[Math.max(0,I-w),Math.min(r,Z-w)];if(!X||_<=c)continue;let o=X.i,b=B.at(-1);if(b&&b.from===o.id&&b.timeline_range.start.value+b.timeline_range.duration.value===c){b.timeline_range.duration.value+=_-c,b.source_range.duration.value+=_-c;continue}let{id:M,timeline_range:$,source_range:d,media_reference_id:C,keyframes:E,...T}=o;B.push({...T,id:`offline-ref-${B.length}`,from:o.id,kind:"clip",enabled:!0,media_reference_id:`offref:${C}`,timeline_range:{start:{value:c,rate:s},duration:{value:_-c,rate:s}},source_range:{start:{value:d.start.value+(c+w-o.timeline_range.start.value),rate:d.start.rate},duration:{value:_-c,rate:d.start.rate}}})}if(!B.length)throw new ae("not_found",`the offline reference timeline "${x.name}" has no picture over this timeline`);let j=new Set(B.map(S=>String(S.media_reference_id).slice(7)));return{lane:a(B),media:k.media_references.filter(S=>j.has(S.id)).map(S=>({...S,id:`offref:${S.id}`})),name:`timeline ${x.name}`}}let u=t?.media_reference_id?e.media_references.find(h=>h.id===t.media_reference_id):void 0,f=u?.local_path??u?.target_url?.replace(/^file:\/\//,"");if(!u||!f)throw new ae("not_found","this timeline has no offline reference linked in Resolve (Timeline \u203A Link Offline Reference Clip): a movie or another timeline");let{probeMedia:m}=await import("./media-7AUNRKHF.js"),l=await m(f),p=l.source_timecode?xe(l.source_timecode,i,null):0,g=l.available_range?.duration?.value??l.declared_duration?.value??null,y=(n.start_frame??0)+(t.frame_offset??0)-p;g!=null&&(y>=g||y+r<=0)&&(y=t.frame_offset??0);let v=g!=null?Math.max(1,Math.min(r,g-y)):r;return{lane:a([{id:"offline-reference",kind:"clip",name:u.name??"offline reference",enabled:!0,media_reference_id:u.id,timeline_range:{start:{value:0,rate:s},duration:{value:v,rate:s}},source_range:{start:{value:y,rate:s},duration:{value:v,rate:s}}}]),media:[],name:u.name??on(f)}}async function Mn(e,n,t,i){if(n.reference_track!=="offline")return await Pe(e,n,t,i);let s=ge(e,n.timeline_id),{lane:r,media:a,name:u}=await mn(e,s);s.tracks.push(r),e.media_references.push(...a);try{return{...await Pe(e,{...n,reference_track:te(s).length,reference_label:"the offline reference"},t,i),reference:`the offline reference (${u})`}}finally{s.tracks.splice(s.tracks.indexOf(r),1),e.media_references=e.media_references.filter(f=>!a.includes(f))}}async function Pe(e,n,t,i){let s=ge(e,n.timeline_id),r=s.resolution_w,a=s.resolution_h,u=te(s),f=u.findIndex(c=>/\b(ref|reference|offline)\b/i.test(String(c.name??""))),m=n.reference_track||(f>=0?f+1:u.length),l=u[m-1];if(!l)throw new Error(`no video track V${m} (the timeline has ${u.length})`);if(n.tracks?.includes(m))throw new ae("invalid_args",`the track to align cannot be the reference track (V${m})`);let p=(n.tracks?.length?n.tracks:u.map((c,_)=>_+1)).filter(c=>c!==m);for(let c of p)if(!u[c-1])throw new Error(`no video track V${c} (the timeline has ${u.length})`);let g=n.input_scaling??"fit",y=n.sizing_target??"edit",v=600,h=(c,_)=>{let o=Math.max(1,_-c);if(n.samples==="ends")return[...new Set([0,.25,.5,.75,1].map($=>c+Math.round($*(Math.max(c,_-1)-c))))];let b=(n.samples??"half")==="half"&&!n.step?Math.max(1,Math.round(me(s)/2)):n.step,M=n.samples==="all"?Math.max(1,Math.ceil(o/v)):b?Math.max(1,Math.floor(b),Math.ceil(o/v)):0;if(M){let $=[];for(let d=c;d<_;d+=M)$.push(d);return $.at(-1)!==_-1&&$.push(_-1),$}return Le(c,_,Math.max(1,Math.min(v,Math.floor(Number(n.samples))||1)))},k=Number(s.start_frame??0),x=[],w=[],A=oe(l),z=n.scope??"all",B=new Set(n.picks??[]);if(z==="selected"&&!B.size)throw new Error("no clips selected: select clips in the timeline, or align the whole timeline");for(let c of p)for(let _ of oe(u[c-1])){let[o,b]=K(_);if(z==="playhead"&&!(o<=(n.at??-1)&&(n.at??-1)<b)||z==="selected"&&!B.has(`${c}:${o}`))continue;let M={item_id:_.id,name:_.name??_.id,track:c,start:o,end:b,record_tc:W(s,o),verdict:"refused",confidence:null,samples:[]};x.push(M);let $=N=>{M.reason=N};if(_.enabled===!1){$("disabled");continue}let d,C=0,E=0;for(let N of A){let[Y,D]=K(N),P=Math.max(o,Y),F=Math.min(b,D);F-P>E-C&&(d=N,C=P,E=F)}if(!d){if(n.reference_label){$(`${n.reference_label} does not cover it (${W(s,o)}\u2013${W(s,b)}): it ends before this clip`);continue}let N=l.items.find(Y=>{let[D,P]=K(Y);return Y.kind!=="clip"&&Y.kind!=="gap"&&Math.min(b,P)>Math.max(o,D)});$(N?`V${m} has ${/compound|stack|timeline/i.test(String(N.kind))?"a compound clip or nested timeline":`a ${N.kind}`} over it, not a movie clip: Align reads a media file there (decompose it, or use Offline ref)`:A.length?`nothing on V${m} over it (${W(s,o)}\u2013${W(s,b)}): the reference does not cover this clip`:`V${m} has no movie clips: pick the track the reference is on, or Offline ref`);continue}let T=ee(e,d),R=ee(e,_);if(!T.path){$(`the reference clip ${d.name??d.id} is not linked (timeline_relink first)`);continue}if(!R.path){$("not linked (timeline_relink first)");continue}let O=h(C,E);if(O.some(N=>!Ee(q(d,N)))){$(`the reference clip ${d.name??d.id} is itself resized; the fit is against its raw picture`);continue}if(T.w>0&&T.h>0&&Math.abs(T.w/T.h-r/a)>.01*(r/a)){$(`the reference ${T.w}x${T.h} does not fill the ${r}x${a} frame`);continue}let ne=N=>N.map(Y=>({ref:T.path,refFrame:be(d,Y),src:R.path,srcFrame:be(_,Y)})),G=Array.from({length:E-C},(N,Y)=>C+Y),H=q(_,o);w.push({row:M,item:_,recs:O,every:G,ask:{pairs:ne(O),every:ne(G),every_t:G.map(N=>N-o),edit:Ke(H),edit_identity:Ee(H),edit_animated:!!H.animated,anchor_off:!!(H.anchorX||H.anchorY),...n.inputs?.get(`${c}:${o+k}`)?.length?{input:n.inputs.get(`${c}:${o+k}`)}:{}}})}let j=w.length?await ce({op:"reframe",items:w.map(c=>c.ask),out:[r,a],target:y},t,i):{items:[],offsets:[]},S=j.offsets;j.items.forEach((c,_)=>{let{row:o,item:b,recs:M,every:$,ask:d}=w[_],C=c.measured==="every"?$:M,E=c.measured==="every"?d.every:d.pairs,T=(({w:R,h:O})=>Ve(R,O,r,a,Ze(b,s,n.input_scaling)))(ee(e,b));o.samples=c.scores.map((R,O)=>({record:C[c.at[O]],ref_frame:E[c.at[O]].refFrame,src_frame:E[c.at[O]].srcFrame,score:R})),Object.assign(o,{verdict:c.verdict,confidence:c.confidence,...c.reason?{reason:c.reason}:{},...c.label?{label:c.label}:{},...c.unchanged?{unchanged:!0}:{},...c.grade_sizing?{grade_sizing:c.grade_sizing}:{}}),c.transform&&(o.transform=c.transform,o.properties=_e(c.edit_transform??c.transform,r,a,T)),c.keys?.length&&(o.keys=c.keys.map(R=>({record:C[c.at[R.j]],transform:R.transform,properties:_e(R.transform,r,a,T),confidence:R.confidence}))),c.grade_keys?.length&&(o.grade_keys=c.grade_keys.map(({shape:R,...O})=>R?.kind==="resolve_dissolve"?{...O,ease_in:R.start,ease_out:R.end}:O),o.grade_keys[0].t>0&&o.grade_keys.unshift({...o.grade_keys[0],t:0,ease_in:void 0,ease_out:void 0})),c.edit_keys?.length&&(o.edit_keys=c.edit_keys[0].t>0?[{...c.edit_keys[0],t:0,shape:void 0},...c.edit_keys]:c.edit_keys)});let I=[];for(let c of x){let _={track:c.track,start:c.start};if(c.verdict==="aligned"&&y==="edit"&&!c.unchanged){let o=c.properties;I.push({op:"properties",item:_,set:{...o.ZoomX!==o.ZoomY?{ZoomGang:!1}:{},...o}})}if(c.verdict==="animated"&&c.edit_keys&&I.push({op:"edit_keys",item:_,keys:c.edit_keys}),c.verdict==="animated"&&c.grade_keys&&I.push({op:"grade_sizing",item:_,target:y==="node"?"node":"input",keys:c.grade_keys,...y==="node"?Be(n):{}}),c.verdict==="aligned"&&c.grade_sizing&&!c.unchanged&&I.push({op:"grade_sizing",item:_,target:y,...c.grade_sizing,...y==="node"?Be(n):{}}),n.markers??!0){let o={aligned:"Aligned",animated:"Animated",no_match:"No match",refused:"Not aligned"}[c.verdict],b=[c.label,c.confidence!=null?`confidence ${c.confidence}`:"",c.reason].filter(Boolean).join(" \xB7 ");I.push({op:"marker_add",frame:c.start,color:cn[c.verdict],name:`${o}: ${c.name}`,note:b,data:"ConformTools:align"})}}let Z;if(n.apply_session){Z=0;for(let c of x.filter(_=>_.verdict==="aligned")){let _=c.transform;ve(e,"transform",{timeline_id:s.id,item_id:c.item_id,scale:_.scale_x,position_x:_.position_x,position_y:_.position_y,rotation:_.rotation});let o=s.tracks.flatMap(b=>b.items).find(b=>b.id===c.item_id);Math.abs(_.scale_x-_.scale_y)>.001&&(o.scale_x=_.scale_x,o.scale_y=_.scale_y),_.flip_h?o.flip_horizontal=!0:delete o.flip_horizontal,_.flip_v?o.flip_vertical=!0:delete o.flip_vertical,Z++}}let X={aligned:0,animated:0,no_match:0,refused:0};for(let c of x)X[c.verdict]++;return{timeline:s.name??s.id,raster:[r,a],reference_track:m,rows:x,counts:X,ops:I,...Z!=null?{applied:Z}:{},input_scaling:g,sizing_target:y,...S.length?{offsets:S}:{}}}function Tn(e){let n=e.counts,t=`${e.timeline} (${e.raster.join("x")}): ${n.aligned} aligned, ${n.animated} animated, ${n.no_match} no match, ${n.refused} not aligned \u2014 against ${e.reference??`V${e.reference_track}`}${e.input_scaling!=="fit"?` (Resolve units for input scaling "${e.input_scaling}")`:""}${e.sizing_target!=="edit"?`; written as Color-page ${e.sizing_target==="input"?"Input Sizing":"node Sizing"} on top of each clip's own edit transform`:""}${e.sizing_target==="edit"&&n.animated?`; the ${n.animated} moving clip(s) get Edit-page keyframes on a copy of the timeline, "${e.timeline} ALIGNED" (Resolve cannot keyframe the Edit page from a script; the copy carries every grade and setting)`:""}${e.applied!=null?`; ${e.applied} transform(s) written into the session`:""}`,i=r=>{let a=r.properties,u=r.grade_sizing,f=u?` \u2192 ${e.sizing_target} sizing Zoom ${u.zoom}${u.height!==1?` Height ${u.height}`:""} Pan ${u.pan} Tilt ${u.tilt} Rotate ${u.rotation}${u.flip_x?" FlipH":""}${u.flip_y?" FlipV":""}`:a?` \u2192 Pan ${a.Pan} Tilt ${a.Tilt} Zoom ${a.ZoomX}${a.ZoomY!==a.ZoomX?`/${a.ZoomY}`:""} Rot ${a.RotationAngle}${a.FlipX?" FlipX":""}${a.FlipY?" FlipY":""}`:"",m=r.grade_keys?.length?` \u2192 ${r.grade_keys.length} keyframes (${e.sizing_target==="node"?"node":"Input"} Sizing)`:r.edit_keys?.length?` \u2192 ${r.edit_keys.length} Edit-page keyframes`:"";return` V${r.track} ${r.record_tc} ${r.name}: ${r.verdict.toUpperCase()}${r.label?` (${r.label})`:""}${f}${m}${r.confidence!=null?`, confidence ${r.confidence}`:""}${r.reason?` \u2014 ${r.reason}`:""}`},s=(e.offsets??[]).map(r=>` the reference differs from the ${r.raster} online by ${r.label} on ${r.clips} of ${r.of} clips: a render / decode difference, not sizing \u2014 taken out of every clip, never written`);return[t,...s,...e.rows.map(i),`host_apply ops ready: ${e.ops.filter(r=>r.op==="properties"||r.op==="grade_sizing").length} ${e.sizing_target==="edit"?"properties":"grade_sizing"}, ${e.ops.filter(r=>r.op==="marker_add").length} markers (data "ConformTools:align")`].join(`
3
+ import{V as ve,c as me}from"./chunk-5WEZRGXG.js";import{b as ke,f as xe}from"./chunk-NU3X7P4N.js";import{b as ce}from"./chunk-NAFLOZER.js";import{a as ae}from"./chunk-PHAMF4JF.js";function Q(e,n,t,i,s){let r=1-s;return r*r*r*e+3*r*r*s*n+3*r*s*s*t+s*s*s*i}function je(e,n,t){let i=0,s=1;for(let a=0;a<48;a++){let u=(i+s)/2;Q(n[0],n[1],n[2],n[3],u)<e?i=u:s=u}let r=(i+s)/2;return Q(t[0],t[1],t[2],t[3],r)}var le=e=>!!(e.sOutX||e.sOutY||e.sInX||e.sInY);function we(e){return e.some(n=>le(n)||n.interp==="bezier")}var $e=new WeakMap;function He(e,n){let t=$e.get(e);if(t&&t.to===n)return t;let i=e.x,s=e.y,r=n.x,a=n.y,u,f,m,l;le(e)||le(n)?(u=i+(e.sOutX??0),f=s+(e.sOutY??0),m=r+(n.sInX??0),l=a+(n.sInY??0)):(u=i+(r-i)/3,f=s+(a-s)/3,m=r-(r-i)/3,l=a-(a-s)/3);let p=[0],g=i,y=s;for(let h=1;h<=256;h++){let k=h/256,x=Q(i,u,m,r,k),w=Q(s,f,l,a,k);p.push(p[p.length-1]+Math.hypot(x-g,w-y)),g=x,y=w}let v={to:n,arc:p,ctrl:[i,u,m,r,s,f,l,a]};return $e.set(e,v),v}function Se(e,n,t){if(!e.length)return[0,0];let i=e[0],s=e[e.length-1];if(n<=i.time)return[i.x,i.y];if(n>=s.time)return[s.x,s.y];for(let r=0;r<e.length-1;r++){let a=e[r],u=e[r+1];if(!(n>=a.time&&n<u.time))continue;if(a.interp==="hold")return[a.x,a.y];let f=u.time-a.time;if(f<=0)return[u.x,u.y];let m=f/(t||24),{arc:l,ctrl:p}=He(a,u),g=l[l.length-1];if(!(g>1e-12))return[a.x,a.y];let y=m>0?g/m:0,v=a.interp==="bezier"&&a.outSpeed!=null?a.outSpeed:y,h=a.interp==="bezier"&&a.outInfluence!=null?a.outInfluence:1/3,k=u.interp==="bezier"&&u.inSpeed!=null?u.inSpeed:y,x=u.interp==="bezier"&&u.inInfluence!=null?u.inInfluence:1/3,w=1/6,A=(b,M)=>Math.abs(b-M)<1e-9,z=v===0&&A(h,1/3),B=k===0&&A(x,1/3);A(h,w)&&(v=y,h=B?.5:1/3),A(x,w)&&(k=y,x=z?.5:1/3);let j=(n-a.time)/(t||24),S=Math.min(Math.max(je(j,[0,h*m,m-x*m,m],[0,v*h*m,g-k*x*m,g]),0),g),I=1,Z=256;for(;I<Z;){let b=I+Z>>1;l[b]<S?I=b+1:Z=b}let X=l[I-1],c=l[I],_=c>X?(S-X)/(c-X):0,o=(I-1+_)/256;return[Q(p[0],p[1],p[2],p[3],o),Q(p[4],p[5],p[6],p[7],o)]}return[s.x,s.y]}function Me(e,n){if((n==="flip_horizontal"?e.flip_horizontal:e.flip_vertical)===!0)return!0;let i=e.effects;return Array.isArray(i)?i.some(s=>{let r=s;return r?.kind===n&&r.enabled!==!1}):!1}function L(e,n){return typeof e=="number"&&Number.isFinite(e)?e:Array.isArray(e)&&typeof e[n]=="number"?e[n]:null}function Ge(e,n,t,i,s){let r;Array.isArray(e.value)&&Array.isArray(n.value)?r=Math.hypot((L(n.value,0)??0)-(L(e.value,0)??0),(L(n.value,1)??0)-(L(e.value,1)??0)):r=(L(n.value,0)??0)-(L(e.value,0)??0);let a=i/t;if(r===0||!(s>0))return a;let u=k=>{let x=typeof k?.x=="number"?k.x:null,w=typeof k?.y=="number"?k.y:null;if(x===null||w===null)return null;let A=Math.min(Math.max(w,0),1)*t;return{dx:A,dy:x/s/r*A}},f=u(e.tout)??{dx:t/3,dy:t/3/t},m=u(n.tin)??{dx:t/3,dy:t/3/t},l=Math.min(Math.max(f.dx,0),t),p=f.dy,g=t-Math.min(Math.max(m.dx,0),t),y=1-m.dy,v=(k,x,w,A)=>{let z=1-A;return 3*k*A*z*z+3*x*A*A*z+w*A*A*A},h=a;for(let k=0;k<8;k++){let x=v(l,g,t,h)-i,w=1-h,A=3*(l*(w*w-2*h*w)+g*(2*h*w-h*h)+t*h*h);if(Math.abs(A)<1e-9)break;let z=h-x/A;if(!(z>=0&&z<=1))break;if(Math.abs(z-h)<1e-7){h=z;break}h=z}if(Math.abs(v(l,g,t,h)-i)>t*1e-4){let k=0,x=1;for(let w=0;w<40;w++)h=(k+x)/2,v(l,g,t,h)<i?k=h:x=h}return v(p,y,1,h)}function De(e,n,t,i=0,s=0){let a=(e.keyframes??[]).filter(m=>m.parameter_path===n&&typeof m.time?.value=="number").map(m=>({time:m.time.value,value:m.value,interp:m.interp??"linear",tin:m.tangent_in,tout:m.tangent_out,drt:!!m.raw_extraction?.drt_tangent})).sort((m,l)=>m.time-l.time);if(!a.length)return;let u=L(a[0].value,i)??0,f=L(a[a.length-1].value,i)??0;if(t<=a[0].time)return u;if(t>=a[a.length-1].time)return f;for(let m=0;m<a.length-1;m++){let l=a[m],p=a[m+1];if(t>=l.time&&t<=p.time){let g=L(l.value,i)??0,y=L(p.value,i)??0;if(l.interp==="hold")return g;let v=p.time-l.time||1,h=(l.tout||p.tin)&&!l.drt&&!p.drt?Ge(l,p,v,t-l.time,s):(t-l.time)/v;return g+(y-g)*h}}return f}function Ue(e){let n=e.keyframes??[];for(let t of n){if(t.parameter_path==="speed")continue;let i=t.time?.rate;if(typeof i=="number"&&i>0)return i}}function Te(e){let n=e.speed;return typeof n=="number"&&Number.isFinite(n)?Math.abs(n)/100:1}function Qe(e){let n=e,t=n.raw_extraction??void 0,i=f=>{let m=t?.[f];return typeof m=="number"&&Number.isFinite(m)?m:void 0};if(!(n.is_reinterpreted===!0||t?.isReinterpreted===!0))return 1;let r=n.original_fps??i("originalFps"),a=n.interpreted_fps??i("reinterpretedFps");if(r!=null&&a!=null&&r>0&&a>0)return a/r;let u=i("reinterpretationSpeedAdjustment");return u!=null&&u>0?u/100:1}function Ae(e,n){let i=(e.keyframes??[]).filter(a=>a.parameter_path==="speed"&&typeof a.time?.value=="number"&&typeof a.value=="number").map(a=>({x:a.time.value,y:a.value,tan:Array.isArray(a.raw_extraction?.drtNativeTangent)?a.raw_extraction.drtNativeTangent:null})).sort((a,u)=>a.x-u.x);if(i.length<2)return null;let s=(a,u)=>{let f=i[a].tan;if(f&&f.length>=4){if(u==="in"&&f[0])return f[1]/f[0];if(u==="out"&&f[2])return f[3]/f[2]}let m=u==="out"?Math.min(a+1,i.length-1):Math.max(a-1,0),l=Math.min(a,m),p=Math.max(a,m),g=i[p].x-i[l].x;return g>0?(i[p].y-i[l].y)/g:0},r=i.length-1;if(n<=i[0].x)return i[0].y+(n-i[0].x)*s(0,"out");if(n>=i[r].x)return i[r].y+(n-i[r].x)*s(r,"in");for(let a=0;a<r;a++){let u=i[a],f=i[a+1];if(n>f.x)continue;let m=f.x-u.x;if(m<=0)return f.y;let l=(n-u.x)/m,p=l*l,g=p*l,y=s(a,"out"),v=s(a+1,"in");return(2*g-3*p+1)*u.y+(g-2*p+l)*m*y+(-2*g+3*p)*f.y+(g-p)*m*v}return i[r].y}function We(e,n,t){let i=e.timeline_range?.start?.value??0,s=e.timeline_range?.start?.rate||t,r=(n-i)/s,a=e.source_range?.start,u=a&&typeof a.value=="number"&&a.rate?a.value/a.rate:0,f=Ae(e,r);if(f!=null)return(u+f)*t;let m=Te(e);if(e.speed_reverse){let l=e.source_range?.duration,p=l&&typeof l.value=="number"&&l.rate?Math.max(0,l.value-1)/l.rate:0;return(u+p-r*m)*t}return(u+r*m)*t}function Je(e,n){let t=e.timeline_range?.start,i=t?.value??0,s=t?.rate||24,r=e.source_range?.start,a=r?.value??0,u=r?.rate||s,f=Ae(e,(n-i)/s);if(f!=null)return a+f*u;let m=Te(e)*Qe(e),l=(n-i)*(u/s)*m;if(e.speed_reverse){let p=e.source_range?.duration?.value??0;return a+Math.max(0,p-1)-l}return a+l}function qe(e){let n=e.keyframes??[],t=[];for(let i of n){if(i.parameter_path!=="position"||typeof i.time?.value!="number")continue;let s=i.value,r=L(s,0),a=L(s,1);if(r==null||a==null)return null;let u=i.raw_extraction?.tangentPs??void 0,f=(m,l)=>{let p=m?.[l];return typeof p=="number"&&Number.isFinite(p)?p:void 0};t.push({time:i.time.value,x:r,y:a,interp:i.interp??"linear",outSpeed:i.tangent_out?.x??void 0,outInfluence:i.tangent_out?.y??void 0,inSpeed:i.tangent_in?.x??void 0,inInfluence:i.tangent_in?.y??void 0,sOutX:f(u,"spatialOutX"),sOutY:f(u,"spatialOutY"),sInX:f(u,"spatialInX"),sInY:f(u,"spatialInY")})}return t.length<2?null:(t.sort((i,s)=>i.time-s.time),we(t)?t:null)}function ze(e,n){let t=Ue(e)??e.timeline_range?.start?.rate??24,i=We(e,n,t),s=!1,r=(m,l=0)=>{let p=De(e,m,i,l,t);return p!==void 0&&(s=!0),p},a=m=>typeof m=="number"?m:null,u=qe(e);u&&(s=!0);let f=u?Se(u,i,t):null;return{scale:r("scale")??a(e.scale),scaleX:r("scale.x")??a(e.scale_x),scaleY:r("scale.y")??a(e.scale_y),posX:f?f[0]:r("position",0)??r("position.x")??a(e.position_x)??0,posY:f?f[1]:r("position",1)??r("position.y")??a(e.position_y)??0,rotation:r("rotation")??a(e.rotation)??0,anchorX:r("anchor",0)??r("anchor.x")??a(e.anchor_x)??0,anchorY:r("anchor",1)??r("anchor.y")??a(e.anchor_y)??0,opacity:r("opacity")??a(e.opacity),cropL:r("crop.left")??a(e.crop_left)??0,cropR:r("crop.right")??a(e.crop_right)??0,cropT:r("crop.top")??a(e.crop_top)??0,cropB:r("crop.bottom")??a(e.crop_bottom)??0,flipH:Me(e,"flip_horizontal"),flipV:Me(e,"flip_vertical"),animated:s}}function Ie(e,n){return Math.floor(Je(e,n)+1e-9)}var fe={strict:{tolerance_px:1,min_frames:1,gap_frames:0,black_threshold:16},standard:{tolerance_px:2,min_frames:2,gap_frames:1,black_threshold:10},relaxed:{tolerance_px:6,min_frames:4,gap_frames:3,black_threshold:6}},pe="strict",Re={tolerance_px:[0,512],min_frames:[1,600],gap_frames:[0,600],black_threshold:[0,255]};function Fe(e,n={}){let t=(e??pe).trim().toLowerCase(),i=fe[t]??fe[pe],s=fe[t]?t:t==="custom"?"custom":pe,r={...i};for(let a of Object.keys(Re)){let u=n[a];if(u===void 0||!Number.isFinite(Number(u)))continue;let[f,m]=Re[a],l=Math.max(f,Math.min(m,Math.round(Number(u))));l!==r[a]&&(s="custom"),r[a]=l}return{...r,preset:s}}function re(e,n){let t=Number(e),i=Number(n);return!Number.isFinite(t)||!Number.isFinite(i)?!1:t>0&&t>=i}function en(e,n,t){return!(e>0)||!(n>0)||!(t>0)?!1:Math.abs(n/t-e)/e>=.02}function nn(e,n,t,i,s){let r=Math.max(2,Number(s)||0);return Math.abs(e-n)<=r&&Math.abs(t-i)<=r}function rn(e,n,t,i,s,r){return!s||!(s.top>0||s.bottom>0||s.left>0||s.right>0)?!1:Math.abs(e-s.top)<=r&&Math.abs(n-s.bottom)<=r&&Math.abs(t-s.left)<=r&&Math.abs(i-s.right)<=r}var Oe=[["bt","ct"],["bb","cb"],["bl","cl"],["br","cr"]],se=e=>Math.max(0,Math.trunc(Number(e)||0)),ie=e=>Math.max(0,Math.min(1,Number(e)||0));function tn(e,n,t,i,s,r={}){let a=r.tolerance_px??4;i=Math.max(1,Math.trunc(i)),s=Math.max(1,Math.trunc(s));let u=[];for(let f of e??[]){let m=Math.trunc(Number(f.pts)||0),l=se(f.bt),p=se(f.bb),g=se(f.bl),y=se(f.br);if(!re(Math.max(l,p,g,y),a)||rn(l,p,g,y,r.declared_blanking,a))continue;let v=Number(r.expected_aspect_ratio)||0;if(v>0){let x=Math.max(1,i-g-y),w=Math.max(1,s-l-p),A=g<=a&&y<=a,z=l<=a&&p<=a;if((A||z)&&en(v,i,s)&&nn(l,p,g,y,a)&&Math.abs(x/w-v)/v<.02)continue}let h=t+m,k;for(let x of n??[])x.start<=h&&h<x.end&&(!k||x.track>k.track)&&(k=x);k&&u.push({frame_abs:h,bt:l,bb:p,bl:g,br:y,ct:ie(f.ct),cb:ie(f.cb),cl:ie(f.cl),cr:ie(f.cr),source:f.source??"pixels",clip:k})}return u.sort((f,m)=>f.frame_abs-m.frame_abs)}function an(e,n){let t=[];return re(e.bt,n)&&t.push("Top"),re(e.bb,n)&&t.push("Bottom"),re(e.bl,n)&&t.push("Left"),re(e.br,n)&&t.push("Right"),t}function Ce(e,n,t,i,s,r={}){let a=Math.max(1,Math.trunc(r.min_frames??1)),u=Math.max(0,Math.trunc(r.gap_frames??0)),f=r.tolerance_px??4,m=[],l;for(let p of tn(e,n,t,i,s,r)){(!l||l.clip!==p.clip||p.frame_abs-l.end_frame-1>u)&&(l={clip:p.clip,start_frame:p.frame_abs,end_frame:p.frame_abs,frame_count:0,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},sources:new Set},m.push(l)),l.end_frame=p.frame_abs,l.frame_count++,l.sources.add(p.source);for(let[g,y]of Oe)p[g]>=l.measured[g]&&(l.measured[g]=p[g],l.coverage[y]=p[y])}return m.filter(p=>p.frame_count>=a).map(p=>({...p,duration_frames:p.end_frame-p.start_frame+1,sources:[...p.sources].sort(),zones:an(p.measured,f)}))}function bn(e){let n=new Map;for(let i of e){let s=n.get(i.clip.id);s||(s={clip:i.clip,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},frames:0,first_frame_abs:i.start_frame,zones:[],sources:[],ranges:[]},n.set(i.clip.id,s)),s.frames+=i.frame_count,s.first_frame_abs=Math.min(s.first_frame_abs,i.start_frame);for(let[r,a]of Oe)i.measured[r]>=s.measured[r]&&(s.measured[r]=i.measured[r],s.coverage[a]=i.coverage[a]);s.sources=[...new Set([...s.sources,...i.sources])].sort(),s.ranges.push(i)}let t=["Top","Bottom","Left","Right"];return[...n.values()].map(i=>{let s=new Set(i.ranges.flatMap(r=>r.zones));return{...i,zones:t.filter(r=>s.has(r)),ranges:i.ranges.sort((r,a)=>r.start_frame-a.start_frame)}}).sort((i,s)=>i.clip.start-s.clip.start)}function _n(e,n=1){let t=Math.max(0,Math.trunc(n)),i=[];for(let s of[...e].sort((r,a)=>r.frame-a.frame)){let r=i.at(-1);if(r&&s.frame-r.end_frame<=t+1){r.end_frame=Math.max(r.end_frame,s.frame),r.frames++,r.darkest=Math.min(r.darkest,s.avg);continue}i.push({start_frame:s.frame,end_frame:s.frame,duration_frames:1,frames:1,darkest:s.avg})}for(let s of i)s.duration_frames=s.end_frame-s.start_frame+1;return i}function ge(e,n){let t=n?e.timelines.find(i=>i.id===n||i.name===n):e.timelines.find(i=>i.kind==="primary")??e.timelines[0];if(!t)throw new Error(n?`no timeline ${n} in this session`:"this session has no timeline");if(!t.resolution_w||!t.resolution_h)throw new Error(`${t.name}: the timeline has no raster (resolution) in the session`);return t}var sn=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,W=(e,n)=>ke((e.start_frame??0)+n,sn(e),!!e.is_drop_frame),on=e=>e.split(/[\\/]/).pop()??e,te=e=>e.tracks.filter(n=>n.kind==="Video").sort((n,t)=>n.track_index-t.track_index),K=e=>{let n=e.timeline_range.start.value;return[n,n+e.timeline_range.duration.value]},oe=e=>e.items.filter(n=>n.kind==="clip");function ee(e,n){let t=e.media_references.find(u=>u.id===n.media_reference_id),i=t?.local_path??t?.target_url?.replace(/^file:\/\//,"")??null,s=t?.source_resolution_w??0,r=t?.source_resolution_h??0,a=t?.source_pixel_aspect||1;return{path:i,w:s*a,h:r}}var q=(e,n)=>ze(e,n),be=(e,n)=>Ie(e,n);function Ne(e,n,t,i){if(!(t>0&&i>0))return[e,n];let s=Math.min(e/t,n/i);return[t*s,i*s]}function Le(e,n,t){let i=n-e,s=Math.max(1,Math.min(t,i));return[...new Set(Array.from({length:s},(r,a)=>e+Math.min(i-1,Math.floor((a+.5)*i/s))))]}var un=["fit","fill","crop","stretch"];function Ze(e,n,t){if(t)return t;let i=e.reframe_fit??n.mismatch_policy??"fit";return i==="none"?"crop":un.includes(i)?i:"fit"}function Ve(e,n,t,i,s){if(!(e>0&&n>0)||s==="fit")return[1,1];let r=t/e,a=i/n,u=[r,r],f=[a,a],m=r<=a?u:f,l=s==="crop"?[1,1]:s==="fill"?r>a?u:f:[r,a];return[l[0]/m[0],l[1]/m[1]]}var J=(e,n)=>Math.round(e*10**n)/10**n||0;function _e(e,n,t,i=[1,1]){return{Pan:J(e.position_x*n/i[0],3),Tilt:J(-e.position_y*t/i[1],3),ZoomX:J(e.scale_x/100/i[0],5),ZoomY:J(e.scale_y/100/i[1],5),RotationAngle:J(-e.rotation,3),FlipX:e.flip_h,FlipY:e.flip_v}}var Ke=e=>({scale_x:e.scaleX??e.scale??100,scale_y:e.scaleY??e.scale??100,position_x:e.posX,position_y:e.posY,rotation:e.rotation,flip_h:e.flipH,flip_v:e.flipV}),Ee=e=>(e.scale??100)===100&&(e.scaleX??100)===100&&(e.scaleY??100)===100&&!e.posX&&!e.posY&&!e.rotation&&!e.cropL&&!e.cropR&&!e.cropT&&!e.cropB&&!e.flipH&&!e.flipV,Sn=["edit","input","node"];function Be(e){let n=e.node,t=typeof n=="object"&&n?n:{layer:e.layer??1,node:n};return{...t.node!==void 0&&t.node!==""?{node:t.node}:{},...t.layer&&t.layer!==1?{layer:t.layer}:{}}}var cn={aligned:"Green",animated:"Yellow",no_match:"Red",refused:"Red"};async function mn(e,n){let t=n.offline_reference,i=me(n),s=i,r=Math.max(...n.tracks.flatMap(h=>h.items.map(k=>k.timeline_range.start.value+k.timeline_range.duration.value)),0),a=h=>({kind:"Video",track_index:Math.max(0,...te(n).map(k=>k.track_index))+1,name:"OFFLINE REFERENCE",enabled:!0,items:h});if(t?.session_id){let{getSession:h}=await import("./store-7IOEBOZY.js"),k=(await h(t.session_id)).session,x=k.timelines.find(S=>S.kind==="primary")??k.timelines[0],w=(n.start_frame??0)+(t.frame_offset??0)-(x.start_frame??0),A=te(x).filter(S=>S.enabled!==!1).flatMap(S=>S.items.filter(I=>I.kind==="clip"&&I.enabled!==!1&&I.media_reference_id).map(I=>({i:I,top:S.track_index}))),z=[...new Set(A.flatMap(({i:S})=>[S.timeline_range.start.value,S.timeline_range.start.value+S.timeline_range.duration.value]))].sort((S,I)=>S-I),B=[];for(let S=0;S+1<z.length;S++){let[I,Z]=[z[S],z[S+1]],X=A.filter(({i:R})=>R.timeline_range.start.value<=I&&I<R.timeline_range.start.value+R.timeline_range.duration.value).sort((R,O)=>O.top-R.top)[0],[c,_]=[Math.max(0,I-w),Math.min(r,Z-w)];if(!X||_<=c)continue;let o=X.i,b=B.at(-1);if(b&&b.from===o.id&&b.timeline_range.start.value+b.timeline_range.duration.value===c){b.timeline_range.duration.value+=_-c,b.source_range.duration.value+=_-c;continue}let{id:M,timeline_range:$,source_range:d,media_reference_id:C,keyframes:E,...T}=o;B.push({...T,id:`offline-ref-${B.length}`,from:o.id,kind:"clip",enabled:!0,media_reference_id:`offref:${C}`,timeline_range:{start:{value:c,rate:s},duration:{value:_-c,rate:s}},source_range:{start:{value:d.start.value+(c+w-o.timeline_range.start.value),rate:d.start.rate},duration:{value:_-c,rate:d.start.rate}}})}if(!B.length)throw new ae("not_found",`the offline reference timeline "${x.name}" has no picture over this timeline`);let j=new Set(B.map(S=>String(S.media_reference_id).slice(7)));return{lane:a(B),media:k.media_references.filter(S=>j.has(S.id)).map(S=>({...S,id:`offref:${S.id}`})),name:`timeline ${x.name}`}}let u=t?.media_reference_id?e.media_references.find(h=>h.id===t.media_reference_id):void 0,f=u?.local_path??u?.target_url?.replace(/^file:\/\//,"");if(!u||!f)throw new ae("not_found","this timeline has no offline reference linked in Resolve (Timeline \u203A Link Offline Reference Clip): a movie or another timeline");let{probeMedia:m}=await import("./media-NZYVREUF.js"),l=await m(f),p=l.source_timecode?xe(l.source_timecode,i,null):0,g=l.available_range?.duration?.value??l.declared_duration?.value??null,y=(n.start_frame??0)+(t.frame_offset??0)-p;g!=null&&(y>=g||y+r<=0)&&(y=t.frame_offset??0);let v=g!=null?Math.max(1,Math.min(r,g-y)):r;return{lane:a([{id:"offline-reference",kind:"clip",name:u.name??"offline reference",enabled:!0,media_reference_id:u.id,timeline_range:{start:{value:0,rate:s},duration:{value:v,rate:s}},source_range:{start:{value:y,rate:s},duration:{value:v,rate:s}}}]),media:[],name:u.name??on(f)}}async function Mn(e,n,t,i){if(n.reference_track!=="offline")return await Pe(e,n,t,i);let s=ge(e,n.timeline_id),{lane:r,media:a,name:u}=await mn(e,s);s.tracks.push(r),e.media_references.push(...a);try{return{...await Pe(e,{...n,reference_track:te(s).length,reference_label:"the offline reference"},t,i),reference:`the offline reference (${u})`}}finally{s.tracks.splice(s.tracks.indexOf(r),1),e.media_references=e.media_references.filter(f=>!a.includes(f))}}async function Pe(e,n,t,i){let s=ge(e,n.timeline_id),r=s.resolution_w,a=s.resolution_h,u=te(s),f=u.findIndex(c=>/\b(ref|reference|offline)\b/i.test(String(c.name??""))),m=n.reference_track||(f>=0?f+1:u.length),l=u[m-1];if(!l)throw new Error(`no video track V${m} (the timeline has ${u.length})`);if(n.tracks?.includes(m))throw new ae("invalid_args",`the track to align cannot be the reference track (V${m})`);let p=(n.tracks?.length?n.tracks:u.map((c,_)=>_+1)).filter(c=>c!==m);for(let c of p)if(!u[c-1])throw new Error(`no video track V${c} (the timeline has ${u.length})`);let g=n.input_scaling??"fit",y=n.sizing_target??"edit",v=600,h=(c,_)=>{let o=Math.max(1,_-c);if(n.samples==="ends")return[...new Set([0,.25,.5,.75,1].map($=>c+Math.round($*(Math.max(c,_-1)-c))))];let b=(n.samples??"half")==="half"&&!n.step?Math.max(1,Math.round(me(s)/2)):n.step,M=n.samples==="all"?Math.max(1,Math.ceil(o/v)):b?Math.max(1,Math.floor(b),Math.ceil(o/v)):0;if(M){let $=[];for(let d=c;d<_;d+=M)$.push(d);return $.at(-1)!==_-1&&$.push(_-1),$}return Le(c,_,Math.max(1,Math.min(v,Math.floor(Number(n.samples))||1)))},k=Number(s.start_frame??0),x=[],w=[],A=oe(l),z=n.scope??"all",B=new Set(n.picks??[]);if(z==="selected"&&!B.size)throw new Error("no clips selected: select clips in the timeline, or align the whole timeline");for(let c of p)for(let _ of oe(u[c-1])){let[o,b]=K(_);if(z==="playhead"&&!(o<=(n.at??-1)&&(n.at??-1)<b)||z==="selected"&&!B.has(`${c}:${o}`))continue;let M={item_id:_.id,name:_.name??_.id,track:c,start:o,end:b,record_tc:W(s,o),verdict:"refused",confidence:null,samples:[]};x.push(M);let $=N=>{M.reason=N};if(_.enabled===!1){$("disabled");continue}let d,C=0,E=0;for(let N of A){let[Y,D]=K(N),P=Math.max(o,Y),F=Math.min(b,D);F-P>E-C&&(d=N,C=P,E=F)}if(!d){if(n.reference_label){$(`${n.reference_label} does not cover it (${W(s,o)}\u2013${W(s,b)}): it ends before this clip`);continue}let N=l.items.find(Y=>{let[D,P]=K(Y);return Y.kind!=="clip"&&Y.kind!=="gap"&&Math.min(b,P)>Math.max(o,D)});$(N?`V${m} has ${/compound|stack|timeline/i.test(String(N.kind))?"a compound clip or nested timeline":`a ${N.kind}`} over it, not a movie clip: Align reads a media file there (decompose it, or use Offline ref)`:A.length?`nothing on V${m} over it (${W(s,o)}\u2013${W(s,b)}): the reference does not cover this clip`:`V${m} has no movie clips: pick the track the reference is on, or Offline ref`);continue}let T=ee(e,d),R=ee(e,_);if(!T.path){$(`the reference clip ${d.name??d.id} is not linked (timeline_relink first)`);continue}if(!R.path){$("not linked (timeline_relink first)");continue}let O=h(C,E);if(O.some(N=>!Ee(q(d,N)))){$(`the reference clip ${d.name??d.id} is itself resized; the fit is against its raw picture`);continue}if(T.w>0&&T.h>0&&Math.abs(T.w/T.h-r/a)>.01*(r/a)){$(`the reference ${T.w}x${T.h} does not fill the ${r}x${a} frame`);continue}let ne=N=>N.map(Y=>({ref:T.path,refFrame:be(d,Y),src:R.path,srcFrame:be(_,Y)})),G=Array.from({length:E-C},(N,Y)=>C+Y),H=q(_,o);w.push({row:M,item:_,recs:O,every:G,ask:{pairs:ne(O),every:ne(G),every_t:G.map(N=>N-o),edit:Ke(H),edit_identity:Ee(H),edit_animated:!!H.animated,anchor_off:!!(H.anchorX||H.anchorY),...n.inputs?.get(`${c}:${o+k}`)?.length?{input:n.inputs.get(`${c}:${o+k}`)}:{}}})}let j=w.length?await ce({op:"reframe",items:w.map(c=>c.ask),out:[r,a],target:y},t,i):{items:[],offsets:[]},S=j.offsets;j.items.forEach((c,_)=>{let{row:o,item:b,recs:M,every:$,ask:d}=w[_],C=c.measured==="every"?$:M,E=c.measured==="every"?d.every:d.pairs,T=(({w:R,h:O})=>Ve(R,O,r,a,Ze(b,s,n.input_scaling)))(ee(e,b));o.samples=c.scores.map((R,O)=>({record:C[c.at[O]],ref_frame:E[c.at[O]].refFrame,src_frame:E[c.at[O]].srcFrame,score:R})),Object.assign(o,{verdict:c.verdict,confidence:c.confidence,...c.reason?{reason:c.reason}:{},...c.label?{label:c.label}:{},...c.unchanged?{unchanged:!0}:{},...c.grade_sizing?{grade_sizing:c.grade_sizing}:{}}),c.transform&&(o.transform=c.transform,o.properties=_e(c.edit_transform??c.transform,r,a,T)),c.keys?.length&&(o.keys=c.keys.map(R=>({record:C[c.at[R.j]],transform:R.transform,properties:_e(R.transform,r,a,T),confidence:R.confidence}))),c.grade_keys?.length&&(o.grade_keys=c.grade_keys.map(({shape:R,...O})=>R?.kind==="resolve_dissolve"?{...O,ease_in:R.start,ease_out:R.end}:O),o.grade_keys[0].t>0&&o.grade_keys.unshift({...o.grade_keys[0],t:0,ease_in:void 0,ease_out:void 0})),c.edit_keys?.length&&(o.edit_keys=c.edit_keys[0].t>0?[{...c.edit_keys[0],t:0,shape:void 0},...c.edit_keys]:c.edit_keys)});let I=[];for(let c of x){let _={track:c.track,start:c.start};if(c.verdict==="aligned"&&y==="edit"&&!c.unchanged){let o=c.properties;I.push({op:"properties",item:_,set:{...o.ZoomX!==o.ZoomY?{ZoomGang:!1}:{},...o}})}if(c.verdict==="animated"&&c.edit_keys&&I.push({op:"edit_keys",item:_,keys:c.edit_keys}),c.verdict==="animated"&&c.grade_keys&&I.push({op:"grade_sizing",item:_,target:y==="node"?"node":"input",keys:c.grade_keys,...y==="node"?Be(n):{}}),c.verdict==="aligned"&&c.grade_sizing&&!c.unchanged&&I.push({op:"grade_sizing",item:_,target:y,...c.grade_sizing,...y==="node"?Be(n):{}}),n.markers??!0){let o={aligned:"Aligned",animated:"Animated",no_match:"No match",refused:"Not aligned"}[c.verdict],b=[c.label,c.confidence!=null?`confidence ${c.confidence}`:"",c.reason].filter(Boolean).join(" \xB7 ");I.push({op:"marker_add",frame:c.start,color:cn[c.verdict],name:`${o}: ${c.name}`,note:b,data:"ConformTools:align"})}}let Z;if(n.apply_session){Z=0;for(let c of x.filter(_=>_.verdict==="aligned")){let _=c.transform;ve(e,"transform",{timeline_id:s.id,item_id:c.item_id,scale:_.scale_x,position_x:_.position_x,position_y:_.position_y,rotation:_.rotation});let o=s.tracks.flatMap(b=>b.items).find(b=>b.id===c.item_id);Math.abs(_.scale_x-_.scale_y)>.001&&(o.scale_x=_.scale_x,o.scale_y=_.scale_y),_.flip_h?o.flip_horizontal=!0:delete o.flip_horizontal,_.flip_v?o.flip_vertical=!0:delete o.flip_vertical,Z++}}let X={aligned:0,animated:0,no_match:0,refused:0};for(let c of x)X[c.verdict]++;return{timeline:s.name??s.id,raster:[r,a],reference_track:m,rows:x,counts:X,ops:I,...Z!=null?{applied:Z}:{},input_scaling:g,sizing_target:y,...S.length?{offsets:S}:{}}}function Tn(e){let n=e.counts,t=`${e.timeline} (${e.raster.join("x")}): ${n.aligned} aligned, ${n.animated} animated, ${n.no_match} no match, ${n.refused} not aligned \u2014 against ${e.reference??`V${e.reference_track}`}${e.input_scaling!=="fit"?` (Resolve units for input scaling "${e.input_scaling}")`:""}${e.sizing_target!=="edit"?`; written as Color-page ${e.sizing_target==="input"?"Input Sizing":"node Sizing"} on top of each clip's own edit transform`:""}${e.sizing_target==="edit"&&n.animated?`; the ${n.animated} moving clip(s) get Edit-page keyframes on a copy of the timeline, "${e.timeline} ALIGNED" (Resolve cannot keyframe the Edit page from a script; the copy carries every grade and setting)`:""}${e.applied!=null?`; ${e.applied} transform(s) written into the session`:""}`,i=r=>{let a=r.properties,u=r.grade_sizing,f=u?` \u2192 ${e.sizing_target} sizing Zoom ${u.zoom}${u.height!==1?` Height ${u.height}`:""} Pan ${u.pan} Tilt ${u.tilt} Rotate ${u.rotation}${u.flip_x?" FlipH":""}${u.flip_y?" FlipV":""}`:a?` \u2192 Pan ${a.Pan} Tilt ${a.Tilt} Zoom ${a.ZoomX}${a.ZoomY!==a.ZoomX?`/${a.ZoomY}`:""} Rot ${a.RotationAngle}${a.FlipX?" FlipX":""}${a.FlipY?" FlipY":""}`:"",m=r.grade_keys?.length?` \u2192 ${r.grade_keys.length} keyframes (${e.sizing_target==="node"?"node":"Input"} Sizing)`:r.edit_keys?.length?` \u2192 ${r.edit_keys.length} Edit-page keyframes`:"";return` V${r.track} ${r.record_tc} ${r.name}: ${r.verdict.toUpperCase()}${r.label?` (${r.label})`:""}${f}${m}${r.confidence!=null?`, confidence ${r.confidence}`:""}${r.reason?` \u2014 ${r.reason}`:""}`},s=(e.offsets??[]).map(r=>` the reference differs from the ${r.raster} online by ${r.label} on ${r.clips} of ${r.of} clips: a render / decode difference, not sizing \u2014 taken out of every clip, never written`);return[t,...s,...e.rows.map(i),`host_apply ops ready: ${e.ops.filter(r=>r.op==="properties"||r.op==="grade_sizing").length} ${e.sizing_target==="edit"?"properties":"grade_sizing"}, ${e.ops.filter(r=>r.op==="marker_add").length} markers (data "ConformTools:align")`].join(`
4
4
  `)}var de={"16:9":16/9,"1.85":1.85,"2.00":2,"2.20":2.2,"2.35":2.35,"2.39":2.39,"2.76":2.76,"4:3":4/3,"1:1":1,"9:16":9/16,none:null};function ln(e){if(e==null)return null;if(typeof e=="number")return e>0?e:null;if(e in de)return de[e];let n=/^(\d+(?:\.\d+)?)(?:[:/](\d+(?:\.\d+)?))?$/.exec(e.trim());if(!n)throw new Error(`aspect '${e}': one of ${Object.keys(de).join(", ")}, or a ratio like 1.66 or 3:2`);let t=n[2]?Number(n[1])/Number(n[2]):Number(n[1]);return t>0?t:null}function Xe(e,n,t){let i=[],s=e;for(let[r,a]of t)if(!(a<=s)&&(r>=n||(r>s&&i.push([s,Math.min(r,n)]),s=Math.max(s,a),s>=n)))break;return s<n&&i.push([s,n]),i}function Ye(e,n,t){let i=[...e,[n,t]].sort((r,a)=>r[0]-a[0]),s=[];for(let r of i){let a=s.at(-1);a&&r[0]<=a[1]?a[1]=Math.max(a[1],r[1]):s.push([r[0],r[1]])}return s}async function An(e,n,t,i){let s=ge(e,n.timeline_id),r=s.resolution_w,a=s.resolution_h,u=ln(n.aspect),f=Fe(n.strictness),m=!!n.pixels,l=Math.max(1,Math.min(12,Math.floor(n.samples??3))),p=te(s),g=p.filter(o=>o.enabled!==!1),y=[],v=[],h=o=>{let b=ee(e,o);if(!(b.w>0&&b.h>0))return!1;let[M,$]=Ne(r,a,b.w,b.h),d=q(o,K(o)[0]);return!d.animated&&Math.abs(M-r)<.5&&Math.abs($-a)<.5&&(d.scaleX??d.scale??100)===100&&(d.scaleY??d.scale??100)===100&&!d.posX&&!d.posY&&!d.rotation&&!d.cropL&&!d.cropR&&!d.cropT&&!d.cropB},k=new Map,x=[];for(let o of g)k.set(o,x),x=oe(o).filter(b=>b.enabled!==!1&&h(b)).reduce((b,M)=>Ye(b,...K(M)),x);let w=[];for(let o of[...g].reverse()){let b=oe(o).filter(d=>d.enabled!==!1),M=b.reduce((d,C)=>Ye(d,...K(C)),w),$=p.indexOf(o)+1;for(let d of b){let[C,E]=K(d),T=k.get(o)??[],R=Xe(C,E,w).flatMap(([P,F])=>Xe(P,F,T));if(!R.length)continue;let O=ee(e,d);if(!(O.w>0&&O.h>0)){y.push({item_id:d.id,name:d.name??d.id,track:$,reason:"the source raster is unknown (timeline_relink the clip first)"});continue}m&&!O.path&&y.push({item_id:d.id,name:d.name??d.id,track:$,reason:"not linked: its source frames were not measured (timeline_relink first); its transform was checked"});let[ne,G]=Ne(r,a,O.w,O.h),H=q(d,C).animated,N=P=>{let F=q(d,P);return{box:[ne,G],scale:[(F.scaleX??F.scale??100)/100,(F.scaleY??F.scale??100)/100],pos:[F.posX*ne,F.posY*G],rot:F.rotation,anchor:[F.anchorX,F.anchorY],crop:[F.cropL/100,F.cropR/100,F.cropT/100,F.cropB/100],flip:[F.flipH,F.flipV]}},Y=[],D=new Map;for(let[P,F]of R){let ue=new Set(m&&O.path?Le(P,F,l):[]),he=new Set(H?Array.from({length:F-P},(V,U)=>P+U):ue.size?[]:[P]);for(let V of ue)he.add(V);let ye=[...he].sort((V,U)=>V-U);ye.forEach((V,U)=>{D.set(V,[U?V:P,ye[U+1]??F]),Y.push({rec:V,place:N(V),...ue.has(V)?{src:be(d,V)}:{}})})}v.push({item:d,track:$,path:O.path,frames:Y,hold:D,animated:H})}w=M}let A=v.length?await ce({op:"blanking",items:v.map(o=>({path:o.path,frames:o.frames})),out:[r,a],aspect:u},t,i):{items:[],target:[0,0,r,a]},z=A.target,B=[],j=new Map,S=0;A.items.forEach((o,b)=>{let M=v[b],$=new Map;j.set(M.item.id,$);for(let d of o){if(d.bars&&S++,d.black||!d.edges.some(T=>T>0))continue;let[C,E]=M.hold.get(d.rec);for(let T=C;T<E;T++)B.push({pts:T,bt:d.edges[0],bb:d.edges[1],bl:d.edges[2],br:d.edges[3],source:d.bars?"pixels":"geometry"}),$.set(T,d.zoom)}});let I=v.map(o=>({id:o.item.id,name:o.item.name??o.item.id,start:K(o.item)[0],end:K(o.item)[1],track:o.track})),X=Ce(B,I,0,Math.round(z[2]-z[0]),Math.round(z[3]-z[1]),{tolerance_px:f.tolerance_px,min_frames:f.min_frames,gap_frames:f.gap_frames}).map(o=>{let b=1,M=j.get(o.clip.id);for(let $=o.start_frame;$<=o.end_frame;$++){if(!M.has($))continue;let d=M.get($);b=d==null||b==null?null:Math.max(b,d)}return{item_id:o.clip.id,name:o.clip.name,track:o.clip.track,record_start:o.start_frame,record_end:o.end_frame,record_tc:W(s,o.start_frame),frames:o.duration_frames,edges:{top:o.measured.bt,bottom:o.measured.bb,left:o.measured.bl,right:o.measured.br},zones:o.zones,sources:o.sources,zoom_fix:b}}),c=[],_=new Map;for(let o of X)_.set(o.item_id,[..._.get(o.item_id)??[],o]);for(let[o,b]of _){let M=v.find(T=>T.item.id===o);if(M.animated||b.some(T=>T.zoom_fix==null))continue;let $=Math.max(...b.map(T=>T.zoom_fix)),d=ee(e,M.item),C=_e(Ke(q(M.item,K(M.item)[0])),r,a,Ve(d.w,d.h,r,a,Ze(M.item,s,n.input_scaling))),E=T=>Math.ceil(T*$*1e5)/1e5;c.push({op:"properties",item:{track:M.track,start:K(M.item)[0]},set:{ZoomX:E(C.ZoomX),ZoomY:E(C.ZoomY)}})}if(n.markers??!0)for(let o of X){let b=v.find(d=>d.item.id===o.item_id),M=o.zones.map(d=>`${d} ${o.edges[d.toLowerCase()]} px`).join(" \xB7 "),$=b.animated?"keyframed sizing: fix the keys":o.zoom_fix==null?"no zoom about its anchor fills it":`zoom \xD7${o.zoom_fix} fills it`;c.push({op:"marker_add",frame:o.record_start,duration:o.frames,color:"Red",name:`Blanking: ${o.name}`,note:`${M} (${o.sources.join("+")}) \u2014 ${$}`,data:"ConformTools:blanking"})}return{timeline:s.name??s.id,raster:[r,a],aspect:u,target:z,strictness:f,pixels:m,clips_checked:v.length,frames_measured:S,findings:X,refused:y,ops:c}}function zn(e){return[`${e.findings.length?`BLANKING: ${e.findings.length} range(s) on ${new Set(e.findings.map(t=>t.item_id)).size} clip(s)`:"CLEAN: no clip shows black"} \u2014 ${e.timeline} ${e.raster.join("x")}${e.aspect?`, delivered ${J(e.aspect,3)}:1 (black counted inside it only)`:""}; ${e.strictness.preset} (${e.strictness.tolerance_px} px, ${e.strictness.min_frames} frame(s)); ${e.clips_checked} clip(s) by their transform${e.pixels?`, ${e.frames_measured} source frame(s) measured for their own black edges`:" (pixels:false: a black edge baked into a source is not seen)"}`,...e.findings.map(t=>` V${t.track} ${t.record_tc} ${t.name} (${t.frames} frame${t.frames>1?"s":""}): ${t.zones.map(i=>`${i} ${t.edges[i.toLowerCase()]} px`).join(", ")} [${t.sources.join("+")}]${t.zoom_fix?` \u2014 zoom \xD7${t.zoom_fix} fills it`:" \u2014 no zoom about its anchor fills it"}`),...e.refused.map(t=>` V${t.track} ${t.name}: ${t.reason}`),`host_apply ops ready: ${e.ops.filter(t=>t.op==="properties").length} ZoomX/ZoomY fixes, ${e.ops.filter(t=>t.op==="marker_add").length} markers (data "ConformTools:blanking")`].join(`
5
5
  `)}export{fe as a,Fe as b,Ce as c,bn as d,_n as e,un as f,Ze as g,Ve as h,_e as i,Sn as j,mn as k,Mn as l,Tn as m,de as n,ln as o,An as p,zn as q};
package/dist/cli.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{$ as V,V as J,X as H,Y as F,_ as G}from"./chunk-OJWIBQK4.js";import"./chunk-OVUCL3YY.js";import"./chunk-UKKRZ574.js";import"./chunk-LFJLRLEP.js";import"./chunk-RFIPLBQ4.js";import"./chunk-SZD4C5MB.js";import{J as L}from"./chunk-BL6L5ZBP.js";import{a as A}from"./chunk-5JBUCVRI.js";import"./chunk-PFISREY4.js";import"./chunk-TXQR2HI2.js";import"./chunk-JV7TZDKJ.js";import"./chunk-3XD6NC4G.js";import"./chunk-PFZVET7S.js";import"./chunk-P7OVDUA5.js";import"./chunk-UCMNH6Q6.js";import"./chunk-5SUGU2YR.js";import"./chunk-NQHQKEP5.js";import"./chunk-6ML26TIK.js";import"./chunk-HGDO3OED.js";import"./chunk-X53BNWNV.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-7MC7M2Y5.js";import"./chunk-VS3MKKJ5.js";import"./chunk-XNR7M4VX.js";import"./chunk-AS7IXHYM.js";import{b as W}from"./chunk-NU3X7P4N.js";import"./chunk-C5IX63YF.js";import"./chunk-EJGVNQ3E.js";import{h as D,i as I}from"./chunk-5RSNFPED.js";import"./chunk-3OCQA33E.js";import{b as T,e as c,f as s}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var i=process.stdout,C=22,E=20,R=E/2,Y=(t,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(t),2.393*(1-Math.abs(t))),nt=(t,n)=>t*t+n*n<=1;function et(t){let n=.62**-t,l=[];for(let r=0;r<E;r++){let p=[];for(let g=0;g<C;g++){let w=(g+.5)/C*2-1,u=(r+.5)/E*2-1,d=!1;if(Y(w,u))for(let $=0;$<6;$++)for(let y of[!1,!0]){let m=.62**$*(y?.77:1)*n,x=.5*Math.max(0,1-m)**2;(y?nt:Y)(w/m,(u-x)/m)&&(d=!y)}p.push(d)}l.push(p)}return l}var M={C:["\u25E2\u2588\u25E3","\u2588 ","\u2588 ","\u25E5\u2588\u25E4"],O:["\u25E2\u2588\u25E3","\u2588 \u2588","\u2588 \u2588","\u25E5\u2588\u25E4"],N:["\u2588\u25E3 \u2588","\u2588\u2588\u25E3\u2588","\u2588\u25E5\u2588\u2588","\u2588 \u25E5\u2588"],F:["\u2588\u2588\u2588","\u2588\u2584\u2584","\u2588 ","\u2588 "],R:["\u2588\u2588\u25E3","\u2588 \u2588","\u2588\u2588\u25E4","\u2588 \u2588"],M:["\u2588\u25E3\u25E2\u2588","\u2588\u25E5\u25E4\u2588","\u2588 \u2588","\u2588 \u2588"],T:["\u2588\u2588\u2588"," \u2588 "," \u2588 "," \u2588 "],L:["\u2588 ","\u2588 ","\u2588 ","\u2588\u2588\u2588"],S:["\u25E2\u2588\u25E3","\u25E5\u25E3 "," \u25E5\u25E3","\u25E5\u2588\u25E4"],".":[" "," "," ","\u25CF"]},B="CONFORM.TOOLS",rt=[...B].reduce((t,n)=>t+M[n][0].length+1,-1);async function K(t){if(!i.isTTY)return!1;let n=!!T("NO_COLOR"),l=/truecolor|24bit/i.test(T("COLORTERM")??""),r=o=>e=>n?e:`\x1B[${o}m${e}\x1B[0m`,p=r(l?"38;2;255;60;0":"38;5;202"),g=r(l?"38;2;255;222;0":"38;5;220"),w=r("1"),u=r("2"),d=(i.columns??80)>=C+4+rt,$=o=>[...B].map(e=>e==="."?p(M[e][o]):w(M[e][o])).join(" "),y=(o,e)=>d&&o>=2&&o<=5?$(o-2):!d&&o===3?`${w("conform")}${p(".")}${w("tools")}`:o===7?e:"",m=(o,e,O=[])=>{let S=et(o),_=[];for(let f=0;f<R;f++){let Z=S[2*f].map((N,ot)=>{let k=S[2*f+1][ot];return N&&k?"\u2588":N?"\u2580":k?"\u2584":" "}).join(""),tt=f>=8?O[f-8]??"":"";_.push(` ${p(Z)} ${tt||y(f,e)}\x1B[K`)}return _.join(`
3
+ import{$ as V,V as J,X as H,Y as F,_ as G}from"./chunk-55BKURYP.js";import"./chunk-S5JDS5PQ.js";import"./chunk-XLEINKFL.js";import"./chunk-EUBXH67N.js";import"./chunk-SNTAZJ5A.js";import"./chunk-TXQR2HI2.js";import{J as L}from"./chunk-5WEZRGXG.js";import{a as A}from"./chunk-P2LL3JMC.js";import"./chunk-GM6QKY7W.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-GK4YYKJ6.js";import{b as W}from"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-SKFMOLUO.js";import{h as D,i as I}from"./chunk-NAFLOZER.js";import"./chunk-PHAMF4JF.js";import{b as T,e as c,f as s}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var i=process.stdout,C=22,E=20,R=E/2,Y=(t,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(t),2.393*(1-Math.abs(t))),nt=(t,n)=>t*t+n*n<=1;function et(t){let n=.62**-t,l=[];for(let r=0;r<E;r++){let g=[];for(let p=0;p<C;p++){let w=(p+.5)/C*2-1,u=(r+.5)/E*2-1,d=!1;if(Y(w,u))for(let $=0;$<6;$++)for(let y of[!1,!0]){let m=.62**$*(y?.77:1)*n,x=.5*Math.max(0,1-m)**2;(y?nt:Y)(w/m,(u-x)/m)&&(d=!y)}g.push(d)}l.push(g)}return l}var M={C:["\u25E2\u2588\u25E3","\u2588 ","\u2588 ","\u25E5\u2588\u25E4"],O:["\u25E2\u2588\u25E3","\u2588 \u2588","\u2588 \u2588","\u25E5\u2588\u25E4"],N:["\u2588\u25E3 \u2588","\u2588\u2588\u25E3\u2588","\u2588\u25E5\u2588\u2588","\u2588 \u25E5\u2588"],F:["\u2588\u2588\u2588","\u2588\u2584\u2584","\u2588 ","\u2588 "],R:["\u2588\u2588\u25E3","\u2588 \u2588","\u2588\u2588\u25E4","\u2588 \u2588"],M:["\u2588\u25E3\u25E2\u2588","\u2588\u25E5\u25E4\u2588","\u2588 \u2588","\u2588 \u2588"],T:["\u2588\u2588\u2588"," \u2588 "," \u2588 "," \u2588 "],L:["\u2588 ","\u2588 ","\u2588 ","\u2588\u2588\u2588"],S:["\u25E2\u2588\u25E3","\u25E5\u25E3 "," \u25E5\u25E3","\u25E5\u2588\u25E4"],".":[" "," "," ","\u25CF"]},B="CONFORM.TOOLS",rt=[...B].reduce((t,n)=>t+M[n][0].length+1,-1);async function K(t){if(!i.isTTY)return!1;let n=!!T("NO_COLOR"),l=/truecolor|24bit/i.test(T("COLORTERM")??""),r=o=>e=>n?e:`\x1B[${o}m${e}\x1B[0m`,g=r(l?"38;2;255;60;0":"38;5;202"),p=r(l?"38;2;255;222;0":"38;5;220"),w=r("1"),u=r("2"),d=(i.columns??80)>=C+4+rt,$=o=>[...B].map(e=>e==="."?g(M[e][o]):w(M[e][o])).join(" "),y=(o,e)=>d&&o>=2&&o<=5?$(o-2):!d&&o===3?`${w("conform")}${g(".")}${w("tools")}`:o===7?e:"",m=(o,e,O=[])=>{let S=et(o),_=[];for(let f=0;f<R;f++){let Z=S[2*f].map((N,ot)=>{let k=S[2*f+1][ot];return N&&k?"\u2588":N?"\u2580":k?"\u2584":" "}).join(""),tt=f>=8?O[f-8]??"":"";_.push(` ${g(Z)} ${tt||y(f,e)}\x1B[K`)}return _.join(`
4
4
  `)+`
5
5
  `},x=null;t.account.then(o=>{x=o});let P=o=>W(o,24),U=!T("CI")&&T("TERM")!=="dumb";if(i.write(`
6
- `),U){let o=()=>i.write("\x1B[?25h");process.once("SIGINT",()=>{o(),process.exit(130)}),i.write("\x1B[?25l"+m(0,g(`\u25B6 ${P(0)}`)));let e=Date.now(),O=0;for(;x===null||Date.now()-e<900;)await new Promise(S=>setTimeout(S,1e3/24)),O=Math.round((Date.now()-e)*24/1e3),i.write(`\x1B[${R}A\r`+m(O/22%1,`${g(`\u25B6 ${P(O)}`)} ${u("checking your account\u2026")}`));i.write(`\x1B[${R}A\r`),o()}let X=(x??await t.account).split(`
6
+ `),U){let o=()=>i.write("\x1B[?25h");process.once("SIGINT",()=>{o(),process.exit(130)}),i.write("\x1B[?25l"+m(0,p(`\u25B6 ${P(0)}`)));let e=Date.now(),O=0;for(;x===null||Date.now()-e<900;)await new Promise(S=>setTimeout(S,1e3/24)),O=Math.round((Date.now()-e)*24/1e3),i.write(`\x1B[${R}A\r`+m(O/22%1,`${p(`\u25B6 ${P(O)}`)} ${u("checking your account\u2026")}`));i.write(`\x1B[${R}A\r`),o()}let X=(x??await t.account).split(`
7
7
  `);return i.write(m(0,`${u("v")}${t.version} ${u("\xB7 built by post pros")}`,X.map(o=>u(o)))),i.write(`
8
8
  `),!0}var z=()=>K({version:A,account:Promise.race([D().catch(()=>null),new Promise(t=>setTimeout(t,1500,null))]).then(t=>t?I(t):"account: no answer (offline?)")}),st={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status",telemetry:"account_telemetry"};c()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));c()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));c()[0]==="statusline"&&((await import("./statusline-GMMCFMOA.js")).main(),s(0));if(c()[0]==="setup"){let t=c()[1];t!=="claude"&&(console.error(`conformtools setup <client>: supported: claude${t?` (not ${t} yet)`:""}`),s(2));let{setupClaude:n,setupText:l}=await import("./claude-setup-IIWUB4CE.js");try{console.log(l(await n())),s(0)}catch(r){console.error(r instanceof Error?r.message:String(r)),s(1)}}var q=c().includes("--json"),[a,v]=c().filter(t=>t!=="--json");if(!a||a==="--list"||a==="help"||a==="--help"){await z(),console.log(`conformtools <verb> '<json args>' [--json]
9
9
 
10
10
  login / whoami / logout sign in with your conform.tools Google account
11
- telemetry on|off|status optional outcome telemetry (off by default; see the README, Feedback and privacy)
11
+ telemetry on|off|status outcome telemetry (on by default, content-free; see the README, Feedback and privacy)
12
12
  mcp run as an MCP server (stdio) for Claude Code, Cursor, Codex\u2026
13
13
  http run the local HTTP API on 127.0.0.1:7791
14
14
  `);let t=L()==="hosted";for(let n of G)console.log(` ${n.name.padEnd(22)} ${n.title}${t&&n.protectedStages?.length?" (on conform.tools)":""}`);t&&console.log(`
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b}from"./chunk-HGDO3OED.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{b as decodeCr3Wasm,a as inspectCr3Wasm};
3
+ import{a,b}from"./chunk-J2JXLEAI.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{b as decodeCr3Wasm,a as inspectCr3Wasm};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b,c}from"./chunk-6ML26TIK.js";import"./chunk-DKGGJM6Z.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{c as decodeDngPreviewWasm,b as decodeDngWasm,a as inspectDngWasm};
3
+ import{a,b,c}from"./chunk-A7FNR3T5.js";import"./chunk-DKGGJM6Z.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{c as decodeDngPreviewWasm,b as decodeDngWasm,a as inspectDngWasm};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b,c}from"./chunk-5SUGU2YR.js";import"./chunk-DKGGJM6Z.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{c as decodeDpxPreviewWasm,b as decodeDpxWasm,a as inspectDpxWasm};
3
+ import{a,b,c}from"./chunk-D4WPRRBT.js";import"./chunk-DKGGJM6Z.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{c as decodeDpxPreviewWasm,b as decodeDpxWasm,a as inspectDpxWasm};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a,b,c}from"./chunk-NQHQKEP5.js";import"./chunk-DKGGJM6Z.js";import"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";export{c as decodeExrPreviewWasm,b as decodeExrWasm,a as inspectExrWasm};
3
+ import{a,b,c}from"./chunk-WN53ARHJ.js";import"./chunk-DKGGJM6Z.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";export{c as decodeExrPreviewWasm,b as decodeExrWasm,a as inspectExrWasm};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l}from"./chunk-XLEINKFL.js";import"./chunk-5WEZRGXG.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-NAFLOZER.js";import"./chunk-PHAMF4JF.js";import"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{i as ASPECTS,a as INPUT_SCALING,e as SIZING_TARGETS,h as alignText,g as alignTimeline,j as aspectOf,k as blankingQc,l as blankingText,c as inputFitRatio,f as offlineLane,d as resolveProps,b as scalingOf};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{e as h,f as d,n as w,p as _}from"./chunk-AS7IXHYM.js";import"./chunk-NU3X7P4N.js";import{Ga as u,T as l,V as g}from"./chunk-C5IX63YF.js";import"./chunk-3OCQA33E.js";import{u as y}from"./chunk-PLRB2YXJ.js";import"./chunk-PSANHDZM.js";import{parentPort as p,workerData as C}from"node:worker_threads";import{createCanvas as M,loadImage as A}from"@napi-rs/canvas";var S=(async()=>{await w(C),await u()})(),o=new Map,c=new Map;p.on("message",async t=>{try{await S;let s={};for(let[e,a]of Object.entries(t.images))c.has(a)||c.set(a,await A(await y(a))),s[e]=c.get(a);let m=`${t.fmt.w}x${t.fmt.h}`;o.has(m)||o.set(m,M(t.fmt.w,t.fmt.h));let i=o.get(m).getContext("2d"),v=h(i),r=[],f=null;for(let e=t.from;e<t.to;e++){d(i,t.scene,e/t.fps,t.fmt,v,s);let a=i.getImageData(0,0,t.fmt.w,t.fmt.h).data,n=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(f&&_(f,n)){r.push(null);continue}r.push(t.alpha?l(n,t.fmt.w,t.fmt.h,4):g(n,t.fmt.w,t.fmt.h,4)),f=n.slice()}p.postMessage({id:t.id,samples:r},r.filter(e=>!!e).map(e=>e.buffer))}catch(s){p.postMessage({id:t.id,error:s.message??String(s)})}});
3
+ import{e as h,f as d,n as w,p as _}from"./chunk-GK4YYKJ6.js";import"./chunk-NU3X7P4N.js";import{Ha as u,T as l,V as g}from"./chunk-RJ6JA2LZ.js";import"./chunk-PHAMF4JF.js";import{u as y}from"./chunk-PLRB2YXJ.js";import"./chunk-PSANHDZM.js";import{parentPort as p,workerData as C}from"node:worker_threads";import{createCanvas as M,loadImage as A}from"@napi-rs/canvas";var S=(async()=>{await w(C),await u()})(),o=new Map,c=new Map;p.on("message",async t=>{try{await S;let s={};for(let[e,a]of Object.entries(t.images))c.has(a)||c.set(a,await A(await y(a))),s[e]=c.get(a);let m=`${t.fmt.w}x${t.fmt.h}`;o.has(m)||o.set(m,M(t.fmt.w,t.fmt.h));let i=o.get(m).getContext("2d"),v=h(i),r=[],f=null;for(let e=t.from;e<t.to;e++){d(i,t.scene,e/t.fps,t.fmt,v,s);let a=i.getImageData(0,0,t.fmt.w,t.fmt.h).data,n=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(f&&_(f,n)){r.push(null);continue}r.push(t.alpha?l(n,t.fmt.w,t.fmt.h,4):g(n,t.fmt.w,t.fmt.h,4)),f=n.slice()}p.postMessage({id:t.id,samples:r},r.filter(e=>!!e).map(e=>e.buffer))}catch(s){p.postMessage({id:t.id,error:s.message??String(s)})}});
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as O}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";function v(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=String.fromCharCode(e[r+4],e[r+5],e[r+6],e[r+7]),c=8;if(o===1){let l=s.getUint32(r+8),g=s.getUint32(r+12);o=l*2**32+g,c=16}else o===0&&(o=t-r);if(o<c||r+o>t)break;f(a,r+c,r+o),r+=o}}var E=new Set(["moov","trak","mdia","minf","stbl"]);function D(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=null,f=(r,o)=>{let a={},c=!1,l=(g,y)=>{v(e,g,y,(w,i,p)=>{if(E.has(w)){l(i,p);return}if(!(!c&&w!=="hdlr"&&w!=="stsd"))switch(w){case"hdlr":{String.fromCharCode(e[i+8],e[i+9],e[i+10],e[i+11])==="vide"&&(c=!0);break}case"stsd":{let u=i+8;a.codec=String.fromCharCode(e[u+4],e[u+5],e[u+6],e[u+7]),a.width=n.getUint16(u+32),a.height=n.getUint16(u+34);break}case"stsz":{let u=n.getUint32(i+4),d=n.getUint32(i+8),m=[];if(u===0)for(let h=0;h<d;h++)m.push(n.getUint32(i+12+h*4));else for(let h=0;h<d;h++)m.push(u);a.sampleSizes=m;break}case"stco":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push(n.getUint32(i+8+m*4));a.chunkOffsets=d;break}case"co64":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++){let h=n.getUint32(i+8+m*8),k=n.getUint32(i+12+m*8);d.push(h*2**32+k)}a.chunkOffsets=d;break}case"stsc":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push({firstChunk:n.getUint32(i+8+m*12),samplesPerChunk:n.getUint32(i+8+m*12+4),descIdx:n.getUint32(i+8+m*12+8)});a.sampleToChunk=d;break}}})};l(r,o),c&&a.chunkOffsets&&a.sampleSizes&&a.sampleToChunk&&(t=a)};if(((r,o)=>{v(e,r,o,(a,c,l)=>{a==="moov"&&v(e,c,l,(g,y,w)=>{g==="trak"&&f(y,w)})})})(0,e.length),!t)throw new Error("could not find a video sample table");return t}function V(e){let n=[],t=0;for(let f=0;f<e.chunkOffsets.length;f++){let s=1;for(let o=0;o<e.sampleToChunk.length;o++)f+1>=e.sampleToChunk[o].firstChunk&&(s=e.sampleToChunk[o].samplesPerChunk);let r=e.chunkOffsets[f];for(let o=0;o<s&&t<e.sampleSizes.length;o++){let a=e.sampleSizes[t];n.push({offset:r,size:a}),r+=a,t++}}return n}var P=(e,n)=>String.fromCharCode(e[n],e[n+1],e[n+2],e[n+3]),z=e=>e.toString(16).padStart(2,"0");function S(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=8;if(o===1?(o=Number(s.getBigUint64(r+8)),a=16):o===0&&(o=t-r),P(e,r+4)===f)return[r+a,r+o];if(o<a)break;r+=o}return null}function H(e,n,t,f){let s=[n,t];for(let r of f){if(!s)return null;s=S(e,s[0],s[1],r)}return s}function M(e,n,t){let f=S(e,n[0],n[1],"stts");if(!f)return new Int32Array(0);let s=t.getUint32(f[0]+4),r=[],o=0,a=f[0]+8;for(let i=0;i<s;i++){let p=t.getUint32(a),u=t.getInt32(a+4);for(let d=0;d<p;d++)r.push(o),o+=u;a+=8}let c=r.length,l=S(e,n[0],n[1],"ctts"),g=new Float64Array(c);for(let i=0;i<c;i++)g[i]=r[i];if(l){let i=t.getUint32(l[0]+4),p=l[0]+8,u=0;for(let d=0;d<i&&u<c;d++){let m=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<m&&u<c;k++)g[u++]+=h;p+=8}}let y=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),w=new Int32Array(c);for(let i=0;i<c;i++)w[y[i]]=i;return w}function F(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=S(e,0,e.length,"moov"),[f,s]=t??[0,e.length],r=f;for(;r+8<=s;){let o=n.getUint32(r),a=8;if(o===1?(o=Number(n.getBigUint64(r+8)),a=16):o===0&&(o=s-r),P(e,r+4)==="trak"){let c=H(e,r+a,r+o,["mdia","minf","stbl"]);if(c){let l=S(e,c[0],c[1],"stsd");if(l){let g=l[0]+8,y=P(e,g+4);if(y==="avc1"||y==="avc3"||y==="hvc1"||y==="hev1"){let w=n.getUint32(g),i=g+8+78,p=y.startsWith("hv")||y.startsWith("he"),u=S(e,i,g+w,p?"hvcC":"avcC");if(!u)return null;let d=e.subarray(u[0],u[1]),m=p?"hvc1.1.6.L93.B0":`avc1.${z(d[1])}${z(d[2])}${z(d[3])}`,h=M(e,c,n),k=h.length,U=S(e,c[0],c[1],"stss"),b=[];if(U){let T=n.getUint32(U[0]+4);for(let C=0;C<T;C++)b.push(n.getUint32(U[0]+8+C*4)-1)}else for(let T=0;T<k;T++)b.push(T);return(b.length===0||b[0]!==0)&&b.unshift(0),b.sort((T,C)=>T-C),{codec:m,description:d,keyframes:b,decodeToPres:h}}}}}if(o<a)break;r+=o}return null}var x=8,R=1500,I=new WeakMap;async function $(e){let n=I.get(e);return n||(n=L(e),I.set(e,n)),n}async function L(e){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let n=e.parts[0],t=await O({fileSize:n.fileSize,read:n.read}),f=V(D(t)),s=F(t);if(!s)throw new Error("h264: no H.264/HEVC config in container");let r=s.decodeToPres.length||f.length,o=new Int32Array(r);for(let l=0;l<s.decodeToPres.length;l++)o[s.decodeToPres[l]]=l;let a=[];for(let l=0;l<s.keyframes.length;l++){let g=s.keyframes[l],y=l+1<s.keyframes.length?s.keyframes[l+1]:f.length;a.push([g,y])}let c={offs:f,cfg:s,gops:a,presToDecode:o,count:r,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return c.dec=new VideoDecoder({output:l=>{Number(l.timestamp)===c.wanted&&!c.got?(c.got=l,c.gotResolve?.()):l.close()},error:()=>{c.fedThrough=-1}}),c.dec.configure({codec:s.codec,description:s.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"}),c}function q(e,n){let t=0,f=e.length-1,s=0;for(;t<=f;){let r=t+f>>1;e[r][0]<=n?(s=r,t=r+1):f=r-1}return s}async function B(e){let n=e.codedWidth,t=e.codedHeight;try{let f=n*t*4,s=new Uint8Array(f);return await e.copyTo(s,{format:"RGBA",colorSpace:"srgb"}),{width:n,height:t,rgba:s}}catch{let s=new OffscreenCanvas(n,t).getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("h264: no 2d context for frame readback");s.drawImage(e,0,0);let r=s.getImageData(0,0,n,t);return{width:n,height:t,rgba:new Uint8Array(r.data.buffer)}}}async function N(e,n){let t=await $(e);if(t.count===0)throw new Error("h264: empty clip");if(n<0||n>=t.count)throw new Error(`COVERAGE_MISS: frame ${n} outside 0..${t.count-1}`);let f,s=new Promise(o=>{f=o}),r=t.queue;t.queue=t.queue.then(()=>s),await r;try{let o=e.parts[0],a=t.presToDecode[n],c=q(t.gops,a),[l,g]=t.gops[c];for(let y=0;y<2;y++){let w=y===0&&t.fedThrough>l&&t.fedThrough<=g&&a>=t.fedThrough,i=w?t.fedThrough:l;if(!w&&t.fedThrough!==-1){try{await t.dec.flush()}catch{}t.fedThrough=-1}let p=Math.min(g,a+1+x);t.wanted=n,t.got=null;let u=new Promise(h=>{t.gotResolve=h});if(p>i){let h=1/0,k=0;for(let b=i;b<p;b++)h=Math.min(h,t.offs[b].offset),k=Math.max(k,t.offs[b].offset+t.offs[b].size);let U=await o.read(h,k-h);for(let b=i;b<p;b++){let T=t.offs[b];t.dec.decode(new EncodedVideoChunk({type:b===l?"key":"delta",timestamp:t.cfg.decodeToPres[b],data:U.subarray(T.offset-h,T.offset-h+T.size)}))}t.fedThrough=p}let d=new Promise(h=>setTimeout(h,R));if(await Promise.race([u,d]),!t.got){try{await t.dec.flush()}catch{}t.fedThrough=-1}let m=t.got;if(t.wanted=-1,t.gotResolve=null,t.got=null,!!m)try{return await B(m)}finally{m.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{f()}}async function A(){return(await import("./isobmff-SIOE67WL.js")).isobmffFormat}var J={async inspect(e){return(await A()).inspect(e)},async extract(e){return(await A()).extract(e)},async sparsify(e,n){return(await A()).sparsify(e,n)},async trim(e,n){return(await A()).trim(e,n)},async decode(e,n){return N(e,n)}};export{J as h264Format};
3
+ import{a as O}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";function v(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=String.fromCharCode(e[r+4],e[r+5],e[r+6],e[r+7]),c=8;if(o===1){let l=s.getUint32(r+8),g=s.getUint32(r+12);o=l*2**32+g,c=16}else o===0&&(o=t-r);if(o<c||r+o>t)break;f(a,r+c,r+o),r+=o}}var E=new Set(["moov","trak","mdia","minf","stbl"]);function D(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=null,f=(r,o)=>{let a={},c=!1,l=(g,y)=>{v(e,g,y,(w,i,p)=>{if(E.has(w)){l(i,p);return}if(!(!c&&w!=="hdlr"&&w!=="stsd"))switch(w){case"hdlr":{String.fromCharCode(e[i+8],e[i+9],e[i+10],e[i+11])==="vide"&&(c=!0);break}case"stsd":{let u=i+8;a.codec=String.fromCharCode(e[u+4],e[u+5],e[u+6],e[u+7]),a.width=n.getUint16(u+32),a.height=n.getUint16(u+34);break}case"stsz":{let u=n.getUint32(i+4),d=n.getUint32(i+8),m=[];if(u===0)for(let h=0;h<d;h++)m.push(n.getUint32(i+12+h*4));else for(let h=0;h<d;h++)m.push(u);a.sampleSizes=m;break}case"stco":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push(n.getUint32(i+8+m*4));a.chunkOffsets=d;break}case"co64":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++){let h=n.getUint32(i+8+m*8),k=n.getUint32(i+12+m*8);d.push(h*2**32+k)}a.chunkOffsets=d;break}case"stsc":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push({firstChunk:n.getUint32(i+8+m*12),samplesPerChunk:n.getUint32(i+8+m*12+4),descIdx:n.getUint32(i+8+m*12+8)});a.sampleToChunk=d;break}}})};l(r,o),c&&a.chunkOffsets&&a.sampleSizes&&a.sampleToChunk&&(t=a)};if(((r,o)=>{v(e,r,o,(a,c,l)=>{a==="moov"&&v(e,c,l,(g,y,w)=>{g==="trak"&&f(y,w)})})})(0,e.length),!t)throw new Error("could not find a video sample table");return t}function V(e){let n=[],t=0;for(let f=0;f<e.chunkOffsets.length;f++){let s=1;for(let o=0;o<e.sampleToChunk.length;o++)f+1>=e.sampleToChunk[o].firstChunk&&(s=e.sampleToChunk[o].samplesPerChunk);let r=e.chunkOffsets[f];for(let o=0;o<s&&t<e.sampleSizes.length;o++){let a=e.sampleSizes[t];n.push({offset:r,size:a}),r+=a,t++}}return n}var P=(e,n)=>String.fromCharCode(e[n],e[n+1],e[n+2],e[n+3]),z=e=>e.toString(16).padStart(2,"0");function S(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=8;if(o===1?(o=Number(s.getBigUint64(r+8)),a=16):o===0&&(o=t-r),P(e,r+4)===f)return[r+a,r+o];if(o<a)break;r+=o}return null}function H(e,n,t,f){let s=[n,t];for(let r of f){if(!s)return null;s=S(e,s[0],s[1],r)}return s}function M(e,n,t){let f=S(e,n[0],n[1],"stts");if(!f)return new Int32Array(0);let s=t.getUint32(f[0]+4),r=[],o=0,a=f[0]+8;for(let i=0;i<s;i++){let p=t.getUint32(a),u=t.getInt32(a+4);for(let d=0;d<p;d++)r.push(o),o+=u;a+=8}let c=r.length,l=S(e,n[0],n[1],"ctts"),g=new Float64Array(c);for(let i=0;i<c;i++)g[i]=r[i];if(l){let i=t.getUint32(l[0]+4),p=l[0]+8,u=0;for(let d=0;d<i&&u<c;d++){let m=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<m&&u<c;k++)g[u++]+=h;p+=8}}let y=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),w=new Int32Array(c);for(let i=0;i<c;i++)w[y[i]]=i;return w}function F(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=S(e,0,e.length,"moov"),[f,s]=t??[0,e.length],r=f;for(;r+8<=s;){let o=n.getUint32(r),a=8;if(o===1?(o=Number(n.getBigUint64(r+8)),a=16):o===0&&(o=s-r),P(e,r+4)==="trak"){let c=H(e,r+a,r+o,["mdia","minf","stbl"]);if(c){let l=S(e,c[0],c[1],"stsd");if(l){let g=l[0]+8,y=P(e,g+4);if(y==="avc1"||y==="avc3"||y==="hvc1"||y==="hev1"){let w=n.getUint32(g),i=g+8+78,p=y.startsWith("hv")||y.startsWith("he"),u=S(e,i,g+w,p?"hvcC":"avcC");if(!u)return null;let d=e.subarray(u[0],u[1]),m=p?"hvc1.1.6.L93.B0":`avc1.${z(d[1])}${z(d[2])}${z(d[3])}`,h=M(e,c,n),k=h.length,U=S(e,c[0],c[1],"stss"),b=[];if(U){let T=n.getUint32(U[0]+4);for(let C=0;C<T;C++)b.push(n.getUint32(U[0]+8+C*4)-1)}else for(let T=0;T<k;T++)b.push(T);return(b.length===0||b[0]!==0)&&b.unshift(0),b.sort((T,C)=>T-C),{codec:m,description:d,keyframes:b,decodeToPres:h}}}}}if(o<a)break;r+=o}return null}var x=8,R=1500,I=new WeakMap;async function $(e){let n=I.get(e);return n||(n=L(e),I.set(e,n)),n}async function L(e){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let n=e.parts[0],t=await O({fileSize:n.fileSize,read:n.read}),f=V(D(t)),s=F(t);if(!s)throw new Error("h264: no H.264/HEVC config in container");let r=s.decodeToPres.length||f.length,o=new Int32Array(r);for(let l=0;l<s.decodeToPres.length;l++)o[s.decodeToPres[l]]=l;let a=[];for(let l=0;l<s.keyframes.length;l++){let g=s.keyframes[l],y=l+1<s.keyframes.length?s.keyframes[l+1]:f.length;a.push([g,y])}let c={offs:f,cfg:s,gops:a,presToDecode:o,count:r,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return c.dec=new VideoDecoder({output:l=>{Number(l.timestamp)===c.wanted&&!c.got?(c.got=l,c.gotResolve?.()):l.close()},error:()=>{c.fedThrough=-1}}),c.dec.configure({codec:s.codec,description:s.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"}),c}function q(e,n){let t=0,f=e.length-1,s=0;for(;t<=f;){let r=t+f>>1;e[r][0]<=n?(s=r,t=r+1):f=r-1}return s}async function B(e){let n=e.codedWidth,t=e.codedHeight;try{let f=n*t*4,s=new Uint8Array(f);return await e.copyTo(s,{format:"RGBA",colorSpace:"srgb"}),{width:n,height:t,rgba:s}}catch{let s=new OffscreenCanvas(n,t).getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("h264: no 2d context for frame readback");s.drawImage(e,0,0);let r=s.getImageData(0,0,n,t);return{width:n,height:t,rgba:new Uint8Array(r.data.buffer)}}}async function N(e,n){let t=await $(e);if(t.count===0)throw new Error("h264: empty clip");if(n<0||n>=t.count)throw new Error(`COVERAGE_MISS: frame ${n} outside 0..${t.count-1}`);let f,s=new Promise(o=>{f=o}),r=t.queue;t.queue=t.queue.then(()=>s),await r;try{let o=e.parts[0],a=t.presToDecode[n],c=q(t.gops,a),[l,g]=t.gops[c];for(let y=0;y<2;y++){let w=y===0&&t.fedThrough>l&&t.fedThrough<=g&&a>=t.fedThrough,i=w?t.fedThrough:l;if(!w&&t.fedThrough!==-1){try{await t.dec.flush()}catch{}t.fedThrough=-1}let p=Math.min(g,a+1+x);t.wanted=n,t.got=null;let u=new Promise(h=>{t.gotResolve=h});if(p>i){let h=1/0,k=0;for(let b=i;b<p;b++)h=Math.min(h,t.offs[b].offset),k=Math.max(k,t.offs[b].offset+t.offs[b].size);let U=await o.read(h,k-h);for(let b=i;b<p;b++){let T=t.offs[b];t.dec.decode(new EncodedVideoChunk({type:b===l?"key":"delta",timestamp:t.cfg.decodeToPres[b],data:U.subarray(T.offset-h,T.offset-h+T.size)}))}t.fedThrough=p}let d=new Promise(h=>setTimeout(h,R));if(await Promise.race([u,d]),!t.got){try{await t.dec.flush()}catch{}t.fedThrough=-1}let m=t.got;if(t.wanted=-1,t.gotResolve=null,t.got=null,!!m)try{return await B(m)}finally{m.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{f()}}async function A(){return(await import("./isobmff-VJOWP4MH.js")).isobmffFormat}var J={async inspect(e){return(await A()).inspect(e)},async extract(e){return(await A()).extract(e)},async sparsify(e,n){return(await A()).sparsify(e,n)},async trim(e,n){return(await A()).trim(e,n)},async decode(e,n){return N(e,n)}};export{J as h264Format};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{Ga as v,ma as g,oa as b}from"./chunk-C5IX63YF.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-74TTDICM.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
3
+ import{Ha as v,ma as g,oa as b}from"./chunk-RJ6JA2LZ.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-FJSRFLJC.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as C}from"./chunk-RFIPLBQ4.js";import{c as D}from"./chunk-SZD4C5MB.js";import{L as A,O as P,V as N,Y as q}from"./chunk-BL6L5ZBP.js";import"./chunk-5JBUCVRI.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import{k as M}from"./chunk-3XD6NC4G.js";import"./chunk-PFZVET7S.js";import"./chunk-P7OVDUA5.js";import"./chunk-UCMNH6Q6.js";import"./chunk-5SUGU2YR.js";import"./chunk-NQHQKEP5.js";import"./chunk-6ML26TIK.js";import"./chunk-HGDO3OED.js";import"./chunk-X53BNWNV.js";import"./chunk-DKGGJM6Z.js";import"./chunk-7MC7M2Y5.js";import"./chunk-VS3MKKJ5.js";import"./chunk-XNR7M4VX.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-C5IX63YF.js";import"./chunk-5RSNFPED.js";import"./chunk-3OCQA33E.js";import{H as x,I as E,V as U,W as R,Y as k,m as O,q as S}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let a=await s.items({timeline:i,kind:"video"}),r=a.items.map(m=>`${m.kind}:${m.track}:${m.start}:${m.end-m.start}`),c=async m=>{let l=await D(m,a.timeline).catch(()=>null);if(!l||!r.every(p=>l.has(p)))return null;let{session:h}=await P(m,"prproj"),u=h.timelines.find(p=>p.name===a.timeline);return u?z(h,u):null};if(a.project_path){let m=await c(a.project_path);if(m)return await T(m),{session:m,from:"the saved project (matches the live sequence)",path:a.project_path};let l=k(R(a.project_path),"Adobe Premiere Pro Auto-Save"),h=U(a.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let p of E(l))p.isFile&&p.name.startsWith(`${h}--`)&&p.name.endsWith(".prproj")&&u.push({path:k(l,p.name),mtime:(await S(k(l,p.name))).mtime?.getTime()??0})}catch{}for(let p of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await c(p.path);if(g&&await T(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(p.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:p.path}}}let e=k(await x("conform-ppro-"),"live.otio"),t=await s.export({timeline:i,out_path:e}),{session:n}=await P(t.path,t.format);if(await Z(s,n),await I(n),typeof a.drop_frame=="boolean")for(let m of n.timelines)m.is_drop_frame=a.drop_frame;await T(n);for(let m of n.timelines)for(let l of m.tracks)for(let h of l.items){let u=h;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let o=await s.model(i).then(m=>m.items.filter(l=>Object.keys(l.sizing??{}).length).map(l=>`${l.name??l.file_path.split("/").pop()} (V${l.track} @${l.start-m.start_frame})`)).catch(()=>[]),f=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${o.length?` \u2014 ${o.length} clip(s) here have Motion that will not carry: ${o.slice(0,6).join(", ")}${o.length>6?"\u2026":""}`:""}; save the project (or wait for its auto-save) and run it again for every one of them`;return{session:n,from:"Premiere's OTIO export of the live sequence (no saved or auto-saved copy matches it yet)",path:t.path,lossy:f}}async function T(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let c=y(r);c&&await S(c).then(e=>e.isFile,()=>!1)&&i.add(R(c))}let a=s;for(let r of i){let c=await C(a,{media_root:r,gather:"path",criteria:{file_name:!0,file_name_mode:"tight"},lane:"both",reset:!1,dry_run:!1,compare:!1,cap:2e3,remember:!1}).catch(()=>null);c?.changed&&(a=c.session)}return a!==s&&Object.assign(s,a),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function I(s){let i=0;for(let a of s.media_references??[]){if(a.source_resolution_w)continue;let r=y(a),c=r?await M(r).catch(()=>null):null;if(!c)continue;let e=c;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&a[t]==null&&(a[t]=e[t]);a.source_fps??=e.source_fps??null,a.source_timecode??=e.source_timecode??null,!a.available_range&&e.available_range&&(a.available_range=e.available_range),i++}return i}async function ie(s,i){let a=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!a.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],c=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of a){let n=c.get(t.offline_reference.clip_id);if(n?.file){let o=i.media_references.find(f=>y(f)===n.file);o||(o={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(o)),t.offline_reference.media_reference_id=o.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:o}=await import("./store-ZHXLQCGN.js"),f=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),m=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:f}:{clip_id:n.id,out_path:f}),{session:l}=await P(m.path,"drt");l=(await A(l))?.session??l,t.offline_reference.session_id=(await o(l,m.path,"drt")).id,e++}else t.offline_reference=null}return e}async function Z(s,i){let a=(await s.projectClips()).clips,r=new Map(a.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),c=0;for(let e of i.media_references??[]){if(e.source_timecode)continue;let t=r.get(y(e));if(t){e.source_timecode=F(t.start_frame,t.fps),e.source_fps??=t.fps,c++;continue}let n=y(e),o=n?await M(n).catch(()=>null):null;o?.source_timecode&&(e.source_timecode=o.source_timecode,e.source_fps??=o.source_fps??null,c++)}return c}function z(s,i){let a=new Map(s.timelines.map(c=>[c.id,c])),r=[i];for(let c=0;c<r.length;c++)for(let e of r[c].tracks)for(let t of e.items){let n=t.nested_timeline_id,o=n?a.get(n):void 0;o&&!r.includes(o)&&r.push(o)}return{...s,timelines:r}}function V(s,i){let a=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let o=a.get(n.id),f=y(n);o!==void 0&&f&&f!==o&&r.push({ref_id:n.id,old:o,new:f})}let c=new Map(r.map(n=>[n.ref_id,n])),e=[],t=i.timelines.find(n=>n.kind==="primary")??i.timelines[0];for(let n of t?.tracks??[])if(n.kind==="Video")for(let o of n.items){let f=o.media_reference_id?c.get(o.media_reference_id):void 0;!f||o.kind!=="clip"||!o.source_range||e.push({track:n.track_index,start:o.timeline_range.start.value,duration:o.timeline_range.duration.value,src_in:o.source_range.start.value,path:f.new,name:o.name??""})}return{media:r,cuts:e}}async function se(s,i){let{session:a,from:r,lossy:c}=await H(s,i.timeline),e=await C(structuredClone(a),{media_root:i.media_root,gather:"walk",reset:!0,lane:"video",dry_run:!1,cap:2e3,criteria:i.criteria??(i.mode==="cut_in"?{file_name:!1,reel_name:!0}:{file_name:!0,file_name_mode:"loose"}),tolerances:i.tolerances}),{media:t,cuts:n}=V(a,e.session),o=[`read from ${r}`,...c&&i.mode==="new_version"?[`\u26A0 ${c}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],f=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...o,...f,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
3
+ import{a as C}from"./chunk-S5JDS5PQ.js";import{c as D}from"./chunk-SNTAZJ5A.js";import{L as A,O as P,V as N,Y as q}from"./chunk-5WEZRGXG.js";import"./chunk-P2LL3JMC.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import{k as M}from"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-NAFLOZER.js";import"./chunk-PHAMF4JF.js";import{H as x,I as E,V as U,W as R,Y as k,m as O,q as S}from"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let a=await s.items({timeline:i,kind:"video"}),r=a.items.map(m=>`${m.kind}:${m.track}:${m.start}:${m.end-m.start}`),c=async m=>{let l=await D(m,a.timeline).catch(()=>null);if(!l||!r.every(p=>l.has(p)))return null;let{session:h}=await P(m,"prproj"),u=h.timelines.find(p=>p.name===a.timeline);return u?z(h,u):null};if(a.project_path){let m=await c(a.project_path);if(m)return await T(m),{session:m,from:"the saved project (matches the live sequence)",path:a.project_path};let l=k(R(a.project_path),"Adobe Premiere Pro Auto-Save"),h=U(a.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let p of E(l))p.isFile&&p.name.startsWith(`${h}--`)&&p.name.endsWith(".prproj")&&u.push({path:k(l,p.name),mtime:(await S(k(l,p.name))).mtime?.getTime()??0})}catch{}for(let p of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await c(p.path);if(g&&await T(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(p.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:p.path}}}let e=k(await x("conform-ppro-"),"live.otio"),t=await s.export({timeline:i,out_path:e}),{session:n}=await P(t.path,t.format);if(await Z(s,n),await I(n),typeof a.drop_frame=="boolean")for(let m of n.timelines)m.is_drop_frame=a.drop_frame;await T(n);for(let m of n.timelines)for(let l of m.tracks)for(let h of l.items){let u=h;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let o=await s.model(i).then(m=>m.items.filter(l=>Object.keys(l.sizing??{}).length).map(l=>`${l.name??l.file_path.split("/").pop()} (V${l.track} @${l.start-m.start_frame})`)).catch(()=>[]),f=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${o.length?` \u2014 ${o.length} clip(s) here have Motion that will not carry: ${o.slice(0,6).join(", ")}${o.length>6?"\u2026":""}`:""}; save the project (or wait for its auto-save) and run it again for every one of them`;return{session:n,from:"Premiere's OTIO export of the live sequence (no saved or auto-saved copy matches it yet)",path:t.path,lossy:f}}async function T(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let c=y(r);c&&await S(c).then(e=>e.isFile,()=>!1)&&i.add(R(c))}let a=s;for(let r of i){let c=await C(a,{media_root:r,gather:"path",criteria:{file_name:!0,file_name_mode:"tight"},lane:"both",reset:!1,dry_run:!1,compare:!1,cap:2e3,remember:!1}).catch(()=>null);c?.changed&&(a=c.session)}return a!==s&&Object.assign(s,a),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function I(s){let i=0;for(let a of s.media_references??[]){if(a.source_resolution_w)continue;let r=y(a),c=r?await M(r).catch(()=>null):null;if(!c)continue;let e=c;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&a[t]==null&&(a[t]=e[t]);a.source_fps??=e.source_fps??null,a.source_timecode??=e.source_timecode??null,!a.available_range&&e.available_range&&(a.available_range=e.available_range),i++}return i}async function ie(s,i){let a=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!a.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],c=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of a){let n=c.get(t.offline_reference.clip_id);if(n?.file){let o=i.media_references.find(f=>y(f)===n.file);o||(o={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(o)),t.offline_reference.media_reference_id=o.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:o}=await import("./store-7IOEBOZY.js"),f=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),m=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:f}:{clip_id:n.id,out_path:f}),{session:l}=await P(m.path,"drt");l=(await A(l))?.session??l,t.offline_reference.session_id=(await o(l,m.path,"drt")).id,e++}else t.offline_reference=null}return e}async function Z(s,i){let a=(await s.projectClips()).clips,r=new Map(a.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),c=0;for(let e of i.media_references??[]){if(e.source_timecode)continue;let t=r.get(y(e));if(t){e.source_timecode=F(t.start_frame,t.fps),e.source_fps??=t.fps,c++;continue}let n=y(e),o=n?await M(n).catch(()=>null):null;o?.source_timecode&&(e.source_timecode=o.source_timecode,e.source_fps??=o.source_fps??null,c++)}return c}function z(s,i){let a=new Map(s.timelines.map(c=>[c.id,c])),r=[i];for(let c=0;c<r.length;c++)for(let e of r[c].tracks)for(let t of e.items){let n=t.nested_timeline_id,o=n?a.get(n):void 0;o&&!r.includes(o)&&r.push(o)}return{...s,timelines:r}}function V(s,i){let a=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let o=a.get(n.id),f=y(n);o!==void 0&&f&&f!==o&&r.push({ref_id:n.id,old:o,new:f})}let c=new Map(r.map(n=>[n.ref_id,n])),e=[],t=i.timelines.find(n=>n.kind==="primary")??i.timelines[0];for(let n of t?.tracks??[])if(n.kind==="Video")for(let o of n.items){let f=o.media_reference_id?c.get(o.media_reference_id):void 0;!f||o.kind!=="clip"||!o.source_range||e.push({track:n.track_index,start:o.timeline_range.start.value,duration:o.timeline_range.duration.value,src_in:o.source_range.start.value,path:f.new,name:o.name??""})}return{media:r,cuts:e}}async function se(s,i){let{session:a,from:r,lossy:c}=await H(s,i.timeline),e=await C(structuredClone(a),{media_root:i.media_root,gather:"walk",reset:!0,lane:"video",dry_run:!1,cap:2e3,criteria:i.criteria??(i.mode==="cut_in"?{file_name:!1,reel_name:!0}:{file_name:!0,file_name_mode:"loose"}),tolerances:i.tolerances}),{media:t,cuts:n}=V(a,e.session),o=[`read from ${r}`,...c&&i.mode==="new_version"?[`\u26A0 ${c}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],f=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...o,...f,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
4
4
  `).slice(-6).join(`
5
5
  `)].filter(Boolean).join(`
6
6
  `),data:{media:t,cuts:n,from:r}};if(i.mode==="replace"||i.mode==="hires"||i.mode==="proxy"){let p=(await s.projectClips()).clips.flatMap(w=>t.filter(v=>v.old===w.file).map(v=>({clip:w.id,path:v.new,mode:i.mode}))),g=i.mode==="replace"?W(a,e.session,t):new Map,_=g.size?await X(s,new Set(g.keys())):[],b=await s.relinkClips(p),d=b.results.filter(w=>w.ok).length,$=[...o,`${i.mode==="hires"?"attached full-res behind":i.mode==="proxy"?"attached as proxies to":"repointed"} ${d}/${p.length} project clip(s)${i.mode==="proxy"?" (Toggle Proxies in Premiere switches)":""}`,...f,...b.results.filter(w=>!w.ok).map(w=>` refused: ${w.detail??"Premiere refused"}`)],j=_.length?await Y(s,_,g):null;return j&&$.push(...j.lines),{text:$.join(`
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{f as a,g as b,h as c,i as d,j as e}from"./chunk-EUBXH67N.js";import"./chunk-SNTAZJ5A.js";import"./chunk-TXQR2HI2.js";import"./chunk-5WEZRGXG.js";import"./chunk-P2LL3JMC.js";import"./chunk-PFISREY4.js";import"./chunk-JV7TZDKJ.js";import"./chunk-VIBEEWPC.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-RGMTLNMF.js";import"./chunk-D4WPRRBT.js";import"./chunk-WN53ARHJ.js";import"./chunk-A7FNR3T5.js";import"./chunk-J2JXLEAI.js";import"./chunk-SGLQY53R.js";import"./chunk-DKGGJM6Z.js";import"./chunk-AMRJXYL4.js";import"./chunk-3D3Z4TBR.js";import"./chunk-2BPR6LK6.js";import"./chunk-NU3X7P4N.js";import"./chunk-RJ6JA2LZ.js";import"./chunk-NAFLOZER.js";import"./chunk-PHAMF4JF.js";import"./chunk-PLRB2YXJ.js";import"./chunk-C2ESM27Z.js";import"./chunk-PSANHDZM.js";export{a as AVID_SETUP,b as FLAME_SETUP,c as NUKE_SETUP,e as adapter,d as setAdapter};