conformtools 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -10
- package/dist/{account-HDXVTS5T.js → account-NJSA4N67.js} +1 -1
- package/dist/{bridge-D5KPIUSY.js → bridge-UIDAF74E.js} +1 -1
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/chunk-2BPR6LK6.js +3 -0
- package/dist/{chunk-VS3MKKJ5.js → chunk-3D3Z4TBR.js} +1 -1
- package/dist/{chunk-P7OVDUA5.js → chunk-6V4OEOOX.js} +1 -1
- package/dist/{chunk-SZD4C5MB.js → chunk-7SENYEIV.js} +1 -1
- package/dist/{chunk-6ML26TIK.js → chunk-A7FNR3T5.js} +1 -1
- package/dist/chunk-AMRJXYL4.js +3 -0
- package/dist/{chunk-RFIPLBQ4.js → chunk-BW4LRTHG.js} +1 -1
- package/dist/{chunk-5SUGU2YR.js → chunk-D4WPRRBT.js} +1 -1
- package/dist/{chunk-EJGVNQ3E.js → chunk-F74QMWXE.js} +1 -1
- package/dist/{chunk-AS7IXHYM.js → chunk-GK4YYKJ6.js} +1 -1
- package/dist/{chunk-LFJLRLEP.js → chunk-GM6QKY7W.js} +1 -1
- package/dist/chunk-H6WZ43NS.js +39 -0
- package/dist/{chunk-OVUCL3YY.js → chunk-IPFPZBSC.js} +1 -1
- package/dist/{chunk-HGDO3OED.js → chunk-J2JXLEAI.js} +1 -1
- package/dist/{chunk-5RSNFPED.js → chunk-JZY2BHQB.js} +7 -6
- package/dist/{chunk-5JBUCVRI.js → chunk-LGUO7PL5.js} +1 -1
- package/dist/{chunk-UKKRZ574.js → chunk-MS3AWOSG.js} +2 -2
- package/dist/{chunk-3OCQA33E.js → chunk-PHAMF4JF.js} +2 -1
- package/dist/chunk-RGMTLNMF.js +3 -0
- package/dist/chunk-RJ6JA2LZ.js +3 -0
- package/dist/{chunk-X53BNWNV.js → chunk-SGLQY53R.js} +1 -1
- package/dist/{chunk-OJWIBQK4.js → chunk-SYX6W5TS.js} +167 -165
- package/dist/{chunk-3XD6NC4G.js → chunk-VIBEEWPC.js} +1 -1
- package/dist/{chunk-NQHQKEP5.js → chunk-WN53ARHJ.js} +1 -1
- package/dist/cli.js +3 -3
- package/dist/conformtools-analyze +0 -0
- package/dist/conformtools-decode +0 -0
- package/dist/{cr3-wasm-L2LFY3LM.js → cr3-wasm-HLJWEV2S.js} +1 -1
- package/dist/{dng-wasm-U6NC3MDK.js → dng-wasm-CQDLPM5V.js} +1 -1
- package/dist/{dpx-wasm-RMKEUKED.js → dpx-wasm-TLGMM7BO.js} +1 -1
- package/dist/{exr-wasm-LBAOMOZD.js → exr-wasm-2NPKPTVB.js} +1 -1
- package/dist/framing-7LAOPOED.js +3 -0
- package/dist/gfx-worker.js +1 -1
- package/dist/{h264-3ESGVT6G.js → h264-JJMZSUWW.js} +1 -1
- package/dist/{h264-mxf-NPFS7NGH.js → h264-mxf-DCUOGLDU.js} +1 -1
- package/dist/{host-relink-D6CB2VOQ.js → host-relink-UOS3P5SL.js} +1 -1
- package/dist/hosts-66KSLCFJ.js +3 -0
- package/dist/http.js +2 -2
- package/dist/{inspect-7ASUPU73.js → inspect-FJKYPEXL.js} +15 -15
- package/dist/{isobmff-SIOE67WL.js → isobmff-VJOWP4MH.js} +1 -1
- package/dist/mc-video-5MGGOQN4.js +3 -0
- package/dist/mcp.js +1 -1
- package/dist/{media-7AUNRKHF.js → media-NZYVREUF.js} +1 -1
- package/dist/media_core-YZ3PABEG.js +9 -0
- package/dist/{mxf-74TTDICM.js → mxf-FJSRFLJC.js} +1 -1
- package/dist/{ops-FSOOBXMV.js → ops-X7NAREC4.js} +1 -1
- package/dist/premiere-uxp/lib/probe.js +212 -1
- package/dist/{r3d-ZDJ3WURS.js → r3d-CXUNG6VS.js} +1 -1
- package/dist/{r3d-YTLOMC7C.js → r3d-T5O6IIZZ.js} +1 -1
- package/dist/{source-BDJAUQVR.js → source-QGWWLMME.js} +1 -1
- package/dist/still-P4JJNTEO.js +3 -0
- package/dist/still-wasm-DN5LPASS.js +3 -0
- package/dist/{store-ZHXLQCGN.js → store-EXUE5XX5.js} +1 -1
- package/dist/{tiff-wasm-D2FJ3L56.js → tiff-wasm-BPRDR6EB.js} +1 -1
- package/dist/{timeline-6DYFDVEH.js → timeline-GVVL2CBI.js} +1 -1
- package/dist/wasm/media_core_bg.wasm +0 -0
- package/dist/wasm-threads/media_core_bg.wasm +0 -0
- package/dist/{wav-OWMUGQMM.js → wav-64SC6P7U.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-7MC7M2Y5.js +0 -3
- package/dist/chunk-BL6L5ZBP.js +0 -39
- package/dist/chunk-C5IX63YF.js +0 -3
- package/dist/chunk-UCMNH6Q6.js +0 -3
- package/dist/chunk-XNR7M4VX.js +0 -3
- package/dist/framing-SRCJKAYO.js +0 -3
- package/dist/hosts-W4AD2MYH.js +0 -3
- package/dist/media_core-Q2PIEV7D.js +0 -9
- package/dist/still-ZG2RUQAL.js +0 -3
|
@@ -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-H6WZ43NS.js";import{b as ke,f as xe}from"./chunk-NU3X7P4N.js";import{b as ce}from"./chunk-JZY2BHQB.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-EXUE5XX5.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};
|
|
@@ -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{
|
|
3
|
+
import{Ha as r,W as s,n as o}from"./chunk-RJ6JA2LZ.js";async function d(t){await r();let e=s(t);return e==="null"?null:JSON.parse(e)}async function l(t){await r();let e;try{e=o(t)}catch{return null}if(e.length<8)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n.getUint32(0,!0),i=n.getUint32(4,!0),u=a*i*4;return e.length<8+u?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+u))}}export{d as a,l as b};
|
|
@@ -1,8 +1,9 @@
|
|
|
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 h}from"./chunk-
|
|
4
|
-
`))>=0;){let m=t.slice(0,d);t=t.slice(d+1);let c=JSON.parse(m);if(c.progress){n?.progress?.(c.progress[0],c.progress[1],c.phase??"");continue}let p=n;n=null,p?.done(c)}},s=>console.error(s.trimEnd()));r.exited.then(()=>n?.done({ok:!1,why:"the analysis engine exited"}));let
|
|
5
|
-
`));let p=await c;return p.miss&&(console.error(`[mirror] MISS \u2014 ${p.miss} is not in the mirror. Replay never reads the source drive; record this case again with the drive mounted (CONFORM_MIRROR_MODE=record).`),F(75)),p}finally{r.hold(!1)}});return
|
|
6
|
-
(the machine licence was not used: ${e.licence_error})`:"")}function
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import{a as h}from"./chunk-PHAMF4JF.js";import{A as K,I as X,L as Y,O as H,P as q,Q as V,Y as u,b as l,f as F,g as x,k as g,l as J,p as N,r as G,s as z,v as y,x as $,y as C,z as v}from"./chunk-PLRB2YXJ.js";var _={payg:{id:"payg",name:"Pay As You Go",monthly:0,yearly:0,stripe:{},includes:{web:!0,mcp:!1,app:!1}},web:{id:"web",name:"Web",monthly:10,yearly:100,stripe:{},includes:{web:!0,mcp:!1,app:!1}},indie:{id:"indie",name:"MCP",monthly:49,yearly:490,stripe:{monthly:"price_1T5XDXJ5lnla0aaLasKq49tm",yearly:"price_1T5XDXJ5lnla0aaL2MdMSuI9"},includes:{web:!0,mcp:!0,app:!1}},pro:{id:"pro",name:"App",monthly:199,yearly:1990,stripe:{monthly:"price_1T5X8oJ5lnla0aaLyNJa93H0",yearly:"price_1T5X8oJ5lnla0aaL3dh7b1el"},includes:{web:!0,mcp:!0,app:!0}},studio:{id:"studio",name:"Studio",monthly:"custom",yearly:"custom",stripe:{monthly:"price_1T5X7xJ5lnla0aaLoeE1aBlL",yearly:"price_1T5X7xJ5lnla0aaLeBiYo3Di"},includes:{web:!0,mcp:!0,app:!0}}},Z={web:!0,mcp:!1,app:!1};var Ne=Object.fromEntries(Object.values(_).flatMap(e=>Object.values(e.stripe).map(t=>[t,e.id])));import{createPrivateKey as De,createPublicKey as fe,sign as Te,verify as ge}from"node:crypto";import{Buffer as w}from"node:buffer";var he="CONFORMTOOLS_LICENSE_V1",W=/^[0-9A-F]{8}(-[0-9A-F]{8}){3}$/,Q=e=>JSON.stringify({dev_mode:e.dev_mode??!1,email:e.email,expires_at:e.expires_at,features:e.features,issued_at:e.issued_at,machine_fingerprint:e.machine_fingerprint,tier:e.tier});function ee(e){let t=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!r.startsWith("#")&&!r.startsWith("-----")).join(""),n=JSON.parse(w.from(t,"base64").toString("utf8"));if(n?.magic!==he||!n.payload?.data)throw new Error("not a conform.tools licence");return n.payload}function te(e,t){let n=w.from(e.signature,"base64"),r=w.from(Q(e.data));return n.length!==64?!1:t.some(o=>ge(null,r,fe({key:w.concat([w.from("302a300506032b6570032100","hex"),w.from(o)]),format:"der",type:"spki"}),n))}async function D(){let e=x()==="win32"?"conformtools-analyze.exe":"conformtools-analyze",t=[l("CONFORM_ANALYZE"),N(new URL(`./${e}`,import.meta.url)),N(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await z(n))return n;return null}var ne=e=>e.code==="not_entitled"?new h("not_entitled",String(e.why)):void 0;async function Be(e){let t=await re(),n=await t.ask({op:"job",reference:e.reference,clips:e.clips,lite:e.lite??!0,display:!!e.display});if(!n.ok)throw t.close(),ne(n)??new Error(`analysis engine: ${n.why}`);return t}async function Fe(e,t,n){let r=await re(),o=()=>r.close();n?.addEventListener("abort",o);let i;try{i=await r.ask(e,t)}finally{n?.removeEventListener("abort",o),r.close()}if(n?.aborted)throw new Error("cancelled");if(!i.ok)throw ne(i)??new Error(i.why??`the analysis engine could not run ${e.op}`);return i}async function re(){let e=await D();if(!e)throw new Error("the analysis engine (conformtools-analyze) is not installed");let t="",n=null,r=H(e,["serve"],s=>{t+=new TextDecoder().decode(s);let d;for(;(d=t.indexOf(`
|
|
4
|
+
`))>=0;){let m=t.slice(0,d);t=t.slice(d+1);let c=JSON.parse(m);if(c.progress){n?.progress?.(c.progress[0],c.progress[1],c.phase??"");continue}let p=n;n=null,p?.done(c)}},s=>console.error(s.trimEnd()));r.exited.then(()=>n?.done({ok:!1,why:"the analysis engine exited"}));let o=Promise.resolve();return{ask:(s,d)=>{let m=o.then(async()=>{r.hold(!0);try{let c=new Promise(f=>{n={done:f,progress:d}});await r.write(new TextEncoder().encode(JSON.stringify(s)+`
|
|
5
|
+
`));let p=await c;return p.miss&&(console.error(`[mirror] MISS \u2014 ${p.miss} is not in the mirror. Replay never reads the source drive; record this case again with the drive mounted (CONFORM_MIRROR_MODE=record).`),F(75)),p}finally{r.hold(!1)}});return o=m.catch(()=>{}),m},close:()=>r.close()}}var ye=["cMwVBrEYKMzlG6pC7FF2lNKIoEqGz2xB5yph6clNnTg=","qnheqkkDU09l1oI6h2CFh4uQ97bY/hkTA5niGKH0+X8="],_e=ye.map(e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)));function A(){let e=l("CONFORM_RECORDS_DIR");if(e)return e;let t=J(),n=x()==="darwin"?u(t,"Library/Application Support"):x()==="win32"?l("LOCALAPPDATA")??u(t,"AppData/Local"):l("XDG_DATA_HOME")??u(t,".local/share");return u(n,"conform.tools")}var we=()=>l("CONFORM_LICENSE_PATH")??u(A(),"license.lic"),k=()=>u(A(),"grant.lic"),be=null;function T(){return be??=(async()=>{let e=await D();if(!e)return[];let t=await Y(e,["machine"],{timeoutMs:15e3}).catch(()=>null);try{return JSON.parse(t?.stdout??"").machines.filter(n=>W.test(n))}catch{return[]}})()}function xe(e,t,n=Date.now()){if(!te(e,_e))return{ok:!1,reason:"invalid licence signature"};let r=Date.parse(e.data.expires_at);return!Number.isFinite(r)||r<n?{ok:!1,reason:`licence expired ${e.data.expires_at}`}:[t??[]].flat().includes(e.data.machine_fingerprint)?{ok:!0,data:e.data}:{ok:!1,reason:"licence is for another machine"}}async function oe(){let e;try{e=await y(we())}catch{return null}try{return xe(ee(e),await T())}catch(t){return{ok:!1,reason:t.message}}}var ve={production:{supabaseUrl:"https://sttpwvjbpsetzbhrkohl.supabase.co",anonKey:"sb_publishable_cyuIPsrQa5Ye7lqFxjnknQ_ozDuwwzp",appBase:"https://conform.tools"},staging:{supabaseUrl:"https://slxggvbvgzkiwojcgykx.supabase.co",anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNseGdndmJ2Z3praXdvamNneWt4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEyODUzMTksImV4cCI6MjA4Njg2MTMxOX0.b18iDsWftny0k9VmOCcbN6kLlyZsZ7GULn_jRH9CE9I",appBase:"https://beta.conform.tools"}};function a(){let e=l("CONFORM_ENV")==="staging"?"staging":"production",t=ve[e];return{env:e,supabaseUrl:l("CONFORM_SUPABASE_URL")??t.supabaseUrl,anonKey:l("CONFORM_SUPABASE_ANON_KEY")??t.anonKey,appBase:l("CONFORM_APP_BASE")??t.appBase}}var Se=600*1e3,ie=72*3600*1e3,Ee=300*1e3,E=()=>u(g(),a().env==="production"?"auth.json":`auth-${a().env}.json`);async function M(){for(let e of new Set([E(),u(g(),"auth.json")]))try{let t=JSON.parse(await y(e));if(t.env===a().env&&t.access_token)return t}catch{}return null}async function Pe(){try{for await(let e of X(g())){if(!/^auth(?:-(\w+))?\.json$/.exec(e.name))continue;let n=JSON.parse(await y(u(g(),e.name)));if(n.access_token&&n.env&&n.env!==a().env)return{other_env:n.env}}}catch{}return{}}async function R(e){await C(g()),await $(E(),JSON.stringify(e)),await K(E(),384)}var se=6e3,P=0,ce=()=>Date.now()<P,le=()=>{P=Date.now()+6e4};function We(){P=0}async function ue(e){if(e.expires_at-60>Date.now()/1e3)return e.access_token;if(ce())return null;let t=a();try{let n=await fetch(`${t.supabaseUrl}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{apikey:t.anonKey,"content-type":"application/json"},body:JSON.stringify({refresh_token:e.refresh_token}),signal:AbortSignal.timeout(se)}).catch(o=>{throw le(),o});if(!n.ok)return n.status===400||n.status===401?"":null;let r=await n.json();return e.access_token=r.access_token,r.refresh_token&&(e.refresh_token=r.refresh_token),e.expires_at=r.expires_at??Math.floor(Date.now()/1e3)+(r.expires_in??3600),await R(e),e.access_token}catch{return null}}async function Qe(){let e=await M();return e&&await ue(e)||null}var b=null;function ae(e,t){return{signed_in:!0,entitled:e.entitled,env:a().env,email:e.email,access:e.access,tier:e.tier,trial_days_remaining:e.trial_days_remaining,source:t,...e.entitled?{}:{reason:"not_entitled"},...e.invite_only?{invite_only:!0}:{}}}async function pe(e={}){let t=await oe();if(t?.ok)return{signed_in:!!await M().catch(()=>null),entitled:!0,env:a().env,email:t.data.email,access:"licence",tier:t.data.tier,source:"licence"};let n=await Ae(e);return t&&!n.entitled?{...n,licence_error:t.reason}:n}async function Ae(e){if(!e.force&&b&&Date.now()-b.at<Se)return{...b.status,source:"cache"};let t=a(),n=await M();if(!n)return{signed_in:!1,entitled:!1,env:t.env,reason:"not_signed_in",...await Pe()};let r=await ue(n);if(r==="")return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(r&&!ce())try{let o=(await T())[0],i=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/entitlement${o?`?machine=${o}`:""}`,{headers:{authorization:`Bearer ${r}`,apikey:t.anonKey},signal:AbortSignal.timeout(se)}).catch(s=>{throw le(),s});if(i.status===401||i.status===403)return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(i.ok){let{grant:s,...d}=(await i.json()).data;o&&await ke(s),n.last_entitlement=d,n.last_entitlement_at=Date.now(),await R(n);let m=ae(d,"live");return b={at:Date.now(),status:m},m}}catch{}if(n.last_entitlement&&n.last_entitlement_at&&Date.now()-n.last_entitlement_at<ie){let o=ie-(Date.now()-n.last_entitlement_at);return{...ae(n.last_entitlement,"grace"),grace_remaining_h:Math.round(o/36e4)/10}}return{signed_in:!0,entitled:!1,env:t.env,reason:"offline_grace_expired"}}async function ke(e){try{if(!e)return await v(k());await C(A()),await $(k(),e)}catch{}}function Le(e){return e.source==="licence"?`${e.email} \xB7 machine licence (${e.tier}) \u2014 runs offline, no account check`:Oe(e)+(e.licence_error?`
|
|
6
|
+
(the machine licence was not used: ${e.licence_error})`:"")}function Oe(e){let t=a();if(!e.signed_in)return`not signed in (${t.env})${e.other_env?`; you are signed in to ${e.other_env} only (each server keeps its own sign-in)`:""}. Run the account_login tool, or \`npx -y conformtools@latest login\` in a terminal.`;if(e.reason==="auth_rejected")return"signed-in session was rejected (expired or revoked) \u2014 sign in again with account_login.";if(e.reason==="offline_grace_expired")return"offline for more than 72 h since the last account check \u2014 reconnect and run account_status.";let n=`${e.email??"(unknown email)"} \xB7 ${t.env}`;if(!e.entitled&&e.invite_only)return`${n}
|
|
7
|
+
the conform.tools engine (the MCP and the app) is invite-only for now, and ${e.email??"this account"} is not on the list. If that is the wrong Google account, run account_logout, then account_login with the invited one.`;if(!e.entitled)return`${n}
|
|
8
|
+
no active plan on ${e.email??"this account"}: the trial has ended and there is no subscription. If that is the wrong Google account, run account_logout, then account_login and pick the account with the plan; otherwise choose a plan at ${t.appBase}/pricing, then run account_status.`;let r=e.access==="trial"?`trial, ${e.trial_days_remaining??"?"} day(s) left`:e.access==="allowlist"?"invited (early access)":`subscribed${e.tier?` (${e.tier})`:""}`,o=L(e),i=o?` \xB7 includes ${[o.web&&"the web tools",o.mcp&&"the MCP",o.app&&"the app"].filter(Boolean).join(", ")||"the web tools"}`:"";return`${n}
|
|
9
|
+
${r}${i}${e.source==="grace"?` \u2014 offline, using the last check (${e.grace_remaining_h} h of grace left)`:""}`}function L(e){if(e.access==="trial")return Z;let t=(e.tier??"").toLowerCase();return(t==="enterprise"?_.studio:_[t])?.includes??null}var de=()=>pe();function et(e){de=e}async function me(){let e=await de();if(e.entitled)return e;let t=e.signed_in&&e.reason==="not_entitled"?"not_entitled":"not_signed_in";throw new h(t,Le(e),{account:e})}async function tt(){let e=await me();if(e.source==="licence"||L(e)?.mcp!==!1)return e;throw new h("not_entitled",`The conform.tools MCP is in the MCP plan ($${_.indie.monthly}/mo) and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${e.tier})`:""}`} includes Timeline Exchange and Conform Connect on ${a().appBase}, but not the engine on this machine. Upgrade at ${a().appBase}/pricing, then run account_status.`,{account:e,needs:"mcp"})}async function nt(){let e=await me();if(e.source==="licence"||L(e)?.app)return e;throw new h("not_entitled",`The conform.tools app is in the App plan ($${_.pro.monthly}/mo). ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${e.tier})`:""}`} does not include the app${L(e)?.mcp?" \u2014 it includes the conform.tools MCP: use it from Claude, Claude Code or any MCP client":""}. Upgrade at ${a().appBase}/pricing, then reopen the app.`,{account:e,needs:"app"})}var S=null;function rt(e={}){if(S)return S;let t=a(),n=crypto.randomUUID().replaceAll("-","");return S=new Promise((r,o)=>{let i=!1,s=c=>{i||(i=!0,clearTimeout(m),setTimeout(()=>d.close(),250),S=null,c())},d=V({hostname:"127.0.0.1",port:0,onListen:async c=>{let p=`${t.appBase}/plugin-auth?client=engine&port=${c}&state=${n}`,f=await q(p);e.onUrl?.(p,f)}},async c=>{let p=new URL(c.url);if(p.pathname!=="/callback")return new Response("not found",{status:404});let f=p.searchParams,U=f.get("access_token")??"",j=f.get("refresh_token")??"",O=!!U&&!!j&&f.get("state")===n;if(O){let B=Number(f.get("expires_at"));await R({env:t.env,access_token:U,refresh_token:j,expires_at:B>0?B:Math.floor(Date.now()/1e3)+3600}),b=null,P=0,pe({force:!0}).then(I=>s(()=>r(I)),I=>s(()=>o(I)))}return new Response(Ie(O),{status:O?200:400,headers:{"content-type":"text/html; charset=utf-8"}})}),m=setTimeout(()=>s(()=>o(new h("not_signed_in","sign-in was not completed within 5 minutes"))),e.timeoutMs??Ee)}),S}async function ot(){b=null,P=0,await G(E())&&await v(E()),await v(k()).catch(()=>{});let e=u(g(),"auth.json");try{JSON.parse(await y(e)).env===a().env&&await v(e)}catch{}}function Ie(e){let[t,n]=e?["Connected","You're signed in \u2014 you can close this tab."]:["Sign-in failed","Please try again."];return`<!doctype html><meta charset=utf-8><title>conform.tools</title><body style='font:16px -apple-system,Helvetica,Arial,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7;color:#1d1d1f'><div style='text-align:center'><div style='font-size:22px;font-weight:700'>conform<span style='color:#ff3c00'>.tools</span></div><div style='margin-top:14px;font-size:20px;font-weight:600'>${t}</div><div style='margin-top:6px;color:#6e6e73'>${n}</div></div></body>`}export{Be as a,Fe as b,re as c,a as d,se as e,We as f,Qe as g,pe as h,Le as i,L as j,et as k,me as l,tt as m,nt as n,rt as o,ot as p};
|
|
@@ -17,4 +17,4 @@ Sec-WebSocket-Version: 13\r
|
|
|
17
17
|
`));let p=m.alloc(0),u=f=>{p=m.concat([p,f]);let l=p.indexOf(`\r
|
|
18
18
|
\r
|
|
19
19
|
`);if(l<0)return;c.off("data",u);let d=p.subarray(0,l).toString("latin1").split(`\r
|
|
20
|
-
`),h=d.find(y=>/^sec-websocket-accept:/i.test(y))?.split(":")[1]?.trim();if(!/^HTTP\/1\.1 101/.test(d[0])||h!==t)return i(new Error(`${a.host} refused the WebSocket upgrade: ${d[0]}`));c.setTimeout(0),c.off("error",i);let g=p.subarray(l+4),v=J(c,null,e.maxBytes,!0);g.length&&c.emit("data",g),s(v)};c.on("data",u)})}import{existsSync as te,readFileSync as ne}from"node:fs";var $="0.6.
|
|
20
|
+
`),h=d.find(y=>/^sec-websocket-accept:/i.test(y))?.split(":")[1]?.trim();if(!/^HTTP\/1\.1 101/.test(d[0])||h!==t)return i(new Error(`${a.host} refused the WebSocket upgrade: ${d[0]}`));c.setTimeout(0),c.off("error",i);let g=p.subarray(l+4),v=J(c,null,e.maxBytes,!0);g.length&&c.emit("data",g),s(v)};c.on("data",u)})}import{existsSync as te,readFileSync as ne}from"node:fs";var $="0.6.8";function Q(o,e){let a=o.split("-")[0].split(".").map(Number),n=e.split("-")[0].split(".").map(Number);for(let t=0;t<Math.max(a.length,n.length);t++){let s=(a[t]||0)-(n[t]||0);if(s)return s>0}return!1}var Z=null;function q(){return N("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):Z??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(o=>o.ok?o.json():null).then(o=>typeof o?.version=="string"?o.version:null).catch(()=>null)}var ee="run npx -y --prefer-online conformtools@latest mcp (in the MCP client config too; --prefer-online makes npx re-check npm instead of reusing its cached copy), then restart the MCP client; if an old global install is shadowing it: npm rm -g conformtools";async function ve(){let o=await q();return`conformtools ${$}`+(o&&Q(o,$)?` \u2014 update available: ${o} \u2192 ${ee}`:"")}var k=1,re=[48127,48128,48129,48130,48131,48132,48133,48134],oe=5e3,V=4,se=8*1024*1024,b=class extends Error{constructor(a,n){super(n);this.code=a}},_=()=>P(A(),"host-bridge","pairing.json"),B="/avid-panel/",ie="/avid-panel/pairing",G="avid",z={"index.html":"text/html; charset=utf-8","panel.js":"text/javascript; charset=utf-8","panel.css":"text/css; charset=utf-8","icon.svg":"image/svg+xml"},ae="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self' ws://localhost:{port} ws://127.0.0.1:{port} http://localhost:* http://127.0.0.1:* https://localhost:* https://127.0.0.1:*; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",X=o=>[`http://localhost:${o}`,`http://127.0.0.1:${o}`];function ce(){for(let o of["./avid/panel/web-dist/","./avid-panel/"]){let e=O(new URL(o,import.meta.url));if(te(P(e,"index.html")))return e}return null}function le(){let o=new Uint8Array(32);return crypto.getRandomValues(o),Array.from(o,e=>e.toString(16).padStart(2,"0")).join("")}var H=class{constructor(){this.token=le();this.port=0;this.live=new Map;this.waiters=[];this.seq=0;this.events=[]}async start(e=re){let a;for(let n of e)try{this.server=await F({hostname:"127.0.0.1",port:n,path:"/host-bridge",maxBytes:se,onHttp:(t,s,r)=>this.servePanel(t,s,r)},t=>this.accept(t)),this.port=this.server.port;break}catch(t){a=t}if(!this.server)throw new b("no_port",`every host-bridge port (${e.join(", ")}) is taken: ${a}`);await W(P(A(),"host-bridge")),await M(_(),JSON.stringify({protocol:k,url:`ws://127.0.0.1:${this.port}/host-bridge`,port:this.port,token:this.token})),await L(_(),384)}async stop(){for(let e of this.live.values())e.conn.close(1001,"engine stopping");this.live.clear(),await this.server?.close();try{JSON.parse(await R(_())).token===this.token&&await I(_())}catch{}}peers(){return[...this.live.values()].map(e=>e.peer)}peer(e){return this.live.get(e)?.peer}async waitFor(e,a){return this.live.has(e)?this.peer(e):(await Promise.race([new Promise(n=>this.waiters.push({host:e,resolve:n})),new Promise(n=>setTimeout(n,a))]),this.peer(e))}request(e,a,n={},t=3e4){let s=this.live.get(e);if(!s)return Promise.reject(new b("not_connected",`${e}: its panel is not connected`));let r=`r${++this.seq}`;return new Promise((c,i)=>{let p=setTimeout(()=>{s.pending.delete(r),i(new b("timeout",`${e}: no answer to ${a} within ${Math.round(t/1e3)} s`))},t);s.pending.set(r,{resolve:c,reject:i,timer:p}),s.conn.send(JSON.stringify({type:"request",id:r,method:a,params:n}))})}servePanel(e,a,n){let t=(e.url??"").split("?")[0];if(!t.startsWith(B)&&t!==B.slice(0,-1))return!1;let s=(f,l,d,h=!1)=>{let g=typeof d=="string"?new TextEncoder().encode(d):d;return a.writeHead(f,{"content-type":l,"content-length":String(g.length),"cache-control":"no-store","x-content-type-options":"nosniff","referrer-policy":"no-referrer","cross-origin-resource-policy":"same-origin","x-frame-options":"DENY","content-security-policy":ae.replaceAll("{port}",String(n))}),a.end(h?void 0:g),!0},r=(f,l)=>s(f,"text/plain; charset=utf-8",l),c=f=>{let l=e.headers[f];return typeof l=="string"?l:void 0},i=(c("host")??"").toLowerCase();if(i!==`localhost:${n}`&&i!==`127.0.0.1:${n}`)return r(421,"misdirected request");if(t===ie)return e.method==="POST"&&X(n).includes(c("origin")??"")&&(c("sec-fetch-site")??"same-origin")==="same-origin"&&c("x-ct-panel")==="1"&&(c("content-length")??"0").trim()==="0"?s(200,"application/json",JSON.stringify({protocol:k,url:`ws://localhost:${n}/host-bridge`,port:n,token:this.token})):r(403,"forbidden");if(e.method!=="GET"&&e.method!=="HEAD")return r(405,"method not allowed");let p=t.slice(B.length)||"index.html",u=ce();return!z[p]||!u?r(404,"not found"):s(200,z[p],ne(P(u,p)),e.method==="HEAD")}accept(e){let a=!!e.origin&&X(this.port).includes(e.origin);if(e.origin&&/^https?:/i.test(e.origin)&&!a){e.send(JSON.stringify({type:"error",code:"origin_refused",message:"web pages may not use the host bridge"})),e.close(1008,"origin");return}let n=null,t=setTimeout(()=>{n||(e.send(JSON.stringify({type:"error",code:"hello_timeout",message:"no hello"})),e.close(1008,"hello"))},oe);e.onMessage(s=>{let r;try{r=JSON.parse(s)}catch{return}if(!n){let i=(l,d)=>{clearTimeout(t),e.send(JSON.stringify({type:"error",code:l,message:d})),e.close(1008,l)};if(r.type!=="hello")return i("hello_expected","the first frame must be hello");if(r.protocol!==k)return i("protocol_mismatch",`this engine speaks protocol ${k}`);if(r.token!==this.token)return i("bad_token","the pairing token does not match: re-read the pairing file");let p=r.host??{},u=String(p.id??"");if(!/^[a-z][a-z0-9_-]{1,31}$/.test(u))return i("bad_host","host.id is missing or malformed");if(a&&u!==G)return i("origin_mismatch",`a connection from the panel page may only be host ${G}`);if(!this.live.has(u)&&this.live.size>=V)return i("too_many_peers",`at most ${V} panels`);clearTimeout(t),this.live.get(u)?.conn.close(1e3,"replaced by a newer connection"),n=u;let f={id:u,name:String(p.name??u),version:String(p.version??""),platform:String(p.platform??""),capabilities:Array.isArray(r.capabilities)?r.capabilities.map(String):[],optional_verbs:Array.isArray(r.optional_verbs)?r.optional_verbs.map(String):[]};this.live.set(u,{peer:f,conn:e,pending:new Map}),e.send(JSON.stringify({type:"welcome",protocol:k,app:{name:"conformtools",version:$}})),this.waiters=this.waiters.filter(l=>l.host===u?(l.resolve(),!1):!0);return}let c=this.live.get(n);if(!(!c||c.conn!==e))if(r.type==="response"){let i=c.pending.get(String(r.id));if(!i)return;if(c.pending.delete(String(r.id)),clearTimeout(i.timer),r.ok)i.resolve(r.result??null);else{let p=r.error??{};i.reject(new b(p.code??"peer_error",`${n}: ${p.message??p.code??"error"}`))}}else r.type==="event"&&(this.events.push({host:n,name:String(r.name),data:r.data}),this.events.length>200&&this.events.shift())}),e.onClose(()=>{if(clearTimeout(t),!n)return;let s=this.live.get(n);if(s?.conn===e){for(let r of s.pending.values())clearTimeout(r.timer),r.reject(new b("disconnected",`${n}: the panel disconnected`));this.live.delete(n)}})}},E=null;function Pe(){return E??=(async()=>{let o=new H;return await o.start(),o})(),E.catch(()=>{E=null}),E}function ke(){E=null}export{$ as a,Q as b,q as c,ee as d,ve as e,de as f,k as g,re as h,b as i,_ as j,B as k,X as l,H as m,Pe as n,ke as o};
|