conformtools 0.6.22 → 0.6.23

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 (58) hide show
  1. package/dist/{agent-hook-setup-ZY4UBZIG.js → agent-hook-setup-IACTYSVL.js} +1 -1
  2. package/dist/{bridge-56MINHUF.js → bridge-6XEVB67I.js} +1 -1
  3. package/dist/browser/timeline_core_bg.wasm +0 -0
  4. package/dist/{chunk-OVBFJOO2.js → chunk-3AR7KSPH.js} +1 -1
  5. package/dist/{chunk-64AMZWOI.js → chunk-3LGFQ42R.js} +1 -1
  6. package/dist/{chunk-REGL3GQB.js → chunk-5JDF2IUF.js} +1 -1
  7. package/dist/{chunk-Z3LQ56WS.js → chunk-5VQ2IHWO.js} +1 -1
  8. package/dist/{chunk-JUJESM4P.js → chunk-6U2DUMIM.js} +1 -1
  9. package/dist/{chunk-QNVFSA7C.js → chunk-BHBBS26Z.js} +1 -1
  10. package/dist/{chunk-4I4MV3DE.js → chunk-DCO5D65W.js} +1 -1
  11. package/dist/{chunk-65SLDY2M.js → chunk-DESBZZGR.js} +92 -92
  12. package/dist/{chunk-JGI5YEGH.js → chunk-EZYCCYY7.js} +1 -1
  13. package/dist/{chunk-DHDSDH6R.js → chunk-GN5T5S6K.js} +2 -2
  14. package/dist/chunk-IDADYIY6.js +7 -0
  15. package/dist/{chunk-BFN565RJ.js → chunk-ISG6PEOD.js} +1 -1
  16. package/dist/{chunk-6C3EEZH3.js → chunk-KDNIWB5V.js} +1 -1
  17. package/dist/{chunk-M3DXHHD7.js → chunk-LBROV5JN.js} +1 -1
  18. package/dist/{chunk-REBF4U5B.js → chunk-NQDVV2PX.js} +1 -1
  19. package/dist/{chunk-FSXF4K3J.js → chunk-Q72JSDNU.js} +1 -1
  20. package/dist/{chunk-PKKUIGZ5.js → chunk-V6MI7VE3.js} +1 -1
  21. package/dist/{chunk-ZCQTIYXB.js → chunk-XIFURVIB.js} +1 -1
  22. package/dist/{chunk-TFKKODSA.js → chunk-XX7QQIBI.js} +1 -1
  23. package/dist/{chunk-CHEQJC4U.js → chunk-ZEVOSOP4.js} +187 -186
  24. package/dist/{chunk-O5HYVCFL.js → chunk-ZNUIZEPF.js} +1 -1
  25. package/dist/cli.js +2 -2
  26. package/dist/{cr3-wasm-HWPQ3QAN.js → cr3-wasm-CQ5YEFUF.js} +1 -1
  27. package/dist/{demo-engine-MOHHYVGV.js → demo-engine-O5T6QRYL.js} +1 -1
  28. package/dist/{dng-wasm-D7HO2OUE.js → dng-wasm-K6PWOV4P.js} +1 -1
  29. package/dist/{dpx-wasm-ASRFRLRT.js → dpx-wasm-RJZANW6N.js} +1 -1
  30. package/dist/{engine-WMOJ3HRU.js → engine-WEGECPAH.js} +2 -2
  31. package/dist/{exr-wasm-Y53DGEKJ.js → exr-wasm-EZY3GZ2L.js} +1 -1
  32. package/dist/{framing-JYGNU6TH.js → framing-V3AI35RV.js} +1 -1
  33. package/dist/gfx-worker.js +1 -1
  34. package/dist/{h264-ZJCLCYYY.js → h264-KMDAFD3Q.js} +1 -1
  35. package/dist/{h264-mxf-BI4ACQUH.js → h264-mxf-IJYHBYKB.js} +1 -1
  36. package/dist/hook.js +3 -3
  37. package/dist/{host-relink-XMVOQYKN.js → host-relink-IDTSHA4V.js} +1 -1
  38. package/dist/hosts-5VFREDGW.js +3 -0
  39. package/dist/http.js +2 -2
  40. package/dist/{inspect-4RF2SDJR.js → inspect-VS5N6SKX.js} +15 -15
  41. package/dist/isobmff-4FUKPUL3.js +3 -0
  42. package/dist/{mc-video-IUPFHPIS.js → mc-video-DTMHUECT.js} +1 -1
  43. package/dist/mcp.js +1 -1
  44. package/dist/{media-R677IADY.js → media-3XXQBZNW.js} +1 -1
  45. package/dist/{mxf-IUCZVILV.js → mxf-LGRSWF7S.js} +1 -1
  46. package/dist/{ops-L5X3Q6SQ.js → ops-QAML7C35.js} +1 -1
  47. package/dist/{r3d-EIQEVYGC.js → r3d-AWQQHTQC.js} +1 -1
  48. package/dist/{r3d-VBXKIIRY.js → r3d-OL6DVR3C.js} +1 -1
  49. package/dist/{still-XAFHXXC3.js → still-CDF26BQZ.js} +1 -1
  50. package/dist/{still-wasm-ZG6PA67L.js → still-wasm-3EBYMLVL.js} +1 -1
  51. package/dist/{tiff-wasm-AHQJJAK2.js → tiff-wasm-JIBA5AI4.js} +1 -1
  52. package/dist/{timeline-LJYGRP3R.js → timeline-BAMMSL7B.js} +1 -1
  53. package/dist/wasm/media_core_bg.wasm +0 -0
  54. package/dist/{wav-4COVRAK3.js → wav-N6EWJR2P.js} +1 -1
  55. package/package.json +5 -5
  56. package/dist/chunk-QPSQQEO6.js +0 -7
  57. package/dist/hosts-ZPBLYFYP.js +0 -3
  58. package/dist/isobmff-FZBZCEYH.js +0 -3
@@ -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{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m}from"./chunk-QPSQQEO6.js";import"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";export{a as CLIENTS,j as WHAT_IT_RECORDS,f as clientsHere,b as hookFiles,i as hookInstalled,l as hooksRemovedText,m as hooksStatusText,k as hooksText,d as installAgentHook,g as installAllAgentHooks,c as installHookScript,e as removeAgentHook,h as removeAllAgentHooks};
3
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m}from"./chunk-IDADYIY6.js";import"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";export{a as CLIENTS,j as WHAT_IT_RECORDS,f as clientsHere,b as hookFiles,i as hookInstalled,l as hooksRemovedText,m as hooksStatusText,k as hooksText,d as installAgentHook,g as installAllAgentHooks,c as installHookScript,e as removeAgentHook,h as removeAllAgentHooks};
@@ -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{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h}from"./chunk-FSXF4K3J.js";import"./chunk-JUJESM4P.js";import"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";export{c as BridgeError,g as HostBridge,e as PANEL_PREFIX,b as PORTS,a as PROTOCOL,h as hostBridge,d as pairingPath,f as panelOrigins};
3
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h}from"./chunk-Q72JSDNU.js";import"./chunk-6U2DUMIM.js";import"./chunk-ZPIY5DOU.js";import"./chunk-PSANHDZM.js";export{c as BridgeError,g as HostBridge,e as PANEL_PREFIX,b as PORTS,a as PROTOCOL,h as hostBridge,d as pairingPath,f as panelOrigins};
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{c as r,d as t}from"./chunk-VFXMP7IF.js";import{i}from"./chunk-REGL3GQB.js";async function d(e){if(!r(e.name))return null;try{return await i(t(e),{verb:"inspect"})}catch(n){return console.warn(`[probeMedia] ${e.name} probe failed:`,n),null}}export{d as a};
3
+ import{c as r,d as t}from"./chunk-VFXMP7IF.js";import{i}from"./chunk-5JDF2IUF.js";async function d(e){if(!r(e.name))return null;try{return await i(t(e),{verb:"inspect"})}catch(n){return console.warn(`[probeMedia] ${e.name} probe failed:`,n),null}}export{d as a};
@@ -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{Rb as F,Sb as N,Vb as D}from"./chunk-65SLDY2M.js";import{i as j}from"./chunk-FSXF4K3J.js";import{B as E,C as M,G as C,I as R,J as T,N as q,O as L,R as w,aa as b,ca as k,da as _,fa as I,h as y,o as O,t as S,u as A,v as x,w as P,z as H}from"./chunk-ZPIY5DOU.js";var W=16e3,h=class extends Error{constructor(t,s){super(s);this.code=t}},$=class p{constructor(e,t=j,s=W){this.spec=e;this.bridge=t;this.waitMs=s;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={},s){return await this.peer(),await(await this.bridge()).request(this.host,e,t,s)}static{this.announced=(e,t)=>e.optional_verbs.includes(t)}async support(){let e;try{e=await(await this.bridge()).waitFor(this.host,Math.min(3e3,this.waitMs))}catch(n){let o={ok:!1,reason:n instanceof Error?n.message:String(n)};return{export:o,open:o,render:o,markers:o}}if(!e){let n={ok:!1,reason:`the conform.tools plugin in ${this.spec.label} is not connected`,setup:this.spec.setup};return{export:n,open:n,render:n,markers:n}}let t=(n,o)=>n?{ok:!0}:{ok:!1,reason:`this plugin version has no ${o}`},s=e.capabilities;return{export:t(s.includes("timeline_read")||s.includes("timeline_write"),"timeline_read"),open:t(p.announced(e,"timeline_write.import_file"),"timeline_write.import_file"),render:t(s.includes("render"),"render"),markers:t(s.includes("markers"),"markers")}}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}),s=[];for(let o=1;o<=t;o++){let l=await this.ask("session.timeline_by_index",{project:e,index:o});l&&s.push(await this.ask("session.name",{handle:l}))}let n=await this.ask("session.current_timeline",{project:e});return{project:await this.ask("session.name",{handle:e}),timelines:s,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 o=await this.ask("session.current_timeline",{project:t});if(!o)throw new h("no_timeline",`${this.host}: no timeline is active`);return{project:t,seq:o,name:await this.ask("session.name",{handle:o})}}let s=await this.ask("session.timeline_count",{project:t}),n=[];for(let o=1;o<=s;o++){let l=await this.ask("session.timeline_by_index",{project:t,index:o});if(!l)continue;let d=await this.ask("session.name",{handle:l});if(d===e)return{project:t,seq:l,name:d};n.push(d)}throw new h("not_found",`${this.host}: no timeline named "${e}" (have: ${n.join(", ")})`)}async model(e){let{project:t,seq:s}=await this.sequence(e);return await this.ask("timeline_read.model",{timeline:s,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:s,seq:n,name:o}=await this.sequence(e.timeline),l=await this.ask("session.name",{handle:s}),d=r=>p.announced(t,r),m=e.out_path,c,a=[];if(d("timeline_write.export_otio")||d("timeline_write.export_xml")){let r=d("timeline_write.export_otio"),i=await this.ask(r?"timeline_write.export_otio":"timeline_write.export_xml",{project:s,timeline:n,path:e.out_path},12e4);if(c=i.format??(r?"otio":"xmeml"),i.ok===!1)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${e.out_path}${i.errors?.length?` (${i.errors.join("; ")})`:""}`);i.path&&i.path!==e.out_path&&(m=await this.adopt(i.path,e.out_path)),a=i.warnings??[]}else if(d("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`);c="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:s},12e4),i=J(r);await E(e.out_path,JSON.stringify(i.otio)),c="otio",a=i.notes}if(!F.includes(c))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${c}, which the engine does not read (${m})`);if(!await P(m)||(await A(m)).size===0)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${m}`);return{path:m,format:c,project:l,timeline:o,...a.length?{notes:a}:{}}}async adopt(e,t){let s=k(e)&&k(e)!==k(t)?t.slice(0,t.length-k(t).length)+k(e):t;if(await C(e,s),!N(s))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${b(e)}, which the engine does not read`);return s}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(!p.announced(t,"timeline_write.import_file"))throw new h("unsupported",`${this.host}: this conform.tools plugin cannot import timelines (${this.spec.setup})`);let s=await this.ask("session.current_project");if(!s)throw new h("no_project",`${this.host}: no project is open`);let n=await this.ask("timeline_write.import_file",{project:s,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 o=[...n.issues??[]];return n.imported.length>1&&o.push(`imported ${n.imported.length} timelines: ${n.imported.map(l=>l.name).join(", ")}`),e.name&&o.push(`${this.spec.label} names imported timelines after the file's own; name was not applied`),e.media_dirs?.length&&o.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:s}),timeline:n.imported[0]?.name??b(e.path),notes:o,restored:!e.stay,...n.bin?{folder:n.bin}:{}}}async modelItems(e){let t=await this.model(e.timeline),s=[...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:s,color_groups:[],layers:1}}async apply(e){let t=e.ops.length>0&&e.ops.every(a=>a.op==="timeline_rename"&&(a.timeline||a.guid)),{project:s,seq:n,name:o}=await this.sequence(t?void 0:e.timeline),l=[],d=[],m=a=>a.op.startsWith("marker_")&&!a.item;for(let a=0;a<e.ops.length;){let r=a;for(;r<e.ops.length&&m(e.ops[r])===m(e.ops[a]);)r++;let i=e.ops.slice(a,r),u=m(i[0])?await this.markerOps(n,i):await this.clipOps(n,i,e.timeline);l.push(...u.results),d.unshift(...u.undo),a=r}let c=l.filter(a=>a.ok).length;return{project:await this.ask("session.name",{handle:s}),timeline:o,results:l,undo:d,applied:c,failed:l.length-c}}async clipOps(e,t,s){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 o=(a,r)=>({op:a.op,ok:!1,detail:r});if(!n.capabilities.includes("item_meta"))return{results:t.map(a=>o(a,`${this.host}: clip edits are not reachable over this plugin`)),undo:[]};let l=await this.model(s),d=a=>a?"id"in a?{$h:a.id}:(a.kind??"video")!=="video"?null:l.items.find(r=>r.track===a.track&&r.start-l.start_frame===a.start)?.handle??null:null,m=[],c=[];for(let a of t){let r=d(a.item);try{if(!r)m.push(o(a,`no video item at ${JSON.stringify(a.item??null)}`));else if(a.op==="clip_color"){let i=await this.ask("item_meta.color",{handle:r}),u=a.color?await this.ask("item_meta.set_color",{handle:r,color:a.color}):await this.ask("item_meta.clear_color",{handle:r});m.push({op:a.op,ok:u}),u&&c.unshift({op:"clip_color",item:a.item,color:i})}else if(a.op==="enabled"&&p.announced(n,"item_meta.set_enabled")){let i=l.items.find(f=>f.handle?.$h===r.$h)?.enabled??!0,u=await this.ask("item_meta.set_enabled",{item:r,enabled:!!a.on});m.push({op:a.op,ok:u}),u&&c.unshift({op:"enabled",item:a.item,on:i})}else m.push(o(a,`${this.host}: '${a.op}' is not reachable over this plugin`))}catch(i){m.push(o(a,i instanceof Error?i.message:String(i)))}}return{results:m,undo:c}}async markerOps(e,t){let s=await this.peer(),n=r=>p.announced(s,r),o=new Map((await this.ask("markers.list",{target:e})).map(r=>[r.frame,r])),l=[],d=[],m=async r=>{let i=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 i&&o.set(r.frame,{color:"",name:"",note:"",duration:1,...r}),i},c=async r=>{let i=await this.ask("markers.delete_at",{target:e,frame:r});return i&&o.delete(r),i},a=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 i=Number(r.frame);try{if(r.op==="marker_add"){let u=o.get(i);u&&await c(i);let f=await m({frame:i,color:r.color,name:r.name,note:r.note,duration:Number(r.duration??1),custom_data:r.data});l.push({op:r.op,ok:f}),f&&d.unshift(...u?[a(u)]:[],{op:"marker_delete",frame:i})}else if(r.op==="marker_update"){let u=o.get(i);if(!u){l.push({op:r.op,ok:!1,detail:`no marker at frame ${i}`});continue}let f=r.to_frame!==void 0?Number(r.to_frame):i,v={...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:i,color:r.color})&&g),(r.name!==void 0||r.note!==void 0)&&(g=await this.ask("markers.set_text",{target:e,frame:i,name:r.name,note:r.note})&&g),f!==i&&(g=await this.ask("markers.move",{target:e,frame:i,to_frame:f})&&g),o.delete(i),o.set(f,v)):g=await c(i)&&await m(v),l.push({op:r.op,ok:g}),d.unshift({op:"marker_update",frame:f,color:u.color,name:u.name,note:u.note,...f!==i?{to_frame:i}:{}})}else if(r.op==="marker_delete"){let u=o.get(i),f=!!u&&await c(i);l.push({op:r.op,ok:f,...u?{}:{detail:`no marker at frame ${i}`}}),f&&u&&d.unshift(a(u))}else l.push({op:r.op,ok:!1,detail:`${this.host}: '${r.op}' is not reachable over this plugin`})}catch(u){l.push({op:r.op,ok:!1,detail:u instanceof Error?u.message:String(u)})}}return{results:l,undo:d}}async renderStart(e){if(await this.needs("render"),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:s}=await this.sequence(e.timeline),n=e.name??s,o={purpose:"deliver",format:"preset",preset:e.preset,target_dir:e.target_dir,name:n,...e.range?{range:[e.range.in,e.range.out]}:{}},l=await this.ask("render.submit",{timeline:t,job:o});if(!l?.id)throw new h("render_refused",`${this.host}: ${l?.error??`${this.spec.label} refused the render`}`);if(!await this.ask("render.start",{job_ids:[l.id]}))throw new h("render_refused",`${this.host}: ${this.spec.label} did not start job ${l.id}`);return this.renders.set(l.id,{dir:e.target_dir,name:n}),{job_id:l.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 s={done:"complete",rendering:"rendering",queued:"queued",failed:"failed",cancelled:"cancelled"}[t.state]??"rendering",n={job_id:e,state:s,percent:Math.round(t.progress??(s==="complete"?100:0)),...t.error?{error:t.error}:{}};if(s==="complete"||s==="failed"||s==="cancelled"){let o=this.renders.get(e);s==="complete"&&o&&(n.outputs=await V(o.dir,o.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 V(p,e){let t=[];try{for await(let s of L(p))s.isFile&&s.name.startsWith(`${e}.`)&&t.push(_(p,s.name))}catch{}return t.sort()}function J(p){let e=(c,a)=>({OTIO_SCHEMA:"RationalTime.1",value:c,rate:a}),t=(c,a,r,i=r)=>({OTIO_SCHEMA:"TimeRange.1",start_time:e(c,r),duration:e(a,i)}),s=p.fps,n=p.tracks?.length?p.tracks:[...new Set(p.items.map(c=>c.track))].sort((c,a)=>c-a).map(c=>({index:c,enabled:!0,name:"",items:p.items.filter(a=>a.track===c)})),o=c=>(c.reversed?-1:1)*(c.speed||1)/(c.fps_factor||1),l=new Map;for(let c of p.items)if(c.file_path&&c.start_tc!=null&&c.src_abs_in!=null){let a=c.src_abs_in-c.start_tc+Math.ceil((c.end-c.start)*Math.abs(o(c))*(c.fps_factor||1));l.set(c.file_path,Math.max(l.get(c.file_path)??0,a))}let d=n.map(c=>{let a=p.start_frame,r=[];for(let i of[...c.items].sort((u,f)=>u.start-f.start)){if(i.start<a)continue;i.start>a&&r.push({OTIO_SCHEMA:"Gap.1",name:"",source_range:t(0,i.start-a,s)});let u=i.src_fps||s,f=i.start_tc!=null&&l.has(i.file_path)?i.start_tc:null,v=f!=null?i.src_abs_in:i.src_in??i.src_abs_in??0,g=o(i);r.push({OTIO_SCHEMA:"Clip.2",name:i.name??b(i.file_path||""),enabled:i.enabled!==!1,source_range:t(v,i.end-i.start,u,s),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",name:b(i.file_path||""),target_url:i.file_path?`file://${i.file_path}`:"",...f!=null?{available_range:t(f,l.get(i.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:i.reel?{cmx_3600:{reel:i.reel}}:{}}),a=i.end}return{OTIO_SCHEMA:"Track.1",name:c.name||`V${c.index}`,kind:"Video",enabled:c.enabled!==!1,children:r,effects:[],markers:[],metadata:{}}}),m=[];return p.audio_items?.length&&m.push(`${p.audio_items.length} audio clip(s) not carried: the host's plugin reports no audio source times`),p.transitions?.length&&m.push(`${p.transitions.length} transition(s) not carried (cuts in their place)`),{otio:{OTIO_SCHEMA:"Timeline.1",name:p.timeline,global_start_time:e(p.start_frame,s),metadata:{},tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",children:d,effects:[],markers:[],metadata:{}}},notes:m}}var X=16e3,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 ${constructor(t=j,s=X){super({host:"premiere",label:"Premiere Pro",setup:G},t,s);this.items=async(t={})=>{await this.needs("edit");let{seq:s}=await this.sequence(t.timeline),n=await this.ask("edit.items",{timeline:s,kind:t.kind,track:t.track},12e4),o=n.project_path?await K(n.project_path,n.timeline).catch(d=>({error:d instanceof Error?d.message:String(d)})):{error:"the project has never been saved"},l=0;if(!("error"in o))for(let d of n.items){let m=o.get(`${d.kind}:${d.track}:${d.start}:${Number(d.end)-Number(d.start)}`);m?Object.assign(d,m,{saved:!0}):(d.saved=!1,l++)}return{...n,color_groups:[],layers:1,..."error"in o?{saved_note:`saved project not read: ${o.error}`}:{unsaved_items:l}}};this.premiereRenders=new Map}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async liveMarkers(t){if(!$.announced(await this.peer(),"edit.markers"))return null;let{seq:s}=await this.sequence(t);return await this.ask("edit.markers",{timeline:s},12e4)}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,s){await this.needs("edit");let{seq:n}=await this.sequence(t);return await this.ask("edit.cut_in",{timeline:n,cuts:s},12e4+s.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:s,name:n}=await this.sequence(t.timeline);await M(t.target_dir);let o=_(t.target_dir,`${t.name??n}.mov`),l=await this.ask("render.export_sequence",{timeline:s,output_path:o,preset_path:t.preset,queue:!1},6e4);if(!l.ok)throw new h("render_refused","premiere: Premiere refused the export");let d=l.job||`ppro-${Date.now()}`;return this.premiereRenders.set(d,o),{job_id:d,state:"rendering",percent:0}}async renderStatus(t){let s=await this.ask("render.progress"),n=s[t]??s.last,o=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"||o&&await x(o)&&!n?{job_id:t,state:"complete",percent:100,...o?{outputs:[o]}:{}}:{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(p,e){let{session:t}=await D(p,"prproj"),s=t.timelines.find(o=>o.name===e),n=new Map;if(!s)throw new Error(`the saved project has no sequence "${e}" (saved before it was made?)`);for(let o of s.tracks)if(!(o.kind!=="Video"&&o.kind!=="Audio"))for(let l of o.items){if(l.kind==="gap"||l.kind==="transition")continue;let d=l;n.set(`${o.kind==="Video"?"video":"audio"}:${o.track_index}:${l.timeline_range.start.value}:${l.timeline_range.duration.value}`,{saved_id:l.id,...d.speed_factor!=null&&d.speed_factor!==1?{retime:d.speed_factor}:{},...d.speed_ramped?{ramped:!0}:{},...d.speed_reverse?{reversed:!0}:{},...l.kind==="nested"?{nested:!0}:{},...d.is_multicam?{multicam:!0}:{},...d.effects?.some(m=>/stabiliz/i.test(m.kind??""))?{stabilized:!0}:{},...d.effects?.length?{saved_effects:d.effects.map(m=>m.name??m.kind??"")}:{}})}return n}function z(p=y()){return p==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":p==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function B(){for(let p of["./uxp-plugin/","./premiere-uxp/"]){let e=S(new URL(p,import.meta.url));if(await P(_(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 B(),"manifest.json"))).version}async function oe(p=y()){let e=z(p);if(!e||!await x(e))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let t=await w(e,p==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),s=t.stdout.split(`
3
+ import{Rb as F,Sb as N,Vb as D}from"./chunk-DESBZZGR.js";import{i as j}from"./chunk-Q72JSDNU.js";import{B as E,C as M,G as C,I as R,J as T,N as q,O as L,R as w,aa as b,ca as k,da as _,fa as I,h as y,o as O,t as S,u as A,v as x,w as P,z as H}from"./chunk-ZPIY5DOU.js";var W=16e3,h=class extends Error{constructor(t,s){super(s);this.code=t}},$=class p{constructor(e,t=j,s=W){this.spec=e;this.bridge=t;this.waitMs=s;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={},s){return await this.peer(),await(await this.bridge()).request(this.host,e,t,s)}static{this.announced=(e,t)=>e.optional_verbs.includes(t)}async support(){let e;try{e=await(await this.bridge()).waitFor(this.host,Math.min(3e3,this.waitMs))}catch(n){let o={ok:!1,reason:n instanceof Error?n.message:String(n)};return{export:o,open:o,render:o,markers:o}}if(!e){let n={ok:!1,reason:`the conform.tools plugin in ${this.spec.label} is not connected`,setup:this.spec.setup};return{export:n,open:n,render:n,markers:n}}let t=(n,o)=>n?{ok:!0}:{ok:!1,reason:`this plugin version has no ${o}`},s=e.capabilities;return{export:t(s.includes("timeline_read")||s.includes("timeline_write"),"timeline_read"),open:t(p.announced(e,"timeline_write.import_file"),"timeline_write.import_file"),render:t(s.includes("render"),"render"),markers:t(s.includes("markers"),"markers")}}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}),s=[];for(let o=1;o<=t;o++){let l=await this.ask("session.timeline_by_index",{project:e,index:o});l&&s.push(await this.ask("session.name",{handle:l}))}let n=await this.ask("session.current_timeline",{project:e});return{project:await this.ask("session.name",{handle:e}),timelines:s,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 o=await this.ask("session.current_timeline",{project:t});if(!o)throw new h("no_timeline",`${this.host}: no timeline is active`);return{project:t,seq:o,name:await this.ask("session.name",{handle:o})}}let s=await this.ask("session.timeline_count",{project:t}),n=[];for(let o=1;o<=s;o++){let l=await this.ask("session.timeline_by_index",{project:t,index:o});if(!l)continue;let d=await this.ask("session.name",{handle:l});if(d===e)return{project:t,seq:l,name:d};n.push(d)}throw new h("not_found",`${this.host}: no timeline named "${e}" (have: ${n.join(", ")})`)}async model(e){let{project:t,seq:s}=await this.sequence(e);return await this.ask("timeline_read.model",{timeline:s,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:s,seq:n,name:o}=await this.sequence(e.timeline),l=await this.ask("session.name",{handle:s}),d=r=>p.announced(t,r),m=e.out_path,c,a=[];if(d("timeline_write.export_otio")||d("timeline_write.export_xml")){let r=d("timeline_write.export_otio"),i=await this.ask(r?"timeline_write.export_otio":"timeline_write.export_xml",{project:s,timeline:n,path:e.out_path},12e4);if(c=i.format??(r?"otio":"xmeml"),i.ok===!1)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${e.out_path}${i.errors?.length?` (${i.errors.join("; ")})`:""}`);i.path&&i.path!==e.out_path&&(m=await this.adopt(i.path,e.out_path)),a=i.warnings??[]}else if(d("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`);c="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:s},12e4),i=J(r);await E(e.out_path,JSON.stringify(i.otio)),c="otio",a=i.notes}if(!F.includes(c))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${c}, which the engine does not read (${m})`);if(!await P(m)||(await A(m)).size===0)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${m}`);return{path:m,format:c,project:l,timeline:o,...a.length?{notes:a}:{}}}async adopt(e,t){let s=k(e)&&k(e)!==k(t)?t.slice(0,t.length-k(t).length)+k(e):t;if(await C(e,s),!N(s))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${b(e)}, which the engine does not read`);return s}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(!p.announced(t,"timeline_write.import_file"))throw new h("unsupported",`${this.host}: this conform.tools plugin cannot import timelines (${this.spec.setup})`);let s=await this.ask("session.current_project");if(!s)throw new h("no_project",`${this.host}: no project is open`);let n=await this.ask("timeline_write.import_file",{project:s,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 o=[...n.issues??[]];return n.imported.length>1&&o.push(`imported ${n.imported.length} timelines: ${n.imported.map(l=>l.name).join(", ")}`),e.name&&o.push(`${this.spec.label} names imported timelines after the file's own; name was not applied`),e.media_dirs?.length&&o.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:s}),timeline:n.imported[0]?.name??b(e.path),notes:o,restored:!e.stay,...n.bin?{folder:n.bin}:{}}}async modelItems(e){let t=await this.model(e.timeline),s=[...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:s,color_groups:[],layers:1}}async apply(e){let t=e.ops.length>0&&e.ops.every(a=>a.op==="timeline_rename"&&(a.timeline||a.guid)),{project:s,seq:n,name:o}=await this.sequence(t?void 0:e.timeline),l=[],d=[],m=a=>a.op.startsWith("marker_")&&!a.item;for(let a=0;a<e.ops.length;){let r=a;for(;r<e.ops.length&&m(e.ops[r])===m(e.ops[a]);)r++;let i=e.ops.slice(a,r),u=m(i[0])?await this.markerOps(n,i):await this.clipOps(n,i,e.timeline);l.push(...u.results),d.unshift(...u.undo),a=r}let c=l.filter(a=>a.ok).length;return{project:await this.ask("session.name",{handle:s}),timeline:o,results:l,undo:d,applied:c,failed:l.length-c}}async clipOps(e,t,s){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 o=(a,r)=>({op:a.op,ok:!1,detail:r});if(!n.capabilities.includes("item_meta"))return{results:t.map(a=>o(a,`${this.host}: clip edits are not reachable over this plugin`)),undo:[]};let l=await this.model(s),d=a=>a?"id"in a?{$h:a.id}:(a.kind??"video")!=="video"?null:l.items.find(r=>r.track===a.track&&r.start-l.start_frame===a.start)?.handle??null:null,m=[],c=[];for(let a of t){let r=d(a.item);try{if(!r)m.push(o(a,`no video item at ${JSON.stringify(a.item??null)}`));else if(a.op==="clip_color"){let i=await this.ask("item_meta.color",{handle:r}),u=a.color?await this.ask("item_meta.set_color",{handle:r,color:a.color}):await this.ask("item_meta.clear_color",{handle:r});m.push({op:a.op,ok:u}),u&&c.unshift({op:"clip_color",item:a.item,color:i})}else if(a.op==="enabled"&&p.announced(n,"item_meta.set_enabled")){let i=l.items.find(f=>f.handle?.$h===r.$h)?.enabled??!0,u=await this.ask("item_meta.set_enabled",{item:r,enabled:!!a.on});m.push({op:a.op,ok:u}),u&&c.unshift({op:"enabled",item:a.item,on:i})}else m.push(o(a,`${this.host}: '${a.op}' is not reachable over this plugin`))}catch(i){m.push(o(a,i instanceof Error?i.message:String(i)))}}return{results:m,undo:c}}async markerOps(e,t){let s=await this.peer(),n=r=>p.announced(s,r),o=new Map((await this.ask("markers.list",{target:e})).map(r=>[r.frame,r])),l=[],d=[],m=async r=>{let i=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 i&&o.set(r.frame,{color:"",name:"",note:"",duration:1,...r}),i},c=async r=>{let i=await this.ask("markers.delete_at",{target:e,frame:r});return i&&o.delete(r),i},a=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 i=Number(r.frame);try{if(r.op==="marker_add"){let u=o.get(i);u&&await c(i);let f=await m({frame:i,color:r.color,name:r.name,note:r.note,duration:Number(r.duration??1),custom_data:r.data});l.push({op:r.op,ok:f}),f&&d.unshift(...u?[a(u)]:[],{op:"marker_delete",frame:i})}else if(r.op==="marker_update"){let u=o.get(i);if(!u){l.push({op:r.op,ok:!1,detail:`no marker at frame ${i}`});continue}let f=r.to_frame!==void 0?Number(r.to_frame):i,v={...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:i,color:r.color})&&g),(r.name!==void 0||r.note!==void 0)&&(g=await this.ask("markers.set_text",{target:e,frame:i,name:r.name,note:r.note})&&g),f!==i&&(g=await this.ask("markers.move",{target:e,frame:i,to_frame:f})&&g),o.delete(i),o.set(f,v)):g=await c(i)&&await m(v),l.push({op:r.op,ok:g}),d.unshift({op:"marker_update",frame:f,color:u.color,name:u.name,note:u.note,...f!==i?{to_frame:i}:{}})}else if(r.op==="marker_delete"){let u=o.get(i),f=!!u&&await c(i);l.push({op:r.op,ok:f,...u?{}:{detail:`no marker at frame ${i}`}}),f&&u&&d.unshift(a(u))}else l.push({op:r.op,ok:!1,detail:`${this.host}: '${r.op}' is not reachable over this plugin`})}catch(u){l.push({op:r.op,ok:!1,detail:u instanceof Error?u.message:String(u)})}}return{results:l,undo:d}}async renderStart(e){if(await this.needs("render"),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:s}=await this.sequence(e.timeline),n=e.name??s,o={purpose:"deliver",format:"preset",preset:e.preset,target_dir:e.target_dir,name:n,...e.range?{range:[e.range.in,e.range.out]}:{}},l=await this.ask("render.submit",{timeline:t,job:o});if(!l?.id)throw new h("render_refused",`${this.host}: ${l?.error??`${this.spec.label} refused the render`}`);if(!await this.ask("render.start",{job_ids:[l.id]}))throw new h("render_refused",`${this.host}: ${this.spec.label} did not start job ${l.id}`);return this.renders.set(l.id,{dir:e.target_dir,name:n}),{job_id:l.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 s={done:"complete",rendering:"rendering",queued:"queued",failed:"failed",cancelled:"cancelled"}[t.state]??"rendering",n={job_id:e,state:s,percent:Math.round(t.progress??(s==="complete"?100:0)),...t.error?{error:t.error}:{}};if(s==="complete"||s==="failed"||s==="cancelled"){let o=this.renders.get(e);s==="complete"&&o&&(n.outputs=await V(o.dir,o.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 V(p,e){let t=[];try{for await(let s of L(p))s.isFile&&s.name.startsWith(`${e}.`)&&t.push(_(p,s.name))}catch{}return t.sort()}function J(p){let e=(c,a)=>({OTIO_SCHEMA:"RationalTime.1",value:c,rate:a}),t=(c,a,r,i=r)=>({OTIO_SCHEMA:"TimeRange.1",start_time:e(c,r),duration:e(a,i)}),s=p.fps,n=p.tracks?.length?p.tracks:[...new Set(p.items.map(c=>c.track))].sort((c,a)=>c-a).map(c=>({index:c,enabled:!0,name:"",items:p.items.filter(a=>a.track===c)})),o=c=>(c.reversed?-1:1)*(c.speed||1)/(c.fps_factor||1),l=new Map;for(let c of p.items)if(c.file_path&&c.start_tc!=null&&c.src_abs_in!=null){let a=c.src_abs_in-c.start_tc+Math.ceil((c.end-c.start)*Math.abs(o(c))*(c.fps_factor||1));l.set(c.file_path,Math.max(l.get(c.file_path)??0,a))}let d=n.map(c=>{let a=p.start_frame,r=[];for(let i of[...c.items].sort((u,f)=>u.start-f.start)){if(i.start<a)continue;i.start>a&&r.push({OTIO_SCHEMA:"Gap.1",name:"",source_range:t(0,i.start-a,s)});let u=i.src_fps||s,f=i.start_tc!=null&&l.has(i.file_path)?i.start_tc:null,v=f!=null?i.src_abs_in:i.src_in??i.src_abs_in??0,g=o(i);r.push({OTIO_SCHEMA:"Clip.2",name:i.name??b(i.file_path||""),enabled:i.enabled!==!1,source_range:t(v,i.end-i.start,u,s),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",name:b(i.file_path||""),target_url:i.file_path?`file://${i.file_path}`:"",...f!=null?{available_range:t(f,l.get(i.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:i.reel?{cmx_3600:{reel:i.reel}}:{}}),a=i.end}return{OTIO_SCHEMA:"Track.1",name:c.name||`V${c.index}`,kind:"Video",enabled:c.enabled!==!1,children:r,effects:[],markers:[],metadata:{}}}),m=[];return p.audio_items?.length&&m.push(`${p.audio_items.length} audio clip(s) not carried: the host's plugin reports no audio source times`),p.transitions?.length&&m.push(`${p.transitions.length} transition(s) not carried (cuts in their place)`),{otio:{OTIO_SCHEMA:"Timeline.1",name:p.timeline,global_start_time:e(p.start_frame,s),metadata:{},tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",children:d,effects:[],markers:[],metadata:{}}},notes:m}}var X=16e3,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 ${constructor(t=j,s=X){super({host:"premiere",label:"Premiere Pro",setup:G},t,s);this.items=async(t={})=>{await this.needs("edit");let{seq:s}=await this.sequence(t.timeline),n=await this.ask("edit.items",{timeline:s,kind:t.kind,track:t.track},12e4),o=n.project_path?await K(n.project_path,n.timeline).catch(d=>({error:d instanceof Error?d.message:String(d)})):{error:"the project has never been saved"},l=0;if(!("error"in o))for(let d of n.items){let m=o.get(`${d.kind}:${d.track}:${d.start}:${Number(d.end)-Number(d.start)}`);m?Object.assign(d,m,{saved:!0}):(d.saved=!1,l++)}return{...n,color_groups:[],layers:1,..."error"in o?{saved_note:`saved project not read: ${o.error}`}:{unsaved_items:l}}};this.premiereRenders=new Map}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async liveMarkers(t){if(!$.announced(await this.peer(),"edit.markers"))return null;let{seq:s}=await this.sequence(t);return await this.ask("edit.markers",{timeline:s},12e4)}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,s){await this.needs("edit");let{seq:n}=await this.sequence(t);return await this.ask("edit.cut_in",{timeline:n,cuts:s},12e4+s.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:s,name:n}=await this.sequence(t.timeline);await M(t.target_dir);let o=_(t.target_dir,`${t.name??n}.mov`),l=await this.ask("render.export_sequence",{timeline:s,output_path:o,preset_path:t.preset,queue:!1},6e4);if(!l.ok)throw new h("render_refused","premiere: Premiere refused the export");let d=l.job||`ppro-${Date.now()}`;return this.premiereRenders.set(d,o),{job_id:d,state:"rendering",percent:0}}async renderStatus(t){let s=await this.ask("render.progress"),n=s[t]??s.last,o=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"||o&&await x(o)&&!n?{job_id:t,state:"complete",percent:100,...o?{outputs:[o]}:{}}:{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(p,e){let{session:t}=await D(p,"prproj"),s=t.timelines.find(o=>o.name===e),n=new Map;if(!s)throw new Error(`the saved project has no sequence "${e}" (saved before it was made?)`);for(let o of s.tracks)if(!(o.kind!=="Video"&&o.kind!=="Audio"))for(let l of o.items){if(l.kind==="gap"||l.kind==="transition")continue;let d=l;n.set(`${o.kind==="Video"?"video":"audio"}:${o.track_index}:${l.timeline_range.start.value}:${l.timeline_range.duration.value}`,{saved_id:l.id,...d.speed_factor!=null&&d.speed_factor!==1?{retime:d.speed_factor}:{},...d.speed_ramped?{ramped:!0}:{},...d.speed_reverse?{reversed:!0}:{},...l.kind==="nested"?{nested:!0}:{},...d.is_multicam?{multicam:!0}:{},...d.effects?.some(m=>/stabiliz/i.test(m.kind??""))?{stabilized:!0}:{},...d.effects?.length?{saved_effects:d.effects.map(m=>m.name??m.kind??"")}:{}})}return n}function z(p=y()){return p==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":p==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function B(){for(let p of["./uxp-plugin/","./premiere-uxp/"]){let e=S(new URL(p,import.meta.url));if(await P(_(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 B(),"manifest.json"))).version}async function oe(p=y()){let e=z(p);if(!e||!await x(e))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let t=await w(e,p==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),s=t.stdout.split(`
4
4
  `).find(n=>/CONFORM\.TOOLS|conformtools/i.test(n));return{installed:!!s&&/enabled|installed/i.test(s),version:s?.match(/(\d+\.\d+\.\d+)\s*$/)?.[1],listing:t.stdout.trim()}}async function ae(p=y()){let e=z(p);if(!e||!await x(e))throw new Error("premiere: Creative Cloud's plugin installer (UnifiedPluginInstallerAgent) is not on this machine; install Creative Cloud");let t=await B(),s=await Q(),n=await q("conform-ccx-");for(let a of["manifest.json","index.html","index.js","lib","icons"])await T(_(t,a),_(n,a));let o=_(O(),"premiere");await M(o);let l=I(_(o,`conformtools-premiere-${s}.ccx`));await R(l);let d=p==="darwin"?await w("sh",["-c",`cd '${n.replace(/'/g,"'\\''")}' && zip -r -q -X '${l.replace(/'/g,"'\\''")}' manifest.json index.html index.js lib icons`]):await w("powershell",["-NoProfile","-Command",`Compress-Archive -Path '${n}\\*' -DestinationPath '${l.replace(/\.ccx$/,".zip")}' -Force; Move-Item -Force '${l.replace(/\.ccx$/,".zip")}' '${l}'`]);if(await R(n),!d.success)throw new Error(`premiere: could not package the panel: ${d.stderr.trim()}`);await w(e,p==="win32"?["/remove","conform.tools"]:["--remove","conform.tools"],{timeoutMs:12e4});let m=await w(e,p==="win32"?["/install",l]:["--install",l],{timeoutMs:18e4}),c=`${m.stdout}
5
5
  ${m.stderr}`.trim();if(!m.success||!/Installation Successful/i.test(c))throw new Error(`premiere: Adobe's installer refused the panel: ${c.split(`
6
6
  `).pop()}`);return{version:s,ccx:l,output:c}}export{$ as a,U as b,K as c,Q as d,oe as e,ae as f};
@@ -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
- var s={scrub:{output:"rgba8",detail:"coarse"},thumbnail:{output:"rgba8",detail:"coarse"},park:{output:"rgba8",detail:"exact"},render:{output:"rgba8",detail:"exact"},transcode:{output:"rgb16",detail:"exact"}};function p(e){let t=new DataView(e.buffer,e.byteOffset,8),r=t.getUint32(0,!0),n=t.getUint32(4,!0),o=e.slice(8);return{width:r,height:n,rgb16:new Uint16Array(o.buffer,o.byteOffset,r*n*3)}}var a=class extends Error{constructor(r,n){super(`COVERAGE_MISS: frame ${r} not in linked media (${n} frames)`);this.index=r;this.frameCount=n;this.name="CoverageMissError"}},m=/(?:[A-Z0-9]+_)?COVERAGE_MISS\s+(\{[\s\S]*\})/;function d(e){let r=(e instanceof Error?e.message:String(e??"")).match(m);if(!r)return null;try{return JSON.parse(r[1])}catch{return{reason:"coverage_miss"}}}var i=class extends Error{constructor(r){super(`DELIVERY_COVERAGE_MISS: ${r.reason}`+(r.cut_in!=null?` cut [${r.cut_in}..${r.cut_out}] file_frames ${r.file_frames}`:""));this.detail=r;this.name="DeliveryCoverageMissError"}};function l(e){return e instanceof i?e.detail:d(e)}var u={mov:()=>import("./isobmff-FZBZCEYH.js").then(e=>e.isobmffFormat),crm:()=>import("./isobmff-FZBZCEYH.js").then(e=>e.isobmffFormat),braw:()=>import("./isobmff-FZBZCEYH.js").then(e=>e.isobmffFormat),wav:()=>import("./wav-4COVRAK3.js").then(e=>e.wavFormat),mxf:()=>import("./mxf-IUCZVILV.js").then(e=>e.mxfFormat),r3d:()=>import("./r3d-VBXKIIRY.js").then(e=>e.r3dFormat),still:()=>import("./still-XAFHXXC3.js").then(e=>e.stillFormat),avc1:()=>import("./h264-ZJCLCYYY.js").then(e=>e.h264Format),avc3:()=>import("./h264-ZJCLCYYY.js").then(e=>e.h264Format),h264:()=>import("./h264-ZJCLCYYY.js").then(e=>e.h264Format),hvc1:()=>import("./h264-ZJCLCYYY.js").then(e=>e.h264Format),hev1:()=>import("./h264-ZJCLCYYY.js").then(e=>e.h264Format),hevc:()=>import("./h264-ZJCLCYYY.js").then(e=>e.h264Format),h264_mxf:()=>import("./h264-mxf-BI4ACQUH.js").then(e=>e.h264MxfFormat),mcvideo:()=>import("./mc-video-IUPFHPIS.js").then(e=>e.mcVideoFormat)};async function c(e){let t=u[e];return t?await t():null}async function f(e){let t=await c(e.format);if(!t)throw new Error(`extract: no handler for format '${e.format}'`);return t.extract(e)}async function b(e,t){let r=await c(e.format);if(!r){if(t.verb==="inspect")return null;throw new Error(`mediaOp: no handler for format '${e.format}' (verb ${t.verb})`)}switch(t.verb){case"inspect":{let n=await r.inspect(e);return n&&(n.source_facts_origin="probed"),n}case"sparsify":return r.sparsify(e,t.selection);case"trim":return r.trim(e,t.selection);case"decode":{let{output:n,detail:o}=s[t.intent];if(n==="rgb16"){if(!r.decode16)throw new Error(`mediaOp: format '${e.format}' has no 16-bit decoder (intent '${t.intent}')`);return r.decode16(e,t.index)}if(!r.decode)throw new Error(`mediaOp: format '${e.format}' has no decoder (no viewer)`);return r.decode(e,t.index,{detail:o})}}}export{s as a,p as b,a as c,d,i as e,l as f,c as g,f as h,b as i};
3
+ var s={scrub:{output:"rgba8",detail:"coarse"},thumbnail:{output:"rgba8",detail:"coarse"},park:{output:"rgba8",detail:"exact"},render:{output:"rgba8",detail:"exact"},transcode:{output:"rgb16",detail:"exact"}};function p(e){let t=new DataView(e.buffer,e.byteOffset,8),r=t.getUint32(0,!0),n=t.getUint32(4,!0),o=e.slice(8);return{width:r,height:n,rgb16:new Uint16Array(o.buffer,o.byteOffset,r*n*3)}}var a=class extends Error{constructor(r,n){super(`COVERAGE_MISS: frame ${r} not in linked media (${n} frames)`);this.index=r;this.frameCount=n;this.name="CoverageMissError"}},m=/(?:[A-Z0-9]+_)?COVERAGE_MISS\s+(\{[\s\S]*\})/;function d(e){let r=(e instanceof Error?e.message:String(e??"")).match(m);if(!r)return null;try{return JSON.parse(r[1])}catch{return{reason:"coverage_miss"}}}var i=class extends Error{constructor(r){super(`DELIVERY_COVERAGE_MISS: ${r.reason}`+(r.cut_in!=null?` cut [${r.cut_in}..${r.cut_out}] file_frames ${r.file_frames}`:""));this.detail=r;this.name="DeliveryCoverageMissError"}};function l(e){return e instanceof i?e.detail:d(e)}var u={mov:()=>import("./isobmff-4FUKPUL3.js").then(e=>e.isobmffFormat),crm:()=>import("./isobmff-4FUKPUL3.js").then(e=>e.isobmffFormat),braw:()=>import("./isobmff-4FUKPUL3.js").then(e=>e.isobmffFormat),wav:()=>import("./wav-N6EWJR2P.js").then(e=>e.wavFormat),mxf:()=>import("./mxf-LGRSWF7S.js").then(e=>e.mxfFormat),r3d:()=>import("./r3d-OL6DVR3C.js").then(e=>e.r3dFormat),still:()=>import("./still-CDF26BQZ.js").then(e=>e.stillFormat),avc1:()=>import("./h264-KMDAFD3Q.js").then(e=>e.h264Format),avc3:()=>import("./h264-KMDAFD3Q.js").then(e=>e.h264Format),h264:()=>import("./h264-KMDAFD3Q.js").then(e=>e.h264Format),hvc1:()=>import("./h264-KMDAFD3Q.js").then(e=>e.h264Format),hev1:()=>import("./h264-KMDAFD3Q.js").then(e=>e.h264Format),hevc:()=>import("./h264-KMDAFD3Q.js").then(e=>e.h264Format),h264_mxf:()=>import("./h264-mxf-IJYHBYKB.js").then(e=>e.h264MxfFormat),mcvideo:()=>import("./mc-video-DTMHUECT.js").then(e=>e.mcVideoFormat)};async function c(e){let t=u[e];return t?await t():null}async function f(e){let t=await c(e.format);if(!t)throw new Error(`extract: no handler for format '${e.format}'`);return t.extract(e)}async function b(e,t){let r=await c(e.format);if(!r){if(t.verb==="inspect")return null;throw new Error(`mediaOp: no handler for format '${e.format}' (verb ${t.verb})`)}switch(t.verb){case"inspect":{let n=await r.inspect(e);return n&&(n.source_facts_origin="probed"),n}case"sparsify":return r.sparsify(e,t.selection);case"trim":return r.trim(e,t.selection);case"decode":{let{output:n,detail:o}=s[t.intent];if(n==="rgb16"){if(!r.decode16)throw new Error(`mediaOp: format '${e.format}' has no 16-bit decoder (intent '${t.intent}')`);return r.decode16(e,t.index)}if(!r.decode)throw new Error(`mediaOp: format '${e.format}' has no decoder (no viewer)`);return r.decode(e,t.index,{detail:o})}}}export{s as a,p as b,a as c,d,i as e,l as f,c as g,f as h,b as i};
@@ -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{Gb as L,Hb as A,Ib as E,Jb as P,Kb as T,Lb as M,Mb as N,Nb as D,Ob as z,Pb as B,Qb as I,tb as S}from"./chunk-65SLDY2M.js";import{a as b}from"./chunk-E75BCWXY.js";import{aa as p,u as R}from"./chunk-ZPIY5DOU.js";async function W(r,t){let c=t.media_root?[t.media_root]:await z();if(!c.length)throw new b("invalid_args","no media_root given and no remembered locations \u2014 pass the folder to link from");for(let e of c)try{if(!(await R(e)).isDirectory)throw 0}catch{throw new b("invalid_args",`media_root is not a folder on this machine: ${e}`)}let i=A(r,{ref_ids:t.ref_ids,lane:t.lane,reset:t.reset});if(!i.length)return{session:r,changed:!1,note:"",text:"nothing in scope: every reference in scope is already linked (use reset=true to re-point) or the ids/lane matched nothing"};if(t.reset)for(let e of i)e.binding_state="unbound",delete e.coverage_reason;let m=[],k=!1,u=[];for(let e of c)if(t.gather==="path")for(let n of i){let l=n.local_path??n.target_url??"",o=l?await P(e,l):null;o?m.push(o):u.push(`${n.id} ${p(l)}: not at its recorded path under ${e}`)}else{let n=await E(e,i,t.cap,{byName:t.criteria?.file_name!==!1,exts:t.criteria?.extensions});m.push(...n.paths),k||=n.capped}let{refs:$,failed:_}=await T([...new Set(m)]);t.remember&&t.media_root&&await B(t.media_root);let y=new Set(i.map(e=>e.id)),f=S(r,$,y);if(f.splits.length){r=f.session;let e=new Set([...y,...f.splits.flatMap(n=>n.into)]);i=(r.media_references??[]).filter(n=>e.has(n.id));for(let n of f.splits){let l=o=>p(i.find(G=>G.id===o)?.target_url??o);u.push(`split ${n.ref_id} across ${n.into.length} section file(s): ${n.into.map(l).join(", ")}`)}}let d=L(t.criteria),a=M(r,i,$,d,t.tolerances),O=t.criteria?.picture?await N(r,a):[],s=e=>a.rows.filter(n=>n.status===e).length,U=c.map(e=>e.split(/[\\/]/).filter(Boolean).pop()??e).join(", "),v=[`${t.dry_run?"would link":"found"} ${s("matched")} of ${i.length} clip${i.length===1?"":"s"} in ${U}${s("ambiguous")?`, ${s("ambiguous")} with more than one match`:""}${i.length-s("matched")-s("ambiguous")?`, ${i.length-s("matched")-s("ambiguous")} not found there`:""}${t.dry_run?" (dry run: nothing changed)":""}`,`scope: ${i.length} reference(s)${t.lane!=="both"?` (${t.lane} lane)`:""}${t.ref_ids?` (zone of ${t.ref_ids.length})`:""}; gather=${t.gather} under ${c.join(", ")}: ${$.length} candidate clip(s)${k?` (CAPPED at ${t.cap} \u2014 narrow the folder)`:""}`,`criteria: ${[...Object.entries(d).filter(([,e])=>e===!0).map(([e])=>e),...t.criteria?.picture?["picture"]:[]].join(", ")}${d.fileName?` (${d.fileNameMode})`:""}${d.fileExtensions?`; ext ${d.fileExtensions}`:""}; timecode containment + fps always on`,..._.length?[`could not probe ${_.length}: ${_.slice(0,5).join("; ")}`]:[],...u.slice(0,20),...O.slice(0,40)];if(t.dry_run)return{session:r,changed:!1,note:"",text:[...v,I(r,a,{compare:t.compare}),"(dry run \u2014 nothing changed; pass accept=[{ref_id,candidate_id}] to commit chosen rows, or run again without dry_run to apply every matched row)"].join(`
3
+ import{Gb as L,Hb as A,Ib as E,Jb as P,Kb as T,Lb as M,Mb as N,Nb as D,Ob as z,Pb as B,Qb as I,tb as S}from"./chunk-DESBZZGR.js";import{a as b}from"./chunk-E75BCWXY.js";import{aa as p,u as R}from"./chunk-ZPIY5DOU.js";async function W(r,t){let c=t.media_root?[t.media_root]:await z();if(!c.length)throw new b("invalid_args","no media_root given and no remembered locations \u2014 pass the folder to link from");for(let e of c)try{if(!(await R(e)).isDirectory)throw 0}catch{throw new b("invalid_args",`media_root is not a folder on this machine: ${e}`)}let i=A(r,{ref_ids:t.ref_ids,lane:t.lane,reset:t.reset});if(!i.length)return{session:r,changed:!1,note:"",text:"nothing in scope: every reference in scope is already linked (use reset=true to re-point) or the ids/lane matched nothing"};if(t.reset)for(let e of i)e.binding_state="unbound",delete e.coverage_reason;let m=[],k=!1,u=[];for(let e of c)if(t.gather==="path")for(let n of i){let l=n.local_path??n.target_url??"",o=l?await P(e,l):null;o?m.push(o):u.push(`${n.id} ${p(l)}: not at its recorded path under ${e}`)}else{let n=await E(e,i,t.cap,{byName:t.criteria?.file_name!==!1,exts:t.criteria?.extensions});m.push(...n.paths),k||=n.capped}let{refs:$,failed:_}=await T([...new Set(m)]);t.remember&&t.media_root&&await B(t.media_root);let y=new Set(i.map(e=>e.id)),f=S(r,$,y);if(f.splits.length){r=f.session;let e=new Set([...y,...f.splits.flatMap(n=>n.into)]);i=(r.media_references??[]).filter(n=>e.has(n.id));for(let n of f.splits){let l=o=>p(i.find(G=>G.id===o)?.target_url??o);u.push(`split ${n.ref_id} across ${n.into.length} section file(s): ${n.into.map(l).join(", ")}`)}}let d=L(t.criteria),a=M(r,i,$,d,t.tolerances),O=t.criteria?.picture?await N(r,a):[],s=e=>a.rows.filter(n=>n.status===e).length,U=c.map(e=>e.split(/[\\/]/).filter(Boolean).pop()??e).join(", "),v=[`${t.dry_run?"would link":"found"} ${s("matched")} of ${i.length} clip${i.length===1?"":"s"} in ${U}${s("ambiguous")?`, ${s("ambiguous")} with more than one match`:""}${i.length-s("matched")-s("ambiguous")?`, ${i.length-s("matched")-s("ambiguous")} not found there`:""}${t.dry_run?" (dry run: nothing changed)":""}`,`scope: ${i.length} reference(s)${t.lane!=="both"?` (${t.lane} lane)`:""}${t.ref_ids?` (zone of ${t.ref_ids.length})`:""}; gather=${t.gather} under ${c.join(", ")}: ${$.length} candidate clip(s)${k?` (CAPPED at ${t.cap} \u2014 narrow the folder)`:""}`,`criteria: ${[...Object.entries(d).filter(([,e])=>e===!0).map(([e])=>e),...t.criteria?.picture?["picture"]:[]].join(", ")}${d.fileName?` (${d.fileNameMode})`:""}${d.fileExtensions?`; ext ${d.fileExtensions}`:""}; timecode containment + fps always on`,..._.length?[`could not probe ${_.length}: ${_.slice(0,5).join("; ")}`]:[],...u.slice(0,20),...O.slice(0,40)];if(t.dry_run)return{session:r,changed:!1,note:"",text:[...v,I(r,a,{compare:t.compare}),"(dry run \u2014 nothing changed; pass accept=[{ref_id,candidate_id}] to commit chosen rows, or run again without dry_run to apply every matched row)"].join(`
4
4
  `)};let h,g=[];if(t.accept?.length){h=[];for(let e of t.accept){let n=a.rows.find(o=>o.ref_id===e.ref_id);n&&(n.candidate?.id===e.candidate_id||n.alternatives.some(o=>o.id===e.candidate_id))?h.push(e):g.push(`${e.ref_id} \u2192 ${e.candidate_id}: not a proposed match or alternative for that reference`)}}else h=a.rows.filter(e=>e.status==="matched"&&e.candidate).map(e=>({ref_id:e.ref_id,candidate_id:e.candidate.id}));let w=D(r,a,h),x=w.session.media_references??[],j=x.filter(e=>i.some(n=>n.id===e.id)&&e.binding_state==="linked").length,q=w.applied,C=x.filter(e=>i.some(n=>n.id===e.id)&&e.binding_state!=="linked").map(e=>` - ${e.id} ${p(e.target_url??"")}: ${e.coverage_reason??(a.rows.find(n=>n.ref_id===e.id)?.status==="ambiguous"?"ambiguous \u2014 pick one with accept":"no file matched")}`),F=[...v,`Linked ${j} of ${i.length}${g.length?`; ${g.length} pick(s) vetoed`:""}`,...q.map(e=>`- ${e.ref_id}: ${p(e.before.path??"?")} \u2192 ${e.after.path}${e.warning?` \u26A0 ${e.warning}`:""}`),...g.map(e=>` \u2717 ${e}`),...C.length?["unresolved:",...C]:[]].join(`
5
5
  `);return{session:w.session,changed:!0,note:`relink ${t.gather} ${c[0]} (${j}/${i.length})`,text:F}}export{W as a};
@@ -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{b as o}from"./chunk-ZPIY5DOU.js";var r="0.6.22";function a(t,n){let s=t.split("-")[0].split(".").map(Number),l=n.split("-")[0].split(".").map(Number);for(let e=0;e<Math.max(s.length,l.length);e++){let i=(s[e]||0)-(l[e]||0);if(i)return i>0}return!1}var m=()=>o("CONFORM_APP_VERSION")||r,p=null;function u(){return o("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):p??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>typeof t?.version=="string"?t.version:null).catch(()=>null)}var c="run npx -y conformtools@latest setup claude (or setup codex) once: it registers the server so every new session runs the newest version (npx --prefer-online), then restart the MCP client; if an old global install is shadowing it: npm rm -g conformtools";async function g(){let t=o("CONFORM_APP_VERSION");if(t)return`conform.tools app ${t}`;let n=await u();return`conformtools ${r}`+(n&&a(n,r)?` \u2014 update available: ${n} \u2192 ${c}`:"")}export{r as a,a as b,m as c,u as d,c as e,g as f};
3
+ import{b as o}from"./chunk-ZPIY5DOU.js";var r="0.6.23";function a(t,n){let s=t.split("-")[0].split(".").map(Number),l=n.split("-")[0].split(".").map(Number);for(let e=0;e<Math.max(s.length,l.length);e++){let i=(s[e]||0)-(l[e]||0);if(i)return i>0}return!1}var m=()=>o("CONFORM_APP_VERSION")||r,p=null;function u(){return o("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):p??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>typeof t?.version=="string"?t.version:null).catch(()=>null)}var c="run npx -y conformtools@latest setup claude (or setup codex) once: it registers the server so every new session runs the newest version (npx --prefer-online), then restart the MCP client; if an old global install is shadowing it: npm rm -g conformtools";async function g(){let t=o("CONFORM_APP_VERSION");if(t)return`conform.tools app ${t}`;let n=await u();return`conformtools ${r}`+(n&&a(n,r)?` \u2014 update available: ${n} \u2192 ${c}`:"")}export{r as a,a as b,m as c,u as d,c as e,g 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 F}from"./chunk-3PVQ5QP4.js";import{b as ge,c as we,f as _e}from"./chunk-VFXMP7IF.js";import{f as X,h as he}from"./chunk-REBF4U5B.js";import{a as be}from"./chunk-TFKKODSA.js";import{i as N}from"./chunk-REGL3GQB.js";import{b as P,d as T,f as E}from"./chunk-NU3X7P4N.js";import{Ha as pe,ea as ce,fa as le,ja as ue,oa as me,wa as de,xa as fe}from"./chunk-4I4MV3DE.js";import{a as ae}from"./chunk-E75BCWXY.js";import{A as J,C as K,H as V,O as v,P as z,Q as se,T as ie,aa as b,b as D,ba as x,ca as k,d as ee,da as y,e as re,h as te,l as ne,m as j,t as W,u as L,w as oe,x as R}from"./chunk-ZPIY5DOU.js";var G=!1,O=8,Ae=0,De=3,U=2;async function ze(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),n=i=>String.fromCharCode(t[i],t[i+1],t[i+2],t[i+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(n(4)==="RED1"||n(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],s=n(4);return/^[A-Za-z0-9 ]{4}$/.test(s)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function ke(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Ne(e){return async(t,n)=>new Uint8Array(await e.slice(t,Math.min(t+n,e.size)).arrayBuffer())}function ye(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function ir(e){return await pe(),xe?xe.clip(e,G?"rec709":"",()=>$e(e)):$e(e)}var xe=null;async function $e(e){let t=await ze(e),n=[];if(t==="r3d"){let r=e,s=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],o=r.bases??[0],i=async(u,d,f)=>{let p=o[u]+d;return new Uint8Array(await e.slice(p,Math.min(p+f,o[u]+s[u].size)).arrayBuffer())},c=JSON.stringify(s.map(u=>({name:u.name,size:u.size}))),a=JSON.parse(await fe(i,c)),l=JSON.parse(await ue(i,c));return s.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&n.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:o[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:a.width??0,h:a.height??0,fps:ye(a),startFrame:a.timecode?.start_frame??0,dropFrame:a.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Ae},geometrySpec:{codec:"r3d",subbands:De},index:null,warnings:n}}if(t==="mxf"){let r=Ne(e),s=JSON.parse(await de(r,e.size));if(!s)throw new Error(`${e.name}: MXF index unreadable`);let o=JSON.parse(await me(r,e.size)),i=[];for(let p=0;p<o.frame_count;p++)i.push({offset:o.frames[p*2],size:o.frames[p*2+1]});let c=i.filter(p=>p.size===0).length;c&&n.push(`${c} frame(s) had no locatable picture KLV`);let a=s.width??0,l=s.height??0,u=(s.inner_codec??"").toLowerCase(),d=null,f="MXF";return u==="arriraw"?(d={codec:"arriraw",w:a,h:l,scale:O},f="ARRIRAW"):u==="xocn"?(d={codec:"xocn",scale:O,...G?{display:"rec709"}:{}},f="X-OCN"):await le(r,e.size)?(d={codec:"vc3",scale:O},f="DNxHR"):await ce(r,e.size)?(d={codec:"prores"},f="ProRes"):n.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:d?i:[],w:a,h:l,fps:ye(s),startFrame:s.timecode?.start_frame??0,dropFrame:s.timecode?.drop_frame??!1,label:f,spec:d,geometrySpec:d&&d.codec==="arriraw"?{...d,scale:U}:d&&d.codec==="xocn"?{codec:"xocn",scale:U,...G?{display:"rec709"}:{}}:d&&d.codec==="vc3"?{codec:"vc3",scale:U}:null,index:null,warnings:n}}if(t==="isobmff"){let r=await he(e),s=ke(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:X(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:n};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:X(r.kind),spec:null,geometrySpec:null,index:r,warnings:n};let o=s==="braw"?{codec:"braw",scale:O}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:O}:null;return o||n.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:o?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:o?s==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:o,geometrySpec:o?{...o,scale:U}:null,index:r,warnings:n}}throw new Error(`${e.name}: unrecognised container`)}var Y=null;var Te=Number(D("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(re()/2),Math.floor(ee()/2**31))),Z=0,ve=[],Me=async(...e)=>{Z>=Te?await new Promise(t=>ve.push(t)):Z++;try{return await ie(...e)}finally{let t=ve.shift();t?t():Z--}};async function Re(){let e=te()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[D("CONFORM_NATIVE_DECODE"),ne(e),W(new URL(`./${e}`,import.meta.url)),W(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await oe(n))return n;return null}var S=class extends Error{constructor(n,r){super(r);this.why=n}};function Pr(e){let t=null;try{t=JSON.parse(e.trim().split(`
3
+ import{a as F}from"./chunk-3PVQ5QP4.js";import{b as ge,c as we,f as _e}from"./chunk-VFXMP7IF.js";import{f as X,h as he}from"./chunk-NQDVV2PX.js";import{a as be}from"./chunk-XX7QQIBI.js";import{i as N}from"./chunk-5JDF2IUF.js";import{b as P,d as T,f as E}from"./chunk-NU3X7P4N.js";import{Ha as pe,ea as ce,fa as le,ja as ue,oa as me,wa as de,xa as fe}from"./chunk-DCO5D65W.js";import{a as ae}from"./chunk-E75BCWXY.js";import{A as J,C as K,H as V,O as v,P as z,Q as se,T as ie,aa as b,b as D,ba as x,ca as k,d as ee,da as y,e as re,h as te,l as ne,m as j,t as W,u as L,w as oe,x as R}from"./chunk-ZPIY5DOU.js";var G=!1,O=8,Ae=0,De=3,U=2;async function ze(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),n=i=>String.fromCharCode(t[i],t[i+1],t[i+2],t[i+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(n(4)==="RED1"||n(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],s=n(4);return/^[A-Za-z0-9 ]{4}$/.test(s)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function ke(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Ne(e){return async(t,n)=>new Uint8Array(await e.slice(t,Math.min(t+n,e.size)).arrayBuffer())}function ye(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function ir(e){return await pe(),xe?xe.clip(e,G?"rec709":"",()=>$e(e)):$e(e)}var xe=null;async function $e(e){let t=await ze(e),n=[];if(t==="r3d"){let r=e,s=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],o=r.bases??[0],i=async(u,d,f)=>{let p=o[u]+d;return new Uint8Array(await e.slice(p,Math.min(p+f,o[u]+s[u].size)).arrayBuffer())},c=JSON.stringify(s.map(u=>({name:u.name,size:u.size}))),a=JSON.parse(await fe(i,c)),l=JSON.parse(await ue(i,c));return s.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&n.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:o[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:a.width??0,h:a.height??0,fps:ye(a),startFrame:a.timecode?.start_frame??0,dropFrame:a.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Ae},geometrySpec:{codec:"r3d",subbands:De},index:null,warnings:n}}if(t==="mxf"){let r=Ne(e),s=JSON.parse(await de(r,e.size));if(!s)throw new Error(`${e.name}: MXF index unreadable`);let o=JSON.parse(await me(r,e.size)),i=[];for(let p=0;p<o.frame_count;p++)i.push({offset:o.frames[p*2],size:o.frames[p*2+1]});let c=i.filter(p=>p.size===0).length;c&&n.push(`${c} frame(s) had no locatable picture KLV`);let a=s.width??0,l=s.height??0,u=(s.inner_codec??"").toLowerCase(),d=null,f="MXF";return u==="arriraw"?(d={codec:"arriraw",w:a,h:l,scale:O},f="ARRIRAW"):u==="xocn"?(d={codec:"xocn",scale:O,...G?{display:"rec709"}:{}},f="X-OCN"):await le(r,e.size)?(d={codec:"vc3",scale:O},f="DNxHR"):await ce(r,e.size)?(d={codec:"prores"},f="ProRes"):n.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:d?i:[],w:a,h:l,fps:ye(s),startFrame:s.timecode?.start_frame??0,dropFrame:s.timecode?.drop_frame??!1,label:f,spec:d,geometrySpec:d&&d.codec==="arriraw"?{...d,scale:U}:d&&d.codec==="xocn"?{codec:"xocn",scale:U,...G?{display:"rec709"}:{}}:d&&d.codec==="vc3"?{codec:"vc3",scale:U}:null,index:null,warnings:n}}if(t==="isobmff"){let r=await he(e),s=ke(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:X(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:n};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:X(r.kind),spec:null,geometrySpec:null,index:r,warnings:n};let o=s==="braw"?{codec:"braw",scale:O}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:O}:null;return o||n.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:o?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:o?s==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:o,geometrySpec:o?{...o,scale:U}:null,index:r,warnings:n}}throw new Error(`${e.name}: unrecognised container`)}var Y=null;var Te=Number(D("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(re()/2),Math.floor(ee()/2**31))),Z=0,ve=[],Me=async(...e)=>{Z>=Te?await new Promise(t=>ve.push(t)):Z++;try{return await ie(...e)}finally{let t=ve.shift();t?t():Z--}};async function Re(){let e=te()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[D("CONFORM_NATIVE_DECODE"),ne(e),W(new URL(`./${e}`,import.meta.url)),W(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await oe(n))return n;return null}var S=class extends Error{constructor(n,r){super(r);this.why=n}};function Pr(e){let t=null;try{t=JSON.parse(e.trim().split(`
4
4
  `).pop())}catch{}if(t?.why==="not_entitled")throw new ae("not_entitled",t.detail??"this machine is not licensed");return t?.detail??e.trim()}function Fe(e,t){try{let n=JSON.parse(e.trim().split(`
5
5
  `).pop()??"");return new S(n.why,n.detail)}catch{return new S("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Er(e){return Y?.owns(e)?Y.meta(`probe|${e}`,()=>Se(e)):Se(e)}async function Se(e){let t=await Re();if(!t)throw new S("missing",j("the native decoder (conformtools-decode)"));let n=[],r=await Me(t,["probe",e],s=>n.push(s));if(r.code!==0)throw Fe(r.stderr,r.code);return JSON.parse(new TextDecoder().decode(Pe(n)))}function Pe(e){let t=e.reduce((s,o)=>s+o.length,0),n=new Uint8Array(t),r=0;for(let s of e)n.set(s,r),r+=s.length;return n}async function Ue(e,t,n,r,s){let o=await Re();if(!o)throw new S("missing",j("the native decoder (conformtools-decode)"));let i=null,c=[],a=0,l=f=>{let p=new Uint8Array(f),m=0;for(;m<f;){let h=c[0],g=Math.min(h.length,f-m);p.set(h.subarray(0,g),m),m+=g,g===h.length?c.shift():c[0]=h.subarray(g)}return a-=f,p},u=[e,t,"--width",String(s.width??32768)];s.from!=null&&u.push("--from",String(s.from)),s.count!=null&&u.push("--count",String(s.count)),s.range&&u.push("--range",s.range);let d=await Me(o,u,f=>{if(c.push(f),a+=f.length,!i){let m=Pe(c.splice(0));c.push(m);let h=m.indexOf(10);if(h<0)return;i=JSON.parse(new TextDecoder().decode(m.subarray(0,h))),l(h+1),n(i)}let p=4+i.w*i.h*(i.bpp??(e==="rgb16"?6:4));for(;a>=p;){let m=l(p);r(new DataView(m.buffer).getUint32(0,!0),m.subarray(4))}},{signal:s.signal});if(d.code!==0||!i)throw Fe(d.stderr,d.code)}function Ee(e,t,n,r={}){return Ue("bgra",e,t,n,r)}var Ie=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],I=e=>(e>>4)*10+(e&15);function He(e){let t=I(e&63),n=I(e>>>8&127),r=I(e>>>16&127),s=I(e>>>24&63),o=i=>String(i).padStart(2,"0");return`${o(s)}:${o(r)}:${o(n)}${e&64?";":":"}${o(t)}`}function Be(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let n={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,s=()=>{let i=r;for(;r<e.length&&e[r]!==0;)r++;let c=new TextDecoder().decode(e.subarray(i,r));return r++,c},o=i=>({width:t.getInt32(i+8,!0)-t.getInt32(i,!0)+1,height:t.getInt32(i+12,!0)-t.getInt32(i+4,!0)+1});for(;r<e.length;){let i=s();if(!i)break;let c=s();if(r+4>e.length)return null;let a=t.getInt32(r,!0);if(r+=4,a<0||r+a>e.length)return null;if(n.attributes.push(`${i}:${c}`),i==="framesPerSecond"&&c==="rational"&&a>=8){let l=t.getInt32(r,!0),u=t.getUint32(r+4,!0);n.fps=u?l/u:null}else i==="timeCode"&&c==="timecode"&&a>=8?n.timecode=He(t.getUint32(r,!0)):i==="dataWindow"&&c==="box2i"&&a>=16?{width:n.width,height:n.height}=o(r):i==="displayWindow"&&c==="box2i"&&a>=16?n.display=o(r):i==="compression"&&a>=1&&(n.compression=Ie[e[r]]??`type ${e[r]}`);r+=a}return n}async function je(e){let t=e,n=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await R(e))n=/^(.*?)(\d+)(\.exr)$/i;else{t=x(e);let o=r?[null,r[1],r[2],r[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(b(e));if(!o)return{frames:[e],numbers:[]};let i=c=>c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`^${i(o[1])}(\\d{${o[2].length}})${i(o[3])}$`,"i")}let s=[];for await(let o of v(t)){let i=o.isFile?n.exec(o.name):null;i&&s.push({n:Number(i[i.length===4?2:1]),f:y(t,o.name)})}return s.sort((o,i)=>o.n-i.n),{frames:s.map(o=>o.f),numbers:s.map(o=>o.n)}}async function Q(e){let t=await je(e),n=t.frames[0];if(!n)throw new Error(`no .exr frames for '${b(e)}'`);let r=await z(n),s;try{s=Be(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!s)throw new Error(`'${b(n)}' is not an OpenEXR file`);let o=Math.max(1,t.frames.length),i=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,c=s.fps??0;return{id:b(n),kind:"external",target_url:n,local_path:n,content_kind:o>1?"video":"still",source_fps:s.fps??void 0,source_timecode:s.timecode??void 0,source_resolution_w:s.width,source_resolution_h:s.height,available_range:{start:{value:0,rate:c},duration:{value:o,rate:c}},streams:[{kind:"video",codec:"exr",width:s.width,height:s.height,rate:s.fps??void 0,codec_specific:{compression:s.compression}}],vendor_metadata:{exr:{frames:o,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:i,display_window:s.display,attributes:s.attributes,fps_source:s.fps!=null?"header framesPerSecond":"not in the header",timecode_source:s.timecode?"header timeCode (first frame)":"not in the header"}}}}var C=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function We(e){let t=await z(e);return{path:e,file:t,size:t.size}}function Le(e){return(t,n)=>e.file.readAt(t,n)}async function Je(e){let t=F(b(e));if(!t)return[e];let n=x(e),r=[];for await(let s of v(n)){if(!s.isFile)continue;let o=F(s.name);o&&o.clipBase===t.clipBase&&r.push({n:o.partNumber,p:y(n,s.name)})}return r.sort((s,o)=>s.n-o.n).map(s=>s.p)}async function Ke(e){let t=[],n=[];for await(let r of v(e))!r.isFile||r.name.startsWith(".")||(F(r.name)?t.push(r.name):C.has(k(r.name).toLowerCase())&&n.push(r.name));if(t.length)return y(e,t.sort()[0]);if(n.length===1)return y(e,n[0]);throw n.length?(n.sort(),new Error(`'${b(e)}' is a folder of ${n.length} clips (${n.slice(0,3).join(", ")}${n.length>3?", \u2026":""}): probe one of them, or media_find to list them all`)):new Error(`'${b(e)}' is a folder with no media file in it (looked for ${[...C].join(" ")}, and RED parts)`)}async function q(e){await R(e)&&(e=await Ke(e));let t=we(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...C].join(" ")})`);let n=await Je(e),r=await Promise.all(n.map(We));return{source:_e(t,r.map(o=>ge(b(o.path),{fileSize:o.size,read:Le(o)}))),parts:r,format:t,anchor:n[0],close:()=>r.forEach(o=>o.file.close())}}async function Br(e,t,n,r){if(!/h264|avc|hevc|h265/.test(n)){let s=null,o=await q(e);try{return await N(o.source,{verb:"decode",index:t,intent:"park"})}catch(i){s=i}finally{o.close()}try{return await Oe(e,t,r)}catch(i){throw/no decoder/.test(String(s))?i:s instanceof Error?s:new Error(String(s))}}return Oe(e,t,r)}async function Oe(e,t,n){t=Math.round(t);let r=0,s=0,o=null;if(await Ee(e,c=>{r=c.w,s=c.h},(c,a)=>{c===t&&(o=a)},{from:t,count:1,width:n}),!o)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let i=o;for(let c=0;c<i.length;c+=4){let a=i[c];i[c]=i[c+2],i[c+2]=a}return{rgba:i,width:r,height:s}}async function A(e){if(await R(e)){let n=[];for await(let r of v(e))r.isFile&&/\.exr$/i.test(r.name)&&!r.name.startsWith(".")&&n.push(r.name);if(n.length)return Q(y(e,n.sort()[0]))}if(/\.exr$/i.test(e))return Q(e);let t=await q(e);try{let n=await N(t.source,{verb:"inspect"});if(!n)throw new Error(`could not read '${b(e)}' as ${t.format}`);return n.target_url=t.anchor,n.local_path=t.anchor,n.id=n.id||b(t.anchor),t.parts.length>1&&((n.vendor_metadata??={}).spanned_parts=t.parts.map(r=>b(r.path))),n.size_bytes=t.parts.reduce((r,s)=>r+s.size,0),n}finally{t.close()}}function Ve(e,t,n,r){let s=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,o=Math.floor(e*s/t+1e-6);return{tc:P(o,r),frames:Math.round(n*s/t)}}var Xe=e=>String(Math.round(e*1e3)/1e3);function jr(e,t){let n=e.streams?.find(m=>m.kind==="video"),r=e.streams?.filter(m=>m.kind==="audio")??[],s=e.vendor_metadata?.bext;if(!n&&e.available_range&&r[0]?.rate){let m=r[0].rate,h=e.available_range.duration.value,_=(t?[t]:[24e3/1001,24]).map(w=>{let $=Ve(s?.time_reference??0,s?.sample_rate||m,h,w);return`${s?`start TC ${$.tc}, `:""}${$.frames} frames @ ${Xe(w)} fps`});return[e.target_url??"",`audio only; ${h} samples (${(h/m).toFixed(3)} s)${s?`; BWF time_reference ${s.time_reference}`:"; no BWF timecode"}`,..._,...t?[]:["(pass fps for the project's rate)"],...r.map((w,$)=>`audio ${r.length>1?`${$+1}: `:""}${w.codec??"pcm"} ${w.channels??"?"}ch ${w.rate} Hz ${w.bit_depth??"?"}-bit`)].join(`
6
6
  `)}let o=e.available_range?.duration?.value??e.declared_duration?.value??null,i=e.source_fps??n?.rate??null,c=e.size_bytes,a=e.vendor_metadata?.spanned_parts,l=n?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,n?.bit_depth?`${n.bit_depth}-bit`:null,l.colr?`color ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", "),d=e.source_pixel_aspect&&Math.abs(e.source_pixel_aspect-1)>.001?e.source_pixel_aspect:null,f=d&&n?.width&&n?.height?`pixel aspect ${Math.round(d*1e3)/1e3}: stored ${n.width}x${n.height}, shown ${(n.width*d/n.height).toFixed(2)}:1 (squeezed; a trim keeps it, a square-pixel copy is a new render)`:null,p=e.raw_extraction?.mov_probe?.every_sample_is_keyframe===!1&&n?"long-GOP (not every frame is a keyframe): media_trim starts on the keyframe at or before the frame asked for":null;return[e.target_url??"",n?`${n.codec??"?"} ${n.width??"?"}x${n.height??"?"}${i?` @ ${Math.round(i*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",...[f,p].filter(m=>!!m),`start TC ${e.source_timecode??"none"}; ${o!=null?`${o} frames`:"length unknown"}${o!=null&&i?` (${(o/i).toFixed(2)} s)`:""}`,r.length?r.map((m,h)=>{let g=m.codec_specific?.channel_layout;return`audio ${r.length>1?`${h+1}: `:""}${m.codec??"pcm"} ${m.channels??"?"}ch${g?` (${g})`:""} ${m.rate??"?"} Hz ${m.bit_depth??"?"}-bit`}).join(`